cogserv-speechtotext-client
Version:
NodeJS service + client package for using Microsoft Translator in front end applications
1 lines • 86.1 kB
JavaScript
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.Translator=e():t.Translator=e()}(this,function(){return function(t){function e(r){if(n[r])return n[r].exports;var o=n[r]={i:r,l:!1,exports:{}};return t[r].call(o.exports,o,o.exports,e),o.l=!0,o.exports}var n={};return e.m=t,e.c=n,e.d=function(t,n,r){e.o(t,n)||Object.defineProperty(t,n,{configurable:!1,enumerable:!0,get:r})},e.n=function(t){var n=t&&t.__esModule?function(){return t.default}:function(){return t};return e.d(n,"a",n),n},e.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},e.p="",e(e.s=21)}([function(t,e){var n;n=function(){return this}();try{n=n||Function("return this")()||(0,eval)("this")}catch(t){"object"==typeof window&&(n=window)}t.exports=n},function(t,e,n){(function(r){function o(){return!("undefined"==typeof window||!window.process||"renderer"!==window.process.type)||("undefined"!=typeof document&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||"undefined"!=typeof window&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/)&&parseInt(RegExp.$1,10)>=31||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/))}function i(t){var n=this.useColors;if(t[0]=(n?"%c":"")+this.namespace+(n?" %c":" ")+t[0]+(n?"%c ":" ")+"+"+e.humanize(this.diff),n){var r="color: "+this.color;t.splice(1,0,r,"color: inherit");var o=0,i=0;t[0].replace(/%[a-zA-Z%]/g,function(t){"%%"!==t&&(o++,"%c"===t&&(i=o))}),t.splice(i,0,r)}}function s(){return"object"==typeof console&&console.log&&Function.prototype.apply.call(console.log,console,arguments)}function a(t){try{null==t?e.storage.removeItem("debug"):e.storage.debug=t}catch(t){}}function c(){var t;try{t=e.storage.debug}catch(t){}return!t&&void 0!==r&&"env"in r&&(t=r.env.DEBUG),t}e=t.exports=n(27),e.log=s,e.formatArgs=i,e.save=a,e.load=c,e.useColors=o,e.storage="undefined"!=typeof chrome&&void 0!==chrome.storage?chrome.storage.local:function(){try{return window.localStorage}catch(t){}}(),e.colors=["lightseagreen","forestgreen","goldenrod","dodgerblue","darkorchid","crimson"],e.formatters.j=function(t){try{return JSON.stringify(t)}catch(t){return"[UnexpectedJSONParseError]: "+t.message}},e.enable(c())}).call(e,n(26))},function(t,e,n){function r(t){if(t)return o(t)}function o(t){for(var e in r.prototype)t[e]=r.prototype[e];return t}t.exports=r,r.prototype.on=r.prototype.addEventListener=function(t,e){return this._callbacks=this._callbacks||{},(this._callbacks["$"+t]=this._callbacks["$"+t]||[]).push(e),this},r.prototype.once=function(t,e){function n(){this.off(t,n),e.apply(this,arguments)}return n.fn=e,this.on(t,n),this},r.prototype.off=r.prototype.removeListener=r.prototype.removeAllListeners=r.prototype.removeEventListener=function(t,e){if(this._callbacks=this._callbacks||{},0==arguments.length)return this._callbacks={},this;var n=this._callbacks["$"+t];if(!n)return this;if(1==arguments.length)return delete this._callbacks["$"+t],this;for(var r,o=0;o<n.length;o++)if((r=n[o])===e||r.fn===e){n.splice(o,1);break}return this},r.prototype.emit=function(t){this._callbacks=this._callbacks||{};var e=[].slice.call(arguments,1),n=this._callbacks["$"+t];if(n){n=n.slice(0);for(var r=0,o=n.length;r<o;++r)n[r].apply(this,e)}return this},r.prototype.listeners=function(t){return this._callbacks=this._callbacks||{},this._callbacks["$"+t]||[]},r.prototype.hasListeners=function(t){return!!this.listeners(t).length}},function(t,e,n){(function(t){function r(t,n){return n("b"+e.packets[t.type]+t.data.data)}function o(t,n,r){if(!n)return e.encodeBase64Packet(t,r);var o=t.data,i=new Uint8Array(o),s=new Uint8Array(1+o.byteLength);s[0]=v[t.type];for(var a=0;a<i.length;a++)s[a+1]=i[a];return r(s.buffer)}function i(t,n,r){if(!n)return e.encodeBase64Packet(t,r);var o=new FileReader;return o.onload=function(){t.data=o.result,e.encodePacket(t,n,!0,r)},o.readAsArrayBuffer(t.data)}function s(t,n,r){if(!n)return e.encodeBase64Packet(t,r);if(g)return i(t,n,r);var o=new Uint8Array(1);return o[0]=v[t.type],r(new k([o.buffer,t.data]))}function a(t){try{t=l.decode(t,{strict:!1})}catch(t){return!1}return t}function c(t,e,n){for(var r=new Array(t.length),o=d(t.length,n),i=0;i<t.length;i++)!function(t,n,o){e(n,function(e,n){r[t]=n,o(e,r)})}(i,t[i],o)}var u,h=n(35),p=n(10),f=n(36),d=n(37),l=n(38);t&&t.ArrayBuffer&&(u=n(40));var m="undefined"!=typeof navigator&&/Android/i.test(navigator.userAgent),y="undefined"!=typeof navigator&&/PhantomJS/i.test(navigator.userAgent),g=m||y;e.protocol=3;var v=e.packets={open:0,close:1,ping:2,pong:3,message:4,upgrade:5,noop:6},b=h(v),w={type:"error",data:"parser error"},k=n(41);e.encodePacket=function(e,n,i,a){"function"==typeof n&&(a=n,n=!1),"function"==typeof i&&(a=i,i=null);var c=void 0===e.data?void 0:e.data.buffer||e.data;if(t.ArrayBuffer&&c instanceof ArrayBuffer)return o(e,n,a);if(k&&c instanceof t.Blob)return s(e,n,a);if(c&&c.base64)return r(e,a);var u=v[e.type];return void 0!==e.data&&(u+=i?l.encode(String(e.data),{strict:!1}):String(e.data)),a(""+u)},e.encodeBase64Packet=function(n,r){var o="b"+e.packets[n.type];if(k&&n.data instanceof t.Blob){var i=new FileReader;return i.onload=function(){var t=i.result.split(",")[1];r(o+t)},i.readAsDataURL(n.data)}var s;try{s=String.fromCharCode.apply(null,new Uint8Array(n.data))}catch(t){for(var a=new Uint8Array(n.data),c=new Array(a.length),u=0;u<a.length;u++)c[u]=a[u];s=String.fromCharCode.apply(null,c)}return o+=t.btoa(s),r(o)},e.decodePacket=function(t,n,r){if(void 0===t)return w;if("string"==typeof t){if("b"===t.charAt(0))return e.decodeBase64Packet(t.substr(1),n);if(r&&!1===(t=a(t)))return w;var o=t.charAt(0);return Number(o)==o&&b[o]?t.length>1?{type:b[o],data:t.substring(1)}:{type:b[o]}:w}var i=new Uint8Array(t),o=i[0],s=f(t,1);return k&&"blob"===n&&(s=new k([s])),{type:b[o],data:s}},e.decodeBase64Packet=function(t,e){var n=b[t.charAt(0)];if(!u)return{type:n,data:{base64:!0,data:t.substr(1)}};var r=u.decode(t.substr(1));return"blob"===e&&k&&(r=new k([r])),{type:n,data:r}},e.encodePayload=function(t,n,r){function o(t){return t.length+":"+t}function i(t,r){e.encodePacket(t,!!s&&n,!1,function(t){r(null,o(t))})}"function"==typeof n&&(r=n,n=null);var s=p(t);return n&&s?k&&!g?e.encodePayloadAsBlob(t,r):e.encodePayloadAsArrayBuffer(t,r):t.length?void c(t,i,function(t,e){return r(e.join(""))}):r("0:")},e.decodePayload=function(t,n,r){if("string"!=typeof t)return e.decodePayloadAsBinary(t,n,r);"function"==typeof n&&(r=n,n=null);var o;if(""===t)return r(w,0,1);for(var i,s,a="",c=0,u=t.length;c<u;c++){var h=t.charAt(c);if(":"===h){if(""===a||a!=(i=Number(a)))return r(w,0,1);if(s=t.substr(c+1,i),a!=s.length)return r(w,0,1);if(s.length){if(o=e.decodePacket(s,n,!1),w.type===o.type&&w.data===o.data)return r(w,0,1);if(!1===r(o,c+i,u))return}c+=i,a=""}else a+=h}return""!==a?r(w,0,1):void 0},e.encodePayloadAsArrayBuffer=function(t,n){function r(t,n){e.encodePacket(t,!0,!0,function(t){return n(null,t)})}if(!t.length)return n(new ArrayBuffer(0));c(t,r,function(t,e){var r=e.reduce(function(t,e){var n;return n="string"==typeof e?e.length:e.byteLength,t+n.toString().length+n+2},0),o=new Uint8Array(r),i=0;return e.forEach(function(t){var e="string"==typeof t,n=t;if(e){for(var r=new Uint8Array(t.length),s=0;s<t.length;s++)r[s]=t.charCodeAt(s);n=r.buffer}o[i++]=e?0:1;for(var a=n.byteLength.toString(),s=0;s<a.length;s++)o[i++]=parseInt(a[s]);o[i++]=255;for(var r=new Uint8Array(n),s=0;s<r.length;s++)o[i++]=r[s]}),n(o.buffer)})},e.encodePayloadAsBlob=function(t,n){function r(t,n){e.encodePacket(t,!0,!0,function(t){var e=new Uint8Array(1);if(e[0]=1,"string"==typeof t){for(var r=new Uint8Array(t.length),o=0;o<t.length;o++)r[o]=t.charCodeAt(o);t=r.buffer,e[0]=0}for(var i=t instanceof ArrayBuffer?t.byteLength:t.size,s=i.toString(),a=new Uint8Array(s.length+1),o=0;o<s.length;o++)a[o]=parseInt(s[o]);if(a[s.length]=255,k){var c=new k([e.buffer,a.buffer,t]);n(null,c)}})}c(t,r,function(t,e){return n(new k(e))})},e.decodePayloadAsBinary=function(t,n,r){"function"==typeof n&&(r=n,n=null);for(var o=t,i=[];o.byteLength>0;){for(var s=new Uint8Array(o),a=0===s[0],c="",u=1;255!==s[u];u++){if(c.length>310)return r(w,0,1);c+=s[u]}o=f(o,2+c.length),c=parseInt(c);var h=f(o,0,c);if(a)try{h=String.fromCharCode.apply(null,new Uint8Array(h))}catch(t){var p=new Uint8Array(h);h="";for(var u=0;u<p.length;u++)h+=String.fromCharCode(p[u])}i.push(h),o=f(o,c)}var d=i.length;i.forEach(function(t,o){r(e.decodePacket(t,n,!0),o,d)})}}).call(e,n(0))},function(t,e){e.encode=function(t){var e="";for(var n in t)t.hasOwnProperty(n)&&(e.length&&(e+="&"),e+=encodeURIComponent(n)+"="+encodeURIComponent(t[n]));return e},e.decode=function(t){for(var e={},n=t.split("&"),r=0,o=n.length;r<o;r++){var i=n[r].split("=");e[decodeURIComponent(i[0])]=decodeURIComponent(i[1])}return e}},function(t,e){t.exports=function(t,e){var n=function(){};n.prototype=e.prototype,t.prototype=new n,t.prototype.constructor=t}},function(t,e,n){function r(){}function o(t){var n=""+t.type;return e.BINARY_EVENT!==t.type&&e.BINARY_ACK!==t.type||(n+=t.attachments+"-"),t.nsp&&"/"!==t.nsp&&(n+=t.nsp+","),null!=t.id&&(n+=t.id),null!=t.data&&(n+=JSON.stringify(t.data)),p("encoded %j as %s",t,n),n}function i(t,e){function n(t){var n=l.deconstructPacket(t),r=o(n.packet),i=n.buffers;i.unshift(r),e(i)}l.removeBlobs(t,n)}function s(){this.reconstructor=null}function a(t){var n=0,r={type:Number(t.charAt(0))};if(null==e.types[r.type])return h();if(e.BINARY_EVENT===r.type||e.BINARY_ACK===r.type){for(var o="";"-"!==t.charAt(++n)&&(o+=t.charAt(n),n!=t.length););if(o!=Number(o)||"-"!==t.charAt(n))throw new Error("Illegal attachments");r.attachments=Number(o)}if("/"===t.charAt(n+1))for(r.nsp="";++n;){var i=t.charAt(n);if(","===i)break;if(r.nsp+=i,n===t.length)break}else r.nsp="/";var s=t.charAt(n+1);if(""!==s&&Number(s)==s){for(r.id="";++n;){var i=t.charAt(n);if(null==i||Number(i)!=i){--n;break}if(r.id+=t.charAt(n),n===t.length)break}r.id=Number(r.id)}return t.charAt(++n)&&(r=c(r,t.substr(n))),p("decoded %s as %j",t,r),r}function c(t,e){try{t.data=JSON.parse(e)}catch(t){return h()}return t}function u(t){this.reconPack=t,this.buffers=[]}function h(){return{type:e.ERROR,data:"parser error"}}var p=n(1)("socket.io-parser"),f=n(2),d=n(10),l=n(29),m=n(12);e.protocol=4,e.types=["CONNECT","DISCONNECT","EVENT","ACK","ERROR","BINARY_EVENT","BINARY_ACK"],e.CONNECT=0,e.DISCONNECT=1,e.EVENT=2,e.ACK=3,e.ERROR=4,e.BINARY_EVENT=5,e.BINARY_ACK=6,e.Encoder=r,e.Decoder=s,r.prototype.encode=function(t,n){if(t.type!==e.EVENT&&t.type!==e.ACK||!d(t.data)||(t.type=t.type===e.EVENT?e.BINARY_EVENT:e.BINARY_ACK),p("encoding packet %j",t),e.BINARY_EVENT===t.type||e.BINARY_ACK===t.type)i(t,n);else{n([o(t)])}},f(s.prototype),s.prototype.add=function(t){var n;if("string"==typeof t)n=a(t),e.BINARY_EVENT===n.type||e.BINARY_ACK===n.type?(this.reconstructor=new u(n),0===this.reconstructor.reconPack.attachments&&this.emit("decoded",n)):this.emit("decoded",n);else{if(!m(t)&&!t.base64)throw new Error("Unknown type: "+t);if(!this.reconstructor)throw new Error("got binary data when not reconstructing a packet");(n=this.reconstructor.takeBinaryData(t))&&(this.reconstructor=null,this.emit("decoded",n))}},s.prototype.destroy=function(){this.reconstructor&&this.reconstructor.finishedReconstruction()},u.prototype.takeBinaryData=function(t){if(this.buffers.push(t),this.buffers.length===this.reconPack.attachments){var e=l.reconstructPacket(this.reconPack,this.buffers);return this.finishedReconstruction(),e}return null},u.prototype.finishedReconstruction=function(){this.reconPack=null,this.buffers=[]}},function(t,e,n){(function(e){var r=n(33);t.exports=function(t){var n=t.xdomain,o=t.xscheme,i=t.enablesXDR;try{if("undefined"!=typeof XMLHttpRequest&&(!n||r))return new XMLHttpRequest}catch(t){}try{if("undefined"!=typeof XDomainRequest&&!o&&i)return new XDomainRequest}catch(t){}if(!n)try{return new(e[["Active"].concat("Object").join("X")])("Microsoft.XMLHTTP")}catch(t){}}}).call(e,n(0))},function(t,e,n){function r(t){this.path=t.path,this.hostname=t.hostname,this.port=t.port,this.secure=t.secure,this.query=t.query,this.timestampParam=t.timestampParam,this.timestampRequests=t.timestampRequests,this.readyState="",this.agent=t.agent||!1,this.socket=t.socket,this.enablesXDR=t.enablesXDR,this.pfx=t.pfx,this.key=t.key,this.passphrase=t.passphrase,this.cert=t.cert,this.ca=t.ca,this.ciphers=t.ciphers,this.rejectUnauthorized=t.rejectUnauthorized,this.forceNode=t.forceNode,this.extraHeaders=t.extraHeaders,this.localAddress=t.localAddress}var o=n(3),i=n(2);t.exports=r,i(r.prototype),r.prototype.onError=function(t,e){var n=new Error(t);return n.type="TransportError",n.description=e,this.emit("error",n),this},r.prototype.open=function(){return"closed"!==this.readyState&&""!==this.readyState||(this.readyState="opening",this.doOpen()),this},r.prototype.close=function(){return"opening"!==this.readyState&&"open"!==this.readyState||(this.doClose(),this.onClose()),this},r.prototype.send=function(t){if("open"!==this.readyState)throw new Error("Transport not open");this.write(t)},r.prototype.onOpen=function(){this.readyState="open",this.writable=!0,this.emit("open")},r.prototype.onData=function(t){var e=o.decodePacket(t,this.socket.binaryType);this.onPacket(e)},r.prototype.onPacket=function(t){this.emit("packet",t)},r.prototype.onClose=function(){this.readyState="closed",this.emit("close")}},function(t,e){var n=/^(?:(?![^:@]+:[^:@\/]*@)(http|https|ws|wss):\/\/)?((?:(([^:@]*)(?::([^:@]*))?)?@)?((?:[a-f0-9]{0,4}:){2,7}[a-f0-9]{0,4}|[^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/,r=["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"];t.exports=function(t){var e=t,o=t.indexOf("["),i=t.indexOf("]");-1!=o&&-1!=i&&(t=t.substring(0,o)+t.substring(o,i).replace(/:/g,";")+t.substring(i,t.length));for(var s=n.exec(t||""),a={},c=14;c--;)a[r[c]]=s[c]||"";return-1!=o&&-1!=i&&(a.source=e,a.host=a.host.substring(1,a.host.length-1).replace(/;/g,":"),a.authority=a.authority.replace("[","").replace("]","").replace(/;/g,":"),a.ipv6uri=!0),a}},function(t,e,n){(function(e){function r(t){if(!t||"object"!=typeof t)return!1;if(o(t)){for(var n=0,i=t.length;n<i;n++)if(r(t[n]))return!0;return!1}if("function"==typeof e.Buffer&&e.Buffer.isBuffer&&e.Buffer.isBuffer(t)||"function"==typeof e.ArrayBuffer&&t instanceof ArrayBuffer||s&&t instanceof Blob||a&&t instanceof File)return!0;if(t.toJSON&&"function"==typeof t.toJSON&&1===arguments.length)return r(t.toJSON(),!0);for(var c in t)if(Object.prototype.hasOwnProperty.call(t,c)&&r(t[c]))return!0;return!1}var o=n(11),i=Object.prototype.toString,s="function"==typeof e.Blob||"[object BlobConstructor]"===i.call(e.Blob),a="function"==typeof e.File||"[object FileConstructor]"===i.call(e.File);t.exports=r}).call(e,n(0))},function(t,e){var n={}.toString;t.exports=Array.isArray||function(t){return"[object Array]"==n.call(t)}},function(t,e,n){(function(e){function n(t){return e.Buffer&&e.Buffer.isBuffer(t)||e.ArrayBuffer&&t instanceof ArrayBuffer}t.exports=n}).call(e,n(0))},function(t,e,n){function r(t,e){if(!(this instanceof r))return new r(t,e);t&&"object"==typeof t&&(e=t,t=void 0),e=e||{},e.path=e.path||"/socket.io",this.nsps={},this.subs=[],this.opts=e,this.reconnection(!1!==e.reconnection),this.reconnectionAttempts(e.reconnectionAttempts||1/0),this.reconnectionDelay(e.reconnectionDelay||1e3),this.reconnectionDelayMax(e.reconnectionDelayMax||5e3),this.randomizationFactor(e.randomizationFactor||.5),this.backoff=new f({min:this.reconnectionDelay(),max:this.reconnectionDelayMax(),jitter:this.randomizationFactor()}),this.timeout(null==e.timeout?2e4:e.timeout),this.readyState="closed",this.uri=t,this.connecting=[],this.lastPing=null,this.encoding=!1,this.packetBuffer=[];var n=e.parser||a;this.encoder=new n.Encoder,this.decoder=new n.Decoder,this.autoConnect=!1!==e.autoConnect,this.autoConnect&&this.open()}var o=n(30),i=n(18),s=n(2),a=n(6),c=n(19),u=n(20),h=n(1)("socket.io-client:manager"),p=n(17),f=n(47),d=Object.prototype.hasOwnProperty;t.exports=r,r.prototype.emitAll=function(){this.emit.apply(this,arguments);for(var t in this.nsps)d.call(this.nsps,t)&&this.nsps[t].emit.apply(this.nsps[t],arguments)},r.prototype.updateSocketIds=function(){for(var t in this.nsps)d.call(this.nsps,t)&&(this.nsps[t].id=this.generateId(t))},r.prototype.generateId=function(t){return("/"===t?"":t+"#")+this.engine.id},s(r.prototype),r.prototype.reconnection=function(t){return arguments.length?(this._reconnection=!!t,this):this._reconnection},r.prototype.reconnectionAttempts=function(t){return arguments.length?(this._reconnectionAttempts=t,this):this._reconnectionAttempts},r.prototype.reconnectionDelay=function(t){return arguments.length?(this._reconnectionDelay=t,this.backoff&&this.backoff.setMin(t),this):this._reconnectionDelay},r.prototype.randomizationFactor=function(t){return arguments.length?(this._randomizationFactor=t,this.backoff&&this.backoff.setJitter(t),this):this._randomizationFactor},r.prototype.reconnectionDelayMax=function(t){return arguments.length?(this._reconnectionDelayMax=t,this.backoff&&this.backoff.setMax(t),this):this._reconnectionDelayMax},r.prototype.timeout=function(t){return arguments.length?(this._timeout=t,this):this._timeout},r.prototype.maybeReconnectOnOpen=function(){!this.reconnecting&&this._reconnection&&0===this.backoff.attempts&&this.reconnect()},r.prototype.open=r.prototype.connect=function(t,e){if(h("readyState %s",this.readyState),~this.readyState.indexOf("open"))return this;h("opening %s",this.uri),this.engine=o(this.uri,this.opts);var n=this.engine,r=this;this.readyState="opening",this.skipReconnect=!1;var i=c(n,"open",function(){r.onopen(),t&&t()}),s=c(n,"error",function(e){if(h("connect_error"),r.cleanup(),r.readyState="closed",r.emitAll("connect_error",e),t){var n=new Error("Connection error");n.data=e,t(n)}else r.maybeReconnectOnOpen()});if(!1!==this._timeout){var a=this._timeout;h("connect attempt will timeout after %d",a);var u=setTimeout(function(){h("connect attempt timed out after %d",a),i.destroy(),n.close(),n.emit("error","timeout"),r.emitAll("connect_timeout",a)},a);this.subs.push({destroy:function(){clearTimeout(u)}})}return this.subs.push(i),this.subs.push(s),this},r.prototype.onopen=function(){h("open"),this.cleanup(),this.readyState="open",this.emit("open");var t=this.engine;this.subs.push(c(t,"data",u(this,"ondata"))),this.subs.push(c(t,"ping",u(this,"onping"))),this.subs.push(c(t,"pong",u(this,"onpong"))),this.subs.push(c(t,"error",u(this,"onerror"))),this.subs.push(c(t,"close",u(this,"onclose"))),this.subs.push(c(this.decoder,"decoded",u(this,"ondecoded")))},r.prototype.onping=function(){this.lastPing=new Date,this.emitAll("ping")},r.prototype.onpong=function(){this.emitAll("pong",new Date-this.lastPing)},r.prototype.ondata=function(t){this.decoder.add(t)},r.prototype.ondecoded=function(t){this.emit("packet",t)},r.prototype.onerror=function(t){h("error",t),this.emitAll("error",t)},r.prototype.socket=function(t,e){function n(){~p(o.connecting,r)||o.connecting.push(r)}var r=this.nsps[t];if(!r){r=new i(this,t,e),this.nsps[t]=r;var o=this;r.on("connecting",n),r.on("connect",function(){r.id=o.generateId(t)}),this.autoConnect&&n()}return r},r.prototype.destroy=function(t){var e=p(this.connecting,t);~e&&this.connecting.splice(e,1),this.connecting.length||this.close()},r.prototype.packet=function(t){h("writing packet %j",t);var e=this;t.query&&0===t.type&&(t.nsp+="?"+t.query),e.encoding?e.packetBuffer.push(t):(e.encoding=!0,this.encoder.encode(t,function(n){for(var r=0;r<n.length;r++)e.engine.write(n[r],t.options);e.encoding=!1,e.processPacketQueue()}))},r.prototype.processPacketQueue=function(){if(this.packetBuffer.length>0&&!this.encoding){var t=this.packetBuffer.shift();this.packet(t)}},r.prototype.cleanup=function(){h("cleanup");for(var t=this.subs.length,e=0;e<t;e++){this.subs.shift().destroy()}this.packetBuffer=[],this.encoding=!1,this.lastPing=null,this.decoder.destroy()},r.prototype.close=r.prototype.disconnect=function(){h("disconnect"),this.skipReconnect=!0,this.reconnecting=!1,"opening"===this.readyState&&this.cleanup(),this.backoff.reset(),this.readyState="closed",this.engine&&this.engine.close()},r.prototype.onclose=function(t){h("onclose"),this.cleanup(),this.backoff.reset(),this.readyState="closed",this.emit("close",t),this._reconnection&&!this.skipReconnect&&this.reconnect()},r.prototype.reconnect=function(){if(this.reconnecting||this.skipReconnect)return this;var t=this;if(this.backoff.attempts>=this._reconnectionAttempts)h("reconnect failed"),this.backoff.reset(),this.emitAll("reconnect_failed"),this.reconnecting=!1;else{var e=this.backoff.duration();h("will wait %dms before reconnect attempt",e),this.reconnecting=!0;var n=setTimeout(function(){t.skipReconnect||(h("attempting reconnect"),t.emitAll("reconnect_attempt",t.backoff.attempts),t.emitAll("reconnecting",t.backoff.attempts),t.skipReconnect||t.open(function(e){e?(h("reconnect attempt error"),t.reconnecting=!1,t.reconnect(),t.emitAll("reconnect_error",e.data)):(h("reconnect success"),t.onreconnect())}))},e);this.subs.push({destroy:function(){clearTimeout(n)}})}},r.prototype.onreconnect=function(){var t=this.backoff.attempts;this.reconnecting=!1,this.backoff.reset(),this.updateSocketIds(),this.emitAll("reconnect",t)}},function(t,e,n){(function(t){function r(e){var n=!1,r=!1,a=!1!==e.jsonp;if(t.location){var c="https:"===location.protocol,u=location.port;u||(u=c?443:80),n=e.hostname!==location.hostname||u!==e.port,r=e.secure!==c}if(e.xdomain=n,e.xscheme=r,"open"in new o(e)&&!e.forceJSONP)return new i(e);if(!a)throw new Error("JSONP disabled");return new s(e)}var o=n(7),i=n(34),s=n(42),a=n(43);e.polling=r,e.websocket=a}).call(e,n(0))},function(t,e,n){function r(t){var e=t&&t.forceBase64;h&&!e||(this.supportsBinary=!1),o.call(this,t)}var o=n(8),i=n(4),s=n(3),a=n(5),c=n(16),u=n(1)("engine.io-client:polling");t.exports=r;var h=function(){return null!=new(n(7))({xdomain:!1}).responseType}();a(r,o),r.prototype.name="polling",r.prototype.doOpen=function(){this.poll()},r.prototype.pause=function(t){function e(){u("paused"),n.readyState="paused",t()}var n=this;if(this.readyState="pausing",this.polling||!this.writable){var r=0;this.polling&&(u("we are currently polling - waiting to pause"),r++,this.once("pollComplete",function(){u("pre-pause polling complete"),--r||e()})),this.writable||(u("we are currently writing - waiting to pause"),r++,this.once("drain",function(){u("pre-pause writing complete"),--r||e()}))}else e()},r.prototype.poll=function(){u("polling"),this.polling=!0,this.doPoll(),this.emit("poll")},r.prototype.onData=function(t){var e=this;u("polling got data %s",t);var n=function(t,n,r){if("opening"===e.readyState&&e.onOpen(),"close"===t.type)return e.onClose(),!1;e.onPacket(t)};s.decodePayload(t,this.socket.binaryType,n),"closed"!==this.readyState&&(this.polling=!1,this.emit("pollComplete"),"open"===this.readyState?this.poll():u('ignoring poll - transport state "%s"',this.readyState))},r.prototype.doClose=function(){function t(){u("writing close packet"),e.write([{type:"close"}])}var e=this;"open"===this.readyState?(u("transport open - closing"),t()):(u("transport not open - deferring close"),this.once("open",t))},r.prototype.write=function(t){var e=this;this.writable=!1;var n=function(){e.writable=!0,e.emit("drain")};s.encodePayload(t,this.supportsBinary,function(t){e.doWrite(t,n)})},r.prototype.uri=function(){var t=this.query||{},e=this.secure?"https":"http",n="";return!1!==this.timestampRequests&&(t[this.timestampParam]=c()),this.supportsBinary||t.sid||(t.b64=1),t=i.encode(t),this.port&&("https"===e&&443!==Number(this.port)||"http"===e&&80!==Number(this.port))&&(n=":"+this.port),t.length&&(t="?"+t),e+"://"+(-1!==this.hostname.indexOf(":")?"["+this.hostname+"]":this.hostname)+n+this.path+t}},function(t,e,n){"use strict";function r(t){var e="";do{e=a[t%c]+e,t=Math.floor(t/c)}while(t>0);return e}function o(t){var e=0;for(p=0;p<t.length;p++)e=e*c+u[t.charAt(p)];return e}function i(){var t=r(+new Date);return t!==s?(h=0,s=t):t+"."+r(h++)}for(var s,a="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-_".split(""),c=64,u={},h=0,p=0;p<c;p++)u[a[p]]=p;i.encode=r,i.decode=o,t.exports=i},function(t,e){var n=[].indexOf;t.exports=function(t,e){if(n)return t.indexOf(e);for(var r=0;r<t.length;++r)if(t[r]===e)return r;return-1}},function(t,e,n){function r(t,e,n){this.io=t,this.nsp=e,this.json=this,this.ids=0,this.acks={},this.receiveBuffer=[],this.sendBuffer=[],this.connected=!1,this.disconnected=!0,n&&n.query&&(this.query=n.query),this.io.autoConnect&&this.open()}var o=n(6),i=n(2),s=n(46),a=n(19),c=n(20),u=n(1)("socket.io-client:socket"),h=n(4);t.exports=r;var p={connect:1,connect_error:1,connect_timeout:1,connecting:1,disconnect:1,error:1,reconnect:1,reconnect_attempt:1,reconnect_failed:1,reconnect_error:1,reconnecting:1,ping:1,pong:1},f=i.prototype.emit;i(r.prototype),r.prototype.subEvents=function(){if(!this.subs){var t=this.io;this.subs=[a(t,"open",c(this,"onopen")),a(t,"packet",c(this,"onpacket")),a(t,"close",c(this,"onclose"))]}},r.prototype.open=r.prototype.connect=function(){return this.connected?this:(this.subEvents(),this.io.open(),"open"===this.io.readyState&&this.onopen(),this.emit("connecting"),this)},r.prototype.send=function(){var t=s(arguments);return t.unshift("message"),this.emit.apply(this,t),this},r.prototype.emit=function(t){if(p.hasOwnProperty(t))return f.apply(this,arguments),this;var e=s(arguments),n={type:o.EVENT,data:e};return n.options={},n.options.compress=!this.flags||!1!==this.flags.compress,"function"==typeof e[e.length-1]&&(u("emitting packet with ack id %d",this.ids),this.acks[this.ids]=e.pop(),n.id=this.ids++),this.connected?this.packet(n):this.sendBuffer.push(n),delete this.flags,this},r.prototype.packet=function(t){t.nsp=this.nsp,this.io.packet(t)},r.prototype.onopen=function(){if(u("transport is open - connecting"),"/"!==this.nsp)if(this.query){var t="object"==typeof this.query?h.encode(this.query):this.query;u("sending connect packet with query %s",t),this.packet({type:o.CONNECT,query:t})}else this.packet({type:o.CONNECT})},r.prototype.onclose=function(t){u("close (%s)",t),this.connected=!1,this.disconnected=!0,delete this.id,this.emit("disconnect",t)},r.prototype.onpacket=function(t){if(t.nsp===this.nsp)switch(t.type){case o.CONNECT:this.onconnect();break;case o.EVENT:case o.BINARY_EVENT:this.onevent(t);break;case o.ACK:case o.BINARY_ACK:this.onack(t);break;case o.DISCONNECT:this.ondisconnect();break;case o.ERROR:this.emit("error",t.data)}},r.prototype.onevent=function(t){var e=t.data||[];u("emitting event %j",e),null!=t.id&&(u("attaching ack callback to event"),e.push(this.ack(t.id))),this.connected?f.apply(this,e):this.receiveBuffer.push(e)},r.prototype.ack=function(t){var e=this,n=!1;return function(){if(!n){n=!0;var r=s(arguments);u("sending ack %j",r),e.packet({type:o.ACK,id:t,data:r})}}},r.prototype.onack=function(t){var e=this.acks[t.id];"function"==typeof e?(u("calling ack %s with %j",t.id,t.data),e.apply(this,t.data),delete this.acks[t.id]):u("bad ack %s",t.id)},r.prototype.onconnect=function(){this.connected=!0,this.disconnected=!1,this.emit("connect"),this.emitBuffered()},r.prototype.emitBuffered=function(){var t;for(t=0;t<this.receiveBuffer.length;t++)f.apply(this,this.receiveBuffer[t]);for(this.receiveBuffer=[],t=0;t<this.sendBuffer.length;t++)this.packet(this.sendBuffer[t]);this.sendBuffer=[]},r.prototype.ondisconnect=function(){u("server disconnect (%s)",this.nsp),this.destroy(),this.onclose("io server disconnect")},r.prototype.destroy=function(){if(this.subs){for(var t=0;t<this.subs.length;t++)this.subs[t].destroy();this.subs=null}this.io.destroy(this)},r.prototype.close=r.prototype.disconnect=function(){return this.connected&&(u("performing disconnect (%s)",this.nsp),this.packet({type:o.DISCONNECT})),this.destroy(),this.connected&&this.onclose("io client disconnect"),this},r.prototype.compress=function(t){return this.flags=this.flags||{},this.flags.compress=t,this}},function(t,e){function n(t,e,n){return t.on(e,n),{destroy:function(){t.removeListener(e,n)}}}t.exports=n},function(t,e){var n=[].slice;t.exports=function(t,e){if("string"==typeof e&&(e=t[e]),"function"!=typeof e)throw new Error("bind() requires a function");var r=n.call(arguments,2);return function(){return e.apply(t,r.concat(n.call(arguments)))}}},function(t,e,n){"use strict";function r(t){return t&&t.__esModule?t:{default:t}}function o(){this._init()}Object.defineProperty(e,"__esModule",{value:!0});var i=n(22),s=r(i),a=n(23),c=r(a),u=n(24),h=r(u);o.prototype=Object.create(c.default.prototype),o.prototype._init=function(){var t=this,e=window.location,n=e.protocol+"//"+e.hostname+":3100";this.socket=(0,h.default)(n),this.socket.on("translation",function(e){return t.emit("translation",e)}),this._setUpRecorder()},o.prototype._setUpRecorder=function(){var t={audio:!0,video:!1};navigator.getUserMedia(t,this._onMediaSuccess.bind(this),this._onMediaError.bind(this))},o.prototype._onMediaSuccess=function(t){var e=this;this.mediaRecorder=new s.default(t),this.mediaRecorder.mimeType="audio/wav",this.mediaRecorder.channels=1,this.mediaRecorder.sampleRate=32e3,this.mediaRecorder.ondataavailable=function(t){e.socket.emit("audio",t)}},o.prototype._onMediaError=function(t){console.error("media error",t)},o.prototype.startListening=function(){var t=this;this.mediaRecorder.start(1e3),this.socket.emit("record:start"),this.socket.once("service:ready",function(){t.emit("listening:started")})},o.prototype.stopListening=function(){this.mediaRecorder.stop(),this.socket.emit("record:stop"),this.emit("listening:stopped")},e.default=o},function(t,e,n){(function(n){function r(t){if(!t)throw"MediaStream is mandatory.";this.start=function(n){var r;"undefined"!=typeof MediaRecorder?r=u:(A||k||w)&&(-1!==this.mimeType.indexOf("video")?r=f:-1!==this.mimeType.indexOf("audio")&&(r=h)),"image/gif"===this.mimeType&&(r=l),"audio/wav"!==this.mimeType&&"audio/pcm"!==this.mimeType||(r=h),this.recorderType&&(r=this.recorderType),e=new r(t),e.blobs=[];var o=this;e.ondataavailable=function(t){e.blobs.push(t),o.ondataavailable(t)},e.onstop=this.onstop,e.onStartedDrawingNonBlankFrames=this.onStartedDrawingNonBlankFrames,e=i(e,this),e.start(n)},this.onStartedDrawingNonBlankFrames=function(){},this.clearOldRecordedFrames=function(){e&&e.clearOldRecordedFrames()},this.stop=function(){e&&e.stop()},this.ondataavailable=function(t){console.log("ondataavailable..",t)},this.onstop=function(t){console.warn("stopped..",t)},this.save=function(t,n){if(!t){if(!e)return;return void ConcatenateBlobs(e.blobs,e.blobs[0].type,function(t){s(t)})}s(t,n)},this.pause=function(){e&&(e.pause(),console.log("Paused recording.",this.mimeType||e.mimeType))},this.resume=function(){e&&(e.resume(),console.log("Resumed recording.",this.mimeType||e.mimeType))},this.recorderType=null,this.mimeType="video/webm",this.disableLogs=!1;var e}function o(t){if(!t)throw"MediaStream is mandatory.";var e=this,n=c();this.stream=t,this.start=function(c){function u(t){a++,e.ondataavailable(t)}o=new r(t),i=new r(t),o.mimeType="audio/ogg",i.mimeType="video/webm";for(var h in this)"function"!=typeof this[h]&&(o[h]=i[h]=this[h]);o.ondataavailable=function(t){s[a]||(s[a]={}),s[a].audio=t,s[a].video&&!s[a].onDataAvailableEventFired&&(s[a].onDataAvailableEventFired=!0,u(s[a]))},i.ondataavailable=function(t){if(n)return e.ondataavailable({video:t,audio:t});s[a]||(s[a]={}),s[a].video=t,s[a].audio&&!s[a].onDataAvailableEventFired&&(s[a].onDataAvailableEventFired=!0,u(s[a]))},i.onstop=o.onstop=function(t){e.onstop(t)},n?i.start(c):(i.onStartedDrawingNonBlankFrames=function(){i.clearOldRecordedFrames(),o.start(c)},i.start(c))},this.stop=function(){o&&o.stop(),i&&i.stop()},this.ondataavailable=function(t){console.log("ondataavailable..",t)},this.onstop=function(t){console.warn("stopped..",t)},this.pause=function(){o&&o.pause(),i&&i.pause()},this.resume=function(){o&&o.resume(),i&&i.resume()};var o,i,s={},a=0}function i(t,e){for(var n in e)"function"!=typeof e[n]&&(t[n]=e[n]);return t}function s(t,e){if(!t)throw"Blob object is required.";if(!t.type)try{t.type="video/webm"}catch(t){}var n=(t.type||"video/webm").split("/")[1];if(e&&-1!==e.indexOf(".")){var r=e.split(".");e=r[0],n=r[1]}var o=(e||Math.round(9999999999*Math.random())+888888888)+"."+n;if(void 0!==navigator.msSaveOrOpenBlob)return navigator.msSaveOrOpenBlob(t,o);if(void 0!==navigator.msSaveBlob)return navigator.msSaveBlob(t,o);var i=document.createElement("a");i.href=b.createObjectURL(t),i.target="_blank",i.download=o,navigator.mozGetUserMedia&&(i.onclick=function(){(document.body||document.documentElement).removeChild(i)},(document.body||document.documentElement).appendChild(i));var s=new MouseEvent("click",{view:window,bubbles:!0,cancelable:!0});i.dispatchEvent(s),navigator.mozGetUserMedia||b.revokeObjectURL(i.href)}function a(t){var e=["Bytes","KB","MB","GB","TB"];if(0===t)return"0 Bytes";var n=parseInt(Math.floor(Math.log(t)/Math.log(1e3)),10);return(t/Math.pow(1e3,n)).toPrecision(3)+" "+e[n]}function c(){var t=!!window.opera||navigator.userAgent.indexOf(" OPR/")>=0,e=!!window.chrome&&!t;if(void 0!==window.InstallTrigger)return!0;if(!e)return!1;var n,r,o=(navigator.appVersion,navigator.userAgent),i=""+parseFloat(navigator.appVersion),s=parseInt(navigator.appVersion,10);return e&&(n=o.indexOf("Chrome"),i=o.substring(n+7)),-1!==(r=i.indexOf(";"))&&(i=i.substring(0,r)),-1!==(r=i.indexOf(" "))&&(i=i.substring(0,r)),s=parseInt(""+i,10),isNaN(s)&&(i=""+parseFloat(navigator.appVersion),s=parseInt(navigator.appVersion,10)),s>=49}function u(t){function e(){if("active"in t){if(!t.active)return!1}else if("ended"in t&&t.ended)return!1;return!0}var n=this;this.start=function(e,o){if(n.mimeType||(n.mimeType="video/webm"),-1!==n.mimeType.indexOf("audio")&&t.getVideoTracks().length&&t.getAudioTracks().length){var i;navigator.mozGetUserMedia?(i=new x,i.addTrack(t.getAudioTracks()[0])):i=new x(t.getAudioTracks()),t=i}-1!==n.mimeType.indexOf("audio")&&(n.mimeType=A?"audio/webm":"audio/ogg"),n.dontFireOnDataAvailableEvent=!1;var s={mimeType:n.mimeType};n.disableLogs||o||console.log("Passing following params over MediaRecorder API.",s),r&&(r=null),A&&!c()&&(s="video/vp8");try{r=new MediaRecorder(t,s)}catch(e){r=new MediaRecorder(t)}"canRecordMimeType"in r&&!1===r.canRecordMimeType(n.mimeType)&&(n.disableLogs||console.warn("MediaRecorder API seems unable to record mimeType:",n.mimeType)),r.ignoreMutedMedia=n.ignoreMutedMedia||!1;var a=!1;r.ondataavailable=function(t){if(!n.dontFireOnDataAvailableEvent&&t.data&&t.data.size&&!(t.data.size<26800)&&!a){a=!0;var o=n.getNativeBlob?t.data:new Blob([t.data],{type:n.mimeType||"video/webm"});n.ondataavailable(o),n.dontFireOnDataAvailableEvent=!0,r&&(r.stop(),r=null),n.start(e,"__disableLogs")}},r.onerror=function(t){n.disableLogs||("InvalidState"===t.name?console.error("The MediaRecorder is not in a state in which the proposed operation is allowed to be executed."):"OutOfMemory"===t.name?console.error("The UA has exhaused the available memory. User agents SHOULD provide as much additional information as possible in the message attribute."):"IllegalStreamModification"===t.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."):"OtherRecordingError"===t.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."):"GenericError"===t.name?console.error("The UA cannot provide the codec or recording option that has been requested.",t):console.error("MediaRecorder Error",t)),r&&"inactive"!==r.state&&"stopped"!==r.state&&r.stop()};try{r.start(36e5)}catch(t){r=null}setTimeout(function(){r&&"recording"===r.state&&r.requestData()},e)},this.stop=function(t){r&&"recording"===r.state&&(r.requestData(),setTimeout(function(){n.dontFireOnDataAvailableEvent=!0,r&&"recording"===r.state&&r.stop(),r=null},2e3))},this.pause=function(){r&&"recording"===r.state&&r.pause()},this.ondataavailable=function(t){console.log("recorded-blob",t)},this.resume=function(){if(this.dontFireOnDataAvailableEvent){this.dontFireOnDataAvailableEvent=!1;var t=n.disableLogs;return n.disableLogs=!0,this.record(),void(n.disableLogs=t)}r&&"paused"===r.state&&r.resume()},this.clearRecordedData=function(){r&&(this.pause(),this.dontFireOnDataAvailableEvent=!0,this.stop())};var r;!function t(){if(r)return!1===e()?void n.stop():void setTimeout(t,1e3)}()}function h(t){this.start=function(r){r=r||1e3,e=new p(t,this),e.record(),n=setInterval(function(){e.requestData()},r)},this.stop=function(){e&&(e.stop(),clearTimeout(n))},this.pause=function(){e&&e.pause()},this.resume=function(){e&&e.resume()},this.ondataavailable=function(){};var e,n}function p(t,e){function n(t,e){for(var n=t.length+e.length,r=new Float32Array(n),o=0,i=0;i<n;)r[i++]=t[o],r[i++]=e[o],o++;return r}function r(t,e){for(var n=new Float32Array(e),r=0,o=t.length,i=0;i<o;i++){var s=t[i];n.set(s,r),r+=s.length}return n}function o(t,e,n){for(var r=n.length,o=0;o<r;o++)t.setUint8(e+o,n.charCodeAt(o))}function i(t){for(var e=t.length,n=new Int16Array(e);e--;)n[e]=65535*t[e];return n.buffer}var s=44100;T.AudioContextConstructor||(T.AudioContextConstructor=new T.AudioContext),s=T.AudioContextConstructor.sampleRate;var c,u,h,p,f=[],d=[],l=!1,m=0,y=e.sampleRate||s,g=e.mimeType||"audio/wav",v=g.indexOf("audio/pcm")>-1,b=e.audioChannels||2;this.record=function(){l=!0,f.length=d.length=0,m=0},this.requestData=function(){if(!A){if(0===m)return void(k=!1);k=!0;var t=f.slice(0),s=d.slice(0),c=m;f.length=d.length=[],m=0,k=!1;var u=r(t,c),h=u;if(2===b){h=n(u,r(s,c))}if(v){var p=new Blob([i(h)],{type:"audio/pcm"});return console.debug("audio recorded blob size:",a(p.size)),void e.ondataavailable(p)}var l=new ArrayBuffer(44+2*h.length),g=new DataView(l);o(g,0,"RIFF"),g.setUint32(4,44+2*h.length-8,!0),o(g,8,"WAVE"),o(g,12,"fmt "),g.setUint32(16,16,!0),g.setUint16(20,1,!0),g.setUint16(22,b,!0),g.setUint32(24,y,!0),g.setUint32(28,y*b*2,!0),g.setUint16(32,2*b,!0),g.setUint16(34,16,!0),o(g,36,"data"),g.setUint32(40,2*h.length,!0);for(var w=h.length,x=44,T=0;T<w;T++)g.setInt16(x,32767*h[T],!0),x+=2;var p=new Blob([g],{type:"audio/wav"});console.debug("audio recorded blob size:",a(p.size)),e.ondataavailable(p)}},this.stop=function(){l=!1,this.requestData(),h.disconnect()};var p=T.AudioContextConstructor;T.VolumeGainNode=p.createGain();var u=T.VolumeGainNode;T.AudioInput=p.createMediaStreamSource(t);var h=T.AudioInput;h.connect(u);var w=e.bufferSize||2048;if(0===e.bufferSize&&(w=0),p.createJavaScriptNode)c=p.createJavaScriptNode(w,b,b);else{if(!p.createScriptProcessor)throw"WebAudio API has no support on this browser.";c=p.createScriptProcessor(w,b,b)}w=c.bufferSize,console.debug("using audio buffer-size:",w);var k=!1;window.scriptprocessornode=c,1===b&&console.debug("All right-channels are skipped.");var A=!1;this.pause=function(){A=!0},this.resume=function(){A=!1},c.onaudioprocess=function(t){if(l&&!k&&!A){var e=t.inputBuffer.getChannelData(0);if(f.push(new Float32Array(e)),2===b){var n=t.inputBuffer.getChannelData(1);d.push(new Float32Array(n))}m+=w}},u.connect(c),c.connect(p.destination)}function f(t){this.start=function(r){r=r||1e3,e=new d(t,this);for(var o in this)"function"!=typeof this[o]&&(e[o]=this[o]);e.record(),n=setInterval(function(){e.requestData()},r)},this.stop=function(){e&&(e.stop(),clearTimeout(n))},this.clearOldRecordedFrames=function(){e&&e.clearOldRecordedFrames()},this.pause=function(){e&&e.pause()},this.resume=function(){e&&e.resume()},this.ondataavailable=function(){};var e,n}function d(t,e){function n(){if(m)return h=(new Date).getTime(),void setTimeout(n,500);if(!c){if(i)return setTimeout(n,100);var t=(new Date).getTime()-h;if(!t)return n();h=(new Date).getTime(),!l.isHTMLObject&&u.paused&&u.play(),d.drawImage(u,0,0,f.width,f.height),c||p.frames.push({duration:t,image:f.toDataURL("image/webp")}),s||r(p.frames[p.frames.length-1])||(s=!0,e.onStartedDrawingNonBlankFrames()),setTimeout(n,10)}}function r(t,e,n){var r=document.createElement("canvas");r.width=f.width,r.height=f.height;var o,i,s,a=r.getContext("2d"),c={r:0,g:0,b:0},u=Math.sqrt(Math.pow(255,2)+Math.pow(255,2)+Math.pow(255,2)),h=e&&e>=0&&e<=1?e:0,p=n&&n>=0&&n<=1?n:0,d=new Image;d.src=t.image,a.drawImage(d,0,0,f.width,f.height);var l=a.getImageData(0,0,f.width,f.height);o=0,i=l.data.length,s=l.data.length/4;for(var m=0;m<i;m+=4){var y={r:l.data[m],g:l.data[m+1],b:l.data[m+2]};Math.sqrt(Math.pow(y.r-c.r,2)+Math.pow(y.g-c.g,2)+Math.pow(y.b-c.b,2))<=u*h&&o++}return!(s-o<=s*p)}function o(t,e,n,r){var o=document.createElement("canvas");o.width=f.width,o.height=f.height;for(var i=o.getContext("2d"),s=[],a=-1===e,c=e&&e>0&&e<=t.length?e:t.length,u={r:0,g:0,b:0},h=Math.sqrt(Math.pow(255,2)+Math.pow(255,2)+Math.pow(255,2)),p=n&&n>=0&&n<=1?n:0,d=r&&r>=0&&r<=1?r:0,l=!1,m=0;m<c;m++){var y,g,v;if(!l){var b=new Image;b.src=t[m].image,i.drawImage(b,0,0,f.width,f.height);var w=i.getImageData(0,0,f.width,f.height);y=0,g=w.data.length,v=w.data.length/4;for(var k=0;k<g;k+=4){var A={r:w.data[k],g:w.data[k+1],b:w.data[k+2]};Math.sqrt(Math.pow(A.r-u.r,2)+Math.pow(A.g-u.g,2)+Math.pow(A.b-u.b,2))<=h*p&&y++}}!l&&v-y<=v*d||(a&&(l=!0),s.push(t[m]))}return s=s.concat(t.slice(c)),s.length<=0&&s.push(t[t.length-1]),s}this.record=function(r){this.width||(this.width=320),this.height||(this.height=240),this.video&&this.video instanceof HTMLVideoElement&&(this.width||(this.width=u.videoWidth||u.clientWidth||320),this.height||(this.height=u.videoHeight||u.clientHeight||240)),this.video||(this.video={width:this.width,height:this.height}),this.canvas&&this.canvas.width&&this.canvas.height||(this.canvas={width:this.width,height:this.height}),f.width=this.canvas.width,f.height=this.canvas.height,this.video&&this.video instanceof HTMLVideoElement?(this.isHTMLObject=!0,u=this.video.cloneNode()):(u=document.createElement("video"),u.src=b.createObjectURL(t),u.width=this.video.width,u.height=this.video.height),u.muted=!0,u.play(),h=(new Date).getTime(),p=new B.Video(e.speed,e.quality),console.log("canvas resolutions",f.width,"*",f.height),console.log("video width/height",u.width||f.width,"*",u.height||f.height),n()},this.clearOldRecordedFrames=function(){p.frames=[]};var i=!1;this.requestData=function(){if(!m){if(!p.frames.length)return void(i=!1);i=!0;var t=p.frames.slice(0);p.frames=o(t,-1),p.compile(function(t){e.ondataavailable(t),console.debug("video recorded blob size:",a(t.size))}),p.frames=[],i=!1}};var s=!1,c=!1;this.stop=function(){c=!0,this.requestData()};var u,h,p,f=document.createElement("canvas"),d=f.getContext("2d"),l=this,m=!1;this.pause=function(){m=!0},this.resume=function(){m=!1}}function l(t){function e(){c=Date.now();var t=new Blob([new Uint8Array(h.stream().bin)],{type:"image/gif"});r.ondataavailable(t),h.stream().bin=[]}if("undefined"==typeof GIFEncoder)throw"Please link: https://cdn.webrtc-experiment.com/gif-recorder.js";this.start=function(t){function r(t){if(n)return void setTimeout(r,500,t);f=requestAnimationFrame(r),void 0===typeof u&&(u=t),t-u<90||(s.paused&&s.play(),i.drawImage(s,0,0,c,d),h.addFrame(i),u=t)}t=t||1e3;var c=this.videoWidth||320,d=this.videoHeight||240;o.width=s.width=c,o.height=s.height=d,h=new GIFEncoder,h.setRepeat(0),h.setDelay(this.frameRate||this.speed||200),h.setQuality(this.quality||1),h.start(),a=Date.now(),f=requestAnimationFrame(r),p=setTimeout(e,t)},this.stop=function(){f&&(cancelAnimationFrame(f),clearTimeout(p),e())};var n=!1;this.pause=function(){n=!0},this.resume=function(){n=!1},this.ondataavailable=function(){},this.onstop=function(){};var r=this,o=document.createElement("canvas"),i=o.getContext("2d"),s=document.createElement("video");s.muted=!0,s.autoplay=!0,s.src=b.createObjectURL(t),s.play();var a,c,u,h,p,f=null}var m,y;void 0!==r&&(r.MultiStreamRecorder=o);var g="Fake/5.0 (FakeOS) AppleWebKit/123 (KHTML, like Gecko) Fake/12.3.4567.89 Fake/123.45";!function(t){"undefined"==typeof window&&("undefined"==typeof window&&void 0!==n&&(n.navigator={userAgent:g,getUserMedia:function(){}},t.window=n),"undefined"==typeof document&&(t.document={},document.createElement=document.captureStream=document.mozCaptureStream=function(){return{}}),"undefined"==typeof location&&(t.location={protocol:"file:",href:"",hash:""}),"undefined"==typeof screen&&(t.screen={width:0,height:0}))}(void 0!==n?n:window);var v=window.AudioContext;void 0===v&&("undefined"!=typeof webkitAudioContext&&(v=webkitAudioContext),"undefined"!=typeof mozAudioContext&&(v=mozAudioContext)),"undefined"==typeof window&&(window={});var 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.webkitGetUserMedia&&(navigator.getUserMedia=navigator.webkitGetUserMedia),void 0!==navigator.mozGetUserMedia&&(navigator.getUserMedia=navigator.mozGetUserMedia)):navigator={getUserMedia:function(){},userAgent:g};var w=!(-1===navigator.userAgent.indexOf("Edge")||!navigator.msSaveBlob&&!navigator.msSaveOrOpenBlob),k=!1;"undefined"!=typeof opera&&navigator.userAgent&&-1!==navigator.userAgent.indexOf("OPR/")&&(k=!0);var A=!w&&!w&&!!navigator.webkitGetUserMedia,x=window.MediaStream;void 0===x&&"undefined"!=typeof webkitMediaStream&&(x=webkitMediaStream),void 0!==x&&("getVideoTracks"in x.prototype||(x.prototype.getVideoTracks=function(){if(!this.getTracks)return[];var t=[];return this.getTracks.forEach(function(e){-1!==e.kind.toString().indexOf("video")&&t.push(e)}),t},x.prototype.getAudioTracks=function(){if(!this.getTracks)return[];var t=[];return this.getTracks.forEach(function(e){-1!==e.kind.toString().indexOf("audio")&&t.push(e)}),t}),"stop"in x.prototype||(x.prototype.stop=function(){this.getAudioTracks().forEach(function(t){t.stop&&t.stop()}),this.getVideoTracks().forEach(function(t){t.stop&&t.stop()})})),"undefined"!=typeof location&&0===location.href.indexOf("file:")&&console.error("Please load this HTML file on HTTP or HTTPS.");var T={AudioContext:v},T={AudioContext:window.AudioContext||window.webkitAudioContext};void 0!==r&&(r.MediaRecorderWrapper=u),void 0!==r&&(r.StereoAudioRecorder=h),void 0!==r&&(r.StereoAudioRecorderHelper=p),void 0!==r&&(r.WhammyRecorder=f),void 0!==r&&(r.WhammyRecorderHelper=d),void 0!==r&&(r.GifRecorder=l);var B=function(){function t(t,e){this.frames=[],t||(t=1),this.duration=1e3/t,this.quality=e||.8}function e(t){var e=b.createObjectURL(new Blob([t.toString(),"this.onmessage = function (e) {"+t.name+"(e.data);}"],{type:"application/javascript"})),n=new Worker(e);return b.revokeObjectURL(e),n}function n(t){function e(t){var e=r(t);if(!e)return[];for(var o=[{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(e.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:e.width,id:176},{data:e.height,id:186}]}]}]}]}],i=0,s=0;i<t.length;){var c=[],u=0;do{c.push(t[i]),u+=t[i].duration,i++}while(i<t.length&&u<3e4);var h={id:524531317,data:n(s,0,c)};o[1].data.push(h),s+=u}return a(o)}function n(t,e,n){return[{data:t,id:231}].concat(n.map(function(t){var n=c({discardable:0,frame:t.data.slice(4),invisible:0,keyframe:1,lacing:0,trackNum:1,timecode:Math.round(e)});return e+=t.duration,{data:n,id:163}}))}function r(t){if(!t[0])return void postMessage({error:"Something went wrong. Maybe WebP format is not supported in the current browser."});for(var e=t[0].width,n=t[0].height,r=t[0].duration,o=1;o<t.length;o++)r+=t[o].duration;return{duration:r,width:e,height:n}}function o(t){for(var e=[];t>0;)e.push(255&t),t>>=8;return new Uint8Array(e.reverse())}function i(t){return new Uint8Array(t.split("").map(function(t){return t.charCodeAt(0)}))}function s(t){var e=[];t=(t.length%8?new Array(9-t.length%8).join("0"):"")+t;for(var n=0;n<t.length;n+=8)e.push(parseInt(t.substr(n,8),2));return new Uint8Array(e)}function a(t){for(var e=[],n=0;n<t.length;n++){var r=t[n].data;"object"==typeof r&&(r=a(r)),"number"==typeof r&&(r=s(r.toString(2))),"string"==typeof r&&(r=i(r));var c=r.size||r.byteLength||r.length,u=Math.ceil(Math.ceil(Math.log(c)/Math.log(2))/8),h=c.toString(2),p=new Array(7*u+7+1-h.length).join("0")+h,f=new Array(u).join("0")+"1"+p;e.push(o(t[n].id)),e.push(s(f)),e.push(r)}return new Blob(e,{type:"video/webm"})}function c(t){var e=0;if(t.keyframe&&(e|=128),t.invisible&&(e|=8),t.lacing&&(e|=t.lacing<<1),t.discardable&&(e|=1),t.trackNum>127)throw"TrackNumber > 127 not supported";return[128|t.trackNum,t.timecode>>8,255&t.timecode,e].map(function(t){return String.fromCharCode(t)}).join("")+t.frame}function u(t){for(var e=t.RIFF[0].WEBP[0],n=e.indexOf("*"),r=0,o=[];r<4;r++)o[r]=e.charCodeAt(n+3+r);var i,s,a;return a=o[1]<<8|o[0],i=16383&a,a=o[3]<<8|o[2],s=16383&a,{width:i,height:s,data:e,riff:t}}function h(t,e){return parseInt(t.substr(e+4,4).split("").map(function(t){var e=t.charCodeAt(0).toString(2);return