text: /*!
   * surveyjs-widgets - Widgets for the SurveyJS library v1.8.52
   * Copyright (c) 2015-2021 Devsoft Baltic OÜ  - http://surveyjs.io/
   * License: MIT (http://www.opensource.org/licenses/mit-license.php)
   */
  !function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define("widgets/microphone",[],t):"object"==typeof exports?exports["widgets/microphone"]=t():e["widgets/microphone"]=t()}("undefined"!=typeof self?self:this,function(){return function(e){function t(i){if(o[i])return o[i].exports;var n=o[i]={i:i,l:!1,exports:{}};return e[i].call(n.exports,n,n.exports,t),n.l=!0,n.exports}var o={};return t.m=e,t.c=o,t.d=function(e,o,i){t.o(e,o)||Object.defineProperty(e,o,{configurable:!1,enumerable:!0,get:i})},t.n=function(e){var o=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(o,"a",o),o},t.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},t.p="",t(t.s=16)}({16:function(e,t,o){"use strict";function i(e){var t={name:"microphone",title:"Microphone",iconName:"icon-microphone",widgetIsLoaded:function(){return void 0!==r.a},isFit:function(e){return"microphone"===e.getType()},htmlTemplate:"<div style='height: 39px'><button type='button'  title='Record' style='vertical-align: top; margin-top: 3px' ><i class='fa fa-microphone' aria-hidden='true'></i></button>&nbsp;<button type='button' title='Save' style='vertical-align: top; margin-top: 3px'><i class='fa fa-cloud' aria-hidden='true' ></i></button>&nbsp;<audio style='vertical-align: top;margin-left: 10px;height:35px;-moz-box-shadow: 2px 2px 4px 0px #006773;-webkit-box-shadow:  2px 2px 4px 0px #006773;box-shadow: 2px 2px 4px 0px #006773;' controls='true' ></audio></div>",activatedByChanged:function(t){e.JsonObject.metaData.addClass("microphone",[],null,"empty")},afterRender:function(e,t){var o=t.getElementsByTagName("button")[0],i=t.getElementsByTagName("button")[1],n=t.getElementsByTagName("audio")[0],a=function(t){var o={type:"audio",mimeType:"audio/webm",audioBitsPerSecond:44100,sampleRate:44100,bufferSize:16384,numberOfAudioChannels:1};console.log("successCallback"),e.survey.mystream=t,e.survey.recordRTC=r()(e.survey.mystream,o),void 0!==e.survey.recordRTC&&(console.log("startRecording"),e.survey.recordRTC.startRecording())},d=function(){alert("No microphone"),e.survey.recordRTC=void 0,e.survey.mystream=void 0},s=function(t){console.log("processAudio");var o=e.survey.recordRTC.getBlob(),i=new FileReader;i.onload=function(t){var o=t.target.result;console.log("dataUri: "+o),e.value=o,n.src=o,console.log("cleaning"),e.survey.recordRTC=void 0,e.survey.mystream=void 0},i.readAsDataURL(o)},c=function(){e.value=void 0,void 0!==e.survey.recordRTC&&(e.survey.recordRTC.stopRecording(f),void 0!==e.survey.mystream&&e.survey.mystream.getAudioTracks().forEach(function(e){e.stop()}));var t={video:!1,audio:!0};navigator.mediaDevices.getUserMedia(t).then(a.bind(this),d.bind(this))},u=function(){console.log("stopRecording"),void 0!==e.survey.recordRTC&&(e.survey.recordRTC.stopRecording(s.bind(this)),void 0!==e.survey.mystream&&e.survey.mystream.getAudioTracks().forEach(function(e){e.stop()}))};e.isReadOnly?o.parentNode.removeChild(o):o.onclick=c,e.isReadOnly?i.parentNode.removeChild(i):i.onclick=u,n.src=e.value;var l=function(){},f=function(){};e.valueChangedCallback=l},willUnmount:function(e,t){console.log("unmount microphone no record "),void 0!==e.survey.recordRTC&&(e.survey.recordRTC.stopRecording(doNothingHandler),void 0!==e.survey.mystream&&e.survey.mystream.getAudioTracks().forEach(function(e){e.stop()}),e.value=void 0,e.survey.recordRTC=void 0,e.survey.mystream=void 0)}};e.CustomWidgetCollection.Instance.addCustomWidget(t,"customtype")}Object.defineProperty(t,"__esModule",{value:!0});var n=o(17),r=o.n(n);"undefined"!=typeof Survey&&i(Survey),t.default=i},17:function(e,t,o){"use strict";(function(o,i){/**
   * {@link https://github.com/muaz-khan/RecordRTC|RecordRTC} is a WebRTC JavaScript library for audio/video as well as screen activity recording. It supports Chrome, Firefox, Opera, Android, and Microsoft Edge. Platforms: Linux, Mac and Windows. 
   * @summary Record audio, video or screen inside the browser.
   * @license {@link https://github.com/muaz-khan/RecordRTC/blob/master/LICENSE|MIT}
   * @author {@link https://MuazKhan.com|Muaz Khan}
   * @typedef RecordRTC
   * @class
   * @example
   * var recorder = RecordRTC(mediaStream or [arrayOfMediaStream], {
   *     type: 'video', // audio or video or gif or canvas
   *     recorderType: MediaStreamRecorder || CanvasRecorder || StereoAudioRecorder || Etc
   * });
   * recorder.startRecording();
   * @see For further information:
   * @see {@link https://github.com/muaz-khan/RecordRTC|RecordRTC Source Code}
   * @param {MediaStream} mediaStream - Single media-stream object, array of media-streams, html-canvas-element, etc.
   * @param {object} config - {type:"video", recorderType: MediaStreamRecorder, disableLogs: true, numberOfAudioChannels: 1, bufferSize: 0, sampleRate: 0, desiredSampRate: 16000, video: HTMLVideoElement, etc.}
   */
  function n(e,t){function o(o){return t.disableLogs||console.log("RecordRTC version: ",b.version),o&&(t=new r(e,o)),t.disableLogs||console.log("started recording "+t.type+" stream."),v?(v.clearRecordedData(),v.record(),g("recording"),b.recordingDuration&&m(),b):(i(function(){b.recordingDuration&&m()}),b)}function i(o){o&&(t.initCallback=function(){o(),o=t.initCallback=null});var i=new a(e,t);v=new i(e,t),v.record(),g("recording"),t.disableLogs||console.log("Initialized recorderType:",v.constructor.name,"for output-type:",t.type)}function d(e){function o(o){if(!v)return void("function"==typeof e.call?e.call(b,""):e(""));Object.keys(v).forEach(function(e){"function"!=typeof v[e]&&(b[e]=v[e])});var i=v.blob;if(!i){if(!o)throw"Recording failed.";v.blob=i=o}if(i&&!t.disableLogs&&console.log(i.type,"->",s(i.size)),e){var n;try{n=D.createObjectURL(i)}catch(e){}"function"==typeof e.call?e.call(b,n):e(n)}t.autoWriteToDisk&&h(function(e){var o={};o[t.type+"Blob"]=e,z.Store(o)})}return e=e||function(){},v?"paused"===b.state?(b.resumeRecording(),void setTimeout(function(){d(e)},1)):("recording"===b.state||t.disableLogs||console.warn('Recording state should be: "recording", however current state is: ',b.state),t.disableLogs||console.log("Stopped recording "+t.type+" stream."),"gif"!==t.type?v.stop(o):(v.stop(),o()),void g("stopped")):void p()}function u(){return v?"recording"!==b.state?void(t.disableLogs||console.warn("Unable to pause the recording. Recording state: ",b.state)):(g("paused"),v.pause(),void(t.disableLogs||console.log("Paused recording."))):void p()}function l(){return v?"paused"!==b.state?void(t.disableLogs||console.warn("Unable to resume the recording. Recording state: ",b.state)):(g("recording"),v.resume(),void(t.disableLogs||console.log("Resumed recording."))):void p()}function f(e){postMessage((new FileReaderSync).readAsDataURL(e))}function h(e,o){if(!e)throw"Pass a callback function over getDataURL.";var i=o?o.blob:(v||{}).blob;if(!i)return t.disableLogs||console.warn("Blob encoder did not finish its job yet."),void setTimeout(function(){h(e,o)},1e3);if("undefined"==typeof Worker||navigator.mozGetUserMedia){var n=new FileReader;n.readAsDataURL(i),n.onload=function(t){e(t.target.result)}}else{var r=function(e){try{var t=D.createObjectURL(new Blob([e.toString(),"this.onmessage =  function (eee) {"+e.name+"(eee.data);}"],{type:"application/javascript"})),o=new Worker(t);return D.revokeObjectURL(t),o}catch(e){}}(f);r.onmessage=function(t){e(t.data)},r.postMessage(i)}}function m(e){if(e=e||0,"paused"===b.state)return void setTimeout(function(){m(e)},1e3);if("stopped"!==b.state){if(e>=b.recordingDuration)return void d(b.onRecordingStopped);e+=1e3,setTimeout(function(){m(e)},1e3)}}function g(e){b&&(b.state=e,"function"==typeof b.onStateChanged.call?b.onStateChanged.call(b,e):b.onStateChanged(e))}function p(){!0!==t.disableLogs&&console.warn(w)}if(!e)throw"First parameter is required.";t=t||{type:"video"},t=new r(e,t);var v,b=this,w='It seems that recorder is destroyed or "startRecording" is not invoked for '+t.type+" recorder.",y={startRecording:o,stopRecording:d,pauseRecording:u,resumeRecording:l,initRecorder:i,setRecordingDuration:function(e,t){if(void 0===e)throw"recordingDuration is required.";if("number"!=typeof e)throw"recordingDuration must be a number.";return b.recordingDuration=e,b.onRecordingStopped=t||function(){},{onRecordingStopped:function(e){b.onRecordingStopped=e}}},clearRecordedData:function(){if(!v)return void p();v.clearRecordedData(),t.disableLogs||console.log("Cleared old recorded data.")},getBlob:function(){return v?v.blob:void p()},getDataURL:h,toURL:function(){return v?D.createObjectURL(v.blob):void p()},getInternalRecorder:function(){return v},save:function(e){if(!v)return void p();c(v.blob,e)},getFromDisk:function(e){if(!v)return void p();n.getFromDisk(t.type,e)},setAdvertisementArray:function(e){t.advertisement=[];for(var o=e.length,i=0;i<o;i++)t.advertisement.push({duration:i,image:e[i]})},blob:null,bufferSize:0,sampleRate:0,buffer:null,reset:function(){"recording"!==b.state||t.disableLogs||console.warn("Stop an active recorder."),v&&"function"==typeof v.clearRecordedData&&v.clearRecordedData(),v=null,g("inactive"),b.blob=null},onStateChanged:function(e){t.disableLogs||console.log("Recorder state changed:",e)},state:"inactive",getState:function(){return b.state},destroy:function(){var e=t.disableLogs;t={disableLogs:!0},b.reset(),g("destroyed"),y=b=null,j.AudioContextConstructor&&(j.AudioContextConstructor.close(),j.AudioContextConstructor=null),t.disableLogs=e,t.disableLogs||console.log("RecordRTC is destroyed.")},version:"5.5.9"};if(!this)return b=y,y;for(var R in y)this[R]=y[R];return b=this,y}/**
   * {@link RecordRTCConfiguration} is an inner/private helper for {@link RecordRTC}.
   * @summary It configures the 2nd parameter passed over {@link RecordRTC} and returns a valid "config" object.
   * @license {@link https://github.com/muaz-khan/RecordRTC/blob/master/LICENSE|MIT}
   * @author {@link https://MuazKhan.com|Muaz Khan}
   * @typedef RecordRTCConfiguration
   * @class
   * @example
   * var options = RecordRTCConfiguration(mediaStream, options);
   * @see {@link https://github.com/muaz-khan/RecordRTC|RecordRTC Source Code}
   * @param {MediaStream} mediaStream - MediaStream object fetched using getUserMedia API or generated using captureStreamUntilEnded or WebAudio API.
   * @param {object} config - {type:"video", disableLogs: true, numberOfAudioChannels: 1, bufferSize: 0, sampleRate: 0, video: HTMLVideoElement, getNativeBlob:true, etc.}
   */
  function r(e,t){return t.recorderType||t.type||(t.audio&&t.video?t.type="video":t.audio&&!t.video&&(t.type="audio")),t.recorderType&&!t.type&&(t.recorderType===b||t.recorderType===v||void 0!==T&&t.recorderType===T?t.type="video":t.recorderType===w?t.type="gif":t.recorderType===p?t.type="audio":t.recorderType===g&&(l(e,"audio").length&&l(e,"video").length?t.type="video":!l(e,"audio").length&&l(e,"video").length?t.type="video":l(e,"audio").length&&!l(e,"video").length&&(t.type="audio"))),void 0!==g&&"undefined"!=typeof MediaRecorder&&"requestData"in MediaRecorder.prototype&&(t.mimeType||(t.mimeType="video/webm"),t.type||(t.type=t.mimeType.split("/")[0]),t.bitsPerSecond),t.type||(t.mimeType&&(t.type=t.mimeType.split("/")[0]),t.type||(t.type="audio")),t}/**
   * {@link GetRecorderType} is an inner/private helper for {@link RecordRTC}.
   * @summary It returns best recorder-type available for your browser.
   * @license {@link https://github.com/muaz-khan/RecordRTC/blob/master/LICENSE|MIT}
   * @author {@link https://MuazKhan.com|Muaz Khan}
   * @typedef GetRecorderType
   * @class
   * @example
   * var RecorderType = GetRecorderType(options);
   * var recorder = new RecorderType(options);
   * @see {@link https://github.com/muaz-khan/RecordRTC|RecordRTC Source Code}
   * @param {MediaStream} mediaStream - MediaStream object fetched using getUserMedia API or generated using captureStreamUntilEnded or WebAudio API.
   * @param {object} config - {type:"video", disableLogs: true, numberOfAudioChannels: 1, bufferSize: 0, sampleRate: 0, video: HTMLVideoElement, etc.}
   */
  function a(e,t){var o;return(O||U||B)&&(o=p),"undefined"!=typeof MediaRecorder&&"requestData"in MediaRecorder.prototype&&!O&&(o=g),"video"===t.type&&(O||B)&&(o=b,void 0!==T&&"undefined"!=typeof ReadableStream&&(o=T)),"gif"===t.type&&(o=w),"canvas"===t.type&&(o=v),m()&&o!==v&&o!==w&&"undefined"!=typeof MediaRecorder&&"requestData"in MediaRecorder.prototype&&(l(e,"video").length||l(e,"audio").length)&&("audio"===t.type?"function"==typeof MediaRecorder.isTypeSupported&&MediaRecorder.isTypeSupported("audio/webm")&&(o=g):"function"==typeof MediaRecorder.isTypeSupported&&MediaRecorder.isTypeSupported("video/webm")&&(o=g)),e instanceof Array&&e.length&&(o=R),t.recorderType&&(o=t.recorderType),!t.disableLogs&&o&&o.name&&console.log("Using recorderType:",o.name||o.constructor.name),!o&&I&&(o=g),o}/**
   * MRecordRTC runs on top of {@link RecordRTC} to bring multiple recordings in a single place, by providing simple API.
   * @summary MRecordRTC stands for "Multiple-RecordRTC".
   * @license {@link https://github.com/muaz-khan/RecordRTC/blob/master/LICENSE|MIT}
   * @author {@link https://MuazKhan.com|Muaz Khan}
   * @typedef MRecordRTC
   * @class
   * @example
   * var recorder = new MRecordRTC();
   * recorder.addStream(MediaStream);
   * recorder.mediaType = {
   *     audio: true, // or StereoAudioRecorder or MediaStreamRecorder
   *     video: true, // or WhammyRecorder or MediaStreamRecorder or WebAssemblyRecorder or CanvasRecorder
   *     gif: true    // or GifRecorder
   * };
   * // mimeType is optional and should be set only in advance cases.
   * recorder.mimeType = {
   *     audio: 'audio/wav',
   *     video: 'video/webm',
   *     gif:   'image/gif'
   * };
   * recorder.startRecording();
   * @see For further information:
   * @see {@link https://github.com/muaz-khan/RecordRTC/tree/master/MRecordRTC|MRecordRTC Source Code}
   * @param {MediaStream} mediaStream - MediaStream object fetched using getUserMedia API or generated using captureStreamUntilEnded or WebAudio API.
   * @requires {@link RecordRTC}
   */
  function d(e){this.addStream=function(t){t&&(e=t)},this.mediaType={audio:!0,video:!0},this.startRecording=function(){var t,o=this.mediaType,i=this.mimeType||{audio:null,video:null,gif:null};if("function"!=typeof o.audio&&m()&&!l(e,"audio").length&&(o.audio=!1),"function"!=typeof o.video&&m()&&!l(e,"video").length&&(o.video=!1),"function"!=typeof o.gif&&m()&&!l(e,"video").length&&(o.gif=!1),!o.audio&&!o.video&&!o.gif)throw"MediaStream must have either audio or video tracks.";if(o.audio&&(t=null,"function"==typeof o.audio&&(t=o.audio),this.audioRecorder=new n(e,{type:"audio",bufferSize:this.bufferSize,sampleRate:this.sampleRate,numberOfAudioChannels:this.numberOfAudioChannels||2,disableLogs:this.disableLogs,recorderType:t,mimeType:i.audio,timeSlice:this.timeSlice,onTimeStamp:this.onTimeStamp}),o.video||this.audioRecorder.startRecording()),o.video){t=null,"function"==typeof o.video&&(t=o.video);var r=e;if(m()&&o.audio&&"function"==typeof o.audio){var a=l(e,"video")[0];E?(r=new F,r.addTrack(a),t&&t===b&&(t=g)):(r=new F,r.addTrack(a))}this.videoRecorder=new n(r,{type:"video",video:this.video,canvas:this.canvas,frameInterval:this.frameInterval||10,disableLogs:this.disableLogs,recorderType:t,mimeType:i.video,timeSlice:this.timeSlice,onTimeStamp:this.onTimeStamp,workerPath:this.workerPath,webAssemblyPath:this.webAssemblyPath,frameRate:this.frameRate,bitrate:this.bitrate}),o.audio||this.videoRecorder.startRecording()}if(o.audio&&o.video){var d=this,s=!0===m();o.audio instanceof p&&o.video?s=!1:!0!==o.audio&&!0!==o.video&&o.audio!==o.video&&(s=!1),!0===s?(d.audioRecorder=null,d.videoRecorder.startRecording()):d.videoRecorder.initRecorder(function(){d.audioRecorder.initRecorder(function(){d.videoRecorder.startRecording(),d.audioRecorder.startRecording()})})}o.gif&&(t=null,"function"==typeof o.gif&&(t=o.gif),this.gifRecorder=new n(e,{type:"gif",frameRate:this.frameRate||200,quality:this.quality||10,disableLogs:this.disableLogs,recorderType:t,mimeType:i.gif}),this.gifRecorder.startRecording())},this.stopRecording=function(e){e=e||function(){},this.audioRecorder&&this.audioRecorder.stopRecording(function(t){e(t,"audio")}),this.videoRecorder&&this.videoRecorder.stopRecording(function(t){e(t,"video")}),this.gifRecorder&&this.gifRecorder.stopRecording(function(t){e(t,"gif")})},this.pauseRecording=function(){this.audioRecorder&&this.audioRecorder.pauseRecording(),this.videoRecorder&&this.videoRecorder.pauseRecording(),this.gifRecorder&&this.gifRecorder.pauseRecording()},this.resumeRecording=function(){this.audioRecorder&&this.audioRecorder.resumeRecording(),this.videoRecorder&&this.videoRecorder.resumeRecording(),this.gifRecorder&&this.gifRecorder.resumeRecording()},this.getBlob=function(e){var t={};return this.audioRecorder&&(t.audio=this.audioRecorder.getBlob()),this.videoRecorder&&(t.video=this.videoRecorder.getBlob()),this.gifRecorder&&(t.gif=this.gifRecorder.getBlob()),e&&e(t),t},this.destroy=function(){this.audioRecorder&&(this.audioRecorder.destroy(),this.audioRecorder=null),this.videoRecorder&&(this.videoRecorder.destroy(),this.videoRecorder=null),this.gifRecorder&&(this.gifRecorder.destroy(),this.gifRecorder=null)},this.getDataURL=function(e){function t(e,t){if("undefined"!=typeof Worker){var i=o(function(e){postMessage((new FileReaderSync).readAsDataURL(e))});i.onmessage=function(e){t(e.data)},i.postMessage(e)}else{var n=new FileReader;n.readAsDataURL(e),n.onload=function(e){t(e.target.result)}}}function o(e){var t,o=D.createObjectURL(new Blob([e.toString(),"this.onmessage =  function (eee) {"+e.name+"(eee.data);}"],{type:"application/javascript"})),i=new Worker(o);if(void 0!==D)t=D;else{if("undefined"==typeof webkitURL)throw"Neither URL nor webkitURL detected.";t=webkitURL}return t.revokeObjectURL(o),i}this.getBlob(function(o){o.audio&&o.video?t(o.audio,function(i){t(o.video,function(t){e({audio:i,video:t})})}):o.audio?t(o.audio,function(t){e({audio:t})}):o.video&&t(o.video,function(t){e({video:t})})})},this.writeToDisk=function(){n.writeToDisk({audio:this.audioRecorder,video:this.videoRecorder,gif:this.gifRecorder})},this.save=function(e){e=e||{audio:!0,video:!0,gif:!0},e.audio&&this.audioRecorder&&this.audioRecorder.save("string"==typeof e.audio?e.audio:""),e.video&&this.videoRecorder&&this.videoRecorder.save("string"==typeof e.video?e.video:""),e.gif&&this.gifRecorder&&this.gifRecorder.save("string"==typeof e.gif?e.gif:"")}}function s(e){var t=["Bytes","KB","MB","GB","TB"];if(0===e)return"0 Bytes";var o=parseInt(Math.floor(Math.log(e)/Math.log(1e3)),10);return(e/Math.pow(1e3,o)).toPrecision(3)+" "+t[o]}function c(e,t){if(!e)throw"Blob object is required.";if(!e.type)try{e.type="video/webm"}catch(e){}var o=(e.type||"video/webm").split("/")[1];if(t&&-1!==t.indexOf(".")){var i=t.split(".");t=i[0],o=i[1]}var n=(t||Math.round(9999999999*Math.random())+888888888)+"."+o;if(void 0!==navigator.msSaveOrOpenBlob)return navigator.msSaveOrOpenBlob(e,n);if(void 0!==navigator.msSaveBlob)return navigator.msSaveBlob(e,n);var r=document.createElement("a");r.href=D.createObjectURL(e),r.download=n,r.style="display:none;opacity:0;color:transparent;",(document.body||document.documentElement).appendChild(r),"function"==typeof r.click?r.click():(r.target="_blank",r.dispatchEvent(new MouseEvent("click",{view:window,bubbles:!0,cancelable:!0}))),D.revokeObjectURL(r.href)}function u(){return"undefined"!=typeof window&&"object"==typeof window.process&&"renderer"===window.process.type||(!(void 0===i||"object"!=typeof i.versions||!i.versions.electron)||"object"==typeof navigator&&"string"==typeof navigator.userAgent&&navigator.userAgent.indexOf("Electron")>=0)}function l(e,t){return e&&e.getTracks?e.getTracks().filter(function(e){return e.kind===(t||"audio")}):[]}function f(e,t){"srcObject"in t?t.srcObject=e:"mozSrcObject"in t?t.mozSrcObject=e:t.srcObject=e}function h(e,t){if("undefined"==typeof EBML)throw new Error("Please link: https://www.webrtc-experiment.com/EBML.js");var o=new EBML.Reader,i=new EBML.Decoder,n=EBML.tools,r=new FileReader;r.onload=function(e){i.decode(this.result).forEach(function(e){o.read(e)}),o.stop();var r=n.makeMetadataSeekable(o.metadatas,o.duration,o.cues),a=this.result.slice(o.metadataSize),d=new Blob([r,a],{type:"video/webm"});t(d)},r.readAsArrayBuffer(e)}function m(){if(E||I||U)return!0;var e,t,o=(navigator.appVersion,navigator.userAgent),i=""+parseFloat(navigator.appVersion),n=parseInt(navigator.appVersion,10);return(O||B)&&(e=o.indexOf("Chrome"),i=o.substring(e+7)),-1!==(t=i.indexOf(";"))&&(i=i.substring(0,t)),-1!==(t=i.indexOf(" "))&&(i=i.substring(0,t)),n=parseInt(""+i,10),isNaN(n)&&(i=""+parseFloat(navigator.appVersion),n=parseInt(navigator.appVersion,10)),n>=49}/**
   * MediaStreamRecorder is an abstraction layer for {@link https://w3c.github.io/mediacapture-record/MediaRecorder.html|MediaRecorder API}. It is used by {@link RecordRTC} to record MediaStream(s) in both Chrome and Firefox.
   * @summary Runs top over {@link https://w3c.github.io/mediacapture-record/MediaRecorder.html|MediaRecorder API}.
   * @license {@link https://github.com/muaz-khan/RecordRTC/blob/master/LICENSE|MIT}
   * @author {@link https://github.com/muaz-khan|Muaz Khan}
   * @typedef MediaStreamRecorder
   * @class
   * @example
   * var config = {
   *     mimeType: 'video/webm', // vp8, vp9, h264, mkv, opus/vorbis
   *     audioBitsPerSecond : 256 * 8 * 1024,
   *     videoBitsPerSecond : 256 * 8 * 1024,
   *     bitsPerSecond: 256 * 8 * 1024,  // if this is provided, skip above two
   *     checkForInactiveTracks: true,
   *     timeSlice: 1000, // concatenate intervals based blobs
   *     ondataavailable: function() {} // get intervals based blobs
   * }
   * var recorder = new MediaStreamRecorder(mediaStream, config);
   * recorder.record();
   * recorder.stop(function(blob) {
   *     video.src = URL.createObjectURL(blob);
   *
   *     // or
   *     var blob = recorder.blob;
   * });
   * @see {@link https://github.com/muaz-khan/RecordRTC|RecordRTC Source Code}
   * @param {MediaStream} mediaStream - MediaStream object fetched using getUserMedia API or generated using captureStreamUntilEnded or WebAudio API.
   * @param {object} config - {disableLogs:true, initCallback: function, mimeType: "video/webm", timeSlice: 1000}
   * @throws Will throw an error if first argument "MediaStream" is missing. Also throws error if "MediaRecorder API" are not supported by the browser.
   */
  function g(e,t){function o(){a.timestamps.push((new Date).getTime()),"function"==typeof t.onTimeStamp&&t.onTimeStamp(a.timestamps[a.timestamps.length-1],a.timestamps)}function i(e){return u&&u.mimeType?u.mimeType:e.mimeType||"video/webm"}function n(){c=[],u=null,a.timestamps=[]}function r(){if("active"in e){if(!e.active)return!1}else if("ended"in e&&e.ended)return!1;return!0}var a=this;if(void 0===e)throw'First argument "MediaStream" is required.';if("undefined"==typeof MediaRecorder)throw"Your browser does not support the Media Recorder API. Please try other modules e.g. WhammyRecorder or StereoAudioRecorder.";if(t=t||{mimeType:"video/webm"},"audio"===t.type){if(l(e,"video").length&&l(e,"audio").length){var d;navigator.mozGetUserMedia?(d=new F,d.addTrack(l(e,"audio")[0])):d=new F(l(e,"audio")),e=d}t.mimeType&&-1!==t.mimeType.toString().toLowerCase().indexOf("audio")||(t.mimeType=O?"audio/webm":"audio/ogg"),t.mimeType&&"audio/ogg"!==t.mimeType.toString().toLowerCase()&&navigator.mozGetUserMedia&&(t.mimeType="audio/ogg")}var c=[];this.getArrayOfBlobs=function(){return c},this.record=function(){a.blob=null,a.clearRecordedData(),a.timestamps=[],f=[],c=[];var n=t;t.disableLogs||console.log("Passing following config over MediaRecorder API.",n),u&&(u=null),O&&!m()&&(n="video/vp8"),"function"==typeof MediaRecorder.isTypeSupported&&n.mimeType&&(MediaRecorder.isTypeSupported(n.mimeType)||(t.disableLogs||console.warn("MediaRecorder API seems unable to record mimeType:",n.mimeType),n.mimeType="audio"===t.type?"audio/webm":"video/webm"));try{u=new MediaRecorder(e,n),t.mimeType=n.mimeType}catch(t){u=new MediaRecorder(e)}n.mimeType&&!MediaRecorder.isTypeSupported&&"canRecordMimeType"in u&&!1===u.canRecordMimeType(n.mimeType)&&(t.disableLogs||console.warn("MediaRecorder API seems unable to record mimeType:",n.mimeType)),u.ondataavailable=function(e){if(e.data&&f.push("ondataavailable: "+s(e.data.size)),"number"!=typeof t.timeSlice){if(!e.data||!e.data.size||e.data.size<100||a.blob)return void(a.recordingCallback&&(a.recordingCallback(new Blob([],{type:i(n)})),a.recordingCallback=null));a.blob=t.getNativeBlob?e.data:new Blob([e.data],{type:i(n)}),a.recordingCallback&&(a.recordingCallback(a.blob),a.recordingCallback=null)}else if(e.data&&e.data.size&&e.data.size>100&&(c.push(e.data),o(),"function"==typeof t.ondataavailable)){var r=t.getNativeBlob?e.data:new Blob([e.data],{type:i(n)});t.ondataavailable(r)}},u.onstart=function(){f.push("started")},u.onpause=function(){f.push("paused")},u.onresume=function(){f.push("resumed")},u.onstop=function(){f.push("stopped")},u.onerror=function(e){e&&(e.name||(e.name="UnknownError"),f.push("error: "+e),t.disableLogs||(-1!==e.name.toString().toLowerCase().indexOf("invalidstate")?console.error("The MediaRecorder is not in a state in which the proposed operation is allowed to be executed.",e):-1!==e.name.toString().toLowerCase().indexOf("notsupported")?console.error("MIME type (",n.mimeType,") is not supported.",e):-1!==e.name.toString().toLowerCase().indexOf("security")?console.error("MediaRecorder security error",e):"OutOfMemory"===e.name?console.error("The UA has exhaused the available memory. User agents SHOULD provide as much additional information as possible in the message attribute.",e):"IllegalStreamModification"===e.name?console.error("A modification to the stream has occurred that makes it impossible to continue recording. An example would be the addition of a Track while recording is occurring. User agents SHOULD provide as much additional information as possible in the message attribute.",e):"OtherRecordingError"===e.name?console.error("Used for an fatal error other than those listed above. User agents SHOULD provide as much additional information as possible in the message attribute.",e):"GenericError"===e.name?console.error("The UA cannot provide the codec or recording option that has been requested.",e):console.error("MediaRecorder Error",e)),function(e){if(!a.manuallyStopped&&u&&"inactive"===u.state)return delete t.timeslice,void u.start(6e5);setTimeout(void 0,1e3)}(),"inactive"!==u.state&&"stopped"!==u.state&&u.stop())},"number"==typeof t.timeSlice?(o(),u.start(t.timeSlice)):u.start(36e5),t.initCallback&&t.initCallback()},this.timestamps=[],this.stop=function(e){e=e||function(){},a.manuallyStopped=!0,u&&(this.recordingCallback=e,"recording"===u.state&&u.stop(),"number"==typeof t.timeSlice&&setTimeout(function(){a.blob=new Blob(c,{type:i(t)}),a.recordingCallback(a.blob)},100))},this.pause=function(){u&&"recording"===u.state&&u.pause()},this.resume=function(){u&&"paused"===u.state&&u.resume()},this.clearRecordedData=function(){u&&"recording"===u.state&&a.stop(n),n()};var u;this.getInternalRecorder=function(){return u},this.blob=null,this.getState=function(){return u?u.state||"inactive":"inactive"};var f=[];this.getAllStates=function(){return f},void 0===t.checkForInactiveTracks&&(t.checkForInactiveTracks=!1);var a=this;!function e(){if(u&&!1!==t.checkForInactiveTracks)return!1===r()?(t.disableLogs||console.log("MediaStream seems stopped."),void a.stop()):void setTimeout(e,1e3)}(),this.name="MediaStreamRecorder",this.toString=function(){return this.name}}/**
   * StereoAudioRecorder is a standalone class used by {@link RecordRTC} to bring "stereo" audio-recording in chrome.
   * @summary JavaScript standalone object for stereo audio recording.
   * @license {@link https://github.com/muaz-khan/RecordRTC/blob/master/LICENSE|MIT}
   * @author {@link https://MuazKhan.com|Muaz Khan}
   * @typedef StereoAudioRecorder
   * @class
   * @example
   * var recorder = new StereoAudioRecorder(MediaStream, {
   *     sampleRate: 44100,
   *     bufferSize: 4096
   * });
   * recorder.record();
   * recorder.stop(function(blob) {
   *     video.src = URL.createObjectURL(blob);
   * });
   * @see {@link https://github.com/muaz-khan/RecordRTC|RecordRTC Source Code}
   * @param {MediaStream} mediaStream - MediaStream object fetched using getUserMedia API or generated using captureStreamUntilEnded or WebAudio API.
   * @param {object} config - {sampleRate: 44100, bufferSize: 4096, numberOfAudioChannels: 1, etc.}
   */
  function p(e,t){function o(){if(!1===t.checkForInactiveTracks)return!0;if("active"in e){if(!e.active)return!1}else if("ended"in e&&e.ended)return!1;return!0}function i(e,t){function o(e,t){function o(e,t,o){var n=Math.round(e.length*(t/o)),r=[],a=Number((e.length-1)/(n-1));r[0]=e[0];for(var d=1;d<n-1;d++){var s=d*a,c=Number(Math.floor(s)).toFixed(),u=Number(Math.ceil(s)).toFixed(),l=s-c;r[d]=i(e[c],e[u],l)}return r[n-1]=e[e.length-1],r}function i(e,t,o){return e+(t-e)*o}function n(e,t){for(var o=new Float64Array(t),i=0,n=e.length,r=0;r<n;r++){var a=e[r];o.set(a,i),i+=a.length}return o}function r(e,t,o){for(var i=o.length,n=0;n<i;n++)e.setUint8(t+n,o.charCodeAt(n))}var a=e.numberOfAudioChannels,d=e.leftBuffers.slice(0),s=e.rightBuffers.slice(0),c=e.sampleRate,u=e.internalInterleavedLength,l=e.desiredSampRate;2===a&&(d=n(d,u),s=n(s,u),l&&(d=o(d,l,c),s=o(s,l,c))),1===a&&(d=n(d,u),l&&(d=o(d,l,c))),l&&(c=l);var f;2===a&&(f=function(e,t){for(var o=e.length+t.length,i=new Float64Array(o),n=0,r=0;r<o;)i[r++]=e[n],i[r++]=t[n],n++;return i}(d,s)),1===a&&(f=d);var h=f.length,m=44+2*h,g=new ArrayBuffer(m),p=new DataView(g);r(p,0,"RIFF"),p.setUint32(4,36+2*h,!0),r(p,8,"WAVE"),r(p,12,"fmt "),p.setUint32(16,16,!0),p.setUint16(20,1,!0),p.setUint16(22,a,!0),p.setUint32(24,c,!0),p.setUint32(28,2*c,!0),p.setUint16(32,2*a,!0),p.setUint16(34,16,!0),r(p,36,"data"),p.setUint32(40,2*h,!0);for(var v=h,b=44,w=0;w<v;w++)p.setInt16(b,32767*f[w],!0),b+=2;if(t)return t({buffer:g,view:p});postMessage({buffer:g,view:p})}if(e.noWorker)return void o(e,function(e){t(e.buffer,e.view)});var i=r(o);i.onmessage=function(e){t(e.data.buffer,e.data.view),D.revokeObjectURL(i.workerURL),i.terminate()},i.postMessage(e)}function r(e){var t=D.createObjectURL(new Blob([e.toString(),";this.onmessage =  function (eee) {"+e.name+"(eee.data);}"],{type:"application/javascript"})),o=new Worker(t);return o.workerURL=t,o}function a(){h=[],m=[],p=0,k=!1,g=!1,C=!1,w=null,f.leftchannel=h,f.rightchannel=m,f.numberOfAudioChannels=v,f.desiredSampRate=b,f.sampleRate=T,f.recordingLength=p,L={left:[],right:[],recordingLength:0}}function d(){u&&(u.onaudioprocess=null,u.disconnect(),u=null),y&&(y.disconnect(),y=null),a()}function s(e){if(!C){if(!1===o()&&(t.disableLogs||console.log("MediaStream seems stopped."),u.disconnect(),g=!1),!g)return void(y&&(y.disconnect(),y=null));k||(k=!0,t.onAudioProcessStarted&&t.onAudioProcessStarted(),t.initCallback&&t.initCallback());var i=e.inputBuffer.getChannelData(0),n=new Float32Array(i);if(h.push(n),2===v){var r=e.inputBuffer.getChannelData(1),a=new Float32Array(r);m.push(a)}p+=S,f.recordingLength=p,void 0!==t.timeSlice&&(L.recordingLength+=S,L.left.push(n),2===v&&L.right.push(a))}}function c(){g&&"function"==typeof t.ondataavailable&&void 0!==t.timeSlice&&(L.left.length?(i({desiredSampRate:b,sampleRate:T,numberOfAudioChannels:v,internalInterleavedLength:L.recordingLength,leftBuffers:L.left,rightBuffers:1===v?[]:L.right},function(e,o){var i=new Blob([o],{type:"audio/wav"});t.ondataavailable(i),setTimeout(c,t.timeSlice)}),L={left:[],right:[],recordingLength:0}):setTimeout(c,t.timeSlice))}if(!l(e,"audio").length)throw"Your stream has no audio tracks.";t=t||{};var u,f=this,h=[],m=[],g=!1,p=0,v=2,b=t.desiredSampRate;!0===t.leftChannel&&(v=1),1===t.numberOfAudioChannels&&(v=1),(!v||v<1)&&(v=2),t.disableLogs||console.log("StereoAudioRecorder is set to record number of channels: "+v),void 0===t.checkForInactiveTracks&&(t.checkForInactiveTracks=!0),this.record=function(){if(!1===o())throw"Please make sure MediaStream is active.";a(),k=C=!1,g=!0,void 0!==t.timeSlice&&c()},this.stop=function(e){e=e||function(){},g=!1,i({desiredSampRate:b,sampleRate:T,numberOfAudioChannels:v,internalInterleavedLength:p,leftBuffers:h,rightBuffers:1===v?[]:m,noWorker:t.noWorker},function(t,o){f.blob=new Blob([o],{type:"audio/wav"}),f.buffer=new ArrayBuffer(o.buffer.byteLength),f.view=o,f.sampleRate=b||T,f.bufferSize=S,f.length=p,k=!1,e&&e(f.blob)})},void 0===n.Storage&&(n.Storage={AudioContextConstructor:null,AudioContext:window.AudioContext||window.webkitAudioContext}),n.Storage.AudioContextConstructor&&"closed"!==n.Storage.AudioContextConstructor.state||(n.Storage.AudioContextConstructor=new n.Storage.AudioContext);var w=n.Storage.AudioContextConstructor,y=w.createMediaStreamSource(e),R=[0,256,512,1024,2048,4096,8192,16384],S=void 0===t.bufferSize?4096:t.bufferSize;if(-1===R.indexOf(S)&&(t.disableLogs||console.log("Legal values for buffer-size are "+JSON.stringify(R,null,"\t"))),w.createJavaScriptNode)u=w.createJavaScriptNode(S,v,v);else{if(!w.createScriptProcessor)throw"WebAudio API has no support on this browser.";u=w.createScriptProcessor(S,v,v)}y.connect(u),t.bufferSize||(S=u.bufferSize);var T=void 0!==t.sampleRate?t.sampleRate:w.sampleRate||44100;(T<22050||T>96e3)&&(t.disableLogs||console.log("sample-rate must be under range 22050 and 96000.")),t.disableLogs||t.desiredSampRate&&console.log("Desired sample-rate: "+t.desiredSampRate);var C=!1;this.pause=function(){C=!0},this.resume=function(){if(!1===o())throw"Please make sure MediaStream is active.";if(!g)return t.disableLogs||console.log("Seems recording has been restarted."),void this.record();C=!1},this.clearRecordedData=function(){t.checkForInactiveTracks=!1,g&&this.stop(d),d()},this.name="StereoAudioRecorder",this.toString=function(){return this.name};var k=!1;u.onaudioprocess=s,w.createMediaStreamDestination?u.connect(w.createMediaStreamDestination()):u.connect(w.destination),this.leftchannel=h,this.rightchannel=m,this.numberOfAudioChannels=v,this.desiredSampRate=b,this.sampleRate=T,f.recordingLength=p;var L={left:[],right:[],recordingLength:0}}/**
   * CanvasRecorder is a standalone class used by {@link RecordRTC} to bring HTML5-Canvas recording into video WebM. It uses HTML2Canvas library and runs top over {@link Whammy}.
   * @summary HTML2Canvas recording into video WebM.
   * @license {@link https://github.com/muaz-khan/RecordRTC/blob/master/LICENSE|MIT}
   * @author {@link https://MuazKhan.com|Muaz Khan}
   * @typedef CanvasRecorder
   * @class
   * @example
   * var recorder = new CanvasRecorder(htmlElement, { disableLogs: true, useWhammyRecorder: true });
   * recorder.record();
   * recorder.stop(function(blob) {
   *     video.src = URL.createObjectURL(blob);
   * });
   * @see {@link https://github.com/muaz-khan/RecordRTC|RecordRTC Source Code}
   * @param {HTMLElement} htmlElement - querySelector/getElementById/getElementsByTagName[0]/etc.
   * @param {object} config - {disableLogs:true, initCallback: function}
   */
  function v(e,t){function o(){p.frames=[],f=!1,h=!1}function i(){var t=document.createElement("canvas"),o=t.getContext("2d");return t.width=e.width,t.height=e.height,o.drawImage(e,0,0),t}function n(){if(h)return m=(new Date).getTime(),setTimeout(n,500);if("canvas"===e.nodeName.toLowerCase()){var o=(new Date).getTime()-m;return m=(new Date).getTime(),p.frames.push({image:i(),duration:o}),void(f&&setTimeout(n,t.frameInterval))}html2canvas(e,{grabMouse:void 0===t.showMousePointer||t.showMousePointer,onrendered:function(e){var o=(new Date).getTime()-m;if(!o)return setTimeout(n,t.frameInterval);m=(new Date).getTime(),p.frames.push({image:e.toDataURL("image/webp",1),duration:o}),f&&setTimeout(n,t.frameInterval)}})}if("undefined"==typeof html2canvas)throw"Please link: https://www.webrtc-experiment.com/screenshot.js";t=t||{},t.frameInterval||(t.frameInterval=10);var r=!1;["captureStream","mozCaptureStream","webkitCaptureStream"].forEach(function(e){e in document.createElement("canvas")&&(r=!0)});var a=!(!window.webkitRTCPeerConnection&&!window.webkitGetUserMedia||!window.chrome),d=50,s=navigator.userAgent.match(/Chrom(e|ium)\/([0-9]+)\./);a&&s&&s[2]&&(d=parseInt(s[2],10)),a&&d<52&&(r=!1),t.useWhammyRecorder&&(r=!1);var c,u;if(r)if(t.disableLogs||console.log("Your browser supports both MediRecorder API and canvas.captureStream!"),e instanceof HTMLCanvasElement)c=e;else{if(!(e instanceof CanvasRenderingContext2D))throw"Please pass either HTMLCanvasElement or CanvasRenderingContext2D.";c=e.canvas}else navigator.mozGetUserMedia&&(t.disableLogs||console.error("Canvas recording is NOT supported in Firefox."));var f;this.record=function(){if(f=!0,r&&!t.useWhammyRecorder){var e;"captureStream"in c?e=c.captureStream(25):"mozCaptureStream"in c?e=c.mozCaptureStream(25):"webkitCaptureStream"in c&&(e=c.webkitCaptureStream(25));try{var o=new F;o.addTrack(l(e,"video")[0]),e=o}catch(e){}if(!e)throw"captureStream API are NOT available.";u=new g(e,{mimeType:t.mimeType||"video/webm"}),u.record()}else p.frames=[],m=(new Date).getTime(),n();t.initCallback&&t.initCallback()},this.getWebPImages=function(o){if("canvas"!==e.nodeName.toLowerCase())return void o();var i=p.frames.length;p.frames.forEach(function(e,o){var n=i-o;t.disableLogs||console.log(n+"/"+i+" frames remaining"),t.onEncodingCallback&&t.onEncodingCallback(n,i);var r=e.image.toDataURL("image/webp",1);p.frames[o].image=r}),t.disableLogs||console.log("Generating WebM"),o()},this.stop=function(e){f=!1;var o=this;if(r&&u)return void u.stop(e);this.getWebPImages(function(){p.compile(function(i){t.disableLogs||console.log("Recording finished!"),o.blob=i,o.blob.forEach&&(o.blob=new Blob([],{type:"video/webm"})),e&&e(o.blob),p.frames=[]})})};var h=!1;this.pause=function(){if(h=!0,u instanceof g)return void u.pause()},this.resume=function(){if(h=!1,u instanceof g)return void u.resume();f||this.record()},this.clearRecordedData=function(){f&&this.stop(o),o()},this.name="CanvasRecorder",this.toString=function(){return this.name};var m=(new Date).getTime(),p=new P.Video(100)}/**
   * WhammyRecorder is a standalone class used by {@link RecordRTC} to bring video recording in Chrome. It runs top over {@link Whammy}.
   * @summary Video recording feature in Chrome.
   * @license {@link https://github.com/muaz-khan/RecordRTC/blob/master/LICENSE|MIT}
   * @author {@link https://MuazKhan.com|Muaz Khan}
   * @typedef WhammyRecorder
   * @class
   * @example
   * var recorder = new WhammyRecorder(mediaStream);
   * recorder.record();
   * recorder.stop(function(blob) {
   *     video.src = URL.createObjectURL(blob);
   * });
   * @see {@link https://github.com/muaz-khan/RecordRTC|RecordRTC Source Code}
   * @param {MediaStream} mediaStream - MediaStream object fetched using getUserMedia API or generated using captureStreamUntilEnded or WebAudio API.
   * @param {object} config - {disableLogs: true, initCallback: function, video: HTMLVideoElement, etc.}
   */
  function b(e,t){function o(e){e=void 0!==e?e:10;var t=(new Date).getTime()-c;return t?d?(c=(new Date).getTime(),setTimeout(o,100)):(c=(new Date).getTime(),s.paused&&s.play(),h.drawImage(s,0,0,l.width,l.height),u.frames.push({duration:t,image:l.toDataURL("image/webp")}),void(a||setTimeout(o,e,e))):setTimeout(o,e,e)}function i(e){var t=-1,o=e.length;!function i(){if(++t===o)return void e.callback();setTimeout(function(){e.functionToLoop(i,t)},1)}()}function n(e,t,o,n,r){var a=document.createElement("canvas");a.width=l.width,a.height=l.height;var d=a.getContext("2d"),s=[],c=-1===t,u=t&&t>0&&t<=e.length?t:e.length,f={r:0,g:0,b:0},h=Math.sqrt(Math.pow(255,2)+Math.pow(255,2)+Math.pow(255,2)),m=o&&o>=0&&o<=1?o:0,g=n&&n>=0&&n<=1?n:0,p=!1;i({length:u,functionToLoop:function(t,o){var i,n,r,a=function(){!p&&r-i<=r*g||(c&&(p=!0),s.push(e[o])),t()};if(p)a();else{var u=new Image;u.onload=function(){d.drawImage(u,0,0,l.width,l.height);var e=d.getImageData(0,0,l.width,l.height);i=0,n=e.data.length,r=e.data.length/4;for(var t=0;t<n;t+=4){var o={r:e.data[t],g:e.data[t+1],b:e.data[t+2]};Math.sqrt(Math.pow(o.r-f.r,2)+Math.pow(o.g-f.g,2)+Math.pow(o.b-f.b,2))<=h*m&&i++}a()},u.src=e[o].image}},callback:function(){s=s.concat(e.slice(u)),s.length<=0&&s.push(e[e.length-1]),r(s)}})}function r(){u.frames=[],a=!0,d=!1}t=t||{},t.frameInterval||(t.frameInterval=10),t.disableLogs||console.log("Using frames-interval:",t.frameInterval),this.record=function(){t.width||(t.width=320),t.height||(t.height=240),t.video||(t.video={width:t.width,height:t.height}),t.canvas||(t.canvas={width:t.width,height:t.height}),l.width=t.canvas.width||320,l.height=t.canvas.height||240,h=l.getContext("2d"),t.video&&t.video instanceof HTMLVideoElement?(s=t.video.cloneNode(),t.initCallback&&t.initCallback()):(s=document.createElement("video"),f(e,s),s.onloadedmetadata=function(){t.initCallback&&t.initCallback()},s.width=t.video.width,s.height=t.video.height),s.muted=!0,s.play(),c=(new Date).getTime(),u=new P.Video,t.disableLogs||(console.log("canvas resolutions",l.width,"*",l.height),console.log("video width/height",s.width||l.width,"*",s.height||l.height)),o(t.frameInterval)};var a=!1;this.stop=function(e){e=e||function(){},a=!0;var o=this;setTimeout(function(){n(u.frames,-1,null,null,function(i){u.frames=i,t.advertisement&&t.advertisement.length&&(u.frames=t.advertisement.concat(u.frames)),u.compile(function(t){o.blob=t,o.blob.forEach&&(o.blob=new Blob([],{type:"video/webm"})),e&&e(o.blob)})})},10)};var d=!1;this.pause=function(){d=!0},this.resume=function(){d=!1,a&&this.record()},this.clearRecordedData=function(){a||this.stop(r),r()},this.name="WhammyRecorder",this.toString=function(){return this.name};var s,c,u,l=document.createElement("canvas"),h=l.getContext("2d")}/**
   * GifRecorder is standalone calss used by {@link RecordRTC} to record video or canvas into animated gif.
   * @license {@link https://github.com/muaz-khan/RecordRTC/blob/master/LICENSE|MIT}
   * @author {@link https://MuazKhan.com|Muaz Khan}
   * @typedef GifRecorder
   * @class
   * @example
   * var recorder = new GifRecorder(mediaStream || canvas || context, { onGifPreview: function, onGifRecordingStarted: function, width: 1280, height: 720, frameRate: 200, quality: 10 });
   * recorder.record();
   * recorder.stop(function(blob) {
   *     img.src = URL.createObjectURL(blob);
   * });
   * @see {@link https://github.com/muaz-khan/RecordRTC|RecordRTC Source Code}
   * @param {MediaStream} mediaStream - MediaStream object or HTMLCanvasElement or CanvasRenderingContext2D.
   * @param {object} config - {disableLogs:true, initCallback: function, width: 320, height: 240, frameRate: 200, quality: 10}
   */
  function w(e,t){function o(){m&&(m.stream().bin=[])}if("undefined"==typeof GIFEncoder){var i=document.createElement("script");i.src="https://www.webrtc-experiment.com/gif-recorder.js",(document.body||document.documentElement).appendChild(i)}t=t||{};var n=e instanceof CanvasRenderingContext2D||e instanceof HTMLCanvasElement;this.record=function(){function e(o){if(!0!==p.clearedRecordedData){if(r)return setTimeout(function(){e(o)},100);g=L(e),void 0===typeof h&&(h=o),o-h<90||(!n&&c.paused&&c.play(),n||d.drawImage(c,0,0,a.width,a.height),t.onGifPreview&&t.onGifPreview(a.toDataURL("image/png")),m.addFrame(d),h=o)}}return"undefined"==typeof GIFEncoder?void setTimeout(p.record,1e3):s?(n||(t.width||(t.width=c.offsetWidth||320),t.height||(t.height=c.offsetHeight||240),t.video||(t.video={width:t.width,height:t.height}),t.canvas||(t.canvas={width:t.width,height:t.height}),a.width=t.canvas.width||320,a.height=t.canvas.height||240,c.width=t.video.width||320,c.height=t.video.height||240),m=new GIFEncoder,m.setRepeat(0),m.setDelay(t.frameRate||200),m.setQuality(t.quality||10),m.start(),"function"==typeof t.onGifRecordingStarted&&t.onGifRecordingStarted(),u=Date.now(),g=L(e),void(t.initCallback&&t.initCallback())):void setTimeout(p.record,1e3)},this.stop=function(e){e=e||function(){},g&&A(g),l=Date.now(),this.blob=new Blob([new Uint8Array(m.stream().bin)],{type:"image/gif"}),e(this.blob),m.stream().bin=[]};var r=!1;this.pause=function(){r=!0},this.resume=function(){r=!1},this.clearRecordedData=function(){p.clearedRecordedData=!0,o()},this.name="GifRecorder",this.toString=function(){return this.name};var a=document.createElement("canvas"),d=a.getContext("2d");n&&(e instanceof CanvasRenderingContext2D?(d=e,a=d.canvas):e instanceof HTMLCanvasElement&&(d=e.getContext("2d"),a=e));var s=!0;if(!n){var c=document.createElement("video");c.muted=!0,c.autoplay=!0,c.playsInline=!0,s=!1,c.onloadedmetadata=function(){s=!0},f(e,c),c.play()}var u,l,h,m,g=null,p=this}function y(e,t){function i(e,t){"srcObject"in t?t.srcObject=e:"mozSrcObject"in t?t.mozSrcObject=e:t.srcObject=e}function r(){if(!h){var e=f.length,t=!1,o=[];if(f.forEach(function(e){e.stream||(e.stream={}),e.stream.fullcanvas?t=e:o.push(e)}),t)m.width=t.stream.width,m.height=t.stream.height;else if(o.length){m.width=e>1?2*o[0].width:o[0].width;var i=1;3!==e&&4!==e||(i=2),5!==e&&6!==e||(i=3),7!==e&&8!==e||(i=4),9!==e&&10!==e||(i=5),m.height=o[0].height*i}else m.width=p.width||360,m.height=p.height||240;t&&t instanceof HTMLVideoElement&&a(t),o.forEach(function(e,t){a(e,t)}),setTimeout(r,p.frameInterval)}}function a(e,t){if(!h){var o=0,i=0,n=e.width,r=e.height;1===t&&(o=e.width),2===t&&(i=e.height),3===t&&(o=e.width,i=e.height),4===t&&(i=2*e.height),5===t&&(o=e.width,i=2*e.height),6===t&&(i=3*e.height),7===t&&(o=e.width,i=3*e.height),void 0!==e.stream.left&&(o=e.stream.left),void 0!==e.stream.top&&(i=e.stream.top),void 0!==e.stream.width&&(n=e.stream.width),void 0!==e.stream.height&&(r=e.stream.height),g.drawImage(e,o,i,n,r),"function"==typeof e.stream.onRender&&e.stream.onRender(g,o,i,n,r,t)}}function d(){h=!1;var t=s(),o=c();o&&o.getTracks().filter(function(e){return"audio"===e.kind}).forEach(function(e){t.addTrack(e)});var i;return e.forEach(function(e){e.fullcanvas&&(i=!0)}),t}function s(){l();var e;"captureStream"in m?e=m.captureStream():"mozCaptureStream"in m?e=m.mozCaptureStream():p.disableLogs||console.error("Upgrade to latest Chrome or otherwise enable this flag: chrome://flags/#enable-experimental-web-platform-features");var t=new w;return e.getTracks().filter(function(e){return"video"===e.kind}).forEach(function(e){t.addTrack(e)}),m.stream=t,t}function c(){y.AudioContextConstructor||(y.AudioContextConstructor=new y.AudioContext),p.audioContext=y.AudioContextConstructor,p.audioSources=[],!0===p.useGainNode&&(p.gainNode=p.audioContext.createGain(),p.gainNode.connect(p.audioContext.destination),p.gainNode.gain.value=0);var t=0;if(e.forEach(function(e){if(e.getTracks().filter(function(e){return"audio"===e.kind}).length){t++;var o=p.audioContext.createMediaStreamSource(e);!0===p.useGainNode&&o.connect(p.gainNode),p.audioSources.push(o)}}),t)return p.audioDestination=p.audioContext.createMediaStreamDestination(),p.audioSources.forEach(function(e){e.connect(p.audioDestination)}),p.audioDestination.stream}function u(e){var o=document.createElement("video");return i(e,o),o.className=t,o.muted=!0,o.volume=0,o.width=e.width||p.width||360,o.height=e.height||p.height||240,o.play(),o}function l(t){f=[],t=t||e,t.forEach(function(e){if(e.getTracks().filter(function(e){return"video"===e.kind}).length){var t=u(e);t.stream=e,f.push(t)}})}!function(e){void 0===n&&e&&"undefined"==typeof window&&void 0!==o&&(o.navigator={userAgent:"Fake/5.0 (FakeOS) AppleWebKit/123 (KHTML, like Gecko) Fake/12.3.4567.89 Fake/123.45",getUserMedia:function(){}},o.console||(o.console={}),void 0!==o.console.log&&void 0!==o.console.error||(o.console.error=o.console.log=o.console.log||function(){console.log(arguments)}),"undefined"==typeof document&&(e.document={documentElement:{appendChild:function(){return""}}},document.createElement=document.captureStream=document.mozCaptureStream=function(){var e={getContext:function(){return e},play:function(){},pause:function(){},drawImage:function(){},toDataURL:function(){return""},style:{}};return e},e.HTMLVideoElement=function(){}),"undefined"==typeof location&&(e.location={protocol:"file:",href:"",hash:""}),"undefined"==typeof screen&&(e.screen={width:0,height:0}),void 0===b&&(e.URL={createObjectURL:function(){return""},revokeObjectURL:function(){return""}}),e.window=o)}(void 0!==o?o:null),t=t||"multi-streams-mixer";var f=[],h=!1,m=document.createElement("canvas"),g=m.getContext("2d");m.style.opacity=0,m.style.position="absolute",m.style.zIndex=-1,m.style.top="-1000em",m.style.left="-1000em",m.className=t,(document.body||document.documentElement).appendChild(m),this.disableLogs=!1,this.frameInterval=10,this.width=360,this.height=240,this.useGainNode=!0;var p=this,v=window.AudioContext;void 0===v&&("undefined"!=typeof webkitAudioContext&&(v=webkitAudioContext),"undefined"!=typeof mozAudioContext&&(v=mozAudioContext));var b=window.URL;void 0===b&&"undefined"!=typeof webkitURL&&(b=webkitURL),"undefined"!=typeof navigator&&void 0===navigator.getUserMedia&&(void 0!==navigator.webkitGetUserMedia&&(navigator.getUserMedia=navigator.webkitGetUserMedia),void 0!==navigator.mozGetUserMedia&&(navigator.getUserMedia=navigator.mozGetUserMedia));var w=window.MediaStream;void 0===w&&"undefined"!=typeof webkitMediaStream&&(w=webkitMediaStream),void 0!==w&&void 0===w.prototype.stop&&(w.prototype.stop=function(){this.getTracks().forEach(function(e){e.stop()})});var y={};void 0!==v?y.AudioContext=v:"undefined"!=typeof webkitAudioContext&&(y.AudioContext=webkitAudioContext),this.startDrawingFrames=function(){r()},this.appendStreams=function(t){if(!t)throw"First parameter is required.";t instanceof Array||(t=[t]),t.forEach(function(t){var o=new w;if(t.getTracks().filter(function(e){return"video"===e.kind}).length){var i=u(t);i.stream=t,f.push(i),o.addTrack(t.getTracks().filter(function(e){return"video"===e.kind})[0])}if(t.getTracks().filter(function(e){return"audio"===e.kind}).length){var n=p.audioContext.createMediaStreamSource(t);p.audioDestination=p.audioContext.createMediaStreamDestination(),n.connect(p.audioDestination),o.addTrack(p.audioDestination.stream.getTracks().filter(function(e){return"audio"===e.kind})[0])}e.push(o)})},this.releaseStreams=function(){f=[],h=!0,p.gainNode&&(p.gainNode.disconnect(),p.gainNode=null),p.audioSources.length&&(p.audioSources.forEach(function(e){e.disconnect()}),p.audioSources=[]),p.audioDestination&&(p.audioDestination.disconnect(),p.audioDestination=null),p.audioContext&&p.audioContext.close(),p.audioContext=null,g.clearRect(0,0,m.width,m.height),m.stream&&(m.stream.stop(),m.stream=null)},this.resetVideoStreams=function(e){!e||e instanceof Array||(e=[e]),l(e)},this.name="MultiStreamsMixer",this.toString=function(){return this.name},this.getMixedStream=d}/**
   * MultiStreamRecorder can record multiple videos in single container.
   * @summary Multi-videos recorder.
   * @license {@link https://github.com/muaz-khan/RecordRTC/blob/master/LICENSE|MIT}
   * @author {@link https://MuazKhan.com|Muaz Khan}
   * @typedef MultiStreamRecorder
   * @class
   * @example
   * var options = {
   *     mimeType: 'video/webm'
   * }
   * var recorder = new MultiStreamRecorder(ArrayOfMediaStreams, options);
   * recorder.record();
   * recorder.stop(function(blob) {
   *     video.src = URL.createObjectURL(blob);
   *
   *     // or
   *     var blob = recorder.blob;
   * });
   * @see {@link https://github.com/muaz-khan/RecordRTC|RecordRTC Source Code}
   * @param {MediaStreams} mediaStreams - Array of MediaStreams.
   * @param {object} config - {disableLogs:true, frameInterval: 1, mimeType: "video/webm"}
   */
  function R(e,t){function o(){var t=[];return e.forEach(function(e){l(e,"video").forEach(function(e){t.push(e)})}),t}e=e||[];var i,n,r=this;t=t||{elementClass:"multi-streams-mixer",mimeType:"video/webm",video:{width:360,height:240}},t.frameInterval||(t.frameInterval=10),t.video||(t.video={}),t.video.width||(t.video.width=360),t.video.height||(t.video.height=240),this.record=function(){i=new y(e,t.elementClass||"multi-streams-mixer"),o().length&&(i.frameInterval=t.frameInterval||10,i.width=t.video.width||360,i.height=t.video.height||240,i.startDrawingFrames()),t.previewStream&&"function"==typeof t.previewStream&&t.previewStream(i.getMixedStream()),n=new g(i.getMixedStream(),t),n.record()},this.stop=function(e){n&&n.stop(function(t){r.blob=t,e(t),r.clearRecordedData()})},this.pause=function(){n&&n.pause()},this.resume=function(){n&&n.resume()},this.clearRecordedData=function(){n&&(n.clearRecordedData(),n=null),i&&(i.releaseStreams(),i=null)},this.addStreams=function(o){if(!o)throw"First parameter is required.";o instanceof Array||(o=[o]),e.concat(o),n&&i&&(i.appendStreams(o),t.previewStream&&"function"==typeof t.previewStream&&t.previewStream(i.getMixedStream()))},this.resetVideoStreams=function(e){i&&(!e||e instanceof Array||(e=[e]),i.resetVideoStreams(e))},this.getMixer=function(){return i},this.name="MultiStreamRecorder",this.toString=function(){return this.name}}/**
   * RecordRTCPromisesHandler adds promises support in {@link RecordRTC}. Try a {@link https://github.com/muaz-khan/RecordRTC/blob/master/simple-demos/RecordRTCPromisesHandler.html|demo here}
   * @summary Promises for {@link RecordRTC}
   * @license {@link https://github.com/muaz-khan/RecordRTC/blob/master/LICENSE|MIT}
   * @author {@link https://MuazKhan.com|Muaz Khan}
   * @typedef RecordRTCPromisesHandler
   * @class
   * @example
   * var recorder = new RecordRTCPromisesHandler(mediaStream, options);
   * recorder.startRecording()
   *         .then(successCB)
   *         .catch(errorCB);
   * // Note: You can access all RecordRTC API using "recorder.recordRTC" e.g. 
   * recorder.recordRTC.onStateChanged = function(state) {};
   * recorder.recordRTC.setRecordingDuration(5000);
   * @see {@link https://github.com/muaz-khan/RecordRTC|RecordRTC Source Code}
   * @param {MediaStream} mediaStream - Single media-stream object, array of media-streams, html-canvas-element, etc.
   * @param {object} config - {type:"video", recorderType: MediaStreamRecorder, disableLogs: true, numberOfAudioChannels: 1, bufferSize: 0, sampleRate: 0, video: HTMLVideoElement, etc.}
   * @throws Will throw an error if "new" keyword is not used to initiate "RecordRTCPromisesHandler". Also throws error if first argument "MediaStream" is missing.
   * @requires {@link RecordRTC}
   */
  function S(e,t){if(!this)throw'Use "new RecordRTCPromisesHandler()"';if(void 0===e)throw'First argument "MediaStream" is required.';var o=this;o.recordRTC=new n(e,t),this.startRecording=function(){return new Promise(function(e,t){try{o.recordRTC.startRecording(),e()}catch(e){t(e)}})},this.stopRecording=function(){return new Promise(function(e,t){try{o.recordRTC.stopRecording(function(i){if(o.blob=o.recordRTC.getBlob(),!o.blob||!o.blob.size)return void t("Empty blob.",o.blob);e(i)})}catch(e){t(e)}})},this.pauseRecording=function(){return new Promise(function(e,t){try{o.recordRTC.pauseRecording(),e()}catch(e){t(e)}})},this.resumeRecording=function(){return new Promise(function(e,t){try{o.recordRTC.resumeRecording(),e()}catch(e){t(e)}})},this.getDataURL=function(e){return new Promise(function(e,t){try{o.recordRTC.getDataURL(function(t){e(t)})}catch(e){t(e)}})},this.getBlob=function(){return new Promise(function(e,t){try{e(o.recordRTC.getBlob())}catch(e){t(e)}})},this.getInternalRecorder=function(){return new Promise(function(e,t){try{e(o.recordRTC.getInternalRecorder())}catch(e){t(e)}})},this.reset=function(){return new Promise(function(e,t){try{e(o.recordRTC.reset())}catch(e){t(e)}})},this.destroy=function(){return new Promise(function(e,t){try{e(o.recordRTC.destroy())}catch(e){t(e)}})},this.getState=function(){return new Promise(function(e,t){try{e(o.recordRTC.getState())}catch(e){t(e)}})},this.blob=null,this.version="5.5.9"}/**
   * WebAssemblyRecorder lets you create webm videos in JavaScript via WebAssembly. The library consumes raw RGBA32 buffers (4 bytes per pixel) and turns them into a webm video with the given framerate and quality. This makes it compatible out-of-the-box with ImageData from a CANVAS. With realtime mode you can also use webm-wasm for streaming webm videos.
   * @summary Video recording feature in Chrome, Firefox and maybe Edge.
   * @license {@link https://github.com/muaz-khan/RecordRTC/blob/master/LICENSE|MIT}
   * @author {@link https://MuazKhan.com|Muaz Khan}
   * @typedef WebAssemblyRecorder
   * @class
   * @example
   * var recorder = new WebAssemblyRecorder(mediaStream);
   * recorder.record();
   * recorder.stop(function(blob) {
   *     video.src = URL.createObjectURL(blob);
   * });
   * @see {@link https://github.com/muaz-khan/RecordRTC|RecordRTC Source Code}
   * @param {MediaStream} mediaStream - MediaStream object fetched using getUserMedia API or generated using captureStreamUntilEnded or WebAudio API.
   * @param {object} config - {webAssemblyPath:'webm-wasm.wasm',workerPath: 'webm-worker.js', frameRate: 30, width: 1920, height: 1080, bitrate: 1024}
   */
  function T(e,t){function o(){return new ReadableStream({start:function(o){var i=document.createElement("canvas"),n=document.createElement("video");n.srcObject=e,n.onplaying=function(){i.width=t.width,i.height=t.height;var e=i.getContext("2d"),r=1e3/t.frameRate;setTimeout(function i(){e.drawImage(n,0,0),o.enqueue(e.getImageData(0,0,t.width,t.height)),setTimeout(i,r)},r)},n.play()}})}function i(e,n){if(!t.workerPath&&!n)return void fetch("https://unpkg.com/webm-wasm@latest/dist/webm-worker.js").then(function(t){t.arrayBuffer().then(function(t){i(e,t)})});if(!t.workerPath&&n instanceof ArrayBuffer){var s=new Blob([n],{type:"text/javascript"});t.workerPath=D.createObjectURL(s)}t.workerPath||console.error("workerPath parameter is missing."),r=new Worker(t.workerPath),r.postMessage(t.webAssemblyPath||"https://unpkg.com/webm-wasm@latest/dist/webm-wasm.wasm"),r.addEventListener("message",function(e){"READY"===e.data?(r.postMessage({width:t.width,height:t.height,bitrate:t.bitrate||1200,timebaseDen:t.frameRate||30,realtime:!0}),o().pipeTo(new WritableStream({write:function(e){r&&r.postMessage(e.data.buffer,[e.data.buffer])}}))):e.data&&(a||d.push(e.data))})}function n(){r&&(r.postMessage(null),r.terminate(),r=null)}"undefined"!=typeof ReadableStream&&"undefined"!=typeof WritableStream||console.error("Following polyfill is strongly recommended: https://unpkg.com/@mattiasbuelens/web-streams-polyfill/dist/polyfill.min.js"),t=t||{},t.width=t.width||640,t.height=t.height||480,t.frameRate=t.frameRate||30,t.bitrate=t.bitrate||1200;var r;this.record=function(){d=[],a=!1,this.blob=null,i(e),"function"==typeof t.initCallback&&t.initCallback()};var a;this.pause=function(){a=!0},this.resume=function(){a=!1};var d=[];this.stop=function(e){n(),this.blob=new Blob(d,{type:"video/webm"}),e(this.blob)},this.name="WebAssemblyRecorder",this.toString=function(){return this.name},this.clearRecordedData=function(){d=[],a=!1,this.blob=null},this.blob=null}var C,k,C,k;n.version="5.5.9",e.exports=n,C=[],void 0!==(k=function(){return n}.apply(t,C))&&(e.exports=k),n.getFromDisk=function(e,t){if(!t)throw"callback is mandatory.";console.log("Getting recorded "+("all"===e?"blobs":e+" blob ")+" from disk!"),z.Fetch(function(o,i){"all"!==e&&i===e+"Blob"&&t&&t(o),"all"===e&&t&&t(o,i.replace("Blob",""))})},n.writeToDisk=function(e){console.log("Writing recorded blob(s) to disk!"),e=e||{},e.audio&&e.video&&e.gif?e.audio.getDataURL(function(t){e.video.getDataURL(function(o){e.gif.getDataURL(function(e){z.Store({audioBlob:t,videoBlob:o,gifBlob:e})})})}):e.audio&&e.video?e.audio.getDataURL(function(t){e.video.getDataURL(function(e){z.Store({audioBlob:t,videoBlob:e})})}):e.audio&&e.gif?e.audio.getDataURL(function(t){e.gif.getDataURL(function(e){z.Store({audioBlob:t,gifBlob:e})})}):e.video&&e.gif?e.video.getDataURL(function(t){e.gif.getDataURL(function(e){z.Store({videoBlob:t,gifBlob:e})})}):e.audio?e.audio.getDataURL(function(e){z.Store({audioBlob:e})}):e.video?e.video.getDataURL(function(e){z.Store({videoBlob:e})}):e.gif&&e.gif.getDataURL(function(e){z.Store({gifBlob:e})})},d.getFromDisk=n.getFromDisk,d.writeToDisk=n.writeToDisk,void 0!==n&&(n.MRecordRTC=d);!function(e){e&&"undefined"==typeof window&&void 0!==o&&(o.navigator={userAgent:"Fake/5.0 (FakeOS) AppleWebKit/123 (KHTML, like Gecko) Fake/12.3.4567.89 Fake/123.45",getUserMedia:function(){}},o.console||(o.console={}),void 0!==o.console.log&&void 0!==o.console.error||(o.console.error=o.console.log=o.console.log||function(){console.log(arguments)}),"undefined"==typeof document&&(e.document={documentElement:{appendChild:function(){return""}}},document.createElement=document.captureStream=document.mozCaptureStream=function(){var e={getContext:function(){return e},play:function(){},pause:function(){},drawImage:function(){},toDataURL:function(){return""},style:{}};return e},e.HTMLVideoElement=function(){}),"undefined"==typeof location&&(e.location={protocol:"file:",href:"",hash:""}),"undefined"==typeof screen&&(e.screen={width:0,height:0}),void 0===D&&(e.URL={createObjectURL:function(){return""},revokeObjectURL:function(){return""}}),e.window=o)}(void 0!==o?o:null);var L=window.requestAnimationFrame;if(void 0===L)if("undefined"!=typeof webkitRequestAnimationFrame)L=webkitRequestAnimationFrame;else if("undefined"!=typeof mozRequestAnimationFrame)L=mozRequestAnimationFrame;else if("undefined"!=typeof msRequestAnimationFrame)L=msRequestAnimationFrame;else if(void 0===L){var M=0;L=function(e,t){var o=(new Date).getTime(),i=Math.max(0,16-(o-M)),n=setTimeout(function(){e(o+i)},i);return M=o+i,n}}var A=window.cancelAnimationFrame;void 0===A&&("undefined"!=typeof webkitCancelAnimationFrame?A=webkitCancelAnimationFrame:"undefined"!=typeof mozCancelAnimationFrame?A=mozCancelAnimationFrame:"undefined"!=typeof msCancelAnimationFrame?A=msCancelAnimationFrame:void 0===A&&(A=function(e){clearTimeout(e)}));var x=window.AudioContext;void 0===x&&("undefined"!=typeof webkitAudioContext&&(x=webkitAudioContext),"undefined"!=typeof mozAudioContext&&(x=mozAudioContext));var D=window.URL;void 0===D&&"undefined"!=typeof webkitURL&&(D=webkitURL),"undefined"!=typeof navigator&&void 0===navigator.getUserMedia&&(void 0!==navigator.webkitGetUserMedia&&(navigator.getUserMedia=navigator.webkitGetUserMedia),void 0!==navigator.mozGetUserMedia&&(navigator.getUserMedia=navigator.mozGetUserMedia));var U=!(-1===navigator.userAgent.indexOf("Edge")||!navigator.msSaveBlob&&!navigator.msSaveOrOpenBlob),B=!!window.opera||-1!==navigator.userAgent.indexOf("OPR/"),E=navigator.userAgent.toLowerCase().indexOf("firefox")>-1&&"netscape"in window&&/ rv:/.test(navigator.userAgent),O=!B&&!U&&!!navigator.webkitGetUserMedia||u()||-1!==navigator.userAgent.toLowerCase().indexOf("chrome/"),I=/^((?!chrome|android).)*safari/i.test(navigator.userAgent);I&&!O&&-1!==navigator.userAgent.indexOf("CriOS")&&(I=!1,O=!0);var F=window.MediaStream;void 0===F&&"undefined"!=typeof webkitMediaStream&&(F=webkitMediaStream),void 0!==F&&void 0===F.prototype.stop&&(F.prototype.stop=function(){this.getTracks().forEach(function(e){e.stop()})}),void 0!==n&&(n.invokeSaveAsDialog=c,n.getTracks=l,n.getSeekableBlob=h,n.bytesToSize=s,n.isElectron=u);/**
   * Storage is a standalone object used by {@link RecordRTC} to store reusable objects e.g. "new AudioContext".
   * @license {@link https://github.com/muaz-khan/RecordRTC/blob/master/LICENSE|MIT}
   * @author {@link https://MuazKhan.com|Muaz Khan}
   * @example
   * Storage.AudioContext === webkitAudioContext
   * @property {webkitAudioContext} AudioContext - Keeps a reference to AudioContext object.
   * @see {@link https://github.com/muaz-khan/RecordRTC|RecordRTC Source Code}
   */
  var j={};void 0!==x?j.AudioContext=x:"undefined"!=typeof webkitAudioContext&&(j.AudioContext=webkitAudioContext),void 0!==n&&(n.Storage=j),void 0!==n&&(n.MediaStreamRecorder=g),void 0!==n&&(n.StereoAudioRecorder=p),void 0!==n&&(n.CanvasRecorder=v),void 0!==n&&(n.WhammyRecorder=b);/**
   * Whammy is a standalone class used by {@link RecordRTC} to bring video recording in Chrome. It is written by {@link https://github.com/antimatter15|antimatter15}
   * @summary A real time javascript webm encoder based on a canvas hack.
   * @license {@link https://github.com/muaz-khan/RecordRTC/blob/master/LICENSE|MIT}
   * @author {@link https://MuazKhan.com|Muaz Khan}
   * @typedef Whammy
   * @class
   * @example
   * var recorder = new Whammy().Video(15);
   * recorder.add(context || canvas || dataURL);
   * var output = recorder.compile();
   * @see {@link https://github.com/muaz-khan/RecordRTC|RecordRTC Source Code}
   */
  var P=function(){function e(e){this.frames=[],this.duration=e||1,this.quality=.8}function t(e){var t=D.createObjectURL(new Blob([e.toString(),"this.onmessage =  function (eee) {"+e.name+"(eee.data);}"],{type:"application/javascript"})),o=new Worker(t);return D.revokeObjectURL(t),o}function o(e){function t(e){var t=i(e);if(!t)return[];for(var n=[{id:440786851,data:[{data:1,id:17030},{data:1,id:17143},{data:4,id:17138},{data:8,id:17139},{data:"webm",id:17026},{data:2,id:17031},{data:2,id:17029}]},{id:408125543,data:[{id:357149030,data:[{data:1e6,id:2807729},{data:"whammy",id:19840},{data:"whammy",id:22337},{data:f(t.duration),id:17545}]},{id:374648427,data:[{id:174,data:[{data:1,id:215},{data:1,id:29637},{data:0,id:156},{data:"und",id:2274716},{data:"V_VP8",id:134},{data:"VP8",id:2459272},{data:1,id:131},{id:224,data:[{data:t.width,id:176},{data:t.height,id:186}]}]}]}]}],r=0,a=0;r<e.length;){var s=[],c=0;do{s.push(e[r]),c+=e[r].duration,r++}while(r<e.length&&c<3e4);var u={id:524531317,data:o(a,0,s)};n[1].data.push(u),a+=c}return d(n)}function o(e,t,o){return[{data:e,id:231}].concat(o.map(function(e){var o=s({discardable:0,frame:e.data.slice(4),invisible:0,keyframe:1,lacing:0,trackNum:1,timecode:Math.round(t)});return t+=e.duration,{data:o,id:163}}))}function i(e){if(!e[0])return void postMessage({error:"Something went wrong. Maybe WebP format is not supported in the current browser."});for(var t=e[0].width,o=e[0].height,i=e[0].duration,n=1;n<e.length;n++)i+=e[n].duration;return{duration:i,width:t,height:o}}function n(e){for(var t=[];e>0;)t.push(255&e),e>>=8;return new Uint8Array(t.reverse())}function r(e){return new Uint8Array(e.split("").map(function(e){return e.charCodeAt(0)}))}function a(e){var t=[];e=(e.length%8?new Array(9-e.length%8).join("0"):"")+e;for(var o=0;o<e.length;o+=8)t.push(parseInt(e.substr(o,8),2));return new Uint8Array(t)}function d(e){for(var t=[],o=0;o<e.length;o++){var i=e[o].data;"object"==typeof i&&(i=d(i)),"number"==typeof i&&(i=a(i.toString(2))),"string"==typeof i&&(i=r(i));var s=i.size||i.byteLength||i.length,c=Math.ceil(Math.ceil(Math.log(s)/Math.log(2))/8),u=s.toString(2),l=new Array(7*c+7+1-u.length).join("0")+u,f=new Array(c).join("0")+"1"+l;t.push(n(e[o].id)),t.push(a(f)),t.push(i)}return new Blob(t,{type:"video/webm"})}function s(e){var t=0;if(e.keyframe&&(t|=128),e.invisible&&(t|=8),e.lacing&&(t|=e.lacing<<1),e.discardable&&(t|=1),e.trackNum>127)throw"TrackNumber > 127 not supported";return[128|e.trackNum,e.timecode>>8,255&e.timecode,t].map(function(e){return String.fromCharCode(e)}).join("")+e.frame}function c(e){for(var t=e.RIFF[0].WEBP[0],o=t.indexOf("*"),i=0,n=[];i<4;i++)n[i]=t.charCodeAt(o+3+i);var r,a,d;return d=n[1]<<8|n[0],r=16383&d,d=n[3]<<8|n[2],a=16383&d,{width:r,height:a,data:t,riff:e}}function u(e,t){return parseInt(e.substr(t+4,4).split("").map(function(e){var t=e.charCodeAt(0).toString(2);return new Array(8-t.length+1).join("0")+t}).join(""),2)}function l(e){for(var t=0,o={};t<e.length;){var i=e.substr(t,4),n=u(e,t),r=e.substr(t+4+4,n);t+=8+n,o[i]=o[i]||[],"RIFF"===i||"LIST"===i?o[i].push(l(r)):o[i].push(r)}return o}function f(e){return[].slice.call(new Uint8Array(new Float64Array([e]).buffer),0).map(function(e){return String.fromCharCode(e)}).reverse().join("")}var h=new t(e.map(function(e){var t=c(l(atob(e.image.slice(23))));return t.duration=e.duration,t}));postMessage(h)}return e.prototype.add=function(e,t){if("canvas"in e&&(e=e.canvas),"toDataURL"in e&&(e=e.toDataURL("image/webp",this.quality)),!/^data:image\/webp;base64,/gi.test(e))throw"Input must be formatted properly as a base64 encoded DataURI of type image/webp";this.frames.push({image:e,duration:t||this.duration})},e.prototype.compile=function(e){var i=t(o);i.onmessage=function(t){if(t.data.error)return void console.error(t.data.error);e(t.data)},i.postMessage(this.frames)},{Video:e}}();void 0!==n&&(n.Whammy=P);/**
   * DiskStorage is a standalone object used by {@link RecordRTC} to store recorded blobs in IndexedDB storage.
   * @summary Writing blobs into IndexedDB.
   * @license {@link https://github.com/muaz-khan/RecordRTC/blob/master/LICENSE|MIT}
   * @author {@link https://MuazKhan.com|Muaz Khan}
   * @example
   * DiskStorage.Store({
   *     audioBlob: yourAudioBlob,
   *     videoBlob: yourVideoBlob,
   *     gifBlob  : yourGifBlob
   * });
   * DiskStorage.Fetch(function(dataURL, type) {
   *     if(type === 'audioBlob') { }
   *     if(type === 'videoBlob') { }
   *     if(type === 'gifBlob')   { }
   * });
   * // DiskStorage.dataStoreName = 'recordRTC';
   * // DiskStorage.onError = function(error) { };
   * @property {function} init - This method must be called once to initialize IndexedDB ObjectStore. Though, it is auto-used internally.
   * @property {function} Fetch - This method fetches stored blobs from IndexedDB.
   * @property {function} Store - This method stores blobs in IndexedDB.
   * @property {function} onError - This function is invoked for any known/unknown error.
   * @property {string} dataStoreName - Name of the ObjectStore created in IndexedDB storage.
   * @see {@link https://github.com/muaz-khan/RecordRTC|RecordRTC Source Code}
   */
  var z={init:function(){function e(e){e.createObjectStore(o.dataStoreName)}function t(){function e(e){t.objectStore(o.dataStoreName).get(e).onsuccess=function(t){o.callback&&o.callback(t.target.result,e)}}var t=i.transaction([o.dataStoreName],"readwrite");o.videoBlob&&t.objectStore(o.dataStoreName).put(o.videoBlob,"videoBlob"),o.gifBlob&&t.objectStore(o.dataStoreName).put(o.gifBlob,"gifBlob"),o.audioBlob&&t.objectStore(o.dataStoreName).put(o.audioBlob,"audioBlob"),e("audioBlob"),e("videoBlob"),e("gifBlob")}var o=this;if("undefined"==typeof indexedDB||void 0===indexedDB.open)return void console.error("IndexedDB API are not available in this browser.");var i,n=this.dbName||location.href.replace(/\/|:|#|%|\.|\[|\]/g,""),r=indexedDB.open(n,1);r.onerror=o.onError,r.onsuccess=function(){if(i=r.result,i.onerror=o.onError,i.setVersion)if(1!==i.version){var n=i.setVersion(1);n.onsuccess=function(){e(i),t()}}else t();else t()},r.onupgradeneeded=function(t){e(t.target.result)}},Fetch:function(e){return this.callback=e,this.init(),this},Store:function(e){return this.audioBlob=e.audioBlob,this.videoBlob=e.videoBlob,this.gifBlob=e.gifBlob,this.init(),this},onError:function(e){console.error(JSON.stringify(e,null,"\t"))},dataStoreName:"recordRTC",dbName:null};void 0!==n&&(n.DiskStorage=z),void 0!==n&&(n.GifRecorder=w),void 0===n&&(e.exports=y,C=[],void 0!==(k=function(){return y}.apply(t,C))&&(e.exports=k)),void 0!==n&&(n.MultiStreamRecorder=R),void 0!==n&&(n.RecordRTCPromisesHandler=S),void 0!==n&&(n.WebAssemblyRecorder=T)}).call(t,o(18),o(19))},18:function(e,t){var o;o=function(){return this}();try{o=o||Function("return this")()||(0,eval)("this")}catch(e){"object"==typeof window&&(o=window)}e.exports=o},19:function(e,t){function o(){throw new Error("setTimeout has not been defined")}function i(){throw new Error("clearTimeout has not been defined")}function n(e){if(u===setTimeout)return setTimeout(e,0);if((u===o||!u)&&setTimeout)return u=setTimeout,setTimeout(e,0);try{return u(e,0)}catch(t){try{return u.call(null,e,0)}catch(t){return u.call(this,e,0)}}}function r(e){if(l===clearTimeout)return clearTimeout(e);if((l===i||!l)&&clearTimeout)return l=clearTimeout,clearTimeout(e);try{return l(e)}catch(t){try{return l.call(null,e)}catch(t){return l.call(this,e)}}}function a(){g&&h&&(g=!1,h.length?m=h.concat(m):p=-1,m.length&&d())}function d(){if(!g){var e=n(a);g=!0;for(var t=m.length;t;){for(h=m,m=[];++p<t;)h&&h[p].run();p=-1,t=m.length}h=null,g=!1,r(e)}}function s(e,t){this.fun=e,this.array=t}function c(){}var u,l,f=e.exports={};!function(){try{u="function"==typeof setTimeout?setTimeout:o}catch(e){u=o}try{l="function"==typeof clearTimeout?clearTimeout:i}catch(e){l=i}}();var h,m=[],g=!1,p=-1;f.nextTick=function(e){var t=new Array(arguments.length-1);if(arguments.length>1)for(var o=1;o<arguments.length;o++)t[o-1]=arguments[o];m.push(new s(e,t)),1!==m.length||g||n(d)},s.prototype.run=function(){this.fun.apply(null,this.array)},f.title="browser",f.browser=!0,f.env={},f.argv=[],f.version="",f.versions={},f.on=c,f.addListener=c,f.once=c,f.off=c,f.removeListener=c,f.removeAllListeners=c,f.emit=c,f.prependListener=c,f.prependOnceListener=c,f.listeners=function(e){return[]},f.binding=function(e){throw new Error("process.binding is not supported")},f.cwd=function(){return"/"},f.chdir=function(e){throw new Error("process.chdir is not supported")},f.umask=function(){return 0}}})});
  //# sourceMappingURL=microphone.min.js.map