// node_modules/@timephy/rnnoise-wasm/dist/polyfills.js
var b64 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";
var b64re = /^(?:[A-Za-z\d+\/]{4})*?(?:[A-Za-z\d+\/]{2}(?:==)?|[A-Za-z\d+\/]{3}=?)?$/;
globalThis.atob = function(string) {
  string = String(string).replace(/[\t\n\f\r ]+/g, "");
  if (!b64re.test(string))
    throw new TypeError("Failed to execute 'atob' on 'Window': The string to be decoded is not correctly encoded.");
  string += "==".slice(2 - (string.length & 3));
  let bitmap, result = "", r1, r2, i = 0;
  for (; i < string.length; ) {
    bitmap = b64.indexOf(string.charAt(i++)) << 18 | b64.indexOf(string.charAt(i++)) << 12 | (r1 = b64.indexOf(string.charAt(i++))) << 6 | (r2 = b64.indexOf(string.charAt(i++)));
    result += r1 === 64 ? String.fromCharCode(bitmap >> 16 & 255) : r2 === 64 ? String.fromCharCode(bitmap >> 16 & 255, bitmap >> 8 & 255) : String.fromCharCode(bitmap >> 16 & 255, bitmap >> 8 & 255, bitmap & 255);
  }
  return result;
};
globalThis.self = { location: { href: "" } };

// node_modules/@timephy/rnnoise-wasm/dist/RnnoiseProcessor.js
var RNNOISE_SAMPLE_LENGTH = 480;
var RNNOISE_BUFFER_SIZE = RNNOISE_SAMPLE_LENGTH * 4;
var PCM_FREQUENCY = 44100;
var SHIFT_16_BIT_NR = 32768;
var RnnoiseProcessor = class {
  /**
   * Rnnoise context object needed to perform the audio processing.
   */
  _context;
  /**
   * State flag, check if the instance was destroyed.
   */
  _destroyed = false;
  /**
   * WASM interface through which calls to rnnoise are made.
   */
  _wasmInterface;
  /**
   * WASM dynamic memory buffer used as input for rnnoise processing method.
   */
  _wasmPcmInput;
  /**
   * The Float32Array index representing the start point in the wasm heap of the _wasmPcmInput buffer.
   */
  _wasmPcmInputF32Index;
  /**
   * Constructor.
   *
   * @class
   * @param {Object} wasmInterface - WebAssembly module interface that exposes rnnoise functionality.
   */
  constructor(wasmInterface) {
    try {
      this._wasmInterface = wasmInterface;
      this._wasmPcmInput = this._wasmInterface._malloc(RNNOISE_BUFFER_SIZE);
      this._wasmPcmInputF32Index = this._wasmPcmInput >> 2;
      if (!this._wasmPcmInput) {
        throw Error("Failed to create wasm input memory buffer!");
      }
      this._context = this._wasmInterface._rnnoise_create();
    } catch (error) {
      this.destroy();
      throw error;
    }
  }
  /**
   * Release resources associated with the wasm context. If something goes downhill here
   * i.e. Exception is thrown, there is nothing much we can do.
   *
   * @returns {void}
   */
  _releaseWasmResources() {
    if (this._wasmPcmInput) {
      this._wasmInterface._free(this._wasmPcmInput);
    }
    if (this._context) {
      this._wasmInterface._rnnoise_destroy(this._context);
    }
  }
  /**
   * Rnnoise can only operate on a certain PCM array size.
   *
   * @returns {number} - The PCM sample array size as required by rnnoise.
   */
  getSampleLength() {
    return RNNOISE_SAMPLE_LENGTH;
  }
  /**
   * Rnnoise can only operate on a certain format of PCM sample namely float 32 44.1Kz.
   *
   * @returns {number} - PCM sample frequency as required by rnnoise.
   */
  getRequiredPCMFrequency() {
    return PCM_FREQUENCY;
  }
  /**
   * Release any resources required by the rnnoise context this needs to be called
   * before destroying any context that uses the processor.
   *
   * @returns {void}
   */
  destroy() {
    if (this._destroyed) {
      return;
    }
    this._releaseWasmResources();
    this._destroyed = true;
  }
  /**
   * Calculate the Voice Activity Detection for a raw Float32 PCM sample Array.
   * The size of the array must be of exactly 480 samples, this constraint comes from the rnnoise library.
   *
   * @param {Float32Array} pcmFrame - Array containing 32 bit PCM samples.
   * @returns {Float} Contains VAD score in the interval 0 - 1 i.e. 0.90.
   */
  calculateAudioFrameVAD(pcmFrame) {
    return this.processAudioFrame(pcmFrame);
  }
  /**
   * Process an audio frame, optionally denoising the input pcmFrame and returning the Voice Activity Detection score
   * for a raw Float32 PCM sample Array.
   * The size of the array must be of exactly 480 samples, this constraint comes from the rnnoise library.
   *
   * @param {Float32Array} pcmFrame - Array containing 32 bit PCM samples. Parameter is also used as output
   * when {@code shouldDenoise} is true.
   * @param {boolean} shouldDenoise - Should the denoised frame be returned in pcmFrame.
   * @returns {Float} Contains VAD score in the interval 0 - 1 i.e. 0.90 .
   */
  processAudioFrame(pcmFrame, shouldDenoise = false) {
    for (let i = 0; i < RNNOISE_SAMPLE_LENGTH; i++) {
      this._wasmInterface.HEAPF32[this._wasmPcmInputF32Index + i] = pcmFrame[i] * SHIFT_16_BIT_NR;
    }
    const vadScore = this._wasmInterface._rnnoise_process_frame(this._context, this._wasmPcmInput, this._wasmPcmInput);
    if (shouldDenoise) {
      for (let i = 0; i < RNNOISE_SAMPLE_LENGTH; i++) {
        pcmFrame[i] = this._wasmInterface.HEAPF32[this._wasmPcmInputF32Index + i] / SHIFT_16_BIT_NR;
      }
    }
    return vadScore;
  }
};

