HEX
Server: Apache
System: Linux p3plzcpnl506847.prod.phx3.secureserver.net 4.18.0-553.54.1.lve.el8.x86_64 #1 SMP Wed Jun 4 13:01:13 UTC 2025 x86_64
User: slfopp7cb1df (5698090)
PHP: 8.1.34
Disabled: NONE
Upload Files
File: /home/slfopp7cb1df/public_html/sitepacket.com/system/assets/js/recordrtc/RecordRTC.min.js
"use strict";function RecordRTC(o,r){if(!o)throw"First parameter is required.";r=new RecordRTCConfiguration(o,r=r||{type:"video"});var n=this;function t(e){e&&(r.initCallback=function(){e(),e=r.initCallback=null});var t=new GetRecorderType(o,r);(u=new t(o,r)).record(),c("recording"),r.disableLogs}function a(i){if(i=i||function(){},u){if("paused"===n.state)return n.resumeRecording(),void setTimeout(function(){a(i)},1);"recording"===n.state||r.disableLogs||console.warn('Recording state should be: "recording", however current state is: ',n.state),r.disableLogs,"gif"!==r.type?u.stop(e):(u.stop(),e()),c("stopped")}else l();function e(e){if(u){Object.keys(u).forEach(function(e){"function"!=typeof u[e]&&(n[e]=u[e])});var t,o=u.blob;if(!o){if(!e)throw"Recording failed.";u.blob=o=e}if(o&&r.disableLogs,i){try{t=URL.createObjectURL(o)}catch(e){}"function"==typeof i.call?i.call(n,t):i(t)}r.autoWriteToDisk&&s(function(e){var t={};t[r.type+"Blob"]=e,DiskStorage.Store(t)})}else"function"==typeof i.call?i.call(n,""):i("")}}function d(e){postMessage((new FileReaderSync).readAsDataURL(e))}function s(t,e){if(!t)throw"Pass a callback function over getDataURL.";var o,i=(e||u||{}).blob;if(!i)return r.disableLogs||console.warn("Blob encoder did not finish its job yet."),void setTimeout(function(){s(t,e)},1e3);"undefined"==typeof Worker||navigator.mozGetUserMedia?((o=new FileReader).readAsDataURL(i),o.onload=function(e){t(e.target.result)}):((o=function(e){try{var t=URL.createObjectURL(new Blob([e.toString(),"this.onmessage =  function (eee) {"+e.name+"(eee.data);}"],{type:"application/javascript"})),o=new Worker(t);return URL.revokeObjectURL(t),o}catch(e){}}(d)).onmessage=function(e){t(e.data)},o.postMessage(i))}function i(e){e=e||0,"paused"!==n.state?"stopped"!==n.state&&(e>=n.recordingDuration?a(n.onRecordingStopped):(e+=1e3,setTimeout(function(){i(e)},1e3))):setTimeout(function(){i(e)},1e3)}function c(e){n&&(n.state=e,"function"==typeof n.onStateChanged.call?n.onStateChanged.call(n,e):n.onStateChanged(e))}var u,e='It seems that recorder is destroyed or "startRecording" is not invoked for '+r.type+" recorder.";function l(){!0!==r.disableLogs&&console.warn(e)}var f,m={startRecording:function(e){return r.disableLogs,e&&(r=new RecordRTCConfiguration(o,e)),r.disableLogs,u?(u.clearRecordedData(),u.record(),c("recording"),n.recordingDuration&&i()):t(function(){n.recordingDuration&&i()}),n},stopRecording:a,pauseRecording:function(){u?"recording"===n.state?(c("paused"),u.pause(),r.disableLogs):r.disableLogs||console.warn("Unable to pause the recording. Recording state: ",n.state):l()},resumeRecording:function(){u?("paused"===n.state&&(c("recording"),u.resume()),r.disableLogs):l()},initRecorder:t,setRecordingDuration:function(e,t){if(void 0===e)throw"recordingDuration is required.";if("number"!=typeof e)throw"recordingDuration must be a number.";return n.recordingDuration=e,n.onRecordingStopped=t||function(){},{onRecordingStopped:function(e){n.onRecordingStopped=e}}},clearRecordedData:function(){u?(u.clearRecordedData(),r.disableLogs):l()},getBlob:function(){if(u)return u.blob;l()},getDataURL:s,toURL:function(){if(u)return URL.createObjectURL(u.blob);l()},getInternalRecorder:function(){return u},save:function(e){u?invokeSaveAsDialog(u.blob,e):l()},getFromDisk:function(e){u?RecordRTC.getFromDisk(r.type,e):l()},setAdvertisementArray:function(e){r.advertisement=[];for(var t=e.length,o=0;o<t;o++)r.advertisement.push({duration:o,image:e[o]})},blob:null,bufferSize:0,sampleRate:0,buffer:null,reset:function(){"recording"!==n.state||r.disableLogs||console.warn("Stop an active recorder."),u&&"function"==typeof u.clearRecordedData&&u.clearRecordedData(),u=null,c("inactive"),n.blob=null},onStateChanged:function(e){r.disableLogs},state:"inactive",getState:function(){return n.state},destroy:function(){var e=r.disableLogs;r={disableLogs:!0},n.reset(),c("destroyed"),m=n=null,Storage.AudioContextConstructor&&(Storage.AudioContextConstructor.close(),Storage.AudioContextConstructor=null),r.disableLogs=e,r.disableLogs},version:"5.6.2"};if(!this)return n=m;for(f in m)this[f]=m[f];return n=this,m}function RecordRTCConfiguration(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===WhammyRecorder||t.recorderType===CanvasRecorder||void 0!==WebAssemblyRecorder&&t.recorderType===WebAssemblyRecorder?t.type="video":t.recorderType===GifRecorder?t.type="gif":t.recorderType===StereoAudioRecorder?t.type="audio":t.recorderType===MediaStreamRecorder&&(getTracks(e,"audio").length&&getTracks(e,"video").length||!getTracks(e,"audio").length&&getTracks(e,"video").length?t.type="video":getTracks(e,"audio").length&&!getTracks(e,"video").length&&(t.type="audio"))),void 0!==MediaStreamRecorder&&"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}function GetRecorderType(e,t){var o;return(isChrome||isEdge||isOpera)&&(o=StereoAudioRecorder),"undefined"!=typeof MediaRecorder&&"requestData"in MediaRecorder.prototype&&!isChrome&&(o=MediaStreamRecorder),"video"===t.type&&(isChrome||isOpera)&&(o=WhammyRecorder,void 0!==WebAssemblyRecorder&&"undefined"!=typeof ReadableStream&&(o=WebAssemblyRecorder)),"gif"===t.type&&(o=GifRecorder),"canvas"===t.type&&(o=CanvasRecorder),isMediaRecorderCompatible()&&o!==CanvasRecorder&&o!==GifRecorder&&"undefined"!=typeof MediaRecorder&&"requestData"in MediaRecorder.prototype&&(getTracks(e,"video").length||getTracks(e,"audio").length)&&("audio"===t.type?"function"==typeof MediaRecorder.isTypeSupported&&MediaRecorder.isTypeSupported("audio/webm")&&(o=MediaStreamRecorder):"function"==typeof MediaRecorder.isTypeSupported&&MediaRecorder.isTypeSupported("video/webm")&&(o=MediaStreamRecorder)),e instanceof Array&&e.length&&(o=MultiStreamRecorder),t.recorderType&&(o=t.recorderType),!t.disableLogs&&o&&o.name,!o&&isSafari&&(o=MediaStreamRecorder),o}function MRecordRTC(a){this.addStream=function(e){e&&(a=e)},this.mediaType={audio:!0,video:!0},this.startRecording=function(){var e,t,o,i,r=this.mediaType,n=this.mimeType||{audio:null,video:null,gif:null};if("function"!=typeof r.audio&&isMediaRecorderCompatible()&&!getTracks(a,"audio").length&&(r.audio=!1),"function"!=typeof r.video&&isMediaRecorderCompatible()&&!getTracks(a,"video").length&&(r.video=!1),"function"!=typeof r.gif&&isMediaRecorderCompatible()&&!getTracks(a,"video").length&&(r.gif=!1),!r.audio&&!r.video&&!r.gif)throw"MediaStream must have either audio or video tracks.";r.audio&&(e=null,"function"==typeof r.audio&&(e=r.audio),this.audioRecorder=new RecordRTC(a,{type:"audio",bufferSize:this.bufferSize,sampleRate:this.sampleRate,numberOfAudioChannels:this.numberOfAudioChannels||2,disableLogs:this.disableLogs,recorderType:e,mimeType:n.audio,timeSlice:this.timeSlice,onTimeStamp:this.onTimeStamp}),r.video||this.audioRecorder.startRecording()),r.video&&(e=null,"function"==typeof r.video&&(e=r.video),i=a,isMediaRecorderCompatible()&&r.audio&&"function"==typeof r.audio&&(t=getTracks(a,"video")[0],isFirefox?((i=new MediaStream).addTrack(t),e&&e===WhammyRecorder&&(e=MediaStreamRecorder)):(i=new MediaStream).addTrack(t)),this.videoRecorder=new RecordRTC(i,{type:"video",video:this.video,canvas:this.canvas,frameInterval:this.frameInterval||10,disableLogs:this.disableLogs,recorderType:e,mimeType:n.video,timeSlice:this.timeSlice,onTimeStamp:this.onTimeStamp,workerPath:this.workerPath,webAssemblyPath:this.webAssemblyPath,frameRate:this.frameRate,bitrate:this.bitrate}),r.audio||this.videoRecorder.startRecording()),r.audio&&r.video&&(o=this,i=!0===isMediaRecorderCompatible(),(r.audio instanceof StereoAudioRecorder&&r.video||!0!==r.audio&&!0!==r.video&&r.audio!==r.video)&&(i=!1),!0===i?(o.audioRecorder=null,o.videoRecorder.startRecording()):o.videoRecorder.initRecorder(function(){o.audioRecorder.initRecorder(function(){o.videoRecorder.startRecording(),o.audioRecorder.startRecording()})})),r.gif&&(e=null,"function"==typeof r.gif&&(e=r.gif),this.gifRecorder=new RecordRTC(a,{type:"gif",frameRate:this.frameRate||200,quality:this.quality||10,disableLogs:this.disableLogs,recorderType:e,mimeType:n.gif}),this.gifRecorder.startRecording())},this.stopRecording=function(t){t=t||function(){},this.audioRecorder&&this.audioRecorder.stopRecording(function(e){t(e,"audio")}),this.videoRecorder&&this.videoRecorder.stopRecording(function(e){t(e,"video")}),this.gifRecorder&&this.gifRecorder.stopRecording(function(e){t(e,"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(o){function i(e,t){var o;"undefined"!=typeof Worker?((o=function(e){var t,o=URL.createObjectURL(new Blob([e.toString(),"this.onmessage =  function (eee) {"+e.name+"(eee.data);}"],{type:"application/javascript"})),e=new Worker(o);if(void 0!==URL)t=URL;else{if("undefined"==typeof webkitURL)throw"Neither URL nor webkitURL detected.";t=webkitURL}return t.revokeObjectURL(o),e}(function(e){postMessage((new FileReaderSync).readAsDataURL(e))})).onmessage=function(e){t(e.data)},o.postMessage(e)):((o=new FileReader).readAsDataURL(e),o.onload=function(e){t(e.target.result)})}this.getBlob(function(e){e.audio&&e.video?i(e.audio,function(t){i(e.video,function(e){o({audio:t,video:e})})}):e.audio?i(e.audio,function(e){o({audio:e})}):e.video&&i(e.video,function(e){o({video:e})})})},this.writeToDisk=function(){RecordRTC.writeToDisk({audio:this.audioRecorder,video:this.videoRecorder,gif:this.gifRecorder})},this.save=function(e){(e=e||{audio:!0,video:!0,gif:!0}).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:"")}}RecordRTC.version="5.6.2","undefined"!=typeof module&&(module.exports=RecordRTC),"function"==typeof define&&define.amd&&define("RecordRTC",[],function(){return RecordRTC}),RecordRTC.getFromDisk=function(o,i){if(!i)throw"callback is mandatory.";DiskStorage.Fetch(function(e,t){"all"!==o&&t===o+"Blob"&&i&&i(e),"all"===o&&i&&i(e,t.replace("Blob",""))})},RecordRTC.writeToDisk=function(e){(e=e||{}).audio&&e.video&&e.gif?e.audio.getDataURL(function(o){e.video.getDataURL(function(t){e.gif.getDataURL(function(e){DiskStorage.Store({audioBlob:o,videoBlob:t,gifBlob:e})})})}):e.audio&&e.video?e.audio.getDataURL(function(t){e.video.getDataURL(function(e){DiskStorage.Store({audioBlob:t,videoBlob:e})})}):e.audio&&e.gif?e.audio.getDataURL(function(t){e.gif.getDataURL(function(e){DiskStorage.Store({audioBlob:t,gifBlob:e})})}):e.video&&e.gif?e.video.getDataURL(function(t){e.gif.getDataURL(function(e){DiskStorage.Store({videoBlob:t,gifBlob:e})})}):e.audio?e.audio.getDataURL(function(e){DiskStorage.Store({audioBlob:e})}):e.video?e.video.getDataURL(function(e){DiskStorage.Store({videoBlob:e})}):e.gif&&e.gif.getDataURL(function(e){DiskStorage.Store({gifBlob:e})})},MRecordRTC.getFromDisk=RecordRTC.getFromDisk,MRecordRTC.writeToDisk=RecordRTC.writeToDisk,void 0!==RecordRTC&&(RecordRTC.MRecordRTC=MRecordRTC);var browserFakeUserAgent="Fake/5.0 (FakeOS) AppleWebKit/123 (KHTML, like Gecko) Fake/12.3.4567.89 Fake/123.45";!function(e){e&&"undefined"==typeof window&&"undefined"!=typeof global&&(global.navigator={userAgent:browserFakeUserAgent,getUserMedia:function(){}},global.console||(global.console={}),void 0!==global.console.log&&void 0!==global.console.error||(global.console.error=global.console.log=global.console.log||function(){}),"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===URL&&(e.URL={createObjectURL:function(){return""},revokeObjectURL:function(){return""}}),e.window=global)}("undefined"!=typeof global?global:null);var lastTime,requestAnimationFrame=window.requestAnimationFrame;void 0===requestAnimationFrame&&("undefined"!=typeof webkitRequestAnimationFrame?requestAnimationFrame=webkitRequestAnimationFrame:"undefined"!=typeof mozRequestAnimationFrame?requestAnimationFrame=mozRequestAnimationFrame:"undefined"!=typeof msRequestAnimationFrame?requestAnimationFrame=msRequestAnimationFrame:void 0===requestAnimationFrame&&(lastTime=0,requestAnimationFrame=function(e,t){var o=(new Date).getTime(),i=Math.max(0,16-(o-lastTime)),r=setTimeout(function(){e(o+i)},i);return lastTime=o+i,r}));var cancelAnimationFrame=window.cancelAnimationFrame;void 0===cancelAnimationFrame&&("undefined"!=typeof webkitCancelAnimationFrame?cancelAnimationFrame=webkitCancelAnimationFrame:"undefined"!=typeof mozCancelAnimationFrame?cancelAnimationFrame=mozCancelAnimationFrame:"undefined"!=typeof msCancelAnimationFrame?cancelAnimationFrame=msCancelAnimationFrame:void 0===cancelAnimationFrame&&(cancelAnimationFrame=function(e){clearTimeout(e)}));var AudioContext=window.AudioContext;void 0===AudioContext&&("undefined"!=typeof webkitAudioContext&&(AudioContext=webkitAudioContext),"undefined"!=typeof mozAudioContext&&(AudioContext=mozAudioContext));var URL=window.URL;void 0===URL&&"undefined"!=typeof webkitURL&&(URL=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 isEdge=!(-1===navigator.userAgent.indexOf("Edge")||!navigator.msSaveBlob&&!navigator.msSaveOrOpenBlob),isOpera=!!window.opera||-1!==navigator.userAgent.indexOf("OPR/"),isFirefox=-1<navigator.userAgent.toLowerCase().indexOf("firefox")&&"netscape"in window&&/ rv:/.test(navigator.userAgent),isChrome=!isOpera&&!isEdge&&!!navigator.webkitGetUserMedia||isElectron()||-1!==navigator.userAgent.toLowerCase().indexOf("chrome/"),isSafari=/^((?!chrome|android).)*safari/i.test(navigator.userAgent);isSafari&&!isChrome&&-1!==navigator.userAgent.indexOf("CriOS")&&(isChrome=!(isSafari=!1));var MediaStream=window.MediaStream;function bytesToSize(e){if(0===e)return"0 Bytes";var t=parseInt(Math.floor(Math.log(e)/Math.log(1e3)),10);return(e/Math.pow(1e3,t)).toPrecision(3)+" "+["Bytes","KB","MB","GB","TB"][t]}function invokeSaveAsDialog(e,t){if(!e)throw"Blob object is required.";if(!e.type)try{e.type="video/webm"}catch(e){}var o,i=(e.type||"video/webm").split("/")[1];-1!==i.indexOf(";")&&(i=i.split(";")[0]),t&&-1!==t.indexOf(".")&&(t=(o=t.split("."))[0],i=o[1]);t=(t||Math.round(9999999999*Math.random())+888888888)+"."+i;if(void 0!==navigator.msSaveOrOpenBlob)return navigator.msSaveOrOpenBlob(e,t);if(void 0!==navigator.msSaveBlob)return navigator.msSaveBlob(e,t);i=document.createElement("a");i.href=URL.createObjectURL(e),i.download=t,i.style="display:none;opacity:0;color:transparent;",(document.body||document.documentElement).appendChild(i),"function"==typeof i.click?i.click():(i.target="_blank",i.dispatchEvent(new MouseEvent("click",{view:window,bubbles:!0,cancelable:!0}))),URL.revokeObjectURL(i.href)}function isElectron(){return"undefined"!=typeof window&&"object"==typeof window.process&&"renderer"===window.process.type||(!("undefined"==typeof process||"object"!=typeof process.versions||!process.versions.electron)||"object"==typeof navigator&&"string"==typeof navigator.userAgent&&0<=navigator.userAgent.indexOf("Electron"))}function getTracks(e,t){return e&&e.getTracks?e.getTracks().filter(function(e){return e.kind===(t||"audio")}):[]}function setSrcObject(e,t){!("srcObject"in t)&&"mozSrcObject"in t?t.mozSrcObject=e:t.srcObject=e}function getSeekableBlob(e,i){if("undefined"==typeof EBML)throw new Error("Please link: https://www.webrtc-experiment.com/EBML.js");var r=new EBML.Reader,n=new EBML.Decoder,a=EBML.tools,t=new FileReader;t.onload=function(e){n.decode(this.result).forEach(function(e){r.read(e)}),r.stop();var t=a.makeMetadataSeekable(r.metadatas,r.duration,r.cues),o=this.result.slice(r.metadataSize),o=new Blob([t,o],{type:"video/webm"});i(o)},t.readAsArrayBuffer(e)}void 0===MediaStream&&"undefined"!=typeof webkitMediaStream&&(MediaStream=webkitMediaStream),void 0!==MediaStream&&void 0===MediaStream.prototype.stop&&(MediaStream.prototype.stop=function(){this.getTracks().forEach(function(e){e.stop()})}),void 0!==RecordRTC&&(RecordRTC.invokeSaveAsDialog=invokeSaveAsDialog,RecordRTC.getTracks=getTracks,RecordRTC.getSeekableBlob=getSeekableBlob,RecordRTC.bytesToSize=bytesToSize,RecordRTC.isElectron=isElectron);var Storage={};function isMediaRecorderCompatible(){if(isFirefox||isSafari||isEdge)return!0;navigator.appVersion;var e,t=navigator.userAgent,o=""+parseFloat(navigator.appVersion),i=parseInt(navigator.appVersion,10);return(isChrome||isOpera)&&(e=t.indexOf("Chrome"),o=t.substring(e+7)),-1!==(e=o.indexOf(";"))&&(o=o.substring(0,e)),-1!==(e=o.indexOf(" "))&&(o=o.substring(0,e)),i=parseInt(""+o,10),isNaN(i)&&(o=""+parseFloat(navigator.appVersion),i=parseInt(navigator.appVersion,10)),49<=i}function MediaStreamRecorder(o,i){var e,r=this;if(void 0===o)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.";"audio"===(i=i||{mimeType:"video/webm"}).type&&(getTracks(o,"video").length&&getTracks(o,"audio").length&&(navigator.mozGetUserMedia?(e=new MediaStream).addTrack(getTracks(o,"audio")[0]):e=new MediaStream(getTracks(o,"audio")),o=e),i.mimeType&&-1!==i.mimeType.toString().toLowerCase().indexOf("audio")||(i.mimeType=isChrome?"audio/webm":"audio/ogg"),i.mimeType&&"audio/ogg"!==i.mimeType.toString().toLowerCase()&&navigator.mozGetUserMedia&&(i.mimeType="audio/ogg"));var n,a=[];function d(){r.timestamps.push((new Date).getTime()),"function"==typeof i.onTimeStamp&&i.onTimeStamp(r.timestamps[r.timestamps.length-1],r.timestamps)}function s(e){return n&&n.mimeType?n.mimeType:e.mimeType||"video/webm"}function t(){a=[],n=null,r.timestamps=[]}this.getArrayOfBlobs=function(){return a},this.record=function(){r.blob=null,r.clearRecordedData(),r.timestamps=[],c=[],a=[];var t=i;i.disableLogs,n=n&&null,isChrome&&!isMediaRecorderCompatible()&&(t="video/vp8"),"function"==typeof MediaRecorder.isTypeSupported&&t.mimeType&&(MediaRecorder.isTypeSupported(t.mimeType)||(i.disableLogs||console.warn("MediaRecorder API seems unable to record mimeType:",t.mimeType),t.mimeType="audio"===i.type?"audio/webm":"video/webm"));try{n=new MediaRecorder(o,t),i.mimeType=t.mimeType}catch(e){n=new MediaRecorder(o)}t.mimeType&&!MediaRecorder.isTypeSupported&&"canRecordMimeType"in n&&!1===n.canRecordMimeType(t.mimeType)&&(i.disableLogs||console.warn("MediaRecorder API seems unable to record mimeType:",t.mimeType)),n.ondataavailable=function(e){e.data&&c.push("ondataavailable: "+bytesToSize(e.data.size)),"number"!=typeof i.timeSlice?!e.data||!e.data.size||e.data.size<100||r.blob?r.recordingCallback&&(r.recordingCallback(new Blob([],{type:s(t)})),r.recordingCallback=null):(r.blob=i.getNativeBlob?e.data:new Blob([e.data],{type:s(t)}),r.recordingCallback&&(r.recordingCallback(r.blob),r.recordingCallback=null)):e.data&&e.data.size&&(a.push(e.data),d(),"function"==typeof i.ondataavailable&&(e=i.getNativeBlob?e.data:new Blob([e.data],{type:s(t)}),i.ondataavailable(e)))},n.onstart=function(){c.push("started")},n.onpause=function(){c.push("paused")},n.onresume=function(){c.push("resumed")},n.onstop=function(){c.push("stopped")},n.onerror=function(e){e&&(e.name||(e.name="UnknownError"),c.push("error: "+e),i.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 (",t.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)),!r.manuallyStopped&&n&&"inactive"===n.state?(delete i.timeslice,n.start(6e5)):setTimeout(void 0,1e3),"inactive"!==n.state&&"stopped"!==n.state&&n.stop())},"number"==typeof i.timeSlice?(d(),n.start(i.timeSlice)):n.start(864e5),i.initCallback&&i.initCallback()},this.timestamps=[],this.stop=function(e){e=e||function(){},r.manuallyStopped=!0,n&&(this.recordingCallback=e,"recording"===n.state&&n.stop(),"number"==typeof i.timeSlice&&setTimeout(function(){r.blob=new Blob(a,{type:s(i)}),r.recordingCallback(r.blob)},100))},this.pause=function(){n&&"recording"===n.state&&n.pause()},this.resume=function(){n&&"paused"===n.state&&n.resume()},this.clearRecordedData=function(){n&&"recording"===n.state&&r.stop(t),t()},this.getInternalRecorder=function(){return n},this.blob=null,this.getState=function(){return n&&n.state||"inactive"};var c=[];this.getAllStates=function(){return c},void 0===i.checkForInactiveTracks&&(i.checkForInactiveTracks=!1);r=this;!function e(){if(n&&!1!==i.checkForInactiveTracks)return!1===function(){if("active"in o){if(!o.active)return!1}else if("ended"in o&&o.ended)return!1;return!0}()?(i.disableLogs,void r.stop()):void setTimeout(e,1e3)}(),this.name="MediaStreamRecorder",this.toString=function(){return this.name}}function StereoAudioRecorder(e,i){if(!getTracks(e,"audio").length)throw"Your stream has no audio tracks.";var r,n=this,a=[],d=[],s=!1,c=0,u=2,l=(i=i||{}).desiredSampRate;function f(){if(!1===i.checkForInactiveTracks)return!0;if("active"in e){if(!e.active)return!1}else if("ended"in e&&e.ended)return!1;return!0}function t(e,t){function o(e,t){var o,i=e.numberOfAudioChannels,r=e.leftBuffers.slice(0),n=e.rightBuffers.slice(0),a=e.sampleRate,d=e.internalInterleavedLength,e=e.desiredSampRate;function s(e,t,o){var i=Math.round(e.length*(t/o)),r=[],n=Number((e.length-1)/(i-1));r[0]=e[0];for(var a=1;a<i-1;a++){var d=a*n,s=Number(Math.floor(d)).toFixed(),c=Number(Math.ceil(d)).toFixed(),d=d-s;r[a]=(s=e[s],c=e[c],s+(c-s)*d)}return r[i-1]=e[e.length-1],r}function c(e,t){for(var o=new Float64Array(t),i=0,r=e.length,n=0;n<r;n++){var a=e[n];o.set(a,i),i+=a.length}return o}function u(e,t,o){for(var i=o.length,r=0;r<i;r++)e.setUint8(t+r,o.charCodeAt(r))}2===i&&(r=c(r,d),n=c(n,d),e&&(r=s(r,e,a),n=s(n,e,a))),1===i&&(r=c(r,d),e&&(r=s(r,e,a))),e&&(a=e),2===i&&(o=function(e,t){for(var o=e.length+t.length,i=new Float64Array(o),r=0,n=0;n<o;)i[n++]=e[r],i[n++]=t[r],r++;return i}(r,n)),1===i&&(o=r);var n=o.length,r=new ArrayBuffer(44+2*n),l=new DataView(r);u(l,0,"RIFF"),l.setUint32(4,36+2*n,!0),u(l,8,"WAVE"),u(l,12,"fmt "),l.setUint32(16,16,!0),l.setUint16(20,1,!0),l.setUint16(22,i,!0),l.setUint32(24,a,!0),l.setUint32(28,a*i*2,!0),l.setUint16(32,2*i,!0),l.setUint16(34,16,!0),u(l,36,"data"),l.setUint32(40,2*n,!0);for(var f=n,m=44,h=0;h<f;h++)l.setInt16(m,32767*o[h],!0),m+=2;if(t)return t({buffer:r,view:l});postMessage({buffer:r,view:l})}var i,r,n;e.noWorker?o(e,function(e){t(e.buffer,e.view)}):((i=(r=o,n=URL.createObjectURL(new Blob([r.toString(),";this.onmessage =  function (eee) {"+r.name+"(eee.data);}"],{type:"application/javascript"})),(r=new Worker(n)).workerURL=n,r)).onmessage=function(e){t(e.data.buffer,e.data.view),URL.revokeObjectURL(i.workerURL),i.terminate()},i.postMessage(e))}!0===i.leftChannel&&(u=1),1===i.numberOfAudioChannels&&(u=1),(!u||u<1)&&(u=2),i.disableLogs,void 0===i.checkForInactiveTracks&&(i.checkForInactiveTracks=!0),this.record=function(){if(!1===f())throw"Please make sure MediaStream is active.";v(),R=p=!1,s=!0,void 0!==i.timeSlice&&y()},this.stop=function(o){o=o||function(){},s=!1,t({desiredSampRate:l,sampleRate:g,numberOfAudioChannels:u,internalInterleavedLength:c,leftBuffers:a,rightBuffers:1===u?[]:d,noWorker:i.noWorker},function(e,t){n.blob=new Blob([t],{type:"audio/wav"}),n.buffer=new ArrayBuffer(t.buffer.byteLength),n.view=t,n.sampleRate=l||g,n.bufferSize=h,n.length=c,R=!1,o&&o(n.blob)})},void 0===RecordRTC.Storage&&(RecordRTC.Storage={AudioContextConstructor:null,AudioContext:window.AudioContext||window.webkitAudioContext}),RecordRTC.Storage.AudioContextConstructor&&"closed"!==RecordRTC.Storage.AudioContextConstructor.state||(RecordRTC.Storage.AudioContextConstructor=new RecordRTC.Storage.AudioContext);var o=RecordRTC.Storage.AudioContextConstructor,m=o.createMediaStreamSource(e),h=void 0===i.bufferSize?4096:i.bufferSize;if(-1===[0,256,512,1024,2048,4096,8192,16384].indexOf(h)&&i.disableLogs,o.createJavaScriptNode)r=o.createJavaScriptNode(h,u,u);else{if(!o.createScriptProcessor)throw"WebAudio API has no support on this browser.";r=o.createScriptProcessor(h,u,u)}m.connect(r),i.bufferSize||(h=r.bufferSize);var g=void 0!==i.sampleRate?i.sampleRate:o.sampleRate||44100;(g<22050||96e3<g)&&i.disableLogs,i.disableLogs||i.desiredSampRate;var p=!1;function v(){a=[],c=0,p=s=R=!(d=[]),o=null,n.leftchannel=a,n.rightchannel=d,n.numberOfAudioChannels=u,n.desiredSampRate=l,n.sampleRate=g,n.recordingLength=c,w={left:[],right:[],recordingLength:0}}function b(){r&&(r.onaudioprocess=null,r.disconnect(),r=null),m&&(m.disconnect(),m=null),v()}this.pause=function(){p=!0},this.resume=function(){if(!1===f())throw"Please make sure MediaStream is active.";if(!s)return i.disableLogs,void this.record();p=!1},this.clearRecordedData=function(){i.checkForInactiveTracks=!1,s&&this.stop(b),b()},this.name="StereoAudioRecorder";var R=!(this.toString=function(){return this.name});r.onaudioprocess=function(e){var t,o;p||(!1===f()&&(i.disableLogs,r.disconnect(),s=!1),s?(R||(R=!0,i.onAudioProcessStarted&&i.onAudioProcessStarted(),i.initCallback&&i.initCallback()),t=e.inputBuffer.getChannelData(0),t=new Float32Array(t),a.push(t),2===u&&(o=e.inputBuffer.getChannelData(1),o=new Float32Array(o),d.push(o)),c+=h,n.recordingLength=c,void 0!==i.timeSlice&&(w.recordingLength+=h,w.left.push(t),2===u&&w.right.push(o))):m&&(m.disconnect(),m=null))},o.createMediaStreamDestination?r.connect(o.createMediaStreamDestination()):r.connect(o.destination),this.leftchannel=a,this.rightchannel=d,this.numberOfAudioChannels=u,this.desiredSampRate=l,this.sampleRate=g,n.recordingLength=c;var w={left:[],right:[],recordingLength:0};function y(){s&&"function"==typeof i.ondataavailable&&void 0!==i.timeSlice&&(w.left.length?(t({desiredSampRate:l,sampleRate:g,numberOfAudioChannels:u,internalInterleavedLength:w.recordingLength,leftBuffers:w.left,rightBuffers:1===u?[]:w.right},function(e,t){t=new Blob([t],{type:"audio/wav"});i.ondataavailable(t),setTimeout(y,i.timeSlice)}),w={left:[],right:[],recordingLength:0}):setTimeout(y,i.timeSlice))}}function CanvasRecorder(r,n){if("undefined"==typeof html2canvas)throw"Please link: https://www.webrtc-experiment.com/screenshot.js";(n=n||{}).frameInterval||(n.frameInterval=10);var i=!1;["captureStream","mozCaptureStream","webkitCaptureStream"].forEach(function(e){e in document.createElement("canvas")&&(i=!0)});var o,a,d,e=!(!window.webkitRTCPeerConnection&&!window.webkitGetUserMedia||!window.chrome),t=50,s=navigator.userAgent.match(/Chrom(e|ium)\/([0-9]+)\./);if(e&&s&&s[2]&&(t=parseInt(s[2],10)),e&&t<52&&(i=!1),n.useWhammyRecorder&&(i=!1),i)if(n.disableLogs||console.log("Your browser supports both MediRecorder API and canvas.captureStream!"),r instanceof HTMLCanvasElement)o=r;else{if(!(r instanceof CanvasRenderingContext2D))throw"Please pass either HTMLCanvasElement or CanvasRenderingContext2D.";o=r.canvas}else navigator.mozGetUserMedia&&(n.disableLogs||console.error("Canvas recording is NOT supported in Firefox."));this.record=function(){if(d=!0,i&&!n.useWhammyRecorder){var e;"captureStream"in o?e=o.captureStream(25):"mozCaptureStream"in o?e=o.mozCaptureStream(25):"webkitCaptureStream"in o&&(e=o.webkitCaptureStream(25));try{var t=new MediaStream;t.addTrack(getTracks(e,"video")[0]),e=t}catch(e){}if(!e)throw"captureStream API are NOT available.";(a=new MediaStreamRecorder(e,{mimeType:n.mimeType||"video/webm"})).record()}else m.frames=[],f=(new Date).getTime(),l();n.initCallback&&n.initCallback()},this.getWebPImages=function(e){var i;"canvas"===r.nodeName.toLowerCase()&&(i=m.frames.length,m.frames.forEach(function(e,t){var o=i-t;n.disableLogs,n.onEncodingCallback&&n.onEncodingCallback(o,i);e=e.image.toDataURL("image/webp",1);m.frames[t].image=e}),n.disableLogs),e()};var c=!(this.stop=function(t){d=!1;var o=this;i&&a?a.stop(t):this.getWebPImages(function(){m.compile(function(e){n.disableLogs,o.blob=e,o.blob.forEach&&(o.blob=new Blob([],{type:"video/webm"})),t&&t(o.blob),m.frames=[]})})});function u(){m.frames=[],c=d=!1}function l(){if(c)return f=(new Date).getTime(),setTimeout(l,500);if("canvas"===r.nodeName.toLowerCase()){var e=(new Date).getTime()-f;return f=(new Date).getTime(),m.frames.push({image:(t=document.createElement("canvas"),o=t.getContext("2d"),t.width=r.width,t.height=r.height,o.drawImage(r,0,0),t),duration:e}),void(d&&setTimeout(l,n.frameInterval))}var t,o;html2canvas(r,{grabMouse:void 0===n.showMousePointer||n.showMousePointer,onrendered:function(e){var t=(new Date).getTime()-f;if(!t)return setTimeout(l,n.frameInterval);f=(new Date).getTime(),m.frames.push({image:e.toDataURL("image/webp",1),duration:t}),d&&setTimeout(l,n.frameInterval)}})}this.pause=function(){c=!0,a instanceof MediaStreamRecorder&&a.pause()},this.resume=function(){c=!1,a instanceof MediaStreamRecorder?a.resume():d||this.record()},this.clearRecordedData=function(){d&&this.stop(u),u()},this.name="CanvasRecorder",this.toString=function(){return this.name};var f=(new Date).getTime(),m=new Whammy.Video(100)}function WhammyRecorder(e,i){function o(e){e=void 0!==e?e:10;var t=(new Date).getTime()-s;return t?a?(s=(new Date).getTime(),setTimeout(o,100)):(s=(new Date).getTime(),d.paused&&d.play(),u.drawImage(d,0,0,w.width,w.height),c.frames.push({duration:t,image:w.toDataURL("image/webp")}),void(n||setTimeout(o,e,e))):setTimeout(o,e,e)}function r(o,e,t,i,r){var n=document.createElement("canvas");n.width=w.width,n.height=w.height;var a,d,s,u=n.getContext("2d"),l=[],f=-1===e,c=e&&0<e&&e<=o.length?e:o.length,m=0,h=0,g=0,p=Math.sqrt(Math.pow(255,2)+Math.pow(255,2)+Math.pow(255,2)),v=t&&0<=t&&t<=1?t:0,b=i&&0<=i&&i<=1?i:0,R=!1;d=-1,s=(a={length:c,functionToLoop:function(e,t){function n(){!R&&s-a<=s*b||(f&&(R=!0),l.push(o[t])),e()}var a,d,s,c;R?n():((c=new Image).onload=function(){u.drawImage(c,0,0,w.width,w.height);var e=u.getImageData(0,0,w.width,w.height);a=0,d=e.data.length,s=e.data.length/4;for(var t=0;t<d;t+=4){var o=e.data[t],i=e.data[t+1],r=e.data[t+2];Math.sqrt(Math.pow(o-m,2)+Math.pow(i-h,2)+Math.pow(r-g,2))<=p*v&&a++}n()},c.src=o[t].image)},callback:function(){(l=l.concat(o.slice(c))).length<=0&&l.push(o[o.length-1]),r(l)}}).length,function e(){++d!==s?setTimeout(function(){a.functionToLoop(e,d)},1):a.callback()}()}(i=i||{}).frameInterval||(i.frameInterval=10),i.disableLogs;var n=!(this.record=function(){i.width||(i.width=320),i.height||(i.height=240),i.video||(i.video={width:i.width,height:i.height}),i.canvas||(i.canvas={width:i.width,height:i.height}),w.width=i.canvas.width||320,w.height=i.canvas.height||240,u=w.getContext("2d"),i.video&&i.video instanceof HTMLVideoElement?(d=i.video.cloneNode(),i.initCallback&&i.initCallback()):(d=document.createElement("video"),setSrcObject(e,d),d.onloadedmetadata=function(){i.initCallback&&i.initCallback()},d.width=i.video.width,d.height=i.video.height),d.muted=!0,d.play(),s=(new Date).getTime(),c=new Whammy.Video,i.disableLogs,o(i.frameInterval)}),a=!(this.stop=function(t){t=t||function(){},n=!0;var o=this;setTimeout(function(){r(c.frames,-1,null,null,function(e){c.frames=e,i.advertisement&&i.advertisement.length&&(c.frames=i.advertisement.concat(c.frames)),c.compile(function(e){o.blob=e,o.blob.forEach&&(o.blob=new Blob([],{type:"video/webm"})),t&&t(o.blob)})})},10)});function t(){c.frames=[],a=!(n=!0)}this.pause=function(){a=!0},this.resume=function(){a=!1,n&&this.record()},this.clearRecordedData=function(){n||this.stop(t),t()},this.name="WhammyRecorder",this.toString=function(){return this.name};var d,s,c,w=document.createElement("canvas"),u=w.getContext("2d")}void 0!==AudioContext?Storage.AudioContext=AudioContext:"undefined"!=typeof webkitAudioContext&&(Storage.AudioContext=webkitAudioContext),void 0!==RecordRTC&&(RecordRTC.Storage=Storage),void 0!==RecordRTC&&(RecordRTC.MediaStreamRecorder=MediaStreamRecorder),void 0!==RecordRTC&&(RecordRTC.StereoAudioRecorder=StereoAudioRecorder),void 0!==RecordRTC&&(RecordRTC.CanvasRecorder=CanvasRecorder),void 0!==RecordRTC&&(RecordRTC.WhammyRecorder=WhammyRecorder);var Whammy=function(){function e(e){this.frames=[],this.duration=e||1,this.quality=.8}function i(e){function c(e){for(var t=[];0<e;)t.push(255&e),e>>=8;return new Uint8Array(t.reverse())}function u(e){return new Uint8Array(e.split("").map(function(e){return e.charCodeAt(0)}))}function l(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 a(e){for(var t=0,o={};t<e.length;){var i=e.substr(t,4),r=(n=t,parseInt(e.substr(n+4,4).split("").map(function(e){e=e.charCodeAt(0).toString(2);return new Array(8-e.length+1).join("0")+e}).join(""),2)),n=e.substr(t+4+4,r);t+=8+r,o[i]=o[i]||[],"RIFF"===i||"LIST"===i?o[i].push(a(n)):o[i].push(n)}return o}e=new function(e){var t=function(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,r=1;r<e.length;r++)i+=e[r].duration;return{duration:i,width:t,height:o}}(e);if(!t)return[];for(var o,i=[{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:(o=t.duration,[].slice.call(new Uint8Array(new Float64Array([o]).buffer),0).map(function(e){return String.fromCharCode(e)}).reverse().join("")),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,n=0;r<e.length;){for(var a=[],d=0;a.push(e[r]),d+=e[r].duration,r++,r<e.length&&d<3e4;);var s={id:524531317,data:function(e,o,t){return[{data:e,id:231}].concat(t.map(function(e){var t=function(e){var t=0;e.keyframe&&(t|=128);e.invisible&&(t|=8);e.lacing&&(t|=e.lacing<<1);e.discardable&&(t|=1);if(127<e.trackNum)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}({discardable:0,frame:e.data.slice(4),invisible:0,keyframe:1,lacing:0,trackNum:1,timecode:Math.round(o)});return o+=e.duration,{data:t,id:163}}))}(n,0,a)};i[1].data.push(s),n+=d}return function e(t){var o=[];for(var i=0;i<t.length;i++){var r=t[i].data;"object"==typeof r&&(r=e(r)),"number"==typeof r&&(r=l(r.toString(2))),"string"==typeof r&&(r=u(r));var n=r.size||r.byteLength||r.length,a=Math.ceil(Math.ceil(Math.log(n)/Math.log(2))/8),n=n.toString(2),n=new Array(7*a+7+1-n.length).join("0")+n,n=new Array(a).join("0")+"1"+n;o.push(c(t[i].id)),o.push(l(n)),o.push(r)}return new Blob(o,{type:"video/webm"})}(i)}(e.map(function(e){var t=function(e){for(var t=e.RIFF[0].WEBP[0],o=t.indexOf("*"),i=0,r=[];i<4;i++)r[i]=t.charCodeAt(o+3+i);return{width:16383&(r[1]<<8|r[0]),height:16383&(r[3]<<8|r[2]),data:t,riff:e}}(a(atob(e.image.slice(23))));return t.duration=e.duration,t}));postMessage(e)}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(t){var e,o,e=(e=i,o=URL.createObjectURL(new Blob([e.toString(),"this.onmessage =  function (eee) {"+e.name+"(eee.data);}"],{type:"application/javascript"})),e=new Worker(o),URL.revokeObjectURL(o),e);e.onmessage=function(e){e.data.error?console.error(e.data.error):t(e.data)},e.postMessage(this.frames)},{Video:e}}();void 0!==RecordRTC&&(RecordRTC.Whammy=Whammy);var DiskStorage={init:function(){var e,o,t,i=this;function r(e){e.createObjectStore(i.dataStoreName)}function n(){var e=o.transaction([i.dataStoreName],"readwrite");function t(t){e.objectStore(i.dataStoreName).get(t).onsuccess=function(e){i.callback&&i.callback(e.target.result,t)}}i.videoBlob&&e.objectStore(i.dataStoreName).put(i.videoBlob,"videoBlob"),i.gifBlob&&e.objectStore(i.dataStoreName).put(i.gifBlob,"gifBlob"),i.audioBlob&&e.objectStore(i.dataStoreName).put(i.audioBlob,"audioBlob"),t("audioBlob"),t("videoBlob"),t("gifBlob")}"undefined"!=typeof indexedDB&&void 0!==indexedDB.open?(e=this.dbName||location.href.replace(/\/|:|#|%|\.|\[|\]/g,""),(t=indexedDB.open(e,1)).onerror=i.onError,t.onsuccess=function(){(o=t.result).onerror=i.onError,o.setVersion&&1!==o.version?o.setVersion(1).onsuccess=function(){r(o),n()}:n()},t.onupgradeneeded=function(e){r(e.target.result)}):console.error("IndexedDB API are not available in this browser.")},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};function GifRecorder(e,o){var t;"undefined"==typeof GIFEncoder&&((t=document.createElement("script")).src="https://www.webrtc-experiment.com/gif-recorder.js",(document.body||document.documentElement).appendChild(t)),o=o||{};var i=e instanceof CanvasRenderingContext2D||e instanceof HTMLCanvasElement;this.record=function(){"undefined"!=typeof GIFEncoder&&s?(i||(o.width||(o.width=d.offsetWidth||320),o.height||(o.height=d.offsetHeight||240),o.video||(o.video={width:o.width,height:o.height}),o.canvas||(o.canvas={width:o.width,height:o.height}),n.width=o.canvas.width||320,n.height=o.canvas.height||240,d.width=o.video.width||320,d.height=o.video.height||240),(u=new GIFEncoder).setRepeat(0),u.setDelay(o.frameRate||200),u.setQuality(o.quality||10),u.start(),"function"==typeof o.onGifRecordingStarted&&o.onGifRecordingStarted(),Date.now(),l=requestAnimationFrame(function e(t){if(!0!==f.clearedRecordedData){if(r)return setTimeout(function(){e(t)},100);l=requestAnimationFrame(e),t-c<90||(!i&&d.paused&&d.play(),i||a.drawImage(d,0,0,n.width,n.height),o.onGifPreview&&o.onGifPreview(n.toDataURL("image/png")),u.addFrame(a),c=t)}}),o.initCallback&&o.initCallback()):setTimeout(f.record,1e3)};var r=!(this.stop=function(e){e=e||function(){},l&&cancelAnimationFrame(l),Date.now(),this.blob=new Blob([new Uint8Array(u.stream().bin)],{type:"image/gif"}),e(this.blob),u.stream().bin=[]});this.pause=function(){r=!0},this.resume=function(){r=!1},this.clearRecordedData=function(){f.clearedRecordedData=!0,u&&(u.stream().bin=[])},this.name="GifRecorder",this.toString=function(){return this.name};var n=document.createElement("canvas"),a=n.getContext("2d");i&&(e instanceof CanvasRenderingContext2D?n=(a=e).canvas:e instanceof HTMLCanvasElement&&(a=e.getContext("2d"),n=e));var d,s=!0;i||((d=document.createElement("video")).muted=!0,d.autoplay=!0,d.playsInline=!0,s=!1,d.onloadedmetadata=function(){s=!0},setSrcObject(e,d),d.play());var c,u,l=null,f=this}function MultiStreamsMixer(i,r){e="undefined"!=typeof global?global:null,void 0===RecordRTC&&e&&"undefined"==typeof window&&"undefined"!=typeof global&&(global.navigator={userAgent:"Fake/5.0 (FakeOS) AppleWebKit/123 (KHTML, like Gecko) Fake/12.3.4567.89 Fake/123.45",getUserMedia:function(){}},global.console||(global.console={}),void 0!==global.console.log&&void 0!==global.console.error||(global.console.error=global.console.log=global.console.log||function(){}),"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===t&&(e.URL={createObjectURL:function(){return""},revokeObjectURL:function(){return""}}),e.window=global),r=r||"multi-streams-mixer";var n=[],a=!1,d=document.createElement("canvas"),s=d.getContext("2d");d.style.opacity=0,d.style.position="absolute",d.style.zIndex=-1,d.style.top="-1000em",d.style.left="-1000em",d.className=r,(document.body||document.documentElement).appendChild(d),this.disableLogs=!1,this.frameInterval=10,this.width=360,this.height=240,this.useGainNode=!0;var c=this,e=window.AudioContext;void 0===e&&("undefined"!=typeof webkitAudioContext&&(e=webkitAudioContext),"undefined"!=typeof mozAudioContext&&(e=mozAudioContext));var t=window.URL;void 0===t&&"undefined"!=typeof webkitURL&&(t=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=window.MediaStream;void 0===u&&"undefined"!=typeof webkitMediaStream&&(u=webkitMediaStream),void 0!==u&&void 0===u.prototype.stop&&(u.prototype.stop=function(){this.getTracks().forEach(function(e){e.stop()})});var o={};function l(){var t,o,e;a||(e=n.length,t=!1,o=[],n.forEach(function(e){e.stream||(e.stream={}),e.stream.fullcanvas?t=e:o.push(e)}),t?(d.width=t.stream.width,d.height=t.stream.height):o.length?(d.width=1<e?2*o[0].width:o[0].width,e=9!==e&&10!==e?7!==e&&8!==e?5!==e&&6!==e?3!==e&&4!==e?1:2:3:4:5,d.height=o[0].height*e):(d.width=c.width||360,d.height=c.height||240),t&&t instanceof HTMLVideoElement&&f(t),o.forEach(function(e,t){f(e,t)}),setTimeout(l,c.frameInterval))}function f(e,t){var o,i,r,n;a||(i=o=0,r=e.width,n=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&&(r=e.stream.width),void 0!==e.stream.height&&(n=e.stream.height),s.drawImage(e,o,i,r,n),"function"==typeof e.stream.onRender&&e.stream.onRender(s,o,i,r,n,t))}function m(e){var t,o,i=document.createElement("video");return t=e,!("srcObject"in(o=i))&&"mozSrcObject"in o?o.mozSrcObject=t:o.srcObject=t,i.className=r,i.muted=!0,i.volume=0,i.width=e.width||c.width||360,i.height=e.height||c.height||240,i.play(),i}function h(e){n=[],(e=e||i).forEach(function(e){var t;e.getTracks().filter(function(e){return"video"===e.kind}).length&&((t=m(e)).stream=e,n.push(t))})}void 0!==e?o.AudioContext=e:"undefined"!=typeof webkitAudioContext&&(o.AudioContext=webkitAudioContext),this.startDrawingFrames=function(){l()},this.appendStreams=function(e){if(!e)throw"First parameter is required.";e instanceof Array||(e=[e]),e.forEach(function(e){var t,o=new u;e.getTracks().filter(function(e){return"video"===e.kind}).length&&((t=m(e)).stream=e,n.push(t),o.addTrack(e.getTracks().filter(function(e){return"video"===e.kind})[0])),e.getTracks().filter(function(e){return"audio"===e.kind}).length&&(e=c.audioContext.createMediaStreamSource(e),c.audioDestination=c.audioContext.createMediaStreamDestination(),e.connect(c.audioDestination),o.addTrack(c.audioDestination.stream.getTracks().filter(function(e){return"audio"===e.kind})[0])),i.push(o)})},this.releaseStreams=function(){n=[],a=!0,c.gainNode&&(c.gainNode.disconnect(),c.gainNode=null),c.audioSources.length&&(c.audioSources.forEach(function(e){e.disconnect()}),c.audioSources=[]),c.audioDestination&&(c.audioDestination.disconnect(),c.audioDestination=null),c.audioContext&&c.audioContext.close(),c.audioContext=null,s.clearRect(0,0,d.width,d.height),d.stream&&(d.stream.stop(),d.stream=null)},this.resetVideoStreams=function(e){!e||e instanceof Array||(e=[e]),h(e)},this.name="MultiStreamsMixer",this.toString=function(){return this.name},this.getMixedStream=function(){a=!1;var t=function(){var e;h(),"captureStream"in d?e=d.captureStream():"mozCaptureStream"in d?e=d.mozCaptureStream():c.disableLogs||console.error("Upgrade to latest Chrome or otherwise enable this flag: chrome://flags/#enable-experimental-web-platform-features");var t=new u;return e.getTracks().filter(function(e){return"video"===e.kind}).forEach(function(e){t.addTrack(e)}),d.stream=t}(),e=function(){o.AudioContextConstructor||(o.AudioContextConstructor=new o.AudioContext);c.audioContext=o.AudioContextConstructor,c.audioSources=[],!0===c.useGainNode&&(c.gainNode=c.audioContext.createGain(),c.gainNode.connect(c.audioContext.destination),c.gainNode.gain.value=0);var t=0;return i.forEach(function(e){e.getTracks().filter(function(e){return"audio"===e.kind}).length&&(t++,e=c.audioContext.createMediaStreamSource(e),!0===c.useGainNode&&e.connect(c.gainNode),c.audioSources.push(e))}),t?(c.audioDestination=c.audioContext.createMediaStreamDestination(),c.audioSources.forEach(function(e){e.connect(c.audioDestination)}),c.audioDestination.stream):void 0}();return e&&e.getTracks().filter(function(e){return"audio"===e.kind}).forEach(function(e){t.addTrack(e)}),i.forEach(function(e){e.fullcanvas}),t}}function MultiStreamRecorder(o,i){o=o||[];var r,n,a=this;(i=i||{elementClass:"multi-streams-mixer",mimeType:"video/webm",video:{width:360,height:240}}).frameInterval||(i.frameInterval=10),i.video||(i.video={}),i.video.width||(i.video.width=360),i.video.height||(i.video.height=240),this.record=function(){var t;r=new MultiStreamsMixer(o,i.elementClass||"multi-streams-mixer"),t=[],o.forEach(function(e){getTracks(e,"video").forEach(function(e){t.push(e)})}),t.length&&(r.frameInterval=i.frameInterval||10,r.width=i.video.width||360,r.height=i.video.height||240,r.startDrawingFrames()),i.previewStream&&"function"==typeof i.previewStream&&i.previewStream(r.getMixedStream()),(n=new MediaStreamRecorder(r.getMixedStream(),i)).record()},this.stop=function(t){n&&n.stop(function(e){a.blob=e,t(e),a.clearRecordedData()})},this.pause=function(){n&&n.pause()},this.resume=function(){n&&n.resume()},this.clearRecordedData=function(){n&&(n.clearRecordedData(),n=null),r&&(r.releaseStreams(),r=null)},this.addStreams=function(e){if(!e)throw"First parameter is required.";e instanceof Array||(e=[e]),o.concat(e),n&&r&&(r.appendStreams(e),i.previewStream&&"function"==typeof i.previewStream&&i.previewStream(r.getMixedStream()))},this.resetVideoStreams=function(e){r&&(!e||e instanceof Array||(e=[e]),r.resetVideoStreams(e))},this.getMixer=function(){return r},this.name="MultiStreamRecorder",this.toString=function(){return this.name}}function RecordRTCPromisesHandler(e,t){if(!this)throw'Use "new RecordRTCPromisesHandler()"';if(void 0===e)throw'First argument "MediaStream" is required.';var i=this;i.recordRTC=new RecordRTC(e,t),this.startRecording=function(){return new Promise(function(e,t){try{i.recordRTC.startRecording(),e()}catch(e){t(e)}})},this.stopRecording=function(){return new Promise(function(t,o){try{i.recordRTC.stopRecording(function(e){i.blob=i.recordRTC.getBlob(),i.blob&&i.blob.size?t(e):o("Empty blob.",i.blob)})}catch(e){o(e)}})},this.pauseRecording=function(){return new Promise(function(e,t){try{i.recordRTC.pauseRecording(),e()}catch(e){t(e)}})},this.resumeRecording=function(){return new Promise(function(e,t){try{i.recordRTC.resumeRecording(),e()}catch(e){t(e)}})},this.getDataURL=function(e){return new Promise(function(t,o){try{i.recordRTC.getDataURL(function(e){t(e)})}catch(e){o(e)}})},this.getBlob=function(){return new Promise(function(e,t){try{e(i.recordRTC.getBlob())}catch(e){t(e)}})},this.getInternalRecorder=function(){return new Promise(function(e,t){try{e(i.recordRTC.getInternalRecorder())}catch(e){t(e)}})},this.reset=function(){return new Promise(function(e,t){try{e(i.recordRTC.reset())}catch(e){t(e)}})},this.destroy=function(){return new Promise(function(e,t){try{e(i.recordRTC.destroy())}catch(e){t(e)}})},this.getState=function(){return new Promise(function(e,t){try{e(i.recordRTC.getState())}catch(e){t(e)}})},this.blob=null,this.version="5.6.2"}function WebAssemblyRecorder(o,d){var s,i,r;function n(t,e){if(!d.workerPath&&!e)return s=!1,void fetch("https://unpkg.com/webm-wasm@latest/dist/webm-worker.js").then(function(e){e.arrayBuffer().then(function(e){n(t,e)})});!d.workerPath&&e instanceof ArrayBuffer&&(e=new Blob([e],{type:"text/javascript"}),d.workerPath=URL.createObjectURL(e)),d.workerPath||console.error("workerPath parameter is missing."),(i=new Worker(d.workerPath)).postMessage(d.webAssemblyPath||"https://unpkg.com/webm-wasm@latest/dist/webm-wasm.wasm"),i.addEventListener("message",function(e){"READY"===e.data?(i.postMessage({width:d.width,height:d.height,bitrate:d.bitrate||1200,timebaseDen:d.frameRate||30,realtime:d.realtime}),new ReadableStream({start:function(i){var r=document.createElement("canvas"),n=document.createElement("video"),a=!0;n.srcObject=o,n.muted=!0,n.height=d.height,n.width=d.width,n.volume=0,n.onplaying=function(){r.width=d.width,r.height=d.height;var e=r.getContext("2d"),t=1e3/d.frameRate,o=setInterval(function(){if(s&&(clearInterval(o),i.close()),a&&(a=!1,d.onVideoProcessStarted&&d.onVideoProcessStarted()),e.drawImage(n,0,0),"closed"!==i._controlledReadableStream.state)try{i.enqueue(e.getImageData(0,0,d.width,d.height))}catch(e){}},t)},n.play()}}).pipeTo(new WritableStream({write:function(e){s?console.error("Got image, but recorder is finished!"):i.postMessage(e.data.buffer,[e.data.buffer])}}))):e.data&&(r||a.push(e.data))})}"undefined"!=typeof ReadableStream&&"undefined"!=typeof WritableStream||console.error("Following polyfill is strongly recommended: https://unpkg.com/@mattiasbuelens/web-streams-polyfill/dist/polyfill.min.js"),(d=d||{}).width=d.width||640,d.height=d.height||480,d.frameRate=d.frameRate||30,d.bitrate=d.bitrate||1200,d.realtime=d.realtime||!0,this.record=function(){r=!(a=[]),this.blob=null,n(o),"function"==typeof d.initCallback&&d.initCallback()},this.pause=function(){r=!0},this.resume=function(){r=!1};var a=[];this.stop=function(e){s=!0;var t,o=this;t=function(){o.blob=new Blob(a,{type:"video/webm"}),e(o.blob)},i?(i.addEventListener("message",function(e){null===e.data&&(i.terminate(),i=null,t&&t())}),i.postMessage(null)):t&&t()},this.name="WebAssemblyRecorder",this.toString=function(){return this.name},this.clearRecordedData=function(){r=!(a=[]),this.blob=null},this.blob=null}void 0!==RecordRTC&&(RecordRTC.DiskStorage=DiskStorage),void 0!==RecordRTC&&(RecordRTC.GifRecorder=GifRecorder),void 0===RecordRTC&&("undefined"!=typeof module&&(module.exports=MultiStreamsMixer),"function"==typeof define&&define.amd&&define("MultiStreamsMixer",[],function(){return MultiStreamsMixer})),void 0!==RecordRTC&&(RecordRTC.MultiStreamRecorder=MultiStreamRecorder),void 0!==RecordRTC&&(RecordRTC.RecordRTCPromisesHandler=RecordRTCPromisesHandler),void 0!==RecordRTC&&(RecordRTC.WebAssemblyRecorder=WebAssemblyRecorder);