1import{ah as D,r,j as e,ad as H}from"./vendor-BFIOfVip.js";import{l as f}from"./index-CKRbob3g.js";import{aj as M,eQ as R,d6 as j,eR as v,d5 as N,Y as I,bL as P,ax as $}from"./vendor-icons-BjlO8Ivt.js";import{A as w,m as A}from"./vendor-motion-C4-LgF0B.js";import"./vendor-firebase-dJP658Hw.js";const G=()=>{const{eventId:d}=D(),{setActiveEventId:l,activeEvent:o,questions:n,loading:k,updateQuestionStatus:c}=f(),[C,x]=r.useState(!1),[m,h]=r.useState(""),[s,i]=r.useState("pending"),{submitQuestion:F,deleteQuestion:Q}=f();r.useEffect(()=>(d&&l(d),()=>l(null)),[d,l]);const u=r.useMemo(()=>[...n].sort((a,T)=>{var b,y;return(((b=T.createdAt)==null?void 0:b.seconds)||0)-(((y=a.createdAt)==null?void 0:y.seconds)||0)}).filter(a=>a.status===s),[n,s]),g=async t=>{await c(t,"approved")},p=async t=>{await c(t,"hidden")},E=async t=>{await c(t,"answered")},L=async t=>{window.confirm("Are you sure you want to permanently delete this question? This action cannot be undone.")&&await Q(t)},S=async t=>{if(t.preventDefault(),!!m.trim())try{await F(m,"Host",!1,[],"approved"),h(""),x(!1)}catch(a){console.error(a),alert("Failed to add question")}};return k&&!o?e.jsx("div",{className:"p-8 text-center text-gray-500",children:"Loading event data..."}):o?e.jsxs("div",{className:"flex flex-col h-screen bg-gray-50",children:[e.jsxs("div",{className:"bg-white border-b border-gray-200 px-6 py-4 flex justify-between items-center shadow-sm z-10",children:[e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx(H,{to:"/admin/qa",className:"text-gray-400 hover:text-gray-900 transition",children:e.jsx(M,{})}),e.jsxs("div",{children:[e.jsx("h1",{className:"text-xl font-bold text-gray-900",children:o.title}),e.jsx("p",{className:"text-xs text-green-600 font-bold uppercase tracking-wide",children:"Live Moderation"})]})]}),e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx("button",{onClick:()=>x(!0),className:"bg-cyan-600 hover:bg-cyan-700 text-white px-4 py-2 rounded-lg font-bold transition flex items-center gap-2",children:"+ Add Question"}),e.jsxs("div",{className:"flex text-sm font-medium bg-gray-100 rounded-lg p-1",children:[e.jsxs("button",{onClick:()=>i("pending"),className:`px-4 py-2 rounded-md transition-all flex items-center gap-2 ${s==="pending"?"bg-white text-cyan-700 shadow-sm":"text-gray-500 hover:text-gray-900"}`,children:[e.jsx(R,{})," Pending ",e.jsx("span",{className:"bg-gray-200 text-gray-600 px-1.5 rounded-full text-xs ml-1",children:n.filter(t=>t.status==="pending").length})]}),e.jsxs("button",{onClick:()=>i("approved"),className:`px-4 py-2 rounded-md transition-all flex items-center gap-2 ${s==="approved"?"bg-white text-green-700 shadow-sm":"text-gray-500 hover:text-gray-900"}`,children:[e.jsx(j,{})," Live ",e.jsx("span",{className:"bg-gray-200 text-gray-600 px-1.5 rounded-full text-xs ml-1",children:n.filter(t=>t.status==="approved").length})]}),e.jsxs("button",{onClick:()=>i("answered"),className:`px-4 py-2 rounded-md transition-all flex items-center gap-2 ${s==="answered"?"bg-white text-blue-700 shadow-sm":"text-gray-500 hover:text-gray-900"}`,children:[e.jsx(v,{})," Done ",e.jsx("span",{className:"bg-gray-200 text-gray-600 px-1.5 rounded-full text-xs ml-1",children:n.filter(t=>t.status==="answered").length})]}),e.jsxs("button",{onClick:()=>i("hidden"),className:`px-4 py-2 rounded-md transition-all flex items-center gap-2 ${s==="hidden"?"bg-white text-red-700 shadow-sm":"text-gray-500 hover:text-gray-900"}`,children:[e.jsx(N,{})," Hidden"]})]})]})]}),e.jsx("div",{className:"flex-1 overflow-y-auto p-6",children:e.jsx("div",{className:"max-w-4xl mx-auto space-y-4",children:u.length===0?e.jsxs("div",{className:"text-center py-20 text-gray-400",children:[e.jsx("div",{className:"text-4xl mb-4 opacity-30",children:"â¨"}),e.jsx("p",{children:"No questions in this list."})]}):e.jsx(w,{children:u.map(t=>{var a;return e.jsx(A.div,{layout:!0,initial:{opacity:0,y:20},animate:{opacity:1,y:0},exit:{opacity:0,scale:.95},className:"bg-white p-6 rounded-xl shadow-sm border border-gray-200 group hover:border-cyan-200 transition-colors",children:e.jsxs("div",{className:"flex flex-col md:flex-row md:items-start justify-between gap-4",children:[e.jsxs("div",{className:"flex-1",children:[e.jsx("p",{className:"text-lg font-medium text-gray-900 mb-2",children:t.text}),e.jsxs("div",{className:"flex items-center gap-3 text-sm text-gray-500",children:[e.jsx("span",{className:"font-semibold text-gray-700",children:t.author}),e.jsx("span",{className:"text-gray-300",children:"â¢"}),e.jsxs("span",{children:[t.votes," Votes"]}),e.jsx("span",{className:"text-gray-300",children:"â¢"}),e.jsx("span",{children:(a=t.createdAt)!=null&&a.seconds?new Date(t.createdAt.seconds*1e3).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}):"Now"})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[s==="pending"&&e.jsxs(e.Fragment,{children:[e.jsx("button",{onClick:()=>p(t.id),className:"p-3 bg-red-50 text-red-600 rounded-lg hover:bg-red-100 transition tooltip-trigger",title:"Hide / Reject",children:e.jsx(I,{})}),e.jsxs("button",{onClick:()=>g(t.id),className:"px-6 py-3 bg-green-500 text-white rounded-lg hover:bg-green-600 font-bold shadow-md transition flex items-center gap-2",children:[e.jsx(P,{})," Approve"]})]}),s==="approved"&&e.jsxs(e.Fragment,{children:[e.jsx("button",{onClick:()=>p(t.id),className:"p-3 bg-red-50 text-red-600 rounded-lg hover:bg-red-100 transition",title:"Hide",children:e.jsx(N,{})}),e.jsxs("button",{onClick:()=>
1E(t.id),className:"px-6 py-3 bg-blue-500 text-white rounded-lg hover:bg-blue-600 font-bold shadow-md transition flex items-center gap-2",children:[e.jsx(v,{})," Mark Answered"]})]}),s==="answered"&&e.jsxs("button",{onClick:()=>g(t.id),className:"px-6 py-3 bg-gray-100 text-green-600 rounded-lg hover:bg-green-50 font-bold border border-gray-200 transition flex items-center gap-2",children:[e.jsx(j,{})," Restore to Live"]}),s==="hidden"&&e.jsxs(e.Fragment,{children:[e.jsx("button",{onClick:()=>L(t.id),className:"p-3 bg-red-50 text-red-600 rounded-lg hover:bg-red-100 transition border border-red-200",title:"Delete Permanently",children:e.jsx($,{})}),e.jsx("button",{onClick:()=>g(t.id),className:"px-6 py-3 bg-gray-100 text-green-600 rounded-lg hover:bg-green-50 font-bold border border-gray-200 transition",children:"Restore"})]})]})]})},t.id)})})})}),e.jsx(w,{children:C&&e.jsx("div",{className:"fixed inset-0 bg-black/50 z-50 flex items-center justify-center p-4",children:e.jsxs(A.div,{initial:{opacity:0,scale:.95},animate:{opacity:1,scale:1},exit:{opacity:0,scale:.95},className:"bg-white rounded-xl shadow-xl w-full max-w-lg p-6",children:[e.jsx("h2",{className:"text-xl font-bold mb-4",children:"Add Host Question"}),e.jsxs("form",{onSubmit:S,children:[e.jsxs("div",{className:"mb-4",children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:"Question"}),e.jsx("textarea",{className:"w-full border border-gray-300 rounded-lg p-3 focus:ring-2 focus:ring-cyan-500 outline-none resize-none h-32",placeholder:"Type the question here...",value:m,onChange:t=>h(t.target.value),autoFocus:!0,required:!0})]}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx("button",{type:"button",onClick:()=>x(!1),className:"px-4 py-2 text-gray-600 hover:bg-gray-100 rounded-lg font-medium",children:"Cancel"}),e.jsx("button",{type:"submit",className:"px-4 py-2 bg-cyan-600 text-white rounded-lg font-bold hover:bg-cyan-700",children:"Add Question"})]})]})]})})})]}):e.jsx("div",{className:"p-8 text-center text-gray-500",children:"Event not found"})};export{G as default};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.