PageSourceSearch

https://nguyentudo.me/assets/LivePage-DD6GJwyg.js

js nguyentudo.me collected 2026-10-04 14:33:05 UTC 49,824 bytes, 1 lines download raw bytes

1import{aJ as ne,W as Se,r as d,s as g,a as Z,aK as Te,j as e,ag as P,h as j,aL as Me,aM as ue,aN as he,E as De,aO as pe,ai as G,I as W,i as fe,Q as Ee,v as ge,q as $e,C as J,n as C,t as Re,w as Ae,x as Le,y as Ie,aI as Q,z as Ve,F as Pe,G as Fe,L as Y,O as Be,as as qe,aP as V,aQ as ce,ap as X,a0 as oe,a8 as Ge,ab as Ke,m as be,aR as je,aS as Qe}from"./index-CyZ-pQAp.js";import{L as He,u as ze,a as Oe,b as Ue,c as Ye,d as Je,e as Xe,f as We}from"./useReviewCallRealtime-D8jIFcEc.js";import{E as K}from"./external-link-rilHTH9s.js";import{T as de}from"./textarea-C7qwAmQX.js";import{C as ve}from"./copy-By7cyAbJ.js";import{M as Ze}from"./medal-CLCwVwrH.js";import{S as et,a as tt,b as st,c as at,d as le}from"./select-CN_M89Vx.js";import{T as rt}from"./target-DJoMdBMW.js";import{L as nt}from"./link-2-lLeCRBRl.js";import{C as it}from"./circle-help-E2fmlGNL.js";import{P as lt}from"./phone-BwmJJZMD.js";import{S as ct}from"./star-DNt5yvWY.js";import{P as me}from"./play-pP6pK1RW.js";import{F as ot}from"./file-text-8E1KycSb.js";import{v as Ne}from"./vi-DxAQwiEv.js";import"./trash-2-BbakTVuS.js";import"./arrow-down-DC7ujc2S.js";import"./index-CW3DgE6K.js";import"./chevron-up-DzuG9eeF.js";function dt(t){const i=ne(),s=["live-participants",t],n=Se({queryKey:s,queryFn:async()=>{const{data:a,error:m}=await g.from("live_participants").select("*").eq("live_session_id",t).order("joined_at",{ascending:!0});if(m)throw m;if(!a||a.length===0)return[];const l=a.map(o=>o.user_id),{data:c}=await g.from("profiles").select("user_id, display_name, avatar_url").in("user_id",l),h=new Map((c||[]).map(o=>[o.user_id,o]));return a.map(o=>({...o,profiles:h.get(o.user_id)||null}))},enabled:!!t,refetchInterval:3e4});return d.useEffect(()=>{if(!t)return;const a=g.channel(`participants-${t}`).on("postgres_changes",{event:"*",schema:"public",table:"live_participants",filter:`live_session_id=eq.${t}`},()=>{i.invalidateQueries({queryKey:s})}).subscribe();return()=>{g.removeChannel(a)}},[t,i]),n}function mt(){const t=ne(),{user:i}=Z();return Te({mutationFn:async s=>{if(!i)throw new Error("Not authenticated");const{error:n}=await g.from("live_participants").upsert({live_session_id:s,user_id:i.id},{onConflict:"live_session_id,user_id"});if(n)throw n},onSuccess:()=>{t.invalidateQueries({queryKey:["live-participants"]})}})}function xt(t,i){const{user:s}=Z();d.useEffect(()=>{if(!t||!i||!s)return;const n=()=>{const a=`https://dppmotcrumaswzlxkare.supabase.co/rest/v1/live_participants?live_session_id=eq.${t}&user_id=eq.${s.id}`;fetch(a,{method:"DELETE",headers:{apikey:void 0,Authorization:"Bearer undefined"},keepalive:!0}).catch(()=>{})};return window.addEventListener("beforeunload",n),()=>{window.removeEventListener("beforeunload",n),n()}},[t,i,s])}function ut(){const{user:t}=Z(),i=ne(),s=Se({queryKey:["latest-review-call",t==null?void 0:t.id],enabled:!!(t!=null&&t.id),refetchInterval:5e3,refetchIntervalInBackground:!1,queryFn:async()=>{const{data:n,error:a}=await g.from("notifications").select("id, created_at, payload_json").eq("user_id",t.id).eq("type","review_called").is("read_at",null).order("created_at",{ascending:!1}).limit(1).maybeSingle();if(a)throw a;if(!n)return null;const m=n.payload_json??{};return{id:n.id,createdAt:n.created_at,submissionId:typeof m.submission_id=="string"?m.submission_id:null,submissionTitle:typeof m.submission_title=="string"?m.submission_title:null,liveSessionId:typeof m.live_session_id=="string"?m.live_session_id:null,discordUrl:typeof m.discord_url=="string"?m.discord_url:null}}});return d.useEffect(()=>{if(!(t!=null&&t.id))return;const n=g.channel(`latest-review-call-${t.id}`).on("postgres_changes",{event:"*",schema:"public",table:"notifications",filter:`user_id=eq.${t.id}`},a=>{console.log("[review-call] realtime event",a),i.refetchQueries({queryKey:["latest-review-call",t.id]})}).subscribe(a=>{console.log("[review-call] channel status",a)});return()=>{g.removeChannel(n)}},[t==null?void 0:t.id,i]),s}function ht(t){const[i,s]=d.useState(()=>Date.now());if(d.useEffect(()=>{const o=setInterval(()=>s(Date.now()),1e3);return()=>clearInterval(o)},[]),!t)return null;const n=typeof t=="string"?new Date(t).getTime():t.getTime(),a=Math.max(0,n-i),m=Math.floor(a/864e5),l=Math.floor(a%864e5/36e5),c=Math.floor(a%36e5/6e4),h=Math.floor(a%6e4/1e3);return{days:m,hours:l,minutes:c,seconds:h,done:a===0,totalMs:a}}function pt(t){const i=[/youtube\.com\/embed\/([\w-]{11})/,/youtube\.com\/live\/([\w-]{11})/,/youtube\.com\/shorts\/([\w-]{11})/,/youtube\.com\/watch\?(?:[^#]*&)?v=([\w-]{11})/,/youtu\.be\/([\w-]{11})/,/[?&]v=([\w-]{11})/];for(const s of i){const n=t.match(s);if(n)return n[1]}return null}function ft(t){return/(^|\/\/)(www\.)?meet\.google\.com\//i.test(t)}function gt(t){return/(^|\/\/)(www\.)?(discord\.(gg|com)|discordapp\.com)\//i.test(t)}function bt({url:t}){if(ft(t)||gt(t))return e.jsxs("div",{className:"relative w-full aspect-video rounded-xl overflow-hidden bg-gradient-to-br from-primary/30 via-background to-background border border-primary/40 flex flex-col items-center justify-center text-center p-6 gap-4",children:[e.jsx("div",{className:"h-16 w-16 rounded-2xl bg-primary flex items-center justify-center shadow-lg",children:e.jsx(P,{className:"h-8 w-8 text-primary-foreground"})}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("h3",{className:"text-xl font-bold",children:"Live đang diễn ra trên Google Meet"}),e.jsx("p",{className:"text-sm text-muted-foreground max-w-md",children:"Buổi live này được phát qua Google Meet (Full HD 1080p). Nhấn nút bên dưới để tham gia trực tiếp — không cần cài app."})]}),e.jsxs(j,{size:"lg",variant:"cta",onClick:()=>window.open(t,"_blank","noopener,noreferrer"),children:[e.jsx(P,{className:"mr-2 h-4 w-4"}),"Vào Google Meet xem live",e.jsx(K,{className:"ml-2 h-3.5 w-3.5"})]})]});const i=pt(t),s=i?`https://www.youtube.com/embed/${i}?autoplay=1`:t;return e.jsx("div",{className:"relative w-full aspect-video rounded-xl overflow-hidden bg-black",children:e.jsx("iframe",{src:s,className:"absolute inset-0 w-full h-full",allow:"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture",allowFullScreen:!0,title:"Live Stream"})})}const ye=["Aiden","Bella","Charlie","Daisy","Ethan","Fiona","George","Hannah","Isaac","Julia","Kevin","Luna","Mason","Nora","Oscar","Piper","Quinn","Ruby","Sam","Tessa","Uma","Violet","Will","Xena","Yuki","Zara","Leo","Mia","Kai","Nova","Rex","Sky"],we=["Minh","An","Huy","Linh","Phúc","Nam","Trang","Thảo","Quân","Khánh","Hiếu","Vy","Ngọc","Tuấn","Hà","Lan","Bảo","Đức","Hằng","Sơn","Trí","Yến","Hoàng","Diệp","Long","My","Quang","Như","Tâm","Thành"];function jt(){const t=d.useMemo(()=>{const n=new Date,a=n.getFullYear()*1e3+n.getMonth()*50+n.getDate();return Array.from({length:50},(m,l)=>{const c=(a+l*7)%we.length,h=(a+l*11)%ye.length;return{id:`fake-${l}`,name:we[c],avatarUrl:`https://api.dicebear.com/9.x/adventurer/svg?seed=${ye[h]}${l}`}})}
1,[]),[i,s]=d.useState(()=>{const n=new Date;return 12+(n.getFullYear()*1e3+n.getMonth()*50+n.getDate())%17});return d.useEffect(()=>{const n=setInterval(()=>{s(a=>{const m=Math.floor(Math.random()*5)-2;return Math.max(8,Math.min(42,a+m))})},8e3);return()=>clearInterval(n)},[]),{viewers:t.slice(0,i),count:i}}function vt({participants:t}){const{viewers:i,count:s}=jt(),n=t.length+s,a=t.map(c=>{var h,o;return{id:c.id,name:((h=c.profiles)==null?void 0:h.display_name)||"User",avatar:(o=c.profiles)==null?void 0:o.avatar_url}}),m=i.map(c=>({id:c.id,name:c.name,avatar:c.avatarUrl})),l=[...a,...m];return e.jsx("div",{className:"flex items-center gap-3 px-4 py-3 rounded-xl bg-card border border-border",children:e.jsxs(Me,{delayDuration:200,children:[e.jsxs(ue,{children:[e.jsx(he,{asChild:!0,children:e.jsxs("div",{className:"flex items-center gap-1.5 text-xs text-muted-foreground shrink-0 cursor-default",children:[e.jsxs("span",{className:"relative flex h-2 w-2",children:[e.jsx("span",{className:"absolute inline-flex h-full w-full animate-ping rounded-full bg-red-500/70"}),e.jsx("span",{className:"relative inline-flex h-2 w-2 rounded-full bg-red-500"})]}),e.jsx(De,{className:"h-3.5 w-3.5"}),e.jsx("span",{className:"font-semibold tabular-nums text-foreground",children:n}),e.jsx("span",{children:"đang xem"})]})}),e.jsx(pe,{side:"bottom",className:"text-xs",children:"Bao gồm cả khách ghé qua live"})]}),e.jsx("div",{className:"h-4 w-px bg-border shrink-0"}),e.jsx("div",{className:"flex items-center gap-1.5 overflow-x-auto scrollbar-hide flex-1",children:l.map(c=>e.jsxs(ue,{children:[e.jsx(he,{asChild:!0,children:e.jsx("div",{className:"h-8 w-8 rounded-full bg-notion-blue/15 flex items-center justify-center text-notion-blue text-xs font-semibold shrink-0 ring-2 ring-card cursor-default overflow-hidden",children:c.avatar?e.jsx("img",{src:c.avatar,alt:c.name,className:"h-full w-full rounded-full object-cover"}):c.name.charAt(0).toUpperCase()})}),e.jsx(pe,{side:"bottom",className:"text-xs",children:c.name})]},c.id))})]})})}function Nt(){const t="ABCDEFGHJKLMNPQRSTUVWXYZ23456789";let i="";for(let s=0;s<6;s++)i+=t[Math.floor(Math.random()*t.length)];return i}const yt=[1e4,2e4,5e4,1e5,2e5,5e5];function wt({sessionId:t}){const[i,s]=d.useState("form"),[n,a]=d.useState(!1),[m,l]=d.useState(null),[c,h]=d.useState(""),[o,u]=d.useState(""),[y,R]=d.useState(2e4),[k,S]=d.useState(""),[_,A]=d.useState(!1),[T,H]=d.useState(""),[f,F]=d.useState(""),[I,ee]=d.useState(null),M=d.useRef(null),[z,ie]=d.useState([]),[O,te]=d.useState([]),[se,r]=d.useState(null),p=d.useRef(new Set),q=d.useRef(!0);d.useEffect(()=>{let x=!1;const v=async()=>{const{data:D}=await g.from("donations").select("id, donor_name, amount, message, completed_at").eq("live_session_id",t).eq("status","completed").order("completed_at",{ascending:!1}).limit(50);if(x||!D)return;const E=D;if(!q.current&&E.length>0){const N=E[0];p.current.has(N.id)||(r(N.id),setTimeout(()=>r($=>$===N.id?null:$),4e3))}E.forEach(N=>p.current.add(N.id)),q.current=!1,ie(E.slice(0,10));const w=new Map;E.forEach(N=>w.set(N.donor_name,(w.get(N.donor_name)||0)+N.amount));const re=[...w.entries()].map(([N,$])=>({donor_name:N,total:$})).sort((N,$)=>$.total-N.total).slice(0,3);te(re)};v();const b=g.channel(`donations-${t}`).on("postgres_changes",{event:"*",schema:"public",table:"donations",filter:`live_session_id=eq.${t}`},()=>v()).subscribe();return()=>{x=!0,g.removeChannel(b)}},[t]),d.useEffect(()=>()=>{M.current&&clearInterval(M.current)},[]);const L=_?Number(k)||0:y,ae=async x=>{if(x.preventDefault(),L<1e3){C.error("Số tiền tối thiểu 1.000₫");return}a(!0);try{const{data:v}=await g.rpc("get_sepay_public_info"),b=(v==null?void 0:v[0])??null;if(!(b!=null&&b.bank_account_number)){C.error("Hệ thống thanh toán chưa được cấu hình."),a(!1);return}const D=Nt(),E=`DONATE ${D}`,{data:w,error:re}=await g.from("donations").insert({donor_name:c||"Ẩn danh",message:o||null,amount:L,donation_code:D,live_session_id:t}).select().single();if(re||!w){console.error(re),C.error("Không thể tạo donate. Thử lại sau."),a(!1);return}const N=`https://qr.sepay.vn/img?acc=${b.bank_account_number}&bank=${b.bank_short_name}&amount=${L}&des=${encodeURIComponent(E)}`;H(D),F(N),ee({bank:b.bank_name||b.bank_short_name||"",account:b.bank_account_number,holder:b.account_holder||""}),s("payment"),M.current=setInterval(async()=>{const{data:$}=await g.from("donations").select("status").eq("id",w.id).single();($==null?void 0:$.status)==="completed"&&(M.current&&clearInterval(M.current),s("thanks"))},4e3)}catch{C.error("Đã có lỗi xảy ra")}a(!1)},U=(x,v)=>{navigator.clipboard.writeText(x),l(v),setTimeout(()=>l(null),2e3)},B=()=>{M.current&&clearInterval(M.current),s("form"),h(""),u(""),R(2e4),S(""),A(!1)};return e.jsxs("div",{className:"flex-1 overflow-y-auto p-4 space-y-4 relative",children:[i==="form"&&e.jsxs("form",{onSubmit:ae,className:"space-y-4",children:[e.jsxs("div",{className:"text-center space-y-1",children:[e.jsx("div",{className:"w-10 h-10 rounded-full bg-primary/20 flex items-center justify-center mx-auto",children:e.jsx(G,{className:"h-5 w-5 text-primary"})}),e.jsx("h3",{className:"font-bold text-sm",children:"Ủng hộ buổi live"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Lời nhắn sẽ hiển thị trên stream"})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("label",{className:"text-xs font-medium text-muted-foreground",children:"Tên hiển thị"}),e.jsx(W,{placeholder:"Ẩn danh",value:c,onChange:x=>h(x.target.value),maxLength:50,className:"h-9"})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("label",{className:"text-xs font-medium text-muted-foreground",children:"Lời nhắn"}),e.jsx(de,{placeholder:"Viết gì đó cho streamer...",value:o,onChange:x=>u(x.target.value),maxLength:200,rows:2,className:"resize-none"})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("label",{className:"text-xs font-medium text-muted-foreground",children:"Số tiền"}),e.jsx("div",{className:"grid grid-cols-3 gap-1.5",children:yt.map(x=>e.jsxs("button",{type:"button",onClick:()=>{R(x),A(!1)},className:`py-2 px-1 rounded-md border text-xs font-medium transition-all ${!_&&y===x?"border-primary bg-primary/20 text-primary":"border-border bg-muted/50 text-foreground hover:border-primary/50"}
1`,children:[(x/1e3).toLocaleString("vi-VN"),"k"]},x))}),e.jsx("button",{type:"button",onClick:()=>A(!0),className:`text-xs ${_?"text-primary":"text-muted-foreground hover:text-foreground"}`,children:"Số tiền khác?"}),_&&e.jsx(W,{type:"number",placeholder:"Nhập số tiền (VNĐ)",value:k,onChange:x=>S(x.target.value),min:1e3,className:"h-9 mt-1",autoFocus:!0})]}),e.jsxs(j,{variant:"cta",className:"w-full rounded-full gap-2",type:"submit",disabled:n,children:[n?e.jsx(fe,{className:"h-4 w-4 animate-spin"}):e.jsx(G,{className:"h-4 w-4"}),"Donate ",L.toLocaleString("vi-VN"),"₫"]})]}),i==="form"&&(z.length>0||O.length>0)&&e.jsxs("div",{className:"space-y-3 pt-2",children:[O.length>0&&e.jsxs("div",{className:"rounded-xl border border-accent/30 bg-accent/5 p-3",children:[e.jsxs("div",{className:"flex items-center gap-1.5 mb-2",children:[e.jsx(Ee,{className:"h-3.5 w-3.5 text-accent"}),e.jsx("h4",{className:"text-xs font-bold uppercase tracking-wide text-accent",children:"Top donor buổi live"})]}),e.jsx("ul",{className:"space-y-1.5",children:O.map((x,v)=>{const b=v===0?Re:Ze,D=v===0?"text-accent":v===1?"text-muted-foreground":"text-muted-foreground/70";return e.jsxs("li",{className:"flex items-center justify-between text-xs",children:[e.jsxs("span",{className:"flex items-center gap-1.5 truncate",children:[e.jsx(b,{className:`h-3.5 w-3.5 shrink-0 ${D}`}),e.jsx("span",{className:"font-semibold truncate",children:x.donor_name})]}),e.jsxs("span",{className:"font-mono font-semibold text-primary shrink-0 ml-2",children:[x.total.toLocaleString("vi-VN"),"₫"]})]},x.donor_name+v)})})]}),z.length>0&&e.jsxs("div",{children:[e.jsxs("h4",{className:"text-xs font-bold uppercase tracking-wide text-muted-foreground mb-2 flex items-center gap-1.5",children:[e.jsx(G,{className:"h-3 w-3 text-primary"})," Donate gần đây"]}),e.jsx("ul",{className:"space-y-2",children:z.map(x=>e.jsxs("li",{className:`rounded-lg border p-2.5 space-y-1 transition-all ${se===x.id?"border-primary bg-primary/10 shadow-[0_0_20px_hsl(var(--primary)/0.5)] animate-pulse":"border-border bg-muted/30"}`,children:[e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsx("span",{className:"text-xs font-semibold truncate",children:x.donor_name}),e.jsxs("span",{className:"text-xs font-mono font-bold text-primary shrink-0",children:[x.amount.toLocaleString("vi-VN"),"₫"]})]}),x.message&&e.jsxs("p",{className:"text-xs text-muted-foreground leading-snug break-words",children:['"',x.message,'"']})]},x.id))})]})]}),i==="payment"&&I&&e.jsxs("div",{className:"space-y-4 text-center",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"font-bold text-sm",children:"Quét QR để chuyển khoản"}),e.jsx("p",{className:"text-xs text-muted-foreground mt-0.5",children:"Mở app ngân hàng và quét mã"})]}),e.jsx("div",{className:"bg-white rounded-xl p-3 inline-block mx-auto",children:e.jsx("img",{src:f,alt:"QR donate",className:"w-48 h-48 object-contain"})}),e.jsxs("div",{className:"text-left space-y-2 bg-muted/50 rounded-lg p-3 text-xs",children:[e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-muted-foreground",children:"Ngân hàng"}),e.jsx("span",{className:"font-medium",children:I.bank})]}),e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsx("span",{className:"text-muted-foreground",children:"Số TK"}),e.jsxs("button",{onClick:()=>U(I.account,"acc"),className:"font-mono font-medium flex items-center gap-1 text-primary hover:opacity-80",children:[I.account,m==="acc"?e.jsx(ge,{className:"h-3 w-3"}):e.jsx(ve,{className:"h-3 w-3"})]})]}),e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-muted-foreground",children:"Chủ TK"}),e.jsx("span",{className:"font-medium",children:I.holder})]}),e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-muted-foreground",children:"Số tiền"}),e.jsxs("span",{className:"font-semibold text-primary",children:[L.toLocaleString("vi-VN"),"₫"]})]}),e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsx("span",{className:"text-muted-foreground",children:"Nội dung CK"}),e.jsxs("button",{onClick:()=>U(`DONATE ${T}`,"content"),className:"font-mono font-medium flex items-center gap-1 text-primary hover:opacity-80",children:["DONATE ",T,m==="content"?e.jsx(ge,{className:"h-3 w-3"}):e.jsx(ve,{className:"h-3 w-3"})]})]})]}),e.jsxs("div",{className:"flex items-center justify-center gap-2 text-xs text-muted-foreground",children:[e.jsx(fe,{className:"h-3.5 w-3.5 animate-spin text-primary"}),e.jsx("span",{children:"Đang chờ xác nhận..."})]}),e.jsxs("button",{onClick:B,className:"text-xs text-muted-foreground hover:text-foreground flex items-center gap-1 mx-auto",children:[e.jsx($e,{className:"h-3 w-3"})," Quay lại"]})]}),i==="thanks"&&e.jsxs("div",{className:"text-center space-y-4 py-6",children:[e.jsx("div",{className:"w-14 h-14 roun
1ded-full bg-primary/20 flex items-center justify-center mx-auto",children:e.jsx(J,{className:"h-7 w-7 text-primary"})}),e.jsxs("div",{children:[e.jsx("h3",{className:"font-bold",children:"Cảm ơn bạn! 💚"}),e.jsxs("p",{className:"text-sm text-muted-foreground mt-1",children:["Donate ",e.jsxs("strong",{children:[L.toLocaleString("vi-VN"),"₫"]})," đã được xác nhận!"]})]}),e.jsxs(j,{variant:"cta",size:"sm",className:"rounded-full gap-2",onClick:B,children:[e.jsx(G,{className:"h-4 w-4"})," Donate thêm"]})]})]})}function _t({videoUrl:t,sessionId:i,participants:s}){const n=d.useRef(null),[a,m]=d.useState(null),[l,c]=d.useState("chat");return d.useEffect(()=>{const h=n.current;if(!h)return;const o=new ResizeObserver(()=>{m(h.getBoundingClientRect().height)});return o.observe(h),()=>o.disconnect()},[]),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-3 gap-4 lg:items-start",children:[e.jsx("div",{className:"lg:col-span-2 min-w-0",ref:n,children:e.jsx(bt,{url:t})}),e.jsx("div",{className:"rounded-2xl border border-border bg-card overflow-hidden flex flex-col h-[500px] lg:h-auto",children:e.jsxs("div",{className:"flex flex-col h-full lg:h-[var(--chat-h)]",style:a?{"--chat-h":`${a}px`}:void 0,children:[e.jsxs("div",{className:"flex border-b border-border bg-muted/20 shrink-0",children:[e.jsxs("button",{onClick:()=>c("chat"),className:`flex-1 px-3 py-2.5 text-xs font-semibold transition-colors flex items-center justify-center gap-1.5 ${l==="chat"?"text-primary border-b-2 border-primary bg-background":"text-muted-foreground hover:text-foreground"}`,children:[e.jsx(Ae,{className:"h-3.5 w-3.5"})," Chat"]}),e.jsxs("button",{onClick:()=>c("donate"),className:`flex-1 px-3 py-2.5 text-xs font-semibold transition-colors flex items-center justify-center gap-1.5 ${l==="donate"?"text-primary border-b-2 border-primary bg-background":"text-muted-foreground hover:text-foreground"}`,children:[e.jsx(G,{className:"h-3.5 w-3.5"})," Donate"]})]}),e.jsx("div",{className:"flex-1 min-h-0 flex flex-col",children:l==="chat"?e.jsx(He,{sessionId:i}):e.jsx(wt,{sessionId:i})})]})})]}),e.jsx(vt,{participants:s})]})}const _e={queued:{color:"bg-muted text-muted-foreground",label:"Đang chờ",icon:ce},selected:{color:"bg-accent/20 text-accent-foreground border-accent/30",label:"Đang chữa",icon:P},reviewed:{color:"bg-primary/20 text-primary border-primary/40",label:"Đã review",icon:J},skipped:{color:"bg-muted/50 text-muted-foreground",label:"Bỏ qua",icon:ce}},ke={quick:{color:"border-primary/20 text-primary",label:"Nhanh"},normal:{color:"border-muted-foreground/30 text-muted-foreground",label:"Bình thường"},deep:{color:"border-primary/40 text-primary",label:"Chuyên sâu"}};function xe({sessionId:t,disabled:i,trigger:s}){const n=ze(),[a,m]=d.useState(!1),[l,c]=d.useState({title:"",link:"",context:"",question:"",priority:"normal"}),h=async()=>{if(!(!t||!l.title.trim()))try{await n.mutateAsync({live_session_id:t,title:l.title,link:l.link||void 0,context:l.context||void 0,question:l.question||void 0,priority:l.priority}),m(!1),c({title:"",link:"",context:"",question:"",priority:"normal"}),C.success("Đã gửi bài chữa!")}catch{C.error("Không thể gửi bài")}};return e.jsxs(Le,{open:a,onOpenChange:m,children:[e.jsx(Ie,{asChild:!0,children:s??e.jsxs(j,{variant:"glow",size:"sm",disabled:i,children:[e.jsx(Q,{className:"mr-2 h-4 w-4"})," Nộp bài chữa"]})}),e.jsxs(Ve,{className:"bg-card border-border max-w-lg",children:[e.jsx(Pe,{children:e.jsxs(Fe,{className:"flex items-center gap-2",children:[e.jsx(Q,{className:"h-5 w-5 text-primary"})," Nộp bài chữa"]})}),e.jsx("p",{className:"text-xs text-muted-foreground -mt-2 mb-2",children:"Điền theo cấu trúc: Bối cảnh → Mục tiêu → Link → Câu hỏi chính"}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs(Y,{className:"flex items-center gap-1.5 text-xs",children:[e.jsx(rt,{className:"h-3.5 w-3.5 text-primary"})," Tiêu đề bài *"]}
1),e.jsx(W,{placeholder:"VD: Sales page khoá học AI cho freelancer",value:l.title,onChange:o=>c({...l,title:o.target.value})})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs(Y,{className:"flex items-center gap-1.5 text-xs",children:[e.jsx(Be,{className:"h-3.5 w-3.5 text-primary"})," Bối cảnh"]}),e.jsx(de,{placeholder:"VD: Mình đang xây khoá học dạy freelancer dùng AI...",value:l.context,onChange:o=>c({...l,context:o.target.value}),rows:3})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs(Y,{className:"flex items-center gap-1.5 text-xs",children:[e.jsx(nt,{className:"h-3.5 w-3.5 text-primary"})," Link sản phẩm / tài liệu"]}),e.jsx(W,{placeholder:"https://...",value:l.link,onChange:o=>c({...l,link:o.target.value})})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs(Y,{className:"flex items-center gap-1.5 text-xs",children:[e.jsx(it,{className:"h-3.5 w-3.5 text-primary"})," Câu hỏi chính"]}),e.jsx(de,{placeholder:"VD: Hook có đủ mạnh không? Offer có clear không?",value:l.question,onChange:o=>c({...l,question:o.target.value}),rows:2})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(Y,{className:"text-xs",children:"Mức độ review"}),e.jsxs(et,{value:l.priority,onValueChange:o=>c({...l,priority:o}),children:[e.jsx(tt,{children:e.jsx(st,{})}),e.jsxs(at,{children:[e.jsx(le,{value:"quick",children:"⚡ Nhanh (~5 phút)"}),e.jsx(le,{value:"normal",children:"📋 Bình thường (~10 phút)"}),e.jsx(le,{value:"deep",children:"🔍 Chuyên sâu (15+ phút)"})]})]})]}),e.jsx(j,{variant:"cta",className:"w-full",onClick:h,disabled:n.isPending||!l.title.trim(),children:n.isPending?"Đang gửi...":"Gửi bài chữa"})]})]})]})}function kt({submissions:t,sessionId:i,discordUrl:s,calledSubmissionId:n}){var se;const{user:a}=Z(),{isAdmin:m}=qe(),l=Oe(),c=ne(),[h,o]=d.useState(null),[u,y]=d.useState("queue"),R=(t==null?void 0:t.filter(r=>r.status==="queued"||r.status==="selected"))||[],k=(t==null?void 0:t.filter(r=>r.status==="reviewed"||r.status==="skipped"))||[],S=(t==null?void 0:t.filter(r=>r.status==="queued").length)||0,_=k.length,A=async r=>{if(!r)return;const{data:p}=await g.from("notifications").select("id").eq("user_id",r).eq("type","review_called").is("read_at",null).order("created_at",{ascending:!1}).limit(1).maybeSingle();p!=null&&p.id&&await g.from("notifications").update({read_at:new Date().toISOString()}).eq("id",p.id)},T=async r=>{try{await l.mutateAsync(r),C.success("Đã chọn — học viên sẽ thấy nút vào Google Meet!")}catch(p){C.error(p.message||"Không thể chọn bài")}},H=async(r,p)=>{try{const{error:q}=await g.from("submissions").update({status:"reviewed",reviewed_at:new Date().toISOString()}).eq("id",r);if(q)throw q;await A(p),c.invalidateQueries({queryKey:["submissions"]}),c.invalidateQueries({queryKey:["latest-review-call",p]}),y("done"),C.success("Đã hoàn thành review!")}catch{C.error("Không thể cập nhật trạng thái")}},f=async(r,p)=>{try{const{error:q}=await g.from("submissions").update({status:"skipped"}).eq("id",r);if(q)throw q;await A(p),c.invalidateQueries({queryKey:["submissions"]}),c.invalidateQueries({queryKey:["latest-review-call",p]}),C.success("Đã bỏ qua")}catch{C.error("Không thể cập nhật")}},F=t==null?void 0:t.find(r=>r.status==="selected"),I=(t==null?void 0:t.filter(r=>r.status==="queued"))||[],ee=I.find(r=>r.user_id===(a==null?void 0:a.id)),M=ee?I.indexOf(ee)+1:null,z=t==null?void 0:t.find(r=>r.status==="selected"&&r.user_id===(a==null?void 0:a.id)),ie=n?t==null?void 0:t.find(r=>r.id===n&&r.user_id===(a==null?void 0:a.id)):void 0,O=z||ie,te=u==="queue"?R:k;return e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center gap-1 border-b border-border",children:[e.jsxs("button",{onClick:()=>y("queue"),className:`px-3 py-2 text-xs font-semibold flex items-center gap-1.5 border-b-2 transition-colors ${u==="queue"?"border-primary text-primary":"border-transparent text-muted-foreground hover:text-foreground"}`,children:[e.jsx(Q,{className:"h-3.5 w-3.5"})," Hàng đợi",S>0&&e.jsx("span",{className:"h-4 min-w-[16px] rounded-full bg-primary/20 text-primary text-[9px] font-bold px-1 flex items-center justify-center",children:S})]}),e.jsxs("button",{onClick:()=>y("done"),className:`px-3 py-2 text-xs font-semibold flex items-center gap-1.5 border-b-2 transition-colors ${u==="done"?"border-primary text-primary":"border-transparent text-muted-foreground hover:text-foreground"}`,children:[e.jsx(J,{className:"h-3.5 w-3.5"})," Đã chữa",_>0&&e.jsx("span",{className:"h-4 min-w-[16px] rounded-full bg-primary/20 text-primary text-[9px] font-bold px-1 flex items-center justify-center",children:_})]}),t&&t.length>0&&e.jsxs("span",{className:"text-[11px] text-muted-foreground ml-auto",children:[_,"/",t.length," đã review"]})]}),u==="queue"&&O&&e.jsxs("div",{className:"rounded-xl border-2 border-accent bg-accent/20 p-4 space-y-3 shadow-[0_0_20px_hsl(var(--accent)/0.25)]",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(V,{className:"h-5 w-5 text-accent"}),e.jsx("span",{className:"font-bold text-sm text-foreground",children:"Đến lượt bạn!"})]}
1),e.jsx("p",{className:"text-xs text-foreground/80",children:s?"Nhấn nút bên dưới để vào phòng Google Meet ngay.":"Mentor đang gọi bạn lên, nhưng buổi này chưa có link Google Meet."}),s&&e.jsxs(j,{variant:"cta",size:"sm",className:"w-full sm:w-auto",onClick:()=>window.open(s,"_blank","noopener,noreferrer"),children:[e.jsx(V,{className:"mr-2 h-3.5 w-3.5"})," Tham gia Google Meet",e.jsx(K,{className:"ml-2 h-3.5 w-3.5"})]})]}),u==="queue"&&M&&e.jsxs("div",{className:"rounded-lg border border-primary/20 bg-primary/5 px-3 py-2 text-xs text-primary font-medium flex items-center gap-2",children:[e.jsx(ce,{className:"h-3 w-3"}),"Bạn đang ở vị trí #",M," trong hàng đợi"]}),u==="queue"&&F&&e.jsx("div",{className:"rounded-lg border border-accent/30 bg-accent/5 px-3 py-2",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(P,{className:"h-3.5 w-3.5 text-destructive-foreground"}),e.jsx("span",{className:"text-xs font-semibold text-destructive-foreground",children:"Đang chữa:"}),e.jsx("span",{className:"text-xs truncate",children:F.title}),e.jsxs("span",{className:"text-[10px] text-muted-foreground",children:["— ",((se=F.profiles)==null?void 0:se.display_name)||"Thành viên"]})]})}),te.length===0?e.jsx("div",{className:"rounded-xl bg-muted/30 border border-border p-6 text-center",children:u==="queue"?e.jsxs(e.Fragment,{children:[e.jsx(Q,{className:"h-6 w-6 text-muted-foreground/30 mx-auto mb-1.5"}),e.jsx("p",{className:"text-muted-foreground text-xs",children:"Chưa có bài nào trong hàng đợi."})]}):e.jsxs(e.Fragment,{children:[e.jsx(J,{className:"h-6 w-6 text-muted-foreground/30 mx-auto mb-1.5"}),e.jsx("p",{className:"text-muted-foreground text-xs",children:"Chưa có bài nào đã chữa."})]})}):e.jsx("div",{className:"space-y-2 max-h-[400px] overflow-y-auto pr-1",children:te.map(r=>{const p=r.profiles,q=(p==null?void 0:p.display_name)||"Thành viên",L=r.status==="reviewed",ae=r.status==="selected",U=r.user_id===(a==null?void 0:a.id)&&(ae||r.id===n),B=_e[r.status]||_e.queued,x=ke[r.priority]||ke.normal,v=B.icon,b=h===r.id,D=r.context||r.question||r.link,E=L&&(r.rubric_notes||r.reviewer_score);return e.jsxs("div",{className:`rounded-lg border bg-card/50 transition-all duration-200 ${U?"border-accent/50 bg-accent/10":ae?"border-accent/40 bg-accent/5":L?"border-primary/30":"border-border hover:border-primary/20"}`,children:[e.jsxs("div",{className:"flex items-center gap-2.5 p-3 cursor-pointer",onClick:()=>(D||E)&&o(b?null:r.id),children:[e.jsx("div",{className:"h-7 w-7 rounded-full bg-primary/10 flex items-center justify-center text-primary text-xs font-bold shrink-0 overflow-hidden",children:p!=null&&p.avatar_url?e.jsx("img",{src:p.avatar_url,alt:"",className:"h-full w-full rounded-full object-cover"}):q.charAt(0).toUpperCase()}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"font-medium text-xs truncate",children:r.title}),e.jsx("p",{className:"text-[10px] text-muted-foreground",children:q})]}),e.jsx(X,{variant:"outline",className:`text-[9px] h-5 ${x.color}`,children:x.label}),e.jsxs(X,{className:`text-[9px] h-5 gap-0.5 ${B.color}`,children:[e.jsx(v,{className:"h-2.5 w-2.5"}),B.label]}),m&&r.status==="queued"&&e.jsxs(j,{variant:"glow",size:"sm",className:"h-6 text-[10px] px-2 gap-1",onClick:w=>{w.stopPropagation(),T(r.id)},disabled:l.isPending||!!F,children:[e.jsx(lt,{className:"h-3 w-3"})," Gọi lên"]}),m&&r.status==="selected"&&e.jsxs("div",{className:"flex gap-1",onClick:w=>w.stopPropagation(),children:[e.jsxs(j,{variant:"cta",size:"sm",className:"h-6 text-[10px] px-2 gap-1",onClick:()=>H(r.id,r.user_id),children:[e.jsx(J,{className:"h-3 w-3"})," Xong"]}),s&&e.jsxs(j,{variant:"outline",size:"sm",className:"h-6 text-[10px] px-2 gap-1",onClick:()=>window.open(s,"_blank","noopener,noreferrer"),children:[e.jsx(V,{className:"h-3 w-3"})," Meet"]})]}),U&&s&&e.jsxs(j,{variant:"cta",size:"sm",className:"h-7 text-[10px] px-2 gap-1",onClick:w=>{w.stopPropagation(),window.open(s,"_blank","noopener,noreferrer")},children:[e.jsx(V,{className:"h-3 w-3"})," Vào Google Meet"]}),m&&r.status==="queued"&&e.jsx(j,{variant:"ghost",size:"sm",className:"h-6 text-[10px] px-1.5 text-muted-foreground hover:text-destructive",onClick:w=>{w.stopPropagation(),f(r.id,r.user_id)},children:"Bỏ qua"})]}),b&&e.jsxs("div",{className:"px-3 pb-3 space-y-2 border-t border-border pt-2 ml-9",children:[r.context&&e.jsxs("div",{children:[e.jsx("p",{className:"text-[9px] font-semibold uppercase tracking-wider text-muted-foreground mb-0.5",children:"Bối cảnh"}),e.jsx("p",{className:"text-xs leading-relaxed",children:r.context})]}),r.link&&e.jsxs("a",{href:r.link,target:"_blank",rel:"noopener noreferrer",className:"text-xs text-primary hover:underline flex items-center gap-1",children:[e.jsx(K,{className:"h-3 w-3"})," ",r.link]}),r.question&&e.jsxs("div",{children:[e.jsx("p",{className:"text-[9px] font-semibold uppercase tracking-wider text-muted-foreground mb-0.5",children:"Câu hỏi"}),e.jsx("p",{className:"text-xs leading-relaxed",children:r.question})]}),E&&e.jsxs("div",{className:"rounded-lg bg-primary/5 border border-primary/20 p-3 space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("p",{className:"text-[10px] font-bold uppercase tracking-wider text-primary flex items-center gap-1",children:[e.jsx(ct,{className:"h-3 w-3"})," Feedback"]}),r.reviewer_score&&e.jsx(Ct,{score:r.reviewer_score})]}),r.rubric_notes&&e.jsx("p",{className:"text-xs leading-relaxed whitespace-pre-wrap",children:r.rubric_notes}),r.replay_timestamp_sec!=null&&e.jsxs("p",{className:"text-[10px] text-primary flex items-center gap-1",children:[e.jsx(me,{className:"h-2.5 w-2.5"})," Phút ",St(r.replay_timestamp_sec)]})]}),r.admin_notes&&e.jsx("div",{className:"rounded-lg bg-muted/50 border border-border p-2",children:e.jsx("p",{className:"text-xs",children:r.admin_notes})})]})]},r.id)})})]})}function Ct({score:t}){const i=t>=8?"text-primary bg-primary/20":t>=5?"text-primary/70 bg-primary/10":"text-muted-foreground bg-muted";return e.jsxs("div",{className:`rounded-md px-2 py-0.5 text-xs font-black ${i}`,children:[t,"/10"]})}function St(t){const i=Math.floor(t/60),s=t%60;return`${i}:${s.toString().padStart(2,"0")}`}function qt({sessionId:t}
1){const[i,s]=d.useState([]),n=d.useRef(new Set),a=d.useRef(!0);d.useEffect(()=>{if(!t)return;let l=!1;(async()=>{const{data:o}=await g.from("donations").select("id").eq("live_session_id",t).eq("status","completed");l||(o==null||o.forEach(u=>n.current.add(u.id)),a.current=!1)})();const c=o=>{if(a.current||n.current.has(o.id))return;n.current.add(o.id);const u={...o,_key:`${o.id}-${Date.now()}`};s(y=>[...y,u].slice(-3)),setTimeout(()=>{s(y=>y.filter(R=>R._key!==u._key))},8e3)},h=g.channel(`donation-toasts-${t}`).on("postgres_changes",{event:"UPDATE",schema:"public",table:"donations",filter:`live_session_id=eq.${t}`},o=>{const u=o.new;(u==null?void 0:u.status)==="completed"&&c(u)}).on("postgres_changes",{event:"INSERT",schema:"public",table:"donations",filter:`live_session_id=eq.${t}`},o=>{const u=o.new;(u==null?void 0:u.status)==="completed"&&c(u)}).subscribe();return()=>{l=!0,g.removeChannel(h)}},[t]);const m=l=>{s(c=>c.filter(h=>h._key!==l))};return i.length===0?null:e.jsx("div",{className:"fixed bottom-4 right-4 z-[60] flex flex-col gap-2 pointer-events-none max-w-[360px] w-[calc(100vw-2rem)] sm:w-[360px]",children:i.map(l=>e.jsx("div",{className:"pointer-events-auto rounded-2xl border-2 border-primary bg-card/95 backdrop-blur-md shadow-[0_0_32px_hsl(var(--primary)/0.5)] p-4 animate-in slide-in-from-right-5 fade-in duration-300",children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:"h-10 w-10 rounded-full bg-primary/20 flex items-center justify-center shrink-0 animate-pulse",children:e.jsx(G,{className:"h-5 w-5 text-primary fill-primary"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-1.5 mb-0.5",children:[e.jsx(oe,{className:"h-3 w-3 text-primary"}),e.jsx("span",{className:"text-[10px] font-bold uppercase tracking-wider text-primary",children:"Donate mới!"})]}),e.jsxs("div",{className:"flex items-baseline justify-between gap-2",children:[e.jsx("span",{className:"font-bold text-sm truncate text-foreground",children:l.donor_name}),e.jsxs("span",{className:"font-mono font-extrabold text-primary text-base shrink-0",children:[l.amount.toLocaleString("vi-VN"),"₫"]})]}),l.message&&e.jsxs("p",{className:"text-xs text-muted-foreground italic mt-1 break-words line-clamp-2",children:['"',l.message,'"']})]}),e.jsx("button",{onClick:()=>m(l._key),className:"text-muted-foreground hover:text-foreground transition-colors shrink-0 -mt-1 -mr-1 p-1","aria-label":"Đóng",children:e.jsx(Ge,{className:"h-3.5 w-3.5"})})]})},l._key))})}function Tt({sessionId:t}){const[i,s]=d.useState(!0),n=[{icon:ot,title:"Chuẩn bị bài của bạn",desc:"Link Google Doc, Notion, video, landing page... bất cứ thứ gì cần feedback."},{icon:Q,title:"Nhấn nút 'Nộp bài'",desc:"Điền tiêu đề, dán link, mô tả ngắn câu hỏi bạn muốn mentor góp ý."},{icon:oe,title:"Chờ tới lượt trong hàng đợi",desc:"Mentor sẽ chọn bài theo thứ tự. Bạn sẽ thấy banner 'Đến lượt bạn'."},{icon:V,title:"Vào Google Meet chữa trực tiếp",desc:"Nhấn nút 'Tham gia Google Meet' trên banner — Meet mở thẳng trên trình duyệt, không cần cài app."}];return e.jsxs("div",{className:"rounded-2xl border border-primary/20 bg-gradient-to-br from-primary/5 via-card to-card overflow-hidden",children:[e.jsxs("button",{onClick:()=>s(a=>!a),className:"w-full flex items-center justify-between gap-3 p-4 hover:bg-primary/5 transition-colors",children:[e.jsxs("div",{className:"flex items-center gap-3 min-w-0",children:[e.jsx("div",{className:"h-9 w-9 rounded-xl bg-primary/15 flex items-center justify-center shrink-0",children:e.jsx(oe,{className:"h-4 w-4 text-primary"})}),e.jsxs("div",{className:"text-left min-w-0",children:[e.jsx("p",{className:"text-sm font-bold text-foreground",children:"Cách tham gia chữa bài trong buổi live"}),e.jsx("p",{className:"text-xs text-muted-foreground truncate",children:"4 bước đơn giản để được mentor feedback trực tiếp"})]})]}),e.jsx(Ke,{className:`h-4 w-4 text-muted-foreground shrink-0 transition-transform ${i?"rotate-180":""}`})]}),i&&e.jsxs("div",{className:"px-4 pb-4 pt-1",children:[e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-4 gap-3",children:n.map((a,m)=>e.jsxs("div",{className:"relative rounded-xl border border-border bg-background/50 p-3 flex flex-col gap-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"h-7 w-7 rounded-lg bg-primary/10 flex items-center justify-center shrink-0",children:e.jsx(a.icon,{className:"h-3.5 w-3.5 text-primary"})}),e.jsxs("span",{className:"text-[10px] font-bold text-muted-foreground uppercase tracking-wider",children:["Bước ",m+1]})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-semibold text-foreground leading-snug",children:a.title}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1 leading-relaxed",children:a.desc})]})]},m))}),e.jsxs("div",{className:"mt-4 flex flex-col sm:flex-row items-center justify-between gap-3 pt-3 border-t border-border/50",children:[e.jsx("p",{className:"text-[11px] text-muted-foreground text-center sm:text-left",children:"💡 Nộp bài càng sớm, càng nhanh đến lượt. Mô tả câu hỏi cụ thể để nhận feedback chất lượng hơn."}),e.jsx(xe,{sessionId:t,disabled:!t,trigger:e.jsxs(j,{variant:"cta",size:"sm",className:"shrink-0 w-full sm:w-auto",children:[e.jsx(Q,{className:"mr-2 h-4 w-4"})," Nộp bài chữa ngay"]})})]})]})]})}function Mt(){const t=new Date,i=new Date(t.getFullYear(),t.getMonth(),t.getDate(),21,0,0,0);return i.getTime()<=t.getTime()&&i.setDate(i.getDate()+1),i}function Ce({target:t}){const i=ht(t);if(!i)return null;const s=[{v:i.days,l:"ngày"},{v:i.hours,l:"giờ"},{v:i.minutes,l:"phút"},{v:i.seconds,l:"giây"}];return e.jsx("div",{className:"flex items-center gap-2 justify-center",children:s.map((n,a)=>e.jsxs("div",{className:"flex flex-col items-center min-w-[56px] rounded-xl bg-primary/10 border border-primary/20 px-3 py-2",children:[e.jsx("span",{className:"text-2xl font-bold text-primary tabular-nums leading-none",children:String(n.v).padStart(2,"0")}),e.jsx("span",{className:"text-[10px] uppercase tracking-wider text-muted-foreground mt-1",children:n.l})]},a))})}function Jt(){const{user:t}
1=Z(),{isAdmin:i}=qe(),{data:s}=Ue(),{data:n}=ut(),{data:a}=Ye(s==null?void 0:s.id),{data:m}=Je(),{data:l}=dt(s==null?void 0:s.id),c=mt(),[h,o]=d.useState("");Xe(),We(s==null?void 0:s.id);const u=(s==null?void 0:s.status)==="live",y=(l==null?void 0:l.some(f=>f.user_id===(t==null?void 0:t.id)))??!1,R=(n==null?void 0:n.liveSessionId)===(s==null?void 0:s.id),k=(R?n==null?void 0:n.discordUrl:null)||(s==null?void 0:s.discord_url);d.useEffect(()=>{u&&(s!=null&&s.id)&&t&&!y&&l!==void 0&&c.mutate(s.id)},[u,s==null?void 0:s.id,t,y,l]),xt(s==null?void 0:s.id,y);const S=a==null?void 0:a.find(f=>f.status==="selected"),_=a==null?void 0:a.find(f=>f.status==="selected"&&f.user_id===(t==null?void 0:t.id)),A=(_==null?void 0:_.id)??(R?(n==null?void 0:n.submissionId)??null:null),T=!!_||!!A,H=i&&!!S;return s&&u&&s.live_url?e.jsxs("div",{className:"max-w-7xl mx-auto space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsxs("div",{className:"flex items-center gap-3 min-w-0",children:[e.jsxs("span",{className:"flex items-center gap-1.5 shrink-0",children:[e.jsx("span",{className:"h-2.5 w-2.5 rounded-full bg-destructive animate-pulse"}),e.jsx("span",{className:"text-sm font-bold text-destructive uppercase tracking-wider",children:"Live"})]}),e.jsx("h1",{className:"text-lg font-semibold truncate",children:s.title}),s.topic_tag&&e.jsx(X,{variant:"outline",className:"text-[10px] border-primary/30 text-primary shrink-0",children:s.topic_tag})]}),e.jsx("div",{className:"flex items-center gap-2 shrink-0",children:e.jsx(xe,{sessionId:s.id})})]}),T&&k&&e.jsx("div",{className:"rounded-2xl border-2 border-accent bg-gradient-to-br from-accent/15 to-accent/5 p-5 animate-in fade-in slide-in-from-top-2 duration-300",children:e.jsxs("div",{className:"flex items-center justify-between gap-4 flex-wrap",children:[e.jsxs("div",{className:"flex items-center gap-3 min-w-0",children:[e.jsx("div",{className:"h-10 w-10 rounded-xl bg-accent/20 flex items-center justify-center shrink-0",children:e.jsx(V,{className:"h-5 w-5 text-accent-foreground"})}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"text-base font-bold text-foreground",children:"Đến lượt bạn chữa bài! 🎙️"}),e.jsx("p",{className:"text-xs text-muted-foreground truncate",children:"Vào phòng Google Meet để được mentor chữa trực tiếp"})]})]}),e.jsxs(j,{variant:"cta",size:"lg",onClick:()=>window.open(k,"_blank","noopener,noreferrer"),className:"shrink-0",children:[e.jsx(V,{className:"mr-2 h-4 w-4"})," Tham gia Google Meet",e.jsx(K,{className:"ml-2 h-3.5 w-3.5"})]})]})}),T&&!k&&e.jsx("div",{className:"rounded-2xl border border-accent/40 bg-accent/10 px-4 py-3",children:e.jsx("p",{className:"text-sm font-medium text-destructive-foreground",children:"🎙️ Đến lượt bạn! Mentor sẽ liên hệ qua kênh đã hẹn — chưa có link Google Meet cho buổi này."})}),H&&!T&&e.jsxs("div",{className:"rounded-2xl border border-primary/30 bg-primary/5 p-4 flex items-center justify-between gap-3 flex-wrap",children:[e.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[e.jsx("span",{className:"h-2 w-2 rounded-full bg-primary animate-pulse shrink-0"}),e.jsxs("span",{className:"text-sm",children:[e.jsx("span",{className:"text-muted-foreground",children:"Đang chữa bài:"})," ",e.jsx("span",{className:"font-bold",children:S.title})]})]}),k&&e.jsxs(j,{variant:"outline",size:"sm",onClick:()=>window.open(k,"_blank","noopener,noreferrer"),children:[e.jsx(V,{className:"mr-2 h-3.5 w-3.5"})," Vào Google Meet"]})]}),!i&&!T&&S&&e.jsxs("div",{className:"flex items-center gap-2 px-4 py-2.5 rounded-xl bg-primary/10 border border-primary/20 animate-in fade-in duration-300",children:[e.jsx("span",{className:"h-2 w-2 rounded-full bg-primary animate-pulse"}),e.jsxs("span",{className:"text-sm text-primary font-medium",children:["Đang chữa bài: ",e.jsx("span",{className:"font-bold",children:S.title})]})]}),e.jsx(_t,{videoUrl:s.live_url,sessionId:s.id,participants:l||[]}),!T&&!S&&e.jsx(Tt,{sessionId:s.id}),e.jsx("div",{className:"rounded-2xl border border-border bg-card p-4",children:e.jsx(kt,{submissions:a,sessionId:s.id,discordUrl:k??null,calledSubmissionId:A})}),e.jsx(qt,{sessionId:s.id})]}
1):e.jsxs("div",{className:"max-w-7xl mx-auto space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"h-9 w-9 rounded-xl bg-[hsl(var(--notion-red))] flex items-center justify-center",children:e.jsx(P,{className:"h-5 w-5 text-white"})}),e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-semibold",children:"Live"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Chữa bài trực tiếp — nộp bài, nhận feedback chi tiết"})]})]}),e.jsx(xe,{sessionId:s==null?void 0:s.id,disabled:!s})]}),s?e.jsxs("div",{className:"rounded-2xl bg-gradient-to-br from-primary/5 via-card to-card border border-primary/20 p-6 glow-primary",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx(be,{className:"h-4 w-4 text-primary"}),e.jsxs("span",{className:"text-sm font-medium text-primary",children:[je(new Date(s.scheduled_at),"HH:mm",{locale:Ne})," — Hôm nay"]}),s.topic_tag&&e.jsx(X,{variant:"outline",className:"text-[10px] border-primary/30 text-primary",children:s.topic_tag})]}),e.jsx("h2",{className:"text-xl font-bold mb-2",children:s.title}),s.description&&e.jsx("p",{className:"text-sm text-muted-foreground mb-4",children:s.description}),e.jsxs("div",{className:"my-4",children:[e.jsx(Ce,{target:s.scheduled_at}),e.jsx("p",{className:"text-xs text-center text-muted-foreground mt-2",children:"Còn lại đến giờ live"})]}),e.jsx("div",{className:"text-center",children:s.status==="live"&&s.live_url?e.jsx(j,{variant:"cta",size:"sm",asChild:!0,children:e.jsxs("a",{href:s.live_url,target:"_blank",rel:"noopener noreferrer",children:[e.jsx(P,{className:"mr-2 h-4 w-4"})," Vào Live ",e.jsx(K,{className:"ml-2 h-3 w-3"})]})}):e.jsxs(j,{variant:"cta",size:"sm",disabled:!0,title:"Nút sẽ tự bật khi mentor bắt đầu live",children:[e.jsx(be,{className:"mr-2 h-4 w-4"})," Chưa bắt đầu — chờ mentor bật live"]})})]}):e.jsxs("div",{className:"relative overflow-hidden rounded-2xl bg-gradient-to-br from-primary/15 via-primary/5 to-accent/10 border-2 border-primary/40 p-8 text-center glow-primary",children:[e.jsxs("div",{className:"absolute top-4 left-4 flex items-center gap-1.5 rounded-full bg-destructive/15 border border-destructive/40 px-2.5 py-1",children:[e.jsx("span",{className:"h-2 w-2 rounded-full bg-destructive animate-pulse"}),e.jsx("span",{className:"text-[10px] font-bold uppercase tracking-wider text-destructive",children:"Sắp live"})]}),e.jsx("div",{className:"h-14 w-14 rounded-2xl bg-primary/20 border border-primary/30 flex items-center justify-center mx-auto mb-4 mt-2",children:e.jsx(P,{className:"h-7 w-7 text-primary"})}),e.jsx("h3",{className:"text-2xl font-bold mb-2",children:"Livestream chữa bài — 21:00 tối nay"}),e.jsx("p",{className:"text-sm text-muted-foreground mb-6 max-w-md mx-auto",children:"Nộp bài trước giờ live để được mentor chữa trực tiếp. Đừng bỏ lỡ nhé!"}),e.jsxs("div",{className:"my-6",children:[e.jsx(Ce,{target:Mt()}),e.jsx("p",{className:"text-xs uppercase tracking-wider text-primary/80 font-semibold mt-3",children:"⏰ Còn lại đến giờ live"})]}),e.jsx("p",{className:"text-xs text-muted-foreground/70 mt-4",children:"Trang sẽ tự chuyển sang chế độ xem live ngay khi bắt đầu."})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsx("h2",{className:"text-lg font-semibold",children:"Thư viện Replay"}),e.jsxs("div",{className:"relative",children:[e.jsx(Qe,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(W,{placeholder:"Tìm theo tên, chủ đề...",value:h,onChange:f=>o(f.target.value),className:"pl-10"})]}),!m||m.length===0?e.jsxs("div",{className:"text-center text-muted-foreground py-10 rounded-2xl bg-card border border-border",children:[e.jsx(me,{className:"h-8 w-8 text-muted-foreground/30 mx-auto mb-2"}),e.jsx("p",{className:"text-sm",children:"Chưa có replay nào."})]}):m.filter(f=>!h||f.title.toLowerCase().includes(h.toLowerCase())).map(f=>e.jsx("a",{href:f.replay_url||f.live_url||"#",target:"_blank",rel:"noopener noreferrer",className:"block rounded-xl bg-card border border-border p-4 hover:border-primary/30 transition-all duration-200 group",children:e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx("div",{className:"h-12 w-16 rounded-lg bg-primary/10 flex items-center justify-center shrink-0 group-hover:bg-primary/20 transition-colors",children:e.jsx(me,{className:"h-5 w-5 text-primary"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"font-semibold text-sm truncate group-hover:text-primary transition-colors",children:f.title}),e.jsxs("div",{className:"flex items-center gap-2 mt-0.5",children:[e.jsx("p",{className:"text-xs text-muted-foreground",children:je(new Date(f.scheduled_at),"d MMM yyyy",{locale:Ne})}),f.topic_tag&&e.jsx(X,{variant:"outline",className:"text-[10px] h-4 border-primary/20 text-primary",children:f.to
1pic_tag})]})]}),e.jsx(K,{className:"h-4 w-4 text-muted-foreground group-hover:text-primary transition-colors shrink-0"})]})},f.id))]})]})}export{Jt 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.