Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

browser version compatible with 1.5.4

  • Loading branch information...
commit 84b878a4fab2c5616bd075c23ef2035bbd4af9c6 1 parent fbbe335
@Zoddy authored
Showing with 146 additions and 41 deletions.
  1. +144 −39 cushion.browser.js
  2. +2 −2 cushion.browser.min.js
View
183 cushion.browser.js
@@ -25,35 +25,35 @@ require._core = {
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');
@@ -73,10 +73,10 @@ require.resolve = (function () {
if (m) return m;
}
}
-
+
return loadAsFileSync(x + '/index');
}
-
+
function loadNodeModulesSync (x, start) {
var dirs = nodeModulesPathsSync(start);
for (var i = 0; i < dirs.length; i++) {
@@ -86,23 +86,23 @@ require.resolve = (function () {
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;
}
};
@@ -118,13 +118,13 @@ require.alias = function (from, to) {
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 + '/') {
@@ -139,17 +139,17 @@ require.alias = function (from, to) {
(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)];
@@ -173,7 +173,7 @@ require.alias = function (from, to) {
loaded : false,
parent: null
};
-
+
require.modules[filename] = function () {
require.cache[filename] = module_;
fn.call(
@@ -282,7 +282,7 @@ path = normalizeArray(filter(path.split('/'), function(p) {
if (path && trailingSlash) {
path += '/';
}
-
+
return (isAbsolute ? '/' : '') + path;
};
@@ -869,7 +869,7 @@ http.request = function (params, cb) {
if (!params) params = {};
if (!params.host) params.host = window.location.host.split(':')[0];
if (!params.port) params.port = window.location.port;
-
+
var req = new Request(new xhrHttp, params);
if (cb) req.on('response', cb);
return req;
@@ -1105,15 +1105,15 @@ var Request = module.exports = function (xhr, params) {
var self = this;
self.xhr = xhr;
self.body = concatStream()
-
+
var uri = params.host + ':' + params.port + (params.path || '/');
-
+
xhr.open(
params.method || 'GET',
(params.scheme || 'http') + '://' + uri,
true
);
-
+
if (params.headers) {
Object.keys(params.headers).forEach(function (key) {
if (!self.isSafeRequestHeader(key)) return;
@@ -1126,12 +1126,12 @@ var Request = module.exports = function (xhr, params) {
else xhr.setRequestHeader(key, value)
});
}
-
+
var res = new Response;
res.on('ready', function () {
self.emit('response', res);
});
-
+
xhr.onreadystatechange = function () {
res.handle(xhr);
};
@@ -1212,11 +1212,11 @@ function parseHeaders (res) {
for (var i = 0; i < lines.length; i++) {
var line = lines[i];
if (line === '') continue;
-
+
var m = line.match(/^([^:]+):\s*(.*)/);
if (m) {
var key = m[1].toLowerCase(), value = m[2];
-
+
if (headers[key] !== undefined) {
if ((Array.isArray && Array.isArray(headers[key]))
|| headers[key] instanceof Array) {
@@ -1257,7 +1257,7 @@ Response.prototype.handle = function (res) {
catch (err) {
capable.status2 = false;
}
-
+
if (capable.status2) {
this.emit('ready');
}
@@ -1271,7 +1271,7 @@ Response.prototype.handle = function (res) {
}
}
catch (err) {}
-
+
try {
this.write(res);
}
@@ -1285,7 +1285,7 @@ Response.prototype.handle = function (res) {
this.emit('ready');
}
this.write(res);
-
+
if (res.error) {
this.emit('error', this.getResponse(res));
}
@@ -2072,6 +2072,43 @@ Database.prototype.name = function() {
/**
+ * sets or gets the document revision limit
+ * if you set two arguments (limit and callback) it will use as a setter
+ * only with one argument (callback) it's a getter
+ *
+ * @param {number|function(error, limit)} limitOrCallback positive integer as a
+ * new setting for the revision limit or function that will be called, after
+ * getting the revision limit or if there was an error
+ * @param {?function(error, saved)} callback function that will be called, after
+ * setting the new revision limit or if there was an error
+ */
+Database.prototype.revisionLimit = function(limitOrCallback, callback) {
+ var limit = (callback) ? limitOrCallback : null,
+ options = {
+ 'method': (limit !== null) ? 'PUT' : 'GET',
+ 'path': this._name + '/_revs_limit'
+ };
+ callback = callback || limitOrCallback;
+
+ if (limit !== null) {
+ options.body = '' + limit;
+ }
+
+ options.callback = function(error, response) {
+ if (error) {
+ callback(error, null);
+ } else if (limit === null) {
+ callback(null, response);
+ } else {
+ callback(null, true);
+ }
+ };
+
+ this._connection.request(options);
+};
+
+
+/**
* retrieving a show function
*
* @param {string} design name of the design document, after the '_design/',
@@ -2117,14 +2154,67 @@ Database.prototype.show = function(
/**
+ * requests a temporary view
+ *
+ * @param {string} map map function for the view as a string not as a function
+ * @param {string|function(error, info, rows)} reduceOrCallback reduce function
+ * for the view as a string not as a function or function that will be
+ * called after retrieving the view or if there was an error
+ * @param {?function(error, info, rows)} callback function that will be called,
+ * after retrieving the view or if there was an error
+ */
+Database.prototype.temporaryView = function(
+ map,
+ reduceOrParamsOrCallback,
+ paramsOrCallback,
+ callback
+) {
+ var reduce = (typeof(reduceOrParamsOrCallback) === 'string') ?
+ reduceOrParamsOrCallback :
+ null,
+ params = (typeof(reduceOrParamsOrCallback) === 'object') ?
+ reduceOrParamsOrCallback :
+ paramsOrCallback,
+ body = {'map': map};
+ callback = callback || paramsOrCallback || reduceOrParamsOrCallback;
+ params = querystring.stringify(params, '&', '=');
+
+ if (reduce !== null) {
+ body.reduce = reduce;
+ }
+
+ this._connection.request({
+ 'method': 'POST',
+ 'path': this.name() + '/_temp_view' + ((params) ? '?' + params : ''),
+ 'body': body,
+ 'callback': function(error, response) {
+ var info = null,
+ rows = null;
+
+ if (error === null) {
+ info = {
+ 'total': response.total_rows,
+ 'offset': response.offset
+ };
+
+ rows = response.rows
+ }
+
+ callback(error, info, rows);
+ }
+ });
+};
+
+
+/**
* requests a view
*
* @param {string} design name of the design document, after the '_design/'
* @param {string} view name of the view
- * @param {object|function(error, info, array)} paramsOrCallback query
+ * @param {object|function(error, info, rows)} paramsOrCallback query
* parameters for the view, or function that will be call, after getting
* response from the view, or if there was an error
- * @param {?function(error, info, array)} callback function that will be
+ * @param {?function(error, info, rows)} callback function that will be
* called, after getting response from the view, or if there was an error
*/
Database.prototype.view = function(design, view, paramsOrCallback, callback) {
@@ -2139,8 +2229,7 @@ Database.prototype.view = function(design, view, paramsOrCallback, callback) {
'path': path + params,
'callback': (function(error, response) {
var info = null,
- documents = null,
- i;
+ rows = null;
if (error === null) {
info = {
@@ -2148,10 +2237,10 @@ Database.prototype.view = function(design, view, paramsOrCallback, callback) {
'offset': response.offset
};
- documents = response.rows;
+ rows = response.rows;
}
- callback(error, info, documents);
+ callback(error, info, rows);
}).bind(this)
});
};
@@ -2220,7 +2309,7 @@ exports.parse = function(str){
return String(str)
.split('&')
.reduce(function(ret, pair){
- try{
+ try{
pair = decodeURIComponent(pair.replace(/\+/g, ' '));
} catch(e) {
// ignore
@@ -2928,6 +3017,22 @@ Design.prototype.view = function(name, map, reduce) {
);
};
+
+/**
+ * returns some infos about the design document and the views
+ *
+ * @param {function(error, info)} callback function that will be called, after
+ * getting the infos or if there was an error
+ */
+Design.prototype.viewInfo = function(callback) {
+ this._connection.request({
+ 'method': 'GET',
+ 'path': this._database.name() + '/' + this._id + '/_info',
+ 'callback': callback
+ });
+};
+
+
exports.Design = Design;
});
@@ -3996,5 +4101,5 @@ cushion.prototype.version = function(callback) {
exports.Connection = cushion;
});
-window.cushion = require("/cushion.js");
+require("/cushion.js");
})();
View
4 cushion.browser.min.js
@@ -1,2 +1,2 @@
-(function(){var a=function(b,c){var d=a.resolve(b,c||"/"),e=a.modules[d];if(!e)throw new Error("Failed to resolve module "+b+", tried "+d);var f=a.cache[d],g=f?f.exports:e();return g};a.paths=[],a.modules={},a.cache={},a.extensions=[".js",".coffee",".json"],a._core={assert:!0,events:!0,fs:!0,path:!0,vm:!0},a.resolve=function(){return function(b,c){function h(b){b=d.normalize(b);if(a.modules[b])return b;for(var c=0;c<a.extensions.length;c++){var e=a.extensions[c];if(a.modules[b+e])return b+e}}function i(b){b=b.replace(/\/+$/,"");var c=d.normalize(b+"/package.json");if(a.modules[c]){var e=a.modules[c](),f=e.browserify;if(typeof f=="object"&&f.main){var g=h(d.resolve(b,f.main));if(g)return g}else if(typeof f=="string"){var g=h(d.resolve(b,f));if(g)return g}else if(e.main){var g=h(d.resolve(b,e.main));if(g)return g}}return h(b+"/index")}function j(a,b){var c=k(b);for(var d=0;d<c.length;d++){var e=c[d],f=h(e+"/"+a);if(f)return f;var g=i(e+"/"+a);if(g)return g}var f=h(a);if(f)return f}function k(a){var b;a==="/"?b=[""]:b=d.normalize(a).split("/");var c=[];for(var e=b.length-1;e>=0;e--){if(b[e]==="node_modules")continue;var f=b.slice(0,e+1).join("/")+"/node_modules";c.push(f)}return c}c||(c="/");if(a._core[b])return b;var d=a.modules.path();c=d.resolve("/",c);var e=c||"/";if(b.match(/^(?:\.\.?\/|\/)/)){var f=h(d.resolve(e,b))||i(d.resolve(e,b));if(f)return f}var g=j(b,e);if(g)return g;throw new Error("Cannot find module '"+b+"'")}}(),a.alias=function(b,c){var d=a.modules.path(),e=null;try{e=a.resolve(b+"/package.json","/")}catch(f){e=a.resolve(b,"/")}var g=d.dirname(e),h=(Object.keys||function(a){var b=[];for(var c in a)b.push(c);return b})(a.modules);for(var i=0;i<h.length;i++){var j=h[i];if(j.slice(0,g.length+1)===g+"/"){var k=j.slice(g.length);a.modules[c+k]=a.modules[g+k]}else j===g&&(a.modules[c]=a.modules[g])}},function(){var b={};a.define=function(c,d){a.modules.__browserify_process&&(b=a.modules.__browserify_process());var e=a._core[c]?"":a.modules.path().dirname(c),f=function(b){var c=a(b,e),d=a.cache[a.resolve(b,e)];return d&&d.parent===null&&(d.parent=g),c};f.resolve=function(b){return a.resolve(b,e)},f.modules=a.modules,f.define=a.define,f.cache=a.cache;var g={id:c,filename:c,exports:{},loaded:!1,parent:null};a.modules[c]=function(){return a.cache[c]=g,d.call(g.exports,f,g,g.exports,e,c,b),g.loaded=!0,g.exports}}}(),a.define("path",function(a,b,c,d,e,f){function g(a,b){var c=[];for(var d=0;d<a.length;d++)b(a[d],d,a)&&c.push(a[d]);return c}function h(a,b){var c=0;for(var d=a.length;d>=0;d--){var e=a[d];e=="."?a.splice(d,1):e===".."?(a.splice(d,1),c++):c&&(a.splice(d,1),c--)}if(b)for(;c--;c)a.unshift("..");return a}var i=/^(.+\/(?!$)|\/)?((?:.+?)?(\.[^.]*)?)$/;c.resolve=function(){var a="",b=!1;for(var c=arguments.length;c>=-1&&!b;c--){var d=c>=0?arguments[c]:f.cwd();if(typeof d!="string"||!d)continue;a=d+"/"+a,b=d.charAt(0)==="/"}return a=h(g(a.split("/"),function(a){return!!a}),!b).join("/"),(b?"/":"")+a||"."},c.normalize=function(a){var b=a.charAt(0)==="/",c=a.slice(-1)==="/";return a=h(g(a.split("/"),function(a){return!!a}),!b).join("/"),!a&&!b&&(a="."),a&&c&&(a+="/"),(b?"/":"")+a},c.join=function(){var a=Array.prototype.slice.call(arguments,0);return c.normalize(g(a,function(a,b){return a&&typeof a=="string"}).join("/"))},c.dirname=function(a){var b=i.exec(a)[1]||"",c=!1;return b?b.length===1||c&&b.length<=3&&b.charAt(1)===":"?b:b.substring(0,b.length-1):"."},c.basename=function(a,b){var c=i.exec(a)[2]||"";return b&&c.substr(-1*b.length)===b&&(c=c.substr(0,c.length-b.length)),c},c.extname=function(a){return i.exec(a)[3]||""}}),a.define("__browserify_process",function(a,b,c,d,e,f){var f=b.exports={};f.nextTick=function(){var a=typeof window!="undefined"&&window.setImmediate,b=typeof window!="undefined"&&window.postMessage&&window.addEventListener;if(a)return window.setImmediate;if(b){var c=[];return window.addEventListener("message",function(a){if(a.source===window&&a.data==="browserify-tick"){a.stopPropagation();if(c.length>0){var b=c.shift();b()}}},!0),function(a){c.push(a),window.postMessage("browserify-tick","*")}}return function(a){setTimeout(a,0)}}(),f.title="browser",f.browser=!0,f.env={},f.argv=[],f.binding=function(b){if(b==="evals")return a("vm");throw new Error("No such module. (Possibly not yet loaded)")},function(){var b="/",c;f.cwd=function(){return b},f.chdir=function(d){c||(c=a("path")),b=c.resolve(d,b)}}()}),a.define("/package.json",function(a,b,c,d,e,f){b.exports={main:"./cushion"}}),a.define("/cushion.js",function(a,b,c,d,e,f){var g=a("http"),h=a("./config.js"),i=a("./database.js").Database,j=a("./user.js").User,k=function(b,c,d,e,f){f=f||{},this._methodMatch=/^GET|PUT|POST|DELETE|HEAD|COPY$/i,this._options={host:b||h.host,port:c||h.port,username:d||h.username,password:e||h.password,secure:f.secure||h.secure,path:f.path?f.path+"/":h.path},this._options.secure===!0&&(g=a("https"))};k.prototype.activeTasks=function(a){this.request({method:"GET",path:"_active_tasks",callback:a})},k.prototype.config=function(a,b,c,d){var e=typeof a=="string"?a:null,f=typeof b=="string"?b:null,g=typeof c=="string"||typeof c=="number"||c===null?c:undefined,h;d=d||c||b||a,h={method:g!==undefined?g===null?"DELETE":"PUT":"GET",path:"_config"+(e?"/"+e:"")+(f?"/"+f:""),callback:function(a,b){a?b=null:b=g!==undefined?!0:b,d(a,b)}};if(typeof g=="string"||typeof g=="number")h.body='"'+g+'"';this.request(h)},k.prototype.createAdmin=function(a,b,c){this.config("admins",a,b,function(b,d){var e,f;d===!0?(e=this.database("_users"),f=e.document("org.couchdb.user:"+a),f.body("name",a),f.body("type","user"),f.body("roles",[]),f.save(function(a,b){a?c(a,null):c(a,!0)})):c(b,null)}.bind(this))},k.prototype.database=function(a){return new i(a,this)},k.prototype.deleteAdmin=function(a,b){this.config("admins",a,null,function(c,d){var e,f;d===!0?(e=this.database("_users"),f=e.document("org.couchdb.user:"+a),f.load(function(a,c){c?c.destroy(function(a,c){c?b(null,!0):b(a,null)}):b(a,null)})):b(c,null)}.bind(this))},k.prototype.listDatabases=function(a,b){var c=b?a:null;b=b||a,this.request({method:"GET",path:"_all_dbs",callback:function(a,d){a===null&&d!==null&&(c===!0&&(d=d.filter(function(a,b,c){return a[0]!=="_"})),d=d.map(function(a){return this.database(a)},this)),b(a,d)}.bind(this)})},k.prototype.log=function(a,b){var c=arguments.length>1?a:null;b=b||a,this.request({method:"GET",path:"_log"+(c?"?bytes="+c:""),callback:b})},k.prototype._request=function(a,b){var c="";b.on("data",function(a){c+=a}),b.on("end",function(){try{b.headers["content-type"]==="application/json"&&c.length>0&&(c=JSON.parse(c)),b.statusCode===404&&c.length===0&&(c={error:"not_found",reason:"missing"}),a(c.error?c:null,c.error?null:c,b.headers||null)}catch(d){a(d,null,null)}}.bind(this))},k.prototype.request=function(a){var b={host:this._options.host,port:this._options.port,method:typeof a.method=="string"&&a.method.match(this._methodMatch)!==null?a.method:"GET",path:"/"+this._options.path+(a.path||""),auth:this._options.username+":"+this._options.password,headers:a.headers||{}},c;b.headers.Accept=b.headers.Accept||"*/*,application/json",b.headers["Content-Type"]=b.headers["Content-Type"]||"application/json",c=g.request(b,this._request.bind(this,a.callback)),c.on("error",function(b){a.callback(b,null,null)}.bind(this)),a.body&&(typeof a.body=="object"?c.write(JSON.stringify(a.body)):c.write(a.body)),c.end()},k.prototype.restart=function(a){this.request({method:"POST",path:"_restart",callback:function(b,c){b&&b.code==="ECONNRESET"&&(b=null,c=!0),a(b,c)}})},k.prototype.stats=function(a){this.request({method:"GET",path:"_stats",callback:a})},k.prototype.user=function(){return new j(this)},k.prototype.uuids=function(a,b){var c=arguments.length>1?a:null;b=b||a,this.request({method:"GET",path:"_uuids"+(c?"?count="+c:""),callback:function(a,c){c&&(c=c.uuids),b(a,c)}})},k.prototype.version=function(a){this.request({method:"GET",path:"",callback:function(b,c){c!==null&&(c=c.version),a(b,c)}})},c.Connection=k}),a.define("http",function(a,b,c,d,e,f){b.exports=a("http-browserify")}),a.define("/node_modules/http-browserify/package.json",function(a,b,c,d,e,f){b.exports={main:"index.js",browserify:"index.js"}}),a.define("/node_modules/http-browserify/index.js",function(a,b,c,d,e,f){var g=b.exports,h=a("events").EventEmitter,i=a("./lib/request");g.request=function(a,b){a||(a={}),a.host||(a.host=window.location.host.split(":")[0]),a.port||(a.port=window.location.port);var c=new i(new j,a);return b&&c.on("response",b),c},g.get=function(a,b){a.method="GET";var c=g.request(a,b);return c.end(),c},g.Agent=function(){},g.Agent.defaultMaxSockets=4;var j=function(){if(typeof window=="undefined")throw new Error("no window object present");if(window.XMLHttpRequest)return window.XMLHttpRequest;if(window.ActiveXObject){var a=["Msxml2.XMLHTTP.6.0","Msxml2.XMLHTTP.3.0","Microsoft.XMLHTTP"];for(var b=0;b<a.length;b++)try{var c=new window.ActiveXObject(a[b]);return function(){if(c){var d=c;return c=null,d}return new window.ActiveXObject(a[b])}}catch(d){}throw new Error("ajax not supported in this browser")}throw new Error("ajax not supported in this browser")}()}),a.define("events",function(a,b,c,d,e,f){f.EventEmitter||(f.EventEmitter=function(){});var g=c.EventEmitter=f.EventEmitter,h=typeof Array.isArray=="function"?Array.isArray:function(a){return Object.prototype.toString.call(a)==="[object Array]"},i=10;g.prototype.setMaxListeners=function(a){this._events||(this._events={}),this._events.maxListeners=a},g.prototype.emit=function(a){if(a==="error")if(!this._events||!this._events.error||h(this._events.error)&&!this._events.error.length)throw arguments[1]instanceof Error?arguments[1]:new Error("Uncaught, unspecified 'error' event.");if(!this._events)return!1;var b=this._events[a];if(!b)return!1;if(typeof b=="function"){switch(arguments.length){case 1:b.call(this);break;case 2:b.call(this,arguments[1]);break;case 3:b.call(this,arguments[1],arguments[2]);break;default:var c=Array.prototype.slice.call(arguments,1);b.apply(this,c)}return!0}if(h(b)){var c=Array.prototype.slice.call(arguments,1),d=b.slice();for(var e=0,f=d.length;e<f;e++)d[e].apply(this,c);return!0}return!1},g.prototype.addListener=function(a,b){if("function"!=typeof b)throw new Error("addListener only takes instances of Function");this._events||(this._events={}),this.emit("newListener",a,b);if(!this._events[a])this._events[a]=b;else if(h(this._events[a])){if(!this._events[a].warned){var c;this._events.maxListeners!==undefined?c=this._events.maxListeners:c=i,c&&c>0&&this._events[a].length>c&&(this._events[a].warned=!0,console.error("(node) warning: possible EventEmitter memory leak detected. %d listeners added. Use emitter.setMaxListeners() to increase limit.",this._events[a].length),console.trace())}this._events[a].push(b)}else this._events[a]=[this._events[a],b];return this},g.prototype.on=g.prototype.addListener,g.prototype.once=function(a,b){var c=this;return c.on(a,function d(){c.removeListener(a,d),b.apply(this,arguments)}),this},g.prototype.removeListener=function(a,b){if("function"!=typeof b)throw new Error("removeListener only takes instances of Function");if(!this._events||!this._events[a])return this;var c=this._events[a];if(h(c)){var d=c.indexOf(b);if(d<0)return this;c.splice(d,1),c.length==0&&delete this._events[a]}else this._events[a]===b&&delete this._events[a];return this},g.prototype.removeAllListeners=function(a){return a&&this._events&&this._events[a]&&(this._events[a]=null),this},g.prototype.listeners=function(a){return this._events||(this._events={}),this._events[a]||(this._events[a]=[]),h(this._events[a])||(this._events[a]=[this._events[a]]),this._events[a]}}),a.define("/node_modules/http-browserify/lib/request.js",function(a,b,c,d,e,f){var g=a("events").EventEmitter,h=a("./response"),i=a("concat-stream"),j=b.exports=function(a,b){var c=this;c.xhr=a,c.body=i();var d=b.host+":"+b.port+(b.path||"/");a.open(b.method||"GET",(b.scheme||"http")+"://"+d,!0),b.headers&&Object.keys(b.headers).forEach(function(d){if(!c.isSafeRequestHeader(d))return;var e=b.headers[d];Array.isArray(e)?e.forEach(function(b){a.setRequestHeader(d,b)}):a.setRequestHeader(d,e)});var e=new h;e.on("ready",function(){c.emit("response",e)}),a.onreadystatechange=function(){e.handle(a)}};j.prototype=new g,j.prototype.setHeader=function(a,b){if(Array.isArray&&Array.isArray(b)||b instanceof Array)for(var c=0;c<b.length;c++)this.xhr.setRequestHeader(a,b[c]);else this.xhr.setRequestHeader(a,b)},j.prototype.write=function(a){this.body.write(a)},j.prototype.end=function(a){a!==undefined&&this.body.write(a),this.body.end(),this.xhr.send(this.body.getBody())},j.unsafeHeaders=["accept-charset","accept-encoding","access-control-request-headers","access-control-request-method","connection","content-length","cookie","cookie2","content-transfer-encoding","date","expect","host","keep-alive","origin","referer","te","trailer","transfer-encoding","upgrade","user-agent","via"],j.prototype.isSafeRequestHeader=function(a){return a?j.unsafeHeaders.indexOf(a.toLowerCase())===-1:!1}}),a.define("/node_modules/http-browserify/lib/response.js",function(a,b,c,d,e,f){function j(a){var b=a.getAllResponseHeaders().split(/\r?\n/),c={};for(var d=0;d<b.length;d++){var e=b[d];if(e==="")continue;var f=e.match(/^([^:]+):\s*(.*)/);if(f){var g=f[1].toLowerCase(),h=f[2];c[g]!==undefined?Array.isArray&&Array.isArray(c[g])||c[g]instanceof Array?c[g].push(h):c[g]=[c[g],h]:c[g]=h}else c[e]=!0}return c}var g=a("events").EventEmitter,h=b.exports=function(a){this.offset=0};h.prototype=new g;var i={streaming:!0,status2:!0};h.prototype.getResponse=function(a){var b=a.responseType.toLowerCase();return b==="blob"?a.responseBlob:b==="arraybuffer"?a.response:a.responseText},h.prototype.getHeader=function(a){return this.headers[a.toLowerCase()]},h.prototype.handle=function(a){if(a.readyState===2&&i.status2){try{this.statusCode=a.status,this.headers=j(a)}catch(b){i.status2=!1}i.status2&&this.emit("ready")}else if(i.streaming&&a.readyState===3){try{this.statusCode||(this.statusCode=a.status,this.headers=j(a),this.emit("ready"))}catch(b){}try{this.write(a)}catch(b){i.streaming=!1}}else a.readyState===4&&(this.statusCode||(this.statusCode=a.status,this.emit("ready")),this.write(a),a.error?this.emit("error",this.getResponse(a)):this.emit("end"))},h.prototype.write=function(a){var b=this.getResponse(a);if(b.toString().match(/ArrayBuffer/)){this.emit("data",new Uint8Array(b,this.offset)),this.offset=b.byteLength;return}b.length>this.offset&&(this.emit("data",b.slice(this.offset)),this.offset=b.length)}}),a.define("/node_modules/http-browserify/node_modules/concat-stream/package.json",function(a,b,c,d,e,f){b.exports={}}),a.define("/node_modules/http-browserify/node_modules/concat-stream/index.js",function(a,b,c,d,e,f){function i(a){g.Stream.call(this),this.writable=!0,a&&(this.cb=a),this.body=[],this.cb&&this.on("error",a)}var g=a("stream"),h=a("util");h.inherits(i,g.Stream),i.prototype.write=function(a){this.body.push(a)},i.prototype.arrayConcat=function(a){return a.length===0?[]:a.length===1?a[0]:a.reduce(function(a,b){return a.concat(b)})},i.prototype.isArray=function(a){var b=Array.isArray(a),c=a.toString().match(/Array/);return b||c},i.prototype.getBody=function(){if(this.body.length===0)return;return typeof this.body[0]=="string"?this.body.join(""):this.isArray(this.body[0])?this.arrayConcat(this.body):typeof Buffer!="undefined"&&Buffer.isBuffer(this.body[0])?Buffer.concat(this.body):this.body},i.prototype.end=function(){this.cb&&this.cb(!1,this.getBody())},b.exports=function(a){return new i(a)},b.exports.ConcatStream=i}),a.define("stream",function(a,b,c,d,e,f){function i(){g.EventEmitter.call(this)}var g=a("events"),h=a("util");h.inherits(i,g.EventEmitter),b.exports=i,i.Stream=i,i.prototype.pipe=function(a,b){function d(b){a.writable&&!1===a.write(b)&&c.pause&&c.pause()}function e(){c.readable&&c.resume&&c.resume()}function g(){if(f)return;f=!0,a._pipeCount--,j();if(a._pipeCount>0)return;a.end()}function h(){if(f)return;f=!0,a._pipeCount--,j();if(a._pipeCount>0)return;a.destroy()}function i(a){j();if(this.listeners("error").length===0)throw a}function j(){c.removeListener("data",d),a.removeListener("drain",e),c.removeListener("end",g),c.removeListener("close",h),c.removeListener("error",i),a.removeListener("error",i),c.removeListener("end",j),c.removeListener("close",j),a.removeListener("end",j),a.removeListener("close",j)}var c=this;c.on("data",d),a.on("drain",e),!a._isStdio&&(!b||b.end!==!1)&&(a._pipeCount=a._pipeCount||0,a._pipeCount++,c.on("end",g),c.on("close",h));var f=!1;return c.on("error",i),a.on("error",i),c.on("end",j),c.on("close",j),a.on("end",j),a.on("close",j),a.emit("pipe",c),a}}),a.define("util",function(a,b,c,d,e,f){function h(a){return a instanceof Array||Array.isArray(a)||a&&a!==Object.prototype&&h(a.__proto__)}function i(a){return a instanceof RegExp||typeof a=="object"&&Object.prototype.toString.call(a)==="[object RegExp]"}function j(a){if(a instanceof Date)return!0;if(typeof a!="object")return!1;var b=Date.prototype&&o(Date.prototype),c=a.__proto__&&o(a.__proto__);return JSON.stringify(c)===JSON.stringify(b)}function k(a){return a<10?"0"+a.toString(10):a.toString(10)}function m(){var a=new Date,b=[k(a.getHours()),k(a.getMinutes()),k(a.getSeconds())].join(":");return[a.getDate(),l[a.getMonth()],b].join(" ")}var g=a("events");c.print=function(){},c.puts=function(){},c.debug=function(){},c.inspect=function(a,b,d,e){function k(a,d){if(a&&typeof a.inspect=="function"&&a!==c&&(!a.constructor||a.constructor.prototype!==a))return a.inspect(d);switch(typeof a){case"undefined":return g("undefined","undefined");case"string":var e="'"+JSON.stringify(a).replace(/^"|"$/g,"").replace(/'/g,"\\'").replace(/\\"/g,'"')+"'";return g(e,"string");case"number":return g(""+a,"number");case"boolean":return g(""+a,"boolean")}if(a===null)return g("null","null");var l=n(a),m=b?o(a):l;if(typeof a=="function"&&m.length===0){if(i(a))return g(""+a,"regexp");var p=a.name?": "+a.name:"";return g("[Function"+p+"]","special")}if(j(a)&&m.length===0)return g(a.toUTCString(),"date");var q,r,s;h(a)?(r="Array",s=["[","]"]):(r="Object",s=["{","}"]);if(typeof a=="function"){var t=a.name?": "+a.name:"";q=i(a)?" "+a:" [Function"+t+"]"}else q="";j(a)&&(q=" "+a.toUTCString());if(m.length===0)return s[0]+q+s[1];if(d<0)return i(a)?g(""+a,"regexp"):g("[Object]","special");f.push(a);var u=m.map(function(b){var c,e;a.__lookupGetter__&&(a.__lookupGetter__(b)?a.__lookupSetter__(b)?e=g("[Getter/Setter]","special"):e=g("[Getter]","special"):a.__lookupSetter__(b)&&(e=g("[Setter]","special"))),l.indexOf(b)<0&&(c="["+b+"]"),e||(f.indexOf(a[b])<0?(d===null?e=k(a[b]):e=k(a[b],d-1),e.indexOf("\n")>-1&&(h(a)?e=e.split("\n").map(function(a){return" "+a}).join("\n").substr(2):e="\n"+e.split("\n").map(function(a){return" "+a}).join("\n"))):e=g("[Circular]","special"));if(typeof c=="undefined"){if(r==="Array"&&b.match(/^\d+$/))return e;c=JSON.stringify(""+b),c.match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)?(c=c.substr(1,c.length-2),c=g(c,"name")):(c=c.replace(/'/g,"\\'").replace(/\\"/g,'"').replace(/(^"|"$)/g,"'"),c=g(c,"string"))}return c+": "+e});f.pop();var v=0,w=u.reduce(function(a,b){return v++,b.indexOf("\n")>=0&&v++,a+b.length+1},0);return w>50?u=s[0]+(q===""?"":q+"\n ")+" "+u.join(",\n ")+" "+s[1]:u=s[0]+q+" "+u.join(", ")+" "+s[1],u}var f=[],g=function(a,b){var c={bold:[1,22],italic:[3,23],underline:[4,24],inverse:[7,27],white:[37,39],grey:[90,39],black:[30,39],blue:[34,39],cyan:[36,39],green:[32,39],magenta:[35,39],red:[31,39],yellow:[33,39]},d={special:"cyan",number:"blue","boolean":"yellow","undefined":"grey","null":"bold",string:"green",date:"magenta",regexp:"red"}[b];return d?"["+c[d][0]+"m"+a+"["+c[d][1]+"m":a};return e||(g=function(a,b){return a}),k(a,typeof d=="undefined"?2:d)};var l=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];c.log=function(a){},c.pump=null;var n=Object.keys||function(a){var b=[];for(var c in a)b.push(c);return b},o=Object.getOwnPropertyNames||function(a){var b=[];for(var c in a)Object.hasOwnProperty.call(a,c)&&b.push(c);return b},p=Object.create||function(a,b){var c;if(a===null)c={__proto__:null};else{if(typeof a!="object")throw new TypeError("typeof prototype["+typeof a+"] != 'object'");var d=function(){};d.prototype=a,c=new d,c.__proto__=a}return typeof b!="undefined"&&Object.defineProperties&&Object.defineProperties(c,b),c};c.inherits=function(a,b){a.super_=b,a.prototype=p(b.prototype,{constructor:{value:a,enumerable:!1,writable:!0,configurable:!0}})}}),a.define("/config.js",function(a,b,c,d,e,f){c.host="127.0.0.1",c.port=5984,c.username="",c.password="",c.secure=!1,c.path=""}),a.define("/database.js",function(a,b,c,d,e,f){var g=a("querystring"),h=a("./document.js").Document,i=a("./design.js").Design,j=function(a,b){this._name=a,this._connection=b};j.prototype.allDocuments=function(a,b){var c=typeof a=="object"?"?"+g.stringify(a,"&","="):"";b=b||a,this._connection.request({method:"GET",path:this.name()+"/_all_docs"+c,callback:function(a,c){var d,e={},f;if(a===null){d={total:c.total_rows,offset:c.offset};for(f=0;c.rows[f];++f)e[c.rows[f].id]=c.rows[f].value.rev}b(a,d,e)}.bind(this)})},j.prototype.cleanup=function(a){this._connection.request({method:"POST",path:this.name()+"/_view_cleanup",callback:function(b,c){a(b,c?!0:null)}})},j.prototype.compact=function(a,b){var c=b?a:undefined;b=b||a,this._connection.request({method:"POST",path:this.name()+"/_compact"+(c?"/"+c:""),callback:function(a,c){b(a,c?!0:null)}.bind(this)})},j.prototype.create=function(a){this._connection.request({method:"PUT",path:this.name(),callback:function(b,c){b===null&&c.ok===!0&&(c=!0),a(b,c)}.bind(this)})},j.prototype.destroy=function(a){this._connection.request({method:"DELETE",path:this.name(),callback:function(b,c){c&&c.ok===!0&&(c=!0),a(b,c)}})},j.prototype.document=function(a,b){var c=a&&a.match(/^_design\//)?i:h;return new c(a||null,b||null,this._connection,this)},j.prototype.exists=function(a){this._connection.request({method:"GET",path:this._name,callback:function(b,c){var d=!0;b&&b.error==="not_found"&&(b=null,d=!1),a(b,b===null?d:null)}})},j.prototype.info=function(a){this._connection.request({method:"GET",path:this._name,callback:a})},j.prototype.list=function(a,b,c,d,e,f){var h=typeof d=="object"?"?"+g.stringify(d,"&","="):typeof e=="object"?"?"+g.stringify(e,"&","="):"",i=typeof d=="string"?d:c,j=typeof d=="string"?"/"+c:"",k=this.name()+"/_design/"+a+"/_list/"+b+j+"/"+i+h;f=f||e||d,this._connection.request({method:"GET",path:k,callback:f})},j.prototype.name=function(){return this._name},j.prototype.show=function(a,b,c,d,e){var f=typeof c=="string"?"/"+c:"",h="";e=e||d||c,typeof c=="object"?h="?"+g.stringify(c,"&","="):typeof d=="object"&&(h="?"+g.stringify(d,"&","=")),this._connection.request({method:"GET",path:this._name+"/_design/"+a+"/_show/"+b+f+h,callback:e})},j.prototype.view=function(a,b,c,d){var e=typeof c=="object"?"?"+g.stringify(c,"&","="):"",f=this.name()+"/_design/"+a+"/_view/"+b;d=d||c,this._connection.request({method:"GET",path:f+e,callback:function(a,b){var c=null,e=null,f;a===null&&(c={total:b.total_rows,offset:b.offset},e=b.rows),d(a,c,e)}.bind(this)})},c.Database=j}),a.define("querystring",function(a,b,c,d,e,f){function l(a,b){if(!b)throw new TypeError("stringify expects an object");return b+"="+encodeURIComponent(a)}function m(a,b){var c=[];if(!b)throw new TypeError("stringify expects an object");for(var d=0;d<a.length;d++)c.push(k(a[d],b+"[]"));return c.join("&")}function n(a,b){var c=[],d=h(a),e;for(var f=0,g=d.length;f<g;++f)e=d[f],c.push(k(a[e],b?b+"["+encodeURIComponent(e)+"]":encodeURIComponent(e)));return c.join("&")}function o(a,b,c){var d=a[b];undefined===d?a[b]=c:g(d)?d.push(c):a[b]=[d,c]}function p(a){var b=a.length,c,d;for(var e=0;e<b;++e){d=a[e],"]"==d&&(c=!1),"["==d&&(c=!0);if("="==d&&!c)return e}}var g=typeof Array.isArray=="function"?Array.isArray:function(a){return Object.prototype.toString.call(a)==="[object Array]"},h=Object.keys||function(a){if(a!==Object(a))throw new TypeError("Invalid object");var b=[];for(var c in a)a.hasOwnProperty(c)&&(b[b.length]=c);return b};c.version="0.3.1";var i=Object.prototype.toString,j=/[^0-9]/;c.parse=function(a){function b(a,b){if(a[b].length==0)return a[b]={};var c={};for(var d in a[b])c[d]=a[b][d];return a[b]=c,c}return null==a||""==a?{}:String(a).split("&").reduce(function(a,c){try{c=decodeURIComponent(c.replace(/\+/g," "))}catch(d){}var e=c.indexOf("="),f=p(c),i=c.substr(0,f||e),k=c.substr(f||e,c.length),k=k.substr(k.indexOf("=")+1,k.length),l=a;""==i&&(i=c,k="");if(~i.indexOf("]")){var m=i.split("["),n=m.length,q=n-1;function r(a,c,d){var e=a.shift();e?(obj=c[d]=c[d]||[],"]"==e?g(obj)?""!=k&&obj.push(k):"object"==typeof obj?obj[h(obj).length]=k:obj=c[d]=[c[d],k]:~e.indexOf("]")?(e=e.substr(0,e.length-1),j.test(e)&&g(obj)&&(obj=b(c,d)),r(a,obj,e)):(j.test(e)&&g(obj)&&(obj=b(c,d)),r(a,obj,e))):g(c[d])?c[d].push(k):"object"==typeof c[d]?c[d]=k:"undefined"==typeof c[d]?c[d]=k:c[d]=[c[d],k]}r(m,l,"base")}else{if(j.test(i)&&g(l.base)){var s={};for(var t in l.base)s[t]=l.base[t];l.base=s}o(l.base,i,k)}return a},{base:{}}).base};var k=c.stringify=function(a,b){return g(a)?m(a,b):"[object Object]"==i.call(a)?n(a,b):"string"==typeof a?l(a,b):b}}),a.define("/document.js",function(a,b,c,d,e,f){var g=a("fs"),h=function(a,b,c,d){this._id=a,this._revision=b,this._connection=c,this._database=d,this._body={},this._error={noId:"no document id was set",noRevision:"no revision was set",noFile:"could not read file"}};h.prototype.body=function(){var a=Array.prototype.slice.call(arguments),b=a.splice(a.length-1,1)[0],c=this._body,d;return a&&a.length>0&&arguments.length>1?(a.forEach(function(a,d,e){d===e.length-1&&typeof b=="undefined"?delete c[a]:(c[a]=d===e.length-1?b:c[a]||{},c=c[a])}),d=this):a&&arguments.length>0?typeof b=="object"?(this._body=JSON.parse(JSON.stringify(b)),d=this):d=typeof this._body[b]=="object"?JSON.parse(JSON.stringify(this._body[b])):this._body[b]:d=JSON.parse(JSON.stringify(this._body)),d},h.prototype.copy=function(a,b,c){var d=c?"?rev="+b:"";c=c||b,this._id===null?f.nextTick(c({error:"no_copy",reason:this._error.noId},null,null)):this._connection.request({method:"COPY",headers:{Destination:a+d},path:this._database.name()+"/"+this._id+(this._revision?"?rev="+this._revision:""),callback:function(a,b){b&&(b=this._database.document(b.id,b.rev)),c(a,this,b)}.bind(this)})},h.prototype.deleteAttachment=function(a,b){this._connection.request({method:"DELETE",path:this._database.name()+"/"+this._id+"/"+a+"?rev="+this._revision,callback:function(a,c){a?c=!1:(this._revision=c.rev,c=!0),b(a,c)}.bind(this)})},h.prototype.destroy=function(a){this._id===null?f.nextTick(a({error:"no_delete",reason:this._error.noId},null)):this._revision===null?f.nextTick(a({error:"no_delete",reason:this._error.noRevision},null)):this._connection.request({method:"DELETE",path:this._database.name()+"/"+this._id+"?rev="+this._revision,callback:function(b,c){c&&(this._revision=c.rev),a(b,this)}.bind(this)})},h.prototype.getAttachment=function(a,b){this._connection.request({method:"GET",path:this._database.name()+"/"+this._id+"/"+a+"?rev="+this._revision,callback:b})},h.prototype.id=function(){return this._id},h.prototype.info=function(a){this._id===null?f.nextTick(a({error:"no_info",reason:"no document id was set"},null)):this._connection.request({method:"HEAD",path:this._database.name()+"/"+this._id,callback:function(b,c,d){var e=null;b===null&&(this._revision=d.etag.substr(1,d.etag.length-2),e={revision:this._revision,size:d["content-length"]}),a(b,e)}.bind(this)})},h.prototype.load=function(a){this._id===null?f.nextTick(a({error:"no_load",reason:this._error.noId},null)):this._connection.request({method:"GET",path:this._database.name()+"/"+this._id+(this._revision!==null?"?rev="+this._revision:""),callback:function(b,c){b===null&&this._saveContent(c),a(b,this)}.bind(this)})},h.prototype.revision=function(){return this._revision},h.prototype.save=function(a){var b=JSON.parse(JSON.stringify(this._body));this._revision!==null&&(b._rev=this._revision),this._connection.request({method:this._id===null?"POST":"PUT",path:this._database.name()+(this._id===null?"":"/"+this._id),body:b,callback:function(b,c){b===null&&(this._id=c.id,this._revision=c.rev),a(b,this)}.bind(this)})},h.prototype.saveAttachment=function(a,b,c,d){var e=typeof c=="string"?c:a.split("/").pop();d=d||c,g.readFile(a,"utf8",function(c,g){c?f.nextTick(d({error:"no_file",reason:this._error.noFile+": "+a},null)):this._connection.request({method:"PUT",path:this._database.name()+"/"+this._id+"/"+e+"?rev="+this._revision,headers:{"Content-Length":g.length,"Content-Type":b},body:g,callback:function(a,b){a?b=!1:(this._revision=b.rev,b=!0),d(a,b)}.bind(this)})}.bind(this))},h.prototype._saveContent=function(a){var b;a=JSON.parse(JSON.stringify(a)),this._body={};for(b in a)b[0]==="_"?b==="_rev"&&(this._revision=a[b]):this._body[b]=a[b]},c.Document=h}),a.define("fs",function(a,b,c,d,e,f){}),a.define("/design.js",function(a,b,c,d,e,f){var g=a("util"),h=a("./document.js").Document,i=function(a,b,c,d){h.call(this,a,b,c,d)};g.inherits(i,h),i.prototype.compact=function(a){this._database.compact(this._id.substr(8),a)},i.prototype.list=function(a,b){return b&&this.body("lists",a,b===null?undefined:b),b!==undefined?this:this._body.lists?this._body.lists[a]:undefined},i.prototype.show=function(a,b){return typeof b!==undefined&&this.body("shows",a,b===null?undefined:b),b!==undefined?this:this._body.shows?this._body.shows[a]:undefined},i.prototype.view=function(a,b,c){var d={};return c&&(d.reduce=c),b!==undefined&&(d.map=b,this.body("views",a,b===null?undefined:d)),b!==undefined?this:this._body.views?this._body.views[a]:undefined},c.Design=i}),a.define("/user.js",function(a,b,c,d,e,f){var g=a("crypto"),h=function(a){this._connection=a};h.prototype.addRole=function(a,b,c){var d=typeof b=="string"?[b]:b;this._connection.database("_users").document("org.couchdb.user:"+a).load(function(a,b){b.body("roles",b.body("roles").concat(d)).save(function(a,b){c(a,a?null:!0)})})},h.prototype.create=function(a,b,c,d){var e=typeof c=="object"?c:[],d=d||c,f;this._lower120(function(c,g){c?d(c,null):g===!0?(f=this._salt(),b=this._hash(b,f),this._connection.database("_users").document("org.couchdb.user:"+a).body({name:a,type:"user",roles:e,password_sha:b,salt:f}).save(function(a,b){d(a,a?null:!0)})):this._connection.database("_users").document("org.couchdb.user:"+a).body({name:a,type:"user",roles:e,password:b}).save(function(a,b){d(a,a?null:!0)})}.bind(this))},h.prototype.delete=function(a,b){var c=this._connection.database("_users").document("org.couchdb.user:"+a);c.info(function(a,d){a?b(a,null):c.destroy(function(a,c){b(a,a?null:!0)})})},h.prototype.deleteRole=function(a,b,c){var d=typeof b=="string"?[b]:b;this._connection.database("_users").document("org.couchdb.user:"+a).load(function(a,b){a?c(a,null):b.body("roles",b.body("roles").filter(function(a,b,c){return d.some(function(b,c,d){return b===a})})).save(function(a,b){c(a,a?null:!0)})})},h.prototype.getRoles=function(a,b){this._connection.database("_users").document("org.couchdb.user:"+a).load(function(a,c){b(a,a?null:c.body("roles"))})},h.prototype._hash=function(a,b){return g.createHash("sha1").update(a+b).digest("hex")},h.prototype._salt=function(){return g.randomBytes(16).toString("hex")},h.prototype._lower120=function(a){this._connection.version(function(b,c){b?a(b,null):(c=c.split(".").map(function(a,b,c){return parseInt(a,10)}),a(null,c[0]<1||c[0]===1&&c[1]<2))})},h.prototype.password=function(a,b,c){var d;this._connection.database("_users").document("org.couchdb.user:"+a).load(function(a,e){a?c(a,null):this._lower120(function(a,f){a?c(a,null):(f===!0?(d=this._salt(),b=this._hash(b,d),e.body("password_sha",b).body("salt",d)):e.body("password_sha",undefined).body("salt",undefined).body("password",b),e.save(function(a,b){c(a,a?null:!0)}))}.bind(this))}.bind(this))},c.User=h}),a.define("crypto",function(a,b,c,d,e,f){b.exports=a("crypto-browserify")}),a.define("/node_modules/crypto-browserify/package.json",function(a,b,c,d,e,f){b.exports={}}),a.define("/node_modules/crypto-browserify/index.js",function(a,b,c,d,e,f){function j(){var a=[].slice.call(arguments).join(" ");throw new Error([a,"we accept pull requests","http://github.com/dominictarr/crypto-browserify"].join("\n"))}var g=a("./sha"),h=a("./rng"),i={sha1:{hex:g.hex_sha1,binary:g.b64_sha1,ascii:g.str_sha1}};c.createHash=function(a){a=a||"sha1",i[a]||j("algorithm:",a,"is not yet supported");var b="",c=i[a];return{update:function(a){return b+=a,this},digest:function(d){d=d||"binary";var e;(e=c[d])||j("encoding:",d,"is not yet supported for algorithm"
-,a);var f=e(b);return b=null,f}}},c.randomBytes=function(a,b){if(!b||!b.call)return h(a);try{b.call(this,undefined,h(a))}catch(c){b(c)}},["createCredentials","createHmac","createCypher","createCypheriv","createDecipher","createDecipheriv","createSign","createVerify","createDeffieHellman","pbkdf2"].forEach(function(a){c[a]=function(){j("sorry,",a,"is not implemented yet")}})}),a.define("/node_modules/crypto-browserify/sha.js",function(a,b,c,d,e,f){function j(a){return y(q(w(a),a.length*i))}function k(a){return z(q(w(a),a.length*i))}function l(a){return x(q(w(a),a.length*i))}function m(a,b){return y(t(a,b))}function n(a,b){return z(t(a,b))}function o(a,b){return x(t(a,b))}function p(){return j("abc")=="a9993e364706816aba3e25717850c26c9cd0d89d"}function q(a,b){a[b>>5]|=128<<24-b%32,a[(b+64>>9<<4)+15]=b;var c=Array(80),d=1732584193,e=-271733879,f=-1732584194,g=271733878,h=-1009589776;for(var i=0;i<a.length;i+=16){var j=d,k=e,l=f,m=g,n=h;for(var o=0;o<80;o++){o<16?c[o]=a[i+o]:c[o]=v(c[o-3]^c[o-8]^c[o-14]^c[o-16],1);var p=u(u(v(d,5),r(o,e,f,g)),u(u(h,c[o]),s(o)));h=g,g=f,f=v(e,30),e=d,d=p}d=u(d,j),e=u(e,k),f=u(f,l),g=u(g,m),h=u(h,n)}return Array(d,e,f,g,h)}function r(a,b,c,d){return a<20?b&c|~b&d:a<40?b^c^d:a<60?b&c|b&d|c&d:b^c^d}function s(a){return a<20?1518500249:a<40?1859775393:a<60?-1894007588:-899497514}function t(a,b){var c=w(a);c.length>16&&(c=q(c,a.length*i));var d=Array(16),e=Array(16);for(var f=0;f<16;f++)d[f]=c[f]^909522486,e[f]=c[f]^1549556828;var g=q(d.concat(w(b)),512+b.length*i);return q(e.concat(g),672)}function u(a,b){var c=(a&65535)+(b&65535),d=(a>>16)+(b>>16)+(c>>16);return d<<16|c&65535}function v(a,b){return a<<b|a>>>32-b}function w(a){var b=Array(),c=(1<<i)-1;for(var d=0;d<a.length*i;d+=i)b[d>>5]|=(a.charCodeAt(d/i)&c)<<32-i-d%32;return b}function x(a){var b="",c=(1<<i)-1;for(var d=0;d<a.length*32;d+=i)b+=String.fromCharCode(a[d>>5]>>>32-i-d%32&c);return b}function y(a){var b=g?"0123456789ABCDEF":"0123456789abcdef",c="";for(var d=0;d<a.length*4;d++)c+=b.charAt(a[d>>2]>>(3-d%4)*8+4&15)+b.charAt(a[d>>2]>>(3-d%4)*8&15);return c}function z(a){var b="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",c="";for(var d=0;d<a.length*4;d+=3){var e=(a[d>>2]>>8*(3-d%4)&255)<<16|(a[d+1>>2]>>8*(3-(d+1)%4)&255)<<8|a[d+2>>2]>>8*(3-(d+2)%4)&255;for(var f=0;f<4;f++)d*8+f*6>a.length*32?c+=h:c+=b.charAt(e>>6*(3-f)&63)}return c}c.hex_sha1=j,c.b64_sha1=k,c.str_sha1=l,c.hex_hmac_sha1=m,c.b64_hmac_sha1=n,c.str_hmac_sha1=o;var g=0,h="",i=8}),a.define("/node_modules/crypto-browserify/rng.js",function(a,b,c,d,e,f){(function(){var a=this,c,d;c=function(a){var b=new Array(a),c;for(var d=0,c;d<a;d++)(d&3)==0&&(c=Math.random()*4294967296),b[d]=c>>>((d&3)<<3)&255;return b};if(a.crypto&&crypto.getRandomValues){var e=new Uint32Array(4);d=function(a){var b=new Array(a);crypto.getRandomValues(e);for(var c=0;c<a;c++)b[c]=e[c>>2]>>>(c&3)*8&255;return b}}b.exports=d||c})()}),a.define("https",function(a,b,c,d,e,f){b.exports=a("http")}),a.define("/cushion.js",function(a,b,c,d,e,f){var g=a("http"),h=a("./config.js"),i=a("./database.js").Database,j=a("./user.js").User,k=function(b,c,d,e,f){f=f||{},this._methodMatch=/^GET|PUT|POST|DELETE|HEAD|COPY$/i,this._options={host:b||h.host,port:c||h.port,username:d||h.username,password:e||h.password,secure:f.secure||h.secure,path:f.path?f.path+"/":h.path},this._options.secure===!0&&(g=a("https"))};k.prototype.activeTasks=function(a){this.request({method:"GET",path:"_active_tasks",callback:a})},k.prototype.config=function(a,b,c,d){var e=typeof a=="string"?a:null,f=typeof b=="string"?b:null,g=typeof c=="string"||typeof c=="number"||c===null?c:undefined,h;d=d||c||b||a,h={method:g!==undefined?g===null?"DELETE":"PUT":"GET",path:"_config"+(e?"/"+e:"")+(f?"/"+f:""),callback:function(a,b){a?b=null:b=g!==undefined?!0:b,d(a,b)}};if(typeof g=="string"||typeof g=="number")h.body='"'+g+'"';this.request(h)},k.prototype.createAdmin=function(a,b,c){this.config("admins",a,b,function(b,d){var e,f;d===!0?(e=this.database("_users"),f=e.document("org.couchdb.user:"+a),f.body("name",a),f.body("type","user"),f.body("roles",[]),f.save(function(a,b){a?c(a,null):c(a,!0)})):c(b,null)}.bind(this))},k.prototype.database=function(a){return new i(a,this)},k.prototype.deleteAdmin=function(a,b){this.config("admins",a,null,function(c,d){var e,f;d===!0?(e=this.database("_users"),f=e.document("org.couchdb.user:"+a),f.load(function(a,c){c?c.destroy(function(a,c){c?b(null,!0):b(a,null)}):b(a,null)})):b(c,null)}.bind(this))},k.prototype.listDatabases=function(a,b){var c=b?a:null;b=b||a,this.request({method:"GET",path:"_all_dbs",callback:function(a,d){a===null&&d!==null&&(c===!0&&(d=d.filter(function(a,b,c){return a[0]!=="_"})),d=d.map(function(a){return this.database(a)},this)),b(a,d)}.bind(this)})},k.prototype.log=function(a,b){var c=arguments.length>1?a:null;b=b||a,this.request({method:"GET",path:"_log"+(c?"?bytes="+c:""),callback:b})},k.prototype._request=function(a,b){var c="";b.on("data",function(a){c+=a}),b.on("end",function(){try{b.headers["content-type"]==="application/json"&&c.length>0&&(c=JSON.parse(c)),b.statusCode===404&&c.length===0&&(c={error:"not_found",reason:"missing"}),a(c.error?c:null,c.error?null:c,b.headers||null)}catch(d){a(d,null,null)}}.bind(this))},k.prototype.request=function(a){var b={host:this._options.host,port:this._options.port,method:typeof a.method=="string"&&a.method.match(this._methodMatch)!==null?a.method:"GET",path:"/"+this._options.path+(a.path||""),auth:this._options.username+":"+this._options.password,headers:a.headers||{}},c;b.headers.Accept=b.headers.Accept||"*/*,application/json",b.headers["Content-Type"]=b.headers["Content-Type"]||"application/json",c=g.request(b,this._request.bind(this,a.callback)),c.on("error",function(b){a.callback(b,null,null)}.bind(this)),a.body&&(typeof a.body=="object"?c.write(JSON.stringify(a.body)):c.write(a.body)),c.end()},k.prototype.restart=function(a){this.request({method:"POST",path:"_restart",callback:function(b,c){b&&b.code==="ECONNRESET"&&(b=null,c=!0),a(b,c)}})},k.prototype.stats=function(a){this.request({method:"GET",path:"_stats",callback:a})},k.prototype.user=function(){return new j(this)},k.prototype.uuids=function(a,b){var c=arguments.length>1?a:null;b=b||a,this.request({method:"GET",path:"_uuids"+(c?"?count="+c:""),callback:function(a,c){c&&(c=c.uuids),b(a,c)}})},k.prototype.version=function(a){this.request({method:"GET",path:"",callback:function(b,c){c!==null&&(c=c.version),a(b,c)}})},c.Connection=k}),window.cushion=a("/cushion.js")})();
+(function(){var a=function(b,c){var d=a.resolve(b,c||"/"),e=a.modules[d];if(!e)throw new Error("Failed to resolve module "+b+", tried "+d);var f=a.cache[d],g=f?f.exports:e();return g};a.paths=[],a.modules={},a.cache={},a.extensions=[".js",".coffee",".json"],a._core={assert:!0,events:!0,fs:!0,path:!0,vm:!0},a.resolve=function(){return function(b,c){function h(b){b=d.normalize(b);if(a.modules[b])return b;for(var c=0;c<a.extensions.length;c++){var e=a.extensions[c];if(a.modules[b+e])return b+e}}function i(b){b=b.replace(/\/+$/,"");var c=d.normalize(b+"/package.json");if(a.modules[c]){var e=a.modules[c](),f=e.browserify;if(typeof f=="object"&&f.main){var g=h(d.resolve(b,f.main));if(g)return g}else if(typeof f=="string"){var g=h(d.resolve(b,f));if(g)return g}else if(e.main){var g=h(d.resolve(b,e.main));if(g)return g}}return h(b+"/index")}function j(a,b){var c=k(b);for(var d=0;d<c.length;d++){var e=c[d],f=h(e+"/"+a);if(f)return f;var g=i(e+"/"+a);if(g)return g}var f=h(a);if(f)return f}function k(a){var b;a==="/"?b=[""]:b=d.normalize(a).split("/");var c=[];for(var e=b.length-1;e>=0;e--){if(b[e]==="node_modules")continue;var f=b.slice(0,e+1).join("/")+"/node_modules";c.push(f)}return c}c||(c="/");if(a._core[b])return b;var d=a.modules.path();c=d.resolve("/",c);var e=c||"/";if(b.match(/^(?:\.\.?\/|\/)/)){var f=h(d.resolve(e,b))||i(d.resolve(e,b));if(f)return f}var g=j(b,e);if(g)return g;throw new Error("Cannot find module '"+b+"'")}}(),a.alias=function(b,c){var d=a.modules.path(),e=null;try{e=a.resolve(b+"/package.json","/")}catch(f){e=a.resolve(b,"/")}var g=d.dirname(e),h=(Object.keys||function(a){var b=[];for(var c in a)b.push(c);return b})(a.modules);for(var i=0;i<h.length;i++){var j=h[i];if(j.slice(0,g.length+1)===g+"/"){var k=j.slice(g.length);a.modules[c+k]=a.modules[g+k]}else j===g&&(a.modules[c]=a.modules[g])}},function(){var b={};a.define=function(c,d){a.modules.__browserify_process&&(b=a.modules.__browserify_process());var e=a._core[c]?"":a.modules.path().dirname(c),f=function(b){var c=a(b,e),d=a.cache[a.resolve(b,e)];return d&&d.parent===null&&(d.parent=g),c};f.resolve=function(b){return a.resolve(b,e)},f.modules=a.modules,f.define=a.define,f.cache=a.cache;var g={id:c,filename:c,exports:{},loaded:!1,parent:null};a.modules[c]=function(){return a.cache[c]=g,d.call(g.exports,f,g,g.exports,e,c,b),g.loaded=!0,g.exports}}}(),a.define("path",function(a,b,c,d,e,f){function g(a,b){var c=[];for(var d=0;d<a.length;d++)b(a[d],d,a)&&c.push(a[d]);return c}function h(a,b){var c=0;for(var d=a.length;d>=0;d--){var e=a[d];e=="."?a.splice(d,1):e===".."?(a.splice(d,1),c++):c&&(a.splice(d,1),c--)}if(b)for(;c--;c)a.unshift("..");return a}var i=/^(.+\/(?!$)|\/)?((?:.+?)?(\.[^.]*)?)$/;c.resolve=function(){var a="",b=!1;for(var c=arguments.length;c>=-1&&!b;c--){var d=c>=0?arguments[c]:f.cwd();if(typeof d!="string"||!d)continue;a=d+"/"+a,b=d.charAt(0)==="/"}return a=h(g(a.split("/"),function(a){return!!a}),!b).join("/"),(b?"/":"")+a||"."},c.normalize=function(a){var b=a.charAt(0)==="/",c=a.slice(-1)==="/";return a=h(g(a.split("/"),function(a){return!!a}),!b).join("/"),!a&&!b&&(a="."),a&&c&&(a+="/"),(b?"/":"")+a},c.join=function(){var a=Array.prototype.slice.call(arguments,0);return c.normalize(g(a,function(a,b){return a&&typeof a=="string"}).join("/"))},c.dirname=function(a){var b=i.exec(a)[1]||"",c=!1;return b?b.length===1||c&&b.length<=3&&b.charAt(1)===":"?b:b.substring(0,b.length-1):"."},c.basename=function(a,b){var c=i.exec(a)[2]||"";return b&&c.substr(-1*b.length)===b&&(c=c.substr(0,c.length-b.length)),c},c.extname=function(a){return i.exec(a)[3]||""}}),a.define("__browserify_process",function(a,b,c,d,e,f){var f=b.exports={};f.nextTick=function(){var a=typeof window!="undefined"&&window.setImmediate,b=typeof window!="undefined"&&window.postMessage&&window.addEventListener;if(a)return window.setImmediate;if(b){var c=[];return window.addEventListener("message",function(a){if(a.source===window&&a.data==="browserify-tick"){a.stopPropagation();if(c.length>0){var b=c.shift();b()}}},!0),function(a){c.push(a),window.postMessage("browserify-tick","*")}}return function(a){setTimeout(a,0)}}(),f.title="browser",f.browser=!0,f.env={},f.argv=[],f.binding=function(b){if(b==="evals")return a("vm");throw new Error("No such module. (Possibly not yet loaded)")},function(){var b="/",c;f.cwd=function(){return b},f.chdir=function(d){c||(c=a("path")),b=c.resolve(d,b)}}()}),a.define("/package.json",function(a,b,c,d,e,f){b.exports={main:"./cushion"}}),a.define("/cushion.js",function(a,b,c,d,e,f){var g=a("http"),h=a("./config.js"),i=a("./database.js").Database,j=a("./user.js").User,k=function(b,c,d,e,f){f=f||{},this._methodMatch=/^GET|PUT|POST|DELETE|HEAD|COPY$/i,this._options={host:b||h.host,port:c||h.port,username:d||h.username,password:e||h.password,secure:f.secure||h.secure,path:f.path?f.path+"/":h.path},this._options.secure===!0&&(g=a("https"))};k.prototype.activeTasks=function(a){this.request({method:"GET",path:"_active_tasks",callback:a})},k.prototype.config=function(a,b,c,d){var e=typeof a=="string"?a:null,f=typeof b=="string"?b:null,g=typeof c=="string"||typeof c=="number"||c===null?c:undefined,h;d=d||c||b||a,h={method:g!==undefined?g===null?"DELETE":"PUT":"GET",path:"_config"+(e?"/"+e:"")+(f?"/"+f:""),callback:function(a,b){a?b=null:b=g!==undefined?!0:b,d(a,b)}};if(typeof g=="string"||typeof g=="number")h.body='"'+g+'"';this.request(h)},k.prototype.createAdmin=function(a,b,c){this.config("admins",a,b,function(b,d){var e,f;d===!0?(e=this.database("_users"),f=e.document("org.couchdb.user:"+a),f.body("name",a),f.body("type","user"),f.body("roles",[]),f.save(function(a,b){a?c(a,null):c(a,!0)})):c(b,null)}.bind(this))},k.prototype.database=function(a){return new i(a,this)},k.prototype.deleteAdmin=function(a,b){this.config("admins",a,null,function(c,d){var e,f;d===!0?(e=this.database("_users"),f=e.document("org.couchdb.user:"+a),f.load(function(a,c){c?c.destroy(function(a,c){c?b(null,!0):b(a,null)}):b(a,null)})):b(c,null)}.bind(this))},k.prototype.listDatabases=function(a,b){var c=b?a:null;b=b||a,this.request({method:"GET",path:"_all_dbs",callback:function(a,d){a===null&&d!==null&&(c===!0&&(d=d.filter(function(a,b,c){return a[0]!=="_"})),d=d.map(function(a){return this.database(a)},this)),b(a,d)}.bind(this)})},k.prototype.log=function(a,b){var c=arguments.length>1?a:null;b=b||a,this.request({method:"GET",path:"_log"+(c?"?bytes="+c:""),callback:b})},k.prototype._request=function(a,b){var c="";b.on("data",function(a){c+=a}),b.on("end",function(){try{b.headers["content-type"]==="application/json"&&c.length>0&&(c=JSON.parse(c)),b.statusCode===404&&c.length===0&&(c={error:"not_found",reason:"missing"}),a(c.error?c:null,c.error?null:c,b.headers||null)}catch(d){a(d,null,null)}}.bind(this))},k.prototype.request=function(a){var b={host:this._options.host,port:this._options.port,method:typeof a.method=="string"&&a.method.match(this._methodMatch)!==null?a.method:"GET",path:"/"+this._options.path+(a.path||""),auth:this._options.username+":"+this._options.password,headers:a.headers||{}},c;b.headers.Accept=b.headers.Accept||"*/*,application/json",b.headers["Content-Type"]=b.headers["Content-Type"]||"application/json",c=g.request(b,this._request.bind(this,a.callback)),c.on("error",function(b){a.callback(b,null,null)}.bind(this)),a.body&&(typeof a.body=="object"?c.write(JSON.stringify(a.body)):c.write(a.body)),c.end()},k.prototype.restart=function(a){this.request({method:"POST",path:"_restart",callback:function(b,c){b&&b.code==="ECONNRESET"&&(b=null,c=!0),a(b,c)}})},k.prototype.stats=function(a){this.request({method:"GET",path:"_stats",callback:a})},k.prototype.user=function(){return new j(this)},k.prototype.uuids=function(a,b){var c=arguments.length>1?a:null;b=b||a,this.request({method:"GET",path:"_uuids"+(c?"?count="+c:""),callback:function(a,c){c&&(c=c.uuids),b(a,c)}})},k.prototype.version=function(a){this.request({method:"GET",path:"",callback:function(b,c){c!==null&&(c=c.version),a(b,c)}})},c.Connection=k}),a.define("http",function(a,b,c,d,e,f){b.exports=a("http-browserify")}),a.define("/node_modules/http-browserify/package.json",function(a,b,c,d,e,f){b.exports={main:"index.js",browserify:"index.js"}}),a.define("/node_modules/http-browserify/index.js",function(a,b,c,d,e,f){var g=b.exports,h=a("events").EventEmitter,i=a("./lib/request");g.request=function(a,b){a||(a={}),a.host||(a.host=window.location.host.split(":")[0]),a.port||(a.port=window.location.port);var c=new i(new j,a);return b&&c.on("response",b),c},g.get=function(a,b){a.method="GET";var c=g.request(a,b);return c.end(),c},g.Agent=function(){},g.Agent.defaultMaxSockets=4;var j=function(){if(typeof window=="undefined")throw new Error("no window object present");if(window.XMLHttpRequest)return window.XMLHttpRequest;if(window.ActiveXObject){var a=["Msxml2.XMLHTTP.6.0","Msxml2.XMLHTTP.3.0","Microsoft.XMLHTTP"];for(var b=0;b<a.length;b++)try{var c=new window.ActiveXObject(a[b]);return function(){if(c){var d=c;return c=null,d}return new window.ActiveXObject(a[b])}}catch(d){}throw new Error("ajax not supported in this browser")}throw new Error("ajax not supported in this browser")}()}),a.define("events",function(a,b,c,d,e,f){f.EventEmitter||(f.EventEmitter=function(){});var g=c.EventEmitter=f.EventEmitter,h=typeof Array.isArray=="function"?Array.isArray:function(a){return Object.prototype.toString.call(a)==="[object Array]"},i=10;g.prototype.setMaxListeners=function(a){this._events||(this._events={}),this._events.maxListeners=a},g.prototype.emit=function(a){if(a==="error")if(!this._events||!this._events.error||h(this._events.error)&&!this._events.error.length)throw arguments[1]instanceof Error?arguments[1]:new Error("Uncaught, unspecified 'error' event.");if(!this._events)return!1;var b=this._events[a];if(!b)return!1;if(typeof b=="function"){switch(arguments.length){case 1:b.call(this);break;case 2:b.call(this,arguments[1]);break;case 3:b.call(this,arguments[1],arguments[2]);break;default:var c=Array.prototype.slice.call(arguments,1);b.apply(this,c)}return!0}if(h(b)){var c=Array.prototype.slice.call(arguments,1),d=b.slice();for(var e=0,f=d.length;e<f;e++)d[e].apply(this,c);return!0}return!1},g.prototype.addListener=function(a,b){if("function"!=typeof b)throw new Error("addListener only takes instances of Function");this._events||(this._events={}),this.emit("newListener",a,b);if(!this._events[a])this._events[a]=b;else if(h(this._events[a])){if(!this._events[a].warned){var c;this._events.maxListeners!==undefined?c=this._events.maxListeners:c=i,c&&c>0&&this._events[a].length>c&&(this._events[a].warned=!0,console.error("(node) warning: possible EventEmitter memory leak detected. %d listeners added. Use emitter.setMaxListeners() to increase limit.",this._events[a].length),console.trace())}this._events[a].push(b)}else this._events[a]=[this._events[a],b];return this},g.prototype.on=g.prototype.addListener,g.prototype.once=function(a,b){var c=this;return c.on(a,function d(){c.removeListener(a,d),b.apply(this,arguments)}),this},g.prototype.removeListener=function(a,b){if("function"!=typeof b)throw new Error("removeListener only takes instances of Function");if(!this._events||!this._events[a])return this;var c=this._events[a];if(h(c)){var d=c.indexOf(b);if(d<0)return this;c.splice(d,1),c.length==0&&delete this._events[a]}else this._events[a]===b&&delete this._events[a];return this},g.prototype.removeAllListeners=function(a){return a&&this._events&&this._events[a]&&(this._events[a]=null),this},g.prototype.listeners=function(a){return this._events||(this._events={}),this._events[a]||(this._events[a]=[]),h(this._events[a])||(this._events[a]=[this._events[a]]),this._events[a]}}),a.define("/node_modules/http-browserify/lib/request.js",function(a,b,c,d,e,f){var g=a("events").EventEmitter,h=a("./response"),i=a("concat-stream"),j=b.exports=function(a,b){var c=this;c.xhr=a,c.body=i();var d=b.host+":"+b.port+(b.path||"/");a.open(b.method||"GET",(b.scheme||"http")+"://"+d,!0),b.headers&&Object.keys(b.headers).forEach(function(d){if(!c.isSafeRequestHeader(d))return;var e=b.headers[d];Array.isArray(e)?e.forEach(function(b){a.setRequestHeader(d,b)}):a.setRequestHeader(d,e)});var e=new h;e.on("ready",function(){c.emit("response",e)}),a.onreadystatechange=function(){e.handle(a)}};j.prototype=new g,j.prototype.setHeader=function(a,b){if(Array.isArray&&Array.isArray(b)||b instanceof Array)for(var c=0;c<b.length;c++)this.xhr.setRequestHeader(a,b[c]);else this.xhr.setRequestHeader(a,b)},j.prototype.write=function(a){this.body.write(a)},j.prototype.end=function(a){a!==undefined&&this.body.write(a),this.body.end(),this.xhr.send(this.body.getBody())},j.unsafeHeaders=["accept-charset","accept-encoding","access-control-request-headers","access-control-request-method","connection","content-length","cookie","cookie2","content-transfer-encoding","date","expect","host","keep-alive","origin","referer","te","trailer","transfer-encoding","upgrade","user-agent","via"],j.prototype.isSafeRequestHeader=function(a){return a?j.unsafeHeaders.indexOf(a.toLowerCase())===-1:!1}}),a.define("/node_modules/http-browserify/lib/response.js",function(a,b,c,d,e,f){function j(a){var b=a.getAllResponseHeaders().split(/\r?\n/),c={};for(var d=0;d<b.length;d++){var e=b[d];if(e==="")continue;var f=e.match(/^([^:]+):\s*(.*)/);if(f){var g=f[1].toLowerCase(),h=f[2];c[g]!==undefined?Array.isArray&&Array.isArray(c[g])||c[g]instanceof Array?c[g].push(h):c[g]=[c[g],h]:c[g]=h}else c[e]=!0}return c}var g=a("events").EventEmitter,h=b.exports=function(a){this.offset=0};h.prototype=new g;var i={streaming:!0,status2:!0};h.prototype.getResponse=function(a){var b=a.responseType.toLowerCase();return b==="blob"?a.responseBlob:b==="arraybuffer"?a.response:a.responseText},h.prototype.getHeader=function(a){return this.headers[a.toLowerCase()]},h.prototype.handle=function(a){if(a.readyState===2&&i.status2){try{this.statusCode=a.status,this.headers=j(a)}catch(b){i.status2=!1}i.status2&&this.emit("ready")}else if(i.streaming&&a.readyState===3){try{this.statusCode||(this.statusCode=a.status,this.headers=j(a),this.emit("ready"))}catch(b){}try{this.write(a)}catch(b){i.streaming=!1}}else a.readyState===4&&(this.statusCode||(this.statusCode=a.status,this.emit("ready")),this.write(a),a.error?this.emit("error",this.getResponse(a)):this.emit("end"))},h.prototype.write=function(a){var b=this.getResponse(a);if(b.toString().match(/ArrayBuffer/)){this.emit("data",new Uint8Array(b,this.offset)),this.offset=b.byteLength;return}b.length>this.offset&&(this.emit("data",b.slice(this.offset)),this.offset=b.length)}}),a.define("/node_modules/http-browserify/node_modules/concat-stream/package.json",function(a,b,c,d,e,f){b.exports={}}),a.define("/node_modules/http-browserify/node_modules/concat-stream/index.js",function(a,b,c,d,e,f){function i(a){g.Stream.call(this),this.writable=!0,a&&(this.cb=a),this.body=[],this.cb&&this.on("error",a)}var g=a("stream"),h=a("util");h.inherits(i,g.Stream),i.prototype.write=function(a){this.body.push(a)},i.prototype.arrayConcat=function(a){return a.length===0?[]:a.length===1?a[0]:a.reduce(function(a,b){return a.concat(b)})},i.prototype.isArray=function(a){var b=Array.isArray(a),c=a.toString().match(/Array/);return b||c},i.prototype.getBody=function(){if(this.body.length===0)return;return typeof this.body[0]=="string"?this.body.join(""):this.isArray(this.body[0])?this.arrayConcat(this.body):typeof Buffer!="undefined"&&Buffer.isBuffer(this.body[0])?Buffer.concat(this.body):this.body},i.prototype.end=function(){this.cb&&this.cb(!1,this.getBody())},b.exports=function(a){return new i(a)},b.exports.ConcatStream=i}),a.define("stream",function(a,b,c,d,e,f){function i(){g.EventEmitter.call(this)}var g=a("events"),h=a("util");h.inherits(i,g.EventEmitter),b.exports=i,i.Stream=i,i.prototype.pipe=function(a,b){function d(b){a.writable&&!1===a.write(b)&&c.pause&&c.pause()}function e(){c.readable&&c.resume&&c.resume()}function g(){if(f)return;f=!0,a._pipeCount--,j();if(a._pipeCount>0)return;a.end()}function h(){if(f)return;f=!0,a._pipeCount--,j();if(a._pipeCount>0)return;a.destroy()}function i(a){j();if(this.listeners("error").length===0)throw a}function j(){c.removeListener("data",d),a.removeListener("drain",e),c.removeListener("end",g),c.removeListener("close",h),c.removeListener("error",i),a.removeListener("error",i),c.removeListener("end",j),c.removeListener("close",j),a.removeListener("end",j),a.removeListener("close",j)}var c=this;c.on("data",d),a.on("drain",e),!a._isStdio&&(!b||b.end!==!1)&&(a._pipeCount=a._pipeCount||0,a._pipeCount++,c.on("end",g),c.on("close",h));var f=!1;return c.on("error",i),a.on("error",i),c.on("end",j),c.on("close",j),a.on("end",j),a.on("close",j),a.emit("pipe",c),a}}),a.define("util",function(a,b,c,d,e,f){function h(a){return a instanceof Array||Array.isArray(a)||a&&a!==Object.prototype&&h(a.__proto__)}function i(a){return a instanceof RegExp||typeof a=="object"&&Object.prototype.toString.call(a)==="[object RegExp]"}function j(a){if(a instanceof Date)return!0;if(typeof a!="object")return!1;var b=Date.prototype&&o(Date.prototype),c=a.__proto__&&o(a.__proto__);return JSON.stringify(c)===JSON.stringify(b)}function k(a){return a<10?"0"+a.toString(10):a.toString(10)}function m(){var a=new Date,b=[k(a.getHours()),k(a.getMinutes()),k(a.getSeconds())].join(":");return[a.getDate(),l[a.getMonth()],b].join(" ")}var g=a("events");c.print=function(){},c.puts=function(){},c.debug=function(){},c.inspect=function(a,b,d,e){function k(a,d){if(a&&typeof a.inspect=="function"&&a!==c&&(!a.constructor||a.constructor.prototype!==a))return a.inspect(d);switch(typeof a){case"undefined":return g("undefined","undefined");case"string":var e="'"+JSON.stringify(a).replace(/^"|"$/g,"").replace(/'/g,"\\'").replace(/\\"/g,'"')+"'";return g(e,"string");case"number":return g(""+a,"number");case"boolean":return g(""+a,"boolean")}if(a===null)return g("null","null");var l=n(a),m=b?o(a):l;if(typeof a=="function"&&m.length===0){if(i(a))return g(""+a,"regexp");var p=a.name?": "+a.name:"";return g("[Function"+p+"]","special")}if(j(a)&&m.length===0)return g(a.toUTCString(),"date");var q,r,s;h(a)?(r="Array",s=["[","]"]):(r="Object",s=["{","}"]);if(typeof a=="function"){var t=a.name?": "+a.name:"";q=i(a)?" "+a:" [Function"+t+"]"}else q="";j(a)&&(q=" "+a.toUTCString());if(m.length===0)return s[0]+q+s[1];if(d<0)return i(a)?g(""+a,"regexp"):g("[Object]","special");f.push(a);var u=m.map(function(b){var c,e;a.__lookupGetter__&&(a.__lookupGetter__(b)?a.__lookupSetter__(b)?e=g("[Getter/Setter]","special"):e=g("[Getter]","special"):a.__lookupSetter__(b)&&(e=g("[Setter]","special"))),l.indexOf(b)<0&&(c="["+b+"]"),e||(f.indexOf(a[b])<0?(d===null?e=k(a[b]):e=k(a[b],d-1),e.indexOf("\n")>-1&&(h(a)?e=e.split("\n").map(function(a){return" "+a}).join("\n").substr(2):e="\n"+e.split("\n").map(function(a){return" "+a}).join("\n"))):e=g("[Circular]","special"));if(typeof c=="undefined"){if(r==="Array"&&b.match(/^\d+$/))return e;c=JSON.stringify(""+b),c.match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)?(c=c.substr(1,c.length-2),c=g(c,"name")):(c=c.replace(/'/g,"\\'").replace(/\\"/g,'"').replace(/(^"|"$)/g,"'"),c=g(c,"string"))}return c+": "+e});f.pop();var v=0,w=u.reduce(function(a,b){return v++,b.indexOf("\n")>=0&&v++,a+b.length+1},0);return w>50?u=s[0]+(q===""?"":q+"\n ")+" "+u.join(",\n ")+" "+s[1]:u=s[0]+q+" "+u.join(", ")+" "+s[1],u}var f=[],g=function(a,b){var c={bold:[1,22],italic:[3,23],underline:[4,24],inverse:[7,27],white:[37,39],grey:[90,39],black:[30,39],blue:[34,39],cyan:[36,39],green:[32,39],magenta:[35,39],red:[31,39],yellow:[33,39]},d={special:"cyan",number:"blue","boolean":"yellow","undefined":"grey","null":"bold",string:"green",date:"magenta",regexp:"red"}[b];return d?"["+c[d][0]+"m"+a+"["+c[d][1]+"m":a};return e||(g=function(a,b){return a}),k(a,typeof d=="undefined"?2:d)};var l=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];c.log=function(a){},c.pump=null;var n=Object.keys||function(a){var b=[];for(var c in a)b.push(c);return b},o=Object.getOwnPropertyNames||function(a){var b=[];for(var c in a)Object.hasOwnProperty.call(a,c)&&b.push(c);return b},p=Object.create||function(a,b){var c;if(a===null)c={__proto__:null};else{if(typeof a!="object")throw new TypeError("typeof prototype["+typeof a+"] != 'object'");var d=function(){};d.prototype=a,c=new d,c.__proto__=a}return typeof b!="undefined"&&Object.defineProperties&&Object.defineProperties(c,b),c};c.inherits=function(a,b){a.super_=b,a.prototype=p(b.prototype,{constructor:{value:a,enumerable:!1,writable:!0,configurable:!0}})}}),a.define("/config.js",function(a,b,c,d,e,f){c.host="127.0.0.1",c.port=5984,c.username="",c.password="",c.secure=!1,c.path=""}),a.define("/database.js",function(a,b,c,d,e,f){var g=a("querystring"),h=a("./document.js").Document,i=a("./design.js").Design,j=function(a,b){this._name=a,this._connection=b};j.prototype.allDocuments=function(a,b){var c=typeof a=="object"?"?"+g.stringify(a,"&","="):"";b=b||a,this._connection.request({method:"GET",path:this.name()+"/_all_docs"+c,callback:function(a,c){var d,e={},f;if(a===null){d={total:c.total_rows,offset:c.offset};for(f=0;c.rows[f];++f)e[c.rows[f].id]=c.rows[f].value.rev}b(a,d,e)}.bind(this)})},j.prototype.cleanup=function(a){this._connection.request({method:"POST",path:this.name()+"/_view_cleanup",callback:function(b,c){a(b,c?!0:null)}})},j.prototype.compact=function(a,b){var c=b?a:undefined;b=b||a,this._connection.request({method:"POST",path:this.name()+"/_compact"+(c?"/"+c:""),callback:function(a,c){b(a,c?!0:null)}.bind(this)})},j.prototype.create=function(a){this._connection.request({method:"PUT",path:this.name(),callback:function(b,c){b===null&&c.ok===!0&&(c=!0),a(b,c)}.bind(this)})},j.prototype.destroy=function(a){this._connection.request({method:"DELETE",path:this.name(),callback:function(b,c){c&&c.ok===!0&&(c=!0),a(b,c)}})},j.prototype.document=function(a,b){var c=a&&a.match(/^_design\//)?i:h;return new c(a||null,b||null,this._connection,this)},j.prototype.exists=function(a){this._connection.request({method:"GET",path:this._name,callback:function(b,c){var d=!0;b&&b.error==="not_found"&&(b=null,d=!1),a(b,b===null?d:null)}})},j.prototype.info=function(a){this._connection.request({method:"GET",path:this._name,callback:a})},j.prototype.list=function(a,b,c,d,e,f){var h=typeof d=="object"?"?"+g.stringify(d,"&","="):typeof e=="object"?"?"+g.stringify(e,"&","="):"",i=typeof d=="string"?d:c,j=typeof d=="string"?"/"+c:"",k=this.name()+"/_design/"+a+"/_list/"+b+j+"/"+i+h;f=f||e||d,this._connection.request({method:"GET",path:k,callback:f})},j.prototype.name=function(){return this._name},j.prototype.revisionLimit=function(a,b){var c=b?a:null,d={method:c!==null?"PUT":"GET",path:this._name+"/_revs_limit"};b=b||a,c!==null&&(d.body=""+c),d.callback=function(a,d){a?b(a,null):c===null?b(null,d):b(null,!0)},this._connection.request(d)},j.prototype.show=function(a,b,c,d,e){var f=typeof c=="string"?"/"+c:"",h="";e=e||d||c,typeof c=="object"?h="?"+g.stringify(c,"&","="):typeof d=="object"&&(h="?"+g.stringify(d,"&","=")),this._connection.request({method:"GET",path:this._name+"/_design/"+a+"/_show/"+b+f+h,callback:e})},j.prototype.temporaryView=function(a,b,c,d){var e=typeof b=="string"?b:null,f=typeof b=="object"?b:c,h={map:a};d=d||c||b,f=g.stringify(f,"&","="),e!==null&&(h.reduce=e),this._connection.request({method:"POST",path:this.name()+"/_temp_view"+(f?"?"+f:""),body:h,callback:function(a,b){var c=null,e=null;a===null&&(c={total:b.total_rows,offset:b.offset},e=b.rows),d(a,c,e)}})},j.prototype.view=function(a,b,c,d){var e=typeof c=="object"?"?"+g.stringify(c,"&","="):"",f=this.name()+"/_design/"+a+"/_view/"+b;d=d||c,this._connection.request({method:"GET",path:f+e,callback:function(a,b){var c=null,e=null;a===null&&(c={total:b.total_rows,offset:b.offset},e=b.rows),d(a,c,e)}.bind(this)})},c.Database=j}),a.define("querystring",function(a,b,c,d,e,f){function l(a,b){if(!b)throw new TypeError("stringify expects an object");return b+"="+encodeURIComponent(a)}function m(a,b){var c=[];if(!b)throw new TypeError("stringify expects an object");for(var d=0;d<a.length;d++)c.push(k(a[d],b+"[]"));return c.join("&")}function n(a,b){var c=[],d=h(a),e;for(var f=0,g=d.length;f<g;++f)e=d[f],c.push(k(a[e],b?b+"["+encodeURIComponent(e)+"]":encodeURIComponent(e)));return c.join("&")}function o(a,b,c){var d=a[b];undefined===d?a[b]=c:g(d)?d.push(c):a[b]=[d,c]}function p(a){var b=a.length,c,d;for(var e=0;e<b;++e){d=a[e],"]"==d&&(c=!1),"["==d&&(c=!0);if("="==d&&!c)return e}}var g=typeof Array.isArray=="function"?Array.isArray:function(a){return Object.prototype.toString.call(a)==="[object Array]"},h=Object.keys||function(a){if(a!==Object(a))throw new TypeError("Invalid object");var b=[];for(var c in a)a.hasOwnProperty(c)&&(b[b.length]=c);return b};c.version="0.3.1";var i=Object.prototype.toString,j=/[^0-9]/;c.parse=function(a){function b(a,b){if(a[b].length==0)return a[b]={};var c={};for(var d in a[b])c[d]=a[b][d];return a[b]=c,c}return null==a||""==a?{}:String(a).split("&").reduce(function(a,c){try{c=decodeURIComponent(c.replace(/\+/g," "))}catch(d){}var e=c.indexOf("="),f=p(c),i=c.substr(0,f||e),k=c.substr(f||e,c.length),k=k.substr(k.indexOf("=")+1,k.length),l=a;""==i&&(i=c,k="");if(~i.indexOf("]")){var m=i.split("["),n=m.length,q=n-1;function r(a,c,d){var e=a.shift();e?(obj=c[d]=c[d]||[],"]"==e?g(obj)?""!=k&&obj.push(k):"object"==typeof obj?obj[h(obj).length]=k:obj=c[d]=[c[d],k]:~e.indexOf("]")?(e=e.substr(0,e.length-1),j.test(e)&&g(obj)&&(obj=b(c,d)),r(a,obj,e)):(j.test(e)&&g(obj)&&(obj=b(c,d)),r(a,obj,e))):g(c[d])?c[d].push(k):"object"==typeof c[d]?c[d]=k:"undefined"==typeof c[d]?c[d]=k:c[d]=[c[d],k]}r(m,l,"base")}else{if(j.test(i)&&g(l.base)){var s={};for(var t in l.base)s[t]=l.base[t];l.base=s}o(l.base,i,k)}return a},{base:{}}).base};var k=c.stringify=function(a,b){return g(a)?m(a,b):"[object Object]"==i.call(a)?n(a,b):"string"==typeof a?l(a,b):b}}),a.define("/document.js",function(a,b,c,d,e,f){var g=a("fs"),h=function(a,b,c,d){this._id=a,this._revision=b,this._connection=c,this._database=d,this._body={},this._error={noId:"no document id was set",noRevision:"no revision was set",noFile:"could not read file"}};h.prototype.body=function(){var a=Array.prototype.slice.call(arguments),b=a.splice(a.length-1,1)[0],c=this._body,d;return a&&a.length>0&&arguments.length>1?(a.forEach(function(a,d,e){d===e.length-1&&typeof b=="undefined"?delete c[a]:(c[a]=d===e.length-1?b:c[a]||{},c=c[a])}),d=this):a&&arguments.length>0?typeof b=="object"?(this._body=JSON.parse(JSON.stringify(b)),d=this):d=typeof this._body[b]=="object"?JSON.parse(JSON.stringify(this._body[b])):this._body[b]:d=JSON.parse(JSON.stringify(this._body)),d},h.prototype.copy=function(a,b,c){var d=c?"?rev="+b:"";c=c||b,this._id===null?f.nextTick(c({error:"no_copy",reason:this._error.noId},null,null)):this._connection.request({method:"COPY",headers:{Destination:a+d},path:this._database.name()+"/"+this._id+(this._revision?"?rev="+this._revision:""),callback:function(a,b){b&&(b=this._database.document(b.id,b.rev)),c(a,this,b)}.bind(this)})},h.prototype.deleteAttachment=function(a,b){this._connection.request({method:"DELETE",path:this._database.name()+"/"+this._id+"/"+a+"?rev="+this._revision,callback:function(a,c){a?c=!1:(this._revision=c.rev,c=!0),b(a,c)}.bind(this)})},h.prototype.destroy=function(a){this._id===null?f.nextTick(a({error:"no_delete",reason:this._error.noId},null)):this._revision===null?f.nextTick(a({error:"no_delete",reason:this._error.noRevision},null)):this._connection.request({method:"DELETE",path:this._database.name()+"/"+this._id+"?rev="+this._revision,callback:function(b,c){c&&(this._revision=c.rev),a(b,this)}.bind(this)})},h.prototype.getAttachment=function(a,b){this._connection.request({method:"GET",path:this._database.name()+"/"+this._id+"/"+a+"?rev="+this._revision,callback:b})},h.prototype.id=function(){return this._id},h.prototype.info=function(a){this._id===null?f.nextTick(a({error:"no_info",reason:"no document id was set"},null)):this._connection.request({method:"HEAD",path:this._database.name()+"/"+this._id,callback:function(b,c,d){var e=null;b===null&&(this._revision=d.etag.substr(1,d.etag.length-2),e={revision:this._revision,size:d["content-length"]}),a(b,e)}.bind(this)})},h.prototype.load=function(a){this._id===null?f.nextTick(a({error:"no_load",reason:this._error.noId},null)):this._connection.request({method:"GET",path:this._database.name()+"/"+this._id+(this._revision!==null?"?rev="+this._revision:""),callback:function(b,c){b===null&&this._saveContent(c),a(b,this)}.bind(this)})},h.prototype.revision=function(){return this._revision},h.prototype.save=function(a){var b=JSON.parse(JSON.stringify(this._body));this._revision!==null&&(b._rev=this._revision),this._connection.request({method:this._id===null?"POST":"PUT",path:this._database.name()+(this._id===null?"":"/"+this._id),body:b,callback:function(b,c){b===null&&(this._id=c.id,this._revision=c.rev),a(b,this)}.bind(this)})},h.prototype.saveAttachment=function(a,b,c,d){var e=typeof c=="string"?c:a.split("/").pop();d=d||c,g.readFile(a,"utf8",function(c,g){c?f.nextTick(d({error:"no_file",reason:this._error.noFile+": "+a},null)):this._connection.request({method:"PUT",path:this._database.name()+"/"+this._id+"/"+e+"?rev="+this._revision,headers:{"Content-Length":g.length,"Content-Type":b},body:g,callback:function(a,b){a?b=!1:(this._revision=b.rev,b=!0),d(a,b)}.bind(this)})}.bind(this))},h.prototype._saveContent=function(a){var b;a=JSON.parse(JSON.stringify(a)),this._body={};for(b in a)b[0]==="_"?b==="_rev"&&(this._revision=a[b]):this._body[b]=a[b]},c.Document=h}),a.define("fs",function(a,b,c,d,e,f){}),a.define("/design.js",function(a,b,c,d,e,f){var g=a("util"),h=a("./document.js").Document,i=function(a,b,c,d){h.call(this,a,b,c,d)};g.inherits(i,h),i.prototype.compact=function(a){this._database.compact(this._id.substr(8),a)},i.prototype.list=function(a,b){return b&&this.body("lists",a,b===null?undefined:b),b!==undefined?this:this._body.lists?this._body.lists[a]:undefined},i.prototype.show=function(a,b){return typeof b!==undefined&&this.body("shows",a,b===null?undefined:b),b!==undefined?this:this._body.shows?this._body.shows[a]:undefined},i.prototype.view=function(a,b,c){var d={};return c&&(d.reduce=c),b!==undefined&&(d.map=b,this.body("views",a,b===null?undefined:d)),b!==undefined?this:this._body.views?this._body.views[a]:undefined},i.prototype.viewInfo=function(a){this._connection.request({method:"GET",path:this._database.name()+"/"+this._id+"/_info",callback:a})},c.Design=i}),a.define("/user.js",function(a,b,c,d,e,f){var g=a("crypto"),h=function(a){this._connection=a};h.prototype.addRole=function(a,b,c){var d=typeof b=="string"?[b]:b;this._connection.database("_users").document("org.couchdb.user:"+a).load(function(a,b){b.body("roles",b.body("roles").concat(d)).save(function(a,b){c(a,a?null:!0)})})},h.prototype.create=function(a,b,c,d){var e=typeof c=="object"?c:[],d=d||c,f;this._lower120(function(c,g){c?d(c,null):g===!0?(f=this._salt(),b=this._hash(b,f),this._connection.database("_users").document("org.couchdb.user:"+a).body({name:a,type:"user",roles:e,password_sha:b,salt:f}).save(function(a,b){d(a,a?null:!0)})):this._connection.database("_users").document("org.couchdb.user:"+a).body({name:a,type:"user",roles:e,password:b}).save(function(a,b){d(a,a?null:!0)})}.bind(this))},h.prototype.delete=function(a,b){var c=this._connection.database("_users").document("org.couchdb.user:"+a);c.info(function(a,d){a?b(a,null):c.destroy(function(a,c){b(a,a?null:!0)})})},h.prototype.deleteRole=function(a,b,c){var d=typeof b=="string"?[b]:b;this._connection.database("_users").document("org.couchdb.user:"+a).load(function(a,b){a?c(a,null):b.body("roles",b.body("roles").filter(function(a,b,c){return d.some(function(b,c,d){return b===a})})).save(function(a,b){c(a,a?null:!0)})})},h.prototype.getRoles=function(a,b){this._connection.database("_users").document("org.couchdb.user:"+a).load(function(a,c){b(a,a?null:c.body("roles"))})},h.prototype._hash=function(a,b){return g.createHash("sha1").update(a+b).digest("hex")},h.prototype._salt=function(){return g.randomBytes(16).toString("hex")},h.prototype._lower120=function(a){this._connection.version(function(b,c){b?a(b,null):(c=c.split(".").map(function(a,b,c){return parseInt(a,10)}),a(null,c[0]<1||c[0]===1&&c[1]<2))})},h.prototype.password=function(a,b,c){var d;this._connection.database("_users").document("org.couchdb.user:"+a).load(function(a,e){a?c(a,null):this._lower120(function(a,f){a?c(a,null):(f===!0?(d=this._salt(),b=this._hash(b,d),e.body("password_sha",b).body("salt",d)):e.body("password_sha",undefined).body("salt",undefined).body("password",b),e.save(function(a,b){c(a,a?null:!0)}))}.bind
+(this))}.bind(this))},c.User=h}),a.define("crypto",function(a,b,c,d,e,f){b.exports=a("crypto-browserify")}),a.define("/node_modules/crypto-browserify/package.json",function(a,b,c,d,e,f){b.exports={}}),a.define("/node_modules/crypto-browserify/index.js",function(a,b,c,d,e,f){function j(){var a=[].slice.call(arguments).join(" ");throw new Error([a,"we accept pull requests","http://github.com/dominictarr/crypto-browserify"].join("\n"))}var g=a("./sha"),h=a("./rng"),i={sha1:{hex:g.hex_sha1,binary:g.b64_sha1,ascii:g.str_sha1}};c.createHash=function(a){a=a||"sha1",i[a]||j("algorithm:",a,"is not yet supported");var b="",c=i[a];return{update:function(a){return b+=a,this},digest:function(d){d=d||"binary";var e;(e=c[d])||j("encoding:",d,"is not yet supported for algorithm",a);var f=e(b);return b=null,f}}},c.randomBytes=function(a,b){if(!b||!b.call)return h(a);try{b.call(this,undefined,h(a))}catch(c){b(c)}},["createCredentials","createHmac","createCypher","createCypheriv","createDecipher","createDecipheriv","createSign","createVerify","createDeffieHellman","pbkdf2"].forEach(function(a){c[a]=function(){j("sorry,",a,"is not implemented yet")}})}),a.define("/node_modules/crypto-browserify/sha.js",function(a,b,c,d,e,f){function j(a){return y(q(w(a),a.length*i))}function k(a){return z(q(w(a),a.length*i))}function l(a){return x(q(w(a),a.length*i))}function m(a,b){return y(t(a,b))}function n(a,b){return z(t(a,b))}function o(a,b){return x(t(a,b))}function p(){return j("abc")=="a9993e364706816aba3e25717850c26c9cd0d89d"}function q(a,b){a[b>>5]|=128<<24-b%32,a[(b+64>>9<<4)+15]=b;var c=Array(80),d=1732584193,e=-271733879,f=-1732584194,g=271733878,h=-1009589776;for(var i=0;i<a.length;i+=16){var j=d,k=e,l=f,m=g,n=h;for(var o=0;o<80;o++){o<16?c[o]=a[i+o]:c[o]=v(c[o-3]^c[o-8]^c[o-14]^c[o-16],1);var p=u(u(v(d,5),r(o,e,f,g)),u(u(h,c[o]),s(o)));h=g,g=f,f=v(e,30),e=d,d=p}d=u(d,j),e=u(e,k),f=u(f,l),g=u(g,m),h=u(h,n)}return Array(d,e,f,g,h)}function r(a,b,c,d){return a<20?b&c|~b&d:a<40?b^c^d:a<60?b&c|b&d|c&d:b^c^d}function s(a){return a<20?1518500249:a<40?1859775393:a<60?-1894007588:-899497514}function t(a,b){var c=w(a);c.length>16&&(c=q(c,a.length*i));var d=Array(16),e=Array(16);for(var f=0;f<16;f++)d[f]=c[f]^909522486,e[f]=c[f]^1549556828;var g=q(d.concat(w(b)),512+b.length*i);return q(e.concat(g),672)}function u(a,b){var c=(a&65535)+(b&65535),d=(a>>16)+(b>>16)+(c>>16);return d<<16|c&65535}function v(a,b){return a<<b|a>>>32-b}function w(a){var b=Array(),c=(1<<i)-1;for(var d=0;d<a.length*i;d+=i)b[d>>5]|=(a.charCodeAt(d/i)&c)<<32-i-d%32;return b}function x(a){var b="",c=(1<<i)-1;for(var d=0;d<a.length*32;d+=i)b+=String.fromCharCode(a[d>>5]>>>32-i-d%32&c);return b}function y(a){var b=g?"0123456789ABCDEF":"0123456789abcdef",c="";for(var d=0;d<a.length*4;d++)c+=b.charAt(a[d>>2]>>(3-d%4)*8+4&15)+b.charAt(a[d>>2]>>(3-d%4)*8&15);return c}function z(a){var b="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",c="";for(var d=0;d<a.length*4;d+=3){var e=(a[d>>2]>>8*(3-d%4)&255)<<16|(a[d+1>>2]>>8*(3-(d+1)%4)&255)<<8|a[d+2>>2]>>8*(3-(d+2)%4)&255;for(var f=0;f<4;f++)d*8+f*6>a.length*32?c+=h:c+=b.charAt(e>>6*(3-f)&63)}return c}c.hex_sha1=j,c.b64_sha1=k,c.str_sha1=l,c.hex_hmac_sha1=m,c.b64_hmac_sha1=n,c.str_hmac_sha1=o;var g=0,h="",i=8}),a.define("/node_modules/crypto-browserify/rng.js",function(a,b,c,d,e,f){(function(){var a=this,c,d;c=function(a){var b=new Array(a),c;for(var d=0,c;d<a;d++)(d&3)==0&&(c=Math.random()*4294967296),b[d]=c>>>((d&3)<<3)&255;return b};if(a.crypto&&crypto.getRandomValues){var e=new Uint32Array(4);d=function(a){var b=new Array(a);crypto.getRandomValues(e);for(var c=0;c<a;c++)b[c]=e[c>>2]>>>(c&3)*8&255;return b}}b.exports=d||c})()}),a.define("https",function(a,b,c,d,e,f){b.exports=a("http")}),a.define("/cushion.js",function(a,b,c,d,e,f){var g=a("http"),h=a("./config.js"),i=a("./database.js").Database,j=a("./user.js").User,k=function(b,c,d,e,f){f=f||{},this._methodMatch=/^GET|PUT|POST|DELETE|HEAD|COPY$/i,this._options={host:b||h.host,port:c||h.port,username:d||h.username,password:e||h.password,secure:f.secure||h.secure,path:f.path?f.path+"/":h.path},this._options.secure===!0&&(g=a("https"))};k.prototype.activeTasks=function(a){this.request({method:"GET",path:"_active_tasks",callback:a})},k.prototype.config=function(a,b,c,d){var e=typeof a=="string"?a:null,f=typeof b=="string"?b:null,g=typeof c=="string"||typeof c=="number"||c===null?c:undefined,h;d=d||c||b||a,h={method:g!==undefined?g===null?"DELETE":"PUT":"GET",path:"_config"+(e?"/"+e:"")+(f?"/"+f:""),callback:function(a,b){a?b=null:b=g!==undefined?!0:b,d(a,b)}};if(typeof g=="string"||typeof g=="number")h.body='"'+g+'"';this.request(h)},k.prototype.createAdmin=function(a,b,c){this.config("admins",a,b,function(b,d){var e,f;d===!0?(e=this.database("_users"),f=e.document("org.couchdb.user:"+a),f.body("name",a),f.body("type","user"),f.body("roles",[]),f.save(function(a,b){a?c(a,null):c(a,!0)})):c(b,null)}.bind(this))},k.prototype.database=function(a){return new i(a,this)},k.prototype.deleteAdmin=function(a,b){this.config("admins",a,null,function(c,d){var e,f;d===!0?(e=this.database("_users"),f=e.document("org.couchdb.user:"+a),f.load(function(a,c){c?c.destroy(function(a,c){c?b(null,!0):b(a,null)}):b(a,null)})):b(c,null)}.bind(this))},k.prototype.listDatabases=function(a,b){var c=b?a:null;b=b||a,this.request({method:"GET",path:"_all_dbs",callback:function(a,d){a===null&&d!==null&&(c===!0&&(d=d.filter(function(a,b,c){return a[0]!=="_"})),d=d.map(function(a){return this.database(a)},this)),b(a,d)}.bind(this)})},k.prototype.log=function(a,b){var c=arguments.length>1?a:null;b=b||a,this.request({method:"GET",path:"_log"+(c?"?bytes="+c:""),callback:b})},k.prototype._request=function(a,b){var c="";b.on("data",function(a){c+=a}),b.on("end",function(){try{b.headers["content-type"]==="application/json"&&c.length>0&&(c=JSON.parse(c)),b.statusCode===404&&c.length===0&&(c={error:"not_found",reason:"missing"}),a(c.error?c:null,c.error?null:c,b.headers||null)}catch(d){a(d,null,null)}}.bind(this))},k.prototype.request=function(a){var b={host:this._options.host,port:this._options.port,method:typeof a.method=="string"&&a.method.match(this._methodMatch)!==null?a.method:"GET",path:"/"+this._options.path+(a.path||""),auth:this._options.username+":"+this._options.password,headers:a.headers||{}},c;b.headers.Accept=b.headers.Accept||"*/*,application/json",b.headers["Content-Type"]=b.headers["Content-Type"]||"application/json",c=g.request(b,this._request.bind(this,a.callback)),c.on("error",function(b){a.callback(b,null,null)}.bind(this)),a.body&&(typeof a.body=="object"?c.write(JSON.stringify(a.body)):c.write(a.body)),c.end()},k.prototype.restart=function(a){this.request({method:"POST",path:"_restart",callback:function(b,c){b&&b.code==="ECONNRESET"&&(b=null,c=!0),a(b,c)}})},k.prototype.stats=function(a){this.request({method:"GET",path:"_stats",callback:a})},k.prototype.user=function(){return new j(this)},k.prototype.uuids=function(a,b){var c=arguments.length>1?a:null;b=b||a,this.request({method:"GET",path:"_uuids"+(c?"?count="+c:""),callback:function(a,c){c&&(c=c.uuids),b(a,c)}})},k.prototype.version=function(a){this.request({method:"GET",path:"",callback:function(b,c){c!==null&&(c=c.version),a(b,c)}})},c.Connection=k}),a("/cushion.js")})();

0 comments on commit 84b878a

Please sign in to comment.
Something went wrong with that request. Please try again.