PageSourceSearch

https://bowtiesports.com/assets/ProducerControlCenter-Ba54xL99.js

js bowtiesports.com collected 2026-10-07 02:29:30 UTC 51,497 bytes, 43 lines download raw bytes

1import{r as o,j as e}from"./react-vendor-DUhHROXo.js";import{d as Ke,b as Je,L as fe}from"./router-vendor-Dz9PdDzH.js";import{m as P,o as x,p as Pe,a5 as E,a6 as We,J as Ye,O as ve,aQ as Ze,a4 as Qe,w as Xe,x as Y,U as es}from"./index-BLtzf0SR.js";import{B as y}from"./badge-BsE4KYIf.js";import{C as Ee,b as ss,c as ts,a as Le}from"./card-9IoFUltb.js";import{S as B}from"./separator-DJ74LIPg.js";import{S as M}from"./scroll-area-BdyOmc9o.js";import{u as b}from"./index-Cx0UdoxP.js";import{j as as,d as rs,e as ns,k as is,h as os,g as ls,l as cs,f as ds,m as ms,n as us,i as xs}from"./useStudioSession-DgiicGBW.js";import{s as _}from"./client-DTel1CZI.js";import{u as hs}from"./useGuestLocalRecording-Dd6yupxC.js";import{M as Ae,C as ps,D as gs,a as fs}from"./CueOverlay-DRANTPxl.js";import{I as H}from"./input-RFokm5kN.js";import"./popover-CQ2o3wvr.js";import{a as vs,b as js,C as bs,S as Ns}from"./publicLinks-Dk_BypBw.js";import{M as Z}from"./music-BuAkZgP4.js";import{V as ws}from"./volume-2-CYbiOkRU.js";import{S as Me}from"./square-CIul4Yuk.js";import{P as Q}from"./plus-Db1qFqHY.js";import{T as se}from"./trash-2-cCh6Q5cl.js";import{T as ys}from"./type-DAarvy2e.js";import{Z as X}from"./zap-kZKB6UD3.js";import{T as ks}from"./timer-9y4I7E8e.js";import{C as Cs}from"./clock-DK72Hop1.js";import{C as V}from"./circle-check-PV1EE3Kr.js";import{S as Ss,e as _s,a as Rs,b as Ts,c as Ps}from"./sheet-SSeHD8GU.js";import{U as je}from"./users-CIwSfVhi.js";import{C as Es}from"./camera-BKoNWt3p.js";import{C as be}from"./copy-BN4qlSYJ.js";import{U as Ls}from"./user-plus-DB_6DvCc.js";import{P as As}from"./progress-DQIGmiuZ.js";import{C as Ne}from"./circle-alert-C1akQxLN.js";import{T as Ms}from"./triangle-alert-BE8FAob-.js";import{M as ee}from"./monitor-Cfk1nyiF.js";import{A as zs}from"./arrow-left-right-CN4TyiOa.js";import{R as Is}from"./rotate-ccw-DUJncSJJ.js";import{A as Us}from"./arrow-left-CRb8P6iH.js";import{R as $s}from"./radio-BQgeDg5T.js";import{H as we}from"./hard-drive-D3lPRAhw.js";import{S as Ds}from"./save-vrPqs9Xk.js";import{S as Gs}from"./sparkles-pO-GFKMR.js";import{L as Fs}from"./list-checks-CDwZS1Hv.js";import"./index-BdQq_4o_.js";import"./useMutation-BXp6BKyU.js";import"./refresh-cw-BBiwQZvS.js";/**
2 * @license lucide-react v0.462.0 - ISC
3 *
4 * This source code is licensed under the ISC license.
5 * See the LICENSE file in the root directory of this source tree.
6 */const Os=P("CaptionsOff",[["path",{d:"M10.5 5H19a2 2 0 0 1 2 2v8.5",key:"jqtk4d"}],["path",{d:"M17 11h-.5",key:"1961ue"}],["path",{d:"M19 19H5a2 2 0 0 1-2-2V7a2 2 0 0 1 2-2",key:"1keqsi"}],["path",{d:"m2 2 20 20",key:"1ooewy"}],["path",{d:"M7 11h4",key:"1o1z6v"}],["path",{d:"M7 15h2.5",key:"1ina1g"}]]);/**
7 * @license lucide-react v0.462.0 - ISC
8 *
9 * This source code is licensed under the ISC license.
10 * See the LICENSE file in the root directory of this source tree.
11 */const ye=P("Captions",[["rect",{width:"18",height:"14",x:"3",y:"5",rx:"2",ry:"2",key:"12ruh7"}],["path",{d:"M7 15h4M15 15h2M7 11h2M13 11h4",key:"1ueiar"}]]);/**
12 * @license lucide-react v0.462.0 - ISC
13 *
14 * This source code is licensed under the ISC license.
15 * See the LICENSE file in the root directory of this source tree.
16 */const Bs=P("Columns2",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M12 3v18",key:"108xh3"}]]);/**
17 * @license lucide-react v0.462.0 - ISC
18 *
19 * This source code is licensed under the ISC license.
20 * See the LICENSE file in the root directory of this source tree.
21 */const Hs=P("Hand",[["path",{d:"M18 11V6a2 2 0 0 0-2-2a2 2 0 0 0-2 2",key:"1fvzgz"}],["path",{d:"M14 10V4a2 2 0 0 0-2-2a2 2 0 0 0-2 2v2",key:"1kc0my"}],["path",{d:"M10 10.5V6a2 2 0 0 0-2-2a2 2 0 0 0-2 2v8",key:"10h0bg"}],["path",{d:"M18 8a2 2 0 1 1 4 0v6a8 8 0 0 1-8 8h-2c-2.8 0-4.5-.86-5.99-2.34l-3.6-3.6a2 2 0 0 1 2.83-2.82L7 15",key:"1s1gnw"}]]);/**
22 * @license lucide-react v0.462.0 - ISC
23 *
24 * This source code is licensed under the ISC license.
25 * See the LICENSE file in the root directory of this source tree.
26 */const Vs=P("Keyboard",[["path",{d:"M10 8h.01",key:"1r9ogq"}],["path",{d:"M12 12h.01",key:"1mp3jc"}],["path",{d:"M14 8h.01",key:"1primd"}],["path",{d:"M16 12h.01",key:"1l6xoz"}],["path",{d:"M18 8h.01",key:"emo2bl"}],["path",{d:"M6 8h.01",key:"x9i8wu"}],["path",{d:"M7 16h10",key:"wp8him"}],["path",{d:"M8 12h.01",key:"czm47f"}],["rect",{width:"20",height:"16",x:"2",y:"4",rx:"2",key:"18n3k1"}]]);/**
27 * @license lucide-react v0.462.0 - ISC
28 *
29 * This source code is licensed under the ISC license.
30 * See the LICENSE file in the root directory of this source tree.
31 */const ke=P("LayoutGrid",[["rect",{width:"7",height:"7",x:"3",y:"3",rx:"1",key:"1g98yp"}],["rect",{width:"7",height:"7",x:"14",y:"3",rx:"1",key:"6d4xhi"}],["rect",{width:"7",height:"7",x:"14",y:"14",rx:"1",key:"nxv5o0"}],["rect",{width:"7",height:"7",x:"3",y:"14",rx:"1",key:"1bb6yr"}]]);/**
32 * @license lucide-react v0.462.0 - ISC
33 *
34 * This source code is licensed under the ISC license.
35 * See the LICENSE file in the root directory of this source tree.
36 */const qs=P("Moon",[["path",{d:"M12 3a6 6 0 0 0 9 9 9 9 0 1 1-9-9Z",key:"a7tn18"}]]);/**
37 * @license lucide-react v0.462.0 - ISC
38 *
39 * This source code is licensed under the ISC license.
40 * See the LICENSE file in the root directory of this source tree.
41 */const Ks=P("Sun",[["circle",{cx:"12",cy:"12",r:"4",key:"4exip2"}],["path",{d:"M12 2v2",key:"tus03m"}],["path",{d:"M12 20v2",key:"1lh1kg"}],["path",{d:"m4.93 4.93 1.41 1.41",key:"149t6j"}],["path",{d:"m17.66 17.66 1.41 1.41",key:"ptbguv"}],["path",{d:"M2 12h2",key:"1t8f8n"}],["path",{d:"M20 12h2",key:"1q8mjw"}],["path",{d:"m6.34 17.66-1.41 1.41",key:"1m8zz5"}],["path",{d:"m19.07 4.93-1.41 1.41",key:"1shlcs"}]]);function Js(s){const[i,t]=o.useState({isRecording:!1,isUploading:!1,recordedBlob:null,uploadedUrl:null,error:null}),l=o.useRef(null),d=o.useRef([]),u=o.useRef(null),j=o.useCallback(async()=>{try{const c=await navigator.mediaDevices.getUserMedia({audio:{echoCancellation:!0,noiseSuppression:!0,sampleRate:48e3},video:!1});u.current=c,d.current=[];
41const a=MediaRecorder.isTypeSupported("audio/webm;codecs=opus")?"audio/webm;codecs=opus":MediaRecorder.isTypeSupported("audio/webm")?"audio/webm":"audio/mp4",m=new MediaRecorder(c,{mimeType:a,audioBitsPerSecond:128e3});m.ondataavailable=g=>{g.data.size>0&&d.current.push(g.data)},m.onstop=()=>{const g=new Blob(d.current,{type:a});t(v=>({...v,recordedBlob:g,isRecording:!1}))},m.start(5e3),l.current=m,t(g=>({...g,isRecording:!0,error:null,recordedBlob:null,uploadedUrl:null}))}catch(c){const a=c instanceof Error?c.message:"Failed to start local recording";t(m=>({...m,error:a})),console.error("Local recording error:",c)}},[]),p=o.useCallback(()=>{var c;((c=l.current)==null?void 0:c.state)==="recording"&&l.current.stop(),u.current&&(u.current.getTracks().forEach(a=>a.stop()),u.current=null)},[]),h=o.useCallback(async()=>{if(!i.recordedBlob)return b.error("No local recording to upload"),null;t(c=>({...c,isUploading:!0,error:null}));try{const c=`local-recording-${s}-${Date.now()}.webm`,a=`studio-recordings/${s}/${c}`,{error:m}=await _.storage.from("media").upload(a,i.recordedBlob,{contentType:i.recordedBlob.type,upsert:!1});if(m)throw m;const{data:g}=_.storage.from("media").getPublicUrl(a),v=g.publicUrl,{data:w}=await _.from("studio_sessions").select("local_recording_urls").eq("id",s).single(),f=[...(w==null?void 0:w.local_recording_urls)||[],v];return await _.from("studio_sessions").update({local_recording_urls:f}).eq("id",s),t(N=>({...N,isUploading:!1,uploadedUrl:v})),b.success("Local recording uploaded successfully"),v}catch(c){const a=c instanceof Error?c.message:"Upload failed";return t(m=>({...m,isUploading:!1,error:a})),b.error(`Upload failed: ${a}`),null}},[i.recordedBlob,s]);return{...i,startLocalRecording:j,stopLocalRecording:p,uploadLocalRecording:h}}function Ws(s){const[i,t]=o.useState([]),[l,d]=o.useState(!0);o.useEffect(()=>{if(!s){t([]),d(!1);return}let a=!1;(async()=>{const{data:v}=await _.from("studio_local_takes").select("*").eq("session_id",s);a||(t(v??[]),d(!1))})();const g=_.channel(`local-takes-${s}`).on("postgres_changes",{event:"*",schema:"public",table:"studio_local_takes",filter:`session_id=eq.${s}`},v=>{t(w=>{if(v.eventType==="DELETE")return w.filter(C=>C.id!==v.old.id);const r=v.new,f=w.findIndex(C=>C.id===r.id);if(f===-1)return[...w,r];const N=[...w];return N[f]=r,N})}).subscribe();return()=>{a=!0,_.removeChannel(g)}},[s]);const u=i.reduce((a,m)=>a+(m.total_bytes??0),0),j=i.reduce((a,m)=>a+(m.uploaded_bytes??0),0),p=u>0?Math.min(100,j/u*100):100,h=i.length===0||i.every(a=>a.status==="complete"||a.status==="stitched"),c=i.length===0||p>=95;return{takes:i,loading:l,overallPct:p,allComplete:h,safeToFinalize:c}}function Ys(s){const[i,t]=o.useState([]),l=o.useRef(null),d=o.useRef(new Map),u=o.useRef(0);o.useEffect(()=>(l.current||(l.current=new AudioContext),()=>{var p;cancelAnimationFrame(u.current),(p=l.current)==null||p.close().catch(()=>{}),l.current=null}),[]),o.useEffect(()=>{const p=l.current;if(!p)return;const h=new Set(s.map(c=>c.sessionId));for(const[c,a]of d.current.entries())if(!h.has(c)){try{a.source.disconnect()}catch{}d.current.delete(c)}for(const c of s)if(c.audioTrack&&!d.current.has(c.sessionId))try{const a=new MediaStream([c.audioTrack]),m=p.createMediaStreamSource(a),g=p.createAnalyser();g.fftSize=256,g.smoothingTimeConstant=.5,m.connect(g),d.current.set(c.sessionId,{analyser:g,source:m})}catch(a){console.warn("[useAudioLevels] Failed to create analyser for",c.sessionId,a)}},[s]),o.useEffect(()=>{const p=()=>{const h=[],c=new Uint8Array(128);for(const[a,{analyser:m}]of d.current.entries()){m.getByteFrequencyData(c);let g=0;for(let w=0;w<c.length;w++)g+=c[w];const v=g/c.length/255;h.push({sessionId:a,level:v})}for(const a of s)h.find(m=>m.sessionId===a.sessionId)||h.push({sessionId:a.sessionId,level:0});t(h),u.current=requestAnimationFrame(p)};return u.current=requestAnimationFrame(p),()=>cancelAnimationFrame(u.current)},[s]);const j=o.useCallback(p=>{var h;return((h=i.find(c=>c.sessionId===p))==null?void 0:h.level)??0},[i]);return{levels:i,getLevel:j}}function Zs(s,i=!0){const t=o.useCallback(l=>{var u,j,p,h,c,a,m,g,v,w;if(!i)return;const d=(j=(u=l.target)==null?void 0:u.tagName)==null?void 0:j.toLowerCase();if(!(d==="input"||d==="textarea"||d==="select")&&!((p=l.target)!=null&&p.isContentEditable))switch(l.key.toLowerCase()){case"m":l.preventDefault(),(h=s.muteAllGuests)==null||h.call(s);break;case"u":l.preventDefault(),(c=s.unmuteAllGuests)==null||c.call(s);break;case"r":l.preventDefault(),(a=s.toggleRecording)==null||a.call(s);break;case"l":l.preventDefault(),(m=s.cycleLayout)==null||m.call(s);break;case"c":l.preventDefault(),(g=s.sendCountdown)==null||g.call(s);break;case" ":s.takePreview&&(l.preventDefault(),s.takePreview());break;case"escape":l.preventDefault(),s.clearPreview?s.clearPreview():(v=s.stopAllSoundboard)==null||v.call(s);break;case"1":case"2":case"3":case"4":l.preventDefault(),(w=s.playSoundboardClip)==null||w.call(s,parseInt(l.key)-1);break}},[i,s]);o.useEffect(()=>(window.addEventListener("keydown",t),()=>window.removeEventListener("keydown",t)),[t])}const Ce="btsg.controlRoom.theme",Se="broadcast-dark";function Qs(){const[s,i]=o.useState(()=>{if(typeof window>"u")return Se;const u=window.localStorage.getItem(Ce);return u==="brand-light"||u==="broadcast-dark"?u:Se});o.useEffect(()=>{try{window.localStorage.setItem(Ce,s)}catch{}},[s]);const t=o.useCallback(u=>i(u),[]),l=o.useCallback(()=>i(u=>u==="broadcast-dark"?"brand-light":"broadcast-dark"),[]);return{theme:s,themeClass:s==="broadcast-dark"?"dark":"",setTheme:t,toggleTheme:l}}const _e={logoUrl:"",logoPosition:"top-right",logoScale:1,lowerThird:{enabled:!1,name:"",title:"",bgColor:"#1a1a2e",textColor:"#ffffff"},watermark:{enabled:!1,text:"BTSG",opacity:.15}};function ze({config:s}){const i={"top-left":"top-3 left-3","top-right":"top-3 right-3","bottom-left":"bottom-12 left-3","bottom-right":"bottom-12 right-3"};return e.jsxs(e.Fragment,{children:[s.logoUrl&&e.jsx("div",{className:`absolute ${i[s.logoPosition]} z-10 pointer-events-none`,children:e.jsx("img",{src:s.logoUrl,alt:"Logo",className:"h-8 w-auto object-contain drop-shadow-lg",style:{transform:`scale(${s.logoScale})`}})}),s.lowerThird.enabled&&s.lowerThird.name&&e.jsx("div",{className:"absolute bottom-3 left-3 right-3 z-10 pointer-events-none",children:e.jsxs("div",{className:"inline-block px-4 py-2 rounded-md shadow-lg",style:{backgroundColor:s.lowerThird.bgColor,color:s.lowerThird.textColor},children:[e.jsx("p",{className:"font-bold text-sm leading-tight",children:s.lowerThird.name}),s.lowerThird.title&&e.jsx("p",{className:"text-xs opacity-80",children:s.lowerThird.title})]})}),s.watermark.enabled&&s.watermark.text&&e.jsx("div",{className:"absolute inset-0 flex items-center justify-center z-10 pointer-events-none select-none",style:{opacity:s.watermark.opacity},children:e.jsx("span",{className:"text-white text-6xl font-bold rotate-[-30deg] tracking-widest",children:s.watermark.text})})]})}const Xs=[{id:"intro",name:"🎙️ Show Intro",url:""},{id:"outro",name:"🎵 Show Outro",url:""},{id:"transition",name:"🔄 Transition",url:""},{id:"applause",name:"👏 Applause",url:""}];function et({isOpen:s,onToggle:i}){const[t,l]=o.useState(Xs),[d,u]=o.useState(null),j=o.useRef(null),p=o.useRef(null),[h,c]=o.useState(null),a=o.useCallback((r,f)=>
41{const N=URL.createObjectURL(f);l(C=>C.map(k=>k.id===r?{...k,url:N,name:k.name||f.name}:k)),c(null)},[]),m=o.useCallback(r=>{if(!r.url)return;j.current&&(j.current.pause(),j.current.currentTime=0);const f=new Audio(r.url);f.onended=()=>u(null),f.play(),j.current=f,u(r.id)},[]),g=o.useCallback(()=>{j.current&&(j.current.pause(),j.current.currentTime=0),u(null)},[]),v=o.useCallback(()=>{const r=`custom-${Date.now()}`;l(f=>[...f,{id:r,name:"New Clip",url:""}]),c(r)},[]),w=o.useCallback(r=>{l(f=>f.filter(N=>N.id!==r))},[]);return e.jsxs("div",{className:"flex flex-col",children:[e.jsxs(x,{variant:"outline",size:"sm",onClick:i,children:[e.jsx(Z,{className:"h-4 w-4 mr-2"}),"Soundboard"]}),s&&e.jsxs("div",{className:"mt-2 border rounded-lg bg-background p-3 space-y-2",children:[e.jsxs("div",{className:"text-xs font-medium text-muted-foreground flex items-center gap-1",children:[e.jsx(ws,{className:"h-3 w-3"}),"Soundboard — click to load audio files, then play during session"]}),e.jsx("div",{className:"grid grid-cols-2 gap-2",children:t.map(r=>e.jsxs("div",{className:"flex items-center gap-1 p-2 border rounded bg-muted/30",children:[r.url?e.jsx(x,{variant:"ghost",size:"icon",className:"h-7 w-7 shrink-0",onClick:()=>d===r.id?g():m(r),children:d===r.id?e.jsx(Me,{className:"h-3.5 w-3.5 text-red-500"}):e.jsx(Pe,{className:"h-3.5 w-3.5"})}):e.jsx(x,{variant:"ghost",size:"icon",className:"h-7 w-7 shrink-0",onClick:()=>{var f;c(r.id),(f=p.current)==null||f.click()},children:e.jsx(Q,{className:"h-3.5 w-3.5"})}),e.jsx("span",{className:"text-xs truncate flex-1",children:r.name}),d===r.id&&e.jsx(y,{className:"bg-green-500/20 text-green-700 text-[10px] px-1",children:"PLAYING"}),r.id.startsWith("custom")&&e.jsx(x,{variant:"ghost",size:"icon",className:"h-5 w-5 text-muted-foreground hover:text-destructive",onClick:()=>w(r.id),children:e.jsx(se,{className:"h-3 w-3"})})]},r.id))}),e.jsxs(x,{variant:"ghost",size:"sm",className:"w-full text-xs",onClick:v,children:[e.jsx(Q,{className:"h-3 w-3 mr-1"}),"Add Custom Clip"]}),e.jsx("input",{ref:p,type:"file",accept:"audio/*",className:"hidden",onChange:r=>{var N;const f=(N=r.target.files)==null?void 0:N[0];f&&h&&a(h,f),r.target.value=""}})]})]})}function st({sessionId:s,isRecording:i,onTranscriptSave:t}){const[l,d]=o.useState(!1),[u,j]=o.useState([]),[p,h]=o.useState(!1),c=o.useRef(null),a=o.useRef(null),m=o.useRef(null),g=o.useRef(null);o.useEffect(()=>{const r=_.channel(`studio-transcript-${s}`,{config:{broadcast:{self:!0}}});return r.on("broadcast",{event:"transcript-line"},({payload:f})=>{j(N=>[...N,f])}).subscribe(),g.current=r,()=>{_.removeChannel(r)}},[s]),o.useEffect(()=>{c.current&&(c.current.scrollTop=c.current.scrollHeight)},[u]);const v=o.useCallback(async()=>{try{const r=await navigator.mediaDevices.getUserMedia({audio:!0}),f=new MediaRecorder(r,{mimeType:"audio/webm"}),N=[];f.ondataavailable=k=>{k.data.size>0&&N.push(k.data)},f.onstop=async()=>{if(N.length===0)return;const k=new Blob(N,{type:"audio/webm"});N.length=0,h(!0);try{const R=new FileReader;R.onloadend=async()=>{var z;const q=R.result.split(",")[1],{data:L,error:A}=await _.functions.invoke("transcribe-live-audio",{body:{audio_base64:q,session_id:s}});!A&&(L!=null&&L.text)&&((z=g.current)==null||z.send({type:"broadcast",event:"transcript-line",payload:{id:crypto.randomUUID(),text:L.text,timestamp:Date.now()}}))},R.readAsDataURL(k)}catch(R){console.error("Transcription error:",R)}finally{h(!1)}},a.current=f;const C=()=>{f.state==="recording"&&f.stop(),l&&f.start()};f.start(),m.current=setInterval(()=>{var k;((k=a.current)==null?void 0:k.state)==="recording"&&(a.current.stop(),setTimeout(()=>{if(a.current&&l)try{a.current.start()}catch{}},100))},1e4),d(!0)}catch(r){console.error("Failed to start transcription:",r)}},[s,l]),w=o.useCallback(()=>{var r,f;((r=a.current)==null?void 0:r.state)==="recording"&&a.current.stop(),(f=a.current)!=null&&f.stream&&a.current.stream.getTracks().forEach(N=>N.stop()),m.current&&(clearInterval(m.current),m.current=null),d(!1)},[]);return o.useEffect(()=>()=>{w()},[]),!i&&!l&&u.length===0?null:e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("h4",{className:"text-sm font-medium flex items-center gap-1.5",children:[e.jsx(ye,{className:"h-4 w-4"}),"Live Captions"]}),l&&e.jsxs(y,{className:"bg-green-500/20 text-green-700 text-xs",children:[p?e.jsx(E,{className:"h-3 w-3 animate-spin mr-1"}):null,"ACTIVE"]})]}),i&&e.jsxs("div",{className:"flex items-center gap-1.5",children:[u.length>0&&t&&e.jsx(x,{variant:"outline",size:"sm",onClick:()=>t(u.map(r=>r.text).join(`
42`)),children:"Save Transcript"}),e.jsx(x,{variant:"outline",size:"sm",onClick:l?w:v,children:l?e.jsxs(e.Fragment,{children:[e.jsx(Os,{className:"h-3.5 w-3.5 mr-1"}),"Stop Captions"]}):e.jsxs(e.Fragment,{children:[e.jsx(ye,{className:"h-3.5 w-3.5 mr-1"}),"Start Captions"]})})]})]}),u.length>0&&e.jsx(M,{className:"h-32 border rounded-md bg-muted/30 p-3",ref:c,children:e.jsx("div",{className:"space-y-1",children:u.map(r=>e.jsxs("p",{className:"text-sm text-foreground",children:[e.jsx("span",{className:"text-xs text-muted-foreground mr-2",children:new Date(r.timestamp).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",second:"2-digit"})}),r.text]},r.id))})})]})}
42const Re="mpm-studio-scene-presets",Te=[{id:"host",label:"Host",name:"D. Orlando Ledbetter",title:"Host, Bow Tie Sports Podcast",bgColor:"#1a1a2e",textColor:"#ffffff"},{id:"guest-1",label:"Guest",name:"",title:"Guest",bgColor:"#1a1a2e",textColor:"#ffffff"}];function tt({activePresetId:s,onActivate:i,onDeactivate:t}){const[l,d]=o.useState(()=>{try{const a=localStorage.getItem(Re);return a?JSON.parse(a):Te}catch{return Te}}),[u,j]=o.useState(null);o.useEffect(()=>{localStorage.setItem(Re,JSON.stringify(l))},[l]);const p=(a,m)=>{d(g=>g.map(v=>v.id===a?{...v,...m}:v))},h=()=>{const a=`preset-${Date.now()}`,m={id:a,label:"New",name:"",title:"",bgColor:"#1a1a2e",textColor:"#ffffff"};d(g=>[...g,m]),j(a)},c=a=>{s===a&&t(),d(m=>m.filter(g=>g.id!==a))};return e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("h4",{className:"text-xs font-semibold flex items-center gap-1.5",children:[e.jsx(ys,{className:"h-3.5 w-3.5"}),"Lower Third Presets"]}),e.jsxs(x,{variant:"ghost",size:"sm",className:"h-6 text-xs px-2",onClick:h,children:[e.jsx(Q,{className:"h-3 w-3 mr-1"}),"Add"]})]}),e.jsx("div",{className:"space-y-1.5",children:l.map(a=>e.jsx("div",{className:`flex items-center gap-1.5 p-1.5 rounded border text-xs ${s===a.id?"border-primary bg-primary/10":"border-border"}`,children:u===a.id?e.jsxs("div",{className:"flex-1 space-y-1",children:[e.jsx(H,{value:a.name,onChange:m=>p(a.id,{name:m.target.value}),placeholder:"Name",className:"h-6 text-xs"}),e.jsx(H,{value:a.title,onChange:m=>p(a.id,{title:m.target.value}),placeholder:"Title",className:"h-6 text-xs"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("input",{type:"color",value:a.bgColor,onChange:m=>p(a.id,{bgColor:m.target.value}),className:"w-5 h-5 rounded cursor-pointer border-0"}),e.jsx("input",{type:"color",value:a.textColor,onChange:m=>p(a.id,{textColor:m.target.value}),className:"w-5 h-5 rounded cursor-pointer border-0"}),e.jsx(x,{variant:"ghost",size:"sm",className:"h-5 text-[10px] px-1.5",onClick:()=>j(null),children:"Done"})]})]}):e.jsxs(e.Fragment,{children:[e.jsxs(x,{variant:"ghost",size:"sm",className:"h-6 flex-1 justify-start text-xs px-1.5",onClick:()=>{s===a.id?t():i(a)},children:[e.jsx("div",{className:"w-2 h-2 rounded-full mr-1.5 shrink-0",style:{backgroundColor:a.bgColor}}),e.jsx("span",{className:"truncate",children:a.name||a.label}),s===a.id&&e.jsx(y,{className:"bg-primary/20 text-primary text-[9px] h-3.5 px-1 ml-auto",children:"LIVE"})]}),e.jsx(x,{variant:"ghost",size:"icon",className:"h-5 w-5 shrink-0",onClick:()=>j(a.id),children:e.jsx(We,{className:"h-3 w-3"})}),e.jsx(x,{variant:"ghost",size:"icon",className:"h-5 w-5 shrink-0 text-muted-foreground hover:text-destructive",onClick:()=>c(a.id),children:e.jsx(se,{className:"h-3 w-3"})})]})},a.id))})]})}function at({sessionId:s}){const i=o.useCallback(async t=>{try{const l=_.channel(`studio-cues-${s}`);await l.subscribe(),await l.send({type:"broadcast",event:"producer-cue",payload:{cueType:t,timestamp:Date.now()}}),_.removeChannel(l),b.success(`Cue sent: ${t.replace("_"," ").toUpperCase()}`)}catch(l){console.error("[ProducerCuePanel] Failed to send cue:",l),b.error("Failed to send cue")}},[s]);return e.jsxs("div",{className:"space-y-2",children:[e.jsxs("h4",{className:"text-xs font-semibold flex items-center gap-1.5",children:[e.jsx(X,{className:"h-3.5 w-3.5"}),"Producer Cues",e.jsx(y,{variant:"outline",className:"text-[9px] h-3.5 px-1",children:e.jsx("kbd",{className:"font-mono",children:"C"})})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-1.5",children:[e.jsxs(x,{variant:"outline",size:"sm",className:"h-8 text-xs gap-1.5 bg-green-500/10 hover:bg-green-500/20 border-green-500/30",onClick:()=>i("countdown"),children:[e.jsx(ks,{className:"h-3.5 w-3.5"}),"3-2-1 GO"]}),e.jsxs(x,{variant:"outline",size:"sm",className:"h-8 text-xs gap-1.5 bg-primary/10 hover:bg-primary/20 border-primary/30",onClick:()=>i("go"),children:[e.jsx(X,{className:"h-3.5 w-3.5"}),"GO"]}),e.jsxs(x,{variant:"outline",size:"sm",className:"h-8 text-xs gap-1.5 bg-yellow-500/10 hover:bg-yellow-500/20 border-yellow-500/30",onClick:()=>i("wrap_up"),children:[e.jsx(Hs,{className:"h-3.5 w-3.5"}),"Wrap Up"]}),e.jsxs(x,{variant:"outline",size:"sm",className:"h-8 text-xs gap-1.5 bg-red-500/10 hover:bg-red-500/20 border-red-500/30",onClick:()=>i("youre_muted"),children:[e.jsx(Ae,{className:"h-3.5 w-3.5"}),"You're Muted"]}),e.jsxs(x,{variant:"outline",size:"sm",className:"h-8 text-xs gap-1.5 col-span-2",onClick:()=>i("stand_by"),children:[e.jsx(Cs,{className:"h-3.5 w-3.5"}),"Stand By"]})]})]})}function rt({episodeId:s,sessionTitle:i}){const[t,l]=o.useState(new Set),{data:d,isLoading:u}=Ye({queryKey:["episode-plan",s],enabled:!!s,queryFn:async()=>{const{data:h,error:c}=await _.from("episode_plans").select("title, segments, notes, description").eq("episode_id",s).maybeSingle();if(c)throw c;return h}}),j=(()=>
42{if(!(d!=null&&d.segments))return[];try{const h=typeof d.segments=="string"?JSON.parse(d.segments):d.segments;return Array.isArray(h)?h:[]}catch{return[]}})(),p=h=>{l(c=>{const a=new Set(c);return a.has(h)?a.delete(h):a.add(h),a})};return s?u?e.jsxs("div",{className:"flex items-center gap-2 text-xs text-muted-foreground",children:[e.jsx(E,{className:"h-3 w-3 animate-spin"}),"Loading rundown..."]}):e.jsxs("div",{className:"space-y-2",children:[e.jsxs("h4",{className:"text-xs font-semibold flex items-center gap-1.5",children:[e.jsx(ve,{className:"h-3.5 w-3.5"}),"Rundown",j.length>0&&e.jsxs(y,{variant:"outline",className:"text-[9px] h-3.5 px-1",children:[t.size,"/",j.length]})]}),(d==null?void 0:d.description)&&e.jsx("p",{className:"text-xs text-muted-foreground bg-muted/30 rounded p-2",children:d.description}),j.length>0?e.jsx("div",{className:"space-y-1",children:j.map((h,c)=>e.jsxs("button",{onClick:()=>p(c),className:`w-full flex items-center gap-2 p-1.5 rounded text-xs text-left transition-colors ${t.has(c)?"bg-green-500/10 text-muted-foreground line-through":"bg-muted/30 hover:bg-muted/50"}`,children:[t.has(c)?e.jsx(V,{className:"h-3.5 w-3.5 text-green-600 shrink-0"}):e.jsx(Ze,{className:"h-3.5 w-3.5 text-muted-foreground shrink-0"}),e.jsx("span",{className:"flex-1 truncate",children:h.title}),h.duration_minutes&&e.jsxs("span",{className:"text-[10px] text-muted-foreground shrink-0",children:[h.duration_minutes,"m"]})]},c))}):e.jsx("p",{className:"text-xs text-muted-foreground p-2 bg-muted/30 rounded",children:d?"No segments defined in the episode plan.":"Episode plan not found."}),(d==null?void 0:d.notes)&&e.jsxs("div",{className:"text-xs text-muted-foreground p-2 bg-muted/30 rounded border-l-2 border-primary/30",children:[e.jsx("span",{className:"font-medium",children:"Notes:"})," ",d.notes]})]}):e.jsxs("div",{className:"space-y-2",children:[e.jsxs("h4",{className:"text-xs font-semibold flex items-center gap-1.5",children:[e.jsx(ve,{className:"h-3.5 w-3.5"}),"Session Rundown"]}),e.jsxs("div",{className:"text-xs text-muted-foreground p-2 bg-muted/30 rounded",children:[e.jsx("p",{className:"font-medium",children:i||"Standalone Session"}),e.jsx("p",{className:"mt-1",children:"No episode plan linked. Use Episode Planning to attach a rundown."})]})]})}function nt({level:s,label:i,compact:t=!1}){const l=Math.min(s*100,100),d=l>80?"bg-red-500":l>50?"bg-yellow-500":l>5?"bg-green-500":"bg-green-500/30";return t?e.jsx("div",{className:"flex items-center gap-1.5 min-w-[60px]",children:e.jsx("div",{className:"flex-1 h-1.5 bg-muted rounded-full overflow-hidden",children:e.jsx("div",{className:`h-full ${d} transition-all duration-75 rounded-full`,style:{width:`${l}%`}})})}):e.jsxs("div",{className:"flex items-center gap-2",children:[i&&e.jsx("span",{className:"text-xs text-muted-foreground truncate w-20",children:i}),e.jsx("div",{className:"flex-1 h-2 bg-muted rounded-full overflow-hidden",children:e.jsx("div",{className:`h-full ${d} transition-all duration-75 rounded-full`,style:{width:`${l}%`}})}),e.jsx("span",{className:"text-[10px] text-muted-foreground w-6 text-right font-mono",children:Math.round(l)})]})}function it({sessionId:s,hostJoinCode:i,guests:t,guestName:l,guestEmail:d,onGuestNameChange:u,onGuestEmailChange:j,onInvite:p,inviteDisabled:h,onAdmit:c,onRemove:a,onToggleMute:m,onToggleCamera:g,getAudioLevel:v}){const w=t.filter(r=>r.status==="waiting"&&!r.is_admitted).length;return e.jsxs(Ss,{children:[e.jsx(_s,{asChild:!0,children:e.jsxs(x,{variant:"outline",size:"sm",className:"gap-1.5 relative",children:[e.jsx(je,{className:"h-3.5 w-3.5"}),e.jsx("span",{className:"text-xs",children:"Guests"}),e.jsxs(y,{variant:"secondary",className:"h-4 px-1 text-[10px]",children:[t.length,"/4"]}),w>0&&e.jsxs("span",{className:"absolute -top-1 -right-1 flex h-2.5 w-2.5",children:[e.jsx("span",{className:"animate-ping absolute inline-flex h-full w-full rounded-full bg-accent opacity-75"}),e.jsx("span",{className:"relative inline-flex rounded-full h-2.5 w-2.5 bg-accent"})]})]})}),e.jsxs(Rs,{side:"right",className:"w-[360px] sm:w-[400px] flex flex-col p-0",children:[e.jsx(Ts,{className:"px-4 py-3 border-b",children:e.jsxs(Ps,{className:"flex items-center gap-2 text-base",children:[e.jsx(je,{className:"h-4 w-4"}),"Guests & Lobby"]})}),e.jsx(M,{className:"flex-1",children:e.jsxs("div",{className:"p-3 space-y-2",children:[t.length===0&&e.jsx("p",{className:"text-xs text-muted-foreground text-center py-6",children:"No guests yet. Invite below to send a join link."}),t.map(r=>e.jsxs("div",{className:"p-2 bg-muted/30 rounded-lg space-y-1.5",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[r.status==="waiting"&&!r.is_admitted&&e.jsxs("span",{className:"relative flex h-2.5 w-2.5",title:"In waiting room",children:[e.jsx("span",{className:"animate-ping absolute inline-flex h-full w-full rounded-full bg-accent opacity-75"}),e.jsx("span",{className:"relative inline-flex rounded-full h-2.5 w-2.5 bg-accent"})]}),e.jsx("span",{className:"text-xs font-medium",children:r.guest_name}),e.jsx(y,{variant:"outline",className:"text-[9px] h-4 px-1",children:r.status==="waiting"?"READY":r.status.toUpperCase()})]}),e.jsxs("div",{className:"flex items-center gap-0.5",children:[r.is_admitted&&r.status==="joined"&&e.jsxs(e.Fragment,{children:[e.jsx(x,{variant:"ghost",size:"icon",className:`h-6 w-6 ${r.remote_mute_audio?"text-destructive":"text-muted-foreground"}`,onClick:()=>m(r,!r.remote_mute_audio),title:r.remote_mute_audio?"Unmute":"Mute",children:r.remote_mute_audio?e.jsx(Ae,{className:"h-3 w-3"}):e.jsx(Qe,{className:"h-3 w-3"})}),e.jsx(x,{variant:"ghost",size:"icon",className:`h-6 w-6 ${r.remote_mute_video?"text-destructive":"text-muted-foreground"}`,onClick:()=>g(r),title:r.remote_mute_video?"Enable camera":"Disable camera",children:r.remote_mute_video?e.jsx(ps,{className:"h-3 w-3"}):e.jsx(Es,{className:"h-3 w-3"})})]}),!r.is_admitted&&(r.status==="invited"||r.status==="waiting")&&e.jsx(y,{variant:"outline",className:"text-[9px] h-5 px-1.5 text-muted-foreground",children:"Waiting for guest"}),e.jsx(x,{variant:"ghost",size:"icon",className:"h-6 w-6 text-muted-foreground hover:text-destructive",onClick:()=>a(r),title:"Remove",children:e.jsx(se,{className:"h-3 w-3"})})]})]}),r.is_admitted&&r.status==="joined"&&e.jsx(nt,{level:v(r.id),compact:!0}),e.jsxs(x,{variant:"ghost",size:"sm",className:"h-5 text-[10px] px-1.5 text-muted-foreground",onClick:()=>{navigator.clipboard.writeText(vs(r.join_code)),b.success("Join link copied")},children:[e.jsx(be,{className:"h-2.5 w-2.5 mr-1"}),r.join_code]})]},r.id)),t.length<4&&e.jsxs("div",{className:"space-y-1.5 pt-3 border-t",children:[e.jsx("p",{className:"text-[11px] font-semibold text-muted-foreground uppercase tracking-wide",children:"Invite a guest"}
42),e.jsx(H,{placeholder:"Guest name",value:l,onChange:r=>u(r.target.value),className:"h-8 text-xs"}),e.jsx(H,{placeholder:"Email (optional)",value:d,onChange:r=>j(r.target.value),className:"h-8 text-xs"}),e.jsxs(x,{size:"sm",className:"w-full h-8 text-xs",onClick:p,disabled:h,children:[e.jsx(Ls,{className:"h-3 w-3 mr-1"}),"Invite Guest"]})]}),e.jsxs(x,{variant:"ghost",size:"sm",className:"w-full h-7 text-xs text-muted-foreground",onClick:()=>{if(!i){b.error("Session has no host code — recreate session");return}navigator.clipboard.writeText(js(i)),b.success("One-click host link copied")},children:[e.jsx(be,{className:"h-3 w-3 mr-1"}),"Copy Host Link"]})]})})]})]})}function ot(s){if(s.fallback_to_cloud)return{level:"amber",label:"Cloud fallback",Icon:bs};if(s.status==="failed")return{level:"red",label:"Failed",Icon:Ne};const i=s.total_bytes>0?s.uploaded_bytes/s.total_bytes*100:100;return i>=95?{level:"green",label:"Healthy",Icon:V}:i>=70?{level:"amber",label:"Lagging",Icon:Ms}:{level:"red",label:"Critical",Icon:Ne}}function lt({takes:s}){return s.length===0?null:e.jsxs(Ee,{className:"border-border/60",children:[e.jsx(ss,{className:"pb-3",children:e.jsxs(ts,{className:"text-sm font-display flex items-center gap-2",children:[e.jsx(V,{className:"h-4 w-4"}),"Recording Health"]})}),e.jsx(Le,{className:"space-y-3",children:s.map(i=>{const t=ot(i),l=i.total_bytes>0?Math.min(100,Math.round(i.uploaded_bytes/i.total_bytes*100)):0,d=t.Icon,u=t.level==="green"?"text-green-500":t.level==="amber"?"text-amber-500":"text-destructive";return e.jsxs("div",{className:"rounded-md border border-border/40 p-3 space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(d,{className:`h-4 w-4 ${u}`}),e.jsx("span",{className:"text-sm font-medium",children:i.participant_name??i.participant_id.slice(0,8)}),e.jsx(y,{variant:"outline",className:"text-xs capitalize",children:i.participant_role})]}),e.jsx("span",{className:`text-xs font-mono ${u}`,children:t.label})]}),e.jsx(As,{value:l,className:"h-1.5"}),e.jsxs("div",{className:"flex items-center justify-between text-xs text-muted-foreground",children:[e.jsxs("span",{children:[i.uploaded_chunks,"/",i.total_chunks," chunks"]}),e.jsxs("span",{children:[l,"%"]})]}),i.fallback_reason&&e.jsx("p",{className:"text-xs text-amber-500",children:i.fallback_reason}),i.error_message&&e.jsx("p",{className:"text-xs text-destructive",children:i.error_message})]},i.id)})})]})}function ct({config:s,programThumbnailUrl:i}){return e.jsxs("div",{className:"relative h-full w-full bg-black overflow-hidden",children:[e.jsx("div",{className:"absolute inset-0 flex items-center justify-center",children:i?e.jsx("img",{src:i,alt:"Program reference",className:"h-full w-full object-cover opacity-60"}):e.jsxs("div",{className:"text-center text-muted-foreground/50",children:[e.jsx(ee,{className:"h-10 w-10 mx-auto mb-3 opacity-40"}),e.jsx("p",{className:"text-xs",children:"Staging canvas"}),e.jsx("p",{className:"text-[10px] mt-1 opacity-70",children:"Compose overlays & scenes — press TAKE to push live"})]})}),e.jsx(ze,{config:s}),e.jsx("div",{className:"absolute inset-0 flex items-center justify-center pointer-events-none select-none z-20",children:e.jsx("span",{className:"text-accent/15 text-7xl font-bold rotate-[-20deg] tracking-widest",children:"PREVIEW"})})]})}function dt({previewDirty:s,onTake:i,onClear:t}){return e.jsxs("div",{className:"flex items-center justify-center gap-2 px-3 py-1.5 border-y bg-card shrink-0",children:[e.jsxs(x,{size:"sm",variant:"destructive",className:"h-8 px-4 text-xs font-bold tracking-wider gap-1.5",onClick:i,title:"TAKE — swap Preview to Program (Space)",children:[e.jsx(zs,{className:"h-3.5 w-3.5"}),"TAKE"]}),e.jsxs(x,{size:"sm",variant:"outline",className:"h-8 px-3 text-xs font-semibold tracking-wider gap-1.5 opacity-50 cursor-not-allowed",disabled:!0,title:"AUTO fade — coming in Phase 3",children:[e.jsx(X,{className:"h-3.5 w-3.5"}),"AUTO"]}),e.jsxs(x,{size:"sm",variant:"ghost",className:"h-8 px-3 text-xs gap-1.5",onClick:t,title:"Clear preview — match program (Esc)",children:[e.jsx(Is,{className:"h-3.5 w-3.5"}),"Clear"]}),s&&e.jsxs(y,{variant:"outline",className:"h-6 px-2 text-[10px] gap-1 border-accent/50 text-accent animate-pulse",children:[e.jsx("span",{className:"h-1.5 w-1.5 rounded-full bg-accent"}),"Preview ≠ Program"]}),e.jsxs("span",{className:"text-[10px] text-muted-foreground ml-2",children:[e.jsx("kbd",{className:"bg-muted px-1.5 py-0.5 rounded font-mono",children:"Space"})," TAKE",e.jsx("span",{className:"mx-1.5",children:"·"}),e.jsx("kbd",{className:"bg-muted px-1.5 py-0.5 rounded font-mono",children:"Esc"})," Clear"]})]})}function ta(){const{sessionId:s}=Ke(),i=Je(),{data:t,isLoading:l}=as(s),{data:d=[]}=rs(s),u=ns(),j=is(),p=os(),h=ls(),c=cs(),a=ds(),m=ms(),g=us(),v=Js(s||""),{theme:w,themeClass:r,toggleTheme:f}=Qs(),{user:N}=Xe(),C=xs(),k=o.useRef(new Set),R=!!t&&(t.room_url==="pending"||!t.producer_token);o.useEffect(()=>{t!=null&&t.id&&R&&!k.current.has(t.id)&&!C.isPending&&(k.current.add(t.id),C.mutate({session_id:t.
42id},{onError:n=>{k.current.delete(t.id),b.error(`Provision failed: ${n.message}`)}}))},[t==null?void 0:t.id,R,C]);const q=!!t&&t.status!=="live"&&t.status!=="recording",L=()=>{if(!t)return;const n=!!t.producer_token&&t.room_url!=="pending";n&&!confirm("Re-provision the room? Anyone currently connected will be disconnected.")||C.mutate({session_id:t.id},{onSuccess:()=>b.success(n?"Room re-provisioned":"Room provisioned"),onError:S=>b.error(`Provision failed: ${S.message}`)})},{takes:A,overallPct:z,safeToFinalize:U}=Ws(s);hs({sessionId:s,participantId:N==null?void 0:N.id,participantName:"Producer",participantRole:"producer",enabled:!!(s&&(N!=null&&N.id)&&(t==null?void 0:t.status)==="live")});const[$,D]=o.useState("grid"),[K,Ie]=o.useState(!1),[G,te]=o.useState(_e),[F,ae]=o.useState(_e),[Ue,re]=o.useState(null),[J,ne]=o.useState("preview"),[I,ie]=o.useState(""),[O,oe]=o.useState(""),[le,$e]=o.useState(!1),[ce,De]=o.useState(!1),de=JSON.stringify(F)!==JSON.stringify(G),me=o.useRef(null),T=(t==null?void 0:t.status)==="live",W=t?["scheduled","pre_flight","live"].includes(t.status):!1,{getLevel:Ge}=Ys(d.filter(n=>n.is_admitted&&n.status==="joined").map(n=>({sessionId:n.id,audioTrack:null}))),Fe=o.useCallback(()=>{d.filter(n=>n.is_admitted&&!n.remote_mute_audio).forEach(n=>{m.mutate({guestId:n.id,muteAudio:!0})}),b.success("All guests muted")},[d,m]),Oe=o.useCallback(()=>{d.filter(n=>n.is_admitted&&n.remote_mute_audio).forEach(n=>{m.mutate({guestId:n.id,muteAudio:!1})}),b.success("All guests unmuted")},[d,m]),Be=o.useCallback(()=>{D(n=>{const S=["grid","speaker","split"];return S[(S.indexOf(n)+1)%S.length]})},[]),ue=async()=>{if(t)try{await c.mutateAsync(K?{sessionId:t.id,multiTrack:!0}:t.id),b.success(K?"LIVE — Multi-track recording started!":"LIVE — Recording started!")}catch(n){b.error(n.message||"Failed to start recording")}},xe=async()=>{if(t){if(!U){b.error(`Hold up — local recordings are still uploading (${Math.round(z)}%). Wait for ≥ 95% before ending.`);return}try{await p.mutateAsync({session_id:t.id});try{await _.functions.invoke("stitch-local-takes",{body:{session_id:t.id}}),b.success("Recording finalized — stitching local takes in background")}catch(n){console.warn("[stitch-local-takes] invocation failed:",n),b.success("Recording finalized — stitching will retry")}setTimeout(()=>i("/admin/recording-studio"),600)}catch(n){b.error(n.message)}}},He=async()=>{if(!(!I.trim()||!t))try{await u.mutateAsync({session_id:t.id,guest_name:I.trim(),guest_email:O.trim()||void 0}),b.success(O.trim()?`Invite sent to ${O}`:`Invite created for ${I}`),ie(""),oe("")}catch(n){b.error(n.message)}},he=J==="program"?te:ae,Ve=n=>{re(n.id),he(S=>({...S,lowerThird:{enabled:!0,name:n.name,title:n.title,bgColor:n.bgColor,textColor:n.textColor}}))},qe=()=>{re(null),he(n=>({...n,lowerThird:{...n.lowerThird,enabled:!1}}))},pe=o.useCallback(()=>{te(F),b.success("TAKE — preview pushed to program")},[F]),ge=o.useCallback(()=>{ae(G),b.message("Preview cleared — matches program")},[G]);return Zs({muteAllGuests:Fe,unmuteAllGuests:Oe,toggleRecording:T?xe:ue,cycleLayout:Be,sendCountdown:void 0,playSoundboardClip:n=>{var S;return(S=me.current)==null?void 0:S.playClip(n)},stopAllSoundboard:()=>{var n;return(n=me.current)==null?void 0:n.stopAll()},takePreview:pe,clearPreview:de?ge:void 0},W),l?e.jsx("div",{className:`${r} flex items-center justify-center min-h-screen bg-background`,children:e.jsx(E,{className:"h-8 w-8 animate-spin text-muted-foreground"})}):t?e.jsxs("div",{className:`${r} h-screen flex flex-col bg-background text-foreground overflow-hidden`,children:[e.jsxs("div",{className:"flex items-center justify-between px-3 py-1.5 border-b bg-card shrink-0 gap-2",children:[e.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[e.jsx(x,{variant:"ghost",size:"sm",asChild:!0,className:"h-7 px-2",title:"Return to sessions list",children:e.jsxs(fe,{to:"/admin/recording-studio",children:[e.jsx(Us,{className:"h-3.5 w-3.5 mr-1"}),e.jsx("span",{className:"text-xs",children:"Sessions"})]})}),e.jsx(B,{orientation:"vertical",className:"h-5"}),e.jsx("span",{className:"font-display font-bold text-sm truncate max-w-[180px]",children:t.title||t.room_name}),T&&e.jsxs(e.Fragment,{children:[e.jsxs(y,{className:"bg-destructive text-destructive-foreground animate-pulse h-5 px-1.5 text-[10px] gap-1",children:[e.jsx($s,{className:"h-2.5 w-2.5"}),"LIVE"]}),e.jsxs(y,{variant:"outline",className:"border-destructive/40 text-destructive h-5 px-1.5 text-[10px] gap-1",children:[e.jsx("span",{className:"h-1.5 w-1.5 rounded-full bg-destructive inline-block animate-pulse"}),"REC"]}),e.jsx(Ns,{isRunning:!0,startedAt:t.started_at})]}),t.status==="pre_flight"&&e.jsx(y,{variant:"outline",className:"bg-accent/20 text-accent-foreground border-accent/40 h-5 px-1.5 text-[10px]",children:"Pre-Flight"}),t.status==="scheduled"&&e.jsx(y,{variant:"outline",className:"h-5 px-1.5 text-[10px]",children:"Scheduled"})]}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(x,{variant:R?"default":"outline",size:"sm",className:"h-7 px-2 text-xs",onClick:L,disabled:C.isPending||!q,title:R?"Create Daily room for this session":"Re-create the Daily room (disconnects everyone)",children:C.isPending?e.jsxs(e.Fragment,{children:[e.jsx(E,{className:"h-3 w-3 mr-1 animate-spin"})," Provisioning…"]}):R?e.jsxs(e.Fragment,{children:[e.jsx(Y,{className:"h-3 w-3 mr-1"})," Provision Room"]}):e.jsxs(e.Fragment,{children:[e.jsx(Y,{className:"h-3 w-3 mr-1"})," Re-provision"]})}),e.jsx(it,{sessionId:t.id,hostJoinCode:t.host_join_code,guests:d,guestName:I,guestEmail:O,onGuestNameChange:ie,onGuestEmailChange:oe,onInvite:He,inviteDisabled:u.isPending||!I.trim(),onAdm
42it:n=>j.mutate({guest_id:n.id,action:"admit"},{onSuccess:()=>b.success(`${n.guest_name} admitted`)}),onRemove:n=>{confirm(`Remove ${n.guest_name}?`)&&a.mutate(n.id,{onSuccess:()=>b.success(`${n.guest_name} removed`)})},onToggleMute:(n,S)=>m.mutate({guestId:n.id,muteAudio:S},{onSuccess:()=>b.success(`${n.guest_name} mic ${S?"muted":"unmuted"}`)}),onToggleCamera:n=>m.mutate({guestId:n.id,muteVideo:!n.remote_mute_video},{onSuccess:()=>b.success(`${n.guest_name} camera ${n.remote_mute_video?"enabled":"disabled"}`)}),getAudioLevel:Ge}),e.jsx(B,{orientation:"vertical",className:"h-5"}),t.status==="scheduled"&&e.jsxs(x,{variant:"outline",size:"sm",className:"h-7 text-xs",onClick:()=>h.mutateAsync({sessionId:t.id,status:"pre_flight"}),children:[e.jsx(V,{className:"h-3 w-3 mr-1"}),"Pre-Flight"]}),t.status==="pre_flight"&&e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsxs("label",{className:"flex items-center gap-1 text-[10px] text-muted-foreground cursor-pointer",children:[e.jsx("input",{type:"checkbox",checked:K,onChange:n=>Ie(n.target.checked),className:"rounded h-3 w-3"}),"Multi-track"]}),e.jsxs(x,{size:"sm",variant:"destructive",className:"h-7 text-xs",onClick:ue,children:[e.jsx(Pe,{className:"h-3 w-3 mr-1"}),"Go Live"]})]}),T&&e.jsxs("div",{className:"flex items-center gap-1.5",children:[A.length>0&&e.jsxs(y,{variant:U?"secondary":"destructive",className:"h-7 text-[10px] gap-1",title:A.map(n=>`${n.participant_name??n.participant_id}: ${n.uploaded_chunks}/${n.total_chunks} chunks`).join(`
43`),children:[e.jsx("span",{className:`h-1.5 w-1.5 rounded-full ${U?"bg-green-500":"bg-red-500 animate-pulse"}`}),"Local takes ",Math.round(z),"%"]}),e.jsxs(x,{size:"sm",variant:"destructive",className:"h-7 text-xs",onClick:xe,disabled:p.isPending||!U,children:[p.isPending?e.jsx(E,{className:"h-3 w-3 mr-1 animate-spin"}):e.jsx(Me,{className:"h-3 w-3 mr-1"}),"End & Save"]})]}),T&&(v.isRecording?e.jsxs(x,{variant:"outline",size:"sm",className:"h-7 text-xs gap-1 border-destructive text-destructive",onClick:v.stopLocalRecording,children:[e.jsx(we,{className:"h-3 w-3 animate-pulse"}),"Stop"]}):e.jsxs(x,{variant:"outline",size:"sm",className:"h-7 text-xs gap-1",onClick:v.startLocalRecording,children:[e.jsx(we,{className:"h-3 w-3"}),"Local"]})),v.recordedBlob&&!v.uploadedUrl&&e.jsxs(x,{variant:"outline",size:"sm",className:"h-7 text-xs gap-1",onClick:v.uploadLocalRecording,disabled:v.isUploading,children:[v.isUploading?e.jsx(E,{className:"h-3 w-3 animate-spin"}):e.jsx(Ds,{className:"h-3 w-3"}),"Upload"]}),e.jsx(B,{orientation:"vertical",className:"h-5"}),e.jsxs("div",{className:"flex items-center gap-0.5 border rounded-md p-0.5",children:[e.jsx(x,{variant:$==="grid"?"default":"ghost",size:"icon",className:"h-6 w-6",onClick:()=>D("grid"),title:"Grid [L]",children:e.jsx(ke,{className:"h-3 w-3"})}),e.jsx(x,{variant:$==="speaker"?"default":"ghost",size:"icon",className:"h-6 w-6",onClick:()=>D("speaker"),title:"Speaker [L]",children:e.jsx(es,{className:"h-3 w-3"})}),e.jsx(x,{variant:$==="split"?"default":"ghost",size:"icon",className:"h-6 w-6",onClick:()=>D("split"),title:"Split [L]",children:e.jsx(Bs,{className:"h-3 w-3"})})]}),e.jsx(x,{variant:"ghost",size:"icon",className:"h-7 w-7",onClick:f,title:w==="broadcast-dark"?"Switch to Brand Light":"Switch to Broadcast Dark",children:w==="broadcast-dark"?e.jsx(Ks,{className:"h-3.5 w-3.5"}):e.jsx(qs,{className:"h-3.5 w-3.5"})}),T&&e.jsx(x,{variant:ce?"default":"ghost",size:"icon",className:"h-7 w-7",onClick:()=>De(n=>!n),title:"Toggle live transcription",children:e.jsx(Gs,{className:"h-3.5 w-3.5"})}),e.jsx(x,{variant:"ghost",size:"icon",className:"h-7 w-7",onClick:()=>$e(!le),title:"Keyboard shortcuts",children:e.jsx(Vs,{className:"h-3.5 w-3.5"})})]})]}),le&&e.jsxs("div",{className:"absolute top-12 right-4 z-50 bg-card border rounded-lg shadow-lg p-3 text-xs space-y-1",children:[e.jsx("p",{className:"font-semibold mb-2",children:"Keyboard Shortcuts"}),[["M","Mute all guests"],["U","Unmute all guests"],["R","Toggle recording"],["L","Cycle layout"],["Space","TAKE preview → program"],["1–4","Play 
43soundboard clip"],["Esc","Clear preview / Stop soundboard"]].map(([n,S])=>e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("kbd",{className:"bg-muted px-1.5 py-0.5 rounded font-mono text-[10px]",children:n}),e.jsx("span",{className:"text-muted-foreground",children:S})]},n))]}),e.jsxs("div",{className:"flex-1 flex flex-col min-h-0",children:[e.jsxs("div",{className:"flex-1 grid grid-cols-2 gap-2 p-2 min-h-0 bg-foreground/95",children:[e.jsxs("div",{className:`relative rounded-lg overflow-hidden border-2 ${T?"border-destructive shadow-[0_0_24px_-6px_hsl(var(--destructive))]":"border-muted-foreground/20"} bg-black`,children:[e.jsxs("div",{className:"absolute top-2 left-2 z-20 flex items-center gap-1.5",children:[e.jsxs(y,{className:`${T?"bg-destructive text-destructive-foreground animate-pulse":"bg-muted text-muted-foreground"} h-5 px-1.5 text-[10px] gap-1`,children:[e.jsx(ee,{className:"h-2.5 w-2.5"}),"PROGRAM"]}),T&&e.jsx("span",{className:"text-[10px] text-destructive font-bold tracking-wider",children:"ON AIR"})]}),t.producer_token&&t.room_url?e.jsxs(e.Fragment,{children:[e.jsx(gs,{roomUrl:t.room_url,token:t.producer_token,userName:"Producer",layoutMode:$,isProducer:!0}),e.jsx(ze,{config:G}),s&&e.jsx(fs,{sessionId:s})]}):e.jsx("div",{className:"h-full flex items-center justify-center text-center text-muted-foreground p-4",children:e.jsxs("div",{children:[C.isPending?e.jsx(E,{className:"h-12 w-12 mx-auto mb-4 animate-spin"}):e.jsx(Y,{className:"h-12 w-12 mx-auto mb-4 opacity-50"}),e.jsx("p",{className:"text-sm",children:C.isPending?"Provisioning studio room…":'Studio room not ready. Click "Provision Room" above.'})]})})]}),e.jsxs("div",{className:"relative rounded-lg overflow-hidden border-2 border-accent/40 bg-black",children:[e.jsxs("div",{className:"absolute top-2 left-2 z-30 flex items-center gap-1.5",children:[e.jsxs(y,{variant:"outline",className:"bg-accent/15 text-accent border-accent/40 h-5 px-1.5 text-[10px] gap-1",children:[e.jsx(ee,{className:"h-2.5 w-2.5"}),"PREVIEW"]}),e.jsx("span",{className:"text-[10px] text-accent/80 font-bold tracking-wider",children:"CUED NEXT"})]}),e.jsx(ct,{config:F})]})]}),e.jsx(dt,{previewDirty:de,onTake:pe,onClear:ge,hotkeysEnabled:W}),T&&ce&&s&&e.jsx("div",{className:"px-2 pb-2 shrink-0",children:e.jsx("div",{className:"rounded-lg border bg-card p-2",children:e.jsx(st,{sessionId:s,isRecording:T,onTranscriptSave:n=>{g.mutate({sessionId:t.id,transcript:n},{onSuccess:()=>b.success("Transcript saved")})}})})}),e.jsxs("div",{className:"grid grid-cols-4 gap-0 border-t bg-card shrink-0",style:{height:"280px"},children:[e.jsxs("div",{className:"border-r flex flex-col min-h-0",children:[e.jsxs("div",{className:"px-3 py-1.5 border-b bg-muted/40 flex items-center gap-1.5 shrink-0",children:[e.jsx(Z,{className:"h-3 w-3"}),e.jsx("span",{className:"text-[11px] font-semibold uppercase tracking-wide",children:"Audio Mixer"})]}),e.jsx(M,{className:"flex-1",children:e.jsx("div",{className:"p-2",children:A.length>0?e.jsx(lt,{takes:A}):e.jsxs("div",{className:"p-3 text-xs text-muted-foreground space-y-2",children:[e.jsx("p",{className:"text-[10px] uppercase tracking-wide opacity-70",children:"Recording Health"}),e.jsx("p",{children:"Per-participant local recording status appears here once the session is live."})]})})})]}),e.jsxs("div",{className:"border-r flex flex-col min-h-0",children:[e.jsxs("div",{className:"px-3 py-1.5 border-b bg-muted/40 flex items-center gap-1.5 shrink-0",children:[e.jsx(Fs,{className:"h-3 w-3"}),e.jsx("span",{className:"text-[11px] font-semibold uppercase tracking-wide",children:"Rundown"})]}),e.jsx(M,{className:"flex-1",children:e.jsx("div",{className:"p-2",children:e.jsx(rt,{episodeId:t.episode_id,sessionTitle:t.title})})})]}),e.jsxs("div",{className:"border-r flex flex-col min-h-0",children:[e.jsxs("div",{className:"px-3 py-1.5 border-b bg-muted/40 flex items-center gap-1.5 shrink-0",children:[e.jsx(Z,{className:"h-3 w-3"}),e.jsx("span",{className:"text-[11px] font-semibold uppercase tracking-wide",children:"Soundboard"})]}),e.jsx(M,{className:"flex-1",children:e.jsx("div",{className:"p-2",children:e.jsx(et,{isOpen:!0,onToggle:()=>{}})})})]}),e.jsxs("div",{className:"flex flex-col min-h-0",children:[e.jsxs("div",{className:"px-3 py-1.5 border-b bg-muted/40 flex items-center gap-1.5 shrink-0",children:[e.jsx(ke,{className:"h-3 w-3"}),e.jsx("span",{className:"text-[11px] font-semibold uppercase tracking-wide",children:"Brand Deck"})]}),e.jsx(M,{className:"flex-1",children:e.jsxs("div",{className:"p-2 space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between gap-2 rounded-md border bg-muted/30 px-2 py-1.5",children:[e.jsx("span",{className:"text-[10px] uppercase tracking-wide text-muted-foreground font-semibold",children:"Stage on"}),e.jsxs("div",{className:"flex items-center gap-0.5 rounded-md border bg-background p-0.5",children:[e.jsx(x,{variant:J==="preview"?"default":"ghost",size:"sm",className:"h-6 px-2 text-[10px]",onClick:()=>ne("preview"),title:"Edits go to Preview (safe staging)",children:"Preview"}),e.jsx(x,{variant:J==="program"?"destructive":"ghost",size:"sm",className:"h-6 px-2 text-[10px]",onClick:()=>ne("program"),title:"Edits go directly to Program (LIVE)",children:"Program"})]})]}),W&&s?e.jsx(at,{sessionId:s}):e.jsx("p",{className:"text-xs text-muted-foreground",children:"Cues available once the session is active."}),e.jsx(B,{}),e.jsx(tt,{activePresetId:Ue,onActivate:Ve,onDeactivate:qe})]})})]})]})]})]}):e.jsx("div",{className:`${r} flex items-center justify-center min-h-screen bg-background`,children:e.jsx(Ee,{children:e.jsxs(Le,{className:"py-12 text-center",children:[e.jsx("p",{className:"text-lg font-medium",children:"Session not found"}),e.jsx(fe,{to:"/admin/recording-studio",className:"text-primary hover:underline text-sm mt-2 block",children:"← Back to Recording Studio"})]})})})}export{ta 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.