!function(e,t){"object"==typeofexports&&"object"==typeofmodule?module.exports=t():"function"==typeofdefine&&define.amd?define([],t):"object"==typeofexports?exports.Recorder=t():e.Recorder=t()}(this,function(){returnfunction(e){functiont(o){if(n[o])returnn[o].exports;vari=n[o]={i:o,l:!1,exports:{}};returne[o].call(i.exports,i,i.exports,t),i.l=!0,i.exports}varn={};returnt.m=e,t.c=n,t.d=function(e,n,o){t.o(e,n)||Object.defineProperty(e,n,{configurable:!1,enumerable:!0,get:o})},t.n=function(e){varn=e&&e.__esModule?function(){returne.default}:function(){returne};returnt.d(n,"a",n),n},t.o=function(e,t){returnObject.prototype.hasOwnProperty.call(e,t)},t.p="",t(t.s=0)}([function(e,t,n){"use strict";(function(t){varo=n(2),i=function(e){varn=this,o=t.AudioContext||t.webkitAudioContext;if(!i.isRecordingSupported())thrownewError("Recording is not supported in this browser");this.state="inactive",this.eventTarget=t.document.createDocumentFragment(),this.audioContext=newo,this.monitorNode=this.audioContext.createGain(),this.config=Object.assign({bufferLength:4096,encoderApplication:2049,encoderFrameSize:20,encoderPath:"encoderWorker.min.js",encoderSampleRate:48e3,leaveStreamOpen:!1,maxBuffersPerPage:40,monitorGain:0,numberOfChannels:1,originalSampleRate:this.audioContext.sampleRate,resampleQuality:3,mediaTrackConstraints:!0,streamPages:!1,wavBitDepth:16,wavSampleRate:this.audioContext.sampleRate},e),this.initWorker(),this.setMonitorGain(this.config.monitorGain),this.scriptProcessorNode=this.audioContext.createScriptProcessor(this.config.bufferLength,this.config.numberOfChannels,this.config.numberOfChannels),this.scriptProcessorNode.onaudioprocess=function(e){n.encodeBuffers(e.inputBuffer)}};i.isRecordingSupported=function(){return(t.AudioContext||t.webkitAudioContext)&&o.isSupported},i.prototype.addEventListener=function(e,t,n){this.eventTarget.addEventListener(e,t,n)},i.prototype.clearStream=function(){this.stream&&(this.stream.getTracks?this.stream.getTracks().forEach(function(e){e.stop()}):this.stream.stop(),deletethis.stream)},i.prototype.encodeBuffers=function(e){if("recording"===this.state){for(vart=[],n=0;n<e.numberOfChannels;n++)t[n]=e.getChannelData(n);this.encoder.postMessage({command:"encode",buffers:t})}},i.prototype.initStream=function(){vare=this,n=function(n){returne.stream=n,e.sourceNode=e.audioContext.createMediaStreamSource(n),e.sourceNode.connect(e.scriptProcessorNode),e.sourceNode.connect(e.monitorNode),e.eventTarget.dispatchEvent(newt.Event("streamReady")),n},i=function(n){throwe.eventTarget.dispatchEvent(newt.ErrorEvent("streamError",{error:n})),n},r={audio:this.config.mediaTrackConstraints};returnthis.stream?(this.eventTarget.dispatchEvent(newt.Event("streamReady")),t.Promise.resolve(this.stream)):o(r).then(n,i)},i.prototype.initWorker=function(){vare=this;this.encoder=newt.Worker(this.config.encoderPath),this.config.streamPages?this.encoder.addEventListener("message",function(t){e.streamPage(t.data)}):(this.recordedPages=[],this.totalLength=0,this.encoder.addEventListener("message",function(t){e.storePage(t.data)}))},i.prototype.pause=function(){"recording"===this.state&&(this.state="paused",this.eventTarget.dispatchEvent(newt.Event("pause")))},i.prototype.removeEventListener=function(e,t,n){this.eventTarget.removeEventListener(e,t,n)},i.prototype.resume=function(){"paused"===this.state&&(this.state="recording",this.eventTarget.dispatchEvent(newt.Event("resume")))},i.prototype.setMonitorGain=function(e){this.monitorNode.gain.setTargetAtTime(e,this.audioContext.currentTime,.01)},i.prototype.start=function(){"inactive"===this.state&&this.stream&&(this.encoder.postMessage(Object.assign({command:"init"},this.config)),this.encodeBuffers=function(){deletethis.encodeBuffers},this.state="recording",this.monitorNode.connect(this.audioContext.destination),this.scriptProcessorNode.connect(this.audioContext.destination),this.eventTarget.dispatchEvent(newt.Event("start")))},i.prototype.stop=function(){"inactive"!==this.state&&(this.state="inactive",this.monitorNode.disconnect(),this.scri