1"use strict";(self.webpackChunkfrontend=self.webpackChunkfrontend||[]).push([[573],{9332(e,t,s){s.d(t,{cn:()=>r});var a=s(72004),l=s(79800);function r(){for(var e=arguments.length,t=new Array(e),s=0;s<e;s++)t[s]=arguments[s];return(0,l.QP)((0,a.$)(t))}},41111(e,t,s){s.d(t,{$:()=>m});var a=s(89379),l=s(53986),r=s(9950),i=s(92962),n=s(94364),c=s(9332),d=s(44414);const o=["className","variant","size","asChild"],x=(0,n.F)("inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0 font-body tracking-wide",{variants:{variant:{default:"bg-primary text-primary-foreground shadow hover:bg-primary/90",destructive:"bg-destructive text-destructive-foreground shadow-sm hover:bg-destructive/90",outline:"border border-input shadow-sm hover:bg-accent hover:text-accent-foreground",secondary:"bg-secondary text-secondary-foreground shadow-sm hover:bg-secondary/80",ghost:"hover:bg-accent hover:text-accent-foreground",link:"text-primary underline-offset-4 hover:underline"},size:{default:"h-9 px-4 py-2",sm:"h-8 rounded-md px-3 text-xs",lg:"h-10 rounded-md px-8",icon:"h-9 w-9"}},defaultVariants:{variant:"default",size:"default"}}),m=r.forwardRef((e,t)=>{let{className:s,variant:r,size:n,asChild:m=!1}=e,p=(0,l.A)(e,o);const h=m?i.DX:"button";return(0,d.jsx)(h,(0,a.A)({className:(0,c.cn)(x({variant:r,size:n,className:s})),ref:t},p))});m.displayName="Button"},50573(e,t,s){s.r(t),s.d(t,{default:()=>qe});var a=s(9950),l=s(92994),r=s(26910),i=s(24276),n=s(29975),c=s(80903),d=s(19201),o=s(34700),x=s(23198),m=s(79408),p=s(97104),h=s(45536),u=s(30855),g=s(58406),j=s(81946),v=s(89318),b=s(96479),f=s(29126),N=s(15332),B=s(30772),y=s(90983),A=s(89379),w=s(21570),k=s(71742),E=s(86311),F=s(52828),_=s(94119),C=s(41111),S=s(94779),D=s(44414);const z="https://peerlessetiquette.com",T=()=>{var e,t,s,l,i,n,c,d,x,m,p,h,u,g,j,v,b;const[f,N]=(0,a.useState)(null),[B,y]=(0,a.useState)(!0),[T,M]=(0,a.useState)(!1),[I,L]=(0,a.useState)(null);(0,a.useEffect)(()=>{R()},[]);const R=async()=>{try{const e=await r.A.get("".concat(z,"/api/design/settings"));N(e.data)}catch(e){L({type:"error",text:"Failed to load design settings"})}finally{y(!1)}},P=(e,t)=>{N(s=>(0,A.A)((0,A.A)({},s),{},{colors:(0,A.A)((0,A.A)({},s.colors),{},{[e]:t})}))},q=(e,t)=>{N(s=>(0,A.A)((0,A.A)({},s),{},{fonts:(0,A.A)((0,A.A)({},s.fonts),{},{[e]:t})}))};return B?(0,D.jsx)("div",{className:"flex items-center justify-center h-64",children:(0,D.jsx)("div",{className:"text-[#A58958] tracking-widest",children:"Loading settings..."})}):(0,D.jsxs)("div",{className:"space-y-6",children:[(0,D.jsxs)("div",{className:"flex items-center justify-between",children:[(0,D.jsxs)("div",{children:[(0,D.jsx)("img",{loading:"lazy",src:"/assets/crest.png",alt:"",className:"w-16 h-16 mx-auto mb-5 opacity-90"}),(0,D.jsx)("h1",{className:"hero-title text-[#2B2B2B] text-2xl mb-2",children:"DESIGN SETTINGS"}),(0,D.jsx)("p",{className:"text-[#5e5e5e] text-sm",children:"Control colors, fonts, and styling across your entire site"})]}),(0,D.jsxs)("div",{className:"flex gap-3",children:[(0,D.jsxs)(C.$,{onClick:async()=>{if(window.confirm("Reset all design settings to defaults? This cannot be undone.")){M(!0);try{const e=localStorage.getItem("adminToken"),t=await r.A.post("".concat(z,"/api/design/settings/reset"),{},{headers:{Authorization:"Bearer ".concat(e)}});N(t.data.settings),L({type:"success",text:"Settings reset to defaults"})}catch(e){L({type:"error",text:"Failed to reset settings"})}finally{M(!1)}}},variant:"outline",className:"border-[#1B7B9E]/25 text-[#2B2B2B] hover:bg-white/5",children:[(0,D.jsx)(w.A,{size:16,className:"mr-2"}),"Reset"]}),(0,D.jsxs)(C.$,{onClick:async()=>{M(!0),L(null);try{const e=localStorage.getItem("adminToken");await r.A.put("".concat(z,"/api/design/settings"),{colors:f.colors,fonts:f.fonts,custom_css:f.custom_css},{headers:{Authorization:"Bearer ".concat(e)}}),L({type:"success",text:"Design settings saved successfully! Changes will apply site-wide."})}catch(e){L({type:"error",text:"Failed to save settings. Please try again."})}finally{M(!1)}},disabled:T,className:"navy-cta bg-[#22364A] hover:opacity-90 rounded-full text-[#2B2B2B]",children:[(0,D.jsx)(k.A,{size:16,className:"mr-2"}),T?"Saving...":"Save Changes"]})]})]}),I&&(0,D.jsxs)("div",{className:"flex items-center gap-3 p-4 border ".concat("success"===I.type?"bg-green-500/10 border-green-500/20 text-green-400":"bg-red-500/10 border-red-500/20 text-red-400"),children:["success"===I.type?(0,D.jsx)(E.A,{size:18}):(0,D.jsx)(F.A,{size:18}),(0,D.jsx)("span",{children:I.text})]}),(0,D.jsxs)("div",{className:"bg-[#f3f0e8] border border-[#1B7B9E]/20 p-6",children:[(0,D.jsxs)("div",{className:"flex items-center gap-3 mb-6",children:[(0,D.jsx)(o.A,{size:20,className:"text-[#A58958]"}),(0,D.jsx)("h2",{className:"text-[#2B2B2B] text-lg",children:"Colors"})]}),(0,D.jsx)("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-6",children:[{key:"primary_color",label:"Primary Color (Gold)",description:"Main brand color used for accents and buttons"},{key:"secondary_color",label:"Secondary Color (Dark)",description:"Dark background color"}
1,{key:"background_color",label:"Background Color",description:"Light sections background"},{key:"text_color",label:"Text Color",description:"Main body text color"},{key:"accent_color",label:"Accent Color",description:"Secondary accent color"},{key:"heading_color",label:"Heading Color",description:"Color for headings"},{key:"muted_color",label:"Muted Text Color",description:"Subtle text and labels"},{key:"hero_overlay",label:"Hero Overlay",description:"Dark overlay on hero images"},{key:"card_background",label:"Card Background",description:"Background for cards and sections"},{key:"border_color",label:"Border Color",description:"Borders and dividers"}].map(e=>{var t,s;return(0,D.jsxs)("div",{className:"space-y-2",children:[(0,D.jsx)("label",{className:"text-[#2B2B2B] text-sm",children:e.label}),(0,D.jsxs)("div",{className:"flex gap-3",children:[(0,D.jsx)("input",{type:"color",value:(null===f||void 0===f||null===(t=f.colors)||void 0===t?void 0:t[e.key])||"#f3f0e8",onChange:t=>P(e.key,t.target.value),className:"w-14 h-10 rounded cursor-pointer bg-transparent border border-[#1B7B9E]/25"}),(0,D.jsx)(S.p,{type:"text",value:(null===f||void 0===f||null===(s=f.colors)||void 0===s?void 0:s[e.key])||"",onChange:t=>P(e.key,t.target.value),className:"flex-1 bg-white/5 border-[#1B7B9E]/20 text-[#2B2B2B] h-10",placeholder:"#f3f0e8"})]}),(0,D.jsx)("p",{className:"text-[#2B2B2B]/30 text-xs",children:e.description})]},e.key)})})]}),(0,D.jsxs)("div",{className:"bg-[#f3f0e8] border border-[#1B7B9E]/20 p-6",children:[(0,D.jsxs)("div",{className:"flex items-center gap-3 mb-6",children:[(0,D.jsx)(_.A,{size:20,className:"text-[#A58958]"}),(0,D.jsx)("h2",{className:"text-[#2B2B2B] text-lg",children:"Typography"})]}),(0,D.jsxs)("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-6",children:[(0,D.jsxs)("div",{className:"space-y-2",children:[(0,D.jsx)("label",{className:"text-[#2B2B2B] text-sm",children:"Heading Font"}),(0,D.jsx)("select",{value:(null===f||void 0===f||null===(e=f.fonts)||void 0===e?void 0:e.heading_font)||"Lato",onChange:e=>q("heading_font",e.target.value),className:"w-full h-10 px-3 bg-white/5 border border-[#1B7B9E]/20 text-[#2B2B2B] rounded-none",children:["Lato","Playfair Display","Lora","Merriweather","Libre Baskerville","Crimson Text","Georgia","Times New Roman"].map(e=>(0,D.jsx)("option",{value:e,style:{fontFamily:e},children:e},e))}),(0,D.jsx)("p",{className:"text-[#2B2B2B]/30 text-xs",children:"Font used for headings and titles"})]}),(0,D.jsxs)("div",{className:"space-y-2",children:[(0,D.jsx)("label",{className:"text-[#2B2B2B] text-sm",children:"Body Font"}),(0,D.jsx)("select",{value:(null===f||void 0===f||null===(t=f.fonts)||void 0===t?void 0:t.body_font)||"Lato",onChange:e=>q("body_font",e.target.value),className:"w-full h-10 px-3 bg-white/5 border border-[#1B7B9E]/20 text-[#2B2B2B] rounded-none",children:["Lato","Inter","Manrope","Open Sans","Lato","Roboto","Source Sans Pro","Montserrat"].map(e=>(0,D.jsx)("option",{value:e,children:e},e))}),(0,D.jsx)("p",{className:"text-[#2B2B2B]/30 text-xs",children:"Font used for body text and paragraphs"})]}),(0,D.jsxs)("div",{className:"space-y-2",children:[(0,D.jsx)("label",{className:"text-[#2B2B2B] text-sm",children:"Heading Weight"}),(0,D.jsxs)("select",{value:(null===f||void 0===f||null===(s=f.fonts)||void 0===s?void 0:s.heading_weight)||"400",onChange:e=>q("heading_weight",e.target.value),className:"w-full h-10 px-3 bg-white/5 border border-[#1B7B9E]/20 text-[#2B2B2B] rounded-none",children:[(0,D.jsx)("option",{value:"300",children:"Light (300)"}),(0,D.jsx)("option",{value:"400",children:"Regular (400)"}),(0,D.jsx)("option",{value:"500",children:"Medium (500)"}),(0,D.jsx)("option",{value:"600",children:"Semi-Bold (600)"}),(0,D.jsx)("option",{value:"700",children:"Bold (700)"})]})]}),(0,D.jsxs)("div",{className:"space-y-2",children:[(0,D.jsx)("label",{className:"text-[#2B2B2B] text-sm",children:"Body Weight"}),(0,D.jsxs)("select",{value:(null===f||void 0===f||null===(l=f.fonts)||void 0===l?void 0:l.body_weight)||"300",onChange:e=>q("body_weight",e.target.value),className:"w-full h-10 px-3 bg-white/5 border border-[#1B7B9E]/20 text-[#2B2B2B] rounded-none",children:[(0,D.jsx)("option",{value:"300",children:"Light (300)"}),(0,D.jsx)("option",{value:"400",children:"Regular (400)"}),(0,D.jsx)("option",{value:"500",children:"Medium (500)"})]})]}),(0,D.jsxs)("div",{className:"space-y-2",children:[(0,D.jsx)("label",{className:"text-[#2B2B2B] text-sm",children:"Line Height"}),(0,D.jsx)(S.p,{type:"number",step:"0.1",min:"1",max:"3",value:(null===f||void 0===f||null===(i=f.fonts)||void 0===i?void 0:i.line_height)||1.6,onChange:e=>q("line_height",parseFloat(e.target.value)),className:"bg-white/5 border-[#1B7B9E]/20 text-[#2B2B2B] h-10"}),(0,D.jsx)("p",{className:"text-[#2B2B2B]/30 text-xs",children:"Spacing between lines of text (1.4 - 2.0 recommended)"})]}),(0,D.jsxs)("div",{className:"space-y-2",children:[(0,D.jsx)("label",{className:"text-[#2B2B2B] text-sm",children:"Heading Letter Spacing"}),(0,D.jsx)(S.p,{type:"text",value:(null===f||void 0===f||null===(n=f.fonts)||void 0===n?void 0:n.letter_spacing_heading)||"0.08em",onCh
1ange:e=>q("letter_spacing_heading",e.target.value),className:"bg-white/5 border-[#1B7B9E]/20 text-[#2B2B2B] h-10",placeholder:"0.08em"})]})]})]}),(0,D.jsxs)("div",{className:"bg-[#f3f0e8] border border-[#1B7B9E]/20 p-6",children:[(0,D.jsx)("h2",{className:"text-[#2B2B2B] text-lg mb-6",children:"Live Preview"}),(0,D.jsxs)("div",{className:"p-8 border border-[#1B7B9E]/20",style:{backgroundColor:(null===f||void 0===f||null===(c=f.colors)||void 0===c?void 0:c.background_color)||"#FFFFFF",color:(null===f||void 0===f||null===(d=f.colors)||void 0===d?void 0:d.text_color)||"#2B2B2B"},children:[(0,D.jsx)("h1",{className:"text-3xl mb-4 uppercase",style:{fontFamily:"'".concat((null===f||void 0===f||null===(x=f.fonts)||void 0===x?void 0:x.heading_font)||"Lato","', serif"),fontWeight:(null===f||void 0===f||null===(m=f.fonts)||void 0===m?void 0:m.heading_weight)||400,letterSpacing:(null===f||void 0===f||null===(p=f.fonts)||void 0===p?void 0:p.letter_spacing_heading)||"0.08em",color:(null===f||void 0===f||null===(h=f.colors)||void 0===h?void 0:h.heading_color)||"#2B2B2B"},children:"The Art of Refined Living"}),(0,D.jsx)("p",{style:{fontFamily:"'".concat((null===f||void 0===f||null===(u=f.fonts)||void 0===u?void 0:u.body_font)||"Lato","', sans-serif"),fontWeight:(null===f||void 0===f||null===(g=f.fonts)||void 0===g?void 0:g.body_weight)||300,lineHeight:(null===f||void 0===f||null===(j=f.fonts)||void 0===j?void 0:j.line_height)||1.6},children:"Experience the timeless elegance of proper etiquette with our comprehensive courses designed for the modern world. Master the art of refined living."}),(0,D.jsx)("button",{className:"mt-4 px-6 py-2 text-sm uppercase tracking-wider",style:{backgroundColor:(null===f||void 0===f||null===(v=f.colors)||void 0===v?void 0:v.primary_color)||"#A58958",color:(null===f||void 0===f||null===(b=f.colors)||void 0===b?void 0:b.secondary_color)||"#2B2B2B"},children:"Get Started"})]})]}),(0,D.jsxs)("div",{className:"bg-[#f3f0e8] border border-[#1B7B9E]/20 p-6",children:[(0,D.jsx)("h2",{className:"text-[#2B2B2B] text-lg mb-4",children:"Custom CSS (Advanced)"}),(0,D.jsx)("textarea",{value:(null===f||void 0===f?void 0:f.custom_css)||"",onChange:e=>N(t=>(0,A.A)((0,A.A)({},t),{},{custom_css:e.target.value})),className:"w-full h-40 p-4 bg-white/5 border border-[#1B7B9E]/20 text-[#2B2B2B] font-mono text-sm",placeholder:"/* Add custom CSS here */"}),(0,D.jsx)("p",{className:"text-[#2B2B2B]/30 text-xs mt-2",children:"Add custom CSS rules to override any styling. Be careful - invalid CSS may break the site."})]})]})};var M=s(11082),I=s(66987),L=s(46327),R=s(12550),P=s(77834),q=s(13147),U=s(81830),G=s(84814),$=s(72420);const W="https://peerlessetiquette.com",O=()=>{const[e,t]=(0,a.useState)([]),[s,l]=(0,a.useState)([]),[i,n]=(0,a.useState)(!0),[c,d]=(0,a.useState)(!1),[o,m]=(0,a.useState)(!1),[p,h]=(0,a.useState)(null),[u,g]=(0,a.useState)("grid"),[j,v]=(0,a.useState)(""),[f,N]=(0,a.useState)("all"),[B,y]=(0,a.useState)(!1),[A,w]=(0,a.useState)(null),[k,F]=(0,a.useState)("library");(0,a.useEffect)(()=>{_(),z()},[]);const _=async()=>{try{const e=localStorage.getItem("adminToken"),s=await r.A.get("".concat(W,"/api/design/media"),{headers:{Authorization:"Bearer ".concat(e)}});t(s.data.media||[])}catch(e){console.error("Failed to fetch media:",e)}finally{n(!1)}},z=async()=>{try{const e=localStorage.getItem("adminToken"),t=await r.A.get("".concat(W,"/api/design/site-images"),{headers:{Authorization:"Bearer ".concat(e)}});l(t.data.slots||[])}catch(e){console.error("Failed to fetch site images:",e)}},T=(0,a.useCallback)(e=>{e.preventDefault(),e.stopPropagation(),"dragenter"===e.type||"dragover"===e.type?y(!0):"dragleave"===e.type&&y(!1)},[]),O=(0,a.useCallback)(e=>{e.preventDefault(),e.stopPropagation(),y(!1),e.dataTransfer.files&&e.dataTransfer.files[0]&&H(e.dataTransfer.files)},[]),H=async e=>{if(!e||0===e.length)return;d(!0),w(null);const t=localStorage.getItem("adminToken");let s=0;for(const l of e)try{const e=new FormData;e.append("file",l),e.append("category","all"===f?"general":f),await r.A.post("".concat(W,"/api/design/media/upload"),e,{headers:{Authorization:"Bearer ".concat(t),"Content-Type":"multipart/form-data"}}),s++}catch(a){console.error("Upload failed for:",l.name,a)}w({type:"success",text:"".concat(s," file(s) uploaded successfully")}),_(),d(!1)},V=async s=>{if(window.confirm("Delete this image? This cannot be undone."))try{const a=localStorage.getItem("adminToken");await r.A.delete("".concat(W,"/api/design/media/").concat(s),{headers:{Authorization:"Bearer ".concat(a)}}),t(e.filter(e=>e.id!==s)),w({type:"success",text:"Image deleted"})}catch(a){w({type:"error",text:"Failed to delete image"})}},J=async(e,t)=>{try{const s=localStorage.getItem("adminToken"),a=e.file_url.startsWith("/")?"".concat(W).concat(e.file_url):e.file_url;await r.A.put("".concat(W,"/api/design/site-images/").concat(t),null,{headers:{Authorization:"Bearer ".concat(s)},params:{image_url:a,media_id:e.id}}),w({type:"success",text:"Image assigned to ".concat(t)}),z()}catch(s){w({type:"error",text:"Failed to assign image"})}},Y=e=>{const t=e.startsWith("/")?"".concat(W).concat(e):e;navigator.clipboard.writeText(t),w({type:"success",text:"URL copied to clipboard"})},Q=e.filter(e=>{const t="all"===f||e.category===f,s=!j||e.file_name.toLowerCase().includes(j.toLowerCase());return t&&s});return i?(0,D.jsx)("div",{className:"flex items-center justify-center h-64",children:(0,D.jsx)("div",{className:"text-[#A58958] tracking-widest",children:"Loading media..."})}):(0,D.jsxs)("div",{className:"space-y-6",children:[(0,D.jsxs)("div",{className:"flex items-center justify-between",children:[(0,D.jsxs)("div",{children:[(0,D.jsx)("img",{loading:"lazy",src:"/assets/crest.png",alt:"",className:"w-16 h-16 mx-auto mb-5 opacity-90"}),(0,D.jsx)("h1",{className:"hero-title text-[#2B2B2B] text-2xl mb-2",children:"MEDIA LIBRARY"}),(0,D.jsx)("p",{className:"text-[#5e5e5e] text-sm",children:"Upload and manage all images for your site"})]}),(0,D.jsxs)("div",{className:"flex gap-3",children:[(0,D.jsxs)(C.$,{onClick:async()=>{m(!0),w(null);try{const e=localStorage.getItem("adminToken"),t=await r.A.post("".concat(W,"/api/design/media/scan-existing"),{},{headers:{Authorization:"Bearer ".concat(e)}});w({type:"success",text:t.data.message}),_()}catch(e){w({type:"error",text:"Failed to scan existing images"})}finally{m(!1)}},disabled:o,variant:"outline",className:"border-[#1B7B9E]/25 text-[#2B2B2B] hover:bg-white/5",children:[(0,D.jsx)(M.A,{size:16,className:"mr-2"}),o?"Scanning...":"Import Existing"]}),(0,D.jsx)(C.$,{onClick:_,variant:"outline",className:"border-[#1B7B9E]/25 text-[#2B2B2B]",children:(0,D.jsx)(I.A,{size:16})}),(0,D.jsx)(C.$,{onClick:()=>g("grid"===u?"list":"grid"),variant:"outline",className:"border-[#1B7B9E]/25 text-[#2B2B2B]",children:"grid"===u?(0,D.jsx)(L.A,{size:16}):(0,D.jsx)(R.A,{size:16})})]})]}),(0,D.jsxs)("div",{className:"flex gap-4 border-b border-[#1B7B9E]/20",children:[(0,D.jsxs)("button",{onClick:()=>F("library"),className:"px-4 py-3 text-sm tracking-wider transition-colors ".concat("library"===k?"text-[#A58958] border-b-2 border-[#1B7B9E]":"text-[#5e5e5e] hover:text-[#2B2B2B]"),children:["MEDIA LIBRARY (",e.length,")"]}),(0,D.jsxs)("button",{onClick:()=>F("site-images"),className:"px-4 py-3 text-sm tracking-wider transition-colors ".concat("site-images"===k?"text-[#A58958] border-b-2 border-[#1B7B9E]":"text-[#5e5e5e] hover:text-[#2B2B2B]"),children:["SITE IMAGE SLOTS (",s.length,")"]})]}),A&&(0,D.jsxs)("div",{className:"flex items-center gap-3 p-4 border ".concat("success"===A.type?"bg-green-500/10 border-green-500/20 text-green-400":"bg-red-500/10 border-red-500/20 text-red-400"),children:["success"===A.type?(0,D.jsx)(E.A,{size:18}):(0,D.jsx)(b.A,{size:18}),(0,D.jsx)("span",{children:A.text})]}),"library"===k&&(0,D.jsxs)(D.Fragment,{children:[(0,D.jsxs)("div",{className:"border-2 border-dashed p-8 text-center transition-colors ".concat(B?"border-[#1B7B9E] bg-[#A58958]/10":"border-[#1B7B9E]/25 hover:border-white/40"),onDragEnter:T,onDragLeave:T,onDragOver:T,onDrop:O,children:[(0,D.jsx)(P.A,{size:40,className:"mx-auto mb-4 text-[#2B2B2B]/30"}),(0,D.jsx)("p",{className:"text-[#2B2B2B] mb-2",children:"Drag and drop images here"}),(0,D.jsx)("p",{className:"text-[#5e5e5e] text-sm mb-4",children:"or"}),(0,D.jsxs)("label",{className:"cursor-pointer",children:[(0,D.jsx)("input",{type:"file",multiple:!0,accept:"image/*",className:"hidden",onChange:e=>H(e.target.files)}),(0,D.jsx)("span",{className:"navy-cta px-6 py-2 bg-[#22364A] hover:opacity-90 rounded-full text-[#2B2B2B] text-sm uppercase tracking-wider",children:c?"Uploading...":"Browse Files"})]}),(0,D.jsx)("p",{className:"text-[#2B2B2B]/30 text-xs mt-4",children:"Supports: JPG, PNG, GIF, WebP, SVG (max 10MB)"})]}),(0,D.jsxs)("div",{className:"flex flex-wrap gap-4",children:[(0,D.jsx)("div",{className:"flex-1 min-w-[200px]",children:(0,D.jsxs)("div",{className:"relative",children:[(0,D.jsx)(q.A,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-[#2B2B2B]/30"}),(0,D.jsx)(S.p,{type:"text",value:j,onChange:e=>v(e.target.value),placeholder:"Search images...",className:"pl-10 bg-white/5 border-[#1B7B9E]/20 text-[#2B2B2B] h-10"})]})}),(0,D.jsx)("div",{className:"flex gap-2",children:["all","hero","section","courses","branding","general"].map(e=>(0,D.jsx)("button",{onClick:()=>N(e),className:"px-4 py-2 text-xs uppercase tracking-wider transition-colors ".concat(f===e?"bg-[#A58958] text-[#2B2B2B]":"bg-white/5 text-[#5e5e5e] hover:text-[#2B2B2B]"),children:e},e))})]}),"grid"===u?(0,D.jsx)("div",{className:"grid grid-cols-2 md:grid-cols-4 lg:grid-cols-6 gap-4",children:Q.map(e=>(0,D.jsxs)("div",{className:"group relative bg-[#f3f0e8] border border-[#1B7B9E]/20 overflow-hidden cursor-pointer ".concat((null===p||void 0===p?void 0:p.id)===e.id?"ring-2 ring-[#1B7B9E]":""),onClick:()=>h(e),children:[(0,D.jsx)("div",{className:"aspect-square",children:(0,D.jsx)("img",{loading:"lazy",src:e.file_url.startsWith("/")?"".concat(W).concat(e.file_url):e.file_url,alt:e.file_name,className:"w-full h-full object-cover"})}),(0,D.jsxs)("div",{className:"absolute inset-0 bg-[#f3f0e8]/60 opacity-0 group-hover:opacity-100 transition-opacity flex items-center justify-center gap-2",children:[(0,D.jsx)("button",{onClick:t=>{t.stopPropagation(),Y(e.file_url)},className:"p-2 bg-white/10 hover:bg-white/20 rounded",children:(0,D.jsx)(U.A,{size:16,className:"text-[#2B2B2B]"})}),(0,D.jsx)("button",{onClick:t=>{t.stopPropagation(),V(e.id)},className:"p-2 bg-red-500/20 hover:bg-red-500/40 rounded",children:(0,D.jsx)(G.A,{size:16,className:"text-red-400"})})]}),(0,D.jsx)("div",{className:"p-2",children:(0,D.jsx)("p",{className:"text-[#2B2B2B] text-xs truncate",children:e.file_name})})]},e.id))}):(0,D.jsx)("div",{className:"space-y-2",children:Q.map(e=>(0,D.jsxs)("div",{className:"flex items-center gap-4 p-3 bg-[#f3f0e8] border border-[#1B7B9E]/20 hover:border-[#1B7B9E]/25",children:[(0,D.jsx)("img",{loading:"lazy",src:e.file_url.startsWith("/")?"".concat(W).concat(e.file_url):e.file_url,alt:e.file_name,className:"w-16 h-16 object-cover"}),(0,D.jsxs)("div",{className:"flex-1",children:[(0,D.jsx)("p",{className:"text-[#2B2B2B] text-sm",children:e.file_name}),(0,D.jsxs)("p",{className:"text-[#5e5e5e] text-xs",children:[e.category," \u2022 ",(e.file_size/1024).toFixed(1)," KB"]}
1)]}),(0,D.jsxs)("div",{className:"flex gap-2",children:[(0,D.jsx)("button",{onClick:()=>Y(e.file_url),className:"p-2 text-[#5e5e5e] hover:text-[#2B2B2B]",children:(0,D.jsx)(U.A,{size:16})}),(0,D.jsx)("button",{onClick:()=>V(e.id),className:"p-2 text-red-400/50 hover:text-red-400",children:(0,D.jsx)(G.A,{size:16})})]})]},e.id))}),0===Q.length&&(0,D.jsxs)("div",{className:"text-center py-12",children:[(0,D.jsx)($.A,{size:48,className:"mx-auto mb-4 text-[#2B2B2B]/20"}),(0,D.jsx)("p",{className:"text-[#5e5e5e]",children:"No images found"}),(0,D.jsx)("p",{className:"text-[#2B2B2B]/30 text-sm mt-2",children:'Click "Import Existing" to scan for previously uploaded images'})]}),p&&(0,D.jsxs)("div",{className:"bg-[#f3f0e8] border border-[#1B7B9E]/50 p-6",children:[(0,D.jsxs)("div",{className:"flex items-center gap-4 mb-4",children:[(0,D.jsx)("img",{loading:"lazy",src:p.file_url.startsWith("/")?"".concat(W).concat(p.file_url):p.file_url,alt:p.file_name,className:"w-20 h-20 object-cover"}),(0,D.jsxs)("div",{children:[(0,D.jsx)("p",{className:"text-[#2B2B2B] font-medium",children:p.file_name}),(0,D.jsx)("p",{className:"text-[#5e5e5e] text-xs",children:"Selected - Click a slot below to assign"})]}),(0,D.jsx)("button",{onClick:()=>h(null),className:"ml-auto p-2 text-[#5e5e5e] hover:text-[#2B2B2B]",children:(0,D.jsx)(b.A,{size:18})})]}),(0,D.jsx)("div",{className:"grid grid-cols-2 md:grid-cols-4 lg:grid-cols-6 gap-2",children:s.slice(0,12).map(e=>(0,D.jsx)("button",{onClick:()=>J(p,e.id),className:"p-2 text-xs bg-white/5 hover:bg-[#22364A] hover:opacity-90 border border-[#1B7B9E]/20 hover:border-[#1B7B9E]/50 text-[#2B2B2B] hover:text-white transition-colors truncate",children:e.name},e.id))})]})]}),"site-images"===k&&(0,D.jsxs)("div",{className:"space-y-6",children:[(0,D.jsx)("p",{className:"text-[#5e5e5e] text-sm",children:"These are all the image slots across your site. Click on any slot to see options, or go to the Media Library tab to select an image first."}),["hero","section","branding","courses","misc"].map(e=>{const t=s.filter(t=>t.category===e);return 0===t.length?null:(0,D.jsxs)("div",{className:"bg-[#f3f0e8] border border-[#1B7B9E]/20 p-6",children:[(0,D.jsx)("h3",{className:"text-[#A58958] text-sm uppercase tracking-wider mb-4",children:"hero"===e?"Hero Images":"section"===e?"Section Backgrounds":"branding"===e?"Branding & Logos":"courses"===e?"Course Images":"Miscellaneous"}),(0,D.jsx)("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:t.map(e=>(0,D.jsxs)("div",{className:"border p-4 transition-colors ".concat(p?"border-[#1B7B9E]/30 hover:border-[#1B7B9E] cursor-pointer":"border-[#1B7B9E]/20"),onClick:()=>p&&J(p,e.id),children:[(0,D.jsxs)("div",{className:"flex items-center justify-between mb-3",children:[(0,D.jsx)("span",{className:"text-[#2B2B2B] text-sm",children:e.name}),(0,D.jsx)("span",{className:"text-[#2B2B2B]/30 text-xs",children:e.page})]}),e.current_image?(0,D.jsx)("img",{loading:"lazy",src:e.current_image,alt:e.name,className:"w-full h-32 object-cover",onError:e=>{e.target.style.display="none"}}):(0,D.jsxs)("div",{className:"w-full h-32 bg-white/5 flex flex-col items-center justify-center",children:[(0,D.jsx)(x.A,{size:32,className:"text-[#2B2B2B]/20 mb-2"}),(0,D.jsx)("span",{className:"text-[#2B2B2B]/30 text-xs",children:"No image assigned"})]}),p&&(0,D.jsx)("p",{className:"text-[#A58958] text-xs mt-2 text-center",children:"Click to assign selected image"})]},e.id))})]},e)})]})]})};var H=s(35097),V=s(51654),J=s(7838);const Y="https://peerlessetiquette.com",Q=()=>{var e,t;const[s,l]=(0,a.useState)([]),[i,c]=(0,a.useState)(!0),[d,o]=(0,a.useState)(!1),[x,m]=(0,a.useState)(null),[p,h]=(0,a.useState)(null),[u,g]=(0,a.useState)({username:"",password:"",name:"",email:""}),[v,f]=(0,a.useState)(!1),[N,B]=(0,a.useState)(!1);(0,a.useEffect)(()=>{const e=localStorage.getItem("adminUser");e&&h(JSON.parse(e)),y()},[]);const y=async()=>{try{const e=localStorage.getItem("adminToken"),t=await r.A.get("".concat(Y,"/api/admin-auth/team/list"),{headers:{Authorization:"Bearer ".concat(e)}});l(t.data.admins||[])}catch(t){var e;403===(null===(e=t.response)||void 0===e?void 0:e.status)&&m({type:"error",text:"Only primary admin can manage team accounts"})}finally{c(!1)}},w="primary_admin"===(null===p||void 0===p?void 0:p.role);return i?(0,D.jsx)("div",{className:"flex items-center justify-center h-64",children:(0,D.jsx)("div",{className:"text-[#A58958] tracking-widest",children:"Loading..."})}):(0,D.jsxs)("div",{className:"space-y-6",children:[(0,D.jsxs)("div",{className:"flex items-center justify-between",children:[(0,D.jsxs)("div",{children:[(0,D.jsx)("img",{loading:"lazy",src:"/assets/crest.png",alt:"",className:"w-16 h-16 mx-auto mb-5 opacity-90"}),(0,D.jsx)("h1",{className:"hero-title text-[#2B2B2B] text-2xl mb-2",children:"TEAM ADMINS"}),(0,D.jsx)("p",{className:"text-[#5e5e5e] text-sm",children:"Manage admin accounts for your team"})]}),w&&(0,D.jsxs)(C.$,{onClick:()=>o(!d),className:"navy-cta bg-[#22364A] hover:opacity-90 rounded-full text-[#2B2B2B]",children:[(0,D.jsx)(H.A,{size:16,className:"mr-2"}),"Add Team Admin"]})]}),x&&(0,D.jsxs)("div",{className:"flex items-center gap-3 p-4 border ".concat("success"===x.type?"bg-green-500/10 border-green-500/20 text-green-400":"bg-red-500/10 border-red-500/20 text-red-400"),children:["success"===x.type?(0,D.jsx)(E.A,{size:18}):(0,D.jsx)(F.A,{size:18}),(0,D.jsx)("span",{children:x.text})]}),!w&&(0,D.jsxs)("div",{className:"flex items-center gap-3 p-4 bg-yellow-500/10 border border-yellow-500/20 text-yellow-400",children:[(0,D.jsx)(j.A,{size:18}),(0,D.jsx)("span",{children:"Only the primary admin can create and manage team admin accounts."})]}),d&&w&&(0,D.jsxs)("form",{onSubmit:async e=>{e.preventDefault(),B(!0),m(null);try{const e=localStorage.getItem("adminToken");await r.A.post("".concat(Y,"/api/admin-auth/team/create"),u,{headers:{Authorization:"Bearer ".concat(e)}}),m({type:"success",text:"Team admin '".concat(u.username,"' created successfully")}),g({username:"",password:"",name:"",email:""}),o(!1),y()}catch(a){var t,s;const e=(null===(t=a.response)||void 0===t||null===(s=t.data)||void 0===s?void 0:s.detail)||"Failed to create admin";m({type:"error",text:e})}finally{B(!1)}},className:"bg-[#f3f0e8] border border-[#1B7B9E]/20 p-6 space-y-4",children:[(0,D.jsx)("h3",{className:"text-[#2B2B2B] text-lg mb-4",children:"Create New Team Admin"}),(0,D.jsxs)("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[(0,D.jsxs)("div",{className:"space-y-2",children:[(0,D.jsx)("label",{className:"text-[#2B2B2B] text-sm",children:"Username *"}),(0,D.jsx)(S.p,{type:"text",value:u.username,onChange:e=>g((0,A.A)((0,A.A)({},u),{},{username:e.target.value})),placeholder:"admin_username",className:"bg-white/5 border-[#1B7B9E]/20 text-[#2B2B2B]",required:!0,minLength:3})]}),(0,D.jsxs)("div",{className:"space-y-2",children:[(0,D.jsx)("label",{className:"text-[#2B2B2B] text-sm",children:"Password *"}),(0,D.jsxs)("div",{className:"relative",children:[(0,D.jsx)(S.p,{type:v?"text":"password",value:u.password,onChange:e=>g((0,A.A)((0,A.A)({},u),{},{password:e.target.value})),placeholder:"Temporary password",className:"bg-white/5 border-[#1B7B9E]/20 text-[#2B2B2B] pr-10",required:!0,minLength:6}),(0,D.jsx)("button",{type:"button",onClick:()=>f(!v),className:"absolute right-3 top-1/2 -translate-y-1/2 text-[#2B2B2B]/30",children:v?(0,D.jsx)(V.A,{size:16}):(0,D.jsx)(J.A,{size:16})})]})]}),(0,D.jsxs)("div",{className:"space-y-2",children:[(0,D.jsx)("label",{className:"text-[#2B2B2B] text-sm",children:"Full Name *"}),(0,D.jsx)(S.p,{type:"text",value:u.name,onChange:e=>g((0,A.A)((0,A.A)({},u),{},{name:e.target.value})),placeholder:"John Doe",className:"bg-white/5 border-[#1B7B9E]/20 text-[#2B2B2B]",required:!0})]}),(0,D.jsxs)("div",{className:"space-y-2",children:[(0,D.jsx)("label",{className:"text-[#2B2B2B] text-sm",children:"Email (optional)"}),(0,D.jsx)(S.p,{type:"email",value:u.email,onChange:e=>g((0,A.A)((0,A.A)({},u),{},{email:e.target.value})),placeholder:"[email protected]",className:"bg-white/5 border-[#1B7B9E]/20 text-[#2B2B2B]"})]})]}),(0,D.jsxs)("div",{className:"flex gap-3 pt-4",children:[(0,D.jsx)(C.$,{type:"submit",disabled:N,className:"navy-cta bg-[#22364A] hover:opacity-90 rounded-full text-[#2B2B2B]",children:N?"Creating...":"Create Admin"}),(0,D.jsx)(C.$,{type:"button",onClick:()=>o(!1),variant:"outline",className:"border-[#1B7B9E]/25 text-[#2B2B2B]",children:"Cancel"})]})]}),(0,D.jsxs)("div",{className:"bg-[#f3f0e8] border border-[#1B7B9E]/20",children:[(0,D.jsx)("div",{className:"p-4 border-b border-[#1B7B9E]/20",children:(0,D.jsxs)("div",{className:"flex items-center gap-3",children:[(0,D.jsx)(n.A,{size:20,className:"text-[#A58958]"}),(0,D.jsxs)("h2",{className:"text-[#2B2B2B] text-lg",children:["Team Admin Accounts (",s.length,")"]})]})}),0===s.length?(0,D.jsxs)("div",{className:"p-8 text-center",children:[(0,D.jsx)(j.A,{size:48,className:"mx-auto mb-4 text-[#2B2B2B]/20"}),(0,D.jsx)("p",{className:"text-[#5e5e5e]",children:"No team admin accounts yet"}),w&&(0,D.jsx)("p",{className:"text-[#2B2B2B]/30 text-sm mt-2",children:'Click "Add Team Admin" to create the first team account'})]}):(0,D.jsx)("div",{className:"divide-y divide-white/10",children:s.map(e=>(0,D.jsxs)("div",{className:"p-4 flex items-center justify-between",children:[(0,D.jsxs)("div",{className:"flex items-center gap-4",children:[(0,D.jsx)("div",{className:"w-10 h-10 rounded-full flex items-center justify-center ".concat(e.is_active?"bg-[#A58958]/20 text-[#A58958]":"bg-white/5 text-[#2B2B2B]/30"),children:(0,D.jsx)(j.A,{size:20})}),(0,D.jsxs)("div",{children:[(0,D.jsx)("p",{className:"text-[#2B2B2B] font-medium",children:e.name}),(0,D.jsxs)("p",{className:"text-[#5e5e5e] text-sm",children:["@",e.username]})]})]}),(0,D.jsxs)("div",{className:"flex items-center gap-4",children:[(0,D.jsx)("span",{className:"px-3 py-1 text-xs uppercase tracking-wider ".concat(e.is_active?"bg-green-500/10 text-green-400":"bg-red-500/10 text-red-400"),children:e.is_active?"Active":"Inactive"}),w&&(0,D.jsxs)("div",{className:"flex gap-2",children:[(0,D.jsx)("button",{onClick:()=>(async(e,t)=>{try{const s=localStorage.getItem("adminToken");await r.A.put("".concat(Y,"/api/admin-auth/team/").concat(e),{is_active:!t},{headers:{Authorization:"Bearer ".concat(s)}}),m({type:"success",text:"Admin ".concat(t?"deactivated":"activated"," successfully")}),y()}catch(s){m({type:"error",text:"Failed to update admin status"})}})(e.id,e.is_active),className:"p-2 transition-colors ".concat(e.is_active?"text-red-400/50 hover:text-red-400":"text-green-400/50 hover:text-green-400"),title:e.is_active?"Deactivate":"Activate",children:e.is_active?(0,D.jsx)(b.A,{size:18}):(0,D.jsx)(E.A,{size:18})}),(0,D.jsx)("button",{onClick:()=>(async(e,t)=>{if(window.confirm("Delete admin account '".concat(t,"'? This cannot be undone.")))try{const t=localStorage.getItem("adminToken");await r.A.delete("".concat(Y,"/api/admin-auth/team/").concat(e),{headers:{Authorization:"Bearer ".concat(t)}}),m({type:"success",text:"Admin deleted successfully"}),y()}catch(s){m({type:"error",text:"Failed to delete admin"})}})(e.id,e.username),className:"p-2 text-red-400/50 hover:text-red-400",title:"Delete",children:(0,D.jsx)(G.A,{size:18})})]})]})]},e.id))})]}),(0,D.jsxs)("div",{className:"bg-[#f3f0e8] border border-[#1B7B9E]/20 p-6",children:[(0,D.jsx)("h3",{className:"text-[#2B2B2B] text-lg mb-4",children:"Your Account"}),(0,D.jsxs)("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4 text-sm",children:[(0,D.jsxs)("div",{children:[(0,D.jsx)("p",{className:"text-[#5e5e5e] mb-1",children:"Username"}),(0,D.jsx)("p",{className:"text-[#2B2B2B]",children:null===p||void 0===p?void 0:p.username})]}),(0,D.jsxs)("div",{children:[(0,D.jsx)("p",{className:"text-[#5e5e5e] mb-1",children:"Role"}),(0,D.jsx)("p",{className:"text-[#A58958] uppercase text-xs tracking-wider",children:"primary_admin"===(null===p||void 0===p?void 0:p.role)?"Primary Admin":"Team Admin"})]}),(0,D.jsxs)("div",{children:[(0,D.jsx)("p",{className:"text-[#5e5e5e] mb-1",children:"Name"}),(0,D.jsx)("p",{className:"text-[#2B2B2B]",children:null===p||void 0===p?void 0:p.name})]}),(0,D.jsxs)("div",{children:[(0,D.jsx)("p",{className:"text-[#5e5e5e] mb-1",children:"Permissions"}),(0,D.jsx)("p",{className:"text-[#2B2B2B]",children:null!==p&&void 0!==p&&null!==(e=p.permissions)&&void 0!==e&&e.includes("all")?"Full Access":null===p||void 0===p||null===(t=p.permissions)||void 0===t?void 0:t.join(", ")})]})]})]})]})};var Z=s(14215),K=s(78130),X=s(25692),ee=s(86805),te=s(18134),se=s(6890);const ae=()=>{var e,t,s;const[l,i]=(0,a.useState)(null),[d,o]=(0,a.useState)(!0);(0,a.useEffect)(()=>{x()},[]);const x=async()=>{try{const e=localStorage.getItem("peerless_token")||localStorage.getItem("adminToken"),t=await r.A.get("".concat("https://peerlessetiquette.com","/api/admin/dashboard/stats"),{headers:{Authorization:"Bearer ".concat(e)}});i(t.data)}catch(e){console.error("Failed to fetch stats:",e),i(null)}finally{o(!1)}},m=e=>{var t;return e>=1e6?"".concat((e/1e6).toFixed(1),"M"):e>=1e3?"".concat((e/1e3).toFixed(1),"K"):(null===e||void 0===e||null===(t=e.toLocaleStr
1ing)||void 0===t?void 0:t.call(e))||"0"},p=e=>"$".concat((e||0).toLocaleString("en-US",{minimumFractionDigits:2,maximumFractionDigits:2})),u=e=>{let{data:t}=e;if(!t||0===t.length)return null;const s=Math.max(...t.map(e=>e.signups),1);return(0,D.jsx)("div",{className:"flex items-end gap-1 sm:gap-1.5 h-14 sm:h-16 mt-3",children:t.map((e,t)=>(0,D.jsxs)("div",{className:"flex-1 flex flex-col items-center gap-1",children:[(0,D.jsx)("div",{className:"w-full rounded-sm transition-all duration-500",style:{height:"".concat(Math.max(e.signups/s*100,4),"%"),background:e.signups>0?"linear-gradient(180deg, #A58958 0%, #C4A873 100%)":"#E3DCDE",minHeight:"3px"}}),(0,D.jsx)("span",{className:"text-[8px] sm:text-[9px] text-[#5A6F82] tracking-wider",children:e.day})]},t))})};if(d)return(0,D.jsx)("div",{className:"flex items-center justify-center h-[50vh]",children:(0,D.jsxs)("div",{className:"flex flex-col items-center gap-3",children:[(0,D.jsx)("div",{className:"w-10 h-10 border-2 border-[#1B7B9E]/20 border-t-[#1B7B9E] rounded-full animate-spin"}),(0,D.jsx)("span",{className:"text-[#5A6F82] text-[10px] tracking-[0.3em] uppercase",children:"Loading"})]})});if(!l)return(0,D.jsxs)("div",{className:"text-center py-16",children:[(0,D.jsx)("p",{className:"text-[#5A6F82] text-sm",children:"Unable to load dashboard data."}),(0,D.jsx)("button",{onClick:x,className:"mt-3 text-[#A58958] hover:underline text-xs",children:"Retry"})]});const j=[{label:"Total Users",value:m(l.users.total),sub:"".concat(l.users.new_this_week," new this week"),icon:n.A,accent:"#A58958",bg:"linear-gradient(135deg, #FDFBF7 0%, #F5F0E8 100%)"},{label:"Revenue",value:p(l.sales.total_revenue),sub:"".concat(p(l.sales.revenue_this_month)," this month"),icon:Z.A,accent:"#2D6A4F",bg:"linear-gradient(135deg, #F0F7F4 0%, #E8F5E9 100%)"},{label:"Courses",value:l.courses.total,sub:"".concat(l.courses.total_units," units"),icon:c.A,accent:"#2B2B2B",bg:"linear-gradient(135deg, #F0F4F8 0%, #E3EBF5 100%)"},{label:"Enrolled",value:m(l.courses.total_enrollments),sub:"".concat(l.courses.completion_rate,"% rate"),icon:K.A,accent:"#7B2D8E",bg:"linear-gradient(135deg, #F8F0FA 0%, #F0E4F5 100%)"}],v=[{label:"Admins",value:l.users.admins,icon:h.A,accent:"#A58958"},{label:"Premium",value:l.users.premium,icon:X.A,accent:"#2D6A4F"},{label:"Transactions",value:l.sales.total_transactions,icon:g.A,accent:"#2B2B2B"},{label:"Challenges",value:l.engagement.total_challenges,icon:ee.A,accent:"#7B2D8E"},{label:"Quizzes",value:l.courses.total_quizzes,icon:te.A,accent:"#E09F3E"},{label:"Completed",value:l.courses.completed_activities,icon:se.A,accent:"#2D6A4F"}];return(0,D.jsxs)("div",{className:"space-y-5 sm:space-y-8","data-testid":"admin-overview",children:[(0,D.jsxs)("div",{children:[(0,D.jsx)("h1",{className:"text-xl sm:text-2xl lg:text-3xl text-[#0B2036] tracking-wide",style:{fontFamily:"'Cormorant Garamond', Georgia, serif",fontVariant:"small-caps",letterSpacing:"0.06em"},"data-testid":"admin-overview-title",children:"Command Center"}),(0,D.jsxs)("div",{className:"flex items-center gap-2 mt-1",children:[(0,D.jsx)("div",{className:"h-px w-10 sm:w-14",style:{background:"#22364A",borderRadius:"9999px"}}),(0,D.jsx)("p",{className:"text-[#5A6F82] text-[9px] sm:text-[10px] tracking-[0.12em] uppercase",style:{fontFamily:"'Manrope', sans-serif"},children:"Real-time analytics"})]})]}),(0,D.jsx)("div",{className:"grid grid-cols-2 lg:grid-cols-4 gap-3 sm:gap-4",children:j.map((e,t)=>(0,D.jsxs)("div",{className:"relative overflow-hidden rounded-xl p-3.5 sm:p-5 transition-all duration-300 hover:shadow-lg",style:{background:e.bg,border:"1px solid ".concat(e.accent,"15")},"data-testid":"stat-card-".concat(e.label.toLowerCase().replace(/\s/g,"-")),children:[(0,D.jsx)("div",{className:"flex items-start justify-between mb-2 sm:mb-3",children:(0,D.jsx)("div",{className:"w-8 h-8 sm:w-9 sm:h-9 rounded-lg flex items-center justify-center",style:{background:"".concat(e.accent,"12")},children:(0,D.jsx)(e.icon,{size:16,style:{color:e.accent}})})}),(0,D.jsx)("p",{className:"text-xl sm:text-2xl lg:text-3xl font-light mb-0.5",style:{color:"#0B2036",fontFamily:"'Cormorant Garamond', Georgia, serif"},children:e.value}),(0,D.jsx)("p",{className:"text-[9px] sm:text-[10px] text-[#5A6F82] tracking-wide uppercase",style:{fontFamily:"'Manrope', sans-serif"},children:e.label}),(0,D.jsx)("p",{className:"text-[8px] sm:text-[9px] text-[#5A6F82]/70 mt-0.5",children:e.sub})]},t))}),(0,D.jsx)("div",{className:"grid grid-cols-3 lg:grid-cols-6 gap-2 sm:gap-3",children:v.map((e,t)=>(0,D.jsxs)("div",{className:"bg-white rounded-lg p-2.5 sm:p-3.5 transition-all duration-200 hover:shadow-md",style:{border:"1px solid #E3DCDE"},children:[(0,D.jsxs)("div",{className:"flex items-center gap-1 sm:gap-1.5 mb-1 sm:mb-2",children:[(0,D.jsx)(e.icon,{size:12,style:{color:e.accent}}),(0,D.jsx)("span",{className:"text-[8px] sm:text-[9px] text-[#5A6F82] tracking-wider up
1percase truncate",children:e.label})]}),(0,D.jsx)("p",{className:"text-base sm:text-lg lg:text-xl font-light text-[#0B2036]",style:{fontFamily:"'Cormorant Garamond', serif"},children:m(e.value)})]},t))}),(0,D.jsxs)("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-4 sm:gap-6",children:[(0,D.jsxs)("div",{className:"bg-white rounded-xl p-4 sm:p-6",style:{border:"1px solid #E3DCDE"},"data-testid":"signup-trend-chart",children:[(0,D.jsx)("h3",{className:"text-xs sm:text-sm text-[#0B2036] tracking-wider uppercase mb-1",style:{fontFamily:"'Manrope', sans-serif"},children:"Signup Trend"}),(0,D.jsx)("p",{className:"text-[9px] text-[#5A6F82] mb-1",children:"Last 7 days"}),(0,D.jsx)(u,{data:l.users.signup_trend})]}),(0,D.jsxs)("div",{className:"bg-white rounded-xl p-4 sm:p-6",style:{border:"1px solid #E3DCDE"},"data-testid":"recent-users-table",children:[(0,D.jsx)("h3",{className:"text-xs sm:text-sm text-[#0B2036] tracking-wider uppercase mb-3",style:{fontFamily:"'Manrope', sans-serif"},children:"Recent Signups"}),(0,D.jsx)("div",{className:"space-y-2 max-h-44 overflow-y-auto",children:l.users.recent.slice(0,6).map((e,t)=>{var s;return(0,D.jsxs)("div",{className:"flex items-center justify-between py-1 border-b border-[#F5F0E8] last:border-0",children:[(0,D.jsxs)("div",{className:"flex items-center gap-2 min-w-0",children:[(0,D.jsx)("div",{className:"w-6 h-6 rounded-full flex items-center justify-center text-[10px] font-medium text-white flex-shrink-0",style:{background:"admin"===e.role?"#A58958":"#2B2B2B"},children:null===(s=(e.name||e.email||"?")[0])||void 0===s?void 0:s.toUpperCase()}),(0,D.jsxs)("div",{className:"min-w-0",children:[(0,D.jsx)("p",{className:"text-[10px] sm:text-xs text-[#0B2036] truncate",children:e.name||"User"}),(0,D.jsx)("p",{className:"text-[8px] sm:text-[10px] text-[#5A6F82] truncate",children:e.email})]})]}),(0,D.jsx)("span",{className:"text-[8px] px-1.5 py-0.5 rounded-full tracking-wider uppercase flex-shrink-0 ml-2",style:{background:"admin"===e.role?"#A5895815":"#594D4410",color:"admin"===e.role?"#A58958":"#2B2B2B"},children:e.role})]},t)})})]})]}),(0,D.jsxs)("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-4 sm:gap-6",children:[(0,D.jsxs)("div",{className:"bg-white rounded-xl p-4 sm:p-6",style:{border:"1px solid #E3DCDE"},children:[(0,D.jsx)("h3",{className:"text-xs sm:text-sm text-[#0B2036] tracking-wider uppercase mb-3",style:{fontFamily:"'Manrope', sans-serif"},children:"Top Selling Courses"}),(null===(e=l.sales.top_selling)||void 0===e?void 0:e.length)>0?(0,D.jsx)("div",{className:"space-y-2",children:l.sales.top_selling.map((e,t)=>(0,D.jsxs)("div",{className:"flex items-center justify-between py-1.5 border-b border-[#F5F0E8] last:border-0",children:[(0,D.jsxs)("div",{className:"flex items-center gap-2 min-w-0",children:[(0,D.jsxs)("span",{className:"text-[9px] text-[#A58958] font-medium w-4 flex-shrink-0",children:["#",t+1]}),(0,D.jsx)("span",{className:"text-[10px] sm:text-xs text-[#0B2036] truncate",children:e.title})]}),(0,D.jsx)("span",{className:"text-[10px] sm:text-xs text-[#2D6A4F] font-medium flex-shrink-0 ml-2",children:p(e.revenue)})]},t))}):(0,D.jsx)("p",{className:"text-[10px] sm:text-xs text-[#5A6F82] italic",children:"No sales data yet"})]}),(0,D.jsxs)("div",{className:"bg-white rounded-xl p-4 sm:p-6",style:{border:"1px solid #E3DCDE"},"data-testid":"popular-courses",children:[(0,D.jsx)("h3",{className:"text-xs sm:text-sm text-[#0B2036] tracking-wider uppercase mb-3",style:{fontFamily:"'Manrope', sans-serif"},children:"Most Popular Courses"}),(null===(t=l.courses.most_popular)||void 0===t?void 0:t.length)>0?(0,D.jsx)("div",{className:"space-y-2",children:l.courses.most_popular.map((e,t)=>(0,D.jsxs)("div",{className:"flex items-center justify-between py-1.5 border-b border-[#F5F0E8] last:border-0",children:[(0,D.jsxs)("div",{className:"flex items-center gap-2 min-w-0",children:[(0,D.jsxs)("span",{className:"text-[9px] text-[#2B2B2B] font-medium w-4 flex-shrink-0",children:["#",t+1]}),(0,D.jsx)("span",{className:"text-[10px] sm:text-xs text-[#0B2036] truncate",children:e.title})]}),(0,D.jsxs)("span",{className:"text-[9px] text-[#5A6F82] flex-shrink-0 ml-2",children:[e.enrollments," enrolled"]})]},t))}):(0,D.jsx)("p",{className:"text-[10px] sm:text-xs text-[#5A6F82] italic",children:"No enrollment data yet"})]})]}),(null===(s=l.sales.recent_transactions)||void 0===s?void 0:s.length)>0&&(0,D.jsxs)("div",{className:"bg-white rounded-xl p-4 sm:p-6",style:{border:"1px solid #E3DCDE"},"data-testid":"recent-transactions",children:[(0,D.jsx)("h3",{className:"text-xs sm:text-sm text-[#0B2036] tracking-wider up
1percase mb-3",style:{fontFamily:"'Manrope', sans-serif"},children:"Recent Transactions"}),(0,D.jsx)("div",{className:"overflow-x-auto -mx-2 px-2",children:(0,D.jsxs)("table",{className:"w-full min-w-[400px]",children:[(0,D.jsx)("thead",{children:(0,D.jsxs)("tr",{className:"border-b border-[#E3DCDE]",children:[(0,D.jsx)("th",{className:"text-left text-[9px] text-[#5A6F82] tracking-wider uppercase py-1.5 pr-3",children:"Email"}),(0,D.jsx)("th",{className:"text-left text-[9px] text-[#5A6F82] tracking-wider uppercase py-1.5 pr-3",children:"Description"}),(0,D.jsx)("th",{className:"text-right text-[9px] text-[#5A6F82] tracking-wider uppercase py-1.5 pr-3",children:"Amount"}),(0,D.jsx)("th",{className:"text-right text-[9px] text-[#5A6F82] tracking-wider uppercase py-1.5",children:"Status"})]})}),(0,D.jsx)("tbody",{children:l.sales.recent_transactions.map((e,t)=>(0,D.jsxs)("tr",{className:"border-b border-[#F5F0E8] last:border-0",children:[(0,D.jsx)("td",{className:"py-1.5 pr-3 text-[10px] text-[#0B2036] truncate max-w-[120px]",children:e.user_email}),(0,D.jsx)("td",{className:"py-1.5 pr-3 text-[10px] text-[#5A6F82] truncate max-w-[120px]",children:e.description}),(0,D.jsx)("td",{className:"py-1.5 pr-3 text-[10px] text-right text-[#2D6A4F] font-medium",children:p(e.amount)}),(0,D.jsx)("td",{className:"py-1.5 text-right",children:(0,D.jsx)("span",{className:"text-[8px] px-1.5 py-0.5 rounded-full bg-[#2D6A4F]/10 text-[#2D6A4F]",children:e.status})})]},t))})]})})]})]})};var le=s(61910),re=s(36391),ie=s(68432),ne=s(67637),ce=s(27453);const de="https://peerlessetiquette.com",oe=()=>localStorage.getItem("peerless_token")||localStorage.getItem("adminToken"),xe=()=>{var e,t,s;const[l,i]=(0,a.useState)([]),[d,o]=(0,a.useState)(!0),[x,m]=(0,a.useState)(""),[p,h]=(0,a.useState)(null),[u,g]=(0,a.useState)(null),[j,v]=(0,a.useState)(!1),[b,f]=(0,a.useState)({}),[N,B]=(0,a.useState)({});(0,a.useEffect)(()=>{w()},[]);const w=async()=>{try{const e=await r.A.get("".concat(de,"/api/admin/dashboard/courses/list"),{headers:{Authorization:"Bearer ".concat(oe())}});i(e.data.courses)}catch(e){console.error("Failed to fetch courses:",e)}finally{o(!1)}},k=l.filter(e=>{var t,s;return!x||(null===(t=e.title)||void 0===t?void 0:t.toLowerCase().includes(x.toLowerCase()))||(null===(s=e.department)||void 0===s?void 0:s.toLowerCase().includes(x.toLowerCase()))}),E=e=>{switch(e){case"quiz":return(0,D.jsx)(re.A,{size:12,className:"text-[#E09F3E]"});case"reflection":return(0,D.jsx)(ie.A,{size:12,className:"text-[#7B2D8E]"});default:return(0,D.jsx)(ne.A,{size:12,className:"text-[#2B2B2B]"})}};return(0,D.jsxs)("div",{className:"space-y-5","data-testid":"admin-courses-page",children:[(0,D.jsxs)("div",{children:[(0,D.jsx)("h1",{className:"text-xl sm:text-2xl text-[#0B2036] tracking-wide",style:{fontFamily:"'Cormorant Garamond', serif",fontVariant:"small-caps"},children:"Course Management"}),(0,D.jsxs)("p",{className:"text-[10px] text-[#5A6F82] mt-0.5",children:[l.length," courses in library"]})]}),(0,D.jsxs)("div",{className:"relative",children:[(0,D.jsx)(q.A,{size:14,className:"absolute left-3 top-1/2 -translate-y-1/2 text-[#5A6F82]"}),(0,D.jsx)("input",{type:"text",value:x,onChange:e=>m(e.target.value),placeholder:"Search courses...",className:"w-full pl-9 pr-3 py-2 text-xs rounded-lg bg-white border border-[#E3DCDE] focus:outline-none focus:border-[#1B7B9E] text-[#0B2036]",style:{fontFamily:"'Manrope', sans-serif"},"data-testid":"search-courses-input"})]}),(0,D.jsxs)("div",{className:"flex flex-col lg:flex-row gap-5",children:[(0,D.jsxs)("div",{className:"".concat(p?"hidden lg:block lg:w-1/3":"w-full"," space-y-2"),children:[d?(0,D.jsx)("div",{className:"flex items-center justify-center py-16",children:(0,D.jsx)("div",{className:"w-8 h-8 border-2 border-[#1B7B9E]/20 border-t-[#1B7B9E] rounded-full animate-spin"})}):k.map((e,t)=>(0,D.jsx)("div",{onClick:()=>(async e=>{h(e),v(!0),g(null),f({}),B({});try{const t=await r.A.get("".concat(de,"/api/admin/dashboard/courses/").concat(e.course_id),{headers:{Authorization:"Bearer ".concat(oe())}});g(t.data)}catch(t){console.error("Failed to fetch course detail:",t)}finally{v(!1)}})(e),className:"bg-white rounded-xl p-4 cursor-pointer transition-all duration-200 hover:shadow-md ".concat((null===p||void 0===p?void 0:p.course_id)===e.course_id?"ring-1 ring-[#1B7B9E]":""),style:{border:"1px solid #E3DCDE"},"data-testid":"course-card-".concat(e.course_id),children:(0,D.jsxs)("div",{className:"flex items-start justify-between",children:[(0,D.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,D.jsx)("p",{className:"text-xs sm:text-sm text-[#0B2036] font-medium leading-snug",children:e.title}),(0,D.jsxs)("div",{className:"flex items-center gap-3 mt-1.5",children:[(0,D.jsx)("span",{className:"text-[8px] px-1.5 py-0.5 rounded-full bg-[#594D44]/8 text-[#2B2B2B] tracking-wider up
1percase",children:e.department||"General"}),e.difficulty&&(0,D.jsx)("span",{className:"text-[8px] text-[#5A6F82]",children:e.difficulty})]}),(0,D.jsxs)("div",{className:"flex items-center gap-3 mt-2 text-[9px] text-[#5A6F82]",children:[(0,D.jsxs)("span",{className:"flex items-center gap-1",children:[(0,D.jsx)(ee.A,{size:10})," ",e.chapters_count," chapters"]}),(0,D.jsxs)("span",{className:"flex items-center gap-1",children:[(0,D.jsx)(n.A,{size:10})," ",e.enrollments," enrolled"]})]})]}),(0,D.jsx)(y.A,{size:14,className:"text-[#E3DCDE] flex-shrink-0 mt-1"})]})},t)),!d&&0===k.length&&(0,D.jsxs)("div",{className:"text-center py-12",children:[(0,D.jsx)(c.A,{size:24,className:"mx-auto text-[#E3DCDE] mb-2"}),(0,D.jsx)("p",{className:"text-xs text-[#5A6F82]",children:"No courses found"})]})]}),p&&(0,D.jsxs)("div",{className:"flex-1 lg:w-2/3",children:[(0,D.jsxs)("button",{onClick:()=>h(null),className:"lg:hidden flex items-center gap-1 text-[10px] text-[#A58958] mb-3 tracking-wider uppercase",children:[(0,D.jsx)(y.A,{size:12,className:"rotate-180"})," Back to courses"]}),(0,D.jsxs)("div",{className:"bg-white rounded-xl overflow-hidden",style:{border:"1px solid #E3DCDE"},children:[(0,D.jsxs)("div",{className:"p-4 sm:p-6 border-b border-[#E3DCDE]",style:{background:"linear-gradient(135deg, #FDFBF7 0%, #F5F0E8 100%)"},children:[(0,D.jsx)("h2",{className:"text-base sm:text-lg text-[#0B2036]",style:{fontFamily:"'Cormorant Garamond', serif"},children:p.title}),(0,D.jsxs)("div",{className:"flex flex-wrap items-center gap-3 mt-2",children:[(0,D.jsx)("span",{className:"text-[8px] px-2 py-0.5 rounded-full bg-[#594D44]/10 text-[#2B2B2B] tracking-wider uppercase",children:p.department}),(0,D.jsxs)("span",{className:"text-[9px] text-[#5A6F82]",children:[p.chapters_count," chapters"]}),(0,D.jsxs)("span",{className:"text-[9px] text-[#5A6F82]",children:[p.enrollments," enrolled"]})]}),u&&(0,D.jsxs)("div",{className:"grid grid-cols-3 gap-3 mt-4",children:[(0,D.jsxs)("div",{className:"text-center",children:[(0,D.jsx)("p",{className:"text-lg font-light text-[#0B2036]",style:{fontFamily:"'Cormorant Garamond', serif"},children:(null===(e=u.learning_units)||void 0===e?void 0:e.length)||0}),(0,D.jsx)("p",{className:"text-[8px] text-[#5A6F82] tracking-wider uppercase",children:"Units"})]}),(0,D.jsxs)("div",{className:"text-center",children:[(0,D.jsx)("p",{className:"text-lg font-light text-[#0B2036]",style:{fontFamily:"'Cormorant Garamond', serif"},children:u.enrollment_count||0}),(0,D.jsx)("p",{className:"text-[8px] text-[#5A6F82] tracking-wider uppercase",children:"Enrolled"})]}),(0,D.jsxs)("div",{className:"text-center",children:[(0,D.jsxs)("p",{className:"text-lg font-light text-[#2D6A4F]",style:{fontFamily:"'Cormorant Garamond', serif"},children:[u.completion_rate||0,"%"]}),(0,D.jsx)("p",{className:"text-[8px] text-[#5A6F82] tracking-wider uppercase",children:"Completion"})]})]})]}),(0,D.jsx)("div",{className:"p-4 sm:p-6",children:j?(0,D.jsx)("div",{className:"flex items-center justify-center py-12",children:(0,D.jsx)("div",{className:"w-8 h-8 border-2 border-[#1B7B9E]/20 border-t-[#1B7B9E] rounded-full animate-spin"})}):(null===u||void 0===u||null===(t=u.learning_units)||void 0===t?void 0:t.length)>0?(0,D.jsxs)("div",{className:"space-y-1.5",children:[(0,D.jsx)("h3",{className:"text-[10px] text-[#5A6F82] tracking-wider uppercase mb-3",style:{fontFamily:"'Manrope', sans-serif"},children:"Course Hierarchy"}),u.learning_units.map(e=>{var t,s;return(0,D.jsxs)("div",{className:"rounded-lg border border-[#E3DCDE] overflow-hidden",children:[(0,D.jsxs)("button",{onClick:()=>{return t=e.id,f(e=>(0,A.A)((0,A.A)({},e),{},{[t]:!e[t]}));var t},className:"w-full flex items-center gap-2 p-3 text-left hover:bg-[#FDFBF7] transition-colors","data-testid":"unit-".concat(e.id),children:[b[e.id]?(0,D.jsx)(ce.A,{size:14,className:"text-[#A58958] flex-shrink-0"}):(0,D.jsx)(y.A,{size:14,className:"text-[#5A6F82] flex-shrink-0"}),(0,D.jsx)(ee.A,{size:13,className:"text-[#A58958] flex-shrink-0"}),(0,D.jsx)("span",{className:"text-[11px] text-[#0B2036] flex-1 truncate",children:e.title}),(0,D.jsxs)("span",{className:"text-[8px] text-[#5A6F82] flex-shrink-0",children:[(null===(t=e.lessons)||void 0===t?void 0:t.length)||0," lessons"]})]}),b[e.id]&&(null===(s=e.lessons)||void 0===s?void 0:s.map(e=>{var t,s;return(0,D.jsxs)("div",{className:"border-t border-[#F5F0E8]",children:[(0,D.jsxs)("button",{onClick:()=>{return t=e.id,B(e=>(0,A.A)((0,A.A)({},e),{},{[t]:!e[t]}));var t},className:"w-full flex items-center gap-2 p-2.5 pl-8 text-left hover:bg-[#FDFBF7]/50","data-testid":"lesson-".concat(e.id),children:[N[e.id]?(0,D.jsx)(ce.A,{size:12,className:"text-[#2B2B2B] flex-shrink-0"}):(0,D.jsx)(y.A,{size:12,className:"text-[#5A6F82] flex-shrink-0"}),(0,D.jsx)(c.A,{size:12,className:"text-[#2B2B2B] flex-shrink-0"}),(0,D.jsx)("span",{className:"text-[10px] text-[#0B2036] flex-1 truncate",children:e.title}),(0,D.jsx)("span",{className:"text-[8px] text-[#5A6F82] flex-shrink-0",children:(null===(t=e.activities)||void 0===t?void 0:t.length)||0})]}),N[e.id]&&(null===(s=e.activities)||void 0===s?void 0:s.map(e=>(0,D.jsxs)("div",{className:"flex items-center gap-2 p-2 pl-14 border-t border-[#F5F0E8]/50 hover:bg-[#FDFBF7]/30",children:[E(e.activity_type),(0,D.jsx)("span",{className:"text-[9px] text-[#0B2036] flex-1 truncate",children:e.title}),(0,D.jsx)("span",{className:"text-[7px] px-1.5 py-0.5 rounded-full tracking-wider up
1percase",style:{background:"quiz"===e.activity_type?"#E09F3E15":"reflection"===e.activity_type?"#7B2D8E12":"#594D4410",color:"quiz"===e.activity_type?"#E09F3E":"reflection"===e.activity_type?"#7B2D8E":"#2B2B2B"},children:e.activity_type})]},e.id)))]},e.id)}))]},e.id)})]}):u?(0,D.jsxs)("div",{className:"text-center py-8",children:[(0,D.jsx)("p",{className:"text-xs text-[#5A6F82]",children:"No learning structure mapped for this course yet."}),(0,D.jsxs)("p",{className:"text-[10px] text-[#5A6F82]/60 mt-1",children:["Chapters: ",(null===(s=u.chapters)||void 0===s?void 0:s.length)||0]})]}):null})]})]})]})]})};var me=s(22796),pe=s(73581),he=s(85113),ue=s(68108);const ge="https://peerlessetiquette.com",je=()=>localStorage.getItem("peerless_token")||localStorage.getItem("adminToken"),ve=e=>{let{label:t,value:s}=e;return(0,D.jsxs)("div",{className:"flex items-center justify-between py-1.5 border-b border-[#F5F0E8]",children:[(0,D.jsx)("span",{className:"text-[9px] text-[#5A6F82] tracking-wider uppercase",children:t}),(0,D.jsx)("span",{className:"text-[10px] text-[#0B2036]",children:s})]})},be=()=>{var e,t;const[s,l]=(0,a.useState)([]),[i,c]=(0,a.useState)(!0),[d,o]=(0,a.useState)(0),[x,m]=(0,a.useState)(0),[p,h]=(0,a.useState)(""),[u,g]=(0,a.useState)(null),[j,v]=(0,a.useState)(!1),[f,N]=(0,a.useState)(!1),[B,A]=(0,a.useState)(null),w=(0,a.useCallback)(async()=>{c(!0);try{const e=new URLSearchParams({skip:x.toString(),limit:25..toString()});p&&e.append("search",p);const t=await r.A.get("".concat(ge,"/api/admin/dashboard/users/list?").concat(e),{headers:{Authorization:"Bearer ".concat(je())}});l(t.data.users),o(t.data.total)}catch(e){console.error("Failed to fetch users:",e)}finally{c(!1)}},[x,p]);(0,a.useEffect)(()=>{w()},[w]);const k=async e=>{N(!0),v(!0);try{const t=await r.A.get("".concat(ge,"/api/admin/dashboard/users/").concat(e.id||e.email),{headers:{Authorization:"Bearer ".concat(je())}});g(t.data)}catch(t){g(e)}finally{N(!1)}},E=async e=>{if(window.confirm("Deactivate ".concat(e.name||e.email,"?"))){try{await r.A.post("".concat(ge,"/api/admin/dashboard/users/").concat(e.id||e.email,"/deactivate"),{},{headers:{Authorization:"Bearer ".concat(je())}}),A({text:"User deactivated",type:"success"}),w(),j&&v(!1)}catch(t){A({text:"Failed to deactivate",type:"error"})}setTimeout(()=>A(null),3e3)}},_=async e=>{try{await r.A.post("".concat(ge,"/api/admin/dashboard/users/").concat(e.id||e.email,"/reactivate"),{},{headers:{Authorization:"Bearer ".concat(je())}}),A({text:"User reactivated",type:"success"}),w(),j&&v(!1)}catch(t){A({text:"Failed to reactivate",type:"error"})}setTimeout(()=>A(null),3e3)},C=async e=>{if(window.confirm("Reset password for ".concat(e.name||e.email,"?"))){try{const t=await r.A.post("".concat(ge,"/api/admin/dashboard/users/").concat(e.id||e.email,"/reset-password"),{},{headers:{Authorization:"Bearer ".concat(je())}});A({text:"Password reset. Temp: ".concat(t.data.temp_password),type:"success"})}catch(t){A({text:"Failed to reset password",type:"error"})}setTimeout(()=>A(null),8e3)}},S=Math.ceil(d/25),z=Math.floor(x/25)+1,T=(e,t)=>{if(!t&&void 0!==t)return(0,D.jsx)("span",{className:"text-[8px] px-1.5 py-0.5 rounded-full bg-red-50 text-red-500 tracking-wider uppercase",children:"inactive"});const s={admin:{bg:"#A5895815",color:"#A58958"},user:{bg:"#594D4410",color:"#2B2B2B"}},a=s[e]||s.user;return(0,D.jsx)("span",{className:"text-[8px] px-1.5 py-0.5 rounded-full tracking-wider uppercase",style:{background:a.bg,color:a.color},children:e})};return(0,D.jsxs)("div",{className:"space-y-5","data-testid":"admin-users-page",children:[(0,D.jsxs)("div",{className:"flex flex-col sm:flex-row sm:items-center justify-between gap-3",children:[(0,D.jsxs)("div",{children:[(0,D.jsx)("h1",{className:"text-xl sm:text-2xl text-[#0B2036] tracking-wide",style:{fontFamily:"'Cormorant Garamond', serif",fontVariant:"small-caps"},children:"User Management"}),(0,D.jsxs)("p",{className:"text-[10px] text-[#5A6F82] mt-0.5",children:[d," total users"]})]}),(0,D.jsx)("button",{onClick:w,className:"self-start sm:self-auto p-2 rounded-lg hover:bg-[#0B2036]/5 text-[#5A6F82]","data-testid":"refresh-users",children:(0,D.jsx)(I.A,{size:16})})]}),B&&(0,D.jsxs)("div",{className:"px-4 py-2.5 rounded-lg text-xs flex items-center gap-2 ".concat("error"===B.type?"bg-red-50 text-red-600":"bg-[#2D6A4F]/10 text-[#2D6A4F]"),children:[(0,D.jsx)(F.A,{size:14}),(0,D.jsx)("span",{className:"font-mono text-[11px]",children:B.text})]}),(0,D.jsxs)("form",{onSubmit:e=>{e.preventDefault(),m(0),w()},className:"flex gap-2",children:[(0,D.jsxs)("div",{className:"relative flex-1",children:[(0,D.jsx)(q.A,{size:14,className:"absolute left-3 top-1/2 -translate-y-1/2 text-[#5A6F82]"}),(0,D.jsx)("input",{type:"text",value:p,onChange:e=>h(e.target.value),placeholder:"Search by name or email...",className:"w-full pl-9 pr-3 py-2 text-xs rounded-lg bg-white border border-[#
1E3DCDE] focus:outline-none focus:border-[#1B7B9E] text-[#0B2036]",style:{fontFamily:"'Manrope', sans-serif"},"data-testid":"search-users-input"})]}),(0,D.jsx)("button",{type:"submit",className:"px-4 py-2 rounded-lg text-[10px] tracking-wider uppercase text-white",style:{background:"#0B2036"},"data-testid":"search-users-btn",children:"Search"})]}),(0,D.jsx)("div",{className:"bg-white rounded-xl overflow-hidden",style:{border:"1px solid #E3DCDE"},children:i?(0,D.jsx)("div",{className:"flex items-center justify-center py-16",children:(0,D.jsx)("div",{className:"w-8 h-8 border-2 border-[#1B7B9E]/20 border-t-[#1B7B9E] rounded-full animate-spin"})}):(0,D.jsxs)(D.Fragment,{children:[(0,D.jsx)("div",{className:"hidden md:block overflow-x-auto",children:(0,D.jsxs)("table",{className:"w-full",children:[(0,D.jsx)("thead",{children:(0,D.jsxs)("tr",{className:"border-b border-[#E3DCDE] bg-[#FDFBF7]",children:[(0,D.jsx)("th",{className:"text-left text-[9px] text-[#5A6F82] tracking-wider uppercase py-2.5 px-4",children:"User"}),(0,D.jsx)("th",{className:"text-left text-[9px] text-[#5A6F82] tracking-wider uppercase py-2.5 px-4",children:"Email"}),(0,D.jsx)("th",{className:"text-left text-[9px] text-[#5A6F82] tracking-wider uppercase py-2.5 px-4",children:"Role"}),(0,D.jsx)("th",{className:"text-left text-[9px] text-[#5A6F82] tracking-wider uppercase py-2.5 px-4",children:"Joined"}),(0,D.jsx)("th",{className:"text-right text-[9px] text-[#5A6F82] tracking-wider uppercase py-2.5 px-4",children:"Actions"})]})}),(0,D.jsx)("tbody",{children:s.map((e,t)=>{var s;return(0,D.jsxs)("tr",{className:"border-b border-[#F5F0E8] last:border-0 hover:bg-[#FDFBF7]/50 transition-colors",children:[(0,D.jsx)("td",{className:"py-2.5 px-4",children:(0,D.jsxs)("div",{className:"flex items-center gap-2.5",children:[(0,D.jsx)("div",{className:"w-7 h-7 rounded-full flex items-center justify-center text-[10px] text-white flex-shrink-0",style:{background:"admin"===e.role?"#A58958":!1===e.is_active?"#999":"#2B2B2B"},children:null===(s=(e.name||e.email||"?")[0])||void 0===s?void 0:s.toUpperCase()}),(0,D.jsx)("span",{className:"text-xs text-[#0B2036]",children:e.name||"Unnamed"})]})}),(0,D.jsx)("td",{className:"py-2.5 px-4 text-[10px] text-[#5A6F82]",children:e.email}),(0,D.jsx)("td",{className:"py-2.5 px-4",children:T(e.role,e.is_active)}),(0,D.jsx)("td",{className:"py-2.5 px-4 text-[10px] text-[#5A6F82]",children:e.created_at?new Date(e.created_at).toLocaleDateString("en-US",{month:"short",day:"numeric",year:"2-digit"}):"\u2014"}),(0,D.jsx)("td",{className:"py-2.5 px-4 text-right",children:(0,D.jsxs)("div",{className:"flex items-center justify-end gap-1",children:[(0,D.jsx)("button",{onClick:()=>k(e),className:"p-1.5 rounded hover:bg-[#594D44]/5 text-[#2B2B2B]",title:"View","data-testid":"view-user-".concat(e.email),children:(0,D.jsx)(J.A,{size:13})}),(0,D.jsx)("button",{onClick:()=>C(e),className:"p-1.5 rounded hover:bg-[#22364A] hover:opacity-90 text-[#A58958]",title:"Reset Password",children:(0,D.jsx)(me.A,{size:13})}),!1===e.is_active?(0,D.jsx)("button",{onClick:()=>_(e),className:"p-1.5 rounded hover:bg-[#2D6A4F]/10 text-[#2D6A4F]",title:"Reactivate",children:(0,D.jsx)(pe.A,{size:13})}):(0,D.jsx)("button",{onClick:()=>E(e),className:"p-1.5 rounded hover:bg-red-50 text-red-400",title:"Deactivate",children:(0,D.jsx)(he.A,{size:13})})]})})]},t)})})]})}),(0,D.jsx)("div",{className:"md:hidden divide-y divide-[#F5F0E8]",children:s.map((e,t)=>{var s;return(0,D.jsxs)("div",{className:"p-3 flex items-center justify-between",onClick:()=>k(e),children:[(0,D.jsxs)("div",{className:"flex items-center gap-2.5 min-w-0",children:[(0,D.jsx)("div",{className:"w-8 h-8 rounded-full flex items-center justify-center text-[10px] text-white flex-shrink-0",style:{background:"admin"===e.role?"#A58958":"#2B2B2B"},children:null===(s=(e.name||e.email||"?")[0])||void 0===s?void 0:s.toUpperCase()}),(0,D.jsxs)("div",{className:"min-w-0",children:[(0,D.jsx)("p",{className:"text-xs text-[#0B2036] truncate",children:e.name||"Unnamed"}),(0,D.jsx)("p",{className:"text-[9px] text-[#5A6F82] truncate",children:e.email})]})]}),(0,D.jsxs)("div",{className:"flex items-center gap-2 flex-shrink-0",children:[T(e.role,e.is_active),(0,D.jsx)(y.A,{size:14,className:"text-[#E3DCDE]"})]})]},t)})}),0===s.length&&(0,D.jsxs)("div",{className:"text-center py-12",children:[(0,D.jsx)(n.A,{size:24,className:"mx-auto text-[#E3DCDE] mb-2"}),(0,D.jsx)("p",{className:"text-xs text-[#5A6F82]",children:"No users found"})]})]})}),S>1&&(0,D.jsxs)("div",{className:"flex items-center justify-between",children:[(0,D.jsxs)("p",{className:"text-[10px] text-[#5A6F82]",children:["Page ",z," of ",S]}),(0,D.jsxs)("div",{className:"flex items-center gap-1",children:[(0,D.jsx)("button",{onClick:()=>m(Math.max(0,x-25)),disabled:0===x,className:"p-1.5 rounded hover:bg-[#0B2036]/5 disabled:opacity-30","data-testid":"prev-page",children:(0,D.jsx)(ue.A,{size:14,className:"text-[#0B2036]"})}),(0,D.jsx)("button",{onClick:()=>m(x+25),disabled:z>=S,className:"p-1.5 rounded hover:bg-[#0B2036]/5 disabled:opacity-30","data-testid":"next-page",children:(0,D.jsx)(y.A,{size:14,className:"text-[#0B2036]"})})]})]}),j&&(0,D.jsxs)("div",{className:"fixed inset-0 z-50 flex justify-end",children:[(0,D.jsx)("div",{className:"absolute inset-0 bg-black/30 backdrop-blur-sm",onClick:()=>v(!1)}),(0,D.jsxs)("div",{className:"relative w-full max-w-md bg-white shadow-xl overflow-y-auto",style:{borderLeft:"1px solid #E3DCDE"},children:[(0,D.jsxs)("div",{className:"sticky top-0 bg-white z-10 px-5 py-4 border-b border-[#
1E3DCDE] flex items-center justify-between",children:[(0,D.jsx)("h3",{className:"text-sm text-[#0B2036] tracking-wider uppercase",style:{fontFamily:"'Manrope', sans-serif"},children:"User Detail"}),(0,D.jsx)("button",{onClick:()=>v(!1),className:"p-1 rounded hover:bg-[#0B2036]/5",children:(0,D.jsx)(b.A,{size:16})})]}),f?(0,D.jsx)("div",{className:"flex items-center justify-center py-20",children:(0,D.jsx)("div",{className:"w-8 h-8 border-2 border-[#1B7B9E]/20 border-t-[#1B7B9E] rounded-full animate-spin"})}):u&&(0,D.jsxs)("div",{className:"p-5 space-y-5",children:[(0,D.jsxs)("div",{className:"flex items-center gap-3",children:[(0,D.jsx)("div",{className:"w-12 h-12 rounded-full flex items-center justify-center text-lg text-white",style:{background:"admin"===u.role?"#A58958":"#2B2B2B"},children:null===(e=(u.name||u.email||"?")[0])||void 0===e?void 0:e.toUpperCase()}),(0,D.jsxs)("div",{children:[(0,D.jsx)("p",{className:"text-sm font-medium text-[#0B2036]",children:u.name||"Unnamed"}),(0,D.jsx)("p",{className:"text-[10px] text-[#5A6F82]",children:u.email}),(0,D.jsxs)("div",{className:"flex items-center gap-2 mt-1",children:[T(u.role,u.is_active),u.is_premium&&(0,D.jsx)("span",{className:"text-[8px] px-1.5 py-0.5 rounded-full bg-[#E09F3E]/10 text-[#E09F3E] tracking-wider uppercase",children:"premium"})]})]})]}),(0,D.jsxs)("div",{className:"grid grid-cols-3 gap-2",children:[(0,D.jsxs)("div",{className:"bg-[#FDFBF7] rounded-lg p-3 text-center",children:[(0,D.jsx)("p",{className:"text-lg font-light text-[#0B2036]",style:{fontFamily:"'Cormorant Garamond', serif"},children:u.activities_completed||0}),(0,D.jsx)("p",{className:"text-[8px] text-[#5A6F82] tracking-wider uppercase",children:"Completed"})]}),(0,D.jsxs)("div",{className:"bg-[#FDFBF7] rounded-lg p-3 text-center",children:[(0,D.jsx)("p",{className:"text-lg font-light text-[#0B2036]",style:{fontFamily:"'Cormorant Garamond', serif"},children:u.courses_in_progress||0}),(0,D.jsx)("p",{className:"text-[8px] text-[#5A6F82] tracking-wider uppercase",children:"In Progress"})]}),(0,D.jsxs)("div",{className:"bg-[#FDFBF7] rounded-lg p-3 text-center",children:[(0,D.jsx)("p",{className:"text-lg font-light text-[#0B2036]",style:{fontFamily:"'Cormorant Garamond', serif"},children:u.coins||0}),(0,D.jsx)("p",{className:"text-[8px] text-[#5A6F82] tracking-wider uppercase",children:"Coins"})]})]}),(0,D.jsxs)("div",{className:"space-y-2",children:[(0,D.jsx)(ve,{label:"Joined",value:u.created_at?new Date(u.created_at).toLocaleDateString():"\u2014"}),(0,D.jsx)(ve,{label:"Last Login",value:u.last_login?new Date(u.last_login).toLocaleDateString():"\u2014"}),(0,D.jsx)(ve,{label:"Membership",value:u.membership_tier||u.membershipTier||"Free"}),(0,D.jsx)(ve,{label:"Status",value:!1===u.is_active?"Inactive":"Active"})]}),(null===(t=u.payments)||void 0===t?void 0:t.length)>0&&(0,D.jsxs)("div",{children:[(0,D.jsx)("h4",{className:"text-[10px] text-[#5A6F82] tracking-wider uppercase mb-2",children:"Payment History"}),(0,D.jsx)("div",{className:"space-y-1.5",children:u.payments.slice(0,5).map((e,t)=>(0,D.jsxs)("div",{className:"flex items-center justify-between py-1 border-b border-[#F5F0E8] last:border-0",children:[(0,D.jsx)("span",{className:"text-[10px] text-[#0B2036]",children:e.description||"Payment"}),(0,D.jsxs)("span",{className:"text-[10px] text-[#2D6A4F]",children:["$",(e.amount||0).toFixed(2)]})]},t))})]}),(0,D.jsxs)("div",{className:"space-y-2 pt-3 border-t border-[#E3DCDE]",children:[(0,D.jsxs)("button",{onClick:()=>C(u),className:"w-full flex items-center gap-2 px-3 py-2 rounded-lg text-[10px] tracking-wider uppercase hover:bg-[#22364A] hover:opacity-90 text-[#A58958] border border-[#1B7B9E]/20",children:[(0,D.jsx)(me.A,{size:13})," Reset Password"]}),!1===u.is_active?(0,D.jsxs)("button",{onClick:()=>_(u),className:"w-full flex items-center gap-2 px-3 py-2 rounded-lg text-[10px] tracking-wider uppercase hover:bg-[#2D6A4F]/5 text-[#2D6A4F] border border-[#2D6A4F]/20",children:[(0,D.jsx)(pe.A,{size:13})," Reactivate Account"]}):(0,D.jsxs)("button",{onClick:()=>E(u),className:"w-full flex items-center gap-2 px-3 py-2 rounded-lg text-[10px] tracking-wider up
1percase hover:bg-red-50 text-red-400 border border-red-200",children:[(0,D.jsx)(he.A,{size:13})," Deactivate Account"]})]})]})]})]})]})};var fe=s(52607),Ne=s(77737),Be=s(32369),ye=s(46355),Ae=s(55120),we=s(31855),ke=s(88276),Ee=s(40978),Fe=s(48110);const _e="https://peerlessetiquette.com",Ce=()=>{var e,t;const[s,l]=(0,a.useState)([]),[i,c]=(0,a.useState)(!0),[o,x]=(0,a.useState)(null),[m,p]=(0,a.useState)(1),[h,u]=(0,a.useState)(1),[g,j]=(0,a.useState)(0),[v,f]=(0,a.useState)(""),[N,B]=(0,a.useState)(""),[w,k]=(0,a.useState)(""),[_,z]=(0,a.useState)(""),[T,M]=(0,a.useState)(!1),[L,R]=(0,a.useState)(!1),[P,G]=(0,a.useState)(!1),[$,W]=(0,a.useState)(null),[O,H]=(0,a.useState)({title:"",description:"",event_type:"workshop",category:"general",date:"",start_time:"",end_time:"",timezone:"America/New_York",location_type:"virtual",location_details:"",max_attendees:null,price:0,member_price:null,is_member_only:!1,image_url:"",instructor:"Mrs. Benjamin",tags:[]}),[V,Y]=(0,a.useState)(!1),[Q,Z]=(0,a.useState)(null),K=()=>localStorage.getItem("adminToken"),X=function(e){Z({message:e,type:arguments.length>1&&void 0!==arguments[1]?arguments[1]:"success"}),setTimeout(()=>Z(null),3e3)},ee=(0,a.useCallback)(async()=>{c(!0);try{const e=new URLSearchParams({page:m.toString(),limit:"20"});v&&e.append("search",v),N&&e.append("event_type",N),w&&e.append("status",w),_&&e.append("category",_);const t=await r.A.get("".concat(_e,"/api/admin/events?").concat(e),{headers:{Authorization:"Bearer ".concat(K())}});l(t.data.events),u(t.data.total_pages),j(t.data.total)}catch(e){console.error("Error fetching events:",e),X("Failed to fetch events","error")}finally{c(!1)}},[m,v,N,w,_]),te=async()=>{try{const e=await r.A.get("".concat(_e,"/api/admin/events/stats"),{headers:{Authorization:"Bearer ".concat(K())}});x(e.data)}catch(e){console.error("Error fetching stats:",e)}};(0,a.useEffect)(()=>{ee(),te()},[ee]);const se=()=>{H({title:"",description:"",event_type:"workshop",category:"general",date:"",start_time:"",end_time:"",timezone:"America/New_York",location_type:"virtual",location_details:"",max_attendees:null,price:0,member_price:null,is_member_only:!1,image_url:"",instructor:"Mrs. Benjamin",tags:[]})},ae=e=>({workshop:"bg-blue-500/20 text-blue-400",webinar:"bg-purple-500/20 text-purple-400",masterclass:"bg-[#A58958]/20 text-[#A58958]",consultation:"bg-green-500/20 text-green-400",live_qa:"bg-pink-500/20 text-pink-400",ceremony:"bg-amber-500/20 text-amber-400"}[e]||"bg-white/10 text-[#5e5e5e]"),le=e=>{const t=(new Date).toISOString().split("T")[0];return e.is_archived?{label:"Archived",style:"bg-gray-500/20 text-gray-400"}:e.date<t?{label:"Past",style:"bg-red-500/20 text-red-400"}:e.date===t?{label:"Today",style:"bg-green-500/20 text-green-400"}:{label:"Upcoming",style:"bg-blue-500/20 text-blue-400"}},re=e=>e?new Date(e+"T00:00:00").toLocaleDateString("en-US",{weekday:"short",month:"short",day:"numeric",year:"numeric"}):"-";return(0,D.jsxs)("div",{className:"space-y-6",children:[Q&&(0,D.jsxs)("div",{className:"fixed top-4 right-4 z-50 px-4 py-3 rounded-lg flex items-center gap-2 ".concat("error"===Q.type?"bg-red-500/90":"bg-green-500/90"," text-[#2B2B2B] shadow-lg"),children:["error"===Q.type?(0,D.jsx)(F.A,{size:18}):(0,D.jsx)(E.A,{size:18}),Q.message]}),(0,D.jsxs)("div",{className:"flex items-center justify-between",children:[(0,D.jsxs)("div",{children:[(0,D.jsx)("img",{loading:"lazy",src:"/assets/crest.png",alt:"",className:"w-16 h-16 mx-auto mb-5 opacity-90"}),(0,D.jsx)("h1",{className:"text-2xl text-[#2B2B2B] font-light tracking-wide",children:"Event Management"}),(0,D.jsx)("p",{className:"text-[#5e5e5e] text-sm mt-1",children:"Manage workshops, webinars, and live sessions"})]}),(0,D.jsxs)(C.$,{onClick:()=>{se(),M(!0)},className:"navy-cta bg-[#22364A] hover:opacity-90 text-black",children:[(0,D.jsx)(fe.A,{size:18,className:"mr-2"}),"Create Event"]})]}),o&&(0,D.jsxs)("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4",children:[(0,D.jsx)("div",{className:"bg-[#f3f0e8] border border-[#1B7B9E]/20 p-4 rounded-lg",children:(0,D.jsxs)("div",{className:"flex items-center gap-3",children:[(0,D.jsx)("div",{className:"navy-cta p-2 bg-[#22364A] hover:opacity-90 rounded-lg",children:(0,D.jsx)(d.A,{size:20,className:"text-[#A58958]"})}),(0,D.jsxs)("div",{children:[(0,D.jsx)("p",{className:"text-2xl text-[#2B2B2B] font-light",children:o.total_events}),(0,D.jsx)("p",{className:"text-[#5e5e5e] text-xs",children:"Total Events"})]})]})}),(0,D.jsx)("div",{className:"bg-[#f3f0e8] border border-[#1B7B9E]/20 p-4 rounded-lg",children:(0,D.jsxs)("div",{className:"flex items-center gap-3",children:[(0,D.jsx)("div",{className:"p-2 bg-blue-500/10 rounded-lg",children:(0,D.jsx)(Ne.A,{size:20,className:"text-blue-400"})}),(0,D.jsxs)("div",{children:[(0,D.jsx)("p",{className:"text-2xl text-[#2B2B2B] font-light",children:o.upcoming_events}),(0,D.jsx)("p",{className:"text-[#5e5e5e] text-xs",children:"Upcoming"})]})]})}),(0,D.jsx)("div",{className:"bg-[#f3f0e8] border border-[#1B7B9E]/20 p-4 rounded-lg",children:(0,D.jsxs)("div",{className:"flex items-center gap-3",children:[(0,D.jsx)("div",{className:"p-2 bg-green-500/10 rounded-lg",children:(0,D.jsx)(n.A,{size:20,className:"text-green-400"})}),(0,D.jsxs)("div",{children:[(0,D.jsx)("p",{className:"text-2xl text-[#2B2B2B] font-light",children:o.total_registrations}),(0,D.jsx)("p",{className:"text-[#5e5e5e] text-xs",children:"Registrations"})]})]})}),(0,D.jsx)("div",{className:"bg-[#f3f0e8] border border-[#1B7B9E]/20 p-4 rounded-lg",children:(0,D.jsxs)("div",{className:"flex items-center gap-3",children:[(0,D.jsx)("div",{className:"p-2 bg-gray-500/10 rounded-lg",children:(0,D.jsx)(Be.A,{size:20,className:"text-gray-400"})}),(0,D.jsxs)("div",{children:[(0,D.jsx)("p",{className:"text-2xl text-[#2B2B2B] font-light",children:o.ar
1chived_events}),(0,D.jsx)("p",{className:"text-[#5e5e5e] text-xs",children:"Archived"})]})]})})]}),(0,D.jsx)("div",{className:"bg-[#f3f0e8] border border-[#1B7B9E]/20 p-4 rounded-lg",children:(0,D.jsxs)("form",{onSubmit:e=>{e.preventDefault(),p(1),ee()},className:"flex flex-wrap gap-4",children:[(0,D.jsx)("div",{className:"flex-1 min-w-[200px]",children:(0,D.jsxs)("div",{className:"relative",children:[(0,D.jsx)(q.A,{size:18,className:"absolute left-3 top-1/2 -translate-y-1/2 text-[#2B2B2B]/30"}),(0,D.jsx)(S.p,{type:"text",placeholder:"Search by title...",value:v,onChange:e=>f(e.target.value),className:"pl-10 bg-[#405353] border-[#1B7B9E]/20 text-[#2B2B2B] placeholder:text-[#2B2B2B]/30"})]})}),(0,D.jsxs)("select",{value:N,onChange:e=>{B(e.target.value),p(1)},className:"bg-[#405353] border border-[#1B7B9E]/20 text-[#2B2B2B] px-4 py-2 rounded-md",children:[(0,D.jsx)("option",{value:"",children:"All Types"}),(0,D.jsx)("option",{value:"workshop",children:"Workshop"}),(0,D.jsx)("option",{value:"webinar",children:"Webinar"}),(0,D.jsx)("option",{value:"masterclass",children:"Masterclass"}),(0,D.jsx)("option",{value:"consultation",children:"Consultation"}),(0,D.jsx)("option",{value:"live_qa",children:"Live Q&A"}),(0,D.jsx)("option",{value:"ceremony",children:"Ceremony"})]}),(0,D.jsxs)("select",{value:w,onChange:e=>{k(e.target.value),p(1)},className:"bg-[#405353] border border-[#1B7B9E]/20 text-[#2B2B2B] px-4 py-2 rounded-md",children:[(0,D.jsx)("option",{value:"",children:"All Status"}),(0,D.jsx)("option",{value:"upcoming",children:"Upcoming"}),(0,D.jsx)("option",{value:"past",children:"Past"}),(0,D.jsx)("option",{value:"archived",children:"Archived"})]}),(0,D.jsxs)("select",{value:_,onChange:e=>{z(e.target.value),p(1)},className:"bg-[#405353] border border-[#1B7B9E]/20 text-[#2B2B2B] px-4 py-2 rounded-md",children:[(0,D.jsx)("option",{value:"",children:"All Categories"}),(0,D.jsx)("option",{value:"general",children:"General"}),(0,D.jsx)("option",{value:"dining",children:"Dining"}),(0,D.jsx)("option",{value:"business",children:"Business"}),(0,D.jsx)("option",{value:"social",children:"Social"}),(0,D.jsx)("option",{value:"communication",children:"Communication"}),(0,D.jsx)("option",{value:"children",children:"Children"}),(0,D.jsx)("option",{value:"advanced",children:"Advanced"})]}),(0,D.jsxs)(C.$,{type:"submit",variant:"outline",className:"border-[#1B7B9E]/20 text-[#2B2B2B] hover:bg-white/5",children:[(0,D.jsx)(ye.A,{size:18,className:"mr-2"}),"Apply"]}),(0,D.jsx)(C.$,{type:"button",variant:"ghost",onClick:()=>{f(""),B(""),k(""),z(""),p(1)},className:"text-[#5e5e5e] hover:text-[#2B2B2B]",children:(0,D.jsx)(I.A,{size:18})})]})}),(0,D.jsxs)("div",{className:"bg-[#f3f0e8] border border-[#1B7B9E]/20 rounded-lg overflow-hidden",children:[(0,D.jsx)("div",{className:"overflow-x-auto",children:(0,D.jsxs)("table",{className:"w-full",children:[(0,D.jsx)("thead",{children:(0,D.jsxs)("tr",{className:"border-b border-[#1B7B9E]/20",children:[(0,D.jsx)("th",{className:"text-left p-4 text-[#5e5e5e] text-xs uppercase tracking-wider",children:"Event"}),(0,D.jsx)("th",{className:"text-left p-4 text-[#5e5e5e] text-xs uppercase tracking-wider",children:"Type"}),(0,D.jsx)("th",{className:"text-left p-4 text-[#5e5e5e] text-xs uppercase tracking-wider",children:"Date"}),(0,D.jsx)("th",{className:"text-left p-4 text-[#5e5e5e] text-xs uppercase tracking-wider",children:"Status"}),(0,D.jsx)("th",{className:"text-left p-4 text-[#5e5e5e] text-xs uppercase tracking-wider",children:"Registrations"}),(0,D.jsx)("th",{className:"text-right p-4 text-[#5e5e5e] text-xs uppercase tracking-wider",children:"Actions"})]})}),(0,D.jsx)("tbody",{children:i?(0,D.jsx)("tr",{children:(0,D.jsx)("td",{colSpan:6,className:"p-8 text-center text-[#5e5e5e]",children:"Loading..."})}):0===s.length?(0,D.jsx)("tr",{children:(0,D.jsx)("td",{colSpan:6,className:"p-8 text-center text-[#5e5e5e]",children:"No events found"})}):s.map(e=>{var t;const s=le(e);return(0,D.jsxs)("tr",{className:"border-b border-white/5 hover:bg-white/5",children:[(0,D.jsx)("td",{className:"p-4",children:(0,D.jsxs)("div",{children:[(0,D.jsx)("p",{className:"text-[#2B2B2B] font-medium",children:e.title}),(0,D.jsxs)("p",{className:"text-[#5e5e5e] text-sm flex items-center gap-2",children:["virtual"===e.location_type?(0,D.jsxs)(D.Fragment,{children:[(0,D.jsx)(Ae.A,{size:12})," Virtual"]}):(0,D.jsxs)(D.Fragment,{children:[(0,D.jsx)(we.A,{size:12})," ",e.location_type]}),e.is_member_only&&(0,D.jsxs)("span",{className:"text-[#A58958] flex items-center gap-1",children:[(0,D.jsx)(ke.A,{size:12})," Members"]})]})]})}),(0,D.jsx)("td",{className:"p-4",children:(0,D.jsx)("span",{className:"px-2 py-1 rounded text-xs ".concat(ae(e.event_type)),children:null===(t=e.event_type)||void 0===t?void 0:t.replace("_"," ")})}),(0,D.jsx)("td",{className:"p-4",children:(0,D.jsxs)("div",{className:"text-[#2B2B2B] text-sm",children:[(0,D.jsx)("p",{children:re(e.date)}),(0,D.jsxs)("p",{className:"text-[#5e5e5e]",children:[e.start_time," - ",e.end_time]})]})}),(0,D.jsx)("td",{className:"p-4",children:(0,D.jsx)("span",{className:"px-2 py-1 rounded text-xs ".concat(s.style),children:s.label})}),(0,D.jsx)("td",{className:"p-4",children:(0,D.jsxs)("div",{className:"flex items-center gap-2 text-[#5e5e5e]",children:[(0,D.jsx)(n.A,{size:14}),e.registration_count||0,e.max_attendees&&(0,D.jsxs)("span",{className:"text-[#5e5e5e]",children:["/ ",e.max_attendees]})]})}),(0,D.jsx)("td",{className:"p-4 text-right",children:(0,D.jsxs)("div",{className:"flex items-center justify-end gap-2",children:[(0,D.jsx)("button",{onClick:()=>(async e=>{try{const t=await r.A.get("".concat(_e,"/api/admin/events/").concat(e.id),{headers:{Authorization:"Bearer ".concat(K())}});W(t.data),G(!0)}catch(t){X("Failed to fetch event details","error")}})(e),className:"p-2 text-[#5e5e5e] hover:text-[#2B2B2B] hover:bg-white/10 rounded",title:"View Details",children:(0,D.jsx)(J.A,{size:16})}),(0,D.jsx)("button",{onClick:()=>(e=>{W(e),H({title:e.title||"",description:e.description||"",event_type:e.event_type||"workshop",category:e.category||"general",date:e.date||"",start_time:e.start_time||"",end_time:e.end_time||"",timezone:e.timezone||"America/Ne
1w_York",location_type:e.location_type||"virtual",location_details:e.location_details||"",max_attendees:e.max_attendees||null,price:e.price||0,member_price:e.member_price||null,is_member_only:e.is_member_only||!1,image_url:e.image_url||"",instructor:e.instructor||"Mrs. Benjamin",tags:e.tags||[],zoom_link:e.zoom_link||"",recording_url:e.recording_url||""}),R(!0)})(e),className:"p-2 text-[#5e5e5e] hover:text-[#A58958] hover:bg-[#22364A] hover:opacity-90 rounded",title:"Edit Event",children:(0,D.jsx)(Ee.A,{size:16})}),(0,D.jsx)("button",{onClick:()=>(async e=>{try{const t=await r.A.post("".concat(_e,"/api/admin/events/").concat(e.id,"/duplicate"),{},{headers:{Authorization:"Bearer ".concat(K())}});X("Event duplicated"),ee(),W(t.data.event),H((0,A.A)((0,A.A)({},t.data.event),{},{tags:t.data.event.tags||[]})),R(!0)}catch(a){var t,s;X((null===(t=a.response)||void 0===t||null===(s=t.data)||void 0===s?void 0:s.detail)||"Failed to duplicate event","error")}})(e),className:"p-2 text-[#5e5e5e] hover:text-blue-400 hover:bg-blue-500/10 rounded",title:"Duplicate Event",children:(0,D.jsx)(U.A,{size:16})}),e.is_archived?(0,D.jsx)("button",{onClick:()=>(async e=>{try{await r.A.post("".concat(_e,"/api/admin/events/").concat(e.id,"/unarchive"),{},{headers:{Authorization:"Bearer ".concat(K())}}),X("Event restored"),ee(),te()}catch(a){var t,s;X((null===(t=a.response)||void 0===t||null===(s=t.data)||void 0===s?void 0:s.detail)||"Failed to restore event","error")}})(e),className:"p-2 text-[#5e5e5e] hover:text-green-400 hover:bg-green-500/10 rounded",title:"Restore Event",children:(0,D.jsx)(Fe.A,{size:16})}):(0,D.jsx)("button",{onClick:()=>(async e=>{if(window.confirm('Are you sure you want to archive "'.concat(e.title,'"?')))try{await r.A.delete("".concat(_e,"/api/admin/events/").concat(e.id),{headers:{Authorization:"Bearer ".concat(K())}}),X("Event archived"),ee(),te()}catch(a){var t,s;X((null===(t=a.response)||void 0===t||null===(s=t.data)||void 0===s?void 0:s.detail)||"Failed to archive event","error")}})(e),className:"p-2 text-[#5e5e5e] hover:text-red-400 hover:bg-red-500/10 rounded",title:"Archive Event",children:(0,D.jsx)(Be.A,{size:16})})]})})]},e.id)})})]})}),h>1&&(0,D.jsxs)("div",{className:"flex items-center justify-between p-4 border-t border-[#1B7B9E]/20",children:[(0,D.jsxs)("p",{className:"text-[#5e5e5e] text-sm",children:["Showing ",20*(m-1)+1," - ",Math.min(20*m,g)," of ",g]}),(0,D.jsxs)("div",{className:"flex items-center gap-2",children:[(0,D.jsx)(C.$,{variant:"outline",size:"sm",onClick:()=>p(e=>Math.max(1,e-1)),disabled:1===m,className:"border-[#1B7B9E]/20 text-[#2B2B2B]",children:(0,D.jsx)(ue.A,{size:16})}),(0,D.jsxs)("span",{className:"text-[#5e5e5e] text-sm px-2",children:["Page ",m," of ",h]}),(0,D.jsx)(C.$,{variant:"outline",size:"sm",onClick:()=>p(e=>Math.min(h,e+1)),disabled:m===h,className:"border-[#1B7B9E]/20 text-[#2B2B2B]",children:(0,D.jsx)(y.A,{size:16})})]})]})]}),T&&(0,D.jsx)("div",{className:"fixed inset-0 bg-[#f3f0e8]/70 flex items-center justify-center z-50",children:(0,D.jsxs)("div",{className:"bg-[#f3f0e8] border border-[#1B7B9E]/20 rounded-lg w-full max-w-2xl mx-4 max-h-[90vh] overflow-y-auto",children:[(0,D.jsxs)("div",{className:"flex items-center justify-between p-4 border-b border-[#1B7B9E]/20 sticky top-0 bg-[#f3f0e8]",children:[(0,D.jsx)("h2",{className:"text-[#2B2B2B] font-medium",children:"Create New Event"}),(0,D.jsx)("button",{onClick:()=>M(!1),className:"text-[#5e5e5e] hover:text-[#2B2B2B]",children:(0,D.jsx)(b.A,{size:20})})]}),(0,D.jsxs)("form",{onSubmit:async e=>{e.preventDefault(),Y(!0);try{await r.A.post("".concat(_e,"/api/admin/events"),O,{headers:{Authorization:"Bearer ".concat(K())}}),X("Event created successfully"),M(!1),se(),ee(),te()}catch(a){var t,s;X((null===(t=a.response)||void 0===t||null===(s=t.data)||void 0===s?void 0:s.detail)||"Failed to create event","error")}finally{Y(!1)}},className:"p-4 space-y-4",children:[(0,D.jsxs)("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[(0,D.jsxs)("div",{className:"md:col-span-2",children:[(0,D.jsx)("label",{className:"block text-[#5e5e5e] text-sm mb-1",children:"Event Title"}
1),(0,D.jsx)(S.p,{value:O.title,onChange:e=>H((0,A.A)((0,A.A)({},O),{},{title:e.target.value})),required:!0,className:"bg-[#405353] border-[#1B7B9E]/20 text-[#2B2B2B]"})]}),(0,D.jsxs)("div",{className:"md:col-span-2",children:[(0,D.jsx)("label",{className:"block text-[#5e5e5e] text-sm mb-1",children:"Description"}),(0,D.jsx)("textarea",{value:O.description,onChange:e=>H((0,A.A)((0,A.A)({},O),{},{description:e.target.value})),rows:3,className:"w-full bg-[#405353] border border-[#1B7B9E]/20 text-[#2B2B2B] px-3 py-2 rounded-md"})]}),(0,D.jsxs)("div",{children:[(0,D.jsx)("label",{className:"block text-[#5e5e5e] text-sm mb-1",children:"Event Type"}),(0,D.jsxs)("select",{value:O.event_type,onChange:e=>H((0,A.A)((0,A.A)({},O),{},{event_type:e.target.value})),className:"w-full bg-[#405353] border border-[#1B7B9E]/20 text-[#2B2B2B] px-3 py-2 rounded-md",children:[(0,D.jsx)("option",{value:"workshop",children:"Workshop"}),(0,D.jsx)("option",{value:"webinar",children:"Webinar"}),(0,D.jsx)("option",{value:"masterclass",children:"Masterclass"}),(0,D.jsx)("option",{value:"consultation",children:"Consultation"}),(0,D.jsx)("option",{value:"live_qa",children:"Live Q&A"}),(0,D.jsx)("option",{value:"ceremony",children:"Ceremony"})]})]}),(0,D.jsxs)("div",{children:[(0,D.jsx)("label",{className:"block text-[#5e5e5e] text-sm mb-1",children:"Category"}),(0,D.jsxs)("select",{value:O.category,onChange:e=>H((0,A.A)((0,A.A)({},O),{},{category:e.target.value})),className:"w-full bg-[#405353] border border-[#1B7B9E]/20 text-[#2B2B2B] px-3 py-2 rounded-md",children:[(0,D.jsx)("option",{value:"general",children:"General"}),(0,D.jsx)("option",{value:"dining",children:"Dining"}),(0,D.jsx)("option",{value:"business",children:"Business"}),(0,D.jsx)("option",{value:"social",children:"Social"}),(0,D.jsx)("option",{value:"communication",children:"Communication"}),(0,D.jsx)("option",{value:"children",children:"Children"}),(0,D.jsx)("option",{value:"advanced",children:"Advanced"})]})]}),(0,D.jsxs)("div",{children:[(0,D.jsx)("label",{className:"block text-[#5e5e5e] text-sm mb-1",children:"Date"}),(0,D.jsx)(S.p,{type:"date",value:O.date,onChange:e=>H((0,A.A)((0,A.A)({},O),{},{date:e.target.value})),required:!0,className:"bg-[#405353] border-[#1B7B9E]/20 text-[#2B2B2B]"})]}),(0,D.jsxs)("div",{className:"grid grid-cols-2 gap-2",children:[(0,D.jsxs)("div",{children:[(0,D.jsx)("label",{className:"block text-[#5e5e5e] text-sm mb-1",children:"Start Time"}),(0,D.jsx)(S.p,{type:"time",value:O.start_time,onChange:e=>H((0,A.A)((0,A.A)({},O),{},{start_time:e.target.value})),required:!0,className:"bg-[#405353] border-[#1B7B9E]/20 text-[#2B2B2B]"})]}),(0,D.jsxs)("div",{children:[(0,D.jsx)("label",{className:"block text-[#5e5e5e] text-sm mb-1",children:"End Time"}),(0,D.jsx)(S.p,{type:"time",value:O.end_time,onChange:e=>H((0,A.A)((0,A.A)({},O),{},{end_time:e.target.value})),required:!0,className:"bg-[#405353] border-[#1B7B9E]/20 text-[#2B2B2B]"})]})]}),(0,D.jsxs)("div",{children:[(0,D.jsx)("label",{className:"block text-[#5e5e5e] text-sm mb-1",children:"Location Type"}
1),(0,D.jsxs)("select",{value:O.location_type,onChange:e=>H((0,A.A)((0,A.A)({},O),{},{location_type:e.target.value})),className:"w-full bg-[#405353] border border-[#1B7B9E]/20 text-[#2B2B2B] px-3 py-2 rounded-md",children:[(0,D.jsx)("option",{value:"virtual",children:"Virtual (Online)"}),(0,D.jsx)("option",{value:"in_person",children:"In Person"}),(0,D.jsx)("option",{value:"hybrid",children:"Hybrid"})]})]}),(0,D.jsxs)("div",{children:[(0,D.jsx)("label",{className:"block text-[#5e5e5e] text-sm mb-1",children:"Max Attendees"}),(0,D.jsx)(S.p,{type:"number",value:O.max_attendees||"",onChange:e=>H((0,A.A)((0,A.A)({},O),{},{max_attendees:e.target.value?parseInt(e.target.value):null})),placeholder:"Unlimited",className:"bg-[#405353] border-[#1B7B9E]/20 text-[#2B2B2B]"})]}),(0,D.jsxs)("div",{children:[(0,D.jsx)("label",{className:"block text-[#5e5e5e] text-sm mb-1",children:"Price ($)"}),(0,D.jsx)(S.p,{type:"number",step:"0.01",value:O.price,onChange:e=>H((0,A.A)((0,A.A)({},O),{},{price:parseFloat(e.target.value)||0})),className:"bg-[#405353] border-[#1B7B9E]/20 text-[#2B2B2B]"})]}),(0,D.jsxs)("div",{children:[(0,D.jsx)("label",{className:"block text-[#5e5e5e] text-sm mb-1",children:"Member Price ($)"}),(0,D.jsx)(S.p,{type:"number",step:"0.01",value:O.member_price||"",onChange:e=>H((0,A.A)((0,A.A)({},O),{},{member_price:e.target.value?parseFloat(e.target.value):null})),placeholder:"Auto (20% off)",className:"bg-[#405353] border-[#1B7B9E]/20 text-[#2B2B2B]"})]}),(0,D.jsxs)("div",{children:[(0,D.jsx)("label",{className:"block text-[#5e5e5e] text-sm mb-1",children:"Instructor"}),(0,D.jsx)(S.p,{value:O.instructor,onChange:e=>H((0,A.A)((0,A.A)({},O),{},{instructor:e.target.value})),className:"bg-[#405353] border-[#1B7B9E]/20 text-[#2B2B2B]"})]}),(0,D.jsxs)("div",{className:"flex items-center gap-2",children:[(0,D.jsx)("input",{type:"checkbox",id:"is_member_only",checked:O.is_member_only,onChange:e=>H((0,A.A)((0,A.A)({},O),{},{is_member_only:e.target.checked})),className:"rounded bg-[#405353] border-[#1B7B9E]/20"}),(0,D.jsx)("label",{htmlFor:"is_member_only",className:"text-[#2B2B2B] text-sm",children:"Members Only"})]})]}),(0,D.jsxs)("div",{className:"flex gap-3 pt-4",children:[(0,D.jsx)(C.$,{type:"button",variant:"outline",onClick:()=>M(!1),className:"flex-1 border-[#1B7B9E]/20 text-[#2B2B2B]",children:"Cancel"}),(0,D.jsx)(C.$,{type:"submit",disabled:V,className:"navy-cta flex-1 bg-[#22364A] hover:opacity-90 text-black",children:V?"Creating...":"Create Event"})]})]})]})}),L&&$&&(0,D.jsx)("div",{className:"fixed inset-0 bg-[#f3f0e8]/70 flex items-center justify-center z-50",children:(0,D.jsxs)("div",{className:"bg-[#f3f0e8] border border-[#1B7B9E]/20 rounded-lg w-full max-w-2xl mx-4 max-h-[90vh] overflow-y-auto",children:[(0,D.jsxs)("div",{className:"flex items-center justify-between p-4 border-b border-[#1B7B9E]/20 sticky top-0 bg-[#f3f0e8]",children:[(0,D.jsx)("h2",{className:"text-[#2B2B2B] font-medium",children:"Edit Event"}),(0,D.jsx)("button",{onClick:()=>R(!1),className:"text-[#5e5e5e] hover:text-[#2B2B2B]",children:(0,D.jsx)(b.A,{size:20})})]}),(0,D.jsxs)("form",{onSubmit:async e=>{if(e.preventDefault(),$){Y(!0);try{await r.A.put("".concat(_e,"/api/admin/events/").concat($.id),O,{headers:{Authorization:"Bearer ".concat(K())}}),X("Event updated successfully"),R(!1),ee()}catch(a){var t,s;X((null===(t=a.response)||void 0===t||null===(s=t.data)||void 0===s?void 0:s.detail)||"Failed to update event","error")}finally{Y(!1)}}},className:"p-4 space-y-4",children:[(0,D.jsxs)("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[(0,D.jsxs)("div",{className:"md:col-span-2",children:[(0,D.jsx)("label",{className:"block text-[#5e5e5e] text-sm mb-1",children:"Event Title"}),(0,D.jsx)(S.p,{value:O.title,onChange:e=>H((0,A.A)((0,A.A)({},O),{},{title:e.target.value})),className:"bg-[#405353] border-[#1B7B9E]/20 text-[#2B2B2B]"})]}),(0,D.jsxs)("div",{className:"md:col-span-2",children:[(0,D.jsx)("label",{className:"block text-[#5e5e5e] text-sm mb-1",children:"Description"}),(0,D.jsx)("textarea",{value:O.description,onChange:e=>H((0,A.A)((0,A.A)({},O),{},{description:e.target.value})),rows:3,className:"w-full bg-[#405353] border border-[#1B7B9E]/20 text-[#2B2B2B] px-3 py-2 rounded-md"})]}),(0,D.jsxs)("div",{children:[(0,D.jsx)("label",{className:"block text-[#5e5e5e] text-sm mb-1",children:"Date"}),(0,D.jsx)(S.p,{type:"date",value:O.date,onChange:e=>H((0,A.A)((0,A.A)({},O),{},{date:e.target.value})),className:"bg-[#405353] border-[#1B7B9E]/20 text-[#2B2B2B]"})]}),(0,D.jsxs)("div",{className:"grid grid-cols-2 gap-2",children:[(0,D.jsxs)("div",{children:[(0,D.jsx)("label",{className:"block text-[#5e5e5e] text-sm mb-1",children:"Start"}),(0,D.jsx)(S.p,{type:"time",value:O.start_time,onChange:e=>H((0,A.A)((0,A.A)({},O),{},{start_time:e.target.value})),className:"bg-[#405353] border-[#1B7B9E]/20 text-[#2B2B2B]"})]}),(0,D.jsxs)("div",{children:[(0,D.jsx)("label",{className:"block text-[#5e5e5e] text-sm mb-1",children:"End"}),(0,D.jsx)(S.p,{type:"time",value:O.end_time,onChange:e=>H((0,A.A)((0,A.A)({},O),{},{end_time:e.target.value})),className:"bg-[#405353] border-[#1B7B9E]/20 text-[#2B2B2B]"})]})]}),(0,D.jsxs)("div",{children:[(0,D.jsx)("label",{className:"block text-[#5e5e5e] text-sm mb-1",children:"Price ($)"}),(0,D.jsx)(S.p,{type:"number",step:"0.01",value:O.price,onChange:e=>H((0,A.A)((0,A.A)({},O),{},{price:parseFloat(e.target.value)||0})),className:"bg-[#405353] border-[#1B7B9E]/20 text-[#2B2B2B]"})]}),(0,D.jsxs)("div",{children:[(0,D.jsx)("label",{className:"block text-[#5e5e5e] text-sm mb-1",children:"Max Attendees"}),(0,D.jsx)(S.p,{type:"number",value:O.max_attendees||"",onChange:e=>H((0,A.A)((0,A.A)({},O),{},{max_attendees:e.target.value?parseInt(e.target.value):null})),placeholder:"Unlimited",className:"bg-[#405353] border-[#1B7B9E]/20 text-[#2B2B2B]"})]}),(0,D.jsxs)("div",{className:"md:col-span-2",children:[(0,D.jsx)("label",{className:"block text-[#5e5e5e] text-sm mb-1",children:"Zoom Link"}),(0,D.jsx)(S.p,{value:O.zoom_link||"",onChange:e=>H((0,A.A)((0,A.A)({},O),{},{zoom_link:e.target.value})),placeholder:"https://zoom.us/j/...",className:"bg-[#405353] border-[#1B7B9E]/20 text-[#2B2B2B]"})]}),(0,D.jsxs)("div",{className:"md:col-span-2",children:[(0,D.jsx)("label",{className:"block text-[#5e5e5e] text-sm mb-1",children:"Recording URL (after event)"}),(0,D.jsx)(S.p,{value:O.recording_url||"",onChange:e=>H((0,A.A)((0,A.A)({},O),{},{recording_url:e.target.value})),placeholder:"https://...",className:"bg-[#405353] border-[#1B7B9E]/20 text-[#2B2B2B]"})]})]}),(0,D.jsxs)("div",{className:"flex gap-3 pt-4",children:[(0,D.jsx)(C.$,{type:"button",variant:"outline",onClick:()=>R(!1),className:"flex-1 border-[#1B7B9E]/20 text-[#2B2B2B]",children:"Cancel"}),(0,D.jsx)(C.$,{type:"submit",disabled:V,className:"navy-cta flex-1 bg-[#22364A] hover:opacity-90 text-black",children:V?"Saving...":"Save Changes"})]})]})]})}),P&&$&&(0,D.jsx)("div",{className:"fixed inset-0 bg-[#f3f0e8]/70 flex items-center justify-center z-50",children:(0,D.jsxs)("div",{className:"bg-[#f3f0e8] border border-[#1B7B9E]/20 rounded-lg w-full max-w-2xl mx-4 max-h-[80vh] overflow-y-auto",children:[(0,D.jsxs)("div",{className:"flex items-center justify-between p-4 border-b border-[#1B7B9E]/20 sticky top-0 bg-[#f3f0e8]",children:[(0,D.jsx)("h2",{className:"text-[#2B2B2B] font-medium",children:"Event Details"}),(0,D.jsx)("button",{onClick:()=>G(!1),className:"text-[#5e5e5e] hover:text-[#2B2B2B]",children:(0,D.jsx)(b.A,{size:20})})]}),(0,D.jsxs)("div",{className:"p-4 space-y-6",children:[(0,D.jsxs)("div",{children:[(0,D.jsx)("h3",{className:"text-[#2B2B2B] text-xl",children:$.title}),(0,D.jsxs)("div",{className:"flex gap-2 mt-2",children:[(0,D.jsx)("span",{className:"px-2 py-1 rounded text-xs ".concat(ae($.event_type)),children:null===(e=$.event_type)||void 0===e?void 0:e.replace("_"," ")}),(0,D.jsx)("span",{className:"px-2 py-1 rounded text-xs ".concat(le($).style),children:le($).label})]}),$.description&&(0,D.jsx)("p",{className:"text-[#5e5e5e] mt-4",children:$.description})]}),(0,D.jsxs)("div",{className:"grid grid-cols-2 gap-4",children:[(0,D.jsxs)("div",{className:"bg-[#405353] p-3 rounded",children:[(0,D.jsx)("p",{className:"text-[#5e5e5e] text-xs",children:"Date & Time"}),(0,D.jsx)("p",{className:"text-[#2B2B2B]",children:re($.date)}),(0,D.jsxs)("p",{className:"text-[#5e5e5e] text-sm",children:[$.start_time," - ",$.end_time]})]}),(0,D.jsxs)("div",{className:"bg-[#405353] p-3 rounded",children:[(0,D.jsx)("p",{className:"text-[#5e5e5e] text-xs",children:"Location"}),(0,D.jsx)("p",{className:"text-[#2B2B2B]",children:"virtual"===$.location_type?"Virtual":$.location_type}),$.location_details&&(0,D.jsx)("p",{className:"text-[#5e5e5e] text-sm",children:$.location_details})]}),(0,D.jsxs)("div",{className:"bg-[#405353] p-3 rounded",children:[(0,D.jsx)("p",{className:"text-[#5e5e5e] text-xs",children:"Price"}),(0,D.jsxs)("p",{className:"text-[#2B2B2B]",children:["$",$.price||0]}),$.member_price&&(0,D.jsxs)("p",{className:"text-[#A58958] text-sm",children:["$",$.member_price," for members"]})]}),(0,D.jsxs)("div",{className:"bg-[#405353] p-3 rounded",children:[(0,D.jsx)("p",{className:"text-[#5e5e5e] text-xs",children:"Registrations"}),(0,D.jsx)("p",{className:"text-[#2B2B2B]",children:$.registration_count||0}),$.max_attendees&&(0,D.jsxs)("p",{className:"text-[#5e5e5e] text-sm",children:["Max: ",$.max_attendees]})]})]}),(null===(t=$.registrations)||void 0===t?void 0:t.length)>0&&(0,D.jsxs)("div",{children:[(0,D.jsx)("h4",{className:"text-[#2B2B2B] text-sm mb-2",children:"Registered Attendees"}),(0,D.jsx)("div",{className:"bg-[#405353] rounded overflow-hidden max-h-48 overflow-y-auto",children:$.registrations.map((e,t)=>(0,D.jsxs)("div",{className:"flex items-center justify-between p-3 border-b border-white/5 last:border-0",children:[(0,D.jsxs)("div",{children:[(0,D.jsx)("p",{className:"text-[#2B2B2B] text-sm",children:e.user_name||e.user_email}),(0,D.jsx)("p",{className:"text-[#5e5e5e] text-xs",children:e.user_email})]}),(0,D.jsx)("p",{className:"text-[#5e5e5e] text-xs",children:new Date(e.registered_at).toLocaleDateString()})]},t))})]})]})]})})]})};
1var Se=s(53270),De=s(15924),ze=s(11464);const Te="https://peerlessetiquette.com",Me=()=>({Authorization:"Bearer ".concat(localStorage.getItem("peerless_token")||localStorage.getItem("adminToken"))}),Ie=e=>{let{icon:t,label:s,value:a,accent:l}=e;return(0,D.jsxs)("div",{className:"bg-white rounded-xl p-3.5 sm:p-4 transition-all hover:shadow-md",style:{border:"1px solid #E3DCDE"},children:[(0,D.jsxs)("div",{className:"flex items-center gap-1.5 mb-2",children:[(0,D.jsx)(t,{size:13,style:{color:l}}),(0,D.jsx)("span",{className:"text-[8px] sm:text-[9px] text-[#5A6F82] tracking-wider uppercase truncate",children:s})]}),(0,D.jsx)("p",{className:"text-lg sm:text-xl font-light text-[#0B2036] truncate",style:{fontFamily:"'Cormorant Garamond', serif"},children:a})]})},Le=()=>{const[e,t]=(0,a.useState)("metrics"),[s,l]=(0,a.useState)(null),[i,n]=(0,a.useState)(null),[c,d]=(0,a.useState)(null),[o,x]=(0,a.useState)(!0),[m,p]=(0,a.useState)(!1),[h,u]=(0,a.useState)(!1),v=(0,a.useCallback)(async()=>{x(!0);try{if("metrics"===e){const e=await r.A.get("".concat(Te,"/api/admin/dashboard/system/metrics"),{headers:Me()});l(e.data)}else if("logs"===e){const e=m?"?errors_only=true&limit=200":"?limit=200",t=await r.A.get("".concat(Te,"/api/admin/dashboard/system/logs").concat(e),{headers:Me()});n(t.data)}else if("database"===e){const e=await r.A.get("".concat(Te,"/api/admin/dashboard/system/health"),{headers:Me()});d(e.data)}}catch(t){console.error("Failed to fetch system data:",t)}finally{x(!1)}},[e,m]);(0,a.useEffect)(()=>{v()},[v]);const b=[{id:"metrics",label:"API Metrics",icon:te.A},{id:"logs",label:"Request Logs",icon:g.A},{id:"database",label:"Database",icon:Se.A}],N=e=>e>=500?"#E53E3E":e>=400?"#E09F3E":e>=300?"#594D44":"#2D6A4F",B=e=>e>1e3?"".concat((e/1e3).toFixed(1),"s"):"".concat(Math.round(e),"ms");return(0,D.jsxs)("div",{className:"space-y-5","data-testid":"admin-system-page",children:[(0,D.jsxs)("div",{className:"flex flex-col sm:flex-row sm:items-center justify-between gap-3",children:[(0,D.jsxs)("div",{children:[(0,D.jsx)("h1",{className:"text-xl sm:text-2xl text-[#0B2036] tracking-wide",style:{fontFamily:"'Cormorant Garamond', serif",fontVariant:"small-caps"},children:"System Monitor"}),(0,D.jsx)("p",{className:"text-[10px] text-[#5A6F82] mt-0.5",children:"API performance, logs & database health"})]}),(0,D.jsx)("button",{onClick:v,className:"self-start sm:self-auto p-2 rounded-lg hover:bg-[#0B2036]/5 text-[#5A6F82]","data-testid":"refresh-system",children:(0,D.jsx)(I.A,{size:16,className:o?"animate-spin":""})})]}),(0,D.jsx)("div",{className:"flex gap-1 bg-white rounded-lg p-1",style:{border:"1px solid #E3DCDE"},children:b.map(s=>(0,D.jsxs)("button",{onClick:()=>t(s.id),className:"flex items-center gap-1.5 px-3 sm:px-4 py-2 rounded-md text-[10px] sm:text-[11px] tracking-wider uppercase transition-all flex-1 justify-center ".concat(e===s.id?"text-white":"text-[#5A6F82] hover:bg-[#FDFBF7]"),style:{background:e===s.id?"#0B2036":"transparent",fontFamily:"'Manrope', sans-serif"},"data-testid":"tab-".concat(s.id),children:[(0,D.jsx)(s.icon,{size:13}),(0,D.jsx)("span",{className:"hidden sm:inline",children:s.label})]},s.id))}),o?(0,D.jsx)("div",{className:"flex items-center justify-center py-16",children:(0,D.jsx)("div",{className:"w-10 h-10 border-2 border-[#1B7B9E]/20 border-t-[#1B7B9E] rounded-full animate-spin"})}):(0,D.jsxs)(D.Fragment,{children:["metrics"===e&&s&&(0,D.jsxs)("div",{className:"space-y-5",children:[(0,D.jsxs)("div",{className:"grid grid-cols-2 lg:grid-cols-4 gap-3",children:[(0,D.jsx)(Ie,{icon:f.A,label:"Requests (24h)",value:s.requests.last_24h,accent:"#594D44"}),(0,D.jsx)(Ie,{icon:X.A,label:"Avg Response",value:B(s.performance.avg_response_ms),accent:"#2D6A4F"}),(0,D.jsx)(Ie,{icon:De.A,label:"Errors (24h)",value:s.requests.errors_24h,accent:"#E53E3E"}),(0,D.jsx)(Ie,{icon:j.A,label:"Error Rate",value:"".concat(s.requests.error_rate,"%"),accent:s.requests.error_rate>5?"#E53E3E":"#2D6A4F"})]}),(0,D.jsxs)("div",{className:"grid grid-cols-1 sm:grid-cols-3 gap-3",children:[(0,D.jsxs)("div",{className:"bg-white rounded-lg p-4",style:{border:"1px solid #E3DCDE"},children:[(0,D.jsx)("p",{className:"text-[9px] text-[#5A6F82] tracking-wider up
1percase mb-1",children:"Min Response"}),(0,D.jsx)("p",{className:"text-lg text-[#0B2036]",style:{fontFamily:"'Cormorant Garamond', serif"},children:B(s.performance.min_response_ms)})]}),(0,D.jsxs)("div",{className:"bg-white rounded-lg p-4",style:{border:"1px solid #E3DCDE"},children:[(0,D.jsx)("p",{className:"text-[9px] text-[#5A6F82] tracking-wider uppercase mb-1",children:"Last Hour"}),(0,D.jsxs)("p",{className:"text-lg text-[#0B2036]",style:{fontFamily:"'Cormorant Garamond', serif"},children:[s.requests.last_hour," requests"]})]}),(0,D.jsxs)("div",{className:"bg-white rounded-lg p-4",style:{border:"1px solid #E3DCDE"},children:[(0,D.jsx)("p",{className:"text-[9px] text-[#5A6F82] tracking-wider uppercase mb-1",children:"Max Response"}),(0,D.jsx)("p",{className:"text-lg text-[#E09F3E]",style:{fontFamily:"'Cormorant Garamond', serif"},children:B(s.performance.max_response_ms)})]})]}),(0,D.jsxs)("div",{className:"bg-white rounded-xl p-4 sm:p-6",style:{border:"1px solid #E3DCDE"},"data-testid":"top-endpoints",children:[(0,D.jsx)("h3",{className:"text-xs text-[#0B2036] tracking-wider uppercase mb-3",style:{fontFamily:"'Manrope', sans-serif"},children:"Top Endpoints (24h)"}),(0,D.jsxs)("div",{className:"space-y-1.5",children:[s.top_endpoints.map((e,t)=>(0,D.jsxs)("div",{className:"flex items-center gap-3 py-1.5 border-b border-[#F5F0E8] last:border-0",children:[(0,D.jsxs)("span",{className:"text-[9px] text-[#A58958] font-medium w-4",children:["#",t+1]}),(0,D.jsx)("span",{className:"text-[10px] text-[#0B2036] flex-1 truncate font-mono",children:e.path}),(0,D.jsxs)("span",{className:"text-[9px] text-[#5A6F82] flex-shrink-0",children:[e.count," calls"]}),(0,D.jsx)("span",{className:"text-[9px] text-[#2B2B2B] flex-shrink-0 w-14 text-right",children:B(e.avg_ms)}),e.errors>0&&(0,D.jsxs)("span",{className:"text-[8px] px-1.5 py-0.5 rounded-full bg-red-50 text-red-500 flex-shrink-0",children:[e.errors," err"]})]},t)),0===s.top_endpoints.length&&(0,D.jsx)("p",{className:"text-xs text-[#5A6F82] italic text-center py-4",children:"No request data yet. Metrics will populate as the API is used."})]})]}),s.status_distribution.length>0&&(0,D.jsxs)("div",{className:"bg-white rounded-xl p-4 sm:p-6",style:{border:"1px solid #E3DCDE"},children:[(0,D.jsx)("h3",{className:"text-xs text-[#0B2036] tracking-wider uppercase mb-3",style:{fontFamily:"'Manrope', sans-serif"},children:"Response Codes (24h)"}),(0,D.jsx)("div",{className:"flex flex-wrap gap-3",children:s.status_distribution.map((e,t)=>(0,D.jsxs)("div",{className:"flex items-center gap-2 px-3 py-2 rounded-lg",style:{background:"".concat(N(e.status),"08"),border:"1px solid ".concat(N(e.status),"20")},children:[(0,D.jsx)("div",{className:"w-2 h-2 rounded-full",style:{background:N(e.status)}}),(0,D.jsx)("span",{className:"text-[10px] font-mono font-medium",style:{color:N(e.status)},children:e.status}),(0,D.jsx)("span",{className:"text-[9px] text-[#5A6F82]",children:e.count})]},t))})]})]}),"logs"===e&&i&&(0,D.jsxs)("div",{className:"space-y-4",children:[(0,D.jsxs)("div",{className:"flex items-center justify-between",children:[(0,D.jsxs)("p",{className:"text-[10px] text-[#5A6F82]",children:["Showing ",i.showing," of ",i.total," logs (",i.errors," errors)"]}),(0,D.jsxs)("label",{className:"flex items-center gap-2 cursor-pointer",children:[(0,D.jsx)("input",{type:"checkbox",checked:m,onChange:e=>p(e.target.checked),className:"w-3.5 h-3.5 rounded border-[#E3DCDE] text-[#A58958] focus:ring-[#1B7B9E]"}),(0,D.jsx)("span",{className:"text-[10px] text-[#5A6F82]",children:"Errors only"})]})]}),(0,D.jsxs)("div",{className:"bg-white rounded-xl overflow-hidden",style:{border:"1px solid #E3DCDE"},"data-testid":"request-logs",children:[(0,D.jsx)("div",{className:"overflow-x-auto max-h-[60vh] overflow-y-auto",children:(0,D.jsxs)("table",{className:"w-full min-w-[600px]",children:[(0,D.jsx)("thead",{className:"sticky top-0 bg-[#FDFBF7] z-10",children:(0,D.jsxs)("tr",{className:"border-b border-[#E3DCDE]",children:[(0,D.jsx)("th",{className:"text-left text-[8px] text-[#5A6F82] tracking-wider uppercase py-2 px-3",children:"Time"}),(0,D.jsx)("th",{className:"text-left text-[8px] text-[#5A6F82] tracking-wider up
1percase py-2 px-3",children:"Method"}),(0,D.jsx)("th",{className:"text-left text-[8px] text-[#5A6F82] tracking-wider uppercase py-2 px-3",children:"Path"}),(0,D.jsx)("th",{className:"text-center text-[8px] text-[#5A6F82] tracking-wider uppercase py-2 px-3",children:"Status"}),(0,D.jsx)("th",{className:"text-right text-[8px] text-[#5A6F82] tracking-wider uppercase py-2 px-3",children:"Duration"})]})}),(0,D.jsx)("tbody",{children:i.logs.map((e,t)=>(0,D.jsxs)("tr",{className:"border-b border-[#F5F0E8] last:border-0 ".concat(e.is_error?"bg-red-50/30":"hover:bg-[#FDFBF7]/50"),children:[(0,D.jsx)("td",{className:"py-1.5 px-3 text-[9px] text-[#5A6F82] font-mono whitespace-nowrap",children:e.timestamp?new Date(e.timestamp).toLocaleTimeString():"\u2014"}),(0,D.jsx)("td",{className:"py-1.5 px-3",children:(0,D.jsx)("span",{className:"text-[8px] px-1.5 py-0.5 rounded font-mono tracking-wider",style:{background:"GET"===e.method?"#594D4410":"POST"===e.method?"#2D6A4F10":"#E09F3E10",color:"GET"===e.method?"#2B2B2B":"POST"===e.method?"#2D6A4F":"#E09F3E"},children:e.method})}),(0,D.jsx)("td",{className:"py-1.5 px-3 text-[9px] text-[#0B2036] font-mono truncate max-w-[250px]",children:e.path}),(0,D.jsx)("td",{className:"py-1.5 px-3 text-center",children:(0,D.jsx)("span",{className:"text-[9px] font-mono font-medium",style:{color:N(e.status)},children:e.status})}),(0,D.jsx)("td",{className:"py-1.5 px-3 text-[9px] text-right text-[#5A6F82] font-mono",children:B(e.duration_ms)})]},t))})]})}),0===i.logs.length&&(0,D.jsxs)("div",{className:"text-center py-12",children:[(0,D.jsx)(g.A,{size:24,className:"mx-auto text-[#E3DCDE] mb-2"}),(0,D.jsx)("p",{className:"text-xs text-[#5A6F82]",children:m?"No errors found":"No request logs yet"})]})]})]}),"database"===e&&c&&(0,D.jsxs)("div",{className:"space-y-5",children:[(0,D.jsxs)("div",{className:"grid grid-cols-2 lg:grid-cols-4 gap-3",children:[(0,D.jsx)(Ie,{icon:Se.A,label:"Status",value:"connected"===c.status?"Healthy":"Error",accent:"connected"===c.status?"#2D6A4F":"#E53E3E"}),(0,D.jsx)(Ie,{icon:ze.A,label:"Database",value:c.database,accent:"#594D44"}),(0,D.jsx)(Ie,{icon:g.A,label:"Collections",value:c.total_collections,accent:"#A58958"}),(0,D.jsx)(Ie,{icon:te.A,label:"Documents",value:c.total_documents.toLocaleString(),accent:"#7B2D8E"})]}),(0,D.jsxs)("div",{className:"bg-white rounded-xl p-4 sm:p-6",style:{border:"1px solid #E3DCDE"},"data-testid":"db-collections",children:[(0,D.jsxs)("div",{className:"flex items-center justify-between mb-4",children:[(0,D.jsxs)("h3",{className:"text-xs text-[#0B2036] tracking-wider uppercase",style:{fontFamily:"'Manrope', sans-serif"},children:["Collections (",c.total_collections,")"]}),(0,D.jsxs)("button",{onClick:()=>u(!h),className:"flex items-center gap-1 text-[9px] text-[#A58958] hover:underline",children:[h?"Show top 20":"Show all",h?(0,D.jsx)(ce.A,{size:10}):(0,D.jsx)(y.A,{size:10})]})]}),(0,D.jsx)("div",{className:"space-y-1",children:(h?c.collections:c.collections.slice(0,20)).map((e,t)=>{var s;const a=(null===(s=c.collections[0])||void 0===s?void 0:s.documents)||1,l=Math.max(e.documents/a*100,1);return(0,D.jsxs)("div",{className:"flex items-center gap-3 py-1",children:[(0,D.jsx)("span",{className:"text-[9px] text-[#0B2036] font-mono w-48 sm:w-56 truncate flex-shrink-0",children:e.name}),(0,D.jsx)("div",{className:"flex-1 h-3 bg-[#F5F0E8] rounded-full overflow-hidden",children:(0,D.jsx)("div",{className:"h-full rounded-full transition-all duration-500",style:{width:"".concat(l,"%"),background:e.documents>100?"#A58958":e.documents>0?"#2B2B2B":"#E3DCDE"}})}),(0,D.jsx)("span",{className:"text-[9px] text-[#5A6F82] font-mono w-12 text-right flex-shrink-0",children:e.documents.toLocaleString()})]},t)})})]})]})]})]})},Re="https://peerlessetiquette.com",Pe=e=>{let{title:t}=e;return(0,D.jsxs)("div",{className:"bg-white rounded-xl p-8 sm:p-12 text-center",style:{border:"1px solid #E3DCDE"},children:[(0,D.jsx)("h2",{className:"text-[#0B2036] text-lg tracking-wide mb-2",style:{fontFamily:"'Cormorant Garamond', serif",fontVariant:"small-caps"},children:t}),(0,D.jsx)("p",{className:"text-[#5A6F82] text-xs",children:"This section is coming soon."})]})},qe=()=>{var e;
1const t=(0,l.Zp)(),s=(0,l.zy)(),[A,w]=(0,a.useState)(null),[k,E]=(0,a.useState)(!1),[F,_]=(0,a.useState)(!0),[C,S]=(0,a.useState)(window.innerWidth<1024);(0,a.useEffect)(()=>{const e=()=>{const e=window.innerWidth<1024;S(e),e||k||E(!0),e&&k&&E(!1)};return window.innerWidth>=1024&&E(!0),window.addEventListener("resize",e),()=>window.removeEventListener("resize",e)},[]);const z=[{title:"Core",items:[{path:"/admin/dashboard",icon:i.A,label:"Dashboard",exact:!0},{path:"/admin/dashboard/users",icon:n.A,label:"Users"},{path:"/admin/dashboard/courses",icon:c.A,label:"Courses"},{path:"/admin/dashboard/events",icon:d.A,label:"Sessions"}]},{title:"Content",items:[{path:"/admin/dashboard/design",icon:o.A,label:"Design"},{path:"/admin/dashboard/media",icon:x.A,label:"Media"},{path:"/admin/music",icon:m.A,label:"Music",external:!0},{path:"/admin/audio",icon:p.A,label:"Audio",external:!0},{path:"/admin/course-images",icon:x.A,label:"Course Art",external:!0}]},{title:"Platform",items:[{path:"/admin/peerless-court",icon:h.A,label:"Court",external:!0},{path:"/admin/games",icon:u.A,label:"Games",external:!0},{path:"/admin/dashboard/system",icon:g.A,label:"System"},{path:"/admin/dashboard/team",icon:j.A,label:"Team"},{path:"/admin/dashboard/settings",icon:v.A,label:"Settings"}]}];(0,a.useEffect)(()=>{M()},[]);const M=async()=>{const e=localStorage.getItem("peerless_token"),s=localStorage.getItem("adminToken"),a=e||s;if(a)try{var l;await r.A.get("".concat(Re,"/api/admin/dashboard/stats"),{headers:{Authorization:"Bearer ".concat(a)}});const e=JSON.parse(atob(a.split(".")[1]));w({email:e.email||"",role:e.role||"admin",name:e.name||(null===(l=e.email)||void 0===l?void 0:l.split("@")[0])||"Admin"})}catch(i){try{if(!s)return void t("/auth");{const e=await r.A.get("".concat(Re,"/api/admin-auth/me"),{headers:{Authorization:"Bearer ".concat(s)}});w(e.data.admin)}}catch(n){return localStorage.removeItem("adminToken"),void t("/auth")}}finally{_(!1)}else t("/auth")},I=()=>{C&&E(!1)},L=function(e){return arguments.length>1&&void 0!==arguments[1]&&arguments[1]?s.pathname===e:s.pathname.startsWith(e)};return F?(0,D.jsx)("div",{className:"min-h-screen flex items-center justify-center",style:{background:"#FDFBF7"},children:(0,D.jsxs)("div",{className:"flex flex-col items-center gap-4",children:[(0,D.jsx)("div",{className:"w-12 h-12 border-2 border-[#1B7B9E]/20 border-t-[#1B7B9E] rounded-full animate-spin"}),(0,D.jsx)("span",{className:"text-[#5A6F82] text-xs tracking-[0.3em] uppercase",style:{fontFamily:"'Manrope', sans-serif"},children:"Loading Admin"})]})}):(0,D.jsxs)("div",{className:"min-h-screen",style:{background:"#FDFBF7"},"data-testid":"admin-dashboard",children:[C&&k&&(0,D.jsx)("div",{className:"fixed inset-0 bg-black/40 backdrop-blur-sm z-40",onClick:()=>E(!1)}),(0,D.jsxs)("aside",{className:"fixed top-0 left-0 h-screen z-50 flex flex-col transition-transform duration-300 ".concat(k?"translate-x-0":"-translate-x-full lg:translate-x-0"," ").concat(C?"w-64":"w-56"),style:{background:"#0B2036",borderRight:"1px solid rgba(165, 137, 88, 0.15)"},"data-testid":"admin-sidebar",children:[(0,D.jsxs)("div",{className:"h-14 flex items-center px-4 border-b",style:{borderColor:"rgba(165, 137, 88, 0.12)"},children:[(0,D.jsxs)("div",{className:"flex items-center gap-2.5 flex-1",children:[(0,D.jsx)("div",{className:"w-7 h-7 rounded-md flex items-center justify-center",style:{background:"rgba(165, 137, 88, 0.15)"},children:(0,D.jsx)(h.A,{size:14,style:{color:"#A58958"}})}),(0,D.jsxs)("div",{children:[(0,D.jsx)("p",{className:"text-[10px] tracking-[0.2em] uppercase",style:{color:"#A58958",fontFamily:"'Manrope', sans-serif"},children:"Peerless"}),(0,D.jsx)("p",{className:"text-[8px] tracking-[0.12em] uppercase text-white/40",children:"Admin"})]})]}),C&&(0,D.jsx)("button",{onClick:()=>E(!1),className:"p-1.5 rounded hover:bg-white/10 text-white/50","data-testid":"sidebar-close",children:(0,D.jsx)(b.A,{size:18})})]}),(0,D.jsx)("nav",{className:"flex-1 py-3 overflow-y-auto",children:z.map((e,t)=>(0,D.jsxs)("div",{className:"mb-3",children:[(0,D.jsx)("p",{className:"px-4 mb-1.5 text-[8px] tracking-[0.25em] uppercase text-white/25",style:{fontFamily:"'Manrope', sans-serif"},children:e.title}),e.items.map(e=>{const t=L(e.path,e.exact);return(0,D.jsxs)(l.N_,{to:e.path,onClick:I,className:"flex items-center gap-2.5 mx-2 mb-0.5 rounded-lg px-3 py-2 transition-all duration-200",style:{background:t?"rgba(165, 137, 88, 0.12)":"transparent",color:t?"#A58958":"rgba(255,255,255,0.45)"},"data-testid":"nav-".concat(e.label.toLowerCase().replace(/\s/g,"-")),children:[(0,D.jsx)(e.icon,{size:16}),(0,D.jsx)("span",{className:"text-[11px] tracking-wide",style:{fontFamily:"'Manrope', sans-serif"},children:e.label}),t&&(0,D.jsx)("div",{className:"navy-cta ml-auto w-1.5 h-1.5 rounded-full",style:{background:"#22364A",borderRadius:"9999px"}})]},e.path)})]},t))}),(0,D.jsxs)("div",{className:"p-3 border-t",style:{borderColor:"rgba(165, 137, 88, 0.12)"},children:[A&&(0,D.jsxs)("div",{className:"mb-2 px-1",children:[(0,D.jsx)("p",{className:"text-white/80 text-[10px] font-medium truncate",children:A.name||A.email}),(0,D.jsx)("p",{className:"text-white/30 text-[8px] tracking-wider up
1percase",children:A.role})]}),(0,D.jsxs)("div",{className:"flex items-center gap-2",children:[(0,D.jsxs)(l.N_,{to:"/",onClick:I,className:"flex items-center gap-1.5 text-white/30 hover:text-[#A58958] transition-colors flex-1 text-[10px]","data-testid":"view-site-link",children:[(0,D.jsx)(f.A,{size:14}),(0,D.jsx)("span",{children:"View Site"})]}),(0,D.jsxs)("button",{onClick:()=>{localStorage.removeItem("peerless_token"),localStorage.removeItem("peerless_user"),localStorage.removeItem("peerless_login_time"),localStorage.removeItem("adminToken"),localStorage.removeItem("adminUser"),t("/")},className:"flex items-center gap-1.5 text-white/30 hover:text-red-400 transition-colors text-[10px]","data-testid":"admin-logout-btn",children:[(0,D.jsx)(N.A,{size:14}),(0,D.jsx)("span",{children:"Out"})]})]})]})]}),(0,D.jsxs)("main",{className:"min-h-screen transition-all duration-300 ".concat(C?"ml-0":"ml-56"),children:[(0,D.jsxs)("header",{className:"sticky top-0 z-30 h-12 flex items-center justify-between px-4 lg:px-8",style:{background:"rgba(253, 251, 247, 0.92)",backdropFilter:"blur(12px)",borderBottom:"1px solid #E3DCDE"},children:[(0,D.jsxs)("div",{className:"flex items-center gap-3",children:[C&&(0,D.jsx)("button",{onClick:()=>E(!0),className:"p-1.5 -ml-1 rounded-lg hover:bg-[#0B2036]/5 text-[#0B2036]","data-testid":"sidebar-toggle",children:(0,D.jsx)(B.A,{size:20})}),(0,D.jsxs)("div",{className:"flex items-center gap-1.5 text-[10px] lg:text-[11px]",style:{fontFamily:"'Manrope', sans-serif"},children:[(0,D.jsx)("span",{className:"text-[#5A6F82] hidden sm:inline",children:"Admin"}),(0,D.jsx)(y.A,{size:10,className:"text-[#E3DCDE] hidden sm:inline"}),(0,D.jsx)("span",{className:"text-[#0B2036] font-medium",children:(null===(e=z.flatMap(e=>e.items).find(e=>L(e.path,e.exact)))||void 0===e?void 0:e.label)||"Dashboard"})]})]}),(0,D.jsxs)("div",{className:"flex items-center gap-2.5",children:[(0,D.jsx)("div",{className:"w-1.5 h-1.5 rounded-full bg-[#2D6A4F] animate-pulse",title:"System healthy"}),(0,D.jsx)("span",{className:"text-[9px] lg:text-[10px] text-[#5A6F82]",children:(new Date).toLocaleDateString("en-US",{month:"short",day:"numeric"})})]})]}),(0,D.jsx)("div",{className:"p-4 sm:p-6 lg:p-8",children:(0,D.jsxs)(l.BV,{children:[(0,D.jsx)(l.qh,{path:"/",element:(0,D.jsx)(ae,{})}),(0,D.jsx)(l.qh,{path:"/design",element:(0,D.jsx)(T,{})}),(0,D.jsx)(l.qh,{path:"/media",element:(0,D.jsx)(O,{})}),(0,D.jsx)(l.qh,{path:"/course-images",element:(0,D.jsx)(le.default,{})}),(0,D.jsx)(l.qh,{path:"/team",element:(0,D.jsx)(Q,{})}),(0,D.jsx)(l.qh,{path:"/users",element:(0,D.jsx)(be,{})}),(0,D.jsx)(l.qh,{path:"/courses",element:(0,D.jsx)(xe,{})}),(0,D.jsx)(l.qh,{path:"/events",element:(0,D.jsx)(Ce,{})}),(0,D.jsx)(l.qh,{path:"/system",element:(0,D.jsx)(Le,{})}),(0,D.jsx)(l.qh,{path:"/settings",element:(0,D.jsx)(Pe,{title:"Settings"})})]})})]})]})}},61910(e,t,s){s.r(t),s.d(t,{default:()=>b});var a=s(89379),l=s(9950),r=s(92994),i=s(26910),n=s(42989),c=s(80903),d=s(86311),o=s(23198),x=s(13147),m=s(77834),p=s(96479),h=s(41111),u=s(94779),g=s(32033),j=s(44414);const v="https://peerlessetiquette.com",b=()=>{const e=(0,r.Zp)(),[t,s]=(0,l.useState)([]),[b,f]=(0,l.useState)(!0),[N,B]=(0,l.useState)(!1),[y,A]=(0,l.useState)(!1),[w,k]=(0,l.useState)(null),[E,F]=(0,l.useState)(null),[_,C]=(0,l.useState)(""),S=(0,l.useRef)(null),[D,z]=(0,l.useState)({file:null});(0,l.useEffect)(()=>{T(),I()},[]);const T=()=>{localStorage.getItem("adminToken")||e("/admin/login")},M=()=>{const e=localStorage.getItem("adminToken");return{Authorization:"Bearer ".concat(e)}},I=async()=>{try{const e=await i.A.get("".concat(v,"/api/courses/public"));s(e.data||[])}catch(e){console.error("Error fetching courses:",e),g.oR.error("Failed to load courses")}finally{f(!1)}},L=()=>{z({file:null}),k(null),F(null),S.current&&(S.current.value="")},R=e=>e.hero_image||e.cover_image||e.image||null,P=t.filter(e=>{var t,s;return(null===(t=e.title)||void 0===t?void 0:t.toLowerCase().includes(_.toLowerCase()))||(null===(s=e.domain_name)||void 0===s?void 0:s.toLowerCase().includes(_.toLowerCase()))});return(0,j.jsxs)("div",{className:"min-h-screen bg-[#f3f0e8] text-[#2B2B2B]",children:[(0,j.jsx)("div",{className:"bg-[#111] border-b border-[#1B7B9E]/20 px-6 py-4",children:(0,j.jsx)("div",{className:"max-w-7xl mx-auto flex items-center justify-between",children:(0,j.jsxs)("div",{className:"flex items-center gap-4",children:[(0,j.jsx)("button",{onClick:()=>
1e("/admin/dashboard"),className:"text-[#5e5e5e] hover:text-[#2B2B2B]",children:"\u2190 Back to Dashboard"}),(0,j.jsx)("img",{loading:"lazy",src:"/assets/crest.png",alt:"",className:"w-16 h-16 mx-auto mb-5 opacity-90"}),(0,j.jsxs)("h1",{className:"text-xl font-medium flex items-center gap-2",children:[(0,j.jsx)(o.A,{className:"w-5 h-5 text-[#A58958]"}),"Course Images"]})]})})}),(0,j.jsxs)("div",{className:"max-w-7xl mx-auto px-6 py-8",children:[(0,j.jsxs)("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4 mb-8",children:[(0,j.jsxs)("div",{className:"bg-white/5 rounded-xl p-6 border border-[#1B7B9E]/20",children:[(0,j.jsx)("p",{className:"text-[#5e5e5e] text-sm mb-1",children:"Total Courses"}),(0,j.jsx)("p",{className:"text-3xl font-light text-[#A58958]",children:t.length})]}),(0,j.jsxs)("div",{className:"bg-white/5 rounded-xl p-6 border border-[#1B7B9E]/20",children:[(0,j.jsx)("p",{className:"text-[#5e5e5e] text-sm mb-1",children:"With Images"}),(0,j.jsx)("p",{className:"text-3xl font-light text-green-400",children:t.filter(e=>R(e)).length})]}),(0,j.jsxs)("div",{className:"bg-white/5 rounded-xl p-6 border border-[#1B7B9E]/20",children:[(0,j.jsx)("p",{className:"text-[#5e5e5e] text-sm mb-1",children:"Need Images"}),(0,j.jsx)("p",{className:"text-3xl font-light text-orange-400",children:t.filter(e=>!R(e)).length})]}),(0,j.jsxs)("div",{className:"bg-white/5 rounded-xl p-6 border border-[#1B7B9E]/20",children:[(0,j.jsx)("p",{className:"text-[#5e5e5e] text-sm mb-1",children:"Categories"}),(0,j.jsx)("p",{className:"text-3xl font-light text-[#A58958]",children:[...new Set(t.map(e=>e.domain_name||e.domain))].length})]})]}),(0,j.jsxs)("div",{className:"relative mb-6",children:[(0,j.jsx)(x.A,{className:"absolute left-4 top-1/2 -translate-y-1/2 w-4 h-4 text-[#5e5e5e]"}),(0,j.jsx)(u.p,{type:"text",placeholder:"Search courses...",value:_,onChange:e=>C(e.target.value),className:"pl-12 bg-white/5 border-[#1B7B9E]/20 text-[#2B2B2B] h-12"})]}),(0,j.jsxs)("div",{className:"bg-white/5 rounded-xl border border-[#1B7B9E]/20 overflow-hidden",children:[(0,j.jsxs)("div",{className:"p-4 border-b border-[#1B7B9E]/20",children:[(0,j.jsxs)("h2",{className:"text-lg font-medium",children:["All Courses (",P.length,")"]}),(0,j.jsx)("p",{className:"text-[#5e5e5e] text-sm mt-1",children:'Click "Upload Image" to change any course image'})]}),b?(0,j.jsx)("div",{className:"flex justify-center py-12",children:(0,j.jsx)(n.A,{className:"w-8 h-8 animate-spin text-[#A58958]"})}):0===P.length?(0,j.jsxs)("div",{className:"text-center py-12",children:[(0,j.jsx)(c.A,{className:"w-16 h-16 mx-auto mb-4 text-[#2B2B2B]/20"}),(0,j.jsx)("p",{className:"text-[#5e5e5e]",children:"No courses found"})]}):(0,j.jsx)("div",{className:"divide-y divide-white/5",children:P.map(e=>(0,j.jsx)("div",{className:"p-4 hover:bg-white/5 transition-colors",children:(0,j.jsxs)("div",{className:"flex items-center gap-4",children:[(0,j.jsx)("div",{className:"w-20 h-14 bg-[#f3f0e8]/50 rounded-lg overflow-hidden flex-shrink-0",children:R(e)?(0,j.jsx)("img",{loading:"lazy",src:R(e),alt:e.title,className:"w-full h-full object-cover",onError:e=>{e.target.style.display="none"}}):(0,j.jsx)("div",{className:"w-full h-full flex items-center justify-center",children:(0,j.jsx)(o.A,{className:"w-6 h-6 text-[#2B2B2B]/20"})})}),(0,j.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,j.jsx)("h3",{className:"font-medium truncate",children:e.title}),(0,j.jsx)("p",{className:"text-sm text-[#5e5e5e] truncate",children:e.domain_name||e.domain})]}),(0,j.jsx)("div",{className:"flex items-center gap-2",children:(0,j.jsxs)(h.$,{onClick:()=>(e=>{k(e),A(!0),F(null),z({file:null})})(e),className:"navy-cta bg-[#22364A] hover:opacity-90 rounded-full text-black",children:[(0,j.jsx)(m.A,{className:"w-4 h-4 mr-2"}),"Upload Image"]})})]})},e.id))})]})]}),y&&(0,j.jsx)("div",{className:"fixed inset-0 bg-[#f3f0e8]/80 flex items-center justify-center z-50 p-6",children:(0,j.jsxs)("div",{className:"bg-[#111] rounded-2xl max-w-lg w-full max-h-[90vh] overflow-y-auto border border-[#1B7B9E]/20",children:[(0,j.jsxs)("div",{className:"p-6 border-b border-[#1B7B9E]/20",children:[(0,j.jsxs)("div",{className:"flex items-center justify-between",children:[(0,j.jsxs)("h2",{className:"text-xl font-medium flex items-center gap-2",children:[(0,j.jsx)(m.A,{className:"w-5 h-5 text-[#A58958]"}),"Upload Course Image"]}),(0,j.jsx)("button",{onClick:()=>{A(!1),L()},className:"text-[#5e5e5e] hover:text-[#2B2B2B]",children:(0,j.jsx)(p.A,{className:"w-6 h-6"})})]}),w&&(0,j.jsx)("p",{className:"text-[#5e5e5e] text-sm mt-2",children:w.title})]}),(0,j.jsxs)("form",{onSubmit:async e=>{if(e.preventDefault(),D.file)if(w){B(!0);try{const e=new FormData;
1e.append("file",D.file),e.append("course_id",w.id),e.append("image_type","hero");const t=await i.A.post("".concat(v,"/api/admin/upload-course-image"),e,{headers:(0,a.A)((0,a.A)({},M()),{},{"Content-Type":"multipart/form-data"})});t.data.success&&(g.oR.success("Course image uploaded successfully!"),A(!1),L(),s(e=>e.map(e=>e.id===w.id?(0,a.A)((0,a.A)({},e),{},{hero_image:t.data.url,cover_image:t.data.url}):e)))}catch(r){var t,l;console.error("Upload error:",r),g.oR.error((null===(t=r.response)||void 0===t||null===(l=t.data)||void 0===l?void 0:l.detail)||"Upload failed")}finally{B(!1)}}else g.oR.error("Please select a course");else g.oR.error("Please select an image file")},className:"p-6 space-y-6",children:[w&&R(w)&&!E&&(0,j.jsxs)("div",{children:[(0,j.jsx)("label",{className:"block text-sm text-[#5e5e5e] mb-2",children:"Current Image"}),(0,j.jsx)("div",{className:"aspect-video bg-[#f3f0e8]/50 rounded-lg overflow-hidden",children:(0,j.jsx)("img",{loading:"lazy",src:R(w),alt:"Current",className:"w-full h-full object-cover"})})]}),(0,j.jsxs)("div",{children:[(0,j.jsx)("label",{className:"block text-sm text-[#5e5e5e] mb-2",children:"Select Image File *"}),(0,j.jsxs)("div",{className:"border-2 border-dashed rounded-xl p-8 text-center cursor-pointer transition-all ".concat(D.file?"border-[#1B7B9E] bg-[#A58958]/10":"border-[#1B7B9E]/25 hover:border-white/40"),onClick:()=>{var e;return null===(e=S.current)||void 0===e?void 0:e.click()},children:[(0,j.jsx)("input",{ref:S,type:"file",accept:".png,.jpg,.jpeg,.webp,.gif",onChange:e=>{const t=e.target.files[0];if(t){if(!["image/jpeg","image/png","image/webp","image/gif"].includes(t.type))return void g.oR.error("Please select a PNG, JPG, WebP, or GIF file");if(t.size>10485760)return void g.oR.error("File too large. Maximum 10MB");z((0,a.A)((0,a.A)({},D),{},{file:t})),F(URL.createObjectURL(t))}},className:"hidden"}),D.file?(0,j.jsxs)("div",{className:"flex items-center justify-center gap-2",children:[(0,j.jsx)(d.A,{className:"w-5 h-5 text-[#A58958]"}),(0,j.jsx)("span",{className:"text-[#A58958]",children:D.file.name})]}):(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(m.A,{className:"w-8 h-8 mx-auto mb-2 text-[#5e5e5e]"}),(0,j.jsx)("p",{className:"text-[#5e5e5e]",children:"Click to select PNG, JPG, or WebP file"}),(0,j.jsx)("p",{className:"text-[#2B2B2B]/30 text-xs mt-2",children:"Maximum file size: 10MB"})]})]})]}),E&&(0,j.jsxs)("div",{children:[(0,j.jsx)("label",{className:"block text-sm text-[#A58958] mb-2",children:"New Image Preview"}),(0,j.jsx)("div",{className:"aspect-video bg-[#f3f0e8]/50 rounded-lg overflow-hidden border-2 border-[#1B7B9E]",children:(0,j.jsx)("img",{loading:"lazy",src:E,alt:"Preview",className:"w-full h-full object-cover"})})]}),(0,j.jsxs)("div",{className:"flex gap-3 pt-4",children:[(0,j.jsx)(h.$,{type:"button",onClick:()=>{A(!1),L()},className:"flex-1 bg-white/10 hover:bg-white/20 text-[#2B2B2B]",children:"Cancel"}),(0,j.jsx)(h.$,{type:"submit",disabled:N||!D.file,className:"navy-cta flex-1 bg-[#22364A] hover:opacity-90 rounded-full text-black",children:N?(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(n.A,{className:"w-4 h-4 mr-2 animate-spin"}),"Uploading..."]}):(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(m.A,{className:"w-4 h-4 mr-2"}),"Upload Image"]})})]})]})]})})]})}},94779(e,t,s){s.d(t,{p:()=>d});var a=s(89379),l=s(53986),r=s(9950),i=s(9332),n=s(44414);const c=["className","type"],d=r.forwardRef((e,t)=>{let{className:s,type:r}=e,d=(0,l.A)(e,c);return(0,n.jsx)("input",(0,a.A)({type:r,className:(0,i.cn)("flex h-9 w-full rounded-md border border-input bg-transparent px-3 py-1 text-base shadow-sm transition-colors file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50 md:text-sm",s),ref:t},d))});d.displayName="Input"}}]);
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.