view on requirebin
Created
January 16, 2014 21:13
-
-
Save balupton/8463539 to your computer and use it in GitHub Desktop.
requirebin sketch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var signaller = require('rtc-signaller')('http://rtc.io/switchboard/'); | |
var rtc = require('rtc'); | |
var media = require('rtc-media'); | |
var processor = require('rtc-videoproc'); | |
var whammy = require('whammy'); | |
var QUALITY = 1; | |
var HEIGHT = 100; | |
var WIDTH = 100; | |
var FPS = 0.2; | |
var FPMS = 1000/FPS; | |
var ID = Math.floor(Math.random()*1000); | |
// render the local media to the document body | |
var localMedia = media(); | |
// capture local media first as firefox | |
// will want a local stream and doesn't support onnegotiationneeded event | |
localMedia.once('capture', function(localStream) { | |
localMedia.render(document.body, function(localHighVideo){ | |
localHighVideo.width = WIDTH; | |
localHighVideo.height = HEIGHT; | |
}); | |
var localLowCanvas = processor(document.body, {fps:0.2}); | |
localLowCanvas.style.opacity = 0.5; | |
localLowCanvas.width = WIDTH; | |
localLowCanvas.height = HEIGHT; | |
localLowCanvas.pipeline.add(greyscaleFilter); | |
localMedia.render(localLowCanvas); | |
// look for friends | |
signaller.on('peer:announce', function(data) { | |
console.log('peer', data); | |
// create a peer connection for our new friend | |
var pc = rtc.createConnection(); | |
// couple our connection via the signalling channel | |
var monitor = rtc.couple(pc, data.id, signaller); | |
// add the stream to the connection | |
// pc.addStream(localStream); | |
// add data to the conncetion | |
pc.ondatachannel = function(channel){ | |
console.log('got channel', channel); | |
}; | |
var lowChannel = pc.createDataChannel("low"); | |
lowChannel.onopen = function(event) { | |
alert('asd'); | |
console.log('data channel opened'); | |
setInterval(function(){ | |
/* | |
var frame = localLowCanvas.toDataURL('image/jpeg', QUALITY); | |
var data = { | |
frame: frame, | |
username: ID | |
} | |
*/ | |
var data = 'hello'; | |
console.log('sent', data); | |
lowChannel.send(data); | |
}, FPMS); | |
}; | |
lowChannel.onmessage = function(event) { | |
console.log('received', event.data); | |
return; | |
var id = 'feed-'+event.data.username; | |
var img = document.getElementById(id); | |
if ( !img ) { | |
img = document.createElement('img'); | |
document.body.appendChild(img); | |
} | |
img.src = event.data.frame; | |
img.id = id; | |
}; | |
// once the connection is active, log a console message | |
monitor.once('active', function() { | |
console.log('connection active to: ' + data.id); | |
}); | |
// add a remote stream to the dom | |
pc.onaddstream = function(remoteStream) { | |
media(remoteStream).render(document.body); | |
}; | |
}); // end peer:announce | |
signaller.announce({ room: 'interconnect' }); | |
}); // end capture | |
function greyscaleFilter(imageData) { | |
var channels = imageData.data; | |
var rgb = []; | |
var rgbAvg; | |
var alpha; | |
var ii; | |
// check that we have channels is divisible by four (just as a safety) | |
if (channels.length % 4 !== 0) { | |
return; | |
} | |
// iterate through the data | |
// NOTE: decrementing loops are fast but you need to know that you will | |
// hit 0 using this logic otherwise it will run forever (only 0 is falsy) | |
for (ii = channels.length; ii -= 4; ) { | |
// get the rgb tuple | |
rgb = [channels[ii], channels[ii + 1], channels[ii + 2]]; | |
// get the alpha value | |
alpha = channels[ii + 3]; | |
// calculate the rgb average | |
rgbAvg = (rgb[0] + rgb[1] + rgb[2] ) / 3; | |
// update the values to the rgb average | |
channels[ii] = channels[ii + 1] = channels[ii + 2] = rgbAvg; | |
} | |
return true; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function greyscaleFilter(t){var e,n,r,o=t.data,i=[];if(0===o.length%4){for(r=o.length;r-=4;)i=[o[r],o[r+1],o[r+2]],n=o[r+3],e=(i[0]+i[1]+i[2])/3,o[r]=o[r+1]=o[r+2]=e;return!0}}require=function e(t,n,r){function o(a,s){if(!n[a]){if(!t[a]){var c="function"==typeof require&&require;if(!s&&c)return c(a,!0);if(i)return i(a,!0);throw Error("Cannot find module '"+a+"'")}var u=n[a]={exports:{}};t[a][0].call(u.exports,function(e){var n=t[a][1][e];return o(n?n:e)},u,u.exports,e,t,n,r)}return n[a].exports}for(var i="function"==typeof require&&require,a=0;r.length>a;a++)o(r[a]);return o}({rP2IBn:[function(t,e){"use strict";function n(t){return this instanceof n?(i.call(this),t&&t instanceof MediaStream&&(t={stream:t,capture:!1,muted:!1}),t&&(t.audio||t.video)&&(t={constraints:t}),t=r({},{capture:!0,muted:!0,constraints:{video:{mandatory:{},optional:[]},audio:!0}},t),this.constraints=t.constraints,this.name=t.name,this.stream=t.stream||null,this.muted=t.muted===void 0||t.muted,this._bindings=[],t.capture&&setTimeout(this.capture.bind(this),0),void 0):new n(t)}t("cog/logger")("media");var r=t("cog/extend"),o=t("rtc-core/detect"),i=t("events").EventEmitter,a=t("util");navigator.getUserMedia=navigator.getUserMedia||o.call(navigator,"getUserMedia"),window.URL=window.URL||o("URL"),window.MediaStream=o("MediaStream"),a.inherits(n,i),e.exports=n,n.prototype.capture=function(t,e){var n=this,r=this.emit.bind(this,"end");this.stream||("function"==typeof t&&(e=t,t=this.constraints),"function"==typeof e&&this.once("capture",e.bind(this)),navigator.getUserMedia(t||this.constraints,function(t){"function"==typeof t.addEventListener?t.addEventListener("ended",r):t.onended=r,n.stream=t,n.emit("capture",t)},this._handleFail.bind(this)))},n.prototype.render=function(t,e,n){return Array.isArray(t)&&(console.log("WARNING: rtc-media render (as of 1.x) expects a single target"),t=t[0]),"function"==typeof e&&(n=e,e={}),e=e||{},t=this._prepareElement(e,t),this.stream?this._bindStream(this.stream):this.once("capture",this._bindStream.bind(this)),"function"==typeof n&&this.once("render",n),t},n.prototype.stop=function(t){var e=this;this.stream&&(this._unbind(t),this.stream.stop(),this.once("capture",e._bindStream.bind(e)),this.stream=null)},n.prototype._prepareElement=function(t,e){var n,r=e instanceof HTMLVideoElement||e instanceof HTMLAudioElement,o=t.preserveAspectRatio===void 0||t.preserveAspectRatio;return r=r||"function"==typeof e.play&&(e.mozSrcObject!==void 0||e.src!==void 0),r||(n=e,e=document.createElement("video"),o&&e.setAttribute("preserveAspectRatio",""),n.appendChild(e),e.setAttribute("data-playing",!1)),e&&this.muted&&e.setAttribute("muted",""),this._bindings.push({el:e,opts:t}),e},n.prototype._bindStream=function(t){function e(){0===i.length&&o.length>0&&(r.emit("render",o[0]),o.map(function(t){t.setAttribute("data-playing",!0)}))}function n(t){var r=t.target||t.srcElement,a=o.indexOf(r);a>=0&&i.splice(a,1),r.removeEventListener("playing",n),e()}var r=this,o=[],i=[];o=this._bindings.map(function(e){return e.el.mozSrcObject!==void 0?e.el.mozSrcObject=t:e.el.src=r._createObjectURL(t)||t,"function"==typeof e.el.play&&e.el.play(),e.el}),i=o.filter(function(t){return 3>t.readyState}),i.map(function(t){t.addEventListener("playing",n,!1)}),e()},n.prototype._unbind=function(t){t=t||{},this._bindings.forEach(function(t){var e=t.el;e.src=null,e.mozSrcObject&&(e.mozSrcObject=null),e.currentSrc&&(e.currentSrc=null)})},n.prototype._createObjectURL=function(t){try{return window.URL.createObjectURL(t)}catch(e){}},n.prototype._handleSuccess=function(t){this.stream=t,this.emit("stream",t)},n.prototype._handleFail=function(t){this.emit("error",t)}},{"cog/extend":3,"cog/logger":4,events:6,"rtc-core/detect":5,util:10}],"rtc-media":[function(t,e){e.exports=t("rP2IBn")},{}],3:[function(t,e){"use strict";e.exports=function(t){return[].slice.call(arguments,1).forEach(function(e){if(e)for(var n in e)t[n]=e[n]}),t}},{}],4:[function(t,e){"use strict";var n=[],r=[],o=[console],i=e.exports=function(t){function e(){return i=n.indexOf("*")>=0||n.indexOf(t)>=0}var i=e();return r[r.length]=e,function(){var e=[].slice.call(arguments);("string"==typeof e[0]||e[0]instanceof String)&&(e[0]=t+": "+e[0]),i&&o.forEach(function(t){t.log.apply(t,e)})}};i.reset=function(){return o=[],n=[],i.enable()},i.to=function(t){return o=o.concat(t||[]),i},i.enable=function(){return n=n.concat([].slice.call(arguments)),r.forEach(function(t){t()}),i}},{}],5:[function(t,e){"use strict";var n={chrome:/Chrom(?:e|ium)\/([0-9]+)\./,firefox:/Firefox\/([0-9]+)\./,opera:/Opera\/([0-9]+)\./},r=e.exports=function(t,e){var n,o,i,a=this||("undefined"!=typeof window?window:void 0);if(a)for(e=(e||["ms","o","moz","webkit"]).concat(""),n=e.length;n--;)if(o=e[n],i=o+(o?t.charAt(0).toUpperCase()+t.slice(1):t),a[i]!==void 0)return r.browser=r.browser||o.toLowerCase(),a[t]=a[i]};r.moz="undefined"!=typeof navigator&&!!navigator.mozGetUserMedia,"undefined"!=typeof navigator?Object.keys(n).forEach(function(t){var e=n[t].exec(navigator.userAgent);e&&(r.browser=t,r.browserVersion=r.version=parseInt(e[1],10))}):(r.browser="node",r.browserVersion=r.version="?")},{}],6:[function(t,e,n){var r=t("__browserify_process");r.EventEmitter||(r.EventEmitter=function(){});var o=n.EventEmitter=r.EventEmitter,i="function"==typeof Array.isArray?Array.isArray:function(t){return"[object Array]"===Object.prototype.toString.call(t)},a=10;o.prototype.setMaxListeners=function(t){this._events||(this._events={}),this._events.maxListeners=t},o.prototype.emit=function(t){if("error"===t&&(!this._events||!this._events.error||i(this._events.error)&&!this._events.error.length))throw arguments[1]instanceof Error?arguments[1]:Error("Uncaught, unspecified 'error' event.");if(!this._events)return!1;var e=this._events[t];if(!e)return!1;if("function"==typeof e){switch(arguments.length){case 1:e.call(this);break;case 2:e.call(this,arguments[1]);break;case 3:e.call(this,arguments[1],arguments[2]);break;default:var n=Array.prototype.slice.call(arguments,1);e.apply(this,n)}return!0}if(i(e)){for(var n=Array.prototype.slice.call(arguments,1),r=e.slice(),o=0,a=r.length;a>o;o++)r[o].apply(this,n);return!0}return!1},o.prototype.addListener=function(t,e){if("function"!=typeof e)throw Error("addListener only takes instances of Function");if(this._events||(this._events={}),this.emit("newListener",t,e),this._events[t])if(i(this._events[t])){if(!this._events[t].warned){var n;n=void 0!==this._events.maxListeners?this._events.maxListeners:a,n&&n>0&&this._events[t].length>n&&(this._events[t].warned=!0,console.error("(node) warning: possible EventEmitter memory leak detected. %d listeners added. Use emitter.setMaxListeners() to increase limit.",this._events[t].length),console.trace())}this._events[t].push(e)}else this._events[t]=[this._events[t],e];else this._events[t]=e;return this},o.prototype.on=o.prototype.addListener,o.prototype.once=function(t,e){var n=this;return n.on(t,function r(){n.removeListener(t,r),e.apply(this,arguments)}),this},o.prototype.removeListener=function(t,e){if("function"!=typeof e)throw Error("removeListener only takes instances of Function");if(!this._events||!this._events[t])return this;var n=this._events[t];if(i(n)){var r=n.indexOf(e);if(0>r)return this;n.splice(r,1),0==n.length&&delete this._events[t]}else this._events[t]===e&&delete this._events[t];return this},o.prototype.removeAllListeners=function(t){return t&&this._events&&this._events[t]&&(this._events[t]=null),this},o.prototype.listeners=function(t){return this._events||(this._events={}),this._events[t]||(this._events[t]=[]),i(this._events[t])||(this._events[t]=[this._events[t]]),this._events[t]}},{__browserify_process:8}],7:[function(t,e){e.exports="function"==typeof Object.create?function(t,e){t.super_=e,t.prototype=Object.create(e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}})}:function(t,e){t.super_=e;var n=function(){};n.prototype=e.prototype,t.prototype=new n,t.prototype.constructor=t}},{}],8:[function(t,e){var n=e.exports={};n.nextTick=function(){var t="undefined"!=typeof window&&window.setImmediate,e="undefined"!=typeof window&&window.postMessage&&window.addEventListener;if(t)return function(t){return window.setImmediate(t)};if(e){var n=[];return window.addEventListener("message",function(t){if(t.source===window&&"process-tick"===t.data&&(t.stopPropagation(),n.length>0)){var e=n.shift();e()}},!0),function(t){n.push(t),window.postMessage("process-tick","*")}}return function(t){setTimeout(t,0)}}(),n.title="browser",n.browser=!0,n.env={},n.argv=[],n.binding=function(){throw Error("process.binding is not supported")},n.cwd=function(){return"/"},n.chdir=function(){throw Error("process.chdir is not supported")}},{}],9:[function(t,e){e.exports=function(t){return t&&"object"==typeof t&&"function"==typeof t.copy&&"function"==typeof t.fill&&"function"==typeof t.binarySlice}},{}],10:[function(t,e,n){function r(t,e){var r={seen:[],stylize:i};return arguments.length>=3&&(r.depth=arguments[2]),arguments.length>=4&&(r.colors=arguments[3]),d(e)?r.showHidden=e:e&&n._extend(r,e),w(r.showHidden)&&(r.showHidden=!1),w(r.depth)&&(r.depth=2),w(r.colors)&&(r.colors=!1),w(r.customInspect)&&(r.customInspect=!0),r.colors&&(r.stylize=o),s(r,t,r.depth)}function o(t,e){var n=r.styles[e];return n?"["+r.colors[n][0]+"m"+t+"["+r.colors[n][1]+"m":t}function i(t){return t}function a(t){var e={};return t.forEach(function(t){e[t]=!0}),e}function s(t,e,r){if(t.customInspect&&e&&C(e.inspect)&&e.inspect!==n.inspect&&(!e.constructor||e.constructor.prototype!==e)){var o=e.inspect(r,t);return m(o)||(o=s(t,o,r)),o}var i=c(t,e);if(i)return i;var d=Object.keys(e),g=a(d);if(t.showHidden&&(d=Object.getOwnPropertyNames(e)),0===d.length){if(C(e)){var v=e.name?": "+e.name:"";return t.stylize("[Function"+v+"]","special")}if(O(e))return t.stylize(RegExp.prototype.toString.call(e),"regexp");if(_(e))return t.stylize(Date.prototype.toString.call(e),"date");if(x(e))return u(e)}var y="",b=!1,w=["{","}"];if(p(e)&&(b=!0,w=["[","]"]),C(e)){var E=e.name?": "+e.name:"";y=" [Function"+E+"]"}if(O(e)&&(y=" "+RegExp.prototype.toString.call(e)),_(e)&&(y=" "+Date.prototype.toUTCString.call(e)),x(e)&&(y=" "+u(e)),0===d.length&&(!b||0==e.length))return w[0]+y+w[1];if(0>r)return O(e)?t.stylize(RegExp.prototype.toString.call(e),"regexp"):t.stylize("[Object]","special");t.seen.push(e);var j;return j=b?f(t,e,r,g,d):d.map(function(n){return h(t,e,r,g,n,b)}),t.seen.pop(),l(j,y,w)}function c(t,e){if(w(e))return t.stylize("undefined","undefined");if(m(e)){var n="'"+JSON.stringify(e).replace(/^"|"$/g,"").replace(/'/g,"\\'").replace(/\\"/g,'"')+"'";return t.stylize(n,"string")}return y(e)?t.stylize(""+e,"number"):d(e)?t.stylize(""+e,"boolean"):g(e)?t.stylize("null","null"):void 0}function u(t){return"["+Error.prototype.toString.call(t)+"]"}function f(t,e,n,r,o){for(var i=[],a=0,s=e.length;s>a;++a)I(e,a+"")?i.push(h(t,e,n,r,a+"",!0)):i.push("");return o.forEach(function(o){o.match(/^\d+$/)||i.push(h(t,e,n,r,o,!0))}),i}function h(t,e,n,r,o,i){var a,c,u;if(u=Object.getOwnPropertyDescriptor(e,o)||{value:e[o]},u.get?c=u.set?t.stylize("[Getter/Setter]","special"):t.stylize("[Getter]","special"):u.set&&(c=t.stylize("[Setter]","special")),I(r,o)||(a="["+o+"]"),c||(0>t.seen.indexOf(u.value)?(c=g(n)?s(t,u.value,null):s(t,u.value,n-1),c.indexOf("\n")>-1&&(c=i?c.split("\n").map(function(t){return" "+t}).join("\n").substr(2):"\n"+c.split("\n").map(function(t){return" "+t}).join("\n"))):c=t.stylize("[Circular]","special")),w(a)){if(i&&o.match(/^\d+$/))return c;a=JSON.stringify(""+o),a.match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)?(a=a.substr(1,a.length-2),a=t.stylize(a,"name")):(a=a.replace(/'/g,"\\'").replace(/\\"/g,'"').replace(/(^"|"$)/g,"'"),a=t.stylize(a,"string"))}return a+": "+c}function l(t,e,n){var r=0,o=t.reduce(function(t,e){return r++,e.indexOf("\n")>=0&&r++,t+e.replace(/\u001b\[\d\d?m/g,"").length+1},0);return o>60?n[0]+(""===e?"":e+"\n ")+" "+t.join(",\n ")+" "+n[1]:n[0]+e+" "+t.join(", ")+" "+n[1]}function p(t){return Array.isArray(t)}function d(t){return"boolean"==typeof t}function g(t){return null===t}function v(t){return null==t}function y(t){return"number"==typeof t}function m(t){return"string"==typeof t}function b(t){return"symbol"==typeof t}function w(t){return void 0===t}function O(t){return E(t)&&"[object RegExp]"===k(t)}function E(t){return"object"==typeof t&&null!==t}function _(t){return E(t)&&"[object Date]"===k(t)}function x(t){return E(t)&&("[object Error]"===k(t)||t instanceof Error)}function C(t){return"function"==typeof t}function j(t){return null===t||"boolean"==typeof t||"number"==typeof t||"string"==typeof t||"symbol"==typeof t||t===void 0}function k(t){return Object.prototype.toString.call(t)}function A(t){return 10>t?"0"+t.toString(10):t.toString(10)}function L(){var t=new Date,e=[A(t.getHours()),A(t.getMinutes()),A(t.getSeconds())].join(":");return[t.getDate(),U[t.getMonth()],e].join(" ")}function I(t,e){return Object.prototype.hasOwnProperty.call(t,e)}var S=t("__browserify_process"),M="undefined"!=typeof self?self:"undefined"!=typeof window?window:{},R=/%[sdj%]/g;n.format=function(t){if(!m(t)){for(var e=[],n=0;arguments.length>n;n++)e.push(r(arguments[n]));return e.join(" ")}for(var n=1,o=arguments,i=o.length,a=(t+"").replace(R,function(t){if("%%"===t)return"%";if(n>=i)return t;switch(t){case"%s":return o[n++]+"";case"%d":return Number(o[n++]);case"%j":try{return JSON.stringify(o[n++])}catch(e){return"[Circular]"}default:return t}}),s=o[n];i>n;s=o[++n])a+=g(s)||!E(s)?" "+s:" "+r(s);return a},n.deprecate=function(t,e){function r(){if(!o){if(S.throwDeprecation)throw Error(e);S.traceDeprecation?console.trace(e):console.error(e),o=!0}return t.apply(this,arguments)}if(w(M.process))return function(){return n.deprecate(t,e).apply(this,arguments)};if(S.noDeprecation===!0)return t;var o=!1;return r};var P,B={};n.debuglog=function(t){if(w(P)&&(P=S.env.NODE_DEBUG||""),t=t.toUpperCase(),!B[t])if(RegExp("\\b"+t+"\\b","i").test(P)){var e=S.pid;B[t]=function(){var r=n.format.apply(n,arguments);console.error("%s %d: %s",t,e,r)}}else B[t]=function(){};return B[t]},n.inspect=r,r.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]},r.styles={special:"cyan",number:"yellow","boolean":"yellow",undefined:"grey","null":"bold",string:"green",date:"magenta",regexp:"red"},n.isArray=p,n.isBoolean=d,n.isNull=g,n.isNullOrUndefined=v,n.isNumber=y,n.isString=m,n.isSymbol=b,n.isUndefined=w,n.isRegExp=O,n.isObject=E,n.isDate=_,n.isError=x,n.isFunction=C,n.isPrimitive=j,n.isBuffer=t("./support/isBuffer");var U=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];n.log=function(){console.log("%s - %s",L(),n.format.apply(n,arguments))},n.inherits=t("inherits"),n._extend=function(t,e){if(!e||!E(e))return t;for(var n=Object.keys(e),r=n.length;r--;)t[n[r]]=e[n[r]];return t}},{"./support/isBuffer":9,__browserify_process:8,inherits:7}]},{},[]),require=function e(t,n,r){function o(a,s){if(!n[a]){if(!t[a]){var c="function"==typeof require&&require;if(!s&&c)return c(a,!0);if(i)return i(a,!0);throw Error("Cannot find module '"+a+"'")}var u=n[a]={exports:{}};t[a][0].call(u.exports,function(e){var n=t[a][1][e];return o(n?n:e)},u,u.exports,e,t,n,r)}return n[a].exports}for(var i="function"==typeof require&&require,a=0;r.length>a;a++)o(r[a]);return o}({tPek8I:[function(t,e){"use strict";function n(t,e,n){function i(t){w=b.push(t)}function a(n){var r,i,s;if(p){if(n=n||Date.now(),n-d>v){if(l.drawImage(e,y,m,c,u),s=O&&new CustomEvent("frame",{detail:{tick:n}}),s&&t.dispatchEvent(s),w){for(r=l.getImageData(0,0,c,u),i=!1,h=0;w>h;h++)i=b[h](r,l,t,f)||i;i&&l.putImageData(r,0,0)}d=n}o(a)}}function s(){var n,r,i;(0===t.width||0===t.height)&&(t.width=e.videoWidth,t.height=e.videoHeight),0!==t.width&&0!==t.height&&(n=Math.min(r=t.width/e.videoWidth,i=t.height/e.videoHeight),c=0|e.videoWidth*n,u=0|e.videoHeight*n,y=t.width-c>>1,m=t.height-u>>1,f={x:y,y:m,width:c,height:u},p=!0,o(a))}var c,u,f,h,l=t.getContext("2d"),p=!1,d=0,g=(n||{}).fps||r,v=0|1e3/g,y=0,m=0,b=[],w=0,O="undefined"!=typeof CustomEvent;return e.addEventListener("playing",s),["mozSrcObject","src"].forEach(function(n){void 0!==e[n]&&Object.defineProperty(t,n,{get:function(){return e[n]},set:function(t){e[n]=t}})}),t.play=function(){e.play()},{add:i}}var r=25,o=t("fdom/raf");e.exports=function(t,e){var r=t instanceof HTMLCanvasElement?t:document.createElement("canvas"),o=t instanceof HTMLVideoElement?t:document.createElement("video");return t===o?o.parentNode.insertBefore(r,o):t!==r&&t.appendChild(r),r.width=(e||{}).width||0,r.height=(e||{}).height||0,o.style.display="none",r.pipeline=n(r,o,e),r}},{"fdom/raf":3}],"rtc-videoproc":[function(t,e){e.exports=t("tPek8I")},{}],3:[function(t,e){"use strict";var n=["r","webkitR","mozR","oR","msR"];e.exports="undefined"!=typeof window&&function(){for(var t=0;n.length>t;t++)window.animFrame=window.animFrame||window[n[t]+"equestAnimationFrame"];return animFrame}()},{}]},{},[]),require=function e(t,n,r){function o(a,s){if(!n[a]){if(!t[a]){var c="function"==typeof require&&require;if(!s&&c)return c(a,!0);if(i)return i(a,!0);throw Error("Cannot find module '"+a+"'")}var u=n[a]={exports:{}};t[a][0].call(u.exports,function(e){var n=t[a][1][e];return o(n?n:e)},u,u.exports,e,t,n,r)}return n[a].exports}for(var i="function"==typeof require&&require,a=0;r.length>a;a++)o(r[a]);return o}({"33ycba":[function(t,e){var n=t("__browserify_process"),r="undefined"!=typeof self?self:"undefined"!=typeof window?window:{};r.Whammy=function(){function t(t,n){for(var r=e(t),o=3e4,a=[{id:440786851,data:[{data:1,id:17030},{data:1,id:17143},{data:4,id:17138},{data:8,id:17139},{data:"webm",id:17026},{data:2,id:17031},{data:2,id:17029}]},{id:408125543,data:[{id:357149030,data:[{data:1e6,id:2807729},{data:"whammy",id:19840},{data:"whammy",id:22337},{data:f(r.duration),id:17545}]},{id:374648427,data:[{id:174,data:[{data:1,id:215},{data:1,id:25541},{data:0,id:156},{data:"und",id:2274716},{data:"V_VP8",id:134},{data:"VP8",id:2459272},{data:1,id:131},{id:224,data:[{data:r.width,id:176},{data:r.height,id:186}]}]}]}]}],c=0,u=0;t.length>c;){var h=[],l=0;do h.push(t[c]),l+=t[c].duration,c++;while(t.length>c&&o>l);var p=0,d={id:524531317,data:[{data:u,id:231}].concat(h.map(function(t){var e=s({discardable:0,frame:t.data.slice(4),invisible:0,keyframe:1,lacing:0,trackNum:1,timecode:Math.round(p)});return p+=t.duration,{data:e,id:163}}))};a[1].data.push(d),u+=l}return i(a,n)}function e(t){for(var e=t[0].width,n=t[0].height,r=t[0].duration,o=1;t.length>o;o++){if(t[o].width!=e)throw"Frame "+(o+1)+" has a different width";if(t[o].height!=n)throw"Frame "+(o+1)+" has a different height";if(0>t[o].duration||t[o].duration>32767)throw"Frame "+(o+1)+" has a weird duration (must be between 0 and 32767)";r+=t[o].duration}return{duration:r,width:e,height:n}}function n(t){for(var e=[];t>0;)e.push(255&t),t>>=8;return new Uint8Array(e.reverse())}function r(t){for(var e=new Uint8Array(t.length),n=0;t.length>n;n++)e[n]=t.charCodeAt(n);return e}function o(t){var e=[],n=t.length%8?Array(9-t.length%8).join("0"):"";t=n+t;for(var r=0;t.length>r;r+=8)e.push(parseInt(t.substr(r,8),2));return new Uint8Array(e)}function i(t,e){for(var s=[],c=0;t.length>c;c++){var u=t[c].data;"object"==typeof u&&(u=i(u,e)),"number"==typeof u&&(u=o(u.toString(2))),"string"==typeof u&&(u=r(u)),u.length;var f=u.size||u.byteLength||u.length,h=Math.ceil(Math.ceil(Math.log(f)/Math.log(2))/8),l=f.toString(2),p=Array(7*h+7+1-l.length).join("0")+l,d=Array(h).join("0")+"1"+p;s.push(n(t[c].id)),s.push(o(d)),s.push(u)}if(e){var g=a(s);return new Uint8Array(g)}return new Blob(s,{type:"video/webm"})}function a(t,e){null==e&&(e=[]);for(var n=0;t.length>n;n++)"object"==typeof t[n]?a(t[n],e):e.push(t[n]);return e}function s(t){var e=0;if(t.keyframe&&(e|=128),t.invisible&&(e|=8),t.lacing&&(e|=t.lacing<<1),t.discardable&&(e|=1),t.trackNum>127)throw"TrackNumber > 127 not supported";var n=[128|t.trackNum,t.timecode>>8,255&t.timecode,e].map(function(t){return String.fromCharCode(t)}).join("")+t.frame;return n}function c(t){for(var e=t.RIFF[0].WEBP[0],n=e.indexOf("*"),r=0,o=[];4>r;r++)o[r]=e.charCodeAt(n+3+r);var i,a,s,c,u;return u=o[1]<<8|o[0],i=16383&u,a=u>>14,u=o[3]<<8|o[2],s=16383&u,c=u>>14,{width:i,height:s,data:e,riff:t}}function u(t){for(var e=0,n={};t.length>e;){var r=t.substr(e,4),o=parseInt(t.substr(e+4,4).split("").map(function(t){var e=t.charCodeAt(0).toString(2);return Array(8-e.length+1).join("0")+e}).join(""),2),i=t.substr(e+4+4,o);e+=8+o,n[r]=n[r]||[],"RIFF"==r||"LIST"==r?n[r].push(u(i)):n[r].push(i)}return n}function f(t){return[].slice.call(new Uint8Array(new Float64Array([t]).buffer),0).map(function(t){return String.fromCharCode(t)}).reverse().join("")}function h(t,e){this.frames=[],this.duration=1e3/t,this.quality=e||.8}return h.prototype.add=function(t,e){if(e!==void 0&&this.duration)throw"you can't pass a duration if the fps is set";if(e===void 0&&!this.duration)throw"if you don't have the fps set, you ned to have durations here.";if("canvas"in t&&(t=t.canvas),"toDataURL"in t)t=t.toDataURL("image/webp",this.quality);else if("string"!=typeof t)throw"frame must be a a HTMLCanvasElement, a CanvasRenderingContext2D or a DataURI formatted string";if(!/^data:image\/webp;base64,/gi.test(t))throw"Input must be formatted properly as a base64 encoded DataURI of type image/webp";this.frames.push({image:t,duration:e||this.duration})},h.prototype.compile=function(e){return new t(this.frames.map(function(t){var e=c(u(atob(t.image.slice(23))));return e.duration=t.duration,e}),e)},{Video:h,fromImageArray:function(e,n,r){return t(e.map(function(t){var e=c(u(atob(t.slice(23))));return e.duration=1e3/n,e}),r)},toWebM:t}}(),n!==void 0&&(e.exports=Whammy)},{__browserify_process:3}],whammy:[function(t,e){e.exports=t("33ycba")},{}],3:[function(t,e){var n=e.exports={};n.nextTick=function(){var t="undefined"!=typeof window&&window.setImmediate,e="undefined"!=typeof window&&window.postMessage&&window.addEventListener;if(t)return function(t){return window.setImmediate(t)};if(e){var n=[];return window.addEventListener("message",function(t){if(t.source===window&&"process-tick"===t.data&&(t.stopPropagation(),n.length>0)){var e=n.shift();e()}},!0),function(t){n.push(t),window.postMessage("process-tick","*")}}return function(t){setTimeout(t,0)}}(),n.title="browser",n.browser=!0,n.env={},n.argv=[],n.binding=function(){throw Error("process.binding is not supported")},n.cwd=function(){return"/"},n.chdir=function(){throw Error("process.chdir is not supported")}},{}]},{},[]),require=function e(t,n,r){function o(a,s){if(!n[a]){if(!t[a]){var c="function"==typeof require&&require;if(!s&&c)return c(a,!0);if(i)return i(a,!0);throw Error("Cannot find module '"+a+"'")}var u=n[a]={exports:{}};t[a][0].call(u.exports,function(e){var n=t[a][1][e];return o(n?n:e)},u,u.exports,e,t,n,r)}return n[a].exports}for(var i="function"==typeof require&&require,a=0;r.length>a;a++)o(r[a]);return o}({1:[function(t,e){"use strict";function n(e,n,a,s){function c(t,e,n){return O[t],function(e){console.error("rtc/couple error ("+t+"): ",e),"function"==typeof n&&n(e)}}function u(){"stable"==e.signalingState&&e.remoteDescription&&(b("signaling state = stable, applying queued candidates"),w.removeListener("change",u),E.splice(0).forEach(function(t){b("applying queued candidate",t);try{e.addIceCandidate(new L(t))}catch(n){b("invalidate candidate specified: ",t)}}))}function f(t){return"checking"!=e.iceConnectionState?!0:(b("connection state is checking, will wait to create a new offer"),w.once("active",function(){k.push({op:t})}),!1)}function h(t){return"stable"===e.signalingState?!0:(b("cannot create offer, signaling state != stable, will retry"),w.on("change",function n(){"stable"===e.signalingState&&k.push({op:t}),w.removeListener("change",n)}),!1)}function l(r,o,i){return t("cog/logger")("handshake-"+r),i=[].concat(i||[]),function s(t,u){var f=!0;return o?(i.forEach(function(t){f=f&&t(s)}),f?(b("calling "+r),e[r](function(t){"function"==typeof _&&(t.sdp=_(t.sdp,e,r)),k.push({op:y(t)}),u()},c(r,"",u)),void 0):u()):(a.to(n).send("/negotiate"),u())}}function p(t){t.candidate?a.to(n).send("/candidate",t.candidate):"complete"===e.iceGatheringState&&b("ice gathering state complete")}function d(t,r){if(r&&r.id===n){if("stable"!=e.signalingState||!e.remoteDescription)return E.push(t),w.removeListener("change",u),w.on("change",u),void 0;try{e.addIceCandidate(new L(t))}catch(o){b("invalidate candidate specified: ",t)}}}function g(t,r){r&&r.id===n&&k.push({op:function(n,r){e.setRemoteDescription(new A(t),function(){"offer"===t.type&&v(j)(),r()},c("offer"===t.type?"createAnswer":"createOffer",t.sdp,r))}})}function v(t){return function(){k.push([{op:t}])}}function y(t){return function(r,o){b("setting local description"),e.setLocalDescription(t,function(){a.to(n).send("/sdp",t),o()},function(e){b("error setting local description",e),b(t.sdp),o(e)})}}var m,b=t("cog/logger")("couple"),w=o(e),O={},E=[],_=(s||{}).sdpfilter;if("function"!=typeof a.isMaster)throw Error("rtc-signaller instance >= 0.14.0 required");var x=a.isMaster(n),C=l("createOffer",x,[h,f]),j=l("createAnswer",!0,[f]),k=r.queue(function(t,e){return"function"!=typeof t.op?e():(t.op(t,e),void 0)},1),A=(s||{}).RTCSessionDescription||i("RTCSessionDescription"),L=(s||{}).RTCIceCandidate||i("RTCIceCandidate");if("string"!=typeof n&&!(n instanceof String))throw Error("2nd argument (targetId) should be a string");return e.addEventListener("negotiationneeded",function(){b("renegotiation required, will create offer in 50ms"),clearTimeout(m),m=setTimeout(v(C),50)}),e.addEventListener("icecandidate",p),a.on("sdp",g),a.on("candidate",d),x&&a.on("negotiate",function(t){t.id===n&&(b("got negotiate request from "+n+", creating offer"),k.push({op:C}))}),w.once("closed",function(){b("closed"),a.removeListener("sdp",g),a.removeListener("candidate",d)}),w.createOffer=v(C),w}var r=t("async"),o=t("./monitor"),i=t("./detect");e.exports=n},{"./detect":2,"./monitor":6,async:7,"cog/logger":9}],2:[function(t,e){"use strict";e.exports=t("rtc-core/detect")},{"rtc-core/detect":10}],3:[function(t,e,n){"use strict";var r=t("cog/logger")("generators"),o=t("./detect"),i=t("cog/defaults"),a={create:{data:function(){},dtls:function(t){o.moz||(t.optional=(t.optional||[]).concat({DtlsSrtpKeyAgreement:!0}))}}},s=["video","audio","data"];n.config=function(t){return i(t,{iceServers:[]})},n.connectionConstraints=function(t,e){var n,o={},s=a.create;return Object.keys(t||{}).forEach(function(t){s[t]&&s[t](o)}),n=i({},e,o),r("generated connection constraints: ",n),n},n.parseFlags=function(t){var e=t||{};return e.video=e.video||e.video===void 0,e.audio=e.audio||e.audio===void 0,Object.keys(e||{}).filter(function(t){return e[t]}).map(function(t){return t.toLowerCase()}).filter(function(t){return s.indexOf(t)>=0})}},{"./detect":2,"cog/defaults":8,"cog/logger":9}],rtc:[function(t,e){e.exports=t("u6jg/5")},{}],"u6jg/5":[function(t,e,n){"use strict";var r=t("./generators"),o=n.detect=t("./detect");n.logger=t("cog/logger");var i=n.RTCPeerConnection=o("RTCPeerConnection");n.couple=t("./couple"),n.createConnection=function(t,e){return new i(r.config(t),r.connectionConstraints(t,e))}},{"./couple":1,"./detect":2,"./generators":3,"cog/logger":9}],6:[function(t,e){var n=t("__browserify_process"),r=t("cog/logger")("monitor"),o=t("events").EventEmitter,i={NEW:"new",LOCAL_OFFER:"have-local-offer",LOCAL_PRANSWER:"have-local-pranswer",REMOTE_PRANSWER:"have-remote-pranswer",ACTIVE:"active",CLOSED:"closed"},a=e.exports=function(t,e){function a(){var n=s(t,e);r("captured state change, new state: "+n+", current state: "+u),c.active=n===i.ACTIVE,n!==u&&(c.emit("change",n,t),c.emit(u=n))}var c=new o,u=s(t),f=c.active=u===i.ACTIVE;return f&&n.nextTick(c.emit.bind(c,i.ACTIVE,t)),t.addEventListener("signalingstatechange",a),t.addEventListener("iceconnectionstatechange",a),c.stop=function(){t.removeEventListener("signalingstatechange",a),t.removeEventListener("iceconnectionstatechange",a)},c},s=a.getState=function(t,e){var n,o,a,s,c=t&&t.signalingState,u=t&&t.iceGatheringState,f=t&&t.iceConnectionState;return t?(e=e||"",n=t.localDescription,o=t.remoteDescription,a=c,"stable"===a&&(a=i.NEW,n&&o&&(a=i.REMOTE_PRANSWER)),s=a===i.REMOTE_PRANSWER&&"connected"===f,r(e+"signaling state: "+c+", iceGatheringState: "+u+", iceConnectionState: "+f),s?i.ACTIVE:a):i.CLOSED};a.isActive=function(t){var e=t&&"stable"===t.signalingState;return e&&s(t)===i.ACTIVE}},{__browserify_process:12,"cog/logger":9,events:11}],7:[function(t,e){var n=t("__browserify_process");(function(){function t(t){var e=!1;return function(){if(e)throw Error("Callback was already called.");e=!0,t.apply(r,arguments)}}var r,o,i={};r=this,null!=r&&(o=r.async),i.noConflict=function(){return r.async=o,i};var a=function(t,e){if(t.forEach)return t.forEach(e);for(var n=0;t.length>n;n+=1)e(t[n],n,t)},s=function(t,e){if(t.map)return t.map(e);var n=[];return a(t,function(t,r,o){n.push(e(t,r,o))}),n},c=function(t,e,n){return t.reduce?t.reduce(e,n):(a(t,function(t,r,o){n=e(n,t,r,o)}),n)},u=function(t){if(Object.keys)return Object.keys(t);var e=[];for(var n in t)t.hasOwnProperty(n)&&e.push(n);return e};void 0!==n&&n.nextTick?(i.nextTick=n.nextTick,i.setImmediate="undefined"!=typeof setImmediate?setImmediate:i.nextTick):"function"==typeof setImmediate?(i.nextTick=function(t){setImmediate(t)},i.setImmediate=i.nextTick):(i.nextTick=function(t){setTimeout(t,0)},i.setImmediate=i.nextTick),i.each=function(e,n,r){if(r=r||function(){},!e.length)return r();var o=0;a(e,function(i){n(i,t(function(t){t?(r(t),r=function(){}):(o+=1,o>=e.length&&r(null))}))})},i.forEach=i.each,i.eachSeries=function(t,e,n){if(n=n||function(){},!t.length)return n();var r=0,o=function(){e(t[r],function(e){e?(n(e),n=function(){}):(r+=1,r>=t.length?n(null):o())})};o()},i.forEachSeries=i.eachSeries,i.eachLimit=function(t,e,n,r){var o=f(e);o.apply(null,[t,n,r])},i.forEachLimit=i.eachLimit;var f=function(t){return function(e,n,r){if(r=r||function(){},!e.length||0>=t)return r();var o=0,i=0,a=0;(function s(){if(o>=e.length)return r();for(;t>a&&e.length>i;)i+=1,a+=1,n(e[i-1],function(t){t?(r(t),r=function(){}):(o+=1,a-=1,o>=e.length?r():s())})})()}},h=function(t){return function(){var e=Array.prototype.slice.call(arguments);return t.apply(null,[i.each].concat(e))}},l=function(t,e){return function(){var n=Array.prototype.slice.call(arguments);return e.apply(null,[f(t)].concat(n))}},p=function(t){return function(){var e=Array.prototype.slice.call(arguments);return t.apply(null,[i.eachSeries].concat(e))}},d=function(t,e,n,r){var o=[];e=s(e,function(t,e){return{index:e,value:t}}),t(e,function(t,e){n(t.value,function(n,r){o[t.index]=r,e(n)})},function(t){r(t,o)})};i.map=h(d),i.mapSeries=p(d),i.mapLimit=function(t,e,n,r){return g(e)(t,n,r)};var g=function(t){return l(t,d)};i.reduce=function(t,e,n,r){i.eachSeries(t,function(t,r){n(e,t,function(t,n){e=n,r(t)})},function(t){r(t,e)})},i.inject=i.reduce,i.foldl=i.reduce,i.reduceRight=function(t,e,n,r){var o=s(t,function(t){return t}).reverse();i.reduce(o,e,n,r)},i.foldr=i.reduceRight;var v=function(t,e,n,r){var o=[];e=s(e,function(t,e){return{index:e,value:t}}),t(e,function(t,e){n(t.value,function(n){n&&o.push(t),e()})},function(){r(s(o.sort(function(t,e){return t.index-e.index}),function(t){return t.value}))})};i.filter=h(v),i.filterSeries=p(v),i.select=i.filter,i.selectSeries=i.filterSeries;var y=function(t,e,n,r){var o=[];e=s(e,function(t,e){return{index:e,value:t}}),t(e,function(t,e){n(t.value,function(n){n||o.push(t),e()})},function(){r(s(o.sort(function(t,e){return t.index-e.index}),function(t){return t.value}))})};i.reject=h(y),i.rejectSeries=p(y);var m=function(t,e,n,r){t(e,function(t,e){n(t,function(n){n?(r(t),r=function(){}):e()})},function(){r()})};i.detect=h(m),i.detectSeries=p(m),i.some=function(t,e,n){i.each(t,function(t,r){e(t,function(t){t&&(n(!0),n=function(){}),r() | |
})},function(){n(!1)})},i.any=i.some,i.every=function(t,e,n){i.each(t,function(t,r){e(t,function(t){t||(n(!1),n=function(){}),r()})},function(){n(!0)})},i.all=i.every,i.sortBy=function(t,e,n){i.map(t,function(t,n){e(t,function(e,r){e?n(e):n(null,{value:t,criteria:r})})},function(t,e){if(t)return n(t);var r=function(t,e){var n=t.criteria,r=e.criteria;return r>n?-1:n>r?1:0};n(null,s(e.sort(r),function(t){return t.value}))})},i.auto=function(t,e){e=e||function(){};var n=u(t);if(!n.length)return e(null);var r={},o=[],s=function(t){o.unshift(t)},f=function(t){for(var e=0;o.length>e;e+=1)if(o[e]===t)return o.splice(e,1),void 0},h=function(){a(o.slice(0),function(t){t()})};s(function(){u(r).length===n.length&&(e(null,r),e=function(){})}),a(n,function(n){var o=t[n]instanceof Function?[t[n]]:t[n],l=function(t){var o=Array.prototype.slice.call(arguments,1);if(1>=o.length&&(o=o[0]),t){var s={};a(u(r),function(t){s[t]=r[t]}),s[n]=o,e(t,s),e=function(){}}else r[n]=o,i.setImmediate(h)},p=o.slice(0,Math.abs(o.length-1))||[],d=function(){return c(p,function(t,e){return t&&r.hasOwnProperty(e)},!0)&&!r.hasOwnProperty(n)};if(d())o[o.length-1](l,r);else{var g=function(){d()&&(f(g),o[o.length-1](l,r))};s(g)}})},i.waterfall=function(t,e){if(e=e||function(){},t.constructor!==Array){var n=Error("First argument to waterfall must be an array of functions");return e(n)}if(!t.length)return e();var r=function(t){return function(n){if(n)e.apply(null,arguments),e=function(){};else{var o=Array.prototype.slice.call(arguments,1),a=t.next();a?o.push(r(a)):o.push(e),i.setImmediate(function(){t.apply(null,o)})}}};r(i.iterator(t))()};var b=function(t,e,n){if(n=n||function(){},e.constructor===Array)t.map(e,function(t,e){t&&t(function(t){var n=Array.prototype.slice.call(arguments,1);1>=n.length&&(n=n[0]),e.call(null,t,n)})},n);else{var r={};t.each(u(e),function(t,n){e[t](function(e){var o=Array.prototype.slice.call(arguments,1);1>=o.length&&(o=o[0]),r[t]=o,n(e)})},function(t){n(t,r)})}};i.parallel=function(t,e){b({map:i.map,each:i.each},t,e)},i.parallelLimit=function(t,e,n){b({map:g(e),each:f(e)},t,n)},i.series=function(t,e){if(e=e||function(){},t.constructor===Array)i.mapSeries(t,function(t,e){t&&t(function(t){var n=Array.prototype.slice.call(arguments,1);1>=n.length&&(n=n[0]),e.call(null,t,n)})},e);else{var n={};i.eachSeries(u(t),function(e,r){t[e](function(t){var o=Array.prototype.slice.call(arguments,1);1>=o.length&&(o=o[0]),n[e]=o,r(t)})},function(t){e(t,n)})}},i.iterator=function(t){var e=function(n){var r=function(){return t.length&&t[n].apply(null,arguments),r.next()};return r.next=function(){return t.length-1>n?e(n+1):null},r};return e(0)},i.apply=function(t){var e=Array.prototype.slice.call(arguments,1);return function(){return t.apply(null,e.concat(Array.prototype.slice.call(arguments)))}};var w=function(t,e,n,r){var o=[];t(e,function(t,e){n(t,function(t,n){o=o.concat(n||[]),e(t)})},function(t){r(t,o)})};i.concat=h(w),i.concatSeries=p(w),i.whilst=function(t,e,n){t()?e(function(r){return r?n(r):(i.whilst(t,e,n),void 0)}):n()},i.doWhilst=function(t,e,n){t(function(r){return r?n(r):(e()?i.doWhilst(t,e,n):n(),void 0)})},i.until=function(t,e,n){t()?n():e(function(r){return r?n(r):(i.until(t,e,n),void 0)})},i.doUntil=function(t,e,n){t(function(r){return r?n(r):(e()?n():i.doUntil(t,e,n),void 0)})},i.queue=function(e,n){function r(t,e,r,o){e.constructor!==Array&&(e=[e]),a(e,function(e){var a={data:e,callback:"function"==typeof o?o:null};r?t.tasks.unshift(a):t.tasks.push(a),t.saturated&&t.tasks.length===n&&t.saturated(),i.setImmediate(t.process)})}void 0===n&&(n=1);var o=0,s={tasks:[],concurrency:n,saturated:null,empty:null,drain:null,push:function(t,e){r(s,t,!1,e)},unshift:function(t,e){r(s,t,!0,e)},process:function(){if(s.concurrency>o&&s.tasks.length){var n=s.tasks.shift();s.empty&&0===s.tasks.length&&s.empty(),o+=1;var r=function(){o-=1,n.callback&&n.callback.apply(n,arguments),s.drain&&0===s.tasks.length+o&&s.drain(),s.process()},i=t(r);e(n.data,i)}},length:function(){return s.tasks.length},running:function(){return o}};return s},i.cargo=function(t,e){var n=!1,r=[],o={tasks:r,payload:e,saturated:null,empty:null,drain:null,push:function(t,n){t.constructor!==Array&&(t=[t]),a(t,function(t){r.push({data:t,callback:"function"==typeof n?n:null}),o.saturated&&r.length===e&&o.saturated()}),i.setImmediate(o.process)},process:function c(){if(!n){if(0===r.length)return o.drain&&o.drain(),void 0;var i="number"==typeof e?r.splice(0,e):r.splice(0),u=s(i,function(t){return t.data});o.empty&&o.empty(),n=!0,t(u,function(){n=!1;var t=arguments;a(i,function(e){e.callback&&e.callback.apply(null,t)}),c()})}},length:function(){return r.length},running:function(){return n}};return o};var O=function(t){return function(e){var n=Array.prototype.slice.call(arguments,1);e.apply(null,n.concat([function(e){var n=Array.prototype.slice.call(arguments,1);"undefined"!=typeof console&&(e?console.error&&console.error(e):console[t]&&a(n,function(e){console[t](e)}))}]))}};i.log=O("log"),i.dir=O("dir"),i.memoize=function(t,e){var n={},r={};e=e||function(t){return t};var o=function(){var o=Array.prototype.slice.call(arguments),i=o.pop(),a=e.apply(null,o);a in n?i.apply(null,n[a]):a in r?r[a].push(i):(r[a]=[i],t.apply(null,o.concat([function(){n[a]=arguments;var t=r[a];delete r[a];for(var e=0,o=t.length;o>e;e++)t[e].apply(null,arguments)}])))};return o.memo=n,o.unmemoized=t,o},i.unmemoize=function(t){return function(){return(t.unmemoized||t).apply(null,arguments)}},i.times=function(t,e,n){for(var r=[],o=0;t>o;o++)r.push(o);return i.map(r,e,n)},i.timesSeries=function(t,e,n){for(var r=[],o=0;t>o;o++)r.push(o);return i.mapSeries(r,e,n)},i.compose=function(){var t=Array.prototype.reverse.call(arguments);return function(){var e=this,n=Array.prototype.slice.call(arguments),r=n.pop();i.reduce(t,n,function(t,n,r){n.apply(e,t.concat([function(){var t=arguments[0],e=Array.prototype.slice.call(arguments,1);r(t,e)}]))},function(t,n){r.apply(e,[t].concat(n))})}};var E=function(t,e){var n=function(){var n=this,r=Array.prototype.slice.call(arguments),o=r.pop();return t(e,function(t,e){t.apply(n,r.concat([e]))},o)};if(arguments.length>2){var r=Array.prototype.slice.call(arguments,2);return n.apply(this,r)}return n};i.applyEach=h(E),i.applyEachSeries=p(E),i.forever=function(t,e){function n(r){if(r){if(e)return e(r);throw r}t(n)}n()},"undefined"!=typeof define&&define.amd?define([],function(){return i}):e!==void 0&&e.exports?e.exports=i:r.async=i})()},{__browserify_process:12}],8:[function(t,e){"use strict";e.exports=function(t){return t=t||{},[].slice.call(arguments,1).forEach(function(e){if(e)for(var n in e)void 0===t[n]&&(t[n]=e[n])}),t}},{}],9:[function(t,e){"use strict";var n=[],r=[],o=[console],i=e.exports=function(t){function e(){return i=n.indexOf("*")>=0||n.indexOf(t)>=0}var i=e();return r[r.length]=e,function(){var e=[].slice.call(arguments);("string"==typeof e[0]||e[0]instanceof String)&&(e[0]=t+": "+e[0]),i&&o.forEach(function(t){t.log.apply(t,e)})}};i.reset=function(){return o=[],n=[],i.enable()},i.to=function(t){return o=o.concat(t||[]),i},i.enable=function(){return n=n.concat([].slice.call(arguments)),r.forEach(function(t){t()}),i}},{}],10:[function(t,e){"use strict";var n={chrome:/Chrom(?:e|ium)\/([0-9]+)\./,firefox:/Firefox\/([0-9]+)\./,opera:/Opera\/([0-9]+)\./},r=e.exports=function(t,e){var n,o,i,a=this||("undefined"!=typeof window?window:void 0);if(a)for(e=(e||["ms","o","moz","webkit"]).concat(""),n=e.length;n--;)if(o=e[n],i=o+(o?t.charAt(0).toUpperCase()+t.slice(1):t),a[i]!==void 0)return r.browser=r.browser||o.toLowerCase(),a[t]=a[i]};r.moz="undefined"!=typeof navigator&&!!navigator.mozGetUserMedia,"undefined"!=typeof navigator?Object.keys(n).forEach(function(t){var e=n[t].exec(navigator.userAgent);e&&(r.browser=t,r.browserVersion=r.version=parseInt(e[1],10))}):(r.browser="node",r.browserVersion=r.version="?")},{}],11:[function(t,e,n){var r=t("__browserify_process");r.EventEmitter||(r.EventEmitter=function(){});var o=n.EventEmitter=r.EventEmitter,i="function"==typeof Array.isArray?Array.isArray:function(t){return"[object Array]"===Object.prototype.toString.call(t)},a=10;o.prototype.setMaxListeners=function(t){this._events||(this._events={}),this._events.maxListeners=t},o.prototype.emit=function(t){if("error"===t&&(!this._events||!this._events.error||i(this._events.error)&&!this._events.error.length))throw arguments[1]instanceof Error?arguments[1]:Error("Uncaught, unspecified 'error' event.");if(!this._events)return!1;var e=this._events[t];if(!e)return!1;if("function"==typeof e){switch(arguments.length){case 1:e.call(this);break;case 2:e.call(this,arguments[1]);break;case 3:e.call(this,arguments[1],arguments[2]);break;default:var n=Array.prototype.slice.call(arguments,1);e.apply(this,n)}return!0}if(i(e)){for(var n=Array.prototype.slice.call(arguments,1),r=e.slice(),o=0,a=r.length;a>o;o++)r[o].apply(this,n);return!0}return!1},o.prototype.addListener=function(t,e){if("function"!=typeof e)throw Error("addListener only takes instances of Function");if(this._events||(this._events={}),this.emit("newListener",t,e),this._events[t])if(i(this._events[t])){if(!this._events[t].warned){var n;n=void 0!==this._events.maxListeners?this._events.maxListeners:a,n&&n>0&&this._events[t].length>n&&(this._events[t].warned=!0,console.error("(node) warning: possible EventEmitter memory leak detected. %d listeners added. Use emitter.setMaxListeners() to increase limit.",this._events[t].length),console.trace())}this._events[t].push(e)}else this._events[t]=[this._events[t],e];else this._events[t]=e;return this},o.prototype.on=o.prototype.addListener,o.prototype.once=function(t,e){var n=this;return n.on(t,function r(){n.removeListener(t,r),e.apply(this,arguments)}),this},o.prototype.removeListener=function(t,e){if("function"!=typeof e)throw Error("removeListener only takes instances of Function");if(!this._events||!this._events[t])return this;var n=this._events[t];if(i(n)){var r=n.indexOf(e);if(0>r)return this;n.splice(r,1),0==n.length&&delete this._events[t]}else this._events[t]===e&&delete this._events[t];return this},o.prototype.removeAllListeners=function(t){return t&&this._events&&this._events[t]&&(this._events[t]=null),this},o.prototype.listeners=function(t){return this._events||(this._events={}),this._events[t]||(this._events[t]=[]),i(this._events[t])||(this._events[t]=[this._events[t]]),this._events[t]}},{__browserify_process:12}],12:[function(t,e){var n=e.exports={};n.nextTick=function(){var t="undefined"!=typeof window&&window.setImmediate,e="undefined"!=typeof window&&window.postMessage&&window.addEventListener;if(t)return function(t){return window.setImmediate(t)};if(e){var n=[];return window.addEventListener("message",function(t){if(t.source===window&&"process-tick"===t.data&&(t.stopPropagation(),n.length>0)){var e=n.shift();e()}},!0),function(t){n.push(t),window.postMessage("process-tick","*")}}return function(t){setTimeout(t,0)}}(),n.title="browser",n.browser=!0,n.env={},n.argv=[],n.binding=function(){throw Error("process.binding is not supported")},n.cwd=function(){return"/"},n.chdir=function(){throw Error("process.chdir is not supported")}},{}]},{},[]),require=function e(t,n,r){function o(a,s){if(!n[a]){if(!t[a]){var c="function"==typeof require&&require;if(!s&&c)return c(a,!0);if(i)return i(a,!0);throw Error("Cannot find module '"+a+"'")}var u=n[a]={exports:{}};t[a][0].call(u.exports,function(e){var n=t[a][1][e];return o(n?n:e)},u,u.exports,e,t,n,r)}return n[a].exports}for(var i="function"==typeof require&&require,a=0;r.length>a;a++)o(r[a]);return o}({1:[function(t,e){"use strict";var n=t("cog/logger")("rtc-signaller-announce");t("cog/extend"),e.exports=function(t){function e(t,e){if(t&&e)for(var n in e)"clock"!=n&&(t[n]=e[n]);return t}return function(r,o,i){var a,s=r[0];return s&&s.id&&s.id!==t.id?(a=t.peers.get(s.id))?(n("signaller: "+t.id+" received update, data: ",s),e(a.data,s),t.emit("peer:update",s)):(a={id:s.id,roleIdx:[s.id,t.id].sort().indexOf(s.id),clock:i||{a:0,b:0},data:{}},e(a.data,s),t.peers.set(s.id,a),t.autoreply&&!i&&t.to(s.id).send("/announce",t.attributes),t.emit("peer:announce",s,a)):void 0}}},{"cog/extend":8,"cog/logger":10}],2:[function(t,e){"use strict";e.exports=function(e){return{announce:t("./announce")(e),leave:t("./leave")(e),lock:t("./lock")(e),unlock:t("./unlock")(e)}}},{"./announce":1,"./leave":3,"./lock":4,"./unlock":5}],3:[function(t,e){"use strict";e.exports=function(t){return function(e){var n=e[0],r=t.peers.get(n&&n.id);r&&(r.inactive=!0),t.emit("peer:leave",n.id,r)}}},{}],4:[function(t,e){"use strict";var n=t("cog/logger")("rtc-signaller-lock"),r=t("vectorclock"),o=t("collections/fast-map");e.exports=function(t){return function(e,i,a,s){var c,u=!1,f=e[0];a&&s&&(n('received "'+f+'" lock request from src: '+s.id),c=r.compare(a,s.clock),u=!t.locks.get(f)||c>0||0===c&&0===s.roleIdx,n("signaller "+t.id+" checking lock state"),n("clock value in message: ",a),n("cached peer clock state: ",s.clock),n("clock comparison = "+c+" ok: "+u,s),u&&(s.locks=s.locks||new o,s.locks.set(f,{id:e[1]||""})),t.to(s.id).send("/lockresult",{label:f,ok:u}))}}},{"cog/logger":10,"collections/fast-map":12,vectorclock:32}],5:[function(t,e){"use strict";var n=t("cog/logger")("rtc-signaller-lock");t("vectorclock"),e.exports=function(t){return function(e,r,o,i){var a=e[0],s=!1;o&&i&&(n('received "'+a+'" unlock request from src: '+i.id),i.locks&&(i.locks.delete(a),s=!0),t.to(i.id).send("/unlockresult",{label:a,ok:s}))}}},{"cog/logger":10,vectorclock:32}],"4+ejFo":[function(t,e){"use strict";var n=t("cog/logger")("rtc-signaller"),r=t("rtc-core/detect"),o=t("events").EventEmitter,i=t("uuid"),a=t("cog/extend"),s=t("collections/fast-map"),c=t("vectorclock"),u=e.exports=function(e,f){function h(t){u.loadPrimus(t,function(n,r){return n?m.emit("error",n):(e=r.connect(t),l(),void 0)})}function l(){if(d=e[C],g=e[j],v=t("./processor")(m),"function"!=typeof d)throw Error('provided messenger does not implement a "'+C+'" write method');e.on(_,v),e.on(x,function(){m.emit("open"),m.emit("connected")}),k=!0,m.emit("init")}function p(t){return"object"!=typeof t||t instanceof String?"function"==typeof t?null:t:JSON.stringify(t)}var d,g,v,y=(f||{}).autoreply,m=new o,b=m.id=i.v4(),w=m.attributes={browser:r.browser,browserVersion:r.browserVersion,id:b},O=m.peers=new s,E=m.locks=new s,_=(f||{}).dataEvent||"data",x=(f||{}).openEvent||"open",C=(f||{}).writeMethod||"write",j=(f||{}).closeMethod||"close",k=!1;m.autoreply=void 0===y||y;var A=m.send=function(){var t=[].slice.call(arguments),n=t.map(p).filter(Boolean).join("|");return k?d.call(e,n):m.once("init",function(){d.call(e,n)})};return m.announce=function(t,e){return a(w,t,{id:m.id}),(e||A)("/announce",w)},m.isMaster=function(t){var e=O.get(t);return e&&0!==e.roleIdx},m.leave=function(){A("/leave",{id:b}),"function"==typeof g&&g.call(e)},m.lock=function(t,e,n){function r(e,i){var s=e&&e.ok;i&&i.id===t&&e&&e.label===a&&(m.removeListener("lockresult",r),s?E.set(a,o={id:u}):o&&E.delete(a),n(s?null:Error("could not acquire lock")))}var o,a,c=O.get(t),u=i.v4();return"function"==typeof e&&(n=e,e={}),n=n||function(){},c?(a=(e||{}).label||(e||{}).name||"default",o=E.get(a),o&&!o.provisional?n():(c.locks=c.locks||new s,c.locks.get(a)?n(Error("remote lock in place, cannot request lock")):(E.set(a,o={id:u,provisional:!0}),m.on("lockresult",r),m.to(t).send("/lock",a,u),void 0))):n(Error("unknown target id - cannot initiate lock"))},m.to=function(t){var r=function(){var r,o=m.peers.get(t);if(!o)throw Error("Unknown peer: "+t);o.inactive||(r=["/to",t,{id:m.id,clock:o.clock}].concat([].slice.call(arguments)),c.increment(o,["a","b"][1^o.roleIdx]),setTimeout(function(){var o=r.map(p).filter(Boolean).join("|");n("TX ("+t+"): ",o),d.call(e,o)},0))};return{announce:function(t){return m.announce(t,r)},send:r}},m.unlock=function(t,e,n){function r(e,i){var a=e&&e.ok;i&&i.id===t&&e&&e.label===o&&(m.removeListener("unlockresult",r),a&&E.delete(o),n(a?null:Error("could not release lock: "+o)))}var o,i=O.get(t);return"function"==typeof e&&(n=e,e={}),n=n||function(){},o=(e||{}).label||(e||{}).name||"default",i&&E.get(o)?(m.on("unlockresult",r),m.to(t).send("/unlock",o,E.get(o)),void 0):n(Error("no local lock with label "+o))},"string"==typeof e||e instanceof String?h(e):l(),m};u.loadPrimus=t("./primus-loader")},{"./primus-loader":33,"./processor":34,"cog/extend":8,"cog/logger":10,"collections/fast-map":12,events:35,"rtc-core/detect":29,uuid:31,vectorclock:32}],"rtc-signaller":[function(t,e){e.exports=t("4+ejFo")},{}],8:[function(t,e){"use strict";e.exports=function(t){return[].slice.call(arguments,1).forEach(function(e){if(e)for(var n in e)t[n]=e[n]}),t}},{}],9:[function(t,e){"use strict";e.exports=function(t){var e,n,r,o="string"==typeof t||t instanceof String,i=/^\-?\d+\.?\d*$/;if(!o||2>t.length)return o&&i.test(t)?parseFloat(t):t;if("true"===t||"false"===t)return"true"===t;if("null"===t)return null;if(n=t.charAt(0),r=t.charAt(t.length-1),e="{"==n&&"}"==r||"["==n&&"]"==r)try{return JSON.parse(t)}catch(a){}return i.test(t)?parseFloat(t):t}},{}],10:[function(t,e){"use strict";var n=[],r=[],o=[console],i=e.exports=function(t){function e(){return i=n.indexOf("*")>=0||n.indexOf(t)>=0}var i=e();return r[r.length]=e,function(){var e=[].slice.call(arguments);("string"==typeof e[0]||e[0]instanceof String)&&(e[0]=t+": "+e[0]),i&&o.forEach(function(t){t.log.apply(t,e)})}};i.reset=function(){return o=[],n=[],i.enable()},i.to=function(t){return o=o.concat(t||[]),i},i.enable=function(){return n=n.concat([].slice.call(arguments)),r.forEach(function(t){t()}),i}},{}],11:[function(t,e){"use strict";function n(t,e){return this instanceof n?(e=e||Function.noop,this.getDefault=e,this.store={},this.length=0,this.addEach(t),void 0):new n(t,e)}function r(t){return"~"+t}function o(t){return t.slice(1)}t("./shim");var i=t("./generic-collection"),a=t("./generic-map"),s=t("./listen/property-changes");e.exports=n,n.Dict=n,Object.addEach(n.prototype,i.prototype),Object.addEach(n.prototype,a.prototype),Object.addEach(n.prototype,s.prototype),n.prototype.constructClone=function(t){return new this.constructor(t,this.mangle,this.getDefault)},n.prototype.assertString=function(t){if("string"!=typeof t)throw new TypeError("key must be a string but Got "+t)},n.prototype.get=function(t,e){this.assertString(t);var n=r(t);return n in this.store?this.store[n]:arguments.length>1?e:this.getDefault(t)},n.prototype.set=function(t,e){this.assertString(t);var n=r(t);return n in this.store?(this.dispatchesBeforeMapChanges&&this.dispatchBeforeMapChange(t,this.store[n]),this.store[n]=e,this.dispatchesMapChanges&&this.dispatchMapChange(t,e),!1):(this.dispatchesMapChanges&&this.dispatchBeforeMapChange(t,void 0),this.length++,this.store[n]=e,this.dispatchesMapChanges&&this.dispatchMapChange(t,e),!0)},n.prototype.has=function(t){this.assertString(t);var e=r(t);return e in this.store},n.prototype["delete"]=function(t){this.assertString(t);var e=r(t);return e in this.store?(this.dispatchesMapChanges&&this.dispatchBeforeMapChange(t,this.store[e]),delete this.store[r(t)],this.length--,this.dispatchesMapChanges&&this.dispatchMapChange(t,void 0),!0):!1},n.prototype.clear=function(){var t,e;for(e in this.store)t=o(e),this.dispatchesMapChanges&&this.dispatchBeforeMapChange(t,this.store[e]),delete this.store[e],this.dispatchesMapChanges&&this.dispatchMapChange(t,void 0);this.length=0},n.prototype.reduce=function(t,e,n){for(var r in this.store)e=t.call(n,e,this.store[r],o(r),this);return e},n.prototype.reduceRight=function(t,e,n){var r=this,i=this.store;return Object.keys(this.store).reduceRight(function(e,a){return t.call(n,e,i[a],o(a),r)},e)},n.prototype.one=function(){var t;for(t in this.store)return this.store[t]}},{"./generic-collection":14,"./generic-map":15,"./listen/property-changes":20,"./shim":27}],12:[function(t,e){"use strict";function n(t,e,o,i){return this instanceof n?(e=e||Object.equals,o=o||Object.hash,i=i||Function.noop,this.contentEquals=e,this.contentHash=o,this.getDefault=i,this.store=new r(void 0,function(t,n){return e(t.key,n.key)},function(t){return o(t.key)}),this.length=0,this.addEach(t),void 0):new n(t,e,o,i)}t("./shim");var r=t("./fast-set"),o=t("./generic-collection"),i=t("./generic-map"),a=t("./listen/property-changes");e.exports=n,n.FastMap=n,Object.addEach(n.prototype,o.prototype),Object.addEach(n.prototype,i.prototype),Object.addEach(n.prototype,a.prototype),n.prototype.constructClone=function(t){return new this.constructor(t,this.contentEquals,this.contentHash,this.getDefault)},n.prototype.log=function(t,e){e=e||this.stringify,this.store.log(t,e)},n.prototype.stringify=function(t,e){return e+JSON.stringify(t.key)+": "+JSON.stringify(t.value)}},{"./fast-set":13,"./generic-collection":14,"./generic-map":15,"./listen/property-changes":20,"./shim":27}],13:[function(t,e){"use strict";function n(t,e,r,o){return this instanceof n?(e=e||Object.equals,r=r||Object.hash,o=o||Function.noop,this.contentEquals=e,this.contentHash=r,this.getDefault=o,this.buckets=new this.Buckets(null,this.Bucket),this.length=0,this.addEach(t),void 0):new n(t,e,r,o)}t("./shim");var r=t("./dict"),o=t("./list"),i=t("./generic-collection"),a=t("./generic-set"),s=t("./tree-log"),c=t("./listen/property-changes");Object.prototype.hasOwnProperty,e.exports=n,n.FastSet=n,Object.addEach(n.prototype,i.prototype),Object.addEach(n.prototype,a.prototype),Object.addEach(n.prototype,c.prototype),n.prototype.Buckets=r,n.prototype.Bucket=o,n.prototype.constructClone=function(t){return new this.constructor(t,this.contentEquals,this.contentHash,this.getDefault)},n.prototype.has=function(t){var e=this.contentHash(t);return this.buckets.get(e).has(t)},n.prototype.get=function(t){var e=this.contentHash(t),n=this.buckets;return n.has(e)?n.get(e).get(t):this.getDefault(t)},n.prototype["delete"]=function(t){var e=this.contentHash(t),n=this.buckets;if(n.has(e)){var r=n.get(e);if(r["delete"](t))return this.length--,0===r.length&&n["delete"](e),!0}return!1},n.prototype.clear=function(){this.buckets.clear(),this.length=0},n.prototype.add=function(t){var e=this.contentHash(t),n=this.buckets;return n.has(e)||n.set(e,new this.Bucket(null,this.contentEquals)),n.get(e).has(t)?!1:(n.get(e).add(t),this.length++,!0)},n.prototype.reduce=function(t,e){var n=arguments[2],r=this.buckets,o=0;return r.reduce(function(e,r){return r.reduce(function(e,r){return t.call(n,e,r,o++,this)},e,this)},e,this)},n.prototype.one=function(){return this.length>0?this.buckets.one().one():void 0},n.prototype.iterate=function(){return this.buckets.values().flatten().iterate()},n.prototype.log=function(t,e,n,r){t=t||s.unicodeSharp,e=e||this.logNode,n||(n=console.log,r=console),n=n.bind(r);var o=this.buckets,i=o.keys();i.forEach(function(a,s){var c,u;s===i.length-1?(c=t.fromAbove,u=" "):0===s?(c=t.branchDown,u=t.strafe):(c=t.fromBoth,u=t.strafe);var f=o.get(a);n.call(r,c+t.through+t.branchDown+" "+a),f.forEach(function(o,i){var a,s;i===f.head.prev?(a=t.fromAbove,s=" "):(a=t.fromBoth,s=t.strafe);var c;e(i,function(e){c?n.call(r,u+" "+s+" "+e):(n.call(r,u+" "+a+t.through+t.through+e),c=!0)},function(e){n.call(r,u+" "+t.strafe+" "+e)})})})},n.prototype.logNode=function(t,e){var n=t.value;Object(n)===n?JSON.stringify(n,null,4).split("\n").forEach(function(t){e(" "+t)}):e(" "+n)}},{"./dict":11,"./generic-collection":14,"./generic-set":17,"./list":18,"./listen/property-changes":20,"./shim":27,"./tree-log":28}],14:[function(t,e){"use strict";function n(){throw Error("Can't construct. GenericCollection is a mixin.")}e.exports=n,n.prototype.addEach=function(t){if(t&&Object(t)===t)if("function"==typeof t.forEach)t.forEach(this.add,this);else if("number"==typeof t.length)for(var e=0;t.length>e;e++)this.add(t[e],e);else Object.keys(t).forEach(function(e){this.add(t[e],e)},this);return this},n.prototype.deleteEach=function(t,e){return t.forEach(function(t){this["delete"](t,e)},this),this},n.prototype.forEach=function(t){var e=arguments[1];return this.reduce(function(n,r,o,i,a){t.call(e,r,o,i,a)},void 0)},n.prototype.map=function(t){var e=arguments[1],n=[];return this.reduce(function(r,o,i,a,s){n.push(t.call(e,o,i,a,s))},void 0),n},n.prototype.enumerate=function(t){null==t&&(t=0);var e=[];return this.reduce(function(n,r){e.push([t++,r])},void 0),e},n.prototype.group=function(t,e,n){n=n||Object.equals;var r=[],o=[];return this.forEach(function(i,a,s){var c,a=t.call(e,i,a,s),u=o.indexOf(a,n);-1===u?(c=[],r.push([a,c]),o.push(a)):c=r[u][1],c.push(i)}),r},n.prototype.toArray=function(){return this.map(Function.identity)},n.prototype.toObject=function(){var t={};return this.reduce(function(e,n,r){t[r]=n},void 0),t},n.prototype.filter=function(t){var e=arguments[1],n=this.constructClone();return this.reduce(function(r,o,i,a,s){t.call(e,o,i,a,s)&&n.add(o)},void 0),n},n.prototype.every=function(t){var e=arguments[1];return this.reduce(function(n,r,o,i,a){return n&&t.call(e,r,o,i,a)},!0)},n.prototype.some=function(t){var e=arguments[1];return this.reduce(function(n,r,o,i,a){return n||t.call(e,r,o,i,a)},!1)},n.prototype.all=function(){return this.every(Boolean)},n.prototype.any=function(){return this.some(Boolean)},n.prototype.min=function(t){t=t||this.contentCompare||Object.compare;var e=!0;return this.reduce(function(n,r){return e?(e=!1,r):0>t(r,n)?r:n},void 0)},n.prototype.max=function(t){t=t||this.contentCompare||Object.compare;var e=!0;return this.reduce(function(n,r){return e?(e=!1,r):t(r,n)>0?r:n},void 0)},n.prototype.sum=function(t){return t=void 0===t?0:t,this.reduce(function(t,e){return t+e},t)},n.prototype.average=function(t){var e=void 0===t?0:t,n=void 0===t?0:t;return this.reduce(function(t,r){e+=r,n+=1},void 0),e/n},n.prototype.concat=function(){for(var t=this.constructClone(this),e=0;arguments.length>e;e++)t.addEach(arguments[e]);return t},n.prototype.flatten=function(){var t=this;return this.reduce(function(e,n){return n.forEach(function(t){this.push(t)},e,t),e},[])},n.prototype.zip=function(){var t=Array.prototype.slice.call(arguments);return t.unshift(this),Array.unzip(t)},n.prototype.join=function(t){return this.reduce(function(e,n){return e+t+n})},n.prototype.sorted=function(t,e,n){return t=t||this.contentCompare||Object.compare,t.by?(e=t.by,t=t.compare||this.contentCompare||Object.compare):e=e||Function.identity,void 0===n&&(n=1),this.map(function(t){return{by:e(t),value:t}}).sort(function(e,r){return t(e.by,r.by)*n}).map(function(t){return t.value})},n.prototype.reversed=function(){return this.constructClone(this).reverse()},n.prototype.clone=function(t,e){if(void 0===t)t=1/0;else if(0===t)return this;var n=this.constructClone();return this.forEach(function(r,o){n.add(Object.clone(r,t-1,e),o)},this),n},n.prototype.only=function(){return 1===this.length?this.one():void 0},n.prototype.iterator=function(){return this.iterate.apply(this,arguments)},t("./shim-array")},{"./shim-array":23}],15:[function(t,e){"use strict";function n(){throw Error("Can't construct. GenericMap is a mixin.")}function r(t,e){this.key=t,this.value=e}var o=t("./shim-object"),i=t("./listen/map-changes"),a=t("./listen/property-changes");e.exports=n,o.addEach(n.prototype,i.prototype),o.addEach(n.prototype,a.prototype),n.prototype.isMap=!0,n.prototype.addEach=function(t){return t&&o(t)===t&&("function"==typeof t.forEach?t.isMap===!0?t.forEach(function(t,e){this.set(e,t)},this):t.forEach(function(t){this.set(t[0],t[1])},this):o.keys(t).forEach(function(e){this.set(e,t[e])},this)),this},n.prototype.get=function(t,e){var n=this.store.get(new this.Item(t));return n?n.value:arguments.length>1?e:this.getDefault(t)},n.prototype.set=function(t,e){var n=new this.Item(t,e),r=this.store.get(n),o=!1;return r?(this.dispatchesMapChanges&&this.dispatchBeforeMapChange(t,r.value),r.value=e,this.dispatchesMapChanges&&this.dispatchMapChange(t,e)):(this.dispatchesMapChanges&&this.dispatchBeforeMapChange(t,void 0),this.store.add(n)&&(this.length++,o=!0),this.dispatchesMapChanges&&this.dispatchMapChange(t,e)),o},n.prototype.add=function(t,e){return this.set(e,t)},n.prototype.has=function(t){return this.store.has(new this.Item(t))},n.prototype["delete"]=function(t){var e=new this.Item(t);if(this.store.has(e)){var n=this.store.get(e).value;return this.dispatchesMapChanges&&this.dispatchBeforeMapChange(t,n),this.store["delete"](e),this.length--,this.dispatchesMapChanges&&this.dispatchMapChange(t,void 0),!0}return!1},n.prototype.clear=function(){var t;this.dispatchesMapChanges&&(this.forEach(function(t,e){this.dispatchBeforeMapChange(e,t)},this),t=this.keys()),this.store.clear(),this.length=0,this.dispatchesMapChanges&&t.forEach(function(t){this.dispatchMapChange(t)},this)},n.prototype.reduce=function(t,e,n){return this.store.reduce(function(e,r){return t.call(n,e,r.value,r.key,this)},e,this)},n.prototype.reduceRight=function(t,e,n){return this.store.reduceRight(function(e,r){return t.call(n,e,r.value,r.key,this)},e,this)},n.prototype.keys=function(){return this.map(function(t,e){return e})},n.prototype.values=function(){return this.map(Function.identity)},n.prototype.entries=function(){return this.map(function(t,e){return[e,t]})},n.prototype.items=function(){return this.entries()},n.prototype.equals=function(t,e){if(e=e||o.equals,this===t)return!0;if(o.can(t,"every"))return t.length===this.length&&t.every(function(t,n){return e(this.get(n),t)},this);var n=o.keys(t);return n.length===this.length&&o.keys(t).every(function(n){return e(this.get(n),t[n])},this)},n.prototype.Item=r,r.prototype.equals=function(t){return o.equals(this.key,t.key)&&o.equals(this.value,t.value)},r.prototype.compare=function(t){return o.compare(this.key,t.key)}},{"./listen/map-changes":19,"./listen/property-changes":20,"./shim-object":25}],16:[function(t,e){function n(){throw Error("Can't construct. GenericOrder is a mixin.")}var r=t("./shim-object");e.exports=n,n.prototype.equals=function(t,e){return e=e||this.contentEquals||r.equals,this===t?!0:t?this.length===t.length&&this.zip(t).every(function(t){return e(t[0],t[1])}):!1},n.prototype.compare=function(t,e){if(e=e||this.contentCompare||r.compare,this===t)return 0;if(!t)return 1;var n=Math.min(this.length,t.length),o=this.zip(t).reduce(function(t,r,o){return 0===t?o>=n?t:e(r[0],r[1]):t},0);return 0===o?this.length-t.length:o}},{"./shim-object":25}],17:[function(t,e){function n(){throw Error("Can't construct. GenericSet is a mixin.")}e.exports=n,n.prototype.union=function(t){var e=this.constructClone(this);return e.addEach(t),e},n.prototype.intersection=function(t){return this.constructClone(this.filter(function(e){return t.has(e)}))},n.prototype.difference=function(t){var e=this.constructClone(this);return e.deleteEach(t),e},n.prototype.symmetricDifference=function(t){var e=this.union(t),n=this.intersection(t);return e.difference(n)},n.prototype.equals=function(t,e){var n=this;return Object.can(t,"reduce")&&this.length===t.length&&t.reduce(function(t,r){return t&&n.has(r,e)},!0)},n.prototype.contains=function(t){return this.has(t)},n.prototype.remove=function(t){return this["delete"](t)},n.prototype.toggle=function(t){this.has(t)?this["delete"](t):this.add(t)}},{}],18:[function(t,e){"use strict";function n(t,e,r){if(!(this instanceof n))return new n(t,e,r);var o=this.head=new this.Node;o.next=o,o.prev=o,this.contentEquals=e||Object.equals,this.getDefault=r||Function.noop,this.length=0,this.addEach(t)}function r(t){this.head=t,this.at=t.next}function o(t){this.value=t,this.prev=null,this.next=null}e.exports=n,t("./shim");var i=t("./generic-collection"),a=t("./generic-order"),s=t("./listen/property-changes"),c=t("./listen/range-changes");n.List=n,Object.addEach(n.prototype,i.prototype),Object.addEach(n.prototype,a.prototype),Object.addEach(n.prototype,s.prototype),Object.addEach(n.prototype,c.prototype),n.prototype.constructClone=function(t){return new this.constructor(t,this.contentEquals,this.getDefault)},n.prototype.find=function(t,e){e=e||this.contentEquals;for(var n=this.head,r=n.next;r!==n;){if(e(r.value,t))return r; | |
r=r.next}},n.prototype.findLast=function(t,e){e=e||this.contentEquals;for(var n=this.head,r=n.prev;r!==n;){if(e(r.value,t))return r;r=r.prev}},n.prototype.has=function(t,e){return!!this.find(t,e)},n.prototype.get=function(t,e){var n=this.find(t,e);return n?n.value:this.getDefault(t)},n.prototype["delete"]=function(t,e){var n=this.findLast(t,e);if(n){if(this.dispatchesRangeChanges){var r=[],o=[t];this.dispatchBeforeRangeChange(r,o,n.index)}return n["delete"](),this.length--,this.dispatchesRangeChanges&&(this.updateIndexes(n.next,n.index),this.dispatchRangeChange(r,o,n.index)),!0}return!1},n.prototype.clear=function(){var t,e;this.dispatchesRangeChanges&&(e=this.toArray(),t=[],this.dispatchBeforeRangeChange(t,e,0)),this.head.next=this.head.prev=this.head,this.length=0,this.dispatchesRangeChanges&&this.dispatchRangeChange(t,e,0)},n.prototype.add=function(t){var e=new this.Node(t);return this.dispatchesRangeChanges&&(e.index=this.length,this.dispatchBeforeRangeChange([t],[],e.index)),this.head.addBefore(e),this.length++,this.dispatchesRangeChanges&&this.dispatchRangeChange([t],[],e.index),!0},n.prototype.push=function(){var t=this.head;if(this.dispatchesRangeChanges){var e=Array.prototype.slice.call(arguments),n=[],r=this.length;this.dispatchBeforeRangeChange(e,n,r);var o=this.head.prev}for(var i=0;arguments.length>i;i++){var a=arguments[i],s=new this.Node(a);t.addBefore(s)}this.length+=arguments.length,this.dispatchesRangeChanges&&(this.updateIndexes(o.next,void 0===o.index?0:o.index+1),this.dispatchRangeChange(e,n,r))},n.prototype.unshift=function(){if(this.dispatchesRangeChanges){var t=Array.prototype.slice.call(arguments),e=[];this.dispatchBeforeRangeChange(t,e,0)}for(var n=this.head,r=0;arguments.length>r;r++){var o=arguments[r],i=new this.Node(o);n.addAfter(i),n=i}this.length+=arguments.length,this.dispatchesRangeChanges&&(this.updateIndexes(this.head.next,0),this.dispatchRangeChange(t,e,0))},n.prototype.pop=function(){var t,e=this.head;if(e.prev!==e){if(t=e.prev.value,this.dispatchesRangeChanges){var n=[],r=[t],o=this.length-1;this.dispatchBeforeRangeChange(n,r,o)}e.prev["delete"](),this.length--,this.dispatchesRangeChanges&&this.dispatchRangeChange(n,r,o)}return t},n.prototype.shift=function(){var t,e=this.head;if(e.prev!==e){if(t=e.next.value,this.dispatchesRangeChanges){var n=[],r=[t];this.dispatchBeforeRangeChange(n,r,0)}e.next["delete"](),this.length--,this.dispatchesRangeChanges&&(this.updateIndexes(this.head.next,0),this.dispatchRangeChange(n,r,0))}return t},n.prototype.peek=function(){return this.head!==this.head.next?this.head.next.value:void 0},n.prototype.poke=function(t){this.head!==this.head.next?this.head.next.value=t:this.push(t)},n.prototype.one=function(){return this.peek()},n.prototype.scan=function(t,e){var n=this.head;if("number"==typeof t){var r=t;if(r>=0)for(t=n.next;r&&(r--,t=t.next,t!=n););else for(t=n;0>r&&(r++,t=t.prev,t!=n););return t}return t||e},n.prototype.slice=function(t,e){var n=[],r=this.head;for(t=this.scan(t,r.next),e=this.scan(e,r);t!==e&&t!==r;)n.push(t.value),t=t.next;return n},n.prototype.splice=function(t,e){return this.swap(t,e,Array.prototype.slice.call(arguments,2))},n.prototype.swap=function(t,e,n){var r=t;t=this.scan(t,this.head),null==e&&(e=1/0),n=Array.from(n);for(var o=[],i=t;e--&&e>=0&&i!==this.head;)o.push(i.value),i=i.next;var a,s;this.dispatchesRangeChanges&&(a=t===this.head?this.length:t.prev===this.head?0:t.index,s=t.prev,this.dispatchBeforeRangeChange(n,o,a));for(var i=t,c=0,i=t;o.length>c;c++,i=i.next)i["delete"]();null==r&&i===this.head&&(i=this.head.next);for(var c=0;n.length>c;c++){var u=new this.Node(n[c]);i.addBefore(u)}return this.length+=n.length-o.length,this.dispatchesRangeChanges&&(t===this.head?this.updateIndexes(this.head.next,0):this.updateIndexes(s.next,s.index+1),this.dispatchRangeChange(n,o,a)),o},n.prototype.reverse=function(){if(this.dispatchesRangeChanges){var t=this.toArray(),e=t.reversed();this.dispatchBeforeRangeChange(e,t,0)}var n=this.head;do{var r=n.next;n.next=n.prev,n.prev=r,n=n.next}while(n!==this.head);return this.dispatchesRangeChanges&&this.dispatchRangeChange(e,t,0),this},n.prototype.sort=function(){this.swap(0,this.length,this.sorted())},n.prototype.reduce=function(t,e){for(var n=arguments[2],r=this.head,o=r.next;o!==r;)e=t.call(n,e,o.value,o,this),o=o.next;return e},n.prototype.reduceRight=function(t,e){for(var n=arguments[2],r=this.head,o=r.prev;o!==r;)e=t.call(n,e,o.value,o,this),o=o.prev;return e},n.prototype.updateIndexes=function(t,e){for(;t!==this.head;)t.index=e++,t=t.next},n.prototype.makeObservable=function(){this.head.index=-1,this.updateIndexes(this.head.next,0),this.dispatchesRangeChanges=!0},n.prototype.iterate=function(){return new r(this.head)},r.prototype.next=function(){if(this.at===this.head)throw StopIteration;var t=this.at.value;return this.at=this.at.next,t},n.prototype.Node=o,o.prototype["delete"]=function(){this.prev.next=this.next,this.next.prev=this.prev},o.prototype.addBefore=function(t){var e=this.prev;this.prev=t,t.prev=e,e.next=t,t.next=this},o.prototype.addAfter=function(t){var e=this.next;this.next=t,t.next=e,e.prev=t,t.prev=this}},{"./generic-collection":14,"./generic-order":16,"./listen/property-changes":20,"./listen/range-changes":21,"./shim":27}],19:[function(t,e){"use strict";function n(){throw Error("Can't construct. MapChanges is a mixin.")}var r=t("weak-map"),o=t("../list");e.exports=n,Object.prototype.hasOwnProperty;var i=new r;n.prototype.getAllMapChangeDescriptors=function(){var e=t("../dict");return i.has(this)||i.set(this,e()),i.get(this)},n.prototype.getMapChangeDescriptor=function(t){var e=this.getAllMapChangeDescriptors();return t=t||"",e.has(t)||e.set(t,{willChangeListeners:new o,changeListeners:new o}),e.get(t)},n.prototype.addMapChangeListener=function(t,e,n){!this.isObservable&&this.makeObservable&&this.makeObservable();var r,o=this.getMapChangeDescriptor(e);r=n?o.willChangeListeners:o.changeListeners,r.push(t),Object.defineProperty(this,"dispatchesMapChanges",{value:!0,writable:!0,configurable:!0,enumerable:!1});var i=this;return function(){i&&(i.removeMapChangeListener(t,e,n),i=null)}},n.prototype.removeMapChangeListener=function(t,e,n){var r,o=this.getMapChangeDescriptor(e);r=n?o.willChangeListeners:o.changeListeners;var i=r.findLast(t);if(!i)throw Error("Can't remove listener: does not exist.");i["delete"]()},n.prototype.dispatchMapChange=function(t,e,n){var r=this.getAllMapChangeDescriptors(),o="Map"+(n?"WillChange":"Change");r.forEach(function(r,i){if(!r.isActive){r.isActive=!0;var a;a=n?r.willChangeListeners:r.changeListeners;var s="handle"+(i.slice(0,1).toUpperCase()+i.slice(1))+o;try{a.forEach(function(n){if(n[s])n[s](e,t,this);else{if(!n.call)throw Error("Handler "+n+" has no method "+s+" and is not callable");n.call(n,e,t,this)}},this)}finally{r.isActive=!1}}},this)},n.prototype.addBeforeMapChangeListener=function(t,e){return this.addMapChangeListener(t,e,!0)},n.prototype.removeBeforeMapChangeListener=function(t,e){return this.removeMapChangeListener(t,e,!0)},n.prototype.dispatchBeforeMapChange=function(t,e){return this.dispatchMapChange(t,e,!0)}},{"../dict":11,"../list":18,"weak-map":22}],20:[function(t,e){function n(){throw Error("This is an abstract interface. Mix it. Don't construct it")}t("../shim");var r=t("weak-map"),o=Object.prototype.hasOwnProperty,i=new r,a=new r;e.exports=n,n.debug=!0,n.prototype.getOwnPropertyChangeDescriptor=function(t){i.has(this)||i.set(this,{});var e=i.get(this);return o.call(e,t)||(e[t]={willChangeListeners:[],changeListeners:[]}),e[t]},n.prototype.hasOwnPropertyChangeDescriptor=function(t){if(!i.has(this))return!1;if(!t)return!0;var e=i.get(this);return o.call(e,t)?!0:!1},n.prototype.addOwnPropertyChangeListener=function(t,e,r){this.makeObservable&&!this.isObservable&&this.makeObservable();var o,i=n.getOwnPropertyChangeDescriptor(this,t);o=r?i.willChangeListeners:i.changeListeners,n.makePropertyObservable(this,t),o.push(e);var a=this;return function(){n.removeOwnPropertyChangeListener(a,t,o,r),a=null}},n.prototype.addBeforeOwnPropertyChangeListener=function(t,e){return n.addOwnPropertyChangeListener(this,t,e,!0)},n.prototype.removeOwnPropertyChangeListener=function(t,e,r){var o,i=n.getOwnPropertyChangeDescriptor(this,t);o=r?i.willChangeListeners:i.changeListeners;var a=o.lastIndexOf(e);if(-1===a)throw Error("Can't remove listener: does not exist.");o.splice(a,1),0===i.changeListeners.length+i.willChangeListeners.length&&n.makePropertyUnobservable(this,t)},n.prototype.removeBeforeOwnPropertyChangeListener=function(t,e){return n.removeOwnPropertyChangeListener(this,t,e,!0)},n.prototype.dispatchOwnPropertyChange=function(t,e,r){var o=n.getOwnPropertyChangeDescriptor(this,t);if(!o.isActive){o.isActive=!0;var i;i=r?o.willChangeListeners:o.changeListeners;var a=(r?"Will":"")+"Change",s="handleProperty"+a,c=t+"";c=c&&c[0].toUpperCase()+c.slice(1);var u="handle"+c+a;try{i.forEach(function(n){var r=n;if(n=n[u]||n[s]||n,!n.call)throw Error("No event listener for "+u+" or "+s+" or call on "+n);n.call(r,e,t,this)},this)}finally{o.isActive=!1}}},n.prototype.dispatchBeforeOwnPropertyChange=function(t,e){return n.dispatchOwnPropertyChange(this,t,e,!0)},n.prototype.makePropertyObservable=function(t){if(!Array.isArray(this)){if(!Object.isExtensible(this,t))throw Error("Can't make property "+JSON.stringify(t)+" observable on "+this+" because object is not extensible");var e;"object"==typeof this.__state__?e=this.__state__:(e={},Object.isExtensible(this,"__state__")&&Object.defineProperty(this,"__state__",{value:e,writable:!0,enumerable:!1})),e[t]=this[t],a.has(this)||(r={},a.set(this,r));var r=a.get(this);if(!o.call(r,t)){var i,s=this;Object.getOwnPropertyDescriptor(s,t);do{if(i=Object.getOwnPropertyDescriptor(s,t))break;s=Object.getPrototypeOf(s)}while(s);if(i=i||{value:void 0,enumerable:!0,writable:!0,configurable:!0},!i.configurable)throw Error("Can't observe non-configurable properties");if(r[t]=i,i.writable||i.set){var c;c="value"in i?{get:function(){return i.value},set:function(r){return r===i.value?r:(n.dispatchBeforeOwnPropertyChange(this,t,i.value),i.value=r,e[t]=r,n.dispatchOwnPropertyChange(this,t,r),r)},enumerable:i.enumerable,configurable:!0}:{get:function(){return i.get?i.get.apply(this,arguments):void 0},set:function(r){var o;return i.get&&(o=i.get.apply(this,arguments)),i.set&&i.set.apply(this,arguments),i.get&&(r=i.get.apply(this,arguments),e[t]=r),r===o?r:(n.dispatchBeforeOwnPropertyChange(this,t,o),n.dispatchOwnPropertyChange(this,t,r),r)},enumerable:i.enumerable,configurable:!0},Object.defineProperty(this,t,c)}}}},n.prototype.makePropertyUnobservable=function(t){if(!Array.isArray(this)){if(!a.has(this))throw Error("Can't uninstall observer on property");var e=a.get(this);if(!e[t])throw Error("Can't uninstall observer on property");var n=e[t];delete e[t];var r;"object"==typeof this.__state__?r=this.__state__:(r={},Object.isExtensible(this,"__state__")&&Object.defineProperty(this,"__state__",{value:r,writable:!0,enumerable:!1})),delete r[t],Object.defineProperty(this,t,n)}},n.getOwnPropertyChangeDescriptor=function(t,e){return t.getOwnPropertyChangeDescriptor?t.getOwnPropertyChangeDescriptor(e):n.prototype.getOwnPropertyChangeDescriptor.call(t,e)},n.hasOwnPropertyChangeDescriptor=function(t,e){return t.hasOwnPropertyChangeDescriptor?t.hasOwnPropertyChangeDescriptor(e):n.prototype.hasOwnPropertyChangeDescriptor.call(t,e)},n.addOwnPropertyChangeListener=function(t,e,r,o){return Object.isObject(t)?t.addOwnPropertyChangeListener?t.addOwnPropertyChangeListener(e,r,o):n.prototype.addOwnPropertyChangeListener.call(t,e,r,o):void 0},n.removeOwnPropertyChangeListener=function(t,e,r,o){return Object.isObject(t)?t.removeOwnPropertyChangeListener?t.removeOwnPropertyChangeListener(e,r,o):n.prototype.removeOwnPropertyChangeListener.call(t,e,r,o):void 0},n.dispatchOwnPropertyChange=function(t,e,r,o){return Object.isObject(t)?t.dispatchOwnPropertyChange?t.dispatchOwnPropertyChange(e,r,o):n.prototype.dispatchOwnPropertyChange.call(t,e,r,o):void 0},n.addBeforeOwnPropertyChangeListener=function(t,e,r){return n.addOwnPropertyChangeListener(t,e,r,!0)},n.removeBeforeOwnPropertyChangeListener=function(t,e,r){return n.removeOwnPropertyChangeListener(t,e,r,!0)},n.dispatchBeforeOwnPropertyChange=function(t,e,r){return n.dispatchOwnPropertyChange(t,e,r,!0)},n.makePropertyObservable=function(t,e){return t.makePropertyObservable?t.makePropertyObservable(e):n.prototype.makePropertyObservable.call(t,e)},n.makePropertyUnobservable=function(t,e){return t.makePropertyUnobservable?t.makePropertyUnobservable(e):n.prototype.makePropertyUnobservable.call(t,e)}},{"../shim":27,"weak-map":22}],21:[function(t,e){"use strict";function n(){throw Error("Can't construct. RangeChanges is a mixin.")}var r=t("weak-map"),o=t("../dict"),i=new r;e.exports=n,n.prototype.getAllRangeChangeDescriptors=function(){return i.has(this)||i.set(this,o()),i.get(this)},n.prototype.getRangeChangeDescriptor=function(t){var e=this.getAllRangeChangeDescriptors();return t=t||"",e.has(t)||e.set(t,{isActive:!1,changeListeners:[],willChangeListeners:[]}),e.get(t)},n.prototype.addRangeChangeListener=function(t,e,n){!this.isObservable&&this.makeObservable&&this.makeObservable();var r,o=this.getRangeChangeDescriptor(e);r=n?o.willChangeListeners:o.changeListeners,r.push(t),Object.defineProperty(this,"dispatchesRangeChanges",{value:!0,writable:!0,configurable:!0,enumerable:!1});var i=this;return function(){i&&(i.removeRangeChangeListener(t,e,n),i=null)}},n.prototype.removeRangeChangeListener=function(t,e,n){var r,o=this.getRangeChangeDescriptor(e);r=n?o.willChangeListeners:o.changeListeners;var i=r.lastIndexOf(t);if(-1===i)throw Error("Can't remove listener: does not exist.");r.splice(i,1)},n.prototype.dispatchRangeChange=function(t,e,n,r){var o=this.getAllRangeChangeDescriptors(),i="Range"+(r?"WillChange":"Change");o.forEach(function(o,a){if(!o.isActive){o.isActive=!0;var s;s=r?o.willChangeListeners:o.changeListeners;var c="handle"+(a.slice(0,1).toUpperCase()+a.slice(1))+i;try{s.forEach(function(o){if(o[c])o[c](t,e,n,this,r);else{if(!o.call)throw Error("Handler "+o+" has no method "+c+" and is not callable");o.call(this,t,e,n,this,r)}},this)}finally{o.isActive=!1}}},this)},n.prototype.addBeforeRangeChangeListener=function(t,e){return this.addRangeChangeListener(t,e,!0)},n.prototype.removeBeforeRangeChangeListener=function(t,e){return this.removeRangeChangeListener(t,e,!0)},n.prototype.dispatchBeforeRangeChange=function(t,e,n){return this.dispatchRangeChange(t,e,n,!0)}},{"../dict":11,"weak-map":22}],22:[function(t,e){(function(){"use strict";function t(e){e.permitHostObjects___&&e.permitHostObjects___(t)}function n(t){return!(t.substr(0,u.length)==u&&"___"===t.substr(t.length-3))}function r(t){if(t!==Object(t))throw new TypeError("Not an object: "+t);var e=t[f];if(e&&e.key===t)return e;if(!c(t))return void 0;var n=[],r=[];return e={key:t,gets:n,vals:r},s(t,f,{value:e,writable:!1,enumerable:!1,configurable:!1}),e}function o(t){return t.prototype=null,Object.freeze(t)}if("undefined"==typeof ses||!ses.ok||ses.ok()){if("undefined"!=typeof ses&&(ses.weakMapPermitHostObjects=t),"function"==typeof WeakMap){var i=WeakMap;if("undefined"==typeof navigator||!/Firefox/.test(navigator.userAgent))return e.exports=WeakMap,void 0}Object.prototype.hasOwnProperty;var a=Object.getOwnPropertyNames,s=Object.defineProperty,c=Object.isExtensible,u="weakmap:",f=u+"ident:"+Math.random()+"___";if("undefined"!=typeof crypto&&"function"==typeof crypto.getRandomValues&&"function"==typeof ArrayBuffer&&"function"==typeof Uint8Array){var h=new ArrayBuffer(25),l=new Uint8Array(h);crypto.getRandomValues(l),f=u+"rand:"+Array.prototype.map.call(l,function(t){return(t%36).toString(36)}).join("")+"___"}if(s(Object,"getOwnPropertyNames",{value:function(t){return a(t).filter(n)}}),"getPropertyNames"in Object){var p=Object.getPropertyNames;s(Object,"getPropertyNames",{value:function(t){return p(t).filter(n)}})}(function(){var t=Object.freeze;s(Object,"freeze",{value:function(e){return r(e),t(e)}});var e=Object.seal;s(Object,"seal",{value:function(t){return r(t),e(t)}});var n=Object.preventExtensions;s(Object,"preventExtensions",{value:function(t){return r(t),n(t)}})})();var d=function(){function t(e,n){var o,i,c=r(e);return c?(o=c.gets.indexOf(t),i=c.vals):(o=a.indexOf(e),i=s),o>=0?i[o]:n}function e(e){var n,o=r(e);return n=o?o.gets.indexOf(t):a.indexOf(e),n>=0}function n(e,n){var o,i=r(e);i?(o=i.gets.indexOf(t),o>=0?i.vals[o]=n:(i.gets.push(t),i.vals.push(n))):(o=a.indexOf(e),o>=0?s[o]=n:(a.push(e),s.push(n)))}function i(e){var n,o=r(e);return o?(n=o.gets.indexOf(t),n>=0&&(o.gets.splice(n,1),o.vals.splice(n,1))):(n=a.indexOf(e),n>=0&&(a.splice(n,1),s.splice(n,1))),!0}var a=[],s=[];return Object.create(d.prototype,{get___:{value:o(t)},has___:{value:o(e)},set___:{value:o(n)},delete___:{value:o(i)}})};d.prototype=Object.create(Object.prototype,{get:{value:function(t,e){return this.get___(t,e)},writable:!0,configurable:!0},has:{value:function(t){return this.has___(t)},writable:!0,configurable:!0},set:{value:function(t,e){this.set___(t,e)},writable:!0,configurable:!0},"delete":{value:function(t){return this.delete___(t)},writable:!0,configurable:!0}}),"function"==typeof i?function(){function n(){function e(t,e){return c?s.has(t)?s.get(t):c.get___(t,e):s.get(t,e)}function n(t){return s.has(t)||(c?c.has___(t):!1)}function r(t,e){if(u)try{s.set(t,e)}catch(n){c||(c=new d),c.set___(t,e)}else s.set(t,e)}function a(t){s["delete"](t),c&&c.delete___(t)}var s=new i,c=void 0,u=!1;return Object.create(d.prototype,{get___:{value:o(e)},has___:{value:o(n)},set___:{value:o(r)},delete___:{value:o(a)},permitHostObjects___:{value:o(function(e){if(e!==t)throw Error("bogus call to permitHostObjects___");u=!0})}})}n.prototype=d.prototype,e.exports=n,Object.defineProperty(WeakMap.prototype,"constructor",{value:WeakMap,enumerable:!1,configurable:!0,writable:!0})}():("undefined"!=typeof Proxy&&(Proxy=void 0),e.exports=d)}})()},{}],23:[function(t,e){"use strict";function n(t,e){Object.defineProperty(Array.prototype,t,{value:e,writable:!0,configurable:!0,enumerable:!1})}function r(t,e,n){this.array=t,this.start=null==e?0:e,this.end=n}t("./shim-function");var o=t("./generic-collection"),i=t("./generic-order"),a=t("weak-map");e.exports=Array,Array.empty=[],Object.freeze&&Object.freeze(Array.empty),Array.from=function(t){var e=[];return e.addEach(t),e},Array.unzip=function(t){for(var e=[],n=1/0,r=0;t.length>r;r++){var o=t[r];t[r]=o.toArray(),n>o.length&&(n=o.length)}for(var r=0;t.length>r;r++)for(var o=t[r],i=0;o.length>i;i++)n>i&&i in o&&(e[i]=e[i]||[],e[i][r]=o[i]);return e},n("addEach",o.prototype.addEach),n("deleteEach",o.prototype.deleteEach),n("toArray",o.prototype.toArray),n("toObject",o.prototype.toObject),n("all",o.prototype.all),n("any",o.prototype.any),n("min",o.prototype.min),n("max",o.prototype.max),n("sum",o.prototype.sum),n("average",o.prototype.average),n("only",o.prototype.only),n("flatten",o.prototype.flatten),n("zip",o.prototype.zip),n("enumerate",o.prototype.enumerate),n("group",o.prototype.group),n("sorted",o.prototype.sorted),n("reversed",o.prototype.reversed),n("constructClone",function(t){var e=new this.constructor;return e.addEach(t),e}),n("has",function(t,e){return-1!==this.find(t,e)}),n("get",function(t,e){if(+t!==t)throw Error("Indicies must be numbers");return!t in this?e:this[t]}),n("set",function(t,e){return this.splice(t,1,e),!0}),n("add",function(t){return this.push(t),!0}),n("delete",function(t,e){var n=this.find(t,e);return-1!==n?(this.splice(n,1),!0):!1}),n("find",function(t,e){e=e||this.contentEquals||Object.equals;for(var n=0;this.length>n;n++)if(n in this&&e(this[n],t))return n;return-1}),n("findLast",function(t,e){e=e||this.contentEquals||Object.equals;var n=this.length;do if(n--,n in this&&e(this[n],t))return n;while(n>0);return-1}),n("swap",function(t,e,n){var r=Array.prototype.slice.call(arguments,0,2);return n&&(Array.isArray(n)||(n=Array.prototype.slice.call(n)),r.push.apply(r,n)),this.splice.apply(this,r)}),n("one",function(){for(var t in this)if(Object.owns(this,t))return this[t]}),n("clear",function(){return this.length=0,this}),n("compare",function(t,e){e=e||Object.compare;var n,r,o,a,s;if(this===t)return 0;if(!t||!Array.isArray(t))return i.prototype.compare.call(this,t,e);for(r=Math.min(this.length,t.length),n=0;r>n;n++)if(n in this){if(!(n in t))return-1;if(o=this[n],a=t[n],s=e(o,a))return s}else if(n in t)return 1;return this.length-t.length}),n("equals",function(t,e){e=e||Object.equals;var n,r,o=0,a=this.length;if(this===t)return!0;if(!t||!Array.isArray(t))return i.prototype.equals.call(this,t);if(a!==t.length)return!1;for(;a>o;++o)if(o in this){if(!(o in t))return!1;if(n=this[o],r=t[o],!e(n,r))return!1}else if(o in t)return!1;return!0}),n("clone",function(t,e){if(void 0===t)t=1/0;else if(0===t)return this;e=e||new a;var n=[];for(var r in this)Object.owns(this,r)&&(n[r]=Object.clone(this[r],t-1,e));return n}),n("iterate",function(t,e){return new r(this,t,e)}),n("Iterator",r),r.prototype.next=function(){if(this.start===(null==this.end?this.array.length:this.end))throw StopIteration;return this.array[this.start++]}},{"./generic-collection":14,"./generic-order":16,"./shim-function":24,"weak-map":22}],24:[function(t,e){e.exports=Function,Function.noop=function(){},Function.identity=function(t){return t},Function.by=function(t,e){e=e||Object.compare,t=t||Function.identity;var n=function(n,r){return e(t(n),t(r))};return n.compare=e,n.by=t,n},Function.get=function(t){return function(e){return Object.get(e,t)}}},{}],25:[function(t,e){"use strict";var n=t("weak-map");e.exports=Object,Object.empty=Object.freeze(Object.create(null)),Object.isObject=function(t){return Object(t)===t},Object.getValueOf=function(t){return Object.can(t,"valueOf")&&(t=t.valueOf()),t};var r=new n;Object.hash=function(t){return Object.can(t,"hash")?""+t.hash():Object(t)===t?(r.has(t)||r.set(t,Math.random().toString(36).slice(2)),r.get(t)):""+t};var o=Object.prototype.hasOwnProperty;Object.owns=function(t,e){return o.call(t,e)},Object.can=function(t,e){return null!=t&&"function"==typeof t[e]&&!o.call(t,e)},Object.has=function(t,e){if("object"!=typeof t)throw Error("Object.has can't accept non-object: "+typeof t);if(Object.can(t,"has"))return t.has(e);if("string"==typeof e)return e in t&&t[e]!==Object.prototype[e];throw Error("Key must be a string for Object.has on plain objects")},Object.get=function(t,e,n){if("object"!=typeof t)throw Error("Object.get can't accept non-object: "+typeof t);return Object.can(t,"get")?t.get(e,n):Object.has(t,e)?t[e]:n},Object.set=function(t,e,n){Object.can(t,"set")?t.set(e,n):t[e]=n},Object.addEach=function(t,e){return e&&(Object.can(e,"forEach")?"function"==typeof e.keys?e.forEach(function(e,n){t[n]=e}):e.forEach(function(e){t[e[0]]=e[1]}):Object.keys(e).forEach(function(n){t[n]=e[n]})),t},Object.forEach=function(t,e,n){Object.keys(t).forEach(function(r){e.call(n,t[r],r,t)})},Object.map=function(t,e,n){return Object.keys(t).map(function(r){return e.call(n,t[r],r,t)})},Object.values=function(t){return Object.map(t,Function.identity)},Object.concat=function(){for(var t={},e=0;arguments.length>e;e++)Object.addEach(t,arguments[e]);return t},Object.from=Object.concat,Object.is=function(t,e){return t===e?0!==t||1/t===1/e:t!==t&&e!==e},Object.equals=function(t,e,n){if(n=n||Object.equals,t=Object.getValueOf(t),e=Object.getValueOf(e),t===e)return 0!==t||1/t===1/e;if(null===t||null===e)return t===e;if(Object.can(t,"equals"))return t.equals(e,n);if(Object.can(e,"equals"))return e.equals(t,n);if("object"==typeof t&&"object"==typeof e){var r=Object.getPrototypeOf(t),o=Object.getPrototypeOf(e);if(r===o&&(r===Object.prototype||null===r)){for(var i in t)if(!n(t[i],e[i]))return!1;for(var i in e)if(!n(t[i],e[i]))return!1;return!0}}return t!==t&&e!==e},Object.compare=function(t,e){t=Object.getValueOf(t),e=Object.getValueOf(e);var n=typeof t,r=typeof e;return t===e?0:n!==r?0:"number"===n?t-e:"string"===n?e>t?-1:1:Object.can(t,"compare")?t.compare(e):Object.can(e,"compare")?-e.compare(t):0},Object.clone=function(t,e,r){if(t=Object.getValueOf(t),r=r||new n,void 0===e)e=1/0;else if(0===e)return t;if(Object.isObject(t)){if(!r.has(t))if(Object.can(t,"clone"))r.set(t,t.clone(e,r));else{var o=Object.getPrototypeOf(t);if(null!==o&&o!==Object.prototype)throw Error("Can't clone "+t);var i=Object.create(o);r.set(t,i);for(var a in t)i[a]=Object.clone(t[a],e-1,r)}return r.get(t)}return t},Object.clear=function(t){if(Object.can(t,"clear"))t.clear();else for(var e=Object.keys(t),n=e.length;n;)n--,delete t[e[n]];return t}},{"weak-map":22}],26:[function(){if(!RegExp.escape){var t=/[-[\]{}()*+?.\\^$|,#\s]/g;RegExp.escape=function(e){return e.replace(t,"\\$&")}}},{}],27:[function(t){t("./shim-array"),t("./shim-object"),t("./shim-function"),t("./shim-regexp")},{"./shim-array":23,"./shim-function":24,"./shim-object":25,"./shim-regexp":26}],28:[function(t,e){"use strict";function n(){}e.exports=n,n.ascii={intersection:"+",through:"-",branchUp:"+",branchDown:"+",fromBelow:".",fromAbove:"'",fromBoth:"+",strafe:"|"},n.unicodeRound={intersection:"╋",through:"━",branchUp:"┻",branchDown:"┳",fromBelow:"╭",fromAbove:"╰",fromBoth:"┣",strafe:"┃"},n.unicodeSharp={intersection:"╋",through:"━",branchUp:"┻",branchDown:"┳",fromBelow:"┏",fromAbove:"┗",fromBoth:"┣",strafe:"┃"}},{}],29:[function(t,e){"use strict";var n={chrome:/Chrom(?:e|ium)\/([0-9]+)\./,firefox:/Firefox\/([0-9]+)\./,opera:/Opera\/([0-9]+)\./},r=e.exports=function(t,e){var n,o,i,a=this||("undefined"!=typeof window?window:void 0);if(a)for(e=(e||["ms","o","moz","webkit"]).concat(""),n=e.length;n--;)if(o=e[n],i=o+(o?t.charAt(0).toUpperCase()+t.slice(1):t),a[i]!==void 0)return r.browser=r.browser||o.toLowerCase(),a[t]=a[i]};r.moz="undefined"!=typeof navigator&&!!navigator.mozGetUserMedia,"undefined"!=typeof navigator?Object.keys(n).forEach(function(t){var e=n[t].exec(navigator.userAgent);e&&(r.browser=t,r.browserVersion=r.version=parseInt(e[1],10))}):(r.browser="node",r.browserVersion=r.version="?")},{}],30:[function(t,e){var n,r="undefined"!=typeof self?self:"undefined"!=typeof window?window:{};if(r.crypto&&crypto.getRandomValues){var o=new Uint8Array(16);n=function(){return crypto.getRandomValues(o),o}}if(!n){var i=Array(16);n=function(){for(var t,e=0;16>e;e++)0===(3&e)&&(t=4294967296*Math.random()),i[e]=255&t>>>((3&e)<<3);return i}}e.exports=n},{}],31:[function(t,e){function n(t,e,n){var r=e&&n||0,o=0;for(e=e||[],t.toLowerCase().replace(/[0-9a-f]{2}/g,function(t){16>o&&(e[r+o++]=f[t])});16>o;)e[r+o++]=0;return e}function r(t,e){var n=e||0,r=u;return r[t[n++]]+r[t[n++]]+r[t[n++]]+r[t[n++]]+"-"+r[t[n++]]+r[t[n++]]+"-"+r[t[n++]]+r[t[n++]]+"-"+r[t[n++]]+r[t[n++]]+"-"+r[t[n++]]+r[t[n++]]+r[t[n++]]+r[t[n++]]+r[t[n++]]+r[t[n++]]}function o(t,e,n){var o=e&&n||0,i=e||[];t=t||{};var a=void 0!==t.clockseq?t.clockseq:d,s=void 0!==t.msecs?t.msecs:(new Date).getTime(),c=void 0!==t.nsecs?t.nsecs:v+1,u=s-g+(c-v)/1e4;if(0>u&&void 0===t.clockseq&&(a=16383&a+1),(0>u||s>g)&&void 0===t.nsecs&&(c=0),c>=1e4)throw Error("uuid.v1(): Can't create more than 10M uuids/sec");g=s,v=c,d=a,s+=122192928e5;var f=(1e4*(268435455&s)+c)%4294967296;i[o++]=255&f>>>24,i[o++]=255&f>>>16,i[o++]=255&f>>>8,i[o++]=255&f;var h=268435455&1e4*(s/4294967296);i[o++]=255&h>>>8,i[o++]=255&h,i[o++]=16|15&h>>>24,i[o++]=255&h>>>16,i[o++]=128|a>>>8,i[o++]=255&a;for(var l=t.node||p,y=0;6>y;y++)i[o+y]=l[y];return e?e:r(i)}function i(t,e,n){var o=e&&n||0;"string"==typeof t&&(e="binary"==t?new c(16):null,t=null),t=t||{};var i=t.random||(t.rng||s)();if(i[6]=64|15&i[6],i[8]=128|63&i[8],e)for(var a=0;16>a;a++)e[o+a]=i[a];return e||r(i)}for(var a=t("__browserify_Buffer"),s=t("./rng"),c="function"==typeof a?a:Array,u=[],f={},h=0;256>h;h++)u[h]=(h+256).toString(16).substr(1),f[u[h]]=h;var l=s(),p=[1|l[0],l[1],l[2],l[3],l[4],l[5]],d=16383&(l[6]<<8|l[7]),g=0,v=0,y=i;y.v1=o,y.v4=i,y.parse=n,y.unparse=r,y.BufferClass=c,e.exports=y},{"./rng":30,__browserify_Buffer:36}],32:[function(t,e,n){function r(t,e){var n=null;return Object.keys(t).concat(Object.keys(e)).sort().filter(function(t){var e=t==n;return n=t,!e})}n.increment=function(t,e){return t.clock?t.clock[e]=t.clock[e]===void 0?1:t.clock[e]+1:t[e]=t[e]===void 0?1:t[e]+1,t},n.ascSort=n.compare=function(t,e){var n=!1,o=!1;return t.clock&&(t=t.clock),e.clock&&(e=e.clock),r(t,e).forEach(function(r){var i=(t[r]||0)-(e[r]||0);i>0&&(n=!0),0>i&&(o=!0)}),n&&o?0:o?-1:n?1:0},n.descSort=function(t,e){return 0-n.ascSort(t,e)},n.isConcurrent=function(t,e){return!(0!=n.compare(t,e))},n.isIdentical=function(t,e){return t.clock&&(t=t.clock),e.clock&&(e=e.clock),r(t,e).every(function(n){if(t[n]===void 0||e[n]===void 0)return!1;var r=t[n]-e[n];return 0!=r?!1:!0})},n.merge=function(t,e){var n={},o=!1;return t.clock&&e.clock&&(o=!0),t.clock&&(t=t.clock),e.clock&&(e=e.clock),r(t,e).forEach(function(r){n[r]=Math.max(t[r]||0,e[r]||0)}),o?{clock:n}:n},n.GT=1,n.LT=-1,n.CONCURRENT=0},{}],33:[function(t,e){"use strict";var n=t("url"),r=/\/$/;e.exports=function(t,e){var o,i,a,s;return"function"==typeof t&&(e=t,t=location.origin),i=t.replace(r,""),a=n.parse(t).pathname,s=i+"/rtc.io/primus.js",o=document.querySelector('script[src="'+s+'"]'),o&&"undefined"!=typeof Primus?e(null,Primus):(o=document.createElement("script"),o.src=s,o.onerror=e,o.onload=function(){"/"!==a&&(Primus.prototype.pathname=a.replace(r,"")+Primus.prototype.pathname),e(null,Primus)},document.body.appendChild(o),void 0)}},{url:42}],34:[function(t,e){"use strict";var n=t("cog/logger")("rtc-signaller-processor"),r=t("cog/jsonparse"),o=t("vectorclock");e.exports=function(e){function i(t,n,o){var i=t[0].slice(1),a=t.slice(1).map(r);e.emit.apply(e,[i].concat(a).concat([n,o]))}var a=t("./handlers")(e);return function(t){var s,c,u,f,h=e.id,l=t,p=!0;n("signaller "+e.id+" received data: "+t),"/to"===l.slice(0,3)&&(p=l.slice(4,h.length+4)===h,p&&(s=l.slice(5+h.length).split("|").map(r),u=s[0],f=e.peers.get(u&&u.id),s=s.slice(1).map(r))),p&&(s=s||l.split("|").map(r),"/"===s[0].charAt(0)&&(c=a[s[0].slice(1)],"function"==typeof c?c(s.slice(1),s[0].slice(1),u&&u.clock,f):i(s,f,t)),u&&u.clock&&f&&(f.clock=o.merge(f.clock,u.clock)))}}},{"./handlers":2,"cog/jsonparse":9,"cog/logger":10,vectorclock:32}],35:[function(t,e,n){var r=t("__browserify_process");r.EventEmitter||(r.EventEmitter=function(){});var o=n.EventEmitter=r.EventEmitter,i="function"==typeof Array.isArray?Array.isArray:function(t){return"[object Array]"===Object.prototype.toString.call(t)},a=10;o.prototype.setMaxListeners=function(t){this._events||(this._events={}),this._events.maxListeners=t},o.prototype.emit=function(t){if("error"===t&&(!this._events||!this._events.error||i(this._events.error)&&!this._events.error.length))throw arguments[1]instanceof Error?arguments[1]:Error("Uncaught, unspecified 'error' event.");if(!this._events)return!1;var e=this._events[t];if(!e)return!1;if("function"==typeof e){switch(arguments.length){case 1:e.call(this);break;case 2:e.call(this,arguments[1]);break;case 3:e.call(this,arguments[1],arguments[2]);break;default:var n=Array.prototype.slice.call(arguments,1);e.apply(this,n)}return!0}if(i(e)){for(var n=Array.prototype.slice.call(arguments,1),r=e.slice(),o=0,a=r.length;a>o;o++)r[o].apply(this,n);return!0}return!1},o.prototype.addListener=function(t,e){if("function"!=typeof e)throw Error("addListener only takes instances of Function");if(this._events||(this._events={}),this.emit("newListener",t,e),this._events[t])if(i(this._events[t])){if(!this._events[t].warned){var n;n=void 0!==this._events.maxListeners?this._events.maxListeners:a,n&&n>0&&this._events[t].length>n&&(this._events[t].warned=!0,console.error("(node) warning: possible EventEmitter memory leak detected. %d listeners added. Use emitter.setMaxListeners() to increase limit.",this._events[t].length),console.trace())}this._events[t].push(e)}else this._events[t]=[this._events[t],e];else this._events[t]=e;return this},o.prototype.on=o.prototype.addListener,o.prototype.once=function(t,e){var n=this; | |
return n.on(t,function r(){n.removeListener(t,r),e.apply(this,arguments)}),this},o.prototype.removeListener=function(t,e){if("function"!=typeof e)throw Error("removeListener only takes instances of Function");if(!this._events||!this._events[t])return this;var n=this._events[t];if(i(n)){var r=n.indexOf(e);if(0>r)return this;n.splice(r,1),0==n.length&&delete this._events[t]}else this._events[t]===e&&delete this._events[t];return this},o.prototype.removeAllListeners=function(t){return t&&this._events&&this._events[t]&&(this._events[t]=null),this},o.prototype.listeners=function(t){return this._events||(this._events={}),this._events[t]||(this._events[t]=[]),i(this._events[t])||(this._events[t]=[this._events[t]]),this._events[t]}},{__browserify_process:37}],36:[function(t,e){t=function n(e,r,o){function i(s,c){if(!r[s]){if(!e[s]){var u="function"==typeof t&&t;if(!c&&u)return u(s,!0);if(a)return a(s,!0);throw Error("Cannot find module '"+s+"'")}var f=r[s]={exports:{}};e[s][0].call(f.exports,function(t){var n=e[s][1][t];return i(n?n:t)},f,f.exports,n,e,r,o)}return r[s].exports}for(var a="function"==typeof t&&t,s=0;o.length>s;s++)i(o[s]);return i}({PcZj9L:[function(t,e,n){function r(t,e){var n=typeof t;if("base64"===e&&"string"===n)for(t=ce(t);0!==t.length%4;)t+="=";var o;if("number"===n)o=pe(t);else if("string"===n)o=r.byteLength(t,e);else{if("object"!==n)throw Error("First argument needs to be a number, array or string.");o=pe(t.length)}var i=he(new Uint8Array(o));if(r.isBuffer(t))i.set(t);else if(de(t))for(var a=0;o>a;a++)i[a]=r.isBuffer(t)?t.readUInt8(a):t[a];else"string"===n&&i.write(t,0,e);return i}function o(t,e,n,o){n=Number(n)||0;var i=t.length-n;o?(o=Number(o),o>i&&(o=i)):o=i;var a=e.length;if(0!==a%2)throw Error("Invalid hex string");o>a/2&&(o=a/2);for(var s=0;o>s;s++){var c=parseInt(e.substr(2*s,2),16);if(isNaN(c))throw Error("Invalid hex string");t[n+s]=c}return r._charsWritten=2*s,s}function i(t,e,n,o){return r._charsWritten=be(ve(e),t,n,o)}function a(t,e,n,o){return r._charsWritten=be(ye(e),t,n,o)}function s(t,e,n,r){return a(t,e,n,r)}function c(t,e,n,o){return r._charsWritten=be(me(e),t,n,o)}function u(t,e,n,r){if(isFinite(e))isFinite(n)||(r=n,n=void 0);else{var u=r;r=e,e=n,n=u}e=Number(e)||0;var f=this.length-e;switch(n?(n=Number(n),n>f&&(n=f)):n=f,r=((r||"utf8")+"").toLowerCase()){case"hex":return o(this,t,e,n);case"utf8":case"utf-8":return i(this,t,e,n);case"ascii":return a(this,t,e,n);case"binary":return s(this,t,e,n);case"base64":return c(this,t,e,n);default:throw Error("Unknown encoding")}}function f(t,e,n){var r=this instanceof fe?this._proxy:this;if(t=((t||"utf8")+"").toLowerCase(),e=Number(e)||0,n=void 0!==n?Number(n):n=r.length,n===e)return"";switch(t){case"hex":return y(r,e,n);case"utf8":case"utf-8":return d(r,e,n);case"ascii":return g(r,e,n);case"binary":return v(r,e,n);case"base64":return p(r,e,n);default:throw Error("Unknown encoding")}}function h(){return{type:"Buffer",data:Array.prototype.slice.call(this,0)}}function l(t,e,n,r){var o=this;if(n||(n=0),r||0===r||(r=this.length),e||(e=0),r!==n&&0!==t.length&&0!==o.length){if(n>r)throw Error("sourceEnd < sourceStart");if(0>e||e>=t.length)throw Error("targetStart out of bounds");if(0>n||n>=o.length)throw Error("sourceStart out of bounds");if(0>r||r>o.length)throw Error("sourceEnd out of bounds");r>this.length&&(r=this.length),r-n>t.length-e&&(r=t.length-e+n);for(var i=0;r-n>i;i++)t[i+e]=this[i+n]}}function p(e,n,r){var o=e.slice(n,r);return t("base64-js").fromByteArray(o)}function d(t,e,n){for(var r=t.slice(e,n),o="",i="",a=0;r.length>a;)127>=r[a]?(o+=we(i)+String.fromCharCode(r[a]),i=""):i+="%"+r[a].toString(16),a++;return o+we(i)}function g(t,e,n){for(var r=t.slice(e,n),o="",i=0;r.length>i;i++)o+=String.fromCharCode(r[i]);return o}function v(t,e,n){return g(t,e,n)}function y(t,e,n){var r=t.length;(!e||0>e)&&(e=0),(!n||0>n||n>r)&&(n=r);for(var o="",i=e;n>i;i++)o+=ge(t[i]);return o}function m(t,e){var n=this.length;return t=le(t,n,0),e=le(e,n,n),he(this.subarray(t,e))}function b(t,e){var n=this;return e||(xe(void 0!==t&&null!==t,"missing offset"),xe(n.length>t,"Trying to read beyond buffer length")),t>=n.length?void 0:n[t]}function w(t,e,n,r){r||(xe("boolean"==typeof n,"missing or invalid endian"),xe(void 0!==e&&null!==e,"missing offset"),xe(t.length>e+1,"Trying to read beyond buffer length"));var o=t.length;if(!(e>=o)){if(e+1===o){var i=new DataView(new ArrayBuffer(2));return i.setUint8(0,t[o-1]),i.getUint16(0,n)}return t._dataview.getUint16(e,n)}}function O(t,e){return w(this,t,!0,e)}function E(t,e){return w(this,t,!1,e)}function _(t,e,n,r){r||(xe("boolean"==typeof n,"missing or invalid endian"),xe(void 0!==e&&null!==e,"missing offset"),xe(t.length>e+3,"Trying to read beyond buffer length"));var o=t.length;if(!(e>=o)){if(e+3>=o){for(var i=new DataView(new ArrayBuffer(4)),a=0;o>a+e;a++)i.setUint8(a,t[a+e]);return i.getUint32(0,n)}return t._dataview.getUint32(e,n)}}function x(t,e){return _(this,t,!0,e)}function C(t,e){return _(this,t,!1,e)}function j(t,e){var n=this;return e||(xe(void 0!==t&&null!==t,"missing offset"),xe(n.length>t,"Trying to read beyond buffer length")),t>=n.length?void 0:n._dataview.getInt8(t)}function k(t,e,n,r){r||(xe("boolean"==typeof n,"missing or invalid endian"),xe(void 0!==e&&null!==e,"missing offset"),xe(t.length>e+1,"Trying to read beyond buffer length"));var o=t.length;if(!(e>=o)){if(e+1===o){var i=new DataView(new ArrayBuffer(2));return i.setUint8(0,t[o-1]),i.getInt16(0,n)}return t._dataview.getInt16(e,n)}}function A(t,e){return k(this,t,!0,e)}function L(t,e){return k(this,t,!1,e)}function I(t,e,n,r){r||(xe("boolean"==typeof n,"missing or invalid endian"),xe(void 0!==e&&null!==e,"missing offset"),xe(t.length>e+3,"Trying to read beyond buffer length"));var o=t.length;if(!(e>=o)){if(e+3>=o){for(var i=new DataView(new ArrayBuffer(4)),a=0;o>a+e;a++)i.setUint8(a,t[a+e]);return i.getInt32(0,n)}return t._dataview.getInt32(e,n)}}function S(t,e){return I(this,t,!0,e)}function M(t,e){return I(this,t,!1,e)}function R(t,e,n,r){return r||(xe("boolean"==typeof n,"missing or invalid endian"),xe(t.length>e+3,"Trying to read beyond buffer length")),t._dataview.getFloat32(e,n)}function P(t,e){return R(this,t,!0,e)}function B(t,e){return R(this,t,!1,e)}function U(t,e,n,r){return r||(xe("boolean"==typeof n,"missing or invalid endian"),xe(t.length>e+7,"Trying to read beyond buffer length")),t._dataview.getFloat64(e,n)}function D(t,e){return U(this,t,!0,e)}function q(t,e){return U(this,t,!1,e)}function F(t,e,n){var r=this;n||(xe(void 0!==t&&null!==t,"missing value"),xe(void 0!==e&&null!==e,"missing offset"),xe(r.length>e,"trying to write beyond buffer length"),Oe(t,255)),e>=r.length||(r[e]=t)}function T(t,e,n,r,o){o||(xe(void 0!==e&&null!==e,"missing value"),xe("boolean"==typeof r,"missing or invalid endian"),xe(void 0!==n&&null!==n,"missing offset"),xe(t.length>n+1,"trying to write beyond buffer length"),Oe(e,65535));var i=t.length;if(!(n>=i))if(n+1===i){var a=new DataView(new ArrayBuffer(2));a.setUint16(0,e,r),t[n]=a.getUint8(0)}else t._dataview.setUint16(n,e,r)}function z(t,e,n){T(this,t,e,!0,n)}function N(t,e,n){T(this,t,e,!1,n)}function V(t,e,n,r,o){o||(xe(void 0!==e&&null!==e,"missing value"),xe("boolean"==typeof r,"missing or invalid endian"),xe(void 0!==n&&null!==n,"missing offset"),xe(t.length>n+3,"trying to write beyond buffer length"),Oe(e,4294967295));var i=t.length;if(!(n>=i))if(n+3>=i){var a=new DataView(new ArrayBuffer(4));a.setUint32(0,e,r);for(var s=0;i>s+n;s++)t[s+n]=a.getUint8(s)}else t._dataview.setUint32(n,e,r)}function H(t,e,n){V(this,t,e,!0,n)}function W(t,e,n){V(this,t,e,!1,n)}function G(t,e,n){var r=this;n||(xe(void 0!==t&&null!==t,"missing value"),xe(void 0!==e&&null!==e,"missing offset"),xe(r.length>e,"Trying to write beyond buffer length"),Ee(t,127,-128)),e>=r.length||r._dataview.setInt8(e,t)}function J(t,e,n,r,o){o||(xe(void 0!==e&&null!==e,"missing value"),xe("boolean"==typeof r,"missing or invalid endian"),xe(void 0!==n&&null!==n,"missing offset"),xe(t.length>n+1,"Trying to write beyond buffer length"),Ee(e,32767,-32768));var i=t.length;if(!(n>=i))if(n+1===i){var a=new DataView(new ArrayBuffer(2));a.setInt16(0,e,r),t[n]=a.getUint8(0)}else t._dataview.setInt16(n,e,r)}function $(t,e,n){J(this,t,e,!0,n)}function Z(t,e,n){J(this,t,e,!1,n)}function K(t,e,n,r,o){o||(xe(void 0!==e&&null!==e,"missing value"),xe("boolean"==typeof r,"missing or invalid endian"),xe(void 0!==n&&null!==n,"missing offset"),xe(t.length>n+3,"Trying to write beyond buffer length"),Ee(e,2147483647,-2147483648));var i=t.length;if(!(n>=i))if(n+3>=i){var a=new DataView(new ArrayBuffer(4));a.setInt32(0,e,r);for(var s=0;i>s+n;s++)t[s+n]=a.getUint8(s)}else t._dataview.setInt32(n,e,r)}function X(t,e,n){K(this,t,e,!0,n)}function Y(t,e,n){K(this,t,e,!1,n)}function Q(t,e,n,r,o){o||(xe(void 0!==e&&null!==e,"missing value"),xe("boolean"==typeof r,"missing or invalid endian"),xe(void 0!==n&&null!==n,"missing offset"),xe(t.length>n+3,"Trying to write beyond buffer length"),_e(e,3.4028234663852886e38,-3.4028234663852886e38));var i=t.length;if(!(n>=i))if(n+3>=i){var a=new DataView(new ArrayBuffer(4));a.setFloat32(0,e,r);for(var s=0;i>s+n;s++)t[s+n]=a.getUint8(s)}else t._dataview.setFloat32(n,e,r)}function te(t,e,n){Q(this,t,e,!0,n)}function ee(t,e,n){Q(this,t,e,!1,n)}function ne(t,e,n,r,o){o||(xe(void 0!==e&&null!==e,"missing value"),xe("boolean"==typeof r,"missing or invalid endian"),xe(void 0!==n&&null!==n,"missing offset"),xe(t.length>n+7,"Trying to write beyond buffer length"),_e(e,1.7976931348623157e308,-1.7976931348623157e308));var i=t.length;if(!(n>=i))if(n+7>=i){var a=new DataView(new ArrayBuffer(8));a.setFloat64(0,e,r);for(var s=0;i>s+n;s++)t[s+n]=a.getUint8(s)}else t._dataview.setFloat64(n,e,r)}function re(t,e,n){ne(this,t,e,!0,n)}function oe(t,e,n){ne(this,t,e,!1,n)}function ie(t,e,n){if(t||(t=0),e||(e=0),n||(n=this.length),"string"==typeof t&&(t=t.charCodeAt(0)),"number"!=typeof t||isNaN(t))throw Error("value is not a number");if(e>n)throw Error("end < start");if(n!==e&&0!==this.length){if(0>e||e>=this.length)throw Error("start out of bounds");if(0>n||n>this.length)throw Error("end out of bounds");for(var r=e;n>r;r++)this[r]=t}}function ae(){for(var t=[],e=this.length,r=0;e>r;r++)if(t[r]=ge(this[r]),r===n.INSPECT_MAX_BYTES){t[r+1]="...";break}return"<Buffer "+t.join(" ")+">"}function se(){return new r(this).buffer}function ce(t){return t.trim?t.trim():t.replace(/^\s+|\s+$/g,"")}function ue(){var t=new Uint8Array(0);t.foo=function(){return 42};try{return 42===t.foo()}catch(e){return!1}}function fe(t){this._arr=t,0!==t.byteLength&&(this._dataview=new DataView(t.buffer,t.byteOffset,t.byteLength))}function he(t){if(void 0===Ce&&(Ce=ue()),Ce)return t.write=u,t.toString=f,t.toLocaleString=f,t.toJSON=h,t.copy=l,t.slice=m,t.readUInt8=b,t.readUInt16LE=O,t.readUInt16BE=E,t.readUInt32LE=x,t.readUInt32BE=C,t.readInt8=j,t.readInt16LE=A,t.readInt16BE=L,t.readInt32LE=S,t.readInt32BE=M,t.readFloatLE=P,t.readFloatBE=B,t.readDoubleLE=D,t.readDoubleBE=q,t.writeUInt8=F,t.writeUInt16LE=z,t.writeUInt16BE=N,t.writeUInt32LE=H,t.writeUInt32BE=W,t.writeInt8=G,t.writeInt16LE=$,t.writeInt16BE=Z,t.writeInt32LE=X,t.writeInt32BE=Y,t.writeFloatLE=te,t.writeFloatBE=ee,t.writeDoubleLE=re,t.writeDoubleBE=oe,t.fill=ie,t.inspect=ae,t.toArrayBuffer=se,t._isBuffer=!0,0!==t.byteLength&&(t._dataview=new DataView(t.buffer,t.byteOffset,t.byteLength)),t;var e=new fe(t),n=new Proxy(e,je);return e._proxy=n,n}function le(t,e,n){return"number"!=typeof t?n:(t=~~t,t>=e?e:t>=0?t:(t+=e,t>=0?t:0))}function pe(t){return t=~~Math.ceil(+t),0>t?0:t}function de(t){return Array.isArray(t)||r.isBuffer(t)||t&&"object"==typeof t&&"number"==typeof t.length}function ge(t){return 16>t?"0"+t.toString(16):t.toString(16)}function ve(t){for(var e=[],n=0;t.length>n;n++)if(127>=t.charCodeAt(n))e.push(t.charCodeAt(n));else for(var r=encodeURIComponent(t.charAt(n)).substr(1).split("%"),o=0;r.length>o;o++)e.push(parseInt(r[o],16));return e}function ye(t){for(var e=[],n=0;t.length>n;n++)e.push(255&t.charCodeAt(n));return e}function me(e){return t("base64-js").toByteArray(e)}function be(t,e,n,r){for(var o=0;r>o&&!(o+n>=e.length||o>=t.length);)e[o+n]=t[o],o++;return o}function we(t){try{return decodeURIComponent(t)}catch(e){return String.fromCharCode(65533)}}function Oe(t,e){xe("number"==typeof t,"cannot write a non-number as a number"),xe(t>=0,"specified a negative value for writing an unsigned value"),xe(e>=t,"value is larger than maximum value for type"),xe(Math.floor(t)===t,"value has a fractional component")}function Ee(t,e,n){xe("number"==typeof t,"cannot write a non-number as a number"),xe(e>=t,"value larger than maximum allowed value"),xe(t>=n,"value smaller than minimum allowed value"),xe(Math.floor(t)===t,"value has a fractional component")}function _e(t,e,n){xe("number"==typeof t,"cannot write a non-number as a number"),xe(e>=t,"value larger than maximum allowed value"),xe(t>=n,"value smaller than minimum allowed value")}function xe(t,e){if(!t)throw Error(e||"Failed assertion")}n.Buffer=r,n.SlowBuffer=r,n.INSPECT_MAX_BYTES=50,r.poolSize=8192;var Ce;r.isEncoding=function(t){switch((t+"").toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":case"raw":return!0;default:return!1}},r.isBuffer=function(t){return t&&t._isBuffer},r.byteLength=function(t,e){switch(e||"utf8"){case"hex":return t.length/2;case"utf8":case"utf-8":return ve(t).length;case"ascii":case"binary":return t.length;case"base64":return me(t).length;default:throw Error("Unknown encoding")}},r.concat=function(t,e){if(!Array.isArray(t))throw Error("Usage: Buffer.concat(list, [totalLength])\nlist should be an Array.");var n,o;if(0===t.length)return new r(0);if(1===t.length)return t[0];if("number"!=typeof e)for(e=0,n=0;t.length>n;n++)o=t[n],e+=o.length;var i=new r(e),a=0;for(n=0;t.length>n;n++)o=t[n],o.copy(i,a),a+=o.length;return i},fe.prototype.write=u,fe.prototype.toString=f,fe.prototype.toLocaleString=f,fe.prototype.toJSON=h,fe.prototype.copy=l,fe.prototype.slice=m,fe.prototype.readUInt8=b,fe.prototype.readUInt16LE=O,fe.prototype.readUInt16BE=E,fe.prototype.readUInt32LE=x,fe.prototype.readUInt32BE=C,fe.prototype.readInt8=j,fe.prototype.readInt16LE=A,fe.prototype.readInt16BE=L,fe.prototype.readInt32LE=S,fe.prototype.readInt32BE=M,fe.prototype.readFloatLE=P,fe.prototype.readFloatBE=B,fe.prototype.readDoubleLE=D,fe.prototype.readDoubleBE=q,fe.prototype.writeUInt8=F,fe.prototype.writeUInt16LE=z,fe.prototype.writeUInt16BE=N,fe.prototype.writeUInt32LE=H,fe.prototype.writeUInt32BE=W,fe.prototype.writeInt8=G,fe.prototype.writeInt16LE=$,fe.prototype.writeInt16BE=Z,fe.prototype.writeInt32LE=X,fe.prototype.writeInt32BE=Y,fe.prototype.writeFloatLE=te,fe.prototype.writeFloatBE=ee,fe.prototype.writeDoubleLE=re,fe.prototype.writeDoubleBE=oe,fe.prototype.fill=ie,fe.prototype.inspect=ae,fe.prototype.toArrayBuffer=se,fe.prototype._isBuffer=!0,fe.prototype.subarray=function(){return this._arr.subarray.apply(this._arr,arguments)},fe.prototype.set=function(){return this._arr.set.apply(this._arr,arguments)};var je={get:function(t,e){return e in t?t[e]:t._arr[e]},set:function(t,e,n){t._arr[e]=n}}},{"base64-js":3}],"native-buffer-browserify":[function(t,e){e.exports=t("PcZj9L")},{}],3:[function(t,e){(function(){"use strict";function t(t){var e,n,o,i,a,s;if(t.length%4>0)throw"Invalid string. Length must be a multiple of 4";for(a=t.indexOf("="),a=a>0?t.length-a:0,s=[],o=a>0?t.length-4:t.length,e=0,n=0;o>e;e+=4,n+=3)i=r.indexOf(t[e])<<18|r.indexOf(t[e+1])<<12|r.indexOf(t[e+2])<<6|r.indexOf(t[e+3]),s.push((16711680&i)>>16),s.push((65280&i)>>8),s.push(255&i);return 2===a?(i=r.indexOf(t[e])<<2|r.indexOf(t[e+1])>>4,s.push(255&i)):1===a&&(i=r.indexOf(t[e])<<10|r.indexOf(t[e+1])<<4|r.indexOf(t[e+2])>>2,s.push(255&i>>8),s.push(255&i)),s}function n(t){function e(t){return r[63&t>>18]+r[63&t>>12]+r[63&t>>6]+r[63&t]}var n,o,i,a=t.length%3,s="";for(n=0,i=t.length-a;i>n;n+=3)o=(t[n]<<16)+(t[n+1]<<8)+t[n+2],s+=e(o);switch(a){case 1:o=t[t.length-1],s+=r[o>>2],s+=r[63&o<<4],s+="==";break;case 2:o=(t[t.length-2]<<8)+t[t.length-1],s+=r[o>>10],s+=r[63&o>>4],s+=r[63&o<<2],s+="="}return s}var r="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";e.exports.toByteArray=t,e.exports.fromByteArray=n})()},{}]},{},[]),e.exports=t("native-buffer-browserify").Buffer},{}],37:[function(t,e){var n=e.exports={};n.nextTick=function(){var t="undefined"!=typeof window&&window.setImmediate,e="undefined"!=typeof window&&window.postMessage&&window.addEventListener;if(t)return function(t){return window.setImmediate(t)};if(e){var n=[];return window.addEventListener("message",function(t){if(t.source===window&&"process-tick"===t.data&&(t.stopPropagation(),n.length>0)){var e=n.shift();e()}},!0),function(t){n.push(t),window.postMessage("process-tick","*")}}return function(t){setTimeout(t,0)}}(),n.title="browser",n.browser=!0,n.env={},n.argv=[],n.binding=function(){throw Error("process.binding is not supported")},n.cwd=function(){return"/"},n.chdir=function(){throw Error("process.chdir is not supported")}},{}],38:[function(t,e,n){var r="undefined"!=typeof self?self:"undefined"!=typeof window?window:{};(function(t){function o(t){throw RangeError(R[t])}function i(t,e){for(var n=t.length;n--;)t[n]=e(t[n]);return t}function a(t,e){return i(t.split(M),e).join(".")}function s(t){for(var e,n,r=[],o=0,i=t.length;i>o;)e=t.charCodeAt(o++),e>=55296&&56319>=e&&i>o?(n=t.charCodeAt(o++),56320==(64512&n)?r.push(((1023&e)<<10)+(1023&n)+65536):(r.push(e),o--)):r.push(e);return r}function c(t){return i(t,function(t){var e="";return t>65535&&(t-=65536,e+=U(55296|1023&t>>>10),t=56320|1023&t),e+=U(t)}).join("")}function u(t){return 10>t-48?t-22:26>t-65?t-65:26>t-97?t-97:E}function f(t,e){return t+22+75*(26>t)-((0!=e)<<5)}function h(t,e,n){var r=0;for(t=n?B(t/j):t>>1,t+=B(t/e);t>P*x>>1;r+=E)t=B(t/P);return B(r+(P+1)*t/(t+C))}function l(t){var e,n,r,i,a,s,f,l,p,d,g=[],v=t.length,y=0,m=A,b=k;for(n=t.lastIndexOf(L),0>n&&(n=0),r=0;n>r;++r)t.charCodeAt(r)>=128&&o("not-basic"),g.push(t.charCodeAt(r));for(i=n>0?n+1:0;v>i;){for(a=y,s=1,f=E;i>=v&&o("invalid-input"),l=u(t.charCodeAt(i++)),(l>=E||l>B((O-y)/s))&&o("overflow"),y+=l*s,p=b>=f?_:f>=b+x?x:f-b,!(p>l);f+=E)d=E-p,s>B(O/d)&&o("overflow"),s*=d;e=g.length+1,b=h(y-a,e,0==a),B(y/e)>O-m&&o("overflow"),m+=B(y/e),y%=e,g.splice(y++,0,m)}return c(g)}function p(t){var e,n,r,i,a,c,u,l,p,d,g,v,y,m,b,w=[];for(t=s(t),v=t.length,e=A,n=0,a=k,c=0;v>c;++c)g=t[c],128>g&&w.push(U(g));for(r=i=w.length,i&&w.push(L);v>r;){for(u=O,c=0;v>c;++c)g=t[c],g>=e&&u>g&&(u=g);for(y=r+1,u-e>B((O-n)/y)&&o("overflow"),n+=(u-e)*y,e=u,c=0;v>c;++c)if(g=t[c],e>g&&++n>O&&o("overflow"),g==e){for(l=n,p=E;d=a>=p?_:p>=a+x?x:p-a,!(d>l);p+=E)b=l-d,m=E-d,w.push(U(f(d+b%m,0))),l=B(b/m);w.push(U(f(l,0))),a=h(n,y,r==i),n=0,++r}++n,++e}return w.join("")}function d(t){return a(t,function(t){return I.test(t)?l(t.slice(4).toLowerCase()):t})}function g(t){return a(t,function(t){return S.test(t)?"xn--"+p(t):t})}var v="object"==typeof n&&n,y="object"==typeof e&&e&&e.exports==v&&e,m="object"==typeof r&&r;(m.global===m||m.window===m)&&(t=m);var b,w,O=2147483647,E=36,_=1,x=26,C=38,j=700,k=72,A=128,L="-",I=/^xn--/,S=/[^ -~]/,M=/\x2E|\u3002|\uFF0E|\uFF61/g,R={overflow:"Overflow: input needs wider integers to process","not-basic":"Illegal input >= 0x80 (not a basic code point)","invalid-input":"Invalid input"},P=E-_,B=Math.floor,U=String.fromCharCode;if(b={version:"1.2.3",ucs2:{decode:s,encode:c},decode:l,encode:p,toASCII:g,toUnicode:d},"function"==typeof define&&"object"==typeof define.amd&&define.amd)define(function(){return b});else if(v&&!v.nodeType)if(y)y.exports=b;else for(w in b)b.hasOwnProperty(w)&&(v[w]=b[w]);else t.punycode=b})(this)},{}],39:[function(t,e){"use strict";function n(t,e){return Object.prototype.hasOwnProperty.call(t,e)}e.exports=function(t,e,o,i){e=e||"&",o=o||"=";var a={};if("string"!=typeof t||0===t.length)return a;var s=/\+/g;t=t.split(e);var c=1e3;i&&"number"==typeof i.maxKeys&&(c=i.maxKeys);var u=t.length;c>0&&u>c&&(u=c);for(var f=0;u>f;++f){var h,l,p,d,g=t[f].replace(s,"%20"),v=g.indexOf(o);v>=0?(h=g.substr(0,v),l=g.substr(v+1)):(h=g,l=""),p=decodeURIComponent(h),d=decodeURIComponent(l),n(a,p)?r(a[p])?a[p].push(d):a[p]=[a[p],d]:a[p]=d}return a};var r=Array.isArray||function(t){return"[object Array]"===Object.prototype.toString.call(t)}},{}],40:[function(t,e){"use strict";function n(t,e){if(t.map)return t.map(e);for(var n=[],r=0;t.length>r;r++)n.push(e(t[r],r));return n}var r=function(t){switch(typeof t){case"string":return t;case"boolean":return t?"true":"false";case"number":return isFinite(t)?t:"";default:return""}};e.exports=function(t,e,a,s){return e=e||"&",a=a||"=",null===t&&(t=void 0),"object"==typeof t?n(i(t),function(n){var i=encodeURIComponent(r(n))+a;return o(t[n])?t[n].map(function(t){return i+encodeURIComponent(r(t))}).join(e):i+encodeURIComponent(r(t[n]))}).join(e):s?encodeURIComponent(r(s))+a+encodeURIComponent(r(t)):""};var o=Array.isArray||function(t){return"[object Array]"===Object.prototype.toString.call(t)},i=Object.keys||function(t){var e=[];for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&e.push(n);return e}},{}],41:[function(t,e,n){"use strict";n.decode=n.parse=t("./decode"),n.encode=n.stringify=t("./encode")},{"./decode":39,"./encode":40}],42:[function(t,e,n){(function(){"use strict";function e(t,e,n){if(t&&"object"==typeof t&&t.href)return t;if("string"!=typeof t)throw new TypeError("Parameter 'url' must be a string, not "+typeof t);var o={},i=t;i=i.trim();var u=c.exec(i);if(u){u=u[0];var f=u.toLowerCase();o.protocol=f,i=i.substr(u.length)}if(n||u||i.match(/^\/\/[^@\/]+@[^@\/]+/)){var h="//"===i.substr(0,2);!h||u&&b[u]||(i=i.substr(2),o.slashes=!0)}if(!b[u]&&(h||u&&!w[u])){var E=i.indexOf("@");if(-1!==E){for(var _=i.slice(0,E),x=!0,C=0,j=d.length;j>C;C++)if(-1!==_.indexOf(d[C])){x=!1;break}x&&(o.auth=decodeURIComponent(_),i=i.substr(E+1))}for(var k=-1,C=0,j=p.length;j>C;C++){var A=i.indexOf(p[C]);-1!==A&&(0>k||k>A)&&(k=A)}-1!==k?(o.host=i.substr(0,k),i=i.substr(k)):(o.host=i,i="");for(var L=a(o.host),I=Object.keys(L),C=0,j=I.length;j>C;C++){var S=I[C];o[S]=L[S]}o.hostname=o.hostname||"";var M="["===o.hostname[0]&&"]"===o.hostname[o.hostname.length-1];if(o.hostname.length>g)o.hostname="";else if(!M)for(var R=o.hostname.split(/\./),C=0,j=R.length;j>C;C++){var P=R[C];if(P&&!P.match(v)){for(var B="",U=0,D=P.length;D>U;U++)B+=P.charCodeAt(U)>127?"x":P[U];if(!B.match(v)){var q=R.slice(0,C),F=R.slice(C+1),T=P.match(y);T&&(q.push(T[1]),F.unshift(T[2])),F.length&&(i="/"+F.join(".")+i),o.hostname=q.join(".");break}}}if(o.hostname=o.hostname.toLowerCase(),!M){for(var z=o.hostname.split("."),N=[],C=0;z.length>C;++C){var V=z[C];N.push(V.match(/[^A-Za-z0-9_-]/)?"xn--"+s.encode(V):V)}o.hostname=N.join(".")}o.host=(o.hostname||"")+(o.port?":"+o.port:""),o.href+=o.host,M&&(o.hostname=o.hostname.substr(1,o.hostname.length-2),"/"!==i[0]&&(i="/"+i))}if(!m[f])for(var C=0,j=l.length;j>C;C++){var H=l[C],W=encodeURIComponent(H);W===H&&(W=escape(H)),i=i.split(H).join(W)}var G=i.indexOf("#");-1!==G&&(o.hash=i.substr(G),i=i.slice(0,G));var J=i.indexOf("?");return-1!==J?(o.search=i.substr(J),o.query=i.substr(J+1),e&&(o.query=O.parse(o.query)),i=i.slice(0,J)):e&&(o.search="",o.query={}),i&&(o.pathname=i),w[u]&&o.hostname&&!o.pathname&&(o.pathname="/"),(o.pathname||o.search)&&(o.path=(o.pathname?o.pathname:"")+(o.search?o.search:"")),o.href=r(o),o}function r(t){"string"==typeof t&&(t=e(t));var n=t.auth||"";n&&(n=encodeURIComponent(n),n=n.replace(/%3A/i,":"),n+="@");var r=t.protocol||"",o=t.pathname||"",i=t.hash||"",a=!1,s="";void 0!==t.host?a=n+t.host:void 0!==t.hostname&&(a=n+(-1===t.hostname.indexOf(":")?t.hostname:"["+t.hostname+"]"),t.port&&(a+=":"+t.port)),t.query&&"object"==typeof t.query&&Object.keys(t.query).length&&(s=O.stringify(t.query));var c=t.search||s&&"?"+s||"";return r&&":"!==r.substr(-1)&&(r+=":"),t.slashes||(!r||w[r])&&a!==!1?(a="//"+(a||""),o&&"/"!==o.charAt(0)&&(o="/"+o)):a||(a=""),i&&"#"!==i.charAt(0)&&(i="#"+i),c&&"?"!==c.charAt(0)&&(c="?"+c),r+a+o+c+i}function o(t,e){return r(i(t,e))}function i(t,n){if(!t)return n;if(t=e(r(t),!1,!0),n=e(r(n),!1,!0),t.hash=n.hash,""===n.href)return t.href=r(t),t;if(n.slashes&&!n.protocol)return n.protocol=t.protocol,w[n.protocol]&&n.hostname&&!n.pathname&&(n.path=n.pathname="/"),n.href=r(n),n;if(n.protocol&&n.protocol!==t.protocol){if(!w[n.protocol])return n.href=r(n),n;if(t.protocol=n.protocol,!n.host&&!b[n.protocol]){for(var o=(n.pathname||"").split("/");o.length&&!(n.host=o.shift()););n.host||(n.host=""),n.hostname||(n.hostname=""),""!==o[0]&&o.unshift(""),2>o.length&&o.unshift(""),n.pathname=o.join("/")}return t.pathname=n.pathname,t.search=n.search,t.query=n.query,t.host=n.host||"",t.auth=n.auth,t.hostname=n.hostname||n.host,t.port=n.port,(void 0!==t.pathname||void 0!==t.search)&&(t.path=(t.pathname?t.pathname:"")+(t.search?t.search:"")),t.slashes=t.slashes||n.slashes,t.href=r(t),t}var i=t.pathname&&"/"===t.pathname.charAt(0),a=void 0!==n.host||n.pathname&&"/"===n.pathname.charAt(0),s=a||i||t.host&&n.pathname,c=s,u=t.pathname&&t.pathname.split("/")||[],o=n.pathname&&n.pathname.split("/")||[],f=t.protocol&&!w[t.protocol];if(f&&(delete t.hostname,delete t.port,t.host&&(""===u[0]?u[0]=t.host:u.unshift(t.host)),delete t.host,n.protocol&&(delete n.hostname,delete n.port,n.host&&(""===o[0]?o[0]=n.host:o.unshift(n.host)),delete n.host),s=s&&(""===o[0]||""===u[0])),a)t.host=n.host||""===n.host?n.host:t.host,t.hostname=n.hostname||""===n.hostname?n.hostname:t.hostname,t.search=n.search,t.query=n.query,u=o;else if(o.length)u||(u=[]),u.pop(),u=u.concat(o),t.search=n.search,t.query=n.query;else if("search"in n){if(f){t.hostname=t.host=u.shift();var h=t.host&&t.host.indexOf("@")>0?t.host.split("@"):!1;h&&(t.auth=h.shift(),t.host=t.hostname=h.shift())}return t.search=n.search,t.query=n.query,(void 0!==t.pathname||void 0!==t.search)&&(t.path=(t.pathname?t.pathname:"")+(t.search?t.search:"")),t.href=r(t),t}if(!u.length)return delete t.pathname,t.search?delete t.path:t.path="/"+t.search,t.href=r(t),t;for(var l=u.slice(-1)[0],p=(t.host||n.host)&&("."===l||".."===l)||""===l,d=0,g=u.length;g>=0;g--)l=u[g],"."==l?u.splice(g,1):".."===l?(u.splice(g,1),d++):d&&(u.splice(g,1),d--);if(!s&&!c)for(;d--;d)u.unshift("..");!s||""===u[0]||u[0]&&"/"===u[0].charAt(0)||u.unshift(""),p&&"/"!==u.join("/").substr(-1)&&u.push("");var v=""===u[0]||u[0]&&"/"===u[0].charAt(0);if(f){t.hostname=t.host=v?"":u.length?u.shift():"";var h=t.host&&t.host.indexOf("@")>0?t.host.split("@"):!1;h&&(t.auth=h.shift(),t.host=t.hostname=h.shift())}return s=s||t.host&&u.length,s&&!v&&u.unshift(""),t.pathname=u.join("/"),(void 0!==t.pathname||void 0!==t.search)&&(t.path=(t.pathname?t.pathname:"")+(t.search?t.search:"")),t.auth=n.auth||t.auth,t.slashes=t.slashes||n.slashes,t.href=r(t),t}function a(t){var e={},n=u.exec(t);return n&&(n=n[0],":"!==n&&(e.port=n.substr(1)),t=t.substr(0,t.length-n.length)),t&&(e.hostname=t),e}var s=t("punycode");n.parse=e,n.resolve=o,n.resolveObject=i,n.format=r;var c=/^([a-z0-9.+-]+:)/i,u=/:[0-9]*$/,f=["<",">",'"',"`"," ","\r","\n"," "],h=["{","}","|","\\","^","~","`"].concat(f),l=["'"].concat(f),p=["%","/","?",";","#"].concat(h).concat(l),d=["/","@","?","#"].concat(f),g=255,v=/^[a-zA-Z0-9][a-z0-9A-Z_-]{0,62}$/,y=/^([a-zA-Z0-9][a-z0-9A-Z_-]{0,62})(.*)$/,m={javascript:!0,"javascript:":!0},b={javascript:!0,"javascript:":!0},w={http:!0,https:!0,ftp:!0,gopher:!0,file:!0,"http:":!0,"https:":!0,"ftp:":!0,"gopher:":!0,"file:":!0},O=t("querystring")})()},{punycode:38,querystring:41}]},{},[]);var signaller=require("rtc-signaller")("http://rtc.io/switchboard/"),rtc=require("rtc"),media=require("rtc-media"),processor=require("rtc-videoproc"),whammy=require("whammy"),QUALITY=1,HEIGHT=100,WIDTH=100,FPS=.2,FPMS=1e3/FPS,ID=Math.floor(1e3*Math.random()),localMedia=media();localMedia.once("capture",function(){localMedia.render(document.body,function(t){t.width=WIDTH,t.height=HEIGHT});var t=processor(document.body,{fps:.2});t.style.opacity=.5,t.width=WIDTH,t.height=HEIGHT,t.pipeline.add(greyscaleFilter),localMedia.render(t),signaller.on("peer:announce",function(t){console.log("peer",t);var e=rtc.createConnection(),n=rtc.couple(e,t.id,signaller);e.ondatachannel=function(t){console.log("got channel",t)};var r=e.createDataChannel("low");r.onopen=function(){alert("asd"),console.log("data channel opened"),setInterval(function(){var t="hello";console.log("sent",t),r.send(t)},FPMS)},r.onmessage=function(t){return console.log("received",t.data),void 0},n.once("active",function(){console.log("connection active to: "+t.id)}),e.onaddstream=function(t){media(t).render(document.body)}}),signaller.announce({room:"interconnect"})}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<style type='text/css'>html, body { margin: 0; padding: 0; border: 0; } | |
body, html { height: 100%; width: 100%; }</style> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment