From 437eb76bfc631d748881f1bb06d07ac2af79e0d7 Mon Sep 17 00:00:00 2001 From: Thomas Shafer Date: Fri, 13 Feb 2015 13:04:49 -0800 Subject: [PATCH] version bump --- build/compiled-dev.js | 2 +- build/compiled-prod.js | 2 +- package.json | 2 +- src/main.coffee | 2 +- test/main_test.coffee | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/build/compiled-dev.js b/build/compiled-dev.js index edfd096..90c6dd2 100644 --- a/build/compiled-dev.js +++ b/build/compiled-dev.js @@ -5379,7 +5379,7 @@ userOrDefault = function(userOptions, key) { }; CineIOPeer = { - version: "0.0.5", + version: "0.0.6", reset: function() { return CineIOPeer.config = { rooms: [], diff --git a/build/compiled-prod.js b/build/compiled-prod.js index 7fc7280..091d97c 100644 --- a/build/compiled-prod.js +++ b/build/compiled-prod.js @@ -1,5 +1,5 @@ !function a(b,c,d){function e(g,h){if(!c[g]){if(!b[g]){var i="function"==typeof require&&require;if(!h&&i)return i(g,!0);if(f)return f(g,!0);var j=new Error("Cannot find module '"+g+"'");throw j.code="MODULE_NOT_FOUND",j}var k=c[g]={exports:{}};b[g][0].call(k.exports,function(a){var c=b[g][1][a];return e(c?c:a)},k,k.exports,a,b,c,d)}return c[g].exports}for(var f="function"==typeof require&&require,g=0;gd;d++)if(b.call(c,a[d],d,a)===f)return}else for(var h in a)if(this.has(a,h)&&b.call(c,a[h],h,a)===f)return},once:function(a){var b,c=!1;return function(){return c?b:(c=!0,b=a.apply(this,arguments),a=null,b)}}}}var d,e=this,f={},g=Array.prototype.forEach,h=Object.prototype.hasOwnProperty,i=Array.prototype.slice,j=0,k=a();d={on:function(a,b,c){if(!m(this,"on",a,[b,c])||!b)return this;this._events||(this._events={});var d=this._events[a]||(this._events[a]=[]);return d.push({callback:b,context:c,ctx:c||this}),this},once:function(a,b,c){if(!m(this,"once",a,[b,c])||!b)return this;var d=this,e=k.once(function(){d.off(a,e),b.apply(this,arguments)});return e._callback=b,this.on(a,e,c)},off:function(a,b,c){var d,e,f,g,h,i,j,l;if(!this._events||!m(this,"off",a,[b,c]))return this;if(!a&&!b&&!c)return this._events={},this;for(g=a?[a]:k.keys(this._events),h=0,i=g.length;i>h;h++)if(a=g[h],f=this._events[a]){if(this._events[a]=d=[],b||c)for(j=0,l=f.length;l>j;j++)e=f[j],(b&&b!==e.callback&&b!==e.callback._callback||c&&c!==e.context)&&d.push(e);d.length||delete this._events[a]}return this},trigger:function(a){if(!this._events)return this;var b=i.call(arguments,1);if(!m(this,"trigger",a,b))return this;var c=this._events[a],d=this._events.all;return c&&n(c,b),d&&n(d,arguments),this},stopListening:function(a,b,c){var d=this._listeners;if(!d)return this;var e=!b&&!c;"object"==typeof b&&(c=this),a&&((d={})[a._listenerId]=a);for(var f in d)d[f].off(b,c,this),e&&delete this._listeners[f];return this}};var l=/\s+/,m=function(a,b,c,d){if(!c)return!0;if("object"==typeof c){for(var e in c)a[b].apply(a,[e,c[e]].concat(d));return!1}if(l.test(c)){for(var f=c.split(l),g=0,h=f.length;h>g;g++)a[b].apply(a,[f[g]].concat(d));return!1}return!0},n=function(a,b){var c,d=-1,e=a.length,f=b[0],g=b[1],h=b[2];switch(b.length){case 0:for(;++d0)){var c=d.shift();c()}},!0),function(a){d.push(a),window.postMessage("process-tick","*")}):function(a){setTimeout(a,0)}}(),d.title="browser",d.browser=!0,d.env={},d.argv=[],d.on=c,d.addListener=c,d.once=c,d.off=c,d.removeListener=c,d.removeAllListeners=c,d.emit=c,d.binding=function(){throw new Error("process.binding is not supported")},d.cwd=function(){return"/"},d.chdir=function(){throw new Error("process.chdir is not supported")}},{}],7:[function(a,b){b.exports=function(a){return a&&"object"==typeof a&&"function"==typeof a.copy&&"function"==typeof a.fill&&"function"==typeof a.readUInt8}},{}],8:[function(a,b,c){(function(b,d){function e(a,b){var d={seen:[],stylize:g};return arguments.length>=3&&(d.depth=arguments[2]),arguments.length>=4&&(d.colors=arguments[3]),p(b)?d.showHidden=b:b&&c._extend(d,b),v(d.showHidden)&&(d.showHidden=!1),v(d.depth)&&(d.depth=2),v(d.colors)&&(d.colors=!1),v(d.customInspect)&&(d.customInspect=!0),d.colors&&(d.stylize=f),i(d,a,d.depth)}function f(a,b){var c=e.styles[b];return c?"["+e.colors[c][0]+"m"+a+"["+e.colors[c][1]+"m":a}function g(a){return a}function h(a){var b={};return a.forEach(function(a){b[a]=!0}),b}function i(a,b,d){if(a.customInspect&&b&&A(b.inspect)&&b.inspect!==c.inspect&&(!b.constructor||b.constructor.prototype!==b)){var e=b.inspect(d,a);return t(e)||(e=i(a,e,d)),e}var f=j(a,b);if(f)return f;var g=Object.keys(b),p=h(g);if(a.showHidden&&(g=Object.getOwnPropertyNames(b)),z(b)&&(g.indexOf("message")>=0||g.indexOf("description")>=0))return k(b);if(0===g.length){if(A(b)){var q=b.name?": "+b.name:"";return a.stylize("[Function"+q+"]","special")}if(w(b))return a.stylize(RegExp.prototype.toString.call(b),"regexp");if(y(b))return a.stylize(Date.prototype.toString.call(b),"date");if(z(b))return k(b)}var r="",s=!1,u=["{","}"];if(o(b)&&(s=!0,u=["[","]"]),A(b)){var v=b.name?": "+b.name:"";r=" [Function"+v+"]"}if(w(b)&&(r=" "+RegExp.prototype.toString.call(b)),y(b)&&(r=" "+Date.prototype.toUTCString.call(b)),z(b)&&(r=" "+k(b)),0===g.length&&(!s||0==b.length))return u[0]+r+u[1];if(0>d)return w(b)?a.stylize(RegExp.prototype.toString.call(b),"regexp"):a.stylize("[Object]","special");a.seen.push(b);var x;return x=s?l(a,b,d,p,g):g.map(function(c){return m(a,b,d,p,c,s)}),a.seen.pop(),n(x,r,u)}function j(a,b){if(v(b))return a.stylize("undefined","undefined");if(t(b)){var c="'"+JSON.stringify(b).replace(/^"|"$/g,"").replace(/'/g,"\\'").replace(/\\"/g,'"')+"'";return a.stylize(c,"string")}return s(b)?a.stylize(""+b,"number"):p(b)?a.stylize(""+b,"boolean"):q(b)?a.stylize("null","null"):void 0}function k(a){return"["+Error.prototype.toString.call(a)+"]"}function l(a,b,c,d,e){for(var f=[],g=0,h=b.length;h>g;++g)f.push(F(b,String(g))?m(a,b,c,d,String(g),!0):"");return e.forEach(function(e){e.match(/^\d+$/)||f.push(m(a,b,c,d,e,!0))}),f}function m(a,b,c,d,e,f){var g,h,j;if(j=Object.getOwnPropertyDescriptor(b,e)||{value:b[e]},j.get?h=j.set?a.stylize("[Getter/Setter]","special"):a.stylize("[Getter]","special"):j.set&&(h=a.stylize("[Setter]","special")),F(d,e)||(g="["+e+"]"),h||(a.seen.indexOf(j.value)<0?(h=q(c)?i(a,j.value,null):i(a,j.value,c-1),h.indexOf("\n")>-1&&(h=f?h.split("\n").map(function(a){return" "+a}).join("\n").substr(2):"\n"+h.split("\n").map(function(a){return" "+a}).join("\n"))):h=a.stylize("[Circular]","special")),v(g)){if(f&&e.match(/^\d+$/))return h;g=JSON.stringify(""+e),g.match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)?(g=g.substr(1,g.length-2),g=a.stylize(g,"name")):(g=g.replace(/'/g,"\\'").replace(/\\"/g,'"').replace(/(^"|"$)/g,"'"),g=a.stylize(g,"string"))}return g+": "+h}function n(a,b,c){var d=0,e=a.reduce(function(a,b){return d++,b.indexOf("\n")>=0&&d++,a+b.replace(/\u001b\[\d\d?m/g,"").length+1},0);return e>60?c[0]+(""===b?"":b+"\n ")+" "+a.join(",\n ")+" "+c[1]:c[0]+b+" "+a.join(", ")+" "+c[1]}function o(a){return Array.isArray(a)}function p(a){return"boolean"==typeof a}function q(a){return null===a}function r(a){return null==a}function s(a){return"number"==typeof a}function t(a){return"string"==typeof a}function u(a){return"symbol"==typeof a}function v(a){return void 0===a}function w(a){return x(a)&&"[object RegExp]"===C(a)}function x(a){return"object"==typeof a&&null!==a}function y(a){return x(a)&&"[object Date]"===C(a)}function z(a){return x(a)&&("[object Error]"===C(a)||a instanceof Error)}function A(a){return"function"==typeof a}function B(a){return null===a||"boolean"==typeof a||"number"==typeof a||"string"==typeof a||"symbol"==typeof a||"undefined"==typeof a}function C(a){return Object.prototype.toString.call(a)}function D(a){return 10>a?"0"+a.toString(10):a.toString(10)}function E(){var a=new Date,b=[D(a.getHours()),D(a.getMinutes()),D(a.getSeconds())].join(":");return[a.getDate(),J[a.getMonth()],b].join(" ")}function F(a,b){return Object.prototype.hasOwnProperty.call(a,b)}var G=/%[sdj%]/g;c.format=function(a){if(!t(a)){for(var b=[],c=0;c=f)return a;switch(a){case"%s":return String(d[c++]);case"%d":return Number(d[c++]);case"%j":try{return JSON.stringify(d[c++])}catch(b){return"[Circular]"}default:return a}}),h=d[c];f>c;h=d[++c])g+=q(h)||!x(h)?" "+h:" "+e(h);return g},c.deprecate=function(a,e){function f(){if(!g){if(b.throwDeprecation)throw new Error(e);b.traceDeprecation?console.trace(e):console.error(e),g=!0}return a.apply(this,arguments)}if(v(d.process))return function(){return c.deprecate(a,e).apply(this,arguments)};if(b.noDeprecation===!0)return a;var g=!1;return f};var H,I={};c.debuglog=function(a){if(v(H)&&(H=b.env.NODE_DEBUG||""),a=a.toUpperCase(),!I[a])if(new RegExp("\\b"+a+"\\b","i").test(H)){var d=b.pid;I[a]=function(){var b=c.format.apply(c,arguments);console.error("%s %d: %s",a,d,b)}}else I[a]=function(){};return I[a]},c.inspect=e,e.colors={bold:[1,22],italic:[3,23],underline:[4,24],inverse:[7,27],white:[37,39],grey:[90,39],black:[30,39],blue:[34,39],cyan:[36,39],green:[32,39],magenta:[35,39],red:[31,39],yellow:[33,39]},e.styles={special:"cyan",number:"yellow","boolean":"yellow",undefined:"grey","null":"bold",string:"green",date:"magenta",regexp:"red"},c.isArray=o,c.isBoolean=p,c.isNull=q,c.isNullOrUndefined=r,c.isNumber=s,c.isString=t,c.isSymbol=u,c.isUndefined=v,c.isRegExp=w,c.isObject=x,c.isDate=y,c.isError=z,c.isFunction=A,c.isPrimitive=B,c.isBuffer=a("./support/isBuffer");var J=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];c.log=function(){console.log("%s - %s",E(),c.format.apply(c,arguments))},c.inherits=a("inherits"),c._extend=function(a,b){if(!b||!x(b))return a;for(var c=Object.keys(b),d=c.length;d--;)a[c[d]]=b[c[d]];return a}}).call(this,a("_process"),"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"./support/isBuffer":7,_process:6,inherits:5}],9:[function(a,b){function c(){}function d(a,b,d){function g(){i.parentNode&&i.parentNode.removeChild(i),window[p]=c,j&&clearTimeout(j)}function h(){window[p]&&g()}"function"==typeof b&&(d=b,b={}),b||(b={});var i,j,k=b.prefix||"__jp",l=b.param||"callback",m=null!=b.timeout?b.timeout:6e4,n=encodeURIComponent,o=document.getElementsByTagName("script")[0]||document.head,p=k+f++;return m&&(j=setTimeout(function(){g(),d&&d(new Error("Timeout"))},m)),window[p]=function(a){e("jsonp got",a),g(),d&&d(null,a)},a+=(~a.indexOf("?")?"&":"?")+l+"="+n(p),a=a.replace("?&","?"),e('jsonp req "%s"',a),i=document.createElement("script"),i.src=a,o.parentNode.insertBefore(i,o),h}var e=a("debug")("jsonp");b.exports=d;var f=0},{debug:10}],10:[function(a,b,c){function d(){return"WebkitAppearance"in document.documentElement.style||window.console&&(console.firebug||console.exception&&console.table)||navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/)&&parseInt(RegExp.$1,10)>=31}function e(){var a=arguments,b=this.useColors;if(a[0]=(b?"%c":"")+this.namespace+(b?" %c":" ")+a[0]+(b?"%c ":" ")+"+"+c.humanize(this.diff),!b)return a;var d="color: "+this.color;a=[a[0],d,"color: inherit"].concat(Array.prototype.slice.call(a,1));var e=0,f=0;return a[0].replace(/%[a-z%]/g,function(a){"%%"!==a&&(e++,"%c"===a&&(f=e))}),a.splice(f,0,d),a}function f(){return"object"==typeof console&&console.log&&Function.prototype.apply.call(console.log,console,arguments)}function g(a){try{null==a?i.removeItem("debug"):i.debug=a}catch(b){}}function h(){var a;try{a=i.debug}catch(b){}return a}c=b.exports=a("./debug"),c.log=f,c.formatArgs=e,c.save=g,c.load=h,c.useColors=d;var i;i="undefined"!=typeof chrome&&"undefined"!=typeof chrome.storage?chrome.storage.local:window.localStorage,c.colors=["lightseagreen","forestgreen","goldenrod","dodgerblue","darkorchid","crimson"],c.formatters.j=function(a){return JSON.stringify(a)},c.enable(h())},{"./debug":11}],11:[function(a,b,c){function d(){return c.colors[k++%c.colors.length]}function e(a){function b(){}function e(){var a=e,b=+new Date,f=b-(j||b);a.diff=f,a.prev=j,a.curr=b,j=b,null==a.useColors&&(a.useColors=c.useColors()),null==a.color&&a.useColors&&(a.color=d());var g=Array.prototype.slice.call(arguments);g[0]=c.coerce(g[0]),"string"!=typeof g[0]&&(g=["%o"].concat(g));var h=0;g[0]=g[0].replace(/%([a-z%])/g,function(b,d){if("%%"===b)return b;h++;var e=c.formatters[d];if("function"==typeof e){var f=g[h];b=e.call(a,f),g.splice(h,1),h--}return b}),"function"==typeof c.formatArgs&&(g=c.formatArgs.apply(a,g));var i=e.log||c.log||console.log.bind(console);i.apply(a,g)}b.enabled=!1,e.enabled=!0;var f=c.enabled(a)?e:b;return f.namespace=a,f}function f(a){c.save(a);for(var b=(a||"").split(/[\s,]+/),d=b.length,e=0;d>e;e++)b[e]&&(a=b[e].replace(/\*/g,".*?"),"-"===a[0]?c.skips.push(new RegExp("^"+a.substr(1)+"$")):c.names.push(new RegExp("^"+a+"$")))}function g(){c.enable("")}function h(a){var b,d;for(b=0,d=c.skips.length;d>b;b++)if(c.skips[b].test(a))return!1;for(b=0,d=c.names.length;d>b;b++)if(c.names[b].test(a))return!0;return!1}function i(a){return a instanceof Error?a.stack||a.message:a}c=b.exports=e,c.coerce=i,c.disable=g,c.enable=f,c.enabled=h,c.humanize=a("ms"),c.names=[],c.skips=[],c.formatters={};var j,k=0},{ms:12}],12:[function(a,b){function c(a){var b=/^((?:\d+)?\.?\d+) *(ms|seconds?|s|minutes?|m|hours?|h|days?|d|years?|y)?$/i.exec(a);if(b){var c=parseFloat(b[1]),d=(b[2]||"ms").toLowerCase();switch(d){case"years":case"year":case"y":return c*k;case"days":case"day":case"d":return c*j;case"hours":case"hour":case"h":return c*i;case"minutes":case"minute":case"m":return c*h;case"seconds":case"second":case"s":return c*g;case"ms":return c}}}function d(a){return a>=j?Math.round(a/j)+"d":a>=i?Math.round(a/i)+"h":a>=h?Math.round(a/h)+"m":a>=g?Math.round(a/g)+"s":a+"ms"}function e(a){return f(a,j,"day")||f(a,i,"hour")||f(a,h,"minute")||f(a,g,"second")||a+" ms"}function f(a,b,c){return b>a?void 0:1.5*b>a?Math.floor(a/b)+" "+c:Math.ceil(a/b)+" "+c+"s"}var g=1e3,h=60*g,i=60*h,j=24*i,k=365.25*j;b.exports=function(a,b){return b=b||{},"string"==typeof a?c(a):b.long?e(a):d(a)}},{}],13:[function(a,b,c){var d=a("./lib/tosdp"),e=a("./lib/tojson");c.toSessionSDP=d.toSessionSDP,c.toMediaSDP=d.toMediaSDP,c.toCandidateSDP=d.toCandidateSDP,c.toSessionJSON=e.toSessionJSON,c.toMediaJSON=e.toMediaJSON,c.toCandidateJSON=e.toCandidateJSON},{"./lib/tojson":15,"./lib/tosdp":16}],14:[function(a,b,c){c.lines=function(a){return a.split("\r\n").filter(function(a){return a.length>0})},c.findLine=function(a,b,c){for(var d=a.length,e=0;e=0?(c.id=d.substr(0,e),c.senders=d.substr(e+1)):(c.id=d,c.senders="sendrecv"),c.uri=b.shift()||"",c},c.rtcpfb=function(a){var b=a.substr(10).split(" "),c={};return c.id=b.shift(),c.type=b.shift(),"trr-int"===c.type?c.value=b.shift():c.subtype=b.shift()||"",c.parameters=b,c},c.candidate=function(a){var b;b=0===a.indexOf("a=candidate:")?a.substring(12).split(" "):a.substring(10).split(" ");for(var c={foundation:b[0],component:b[1],protocol:b[2].toLowerCase(),priority:b[3],ip:b[4],port:b[5],type:b[7],generation:"0"},d=8;d0||h.length>0?"RTP/SAVPF":"RTP/AVPF"),g.forEach(function(a){i.push(a.id)})),b.push("m="+i.join(" ")),b.push("c=IN IP4 0.0.0.0"),e.bandwidth&&e.bandwidth.type&&e.bandwidth.bandwidth&&b.push("b="+e.bandwidth.type+":"+e.bandwidth.bandwidth),"rtp"==e.descType&&b.push("a=rtcp:1 IN IP4 0.0.0.0"),f){f.ufrag&&b.push("a=ice-ufrag:"+f.ufrag),f.pwd&&b.push("a=ice-pwd:"+f.pwd);var j=!1;h.forEach(function(a){b.push("a=fingerprint:"+a.hash+" "+a.value),a.setup&&!j&&b.push("a=setup:"+a.setup)}),f.sctp&&f.sctp.forEach(function(a){b.push("a=sctpmap:"+a.number+" "+a.protocol+" "+a.streams)})}"rtp"==e.descType&&b.push("a="+(d[a.senders]||"sendrecv")),b.push("a=mid:"+a.name),e.mux&&b.push("a=rtcp-mux");var k=e.encryption||[];k.forEach(function(a){b.push("a=crypto:"+a.tag+" "+a.cipherSuite+" "+a.keyParams+(a.sessionParams?" "+a.sessionParams:""))}),e.googConferenceFlag&&b.push("a=x-google-flag:conference"),g.forEach(function(a){var c="a=rtpmap:"+a.id+" "+a.name+"/"+a.clockrate;if(a.channels&&"1"!=a.channels&&(c+="/"+a.channels),b.push(c),a.parameters&&a.parameters.length){var d=["a=fmtp:"+a.id],e=[];a.parameters.forEach(function(a){e.push((a.key?a.key+"=":"")+a.value)}),d.push(e.join(";")),b.push(d.join(" "))}a.feedback&&a.feedback.forEach(function(c){b.push("trr-int"===c.type?"a=rtcp-fb:"+a.id+" trr-int "+c.value?c.value:"0":"a=rtcp-fb:"+a.id+" "+c.type+(c.subtype?" "+c.subtype:""))})}),e.feedback&&e.feedback.forEach(function(a){b.push("trr-int"===a.type?a.value:"a=rtcp-fb:* "+a.type+(a.subtype?" "+a.subtype:""))});var l=e.headerExtensions||[];l.forEach(function(a){b.push("a=extmap:"+a.id+(a.senders?"/"+d[a.senders]:"")+" "+a.uri)});var m=e.sourceGroups||[];m.forEach(function(a){b.push("a=ssrc-group:"+a.semantics+" "+a.sources.join(" "))});var n=e.sources||[];n.forEach(function(a){for(var c=0;cd;d++)b(a[d],d,a);else{var f=p.keys(a);for(d=0,e=f.length;e>d;d++)b(a[f[d]],f[d],a)}return a},p.map=p.collect=function(a,b,c){if(null==a)return[];b=p.iteratee(b,c);for(var d,e=a.length!==+a.length&&p.keys(a),f=(e||a).length,g=Array(f),h=0;f>h;h++)d=e?e[h]:h,g[h]=b(a[d],d,a);return g};var r="Reduce of empty array with no initial value";p.reduce=p.foldl=p.inject=function(a,b,c,d){null==a&&(a=[]),b=q(b,d,4);var e,f=a.length!==+a.length&&p.keys(a),g=(f||a).length,h=0;if(arguments.length<3){if(!g)throw new TypeError(r);c=a[f?f[h++]:h++]}for(;g>h;h++)e=f?f[h]:h,c=b(c,a[e],e,a);return c},p.reduceRight=p.foldr=function(a,b,c,d){null==a&&(a=[]),b=q(b,d,4);var e,f=a.length!==+a.length&&p.keys(a),g=(f||a).length;if(arguments.length<3){if(!g)throw new TypeError(r); c=a[f?f[--g]:--g]}for(;g--;)e=f?f[g]:g,c=b(c,a[e],e,a);return c},p.find=p.detect=function(a,b,c){var d;return b=p.iteratee(b,c),p.some(a,function(a,c,e){return b(a,c,e)?(d=a,!0):void 0}),d},p.filter=p.select=function(a,b,c){var d=[];return null==a?d:(b=p.iteratee(b,c),p.each(a,function(a,c,e){b(a,c,e)&&d.push(a)}),d)},p.reject=function(a,b,c){return p.filter(a,p.negate(p.iteratee(b)),c)},p.every=p.all=function(a,b,c){if(null==a)return!0;b=p.iteratee(b,c);var d,e,f=a.length!==+a.length&&p.keys(a),g=(f||a).length;for(d=0;g>d;d++)if(e=f?f[d]:d,!b(a[e],e,a))return!1;return!0},p.some=p.any=function(a,b,c){if(null==a)return!1;b=p.iteratee(b,c);var d,e,f=a.length!==+a.length&&p.keys(a),g=(f||a).length;for(d=0;g>d;d++)if(e=f?f[d]:d,b(a[e],e,a))return!0;return!1},p.contains=p.include=function(a,b){return null==a?!1:(a.length!==+a.length&&(a=p.values(a)),p.indexOf(a,b)>=0)},p.invoke=function(a,b){var c=i.call(arguments,2),d=p.isFunction(b);return p.map(a,function(a){return(d?b:a[b]).apply(a,c)})},p.pluck=function(a,b){return p.map(a,p.property(b))},p.where=function(a,b){return p.filter(a,p.matches(b))},p.findWhere=function(a,b){return p.find(a,p.matches(b))},p.max=function(a,b,c){var d,e,f=-1/0,g=-1/0;if(null==b&&null!=a){a=a.length===+a.length?a:p.values(a);for(var h=0,i=a.length;i>h;h++)d=a[h],d>f&&(f=d)}else b=p.iteratee(b,c),p.each(a,function(a,c,d){e=b(a,c,d),(e>g||e===-1/0&&f===-1/0)&&(f=a,g=e)});return f},p.min=function(a,b,c){var d,e,f=1/0,g=1/0;if(null==b&&null!=a){a=a.length===+a.length?a:p.values(a);for(var h=0,i=a.length;i>h;h++)d=a[h],f>d&&(f=d)}else b=p.iteratee(b,c),p.each(a,function(a,c,d){e=b(a,c,d),(g>e||1/0===e&&1/0===f)&&(f=a,g=e)});return f},p.shuffle=function(a){for(var b,c=a&&a.length===+a.length?a:p.values(a),d=c.length,e=Array(d),f=0;d>f;f++)b=p.random(0,f),b!==f&&(e[f]=e[b]),e[b]=c[f];return e},p.sample=function(a,b,c){return null==b||c?(a.length!==+a.length&&(a=p.values(a)),a[p.random(a.length-1)]):p.shuffle(a).slice(0,Math.max(0,b))},p.sortBy=function(a,b,c){return b=p.iteratee(b,c),p.pluck(p.map(a,function(a,c,d){return{value:a,index:c,criteria:b(a,c,d)}}).sort(function(a,b){var c=a.criteria,d=b.criteria;if(c!==d){if(c>d||void 0===c)return 1;if(d>c||void 0===d)return-1}return a.index-b.index}),"value")};var s=function(a){return function(b,c,d){var e={};return c=p.iteratee(c,d),p.each(b,function(d,f){var g=c(d,f,b);a(e,d,g)}),e}};p.groupBy=s(function(a,b,c){p.has(a,c)?a[c].push(b):a[c]=[b]}),p.indexBy=s(function(a,b,c){a[c]=b}),p.countBy=s(function(a,b,c){p.has(a,c)?a[c]++:a[c]=1}),p.sortedIndex=function(a,b,c,d){c=p.iteratee(c,d,1);for(var e=c(b),f=0,g=a.length;g>f;){var h=f+g>>>1;c(a[h])b?[]:i.call(a,0,b)},p.initial=function(a,b,c){return i.call(a,0,Math.max(0,a.length-(null==b||c?1:b)))},p.last=function(a,b,c){return null==a?void 0:null==b||c?a[a.length-1]:i.call(a,Math.max(a.length-b,0))},p.rest=p.tail=p.drop=function(a,b,c){return i.call(a,null==b||c?1:b)},p.compact=function(a){return p.filter(a,p.identity)};var t=function(a,b,c,d){if(b&&p.every(a,p.isArray))return j.apply(d,a);for(var e=0,f=a.length;f>e;e++){var g=a[e];p.isArray(g)||p.isArguments(g)?b?h.apply(d,g):t(g,b,c,d):c||d.push(g)}return d};p.flatten=function(a,b){return t(a,b,!1,[])},p.without=function(a){return p.difference(a,i.call(arguments,1))},p.uniq=p.unique=function(a,b,c,d){if(null==a)return[];p.isBoolean(b)||(d=c,c=b,b=!1),null!=c&&(c=p.iteratee(c,d));for(var e=[],f=[],g=0,h=a.length;h>g;g++){var i=a[g];if(b)g&&f===i||e.push(i),f=i;else if(c){var j=c(i,g,a);p.indexOf(f,j)<0&&(f.push(j),e.push(i))}else p.indexOf(e,i)<0&&e.push(i)}return e},p.union=function(){return p.uniq(t(arguments,!0,!0,[]))},p.intersection=function(a){if(null==a)return[];for(var b=[],c=arguments.length,d=0,e=a.length;e>d;d++){var f=a[d];if(!p.contains(b,f)){for(var g=1;c>g&&p.contains(arguments[g],f);g++);g===c&&b.push(f)}}return b},p.difference=function(a){var b=t(i.call(arguments,1),!0,!0,[]);return p.filter(a,function(a){return!p.contains(b,a)})},p.zip=function(a){if(null==a)return[];for(var b=p.max(arguments,"length").length,c=Array(b),d=0;b>d;d++)c[d]=p.pluck(arguments,d);return c},p.object=function(a,b){if(null==a)return{};for(var c={},d=0,e=a.length;e>d;d++)b?c[a[d]]=b[d]:c[a[d][0]]=a[d][1];return c},p.indexOf=function(a,b,c){if(null==a)return-1;var d=0,e=a.length;if(c){if("number"!=typeof c)return d=p.sortedIndex(a,b),a[d]===b?d:-1;d=0>c?Math.max(0,e+c):c}for(;e>d;d++)if(a[d]===b)return d;return-1},p.lastIndexOf=function(a,b,c){if(null==a)return-1;var d=a.length;for("number"==typeof c&&(d=0>c?d+c+1:Math.min(d,c+1));--d>=0;)if(a[d]===b)return d;return-1},p.range=function(a,b,c){arguments.length<=1&&(b=a||0,a=0),c=c||1;for(var d=Math.max(Math.ceil((b-a)/c),0),e=Array(d),f=0;d>f;f++,a+=c)e[f]=a;return e};var u=function(){};p.bind=function(a,b){var c,d;if(o&&a.bind===o)return o.apply(a,i.call(arguments,1));if(!p.isFunction(a))throw new TypeError("Bind must be called on a function");return c=i.call(arguments,2),d=function(){if(!(this instanceof d))return a.apply(b,c.concat(i.call(arguments)));u.prototype=a.prototype;var e=new u;u.prototype=null;var f=a.apply(e,c.concat(i.call(arguments)));return p.isObject(f)?f:e}},p.partial=function(a){var b=i.call(arguments,1);return function(){for(var c=0,d=b.slice(),e=0,f=d.length;f>e;e++)d[e]===p&&(d[e]=arguments[c++]);for(;c=d)throw new Error("bindAll must be passed function names");for(b=1;d>b;b++)c=arguments[b],a[c]=p.bind(a[c],a);return a},p.memoize=function(a,b){var c=function(d){var e=c.cache,f=b?b.apply(this,arguments):d;return p.has(e,f)||(e[f]=a.apply(this,arguments)),e[f]};return c.cache={},c},p.delay=function(a,b){var c=i.call(arguments,2);return setTimeout(function(){return a.apply(null,c)},b)},p.defer=function(a){return p.delay.apply(p,[a,1].concat(i.call(arguments,1)))},p.throttle=function(a,b,c){var d,e,f,g=null,h=0;c||(c={});var i=function(){h=c.leading===!1?0:p.now(),g=null,f=a.apply(d,e),g||(d=e=null)};return function(){var j=p.now();h||c.leading!==!1||(h=j);var k=b-(j-h);return d=this,e=arguments,0>=k||k>b?(clearTimeout(g),g=null,h=j,f=a.apply(d,e),g||(d=e=null)):g||c.trailing===!1||(g=setTimeout(i,k)),f}},p.debounce=function(a,b,c){var d,e,f,g,h,i=function(){var j=p.now()-g;b>j&&j>0?d=setTimeout(i,b-j):(d=null,c||(h=a.apply(f,e),d||(f=e=null)))};return function(){f=this,e=arguments,g=p.now();var j=c&&!d;return d||(d=setTimeout(i,b)),j&&(h=a.apply(f,e),f=e=null),h}},p.wrap=function(a,b){return p.partial(b,a)},p.negate=function(a){return function(){return!a.apply(this,arguments)}},p.compose=function(){var a=arguments,b=a.length-1;return function(){for(var c=b,d=a[b].apply(this,arguments);c--;)d=a[c].call(this,d);return d}},p.after=function(a,b){return function(){return--a<1?b.apply(this,arguments):void 0}},p.before=function(a,b){var c;return function(){return--a>0?c=b.apply(this,arguments):b=null,c}},p.once=p.partial(p.before,2),p.keys=function(a){if(!p.isObject(a))return[];if(n)return n(a);var b=[];for(var c in a)p.has(a,c)&&b.push(c);return b},p.values=function(a){for(var b=p.keys(a),c=b.length,d=Array(c),e=0;c>e;e++)d[e]=a[b[e]];return d},p.pairs=function(a){for(var b=p.keys(a),c=b.length,d=Array(c),e=0;c>e;e++)d[e]=[b[e],a[b[e]]];return d},p.invert=function(a){for(var b={},c=p.keys(a),d=0,e=c.length;e>d;d++)b[a[c[d]]]=c[d];return b},p.functions=p.methods=function(a){var b=[];for(var c in a)p.isFunction(a[c])&&b.push(c);return b.sort()},p.extend=function(a){if(!p.isObject(a))return a;for(var b,c,d=1,e=arguments.length;e>d;d++){b=arguments[d];for(c in b)l.call(b,c)&&(a[c]=b[c])}return a},p.pick=function(a,b,c){var d,e={};if(null==a)return e;if(p.isFunction(b)){b=q(b,c);for(d in a){var f=a[d];b(f,d,a)&&(e[d]=f)}}else{var g=j.apply([],i.call(arguments,1));a=new Object(a);for(var h=0,k=g.length;k>h;h++)d=g[h],d in a&&(e[d]=a[d])}return e},p.omit=function(a,b,c){if(p.isFunction(b))b=p.negate(b);else{var d=p.map(j.apply([],i.call(arguments,1)),String);b=function(a,b){return!p.contains(d,b)}}return p.pick(a,b,c)},p.defaults=function(a){if(!p.isObject(a))return a;for(var b=1,c=arguments.length;c>b;b++){var d=arguments[b];for(var e in d)void 0===a[e]&&(a[e]=d[e])}return a},p.clone=function(a){return p.isObject(a)?p.isArray(a)?a.slice():p.extend({},a):a},p.tap=function(a,b){return b(a),a};var v=function(a,b,c,d){if(a===b)return 0!==a||1/a===1/b;if(null==a||null==b)return a===b;a instanceof p&&(a=a._wrapped),b instanceof p&&(b=b._wrapped);var e=k.call(a);if(e!==k.call(b))return!1;switch(e){case"[object RegExp]":case"[object String]":return""+a==""+b;case"[object Number]":return+a!==+a?+b!==+b:0===+a?1/+a===1/b:+a===+b;case"[object Date]":case"[object Boolean]":return+a===+b}if("object"!=typeof a||"object"!=typeof b)return!1;for(var f=c.length;f--;)if(c[f]===a)return d[f]===b;var g=a.constructor,h=b.constructor;if(g!==h&&"constructor"in a&&"constructor"in b&&!(p.isFunction(g)&&g instanceof g&&p.isFunction(h)&&h instanceof h))return!1;c.push(a),d.push(b);var i,j;if("[object Array]"===e){if(i=a.length,j=i===b.length)for(;i--&&(j=v(a[i],b[i],c,d)););}else{var l,m=p.keys(a);if(i=m.length,j=p.keys(b).length===i)for(;i--&&(l=m[i],j=p.has(b,l)&&v(a[l],b[l],c,d)););}return c.pop(),d.pop(),j};p.isEqual=function(a,b){return v(a,b,[],[])},p.isEmpty=function(a){if(null==a)return!0;if(p.isArray(a)||p.isString(a)||p.isArguments(a))return 0===a.length;for(var b in a)if(p.has(a,b))return!1;return!0},p.isElement=function(a){return!(!a||1!==a.nodeType)},p.isArray=m||function(a){return"[object Array]"===k.call(a)},p.isObject=function(a){var b=typeof a;return"function"===b||"object"===b&&!!a},p.each(["Arguments","Function","String","Number","Date","RegExp"],function(a){p["is"+a]=function(b){return k.call(b)==="[object "+a+"]"}}),p.isArguments(arguments)||(p.isArguments=function(a){return p.has(a,"callee")}),"function"!=typeof/./&&(p.isFunction=function(a){return"function"==typeof a||!1}),p.isFinite=function(a){return isFinite(a)&&!isNaN(parseFloat(a))},p.isNaN=function(a){return p.isNumber(a)&&a!==+a},p.isBoolean=function(a){return a===!0||a===!1||"[object Boolean]"===k.call(a)},p.isNull=function(a){return null===a},p.isUndefined=function(a){return void 0===a},p.has=function(a,b){return null!=a&&l.call(a,b)},p.noConflict=function(){return a._=d,this},p.identity=function(a){return a},p.constant=function(a){return function(){return a}},p.noop=function(){},p.property=function(a){return function(b){return b[a]}},p.matches=function(a){var b=p.pairs(a),c=b.length;return function(a){if(null==a)return!c;a=new Object(a);for(var d=0;c>d;d++){var e=b[d],f=e[0];if(e[1]!==a[f]||!(f in a))return!1}return!0}},p.times=function(a,b,c){var d=Array(Math.max(0,a));b=q(b,c,1);for(var e=0;a>e;e++)d[e]=b(e);return d},p.random=function(a,b){return null==b&&(b=a,a=0),a+Math.floor(Math.random()*(b-a+1))},p.now=Date.now||function(){return(new Date).getTime()};var w={"&":"&","<":"<",">":">",'"':""","'":"'","`":"`"},x=p.invert(w),y=function(a){var b=function(b){return a[b]},c="(?:"+p.keys(a).join("|")+")",d=RegExp(c),e=RegExp(c,"g");return function(a){return a=null==a?"":""+a,d.test(a)?a.replace(e,b):a}};p.escape=y(w),p.unescape=y(x),p.result=function(a,b){if(null==a)return void 0;var c=a[b];return p.isFunction(c)?a[b]():c};var z=0;p.uniqueId=function(a){var b=++z+"";return a?a+b:b},p.templateSettings={evaluate:/<%([\s\S]+?)%>/g,interpolate:/<%=([\s\S]+?)%>/g,escape:/<%-([\s\S]+?)%>/g};var A=/(.)^/,B={"'":"'","\\":"\\","\r":"r","\n":"n","\u2028":"u2028","\u2029":"u2029"},C=/\\|'|\r|\n|\u2028|\u2029/g,D=function(a){return"\\"+B[a]};p.template=function(a,b,c){!b&&c&&(b=c),b=p.defaults({},b,p.templateSettings);var d=RegExp([(b.escape||A).source,(b.interpolate||A).source,(b.evaluate||A).source].join("|")+"|$","g"),e=0,f="__p+='";a.replace(d,function(b,c,d,g,h){return f+=a.slice(e,h).replace(C,D),e=h+b.length,c?f+="'+\n((__t=("+c+"))==null?'':_.escape(__t))+\n'":d?f+="'+\n((__t=("+d+"))==null?'':__t)+\n'":g&&(f+="';\n"+g+"\n__p+='"),b}),f+="';\n",b.variable||(f="with(obj||{}){\n"+f+"}\n"),f="var __t,__p='',__j=Array.prototype.join,print=function(){__p+=__j.call(arguments,'');};\n"+f+"return __p;\n";try{var g=new Function(b.variable||"obj","_",f)}catch(h){throw h.source=f,h}var i=function(a){return g.call(this,a,p)},j=b.variable||"obj";return i.source="function("+j+"){\n"+f+"}",i},p.chain=function(a){var b=p(a);return b._chain=!0,b};var E=function(a){return this._chain?p(a).chain():a};p.mixin=function(a){p.each(p.functions(a),function(b){var c=p[b]=a[b];p.prototype[b]=function(){var a=[this._wrapped];return h.apply(a,arguments),E.call(this,c.apply(p,a))}})},p.mixin(p),p.each(["pop","push","reverse","shift","sort","splice","unshift"],function(a){var b=e[a];p.prototype[a]=function(){var c=this._wrapped;return b.apply(c,arguments),"shift"!==a&&"splice"!==a||0!==c.length||delete c[0],E.call(this,c)}}),p.each(["concat","join","slice"],function(a){var b=e[a];p.prototype[a]=function(){return E.call(this,b.apply(this._wrapped,arguments))}}),p.prototype.value=function(){return this._wrapped},"function"==typeof define&&define.amd&&define("underscore",[],function(){return p})}).call(this)},{}],19:[function(a,b){function c(){this.callbacks={}}b.exports=c,c.prototype.on=function(a){var b=3===arguments.length,c=b?arguments[1]:void 0,d=b?arguments[2]:arguments[1];return d._groupName=c,(this.callbacks[a]=this.callbacks[a]||[]).push(d),this},c.prototype.once=function(a){function b(){c.off(a,b),f.apply(this,arguments)}var c=this,d=3===arguments.length,e=d?arguments[1]:void 0,f=d?arguments[2]:arguments[1];return this.on(a,e,b),this},c.prototype.releaseGroup=function(a){var b,c,d,e;for(b in this.callbacks)for(e=this.callbacks[b],c=0,d=e.length;d>c;c++)e[c]._groupName===a&&(e.splice(c,1),c--,d--);return this},c.prototype.off=function(a,b){var c,d=this.callbacks[a];return d?1===arguments.length?(delete this.callbacks[a],this):(c=d.indexOf(b),d.splice(c,1),this):this},c.prototype.emit=function(a){var b,c,d,e=[].slice.call(arguments,1),f=this.callbacks[a],g=this.getWildcardCallbacks(a);if(f)for(d=f.slice(),b=0,c=d.length;c>b&&d[b];++b)d[b].apply(this,e);if(g)for(c=g.length,d=g.slice(),b=0,c=d.length;c>b&&d[b];++b)d[b].apply(this,[a].concat(e));return this},c.prototype.getWildcardCallbacks=function(a){var b,c,d=[];for(b in this.callbacks)c=b.split("*"),("*"===b||2===c.length&&a.slice(0,c[0].length)===c[0])&&(d=d.concat(this.callbacks[b]));return d}},{}],20:[function(a,b){function c(a,b){var c,d=this;h.call(this),a=a||{},a.iceServers=a.iceServers||[],this.enableChromeNativeSimulcast=!1,b&&b.optional&&"webkit"===f.prefix&&null===navigator.appVersion.match(/Chromium\//)&&b.optional.forEach(function(a){a.enableChromeNativeSimulcast&&(d.enableChromeNativeSimulcast=!0)}),this.enableMultiStreamHacks=!1,b&&b.optional&&b.optional.forEach(function(a){a.enableMultiStreamHacks&&(d.enableMultiStreamHacks=!0)}),this.pc=new i(a,b),this.getLocalStreams=this.pc.getLocalStreams.bind(this.pc),this.getRemoteStreams=this.pc.getRemoteStreams.bind(this.pc),this.addStream=this.pc.addStream.bind(this.pc),this.removeStream=this.pc.removeStream.bind(this.pc),this.pc.on("*",function(){d.emit.apply(d,arguments)}),this.pc.onremovestream=this.emit.bind(this,"removeStream"),this.pc.onnegotiationneeded=this.emit.bind(this,"negotiationNeeded"),this.pc.oniceconnectionstatechange=this.emit.bind(this,"iceConnectionStateChange"),this.pc.onsignalingstatechange=this.emit.bind(this,"signalingStateChange"),this.pc.onaddstream=this._onAddStream.bind(this),this.pc.onicecandidate=this._onIce.bind(this),this.pc.ondatachannel=this._onDataChannel.bind(this),this.localDescription={contents:[]},this.remoteDescription={contents:[]},this.localStream=null,this.remoteStreams=[],this.config={debug:!1,ice:{},sid:"",isInitiator:!0,sdpSessionID:Date.now(),useJingle:!1};for(c in a)this.config[c]=a[c];this.config.debug&&this.on("*",function(){var b=a.logger||console;b.log("PeerConnection event:",arguments)}),this.hadLocalStunCandidate=!1,this.hadRemoteStunCandidate=!1,this.hadLocalRelayCandidate=!1,this.hadRemoteRelayCandidate=!1,this.hadLocalIPv6Candidate=!1,this.hadRemoteIPv6Candidate=!1,this._remoteDataChannels=[],this._localDataChannels=[]}var d=a("underscore"),e=a("util"),f=a("webrtcsupport"),g=a("sdp-jingle-json"),h=a("wildemitter"),i=a("traceablepeerconnection");e.inherits(c,h),Object.defineProperty(c.prototype,"signalingState",{get:function(){return this.pc.signalingState}}),Object.defineProperty(c.prototype,"iceConnectionState",{get:function(){return this.pc.iceConnectionState}}),c.prototype.addStream=function(a){this.localStream=a,this.pc.addStream(a)},c.prototype._checkLocalCandidate=function(a){var b=g.toCandidateJSON(a);"srflx"==b.type?this.hadLocalStunCandidate=!0:"relay"==b.type&&(this.hadLocalRelayCandidate=!0),-1!=b.ip.indexOf(":")&&(this.hadLocalIPv6Candidate=!0)},c.prototype._checkRemoteCandidate=function(a){var b=g.toCandidateJSON(a);"srflx"==b.type?this.hadRemoteStunCandidate=!0:"relay"==b.type&&(this.hadRemoteRelayCandidate=!0),-1!=b.ip.indexOf(":")&&(this.hadRemoteIPv6Candidate=!0)},c.prototype.processIce=function(a,b){b=b||function(){};var c=this;if(a.contents){var e=d.pluck(this.remoteDescription.contents,"name"),h=a.contents;h.forEach(function(a){var b=a.transport||{},d=b.candidates||[],h=e.indexOf(a.name),i=a.name;d.forEach(function(a){var b=g.toCandidateSDP(a)+"\r\n";c.pc.addIceCandidate(new f.IceCandidate({candidate:b,sdpMLineIndex:h,sdpMid:i})),c._checkRemoteCandidate(b)})})}else 0!==a.candidate.candidate.indexOf("a=")&&(a.candidate.candidate="a="+a.candidate.candidate),c.pc.addIceCandidate(new f.IceCandidate(a.candidate)),c._checkRemoteCandidate(a.candidate.candidate);b()},c.prototype.offer=function(a,b){var c=this,e=2===arguments.length,f=e?a:{mandatory:{OfferToReceiveAudio:!0,OfferToReceiveVideo:!0}};b=e?b:a,b=b||function(){},this.pc.createOffer(function(a){c.pc.setLocalDescription(a,function(){var e,f={type:"offer",sdp:a.sdp};c.config.useJingle&&(e=g.toSessionJSON(a.sdp,c.config.isInitiator?"initiator":"responder"),e.sid=c.config.sid,c.localDescription=e,d.each(e.contents,function(a){var b=a.transport||{};b.ufrag&&(c.config.ice[a.name]={ufrag:b.ufrag,pwd:b.pwd})}),f.jingle=e),f.sdp.split("\r\n").forEach(function(a){0===a.indexOf("a=candidate:")&&c._checkLocalCandidate(a)}),c.emit("offer",f),b(null,f)},function(a){c.emit("error",a),b(a)})},function(a){c.emit("error",a),b(a)},f)},c.prototype.handleOffer=function(a,b){b=b||function(){};var c=this;a.type="offer",a.jingle&&(this.enableChromeNativeSimulcast&&a.jingle.contents.forEach(function(a){"video"===a.name&&(a.description.googConferenceFlag=!0)}),a.sdp=g.toSessionSDP(a.jingle,c.config.sdpSessionID),c.remoteDescription=a.jingle),a.sdp.split("\r\n").forEach(function(a){0===a.indexOf("a=candidate:")&&c._checkRemoteCandidate(a)}),c.pc.setRemoteDescription(new f.SessionDescription(a),function(){b()},b)},c.prototype.answerAudioOnly=function(a){var b={mandatory:{OfferToReceiveAudio:!0,OfferToReceiveVideo:!1}};this._answer(b,a)},c.prototype.answerBroadcastOnly=function(a){var b={mandatory:{OfferToReceiveAudio:!1,OfferToReceiveVideo:!1}};this._answer(b,a)},c.prototype.answer=function(a,b){var c=2===arguments.length,d=c?b:a,e=c?a:{mandatory:{OfferToReceiveAudio:!0,OfferToReceiveVideo:!0}};this._answer(e,d)},c.prototype.handleAnswer=function(a,b){b=b||function(){};var c=this;a.jingle&&(a.sdp=g.toSessionSDP(a.jingle,c.config.sdpSessionID),c.remoteDescription=a.jingle),a.sdp.split("\r\n").forEach(function(a){0===a.indexOf("a=candidate:")&&c._checkRemoteCandidate(a)}),c.pc.setRemoteDescription(new f.SessionDescription(a),function(){b(null)},b)},c.prototype.close=function(){this.pc.close(),this._localDataChannels=[],this._remoteDataChannels=[],this.emit("close")},c.prototype._answer=function(a,b){b=b||function(){};var c=this;if(!this.pc.remoteDescription)throw new Error("remoteDescription not set");c.pc.createAnswer(function(a){var d=[];if(c.enableChromeNativeSimulcast&&(a.jingle=g.toSessionJSON(a.sdp),a.jingle.contents.length>=2&&"video"===a.jingle.contents[1].name)){var e=a.jingle.contents[1].description.sourceGroups||[],f=!1;if(e.forEach(function(a){"SIM"==a.semantics&&(f=!0)}),!f&&a.jingle.contents[1].description.sources.length){var h=JSON.parse(JSON.stringify(a.jingle.contents[1].description.sources[0]));h.ssrc=""+Math.floor(4294967295*Math.random()),a.jingle.contents[1].description.sources.push(h),d.push(a.jingle.contents[1].description.sources[0].ssrc),d.push(h.ssrc),e.push({semantics:"SIM",sources:d});var i=JSON.parse(JSON.stringify(h));i.ssrc=""+Math.floor(4294967295*Math.random()),a.jingle.contents[1].description.sources.push(i),e.push({semantics:"FID",sources:[h.ssrc,i.ssrc]}),a.jingle.contents[1].description.sourceGroups=e,a.sdp=g.toSessionSDP(a.jingle,c.config.sdpSessionID)}}c.pc.setLocalDescription(a,function(){var d={type:"answer",sdp:a.sdp};if(c.config.useJingle){var e=g.toSessionJSON(a.sdp);e.sid=c.config.sid,c.localDescription=e,d.jingle=e}if(c.enableChromeNativeSimulcast){d.jingle||(d.jingle=g.toSessionJSON(a.sdp));{d.jingle.contents[1].description.sourceGroups||[]}d.jingle.contents[1].description.sources.forEach(function(a,b){a.parameters=a.parameters.map(function(a){return"msid"===a.key&&(a.value+="-"+Math.floor(b/2)),a})}),d.sdp=g.toSessionSDP(d.jingle)}d.sdp.split("\r\n").forEach(function(a){0===a.indexOf("a=candidate:")&&c._checkLocalCandidate(a)}),c.emit("answer",d),b(null,d)},function(a){c.emit("error",a),b(a)})},function(a){c.emit("error",a),b(a)},a)},c.prototype._onIce=function(a){var b=this;if(a.candidate){var c=a.candidate,e={candidate:a.candidate},f=g.toCandidateJSON(c.candidate);if(b.config.useJingle){if(c.sdpMid||(c.sdpMid=b.localDescription.contents[c.sdpMLineIndex].name),!b.config.ice[c.sdpMid]){var h=g.toSessionJSON(b.pc.localDescription.sdp,b.config.isInitiator?"initiator":"responder");d.each(h.contents,function(a){var c=a.transport||{};c.ufrag&&(b.config.ice[a.name]={ufrag:c.ufrag,pwd:c.pwd})})}e.jingle={contents:[{name:c.sdpMid,creator:b.config.isInitiator?"initiator":"responder",transport:{transType:"iceUdp",ufrag:b.config.ice[c.sdpMid].ufrag,pwd:b.config.ice[c.sdpMid].pwd,candidates:[f]}}]}}this._checkLocalCandidate(c.candidate),this.emit("ice",e)}else this.emit("endOfCandidates")},c.prototype._onDataChannel=function(a){var b=a.channel;this._remoteDataChannels.push(b),this.emit("addChannel",b)},c.prototype._onAddStream=function(a){this.remoteStreams.push(a.stream),this.emit("addStream",a)},c.prototype.createDataChannel=function(a,b){var c=this.pc.createDataChannel(a,b);return this._localDataChannels.push(c),c},c.prototype.getStats=function(a){"moz"===f.prefix?this.pc.getStats(function(b){var c=[];for(var d in b)"object"==typeof b[d]&&c.push(b[d]);a(null,c)},a):this.pc.getStats(function(b){var c=[];b.result().forEach(function(a){var b={};a.names().forEach(function(c){b[c]=a.stat(c)}),b.id=a.id,b.type=a.type,b.timestamp=a.timestamp,c.push(b)}),a(null,c)})},b.exports=c},{"sdp-jingle-json":13,traceablepeerconnection:17,underscore:18,util:8,webrtcsupport:21,wildemitter:19}],21:[function(a,b){var c,d=!1,e=!1,f=window.navigator.userAgent.toLowerCase();-1!==f.indexOf("firefox")?(c="moz",e=!0):-1!==f.indexOf("chrome")&&(c="webkit",d=!0);var g=window.mozRTCPeerConnection||window.webkitRTCPeerConnection,h=window.mozRTCIceCandidate||window.RTCIceCandidate,i=window.mozRTCSessionDescription||window.RTCSessionDescription,j=window.webkitMediaStream||window.MediaStream,k="https:"===window.location.protocol&&(window.navigator.userAgent.match("Chrome")&&parseInt(window.navigator.userAgent.match(/Chrome\/(.*) /)[1],10)>=26||window.navigator.userAgent.match("Firefox")&&parseInt(window.navigator.userAgent.match(/Firefox\/(.*)/)[1],10)>=33),l=window.webkitAudioContext||window.AudioContext;b.exports={support:!!g,dataChannel:d||e||g&&g.prototype&&g.prototype.createDataChannel,prefix:c,webAudio:!(!l||!l.prototype.createMediaStreamSource),mediaStream:!(!j||!j.prototype.removeTrack),screenSharing:!!k,AudioContext:l,PeerConnection:g,SessionDescription:i,IceCandidate:h,MediaStream:j}},{}],22:[function(a,b){var c,d,e,f,g,h,i,j,k=function(a,b){return function(){return a.apply(b,arguments)}};j=a("./vendor/uuid"),e=a("./peer_connection_factory"),f=a("./vendor/primus"),h=a("./nearest_server"),i=function(){},g=function(a){return f.connect(a)},d=function(){function a(a){this.broadcastBridge=a,this._ensureIce=k(this._ensureIce,this),this._ensureReady=k(this._ensureReady,this),this._signalHandler=k(this._signalHandler,this),this._onConnectionOpen=k(this._onConnectionOpen,this),this.write=k(this.write,this),this.myUUID=j(),this.peerConnections={},this.calls={},this.connected=!1}return a.prototype.connectToCineBroadcastBridge=function(a){return this.primus=g(a),this.primus.on("open",this._onConnectionOpen),this.primus.on("data",this._signalHandler),this.primus.on("end",this._connectionEnded),this.connected=!0},a.prototype.write=function(a){var b;return a.client="cineio-peer-js version-"+CineIOPeer.version,a.publicKey=CineIOPeer.config.publicKey,a.uuid=this.myUUID,console.log("Writing",a),(b=this.primus).write.apply(b,arguments)},a.prototype.startBroadcast=function(a,b,c,d,f){return console.log("ensuring ready"),this._ensureReady(function(g){return function(){var h;return console.log("ready"),h=e.create(),g.peerConnections[a]=h,h.addStream(d),console.log("waiting for ice"),h.on("close",function(){return g._onCloseOfPeerConnection(h),delete g.peerConnections[a]}),g._createOffer(h,function(d,e){return console.log("MADE OFFER",d,e),d?f(d):h.on("endOfCandidates",function(){var d;return console.log("got all candidates"),d={streamType:a,action:"broadcast-start",offer:h.pc.localDescription,streamId:b,streamKey:c},g.write(d),f()})})}}(this))},a.prototype.stopBroadcast=function(a,b){var c;return this.peerConnections[a]&&this.peerConnections[a].close(),c={streamType:a,action:"broadcast-stop"},this.write(c),b()},a.prototype._onConnectionOpen=function(){return this.write({action:"auth"})},a.prototype._connectionEnded=function(){return console.log("Connection closed")},a.prototype._signalHandler=function(a){var b;switch(console.log("got data",a),a.action){case"error":return CineIOPeer.trigger("error",a);case"ack":return console.log("ack");case"rtc-answer":return console.log("got answer",a),b=this.peerConnections[a.streamType],b.handleAnswer(a.answer)}},a.prototype._createOffer=function(a,b){var c,d;return d=function(a,c){return a||!c?(console.log("FATAL ERROR in offer",a,c),CineIOPeer.trigger("error",{kind:"offer",fatal:!0,err:a})):(console.log("offering",a,c),b(a,c))},c={mandatory:{OfferToReceiveAudio:!0,OfferToReceiveVideo:!0}},a.offer(c,d)},a.prototype._onCloseOfPeerConnection=function(){},a.prototype._ensureReady=function(a){return this._ensureIce(a)},a.prototype._ensureIce=function(a){return this.broadcastBridge.iceReady?setTimeout(a):CineIOPeer.once("gotIceServers",a)},a}(),b.exports=c=function(){function a(a){this.CineIOPeer=a,this.CineIOPeer.on("gotIceServers",function(a){return function(){return a.iceReady=!0}}(this)),this.connection=new d(this)}return a.prototype.startBroadcast=function(a,b,c,d,e){return null==e&&(e=i),this._ensureConnection(function(f){return function(){return f.connection.startBroadcast(a,c,d,b,e)}}(this))},a.prototype.stopBroadcast=function(a,b){return this.connection.connected?this.connection.stopBroadcast(a,b):b()},a.prototype._ensureConnection=function(a){return null==a&&(a=i),this.connection.connected?setTimeout(function(){return a()}):h(function(b){return function(c,d){return console.log("HERE I AM",c,d),c?a(c):(b.connection.connectToCineBroadcastBridge(d.rtcPublish),a())}}(this))},a}()},{"./nearest_server":29,"./peer_connection_factory":30,"./vendor/primus":34,"./vendor/uuid":35}],23:[function(a,b,c){var d;d=function(a){return-1!==navigator.userAgent.indexOf(a)},c.isOpera=d("OPR"),c.isChrome=d("Chrome")&&!c.isOpera,c.isFirefox=d("Firefox")&&!c.isOpera,c.isMSIE=d("MSIE")},{}],24:[function(a,b){var c,d,e,f,g,h,i,j;c=a("backbone-events-standalone"),j=function(){},g=0,h=1,f=2,i=function(){function a(a,b){this.otherIdentity=a,this.room=b,this.state=g}return a.prototype.call=function(){var a;return this.state=h,a={action:"call",room:this.room,otheridentity:this.otherIdentity},e._signalConnection.write(a)},a.prototype.cancel=function(){var a;return this.state=f,a={action:"call-cancel",room:this.room,otheridentity:this.otherIdentity},e._signalConnection.write(a)},a.prototype.left=function(){return this.state=f},a.prototype.joined=function(){return this.state=h},a}(),b.exports=d=function(){function a(a,b){this.room=a,this.options=null!=b?b:{},this.state=this.options.initiated?h:g,this.participants={},this.options.called&&this._createParticipant(this.options.called)}return a.prototype.answer=function(a){return null==a&&(a=j),this.state=h,e.join(this.room,a)},a.prototype.isInCall=function(){return this.state===h},a.prototype.isEnded=function(){return this.state===f},a.prototype.reject=function(a){var b;return null==a&&(a=j),this.state=f,b={action:"call-reject",room:this.room},e._signalConnection.write(b),a()},a.prototype.hangup=function(a){return null==a&&(a=j),this.state=f,e.leave(this.room,a),this._cancelOutgoingCalls()},a.prototype.left=function(a){var b;return(b=this.participants[a])?b.left():void 0},a.prototype.joined=function(a){var b;return b=this._createParticipant(a),b.joined()},a.prototype.invite=function(a,b){var c;return null==b&&(b=j),c=this._createParticipant(a),c.call(),b()},a.prototype.cancel=function(a,b){var c;return null==b&&(b=j),(c=this.participants[a])?(c.cancel(),b()):b("participant not in room: "+otheridentity)},a.prototype._cancelOutgoingCalls=function(){var a,b,c,d;c=this.participants,d=[];for(a in c)b=c[a],d.push(b.cancel());return d},a.prototype._createParticipant=function(a){var b;return b=this.participants[a],b?b:this.participants[a]=new i(a,this.room)},a}(),c.mixin(d.prototype),e=a("./main")},{"./main":28,"backbone-events-standalone":3}],25:[function(a,b){var c,d,e,f,g,h=function(a,b){return function(){return a.apply(b,arguments)}},i={}.hasOwnProperty,j=function(a,b){function c(){this.constructor=a}for(var d in b)i.call(b,d)&&(a[d]=b[d]);return c.prototype=b.prototype,a.prototype=new c,a.__super__=b.prototype,a};d=a("./config"),g=a("./screen_share_base"),f=g.ScreenSharer,e=g.ScreenShareError,c=function(a){function b(){this._onScreenShareResponse=h(this._onScreenShareResponse,this),b.__super__.constructor.call(this),this._extensionInstalled=!1,this._extensionReplyTries=0,window.addEventListener("message",this._receiveMessage.bind(this),!1),window.postMessage({name:"cineScreenShareCheckForExtension"},"*")}return j(b,a),b.prototype.share=function(a,c){return b.__super__.share.call(this,a,c),this._shareAfterExtensionReplies()},b.prototype._shareAfterExtensionReplies=function(){return this._extensionInstalled||++this._extensionReplyTries<3?this._extensionInstalled?window.postMessage({name:"cineScreenShare"},"*"):(console.log("Waiting for the screen sharing extension reply ..."),setTimeout(this._shareAfterExtensionReplies.bind(this),100)):this._callback(new e("Screen sharing in chrome requires the cine.io Screen Sharing extension.",{extensionRequired:!0,type:"chrome",url:d.chromeExtension}))},b.prototype._receiveMessage=function(a){switch(console.log("received:",a),a.data.name){case"cineScreenShareHasExtension":console.log("cine.io screen share extension is installed."),this._extensionInstalled=!0;break;case"cineScreenShareResponse":return this._onScreenShareResponse(a.data.id) -}},b.prototype._onScreenShareResponse=function(a){var b;return a?(console.log("ossr id =",a),b={audio:!1,video:{mandatory:{chromeMediaSource:"desktop",chromeMediaSourceId:a}}},navigator.webkitGetUserMedia(b,this._onStreamReceived.bind(this),this._onError.bind(this))):this._callback(new e("Screen access rejected."))},b}(f),b.exports=c},{"./config":26,"./screen_share_base":31}],26:[function(a,b,c){var d;d="https:"===location.protocol?"https":"http",c.signalingServer=""+d+"://signaling.cine.io",c.chromeExtension="https://chrome.google.com/webstore/detail/cineio-screen-sharing/ancoeogeclfnhienkmfmeeomadmofhmi"},{}],27:[function(a,b){var c,d,e,f,g={}.hasOwnProperty,h=function(a,b){function c(){this.constructor=a}for(var d in b)g.call(b,d)&&(a[d]=b[d]);return c.prototype=b.prototype,a.prototype=new c,a.__super__=b.prototype,a};f=a("./screen_share_base"),e=f.ScreenSharer,d=f.ScreenShareError,c=function(a){function b(){return b.__super__.constructor.apply(this,arguments)}return h(b,a),b.prototype.share=function(a,c){var d;return b.__super__.share.call(this,a,c),console.log("requesting screen share (moz) ..."),d={audio:this.options.audio,video:{mediaSource:"screen"}},navigator.mozGetUserMedia(d,this._onStreamReceived.bind(this),this._onError.bind(this))},b}(e),b.exports=c},{"./screen_share_base":31}],28:[function(a,b){var c,d,e,f,g,h,i,j,k,l,m,n,o;j=a("getusermedia"),g=a("attachmediastream"),o=a("webrtcsupport"),c=a("backbone-events-standalone"),k=function(){},i={video:!0,audio:!0,autoplay:!0,mirror:!0,muted:!0},n=function(a,b){return Object.prototype.hasOwnProperty.call(a,b)?a[b]:i[b]},e={version:"0.0.5",reset:function(){return e.config={rooms:[],videoElements:{}}},init:function(a){return e.config.publicKey=a,e._signalConnection||(e._signalConnection=m.connect()),e._broadcastBridge=new d(this),setTimeout(e._checkSupport)},identify:function(a,b,c){return e.config.identity={identity:a,timestamp:b,signature:c},e._sendIdentity()},_sendIdentity:function(){return e._signalConnection.write({action:"identify",identity:e.config.identity.identity,timestamp:e.config.identity.timestamp,signature:e.config.identity.signature,publicKey:e.config.publicKey,client:"web"})},sendDataToAll:function(a){return e._signalConnection.sendDataToAllPeers(a)},call:function(a,b,c){var d,f;return null==b&&(b=null),null==c&&(c=k),"function"==typeof b&&(c=b,b=null),f={action:"call",otheridentity:a},e.config.identity&&(f.identity=e.config.identity.identity),b&&(f.room=b),e._signalConnection.write(f),d=function(b){return b.otheridentity===a?(e.off("call-placed",d),c(null,{call:b.call})):void 0},e.on("call-placed",d)},join:function(a,b){return null==b&&(b=k),e.config.rooms.push(a),e._sendJoinRoom(a),setTimeout(b)},leave:function(a,b){var c;return null==b&&(b=k),c=e.config.rooms.indexOf(a),0>c?(e.trigger("error",{msg:"not connected to room",room:a}),setTimeout(b)):(e.config.rooms.splice(c,1),e._signalConnection.write({action:"room-leave",room:a}),setTimeout(b))},startCameraAndMicrophone:function(a){return null==a&&(a=k),e._startMedia({video:!0,audio:!0},a)},stopCameraAndMicrophone:function(a){return null==a&&(a=k),e.microphoneStream&&(e._removeStream(e.microphoneStream,"camera"),delete e.microphoneStream),e.cameraStream&&(e._removeStream(e.cameraStream,"camera"),delete e.cameraStream),e.cameraAndMicrophoneStream&&(e._removeStream(e.cameraAndMicrophoneStream,"camera"),delete e.cameraAndMicrophoneStream),a()},startMicrophone:function(a){return null==a&&(a=k),e._audioCapableStreams().length>0?(e._unmuteAudio(),a()):e.cameraStream&&!e.mutedCamera?(e._removeStream(e.cameraStream,"camera",{silent:!0}),delete e.cameraStream,e.startCameraAndMicrophone(a)):e._startMedia({video:!1,audio:!0},a)},stopMicrophone:function(a){return null==a&&(a=k),e.microphoneStream&&(e._removeStream(e.microphoneStream,"camera"),delete e.microphoneStream),e.cameraAndMicrophoneStream&&(e.mutedCamera?(e._removeStream(e.cameraAndMicrophoneStream,"camera"),delete e.cameraAndMicrophoneStream):e._muteAudio()),a()},startCamera:function(a){return null==a&&(a=k),e._cameraCapableStreams().length>0?(e._unmuteCamera(),a()):e.microphoneStream&&!e.mutedMicrophone?(e._removeStream(e.microphoneStream,"camera",{silent:!0}),delete e.microphoneStream,e.startCameraAndMicrophone(a)):e._startMedia({video:!0,audio:!1},a)},stopCamera:function(a){return null==a&&(a=k),e.cameraStream&&(e._removeStream(e.cameraStream,"camera"),delete e.cameraStream),e.cameraAndMicrophoneStream&&(e.mutedMicrophone?(e._removeStream(e.cameraAndMicrophoneStream,"camera"),delete e.cameraAndMicrophoneStream):e._muteCamera()),a()},cameraRunning:function(){return e.cameraStream?!0:e.cameraAndMicrophoneStream&&!e.mutedCamera},screenShareRunning:function(){return null!=e.screenShareStream},microphoneRunning:function(){return null!=e.microphoneStream?!0:e._audioCapableStreams().length>0&&!e.mutedMicrophone},screenShareSupported:function(){return h.isChrome||h.isFirefox},startScreenShare:function(a,b){var c,d;return null==a&&(a={}),null==b&&(b=k),"function"==typeof a&&(b=a,a={}),e._screenSharer||(e._screenSharer=l.get()),d=setTimeout(e._mediaNotReady("screen"),1e3),c=function(a){return function(c,f){var g;return clearTimeout(d),c?c.extensionRequired?(e.trigger("extension-required",{url:c.url,type:c.type}),b()):(e.trigger("media-rejected",{type:"screen",local:!0}),b(c)):(g=a._createVideoElementFromStream(f,{mirror:!1}),e.screenShareStream=f,e._signalConnection.addLocalStream(f),e.trigger("media-added",{videoElement:g,stream:f,type:"screen",local:!0}),b())}}(this),e._screenSharer.share(a,c)},stopScreenShare:function(a){return null==a&&(a=k),e.screenShareRunning()?(e._removeStream(e.screenShareStream,"screen"),delete e.screenShareStream,a()):a()},broadcastCameraAndMicrophone:function(a,b,c){var d;return null==c&&(c=k),e.isBroadcastingCameraAndMicrophone()?setTimeout(function(){return c("cannot broadcast to multiple endpoints")}):(d=e.cameraAndMicrophoneStream)?(e._isBroadcastingCameraAndMicrophone=!0,e._broadcastBridge.startBroadcast("camera",d,a,b,c)):setTimeout(function(){return c("stream not started")})},stopCameraAndMicrophoneBroadcast:function(a){return null==a&&(a=k),delete e._isBroadcastingCameraAndMicrophone,e._broadcastBridge.stopBroadcast("camera",a)},isBroadcastingCameraAndMicrophone:function(){return null!=e._isBroadcastingCameraAndMicrophone},broadcastScreenShare:function(a,b,c){var d;return null==c&&(c=k),e.isBroadcastingScreenShare()?setTimeout(function(){return c("cannot broadcast to multiple endpoints")}):(d=e.screenShareStream)?(e._isBroadcastingScreenShare=!0,e._broadcastBridge.startBroadcast("screen",d,a,b,c)):setTimeout(function(){return c("stream not started")})},stopScreenShareBroadcast:function(a){return null==a&&(a=k),delete e._isBroadcastingScreenShare,e._broadcastBridge.stopBroadcast("screen",a)},isBroadcastingScreenShare:function(){return null!=e._isBroadcastingScreenShare},_muteAudio:function(){var a,b,c,d;for(d=e.localStreams(),b=0,c=d.length;c>b;b++)a=d[b],e._muteStreamAudio(a);return e.mutedMicrophone=!0},_muteCamera:function(){var a,b,c,d;for(d=e._cameraCapableStreams(),b=0,c=d.length;c>b;b++)a=d[b],e._muteStreamVideo(a);return e.mutedCamera=!0},_unmuteAudio:function(){var a;return a=e._audioCapableStreams()[0],a?e._unmuteStreamAudio(a):e.startMicrophone(),delete e.mutedMicrophone},_unmuteCamera:function(){var a;return a=e._cameraCapableStreams()[0],a?e._unmuteStreamVideo(a):e.startCamera(),delete e.mutedCamera},_removeStream:function(a,b,c){return null==c&&(c={}),a.stop(),e._signalConnection.removeLocalStream(a,c),e.trigger("media-removed",{local:!0,type:b,videoElement:e.config.videoElements[a.id]}),delete e.config.videoElements[a.id]},_muteStreamAudio:function(a){return a?e._disableTracks(a.getAudioTracks()):void 0},_unmuteStreamAudio:function(a){return a?e._enableTracks(a.getAudioTracks()):void 0},_muteStreamVideo:function(a){return a?e._disableTracks(a.getVideoTracks()):void 0},_unmuteStreamVideo:function(a){return a?e._enableTracks(a.getVideoTracks()):void 0},_enableTracks:function(a){var b,c,d,e;for(e=[],c=0,d=a.length;d>c;c++)b=a[c],e.push(b.enabled=!0);return e},_disableTracks:function(a){var b,c,d,e;for(e=[],c=0,d=a.length;d>c;c++)b=a[c],e.push(b.enabled=!1);return e},localStreams:function(){var a;return a=[],e.cameraAndMicrophoneStream&&a.push(e.cameraAndMicrophoneStream),e.cameraStream&&a.push(e.cameraStream),e.microphoneStream&&a.push(e.microphoneStream),e.screenShareStream&&a.push(e.screenShareStream),a},_cameraCapableStreams:function(){var a;return a=[],e.cameraAndMicrophoneStream&&a.push(e.cameraAndMicrophoneStream),e.cameraStream&&a.push(e.cameraStream),a},_audioCapableStreams:function(){var a;return a=[],e.cameraAndMicrophoneStream&&a.push(e.cameraAndMicrophoneStream),e.microphoneStream&&a.push(e.microphoneStream),a},_startMedia:function(a,b){var c;return null==b&&(b=k),e.cameraAndMicrophoneStream&&a.video&&a.audio?setTimeout(b):e.cameraStream&&a.video?setTimeout(b):e.microphoneStream&&a.audio?setTimeout(b):(c=setTimeout(e._mediaNotReady("camera"),1e3),e._askForMedia(a,function(d,f){return clearTimeout(c),d?(e.trigger("media-rejected",{type:"camera",local:!0}),b(d)):(a.video&&a.audio?(e.cameraAndMicrophoneStream=f.stream,delete e.mutedMicrophone,delete e.mutedCamera):a.video?(e.cameraStream=f.stream,delete e.mutedCamera):a.audio&&(e.microphoneStream=f.stream,delete e.mutedMicrophone),e.trigger("media-added",{videoElement:f.videoElement,stream:f.stream,type:"camera",video:a.video,audio:a.audio,local:!0}),e._signalConnection.addLocalStream(f.stream),b())}))},_checkSupport:function(){return o.support?e.trigger("info",{support:!0}):e.trigger("error",{support:!1})},_sendJoinRoom:function(a){return e._signalConnection.write({action:"room-join",room:a})},_mediaNotReady:function(a){return function(){return e.trigger("media-request",{local:!0,type:a})}},_askForMedia:function(a,b){var c;return null==a&&(a={}),"function"==typeof a&&(b=a,a={}),c={video:n(a,"video"),audio:n(a,"audio")},e._unsafeGetUserMedia(c,function(c){return function(d,e){var f;return d?b(d):(f=c._createVideoElementFromStream(e,a),b(null,{videoElement:f,stream:e}))}}(this))},_unsafeGetUserMedia:function(a,b){return j(a,b)},_createVideoElementFromStream:function(a,b){var c,d;return null==b&&(b={}),d={autoplay:n(b,"autoplay"),mirror:n(b,"mirror"),muted:n(b,"muted")},c=g(a,null,d),e.config.videoElements[a.id]=c,c},_getVideoElementFromStream:function(a){return e.config.videoElements[a.id]}},e.reset(),c.mixin(e),"undefined"!=typeof window&&(window.CineIOPeer=e),b.exports=e,f=a("./config"),m=a("./signaling_connection"),l=a("./screen_sharer"),h=a("./browser_detect"),d=a("./broadcast_bridge")},{"./broadcast_bridge":22,"./browser_detect":23,"./config":26,"./screen_sharer":32,"./signaling_connection":33,attachmediastream:1,"backbone-events-standalone":3,getusermedia:4,webrtcsupport:21}],29:[function(a,b){var c,d,e,f,g;e=a("jsonp"),c="https://www.cine.io/api/1/-/nearest-server?default=ok",f=null,d=null,g=null,b.exports=function(a){return f?a(null,f):d?g.push(a):(d=!0,b.exports._makeJsonpCall(c,function(b,c){var d,e,h;for(f=c,e=0,h=g.length;h>e;e++)(d=g[e])(b,f);return g=[],a(b,f)}))},b.exports._makeJsonpCall=function(a,b){return e(a,b)},b.exports._reset=function(){return f=null,d=!1,g=[]},b.exports._reset()},{jsonp:9}],30:[function(a,b,c){var d,e,f;e=a("rtcpeerconnection"),f=null,c.create=function(){return f?c._actuallyCreatePeerConnection({iceServers:f}):null},c._actuallyCreatePeerConnection=function(a){return new e(a)},c._reset=function(){return f=null},d=a("./main"),d.on("gotIceServers",function(a){return f=a})},{"./main":28,rtcpeerconnection:20}],31:[function(a,b){var c,d,e,f;f=a("webrtcsupport"),d=function(){function a(a,b){var c,d;this.msg=a;for(c in b)d=b[c],this[c]=d}return a}(),e=function(){function a(){}return a.prototype.share=function(a,b){return this.options=a,this._callback=b,window&&navigator?f.screenSharing?void 0:this._callback(new d("Screen sharing not implemented in this browser / environment.")):this._callback(new d("Screen sharing requires a browser environment!"))},a.prototype._onStreamReceived=function(a){return console.log("Received local stream:",a),a.onended=this._onStreamEnded.bind(this),this._callback(null,a)},a.prototype._onStreamEnded=function(){console.log("Screen share ended."),c.stopScreenShare()},a.prototype._onError=function(a){var b;return b=a.name?a.name+(a.message?" ("+a.message+")":""):a,b="Screen share failed: "+b,console.dir(a),console.log(b),this._callback(new d(b))},a}(),b.exports={ScreenShareError:d,ScreenSharer:e},c=a("./main")},{"./main":28,webrtcsupport:21}],32:[function(a,b){var c,d,e;c=a("./screen_share_base").ScreenShareError,e=a("./browser_detect"),d={get:function(b,d){var f,g;return null==b&&(b={}),b.hasOwnProperty("audio")||(b.audio=!1),e.isChrome?new(f=a("./chrome_screen_sharer"))(b,d):e.isFirefox?new(g=a("./firefox_screen_sharer"))(b,d):d(new c("Screen sharing not implemented in this browser / environment."))}},b.exports=d},{"./browser_detect":23,"./chrome_screen_sharer":25,"./firefox_screen_sharer":27,"./screen_share_base":31}],33:[function(a,b,c){var d,e,f,g,h,i,j,k,l,m,n,o,p=function(a,b){return function(){return a.apply(b,arguments)}};o=a("./vendor/uuid"),i=a("./peer_connection_factory"),j=a("./vendor/primus"),f=a("./config"),l=function(){},k=function(){return j.connect(f.signalingServer)},h=1,m=function(a,b){return"open"===a.readyState?a.send(JSON.stringify(b)):a.dataToSend.push(b)},n=function(a,b){return a.otherClientSparkId=b},g=function(){function a(a){this.options=a,this._ensureIce=p(this._ensureIce,this),this._ensureReady=p(this._ensureReady,this),this._ensurePeerConnection=p(this._ensurePeerConnection,this),this._newMember=p(this._newMember,this),this._sendOffer=p(this._sendOffer,this),this._closePeerConnection=p(this._closePeerConnection,this),this._signalHandler=p(this._signalHandler,this),this._onConnectionOpen=p(this._onConnectionOpen,this),this.removeLocalStream=p(this.removeLocalStream,this),this.addLocalStream=p(this.addLocalStream,this),this.write=p(this.write,this),this.myUUID=o(),this.iceServers=null,this.fetchedIce=!1,this.peerConnections={},this.calls={},this.primus=k(),this.primus.on("open",this._onConnectionOpen),this.primus.on("data",this._signalHandler),this.primus.on("end",this._connectionEnded)}return a.prototype.write=function(a){var b;return a.client="cineio-peer-js version-"+e.version,a.publicKey=e.config.publicKey,a.uuid=this.myUUID,e.config.identity&&(a.identity=e.config.identity.identity),console.log("Writing",a),(b=this.primus).write.apply(b,arguments)},a.prototype.addLocalStream=function(a,b){var c,d,e,f;null==b&&(b={}),e=this.peerConnections,f=[];for(c in e)d=e[c],console.log("adding local stream "+a.id+" to "+c),d.addStream(a),f.push(b.silent?void 0:this._sendOffer(d));return f},a.prototype.removeLocalStream=function(a,b){var c,d,e,f;null==b&&(b={}),e=this.peerConnections,f=[];for(c in e)d=e[c],console.log("removing local stream "+a.id+" from "+c),d.removeStream(a),f.push(b.silent?void 0:this._sendOffer(d));return f},a.prototype.sendDataToAllPeers=function(a){var b,c,d,e;d=this.peerConnections,e=[];for(b in d)c=d[b],console.log("sending data "+a+" to "+b),e.push(this._sendDataToPeer(c,a));return e},a.prototype._sendDataToPeer=function(a,b){return a.mainDataChannel||(a.mainDataChannel=this._newDataChannel(a),this._sendOffer(a)),m(a.mainDataChannel,{action:"userData",data:b})},a.prototype._newDataChannel=function(a){var b;return b=a.createDataChannel("CINE",{ordered:!1,maxRetransmitTime:3e3}),this._prepareDataChannel(a,b),b},a.prototype._prepareDataChannel=function(a,b){return b.dataToSend=[],b.onopen=function(a){var c,d,e,f;if(console.log("ON OPEN",a),"open"===b.readyState){for(f=b.dataToSend,d=0,e=f.length;e>d;d++)c=f[d],console.log("Actually sending data",c),m(b,c);return delete b.dataToSend}},b.onmessage=function(a){var b;return a&&a.data&&(b=JSON.parse(a.data),"userData"===b.action)?e.trigger("peer-data",b.data):void 0},b},a.prototype._onConnectionOpen=function(){var a,b,c,d,f;for(this.write({action:"auth"}),e.config.identity&&e._sendIdentity(),d=e.config.rooms,f=[],b=0,c=d.length;c>b;b++)a=d[b],f.push(e._sendJoinRoom(a));return f},a.prototype._connectionEnded=function(){return console.log("Connection closed")},a.prototype._callFromRoom=function(a,b){var c;return(c=this.calls)[a]||(c[a]=new d(a,b)),this.calls[a]},a.prototype._signalHandler=function(a){var b;switch(a.action){case"error":return e.trigger("error",a);case"rtc-servers":return console.log("setting config",a),this.iceServers=a.data,this.fetchedIce=!0,e.trigger("gotIceServers",a.data);case"ack":if("call"===a.source)return e.config.rooms.push(a.room),b=this._callFromRoom(a.room,{initiated:!0,called:a.otheridentity}),e.trigger("call-placed",{call:b,otheridentity:a.otheridentity});break;case"call":return e.trigger("call",{identity:a.identity,call:this._callFromRoom(a.room)});case"call-cancel":return this._callFromRoom(a.room).trigger("call-cancel",{identity:a.identity});case"call-reject":return this._callFromRoom(a.room).trigger("call-reject",{identity:a.identity});case"room-leave":return console.log("room-leave",a),a.identity&&this._callFromRoom(a.room).left(a.identity),this.write({action:"room-goodbye",sparkId:a.sparkId},a.room),this._closePeerConnection(a);case"room-join":return console.log("room-join",a),a.identity&&this._callFromRoom(a.room).joined(a.identity),this._ensurePeerConnection(a,{offer:!0}),this.write({action:"room-announce",sparkId:a.sparkId,room:a.room});case"room-announce":return console.log("room-announce",a),this._ensurePeerConnection(a,{offer:!1});case"room-goodbye":return console.log("room-goodbye",a),this._closePeerConnection(a);case"rtc-ice":if(!a.sparkId)return;return this._ensurePeerConnection(a,{offer:!1},function(b,c){return c.processIce(a.candidate)});case"rtc-offer":return console.log("got offer",a),this._ensurePeerConnection(a,{offer:!1},function(b){return function(c,d){return d.handleOffer(a.offer,function(){var c;return c=function(c,d){return b.write({action:"rtc-answer",answer:d,sparkId:a.sparkId})},d.answer(0===e.localStreams().length?c:c)})}}(this));case"rtc-answer":return this._ensurePeerConnection(a,{offer:!1},function(b,c){return c.handleAnswer(a.answer)})}},a.prototype._closePeerConnection=function(a){var b;return b=a.sparkUUID,this.peerConnections[b]&&this.peerConnections[b]!==h?(this.peerConnections[b].close(),delete this.peerConnections[b]):void 0},a.prototype._sendOffer=function(a){var b,c;return c=function(b){return function(c,d){var f;return f=a.otherClientSparkId,c||!d?(console.log("FATAL ERROR in offer",c,d),e.trigger("error",{kind:"offer",fatal:!0,err:c})):(console.log("offering",c,f,d),b.write({action:"rtc-offer",offer:d,sparkId:f}))}}(this),b={mandatory:{OfferToReceiveAudio:!0,OfferToReceiveVideo:!0}},a.mainDataChannel&&(b.optional=[{RtpDataChannels:!0}]),a.offer(b,c)},a.prototype._onCloseOfPeerConnection=function(a){var b,c,d,f;if(a.videoEls){for(f=a.videoEls,c=0,d=f.length;d>c;c++)b=f[c],e.trigger("media-removed",{peerConnection:a,videoElement:b,remote:!0});return delete a.videoEls}},a.prototype._newMember=function(a,b,c,d){return this.peerConnections[a]?this._ensureReady(function(b){return function(){return d(null,b.peerConnections[a])}}(this)):(this.peerConnections[a]=h,this._ensureReady(function(f){return function(){var g,h,j,k,l;for(console.log("CREATING NEW PEER CONNECTION!!",a,c),g=i.create(),f.peerConnections[a]=g,g.videoEls=[],n(g,b),l=e.localStreams(),j=0,k=l.length;k>j;j++)h=l[j],g.addStream(h);return g.on("addStream",function(a){var b;return console.log("got remote stream",a),b=e._createVideoElementFromStream(a.stream,{muted:!1,mirror:!1}),g.videoEls.push(b),e.trigger("media-added",{peerConnection:g,videoElement:b,remote:!0})}),g.on("removeStream",function(a){var b,c;return console.log("removing remote stream",a),c=e._getVideoElementFromStream(a.stream),b=g.videoEls.indexOf(c),b>-1&&g.videoEls.splice(b,1),e.trigger("media-removed",{peerConnection:g,videoElement:c,remote:!0})}),g.on("addChannel",function(a){return console.log("GOT A NEW DATA CHANNEL",a),g.mainDataChannel=f._prepareDataChannel(g,a)}),g.on("ice",function(a){return f.write({action:"rtc-ice",candidate:a,sparkId:g.otherClientSparkId})}),(c.offer&&e.localStreams().length>0||g.mainDataChannel)&&f._sendOffer(g),g.on("close",function(){return f._onCloseOfPeerConnection(g),delete f.peerConnections[a]}),d(null,g),e.trigger("peerConnectionMade")}}(this)))},a.prototype._ensurePeerConnection=function(a,b,c){var d,e,f;return null==c&&(c=l),e=a.sparkId,f=a.sparkUUID,d=this.peerConnections[f],d&&d!==h?(n(d,e),setTimeout(function(){return c(null,d)})):this._newMember(f,e,b,c)},a.prototype._ensureReady=function(a){return this._ensureIce(a)},a.prototype._ensureIce=function(a){return this.fetchedIce?setTimeout(a):e.once("gotIceServers",a)},a}(),c.connect=function(a){return new g(a)},e=a("./main"),d=a("./call")},{"./call":24,"./config":26,"./main":28,"./peer_connection_factory":30,"./vendor/primus":34,"./vendor/uuid":35}],34:[function(require,module,exports){!function(a,b,c){b[a]=c.call(b),"undefined"!=typeof module&&module.exports?module.exports=b[a]:"function"==typeof define&&define.amd&&define(function(){return b[a]})}("Primus",this,function a(){"use strict";function b(a,b,c){this.fn=a,this.context=b,this.once=c||!1}function c(){}function d(b,c){if(!(b instanceof a)){var d=new Error("Primus#"+c+"'s context should called with a Primus instance");if("function"!=typeof b.listeners||!b.listeners("error").length)throw d;b.emit("error",d)}}function a(b,d){if(!(this instanceof a))return new a(b,d);if("function"!=typeof this.client){var f="The client library has not been compiled correctly, see https://github.com/primus/primus#client-library for more details";return this.critical(new Error(f))}"object"==typeof b?(d=b,b=d.url||d.uri||e):d=d||{};var h=this;d.queueSize="queueSize"in d?d.queueSize:1/0,d.timeout="timeout"in d?d.timeout:1e4,d.reconnect="reconnect"in d?d.reconnect:{},d.ping="ping"in d?d.ping:25e3,d.pong="pong"in d?d.pong:1e4,d.strategy="strategy"in d?d.strategy:[],d.transport="transport"in d?d.transport:{},h.buffer=[],h.writable=!0,h.readable=!0,h.url=h.parse(b||e),h.readyState=a.CLOSED,h.options=d,h.timers={},h.attempt=null,h.socket=null,h.latency=0,h.stamps=0,h.disconnect=!1,h.transport=d.transport,h.transformers={outgoing:[],incoming:[]},"string"==typeof d.strategy&&(d.strategy=d.strategy.split(/\s?\,\s?/g)),!1===d.strategy?d.strategy=[]:d.strategy.length||(d.strategy.push("disconnect","online"),this.authorization||d.strategy.push("timeout")),d.strategy=d.strategy.join(",").toLowerCase(),g||c.call(h),"websockets"in d&&(h.AVOID_WEBSOCKETS=!d.websockets),"network"in d&&(h.NETWORK_EVENTS=d.network),d.manual||(h.timers.open=setTimeout(function(){h.clearTimeout("open").open()},0)),h.initialise(d)}c.prototype._events=void 0,c.prototype.listeners=function(a){if(!this._events||!this._events[a])return[];for(var b=0,c=this._events[a].length,d=[];c>b;b++)d.push(this._events[a][b].fn);return d},c.prototype.emit=function(a,b,c,d,e,f){if(!this._events||!this._events[a])return!1;var g,h,i,j=this._events[a],k=j.length,l=arguments.length,m=j[0];if(1===k){switch(m.once&&this.removeListener(a,m.fn,!0),l){case 1:return m.fn.call(m.context),!0;case 2:return m.fn.call(m.context,b),!0;case 3:return m.fn.call(m.context,b,c),!0;case 4:return m.fn.call(m.context,b,c,d),!0;case 5:return m.fn.call(m.context,b,c,d,e),!0;case 6:return m.fn.call(m.context,b,c,d,e,f),!0}for(h=1,g=new Array(l-1);l>h;h++)g[h-1]=arguments[h];m.fn.apply(m.context,g)}else for(h=0;k>h;h++)switch(j[h].once&&this.removeListener(a,j[h].fn,!0),l){case 1:j[h].fn.call(j[h].context);break;case 2:j[h].fn.call(j[h].context,b);break;case 3:j[h].fn.call(j[h].context,b,c);break;default:if(!g)for(i=1,g=new Array(l-1);l>i;i++)g[i-1]=arguments[i];j[h].fn.apply(j[h].context,g)}return!0},c.prototype.on=function(a,c,d){return this._events||(this._events={}),this._events[a]||(this._events[a]=[]),this._events[a].push(new b(c,d||this)),this},c.prototype.once=function(a,c,d){return this._events||(this._events={}),this._events[a]||(this._events[a]=[]),this._events[a].push(new b(c,d||this,!0)),this},c.prototype.removeListener=function(a,b,c){if(!this._events||!this._events[a])return this;var d=this._events[a],e=[];if(b)for(var f=0,g=d.length;g>f;f++)d[f].fn!==b&&d[f].once!==c&&e.push(d[f]);return this._events[a]=e.length?e:null,this},c.prototype.removeAllListeners=function(a){return this._events?(a?this._events[a]=null:this._events={},this):this},c.prototype.off=c.prototype.removeListener,c.prototype.addListener=c.prototype.on,c.prototype.setMaxListeners=function(){return this};var e;try{e=location.origin?location.origin:location.protocol+"//"+location.hostname+(location.port?":"+location.port:"")}catch(f){e="http://127.0.0.1"}a.require=function(a){return"function"!=typeof require?void 0:"function"==typeof define&&define.amd?void 0:require(a)};var g,h;try{a.Stream=g=a.require("stream"),h=a.require("url").parse,a.require("util").inherits(a,g)}catch(f){a.Stream=c,a.prototype=new c,h=function(a){var b,c=document.createElement("a"),d={};c.href=a;for(b in c)("string"==typeof c[b]||"number"==typeof c[b])&&(d[b]=c[b]);if(!d.port){var e=(d.href||"").split("/");if(e.length>2){var f=e[2],g=f.lastIndexOf("@");~g&&(f=f.slice(g+1)),e=f.split(":"),2===e.length&&(d.port=e[1])}}if(":"===d.protocol&&(d.protocol=d.href.substr(0,d.href.indexOf(":")+1)),"0"===d.port&&(d.port=""),~d.href.indexOf("@")&&!d.auth){var h=d.protocol.length+2;d.auth=d.href.slice(h,d.href.indexOf(d.pathname,h)).split("@")[0]}return d}}a.OPENING=1,a.CLOSED=2,a.OPEN=3,a.prototype.AVOID_WEBSOCKETS=!1,a.prototype.NETWORK_EVENTS=!1,a.prototype.online=!0;try{(a.prototype.NETWORK_EVENTS="onLine"in navigator&&(window.addEventListener||document.body.attachEvent))&&(navigator.onLine||(a.prototype.online=!1))}catch(f){}if(a.prototype.ark={},a.prototype.plugin=function(a){if(d(this,"plugin"),a)return this.ark[a];var b={};for(a in this.ark)b[a]=this.ark[a];return b},a.prototype.reserved=function(a){return/^(incoming|outgoing)::/.test(a)||a in this.reserved.events},a.prototype.reserved.events={readyStateChange:1,reconnecting:1,reconnected:1,reconnect:1,offline:1,timeout:1,online:1,error:1,close:1,open:1,data:1,end:1},a.prototype.initialise=function(b){function c(){f.online&&(f.online=!1,f.emit("offline"),f.end())}function d(){f.online||(f.online=!0,f.emit("online"),~f.options.strategy.indexOf("online")&&f.reconnect())}var e,f=this;f.on("outgoing::open",function(){var b=f.readyState;f.readyState=a.OPENING,b!==f.readyState&&f.emit("readyStateChange","opening"),e=+new Date}),f.on("incoming::open",function(){var b=f.readyState,c=f.attempt;if(f.attempt&&(f.attempt=null),f.writable=!0,f.readable=!0,f.online||(f.online=!0,f.emit("online")),f.readyState=a.OPEN,b!==f.readyState&&f.emit("readyStateChange","open"),f.latency=+new Date-e,f.emit("open"),c&&f.emit("reconnected"),f.clearTimeout("ping","pong").heartbeat(),f.buffer.length){for(var d=0,g=f.buffer.length;g>d;d++)f._write(f.buffer[d]);f.buffer=[]}}),f.on("incoming::pong",function(a){f.online=!0,f.clearTimeout("pong").heartbeat(),f.latency=+new Date-a}),f.on("incoming::error",function(a){var b=f.timers.connect,c=a;if(f.attempt)return f.reconnect();if("string"==typeof a)c=new Error(a);else if(!(a instanceof Error)&&"object"==typeof a){c=new Error(a.message||a.reason);for(var d in a)a.hasOwnProperty(d)&&(c[d]=a[d])}f.listeners("error").length&&f.emit("error",c),b&&(~f.options.strategy.indexOf("timeout")?f.reconnect():f.end())}),f.on("incoming::data",function(a){f.decoder(a,function(b,c){return b?f.listeners("error").length&&f.emit("error",b):void(f.protocol(c)||f.transforms(f,f,"incoming",c,a))})}),f.on("incoming::end",function(){var b=f.readyState;if(f.disconnect)return f.disconnect=!1,f.end();if(f.readyState=a.CLOSED,b!==f.readyState&&f.emit("readyStateChange","end"),f.timers.connect&&f.end(),b===a.OPEN){this.writable=!1,this.readable=!1;for(var c in this.timers)this.clearTimeout(c);if(f.emit("close"),~f.options.strategy.indexOf("disconnect"))return f.reconnect();f.emit("outgoing::end"),f.emit("end")}}),f.client();for(var g in f.ark)f.ark[g].call(f,f,b);return f.NETWORK_EVENTS?(window.addEventListener?(window.addEventListener("offline",c,!1),window.addEventListener("online",d,!1)):document.body.attachEvent&&(document.body.attachEvent("onoffline",c),document.body.attachEvent("ononline",d)),f):f},a.prototype.protocol=function(a){if("string"!=typeof a||0!==a.indexOf("primus::"))return!1;var b=a.indexOf(":",8),c=a.slice(b+2);switch(a.slice(8,b)){case"pong":this.emit("incoming::pong",c);break;case"server":"close"===c&&(this.disconnect=!0);break;case"id":this.emit("incoming::id",c);break;default:return!1}return!0},a.prototype.transforms=function(a,b,c,d,e){var f={data:d},g=a.transformers[c];return function h(a,c){var d=g[a++];if(!d)return c();if(1===d.length){if(!1===d.call(b,f))return;return h(a,c)}d.call(b,f,function(d,e){return d?b.emit("error",d):void(!1!==e&&h(a,c))})}(0,function(){return"incoming"===c?b.emit("data",f.data,e):void b._write(f.data)}),this},a.prototype.id=function(a){return this.socket&&this.socket.id?a(this.socket.id):(this.write("primus::id::"),this.once("incoming::id",a))},a.prototype.open=function(){return d(this,"open"),!this.attempt&&this.options.timeout&&this.timeout(),this.emit("outgoing::open"),this},a.prototype.write=function(a){return d(this,"write"),this.transforms(this,this,"outgoing",a),!0},a.prototype._write=function(b){var c=this;return a.OPEN!==c.readyState?(this.buffer.length===this.options.queueSize&&this.buffer.splice(0,1),this.buffer.push(b),!1):(c.encoder(b,function(a,b){return a?c.listeners("error").length&&c.emit("error",a):void c.emit("outgoing::data",b)}),!0)},a.prototype.heartbeat=function(){function a(){c.clearTimeout("pong"),c.online&&(c.online=!1,c.emit("offline"),c.emit("incoming::end"))}function b(){var b=+new Date;c.clearTimeout("ping").write("primus::ping::"+b),c.emit("outgoing::ping",b),c.timers.pong=setTimeout(a,c.options.pong)}var c=this;return c.options.ping?(c.timers.ping=setTimeout(b,c.options.ping),this):c},a.prototype.timeout=function(){function b(){c.removeListener("error",b).removeListener("open",b).removeListener("end",b).clearTimeout("connect")}var c=this;return c.timers.connect=setTimeout(function(){b(),c.readyState===a.OPEN||c.attempt||(c.emit("timeout"),~c.options.strategy.indexOf("timeout")?c.reconnect():c.end())},c.options.timeout),c.on("error",b).on("open",b).on("end",b)},a.prototype.clearTimeout=function(){for(var a=arguments,b=0,c=a.length;c>b;b++)this.timers[a[b]]&&clearTimeout(this.timers[a[b]]),delete this.timers[a[b]];return this},a.prototype.backoff=function(a,b){b=b||{};var c=this;return b.backoff?c:(b.maxDelay="maxDelay"in b?b.maxDelay:1/0,b.minDelay="minDelay"in b?b.minDelay:500,b.retries="retries"in b?b.retries:10,b.attempt=(+b.attempt||0)+1,b.factor="factor"in b?b.factor:2,b.attempt>b.retries?(a(new Error("Unable to retry"),b),c):(b.backoff=!0,b.timeout=1!==b.attempt?Math.min(Math.round((Math.random()+1)*b.minDelay*Math.pow(b.factor,b.attempt)),b.maxDelay):b.minDelay,c.timers.reconnect=setTimeout(function(){b.backoff=!1,c.clearTimeout("reconnect"),a(void 0,b)},b.timeout),c.emit("reconnecting",b),c))},a.prototype.reconnect=function(){var a=this;return a.attempt=a.attempt||a.clone(a.options.reconnect),a.backoff(function(b,c){return b?(a.attempt=null,a.emit("end")):(a.emit("reconnect",c),void a.emit("outgoing::reconnect"))},a.attempt),a},a.prototype.end=function(b){if(d(this,"end"),this.readyState===a.CLOSED&&!this.timers.connect)return this.timers.reconnect&&(this.clearTimeout("reconnect"),this.attempt=null,this.emit("end")),this;void 0!==b&&this.write(b),this.writable=!1,this.readable=!1;var c=this.readyState;this.readyState=a.CLOSED,c!==this.readyState&&this.emit("readyStateChange","end");for(var e in this.timers)this.clearTimeout(e);return this.emit("outgoing::end"),this.emit("close"),this.emit("end"),this +}},b.prototype._onScreenShareResponse=function(a){var b;return a?(console.log("ossr id =",a),b={audio:!1,video:{mandatory:{chromeMediaSource:"desktop",chromeMediaSourceId:a}}},navigator.webkitGetUserMedia(b,this._onStreamReceived.bind(this),this._onError.bind(this))):this._callback(new e("Screen access rejected."))},b}(f),b.exports=c},{"./config":26,"./screen_share_base":31}],26:[function(a,b,c){var d;d="https:"===location.protocol?"https":"http",c.signalingServer=""+d+"://signaling.cine.io",c.chromeExtension="https://chrome.google.com/webstore/detail/cineio-screen-sharing/ancoeogeclfnhienkmfmeeomadmofhmi"},{}],27:[function(a,b){var c,d,e,f,g={}.hasOwnProperty,h=function(a,b){function c(){this.constructor=a}for(var d in b)g.call(b,d)&&(a[d]=b[d]);return c.prototype=b.prototype,a.prototype=new c,a.__super__=b.prototype,a};f=a("./screen_share_base"),e=f.ScreenSharer,d=f.ScreenShareError,c=function(a){function b(){return b.__super__.constructor.apply(this,arguments)}return h(b,a),b.prototype.share=function(a,c){var d;return b.__super__.share.call(this,a,c),console.log("requesting screen share (moz) ..."),d={audio:this.options.audio,video:{mediaSource:"screen"}},navigator.mozGetUserMedia(d,this._onStreamReceived.bind(this),this._onError.bind(this))},b}(e),b.exports=c},{"./screen_share_base":31}],28:[function(a,b){var c,d,e,f,g,h,i,j,k,l,m,n,o;j=a("getusermedia"),g=a("attachmediastream"),o=a("webrtcsupport"),c=a("backbone-events-standalone"),k=function(){},i={video:!0,audio:!0,autoplay:!0,mirror:!0,muted:!0},n=function(a,b){return Object.prototype.hasOwnProperty.call(a,b)?a[b]:i[b]},e={version:"0.0.6",reset:function(){return e.config={rooms:[],videoElements:{}}},init:function(a){return e.config.publicKey=a,e._signalConnection||(e._signalConnection=m.connect()),e._broadcastBridge=new d(this),setTimeout(e._checkSupport)},identify:function(a,b,c){return e.config.identity={identity:a,timestamp:b,signature:c},e._sendIdentity()},_sendIdentity:function(){return e._signalConnection.write({action:"identify",identity:e.config.identity.identity,timestamp:e.config.identity.timestamp,signature:e.config.identity.signature,publicKey:e.config.publicKey,client:"web"})},sendDataToAll:function(a){return e._signalConnection.sendDataToAllPeers(a)},call:function(a,b,c){var d,f;return null==b&&(b=null),null==c&&(c=k),"function"==typeof b&&(c=b,b=null),f={action:"call",otheridentity:a},e.config.identity&&(f.identity=e.config.identity.identity),b&&(f.room=b),e._signalConnection.write(f),d=function(b){return b.otheridentity===a?(e.off("call-placed",d),c(null,{call:b.call})):void 0},e.on("call-placed",d)},join:function(a,b){return null==b&&(b=k),e.config.rooms.push(a),e._sendJoinRoom(a),setTimeout(b)},leave:function(a,b){var c;return null==b&&(b=k),c=e.config.rooms.indexOf(a),0>c?(e.trigger("error",{msg:"not connected to room",room:a}),setTimeout(b)):(e.config.rooms.splice(c,1),e._signalConnection.write({action:"room-leave",room:a}),setTimeout(b))},startCameraAndMicrophone:function(a){return null==a&&(a=k),e._startMedia({video:!0,audio:!0},a)},stopCameraAndMicrophone:function(a){return null==a&&(a=k),e.microphoneStream&&(e._removeStream(e.microphoneStream,"camera"),delete e.microphoneStream),e.cameraStream&&(e._removeStream(e.cameraStream,"camera"),delete e.cameraStream),e.cameraAndMicrophoneStream&&(e._removeStream(e.cameraAndMicrophoneStream,"camera"),delete e.cameraAndMicrophoneStream),a()},startMicrophone:function(a){return null==a&&(a=k),e._audioCapableStreams().length>0?(e._unmuteAudio(),a()):e.cameraStream&&!e.mutedCamera?(e._removeStream(e.cameraStream,"camera",{silent:!0}),delete e.cameraStream,e.startCameraAndMicrophone(a)):e._startMedia({video:!1,audio:!0},a)},stopMicrophone:function(a){return null==a&&(a=k),e.microphoneStream&&(e._removeStream(e.microphoneStream,"camera"),delete e.microphoneStream),e.cameraAndMicrophoneStream&&(e.mutedCamera?(e._removeStream(e.cameraAndMicrophoneStream,"camera"),delete e.cameraAndMicrophoneStream):e._muteAudio()),a()},startCamera:function(a){return null==a&&(a=k),e._cameraCapableStreams().length>0?(e._unmuteCamera(),a()):e.microphoneStream&&!e.mutedMicrophone?(e._removeStream(e.microphoneStream,"camera",{silent:!0}),delete e.microphoneStream,e.startCameraAndMicrophone(a)):e._startMedia({video:!0,audio:!1},a)},stopCamera:function(a){return null==a&&(a=k),e.cameraStream&&(e._removeStream(e.cameraStream,"camera"),delete e.cameraStream),e.cameraAndMicrophoneStream&&(e.mutedMicrophone?(e._removeStream(e.cameraAndMicrophoneStream,"camera"),delete e.cameraAndMicrophoneStream):e._muteCamera()),a()},cameraRunning:function(){return e.cameraStream?!0:e.cameraAndMicrophoneStream&&!e.mutedCamera},screenShareRunning:function(){return null!=e.screenShareStream},microphoneRunning:function(){return null!=e.microphoneStream?!0:e._audioCapableStreams().length>0&&!e.mutedMicrophone},screenShareSupported:function(){return h.isChrome||h.isFirefox},startScreenShare:function(a,b){var c,d;return null==a&&(a={}),null==b&&(b=k),"function"==typeof a&&(b=a,a={}),e._screenSharer||(e._screenSharer=l.get()),d=setTimeout(e._mediaNotReady("screen"),1e3),c=function(a){return function(c,f){var g;return clearTimeout(d),c?c.extensionRequired?(e.trigger("extension-required",{url:c.url,type:c.type}),b()):(e.trigger("media-rejected",{type:"screen",local:!0}),b(c)):(g=a._createVideoElementFromStream(f,{mirror:!1}),e.screenShareStream=f,e._signalConnection.addLocalStream(f),e.trigger("media-added",{videoElement:g,stream:f,type:"screen",local:!0}),b())}}(this),e._screenSharer.share(a,c)},stopScreenShare:function(a){return null==a&&(a=k),e.screenShareRunning()?(e._removeStream(e.screenShareStream,"screen"),delete e.screenShareStream,a()):a()},broadcastCameraAndMicrophone:function(a,b,c){var d;return null==c&&(c=k),e.isBroadcastingCameraAndMicrophone()?setTimeout(function(){return c("cannot broadcast to multiple endpoints")}):(d=e.cameraAndMicrophoneStream)?(e._isBroadcastingCameraAndMicrophone=!0,e._broadcastBridge.startBroadcast("camera",d,a,b,c)):setTimeout(function(){return c("stream not started")})},stopCameraAndMicrophoneBroadcast:function(a){return null==a&&(a=k),delete e._isBroadcastingCameraAndMicrophone,e._broadcastBridge.stopBroadcast("camera",a)},isBroadcastingCameraAndMicrophone:function(){return null!=e._isBroadcastingCameraAndMicrophone},broadcastScreenShare:function(a,b,c){var d;return null==c&&(c=k),e.isBroadcastingScreenShare()?setTimeout(function(){return c("cannot broadcast to multiple endpoints")}):(d=e.screenShareStream)?(e._isBroadcastingScreenShare=!0,e._broadcastBridge.startBroadcast("screen",d,a,b,c)):setTimeout(function(){return c("stream not started")})},stopScreenShareBroadcast:function(a){return null==a&&(a=k),delete e._isBroadcastingScreenShare,e._broadcastBridge.stopBroadcast("screen",a)},isBroadcastingScreenShare:function(){return null!=e._isBroadcastingScreenShare},_muteAudio:function(){var a,b,c,d;for(d=e.localStreams(),b=0,c=d.length;c>b;b++)a=d[b],e._muteStreamAudio(a);return e.mutedMicrophone=!0},_muteCamera:function(){var a,b,c,d;for(d=e._cameraCapableStreams(),b=0,c=d.length;c>b;b++)a=d[b],e._muteStreamVideo(a);return e.mutedCamera=!0},_unmuteAudio:function(){var a;return a=e._audioCapableStreams()[0],a?e._unmuteStreamAudio(a):e.startMicrophone(),delete e.mutedMicrophone},_unmuteCamera:function(){var a;return a=e._cameraCapableStreams()[0],a?e._unmuteStreamVideo(a):e.startCamera(),delete e.mutedCamera},_removeStream:function(a,b,c){return null==c&&(c={}),a.stop(),e._signalConnection.removeLocalStream(a,c),e.trigger("media-removed",{local:!0,type:b,videoElement:e.config.videoElements[a.id]}),delete e.config.videoElements[a.id]},_muteStreamAudio:function(a){return a?e._disableTracks(a.getAudioTracks()):void 0},_unmuteStreamAudio:function(a){return a?e._enableTracks(a.getAudioTracks()):void 0},_muteStreamVideo:function(a){return a?e._disableTracks(a.getVideoTracks()):void 0},_unmuteStreamVideo:function(a){return a?e._enableTracks(a.getVideoTracks()):void 0},_enableTracks:function(a){var b,c,d,e;for(e=[],c=0,d=a.length;d>c;c++)b=a[c],e.push(b.enabled=!0);return e},_disableTracks:function(a){var b,c,d,e;for(e=[],c=0,d=a.length;d>c;c++)b=a[c],e.push(b.enabled=!1);return e},localStreams:function(){var a;return a=[],e.cameraAndMicrophoneStream&&a.push(e.cameraAndMicrophoneStream),e.cameraStream&&a.push(e.cameraStream),e.microphoneStream&&a.push(e.microphoneStream),e.screenShareStream&&a.push(e.screenShareStream),a},_cameraCapableStreams:function(){var a;return a=[],e.cameraAndMicrophoneStream&&a.push(e.cameraAndMicrophoneStream),e.cameraStream&&a.push(e.cameraStream),a},_audioCapableStreams:function(){var a;return a=[],e.cameraAndMicrophoneStream&&a.push(e.cameraAndMicrophoneStream),e.microphoneStream&&a.push(e.microphoneStream),a},_startMedia:function(a,b){var c;return null==b&&(b=k),e.cameraAndMicrophoneStream&&a.video&&a.audio?setTimeout(b):e.cameraStream&&a.video?setTimeout(b):e.microphoneStream&&a.audio?setTimeout(b):(c=setTimeout(e._mediaNotReady("camera"),1e3),e._askForMedia(a,function(d,f){return clearTimeout(c),d?(e.trigger("media-rejected",{type:"camera",local:!0}),b(d)):(a.video&&a.audio?(e.cameraAndMicrophoneStream=f.stream,delete e.mutedMicrophone,delete e.mutedCamera):a.video?(e.cameraStream=f.stream,delete e.mutedCamera):a.audio&&(e.microphoneStream=f.stream,delete e.mutedMicrophone),e.trigger("media-added",{videoElement:f.videoElement,stream:f.stream,type:"camera",video:a.video,audio:a.audio,local:!0}),e._signalConnection.addLocalStream(f.stream),b())}))},_checkSupport:function(){return o.support?e.trigger("info",{support:!0}):e.trigger("error",{support:!1})},_sendJoinRoom:function(a){return e._signalConnection.write({action:"room-join",room:a})},_mediaNotReady:function(a){return function(){return e.trigger("media-request",{local:!0,type:a})}},_askForMedia:function(a,b){var c;return null==a&&(a={}),"function"==typeof a&&(b=a,a={}),c={video:n(a,"video"),audio:n(a,"audio")},e._unsafeGetUserMedia(c,function(c){return function(d,e){var f;return d?b(d):(f=c._createVideoElementFromStream(e,a),b(null,{videoElement:f,stream:e}))}}(this))},_unsafeGetUserMedia:function(a,b){return j(a,b)},_createVideoElementFromStream:function(a,b){var c,d;return null==b&&(b={}),d={autoplay:n(b,"autoplay"),mirror:n(b,"mirror"),muted:n(b,"muted")},c=g(a,null,d),e.config.videoElements[a.id]=c,c},_getVideoElementFromStream:function(a){return e.config.videoElements[a.id]}},e.reset(),c.mixin(e),"undefined"!=typeof window&&(window.CineIOPeer=e),b.exports=e,f=a("./config"),m=a("./signaling_connection"),l=a("./screen_sharer"),h=a("./browser_detect"),d=a("./broadcast_bridge")},{"./broadcast_bridge":22,"./browser_detect":23,"./config":26,"./screen_sharer":32,"./signaling_connection":33,attachmediastream:1,"backbone-events-standalone":3,getusermedia:4,webrtcsupport:21}],29:[function(a,b){var c,d,e,f,g;e=a("jsonp"),c="https://www.cine.io/api/1/-/nearest-server?default=ok",f=null,d=null,g=null,b.exports=function(a){return f?a(null,f):d?g.push(a):(d=!0,b.exports._makeJsonpCall(c,function(b,c){var d,e,h;for(f=c,e=0,h=g.length;h>e;e++)(d=g[e])(b,f);return g=[],a(b,f)}))},b.exports._makeJsonpCall=function(a,b){return e(a,b)},b.exports._reset=function(){return f=null,d=!1,g=[]},b.exports._reset()},{jsonp:9}],30:[function(a,b,c){var d,e,f;e=a("rtcpeerconnection"),f=null,c.create=function(){return f?c._actuallyCreatePeerConnection({iceServers:f}):null},c._actuallyCreatePeerConnection=function(a){return new e(a)},c._reset=function(){return f=null},d=a("./main"),d.on("gotIceServers",function(a){return f=a})},{"./main":28,rtcpeerconnection:20}],31:[function(a,b){var c,d,e,f;f=a("webrtcsupport"),d=function(){function a(a,b){var c,d;this.msg=a;for(c in b)d=b[c],this[c]=d}return a}(),e=function(){function a(){}return a.prototype.share=function(a,b){return this.options=a,this._callback=b,window&&navigator?f.screenSharing?void 0:this._callback(new d("Screen sharing not implemented in this browser / environment.")):this._callback(new d("Screen sharing requires a browser environment!"))},a.prototype._onStreamReceived=function(a){return console.log("Received local stream:",a),a.onended=this._onStreamEnded.bind(this),this._callback(null,a)},a.prototype._onStreamEnded=function(){console.log("Screen share ended."),c.stopScreenShare()},a.prototype._onError=function(a){var b;return b=a.name?a.name+(a.message?" ("+a.message+")":""):a,b="Screen share failed: "+b,console.dir(a),console.log(b),this._callback(new d(b))},a}(),b.exports={ScreenShareError:d,ScreenSharer:e},c=a("./main")},{"./main":28,webrtcsupport:21}],32:[function(a,b){var c,d,e;c=a("./screen_share_base").ScreenShareError,e=a("./browser_detect"),d={get:function(b,d){var f,g;return null==b&&(b={}),b.hasOwnProperty("audio")||(b.audio=!1),e.isChrome?new(f=a("./chrome_screen_sharer"))(b,d):e.isFirefox?new(g=a("./firefox_screen_sharer"))(b,d):d(new c("Screen sharing not implemented in this browser / environment."))}},b.exports=d},{"./browser_detect":23,"./chrome_screen_sharer":25,"./firefox_screen_sharer":27,"./screen_share_base":31}],33:[function(a,b,c){var d,e,f,g,h,i,j,k,l,m,n,o,p=function(a,b){return function(){return a.apply(b,arguments)}};o=a("./vendor/uuid"),i=a("./peer_connection_factory"),j=a("./vendor/primus"),f=a("./config"),l=function(){},k=function(){return j.connect(f.signalingServer)},h=1,m=function(a,b){return"open"===a.readyState?a.send(JSON.stringify(b)):a.dataToSend.push(b)},n=function(a,b){return a.otherClientSparkId=b},g=function(){function a(a){this.options=a,this._ensureIce=p(this._ensureIce,this),this._ensureReady=p(this._ensureReady,this),this._ensurePeerConnection=p(this._ensurePeerConnection,this),this._newMember=p(this._newMember,this),this._sendOffer=p(this._sendOffer,this),this._closePeerConnection=p(this._closePeerConnection,this),this._signalHandler=p(this._signalHandler,this),this._onConnectionOpen=p(this._onConnectionOpen,this),this.removeLocalStream=p(this.removeLocalStream,this),this.addLocalStream=p(this.addLocalStream,this),this.write=p(this.write,this),this.myUUID=o(),this.iceServers=null,this.fetchedIce=!1,this.peerConnections={},this.calls={},this.primus=k(),this.primus.on("open",this._onConnectionOpen),this.primus.on("data",this._signalHandler),this.primus.on("end",this._connectionEnded)}return a.prototype.write=function(a){var b;return a.client="cineio-peer-js version-"+e.version,a.publicKey=e.config.publicKey,a.uuid=this.myUUID,e.config.identity&&(a.identity=e.config.identity.identity),console.log("Writing",a),(b=this.primus).write.apply(b,arguments)},a.prototype.addLocalStream=function(a,b){var c,d,e,f;null==b&&(b={}),e=this.peerConnections,f=[];for(c in e)d=e[c],console.log("adding local stream "+a.id+" to "+c),d.addStream(a),f.push(b.silent?void 0:this._sendOffer(d));return f},a.prototype.removeLocalStream=function(a,b){var c,d,e,f;null==b&&(b={}),e=this.peerConnections,f=[];for(c in e)d=e[c],console.log("removing local stream "+a.id+" from "+c),d.removeStream(a),f.push(b.silent?void 0:this._sendOffer(d));return f},a.prototype.sendDataToAllPeers=function(a){var b,c,d,e;d=this.peerConnections,e=[];for(b in d)c=d[b],console.log("sending data "+a+" to "+b),e.push(this._sendDataToPeer(c,a));return e},a.prototype._sendDataToPeer=function(a,b){return a.mainDataChannel||(a.mainDataChannel=this._newDataChannel(a),this._sendOffer(a)),m(a.mainDataChannel,{action:"userData",data:b})},a.prototype._newDataChannel=function(a){var b;return b=a.createDataChannel("CINE",{ordered:!1,maxRetransmitTime:3e3}),this._prepareDataChannel(a,b),b},a.prototype._prepareDataChannel=function(a,b){return b.dataToSend=[],b.onopen=function(a){var c,d,e,f;if(console.log("ON OPEN",a),"open"===b.readyState){for(f=b.dataToSend,d=0,e=f.length;e>d;d++)c=f[d],console.log("Actually sending data",c),m(b,c);return delete b.dataToSend}},b.onmessage=function(a){var b;return a&&a.data&&(b=JSON.parse(a.data),"userData"===b.action)?e.trigger("peer-data",b.data):void 0},b},a.prototype._onConnectionOpen=function(){var a,b,c,d,f;for(this.write({action:"auth"}),e.config.identity&&e._sendIdentity(),d=e.config.rooms,f=[],b=0,c=d.length;c>b;b++)a=d[b],f.push(e._sendJoinRoom(a));return f},a.prototype._connectionEnded=function(){return console.log("Connection closed")},a.prototype._callFromRoom=function(a,b){var c;return(c=this.calls)[a]||(c[a]=new d(a,b)),this.calls[a]},a.prototype._signalHandler=function(a){var b;switch(a.action){case"error":return e.trigger("error",a);case"rtc-servers":return console.log("setting config",a),this.iceServers=a.data,this.fetchedIce=!0,e.trigger("gotIceServers",a.data);case"ack":if("call"===a.source)return e.config.rooms.push(a.room),b=this._callFromRoom(a.room,{initiated:!0,called:a.otheridentity}),e.trigger("call-placed",{call:b,otheridentity:a.otheridentity});break;case"call":return e.trigger("call",{identity:a.identity,call:this._callFromRoom(a.room)});case"call-cancel":return this._callFromRoom(a.room).trigger("call-cancel",{identity:a.identity});case"call-reject":return this._callFromRoom(a.room).trigger("call-reject",{identity:a.identity});case"room-leave":return console.log("room-leave",a),a.identity&&this._callFromRoom(a.room).left(a.identity),this.write({action:"room-goodbye",sparkId:a.sparkId},a.room),this._closePeerConnection(a);case"room-join":return console.log("room-join",a),a.identity&&this._callFromRoom(a.room).joined(a.identity),this._ensurePeerConnection(a,{offer:!0}),this.write({action:"room-announce",sparkId:a.sparkId,room:a.room});case"room-announce":return console.log("room-announce",a),this._ensurePeerConnection(a,{offer:!1});case"room-goodbye":return console.log("room-goodbye",a),this._closePeerConnection(a);case"rtc-ice":if(!a.sparkId)return;return this._ensurePeerConnection(a,{offer:!1},function(b,c){return c.processIce(a.candidate)});case"rtc-offer":return console.log("got offer",a),this._ensurePeerConnection(a,{offer:!1},function(b){return function(c,d){return d.handleOffer(a.offer,function(){var c;return c=function(c,d){return b.write({action:"rtc-answer",answer:d,sparkId:a.sparkId})},d.answer(0===e.localStreams().length?c:c)})}}(this));case"rtc-answer":return this._ensurePeerConnection(a,{offer:!1},function(b,c){return c.handleAnswer(a.answer)})}},a.prototype._closePeerConnection=function(a){var b;return b=a.sparkUUID,this.peerConnections[b]&&this.peerConnections[b]!==h?(this.peerConnections[b].close(),delete this.peerConnections[b]):void 0},a.prototype._sendOffer=function(a){var b,c;return c=function(b){return function(c,d){var f;return f=a.otherClientSparkId,c||!d?(console.log("FATAL ERROR in offer",c,d),e.trigger("error",{kind:"offer",fatal:!0,err:c})):(console.log("offering",c,f,d),b.write({action:"rtc-offer",offer:d,sparkId:f}))}}(this),b={mandatory:{OfferToReceiveAudio:!0,OfferToReceiveVideo:!0}},a.mainDataChannel&&(b.optional=[{RtpDataChannels:!0}]),a.offer(b,c)},a.prototype._onCloseOfPeerConnection=function(a){var b,c,d,f;if(a.videoEls){for(f=a.videoEls,c=0,d=f.length;d>c;c++)b=f[c],e.trigger("media-removed",{peerConnection:a,videoElement:b,remote:!0});return delete a.videoEls}},a.prototype._newMember=function(a,b,c,d){return this.peerConnections[a]?this._ensureReady(function(b){return function(){return d(null,b.peerConnections[a])}}(this)):(this.peerConnections[a]=h,this._ensureReady(function(f){return function(){var g,h,j,k,l;for(console.log("CREATING NEW PEER CONNECTION!!",a,c),g=i.create(),f.peerConnections[a]=g,g.videoEls=[],n(g,b),l=e.localStreams(),j=0,k=l.length;k>j;j++)h=l[j],g.addStream(h);return g.on("addStream",function(a){var b;return console.log("got remote stream",a),b=e._createVideoElementFromStream(a.stream,{muted:!1,mirror:!1}),g.videoEls.push(b),e.trigger("media-added",{peerConnection:g,videoElement:b,remote:!0})}),g.on("removeStream",function(a){var b,c;return console.log("removing remote stream",a),c=e._getVideoElementFromStream(a.stream),b=g.videoEls.indexOf(c),b>-1&&g.videoEls.splice(b,1),e.trigger("media-removed",{peerConnection:g,videoElement:c,remote:!0})}),g.on("addChannel",function(a){return console.log("GOT A NEW DATA CHANNEL",a),g.mainDataChannel=f._prepareDataChannel(g,a)}),g.on("ice",function(a){return f.write({action:"rtc-ice",candidate:a,sparkId:g.otherClientSparkId})}),(c.offer&&e.localStreams().length>0||g.mainDataChannel)&&f._sendOffer(g),g.on("close",function(){return f._onCloseOfPeerConnection(g),delete f.peerConnections[a]}),d(null,g),e.trigger("peerConnectionMade")}}(this)))},a.prototype._ensurePeerConnection=function(a,b,c){var d,e,f;return null==c&&(c=l),e=a.sparkId,f=a.sparkUUID,d=this.peerConnections[f],d&&d!==h?(n(d,e),setTimeout(function(){return c(null,d)})):this._newMember(f,e,b,c)},a.prototype._ensureReady=function(a){return this._ensureIce(a)},a.prototype._ensureIce=function(a){return this.fetchedIce?setTimeout(a):e.once("gotIceServers",a)},a}(),c.connect=function(a){return new g(a)},e=a("./main"),d=a("./call")},{"./call":24,"./config":26,"./main":28,"./peer_connection_factory":30,"./vendor/primus":34,"./vendor/uuid":35}],34:[function(require,module,exports){!function(a,b,c){b[a]=c.call(b),"undefined"!=typeof module&&module.exports?module.exports=b[a]:"function"==typeof define&&define.amd&&define(function(){return b[a]})}("Primus",this,function a(){"use strict";function b(a,b,c){this.fn=a,this.context=b,this.once=c||!1}function c(){}function d(b,c){if(!(b instanceof a)){var d=new Error("Primus#"+c+"'s context should called with a Primus instance");if("function"!=typeof b.listeners||!b.listeners("error").length)throw d;b.emit("error",d)}}function a(b,d){if(!(this instanceof a))return new a(b,d);if("function"!=typeof this.client){var f="The client library has not been compiled correctly, see https://github.com/primus/primus#client-library for more details";return this.critical(new Error(f))}"object"==typeof b?(d=b,b=d.url||d.uri||e):d=d||{};var h=this;d.queueSize="queueSize"in d?d.queueSize:1/0,d.timeout="timeout"in d?d.timeout:1e4,d.reconnect="reconnect"in d?d.reconnect:{},d.ping="ping"in d?d.ping:25e3,d.pong="pong"in d?d.pong:1e4,d.strategy="strategy"in d?d.strategy:[],d.transport="transport"in d?d.transport:{},h.buffer=[],h.writable=!0,h.readable=!0,h.url=h.parse(b||e),h.readyState=a.CLOSED,h.options=d,h.timers={},h.attempt=null,h.socket=null,h.latency=0,h.stamps=0,h.disconnect=!1,h.transport=d.transport,h.transformers={outgoing:[],incoming:[]},"string"==typeof d.strategy&&(d.strategy=d.strategy.split(/\s?\,\s?/g)),!1===d.strategy?d.strategy=[]:d.strategy.length||(d.strategy.push("disconnect","online"),this.authorization||d.strategy.push("timeout")),d.strategy=d.strategy.join(",").toLowerCase(),g||c.call(h),"websockets"in d&&(h.AVOID_WEBSOCKETS=!d.websockets),"network"in d&&(h.NETWORK_EVENTS=d.network),d.manual||(h.timers.open=setTimeout(function(){h.clearTimeout("open").open()},0)),h.initialise(d)}c.prototype._events=void 0,c.prototype.listeners=function(a){if(!this._events||!this._events[a])return[];for(var b=0,c=this._events[a].length,d=[];c>b;b++)d.push(this._events[a][b].fn);return d},c.prototype.emit=function(a,b,c,d,e,f){if(!this._events||!this._events[a])return!1;var g,h,i,j=this._events[a],k=j.length,l=arguments.length,m=j[0];if(1===k){switch(m.once&&this.removeListener(a,m.fn,!0),l){case 1:return m.fn.call(m.context),!0;case 2:return m.fn.call(m.context,b),!0;case 3:return m.fn.call(m.context,b,c),!0;case 4:return m.fn.call(m.context,b,c,d),!0;case 5:return m.fn.call(m.context,b,c,d,e),!0;case 6:return m.fn.call(m.context,b,c,d,e,f),!0}for(h=1,g=new Array(l-1);l>h;h++)g[h-1]=arguments[h];m.fn.apply(m.context,g)}else for(h=0;k>h;h++)switch(j[h].once&&this.removeListener(a,j[h].fn,!0),l){case 1:j[h].fn.call(j[h].context);break;case 2:j[h].fn.call(j[h].context,b);break;case 3:j[h].fn.call(j[h].context,b,c);break;default:if(!g)for(i=1,g=new Array(l-1);l>i;i++)g[i-1]=arguments[i];j[h].fn.apply(j[h].context,g)}return!0},c.prototype.on=function(a,c,d){return this._events||(this._events={}),this._events[a]||(this._events[a]=[]),this._events[a].push(new b(c,d||this)),this},c.prototype.once=function(a,c,d){return this._events||(this._events={}),this._events[a]||(this._events[a]=[]),this._events[a].push(new b(c,d||this,!0)),this},c.prototype.removeListener=function(a,b,c){if(!this._events||!this._events[a])return this;var d=this._events[a],e=[];if(b)for(var f=0,g=d.length;g>f;f++)d[f].fn!==b&&d[f].once!==c&&e.push(d[f]);return this._events[a]=e.length?e:null,this},c.prototype.removeAllListeners=function(a){return this._events?(a?this._events[a]=null:this._events={},this):this},c.prototype.off=c.prototype.removeListener,c.prototype.addListener=c.prototype.on,c.prototype.setMaxListeners=function(){return this};var e;try{e=location.origin?location.origin:location.protocol+"//"+location.hostname+(location.port?":"+location.port:"")}catch(f){e="http://127.0.0.1"}a.require=function(a){return"function"!=typeof require?void 0:"function"==typeof define&&define.amd?void 0:require(a)};var g,h;try{a.Stream=g=a.require("stream"),h=a.require("url").parse,a.require("util").inherits(a,g)}catch(f){a.Stream=c,a.prototype=new c,h=function(a){var b,c=document.createElement("a"),d={};c.href=a;for(b in c)("string"==typeof c[b]||"number"==typeof c[b])&&(d[b]=c[b]);if(!d.port){var e=(d.href||"").split("/");if(e.length>2){var f=e[2],g=f.lastIndexOf("@");~g&&(f=f.slice(g+1)),e=f.split(":"),2===e.length&&(d.port=e[1])}}if(":"===d.protocol&&(d.protocol=d.href.substr(0,d.href.indexOf(":")+1)),"0"===d.port&&(d.port=""),~d.href.indexOf("@")&&!d.auth){var h=d.protocol.length+2;d.auth=d.href.slice(h,d.href.indexOf(d.pathname,h)).split("@")[0]}return d}}a.OPENING=1,a.CLOSED=2,a.OPEN=3,a.prototype.AVOID_WEBSOCKETS=!1,a.prototype.NETWORK_EVENTS=!1,a.prototype.online=!0;try{(a.prototype.NETWORK_EVENTS="onLine"in navigator&&(window.addEventListener||document.body.attachEvent))&&(navigator.onLine||(a.prototype.online=!1))}catch(f){}if(a.prototype.ark={},a.prototype.plugin=function(a){if(d(this,"plugin"),a)return this.ark[a];var b={};for(a in this.ark)b[a]=this.ark[a];return b},a.prototype.reserved=function(a){return/^(incoming|outgoing)::/.test(a)||a in this.reserved.events},a.prototype.reserved.events={readyStateChange:1,reconnecting:1,reconnected:1,reconnect:1,offline:1,timeout:1,online:1,error:1,close:1,open:1,data:1,end:1},a.prototype.initialise=function(b){function c(){f.online&&(f.online=!1,f.emit("offline"),f.end())}function d(){f.online||(f.online=!0,f.emit("online"),~f.options.strategy.indexOf("online")&&f.reconnect())}var e,f=this;f.on("outgoing::open",function(){var b=f.readyState;f.readyState=a.OPENING,b!==f.readyState&&f.emit("readyStateChange","opening"),e=+new Date}),f.on("incoming::open",function(){var b=f.readyState,c=f.attempt;if(f.attempt&&(f.attempt=null),f.writable=!0,f.readable=!0,f.online||(f.online=!0,f.emit("online")),f.readyState=a.OPEN,b!==f.readyState&&f.emit("readyStateChange","open"),f.latency=+new Date-e,f.emit("open"),c&&f.emit("reconnected"),f.clearTimeout("ping","pong").heartbeat(),f.buffer.length){for(var d=0,g=f.buffer.length;g>d;d++)f._write(f.buffer[d]);f.buffer=[]}}),f.on("incoming::pong",function(a){f.online=!0,f.clearTimeout("pong").heartbeat(),f.latency=+new Date-a}),f.on("incoming::error",function(a){var b=f.timers.connect,c=a;if(f.attempt)return f.reconnect();if("string"==typeof a)c=new Error(a);else if(!(a instanceof Error)&&"object"==typeof a){c=new Error(a.message||a.reason);for(var d in a)a.hasOwnProperty(d)&&(c[d]=a[d])}f.listeners("error").length&&f.emit("error",c),b&&(~f.options.strategy.indexOf("timeout")?f.reconnect():f.end())}),f.on("incoming::data",function(a){f.decoder(a,function(b,c){return b?f.listeners("error").length&&f.emit("error",b):void(f.protocol(c)||f.transforms(f,f,"incoming",c,a))})}),f.on("incoming::end",function(){var b=f.readyState;if(f.disconnect)return f.disconnect=!1,f.end();if(f.readyState=a.CLOSED,b!==f.readyState&&f.emit("readyStateChange","end"),f.timers.connect&&f.end(),b===a.OPEN){this.writable=!1,this.readable=!1;for(var c in this.timers)this.clearTimeout(c);if(f.emit("close"),~f.options.strategy.indexOf("disconnect"))return f.reconnect();f.emit("outgoing::end"),f.emit("end")}}),f.client();for(var g in f.ark)f.ark[g].call(f,f,b);return f.NETWORK_EVENTS?(window.addEventListener?(window.addEventListener("offline",c,!1),window.addEventListener("online",d,!1)):document.body.attachEvent&&(document.body.attachEvent("onoffline",c),document.body.attachEvent("ononline",d)),f):f},a.prototype.protocol=function(a){if("string"!=typeof a||0!==a.indexOf("primus::"))return!1;var b=a.indexOf(":",8),c=a.slice(b+2);switch(a.slice(8,b)){case"pong":this.emit("incoming::pong",c);break;case"server":"close"===c&&(this.disconnect=!0);break;case"id":this.emit("incoming::id",c);break;default:return!1}return!0},a.prototype.transforms=function(a,b,c,d,e){var f={data:d},g=a.transformers[c];return function h(a,c){var d=g[a++];if(!d)return c();if(1===d.length){if(!1===d.call(b,f))return;return h(a,c)}d.call(b,f,function(d,e){return d?b.emit("error",d):void(!1!==e&&h(a,c))})}(0,function(){return"incoming"===c?b.emit("data",f.data,e):void b._write(f.data)}),this},a.prototype.id=function(a){return this.socket&&this.socket.id?a(this.socket.id):(this.write("primus::id::"),this.once("incoming::id",a))},a.prototype.open=function(){return d(this,"open"),!this.attempt&&this.options.timeout&&this.timeout(),this.emit("outgoing::open"),this},a.prototype.write=function(a){return d(this,"write"),this.transforms(this,this,"outgoing",a),!0},a.prototype._write=function(b){var c=this;return a.OPEN!==c.readyState?(this.buffer.length===this.options.queueSize&&this.buffer.splice(0,1),this.buffer.push(b),!1):(c.encoder(b,function(a,b){return a?c.listeners("error").length&&c.emit("error",a):void c.emit("outgoing::data",b)}),!0)},a.prototype.heartbeat=function(){function a(){c.clearTimeout("pong"),c.online&&(c.online=!1,c.emit("offline"),c.emit("incoming::end"))}function b(){var b=+new Date;c.clearTimeout("ping").write("primus::ping::"+b),c.emit("outgoing::ping",b),c.timers.pong=setTimeout(a,c.options.pong)}var c=this;return c.options.ping?(c.timers.ping=setTimeout(b,c.options.ping),this):c},a.prototype.timeout=function(){function b(){c.removeListener("error",b).removeListener("open",b).removeListener("end",b).clearTimeout("connect")}var c=this;return c.timers.connect=setTimeout(function(){b(),c.readyState===a.OPEN||c.attempt||(c.emit("timeout"),~c.options.strategy.indexOf("timeout")?c.reconnect():c.end())},c.options.timeout),c.on("error",b).on("open",b).on("end",b)},a.prototype.clearTimeout=function(){for(var a=arguments,b=0,c=a.length;c>b;b++)this.timers[a[b]]&&clearTimeout(this.timers[a[b]]),delete this.timers[a[b]];return this},a.prototype.backoff=function(a,b){b=b||{};var c=this;return b.backoff?c:(b.maxDelay="maxDelay"in b?b.maxDelay:1/0,b.minDelay="minDelay"in b?b.minDelay:500,b.retries="retries"in b?b.retries:10,b.attempt=(+b.attempt||0)+1,b.factor="factor"in b?b.factor:2,b.attempt>b.retries?(a(new Error("Unable to retry"),b),c):(b.backoff=!0,b.timeout=1!==b.attempt?Math.min(Math.round((Math.random()+1)*b.minDelay*Math.pow(b.factor,b.attempt)),b.maxDelay):b.minDelay,c.timers.reconnect=setTimeout(function(){b.backoff=!1,c.clearTimeout("reconnect"),a(void 0,b)},b.timeout),c.emit("reconnecting",b),c))},a.prototype.reconnect=function(){var a=this;return a.attempt=a.attempt||a.clone(a.options.reconnect),a.backoff(function(b,c){return b?(a.attempt=null,a.emit("end")):(a.emit("reconnect",c),void a.emit("outgoing::reconnect"))},a.attempt),a},a.prototype.end=function(b){if(d(this,"end"),this.readyState===a.CLOSED&&!this.timers.connect)return this.timers.reconnect&&(this.clearTimeout("reconnect"),this.attempt=null,this.emit("end")),this;void 0!==b&&this.write(b),this.writable=!1,this.readable=!1;var c=this.readyState;this.readyState=a.CLOSED,c!==this.readyState&&this.emit("readyStateChange","end");for(var e in this.timers)this.clearTimeout(e);return this.emit("outgoing::end"),this.emit("close"),this.emit("end"),this },a.prototype.clone=function(a){return this.merge({},a)},a.prototype.merge=function(a){for(var b,c,d=Array.prototype.slice.call(arguments,1),e=0,f=d.length;f>e;e++){c=d[e];for(b in c)c.hasOwnProperty(b)&&(a[b]=c[b])}return a},a.prototype.parse=h,a.prototype.querystring=function(a){for(var b,c=/([^=?&]+)=([^&]*)/g,d={};b=c.exec(a);d[decodeURIComponent(b[1])]=decodeURIComponent(b[2]));return d},a.prototype.querystringify=function(a){var b=[];for(var c in a)a.hasOwnProperty(c)&&b.push(encodeURIComponent(c)+"="+encodeURIComponent(a[c]));return b.join("&")},a.prototype.uri=function(a){var b=this.url,c=[],d=!1;a.query&&(d=!0),a=a||{},a.protocol="protocol"in a?a.protocol:"http",a.query=b.search&&"query"in a?"?"===b.search.charAt(0)?b.search.slice(1):b.search:!1,a.secure="secure"in a?a.secure:"https:"===b.protocol||"wss:"===b.protocol,a.auth="auth"in a?a.auth:b.auth,a.pathname="pathname"in a?a.pathname:this.pathname.slice(1),a.port="port"in a?+a.port:+b.port||(a.secure?443:80),a.host="host"in a?a.host:b.hostname||b.host.replace(":"+b.port,""),this.emit("outgoing::url",a);var e=443!==a.port&&80!==a.port?a.host+":"+a.port:a.host,f=this.querystring(a.query||"");return f._primuscb=+new Date+"-"+this.stamps++,a.query=this.querystringify(f),c.push(a.secure?a.protocol+"s:":a.protocol+":",""),c.push(a.auth?a.auth+"@"+e:e),a.pathname&&c.push(a.pathname),d?c.push("?"+a.query):delete a.query,a.object?a:c.join("/")},a.prototype.emits=function(a,b){var c=this;return function(d){var e=b?b.apply(c,arguments):d;setTimeout(function(){c.emit("incoming::"+a,e)},0)}},a.prototype.transform=function(a,b){return d(this,"transform"),a in this.transformers?(this.transformers[a].push(b),this):this.critical(new Error("Invalid transformer type"))},a.prototype.critical=function(a){if(this.listeners("error").length)return this.emit("error",a),this;throw a},a.connect=function(b,c){return new a(b,c)},a.EventEmitter=c,a.prototype.client=function(){var b,c=this,d=function(){if("undefined"!=typeof SockJS)return SockJS;try{return a.require("sockjs-client-node")}catch(b){}return void 0}();return d?(c.on("outgoing::open",function(){c.emit("outgoing::end"),c.socket=b=new d(c.uri({protocol:"http"}),null,c.merge(c.transport,{info:{websocket:!c.AVOID_WEBSOCKETS,cookie_needed:!0}})),b.onopen=c.emits("open"),b.onerror=c.emits("error"),b.onclose=function(a){setTimeout(function(){a&&a.code>1e3&&c.emit("incoming::error",a),c.emit("incoming::end")},0)},b.onmessage=c.emits("data",function(a){return a.data})}),c.on("outgoing::data",function(a){b&&b.send(a)}),c.on("outgoing::reconnect",function(){c.emit("outgoing::end"),c.emit("outgoing::open")}),void c.on("outgoing::end",function(){b&&(b.onerror=b.onopen=b.onclose=b.onmessage=function(){},b.close(),b=null)})):c.critical(new Error("Missing required `sockjs-client-node` module. Please run `npm install --save sockjs-client-node`"))},a.prototype.authorization=!1,a.prototype.pathname="/primus",a.prototype.encoder=function(a,b){var c;try{a=JSON.stringify(a)}catch(d){c=d}b(c,a)},a.prototype.decoder=function(a,b){var c;if("string"!=typeof a)return b(c,a);try{a=JSON.parse(a)}catch(d){c=d}b(c,a)},a.prototype.version="2.4.5","object"==typeof JSON&&"function"==typeof JSON.stringify&&'["\u2028\u2029"]'===JSON.stringify(["\u2028\u2029"])&&(JSON.stringify=function(a){var b=/\u2028/g,c=/\u2029/g;return function(d,e,f){var g=a.call(this,d,e,f);return g&&(~g.indexOf("\u2028")&&(g=g.replace(b,"\\u2028")),~g.indexOf("\u2029")&&(g=g.replace(c,"\\u2029"))),g}}(JSON.stringify)),"undefined"!=typeof document&&"undefined"!=typeof navigator){document.addEventListener&&document.addEventListener("keydown",function(a){27===a.keyCode&&a.preventDefault&&a.preventDefault()},!1);var i=(navigator.userAgent||"").toLowerCase(),j=i.match(/.+(?:rv|it|ra|ie)[\/: ](\d+)\.(\d+)(?:\.(\d+))?/)||[],k=+[j[1],j[2]].join(".");!~i.indexOf("chrome")&&~i.indexOf("safari")&&534.54>k&&(a.prototype.AVOID_WEBSOCKETS=!0)}return a});var JSON;JSON||(JSON={}),function(){function str(a,b){var c,d,e,f,g,h=gap,i=b[a];switch(i&&"object"==typeof i&&"function"==typeof i.toJSON&&(i=i.toJSON(a)),"function"==typeof rep&&(i=rep.call(b,a,i)),typeof i){case"string":return quote(i);case"number":return isFinite(i)?String(i):"null";case"boolean":case"null":return String(i);case"object":if(!i)return"null";if(gap+=indent,g=[],"[object Array]"===Object.prototype.toString.apply(i)){for(f=i.length,c=0;f>c;c+=1)g[c]=str(c,i)||"null";return e=0===g.length?"[]":gap?"[\n"+gap+g.join(",\n"+gap)+"\n"+h+"]":"["+g.join(",")+"]",gap=h,e}if(rep&&"object"==typeof rep)for(f=rep.length,c=0;f>c;c+=1)"string"==typeof rep[c]&&(d=rep[c],e=str(d,i),e&&g.push(quote(d)+(gap?": ":":")+e));else for(d in i)Object.prototype.hasOwnProperty.call(i,d)&&(e=str(d,i),e&&g.push(quote(d)+(gap?": ":":")+e));return e=0===g.length?"{}":gap?"{\n"+gap+g.join(",\n"+gap)+"\n"+h+"}":"{"+g.join(",")+"}",gap=h,e}}function quote(a){return escapable.lastIndex=0,escapable.test(a)?'"'+a.replace(escapable,function(a){var b=meta[a];return"string"==typeof b?b:"\\u"+("0000"+a.charCodeAt(0).toString(16)).slice(-4)})+'"':'"'+a+'"'}function f(a){return 10>a?"0"+a:a}"function"!=typeof Date.prototype.toJSON&&(Date.prototype.toJSON=function(){return isFinite(this.valueOf())?this.getUTCFullYear()+"-"+f(this.getUTCMonth()+1)+"-"+f(this.getUTCDate())+"T"+f(this.getUTCHours())+":"+f(this.getUTCMinutes())+":"+f(this.getUTCSeconds())+"Z":null},String.prototype.toJSON=Number.prototype.toJSON=Boolean.prototype.toJSON=function(){return this.valueOf()});var cx=/[\u0000\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,escapable=/[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,gap,indent,meta={"\b":"\\b"," ":"\\t","\n":"\\n","\f":"\\f","\r":"\\r",'"':'\\"',"\\":"\\\\"},rep;"function"!=typeof JSON.stringify&&(JSON.stringify=function(a,b,c){var d;if(gap="",indent="","number"==typeof c)for(d=0;c>d;d+=1)indent+=" ";else"string"==typeof c&&(indent=c);if(rep=b,!b||"function"==typeof b||"object"==typeof b&&"number"==typeof b.length)return str("",{"":a});throw new Error("JSON.stringify")}),"function"!=typeof JSON.parse&&(JSON.parse=function(text,reviver){function walk(a,b){var c,d,e=a[b];if(e&&"object"==typeof e)for(c in e)Object.prototype.hasOwnProperty.call(e,c)&&(d=walk(e,c),void 0!==d?e[c]=d:delete e[c]);return reviver.call(a,b,e)}var j;if(text=String(text),cx.lastIndex=0,cx.test(text)&&(text=text.replace(cx,function(a){return"\\u"+("0000"+a.charCodeAt(0).toString(16)).slice(-4)})),/^[\],:{}\s]*$/.test(text.replace(/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g,"@").replace(/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g,"]").replace(/(?:^|:|,)(?:\s*\[)+/g,"")))return j=eval("("+text+")"),"function"==typeof reviver?walk({"":j},""):j;throw new SyntaxError("JSON.parse")})}(),SockJS=function(){var a=document,b=window,c={},d=function(){};d.prototype.addEventListener=function(a,b){this._listeners||(this._listeners={}),a in this._listeners||(this._listeners[a]=[]);var d=this._listeners[a];-1===c.arrIndexOf(d,b)&&d.push(b)},d.prototype.removeEventListener=function(a,b){if(this._listeners&&a in this._listeners){var d=this._listeners[a],e=c.arrIndexOf(d,b);return-1!==e?void(d.length>1?this._listeners[a]=d.slice(0,e).concat(d.slice(e+1)):delete this._listeners[a]):void 0}},d.prototype.dispatchEvent=function(a){var b=a.type,c=Array.prototype.slice.call(arguments,0);if(this["on"+b]&&this["on"+b].apply(this,c),this._listeners&&b in this._listeners)for(var d=0;dc;c++)d.push(g.substr(Math.floor(Math.random()*b),1));return d.join("")},c.random_number=function(a){return Math.floor(Math.random()*a)},c.random_number_string=function(a){var b=(""+(a-1)).length,d=Array(b+1).join("0");return(d+c.random_number(a)).slice(-b)},c.getOrigin=function(a){if(a.match(/^file:\/\//))return null;var b,c,d=a.split("/"),e=d[0],f=d[2],g=f.lastIndexOf("@");return~g&&(f=f.slice(g+1)),d=f.split(":"),b=d[0],c=d[1],c||(c="https:"===e?443:80),e+"//"+b+":"+c},c.isSameOriginUrl=function(a,d){return d||(d=b.location.href),c.getOrigin(a)===c.getOrigin(d)},c.getParentDomain=function(a){if(/^[0-9.]*$/.test(a))return a;if(/^\[/.test(a))return a;if(!/[.]/.test(a))return a;var b=a.split(".").slice(1);return b.join(".")},c.objectExtend=function(a,b){for(var c in b)b.hasOwnProperty(c)&&(a[c]=b[c]);return a};var h="_jp";c.polluteGlobalNamespace=function(){h in b||(b[h]={})},c.closeFrame=function(a,b){return"c"+JSON.stringify([a,b])},c.userSetCode=function(a){return 1e3===a||a>=3e3&&4999>=a},c.countRTO=function(a){return a>100?4*a:300+a},c.log=function(){b.console&&console.log&&console.log.apply&&console.log.apply(console,arguments)},c.bind=function(a,b){return a.bind?a.bind(b):function(){return a.apply(b,arguments)}},c.flatUrl=function(a){return-1===a.indexOf("?")&&-1===a.indexOf("#")},c.amendUrl=function(b){var d=a.location;if(!b)throw new Error("Wrong url for SockJS");if(!c.flatUrl(b))throw new Error("Only basic urls are supported in SockJS");return 0===b.indexOf("//")&&(b=d.protocol+b),0===b.indexOf("/")&&(b=d.protocol+"//"+d.host+b),b=b.replace(/[/]+$/,"")},c.arrIndexOf=function(a,b){for(var c=0;c=0},c.delay=function(a,b){return"function"==typeof a&&(b=a,a=0),setTimeout(b,a)};var i,j=/[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,k={"\x00":"\\u0000","":"\\u0001","":"\\u0002","":"\\u0003","":"\\u0004","":"\\u0005","":"\\u0006","":"\\u0007","\b":"\\b"," ":"\\t","\n":"\\n"," ":"\\u000b","\f":"\\f","\r":"\\r","":"\\u000e","":"\\u000f","":"\\u0010","":"\\u0011","":"\\u0012","":"\\u0013","":"\\u0014","":"\\u0015","":"\\u0016","":"\\u0017","":"\\u0018","":"\\u0019","":"\\u001a","":"\\u001b","":"\\u001c","":"\\u001d","":"\\u001e","":"\\u001f",'"':'\\"',"\\":"\\\\","":"\\u007f","€":"\\u0080","":"\\u0081","‚":"\\u0082","ƒ":"\\u0083","„":"\\u0084","…":"\\u0085","†":"\\u0086","‡":"\\u0087","ˆ":"\\u0088","‰":"\\u0089","Š":"\\u008a","‹":"\\u008b","Œ":"\\u008c","":"\\u008d","Ž":"\\u008e","":"\\u008f","":"\\u0090","‘":"\\u0091","’":"\\u0092","“":"\\u0093","”":"\\u0094","•":"\\u0095","–":"\\u0096","—":"\\u0097","˜":"\\u0098","™":"\\u0099","š":"\\u009a","›":"\\u009b","œ":"\\u009c","":"\\u009d","ž":"\\u009e","Ÿ":"\\u009f","­":"\\u00ad","؀":"\\u0600","؁":"\\u0601","؂":"\\u0602","؃":"\\u0603","؄":"\\u0604","܏":"\\u070f","឴":"\\u17b4","឵":"\\u17b5","‌":"\\u200c","‍":"\\u200d","‎":"\\u200e","‏":"\\u200f","\u2028":"\\u2028","\u2029":"\\u2029","‪":"\\u202a","‫":"\\u202b","‬":"\\u202c","‭":"\\u202d","‮":"\\u202e"," ":"\\u202f","⁠":"\\u2060","⁡":"\\u2061","⁢":"\\u2062","⁣":"\\u2063","⁤":"\\u2064","⁥":"\\u2065","⁦":"\\u2066","⁧":"\\u2067","⁨":"\\u2068","⁩":"\\u2069","":"\\u206a","":"\\u206b","":"\\u206c","":"\\u206d","":"\\u206e","":"\\u206f","":"\\ufeff","￰":"\\ufff0","￱":"\\ufff1","￲":"\\ufff2","￳":"\\ufff3","￴":"\\ufff4","￵":"\\ufff5","￶":"\\ufff6","￷":"\\ufff7","￸":"\\ufff8","":"\\ufff9","":"\\ufffa","":"\\ufffb","":"\\ufffc","�":"\\ufffd","￾":"\\ufffe","￿":"\\uffff"},l=/[\x00-\x1f\ud800-\udfff\ufffe\uffff\u0300-\u0333\u033d-\u0346\u034a-\u034c\u0350-\u0352\u0357-\u0358\u035c-\u0362\u0374\u037e\u0387\u0591-\u05af\u05c4\u0610-\u0617\u0653-\u0654\u0657-\u065b\u065d-\u065e\u06df-\u06e2\u06eb-\u06ec\u0730\u0732-\u0733\u0735-\u0736\u073a\u073d\u073f-\u0741\u0743\u0745\u0747\u07eb-\u07f1\u0951\u0958-\u095f\u09dc-\u09dd\u09df\u0a33\u0a36\u0a59-\u0a5b\u0a5e\u0b5c-\u0b5d\u0e38-\u0e39\u0f43\u0f4d\u0f52\u0f57\u0f5c\u0f69\u0f72-\u0f76\u0f78\u0f80-\u0f83\u0f93\u0f9d\u0fa2\u0fa7\u0fac\u0fb9\u1939-\u193a\u1a17\u1b6b\u1cda-\u1cdb\u1dc0-\u1dcf\u1dfc\u1dfe\u1f71\u1f73\u1f75\u1f77\u1f79\u1f7b\u1f7d\u1fbb\u1fbe\u1fc9\u1fcb\u1fd3\u1fdb\u1fe3\u1feb\u1fee-\u1fef\u1ff9\u1ffb\u1ffd\u2000-\u2001\u20d0-\u20d1\u20d4-\u20d7\u20e7-\u20e9\u2126\u212a-\u212b\u2329-\u232a\u2adc\u302b-\u302c\uaab2-\uaab3\uf900-\ufa0d\ufa10\ufa12\ufa15-\ufa1e\ufa20\ufa22\ufa25-\ufa26\ufa2a-\ufa2d\ufa30-\ufa6d\ufa70-\ufad9\ufb1d\ufb1f\ufb2a-\ufb36\ufb38-\ufb3c\ufb3e\ufb40-\ufb41\ufb43-\ufb44\ufb46-\ufb4e\ufff0-\uffff]/g,m=JSON&&JSON.stringify||function(a){return j.lastIndex=0,j.test(a)&&(a=a.replace(j,function(a){return k[a]})),'"'+a+'"'},n=function(a){var b,c={},d=[];for(b=0;65536>b;b++)d.push(String.fromCharCode(b));return a.lastIndex=0,d.join("").replace(a,function(a){return c[a]="\\u"+("0000"+a.charCodeAt(0).toString(16)).slice(-4),""}),a.lastIndex=0,c};c.quote=function(a){var b=m(a);return l.lastIndex=0,l.test(b)?(i||(i=n(l)),b.replace(l,function(a){return i[a]})):b};var o=["websocket","xdr-streaming","xhr-streaming","iframe-eventsource","iframe-htmlfile","xdr-polling","xhr-polling","iframe-xhr-polling","jsonp-polling"];c.probeProtocols=function(){for(var a={},b=0;b0&&h(a)};return c.websocket!==!1&&h(["websocket"]),d["xhr-streaming"]&&!c.null_origin?e.push("xhr-streaming"):!d["xdr-streaming"]||c.cookie_needed||c.null_origin?h(["iframe-eventsource","iframe-htmlfile"]):e.push("xdr-streaming"),d["xhr-polling"]&&!c.null_origin?e.push("xhr-polling"):!d["xdr-polling"]||c.cookie_needed||c.null_origin?h(["iframe-xhr-polling","jsonp-polling"]):e.push("xdr-polling"),e};var p="_sockjs_global";c.createHook=function(){var a="a"+c.random_string(8);if(!(p in b)){var d={};b[p]=function(a){return a in d||(d[a]={id:a,del:function(){delete d[a]}}),d[a]}}return b[p](a)},c.attachMessage=function(a){c.attachEvent("message",a)},c.attachEvent=function(c,d){"undefined"!=typeof b.addEventListener?b.addEventListener(c,d,!1):(a.attachEvent("on"+c,d),b.attachEvent("on"+c,d))},c.detachMessage=function(a){c.detachEvent("message",a)},c.detachEvent=function(c,d){"undefined"!=typeof b.addEventListener?b.removeEventListener(c,d,!1):(a.detachEvent("on"+c,d),b.detachEvent("on"+c,d))};var q={},r=!1,s=function(){for(var a in q)q[a](),delete q[a]},t=function(){r||(r=!0,s())};c.attachEvent("unload",t),c.unload_add=function(a){var b=c.random_string(8);return q[b]=a,r&&c.delay(s),b},c.unload_del=function(a){a in q&&delete q[a]},c.createIframe=function(b,d){var e,f,g=a.createElement("iframe"),h=function(){clearTimeout(e);try{g.onload=null}catch(a){}g.onerror=null},i=function(){g&&(h(),setTimeout(function(){g&&g.parentNode.removeChild(g),g=null},0),c.unload_del(f))},j=function(a){g&&(i(),d(a))},k=function(a,b){try{g&&g.contentWindow&&g.contentWindow.postMessage(a,b)}catch(c){}};return g.src=b,g.style.display="none",g.style.position="absolute",g.onerror=function(){j("onerror")},g.onload=function(){clearTimeout(e),e=setTimeout(function(){j("onload timeout")},2e3)},a.body.appendChild(g),e=setTimeout(function(){j("timeout")},15e3),f=c.unload_add(i),{post:k,cleanup:i,loaded:h}},c.createHtmlfile=function(a,d){var e,f,g,i=new ActiveXObject("htmlfile"),j=function(){clearTimeout(e)},k=function(){i&&(j(),c.unload_del(f),g.parentNode.removeChild(g),g=i=null,CollectGarbage())},l=function(a){i&&(k(),d(a))},m=function(a,b){try{g&&g.contentWindow&&g.contentWindow.postMessage(a,b)}catch(c){}};i.open(),i.write(''),i.close(),i.parentWindow[h]=b[h];var n=i.createElement("div");return i.body.appendChild(n),g=i.createElement("iframe"),n.appendChild(g),g.src=a,e=setTimeout(function(){l("timeout")},15e3),f=c.unload_add(k),{post:m,cleanup:k,loaded:j}};var u=function(){};u.prototype=new f(["chunk","finish"]),u.prototype._start=function(a,d,e,f){var g=this;try{g.xhr=new XMLHttpRequest}catch(h){}if(!g.xhr)try{g.xhr=new b.ActiveXObject("Microsoft.XMLHTTP")}catch(h){}(b.ActiveXObject||b.XDomainRequest)&&(d+=(-1===d.indexOf("?")?"?":"&")+"t="+ +new Date),g.unload_ref=c.unload_add(function(){g._cleanup(!0)});try{g.xhr.open(a,d,!0)}catch(i){return g.emit("finish",0,""),void g._cleanup()}if(f&&f.no_credentials||(g.xhr.withCredentials="true"),f&&f.headers)for(var j in f.headers)g.xhr.setRequestHeader(j,f.headers[j]);g.xhr.onreadystatechange=function(){if(g.xhr){var a=g.xhr;switch(a.readyState){case 3:try{var b=a.status,c=a.responseText}catch(a){}1223===b&&(b=204),c&&c.length>0&&g.emit("chunk",b,c);break;case 4:var b=a.status;1223===b&&(b=204),g.emit("finish",b,a.responseText),g._cleanup(!1)}}},g.xhr.send(e)},u.prototype._cleanup=function(a){var b=this;if(b.xhr){if(c.unload_del(b.unload_ref),b.xhr.onreadystatechange=function(){},a)try{b.xhr.abort()}catch(d){}b.unload_ref=b.xhr=null}},u.prototype.close=function(){var a=this;a.nuke(),a._cleanup(!0)};var v=c.XHRCorsObject=function(){var a=this,b=arguments;c.delay(function(){a._start.apply(a,b)})};v.prototype=new u;var w=c.XHRLocalObject=function(a,b,d){var e=this;c.delay(function(){e._start(a,b,d)})};w.prototype=new u;var x=c.XDRObject=function(a,b,d){var e=this;c.delay(function(){e._start(a,b,d)})};x.prototype=new f(["chunk","finish"]),x.prototype._start=function(a,b,d){var e=this,f=new XDomainRequest;b+=(-1===b.indexOf("?")?"?":"&")+"t="+ +new Date;var g=f.ontimeout=f.onerror=function(){e.emit("finish",0,""),e._cleanup(!1)};f.onprogress=function(){e.emit("chunk",200,f.responseText)},f.onload=function(){e.emit("finish",200,f.responseText),e._cleanup(!1)},e.xdr=f,e.unload_ref=c.unload_add(function(){e._cleanup(!0)});try{e.xdr.open(a,b),e.xdr.send(d)}catch(h){g()}},x.prototype._cleanup=function(a){var b=this;if(b.xdr){if(c.unload_del(b.unload_ref),b.xdr.ontimeout=b.xdr.onerror=b.xdr.onprogress=b.xdr.onload=null,a)try{b.xdr.abort()}catch(d){}b.unload_ref=b.xdr=null}},x.prototype.close=function(){var a=this;a.nuke(),a._cleanup(!0)},c.isXHRCorsCapable=function(){if(a.domain){if(b.XMLHttpRequest&&"withCredentials"in new XMLHttpRequest)return 1;if(b.XDomainRequest)return 2}return L.enabled()?3:4};var y=function(a,d,e){if(this===b)return new y(a,d,e);var f,g=this;g._options={devel:!1,debug:!1,protocols_whitelist:[],info:void 0,rtt:void 0},e&&c.objectExtend(g._options,e),g._base_url=c.amendUrl(a),g._server=g._options.server||c.random_number_string(1e3),g._options.protocols_whitelist&&g._options.protocols_whitelist.length?f=g._options.protocols_whitelist:(f="string"==typeof d&&d.length>0?[d]:c.isArray(d)?d:null,f&&g._debug('Deprecated API: Use "protocols_whitelist" option instead of supplying protocol list as a second parameter to SockJS constructor.')),g._protocols=[],g.protocol=null,g.readyState=y.CONNECTING,g._ir=S(g._base_url),g._ir.onfinish=function(a,b){g._ir=null,a?(g._options.info&&(a=c.objectExtend(a,g._options.info)),g._options.rtt&&(b=g._options.rtt),g._applyInfo(a,b,f),g._didClose()):g._didClose(1002,"Can't connect to server",!0)}};y.prototype=new d,y.version="0.3.4",y.CONNECTING=0,y.OPEN=1,y.CLOSING=2,y.CLOSED=3,y.prototype._debug=function(){this._options.debug&&c.log.apply(c,arguments)},y.prototype._dispatchOpen=function(){var a=this;a.readyState===y.CONNECTING?(a._transport_tref&&(clearTimeout(a._transport_tref),a._transport_tref=null),a.readyState=y.OPEN,a.dispatchEvent(new e("open"))):a._didClose(1006,"Server lost session")},y.prototype._dispatchMessage=function(a){var b=this;b.readyState===y.OPEN&&b.dispatchEvent(new e("message",{data:a}))},y.prototype._dispatchHeartbeat=function(){var a=this;a.readyState===y.OPEN&&a.dispatchEvent(new e("heartbeat",{}))},y.prototype._didClose=function(a,b,d){var f=this;if(f.readyState!==y.CONNECTING&&f.readyState!==y.OPEN&&f.readyState!==y.CLOSING)throw new Error("INVALID_STATE_ERR");f._ir&&(f._ir.nuke(),f._ir=null),f._transport&&(f._transport.doCleanup(),f._transport=null);var g=new e("close",{code:a,reason:b,wasClean:c.userSetCode(a)});if(!c.userSetCode(a)&&f.readyState===y.CONNECTING&&!d){if(f._try_next_protocol(g))return;g=new e("close",{code:2e3,reason:"All transports failed",wasClean:!1,last_event:g})}f.readyState=y.CLOSED,c.delay(function(){f.dispatchEvent(g)})},y.prototype._didMessage=function(a){var b=this,c=a.slice(0,1);switch(c){case"o":b._dispatchOpen();break;case"a":for(var d=JSON.parse(a.slice(1)||"[]"),e=0;e0){var b="["+a.send_buffer.join(",")+"]";a.send_stop=a.sender(a.trans_url,b,function(b,c){a.send_stop=null,b===!1?a.ri._didClose(1006,"Sending error "+c):a.send_schedule_wait()}),a.send_buffer=[]}},A.prototype.send_destructor=function(){var a=this;a._send_stop&&a._send_stop(),a._send_stop=null};var B=function(b,d,e){var f=this;if(!("_send_form"in f)){var g=f._send_form=a.createElement("form"),h=f._send_area=a.createElement("textarea");h.name="d",g.style.display="none",g.style.position="absolute",g.method="POST",g.enctype="application/x-www-form-urlencoded",g.acceptCharset="UTF-8",g.appendChild(h),a.body.appendChild(g)}var g=f._send_form,h=f._send_area,i="a"+c.random_string(8);g.target=i,g.action=b+"/jsonp_send?i="+i;var j;try{j=a.createElement('