import { ref } from 'vue'; import WhatsappCallsAPI from 'dashboard/api/channel/whatsapp/whatsappCallsAPI'; // Browser ↔ Meta WebRTC is a singleton — only one PeerConnection at a time can // hold the user's mic. Module-level state lets cable handlers and the pagehide // listener reach the live session without prop-drilling refs through composables. let pc = null; let localStream = null; let remoteStream = null; let remoteAudioEl = null; let mediaRecorder = null; let recorderChunks = []; let audioContext = null; let activeCallId = null; let intentionallyClosing = false; // Lazily attach a hidden