/
bundle.js
381 lines (261 loc) · 254 KB
/
bundle.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
(function(){var require = function (file, cwd) {
var resolved = require.resolve(file, cwd || '/');
var mod = require.modules[resolved];
if (!mod) throw new Error(
'Failed to resolve module ' + file + ', tried ' + resolved
);
var cached = require.cache[resolved];
var res = cached? cached.exports : mod();
return res;
};
require.paths = [];
require.modules = {};
require.cache = {};
require.extensions = [".js",".coffee",".html"];
require._core = {
'assert': true,
'events': true,
'fs': true,
'path': true,
'vm': true
};
require.resolve = (function () {
return function (x, cwd) {
if (!cwd) cwd = '/';
if (require._core[x]) return x;
var path = require.modules.path();
cwd = path.resolve('/', cwd);
var y = cwd || '/';
if (x.match(/^(?:\.\.?\/|\/)/)) {
var m = loadAsFileSync(path.resolve(y, x))
|| loadAsDirectorySync(path.resolve(y, x));
if (m) return m;
}
var n = loadNodeModulesSync(x, y);
if (n) return n;
throw new Error("Cannot find module '" + x + "'");
function loadAsFileSync (x) {
x = path.normalize(x);
if (require.modules[x]) {
return x;
}
for (var i = 0; i < require.extensions.length; i++) {
var ext = require.extensions[i];
if (require.modules[x + ext]) return x + ext;
}
}
function loadAsDirectorySync (x) {
x = x.replace(/\/+$/, '');
var pkgfile = path.normalize(x + '/package.json');
if (require.modules[pkgfile]) {
var pkg = require.modules[pkgfile]();
var b = pkg.browserify;
if (typeof b === 'object' && b.main) {
var m = loadAsFileSync(path.resolve(x, b.main));
if (m) return m;
}
else if (typeof b === 'string') {
var m = loadAsFileSync(path.resolve(x, b));
if (m) return m;
}
else if (pkg.main) {
var m = loadAsFileSync(path.resolve(x, pkg.main));
if (m) return m;
}
}
return loadAsFileSync(x + '/index');
}
function loadNodeModulesSync (x, start) {
var dirs = nodeModulesPathsSync(start);
for (var i = 0; i < dirs.length; i++) {
var dir = dirs[i];
var m = loadAsFileSync(dir + '/' + x);
if (m) return m;
var n = loadAsDirectorySync(dir + '/' + x);
if (n) return n;
}
var m = loadAsFileSync(x);
if (m) return m;
}
function nodeModulesPathsSync (start) {
var parts;
if (start === '/') parts = [ '' ];
else parts = path.normalize(start).split('/');
var dirs = [];
for (var i = parts.length - 1; i >= 0; i--) {
if (parts[i] === 'node_modules') continue;
var dir = parts.slice(0, i + 1).join('/') + '/node_modules';
dirs.push(dir);
}
return dirs;
}
};
})();
require.alias = function (from, to) {
var path = require.modules.path();
var res = null;
try {
res = require.resolve(from + '/package.json', '/');
}
catch (err) {
res = require.resolve(from, '/');
}
var basedir = path.dirname(res);
var keys = (Object.keys || function (obj) {
var res = [];
for (var key in obj) res.push(key);
return res;
})(require.modules);
for (var i = 0; i < keys.length; i++) {
var key = keys[i];
if (key.slice(0, basedir.length + 1) === basedir + '/') {
var f = key.slice(basedir.length);
require.modules[to + f] = require.modules[basedir + f];
}
else if (key === basedir) {
require.modules[to] = require.modules[basedir];
}
}
};
(function () {
var process = {};
require.define = function (filename, fn) {
if (require.modules.__browserify_process) {
process = require.modules.__browserify_process();
}
var dirname = require._core[filename]
? ''
: require.modules.path().dirname(filename)
;
var require_ = function (file) {
var requiredModule = require(file, dirname);
var cached = require.cache[require.resolve(file, dirname)];
if (cached && cached.parent === null) {
cached.parent = module_;
}
return requiredModule;
};
require_.resolve = function (name) {
return require.resolve(name, dirname);
};
require_.modules = require.modules;
require_.define = require.define;
require_.cache = require.cache;
var module_ = {
id : filename,
filename: filename,
exports : {},
loaded : false,
parent: null
};
require.modules[filename] = function () {
require.cache[filename] = module_;
fn.call(
module_.exports,
require_,
module_,
module_.exports,
dirname,
filename,
process
);
module_.loaded = true;
return module_.exports;
};
};
})();
require.define("path",Function(['require','module','exports','__dirname','__filename','process'],"function filter (xs, fn) {\n var res = [];\n for (var i = 0; i < xs.length; i++) {\n if (fn(xs[i], i, xs)) res.push(xs[i]);\n }\n return res;\n}\n\n// resolves . and .. elements in a path array with directory names there\n// must be no slashes, empty elements, or device names (c:\\) in the array\n// (so also no leading and trailing slashes - it does not distinguish\n// relative and absolute paths)\nfunction normalizeArray(parts, allowAboveRoot) {\n // if the path tries to go above the root, `up` ends up > 0\n var up = 0;\n for (var i = parts.length; i >= 0; i--) {\n var last = parts[i];\n if (last == '.') {\n parts.splice(i, 1);\n } else if (last === '..') {\n parts.splice(i, 1);\n up++;\n } else if (up) {\n parts.splice(i, 1);\n up--;\n }\n }\n\n // if the path is allowed to go above the root, restore leading ..s\n if (allowAboveRoot) {\n for (; up--; up) {\n parts.unshift('..');\n }\n }\n\n return parts;\n}\n\n// Regex to split a filename into [*, dir, basename, ext]\n// posix version\nvar splitPathRe = /^(.+\\/(?!$)|\\/)?((?:.+?)?(\\.[^.]*)?)$/;\n\n// path.resolve([from ...], to)\n// posix version\nexports.resolve = function() {\nvar resolvedPath = '',\n resolvedAbsolute = false;\n\nfor (var i = arguments.length; i >= -1 && !resolvedAbsolute; i--) {\n var path = (i >= 0)\n ? arguments[i]\n : process.cwd();\n\n // Skip empty and invalid entries\n if (typeof path !== 'string' || !path) {\n continue;\n }\n\n resolvedPath = path + '/' + resolvedPath;\n resolvedAbsolute = path.charAt(0) === '/';\n}\n\n// At this point the path should be resolved to a full absolute path, but\n// handle relative paths to be safe (might happen when process.cwd() fails)\n\n// Normalize the path\nresolvedPath = normalizeArray(filter(resolvedPath.split('/'), function(p) {\n return !!p;\n }), !resolvedAbsolute).join('/');\n\n return ((resolvedAbsolute ? '/' : '') + resolvedPath) || '.';\n};\n\n// path.normalize(path)\n// posix version\nexports.normalize = function(path) {\nvar isAbsolute = path.charAt(0) === '/',\n trailingSlash = path.slice(-1) === '/';\n\n// Normalize the path\npath = normalizeArray(filter(path.split('/'), function(p) {\n return !!p;\n }), !isAbsolute).join('/');\n\n if (!path && !isAbsolute) {\n path = '.';\n }\n if (path && trailingSlash) {\n path += '/';\n }\n \n return (isAbsolute ? '/' : '') + path;\n};\n\n\n// posix version\nexports.join = function() {\n var paths = Array.prototype.slice.call(arguments, 0);\n return exports.normalize(filter(paths, function(p, index) {\n return p && typeof p === 'string';\n }).join('/'));\n};\n\n\nexports.dirname = function(path) {\n var dir = splitPathRe.exec(path)[1] || '';\n var isWindows = false;\n if (!dir) {\n // No dirname\n return '.';\n } else if (dir.length === 1 ||\n (isWindows && dir.length <= 3 && dir.charAt(1) === ':')) {\n // It is just a slash or a drive letter with a slash\n return dir;\n } else {\n // It is a full dirname, strip trailing slash\n return dir.substring(0, dir.length - 1);\n }\n};\n\n\nexports.basename = function(path, ext) {\n var f = splitPathRe.exec(path)[2] || '';\n // TODO: make this comparison case-insensitive on windows?\n if (ext && f.substr(-1 * ext.length) === ext) {\n f = f.substr(0, f.length - ext.length);\n }\n return f;\n};\n\n\nexports.extname = function(path) {\n return splitPathRe.exec(path)[3] || '';\n};\n\n//@ sourceURL=path"));
require.define("__browserify_process",Function(['require','module','exports','__dirname','__filename','process'],"var process = module.exports = {};\n\nprocess.nextTick = (function () {\n var queue = [];\n var canPost = typeof window !== 'undefined'\n && window.postMessage && window.addEventListener\n ;\n \n if (canPost) {\n window.addEventListener('message', function (ev) {\n if (ev.source === window && ev.data === 'browserify-tick') {\n ev.stopPropagation();\n if (queue.length > 0) {\n var fn = queue.shift();\n fn();\n }\n }\n }, true);\n }\n \n return function (fn) {\n if (canPost) {\n queue.push(fn);\n window.postMessage('browserify-tick', '*');\n }\n else setTimeout(fn, 0);\n };\n})();\n\nprocess.title = 'browser';\nprocess.browser = true;\nprocess.env = {};\nprocess.argv = [];\n\nprocess.binding = function (name) {\n if (name === 'evals') return (require)('vm')\n else throw new Error('No such module. (Possibly not yet loaded)')\n};\n\n(function () {\n var cwd = '/';\n var path;\n process.cwd = function () { return cwd };\n process.chdir = function (dir) {\n if (!path) path = require('path');\n cwd = path.resolve(dir, cwd);\n };\n})();\n//@ sourceURL=__browserify_process"));
require.define("vm",Function(['require','module','exports','__dirname','__filename','process'],"module.exports = require(\"vm-browserify\")\n//@ sourceURL=vm"));
require.define("/node_modules/vm-browserify/package.json",Function(['require','module','exports','__dirname','__filename','process'],"module.exports = {\"main\":\"index.js\"}\n//@ sourceURL=/node_modules/vm-browserify/package.json"));
require.define("/node_modules/vm-browserify/index.js",Function(['require','module','exports','__dirname','__filename','process'],"var Object_keys = function (obj) {\n if (Object.keys) return Object.keys(obj)\n else {\n var res = [];\n for (var key in obj) res.push(key)\n return res;\n }\n};\n\nvar forEach = function (xs, fn) {\n if (xs.forEach) return xs.forEach(fn)\n else for (var i = 0; i < xs.length; i++) {\n fn(xs[i], i, xs);\n }\n};\n\nvar Script = exports.Script = function NodeScript (code) {\n if (!(this instanceof Script)) return new Script(code);\n this.code = code;\n};\n\nScript.prototype.runInNewContext = function (context) {\n if (!context) context = {};\n \n var iframe = document.createElement('iframe');\n if (!iframe.style) iframe.style = {};\n iframe.style.display = 'none';\n \n document.body.appendChild(iframe);\n \n var win = iframe.contentWindow;\n \n forEach(Object_keys(context), function (key) {\n win[key] = context[key];\n });\n \n if (!win.eval && win.execScript) {\n // win.eval() magically appears when this is called in IE:\n win.execScript('null');\n }\n \n var res = win.eval(this.code);\n \n forEach(Object_keys(win), function (key) {\n context[key] = win[key];\n });\n \n document.body.removeChild(iframe);\n \n return res;\n};\n\nScript.prototype.runInThisContext = function () {\n return eval(this.code); // maybe...\n};\n\nScript.prototype.runInContext = function (context) {\n // seems to be just runInNewContext on magical context objects which are\n // otherwise indistinguishable from objects except plain old objects\n // for the parameter segfaults node\n return this.runInNewContext(context);\n};\n\nforEach(Object_keys(Script.prototype), function (name) {\n exports[name] = Script[name] = function (code) {\n var s = Script(code);\n return s[name].apply(s, [].slice.call(arguments, 1));\n };\n});\n\nexports.createScript = function (code) {\n return exports.Script(code);\n};\n\nexports.createContext = Script.createContext = function (context) {\n // not really sure what this one does\n // seems to just make a shallow copy\n var copy = {};\n if(typeof context === 'object') {\n forEach(Object_keys(context), function (key) {\n copy[key] = context[key];\n });\n }\n return copy;\n};\n\n//@ sourceURL=/node_modules/vm-browserify/index.js"));
require.define("/node_modules/live-reload/package.json",Function(['require','module','exports','__dirname','__filename','process'],"module.exports = {\"main\":\"index\",\"browserify\":\"browser.js\"}\n//@ sourceURL=/node_modules/live-reload/package.json"));
require.define("/node_modules/live-reload/browser.js",Function(['require','module','exports','__dirname','__filename','process'],"var shoe = require(\"shoe\")\n\nmodule.exports = LiveReloadClient\n\nfunction LiveReloadClient(uri) {\n if (typeof uri === \"number\") {\n uri = \"http://localhost:\" + uri\n }\n\n var stream = shoe(uri + \"/shoe\")\n \n stream.on(\"data\", ondata)\n}\n\nfunction ondata(data) {\n if (data === \"reload\") {\n document.location.reload()\n }\n}\n//@ sourceURL=/node_modules/live-reload/browser.js"));
require.define("/node_modules/live-reload/node_modules/shoe/package.json",Function(['require','module','exports','__dirname','__filename','process'],"module.exports = {\"main\":\"index.js\",\"browserify\":\"browser.js\"}\n//@ sourceURL=/node_modules/live-reload/node_modules/shoe/package.json"));
require.define("/node_modules/live-reload/node_modules/shoe/browser.js",Function(['require','module','exports','__dirname','__filename','process'],"var Stream = require('stream');\nvar sockjs = require('sockjs-client');\n\nmodule.exports = function (uri, cb) {\n if (/^\\/\\/[^\\/]+\\//.test(uri)) {\n uri = window.location.protocol + uri;\n }\n else if (!/^https?:\\/\\//.test(uri)) {\n uri = window.location.protocol + '//'\n + window.location.host\n + (/^\\//.test(uri) ? uri : '/' + uri)\n ;\n }\n \n var stream = new Stream;\n stream.readable = true;\n stream.writable = true;\n \n var ready = false;\n var buffer = [];\n \n var sock = sockjs(uri);\n stream.sock = sock;\n \n stream.write = function (msg) {\n if (!ready || buffer.length) buffer.push(msg)\n else sock.send(msg)\n };\n stream.end = function (msg) {\n if (msg !== undefined) stream.write(msg);\n if (!ready) {\n stream._ended = true;\n return;\n }\n stream.writable = false;\n sock.close();\n };\n\n stream.destroy = function () {\n stream._ended = true;\n stream.writable = stream.readable = false;\n buffer.length = 0\n sock.close();\n }\n \n sock.onopen = function () {\n if (typeof cb === 'function') cb();\n ready = true;\n buffer.forEach(function (msg) {\n sock.send(msg);\n });\n buffer = [];\n stream.emit('connect')\n if (stream._ended) stream.end();\n };\n sock.onmessage = function (e) {\n stream.emit('data', e.data);\n };\n sock.onclose = function () {\n stream.emit('end');\n stream.writable = false;\n stream.readable = false;\n };\n \n return stream;\n};\n\n//@ sourceURL=/node_modules/live-reload/node_modules/shoe/browser.js"));
require.define("stream",Function(['require','module','exports','__dirname','__filename','process'],"var events = require('events');\nvar util = require('util');\n\nfunction Stream() {\n events.EventEmitter.call(this);\n}\nutil.inherits(Stream, events.EventEmitter);\nmodule.exports = Stream;\n// Backwards-compat with node 0.4.x\nStream.Stream = Stream;\n\nStream.prototype.pipe = function(dest, options) {\n var source = this;\n\n function ondata(chunk) {\n if (dest.writable) {\n if (false === dest.write(chunk) && source.pause) {\n source.pause();\n }\n }\n }\n\n source.on('data', ondata);\n\n function ondrain() {\n if (source.readable && source.resume) {\n source.resume();\n }\n }\n\n dest.on('drain', ondrain);\n\n // If the 'end' option is not supplied, dest.end() will be called when\n // source gets the 'end' or 'close' events. Only dest.end() once, and\n // only when all sources have ended.\n if (!dest._isStdio && (!options || options.end !== false)) {\n dest._pipeCount = dest._pipeCount || 0;\n dest._pipeCount++;\n\n source.on('end', onend);\n source.on('close', onclose);\n }\n\n var didOnEnd = false;\n function onend() {\n if (didOnEnd) return;\n didOnEnd = true;\n\n dest._pipeCount--;\n\n // remove the listeners\n cleanup();\n\n if (dest._pipeCount > 0) {\n // waiting for other incoming streams to end.\n return;\n }\n\n dest.end();\n }\n\n\n function onclose() {\n if (didOnEnd) return;\n didOnEnd = true;\n\n dest._pipeCount--;\n\n // remove the listeners\n cleanup();\n\n if (dest._pipeCount > 0) {\n // waiting for other incoming streams to end.\n return;\n }\n\n dest.destroy();\n }\n\n // don't leave dangling pipes when there are errors.\n function onerror(er) {\n cleanup();\n if (this.listeners('error').length === 0) {\n throw er; // Unhandled stream error in pipe.\n }\n }\n\n source.on('error', onerror);\n dest.on('error', onerror);\n\n // remove all the event listeners that were added.\n function cleanup() {\n source.removeListener('data', ondata);\n dest.removeListener('drain', ondrain);\n\n source.removeListener('end', onend);\n source.removeListener('close', onclose);\n\n source.removeListener('error', onerror);\n dest.removeListener('error', onerror);\n\n source.removeListener('end', cleanup);\n source.removeListener('close', cleanup);\n\n dest.removeListener('end', cleanup);\n dest.removeListener('close', cleanup);\n }\n\n source.on('end', cleanup);\n source.on('close', cleanup);\n\n dest.on('end', cleanup);\n dest.on('close', cleanup);\n\n dest.emit('pipe', source);\n\n // Allow for unix-like usage: A.pipe(B).pipe(C)\n return dest;\n};\n\n//@ sourceURL=stream"));
require.define("events",Function(['require','module','exports','__dirname','__filename','process'],"if (!process.EventEmitter) process.EventEmitter = function () {};\n\nvar EventEmitter = exports.EventEmitter = process.EventEmitter;\nvar isArray = typeof Array.isArray === 'function'\n ? Array.isArray\n : function (xs) {\n return Object.prototype.toString.call(xs) === '[object Array]'\n }\n;\n\n// By default EventEmitters will print a warning if more than\n// 10 listeners are added to it. This is a useful default which\n// helps finding memory leaks.\n//\n// Obviously not all Emitters should be limited to 10. This function allows\n// that to be increased. Set to zero for unlimited.\nvar defaultMaxListeners = 10;\nEventEmitter.prototype.setMaxListeners = function(n) {\n if (!this._events) this._events = {};\n this._events.maxListeners = n;\n};\n\n\nEventEmitter.prototype.emit = function(type) {\n // If there is no 'error' event listener then throw.\n if (type === 'error') {\n if (!this._events || !this._events.error ||\n (isArray(this._events.error) && !this._events.error.length))\n {\n if (arguments[1] instanceof Error) {\n throw arguments[1]; // Unhandled 'error' event\n } else {\n throw new Error(\"Uncaught, unspecified 'error' event.\");\n }\n return false;\n }\n }\n\n if (!this._events) return false;\n var handler = this._events[type];\n if (!handler) return false;\n\n if (typeof handler == 'function') {\n switch (arguments.length) {\n // fast cases\n case 1:\n handler.call(this);\n break;\n case 2:\n handler.call(this, arguments[1]);\n break;\n case 3:\n handler.call(this, arguments[1], arguments[2]);\n break;\n // slower\n default:\n var args = Array.prototype.slice.call(arguments, 1);\n handler.apply(this, args);\n }\n return true;\n\n } else if (isArray(handler)) {\n var args = Array.prototype.slice.call(arguments, 1);\n\n var listeners = handler.slice();\n for (var i = 0, l = listeners.length; i < l; i++) {\n listeners[i].apply(this, args);\n }\n return true;\n\n } else {\n return false;\n }\n};\n\n// EventEmitter is defined in src/node_events.cc\n// EventEmitter.prototype.emit() is also defined there.\nEventEmitter.prototype.addListener = function(type, listener) {\n if ('function' !== typeof listener) {\n throw new Error('addListener only takes instances of Function');\n }\n\n if (!this._events) this._events = {};\n\n // To avoid recursion in the case that type == \"newListeners\"! Before\n // adding it to the listeners, first emit \"newListeners\".\n this.emit('newListener', type, listener);\n\n if (!this._events[type]) {\n // Optimize the case of one listener. Don't need the extra array object.\n this._events[type] = listener;\n } else if (isArray(this._events[type])) {\n\n // Check for listener leak\n if (!this._events[type].warned) {\n var m;\n if (this._events.maxListeners !== undefined) {\n m = this._events.maxListeners;\n } else {\n m = defaultMaxListeners;\n }\n\n if (m && m > 0 && this._events[type].length > m) {\n this._events[type].warned = true;\n console.error('(node) warning: possible EventEmitter memory ' +\n 'leak detected. %d listeners added. ' +\n 'Use emitter.setMaxListeners() to increase limit.',\n this._events[type].length);\n console.trace();\n }\n }\n\n // If we've already got an array, just append.\n this._events[type].push(listener);\n } else {\n // Adding the second element, need to change to array.\n this._events[type] = [this._events[type], listener];\n }\n\n return this;\n};\n\nEventEmitter.prototype.on = EventEmitter.prototype.addListener;\n\nEventEmitter.prototype.once = function(type, listener) {\n var self = this;\n self.on(type, function g() {\n self.removeListener(type, g);\n listener.apply(this, arguments);\n });\n\n return this;\n};\n\nEventEmitter.prototype.removeListener = function(type, listener) {\n if ('function' !== typeof listener) {\n throw new Error('removeListener only takes instances of Function');\n }\n\n // does not use listeners(), so no side effect of creating _events[type]\n if (!this._events || !this._events[type]) return this;\n\n var list = this._events[type];\n\n if (isArray(list)) {\n var i = list.indexOf(listener);\n if (i < 0) return this;\n list.splice(i, 1);\n if (list.length == 0)\n delete this._events[type];\n } else if (this._events[type] === listener) {\n delete this._events[type];\n }\n\n return this;\n};\n\nEventEmitter.prototype.removeAllListeners = function(type) {\n // does not use listeners(), so no side effect of creating _events[type]\n if (type && this._events && this._events[type]) this._events[type] = null;\n return this;\n};\n\nEventEmitter.prototype.listeners = function(type) {\n if (!this._events) this._events = {};\n if (!this._events[type]) this._events[type] = [];\n if (!isArray(this._events[type])) {\n this._events[type] = [this._events[type]];\n }\n return this._events[type];\n};\n\n//@ sourceURL=events"));
require.define("util",Function(['require','module','exports','__dirname','__filename','process'],"var events = require('events');\n\nexports.print = function () {};\nexports.puts = function () {};\nexports.debug = function() {};\n\nvar formatRegExp = /%[sdj%]/g;\nexports.format = function(f) {\n if (typeof f !== 'string') {\n var objects = [];\n for (var i = 0; i < arguments.length; i++) {\n objects.push(inspect(arguments[i]));\n }\n return objects.join(' ');\n }\n\n var i = 1;\n var args = arguments;\n var len = args.length;\n var str = String(f).replace(formatRegExp, function(x) {\n if (x === '%%') return '%';\n if (i >= len) return x;\n switch (x) {\n case '%s': return String(args[i++]);\n case '%d': return Number(args[i++]);\n case '%j': return JSON.stringify(args[i++]);\n default:\n return x;\n }\n });\n for (var x = args[i]; i < len; x = args[++i]) {\n if (x === null || typeof x !== 'object') {\n str += ' ' + x;\n } else {\n str += ' ' + inspect(x);\n }\n }\n return str;\n};\n\n\n/**\n * Echos the value of a value. Trys to print the value out\n * in the best way possible given the different types.\n *\n * @param {Object} obj The object to print out.\n * @param {Boolean} showHidden Flag that shows hidden (not enumerable)\n * properties of objects.\n * @param {Number} depth Depth in which to descend in object. Default is 2.\n * @param {Boolean} colors Flag to turn on ANSI escape codes to color the\n * output. Default is false (no coloring).\n */\nfunction inspect(obj, showHidden, depth, colors) {\n var ctx = {\n showHidden: showHidden,\n seen: [],\n stylize: colors ? stylizeWithColor : stylizeNoColor\n };\n return formatValue(ctx, obj, (typeof depth === 'undefined' ? 2 : depth));\n}\nexports.inspect = inspect;\n\n\n// http://en.wikipedia.org/wiki/ANSI_escape_code#graphics\nvar colors = {\n 'bold' : [1, 22],\n 'italic' : [3, 23],\n 'underline' : [4, 24],\n 'inverse' : [7, 27],\n 'white' : [37, 39],\n 'grey' : [90, 39],\n 'black' : [30, 39],\n 'blue' : [34, 39],\n 'cyan' : [36, 39],\n 'green' : [32, 39],\n 'magenta' : [35, 39],\n 'red' : [31, 39],\n 'yellow' : [33, 39]\n};\n\n// Don't use 'blue' not visible on cmd.exe\nvar styles = {\n 'special': 'cyan',\n 'number': 'yellow',\n 'boolean': 'yellow',\n 'undefined': 'grey',\n 'null': 'bold',\n 'string': 'green',\n 'date': 'magenta',\n // \"name\": intentionally not styling\n 'regexp': 'red'\n};\n\n\nfunction stylizeWithColor(str, styleType) {\n var style = styles[styleType];\n\n if (style) {\n return '\\u001b[' + colors[style][0] + 'm' + str +\n '\\u001b[' + colors[style][1] + 'm';\n } else {\n return str;\n }\n}\n\n\nfunction stylizeNoColor(str, styleType) {\n return str;\n}\n\n\nfunction arrayToHash(array) {\n var hash = {};\n\n array.forEach(function(val, idx) {\n hash[val] = true;\n });\n\n return hash;\n}\n\n\nfunction formatValue(ctx, value, recurseTimes) {\n // Provide a hook for user-specified inspect functions.\n // Check that value is an object with an inspect function on it\n if (value && typeof value.inspect === 'function' &&\n // Filter out the util module, it's inspect function is special\n value.inspect !== exports.inspect &&\n // Also filter out any prototype objects using the circular check.\n !(value.constructor && value.constructor.prototype === value)) {\n return String(value.inspect(recurseTimes));\n }\n\n // Primitive types cannot have properties\n var primitive = formatPrimitive(ctx, value);\n if (primitive) {\n return primitive;\n }\n\n // Look up the keys of the object.\n var keys = Object_keys(value);\n var visibleKeys = arrayToHash(keys);\n\n if (ctx.showHidden) {\n keys = Object_getOwnPropertyNames(value);\n }\n\n // Some type of object without properties can be shortcutted.\n if (keys.length === 0) {\n if (typeof value === 'function') {\n var name = value.name ? ': ' + value.name : '';\n return ctx.stylize('[Function' + name + ']', 'special');\n }\n if (isRegExp(value)) {\n return ctx.stylize(RegExp.prototype.toString.call(value), 'regexp');\n }\n if (isDate(value)) {\n return ctx.stylize(Date.prototype.toString.call(value), 'date');\n }\n if (isError(value)) {\n return formatError(value);\n }\n }\n\n var base = '', array = false, braces = ['{', '}'];\n\n // Make Array say that they are Array\n if (isArray(value)) {\n array = true;\n braces = ['[', ']'];\n }\n\n // Make functions say that they are functions\n if (typeof value === 'function') {\n var n = value.name ? ': ' + value.name : '';\n base = ' [Function' + n + ']';\n }\n\n // Make RegExps say that they are RegExps\n if (isRegExp(value)) {\n base = ' ' + RegExp.prototype.toString.call(value);\n }\n\n // Make dates with properties first say the date\n if (isDate(value)) {\n base = ' ' + Date.prototype.toUTCString.call(value);\n }\n\n // Make error with message first say the error\n if (isError(value)) {\n base = ' ' + formatError(value);\n }\n\n if (keys.length === 0 && (!array || value.length == 0)) {\n return braces[0] + base + braces[1];\n }\n\n if (recurseTimes < 0) {\n if (isRegExp(value)) {\n return ctx.stylize(RegExp.prototype.toString.call(value), 'regexp');\n } else {\n return ctx.stylize('[Object]', 'special');\n }\n }\n\n ctx.seen.push(value);\n\n var output;\n if (array) {\n output = formatArray(ctx, value, recurseTimes, visibleKeys, keys);\n } else {\n output = keys.map(function(key) {\n return formatProperty(ctx, value, recurseTimes, visibleKeys, key, array);\n });\n }\n\n ctx.seen.pop();\n\n return reduceToSingleString(output, base, braces);\n}\n\n\nfunction formatPrimitive(ctx, value) {\n switch (typeof value) {\n case 'undefined':\n return ctx.stylize('undefined', 'undefined');\n\n case 'string':\n var simple = '\\'' + JSON.stringify(value).replace(/^\"|\"$/g, '')\n .replace(/'/g, \"\\\\'\")\n .replace(/\\\\\"/g, '\"') + '\\'';\n return ctx.stylize(simple, 'string');\n\n case 'number':\n return ctx.stylize('' + value, 'number');\n\n case 'boolean':\n return ctx.stylize('' + value, 'boolean');\n }\n // For some reason typeof null is \"object\", so special case here.\n if (value === null) {\n return ctx.stylize('null', 'null');\n }\n}\n\n\nfunction formatError(value) {\n return '[' + Error.prototype.toString.call(value) + ']';\n}\n\n\nfunction formatArray(ctx, value, recurseTimes, visibleKeys, keys) {\n var output = [];\n for (var i = 0, l = value.length; i < l; ++i) {\n if (Object.prototype.hasOwnProperty.call(value, String(i))) {\n output.push(formatProperty(ctx, value, recurseTimes, visibleKeys,\n String(i), true));\n } else {\n output.push('');\n }\n }\n keys.forEach(function(key) {\n if (!key.match(/^\\d+$/)) {\n output.push(formatProperty(ctx, value, recurseTimes, visibleKeys,\n key, true));\n }\n });\n return output;\n}\n\n\nfunction formatProperty(ctx, value, recurseTimes, visibleKeys, key, array) {\n var name, str, desc;\n desc = Object.getOwnPropertyDescriptor(value, key) || { value: value[key] };\n if (desc.get) {\n if (desc.set) {\n str = ctx.stylize('[Getter/Setter]', 'special');\n } else {\n str = ctx.stylize('[Getter]', 'special');\n }\n } else {\n if (desc.set) {\n str = ctx.stylize('[Setter]', 'special');\n }\n }\n if (!visibleKeys.hasOwnProperty(key)) {\n name = '[' + key + ']';\n }\n if (!str) {\n if (ctx.seen.indexOf(desc.value) < 0) {\n if (recurseTimes === null) {\n str = formatValue(ctx, desc.value, null);\n } else {\n str = formatValue(ctx, desc.value, recurseTimes - 1);\n }\n if (str.indexOf('\\n') > -1) {\n if (array) {\n str = str.split('\\n').map(function(line) {\n return ' ' + line;\n }).join('\\n').substr(2);\n } else {\n str = '\\n' + str.split('\\n').map(function(line) {\n return ' ' + line;\n }).join('\\n');\n }\n }\n } else {\n str = ctx.stylize('[Circular]', 'special');\n }\n }\n if (typeof name === 'undefined') {\n if (array && key.match(/^\\d+$/)) {\n return str;\n }\n name = JSON.stringify('' + key);\n if (name.match(/^\"([a-zA-Z_][a-zA-Z_0-9]*)\"$/)) {\n name = name.substr(1, name.length - 2);\n name = ctx.stylize(name, 'name');\n } else {\n name = name.replace(/'/g, \"\\\\'\")\n .replace(/\\\\\"/g, '\"')\n .replace(/(^\"|\"$)/g, \"'\");\n name = ctx.stylize(name, 'string');\n }\n }\n\n return name + ': ' + str;\n}\n\n\nfunction reduceToSingleString(output, base, braces) {\n var numLinesEst = 0;\n var length = output.reduce(function(prev, cur) {\n numLinesEst++;\n if (cur.indexOf('\\n') >= 0) numLinesEst++;\n return prev + cur.length + 1;\n }, 0);\n\n if (length > 60) {\n return braces[0] +\n (base === '' ? '' : base + '\\n ') +\n ' ' +\n output.join(',\\n ') +\n ' ' +\n braces[1];\n }\n\n return braces[0] + base + ' ' + output.join(', ') + ' ' + braces[1];\n}\n\n\nfunction isArray(ar) {\n return ar instanceof Array ||\n Array.isArray(ar) ||\n (ar && ar !== Object.prototype && isArray(ar.__proto__));\n}\n\n\nfunction isRegExp(re) {\n return re instanceof RegExp ||\n (typeof re === 'object' && Object.prototype.toString.call(re) === '[object RegExp]');\n}\n\n\nfunction isDate(d) {\n if (d instanceof Date) return true;\n if (typeof d !== 'object') return false;\n var properties = Date.prototype && Object_getOwnPropertyNames(Date.prototype);\n var proto = d.__proto__ && Object_getOwnPropertyNames(d.__proto__);\n return JSON.stringify(proto) === JSON.stringify(properties);\n}\n\nfunction isError(e) {\n return typeof e === 'object' && objectToString(e) === '[object Error]';\n}\nexports.isError = isError;\n\nfunction objectToString(o) {\n return Object.prototype.toString.call(o);\n}\n\n\nfunction pad(n) {\n return n < 10 ? '0' + n.toString(10) : n.toString(10);\n}\n\nvar months = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep',\n 'Oct', 'Nov', 'Dec'];\n\n// 26 Feb 16:19:34\nfunction timestamp() {\n var d = new Date();\n var time = [pad(d.getHours()),\n pad(d.getMinutes()),\n pad(d.getSeconds())].join(':');\n return [d.getDate(), months[d.getMonth()], time].join(' ');\n}\n\nexports.log = function (msg) {};\n\nexports.pump = null;\n\nvar Object_keys = Object.keys || function (obj) {\n var res = [];\n for (var key in obj) res.push(key);\n return res;\n};\n\nvar Object_getOwnPropertyNames = Object.getOwnPropertyNames || function (obj) {\n var res = [];\n for (var key in obj) {\n if (Object.hasOwnProperty.call(obj, key)) res.push(key);\n }\n return res;\n};\n\nvar Object_create = Object.create || function (prototype, properties) {\n // from es5-shim\n var object;\n if (prototype === null) {\n object = { '__proto__' : null };\n }\n else {\n if (typeof prototype !== 'object') {\n throw new TypeError(\n 'typeof prototype[' + (typeof prototype) + '] != \\'object\\''\n );\n }\n var Type = function () {};\n Type.prototype = prototype;\n object = new Type();\n object.__proto__ = prototype;\n }\n if (typeof properties !== 'undefined' && Object.defineProperties) {\n Object.defineProperties(object, properties);\n }\n return object;\n};\n\nexports.inherits = function(ctor, superCtor) {\n ctor.super_ = superCtor;\n ctor.prototype = Object_create(superCtor.prototype, {\n constructor: {\n value: ctor,\n enumerable: false,\n writable: true,\n configurable: true\n }\n });\n};\n\n//@ sourceURL=util"));
require.define("/node_modules/live-reload/node_modules/shoe/node_modules/sockjs-client/package.json",Function(['require','module','exports','__dirname','__filename','process'],"module.exports = {\"main\":\"sockjs.js\"}\n//@ sourceURL=/node_modules/live-reload/node_modules/shoe/node_modules/sockjs-client/package.json"));
require.define("/node_modules/live-reload/node_modules/shoe/node_modules/sockjs-client/sockjs.js",Function(['require','module','exports','__dirname','__filename','process'],"/* SockJS client, version 0.3.1.7.ga67f.dirty, http://sockjs.org, MIT License\n\nCopyright (c) 2011-2012 VMware, Inc.\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in\nall copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\nTHE SOFTWARE.\n*/\n\n// JSON2 by Douglas Crockford (minified).\nvar JSON;JSON||(JSON={}),function(){function str(a,b){var c,d,e,f,g=gap,h,i=b[a];i&&typeof i==\"object\"&&typeof i.toJSON==\"function\"&&(i=i.toJSON(a)),typeof rep==\"function\"&&(i=rep.call(b,a,i));switch(typeof i){case\"string\":return quote(i);case\"number\":return isFinite(i)?String(i):\"null\";case\"boolean\":case\"null\":return String(i);case\"object\":if(!i)return\"null\";gap+=indent,h=[];if(Object.prototype.toString.apply(i)===\"[object Array]\"){f=i.length;for(c=0;c<f;c+=1)h[c]=str(c,i)||\"null\";e=h.length===0?\"[]\":gap?\"[\\n\"+gap+h.join(\",\\n\"+gap)+\"\\n\"+g+\"]\":\"[\"+h.join(\",\")+\"]\",gap=g;return e}if(rep&&typeof rep==\"object\"){f=rep.length;for(c=0;c<f;c+=1)typeof rep[c]==\"string\"&&(d=rep[c],e=str(d,i),e&&h.push(quote(d)+(gap?\": \":\":\")+e))}else for(d in i)Object.prototype.hasOwnProperty.call(i,d)&&(e=str(d,i),e&&h.push(quote(d)+(gap?\": \":\":\")+e));e=h.length===0?\"{}\":gap?\"{\\n\"+gap+h.join(\",\\n\"+gap)+\"\\n\"+g+\"}\":\"{\"+h.join(\",\")+\"}\",gap=g;return e}}function quote(a){escapable.lastIndex=0;return escapable.test(a)?'\"'+a.replace(escapable,function(a){var b=meta[a];return typeof b==\"string\"?b:\"\\\\u\"+(\"0000\"+a.charCodeAt(0).toString(16)).slice(-4)})+'\"':'\"'+a+'\"'}function f(a){return a<10?\"0\"+a:a}\"use strict\",typeof Date.prototype.toJSON!=\"function\"&&(Date.prototype.toJSON=function(a){return isFinite(this.valueOf())?this.getUTCFullYear()+\"-\"+f(this.getUTCMonth()+1)+\"-\"+f(this.getUTCDate())+\"T\"+f(this.getUTCHours())+\":\"+f(this.getUTCMinutes())+\":\"+f(this.getUTCSeconds())+\"Z\":null},String.prototype.toJSON=Number.prototype.toJSON=Boolean.prototype.toJSON=function(a){return this.valueOf()});var cx=/[\\u0000\\u00ad\\u0600-\\u0604\\u070f\\u17b4\\u17b5\\u200c-\\u200f\\u2028-\\u202f\\u2060-\\u206f\\ufeff\\ufff0-\\uffff]/g,escapable=/[\\\\\\\"\\x00-\\x1f\\x7f-\\x9f\\u00ad\\u0600-\\u0604\\u070f\\u17b4\\u17b5\\u200c-\\u200f\\u2028-\\u202f\\u2060-\\u206f\\ufeff\\ufff0-\\uffff]/g,gap,indent,meta={\"\\b\":\"\\\\b\",\"\\t\":\"\\\\t\",\"\\n\":\"\\\\n\",\"\\f\":\"\\\\f\",\"\\r\":\"\\\\r\",'\"':'\\\\\"',\"\\\\\":\"\\\\\\\\\"},rep;typeof JSON.stringify!=\"function\"&&(JSON.stringify=function(a,b,c){var d;gap=\"\",indent=\"\";if(typeof c==\"number\")for(d=0;d<c;d+=1)indent+=\" \";else typeof c==\"string\"&&(indent=c);rep=b;if(!b||typeof b==\"function\"||typeof b==\"object\"&&typeof b.length==\"number\")return str(\"\",{\"\":a});throw new Error(\"JSON.stringify\")}),typeof JSON.parse!=\"function\"&&(JSON.parse=function(text,reviver){function walk(a,b){var c,d,e=a[b];if(e&&typeof e==\"object\")for(c in e)Object.prototype.hasOwnProperty.call(e,c)&&(d=walk(e,c),d!==undefined?e[c]=d:delete e[c]);return reviver.call(a,b,e)}var j;text=String(text),cx.lastIndex=0,cx.test(text)&&(text=text.replace(cx,function(a){return\"\\\\u\"+(\"0000\"+a.charCodeAt(0).toString(16)).slice(-4)}));if(/^[\\],:{}\\s]*$/.test(text.replace(/\\\\(?:[\"\\\\\\/bfnrt]|u[0-9a-fA-F]{4})/g,\"@\").replace(/\"[^\"\\\\\\n\\r]*\"|true|false|null|-?\\d+(?:\\.\\d*)?(?:[eE][+\\-]?\\d+)?/g,\"]\").replace(/(?:^|:|,)(?:\\s*\\[)+/g,\"\"))){j=eval(\"(\"+text+\")\");return typeof reviver==\"function\"?walk({\"\":j},\"\"):j}throw new SyntaxError(\"JSON.parse\")})}()\n\n\n// [*] Including lib/index.js\n// Public object\nvar SockJS = (function(){\n var _document = document;\n var _window = window;\n var utils = {};\n\n\n// [*] Including lib/reventtarget.js\n/*\n * ***** BEGIN LICENSE BLOCK *****\n * Copyright (c) 2011-2012 VMware, Inc.\n *\n * For the license see COPYING.\n * ***** END LICENSE BLOCK *****\n */\n\n/* Simplified implementation of DOM2 EventTarget.\n * http://www.w3.org/TR/DOM-Level-2-Events/events.html#Events-EventTarget\n */\nvar REventTarget = function() {};\nREventTarget.prototype.addEventListener = function (eventType, listener) {\n if(!this._listeners) {\n this._listeners = {};\n }\n if(!(eventType in this._listeners)) {\n this._listeners[eventType] = [];\n }\n var arr = this._listeners[eventType];\n if(utils.arrIndexOf(arr, listener) === -1) {\n arr.push(listener);\n }\n return;\n};\n\nREventTarget.prototype.removeEventListener = function (eventType, listener) {\n if(!(this._listeners && (eventType in this._listeners))) {\n return;\n }\n var arr = this._listeners[eventType];\n var idx = utils.arrIndexOf(arr, listener);\n if (idx !== -1) {\n if(arr.length > 1) {\n this._listeners[eventType] = arr.slice(0, idx).concat( arr.slice(idx+1) );\n } else {\n delete this._listeners[eventType];\n }\n return;\n }\n return;\n};\n\nREventTarget.prototype.dispatchEvent = function (event) {\n var t = event.type;\n var args = Array.prototype.slice.call(arguments, 0);\n if (this['on'+t]) {\n this['on'+t].apply(this, args);\n }\n if (this._listeners && t in this._listeners) {\n for(var i=0; i < this._listeners[t].length; i++) {\n this._listeners[t][i].apply(this, args);\n }\n }\n};\n// [*] End of lib/reventtarget.js\n\n\n// [*] Including lib/simpleevent.js\n/*\n * ***** BEGIN LICENSE BLOCK *****\n * Copyright (c) 2011-2012 VMware, Inc.\n *\n * For the license see COPYING.\n * ***** END LICENSE BLOCK *****\n */\n\nvar SimpleEvent = function(type, obj) {\n this.type = type;\n if (typeof obj !== 'undefined') {\n for(var k in obj) {\n if (!obj.hasOwnProperty(k)) continue;\n this[k] = obj[k];\n }\n }\n};\n\nSimpleEvent.prototype.toString = function() {\n var r = [];\n for(var k in this) {\n if (!this.hasOwnProperty(k)) continue;\n var v = this[k];\n if (typeof v === 'function') v = '[function]';\n r.push(k + '=' + v);\n }\n return 'SimpleEvent(' + r.join(', ') + ')';\n};\n// [*] End of lib/simpleevent.js\n\n\n// [*] Including lib/eventemitter.js\n/*\n * ***** BEGIN LICENSE BLOCK *****\n * Copyright (c) 2011-2012 VMware, Inc.\n *\n * For the license see COPYING.\n * ***** END LICENSE BLOCK *****\n */\n\nvar EventEmitter = function(events) {\n this.events = events || [];\n};\nEventEmitter.prototype.emit = function(type) {\n var that = this;\n var args = Array.prototype.slice.call(arguments, 1);\n if (!that.nuked && that['on'+type]) {\n that['on'+type].apply(that, args);\n }\n if (utils.arrIndexOf(that.events, type) === -1) {\n utils.log('Event ' + JSON.stringify(type) +\n ' not listed ' + JSON.stringify(that.events) +\n ' in ' + that);\n }\n};\n\nEventEmitter.prototype.nuke = function(type) {\n var that = this;\n that.nuked = true;\n for(var i=0; i<that.events.length; i++) {\n delete that[that.events[i]];\n }\n};\n// [*] End of lib/eventemitter.js\n\n\n// [*] Including lib/utils.js\n/*\n * ***** BEGIN LICENSE BLOCK *****\n * Copyright (c) 2011-2012 VMware, Inc.\n *\n * For the license see COPYING.\n * ***** END LICENSE BLOCK *****\n */\n\nvar random_string_chars = 'abcdefghijklmnopqrstuvwxyz0123456789_';\nutils.random_string = function(length, max) {\n max = max || random_string_chars.length;\n var i, ret = [];\n for(i=0; i < length; i++) {\n ret.push( random_string_chars.substr(Math.floor(Math.random() * max),1) );\n }\n return ret.join('');\n};\nutils.random_number = function(max) {\n return Math.floor(Math.random() * max);\n};\nutils.random_number_string = function(max) {\n var t = (''+(max - 1)).length;\n var p = Array(t+1).join('0');\n return (p + utils.random_number(max)).slice(-t);\n};\n\n// Assuming that url looks like: http://asdasd:111/asd\nutils.getOrigin = function(url) {\n url += '/';\n var parts = url.split('/').slice(0, 3);\n return parts.join('/');\n};\n\nutils.isSameOriginUrl = function(url_a, url_b) {\n // location.origin would do, but it's not always available.\n if (!url_b) url_b = _window.location.href;\n\n return (url_a.split('/').slice(0,3).join('/')\n ===\n url_b.split('/').slice(0,3).join('/'));\n};\n\nutils.getParentDomain = function(url) {\n // ipv4 ip address\n if (/^[0-9.]*$/.test(url)) return url;\n // ipv6 ip address\n if (/^\\[/.test(url)) return url;\n // no dots\n if (!(/[.]/.test(url))) return url;\n\n var parts = url.split('.').slice(1);\n return parts.join('.');\n};\n\nutils.objectExtend = function(dst, src) {\n for(var k in src) {\n if (src.hasOwnProperty(k)) {\n dst[k] = src[k];\n }\n }\n return dst;\n};\n\nvar WPrefix = '_jp';\n\nutils.polluteGlobalNamespace = function() {\n if (!(WPrefix in _window)) {\n _window[WPrefix] = {};\n }\n};\n\nutils.closeFrame = function (code, reason) {\n return 'c'+JSON.stringify([code, reason]);\n};\n\nutils.userSetCode = function (code) {\n return code === 1000 || (code >= 3000 && code <= 4999);\n};\n\n// See: http://www.erg.abdn.ac.uk/~gerrit/dccp/notes/ccid2/rto_estimator/\n// and RFC 2988.\nutils.countRTO = function (rtt) {\n var rto;\n if (rtt > 100) {\n rto = 3 * rtt; // rto > 300msec\n } else {\n rto = rtt + 200; // 200msec < rto <= 300msec\n }\n return rto;\n}\n\nutils.log = function() {\n if (_window.console && console.log && console.log.apply) {\n console.log.apply(console, arguments);\n }\n};\n\nutils.bind = function(fun, that) {\n if (fun.bind) {\n return fun.bind(that);\n } else {\n return function() {\n return fun.apply(that, arguments);\n };\n }\n};\n\nutils.flatUrl = function(url) {\n return url.indexOf('?') === -1 && url.indexOf('#') === -1;\n};\n\nutils.amendUrl = function(url) {\n var dl = _document.location;\n if (!url) {\n throw new Error('Wrong url for SockJS');\n }\n if (!utils.flatUrl(url)) {\n throw new Error('Only basic urls are supported in SockJS');\n }\n\n // '//abc' --> 'http://abc'\n if (url.indexOf('//') === 0) {\n url = dl.protocol + url;\n }\n // '/abc' --> 'http://localhost:80/abc'\n if (url.indexOf('/') === 0) {\n url = dl.protocol + '//' + dl.host + url;\n }\n // strip trailing slashes\n url = url.replace(/[/]+$/,'');\n return url;\n};\n\n// IE doesn't support [].indexOf.\nutils.arrIndexOf = function(arr, obj){\n for(var i=0; i < arr.length; i++){\n if(arr[i] === obj){\n return i;\n }\n }\n return -1;\n};\n\nutils.arrSkip = function(arr, obj) {\n var idx = utils.arrIndexOf(arr, obj);\n if (idx === -1) {\n return arr.slice();\n } else {\n var dst = arr.slice(0, idx);\n return dst.concat(arr.slice(idx+1));\n }\n};\n\n// Via: https://gist.github.com/1133122/2121c601c5549155483f50be3da5305e83b8c5df\nutils.isArray = Array.isArray || function(value) {\n return {}.toString.call(value).indexOf('Array') >= 0\n};\n\nutils.delay = function(t, fun) {\n if(typeof t === 'function') {\n fun = t;\n t = 0;\n }\n return setTimeout(fun, t);\n};\n\n\n// Chars worth escaping, as defined by Douglas Crockford:\n// https://github.com/douglascrockford/JSON-js/blob/47a9882cddeb1e8529e07af9736218075372b8ac/json2.js#L196\nvar json_escapable = /[\\\\\\\"\\x00-\\x1f\\x7f-\\x9f\\u00ad\\u0600-\\u0604\\u070f\\u17b4\\u17b5\\u200c-\\u200f\\u2028-\\u202f\\u2060-\\u206f\\ufeff\\ufff0-\\uffff]/g,\n json_lookup = {\n\"\\u0000\":\"\\\\u0000\",\"\\u0001\":\"\\\\u0001\",\"\\u0002\":\"\\\\u0002\",\"\\u0003\":\"\\\\u0003\",\n\"\\u0004\":\"\\\\u0004\",\"\\u0005\":\"\\\\u0005\",\"\\u0006\":\"\\\\u0006\",\"\\u0007\":\"\\\\u0007\",\n\"\\b\":\"\\\\b\",\"\\t\":\"\\\\t\",\"\\n\":\"\\\\n\",\"\\u000b\":\"\\\\u000b\",\"\\f\":\"\\\\f\",\"\\r\":\"\\\\r\",\n\"\\u000e\":\"\\\\u000e\",\"\\u000f\":\"\\\\u000f\",\"\\u0010\":\"\\\\u0010\",\"\\u0011\":\"\\\\u0011\",\n\"\\u0012\":\"\\\\u0012\",\"\\u0013\":\"\\\\u0013\",\"\\u0014\":\"\\\\u0014\",\"\\u0015\":\"\\\\u0015\",\n\"\\u0016\":\"\\\\u0016\",\"\\u0017\":\"\\\\u0017\",\"\\u0018\":\"\\\\u0018\",\"\\u0019\":\"\\\\u0019\",\n\"\\u001a\":\"\\\\u001a\",\"\\u001b\":\"\\\\u001b\",\"\\u001c\":\"\\\\u001c\",\"\\u001d\":\"\\\\u001d\",\n\"\\u001e\":\"\\\\u001e\",\"\\u001f\":\"\\\\u001f\",\"\\\"\":\"\\\\\\\"\",\"\\\\\":\"\\\\\\\\\",\n\"\\u007f\":\"\\\\u007f\",\"\\u0080\":\"\\\\u0080\",\"\\u0081\":\"\\\\u0081\",\"\\u0082\":\"\\\\u0082\",\n\"\\u0083\":\"\\\\u0083\",\"\\u0084\":\"\\\\u0084\",\"\\u0085\":\"\\\\u0085\",\"\\u0086\":\"\\\\u0086\",\n\"\\u0087\":\"\\\\u0087\",\"\\u0088\":\"\\\\u0088\",\"\\u0089\":\"\\\\u0089\",\"\\u008a\":\"\\\\u008a\",\n\"\\u008b\":\"\\\\u008b\",\"\\u008c\":\"\\\\u008c\",\"\\u008d\":\"\\\\u008d\",\"\\u008e\":\"\\\\u008e\",\n\"\\u008f\":\"\\\\u008f\",\"\\u0090\":\"\\\\u0090\",\"\\u0091\":\"\\\\u0091\",\"\\u0092\":\"\\\\u0092\",\n\"\\u0093\":\"\\\\u0093\",\"\\u0094\":\"\\\\u0094\",\"\\u0095\":\"\\\\u0095\",\"\\u0096\":\"\\\\u0096\",\n\"\\u0097\":\"\\\\u0097\",\"\\u0098\":\"\\\\u0098\",\"\\u0099\":\"\\\\u0099\",\"\\u009a\":\"\\\\u009a\",\n\"\\u009b\":\"\\\\u009b\",\"\\u009c\":\"\\\\u009c\",\"\\u009d\":\"\\\\u009d\",\"\\u009e\":\"\\\\u009e\",\n\"\\u009f\":\"\\\\u009f\",\"\\u00ad\":\"\\\\u00ad\",\"\\u0600\":\"\\\\u0600\",\"\\u0601\":\"\\\\u0601\",\n\"\\u0602\":\"\\\\u0602\",\"\\u0603\":\"\\\\u0603\",\"\\u0604\":\"\\\\u0604\",\"\\u070f\":\"\\\\u070f\",\n\"\\u17b4\":\"\\\\u17b4\",\"\\u17b5\":\"\\\\u17b5\",\"\\u200c\":\"\\\\u200c\",\"\\u200d\":\"\\\\u200d\",\n\"\\u200e\":\"\\\\u200e\",\"\\u200f\":\"\\\\u200f\",\"\\u2028\":\"\\\\u2028\",\"\\u2029\":\"\\\\u2029\",\n\"\\u202a\":\"\\\\u202a\",\"\\u202b\":\"\\\\u202b\",\"\\u202c\":\"\\\\u202c\",\"\\u202d\":\"\\\\u202d\",\n\"\\u202e\":\"\\\\u202e\",\"\\u202f\":\"\\\\u202f\",\"\\u2060\":\"\\\\u2060\",\"\\u2061\":\"\\\\u2061\",\n\"\\u2062\":\"\\\\u2062\",\"\\u2063\":\"\\\\u2063\",\"\\u2064\":\"\\\\u2064\",\"\\u2065\":\"\\\\u2065\",\n\"\\u2066\":\"\\\\u2066\",\"\\u2067\":\"\\\\u2067\",\"\\u2068\":\"\\\\u2068\",\"\\u2069\":\"\\\\u2069\",\n\"\\u206a\":\"\\\\u206a\",\"\\u206b\":\"\\\\u206b\",\"\\u206c\":\"\\\\u206c\",\"\\u206d\":\"\\\\u206d\",\n\"\\u206e\":\"\\\\u206e\",\"\\u206f\":\"\\\\u206f\",\"\\ufeff\":\"\\\\ufeff\",\"\\ufff0\":\"\\\\ufff0\",\n\"\\ufff1\":\"\\\\ufff1\",\"\\ufff2\":\"\\\\ufff2\",\"\\ufff3\":\"\\\\ufff3\",\"\\ufff4\":\"\\\\ufff4\",\n\"\\ufff5\":\"\\\\ufff5\",\"\\ufff6\":\"\\\\ufff6\",\"\\ufff7\":\"\\\\ufff7\",\"\\ufff8\":\"\\\\ufff8\",\n\"\\ufff9\":\"\\\\ufff9\",\"\\ufffa\":\"\\\\ufffa\",\"\\ufffb\":\"\\\\ufffb\",\"\\ufffc\":\"\\\\ufffc\",\n\"\\ufffd\":\"\\\\ufffd\",\"\\ufffe\":\"\\\\ufffe\",\"\\uffff\":\"\\\\uffff\"};\n\n// Some extra characters that Chrome gets wrong, and substitutes with\n// something else on the wire.\nvar extra_escapable = /[\\x00-\\x1f\\ud800-\\udfff\\ufffe\\uffff\\u0300-\\u0333\\u033d-\\u0346\\u034a-\\u034c\\u0350-\\u0352\\u0357-\\u0358\\u035c-\\u0362\\u0374\\u037e\\u0387\\u0591-\\u05af\\u05c4\\u0610-\\u0617\\u0653-\\u0654\\u0657-\\u065b\\u065d-\\u065e\\u06df-\\u06e2\\u06eb-\\u06ec\\u0730\\u0732-\\u0733\\u0735-\\u0736\\u073a\\u073d\\u073f-\\u0741\\u0743\\u0745\\u0747\\u07eb-\\u07f1\\u0951\\u0958-\\u095f\\u09dc-\\u09dd\\u09df\\u0a33\\u0a36\\u0a59-\\u0a5b\\u0a5e\\u0b5c-\\u0b5d\\u0e38-\\u0e39\\u0f43\\u0f4d\\u0f52\\u0f57\\u0f5c\\u0f69\\u0f72-\\u0f76\\u0f78\\u0f80-\\u0f83\\u0f93\\u0f9d\\u0fa2\\u0fa7\\u0fac\\u0fb9\\u1939-\\u193a\\u1a17\\u1b6b\\u1cda-\\u1cdb\\u1dc0-\\u1dcf\\u1dfc\\u1dfe\\u1f71\\u1f73\\u1f75\\u1f77\\u1f79\\u1f7b\\u1f7d\\u1fbb\\u1fbe\\u1fc9\\u1fcb\\u1fd3\\u1fdb\\u1fe3\\u1feb\\u1fee-\\u1fef\\u1ff9\\u1ffb\\u1ffd\\u2000-\\u2001\\u20d0-\\u20d1\\u20d4-\\u20d7\\u20e7-\\u20e9\\u2126\\u212a-\\u212b\\u2329-\\u232a\\u2adc\\u302b-\\u302c\\uaab2-\\uaab3\\uf900-\\ufa0d\\ufa10\\ufa12\\ufa15-\\ufa1e\\ufa20\\ufa22\\ufa25-\\ufa26\\ufa2a-\\ufa2d\\ufa30-\\ufa6d\\ufa70-\\ufad9\\ufb1d\\ufb1f\\ufb2a-\\ufb36\\ufb38-\\ufb3c\\ufb3e\\ufb40-\\ufb41\\ufb43-\\ufb44\\ufb46-\\ufb4e\\ufff0-\\uffff]/g,\n extra_lookup;\n\n// JSON Quote string. Use native implementation when possible.\nvar JSONQuote = (JSON && JSON.stringify) || function(string) {\n json_escapable.lastIndex = 0;\n if (json_escapable.test(string)) {\n string = string.replace(json_escapable, function(a) {\n return json_lookup[a];\n });\n }\n return '\"' + string + '\"';\n};\n\n// This may be quite slow, so let's delay until user actually uses bad\n// characters.\nvar unroll_lookup = function(escapable) {\n var i;\n var unrolled = {}\n var c = []\n for(i=0; i<65536; i++) {\n c.push( String.fromCharCode(i) );\n }\n escapable.lastIndex = 0;\n c.join('').replace(escapable, function (a) {\n unrolled[ a ] = '\\\\u' + ('0000' + a.charCodeAt(0).toString(16)).slice(-4);\n return '';\n });\n escapable.lastIndex = 0;\n return unrolled;\n};\n\n// Quote string, also taking care of unicode characters that browsers\n// often break. Especially, take care of unicode surrogates:\n// http://en.wikipedia.org/wiki/Mapping_of_Unicode_characters#Surrogates\nutils.quote = function(string) {\n var quoted = JSONQuote(string);\n\n // In most cases this should be very fast and good enough.\n extra_escapable.lastIndex = 0;\n if(!extra_escapable.test(quoted)) {\n return quoted;\n }\n\n if(!extra_lookup) extra_lookup = unroll_lookup(extra_escapable);\n\n return quoted.replace(extra_escapable, function(a) {\n return extra_lookup[a];\n });\n}\n\nvar _all_protocols = ['websocket',\n 'xdr-streaming',\n 'xhr-streaming',\n 'iframe-eventsource',\n 'iframe-htmlfile',\n 'xdr-polling',\n 'xhr-polling',\n 'iframe-xhr-polling',\n 'jsonp-polling'];\n\nutils.probeProtocols = function() {\n var probed = {};\n for(var i=0; i<_all_protocols.length; i++) {\n var protocol = _all_protocols[i];\n // User can have a typo in protocol name.\n probed[protocol] = SockJS[protocol] &&\n SockJS[protocol].enabled();\n }\n return probed;\n};\n\nutils.detectProtocols = function(probed, protocols_whitelist, info) {\n var pe = {},\n protocols = [];\n if (!protocols_whitelist) protocols_whitelist = _all_protocols;\n for(var i=0; i<protocols_whitelist.length; i++) {\n var protocol = protocols_whitelist[i];\n pe[protocol] = probed[protocol];\n }\n var maybe_push = function(protos) {\n var proto = protos.shift();\n if (pe[proto]) {\n protocols.push(proto);\n } else {\n if (protos.length > 0) {\n maybe_push(protos);\n }\n }\n }\n\n // 1. Websocket\n if (info.websocket !== false) {\n maybe_push(['websocket']);\n }\n\n // 2. Streaming\n if (pe['xhr-streaming'] && !info.null_origin) {\n protocols.push('xhr-streaming');\n } else {\n if (pe['xdr-streaming'] && !info.cookie_needed && !info.null_origin) {\n protocols.push('xdr-streaming');\n } else {\n maybe_push(['iframe-eventsource',\n 'iframe-htmlfile']);\n }\n }\n\n // 3. Polling\n if (pe['xhr-polling'] && !info.null_origin) {\n protocols.push('xhr-polling');\n } else {\n if (pe['xdr-polling'] && !info.cookie_needed && !info.null_origin) {\n protocols.push('xdr-polling');\n } else {\n maybe_push(['iframe-xhr-polling',\n 'jsonp-polling']);\n }\n }\n return protocols;\n}\n// [*] End of lib/utils.js\n\n\n// [*] Including lib/dom.js\n/*\n * ***** BEGIN LICENSE BLOCK *****\n * Copyright (c) 2011-2012 VMware, Inc.\n *\n * For the license see COPYING.\n * ***** END LICENSE BLOCK *****\n */\n\n// May be used by htmlfile jsonp and transports.\nvar MPrefix = '_sockjs_global';\nutils.createHook = function() {\n var window_id = 'a' + utils.random_string(8);\n if (!(MPrefix in _window)) {\n var map = {};\n _window[MPrefix] = function(window_id) {\n if (!(window_id in map)) {\n map[window_id] = {\n id: window_id,\n del: function() {delete map[window_id];}\n };\n }\n return map[window_id];\n }\n }\n return _window[MPrefix](window_id);\n};\n\n\n\nutils.attachMessage = function(listener) {\n utils.attachEvent('message', listener);\n};\nutils.attachEvent = function(event, listener) {\n if (typeof _window.addEventListener !== 'undefined') {\n _window.addEventListener(event, listener, false);\n } else {\n // IE quirks.\n // According to: http://stevesouders.com/misc/test-postmessage.php\n // the message gets delivered only to 'document', not 'window'.\n _document.attachEvent(\"on\" + event, listener);\n // I get 'window' for ie8.\n _window.attachEvent(\"on\" + event, listener);\n }\n};\n\nutils.detachMessage = function(listener) {\n utils.detachEvent('message', listener);\n};\nutils.detachEvent = function(event, listener) {\n if (typeof _window.addEventListener !== 'undefined') {\n _window.removeEventListener(event, listener, false);\n } else {\n _document.detachEvent(\"on\" + event, listener);\n _window.detachEvent(\"on\" + event, listener);\n }\n};\n\n\nvar on_unload = {};\n// Things registered after beforeunload are to be called immediately.\nvar after_unload = false;\n\nvar trigger_unload_callbacks = function() {\n for(var ref in on_unload) {\n on_unload[ref]();\n delete on_unload[ref];\n };\n};\n\nvar unload_triggered = function() {\n if(after_unload) return;\n after_unload = true;\n trigger_unload_callbacks();\n};\n\n// Onbeforeunload alone is not reliable. We could use only 'unload'\n// but it's not working in opera within an iframe. Let's use both.\nutils.attachEvent('beforeunload', unload_triggered);\nutils.attachEvent('unload', unload_triggered);\n\nutils.unload_add = function(listener) {\n var ref = utils.random_string(8);\n on_unload[ref] = listener;\n if (after_unload) {\n utils.delay(trigger_unload_callbacks);\n }\n return ref;\n};\nutils.unload_del = function(ref) {\n if (ref in on_unload)\n delete on_unload[ref];\n};\n\n\nutils.createIframe = function (iframe_url, error_callback) {\n var iframe = _document.createElement('iframe');\n var tref, unload_ref;\n var unattach = function() {\n clearTimeout(tref);\n // Explorer had problems with that.\n try {iframe.onload = null;} catch (x) {}\n iframe.onerror = null;\n };\n var cleanup = function() {\n if (iframe) {\n unattach();\n // This timeout makes chrome fire onbeforeunload event\n // within iframe. Without the timeout it goes straight to\n // onunload.\n setTimeout(function() {\n if(iframe) {\n iframe.parentNode.removeChild(iframe);\n }\n iframe = null;\n }, 0);\n utils.unload_del(unload_ref);\n }\n };\n var onerror = function(r) {\n if (iframe) {\n cleanup();\n error_callback(r);\n }\n };\n var post = function(msg, origin) {\n try {\n // When the iframe is not loaded, IE raises an exception\n // on 'contentWindow'.\n if (iframe && iframe.contentWindow) {\n iframe.contentWindow.postMessage(msg, origin);\n }\n } catch (x) {};\n };\n\n iframe.src = iframe_url;\n iframe.style.display = 'none';\n iframe.style.position = 'absolute';\n iframe.onerror = function(){onerror('onerror');};\n iframe.onload = function() {\n // `onload` is triggered before scripts on the iframe are\n // executed. Give it few seconds to actually load stuff.\n clearTimeout(tref);\n tref = setTimeout(function(){onerror('onload timeout');}, 2000);\n };\n _document.body.appendChild(iframe);\n tref = setTimeout(function(){onerror('timeout');}, 15000);\n unload_ref = utils.unload_add(cleanup);\n return {\n post: post,\n cleanup: cleanup,\n loaded: unattach\n };\n};\n\nutils.createHtmlfile = function (iframe_url, error_callback) {\n var doc = new ActiveXObject('htmlfile');\n var tref, unload_ref;\n var iframe;\n var unattach = function() {\n clearTimeout(tref);\n };\n var cleanup = function() {\n if (doc) {\n unattach();\n utils.unload_del(unload_ref);\n iframe.parentNode.removeChild(iframe);\n iframe = doc = null;\n CollectGarbage();\n }\n };\n var onerror = function(r) {\n if (doc) {\n cleanup();\n error_callback(r);\n }\n };\n var post = function(msg, origin) {\n try {\n // When the iframe is not loaded, IE raises an exception\n // on 'contentWindow'.\n if (iframe && iframe.contentWindow) {\n iframe.contentWindow.postMessage(msg, origin);\n }\n } catch (x) {};\n };\n\n doc.open();\n doc.write('<html><s' + 'cript>' +\n 'document.domain=\"' + document.domain + '\";' +\n '</s' + 'cript></html>');\n doc.close();\n doc.parentWindow[WPrefix] = _window[WPrefix];\n var c = doc.createElement('div');\n doc.body.appendChild(c);\n iframe = doc.createElement('iframe');\n c.appendChild(iframe);\n iframe.src = iframe_url;\n tref = setTimeout(function(){onerror('timeout');}, 15000);\n unload_ref = utils.unload_add(cleanup);\n return {\n post: post,\n cleanup: cleanup,\n loaded: unattach\n };\n};\n// [*] End of lib/dom.js\n\n\n// [*] Including lib/dom2.js\n/*\n * ***** BEGIN LICENSE BLOCK *****\n * Copyright (c) 2011-2012 VMware, Inc.\n *\n * For the license see COPYING.\n * ***** END LICENSE BLOCK *****\n */\n\nvar AbstractXHRObject = function(){};\nAbstractXHRObject.prototype = new EventEmitter(['chunk', 'finish']);\n\nAbstractXHRObject.prototype._start = function(method, url, payload, opts) {\n var that = this;\n\n try {\n that.xhr = new XMLHttpRequest();\n } catch(x) {};\n\n if (!that.xhr) {\n try {\n that.xhr = new _window.ActiveXObject('Microsoft.XMLHTTP');\n } catch(x) {};\n }\n if (_window.ActiveXObject || _window.XDomainRequest) {\n // IE8 caches even POSTs\n url += ((url.indexOf('?') === -1) ? '?' : '&') + 't='+(+new Date);\n }\n\n // Explorer tends to keep connection open, even after the\n // tab gets closed: http://bugs.jquery.com/ticket/5280\n that.unload_ref = utils.unload_add(function(){that._cleanup(true);});\n try {\n that.xhr.open(method, url, true);\n } catch(e) {\n // IE raises an exception on wrong port.\n that.emit('finish', 0, '');\n that._cleanup();\n return;\n };\n\n if (!opts || !opts.no_credentials) {\n // Mozilla docs says https://developer.mozilla.org/en/XMLHttpRequest :\n // \"This never affects same-site requests.\"\n that.xhr.withCredentials = 'true';\n }\n if (opts && opts.headers) {\n for(var key in opts.headers) {\n that.xhr.setRequestHeader(key, opts.headers[key]);\n }\n }\n\n that.xhr.onreadystatechange = function() {\n if (that.xhr) {\n var x = that.xhr;\n switch (x.readyState) {\n case 3:\n // IE doesn't like peeking into responseText or status\n // on Microsoft.XMLHTTP and readystate=3\n try {\n var status = x.status;\n var text = x.responseText;\n } catch (x) {};\n // IE does return readystate == 3 for 404 answers.\n if (text && text.length > 0) {\n that.emit('chunk', status, text);\n }\n break;\n case 4:\n that.emit('finish', x.status, x.responseText);\n that._cleanup(false);\n break;\n }\n }\n };\n that.xhr.send(payload);\n};\n\nAbstractXHRObject.prototype._cleanup = function(abort) {\n var that = this;\n if (!that.xhr) return;\n utils.unload_del(that.unload_ref);\n\n // IE needs this field to be a function\n that.xhr.onreadystatechange = function(){};\n\n if (abort) {\n try {\n that.xhr.abort();\n } catch(x) {};\n }\n that.unload_ref = that.xhr = null;\n};\n\nAbstractXHRObject.prototype.close = function() {\n var that = this;\n that.nuke();\n that._cleanup(true);\n};\n\nvar XHRCorsObject = utils.XHRCorsObject = function() {\n var that = this, args = arguments;\n utils.delay(function(){that._start.apply(that, args);});\n};\nXHRCorsObject.prototype = new AbstractXHRObject();\n\nvar XHRLocalObject = utils.XHRLocalObject = function(method, url, payload) {\n var that = this;\n utils.delay(function(){\n that._start(method, url, payload, {\n no_credentials: true\n });\n });\n};\nXHRLocalObject.prototype = new AbstractXHRObject();\n\n\n\n// References:\n// http://ajaxian.com/archives/100-line-ajax-wrapper\n// http://msdn.microsoft.com/en-us/library/cc288060(v=VS.85).aspx\nvar XDRObject = utils.XDRObject = function(method, url, payload) {\n var that = this;\n utils.delay(function(){that._start(method, url, payload);});\n};\nXDRObject.prototype = new EventEmitter(['chunk', 'finish']);\nXDRObject.prototype._start = function(method, url, payload) {\n var that = this;\n var xdr = new XDomainRequest();\n // IE caches even POSTs\n url += ((url.indexOf('?') === -1) ? '?' : '&') + 't='+(+new Date);\n\n var onerror = xdr.ontimeout = xdr.onerror = function() {\n that.emit('finish', 0, '');\n that._cleanup(false);\n };\n xdr.onprogress = function() {\n that.emit('chunk', 200, xdr.responseText);\n };\n xdr.onload = function() {\n that.emit('finish', 200, xdr.responseText);\n that._cleanup(false);\n };\n that.xdr = xdr;\n that.unload_ref = utils.unload_add(function(){that._cleanup(true);});\n try {\n // Fails with AccessDenied if port number is bogus\n that.xdr.open(method, url);\n that.xdr.send(payload);\n } catch(x) {\n onerror();\n }\n};\n\nXDRObject.prototype._cleanup = function(abort) {\n var that = this;\n if (!that.xdr) return;\n utils.unload_del(that.unload_ref);\n\n that.xdr.ontimeout = that.xdr.onerror = that.xdr.onprogress =\n that.xdr.onload = null;\n if (abort) {\n try {\n that.xdr.abort();\n } catch(x) {};\n }\n that.unload_ref = that.xdr = null;\n};\n\nXDRObject.prototype.close = function() {\n var that = this;\n that.nuke();\n that._cleanup(true);\n};\n\n// 1. Is natively via XHR\n// 2. Is natively via XDR\n// 3. Nope, but postMessage is there so it should work via the Iframe.\n// 4. Nope, sorry.\nutils.isXHRCorsCapable = function() {\n if (_window.XMLHttpRequest && 'withCredentials' in new XMLHttpRequest()) {\n return 1;\n }\n // XDomainRequest doesn't work if page is served from file://\n if (_window.XDomainRequest && _document.domain) {\n return 2;\n }\n if (IframeTransport.enabled()) {\n return 3;\n }\n return 4;\n};\n// [*] End of lib/dom2.js\n\n\n// [*] Including lib/sockjs.js\n/*\n * ***** BEGIN LICENSE BLOCK *****\n * Copyright (c) 2011-2012 VMware, Inc.\n *\n * For the license see COPYING.\n * ***** END LICENSE BLOCK *****\n */\n\nvar SockJS = function(url, dep_protocols_whitelist, options) {\n if (this === window) {\n // makes `new` optional\n return new SockJS(url, dep_protocols_whitelist, options);\n }\n \n var that = this, protocols_whitelist;\n that._options = {devel: false, debug: false, protocols_whitelist: [],\n info: undefined, rtt: undefined};\n if (options) {\n utils.objectExtend(that._options, options);\n }\n that._base_url = utils.amendUrl(url);\n that._server = that._options.server || utils.random_number_string(1000);\n if (that._options.protocols_whitelist &&\n that._options.protocols_whitelist.length) {\n protocols_whitelist = that._options.protocols_whitelist;\n } else {\n // Deprecated API\n if (typeof dep_protocols_whitelist === 'string' &&\n dep_protocols_whitelist.length > 0) {\n protocols_whitelist = [dep_protocols_whitelist];\n } else if (utils.isArray(dep_protocols_whitelist)) {\n protocols_whitelist = dep_protocols_whitelist\n } else {\n protocols_whitelist = null;\n }\n if (protocols_whitelist) {\n that._debug('Deprecated API: Use \"protocols_whitelist\" option ' +\n 'instead of supplying protocol list as a second ' +\n 'parameter to SockJS constructor.');\n }\n }\n that._protocols = [];\n that.protocol = null;\n that.readyState = SockJS.CONNECTING;\n that._ir = createInfoReceiver(that._base_url);\n that._ir.onfinish = function(info, rtt) {\n that._ir = null;\n if (info) {\n if (that._options.info) {\n // Override if user supplies the option\n info = utils.objectExtend(info, that._options.info);\n }\n if (that._options.rtt) {\n rtt = that._options.rtt;\n }\n that._applyInfo(info, rtt, protocols_whitelist);\n that._didClose();\n } else {\n that._didClose(1002, 'Can\\'t connect to server', true);\n }\n };\n};\n// Inheritance\nSockJS.prototype = new REventTarget();\n\nSockJS.version = \"0.3.1.7.ga67f.dirty\";\n\nSockJS.CONNECTING = 0;\nSockJS.OPEN = 1;\nSockJS.CLOSING = 2;\nSockJS.CLOSED = 3;\n\nSockJS.prototype._debug = function() {\n if (this._options.debug)\n utils.log.apply(utils, arguments);\n};\n\nSockJS.prototype._dispatchOpen = function() {\n var that = this;\n if (that.readyState === SockJS.CONNECTING) {\n if (that._transport_tref) {\n clearTimeout(that._transport_tref);\n that._transport_tref = null;\n }\n that.readyState = SockJS.OPEN;\n that.dispatchEvent(new SimpleEvent(\"open\"));\n } else {\n // The server might have been restarted, and lost track of our\n // connection.\n that._didClose(1006, \"Server lost session\");\n }\n};\n\nSockJS.prototype._dispatchMessage = function(data) {\n var that = this;\n if (that.readyState !== SockJS.OPEN)\n return;\n that.dispatchEvent(new SimpleEvent(\"message\", {data: data}));\n};\n\nSockJS.prototype._dispatchHeartbeat = function(data) {\n var that = this;\n if (that.readyState !== SockJS.OPEN)\n return;\n that.dispatchEvent(new SimpleEvent('heartbeat', {}));\n};\n\nSockJS.prototype._didClose = function(code, reason, force) {\n var that = this;\n if (that.readyState !== SockJS.CONNECTING &&\n that.readyState !== SockJS.OPEN &&\n that.readyState !== SockJS.CLOSING)\n throw new Error('INVALID_STATE_ERR');\n if (that._ir) {\n that._ir.nuke();\n that._ir = null;\n }\n\n if (that._transport) {\n that._transport.doCleanup();\n that._transport = null;\n }\n\n var close_event = new SimpleEvent(\"close\", {\n code: code,\n reason: reason,\n wasClean: utils.userSetCode(code)});\n\n if (!utils.userSetCode(code) &&\n that.readyState === SockJS.CONNECTING && !force) {\n if (that._try_next_protocol(close_event)) {\n return;\n }\n close_event = new SimpleEvent(\"close\", {code: 2000,\n reason: \"All transports failed\",\n wasClean: false,\n last_event: close_event});\n }\n that.readyState = SockJS.CLOSED;\n\n utils.delay(function() {\n that.dispatchEvent(close_event);\n });\n};\n\nSockJS.prototype._didMessage = function(data) {\n var that = this;\n var type = data.slice(0, 1);\n switch(type) {\n case 'o':\n that._dispatchOpen();\n break;\n case 'a':\n var payload = JSON.parse(data.slice(1) || '[]');\n for(var i=0; i < payload.length; i++){\n that._dispatchMessage(payload[i]);\n }\n break;\n case 'm':\n var payload = JSON.parse(data.slice(1) || 'null');\n that._dispatchMessage(payload);\n break;\n case 'c':\n var payload = JSON.parse(data.slice(1) || '[]');\n that._didClose(payload[0], payload[1]);\n break;\n case 'h':\n that._dispatchHeartbeat();\n break;\n }\n};\n\nSockJS.prototype._try_next_protocol = function(close_event) {\n var that = this;\n if (that.protocol) {\n that._debug('Closed transport:', that.protocol, ''+close_event);\n that.protocol = null;\n }\n if (that._transport_tref) {\n clearTimeout(that._transport_tref);\n that._transport_tref = null;\n }\n\n while(1) {\n var protocol = that.protocol = that._protocols.shift();\n if (!protocol) {\n return false;\n }\n // Some protocols require access to `body`, what if were in\n // the `head`?\n if (SockJS[protocol] &&\n SockJS[protocol].need_body === true &&\n (!_document.body ||\n (typeof _document.readyState !== 'undefined'\n && _document.readyState !== 'complete'))) {\n that._protocols.unshift(protocol);\n that.protocol = 'waiting-for-load';\n utils.attachEvent('load', function(){\n that._try_next_protocol();\n });\n return true;\n }\n\n if (!SockJS[protocol] ||\n !SockJS[protocol].enabled(that._options)) {\n that._debug('Skipping transport:', protocol);\n } else {\n var roundTrips = SockJS[protocol].roundTrips || 1;\n var to = ((that._options.rto || 0) * roundTrips) || 5000;\n that._transport_tref = utils.delay(to, function() {\n if (that.readyState === SockJS.CONNECTING) {\n // I can't understand how it is possible to run\n // this timer, when the state is CLOSED, but\n // apparently in IE everythin is possible.\n that._didClose(2007, \"Transport timeouted\");\n }\n });\n\n var connid = utils.random_string(8);\n var trans_url = that._base_url + '/' + that._server + '/' + connid;\n that._debug('Opening transport:', protocol, ' url:'+trans_url,\n ' RTO:'+that._options.rto);\n that._transport = new SockJS[protocol](that, trans_url,\n that._base_url);\n return true;\n }\n }\n};\n\nSockJS.prototype.close = function(code, reason) {\n var that = this;\n if (code && !utils.userSetCode(code))\n throw new Error(\"INVALID_ACCESS_ERR\");\n if(that.readyState !== SockJS.CONNECTING &&\n that.readyState !== SockJS.OPEN) {\n return false;\n }\n that.readyState = SockJS.CLOSING;\n that._didClose(code || 1000, reason || \"Normal closure\");\n return true;\n};\n\nSockJS.prototype.send = function(data) {\n var that = this;\n if (that.readyState === SockJS.CONNECTING)\n throw new Error('INVALID_STATE_ERR');\n if (that.readyState === SockJS.OPEN) {\n that._transport.doSend(utils.quote('' + data));\n }\n return true;\n};\n\nSockJS.prototype._applyInfo = function(info, rtt, protocols_whitelist) {\n var that = this;\n that._options.info = info;\n that._options.rtt = rtt;\n that._options.rto = utils.countRTO(rtt);\n that._options.info.null_origin = !_document.domain;\n var probed = utils.probeProtocols();\n that._protocols = utils.detectProtocols(probed, protocols_whitelist, info);\n};\n// [*] End of lib/sockjs.js\n\n\n// [*] Including lib/trans-websocket.js\n/*\n * ***** BEGIN LICENSE BLOCK *****\n * Copyright (c) 2011-2012 VMware, Inc.\n *\n * For the license see COPYING.\n * ***** END LICENSE BLOCK *****\n */\n\nvar WebSocketTransport = SockJS.websocket = function(ri, trans_url) {\n var that = this;\n var url = trans_url + '/websocket';\n if (url.slice(0, 5) === 'https') {\n url = 'wss' + url.slice(5);\n } else {\n url = 'ws' + url.slice(4);\n }\n that.ri = ri;\n that.url = url;\n var Constructor = _window.WebSocket || _window.MozWebSocket;\n\n that.ws = new Constructor(that.url);\n that.ws.onmessage = function(e) {\n that.ri._didMessage(e.data);\n };\n // Firefox has an interesting bug. If a websocket connection is\n // created after onbeforeunload, it stays alive even when user\n // navigates away from the page. In such situation let's lie -\n // let's not open the ws connection at all. See:\n // https://github.com/sockjs/sockjs-client/issues/28\n // https://bugzilla.mozilla.org/show_bug.cgi?id=696085\n that.unload_ref = utils.unload_add(function(){that.ws.close()});\n that.ws.onclose = function() {\n that.ri._didMessage(utils.closeFrame(1006, \"WebSocket connection broken\"));\n };\n};\n\nWebSocketTransport.prototype.doSend = function(data) {\n this.ws.send('[' + data + ']');\n};\n\nWebSocketTransport.prototype.doCleanup = function() {\n var that = this;\n var ws = that.ws;\n if (ws) {\n ws.onmessage = ws.onclose = null;\n ws.close();\n utils.unload_del(that.unload_ref);\n that.unload_ref = that.ri = that.ws = null;\n }\n};\n\nWebSocketTransport.enabled = function() {\n return !!(_window.WebSocket || _window.MozWebSocket);\n};\n\n// In theory, ws should require 1 round trip. But in chrome, this is\n// not very stable over SSL. Most likely a ws connection requires a\n// separate SSL connection, in which case 2 round trips are an\n// absolute minumum.\nWebSocketTransport.roundTrips = 2;\n// [*] End of lib/trans-websocket.js\n\n\n// [*] Including lib/trans-sender.js\n/*\n * ***** BEGIN LICENSE BLOCK *****\n * Copyright (c) 2011-2012 VMware, Inc.\n *\n * For the license see COPYING.\n * ***** END LICENSE BLOCK *****\n */\n\nvar BufferedSender = function() {};\nBufferedSender.prototype.send_constructor = function(sender) {\n var that = this;\n that.send_buffer = [];\n that.sender = sender;\n};\nBufferedSender.prototype.doSend = function(message) {\n var that = this;\n that.send_buffer.push(message);\n if (!that.send_stop) {\n that.send_schedule();\n }\n};\n\n// For polling transports in a situation when in the message callback,\n// new message is being send. If the sending connection was started\n// before receiving one, it is possible to saturate the network and\n// timeout due to the lack of receiving socket. To avoid that we delay\n// sending messages by some small time, in order to let receiving\n// connection be started beforehand. This is only a halfmeasure and\n// does not fix the big problem, but it does make the tests go more\n// stable on slow networks.\nBufferedSender.prototype.send_schedule_wait = function() {\n var that = this;\n var tref;\n that.send_stop = function() {\n that.send_stop = null;\n clearTimeout(tref);\n };\n tref = utils.delay(25, function() {\n that.send_stop = null;\n that.send_schedule();\n });\n};\n\nBufferedSender.prototype.send_schedule = function() {\n var that = this;\n if (that.send_buffer.length > 0) {\n var payload = '[' + that.send_buffer.join(',') + ']';\n that.send_stop = that.sender(that.trans_url,\n payload,\n function() {\n that.send_stop = null;\n that.send_schedule_wait();\n });\n that.send_buffer = [];\n }\n};\n\nBufferedSender.prototype.send_destructor = function() {\n var that = this;\n if (that._send_stop) {\n that._send_stop();\n }\n that._send_stop = null;\n};\n\nvar jsonPGenericSender = function(url, payload, callback) {\n var that = this;\n\n if (!('_send_form' in that)) {\n var form = that._send_form = _document.createElement('form');\n var area = that._send_area = _document.createElement('textarea');\n area.name = 'd';\n form.style.display = 'none';\n form.style.position = 'absolute';\n form.method = 'POST';\n form.enctype = 'application/x-www-form-urlencoded';\n form.acceptCharset = \"UTF-8\";\n form.appendChild(area);\n _document.body.appendChild(form);\n }\n var form = that._send_form;\n var area = that._send_area;\n var id = 'a' + utils.random_string(8);\n form.target = id;\n form.action = url + '/jsonp_send?i=' + id;\n\n var iframe;\n try {\n // ie6 dynamic iframes with target=\"\" support (thanks Chris Lambacher)\n iframe = _document.createElement('<iframe name=\"'+ id +'\">');\n } catch(x) {\n iframe = _document.createElement('iframe');\n iframe.name = id;\n }\n iframe.id = id;\n form.appendChild(iframe);\n iframe.style.display = 'none';\n\n try {\n area.value = payload;\n } catch(e) {\n utils.log('Your browser is seriously broken. Go home! ' + e.message);\n }\n form.submit();\n\n var completed = function(e) {\n if (!iframe.onerror) return;\n iframe.onreadystatechange = iframe.onerror = iframe.onload = null;\n // Opera mini doesn't like if we GC iframe\n // immediately, thus this timeout.\n utils.delay(500, function() {\n iframe.parentNode.removeChild(iframe);\n iframe = null;\n });\n area.value = '';\n callback();\n };\n iframe.onerror = iframe.onload = completed;\n iframe.onreadystatechange = function(e) {\n if (iframe.readyState == 'complete') completed();\n };\n return completed;\n};\n\nvar createAjaxSender = function(AjaxObject) {\n return function(url, payload, callback) {\n var xo = new AjaxObject('POST', url + '/xhr_send', payload);\n xo.onfinish = function(status, text) {\n callback(status);\n };\n return function(abort_reason) {\n callback(0, abort_reason);\n };\n };\n};\n// [*] End of lib/trans-sender.js\n\n\n// [*] Including lib/trans-jsonp-receiver.js\n/*\n * ***** BEGIN LICENSE BLOCK *****\n * Copyright (c) 2011-2012 VMware, Inc.\n *\n * For the license see COPYING.\n * ***** END LICENSE BLOCK *****\n */\n\n// Parts derived from Socket.io:\n// https://github.com/LearnBoost/socket.io/blob/0.6.17/lib/socket.io/transports/jsonp-polling.js\n// and jQuery-JSONP:\n// https://code.google.com/p/jquery-jsonp/source/browse/trunk/core/jquery.jsonp.js\nvar jsonPGenericReceiver = function(url, callback) {\n var tref;\n var script = _document.createElement('script');\n var script2; // Opera synchronous load trick.\n var close_script = function(frame) {\n if (script2) {\n script2.parentNode.removeChild(script2);\n script2 = null;\n }\n if (script) {\n clearTimeout(tref);\n script.parentNode.removeChild(script);\n script.onreadystatechange = script.onerror =\n script.onload = script.onclick = null;\n script = null;\n callback(frame);\n callback = null;\n }\n };\n\n // IE9 fires 'error' event after orsc or before, in random order.\n var loaded_okay = false;\n var error_timer = null;\n\n script.id = 'a' + utils.random_string(8);\n script.src = url;\n script.type = 'text/javascript';\n script.charset = 'UTF-8';\n script.onerror = function(e) {\n if (!error_timer) {\n // Delay firing close_script.\n error_timer = setTimeout(function() {\n if (!loaded_okay) {\n close_script(utils.closeFrame(\n 1006,\n \"JSONP script loaded abnormally (onerror)\"));\n }\n }, 1000);\n }\n };\n script.onload = function(e) {\n close_script(utils.closeFrame(1006, \"JSONP script loaded abnormally (onload)\"));\n };\n\n script.onreadystatechange = function(e) {\n if (/loaded|closed/.test(script.readyState)) {\n if (script && script.htmlFor && script.onclick) {\n loaded_okay = true;\n try {\n // In IE, actually execute the script.\n script.onclick();\n } catch (x) {}\n }\n if (script) {\n close_script(utils.closeFrame(1006, \"JSONP script loaded abnormally (onreadystatechange)\"));\n }\n }\n };\n // IE: event/htmlFor/onclick trick.\n // One can't rely on proper order for onreadystatechange. In order to\n // make sure, set a 'htmlFor' and 'event' properties, so that\n // script code will be installed as 'onclick' handler for the\n // script object. Later, onreadystatechange, manually execute this\n // code. FF and Chrome doesn't work with 'event' and 'htmlFor'\n // set. For reference see:\n // http://jaubourg.net/2010/07/loading-script-as-onclick-handler-of.html\n // Also, read on that about script ordering:\n // http://wiki.whatwg.org/wiki/Dynamic_Script_Execution_Order\n if (typeof script.async === 'undefined' && _document.attachEvent) {\n // According to mozilla docs, in recent browsers script.async defaults\n // to 'true', so we may use it to detect a good browser:\n // https://developer.mozilla.org/en/HTML/Element/script\n if (!/opera/i.test(navigator.userAgent)) {\n // Naively assume we're in IE\n try {\n script.htmlFor = script.id;\n script.event = \"onclick\";\n } catch (x) {}\n script.async = true;\n } else {\n // Opera, second sync script hack\n script2 = _document.createElement('script');\n script2.text = \"try{var a = document.getElementById('\"+script.id+\"'); if(a)a.onerror();}catch(x){};\";\n script.async = script2.async = false;\n }\n }\n if (typeof script.async !== 'undefined') {\n script.async = true;\n }\n\n // Fallback mostly for Konqueror - stupid timer, 35 seconds shall be plenty.\n tref = setTimeout(function() {\n close_script(utils.closeFrame(1006, \"JSONP script loaded abnormally (timeout)\"));\n }, 35000);\n\n var head = _document.getElementsByTagName('head')[0];\n head.insertBefore(script, head.firstChild);\n if (script2) {\n head.insertBefore(script2, head.firstChild);\n }\n return close_script;\n};\n// [*] End of lib/trans-jsonp-receiver.js\n\n\n// [*] Including lib/trans-jsonp-polling.js\n/*\n * ***** BEGIN LICENSE BLOCK *****\n * Copyright (c) 2011-2012 VMware, Inc.\n *\n * For the license see COPYING.\n * ***** END LICENSE BLOCK *****\n */\n\n// The simplest and most robust transport, using the well-know cross\n// domain hack - JSONP. This transport is quite inefficient - one\n// mssage could use up to one http request. But at least it works almost\n// everywhere.\n// Known limitations:\n// o you will get a spinning cursor\n// o for Konqueror a dumb timer is needed to detect errors\n\n\nvar JsonPTransport = SockJS['jsonp-polling'] = function(ri, trans_url) {\n utils.polluteGlobalNamespace();\n var that = this;\n that.ri = ri;\n that.trans_url = trans_url;\n that.send_constructor(jsonPGenericSender);\n that._schedule_recv();\n};\n\n// Inheritnace\nJsonPTransport.prototype = new BufferedSender();\n\nJsonPTransport.prototype._schedule_recv = function() {\n var that = this;\n var callback = function(data) {\n that._recv_stop = null;\n if (data) {\n // no data - heartbeat;\n if (!that._is_closing) {\n that.ri._didMessage(data);\n }\n }\n // The message can be a close message, and change is_closing state.\n if (!that._is_closing) {\n that._schedule_recv();\n }\n };\n that._recv_stop = jsonPReceiverWrapper(that.trans_url + '/jsonp',\n jsonPGenericReceiver, callback);\n};\n\nJsonPTransport.enabled = function() {\n return true;\n};\n\nJsonPTransport.need_body = true;\n\n\nJsonPTransport.prototype.doCleanup = function() {\n var that = this;\n that._is_closing = true;\n if (that._recv_stop) {\n that._recv_stop();\n }\n that.ri = that._recv_stop = null;\n that.send_destructor();\n};\n\n\n// Abstract away code that handles global namespace pollution.\nvar jsonPReceiverWrapper = function(url, constructReceiver, user_callback) {\n var id = 'a' + utils.random_string(6);\n var url_id = url + '?c=' + escape(WPrefix + '.' + id);\n // Callback will be called exactly once.\n var callback = function(frame) {\n delete _window[WPrefix][id];\n user_callback(frame);\n };\n\n var close_script = constructReceiver(url_id, callback);\n _window[WPrefix][id] = close_script;\n var stop = function() {\n if (_window[WPrefix][id]) {\n _window[WPrefix][id](utils.closeFrame(1000, \"JSONP user aborted read\"));\n }\n };\n return stop;\n};\n// [*] End of lib/trans-jsonp-polling.js\n\n\n// [*] Including lib/trans-xhr.js\n/*\n * ***** BEGIN LICENSE BLOCK *****\n * Copyright (c) 2011-2012 VMware, Inc.\n *\n * For the license see COPYING.\n * ***** END LICENSE BLOCK *****\n */\n\nvar AjaxBasedTransport = function() {};\nAjaxBasedTransport.prototype = new BufferedSender();\n\nAjaxBasedTransport.prototype.run = function(ri, trans_url,\n url_suffix, Receiver, AjaxObject) {\n var that = this;\n that.ri = ri;\n that.trans_url = trans_url;\n that.send_constructor(createAjaxSender(AjaxObject));\n that.poll = new Polling(ri, Receiver,\n trans_url + url_suffix, AjaxObject);\n};\n\nAjaxBasedTransport.prototype.doCleanup = function() {\n var that = this;\n if (that.poll) {\n that.poll.abort();\n that.poll = null;\n }\n};\n\n// xhr-streaming\nvar XhrStreamingTransport = SockJS['xhr-streaming'] = function(ri, trans_url) {\n this.run(ri, trans_url, '/xhr_streaming', XhrReceiver, utils.XHRCorsObject);\n};\n\nXhrStreamingTransport.prototype = new AjaxBasedTransport();\n\nXhrStreamingTransport.enabled = function() {\n // Support for CORS Ajax aka Ajax2? Opera 12 claims CORS but\n // doesn't do streaming.\n return (_window.XMLHttpRequest &&\n 'withCredentials' in new XMLHttpRequest() &&\n (!/opera/i.test(navigator.userAgent)));\n};\nXhrStreamingTransport.roundTrips = 2; // preflight, ajax\n\n// Safari gets confused when a streaming ajax request is started\n// before onload. This causes the load indicator to spin indefinetely.\nXhrStreamingTransport.need_body = true;\n\n\n// According to:\n// http://stackoverflow.com/questions/1641507/detect-browser-support-for-cross-domain-xmlhttprequests\n// http://hacks.mozilla.org/2009/07/cross-site-xmlhttprequest-with-cors/\n\n\n// xdr-streaming\nvar XdrStreamingTransport = SockJS['xdr-streaming'] = function(ri, trans_url) {\n this.run(ri, trans_url, '/xhr_streaming', XhrReceiver, utils.XDRObject);\n};\n\nXdrStreamingTransport.prototype = new AjaxBasedTransport();\n\nXdrStreamingTransport.enabled = function() {\n return !!_window.XDomainRequest;\n};\nXdrStreamingTransport.roundTrips = 2; // preflight, ajax\n\n\n\n// xhr-polling\nvar XhrPollingTransport = SockJS['xhr-polling'] = function(ri, trans_url) {\n this.run(ri, trans_url, '/xhr', XhrReceiver, utils.XHRCorsObject);\n};\n\nXhrPollingTransport.prototype = new AjaxBasedTransport();\n\nXhrPollingTransport.enabled = XhrStreamingTransport.enabled;\nXhrPollingTransport.roundTrips = 2; // preflight, ajax\n\n\n// xdr-polling\nvar XdrPollingTransport = SockJS['xdr-polling'] = function(ri, trans_url) {\n this.run(ri, trans_url, '/xhr', XhrReceiver, utils.XDRObject);\n};\n\nXdrPollingTransport.prototype = new AjaxBasedTransport();\n\nXdrPollingTransport.enabled = XdrStreamingTransport.enabled;\nXdrPollingTransport.roundTrips = 2; // preflight, ajax\n// [*] End of lib/trans-xhr.js\n\n\n// [*] Including lib/trans-iframe.js\n/*\n * ***** BEGIN LICENSE BLOCK *****\n * Copyright (c) 2011-2012 VMware, Inc.\n *\n * For the license see COPYING.\n * ***** END LICENSE BLOCK *****\n */\n\n// Few cool transports do work only for same-origin. In order to make\n// them working cross-domain we shall use iframe, served form the\n// remote domain. New browsers, have capabilities to communicate with\n// cross domain iframe, using postMessage(). In IE it was implemented\n// from IE 8+, but of course, IE got some details wrong:\n// http://msdn.microsoft.com/en-us/library/cc197015(v=VS.85).aspx\n// http://stevesouders.com/misc/test-postmessage.php\n\nvar IframeTransport = function() {};\n\nIframeTransport.prototype.i_constructor = function(ri, trans_url, base_url) {\n var that = this;\n that.ri = ri;\n that.origin = utils.getOrigin(base_url);\n that.base_url = base_url;\n that.trans_url = trans_url;\n\n var iframe_url = base_url + '/iframe.html';\n if (that.ri._options.devel) {\n iframe_url += '?t=' + (+new Date);\n }\n that.window_id = utils.random_string(8);\n iframe_url += '#' + that.window_id;\n\n that.iframeObj = utils.createIframe(iframe_url, function(r) {\n that.ri._didClose(1006, \"Unable to load an iframe (\" + r + \")\");\n });\n\n that.onmessage_cb = utils.bind(that.onmessage, that);\n utils.attachMessage(that.onmessage_cb);\n};\n\nIframeTransport.prototype.doCleanup = function() {\n var that = this;\n if (that.iframeObj) {\n utils.detachMessage(that.onmessage_cb);\n try {\n // When the iframe is not loaded, IE raises an exception\n // on 'contentWindow'.\n if (that.iframeObj.iframe.contentWindow) {\n that.postMessage('c');\n }\n } catch (x) {}\n that.iframeObj.cleanup();\n that.iframeObj = null;\n that.onmessage_cb = that.iframeObj = null;\n }\n};\n\nIframeTransport.prototype.onmessage = function(e) {\n var that = this;\n if (e.origin !== that.origin) return;\n var window_id = e.data.slice(0, 8);\n var type = e.data.slice(8, 9);\n var data = e.data.slice(9);\n\n if (window_id !== that.window_id) return;\n\n switch(type) {\n case 's':\n that.iframeObj.loaded();\n that.postMessage('s', JSON.stringify([SockJS.version, that.protocol, that.trans_url, that.base_url]));\n break;\n case 't':\n that.ri._didMessage(data);\n break;\n }\n};\n\nIframeTransport.prototype.postMessage = function(type, data) {\n var that = this;\n that.iframeObj.post(that.window_id + type + (data || ''), that.origin);\n};\n\nIframeTransport.prototype.doSend = function (message) {\n this.postMessage('m', message);\n};\n\nIframeTransport.enabled = function() {\n // postMessage misbehaves in konqueror 4.6.5 - the messages are delivered with\n // huge delay, or not at all.\n var konqueror = navigator && navigator.userAgent && navigator.userAgent.indexOf('Konqueror') !== -1;\n return ((typeof _window.postMessage === 'function' ||\n typeof _window.postMessage === 'object') && (!konqueror));\n};\n// [*] End of lib/trans-iframe.js\n\n\n// [*] Including lib/trans-iframe-within.js\n/*\n * ***** BEGIN LICENSE BLOCK *****\n * Copyright (c) 2011-2012 VMware, Inc.\n *\n * For the license see COPYING.\n * ***** END LICENSE BLOCK *****\n */\n\nvar curr_window_id;\n\nvar postMessage = function (type, data) {\n if(parent !== _window) {\n parent.postMessage(curr_window_id + type + (data || ''), '*');\n } else {\n utils.log(\"Can't postMessage, no parent window.\", type, data);\n }\n};\n\nvar FacadeJS = function() {};\nFacadeJS.prototype._didClose = function (code, reason) {\n postMessage('t', utils.closeFrame(code, reason));\n};\nFacadeJS.prototype._didMessage = function (frame) {\n postMessage('t', frame);\n};\nFacadeJS.prototype._doSend = function (data) {\n this._transport.doSend(data);\n};\nFacadeJS.prototype._doCleanup = function () {\n this._transport.doCleanup();\n};\n\nutils.parent_origin = undefined;\n\nSockJS.bootstrap_iframe = function() {\n var facade;\n curr_window_id = _document.location.hash.slice(1);\n var onMessage = function(e) {\n if(e.source !== parent) return;\n if(typeof utils.parent_origin === 'undefined')\n utils.parent_origin = e.origin;\n if (e.origin !== utils.parent_origin) return;\n\n var window_id = e.data.slice(0, 8);\n var type = e.data.slice(8, 9);\n var data = e.data.slice(9);\n if (window_id !== curr_window_id) return;\n switch(type) {\n case 's':\n var p = JSON.parse(data);\n var version = p[0];\n var protocol = p[1];\n var trans_url = p[2];\n var base_url = p[3];\n if (version !== SockJS.version) {\n utils.log(\"Incompatibile SockJS! Main site uses:\" +\n \" \\\"\" + version + \"\\\", the iframe:\" +\n \" \\\"\" + SockJS.version + \"\\\".\");\n }\n if (!utils.flatUrl(trans_url) || !utils.flatUrl(base_url)) {\n utils.log(\"Only basic urls are supported in SockJS\");\n return;\n }\n\n if (!utils.isSameOriginUrl(trans_url) ||\n !utils.isSameOriginUrl(base_url)) {\n utils.log(\"Can't connect to different domain from within an \" +\n \"iframe. (\" + JSON.stringify([_window.location.href, trans_url, base_url]) +\n \")\");\n return;\n }\n facade = new FacadeJS();\n facade._transport = new FacadeJS[protocol](facade, trans_url, base_url);\n break;\n case 'm':\n facade._doSend(data);\n break;\n case 'c':\n if (facade)\n facade._doCleanup();\n facade = null;\n break;\n }\n };\n\n // alert('test ticker');\n // facade = new FacadeJS();\n // facade._transport = new FacadeJS['w-iframe-xhr-polling'](facade, 'http://host.com:9999/ticker/12/basd');\n\n utils.attachMessage(onMessage);\n\n // Start\n postMessage('s');\n};\n// [*] End of lib/trans-iframe-within.js\n\n\n// [*] Including lib/info.js\n/*\n * ***** BEGIN LICENSE BLOCK *****\n * Copyright (c) 2011-2012 VMware, Inc.\n *\n * For the license see COPYING.\n * ***** END LICENSE BLOCK *****\n */\n\nvar InfoReceiver = function(base_url, AjaxObject) {\n var that = this;\n utils.delay(function(){that.doXhr(base_url, AjaxObject);});\n};\n\nInfoReceiver.prototype = new EventEmitter(['finish']);\n\nInfoReceiver.prototype.doXhr = function(base_url, AjaxObject) {\n var that = this;\n var t0 = (new Date()).getTime();\n var xo = new AjaxObject('GET', base_url + '/info');\n\n var tref = utils.delay(8000,\n function(){xo.ontimeout();});\n\n xo.onfinish = function(status, text) {\n clearTimeout(tref);\n tref = null;\n if (status === 200) {\n var rtt = (new Date()).getTime() - t0;\n var info = JSON.parse(text);\n if (typeof info !== 'object') info = {};\n that.emit('finish', info, rtt);\n } else {\n that.emit('finish');\n }\n };\n xo.ontimeout = function() {\n xo.close();\n that.emit('finish');\n };\n};\n\nvar InfoReceiverIframe = function(base_url) {\n var that = this;\n var go = function() {\n var ifr = new IframeTransport();\n ifr.protocol = 'w-iframe-info-receiver';\n var fun = function(r) {\n if (typeof r === 'string' && r.substr(0,1) === 'm') {\n var d = JSON.parse(r.substr(1));\n var info = d[0], rtt = d[1];\n that.emit('finish', info, rtt);\n } else {\n that.emit('finish');\n }\n ifr.doCleanup();\n ifr = null;\n };\n var mock_ri = {\n _options: {},\n _didClose: fun,\n _didMessage: fun\n };\n ifr.i_constructor(mock_ri, base_url, base_url);\n }\n if(!_document.body) {\n utils.attachEvent('load', go);\n } else {\n go();\n }\n};\nInfoReceiverIframe.prototype = new EventEmitter(['finish']);\n\n\nvar InfoReceiverFake = function() {\n // It may not be possible to do cross domain AJAX to get the info\n // data, for example for IE7. But we want to run JSONP, so let's\n // fake the response, with rtt=2s (rto=6s).\n var that = this;\n utils.delay(function() {\n that.emit('finish', {}, 2000);\n });\n};\nInfoReceiverFake.prototype = new EventEmitter(['finish']);\n\nvar createInfoReceiver = function(base_url) {\n if (utils.isSameOriginUrl(base_url)) {\n // If, for some reason, we have SockJS locally - there's no\n // need to start up the complex machinery. Just use ajax.\n return new InfoReceiver(base_url, utils.XHRLocalObject);\n }\n switch (utils.isXHRCorsCapable()) {\n case 1:\n return new InfoReceiver(base_url, utils.XHRCorsObject);\n case 2:\n return new InfoReceiver(base_url, utils.XDRObject);\n case 3:\n // Opera\n return new InfoReceiverIframe(base_url);\n default:\n // IE 7\n return new InfoReceiverFake();\n };\n};\n\n\nvar WInfoReceiverIframe = FacadeJS['w-iframe-info-receiver'] = function(ri, _trans_url, base_url) {\n var ir = new InfoReceiver(base_url, utils.XHRLocalObject);\n ir.onfinish = function(info, rtt) {\n ri._didMessage('m'+JSON.stringify([info, rtt]));\n ri._didClose();\n }\n};\nWInfoReceiverIframe.prototype.doCleanup = function() {};\n// [*] End of lib/info.js\n\n\n// [*] Including lib/trans-iframe-eventsource.js\n/*\n * ***** BEGIN LICENSE BLOCK *****\n * Copyright (c) 2011-2012 VMware, Inc.\n *\n * For the license see COPYING.\n * ***** END LICENSE BLOCK *****\n */\n\nvar EventSourceIframeTransport = SockJS['iframe-eventsource'] = function () {\n var that = this;\n that.protocol = 'w-iframe-eventsource';\n that.i_constructor.apply(that, arguments);\n};\n\nEventSourceIframeTransport.prototype = new IframeTransport();\n\nEventSourceIframeTransport.enabled = function () {\n return ('EventSource' in _window) && IframeTransport.enabled();\n};\n\nEventSourceIframeTransport.need_body = true;\nEventSourceIframeTransport.roundTrips = 3; // html, javascript, eventsource\n\n\n// w-iframe-eventsource\nvar EventSourceTransport = FacadeJS['w-iframe-eventsource'] = function(ri, trans_url) {\n this.run(ri, trans_url, '/eventsource', EventSourceReceiver, utils.XHRLocalObject);\n}\nEventSourceTransport.prototype = new AjaxBasedTransport();\n// [*] End of lib/trans-iframe-eventsource.js\n\n\n// [*] Including lib/trans-iframe-xhr-polling.js\n/*\n * ***** BEGIN LICENSE BLOCK *****\n * Copyright (c) 2011-2012 VMware, Inc.\n *\n * For the license see COPYING.\n * ***** END LICENSE BLOCK *****\n */\n\nvar XhrPollingIframeTransport = SockJS['iframe-xhr-polling'] = function () {\n var that = this;\n that.protocol = 'w-iframe-xhr-polling';\n that.i_constructor.apply(that, arguments);\n};\n\nXhrPollingIframeTransport.prototype = new IframeTransport();\n\nXhrPollingIframeTransport.enabled = function () {\n return _window.XMLHttpRequest && IframeTransport.enabled();\n};\n\nXhrPollingIframeTransport.need_body = true;\nXhrPollingIframeTransport.roundTrips = 3; // html, javascript, xhr\n\n\n// w-iframe-xhr-polling\nvar XhrPollingITransport = FacadeJS['w-iframe-xhr-polling'] = function(ri, trans_url) {\n this.run(ri, trans_url, '/xhr', XhrReceiver, utils.XHRLocalObject);\n};\n\nXhrPollingITransport.prototype = new AjaxBasedTransport();\n// [*] End of lib/trans-iframe-xhr-polling.js\n\n\n// [*] Including lib/trans-iframe-htmlfile.js\n/*\n * ***** BEGIN LICENSE BLOCK *****\n * Copyright (c) 2011-2012 VMware, Inc.\n *\n * For the license see COPYING.\n * ***** END LICENSE BLOCK *****\n */\n\n// This transport generally works in any browser, but will cause a\n// spinning cursor to appear in any browser other than IE.\n// We may test this transport in all browsers - why not, but in\n// production it should be only run in IE.\n\nvar HtmlFileIframeTransport = SockJS['iframe-htmlfile'] = function () {\n var that = this;\n that.protocol = 'w-iframe-htmlfile';\n that.i_constructor.apply(that, arguments);\n};\n\n// Inheritance.\nHtmlFileIframeTransport.prototype = new IframeTransport();\n\nHtmlFileIframeTransport.enabled = function() {\n return IframeTransport.enabled();\n};\n\nHtmlFileIframeTransport.need_body = true;\nHtmlFileIframeTransport.roundTrips = 3; // html, javascript, htmlfile\n\n\n// w-iframe-htmlfile\nvar HtmlFileTransport = FacadeJS['w-iframe-htmlfile'] = function(ri, trans_url) {\n this.run(ri, trans_url, '/htmlfile', HtmlfileReceiver, utils.XHRLocalObject);\n};\nHtmlFileTransport.prototype = new AjaxBasedTransport();\n// [*] End of lib/trans-iframe-htmlfile.js\n\n\n// [*] Including lib/trans-polling.js\n/*\n * ***** BEGIN LICENSE BLOCK *****\n * Copyright (c) 2011-2012 VMware, Inc.\n *\n * For the license see COPYING.\n * ***** END LICENSE BLOCK *****\n */\n\nvar Polling = function(ri, Receiver, recv_url, AjaxObject) {\n var that = this;\n that.ri = ri;\n that.Receiver = Receiver;\n that.recv_url = recv_url;\n that.AjaxObject = AjaxObject;\n that._scheduleRecv();\n};\n\nPolling.prototype._scheduleRecv = function() {\n var that = this;\n var poll = that.poll = new that.Receiver(that.recv_url, that.AjaxObject);\n var msg_counter = 0;\n poll.onmessage = function(e) {\n msg_counter += 1;\n that.ri._didMessage(e.data);\n };\n poll.onclose = function(e) {\n that.poll = poll = poll.onmessage = poll.onclose = null;\n if (!that.poll_is_closing) {\n if (e.reason === 'permanent') {\n that.ri._didClose(1006, 'Polling error (' + e.reason + ')');\n } else {\n that._scheduleRecv();\n }\n }\n };\n};\n\nPolling.prototype.abort = function() {\n var that = this;\n that.poll_is_closing = true;\n if (that.poll) {\n that.poll.abort();\n }\n};\n// [*] End of lib/trans-polling.js\n\n\n// [*] Including lib/trans-receiver-eventsource.js\n/*\n * ***** BEGIN LICENSE BLOCK *****\n * Copyright (c) 2011-2012 VMware, Inc.\n *\n * For the license see COPYING.\n * ***** END LICENSE BLOCK *****\n */\n\nvar EventSourceReceiver = function(url) {\n var that = this;\n var es = new EventSource(url);\n es.onmessage = function(e) {\n that.dispatchEvent(new SimpleEvent('message',\n {'data': unescape(e.data)}));\n };\n that.es_close = es.onerror = function(e, abort_reason) {\n // ES on reconnection has readyState = 0 or 1.\n // on network error it's CLOSED = 2\n var reason = abort_reason ? 'user' :\n (es.readyState !== 2 ? 'network' : 'permanent');\n that.es_close = es.onmessage = es.onerror = null;\n // EventSource reconnects automatically.\n es.close();\n es = null;\n // Safari and chrome < 15 crash if we close window before\n // waiting for ES cleanup. See:\n // https://code.google.com/p/chromium/issues/detail?id=89155\n utils.delay(200, function() {\n that.dispatchEvent(new SimpleEvent('close', {reason: reason}));\n });\n };\n};\n\nEventSourceReceiver.prototype = new REventTarget();\n\nEventSourceReceiver.prototype.abort = function() {\n var that = this;\n if (that.es_close) {\n that.es_close({}, true);\n }\n};\n// [*] End of lib/trans-receiver-eventsource.js\n\n\n// [*] Including lib/trans-receiver-htmlfile.js\n/*\n * ***** BEGIN LICENSE BLOCK *****\n * Copyright (c) 2011-2012 VMware, Inc.\n *\n * For the license see COPYING.\n * ***** END LICENSE BLOCK *****\n */\n\nvar _is_ie_htmlfile_capable;\nvar isIeHtmlfileCapable = function() {\n if (_is_ie_htmlfile_capable === undefined) {\n if ('ActiveXObject' in _window) {\n try {\n _is_ie_htmlfile_capable = !!new ActiveXObject('htmlfile');\n } catch (x) {}\n } else {\n _is_ie_htmlfile_capable = false;\n }\n }\n return _is_ie_htmlfile_capable;\n};\n\n\nvar HtmlfileReceiver = function(url) {\n var that = this;\n utils.polluteGlobalNamespace();\n\n that.id = 'a' + utils.random_string(6, 26);\n url += ((url.indexOf('?') === -1) ? '?' : '&') +\n 'c=' + escape(WPrefix + '.' + that.id);\n\n var constructor = isIeHtmlfileCapable() ?\n utils.createHtmlfile : utils.createIframe;\n\n var iframeObj;\n _window[WPrefix][that.id] = {\n start: function () {\n iframeObj.loaded();\n },\n message: function (data) {\n that.dispatchEvent(new SimpleEvent('message', {'data': data}));\n },\n stop: function () {\n that.iframe_close({}, 'network');\n }\n };\n that.iframe_close = function(e, abort_reason) {\n iframeObj.cleanup();\n that.iframe_close = iframeObj = null;\n delete _window[WPrefix][that.id];\n that.dispatchEvent(new SimpleEvent('close', {reason: abort_reason}));\n };\n iframeObj = constructor(url, function(e) {\n that.iframe_close({}, 'permanent');\n });\n};\n\nHtmlfileReceiver.prototype = new REventTarget();\n\nHtmlfileReceiver.prototype.abort = function() {\n var that = this;\n if (that.iframe_close) {\n that.iframe_close({}, 'user');\n }\n};\n// [*] End of lib/trans-receiver-htmlfile.js\n\n\n// [*] Including lib/trans-receiver-xhr.js\n/*\n * ***** BEGIN LICENSE BLOCK *****\n * Copyright (c) 2011-2012 VMware, Inc.\n *\n * For the license see COPYING.\n * ***** END LICENSE BLOCK *****\n */\n\nvar XhrReceiver = function(url, AjaxObject) {\n var that = this;\n var buf_pos = 0;\n\n that.xo = new AjaxObject('POST', url, null);\n that.xo.onchunk = function(status, text) {\n if (status !== 200) return;\n while (1) {\n var buf = text.slice(buf_pos);\n var p = buf.indexOf('\\n');\n if (p === -1) break;\n buf_pos += p+1;\n var msg = buf.slice(0, p);\n that.dispatchEvent(new SimpleEvent('message', {data: msg}));\n }\n };\n that.xo.onfinish = function(status, text) {\n that.xo.onchunk(status, text);\n that.xo = null;\n var reason = status === 200 ? 'network' : 'permanent';\n that.dispatchEvent(new SimpleEvent('close', {reason: reason}));\n }\n};\n\nXhrReceiver.prototype = new REventTarget();\n\nXhrReceiver.prototype.abort = function() {\n var that = this;\n if (that.xo) {\n that.xo.close();\n that.dispatchEvent(new SimpleEvent('close', {reason: 'user'}));\n that.xo = null;\n }\n};\n// [*] End of lib/trans-receiver-xhr.js\n\n\n// [*] Including lib/test-hooks.js\n/*\n * ***** BEGIN LICENSE BLOCK *****\n * Copyright (c) 2011-2012 VMware, Inc.\n *\n * For the license see COPYING.\n * ***** END LICENSE BLOCK *****\n */\n\n// For testing\nSockJS.getUtils = function(){\n return utils;\n};\n\nSockJS.getIframeTransport = function(){\n return IframeTransport;\n};\n// [*] End of lib/test-hooks.js\n\n return SockJS;\n })();\nif ('_sockjs_onload' in window) setTimeout(_sockjs_onload, 1);\n\n// AMD compliance\nif (typeof define === 'function' && define.amd) {\n define('sockjs', [], function(){return SockJS;});\n}\n\nif (typeof module === 'object' && module && module.exports) {\n module.exports = SockJS;\n}\n// [*] End of lib/index.js\n\n// [*] End of lib/all.js\n\n\n//@ sourceURL=/node_modules/live-reload/node_modules/shoe/node_modules/sockjs-client/sockjs.js"));
require.define("/example/demo/index.js",Function(['require','module','exports','__dirname','__filename','process'],"var html = require(\"./snippet\")\n , TextNode = require(\"../../index\")\n , Fragment = require(\"fragment\")\n , curry = require(\"ap\").curry\n\nvar update = curry(function (name, delta, field) {\n delta.set(name, field.value)\n})\n\nmodule.exports = Widget\n\nfunction Widget() {\n var elem = Fragment(html)\n , foo = elem.querySelector(\"#foo\")\n , bar = elem.querySelector(\"#bar\")\n , delta = TextNode(elem)\n\n foo.addEventListener(\"keyup\", update(\"foo\", delta, foo))\n bar.addEventListener(\"keyup\", update(\"bar\", delta, bar))\n\n return {\n appendTo: appendTo\n }\n\n function appendTo(parent) {\n parent.appendChild(elem)\n }\n}\n//@ sourceURL=/example/demo/index.js"));
require.define("/example/demo/snippet.html",Function(['require','module','exports','__dirname','__filename','process'],"module.exports = '<div>\\n <div class=\"red\" data-foo></div>\\n <div class=\"blue\" data-bar></div>\\n</div>\\n<fieldset>\\n <legend>Change items</legend>\\n <input id=\"foo\" autocomplete=\"foo\"/>\\n <input id=\"bar\" autocomplete=\"bar\"/>\\n</fieldset>'\n//@ sourceURL=/example/demo/snippet.html"));
require.define("/package.json",Function(['require','module','exports','__dirname','__filename','process'],"module.exports = {\"main\":\"index\"}\n//@ sourceURL=/package.json"));
require.define("/index.js",Function(['require','module','exports','__dirname','__filename','process'],"var walk = require(\"dom-walk\")\n , forEach = require(\"iterators\").forEachSync\n , Delta = require(\"delta-stream\")\n , Node = window.Node\n\nmodule.exports = TextNode\n\nfunction TextNode(elem) {\n var nodes = {}\n , delta = Delta()\n\n delta.on(\"change\", updateNodes)\n\n walk([elem], addToSet)\n\n return delta\n\n function addToSet(node) {\n if (!node.dataset) {\n return\n }\n\n forEach(node.dataset, addNodeToSet, node)\n }\n\n function addNodeToSet(_, key) {\n var node = this\n\n if (!nodes[key]) {\n nodes[key] = []\n }\n\n nodes[key].push(node)\n }\n\n function updateNodes(key, value) {\n if (!nodes[key]) {\n return\n }\n\n forEach(nodes[key], updateNode, value)\n }\n\n function updateNode(elem) {\n var first = elem.firstChild\n , value = this\n\n if (first && first.nodeType === Node.TEXT_NODE &&\n elem.childNodes.length === 1\n ) {\n return first.data = value\n }\n\n elem.textContent = value\n }\n}\n//@ sourceURL=/index.js"));
require.define("/node_modules/dom-walk/package.json",Function(['require','module','exports','__dirname','__filename','process'],"module.exports = {\"main\":\"index\"}\n//@ sourceURL=/node_modules/dom-walk/package.json"));
require.define("/node_modules/dom-walk/index.js",Function(['require','module','exports','__dirname','__filename','process'],"var slice = Array.prototype.slice\n\nmodule.exports = iterativelyWalk\n\nfunction iterativelyWalk(nodes, cb) {\n nodes = slice.call(nodes)\n\n while(nodes.length) {\n var node = nodes.shift(),\n ret = cb(node)\n\n if (ret) {\n return ret\n }\n\n if (node.childNodes.length) {\n nodes = slice.call(node.childNodes).concat(nodes)\n }\n }\n}\n//@ sourceURL=/node_modules/dom-walk/index.js"));
require.define("/node_modules/iterators/package.json",Function(['require','module','exports','__dirname','__filename','process'],"module.exports = {\"main\":\"index\"}\n//@ sourceURL=/node_modules/iterators/package.json"));
require.define("/node_modules/iterators/index.js",Function(['require','module','exports','__dirname','__filename','process'],"module.exports = {\n // sync\n forEachSync: require(\"./lib/sync/forEach\")\n , filterSync: require(\"./lib/sync/filter\")\n , mapSync: require(\"./lib/sync/map\")\n , reduceSync: require(\"./lib/sync/reduce\")\n , reduceRightSync: require(\"./lib/sync/reduceRight\")\n , everySync: require(\"./lib/sync/every\")\n , someSync: require(\"./lib/sync/some\")\n // async\n , forEach: require(\"./lib/async/forEach\")\n , filter: require(\"./lib/async/filter\")\n , map: require(\"./lib/async/map\")\n , reduce: require(\"./lib/async/reduce\")\n , reduceRight: require(\"./lib/async/reduceRight\")\n , every: require(\"./lib/async/every\")\n , some: require(\"./lib/async/some\")\n}\n//@ sourceURL=/node_modules/iterators/index.js"));
require.define("/node_modules/iterators/lib/sync/forEach.js",Function(['require','module','exports','__dirname','__filename','process'],"module.exports = forEach\n\nfunction forEach(list, iterator, context) {\n var keys = Object.keys(list)\n\n if (arguments.length < 3) {\n context = this\n }\n\n for (var i = 0, len = keys.length; i < len; i++) {\n var key = keys[i]\n , value = list[key]\n \n iterator.call(context, value, key, list)\n }\n}\n//@ sourceURL=/node_modules/iterators/lib/sync/forEach.js"));
require.define("/node_modules/iterators/lib/sync/filter.js",Function(['require','module','exports','__dirname','__filename','process'],"module.exports = filter\n\nfunction filter(list, iterator, context) {\n var returnValue = Array.isArray(list) ? [] : {}\n , keys = Object.keys(list)\n\n if (arguments.length < 3) {\n context = this\n }\n\n for (var i = 0, len = keys.length; i < len; i++) {\n var key = keys[i]\n , value = list[key]\n , keepValue = iterator.call(context, value, key, list)\n\n if (keepValue) {\n if (Array.isArray(returnValue)) {\n returnValue.push(value)\n } else {\n returnValue[key] = value\n }\n }\n }\n\n return returnValue\n}\n//@ sourceURL=/node_modules/iterators/lib/sync/filter.js"));
require.define("/node_modules/iterators/lib/sync/map.js",Function(['require','module','exports','__dirname','__filename','process'],"module.exports = map\n\nfunction map(list, iterator, context) {\n var returnValue = Array.isArray(list) ? [] : {}\n , keys = Object.keys(list)\n\n if (arguments.length < 3) {\n context = this\n }\n\n for (var i = 0, len = keys.length; i < len; i++) {\n var key = keys[i]\n , value = list[key]\n , newValue = iterator.call(context, value, key, list)\n\n returnValue[key] = newValue\n }\n\n return returnValue\n}\n//@ sourceURL=/node_modules/iterators/lib/sync/map.js"));
require.define("/node_modules/iterators/lib/sync/reduce.js",Function(['require','module','exports','__dirname','__filename','process'],"module.exports = reduce\n\nfunction reduce(list, iterator, context, accumulator) {\n var keys = Object.keys(list)\n , i = 0\n\n if (arguments.length === 2) {\n context = this\n accumulator = list[0]\n i = 1\n } else if (arguments.length === 3) {\n accumulator = context\n context = this\n }\n\n for (var len = keys.length; i < len; i++) {\n var key = keys[i]\n , value = list[key]\n\n accumulator = iterator.call(context, accumulator, value, key, list)\n }\n\n return accumulator\n}\n//@ sourceURL=/node_modules/iterators/lib/sync/reduce.js"));
require.define("/node_modules/iterators/lib/sync/reduceRight.js",Function(['require','module','exports','__dirname','__filename','process'],"module.exports = reduceRight\n\nfunction reduceRight(list, iterator, context, accumulator) {\n var keys = Object.keys(list)\n , len = keys.length\n , i = len - 1\n\n if (arguments.length === 2) {\n context = this\n accumulator = list[i]\n i--\n } else if (arguments.length === 3) {\n accumulator = context\n context = this\n }\n\n for (; i >= 0; i--) {\n var key = keys[i]\n , value = list[key]\n\n accumulator = iterator.call(context, accumulator, value, key, list)\n }\n\n return accumulator\n}\n//@ sourceURL=/node_modules/iterators/lib/sync/reduceRight.js"));
require.define("/node_modules/iterators/lib/sync/every.js",Function(['require','module','exports','__dirname','__filename','process'],"module.exports = every\n\nfunction every(list, iterator, context) {\n var keys = Object.keys(list)\n , result\n\n if (arguments.length < 3) {\n context = this\n }\n\n for (var i = 0, len = keys.length; i < len; i++) {\n var key = keys[i]\n , value = list[key]\n \n result = iterator.call(context, value, key, list)\n\n if (!result) {\n return result\n }\n }\n\n return result\n}\n//@ sourceURL=/node_modules/iterators/lib/sync/every.js"));
require.define("/node_modules/iterators/lib/sync/some.js",Function(['require','module','exports','__dirname','__filename','process'],"module.exports = some\n\nfunction some(list, iterator, context) {\n var keys = Object.keys(list)\n , result = false\n\n if (arguments.length < 3) {\n context = this\n }\n\n for (var i = 0, len = keys.length; i < len; i++) {\n var key = keys[i]\n , value = list[key]\n \n result = iterator.call(context, value, key, list)\n\n if (result) {\n return result\n }\n }\n\n return result\n}\n//@ sourceURL=/node_modules/iterators/lib/sync/some.js"));
require.define("/node_modules/iterators/lib/async/forEach.js",Function(['require','module','exports','__dirname','__filename','process'],"module.exports = forEach\n\nfunction forEach(list, iterator, context, callback) {\n var keys = Object.keys(list)\n , count = keys.length\n\n if (typeof context === \"function\") {\n callback = context\n context = this\n }\n\n for (var i = 0, len = keys.length; i < len; i++) {\n var key = keys[i]\n , value = list[key]\n \n invokeIterator(iterator, next, context, value, key, list)\n }\n\n function next(err) {\n if (err) {\n return callback && callback(err)\n }\n\n if (--count === 0) {\n callback && callback(null)\n }\n }\n}\n\nfunction invokeIterator(iterator, done, context, value, key, list) {\n var length = iterator.length\n\n if (length === 1) {\n iterator.call(context, done)\n } else if (length === 2) {\n iterator.call(context, value, done)\n } else if (length === 3) {\n iterator.call(context, value, key, done)\n } else {\n iterator.call(context, value, key, list, done)\n }\n}\n//@ sourceURL=/node_modules/iterators/lib/async/forEach.js"));
require.define("/node_modules/iterators/lib/async/filter.js",Function(['require','module','exports','__dirname','__filename','process'],"var partial = require(\"ap\").partial\n\nmodule.exports = filter\n\nfunction filter(list, iterator, context, callback) {\n var keys = Object.keys(list)\n , returnValue = Array.isArray(list) ? [] : {}\n , count = keys.length\n\n if (typeof context === \"function\") {\n callback = context\n context = this\n }\n\n for (var i = 0, len = keys.length; i < len; i++) {\n var key = keys[i]\n , value = list[key]\n \n invokeIterator(iterator,\n partial(next, value, key), context, value, key, list)\n }\n\n function next(value, key, err, keepValue) {\n if (err) {\n return callback && callback(err)\n }\n\n if (keepValue) {\n if (Array.isArray(returnValue)) {\n returnValue.push(value)\n } else {\n returnValue[key] = value\n }\n }\n\n if (--count === 0) {\n callback && callback(null, returnValue)\n }\n }\n}\n\nfunction invokeIterator(iterator, done, context, value, key, list) {\n var length = iterator.length\n\n if (length === 1) {\n iterator.call(context, done)\n } else if (length === 2) {\n iterator.call(context, value, done)\n } else if (length === 3) {\n iterator.call(context, value, key, done)\n } else {\n iterator.call(context, value, key, list, done)\n }\n}\n//@ sourceURL=/node_modules/iterators/lib/async/filter.js"));
require.define("/node_modules/ap/package.json",Function(['require','module','exports','__dirname','__filename','process'],"module.exports = {\"main\":\"./index.js\"}\n//@ sourceURL=/node_modules/ap/package.json"));
require.define("/node_modules/ap/index.js",Function(['require','module','exports','__dirname','__filename','process'],"exports = module.exports = ap;\nfunction ap (args, fn) {\n return function () {\n return fn.apply(this, args.concat.apply(args, arguments));\n };\n}\n\nexports.pa = pa;\nfunction pa (args, fn) {\n return function () {\n return fn.apply(this, [].slice.call(arguments).concat(args));\n };\n}\n\nexports.apa = apa;\nfunction apa (left, right, fn) {\n return function () {\n return fn.apply(this,\n left.concat.apply(left, arguments).concat(right)\n );\n };\n}\n\nexports.partial = partial;\nfunction partial (fn) {\n var args = [].slice.call(arguments, 1);\n return ap(args, fn);\n}\n\nexports.partialRight = partialRight;\nfunction partialRight (fn) {\n var args = [].slice.call(arguments, 1);\n return pa(args, fn);\n}\n\nexports.curry = curry;\nfunction curry (fn) {\n return partial(partial, fn);\n}\n\nexports.curryRight = function curryRight (fn) {\n return partial(partialRight, fn);\n}\n\n//@ sourceURL=/node_modules/ap/index.js"));
require.define("/node_modules/iterators/lib/async/map.js",Function(['require','module','exports','__dirname','__filename','process'],"var partial = require(\"ap\").partial\n\nmodule.exports = map\n\nfunction map(list, iterator, context, callback) {\n var keys = Object.keys(list)\n , returnValue = Array.isArray(list) ? [] : {}\n , count = keys.length\n\n if (typeof context === \"function\") {\n callback = context\n context = this\n }\n\n for (var i = 0, len = keys.length; i < len; i++) {\n var key = keys[i]\n , value = list[key]\n \n invokeIterator(iterator,\n partial(next, key), context, value, key, list)\n }\n\n function next(key, err, newValue) {\n if (err) {\n return callback && callback(err)\n }\n\n returnValue[key] = newValue\n\n if (--count === 0) {\n callback && callback(null, returnValue)\n }\n }\n}\n\nfunction invokeIterator(iterator, done, context, value, key, list) {\n var length = iterator.length\n\n if (length === 1) {\n iterator.call(context, done)\n } else if (length === 2) {\n iterator.call(context, value, done)\n } else if (length === 3) {\n iterator.call(context, value, key, done)\n } else {\n iterator.call(context, value, key, list, done)\n }\n}\n//@ sourceURL=/node_modules/iterators/lib/async/map.js"));
require.define("/node_modules/iterators/lib/async/reduce.js",Function(['require','module','exports','__dirname','__filename','process'],"module.exports = forEach\n\nfunction forEach(list, iterator, context, accumulator, callback) {\n var keys = Object.keys(list)\n , i = 0\n , count = keys.length\n\n if (arguments.length === 3) {\n callback = context\n context = this\n accumulator = list[0]\n i = 1\n count--\n } else if (arguments.length === 4) {\n callback = accumulator\n accumulator = context\n context = this\n }\n\n for (var len = keys.length; i < len; i++) {\n var key = keys[i]\n , value = list[key]\n \n invokeIterator(iterator, next, context, accumulator, value, key, list)\n }\n\n function next(err, value) {\n if (err) {\n return callback && callback(err)\n }\n\n accumulator = value\n\n if (--count === 0) {\n callback && callback(null, accumulator)\n }\n }\n}\n\nfunction invokeIterator(iterator, done, context, acc, value, key, list) {\n var length = iterator.length\n\n if (length === 1) {\n iterator.call(context, done)\n } else if (length === 2) {\n iterator.call(context, acc, done)\n } else if (length === 3) {\n iterator.call(context, acc, value, done)\n } else if (length === 4) {\n iterator.call(context, acc, value, key, done)\n } else {\n iterator.call(context, acc, value, key, list, done)\n }\n}\n//@ sourceURL=/node_modules/iterators/lib/async/reduce.js"));
require.define("/node_modules/iterators/lib/async/reduceRight.js",Function(['require','module','exports','__dirname','__filename','process'],"module.exports = forEach\n\nfunction forEach(list, iterator, context, accumulator, callback) {\n var keys = Object.keys(list)\n , len = keys.length\n , i = len - 1\n , count = keys.length\n\n if (arguments.length === 3) {\n callback = context\n context = this\n accumulator = list[i]\n i--\n count--\n } else if (arguments.length === 4) {\n callback = accumulator\n accumulator = context\n context = this\n }\n\n for (; i >= 0; i--) {\n var key = keys[i]\n , value = list[key]\n \n invokeIterator(iterator, next, context, accumulator, value, key, list)\n }\n\n function next(err, value) {\n if (err) {\n return callback && callback(err)\n }\n\n accumulator = value\n\n if (--count === 0) {\n callback && callback(null, accumulator)\n }\n }\n}\n\nfunction invokeIterator(iterator, done, context, acc, value, key, list) {\n var length = iterator.length\n\n if (length === 1) {\n iterator.call(context, done)\n } else if (length === 2) {\n iterator.call(context, acc, done)\n } else if (length === 3) {\n iterator.call(context, acc, value, done)\n } else if (length === 4) {\n iterator.call(context, acc, value, key, done)\n } else {\n iterator.call(context, acc, value, key, list, done)\n }\n}\n//@ sourceURL=/node_modules/iterators/lib/async/reduceRight.js"));
require.define("/node_modules/iterators/lib/async/every.js",Function(['require','module','exports','__dirname','__filename','process'],"module.exports = forEach\n\nfunction forEach(list, iterator, context, callback) {\n var keys = Object.keys(list)\n , count = keys.length\n\n if (typeof context === \"function\") {\n callback = context\n context = this\n }\n\n for (var i = 0, len = keys.length; i < len; i++) {\n var key = keys[i]\n , value = list[key]\n \n invokeIterator(iterator, next, context, value, key, list)\n }\n\n function next(err, result) {\n if (err) {\n return callback && callback(err)\n }\n\n if (!result) {\n return callback && callback(null, result)\n }\n\n if (--count === 0) {\n callback && callback(null, result)\n }\n }\n}\n\nfunction invokeIterator(iterator, done, context, value, key, list) {\n var length = iterator.length\n\n if (length === 1) {\n iterator.call(context, done)\n } else if (length === 2) {\n iterator.call(context, value, done)\n } else if (length === 3) {\n iterator.call(context, value, key, done)\n } else {\n iterator.call(context, value, key, list, done)\n }\n}\n//@ sourceURL=/node_modules/iterators/lib/async/every.js"));
require.define("/node_modules/iterators/lib/async/some.js",Function(['require','module','exports','__dirname','__filename','process'],"module.exports = forEach\n\nfunction forEach(list, iterator, context, callback) {\n var keys = Object.keys(list)\n , count = keys.length\n\n if (typeof context === \"function\") {\n callback = context\n context = this\n }\n\n for (var i = 0, len = keys.length; i < len; i++) {\n var key = keys[i]\n , value = list[key]\n \n invokeIterator(iterator, next, context, value, key, list)\n }\n\n function next(err, result) {\n if (err) {\n return callback && callback(err)\n }\n\n if (result) {\n return callback && callback(null, result)\n }\n\n if (--count === 0) {\n callback && callback(null, result)\n }\n }\n}\n\nfunction invokeIterator(iterator, done, context, value, key, list) {\n var length = iterator.length\n\n if (length === 1) {\n iterator.call(context, done)\n } else if (length === 2) {\n iterator.call(context, value, done)\n } else if (length === 3) {\n iterator.call(context, value, key, done)\n } else {\n iterator.call(context, value, key, list, done)\n }\n}\n//@ sourceURL=/node_modules/iterators/lib/async/some.js"));
require.define("/node_modules/delta-stream/package.json",Function(['require','module','exports','__dirname','__filename','process'],"module.exports = {\"main\":\"index\"}\n//@ sourceURL=/node_modules/delta-stream/package.json"));
require.define("/node_modules/delta-stream/index.js",Function(['require','module','exports','__dirname','__filename','process'],"var Scuttlebutt = require(\"scuttlebutt\")\n , updateIsRecent = Scuttlebutt.updateIsRecent\n , EventEmitter = require(\"events\").EventEmitter\n , iterators = require(\"iterators\")\n , reduce = iterators.reduceSync\n , forEach = iterators.forEachSync\n\nmodule.exports = Delta\n\n/*\n Protocol is [key, value, source, timestamp]\n*/\nfunction Delta(id, silent) {\n var scutt = Scuttlebutt(id)\n , delta = new EventEmitter()\n , updates = {}\n , state = { id: scutt.id }\n , log = silent ? noop : error\n\n id = delta.id = scutt.id\n\n scutt.applyUpdate = applyUpdate\n // history is a global variable -.-\n scutt.history = $history\n\n delta.validate = validate\n delta.set = set\n delta.get = get\n delta.has = has\n // stupid tokens\n delta.delete = $delete\n delta.toJSON = toJSON\n delta.createStream = scutt.createStream.bind(scutt)\n\n return delta\n\n function applyUpdate(update) {\n var key = update[0]\n , value = update[1]\n , recentUpdate = updates[key]\n\n // If the most recent update for that key is newer then the incoming\n // update. Then ignore it\n if (recentUpdate && recentUpdate[2] > update[2]) {\n return\n }\n\n updates[key] = update\n\n if (value === undefined) {\n delete state[key]\n } else {\n state[key] = value\n }\n\n delta.emit(\"change\", key, value)\n delta.emit(\"change:\" + key, value)\n\n return true\n }\n\n function $history(sources) {\n return reduce(updates, isRecent, sources, []).sort(byTimestamp)\n }\n\n function validate(changes) {\n try {\n delta.emit(\"validate\", changes)\n return true\n } catch (e) {\n log(\"[DELTA-STREAM]: validation\", e.message, e)\n return false\n }\n }\n\n function set(key, value) {\n if (key === \"id\" && value !== id) {\n console.log(\"invalid\", key, value)\n throw Error(\"id cannot be changed\")\n }\n\n if (typeof key === \"string\") {\n scutt.localUpdate(key, value)\n } else {\n forEach(key, setKeyValue)\n }\n }\n\n function setKeyValue(value, key) {\n set(key, value)\n }\n\n function get(key) {\n return state[key]\n }\n\n function has(key) {\n return key in state\n }\n\n function $delete(key) {\n set(key, undefined)\n }\n\n function toJSON() {\n return state\n }\n}\n\nfunction isRecent(acc, update) {\n var sources = this\n\n if (updateIsRecent(update, sources)) {\n acc.push(update)\n }\n\n return acc\n}\n\nfunction byTimestamp(a, b) {\n return a[2] - b[2]\n}\n\nfunction noop() {}\n\nfunction error() {\n console.error.apply(console, arguments)\n}\n//@ sourceURL=/node_modules/delta-stream/index.js"));
require.define("/node_modules/delta-stream/node_modules/scuttlebutt/package.json",Function(['require','module','exports','__dirname','__filename','process'],"module.exports = {}\n//@ sourceURL=/node_modules/delta-stream/node_modules/scuttlebutt/package.json"));
require.define("/node_modules/delta-stream/node_modules/scuttlebutt/index.js",Function(['require','module','exports','__dirname','__filename','process'],"//really simple data replication.\n\nvar EventEmitter = require('events').EventEmitter\nvar i = require('iterate')\nvar duplex = require('duplex')\nvar inherits = require('util').inherits\nvar serializer = require('stream-serializer')\nvar u = require('./util')\nvar ReadableStream = require('readable-stream')\n\nexports = \nmodule.exports = Scuttlebutt\n\nexports.createID = u.createID\nexports.updateIsRecent = u.filter\nexports.filter = u.filter\nexports.timestamp = u.timestamp\n\nfunction dutyOfSubclass() {\n throw new Error('method must be implemented by subclass')\n}\n\nfunction validate (data) {\n //must be an 4 element array\n //string, *, string, number\n //log a message and ignore if invalid.\n function error () {\n console.error('invalid update', data)\n }\n var key = data[0], ts = data[2], source = data[3]\n\n /*console.log(!Array.isArray(data) \n , data.length !== 4 \n , 'string' !== typeof key\n , 'string' !== typeof source\n , 'number' !== typeof ts\n )*/\n\n if( !Array.isArray(data) \n || data.length !== 4 \n || 'string' !== typeof key\n || 'string' !== typeof source\n || 'number' !== typeof ts\n ) \n return error(), false\n\n return true\n}\n\ninherits (Scuttlebutt, EventEmitter)\n\nfunction Scuttlebutt (id) {\n if(!(this instanceof Scuttlebutt)) return new Scuttlebutt(id)\n this.sources = {}\n this.id = id = id || u.createID()\n}\n\nvar sb = Scuttlebutt.prototype\n\nvar emit = EventEmitter.prototype.emit\n\nsb.applyUpdate = dutyOfSubclass\nsb.history = dutyOfSubclass\n\nsb.localUpdate = function (key, value) {\n this._update([key, value, u.timestamp(), this.id])\n return this\n}\n\n//checks whether this update is valid.\n\nsb._update = function (update) {\n var ts = update[2]\n var source = update[3]\n\n //if this message is old for it's source,\n //ignore it. it's out of order.\n //each node must emit it's changes in order!\n \n var latest = this.sources[source]\n if(latest && latest >= ts)\n return emit.call(this, 'old_data', update), false\n\n this.sources[source] = ts\n\n //check if this message is older than\n //the value we already have.\n //do nothing if so\n //emit an 'old-data' event because i'll want to track how many\n //unnecessary messages are sent.\n if(this.applyUpdate(update)) {\n emit.call(this, '_update', update)\n return true\n }\n\n //key, value, timestamp, source\n return false\n}\n\nsb.createStream = function (opts) {\n var self = this\n //the sources for the remote end.\n var sources = {}, other\n var d = duplex()\n var outer = serializer(opts && opts.wrapper)(d)\n outer.inner = d\n d\n .on('write', function (data) {\n //if it's an array, it's an update.\n //if it's an object, it's a scuttlebut digest.\n if(Array.isArray(data)) {\n if(validate(data))\n return self._update(data)\n }\n else if('object' === typeof data && data) {\n //when the digest is recieved from the other end,\n //send the history.\n //merge with the current list of sources.\n sources = data\n i.each(self.history(sources), d.emitData.bind(d))\n outer.emit('sync')\n }\n }).on('ended', function () { d.emitEnd() })\n .on('close', function () {\n self.removeListener('data', onUpdate)\n })\n\n function onUpdate (update) { //key, value, source, ts) {\n if(!u.filter(update, sources))\n return\n\n //if I put this after source[source]= ... it breaks tests\n d.emitData(update)\n\n //really, this should happen before emitting.\n var ts = update[2]\n var source = update[3]\n sources[source] = ts\n }\n d.emitData(self.sources)\n self.on('_update', onUpdate)\n return outer\n}\n\n//createReadStream -- for persisting.\n\nsb.createReadStream = function (opts) {\n opts = opts || {}\n\n //write this.id\n //then write the histroy.\n //then, if opts.tail\n //listen for updates, else emit 'end'\n\n var out = this.history()\n out.unshift(this.id)\n\n var wrapper = ({\n json: function (e) { return JSON.stringify(e) + '\\n' },\n raw: function (e) { return e }\n }) [opts.wrapper || 'json']\n\n var rs = new ReadableStream()\n rs.read = function () {\n var data = out.shift()\n console.log('>>', data)\n if(!data && !opts.tail)\n return this.emit('end'), null\n \n return wrapper(data)\n }\n\n if(opts.tail) {\n this.on('_update', function (update) {\n out.push(update)\n rs.emit('readable')\n })\n }\n\n return rs\n}\n\nsb.createWriteStream = function (opts) {\n opts = opts || {}\n var Stream = require('stream')\n var ws = new Stream()\n var self = this, first = true\n ws.writable = true\n ws.write = function (data) {\n if(!this.writable) return\n if('string' === typeof data)\n return self.id = data, true\n first = false\n self.applyUpdate(data)\n return true\n }\n ws.end = function () {\n this.writable = false\n self.sync = true\n self.emit('sync')\n }\n ws.destroy = function () {\n this.writable = false\n this.emit('close')\n }\n\n return serializer(opts.wrapper)(ws)\n}\n\n//@ sourceURL=/node_modules/delta-stream/node_modules/scuttlebutt/index.js"));
require.define("/node_modules/delta-stream/node_modules/scuttlebutt/node_modules/iterate/package.json",Function(['require','module','exports','__dirname','__filename','process'],"module.exports = {\"main\":\"index.js\"}\n//@ sourceURL=/node_modules/delta-stream/node_modules/scuttlebutt/node_modules/iterate/package.json"));
require.define("/node_modules/delta-stream/node_modules/scuttlebutt/node_modules/iterate/index.js",Function(['require','module','exports','__dirname','__filename','process'],"\n//\n// adds all the fields from obj2 onto obj1\n//\n\nvar each = exports.each = function (obj,iterator){\n var keys = Object.keys(obj)\n keys.forEach(function (key){\n iterator(obj[key],key,obj) \n })\n}\n\nvar RX = /sadf/.constructor\nfunction rx (iterator ){\n return iterator instanceof RX ? function (str) { \n var m = iterator.exec(str)\n return m && (m[1] ? m[1] : m[0]) \n } : iterator\n}\n\nvar times = exports.times = function () {\n var args = [].slice.call(arguments)\n , iterator = rx(args.pop())\n , m = args.pop()\n , i = args.shift()\n , j = args.shift()\n , diff, dir\n , a = []\n \n i = 'number' === typeof i ? i : 1\n diff = j ? j - i : 1\n dir = i < m\n if(m == i)\n throw new Error('steps cannot be the same: '+m+', '+i)\n for (; dir ? i <= m : m <= i; i += diff)\n a.push(iterator(i))\n return a\n}\n\nvar map = exports.map = function (obj, iterator){\n iterator = rx(iterator)\n if(Array.isArray(obj))\n return obj.map(iterator)\n if('number' === typeof obj)\n return times.apply(null, [].slice.call(arguments)) \n //return if null ? \n var keys = Object.keys(obj)\n , r = {}\n keys.forEach(function (key){\n r[key] = iterator(obj[key],key,obj) \n })\n return r\n}\n\nvar findReturn = exports.findReturn = function (obj, iterator) {\n iterator = rx(iterator)\n if(obj == null)\n return\n var keys = Object.keys(obj)\n , l = keys.length\n for (var i = 0; i < l; i ++) {\n var key = keys[i]\n , value = obj[key]\n var r = iterator(value, key)\n if(r) return r\n }\n}\n\nvar find = exports.find = function (obj, iterator) { \n iterator = rx(iterator)\n return findReturn (obj, function (v, k) {\n var r = iterator(v, k)\n if(r) return v\n })\n}\n\nvar findKey = exports.findKey = function (obj, iterator) { \n iterator = rx(iterator)\n return findReturn (obj, function (v, k) {\n var r = iterator(v, k)\n if(r) return k\n })\n}\n\nvar filter = exports.filter = function (obj, iterator){\n iterator = rx (iterator)\n\n if(Array.isArray(obj))\n return obj.filter(iterator)\n \n var keys = Object.keys(obj)\n , r = {}\n keys.forEach(function (key){\n var v\n if(iterator(v = obj[key],key,obj))\n r[key] = v\n })\n return r \n}\n\nvar mapKeys = exports.mapKeys = function (ary, iterator){\n var r = {}\n iterator = rx(iterator)\n each(ary, function (v,k){\n r[v] = iterator(v,k)\n })\n return r\n}\n\n\nvar mapToArray = exports.mapToArray = function (ary, iterator){\n var r = []\n iterator = rx(iterator)\n each(ary, function (v,k){\n r.push(iterator(v,k))\n })\n return r\n}\n\nvar path = exports.path = function (object, path) {\n\n for (var i in path) {\n if(object == null) return undefined\n var key = path[i]\n object = object[key]\n }\n return object\n}\n\n/*\nNOTE: naive implementation. \n`match` must not contain circular references.\n*/\n\nvar setPath = exports.setPath = function (object, path, value) {\n\n for (var i in path) {\n var key = path[i]\n if(object[key] == null) object[key] = ( \n i + 1 == path.length ? value : {}\n )\n object = object[key]\n }\n}\n\n\n//@ sourceURL=/node_modules/delta-stream/node_modules/scuttlebutt/node_modules/iterate/index.js"));
require.define("/node_modules/delta-stream/node_modules/scuttlebutt/node_modules/duplex/package.json",Function(['require','module','exports','__dirname','__filename','process'],"module.exports = {}\n//@ sourceURL=/node_modules/delta-stream/node_modules/scuttlebutt/node_modules/duplex/package.json"));
require.define("/node_modules/delta-stream/node_modules/scuttlebutt/node_modules/duplex/index.js",Function(['require','module','exports','__dirname','__filename','process'],"var Stream = require('stream')\n\n/*\n lemmy think...\n\n pause() and resume() must prevent data from being emitted.\n\n write controls 'drain', and the return value.\n\n idea:\n\n write -> emit('write')\n\n on('pause') --> writePause = true\n if(writePause) --> wirte() == false\n on('drain') --> writePause = false\n\n pause() -> paused = true\n resume() -> paused = false, drain()\n sendData(data) -> push onto buffer or emit.\n sendEnd() -> queue end after buffer clears. \n*/\n\nmodule.exports = function (write, end) {\n var stream = new Stream() \n var buffer = [], ended = false, destroyed = false, emitEnd\n stream.writable = stream.readable = true\n stream.paused = false\n stream.buffer = buffer\n \n stream.writePause = false\n stream\n .on('pause', function () {\n stream.writePause = true\n })\n .on('drain', function () {\n stream.writePause = false\n })\n \n function destroySoon () {\n process.nextTick(stream.destroy.bind(stream))\n }\n\n if(write)\n stream.on('write', write)\n if(end)\n stream.on('ended', end)\n\n //destroy the stream once both ends are over\n\n stream.once('end', function () { \n stream.readable = false\n if(!stream.writable)\n stream.destroy()\n })\n\n stream.once('ended', function () { \n stream.writable = false\n if(!stream.readable)\n stream.destroy()\n })\n\n // this is the default write method,\n // if you overide it, you are resposible\n // for pause state.\n\n stream.emitData =\n stream.sendData = function (data) {\n if(!stream.paused && !buffer.length)\n stream.emit('data', data)\n else \n buffer.push(data) \n return !(stream.paused || buffer.length)\n }\n\n stream.emitEnd =\n stream.sendEnd = function (data) {\n if(data) stream.write(data)\n if(emitEnd) return\n emitEnd = true\n //destroy is handled above.\n stream.drain()\n }\n\n stream.write = function (data) {\n stream.emit('write', data)\n return !stream.writePaused\n }\n stream.end = function () {\n stream.writable = false\n if(stream.ended) return\n stream.ended = true\n stream.emit('ended')\n }\n stream.drain = function () {\n if(!buffer.length && !emitEnd) return\n //if the stream is paused after just before emitEnd()\n //end should be buffered.\n while(!stream.paused) {\n if(buffer.length) {\n stream.emit('data', buffer.shift())\n if(buffer.length == 0)\n stream.emit('read-drain')\n }\n else if(emitEnd && stream.readable) {\n stream.readable = false\n stream.emit('end')\n return\n } else {\n //if the buffer has emptied. emit drain.\n return true\n }\n }\n }\n var started = false\n stream.resume = function () {\n //this is where I need pauseRead, and pauseWrite.\n //here the reading side is unpaused,\n //but the writing side may still be paused.\n //the whole buffer might not empity at once.\n //it might pause again.\n //the stream should never emit data inbetween pause()...resume()\n //and write should return !buffer.length\n started = true\n stream.paused = false\n stream.drain() //will emit drain if buffer empties.\n return stream\n }\n\n stream.destroy = function () {\n if(destroyed) return\n destroyed = ended = true \n buffer.length = 0\n stream.emit('close')\n }\n var pauseCalled = false\n stream.pause = function () {\n started = true\n stream.paused = true\n return stream\n }\n stream.paused = true\n process.nextTick(function () {\n //unless the user manually\n if(started) return\n stream.resume()\n })\n \n return stream\n}\n\n\n//@ sourceURL=/node_modules/delta-stream/node_modules/scuttlebutt/node_modules/duplex/index.js"));
require.define("/node_modules/delta-stream/node_modules/scuttlebutt/node_modules/stream-serializer/package.json",Function(['require','module','exports','__dirname','__filename','process'],"module.exports = {}\n//@ sourceURL=/node_modules/delta-stream/node_modules/scuttlebutt/node_modules/stream-serializer/package.json"));
require.define("/node_modules/delta-stream/node_modules/scuttlebutt/node_modules/stream-serializer/index.js",Function(['require','module','exports','__dirname','__filename','process'],"\nvar es = require('event-stream')\n\nexports = module.exports = function (wrapper) {\n\n if('function' == typeof wrapper)\n return wrapper\n \n return exports[wrapper] || exports.json\n}\n\nexports.json = function (stream) {\n return es.pipeline(es.split(), es.parse(), stream, es.stringify())\n}\n\nexports.raw = function (stream) {\n return stream\n}\n\n\n//@ sourceURL=/node_modules/delta-stream/node_modules/scuttlebutt/node_modules/stream-serializer/index.js"));
require.define("/node_modules/delta-stream/node_modules/scuttlebutt/node_modules/stream-serializer/node_modules/event-stream/package.json",Function(['require','module','exports','__dirname','__filename','process'],"module.exports = {}\n//@ sourceURL=/node_modules/delta-stream/node_modules/scuttlebutt/node_modules/stream-serializer/node_modules/event-stream/package.json"));
require.define("/node_modules/delta-stream/node_modules/scuttlebutt/node_modules/stream-serializer/node_modules/event-stream/index.js",Function(['require','module','exports','__dirname','__filename','process'],"//filter will reemit the data if cb(err,pass) pass is truthy\n\n// reduce is more tricky\n// maybe we want to group the reductions or emit progress updates occasionally\n// the most basic reduce just emits one 'data' event after it has recieved 'end'\n\n\nvar Stream = require('stream').Stream\n , es = exports\n , through = require('through')\n , from = require('from')\n , duplex = require('duplexer')\n , map = require('map-stream')\n , pause = require('pause-stream')\n , split = require('split')\n\nes.Stream = Stream //re-export Stream from core\nes.through = through\nes.from = from\nes.duplex = duplex\nes.map = map\nes.pause = pause\nes.split = split\n\n// merge / concat\n//\n// combine multiple streams into a single stream.\n// will emit end only once\n\nes.concat = //actually this should be called concat\nes.merge = function (/*streams...*/) {\n var toMerge = [].slice.call(arguments)\n var stream = new Stream()\n var endCount = 0\n stream.writable = stream.readable = true\n\n toMerge.forEach(function (e) {\n e.pipe(stream, {end: false})\n var ended = false\n e.on('end', function () {\n if(ended) return\n ended = true\n endCount ++\n if(endCount == toMerge.length)\n stream.emit('end') \n })\n })\n stream.write = function (data) {\n this.emit('data', data)\n }\n stream.destroy = function () {\n merge.forEach(function (e) {\n if(e.destroy) e.destroy()\n })\n }\n return stream\n}\n\n\n// writable stream, collects all events into an array \n// and calls back when 'end' occurs\n// mainly I'm using this to test the other functions\n\nes.writeArray = function (done) {\n if ('function' !== typeof done)\n throw new Error('function writeArray (done): done must be function')\n\n var a = new Stream ()\n , array = [], isDone = false\n a.write = function (l) {\n array.push(l)\n }\n a.end = function () {\n isDone = true\n done(null, array)\n }\n a.writable = true\n a.readable = false\n a.destroy = function () {\n a.writable = a.readable = false\n if(isDone) return\n done(new Error('destroyed before end'), array)\n }\n return a\n}\n\n//return a Stream that reads the properties of an object\n//respecting pause() and resume()\n\nes.readArray = function (array) {\n var stream = new Stream()\n , i = 0\n , paused = false\n , ended = false\n \n stream.readable = true \n stream.writable = false\n \n if(!Array.isArray(array))\n throw new Error('event-stream.read expects an array')\n \n stream.resume = function () {\n if(ended) return\n paused = false\n var l = array.length\n while(i < l && !paused && !ended) {\n stream.emit('data', array[i++])\n }\n if(i == l && !ended)\n ended = true, stream.readable = false, stream.emit('end')\n }\n process.nextTick(stream.resume)\n stream.pause = function () {\n paused = true\n }\n stream.destroy = function () {\n ended = true\n stream.emit('close')\n }\n return stream\n}\n\n//\n// readable (asyncFunction)\n// return a stream that calls an async function while the stream is not paused.\n//\n// the function must take: (count, callback) {...\n//\n\nes.readable = function (func, continueOnError) {\n var stream = new Stream()\n , i = 0\n , paused = false\n , ended = false\n , reading = false\n\n stream.readable = true \n stream.writable = false\n \n if('function' !== typeof func)\n throw new Error('event-stream.readable expects async function')\n \n stream.on('end', function () { ended = true })\n \n function get (err, data) {\n \n if(err) {\n stream.emit('error', err)\n if(!continueOnError) stream.emit('end')\n } else if (arguments.length > 1)\n stream.emit('data', data)\n\n process.nextTick(function () {\n if(ended || paused || reading) return\n try {\n reading = true\n func.call(stream, i++, function () {\n reading = false\n get.apply(null, arguments)\n })\n } catch (err) {\n stream.emit('error', err) \n }\n })\n \n }\n stream.resume = function () {\n paused = false\n get()\n }\n process.nextTick(get)\n stream.pause = function () {\n paused = true\n }\n stream.destroy = function () {\n stream.emit('end')\n stream.emit('close')\n ended = true\n }\n return stream\n}\n\n\n\n//\n// map sync\n//\n\nes.mapSync = function (sync) { \n return es.through(function write(data) {\n var mappedData = sync(data)\n if (typeof mappedData !== 'undefined')\n this.emit('data', mappedData)\n })\n}\n\n//\n// log just print out what is coming through the stream, for debugging\n//\n\nes.log = function (name) {\n return es.through(function (data) {\n var args = [].slice.call(arguments)\n if(name) console.error(name, data)\n else console.error(data)\n this.emit('data', data)\n })\n}\n\n//\n// combine multiple streams together so that they act as a single stream\n//\nes.pipeline = \nes.pipe = es.connect = function () {\n\n var streams = [].slice.call(arguments)\n , first = streams[0]\n , last = streams[streams.length - 1]\n , thepipe = es.duplex(first, last)\n\n if(streams.length == 1)\n return streams[0]\n else if (!streams.length)\n throw new Error('connect called with empty args')\n\n //pipe all the streams together\n\n function recurse (streams) {\n if(streams.length < 2)\n return\n streams[0].pipe(streams[1])\n recurse(streams.slice(1)) \n }\n \n recurse(streams)\n \n function onerror () {\n var args = [].slice.call(arguments)\n args.unshift('error')\n thepipe.emit.apply(thepipe, args)\n }\n \n streams.forEach(function (stream) {\n stream.on('error', onerror)\n })\n\n return thepipe\n}\n\n//\n// child -- pipe through a child process\n//\n\nes.child = function (child) {\n\n return es.duplex(child.stdin, child.stdout)\n\n}\n\n//\n// parse\n//\n// must be used after es.split() to ensure that each chunk represents a line\n// source.pipe(es.split()).pipe(es.parse())\n\nes.parse = function () { \n return es.through(function (data) {\n var obj\n try {\n if(data) //ignore empty lines\n obj = JSON.parse(data.toString())\n } catch (err) {\n return console.error(err, 'attemping to parse:', data)\n }\n //ignore lines that where only whitespace.\n if(obj !== undefined)\n this.emit('data', obj)\n })\n}\n//\n// stringify\n//\n\nes.stringify = function () { \n var Buffer = require('buffer').Buffer\n return es.mapSync(function (e){ \n return JSON.stringify(Buffer.isBuffer(e) ? e.toString() : e) + '\\n'\n }) \n}\n\n//\n// replace a string within a stream.\n//\n// warn: just concatenates the string and then does str.split().join(). \n// probably not optimal.\n// for smallish responses, who cares?\n// I need this for shadow-npm so it's only relatively small json files.\n\nes.replace = function (from, to) {\n return es.pipeline(es.split(from), es.join(to))\n} \n\n//\n// join chunks with a joiner. just like Array#join\n// also accepts a callback that is passed the chunks appended together\n// this is still supported for legacy reasons.\n// \n\nes.join = function (str) {\n \n //legacy api\n if('function' === typeof str)\n return es.wait(str)\n\n var first = true\n return es.through(function (data) {\n if(!first)\n this.emit('data', str)\n first = false\n this.emit('data', data)\n return true\n })\n}\n\n\n//\n// wait. callback when 'end' is emitted, with all chunks appended as string.\n//\n\nes.wait = function (callback) {\n var body = ''\n return es.through(function (data) { body += data },\n function () {\n this.emit('data', body)\n this.emit('end')\n if(callback) callback(null, body)\n })\n}\n\n//\n// helper to make your module into a unix pipe\n// simply add \n// \n// if(!module.parent)\n// require('event-stream').pipable(asyncFunctionOrStreams)\n// \n// asyncFunctionOrStreams may be one or more Streams or if it is a function, \n// it will be automatically wrapped in es.map\n//\n// then pipe stuff into from the command line!\n// \n// curl registry.npmjs.org/event-stream | node hello-pipeable.js | grep whatever\n//\n// etc!\n//\n// also, start pipeable running as a server!\n//\n// > node hello-pipeable.js --port 44444\n// \n\nvar setup = function (args) {\n return args.map(function (f) {\n var x = f()\n if('function' === typeof x)\n return es.map(x)\n return x\n })\n}\n\nes.pipeable = function () {\n console.error('warn: event-stream. I have decided that pipeable is a kitchen-sick and will remove soon if no objections')\n console.error('please post an issue if you actually use this. -- dominictarr')\n throw new Error('[EVENT-STREAM] es.pipeable is deprecated')\n}\n\n//@ sourceURL=/node_modules/delta-stream/node_modules/scuttlebutt/node_modules/stream-serializer/node_modules/event-stream/index.js"));
require.define("/node_modules/delta-stream/node_modules/scuttlebutt/node_modules/stream-serializer/node_modules/event-stream/node_modules/through/package.json",Function(['require','module','exports','__dirname','__filename','process'],"module.exports = {\"main\":\"index.js\"}\n//@ sourceURL=/node_modules/delta-stream/node_modules/scuttlebutt/node_modules/stream-serializer/node_modules/event-stream/node_modules/through/package.json"));
require.define("/node_modules/delta-stream/node_modules/scuttlebutt/node_modules/stream-serializer/node_modules/event-stream/node_modules/through/index.js",Function(['require','module','exports','__dirname','__filename','process'],"var Stream = require('stream')\n\n// through\n//\n// a stream that does nothing but re-emit the input.\n// useful for aggregating a series of changing but not ending streams into one stream)\n\nexports = module.exports = through\nthrough.through = through\n\n//create a readable writable stream.\n\nfunction through (write, end) {\n write = write || function (data) { this.emit('data', data) }\n end = end || function () { this.emit('end') }\n\n var ended = false, destroyed = false\n var stream = new Stream()\n stream.readable = stream.writable = true\n stream.paused = false \n stream.write = function (data) {\n write.call(this, data)\n return !stream.paused\n }\n //this will be registered as the first 'end' listener\n //must call destroy next tick, to make sure we're after any\n //stream piped from here. \n stream.on('end', function () {\n stream.readable = false\n if(!stream.writable)\n process.nextTick(function () {\n stream.destroy()\n })\n })\n\n stream.end = function (data) {\n if(ended) return \n //this breaks, because pipe doesn't check writable before calling end.\n //throw new Error('cannot call end twice')\n ended = true\n if(arguments.length) stream.write(data)\n this.writable = false\n end.call(this)\n if(!this.readable)\n this.destroy()\n }\n stream.destroy = function () {\n if(destroyed) return\n destroyed = true\n ended = true\n stream.writable = stream.readable = false\n stream.emit('close')\n }\n stream.pause = function () {\n if(stream.paused) return\n stream.paused = true\n stream.emit('pause')\n }\n stream.resume = function () {\n if(stream.paused) {\n stream.paused = false\n }\n stream.emit('drain')\n }\n return stream\n}\n\n\n//@ sourceURL=/node_modules/delta-stream/node_modules/scuttlebutt/node_modules/stream-serializer/node_modules/event-stream/node_modules/through/index.js"));
require.define("/node_modules/delta-stream/node_modules/scuttlebutt/node_modules/stream-serializer/node_modules/event-stream/node_modules/from/package.json",Function(['require','module','exports','__dirname','__filename','process'],"module.exports = {\"main\":\"index.js\"}\n//@ sourceURL=/node_modules/delta-stream/node_modules/scuttlebutt/node_modules/stream-serializer/node_modules/event-stream/node_modules/from/package.json"));
require.define("/node_modules/delta-stream/node_modules/scuttlebutt/node_modules/stream-serializer/node_modules/event-stream/node_modules/from/index.js",Function(['require','module','exports','__dirname','__filename','process'],"\nvar Stream = require('stream')\n\n// from\n//\n// a stream that reads from an source.\n// source may be an array, or a function.\n// from handles pause behaviour for you.\n\nmodule.exports =\nfunction from (source) {\n if(Array.isArray(source))\n return from (function (i) {\n if(source.length)\n this.emit('data', source.shift())\n else\n this.emit('end')\n return true\n })\n\n var s = new Stream(), i = 0, ended = false, started = false\n s.readable = true\n s.writable = false\n s.paused = false\n s.pause = function () {\n started = true\n s.paused = true\n }\n function next () {\n var n = 0, r = false\n if(ended) return\n while(!ended && !s.paused && source.call(s, i++, function () {\n if(!n++ && !s.ended && !s.paused)\n next()\n }))\n ;\n }\n s.resume = function () {\n started = true\n s.paused = false\n next()\n }\n s.on('end', function () {\n ended = true\n s.readable = false\n process.nextTick(s.destroy)\n })\n s.destroy = function () {\n ended = true\n s.emit('close') \n }\n /*\n by default, the stream will start emitting at nextTick\n if you want, you can pause it, after pipeing.\n you can also resume before next tick, and that will also\n work.\n */\n process.nextTick(function () {\n if(!started) s.resume()\n })\n return s\n}\n\n//@ sourceURL=/node_modules/delta-stream/node_modules/scuttlebutt/node_modules/stream-serializer/node_modules/event-stream/node_modules/from/index.js"));
require.define("/node_modules/delta-stream/node_modules/scuttlebutt/node_modules/stream-serializer/node_modules/event-stream/node_modules/duplexer/package.json",Function(['require','module','exports','__dirname','__filename','process'],"module.exports = {\"main\":\"index\"}\n//@ sourceURL=/node_modules/delta-stream/node_modules/scuttlebutt/node_modules/stream-serializer/node_modules/event-stream/node_modules/duplexer/package.json"));
require.define("/node_modules/delta-stream/node_modules/scuttlebutt/node_modules/stream-serializer/node_modules/event-stream/node_modules/duplexer/index.js",Function(['require','module','exports','__dirname','__filename','process'],"var Stream = require(\"stream\")\n , writeMethods = [\"write\", \"end\", \"destroy\"]\n , readMethods = [\"resume\", \"pause\"]\n , readEvents = [\"data\", \"close\"]\n , slice = Array.prototype.slice\n\nmodule.exports = duplex\n\nfunction duplex(writer, reader) {\n var stream = new Stream()\n , ended = false\n\n Object.defineProperties(stream, {\n writable: {\n get: getWritable\n }\n , readable: {\n get: getReadable\n }\n })\n\n writeMethods.forEach(proxyWriter)\n\n readMethods.forEach(proxyReader)\n\n readEvents.forEach(proxyStream)\n\n reader.on(\"end\", handleEnd)\n\n writer.on(\"error\", reemit)\n reader.on(\"error\", reemit)\n\n return stream\n\n function getWritable() {\n return writer.writable\n }\n\n function getReadable() {\n return reader.readable\n }\n\n function proxyWriter(methodName) {\n stream[methodName] = method\n\n function method() {\n return writer[methodName].apply(writer, arguments)\n }\n }\n\n function proxyReader(methodName) {\n stream[methodName] = method\n\n function method() {\n stream.emit(methodName)\n var func = reader[methodName]\n if (func) {\n return func.apply(reader, arguments)\n }\n reader.emit(methodName)\n }\n }\n\n function proxyStream(methodName) {\n reader.on(methodName, reemit)\n\n function reemit() {\n var args = slice.call(arguments)\n args.unshift(methodName)\n stream.emit.apply(stream, args)\n }\n }\n\n function handleEnd() {\n if (ended) {\n return\n }\n ended = true\n var args = slice.call(arguments)\n args.unshift(\"end\")\n stream.emit.apply(stream, args)\n }\n\n function reemit(err) {\n stream.emit(\"error\", err)\n }\n}\n//@ sourceURL=/node_modules/delta-stream/node_modules/scuttlebutt/node_modules/stream-serializer/node_modules/event-stream/node_modules/duplexer/index.js"));
require.define("/node_modules/delta-stream/node_modules/scuttlebutt/node_modules/stream-serializer/node_modules/event-stream/node_modules/map-stream/package.json",Function(['require','module','exports','__dirname','__filename','process'],"module.exports = {}\n//@ sourceURL=/node_modules/delta-stream/node_modules/scuttlebutt/node_modules/stream-serializer/node_modules/event-stream/node_modules/map-stream/package.json"));
require.define("/node_modules/delta-stream/node_modules/scuttlebutt/node_modules/stream-serializer/node_modules/event-stream/node_modules/map-stream/index.js",Function(['require','module','exports','__dirname','__filename','process'],"//filter will reemit the data if cb(err,pass) pass is truthy\n\n// reduce is more tricky\n// maybe we want to group the reductions or emit progress updates occasionally\n// the most basic reduce just emits one 'data' event after it has recieved 'end'\n\n\nvar Stream = require('stream').Stream\n\n\n//create an event stream and apply function to each .write\n//emitting each response as data\n//unless it's an empty callback\n\nmodule.exports = function (mapper) {\n var stream = new Stream()\n , inputs = 0\n , outputs = 0\n , ended = false\n , paused = false\n , destroyed = false\n\n stream.writable = true\n stream.readable = true\n \n stream.write = function () {\n if(ended) throw new Error('map stream is not writable')\n inputs ++\n var args = [].slice.call(arguments)\n , r\n , inNext = false \n //pipe only allows one argument. so, do not \n function next (err) {\n if(destroyed) return\n inNext = true\n outputs ++\n var args = [].slice.call(arguments)\n if(err) {\n args.unshift('error')\n return inNext = false, stream.emit.apply(stream, args)\n }\n args.shift() //drop err\n if (args.length) {\n args.unshift('data')\n r = stream.emit.apply(stream, args)\n }\n if(inputs == outputs) {\n if(paused) paused = false, stream.emit('drain') //written all the incoming events\n if(ended) end()\n }\n inNext = false\n }\n args.push(next)\n \n try {\n //catch sync errors and handle them like async errors\n var written = mapper.apply(null, args)\n paused = (written === false)\n return !paused\n } catch (err) {\n //if the callback has been called syncronously, and the error\n //has occured in an listener, throw it again.\n if(inNext)\n throw err\n next(err)\n return !paused\n }\n }\n\n function end (data) {\n //if end was called with args, write it, \n ended = true //write will emit 'end' if ended is true\n stream.writable = false\n if(data !== undefined)\n return stream.write(data)\n else if (inputs == outputs) //wait for processing \n stream.readable = false, stream.emit('end'), stream.destroy() \n }\n\n stream.end = function (data) {\n if(ended) return\n end()\n }\n\n stream.destroy = function () {\n ended = destroyed = true\n stream.writable = stream.readable = paused = false\n process.nextTick(function () {\n stream.emit('close')\n })\n }\n stream.pause = function () {\n paused = true\n }\n\n stream.resume = function () {\n paused = false\n }\n\n return stream\n}\n\n\n\n\n\n//@ sourceURL=/node_modules/delta-stream/node_modules/scuttlebutt/node_modules/stream-serializer/node_modules/event-stream/node_modules/map-stream/index.js"));
require.define("/node_modules/delta-stream/node_modules/scuttlebutt/node_modules/stream-serializer/node_modules/event-stream/node_modules/pause-stream/package.json",Function(['require','module','exports','__dirname','__filename','process'],"module.exports = {\"main\":\"index.js\"}\n//@ sourceURL=/node_modules/delta-stream/node_modules/scuttlebutt/node_modules/stream-serializer/node_modules/event-stream/node_modules/pause-stream/package.json"));
require.define("/node_modules/delta-stream/node_modules/scuttlebutt/node_modules/stream-serializer/node_modules/event-stream/node_modules/pause-stream/index.js",Function(['require','module','exports','__dirname','__filename','process'],"var Stream = require('stream')\n\n/*\n was gonna use through for this,\n but it does not match quite right,\n because you need a seperate pause\n mechanism for the readable and writable\n sides.\n*/\n\nmodule.exports = function () {\n var buffer = [], ended = false, destroyed = false\n var stream = new Stream() \n stream.writable = stream.readable = true\n stream.paused = false \n \n stream.write = function (data) {\n if(!this.paused)\n this.emit('data', data)\n else \n buffer.push(data)\n return !(this.paused || buffer.length)\n }\n function onEnd () {\n stream.readable = false\n stream.emit('end')\n process.nextTick(stream.destroy.bind(stream))\n }\n stream.end = function (data) {\n if(data) this.write(data)\n this.ended = true\n this.writable = false\n if(!(this.paused || buffer.length))\n return onEnd()\n else\n this.once('drain', onEnd)\n this.drain()\n }\n\n stream.drain = function () {\n while(!this.paused && buffer.length)\n this.emit('data', buffer.shift())\n //if the buffer has emptied. emit drain.\n if(!buffer.length && !this.paused)\n this.emit('drain')\n }\n\n stream.resume = function () {\n //this is where I need pauseRead, and pauseWrite.\n //here the reading side is unpaused,\n //but the writing side may still be paused.\n //the whole buffer might not empity at once.\n //it might pause again.\n //the stream should never emit data inbetween pause()...resume()\n //and write should return !buffer.length\n\n this.paused = false\n// process.nextTick(this.drain.bind(this)) //will emit drain if buffer empties.\n this.drain()\n return this\n }\n\n stream.destroy = function () {\n if(destroyed) return\n destroyed = ended = true \n buffer.length = 0\n this.emit('close')\n }\n\n stream.pause = function () {\n stream.paused = true\n return this\n }\n \n return stream\n}\n\n//@ sourceURL=/node_modules/delta-stream/node_modules/scuttlebutt/node_modules/stream-serializer/node_modules/event-stream/node_modules/pause-stream/index.js"));
require.define("/node_modules/delta-stream/node_modules/scuttlebutt/node_modules/stream-serializer/node_modules/event-stream/node_modules/split/package.json",Function(['require','module','exports','__dirname','__filename','process'],"module.exports = {}\n//@ sourceURL=/node_modules/delta-stream/node_modules/scuttlebutt/node_modules/stream-serializer/node_modules/event-stream/node_modules/split/package.json"));
require.define("/node_modules/delta-stream/node_modules/scuttlebutt/node_modules/stream-serializer/node_modules/event-stream/node_modules/split/index.js",Function(['require','module','exports','__dirname','__filename','process'],"//filter will reemit the data if cb(err,pass) pass is truthy\n\n// reduce is more tricky\n// maybe we want to group the reductions or emit progress updates occasionally\n// the most basic reduce just emits one 'data' event after it has recieved 'end'\n\n\nvar through = require('through')\n\n\nmodule.exports = split\n\nfunction split (matcher) {\n var soFar = ''\n if (!matcher)\n matcher = '\\n'\n\n return through(function (buffer) { \n var stream = this\n , pieces = (soFar + buffer).split(matcher)\n soFar = pieces.pop()\n\n pieces.forEach(function (piece) {\n stream.emit('data', piece)\n })\n\n return true\n },\n function () {\n if(soFar)\n this.emit('data', soFar) \n this.emit('end')\n })\n}\n\n\n//@ sourceURL=/node_modules/delta-stream/node_modules/scuttlebutt/node_modules/stream-serializer/node_modules/event-stream/node_modules/split/index.js"));
require.define("/node_modules/delta-stream/node_modules/scuttlebutt/node_modules/stream-serializer/node_modules/event-stream/node_modules/split/node_modules/through/package.json",Function(['require','module','exports','__dirname','__filename','process'],"module.exports = {\"main\":\"index.js\"}\n//@ sourceURL=/node_modules/delta-stream/node_modules/scuttlebutt/node_modules/stream-serializer/node_modules/event-stream/node_modules/split/node_modules/through/package.json"));
require.define("/node_modules/delta-stream/node_modules/scuttlebutt/node_modules/stream-serializer/node_modules/event-stream/node_modules/split/node_modules/through/index.js",Function(['require','module','exports','__dirname','__filename','process'],"var Stream = require('stream')\n\n// through\n//\n// a stream that does nothing but re-emit the input.\n// useful for aggregating a series of changing but not ending streams into one stream)\n\nexports = module.exports = through\nthrough.through = through\n\n//create a readable writable stream.\n\nfunction through (write, end) {\n write = write || function (data) { this.emit('data', data) }\n end = end || function () { this.emit('end') }\n\n var ended = false, destroyed = false\n var stream = new Stream()\n stream.readable = stream.writable = true\n stream.paused = false \n stream.write = function (data) {\n write.call(this, data)\n return !stream.paused\n }\n //this will be registered as the first 'end' listener\n //must call destroy next tick, to make sure we're after any\n //stream piped from here. \n stream.on('end', function () {\n stream.readable = false\n if(!stream.writable)\n process.nextTick(function () {\n stream.destroy()\n })\n })\n\n stream.end = function (data) {\n if(ended) return \n //this breaks, because pipe doesn't check writable before calling end.\n //throw new Error('cannot call end twice')\n ended = true\n if(arguments.length) stream.write(data)\n this.writable = false\n end.call(this)\n if(!this.readable)\n this.destroy()\n }\n stream.destroy = function () {\n if(destroyed) return\n destroyed = true\n ended = true\n stream.writable = stream.readable = false\n stream.emit('close')\n }\n stream.pause = function () {\n stream.paused = true\n }\n stream.resume = function () {\n if(stream.paused) {\n stream.paused = false\n stream.emit('drain')\n }\n }\n return stream\n}\n\n\n//@ sourceURL=/node_modules/delta-stream/node_modules/scuttlebutt/node_modules/stream-serializer/node_modules/event-stream/node_modules/split/node_modules/through/index.js"));
require.define("buffer",Function(['require','module','exports','__dirname','__filename','process'],"module.exports = require(\"buffer-browserify\")\n//@ sourceURL=buffer"));
require.define("/node_modules/buffer-browserify/package.json",Function(['require','module','exports','__dirname','__filename','process'],"module.exports = {\"main\":\"index.js\",\"browserify\":\"index.js\"}\n//@ sourceURL=/node_modules/buffer-browserify/package.json"));
require.define("/node_modules/buffer-browserify/index.js",Function(['require','module','exports','__dirname','__filename','process'],"function SlowBuffer (size) {\n this.length = size;\n};\n\nvar assert = require('assert');\n\nexports.INSPECT_MAX_BYTES = 50;\n\n\nfunction toHex(n) {\n if (n < 16) return '0' + n.toString(16);\n return n.toString(16);\n}\n\nfunction utf8ToBytes(str) {\n var byteArray = [];\n for (var i = 0; i < str.length; i++)\n if (str.charCodeAt(i) <= 0x7F)\n byteArray.push(str.charCodeAt(i));\n else {\n var h = encodeURIComponent(str.charAt(i)).substr(1).split('%');\n for (var j = 0; j < h.length; j++)\n byteArray.push(parseInt(h[j], 16));\n }\n\n return byteArray;\n}\n\nfunction asciiToBytes(str) {\n var byteArray = []\n for (var i = 0; i < str.length; i++ )\n // Node's code seems to be doing this and not & 0x7F..\n byteArray.push( str.charCodeAt(i) & 0xFF );\n\n return byteArray;\n}\n\nfunction base64ToBytes(str) {\n return require(\"base64-js\").toByteArray(str);\n}\n\nSlowBuffer.byteLength = function (str, encoding) {\n switch (encoding || \"utf8\") {\n case 'hex':\n return str.length / 2;\n\n case 'utf8':\n case 'utf-8':\n return utf8ToBytes(str).length;\n\n case 'ascii':\n return str.length;\n\n case 'base64':\n return base64ToBytes(str).length;\n\n default:\n throw new Error('Unknown encoding');\n }\n};\n\nfunction blitBuffer(src, dst, offset, length) {\n var pos, i = 0;\n while (i < length) {\n if ((i+offset >= dst.length) || (i >= src.length))\n break;\n\n dst[i + offset] = src[i];\n i++;\n }\n return i;\n}\n\nSlowBuffer.prototype.utf8Write = function (string, offset, length) {\n var bytes, pos;\n return SlowBuffer._charsWritten = blitBuffer(utf8ToBytes(string), this, offset, length);\n};\n\nSlowBuffer.prototype.asciiWrite = function (string, offset, length) {\n var bytes, pos;\n return SlowBuffer._charsWritten = blitBuffer(asciiToBytes(string), this, offset, length);\n};\n\nSlowBuffer.prototype.base64Write = function (string, offset, length) {\n var bytes, pos;\n return SlowBuffer._charsWritten = blitBuffer(base64ToBytes(string), this, offset, length);\n};\n\nSlowBuffer.prototype.base64Slice = function (start, end) {\n var bytes = Array.prototype.slice.apply(this, arguments)\n return require(\"base64-js\").fromByteArray(bytes);\n}\n\nfunction decodeUtf8Char(str) {\n try {\n return decodeURIComponent(str);\n } catch (err) {\n return String.fromCharCode(0xFFFD); // UTF 8 invalid char\n }\n}\n\nSlowBuffer.prototype.utf8Slice = function () {\n var bytes = Array.prototype.slice.apply(this, arguments);\n var res = \"\";\n var tmp = \"\";\n var i = 0;\n while (i < bytes.length) {\n if (bytes[i] <= 0x7F) {\n res += decodeUtf8Char(tmp) + String.fromCharCode(bytes[i]);\n tmp = \"\";\n } else\n tmp += \"%\" + bytes[i].toString(16);\n\n i++;\n }\n\n return res + decodeUtf8Char(tmp);\n}\n\nSlowBuffer.prototype.asciiSlice = function () {\n var bytes = Array.prototype.slice.apply(this, arguments);\n var ret = \"\";\n for (var i = 0; i < bytes.length; i++)\n ret += String.fromCharCode(bytes[i]);\n return ret;\n}\n\nSlowBuffer.prototype.inspect = function() {\n var out = [],\n len = this.length;\n for (var i = 0; i < len; i++) {\n out[i] = toHex(this[i]);\n if (i == exports.INSPECT_MAX_BYTES) {\n out[i + 1] = '...';\n break;\n }\n }\n return '<SlowBuffer ' + out.join(' ') + '>';\n};\n\n\nSlowBuffer.prototype.hexSlice = function(start, end) {\n var len = this.length;\n\n if (!start || start < 0) start = 0;\n if (!end || end < 0 || end > len) end = len;\n\n var out = '';\n for (var i = start; i < end; i++) {\n out += toHex(this[i]);\n }\n return out;\n};\n\n\nSlowBuffer.prototype.toString = function(encoding, start, end) {\n encoding = String(encoding || 'utf8').toLowerCase();\n start = +start || 0;\n if (typeof end == 'undefined') end = this.length;\n\n // Fastpath empty strings\n if (+end == start) {\n return '';\n }\n\n switch (encoding) {\n case 'hex':\n return this.hexSlice(start, end);\n\n case 'utf8':\n case 'utf-8':\n return this.utf8Slice(start, end);\n\n case 'ascii':\n return this.asciiSlice(start, end);\n\n case 'binary':\n return this.binarySlice(start, end);\n\n case 'base64':\n return this.base64Slice(start, end);\n\n case 'ucs2':\n case 'ucs-2':\n return this.ucs2Slice(start, end);\n\n default:\n throw new Error('Unknown encoding');\n }\n};\n\n\nSlowBuffer.prototype.hexWrite = function(string, offset, length) {\n offset = +offset || 0;\n var remaining = this.length - offset;\n if (!length) {\n length = remaining;\n } else {\n length = +length;\n if (length > remaining) {\n length = remaining;\n }\n }\n\n // must be an even number of digits\n var strLen = string.length;\n if (strLen % 2) {\n throw new Error('Invalid hex string');\n }\n if (length > strLen / 2) {\n length = strLen / 2;\n }\n for (var i = 0; i < length; i++) {\n var byte = parseInt(string.substr(i * 2, 2), 16);\n if (isNaN(byte)) throw new Error('Invalid hex string');\n this[offset + i] = byte;\n }\n SlowBuffer._charsWritten = i * 2;\n return i;\n};\n\n\nSlowBuffer.prototype.write = function(string, offset, length, encoding) {\n // Support both (string, offset, length, encoding)\n // and the legacy (string, encoding, offset, length)\n if (isFinite(offset)) {\n if (!isFinite(length)) {\n encoding = length;\n length = undefined;\n }\n } else { // legacy\n var swap = encoding;\n encoding = offset;\n offset = length;\n length = swap;\n }\n\n offset = +offset || 0;\n var remaining = this.length - offset;\n if (!length) {\n length = remaining;\n } else {\n length = +length;\n if (length > remaining) {\n length = remaining;\n }\n }\n encoding = String(encoding || 'utf8').toLowerCase();\n\n switch (encoding) {\n case 'hex':\n return this.hexWrite(string, offset, length);\n\n case 'utf8':\n case 'utf-8':\n return this.utf8Write(string, offset, length);\n\n case 'ascii':\n return this.asciiWrite(string, offset, length);\n\n case 'binary':\n return this.binaryWrite(string, offset, length);\n\n case 'base64':\n return this.base64Write(string, offset, length);\n\n case 'ucs2':\n case 'ucs-2':\n return this.ucs2Write(string, offset, length);\n\n default:\n throw new Error('Unknown encoding');\n }\n};\n\n\n// slice(start, end)\nSlowBuffer.prototype.slice = function(start, end) {\n if (end === undefined) end = this.length;\n\n if (end > this.length) {\n throw new Error('oob');\n }\n if (start > end) {\n throw new Error('oob');\n }\n\n return new Buffer(this, end - start, +start);\n};\n\n\nfunction coerce(length) {\n // Coerce length to a number (possibly NaN), round up\n // in case it's fractional (e.g. 123.456) then do a\n // double negate to coerce a NaN to 0. Easy, right?\n length = ~~Math.ceil(+length);\n return length < 0 ? 0 : length;\n}\n\n\n// Buffer\n\nfunction Buffer(subject, encoding, offset) {\n if (!(this instanceof Buffer)) {\n return new Buffer(subject, encoding, offset);\n }\n\n var type;\n\n // Are we slicing?\n if (typeof offset === 'number') {\n this.length = coerce(encoding);\n this.parent = subject;\n this.offset = offset;\n } else {\n // Find the length\n switch (type = typeof subject) {\n case 'number':\n this.length = coerce(subject);\n break;\n\n case 'string':\n this.length = Buffer.byteLength(subject, encoding);\n break;\n\n case 'object': // Assume object is an array\n this.length = coerce(subject.length);\n break;\n\n default:\n throw new Error('First argument needs to be a number, ' +\n 'array or string.');\n }\n\n if (this.length > Buffer.poolSize) {\n // Big buffer, just alloc one.\n this.parent = new SlowBuffer(this.length);\n this.offset = 0;\n\n } else {\n // Small buffer.\n if (!pool || pool.length - pool.used < this.length) allocPool();\n this.parent = pool;\n this.offset = pool.used;\n pool.used += this.length;\n }\n\n // Treat array-ish objects as a byte array.\n if (isArrayIsh(subject)) {\n for (var i = 0; i < this.length; i++) {\n this.parent[i + this.offset] = subject[i];\n }\n } else if (type == 'string') {\n // We are a string\n this.length = this.write(subject, 0, encoding);\n }\n }\n\n}\n\nfunction isArrayIsh(subject) {\n return Array.isArray(subject) || Buffer.isBuffer(subject) ||\n subject && typeof subject === 'object' &&\n typeof subject.length === 'number';\n}\n\nexports.SlowBuffer = SlowBuffer;\nexports.Buffer = Buffer;\n\nBuffer.poolSize = 8 * 1024;\nvar pool;\n\nfunction allocPool() {\n pool = new SlowBuffer(Buffer.poolSize);\n pool.used = 0;\n}\n\n\n// Static methods\nBuffer.isBuffer = function isBuffer(b) {\n return b instanceof Buffer || b instanceof SlowBuffer;\n};\n\n\n// Inspect\nBuffer.prototype.inspect = function inspect() {\n var out = [],\n len = this.length;\n\n for (var i = 0; i < len; i++) {\n out[i] = toHex(this.parent[i + this.offset]);\n if (i == exports.INSPECT_MAX_BYTES) {\n out[i + 1] = '...';\n break;\n }\n }\n\n return '<Buffer ' + out.join(' ') + '>';\n};\n\n\nBuffer.prototype.get = function get(i) {\n if (i < 0 || i >= this.length) throw new Error('oob');\n return this.parent[this.offset + i];\n};\n\n\nBuffer.prototype.set = function set(i, v) {\n if (i < 0 || i >= this.length) throw new Error('oob');\n return this.parent[this.offset + i] = v;\n};\n\n\n// write(string, offset = 0, length = buffer.length-offset, encoding = 'utf8')\nBuffer.prototype.write = function(string, offset, length, encoding) {\n // Support both (string, offset, length, encoding)\n // and the legacy (string, encoding, offset, length)\n if (isFinite(offset)) {\n if (!isFinite(length)) {\n encoding = length;\n length = undefined;\n }\n } else { // legacy\n var swap = encoding;\n encoding = offset;\n offset = length;\n length = swap;\n }\n\n offset = +offset || 0;\n var remaining = this.length - offset;\n if (!length) {\n length = remaining;\n } else {\n length = +length;\n if (length > remaining) {\n length = remaining;\n }\n }\n encoding = String(encoding || 'utf8').toLowerCase();\n\n var ret;\n switch (encoding) {\n case 'hex':\n ret = this.parent.hexWrite(string, this.offset + offset, length);\n break;\n\n case 'utf8':\n case 'utf-8':\n ret = this.parent.utf8Write(string, this.offset + offset, length);\n break;\n\n case 'ascii':\n ret = this.parent.asciiWrite(string, this.offset + offset, length);\n break;\n\n case 'binary':\n ret = this.parent.binaryWrite(string, this.offset + offset, length);\n break;\n\n case 'base64':\n // Warning: maxLength not taken into account in base64Write\n ret = this.parent.base64Write(string, this.offset + offset, length);\n break;\n\n case 'ucs2':\n case 'ucs-2':\n ret = this.parent.ucs2Write(string, this.offset + offset, length);\n break;\n\n default:\n throw new Error('Unknown encoding');\n }\n\n Buffer._charsWritten = SlowBuffer._charsWritten;\n\n return ret;\n};\n\n\n// toString(encoding, start=0, end=buffer.length)\nBuffer.prototype.toString = function(encoding, start, end) {\n encoding = String(encoding || 'utf8').toLowerCase();\n\n if (typeof start == 'undefined' || start < 0) {\n start = 0;\n } else if (start > this.length) {\n start = this.length;\n }\n\n if (typeof end == 'undefined' || end > this.length) {\n end = this.length;\n } else if (end < 0) {\n end = 0;\n }\n\n start = start + this.offset;\n end = end + this.offset;\n\n switch (encoding) {\n case 'hex':\n return this.parent.hexSlice(start, end);\n\n case 'utf8':\n case 'utf-8':\n return this.parent.utf8Slice(start, end);\n\n case 'ascii':\n return this.parent.asciiSlice(start, end);\n\n case 'binary':\n return this.parent.binarySlice(start, end);\n\n case 'base64':\n return this.parent.base64Slice(start, end);\n\n case 'ucs2':\n case 'ucs-2':\n return this.parent.ucs2Slice(start, end);\n\n default:\n throw new Error('Unknown encoding');\n }\n};\n\n\n// byteLength\nBuffer.byteLength = SlowBuffer.byteLength;\n\n\n// fill(value, start=0, end=buffer.length)\nBuffer.prototype.fill = function fill(value, start, end) {\n value || (value = 0);\n start || (start = 0);\n end || (end = this.length);\n\n if (typeof value === 'string') {\n value = value.charCodeAt(0);\n }\n if (!(typeof value === 'number') || isNaN(value)) {\n throw new Error('value is not a number');\n }\n\n if (end < start) throw new Error('end < start');\n\n // Fill 0 bytes; we're done\n if (end === start) return 0;\n if (this.length == 0) return 0;\n\n if (start < 0 || start >= this.length) {\n throw new Error('start out of bounds');\n }\n\n if (end < 0 || end > this.length) {\n throw new Error('end out of bounds');\n }\n\n return this.parent.fill(value,\n start + this.offset,\n end + this.offset);\n};\n\n\n// copy(targetBuffer, targetStart=0, sourceStart=0, sourceEnd=buffer.length)\nBuffer.prototype.copy = function(target, target_start, start, end) {\n var source = this;\n start || (start = 0);\n end || (end = this.length);\n target_start || (target_start = 0);\n\n if (end < start) throw new Error('sourceEnd < sourceStart');\n\n // Copy 0 bytes; we're done\n if (end === start) return 0;\n if (target.length == 0 || source.length == 0) return 0;\n\n if (target_start < 0 || target_start >= target.length) {\n throw new Error('targetStart out of bounds');\n }\n\n if (start < 0 || start >= source.length) {\n throw new Error('sourceStart out of bounds');\n }\n\n if (end < 0 || end > source.length) {\n throw new Error('sourceEnd out of bounds');\n }\n\n // Are we oob?\n if (end > this.length) {\n end = this.length;\n }\n\n if (target.length - target_start < end - start) {\n end = target.length - target_start + start;\n }\n\n return this.parent.copy(target.parent,\n target_start + target.offset,\n start + this.offset,\n end + this.offset);\n};\n\n\n// slice(start, end)\nBuffer.prototype.slice = function(start, end) {\n if (end === undefined) end = this.length;\n if (end > this.length) throw new Error('oob');\n if (start > end) throw new Error('oob');\n\n return new Buffer(this.parent, end - start, +start + this.offset);\n};\n\n\n// Legacy methods for backwards compatibility.\n\nBuffer.prototype.utf8Slice = function(start, end) {\n return this.toString('utf8', start, end);\n};\n\nBuffer.prototype.binarySlice = function(start, end) {\n return this.toString('binary', start, end);\n};\n\nBuffer.prototype.asciiSlice = function(start, end) {\n return this.toString('ascii', start, end);\n};\n\nBuffer.prototype.utf8Write = function(string, offset) {\n return this.write(string, offset, 'utf8');\n};\n\nBuffer.prototype.binaryWrite = function(string, offset) {\n return this.write(string, offset, 'binary');\n};\n\nBuffer.prototype.asciiWrite = function(string, offset) {\n return this.write(string, offset, 'ascii');\n};\n\nBuffer.prototype.readUInt8 = function(offset, noAssert) {\n var buffer = this;\n\n if (!noAssert) {\n assert.ok(offset !== undefined && offset !== null,\n 'missing offset');\n\n assert.ok(offset < buffer.length,\n 'Trying to read beyond buffer length');\n }\n\n return buffer[offset];\n};\n\nfunction readUInt16(buffer, offset, isBigEndian, noAssert) {\n var val = 0;\n\n\n if (!noAssert) {\n assert.ok(typeof (isBigEndian) === 'boolean',\n 'missing or invalid endian');\n\n assert.ok(offset !== undefined && offset !== null,\n 'missing offset');\n\n assert.ok(offset + 1 < buffer.length,\n 'Trying to read beyond buffer length');\n }\n\n if (isBigEndian) {\n val = buffer[offset] << 8;\n val |= buffer[offset + 1];\n } else {\n val = buffer[offset];\n val |= buffer[offset + 1] << 8;\n }\n\n return val;\n}\n\nBuffer.prototype.readUInt16LE = function(offset, noAssert) {\n return readUInt16(this, offset, false, noAssert);\n};\n\nBuffer.prototype.readUInt16BE = function(offset, noAssert) {\n return readUInt16(this, offset, true, noAssert);\n};\n\nfunction readUInt32(buffer, offset, isBigEndian, noAssert) {\n var val = 0;\n\n if (!noAssert) {\n assert.ok(typeof (isBigEndian) === 'boolean',\n 'missing or invalid endian');\n\n assert.ok(offset !== undefined && offset !== null,\n 'missing offset');\n\n assert.ok(offset + 3 < buffer.length,\n 'Trying to read beyond buffer length');\n }\n\n if (isBigEndian) {\n val = buffer[offset + 1] << 16;\n val |= buffer[offset + 2] << 8;\n val |= buffer[offset + 3];\n val = val + (buffer[offset] << 24 >>> 0);\n } else {\n val = buffer[offset + 2] << 16;\n val |= buffer[offset + 1] << 8;\n val |= buffer[offset];\n val = val + (buffer[offset + 3] << 24 >>> 0);\n }\n\n return val;\n}\n\nBuffer.prototype.readUInt32LE = function(offset, noAssert) {\n return readUInt32(this, offset, false, noAssert);\n};\n\nBuffer.prototype.readUInt32BE = function(offset, noAssert) {\n return readUInt32(this, offset, true, noAssert);\n};\n\n\n/*\n * Signed integer types, yay team! A reminder on how two's complement actually\n * works. The first bit is the signed bit, i.e. tells us whether or not the\n * number should be positive or negative. If the two's complement value is\n * positive, then we're done, as it's equivalent to the unsigned representation.\n *\n * Now if the number is positive, you're pretty much done, you can just leverage\n * the unsigned translations and return those. Unfortunately, negative numbers\n * aren't quite that straightforward.\n *\n * At first glance, one might be inclined to use the traditional formula to\n * translate binary numbers between the positive and negative values in two's\n * complement. (Though it doesn't quite work for the most negative value)\n * Mainly:\n * - invert all the bits\n * - add one to the result\n *\n * Of course, this doesn't quite work in Javascript. Take for example the value\n * of -128. This could be represented in 16 bits (big-endian) as 0xff80. But of\n * course, Javascript will do the following:\n *\n * > ~0xff80\n * -65409\n *\n * Whoh there, Javascript, that's not quite right. But wait, according to\n * Javascript that's perfectly correct. When Javascript ends up seeing the\n * constant 0xff80, it has no notion that it is actually a signed number. It\n * assumes that we've input the unsigned value 0xff80. Thus, when it does the\n * binary negation, it casts it into a signed value, (positive 0xff80). Then\n * when you perform binary negation on that, it turns it into a negative number.\n *\n * Instead, we're going to have to use the following general formula, that works\n * in a rather Javascript friendly way. I'm glad we don't support this kind of\n * weird numbering scheme in the kernel.\n *\n * (BIT-MAX - (unsigned)val + 1) * -1\n *\n * The astute observer, may think that this doesn't make sense for 8-bit numbers\n * (really it isn't necessary for them). However, when you get 16-bit numbers,\n * you do. Let's go back to our prior example and see how this will look:\n *\n * (0xffff - 0xff80 + 1) * -1\n * (0x007f + 1) * -1\n * (0x0080) * -1\n */\nBuffer.prototype.readInt8 = function(offset, noAssert) {\n var buffer = this;\n var neg;\n\n if (!noAssert) {\n assert.ok(offset !== undefined && offset !== null,\n 'missing offset');\n\n assert.ok(offset < buffer.length,\n 'Trying to read beyond buffer length');\n }\n\n neg = buffer[offset] & 0x80;\n if (!neg) {\n return (buffer[offset]);\n }\n\n return ((0xff - buffer[offset] + 1) * -1);\n};\n\nfunction readInt16(buffer, offset, isBigEndian, noAssert) {\n var neg, val;\n\n if (!noAssert) {\n assert.ok(typeof (isBigEndian) === 'boolean',\n 'missing or invalid endian');\n\n assert.ok(offset !== undefined && offset !== null,\n 'missing offset');\n\n assert.ok(offset + 1 < buffer.length,\n 'Trying to read beyond buffer length');\n }\n\n val = readUInt16(buffer, offset, isBigEndian, noAssert);\n neg = val & 0x8000;\n if (!neg) {\n return val;\n }\n\n return (0xffff - val + 1) * -1;\n}\n\nBuffer.prototype.readInt16LE = function(offset, noAssert) {\n return readInt16(this, offset, false, noAssert);\n};\n\nBuffer.prototype.readInt16BE = function(offset, noAssert) {\n return readInt16(this, offset, true, noAssert);\n};\n\nfunction readInt32(buffer, offset, isBigEndian, noAssert) {\n var neg, val;\n\n if (!noAssert) {\n assert.ok(typeof (isBigEndian) === 'boolean',\n 'missing or invalid endian');\n\n assert.ok(offset !== undefined && offset !== null,\n 'missing offset');\n\n assert.ok(offset + 3 < buffer.length,\n 'Trying to read beyond buffer length');\n }\n\n val = readUInt32(buffer, offset, isBigEndian, noAssert);\n neg = val & 0x80000000;\n if (!neg) {\n return (val);\n }\n\n return (0xffffffff - val + 1) * -1;\n}\n\nBuffer.prototype.readInt32LE = function(offset, noAssert) {\n return readInt32(this, offset, false, noAssert);\n};\n\nBuffer.prototype.readInt32BE = function(offset, noAssert) {\n return readInt32(this, offset, true, noAssert);\n};\n\nfunction readFloat(buffer, offset, isBigEndian, noAssert) {\n if (!noAssert) {\n assert.ok(typeof (isBigEndian) === 'boolean',\n 'missing or invalid endian');\n\n assert.ok(offset + 3 < buffer.length,\n 'Trying to read beyond buffer length');\n }\n\n return require('./buffer_ieee754').readIEEE754(buffer, offset, isBigEndian,\n 23, 4);\n}\n\nBuffer.prototype.readFloatLE = function(offset, noAssert) {\n return readFloat(this, offset, false, noAssert);\n};\n\nBuffer.prototype.readFloatBE = function(offset, noAssert) {\n return readFloat(this, offset, true, noAssert);\n};\n\nfunction readDouble(buffer, offset, isBigEndian, noAssert) {\n if (!noAssert) {\n assert.ok(typeof (isBigEndian) === 'boolean',\n 'missing or invalid endian');\n\n assert.ok(offset + 7 < buffer.length,\n 'Trying to read beyond buffer length');\n }\n\n return require('./buffer_ieee754').readIEEE754(buffer, offset, isBigEndian,\n 52, 8);\n}\n\nBuffer.prototype.readDoubleLE = function(offset, noAssert) {\n return readDouble(this, offset, false, noAssert);\n};\n\nBuffer.prototype.readDoubleBE = function(offset, noAssert) {\n return readDouble(this, offset, true, noAssert);\n};\n\n\n/*\n * We have to make sure that the value is a valid integer. This means that it is\n * non-negative. It has no fractional component and that it does not exceed the\n * maximum allowed value.\n *\n * value The number to check for validity\n *\n * max The maximum value\n */\nfunction verifuint(value, max) {\n assert.ok(typeof (value) == 'number',\n 'cannot write a non-number as a number');\n\n assert.ok(value >= 0,\n 'specified a negative value for writing an unsigned value');\n\n assert.ok(value <= max, 'value is larger than maximum value for type');\n\n assert.ok(Math.floor(value) === value, 'value has a fractional component');\n}\n\nBuffer.prototype.writeUInt8 = function(value, offset, noAssert) {\n var buffer = this;\n\n if (!noAssert) {\n assert.ok(value !== undefined && value !== null,\n 'missing value');\n\n assert.ok(offset !== undefined && offset !== null,\n 'missing offset');\n\n assert.ok(offset < buffer.length,\n 'trying to write beyond buffer length');\n\n verifuint(value, 0xff);\n }\n\n buffer[offset] = value;\n};\n\nfunction writeUInt16(buffer, value, offset, isBigEndian, noAssert) {\n if (!noAssert) {\n assert.ok(value !== undefined && value !== null,\n 'missing value');\n\n assert.ok(typeof (isBigEndian) === 'boolean',\n 'missing or invalid endian');\n\n assert.ok(offset !== undefined && offset !== null,\n 'missing offset');\n\n assert.ok(offset + 1 < buffer.length,\n 'trying to write beyond buffer length');\n\n verifuint(value, 0xffff);\n }\n\n if (isBigEndian) {\n buffer[offset] = (value & 0xff00) >>> 8;\n buffer[offset + 1] = value & 0x00ff;\n } else {\n buffer[offset + 1] = (value & 0xff00) >>> 8;\n buffer[offset] = value & 0x00ff;\n }\n}\n\nBuffer.prototype.writeUInt16LE = function(value, offset, noAssert) {\n writeUInt16(this, value, offset, false, noAssert);\n};\n\nBuffer.prototype.writeUInt16BE = function(value, offset, noAssert) {\n writeUInt16(this, value, offset, true, noAssert);\n};\n\nfunction writeUInt32(buffer, value, offset, isBigEndian, noAssert) {\n if (!noAssert) {\n assert.ok(value !== undefined && value !== null,\n 'missing value');\n\n assert.ok(typeof (isBigEndian) === 'boolean',\n 'missing or invalid endian');\n\n assert.ok(offset !== undefined && offset !== null,\n 'missing offset');\n\n assert.ok(offset + 3 < buffer.length,\n 'trying to write beyond buffer length');\n\n verifuint(value, 0xffffffff);\n }\n\n if (isBigEndian) {\n buffer[offset] = (value >>> 24) & 0xff;\n buffer[offset + 1] = (value >>> 16) & 0xff;\n buffer[offset + 2] = (value >>> 8) & 0xff;\n buffer[offset + 3] = value & 0xff;\n } else {\n buffer[offset + 3] = (value >>> 24) & 0xff;\n buffer[offset + 2] = (value >>> 16) & 0xff;\n buffer[offset + 1] = (value >>> 8) & 0xff;\n buffer[offset] = value & 0xff;\n }\n}\n\nBuffer.prototype.writeUInt32LE = function(value, offset, noAssert) {\n writeUInt32(this, value, offset, false, noAssert);\n};\n\nBuffer.prototype.writeUInt32BE = function(value, offset, noAssert) {\n writeUInt32(this, value, offset, true, noAssert);\n};\n\n\n/*\n * We now move onto our friends in the signed number category. Unlike unsigned\n * numbers, we're going to have to worry a bit more about how we put values into\n * arrays. Since we are only worrying about signed 32-bit values, we're in\n * slightly better shape. Unfortunately, we really can't do our favorite binary\n * & in this system. It really seems to do the wrong thing. For example:\n *\n * > -32 & 0xff\n * 224\n *\n * What's happening above is really: 0xe0 & 0xff = 0xe0. However, the results of\n * this aren't treated as a signed number. Ultimately a bad thing.\n *\n * What we're going to want to do is basically create the unsigned equivalent of\n * our representation and pass that off to the wuint* functions. To do that\n * we're going to do the following:\n *\n * - if the value is positive\n * we can pass it directly off to the equivalent wuint\n * - if the value is negative\n * we do the following computation:\n * mb + val + 1, where\n * mb is the maximum unsigned value in that byte size\n * val is the Javascript negative integer\n *\n *\n * As a concrete value, take -128. In signed 16 bits this would be 0xff80. If\n * you do out the computations:\n *\n * 0xffff - 128 + 1\n * 0xffff - 127\n * 0xff80\n *\n * You can then encode this value as the signed version. This is really rather\n * hacky, but it should work and get the job done which is our goal here.\n */\n\n/*\n * A series of checks to make sure we actually have a signed 32-bit number\n */\nfunction verifsint(value, max, min) {\n assert.ok(typeof (value) == 'number',\n 'cannot write a non-number as a number');\n\n assert.ok(value <= max, 'value larger than maximum allowed value');\n\n assert.ok(value >= min, 'value smaller than minimum allowed value');\n\n assert.ok(Math.floor(value) === value, 'value has a fractional component');\n}\n\nfunction verifIEEE754(value, max, min) {\n assert.ok(typeof (value) == 'number',\n 'cannot write a non-number as a number');\n\n assert.ok(value <= max, 'value larger than maximum allowed value');\n\n assert.ok(value >= min, 'value smaller than minimum allowed value');\n}\n\nBuffer.prototype.writeInt8 = function(value, offset, noAssert) {\n var buffer = this;\n\n if (!noAssert) {\n assert.ok(value !== undefined && value !== null,\n 'missing value');\n\n assert.ok(offset !== undefined && offset !== null,\n 'missing offset');\n\n assert.ok(offset < buffer.length,\n 'Trying to write beyond buffer length');\n\n verifsint(value, 0x7f, -0x80);\n }\n\n if (value >= 0) {\n buffer.writeUInt8(value, offset, noAssert);\n } else {\n buffer.writeUInt8(0xff + value + 1, offset, noAssert);\n }\n};\n\nfunction writeInt16(buffer, value, offset, isBigEndian, noAssert) {\n if (!noAssert) {\n assert.ok(value !== undefined && value !== null,\n 'missing value');\n\n assert.ok(typeof (isBigEndian) === 'boolean',\n 'missing or invalid endian');\n\n assert.ok(offset !== undefined && offset !== null,\n 'missing offset');\n\n assert.ok(offset + 1 < buffer.length,\n 'Trying to write beyond buffer length');\n\n verifsint(value, 0x7fff, -0x8000);\n }\n\n if (value >= 0) {\n writeUInt16(buffer, value, offset, isBigEndian, noAssert);\n } else {\n writeUInt16(buffer, 0xffff + value + 1, offset, isBigEndian, noAssert);\n }\n}\n\nBuffer.prototype.writeInt16LE = function(value, offset, noAssert) {\n writeInt16(this, value, offset, false, noAssert);\n};\n\nBuffer.prototype.writeInt16BE = function(value, offset, noAssert) {\n writeInt16(this, value, offset, true, noAssert);\n};\n\nfunction writeInt32(buffer, value, offset, isBigEndian, noAssert) {\n if (!noAssert) {\n assert.ok(value !== undefined && value !== null,\n 'missing value');\n\n assert.ok(typeof (isBigEndian) === 'boolean',\n 'missing or invalid endian');\n\n assert.ok(offset !== undefined && offset !== null,\n 'missing offset');\n\n assert.ok(offset + 3 < buffer.length,\n 'Trying to write beyond buffer length');\n\n verifsint(value, 0x7fffffff, -0x80000000);\n }\n\n if (value >= 0) {\n writeUInt32(buffer, value, offset, isBigEndian, noAssert);\n } else {\n writeUInt32(buffer, 0xffffffff + value + 1, offset, isBigEndian, noAssert);\n }\n}\n\nBuffer.prototype.writeInt32LE = function(value, offset, noAssert) {\n writeInt32(this, value, offset, false, noAssert);\n};\n\nBuffer.prototype.writeInt32BE = function(value, offset, noAssert) {\n writeInt32(this, value, offset, true, noAssert);\n};\n\nfunction writeFloat(buffer, value, offset, isBigEndian, noAssert) {\n if (!noAssert) {\n assert.ok(value !== undefined && value !== null,\n 'missing value');\n\n assert.ok(typeof (isBigEndian) === 'boolean',\n 'missing or invalid endian');\n\n assert.ok(offset !== undefined && offset !== null,\n 'missing offset');\n\n assert.ok(offset + 3 < buffer.length,\n 'Trying to write beyond buffer length');\n\n verifIEEE754(value, 3.4028234663852886e+38, -3.4028234663852886e+38);\n }\n\n require('./buffer_ieee754').writeIEEE754(buffer, value, offset, isBigEndian,\n 23, 4);\n}\n\nBuffer.prototype.writeFloatLE = function(value, offset, noAssert) {\n writeFloat(this, value, offset, false, noAssert);\n};\n\nBuffer.prototype.writeFloatBE = function(value, offset, noAssert) {\n writeFloat(this, value, offset, true, noAssert);\n};\n\nfunction writeDouble(buffer, value, offset, isBigEndian, noAssert) {\n if (!noAssert) {\n assert.ok(value !== undefined && value !== null,\n 'missing value');\n\n assert.ok(typeof (isBigEndian) === 'boolean',\n 'missing or invalid endian');\n\n assert.ok(offset !== undefined && offset !== null,\n 'missing offset');\n\n assert.ok(offset + 7 < buffer.length,\n 'Trying to write beyond buffer length');\n\n verifIEEE754(value, 1.7976931348623157E+308, -1.7976931348623157E+308);\n }\n\n require('./buffer_ieee754').writeIEEE754(buffer, value, offset, isBigEndian,\n 52, 8);\n}\n\nBuffer.prototype.writeDoubleLE = function(value, offset, noAssert) {\n writeDouble(this, value, offset, false, noAssert);\n};\n\nBuffer.prototype.writeDoubleBE = function(value, offset, noAssert) {\n writeDouble(this, value, offset, true, noAssert);\n};\n\nSlowBuffer.prototype.readUInt8 = Buffer.prototype.readUInt8;\nSlowBuffer.prototype.readUInt16LE = Buffer.prototype.readUInt16LE;\nSlowBuffer.prototype.readUInt16BE = Buffer.prototype.readUInt16BE;\nSlowBuffer.prototype.readUInt32LE = Buffer.prototype.readUInt32LE;\nSlowBuffer.prototype.readUInt32BE = Buffer.prototype.readUInt32BE;\nSlowBuffer.prototype.readInt8 = Buffer.prototype.readInt8;\nSlowBuffer.prototype.readInt16LE = Buffer.prototype.readInt16LE;\nSlowBuffer.prototype.readInt16BE = Buffer.prototype.readInt16BE;\nSlowBuffer.prototype.readInt32LE = Buffer.prototype.readInt32LE;\nSlowBuffer.prototype.readInt32BE = Buffer.prototype.readInt32BE;\nSlowBuffer.prototype.readFloatLE = Buffer.prototype.readFloatLE;\nSlowBuffer.prototype.readFloatBE = Buffer.prototype.readFloatBE;\nSlowBuffer.prototype.readDoubleLE = Buffer.prototype.readDoubleLE;\nSlowBuffer.prototype.readDoubleBE = Buffer.prototype.readDoubleBE;\nSlowBuffer.prototype.writeUInt8 = Buffer.prototype.writeUInt8;\nSlowBuffer.prototype.writeUInt16LE = Buffer.prototype.writeUInt16LE;\nSlowBuffer.prototype.writeUInt16BE = Buffer.prototype.writeUInt16BE;\nSlowBuffer.prototype.writeUInt32LE = Buffer.prototype.writeUInt32LE;\nSlowBuffer.prototype.writeUInt32BE = Buffer.prototype.writeUInt32BE;\nSlowBuffer.prototype.writeInt8 = Buffer.prototype.writeInt8;\nSlowBuffer.prototype.writeInt16LE = Buffer.prototype.writeInt16LE;\nSlowBuffer.prototype.writeInt16BE = Buffer.prototype.writeInt16BE;\nSlowBuffer.prototype.writeInt32LE = Buffer.prototype.writeInt32LE;\nSlowBuffer.prototype.writeInt32BE = Buffer.prototype.writeInt32BE;\nSlowBuffer.prototype.writeFloatLE = Buffer.prototype.writeFloatLE;\nSlowBuffer.prototype.writeFloatBE = Buffer.prototype.writeFloatBE;\nSlowBuffer.prototype.writeDoubleLE = Buffer.prototype.writeDoubleLE;\nSlowBuffer.prototype.writeDoubleBE = Buffer.prototype.writeDoubleBE;\n\n//@ sourceURL=/node_modules/buffer-browserify/index.js"));
require.define("assert",Function(['require','module','exports','__dirname','__filename','process'],"// UTILITY\nvar util = require('util');\nvar Buffer = require(\"buffer\").Buffer;\nvar pSlice = Array.prototype.slice;\n\n// 1. The assert module provides functions that throw\n// AssertionError's when particular conditions are not met. The\n// assert module must conform to the following interface.\n\nvar assert = module.exports = ok;\n\n// 2. The AssertionError is defined in assert.\n// new assert.AssertionError({ message: message,\n// actual: actual,\n// expected: expected })\n\nassert.AssertionError = function AssertionError(options) {\n this.name = 'AssertionError';\n this.message = options.message;\n this.actual = options.actual;\n this.expected = options.expected;\n this.operator = options.operator;\n var stackStartFunction = options.stackStartFunction || fail;\n\n if (Error.captureStackTrace) {\n Error.captureStackTrace(this, stackStartFunction);\n }\n};\nutil.inherits(assert.AssertionError, Error);\n\nfunction replacer(key, value) {\n if (value === undefined) {\n return '' + value;\n }\n if (typeof value === 'number' && (isNaN(value) || !isFinite(value))) {\n return value.toString();\n }\n if (typeof value === 'function' || value instanceof RegExp) {\n return value.toString();\n }\n return value;\n}\n\nfunction truncate(s, n) {\n if (typeof s == 'string') {\n return s.length < n ? s : s.slice(0, n);\n } else {\n return s;\n }\n}\n\nassert.AssertionError.prototype.toString = function() {\n if (this.message) {\n return [this.name + ':', this.message].join(' ');\n } else {\n return [\n this.name + ':',\n truncate(JSON.stringify(this.actual, replacer), 128),\n this.operator,\n truncate(JSON.stringify(this.expected, replacer), 128)\n ].join(' ');\n }\n};\n\n// assert.AssertionError instanceof Error\n\nassert.AssertionError.__proto__ = Error.prototype;\n\n// At present only the three keys mentioned above are used and\n// understood by the spec. Implementations or sub modules can pass\n// other keys to the AssertionError's constructor - they will be\n// ignored.\n\n// 3. All of the following functions must throw an AssertionError\n// when a corresponding condition is not met, with a message that\n// may be undefined if not provided. All assertion methods provide\n// both the actual and expected values to the assertion error for\n// display purposes.\n\nfunction fail(actual, expected, message, operator, stackStartFunction) {\n throw new assert.AssertionError({\n message: message,\n actual: actual,\n expected: expected,\n operator: operator,\n stackStartFunction: stackStartFunction\n });\n}\n\n// EXTENSION! allows for well behaved errors defined elsewhere.\nassert.fail = fail;\n\n// 4. Pure assertion tests whether a value is truthy, as determined\n// by !!guard.\n// assert.ok(guard, message_opt);\n// This statement is equivalent to assert.equal(true, guard,\n// message_opt);. To test strictly for the value true, use\n// assert.strictEqual(true, guard, message_opt);.\n\nfunction ok(value, message) {\n if (!!!value) fail(value, true, message, '==', assert.ok);\n}\nassert.ok = ok;\n\n// 5. The equality assertion tests shallow, coercive equality with\n// ==.\n// assert.equal(actual, expected, message_opt);\n\nassert.equal = function equal(actual, expected, message) {\n if (actual != expected) fail(actual, expected, message, '==', assert.equal);\n};\n\n// 6. The non-equality assertion tests for whether two objects are not equal\n// with != assert.notEqual(actual, expected, message_opt);\n\nassert.notEqual = function notEqual(actual, expected, message) {\n if (actual == expected) {\n fail(actual, expected, message, '!=', assert.notEqual);\n }\n};\n\n// 7. The equivalence assertion tests a deep equality relation.\n// assert.deepEqual(actual, expected, message_opt);\n\nassert.deepEqual = function deepEqual(actual, expected, message) {\n if (!_deepEqual(actual, expected)) {\n fail(actual, expected, message, 'deepEqual', assert.deepEqual);\n }\n};\n\nfunction _deepEqual(actual, expected) {\n // 7.1. All identical values are equivalent, as determined by ===.\n if (actual === expected) {\n return true;\n\n } else if (Buffer.isBuffer(actual) && Buffer.isBuffer(expected)) {\n if (actual.length != expected.length) return false;\n\n for (var i = 0; i < actual.length; i++) {\n if (actual[i] !== expected[i]) return false;\n }\n\n return true;\n\n // 7.2. If the expected value is a Date object, the actual value is\n // equivalent if it is also a Date object that refers to the same time.\n } else if (actual instanceof Date && expected instanceof Date) {\n return actual.getTime() === expected.getTime();\n\n // 7.3. Other pairs that do not both pass typeof value == 'object',\n // equivalence is determined by ==.\n } else if (typeof actual != 'object' && typeof expected != 'object') {\n return actual == expected;\n\n // 7.4. For all other Object pairs, including Array objects, equivalence is\n // determined by having the same number of owned properties (as verified\n // with Object.prototype.hasOwnProperty.call), the same set of keys\n // (although not necessarily the same order), equivalent values for every\n // corresponding key, and an identical 'prototype' property. Note: this\n // accounts for both named and indexed properties on Arrays.\n } else {\n return objEquiv(actual, expected);\n }\n}\n\nfunction isUndefinedOrNull(value) {\n return value === null || value === undefined;\n}\n\nfunction isArguments(object) {\n return Object.prototype.toString.call(object) == '[object Arguments]';\n}\n\nfunction objEquiv(a, b) {\n if (isUndefinedOrNull(a) || isUndefinedOrNull(b))\n return false;\n // an identical 'prototype' property.\n if (a.prototype !== b.prototype) return false;\n //~~~I've managed to break Object.keys through screwy arguments passing.\n // Converting to array solves the problem.\n if (isArguments(a)) {\n if (!isArguments(b)) {\n return false;\n }\n a = pSlice.call(a);\n b = pSlice.call(b);\n return _deepEqual(a, b);\n }\n try {\n var ka = Object.keys(a),\n kb = Object.keys(b),\n key, i;\n } catch (e) {//happens when one is a string literal and the other isn't\n return false;\n }\n // having the same number of owned properties (keys incorporates\n // hasOwnProperty)\n if (ka.length != kb.length)\n return false;\n //the same set of keys (although not necessarily the same order),\n ka.sort();\n kb.sort();\n //~~~cheap key test\n for (i = ka.length - 1; i >= 0; i--) {\n if (ka[i] != kb[i])\n return false;\n }\n //equivalent values for every corresponding key, and\n //~~~possibly expensive deep test\n for (i = ka.length - 1; i >= 0; i--) {\n key = ka[i];\n if (!_deepEqual(a[key], b[key])) return false;\n }\n return true;\n}\n\n// 8. The non-equivalence assertion tests for any deep inequality.\n// assert.notDeepEqual(actual, expected, message_opt);\n\nassert.notDeepEqual = function notDeepEqual(actual, expected, message) {\n if (_deepEqual(actual, expected)) {\n fail(actual, expected, message, 'notDeepEqual', assert.notDeepEqual);\n }\n};\n\n// 9. The strict equality assertion tests strict equality, as determined by ===.\n// assert.strictEqual(actual, expected, message_opt);\n\nassert.strictEqual = function strictEqual(actual, expected, message) {\n if (actual !== expected) {\n fail(actual, expected, message, '===', assert.strictEqual);\n }\n};\n\n// 10. The strict non-equality assertion tests for strict inequality, as\n// determined by !==. assert.notStrictEqual(actual, expected, message_opt);\n\nassert.notStrictEqual = function notStrictEqual(actual, expected, message) {\n if (actual === expected) {\n fail(actual, expected, message, '!==', assert.notStrictEqual);\n }\n};\n\nfunction expectedException(actual, expected) {\n if (!actual || !expected) {\n return false;\n }\n\n if (expected instanceof RegExp) {\n return expected.test(actual);\n } else if (actual instanceof expected) {\n return true;\n } else if (expected.call({}, actual) === true) {\n return true;\n }\n\n return false;\n}\n\nfunction _throws(shouldThrow, block, expected, message) {\n var actual;\n\n if (typeof expected === 'string') {\n message = expected;\n expected = null;\n }\n\n try {\n block();\n } catch (e) {\n actual = e;\n }\n\n message = (expected && expected.name ? ' (' + expected.name + ').' : '.') +\n (message ? ' ' + message : '.');\n\n if (shouldThrow && !actual) {\n fail('Missing expected exception' + message);\n }\n\n if (!shouldThrow && expectedException(actual, expected)) {\n fail('Got unwanted exception' + message);\n }\n\n if ((shouldThrow && actual && expected &&\n !expectedException(actual, expected)) || (!shouldThrow && actual)) {\n throw actual;\n }\n}\n\n// 11. Expected to throw an error:\n// assert.throws(block, Error_opt, message_opt);\n\nassert.throws = function(block, /*optional*/error, /*optional*/message) {\n _throws.apply(this, [true].concat(pSlice.call(arguments)));\n};\n\n// EXTENSION! This is annoying to write outside this module.\nassert.doesNotThrow = function(block, /*optional*/error, /*optional*/message) {\n _throws.apply(this, [false].concat(pSlice.call(arguments)));\n};\n\nassert.ifError = function(err) { if (err) {throw err;}};\n\n//@ sourceURL=assert"));
require.define("/node_modules/buffer-browserify/node_modules/base64-js/package.json",Function(['require','module','exports','__dirname','__filename','process'],"module.exports = {\"main\":\"lib/b64.js\"}\n//@ sourceURL=/node_modules/buffer-browserify/node_modules/base64-js/package.json"));
require.define("/node_modules/buffer-browserify/node_modules/base64-js/lib/b64.js",Function(['require','module','exports','__dirname','__filename','process'],"(function (exports) {\n\t'use strict';\n\n\tvar lookup = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';\n\n\tfunction b64ToByteArray(b64) {\n\t\tvar i, j, l, tmp, placeHolders, arr;\n\t\n\t\tif (b64.length % 4 > 0) {\n\t\t\tthrow 'Invalid string. Length must be a multiple of 4';\n\t\t}\n\n\t\t// the number of equal signs (place holders)\n\t\t// if there are two placeholders, than the two characters before it\n\t\t// represent one byte\n\t\t// if there is only one, then the three characters before it represent 2 bytes\n\t\t// this is just a cheap hack to not do indexOf twice\n\t\tplaceHolders = b64.indexOf('=');\n\t\tplaceHolders = placeHolders > 0 ? b64.length - placeHolders : 0;\n\n\t\t// base64 is 4/3 + up to two characters of the original data\n\t\tarr = [];//new Uint8Array(b64.length * 3 / 4 - placeHolders);\n\n\t\t// if there are placeholders, only get up to the last complete 4 chars\n\t\tl = placeHolders > 0 ? b64.length - 4 : b64.length;\n\n\t\tfor (i = 0, j = 0; i < l; i += 4, j += 3) {\n\t\t\ttmp = (lookup.indexOf(b64[i]) << 18) | (lookup.indexOf(b64[i + 1]) << 12) | (lookup.indexOf(b64[i + 2]) << 6) | lookup.indexOf(b64[i + 3]);\n\t\t\tarr.push((tmp & 0xFF0000) >> 16);\n\t\t\tarr.push((tmp & 0xFF00) >> 8);\n\t\t\tarr.push(tmp & 0xFF);\n\t\t}\n\n\t\tif (placeHolders === 2) {\n\t\t\ttmp = (lookup.indexOf(b64[i]) << 2) | (lookup.indexOf(b64[i + 1]) >> 4);\n\t\t\tarr.push(tmp & 0xFF);\n\t\t} else if (placeHolders === 1) {\n\t\t\ttmp = (lookup.indexOf(b64[i]) << 10) | (lookup.indexOf(b64[i + 1]) << 4) | (lookup.indexOf(b64[i + 2]) >> 2);\n\t\t\tarr.push((tmp >> 8) & 0xFF);\n\t\t\tarr.push(tmp & 0xFF);\n\t\t}\n\n\t\treturn arr;\n\t}\n\n\tfunction uint8ToBase64(uint8) {\n\t\tvar i,\n\t\t\textraBytes = uint8.length % 3, // if we have 1 byte left, pad 2 bytes\n\t\t\toutput = \"\",\n\t\t\ttemp, length;\n\n\t\tfunction tripletToBase64 (num) {\n\t\t\treturn lookup[num >> 18 & 0x3F] + lookup[num >> 12 & 0x3F] + lookup[num >> 6 & 0x3F] + lookup[num & 0x3F];\n\t\t};\n\n\t\t// go through the array every three bytes, we'll deal with trailing stuff later\n\t\tfor (i = 0, length = uint8.length - extraBytes; i < length; i += 3) {\n\t\t\ttemp = (uint8[i] << 16) + (uint8[i + 1] << 8) + (uint8[i + 2]);\n\t\t\toutput += tripletToBase64(temp);\n\t\t}\n\n\t\t// pad the end with zeros, but make sure to not forget the extra bytes\n\t\tswitch (extraBytes) {\n\t\t\tcase 1:\n\t\t\t\ttemp = uint8[uint8.length - 1];\n\t\t\t\toutput += lookup[temp >> 2];\n\t\t\t\toutput += lookup[(temp << 4) & 0x3F];\n\t\t\t\toutput += '==';\n\t\t\t\tbreak;\n\t\t\tcase 2:\n\t\t\t\ttemp = (uint8[uint8.length - 2] << 8) + (uint8[uint8.length - 1]);\n\t\t\t\toutput += lookup[temp >> 10];\n\t\t\t\toutput += lookup[(temp >> 4) & 0x3F];\n\t\t\t\toutput += lookup[(temp << 2) & 0x3F];\n\t\t\t\toutput += '=';\n\t\t\t\tbreak;\n\t\t}\n\n\t\treturn output;\n\t}\n\n\tmodule.exports.toByteArray = b64ToByteArray;\n\tmodule.exports.fromByteArray = uint8ToBase64;\n}());\n\n//@ sourceURL=/node_modules/buffer-browserify/node_modules/base64-js/lib/b64.js"));
require.define("/node_modules/buffer-browserify/buffer_ieee754.js",Function(['require','module','exports','__dirname','__filename','process'],"exports.readIEEE754 = function(buffer, offset, isBE, mLen, nBytes) {\n var e, m,\n eLen = nBytes * 8 - mLen - 1,\n eMax = (1 << eLen) - 1,\n eBias = eMax >> 1,\n nBits = -7,\n i = isBE ? 0 : (nBytes - 1),\n d = isBE ? 1 : -1,\n s = buffer[offset + i];\n\n i += d;\n\n e = s & ((1 << (-nBits)) - 1);\n s >>= (-nBits);\n nBits += eLen;\n for (; nBits > 0; e = e * 256 + buffer[offset + i], i += d, nBits -= 8);\n\n m = e & ((1 << (-nBits)) - 1);\n e >>= (-nBits);\n nBits += mLen;\n for (; nBits > 0; m = m * 256 + buffer[offset + i], i += d, nBits -= 8);\n\n if (e === 0) {\n e = 1 - eBias;\n } else if (e === eMax) {\n return m ? NaN : ((s ? -1 : 1) * Infinity);\n } else {\n m = m + Math.pow(2, mLen);\n e = e - eBias;\n }\n return (s ? -1 : 1) * m * Math.pow(2, e - mLen);\n};\n\nexports.writeIEEE754 = function(buffer, value, offset, isBE, mLen, nBytes) {\n var e, m, c,\n eLen = nBytes * 8 - mLen - 1,\n eMax = (1 << eLen) - 1,\n eBias = eMax >> 1,\n rt = (mLen === 23 ? Math.pow(2, -24) - Math.pow(2, -77) : 0),\n i = isBE ? (nBytes - 1) : 0,\n d = isBE ? -1 : 1,\n s = value < 0 || (value === 0 && 1 / value < 0) ? 1 : 0;\n\n value = Math.abs(value);\n\n if (isNaN(value) || value === Infinity) {\n m = isNaN(value) ? 1 : 0;\n e = eMax;\n } else {\n e = Math.floor(Math.log(value) / Math.LN2);\n if (value * (c = Math.pow(2, -e)) < 1) {\n e--;\n c *= 2;\n }\n if (e + eBias >= 1) {\n value += rt / c;\n } else {\n value += rt * Math.pow(2, 1 - eBias);\n }\n if (value * c >= 2) {\n e++;\n c /= 2;\n }\n\n if (e + eBias >= eMax) {\n m = 0;\n e = eMax;\n } else if (e + eBias >= 1) {\n m = (value * c - 1) * Math.pow(2, mLen);\n e = e + eBias;\n } else {\n m = value * Math.pow(2, eBias - 1) * Math.pow(2, mLen);\n e = 0;\n }\n }\n\n for (; mLen >= 8; buffer[offset + i] = m & 0xff, i += d, m /= 256, mLen -= 8);\n\n e = (e << mLen) | m;\n eLen += mLen;\n for (; eLen > 0; buffer[offset + i] = e & 0xff, i += d, e /= 256, eLen -= 8);\n\n buffer[offset + i - d] |= s * 128;\n};\n\n//@ sourceURL=/node_modules/buffer-browserify/buffer_ieee754.js"));
require.define("/node_modules/delta-stream/node_modules/scuttlebutt/util.js",Function(['require','module','exports','__dirname','__filename','process'],"var map = require('iterate').map\n\nexports.createID = \nfunction createID () {\n return map(3, function (i) {\n return Math.random().toString(16).substring(2).toUpperCase()\n }).join('')\n}\n\n/*\nthis is just copied from crdt\n\nthis is NOT a wholly accurate representation of the time.\nsince js only measures time as ms, if you call Date.now()\ntwice quickly, it's possible to get two identical time stamps.\n\nsubsequent calls to timestamp() are ALWAYS strictly ordered.\n\nwhich is the important part.\n\nmaybe call this something other than timestamp?\n\nwhat about 'close-enough' since that's what it is.\n\nalso, it may be a very good idea to add something to syncronize\nnetwork time.\n\nI'm guessing you ping your time stamps back in time, and make the minimal adjustment so that all messages are measured to \narrive on one machine after the time they claim to make left the other machine.\n\nwill need to spin up a cluster to test this.\n*/\n\nexports.timestamp = timestamp\n\nvar _last = 0\nvar _count = 1\nvar LAST\nfunction timestamp () {\n var t = Date.now()\n var _t = t\n if(_last == t) {\n// while(_last == _t)\n _t += ((_count++)/1000) \n } \n else _count = 1 \n\n _last = t\n\n if(_t === LAST)\n throw new Error('LAST:' + LAST + ',' + _t)\n LAST = _t\n return _t\n}\n\nexports.filter = function (update, sources) {\n var ts = update[2]\n var source = update[3]\n return (!sources || !sources[source] || sources[source] < ts)\n}\n\n//@ sourceURL=/node_modules/delta-stream/node_modules/scuttlebutt/util.js"));
require.define("/node_modules/delta-stream/node_modules/scuttlebutt/node_modules/readable-stream/package.json",Function(['require','module','exports','__dirname','__filename','process'],"module.exports = {\"main\":\"readable.js\"}\n//@ sourceURL=/node_modules/delta-stream/node_modules/scuttlebutt/node_modules/readable-stream/package.json"));
require.define("/node_modules/delta-stream/node_modules/scuttlebutt/node_modules/readable-stream/readable.js",Function(['require','module','exports','__dirname','__filename','process'],"\"use strict\";\n\nmodule.exports = Readable;\n\nvar Stream = require('stream');\nvar util = require('util');\n\nutil.inherits(Readable, Stream);\n\nfunction Readable(stream) {\n if (stream) this.wrap(stream);\n Stream.apply(this);\n}\n\n// override this method.\nReadable.prototype.read = function(n) {\n return null;\n};\n\nReadable.prototype.pipe = function(dest, opt) {\n if (!(opt && opt.end === false || dest === process.stdout ||\n dest === process.stderr)) {\n this.on('end', dest.end.bind(dest));\n }\n\n dest.emit('pipe', this);\n\n flow.call(this);\n\n function flow() {\n var chunk;\n while (chunk = this.read()) {\n var written = dest.write(chunk);\n if (written === false) {\n dest.once('drain', flow.bind(this));\n return;\n }\n }\n this.once('readable', flow);\n }\n};\n\n// kludge for on('data', fn) consumers. Sad.\n// This is *not* part of the new readable stream interface.\n// It is an ugly unfortunate mess of history.\nReadable.prototype.on = function(ev, fn) {\n if (ev === 'data') emitDataEvents(this);\n return Stream.prototype.on.call(this, ev, fn);\n};\nReadable.prototype.addListener = Readable.prototype.on;\n\nfunction emitDataEvents(stream) {\n var paused = false;\n var readable = false;\n\n // convert to an old-style stream.\n stream.readable = true;\n stream.pipe = Stream.prototype.pipe;\n stream.on = stream.addEventListener = Stream.prototype.on;\n\n stream.on('readable', function() {\n readable = true;\n var c;\n while (!paused && (c = stream.read())) {\n stream.emit('data', c);\n }\n if (c === null) readable = false;\n });\n\n stream.pause = function() {\n paused = true;\n };\n\n stream.resume = function() {\n paused = false;\n if (readable) stream.emit('readable');\n };\n}\n\n// wrap an old-style stream\n// This is *not* part of the readable stream interface.\n// It is an ugly unfortunate mess of history.\nReadable.prototype.wrap = function(stream) {\n this._buffer = [];\n this._bufferLength = 0;\n var paused = false;\n var ended = false;\n\n stream.on('end', function() {\n ended = true;\n if (this._bufferLength === 0) {\n this.emit('end');\n }\n }.bind(this));\n\n stream.on('data', function(chunk) {\n this._buffer.push(chunk);\n this._bufferLength += chunk.length;\n this.emit('readable');\n // if not consumed, then pause the stream.\n if (this._bufferLength > 0 && !paused) {\n paused = true;\n stream.pause();\n }\n }.bind(this));\n\n // proxy all the other methods.\n // important when wrapping filters and duplexes.\n for (var i in stream) {\n if (typeof stream[i] === 'function' &&\n typeof this[i] === 'undefined') {\n this[i] = function(method) { return function() {\n return stream[method].apply(stream, arguments);\n }}(i);\n }\n }\n\n // proxy certain important events.\n var events = ['error', 'close', 'destroy', 'pause', 'resume'];\n events.forEach(function(ev) {\n stream.on(ev, this.emit.bind(this, ev));\n }.bind(this));\n\n // consume some bytes. if not all is consumed, then\n // pause the underlying stream.\n this.read = function(n) {\n var ret;\n\n if (this._bufferLength === 0) {\n ret = null;\n } else if (!n || n >= this._bufferLength) {\n // read it all\n ret = Buffer.concat(this._buffer);\n this._bufferLength = 0;\n this._buffer.length = 0;\n } else {\n // read just some of it.\n if (n < this._buffer[0].length) {\n // just take a part of the first buffer.\n var buf = this._buffer[0];\n ret = buf.slice(0, n);\n this._buffer[0] = buf.slice(n);\n } else if (n === this._buffer[0].length) {\n // first buffer is a perfect match\n ret = this._buffer.shift();\n } else {\n // complex case.\n ret = new Buffer(n);\n var c = 0;\n for (var i = 0; i < this._buffer.length && c < n; i++) {\n var buf = this._buffer[i];\n var cpy = Math.min(n - c, buf.length);\n buf.copy(ret, c, 0, cpy);\n if (cpy < buf.length) {\n this._buffer[i] = buf.slice(cpy);\n this._buffer = this._buffer.slice(i);\n }\n n -= cpy;\n }\n }\n this._bufferLength -= n;\n }\n\n if (this._bufferLength === 0) {\n if (paused) {\n stream.resume();\n paused = false;\n }\n if (ended) {\n process.nextTick(this.emit.bind(this, 'end'));\n }\n }\n return ret;\n };\n};\n\n//@ sourceURL=/node_modules/delta-stream/node_modules/scuttlebutt/node_modules/readable-stream/readable.js"));
require.define("/node_modules/delta-stream/node_modules/iterators/package.json",Function(['require','module','exports','__dirname','__filename','process'],"module.exports = {\"main\":\"index\"}\n//@ sourceURL=/node_modules/delta-stream/node_modules/iterators/package.json"));
require.define("/node_modules/delta-stream/node_modules/iterators/index.js",Function(['require','module','exports','__dirname','__filename','process'],"module.exports = {\n // sync\n forEachSync: require(\"./lib/sync/forEach\")\n , filterSync: require(\"./lib/sync/filter\")\n , mapSync: require(\"./lib/sync/map\")\n , reduceSync: require(\"./lib/sync/reduce\")\n , reduceRightSync: require(\"./lib/sync/reduceRight\")\n , everySync: require(\"./lib/sync/every\")\n , someSync: require(\"./lib/sync/some\")\n // async\n , forEach: require(\"./lib/async/forEach\")\n , filter: require(\"./lib/async/filter\")\n , map: require(\"./lib/async/map\")\n , reduce: require(\"./lib/async/reduce\")\n , reduceRight: require(\"./lib/async/reduceRight\")\n , every: require(\"./lib/async/every\")\n , some: require(\"./lib/async/some\")\n}\n//@ sourceURL=/node_modules/delta-stream/node_modules/iterators/index.js"));
require.define("/node_modules/delta-stream/node_modules/iterators/lib/sync/forEach.js",Function(['require','module','exports','__dirname','__filename','process'],"module.exports = forEach\n\nfunction forEach(list, iterator, context) {\n var keys = Object.keys(list)\n\n if (arguments.length < 3) {\n context = this\n }\n\n for (var i = 0, len = keys.length; i < len; i++) {\n var key = keys[i]\n , value = list[key]\n \n iterator.call(context, value, key, list)\n }\n}\n//@ sourceURL=/node_modules/delta-stream/node_modules/iterators/lib/sync/forEach.js"));
require.define("/node_modules/delta-stream/node_modules/iterators/lib/sync/filter.js",Function(['require','module','exports','__dirname','__filename','process'],"module.exports = filter\n\nfunction filter(list, iterator, context) {\n var returnValue = Array.isArray(list) ? [] : {}\n , keys = Object.keys(list)\n\n if (arguments.length < 3) {\n context = this\n }\n\n for (var i = 0, len = keys.length; i < len; i++) {\n var key = keys[i]\n , value = list[key]\n , keepValue = iterator.call(context, value, key, list)\n\n if (keepValue) {\n if (Array.isArray(returnValue)) {\n returnValue.push(value)\n } else {\n returnValue[key] = value\n }\n }\n }\n\n return returnValue\n}\n//@ sourceURL=/node_modules/delta-stream/node_modules/iterators/lib/sync/filter.js"));
require.define("/node_modules/delta-stream/node_modules/iterators/lib/sync/map.js",Function(['require','module','exports','__dirname','__filename','process'],"module.exports = map\n\nfunction map(list, iterator, context) {\n var returnValue = Array.isArray(list) ? [] : {}\n , keys = Object.keys(list)\n\n if (arguments.length < 3) {\n context = this\n }\n\n for (var i = 0, len = keys.length; i < len; i++) {\n var key = keys[i]\n , value = list[key]\n , newValue = iterator.call(context, value, key, list)\n\n returnValue[key] = newValue\n }\n\n return returnValue\n}\n//@ sourceURL=/node_modules/delta-stream/node_modules/iterators/lib/sync/map.js"));
require.define("/node_modules/delta-stream/node_modules/iterators/lib/sync/reduce.js",Function(['require','module','exports','__dirname','__filename','process'],"module.exports = reduce\n\nfunction reduce(list, iterator, context, accumulator) {\n var keys = Object.keys(list)\n , i = 0\n\n if (arguments.length === 2) {\n context = this\n accumulator = list[0]\n i = 1\n } else if (arguments.length === 3) {\n accumulator = context\n context = this\n }\n\n for (var len = keys.length; i < len; i++) {\n var key = keys[i]\n , value = list[key]\n\n accumulator = iterator.call(context, accumulator, value, key, list)\n }\n\n return accumulator\n}\n//@ sourceURL=/node_modules/delta-stream/node_modules/iterators/lib/sync/reduce.js"));
require.define("/node_modules/delta-stream/node_modules/iterators/lib/sync/reduceRight.js",Function(['require','module','exports','__dirname','__filename','process'],"module.exports = reduceRight\n\nfunction reduceRight(list, iterator, context, accumulator) {\n var keys = Object.keys(list)\n , len = keys.length\n , i = len - 1\n\n if (arguments.length === 2) {\n context = this\n accumulator = list[i]\n i--\n } else if (arguments.length === 3) {\n accumulator = context\n context = this\n }\n\n for (; i >= 0; i--) {\n var key = keys[i]\n , value = list[key]\n\n accumulator = iterator.call(context, accumulator, value, key, list)\n }\n\n return accumulator\n}\n//@ sourceURL=/node_modules/delta-stream/node_modules/iterators/lib/sync/reduceRight.js"));
require.define("/node_modules/delta-stream/node_modules/iterators/lib/sync/every.js",Function(['require','module','exports','__dirname','__filename','process'],"module.exports = every\n\nfunction every(list, iterator, context) {\n var keys = Object.keys(list)\n , result\n\n if (arguments.length < 3) {\n context = this\n }\n\n for (var i = 0, len = keys.length; i < len; i++) {\n var key = keys[i]\n , value = list[key]\n \n result = iterator.call(context, value, key, list)\n\n if (!result) {\n return result\n }\n }\n\n return result\n}\n//@ sourceURL=/node_modules/delta-stream/node_modules/iterators/lib/sync/every.js"));
require.define("/node_modules/delta-stream/node_modules/iterators/lib/sync/some.js",Function(['require','module','exports','__dirname','__filename','process'],"module.exports = some\n\nfunction some(list, iterator, context) {\n var keys = Object.keys(list)\n , result = false\n\n if (arguments.length < 3) {\n context = this\n }\n\n for (var i = 0, len = keys.length; i < len; i++) {\n var key = keys[i]\n , value = list[key]\n \n result = iterator.call(context, value, key, list)\n\n if (result) {\n return result\n }\n }\n\n return result\n}\n//@ sourceURL=/node_modules/delta-stream/node_modules/iterators/lib/sync/some.js"));
require.define("/node_modules/delta-stream/node_modules/iterators/lib/async/forEach.js",Function(['require','module','exports','__dirname','__filename','process'],"module.exports = forEach\n\nfunction forEach(list, iterator, context, callback) {\n var keys = Object.keys(list)\n , count = keys.length\n\n if (typeof context === \"function\") {\n callback = context\n context = this\n }\n\n for (var i = 0, len = keys.length; i < len; i++) {\n var key = keys[i]\n , value = list[key]\n \n invokeIterator(iterator, next, context, value, key, list)\n }\n\n function next(err) {\n if (err) {\n return callback && callback(err)\n }\n\n if (--count === 0) {\n callback && callback(null)\n }\n }\n}\n\nfunction invokeIterator(iterator, done, context, value, key, list) {\n var length = iterator.length\n\n if (length === 1) {\n iterator.call(context, done)\n } else if (length === 2) {\n iterator.call(context, value, done)\n } else if (length === 3) {\n iterator.call(context, value, key, done)\n } else {\n iterator.call(context, value, key, list, done)\n }\n}\n//@ sourceURL=/node_modules/delta-stream/node_modules/iterators/lib/async/forEach.js"));
require.define("/node_modules/delta-stream/node_modules/iterators/lib/async/filter.js",Function(['require','module','exports','__dirname','__filename','process'],"var partial = require(\"ap\").partial\n\nmodule.exports = filter\n\nfunction filter(list, iterator, context, callback) {\n var keys = Object.keys(list)\n , returnValue = Array.isArray(list) ? [] : {}\n , count = keys.length\n\n if (typeof context === \"function\") {\n callback = context\n context = this\n }\n\n for (var i = 0, len = keys.length; i < len; i++) {\n var key = keys[i]\n , value = list[key]\n \n invokeIterator(iterator,\n partial(next, value, key), context, value, key, list)\n }\n\n function next(value, key, err, keepValue) {\n if (err) {\n return callback && callback(err)\n }\n\n if (keepValue) {\n if (Array.isArray(returnValue)) {\n returnValue.push(value)\n } else {\n returnValue[key] = value\n }\n }\n\n if (--count === 0) {\n callback && callback(null, returnValue)\n }\n }\n}\n\nfunction invokeIterator(iterator, done, context, value, key, list) {\n var length = iterator.length\n\n if (length === 1) {\n iterator.call(context, done)\n } else if (length === 2) {\n iterator.call(context, value, done)\n } else if (length === 3) {\n iterator.call(context, value, key, done)\n } else {\n iterator.call(context, value, key, list, done)\n }\n}\n//@ sourceURL=/node_modules/delta-stream/node_modules/iterators/lib/async/filter.js"));
require.define("/node_modules/delta-stream/node_modules/iterators/lib/async/map.js",Function(['require','module','exports','__dirname','__filename','process'],"var partial = require(\"ap\").partial\n\nmodule.exports = map\n\nfunction map(list, iterator, context, callback) {\n var keys = Object.keys(list)\n , returnValue = Array.isArray(list) ? [] : {}\n , count = keys.length\n\n if (typeof context === \"function\") {\n callback = context\n context = this\n }\n\n for (var i = 0, len = keys.length; i < len; i++) {\n var key = keys[i]\n , value = list[key]\n \n invokeIterator(iterator,\n partial(next, key), context, value, key, list)\n }\n\n function next(key, err, newValue) {\n if (err) {\n return callback && callback(err)\n }\n\n returnValue[key] = newValue\n\n if (--count === 0) {\n callback && callback(null, returnValue)\n }\n }\n}\n\nfunction invokeIterator(iterator, done, context, value, key, list) {\n var length = iterator.length\n\n if (length === 1) {\n iterator.call(context, done)\n } else if (length === 2) {\n iterator.call(context, value, done)\n } else if (length === 3) {\n iterator.call(context, value, key, done)\n } else {\n iterator.call(context, value, key, list, done)\n }\n}\n//@ sourceURL=/node_modules/delta-stream/node_modules/iterators/lib/async/map.js"));
require.define("/node_modules/delta-stream/node_modules/iterators/lib/async/reduce.js",Function(['require','module','exports','__dirname','__filename','process'],"module.exports = reduce\n\nfunction reduce(list, iterator, context, accumulator, callback) {\n var keys = Object.keys(list)\n , count = keys.length\n\n if (arguments.length === 3) {\n callback = context\n context = this\n accumulator = list[0]\n keys.shift()\n count--\n } else if (arguments.length === 4) {\n callback = accumulator\n accumulator = context\n context = this\n }\n\n go()\n\n function go() {\n var key = keys.shift()\n , value = list[key]\n\n invokeIterator(iterator, next, context, accumulator, value, key, list)\n }\n\n function next(err, value) {\n if (err) {\n return callback && callback(err)\n }\n\n accumulator = value\n\n if (--count === 0) {\n callback && callback(null, accumulator)\n } else {\n go()\n }\n }\n}\n\nfunction invokeIterator(iterator, done, context, acc, value, key, list) {\n var length = iterator.length\n\n if (length === 1) {\n iterator.call(context, done)\n } else if (length === 2) {\n iterator.call(context, acc, done)\n } else if (length === 3) {\n iterator.call(context, acc, value, done)\n } else if (length === 4) {\n iterator.call(context, acc, value, key, done)\n } else {\n iterator.call(context, acc, value, key, list, done)\n }\n}\n//@ sourceURL=/node_modules/delta-stream/node_modules/iterators/lib/async/reduce.js"));
require.define("/node_modules/delta-stream/node_modules/iterators/lib/async/reduceRight.js",Function(['require','module','exports','__dirname','__filename','process'],"module.exports = forEach\n\nfunction forEach(list, iterator, context, accumulator, callback) {\n var keys = Object.keys(list)\n , len = keys.length\n , count = keys.length\n\n if (arguments.length === 3) {\n callback = context\n context = this\n accumulator = list[len - 1]\n keys.pop()\n count--\n } else if (arguments.length === 4) {\n callback = accumulator\n accumulator = context\n context = this\n }\n\n go()\n\n function go() {\n var key = keys.pop()\n , value = list[key]\n\n invokeIterator(iterator, next, context, accumulator, value, key, list)\n }\n\n function next(err, value) {\n if (err) {\n return callback && callback(err)\n }\n\n accumulator = value\n\n if (--count === 0) {\n callback && callback(null, accumulator)\n } else {\n go()\n }\n }\n}\n\nfunction invokeIterator(iterator, done, context, acc, value, key, list) {\n var length = iterator.length\n\n if (length === 1) {\n iterator.call(context, done)\n } else if (length === 2) {\n iterator.call(context, acc, done)\n } else if (length === 3) {\n iterator.call(context, acc, value, done)\n } else if (length === 4) {\n iterator.call(context, acc, value, key, done)\n } else {\n iterator.call(context, acc, value, key, list, done)\n }\n}\n//@ sourceURL=/node_modules/delta-stream/node_modules/iterators/lib/async/reduceRight.js"));
require.define("/node_modules/delta-stream/node_modules/iterators/lib/async/every.js",Function(['require','module','exports','__dirname','__filename','process'],"module.exports = every\n\nfunction every(list, iterator, context, callback) {\n var keys = Object.keys(list)\n , count = keys.length\n\n if (typeof context === \"function\") {\n callback = context\n context = this\n }\n\n for (var i = 0, len = keys.length; i < len; i++) {\n var key = keys[i]\n , value = list[key]\n \n invokeIterator(iterator, next, context, value, key, list)\n }\n\n function next(err, result) {\n if (err) {\n return callback && callback(err)\n }\n\n if (!result) {\n return callback && callback(null, result)\n }\n\n if (--count === 0) {\n callback && callback(null, result)\n }\n }\n}\n\nfunction invokeIterator(iterator, done, context, value, key, list) {\n var length = iterator.length\n\n if (length === 1) {\n iterator.call(context, done)\n } else if (length === 2) {\n iterator.call(context, value, done)\n } else if (length === 3) {\n iterator.call(context, value, key, done)\n } else {\n iterator.call(context, value, key, list, done)\n }\n}\n//@ sourceURL=/node_modules/delta-stream/node_modules/iterators/lib/async/every.js"));
require.define("/node_modules/delta-stream/node_modules/iterators/lib/async/some.js",Function(['require','module','exports','__dirname','__filename','process'],"module.exports = forEach\n\nfunction forEach(list, iterator, context, callback) {\n var keys = Object.keys(list)\n , count = keys.length\n\n if (typeof context === \"function\") {\n callback = context\n context = this\n }\n\n for (var i = 0, len = keys.length; i < len; i++) {\n var key = keys[i]\n , value = list[key]\n \n invokeIterator(iterator, next, context, value, key, list)\n }\n\n function next(err, result) {\n if (err) {\n return callback && callback(err)\n }\n\n if (result) {\n return callback && callback(null, result)\n }\n\n if (--count === 0) {\n callback && callback(null, result)\n }\n }\n}\n\nfunction invokeIterator(iterator, done, context, value, key, list) {\n var length = iterator.length\n\n if (length === 1) {\n iterator.call(context, done)\n } else if (length === 2) {\n iterator.call(context, value, done)\n } else if (length === 3) {\n iterator.call(context, value, key, done)\n } else {\n iterator.call(context, value, key, list, done)\n }\n}\n//@ sourceURL=/node_modules/delta-stream/node_modules/iterators/lib/async/some.js"));
require.define("/node_modules/fragment/package.json",Function(['require','module','exports','__dirname','__filename','process'],"module.exports = {}\n//@ sourceURL=/node_modules/fragment/package.json"));
require.define("/node_modules/fragment/index.js",Function(['require','module','exports','__dirname','__filename','process'],"module.exports = Fragment\n\nfunction Fragment(html) {\n var div = document.createElement(\"div\"),\n fragment = document.createDocumentFragment()\n\n div.innerHTML = html\n\n while (div.hasChildNodes()) {\n fragment.appendChild(div.firstChild)\n }\n\n return fragment\n}\n//@ sourceURL=/node_modules/fragment/index.js"));
require.define("/example/index.js",Function(['require','module','exports','__dirname','__filename','process'],"var LiveReloadClient = require(\"live-reload\")\n , Widget = require(\"./demo\")\n\nWidget().appendTo(document.body)\n\nLiveReloadClient(8081)\n//@ sourceURL=/example/index.js"));
require("/example/index.js");
})();