// public/publish.js if (window.__PUBLISH_JS_RUNNING__) { console.warn('publish.js ya estaba corriendo, ignorando segunda carga.'); } else { window.__PUBLISH_JS_RUNNING__ = true; const rawOwnerId = new URLSearchParams(location.search).get('ownerId'); const ownerId = decodeURIComponent(String(rawOwnerId || '')).trim(); if (!ownerId) throw new Error('ownerId requerido'); const MS = window.mediasoupClient; if (!MS?.Device) throw new Error('window.mediasoupClient.Device no existe. Revisa el bundle.'); const $ = (id) => document.getElementById(id); const overlay = $('overlay'); const previewVideo = $('localVideo'); const effectsBtn = $('effectsBtn'); const configBtn = $('configBtn'); const sheetOverlay = $('sheetOverlay'); const effectsPanel = $('effectsPanel'); const configPanel = $('configPanel'); const micBtn = $('micBtn'); const camBtn = $('camBtn'); const videoSelect = $('videoSelect'); const audioSelect = $('audioSelect'); const nickInput = $('nickInput'); const fxList = $('fxList'); const maskList = $('maskList'); let socket = null; let device = null; let sendTransport = null; let videoProducer = null; let audioProducer = null; let rawStream = null; let processedStream = null; // Track clonado que va al producer cuando estamos en modo natural (sin canvas). // Compartir un MediaStreamTrack entre un