// node_modules/@timephy/rnnoise-wasm/dist/generated/rnnoise-sync.js
var createRNNWasmModuleSync = (() => {
  var _scriptName = import.meta.url;
  return (function(moduleArg = {}) {
    var moduleRtn;
    var Module = moduleArg;
    var readyPromiseResolve, readyPromiseReject;
    var readyPromise = new Promise((resolve, reject) => {
      readyPromiseResolve = resolve;
      readyPromiseReject = reject;
    });
    var ENVIRONMENT_IS_WEB = typeof window == "object";
    var ENVIRONMENT_IS_WORKER = typeof importScripts == "function";
    var ENVIRONMENT_IS_NODE = typeof process == "object" && typeof process.versions == "object" && typeof process.versions.node == "string";
    var moduleOverrides = Object.assign({}, Module);
    var arguments_ = [];
    var thisProgram = "./this.program";
    var quit_ = (status, toThrow) => {
      throw toThrow;
    };
    var scriptDirectory = "";
    var read_, readAsync, readBinary;
    if (ENVIRONMENT_IS_WEB || ENVIRONMENT_IS_WORKER) {
      if (ENVIRONMENT_IS_WORKER) {
        scriptDirectory = self.location.href;
      } else if (typeof document != "undefined" && document.currentScript) {
        scriptDirectory = document.currentScript.src;
      }
      if (_scriptName) {
        scriptDirectory = _scriptName;
      }
      if (scriptDirectory.startsWith("blob:")) {
        scriptDirectory = "";
      } else {
        scriptDirectory = scriptDirectory.substr(0, scriptDirectory.replace(/[?#].*/, "").lastIndexOf("/") + 1);
      }
      {
        read_ = (url) => {
          var xhr = new XMLHttpRequest();
          xhr.open("GET", url, false);
          xhr.send(null);
          return xhr.responseText;
        };
        if (ENVIRONMENT_IS_WORKER) {
          readBinary = (url) => {
            var xhr = new XMLHttpRequest();
            xhr.open("GET", url, false);
            xhr.responseType = "arraybuffer";
            xhr.send(null);
            return new Uint8Array(
              /** @type{!ArrayBuffer} */
              xhr.response
            );
          };
        }
        readAsync = (url, onload, onerror) => {
          fetch(url, {
            credentials: "same-origin"
          }).then((response) => {
            if (response.ok) {
              return response.arrayBuffer();
            }
            return Promise.reject(new Error(response.status + " : " + response.url));
          }).then(onload, onerror);
        };
      }
    } else {
    }
    var out = Module["print"] || console.log.bind(console);
    var err = Module["printErr"] || console.error.bind(console);
    Object.assign(Module, moduleOverrides);
    moduleOverrides = null;
    if (Module["arguments"])
      arguments_ = Module["arguments"];
    if (Module["thisProgram"])
      thisProgram = Module["thisProgram"];
    if (Module["quit"])
      quit_ = Module["quit"];
    var wasmBinary;
    if (Module["wasmBinary"])
      wasmBinary = Module["wasmBinary"];
    function intArrayFromBase64(s) {
      var decoded = atob(s);
      var bytes = new Uint8Array(decoded.length);
      for (var i = 0; i < decoded.length; ++i) {
        bytes[i] = decoded.charCodeAt(i);
      }
      return bytes;
    }
    function tryParseAsDataURI(filename) {
      if (!isDataURI(filename)) {
        return;
      }
      return intArrayFromBase64(filename.slice(dataURIPrefix.length));
    }
    var wasmMemory;
    var ABORT = false;
    var HEAP8, HEAPU8, HEAP16, HEAPU16, HEAP32, HEAPU32, HEAPF32, HEAPF64;
    function updateMemoryViews() {
      var b = wasmMemory.buffer;
      Module["HEAP8"] = HEAP8 = new Int8Array(b);
      Module["HEAP16"] = HEAP16 = new Int16Array(b);
      Module["HEAPU8"] = HEAPU8 = new Uint8Array(b);
      Module["HEAPU16"] = HEAPU16 = new Uint16Array(b);
      Module["HEAP32"] = HEAP32 = new Int32Array(b);
      Module["HEAPU32"] = HEAPU32 = new Uint32Array(b);
      Module["HEAPF32"] = HEAPF32 = new Float32Array(b);
      Module["HEAPF64"] = HEAPF64 = new Float64Array(b);
    }
    var __ATPRERUN__ = [];
    var __ATINIT__ = [];
    var __ATPOSTRUN__ = [];
    var runtimeInitialized = false;
    function preRun() {
      if (Module["preRun"]) {
        if (typeof Module["preRun"] == "function")
          Module["preRun"] = [Module["preRun"]];
        while (Module["preRun"].length) {
          addOnPreRun(Module["preRun"].shift());
        }
      }
      callRuntimeCallbacks(__ATPRERUN__);
    }
    function initRuntime() {
      runtimeInitialized = true;
      callRuntimeCallbacks(__ATINIT__);
    }
    function postRun() {
      if (Module["postRun"]) {
        if (typeof Module["postRun"] == "function")
          Module["postRun"] = [Module["postRun"]];
        while (Module["postRun"].length) {
          addOnPostRun(Module["postRun"].shift());
        }
      }
      callRuntimeCallbacks(__ATPOSTRUN__);
    }
    function addOnPreRun(cb) {
      __ATPRERUN__.unshift(cb);
    }
    function addOnInit(cb) {
      __ATINIT__.unshift(cb);
    }
    function addOnPostRun(cb) {
      __ATPOSTRUN__.unshift(cb);
    }
    var runDependencies = 0;
    var runDependencyWatcher = null;
    var dependenciesFulfilled = null;
    function addRunDependency(id) {
      runDependencies++;
      Module["monitorRunDependencies"]?.(runDependencies);
    }
    function removeRunDependency(id) {
      runDependencies--;
      Module["monitorRunDependencies"]?.(runDependencies);
      if (runDependencies == 0) {
        if (runDependencyWatcher !== null) {
          clearInterval(runDependencyWatcher);
          runDependencyWatcher = null;
        }
        if (dependenciesFulfilled) {
          var callback = dependenciesFulfilled;
          dependenciesFulfilled = null;
          callback();
        }
      }
    }
    var dataURIPrefix = "data:application/octet-stream;base64,";
    var isDataURI = (filename) => filename.startsWith(dataURIPrefix);
    function findWasmBinary() {
      var f = "data:application/octet-stream;base64,[encoded data, 1920124 characters]";
      return f;
    }
    var wasmBinaryFile;
    function getBinarySync(file) {
      if (file == wasmBinaryFile && wasmBinary) {
        return new Uint8Array(wasmBinary);
      }
      var binary = tryParseAsDataURI(file);
      if (binary) {
        return binary;
      }
      if (readBinary) {
        return readBinary(file);
      }
      throw 'sync fetching of the wasm failed: you can preload it to Module["wasmBinary"] manually, or emcc.py will do that for you when generating HTML (but not JS)';
    }
    function instantiateSync(file, info) {
      var module;
      var binary = getBinarySync(file);
      module = new WebAssembly.Module(binary);
      var instance = new WebAssembly.Instance(module, info);
      return [instance, module];
    }
    function getWasmImports() {
      return {
        "a": wasmImports
      };
    }
    function createWasm() {
      var info = getWasmImports();
      function receiveInstance(instance, module) {
        wasmExports = instance.exports;
        wasmMemory = wasmExports["c"];
        updateMemoryViews();
        addOnInit(wasmExports["d"]);
        removeRunDependency("wasm-instantiate");
        return wasmExports;
      }
      addRunDependency("wasm-instantiate");
      if (Module["instantiateWasm"]) {
        try {
          return Module["instantiateWasm"](info, receiveInstance);
        } catch (e) {
          err(`Module.instantiateWasm callback failed with error: ${e}`);
          readyPromiseReject(e);
        }
      }
      if (!wasmBinaryFile)
        wasmBinaryFile = findWasmBinary();
      var result = instantiateSync(wasmBinaryFile, info);
      return receiveInstance(result[0]);
    }
    var callRuntimeCallbacks = (callbacks) => {
      while (callbacks.length > 0) {
        callbacks.shift()(Module);
      }
    };
    var noExitRuntime = Module["noExitRuntime"] || true;
    var __emscripten_memcpy_js = (dest, src, num) => HEAPU8.copyWithin(dest, src, src + num);
    var getHeapMax = () => 2147483648;
    var growMemory = (size) => {
      var b = wasmMemory.buffer;
      var pages = (size - b.byteLength + 65535) / 65536;
      try {
        wasmMemory.grow(pages);
        updateMemoryViews();
        return 1;
      } catch (e) {
      }
    };
    var _emscripten_resize_heap = (requestedSize) => {
      var oldSize = HEAPU8.length;
      requestedSize >>>= 0;
      var maxHeapSize = getHeapMax();
      if (requestedSize > maxHeapSize) {
        return false;
      }
      var alignUp = (x, multiple) => x + (multiple - x % multiple) % multiple;
      for (var cutDown = 1; cutDown <= 4; cutDown *= 2) {
        var overGrownHeapSize = oldSize * (1 + 0.2 / cutDown);
        overGrownHeapSize = Math.min(overGrownHeapSize, requestedSize + 100663296);
        var newSize = Math.min(maxHeapSize, alignUp(Math.max(requestedSize, overGrownHeapSize), 65536));
        var replacement = growMemory(newSize);
        if (replacement) {
          return true;
        }
      }
      return false;
    };
    var wasmImports = {
      /** @export */
      b: __emscripten_memcpy_js,
      /** @export */
      a: _emscripten_resize_heap
    };
    var wasmExports = createWasm();
    var ___wasm_call_ctors = wasmExports["d"];
    var _malloc = Module["_malloc"] = wasmExports["e"];
    var _free = Module["_free"] = wasmExports["f"];
    var _rnnoise_init = Module["_rnnoise_init"] = wasmExports["g"];
    var _rnnoise_create = Module["_rnnoise_create"] = wasmExports["h"];
    var _rnnoise_destroy = Module["_rnnoise_destroy"] = wasmExports["i"];
    var _rnnoise_process_frame = Module["_rnnoise_process_frame"] = wasmExports["j"];
    var calledRun;
    dependenciesFulfilled = function runCaller() {
      if (!calledRun)
        run();
      if (!calledRun)
        dependenciesFulfilled = runCaller;
    };
    function run() {
      if (runDependencies > 0) {
        return;
      }
      preRun();
      if (runDependencies > 0) {
        return;
      }
      function doRun() {
        if (calledRun)
          return;
        calledRun = true;
        Module["calledRun"] = true;
        if (ABORT)
          return;
        initRuntime();
        readyPromiseResolve(Module);
        if (Module["onRuntimeInitialized"])
          Module["onRuntimeInitialized"]();
        postRun();
      }
      if (Module["setStatus"]) {
        Module["setStatus"]("Running...");
        setTimeout(function() {
          setTimeout(function() {
            Module["setStatus"]("");
          }, 1);
          doRun();
        }, 1);
      } else {
        doRun();
      }
    }
    if (Module["preInit"]) {
      if (typeof Module["preInit"] == "function")
        Module["preInit"] = [Module["preInit"]];
      while (Module["preInit"].length > 0) {
        Module["preInit"].pop()();
      }
    }
    run();
    moduleRtn = Module;
    return moduleRtn;
  });
})();
var rnnoise_sync_default = createRNNWasmModuleSync;

// node_modules/@timephy/rnnoise-wasm/dist/index.js
var NoiseSuppressorWorklet_Name = "NoiseSuppressorWorklet";

// node_modules/@timephy/rnnoise-wasm/dist/math.js
function greatestCommonDivisor(num1, num2) {
  let number1 = num1;
  let number2 = num2;
  while (number1 !== number2) {
    if (number1 > number2) {
      number1 = number1 - number2;
    } else {
      number2 = number2 - number1;
    }
  }
  return number2;
}
function leastCommonMultiple(num1, num2) {
  const number1 = num1;
  const number2 = num2;
  const gcd = greatestCommonDivisor(number1, number2);
  return number1 * number2 / gcd;
}

// node_modules/@timephy/rnnoise-wasm/dist/NoiseSuppressorWorklet.js
var NoiseSuppressorWorklet = class extends AudioWorkletProcessor {
  /**
   * RnnoiseProcessor instance.
   */
  _denoiseProcessor;
  /**
   * Audio worklets work with a predefined sample rate of 128.
   */
  _procNodeSampleRate = 128;
  /**
   * PCM Sample size expected by the denoise processor.
   */
  _denoiseSampleSize;
  /**
   * Circular buffer data used for efficient memory operations.
   */
  _circularBufferLength;
  _circularBuffer;
  /**
   * The circular buffer uses a couple of indexes to track data segments. Input data from the stream is
   * copied to the circular buffer as it comes in, one `procNodeSampleRate` sized sample at a time.
   * _inputBufferLength denotes the current length of all gathered raw audio segments.
   */
  _inputBufferLength = 0;
  /**
   * Denoising is done directly on the circular buffer using subArray views, but because
   * `procNodeSampleRate` and `_denoiseSampleSize` have different sizes, denoised samples lag behind
   * the current gathered raw audio samples so we need a different index, `_denoisedBufferLength`.
   */
  _denoisedBufferLength = 0;
  /**
   * Once enough data has been denoised (size of procNodeSampleRate) it's sent to the
   * output buffer, `_denoisedBufferIndx` indicates the start index on the circular buffer
   * of denoised data not yet sent.
   */
  _denoisedBufferIndx = 0;
  /**
   * C'tor.
   */
  constructor() {
    super();
    this._denoiseProcessor = new RnnoiseProcessor(rnnoise_sync_default());
    this._denoiseSampleSize = this._denoiseProcessor.getSampleLength();
    this._circularBufferLength = leastCommonMultiple(this._procNodeSampleRate, this._denoiseSampleSize);
    this._circularBuffer = new Float32Array(this._circularBufferLength);
  }
  /**
   * Worklet interface process method. The inputs parameter contains PCM audio that is then sent to rnnoise.
   * Rnnoise only accepts PCM samples of 480 bytes whereas `process` handles 128 sized samples, we take this into
   * account using a circular buffer.
   *
   * @param {Float32Array[]} inputs - Array of inputs connected to the node, each of them with their associated
   * array of channels. Each channel is an array of 128 pcm samples.
   * @param {Float32Array[]} outputs - Array of outputs similar to the inputs parameter structure, expected to be
   * filled during the execution of `process`. By default each channel is zero filled.
   * @returns {boolean} - Boolean value that returns whether or not the processor should remain active. Returning
   * false will terminate it.
   */
  process(inputs, outputs) {
    const inData = inputs[0][0];
    const outData = outputs[0][0];
    if (!inData) {
      return true;
    }
    this._circularBuffer.set(inData, this._inputBufferLength);
    this._inputBufferLength += inData.length;
    for (; this._denoisedBufferLength + this._denoiseSampleSize <= this._inputBufferLength; this._denoisedBufferLength += this._denoiseSampleSize) {
      const denoiseFrame = this._circularBuffer.subarray(this._denoisedBufferLength, this._denoisedBufferLength + this._denoiseSampleSize);
      this._denoiseProcessor.processAudioFrame(denoiseFrame, true);
    }
    let unsentDenoisedDataLength;
    if (this._denoisedBufferIndx > this._denoisedBufferLength) {
      unsentDenoisedDataLength = this._circularBufferLength - this._denoisedBufferIndx;
    } else {
      unsentDenoisedDataLength = this._denoisedBufferLength - this._denoisedBufferIndx;
    }
    if (unsentDenoisedDataLength >= outData.length) {
      const denoisedFrame = this._circularBuffer.subarray(this._denoisedBufferIndx, this._denoisedBufferIndx + outData.length);
      outData.set(denoisedFrame, 0);
      this._denoisedBufferIndx += outData.length;
    }
    if (this._denoisedBufferIndx === this._circularBufferLength) {
      this._denoisedBufferIndx = 0;
    }
    if (this._inputBufferLength === this._circularBufferLength) {
      this._inputBufferLength = 0;
      this._denoisedBufferLength = 0;
    }
    return true;
  }
};
registerProcessor(NoiseSuppressorWorklet_Name, NoiseSuppressorWorklet);
