PageSourceSearch

https://snich.ai/assets/EgressRenderPage-33bf9376.js

js snich.ai collected 2026-10-05 15:07:23 UTC 27,417 bytes, 1 lines download raw bytes

1import{r as l,u as bt,b as _t,j as c}from"./vendor-react-72e4a099.js";import{l as Oe}from"./index-d9998155.js";import{u as At,a as Ct,p as It,f as Tt,b as kt,r as Nt,c as Rt,d as Pe,L as Et,s as jt,e as Mt,g as $t,V as Ft,S as Lt,P as Be,h as Ot,i as Pt,j as Bt,k as Dt}from"./ProgramGraphicsLayer-e1e0e604.js";import{L as M,r as Ve,A as me}from"./slotWidgets-57ef49ea.js";import{r as Ut,e as Ht,a as zt}from"./chromaKey-9ef66bf0.js";import{S as qe,h as De}from"./buildLifecycle-a44b0e05.js";import{a as Gt}from"./logo-snich-dialogue-bd9a9926.js";import{T as Vt}from"./triangle-alert-cdc85d96.js";import{L as qt}from"./loader-circle-f10bdd75.js";import{U as Wt}from"./user-plus-d862ebc6.js";import{V as Kt}from"./volume-2-a1e941cc.js";import{C as Ue}from"./check-083433f7.js";import"./guestAccess-28c96151.js";import"./chevron-left-39dc0897.js";import"./createLucideIcon-581cd729.js";import"./chevron-right-b4336544.js";import"./refresh-cw-98362cea.js";import"./globe-e09c7f1b.js";import"./lock-73755c1f.js";import"./mouse-pointer-2-a64daac3.js";import"./external-link-63c5a0ce.js";import"./x-b9f3d093.js";import"./mic-off-05523af3.js";import"./film-0ba9e353.js";import"./sparkles-e0558c3e.js";import"./pause-2cb080c5.js";import"./play-3580deb4.js";import"./ellipsis-vertical-09d18e39.js";import"./mic-098d6d5b.js";import"./video-a08888e9.js";import"./video-off-a445220e.js";import"./trash-2-7a739e24.js";import"./crown-fdf36aa5.js";import"./user-2d8f405f.js";import"./users-a990a1e8.js";import"./eye-5711d0dd.js";import"./deviceDetection-9fe14a8f.js";import"./roomAccess-6d61bdfc.js";import"./audioQuality-b8c9f17c.js";import"./snichDenoiseRuntime-273d9ce6.js";const fe=2,Qt=2;function He(s,g){typeof g!="string"||!g||(s.add(g),g.startsWith("remote-")?s.add(g.slice(7)):s.add(`remote-${g}`))}function Jt(s){const g=new Set;for(const f of s)He(g,f.id),He(g,f.peerId),f.id&&g.add(`media:${f.id}`);return g}function Yt(s,g){const f=Jt(g),_=[];for(const v of s)[v.peerId,v.ownerPeerId,v.peerId?`remote-${v.peerId}`:void 0,v.ownerPeerId?`remote-${v.ownerPeerId}`:void 0,v.mediaId,v.mediaId?`media:${v.mediaId}`:void 0].filter(y=>typeof y=="string"&&y.length>0).some(y=>f.has(y))&&(v.videoConsumerId&&_.push(v.videoConsumerId),v.screenVideoConsumerId&&_.push(v.screenVideoConsumerId));return _}const Xt=5e3;function Zt(s){const g=l.useRef(s);g.current=s;const f=l.useRef(new Map),_=s.intervalMs||Xt,v=l.useMemo(()=>{const C=s.stageParticipants.map(y=>y.id).sort().join(","),x=Array.from(s.remoteStreams.values()).map(y=>`${y.peerId}:${y.videoConsumerId||""}:${y.screenVideoConsumerId||""}`).sort().join("|");return`${C}::${x}`},[s.stageParticipants,s.remoteStreams]);l.useEffect(()=>{if(!s.enabled){f.current.clear();return}const C=()=>{const y=g.current,P=new Set(Yt(y.remoteStreams.values(),y.stageParticipants));for(const k of P)f.current.get(k)!==fe&&(y.resumeConsumer(k),y.setQuality(k,fe,Qt),f.current.set(k,fe));for(const k of Array.from(f.current.keys()))P.has(k)||f.current.delete(k)};C();const x=window.setInterval(C,_);return()=>window.clearInterval(x)},[s.enabled,v,_])}const es={color:"#2563EB",theme:"classic",logo:Gt,overlay:null,background:null,showNames:!0,showHeadlines:!0,showCommentAvatar:!0},U={ready:!1,connected:!1,buildId:qe,firstFrameAt:null,firstAudioAt:null,sceneStateRequestedAt:null,sceneStateReceivedAt:null,sceneLoadTimedOut:!1,fps:0,audioRms:0,sceneVersion:0,participantCount:0,stageParticipantCount:0,streamCount:0,streamSummaries:[],layoutMode:M.GRID,activeSceneId:null,captionsMode:"none",captionCount:0,latestCaption:null,commentCount:0,latestComment:null,errors:[]},ts="/stage-placeholders/stage-empty-host.png",We=["owner","host","co_host","streamer","speaker","guest","viewer"],ze=s=>{const g=String(s||"").toUpperCase();return Object.values(M).includes(g)?g:M.GRID},ss=s=>(s==null?void 0:s.find(f=>We.includes(f)))||"guest",he=s=>s.startsWith("remote-")?s:`remote-${s}`,ee=(s,g)=>{const f=g==="audio"?s==null?void 0:s.getAudioTracks():s==null?void 0:s.getVideoTracks();return!!(f!=null&&f.some(_=>_.readyState==="live"&&_.enabled!==!1))},ge=(s,g,f)=>!!(f.has(s)||g&&(f.has(g)||f.has(`remote-${g}`)||f.has(`user:${g}`))||f.has(`media:${s}`)||f.has(`presentation:${s}`)),Ge=(s,g,f)=>{const _=Ve(s,s.w/100*g,s.h/100*f),v={left:`${s.x}%`,top:`${s.y}%`,width:`${s.w}%`,height:`${s.h}%`,borderRadius:`${_}px`,opacity:(s.opacity??100)/100,zIndex:s.zIndex||1,transform:s.rotation?`rotate(${s.rotation}deg)`:void 0};return s.type==="background"||s.type==="shape"?c.jsx("div",{className:"absolute pointer-events-none",style:{...v,backgroundColor:s.backgroundColor||"transparent",backgroundImage:s.backgroundImage?`url(${s.backgroundImage})`:void 0,backgroundSize:"cover",backgroundPosition:"center",border:s.borderColor&&s.borderWidth?`${s.borderWidth}px solid ${s.borderColor}`:void 0}},s.id):s.type==="image"?c.jsx("div",{className:"absolute pointer-events-none flex items-center justify-center overflow-hidden",style:v,children:s.backgroundImage?c.jsx("img",{src:s.backgroundImage,alt:"",className:"max-h-full max-w-full",style:{width:s.fit==="cover"?"100%":"auto",height:s.fit==="cover"?"100%":"auto",objectFit:s.fit||"contain",borderRadius:`${_}px`}}):null},s.id):s.type==="text"?c.jsx("div",{className:"absolute pointer-events-none flex items-center justify-center",style:{...v,backgroundColor:s.backgroundColor&&s.backgroundColor!=="transparent"?s.backgroundColor:"transparent"},children:c.jsx("span",{style:{color:s.textColor||"#ffffff",fontSize:`${s.fontSize||32}px`,fontWeight:s.fontWeight||"bold",fontFamily:Dt(s.fontFamily),textAlign:s.textAlign||"center",width:"100%",padding:10,overflowWrap:"break-word",display:"flex",alignItems:"center",justifyContent:s.textAlign==="left"?"flex-start":s.textAlign==="right"?"flex-end":"center"},children:s.text||""})},s.id):s.type==="overlay"?c.jsx("div",{className:"absolute pointer-events-none",style:v,children:s.overlayImage?c.jsx("img",{src:s.overlayImage,alt:"",className:"h-full w-full object-cover",style:{borderRadius:`${s.radius||0}px`}}
1):null},s.id):null},zs=()=>{const{roomId:s}=bt(),[g]=_t(),f=g.get("token")||"",_=g.get("profile")||"horizontal_1080p30",v=g.get("mode")||"program",C=g.get("captions")||g.get("captionMode")||"none",x=_.includes("vertical")?"9:16":"16:9",y=l.useRef(null),P=l.useRef(null),k=l.useRef(0),pe=l.useRef({lastAt:performance.now(),frames:0,fps:0}),Se=l.useRef(null),ve=l.useRef(null),[Ke,Qe]=l.useState(0),[F,Je]=l.useState([]),[H,te]=l.useState([]),[z,B]=l.useState([]),[L,ye]=l.useState(M.GRID),[Q,Ye]=l.useState(null),[Xe,we]=l.useState([]),[Ze,et]=l.useState([]),[tt,st]=l.useState([]),[$,xe]=l.useState(es),[G,nt]=l.useState({page:0,auto:!1}),[V,J]=l.useState([]),[se,ne]=l.useState(null),[re,oe]=l.useState(null),{isConnected:R,isConnecting:be,error:ae,roomState:u,remoteStreams:ie,peers:le,socket:w,activePollOverlay:ce,joinRoom:_e,leaveRoom:Ae,setQuality:rt,resumeConsumer:ot}=At(),at=l.useCallback(t=>{ye(ze(t))},[]),it=l.useCallback(t=>{nt({page:Number.isFinite(t==null?void 0:t.page)?Math.max(0,Math.floor(t.page)):0,auto:!!(t!=null&&t.auto)})},[]),q=l.useMemo(()=>Array.from(ie.values()),[ie]),Ce=l.useMemo(()=>Array.from(le.entries()),[le]),Y=l.useMemo(()=>new Set((u==null?void 0:u.stageParticipants)||[]),[u==null?void 0:u.stageParticipants]);l.useEffect(()=>(window.__SNICH_EGRESS_STATUS__={...U},()=>{Ae()}),[Ae]),l.useEffect(()=>{if(!s||!f||R||be)return;const t=new MediaStream;_e(s,t,"SNICH Egress","read-only render",{egressToken:f})},[R,be,_e,s,f]),l.useEffect(()=>()=>{Ut()},[]),l.useEffect(()=>{u&&(u.layoutMode&&ye(ze(u.layoutMode)),Array.isArray(u.customLayout)&&we(u.customLayout),u.brand&&typeof u.brand=="object"&&xe(t=>({...t,...u.brand})),Array.isArray(u.banners)&&J(u.banners),u.activeBannerId!==void 0&&ne(u.activeBannerId),u.activeTickerId!==void 0&&oe(u.activeTickerId))},[u]),l.useEffect(()=>{const t=new Map,a=[];q.forEach(o=>{o.source==="screen"?a.push(o):t.has(o.peerId)||t.set(o.peerId,o)}),B(o=>{const n=new Map(o.map(e=>[e.id,e])),m=[];Ce.forEach(([e,r])=>{var Fe,Le;if(!r||r.name==="SNICH Egress")return;const i=he(e),h=n.get(i),T=t.get(e),A=T==null?void 0:T.stream,j=ee(A,"audio"),K=ee(A,"video"),Z=(r.roles||[]).filter(xt=>We.includes(xt)),Me=!!((Fe=r.metadata)!=null&&Fe.virtualBackgroundTransparent)&&K&&!!A,$e=Me?Ht(`peer:${e}`,A):void 0;Me||zt(`peer:${e}`),m.push({id:i,name:r.name||"Participant",headline:r.headline||"",type:"user",isLocal:!1,isAI:!1,isOnStage:(h==null?void 0:h.isOnStage)??ge(i,e,Y),isMuted:j?(h==null?void 0:h.isMuted)??!1:!0,isCameraOff:!K,stream:A,hasTransparentBackground:!!$e,virtualBackgroundCanvas:$e,role:ss(r.roles),meetingRoles:Z.length>0?Z:["guest"],quality:(h==null?void 0:h.quality)||"1080p",avatarUrl:(h==null?void 0:h.avatarUrl)||((Le=r.metadata)==null?void 0:Le.avatarUrl),volume:(h==null?void 0:h.volume)??100,userId:r.userId??null,peerId:e,isHandRaised:r.isHandRaised,handRaisedAt:r.handRaisedAt??null})}),a.forEach(e=>{const r=e.mediaId||`screen:${e.peerId}`,i=n.get(r);m.push({id:r,name:e.peerName?`${e.peerName}: screen`:"Screen share",headline:e.peerName||"",type:"screen",isLocal:!1,isAI:!1,isOnStage:(i==null?void 0:i.isOnStage)??ge(r,e.peerId,Y),isMuted:!ee(e.stream,"audio"),isCameraOff:!ee(e.stream,"video"),stream:e.stream,role:"guest",meetingRoles:["guest"],quality:(i==null?void 0:i.quality)||"1080p",volume:(i==null?void 0:i.volume)??100,peerId:e.peerId,ownerSocketId:e.ownerPeerId||e.peerId})}),(Array.isArray(u==null?void 0:u.sharedMedia)?u.sharedMedia:[]).forEach(e=>{var h,T,A,j,K;if(!(e!=null&&e.id)||m.some(Z=>Z.id===e.id))return;const r=n.get(e.id),i=e.type==="video_file"?"video_file":e.type==="screen"?"screen":"presentation";m.push({id:e.id,name:e.name||"Shared media",headline:e.ownerName||"",type:i,isLocal:!1,isAI:!1,isOnStage:(r==null?void 0:r.isOnStage)??ge(e.id,e.ownerId,Y),isMuted:i!=="video_file",isCameraOff:!1,presentation:i==="presentation"?{slides:((h=r==null?void 0:r.presentation)==null?void 0:h.slides)||[],currentSlide:e.currentSlide||((T=r==null?void 0:r.presentation)==null?void 0:T.currentSlide)||0,allowDownload:!!e.allowDownload,sourceFileName:e.sourceFileName||e.name}:void 0,videoFile:i==="video_file"?{url:e.url||((A=r==null?void 0:r.videoFile)==null?void 0:A.url)||"",duration:e.duration||((j=r==null?void 0:r.videoFile)==null?void 0:j.duration)||0,isPlaying:!!e.isPlaying,currentTime:e.currentTime||0,lastSyncedAt:e.lastSyncedAt||Date.now(),allowDownload:!!e.allowDownload,sourceFileName:e.sourceFileName||e.name,captionText:e.captionText||((K=r==null?void 0:r.videoFile)==null?void 0:K.captionText)||e.name,showCaption:e.showCaption!==!1}:void 0,role:"guest",meetingRoles:["guest"],quality:(r==null?void 0:r.quality)||"1080p",volume:(r==null?void 0:r.volume)??100,ownerSocketId:e.ownerId})});const p=o.map(e=>{var r,i,h,T,A,j;return[e.id,e.isOnStage,e.isMuted,e.isCameraOff,((r=e.stream)==null?void 0:r.id)||"",((i=e.presentation)==null?void 0:i.slides.length)||0,((h=e.presentation)==null?void 0:h.currentSlide)||0,((T=e.videoFile)==null?void 0:T.url)||"",((A=e.videoFile)==null?void 0:A.isPlaying)||!1,((j=e.videoFile)==null?void 0:j.currentTime)||0].join(":")}).join("|"),d=m.map(e=>{var r,i,h,T,A,j;return[e.id,e.isOnStage,e.isMuted,e.isCameraOff,((r=e.stream)==null?void 0:r.id)||"",((i=e.presentation)==null?void 0:i.slides.length)||0,((h=e.presentation)==null?void 0:h.currentSlide)||0,((T=e.videoFile)==null?void 0:T.url)||"",((A=e.videoFile)==null?void 0:A.isPlaying)||!1,((j=e.videoFile)==null?void 0:j.currentTime)||0].join(":")}).join("|");return p===d?o:m})},[Ce,u==null?void 0:u.sharedMedia,Y,q]),l.useEffect(()=>{const a=(Array.isArray(u==null?void 0:u.sharedMedia)?u.sharedMedia:[]).filter(n=>(n==null?void 0:n.id)&&n.type!=="video_file"&&n.type!=="screen").map(n=>String(n.id));if(a.length===0)return;let o=!1;return a.forEach(n=>{var S;const m=z.find(p=>p.id===n);(S=m==null?void 0:m.presentation)!=null&&S.slides.length||fetch(`/api/v1/presentations/${n}`).then(p=>p.ok?p.json():null).then(p=>{o||!Array.isArray(p==null?void 0:p.slides)||B(d=>d.map(e=>{var r,i,h;return e.id!==n||e.type!=="presentation"?e:{...e,name:p.name||e.name,presentation:{slides:p.slides,currentSlide:((r=e.presentation)==null?void 0:r.currentSlide)||0,allowDownload:((i=e.presentation)==null?void 0:i.allowDownload)||!1,sourceFileName:((h=e.presentation)==null?void 0:h.sourceFileName)||p.name||e.name}}}))}).catch(()=>{var p;window.__SNICH_EGRESS_STATUS__={...window.__SNICH_EGRESS_STATUS__||U,errors:[...((p=window.__SNICH_EGRESS_STATUS__)==null?void 0:p.errors)||[],`presentation:${n}:load_failed`].slice(-5)}})}),()=>{o=!0}},[z,u==null?void 0:u.sharedMedia]),l.useEffect(()=>{if(!w)return;const t=({peerId:d,enabled:e})=>
1{if(!d)return;const r=he(d);B(i=>i.map(h=>h.id===r?{...h,isMuted:!e}:h))},a=({peerId:d,enabled:e})=>{if(!d)return;const r=he(d);B(i=>i.map(h=>h.id===r?{...h,isCameraOff:!e}:h))},o=({banner:d})=>{J(e=>e.some(r=>r.id===d.id)?e.map(r=>r.id===d.id?{...r,...d,isActive:r.isActive}:r):[...e,d])},n=({bannerId:d})=>{J(e=>e.filter(r=>r.id!==d)),ne(e=>e===d?null:e),oe(e=>e===d?null:e)},m=({banners:d})=>{J(Array.isArray(d)?d:[])},S=({activeBannerId:d,activeTickerId:e})=>{d!==void 0&&ne(d),e!==void 0&&oe(e)},p=({mediaId:d,updates:e})=>{!d||!e||B(r=>r.map(i=>i.id!==d?i:i.type==="presentation"&&i.presentation?{...i,presentation:{...i.presentation,currentSlide:e.currentSlide??i.presentation.currentSlide,allowDownload:e.allowDownload??i.presentation.allowDownload,sourceFileName:e.sourceFileName??i.presentation.sourceFileName}}:i.type==="video_file"&&i.videoFile?{...i,videoFile:{...i.videoFile,duration:e.duration??i.videoFile.duration,isPlaying:e.isPlaying??i.videoFile.isPlaying,currentTime:e.currentTime??i.videoFile.currentTime,lastSyncedAt:e.lastSyncedAt??i.videoFile.lastSyncedAt,allowDownload:e.allowDownload??i.videoFile.allowDownload,sourceFileName:e.sourceFileName??i.videoFile.sourceFileName,captionText:e.captionText??i.videoFile.captionText,showCaption:e.showCaption??i.videoFile.showCaption}}:i))};return w.on("ms:peerAudioStateChanged",t),w.on("ms:peerVideoStateChanged",a),w.on("banner-added",o),w.on("banner-deleted",n),w.on("banners-updated",m),w.on("overlay-toggled",S),w.on("shared-media-updated",p),()=>{w.off("ms:peerAudioStateChanged",t),w.off("ms:peerVideoStateChanged",a),w.off("banner-added",o),w.off("banner-deleted",n),w.off("banners-updated",m),w.off("overlay-toggled",S),w.off("shared-media-updated",p)}},[w]);const[Ie,lt]=l.useState(0),ct=l.useCallback(t=>{t.transition==="fade"&&lt(a=>a+1)},[]),{activeSceneLayout:Te,stageParticipants:N,isSceneLoading:W}=Ct({onProgramChanged:ct,socket:w,hasJoined:R,localPeerId:null,layoutMode:L,activeSceneId:Q,customLayout:Xe,customLayoutVertical:Ze,scenes:tt,brand:$,participants:z,previewAspectRatio:x,pagination:G,canChangeLayout:!1,setLayoutMode:at,setActiveSceneId:Ye,setCustomLayout:we,setCustomLayoutVertical:et,setScenes:st,setBrand:xe,setParticipants:B,setPagination:it}),{visible:O}=l.useMemo(()=>It(N,L,G.page),[L,G.page,N]);Zt({enabled:R,remoteStreams:ie,stageParticipants:N,setQuality:rt,resumeConsumer:ot});const[ke,dt]=l.useState({});l.useEffect(()=>{let t=!1;return Tt().then(a=>{t||dt(a)}),()=>{t=!0}},[]);const Ne=l.useMemo(()=>kt(V,se,re),[V,se,re]),b=l.useMemo(()=>{const t=Nt(L,ke,x,Te);return{...t,customLayout:Rt(t.customLayout,Ne,x==="9:16")}},[Te,L,ke,x,Ne]),[ut,mt]=l.useState("");l.useEffect(()=>{const t=()=>{const o=N.map(n=>{const m=Pe(null,null,n.stream??null);return`${n.id}:${m===null?"-":m.toFixed(2)}`}).join("|");mt(n=>n===o?n:o)};t();const a=window.setInterval(t,1500);return()=>window.clearInterval(a)},[N]);const Re=l.useMemo(()=>{const t=me[x],a=O.map(o=>Pe(null,null,o.stream??null));return Et.calculateLayout(O.length,b.layoutMode,b.customLayout,x,t.width,t.height,a,O.map(o=>jt(o.type)),O.map(o=>Mt(o,null)))},[b,O,x,ut]),ft=l.useCallback(t=>{const a=me[x];return{left:`${t.x/a.width*100}%`,top:`${t.y/a.height*100}%`,width:`${t.w/a.width*100}%`,height:`${t.h/a.height*100}%`,borderRadius:t.radius!==void 0?`${t.radius}px`:void 0}},[x]),Ee=F.slice(-3),X=C==="none"&&!!(u!=null&&u.captionsOnAir),[ht,de]=l.useState(null);l.useEffect(()=>{if(!X){de(null);return}const t=F[F.length-1],a=t!=null&&t.text?$t(t.text):"";if(de(a||null),!a)return;const o=window.setTimeout(()=>de(null),7e3);return()=>window.clearTimeout(o)},[X,F]);const je=H.slice(-3),gt=C==="burned-in"||C==="preview"&&v!=="program",pt=b.layoutMode===M.CUSTOM?b.customLayout.filter(t=>t.type==="background"||t.type==="shape"||t.type==="image"):[],St=b.layoutMode===M.CUSTOM?b.customLayout.filter(t=>t.type==="text"||t.type==="overlay"):[],I=b.layoutMode===M.CUSTOM?b.customLayout.find(t=>t.type==="poll"):null,vt=b.layoutMode===M.CUSTOM?b.customLayout.filter(t=>t.type==="question"):[],yt=b.layoutMode===M.CUSTOM&&b.customLayout.some(t=>["background","image","text","question"].includes(t.type)),wt=b.layoutMode===M.CUSTOM?b.customLayout.filter(t=>t.type==="clock"||t.type==="timer"):[],E=me[x],ue=l.useMemo(()=>N.map(t=>({id:t.id,stream:t.stream,muted:t.isMuted,volume:t.volume??100})).filter(t=>{var a;return!t.muted&&((a=t.stream)==null?void 0:a.getAudioTracks().some(o=>o.readyState==="live"))}),[N]);if(l.useEffect(()=>{if(!s||!f||C==="none"&&!X)return;const t=Oe(`${De()}/ai`,{transports:["websocket","polling"],reconnection:!0,reconnectionAttempts:5,reconnectionDelay:2e3});return Se.current=t,t.on("connect",()=>{t.emit("stt:subscribe",{roomId:s,egressToken:f})}),t.on("stt:subtitle",a=>{var S;const o=(S=a.text)==null?void 0:S.trim();if(!o)return;const n=a.peerId||"unknown",m={id:a.segmentId||`caption:${n}:${a.isFinal?"final":"partial"}`,peerId:n,speakerName:a.speakerName||"Participant",text:o,isFinal:!!a.isFinal,startOffsetMs:typeof a.startOffsetMs=="number"?a.startOffsetMs:null,endOffsetMs:typeof a.endOffsetMs=="number"?a.endOffsetMs:null,receivedAt:new Date().toISOString()};Je(p=>{const d=p.findIndex(r=>
1r.id===m.id||!m.isFinal&&r.peerId===m.peerId&&!r.isFinal),e=d>=0?[...p]:[...p,m];return d>=0&&(e[d]=m),e.slice(-8)})}),t.on("connect_error",a=>{var o;window.__SNICH_EGRESS_STATUS__={...window.__SNICH_EGRESS_STATUS__||U,errors:[...((o=window.__SNICH_EGRESS_STATUS__)==null?void 0:o.errors)||[],`captions:${a.message}`].slice(-5)}}),()=>{t.disconnect(),Se.current=null}},[C,X,s,f]),l.useEffect(()=>{if(!s||!f)return;const t=Oe(`${De()}/comms`,{transports:["websocket","polling"],reconnection:!0,reconnectionAttempts:5,reconnectionDelay:2e3,auth:{egressToken:f,roomId:s}});ve.current=t;const a=n=>{const m=typeof(n==null?void 0:n.text)=="string"?n.text.trim():"";return!m||(n==null?void 0:n.visibility)==="private"||n!=null&&n.isDeleted?null:{id:String(n.id||`comment:${n.peerId||"unknown"}:${n.createdAt||Date.now()}`),peerId:String(n.peerId||"unknown"),senderName:String(n.senderName||"Participant"),text:m,createdAt:String(n.createdAt||new Date().toISOString())}},o=n=>{const m=a(n);m&&te(S=>{const p=S.findIndex(e=>e.id===m.id),d=p>=0?[...S]:[...S,m];return p>=0&&(d[p]=m),d.slice(-12)})};return t.on("connect",()=>{t.emit("chat:subscribe",{roomId:s,limit:4},n=>{var p;const S=(Array.isArray((p=n==null?void 0:n.data)==null?void 0:p.recent)?n.data.recent:[]).map(a).filter(Boolean);S.length>0&&te(d=>[...d,...S].slice(-12))})}),t.on("chat:message",o),t.on("chat:edited",o),t.on("chat:deleted",n=>{n!=null&&n.messageId&&te(m=>m.filter(S=>S.id!==n.messageId))}),t.on("connect_error",n=>{var m;window.__SNICH_EGRESS_STATUS__={...window.__SNICH_EGRESS_STATUS__||U,errors:[...((m=window.__SNICH_EGRESS_STATUS__)==null?void 0:m.errors)||[],`comments:${n.message}`].slice(-5)}}),()=>{t.disconnect(),ve.current=null}},[s,f]),l.useEffect(()=>{let t=0;const a=()=>{const o=pe.current;o.frames+=1;const n=performance.now();n-o.lastAt>=1e3&&(o.fps=Math.round(o.frames*1e3/(n-o.lastAt)),o.frames=0,o.lastAt=n),t=requestAnimationFrame(a)};return t=requestAnimationFrame(a),()=>cancelAnimationFrame(t)},[]),l.useEffect(()=>{const t=window.setInterval(()=>Qe(a=>a+1),500);return()=>window.clearInterval(t)},[]),l.useEffect(()=>{!R||W||y.current||(y.current=new Date().toISOString())},[R,W,N.length]),l.useEffect(()=>{var p;const t=ue.map(d=>d.stream).filter(d=>!!d);if(t.length===0){k.current=0;return}const a=window.AudioContext||window.webkitAudioContext;if(!a){window.__SNICH_EGRESS_STATUS__={...window.__SNICH_EGRESS_STATUS__||U,errors:[...((p=window.__SNICH_EGRESS_STATUS__)==null?void 0:p.errors)||[],"audio_meter_unavailable"].slice(-5)};return}const o=new a,n=t.map(d=>{const e=o.createAnalyser();e.fftSize=1024;const r=o.createMediaStreamSource(d);return r.connect(e),{analyser:e,source:r,buffer:new Uint8Array(e.fftSize)}});o.resume().catch(()=>{});let m=0;const S=()=>{let d=0;for(const e of n){e.analyser.getByteTimeDomainData(e.buffer);let r=0;for(let i=0;i<e.buffer.length;i+=1){const h=(e.buffer[i]-128)/128;r+=h*h}d=Math.max(d,Math.sqrt(r/e.buffer.length))}k.current=d,!P.current&&d>=.015&&(P.current=new Date().toISOString()),m=requestAnimationFrame(S)};return m=requestAnimationFrame(S),()=>{cancelAnimationFrame(m),n.forEach(d=>d.source.disconnect()),o.close().catch(()=>{})}},[ue]),l.useEffect(()=>{const t=window.__SNICH_EGRESS_STATUS__||U,a=[f?null:"missing_token",ae?`livekit:${ae}`:null].filter(Boolean);window.__SNICH_EGRESS_STATUS__={ready:!!(R&&!W&&y.current),connected:R,buildId:qe,firstFrameAt:y.current,firstAudioAt:P.current,sceneStateRequestedAt:t.sceneStateRequestedAt||null,sceneStateReceivedAt:t.sceneStateReceivedAt||null,sceneLoadTimedOut:!!t.sceneLoadTimedOut,fps:pe.current.fps,audioRms:k.current,sceneVersion:JSON.stringify({roomState:u,layoutMode:L,activeSceneId:Q,brand:$,banners:V,pagination:G}).length,participantCount:z.length,stageParticipantCount:N.length,streamCount:q.length,streamSummaries:q.map(o=>({peerId:o.peerId,peerName:o.peerName,source:o.source,mediaId:o.mediaId,audioTracks:o.stream.getAudioTracks().length,videoTracks:o.stream.getVideoTracks().length})),layoutMode:L,activeSceneId:Q,captionsMode:C,captionCount:F.length,latestCaption:F[F.length-1]||null,commentCount:H.length,latestComment:H[H.length-1]||null,errors:a}},[Q,V,$,F,C,H,ae,R,W,L,G,z.length,u,N.length,Ke,q,f]),!f||!s)return c.jsx("div",{className:"flex min-h-screen items-center justify-center bg-[#090a0d] text-white",children:c.jsxs("div",{className:"flex items-center gap-3 rounded border border-red-500/40 bg-red-950/40 px-4 py-3 text-sm",children:[c.jsx(Vt,{size:18}),"Egress token is required."]})});const D=x==="9:16";return c.jsx("main",{className:"flex min-h-screen items-center justify-center bg-black text-white",children:c.jsxs("section",{className:"relative overflow-hidden bg-black",style:{width:D?"min(100vw, calc(100vh * 9 / 16))":"100vw",height:D?"100vh":"min(100vh, calc(100vw * 9 / 16))",aspectRatio:D?"9 / 16":"16 / 9",backgroundColor:"black",backgroundImage:$.background?`url(${$.background})`:void 0,backgroundSize:"cover",backgroundPosition:"center"},children:[$.overlay?c.jsx("img",{src:$.overlay,alt:"",className:"pointer-events-none absolute inset-0 z-20 h-full w-full object-cover"}):null,pt.map(t=>Ge(t,E.width,E.height)),W?c.jsxs("div",{className:"flex h-full w-full flex-col items-center justify-center bg-gradient-to-br from-slate-900 to-slate-800 text-white",children:[c.jsx(qt,{className:"mb-4 animate-spin text-blue-300",size:42}),c.jsx("p",{className:"text-sm font-medium text-white/70",children:"Loading scene..."})]}):N.length===0&&!yt?c.jsx("div",{className:"studio-stage-placeholder is-host",style:{"--stage-placeholder-bg":`url(${ts})`},children:c.jsxs("div",{className:"studio-stage-placeholder-content",children:[c.jsxs("div",{className:"studio-stage-placeholder-kicker",children:[c.jsx("span",{className:"studio-stage-placeholder-pulse"}),c.jsx("span",{children:"Stage is empty"})]}),c.jsx("div",{className:"studio-stage-placeholder-icon",children:R?c.jsx(Wt,{size:34}):c.jsx(Kt,{size:34})}),c.jsx("h2",{children:"Add guests to the scene"}),c.jsx("p",{children:"Select participants or content backstage to put them into the program output."}),c.jsxs("div",{className:"studio-stage-placeholder-hints",children:[c.jsxs("span",{children:[c.jsx(Ue,{size:14})," Synced with studio"]}),c.jsxs("span",{children:[c.jsx(Ue,{size:14})," Ready for streaming"]})]})]})}):O.map((t,a)=>{var m,S;const o=Re[a];if(!o)return null;const n=t.stream?{...t,volume:0}:t;return c.jsx("div",{className:"absolute z-10 transition-all duration-500 ease-in-out",style:ft(o),children:c.jsx("div",{style:o.radius!==void 0?{borderRadius:`${o.radius}px`}:void 0,className:`grid h-full w-full overflow-hidden ${o.radius!==void 0?"":"rounded-lg"}
1 ${n.type==="user"&&n.hasTransparentBackground&&n.virtualBackgroundCanvas&&!n.isCameraOff?"bg-transparent":"bg-gray-900"}`,children:t.type==="polls"?c.jsx("div",{className:"flex h-full w-full items-center justify-center bg-gray-900 text-sm text-gray-500",children:"Polls are shown as overlay"}):c.jsx(Ft,{participant:n,brand:$,activeBanner:null,mirror:n.type==="user"&&n.peerId?!!((S=(m=le.get(n.peerId))==null?void 0:m.metadata)!=null&&S.isMirrored):!1,className:"h-full w-full",slotShaped:o.radius!==void 0,canControlSlides:!1,roomId:s,isHost:!1,hideBackstageStageAction:!0,hideNameTag:!0})})},t.id)}),St.map(t=>Ge(t,E.width,E.height)),wt.map(t=>c.jsx(Lt,{slot:t,containerWidth:E.width,containerHeight:E.height,designWidth:E.width},t.id)),I&&ce?c.jsx("div",{className:"absolute",style:{left:`${I.x}%`,top:`${I.y}%`,width:`${I.w}%`,height:`${I.h}%`,borderRadius:`${Ve(I,I.w/100*E.width,I.h/100*E.height)}px`,opacity:(I.opacity??100)/100,zIndex:I.zIndex||100,transform:I.rotation?`rotate(${I.rotation}deg)`:void 0},children:c.jsx(Be,{overlayState:ce,interactive:!1,useSlotPosition:!0})}):c.jsx(Be,{overlayState:ce,interactive:!1}),c.jsx("div",{className:"pointer-events-none absolute inset-0 z-30 flex flex-col justify-end overflow-hidden p-2 pb-8 sm:p-4 sm:pb-12 md:p-8 md:pb-16",children:je.length>0?c.jsx("div",{className:`flex flex-col gap-2 ${D?"w-[78%] self-center":"w-[min(34%,420px)] self-end"}`,children:je.map(t=>c.jsxs("div",{className:"max-w-full rounded bg-slate-950/72 px-3 py-2 text-left text-[clamp(12px,1.2vw,18px)] font-semibold leading-snug text-white shadow-[0_10px_30px_rgba(0,0,0,0.28)]",children:[c.jsx("div",{className:"truncate text-[0.78em] font-extrabold uppercase text-sky-300",children:t.senderName}),c.jsx("div",{className:"line-clamp-2 break-words",children:t.text})]},t.id))}):null}),c.jsx(Ot,{vertical:D,resolution:E,brand:$,banners:V,activeBannerId:se,activeTickerId:re,tiles:O.map((t,a)=>({participant:t,rect:Re[a]})),questionSlots:vt,caption:ht}),Ie>0?c.jsx("div",{className:"sn-program-dipper","aria-hidden":"true"},Ie):null,gt&&Ee.length>0?c.jsx("div",{className:`pointer-events-none absolute left-1/2 z-40 flex w-[min(88%,960px)] -translate-x-1/2 flex-col items-center gap-2 ${D?"bottom-[9%]":"bottom-[7%]"}`,"data-testid":"egress-captions-safe-area",children:Ee.map(t=>c.jsxs("div",{className:"max-w-full rounded bg-black/72 px-4 py-2 text-center text-[clamp(16px,2.1vw,34px)] font-semibold leading-tight text-white shadow-[0_10px_30px_rgba(0,0,0,0.35)]",children:[c.jsxs("span",{className:"mr-2 text-emerald-300",children:[t.speakerName,":"]}),c.jsx("span",{children:t.text})]},t.id))}):null,ue.map(t=>c.jsx("audio",{autoPlay:!0,ref:a=>{a&&t.stream&&(a.srcObject=t.stream,a.volume=Math.max(0,Math.min(1,t.volume/100)),a.play().catch(()=>{}))}},`audio:${t.id}`)),c.jsx(Pt,{state:Bt(u==null?void 0:u.programSound),loaded:!!u})]})})};export{zs 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.