Skip to content

Instantly share code, notes, and snippets.

@altanai
Created May 16, 2016 12:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save altanai/386d58f5b3c9b91cbe78c97a71ba956d to your computer and use it in GitHub Desktop.
Save altanai/386d58f5b3c9b91cbe78c97a71ba956d to your computer and use it in GitHub Desktop.
function init(e){var n;return e&&!location.hash.replace("#","").length?(location.href=location.href.split("#")[0]+"#"+(100*Math.random()).toString().replace(".",""),location.reload()):n=e&&location.hash.replace("#","").length?location.href.replace(/\/|:|#|\?|\$|\^|%|\.|`|~|!|\+|@|\[|\||]|\|*. /g,"").split("\n").join("").split("\r").join(""):prompt("Enter session ",""),n}var t=" ",e=null,n="tara181989@gmail.com",usersList=document.getElementById("userslist"),numbersOfUsers=document.getElementById("numbersofusers"),usersContainer=document.getElementById("usersContainer"),localUserId=null,remoteUserId=null,card=document.getElementById("card"),containerDiv,main=document.querySelector("#main"),smaller=document.querySelector("#smaller"),webcallpeers=[],sessions={},whoIsTyping=document.querySelector("#who-is-typing"),repeatFlagShowButton=null,repeatFlagHideButton=null,repeatFlagRemoveButton=null,localVideo=null,miniVideo=null,remoteVideos=[],autoload=!0,sessionid=null,socketAddr="/",incomingAudio=!0,incomingVideo=!0,incomingData=!0,outgoingAudio=!0,outgoingVideo=!0,outgoingData=!0,chat=!1,fileShare=!1,screenrecord=!1,screenshare=!1,videorecord=!1,drawCanvas=!1,reconnect=!1,role="participant";
if(function(e,t){var n=e;n.version="0.9.0",n.protocol=1,n.transports=[],n.j=[],n.sockets={},n.connect=function(e,o){var i,r,s,a=n.util.parseUri(e);return t&&t.location&&(a.protocol=a.protocol||t.location.protocol.slice(0,-1),a.host=a.host||(t.document?t.document.domain:t.location.hostname),a.port=a.port||t.location.port),i=n.util.uniqueUri(a),s={host:a.host,secure:"https"==a.protocol,port:a.port||("https"==a.protocol?443:80),query:a.query||""},n.util.merge(s,o),(s["force new connection"]||!n.sockets[i])&&(r=new n.Socket(s)),!s["force new connection"]&&r&&(n.sockets[i]=r),r=r||n.sockets[i],r.of(a.path.length>1?a.path:"")}}("object"==typeof module?module.exports:this.io={},this),function(e,t){var n,o=e.util={},i=/^(?:(?![^:@]+:[^:@\/]*@)([^:\/?#.]+):)?(?:\/\/)?((?:(([^:@]*)(?::([^:@]*))?)?@)?([^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/,r=["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"];o.parseUri=function(e){for(var t=i.exec(e||""),n={},o=14;o--;)n[r[o]]=t[o]||"";return n},o.uniqueUri=function(e){var n=e.protocol,o=e.host,i=e.port;return"document"in t?(o=o||document.domain,i=i||("https"==n&&"https:"!==document.location.protocol?443:document.location.port)):(o=o||"localhost",i||"https"!=n||(i=443)),(n||"http")+"://"+o+":"+(i||80)},o.query=function(e,t){var n,i=o.chunkQuery(e||""),r=[];o.merge(i,o.chunkQuery(t||""));for(n in i)i.hasOwnProperty(n)&&r.push(n+"="+i[n]);return r.length?"?"+r.join("&"):""},o.chunkQuery=function(e){for(var t,n={},o=e.split("&"),i=0,r=o.length;r>i;++i)t=o[i].split("="),t[0]&&(n[t[0]]=t[1]);return n},n=!1,o.load=function(e){return"document"in t&&"complete"===document.readyState||n?e():void o.on(t,"load",e,!1)},o.on=function(e,t,n,o){e.attachEvent?e.attachEvent("on"+t,n):e.addEventListener&&e.addEventListener(t,n,o)},o.request=function(e){if(e&&"undefined"!=typeof XDomainRequest)return new XDomainRequest;if("undefined"!=typeof XMLHttpRequest&&(!e||o.ua.hasCORS))return new XMLHttpRequest;if(!e)try{return new ActiveXObject("Microsoft.XMLHTTP")}catch(t){}return null},"undefined"!=typeof window&&o.load(function(){n=!0}),o.defer=function(e){return o.ua.webkit&&"undefined"==typeof importScripts?void o.load(function(){setTimeout(e,100)}):e()},o.merge=function(e,t,n,i){var r,s=i||[],a="undefined"==typeof n?2:n;for(r in t)t.hasOwnProperty(r)&&o.indexOf(s,r)<0&&("object"==typeof e[r]&&a?o.merge(e[r],t[r],a-1,s):(e[r]=t[r],s.push(t[r])));return e},o.mixin=function(e,t){o.merge(e.prototype,t.prototype)},o.inherit=function(e,t){function n(){}n.prototype=t.prototype,e.prototype=new n},o.isArray=Array.isArray||function(e){return"[object Array]"===Object.prototype.toString.call(e)},o.intersect=function(e,t){for(var n=[],i=e.length>t.length?e:t,r=e.length>t.length?t:e,s=0,a=r.length;a>s;s++)~o.indexOf(i,r[s])&&n.push(r[s]);return n},o.indexOf=function(e,t,n){for(var o=e.length,n=0>n?0>n+o?0:n+o:n||0;o>n&&e[n]!==t;n++);return n>=o?-1:n},o.toArray=function(e){for(var t=[],n=0,o=e.length;o>n;n++)t.push(e[n]);return t},o.ua={},o.ua.hasCORS="undefined"!=typeof XMLHttpRequest&&function(){try{var e=new XMLHttpRequest}catch(t){return!1}return void 0!=e.withCredentials}(),o.ua.webkit="undefined"!=typeof navigator&&/webkit/i.test(navigator.userAgent)}("undefined"!=typeof io?io:module.exports,this),function(e,t){function n(){}e.EventEmitter=n,n.prototype.on=function(e,n){return this.$events||(this.$events={}),this.$events[e]?t.util.isArray(this.$events[e])?this.$events[e].push(n):this.$events[e]=[this.$events[e],n]:this.$events[e]=n,this},n.prototype.addListener=n.prototype.on,n.prototype.once=function(e,t){function n(){o.removeListener(e,n),t.apply(this,arguments)}var o=this;return n.listener=t,this.on(e,n),this},n.prototype.removeListener=function(e,n){var o,i,r,s;if(this.$events&&this.$events[e])if(o=this.$events[e],t.util.isArray(o)){for(i=-1,r=0,s=o.length;s>r;r++)if(o[r]===n||o[r].listener&&o[r].listener===n){i=r;break}if(0>i)return this;o.splice(i,1),o.length||delete this.$events[e]}else(o===n||o.listener&&o.listener===n)&&delete this.$events[e];return this},n.prototype.removeAllListeners=function(e){return this.$events&&this.$events[e]&&(this.$events[e]=null),this},n.prototype.listeners=function(e){return this.$events||(this.$events={}),this.$events[e]||(this.$events[e]=[]),t.util.isArray(this.$events[e])||(this.$events[e]=[this.$events[e]]),this.$events[e]},n.prototype.emit=function(e){var n,o,i,r,s;if(!this.$events)return!1;if(n=this.$events[e],!n)return!1;if(o=Array.prototype.slice.call(arguments,1),"function"==typeof n)n.apply(this,o);else{if(!t.util.isArray(n))return!1;for(i=n.slice(),r=0,s=i.length;s>r;r++)i[r].apply(this,o)}return!0}}("undefined"!=typeof io?io:module.exports,"undefined"!=typeof io?io:module.parent.exports),function(n,t){"use strict";function u(e){return 10>e?"0"+e:e}function a(e){return isFinite(e.valueOf())?e.getUTCFullYear()+"-"+u(e.getUTCMonth()+1)+"-"+u(e.getUTCDate())+"T"+u(e.getUTCHours())+":"+u(e.getUTCMinutes())+":"+u(e.getUTCSeconds())+"Z":null}function s(e){return h.lastIndex=0,h.test(e)?'"'+e.replace(h,function(e){var t=l[e];return"string"==typeof t?t:"\\u"+("0000"+e.charCodeAt(0).toString(16)).slice(-4)})+'"':'"'+e+'"'}function e(t,n){var o,c,p,u,l,h=i,d=n[t];switch(d instanceof Date&&(d=a(t)),"function"==typeof r&&(d=r.call(n,t,d)),typeof d){case"string":return s(d);case"number":return isFinite(d)?String(d):"null";case"boolean":case"null":return String(d);case"object":if(!d)return"null";if(i+=f,l=[],"[object Array]"===Object.prototype.toString.apply(d)){for(u=d.length,o=0;u>o;o+=1)l[o]=e(o,d)||"null";return p=0===l.length?"[]":i?"[\n"+i+l.join(",\n"+i)+"\n"+h+"]":"["+l.join(",")+"]",i=h,p}if(r&&"object"==typeof r)for(u=r.length,o=0;u>o;o+=1)"string"==typeof r[o]&&(c=r[o],p=e(c,d),p&&l.push(s(c)+(i?": ":":")+p));else for(c in d)Object.prototype.hasOwnProperty.call(d,c)&&(p=e(c,d),p&&l.push(s(c)+(i?": ":":")+p));return p=0===l.length?"{}":i?"{\n"+i+l.join(",\n"+i)+"\n"+h+"}":"{"+l.join(",")+"}",i=h,p}}var o;if(t&&t.parse)return n.JSON={parse:t.parse,stringify:t.stringify};o=n.JSON={};var c=/[\u0000\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,h=/[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,i,f,l={"\b":"\\b"," ":"\\t","\n":"\\n","\f":"\\f","\r":"\\r",'"':'\\"',"\\":"\\\\"},r;o.stringify=function(t,n,o){var s;if(i="",f="","number"==typeof o)for(s=0;o>s;s+=1)f+=" ";else"string"==typeof o&&(f=o);if(r=n,n&&"function"!=typeof n&&("object"!=typeof n||"number"!=typeof n.length))throw new Error("JSON.stringify");return e("",{"":t})},o.parse=function(n,t){function r(e,n){var o,i,s=e[n];if(s&&"object"==typeof s)for(o in s)Object.prototype.hasOwnProperty.call(s,o)&&(i=r(s,o),void 0!==i?s[o]=i:delete s[o]);return t.call(e,n,s)}var i;if(n=String(n),c.lastIndex=0,c.test(n)&&(n=n.replace(c,function(e){return"\\u"+("0000"+e.charCodeAt(0).toString(16)).slice(-4)})),/^[\],:{}\s]*$/.test(n.replace(/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g,"@").replace(/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g,"]").replace(/(?:^|:|,)(?:\s*\[)+/g,"")))return i=eval("("+n+")"),"function"==typeof t?r({"":i},""):i;throw new SyntaxError("JSON.parse")}}("undefined"!=typeof io?io:module.exports,"undefined"!=typeof JSON?JSON:void 0),function(e,t){var n,o=e.parser={},i=o.packets=["disconnect","connect","heartbeat","message","json","event","ack","error","noop"],r=o.reasons=["transport not supported","client not handshaken","unauthorized"],s=o.advice=["reconnect"],a=t.JSON,c=t.util.indexOf;o.encodePacket=function(e){var t,n,o,p,u=c(i,e.type),l=e.id||"",h=e.endpoint||"",f=e.ack,d=null;switch(e.type){case"error":t=e.reason?c(r,e.reason):"",n=e.advice?c(s,e.advice):"",(""!==t||""!==n)&&(d=t+(""!==n?"+"+n:""));break;case"message":""!==e.data&&(d=e.data);break;case"event":o={name:e.name},e.args&&e.args.length&&(o.args=e.args),d=a.stringify(o);break;case"json":d=a.stringify(e.data);break;case"connect":e.qs&&(d=e.qs);break;case"ack":d=e.ackId+(e.args&&e.args.length?"+"+a.stringify(e.args):"")}return p=[u,l+("data"==f?"+":""),h],null!==d&&void 0!==d&&p.push(d),p.join(":")},o.encodePayload=function(e){var t,n,o,i="";if(1==e.length)return e[0];for(t=0,n=e.length;n>t;t++)o=e[t],i+="�"+o.length+"�"+e[t];return i},n=/([^:]+):([0-9]+)?(\+)?:([^:]+)?:?([\s\S]*)?/,o.decodePacket=function(e){var t,o=e.match(n);if(!o)return{};var c=o[2]||"",e=o[5]||"",p={type:i[o[1]],endpoint:o[4]||""};switch(c&&(p.id=c,p.ack=o[3]?"data":!0),p.type){case"error":o=e.split("+"),p.reason=r[o[0]]||"",p.advice=s[o[1]]||"";break;case"message":p.data=e||"";break;case"event":try{t=a.parse(e),p.name=t.name,p.args=t.args}catch(u){}p.args=p.args||[];break;case"json":try{p.data=a.parse(e)}catch(u){}break;case"connect":p.qs=e||"";break;case"ack":if(o=e.match(/^([0-9]+)(\+)?(.*)/),o&&(p.ackId=o[1],p.args=[],o[3]))try{p.args=o[3]?a.parse(o[3]):[]}catch(u){}}return p},o.decodePayload=function(e){var t,n,i;if("�"==e.charAt(0)){for(t=[],n=1,i="";n<e.length;n++)"�"==e.charAt(n)?(t.push(o.decodePacket(e.substr(n+1).substr(0,i))),n+=Number(i)+1,i=""):i+=e.charAt(n);return t}return[o.decodePacket(e)]}}("undefined"!=typeof io?io:module.exports,"undefined"!=typeof io?io:module.parent.exports),function(e,t){function n(e,t){this.socket=e,this.sessid=t}e.Transport=n,t.util.mixin(n,t.EventEmitter),n.prototype.onData=function(e){var n,o,i;if(this.clearCloseTimeout(),(this.socket.connected||this.socket.connecting||this.socket.reconnecting)&&this.setCloseTimeout(),""!==e&&(n=t.parser.decodePayload(e),n&&n.length))for(o=0,i=n.length;i>o;o++)this.onPacket(n[o]);return this},n.prototype.onPacket=function(e){return"heartbeat"==e.type?this.onHeartbeat():("connect"==e.type&&""==e.endpoint&&this.onConnect(),this.socket.onPacket(e),this)},n.prototype.setCloseTimeout=function(){if(!this.closeTimeout){var e=this;this.closeTimeout=setTimeout(function(){e.onDisconnect()},this.socket.closeTimeout)}},n.prototype.onDisconnect=function(){return this.close&&this.open&&this.close(),this.clearTimeouts(),this.socket.onDisconnect(),this},n.prototype.onConnect=function(){return this.socket.onConnect(),this},n.prototype.clearCloseTimeout=function(){this.closeTimeout&&(clearTimeout(this.closeTimeout),this.closeTimeout=null)},n.prototype.clearTimeouts=function(){this.clearCloseTimeout(),this.reopenTimeout&&clearTimeout(this.reopenTimeout)},n.prototype.packet=function(e){this.send(t.parser.encodePacket(e))},n.prototype.onHeartbeat=function(){this.packet({type:"heartbeat"})},n.prototype.onOpen=function(){this.open=!0,this.clearCloseTimeout(),this.socket.onOpen()},n.prototype.onClose=function(){this.open=!1,this.socket.onClose(),this.onDisconnect()},n.prototype.prepareUrl=function(){var e=this.socket.options;return this.scheme()+"://"+e.host+":"+e.port+"/"+e.resource+"/"+t.protocol+"/"+this.name+"/"+this.sessid},n.prototype.ready=function(e,t){t.call(this)}}("undefined"!=typeof io?io:module.exports,"undefined"!=typeof io?io:module.parent.exports),function(e,t,n){function o(e){if(this.options={port:80,secure:!1,document:"document"in n?document:!1,resource:"socket.io",transports:t.transports,"connect timeout":1e4,"try multiple transports":!0,reconnect:!0,"reconnection delay":500,"reconnection limit":1/0,"reopen delay":3e3,"max reconnection attempts":10,"sync disconnect on unload":!0,"auto connect":!0,"flash policy port":10843},t.util.merge(this.options,e),this.connected=!1,this.open=!1,this.connecting=!1,this.reconnecting=!1,this.namespaces={},this.buffer=[],this.doBuffer=!1,this.options["sync disconnect on unload"]&&(!this.isXDomain()||t.util.ua.hasCORS)){var o=this;t.util.on(n,"beforeunload",function(){o.disconnectSync()},!1)}this.options["auto connect"]&&this.connect()}function i(){}e.Socket=o,t.util.mixin(o,t.EventEmitter),o.prototype.of=function(e){return this.namespaces[e]||(this.namespaces[e]=new t.SocketNamespace(this,e),""!==e&&this.namespaces[e].packet({type:"connect"})),this.namespaces[e]},o.prototype.publish=function(){var e,t;this.emit.apply(this,arguments);for(t in this.namespaces)this.namespaces.hasOwnProperty(t)&&(e=this.of(t),e.$emit.apply(e,arguments))},o.prototype.handshake=function(e){function n(t){t instanceof Error?a.onError(t.message):e.apply(null,t.split(":"))}var o,r,s,a=this,c=this.options,p=["http"+(c.secure?"s":"")+":/",c.host+":"+c.port,c.resource,t.protocol,t.util.query(this.options.query,"t="+ +new Date)].join("/");this.isXDomain()&&!t.util.ua.hasCORS?(o=document.getElementsByTagName("script")[0],r=document.createElement("script"),r.src=p+"&jsonp="+t.j.length,o.parentNode.insertBefore(r,o),t.j.push(function(e){n(e),r.parentNode.removeChild(r)})):(s=t.util.request(),s.open("GET",p,!0),s.withCredentials=!0,s.onreadystatechange=function(){4==s.readyState&&(s.onreadystatechange=i,200==s.status?n(s.responseText):!a.reconnecting&&a.onError(s.responseText))},s.send(null))},o.prototype.getTransport=function(e){for(var n,o=e||this.transports,i=0;n=o[i];i++)if(t.Transport[n]&&t.Transport[n].check(this)&&(!this.isXDomain()||t.Transport[n].xdomainCheck()))return new t.Transport[n](this,this.sessionid);return null},o.prototype.connect=function(e){if(this.connecting)return this;var n=this;return this.handshake(function(o,i,r,s){function a(e){return n.transport&&n.transport.clearTimeouts(),n.transport=n.getTransport(e),n.transport?void n.transport.ready(n,function(){n.connecting=!0,n.publish("connecting",n.transport.name),n.transport.open(),n.options["connect timeout"]&&(n.connectTimeoutTimer=setTimeout(function(){if(!n.connected&&(n.connecting=!1,n.options["try multiple transports"])){n.remainingTransports||(n.remainingTransports=n.transports.slice(0));for(var e=n.remainingTransports;e.length>0&&e.splice(0,1)[0]!=n.transport.name;);e.length?a(e):n.publish("connect_failed")}},n.options["connect timeout"]))}):n.publish("connect_failed")}n.sessionid=o,n.closeTimeout=1e3*r,n.heartbeatTimeout=1e3*i,n.transports=t.util.intersect(s.split(","),n.options.transports),a(),n.once("connect",function(){clearTimeout(n.connectTimeoutTimer),e&&"function"==typeof e&&e()})}),this},o.prototype.packet=function(e){return this.connected&&!this.doBuffer?this.transport.packet(e):this.buffer.push(e),this},o.prototype.setBuffer=function(e){this.doBuffer=e,!e&&this.connected&&this.buffer.length&&(this.transport.payload(this.buffer),this.buffer=[])},o.prototype.disconnect=function(){return this.connected&&(this.open&&this.of("").packet({type:"disconnect"}),this.onDisconnect("booted")),this},o.prototype.disconnectSync=function(){var e=t.util.request(),n=this.resource+"/"+t.protocol+"/"+this.sessionid;e.open("GET",n,!0),this.onDisconnect("booted")},o.prototype.isXDomain=function(){var e=n.location.port||("https:"==n.location.protocol?443:80);return this.options.host!==n.location.hostname||this.options.port!=e},o.prototype.onConnect=function(){this.connected||(this.connected=!0,this.connecting=!1,this.doBuffer||this.setBuffer(!1),this.emit("connect"))},o.prototype.onOpen=function(){this.open=!0},o.prototype.onClose=function(){this.open=!1},o.prototype.onPacket=function(e){this.of(e.endpoint).onPacket(e)},o.prototype.onError=function(e){e&&e.advice&&this.options.reconnect&&"reconnect"===e.advice&&this.connected&&(this.disconnect(),this.reconnect()),this.publish("error",e&&e.reason?e.reason:e)},o.prototype.onDisconnect=function(e){var t=this.connected;this.connected=!1,this.connecting=!1,this.open=!1,t&&(this.transport.close(),this.transport.clearTimeouts(),this.publish("disconnect",e),"booted"!=e&&this.options.reconnect&&!this.reconnecting&&this.reconnect())},o.prototype.reconnect=function(){function e(){if(n.connected){for(var e in n.namespaces)n.namespaces.hasOwnProperty(e)&&""!==e&&n.namespaces[e].packet({type:"connect"});n.publish("reconnect",n.transport.name,n.reconnectionAttempts)}clearTimeout(n.reconnectionTimer),n.removeListener("connect_failed",t),n.removeListener("connect",t),n.reconnecting=!1,delete n.reconnectionAttempts,delete n.reconnectionDelay,delete n.reconnectionTimer,delete n.redoTransports,n.options["try multiple transports"]=i}function t(){return n.reconnecting?n.connected?e():n.connecting&&n.reconnecting?n.reconnectionTimer=setTimeout(t,1e3):void(n.reconnectionAttempts++<o?(n.reconnectionDelay<r&&(n.reconnectionDelay*=2),n.connect(),n.publish("reconnecting",n.reconnectionDelay,n.reconnectionAttempts),n.reconnectionTimer=setTimeout(t,n.reconnectionDelay)):n.redoTransports?(n.publish("reconnect_failed"),e()):(n.on("connect_failed",t),n.options["try multiple transports"]=!0,n.transport=n.getTransport(),n.redoTransports=!0,n.connect())):void 0}this.reconnecting=!0,this.reconnectionAttempts=0,this.reconnectionDelay=this.options["reconnection delay"];var n=this,o=this.options["max reconnection attempts"],i=this.options["try multiple transports"],r=this.options["reconnection limit"];this.options["try multiple transports"]=!1,this.reconnectionTimer=setTimeout(t,this.reconnectionDelay),this.on("connect",t)}}("undefined"!=typeof io?io:module.exports,"undefined"!=typeof io?io:module.parent.exports,this),function(e,t){function n(e,t){this.socket=e,this.name=t||"",this.flags={},this.json=new o(this,"json"),this.ackPackets=0,this.acks={}}function o(e,t){this.namespace=e,this.name=t}e.SocketNamespace=n,t.util.mixin(n,t.EventEmitter),n.prototype.$emit=t.EventEmitter.prototype.emit,n.prototype.of=function(){return this.socket.of.apply(this.socket,arguments)},n.prototype.packet=function(e){return e.endpoint=this.name,this.socket.packet(e),this.flags={},this},n.prototype.send=function(e,t){var n={type:this.flags.json?"json":"message",data:e};return"function"==typeof t&&(n.id=++this.ackPackets,n.ack=!0,this.acks[n.id]=t),this.packet(n)},n.prototype.emit=function(e){var t=Array.prototype.slice.call(arguments,1),n=t[t.length-1],o={type:"event",name:e};return"function"==typeof n&&(o.id=++this.ackPackets,o.ack="data",this.acks[o.id]=n,t=t.slice(0,t.length-1)),o.args=t,this.packet(o)},n.prototype.disconnect=function(){return""===this.name?this.socket.disconnect():(this.packet({type:"disconnect"}),this.$emit("disconnect")),this},n.prototype.onPacket=function(e){function n(){i.packet({type:"ack",args:t.util.toArray(arguments),ackId:e.id})}var o,i=this;switch(e.type){case"connect":this.$emit("connect");break;case"disconnect":""===this.name?this.socket.onDisconnect(e.reason||"booted"):this.$emit("disconnect",e.reason);break;case"message":case"json":o=["message",e.data],"data"==e.ack?o.push(n):e.ack&&this.packet({type:"ack",ackId:e.id}),this.$emit.apply(this,o);break;case"event":o=[e.name].concat(e.args),"data"==e.ack&&o.push(n),this.$emit.apply(this,o);break;case"ack":this.acks[e.ackId]&&(this.acks[e.ackId].apply(this,e.args),delete this.acks[e.ackId]);break;case"error":e.advice?this.socket.onError(e):"unauthorized"==e.reason?this.$emit("connect_failed",e.reason):this.$emit("error",e.reason)}},o.prototype.send=function(){this.namespace.flags[this.name]=!0,this.namespace.send.apply(this.namespace,arguments)},o.prototype.emit=function(){this.namespace.flags[this.name]=!0,this.namespace.emit.apply(this.namespace,arguments)}}("undefined"!=typeof io?io:module.exports,"undefined"!=typeof io?io:module.parent.exports),function(e,t,n){function o(){t.Transport.apply(this,arguments)}e.websocket=o,t.util.inherit(o,t.Transport),o.prototype.name="websocket",o.prototype.open=function(){var e,o=t.util.query(this.socket.options.query),i=this;return e||(e=n.MozWebSocket||n.WebSocket),this.websocket=new e(this.prepareUrl()+o),this.websocket.onopen=function(){i.onOpen(),i.socket.setBuffer(!1)},this.websocket.onmessage=function(e){i.onData(e.data)},this.websocket.onclose=function(){i.onClose(),i.socket.setBuffer(!0)},this.websocket.onerror=function(e){i.onError(e)},this},o.prototype.send=function(e){return this.websocket.send(e),this},o.prototype.payload=function(e){for(var t=0,n=e.length;n>t;t++)this.packet(e[t]);return this},o.prototype.close=function(){return this.websocket.close(),this},o.prototype.onError=function(e){this.socket.onError(e)},o.prototype.scheme=function(){return this.socket.options.secure?"wss":"ws"},o.check=function(){return"WebSocket"in n&&!("__addTask"in WebSocket)||"MozWebSocket"in n},o.xdomainCheck=function(){return!0},t.transports.push("websocket")}("undefined"!=typeof io?io.Transport:module.exports,"undefined"!=typeof io?io:module.parent.exports,this),function(e,t){function n(){t.Transport.websocket.apply(this,arguments)}e.flashsocket=n,t.util.inherit(n,t.Transport.websocket),n.prototype.name="flashsocket",n.prototype.open=function(){var e=this,n=arguments;return WebSocket.__addTask(function(){t.Transport.websocket.prototype.open.apply(e,n)}),this},n.prototype.send=function(){var e=this,n=arguments;return WebSocket.__addTask(function(){t.Transport.websocket.prototype.send.apply(e,n)}),this},n.prototype.close=function(){return WebSocket.__tasks.length=0,t.Transport.websocket.prototype.close.call(this),this},n.prototype.ready=function(e,o){function i(){var t=e.options,i=t["flash policy port"],s=["http"+(t.secure?"s":"")+":/",t.host+":"+t.port,t.resource,"static/flashsocket","WebSocketMain"+(e.isXDomain()?"Insecure":"")+".swf"];n.loaded||("undefined"==typeof WEB_SOCKET_SWF_LOCATION&&(WEB_SOCKET_SWF_LOCATION=s.join("/")),843!==i&&WebSocket.loadFlashPolicyFile("xmlsocket://"+t.host+":"+i),WebSocket.__initialize(),n.loaded=!0),o.call(r)}var r=this;return document.body?i():void t.util.load(i)},n.check=function(){return"undefined"!=typeof WebSocket&&"__initialize"in WebSocket&&swfobject?swfobject.getFlashPlayerVersion().major>=10:!1},n.xdomainCheck=function(){return!0},"undefined"!=typeof window&&(WEB_SOCKET_DISABLE_AUTO_INITIALIZATION=!0),t.transports.push("flashsocket")}("undefined"!=typeof io?io.Transport:module.exports,"undefined"!=typeof io?io:module.parent.exports),"undefined"!=typeof window)var swfobject=function(){function e(){var e,t,n;if(!H){try{e=B.getElementsByTagName("body")[0].appendChild(m("span")),e.parentNode.removeChild(e)}catch(o){return}for(H=!0,t=R.length,n=0;t>n;n++)R[n]()}}function t(e){H?e():R[R.length]=e}function n(e){if(typeof D.addEventListener!=W)D.addEventListener("load",e,!1);else if(typeof B.addEventListener!=W)B.addEventListener("load",e,!1);else if(typeof D.attachEvent!=W)v(D,"onload",e);else if("function"==typeof D.onload){var t=D.onload;D.onload=function(){t(),e()}}else D.onload=e}function o(){P?i():r()}function i(){var e,t,n=B.getElementsByTagName("body")[0],o=m(O);o.setAttribute("type",N),e=n.appendChild(o),e?(t=0,function(){if(typeof e.GetVariable!=W){var i=e.GetVariable("$version");i&&(i=i.split(" ")[1].split(","),G.pv=[parseInt(i[0],10),parseInt(i[1],10),parseInt(i[2],10)])}else if(10>t)return t++,void setTimeout(arguments.callee,10);n.removeChild(o),e=null,r()}()):r()}function r(){var e,t,n,o,i,r=F.length;if(r>0)for(e=0;r>e;e++){var u=F[e].id,l=F[e].callbackFn,h={success:!1,id:u};if(G.pv[0]>0){if(t=y(u))if(!k(F[e].swfVersion)||G.wk&&G.wk<312)if(F[e].expressInstall&&a()){n={},n.data=F[e].expressInstall,n.width=t.getAttribute("width")||"0",n.height=t.getAttribute("height")||"0",t.getAttribute("class")&&(n.styleclass=t.getAttribute("class")),t.getAttribute("align")&&(n.align=t.getAttribute("align"));var f={},d=t.getElementsByTagName("param"),m=d.length;for(o=0;m>o;o++)"movie"!=d[o].getAttribute("name").toLowerCase()&&(f[d[o].getAttribute("name")]=d[o].getAttribute("value"));c(n,f,u,l)}else p(t),l&&l(h);else g(u,!0),l&&(h.success=!0,h.ref=s(u),l(h))}else g(u,!0),l&&(i=s(u),i&&typeof i.SetVariable!=W&&(h.success=!0,h.ref=i),l(h))}}function s(e){var t,n=null,o=y(e);return o&&"OBJECT"==o.nodeName&&(typeof o.SetVariable!=W?n=o:(t=o.getElementsByTagName(O)[0],t&&(n=t))),n}function a(){return!M&&k("6.0.65")&&(G.win||G.mac)&&!(G.wk&&G.wk<312)}function c(e,t,n,o){var i,r,s,a;M=!0,_=o||null,E={success:!1,id:n},i=y(n),i&&("OBJECT"==i.nodeName?(S=u(i),T=null):(S=i,T=n),e.id=j,(typeof e.width==W||!/%$/.test(e.width)&&parseInt(e.width,10)<310)&&(e.width="310"),(typeof e.height==W||!/%$/.test(e.height)&&parseInt(e.height,10)<137)&&(e.height="137"),B.title=B.title.slice(0,47)+" - Flash Player Installation",r=G.ie&&G.win?"ActiveX":"PlugIn",s="MMredirectURL="+D.location.toString().replace(/&/g,"%26")+"&MMplayerType="+r+"&MMdoctitle="+B.title,typeof t.flashvars!=W?t.flashvars+="&"+s:t.flashvars=s,G.ie&&G.win&&4!=i.readyState&&(a=m("div"),n+="SWFObjectNew",a.setAttribute("id",n),i.parentNode.insertBefore(a,i),i.style.display="none",function(){4==i.readyState?i.parentNode.removeChild(i):setTimeout(arguments.callee,10)}()),l(e,t,n))}function p(e){if(G.ie&&G.win&&4!=e.readyState){var t=m("div");e.parentNode.insertBefore(t,e),t.parentNode.replaceChild(u(e),t),e.style.display="none",function(){4==e.readyState?e.parentNode.removeChild(e):setTimeout(arguments.callee,10)}()}else e.parentNode.replaceChild(u(e),e)}function u(e){var t,n,o,i,r=m("div");if(G.win&&G.ie)r.innerHTML=e.innerHTML;else if(t=e.getElementsByTagName(O)[0],t&&(n=t.childNodes))for(o=n.length,i=0;o>i;i++)1==n[i].nodeType&&"PARAM"==n[i].nodeName||8==n[i].nodeType||r.appendChild(n[i].cloneNode(!0));return r}function l(e,t,n){var o,i,r,s,a,c,p,u,l=y(n);if(G.wk&&G.wk<312)return o;if(l)if(typeof e.id==W&&(e.id=n),G.ie&&G.win){i="";for(r in e)e[r]!=Object.prototype[r]&&("data"==r.toLowerCase()?t.movie=e[r]:"styleclass"==r.toLowerCase()?i+=' class="'+e[r]+'"':"classid"!=r.toLowerCase()&&(i+=" "+r+'="'+e[r]+'"'));s="";for(a in t)t[a]!=Object.prototype[a]&&(s+='<param name="'+a+'" value="'+t[a]+'" />');l.outerHTML='<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"'+i+">"+s+"</object>",q[q.length]=e.id,o=y(e.id)}else{c=m(O),c.setAttribute("type",N);for(p in e)e[p]!=Object.prototype[p]&&("styleclass"==p.toLowerCase()?c.setAttribute("class",e[p]):"classid"!=p.toLowerCase()&&c.setAttribute(p,e[p]));for(u in t)t[u]!=Object.prototype[u]&&"movie"!=u.toLowerCase()&&h(c,u,t[u]);l.parentNode.replaceChild(c,l),o=c}return o}function h(e,t,n){var o=m("param");o.setAttribute("name",t),o.setAttribute("value",n),e.appendChild(o)}function f(e){var t=y(e);t&&"OBJECT"==t.nodeName&&(G.ie&&G.win?(t.style.display="none",function(){4==t.readyState?d(e):setTimeout(arguments.callee,10)}()):t.parentNode.removeChild(t))}function d(e){var t,n=y(e);if(n){for(t in n)"function"==typeof n[t]&&(n[t]=null);n.parentNode.removeChild(n)}}function y(e){var t=null;try{t=B.getElementById(e)}catch(n){}return t}function m(e){return B.createElement(e)}function v(e,t,n){e.attachEvent(t,n),X[X.length]=[e,t,n]}function k(e){var t=G.pv,n=e.split(".");return n[0]=parseInt(n[0],10),n[1]=parseInt(n[1],10)||0,n[2]=parseInt(n[2],10)||0,t[0]>n[0]||t[0]==n[0]&&t[1]>n[1]||t[0]==n[0]&&t[1]==n[1]&&t[2]>=n[2]}function b(e,t,n,o){var i,r,s;G.ie&&G.mac||(i=B.getElementsByTagName("head")[0],i&&(r=n&&"string"==typeof n?n:"screen",o&&(C=null,x=null),C&&x==r||(s=m("style"),s.setAttribute("type","text/css"),s.setAttribute("media",r),C=i.appendChild(s),G.ie&&G.win&&typeof B.styleSheets!=W&&B.styleSheets.length>0&&(C=B.styleSheets[B.styleSheets.length-1]),x=r),G.ie&&G.win?C&&typeof C.addRule==O&&C.addRule(e,t):C&&typeof B.createTextNode!=W&&C.appendChild(B.createTextNode(e+" {"+t+"}"))))}function g(e,t){if(U){var n=t?"visible":"hidden";H&&y(e)?y(e).style.visibility=n:b("#"+e,"visibility:"+n)}}function w(e){var t=/[\\\"<>\.;]/,n=null!=t.exec(e);return n&&typeof encodeURIComponent!=W?encodeURIComponent(e):e}var S,T,_,E,C,x,W="undefined",O="object",A="Shockwave Flash",I="ShockwaveFlash.ShockwaveFlash",N="application/x-shockwave-flash",j="SWFObjectExprInst",L="onreadystatechange",D=window,B=document,$=navigator,P=!1,R=[o],F=[],q=[],X=[],H=!1,M=!1,U=!0,G=function(){var e,t=typeof B.getElementById!=W&&typeof B.getElementsByTagName!=W&&typeof B.createElement!=W,n=$.userAgent.toLowerCase(),o=$.platform.toLowerCase(),i=/win/.test(o?o:n),r=/mac/.test(o?o:n),s=/webkit/.test(n)?parseFloat(n.replace(/^.*webkit\/(\d+(\.\d+)?).*$/,"$1")):!1,a=!1,c=[0,0,0],p=null;if(typeof $.plugins!=W&&typeof $.plugins[A]==O)p=$.plugins[A].description,!p||typeof $.mimeTypes!=W&&$.mimeTypes[N]&&!$.mimeTypes[N].enabledPlugin||(P=!0,a=!1,p=p.replace(/^.*\s+(\S+\s+\S+$)/,"$1"),c[0]=parseInt(p.replace(/^(.*)\..*$/,"$1"),10),c[1]=parseInt(p.replace(/^.*\.(.*)\s.*$/,"$1"),10),c[2]=/[a-zA-Z]/.test(p)?parseInt(p.replace(/^.*[a-zA-Z]+(.*)$/,"$1"),10):0);else if(typeof D.ActiveXObject!=W)try{e=new ActiveXObject(I),e&&(p=e.GetVariable("$version"),p&&(a=!0,p=p.split(" ")[1].split(","),c=[parseInt(p[0],10),parseInt(p[1],10),parseInt(p[2],10)]))}catch(u){}return{w3:t,pv:c,wk:s,ie:a,win:i,mac:r}}();return!function(){G.w3&&((typeof B.readyState!=W&&"complete"==B.readyState||typeof B.readyState==W&&(B.getElementsByTagName("body")[0]||B.body))&&e(),H||(typeof B.addEventListener!=W&&B.addEventListener("DOMContentLoaded",e,!1),G.ie&&G.win&&(B.attachEvent(L,function(){"complete"==B.readyState&&(B.detachEvent(L,arguments.callee),e())}),D==top&&function(){if(!H){try{B.documentElement.doScroll("left")}catch(t){return void setTimeout(arguments.callee,0)}e()}}()),G.wk&&function(){return H?void 0:/loaded|complete/.test(B.readyState)?void e():void setTimeout(arguments.callee,0)}(),n(e)))}(),function(){G.ie&&G.win&&window.attachEvent("onunload",function(){for(var e,t,n,o,i=X.length,r=0;i>r;r++)X[r][0].detachEvent(X[r][1],X[r][2]);for(e=q.length,t=0;e>t;t++)f(q[t]);for(n in G)G[n]=null;G=null;for(o in swfobject)swfobject[o]=null;swfobject=null})}(),{registerObject:function(e,t,n,o){if(G.w3&&e&&t){var i={};i.id=e,i.swfVersion=t,i.expressInstall=n,i.callbackFn=o,F[F.length]=i,g(e,!1)}else o&&o({success:!1,id:e})},getObjectById:function(e){return G.w3?s(e):void 0},embedSWF:function(e,n,o,i,r,s,p,u,h,f){var d={success:!1,id:n};G.w3&&!(G.wk&&G.wk<312)&&e&&n&&o&&i&&r?(g(n,!1),t(function(){var t,y,m,v,b,w;if(o+="",i+="",t={},h&&typeof h===O)for(y in h)t[y]=h[y];if(t.data=e,t.width=o,t.height=i,m={},u&&typeof u===O)for(v in u)m[v]=u[v];if(p&&typeof p===O)for(b in p)typeof m.flashvars!=W?m.flashvars+="&"+b+"="+p[b]:m.flashvars=b+"="+p[b];if(k(r))w=l(t,m,n),t.id==n&&g(n,!0),d.success=!0,d.ref=w;else{if(s&&a())return t.data=s,void c(t,m,n,f);g(n,!0)}f&&f(d)})):f&&f(d)},switchOffAutoHideShow:function(){U=!1},ua:G,getFlashPlayerVersion:function(){return{major:G.pv[0],minor:G.pv[1],release:G.pv[2]}},hasFlashPlayerVersion:k,createSWF:function(e,t,n){return G.w3?l(e,t,n):void 0},showExpressInstall:function(e,t,n,o){G.w3&&a()&&c(e,t,n,o)},removeSWF:function(e){G.w3&&f(e)},createCSS:function(e,t,n,o){G.w3&&b(e,t,n,o)},addDomLoadEvent:t,addLoadEvent:n,getQueryParamValue:function(e){var t,n,o=B.location.search||B.location.hash;if(o){if(/\?/.test(o)&&(o=o.split("?")[1]),null==e)return w(o);for(t=o.split("&"),n=0;n<t.length;n++)if(t[n].substring(0,t[n].indexOf("="))==e)return w(t[n].substring(t[n].indexOf("=")+1))}return""},expressInstallCallback:function(){if(M){var e=y(j);e&&S&&(e.parentNode.replaceChild(S,e),T&&(g(T,!0),G.ie&&G.win&&(S.style.display="block")),_&&_(E)),M=!1}}}}();!function(){if("undefined"!=typeof window&&!window.WebSocket){var e=window.console;return e&&e.log&&e.error||(e={log:function(){},error:function(){}}),swfobject.hasFlashPlayerVersion("10.0.0")?("file:"==location.protocol&&e.error("WARNING: web-socket-js doesn't work in file:///... URL unless you set Flash Security Settings properly. Open the page via Web server i.e. http://..."),WebSocket=function(e,t,n,o,i){var r=this;r.__id=WebSocket.__nextId++,WebSocket.__instances[r.__id]=r,r.readyState=WebSocket.CONNECTING,r.bufferedAmount=0,r.__events={},t?"string"==typeof t&&(t=[t]):t=[],setTimeout(function(){WebSocket.__addTask(function(){WebSocket.__flash.create(r.__id,e,t,n||null,o||0,i||null)})},0)},WebSocket.prototype.send=function(e){if(this.readyState==WebSocket.CONNECTING)throw"INVALID_STATE_ERR: Web Socket connection has not been established";var t=WebSocket.__flash.send(this.__id,encodeURIComponent(e));return 0>t?!0:(this.bufferedAmount+=t,
!1)},WebSocket.prototype.close=function(){this.readyState!=WebSocket.CLOSED&&this.readyState!=WebSocket.CLOSING&&(this.readyState=WebSocket.CLOSING,WebSocket.__flash.close(this.__id))},WebSocket.prototype.addEventListener=function(e,t){e in this.__events||(this.__events[e]=[]),this.__events[e].push(t)},WebSocket.prototype.removeEventListener=function(e,t){var n,o;if(e in this.__events)for(n=this.__events[e],o=n.length-1;o>=0;--o)if(n[o]===t){n.splice(o,1);break}},WebSocket.prototype.dispatchEvent=function(e){for(var t,n=this.__events[e.type]||[],o=0;o<n.length;++o)n[o](e);t=this["on"+e.type],t&&t(e)},WebSocket.prototype.__handleEvent=function(e){var t,n;if("readyState"in e&&(this.readyState=e.readyState),"protocol"in e&&(this.protocol=e.protocol),"open"==e.type||"error"==e.type)t=this.__createSimpleEvent(e.type);else if("close"==e.type)t=this.__createSimpleEvent("close");else{if("message"!=e.type)throw"unknown event type: "+e.type;n=decodeURIComponent(e.message),t=this.__createMessageEvent("message",n)}this.dispatchEvent(t)},WebSocket.prototype.__createSimpleEvent=function(e){if(document.createEvent&&window.Event){var t=document.createEvent("Event");return t.initEvent(e,!1,!1),t}return{type:e,bubbles:!1,cancelable:!1}},WebSocket.prototype.__createMessageEvent=function(e,t){if(document.createEvent&&window.MessageEvent&&!window.opera){var n=document.createEvent("MessageEvent");return n.initMessageEvent("message",!1,!1,t,null,null,window,null),n}return{type:e,data:t,bubbles:!1,cancelable:!1}},WebSocket.CONNECTING=0,WebSocket.OPEN=1,WebSocket.CLOSING=2,WebSocket.CLOSED=3,WebSocket.__flash=null,WebSocket.__instances={},WebSocket.__tasks=[],WebSocket.__nextId=0,WebSocket.loadFlashPolicyFile=function(e){WebSocket.__addTask(function(){WebSocket.__flash.loadManualPolicyFile(e)})},WebSocket.__initialize=function(){var t,n;return WebSocket.__flash?void 0:(WebSocket.__swfLocation&&(window.WEB_SOCKET_SWF_LOCATION=WebSocket.__swfLocation),window.WEB_SOCKET_SWF_LOCATION?(t=document.createElement("div"),t.id="webSocketContainer",t.style.position="absolute",WebSocket.__isFlashLite()?(t.style.left="0px",t.style.top="0px"):(t.style.left="-100px",t.style.top="-100px"),n=document.createElement("div"),n.id="webSocketFlash",t.appendChild(n),document.body.appendChild(t),void swfobject.embedSWF(WEB_SOCKET_SWF_LOCATION,"webSocketFlash","1","1","10.0.0",null,null,{hasPriority:!0,swliveconnect:!0,allowScriptAccess:"always"},null,function(t){t.success||e.error("[WebSocket] swfobject.embedSWF failed")})):void e.error("[WebSocket] set WEB_SOCKET_SWF_LOCATION to location of WebSocketMain.swf"))},WebSocket.__onFlashInitialized=function(){setTimeout(function(){WebSocket.__flash=document.getElementById("webSocketFlash"),WebSocket.__flash.setCallerUrl(location.href),WebSocket.__flash.setDebug(!!window.WEB_SOCKET_DEBUG);for(var e=0;e<WebSocket.__tasks.length;++e)WebSocket.__tasks[e]();WebSocket.__tasks=[]},0)},WebSocket.__onFlashEvent=function(){return setTimeout(function(){var t,n;try{for(t=WebSocket.__flash.receiveEvents(),n=0;n<t.length;++n)WebSocket.__instances[t[n].webSocketId].__handleEvent(t[n])}catch(o){e.error(o)}},0),!0},WebSocket.__log=function(t){e.log(decodeURIComponent(t))},WebSocket.__error=function(t){e.error(decodeURIComponent(t))},WebSocket.__addTask=function(e){WebSocket.__flash?e():WebSocket.__tasks.push(e)},WebSocket.__isFlashLite=function(){if(!window.navigator||!window.navigator.mimeTypes)return!1;var e=window.navigator.mimeTypes["application/x-shockwave-flash"];return!!(e&&e.enabledPlugin&&e.enabledPlugin.filename&&e.enabledPlugin.filename.match(/flashlite/i))},void(window.WEB_SOCKET_DISABLE_AUTO_INITIALIZATION||(window.addEventListener?window.addEventListener("load",function(){WebSocket.__initialize()},!1):window.attachEvent("onload",function(){WebSocket.__initialize()})))):void e.error("Flash Player >= 10.0.0 is required.")}}(),function(e,t,n){function o(e){e&&(t.Transport.apply(this,arguments),this.sendBuffer=[])}function i(){}e.XHR=o,t.util.inherit(o,t.Transport),o.prototype.open=function(){return this.socket.setBuffer(!1),this.onOpen(),this.get(),this.setCloseTimeout(),this},o.prototype.payload=function(e){for(var n=[],o=0,i=e.length;i>o;o++)n.push(t.parser.encodePacket(e[o]));this.send(t.parser.encodePayload(n))},o.prototype.send=function(e){return this.post(e),this},o.prototype.post=function(e){function t(){4==this.readyState&&(this.onreadystatechange=i,r.posting=!1,200==this.status?r.socket.setBuffer(!1):r.onClose())}function o(){this.onload=i,r.socket.setBuffer(!1)}var r=this;this.socket.setBuffer(!0),this.sendXHR=this.request("POST"),n.XDomainRequest&&this.sendXHR instanceof XDomainRequest?this.sendXHR.onload=this.sendXHR.onerror=o:this.sendXHR.onreadystatechange=t,this.sendXHR.send(e)},o.prototype.close=function(){return this.onClose(),this},o.prototype.request=function(e){var n=t.util.request(this.socket.isXDomain()),o=t.util.query(this.socket.options.query,"t="+ +new Date);if(n.open(e||"GET",this.prepareUrl()+o,!0),"POST"==e)try{n.setRequestHeader?n.setRequestHeader("Content-type","text/plain;charset=UTF-8"):n.contentType="text/plain"}catch(i){}return n},o.prototype.scheme=function(){return this.socket.options.secure?"https":"http"},o.check=function(e,n){try{if(t.util.request(n))return!0}catch(o){}return!1},o.xdomainCheck=function(){return o.check(null,!0)}}("undefined"!=typeof io?io.Transport:module.exports,"undefined"!=typeof io?io:module.parent.exports,this),function(e,t){function n(){t.Transport.XHR.apply(this,arguments)}e.htmlfile=n,t.util.inherit(n,t.Transport.XHR),n.prototype.name="htmlfile",n.prototype.get=function(){var e,n,o;this.doc=new ActiveXObject("htmlfile"),this.doc.open(),this.doc.write("<html></html>"),this.doc.close(),this.doc.parentWindow.s=this,e=this.doc.createElement("div"),e.className="socketio",this.doc.body.appendChild(e),this.iframe=this.doc.createElement("iframe"),e.appendChild(this.iframe),n=this,o=t.util.query(this.socket.options.query,"t="+ +new Date),this.iframe.src=this.prepareUrl()+o,t.util.on(window,"unload",function(){n.destroy()})},n.prototype._=function(e,t){this.onData(e);try{var n=t.getElementsByTagName("script")[0];n.parentNode.removeChild(n)}catch(o){}},n.prototype.destroy=function(){if(this.iframe){try{this.iframe.src="about:blank"}catch(e){}this.doc=null,this.iframe.parentNode.removeChild(this.iframe),this.iframe=null,CollectGarbage()}},n.prototype.close=function(){return this.destroy(),t.Transport.XHR.prototype.close.call(this)},n.check=function(){if("undefined"!=typeof window&&"ActiveXObject"in window)try{var e=new ActiveXObject("htmlfile");return e&&t.Transport.XHR.check()}catch(n){}return!1},n.xdomainCheck=function(){return!1},t.transports.push("htmlfile")}("undefined"!=typeof io?io.Transport:module.exports,"undefined"!=typeof io?io:module.parent.exports),function(e,t,n){function o(){t.Transport.XHR.apply(this,arguments)}function i(){}e["xhr-polling"]=o,t.util.inherit(o,t.Transport.XHR),t.util.merge(o,t.Transport.XHR),o.prototype.name="xhr-polling",o.prototype.open=function(){var e=this;return t.Transport.XHR.prototype.open.call(e),!1},o.prototype.get=function(){function e(){4==this.readyState&&(this.onreadystatechange=i,200==this.status?(r.onData(this.responseText),r.get()):r.onClose())}function t(){this.onload=i,this.onerror=i,r.onData(this.responseText),r.get()}function o(){r.onClose()}if(this.open){var r=this;this.xhr=this.request(),n.XDomainRequest&&this.xhr instanceof XDomainRequest?(this.xhr.onload=t,this.xhr.onerror=o):this.xhr.onreadystatechange=e,this.xhr.send(null)}},o.prototype.onClose=function(){if(t.Transport.XHR.prototype.onClose.call(this),this.xhr){this.xhr.onreadystatechange=this.xhr.onload=this.xhr.onerror=i;try{this.xhr.abort()}catch(e){}this.xhr=null}},o.prototype.ready=function(e,n){var o=this;t.util.defer(function(){n.call(o)})},t.transports.push("xhr-polling")}("undefined"!=typeof io?io.Transport:module.exports,"undefined"!=typeof io?io:module.parent.exports,this),function(e,t,n){function o(){t.Transport["xhr-polling"].apply(this,arguments),this.index=t.j.length;var e=this;t.j.push(function(t){e._(t)})}var i=n.document&&"MozAppearance"in n.document.documentElement.style;e["jsonp-polling"]=o,t.util.inherit(o,t.Transport["xhr-polling"]),o.prototype.name="jsonp-polling",o.prototype.post=function(e){function n(){o(),i.socket.setBuffer(!1)}function o(){i.iframe&&i.form.removeChild(i.iframe);try{s=document.createElement('<iframe name="'+i.iframeId+'">')}catch(e){s=document.createElement("iframe"),s.name=i.iframeId}s.id=i.iframeId,i.form.appendChild(s),i.iframe=s}var i=this,r=t.util.query(this.socket.options.query,"t="+ +new Date+"&i="+this.index);if(!this.form){var s,a=document.createElement("form"),c=document.createElement("textarea"),p=this.iframeId="socketio_iframe_"+this.index;a.className="socketio",a.style.position="absolute",a.style.top="-1000px",a.style.left="-1000px",a.target=p,a.method="POST",a.setAttribute("accept-charset","utf-8"),c.name="d",a.appendChild(c),document.body.appendChild(a),this.form=a,this.area=c}this.form.action=this.prepareUrl()+r,o(),this.area.value=t.JSON.stringify(e);try{this.form.submit()}catch(u){}this.iframe.attachEvent?s.onreadystatechange=function(){"complete"==i.iframe.readyState&&n()}:this.iframe.onload=n,this.socket.setBuffer(!0)},o.prototype.get=function(){var e,n=this,o=document.createElement("script"),r=t.util.query(this.socket.options.query,"t="+ +new Date+"&i="+this.index);this.script&&(this.script.parentNode.removeChild(this.script),this.script=null),o.async=!0,o.src=this.prepareUrl()+r,o.onerror=function(){n.onClose()},e=document.getElementsByTagName("script")[0],e.parentNode.insertBefore(o,e),this.script=o,i&&setTimeout(function(){var e=document.createElement("iframe");document.body.appendChild(e),document.body.removeChild(e)},100)},o.prototype._=function(e){return this.onData(e),this.open&&this.get(),this},o.prototype.ready=function(e,n){var o=this;return i?void t.util.load(function(){n.call(o)}):n.call(this)},o.check=function(){return"document"in n},o.xdomainCheck=function(){return!0},t.transports.push("jsonp-polling")}("undefined"!=typeof io?io.Transport:module.exports,"undefined"!=typeof io?io:module.parent.exports,this);
!function(){function g(t){throw t}function aa(t){return function(){return this[t]}}function p(t){return function(){return t}}function ca(t,e){var n=t.split("."),i=ba;!(n[0]in i)&&i.execScript&&i.execScript("var "+n[0]);for(var r;n.length&&(r=n.shift());)!n.length&&s(e)?i[r]=e:i=i[r]?i[r]:i[r]={}}function da(){}function ea(t){var e=typeof t;if("object"==e){if(!t)return"null";if(t instanceof Array)return"array";if(t instanceof Object)return e;var n=Object.prototype.toString.call(t);if("[object Window]"==n)return"object";if("[object Array]"==n||"number"==typeof t.length&&"undefined"!=typeof t.splice&&"undefined"!=typeof t.propertyIsEnumerable&&!t.propertyIsEnumerable("splice"))return"array";if("[object Function]"==n||"undefined"!=typeof t.call&&"undefined"!=typeof t.propertyIsEnumerable&&!t.propertyIsEnumerable("call"))return"function"}else if("function"==e&&"undefined"==typeof t.call)return"object";return e}function s(t){return t!==j}function fa(t){var e=ea(t);return"array"==e||"object"==e&&"number"==typeof t.length}function t(t){return"string"==typeof t}function ga(t){return"number"==typeof t}function ha(t){var e=typeof t;return"object"==e&&t!=l||"function"==e}function ia(t,e,n){return t.call.apply(t.bind,arguments)}function ja(t,e,n){if(t||g(Error()),2<arguments.length){var i=Array.prototype.slice.call(arguments,2);return function(){var n=Array.prototype.slice.call(arguments);return Array.prototype.unshift.apply(n,i),t.apply(e,n)}}return function(){return t.apply(e,arguments)}}function u(t,e,n){return u=Function.prototype.bind&&-1!=Function.prototype.bind.toString().indexOf("native code")?ia:ja,u.apply(l,arguments)}function ka(t,e){function n(){}n.prototype=e.prototype,t.Jd=e.prototype,t.prototype=new n}function la(a){if(a=String(a),/^\s*$/.test(a)?0:/^[\],:{}\s\u2028\u2029]*$/.test(a.replace(/\\["\\\/bfnrtu]/g,"@").replace(/"[^"\\\n\r\u2028\u2029\x00-\x08\x10-\x1f\x80-\x9f]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g,"]").replace(/(?:^|:|,)(?:[\s\u2028\u2029]*\[)+/g,"")))try{return eval("("+a+")")}catch(b){}g(Error("Invalid JSON string: "+a))}function ma(){this.Xb=j}function na(t,e,n){switch(typeof e){case"string":oa(e,n);break;case"number":n.push(isFinite(e)&&!isNaN(e)?e:"null");break;case"boolean":n.push(e);break;case"undefined":n.push("null");break;case"object":if(e==l){n.push("null");break}if("array"==ea(e)){var i=e.length;n.push("[");for(var r="",o=0;i>o;o++)n.push(r),r=e[o],na(t,t.Xb?t.Xb.call(e,String(o),r):r,n),r=",";n.push("]");break}n.push("{"),i="";for(o in e)Object.prototype.hasOwnProperty.call(e,o)&&(r=e[o],"function"!=typeof r&&(n.push(i),oa(o,n),n.push(":"),na(t,t.Xb?t.Xb.call(e,o,r):r,n),i=","));n.push("}");break;case"function":break;default:g(Error("Unknown type: "+typeof e))}}function oa(t,e){e.push('"',t.replace(qa,function(t){if(t in pa)return pa[t];var e=t.charCodeAt(0),n="\\u";return 16>e?n+="000":256>e?n+="00":4096>e&&(n+="0"),pa[t]=n+e.toString(16)}),'"')}function y(t){if("undefined"!=typeof JSON&&s(JSON.stringify))t=JSON.stringify(t);else{var e=[];na(new ma,t,e),t=e.join("")}return t}function ra(t){for(var e=[],n=0,i=0;i<t.length;i++){var r=t.charCodeAt(i);r>=55296&&56319>=r&&(r-=55296,i++,z(i<t.length,"Surrogate pair missing trail surrogate."),r=65536+(r<<10)+(t.charCodeAt(i)-56320)),128>r?e[n++]=r:(2048>r?e[n++]=r>>6|192:(65536>r?e[n++]=r>>12|224:(e[n++]=r>>18|240,e[n++]=r>>12&63|128),e[n++]=r>>6&63|128),e[n++]=63&r|128)}return e}function A(t,e,n,i){var r;e>i?r="at least "+e:i>n&&(r=0===n?"none":"no more than "+n),r&&g(Error(t+" failed: Was called with "+i+(1===i?" argument.":" arguments.")+" Expects "+r+"."))}function B(t,e,n){var i="";switch(e){case 1:i=n?"first":"First";break;case 2:i=n?"second":"Second";break;case 3:i=n?"third":"Third";break;case 4:i=n?"fourth":"Fourth";break;default:sa.assert(o,"errorPrefix_ called with argumentNumber > 4. Need to update it?")}return t+" failed: "+(i+" argument ")}function C(t,e,n,i){(!i||s(n))&&"function"!=ea(n)&&g(Error(B(t,e,i)+"must be a valid function."))}function ta(t,e,n){s(n)&&(!ha(n)||n===l)&&g(Error(B(t,e,k)+"must be a valid context object."))}function D(t,e){return Object.prototype.hasOwnProperty.call(t,e)}function ua(t,e){return Object.prototype.hasOwnProperty.call(t,e)?t[e]:void 0}function ya(e){return t(e)&&0!==e.length&&!wa.test(e)}function za(t,e,n){(!n||s(e))&&Aa(B(t,1,n),e)}function Aa(e,n,i,r){if(i||(i=0),r||(r=[]),s(n)||g(Error(e+"contains undefined"+Ba(r))),"function"==ea(n)&&g(Error(e+"contains a function"+Ba(r))),Ca(n)&&g(Error(e+"contains "+n.toString()+Ba(r))),i>1e3&&g(new TypeError(e+"contains a cyclic object value ("+r.slice(0,100).join(".")+"...)")),t(n)&&n.length>10485760/3&&10485760<va.Kd.Id(n).length&&g(Error(e+"contains a string greater than 10485760 utf8 bytes"+Ba(r)+" ('"+n.substring(0,50)+"...')")),ha(n))for(var o in n)D(n,o)&&(".priority"!==o&&".value"!==o&&!ya(o)&&g(Error(e+"contains an invalid key ("+o+")"+Ba(r)+'. Keys must be non-empty strings and can\'t contain ".", "#", "$", "/", "[", or "]"')),r.push(o),Aa(e,n[o],i+1,r),r.pop())}function Ba(t){return 0==t.length?"":" in property "+t.join(".")}function Da(t,e){ha(e)||g(Error(B(t,1,o)+" must be an object containing the children to replace.")),za(t,e,o)}function Ea(e,n,i,r){(!r||s(i))&&i!==l&&!ga(i)&&!t(i)&&g(Error(B(e,n,r)+"must be a valid firebase priority (null or a string.)"))}function Fa(t,e,n){if(!n||s(e))switch(e){case"value":case"child_added":case"child_removed":case"child_changed":case"child_moved":break;default:g(Error(B(t,1,n)+'must be a valid event type: "value", "child_added", "child_removed", "child_changed", or "child_moved".'))}}function Ga(t,e){s(e)&&!ya(e)&&g(Error(B(t,2,k)+'must be a valid firebase key (non-empty string, not containing ".", "#", "$", "/", "[", or "]").'))}function Ha(e,n){(!t(n)||0===n.length||xa.test(n))&&g(Error(B(e,1,o)+'must be a non-empty string and can\'t contain ".", "#", "$", "[", or "]".'))}function E(t,e){".info"===F(e)&&g(Error(t+" failed: Can't modify data under /.info/"))}function G(t,e,n,i,r,o,a){this.o=t,this.path=e,this.ta=n,this.Z=i,this.la=r,this.ra=o,this.Pa=a,s(this.Z)&&s(this.ra)&&s(this.ta)&&g("Query: Can't combine startAt(), endAt(), and limit().")}function Ja(t){var e={};return s(t.Z)&&(e.sp=t.Z),s(t.la)&&(e.sn=t.la),s(t.ra)&&(e.ep=t.ra),s(t.Pa)&&(e.en=t.Pa),s(t.ta)&&(e.l=t.ta),s(t.Z)&&s(t.la)&&t.Z===l&&t.la===l&&(e.vf="l"),e}function Ia(t,e,n){var i={};return e&&n?(i.cancel=e,C(t,3,i.cancel,k),i.W=n,ta(t,4,i.W)):e&&("object"==typeof e&&e!==l?i.W=e:"function"==typeof e?i.cancel=e:g(Error(B(t,3,k)+"must either be a cancel callback or a context object."))),i}function I(t){if(t instanceof I)return t;if(1==arguments.length){this.m=t.split("/");for(var e=0,n=0;n<this.m.length;n++)0<this.m[n].length&&(this.m[e]=this.m[n],e++);this.m.length=e,this.X=0}else this.m=arguments[0],this.X=arguments[1]}function F(t){return t.X>=t.m.length?l:t.m[t.X]}function La(t){var e=t.X;return e<t.m.length&&e++,new I(t.m,e)}function Ma(t){return t.X<t.m.length?t.m[t.m.length-1]:l}function Na(t,e){var n=F(t);return n===l?e:n===F(e)?Na(La(t),La(e)):void g("INTERNAL ERROR: innerPath ("+e+") is not within outerPath ("+t+")")}function Oa(){this.children={},this.hc=0,this.value=l}function Ra(t,e,n){this.ua=t?t:"",this.ob=e?e:l,this.u=n?n:new Oa}function J(t,e){for(var n,i=e instanceof I?e:new I(e),r=t;(n=F(i))!==l;)r=new Ra(n,r,ua(r.u.children,n)||new Oa),i=La(i);return r}function M(t,e){z("undefined"!=typeof e),t.u.value=e,Sa(t)}function Ta(t,e,n,i){n&&!i&&e(t),t.B(function(t){Ta(t,e,k,i)}),n&&i&&e(t)}function Ua(t,e,n){for(t=n?t:t.parent();t!==l;){if(e(t))return k;t=t.parent()}return o}function Sa(t){if(t.ob!==l){var e=t.ob,n=t.ua,i=t.f(),r=D(e.u.children,n);i&&r?(delete e.u.children[n],e.u.hc--,Sa(e)):!i&&!r&&(e.u.children[n]=t.u,e.u.hc++,Sa(e))}}function Va(t,e){this.Ma=t?t:Wa,this.Y=e?e:Xa}function Wa(t,e){return e>t?-1:t>e?1:0}function Ya(t,e){for(var n,i=t.Y,r=l;!i.f();){if(n=t.Ma(e,i.key),0===n){if(i.left.f())return r?r.key:l;for(i=i.left;!i.right.f();)i=i.right;return i.key}0>n?i=i.left:n>0&&(r=i,i=i.right)}g(Error("Attempted to find predecessor key for a nonexistent key. What gives?"))}function Za(t,e){for(this.Wc=e,this.Gb=[];!t.f();)this.Gb.push(t),t=t.left}function $a(t){if(0===t.Gb.length)return l;var e,n=t.Gb.pop();for(e=t.Wc?t.Wc(n.key,n.value):{key:n.key,value:n.value},n=n.right;!n.f();)t.Gb.push(n),n=n.left;return e}function ab(t,e,n,i,r){this.key=t,this.value=e,this.color=n!=l?n:k,this.left=i!=l?i:Xa,this.right=r!=l?r:Xa}function bb(t){return t.left.f()?t:bb(t.left)}function db(t){return t.left.f()?Xa:(!t.left.H()&&!t.left.left.H()&&(t=eb(t)),t=t.copy(l,l,l,db(t.left),l),cb(t))}function cb(t){return t.right.H()&&!t.left.H()&&(t=ib(t)),t.left.H()&&t.left.left.H()&&(t=gb(t)),t.left.H()&&t.right.H()&&(t=hb(t)),t}function eb(t){return t=hb(t),t.right.left.H()&&(t=t.copy(l,l,l,l,gb(t.right)),t=ib(t),t=hb(t)),t}function ib(t){var e;return e=t.copy(l,l,k,l,t.right.left),t.right.copy(l,l,t.color,e,l)}function gb(t){var e;return e=t.copy(l,l,k,t.left.right,l),t.left.copy(l,l,t.color,l,e)}function hb(t){var e,n;return e=t.left.copy(l,l,!t.left.color,l,l),n=t.right.copy(l,l,!t.right.color,l,l),t.copy(l,l,!t.color,e,n)}function jb(){}function nb(){}function ob(){this.z=[],this.gc=[],this.hd=[],this.Ob=[],this.Ob[0]=128;for(var t=1;64>t;++t)this.Ob[t]=0;this.reset()}function pb(t,e){var n;n||(n=0);for(var i=t.hd,r=n;n+64>r;r+=4)i[r/4]=e[r]<<24|e[r+1]<<16|e[r+2]<<8|e[r+3];for(r=16;80>r;r++){var o=i[r-3]^i[r-8]^i[r-14]^i[r-16];i[r]=4294967295&(o<<1|o>>>31)}n=t.z[0];for(var a,s=t.z[1],c=t.z[2],h=t.z[3],u=t.z[4],r=0;80>r;r++)40>r?20>r?(o=h^s&(c^h),a=1518500249):(o=s^c^h,a=1859775393):60>r?(o=s&c|h&(s|c),a=2400959708):(o=s^c^h,a=3395469782),o=(n<<5|n>>>27)+o+u+a+i[r]&4294967295,u=h,h=c,c=4294967295&(s<<30|s>>>2),s=n,n=o;t.z[0]=t.z[0]+n&4294967295,t.z[1]=t.z[1]+s&4294967295,t.z[2]=t.z[2]+c&4294967295,t.z[3]=t.z[3]+h&4294967295,t.z[4]=t.z[4]+u&4294967295}function qb(){this.La={},this.length=0}function sb(t,e,n,i){this.host=t,this.Yb=e,this.jb=n,this.aa=i||N.getItem(t)||this.host}function tb(t,e){e!==t.aa&&(t.aa=e,"s-"===t.aa.substr(0,2)&&N.setItem(t.host,t.aa))}function yb(){return ba.navigator?ba.navigator.userAgent:l}function Ib(t,e){if(fa(t)||g(Error("encodeByteArray takes an array as a parameter")),!Gb){Gb={},Hb={};for(var n=0;65>n;n++)Gb[n]="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".charAt(n),Hb[n]="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_.".charAt(n)}for(var n=e?Hb:Gb,i=[],r=0;r<t.length;r+=3){var o=t[r],a=r+1<t.length,s=a?t[r+1]:0,c=r+2<t.length,h=c?t[r+2]:0,u=o>>2,o=(3&o)<<4|s>>4,s=(15&s)<<2|h>>6,h=63&h;c||(h=64,a||(s=64)),i.push(n[u],n[o],n[s],n[h])}return i.join("")}function z(t,e){t||g(Error("Firebase INTERNAL ASSERT FAILED:"+e))}function Lb(t){var e=ra(t),t=new ob;t.update(e);var e=[],n=8*t.Ac;56>t.eb?t.update(t.Ob,56-t.eb):t.update(t.Ob,64-(t.eb-56));for(var i=63;i>=56;i--)t.gc[i]=255&n,n/=256;for(pb(t,t.gc),i=n=0;5>i;i++)for(var r=24;r>=0;r-=8)e[n++]=t.z[i]>>r&255;return Ib(e)}function Mb(){for(var t="",e=0;e<arguments.length;e++)t=fa(arguments[e])?t+Mb.apply(l,arguments[e]):"object"==typeof arguments[e]?t+y(arguments[e]):t+arguments[e],t+=" ";return t}function Pb(){if(Ob===k&&(Ob=o,Nb===l&&"true"===N.getItem("logging_enabled")&&Qb(k)),Nb){var t=Mb.apply(l,arguments);Nb(t)}}function Sb(t){return function(){Pb(t,arguments)}}function Tb(){if("undefined"!=typeof console){var t="FIREBASE INTERNAL ERROR: "+Mb.apply(l,arguments);"undefined"!=typeof console.error?console.error(t):console.log(t)}}function Ub(){var t=Mb.apply(l,arguments);g(Error("FIREBASE FATAL ERROR: "+t))}function Vb(){if("undefined"!=typeof console){var t="FIREBASE WARNING: "+Mb.apply(l,arguments);"undefined"!=typeof console.warn?console.warn(t):console.log(t)}}function Ca(t){return ga(t)&&(t!=t||t==Number.POSITIVE_INFINITY||t==Number.NEGATIVE_INFINITY)}function Wb(t,e){return t!==e?t===l?-1:e===l?1:typeof t!=typeof e?"number"==typeof t?-1:1:t>e?1:-1:0}function Xb(t,e){return e&&t in e?e[t]:void g(Error("Missing required key ("+t+") in object: "+y(e)))}function Ka(t){if("object"!=typeof t||t===l)return y(t);var e,n=[];for(e in t)n.push(e);n.sort(),e="{";for(var i=0;i<n.length;i++)0!==i&&(e+=","),e+=y(n[i]),e+=":",e+=Ka(t[n[i]]);return e+"}"}function Zb(t,e){if(t.length<=e)return[t];for(var n=[],i=0;i<t.length;i+=e)i+e>t?n.push(t.substring(i,t.length)):n.push(t.substring(i,i+e));return n}function $b(t){z(!Ca(t));var e,n,i,r;for(0===t?(i=n=0,e=-(1/0)===1/t?1:0):(e=0>t,t=Math.abs(t),t>=Math.pow(2,-1022)?(i=Math.min(Math.floor(Math.log(t)/Math.LN2),1023),n=i+1023,i=Math.round(t*Math.pow(2,52-i)-Math.pow(2,52))):(n=0,i=Math.round(t/Math.pow(2,-1074)))),r=[],t=52;t;t-=1)r.push(i%2?1:0),i=Math.floor(i/2);for(t=11;t;t-=1)r.push(n%2?1:0),n=Math.floor(n/2);for(r.push(e?1:0),r.reverse(),e=r.join(""),n="",t=0;64>t;t+=8)i=parseInt(e.substr(t,8),2).toString(16),1===i.length&&(i="0"+i),n+=i;return n.toLowerCase()}function ac(t,e){this.oa=t,z(this.oa!==l,"LeafNode shouldn't be created with null value."),this.Ua="undefined"!=typeof e?e:l}function P(t,e){this.R=t||new Va,this.Ua="undefined"!=typeof e?e:l}function cc(t,e,n){P.call(this,t,n),e===l&&(e=new Va(ec),t.sa(function(t,n){e=e.ia({name:t,wa:n.k()},n)})),this.ka=e}function Q(t,e){if("object"!=typeof t)return new ac(t,e);if(t===l)return O;var n=l;if(".priority"in t?n=t[".priority"]:"undefined"!=typeof e&&(n=e),z(n===l||"string"==typeof n||"number"==typeof n),".value"in t&&t[".value"]!==l)return new ac(t[".value"],n);var i,n=new P(new Va,n);for(i in t)if(D(t,i)&&"."!==i.substring(0,1)){var r=Q(t[i]);!r.J()&&r.f()||(n=n.D(i,r))}return n}function ec(t,e){return Wb(t.wa,e.wa)||(t.name!==e.name?t.name<e.name?-1:1:0)}function bc(t){return"number"==typeof t?"number:"+$b(t):"string:"+t}function R(t,e){this.u=t,this.Vb=e}function fc(t){this.sc=t,this.Qb=[],this.Oa=0,this.ic=-1,this.Ga=l}function S(t,e){for(var n in t)e.call(j,t[n],n,t)}function gc(t){var e,n={};for(e in t)n[e]=t[e];return n}function hc(){this.$a={}}function ic(t,e,n){s(n)||(n=1),D(t.$a,e)||(t.$a[e]=0),t.$a[e]+=n}function jc(t){this.jd=t,this.Fb=l}function kc(t,e){this.ad={},this.$b=new jc(t),this.n=e,setTimeout(u(this.Uc,this),10+6e4*Math.random())}function nc(t){return t=t.toString(),lc[t]||(lc[t]=new hc),lc[t]}function pc(t,e,n){this.jc=t,this.e=Sb(this.jc),this.frames=this.gb=l,this.zc=0,this.$=nc(e),this.Na=(e.Yb?"wss://":"ws://")+e.aa+"/.ws?v=5",e.host!==e.aa&&(this.Na=this.Na+"&ns="+e.jb),n&&(this.Na=this.Na+"&s="+n)}function sc(t,e){if(t.frames.push(e),t.frames.length==t.zc){var n=t.frames.join("");t.frames=l,n="undefined"!=typeof JSON&&s(JSON.parse)?JSON.parse(n):la(n),t.Mb(n)}}function rc(t){clearTimeout(t.gb),t.gb=setInterval(function(){t.U.send("0"),rc(t)},45e3)}function tc(){this.set={}}function wc(t,e,n){this.jc=t,this.e=Sb(t),this.Hd=e,this.$=nc(e),this.Zb=n,this.ab=o,this.Ab=function(t){e.host!==e.aa&&(t.ns=e.jb);var n,i=[];for(n in t)t.hasOwnProperty(n)&&i.push(n+"="+t[n]);return(e.Yb?"https://":"http://")+e.aa+"/.lp?"+i.join("&")}}function zc(t,e,n,i){this.Ab=i,this.da=n,this.tc=new tc,this.qb=[],this.kc=Math.floor(1e8*Math.random()),this.Zc=k,this.cc=Jb(),window[uc+this.cc]=t,window[vc+this.cc]=e,t=document.createElement("iframe"),t.style.display="none",document.body?document.body.appendChild(t):g("Document body has not initialized. Wait to initialize Firebase until after the document is ready."),t.contentDocument?t.qa=t.contentDocument:t.contentWindow?t.qa=t.contentWindow.document:t.document&&(t.qa=t.document),this.ca=t;try{this.ca.qa.open(),this.ca.qa.write("<html><body></body></html>"),this.ca.qa.close()}catch(r){Pb("frame writing exception"),r.stack&&Pb(r.stack),Pb(r)}}function Bc(t){if(t.fc&&t.Zc&&t.tc.count()<(0<t.qb.length?2:1)){t.kc++;var e={};e.id=t.td,e.pw=t.ud,e.ser=t.kc;for(var e=t.Ab(e),n="",i=0;0<t.qb.length&&1870>=t.qb[0].Fc.length+30+n.length;){var r=t.qb.shift(),n=n+"&seg"+i+"="+r.Ad+"&ts"+i+"="+r.Gd+"&d"+i+"="+r.Fc;i++}var e=e+n,a=t.kc;t.tc.add(a);var s=function(){t.tc.remove(a),Bc(t)},c=setTimeout(s,25e3);return Ac(t,e,function(){clearTimeout(c),s()}),k}return o}function Ac(t,e,n){setTimeout(function(){try{var i=t.ca.qa.createElement("script");i.type="text/javascript",i.async=k,i.src=e,i.onload=i.onreadystatechange=function(){var t=i.readyState;t&&"loaded"!==t&&"complete"!==t||(i.onload=i.onreadystatechange=l,i.parentNode&&i.parentNode.removeChild(i),n())},i.onerror=function(){Pb("Long-poll script failed to load."),t.close()},t.ca.qa.body.appendChild(i)}catch(r){}},1)}function Cc(){function t(t,n){n&&n.isAvailable()&&e.push(n)}var e=[],n=Dc;if("array"==ea(n))for(var i=0;i<n.length;++i)t(0,n[i]);else S(n,t);this.bc=e}function Ec(t,e,n,i,r,o){this.id=t,this.e=Sb("c:"+this.id+":"),this.sc=n,this.mb=i,this.va=r,this.rc=o,this.M=e,this.Pb=[],this.Dc=0,this.Bc=new Cc,this.ma=0,this.e("Connection created"),Fc(this)}function Fc(t){var e,n=t.Bc;0<n.bc.length?e=n.bc[0]:g(Error("No transports available")),t.G=new e("c:"+t.id+":"+t.Dc++,t.M);var i=Gc(t,t.G),r=Hc(t,t.G);t.yb=t.G,t.vb=t.G,t.w=l,setTimeout(function(){t.G&&t.G.open(i,r)},0)}function Hc(t,e){return function(n){e===t.G?(t.G=l,n||0!==t.ma?1===t.ma&&t.e("Realtime connection lost."):(t.e("Realtime connection failed."),"s-"===t.M.aa.substr(0,2)&&(N.removeItem(t.M.jb),t.M.aa=t.M.host)),t.close()):e===t.w?(n=t.w,t.w=l,(t.yb===n||t.vb===n)&&t.close()):t.e("closing an old connection")}}function Gc(t,e){return function(n){if(2!=t.ma)if(e===t.vb){var i=Xb("t",n),n=Xb("d",n);if("c"==i){if(i=Xb("t",n),"d"in n)if(n=n.d,"h"===i){var i=n.ts,r=n.v,o=n.h;t.Zb=n.s,tb(t.M,o),0==t.ma&&(t.G.start(),n=t.G,t.e("Realtime connection established."),t.G=n,t.ma=1,t.mb&&(t.mb(i),t.mb=l),"5"!==r&&Vb("Protocol version mismatch detected"),n=1<t.Bc.bc.length?t.Bc.bc[1]:l)&&(t.w=new n("c:"+t.id+":"+t.Dc++,t.M,t.Zb),t.w.open(Gc(t,t.w),Hc(t,t.w)))}else if("n"===i){for(t.e("recvd end transmission on primary"),t.vb=t.w,n=0;n<t.Pb.length;++n)t.Kb(t.Pb[n]);t.Pb=[],Ic(t)}else"s"===i?(t.e("Connection shutdown command received. Shutting down..."),t.rc&&(t.rc(n),t.rc=l),t.va=l,t.close()):"r"===i?(t.e("Reset packet received. New host: "+n),tb(t.M,n),1===t.ma?t.close():(Jc(t),Fc(t))):Tb("Unknown control packet command: "+i)}else"d"==i&&t.Kb(n)}else e===t.w?(i=Xb("t",n),n=Xb("d",n),"c"==i?"t"in n&&(n=n.t,"a"===n?(t.w.start(),t.e("sending client ack on secondary"),t.w.send({t:"c",d:{t:"a",d:{}}}),t.e("Ending transmission on primary"),t.G.send({t:"c",d:{t:"n",d:{}}}),t.yb=t.w,Ic(t)):"r"===n&&(t.e("Got a reset on secondary, closing it"),t.w.close(),(t.yb===t.w||t.vb===t.w)&&t.close())):"d"==i?t.Pb.push(n):g(Error("Unknown protocol layer: "+i))):t.e("message on old connection")}}function Ic(t){t.yb===t.w&&t.vb===t.w&&(t.e("cleaning up and promoting a connection: "+t.w.jc),t.G=t.w,t.w=l)}function Jc(t){t.e("Shutting down all connections"),t.G&&(t.G.close(),t.G=l),t.w&&(t.w.close(),t.w=l)}function Kc(t,e,n,i){this.id=Lc++,this.e=Sb("p:"+this.id+":"),this.wb=k,this.ba={},this.O=[],this.nb=0,this.lb=[],this.S=o,this.Ub=1e3,this.Lb=e||da,this.Jb=n||da,this.kb=i||da,this.M=t,this.vc=l,this.Rb=[],this.xa={},this.zd=0,this.hb=this.Oc=l,setTimeout(u(this.Gc,this),0)}function Nc(t,e,n,i,r){t.e("Listen on "+e+" for "+n);var o={p:e},i=mb(i,function(t){return Ja(t)});"{}"!==n&&(o.q=i),t.ya("l",o,function(i){t.e("listen response",i),i=i.s,"ok"!==i&&Oc(t,e,n),r&&r(i)},function(){t.e("timed out on listen...")})}function Pc(t){var e=t.Ca;t.S&&e&&t.ya("auth",{cred:e.kd},function(n){var i=n.s,n=n.d||"error";"ok"!==i&&t.Ca===e&&delete t.Ca,e.Ic?"ok"!==i&&e.Cb&&e.Cb(i,n):(e.Ic=k,e.fa&&e.fa(i,n)),t.kb("ok"===i)},function(){t.e("timed out on auth...")})}function Qc(t,e,n,i){t.S?Rc(t,"o",e,n,i):t.lb.push({uc:e,action:"o",data:n,A:i})}function Rc(t,e,n,i,r){n={p:n,d:i},t.e("onDisconnect "+e,n),t.ya(e,n,function(t){r&&setTimeout(function(){r(t.s)},0)},function(){t.e("timed out on onDisconnect...")})}function Sc(t,e,n,i,r,o){n={p:n,d:i},s(o)&&(n.h=o),t.O.push({action:e,Vc:n,A:r}),t.nb++,e=t.O.length-1,t.S&&Tc(t,e)}function Tc(t,e){var n=t.O[e].action,i=t.O[e].A;t.ya(n,t.O[e].Vc,function(r){t.e(n+" response",r),delete t.O[e],t.nb--,0===t.nb&&(t.O=[]),i&&i(r.s)},function(){t.e("timed out on put...")})}function Oc(t,e,n){e=new I(e).toString(),n||(n="{}");var i=t.ba[e][n];return delete t.ba[e][n],i}function Uc(){this.Ka=O}function T(t,e){return t.Ka.F(e)}function U(t,e,n){t.Ka=t.Ka.Ya(e,n)}function Vc(){this.za=new Uc,this.K=new Uc,this.Aa=new Uc,this.pb=new Ra}function Wc(t,e){for(var n=T(t.za,e),i=T(t.K,e),r=J(t.pb,e),a=o,s=r;s!==l;){if(s.j()!==l){a=k;break}s=s.parent()}return a?o:(n=Xc(n,i,r),n!==i?(U(t.K,e,n),k):o)}function Xc(t,e,n){return n.f()?t:n.j()!==l?e:(t=t||O,n.B(function(i){var i=i.name(),r=t.N(i),o=e.N(i),a=J(n,i),r=Xc(r,o,a);t=t.D(i,r)}),t)}function Yc(t,e){lb(e,function(e){var n=e.Bd,e=J(t.pb,e.path),i=e.j();z(i!==l,"pendingPut should not be null."),i===n&&M(e,l)})}function Zc(){this.Da=[]}function $c(t,e){if(0!==e.length){t.Da.push.apply(t.Da,e);for(var n=0;n<t.Da.length;n++)if(t.Da[n]){var i=t.Da[n];t.Da[n]=l;var r=i.fa;r(i.$c,i.rb)}t.Da=[]}}function V(t,e,n,i){this.type=t,this.ja=e,this.V=n,this.rb=i}function ad(t){this.I=t,this.ga=[],this.Hc=new Zc}function bd(t,e,n,i,r){t.ga.push({type:e,fa:n,cancel:i,W:r});var i=[],o=cd(t.g);t.fb&&o.push(new V("value",t.g));for(var a=0;a<o.length;a++)if(o[a].type===e){var s=new W(t.I.o,t.I.path);o[a].V&&(s=s.C(o[a].V)),i.push({fa:r?u(n,r):n,$c:new R(o[a].ja,s),rb:o[a].rb})}$c(t.Hc,i)}function fd(t,e){for(var n=[],i=0;i<e.length;i++){var r=e[i],o=r.type,a=new W(t.I.o,t.I.path);for(e[i].V&&(a=a.C(e[i].V)),a=new R(e[i].ja,a),"value"!==r.type||a.Eb()?"value"!==r.type&&(o+=" "+a.name()):o+="("+a.P()+")",Pb(t.I.o.n.id+": event:"+t.I.path+":"+t.I.Ia()+":"+o),o=0;o<t.ga.length;o++){var s=t.ga[o];e[i].type===s.type&&n.push({fa:s.W?u(s.fa,s.W):s.fa,$c:a,rb:r.rb})}}$c(t.Hc,n)}function cd(t){var e=[];if(!t.J()){var n=l;t.B(function(t,i){e.push(new V("child_added",i,t,n)),n=t})}return e}function gd(t){t.fb||(t.fb=k,fd(t,[new V("value",t.g)]))}function hd(t,e){ad.call(this,t),this.g=e}function id(t,e){this.Db=t,this.pc=e}function jd(t,e,n,i,r){var a=t.F(n),s=e.F(n),i=new id(i,r),r=kd(i,n,a,s),c=o;if(!a.f()&&!s.f()&&a.k()!==s.k())var c=t.F(n.parent()),h=e.F(n.parent()),u=Ma(n),c=c.T(u,a)!=h.T(u,s);if(r||c)for(a=n,n=r,s=c;a.parent()!==l;){var f=t.F(a),r=e.F(a),c=a.parent();i.Db&&!J(i.Db,c).j()||(h=e.F(c),u=[],a=Ma(a),f.f()?(f=h.T(a,r),u.push(new V("child_added",r,a,f))):r.f()?u.push(new V("child_removed",f,a)):(f=h.T(a,r),s&&u.push(new V("child_moved",r,a,f)),n&&u.push(new V("child_changed",r,a,f))),i.pc(c,h,u)),s&&(s=o,n=k),a=c}}function kd(t,e,n,i){var r,a=[];return n===i?r=o:n.J()&&i.J()?r=n.j()!==i.j():n.J()?(ld(t,e,O,i,a),r=k):i.J()?(ld(t,e,n,O,a),r=k):r=ld(t,e,n,i,a),r?t.pc(e,i,a):n.k()!==i.k()&&t.pc(e,i,l),r}function ld(t,e,n,i,r){var a,c,h,u,f=o,p=!t.Db||!J(t.Db,e).f(),d=[],b=[],y=[],g=[],v={},m={};for(a=n.Qa(),h=$a(a),c=i.Qa(),u=$a(c);h!==l||u!==l;)if(n=h===l?1:u===l?-1:h.key===u.key?0:ec({name:h.key,wa:h.value.k()},{name:u.key,wa:u.value.k()}),0>n?(f=ua(v,h.key),s(f)?(y.push({Jc:h,cd:d[f]}),d[f]=l):(m[h.key]=b.length,b.push(h)),f=k,h=$a(a)):(n>0?(f=ua(m,u.key),s(f)?(y.push({Jc:b[f],cd:u}),b[f]=l):(v[u.key]=d.length,d.push(u)),f=k):(n=e.C(u.key),(n=kd(t,n,h.value,u.value))&&(g.push(u),f=k),h=$a(a)),u=$a(c)),!p&&f)return k;for(p=0;p<b.length;p++)(v=b[p])&&(n=e.C(v.key),kd(t,n,v.value,O),r.push(new V("child_removed",v.value,v.key)));for(p=0;p<d.length;p++)(v=d[p])&&(n=e.C(v.key),b=i.T(v.key,v.value),kd(t,n,O,v.value),r.push(new V("child_added",v.value,v.key,b)));for(p=0;p<y.length;p++)v=y[p].Jc,d=y[p].cd,n=e.C(d.key),b=i.T(d.key,d.value),r.push(new V("child_moved",d.value,d.key,b)),(n=kd(t,n,v.value,d.value))&&g.push(d);for(p=0;p<g.length;p++)t=g[p],b=i.T(t.key,t.value),r.push(new V("child_changed",t.value,t.key,b));return f}function md(){this.L=this.na=l,this.set={}}function nd(t){return t.contains("default")}function od(t){return t.na!=l&&nd(t)}function pd(t,e){ad.call(this,t),this.g=O,this.Tb(e,cd(e))}function qd(t,e,n,i){if(t.J())return l;var r=l;return(i?t.lc:t.B).call(t,function(t,i){return rd(e,t,i)&&(r=t,n--,0===n)?k:void 0}),r}function rd(t,e,n){for(var i=0;i<t.length;i++)if(!t[i](e,n.k()))return o;return k}function sd(t,e){this.n=t,this.i=e,this.Qc=e.Ka,this.pa=new Ra}function vd(t,e,n,i,r){for(var a=t.get(e),s=o,c=a.ga.length-1;c>=0;c--){var h=a.ga[c];if(!(n&&h.type!==n||i&&h.fa!==i||r&&h.W!==r)&&(a.ga.splice(c,1),s=k,n&&i))break}return(n=s&&!(0<a.ga.length))&&t.remove(e),n}function wd(t,e,n,i,r,a){var s=e.path(),s=J(t.pa,s),n=n?n.Ia():l,c=[];if(n&&"default"!==n?vd(e,n,i,r,a)&&c.push(n):lb(e.keys(),function(t){vd(e,t,i,r,a)&&c.push(t)}),e.f()&&M(s,l),n=td(s),0<c.length&&!n){for(var h=s,u=s.parent(),n=o;!n&&u;){var f=u.j();if(f){z(!od(f));var p=h.name(),d=o;S(f.set,function(t){d=t.mc(p)||d}),d&&(n=k)}h=u,u=u.parent()}if(h=l,!od(e)){u=e.na,e.na=l;var b=[],y=function(e){var n=e.j();n&&nd(n)?(b.push(n.path()),n.na==l&&n.setActive(ud(t,n))):(n&&n.na==l&&n.setActive(ud(t,n)),e.B(y))};y(s),h=b,u&&u()}return n?l:h}return l}function xd(t,e,n){Ta(J(t.pa,e),function(t){(t=t.j())&&S(t.set,function(t){gd(t)})},n,k)}function yd(t,e,n){function i(t){for(var e=0;e<n.length;++e)if(n[e].contains(t))return k;return o}var r=t.Qc,a=t.i.Ka;t.Qc=a,jd(r,a,e,t.pa,function(n,r,a){if(e.contains(n)){var s=i(n);s&&xd(t,n,o),t.Sb(n,r,a),s&&xd(t,n,k)}else t.Sb(n,r,a)}),i(e)&&xd(t,e,k)}function td(t){return Ua(t,function(t){return t.j()&&od(t.j())})}function ud(t,e){if(t.n){var n=e.keys(),i=t.n,r=function(i){"ok"!==i?(Vb("on() or once() for "+e.path().toString()+" failed: "+i),e&&S(e.set,function(t){for(var e=0;e<t.ga.length;e++){var n=t.ga[e];n.cancel&&(n.W?u(n.cancel,n.W):n.cancel)()}}),wd(t,e)):lb(n,function(t){(t=e.get(t))&&gd(t)})},o=e.toString(),a=e.path().toString();return i.ba[a]=i.ba[a]||{},z(!i.ba[a][o],"listen() called twice for same path/queryId."),i.ba[a][o]={Va:e.Va(),A:r},i.S&&Nc(i,a,o,e.Va(),r),u(t.n.dd,t.n,e.path(),e.toString(),e.Va())}return da}function zd(t,e,n,i,r,o){var a=e.path();if(o!==l){var s=[];return i.J()||i.B(function(t,e){s.push({path:a.C(t),Fa:e}),delete o[t]}),S(o,function(t,e){s.push({path:a.C(e),Fa:O})}),s}var e=t.bb(a,e,i,r),c=O,h=[];return S(e,function(e,o){var a=new I(o);e?c=c.D(o,i.F(a)):h=h.concat(Ad(t,i.F(a),J(n,a),r))}),[{path:a,Fa:c}].concat(h)}function Bd(t,e,n,i,r){for(var a=J(t.pa,e),s=a.parent(),c=o;!c&&s!==l;){var h=s.j();h!==l&&(nd(h)?c=k:(h=t.bb(e,h,n,i),a=a.name(),ua(h,a)&&(c=k))),a=s,s=s.parent()}return c?[{path:e,Fa:n}]:(s=J(t.pa,e),c=s.j(),c!==l?nd(c)?[{path:e,Fa:n}]:zd(t,c,s,n,i,r):Ad(t,n,s,i))}function Ad(t,e,n,i){var r=n.j();if(r!==l)return nd(r)?[{path:n.path(),Fa:e}]:zd(t,r,n,e,i,l);if(e.J())return[];var o=[];return e.B(function(e,r){var a=new I(e);o=o.concat(Ad(t,r,J(n,a),i))}),o}function Cd(t){this.M=t,this.$=nc(t),this.n=new Kc(this.M,u(this.Lb,this),u(this.Jb,this),u(this.kb,this));var e=u(function(){return new kc(this.$,this.n)},this),t=t.toString();mc[t]||(mc[t]=e()),this.Fd=mc[t],this.ac=new Ra,this.i=new Vc,this.Q=new sd(this.n,this.i.Aa),this.Mc=new Uc,this.nc=new sd(l,this.Mc),Dd(this,"connected",o),Dd(this,"authenticated",o)}function Dd(t,e,n){e=new I("/.info/"+e),U(t.Mc,e,Q(n)),yd(t.nc,e,[e])}function Hd(t,e,n,i){n=Q(n),Qc(t.n,e.toString(),n.P(k),function(t){X(i,t)})}function Id(t){ic(t.$,"deprecated_on_disconnect"),t.Fd.ad.deprecated_on_disconnect=k}function Jd(t,e){var n=new W(t,e);return new R(T(t.i.Aa,e),n)}function X(t,e,n){if(t)if("ok"==e)t(l,n);else{var i=e=(e||"error").toUpperCase();n&&(i+=": "+n),n=Error(i),n.code=e,t(n)}}function Gd(t,e){var n=J(t.ac,e);Ua(n,function(e){Kd(t,e)}),Kd(t,n),Ta(n,function(e){Kd(t,e)})}function Kd(t,e){var n=e.j();if(n!==l){for(var i=-1,r=[],a=0;a<n.length;a++)if(2===n[a].status)z(i===a-1,"All SENT items should be at beginning of queue."),i=a,n[a].status=4,n[a].Cc="set";else if(n[a].dc(),n[a].A){var s=Jd(t,e.path());r.push(u(n[a].A,l,Error("set"),o,s))}for(-1===i?M(e,l):n.length=i+1,a=0;a<r.length;a++)r[a]()}}function Ld(t,e){var n=e||t.ac;if(e||Md(t,n),!n.f())if(n.j()!==l){var i=Nd(t,n);if(0!==i.length){var r=n.path();if(2!==i[0].status&&4!==i[0].status){for(var o=0;o<i.length;o++)z(1===i[o].status,"tryToSendTransactionForNode_: items in queue should all be run."),i[o].status=2,i[o].Yc++;var a=T(t.i.K,r).hash();U(t.i.K,r,T(t.i.Aa,r));var s=T(t.i.K,r).P(k),c=Jb();M(J(t.i.pb,r),c),t.n.put(r.toString(),s,function(e){t.e("transaction put response",{path:r.toString(),status:e});var a=J(t.i.pb,r),s=a.j();if(z(s!==l,"tryToSendTransactionsForNode_: pendingPut should not be null."),s===c&&(M(a,l),U(t.i.K,r,T(t.i.za,r))),"ok"===e){for(e=[],o=0;o<i.length;o++)i[o].status=3,i[o].A&&(a=Jd(t,i[o].path),e.push(u(i[o].A,l,l,k,a))),i[o].dc();for(Md(t,n),Ld(t),o=0;o<e.length;o++)e[o]()}else{if("datastale"===e)for(o=0;o<i.length;o++)i[o].status=4===i[o].status?5:1;else for(Vb("transaction at "+r+" failed: "+e),o=0;o<i.length;o++)i[o].status=5,i[o].Cc=e;e=Ed(t,r),Fd(t,e),yd(t.Q,e.path(),[r])}},a)}}}else n.B(function(e){Ld(t,e)})}function Fd(t,e){var n=e.path();U(t.i.Aa,n,T(t.i.K,n));var i=Nd(t,e);if(0!==i.length){for(var r=T(t.i.Aa,n),a=[],c=0;c<i.length;c++){var h,f=Na(n,i[c].path),p=o;if(z(f!==l,"rerunTransactionsUnderNode_: relativePath should not be null."),5===i[c].status)p=k,h=i[c].Cc;else if(1===i[c].status)if(25<=i[c].Yc)p=k,h="maxretry";else{var d=i[c].update(r.F(f).P());s(d)?(Aa("transaction failed: Data returned ",d),r=r.Ya(f,Q(d))):(p=k,h="nodata")}p&&(i[c].dc(),i[c].status=3,i[c].A&&(p=new W(t,i[c].path),f=new R(r.F(f),p),"nodata"===h?a.push(u(i[c].A,l,l,o,f)):a.push(u(i[c].A,l,Error(h),o,f))))}for(i=T(t.i.K,n).k(),U(t.i.Aa,n,r.ec(i)),Ld(t),c=0;c<a.length;c++)a[c]()}}function Ed(t,e){for(var n,i=t.ac;(n=F(e))!==l&&i.j()===l;)i=J(i,n),e=La(e);return i}function Nd(t,e){var n=[];return Od(t,e,n),n.sort(function(t,e){return t.Sc-e.Sc}),n}function Od(t,e,n){var i=e.j();if(i!==l)for(var r=0;r<i.length;r++)n.push(i[r]);e.B(function(e){Od(t,e,n)})}function Md(t,e){var n=e.j();if(n){for(var i=0,r=0;r<n.length;r++)3!==n[r].status&&(n[i]=n[r],i++);n.length=i,M(e,0<n.length?n:l)}e.B(function(e){Md(t,e)})}function Y(){this.Wa={}}function $(t,e,n){this.tb=t,this.L=e,this.ua=n}function W(){var e,n,i;if(arguments[0]instanceof Cd)i=arguments[0],e=arguments[1];else{A("new Firebase",1,2,arguments.length);var r=arguments[0];n=e="";var a=k,s="";if(t(r)){var c=r.indexOf("//");if(c>=0)var h=r.substring(0,c-1),r=r.substring(c+2);c=r.indexOf("/"),-1===c&&(c=r.length),e=r.substring(0,c);var r=r.substring(c+1),u=e.split(".");if(3==u.length){if(c=u[2].indexOf(":"),a=c>=0?"https"===h:k,"firebase"===u[1])Ub(e+" is no longer supported. Please use <YOUR FIREBASE>.firebaseio.com instead");else for(n=u[0],s="",r=("/"+r).split("/"),h=0;h<r.length;h++)if(0<r[h].length){c=r[h];try{c=decodeURIComponent(c.replace(/\+/g," "))}catch(f){}s+="/"+c}n=n.toLowerCase()}else n=l}a||"undefined"!=typeof window&&window.location&&window.location.protocol&&-1!==window.location.protocol.indexOf("https:")&&Vb("Insecure Firebase access from a secure page. Please use https in calls to new Firebase()."),e=new sb(e,a,n),n=new I(s),a=n.toString(),(r=!t(e.host))||(r=0===e.host.length)||(r=!ya(e.jb))||(r=0!==a.length)&&(a&&(a=a.replace(/^\/*\.info(\/|$)/,"/")),r=!(t(a)&&0!==a.length&&!xa.test(a))),r&&g(Error(B("new Firebase",1,o)+'must be a valid firebase URL and the path can\'t contain ".", "#", "$", "[", or "]".')),arguments[1]?arguments[1]instanceof Y?i=arguments[1]:g(Error("Expected a valid Firebase.Context for second argument to new Firebase()")):i=Y.pd(),a=e.toString(),r=ua(i.Wa,a),r||(r=new Cd(e),i.Wa[a]=r),i=r,e=n}G.call(this,i,e)}function Qb(t,e){z(!e||t===k||t===o,"Can't turn on custom loggers persistently."),t===k?("undefined"!=typeof console&&("function"==typeof console.log?Nb=u(console.log,console):"object"==typeof console.log&&(Nb=function(t){console.log(t)})),e&&N.setItem("logging_enabled","true")):t?Nb=t:(Nb=l,N.removeItem("logging_enabled"))}var j=void 0,k=!0,l=null,o=!1,r,ba=this;
Math.floor(2147483648*Math.random()).toString(36);var pa={'"':'\\"',"\\":"\\\\","/":"\\/","\b":"\\b","\f":"\\f","\n":"\\n","\r":"\\r"," ":"\\t","\x0B":"\\u000b"},qa=/\uffff/.test("￿")?/[\\\"\x00-\x1f\x7f-\uffff]/g:/[\\\"\x00-\x1f\x7f-\xff]/g,va={},sa={},wa=/[\[\].#$\/]/,xa=/[\[\].#$]/;G.prototype.oc=function(t,e){A("Query.on",2,4,arguments.length),Fa("Query.on",t,o),C("Query.on",2,e,o);var n=Ia("Query.on",arguments[2],arguments[3]);return this.o.Bb(this,t,e,n.cancel,n.W),e},G.prototype.on=G.prototype.oc,G.prototype.Ib=function(t,e,n){A("Query.off",0,3,arguments.length),Fa("Query.off",t,k),C("Query.off",2,e,k),ta("Query.off",3,n),this.o.Wb(this,t,e,n)},G.prototype.off=G.prototype.Ib,G.prototype.vd=function(t,e){function n(s){a&&(a=o,r.Ib(t,n),e.call(i.W,s))}A("Query.once",2,4,arguments.length),Fa("Query.once",t,o),C("Query.once",2,e,o);var i=Ia("Query.once",arguments[2],arguments[3]),r=this,a=k;this.oc(t,n,function(){r.Ib(t,n),i.cancel&&i.cancel.call(i.W)})},G.prototype.once=G.prototype.vd,G.prototype.rd=function(t){return A("Query.limit",1,1,arguments.length),(!ga(t)||Math.floor(t)!==t||0>=t)&&g("Query.limit: First argument must be a positive integer."),new G(this.o,this.path,t,this.Z,this.la,this.ra,this.Pa)},G.prototype.limit=G.prototype.rd,G.prototype.Ed=function(t,e){return A("Query.startAt",0,2,arguments.length),Ea("Query.startAt",1,t,k),Ga("Query.startAt",e),s(t)||(e=t=l),new G(this.o,this.path,this.ta,t,e,this.ra,this.Pa)},G.prototype.startAt=G.prototype.Ed,G.prototype.ld=function(t,e){return A("Query.endAt",0,2,arguments.length),Ea("Query.endAt",1,t,k),Ga("Query.endAt",e),new G(this.o,this.path,this.ta,this.Z,this.la,t,e)},G.prototype.endAt=G.prototype.ld,G.prototype.Ia=function(){var t=Ka(Ja(this));return"{}"===t?"default":t},r=I.prototype,r.toString=function(){for(var t="",e=this.X;e<this.m.length;e++)""!==this.m[e]&&(t+="/"+this.m[e]);return t||"/"},r.parent=function(){if(this.X>=this.m.length)return l;for(var t=[],e=this.X;e<this.m.length-1;e++)t.push(this.m[e]);return new I(t,0)},r.C=function(t){for(var e=[],n=this.X;n<this.m.length;n++)e.push(this.m[n]);if(t instanceof I)for(n=t.X;n<t.m.length;n++)e.push(t.m[n]);else for(t=t.split("/"),n=0;n<t.length;n++)0<t[n].length&&e.push(t[n]);return new I(e,0)},r.f=function(){return this.X>=this.m.length},r.contains=function(t){var e=0;if(this.m.length>t.m.length)return o;for(;e<this.m.length;){if(this.m[e]!==t.m[e])return o;++e}return k},r=Ra.prototype,r.j=function(){return this.u.value},r.Eb=function(){return 0<this.u.hc},r.f=function(){return this.j()===l&&!this.Eb()},r.B=function(t){for(var e in this.u.children)t(new Ra(e,this,this.u.children[e]))},r.path=function(){return new I(this.ob===l?this.ua:this.ob.path()+"/"+this.ua)},r.name=aa("ua"),r.parent=aa("ob"),r=Va.prototype,r.ia=function(t,e){return new Va(this.Ma,this.Y.ia(t,e,this.Ma).copy(l,l,o,l,l))},r.remove=function(t){return new Va(this.Ma,this.Y.remove(t,this.Ma).copy(l,l,o,l,l))},r.get=function(t){for(var e,n=this.Y;!n.f();){if(e=this.Ma(t,n.key),0===e)return n.value;0>e?n=n.left:e>0&&(n=n.right)}return l},r.f=function(){return this.Y.f()},r.count=function(){return this.Y.count()},r.ib=function(){return this.Y.ib()},r.Sa=function(){return this.Y.Sa()},r.sa=function(t){return this.Y.sa(t)},r.Ja=function(t){return this.Y.Ja(t)},r.Qa=function(t){return new Za(this.Y,t)},r=ab.prototype,r.copy=function(t,e,n,i,r){return new ab(t!=l?t:this.key,e!=l?e:this.value,n!=l?n:this.color,i!=l?i:this.left,r!=l?r:this.right)},r.count=function(){return this.left.count()+1+this.right.count()},r.f=p(o),r.sa=function(t){return this.left.sa(t)||t(this.key,this.value)||this.right.sa(t)},r.Ja=function(t){return this.right.Ja(t)||t(this.key,this.value)||this.left.Ja(t)},r.ib=function(){return bb(this).key},r.Sa=function(){return this.right.f()?this.key:this.right.Sa()},r.ia=function(t,e,n){var i,r;return r=this,i=n(t,r.key),r=0>i?r.copy(l,l,l,r.left.ia(t,e,n),l):0===i?r.copy(l,e,l,l,l):r.copy(l,l,l,l,r.right.ia(t,e,n)),cb(r)},r.remove=function(t,e){var n,i;if(n=this,0>e(t,n.key))!n.left.f()&&!n.left.H()&&!n.left.left.H()&&(n=eb(n)),n=n.copy(l,l,l,n.left.remove(t,e),l);else{if(n.left.H()&&(n=gb(n)),!n.right.f()&&!n.right.H()&&!n.right.left.H()&&(n=hb(n),n.left.left.H()&&(n=gb(n),n=hb(n))),0===e(t,n.key)){if(n.right.f())return Xa;i=bb(n.right),n=n.copy(i.key,i.value,l,l,db(n.right))}n=n.copy(l,l,l,l,n.right.remove(t,e))}return cb(n)},r.H=aa("color"),r=jb.prototype,r.copy=function(){return this},r.ia=function(t,e){return new ab(t,e,j,j,j)},r.remove=function(){return this},r.get=p(l),r.count=p(0),r.f=p(k),r.sa=p(o),r.Ja=p(o),r.ib=p(l),r.Sa=p(l),r.H=p(o);var Xa=new jb,kb=Array.prototype,lb=kb.forEach?function(t,e,n){kb.forEach.call(t,e,n)}:function(e,n,i){for(var r=e.length,o=t(e)?e.split(""):e,a=0;r>a;a++)a in o&&n.call(i,o[a],a,e)},mb=kb.map?function(t,e,n){return kb.map.call(t,e,n)}:function(e,n,i){for(var r=e.length,o=Array(r),a=t(e)?e.split(""):e,s=0;r>s;s++)s in a&&(o[s]=n.call(i,a[s],s,e));return o};ka(ob,nb),ob.prototype.reset=function(){this.z[0]=1732584193,this.z[1]=4023233417,this.z[2]=2562383102,this.z[3]=271733878,this.z[4]=3285377520,this.Ac=this.eb=0},ob.prototype.update=function(e,n){s(n)||(n=e.length);var i=this.gc,r=this.eb,o=0;if(t(e))for(;n>o;)i[r++]=e.charCodeAt(o++),64==r&&(pb(this,i),r=0);else for(;n>o;)i[r++]=e[o++],64==r&&(pb(this,i),r=0);this.eb=r,this.Ac+=n},qb.prototype.setItem=function(t,e){D(this.La,t)||(this.length+=1),this.La[t]=e},qb.prototype.getItem=function(t){return D(this.La,t)?this.La[t]:l},qb.prototype.removeItem=function(t){D(this.La,t)&&(this.length-=1,delete this.La[t])};var N=l;if("undefined"!=typeof sessionStorage)try{sessionStorage.setItem("firebase-sentinel","cache"),sessionStorage.removeItem("firebase-sentinel"),N=sessionStorage}catch(rb){N=new qb}else N=new qb;sb.prototype.toString=function(){return(this.Yb?"https://":"http://")+this.host};var ub,vb,wb,xb;xb=wb=vb=ub=o;var zb;if(zb=yb()){var Ab=ba.navigator;ub=0==zb.indexOf("Opera"),vb=!ub&&-1!=zb.indexOf("MSIE"),wb=!ub&&-1!=zb.indexOf("WebKit"),xb=!ub&&!wb&&"Gecko"==Ab.product}var Bb=vb,Cb=xb,Db=wb,Eb;if(ub&&ba.opera){var Fb=ba.opera.version;"function"==typeof Fb&&Fb()}else Cb?Eb=/rv\:([^\);]+)(\)|;)/:Bb?Eb=/MSIE\s+([^\);]+)(\)|;)/:Db&&(Eb=/WebKit\/(\S+)/),Eb&&Eb.exec(yb());var Gb=l,Hb=l,Jb,Kb=1;Jb=function(){return Kb++};var Nb=l,Ob=k,Yb=0;r=ac.prototype,r.J=p(k),r.k=aa("Ua"),r.ec=function(t){return new ac(this.oa,t)},r.N=function(){return O},r.F=function(t){return F(t)===l?this:O},r.T=p(l),r.D=function(t,e){return new P(new Va,this.Ua).D(t,e)},r.Ya=function(t,e){var n=F(t);return n===l?e:this.D(n,O.Ya(La(t),e))},r.f=p(o),r.Hb=p(0),r.P=function(t){return t&&this.k()!==l?{".value":this.j(),".priority":this.k()}:this.j()},r.hash=function(){var t="";this.k()!==l&&(t+="priority:"+bc(this.k())+":");var e=typeof this.oa,t=t+(e+":"),t="number"===e?t+$b(this.oa):t+this.oa;return Lb(t)},r.j=aa("oa"),r.toString=function(){return"string"==typeof this.oa?'"'+this.oa+'"':this.oa},r=P.prototype,r.J=p(o),r.k=aa("Ua"),r.ec=function(t){return new P(this.R,t)},r.D=function(t,e){var n=this.R.remove(t);return e&&e.f()&&(e=l),e!==l&&(n=n.ia(t,e)),e&&e.k()!==l?new cc(n,l,this.Ua):new P(n,this.Ua)},r.Ya=function(t,e){var n=F(t);if(n===l)return e;var i=this.N(n).Ya(La(t),e);return this.D(n,i)},r.f=function(){return this.R.f()},r.Hb=function(){return this.R.count()};var dc=/^\d+$/;r=P.prototype,r.P=function(t){if(this.f())return l;var e={},n=0,i=0,r=k;if(this.B(function(a,s){e[a]=s.P(t),n++,r&&dc.test(a)?i=Math.max(i,Number(a)):r=o}),!t&&r&&2*n>i){var a,s=[];for(a in e)s[a]=e[a];return s}return t&&this.k()!==l&&(e[".priority"]=this.k()),e},r.hash=function(){var t="";return this.k()!==l&&(t+="priority:"+bc(this.k())+":"),this.B(function(e,n){var i=n.hash();""!==i&&(t+=":"+e+":"+i)}),""===t?"":Lb(t)},r.N=function(t){return t=this.R.get(t),t===l?O:t},r.F=function(t){var e=F(t);return e===l?this:this.N(e).F(La(t))},r.T=function(t){return Ya(this.R,t)},r.Kc=function(){return this.R.ib()},r.Lc=function(){return this.R.Sa()},r.B=function(t){return this.R.sa(t)},r.lc=function(t){return this.R.Ja(t)},r.Qa=function(){return this.R.Qa()},r.toString=function(){var t="{",e=k;return this.B(function(n,i){e?e=o:t+=", ",t+='"'+n+'" : '+i.toString()}),t+="}"};var O=new P(new Va);ka(cc,P),r=cc.prototype,r.D=function(t,e){var n=this.N(t),i=this.R,r=this.ka;return n!==l&&(i=i.remove(t),r=r.remove({name:t,wa:n.k()})),e&&e.f()&&(e=l),e!==l&&(i=i.ia(t,e),r=r.ia({name:t,wa:e.k()},e)),new cc(i,r,this.k())},r.T=function(t,e){var n=Ya(this.ka,{name:t,wa:e.k()});return n?n.name:l},r.B=function(t){return this.ka.sa(function(e,n){return t(e.name,n)})},r.lc=function(t){return this.ka.Ja(function(e,n){return t(e.name,n)})},r.Qa=function(){return this.ka.Qa(function(t,e){return{key:t.name,value:e}})},r.Kc=function(){return this.ka.f()?l:this.ka.ib().name},r.Lc=function(){return this.ka.f()?l:this.ka.Sa().name},R.prototype.P=function(){return A("Firebase.DataSnapshot.val",0,0,arguments.length),this.u.P()},R.prototype.val=R.prototype.P,R.prototype.md=function(){return A("Firebase.DataSnapshot.exportVal",0,0,arguments.length),this.u.P(k)},R.prototype.exportVal=R.prototype.md,R.prototype.C=function(t){A("Firebase.DataSnapshot.child",0,1,arguments.length),ga(t)&&(t=String(t)),Ha("Firebase.DataSnapshot.child",t);var e=new I(t),n=this.Vb.C(e);return new R(this.u.F(e),n)},R.prototype.child=R.prototype.C,R.prototype.mc=function(t){A("Firebase.DataSnapshot.hasChild",1,1,arguments.length),Ha("Firebase.DataSnapshot.hasChild",t);var e=new I(t);return!this.u.F(e).f()},R.prototype.hasChild=R.prototype.mc,R.prototype.k=function(){return A("Firebase.DataSnapshot.getPriority",0,0,arguments.length),this.u.k()},R.prototype.getPriority=R.prototype.k,R.prototype.forEach=function(t){if(A("Firebase.DataSnapshot.forEach",1,1,arguments.length),C("Firebase.DataSnapshot.forEach",1,t,o),this.u.J())return o;var e=this;return this.u.B(function(n,i){return t(new R(i,e.Vb.C(n)))})},R.prototype.forEach=R.prototype.forEach,R.prototype.Eb=function(){return A("Firebase.DataSnapshot.hasChildren",0,0,arguments.length),this.u.J()?o:!this.u.f()},R.prototype.hasChildren=R.prototype.Eb,R.prototype.name=function(){return A("Firebase.DataSnapshot.name",0,0,arguments.length),this.Vb.name()},R.prototype.name=R.prototype.name,R.prototype.Hb=function(){return A("Firebase.DataSnapshot.numChildren",0,0,arguments.length),this.u.Hb()},R.prototype.numChildren=R.prototype.Hb,R.prototype.wd=function(){return A("Firebase.DataSnapshot.ref",0,0,arguments.length),this.Vb},R.prototype.ref=R.prototype.wd,hc.prototype.get=function(){return gc(this.$a)},jc.prototype.get=function(){var t=this.jd.get(),e=gc(t);if(this.Fb)for(var n in this.Fb)e[n]-=this.Fb[n];return this.Fb=t,e},kc.prototype.Uc=function(){var t,e=this.$b.get(),n={},i=o;for(t in e)0<e[t]&&D(this.ad,t)&&(n[t]=e[t],i=k);i&&(e=this.n,e.S&&(n={c:n},e.e("reportStats",n),e.ya("s",n))),setTimeout(u(this.Uc,this),6e5*Math.random())};var lc={},mc={},oc=l;"undefined"!=typeof MozWebSocket?oc=MozWebSocket:"undefined"!=typeof WebSocket&&(oc=WebSocket);var qc;pc.prototype.open=function(t,e){this.da=e,this.Mb=t,this.e("websocket connecting to "+this.Na),this.U=new oc(this.Na),this.ab=o;var n=this;this.U.onopen=function(){n.e("Websocket connected."),n.ab=k},this.U.onclose=function(){n.e("Websocket connection was disconnected."),n.U=l,n.Ha()},this.U.onmessage=function(t){if(n.U!==l)if(t=t.data,ic(n.$,"bytes_received",t.length),rc(n),n.frames!==l)sc(n,t);else{t:{if(z(n.frames===l,"We already have a frame buffer"),4>=t.length){var e=Number(t);if(!isNaN(e)){n.zc=e,n.frames=[],t=l;break t}}n.zc=1,n.frames=[]}t!==l&&sc(n,t)}},this.U.onerror=function(){n.e("WebSocket error. Closing connection."),n.Ha()}},pc.prototype.start=function(){},pc.isAvailable=function(){return!("undefined"!=typeof navigator&&"Opera"===navigator.appName||oc===l||qc)},pc.prototype.send=function(t){rc(this),t=y(t),ic(this.$,"bytes_sent",t.length),t=Zb(t,16384),1<t.length&&this.U.send(String(t.length));for(var e=0;e<t.length;e++)this.U.send(t[e])},pc.prototype.xb=function(){this.Ea=k,this.gb&&(clearTimeout(this.gb),this.gb=l),this.U&&(this.U.close(),this.U=l)},pc.prototype.Ha=function(){this.Ea||(this.e("WebSocket is closing itself"),this.xb(),this.da&&(this.da(this.ab),this.da=l))},pc.prototype.close=function(){this.Ea||(this.e("WebSocket is being closed"),this.xb())},r=tc.prototype,r.add=function(t,e){this.set[t]=e!==l?e:k},r.contains=function(t){return D(this.set,t)},r.get=function(t){return this.set[t]},r.remove=function(t){delete this.set[t]},r.f=function(){var t;t:{for(t in this.set){t=o;break t}t=k}return t},r.count=function(){var t,e=0;for(t in this.set)e++;return e},r.keys=function(){var t,e=[];for(t in this.set)D(this.set,t)&&e.push(t);return e};var uc="pLPCommand",vc="pRTLPCB",xc,yc;wc.prototype.open=function(t,e){function n(){if(!i.Ea){i.ea=new zc(function(t,e,n,r,a){if(ic(i.$,"bytes_received",y(arguments).length),i.ea)if(i.Ba&&(clearTimeout(i.Ba),i.Ba=l),i.ab=k,"start"==t)i.id=e,i.Tc=n;else if("close"===t)if(e){i.ea.Zc=o;var s=i.Pc;s.ic=e,s.Ga=function(){i.Ha()},s.ic<s.Oa&&(s.Ga(),s.Ga=l)}else i.Ha();else g(Error("Unrecognized command received: "+t))},function(t,e){ic(i.$,"bytes_received",y(arguments).length);var n=i.Pc;for(n.Qb[t]=e;n.Qb[n.Oa];){var r=n.Qb[n.Oa];delete n.Qb[n.Oa];for(var o=0;o<r.length;++o)r[o]&&n.sc(r[o]);if(n.Oa===n.ic){n.Ga&&(clearTimeout(n.Ga),n.Ga(),n.Ga=l);break}n.Oa++}},function(){i.Ha()},i.Ab);var t={start:"t"};t.ser=Math.floor(1e8*Math.random()),i.ea.cc&&(t.cb=i.ea.cc),t.v="5",i.Zb&&(t.s=i.Zb),t=i.Ab(t),i.e("Connecting via long-poll to "+t),Ac(i.ea,t,function(){})}}this.Ec=0,this.va=e,this.Pc=new fc(t),this.Ea=o;var i=this;if(this.Ba=setTimeout(function(){i.e("Timed out trying to connect."),i.Ha(),i.Ba=l},3e4),"complete"===document.readyState)n();else{var r=o,a=function(){document.body?r||(r=k,n()):setTimeout(a,10)};document.addEventListener?(document.addEventListener("DOMContentLoaded",a,o),window.addEventListener("load",a,o)):document.attachEvent&&(document.attachEvent("onreadystatechange",function(){"complete"===document.readyState&&a()},o),window.attachEvent("onload",a,o))}},wc.prototype.start=function(){var t=this.ea,e=this.Tc;for(t.td=this.id,t.ud=e,t.fc=k;Bc(t););t=this.id,e=this.Tc,this.Ta=document.createElement("iframe");var n={dframe:"t"};n.id=t,n.pw=e,t=this.Ab(n),this.Ta.src=t,this.Ta.style.display="none",document.body.appendChild(this.Ta)},wc.isAvailable=function(){return!yc&&(xc||k)},wc.prototype.xb=function(){this.Ea=k,this.ea&&(this.ea.close(),this.ea=l),this.Ta&&(document.body.removeChild(this.Ta),this.Ta=l),this.Ba&&(clearTimeout(this.Ba),this.Ba=l)},wc.prototype.Ha=function(){this.Ea||(this.e("Longpoll is closing itself"),this.xb(),this.va&&(this.va(this.ab),this.va=l))},wc.prototype.close=function(){this.Ea||(this.e("Longpoll is being closed."),this.xb())},wc.prototype.send=function(t){t=y(t),ic(this.$,"bytes_sent",t.length);for(var t=ra(t),t=Ib(t,k),t=Zb(t,1840),e=0;e<t.length;e++){var n=this.ea;n.qb.push({Ad:this.Ec,Gd:t.length,Fc:t[e]}),n.fc&&Bc(n),this.Ec++}},zc.prototype.close=function(){if(this.fc=o,this.ca){this.ca.qa.body.innerHTML="";var t=this;setTimeout(function(){t.ca!==l&&(document.body.removeChild(t.ca),t.ca=l)},0)}var e=this.da;e&&(this.da=l,e())};var Dc=[wc,{isAvailable:p(o)},pc];Ec.prototype.wc=function(t){t={t:"d",d:t},1!==this.ma&&g("Connection is not connected"),this.yb.send(t)},Ec.prototype.Kb=function(t){this.sc(t)},Ec.prototype.close=function(){2!==this.ma&&(this.e("Closing realtime connection."),this.ma=2,Jc(this),this.va&&(this.va(),this.va=l))};var Lc=0,Mc=0;r=Kc.prototype,r.ya=function(t,e,n,i){var r=++this.zd,t={r:r,a:t,b:e};this.e(y(t)),this.S?this.sb.wc(t):this.Rb.push(t);var o=this,t=setTimeout(function(){var t=o.xa[r];t&&(delete o.xa[r],t.ha&&t.ha.Nb&&t.ha.Nb())},45e3);this.xa[r]={ha:{Mb:n,Nb:i},bd:t}},r.Za=function(t,e,n){this.Ca={kd:t,Ic:o,fa:e,Cb:n},this.e("Authenticating using credential: "+this.Ca),Pc(this)},r.zb=function(){delete this.Ca,this.kb(o),this.S&&this.ya("unauth",{},function(){},function(){})},r.dd=function(t,e,n){if(t=t.toString(),Oc(this,t,e)&&this.S){this.e("Unlisten on "+t+" for "+e);var i=this,t={p:t},n=mb(n,function(t){return Ja(t)});"{}"!==e&&(t.q=n),this.ya("u",t,l,function(){i.e("timed out on unlisten...")})}},r.qc=function(t,e){this.S?Rc(this,"oc",t,l,e):this.lb.push({uc:t,action:"oc",data:l,A:e})},r.put=function(t,e,n,i){Sc(this,"p",t,e,n,i)},r.Kb=function(t){if("r"in t){this.e("from server: "+y(t));var e=t.r,n=this.xa[e];n&&(delete this.xa[e],clearTimeout(n.bd),n.ha&&n.ha.Mb&&n.ha.Mb(t.b))}else"error"in t&&g("A server-side error has occurred: "+t.error),"a"in t&&(e=t.a,t=t.b,this.e("handleServerMessage",e,t),"d"===e?this.Lb(t.p,t.d):"m"===e?this.Lb(t.p,t.d,k):"c"===e?(e=t.p,t=(t=t.q)?mb(t,function(t){return Ka(t)}).join("$"):"{}",(t=Oc(this,e,t))&&t.A&&t.A("permission_denied")):"ac"===e?(e=t.s,t=t.d,n=this.Ca,delete this.Ca,n&&n.Cb&&n.Cb(e,t),this.kb(o)):"sd"===e?this.vc?this.vc(t):"msg"in t&&"undefined"!=typeof console&&console.log("FIREBASE: "+t.msg.replace("\n","\nFIREBASE: ")):Tb("Unrecognized action received from server: "+y(e)+"\nAre you using the latest client?"))},r.mb=function(t){for(this.e("connection ready"),this.S=k,this.hb=(new Date).getTime(),Yb=t-(new Date).getTime(),t=0;t<this.Rb.length;t++)this.sb.wc(this.Rb[t]);for(this.Rb=[],Pc(this),t=0;t<this.O.length;t++)this.O[t]&&Tc(this,t);for(var e in this.ba)for(var n in this.ba[e])t=this.ba[e][n],Nc(this,e,n,t.Va,t.A);for(;this.lb.length;)e=this.lb.shift(),Rc(this,e.action,e.uc,e.data,e.A);this.Jb(k)},r.Rc=function(){this.S=o,this.e("data client disconnected");var t=u(function(){this.Gc()},this);if(this.wb){this.hb&&(3e4<(new Date).getTime()-this.hb&&(this.Ub=1e3),this.hb=l);var e=Math.max(0,this.Ub-((new Date).getTime()-this.Oc)),e=Math.random()*e;this.e("Trying to reconnect in "+e+"ms"),setTimeout(t,e),this.Ub=Math.min(3e5,1.5*this.Ub)}else{for(var n=0;n<this.O.length;n++){var i=this.O[n];i&&"h"in i.Vc&&(i.A&&i.A("disconnect"),delete this.O[n],this.nb--)}0===this.nb&&(this.O=[]);for(e in this.xa)n=this.xa[e],delete this.xa[e],n!==l&&(n.ha&&n.ha.Nb&&n.ha.Nb(),clearTimeout(n.bd));this.Xc=function(){setTimeout(t,0)}}this.Jb(o)},r.Gc=function(){if(this.wb){this.e("Making a connection attempt"),this.Oc=(new Date).getTime(),this.hb=l;var t=u(this.Kb,this),e=u(this.mb,this),n=u(this.Rc,this),i=this.id+":"+Mc++,r=this;this.sb=new Ec(i,this.M,t,e,n,function(t){r.wb=o,g(Error(t))})}},r.Ra=function(){this.wb=o,this.sb?this.sb.close():this.Rc()},r.ub=function(){this.wb=k,this.Xc(),this.Xc=j},Uc.prototype.toString=function(){return this.Ka.toString()},Vc.prototype.set=function(t,e){var n=this,i=[];return lb(e,function(t){var e=t.path,t=t.Fa,r=Jb();M(J(n.pb,e),r),U(n.K,e,t),i.push({path:e,Bd:r})}),i},ad.prototype.Sb=function(t,e){e=this.Tb(t,e),e!=l&&fd(this,e)},ka(hd,ad),hd.prototype.Tb=function(t,e){return this.g=t,this.fb&&e!=l&&e.push(new V("value",this.g)),e},hd.prototype.bb=function(){return{}},ka(md,tc),r=md.prototype,r.setActive=function(t){this.na=t},r.defaultView=function(){return nd(this)?this.get("default"):l},r.path=aa("L"),r.toString=function(){return mb(this.keys(),function(t){return"default"===t?"{}":t}).join("$")},r.Va=function(){var t=[];return S(this.set,function(e){t.push(e.I)}),t},ka(pd,ad),pd.prototype.Tb=function(t,e){if(e===l)return e;var n=[],i=this.I;s(i.Z)&&(s(i.la)&&i.la!=l?n.push(function(t,e){var n=Wb(e,i.Z);return n>0||0===n&&t>=i.la}):n.push(function(t,e){return 0<=Wb(e,i.Z)})),s(i.ra)&&(s(i.Pa)?n.push(function(t,e){var n=Wb(e,i.ra);return 0>n||0===n&&t<=i.Pa}):n.push(function(t,e){return 0>=Wb(e,i.ra)}));var r=l,a=l;if(s(this.I.ta))if(s(this.I.Z)){if(r=qd(t,n,this.I.ta,o)){var c=t.N(r).k();n.push(function(t,e){var n=Wb(e,c);return 0>n||0===n&&r>=t})}}else if(a=qd(t,n,this.I.ta,k)){var h=t.N(a).k();n.push(function(t,e){var n=Wb(e,h);return n>0||0===n&&t>=a})}for(var u=[],f=[],p=[],d=[],b=0;b<e.length;b++){var y=e[b].V,g=e[b].ja;switch(e[b].type){case"child_added":rd(n,y,g)&&(this.g=this.g.D(y,g),f.push(e[b]));break;case"child_removed":this.g.N(y).f()||(this.g=this.g.D(y,l),u.push(e[b]));break;case"child_changed":!this.g.N(y).f()&&rd(n,y,g)&&(this.g=this.g.D(y,g),d.push(e[b]));break;case"child_moved":var v=!this.g.N(y).f(),m=rd(n,y,g);v?m?(this.g=this.g.D(y,g),p.push(e[b])):(u.push(new V("child_removed",this.g.N(y),y)),this.g=this.g.D(y,l)):m&&(this.g=this.g.D(y,g),f.push(e[b]))}}var w=r||a;if(w){var F=(b=a!==l)?this.g.Kc():this.g.Lc(),S=o,A=o,E=this;(b?t.lc:t.B).call(t,function(t,e){return!A&&F===l&&(A=k),A&&S?k:(S?(u.push(new V("child_removed",E.g.N(t),t)),E.g=E.g.D(t,l)):A&&(f.push(new V("child_added",e,t)),E.g=E.g.D(t,e)),F===t&&(A=k),void(t===w&&(S=k)))})}for(b=0;b<f.length;b++)n=f[b],y=this.g.T(n.V,n.ja),u.push(new V("child_added",n.ja,n.V,y));for(b=0;b<p.length;b++)n=p[b],y=this.g.T(n.V,n.ja),u.push(new V("child_moved",n.ja,n.V,y));for(b=0;b<d.length;b++)n=d[b],y=this.g.T(n.V,n.ja),u.push(new V("child_changed",n.ja,n.V,y));return this.fb&&0<u.length&&u.push(new V("value",this.g)),u},pd.prototype.mc=function(t){return this.g.N(t)!==O},pd.prototype.bb=function(t,e,n){var i={};this.g.J()||this.g.B(function(t){i[t]=k});var r=this.g,n=T(n,new I("")),o=new Ra;M(J(o,this.I.path),k);var a=O.Ya(t,e),s=[];return jd(n,a,t,o,function(t,e,n){n!==l&&(s=s.concat(n))}),this.Tb(e,s),this.g.J()||this.g.B(function(t){i[t]=k}),this.g=r,i},sd.prototype.Bb=function(t,e,n,i,r){var o=t.path,a=J(this.pa,o),s=a.j();s===l?(s=new md,M(a,s)):z(!s.f(),"We shouldn't be storing empty QueryMaps");var c=t.Ia();if(s.contains(c))bd(s.get(c),e,n,i,r);else{var h=this.i.Ka.F(o),t="default"===t.Ia()?new hd(t,h):new pd(t,h);if(od(s)||td(a))s.add(c,t),s.L||(s.L=t.I.path);else{var u,f;s.f()||(u=s.toString(),f=s.Va()),s.add(c,t),s.L||(s.L=t.I.path),s.setActive(ud(this,s)),u&&f&&this.n.dd(s.path(),u,f)}od(s)&&Ta(a,function(t){(t=t.j())&&(t.na&&t.na(),t.na=l)}),bd(t,e,n,i,r),(e=(e=Ua(J(this.pa,o),function(t){var e;return(e=t.j())&&(e=t.j().defaultView())&&(e=t.j().defaultView().fb),e?k:void 0},k))||this.n===l)&&gd(t)}},sd.prototype.Wb=function(t,e,n,i){var r=J(this.pa,t.path).j();return r===l?l:wd(this,r,t,e,n,i)},sd.prototype.Sb=function(t,e,n){t=J(this.pa,t).j(),t!==l&&S(t.set,function(t){t.Sb(e,n)})},sd.prototype.bb=function(t,e,n,i){var r={};return S(e.set,function(e){e=e.bb(t,n,i),S(e,function(t,e){r[e]=t?k:ua(r,e)||o})}),n.J()||n.B(function(t){D(r,t)||(r[t]=o)}),r},r=Cd.prototype,r.toString=function(){return(this.M.Yb?"https://":"http://")+this.M.host},r.name=function(){return this.M.jb},r.Lb=function(t,e,n){var i=[],r=l;if(9<=t.length&&t.lastIndexOf(".priority")===t.length-9)t=new I(t.substring(0,t.length-9)),n=T(this.i.za,t).ec(e),i.push(t);else if(n){var a,r=e,t=new I(t),n=T(this.i.za,t);for(a in e){var s=Q(e[a]),n=n.D(a,s);i.push(t.C(a))}}else t=new I(t),n=Q(e),i.push(t);for(e=Bd(this.Q,t,n,this.i.K,r),r=o,a=0;a<e.length;++a){var n=e[a],s=this.i,c=n.path;U(s.za,c,n.Fa),r=Wc(s,c)||r}r&&(t=Ed(this,t),Fd(this,t),t=t.path()),yd(this.Q,t,i)},r.Jb=function(t){Dd(this,"connected",t)},r.kb=function(t){Dd(this,"authenticated",t)},r.Za=function(t,e,n){this.n.Za(t,function(t,n){X(e,t,n)},function(t,e){if(Vb("auth() was canceled: "+e),n){var i=Error(e);i.code=t.toUpperCase(),n(i)}})},r.zb=function(){this.n.zb()},r.Xa=function(t,e,n,i){this.e("set",{path:t.toString(),value:e});var e=Q(e,n),n=Bd(this.Q,t,e,this.i.K,l),r=this.i.set(t,n),o=this;this.n.put(t.toString(),e.P(k),function(e){var n="ok"===e;Yc(o.i,r),n||(Vb("set at "+t+" failed: "+e),Wc(o.i,t),n=Ed(o,t),Fd(o,n),yd(o.Q,n.path(),[])),X(i,e)}),e=Ed(this,t),Gd(this,t),Fd(this,e),yd(this.Q,e.path(),[t])},r.update=function(t,e,n){this.e("update",{path:t.toString(),value:e});var i,r=T(this.i.Aa,t),a=k,s=[];for(i in e){var a=o,c=Q(e[i]),r=r.D(i,c);s.push(t.C(i))}if(a)Pb("update() called with empty data. Don't do anything."),X(n,"ok");else{var r=Bd(this.Q,t,r,this.i.K,e),h=this.i.set(t,r),u=this;Sc(this.n,"m",t.toString(),e,function(e){z("ok"===e||"permission_denied"===e,"merge at "+t+" failed."),Yc(u.i,h),X(n,e)},j),e=Ed(this,t),Gd(this,t),Fd(this,e),yd(this.Q,e.path(),s)}},r.xc=function(t,e,n){this.e("setPriority",{path:t.toString(),wa:e});var i=T(this.i.K,t).ec(e),i=Bd(this.Q,t,i,this.i.K,l),r=this.i.set(t,i),o=this;this.n.put(t.toString()+"/.priority",e,function(t){Yc(o.i,r),X(n,t)}),t=Ed(this,t),Fd(this,t),yd(this.Q,t.path(),[])},r.qc=function(t,e){this.n.qc(t.toString(),function(t){X(e,t)})},r.Bb=function(t,e,n,i,r){".info"===F(t.path)?this.nc.Bb(t,e,n,i,r):this.Q.Bb(t,e,n,i,r)},r.Wb=function(t,e,n,i){if(".info"===F(t.path))this.nc.Wb(t,e,n,i);else if(e=this.Q.Wb(t,e,n,i),e!==l){for(var n=this.i,t=t.path,i=[],r=0;r<e.length;++r)i[r]=T(n.za,e[r]);for(U(n.za,t,O),r=0;r<e.length;++r)U(n.za,e[r],i[r])}},r.Ra=function(){this.n.Ra()},r.ub=function(){this.n.ub()},r.yc=function(t){if("undefined"!=typeof console){t?(this.$b||(this.$b=new jc(this.$)),t=this.$b.get()):t=this.$.get();var e,n=t,i=[],r=0;for(e in n)i[r++]=e;var o=function(t,e){return Math.max(e.length,t)};if(i.reduce)e=i.reduce(o,0);else{var a=0;lb(i,function(t){a=o.call(j,a,t)}),e=a}for(var s in t){for(n=t[s],i=s.length;e+2>i;i++)s+=" ";console.log(s+n)}}},r.e=function(){Pb("r:"+this.n.id+":",arguments)},Y.pd=function(){return Y.Nc?Y.Nc:Y.Nc=new Y},Y.prototype.Ra=function(){for(var t in this.Wa)this.Wa[t].Ra()},Y.prototype.interrupt=Y.prototype.Ra,Y.prototype.ub=function(){for(var t in this.Wa)this.Wa[t].ub()},Y.prototype.resume=Y.prototype.ub;var Z={qd:function(t){var e=P.prototype.hash;return P.prototype.hash=t,function(){P.prototype.hash=e}}};Z.hijackHash=Z.qd,Z.Ia=function(t){return t.Ia()},Z.queryIdentifier=Z.Ia,Z.sd=function(t){return t.o.n.ba},Z.listens=Z.sd,Z.xd=function(t){return t.o.n.sb},Z.refConnection=Z.xd,Z.fd=Kc,Z.DataConnection=Z.fd,Kc.prototype.sendRequest=Kc.prototype.ya,Kc.prototype.interrupt=Kc.prototype.Ra,Z.gd=Ec,Z.RealTimeConnection=Z.gd,Ec.prototype.sendRequest=Ec.prototype.wc,Ec.prototype.close=Ec.prototype.close,Z.ed=sb,Z.ConnectionTarget=Z.ed,Z.nd=function(){xc=qc=k},Z.forceLongPolling=Z.nd,Z.od=function(){yc=k},Z.forceWebSockets=Z.od,Z.Dd=function(t,e){t.o.n.vc=e},Z.setSecurityDebugCallback=Z.Dd,Z.yc=function(t,e){t.o.yc(e)},Z.stats=Z.yc,ca("fb.api.onDisconnect",$),$.prototype.cancel=function(t){A("Firebase.onDisconnect().cancel",0,1,arguments.length),C("Firebase.onDisconnect().cancel",1,t,k),this.tb.qc(this.L,t)},$.prototype.cancel=$.prototype.cancel,$.prototype.remove=function(t){A("Firebase.onDisconnect().remove",0,1,arguments.length),E("Firebase.onDisconnect().remove",this.L),C("Firebase.onDisconnect().remove",1,t,k),Hd(this.tb,this.L,l,t)},$.prototype.remove=$.prototype.remove,$.prototype.set=function(t,e){A("Firebase.onDisconnect().set",1,2,arguments.length),E("Firebase.onDisconnect().set",this.L),za("Firebase.onDisconnect().set",t,o),C("Firebase.onDisconnect().set",2,e,k),Hd(this.tb,this.L,t,e)},$.prototype.set=$.prototype.set,$.prototype.Xa=function(t,e,n){A("Firebase.onDisconnect().setWithPriority",2,3,arguments.length),E("Firebase.onDisconnect().setWithPriority",this.L),za("Firebase.onDisconnect().setWithPriority",t,o),Ea("Firebase.onDisconnect().setWithPriority",2,e,o),C("Firebase.onDisconnect().setWithPriority",3,n,k),(".length"===this.ua||".keys"===this.ua)&&g("Firebase.onDisconnect().setWithPriority failed: "+this.ua+" is a read-only object.");var i=this.tb,r=this.L,a=Q(t,e);Qc(i.n,r.toString(),a.P(k),function(t){X(n,t)})},$.prototype.setWithPriority=$.prototype.Xa,$.prototype.update=function(t,e){A("Firebase.onDisconnect().update",1,2,arguments.length),E("Firebase.onDisconnect().update",this.L),Da("Firebase.onDisconnect().update",t),C("Firebase.onDisconnect().update",2,e,k);var n,i=this.tb,r=this.L,a=k;for(n in t)a=o;a?(Pb("onDisconnect().update() called with empty data. Don't do anything."),X(e,k)):(i=i.n,r=r.toString(),a=function(t){X(e,t)},i.S?Rc(i,"om",r,t,a):i.lb.push({uc:r,action:"om",data:t,A:a}))},$.prototype.update=$.prototype.update;var Pd,Qd=0,Rd=[];Pd=function(){var t=(new Date).getTime()+Yb,e=t===Qd;Qd=t;for(var n=Array(8),i=7;i>=0;i--)n[i]="-0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz".charAt(t%64),t=Math.floor(t/64);if(z(0===t),t=n.join(""),e){for(i=11;i>=0&&63===Rd[i];i--)Rd[i]=0;Rd[i]++}else for(i=0;12>i;i++)Rd[i]=Math.floor(64*Math.random());for(i=0;12>i;i++)t+="-0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz".charAt(Rd[i]);return z(20===t.length,"NextPushId: Length should be 20."),t},ka(W,G),ca("Firebase",W),W.prototype.name=function(){return A("Firebase.name",0,0,arguments.length),this.path.f()?l:Ma(this.path)},W.prototype.name=W.prototype.name,W.prototype.C=function(t){if(A("Firebase.child",1,1,arguments.length),ga(t))t=String(t);else if(!(t instanceof I))if(F(this.path)===l){var e=t;e&&(e=e.replace(/^\/*\.info(\/|$)/,"/")),Ha("Firebase.child",e)}else Ha("Firebase.child",t);return new W(this.o,this.path.C(t))},W.prototype.child=W.prototype.C,W.prototype.parent=function(){A("Firebase.parent",0,0,arguments.length);var t=this.path.parent();return t===l?l:new W(this.o,t)},W.prototype.parent=W.prototype.parent,W.prototype.toString=function(){A("Firebase.toString",0,0,arguments.length);var t;if(this.parent()===l)t=this.o.toString();else{t=this.parent().toString()+"/";var e=this.name();t+=encodeURIComponent(String(e))}return t},W.prototype.toString=W.prototype.toString,W.prototype.set=function(t,e){return A("Firebase.set",1,2,arguments.length),E("Firebase.set",this.path),za("Firebase.set",t,o),C("Firebase.set",2,e,k),this.o.Xa(this.path,t,l,e)},W.prototype.set=W.prototype.set,W.prototype.update=function(t,e){return A("Firebase.update",1,2,arguments.length),E("Firebase.update",this.path),Da("Firebase.update",t),C("Firebase.update",2,e,k),this.o.update(this.path,t,e)},W.prototype.update=W.prototype.update,W.prototype.Xa=function(t,e,n){return A("Firebase.setWithPriority",2,3,arguments.length),E("Firebase.setWithPriority",this.path),za("Firebase.setWithPriority",t,o),Ea("Firebase.setWithPriority",2,e,o),C("Firebase.setWithPriority",3,n,k),(".length"===this.name()||".keys"===this.name())&&g("Firebase.setWithPriority failed: "+this.name()+" is a read-only object."),this.o.Xa(this.path,t,e,n)},W.prototype.setWithPriority=W.prototype.Xa,W.prototype.remove=function(t){A("Firebase.remove",0,1,arguments.length),E("Firebase.remove",this.path),C("Firebase.remove",1,t,k),this.set(l,t)},W.prototype.remove=W.prototype.remove,W.prototype.transaction=function(t,e){function n(){}A("Firebase.transaction",1,2,arguments.length),E("Firebase.transaction",this.path),C("Firebase.transaction",1,t,o),C("Firebase.transaction",2,e,k),(".length"===this.name()||".keys"===this.name())&&g("Firebase.transaction failed: "+this.name()+" is a read-only object.");var i=this.o,r=this.path;i.e("transaction on "+r);var a=new W(i,r);a.oc("value",n);var c={path:r,update:t,A:e,Sc:Jb(),Yc:0,dc:function(){a.Ib("value",n)}},h=i.i.Aa,u=c.update(T(h,r).P());if(s(u)){Aa("transaction failed: Data returned ",u);var f=T(i.i.K,r).k();U(h,r,Q(u,f)),yd(i.Q,r,[r]),c.status=1,r=J(i.ac,r),h=r.j()||[],h.push(c),M(r,h),Ld(i)}else c.dc(),c.A&&(i=Jd(i,r),c.A(l,o,i))},W.prototype.transaction=W.prototype.transaction,W.prototype.xc=function(t,e){A("Firebase.setPriority",1,2,arguments.length),E("Firebase.setPriority",this.path),Ea("Firebase.setPriority",1,t,o),C("Firebase.setPriority",2,e,k),this.o.xc(this.path,t,e)},W.prototype.setPriority=W.prototype.xc,W.prototype.push=function(t,e){A("Firebase.push",0,2,arguments.length),E("Firebase.push",this.path),za("Firebase.push",t,k),C("Firebase.push",2,e,k);var n=Pd(),n=this.C(n);return"undefined"!=typeof t&&t!==l&&n.set(t,e),n},W.prototype.push=W.prototype.push,W.prototype.da=function(){return new $(this.o,this.path,this.name())},W.prototype.onDisconnect=W.prototype.da,W.prototype.yd=function(){Vb("FirebaseRef.removeOnDisconnect() being deprecated. Please use FirebaseRef.onDisconnect().remove() instead."),this.da().remove(),Id(this.o)},W.prototype.removeOnDisconnect=W.prototype.yd,
W.prototype.Cd=function(t){Vb("FirebaseRef.setOnDisconnect(value) being deprecated. Please use FirebaseRef.onDisconnect().set(value) instead."),this.da().set(t),Id(this.o)},W.prototype.setOnDisconnect=W.prototype.Cd,W.prototype.Za=function(e,n,i){A("Firebase.auth",1,3,arguments.length),t(e)||g(Error(B("Firebase.auth",1,o)+"must be a valid credential (a string).")),C("Firebase.auth",2,n,k),C("Firebase.auth",3,n,k),this.o.Za(e,n,i)},W.prototype.auth=W.prototype.Za,W.prototype.zb=function(){this.o.zb()},W.prototype.unauth=W.prototype.zb,W.enableLogging=Qb,W.INTERNAL=Z,W.Context=Y}();
!function(){function e(e,n){if(e||(e={}),!n)return e;for(var r in n)e[r]=n[r];return e}window.FileBufferReader=function(){var e=this;e.chunks={},e.readAsArrayBuffer=function(r,t,o){return r?(o=o||{},o.chunkSize=o.chunkSize||12e3,void n.Read(r,function(n){n=n||{},r.extra=o||{},r.url=URL.createObjectURL(r),n.file=r,e.chunks[n.uuid]=n,t(n.uuid)},o)):void console.error("File or Blob is missing.")},e.setMultipleUsers=function(n,r){if(!(r&&r instanceof Array))return void console.error("Exepcted array of user-ids but either NULL or invalid value passed.");var t=e.chunks[n];if(!t)return void console.error("No such file exists.");if(t.file)e.chunks[n]={};else for(var o in t)t=t[o];r.forEach(function(r){var o={};for(var i in t)o[i]=t[i];var a=new Blob([o.file],{type:o.file.type});for(var c in o.file)a[c]||(a[c]=o.file[c]);e.chunks[n][r]=o,e.chunks[n][r].file=a})},e.getNextChunk=function(n,t,o){if(!n)return void console.error('"uuid" is missing.');var i=e.chunks[n];if(i&&(!o||(i=i[o]))){var a=i.listOfChunks[i.currentPosition];if(a){var c=a.end;r.ConvertToArrayBuffer(a,function(r){return 0==i.currentPosition&&(i.file.remoteUserId=o||"",e.onBegin(i.file)),c&&(i.file.remoteUserId=o||"",e.onEnd(i.file)),t(r,c,a.extra),e.onProgress({currentPosition:i.currentPosition,maxChunks:i.maxChunks,uuid:i.uuid,extra:a.extra,remoteUserId:o||""}),o?void e.chunks[n][o].currentPosition++:void e.chunks[n].currentPosition++})}}},e.onBegin=e.onProgress=e.onEnd=function(){};var t=new n.Receiver(e);e.addChunk=function(e,n){return e?void t.receive(e,function(e){r.ConvertToArrayBuffer({readyForNextChunk:!0,uuid:e},n)}):void console.error("Chunk is missing.")},e.convertToObject=r.ConvertToObject,e.convertToArrayBuffer=r.ConvertToArrayBuffer},window.FileSelector=function(){function e(e,r){var t=document.createElement("input");t.type="file",r&&(t.multiple=!0),t.onchange=function(){return r?t.files.length?void e(t.files):void console.error("No file selected."):t.files[0]?void e(t.files[0]):void console.error("No file selected.")},n(t)}function n(e){var n=new window.MouseEvent("click",{view:window,bubbles:!0,cancelable:!0});e.dispatchEvent(n)}var r=this;r.selectSingleFile=e,r.selectMultipleFiles=function(n){e(n,!0)}};var n={Read:function(e,n,r){function t(e,n,t){o=Math.ceil(n.byteLength/s);for(var u=0;o>u;u++){var l=u*s;c[a]={uuid:d,value:n.slice(l,Math.min(l+s,n.byteLength)),currentPosition:a,maxChunks:R,extra:r},a++}a==R&&(i=!0),t()}r=r||{};var o,i,a=1,c={},s=r.chunkSize||6e4,u=0,l=s,f=Math.floor(Math.min(1e8,l)/s),A=f*s,R=Math.ceil(e.size/s),d=e.uuid||(Math.random()*(new Date).getTime()).toString(36).replace(/\./g,"-");c[0]={uuid:d,maxChunks:R,size:e.size,name:e.name,lastModifiedDate:e.lastModifiedDate+"",type:e.type,start:!0,extra:r},e.maxChunks=R,e.uuid=d;var v,h=new FileReader;h.onloadend=function(o){o.target.readyState==FileReader.DONE&&t(e.name,o.target.result,function(){u++,(u+1)*A<e.size?(v=e.slice(u*A,(u+1)*A),h.readAsArrayBuffer(v)):u*A<e.size?(v=e.slice(u*A,e.size),h.readAsArrayBuffer(v)):(c[a]={uuid:d,maxChunks:R,size:e.size,name:e.name,lastModifiedDate:e.lastModifiedDate+"",type:e.type,end:!0,extra:r},n({currentPosition:0,listOfChunks:c,maxChunks:R+1,uuid:d,extra:r}))})},v=e.slice(u*A,(u+1)*A),h.readAsArrayBuffer(v)},Receiver:function(n){function t(i,a){if(!i.uuid)return void r.ConvertToObject(i,function(e){t(e)});if(i.start&&!o[i.uuid]&&(o[i.uuid]=[],n.onBegin&&n.onBegin(i)),!i.end&&i.value&&o[i.uuid].push(i.value),i.end){for(var c=o[i.uuid],s=[],u=c.length,l=0;u>l;l++)c[l]&&s.push(c[l]);var f=new Blob(s,{type:i.type});f=e(f,i),f.url=URL.createObjectURL(f),f.uuid=i.uuid,f.size||console.error("Something went wrong. Blob Size is 0."),n.onEnd&&n.onEnd(f)}i.value&&n.onProgress&&n.onProgress(i),i.end||a(i.uuid)}var o={};return{receive:t}},SaveToDisk:function(e,n){var r=document.createElement("a");r.href=e,r.target="_blank",r.download=n||e;var t=new MouseEvent("click",{view:window,bubbles:!0,cancelable:!0});r.dispatchEvent(t),(window.URL||window.webkitURL).revokeObjectURL(r.href)}},r={ConvertToArrayBuffer:function(e,n){binarize.pack(e,function(e){n(e.buffer)})},ConvertToObject:function(e,n){binarize.unpack(e,n)}};!function(e){var n=!1,r=!1,t=!0,o=Uint8Array.BYTES_PER_ELEMENT,i=Uint16Array.BYTES_PER_ELEMENT,a=Uint32Array.BYTES_PER_ELEMENT,c={NULL:0,UNDEFINED:1,STRING:2,NUMBER:3,BOOLEAN:4,ARRAY:5,OBJECT:6,INT8ARRAY:7,INT16ARRAY:8,INT32ARRAY:9,UINT8ARRAY:10,UINT16ARRAY:11,UINT32ARRAY:12,FLOAT32ARRAY:13,FLOAT64ARRAY:14,ARRAYBUFFER:15,BLOB:16,FILE:16,BUFFER:17};if(n)var s=["NULL","UNDEFINED","STRING","NUMBER","BOOLEAN","ARRAY","OBJECT","INT8ARRAY","INT16ARRAY","INT32ARRAY","UINT8ARRAY","UINT16ARRAY","UINT32ARRAY","FLOAT32ARRAY","FLOAT64ARRAY","ARRAYBUFFER","BLOB","BUFFER"];var u=[null,null,"Uint16","Float64","Uint8",null,null,"Int8","Int16","Int32","Uint8","Uint16","Uint32","Float32","Float64","Uint8","Uint8","Uint8"],l=function(e,n,t){var o=[],i=r,a=40;o[0]=[];for(var c=0;a>c;c++)o[0][c]=10>c?"0"+c.toString(10):c.toString(10);for(c=0;t>c;c++){var s=e.getUint8(n+c,i),u=~~(c/a)+1;"undefined"==typeof o[u]&&(o[u]=[]),o[u][c%a]=16>s?"0"+s.toString(16):s.toString(16)}for(console.log("%c"+o[0].join(" "),"font-weight: bold;"),c=1;c<o.length;c++)console.log(o[c].join(" "))},f=function(e){var n=void 0;if(void 0===e)n=c.UNDEFINED;else if(null===e)n=c.NULL;else{var r=e.constructor.name;if(void 0!==r)n=c[r.toUpperCase()];else switch(typeof e){case"string":n=c.STRING;break;case"number":n=c.NUMBER;break;case"boolean":n=c.BOOLEAN;break;case"object":e instanceof Array?n=c.ARRAY:e instanceof Int8Array?n=c.INT8ARRAY:e instanceof Int16Array?n=c.INT16ARRAY:e instanceof Int32Array?n=c.INT32ARRAY:e instanceof Uint8Array?n=c.UINT8ARRAY:e instanceof Uint16Array?n=c.UINT16ARRAY:e instanceof Uint32Array?n=c.UINT32ARRAY:e instanceof Float32Array?n=c.FLOAT32ARRAY:e instanceof Float64Array?n=c.FLOAT64ARRAY:e instanceof ArrayBuffer?n=c.ARRAYBUFFER:e instanceof Blob?n=c.BLOB:e instanceof Buffer?n=c.BUFFER:e instanceof Object&&(n=c.OBJECT)}}return n},A=function(t){var f=0,A=0,R=0,d=r,v=new ArrayBuffer(t[0].byte_length+t[0].header_size),h=new DataView(v);for(A=0;A<t.length;A++){var E=f,T=t[A].header_size,U=t[A].type,N=t[A].length,b=t[A].value,g=t[A].byte_length,B=u[U],y=null===B?0:e[B+"Array"].BYTES_PER_ELEMENT;switch(U===c.BUFFER?h.setUint8(f,c.BLOB,d):h.setUint8(f,U,d),f+=o,n&&console.info("Packing",U,s[U]),U!==c.ARRAY&&U!==c.OBJECT||(h.setUint16(f,N,d),f+=i,n&&console.info("Content Length",N)),h.setUint32(f,g,d),f+=a,n&&(console.info("Header Size",T,"bytes"),console.info("Byte Length",g,"bytes")),U){case c.NULL:case c.UNDEFINED:break;case c.STRING:for(n&&console.info('Actual Content %c"'+b+'"',"font-weight:bold;"),R=0;N>R;R++,f+=y)h.setUint16(f,b.charCodeAt(R),d);break;case c.NUMBER:case c.BOOLEAN:n&&console.info("%c"+b.toString(),"font-weight:bold;"),h["set"+B](f,b,d),f+=y;break;case c.INT8ARRAY:case c.INT16ARRAY:case c.INT32ARRAY:case c.UINT8ARRAY:case c.UINT16ARRAY:case c.UINT32ARRAY:case c.FLOAT32ARRAY:case c.FLOAT64ARRAY:var Y=new Uint8Array(h.buffer,f,g);Y.set(new Uint8Array(b.buffer)),f+=g;break;case c.ARRAYBUFFER:case c.BUFFER:var Y=new Uint8Array(h.buffer,f,g);Y.set(new Uint8Array(b)),f+=g;break;case c.BLOB:case c.ARRAY:case c.OBJECT:break;default:throw"TypeError: Unexpected type found."}n&&l(h,E,f-E)}return h},R=function(t,f){var A,d,v,h,E,T=0,U=r,N=f;A=t.getUint8(f,U),f+=o,n&&console.info("Unpacking",A,s[A]),A!==c.ARRAY&&A!==c.OBJECT||(d=t.getUint16(f,U),f+=i,n&&console.info("Content Length",d)),v=t.getUint32(f,U),f+=a,n&&console.info("Byte Length",v,"bytes");var b=u[A],g=null===b?0:e[b+"Array"].BYTES_PER_ELEMENT;switch(A){case c.NULL:case c.UNDEFINED:n&&l(t,N,f-N),h=null;break;case c.STRING:d=v/g;var B=[];for(T=0;d>T;T++){var y=t.getUint16(f,U);f+=g,B.push(String.fromCharCode(y))}h=B.join(""),n&&(console.info('Actual Content %c"'+h+'"',"font-weight:bold;"),l(t,N,f-N));break;case c.NUMBER:h=t.getFloat64(f,U),f+=g,n&&(console.info('Actual Content %c"'+h.toString()+'"',"font-weight:bold;"),l(t,N,f-N));break;case c.BOOLEAN:h=1===t.getUint8(f,U),f+=g,n&&(console.info('Actual Content %c"'+h.toString()+'"',"font-weight:bold;"),l(t,N,f-N));break;case c.INT8ARRAY:case c.INT16ARRAY:case c.INT32ARRAY:case c.UINT8ARRAY:case c.UINT16ARRAY:case c.UINT32ARRAY:case c.FLOAT32ARRAY:case c.FLOAT64ARRAY:case c.ARRAYBUFFER:E=t.buffer.slice(f,f+v),f+=v,h=A===c.ARRAYBUFFER?E:new e[b+"Array"](E),n&&l(t,N,f-N);break;case c.BLOB:if(n&&l(t,N,f-N),e.Blob){var Y=R(t,f),k=R(t,Y.cursor);f=k.cursor,h=new Blob([k.value],{type:Y.value})}else E=t.buffer.slice(f,f+v),f+=v,h=new Buffer(E);break;case c.ARRAY:for(n&&l(t,N,f-N),h=[],T=0;d>T;T++)E=R(t,f),f=E.cursor,h.push(E.value);break;case c.OBJECT:for(n&&l(t,N,f-N),h={},T=0;d>T;T++){var I=R(t,f),L=R(t,I.cursor);f=L.cursor,h[I.value]=L.value}break;default:throw"TypeError: Type not supported."}return{value:h,cursor:f}},d=function(e,n){for(var r=e.length,t=[],o=0,i=0,a=0;a<e.length;a++)!function(a){v(e[a],function(e){if(t[a]=e,i+=e[0].header_size+e[0].byte_length,++o===r){for(var c=[],s=0;s<t.length;s++)c=c.concat(t[s]);n(c,i)}})}(a)},v=function(n,r){var t,s=[],l=1,A=o+a,R=0,v=0,h=n;switch(t=f(n),l=void 0===u[t]||null===u[t]?0:e[u[t]+"Array"].BYTES_PER_ELEMENT,t){case c.UNDEFINED:case c.NULL:break;case c.NUMBER:case c.BOOLEAN:R=l;break;case c.STRING:v=n.length,R+=v*l;break;case c.INT8ARRAY:case c.INT16ARRAY:case c.INT32ARRAY:case c.UINT8ARRAY:case c.UINT16ARRAY:case c.UINT32ARRAY:case c.FLOAT32ARRAY:case c.FLOAT64ARRAY:v=n.length,R+=v*l;break;case c.ARRAY:return void d(n,function(e,o){r([{type:t,length:n.length,header_size:A+i,byte_length:o,value:null}].concat(e))});case c.OBJECT:var E=[];for(var T in n)n.hasOwnProperty(T)&&(E.push(T),E.push(n[T]),v++);return void d(E,function(e,n){r([{type:t,length:v,header_size:A+i,byte_length:n,value:null}].concat(e))});case c.ARRAYBUFFER:R+=n.byteLength;break;case c.BLOB:var U=n.type,N=new FileReader;return N.onload=function(e){d([U,e.target.result],function(e,n){r([{type:t,length:v,header_size:A,byte_length:n,value:null}].concat(e))})},N.onerror=function(e){throw"FileReader Error: "+e},void N.readAsArrayBuffer(n);case c.BUFFER:R+=n.length;break;default:throw'TypeError: Type "'+n.constructor.name+'" not supported.'}r([{type:t,length:v,header_size:A,byte_length:R,value:h}].concat(s))},h=function(e,n){var r=e instanceof DataView?e:new DataView(e),t=R(r,0);return t.value};n&&(e.Test={BIG_ENDIAN:r,LITTLE_ENDIAN:t,Types:c,pack:A,unpack:R,serialize:v,deserialize:h});var E={pack:function(e,r){try{n&&console.info("%cPacking Start","font-weight: bold; color: red;",e),v(e,function(e){n&&console.info("Serialized Object",e),r(A(e))})}catch(t){throw t}},unpack:function(e,r){try{n&&console.info("%cUnpacking Start","font-weight: bold; color: red;",e);var t=h(e);n&&console.info("Deserialized Object",t),r(t)}catch(o){throw o}}};"undefined"!=typeof module&&module.exports?module.exports=E:e.binarize=E}("undefined"!=typeof global?global:this)}();
!function(){function e(e,n){function u(n){return n.data.checkingPresence&&e.channels[n.userid]?void e.channels[n.userid].send({presenceDetected:!0}):n.data.presenceDetected&&e.peers[n.userid]?void(e.peers[n.userid].connected=!0):void("text"===n.data.type?ee.receive(n.data,n.userid,n.extra):e.autoTranslateText?(n.original=n.data,e.Translator.TranslateText(n.data,function(t){n.data=t,e.onmessage(n)})):e.onmessage(n))}function M(n){return e.skipOnNewSession||(n.session||(n.session={}),n.extra||(n.extra={}),e.sessionid&&n.sessionid!=e.sessionid)?void 0:e.onNewSession?(n.join=function(t){if(!t)return e.join(n);for(var i in t)n.session[i]=t[i];var o=e.dontCaptureUserMedia;e.dontCaptureUserMedia=!1,e.captureUserMedia(function(){e.dontCaptureUserMedia=!0,e.join(n),e.dontCaptureUserMedia=o},t)},n.extra||(n.extra={}),e.onNewSession(n)):void e.join(n)}function O(n){for(var t=0;t<e.localStreamids.length;t++){var i=e.localStreamids[t];e.streams[i]&&e.streams[i].sockets.push(n)}}function E(n){function t(n){return H||W||o(e.waitUntilRemoteStreamStartsFlowing)||!e.waitUntilRemoteStreamStartsFlowing?l(n):(n.numberOfTimes||(n.numberOfTimes=0),n.numberOfTimes++,n.mediaElement.readyState<=HTMLMediaElement.HAVE_CURRENT_DATA||n.mediaElement.paused||n.mediaElement.currentTime<=0?n.numberOfTimes>=60?U.send({failedToReceiveRemoteVideo:!0,streamid:n.stream.streamid}):void setTimeout(function(){m("Waiting for incoming remote stream to be started flowing: "+n.numberOfTimes+" seconds."),t(n)},900):l(n))}function d(){if(e.fakeDataChannels&&!e.channels[n.userid]&&!e.session.data){var t={send:function(e){U.send({fakeData:e})},readyState:"open"};e.channels[n.userid]={channel:t,send:function(e){this.channel.send(e)}},B.onopen(t)}}function l(t){var i=t.mediaElement,o=t.session,s=t.stream;s.onended=function(){a.mediaElement&&!a.mediaElement.parentNode&&document.getElementById(s.streamid)&&(a.mediaElement=document.getElementById(s.streamid)),g(a,e)};var a={mediaElement:i,stream:s,streamid:s.streamid,session:o||e.session,blobURL:W?"":i.mozSrcObject?URL.createObjectURL(s):i.src,type:"remote",extra:n.extra,userid:n.userid,isVideo:W?!!o.video:!!s.isVideo,isAudio:W?!!o.audio&&!o.video:!!s.isAudio,isScreen:!!s.isScreen,isInitiator:!!n.isInitiator,rtcMultiConnection:e,socket:U};if(e.streams[s.streamid]=e._getStream(a),e.onstream(a),!r(t.preMuted)&&(t.preMuted.audio||t.preMuted.video)){var d=b({},a);d.session=b(d.session,t.preMuted),d.isAudio=!!d.session.audio&&!d.session.video,d.isVideo=!!d.session.video,d.isScreen=!1,e.onmute(d)}m("on:add:stream",a),x(),e.onspeaking&&D({stream:s,streamedObject:a,connection:e})}function C(t){n.channel=t,e.channels[n.userid]={channel:n.channel,send:function(n){e.send(n,this.channel)}},e.onopen({extra:n.extra,userid:n.userid,channel:t});for(var o in e.fileQueue)e.send(e.fileQueue[o],t);i(e.session)&&x(),e.partOfScreen&&e.partOfScreen.sharing&&e.peers[n.userid].sharePartOfScreen(e.partOfScreen)}function R(){U.userid!=n.userid&&(U.userid=n.userid,K[n.socketIndex]=U,e.numberOfConnectedUsers++,e.peers[n.userid]={socket:U,peer:N,userid:n.userid,extra:n.extra,userinfo:n.userinfo,addStream:function(n){e.addStream(n,this.socket)},removeStream:function(n){return e.streams[n]?(this.peer.connection.removeStream(e.streams[n].stream),void this.renegotiate()):f("No such stream exists. Stream-id:",n)},renegotiate:function(n,t){e.renegotiate(n,t)},changeBandwidth:function(e){if(!e)throw"You MUST pass bandwidth object.";if(s(e))throw"Pass object for bandwidth instead of string; e.g. {audio:10, video:20}";this.peer.bandwidth=e,this.socket.send({changeBandwidth:!0,bandwidth:e})},sendCustomMessage:function(e){this.socket.send({customMessage:!0,message:e})},onCustomMessage:function(e){m('Received "private" message from',this.userid,s(e)?e:p(e))},drop:function(n){for(var t in e.streams)-1==e._skip.indexOf(t)&&(t=e.streams[t],t.userid==e.userid&&"local"==t.type&&(this.peer.connection.removeStream(t.stream),g(t,e)),"remote"==t.type&&t.userid==this.userid&&g(t,e));!n&&this.socket.send({drop:!0})},hold:function(n){return"answer"==N.prevCreateType?void this.socket.send({unhold:!0,holdMLine:n||"both",takeAction:!0}):(this.socket.send({hold:!0,holdMLine:n||"both"}),this.peer.hold=!0,void this.fireHoldUnHoldEvents({kind:n,isHold:!0,userid:e.userid,remoteUser:this.userid}))},unhold:function(n){return"answer"==N.prevCreateType?void this.socket.send({unhold:!0,holdMLine:n||"both",takeAction:!0}):(this.socket.send({unhold:!0,holdMLine:n||"both"}),this.peer.hold=!1,void this.fireHoldUnHoldEvents({kind:n,isHold:!1,userid:e.userid,remoteUser:this.userid}))},fireHoldUnHoldEvents:function(n){var t=n.isHold,i=n.kind,o=n.remoteUser||n.userid;for(var s in e.streams)-1==e._skip.indexOf(s)&&(s=e.streams[s],s.userid==o&&(t&&e.onhold(b({kind:i},s)),t||e.onunhold(b({kind:i},s))))},redial:function(){for(var n in e.streams)-1==e._skip.indexOf(n)&&(n=e.streams[n],n.userid==this.userid&&"remote"==n.type&&g(n,e));m("ReDialing..."),U.send({recreatePeer:!0}),N=new A,N.create("offer",B)},sharePartOfScreen:function(n){function t(){return i.stopPartOfScreenSharing?(i.stopPartOfScreenSharing=!1,void(e.onpartofscreenstopped&&e.onpartofscreenstopped())):i.pausePartOfScreenSharing?(e.onpartofscreenpaused&&e.onpartofscreenpaused(),setTimeout(t,n.interval||200)):void T({element:n.element,connection:e,callback:function(s){if(!e.channels[i.userid])throw"No such data channel exists.";s!=o&&(o=s,e.channels[i.userid].send({screenshot:s,isPartOfScreen:!0})),!n.once&&setTimeout(t,n.interval||200)}})}var i=this,o="";t()},getConnectionStats:function(n,t){function i(){re.prototype.getConnectionStats=window.getConnectionStats,N.connection&&N.connection.getConnectionStats(n,t)}if(!n)throw"callback is mandatory.";window.getConnectionStats?i():y(e.resources.getConnectionStats,i)},takeSnapshot:function(n){w({userid:this.userid,connection:e,callback:n})}})}function x(){if(e.isInitiator&&h(Z)&&h(Z)<=e.maxParticipantsAllowed&&(e.session.oneway||e.session.broadcast||ne.send({sessionid:e.sessionid,newParticipant:n.userid||U.channel,userData:{userid:n.userid||U.channel,extra:n.extra}})),"chrome"==n.userinfo.browser&&!n.renegotiatedOnce)for(var t in e.renegotiatedSessions)n.renegotiatedOnce=!0,e.renegotiatedSessions[t]&&e.renegotiatedSessions[t].stream&&e.peers[n.userid].renegotiate(e.renegotiatedSessions[t].stream,e.renegotiatedSessions[t].session)}function M(t){if(!te&&t.userid!=e.userid){if(t.sdp){n.userid=t.userid,n.extra=t.extra||{},n.renegotiate=t.renegotiate,n.streaminfo=t.streaminfo,n.isInitiator=t.isInitiator,n.userinfo=t.userinfo;var i=JSON.parse(t.sdp);"offer"==i.type&&(B.preferSCTP=!!t.preferSCTP,e.fakeDataChannels=!!t.fakeDataChannels),d(),E(i,t.labels)}if(t.candidate&&N&&N.addIceCandidate(JSON.parse(t.candidate)),t.streamid&&($.streamids||($.streamids={}),$.streamids[t.streamid]||($.streamids[t.streamid]=t.streamid,e.onstreamid(t))),t.mute||t.unmute)if(t.promptMuteUnmute){if(!e.privileges.canMuteRemoteStream)return void e.onstatechange({userid:t.userid,extra:t.extra,name:"mute-request-denied",reason:t.userid+' tried to mute your stream; however "privileges.canMuteRemoteStream" is "false".'});e.streams[t.streamid]&&(t.mute&&!e.streams[t.streamid].muted&&e.streams[t.streamid].mute(t.session),t.unmute&&e.streams[t.streamid].muted&&e.streams[t.streamid].unmute(t.session))}else{var o={};e.streams[t.streamid]&&(o=e.streams[t.streamid]);var s=t.session,r=b({},o);r.session=s,r.isAudio=!!r.session.audio&&!r.session.video,r.isVideo=!!r.session.video,r.isScreen=!!r.session.screen,t.mute&&e.onmute(r||t),t.unmute&&e.onunmute(r||t)}if(t.isVolumeChanged&&(m("Volume of stream: "+t.streamid+" has changed to: "+t.volume),e.streams[t.streamid])){var a=e.streams[t.streamid].mediaElement;a&&(a.volume=t.volume)}if(t.stopped&&e.streams[t.streamid]&&g(e.streams[t.streamid],e),t.promptStreamStop){if(!e.privileges.canStopRemoteStream)return void e.onstatechange({userid:t.userid,extra:t.extra,name:"stop-request-denied",reason:t.userid+' tried to stop your stream; however "privileges.canStopRemoteStream" is "false".'});f("Remote stream has been manually stopped!"),e.streams[t.streamid]&&e.streams[t.streamid].stop()}if(t.left){if(V){var u=t.userid;for(var l in e.streams)l=e.streams[l],l.userid==u&&(e.stopMediaStream(l),g(l,e))}if(N&&N.connection&&("closed"!=N.connection.signalingState&&-1==N.connection.iceConnectionState.search(/disconnected|failed/gi)&&N.connection.close(),N.connection=null),Z[t.userid]&&delete Z[t.userid],t.closeEntireSession)return e.onSessionClosed(t),void e.leave();e.remove(t.userid),S({userid:t.userid,extra:t.extra||{},entireSessionClosed:!!t.closeEntireSession},e)}if(t.playRoleOfBroadcaster&&(t.extra&&(e.extra=b(e.extra,t.extra)),t.participants&&(Z=t.participants,Z[e.userid]&&delete Z[e.userid],K[0]&&K[0].userid==t.userid&&(delete K[0],K=c(K)),X[t.userid]&&delete X[t.userid]),setTimeout(e.playRoleOfInitiator,2e3)),t.changeBandwidth){if(!e.peers[t.userid])throw"No such peer exists.";e.peers[t.userid].peer.bandwidth=t.bandwidth,e.peers[t.userid].renegotiate()}if(t.customMessage){if(!e.peers[t.userid])throw"No such peer exists.";if(t.message.ejected){if(e.sessionDescriptions[e.sessionid].userid!=t.userid)throw"only initiator can eject a user.";e.leave(),e.onSessionClosed({userid:t.userid,extra:t.extra||n.extra,isEjected:!0})}else e.peers[t.userid].onCustomMessage(t.message)}if(t.drop){if(!e.peers[t.userid])throw"No such peer exists.";e.peers[t.userid].drop(!0),e.peers[t.userid].renegotiate(),e.ondrop(t.userid)}if(t.hold||t.unhold){if(!e.peers[t.userid])throw"No such peer exists.";if(t.takeAction)return void e.peers[t.userid][t.hold?"hold":"unhold"](t.holdMLine);e.peers[t.userid].peer.hold=!!t.hold,e.peers[t.userid].peer.holdMLine=t.holdMLine,U.send({isRenegotiate:!0}),e.peers[t.userid].fireHoldUnHoldEvents({kind:t.holdMLine,isHold:!!t.hold,userid:t.userid})}t.isRenegotiate&&e.peers[t.userid].renegotiate(null,e.peers[t.userid].peer.session),t.fakeData&&B.onmessage(t.fakeData),t.recreatePeer&&(N=new A),t.failedToReceiveRemoteVideo&&(m("Remote peer hasn't received stream: "+t.streamid+". Renegotiating..."),e.peers[t.userid]&&e.peers[t.userid].renegotiate()),t.redial&&e.peers[t.userid]&&("disconnected"!=e.peers[t.userid].peer.connection.iceConnectionState&&(n.redialing=!1),"disconnected"!=e.peers[t.userid].peer.connection.iceConnectionState||n.redialing||(n.redialing=!0,f("Peer connection is closed.",p(e.peers[t.userid].peer.connection),"ReDialing.."),e.peers[t.userid].redial()))}}function E(t,o){function s(){N.recreateAnswer(t,r,function(n,t){L({sdp:n,socket:U,streaminfo:t}),e.detachStreams=[]})}if("answer"==t.type)return N.setRemoteDescription(t),void R();if(!n.renegotiate&&"offer"==t.type)return B.offerDescription=t,B.session=e.session,N||(N=new A),N.create("answer",B),void R();var r=n.renegotiate;if(P(o,N.connection),r.oneway||i(r))s(),delete n.renegotiate;else{if(n.capturing)return;n.capturing=!0,e.captureUserMedia(function(t){n.capturing=!1,N.addStream(t),e.renegotiatedSessions[JSON.stringify(n.renegotiate)]={session:n.renegotiate,stream:t},delete n.renegotiate,s()},n.renegotiate)}}var I={channel:n.channel,onmessage:M,onopen:function(t){t&&(U=t),F&&!N&&(B.session=e.session,N||(N=new A),N.create("offer",B)),n.socketIndex=U.index=K.length,X[I.channel]=U,K[n.socketIndex]=U,O(U),U.__push||(U.__push=U.send,U.send=function(n){n.userid=n.userid||e.userid,n.extra=n.extra||e.extra||{},U.__push(n)})}};I.callback=function(e){U=e,I.onopen()};var U=e.openSignalingChannel(I);U&&I.onopen(U);var N,F=n.isofferer,B={onopen:C,onicecandidate:function(n){if(!e.candidates)throw"ICE candidates are mandatory.";if(!e.iceProtocols)throw"At least one must be true; UDP or TCP.";var t=e.candidates,i=t.stun,s=t.turn;if(o(t.reflexive)||(i=t.reflexive),o(t.relay)||(s=t.relay),(t.host||!n.candidate.match(/a=candidate.*typ host/g))&&(s||!n.candidate.match(/a=candidate.*typ relay/g))&&(i||!n.candidate.match(/a=candidate.*typ srflx/g))){var r=e.iceProtocols;!r.udp&&n.candidate.match(/a=candidate.* udp/g)||!r.tcp&&n.candidate.match(/a=candidate.* tcp/g)||(window.selfNPObject||(window.selfNPObject=n),U&&U.send({candidate:JSON.stringify({candidate:n.candidate,sdpMid:n.sdpMid,sdpMLineIndex:n.sdpMLineIndex})}))}},onmessage:function(t){if(t){var i=a(t);if(-1!=i.indexOf('"userid":'))i=JSON.parse(i),u(i);else if(t instanceof ArrayBuffer||t instanceof DataView){if(!e.enableFileSharing)throw'It seems that receiving data is either "Blob" or "File" but file sharing is disabled.';if(!$.fileBufferReader){var o=this;return void k(e,function(e){$.fileBufferReader=e,o.onmessage(t)})}var s=$.fileBufferReader;return void s.convertToObject(t,function(t){return t.maxChunks||t.readyForNextChunk?t.readyForNextChunk?void s.getNextChunk(t.uuid,function(e,n,t){$.send(e)}):void s.addChunk(t,function(e){$.send(e)}):void e.onmessage({data:t,userid:n.userid,extra:n.extra})})}}},onaddstream:function(o,s){function r(){setTimeout(function(){u.muted=!1,l({mediaElement:u,session:s,stream:o,preMuted:a})},3e3),u.removeEventListener("play",r)}if(s=s||n.renegotiate||e.session,!i(s)){s.screen&&(s.audio||s.video)&&(n.gotAudioOrVideo?(s.audio=!1,s.video=!1):(n.gotAudioOrVideo=!0,s.screen=!1));var a={};if(n.streaminfo){var d=n.streaminfo.split("----"),c=JSON.parse(d[d.length-1]);j||(o.streamid=c.streamid,o.isScreen=!!c.isScreen,o.isVideo=!!c.isVideo,o.isAudio=!!c.isAudio,a=c.preMuted),d.pop(),n.streaminfo=d.join("----")}var u=v(o,b({remote:!0},s));return e.setDefaultEventsForMediaElement&&e.setDefaultEventsForMediaElement(u,o.streamid),W||o.getVideoTracks().length?void t({mediaElement:u,session:s,stream:o,preMuted:a}):u.addEventListener("play",r,!1)}},onremovestream:function(n){n&&n.streamid?(n=e.streams[n.streamid],n&&(m("on:stream:ended via on:remove:stream",n),g(n,e))):m("on:remove:stream",n)},onclose:function(t){t.extra=n.extra,t.userid=n.userid,e.onclose(t),e.channels[t.userid]&&delete e.channels[t.userid]},onerror:function(t){t.extra=n.extra,t.userid=n.userid,e.onerror(t)},oniceconnectionstatechange:function(t){m("oniceconnectionstatechange",p(t)),N.connection&&"connected"==N.connection.iceConnectionState&&"complete"==N.connection.iceGatheringState&&"stable"==N.connection.signalingState&&1==e.numberOfConnectedUsers&&e.onconnected({userid:n.userid,extra:n.extra,peer:e.peers[n.userid],targetuser:n.userinfo}),!e.isInitiator&&N.connection&&"connected"==N.connection.iceConnectionState&&"complete"==N.connection.iceGatheringState&&"stable"==N.connection.signalingState&&1==e.numberOfConnectedUsers&&e.onstatechange({userid:n.userid,extra:n.extra,name:"connected-with-initiator",reason:"ICE connection state seems connected; gathering state is completed; and signaling state is stable."}),e.peers[n.userid]&&e.peers[n.userid].oniceconnectionstatechange&&e.peers[n.userid].oniceconnectionstatechange(t),e.peers[n.userid]&&"failed"==e.peers[n.userid].peer.connection.iceConnectionState&&e.onfailed({userid:n.userid,extra:n.extra,peer:e.peers[n.userid],targetuser:n.userinfo}),e.peers[n.userid]&&"disconnected"==e.peers[n.userid].peer.connection.iceConnectionState&&(!N.connection.renegotiate&&e.ondisconnected({userid:n.userid,extra:n.extra,peer:e.peers[n.userid],targetuser:n.userinfo}),N.connection.renegotiate=!1),e.autoReDialOnFailure&&e.peers[n.userid]&&("disconnected"!=e.peers[n.userid].peer.connection.iceConnectionState&&(n.redialing=!1),"disconnected"!=e.peers[n.userid].peer.connection.iceConnectionState||n.redialing||(n.redialing=!0,f("Peer connection is closed.",p(e.peers[n.userid].peer.connection),"ReDialing.."),e.peers[n.userid].socket.send({redial:!0}),e.streams.remove({remote:!0,userid:n.userid})))},onsignalingstatechange:function(e){m("onsignalingstatechange",p(e))},attachStreams:e.dontAttachStream?[]:e.attachStreams,iceServers:e.iceServers,rtcConfiguration:e.rtcConfiguration,bandwidth:e.bandwidth,sdpConstraints:e.sdpConstraints,optionalArgument:e.optionalArgument,disableDtlsSrtp:e.disableDtlsSrtp,dataChannelDict:e.dataChannelDict,preferSCTP:e.preferSCTP,onSessionDescription:function(e,n){L({sdp:e,socket:U,streaminfo:n})},trickleIce:e.trickleIce,processSdp:e.processSdp,sendStreamId:function(e){U&&U.send({streamid:e.streamid,isScreen:!!e.isScreen,isAudio:!!e.isAudio,isVideo:!!e.isVideo})},rtcMultiConnection:e};e.playRoleOfInitiator=function(){e.dontCaptureUserMedia=!0,e.open(),K=c(K),e.dontCaptureUserMedia=!1},e.askToShareParticipants=function(){ne&&ne.send({askToShareParticipants:!0})},e.shareParticipants=function(n){var t={joinUsers:Z,userid:e.userid,extra:e.extra};n&&(n.dontShareWith&&(t.dontShareWith=n.dontShareWith),n.shareWith&&(t.shareWith=n.shareWith)),ne.send(t)}}function P(n,t){if(n)for(var i=0;i<n.length;i++){var o=n[i];e.streams[o]&&t.removeStream(e.streams[o].stream)}}function L(n){n.socket.send({sdp:JSON.stringify({sdp:n.sdp.sdp,type:n.sdp.type}),renegotiate:n.renegotiate?n.renegotiate:!1,streaminfo:n.streaminfo||"",labels:n.labels||[],preferSCTP:!!e.preferSCTP,fakeDataChannels:!!e.fakeDataChannels,isInitiator:!!e.isInitiator,userinfo:{browser:V?"firefox":"chrome"}})}function F(n){var t=n.newParticipant;if(t&&!Z[t]&&t!=e.userid){var i=e.token();E({channel:i,extra:n.userData?n.userData.extra:n.extra,userid:n.userData?n.userData.userid:n.userid}),ne.send({participant:!0,targetUser:t,channel:i})}}function B(){e.numberOfConnectedUsers--;var n={left:!0,extra:e.extra||{},userid:e.userid,sessionid:e.sessionid};e.isInitiator&&(e.autoCloseEntireSession?n.closeEntireSession=!0:K[0]&&K[0].send({playRoleOfBroadcaster:!0,userid:e.userid,extra:e.extra,participants:Z})),K.forEach(function(e,t){e.send(n),X[e.channel]&&delete X[e.channel],delete K[t]}),K=c(K),e.refresh(),N.forEach(function(e){e.disconnect()}),N=[]}function _(){$.signalingReady||($.signalingReady=!0,setTimeout(n,1e3),e.isInitiator||ne&&ne.send({searchingForRooms:!0}))}function q(n){for(var t in n)Z[n[t]]||F({sessionid:e.sessionid,newParticipant:n[t],userid:e.userid,extra:e.extra})}function z(){return e.openSignalingChannel({onmessage:function(n){if(!te&&n.userid!=e.userid){if(n.sessionid&&n.userid&&(e.sessionDescriptions[n.sessionid]||(e.numberOfSessions++,e.sessionDescriptions[n.sessionid]=n,e.isAcceptNewSession&&(e.dontOverrideSession||(e.session=n.session),M(n)))),n.newParticipant&&!e.isAcceptNewSession&&$.broadcasterid===n.userid&&n.newParticipant!=e.userid&&F(n),h(Z)<e.maxParticipantsAllowed&&n.targetUser==e.userid&&n.participant){if(e.peers[n.userid]&&!e.peers[n.userid].peer)return delete Z[n.userid],delete e.peers[n.userid],e.isAcceptNewSession=!0,Y(n);Z[n.userid]||Y(n)}if(n.acceptedRequestOf==e.userid&&e.onstatechange({userid:n.userid,extra:n.extra,name:"request-accepted",reason:n.userid+" accepted your participation request."}),n.rejectedRequestOf==e.userid&&e.onstatechange({userid:n.userid,extra:n.extra,name:"request-rejected",reason:n.userid+" rejected your participation request."}),n.customMessage)if(n.message.drop){e.ondrop(n.userid),e.attachStreams=[];for(var t in e.streams)-1==e._skip.indexOf(t)&&(t=e.streams[t],"local"==t.type?(e.detachStreams.push(t.streamid),g(t,e)):g(t,e));n.message.renegotiate&&e.renegotiate()}else e.onCustomMessage&&e.onCustomMessage(n.message);if(e.isInitiator&&n.searchingForRooms&&ne&&ne.send({sessionDescription:e.sessionDescription,responseFor:n.userid}),n.sessionDescription&&n.responseFor==e.userid){var i=n.sessionDescription;e.sessionDescriptions[i.sessionid]||(e.numberOfSessions++,e.sessionDescriptions[i.sessionid]=i)}e.isInitiator&&n.askToShareParticipants&&ne&&e.shareParticipants({shareWith:n.userid}),n.shareWith==e.userid&&n.dontShareWith!=e.userid&&n.joinUsers&&q(n.joinUsers),!n.shareWith&&n.joinUsers&&(n.dontShareWith?e.userid!=n.dontShareWith&&q(n.joinUsers):q(n.joinUsers)),n.messageFor==e.userid&&n.presenceState&&("checking"==n.presenceState&&(ne.send({messageFor:n.userid,presenceState:"available",_config:n._config}),m("participant asked for availability")),"available"==n.presenceState&&($.presenceState="available",e.onstatechange({userid:"browser",extra:{},name:"room-available",reason:"Initiator is available and room is active."}),J(n._config))),n.donotJoin&&n.messageFor==e.userid&&m(n.userid,"is not joining your room."),n.isDisconnectSockets&&(m("Disconnecting your sockets because initiator also disconnected his sockets."),e.disconnect())}},callback:function(e){e&&this.onopen(e)},onopen:function(n){n&&(ne=n),_&&_(),$.defaultSocket=ne,ne.__push||(ne.__push=ne.send,ne.send=function(n){n.userid=n.userid||e.userid,n.extra=n.extra||e.extra||{},ne.__push(n)})}})}function G(){var n=0;256!=e.maxParticipantsAllowed&&(n=e.maxParticipantsAllowed),"one-way"==e.direction&&(e.session.oneway=!0),"one-to-one"==e.direction&&(e.maxParticipantsAllowed=1),"one-to-many"==e.direction&&(e.session.broadcast=!0),"many-to-many"==e.direction&&(e.maxParticipantsAllowed&&1!=e.maxParticipantsAllowed||(e.maxParticipantsAllowed=256)),n&&1!=e.maxParticipantsAllowed&&(e.maxParticipantsAllowed=n)}function J(n,i){if(!$.donotJoin||$.donotJoin!=n.sessionid){e.dontOverrideSession||(e.session=n.session||{}),$.broadcasterid=n.userid,n.sessionid&&(e.sessionid=n.sessionid),e.isAcceptNewSession=!1;var o=t();E({channel:o,extra:n.extra||{},userid:n.userid});var s={};if(e.attachStreams.length){var a=e.attachStreams[e.attachStreams.length-1];a.getAudioTracks&&a.getAudioTracks().length&&(s.audio=!0),a.getVideoTracks().length&&(s.video=!0)}m(r(s)?"Seems data-only connection.":p(s)),e.onstatechange({userid:n.userid,extra:{},name:"connecting-with-initiator",reason:"Checking presence of the initiator; and the room."}),ne.send({participant:!0,channel:o,targetUser:n.userid,session:e.session,offers:{audio:!!s.audio,video:!!s.video}}),e.skipOnNewSession=!1,C(e)}}function Y(n){if($.requestsFrom||($.requestsFrom={}),!$.requestsFrom[n.userid]){var t={userid:n.userid,extra:n.extra,channel:n.channel||n.userid,session:n.session||e.session};if(n.offers){m(n.offers.audio&&n.offers.video?"target user has both audio/video streams.":n.offers.audio&&!n.offers.video?"target user has only audio stream.":!n.offers.audio&&n.offers.video?"target user has only video stream.":"target user has no stream; it seems one-way streaming or data-only connection.");var i=e.sdpConstraints.mandatory;o(i.OfferToReceiveAudio)&&(e.sdpConstraints.mandatory.OfferToReceiveAudio=!!n.offers.audio),o(i.OfferToReceiveVideo)&&(e.sdpConstraints.mandatory.OfferToReceiveVideo=!!n.offers.video),m("target user's SDP has?",p(e.sdpConstraints.mandatory))}$.requestsFrom[n.userid]=t,e.onRequest&&e.isInitiator?e.onRequest(t):Q(t)}}function Q(n){return $.captureUserMediaOnDemand?($.captureUserMediaOnDemand=!1,void e.captureUserMedia(function(){Q(n),C(e)})):(m("accepting request from",n.userid),Z[n.userid]=n.userid,void E({isofferer:!0,userid:n.userid,channel:n.channel,extra:n.extra||{},session:n.session||e.session}))}var X={},K=[],$=this,Z={};!$.fileBufferReader&&e.session.data&&e.enableFileSharing&&k(e,function(e){$.fileBufferReader=e});var ee=new I(e);e.remove=function(n){$.requestsFrom&&$.requestsFrom[n]&&delete $.requestsFrom[n],e.peers[n]&&(e.peers[n].peer&&e.peers[n].peer.connection&&("closed"!=e.peers[n].peer.connection.signalingState&&e.peers[n].peer.connection.close(),e.peers[n].peer.connection=null),delete e.peers[n]),Z[n]&&delete Z[n];for(var t in e.streams)t=e.streams[t],t.userid==n&&(g(t,e),delete e.streams[t]);X[n]&&delete X[n]},e.refresh=function(){e.isInitiator&&e.socket&&e.socket.remove&&e.socket.remove(),Z={};for(var n=0;n<e.attachStreams.length;n++)e.stopMediaStream(e.attachStreams[n]);de={streams:[],mutex:!1,queueRequests:[]},$.isOwnerLeaving=!0,e.isInitiator=!1,e.isAcceptNewSession=!0,e.attachMediaStreams=[],e.sessionDescription=null,e.sessionDescriptions={},e.localStreamids=[],e.preRecordedMedias={},e.snapshots={},e.numberOfConnectedUsers=0,e.numberOfSessions=0,e.attachStreams=[],e.detachStreams=[],e.fileQueue={},e.channels={},e.renegotiatedSessions={};for(var t in e.peers)t!=e.userid&&delete e.peers[t];for(var i in e.streams)-1==e._skip.indexOf(i)&&(g(e.streams[i],e),delete e.streams[i]);X={},K=[],Z={}},e.reject=function(n){s(n)||(n=n.userid),ne.send({rejectedRequestOf:n}),e.remove(n)},$.leaveHandler=function(n){return e.leaveOnPageUnload?o(n.keyCode)?B():void(116==n.keyCode&&B()):void 0},U("beforeunload",$.leaveHandler),U("keyup",$.leaveHandler),$.onLineOffLineHandler=function(){navigator.onLine?$.isOffLine&&($.isOffLine=!navigator.onLine):$.isOffLine=!0},U("load",$.onLineOffLineHandler),U("online",$.onLineOffLineHandler),U("offline",$.onLineOffLineHandler);var ne=z();$.defaultSocket=ne,ne&&_&&setTimeout(_,2e3),e.session.screen&&R(),e.getExternalIceServers&&x(function(n){e.iceServers=e.iceServers.concat(n)}),0==e.log&&e.skipLogs(),e.onlog&&(m=f=l=function(){var n={},t=0;Array.prototype.slice.call(arguments).forEach(function(e){n[t++]=p(e)}),p=function(e){return e},e.onlog(n)}),this.initSession=function(n){function t(){ne&&h(Z)<e.maxParticipantsAllowed&&!$.isOwnerLeaving&&ne.send(e.sessionDescription),e.transmitRoomOnce||$.isOwnerLeaving||setTimeout(t,e.interval||3e3)}$.isOwnerLeaving=!1,G(),Z={},$.isOwnerLeaving=!1,o(n.transmitRoomOnce)||(e.transmitRoomOnce=n.transmitRoomOnce),n.dontTransmit||t()},this.joinSession=function(n){function t(){ne.send({messageFor:n.userid,presenceState:$.presenceState,_config:{userid:n.userid,extra:n.extra||{},sessionid:n.sessionid,session:n.session||!1}})}function i(){"checking"==$.presenceState&&(f("Unable to reach initiator. Trying again..."),t(),setTimeout(function(){"checking"==$.presenceState&&(e.onstatechange({userid:n.userid,extra:n.extra||{},name:"room-not-available",reason:"Initiator seems absent. Waiting for someone to open the room."}),e.isAcceptNewSession=!0,setTimeout(i,2e3))},2e3))}return ne?(n=n||{},Z={},$.presenceState="checking",e.onstatechange({userid:n.userid,extra:n.extra||{},name:"detecting-room-presence",reason:"Checking presence of the room."}),t(),void setTimeout(i,3e3)):setTimeout(function(){f("Default-Socket is not yet initialized."),$.joinSession(n)},1e3)},e.donotJoin=function(n){$.donotJoin=n;var t=e.sessionDescriptions[n];t&&(ne.send({donotJoin:!0,messageFor:t.userid,sessionid:n}),Z={},e.isAcceptNewSession=!0,e.sessionid=null)},this.send=function(n,t){if(n instanceof ArrayBuffer||n instanceof DataView||(n=d({extra:e.extra,userid:e.userid,data:n})),t)return void("open"==t.readyState&&t.send(n));for(var i in e.channels){var o=e.channels[i].channel;"open"==o.readyState&&o.send(n)}},this.leave=function(){B()},this.addStream=function(n){function t(t){var o=t.socket;if(!o)return void f(t,"doesn't has socket.");if(O(o),!t||!t.peer)throw"No peer to renegotiate.";var s=t.peer;n.stream&&(s.attachStreams||(s.attachStreams=[]),s.attachStreams.push(n.stream)),P(e.detachStreams,s.connection),n.stream&&(i.audio||i.video||i.screen)&&s.addStream(n.stream),s.recreateOffer(i,function(n,t){L({sdp:n,socket:o,renegotiate:i,labels:e.detachStreams,streaminfo:t}),e.detachStreams=[]})}var i=n.renegotiate;if(e.renegotiatedSessions[JSON.stringify(n.renegotiate)]||(e.renegotiatedSessions[JSON.stringify(n.renegotiate)]={session:n.renegotiate,stream:n.stream}),n.socket)n.socket.userid!=e.userid&&t(e.peers[n.socket.userid]);else for(var o in e.peers)o!=e.userid&&t(e.peers[o])},e.request=function(n,t){e.captureUserMedia(function(){E({channel:e.userid,extra:t||{},userid:n}),ne.send({participant:!0,targetUser:n})})},e.accept=function(n){arguments.length>1&&s(arguments[0])&&(n={},arguments[0]&&(n.userid=arguments[0]),arguments[1]&&(n.extra=arguments[1]),arguments[2]&&(n.channel=arguments[2])),e.captureUserMedia(function(){Q(n)})};var te=!1;this.disconnect=function(){if(this.isOwnerLeaving=!0,!e.keepStreamsOpened){for(var n in e.localStreams)e.localStreams[n].stop();e.localStreams={},de={streams:[],mutex:!1,queueRequests:[]}}e.isInitiator&&ne.send({isDisconnectSockets:!0}),e.refresh(),$.defaultSocket=ne=null,te=!0,e.ondisconnected({userid:e.userid,extra:e.extra,peer:e.peers[e.userid],isSocketsDisconnected:!0}),e.close(),window.removeEventListener("beforeunload",$.leaveHandler),window.removeEventListener("keyup",$.leaveHandler),delete this,m("Disconnected your sockets, peers, streams and everything except RTCMultiConnection object.")}}function n(e){if(!e)throw"MediaStream is mandatory.";if(e.getVideoTracks&&!e.getVideoTracks().length)return e;var n=new AudioContext,t=n.createMediaStreamSource(e),i=n.createMediaStreamDestination();return t.connect(i),N.push(t),i.stream}function t(){if(window.crypto&&crypto.getRandomValues&&-1==navigator.userAgent.indexOf("Safari")){for(var e=window.crypto.getRandomValues(new Uint32Array(3)),n="",t=0,i=e.length;i>t;t++)n+=e[t].toString(36);return n}return(Math.random()*(new Date).getTime()).toString(36).replace(/\./g,"")}function i(e){return!e.audio&&!e.video&&!e.screen&&e.data}function o(e){return"undefined"==typeof e}function s(e){return"string"==typeof e}function r(e){var n=0;for(var t in e)n++;return 0==n}function a(e){var n="";try{n=String.fromCharCode.apply(null,new Uint16Array(e))}catch(t){}return n}function d(e){s(e)||(e=JSON.stringify(e));for(var n=new ArrayBuffer(2*e.length),t=new Uint16Array(n),i=0,o=e.length;o>i;i++)t[i]=e.charCodeAt(i);return n}function c(e){for(var n=[],t=e.length,i=0;t>i;i++)e[i]&&e[i]!==!0&&n.push(e[i]);return n}function u(e,n){for(var t in e)n(e[t],t)}function m(){Y.log(arguments)}function l(){Y.error(arguments)}function f(){Y.warn(arguments)}function p(e){return JSON.stringify(e,function(e,n){return n&&n.sdp?(m(n.sdp.type," ",n.sdp.sdp),""):n}," ")}function h(e){var n=0;for(var t in e)t&&n++;return n}function v(e,n){var t=document.createElement(e.isAudio?"audio":"video");if(t.id=e.streamid,W){var i=document.body||document.documentElement;return i.insertBefore(t,i.firstChild),setTimeout(function(){oe.attachMediaStream(t,e)},1e3),oe.attachMediaStream(t,e)}return t[V?"mozSrcObject":"src"]=V?e:(window.URL||window.webkitURL).createObjectURL(e),t.controls=!0,t.autoplay=!!n.remote,t.muted=!n.remote,V&&t.addEventListener("ended",function(){e.onended()},!1),t.play(),t}function g(e,n){e.mediaElement&&!e.mediaElement.parentNode||$[e.streamid]||($[e.streamid]=e,n.onstreamended(e))}function S(e,n){Z[e.userid]||(Z[e.userid]=e,n.onleave(e))}function w(e){function n(n){var o=document.createElement("canvas");o.width=n.videoWidth||n.clientWidth,o.height=n.videoHeight||n.clientHeight;var s=o.getContext("2d");s.drawImage(n,0,0,o.width,o.height),i.snapshots[t]=o.toDataURL("image/png"),e.callback&&e.callback(i.snapshots[t])}var t=e.userid,i=e.connection;if(e.mediaElement)return n(e.mediaElement);for(var o in i.streams)o=i.streams[o],o.userid==t&&o.stream&&o.stream.getVideoTracks&&o.stream.getVideoTracks().length&&n(o.mediaElement)}function C(e){e.onMediaCaptured&&(e.onMediaCaptured(),delete e.onMediaCaptured)}function b(e,n){if(e||(e={}),!n)return e;for(var t in n)e[t]=n[t];return e}function y(e,n){var t=document.createElement("script");t.src=e,t.onload=function(){m("loaded resource:",e),n&&n()},document.documentElement.appendChild(t)}function T(e){var n=e.connection,t=e.element;if(!window.html2canvas)return y(n.resources.html2canvas,function(){T(e)});if(s(t)&&(t=document.querySelector(t),t||(t=document.getElementById(t))),!t)throw"HTML DOM Element is not accessible!";html2canvas(t,{onrendered:function(n){e.callback(n.toDataURL())}})}function k(e,n){function t(e){return e.userid=e.extra.userid,e}if(!window.FileBufferReader)return void y(e.resources.FileBufferReader,function(){k(e,n)});var i=new FileBufferReader;i.onProgress=function(n){e.onFileProgress(t(n),n.uuid)},i.onBegin=function(n){e.onFileStart(t(n))},i.onEnd=function(n){e.onFileEnd(t(n))},n(i)}function R(e){if(DetectRTC.screen.extensionid==te&&!X){if(!e)return R(!0);X=!0;var n=document.createElement("iframe");n.onload=function(){n.isLoaded=!0,m("Screen Capturing frame is loaded.")},n.src="getSourceId/",n.style.display="none",(document.body||document.documentElement).appendChild(n),Q={postMessage:function(){return n.isLoaded?void n.contentWindow.postMessage({captureSourceId:!0},"*"):void setTimeout(Q.postMessage,100);
}}}}function x(e,n){if(!K){if(!n)return x(e,!0);K=!0;var t=document.createElement("iframe");t.onload=function(){function n(t){t.data&&t.data.iceServers&&(e(t.data.iceServers),window.removeEventListener("message",n))}t.isLoaded=!0,U("message",n),t.contentWindow.postMessage("get-ice-servers","*")},t.src="getIceServers.html",t.style.display="none",(document.body||document.documentElement).appendChild(t)}}function M(e){var n=e.stream,t=e.root,i=e.session||{},o=e.enabled;if(i.audio||i.video||(i=s(i)?{audio:!0,video:!0}:b(i,{audio:!0,video:!0})),i.type){if("remote"==i.type&&"remote"!=t.type)return;if("local"==i.type&&"local"!=t.type)return}if(m(o?"Muting":"UnMuting","session",p(i)),"local"==t.type&&i.audio&&n.getAudioTracks){var r=n.getAudioTracks()[0];r&&(r.enabled=!o)}if("local"==t.type&&(i.video||i.screen)&&n.getVideoTracks){var a=n.getVideoTracks()[0];a&&(a.enabled=!o)}if(t.sockets.forEach(function(e){"local"==t.type&&e.send({streamid:t.streamid,mute:!!o,unmute:!o,session:i}),"remote"==t.type&&e.send({promptMuteUnmute:!0,streamid:t.streamid,mute:!!o,unmute:!o,session:i})}),"remote"!=t.type){var d=b({},t);d.session=i,d.isAudio=!!d.session.audio&&!d.session.video,d.isVideo=!!d.session.video,d.isScreen=!!d.session.screen,o&&(n.preMuted={audio:n.getAudioTracks().length&&!n.getAudioTracks()[0].enabled,video:n.getVideoTracks().length&&!n.getVideoTracks()[0].enabled},t.rtcMultiConnection.onmute(d)),o||(n.preMuted={},t.rtcMultiConnection.onunmute(d))}}function D(e){if(!window.hark)return void y(e.connection.resources.hark,function(){D(e)});var n=e.connection,t=e.streamedObject,i=e.stream,o={},s=hark(i,o);s.on("speaking",function(){n.onspeaking&&n.onspeaking(t)}),s.on("stopped_speaking",function(){n.onsilence&&n.onsilence(t)}),s.on("volume_change",function(e,i){n.onvolumechange&&n.onvolumechange(b({volume:e,threshold:i},t))})}function O(e){function n(n,o,s){s||(s=t()),i.localStreams[s]=n;var r=e.video;r&&(r[V?"mozSrcObject":"src"]=V?n:(window.URL||window.webkitURL).createObjectURL(n),r.play()),e.onsuccess(n,o,w,s),de.streams[w]={stream:n,streamid:s},de.mutex=!1,de.queueRequests.length&&O(de.queueRequests.shift())}if(W)return oe.getUserMedia?oe.getUserMedia(e.constraints||{audio:!0,video:!0},e.onsuccess,e.onerror):void setTimeout(function(){O(e)},1e3);if(de.mutex===!0)return void de.queueRequests.push(e);de.mutex=!0;var i=e.connection,o=e.mediaConstraints||{},s="boolean"==typeof o.video?o.video:o.video||o,a="boolean"==typeof o.audio?o.audio:o.audio||ae,d=navigator,u=e.constraints||{audio:ae,video:ae};u.video&&u.video.mozMediaSource&&(s={}),1==u.video&&(u.video=ae),1==u.audio&&(u.audio=ae),"boolean"==typeof a&&u.audio&&(u.audio=a),"boolean"==typeof s&&u.video&&(u.video=s);var h=a.mandatory;r(h)||(u.audio.mandatory=b(u.audio.mandatory,h));var v=s.mandatory;if(v){var g={};if(v.minWidth&&(g.minWidth=v.minWidth),v.minHeight&&(g.minHeight=v.minHeight),v.maxWidth&&(g.maxWidth=v.maxWidth),v.maxHeight&&(g.maxHeight=v.maxHeight),v.minAspectRatio&&(g.minAspectRatio=v.minAspectRatio),v.maxFrameRate&&(g.maxFrameRate=v.maxFrameRate),v.minFrameRate&&(g.minFrameRate=v.minFrameRate),g.minWidth&&g.minHeight){var S=["1920:1080","1280:720","960:720","640:360","640:480","320:240","320:180"];-1!=S.indexOf(g.minWidth+":"+g.minHeight)&&-1!=S.indexOf(g.maxWidth+":"+g.maxHeight)||l('The min/max width/height constraints you passed "seems" NOT supported.',p(g)),(g.minWidth>g.maxWidth||g.minHeight>g.maxHeight)&&l("Minimum value must not exceed maximum value.",p(g)),g.minWidth>=1280&&g.minHeight>=720&&f("Enjoy HD video! min/"+g.minWidth+":"+g.minHeight+", max/"+g.maxWidth+":"+g.maxHeight)}u.video.mandatory=b(u.video.mandatory,g)}v&&(u.video.mandatory=b(u.video.mandatory,v)),s.optional&&s.optional instanceof Array&&s.optional.length&&(u.video.optional=u.video.optional?u.video.optional.concat(s.optional):s.optional),a.optional&&a.optional instanceof Array&&a.optional.length&&(u.audio.optional=u.audio.optional?u.audio.optional.concat(a.optional):a.optional),u.video.mandatory&&!r(u.video.mandatory)&&i._mediaSources.video&&(u.video.optional.forEach(function(e,n){e.sourceId==i._mediaSources.video&&delete u.video.optional[n]}),u.video.optional=c(u.video.optional),u.video.optional.push({sourceId:i._mediaSources.video})),u.audio.mandatory&&!r(u.audio.mandatory)&&i._mediaSources.audio&&(u.audio.optional.forEach(function(e,n){e.sourceId==i._mediaSources.audio&&delete u.audio.optional[n]}),u.audio.optional=c(u.audio.optional),u.audio.optional.push({sourceId:i._mediaSources.audio})),u.video&&!u.video.mozMediaSource&&u.video.optional&&u.video.mandatory&&!u.video.optional.length&&r(u.video.mandatory)&&(u.video=!0),H&&(u={audio:!!u.audio,video:!!u.video}),m("invoked getUserMedia with constraints:",p(u));var w=JSON.stringify(u);de.streams[w]?n(de.streams[w].stream,!0,de.streams[w].streamid):(d.getMedia=d.webkitGetUserMedia||d.mozGetUserMedia,d.getMedia(u,n,function(n){e.onerror(n,u)}))}function E(e){var n,t={OfferToReceiveAudio:!!e.OfferToReceiveAudio,OfferToReceiveVideo:!!e.OfferToReceiveVideo};return n={mandatory:t,optional:[{VoiceActivityDetection:!1}]},navigator.mozGetUserMedia&&J>34&&(n={OfferToReceiveAudio:!!e.OfferToReceiveAudio,OfferToReceiveVideo:!!e.OfferToReceiveVideo}),n}function A(){return{create:function(e,n){b(this,n);var t=this;return this.type=e,this.init(),this.attachMediaStreams(),V&&this.session.data?(this.session.data&&"offer"==e&&this.createDataChannel(),this.getLocalDescription(e),this.session.data&&"answer"==e&&this.createDataChannel()):t.getLocalDescription(e),this},getLocalDescription:function(e){function n(){t.connection["offer"==e?"createOffer":"createAnswer"](function(n){n.sdp=t.serializeSdp(n.sdp,e),t.connection.setLocalDescription(n),t.trickleIce&&t.onSessionDescription(n,t.streaminfo),"offer"==n.type&&m("offer sdp",n.sdp),t.prevCreateType=e},t.onSdpError,t.constraints)}m("(getLocalDescription) peer createType is",e),this.session.inactive&&o(this.rtcMultiConnection.waitUntilRemoteStreamStartsFlowing)&&(this.rtcMultiConnection.waitUntilRemoteStreamStartsFlowing=!1);var t=this;"answer"==e?this.setRemoteDescription(this.offerDescription,n):n()},serializeSdp:function(e,n){if(e=this.processSdp(e),V)return e;if(this.session.inactive&&!this.holdMLine&&(this.hold=!0,(this.session.screen||this.session.video)&&this.session.audio?this.holdMLine="both":this.session.screen||this.session.video?this.holdMLine="video":this.session.audio&&(this.holdMLine="audio")),e=this.setBandwidth(e),"both"==this.holdMLine){if(this.hold)this.prevSDP=e,e=e.replace(/a=sendonly|a=recvonly|a=sendrecv/g,"a=inactive");else if(this.prevSDP&&!this.session.inactive&&(e=this.prevSDP,35>=z))return e}else if("audio"==this.holdMLine||"video"==this.holdMLine){e=e.split("m=");var t="",i="";e[1]&&0==e[1].indexOf("audio")&&(t="m="+e[1]),e[2]&&0==e[2].indexOf("audio")&&(t="m="+e[2]),e[1]&&0==e[1].indexOf("video")&&(i="m="+e[1]),e[2]&&0==e[2].indexOf("video")&&(i="m="+e[2]),"audio"==this.holdMLine&&(this.hold?(this.prevSDP=e[0]+t+i,e=e[0]+t.replace(/a=sendonly|a=recvonly|a=sendrecv/g,"a=inactive")+i):this.prevSDP&&(e=this.prevSDP)),"video"==this.holdMLine&&(this.hold?(this.prevSDP=e[0]+t+i,e=e[0]+t+i.replace(/a=sendonly|a=recvonly|a=sendrecv/g,"a=inactive")):this.prevSDP&&(e=this.prevSDP))}return!this.hold&&this.session.inactive&&(e="offer"==n?e.replace(/a=setup:passive|a=setup:active|a=setup:holdconn/g,"a=setup:actpass"):e.replace(/a=setup:actpass|a=setup:passive|a=setup:holdconn/g,"a=setup:active"),e=e.replace(/a=inactive/g,"a=sendrecv")),e},init:function(){function e(){return n.returnedSDP?void(n.returnedSDP=!1):(n.returnedSDP=!0,void n.onSessionDescription(n.connection.localDescription,n.streaminfo))}this.setConstraints(),this.connection=new re(this.iceServers,this.optionalArgument),this.session.data&&(m("invoked: createDataChannel"),this.createDataChannel()),this.connection.onicecandidate=function(t){return t.candidate?void(n.trickleIce&&n.onicecandidate(t.candidate)):void(n.trickleIce||e())},this.connection.onaddstream=function(e){m("onaddstream",W?e.stream:p(e.stream)),n.onaddstream(e.stream,n.session)},this.connection.onremovestream=function(e){n.onremovestream(e.stream)},this.connection.onsignalingstatechange=function(){n.connection&&n.oniceconnectionstatechange({iceConnectionState:n.connection.iceConnectionState,iceGatheringState:n.connection.iceGatheringState,signalingState:n.connection.signalingState})},this.connection.oniceconnectionstatechange=function(){n.connection&&(n.oniceconnectionstatechange({iceConnectionState:n.connection.iceConnectionState,iceGatheringState:n.connection.iceGatheringState,signalingState:n.connection.signalingState}),n.trickleIce||"complete"==n.connection.iceGatheringState&&(m("iceGatheringState",n.connection.iceGatheringState),e()))};var n=this},setBandwidth:function(e){if(H||V||!this.bandwidth)return e;var n=this.bandwidth;return this.session.screen&&(n.screen?n.screen<300&&f("It seems that you are using wrong bandwidth value for screen. Screen sharing is expected to fail."):f("It seems that you are not using bandwidth for screen. Screen sharing is expected to fail.")),n.screen&&this.session.screen&&(e=e.replace(/b=AS([^\r\n]+\r\n)/g,""),e=e.replace(/a=mid:video\r\n/g,"a=mid:video\r\nb=AS:"+n.screen+"\r\n")),(n.audio||n.video||n.data)&&(e=e.replace(/b=AS([^\r\n]+\r\n)/g,"")),n.audio&&(e=e.replace(/a=mid:audio\r\n/g,"a=mid:audio\r\nb=AS:"+n.audio+"\r\n")),n.video&&(e=e.replace(/a=mid:video\r\n/g,"a=mid:video\r\nb=AS:"+(this.session.screen?n.screen:n.video)+"\r\n")),n.data&&!this.preferSCTP&&(e=e.replace(/a=mid:data\r\n/g,"a=mid:data\r\nb=AS:"+n.data+"\r\n")),e},setConstraints:function(){var e=E({OfferToReceiveAudio:!!this.session.audio,OfferToReceiveVideo:!!this.session.video||!!this.session.screen});if(this.sdpConstraints.mandatory&&(e=E(this.sdpConstraints.mandatory)),this.constraints=e,this.constraints&&m("sdp-constraints",p(this.constraints)),this.optionalArgument={optional:this.optionalArgument.optional||[],mandatory:this.optionalArgument.mandatory||{}},this.preferSCTP||this.optionalArgument.optional.push({RtpDataChannels:!0}),m("optional-argument",p(this.optionalArgument)),o(this.iceServers))this.iceServers=null;else{var n=this.rtcMultiConnection.candidates,t=n.stun,i=n.turn,s=n.host;o(n.reflexive)||(t=n.reflexive),o(n.relay)||(i=n.relay),s||t||!i?s||t||i||(this.rtcConfiguration.iceTransports="none"):this.rtcConfiguration.iceTransports="relay",this.iceServers={iceServers:this.iceServers,iceTransports:this.rtcConfiguration.iceTransports}}m("rtc-configuration",p(this.iceServers))},onSdpError:function(e){var n=p(e);n&&-1!=n.indexOf("RTP/SAVPF Expects at least 4 fields")&&(n="It seems that you are trying to interop RTP-datachannels with SCTP. It is not supported!"),l("onSdpError:",n)},onSdpSuccess:function(){m("sdp success")},onMediaError:function(e){l(p(e))},setRemoteDescription:function(e,n){if(!e)throw"Remote session description should NOT be NULL.";if(this.connection){m("setting remote description",e.type,e.sdp);var t=this;this.connection.setRemoteDescription(new ce(e),n||this.onSdpSuccess,function(e){-1==e.search(/STATE_SENTINITIATE|STATE_INPROGRESS/gi)&&t.onSdpError(e)})}},addIceCandidate:function(e){function n(n){t.connection.addIceCandidate(n,function(){m("added:",e.sdpMid,e.candidate)},function(){l("onIceFailure",arguments,e.candidate)})}var t=this;W?ue(e,function(e){n(e)}):n(new ue(e))},createDataChannel:function(e){if(!this.channels||!this.channels.length){var n=this;this.channels||(this.channels=[]);var t={};this.dataChannelDict&&(t=this.dataChannelDict),_&&!this.preferSCTP&&(t.reliable=!1),m("dataChannelDict",p(t)),("answer"==this.type||V)&&(this.connection.ondatachannel=function(e){n.setChannelEvents(e.channel)}),(_&&"offer"==this.type||V)&&this.setChannelEvents(this.connection.createDataChannel(e||"channel",t))}},setChannelEvents:function(e){var n=this;e.binaryType="arraybuffer",this.dataChannelDict.binaryType&&(e.binaryType=this.dataChannelDict.binaryType),e.onmessage=function(e){n.onmessage(e.data)};var t=0;e.onopen=function(){e.push=e.send,e.send=function(i){if("disconnected"!=n.connection.iceConnectionState&&-1==e.readyState.search(/closing|closed/g)&&-1!=e.readyState.search(/connecting|open/g)){if("connecting"==e.readyState)return t++,setTimeout(function(){if(!(20>t))throw"Number of times exceeded to wait for WebRTC data connection to be opened.";e.send(i)},1e3);try{e.push(i)}catch(o){if(t++,f("Data transmission failed. Re-transmitting..",t,p(o)),t>=20)throw"Number of times exceeded to resend data packets over WebRTC data channels.";setTimeout(function(){e.send(i)},100)}}},n.onopen(e)},e.onerror=function(e){n.onerror(e)},e.onclose=function(e){n.onclose(e)},this.channels.push(e)},addStream:function(e){e.streamid||j||(e.streamid=t()),m("attaching stream:",e.streamid,W?e:p(e)),this.connection.addStream(e),this.sendStreamId(e),this.getStreamInfo()},attachMediaStreams:function(){for(var e=this.attachStreams,n=0;n<e.length;n++)this.addStream(e[n])},getStreamInfo:function(){this.streaminfo="";for(var e=this.connection.getLocalStreams(),n=0;n<e.length;n++)0==n?this.streaminfo=JSON.stringify({streamid:e[n].streamid||"",isScreen:!!e[n].isScreen,isAudio:!!e[n].isAudio,isVideo:!!e[n].isVideo,preMuted:e[n].preMuted||{}}):this.streaminfo+="----"+JSON.stringify({streamid:e[n].streamid||"",isScreen:!!e[n].isScreen,isAudio:!!e[n].isAudio,isVideo:!!e[n].isVideo,preMuted:e[n].preMuted||{}})},recreateOffer:function(e,n){m("recreating offer"),this.type="offer",this.session=e,this.onSessionDescription=n,this.getStreamInfo(),this.session.data&&this.createDataChannel(),this.getLocalDescription("offer")},recreateAnswer:function(e,n,t){m("recreating answer"),this.type="answer",this.session=n,this.onSessionDescription=t,this.offerDescription=e,this.getStreamInfo(),this.session.data&&this.createDataChannel(),this.getLocalDescription("answer")}}}function P(e,n){var t=document.createElement("a");t.href=e,t.target="_blank",t.download=n||e,navigator.mozGetUserMedia&&(t.onclick=function(){(document.body||document.documentElement).removeChild(t)},(document.body||document.documentElement).appendChild(t));var i=new MouseEvent("click",{view:window,bubbles:!0,cancelable:!0});t.dispatchEvent(i),navigator.mozGetUserMedia||URL.revokeObjectURL(t.href)}function I(e){function n(n,i,o){var s=n.uuid;if(t[s]||(t[s]=[]),t[s].push(n.message),n.last){var r=t[s].join("");n.isobject&&(r=JSON.parse(r));var a=(new Date).getTime(),d=a-n.sendingTime,c={data:r,userid:i,extra:o,latency:d};r.preRecordedMediaChunk?(e.preRecordedMedias[r.streamerid]||e.shareMediaFile(null,null,r.streamerid),e.preRecordedMedias[r.streamerid].onData(r.chunk)):e.autoTranslateText?(c.original=c.data,e.Translator.TranslateText(c.data,function(n){c.data=n,e.onmessage(c)})):r.isPartOfScreen?e.onpartofscreen(r):e.onmessage(c),delete t[s]}}var t={};return{receive:n}}function U(e,n){window.removeEventListener(e,n),window.addEventListener(e,n,!1)}function L(e){function i(e,n){if(-1!=e.position){var t=+e.position.toFixed(2).split(".")[1]||100;n.innerHTML=t+"%"}}e.userid=t(),e.session={audio:!0,video:!0},e.maxParticipantsAllowed=256,e.direction="many-to-many",e.mediaConstraints={mandatory:{},optional:[],audio:{mandatory:{},optional:[]},video:{mandatory:{},optional:[]}},e.candidates={host:!0,stun:!0,turn:!0},e.sdpConstraints={},e.sdpConstraints.mandatory={OfferToReceiveAudio:!0,OfferToReceiveVideo:!0},e.privileges={canStopRemoteStream:!1,canMuteRemoteStream:!1},e.iceProtocols={tcp:!0,udp:!0},e.preferSCTP=!!(V||z>=32),e.chunkInterval=V||z>=32?100:500,e.chunkSize=V||z>=32?13e3:1e3,e.fakeDataChannels=!1,e.waitUntilRemoteStreamStartsFlowing=null,e.leaveOnPageUnload=!0,e.getExternalIceServers=_,e.UA={isFirefox:V,isChrome:_,isMobileDevice:H,version:_?z:J,isNodeWebkit:q,isSafari:B,isIE:j,isOpera:F},e.fileQueue={},e.renegotiatedSessions={},e.channels={},e.extra={},e.bandwidth={screen:300},e.caniuse={RTCPeerConnection:DetectRTC.isWebRTCSupported,getUserMedia:!!navigator.webkitGetUserMedia||!!navigator.mozGetUserMedia,AudioContext:DetectRTC.isAudioContextSupported,ScreenSharing:DetectRTC.isScreenCapturingSupported,RtpDataChannels:DetectRTC.isRtpDataChannelsSupported,SctpDataChannels:DetectRTC.isSctpDataChannelsSupported},e.snapshots={},e._mediaSources={},e.devices={},e.language="en",e.autoTranslateText=!1,e.googKey="AIzaSyCgB5hmFY74WYB-EoWkhr9cAGr6TiTHrEE",e.localStreamids=[],e.localStreams={},e.preRecordedMedias={},e.attachStreams=[],e.detachStreams=[],e.optionalArgument={optional:[{DtlsSrtpKeyAgreement:!0},{googImprovedWifiBwe:!0},{googScreencastMinBitrate:300}],mandatory:{}},e.dataChannelDict={},e.dontAttachStream=!1,e.dontCaptureUserMedia=!1,e.preventSSLAutoAllowed=!1,e.autoReDialOnFailure=!0,e.isInitiator=!1,e.DetectRTC=DetectRTC,e.trickleIce=!0,e.sessionDescriptions={},e.sessionDescription=null,e.resources={RecordRTC:"https://cdn.webrtc-experiment.com/RecordRTC.js",PreRecordedMediaStreamer:"https://cdn.webrtc-experiment.com/PreRecordedMediaStreamer.js",customGetUserMediaBar:"https://cdn.webrtc-experiment.com/navigator.customGetUserMediaBar.js",html2canvas:"https://cdn.webrtc-experiment.com/screenshot.js",hark:"https://cdn.webrtc-experiment.com/hark.js",firebase:"scripts/irebase.js",firebaseio:"https://webrtc-experiment.firebaseIO.com/",muted:"muted.png",getConnectionStats:"scripts/getConnectionStats.js",FileBufferReader:"scripts/FileBufferReader.js"},e.body=document.body||document.documentElement,e.peers={},e.firebase="chat",e.numberOfSessions=0,e.numberOfConnectedUsers=0,e.enableFileSharing=!0,e.autoSaveToDisk=!1,e.processSdp=function(e){return e},e.onmessage=function(e){m("onmessage",p(e))},e.onopen=function(e){m("Data connection is opened between you and",e.userid)},e.onerror=function(e){l(onerror,p(e))},e.onclose=function(n){f("onclose",p(n)),e.streams.remove({userid:n.userid})};var a={};e.onFileStart=function(n){var t=document.createElement("div");t.title=n.name,t.innerHTML="<label>0%</label> <progress></progress>",e.body.insertBefore(t,e.body.firstChild),a[n.uuid]={div:t,progress:t.querySelector("progress"),label:t.querySelector("label")},a[n.uuid].progress.max=n.maxChunks},e.onFileProgress=function(e){var n=a[e.uuid];n&&(n.progress.value=e.currentPosition||e.maxChunks||n.progress.max,i(n.progress,n.label))},e.onFileEnd=function(n){a[n.uuid]&&(a[n.uuid].div.innerHTML='<a href="'+n.url+'" target="_blank" download="'+n.name+'">'+n.name+"</a>"),(e.onFileSent||e.onFileReceived)&&(e.onFileSent&&e.onFileSent(n,n.uuid),e.onFileReceived&&e.onFileReceived(n.name,n))},e.onstream=function(n){e.body.insertBefore(n.mediaElement,e.body.firstChild)},e.onstreamended=function(e){if(m("onStreamEndedHandler:",e),!e.mediaElement)return f("Event.mediaElement is undefined",e);if(!e.mediaElement.parentNode){if(e.mediaElement=document.getElementById(e.streamid),!e.mediaElement)return f("Event.mediaElement is undefined",e);if(!e.mediaElement.parentNode)return f("Event.mediElement.parentNode is null.",e)}e.mediaElement.parentNode.removeChild(e.mediaElement)},e.onSessionClosed=function(e){e.isEjected?f(e.userid,"ejected you."):f("Session has been closed.",e)},e.onmute=function(n){n.isVideo&&n.mediaElement&&(n.mediaElement.pause(),n.mediaElement.setAttribute("poster",n.snapshot||e.resources.muted)),n.isAudio&&n.mediaElement&&(n.mediaElement.muted=!0)},e.onunmute=function(e){e.isVideo&&e.mediaElement&&(e.mediaElement.play(),e.mediaElement.removeAttribute("poster")),e.isAudio&&e.mediaElement&&(e.mediaElement.muted=!1)},e.onleave=function(e){m("onleave",p(e))},e.token=t,e.peers[e.userid]={drop:function(){e.drop()},renegotiate:function(){},addStream:function(){},hold:function(){},unhold:function(){},changeBandwidth:function(){},sharePartOfScreen:function(){}},e._skip=["stop","mute","unmute","_private","_selectStreams","selectFirst","selectAll","remove"],e.streams={mute:function(e){this._private(e,!0)},unmute:function(e){this._private(e,!1)},_private:function(n,t){function i(e,n,t){n.local&&"local"!=e.type||n.remote&&"remote"!=e.type||n.isScreen&&!e.isScreen||n.isAudio&&!e.isAudio||n.isVideo&&!e.isVideo||(t?e.mute(n):e.unmute(n))}if(!n||s(n))for(var o in this)-1==e._skip.indexOf(o)&&this[o]._private(n,t);else for(var o in this)-1==e._skip.indexOf(o)&&i(this[o],n,t)},stop:function(n){function t(e,n){n.userid&&e.userid!=n.userid||n.local&&"local"!=e.type||n.remote&&"remote"!=e.type||(n.screen&&e.isScreen&&e.stop(),n.audio&&e.isAudio&&e.stop(),n.video&&e.isVideo&&e.stop(),n.audio||n.video||n.screen||e.stop())}var i;for(var o in this)if(-1==e._skip.indexOf(o))if(i=this[o],n)if(s(n)){var r={};r[n]=!0,t(i,r)}else t(i,n);else i.stop()},remove:function(n){function t(e,n){n.userid&&e.userid!=n.userid||n.local&&"local"!=e.type||n.remote&&"remote"!=e.type||(n.screen&&e.isScreen&&i(e),n.audio&&e.isAudio&&i(e),n.video&&e.isVideo&&i(e),n.audio||n.video||n.screen||i(e))}function i(n){g(n,e),delete e.streams[n.streamid]}var o;for(var r in this)if(-1==e._skip.indexOf(r))if(o=this[r],n)if(s(n)){var a={};a[n]=!0,t(o,a)}else t(o,n);else t(o,{local:!0,remote:!0})},selectFirst:function(e){return this._selectStreams(e,!1)},selectAll:function(e){return this._selectStreams(e,!0)},_selectStreams:function(n,t){if(!n||s(n)||r(n))throw"Invalid arguments.";o(n.local)&&o(n.remote)&&o(n.userid)&&(n.local=n.remote=!0),n.isAudio||n.isVideo||n.isScreen||(n.isAudio=n.isVideo=n.isScreen=!0);var i=[];for(var a in this)-1==e._skip.indexOf(a)&&(a=this[a])&&(n.local&&"local"==a.type||n.remote&&"remote"==a.type||n.userid&&a.userid==n.userid)&&(n.isVideo&&a.isVideo&&i.push(a),n.isAudio&&a.isAudio&&i.push(a),n.isScreen&&a.isScreen&&i.push(a));return t?i:i[0]}};var d=[];d.push({url:"stun:stun.l.google.com:19302"}),d.push({url:"stun:stun.anyfirewall.com:3478"}),d.push({url:"turn:turn.bistri.com:80",credential:"homeo",username:"homeo"}),d.push({url:"turn:turn.anyfirewall.com:443?transport=tcp",credential:"webrtc",username:"webrtc"}),e.iceServers=d,e.rtcConfiguration={iceServers:null,iceTransports:"all",peerIdentity:!1},e.media={min:function(n,t){e.mediaConstraints.video&&(e.mediaConstraints.video.mandatory||(e.mediaConstraints.video.mandatory={}),e.mediaConstraints.video.mandatory.minWidth=n,e.mediaConstraints.video.mandatory.minHeight=t)},max:function(n,t){e.mediaConstraints.video&&(e.mediaConstraints.video.mandatory||(e.mediaConstraints.video.mandatory={}),e.mediaConstraints.video.mandatory.maxWidth=n,e.mediaConstraints.video.mandatory.maxHeight=t)}},e._getStream=function(n){function t(e,n,t){if(t){var i=t.onpause,o=t.onplay;t.onpause=t.onplay=function(){},n?t.pause():t.play(),t.onpause=i,t.onplay=o}}var i=b({sockets:n.socket?[n.socket]:[]},n);return i.stop=function(){var e=this;if(e.sockets.forEach(function(n){"local"==e.type&&n.send({streamid:e.streamid,stopped:!0}),"remote"==e.type&&n.send({promptStreamStop:!0,streamid:e.streamid})}),"remote"!=e.type){var n=e.stream;n&&e.rtcMultiConnection.stopMediaStream(n)}},i.mute=function(e){this.muted=!0,this._private(e,!0)},i.unmute=function(e){this.muted=!1,this._private(e,!1)},i._private=function(e,n){return e&&!o(e.sync)&&0==e.sync?void t(e,n,this.mediaElement):void M({root:this,session:e,enabled:n,stream:this.stream})},i.startRecording=function(n){var t=this;return n||(n={audio:!0,video:!0}),s(n)&&(n={audio:"audio"==n,video:"video"==n}),window.RecordRTC?(m("started recording session",n),t.videoRecorder=t.audioRecorder=null,V?t.stream.getAudioTracks().length&&t.stream.getVideoTracks().length?t.videoRecorder=RecordRTC(t.stream,{type:"video"}):n.video?t.videoRecorder=RecordRTC(t.stream,{type:"video"}):n.audio&&(t.audioRecorder=RecordRTC(t.stream,{type:"audio"})):_&&(isMediaRecorderCompatible()&&e.DetectRTC.browser.version>=50&&t.stream.getAudioTracks().length&&t.stream.getVideoTracks().length?t.videoRecorder=RecordRTC(t.stream,{type:"video"}):isMediaRecorderCompatible()&&e.DetectRTC.browser.version>=50?n.video?t.videoRecorder=RecordRTC(t.stream,{type:"video"}):n.audio&&(t.audioRecorder=RecordRTC(t.stream,{type:"audio"})):(n.video&&(t.videoRecorder=RecordRTC(t.stream,{type:"video"})),n.audio&&(t.audioRecorder=RecordRTC(t.stream,{type:"audio"})))),t.audioRecorder&&t.audioRecorder.startRecording(),void(t.videoRecorder&&t.videoRecorder.startRecording())):y(t.rtcMultiConnection.resources.RecordRTC,function(){t.startRecording(n)})},i.stopRecording=function(e,n){n||(n={audio:!0,video:!0}),s(n)&&(n={audio:"audio"==n,video:"video"==n}),m("stopped recording session",n);var t=this;n.audio&&t.audioRecorder?t.audioRecorder.stopRecording(function(){n.video&&t.videoRecorder?t.videoRecorder.stopRecording(function(){e({audio:t.audioRecorder.getBlob(),video:t.videoRecorder.getBlob()})}):e({audio:t.audioRecorder.getBlob()})}):n.video&&t.videoRecorder&&t.videoRecorder.stopRecording(function(){e({video:t.videoRecorder.getBlob()})})},i.takeSnapshot=function(n){w({mediaElement:this.mediaElement,userid:this.userid,connection:e,callback:n})},i.streamObject=i,i},e.set=function(e){for(var n in e)this[n]=e[n];return this},e.onMediaError=function(e){l("name",e.name),l("constraintName",p(e.constraintName)),l("message",e.message),l("original session",e.session)},e.takeSnapshot=function(n,t){w({userid:n,connection:e,callback:t})},e.saveToDisk=function(e,n){e.size&&e.type?me.SaveToDisk(URL.createObjectURL(e),n||e.name||e.type.replace("/","-")+e.type.split("/")[1]):me.SaveToDisk(e,n)},e.selectDevices=function(n,t){function i(n){n&&(e._mediaSources[n.kind]=n.id)}n&&i(this.devices[n]),t&&i(this.devices[t])},e.getDevices=function(n){return DetectRTC.MediaDevices.length?(DetectRTC.MediaDevices.forEach(function(n){e.devices[n.deviceId]=n}),void(n&&n(e.devices))):setTimeout(function(){e.getDevices(n)},1e3)},e.getMediaDevices=e.enumerateDevices=function(n){if(!n)throw"callback is mandatory.";e.getDevices(function(){n(e.DetectRTC.MediaDevices)})},e.onCustomMessage=function(e){m("Custom message",e)},e.ondrop=function(e){m("Media connection is dropped by "+e)},e.drop=function(n){n=n||{},e.attachStreams=[];for(var t in e.streams)-1==e._skip.indexOf(t)&&(t=e.streams[t],"local"==t.type?(e.detachStreams.push(t.streamid),g(t,e)):g(t,e));e.sendCustomMessage({drop:!0,dontRenegotiate:o(n.renegotiate)?!0:n.renegotiate})},e.Translator={TranslateText:function(n,t){var i=document.createElement("script");i.type="text/javascript";var o=encodeURIComponent(n),s="method"+e.token();window[s]=function(e){e.data&&e.data.translations[0]&&t&&t(e.data.translations[0].translatedText),e.error&&"Daily Limit Exceeded"==e.error.message&&(f('Text translation failed. Error message: "Daily Limit Exceeded."'),t(n))};var r="https://www.googleapis.com/language/translate/v2?key="+e.googKey+"&target="+(e.language||"en-US")+"&callback=window."+s+"&q="+o;i.src=r,document.getElementsByTagName("head")[0].appendChild(i)}},e.setDefaultEventsForMediaElement=function(n,t){n.onpause=function(){e.streams[t]&&!e.streams[t].muted&&e.streams[t].mute()},n.onplay=function(){e.streams[t]&&e.streams[t].muted&&e.streams[t].unmute()};var i=!1;n.onvolumechange=function(){i||(i=!0,e.streams[t]&&setTimeout(function(){var o=e.streams[t];e.streams[t].sockets.forEach(function(e){e.send({streamid:o.streamid,isVolumeChanged:!0,volume:n.volume})}),i=!1},2e3))}},e.onMediaFile=function(n){m("onMediaFile",n),e.body.appendChild(n.mediaElement)},e.shareMediaFile=function(n,t,i){return i=i||e.token(),PreRecordedMediaStreamer?PreRecordedMediaStreamer.shareMediaFile({file:n,video:t,streamerid:i,connection:e}):(y(e.resources.PreRecordedMediaStreamer,function(){e.shareMediaFile(n,t,i)}),i)},e.onpartofscreen=function(n){var t=document.createElement("img");t.src=n.screenshot,e.body.appendChild(t)},e.skipLogs=function(){m=l=f=function(){}},e.hold=function(n){for(var t in e.peers)e.peers[t].hold(n)},e.onhold=function(n){m("onhold",n),"audio"!=n.kind&&(n.mediaElement.pause(),n.mediaElement.setAttribute("poster",n.screenshot||e.resources.muted)),"audio"==n.kind&&(n.mediaElement.muted=!0)},e.unhold=function(n){for(var t in e.peers)e.peers[t].unhold(n)},e.onunhold=function(e){m("onunhold",e),"audio"!=e.kind&&(e.mediaElement.play(),e.mediaElement.removeAttribute("poster")),"audio"!=e.kind&&(e.mediaElement.muted=!1)},e.sharePartOfScreen=function(n){function t(){e.partOfScreen&&!e.partOfScreen.sharing||T({element:n.element,connection:e,callback:function(o){if(o!=i){i=o;for(var s in e.channels)e.channels[s].send({screenshot:o,isPartOfScreen:!0})}!n.once&&setTimeout(t,n.interval||200)}})}var i="";t(),e.partOfScreen=b({sharing:!0},n)},e.pausePartOfScreenSharing=function(){for(var n in e.peers)e.peers[n].pausePartOfScreenSharing=!0;e.partOfScreen&&(e.partOfScreen.sharing=!1)},e.resumePartOfScreenSharing=function(){for(var n in e.peers)e.peers[n].pausePartOfScreenSharing=!1;e.partOfScreen&&(e.partOfScreen.sharing=!0)},e.stopPartOfScreenSharing=function(){for(var n in e.peers)e.peers[n].stopPartOfScreenSharing=!0;e.partOfScreen&&(e.partOfScreen.sharing=!1)},e.takeScreenshot=function(n,t){if(!n||!t)throw"Invalid number of arguments.";if(!window.html2canvas)return y(e.resources.html2canvas,function(){e.takeScreenshot(n)});if(s(n)&&(n=document.querySelector(n),n||(n=document.getElementById(n))),!n)throw"HTML Element is inaccessible!";html2canvas(n,{onrendered:function(e){t(e.toDataURL())}})},e.onScreenCapturingExtensionAvailable=function(){m("It seems that screen capturing extension is installed and available on your system!")},!W&&DetectRTC.screen.onScreenCapturingExtensionAvailable&&(DetectRTC.screen.onScreenCapturingExtensionAvailable=function(){e.onScreenCapturingExtensionAvailable()}),e.changeBandwidth=function(n){for(var t in e.peers)e.peers[t].changeBandwidth(n)},e.convertToAudioStream=function(e){n(e)},e.onstatechange=function(e){m("on:state:change ("+e.userid+"):",e.name+":",e.reason||"")},e.onfailed=function(e){e.peer.numOfRetries||(e.peer.numOfRetries=0),e.peer.numOfRetries++,l("ICE connectivity check is failed. Renegotiating peer connection."),e.peer.numOfRetries<2&&e.peer.renegotiate(),e.peer.numOfRetries>=2&&(e.peer.numOfRetries=0)},e.onconnected=function(e){m("Peer connection has been established between you and",e.userid)},e.ondisconnected=function(n){l("Peer connection seems has been disconnected between you and",n.userid),r(e.channels)||e.channels[n.userid]&&(e.channels[n.userid].send({checkingPresence:!0}),setTimeout(function(){return e.peers[n.userid].connected?void delete e.peers[n.userid].connected:(e.streams.remove({remote:!0,userid:n.userid}),void e.remove(n.userid))},3e3))},e.onstreamid=function(e){m("got remote streamid",e.streamid,"from",e.userid)},e.stopMediaStream=function(n){if(!n)throw"MediaStream argument is mandatory.";if(e.keepStreamsOpened)return void(n.onended&&n.onended());e.localStreams[n.streamid]&&delete e.localStreams[n.streamid],V&&n.onended&&n.onended();var t=Boolean((n.getAudioTracks||n.getVideoTracks)&&(n.getAudioTracks()[0]&&!n.getAudioTracks()[0].stop||n.getVideoTracks()[0]&&!n.getVideoTracks()[0].stop));return!n.getAudioTracks||t?void(n.stop&&n.stop()):(n.getAudioTracks().length&&n.getAudioTracks()[0].stop&&n.getAudioTracks().forEach(function(e){e.stop()}),void(n.getVideoTracks().length&&n.getVideoTracks()[0].stop&&n.getVideoTracks().forEach(function(e){e.stop()})))},e.changeBandwidth=function(n){if(!n||s(n)||r(n))throw'Invalid "bandwidth" arguments.';u(e.peers,function(e){e.peer.bandwidth=n}),e.renegotiate()},e.openSignalingChannel=function(n){if(!window.Firebase)return y(e.resources.firebase,function(){e.openSignalingChannel(n)});var t=n.channel||e.channel;e.firebase&&(e.resources.firebaseio=e.resources.firebaseio.replace("//chat.","//"+e.firebase+"."));var i=new Firebase(e.resources.firebaseio+t);i.channel=t,i.on("child_added",function(e){n.onmessage(e.val())}),i.send=function(e){for(var n in e)(o(e[n])||"function"==typeof e[n])&&(e[n]=!1);this.push(e)},e.socket||(e.socket=i),i.onDisconnect().remove(),setTimeout(function(){n.callback(i)},1)},e.Plugin=oe}window.RMCDefaultChannel=location.href.replace(/\/|:|#|\?|\$|\^|%|\.|`|~|!|\+|@|\[|\||]|\|*. /g,"").split("\n").join("").split("\r").join(""),window.RTCMultiConnection=function(a){
function d(n){return Q&&R(),w?n():void(w=new e(T,n))}function u(e,n){if(s(e)&&(T.skipOnNewSession=!0),!w)return m("Signaling channel is not ready. Connecting..."),void d(function(){m("Signaling channel is connected. Joining the session again..."),setTimeout(function(){u(e,n)},1e3)});if(s(e)){if(!T.sessionDescriptions[e])return setTimeout(function(){m("Session-Descriptions not found. Rechecking.."),u(e,n)},1e3);e=T.sessionDescriptions[e]}if(n)return h(function(){e.oneway=!0,u(e)},n);if(!e||!e.userid||!e.sessionid){t("missing arguments",arguments);var t='Invalid data passed over "connection.join" method.';throw T.onstatechange({userid:"browser",extra:{},name:"Unexpected data detected.",reason:t}),t}T.dontOverrideSession||(T.session=e.session);var o=T.extra||e.extra||{};e.oneway||i(e)?w.joinSession(e,o):h(function(){w.joinSession(e,o)})}function h(e,n,t){function o(t){if(t.data&&t.data.chromeMediaSourceId){window.removeEventListener("message",o);var i=t.data.chromeMediaSourceId;if(DetectRTC.screen.sourceId=i,DetectRTC.screen.chromeMediaSource="desktop","PermissionDeniedError"==i){var s={message:"https:"==location.protocol?"User denied to share content of his screen.":ne,name:"PermissionDeniedError",constraintName:u,session:d};return de.mutex=!1,DetectRTC.screen.sourceId=null,T.onMediaError(s)}h(e,n)}t.data&&t.data.chromeExtensionStatus&&(f("Screen capturing extension status is:",t.data.chromeExtensionStatus),DetectRTC.screen.chromeMediaSource="screen",h(e,n,!0))}function a(n,t,i,o){if(T.onstatechange({userid:"browser",extra:{},name:"fetching-usermedia",reason:"About to capture user-media with constraints: "+p(n)}),T.preventSSLAutoAllowed&&!o&&_)return navigator.customGetUserMediaBar?void navigator.customGetUserMediaBar(n,function(){a(n,t,i,!0)},function(){T.onMediaError({name:"PermissionDeniedError",message:"User denied permission.",constraintName:n,session:d})}):void y(T.resources.customGetUserMediaBar,function(){a(n,t,i,o)});var r={onsuccess:function(e,o,s,r){S(e,o,s,r,n,t,i,u,c,d)},onerror:function(n,t){if(V&&"PERMISSION_DENIED"==n&&(n={message:"",name:"PermissionDeniedError",constraintName:t,session:d}),V&&t.video&&t.video.mozMediaSource)return i={message:ee,name:n.name||"PermissionDeniedError",constraintName:t,session:d},void T.onMediaError(i);if(s(n))return T.onMediaError({message:"Unknown Error",name:n,constraintName:t,session:d});if(n.name&&("PermissionDeniedError"==n.name||"DevicesNotFoundError"==n.name)){var i="Either: ";i+="\n Media resolutions are not permitted.",i+="\n Another application is using same media device.",i+="\n Media device is not attached or drivers not installed.",i+="\n You denied access once and it is still denied.",n.message&&n.message.length&&(i+="\n "+n.message),i={message:i,name:n.name,constraintName:t,session:d},T.onMediaError(i),_&&(d.audio||d.video)&&DetectRTC.load(function(){d.audio&&!DetectRTC.hasMicrophone&&(f("It seems that you have no microphone attached to your device/system."),d.audio=d.audio=!1,d.video||(alert("It seems that you are capturing microphone and there is no device available or access is denied. Reloading..."),location.reload())),d.video&&!DetectRTC.hasWebcam&&(f("It seems that you have no webcam attached to your device/system."),d.video=d.video=!1,d.audio||(alert("It seems that you are capturing webcam and there is no device available or access is denied. Reloading..."),location.reload())),DetectRTC.hasMicrophone||DetectRTC.hasWebcam?T.getUserMediaPromptedOnce||(T.getUserMediaPromptedOnce=!0,h(e,d)):(alert("It seems that either both microphone/webcam are not available or access is denied. Reloading..."),location.reload())})}if(n.name&&"ConstraintNotSatisfiedError"==n.name){var i="Either: ";i+="\n You are prompting unknown media resolutions.",i+="\n You are using invalid media constraints.",n.message&&n.message.length&&(i+="\n "+n.message),i={message:i,name:n.name,constraintName:t,session:d},T.onMediaError(i)}d.screen&&(V?l(ee):"https:"!==location.protocol?q||"file:"!=location.protocol&&"http:"!=location.protocol||l("You cannot use HTTP or file protocol for screen capturing. You must either use HTTPs or chrome extension page or Node-Webkit page."):l('Unable to detect actual issue. Maybe "deprecated" screen capturing flag was not set using command line or maybe you clicked "No" button or maybe chrome extension returned invalid "sourceId". Please install chrome-extension: http://bit.ly/webrtc-screen-extension')),de.mutex=!1;var o=JSON.stringify(t);de.streams[o]&&delete de.streams[o]},mediaConstraints:T.mediaConstraints||{}};r.constraints=n||c,r.connection=T,O(r)}var d=n||T.session;if(r(d))return void(e&&e());if(T.dontCaptureUserMedia)return e();if(i(d)||!T.isInitiator&&d.oneway)return T.attachStreams=[],e();var c={audio:d.audio?{mandatory:{},optional:[{chromeRenderToAssociatedSink:!0}]}:!1,video:!!d.video};if(T._mediaSources.audio&&c.audio.optional.push({sourceId:T._mediaSources.audio}),T._mediaSources.video&&(c.video={optional:[{sourceId:T._mediaSources.video}]}),!d.screen&&!c.audio&&!c.video)return e();var u={audio:!1,video:{mandatory:{chromeMediaSource:DetectRTC.screen.chromeMediaSource,maxWidth:screen.width>1920?screen.width:1920,maxHeight:screen.height>1080?screen.height:1080},optional:[]}};if(V&&d.screen){if("https:"!==location.protocol)return l(ne);f(ee),u.video=b(u.video.mandatory,{mozMediaSource:"window",mediaSource:"window"}),c.audio&&(u.audio=!0,c={}),delete u.video.chromeMediaSource}if(d.screen){if(_&&DetectRTC.screen.extensionid!=te&&(ie=!0),_&&!ie&&!t&&!DetectRTC.screen.sourceId)return U("message",o),Q||R(),void Q.postMessage();if(_&&ie&&!t&&"screen"==DetectRTC.screen.chromeMediaSource&&DetectRTC.screen.extensionid)return DetectRTC.screen.extensionid==te&&-1==document.domain.indexOf("webrtc-experiment.com")?h(e,n,!0):(m("checking if chrome extension is installed."),void DetectRTC.screen.getChromeExtensionStatus(function(t){"installed-enabled"==t&&(DetectRTC.screen.chromeMediaSource="desktop"),h(e,n,!0),m("chrome extension is installed?","desktop"==DetectRTC.screen.chromeMediaSource)}));if(_&&ie&&"desktop"==DetectRTC.screen.chromeMediaSource&&!DetectRTC.screen.sourceId)return void DetectRTC.screen.getSourceId(function(t){if("PermissionDeniedError"==t){var i={message:"User denied to share content of his screen.",name:"PermissionDeniedError",constraintName:u,session:d};return de.mutex=!1,DetectRTC.screen.chromeMediaSource="desktop",T.onMediaError(i)}return"No-Response"==t?(l("Chrome extension seems not available. Make sure that manifest.json#L16 has valid content-script matches pointing to your URL."),DetectRTC.screen.chromeMediaSource="screen",h(e,n,!0)):void h(e,n,!0)});_&&"desktop"==DetectRTC.screen.chromeMediaSource&&(u.video.mandatory.chromeMediaSourceId=DetectRTC.screen.sourceId);var v=x;a(u,c.audio||c.video?function(){v&&(x=!0),a(c,e)}:e)}else a(c,e,d.audio&&!d.video)}function S(e,i,o,s,r,a,d,u,m,l){s||(s=t()),T.onstatechange({userid:"browser",extra:{},name:"usermedia-fetched",reason:"Captured user media using constraints: "+p(r)}),d&&(e=n(e)),T.localStreamids.push(s),e.onended=function(){h.mediaElement&&!h.mediaElement.parentNode&&document.getElementById(e.streamid)&&(h.mediaElement=document.getElementById(e.streamid)),T.attachStreams.forEach(function(n,t){n==e&&(delete T.attachStreams[t],T.attachStreams=c(T.attachStreams))}),g(h,T),T.streams[s]&&T.removeStream(s);var n=T.streams[s];n&&n.sockets.length&&n.sockets.forEach(function(e){e.send({streamid:n.streamid,stopped:!0})}),de.mutex=!1,de.streams[o]&&delete de.streams[o],DetectRTC.screen.sourceId=null},j||(e.streamid=s,e.isScreen=r==u,e.isVideo=r==m&&!!m.video,e.isAudio=r==m&&!!m.audio&&!m.video,e.preMuted={audio:e.getAudioTracks().length&&!e.getAudioTracks()[0].enabled,video:e.getVideoTracks().length&&!e.getVideoTracks()[0].enabled});var f=v(e,l);f.muted=!0;var h={stream:e,streamid:s,mediaElement:f,blobURL:f.mozSrcObject?URL.createObjectURL(e):f.src,type:"local",userid:T.userid,extra:T.extra,session:l,isVideo:!!e.isVideo,isAudio:!!e.isAudio,isScreen:!!e.isScreen,isInitiator:!!T.isInitiator,rtcMultiConnection:T};x&&T.attachStreams.push(e),x=!1,T.streams[s]=T._getStream(h),i||T.onstream(h),T.setDefaultEventsForMediaElement&&T.setDefaultEventsForMediaElement(f,s),a&&a(e,h),T.onspeaking&&D({stream:e,streamedObject:h,connection:T})}var w,T=this;T.channel=a||RMCDefaultChannel,T.isAcceptNewSession=!0,T.open=function(e){T.isAcceptNewSession=!1,T.isInitiator=!0;var n=!1;return e&&(s(e)?T.sessionid=e:(o(e.transmitRoomOnce)||(T.transmitRoomOnce=e.transmitRoomOnce),o(e.dontTransmit)||(n=e.dontTransmit),o(e.sessionid)||(T.sessionid=e.sessionid))),T.socket&&T.socket.remove&&T.socket.remove(),T.sessionid||(T.sessionid=T.channel),T.sessionDescription={sessionid:T.sessionid,userid:T.userid,session:T.session,extra:T.extra},T.sessionDescriptions[T.sessionDescription.sessionid]||(T.numberOfSessions++,T.sessionDescriptions[T.sessionDescription.sessionid]=T.sessionDescription),d(function(){w.captureUserMediaOnDemand=e?!!e.captureUserMediaOnDemand:!1,e&&e.onMediaCaptured&&(T.onMediaCaptured=e.onMediaCaptured),w.captureUserMediaOnDemand||h(function(){w.initSession({sessionDescription:T.sessionDescription,dontTransmit:n}),C(T)}),w.captureUserMediaOnDemand&&w.initSession({sessionDescription:T.sessionDescription,dontTransmit:n})}),T.sessionDescription},T.connect=function(e){return e&&(T.sessionid=e),d(function(){m("Signaling channel is ready.")}),this},T.join=u,T.send=function(e,n){if(T.numberOfConnectedUsers<=0)return void setTimeout(function(){T.send(e,n)},1e3);if(!e)throw"No file, data or text message to share.";if(e instanceof Array&&!o(e[0].size)&&!o(e[0].type))for(var t=0;t<e.length;t++)e[t].size&&e[t].type&&T.send(e[t],n);else if(o(e.size)||o(e.type))le.send({text:e,channel:w,_channel:n,connection:T});else{if(!T.enableFileSharing)throw'"enableFileSharing" boolean MUST be "true" to support file sharing.';if(!w.fileBufferReader)return void k(T,function(t){w.fileBufferReader=t,T.send(e,n)});var i=b({userid:T.userid},e.extra||T.extra);w.fileBufferReader.readAsArrayBuffer(e,function(e){w.fileBufferReader.getNextChunk(e,function(e,t,i){n?n.send(e):w.send(e)})},i)}},T.disconnect=function(){w&&w.disconnect(),w=null};var x=!0;T.captureUserMedia=h,T.leave=function(e){return w?(x=!0,e?void T.eject(e):void w.leave()):void 0},T.eject=function(e){if(!T.isInitiator)throw"Only session-initiator can eject a user.";if(!T.peers[e])throw"You ejected invalid user.";T.peers[e].sendCustomMessage({ejected:!0})},T.close=function(){T.autoCloseEntireSession=!0,T.leave()},T.renegotiate=function(e,n){return T.numberOfConnectedUsers<=0?void setTimeout(function(){T.renegotiate(e,n)},1e3):void w.addStream({renegotiate:n||b({oneway:!0},T.session),stream:e})},T.attachExternalStream=function(e,n){var t={};e.getAudioTracks&&e.getAudioTracks().length&&(t.audio=!0),e.getVideoTracks&&e.getVideoTracks().length&&(t.video=!0);var i={video:{chromeMediaSource:"fake"}},o=n?i:t;S(e,!1,"",null,o,!1,!1,i,t,t)},T.addStream=function(e,n){function t(t){w.addStream({stream:t,renegotiate:e||T.session,socket:n})}if(T.numberOfConnectedUsers<=0)return void setTimeout(function(){T.addStream(e,n)},1e3);if(e){var i;!T.isInitiator&&e.oneway&&(e.oneway=!1,i=!0),h(function(n){i&&(e.oneway=!0),t(n)},e)}else t()},T.removeStream=function(e,n){function t(e,n){n.local&&"local"!=e.type||n.remote&&"remote"!=e.type||(n.screen&&e.isScreen&&T.detachStreams.push(e.streamid),n.audio&&e.isAudio&&T.detachStreams.push(e.streamid),n.video&&e.isVideo&&T.detachStreams.push(e.streamid),n.audio||n.video||n.screen||T.detachStreams.push(e.streamid),-1!=T.detachStreams.indexOf(e.streamid)&&(m("removing stream",e.streamid),g(e,T),n.stop&&T.stopMediaStream(e.stream)))}if(T.numberOfConnectedUsers<=0)return void setTimeout(function(){T.removeStream(e,n)},1e3);if(e||(e="all"),!s(e)||-1!=e.search(/all|audio|video|screen/gi)){for(var i in T.streams)if(-1==T._skip.indexOf(i))if(_stream=T.streams[i],"all"==e)t(_stream,{audio:!0,video:!0,screen:!0});else if(s(e)){var o={};o[e]=!0,t(_stream,o)}else t(_stream,e);return void(!n&&T.detachStreams.length&&T.renegotiate())}var i=T.streams[e];return i?(T.detachStreams.push(i.streamid),m("removing stream",i.streamid),g(i,T),void(n||T.renegotiate())):f("No such stream exists. Stream-id:",e)},T.switchStream=function(e){return T.numberOfConnectedUsers<=0?void setTimeout(function(){T.switchStream(e)},1e3):(T.removeStream("all",!0),void T.addStream(e))},T.sendCustomMessage=function(e){return w&&w.defaultSocket?void w.defaultSocket.send({customMessage:!0,message:e}):setTimeout(function(){T.sendCustomMessage(e)},1e3)},L(T)};var N=[],F=!!window.opera||navigator.userAgent.indexOf(" OPR/")>=0,V="undefined"!=typeof window.InstallTrigger,B=Object.prototype.toString.call(window.HTMLElement).indexOf("Constructor")>0,_=!!window.chrome&&!F,j=!!document.documentMode,W=B||j,H=!!navigator.userAgent.match(/Android|iPhone|iPad|iPod|BlackBerry|IEMobile/i),q=!!(window.process&&"object"==typeof window.process&&window.process.versions&&window.process.versions["node-webkit"]);window.MediaStream=window.MediaStream||window.webkitMediaStream,window.AudioContext=window.AudioContext||window.webkitAudioContext;var z=50,G=navigator.userAgent.match(/Chrom(e|ium)\/([0-9]+)\./);_&&G&&G[2]&&(z=parseInt(G[2],10));var J=50;G=navigator.userAgent.match(/Firefox\/(.*)/),V&&G&&G[1]&&(J=parseInt(G[1],10));var Y=window.console||{log:function(){},error:function(){},warn:function(){}};if(_||V||B)var m=Y.log.bind(Y),l=Y.error.bind(Y),f=Y.warn.bind(Y);var Q,X,K,$={},Z={},ee='Make sure that you are using Firefox Nightly and you enabled: media.getusermedia.screensharing.enabled flag from about:config page. You also need to add your domain in "media.getusermedia.screensharing.allowed_domains" flag. If you are using WinXP then also enable "media.getusermedia.screensharing.allow_on_old_platforms" flag. NEVER forget to use "only" HTTPs for screen capturing!',ne="HTTPs i.e. SSL-based URI is mandatory to use screen capturing.",te="ajhifddimkapgcifgcodmmfdlknahffk",ie=-1!=document.domain.indexOf("webrtc-experiment.com");attachEventListener=function(e,n,t,i){e.addEventListener(n,t,i)};var oe=window.PluginRTC||{};window.onPluginRTCInitialized=function(e){oe=e,MediaStreamTrack=oe.MediaStreamTrack,re=oe.RTCPeerConnection,ue=oe.RTCIceCandidate,ce=oe.RTCSessionDescription,m(W?"Java-Applet":"ActiveX","plugin has been loaded.")},r(oe)||window.onPluginRTCInitialized(oe),W&&y("https://cdn.webrtc-experiment.com/Plugin.EveryWhere.js");var se=window.MediaStream;"undefined"==typeof se&&"undefined"!=typeof webkitMediaStream&&(se=webkitMediaStream),"undefined"==typeof se||"stop"in se.prototype||(se.prototype.stop=function(){this.getAudioTracks().forEach(function(e){e.stop()}),this.getVideoTracks().forEach(function(e){e.stop()})});var re,ae={mandatory:{},optional:[]},de={streams:[],mutex:!1,queueRequests:[]},ce=window.RTCSessionDescription||window.mozRTCSessionDescription,ue=window.RTCIceCandidate||window.mozRTCIceCandidate;"undefined"!=typeof mozRTCPeerConnection?re=mozRTCPeerConnection:"undefined"!=typeof webkitRTCPeerConnection?re=webkitRTCPeerConnection:"undefined"!=typeof window.RTCPeerConnection?re=window.RTCPeerConnection:Y.error("WebRTC 1.0 (RTCPeerConnection) API seems NOT available in this browser.");var me={SaveToDisk:P},le={send:function(e){function n(e,t){var s={type:"text",uuid:m,sendingTime:l};e&&(t=e,s.packets=parseInt(t.length/d)),t.length>d?s.message=t.slice(0,d):(s.message=t,s.last=!0,s.isobject=u),o.send(s,r),c=t.slice(s.message.length),c.length&&setTimeout(function(){n(null,c)},i.chunkInterval||100)}var i=e.connection;if(e.text instanceof ArrayBuffer||e.text instanceof DataView)return e.channel.send(e.text,e._channel);var o=e.channel,r=e._channel,a=e.text,d=i.chunkSize||1e3,c="",u=!1;s(a)||(u=!0,a=JSON.stringify(a));var m=t(),l=(new Date).getTime();n(a)}};!function(){"use strict";function e(){var e,n,t,i=(o.appVersion,o.userAgent),s=o.appName,a=""+parseFloat(o.appVersion),d=parseInt(o.appVersion,10);return-1!==(n=i.indexOf("Opera"))?(s="Opera",a=i.substring(n+6),-1!==(n=i.indexOf("Version"))&&(a=i.substring(n+8))):-1!==(n=i.indexOf("MSIE"))?(s="IE",a=i.substring(n+5)):-1!==(n=i.indexOf("Chrome"))?(s="Chrome",a=i.substring(n+7)):-1!==(n=i.indexOf("Safari"))?(s="Safari",a=i.substring(n+7),-1!==(n=i.indexOf("Version"))&&(a=i.substring(n+8))):-1!==(n=i.indexOf("Firefox"))?(s="Firefox",a=i.substring(n+8)):(e=i.lastIndexOf(" ")+1)<(n=i.lastIndexOf("/"))&&(s=i.substring(e,n),a=i.substring(n+1),s.toLowerCase()===s.toUpperCase()&&(s=o.appName)),r&&(s="Edge",a=parseInt(o.userAgent.match(/Edge\/(\d+).(\d+)$/)[2],10)),-1!==(t=a.indexOf(";"))&&(a=a.substring(0,t)),-1!==(t=a.indexOf(" "))&&(a=a.substring(0,t)),d=parseInt(""+a,10),isNaN(d)&&(a=""+parseFloat(o.appVersion),d=parseInt(o.appVersion,10)),{fullVersion:a,version:d,name:s}}function n(e){t(function(n){e(n.match(/^(192\.168\.|169\.254\.|10\.|172\.(1[6-9]|2\d|3[01]))/)?"Local: "+n:"Public: "+n)})}function t(e){function n(n){var i=/([0-9]{1,3}(\.[0-9]{1,3}){3})/,o=i.exec(n)[1];void 0===t[o]&&e(o),t[o]=!0}var t={},i=window.RTCPeerConnection||window.mozRTCPeerConnection||window.webkitRTCPeerConnection,o=!!window.webkitRTCPeerConnection;if(!i){var s=document.getElementById("iframe");if(!s)throw"NOTE: you need to have an iframe in the page right above the script tag.";var r=s.contentWindow;i=r.RTCPeerConnection||r.mozRTCPeerConnection||r.webkitRTCPeerConnection,o=!!r.webkitRTCPeerConnection}var a,d={optional:[{RtpDataChannels:!0}]};o&&(a={iceServers:[{urls:"stun:stun.services.mozilla.com"}]},"undefined"!=typeof v&&v.browser.isFirefox&&v.browser.version<=38&&(a[0]={url:a[0].urls}));var c=new i(a,d);c.onicecandidate=function(e){e.candidate&&n(e.candidate.candidate)},c.createDataChannel(""),c.createOffer(function(e){c.setLocalDescription(e,function(){},function(){})},function(){}),setTimeout(function(){var e=c.localDescription.sdp.split("\n");e.forEach(function(e){0===e.indexOf("a=candidate:")&&n(e)})},1e3)}function i(e){return!o.enumerateDevices&&window.MediaStreamTrack&&window.MediaStreamTrack.getSources&&(o.enumerateDevices=window.MediaStreamTrack.getSources.bind(window.MediaStreamTrack)),!o.enumerateDevices&&o.enumerateDevices&&(o.enumerateDevices=o.enumerateDevices.bind(o)),o.enumerateDevices?(m=[],void o.enumerateDevices(function(n){n.forEach(function(e){var n={};for(var t in e)n[t]=e[t];var i;m.forEach(function(e){e.id===n.id&&(i=!0)}),i||("audio"===n.kind&&(n.kind="audioinput"),"video"===n.kind&&(n.kind="videoinput"),n.deviceId||(n.deviceId=n.id),n.id||(n.id=n.deviceId),n.label||(n.label="Please invoke getUserMedia once.",g||(n.label="HTTPs is required to get label of this "+n.kind+" device.")),"audioinput"!==n.kind&&"audio"!==n.kind||(f=!0),"audiooutput"===n.kind&&(p=!0),"videoinput"!==n.kind&&"video"!==n.kind||(h=!0),m.push(n))}),"undefined"!=typeof v&&(v.MediaDevices=m,v.hasMicrophone=f,v.hasSpeakers=p,v.hasWebcam=h),e&&e()})):void(e&&e())}var o=window.navigator;o.mediaDevices&&o.mediaDevices.enumerateDevices&&(o.enumerateDevices=function(e){o.mediaDevices.enumerateDevices().then(e)}),"undefined"!=typeof o?("undefined"!=typeof o.webkitGetUserMedia&&(o.getUserMedia=o.webkitGetUserMedia),"undefined"!=typeof o.mozGetUserMedia&&(o.getUserMedia=o.mozGetUserMedia)):o={getUserMedia:function(){}};var s=!!o.userAgent.match(/Android|iPhone|iPad|iPod|BlackBerry|IEMobile/i),r=!(-1===o.userAgent.indexOf("Edge")||!o.msSaveOrOpenBlob&&!o.msSaveBlob),a={Android:function(){return o.userAgent.match(/Android/i)},BlackBerry:function(){return o.userAgent.match(/BlackBerry/i)},iOS:function(){return o.userAgent.match(/iPhone|iPad|iPod/i)},Opera:function(){return o.userAgent.match(/Opera Mini/i)},Windows:function(){return o.userAgent.match(/IEMobile/i)},any:function(){return a.Android()||a.BlackBerry()||a.iOS()||a.Opera()||a.Windows()},getOsName:function(){var e="Unknown OS";return a.Android()&&(e="Android"),a.BlackBerry()&&(e="BlackBerry"),a.iOS()&&(e="iOS"),a.Opera()&&(e="Opera Mini"),a.Windows()&&(e="Windows"),e}},d="Unknown OS";a.any()?d=a.getOsName():(-1!==o.appVersion.indexOf("Win")&&(d="Windows"),-1!==o.appVersion.indexOf("Mac")&&(d="MacOS"),-1!==o.appVersion.indexOf("X11")&&(d="UNIX"),-1!==o.appVersion.indexOf("Linux")&&(d="Linux"));var c=!1,u=!1;["captureStream","mozCaptureStream","webkitCaptureStream"].forEach(function(e){e in document.createElement("canvas")&&(c=!0),e in document.createElement("video")&&(u=!0)});var m=[],l=!1;"undefined"!=typeof MediaStreamTrack&&"getSources"in MediaStreamTrack?l=!0:o.mediaDevices&&o.mediaDevices.enumerateDevices&&(l=!0);var f=l,p=l,h=l;i();var v={};v.browser=e(),v.browser["is"+v.browser.name]=!0;var g="https:"===location.protocol,S=(!!(window.process&&"object"==typeof window.process&&window.process.versions&&window.process.versions["node-webkit"]),!1);["webkitRTCPeerConnection","mozRTCPeerConnection","RTCIceGatherer"].forEach(function(e){e in window&&(S=!0)}),v.isWebRTCSupported=S,v.isORTCSupported="undefined"!=typeof RTCIceGatherer;var w=!1;v.browser.isChrome&&v.browser.version>=35?w=!0:v.browser.isFirefox&&v.browser.version>=34&&(w=!0),g||(w=!1),v.isScreenCapturingSupported=w;var C={};["AudioContext","webkitAudioContext","mozAudioContext","msAudioContext"].forEach(function(e){C.isSupported&&C.isCreateMediaStreamSourceSupported||e in window&&(C.isSupported=!0,"createMediaStreamSource"in window[e].prototype&&(C.isCreateMediaStreamSourceSupported=!0))}),v.isAudioContextSupported=C.isSupported,v.isCreateMediaStreamSourceSupported=C.isCreateMediaStreamSourceSupported;var b=!1;v.browser.isChrome&&v.browser.version>31&&(b=!0),v.isRtpDataChannelsSupported=b;var y=!1;if(v.browser.isFirefox&&v.browser.version>28?y=!0:v.browser.isChrome&&v.browser.version>25?y=!0:v.browser.isOpera&&v.browser.version>=11&&(y=!0),v.isSctpDataChannelsSupported=y,v.isMobileDevice=s,v.isWebSocketsSupported="WebSocket"in window&&2===window.WebSocket.CLOSING,v.isWebSocketsBlocked="Checking",v.isWebSocketsSupported){var T=new WebSocket("wss://echo.websocket.org:443/");T.onopen=function(){v.isWebSocketsBlocked=!1,v.loadCallback&&v.loadCallback()},T.onerror=function(){v.isWebSocketsBlocked=!0,v.loadCallback&&v.loadCallback()}}var k=!1;o.getUserMedia?k=!0:o.mediaDevices&&o.mediaDevices.getUserMedia&&(k=!0),v.browser.isChrome&&v.browser.version>=47&&!g&&(v.isGetUserMediaSupported="Requires HTTPs"),v.isGetUserMediaSupported=k,v.osName=d,v.isCanvasSupportsStreamCapturing=c,v.isVideoSupportsStreamCapturing=u,v.DetectLocalIPAddress=n,v.load=function(e){this.loadCallback=e,i(e)},v.MediaDevices=m,v.hasMicrophone=f,v.hasSpeakers=p,v.hasWebcam=h;var R=!1;"setSinkId"in document.createElement("video")&&(R=!0),v.isSetSinkIdSupported=R;var x=!1;v.browser.isFirefox?"getSenders"in mozRTCPeerConnection.prototype&&(x=!0):v.browser.isChrome&&"getSenders"in webkitRTCPeerConnection.prototype&&(x=!0),v.isRTPSenderReplaceTracksSupported=x;var M=!1;v.browser.isFirefox&&v.browser.version>38&&(M=!0),v.isRemoteStreamProcessingSupported=M;var D=!1;"undefined"!=typeof MediaStreamTrack&&"applyConstraints"in MediaStreamTrack.prototype&&(D=!0),v.isApplyConstraintsSupported=D;var O=!1;v.browser.isFirefox&&v.browser.version>=43&&(O=!0),v.isMultiMonitorScreenCapturingSupported=O,window.DetectRTC=v}();var fe;DetectRTC.screen={chromeMediaSource:"screen",extensionid:te,getSourceId:function(e){function n(n){return"installed-enabled"==n?(fe=e,void window.postMessage("get-sourceId","*")):(DetectRTC.screen.chromeMediaSource="screen",void e("No-Response"))}if(!e)throw'"callback" parameter is mandatory.';DetectRTC.screen.status?n(DetectRTC.screen.status):DetectRTC.screen.getChromeExtensionStatus(n)},onMessageCallback:function(e){if(s(e)||e.sourceId){if(m("chrome message",e),"PermissionDeniedError"==e){if(DetectRTC.screen.chromeMediaSource="PermissionDeniedError",fe)return fe("PermissionDeniedError");throw new Error("PermissionDeniedError")}"rtcmulticonnection-extension-loaded"==e&&(DetectRTC.screen.chromeMediaSource="desktop",DetectRTC.screen.onScreenCapturingExtensionAvailable&&(DetectRTC.screen.onScreenCapturingExtensionAvailable(),DetectRTC.screen.onScreenCapturingExtensionAvailable=null)),e.sourceId&&(DetectRTC.screen.sourceId=e.sourceId,fe&&fe(DetectRTC.screen.sourceId))}},getChromeExtensionStatus:function(e,n){function t(e){DetectRTC.screen.status=e,n(e)}if(V)return t("not-chrome");2!=arguments.length&&(n=e,e=this.extensionid);var i=document.createElement("img");i.src="chrome-extension://"+e+"/icon.png",i.onload=function(){DetectRTC.screen.chromeMediaSource="screen",window.postMessage("are-you-there","*"),setTimeout(function(){t("screen"==DetectRTC.screen.chromeMediaSource?"desktop"==DetectRTC.screen.chromeMediaSource?"installed-enabled":"installed-disabled":"installed-enabled")},2e3)},i.onerror=function(){t("not-installed")}}},window.addEventListener||(window.addEventListener=function(e,n,t){e.attachEvent&&e.attachEvent("on"+n,t)}),window.addEventListener("message",function(e){e.origin==window.location.origin&&DetectRTC.screen.onMessageCallback(e.data)})}();
var CanvasDesigner=function(){function e(e){t&&t.contentWindow.postMessage({canvasDesignerSyncData:e},"*")}function n(){event.data&&event.data.canvasDesignerSyncData&&s(event.data.canvasDesignerSyncData)}var t,a={line:!0,pencil:!0,dragSingle:!0,dragMultiple:!0,eraser:!0,rectangle:!0,arc:!0,bezier:!0,quadratic:!0,text:!0},i="pencil",s=function(e){},c=window.addEventListener?"addEventListener":"attachEvent",d=window[c],r="attachEvent"==c?"onmessage":"message";return d(r,function(e){console.log("parent received message!: ",e.data),e.data&&e.data.canvasDesignerSyncData&&s(e.data.canvasDesignerSyncData)},!1),{appendTo:function(e){t=document.createElement("iframe"),t.id="drawboard",t.src="widget.html?tools="+JSON.stringify(a)+"&selectedIcon="+i,t.style.width="100%",t.style.height="100%",t.style.border=0,e.appendChild(t)},destroy:function(){t&&t.parentNode.removeChild(t),window.removeEventListener("message",n)},addSyncListener:function(e){s=e},syncData:e,setTools:function(e){a=e},setSelected:function(e){"undefined"!=typeof a[e]&&(i=e)}}}();
!function(){function e(e,o){var n={audio:!1,video:{mandatory:{chromeMediaSource:e?"screen":"desktop",maxWidth:window.screen.width>1920?window.screen.width:1920,maxHeight:window.screen.height>1080?window.screen.height:1080},optional:[]}};return o&&(n.video.mandatory.chromeMediaSourceId=o),n}function o(){return d?d.isLoaded?void d.contentWindow.postMessage({captureSourceId:!0},"*"):void setTimeout(o,100):void n(o)}function n(e){return d?void e():(d=document.createElement("iframe"),d.onload=function(){d.isLoaded=!0,e()},d.src="getScreenId.html",d.style.display="none",void(document.body||document.documentElement).appendChild(d))}window.getScreenId=function(n){function d(o){o.data&&(o.data.chromeMediaSourceId&&("PermissionDeniedError"===o.data.chromeMediaSourceId?n("permission-denied"):n(null,o.data.chromeMediaSourceId,e(null,o.data.chromeMediaSourceId))),o.data.chromeExtensionStatus&&n(o.data.chromeExtensionStatus,null,e(o.data.chromeExtensionStatus)),window.removeEventListener("message",d))}return navigator.mozGetUserMedia?void n(null,"firefox",{video:{mozMediaSource:"window",mediaSource:"window"}}):(o(),void window.addEventListener("message",d))};var d;window.getScreenConstraints=function(e){n(function(){getScreenId(function(o,n,d){e(o,d.video)})})}}();
!function(){function e(e,n){function i(){a.signal({leaving:!0}),a.isbroadcaster&&(a.stopBroadcasting=!0),e.stream&&e.stream.stop(),window.Firebase&&o.remove()}var o,r=e.userid||t();e.userid||(e.userid=r);var a=this,d={},s={},c=0;this.onmessage=function(t){if(console.log(a.sentParticipationRequest),console.log(n),console.log(t),null!=t.roomid&&null!=t.userid&&(screen_roomid=t.roomid,screen_userid=t.userid),t.roomid==n&&t.broadcasting&&!a.sentParticipationRequest?e.onscreen(t):console.debug(JSON.stringify(t,function(e,n){return n.sdp?(console.log(n.sdp.type,"————",n.sdp.sdp),""):n},"————")),t.sdp&&t.to==r&&this.onsdp(t),t.candidate&&t.to==r&&this.onice(t),t.participationRequest&&t.to==r){var i=l;i.to=t.userid,i.stream=e.stream,d[t.userid]=w.createOffer(i),c++,e.onNumberOfParticipantsChnaged&&e.onNumberOfParticipantsChnaged(c)}},this.onsdp=function(n){var t=JSON.parse(n.sdp);if("offer"==t.type){var i=l;i.stream=e.stream,i.sdp=t,i.to=n.userid,d[n.userid]=b.createAnswer(i)}"answer"==t.type&&d[n.userid].setRemoteDescription(t)},this.onice=function(e){e.candidate=JSON.parse(e.candidate);var n=d[e.userid];if(n){n.addIceCandidate(e.candidate);var t=s[e.userid]||[];if(t.length){for(var i=0;i<t.length;i++)n.addIceCandidate(t[i]);s[e.userid]=[]}}else{var o=s[e.userid];o?s[e.userid][o.length]=e.candidate:s[e.userid]=[e.candidate]}};var l={onsdp:function(e,n){console.log("local-sdp",JSON.stringify(e.sdp,null," ")),a.signal({sdp:JSON.stringify(e),to:n})},onicecandidate:function(e,n){a.signal({candidate:JSON.stringify(e),to:n})},onaddstream:function(n,t){function i(){return f?o():void(r.readyState<=HTMLMediaElement.HAVE_CURRENT_DATA||r.paused||r.currentTime<=0?setTimeout(i,300):o())}function o(){e.onaddstream&&e.onaddstream({video:r,stream:n,userid:t,type:"remote"})}console.debug("onaddstream",">>>>>>",n),document.getElementById("viewScreenShareButton").removeAttribute("disabled"),n.onended=function(){e.onuserleft&&e.onuserleft(t)};var r=document.createElement("video");r.id=t,r[u?"mozSrcObject":"src"]=u?n:window.webkitURL.createObjectURL(n),r.autoplay=!0,r.controls=!0,r.play(),i()}};if(this.broadcast=function(n){a.roomid=n.roomid||t(),n.userid&&(r=n.userid),a.isbroadcaster=!0,function i(){a.signal({roomid:a.roomid,broadcasting:!0}),a.stopBroadcasting||e.transmitOnce||setTimeout(i,3e3)}(),o.onDisconnect&&o.onDisconnect().remove()},this.join=function(e){a.roomid=e.roomid,this.signal({participationRequest:!0,to:e.to}),a.sentParticipationRequest=!0},window.addEventListener("beforeunload",function(){i()},!1),window.addEventListener("keyup",function(e){116==e.keyCode&&i()},!1),e.leave=i,e.openSignalingChannel)o=e.openSignalingChannel(function(n){n=JSON.parse(n);var t=!1;"number"==typeof r&&parseInt(n.userid)!=r&&(t=!0),"string"==typeof r&&n.userid+""!=r&&(t=!0),t&&(n.to&&("number"==typeof r&&(n.to=parseInt(n.to)),"string"==typeof r&&(n.to=n.to+"")),n.leaving?(e.onuserleft(n.userid),c--,e.onNumberOfParticipantsChnaged&&e.onNumberOfParticipantsChnaged(c)):a.onmessage(n))}),this.signal=function(e){e.userid=r,o.send(JSON.stringify(e))};else{if(!window.Firebase)throw"You must link <https://cdn.firebase.com/v0/firebase.js> file.";o=new window.Firebase("https://"+(e.firebase||"signaling")+".firebaseIO.com/"+e.channel),o.on("child_added",function(n){var t=n.val(),i=!1;"number"==typeof r&&parseInt(t.userid)!=r&&(i=!0),"string"==typeof r&&t.userid+""!=r&&(i=!0),i&&(t.to&&("number"==typeof r&&(t.to=parseInt(t.to)),"string"==typeof r&&(t.to=t.to+"")),t.leaving?(c--,e.onNumberOfParticipantsChnaged&&e.onNumberOfParticipantsChnaged(c),e.onuserleft(t.userid)):a.onmessage(t)),i&&n.ref().remove()}),this.signal=function(e){e.userid=r,o.push(e)}}}function n(e,t){if(!p){if(!t)return n(e,!0);p=!0;var i=document.createElement("iframe");i.onload=function(){i.isLoaded=!0,window.addEventListener("message",function(n){window.iceServers=n.data.iceServers,n.data&&n.data.iceServers&&e(n.data.iceServers)}),i.contentWindow.postMessage("get-ice-servers","*")},i.src="getIceServers.html",i.style.display="none",(document.body||document.documentElement).appendChild(i)}}function t(){return Math.round(9999999999*Math.random())+9999999999}function i(){}function o(e){console.error("sdp error:",e)}function r(e){if(u)return e;if(f)return e;if("undefined"!=typeof BandwidthHandler){window.isMobileDevice=f,window.isFirefox=u;var n={screen:300,video:256},t=!1;return e=BandwidthHandler.setApplicationSpecificBandwidth(e,n,t),e=BandwidthHandler.setVideoBitrates(e,{min:n.video,max:n.video})}return e=e.replace(/b=AS([^\r\n]+\r\n)/g,""),e=e.replace(/a=mid:video\r\n/g,"a=mid:video\r\nb=AS:300\r\n")}function a(e,n){var t=document.createElement("script");t.src=e,t.async=!0,document.documentElement.appendChild(t),console.log("loaded",e)}window.Screen=function(n){function t(n){o=new e(r,n&&n.length||r.channel)}function i(e,n){getScreenId(function(n,t,i){console.log("screen_constraints",JSON.stringify(i,null," ")),navigator.getUserMedia(i,function(n){n.onended=function(){r.onuserleft&&r.onuserleft("self")},r.stream=n;var t=document.createElement("video");t.id="self",t[u?"mozSrcObject":"src"]=u?n:window.webkitURL.createObjectURL(n),t.autoplay=!0,t.controls=!0,t.play(),r.onaddstream({video:t,stream:n,userid:"self",type:"local"}),e(n)},function(e){l&&"http:"===location.protocol?alert("You're not testing it on SSL origin (HTTPS domain) otherwise you didn't enable --allow-http-screen-capture command-line flag on canary."):l?alert("Screen capturing is either denied or not supported. Please install chrome extension for screen capturing or run chrome with command-line flag: --enable-usermedia-screen-capturing"):u&&alert(a),console.error(e)})})}var o,r=this;this.channel=n||location.href.replace(/\/|:|#|%|\.|\[|\]/g,""),this.onscreen=function(e){console.log(" onscreen ",e),r.detectedRoom||(r.detectedRoom=!0,r.view(e))};var a='Make sure that you are using Firefox Nightly and you enabled: media.getusermedia.screensharing.enabled flag from about:config page. You also need to add your domain in "media.getusermedia.screensharing.allowed_domains" flag.';this.share=function(e){i(function(){!o&&t(e),console.log("share new screen ",e),o.broadcast({roomid:e&&e.length||r.channel,userid:r.userid})})},this.view=function(e){!o&&t(),console.log("view and join new screen "),o.join({to:e.userid,roomid:e.roomid})},this.check=t};var d=window.mozRTCPeerConnection||window.webkitRTCPeerConnection,s=window.mozRTCSessionDescription||window.RTCSessionDescription,c=window.mozRTCIceCandidate||window.RTCIceCandidate;navigator.getUserMedia=navigator.mozGetUserMedia||navigator.webkitGetUserMedia;var u=!!navigator.mozGetUserMedia,l=!!navigator.webkitGetUserMedia,f=!!navigator.userAgent.match(/Android|iPhone|iPad|iPod|BlackBerry|IEMobile/i),m=[];m.push({url:"stun:stun.l.google.com:19302"}),m.push({url:"stun:stun.anyfirewall.com:3478"}),m.push({url:"turn:turn.bistri.com:80",credential:"homeo",username:"homeo"}),m.push({url:"turn:turn.anyfirewall.com:443?transport=tcp",credential:"webrtc",username:"webrtc"}),m={iceServers:m};var p;n(function(e){m.iceServers=m.iceServers.concat(e)});var g={optional:[{DtlsSrtpKeyAgreement:!0}]},h={optional:[],mandatory:{OfferToReceiveAudio:!1,OfferToReceiveVideo:!1}},w={createOffer:function(e){var n=new d(m,g);return n.addStream(e.stream),n.onicecandidate=function(n){n.candidate&&e.onicecandidate(n.candidate,e.to)},n.createOffer(function(t){t.sdp=r(t.sdp),n.setLocalDescription(t),e.onsdp(t,e.to)},o,h),this.peer=n,this},setRemoteDescription:function(e){console.log("setting remote descriptions",e.sdp),this.peer.setRemoteDescription(new s(e),i,o)},addIceCandidate:function(e){console.log("adding ice",e.candidate),this.peer.addIceCandidate(new c({sdpMLineIndex:e.sdpMLineIndex,candidate:e.candidate}))}},v={optional:[],mandatory:{OfferToReceiveAudio:!1,OfferToReceiveVideo:!0}},b={createAnswer:function(e){var n=new d(m,g);return n.onaddstream=function(n){e.onaddstream(n.stream,e.to)},n.onicecandidate=function(n){n.candidate&&e.onicecandidate(n.candidate,e.to)},console.log("setting remote descriptions",e.sdp.sdp),n.setRemoteDescription(new s(e.sdp),i,o),n.createAnswer(function(t){t.sdp=r(t.sdp),n.setLocalDescription(t),e.onsdp(t,e.to)},o,v),this.peer=n,this},addIceCandidate:function(e){console.log("adding ice",e.candidate),this.peer.addIceCandidate(new c({sdpMLineIndex:e.sdpMLineIndex,candidate:e.candidate}))}};!window.getScreenId&&a("getScreenId.js")}();
function shownotification(e){var t=document.createElement("div");t.className="alert alert-success fade in",t.innerHTML='<a href="#" class="close" data-dismiss="alert" aria-label="close">&times;</a>'+e,document.getElementById("alertBox").hidden=!1,document.getElementById("alertBox").innerHTML="",document.getElementById("alertBox").appendChild(t),setTimeout(function(){document.getElementById("alertBox").hidden=!0},3e3)}function error(e,t){console.log(e,t)}function getElement(e){return document.querySelector(e)}function getRandomColor(){for(var e="0123456789ABCDEF".split(""),t="#",n=0;6>n;n++)t+=e[Math.round(15*Math.random())];return t}function getUserinfo(e,t){return e?'<video src="'+e+'" autoplay></vide>':'<img src="'+t+'">'}function fireClickEvent(e){var t=new MouseEvent("click",{view:window,bubbles:!0,cancelable:!0});e.dispatchEvent(t)}function bytesToSize(e){var t=["Bytes","KB","MB","GB","TB"];if(0==e)return"0 Bytes";var n=parseInt(Math.floor(Math.log(e)/Math.log(1024)));return Math.round(e/Math.pow(1024,n),2)+" "+t[n]}function startsessionTimer(){var e=$("#countdownSecond"),t=$("#countdownMinutes"),n=parseInt(e.text(),10),i=parseInt(t.text(),10);timer(e,n,t,i)}function timer(e,t,n,i){console.log(i);var o=setInterval(function(){t--,e.html(t),0==t&&(t=60,i--,$("#countdownMinutes").html(i),0>i&&clearInterval(o))},1e3)}function appendVideo(e,t){createVideoContainer(e,t,function(n){var i=document.createElement("video");i.className=t,i.setAttribute("style","height:auto;opacity:1;"),i.id=e.userid,i.src=URL.createObjectURL(e.stream),viden.hidden=!1;document.getElementById("remote");n.appendChild(i),i.play()})}function createVideoContainer(e,t,n){var i=document.createElement("div");i.setAttribute("style",t||"float:left;opacity: 1;width: 32%;"),remote.insertBefore(i,remote.firstChild),n&&n(i)}function waitForRemoteVideo(e,t,n,i){var o=e.getVideoTracks();0===o.length||t.currentTime>0?transitionToActive(t,n,i):setTimeout(function(){waitForRemoteVideo(e,t,n,i)},100)}function transitionToActive(e,t,n){e.style.opacity=1,null!=localVideo&&setTimeout(function(){t.src=""},500),null!=miniVideo&&setTimeout(function(){n.style.opacity=1},1e3)}function transitionToWaiting(){card.style.webkitTransform="rotateY(0deg)",setTimeout(function(){localVideo.src=miniVideo.src,localVideo.muted=!0,miniVideo.src="",remoteVideo.src="",localVideo.style.opacity=1},500),miniVideo.style.opacity=0,remoteVideo.style.opacity=0}function syncSnapshot(e,t,n){rtcMultiConnection.send({type:t,message:e,name:n})}function createFileSharingDiv(e){var t=document.createElement("div");t.className="col-sm-6 fileViewing1Box",t.id=webcallpeers[e].fileSharingSubContents.fileSharingBox;var n=document.createElement("p");n.appendChild(document.createTextNode("File Viewer"));var i=document.createElement("span");i.className="btn btn-default glyphicon glyphicon-import closeButton",i.innerHTML="Minimize",i.id=webcallpeers[e].fileSharingSubContents.minButton,i.setAttribute("lastClickedBy",""),i.onclick=function(){resizeFV(webcallpeers[e].userid,i.id,arrFilesharingBoxes)};var o=document.createElement("span");o.className="btn btn-default glyphicon glyphicon-export closeButton",o.innerHTML="Maximize",o.id=webcallpeers[e].fileSharingSubContents.maxButton,o.setAttribute("lastClickedBy",""),o.onclick=function(){maxFV(webcallpeers[e].userid,o.id,arrFilesharingBoxes,webcallpeers[e].fileSharingSubContents.fileSharingBox)};var r=document.createElement("span");r.className="btn btn-default glyphicon glyphicon-remove closeButton",r.innerHTML="Close",r.id=webcallpeers[e].fileSharingSubContents.closeButton,r.setAttribute("lastClickedBy",""),r.onclick=function(){closeFV(webcallpeers[e].userid,r.id,webcallpeers[e].fileSharingContainer)},n.appendChild(i),n.appendChild(o),n.appendChild(r);var a=document.createElement("div");a.className="filesharingWidget",a.id=webcallpeers[e].fileSharingContainer;var l=document.createElement("p");l.className="filler",t.appendChild(n),t.appendChild(a),t.appendChild(l),document.getElementById("fileSharingRow").appendChild(t);var c=document.createElement("div");c.className="col-sm-6 filesharing1Box";var s=document.createElement("p"),d=document.createElement("span");d.className="btn btn-default glyphicon glyphicon-question-sign closeButton",d.innerHTML="Help",s.appendChild(document.createTextNode("List of Uploaded Files")),s.appendChild(d);var u=document.createElement("div");u.id=webcallpeers[e].fileListContainer;var m=document.createElement("div");c.appendChild(s),c.appendChild(u),c.appendChild(m),document.getElementById("fileListingRow").appendChild(c)}function attachControlButtons(e,t,n,o){var r=document.createElement("div");r.id=n,r.setAttribute("style","float:left;margin-left: 20px;"),r.name=t;var a=document.createElement("span");a.id="videoButton",a.setAttribute("data-val","mute"),a.setAttribute("title","Toggle Video"),a.setAttribute("data-placement","bottom"),a.setAttribute("data-toggle","tooltip"),a.setAttribute("data-container","body"),a.className="pull-right glyphicon glyphicon-eye-open btn btn-default videoButtonClass mediaButton",a.innerHTML="Video On",a.onclick=function(e){"mute"==this.getAttribute("data-val")?(this.setAttribute("data-val","unmute"),rtcMultiConnection.streams[t].mute({video:!0}),a.innerHTML="Video Off",a.className="pull-right glyphicon glyphicon-eye-close btn btn-default videoButtonClass mediaButton"):(this.setAttribute("data-val","mute"),rtcMultiConnection.streams[t].unmute({video:!0}),a.innerHTML="Video On",a.className="pull-right glyphicon glyphicon-eye-open btn btn-default videoButtonClass mediaButton")},r.appendChild(a);var l=document.createElement("span");if(l.id="audioButton",l.setAttribute("data-val","mute"),l.setAttribute("title","Toggle Audio"),l.setAttribute("data-placement","bottom"),l.setAttribute("data-toggle","tooltip"),l.setAttribute("data-container","body"),l.className="pull-right glyphicon glyphicon-volume-up btn btn-default mediaButton",l.innerHTML="Audio On",l.onclick=function(){"mute"==this.getAttribute("data-val")?(this.setAttribute("data-val","unmute"),l.innerHTML="Audio Off",l.className="pull-right glyphicon glyphicon-volume-off btn btn-default mediaButton"):(this.setAttribute("data-val","mute"),l.innerHTML="Audio On",l.className="pull-right glyphicon glyphicon-volume-up btn btn-default mediaButton")},r.appendChild(l),videoRecord){var c=document.createElement("div");c.id="snapshotButton",c.setAttribute("title","Snapshot"),c.setAttribute("data-placement","bottom"),c.setAttribute("data-toggle","tooltip"),c.setAttribute("data-container","body"),c.className="pull-right glyphicon glyphicon-camera btn btn-default mediaButton",c.innerHTML="Snapshot",c.onclick=function(){rtcMultiConnection.streams[t].takeSnapshot(function(e){for(i in webcallpeers)if(webcallpeers[i].userid==rtcMultiConnection.userid){var t="snapshot"+(new Date).getTime();webcallpeers[i].filearray.push(t);var n=document.createElement("div");n.value=webcallpeers[i].filearray.length,fileShare?(syncSnapshot(e,"imagesnapshot",t),displayList(rtcMultiConnection.uuid,rtcMultiConnection.userid,e,t,"imagesnapshot"),displayFile(rtcMultiConnection.uuid,rtcMultiConnection.userid,e,t,"imagesnapshot")):displayFile(rtcMultiConnection.uuid,rtcMultiConnection.userid,e,t,"imagesnapshot")}})},r.appendChild(c);var s=document.createElement("div");s.id="recordButton",s.setAttribute("title","Record"),s.setAttribute("data-placement","bottom"),s.setAttribute("data-toggle","tooltip"),s.setAttribute("data-container","body"),s.className="pull-right glyphicon glyphicon-facetime-video btn btn-default mediaButton",s.innerHTML=" Record ",s.onclick=function(){" Record "==s.innerHTML?(s.innerHTML=" Stop ",rtcMultiConnection.streams[t].startRecording({audio:!0,video:!0})):" Stop "==s.innerHTML&&(s.innerHTML=" Record ",rtcMultiConnection.streams[t].stopRecording(function(e){for(i in webcallpeers)if(webcallpeers[i].userid==rtcMultiConnection.userid){var t="recordedvideo"+(new Date).getTime();webcallpeers[i].filearray.push(t);var n=document.createElement("div");n.value=webcallpeers[i].filearray.length,fileShare?(syncSnapshot(e,"videoRecording",t),displayList(rtcMultiConnection.uuid,rtcMultiConnection.userid,e,t,"videoRecording"),displayFile(rtcMultiConnection.uuid,rtcMultiConnection.userid,e,t,"videoRecording")):displayFile(rtcMultiConnection.uuid,rtcMultiConnection.userid,e,t,"videoRecording")}},{audio:!0,video:!0}))},r.appendChild(s)}e.parentNode.appendChild(r)}function updateWebCallView(e){if("localVideo"==e.name)localStream=webcallpeers[0].stream,localStreamId=webcallpeers[0].streamid,$("#local").show(),$("#remote").hide(),localVideo&&(attachMediaStream(localVideo,webcallpeers[0].stream),localVideo.muted=!0,localVideo.id=webcallpeers[0].userid,localVideo.style.opacity=1,attachControlButtons(localVideo,webcallpeers[0].streamid,webcallpeers[0].controlBarName,webcallpeers[0].fileSharingContainer));else if("remoteVideo"==e.name){var t=0,n=0;$("#local").hide(),$("#remote").show();for(x in webcallpeers)arrFilesharingBoxes.push(webcallpeers[x].fileSharingSubContents.fileSharingBox);outgoingVideo?(0==remoteVideos[0].played.length&&(reattachMediaStream(remoteVideos[0],localVideo),remoteVideos[0].id=webcallpeers[0].videoContainer,remoteVideos[0].muted=!0,attachControlButtons(remoteVideos[0],webcallpeers[0].streamid,webcallpeers[0].controlBarName,webcallpeers[0].fileSharingContainer),remoteVideos[0].hidden&&(remoteVideos[0].hidden=!1),fileShare&&createFileSharingDiv(0)),console.log("............local..................."),console.log(0,remoteVideos[0]),console.log(0,webcallpeers[0]),console.log(".................................."),n++,t++):t++;for(var i=n;i<remoteVideos.length;i++)console.log("checking "+i+" for length "+remoteVideos[i].played.length),remoteVideos[i].src&&(console.log("............existing.remotes..................."),console.log(n,remoteVideos[n]),console.log(t,webcallpeers[t]),console.log(".................................."),n++,t++);console.log("Empty for new remote stream ",n," || ",t),attachMediaStream(remoteVideos[n],webcallpeers[t].stream),attachControlButtons(remoteVideos[n],webcallpeers[t].streamid,webcallpeers[t].controlBarName,webcallpeers[t].fileSharingContainer),outgoingVideo?waitForRemoteVideo(webcallpeers[t].stream,remoteVideos[n],localVideo,remoteVideos[0]):waitForRemoteVideo(webcallpeers[t].stream,remoteVideos[n],null,null),remoteVideos[n].hidden&&(remoteVideos[n].hidden=!1),fileShare&&createFileSharingDiv(t),console.log("............remotes just added..................."),console.log(n,remoteVideos[n]),console.log(t,webcallpeers[t]),console.log(".................................."),console.log("webcallperrs ",webcallpeers)}}function startcall(){rtcMultiConnection=new RTCMultiConnection(sessionid),rtcMultiConnection.iceServers=iceServers,rtcMultiConnection.channel=sessionid,rtcMultiConnection.preventSSLAutoAllowed=!1,rtcMultiConnection.autoReDialOnFailure=!0,rtcMultiConnection.setDefaultEventsForMediaElement=!1,rtcMultiConnection.customStreams={},rtcMultiConnection.autoCloseEntireSession=!1,rtcMultiConnection.autoTranslateText=!1,rtcMultiConnection.maxParticipantsAllowed=4,rtcMultiConnection.setDefaultEventsForMediaElement=!1,rtcMultiConnection.blobURLs={},rtcMultiConnection.session={video:incomingVideo,audio:incomingAudio,data:incomingData},rtcMultiConnection.sdpConstraints.mandatory={OfferToReceiveAudio:!0,OfferToReceiveVideo:!0},rtcMultiConnection.onstream=function(e){var t=null;"local"==e.type?(console.log("LocalStream ------------",e),t={name:"localVideo",videoContainer:"video"+e.userid,videoHeight:null,videoClassName:null,uuid:e.uuid,userid:e.userid,stream:e.stream,streamid:e.stream.streamid,fileSharingContainer:"widget-filesharing-container"+e.userid,fileSharingSubContents:{fileSharingBox:"widget-filesharing-box"+e.userid,minButton:"widget-filesharing-minbutton"+e.userid,maxButton:"widget-filesharing-maxbutton"+e.userid,closeButton:"widget-filesharing-closebutton"+e.userid},fileListContainer:"widget-filelisting-container"+e.userid,controlBarName:"control-video"+e.userid,filearray:[]}):"remote"==e.type&&(console.log("Remote ------------",e),t={name:"remoteVideo",videoContainer:"video"+e.userid,videoHeight:null,videoClassName:null,uuid:e.uuid,userid:e.userid,stream:e.stream,streamid:e.stream.streamid,fileSharingContainer:"widget-filesharing-container"+e.userid,fileSharingSubContents:{fileSharingBox:"widget-filesharing-box"+e.userid,minButton:"widget-filesharing-minbutton"+e.userid,maxButton:"widget-filesharing-maxbutton"+e.userid,closeButton:"widget-filesharing-closebutton"+e.userid},fileListContainer:"widget-filelisting-container"+e.userid,controlBarName:"control-video"+e.userid,filearray:[]}),webcallpeers.push(t),updateWebCallView(t)},rtcMultiConnection.onstreamended=function(e){e.isScreen?$("#"+e.userid+"_screen").remove():$("#"+e.userid).remove()},rtcMultiConnection.onopen=function(e){console.log(e),console.log(rtcMultiConnection),shownotification(e.extra.username+" joined channel ")},rtcMultiConnection.onmessage=function(e){if(e.data.typing)void(whoIsTyping.innerHTML=e.extra.username+" is typing ...");else if(e.data.stoppedTyping)void(whoIsTyping.innerHTML="");else switch(e.data.type){case"chat":whoIsTyping.innerHTML="",addNewMessage({header:e.extra.username,message:e.data.message,userinfo:getUserinfo(rtcMultiConnection.blobURLs[e.userid],"chat-message.png"),color:e.extra.color}),void(document.title=e.data.message);break;case"imagesnapshot":displayList(null,e.userid,e.data.message,e.data.name,"imagesnapshot"),displayFile(null,e.userid,e.data.message,e.data.name,"imagesnapshot");break;case"videoRecording":displayList(null,e.userid,e.data.message,e.data.name,"videoRecording"),displayFile(null,e.userid,e.data.message,e.data.name,"videoRecording");break;case"videoScreenRecording":displayList(null,e.userid,e.data.message,e.data.name,"videoScreenRecording"),displayFile(null,e.userid,e.data.message,e.data.name,"videoScreenRecording");break;case"file":addNewMessage({header:e.extra.username,message:e.data.message,userinfo:getUserinfo(rtcMultiConnection.blobURLs[e.userid],"chat-message.png"),color:e.extra.color});break;case"canvas":CanvasDesigner.syncData(e.data.draw);break;case"pointer":placeCursor("cursor2",e.data.corX,e.data.corY);break;case"buttonclick":var t=document.getElementById(e.data.buttonName);t.getAttribute("lastClickedBy")!=rtcMultiConnection.userid&&(t.setAttribute("lastClickedBy",e.userid),t.click());break;default:console.log(" unrecognizable message from peer ",e)}},rtcMultiConnection.onNewSession=function(e){sessions[e.sessionid]||(sessions[e.sessionid]=e,e.join())},rtcMultiConnection.onRequest=function(e){rtcMultiConnection.accept(e)},rtcMultiConnection.onCustomMessage=function(e){if(e.hasCamera||e.hasScreen){var t=e.extra.username+" enabled webcam.";e.hasScreen&&(e.session.oneway=!0,rtcMultiConnection.sendMessage({renegotiate:!0,streamid:e.streamid,session:e.session}),t=e.extra.username+" is ready to share screen.")}if(e.hasMic&&(e.session.oneway=!0,rtcMultiConnection.sendMessage({renegotiate:!0,streamid:e.streamid,session:e.session})),e.renegotiate){var n=rtcMultiConnection.customStreams[e.streamid];n&&rtcMultiConnection.peers[e.userid].renegotiate(n,e.session)}},rtcMultiConnection.sendMessage=function(e){e.userid=rtcMultiConnection.userid,e.extra=rtcMultiConnection.extra,rtcMultiConnection.sendCustomMessage(e)},rtcMultiConnection.onclose=rtcMultiConnection.onleave=function(e){addNewMessage({header:e.extra.username,message:e.extra.username+" left session.",userinfo:getUserinfo(rtcMultiConnection.blobURLs[e.userid],"info.png"),color:e.extra.color}),shownotification(e.extra.username+" left the conversation.");for(x in webcallpeers)(webcallpeers[x].userid=e.userid)&&webcallpeers.splice(x,1)},rtcMultiConnection.onFileStart=function(e){addNewFileLocal({userid:rtcMultiConnection.userid,header:"User local",message:"File shared",userinfo:getUserinfo(rtcMultiConnection.blobURLs[rtcMultiConnection.userid],"images/share-files.png"),callback:function(e){}}),addProgressHelper(e.uuid,e.userid,e.name,e.maxChunks,"fileBoxClass")},rtcMultiConnection.onFileProgress=function(e){var t=progressHelper[e.uuid];t&&(t.progress.value=e.currentPosition||e.maxChunks||t.progress.max,updateLabel(t.progress,t.label))},rtcMultiConnection.onFileEnd=function(e){for(i in webcallpeers)if(webcallpeers[i].userid==e.userid){webcallpeers[i].filearray.push(e.name);var t=document.createElement("div");t.value=webcallpeers[i].filearray.length}displayFile(e.uuid,e.userid,e.url,e.name,e.type),displayList(e.uuid,e.userid,e.url,e.name,e.type)},rtcMultiConnection.extra={username:"none",color:"ffffff",useredisplayListmail:n};var e="/";if("/"!=socketAddr&&(e=socketAddr),socket=io.connect(e),socket.emit("presence",{channel:rtcMultiConnection.channel,useremail:n,username:t}),socket.on("presence",function(e){e?joinWebRTC():opneWebRTC()}),rtcMultiConnection.openSignalingChannel=function(t){var n=t.channel||this.channel;socket.emit("namespace",{channel:n,sender:rtcMultiConnection.userid});var i=io.connect(e+n);i.channel=e+n,i.on("connect",function(){t.callback&&t.callback(i)}),i.send=function(e){i.emit("message",{sender:rtcMultiConnection.userid,data:e})},i.on("message",t.onmessage),i.on("disconnect","datalost")},$("#inspectorlink").val(window.location+"?appname=webrtcwebcall&role=inspector&audio=0&video=0"),$("#channelname").val(rtcMultiConnection.channel),$("#userid").val(rtcMultiConnection.userid),$("#inAudio").val(rtcMultiConnection.session.audio),$("#inVideo").val(rtcMultiConnection.session.video),$("#inData").val(rtcMultiConnection.session.data),$("#outAudio").val(rtcMultiConnection.session.audio),$("#outVideo").val(rtcMultiConnection.session.video),$("#outData").val(rtcMultiConnection.session.data),$("#btnGetPeers").click(function(){$("#alllpeerinfo").empty(),$("#allpeerinfo").append("<pre contenteditable>"+JSON.stringify(webcallpeers,null,2)+"<pre>")}),$("#btnDebug").click(function(){$("#allwebrtcdevinfo").empty(),$("#allwebrtcdevinfo").append("<pre contenteditable>"+rtcMultiConnection+"<pre>"),console.info(rtcMultiConnection)}),screenrecord){var o=document.createElement("span");o.className="btn btn-success glyphicon glyphicon-refresh topPanelButton",o.innerHTML="Record",o.onclick=function(){recordScreenVideo(o)};var r=document.createElement("li");r.appendChild(o),document.getElementById("topIconHolder_ul").appendChild(r)}if(screenshare){var a=document.createElement("span");a.className="btn btn-success glyphicon glyphicon-expand topPanelButton",a.innerHTML="Screen Share",a.onclick=function(){a.id="screenShareButton",0==isScreenOn?(screen.share("screenShareVilageExperts"),isScreenOn=1):1==isScreenOn&&(screen.leave(),isScreenOn=0),webrtcdevScreenShare(screen)};var r=document.createElement("li");r.appendChild(a),document.getElementById("topIconHolder_ul").appendChild(r);var l=document.createElement("span");l.className="btn btn-success glyphicon glyphicon-expand topPanelButton",l.innerHTML="Screen View",l.id="viewScreenShareButton",l.onclick=function(){screen.view({roomid:screen_roomid,userid:screen_userid})};var r=document.createElement("li");r.appendChild(l),document.getElementById("topIconHolder_ul").appendChild(r)}if(reconnect){var c=document.createElement("span");c.className="btn btn-success glyphicon glyphicon-refresh topPanelButton",c.innerHTML="Reconnect",c.onclick=function(){var e=confirm("Do you want to reconnet ?");1==e&&location.reload()};var r=document.createElement("li");r.appendChild(c),document.getElementById("topIconHolder_ul").appendChild(r)}if(drawCanvas){var s=document.createElement("span");s.className="btn btn-success glyphicon glyphicon-edit topPanelButton",s.innerHTML="Whiteborad";var r=document.createElement("li");r.appendChild(s),document.getElementById("topIconHolder_ul").appendChild(r)}}function addMessageLineformat(e,t,n){var i=document.createElement("div");i.className=e,i.innerHTML=t,document.getElementById(n).insertBefore(i,document.getElementById(n).firstChild)}function addMessageBlockFormat(e,t,n,i,o){var r=document.createElement("div");r.className=e,r.innerHTML='<div class="chatusername">'+t+"</div>";var a=document.createElement("div");a.className=n,a.innerHTML=i,r.appendChild(a),$("#"+o).append(a)}function addNewMessage(e){""!=e.message&&" "!=e.message&&addMessageLineformat("user-activity user-activity-right remoteMessageClass",e.message,"all-messages")}function addNewMessagelocal(e){""!=e.message&&" "!=e.message&&addMessageLineformat("user-activity user-activity-right localMessageClass",e.message,"all-messages")}function sendChatMessage(){var e=document.getElementById("chatInput").value;addNewMessagelocal({header:rtcMultiConnection.extra.username,message:e,userinfo:getUserinfo(rtcMultiConnection.blobURLs[rtcMultiConnection.userid],"chat-message.png"),color:rtcMultiConnection.extra.color}),rtcMultiConnection.send({type:"chat",message:e}),document.getElementById("chatInput").value=""}function addProgressHelper(e,t,n,o,r){for(i in webcallpeers)if(webcallpeers[i].userid==t){var a=document.createElement("div");a.title=n,a.id=e+n,a.setAttribute("class",r),a.innerHTML="<label>0%</label><progress></progress>",document.getElementById(webcallpeers[i].fileListContainer).appendChild(a),progressHelper[e]={div:a,progress:a.querySelector("progress"),label:a.querySelector("label")},progressHelper[e].progress.max=o}}function addNewFileLocal(e){console.log("add new message ",e),""!=e.message&&" "!=e.message}function addNewFileRemote(e){console.log("add new message ",e),""!=e.message&&" "!=e.message}function updateLabel(e,t){if(-1!=e.position){var n=+e.position.toFixed(2).split(".")[1]||100;t.innerHTML=n+"%"}}function simulateClick(e){return document.getElementById(e).click(),console.log(e),!0}function displayList(e,t,n,o,r){var a=null,l=null,c=null,s=null,d=null;for(i in webcallpeers)webcallpeers[i].userid==t?(a=webcallpeers[i].fileListContainer,s=webcallpeers[i].fileSharingContainer,c=webcallpeers[i].filearray.length):(l=webcallpeers[i].fileListContainer,d=webcallpeers[i].fileSharingContainer);var u=document.createElement("div");u.innerHTML=c+" "+o,u.id="name"+o;var m=document.createElement("div");m.setAttribute("class","btn btn-primary"),m.setAttribute("style","color:white"),"videoScreenRecording"==r?(m.innerHTML="Download",m.onclick=function(){downloadVideoScreenRecording(URL.createObjectURL(n),o+"webm")}):m.innerHTML='<a href="'+n+'" download="'+o+'" style="color:white" > Download </a>';var p=document.createElement("div");p.id="showButton"+o,p.setAttribute("class","btn btn-primary"),p.innerHTML="show",p.onclick=function(){repeatFlagShowButton!=o?(showFile(e,s,n,o,r),rtcMultiConnection.send({type:"shareFileShow",_uuid:e,_element:elementDisplayPeer,_fileurl:n,_filename:o,_filetype:r}),repeatFlagShowButton=o):repeatFlagShowButton==o&&(repeatFlagShowButton="")};var g=document.createElement("div");g.id="hideButton"+o,g.setAttribute("class","btn btn-primary"),g.innerHTML="hide",g.onclick=function(){repeatFlagHideButton!=o?(hideFile(e,s,n,o,r),rtcMultiConnection.send({type:"shareFileHide",_uuid:e,_element:d,_fileurl:n,_filename:o,_filetype:r}),repeatFlagHideButton=o):repeatFlagHideButton==o&&(repeatFlagHideButton="")};var h=document.createElement("div");h.id="removeButton"+o,h.setAttribute("class","btn btn-primary"),h.innerHTML="remove",h.onclick=function(t){if(repeatFlagRemoveButton!=o){hideFile(e,s,n,o,r);var i=t.target.parentNode.id;rtcMultiConnection.send({type:"shareFileRemove",_element:i,_filename:o}),removeFile(i),repeatFlagRemoveButton=o}else repeatFlagRemoveButton==o&&(repeatFlagRemoveButton="")};var f;if(fileShare&&null!=document.getElementById(a))switch(r){case"imagesnapshot":f=document.createElement("div"),f.id=o,document.getElementById(a).appendChild(f);break;case"videoRecording":f=document.createElement("div"),f.id=o,document.getElementById(a).appendChild(f);break;case"videoScreenRecording":f=document.createElement("div"),f.id=o,document.getElementById(a).appendChild(f);break;default:f=progressHelper[e].div}else f=document.createElement("div"),f.id=o,document.body.appendChild(f);f.innerHTML="",f.appendChild(u),f.appendChild(m),f.appendChild(p),f.appendChild(g),f.appendChild(h)}function getFileElementDisplayByType(e,t,n){var i;if(e.indexOf("msword")>-1||e.indexOf("officedocument")>-1){var o=document.createElement("div");o.className="alert alert-warning",o.innerHTML="Microsoft and Libra word file cannt be opened in browser",i=o}else if(e.indexOf("image")>-1){var r=document.createElement("img");r.src=t,r.style.width="100%",r.title=n,r.id="display"+n,i=r}else if(e.indexOf("video")>-1){var a=document.createElement("video");void 0!=t.video?a.src=URL.createObjectURL(t.video):a.src=URL.createObjectURL(t),a.setAttribute("controls","controls"),a.style.width="100%",a.title=n,a.id="display"+n,i=a}else{var l=document.createElement("iframe");l.src=t,l.className="viewerIframeClass",l.title=n,l.id="display"+n,i=l}return i}function displayFile(e,t,n,o,r){alert(" display File "+t);var a=null;for(i in webcallpeers)webcallpeers[i].userid==t&&(a=webcallpeers[i].fileSharingContainer);a?$("#"+a).html(getFileElementDisplayByType(r,n,o)):document.body.appendChild(getFileElementDisplayByType(r,n,o))}function syncButton(e){var t=document.getElementById(e);console.log(t.getAttribute("lastClickedBy"),t.getAttribute("lastClickedBy")!=rtcMultiConnection.userid,""!=t.getAttribute("lastClickedBy"));for(x in webcallpeers)if(t.getAttribute("lastClickedBy")==webcallpeers[x].userid)return void t.setAttribute("lastClickedBy","");""==t.getAttribute("lastClickedBy")&&(t.setAttribute("lastClickedBy",rtcMultiConnection.userid),rtcMultiConnection.send({type:"buttonclick",buttonName:e}),console.log("Synced with peer ",t.getAttribute("lastClickedBy")))}function showFile(e,t,n,i,o){$("#"+t).html(getFileElementDisplayByType(o,n,i))}function hideFile(e,t,n,i,o){$("#"+t).has("#display"+i)?(document.getElementById(t).innerHTML="",console.log("hidefile ",i," from ",t)):console.log(" file is not displayed to hide ")}function removeFile(e){document.getElementById(e).hidden=!0}function closeFV(e,t,n){document.getElementById(n).innerHTML="",syncButton(t)}function resizeFV(e,t,n){for(x in n)document.getElementById(n[x]).hidden=!1,document.getElementById(n[x]).style.width="50%";syncButton(t)}function minFV(e,t,n){for(x in n)document.getElementById(n[x]).hidden=!1,document.getElementById(n[x]).style.width="50%",document.getElementById(n[x]).style.height="10%";syncButton(t)}function maxFV(e,t,n,i){for(x in n)n[x]==i?(document.getElementById(n[x]).hidden=!1,document.getElementById(n[x]).style.width="100%"):(document.getElementById(n[x]).hidden=!0,document.getElementById(n[x]).style.width="0%");syncButton(t)}function webrtcdevCanvasDEsigner(){try{CanvasDesigner.addSyncListener(function(e){rtcMultiConnection.send({type:"canvas",draw:e})}),CanvasDesigner.setSelected("pencil"),CanvasDesigner.setTools({pencil:!0,eraser:!0}),CanvasDesigner.appendTo(document.getElementById("widget-container"))}catch(e){$("#drawButton").hide(),console.log(" Canvas drawing not supported "),console.log(e)}}function placeCursor(e,t,n){var i=document.getElementById(e);i.style.position="absolute",i.style.left=t+"px",i.style.top=n+"px"}function shareCursor(){rtcMultiConnection.send({type:"pointer",corX:cursorX,corY:cursorY}),placeCursor("cursor1",cursorX,cursorY)}function webrtcdevScreenShare(e){try{e=new Screen("screen"+rtcMultiConnection.channel),e.onaddstream=function(n){e.openSignalingChannel=function(e){var n=io.connect("/"+rtcMultiConnection.channel);return n.channel=t,n.on("message",e)}},e.check(),e.onuserleft=function(e){document.getElementById("screenshare").hidden=!0},e.onscreen=function(e){console.log(" onscreen ",e),self.detectedRoom||(self.detectedRoom=!0,self.view(e))}}catch(n){console.log("------------screenshare not supported "),$("#screenShareButton").hide(),$("#viewScreenShareButton").hide(),console.log(n)}}function syncVideoScreenRecording(e,t,n){rtcMultiConnection.send({type:t,message:e,name:n})}function recordScreenVideo(e){"Record"==e.innerHTML?(e.innerHTML="Stop Recording",playVideo(function(){recorder.record()})):"Stop Recording"==e.innerHTML&&(e.innerHTML="Record",recorder.stop(function(e){for(i in webcallpeers)if(webcallpeers[i].userid==rtcMultiConnection.userid){var t="recordedScreenvideo"+(new Date).getTime();webcallpeers[i].filearray.push(t);var n=document.createElement("div");n.value=webcallpeers[i].filearray.length,syncVideoScreenRecording(e,"videoScreenRecording",t),displayList(rtcMultiConnection.uuid,rtcMultiConnection.userid,e,t,"videoScreenRecording"),displayFile(rtcMultiConnection.uuid,rtcMultiConnection.userid,e,t,"videoScreenRecording")}}))}function playVideo(e){function t(t){videoElement.onloadedmetadata=function(){e()},videoElement.srcObject=t,videoElement.play()}function n(t){console.error("get-user-media error",t),e()}var i={video:!0};navigator.webkitGetUserMedia.bind(navigator);navigator.mediaDevices.getUserMedia1(i).then(t)["catch"](n)}function getAllPeerInfo(){console.log(webcallpeers)}var WebRTCdom=function(e,t){var n=e.localVideo,i=(e.videoClass,e.userDisplay,e.userMetaDisplay,t.remotearr);t.videoClass,t.userDisplay,t.userMetaDisplay;if(null!=n){localVideo=document.getElementsByName(n)[0];for(var o=0;o<i.length;o++)remoteVideos.push(document.getElementsByName(i[o])[0])}else for(var o=0;o<i.length;o++)remoteVideos.push(document.getElementsByName(i[o])[0]);console.log(remoteVideos)},WebRTCdev=function(e,t,n,i){sessionid=e.sessionid,socketAddr=e.socketAddr,incomingAudio=t.audio,incomingVideo=t.video,incomingData=t.data,outgoingAudio=n.audio,outgoingVideo=n.video,outgoingData=n.data,chat=i.chat.active,fileShare=i.fileShare,screenrecord=i.screenrecord,screenshare=i.screenshare,videoRecord=i.videoRecord,drawCanvas=i.drawCanvas,reconnect=i.reconnect},islocalStream=1,arrFilesharingBoxes=[],localStream,localStreamId,remoteStream,remoteStreamId,RTCPeerConnection=null,getUserMedia=null,attachMediaStream=null,reattachMediaStream=null,webrtcDetectedBrowser=null,webrtcDetectedVersion=null,rtcMultiConnection;navigator.mozGetUserMedia?(console.log("This appears to be Firefox"),webrtcDetectedBrowser="firefox",webrtcDetectedVersion=parseInt(navigator.userAgent.match(/Firefox\/([0-9]+)\./)[1]),RTCPeerConnection=mozRTCPeerConnection,RTCSessionDescription=mozRTCSessionDescription,RTCIceCandidate=mozRTCIceCandidate,getUserMedia=navigator.mozGetUserMedia.bind(navigator),attachMediaStream=function(e,t){console.log("Attaching media stream"),e.mozSrcObject=t,e.play()},reattachMediaStream=function(e,t){console.log("Reattaching media stream"),e.mozSrcObject=t.mozSrcObject,e.play()},MediaStream.prototype.getVideoTracks=function(){return[]},MediaStream.prototype.getAudioTracks=function(){return[]}):navigator.webkitGetUserMedia?(console.log("This appears to be Chrome"),webrtcDetectedBrowser="chrome",webrtcDetectedVersion=parseInt(navigator.userAgent.match(/Chrom(e|ium)\/([0-9]+)\./)[2]),RTCPeerConnection=webkitRTCPeerConnection,outgoingVideo&&(getUserMedia=navigator.webkitGetUserMedia.bind(navigator)),attachMediaStream=function(e,t){"undefined"!=typeof e.srcObject?e.srcObject=t:"undefined"!=typeof e.mozSrcObject?e.mozSrcObject=t:"undefined"!=typeof e.src?e.src=URL.createObjectURL(t):console.log("Error attaching stream to element.")},reattachMediaStream=function(e,t){e.src=t.src},webkitMediaStream.prototype.getVideoTracks||(webkitMediaStream.prototype.getVideoTracks=function(){return this.videoTracks},webkitMediaStream.prototype.getAudioTracks=function(){return this.audioTracks}),webkitRTCPeerConnection.prototype.getLocalStreams||(webkitRTCPeerConnection.prototype.getLocalStreams=function(){return this.localStreams},webkitRTCPeerConnection.prototype.getRemoteStreams=function(){return this.remoteStreams})):console.log("Browser does not appear to be WebRTC-capable"),opneWebRTC=function(){shownotification("Making a new session "),rtcMultiConnection.open(),socket.emit("new-channel",{channel:rtcMultiConnection.channel,
sender:rtcMultiConnection.userid})},joinWebRTC=function(){shownotification("Joing an existing session "),rtcMultiConnection.join({audio:outgoingVideo,video:outgoingVideo}),socket.emit("join-channel",{channel:rtcMultiConnection.channel,sender:rtcMultiConnection.userid})};var iceServers=[];iceServers.push({url:"stun:stun.l.google.com:19302"}),iceServers.push({url:"stun:stun.anyfirewall.com:3478"}),iceServers.push({url:"turn:turn.bistri.com:80",credential:"homeo",username:"homeo"}),iceServers.push({url:"turn:turn.anyfirewall.com:443?transport=tcp",credential:"webrtc",username:"webrtc"}),$("#chatInput").keypress(function(e){13==e.keyCode&&sendChatMessage()}),$("#send").click(function(){return sendChatMessage(),!1}),$("#chatbox").css("max-height",$("#leftVideo").height()+80),$("#chatBoard").css("max-height",$("#leftVideo").height()),$("#chatBoard").css("overflow-y","scroll");var progressHelper={};$("#file").change(function(){var e=this.files[0];rtcMultiConnection.send(e)});var cursorX,cursorY,screen,isScreenOn=0,screen_roomid,screen_userid,downloadVideoScreenRecording=function(e,t){var n=document.createElement("a");return document.body.appendChild(n),n.style="display: none",function(i,o){var r=JSON.stringify(e),a=new Blob([r],{type:"octet/stream"}),l=window.URL.createObjectURL(a);n.href=l,n.download=t,n.click(),window.URL.revokeObjectURL(l)}}();try{var elementToShare=document.getElementById("elementToShare"),recorder=new CanvasRecorder(elementToShare,{disableLogs:!1}),videoElement=document.querySelector("video")}catch(e){console.error(" Canvas recorder is not defined ")}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment