import{_}from"./index-Bkuhln3H.js";async function f(){const n=await navigator.mediaDevices.getUserMedia({audio:{noiseSuppression:!0,echoCancellation:!0,autoGainControl:!0}}),e=new AudioContext({sampleRate:48e3}),s=e.createMediaStreamSource(n);let r=s,o=null;try{const{RnnoiseWorkletNode:t,loadRnnoise:l}=await _(async()=>{const{RnnoiseWorkletNode:p,loadRnnoise:w}=await import("./index-B80mu6sq.js");return{RnnoiseWorkletNode:p,loadRnnoise:w}},[]),c=new URL("/assets/rnnoise-lVVwgm0Y.wasm",import.meta.url).href,u=new URL("/assets/rnnoise-lVVwgm0Y.wasm",import.meta.url).href,d=await l({url:c,simdUrl:u}),m=new URL("/assets/workletProcessor-CqIjLsie.js",import.meta.url).href;await e.audioWorklet.addModule(m),o=new t(e,{maxChannels:1,wasmBinary:d}),s.connect(o),r=o,console.info("[AudioPipeline] RNNoise AudioWorklet loaded")}catch(t){console.warn("[AudioPipeline] RNNoise unavailable, using browser-only noise suppression:",t)}const i=e.createMediaStreamDestination();r.connect(i);const a=()=>{o?.destroy&&o.destroy(),n.getTracks().forEach(t=>t.stop()),e.close().catch(()=>{})};return console.info(`[AudioPipeline] Pipeline ready: Mic → Browser NS${o?" → RNNoise":""} → Output`),{stream:i.stream,audio_ctx:e,destroy:a}}export{f as create_audio_pipeline};
