UNPKG

@dmk-dark/opus-media-recorder-fork

Version:

MedialRecorer polyfill for Opus recording using WebAssembly

17 lines (16 loc) 45.7 kB
(function OpusMediaWorkerUMD(root, factory) { if (typeof WorkerGlobalScope !== 'undefined' && self instanceof WorkerGlobalScope) { var initWorker = factory(); initWorker(); } else if(typeof exports === 'object' && typeof module === 'object') module.exports = factory(); else if(typeof define === 'function' && define.amd) define([], factory); else if(typeof exports === 'object') exports["encoderWorker"] = factory(); else root["encoderWorker"] = factory(); })(typeof OpusMediaRecorder !== 'undefined' ? OpusMediaRecorder : typeof self !== 'undefined' ? self : this, function() { return function() {!function(e){var t={};function n(r){if(t[r])return t[r].exports;var o=t[r]={i:r,l:!1,exports:{}};return e[r].call(o.exports,o,o.exports,n),o.l=!0,o.exports}n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)n.d(r,o,function(t){return e[t]}.bind(null,o));return r},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=5)}([function(e,t,n){(function(e){function n(e,t){for(var n=0,r=e.length-1;r>=0;r--){var o=e[r];"."===o?e.splice(r,1):".."===o?(e.splice(r,1),n++):n&&(e.splice(r,1),n--)}if(t)for(;n--;n)e.unshift("..");return e}function r(e,t){if(e.filter)return e.filter(t);for(var n=[],r=0;r<e.length;r++)t(e[r],r,e)&&n.push(e[r]);return n}t.resolve=function(){for(var t="",o=!1,i=arguments.length-1;i>=-1&&!o;i--){var u=i>=0?arguments[i]:e.cwd();if("string"!=typeof u)throw new TypeError("Arguments to path.resolve must be strings");u&&(t=u+"/"+t,o="/"===u.charAt(0))}return(o?"/":"")+(t=n(r(t.split("/"),(function(e){return!!e})),!o).join("/"))||"."},t.normalize=function(e){var i=t.isAbsolute(e),u="/"===o(e,-1);return(e=n(r(e.split("/"),(function(e){return!!e})),!i).join("/"))||i||(e="."),e&&u&&(e+="/"),(i?"/":"")+e},t.isAbsolute=function(e){return"/"===e.charAt(0)},t.join=function(){var e=Array.prototype.slice.call(arguments,0);return t.normalize(r(e,(function(e,t){if("string"!=typeof e)throw new TypeError("Arguments to path.join must be strings");return e})).join("/"))},t.relative=function(e,n){function r(e){for(var t=0;t<e.length&&""===e[t];t++);for(var n=e.length-1;n>=0&&""===e[n];n--);return t>n?[]:e.slice(t,n-t+1)}e=t.resolve(e).substr(1),n=t.resolve(n).substr(1);for(var o=r(e.split("/")),i=r(n.split("/")),u=Math.min(o.length,i.length),a=u,s=0;s<u;s++)if(o[s]!==i[s]){a=s;break}var c=[];for(s=a;s<o.length;s++)c.push("..");return(c=c.concat(i.slice(a))).join("/")},t.sep="/",t.delimiter=":",t.dirname=function(e){if("string"!=typeof e&&(e+=""),0===e.length)return".";for(var t=e.charCodeAt(0),n=47===t,r=-1,o=!0,i=e.length-1;i>=1;--i)if(47===(t=e.charCodeAt(i))){if(!o){r=i;break}}else o=!1;return-1===r?n?"/":".":n&&1===r?"/":e.slice(0,r)},t.basename=function(e,t){var n=function(e){"string"!=typeof e&&(e+="");var t,n=0,r=-1,o=!0;for(t=e.length-1;t>=0;--t)if(47===e.charCodeAt(t)){if(!o){n=t+1;break}}else-1===r&&(o=!1,r=t+1);return-1===r?"":e.slice(n,r)}(e);return t&&n.substr(-1*t.length)===t&&(n=n.substr(0,n.length-t.length)),n},t.extname=function(e){"string"!=typeof e&&(e+="");for(var t=-1,n=0,r=-1,o=!0,i=0,u=e.length-1;u>=0;--u){var a=e.charCodeAt(u);if(47!==a)-1===r&&(o=!1,r=u+1),46===a?-1===t?t=u:1!==i&&(i=1):-1!==t&&(i=-1);else if(!o){n=u+1;break}}return-1===t||-1===r||0===i||1===i&&t===r-1&&t===n+1?"":e.slice(t,r)};var o="b"==="ab".substr(-1)?function(e,t,n){return e.substr(t,n)}:function(e,t,n){return t<0&&(t=e.length+t),e.substr(t,n)}}).call(this,n(2))},function(e,t){function n(e,t,n){return t=r(t),function(e,t){if(t&&("object"==u(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e)}(e,function(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(e){}return function(){return!!e}()}()?Reflect.construct(t,n||[],r(e).constructor):t.apply(e,n))}function r(e){return(r=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function o(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&i(e,t)}function i(e,t){return(i=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e})(e,t)}function u(e){return(u="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function a(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function s(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,f(r.key),r)}}function c(e,t,n){return t&&s(e.prototype,t),n&&s(e,n),Object.defineProperty(e,"prototype",{writable:!1}),e}function f(e){var t=function(e,t){if("object"!=u(e)||!e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var r=n.call(e,t||"default");if("object"!=u(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==u(t)?t:t+""}var l=function(){return c((function e(t,n,r,o){switch(a(this,e),this._size=n,this._module=t,this._size){case 1:this._heapArray=r?this._module.HEAP8:this._module.HEAPU8;break;case 2:this._heapArray=r?this._module.HEAP16:this._module.HEAPU16;break;case 4:this._heapArray=r?this._module.HEAP32:this._module.HEAPU32;break;default:this._heapArray=this._module.HEAPU8}o&&(this._size=4,this._heapArray=this._module.HEAPF32),this._pointer=this._module._malloc(n)}),[{key:"free",value:function(){this._module._free(this.pointer)}},{key:"pointer",get:function(){return this._pointer}},{key:"value",get:function(){var e=0;switch(this._size){case 2:e=1;break;case 4:e=2;break;default:throw new Error("Pointer can be only deferenced as integer-sized")}return this._heapArray[this.pointer>>e]},set:function(e){var t=0;switch(this._size){case 2:t=1;break;case 4:t=2;break;default:throw new Error("Pointer can be only deferenced as integer-sized")}this._heapArray[this.pointer>>t]=e}}])}(),p=function(e){function t(e,r){var o;return a(this,t),o=n(this,t,[e,4,!0,!1]),void 0!==r&&(o.value=r),o}return o(t,e),c(t)}(l),_=function(e){function t(e,r){var o;return a(this,t),o=n(this,t,[e,4,!1,!1]),void 0!==r&&(o.value=r),o}return o(t,e),c(t)}(l),d=function(e){function t(e,r,o,i,u){var s;a(this,t),s=n(this,t,[e,r*o,i,u]);var c=0;switch(o){case 1:s._heapArray=i?s._module.HEAP8:s._module.HEAPU8,c=0;break;case 2:s._heapArray=i?s._module.HEAP16:s._module.HEAPU16,c=1;break;case 4:s._heapArray=i?s._module.HEAP32:s._module.HEAPU32,c=2;break;default:throw new Error("Unit size must be an integer-size")}u&&(s._heapArray=s._module.HEAPF32,c=2);var f=s._pointer>>c;return s._buffer=s._heapArray.subarray(f,f+r),s._length=r,s}return o(t,e),c(t,[{key:"set",value:function(e,t){this._buffer.set(e,t)}},{key:"subarray",value:function(e,t){return this._buffer.subarray(e,t)}},{key:"length",get:function(){return this._length}}])}(l),m=function(e){function t(e,r){return a(this,t),n(this,t,[e,r,4,!0,!0])}return o(t,e),c(t)}(d),h=function(e){function t(e,r){return a(this,t),n(this,t,[e,r,1,!1,!1])}return o(t,e),c(t)}(d),y=function(){return c((function e(t){a(this,e),this._module=t}),[{key:"mallocInt32",value:function(e){return new p(this._module,e)}},{key:"mallocUint32",value:function(e){return new _(this._module,e)}},{key:"mallocUint8Buffer",value:function(e){return new h(this._module,e)}},{key:"mallocFloat32Buffer",value:function(e){return new m(this._module,e)}}])}();e.exports={writeString:function(e,t,n){for(var r=0;r<n.length;r++)e.setUint8(t+r,n.charCodeAt(r))},EmscriptenMemoryAllocator:y}},function(e,t){var n,r,o=e.exports={};function i(){throw new Error("setTimeout has not been defined")}function u(){throw new Error("clearTimeout has not been defined")}function a(e){if(n===setTimeout)return setTimeout(e,0);if((n===i||!n)&&setTimeout)return n=setTimeout,setTimeout(e,0);try{return n(e,0)}catch(t){try{return n.call(null,e,0)}catch(t){return n.call(this,e,0)}}}!function(){try{n="function"==typeof setTimeout?setTimeout:i}catch(e){n=i}try{r="function"==typeof clearTimeout?clearTimeout:u}catch(e){r=u}}();var s,c=[],f=!1,l=-1;function p(){f&&s&&(f=!1,s.length?c=s.concat(c):l=-1,c.length&&_())}function _(){if(!f){var e=a(p);f=!0;for(var t=c.length;t;){for(s=c,c=[];++l<t;)s&&s[l].run();l=-1,t=c.length}s=null,f=!1,function(e){if(r===clearTimeout)return clearTimeout(e);if((r===u||!r)&&clearTimeout)return r=clearTimeout,clearTimeout(e);try{r(e)}catch(t){try{return r.call(null,e)}catch(t){return r.call(this,e)}}}(e)}}function d(e,t){this.fun=e,this.array=t}function m(){}o.nextTick=function(e){var t=new Array(arguments.length-1);if(arguments.length>1)for(var n=1;n<arguments.length;n++)t[n-1]=arguments[n];c.push(new d(e,t)),1!==c.length||f||a(_)},d.prototype.run=function(){this.fun.apply(null,this.array)},o.title="browser",o.browser=!0,o.env={},o.argv=[],o.version="",o.versions={},o.on=m,o.addListener=m,o.once=m,o.off=m,o.removeListener=m,o.removeAllListeners=m,o.emit=m,o.prependListener=m,o.prependOnceListener=m,o.listeners=function(e){return[]},o.binding=function(e){throw new Error("process.binding is not supported")},o.cwd=function(){return"/"},o.chdir=function(e){throw new Error("process.chdir is not supported")},o.umask=function(){return 0}},function(e,t){e.exports=function(e){return e.webpackPolyfill||(e.deprecate=function(){},e.paths=[],e.children||(e.children=[]),Object.defineProperty(e,"loaded",{enumerable:!0,get:function(){return e.l}}),Object.defineProperty(e,"id",{enumerable:!0,get:function(){return e.i}}),e.webpackPolyfill=1),e}},function(e,t){},function(e,t,n){function r(e){var t,r=n(6),o=n(7),i=n(8);e.onmessage=function(e){var n=e.data.command;switch(n){case"loadEncoder":var u,a=e.data,s=a.mimeType,c=a.wasmPath;switch(s){case"audio/wav":case"audio/wave":u=r;break;case"audio/webm":u=o;break;case"audio/ogg":u=i}var f={};c&&(f.locateFile=function(e,t){return e.match(/.wasm/)?c:t+e}),u(f).then((function(e){t=e,self.postMessage({command:"readyToInit"})}));break;case"init":var l=e.data,p=l.sampleRate,_=l.channelCount,d=l.bitsPerSecond;t.init(p,_,d);break;case"pushInputData":for(var m=e.data,h=m.channelBuffers,y=(m.length,m.duration,0);y<h.length;y++)h[y]=new Float32Array(h[y].buffer);t.encode(h);break;case"getEncodedData":case"done":"done"===n&&t.close();var v=t.flush();self.postMessage({command:"done"===n?"lastEncodedData":"encodedData",buffers:v},v),"done"===n&&self.close()}}}"undefined"!=typeof WorkerGlobalScope&&self instanceof WorkerGlobalScope&&r(self),e.exports=r},function(e,t,n){function r(e){return(r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function o(e){return function(e){if(Array.isArray(e))return i(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||function(e,t){if(e){if("string"==typeof e)return i(e,t);var n={}.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?i(e,t):void 0}}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function i(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function u(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,a(r.key),r)}}function a(e){var t=function(e,t){if("object"!=r(e)||!e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var o=n.call(e,t||"default");if("object"!=r(o))return o;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==r(t)?t:t+""}var s=n(1).writeString,c=Int16Array.BYTES_PER_ELEMENT,f=function(){return e=function e(t,n,r){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.config={inputSampleRate:t,channelCount:n},this.encodedBuffers=[]},(t=[{key:"encode",value:function(e){for(var t=e[0].length,n=new ArrayBuffer(t*c*this.config.channelCount),r=new DataView(n),o=0;o<this.config.channelCount;o++)for(var i=e[o],u=0;u<t;u++){var a=32767*i[u]|0;a>32767?a=32767:a<-32768&&(a=-32768);var s=(u*this.config.channelCount+o)*c;r.setInt16(s,0|a,!0)}this.encodedBuffers.push(n)}},{key:"getHeader",value:function(){var e=this.encodedBuffers.reduce((function(e,t){return e+t.byteLength}),0),t=new ArrayBuffer(44),n=new DataView(t);return s(n,0,"RIFF"),n.setUint32(4,36+e,!0),s(n,8,"WAVE"),s(n,12,"fmt "),n.setUint32(16,16,!0),n.setUint16(20,1,!0),n.setUint16(22,this.config.channelCount,!0),n.setUint32(24,this.config.inputSampleRate,!0),n.setUint32(28,this.config.inputSampleRate*c*this.config.channelCount,!0),n.setUint16(32,c*this.config.channelCount,!0),n.setUint16(34,8*c,!0),s(n,36,"data"),n.setUint32(40,e,!0),t}}])&&u(e.prototype,t),n&&u(e,n),Object.defineProperty(e,"prototype",{writable:!1}),e;var e,t,n}();e.exports=function(e){return new Promise((function(t,n){(e=void 0!==e&&e||{}).init=function(t,n,r){e.encoder=new f(t,n,r)},e.encode=function(t){e.encoder.encode(t)},e.flush=function(){var t=e.encoder.getHeader(),n=e.encoder.encodedBuffers.splice(0,e.encoder.encodedBuffers.length);return[t].concat(o(n))},e.close=function(){},t(e)}))}},function(e,t,n){(function(e,r,o,i){var u;function a(e){return(a="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function s(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function c(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,l(r.key),r)}}function f(e,t,n){return t&&c(e.prototype,t),n&&c(e,n),Object.defineProperty(e,"prototype",{writable:!1}),e}function l(e){var t=function(e,t){if("object"!=a(e)||!e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var r=n.call(e,t||"default");if("object"!=a(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==a(t)?t:t+""}var p,_=(p=(p="undefined"!=typeof document&&document.currentScript?document.currentScript.src:void 0)||e,function(e){e=void 0!==(e=e||{})?e:{};var t=n(1),i=t.EmscriptenMemoryAllocator,u=2049,c=48e3,l=4e3,_=20,d=6,m=4096,h=0,y=4002,v=0,b=function(){return f((function t(n,r){var o=arguments.length>2&&void 0!==arguments[2]?arguments[2]:void 0;s(this,t),this.config={inputSampleRate:n,channelCount:r},this.memory=new i(e),this._opus_encoder_create=e._opus_encoder_create,this._opus_encoder_ctl=e._opus_encoder_ctl,this._opus_encode_float=e._opus_encode_float,this._opus_encoder_destroy=e._opus_encoder_destroy,this._speex_resampler_init=e._speex_resampler_init,this._speex_resampler_process_interleaved_float=e._speex_resampler_process_interleaved_float,this._speex_resampler_destroy=e._speex_resampler_destroy,this._container=new e.Container,this._container.init(c,r,Math.floor(4294967295*Math.random())),this.OpusInitCodec(c,r,o),this.SpeexInitResampler(n,c,r),this.inputSamplesPerChannel=n*_/1e3,this.outputSamplePerChannel=c*_/1e3,this.inputBufferIndex=0,this.mInputBuffer=this.memory.mallocFloat32Buffer(this.inputSamplesPerChannel*r),this.mResampledBuffer=this.memory.mallocFloat32Buffer(this.outputSamplePerChannel*r),this.mOutputBuffer=this.memory.mallocUint8Buffer(l),this.interleavedBuffers=1!==r?new Float32Array(m*r):void 0}),[{key:"encode",value:function(e){for(var t=this.interleave(e),n=0;n<t.length;){var r=Math.min(this.mInputBuffer.length-this.inputBufferIndex,t.length-n);if(this.mInputBuffer.set(t.subarray(n,n+r),this.inputBufferIndex),this.inputBufferIndex+=r,this.inputBufferIndex>=this.mInputBuffer.length){var o=this.memory.mallocUint32(this.inputSamplesPerChannel),i=this.memory.mallocUint32(this.outputSamplePerChannel),u=this._speex_resampler_process_interleaved_float(this.resampler,this.mInputBuffer.pointer,o.pointer,this.mResampledBuffer.pointer,i.pointer);if(o.free(),i.free(),u!==v)throw new Error("Resampling error.");var a=this._opus_encode_float(this.encoder,this.mResampledBuffer.pointer,this.outputSamplePerChannel,this.mOutputBuffer.pointer,this.mOutputBuffer.length);if(a<0)throw new Error("Opus encoding error.");this._container.writeFrame(this.mOutputBuffer.pointer,a,this.outputSamplePerChannel),this.inputBufferIndex=0}n+=r}}},{key:"close",value:function(){for(var t=this.config.channelCount,n=[],r=0;r<t;++r)n.push(new Float32Array(m-this.inputBufferIndex/t));this.encode(n),e.destroy(this._container),this.mInputBuffer.free(),this.mResampledBuffer.free(),this.mOutputBuffer.free(),this._opus_encoder_destroy(this.encoder),this._speex_resampler_destroy(this.resampler)}},{key:"interleave",value:function(e){var t=e.length;if(1===t)return e[0];for(var n=0;n<t;n++)for(var r=e[n],o=0;o<r.length;o++)this.interleavedBuffers[o*t+n]=r[o];return this.interleavedBuffers}},{key:"OpusInitCodec",value:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:void 0,r=this.memory.mallocUint32(void 0);this.encoder=this._opus_encoder_create(e,t,u,r.pointer);var o=r.value;if(r.free(),o!==h)throw new Error("Opus encodor initialization failed.");n&&this.OpusSetOpusControl(y,n)}},{key:"OpusSetOpusControl",value:function(e,t){var n=this.memory.mallocInt32(t);this._opus_encoder_ctl(this.encoder,e,n.pointer),n.free()}},{key:"SpeexInitResampler",value:function(e,t,n){var r=this.memory.mallocUint32(void 0);this.resampler=this._speex_resampler_init(n,e,t,d,r.pointer);var o=r.value;if(r.free(),o!==v)throw new Error("Initializing resampler failed.")}}])}();e.init=function(t,n,r){e.encodedBuffers=[],e.encoder=new b(t,n,r)},e.encode=function(t){e.encoder.encode(t)},e.flush=function(){return e.encodedBuffers.splice(0,e.encodedBuffers.length)},e.close=function(){e.encoder.close()};var g,w={};for(g in e)e.hasOwnProperty(g)&&(w[g]=e[g]);var A=[],S=!1,P=!1,C=!1,E=!1;S="object"===("undefined"==typeof window?"undefined":a(window)),P="function"==typeof importScripts,C="object"===(void 0===r?"undefined":a(r))&&"object"===a(r.versions)&&"string"==typeof r.versions.node,E=!S&&!C&&!P;var x,j,B,O,I="";function R(t){return e.locateFile?e.locateFile(t,I):I+t}C?(I=P?n(0).dirname(I)+"/":o+"/",x=function(e,t){return B||(B=n(4)),O||(O=n(0)),e=O.normalize(e),B.readFileSync(e,t?null:"utf8")},j=function(e){var t=x(e,!0);return t.buffer||(t=new Uint8Array(t)),W(t.buffer),t},r.argv.length>1&&r.argv[1].replace(/\\/g,"/"),A=r.argv.slice(2),r.on("uncaughtException",(function(e){if(!(e instanceof Ve))throw e})),r.on("unhandledRejection",_e),e.inspect=function(){return"[Emscripten Module object]"}):E?("undefined"!=typeof read&&(x=function(e){return read(e)}),j=function(e){var t;return"function"==typeof readbuffer?new Uint8Array(readbuffer(e)):(W("object"===a(t=read(e,"binary"))),t)},"undefined"!=typeof scriptArgs?A=scriptArgs:void 0!==arguments&&(A=arguments),"undefined"!=typeof print&&("undefined"==typeof console&&(console={}),console.log=print,console.warn=console.error="undefined"!=typeof printErr?printErr:print)):(S||P)&&(P?I=self.location.href:document.currentScript&&(I=document.currentScript.src),p&&(I=p),I=0!==I.indexOf("blob:")?I.substr(0,I.lastIndexOf("/")+1):"",x=function(e){var t=new XMLHttpRequest;return t.open("GET",e,!1),t.send(null),t.responseText},P&&(j=function(e){var t=new XMLHttpRequest;return t.open("GET",e,!1),t.responseType="arraybuffer",t.send(null),new Uint8Array(t.response)}));var k,T,U=e.print||console.log.bind(console),F=e.printErr||console.warn.bind(console);for(g in w)w.hasOwnProperty(g)&&(e[g]=w[g]);w=null,e.arguments&&(A=e.arguments),e.thisProgram&&e.thisProgram,e.quit&&e.quit,e.wasmBinary&&(k=e.wasmBinary),e.noExitRuntime&&e.noExitRuntime,"object"!==("undefined"==typeof WebAssembly?"undefined":a(WebAssembly))&&F("no native wasm support detected");var H=new WebAssembly.Table({initial:60,maximum:60,element:"anyfunc"}),M=!1;function W(e,t){e||_e("Assertion failed: "+t)}var D="undefined"!=typeof TextDecoder?new TextDecoder("utf8"):void 0;function z(e,t,n){for(var r=t+n,o=t;e[o]&&!(o>=r);)++o;if(o-t>16&&e.subarray&&D)return D.decode(e.subarray(t,o));for(var i="";t<o;){var u=e[t++];if(128&u){var a=63&e[t++];if(192!=(224&u)){var s=63&e[t++];if((u=224==(240&u)?(15&u)<<12|a<<6|s:(7&u)<<18|a<<12|s<<6|63&e[t++])<65536)i+=String.fromCharCode(u);else{var c=u-65536;i+=String.fromCharCode(55296|c>>10,56320|1023&c)}}else i+=String.fromCharCode((31&u)<<6|a)}else i+=String.fromCharCode(u)}return i}function L(e,t){return e?z(V,e,t):""}"undefined"!=typeof TextDecoder&&new TextDecoder("utf-16le");var N,V,q,G=65536;function X(t){N=t,e.HEAP8=new Int8Array(t),e.HEAP16=new Int16Array(t),e.HEAP32=q=new Int32Array(t),e.HEAPU8=V=new Uint8Array(t),e.HEAPU16=new Uint16Array(t),e.HEAPU32=new Uint32Array(t),e.HEAPF32=new Float32Array(t),e.HEAPF64=new Float64Array(t)}var Y=5289024,$=45984,J=e.INITIAL_MEMORY||16777216;function K(t){for(;t.length>0;){var n=t.shift();if("function"!=typeof n){var r=n.func;"number"==typeof r?void 0===n.arg?e.dynCall_v(r):e.dynCall_vi(r,n.arg):r(void 0===n.arg?null:n.arg)}else n()}}(T=e.wasmMemory?e.wasmMemory:new WebAssembly.Memory({initial:J/G,maximum:J/G}))&&(N=T.buffer),J=N.byteLength,X(N),q[$>>2]=Y;var Q=[],Z=[],ee=[],te=[];function ne(){if(e.preRun)for("function"==typeof e.preRun&&(e.preRun=[e.preRun]);e.preRun.length;)ue(e.preRun.shift());K(Q)}function re(){K(Z)}function oe(){K(ee)}function ie(){if(e.postRun)for("function"==typeof e.postRun&&(e.postRun=[e.postRun]);e.postRun.length;)ae(e.postRun.shift());K(te)}function ue(e){Q.unshift(e)}function ae(e){te.unshift(e)}var se=0,ce=null,fe=null;function le(t){se++,e.monitorRunDependencies&&e.monitorRunDependencies(se)}function pe(t){if(se--,e.monitorRunDependencies&&e.monitorRunDependencies(se),0==se&&(null!==ce&&(clearInterval(ce),ce=null),fe)){var n=fe;fe=null,n()}}function _e(t){throw e.onAbort&&e.onAbort(t),U(t+=""),F(t),M=!0,t="abort("+t+"). Build with -s ASSERTIONS=1 for more info.",new WebAssembly.RuntimeError(t)}e.preloadedImages={},e.preloadedAudios={};var de="data:application/octet-stream;base64,";function me(e){return String.prototype.startsWith?e.startsWith(de):0===e.indexOf(de)}var he="WebMOpusEncoder.wasm";function ye(){try{if(k)return new Uint8Array(k);if(j)return j(he);throw"both async and sync fetching of the wasm failed"}catch(e){_e(e)}}function ve(){return k||!S&&!P||"function"!=typeof fetch?new Promise((function(e,t){e(ye())})):fetch(he,{credentials:"same-origin"}).then((function(e){if(!e.ok)throw"failed to load wasm binary file at '"+he+"'";return e.arrayBuffer()})).catch((function(){return ye()}))}function be(){var t={a:Ue};function n(t,n){var r=t.exports;e.asm=r,pe()}function r(e){n(e.instance)}function o(e){return ve().then((function(e){return WebAssembly.instantiate(e,t)})).then(e,(function(e){F("failed to asynchronously prepare wasm: "+e),_e(e)}))}if(le(),e.instantiateWasm)try{return e.instantiateWasm(t,n)}catch(e){return F("Module.instantiateWasm callback failed with error: "+e),!1}return function(){if(k||"function"!=typeof WebAssembly.instantiateStreaming||me(he)||"function"!=typeof fetch)return o(r);fetch(he,{credentials:"same-origin"}).then((function(e){return WebAssembly.instantiateStreaming(e,t).then(r,(function(e){F("wasm streaming compile failed: "+e),F("falling back to ArrayBuffer instantiation"),o(r)}))}))}(),{}}function ge(t,n){var r=new Uint8Array(e.HEAPU8.buffer,t,n);e.encodedBuffers.push(new Uint8Array(r).buffer)}function we(e,t,n,r){_e("Assertion failed: "+L(e)+", at: "+[t?L(t):"unknown filename",n,r?L(r):"unknown function"])}me(he)||(he=R(he)),Z.push({func:function(){Me()}});var Ae={mappings:{},buffers:[null,[],[]],printChar:function(e,t){var n=Ae.buffers[e];0===t||10===t?((1===e?U:F)(z(n,0)),n.length=0):n.push(t)},varargs:void 0,get:function(){return Ae.varargs+=4,q[Ae.varargs-4>>2]},getStr:function(e){return L(e)},get64:function(e,t){return e}};function Se(e,t,n){return Ae.varargs=n,0}function Pe(e,t,n){Ae.varargs=n}function Ce(e,t,n){return Ae.varargs=n,0}function Ee(){_e()}function xe(e,t,n){V.copyWithin(e,t,t+n)}function je(e){_e("OOM")}function Be(e){je()}function Oe(e){return 0}function Ie(e,t,n,r){var o=Ae.getStreamFromFD(e),i=Ae.doReadv(o,t,n);return q[r>>2]=i,0}function Re(e,t,n,r,o){}function ke(e,t,n,r){for(var o=0,i=0;i<n;i++){for(var u=q[t+8*i>>2],a=q[t+(8*i+4)>>2],s=0;s<a;s++)Ae.printChar(e,V[u+s]);o+=a}return q[r>>2]=o,0}function Te(e){var t=Date.now()/1e3|0;return e&&(q[e>>2]=t),t}var Ue={a:we,e:Se,h:Pe,g:Ce,b:Ee,m:ge,k:xe,l:Be,c:Oe,f:Ie,j:Re,d:ke,memory:T,table:H,i:Te},Fe=be();e.asm=Fe;var He,Me=e.___wasm_call_ctors=function(){return(Me=e.___wasm_call_ctors=e.asm.n).apply(null,arguments)},We=(e.___em_js__emscriptenPushBuffer=function(){return(e.___em_js__emscriptenPushBuffer=e.asm.o).apply(null,arguments)},e._emscripten_bind_VoidPtr___destroy___0=function(){return(We=e._emscripten_bind_VoidPtr___destroy___0=e.asm.p).apply(null,arguments)}),De=e._emscripten_bind_Container_Container_0=function(){return(De=e._emscripten_bind_Container_Container_0=e.asm.q).apply(null,arguments)},ze=e._emscripten_bind_Container_init_3=function(){return(ze=e._emscripten_bind_Container_init_3=e.asm.r).apply(null,arguments)},Le=e._emscripten_bind_Container_writeFrame_3=function(){return(Le=e._emscripten_bind_Container_writeFrame_3=e.asm.s).apply(null,arguments)},Ne=e._emscripten_bind_Container___destroy___0=function(){return(Ne=e._emscripten_bind_Container___destroy___0=e.asm.t).apply(null,arguments)};function Ve(e){this.name="ExitStatus",this.message="Program terminated with exit("+e+")",this.status=e}function qe(t){function n(){He||(He=!0,e.calledRun=!0,M||(re(),oe(),e.onRuntimeInitialized&&e.onRuntimeInitialized(),ie()))}t=t||A,se>0||(ne(),se>0||(e.setStatus?(e.setStatus("Running..."),setTimeout((function(){setTimeout((function(){e.setStatus("")}),1),n()}),1)):n()))}if(e._opus_encoder_create=function(){return(e._opus_encoder_create=e.asm.u).apply(null,arguments)},e._opus_encode_float=function(){return(e._opus_encode_float=e.asm.v).apply(null,arguments)},e._opus_encoder_ctl=function(){return(e._opus_encoder_ctl=e.asm.w).apply(null,arguments)},e._opus_encoder_destroy=function(){return(e._opus_encoder_destroy=e.asm.x).apply(null,arguments)},e._speex_resampler_init=function(){return(e._speex_resampler_init=e.asm.y).apply(null,arguments)},e._speex_resampler_destroy=function(){return(e._speex_resampler_destroy=e.asm.z).apply(null,arguments)},e._speex_resampler_process_interleaved_float=function(){return(e._speex_resampler_process_interleaved_float=e.asm.A).apply(null,arguments)},e._free=function(){return(e._free=e.asm.B).apply(null,arguments)},e._malloc=function(){return(e._malloc=e.asm.C).apply(null,arguments)},e.dynCall_vi=function(){return(e.dynCall_vi=e.asm.D).apply(null,arguments)},e.dynCall_v=function(){return(e.dynCall_v=e.asm.E).apply(null,arguments)},e.asm=Fe,e.then=function(t){if(He)t(e);else{var n=e.onRuntimeInitialized;e.onRuntimeInitialized=function(){n&&n(),t(e)}}return e},fe=function e(){He||qe(),He||(fe=e)},e.run=qe,e.preInit)for("function"==typeof e.preInit&&(e.preInit=[e.preInit]);e.preInit.length>0;)e.preInit.pop()();function Ge(){}function Xe(e){return(e||Ge).__cache__}function Ye(e,t){var n=Xe(t),r=n[e];return r||((r=Object.create((t||Ge).prototype)).ptr=e,n[e]=r)}function $e(e,t){return Ye(e.ptr,t)}function Je(e){if(!e.__destroy__)throw"Error: Cannot destroy object. (Did you create it yourself?)";e.__destroy__(),delete Xe(e.__class__)[e.ptr]}function Ke(e,t){return e.ptr===t.ptr}function Qe(e){return e.ptr}function Ze(e){return e.__class__}function et(){throw"cannot construct a VoidPtr, no constructor in IDL"}function tt(){this.ptr=De(),Xe(tt)[this.ptr]=this}return qe(),Ge.prototype=Object.create(Ge.prototype),Ge.prototype.constructor=Ge,Ge.prototype.__class__=Ge,Ge.__cache__={},e.WrapperObject=Ge,e.getCache=Xe,e.wrapPointer=Ye,e.castObject=$e,e.NULL=Ye(0),e.destroy=Je,e.compare=Ke,e.getPointer=Qe,e.getClass=Ze,et.prototype=Object.create(Ge.prototype),et.prototype.constructor=et,et.prototype.__class__=et,et.__cache__={},e.VoidPtr=et,et.prototype.__destroy__=et.prototype.__destroy__=function(){var e=this.ptr;We(e)},tt.prototype=Object.create(Ge.prototype),tt.prototype.constructor=tt,tt.prototype.__class__=tt,tt.__cache__={},e.Container=tt,tt.prototype.init=tt.prototype.init=function(e,t,n){var r=this.ptr;e&&"object"===a(e)&&(e=e.ptr),t&&"object"===a(t)&&(t=t.ptr),n&&"object"===a(n)&&(n=n.ptr),ze(r,e,t,n)},tt.prototype.writeFrame=tt.prototype.writeFrame=function(e,t,n){var r=this.ptr;e&&"object"===a(e)&&(e=e.ptr),t&&"object"===a(t)&&(t=t.ptr),n&&"object"===a(n)&&(n=n.ptr),Le(r,e,t,n)},tt.prototype.__destroy__=tt.prototype.__destroy__=function(){var e=this.ptr;Ne(e)},e});"object"===a(t)&&"object"===a(i)?i.exports=_:void 0===(u=function(){return _}.apply(t,[]))||(i.exports=u)}).call(this,"/index.js",n(2),"/",n(3)(e))},function(e,t,n){(function(e,r,o,i){var u;function a(e){return(a="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function s(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function c(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,l(r.key),r)}}function f(e,t,n){return t&&c(e.prototype,t),n&&c(e,n),Object.defineProperty(e,"prototype",{writable:!1}),e}function l(e){var t=function(e,t){if("object"!=a(e)||!e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var r=n.call(e,t||"default");if("object"!=a(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==a(t)?t:t+""}var p,_=(p=(p="undefined"!=typeof document&&document.currentScript?document.currentScript.src:void 0)||e,function(e){e=void 0!==(e=e||{})?e:{};var t=n(1),i=t.EmscriptenMemoryAllocator,u=2049,c=48e3,l=4e3,_=20,d=6,m=4096,h=0,y=4002,v=0,b=function(){return f((function t(n,r){var o=arguments.length>2&&void 0!==arguments[2]?arguments[2]:void 0;s(this,t),this.config={inputSampleRate:n,channelCount:r},this.memory=new i(e),this._opus_encoder_create=e._opus_encoder_create,this._opus_encoder_ctl=e._opus_encoder_ctl,this._opus_encode_float=e._opus_encode_float,this._opus_encoder_destroy=e._opus_encoder_destroy,this._speex_resampler_init=e._speex_resampler_init,this._speex_resampler_process_interleaved_float=e._speex_resampler_process_interleaved_float,this._speex_resampler_destroy=e._speex_resampler_destroy,this._container=new e.Container,this._container.init(c,r,Math.floor(4294967295*Math.random())),this.OpusInitCodec(c,r,o),this.SpeexInitResampler(n,c,r),this.inputSamplesPerChannel=n*_/1e3,this.outputSamplePerChannel=c*_/1e3,this.inputBufferIndex=0,this.mInputBuffer=this.memory.mallocFloat32Buffer(this.inputSamplesPerChannel*r),this.mResampledBuffer=this.memory.mallocFloat32Buffer(this.outputSamplePerChannel*r),this.mOutputBuffer=this.memory.mallocUint8Buffer(l),this.interleavedBuffers=1!==r?new Float32Array(m*r):void 0}),[{key:"encode",value:function(e){for(var t=this.interleave(e),n=0;n<t.length;){var r=Math.min(this.mInputBuffer.length-this.inputBufferIndex,t.length-n);if(this.mInputBuffer.set(t.subarray(n,n+r),this.inputBufferIndex),this.inputBufferIndex+=r,this.inputBufferIndex>=this.mInputBuffer.length){var o=this.memory.mallocUint32(this.inputSamplesPerChannel),i=this.memory.mallocUint32(this.outputSamplePerChannel),u=this._speex_resampler_process_interleaved_float(this.resampler,this.mInputBuffer.pointer,o.pointer,this.mResampledBuffer.pointer,i.pointer);if(o.free(),i.free(),u!==v)throw new Error("Resampling error.");var a=this._opus_encode_float(this.encoder,this.mResampledBuffer.pointer,this.outputSamplePerChannel,this.mOutputBuffer.pointer,this.mOutputBuffer.length);if(a<0)throw new Error("Opus encoding error.");this._container.writeFrame(this.mOutputBuffer.pointer,a,this.outputSamplePerChannel),this.inputBufferIndex=0}n+=r}}},{key:"close",value:function(){for(var t=this.config.channelCount,n=[],r=0;r<t;++r)n.push(new Float32Array(m-this.inputBufferIndex/t));this.encode(n),e.destroy(this._container),this.mInputBuffer.free(),this.mResampledBuffer.free(),this.mOutputBuffer.free(),this._opus_encoder_destroy(this.encoder),this._speex_resampler_destroy(this.resampler)}},{key:"interleave",value:function(e){var t=e.length;if(1===t)return e[0];for(var n=0;n<t;n++)for(var r=e[n],o=0;o<r.length;o++)this.interleavedBuffers[o*t+n]=r[o];return this.interleavedBuffers}},{key:"OpusInitCodec",value:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:void 0,r=this.memory.mallocUint32(void 0);this.encoder=this._opus_encoder_create(e,t,u,r.pointer);var o=r.value;if(r.free(),o!==h)throw new Error("Opus encodor initialization failed.");n&&this.OpusSetOpusControl(y,n)}},{key:"OpusSetOpusControl",value:function(e,t){var n=this.memory.mallocInt32(t);this._opus_encoder_ctl(this.encoder,e,n.pointer),n.free()}},{key:"SpeexInitResampler",value:function(e,t,n){var r=this.memory.mallocUint32(void 0);this.resampler=this._speex_resampler_init(n,e,t,d,r.pointer);var o=r.value;if(r.free(),o!==v)throw new Error("Initializing resampler failed.")}}])}();e.init=function(t,n,r){e.encodedBuffers=[],e.encoder=new b(t,n,r)},e.encode=function(t){e.encoder.encode(t)},e.flush=function(){return e.encodedBuffers.splice(0,e.encodedBuffers.length)},e.close=function(){e.encoder.close()};var g,w={};for(g in e)e.hasOwnProperty(g)&&(w[g]=e[g]);var A=[],S=!1,P=!1,C=!1,E=!1;S="object"===("undefined"==typeof window?"undefined":a(window)),P="function"==typeof importScripts,C="object"===(void 0===r?"undefined":a(r))&&"object"===a(r.versions)&&"string"==typeof r.versions.node,E=!S&&!C&&!P;var x,j,B,O,I="";function R(t){return e.locateFile?e.locateFile(t,I):I+t}C?(I=P?n(0).dirname(I)+"/":o+"/",x=function(e,t){return B||(B=n(4)),O||(O=n(0)),e=O.normalize(e),B.readFileSync(e,t?null:"utf8")},j=function(e){var t=x(e,!0);return t.buffer||(t=new Uint8Array(t)),W(t.buffer),t},r.argv.length>1&&r.argv[1].replace(/\\/g,"/"),A=r.argv.slice(2),r.on("uncaughtException",(function(e){if(!(e instanceof We))throw e})),r.on("unhandledRejection",_e),e.inspect=function(){return"[Emscripten Module object]"}):E?("undefined"!=typeof read&&(x=function(e){return read(e)}),j=function(e){var t;return"function"==typeof readbuffer?new Uint8Array(readbuffer(e)):(W("object"===a(t=read(e,"binary"))),t)},"undefined"!=typeof scriptArgs?A=scriptArgs:void 0!==arguments&&(A=arguments),"undefined"!=typeof print&&("undefined"==typeof console&&(console={}),console.log=print,console.warn=console.error="undefined"!=typeof printErr?printErr:print)):(S||P)&&(P?I=self.location.href:document.currentScript&&(I=document.currentScript.src),p&&(I=p),I=0!==I.indexOf("blob:")?I.substr(0,I.lastIndexOf("/")+1):"",x=function(e){var t=new XMLHttpRequest;return t.open("GET",e,!1),t.send(null),t.responseText},P&&(j=function(e){var t=new XMLHttpRequest;return t.open("GET",e,!1),t.responseType="arraybuffer",t.send(null),new Uint8Array(t.response)}));var k,T,U=e.print||console.log.bind(console),F=e.printErr||console.warn.bind(console);for(g in w)w.hasOwnProperty(g)&&(e[g]=w[g]);w=null,e.arguments&&(A=e.arguments),e.thisProgram&&e.thisProgram,e.quit&&e.quit,e.wasmBinary&&(k=e.wasmBinary),e.noExitRuntime&&e.noExitRuntime,"object"!==("undefined"==typeof WebAssembly?"undefined":a(WebAssembly))&&F("no native wasm support detected");var H=new WebAssembly.Table({initial:36,maximum:36,element:"anyfunc"}),M=!1;function W(e,t){e||_e("Assertion failed: "+t)}var D="undefined"!=typeof TextDecoder?new TextDecoder("utf8"):void 0;function z(e,t,n){for(var r=t+n,o=t;e[o]&&!(o>=r);)++o;if(o-t>16&&e.subarray&&D)return D.decode(e.subarray(t,o));for(var i="";t<o;){var u=e[t++];if(128&u){var a=63&e[t++];if(192!=(224&u)){var s=63&e[t++];if((u=224==(240&u)?(15&u)<<12|a<<6|s:(7&u)<<18|a<<12|s<<6|63&e[t++])<65536)i+=String.fromCharCode(u);else{var c=u-65536;i+=String.fromCharCode(55296|c>>10,56320|1023&c)}}else i+=String.fromCharCode((31&u)<<6|a)}else i+=String.fromCharCode(u)}return i}function L(e,t){return e?z(V,e,t):""}"undefined"!=typeof TextDecoder&&new TextDecoder("utf-16le");var N,V,q,G=65536;function X(t){N=t,e.HEAP8=new Int8Array(t),e.HEAP16=new Int16Array(t),e.HEAP32=q=new Int32Array(t),e.HEAPU8=V=new Uint8Array(t),e.HEAPU16=new Uint16Array(t),e.HEAPU32=new Uint32Array(t),e.HEAPF32=new Float32Array(t),e.HEAPF64=new Float64Array(t)}var Y=5289728,$=46688,J=e.INITIAL_MEMORY||16777216;function K(t){for(;t.length>0;){var n=t.shift();if("function"!=typeof n){var r=n.func;"number"==typeof r?void 0===n.arg?e.dynCall_v(r):e.dynCall_vi(r,n.arg):r(void 0===n.arg?null:n.arg)}else n()}}(T=e.wasmMemory?e.wasmMemory:new WebAssembly.Memory({initial:J/G,maximum:J/G}))&&(N=T.buffer),J=N.byteLength,X(N),q[$>>2]=Y;var Q=[],Z=[],ee=[],te=[];function ne(){if(e.preRun)for("function"==typeof e.preRun&&(e.preRun=[e.preRun]);e.preRun.length;)ue(e.preRun.shift());K(Q)}function re(){K(Z)}function oe(){K(ee)}function ie(){if(e.postRun)for("function"==typeof e.postRun&&(e.postRun=[e.postRun]);e.postRun.length;)ae(e.postRun.shift());K(te)}function ue(e){Q.unshift(e)}function ae(e){te.unshift(e)}var se=0,ce=null,fe=null;function le(t){se++,e.monitorRunDependencies&&e.monitorRunDependencies(se)}function pe(t){if(se--,e.monitorRunDependencies&&e.monitorRunDependencies(se),0==se&&(null!==ce&&(clearInterval(ce),ce=null),fe)){var n=fe;fe=null,n()}}function _e(t){throw e.onAbort&&e.onAbort(t),U(t+=""),F(t),M=!0,t="abort("+t+"). Build with -s ASSERTIONS=1 for more info.",new WebAssembly.RuntimeError(t)}e.preloadedImages={},e.preloadedAudios={};var de="data:application/octet-stream;base64,";function me(e){return String.prototype.startsWith?e.startsWith(de):0===e.indexOf(de)}var he="OggOpusEncoder.wasm";function ye(){try{if(k)return new Uint8Array(k);if(j)return j(he);throw"both async and sync fetching of the wasm failed"}catch(e){_e(e)}}function ve(){return k||!S&&!P||"function"!=typeof fetch?new Promise((function(e,t){e(ye())})):fetch(he,{credentials:"same-origin"}).then((function(e){if(!e.ok)throw"failed to load wasm binary file at '"+he+"'";return e.arrayBuffer()})).catch((function(){return ye()}))}function be(){var t={a:Oe};function n(t,n){var r=t.exports;e.asm=r,pe()}function r(e){n(e.instance)}function o(e){return ve().then((function(e){return WebAssembly.instantiate(e,t)})).then(e,(function(e){F("failed to asynchronously prepare wasm: "+e),_e(e)}))}if(le(),e.instantiateWasm)try{return e.instantiateWasm(t,n)}catch(e){return F("Module.instantiateWasm callback failed with error: "+e),!1}return function(){if(k||"function"!=typeof WebAssembly.instantiateStreaming||me(he)||"function"!=typeof fetch)return o(r);fetch(he,{credentials:"same-origin"}).then((function(e){return WebAssembly.instantiateStreaming(e,t).then(r,(function(e){F("wasm streaming compile failed: "+e),F("falling back to ArrayBuffer instantiation"),o(r)}))}))}(),{}}function ge(t,n){var r=new Uint8Array(e.HEAPU8.buffer,t,n);e.encodedBuffers.push(new Uint8Array(r).buffer)}function we(e,t,n,r){_e("Assertion failed: "+L(e)+", at: "+[t?L(t):"unknown filename",n,r?L(r):"unknown function"])}function Ae(){_e()}function Se(e,t,n){V.copyWithin(e,t,t+n)}function Pe(e){_e("OOM")}function Ce(e){Pe()}me(he)||(he=R(he)),Z.push({func:function(){ke()}});var Ee={mappings:{},buffers:[null,[],[]],printChar:function(e,t){var n=Ee.buffers[e];0===t||10===t?((1===e?U:F)(z(n,0)),n.length=0):n.push(t)},varargs:void 0,get:function(){return Ee.varargs+=4,q[Ee.varargs-4>>2]},getStr:function(e){return L(e)},get64:function(e,t){return e}};function xe(e){return 0}function je(e,t,n,r,o){}function Be(e,t,n,r){for(var o=0,i=0;i<n;i++){for(var u=q[t+8*i>>2],a=q[t+(8*i+4)>>2],s=0;s<a;s++)Ee.printChar(e,V[u+s]);o+=a}return q[r>>2]=o,0}var Oe={a:we,c:Ae,d:ge,f:Se,g:Ce,h:xe,e:je,b:Be,memory:T,table:H},Ie=be();e.asm=Ie;var Re,ke=e.___wasm_call_ctors=function(){return(ke=e.___wasm_call_ctors=e.asm.i).apply(null,arguments)},Te=(e.___em_js__emscriptenPushBuffer=function(){return(e.___em_js__emscriptenPushBuffer=e.asm.j).apply(null,arguments)},e._emscripten_bind_VoidPtr___destroy___0=function(){return(Te=e._emscripten_bind_VoidPtr___destroy___0=e.asm.k).apply(null,arguments)}),Ue=e._emscripten_bind_Container_Container_0=function(){return(Ue=e._emscripten_bind_Container_Container_0=e.asm.l).apply(null,arguments)},Fe=e._emscripten_bind_Container_init_3=function(){return(Fe=e._emscripten_bind_Container_init_3=e.asm.m).apply(null,arguments)},He=e._emscripten_bind_Container_writeFrame_3=function(){return(He=e._emscripten_bind_Container_writeFrame_3=e.asm.n).apply(null,arguments)},Me=e._emscripten_bind_Container___destroy___0=function(){return(Me=e._emscripten_bind_Container___destroy___0=e.asm.o).apply(null,arguments)};function We(e){this.name="ExitStatus",this.message="Program terminated with exit("+e+")",this.status=e}function De(t){function n(){Re||(Re=!0,e.calledRun=!0,M||(re(),oe(),e.onRuntimeInitialized&&e.onRuntimeInitialized(),ie()))}t=t||A,se>0||(ne(),se>0||(e.setStatus?(e.setStatus("Running..."),setTimeout((function(){setTimeout((function(){e.setStatus("")}),1),n()}),1)):n()))}if(e._opus_encoder_create=function(){return(e._opus_encoder_create=e.asm.p).apply(null,arguments)},e._opus_encode_float=function(){return(e._opus_encode_float=e.asm.q).apply(null,arguments)},e._opus_encoder_ctl=function(){return(e._opus_encoder_ctl=e.asm.r).apply(null,arguments)},e._opus_encoder_destroy=function(){return(e._opus_encoder_destroy=e.asm.s).apply(null,arguments)},e._malloc=function(){return(e._malloc=e.asm.t).apply(null,arguments)},e._free=function(){return(e._free=e.asm.u).apply(null,arguments)},e._speex_resampler_init=function(){return(e._speex_resampler_init=e.asm.v).apply(null,arguments)},e._speex_resampler_destroy=function(){return(e._speex_resampler_destroy=e.asm.w).apply(null,arguments)},e._speex_resampler_process_interleaved_float=function(){return(e._speex_resampler_process_interleaved_float=e.asm.x).apply(null,arguments)},e.dynCall_vi=function(){return(e.dynCall_vi=e.asm.y).apply(null,arguments)},e.dynCall_v=function(){return(e.dynCall_v=e.asm.z).apply(null,arguments)},e.asm=Ie,e.then=function(t){if(Re)t(e);else{var n=e.onRuntimeInitialized;e.onRuntimeInitialized=function(){n&&n(),t(e)}}return e},fe=function e(){Re||De(),Re||(fe=e)},e.run=De,e.preInit)for("function"==typeof e.preInit&&(e.preInit=[e.preInit]);e.preInit.length>0;)e.preInit.pop()();function ze(){}function Le(e){return(e||ze).__cache__}function Ne(e,t){var n=Le(t),r=n[e];return r||((r=Object.create((t||ze).prototype)).ptr=e,n[e]=r)}function Ve(e,t){return Ne(e.ptr,t)}function qe(e){if(!e.__destroy__)throw"Error: Cannot destroy object. (Did you create it yourself?)";e.__destroy__(),delete Le(e.__class__)[e.ptr]}function Ge(e,t){return e.ptr===t.ptr}function Xe(e){return e.ptr}function Ye(e){return e.__class__}function $e(){throw"cannot construct a VoidPtr, no constructor in IDL"}function Je(){this.ptr=Ue(),Le(Je)[this.ptr]=this}return De(),ze.prototype=Object.create(ze.prototype),ze.prototype.constructor=ze,ze.prototype.__class__=ze,ze.__cache__={},e.WrapperObject=ze,e.getCache=Le,e.wrapPointer=Ne,e.castObject=Ve,e.NULL=Ne(0),e.destroy=qe,e.compare=Ge,e.getPointer=Xe,e.getClass=Ye,$e.prototype=Object.create(ze.prototype),$e.prototype.constructor=$e,$e.prototype.__class__=$e,$e.__cache__={},e.VoidPtr=$e,$e.prototype.__destroy__=$e.prototype.__destroy__=function(){var e=this.ptr;Te(e)},Je.prototype=Object.create(ze.prototype),Je.prototype.constructor=Je,Je.prototype.__class__=Je,Je.__cache__={},e.Container=Je,Je.prototype.init=Je.prototype.init=function(e,t,n){var r=this.ptr;e&&"object"===a(e)&&(e=e.ptr),t&&"object"===a(t)&&(t=t.ptr),n&&"object"===a(n)&&(n=n.ptr),Fe(r,e,t,n)},Je.prototype.writeFrame=Je.prototype.writeFrame=function(e,t,n){var r=this.ptr;e&&"object"===a(e)&&(e=e.ptr),t&&"object"===a(t)&&(t=t.ptr),n&&"object"===a(n)&&(n=n.ptr),He(r,e,t,n)},Je.prototype.__destroy__=Je.prototype.__destroy__=function(){var e=this.ptr;Me(e)},e});"object"===a(t)&&"object"===a(i)?i.exports=_:void 0===(u=function(){return _}.apply(t,[]))||(i.exports=u)}).call(this,"/index.js",n(2),"/",n(3)(e))}]);}});