1const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/index-ClvMDdP5.js","assets/index-DizUTG5R.css"])))=>i.map(i=>d[i]); 2import{r as n,s as I,j as e,A as qe,m as he,a3 as Tr,u as sr,cF as ar,X as Ar,b9 as Dr,P as Pr,a as $r,B as Kn,b as Fr,ai as Ft,w as Or,g as Ur,i as Br,cG as zr,bP as Hr,b7 as qr,ci as Wr,cH as mn,cI as Yn,bS as Vr,L as Gr,V as Jr,U as Kr,cJ as Yr,a4 as Zr,a6 as Xr,H as Qr,bQ as es,ap as $t,cK as ts,a$ as ns,bO as rs}from"./index-ClvMDdP5.js";import{u as ss,a as as,s as Zn,b as os,L as is,c as cs,d as ls}from"./LiveArtwork-5Kc4Teb1.js";import{t as ht}from"./top20-cover.jpg.asset-C4KCUSQD.js";import{H as us,S as ds}from"./HypeOverlay-cZJ_pG3x.js";import{A as fs}from"./arrow-down-Br5uRo3T.js";import{I as ms}from"./input-DAmQA-Zd.js";import{S as hs}from"./scroll-area-jPn2piF2.js";import{m as ps}from"./profanity-BnD4puAE.js";import{L as Xn}from"./lock-CuvaUibU.js";import{S as gs}from"./smile-B5NiXVsr.js";import{S as ws}from"./send-5fEvA9uK.js";import{C as xs,a as vs}from"./CountdownPrizeFX-jG0ePDZi.js";import{A as bs}from"./AddToPlaylist-BRXGj8FC.js";import{g as ys}from"./weeklyChartCache-D9qXuwSD.js";import{U as _s}from"./user-check-BoNIGVY_.js";import"./flame-CkEs7oM1.js";import"./index-D8eoOd04.js";import"./index-BdQq_4o_.js";import"./list-plus-vfxGGyE8.js";import"./plus-CSvhjgmi.js";const ks=/^\[\[re:([^|\]]{1,40})\|([^\]]{0,120})\]\]\s*/,Ss=50;function or(w,S=Ss){const M=(w||"").replace(/\[\[re:[^\]]*\]\]\s*/g,"").replace(/\s+/g," ").trim();return M.length<=S?M:M.slice(0,S).trimEnd()+"â¦"}function js(w,S){const M=(w||"").replace(/[|\]\[]/g,"").slice(0,40),D=or(S).replace(/[\]\[]/g,"");return`[[re:${M}|${D}]] `}function ir(w){const S=ks.exec(w||"");return S?{reply:{quotedUser:S[1],quotedText:S[2]},body:(w||"").slice(S[0].length)}:{reply:null,body:w||""}}function Ns(w){const{reply:S,body:M}=ir(w);return S?`(replying to ${S.quotedUser}: "${S.quotedText}") ${M}`.trim():w||""}const Qn=50,Rs=9;function Es({className:w}){return e.jsxs("svg",{viewBox:"0 0 24 24","aria-hidden":"true",className:w,fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("path",{d:"M20 5v2.5c0 4.15-3.35 7.5-7.5 7.5H4.75"}),e.jsx("path",{d:"M9 10.75 4.75 15 9 19.25"})]})}function Cs({onUsernameTap:w,channelId:S="podcast-chat-live",streamMode:M=!1}){const[D,H]=n.useState([]),[A,O]=n.useState(!0),[P,X]=n.useState(!1),$=n.useRef(!0),_e=n.useRef(null),xe=n.useRef(!0),Re=C=>{H(U=>U.some(se=>se.id===C.id)?U:[...U,C].slice(-Qn)),xe.current||X(!0)},ke=n.useCallback((C="smooth")=>{const U=_e.current;U&&(U.scrollTo({top:U.scrollHeight,behavior:C}),X(!1))},[]),Ee=n.useCallback(()=>{const C=_e.current;if(!C)return;const U=C.scrollHeight-C.scrollTop-C.clientHeight<48;xe.current=U,O(U),U&&X(!1)},[]);return n.useEffect(()=>{(async()=>{const{data:U}=await I.from("podcast_messages").select("id, username, message, created_at, source").order("created_at",{ascending:!1}).limit(Qn);U&&U.length>0&&H(U.reverse())})(),requestAnimationFrame(()=>{$.current=!1})},[]),n.useEffect(()=>{if(!xe.current)return;const C=_e.current;C&&(C.scrollTop=C.scrollHeight)},[D]),n.useEffect(()=>{const C=I.channel(`podcast-chat-${Math.random().toString(36).slice(2,8)}`).on("postgres_changes",{event:"INSERT",schema:"public",table:"podcast_messages"},se=>{Re(se.new)}).subscribe(),U=se=>{const V=se.detail;V&&(Re(V),xe.current=!0,O(!0),requestAnimationFrame(()=>ke("smooth")))};return window.addEventListener("podcast-chat-local",U),()=>{I.removeChannel(C),window.removeEventListener("podcast-chat-local",U)}},[S,ke]),e.jsxs("div",{className:"absolute inset-0 min-h-0",children:[e.jsx("div",{ref:_e,onScroll:Ee,className:`h-full min-h-0 px-2 pb-1 ${M?"overflow-hidden":"overflow-y-auto overscroll-contain touch-pan-y"}`,style:{maskImage:"linear-gradient(to bottom, transparent 0%, black 6%)",WebkitMaskImage:"linear-gradient(to bottom, transparent 0%, black 6%)",WebkitOverflowScrolling:"touch"},children:e.jsx("div",{className:"min-h-full flex flex-col justify-end",children:e.jsx(qe,{initial:!1,children:(M?D.slice(-Rs):D).map(C=>{const U=C.source==="instagram"?C.username.replace(/^ig:/,""):C.source==="youtube"?C.username.replace(/^yt:/,""):C.username,{reply:se,body:V}=ir(C.message),pe=(()=>{try{return new Intl.DateTimeFormat(void 0,{hour:"2-digit",minute:"2-digit"}).format(new Date(C.created_at))}catch{return""}})();return e.jsxs(he.div,{layout:!0,initial:$.current?!1:{opacity:0,y:20}
2,animate:{opacity:1,y:0},transition:{type:"spring",stiffness:500,damping:40,mass:.8},className:`group px-2 py-0.5 shrink-0 ${M?"max-w-[95%]":"max-w-[80%]"}`,children:[se&&e.jsxs("div",{className:"flex items-start gap-1.5 pl-0.5 mb-0.5",children:[e.jsx("span",{className:"mt-[3px] w-[2px] self-stretch rounded-full bg-cyan-400/40"}),e.jsxs("span",{className:"text-[10.5px] leading-snug text-white/45 truncate drop-shadow-[0_1px_2px_rgba(0,0,0,0.8)]",children:[e.jsx("span",{className:"text-cyan-400/70 font-semibold",children:se.quotedUser}),se.quotedText?`: ${se.quotedText}`:""]})]}),e.jsxs("div",{className:"leading-snug",children:[C.source==="instagram"&&e.jsx("span",{className:"mr-1 text-[11px]",title:"From Instagram Live","aria-label":"Instagram",children:"ð·"}),C.source==="youtube"&&e.jsx("span",{className:"inline-flex align-middle mr-1 text-red-500/90",title:"From YouTube Live","aria-label":"YouTube",children:e.jsx(Tr,{className:"w-3.5 h-3.5"})}),e.jsx("span",{className:`text-cyan-400 font-bold ${M?"text-[15px]":"text-[12px]"} mr-1.5 drop-shadow-[0_1px_3px_rgba(0,0,0,0.8)]`,children:U}),e.jsx("span",{className:`text-white/90 ${M?"text-[15px]":"text-[12px]"} drop-shadow-[0_1px_3px_rgba(0,0,0,0.8)] select-text [-webkit-user-select:text]`,children:V.split(/(@\[[^\]]+\]|https?:\/\/[^\s]+|www\.[^\s]+)/g).map((Q,oe)=>{if(/^@\[.+\]$/.test(Q))return e.jsxs("span",{className:"text-pink-400 font-semibold",children:["@",Q.slice(2,-1)]},oe);if(/^(https?:\/\/|www\.)/.test(Q)){const ie=Q.startsWith("http")?Q:`https://${Q}`;return e.jsx("a",{href:ie,target:"_blank",rel:"noopener noreferrer nofollow ugc",className:"text-cyan-300 underline underline-offset-2 hover:text-cyan-200 break-all",children:Q},oe)}return Q})}),!M&&e.jsx("button",{type:"button",onClick:()=>w==null?void 0:w(U,V),className:"inline-flex align-middle ml-1 text-cyan-400/40 hover:text-cyan-400 transition-colors","aria-label":`Reply to ${U}`,children:e.jsx(Es,{className:"w-3.5 h-3.5"})})]}),e.jsx("div",{className:"flex items-center gap-2 pl-0.5 leading-none -mt-0.5",children:pe&&e.jsx("span",{className:"text-[10px] text-white/40 drop-shadow-[0_1px_2px_rgba(0,0,0,0.8)]",children:pe})})]},C.id)})})})}),!A&&!M&&e.jsxs("button",{type:"button",onClick:()=>ke("smooth"),className:"absolute bottom-2 left-1/2 -translate-x-1/2 inline-flex items-center gap-1.5 rounded-full bg-black/70 backdrop-blur border border-cyan-400/30 px-3 py-1 text-[11px] font-semibold text-cyan-300 shadow-lg",children:[e.jsx(fs,{className:"w-3 h-3"}),P?"New messages":"Jump to latest"]})]})}const er=200,Is=[{label:"Smileys",items:["ð","ð","ð","ð","ð","ð
","ð¤£","ð","ð","ð","ð","ð","ð¥°","ð","ð¤©","ð","ð","ð","ð","ð","ð","ð","ð","ð¤ª","ð¤¨","ð§","ð¤","ð","ð¥¸","ð¤","ð¤","ð¤«","ð¤","ð","ð¶","ð","ð","ð","ð¬","ð®","ð¯","ð²","ð¥±","ð´","ð¤¤","ðª","ðµ","ð¤","ð¥´","ð¤¢","ð¤®","ð¤§","ð·","ð¤","ð¤","ð¥³","ð¥º","ð¢","ð","ð±","ð¨","ð°","ð¥","ð","ð¤"]},{label:"Hearts & sparkles",items:["â¤ï¸","ð§¡","ð","ð","ð","ð","ð¤","ð¤","ð¤","ð","ð","ð","ð","ð","ð","ð","ð","â£ï¸","ð","â¨","ð«","â","ð","ð ","ð¥","â¡","ð¥","ð","âï¸","ð"]},{label:"Hands & people",items:["ð","ð","ð","ð¤","ð","ð¤²","ð","ð¤","â","ðï¸","ð","ð","ð¤","ð¤","âï¸","ð¤","ð«°","ð¤","ð¤","ð¤","ð","ð","ð","ð","ð","ð","â","ð","ð«¶","ðª","ðº","ð","ð§","ð¶","ð"]},{label:"Music",items:["ðµ","ð¶","ð¼","ð¤","ð§","ð¸","ð¹","ð¥","ð·","ðº","ðª","ð»","ðª","ð»","ð","ð","ðï¸","ðï¸","ð","ð¿"]},{label:"Vibes & party",items:["ð¥","ð¯","â¡","ð","ð¥","ð","ð","ð¥","ð¾","ð»","ð¸","ð¹","ðª©","ð","ð","ð¥","ð¥","ð¥","ð¯","ð²"]},{label:"Faces & reactions",items:["ð","â ï¸","ð","ðï¸","ð¤¯","ð«¨","ð±","ð¤¤","ð¥º","ð","ð¿","ð»","ð¤","ð½","ð©","ð¤¡","ð","ð","ð"]},{label:"Animals & nature",items:["ð","ð¦","ð¦","ð","ð¶","ð±","ð¦","ð¯","ð¸","ðµ","ð§","ð¦
","ð¦","ð¢","ð¬","ð¹","ð»","ð¸","ð·","ðº","ðµ","ð","ð´","ð²"]}];function Ms({onLoginRequired:w,onTopicSubmit:S,onReplyRef:M}){const{user:D}=sr(),{toast:H}=ar(),[A,O]=n.useState(""),[P,X]=n.useState(null),[$,_e]=n.useState(0),[xe,Re]=n.useState(!1),[ke,Ee]=n.useState(null),[C,U]=n.useState(null),[se,V]=n.useState(-1),[pe,Q]=n.useState([]),[oe,ie]=n.useState(0),[pt,G]=n.useState(!1),[je,le]=n.useState(!1),We=n.useRef(null),F=n.useRef(null);n.useEffect(()=>{D&&I.from("profiles").select("username").eq("user_id",D.id).maybeSingle().then(({data:j})=>{j&&X(j.username)})},[D]),n.useEffect(()=>(M&&(M.current=(j,E)=>{Ee({username:j,snippet:or(E||"")}),setTimeout(()=>{var z;return(z=We.current)==null?void 0:z.focus()},0)}),()=>{M&&(M.current=null)}),[M]),n.useEffect(()=>{if(!D)return;(async()=>{const z=await Ft("live_banned_users");if(z){const L=(z==null?void 0:z.user_ids)??[];Re(L.includes(D.id))}})();const E=I.channel("chat-ban-check").on("postgres_changes",{event:"*",schema:"public",table:"site_settings",filter:"key=eq.live_banned_users"},z=>{var N,W;const L=((W=(N=z.new)==null?void 0:N.value)==null?void 0:W.user_ids)??[];Re(L.includes(D.id))}).subscribe();return()=>{I.removeChannel(E)}},[D]),n.useEffect(()=>{if(C===null||C.length<1){Q([]),G(!1);return}const j=setTimeout(async()=>{const E=[],z=new Date(Date.now()-72e5).toISOString(),[{data:L},{data:N}]=await Promise.all([I.from("podcast_messages").select("username").ilike("username",`${C}%`).gte("created_at",z).order("created_at",{ascending:!1}).limit(20),I.from("profiles").select("username").ilike("username",`${C}%`).limit(10)]),W=new Set;if(L){for(const J of L)if(J.username!==P&&!W.has(J.username)&&(W.add(J.username),E.push({label:J.username})),E.length>=8)break}if(N){for(const J of N)if(J.username&&J.username!==P&&!W.has(J.username)&&(W.add(J.username),E.push({label:J.username})),E.length>=8)break}Q(E),G(E.length>0),ie(0)},150);return()=>clearTimeout(j)},[C,P]);const st=j=>{const E=j.target.value;O(E);const z=j.target.selectionStart??E.length,L=E.slice(0,z),N=L.lastIndexOf("@");if(N>=0&&((N>0?E[N-1]:" ")===" "||N===0)){const J=L.slice(N+1);if(!J.includes("]")){U(J),V(N);return}}U(null),V(-1),G(!1)},at=n.useCallback(j=>{const E=A.slice(0,se),z=A.slice(se+1+((C==null?void 0:C.length)||0)),L=`${E}@[${j.label}]${z} `;O(L),G(!1),U(null),V(-1),setTimeout(()=>{var N;return(N=We.current)==null?void 0:N.focus()},0)},[A,se,C]),Ot=j=>{const E=We.current;if(!E){O(W=>(W+j).slice(0,er));return}const z=E.selectionStart??A.length,L=E.selectionEnd??A.length,N=(A.slice(0,z)+j+A.slice(L)).slice(0,er);O(N),U(null),V(-1),G(!1),requestAnimationFrame(()=>{E.focus();const W=Math.min(z+j.length,N.length);try{E.setSelectionRange(W,W)}catch{}})},Ut=j=>{!pt||pe.length===0||(j.key==="ArrowDown"?(j.preventDefault(),ie(E=>(E+1)%pe.length)):j.key==="ArrowUp"?(j.preventDefault(),ie(E=>(E-1+pe.length)%pe.length)):j.key==="Enter"||j.key==="Tab"?(j.preventDefault(),at(pe[oe])):j.key==="Escape"&&G(!1))},Ce=async j=>{if(j.preventDefault(),pt)return;const E=A.trim();if(!E)return;if(!D){w();return}const z=ps(E);if(z.blocked){_e(gt=>gt+1);const Ge=$+1;H({title:"â ï¸ Message blocked",description:({profanity:"Your message contains inappropriate language.",sexual:"Sexually explicit content is not allowed.",political:"Political topics are not allowed on Channel Sone.",religious:"Religious topics are not allowed on Channel Sone.",hateful:"Hateful or harassing content is not tolerated."}[z.category]||"Your message was blocked.")+(Ge>=3?" Further violations may result in a ban.":" Continued violations may result in a ban."),variant:"destructive"});return}if(E.startsWith("/topic ")&&S){const Ge=E.slice(7).trim();Ge&&(S(Ge,P||"Anonymous"),O(""));return}const L=E,N=ke,W=N?`${js(N.username,N.snippet)}@[${N.username}] ${L}`:L;O(""),Ee(null);const{data:J,error:Ve}=await I.from("podcast_messages").insert({user_id:D.id,username:P||"Anonymous",message:W}).select("id, username, message, created_at, source").single();Ve?(O(L),Ee(N),H({title:"Failed to send",description:Ve.message,variant:"destructive"})):J&&window.dispatchEvent(new CustomEvent("podcast-chat-local",{detail:J}))};return D?xe?e.jsxs("div",{className:"flex items-center justify-center gap-2 w-full py-3 text-red-400/60 text-sm",children:[e.jsx(Xn,{className:"w-3.5 h-3.5"}),"You have been suspended from chat for this session"]}):e.jsxs("div",{className:"max-w-xl mx-auto",children:[ke&&e.jsxs("div",{className:"flex items-center gap-2 mb-1.5 rounded-lg bg-white/5 border border-cyan-400/20 px-2.5 py-1.5",children:[e.jsx("span",{className:"w-[2px] self-stretch rounded-full bg-cyan-400/50"}),e.jsxs("span",{className:"flex-1 min-w-0 text-[11px] text-white/60 truncate",children:["Replying to ",e.jsx("span",{className:"text-cyan-400 font-semibold",children:ke.username}),ke.snippet?`: ${ke.snippet}`:""]}),e.jsx("button",{type:"button",onClick:()=>Ee(null),className:"text-white/40 hover:text-white transition-colors","aria-label":"Cancel reply",children:e.jsx(Ar,{className:"w-3.5 h-3.5"})})]}),e.jsxs("form",{onSubmit:Ce,className:"flex gap-3 relative",children:[e.jsxs("div",{className:"relative flex-1",children:[e.jsx(ms,{ref:We,value:A,onChange:st,onKeyDown:Ut,placeholder:S?"Chat or /topic...":"Say something...",maxLength:200,autoComplete:"off",className:"bg-white/5 border-white/10 text-white placeholder:text-white/30 focus-visible:ring-cyan-400/30"}),pt&&pe.length>0&&e.jsx("div",{ref:F,className:"absolute bottom-full left-0 right-0 mb-1 bg-background/95 backdrop-blur-md border border-border rounded-lg overflow-hidden shadow-lg z-50",children:e.jsxs(hs,{className:"max-h-[260px]",children:[e.jsxs("div",{className:"px-3 py-1.5 text-[10px] uppercase tracking-wider text-muted-foreground font-semibold flex items-center gap-1.5",children:[e.jsx(Dr,{className:"w-3 h-3"})," Users"]}),pe.map((j,E)=>{var z;return e.jsxs("button",{type:"button",onMouseDown:L=>{L.preventDefault(),at(j)},className:`w-full flex items-center gap-2 px-3 py-2 text-sm text-left transition-colors ${E===oe?"bg-primary/20 text-primary":"text-foreground hover:bg-muted/50"}`,children:[e.jsx("div",{className:"w-5 h-5 rounded-full bg-muted flex items-center justify-center text-[10px] font-bold text-muted-foreground",children:(z=j.label[0])==null?void 0:z.toUpperCase()}),e.jsxs("span",{className:"font-medium truncate",children:["@",j.label]})]},`user-${j.label}`)})]})})]}),e.jsxs(Pr,{open:je,onOpenChange:le,children:[e.jsx($r,{asChild:!0,children:e.jsx(Kn,{type:"button",variant:"ghost",className:"px-2 text-white/50 hover:text-white hover:bg-white/5","aria-label":"Add emoji",children:e.jsx(gs,{className:"w-5 h-5"})})}),e.jsx(Fr,{side:"top",align:"end",className:"w-72 p-2 bg-background/95 backdrop-blur-md border-white/10 max-h-80 overflow-y-auto",onOpenAutoFocus:j=>j.preventDefault(),onCloseAutoFocus:j=>j.preventDefault(),children:Is.map(j=>e.jsxs("div",{className:"mb-2 last:mb-0",children:[e.jsx("div",{className:"text-[10px] uppercase tracking-wider text-muted-foreground
2/70 px-1 mb-1",children:j.label}),e.jsx("div",{className:"grid grid-cols-9 gap-0.5",children:j.items.map((E,z)=>e.jsx("button",{type:"button",onClick:()=>{Ot(E)},className:"text-lg leading-none p-1.5 rounded hover:bg-white/10 transition-colors",children:E},`${j.label}-${z}`))})]},j.label))})]}),e.jsx(Kn,{type:"submit",disabled:!A.trim(),className:"bg-cyan-400 text-black hover:bg-cyan-300 disabled:opacity-30",children:e.jsx(ws,{className:"w-4 h-4"})})]})]}):e.jsxs("button",{onClick:w,className:"flex items-center justify-center gap-2 w-full py-3 text-white/40 text-sm hover:text-white/60 transition-colors",children:[e.jsx(Xn,{className:"w-3.5 h-3.5"}),"Log in to comment"]})}const Ls=w=>w===null?"NEW ENTRY":w>0?`â²${w}`:w<0?`â¼${Math.abs(w)}`:"=",Ts=({isNew:w,chart:S})=>!w&&!S?null:e.jsx("div",{className:"absolute top-2 right-2 z-10 flex flex-col gap-1.5 items-end pointer-events-none",children:e.jsxs(qe,{children:[w&&e.jsx(he.div,{initial:{opacity:0,scale:.7,x:20},animate:{opacity:1,scale:1,x:0},exit:{opacity:0,scale:.7},transition:{type:"spring",damping:18,stiffness:320},className:"px-2.5 py-1 rounded-full backdrop-blur-md border border-neon-pink/60 bg-[hsla(var(--accent-surface-pink))] shadow-lg",style:{boxShadow:"0 0 20px hsl(var(--neon-pink) / 0.5)"},children:e.jsx("span",{className:"text-[10px] font-mono font-bold uppercase tracking-widest text-neon-pink animate-pulse",children:"New!"})},"new-badge"),S&&e.jsxs(he.div,{initial:{opacity:0,scale:.7,x:20},animate:{opacity:1,scale:1,x:0},exit:{opacity:0,scale:.7},transition:{type:"spring",damping:18,stiffness:320,delay:.05},className:"px-2.5 py-1 rounded-full backdrop-blur-md border border-neon-green/60 bg-[hsla(var(--accent-surface-green))] shadow-lg flex flex-col items-center",style:{boxShadow:"0 0 20px hsl(var(--neon-green) / 0.5)"},children:[e.jsxs("span",{className:"text-[10px] font-mono font-bold uppercase tracking-widest text-neon-green leading-tight",children:["Chart #",S.rank]}),e.jsx("span",{className:"text-[8px] font-mono text-neon-green/80 leading-tight mt-0.5",children:Ls(S.movement)})]},`chart-${S.rank}`)]})}),tr="/assets/sone-logo-live-DQt445uO.png",As=1,Ds="ff21e51f-dcab-4206-8a23-0096624071aa",Ps="b7a606ca-04f2-4727-8b3d-dcd2802133b3",$s="/__l5e/assets-v1/ff21e51f-dcab-4206-8a23-0096624071aa/jake-gemma-off-air.png",Fs="a/v1/b7a606ca-04f2-4727-8b3d-dcd2802133b3/ff21e51f-dcab-4206-8a23-0096624071aa/jake-gemma-off-air.png",Os="jake-gemma-off-air.png",Us=1305755,Bs="image/png",zs="2026-07-26T13:19:24Z",Hs={version:As,asset_id:Ds,project_id:Ps,url:$s,r2_key:Fs,original_filename:Os,size:Us,content_type:Bs,created_at:zs},hn=({src:w,poster:S,className:M,style:D})=>{const H=n.useRef(null);return n.useEffect(()=>{const A=H.current;if(!A)return;A.muted=!0,A.defaultMuted=!0,A.volume=0;const O=()=>{const P=A.play();P&&typeof P.catch=="function"&&P.catch(()=>{})};return O(),A.addEventListener("loadeddata",O),document.addEventListener("visibilitychange",O),()=>{A.removeEventListener("loadeddata",O),document.removeEventListener("visibilitychange",O)}},[w]),e.jsx("video",{ref:H,src:w,poster:S,autoPlay:!0,loop:!0,muted:!0,playsInline:!0,preload:"auto",disablePictureInPicture:!0,className:M,style:D})};function qs(w){const S=n.useRef(null),M=n.useRef(null);n.useEffect(()=>{if(!w)return;const D=()=>{if(!S.current)try{const O=window.AudioContext||window.webkitAudioContext;if(!O)return;const P=new O,X=P.createGain();
2X.gain.value=.001,X.connect(P.destination);const $=P.createOscillator();$.frequency.value=1,$.connect(X),$.start(),S.current=P,M.current=$}catch{}};D();const H=()=>{var O;document.visibilityState==="visible"&&((O=S.current)==null?void 0:O.state)==="suspended"&&S.current.resume().catch(()=>{}),S.current||D()},A=()=>D();return document.addEventListener("visibilitychange",H),window.addEventListener("touchstart",A,{once:!0,passive:!0}),window.addEventListener("click",A,{once:!0}),()=>{var O,P;document.removeEventListener("visibilitychange",H),window.removeEventListener("touchstart",A),window.removeEventListener("click",A);try{(O=M.current)==null||O.stop()}catch{}try{(P=S.current)==null||P.close()}catch{}M.current=null,S.current=null}},[w])}const Ws=Hs.url,pn=cs.url,gn=ls.url,nr=new Map,wn=new Map;function xn(w){if(!w)return null;const S=nr.get(w);if(S)return Promise.resolve(S);const M=wn.get(w);if(M)return M;const D=fetch(w,{cache:"force-cache",credentials:"omit",mode:"cors"}).then(async H=>{if(!H.ok)throw new Error(`countdown_clip_${H.status}`);return await H.arrayBuffer(),nr.set(w,w),w}).catch(()=>w).finally(()=>wn.delete(w));return wn.set(w,D),D}function rr(w,S,M=new Date){if(w=(w??[]).filter(A=>A&&A.enabled!==!1),!(w!=null&&w.length))return[];const D=[],H=Date.UTC(M.getUTCFullYear(),M.getUTCMonth(),M.getUTCDate());for(const A of w){const[O,P]=(A.start_time||"08:00").split(":").map(Number);for(let X=0;X<2;X++){const $=new Date(H+X*864e5);$.setUTCHours(O||0,P||0,0,0),$>M&&D.push({when:$,slot:A})}}return D.sort((A,O)=>A.when.getTime()-O.when.getTime()).slice(0,S)}function ma(){var Wn,Vn,Gn;const{toast:w}=ar(),[S]=Or(),M=S.get("stream")==="1",D=Ur(),{user:H}=sr(),{isLiked:A,toggleLike:O}=Br(),[P,X]=n.useState(null),[$,_e]=n.useState(!0),[xe,Re]=n.useState(!1),[ke,Ee]=n.useState(!1),[C,U]=n.useState(null),se=n.useRef(!1),[V,pe]=n.useState([]),Q=n.useRef(null);zr(),qs(P===!0);const oe=n.useRef(1),{rows:ie,seed:pt,pickAt:G,pickOverlayAt:je,refresh:le,version:We}=ss(P===!0),[F,st]=n.useState(!1),at=as({enabled:F,pickAt:G,getDefaultVolume:()=>oe.current}),{registerMusicA:Ot,registerMusicB:Ut,getMusicEls:Ce,applyTrackSource:j,correctDrift:E,clearPreload:z}=at,L=at.musicRef,N=n.useRef(null),W=n.useRef(null);n.useRef(null),n.useRef(null),n.useRef(null);const J=n.useRef(null);n.useRef(!1);const[Ve,Ge]=n.useState(1),[ue,gt]=n.useState(!1);n.useEffect(()=>{oe.current=ue?0:Ve},[Ve,ue]);const cr=n.useCallback(t=>{const a=Math.max(0,Math.min(1,t)),r=oe.current,s=L.current;if(s){const o=r>0?Math.min(1,s.volume/r):1;try{s.volume=Math.max(0,Math.min(1,o*a))}catch{}}if(N.current)try{N.current.volume=a}catch{}if(ge.current)try{ge.current.volume=.55*a}catch{}if(Oe.current)try{Oe.current.volume=.14*a}catch{}Ge(a),a>0&>(!1)},[]),lr=n.useCallback(()=>gt(t=>!t),[]);n.useEffect(()=>{for(const t of[...Ce(),N.current,ge.current,Oe.current])if(t)try{t.muted=ue}catch{}},[ue,Ce]);const[u,wt]=n.useState(null),ot=n.useRef(null),[vn,bn]=n.useState(!1),[ur,dr]=n.useState(new Map),[q,Bt]=n.useState(!1),[fr,yn]=n.useState(new Map),[Je,it]=n.useState(null),zt=n.useRef(new Map),Ht=n.useRef(new Map),[ve,qt]=n.useState(null),[mr,Ue]=n.useState("waiting for clock"),[hr,pr]=n.useState(null),de=n.useRef(-1),Pe=n.useRef(0),gr=n.useRef(0),ae=n.useRef(null),re=n.useRef(null),be=n.useRef(!1),ce=n.useRef(!1),ge=n.useRef(null),[wr,xr]=n.useState(0),K=n.useRef(null),_n=n.useRef(null),kn=n.useRef(new Map),Sn=n.useRef(new Map),jn=n.useRef(new Map),B=n.useRef(null),Ke=n.useRef(0),$e=n.useRef(0),Be=n.useRef({id:null,count:0}),Nn=n.useRef(0),fe=n.useRef(new Set),xt=n.useRef(!1),[Wt,vt]=n.useState(!1),[Rn,En]=n.useState(!1),Vt=n.useRef(null),Ye=n.useRef(null),Cn=n.useRef(0),bt=n.useRef(0),yt=n.useRef({time:-1,since:0}),Gt=n.useRef(0),ct=n.useRef(0),lt=n.useRef(!1),[ut,vr]=n.useState({paused:!0,vol:1,ready:0,rowId:null,fixes:0}),ze=n.useRef(null),[Jt,Kt]=n.useState(null),[Yt,Zt]=n.useState(null),[In,_t]=n.useState(!1),He=n.useRef(!1),[br,kt]=n.useState(!1),St=n.useRef(null),[jt,Nt]=n.useState(!1),Xt=n.useRef(new Map),Mn=n.useRef(new Map),Rt=n.useRef(new Map),Et=n.useRef((()=>{try{const t=sessionStorage.getItem("sone_live_session_id");if(t)return t;const a=crypto.randomUUID();return sessionStorage.setItem("sone_live_session_id",a),a}catch{return crypto.randomUUID()}})()),Ze=n.useRef(new Set),Qt=n.useRef(0),en=n.useRef(0),[Ie,Ct]=n.useState(null),[yr,It]=n.useState(!1),Ln=n.useRef(0);n.useEffect(()=>{let t=!1;const a=async()=>{try{const s=Date.now(),o=await fetch(window.location.origin+"/",{method:"HEAD",cache:"no-store"}),i=Date.now(),d=o.headers.get("date");if(!d||t)return;const c=new Date(d).getTime();if(!Number.isFinite(c))return;const f=i-s;Ln.current=c+Math.floor(f/2)-i}catch{}};a();const r=setInterval(a,5*6e4);return()=>{t=!0,clearInterval(r)}},[]);const Me=n.useRef([]);n.useEffect(()=>{Me.current=ie},[ie]),n.useEffect(()=>{He.current=In},[In]),n.useEffect(()=>{ot.current=u},[u]),n.useEffect(()=>{bn(!1)},[u==null?void 0:u.audio_url]),n.useEffect(()=>{se.current=xe},[xe]),n.useEffect(()=>{const t=()=>{if(!P||V.length===0){Q.current=null;return}const r=new Date,s=r.getUTCHours()*60+r.getUTCMinutes(),o=V.find(f=>{const[y,g]=(f.start_time||"08:00").split(":").map(Number),m=(y||0)*60+(g||0),h=Math.round(Number(f.duration_hours||0)*60);return s>=m&&s<=m+h});if(!o){Q.current=null;return}const[i,d]=(o.start_time||"08:00").split(":").map(Number),c=new Date(Date.UTC(r.getUTCFullYear(),r.getUTCMonth(),r.getUTCDate(),i||0,d||0,0));Q.current=c.getTime()+Number(o.duration_hours)*36e5};t();const a=setInterval(t,6e4);return()=>clearInterval(a)},[P,V]),n.useEffect(()=>{if(!P)return;let t=!1,a=0;const r=()=>{const s=Q.current,o=L.current;if(s&&o&&!t){const i=s-Date.now();if(i<=2e3&&i>-500){t=!0;const d=o.volume,c=Date.now(),f=Math.max(500,Math.min(2e3,i)),y=setInterval(()=>{const g=Math.min(1,(Date.now()-c)/f);try{o.volume=Math.max(0,d*(1-g))}catch{}g>=1&&clearInterval(y)},50)}}a=window.setTimeout(r,250)};return r(),()=>{a&&clearTimeout(a)}},[P]),n.useEffect(()=>{if(P||V.length===0){Ct(null),It(!1);return}const t=9e4,a=o=>{const i=new Date(o-t);let d=null;for(const c of V){if((c==null?void 0:c.enabled)===!1)continue;const f=Yn(c.start_time||"08:00",void 0,i);(!d||f<d)&&(d=f)}return d},r=()=>{const o=Date.now()+Ln.current,i=a(o);if(!i){Ct(null),It(!1);return}const d=i.getTime()-o;if(d<=0){Ct(null),It(!0);return}const c=Math.floor(d/1e3);It(!1),Ct({days:Math.floor(c/86400),hours:Math.floor(c%86400/3600),minutes:Math.floor(c%3600/60),seconds:c%60})};r();const s=setInterval(r,1e3);return()=>clearInterval(s)},[P,V]),n.useEffect(()=>{let t=!1;(async()=>{var s;const{data:r}=await I.from("podcast_messages").select("created_at").order("created_at",{ascending:!1}).limit(1);!t&&((s=r==null?void 0:r[0])!=null&&s.created_at)&&(Qt.current=ne
2w Date(r[0].created_at).getTime())})();const a=Zn("live-broadcast",{event:"INSERT",schema:"public",table:"podcast_messages"},r=>{const s=r.new,o=((s==null?void 0:s.username)??"").toString().trim(),i=((s==null?void 0:s.message)??"").toString().trim();!o||!i||o.startsWith("ð¢")||(Qt.current=s.created_at?new Date(s.created_at).getTime():Date.now())});return()=>{t=!0,a()}},[]),n.useEffect(()=>{if(u&&F){const t=u.artist||"Unknown";document.title=`${u.title}, ${t} | Channel Sone`}else document.title="Channel Soneâ | Sone.fm";return()=>{document.title="Sone.fm â Real artists. AI music."}},[u==null?void 0:u.title,u==null?void 0:u.artist,F]),n.useEffect(()=>{if(!F)return;const t=32,a=document.createElement("canvas");a.width=t,a.height=t;const r=a.getContext("2d"),s=document.querySelector('link[rel="icon"]');if(!s)return;const o=s.href,i=new Image;i.crossOrigin="anonymous",i.src="/favicon.png";let d,c=null;const f=y=>{c||(c=y);const g=(y-c)%2e3/2e3,m=.2+.8*(.5+.5*Math.sin(g*Math.PI*2));r.clearRect(0,0,t,t),r.save(),r.shadowColor="hsl(300, 100%, 50%)",r.shadowBlur=12*m,r.drawImage(i,2,2,t-4,t-4),r.shadowBlur=8*m,r.drawImage(i,2,2,t-4,t-4),r.restore(),r.drawImage(i,2,2,t-4,t-4),s.href=a.toDataURL("image/png"),d=requestAnimationFrame(f)};return i.onload=()=>{d=requestAnimationFrame(f)},()=>{cancelAnimationFrame(d),s&&(s.href=o)}},[F]),n.useEffect(()=>{if(!H||!(u!=null&&u.user_id)){Nt(!1);return}(async()=>{const{data:a}=await I.from("follows").select("id").eq("follower_id",H.id).eq("following_id",u.user_id).maybeSingle();Nt(!!a)})()},[H==null?void 0:H.id,u==null?void 0:u.user_id]);const _r=n.useCallback(async()=>{if(!H){kt(!0);return}if(!(u!=null&&u.user_id))return;const t=u.user_id;jt?(Nt(!1),await I.from("follows").delete().eq("follower_id",H.id).eq("following_id",t)):(Nt(!0),await I.from("follows").insert({follower_id:H.id,following_id:t}))},[H,u==null?void 0:u.user_id,jt]),[dt,kr]=n.useState(null);n.useEffect(()=>{(async()=>{var m,h,p;const i=await es(["live_station_enabled","live_hosts_enabled","live_schedule","live_winding_down","live_broadcast_starting","countdown_show"]),d=Object.entries(i).map(([b,x])=>({key:b,value:x}));let c=!0,f=!1,y=[];if(d)for(const b of d){if(b.key==="live_station_enabled"&&(c=((m=b.value)==null?void 0:m.enabled)??!0),b.key==="live_hosts_enabled"&&(f=((h=b.value)==null?void 0:h.enabled)===!0),b.key==="live_winding_down"){const x=b.value;Re((x==null?void 0:x.winding_down)===!0)}if(b.key==="live_broadcast_starting"&&Ee(((p=b.value)==null?void 0:p.starting)===!0),b.key==="countdown_show"){const x=b.value;kr((x==null?void 0:x.enabled)===!0?x:null)}if(b.key==="live_schedule"){const x=b.value;if(x!=null&&x.enabled){if(x!=null&&x.slots)pe(x.slots),y=x.slots;else if((x==null?void 0:x.day)!==void 0){const v=[{day:x.day,start_time:x.start_time??"08:00",duration_hours:x.duration_hours??2}];pe(v),y=v}}}}X(c);const{isWithinDailySlot:g}=await $t(async()=>{const{isWithinDailySlot:b}=await import("./index-ClvMDdP5.js").then(x=>x.cS);return{isWithinDailySlot:b}},__vite__mapDeps([0,1]));_e(f||g(y))})();const a=Zn("live-broadcast",{event:"UPDATE",schema:"public",table:"site_settings",filter:"key=in.(live_station_enabled,live_hosts_enabled,live_winding_down,live_broadcast_starting,live_fading_out)"},i=>{var c,f,y,g,m;const d=i.new;if(d.key==="live_winding_down"){const h=((c=d.value)==null?void 0:c.winding_down)===!0;if(Re(h),h){const p=V;p.length>0&&$t(async()=>{const{nextOccurrence:b,formatLocal:x,formatLondon:v,londonWeekday:T,activeDailySlots:R}=await import("./index-ClvMDdP5.js").then(k=>k.cS);return{nextOccurrence:b,formatLocal:x,formatLondon:v,londonWeekday:T,activeDailySlots:R}},__vite__mapDeps([0,1])).then(({nextOccurrence:b,formatLocal:x,formatLondon:v,londonWeekday:T,activeDailySlots:R})=>{const k=new Date,l=R(p).map(_=>b(_.start_time,void 0,k)).sort((_,ee)=>_.getTime()-ee.getTime())[0];l&&U(`${T(l)} at ${x(l)} (${v(l)})`)})}}if(d.key==="live_broadcast_starting"&&Ee(((f=d.value)==null?void 0:f.starting)===!0),d.key==="live_station_enabled"&&(((y=d.value)==null?void 0:y.enabled)??!0?(en.current=0,X(!0)):tn()),d.key==="live_hosts_enabled"){const h=((g=d.value)==null?void 0:g.enabled)===!0;$t(async()=>{const{isWithinDailySlot:p}=await import("./index-ClvMDdP5.js").then(b=>b.cS);return{isWithinDailySlot:p}},__vite__mapDeps([0,1])).then(({isWithinDailySlot:p})=>{_e(h||p(V))})}if(d.key==="live_fading_out"&&((m=d.value)==null?void 0:m.fading_out)===!0){_e(!1);
2const p=L.current,b=(p==null?void 0:p.volume)??1,x=Date.now(),v=5e3,T=setInterval(()=>{const R=Math.min(1,(Date.now()-x)/v),k=1-R;try{p&&(p.volume=Math.max(0,b*k))}catch{}R>=1&&clearInterval(T)},100)}});let r=!1;const o=setInterval(async()=>{if(r)return;const i=await Ft("live_hosts_enabled"),d=(i==null?void 0:i.enabled)===!0,{isWithinDailySlot:c}=await $t(async()=>{const{isWithinDailySlot:f}=await import("./index-ClvMDdP5.js").then(y=>y.cS);return{isWithinDailySlot:f}},__vite__mapDeps([0,1]));_e(d||c(V))},6e4);return()=>{r=!0,clearInterval(o),a()}},[V]);const tn=n.useCallback(async()=>{const t=async()=>{ts("live_station_enabled");const s=await Ft("live_station_enabled");return((s==null?void 0:s.enabled)??!0)===!1};if(!await t()){en.current=0,X(!0);return}if(await new Promise(s=>setTimeout(s,6e3)),!await t()){en.current=0,X(!0);return}for(const s of Ce())try{s.pause(),s.src=""}catch{}z(),N.current&&(N.current.pause(),N.current.src=""),I.rpc("podcast_listener_leave",{p_session_id:Et.current}),X(!1),st(!1),Re(!1),U(null),K.current=null,B.current=null,wt(null),console.log("[Podcast v3] Station confirmed OFF, playback stopped")},[]);Hr(F?"test":null);const{counts:Tn}=qr({ambient:!1});n.useEffect(()=>{xr(Tn.test??0)},[Tn]),n.useEffect(()=>{if(!F)return;const t=Et.current,a=async()=>{await I.rpc("podcast_listener_heartbeat",{p_session_id:t})};(async()=>{await I.rpc("log_live_visit",{p_session_id:t})})(),a();const s=setInterval(a,45e3);return()=>{clearInterval(s),I.rpc("podcast_listener_leave",{p_session_id:t})}},[F]),n.useEffect(()=>{if(!F)return;const a=Wr(async()=>{const r=await Ft("live_station_enabled");((r==null?void 0:r.enabled)??!0)||tn()},3e5);return()=>a()},[F,tn]),n.useEffect(()=>{const t=ie.filter(r=>r.kind==="track"&&r.track_id).map(r=>r.track_id);if(t.length===0)return;const a=t.filter(r=>!Xt.current.has(r));a.length!==0&&(async()=>{const{data:r}=await I.from("tracks").select("id, user_id, studio_version, created_at").in("id",a);r==null||r.forEach(d=>Sn.current.set(d.id,d.created_at??null));const s=[...new Set((r||[]).map(d=>
2d.user_id).filter(Boolean))];if(s.length===0)return;const{data:o}=await I.from("profiles").select("user_id, username, avatar_url").in("user_id",s),i=new Map;o==null||o.forEach(d=>i.set(d.user_id,{username:d.username,avatar_url:d.avatar_url})),r==null||r.forEach(d=>{if(kn.current.set(d.id,d.studio_version??null),d.user_id){Rt.current.set(d.id,d.user_id);const c=i.get(d.user_id);c&&(Xt.current.set(d.id,c.username),Mn.current.set(d.id,c.avatar_url))}})})()},[ie]),n.useEffect(()=>{if(!F||ie.length===0)return;const t=()=>{const r=Date.now(),s=ie.filter(o=>{const i=new Date(o.start_at).getTime();return o.kind==="track"&&i>r-2e3&&i<r+12e4&&!!o.audio_url}).slice(0,2);for(const o of s)ns(rs(o.audio_url));ie.filter(o=>{var i;return o.kind==="clip"&&((i=o.clip_metadata)==null?void 0:i.countdown)}).slice(0,8).forEach(o=>{xn(o.clip_audio_url||o.audio_url)})};t();const a=window.setInterval(t,1e4);return()=>window.clearInterval(a)},[F,ie]),n.useEffect(()=>{const t=u==null?void 0:u.id;if(!t||u!=null&&u.user_id)return;const a=Rt.current.get(t);if(a){wt(r=>r&&r.id===t?{...r,user_id:a}:r);return}(async()=>{const{data:r}=await I.from("tracks").select("user_id").eq("id",t).maybeSingle(),s=r==null?void 0:r.user_id;s&&(Rt.current.set(t,s),wt(o=>o&&o.id===t?{...o,user_id:s}:o))})()},[u==null?void 0:u.id,u==null?void 0:u.user_id]),n.useEffect(()=>{(async()=>{const a=await ys();if(a.length){const r=new Map;for(const s of a)r.set(s.track_id,{rank:Number(s.rank),movement:s.movement===null?null:Number(s.movement)});dr(r)}})()},[]);const Mt=n.useCallback(t=>{W.current&&clearInterval(W.current);const a=L.current;if(!a)return;const r=Math.max(0,Math.min(1,t))*oe.current,s=a.volume+(r-a.volume)*.5;try{a.volume=Math.max(0,Math.min(1,s))}catch{}W.current=setInterval(()=>{const o=r-a.volume;if(Math.abs(o)<.03){try{a.volume=r}catch{}W.current&&clearInterval(W.current),W.current=null;return}try{a.volume=Math.max(0,Math.min(1,a.volume+o*.35))}catch{}},40)},[]),Lt=n.useCallback(t=>{Mt(t?.15:.05)},[Mt]),Tt=n.useCallback(t=>{W.current&&(clearInterval(W.current),W.current=null);const a=(t?.12:.05)*oe.current;for(const r of Ce())try{r.volume=Math.max(0,Math.min(1,a))}catch{}},[Ce]),me=n.useCallback(()=>{Mt(1)},[Mt]),At=n.useCallback(()=>{J.current!==null&&(cancelAnimationFrame(J.current),J.current=null)},[]),An=n.useCallback(()=>{},[]),ne=n.useCallback(async(t,a)=>{var d,c;if(K.current===t.id)return;K.current=t.id,_n.current=t;const r=j(t,a);if(!r)return;const s=t.track_id&&Xt.current.get(t.track_id)||null,o=t.track_id&&Mn.current.get(t.track_id)||null,i={id:t.track_id||void 0,title:t.title||"Channel Sone",artist:t.artist,artwork_url:t.artwork_url,audio_url:t.audio_url,artistUsername:s,artistAvatarUrl:o,user_id:t.track_id&&Rt.current.get(t.track_id)||null,studio_version:t.track_id?kn.current.get(t.track_id)??null:null,created_at:t.track_id?Sn.current.get(t.track_id)??null:null};if(wt(i),ot.current=i,t.kind==="track"){const f=Number(((d=t.clip_metadata)==null?void 0:d.chart_position)??((c=t.clip_metadata)==null?void 0:c.position));pr(Number.isFinite(f)&&f>0?f:null)}try{r.muted=ue,await r.play()}catch(f){K.current===t.id&&(K.current=null),console.warn("[Podcast v3] music play failed:",f)}if("mediaSession"in navigator&&(navigator.mediaSession.metadata=new MediaMetadata({title:i.title,artist:i.artist||"Soné",album:"Channel Soné",artwork:i.artwork_url?[{src:i.artwork_url,sizes:"512x512",type:"image/jpeg"}]:[]}),navigator.mediaSession.playbackState="playing"),t.track_id){const f=t.track_id,y=Date.now(),g=jn.current.get(f)??0;y-g>=5*6e4&&(jn.current.set(f,y),(async()=>{var m;try{const{data:{session:h}}=await I.auth.getSession(),p=((m=h==null?void 0:h.user)==null?void 0:m.id)??null;I.rpc("increment_track_views",{p_track_id:f,p_user_id:p}).then(),p&&I.from("listen_history").insert({track_id:f,user_id:p,station_id:"test"}).then()}catch(h){console.warn("[Podcast v3] play count failed:",h)}})())}},[j,ue]),Fe=n.useCallback(async(t,a)=>{const r=N.current;if(!r||B.current===t.id)return;if(fe.current.has(t.id)){console.log(`[Podcast v3] refusing to (re)start overlay ${t.id.slice(0,8)}, already played this session`);return}if(xt.current&&t.style!=="broadcast_intro"&&t.style!=="announcement"){fe.current.add(t.id),console.warn(`[Podcast v3.1] dropped overlay ${t.id.slice(0,8)} (style=${t.style}), hosts already signed off`);return}if(t.style==="broadcast_intro"&&(xt.current=!1),t.style==="broadcast_outro"&&(xt.current=!0),B.current&&!r.ended){const c=Date.now()-Ke.current,f=$e.current>0&&c>$e.current+6e3;if(!(!r.currentSrc||!!r.error||f)){console.log(`[Podcast v3] refusing to start overlay ${t.id.slice(0,8)}, ${B.current.slice(0,8)} still active (paused=${r.paused}, t=${r.currentTime.toFixed(2)}/${r.duration.toFixed(2)})`);return}console.warn(`[Podcast v2.4] clearing zombie overlay ${B.current.slice(0,8)} (overdue=${f}, err=${!!r.error}), freeing the voice lane`),fe.current.add(B.current),B.current=null;try{r.pause()}catch{}}B.current=t.id,Ke.current=Date.now(),$e.current=Math.max(1,Number(t.duration_sec)||0)*1e3,Be.current.id!==t.id&&(Be.current={id:t.
2id,count:0});const i=!(Date.now()-Nn.current<1e4)||a<3.5,d=i?0:a;console.log(`[Podcast v3] overlay ${t.id.slice(0,8)} style=${t.style} offset=${a.toFixed(2)}s â seek=${d.toFixed(2)}s (fromStart=${i})`),Lt(!0),vt(!0),Kt((t.style||"").replace(/_/g," ")||null),Zt("Channel Sone");try{r.src=t.audio_url,r.load(),await new Promise(c=>{let f=!1;const y=()=>{f||(f=!0,g(),c())},g=()=>{r.removeEventListener("canplay",y),r.removeEventListener("loadeddata",y),r.removeEventListener("error",y)};r.addEventListener("canplay",y,{once:!0}),r.addEventListener("loadeddata",y,{once:!0}),r.addEventListener("error",y,{once:!0}),setTimeout(y,1500)});try{r.currentTime=d}catch{}await r.play(),An()}catch(c){console.warn("[Podcast v3] voice play failed:",c),vt(!1),At(),me(),B.current=null}},[Lt,me,An,At]),Ne=n.useCallback(()=>{const t=N.current;if(t)try{t.pause(),t.removeAttribute("src"),t.load()}catch{}B.current=null,Ke.current=0,$e.current=0,Be.current={id:null,count:0},vt(!1),Kt(null),Zt(null),At(),me()},[me,At]),Le=n.useRef(()=>{}),Xe=n.useCallback(()=>{const t=Date.now(),r=Me.current.filter(i=>{var d;return!((d=i.clip_metadata)!=null&&d.countdown)&&i.kind==="track"}).find(i=>new Date(i.start_at).getTime()+(Number(i.duration_sec)||0)*1e3>t+500);if(!r){le();return}const s=new Date(r.start_at).getTime(),o=s<=t?Math.max(0,(t-s)/1e3):0;K.current=null,ne(r,o),me()},[ne,me,le]),Dt=n.useCallback(()=>{var t,a,r;(t=ae.current)==null||t.call(ae),ae.current=null,(a=re.current)==null||a.call(re),re.current=null,de.current=-1,be.current=!0,ce.current=!0,Qe.current=!1,Bt(!1),qt(null),it(null),Ue("show complete · live");try{(r=ge.current)==null||r.pause()}catch{}ge.current=null,Xe()},[Xe]),Sr=n.useCallback((t,a=0,r=0)=>{var m,h,p,b,x,v,T,R;const s=Me.current.filter(k=>{var l;return(l=k.clip_metadata)==null?void 0:l.countdown}),o=s[t];if(!o){Dt();return}const i=++Pe.current;de.current=t,gr.current=r,be.current=!0,ce.current=!1,qt(o);try{(m=ge.current)==null||m.pause(),ge.current&&(ge.current.currentTime=0)}catch{}if(ge.current=null,s.slice(t,t+6).forEach(k=>{k.kind==="clip"&&xn(k.clip_audio_url||k.audio_url)}),o.kind==="track"){it(null),Ue(`idx ${t} · track no.${((h=o.clip_metadata)==null?void 0:h.chart_position)??"?"}`),K.current!==o.id&&(K.current=null,ne(o,a)),me();const k=L.current;if((p=re.current)==null||p.call(re),re.current=null,k){const l=()=>{var _;i!==Pe.current||de.current!==t||K.current!==o.id||L.current!==k||((_=re.current)==null||_.call(re),re.current=null,Le.current(t+1))};k.addEventListener("ended",l),re.current=()=>k.removeEventListener("ended",l)}return}const d=s[t+1];(d==null?void 0:d.kind)==="track"?(Tt(!0),K.current=null,ne(d,0).then(()=>Tt(!0))):Tt(!0);const c=((b=o.clip_metadata)==null?void 0:b.segment)==="award"?String(((x=o.clip_metadata)==null?void 0:x.award)??""):"",f=c?zt.current.get(c):null;if(it(f?{key:`${o.id}:${c}`,prize:f}:null),c){const k=Ht.current.get(c);if(k){try{(v=ge.current)==null||v.pause()}catch{}const l=new Audio(k);l.volume=.55*oe.current,l.muted=ue,ge.current=l,l.play().catch(()=>{})}}const y=o.clip_audio_url||o.audio_url,g=String(((T=o.clip_metadata)==null?void 0:T.segment)??"clip");(R=xn(y))==null||R.then(async k=>{var Y;if(i!==Pe.current||de.current!==t)return;const l=N.current;if(!l){Ue(`idx ${t} · ${g} · no voice element`);return}(Y=ae.current)==null||Y.call(ae),ae.current=null;const _=()=>i===Pe.current&&de.current===t&&B.current===o.id&&N.current===l,ee=()=>{l.removeEventListener("ended",Se),l.removeEventListener("error",De)},Se=()=>
2{_()&&(ee(),ae.current=null,fe.current.add(o.id),Ne(),Le.current(t+1))},De=()=>{_()&&(ee(),ae.current=null,B.current=null,r<1?(Ue(`idx ${t} · ${g} · retrying`),window.setTimeout(()=>{i===Pe.current&&Le.current(t,0,r+1)},350)):(Ne(),Le.current(t+1)))};l.addEventListener("ended",Se),l.addEventListener("error",De),ae.current=ee,xt.current=!1,fe.current.delete(o.id),B.current=o.id,Ke.current=Date.now(),$e.current=Math.max(1,Number(o.duration_sec)||0)*1e3,Be.current={id:o.id,count:0},vt(!0),Kt(`Top 20 · ${g.replace(/_/g," ")}`),Zt("Channel Sone");try{l.pause()}catch{}if(l.src=k,l.muted=ue,l.volume=oe.current,l.load(),await new Promise(te=>{let we=!1;const Z=()=>{we||(we=!0,rt(),te())},rt=()=>{l.removeEventListener("canplay",Z),l.removeEventListener("loadeddata",Z),l.removeEventListener("error",Z),window.clearTimeout(fn)},fn=window.setTimeout(Z,6e3);l.addEventListener("canplay",Z,{once:!0}),l.addEventListener("loadeddata",Z,{once:!0}),l.addEventListener("error",Z,{once:!0})}),!(i!==Pe.current||de.current!==t)){try{l.currentTime=0}catch{}try{await l.play(),Ue(`idx ${t} · ${g} · speaking`)}catch{if(!_())return;ee(),ae.current=null,B.current=null,r<1?(Ue(`idx ${t} · ${g} · blocked, retrying`),window.setTimeout(()=>{i===Pe.current&&Le.current(t,0,r+1)},350)):(Ue(`idx ${t} · ${g} · unavailable, continuing`),Ne(),Le.current(t+1))}}})},[ne,Tt,me,ue,Dt,Ne]);Le.current=Sr;const Dn=n.useCallback(()=>{En(!0),Vt.current&&clearTimeout(Vt.current),Vt.current=setTimeout(()=>En(!1),1800)},[]);n.useEffect(()=>{if(!F)return;const t=()=>{var y,g;const r=Date.now(),s=G(r),o=!!((y=s==null?void 0:s.row.clip_metadata)!=null&&y.countdown);if(o&&!Qe.current&&(Qe.current=!0,Bt(!0)),o&&!be.current&&!ce.current){const h=Me.current.filter(p=>{var b;return(b=p.clip_metadata)==null?void 0:b.countdown}).findIndex(p=>p.id===(s==null?void 0:s.row.id));h>=0&&Le.current(h,(s==null?void 0:s.offset)??0)}const i=ce.current;if(i&&(!s||o)){Ye.current=null;const m=L.current;lt.current||(!m||!K.current||m.ended||m.error?Xe():m.paused&&m.play().catch(()=>{}))}else if(s)if((o||be.current)&&!i&&(()=>{if(o)return!0;const m=Me.current.filter(R=>{var k;return(k=R.clip_metadata)==null?void 0:k.countdown}),h=de.current,p=m[h],b=h===m.length-1,x=(p==null?void 0:p.kind)==="track"?L.current:N.current,T=((p==null?void 0:p.kind)==="track"?K.current===p.id:B.current===(p==null?void 0:p.id))&&!!x&&(x.ended||!!x.error);return b&&T?(Dt(),!1):!0})()){Ye.current=null;const m=Me.current.filter(x=>{var v;return(v=x.clip_metadata)==null?void 0:v.countdown}),h=m[de.current],p=(h==null?void 0:h.kind)==="track"?h:((g=m[de.current+1])==null?void 0:g.kind)==="track"?m[de.current+1]:null,b=L.current;p&&!lt.current&&(!b||K.current!==p.id?(K.current=null,ne(p,0).then(()=>{(h==null?void 0:h.kind)==="clip"&&Lt(!0)})):b.paused&&!b.ended&&b.play().catch(()=>{K.current===p.id&&(K.current=null)}))}else if(Ye.current=null,K.current===s.row.id){const m=L.current;if(m&&E(m,s.offset),m&&!B.current&&!lt.current){const b=m.networkState===2&&!m.error,x=!!m.error||m.ended||m.paused||m.readyState===0&&!b;x?ct.current||(ct.current=r):ct.current=0;const v=x&&r-ct.current>=3e3,T=r-Gt.current>=8e3;if(v&&T&&(Gt.current=r,ct.current=0,bt.current+=1,console.warn("[Podcast v3.4] watchdog: music not playing, recovering"),m.error||m.ended||m.readyState===0?(K.current=null,ne(s.row,s.offset)):m.play().catch(()=>{})),x)yt.current={time:-1,since:0};else{const R=m.currentTime,k=yt.current;Math.abs(R-k.time)>.25?yt.current={time:R,since:Date.now()}:k.since&&Date.now()-k.since>8e3&&T&&(yt.current={time:-1,since:0},Gt.current=r,bt.current+=1,console.warn("[Podcast v3.2] watchdog: music frozen, reloading row"),K.current=null,ne(s.row,s.offset))}!ue&&m.volume<oe.current*.5&&(bt.current+=1,me())}}else{const m=_n.current,h=L.current,p=(m==null?void 0:m.kind)==="clip"&&!!h&&!h.ended&&!h.error&&h.duration>0&&h.currentTime<h.duration-.2,b=m?new Date(m.start_at).getTime()+(Number(m.duration_sec)||0)*1e3:0;p&&r-b<5e3||ne(s.row,s.offset)}else if(!Ye.current)Ye.current=r,le();else if(r-Ye.current>4e3&&(Dn(),le(),r-Cn.current>6e4)){Cn.current=r;const m=()=>I.functions.invoke("build-broadcast-timeline",{body:{mode:"extend"}});m().then(h=>{if(h!=null&&h.error)throw h.error;setTimeout(()=>le(),4e3)}
2).catch(()=>{setTimeout(()=>{m().then(()=>{setTimeout(()=>le(),4e3)}).catch(()=>{})},3e3)})}const d=L.current;vr(m=>{const h={paused:d?d.paused:!0,vol:d?Number(d.volume.toFixed(2)):0,ready:d?d.readyState:0,rowId:s?s.row.id.slice(0,8):null,fixes:bt.current};return m.paused===h.paused&&m.vol===h.vol&&m.ready===h.ready&&m.rowId===h.rowId&&m.fixes===h.fixes?m:h});const c=be.current&&!ce.current?null:je(r),f=N.current;if(c){if(ze.current=null,B.current!==c.overlay.id){const m=c.overlay.style==="track_intro",h=(s==null?void 0:s.offset)??999;!m&&h<6&&!fe.current.has(c.overlay.id)?(fe.current.add(c.overlay.id),console.warn(`[Podcast v3] suppressed overlay ${c.overlay.id.slice(0,8)} (style=${c.overlay.style}), too close to track start (offset=${h.toFixed(2)}s)`)):fe.current.has(c.overlay.id)||Fe(c.overlay,c.offset)}}else if(B.current){const m=f&&f.ended,h=f&&f.paused&&!f.ended;if(m){const p=B.current;p&&fe.current.add(p),Ne(),ze.current=null}else if(h){if(!ze.current)ze.current=r;else if(r-ze.current>3e4){console.warn("[Podcast v3] overlay stuck >30s past window, force-stopping");const p=B.current;p&&fe.current.add(p),Ne(),ze.current=null}}else ze.current=null}};t();const a=setInterval(t,1e3);return()=>clearInterval(a)},[F,G,je,ne,Fe,Ne,We,Dn,le,me,E,Xe,Dt]),n.useEffect(()=>{$||me()},[$,me]),n.useEffect(()=>{if(!F)return;const t=()=>{if(be.current&&!ce.current)return;if(console.log("[Podcast v3] music ended â re-pick"),ce.current){Xe();return}const l=G();l?ne(l.row,l.offset):le()},a=()=>{if(be.current&&!ce.current)return;const l=B.current;l&&fe.current.add(l),Ne()},r=()=>{var Se,De,Y;const l=N.current,_=B.current;if(console.warn("[Podcast v3] VOICE error",{id:_==null?void 0:_.slice(0,8),code:(Se=l==null?void 0:l.error)==null?void 0:Se.code,message:(De=l==null?void 0:l.error)==null?void 0:De.message,src:(Y=l==null?void 0:l.src)==null?void 0:Y.slice(0,120)}),be.current&&!ce.current)return;const ee=je();if(ee&&_===ee.overlay.id){const te=Be.current.id===ee.overlay.id?Be.current.count:0;if(te<2){Be.current={id:ee.overlay.id,count:te+1},B.current=null,setTimeout(()=>Fe(ee.overlay,ee.offset),350);return}}_&&fe.current.add(_),Ne()},s=l=>{var ee,Se,De;const _=L.current;console.warn("[Podcast v3] MUSIC error",{code:(ee=_==null?void 0:_.error)==null?void 0:ee.code,message:(Se=_==null?void 0:_.error)==null?void 0:Se.message,src:(De=_==null?void 0:_.src)==null?void 0:De.slice(0,60)}),setTimeout(()=>{var te;if(be.current&&!ce.current){const we=Me.current.filter(fn=>{var Jn;return(Jn=fn.clip_metadata)==null?void 0:Jn.countdown}),Z=we[de.current],rt=(Z==null?void 0:Z.kind)==="track"?Z:((te=we[de.current+1])==null?void 0:te.kind)==="track"?we[de.current+1]:null;rt&&(K.current=null,ne(rt,0).then(()=>{(Z==null?void 0:Z.kind)==="clip"&&Lt(!0)}));return}le();const Y=G();Y&&ne(Y.row,Y.offset)},500)},o=()=>{var _;const l=L.current;console.warn("[Podcast v3] MUSIC stalled",{networkState:l==null?void 0:l.networkState,readyState:l==null?void 0:l.readyState,src:(_=l==null?void 0:l.src)==null?void 0:_.slice(0,60)})},i=()=>{const l=L.current;console.warn("[Podcast v3] MUSIC waiting (buffering)",{networkState:l==null?void 0:l.networkState,readyState:l==null?void 0:l.readyState})},d=()=>{console.warn("[Podcast v3] MUSIC aborted, likely Brave Shields / network block")},c=()=>{const l=L.current;l&&l.networkState===3&&console.warn("[Podcast v3] MUSIC suspended NO_SOURCE, fetch likely blocked")},f=Ce(),y=l=>_=>{_.currentTarget===L.current&&l()},g=y(t),m=y(()=>s(new Event("error"))),h=y(o),p=y(i),b=y(d),x=y(c),v=N.current;for(const l of f)l.addEventListener("ended",g),l.addEventListener("error",m),l.addEventListener("stalled",h),l.addEventListener("waiting",p),l.addEventListener("abort",b),l.addEventListener("suspend",x);v==null||v.addEventListener("ended",a),v==null||v.addEventListener("error",r);let T=!1,R=null;const k=()=>{const l=N.current;if(!l||!isFinite(l.duration)||be.current&&!ce.current)return;const _=B.current;_!==R&&(R=_,T=!1),!(!_||T)&&l.duration-l.currentTime<=.8&&(T=!0,me())};return v==null||v.addEventListener("timeupdate",k),()=>{for(const l of f)l.removeEventListener("ended",g),l.removeEventListener("error",m),l.removeEventListener("stalled",h),l.removeEventListener("waiting",p),l.removeEventListener("abort",b),l.removeEventListener("suspend",x);v==null||v.removeEventListener("ended",a),v==null||v.removeEventListener("error",r),v==null||v.removeEventListener("timeupdate",k)}},[F,G,je,Fe,ne,Ne,le,me,Xe]),n.useEffect(()=>{if(!F)return;const t=()=>{var s;if(document.visibilityState!=="visible"||be.current&&!ce.current)return;const a=G();if(ce.current&&((s=a==null?void 0:a.row.clip_metadata)!=null&&s.countdown))return;a&&ne(a.row,a.offset);const r=je();r&&!B.current&&!fe.current.has(r.overlay.id)&&Fe(r.overlay,r.offset)};return document.addEventListener("visibilitychange",t),()=>document.removeEventListener("visibilitychange",t)},[F,G,je,ne,Fe]);const nn=n.useCallback(async()=>{var a;st(!0),Nn.current=Date.now(),"mediaSession"in navigator&&(navigator.mediaSession.setActionHandler("play",()=>{var r;lt.current=!1,(r=L.current)==null||r.play().catch(()=>{})}),navigator.mediaSession.setActionHandler("pause",()=>{var r;lt.current=!0,(r=L.current)==null||r.pause()}),navigator.mediaSession.setActionHandler("previoustrack",null),navigator.mediaSession.setActionHandler("seekto",null)),await new Promise(r=>setTimeout(r,200)),await le();const t=G();if((a=t==null?void 0:t.row.clip_metadata)!=null&&a.countdown){const s=Me.current.filter(o=>{var i;return(i=o.clip_metadata)==null?void 0:i.countdown}).findIndex(o=>
2o.id===t.row.id);s>=0&&Le.current(s,t.offset)}else{t&&await ne(t.row,t.offset);const r=je();r&&await Fe(r.overlay,r.offset)}},[G,je,ne,Fe,le]),Pn=n.useRef(!1);n.useEffect(()=>{Pn.current||F||S.get("autoplay")==="true"&&(Pn.current=!0,nn().catch(()=>{st(!1)}))},[S,F,nn]);const Qe=n.useRef(!1);n.useEffect(()=>{let t=!1;const a=async()=>{const{data:s}=await I.from("site_settings").select("value").eq("key","live_countdown_window").maybeSingle();if(t)return;const o=(s==null?void 0:s.value)??null,i=Date.now(),d=o!=null&&o.start_at?new Date(o.start_at).getTime():0,c=o!=null&&o.end_at?new Date(o.end_at).getTime():0,f=!ce.current&&!!(o!=null&&o.show_id)&&(!d||i>=d)&&(!c||i<=c);Qe.current=f,Bt(f)};a();const r=setInterval(a,6e4);return()=>{t=!0,clearInterval(r)}},[]),n.useEffect(()=>{if(!q){yn(new Map);return}let t=!1;const a=async()=>{const{data:s}=await I.from("countdown_shows").select("id").in("status",["live","airing","prepared","finalized"]).order("scheduled_start",{ascending:!1}).limit(1).maybeSingle();if(t||!(s!=null&&s.id))return;const{data:o}=await I.from("countdown_entries").select("track_id, position").eq("show_id",s.id);if(t||!o)return;const i=new Map;for(const d of o)i.set(d.track_id,Number(d.position));yn(i)};a();const r=setInterval(a,6e4);return()=>{t=!0,clearInterval(r)}},[q]),n.useEffect(()=>{if(!q){zt.current=new Map,Ht.current=new Map,it(null);return}let t=!1;return(async()=>{const[{data:r},{data:s}]=await Promise.all([I.from("countdown_shows").select("id").in("status",["live","airing","prepared","finalized"]).order("scheduled_start",{ascending:!1}).limit(1).maybeSingle(),I.from("countdown_stingers").select("slot_key, audio_url").eq("kind","sfx").eq("enabled",!0).like("slot_key","award/%")]);if(t||!(r!=null&&r.id))return;const{data:o}=await I.from("countdown_awards").select("award_key, label, credits, artist, title").eq("show_id",r.id);if(t||!o)return;const i=new Map;o.forEach(c=>i.set(String(c.award_key),{label:c.label??String(c.award_key).replace(/_/g," "),credits:Number(c.credits)||0,artist:c.artist,title:c.title})),zt.current=i;const d=new Map;s==null||s.forEach(c=>{const f=String(c.slot_key??"").replace(/^award\//,"");f&&c.audio_url&&d.set(f,c.audio_url)}),Ht.current=d})(),()=>{t=!0}},[q]);const Oe=n.useRef(null);n.useEffect(()=>{if(!q||!F)return;let t=!1,a=null;(async()=>{const{data:o}=await I.from("countdown_stingers").select("audio_url").eq("kind","sfx").eq("slot_key","recap").eq("enabled",!0).maybeSingle();t||(a=(o==null?void 0:o.audio_url)??null)})();const r=()=>{var d;const o=Oe.current;if(((d=ve==null?void 0:ve.clip_metadata)==null?void 0:d.segment)==="recap"&&a){if(!o){const c=new Audio(a);c.loop=!0,c.volume=.14*oe.current,c.muted=ue,Oe.current=c,c.play().catch(()=>{})}}else o&&(o.pause(),Oe.current=null)};r();const s=setInterval(r,1e3);return()=>{var o;t=!0,clearInterval(s),(o=Oe.current)==null||o.pause(),Oe.current=null}},[q,F,ve,ue]);const Te=n.useCallback(async(t,a)=>{var r;if(!(!$||He.current)){$n.current.anyFired=!0,_t(!0),He.current=!0;try{const s=new Date(Date.now()-24e4).toISOString(),{data:o}=await I.from("podcast_messages").select("id, username, message, created_at").gt("created_at",s).order("created_at",{ascending:!1}).limit(10),i=(o||[]).filter(R=>{if(Ze.current.has(R.id))return!1;const k=(R.username??"").toString().trim(),l=(R.message??"").toString().trim();return!(!k||!l||k.startsWith("ð¢")||k.toLowerCase()==="undefined"||l.toLowerCase()==="undefined")}),d=new Date(Date.now()-18e4).toISOString(),{count:c}=await I.from("podcast_listeners").select("id",{count:"exact",head:!0}).gte("last_heartbeat_at",d),f=ot.current,y=f?{title:f.title,artist:f.artist,artwork_url:f.artwork_url,tags:f.tags||[]}:null,g=a?{title:a.title,artist:a.artist,artwork_url:a.artwork_url,tags:a.tags||[]}:null,h=!t||!new Set(["track_intro","track_react","broadcast_intro","broadcast_outro"]).has(t),p=Qe.current;if(p)return;let b;if(h&&i.length>0){const R=i.reduce((Y,te)=>te.created_at<Y?te.created_at:Y,i[0].created_at),k=new Date(new Date(R).getTime()-15*6e4).toISOString(),l=new Date(Date.now()+6e4).toISOString(),{data:_}=await I.from("live_broadcast_timeline").select("title, artist, start_at, duration_sec, kind").eq("kind","track").gte("start_at",k).lte("start_at",l).order("start_at",{ascending:!0}).limit(60),ee=Y=>{const te=new Date(Y).getTime();for(const we of _||[]){const Z=new Date(we.start_at).getTime(),rt=Z+(Number(we.duration_sec)||0)*1e3;if(te>=Z-2e3&&te<=rt+2e3)return{title:we.title,artist:we.artist}}return null},Se=(f==null?void 0:f.title)||"";b={segment_style:"chat_react",chat_messages:i.reverse().map(Y=>{const te=ee(Y.created_at),we=te&&Se&&te.title===Se,Z=te&&!we?` [re: "${te.title}" by ${te.artist||"unknown"}]`:"";return`${Y.username}${Z}: "${Ns(String(Y.message??""))}"`}).join(` 3`),current_track:y,listener_count:c??0,countdown_mode:p}
3,i.forEach(Y=>Ze.current.add(Y.id)),Ze.current.size>100&&(Ze.current=new Set([...Ze.current].slice(-50)))}else{if(p)return;const R=t||"fun_fact";b={segment_style:R,current_track:R==="track_intro"?null:y,next_track:R==="track_intro"?g:null,listener_count:c??0,current_time_utc:new Date().toISOString()}}const{data:x,error:v}=await I.functions.invoke("generate-podcast-segment",{body:b});v&&console.warn("[Podcast v3] generate-podcast-segment invoke error:",v);const T=new Response(JSON.stringify(x??{}),{status:v?500:200,headers:{"Content-Type":"application/json"}});try{const R=await T.clone().json().catch(()=>null),k=(R==null?void 0:R.metadata)||{};k.teased_rundown_id&&(Ae.current={rundownId:k.teased_rundown_id,tracksSince:0},console.log("[Tease] ð lock engaged for rundown",k.teased_rundown_id)),k.paid_off_rundown_id&&(((r=Ae.current)==null?void 0:r.rundownId)===k.paid_off_rundown_id?console.log("[Tease] â
paid off, clearing lock, entering cooldown"):console.log("[Tease] â
payoff fired (no matching pending lock, clearing anyway)"),Ae.current=null,ft.current=5)}catch{}}catch(s){console.warn("[Podcast v3] triggerAutoSegment failed:",s)}finally{_t(!1),He.current=!1}}},[$]),$n=n.useRef({rowId:null,cap:0,fired:0,bridgeFired:!1,reactFired:!1,anyFired:!1,floorFired:!1,lastOverlayEndedAt:0}),jr=10,Nr=3,ye=n.useRef(0),[Vs,et]=n.useState(0),rn=n.useRef(3),Fn=n.useRef(5+Math.floor(Math.random()*3)),sn=n.useRef(0),an=n.useRef(2),On=n.useRef(3+Math.floor(Math.random()*3)),on=n.useRef(2),Un=n.useRef(5+Math.floor(Math.random()*3)),cn=n.useRef(2),Bn=n.useRef(4+Math.floor(Math.random()*3)),ln=n.useRef(0),Pt=n.useRef(1),un=n.useRef(0),zn=n.useRef(3+Math.floor(Math.random()*2)),Ae=n.useRef(null),ft=n.useRef(0),Rr=5,Er=7;n.useEffect(()=>{if(!F||!$||q)return;const t=()=>{const s=Date.now(),o=G(s);if(!o)return;const{row:i,offset:d,next:c}=o;if(i.kind!=="track")return;const f=Number(i.duration_sec)-d,y=c?{id:c.track_id||void 0,title:c.title||"Channel Sone",artist:c.artist,artwork_url:c.artwork_url,audio_url:c.audio_url}:null,g=$n.current;if(g.rowId!==i.id&&(g.rowId=i.id,g.cap=1,g.fired=0,g.bridgeFired=!1,g.reactFired=!1,g.anyFired=!1,g.floorFired=!1,ye.current=0,et(0),ln.current=0,un.current+=1,un.current>=zn.current?(Pt.current=2,un.current=0,zn.current=3+Math.floor(Math.random()*2),console.log("[Podcast v1.9] ðï¸ chat_react burst track, allowance=2")):Pt.current=1,rn.current+=1,sn.current+=1,an.current+=1,on.current+=1,cn.current+=1,Ae.current&&(Ae.current.tracksSince+=1),ft.current>0&&(ft.current-=1),Ae.current&&Ae.current.tracksSince>=Er&&(console.warn("[Tease] â ï¸ hard ceiling hit, clearing stale lock without payoff"),Ae.current=null,ft.current=5)),B.current){const T=s-Ke.current;if(!($e.current>0&&T>$e.current+6e3))return;console.warn("[Podcast v2.4] overlay overdue, unblocking clip generation"),fe.current.add(B.current),B.current=null,Ke.current=0,$e.current=0}if(He.current)return;const m=ye.current>=Nr,h=Q.current,b=(h?h-s:1/0)<4*6e4,x=!h||s+f*1e3+Number((c==null?void 0:c.duration_sec)||0)*1e3<=h;if(c&&y&&f<=110&&f>=40&&!g.bridgeFired&&x){g.bridgeFired=!0,g.lastOverlayEndedAt=s+14e3,ye.current+=1,et(ye.current),Te("track_intro",y);return}if(!g.anyFired&&!g.floorFired&&f<=38&&f>=12){g.floorFired=!0,g.lastOverlayEndedAt=s+12e3,ye.current+=1,et(ye.current),console.log("[Podcast v2.2] ðï¸ presence floor, firing quick_banter"),Te("quick_banter");return}if(!m&&cn.current>=Bn.current&&f<=135&&f>=100&&!g.reactFired){g.reactFired=!0,g.lastOverlayEndedAt=s+14e3,cn.current=0,Bn.current=4+Math.floor(Math.random()*3),ye.current+=1,et(ye.current),Te("track_react");return}const v=s-g.lastOverlayEndedAt;if(!m&&v>=3e4&&g.fired<g.cap&&f>=140){const T=[];!b&&rn.current>=Fn.current&&ot.current&&T.push("now_playing_appreciation");const R=Ae.current,k=!!(R&&R.tracksSince>=Rr);(an.current>=On.current||k)&&T.push("entertainment_banter","entertainment_banter");const l=!R&&ft.current===0;!b&&l&&on.current>=Un.current&&T.push("tease");let _=null;if(k)_="entertainment_banter",console.log("[Tease] â° forcing payoff after",R==null?void 0:R.tracksSince,"tracks");else if(T.length>0)_=T[Math.floor(Math.random()*T.length)];else if(sn.current>=jr){if(s-Qt.current<24e4){console.log("[Podcast v1.6] fun_fact suppressed, chat active");return}_="fun_fact"}else return;_==="now_playing_appreciation"?(rn.current=0,Fn.current=5+Math.floor(Math.random()*3)):_==="fun_fact"?sn.current=0:_==="entertainment_banter"?(an.current=0,On.current=3+Math.floor(Math.random()*3)):_==="tease"&&(on.current=0,Un.current=5+Math.floor(Math.random()*3)),g.fired+=1,g.lastOverlayEndedAt=s+18e3,ye.current+=1,et(ye.current),Te(_)}},a=setTimeout(t,12e3),r=setInterval(t,3e3);return()=>{clearTimeout(a),clearInterval(r)}},[F,$,q,G,Te]);const dn=n.useRef(!1);n.useEffect(()=>{if(!F||!$||q||dn.current)return;let t=!1;const a=setTimeout(async()=>
3{if(!(t||dn.current))try{const r=Date.now(),s=Q.current,o=s?`slot-${s}`:`open-${Math.floor(r/(2*36e5))}`;if(localStorage.getItem("sone_live_welcomed_slot")===o||He.current||B.current)return;const i=new Date(r-6e4).toISOString(),{data:d}=await I.from("live_broadcast_overlays").select("id").gt("start_at",i).limit(1);if(((d==null?void 0:d.length)??0)>0||s&&s-r<2*6e4)return;const c=G(r);if(!c||c.row.kind!=="track"||Number(c.row.duration_sec)-c.offset<25)return;dn.current=!0,localStorage.setItem("sone_live_welcomed_slot",o),console.log("[Podcast v2.5] firing listener_welcome clip for",o),Te("listener_welcome")}catch(r){console.warn("[Podcast v2.5] welcome clip check failed:",r)}},4e3);return()=>{t=!0,clearTimeout(a)}},[F,$,q,G,Te]);const Hn=n.useRef(0);n.useEffect(()=>{if(!F||!$||q)return;const t=12e4,a=45e3,r=async()=>{try{if(Qe.current||He.current||B.current)return;const i=Date.now(),c=Pt.current>1?a:t;if(i-Hn.current<c||ln.current>=Pt.current)return;const f=Q.current;if(f&&f-i<4*6e4)return;const y=G(i);if(!y||y.row.kind!=="track")return;const g=Number(y.row.duration_sec)-y.offset;if(g<60||g>Number(y.row.duration_sec)-6)return;const m=new Date(i-24e4).toISOString(),{data:h}=await I.from("podcast_messages").select("id, username, message, created_at").gt("created_at",m).order("created_at",{ascending:!1}).limit(15),p=(Me.current||[]).filter(v=>v.kind==="track").flatMap(v=>{const T=new Date(v.start_at).getTime();return[T,T+(Number(v.duration_sec)||0)*1e3]}),b=v=>{const T=new Date(v).getTime();for(const R of p)if(Math.abs(T-R)<=3e3)return!0;return!1};if((h||[]).filter(v=>{if(Ze.current.has(v.id))return!1;const T=(v.username??"").toString().trim(),R=(v.message??"").toString().trim();return!(!T||!R||T.startsWith("ð¢")||T.toLowerCase()==="undefined"||R.toLowerCase()==="undefined"||b(v.created_at))}).length===0)return;Hn.current=i,ln.current+=1,ye.current+=1,et(ye.current),await Te("chat_react")}catch(i){console.warn("[Podcast] chat-react loop error:",i)}},s=setTimeout(r,8e3),o=setInterval(r,6e3);return()=>{clearTimeout(s),clearInterval(o)}},[F,$,G,Te]),n.useEffect(()=>{var t,a,r;q||((t=ae.current)==null||t.call(ae),ae.current=null,(a=re.current)==null||a.call(re),re.current=null,be.current=!1,ce.current=!1,de.current=-1,Pe.current+=1,qt(null),it(null),(r=ge.current)==null||r.pause(),ge.current=null)},[q]);const Cr=async(t,a="Anonymous")=>{if(!(!t.trim()||!$)){_t(!0);try{const{data:r,error:s}=await I.from("podcast_queue").insert({topic:t.trim(),submitted_by:a,status:"pending"}).select().single();if(s||!r)throw new Error((s==null?void 0:s.message)||"Insert failed");await I.functions.invoke("generate-podcast-segment",{body:{queue_id:r.id,topic:t.trim(),submitted_by:a,current_track:ot.current,skip_listener_check:!0}})}catch(r){const s=r instanceof Error?r.message:"Unknown error";w({title:"Generation failed",description:s,variant:"destructive"})}finally{_t(!1)}}},Ir=!(u!=null&&u.artwork_url)||vn,mt=String(((Wn=ve==null?void 0:ve.clip_metadata)==null?void 0:Wn.segment)??""),tt=q&&(mt==="open"||mt==="recap"||mt==="sting"||mt==="filler"||mt==="signoff"),nt=q&&ve&&!tt?ie.find(t=>{var a;return((a=t.clip_metadata)==null?void 0:a.countdown)&&t.kind==="track"&&t.position>=ve.position})??null:null,Mr=(nt==null?void 0:nt.artwork_url)??(u==null?void 0:u.artwork_url)??null,qn=q?hr??(ve&&Number(((Vn=ve.clip_metadata)==null?void 0:Vn.chart_position)??((Gn=ve.clip_metadata)==null?void 0:Gn.position))||null)??(u!=null&&u.id?fr.get(u.id)??null:null):null,Lr=n.useCallback(async()=>{Et.current&&await I.rpc("podcast_listener_leave",{p_session_id:Et.current});for(const t of Ce())try{t.pause(),t.src=""}catch{}z(),N.current&&(N.current.pause(),N.current.src=""),D("/")},[D]);if(P===null)return e.jsx("div",{className:"w-screen bg-[#0A0A0A] text-white flex flex-col items-center justify-center",style:{height:"100dvh"},children:e.jsx("div",{className:"animate-pulse text-white/50 text-sm",children:"Loading..."})});if(!P){const t=rr(V,3);return(()=>{var a;try{return((a=new Intl.DateTimeFormat(void 0,{timeZoneName:"short"}).formatToParts(new Date).find(s=>s.type==="timeZoneName"))==null?void 0:a.value)||""}catch{return""}})(),e.jsxs("div",{className:"w-screen relative overflow-hidden text-white flex flex-col items-center justify-center px-6",style:{height:"100dvh"},children:[e.jsx("img",{src:Ws,alt:"",className:"absolute inset-0 w-full h-full object-cover scale-110",style:{filter:"blur(30px) brightness(0.35)"},loading:"lazy",decoding:"async"}),e.jsx("div",{className:"absolute inset-0 bg-black/40 backdrop-blur-sm"}),e.jsx("button",{onClick:()=>D("/"),className:"absolute top-6 left-6 z-20 flex items-center gap-2 hover:opacity-80 transition-opacity","aria-label":"Go to Sone.fm home",children:e.jsx("img",{src:tr,alt:"Sone",className:"h-10 object-contain",loading:"lazy",decoding:"async"})}),e.jsxs("div",{className:"relative z-10 flex flex-col items-center text-center max-w-sm w-full",children:[e.jsxs("div",{className:"flex flex-col items-center mb-6",children:[e.jsx("img",{src:"/__l5e/assets-v1/7a2c3f96-d2ef-44cf-8cd4-9d4f56596131/jake-gemma-live.png",alt:"Jake & Gemma",className:"w-16 h-16 rounded-full object-cover ring-2 ring-white/20 mb-4",loading:"lazy",decoding:"async"}),t.length>0&&e.jsxs("p",{className:"text-white/90 text-sm font-medium",children:["we're back at ",e.jsx("span",{className:"text-white font-semibold",children:mn(t[0].when)})]}),t.length===0&&e.jsx("p",{className:"text-white/60 text-sm font-medium",children:"we're back soon"}),(dt==null?void 0:dt.start_time)&&e.jsxs("p",{className:"mt-2 text-white/60 text-xs",children:["Soné Top 20 · Sundays at"," ",e.jsx("span",{className:"text-white/90 font-semibold",children:mn(Yn(dt.weekday??0,dt.start_time))})]})]}),yr&&e.jsxs(he.div,{initial:{opacity:0}
3,animate:{opacity:1},className:"flex flex-col items-center",children:[e.jsxs("div",{className:"flex items-center gap-3 mb-2",children:[e.jsxs("span",{className:"relative flex h-3 w-3",children:[e.jsx("span",{className:"animate-ping absolute inline-flex h-full w-full rounded-full opacity-75",style:{backgroundColor:"hsl(82, 100%, 50%)"}}),e.jsx("span",{className:"relative inline-flex rounded-full h-3 w-3",style:{backgroundColor:"hsl(82, 100%, 50%)"}})]}),e.jsx("p",{className:"text-lg font-semibold",style:{color:"hsl(82, 100%, 50%)"},children:"Tuning inâ¦"})]}),e.jsx("p",{className:"text-white/50 text-xs",children:"Broadcast is starting any moment now"})]}),Ie&&e.jsxs(he.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},transition:{delay:.2},className:"flex flex-col items-center",children:[e.jsx("p",{className:"text-white/60 text-xs font-semibold uppercase tracking-widest mb-4",children:"Next Broadcast In"}),e.jsx("div",{className:"flex gap-3 sm:gap-5",children:(Ie.days>0?[{val:Ie.days,label:"Days"},{val:Ie.hours,label:"Hours"},{val:Ie.minutes,label:"Mins"},{val:Ie.seconds,label:"Secs"}]:[{val:Ie.hours,label:"Hours"},{val:Ie.minutes,label:"Mins"},{val:Ie.seconds,label:"Secs"}]).map(({val:a,label:r})=>e.jsxs("div",{className:"flex flex-col items-center",children:[e.jsx("span",{className:"text-4xl sm:text-6xl font-black tabular-nums leading-none",style:{color:"hsl(82, 100%, 50%)",textShadow:"0 0 30px hsla(82, 100%, 50%, 0.5), 0 0 60px hsla(82, 100%, 50%, 0.2)"},children:String(a).padStart(2,"0")}),e.jsx("span",{className:"text-white/40 text-[10px] sm:text-xs uppercase tracking-wider mt-1.5",children:r})]},r))})]})]})]})}return e.jsxs("div",{className:"fixed inset-0 bg-[#0A0A0A] text-white flex flex-col overflow-hidden",children:[e.jsxs(Vr,{children:[e.jsx("title",{children:"Channel Sone, Live AI Radio on Sone.fm"}),e.jsx("meta",{name:"description",content:"Channel Sone, the live AI radio show on Sone.fm. Hosted, scheduled and streaming around the clock."}),e.jsx("link",{rel:"canonical",href:"https://sone.fm/live"}),e.jsx("meta",{property:"og:title",content:"Channel Sone, Live on Sone.fm"}),e.jsx("meta",{property:"og:description",content:"Hosted live AI radio on Sone.fm."}),e.jsx("meta",{property:"og:url",content:"https://sone.fm/live"}),e.jsx("meta",{property:"og:type",content:"website"}),e.jsx("script",{type:"application/ld+json",children:JSON.stringify({"@context":"https://schema.org","@type":"RadioSeries",name:"Channel Sone",description:"Live, hosted AI radio streaming around the clock on Sone.fm.",url:"https://sone.fm/live",broadcastOfEvent:{"@type":"BroadcastService",name:"Channel Sone Live",broadcastDisplayName:"Channel Sone",areaServed:"Worldwide"}})})]}),e.jsx("audio",{ref:Ot,preload:"auto",playsInline:!0,crossOrigin:"anonymous"}),e.jsx("audio",{ref:Ut,preload:"auto",playsInline:!0,crossOrigin:"anonymous"}),e.jsx("audio",{ref:N,preload:"auto",playsInline:!0,crossOrigin:"anonymous"}),e.jsx(os,{}),e.jsx(Gr,{open:br,onOpenChange:kt,redirectTo:"/live"}),e.jsx(qe,{mode:"wait",children:F?u!=null&&u.artwork_url&&!vn?e.jsxs(he.div,{initial:{opacity:0}
3,animate:{opacity:1},exit:{opacity:0},transition:{duration:1.2},className:"absolute inset-0 z-0",children:[e.jsx("img",{src:u.artwork_url,alt:"",className:"absolute inset-0 w-full h-full object-cover scale-150",style:{filter:"blur(80px) saturate(1.5) brightness(0.4)"},loading:"lazy",decoding:"async",fetchPriority:"low"}),e.jsx("div",{className:"absolute inset-0 bg-black/50 backdrop-blur-3xl"}),e.jsx("div",{className:"absolute inset-0 bg-gradient-to-b from-black/40 via-transparent to-black/80"})]},u.audio_url):null:e.jsxs(he.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:{duration:1.2},className:"absolute inset-0 z-0",children:[q?e.jsx("img",{src:ht.url,alt:"",className:"absolute inset-0 w-full h-full object-cover scale-150",style:{filter:"blur(80px) saturate(1.5) brightness(0.4)"},fetchPriority:"high"}):$?e.jsx("img",{src:"/__l5e/assets-v1/7a2c3f96-d2ef-44cf-8cd4-9d4f56596131/jake-gemma-live.png",alt:"",className:"absolute inset-0 w-full h-full object-cover scale-150",style:{filter:"blur(80px) saturate(1.5) brightness(0.4)"},loading:"lazy",decoding:"async"}):e.jsx(hn,{src:pn,poster:gn,className:"absolute inset-0 w-full h-full object-cover scale-150",style:{filter:"blur(80px) saturate(1.5) brightness(0.4)"}}),e.jsx("div",{className:"absolute inset-0 bg-black/50 backdrop-blur-3xl"}),e.jsx("div",{className:"absolute inset-0 bg-gradient-to-b from-black/40 via-transparent to-black/80"})]},"landing-bg")}),e.jsxs("div",{className:"relative z-10 flex flex-col flex-1 min-h-0 max-w-lg mx-auto w-full",children:[e.jsxs("header",{className:"shrink-0 flex items-center px-4 pt-4 pb-2",children:[e.jsx("button",{onClick:Lr,className:"shrink-0 w-24","aria-label":"Exit station",children:e.jsx("img",{src:tr,alt:"Sone",className:"h-16 object-contain",loading:"lazy",decoding:"async"})}),e.jsx("div",{className:"flex-1 flex flex-col items-center justify-center",children:e.jsxs("div",{className:"flex items-center gap-2.5",children:[e.jsx("div",{className:"relative",children:q?e.jsx("img",{src:ht.url,alt:"Soné Top 20",className:`w-10 h-10 rounded-full object-cover ${Wt?"host-speaking-active":"host-speaking-ring"}`,fetchPriority:"high"}):$?e.jsx("img",{src:"/__l5e/assets-v1/7a2c3f96-d2ef-44cf-8cd4-9d4f56596131/jake-gemma-live.png",alt:"Jake & Gemma Live",className:`w-10 h-10 rounded-full object-cover ${Wt?"host-speaking-active":"host-speaking-ring"}`,loading:"lazy",decoding:"async"}):e.jsx(hn,{src:pn,poster:gn,className:"w-10 h-10 rounded-full object-cover ring-1 ring-white/10"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-white text-sm font-bold leading-tight",children:q?"Soné Top 20":$?"Jake & Gemma":"Channel Sone"}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsxs("span",{className:"relative flex h-1.5 w-1.5",children:[e.jsx("span",{className:"animate-ping absolute inline-flex h-full w-full rounded-full bg-cyan-400 opacity-75"}),e.jsx("span",{className:"relative inline-flex rounded-full h-1.5 w-1.5 bg-cyan-400"})]}),e.jsx("span",{className:"text-cyan-400 font-semibold text-[9px] tracking-[0.15em] uppercase",children:q?"with Jake & Gemma":"Live"})]})]})]})}),e.jsxs("div",{className:"shrink-0 flex items-center justify-end gap-1 text-white/50 text-[11px]",children:[F&&e.jsx(Jr,{volume:Ve,muted:ue,onVolumeChange:cr,onToggleMute:lr}),e.jsx(Kr,{className:"w-3.5 h-3.5"}),e.jsx("span",{children:wr})]})]}),F?e.jsxs(e.Fragment,{children:[e.jsxs(qe,{children:[xe&&e.jsx(he.div,{initial:{opacity:0,y:-20},animate:{opacity:1,y:0},exit:{opacity:0,y:-20},className:"shrink-0 mx-4 mt-1 mb-1",children:e.jsxs("div",{className:"flex items-center gap-2.5 bg-white/[0.06] backdrop-blur-xl rounded-xl px-4 py-2.5 border border-white/10 shadow-[0_0_30px_rgba(34,211,238,0.08)]",children:[e.jsx("img",{src:"/__l5e/assets-v1/7a2c3f96-d2ef-44cf-8cd4-9d4f56596131/jake-gemma-live.png",alt:"Jake & Gemma",className:"w-6 h-6 rounded-full object-cover ring-1 ring-white/20 shrink-0",loading:"lazy",decoding:"async"}),e.jsxs("p",{className:"text-white/90 text-xs font-medium leading-snug",children:["The show is ending soon",C&&e.jsxs("span",{className:"text-cyan-400/80",children:[" · we're back ",C]})]})]})}),!xe&&q&&e.jsx(he.div,{initial:{opacity:0,y:-20}
3,animate:{opacity:1,y:0},exit:{opacity:0,y:-20},className:"shrink-0 mx-4 mt-1 mb-1",children:e.jsxs("div",{className:"flex items-center gap-2.5 bg-white/[0.05] backdrop-blur-xl rounded-xl px-4 py-2.5 border border-white/10",children:[e.jsx("img",{src:ht.url,alt:"Soné Top 20",className:"w-6 h-6 rounded-full object-cover ring-1 ring-white/20 shrink-0",decoding:"async"}),e.jsxs("p",{className:"text-white/85 text-xs font-medium leading-snug",children:[e.jsx("span",{className:"text-white",children:"Soné Top 20"})," with Jake & Gemma"]})]})}),!xe&&!q&&!$&&P&&V.length>0&&(()=>{const t=rr(V,1)[0];if(!t)return null;const a=Yr(t.when),r=mn(t.when),o=(()=>{try{return Intl.DateTimeFormat().resolvedOptions().timeZone}catch{return""}})()==="Europe/London";return e.jsx(he.div,{initial:{opacity:0,y:-20},animate:{opacity:1,y:0},exit:{opacity:0,y:-20},className:"shrink-0 mx-4 mt-1 mb-1",children:e.jsxs("div",{className:"flex items-center gap-2.5 bg-white/[0.05] backdrop-blur-xl rounded-xl px-4 py-2.5 border border-white/10",children:[e.jsx("img",{src:"/__l5e/assets-v1/7a2c3f96-d2ef-44cf-8cd4-9d4f56596131/jake-gemma-live.png",alt:"Jake & Gemma",className:"w-6 h-6 rounded-full object-cover ring-1 ring-white/20 shrink-0",loading:"lazy",decoding:"async"}),e.jsxs("p",{className:"text-white/85 text-xs font-medium leading-snug",children:["we're back at ",e.jsx("span",{className:"text-white",children:r}),!o&&e.jsxs("span",{className:"text-white/60",children:[" (",a,")"]})]})]})})})()]}),e.jsxs("div",{className:"shrink-0 flex flex-col items-center relative mt-2 min-h-0 px-3",style:{height:"clamp(170px, min(46dvh, calc(100dvh - 20rem)), 340px)"},children:[$&&Jt&&Yt&&Yt!=="Channel Sone"&&e.jsx("div",{className:"absolute top-2 left-4 z-20 pointer-events-none",children:e.jsx(qe,{mode:"wait",children:e.jsx(he.div,{initial:{opacity:0,x:-10},animate:{opacity:1,x:0},exit:{opacity:0,x:-10},children:e.jsxs("div",{className:"inline-flex items-center gap-1.5 bg-white/5 backdrop-blur-sm rounded-full px-3 py-1 border border-white/5",children:[e.jsxs("span",{className:"relative flex h-1.5 w-1.5",children:[e.jsx("span",{className:"animate-ping absolute inline-flex h-full w-full rounded-full bg-pink-400 opacity-75"}),e.jsx("span",{className:"relative inline-flex rounded-full h-1.5 w-1.5 bg-pink-400"})]}),e.jsx("p",{className:"text-white/80 font-medium text-[11px] leading-snug max-w-[30vw] truncate",children:Jt}),e.jsxs("span",{className:"text-cyan-400/60 text-[10px]",children:["· ",Yt]})]})},Jt)})}),e.jsx(qe,{children:Rn&&e.jsx(he.div,{initial:{opacity:0,y:-6},animate:{opacity:1,y:0},exit:{opacity:0,y:-6},className:"absolute top-2 right-4 z-20 pointer-events-none",children:e.jsxs("div",{className:"inline-flex items-center gap-1.5 bg-cyan-400/10 backdrop-blur-sm rounded-full px-3 py-1 border border-cyan-400/30",children:[e.jsxs("span",{className:"relative flex h-1.5 w-1.5",children:[e.jsx("span",{className:"animate-ping absolute inline-flex h-full w-full rounded-full bg-cyan-400 opacity-75"}),e.jsx("span",{className:"relative inline-flex rounded-full h-1.5 w-1.5 bg-cyan-400"})]}),e.jsx("span",{className:"text-cyan-300 text-[10px] uppercase tracking-wider font-medium",children:"Re-syncingâ¦"})]})},"resync")}),e.jsx("div",{"data-hype-stage":!0,className:"flex-1 min-h-0 w-full flex items-center justify-center relative",children:e.jsx(qe,{mode:"wait",children:e.jsx(he.div,{initial:{opacity:0,scale:.92},animate:{opacity:1,scale:1},exit:{opacity:0,scale:.95},transition:{duration:.5},className:"h-full w-auto aspect-square max-w-full max-h-full rounded-2xl relative z-10 p-[3px] animate-gradient-border",children:e.jsxs("div",{className:"relative w-full h-full rounded-[14px] overflow-hidden z-[1]",children:[tt&&e.jsx("img",{src:ht.url,alt:"Soné Top 20 countdown",className:"absolute inset-0 z-10 w-full h-full object-cover",fetchPriority:"high"}),!tt&&u?e.jsx(is,{src:Ir&&!(nt!=null&&nt.artwork_url)?null:Mr,alt:u.title,className:"w-full h-full",onError:()=>bn(!0)}):!tt&&ke?e.jsxs("div",{className:"w-full h-full bg-white/5 flex flex-col items-center justify-center gap-3 px-4 text-center",children:[e.jsxs("div",{className:"relative flex h-3 w-3",children:[e.jsx("span",{className:"animate-ping absolute inline-flex h-full w-full rounded-full bg-cyan-400 opacity-75"}),e.jsx("span",{className:"relative inline-flex rounded-full h-3 w-3 bg-cyan-400"})]}),e.jsx("p",{className:"text-white/80 text-sm font-semibold",children:"Broadcast is startingâ¦"}),e.jsx("p",{className:"text-white/40 text-xs",children:"Warming up the studio. First track in a few seconds."})]}):tt?null:e.jsxs("div",{className:"w-full h-full bg-white/5 flex flex-col items-center justify-center gap-2 px-4 text-center",children:[e.jsx("div",{className:"w-5 h-5 border-2 border-white/20 border-t-cyan-400 rounded-full animate-spin"}),e.jsx("p",{className:"text-white/40 text-xs",children:"Tuning inâ¦"})]}),(u==null?void 0:u.id)&&e.jsx(us,{trackId:u.id,counterClassName:"absolute top-2 left-2 z-30",showHint:!0}),u!=null&&u.id&&q&&!tt&&qn?e.jsx(xs,{position:qn,trackKey:u.audio_url||u.id}):u!=null&&u.id?e.jsx(Ts,{isNew:!!u.created_at&&Date.now()-new Date(u.created_at).getTime()<7*24*60*60*1e3,chart:ur.get(u.id)||null}):null,q&&e.jsx(vs,{prize:(Je==null?void 0:Je.prize)??null,prizeKey:(Je==null?void 0:Je.key)??"idle"}),q&&S.get("debug")==="1"&&e.jsx("div",{className:"absolute bottom-2 left-2 z-40 pointer-events-none",children:e.jsxs("span",{className:"px-2 py-0.5 rounded-md bg-black/70 border border-white/15 text-[9px] font-mono text-white/60 tracking-wide",children:["T20 v1.2 · ",mr]})}),u&&e.jsx(e.Fragment,{children:e.jsx("div",{className:"absolute bottom-0 left-0 right-0 z-20 bg-gradient-to-t from-black/80 via-black/40 to-transparent pt-10 pb-3 px-3",children:e.jsxs(he.div,{initial:{opacity:0,y:6}
3,animate:{opacity:1,y:0},className:"flex items-end justify-between gap-2",children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[u.artistUsername?e.jsx("button",{onClick:()=>D(`/profile/${u.artistUsername}`),className:"text-white text-sm font-bold truncate drop-shadow-lg block max-w-full text-left hover:underline",children:u.title}):e.jsx("h1",{className:"text-white text-sm font-bold truncate drop-shadow-lg",children:u.title}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[u.artistAvatarUrl?e.jsx("img",{src:u.artistAvatarUrl,alt:u.artist||"",className:"w-5 h-5 rounded-full object-cover flex-shrink-0 border border-white/20",loading:"lazy",decoding:"async"}):e.jsx(Zr,{className:"w-5 h-5 rounded-full flex-shrink-0 border border-white/20",iconSize:10,username:u.artist||u.artistUsername||void 0}),u.artistUsername?e.jsx("button",{onClick:()=>D(`/profile/${u.artistUsername}`),className:"text-white/70 text-xs truncate drop-shadow-lg block max-w-full text-left hover:underline",children:u.artist||"Unknown Artist"}):e.jsx("p",{className:"text-white/70 text-xs truncate drop-shadow-lg",children:u.artist||"Unknown Artist"})]})]}),e.jsxs("div",{className:"flex flex-col items-end gap-1",children:[e.jsx(ds,{version:u.studio_version}),e.jsxs("div",{className:"flex items-center gap-1",children:[u.user_id&&e.jsx("button",{onClick:_r,className:"shrink-0 p-1.5 rounded-full transition-transform active:scale-90",title:jt?"Following artist":"Follow artist",children:jt?e.jsx(_s,{className:"w-4 h-4 drop-shadow-lg text-cyan-400"}):e.jsx(Xr,{className:"w-4 h-4 drop-shadow-lg text-white/70"})}),u.id&&e.jsx("div",{className:"shrink-0 [&_button]:text-white/70 [&_button:hover]:text-white [&_button]:hover:bg-white/10",children:e.jsx(bs,{trackId:u.id,size:16})}),u.id&&e.jsx("button",{onClick:()=>{if(!H){kt(!0);return}O(u.id)},className:"shrink-0 p-1.5 rounded-full transition-transform active:scale-90",title:"Like",children:e.jsx(Qr,{className:`w-5 h-5 drop-shadow-lg transition-colors ${A(u.id)?"text-pink-500 fill-pink-500":"text-white/70"}`})})]})]})]},`info-${u.audio_url}`)})})]})},(u==null?void 0:u.audio_url)||"empty")})})]}),e.jsx("div",{className:M?"shrink-0 relative px-3 h-[34%] max-h-[34%] overflow-hidden pointer-events-none":"flex-1 min-h-0 relative px-3 pointer-events-auto",children:e.jsx(Cs,{channelId:"podcast-chat-active",streamMode:M,onUsernameTap:(t,a)=>{var r;return(r=St.current)==null?void 0:r.call(St,t,a)}})}),M?e.jsx("div",{className:"shrink-0 h-[9%] w-full"}):e.jsx("div",{className:"shrink-0 z-40 bg-gradient-to-t from-black via-black/90 to-transparent pt-3 px-4 pb-[max(env(safe-area-inset-bottom),12px)] pointer-events-auto",children:e.jsx(Ms,{onLoginRequired:()=>kt(!0),onTopicSubmit:$?Cr:void 0,onReplyRef:St})})]}):e.jsx("div",{className:"flex-1 flex flex-col items-center justify-center px-6 py-6 gap-6",children:e.jsxs("div",{onClick:nn,className:"relative w-64 h-64 sm:w-72 sm:h-72 rounded-2xl overflow-hidden shadow-[0_0_60px_rgba(34,211,238,0.12)] cursor-pointer group",children:[q?e.jsx("img",{src:ht.url,alt:"Soné Top 20 countdown",className:"w-full h-full object-cover transition-transform duration-500 group-hover:scale-105",fetchPriority:"high"}):$?e.jsx("img",{src:"/__l5e/assets-v1/7a2c3f96-d2ef-44cf-8cd4-9d4f56596131/jake-gemma-live.png",alt:"Jake & Gemma",className:"w-full h-full object-cover transition-transform duration-500 group-hover:scale-105",loading:"lazy",decoding:"async"}):e.jsx(hn,{src:pn,poster:gn,className:"w-full h-full object-cover transition-transform duration-500 group-hover:scale-105"}),e.jsxs("div",{className:"absolute inset-0 bg-gradient-to-t from-black/80 via-black/30 to-transparent flex flex-col justify-end p-6",children:[e.jsx("span",{className:"text-foreground/80 text-sm font-medium leading-snug",children:q?"The Soné Top 20 is live":$?"Join the Jake & Gemma banter live":"Channel Sone is live"}),e.jsx("span",{className:"text-primary font-bold text-xl mt-1 animate-pulse drop-shadow-[0_0_12px_hsl(var(--primary)/0.6)]",children:"Tune in now"})]})]})})]}),new URLSearchParams(window.location.search).get("debug")==="1"&&e.jsxs("div",{className:"fixed bottom-2 right-2 z-[100] rounded-md bg-black/80 border border-white/15 px-2 py-1 font-mono text-[10px] leading-tight text-cyan-300 pointer-events-none",children:[e.jsxs("div",{children:["v3.1 · station ",P?"on":"off"," · hosts ",$?"on":"off"]}),e.jsxs("div",{children:["row ",ut.rowId??"none"," · ",ut.paused?"PAUSED":"playing"," · vol ",ut.vol," · rs ",ut.ready]}),e.jsxs("div",{children:["overlay ",Wt?"speaking":"idle"," · resync ",Rn?"yes":"no"," · fixes ",ut.fixes]})]})]})}export{ma 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.