PageSourceSearch

https://gobytv.com/assets/WatchParty-Ba1x_8eh.js

js gobytv.com collected 2026-10-05 19:23:51 UTC 9,863 bytes, 1 lines download raw bytes

1import{aj as $,ab as J,V as X,k as Y,r as l,a as p,ak as M,l as U,j as e,W as F,g as K,B as m,A as Z,s as f,T as ee,G as se,E as te,al as ae,U as re,J as R,X as ie,am as ne,q as le,M as ce,m as oe,n as de,a5 as me,h as d,t as z}from"./index-C4LWZPK9.js";import{C as ue}from"./crown-DjtBWkti.js";import{U as A}from"./users-DL5nkPsl.js";function j(a){if(!a||isNaN(a))return"0:00";const c=Math.floor(a/60),y=Math.floor(a%60);return`${c}:${y.toString().padStart(2,"0")}`}function fe(){var W;const{id:a}=$(),{user:c}=J()||{},y=X(),v=Y(),o=l.useRef(null),g=l.useRef(null),[u,N]=l.useState(""),[w,_]=l.useState(!1),[k,x]=l.useState(!1),[C,P]=l.useState(!1),[h,S]=l.useState(""),I=l.useRef(!1),{data:t}=p({queryKey:["watch-party",a],queryFn:()=>d.entities.WatchParty.filter({id:a}),select:s=>s[0],refetchInterval:3e3}),{data:n}=p({queryKey:["party-video",t==null?void 0:t.video_id],queryFn:()=>d.entities.VideoContent.filter({id:t==null?void 0:t.video_id}),select:s=>s[0],enabled:!!(t!=null&&t.video_id)}),{data:L=[]}=p({queryKey:["party-comments",a],queryFn:()=>d.entities.WatchPartyComment.filter({party_id:a},"created_date",200),refetchInterval:2e3}),r=(t==null?void 0:t.host_id)===(c==null?void 0:c.id);l.useEffect(()=>{const s=o.current;if(!s||!t||r)return;Math.abs(s.currentTime-(t.playback_position||0))>2&&(I.current=!0,s.currentTime=t.playback_position||0,setTimeout(()=>{I.current=!1},500)),t.is_playing&&s.paused&&s.play().catch(()=>{}),!t.is_playing&&!s.paused&&s.pause()},[t,r]),l.useEffect(()=>{const s=o.current;if(!(!s||!(n!=null&&n.video_url)))if(M.isSupported()&&n.video_url.includes(".m3u8")){const i=new M;return i.loadSource(n.video_url),i.attachMedia(s),()=>i.destroy()}else s.src=n.video_url},[n==null?void 0:n.video_url]),l.useEffect(()=>{var s;(s=g.current)==null||s.scrollIntoView({behavior:"smooth"})},[L.length]);const b=U({mutationFn:s=>d.entities.WatchParty.update(a,s),onSuccess:()=>v.invalidateQueries({queryKey:["watch-party",a]})}),Q=()=>{const s=o.current;s&&(s.play(),x(!0),r&&b.mutate({is_playing:!0,playback_position:s.currentTime,last_sync:new Date().toISOString()}))},B=()=>{const s=o.current;s&&(s.pause(),x(!1),r&&b.mutate({is_playing:!1,playback_position:s.currentTime,last_sync:new Date().toISOString()}))};l.useEffect(()=>{if(!r)return;const s=setInterval(()=>{const i=o.current;!i||i.paused||b.mutate({playback_position:i.currentTime,is_playing:!i.paused})},5e3);return()=>clearInterval(s)},[r]);const q=U({mutationFn:()=>{var s;return d.entities.WatchPartyComment.create({party_id:a,user_id:c.id,user_name:c.full_name||c.email,content:u.trim(),timestamp_seconds:((s=o.current)==null?void 0:s.currentTime)||0})},onSuccess:()=>{v.invalidateQueries({queryKey:["party-comments",a]}),N("")}}),H=s=>{s.preventDefault(),u.trim()&&q.mutate()},D=async()=>{await d.entities.WatchParty.update(a,{status:"ended"}),y("/goby-chat")},G=()=>{navigator.clipboard.writeText(window.location.href),_(!0),setTimeout(()=>_(!1),2e3),z.success("Link copied!")},{data:O=[]}=p({queryKey:["users-for-invite"],queryFn:()=>d.entities.User.list(),enabled:r&&C}),T=h.trim()?O.filter(s=>{var i,E;return s.id!==(c==null?void 0:c.id)&&!((t==null?void 0:t.invited_user_ids)||[]).includes(s.id)&&(((i=s.full_name)==null?void 0:i.toLowerCase().includes(h.toLowerCase()))||((E=s.email)==null?void 0:E.toLowerCase().includes(h.toLowerCase())))}).slice(0,5):[],V=async s=>{const i=(t==null?void 0:t.invited_user_ids)||[];await d.entities.WatchParty.update(a,{invited_user_ids:[...i,s.id]}),v.invalidateQueries({queryKey:["watch-party",a]}),z.success(`${s.full_name||s.email} invited!`),S("")};return t?t.status==="ended"?e.jsxs("div",{className:"flex flex-col items-center justify-center h-screen gap-4",children:[e.jsx(F,{className:"w-12 h-12 text-primary"}),e.jsx("h2",{className:"text-2xl font-display font-bold",children:"Watch Party Ended"}),e.jsx(K,{to:"/goby-chat",children:e.jsx(m,{className:"bg-primary hover:bg-primary/90",children:"Back to Goby Chat"})})]}):e.jsxs("div",{className:"pt-16 h-screen flex flex-col bg-background",children:[e.jsxs("div",{className:"flex items-center gap-3 px-4 py-2 border-b border-border bg-card shrink-0",children:[e.jsx(K,{to:"/goby-chat",children:e.jsx(m,{variant:"ghost",size:"icon",children:e.jsx(Z,{className:"w-4 h-4"})})}),e.jsxs("div",{className:"flex items-center gap-2 flex-1 min-w-0",children:[e.jsx(F,{className:"w-4 h-4 text-primary shrink-0"}),e.jsx("span",{className:"font-semibold truncate",children:t.video_title||"Watch Party"}),t.is_private?e.jsxs(f,{variant:"outline",className:"gap-1 shrink-0 text-xs",children:[e.jsx(ee,{className:"w-2.5 h-2.5"})," Private"]}):e.jsxs(f,{variant:"outline",className:"gap-1 shrink-0 text-xs",children:[e.jsx(se,{className:"w-2.5 h-2.5"})," Public"]}),r&&e.jsxs(f,{className:"bg-primary/20 text-primary border-primary/30 gap-1 shrink-0",children:[e.jsx(ue,{className:"w-2.5 h-2.5"})," Host"]})]}),e.jsxs(m,{variant:"outline",size:"sm",className:"gap-1.5 shrink-0",onClick:G,children:[w?e.jsx(te,{className:"w-3.5 h-3.5"}):e.jsx(ae,{className:"w-3.5 h-3.5"}),e.jsx("span",{className:"hidden sm:inline",children:w?"Copied!":"Copy Link"})]}),r&&e.jsxs(m,{variant:"outline",size:"sm",className:"gap-1.5 shrink-0",onClick:()=>P(s=>!s),children:[e.jsx(re,{className:"w-3.5 h-3.5"})," ",e.jsx("span",{className:"hidden sm:inline",children:"Invite"})]}),r&&e.jsx(m,{variant:"destructive",size:"sm",onClick:D,children:"End"})]}),r&&C&&e.jsxs("div",{className:"px-4 py-3 border-b border-border bg-card/80 backdrop-blur",children:[e.jsxs("div",{className:"flex items-center gap-2 max-w-sm",children:[e.jsxs("div",{className:"relative flex-1",children:[e.jsx(R,{autoFocus:!0,placeholder:"Search users to invite...",value:h,onChange:s=>S(s.target.value),className:"text-sm h-8"}),T.length>0&&e.jsx("div",{className:"absolute top-full left-0 right-0 z-20 mt-1 bg-popover border border-border rounded-lg shadow-lg overflow-hidden",children:T.map(s=>e.jsxs("button",{onClick:()=>V(s),className:"w-full flex items-center gap-2 px-3 py-2 text-sm hover:bg-secondary transition-colors text-left",children:[e.jsx("div",{className:"w-6 h-6 rounded-full bg-primary/20 flex items-center justify-center text-xs font-bold text-primary shrink-0",children:(s.full_name||s.email||"U")[0].toUpperCase()}),e.jsx("span",{className:"truncate",children:s.full_name||s.email})]},s.id))})]}),e.jsx("button",{onClick:()=>P(!1),className:"text-muted-foreground hover:text-foreground",children:e.jsx(ie,{className:"w-4 h-4"})})]}),t.is_private&&(t.invited_user_ids||[]).length>0&&e.jsxs("p",{className:"text-xs text-muted-foreground mt-2",children:[(t.invited_user_ids||[]).length," user(s) invited to this private party"]})]}),e.jsxs("div",{className:"flex flex-1 min-h-0",children:[e.jsx("div",{className:"flex-1 flex flex-col min-w-0 bg-black",children:e.jsxs("div",{className:"flex-1 flex items-center justify-center relative min-h-0",children:[e.jsx("video",{ref:o,className:"w-full h-full max-h-full object-contain",onPlay:()=>x(!0),onPause:()=>
1x(!1),playsInline:!0}),r&&e.jsxs("div",{className:"absolute bottom-4 left-1/2 -translate-x-1/2 flex items-center gap-3 bg-black/70 backdrop-blur rounded-full px-4 py-2",children:[e.jsx("button",{onClick:k?B:Q,className:"text-white hover:text-primary transition-colors",children:k?e.jsx(ne,{className:"w-6 h-6"}):e.jsx(le,{className:"w-6 h-6"})}),e.jsxs("span",{className:"text-white/70 text-xs font-mono",children:[j((W=o.current)==null?void 0:W.currentTime)," / ",j(n==null?void 0:n.duration_seconds)]}),e.jsx("span",{className:"text-xs text-primary",children:"Host controls"})]}),!r&&e.jsxs("div",{className:"absolute top-3 right-3 bg-black/60 rounded-lg px-3 py-1.5 text-xs text-white/70 flex items-center gap-1.5",children:[e.jsx(A,{className:"w-3 h-3"})," Synced to host"]})]})}),e.jsxs("div",{className:"w-80 shrink-0 flex flex-col border-l border-border bg-card",children:[e.jsxs("div",{className:"px-4 py-3 border-b border-border flex items-center gap-2",children:[e.jsx(ce,{className:"w-4 h-4 text-primary"}),e.jsx("span",{className:"font-semibold text-sm",children:"Live Chat"}),e.jsxs(f,{variant:"secondary",className:"ml-auto text-xs gap-1",children:[e.jsx(A,{className:"w-2.5 h-2.5"})," Live"]})]}),e.jsxs("div",{className:"flex-1 overflow-y-auto p-3 space-y-2 min-h-0",children:[e.jsx(oe,{initial:!1,children:L.map(s=>e.jsxs(de.div,{initial:{opacity:0,y:6},animate:{opacity:1,y:0},className:"flex gap-2",children:[e.jsx("div",{className:"w-6 h-6 rounded-full bg-primary/20 flex items-center justify-center text-xs font-bold text-primary shrink-0 mt-0.5",children:(s.user_name||"A")[0].toUpperCase()}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-baseline gap-1.5 flex-wrap",children:[e.jsx("span",{className:"text-xs font-semibold truncate",children:s.user_name||"Anon"}),s.timestamp_seconds>0&&e.jsxs("button",{onClick:()=>{r&&o.current&&(o.current.currentTime=s.timestamp_seconds)},className:"text-[10px] text-primary/70 hover:text-primary transition-colors font-mono shrink-0",title:r?"Jump to this moment":void 0,children:["@",j(s.timestamp_seconds)]})]}),e.jsx("p",{className:"text-xs text-foreground/80 leading-relaxed break-words",children:s.content})]})]},s.id))}),e.jsx("div",{ref:g})]}),e.jsxs("form",{onSubmit:H,className:"p-3 border-t border-border flex gap-2",children:[e.jsx(R,{value:u,onChange:s=>N(s.target.value),placeholder:"React at this moment...",className:"text-sm h-8",maxLength:200}),e.jsx(m,{type:"submit",size:"icon",className:"h-8 w-8 shrink-0 bg-primary hover:bg-primary/90",disabled:!u.trim()||q.isPending,children:e.jsx(me,{className:"w-3.5 h-3.5"})})]})]})]})]}):e.jsx("div",{className:"flex items-center justify-center h-screen",children:e.jsx("div",{className:"w-8 h-8 border-4 border-primary/30 border-t-primary rounded-full animate-spin"})})}export{fe 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.