opal-pouchdb 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ /*!
2
+ * https://github.com/es-shims/es5-shim
3
+ * @license es5-shim Copyright 2009-2014 by contributors, MIT License
4
+ * see https://github.com/es-shims/es5-shim/blob/v4.1.0/LICENSE
5
+ */
6
+ (function(t,e){"use strict";if(typeof define==="function"&&define.amd){define(e)}else if(typeof exports==="object"){module.exports=e()}else{t.returnExports=e()}})(this,function(){var t=Array.prototype;var e=Object.prototype;var r=Function.prototype;var n=String.prototype;var i=Number.prototype;var a=t.slice;var o=t.splice;var u=t.push;var l=t.unshift;var f=r.call;var s=e.toString;var c=Array.isArray||function ye(t){return s.call(t)==="[object Array]"};var p=typeof Symbol==="function"&&typeof Symbol.toStringTag==="symbol";var h;var v=Function.prototype.toString,g=function de(t){try{v.call(t);return true}catch(e){return false}},y="[object Function]",d="[object GeneratorFunction]";h=function me(t){if(typeof t!=="function"){return false}if(p){return g(t)}var e=s.call(t);return e===y||e===d};var m;var b=RegExp.prototype.exec,w=function be(t){try{b.call(t);return true}catch(e){return false}},T="[object RegExp]";m=function we(t){if(typeof t!=="object"){return false}return p?w(t):s.call(t)===T};var x;var O=String.prototype.valueOf,j=function Te(t){try{O.call(t);return true}catch(e){return false}},S="[object String]";x=function xe(t){if(typeof t==="string"){return true}if(typeof t!=="object"){return false}return p?j(t):s.call(t)===S};var E=function Oe(t){var e=s.call(t);var r=e==="[object Arguments]";if(!r){r=!c(t)&&t!==null&&typeof t==="object"&&typeof t.length==="number"&&t.length>=0&&h(t.callee)}return r};var N=function(t){var e=Object.defineProperty&&function(){try{Object.defineProperty({},"x",{});return true}catch(t){return false}}();var r;if(e){r=function(t,e,r,n){if(!n&&e in t){return}Object.defineProperty(t,e,{configurable:true,enumerable:false,writable:true,value:r})}}else{r=function(t,e,r,n){if(!n&&e in t){return}t[e]=r}}return function n(e,i,a){for(var o in i){if(t.call(i,o)){r(e,o,i[o],a)}}}}(e.hasOwnProperty);function I(t){var e=typeof t;return t===null||e==="undefined"||e==="boolean"||e==="number"||e==="string"}var D={ToInteger:function je(t){var e=+t;if(e!==e){e=0}else if(e!==0&&e!==1/0&&e!==-(1/0)){e=(e>0||-1)*Math.floor(Math.abs(e))}return e},ToPrimitive:function Se(t){var e,r,n;if(I(t)){return t}r=t.valueOf;if(h(r)){e=r.call(t);if(I(e)){return e}}n=t.toString;if(h(n)){e=n.call(t);if(I(e)){return e}}throw new TypeError},ToObject:function(t){if(t==null){throw new TypeError("can't convert "+t+" to object")}return Object(t)},ToUint32:function Ee(t){return t>>>0}};var M=function Ne(){};N(r,{bind:function Ie(t){var e=this;if(!h(e)){throw new TypeError("Function.prototype.bind called on incompatible "+e)}var r=a.call(arguments,1);var n;var i=function(){if(this instanceof n){var i=e.apply(this,r.concat(a.call(arguments)));if(Object(i)===i){return i}return this}else{return e.apply(t,r.concat(a.call(arguments)))}};var o=Math.max(0,e.length-r.length);var u=[];for(var l=0;l<o;l++){u.push("$"+l)}n=Function("binder","return function ("+u.join(",")+"){ return binder.apply(this, arguments); }")(i);if(e.prototype){M.prototype=e.prototype;n.prototype=new M;M.prototype=null}return n}});var F=f.bind(e.hasOwnProperty);var R=function(){var t=[1,2];var e=t.splice();return t.length===2&&c(e)&&e.length===0}();N(t,{splice:function De(t,e){if(arguments.length===0){return[]}else{return o.apply(this,arguments)}}},!R);var U=function(){var e={};t.splice.call(e,0,0,1);return e.length===1}();N(t,{splice:function Me(t,e){if(arguments.length===0){return[]}var r=arguments;this.length=Math.max(D.ToInteger(this.length),0);if(arguments.length>0&&typeof e!=="number"){r=a.call(arguments);if(r.length<2){r.push(this.length-t)}else{r[1]=D.ToInteger(e)}}return o.apply(this,r)}},!U);var k=[].unshift(0)!==1;N(t,{unshift:function(){l.apply(this,arguments);return this.length}},k);N(Array,{isArray:c});var A=Object("a");var C=A[0]!=="a"||!(0 in A);var P=function Fe(t){var e=true;var r=true;if(t){t.call("foo",function(t,r,n){if(typeof n!=="object"){e=false}});t.call([1],function(){"use strict";r=typeof this==="string"},"x")}return!!t&&e&&r};N(t,{forEach:function Re(t){var e=D.ToObject(this),r=C&&x(this)?this.split(""):e,n=arguments[1],i=-1,a=r.length>>>0;if(!h(t)){throw new TypeError}while(++i<a){if(i in r){t.call(n,r[i],i,e)}}}},!P(t.forEach));N(t,{map:function Ue(t){var e=D.ToObject(this),r=C&&x(this)?this.split(""):e,n=r.length>>>0,i=Array(n),a=arguments[1];if(!h(t)){throw new TypeError(t+" is not a function")}for(var o=0;o<n;o++){if(o in r){i[o]=t.call(a,r[o],o,e)}}return i}},!P(t.map));N(t,{filter:function ke(t){var e=D.ToObject(this),r=C&&x(this)?this.split(""):e,n=r.length>>>0,i=[],a,o=arguments[1];if(!h(t)){throw new TypeError(t+" is not a function")}for(var u=0;u<n;u++){if(u in r){a=r[u];if(t.call(o,a,u,e)){i.push(a)}}}return i}},!P(t.filter));N(t,{every:function Ae(t){var e=D.ToObject(this),r=C&&x(this)?this.split(""):e,n=r.length>>>0,i=arguments[1];if(!h(t)){throw new TypeError(t+" is not a function")}for(var a=0;a<n;a++){if(a in r&&!t.call(i,r[a],a,e)){return false}}return true}},!P(t.every));N(t,{some:function Ce(t){var e=D.ToObject(this),r=C&&x(this)?this.split(""):e,n=r.length>>>0,i=arguments[1];if(!h(t)){throw new TypeError(t+" is not a function")}for(var a=0;a<n;a++){if(a in r&&t.call(i,r[a],a,e)){return true}}return false}},!P(t.some));var Z=false;if(t.reduce){Z=typeof t.reduce.call("es5",function(t,e,r,n){return n})==="object"}N(t,{reduce:function Pe(t){var e=D.ToObject(this),r=C&&x(this)?this.split(""):e,n=r.length>>>0;if(!h(t)){throw new TypeError(t+" is not a function")}if(!n&&arguments.length===1){throw new TypeError("reduce of empty array with no initial value")}var i=0;var a;if(arguments.length>=2){a=arguments[1]}else{do{if(i in r){a=r[i++];break}if(++i>=n){throw new TypeError("reduce of empty array with no initial value")}}while(true)}for(;i<n;i++){if(i in r){a=t.call(void 0,a,r[i],i,e)}}return a}},!Z);var J=false;if(t.reduceRight){J=typeof t.reduceRight.call("es5",function(t,e,r,n){return n})==="object"}N(t,{reduceRight:function Ze(t){var e=D.ToObject(this),r=C&&x(this)?this.split(""):e,n=r.length>>>0;if(!h(t)){throw new TypeError(t+" is not a function")}if(!n&&arguments.length===1){throw new TypeError("reduceRight of empty array with no initial value")}var i,a=n-1;if(arguments.length>=2){i=arguments[1]}else{do{if(a in r){i=r[a--];break}if(--a<0){throw new TypeError("reduceRight of empty array with no initial value")}}while(true)}if(a<0){return i}do{if(a in r){i=t.call(void 0,i,r[a],a,e)}}while(a--);return i}},!J);var z=Array.prototype.indexOf&&[0,1].indexOf(1,2)!==-1;N(t,{indexOf:function Je(t){var e=C&&x(this)?this.split(""):D.ToObject(this),r=e.length>>>0;if(!r){return-1}var n=0;if(arguments.length>1){n=D.ToInteger(arguments[1])}n=n>=0?n:Math.max(0,r+n);for(;n<r;n++){if(n in e&&e[n]===t){return n}}return-1}},z);var $=Array.prototype.lastIndexOf&&[0,1].lastIndexOf(0,-3)!==-1;N(t,{lastIndexOf:function ze(t){var e=C&&x(this)?this.split(""):D.ToObject(this),r=e.length>>>0;if(!r){return-1}var n=r-1;if(arguments.length>1){n=Math.min(n,D.ToInteger(arguments[1]))}n=n>=0?n:r-Math.abs(n);for(;n>=0;n--){if(n in e&&t===e[n]){return n}}return-1}},$);var B=!{toString:null}.propertyIsEnumerable("toString"),G=function(){}.propertyIsEnumerable("prototype"),H=!F("x","0"),L=["toString","toLocaleString","valueOf","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","constructor"],X=L.length;N(Object,{keys:function $e(t){var e=h(t),r=E(t),n=t!==null&&typeof t==="object",i=n&&x(t);if(!n&&!e&&!r){throw new TypeError("Object.keys called on a non-object")}var a=[];var o=G&&e;if(i&&H||r){for(var u=0;u<t.length;++u){a.push(String(u))}}if(!r){for(var l in t){if(!(o&&l==="prototype")&&F(t,l)){a.push(String(l))}}}if(B){var f=t.constructor,s=f&&f.prototype===t;for(var c=0;c<X;c++){var p=L[c];if(!(s&&p==="constructor")&&F(t,p)){a.push(p)}}}return a}});var Y=Object.keys&&function(){return Object.keys(arguments).length===2}(1,2);var q=Object.keys;N(Object,{keys:function Be(e){if(E(e)){return q(t.slice.call(e))}else{return q(e)}}},!Y);var K=-621987552e5;var Q="-000001";var V=Date.prototype.toISOString&&new Date(K).toISOString().indexOf(Q)===-1;N(Date.prototype,{toISOString:function Ge(){var t,e,r,n,i;if(!isFinite(this)){throw new RangeError("Date.prototype.toISOString called on non-finite value.")}n=this.getUTCFullYear();i=this.getUTCMonth();n+=Math.floor(i/12);i=(i%12+12)%12;t=[i+1,this.getUTCDate(),this.getUTCHours(),this.getUTCMinutes(),this.getUTCSeconds()];n=(n<0?"-":n>9999?"+":"")+("00000"+Math.abs(n)).slice(0<=n&&n<=9999?-4:-6);e=t.length;while(e--){r=t[e];if(r<10){t[e]="0"+r}}return n+"-"+t.slice(0,2).join("-")+"T"+t.slice(2).join(":")+"."+("000"+this.getUTCMilliseconds()).slice(-3)+"Z"}},V);var W=false;try{W=Date.prototype.toJSON&&new Date(NaN).toJSON()===null&&new Date(K).toJSON().indexOf(Q)!==-1&&Date.prototype.toJSON.call({toISOString:function(){return true}})}catch(_){}if(!W){Date.prototype.toJSON=function He(t){var e=Object(this),r=D.ToPrimitive(e),n;if(typeof r==="number"&&!isFinite(r)){return null}n=e.toISOString;if(typeof n!=="function"){throw new TypeError("toISOString property is not callable")}return n.call(e)}}var te=Date.parse("+033658-09-27T01:46:40.000Z")===1e15;var ee=!isNaN(Date.parse("2012-04-04T24:00:00.500Z"))||!isNaN(Date.parse("2012-11-31T23:59:59.000Z"));var re=isNaN(Date.parse("2000-01-01T00:00:00.000Z"));if(!Date.parse||re||ee||!te){Date=function(t){function e(r,n,i,a,o,u,l){var f=arguments.length;if(this instanceof t){var s=f===1&&String(r)===r?new t(e.parse(r)):f>=7?new t(r,n,i,a,o,u,l):f>=6?new t(r,n,i,a,o,u):f>=5?new t(r,n,i,a,o):f>=4?new t(r,n,i,a):f>=3?new t(r,n,i):f>=2?new t(r,n):f>=1?new t(r):new t;s.constructor=e;return s}return t.apply(this,arguments)}var r=new RegExp("^"+"(\\d{4}|[+-]\\d{6})"+"(?:-(\\d{2})"+"(?:-(\\d{2})"+"(?:"+"T(\\d{2})"+":(\\d{2})"+"(?:"+":(\\d{2})"+"(?:(\\.\\d{1,}))?"+")?"+"("+"Z|"+"(?:"+"([-+])"+"(\\d{2})"+":(\\d{2})"+")"+")?)?)?)?"+"$");var n=[0,31,59,90,120,151,181,212,243,273,304,334,365];function i(t,e){var r=e>1?1:0;return n[e]+Math.floor((t-1969+r)/4)-Math.floor((t-1901+r)/100)+Math.floor((t-1601+r)/400)+365*(t-1970)}function a(e){return Number(new t(1970,0,1,0,0,0,e))}for(var o in t){e[o]=t[o]}e.now=t.now;e.UTC=t.UTC;e.prototype=t.prototype;e.prototype.constructor=e;e.parse=function u(e){var n=r.exec(e);if(n){var o=Number(n[1]),u=Number(n[2]||1)-1,l=Number(n[3]||1)-1,f=Number(n[4]||0),s=Number(n[5]||0),c=Number(n[6]||0),p=Math.floor(Number(n[7]||0)*1e3),h=Boolean(n[4]&&!n[8]),v=n[9]==="-"?1:-1,g=Number(n[10]||0),y=Number(n[11]||0),d;if(f<(s>0||c>0||p>0?24:25)&&s<60&&c<60&&p<1e3&&u>-1&&u<12&&g<24&&y<60&&l>-1&&l<i(o,u+1)-i(o,u)){d=((i(o,u)+l)*24+f+g*v)*60;d=((d+s+y*v)*60+c)*1e3+p;if(h){d=a(d)}if(-864e13<=d&&d<=864e13){return d}}return NaN}return t.parse.apply(this,arguments)};return e}(Date)}if(!Date.now){Date.now=function Le(){return(new Date).getTime()}}var ne=i.toFixed&&(8e-5.toFixed(3)!=="0.000"||.9.toFixed(0)!=="1"||1.255.toFixed(2)!=="1.25"||0xde0b6b3a7640080.toFixed(0)!=="1000000000000000128");var ie={base:1e7,size:6,data:[0,0,0,0,0,0],multiply:function Xe(t,e){var r=-1;while(++r<ie.size){e+=t*ie.data[r];ie.data[r]=e%ie.base;e=Math.floor(e/ie.base)}},divide:function Ye(t){var e=ie.size,r=0;while(--e>=0){r+=ie.data[e];ie.data[e]=Math.floor(r/t);r=r%t*ie.base}},numToString:function qe(){var t=ie.size;var e="";while(--t>=0){if(e!==""||t===0||ie.data[t]!==0){var r=String(ie.data[t]);if(e===""){e=r}else{e+="0000000".slice(0,7-r.length)+r}}}return e},pow:function Ke(t,e,r){return e===0?r:e%2===1?Ke(t,e-1,r*t):Ke(t*t,e/2,r)},log:function Qe(t){var e=0;while(t>=4096){e+=12;t/=4096}while(t>=2){e+=1;t/=2}return e}};N(i,{toFixed:function Ve(t){var e,r,n,i,a,o,u,l;e=Number(t);e=e!==e?0:Math.floor(e);if(e<0||e>20){throw new RangeError("Number.toFixed called with invalid number of decimals")}r=Number(this);if(r!==r){return"NaN"}if(r<=-1e21||r>=1e21){return String(r)}n="";if(r<0){n="-";r=-r}i="0";if(r>1e-21){a=ie.log(r*ie.pow(2,69,1))-69;o=a<0?r*ie.pow(2,-a,1):r/ie.pow(2,a,1);o*=4503599627370496;a=52-a;if(a>0){ie.multiply(0,o);u=e;while(u>=7){ie.multiply(1e7,0);u-=7}ie.multiply(ie.pow(10,u,1),0);u=a-1;while(u>=23){ie.divide(1<<23);u-=23}ie.divide(1<<u);ie.multiply(1,1);ie.divide(2);i=ie.numToString()}else{ie.multiply(0,o);ie.multiply(1<<-a,0);i=ie.numToString()+"0.00000000000000000000".slice(2,2+e)}}if(e>0){l=i.length;if(l<=e){i=n+"0.0000000000000000000".slice(0,e-l+2)+i}else{i=n+i.slice(0,l-e)+"."+i.slice(l-e)}}else{i=n+i}return i}},ne);var ae=n.split;if("ab".split(/(?:ab)*/).length!==2||".".split(/(.?)(.?)/).length!==4||"tesst".split(/(s)*/)[1]==="t"||"test".split(/(?:)/,-1).length!==4||"".split(/.?/).length||".".split(/()()/).length>1){(function(){var t=typeof/()??/.exec("")[1]==="undefined";n.split=function(e,r){var n=this;if(typeof e==="undefined"&&r===0){return[]}if(!m(e)){return ae.call(this,e,r)}var i=[],a=(e.ignoreCase?"i":"")+(e.multiline?"m":"")+(e.extended?"x":"")+(e.sticky?"y":""),o=0,l,f,s,c;e=new RegExp(e.source,a+"g");n+="";if(!t){l=new RegExp("^"+e.source+"$(?!\\s)",a)}r=typeof r==="undefined"?-1>>>0:D.ToUint32(r);f=e.exec(n);while(f){s=f.index+f[0].length;if(s>o){i.push(n.slice(o,f.index));if(!t&&f.length>1){f[0].replace(l,function(){for(var t=1;t<arguments.length-2;t++){if(typeof arguments[t]==="undefined"){f[t]=void 0}}})}if(f.length>1&&f.index<n.length){u.apply(i,f.slice(1))}c=f[0].length;o=s;if(i.length>=r){break}}if(e.lastIndex===f.index){e.lastIndex++}f=e.exec(n)}if(o===n.length){if(c||!e.test("")){i.push("")}}else{i.push(n.slice(o))}return i.length>r?i.slice(0,r):i}})()}else if("0".split(void 0,0).length){n.split=function We(t,e){if(typeof t==="undefined"&&e===0){return[]}return ae.call(this,t,e)}}var oe=n.replace;var ue=function(){var t=[];"x".replace(/x(.)?/g,function(e,r){t.push(r)});return t.length===1&&typeof t[0]==="undefined"}();if(!ue){n.replace=function _e(t,e){var r=h(e);var n=m(t)&&/\)[*?]/.test(t.source);if(!r||!n){return oe.call(this,t,e)}else{var i=function(r){var n=arguments.length;var i=t.lastIndex;t.lastIndex=0;var a=t.exec(r)||[];t.lastIndex=i;a.push(arguments[n-2],arguments[n-1]);return e.apply(this,a)};return oe.call(this,t,i)}}}var le=n.substr;var fe="".substr&&"0b".substr(-1)!=="b";N(n,{substr:function tr(t,e){return le.call(this,t<0?(t=this.length+t)<0?0:t:t,e)}},fe);var se=" \n \f\r \xa0\u1680\u180e\u2000\u2001\u2002\u2003"+"\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u202f\u205f\u3000\u2028"+"\u2029\ufeff";var ce="\u200b";var pe="["+se+"]";var he=new RegExp("^"+pe+pe+"*");var ve=new RegExp(pe+pe+"*$");var ge=n.trim&&(se.trim()||!ce.trim());N(n,{trim:function er(){if(typeof this==="undefined"||this===null){throw new TypeError("can't convert "+this+" to object")}return String(this).replace(he,"").replace(ve,"")}},ge);if(parseInt(se+"08")!==8||parseInt(se+"0x16")!==22){parseInt=function(t){var e=/^0[xX]/;return function r(n,i){n=String(n).trim();if(!Number(i)){i=e.test(n)?16:10}return t(n,i)}}(parseInt)}});
7
+ //# sourceMappingURL=es5-shim.map
@@ -0,0 +1,10 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ </head>
5
+ <body>
6
+ <%= javascript_include_tag "pouchdb/es5-shim.min" %>
7
+ <%= javascript_include_tag "pouchdb/pouchdb" %>
8
+ <%= javascript_include_tag @server.main %>
9
+ </body>
10
+ </html>
@@ -0,0 +1,11 @@
1
+ // PouchDB 3.3.1
2
+ //
3
+ // (c) 2012-2015 Dale Harvey and the PouchDB team
4
+ // PouchDB may be freely distributed under the Apache license, version 2.0.
5
+ // For all details and documentation:
6
+ // http://pouchdb.com
7
+ !function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var t;"undefined"!=typeof window?t=window:"undefined"!=typeof global?t=global:"undefined"!=typeof self&&(t=self),t.PouchDB=e()}}(function(){var define,module,exports;return function e(t,n,r){function o(s,a){if(!n[s]){if(!t[s]){var c="function"==typeof require&&require;if(!a&&c)return c(s,!0);if(i)return i(s,!0);var u=new Error("Cannot find module '"+s+"'");throw u.code="MODULE_NOT_FOUND",u}var f=n[s]={exports:{}};t[s][0].call(f.exports,function(e){var n=t[s][1][e];return o(n?n:e)},f,f.exports,e,t,n,r)}return n[s].exports}for(var i="function"==typeof require&&require,s=0;s<r.length;s++)o(r[s]);return o}({1:[function(e,t){"use strict";function n(e,t){for(var n=0;n<e.length;n++)if(t(e[n],n)===!0)return e[n];return!1}function r(e){return function(t,n){t||n[0]&&n[0].error?e(t||n[0]):e(null,n.length?n[0]:n)}}function o(e){var t={},n=[];return c.traverseRevTree(e,function(e,r,o,i){var s=r+"-"+o;return e&&(t[s]=0),void 0!==i&&n.push({from:i,to:s}),s}),n.reverse(),n.forEach(function(e){t[e.from]=void 0===t[e.from]?1+t[e.to]:Math.min(t[e.from],1+t[e.to])}),t}function i(e,t,n){var r="limit"in t?t.keys.slice(t.skip,t.limit+t.skip):t.skip>0?t.keys.slice(t.skip):t.keys;if(t.descending&&r.reverse(),!r.length)return e._allDocs({limit:0},n);var o={offset:t.skip};return p.all(r.map(function(n){var r=a.extend(!0,{key:n,deleted:"ok"},t);return["limit","skip","keys"].forEach(function(e){delete r[e]}),new p(function(t,i){e._allDocs(r,function(e,r){return e?i(e):(o.total_rows=r.total_rows,void t(r.rows[0]||{key:n,error:"not_found"}))})})})).then(function(e){return o.rows=e,o})}function s(){var e=this;f.call(this);var t,n=0,r=["change","delete","create","update"];this.on("newListener",function(o){if(~r.indexOf(o)){if(n)return void n++;n++;var i=0;t=this.changes({conflicts:!0,include_docs:!0,continuous:!0,since:"now",onChange:function(t){t.seq<=i||(i=t.seq,e.emit("change",t),t.doc._deleted?e.emit("delete",t):"1"===t.doc._rev.split("-")[0]?e.emit("create",t):e.emit("update",t))}})}}),this.on("removeListener",function(e){~r.indexOf(e)&&(n--,n||t.cancel())})}var a=e(34),c=e(29),u=e(19),f=e(38).EventEmitter,l=e(25),d=e(13),p=a.Promise;a.inherits(s,f),t.exports=s,s.prototype.post=a.adapterFun("post",function(e,t,n){return"function"==typeof t&&(n=t,t={}),"object"!=typeof e||Array.isArray(e)?n(u.error(u.NOT_AN_OBJECT)):void this.bulkDocs({docs:[e]},t,r(n))}),s.prototype.put=a.adapterFun("put",a.getArguments(function(e){var t,n,o,i,s=e.shift(),c="_id"in s;if("object"!=typeof s||Array.isArray(s))return(i=e.pop())(u.error(u.NOT_AN_OBJECT));for(s=a.clone(s);;)if(t=e.shift(),n=typeof t,"string"!==n||c?"string"!==n||!c||"_rev"in s?"object"===n?o=t:"function"===n&&(i=t):s._rev=t:(s._id=t,c=!0),!e.length)break;o=o||{};var f=a.invalidIdError(s._id);return f?i(f):a.isLocalId(s._id)&&"function"==typeof this._putLocal?s._deleted?this._removeLocal(s,i):this._putLocal(s,i):void this.bulkDocs({docs:[s]},o,r(i))})),s.prototype.putAttachment=a.adapterFun("putAttachment",function(e,t,n,r,o,i){function s(e){return e._attachments=e._attachments||{},e._attachments[t]={content_type:o,data:r},a.put(e)}var a=this;return"function"==typeof o&&(i=o,o=r,r=n,n=null),"undefined"==typeof o&&(o=r,r=n,n=null),a.get(e).then(function(e){if(e._rev!==n)throw u.error(u.REV_CONFLICT);return s(e)},function(t){if(t.reason===u.MISSING_DOC.message)return s({_id:e});throw t})}),s.prototype.removeAttachment=a.adapterFun("removeAttachment",function(e,t,n,r){var o=this;o.get(e,function(e,i){return e?void r(e):i._rev!==n?void r(u.error(u.REV_CONFLICT)):i._attachments?(delete i._attachments[t],0===Object.keys(i._attachments).length&&delete i._attachments,void o.put(i,r)):r()})}),s.prototype.remove=a.adapterFun("remove",function(e,t,n,o){var i;"string"==typeof t?(i={_id:e,_rev:t},"function"==typeof n&&(o=n,n={})):(i=e,"function"==typeof t?(o=t,n={}):(o=n,n=t)),n=a.clone(n||{}),n.was_delete=!0;var s={_id:i._id,_rev:i._rev||n.rev};return s._deleted=!0,a.isLocalId(s._id)&&"function"==typeof this._removeLocal?this._removeLocal(i,o):void this.bulkDocs({docs:[s]},n,r(o))}),s.prototype.revsDiff=a.adapterFun("revsDiff",function(e,t,n){function r(e,t){u.has(e)||u.set(e,{missing:[]}),u.get(e).missing.push(t)}function o(t,n){var o=e[t].slice(0);c.traverseRevTree(n,function(e,n,i,s,a){var c=n+"-"+i,u=o.indexOf(c);-1!==u&&(o.splice(u,1),"available"!==a.status&&r(t,c))}),o.forEach(function(e){r(t,e)})}"function"==typeof t&&(n=t,t={}),t=a.clone(t);var i=Object.keys(e);if(!i.length)return n(null,{});var s=0,u=new a.Map;i.map(function(t){this._getRevisionTree(t,function(r,a){if(r&&404===r.status&&"missing"===r.message)u.set(t,{missing:e[t]});else{if(r)return n(r);o(t,a)}if(++s===i.length){var c={};return u.forEach(function(e,t){c[t]=e}),n(null,c)}})},this)}),s.prototype.compactDocument=a.adapterFun("compactDocument",function(e,t,n){var r=this;this._getRevisionTree(e,function(i,s){if(i)return n(i);var a=o(s),u=[],f=[];Object.keys(a).forEach(function(e){a[e]>t&&u.push(e)}),c.traverseRevTree(s,function(e,t,n,r,o){var i=t+"-"+n;"available"===o.status&&-1!==u.indexOf(i)&&f.push(i)}),r._doCompaction(e,f,n)})}),s.prototype.compact=a.adapterFun("compact",function(e,t){"function"==typeof e&&(t=e,e={});var n=this;e=a.clone(e||{}),n.get("_local/compaction")["catch"](function(){return!1}).then(function(r){return"function"==typeof n._compact?(r&&r.last_seq&&(e.last_seq=r.last_seq),n._compact(e,t)):void 0})}),s.prototype._compact=function(e,t){function n(e){s.push(o.compactDocument(e.id,0))}function r(e){var n=e.last_seq;p.all(s).then(function(){return l(o,"_local/compaction",function(e){return!e.last_seq||e.last_seq<n?(e.last_seq=n,e):!1})}).then(function(){t(null,{ok:!0})})["catch"](t)}var o=this,i={returnDocs:!1,last_seq:e.last_seq||0},s=[];o.changes(i).on("change",n).on("complete",r).on("error",t)},s.prototype.get=a.adapterFun("get",function(e,t,r){function o(){var n=[],o=i.length;return o?void i.forEach(function(i){s.get(e,{rev:i,revs:t.revs,attachments:t.attachments},function(e,t){n.push(e?{missing:i}:{ok:t}),o--,o||r(null,n)})}):r(null,n)}if("function"==typeof t&&(r=t,t={}),"string"!=typeof e)return r(u.error(u.INVALID_ID));if(a.isLocalId(e)&&"function"==typeof this._getLocal)return this._getLocal(e,r);var i=[],s=this;if(!t.open_revs)return this._get(e,t,function(e,o){if(t=a.clone(t),e)return r(e);var i=o.doc,u=o.metadata,f=o.ctx;if(t.conflicts){var l=c.collectConflicts(u);l.length&&(i._conflicts=l)}if(a.isDeleted(u,i._rev)&&(i._deleted=!0),t.revs||t.revs_info){var d=c.rootToLeaf(u.rev_tree),p=n(d,function(e){return-1!==e.ids.map(function(e){return e.id}).indexOf(i._rev.split("-")[1])}),h=p.ids.map(function(e){return e.id}).indexOf(i._rev.split("-")[1])+1,v=p.ids.length-h;if(p.ids.splice(h,v),p.ids.reverse(),t.revs&&(i._revisions={start:p.pos+p.ids.length-1,ids:p.ids.map(function(e){return e.id})}),t.revs_info){var _=p.pos+p.ids.length;i._revs_info=p.ids.map(function(e){return _--,{rev:_+"-"+e.id,status:e.opts.status}})}}if(t.local_seq&&(a.info('The "local_seq" option is deprecated and will be removed'),i._local_seq=o.metadata.seq),t.attachments&&i._attachments){var m=i._attachments,g=Object.keys(m).length;if(0===g)return r(null,i);Object.keys(m).forEach(function(e){this._getAttachment(m[e],{encode:!0,ctx:f},function(t,n){var o=i._attachments[e];o.data=n,delete o.stub,delete o.length,--g||r(null,i)})},s)}else{if(i._attachments)for(var y in i._attachments)i._attachments.hasOwnProperty(y)&&(i._attachments[y].stub=!0);r(null,i)}});if("all"===t.open_revs)this._getRevisionTree(e,function(e,t){return e?r(e):(i=c.collectLeaves(t).map(function(e){return e.rev}),void o())});else{if(!Array.isArray(t.open_revs))return r(u.error(u.UNKNOWN_ERROR,"function_clause"));i=t.open_revs;for(var f=0;f<i.length;f++){var l=i[f];if("string"!=typeof l||!/^\d+-/.test(l))return r(u.error(u.INVALID_REV))}o()}}),s.prototype.getAttachment=a.adapterFun("getAttachment",function(e,t,n,r){var o=this;n instanceof Function&&(r=n,n={}),n=a.clone(n),this._get(e,n,function(e,i){return e?r(e):i.doc._attachments&&i.doc._attachments[t]?(n.ctx=i.ctx,void o._getAttachment(i.doc._attachments[t],n,r)):r(u.error(u.MISSING_DOC))})}),s.prototype.allDocs=a.adapterFun("allDocs",function(e,t){if("function"==typeof e&&(t=e,e={}),e=a.clone(e),e.skip="undefined"!=typeof e.skip?e.skip:0,"keys"in e){if(!Array.isArray(e.keys))return t(new TypeError("options.keys must be an array"));var n=["startkey","endkey","key"].filter(function(t){return t in e})[0];if(n)return void t(u.error(u.QUERY_PARSE_ERROR,"Query parameter `"+n+"` is not compatible with multi-get"));if("http"!==this.type())return i(this,e,t)}return this._allDocs(e,t)}),s.prototype.changes=function(e,t){return"function"==typeof e&&(t=e,e={}),new d(this,e,t)},s.prototype.close=a.adapterFun("close",function(e){return this._closed=!0,this._close(e)}),s.prototype.info=a.adapterFun("info",function(e){var t=this;this._info(function(n,r){return n?e(n):(r.db_name=r.db_name||t._db_name,r.auto_compaction=!(!t.auto_compaction||"http"===t.type()),void e(null,r))})}),s.prototype.id=a.adapterFun("id",function(e){return this._id(e)}),s.prototype.type=function(){return"function"==typeof this._type?this._type():this.adapter},s.prototype.bulkDocs=a.adapterFun("bulkDocs",function(e,t,n){if("function"==typeof t&&(n=t,t={}),t=a.clone(t),Array.isArray(e)&&(e={docs:e}),!e||!e.docs||!Array.isArray(e.docs))return n(u.error(u.MISSING_BULK_DOCS));for(var r=0;r<e.docs.length;++r)if("object"!=typeof e.docs[r]||Array.isArray(e.docs[r]))return n(u.error(u.NOT_AN_OBJECT));return e=a.clone(e),"new_edits"in t||(t.new_edits="new_edits"in e?e.new_edits:!0),t.new_edits||"http"===this.type()||e.docs.sort(function(e,t){var n=a.compare(e._id,t._id);if(0!==n)return n;var r=e._revisions?e._revisions.start:0,o=t._revisions?t._revisions.start:0;return a.compare(r,o)}),e.docs.forEach(function(e){e._deleted&&delete e._attachments}),this._bulkDocs(e,t,function(e,r){return e?n(e):(t.new_edits||(r=r.filter(function(e){return e.error})),void n(null,r))})}),s.prototype.registerDependentDatabase=a.adapterFun("registerDependentDatabase",function(e,t){function n(t){return t.dependentDbs=t.dependentDbs||{},t.dependentDbs[e]?!1:(t.dependentDbs[e]=!0,t)}var r=new this.constructor(e,this.__opts||{});l(this,"_local/_pouch_dependentDbs",n,function(e){return e?t(e):t(null,{db:r})})})},{}],2:[function(e,t){(function(n){"use strict";function r(e){return/^_(design|local)/.test(e)?e:encodeURIComponent(e)}function o(e){return e._attachments&&Object.keys(e._attachments)?l.Promise.all(Object.keys(e._attachments).map(function(t){var n=e._attachments[t];if(n.data&&"string"!=typeof n.data){if(h)return new l.Promise(function(e){l.readAsBinaryString(n.data,function(t){n.data=l.btoa(t),e()})});n.data=n.data.toString("base64")}})):l.Promise.resolve()}function i(e,t){if(/http(s?):/.test(e)){var n=l.parseUri(e);n.remote=!0,(n.user||n.password)&&(n.auth={username:n.user,password:n.password});var r=n.path.replace(/(^\/|\/$)/g,"").split("/");if(n.db=r.pop(),n.path=r.join("/"),t=t||{},t=l.clone(t),n.headers=t.headers||t.ajax&&t.ajax.headers||{},t.auth||n.auth){var o=t.auth||n.auth,i=l.btoa(o.username+":"+o.password);n.headers.Authorization="Basic "+i}return t.headers&&(n.headers=t.headers),n}return{host:"",path:"/",db:e,auth:!1}}function s(e,t){return a(e,e.db+"/"+t)}function a(e,t){if(e.remote){var n=e.path?"/":"";return e.protocol+"://"+e.host+":"+e.port+"/"+e.path+n+t}return"/"+t}function c(e,t){function n(e,t){var n=l.extend({},y,e);return p(n.method+" "+n.url),l.ajax(n,t)}function c(e){return e.split("/").map(encodeURIComponent).join("/")}var _=this;_.getHost=e.getHost?e.getHost:i;var m=_.getHost(e.name,e),g=s(m,"");_.getUrl=function(){return g},_.getHeaders=function(){return l.clone(m.headers)};var y=e.ajax||{};e=l.clone(e);var b=function(){n({headers:m.headers,method:"PUT",url:g},function(e){e&&401===e.status?n({headers:m.headers,method:"HEAD",url:g},function(e){e?t(e):t(null,_)}):e&&412!==e.status?t(e):t(null,_)})};e.skipSetup||n({headers:m.headers,method:"GET",url:g},function(e){e?404===e.status?(l.explain404("PouchDB is just detecting if the remote DB exists."),b()):t(e):t(null,_)}),_.type=function(){return"http"},_.id=l.adapterFun("id",function(e){n({headers:m.headers,method:"GET",url:a(m,"")},function(t,n){var r=n&&n.uuid?n.uuid+m.db:s(m,"");e(null,r)})}),_.request=l.adapterFun("request",function(e,t){e.headers=m.headers,e.url=s(m,e.url),n(e,t)}),_.compact=l.adapterFun("compact",function(e,t){"function"==typeof e&&(t=e,e={}),e=l.clone(e),n({headers:m.headers,url:s(m,"_compact"),method:"POST"},function(){function n(){_.info(function(r,o){o.compact_running?setTimeout(n,e.interval||200):t(null,{ok:!0})})}"function"==typeof t&&n()})}),_._info=function(e){n({headers:m.headers,method:"GET",url:s(m,"")},function(t,n){t?e(t):(n.host=s(m,""),e(null,n))})},_.get=l.adapterFun("get",function(e,t,o){"function"==typeof t&&(o=t,t={}),t=l.clone(t),void 0===t.auto_encode&&(t.auto_encode=!0);var i=[];t.revs&&i.push("revs=true"),t.revs_info&&i.push("revs_info=true"),t.local_seq&&i.push("local_seq=true"),t.open_revs&&("all"!==t.open_revs&&(t.open_revs=JSON.stringify(t.open_revs)),i.push("open_revs="+t.open_revs)),t.attachments&&i.push("attachments=true"),t.rev&&i.push("rev="+t.rev),t.conflicts&&i.push("conflicts="+t.conflicts),i=i.join("&"),i=""===i?"":"?"+i,t.auto_encode&&(e=r(e));var a={headers:m.headers,method:"GET",url:s(m,e+i)},c=e.split("/");(c.length>1&&"_design"!==c[0]&&"_local"!==c[0]||c.length>2&&"_design"===c[0]&&"_local"!==c[0])&&(a.binary=!0),n(a,function(e,t,n){return e?o(e):void o(null,t,n)})}),_.remove=l.adapterFun("remove",function(e,t,o,i){var a;"string"==typeof t?(a={_id:e,_rev:t},"function"==typeof o&&(i=o,o={})):(a=e,"function"==typeof t?(i=t,o={}):(i=o,o=t));var c=a._rev||o.rev;n({headers:m.headers,method:"DELETE",url:s(m,r(a._id))+"?rev="+c},i)}),_.getAttachment=l.adapterFun("getAttachment",function(e,t,n,o){"function"==typeof n&&(o=n,n={}),n=l.clone(n),void 0===n.auto_encode&&(n.auto_encode=!0),n.auto_encode&&(e=r(e)),n.auto_encode=!1,_.get(e+"/"+c(t),n,o)}),_.removeAttachment=l.adapterFun("removeAttachment",function(e,t,o,i){var a=s(m,r(e)+"/"+c(t))+"?rev="+o;n({headers:m.headers,method:"DELETE",url:a},i)}),_.putAttachment=l.adapterFun("putAttachment",function(e,t,o,i,a,u){"function"==typeof a&&(u=a,a=i,i=o,o=null),"undefined"==typeof a&&(a=i,i=o,o=null);var f=r(e)+"/"+c(t),p=s(m,f);if(o&&(p+="?rev="+o),"string"==typeof i){var _;try{_=l.atob(i)}catch(g){return u(d.error(d.BAD_ARG,"Attachments need to be base64 encoded"))}i=h?l.createBlob([l.fixBinary(_)],{type:a}):_?new v(_,"binary"):""}var y={headers:l.clone(m.headers),method:"PUT",url:p,processData:!1,body:i,timeout:6e4};y.headers["Content-Type"]=a,n(y,u)}),_.put=l.adapterFun("put",l.getArguments(function(e){var t,i,a,c=e.shift(),u="_id"in c,f=e.pop();return"object"!=typeof c||Array.isArray(c)?f(d.error(d.NOT_AN_OBJECT)):(c=l.clone(c),void o(c).then(function(){for(;;)if(t=e.shift(),i=typeof t,"string"!==i||u?"string"!==i||!u||"_rev"in c?"object"===i&&(a=l.clone(t)):c._rev=t:(c._id=t,u=!0),!e.length)break;a=a||{};var o=l.invalidIdError(c._id);if(o)throw o;var d=[];a&&"undefined"!=typeof a.new_edits&&d.push("new_edits="+a.new_edits),d=d.join("&"),""!==d&&(d="?"+d),n({headers:m.headers,method:"PUT",url:s(m,r(c._id))+d,body:c},function(e,t){return e?f(e):(t.ok=!0,void f(null,t))})})["catch"](f))})),_.post=l.adapterFun("post",function(e,t,n){return"function"==typeof t&&(n=t,t={}),t=l.clone(t),"object"!=typeof e?n(d.error(d.NOT_AN_OBJECT)):("_id"in e||(e._id=l.uuid()),void _.put(e,t,function(e,t){return e?n(e):(t.ok=!0,void n(null,t))}))}),_._bulkDocs=function(e,t,r){"undefined"!=typeof t.new_edits&&(e.new_edits=t.new_edits),l.Promise.all(e.docs.map(o)).then(function(){n({headers:m.headers,method:"POST",url:s(m,"_bulk_docs"),body:e},function(e,t){return e?r(e):(t.forEach(function(e){e.ok=!0}),void r(null,t))})})["catch"](r)},_.allDocs=l.adapterFun("allDocs",function(e,t){"function"==typeof e&&(t=e,e={}),e=l.clone(e);var r,o=[],i="GET";if(e.conflicts&&o.push("conflicts=true"),e.descending&&o.push("descending=true"),e.include_docs&&o.push("include_docs=true"),e.attachments&&o.push("attachments=true"),e.key&&o.push("key="+encodeURIComponent(JSON.stringify(e.key))),e.startkey&&o.push("startkey="+encodeURIComponent(JSON.stringify(e.startkey))),e.endkey&&o.push("endkey="+encodeURIComponent(JSON.stringify(e.endkey))),"undefined"!=typeof e.inclusive_end&&o.push("inclusive_end="+!!e.inclusive_end),"undefined"!=typeof e.limit&&o.push("limit="+e.limit),"undefined"!=typeof e.skip&&o.push("skip="+e.skip),o=o.join("&"),""!==o&&(o="?"+o),"undefined"!=typeof e.keys){var a="keys="+encodeURIComponent(JSON.stringify(e.keys));a.length+o.length+1<=f?o+=(-1!==o.indexOf("?")?"&":"?")+a:(i="POST",r=JSON.stringify({keys:e.keys}))}n({headers:m.headers,method:i,url:s(m,"_all_docs"+o),body:r},t)}),_._changes=function(e){var t="batch_size"in e?e.batch_size:u;e=l.clone(e),e.timeout=e.timeout||3e4;var r={timeout:e.timeout-5e3},o="undefined"!=typeof e.limit?e.limit:!1;0===o&&(o=1);var i;i="returnDocs"in e?e.returnDocs:!0;var a=o;if(e.style&&(r.style=e.style),(e.include_docs||e.filter&&"function"==typeof e.filter)&&(r.include_docs=!0),e.attachments&&(r.attachments=!0),e.continuous&&(r.feed="longpoll"),e.conflicts&&(r.conflicts=!0),e.descending&&(r.descending=!0),e.filter&&"string"==typeof e.filter&&(r.filter=e.filter,"_view"===e.filter&&e.view&&"string"==typeof e.view&&(r.view=e.view)),e.query_params&&"object"==typeof e.query_params)for(var c in e.query_params)e.query_params.hasOwnProperty(c)&&(r[c]=e.query_params[c]);var p,h="GET";if(e.doc_ids){r.filter="_doc_ids";var v=JSON.stringify(e.doc_ids);v.length<f?r.doc_ids=v:(h="POST",p={doc_ids:e.doc_ids})}if(e.continuous&&_._useSSE)return _.sse(e,r,i);var g,y,b=function(i,c){if(!e.aborted){r.since=i,"object"==typeof r.since&&(r.since=JSON.stringify(r.since)),e.descending?o&&(r.limit=a):r.limit=!o||a>t?t:a;var u="?"+Object.keys(r).map(function(e){return e+"="+r[e]}).join("&"),f={headers:m.headers,method:h,url:s(m,"_changes"+u),timeout:e.timeout,body:p};y=i,e.aborted||(g=n(f,c))}},E=10,w=0,S={results:[]},T=function(n,r){if(!e.aborted){var s=0;if(r&&r.results){s=r.results.length,S.last_seq=r.last_seq;var c={};c.query=e.query_params,r.results=r.results.filter(function(t){a--;var n=l.filterChange(e)(t);return n&&(i&&S.results.push(t),l.call(e.onChange,t)),n})}else if(n)return e.aborted=!0,void l.call(e.complete,n);r&&r.last_seq&&(y=r.last_seq);var u=o&&0>=a||r&&t>s||e.descending;if((!e.continuous||o&&0>=a)&&u)l.call(e.complete,null,S);else{n?w+=1:w=0;var f=1<<w,p=E*f,h=e.maximumWait||3e4;if(p>h)return void l.call(e.complete,n||d.error(d.UNKNOWN_ERROR));setTimeout(function(){b(y,T)},p)}}};return b(e.since||0,T),{cancel:function(){e.aborted=!0,g&&g.abort()}}},_.sse=function(e,t,n){function r(t){var r=JSON.parse(t.data);n&&u.results.push(r),u.last_seq=r.seq,l.call(e.onChange,r)}function o(t){return c.removeEventListener("message",r,!1),d===!1?(_._useSSE=!1,void(f=_._changes(e))):(c.close(),void l.call(e.complete,t))}t.feed="eventsource",t.since=e.since||0,t.limit=e.limit,delete t.timeout;var i="?"+Object.keys(t).map(function(e){return e+"="+t[e]}).join("&"),a=s(m,"_changes"+i),c=new EventSource(a),u={results:[],last_seq:!1},f=!1,d=!1;return c.addEventListener("message",r,!1),c.onopen=function(){d=!0},c.onerror=o,{cancel:function(){return f?f.cancel():(c.removeEventListener("message",r,!1),void c.close())}}},_._useSSE=!1,_.revsDiff=l.adapterFun("revsDiff",function(e,t,r){"function"==typeof t&&(r=t,t={}),n({headers:m.headers,method:"POST",url:s(m,"_revs_diff"),body:JSON.stringify(e)},r)}),_._close=function(e){e()},_.destroy=l.adapterFun("destroy",function(e){n({url:s(m,""),method:"DELETE",headers:m.headers},function(t,n){t?(_.emit("error",t),e(t)):(_.emit("destroyed"),e(null,n))})})}var u=25,f=1800,l=e(34),d=e(19),p=e(40)("pouchdb:http"),h="undefined"==typeof n||n.browser,v=e(18);c.destroy=l.toPromise(function(e,t,n){var r=i(e,t);t=t||{},"function"==typeof t&&(n=t,t={}),t=l.clone(t),t.headers=r.headers,t.method="DELETE",t.url=s(r,"");var o=t.ajax||{};t=l.extend({},t,o),l.ajax(t,n)}),c.valid=function(){return!0},t.exports=c}).call(this,e(39))},{}],3:[function(e,t){"use strict";function n(e,t){return new r.Promise(function(n,o){var s=r.createBlob([""],{type:"image/png"});e.objectStore(i).put(s,"key"),e.oncomplete=function(){var e=t.transaction([i],"readwrite"),s=e.objectStore(i).get("key");s.onerror=o,s.onsuccess=function(e){var t=e.target.result,o=URL.createObjectURL(t);r.ajax({url:o,cache:!0,binary:!0},function(e,t){e&&405===e.status?n(!0):(n(!(!t||"image/png"!==t.type)),e&&404===e.status&&r.explain404("PouchDB is just detecting blob URL support.")),URL.revokeObjectURL(o)})}}})["catch"](function(){return!1})}var r=e(34),o=e(5),i=o.DETECT_BLOB_SUPPORT_STORE;t.exports=n},{}],4:[function(e,t){"use strict";function n(e,t,n,i,s,g){function y(){var e=[f,u,c,d,l,a],t=m(i,e,"readwrite");return t.error?g(t.error):(D=t.txn,D.onerror=_(g),D.ontimeout=_(g),D.oncomplete=w,C=D.objectStore(f),L=D.objectStore(u),I=D.objectStore(c),N=D.objectStore(a),void T(function(e){return e?(H=!0,g(e)):void E()}))}function b(){r.processDocs(B,n,J,D,U,x,t)}function E(){function e(){++n===B.length&&b()}function t(t){var n=h(t.target.result);n&&J.set(n.id,n),e()}if(B.length)for(var n=0,o=0,i=B.length;i>o;o++){var s=B[o];if(s._id&&r.isLocalId(s._id))e();else{var a=C.get(s.metadata.id);a.onsuccess=t}}}function w(){H||(s.notify(n._name),n._docCount=-1,g(null,U))}function S(e,t){var n=I.get(e);n.onsuccess=function(n){if(n.target.result)t();else{var r=o.error(o.MISSING_STUB,"unknown stub attachment with digest "+e);r.status=412,t(r)}}}function T(e){function t(){++o===n.length&&e(r)}var n=[];if(B.forEach(function(e){e.data&&e.data._attachments&&Object.keys(e.data._attachments).forEach(function(t){var r=e.data._attachments[t];r.stub&&n.push(r.digest)})}),!n.length)return e();var r,o=0;n.forEach(function(e){S(e,function(e){e&&!r&&(r=e),t()})})}function x(e,t,n,r,o,i,s){var a=e.data;a._id=e.metadata.id,a._rev=e.metadata.rev,n&&(a._deleted=!0);var c=a._attachments&&Object.keys(a._attachments).length;return c?k(e,t,n,r,o,s):void O(e,t,n,r,o,s)}function A(e){var t=r.compactTree(e.metadata);p(t,e.metadata.id,D)}function O(e,t,r,o,i,s){function a(o){i&&n.auto_compaction&&A(e),l.seq=o.target.result,delete l.rev;var s=v(l,t,r),a=C.put(s);a.onsuccess=u}function c(e){e.preventDefault(),e.stopPropagation();var t=L.index("_doc_id_rev"),n=t.getKey(f._doc_id_rev);n.onsuccess=function(e){var t=L.put(f,e.target.result);t.onsuccess=a}}function u(){U[s]={ok:!0,id:l.id,rev:t},J.set(e.metadata.id,e.metadata),q(e,l.seq,o)}var f=e.data,l=e.metadata;f._doc_id_rev=l.id+"::"+l.rev,delete f._id,delete f._rev;var d=L.put(f);d.onsuccess=a,d.onerror=c}function k(e,t,n,r,o,i){function s(){u===f.length&&O(e,t,n,r,o,i)}function a(){u++,s()}var c=e.data,u=0,f=Object.keys(c._attachments);f.forEach(function(t){var n=e.data._attachments[t];if(n.stub)u++,s();else{var r=n.data;delete n.data;var o=n.digest;R(o,r,a)}})}function q(e,t,n){function r(){++i===s.length&&n()}function o(n){var o=e.data._attachments[n].digest,i=N.put({seq:t,digestSeq:o+"::"+t});i.onsuccess=r,i.onerror=function(e){e.preventDefault(),e.stopPropagation(),r()}}var i=0,s=Object.keys(e.data._attachments||{});if(!s.length)return n();for(var a=0;a<s.length;a++)o(s[a])}function R(e,t,n){var r=I.count(e);r.onsuccess=function(r){var o=r.target.result;if(o)return n();var i={digest:e,body:t},s=I.put(i);s.onsuccess=n}}for(var D,C,L,I,N,j,B=e.docs,F=0,M=B.length;M>F;F++){var P=B[F];P._id&&r.isLocalId(P._id)||(P=B[F]=r.parseDoc(P,t.new_edits),P.error&&!j&&(j=P))}if(j)return g(j);var U=new Array(B.length),J=new r.Map,H=!1,V=n._blobSupport?"blob":"base64";r.preprocessAttachments(B,V,function(e){return e?g(e):void y()})}var r=e(34),o=e(19),i=e(6),s=e(5),a=s.ATTACH_AND_SEQ_STORE,c=s.ATTACH_STORE,u=s.BY_SEQ_STORE,f=s.DOC_STORE,l=s.LOCAL_STORE,d=s.META_STORE,p=i.compactRevs,h=i.decodeMetadata,v=i.encodeMetadata,_=i.idbError,m=i.openTransactionSafely;t.exports=n},{}],5:[function(e,t,n){"use strict";n.ADAPTER_VERSION=5,n.DOC_STORE="document-store",n.BY_SEQ_STORE="by-sequence",n.ATTACH_STORE="attach-store",n.ATTACH_AND_SEQ_STORE="attach-seq-store",n.META_STORE="meta-store",n.LOCAL_STORE="local-store",n.DETECT_BLOB_SUPPORT_STORE="detect-blob-support"},{}],6:[function(e,t,n){(function(t){"use strict";function r(e,t,n){try{e.apply(t,n)}catch(r){"undefined"!=typeof PouchDB&&PouchDB.emit("error",r)}}var o=e(19),i=e(34),s=e(5);n.taskQueue={running:!1,queue:[]},n.applyNext=function(){if(!n.taskQueue.running&&n.taskQueue.queue.length){n.taskQueue.running=!0;var e=n.taskQueue.queue.shift();e.action(function(o,i){r(e.callback,this,[o,i]),n.taskQueue.running=!1,t.nextTick(n.applyNext)})}},n.idbError=function(e){return function(t){var n=t.target&&t.target.error&&t.target.error.name||t.target;e(o.error(o.IDB_ERROR,n,t.type))}},n.encodeMetadata=function(e,t,n){return{data:i.safeJsonStringify(e),winningRev:t,deletedOrLocal:n?"1":"0",seq:e.seq,id:e.id}},n.decodeMetadata=function(e){if(!e)return null;var t=i.safeJsonParse(e.data);return t.winningRev=e.winningRev,t.deletedOrLocal="1"===e.deletedOrLocal,t.seq=e.seq,t},n.decodeDoc=function(e){if(!e)return e;var t=i.lastIndexOf(e._doc_id_rev,":");return e._id=e._doc_id_rev.substring(0,t-1),e._rev=e._doc_id_rev.substring(t+1),delete e._doc_id_rev,e},n.readBlobData=function(e,t,n,r){n?e?"string"!=typeof e?i.readAsBinaryString(e,function(e){r(i.btoa(e))}):r(e):r(""):e?"string"!=typeof e?r(e):(e=i.fixBinary(atob(e)),r(i.createBlob([e],{type:t}))):r(i.createBlob([""],{type:t}))},n.fetchAttachmentsIfNecessary=function(e,t,n,r){function o(){++c===a.length&&r&&r()}function i(e,t){var r=e._attachments[t],i=r.digest,a=n.objectStore(s.ATTACH_STORE).get(i);a.onsuccess=function(e){r.body=e.target.result.body,o()}}var a=Object.keys(e._attachments||{});if(!a.length)return r&&r();var c=0;a.forEach(function(n){t.attachments&&t.include_docs?i(e,n):(e._attachments[n].stub=!0,o())})},n.postProcessAttachments=function(e){return i.Promise.all(e.map(function(e){if(e.doc&&e.doc._attachments){var t=Object.keys(e.doc._attachments);return i.Promise.all(t.map(function(t){var r=e.doc._attachments[t];if("body"in r){var o=r.body,s=r.content_type;return new i.Promise(function(a){n.readBlobData(o,s,!0,function(n){e.doc._attachments[t]=i.extend(i.pick(r,["digest","content_type"]),{data:n}),a()})})}}))}}))},n.compactRevs=function(e,t,n){function r(){f--,f||o()}function o(){i.length&&i.forEach(function(e){var t=u.index("digestSeq").count(IDBKeyRange.bound(e+"::",e+"::￿",!1,!1));t.onsuccess=function(t){var n=t.target.result;n||c["delete"](e)}})}var i=[],a=n.objectStore(s.BY_SEQ_STORE),c=n.objectStore(s.ATTACH_STORE),u=n.objectStore(s.ATTACH_AND_SEQ_STORE),f=e.length;e.forEach(function(e){var n=a.index("_doc_id_rev"),o=t+"::"+e;n.getKey(o).onsuccess=function(e){var t=e.target.result;if("number"!=typeof t)return r();a["delete"](t);var n=u.index("seq").openCursor(IDBKeyRange.only(t));n.onsuccess=function(e){var t=e.target.result;if(t){var n=t.value.digestSeq.split("::")[0];i.push(n),u["delete"](t.primaryKey),t["continue"]()}else r()}}})},n.openTransactionSafely=function(e,t,n){try{return{txn:e.transaction(t,n)}}catch(r){return{error:r}}}}).call(this,e(39))},{}],7:[function(e,t){(function(n){"use strict";function r(e,t){var n=this;D.queue.push({action:function(t){o(n,e,t)},callback:t}),w()}function o(e,t,o){function i(e){var t=e.createObjectStore(y,{keyPath:"id"});e.createObjectStore(m,{autoIncrement:!0}).createIndex("_doc_id_rev","_doc_id_rev",{unique:!0}),e.createObjectStore(_,{keyPath:"digest"}),e.createObjectStore(E,{keyPath:"id",autoIncrement:!1}),e.createObjectStore(g),t.createIndex("deletedOrLocal","deletedOrLocal",{unique:!1}),e.createObjectStore(b,{keyPath:"_id"});var n=e.createObjectStore(v,{autoIncrement:!0});n.createIndex("seq","seq"),n.createIndex("digestSeq","digestSeq",{unique:!0})}function f(e,t){var n=e.objectStore(y);n.createIndex("deletedOrLocal","deletedOrLocal",{unique:!1}),n.openCursor().onsuccess=function(e){var r=e.target.result;if(r){var o=r.value,i=a.isDeleted(o);o.deletedOrLocal=i?"1":"0",n.put(o),r["continue"]()}else t()}}function l(e){e.createObjectStore(b,{keyPath:"_id"}).createIndex("_doc_id_rev","_doc_id_rev",{unique:!0})}function w(e,t){var n=e.objectStore(b),r=e.objectStore(y),o=e.objectStore(m),i=r.openCursor();i.onsuccess=function(e){var i=e.target.result;if(i){var s=i.value,u=s.id,f=a.isLocalId(u),l=c.winningRev(s);if(f){var d=u+"::"+l,p=u+"::",h=u+"::~",v=o.index("_doc_id_rev"),_=IDBKeyRange.bound(p,h,!1,!1),m=v.openCursor(_);m.onsuccess=function(e){if(m=e.target.result){var t=m.value;t._doc_id_rev===d&&n.put(t),o["delete"](m.primaryKey),m["continue"]()}else r["delete"](i.primaryKey),i["continue"]()}}else i["continue"]()}else t&&t()}}function D(e){var t=e.createObjectStore(v,{autoIncrement:!0});t.createIndex("seq","seq"),t.createIndex("digestSeq","digestSeq",{unique:!0})}function I(e,t){var n=e.objectStore(m),r=e.objectStore(_),o=e.objectStore(v),i=r.count();i.onsuccess=function(e){var r=e.target.result;return r?void(n.openCursor().onsuccess=function(e){var n=e.target.result;if(!n)return t();for(var r=n.value,i=n.primaryKey,s=Object.keys(r._attachments||{}),a={},c=0;c<s.length;c++){var u=r._attachments[s[c]];a[u.digest]=!0}var f=Object.keys(a);for(c=0;c<f.length;c++){var l=f[c];o.put({seq:i,digestSeq:l+"::"+i})}n["continue"]()}):t()}}function N(e){function t(e){return e.data?x(e):(e.deletedOrLocal="1"===e.deletedOrLocal,e)}var n=e.objectStore(m),r=e.objectStore(y),o=r.openCursor();o.onsuccess=function(e){function o(){var e=a.id+"::",t=a.id+"::￿",r=n.index("_doc_id_rev").openCursor(IDBKeyRange.bound(e,t)),o=0;r.onsuccess=function(e){var t=e.target.result;if(!t)return a.seq=o,i();var n=t.primaryKey;n>o&&(o=n),t["continue"]()}}function i(){var e=A(a,a.winningRev,a.deletedOrLocal),t=r.put(e);t.onsuccess=function(){s["continue"]()}}var s=e.target.result;if(s){var a=t(s.value);return a.winningRev=a.winningRev||c.winningRev(a),a.seq?i():void o()}}}function j(e,t,n,r,o){try{if(e&&t)return o?IDBKeyRange.bound(t,e,!n,!1):IDBKeyRange.bound(e,t,!1,!n);if(e)return o?IDBKeyRange.upperBound(e):IDBKeyRange.lowerBound(e);if(t)return o?IDBKeyRange.lowerBound(t,!n):IDBKeyRange.upperBound(t,!n);if(r)return IDBKeyRange.only(r)}catch(i){return{error:i}}return null}function B(e,t,n){function r(){n(null,{total_rows:e,offset:t.skip,rows:A})}var o="startkey"in t?t.startkey:!1,i="endkey"in t?t.endkey:!1,s="key"in t?t.key:!1,f=t.skip||0,l="number"==typeof t.limit?t.limit:-1,d=t.inclusive_end!==!1,p="descending"in t&&t.descending?"prev":null,h=j(o,i,d,s,p);if(h&&h.error){var v=h.error;return"DataError"===v.name&&0===v.code?n(null,{total_rows:e,offset:t.skip,rows:[]}):n(u.error(u.IDB_ERROR,v.name,v.message))}var g=[y,m];t.attachments&&g.push(_);var b=C(J,g,"readonly");if(b.error)return n(b.error);var E=b.txn;E.oncomplete=function(){t.attachments?q(A).then(r):r()};var w=E.objectStore(y),S=p?w.openCursor(h,p):w.openCursor(h),A=[];S.onsuccess=function(e){function n(e,n){var o={id:e.id,key:e.id,value:{rev:i}};t.include_docs&&(o.doc=n,t.conflicts&&(o.doc._conflicts=c.collectConflicts(e)),O(o.doc,t,E));var s=a.isDeleted(e,i);if("ok"===t.deleted)s&&(o.value.deleted=!0,o.doc=null),A.push(o);else if(!s&&f--<=0&&(A.push(o),0===--l))return;r["continue"]()}if(e.target.result){var r=e.target.result,o=x(r.value),i=o.winningRev;if(t.include_docs){var s=E.objectStore(m).index("_doc_id_rev"),u=o.id+"::"+i;s.get(u).onsuccess=function(e){n(x(r.value),T(e.target.result))}}else n(o)}}}function F(t){if(-1!==e._docCount)return t(null,e._docCount);var n,r=C(J,[y],"readonly");if(r.error)return t(r.error);var o=r.txn,i=o.objectStore(y).index("deletedOrLocal");i.count(IDBKeyRange.only("0")).onsuccess=function(e){n=e.target.result
8
+ },o.onerror=k(t),o.oncomplete=function(){e._docCount=n,t(null,e._docCount)}}var M=t.name,P=null,U=!1,J=null;e._docCount=-1,e._blobSupport=null,e._name=M,e.type=function(){return"idb"},e._id=a.toPromise(function(e){e(null,P)}),e._bulkDocs=function(t,n,o){d(t,n,e,J,r.Changes,o)},e._get=function(e,t,n){function r(){n(s,{doc:o,metadata:i,ctx:c})}var o,i,s,c;if(t=a.clone(t),t.ctx)c=t.ctx;else{var f=C(J,[y,m,_],"readonly");if(f.error)return n(f.error);c=f.txn}c.objectStore(y).get(e).onsuccess=function(e){if(i=x(e.target.result),!i)return s=u.error(u.MISSING_DOC,"missing"),r();if(a.isDeleted(i)&&!t.rev)return s=u.error(u.MISSING_DOC,"deleted"),r();var n=c.objectStore(m),f=t.rev||i.winningRev,l=i.id+"::"+f;n.index("_doc_id_rev").get(l).onsuccess=function(e){return o=e.target.result,o&&(o=T(o)),o?void r():(s=u.error(u.MISSING_DOC,"missing"),r())}}},e._getAttachment=function(e,t,n){var r;if(t=a.clone(t),t.ctx)r=t.ctx;else{var o=C(J,[y,m,_],"readonly");if(o.error)return n(o.error);r=o.txn}var i=e.digest,s=e.content_type;r.objectStore(_).get(i).onsuccess=function(e){var r=e.target.result.body;R(r,s,t.encode,function(e){n(null,e)})}},e._allDocs=function(e,t){F(function(n,r){return n?t(n):0===e.limit?t(null,{total_rows:r,offset:e.skip,rows:[]}):void B(r,e,t)})},e._info=function(t){F(function(n,r){if(n)return t(n);if(null===J||!L[e._name]){var o=new Error("db isn't open");return o.id="idbNull",t(o)}var i=0,s=C(J,[m],"readonly");if(s.error)return t(s.error);var a=s.txn;a.objectStore(m).openCursor(null,"prev").onsuccess=function(e){var t=e.target.result;i=t?t.key:0},a.oncomplete=function(){t(null,{doc_count:r,update_seq:i,idb_attachment_format:e._blobSupport?"binary":"base64"})}})},e._changes=function(t){function n(e){function n(){return a.seq!==s?e["continue"]():(l=s,a.winningRev===i._rev?o(i):void r())}function r(){var e=i._id+"::"+a.winningRev,t=v.index("_doc_id_rev").openCursor(IDBKeyRange.bound(e,e+"￿"));t.onsuccess=function(e){o(T(e.target.result.value))}}function o(n){var r=t.processChange(n,a,t);r.seq=a.seq,w(r)&&(E++,p&&b.push(r),t.attachments&&t.include_docs?O(n,t,h,function(){q([r]).then(function(){t.onChange(r)})}):t.onChange(r)),E!==d&&e["continue"]()}var i=T(e.value),s=e.key;if(u&&!u.has(i._id))return e["continue"]();var a;return(a=S.get(i._id))?n():void(g.get(i._id).onsuccess=function(e){a=x(e.target.result),S.set(i._id,a),n()})}function o(e){var t=e.target.result;t&&n(t)}function i(){var e=[y,m];t.attachments&&e.push(_);var n=C(J,e,"readonly");if(n.error)return t.complete(n.error);h=n.txn,h.onerror=k(t.complete),h.oncomplete=s,v=h.objectStore(m),g=h.objectStore(y);var r;r=f?v.openCursor(null,f):v.openCursor(IDBKeyRange.lowerBound(t.since,!0)),r.onsuccess=o}function s(){function e(){t.complete(null,{results:b,last_seq:l})}!t.continuous&&t.attachments?q(b).then(e):e()}if(t=a.clone(t),t.continuous){var c=M+":"+a.uuid();return r.Changes.addListener(M,c,e,t),r.Changes.notify(M),{cancel:function(){r.Changes.removeListener(M,c)}}}var u=t.doc_ids&&new a.Set(t.doc_ids),f=t.descending?"prev":null;t.since=t.since||0;var l=t.since,d="limit"in t?t.limit:-1;0===d&&(d=1);var p;p="returnDocs"in t?t.returnDocs:!0;var h,v,g,b=[],E=0,w=a.filterChange(t),S=new a.Map;i()},e._close=function(e){return null===J?e(u.error(u.NOT_OPEN)):(J.close(),delete L[M],J=null,void e())},e._getRevisionTree=function(e,t){var n=C(J,[y],"readonly");if(n.error)return t(n.error);var r=n.txn,o=r.objectStore(y).get(e);o.onsuccess=function(e){var n=x(e.target.result);n?t(null,n.rev_tree):t(u.error(u.MISSING_DOC))}},e._doCompaction=function(e,t,n){var r=[y,m,_,v],o=C(J,r,"readwrite");if(o.error)return n(o.error);var i=o.txn,s=i.objectStore(y);s.get(e).onsuccess=function(n){var r=x(n.target.result);c.traverseRevTree(r.rev_tree,function(e,n,r,o,i){var s=n+"-"+r;-1!==t.indexOf(s)&&(i.status="missing")}),S(t,e,i);var o=r.winningRev,s=r.deletedOrLocal;i.objectStore(y).put(A(r,o,s))},i.onerror=k(n),i.oncomplete=function(){a.call(n)}},e._getLocal=function(e,t){var n=C(J,[b],"readonly");if(n.error)return t(n.error);var r=n.txn,o=r.objectStore(b).get(e);o.onerror=k(t),o.onsuccess=function(e){var n=e.target.result;n?(delete n._doc_id_rev,t(null,n)):t(u.error(u.MISSING_DOC))}},e._putLocal=function(e,t,n){"function"==typeof t&&(n=t,t={}),delete e._revisions;var r=e._rev,o=e._id;e._rev=r?"0-"+(parseInt(r.split("-")[1],10)+1):"0-1";var i,s=t.ctx;if(!s){var a=C(J,[b],"readwrite");if(a.error)return n(a.error);s=a.txn,s.onerror=k(n),s.oncomplete=function(){i&&n(null,i)}}var c,f=s.objectStore(b);r?(c=f.get(o),c.onsuccess=function(o){var s=o.target.result;if(s&&s._rev===r){var a=f.put(e);a.onsuccess=function(){i={ok:!0,id:e._id,rev:e._rev},t.ctx&&n(null,i)}}else n(u.error(u.REV_CONFLICT))}):(c=f.add(e),c.onerror=function(e){n(u.error(u.REV_CONFLICT)),e.preventDefault(),e.stopPropagation()},c.onsuccess=function(){i={ok:!0,id:e._id,rev:e._rev},t.ctx&&n(null,i)})},e._removeLocal=function(e,t){var n=C(J,[b],"readwrite");if(n.error)return t(n.error);var r,o=n.txn;o.oncomplete=function(){r&&t(null,r)};var i=e._id,s=o.objectStore(b),a=s.get(i);a.onerror=k(t),a.onsuccess=function(n){var o=n.target.result;o&&o._rev===e._rev?(s["delete"](i),r={ok:!0,id:i,rev:"0-0"}):t(u.error(u.MISSING_DOC))}};var H=L[M];if(H)return J=H.idb,P=H.instanceId,e._blobSupport=H.blobSupport,void n.nextTick(function(){o(null,e)});var V=indexedDB.open(M,h);"openReqList"in r||(r.openReqList={}),r.openReqList[M]=V,V.onupgradeneeded=function(e){function t(){var e=o[s-1];s++,e&&e(r,t)}var n=e.target.result;if(e.oldVersion<1)return i(n);var r=e.currentTarget.transaction;e.oldVersion<3&&l(n),e.oldVersion<4&&D(n);var o=[f,w,I,N],s=e.oldVersion;t()},V.onsuccess=function(t){J=t.target.result,J.onversionchange=function(){J.close(),delete L[M]},J.onabort=function(){J.close(),delete L[M]};var n=J.transaction([E,g],"readwrite"),r=n.objectStore(E).get(E);r.onsuccess=function(t){var r=function(){null!==e._blobSupport&&U&&(L[M]={idb:J,instanceId:P,blobSupport:e._blobSupport,loaded:!0},o(null,e))},i=t.target.result||{id:E};M+"_id"in i?(P=i[M+"_id"],U=!0,r()):(P=a.uuid(),i[M+"_id"]=P,n.objectStore(E).put(i).onsuccess=function(){U=!0,r()}),s||(s=p(n,J)),s.then(function(t){e._blobSupport=t,r()})}},V.onerror=k(o)}function i(e,t,n){"openReqList"in r||(r.openReqList={}),r.Changes.removeAllListeners(e),r.openReqList[e]&&r.openReqList[e].result&&(r.openReqList[e].result.close(),delete L[e]);var o=indexedDB.deleteDatabase(e);o.onsuccess=function(){r.openReqList[e]&&(r.openReqList[e]=null),a.hasLocalStorage()&&e in localStorage&&delete localStorage[e],n(null,{ok:!0})},o.onerror=k(n)}var s,a=e(34),c=e(29),u=e(19),f=e(6),l=e(5),d=e(4),p=e(3),h=l.ADAPTER_VERSION,v=l.ATTACH_AND_SEQ_STORE,_=l.ATTACH_STORE,m=l.BY_SEQ_STORE,g=l.DETECT_BLOB_SUPPORT_STORE,y=l.DOC_STORE,b=l.LOCAL_STORE,E=l.META_STORE,w=f.applyNext,S=f.compactRevs,T=f.decodeDoc,x=f.decodeMetadata,A=f.encodeMetadata,O=f.fetchAttachmentsIfNecessary,k=f.idbError,q=f.postProcessAttachments,R=f.readBlobData,D=f.taskQueue,C=f.openTransactionSafely,L={};r.valid=function(){var e="undefined"!=typeof openDatabase&&/(Safari|iPhone|iPad|iPod)/.test(navigator.userAgent)&&!/Chrome/.test(navigator.userAgent);return!e&&"undefined"!=typeof indexedDB&&"undefined"!=typeof IDBKeyRange},r.destroy=a.toPromise(function(e,t,n){D.queue.push({action:function(n){i(e,t,n)},callback:n}),w()}),r.Changes=new a.Changes,t.exports=r}).call(this,e(39))},{}],8:[function(e,t){t.exports=["idb","websql"]},{}],9:[function(e,t){"use strict";function n(e,t,n,s,v,_){function m(){return q?_(q):(v.notify(n._name),n._docCount=-1,void _(null,R))}function g(e,t){var n="SELECT count(*) as cnt FROM "+u+" WHERE digest=?";k.executeSql(n,[e],function(n,r){if(0===r.rows.item(0).cnt){var i=o.error(o.MISSING_STUB,"unknown stub attachment with digest "+e);t(i)}else t()})}function y(e){function t(){++o===n.length&&e(r)}var n=[];if(A.forEach(function(e){e.data&&e.data._attachments&&Object.keys(e.data._attachments).forEach(function(t){var r=e.data._attachments[t];r.stub&&n.push(r.digest)})}),!n.length)return e();var r,o=0;n.forEach(function(e){g(e,function(e){e&&!r&&(r=e),t()})})}function b(e,t,o,i,s,u,h){function v(){function t(e,t){function r(){return++i===s.length&&t(),!1}function o(t){var o="INSERT INTO "+f+" (digest, seq) VALUES (?,?)",i=[n._attachments[t].digest,e];k.executeSql(o,i,r,r)}var i=0,s=Object.keys(n._attachments||{});if(!s.length)return t();for(var a=0;a<s.length;a++)o(s[a])}var n=e.data,r=o?1:0,i=n._id,s=n._rev,a=d(n),u="INSERT INTO "+c+" (doc_id, rev, json, deleted) VALUES (?, ?, ?, ?);",p=[i,s,a,r];k.executeSql(u,p,function(e,n){var r=n.insertId;t(r,function(){y(e,r)})},function(){var e=l("seq",c,null,"doc_id=? AND rev=?");return k.executeSql(e,[i,s],function(e,n){var o=n.rows.item(0).seq,u="UPDATE "+c+" SET json=?, deleted=? WHERE doc_id=? AND rev=?;",f=[a,r,i,s];e.executeSql(u,f,function(e){t(o,function(){y(e,o)})})}),!1})}function _(e){b||(e?(b=e,i(b)):E===w.length&&v())}function m(e){E++,_(e)}function g(){if(s&&n.auto_compaction){var t=e.metadata.id,o=r.compactTree(e.metadata);p(o,t,k)}}function y(n,o){g(),e.metadata.seq=o,delete e.metadata.rev;var u=s?"UPDATE "+a+" SET json=?, max_seq=?, winningseq=(SELECT seq FROM "+c+" WHERE doc_id="+a+".id AND rev=?) WHERE id=?":"INSERT INTO "+a+" (id, winningseq, max_seq, json) VALUES (?,?,?,?);",f=r.safeJsonStringify(e.metadata),l=e.metadata.id,d=s?[f,o,t,l]:[l,o,o,f];n.executeSql(u,d,function(){R[h]={ok:!0,id:e.metadata.id,rev:t},D.set(l,e.metadata),i()})}var b=null,E=0;e.data._id=e.metadata.id,e.data._rev=e.metadata.rev;var w=Object.keys(e.data._attachments||{});o&&(e.data._deleted=!0),w.forEach(function(t){var n=e.data._attachments[t];if(n.stub)E++,_();else{var r=n.data;delete n.data;var o=n.digest;S(o,r,m)}}),w.length||v()}function E(){r.processDocs(A,n,D,k,R,b,t)}function w(e){function t(){++n===A.length&&e()}if(!A.length)return e();var n=0;A.forEach(function(e){if(e._id&&r.isLocalId(e._id))return t();var n=e.metadata.id;k.executeSql("SELECT json FROM "+a+" WHERE id = ?",[n],function(e,o){if(o.rows.length){var i=r.safeJsonParse(o.rows.item(0).json);D.set(n,i)}t()})})}function S(e,t,n){var r="SELECT digest FROM "+u+" WHERE digest=?";k.executeSql(r,[e],function(o,s){return s.rows.length?n():(r="INSERT INTO "+u+" (digest, body, escaped) VALUES (?,?,1)",void o.executeSql(r,[e,i.escapeBlob(t)],function(){n()},function(){return n(),!1}))})}var T=t.new_edits,x=e.docs,A=x.map(function(e){if(e._id&&r.isLocalId(e._id))return e;var t=r.parseDoc(e,T);return t}),O=A.filter(function(e){return e.error});if(O.length)return _(O[0]);var k,q,R=new Array(A.length),D=new r.Map;r.preprocessAttachments(A,"binary",function(e){return e?_(e):void s.transaction(function(e){k=e,y(function(e){e?q=e:w(E)})},h(_),m)})}var r=e(34),o=e(19),i=e(11),s=e(10),a=s.DOC_STORE,c=s.BY_SEQ_STORE,u=s.ATTACH_STORE,f=s.ATTACH_AND_SEQ_STORE,l=i.select,d=i.stringifyDoc,p=i.compactRevs,h=i.unknownError;t.exports=n},{}],10:[function(e,t,n){"use strict";function r(e){return"'"+e+"'"}n.ADAPTER_VERSION=7,n.DOC_STORE=r("document-store"),n.BY_SEQ_STORE=r("by-sequence"),n.ATTACH_STORE=r("attach-store"),n.LOCAL_STORE=r("local-store"),n.META_STORE=r("metadata-store"),n.ATTACH_AND_SEQ_STORE=r("attach-seq-store")},{}],11:[function(e,t){"use strict";function n(e){return e.replace(/\u0002/g,"").replace(/\u0001/g,"").replace(/\u0000/g,"")}function r(e){return e.replace(/\u0001\u0001/g,"\x00").replace(/\u0001\u0002/g,"").replace(/\u0002\u0002/g,"")}function o(e){return delete e._id,delete e._rev,JSON.stringify(e)}function i(e,t,n){return e=JSON.parse(e),e._id=t,e._rev=n,e}function s(e){for(var t="(";e--;)t+="?",e&&(t+=",");return t+")"}function a(e,t,n,r,o){return"SELECT "+e+" FROM "+("string"==typeof t?t:t.join(" JOIN "))+(n?" ON "+n:"")+(r?" WHERE "+("string"==typeof r?r:r.join(" AND ")):"")+(o?" ORDER BY "+o:"")}function c(e,t,n){function r(){++i===e.length&&o()}function o(){if(a.length){var e="SELECT DISTINCT digest AS digest FROM "+g+" WHERE seq IN "+s(a.length);n.executeSql(e,a,function(e,t){for(var n=[],r=0;r<t.rows.length;r++)n.push(t.rows.item(r).digest);if(n.length){var o="DELETE FROM "+g+" WHERE seq IN ("+a.map(function(){return"?"}).join(",")+")";e.executeSql(o,a,function(e){var t="SELECT digest FROM "+g+" WHERE digest IN ("+n.map(function(){return"?"}).join(",")+")";e.executeSql(t,n,function(e,t){for(var r=new p.Set,o=0;o<t.rows.length;o++)r.add(t.rows.item(o).digest);n.forEach(function(t){r.has(t)||(e.executeSql("DELETE FROM "+g+" WHERE digest=?",[t]),e.executeSql("DELETE FROM "+m+" WHERE digest=?",[t]))})})})}})}}if(e.length){var i=0,a=[];e.forEach(function(e){var o="SELECT seq FROM "+_+" WHERE doc_id=? AND rev=?";n.executeSql(o,[t,e],function(e,t){if(!t.rows.length)return r();var n=t.rows.item(0).seq;a.push(n),e.executeSql("DELETE FROM "+_+" WHERE seq=?",[n],r)})})}}function u(e){return function(t){var n=t&&t.constructor.toString().match(/function ([^\(]+)/),r=n&&n[1]||t.type,o=t.target||t.message;e(h.error(h.WSQ_ERROR,o,r))}}function f(e){if("size"in e)return 1e6*e.size;var t=/Android/.test(window.navigator.userAgent);return t?5e6:1}function l(e,t,n,r){var o="undefined"!=typeof sqlitePlugin&&sqlitePlugin.openDatabase&&sqlitePlugin.openDatabase.bind(sqlitePlugin),i=o||"undefined"!=typeof openDatabase&&openDatabase,s=y[e];return s||(s=y[e]=i(e,t,n,r),s._sqlitePlugin=!!o),s}function d(){return"undefined"!=typeof openDatabase||"undefined"!=typeof SQLitePlugin}var p=e(34),h=e(19),v=e(10),_=v.BY_SEQ_STORE,m=v.ATTACH_STORE,g=v.ATTACH_AND_SEQ_STORE,y={};t.exports={escapeBlob:n,unescapeBlob:r,stringifyDoc:o,unstringifyDoc:i,qMarks:s,select:a,compactRevs:c,unknownError:u,getSize:f,openDB:l,valid:d}},{}],12:[function(e,t){"use strict";function n(e,t,n,r,i){function s(){++u===c.length&&i&&i()}function a(e,t){var i=e._attachments[t],a={encode:!0,ctx:r};n._getAttachment(i,a,function(n,r){e._attachments[t]=o.extend(o.pick(i,["digest","content_type"]),{data:r}),s()})}var c=Object.keys(e._attachments||{});if(!c.length)return i&&i();var u=0;c.forEach(function(n){t.attachments&&t.include_docs?a(e,n):(e._attachments[n].stub=!0,s())})}function r(e,t){function c(){o.hasLocalStorage()&&(window.localStorage["_pouch__websqldb_"+K._name]=!0),t(null,K)}function I(e,t){e.executeSql(q),e.executeSql("ALTER TABLE "+p+" ADD COLUMN deleted TINYINT(1) DEFAULT 0",[],function(){e.executeSql(O),e.executeSql("ALTER TABLE "+d+" ADD COLUMN local TINYINT(1) DEFAULT 0",[],function(){e.executeSql("CREATE INDEX IF NOT EXISTS 'doc-store-local-idx' ON "+d+" (local, id)");var n="SELECT "+d+".winningseq AS seq, "+d+".json AS metadata FROM "+p+" JOIN "+d+" ON "+p+".seq = "+d+".winningseq";e.executeSql(n,[],function(e,n){for(var r=[],i=[],s=0;s<n.rows.length;s++){var a=n.rows.item(s),c=a.seq,u=JSON.parse(a.metadata);o.isDeleted(u)&&r.push(c),o.isLocalId(u.id)&&i.push(u.id)}e.executeSql("UPDATE "+d+"SET local = 1 WHERE id IN "+g(i.length),i,function(){e.executeSql("UPDATE "+p+" SET deleted = 1 WHERE seq IN "+g(r.length),r,t)})})})})}function N(e,t){var n="CREATE TABLE IF NOT EXISTS "+v+" (id UNIQUE, rev, json)";e.executeSql(n,[],function(){var n="SELECT "+d+".id AS id, "+p+".json AS data FROM "+p+" JOIN "+d+" ON "+p+".seq = "+d+".winningseq WHERE local = 1";e.executeSql(n,[],function(e,n){function r(){if(!o.length)return t(e);var n=o.shift(),i=JSON.parse(n.data)._rev;e.executeSql("INSERT INTO "+v+" (id, rev, json) VALUES (?,?,?)",[n.id,i,n.data],function(e){e.executeSql("DELETE FROM "+d+" WHERE id=?",[n.id],function(e){e.executeSql("DELETE FROM "+p+" WHERE seq=?",[n.seq],function(){r()})})})}for(var o=[],i=0;i<n.rows.length;i++)o.push(n.rows.item(i));r()})})}function j(e,t){function n(n){function r(){if(!n.length)return t(e);var o=n.shift(),i=a(o.hex,W),s=i.lastIndexOf("::"),c=i.substring(0,s),u=i.substring(s+2),f="UPDATE "+p+" SET doc_id=?, rev=? WHERE doc_id_rev=?";e.executeSql(f,[c,u,i],function(){r()})}r()}var r="ALTER TABLE "+p+" ADD COLUMN doc_id";e.executeSql(r,[],function(e){var t="ALTER TABLE "+p+" ADD COLUMN rev";e.executeSql(t,[],function(e){e.executeSql(k,[],function(e){var t="SELECT hex(doc_id_rev) as hex FROM "+p;e.executeSql(t,[],function(e,t){for(var r=[],o=0;o<t.rows.length;o++)r.push(t.rows.item(o));n(r)})})})})}function B(e,t){function n(e){var n="SELECT COUNT(*) AS cnt FROM "+h;e.executeSql(n,[],function(e,n){function r(){var n=E(L+", "+d+".id AS id",[d,p],C,null,d+".id ");n+=" LIMIT "+s+" OFFSET "+i,i+=s,e.executeSql(n,[],function(e,n){function o(e,t){var n=i[e]=i[e]||[];-1===n.indexOf(t)&&n.push(t)}if(!n.rows.length)return t(e);for(var i={},s=0;s<n.rows.length;s++)for(var a=n.rows.item(s),c=b(a.data,a.id,a.rev),u=Object.keys(c._attachments||{}),f=0;f<u.length;f++){var l=c._attachments[u[f]];o(l.digest,a.seq)}var d=[];if(Object.keys(i).forEach(function(e){var t=i[e];t.forEach(function(t){d.push([e,t])})}),!d.length)return r();var p=0;d.forEach(function(t){var n="INSERT INTO "+m+" (digest, seq) VALUES (?,?)";e.executeSql(n,t,function(){++p===d.length&&r()})})})}var o=n.rows.item(0).cnt;if(!o)return t(e);var i=0,s=10;r()})}var r="CREATE TABLE IF NOT EXISTS "+m+" (digest, seq INTEGER)";e.executeSql(r,[],function(e){e.executeSql(D,[],function(e){e.executeSql(R,[],n)})})}function F(e,t){var n="ALTER TABLE "+h+" ADD COLUMN escaped TINYINT(1) DEFAULT 0";e.executeSql(n,[],t)}function M(e,t){var n="ALTER TABLE "+d+" ADD COLUMN max_seq INTEGER";e.executeSql(n,[],function(e){var n="UPDATE "+d+" SET max_seq=(SELECT MAX(seq) FROM "+p+" WHERE doc_id=id)";e.executeSql(n,[],function(e){var n="CREATE UNIQUE INDEX IF NOT EXISTS 'doc-max-seq-idx' ON "+d+" (max_seq)";e.executeSql(n,[],t)})})}function P(e,t){e.executeSql('SELECT HEX("a") AS hex',[],function(e,n){var r=n.rows.item(0).hex;W=2===r.length?"UTF-8":"UTF-16",t()})}function U(){for(;X.length>0;){var e=X.pop();e(null,Q)}}function J(e,t){if(0===t){var n="CREATE TABLE IF NOT EXISTS "+_+" (dbid, db_version INTEGER)",r="CREATE TABLE IF NOT EXISTS "+h+" (digest UNIQUE, escaped TINYINT(1), body BLOB)",i="CREATE TABLE IF NOT EXISTS "+m+" (digest, seq INTEGER)",s="CREATE TABLE IF NOT EXISTS "+d+" (id unique, json, winningseq, max_seq INTEGER UNIQUE)",a="CREATE TABLE IF NOT EXISTS "+p+" (seq INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, json, deleted TINYINT(1), doc_id, rev)",c="CREATE TABLE IF NOT EXISTS "+v+" (id UNIQUE, rev, json)";e.executeSql(r),e.executeSql(c),e.executeSql(i,[],function(){e.executeSql(R),e.executeSql(D)}),e.executeSql(s,[],function(){e.executeSql(q),e.executeSql(a,[],function(){e.executeSql(O),e.executeSql(k),e.executeSql(n,[],function(){var t="INSERT INTO "+_+" (db_version, dbid) VALUES (?,?)";Q=o.uuid();var n=[l,Q];e.executeSql(t,n,function(){U()})})})})}else{var u=function(){var n=l>t;n&&e.executeSql("UPDATE "+_+" SET db_version = "+l);var r="SELECT dbid FROM "+_;e.executeSql(r,[],function(e,t){Q=t.rows.item(0).dbid,U()})},f=[I,N,j,B,F,M,u],g=t,y=function(e){f[g-1](e,y),g++};y(e)}}function H(){Y.transaction(function(e){P(e,function(){V(e)})},S(t),c)}function V(e){var t="SELECT sql FROM sqlite_master WHERE tbl_name = "+_;e.executeSql(t,[],function(e,t){t.rows.length?/db_version/.test(t.rows.item(0).sql)?e.executeSql("SELECT db_version FROM "+_,[],function(e,t){var n=t.rows.item(0).db_version;J(e,n)}):e.executeSql("ALTER TABLE "+_+" ADD COLUMN db_version INTEGER",[],function(){J(e,1)}):J(e,0)})}function G(e,t){if(-1!==K._docCount)return t(K._docCount);var n=E("COUNT("+d+".id) AS 'num'",[d,p],C,p+".deleted=0");e.executeSql(n,[],function(e,n){K._docCount=n.rows.item(0).num,t(K._docCount)})}var W,K=this,Q=null,z=T(e),X=[];K._docCount=-1,K._name=e.name;var Y=x(K._name,A,K._name,z);return Y?("function"!=typeof Y.readTransaction&&(Y.readTransaction=Y.transaction),o.isCordova()?window.addEventListener(K._name+"_pouch",function $(){window.removeEventListener(K._name+"_pouch",$,!1),H()},!1):H(),K.type=function(){return"websql"},K._id=o.toPromise(function(e){e(null,Q)}),K._info=function(e){Y.readTransaction(function(t){G(t,function(n){var r="SELECT MAX(seq) AS seq FROM "+p;t.executeSql(r,[],function(t,r){var o=r.rows.item(0).seq||0;e(null,{doc_count:n,update_seq:o,sqlite_plugin:Y._sqlitePlugin,websql_encoding:W})})})},S(e))},K._bulkDocs=function(e,t,n){f(e,t,K,Y,r.Changes,n)},K._get=function(e,t,n){function r(){n(c,{doc:i,metadata:a,ctx:l})}t=o.clone(t);var i,a,c;if(!t.ctx)return void Y.readTransaction(function(r){t.ctx=r,K._get(e,t,n)});var u,f,l=t.ctx;t.rev?(u=E(L,[d,p],d+".id="+p+".doc_id",[p+".doc_id=?",p+".rev=?"]),f=[e,t.rev]):(u=E(L,[d,p],C,d+".id=?"),f=[e]),l.executeSql(u,f,function(e,n){if(!n.rows.length)return c=s.error(s.MISSING_DOC,"missing"),r();var u=n.rows.item(0);return a=o.safeJsonParse(u.metadata),u.deleted&&!t.rev?(c=s.error(s.MISSING_DOC,"deleted"),r()):(i=b(u.data,a.id,u.rev),void r())})},K._allDocs=function(e,t){var r,s=[],a="startkey"in e?e.startkey:!1,c="endkey"in e?e.endkey:!1,u="key"in e?e.key:!1,f="descending"in e?e.descending:!1,l="limit"in e?e.limit:-1,h="skip"in e?e.skip:0,v=e.inclusive_end!==!1,_=[],m=[];if(u!==!1)m.push(d+".id = ?"),_.push(u);else if(a!==!1||c!==!1){if(a!==!1&&(m.push(d+".id "+(f?"<=":">=")+" ?"),_.push(a)),c!==!1){var g=f?">":"<";v&&(g+="="),m.push(d+".id "+g+" ?"),_.push(c)}u!==!1&&(m.push(d+".id = ?"),_.push(u))}"ok"!==e.deleted&&m.push(p+".deleted = 0"),Y.readTransaction(function(t){G(t,function(a){if(r=a,0!==l){var c=E(L,[d,p],C,m,d+".id "+(f?"DESC":"ASC"));c+=" LIMIT "+l+" OFFSET "+h,t.executeSql(c,_,function(t,r){for(var a=0,c=r.rows.length;c>a;a++){var u=r.rows.item(a),f=o.safeJsonParse(u.metadata),l=f.id,d=b(u.data,l,u.rev),p=d._rev,h={id:l,key:l,value:{rev:p}};if(e.include_docs&&(h.doc=d,h.doc._rev=p,e.conflicts&&(h.doc._conflicts=i.collectConflicts(f)),n(h.doc,e,K,t)),u.deleted){if("ok"!==e.deleted)continue;h.value.deleted=!0,h.doc=null}s.push(h)}})}})},S(t),function(){t(null,{total_rows:r,offset:e.skip,rows:s})})},K._changes=function(e){function t(){var t=d+".json AS metadata, "+d+".max_seq AS maxSeq, "+p+".json AS winningDoc, "+p+".rev AS winningRev ",r=d+" JOIN "+p,i=d+".id="+p+".doc_id AND "+d+".winningseq="+p+".seq",l=["maxSeq > ?"],h=[e.since];e.doc_ids&&(l.push(d+".id IN "+g(e.doc_ids.length)),h=h.concat(e.doc_ids));var v="maxSeq "+(s?"DESC":"ASC"),_=E(t,r,i,l,v),m=o.filterChange(e);e.view||e.filter||(_+=" LIMIT "+a);var y=e.since||0;Y.readTransaction(function(t){t.executeSql(_,h,function(t,r){function i(t){return function(){e.onChange(t)}}for(var s=0,l=r.rows.length;l>s;s++){var d=r.rows.item(s),p=o.safeJsonParse(d.metadata);y=d.maxSeq;var h=b(d.winningDoc,p.id,d.winningRev),v=e.processChange(h,p,e);if(v.seq=d.maxSeq,m(v)&&(f++,c&&u.push(v),e.attachments&&e.include_docs?n(h,e,K,t,i(v)):i(v)()),f===a)break}})},S(e.complete),function(){e.continuous||e.complete(null,{results:u,last_seq:y})})}if(e=o.clone(e),e.continuous){var i=K._name+":"+o.uuid();return r.Changes.addListener(K._name,i,K,e),r.Changes.notify(K._name),{cancel:function(){r.Changes.removeListener(K._name,i)}}}var s=e.descending;e.since=e.since&&!s?e.since:0;var a="limit"in e?e.limit:-1;0===a&&(a=1);var c;c="returnDocs"in e?e.returnDocs:!0;var u=[],f=0;t()},K._close=function(e){e()},K._getAttachment=function(e,t,n){var r,i=t.ctx,s=e.digest,c=e.content_type,f="SELECT escaped, CASE WHEN escaped = 1 THEN body ELSE HEX(body) END AS body FROM "+h+" WHERE digest=?";i.executeSql(f,[s],function(e,i){var s=i.rows.item(0),f=s.escaped?u.unescapeBlob(s.body):a(s.body,W);t.encode?r=btoa(f):(f=o.fixBinary(f),r=o.createBlob([f],{type:c})),n(null,r)})},K._getRevisionTree=function(e,t){Y.readTransaction(function(n){var r="SELECT json AS metadata FROM "+d+" WHERE id = ?";n.executeSql(r,[e],function(e,n){if(n.rows.length){var r=o.safeJsonParse(n.rows.item(0).metadata);t(null,r.rev_tree)}else t(s.error(s.MISSING_DOC))})})},K._doCompaction=function(e,t,n){return t.length?void Y.transaction(function(n){var r="SELECT json AS metadata FROM "+d+" WHERE id = ?";n.executeSql(r,[e],function(n,r){var s=o.safeJsonParse(r.rows.item(0).metadata);i.traverseRevTree(s.rev_tree,function(e,n,r,o,i){var s=n+"-"+r;-1!==t.indexOf(s)&&(i.status="missing")});var a="UPDATE "+d+" SET json = ? WHERE id = ?";n.executeSql(a,[o.safeJsonStringify(s),e])}),w(t,e,n)},S(n),function(){n()}):n()},K._getLocal=function(e,t){Y.readTransaction(function(n){var r="SELECT json, rev FROM "+v+" WHERE id=?";n.executeSql(r,[e],function(n,r){if(r.rows.length){var o=r.rows.item(0),i=b(o.json,e,o.rev);t(null,i)}else t(s.error(s.MISSING_DOC))})})},K._putLocal=function(e,t,n){function r(e){var r,f;i?(r="UPDATE "+v+" SET rev=?, json=? WHERE id=? AND rev=?",f=[o,u,a,i]):(r="INSERT INTO "+v+" (id, rev, json) VALUES (?,?,?)",f=[a,o,u]),e.executeSql(r,f,function(e,r){r.rowsAffected?(c={ok:!0,id:a,rev:o},t.ctx&&n(null,c)):n(s.error(s.REV_CONFLICT))},function(){return n(s.error(s.REV_CONFLICT)),!1})}"function"==typeof t&&(n=t,t={}),delete e._revisions;var o,i=e._rev,a=e._id;o=e._rev=i?"0-"+(parseInt(i.split("-")[1],10)+1):"0-1";var c,u=y(e);t.ctx?r(t.ctx):Y.transaction(function(e){r(e)},S(n),function(){c&&n(null,c)})},void(K._removeLocal=function(e,t){var n;Y.transaction(function(r){var o="DELETE FROM "+v+" WHERE id=? AND rev=?",i=[e._id,e._rev];r.executeSql(o,i,function(r,o){return o.rowsAffected?void(n={ok:!0,id:e._id,rev:"0-0"}):t(s.error(s.MISSING_DOC))})},S(t),function(){n&&t(null,n)})})):t(s.error(s.UNKNOWN_ERROR))}var o=e(34),i=e(29),s=e(19),a=e(22),c=e(10),u=e(11),f=e(9),l=c.ADAPTER_VERSION,d=c.DOC_STORE,p=c.BY_SEQ_STORE,h=c.ATTACH_STORE,v=c.LOCAL_STORE,_=c.META_STORE,m=c.ATTACH_AND_SEQ_STORE,g=u.qMarks,y=u.stringifyDoc,b=u.unstringifyDoc,E=u.select,w=u.compactRevs,S=u.unknownError,T=u.getSize,x=u.openDB,A=1,O="CREATE INDEX IF NOT EXISTS 'by-seq-deleted-idx' ON "+p+" (seq, deleted)",k="CREATE UNIQUE INDEX IF NOT EXISTS 'by-seq-doc-id-rev' ON "+p+" (doc_id, rev)",q="CREATE INDEX IF NOT EXISTS 'doc-winningseq-idx' ON "+d+" (winningseq)",R="CREATE INDEX IF NOT EXISTS 'attach-seq-seq-idx' ON "+m+" (seq)",D="CREATE UNIQUE INDEX IF NOT EXISTS 'attach-seq-digest-idx' ON "+m+" (digest, seq)",C=p+".seq = "+d+".winningseq",L=p+".seq AS seq, "+p+".deleted AS deleted, "+p+".json AS data, "+p+".rev AS rev, "+d+".json AS metadata";r.valid=u.valid,r.destroy=o.toPromise(function(e,t,n){r.Changes.removeAllListeners(e);var i=T(t),s=x(e,A,e,i);s.transaction(function(e){var t=[d,p,h,_,v,m];t.forEach(function(t){e.executeSql("DROP TABLE IF EXISTS "+t,[])})},S(n),function(){o.hasLocalStorage()&&(delete window.localStorage["_pouch__websqldb_"+e],delete window.localStorage[e]),n(null,{ok:!0})})}),r.Changes=new o.Changes,t.exports=r},{}],13:[function(e,t){"use strict";function n(e,t,n){function r(){i.cancel()}a.call(this);var i=this;this.db=e,t=t?o.clone(t):{};var s=n||t.complete||function(){},c=t.complete=o.once(function(t,n){t?i.emit("error",t):i.emit("complete",n),i.removeAllListeners(),e.removeListener("destroyed",r)});s&&(i.on("complete",function(e){s(null,e)}),i.on("error",function(e){s(e)}));var u=t.onChange;u&&i.on("change",u),e.once("destroyed",r),t.onChange=function(e){t.isCancelled||(i.emit("change",e),i.startSeq&&i.startSeq<=e.seq&&(i.emit("uptodate"),i.startSeq=!1),e.deleted?i.emit("delete",e):1===e.changes.length&&"1-"===e.changes[0].rev.slice(0,2)?i.emit("create",e):i.emit("update",e))};var f=new o.Promise(function(e,n){t.complete=function(t,r){t?n(t):e(r)}});i.once("cancel",function(){u&&i.removeListener("change",u),t.complete(null,{status:"cancelled"})}),this.then=f.then.bind(f),this["catch"]=f["catch"].bind(f),this.then(function(e){c(null,e)},c),e.taskqueue.isReady?i.doChanges(t):e.taskqueue.addTask(function(){i.isCancelled?i.emit("cancel"):i.doChanges(t)})}function r(e,t,n){var r=[{rev:e._rev}];"all_docs"===n.style&&(r=i.collectLeaves(t.rev_tree).map(function(e){return{rev:e.rev}}));var s={id:t.id,changes:r,doc:e};return o.isDeleted(t,e._rev)&&(s.deleted=!0),n.conflicts&&(s.doc._conflicts=i.collectConflicts(t),s.doc._conflicts.length||delete s.doc._conflicts),s}var o=e(34),i=e(29),s=e(19),a=e(38).EventEmitter,c=e(27),u=e(28);t.exports=n,o.inherits(n,a),n.prototype.cancel=function(){this.isCancelled=!0,this.db.taskqueue.isReady&&this.emit("cancel")},n.prototype.doChanges=function(e){var t=this,n=e.complete;if(e=o.clone(e),"live"in e&&!("continuous"in e)&&(e.continuous=e.live),e.processChange=r,"latest"===e.since&&(e.since="now"),e.since||(e.since=0),"now"===e.since)return void this.db.info().then(function(r){return t.isCancelled?void n(null,{status:"cancelled"}):(e.since=r.update_seq,void t.doChanges(e))},n);if(e.continuous&&"now"!==e.since&&this.db.info().then(function(e){t.startSeq=e.update_seq},function(e){if("idbNull"!==e.id)throw e}),"http"!==this.db.type()&&e.filter&&"string"==typeof e.filter&&!e.doc_ids)return this.filterChanges(e);"descending"in e||(e.descending=!1),e.limit=0===e.limit?1:e.limit,e.complete=n;var i=this.db._changes(e);if(i&&"function"==typeof i.cancel){var s=t.cancel;t.cancel=o.getArguments(function(e){i.cancel(),s.apply(this,e)})}},n.prototype.filterChanges=function(e){var t=this,n=e.complete;if("_view"===e.filter){if(!e.view||"string"!=typeof e.view){var r=s.error(s.BAD_REQUEST,"`view` filter parameter is not provided.");return void n(r)}var o=e.view.split("/");this.db.get("_design/"+o[0],function(r,i){if(t.isCancelled)return void n(null,{status:"cancelled"});if(r)return void n(s.generateErrorFromResponse(r));if(i&&i.views&&i.views[o[1]]){var a=u(i.views[o[1]].map);return e.filter=a,void t.doChanges(e)}var c=i.views?"missing json key: "+o[1]:"missing json key: views";r||(r=s.error(s.MISSING_DOC,c)),n(r)})}else{var i=e.filter.split("/");this.db.get("_design/"+i[0],function(r,o){if(t.isCancelled)return void n(null,{status:"cancelled"});if(r)return void n(s.generateErrorFromResponse(r));if(o&&o.filters&&o.filters[i[1]]){var a=c(o.filters[i[1]]);return e.filter=a,void t.doChanges(e)}var u=o&&o.filters?"missing json key: "+i[1]:"missing json key: filters";return r||(r=s.error(s.MISSING_DOC,u)),void n(r)})}}},{}],14:[function(e,t){"use strict";function n(e,t,n,r){return e.get(t)["catch"](function(n){if(404===n.status)return"http"===e.type()&&o.explain404("PouchDB is just checking if a remote checkpoint exists."),{_id:t};throw n}).then(function(t){return r.cancelled?void 0:(t.last_seq=n,e.put(t))})}function r(e,t,n,r){this.src=e,this.target=t,this.id=n,this.returnValue=r}var o=e(34),i=e(62),s=i.collate;r.prototype.writeCheckpoint=function(e){var t=this;return this.updateTarget(e).then(function(){return t.updateSource(e)})},r.prototype.updateTarget=function(e){return n(this.target,this.id,e,this.returnValue)},r.prototype.updateSource=function(e){var t=this;return this.readOnlySource?o.Promise.resolve(!0):n(this.src,this.id,e,this.returnValue)["catch"](function(e){var n="number"==typeof e.status&&4===Math.floor(e.status/100);if(n)return t.readOnlySource=!0,!0;throw e})},r.prototype.getCheckpoint=function(){var e=this;return e.target.get(e.id).then(function(t){return e.src.get(e.id).then(function(e){return 0===s(t.last_seq,e.last_seq)?e.last_seq:0},function(n){if(404===n.status&&t.last_seq)return e.src.put({_id:e.id,last_seq:0}).then(function(){return 0},function(n){return 401===n.status?(e.readOnlySource=!0,t.last_seq):0});throw n})})["catch"](function(e){if(404!==e.status)throw e;return 0})},t.exports=r},{}],15:[function(e,t){(function(n,r){"use strict";function o(e){e&&r.debug&&console.error(e)}function i(e,t,r){if(!(this instanceof i))return new i(e,t,r);var f=this;("function"==typeof t||"undefined"==typeof t)&&(r=t,t={}),e&&"object"==typeof e&&(t=e,e=void 0),"undefined"==typeof r&&(r=o),t=t||{},this.__opts=t;var l=r;f.auto_compaction=t.auto_compaction,f.prefix=i.prefix,s.call(f),f.taskqueue=new c;var d=new u(function(o,s){r=function(e,t){return e?s(e):(delete t.then,void o(t))},t=a.clone(t);var c,u,l=t.name||e;return function(){try{if("string"!=typeof l)throw u=new Error("Missing/invalid DB name"),u.code=400,u;if(c=i.parseAdapter(l,t),t.originalName=l,t.name=c.name,t.prefix&&"http"!==c.adapter&&"https"!==c.adapter&&(t.name=t.prefix+t.name),t.adapter=t.adapter||c.adapter,f._adapter=t.adapter,f._db_name=l,!i.adapters[t.adapter])throw u=new Error("Adapter is missing"),u.code=404,u;
9
+ if(!i.adapters[t.adapter].valid())throw u=new Error("Invalid Adapter"),u.code=404,u}catch(e){f.taskqueue.fail(e),f.changes=a.toPromise(function(t){t.complete&&t.complete(e)})}}(),u?s(u):(f.adapter=t.adapter,f.replicate={},f.replicate.from=function(e,t,n){return f.constructor.replicate(e,f,t,n)},f.replicate.to=function(e,t,n){return f.constructor.replicate(f,e,t,n)},f.sync=function(e,t,n){return f.constructor.sync(f,e,t,n)},f.replicate.sync=f.sync,f.destroy=a.adapterFun("destroy",function(e){var t=this,n=this.__opts||{};t.info(function(r,o){return r?e(r):(n.internal=!0,void t.constructor.destroy(o.db_name,n,e))})}),i.adapters[t.adapter].call(f,t,function(e){function n(e){"destroyed"===e&&(f.emit("destroyed"),i.removeListener(l,n))}return e?void(r&&(f.taskqueue.fail(e),r(e))):(i.on(l,n),f.emit("created",f),i.emit("created",t.originalName),f.taskqueue.ready(f),void r(null,f))}),t.skipSetup&&(f.taskqueue.ready(f),n.nextTick(function(){r(null,f)})),void(a.isCordova()&&cordova.fireWindowEvent(t.name+"_pouch",{})))});d.then(function(e){l(null,e)},l),f.then=d.then.bind(d),f["catch"]=d["catch"].bind(d)}var s=e(1),a=e(34),c=e(33),u=a.Promise;a.inherits(i,s),i.debug=e(40),t.exports=i}).call(this,e(39),"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],16:[function(e,t){(function(n){"use strict";function r(e,t){function r(t,n,r){if(e.binary||e.json||!e.processData||"string"==typeof t){if(!e.binary&&e.json&&"string"==typeof t)try{t=JSON.parse(t)}catch(o){return r(o)}}else t=JSON.stringify(t);Array.isArray(t)&&(t=t.map(function(e){return e.error||e.missing?s.generateErrorFromResponse(e):e})),r(null,t,n)}function c(e,t){var n,r;if(e.code&&e.status){var o=new Error(e.message||e.code);return o.status=e.status,t(o)}try{n=JSON.parse(e.responseText),r=s.generateErrorFromResponse(n)}catch(i){r=s.generateErrorFromResponse(e)}t(r)}function u(){return n.browser?"":new i("","binary")}var f=!1,l=a.getArguments(function(e){f||(t.apply(this,e),f=!0)});"function"==typeof e&&(l=e,e={}),e=a.clone(e);var d={method:"GET",headers:{},json:!0,processData:!0,timeout:1e4,cache:!1};return e=a.extend(!0,d,e),e.json&&(e.binary||(e.headers.Accept="application/json"),e.headers["Content-Type"]=e.headers["Content-Type"]||"application/json"),e.binary&&(e.encoding=null,e.json=!1),e.processData||(e.json=!1),o(e,function(t,n,o){if(t)return t.status=n?n.statusCode:400,c(t,l);var i,a=n.headers&&n.headers["content-type"],f=o||u();e.binary||!e.json&&e.processData||"object"==typeof f||!(/json/.test(a)||/^[\s]*\{/.test(f)&&/\}[\s]*$/.test(f))||(f=JSON.parse(f)),n.statusCode>=200&&n.statusCode<300?r(f,n,l):(e.binary&&(f=JSON.parse(f.toString())),i=s.generateErrorFromResponse(f),i.status=n.statusCode,l(i))})}var o=e(24),i=e(18),s=e(19),a=e(34);t.exports=r}).call(this,e(39))},{}],17:[function(e,t){(function(e){"use strict";function n(t,n){t=t||[],n=n||{};try{return new Blob(t,n)}catch(r){if("TypeError"!==r.name)throw r;for(var o=e.BlobBuilder||e.MSBlobBuilder||e.MozBlobBuilder||e.WebKitBlobBuilder,i=new o,s=0;s<t.length;s+=1)i.append(t[s]);return i.getBlob(n.type)}}t.exports=n}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],18:[function(e,t){t.exports={}},{}],19:[function(e,t,n){"use strict";function r(e){Error.call(e.reason),this.status=e.status,this.name=e.error,this.message=e.reason,this.error=!0}var o=e(43);o(r,Error),r.prototype.toString=function(){return JSON.stringify({status:this.status,name:this.name,message:this.message})},n.UNAUTHORIZED=new r({status:401,error:"unauthorized",reason:"Name or password is incorrect."}),n.MISSING_BULK_DOCS=new r({status:400,error:"bad_request",reason:"Missing JSON list of 'docs'"}),n.MISSING_DOC=new r({status:404,error:"not_found",reason:"missing"}),n.REV_CONFLICT=new r({status:409,error:"conflict",reason:"Document update conflict"}),n.INVALID_ID=new r({status:400,error:"invalid_id",reason:"_id field must contain a string"}),n.MISSING_ID=new r({status:412,error:"missing_id",reason:"_id is required for puts"}),n.RESERVED_ID=new r({status:400,error:"bad_request",reason:"Only reserved document ids may start with underscore."}),n.NOT_OPEN=new r({status:412,error:"precondition_failed",reason:"Database not open"}),n.UNKNOWN_ERROR=new r({status:500,error:"unknown_error",reason:"Database encountered an unknown error"}),n.BAD_ARG=new r({status:500,error:"badarg",reason:"Some query argument is invalid"}),n.INVALID_REQUEST=new r({status:400,error:"invalid_request",reason:"Request was invalid"}),n.QUERY_PARSE_ERROR=new r({status:400,error:"query_parse_error",reason:"Some query parameter is invalid"}),n.DOC_VALIDATION=new r({status:500,error:"doc_validation",reason:"Bad special document member"}),n.BAD_REQUEST=new r({status:400,error:"bad_request",reason:"Something wrong with the request"}),n.NOT_AN_OBJECT=new r({status:400,error:"bad_request",reason:"Document must be a JSON object"}),n.DB_MISSING=new r({status:404,error:"not_found",reason:"Database not found"}),n.IDB_ERROR=new r({status:500,error:"indexed_db_went_bad",reason:"unknown"}),n.WSQ_ERROR=new r({status:500,error:"web_sql_went_bad",reason:"unknown"}),n.LDB_ERROR=new r({status:500,error:"levelDB_went_went_bad",reason:"unknown"}),n.FORBIDDEN=new r({status:403,error:"forbidden",reason:"Forbidden by design doc validate_doc_update function"}),n.INVALID_REV=new r({status:400,error:"bad_request",reason:"Invalid rev format"}),n.FILE_EXISTS=new r({status:412,error:"file_exists",reason:"The database could not be created, the file already exists."}),n.MISSING_STUB=new r({status:412,error:"missing_stub"}),n.error=function(e,t,n){function o(t){for(var r in e)"function"!=typeof e[r]&&(this[r]=e[r]);void 0!==n&&(this.name=n),void 0!==t&&(this.reason=t)}return o.prototype=r.prototype,new o(t)},n.getErrorTypeByProp=function(e,t,r){var o=n,i=Object.keys(o).filter(function(n){var r=o[n];return"function"!=typeof r&&r[e]===t}),s=r&&i.filter(function(e){var t=o[e];return t.message===r})[0]||i[0];return s?o[s]:null},n.generateErrorFromResponse=function(e){var t,r,o,i,s,a=n;return r=e.error===!0&&"string"==typeof e.name?e.name:e.error,s=e.reason,o=a.getErrorTypeByProp("name",r,s),e.missing||"missing"===s||"deleted"===s||"not_found"===r?o=a.MISSING_DOC:"doc_validation"===r?(o=a.DOC_VALIDATION,i=s):"bad_request"===r&&o.message!==s&&(0===s.indexOf("unknown stub attachment")?(o=a.MISSING_STUB,i=s):o=a.BAD_REQUEST),o||(o=a.getErrorTypeByProp("status",e.status,s)||a.UNKNOWN_ERROR),t=a.error(o,s,r),i&&(t.message=i),e.id&&(t.id=e.id),e.status&&(t.status=e.status),e.statusText&&(t.name=e.statusText),e.missing&&(t.missing=e.missing),t}},{}],20:[function(e,t){(function(n,r){"use strict";function o(e,t,n){if("function"==typeof e.slice)return t||n?n?e.slice(t,n):e.slice(t):e.slice();t=Math.floor(t||0),n=Math.floor(n||0);var r=e.byteLength;if(t=0>t?Math.max(t+r,0):Math.min(r,t),n=0>n?Math.max(n+r,0):Math.min(r,n),0>=n-t)return new ArrayBuffer(0);var o=new ArrayBuffer(n-t),i=new Uint8Array(o),s=new Uint8Array(e,t,n-t);return i.set(s),o}function i(e){var t=[255&e,e>>>8&255,e>>>16&255,e>>>24&255];return t.map(function(e){return String.fromCharCode(e)}).join("")}function s(e){for(var t="",n=0;n<e.length;n++)t+=i(e[n]);return btoa(t)}var a=e(37),c=e(73),u=r.setImmediate||r.setTimeout,f=32768;t.exports=function(e,t){function r(e,t,n,r){d?e.appendBinary(t.substring(n,r)):e.append(o(t,n,r))}function i(){var n=_*h,o=n+h;if(_++,v>_)r(m,e,n,o),u(i);else{r(m,e,n,o);var a=m.end(!0),c=s(a);t(null,c),m.destroy()}}if(!n.browser){var l=a.createHash("md5").update(e).digest("base64");return void t(null,l)}var d="string"==typeof e,p=d?e.length:e.byteLength,h=Math.min(f,p),v=Math.ceil(p/h),_=0,m=d?new c:new c.ArrayBuffer;i()}}).call(this,e(39),"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],21:[function(e,t,n){"use strict";function r(e){return e.reduce(function(e,t){return e[t]=!0,e},{})}function o(e){if(!/^\d+\-./.test(e))return s.error(s.INVALID_REV);var t=e.indexOf("-"),n=e.substring(0,t),r=e.substring(t+1);return{prefix:parseInt(n,10),id:r}}function i(e,t){for(var n=e.start-e.ids.length+1,r=e.ids,o=[r[0],t,[]],i=1,s=r.length;s>i;i++)o=[r[i],{status:"missing"},[o]];return[{pos:n,ids:o}]}var s=e(19),a=e(26),c=r(["_id","_rev","_attachments","_deleted","_revisions","_revs_info","_conflicts","_deleted_conflicts","_local_seq","_rev_tree","_replication_id","_replication_state","_replication_state_time","_replication_state_reason","_replication_stats","_removed"]),u=r(["_attachments","_replication_id","_replication_state","_replication_state_time","_replication_state_reason","_replication_stats"]);n.invalidIdError=function(e){var t;if(e?"string"!=typeof e?t=s.error(s.INVALID_ID):/^_/.test(e)&&!/^_(design|local)/.test(e)&&(t=s.error(s.RESERVED_ID)):t=s.error(s.MISSING_ID),t)throw t},n.parseDoc=function(e,t){var r,f,l,d={status:"available"};if(e._deleted&&(d.deleted=!0),t)if(e._id||(e._id=a()),f=a(32,16).toLowerCase(),e._rev){if(l=o(e._rev),l.error)return l;e._rev_tree=[{pos:l.prefix,ids:[l.id,{status:"missing"},[[f,d,[]]]]}],r=l.prefix+1}else e._rev_tree=[{pos:1,ids:[f,d,[]]}],r=1;else if(e._revisions&&(e._rev_tree=i(e._revisions,d),r=e._revisions.start,f=e._revisions.ids[0]),!e._rev_tree){if(l=o(e._rev),l.error)return l;r=l.prefix,f=l.id,e._rev_tree=[{pos:r,ids:[f,d,[]]}]}n.invalidIdError(e._id),e._rev=r+"-"+f;var p={metadata:{},data:{}};for(var h in e)if(e.hasOwnProperty(h)){var v="_"===h[0];if(v&&!c[h]){var _=s.error(s.DOC_VALIDATION,h);throw _.message=s.DOC_VALIDATION.message+": "+h,_}v&&!u[h]?p.metadata[h.slice(1)]=e[h]:p.data[h]=e[h]}return p}},{}],22:[function(e,t){"use strict";function n(e){return decodeURIComponent(window.escape(e))}function r(e){return 65>e?e-48:e-55}function o(e,t,n){for(var o="";n>t;)o+=String.fromCharCode(r(e.charCodeAt(t++))<<4|r(e.charCodeAt(t++)));return o}function i(e,t,n){for(var o="";n>t;)o+=String.fromCharCode(r(e.charCodeAt(t+2))<<12|r(e.charCodeAt(t+3))<<8|r(e.charCodeAt(t))<<4|r(e.charCodeAt(t+1))),t+=4;return o}function s(e,t){return"UTF-8"===t?n(o(e,0,e.length)):i(e,0,e.length)}t.exports=s},{}],23:[function(e,t){"use strict";function n(e){for(var t=r,n=t.parser[t.strictMode?"strict":"loose"].exec(e),o={},i=14;i--;){var s=t.key[i],a=n[i]||"",c=-1!==["user","password"].indexOf(s);o[s]=c?decodeURIComponent(a):a}return o[t.q.name]={},o[t.key[12]].replace(t.q.parser,function(e,n,r){n&&(o[t.q.name][n]=r)}),o}var r={strictMode:!1,key:["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"],q:{name:"queryKey",parser:/(?:^|&)([^&=]*)=?([^&]*)/g},parser:{strict:/^(?:([^:\/?#]+):)?(?:\/\/((?:(([^:@]*)(?::([^:@]*))?)?@)?([^:\/?#]*)(?::(\d*))?))?((((?:[^?#\/]*\/)*)([^?#]*))(?:\?([^#]*))?(?:#(.*))?)/,loose:/^(?:(?![^:@]+:[^:@\/]*@)([^:\/?#.]+):)?(?:\/\/)?((?:(([^:@]*)(?::([^:@]*))?)?@)?([^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/}};t.exports=n},{}],24:[function(e,t){"use strict";var n=e(17),r=e(34);t.exports=function(e,t){var o,i,s,a=function(){o.abort()};if(o=e.xhr?new e.xhr:new XMLHttpRequest,"GET"===e.method&&!e.cache){var c=-1!==e.url.indexOf("?");e.url+=(c?"&":"?")+"_nonce="+Date.now()}o.open(e.method,e.url),o.withCredentials=!0,e.json&&(e.headers.Accept="application/json",e.headers["Content-Type"]=e.headers["Content-Type"]||"application/json",e.body&&e.processData&&"string"!=typeof e.body&&(e.body=JSON.stringify(e.body))),e.binary&&(o.responseType="arraybuffer"),"body"in e||(e.body=null);for(var u in e.headers)e.headers.hasOwnProperty(u)&&o.setRequestHeader(u,e.headers[u]);return e.timeout>0&&(i=setTimeout(a,e.timeout),o.onprogress=function(){clearTimeout(i),i=setTimeout(a,e.timeout)},"undefined"==typeof s&&(s=-1!==Object.keys(o).indexOf("upload")),s&&(o.upload.onprogress=o.onprogress)),o.onreadystatechange=function(){if(4===o.readyState){var r={statusCode:o.status};if(o.status>=200&&o.status<300){var i;i=e.binary?n([o.response||""],{type:o.getResponseHeader("Content-Type")}):o.responseText,t(null,r,i)}else{var s={};try{s=JSON.parse(o.response)}catch(a){}t(s,r)}}},e.body&&e.body instanceof Blob?r.readAsBinaryString(e.body,function(e){o.send(r.fixBinary(e))}):o.send(e.body),{abort:a}}},{}],25:[function(e,t){"use strict";var n=e(72).upsert;t.exports=function(e,t,r,o){return n.call(e,t,r,o)}},{}],26:[function(e,t){"use strict";function n(e){return 0|Math.random()*e}function r(e,t){t=t||o.length;var r="",i=-1;if(e){for(;++i<e;)r+=o[n(t)];return r}for(;++i<36;)switch(i){case 8:case 13:case 18:case 23:r+="-";break;case 19:r+=o[3&n(16)|8];break;default:r+=o[n(16)]}return r}var o="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz".split("");t.exports=r},{}],27:[function(_dereq_,module,exports){"use strict";function evalFilter(input){return eval(["(function () { return ",input," })()"].join(""))}module.exports=evalFilter},{}],28:[function(_dereq_,module,exports){"use strict";function evalView(input){return eval(["(function () {"," return function (doc) {"," var emitted = false;"," var emit = function (a, b) {"," emitted = true;"," };"," var view = "+input+";"," view(doc);"," if (emitted) {"," return true;"," }"," }","})()"].join("\n"))}module.exports=evalView},{}],29:[function(e,t){"use strict";function n(e,t,n){for(var r,o=0,i=e.length;i>o;)r=o+i>>>1,n(e[r],t)<0?o=r+1:i=r;return o}function r(e,t,r){var o=n(e,t,r);e.splice(o,0,t)}function o(e){for(var t,n=e.shift(),r=[n.id,n.opts,[]],o=r;e.length;)n=e.shift(),t=[n.id,n.opts,[]],o[2].push(t),o=t;return r}function i(e,t){return e[0]<t[0]?-1:1}function s(e,t){for(var n=[{tree1:e,tree2:t}],o=!1;n.length>0;){var s=n.pop(),a=s.tree1,c=s.tree2;(a[1].status||c[1].status)&&(a[1].status="available"===a[1].status||"available"===c[1].status?"available":"missing");for(var u=0;u<c[2].length;u++)if(a[2][0]){for(var f=!1,l=0;l<a[2].length;l++)a[2][l][0]===c[2][u][0]&&(n.push({tree1:a[2][l],tree2:c[2][u]}),f=!0);f||(o="new_branch",r(a[2],c[2][u],i))}else o="new_leaf",a[2][0]=c[2][u]}return{conflicts:o,tree:e}}function a(e,t,n){var r,o=[],i=!1,a=!1;return e.length?(e.forEach(function(e){if(e.pos===t.pos&&e.ids[0]===t.ids[0])r=s(e.ids,t.ids),o.push({pos:e.pos,ids:r.tree}),i=i||r.conflicts,a=!0;else if(n!==!0){var c=e.pos<t.pos?e:t,u=e.pos<t.pos?t:e,f=u.pos-c.pos,l=[],d=[];for(d.push({ids:c.ids,diff:f,parent:null,parentIdx:null});d.length>0;){var p=d.pop();0!==p.diff?p.ids&&p.ids[2].forEach(function(e,t){d.push({ids:e,diff:p.diff-1,parent:p.ids,parentIdx:t})}):p.ids[0]===u.ids[0]&&l.push(p)}var h=l[0];h?(r=s(h.ids,u.ids),h.parent[2][h.parentIdx]=r.tree,o.push({pos:c.pos,ids:c.ids}),i=i||r.conflicts,a=!0):o.push(e)}else o.push(e)}),a||o.push(t),o.sort(function(e,t){return e.pos-t.pos}),{tree:o,conflicts:i||"internal_node"}):{tree:[t],conflicts:"new_leaf"}}function c(e,t){var n=f.rootToLeaf(e).map(function(e){var n=e.ids.slice(-t);return{pos:e.pos+(e.ids.length-n.length),ids:o(n)}});return n.reduce(function(e,t){return a(e,t,!0).tree},[n.shift()])}var u=e(65),f={};f.merge=function(e,t,n){e=u(!0,[],e),t=u(!0,{},t);var r=a(e,t);return{tree:c(r.tree,n),conflicts:r.conflicts}},f.winningRev=function(e){var t=[];return f.traverseRevTree(e.rev_tree,function(e,n,r,o,i){e&&t.push({pos:n,id:r,deleted:!!i.deleted})}),t.sort(function(e,t){return e.deleted!==t.deleted?e.deleted>t.deleted?1:-1:e.pos!==t.pos?t.pos-e.pos:e.id<t.id?1:-1}),t[0].pos+"-"+t[0].id},f.traverseRevTree=function(e,t){for(var n,r=e.slice();n=r.pop();)for(var o=n.pos,i=n.ids,s=i[2],a=t(0===s.length,o,i[0],n.ctx,i[1]),c=0,u=s.length;u>c;c++)r.push({pos:o+1,ids:s[c],ctx:a})},f.collectLeaves=function(e){var t=[];return f.traverseRevTree(e,function(e,n,r,o,i){e&&t.push({rev:n+"-"+r,pos:n,opts:i})}),t.sort(function(e,t){return t.pos-e.pos}),t.forEach(function(e){delete e.pos}),t},f.collectConflicts=function(e){var t=f.winningRev(e),n=f.collectLeaves(e.rev_tree),r=[];return n.forEach(function(e){e.rev===t||e.opts.deleted||r.push(e.rev)}),r},f.rootToLeaf=function(e){var t=[];return f.traverseRevTree(e,function(e,n,r,o,i){if(o=o?o.slice(0):[],o.push({id:r,opts:i}),e){var s=n+1-o.length;t.unshift({pos:s,ids:o})}return o}),t},t.exports=f},{}],30:[function(e,t,n){"use strict";function r(e,t){e=parseInt(e,10),t=parseInt(t,10),e!==e&&(e=0),t!==t||e>=t?t=(e||1)<<1:t+=1;var n=Math.random(),r=t-e;return~~(r*n+e)}function o(e){var t=0;return e||(t=2e3),r(e,t)}function i(e,t,n,r,i,s,a){return r.retry===!1?(i.emit("error",a),void i.removeAllListeners()):(r.default_back_off=r.default_back_off||0,r.retries=r.retries||0,"function"!=typeof r.back_off_function&&(r.back_off_function=o),r.retries++,r.max_retries&&r.retries>r.max_retries?(i.emit("error",new Error("tried "+r.retries+" times but replication failed")),void i.removeAllListeners()):(i.emit("requestError",a),"active"===i.state&&(i.emit("paused",a),i.state="stopped",i.once("active",function(){r.current_back_off=r.default_back_off})),r.current_back_off=r.current_back_off||r.default_back_off,r.current_back_off=r.back_off_function(r.current_back_off),void setTimeout(function(){c(e,t,n,r,i)},r.current_back_off)))}function s(){d.call(this),this.cancelled=!1,this.state="pending";var e=this,t=new l.Promise(function(t,n){e.once("complete",t),e.once("error",n)});e.then=function(e,n){return t.then(e,n)},e["catch"]=function(e){return t["catch"](e)},e["catch"](function(){})}function a(e,t,n){var r=n.filter?n.filter.toString():"";return e.id().then(function(e){return t.id().then(function(t){var o=e+t+r+JSON.stringify(n.query_params)+n.doc_ids;return l.MD5(o).then(function(e){return e=e.replace(/\//g,".").replace(/\+/g,"_"),"_local/"+e})})})}function c(e,t,n,r,o,s){function a(){if(0!==A.docs.length){var e=A.docs;return n.bulkDocs({docs:e,new_edits:!1}).then(function(t){if(F.cancelled)throw b(),new Error("cancelled");var n=[],r={};t.forEach(function(e){e.error&&(s.doc_write_failures++,n.push(e),r[e.id]=e)}),s.errors=n,P=P.concat(n),s.docs_written+=A.docs.length-n.length;var i=n.filter(function(e){return"unauthorized"!==e.name&&"forbidden"!==e.name});if(U=[],e.forEach(function(e){var t=r[e._id];t?o.emit("denied",l.clone(t)):U.push(e)}),i.length>0){var a=new Error("bulkDocs error");throw a.other_errors=n,y("target.bulkDocs failed to write docs",a),new Error("bulkWrite partial failure")}},function(t){throw s.doc_write_failures+=e.length,t})}}function c(e){for(var n=A.diffs,r=n[e].missing,o=[],i=0;i<r.length;i+=h)o.push(r.slice(i,Math.min(r.length,i+h)));return l.Promise.all(o.map(function(r){var o={revs:!0,open_revs:r,attachments:!0};return t.get(e,o).then(function(t){t.forEach(function(e){return F.cancelled?b():void(e.ok&&(s.docs_read++,A.pendingRevs++,A.docs.push(e.ok)))}),delete n[e]})}))}function u(){var e=Object.keys(A.diffs);return l.Promise.all(e.map(c))}function f(){var e=Object.keys(A.diffs).filter(function(e){var t=A.diffs[e].missing;return 1===t.length&&"1-"===t[0].slice(0,2)});return e.length?t.allDocs({keys:e,include_docs:!0}).then(function(e){if(F.cancelled)throw b(),new Error("cancelled");e.rows.forEach(function(e){!e.doc||e.deleted||"1-"!==e.value.rev.slice(0,2)||e.doc._attachments&&0!==Object.keys(e.doc._attachments).length||(s.docs_read++,A.pendingRevs++,A.docs.push(e.doc),delete A.diffs[e.id])})}):l.Promise.resolve()}function d(){return f().then(u)}function v(){return q=!0,M.writeCheckpoint(A.seq).then(function(){if(q=!1,F.cancelled)throw b(),new Error("cancelled");s.last_seq=C=A.seq;var e=l.clone(s);e.docs=U,o.emit("change",e),A=void 0,T()})["catch"](function(e){throw q=!1,y("writeCheckpoint completed with error",e),e})}function _(){var e={};return A.changes.forEach(function(t){e[t.id]=t.changes.map(function(e){return e.rev})}),n.revsDiff(e).then(function(e){if(F.cancelled)throw b(),new Error("cancelled");A.diffs=e,A.pendingRevs=0})}function m(){if(!F.cancelled&&!A){if(0===O.length)return void g(!0);A=O.shift(),_().then(d).then(a).then(v).then(m)["catch"](function(e){y("batch processing terminated with error",e)})}}function g(e){return 0===k.changes.length?void(0!==O.length||A||((L&&J.live||R)&&(o.emit("paused"),o.emit("uptodate",s)),R&&b())):void((e||R||k.changes.length>=I)&&(O.push(k),k={seq:0,changes:[],docs:[]},m()))}function y(e,t){D||(t.message||(t.message=e),s.ok=!1,s.status="aborting",s.errors.push(t),P=P.concat(t),O=[],k={seq:0,changes:[],docs:[]},b())}function b(){if(!(D||F.cancelled&&(s.status="cancelled",q))){s.status=s.status||"complete",s.end_time=new Date,s.last_seq=C,D=F.cancelled=!0;var a=P.filter(function(e){return"unauthorized"!==e.name&&"forbidden"!==e.name});if(a.length>0){var c=P.pop();P.length>0&&(c.other_errors=P),c.result=s,i(e,t,n,r,o,s,c)}else s.errors=P,o.emit("complete",s),o.removeAllListeners()}}function E(e){if(F.cancelled)return b();var t=l.filterChange(r)(e);t&&(0!==k.changes.length||0!==O.length||A||o.emit("outofdate",s),k.seq=e.seq,k.changes.push(e),g(0===O.length))}function w(e){return j=!1,F.cancelled?b():(e.results.length>0?(J.since=e.last_seq,T()):L?(J.live=!0,T()):R=!0,void g(!0))}function S(e){return j=!1,F.cancelled?b():void y("changes rejected",e)}function T(){function e(){r.cancel()}function n(){o.removeListener("cancel",e)}if(!j&&!R&&O.length<N){j=!0,o.once("cancel",e);var r=t.changes(J).on("change",E);r.then(n,n),r.then(w)["catch"](S)}}function x(){M.getCheckpoint().then(function(e){C=e,J={since:C,limit:I,batch_size:I,style:"all_docs",doc_ids:B,returnDocs:!0},r.filter&&(J.include_docs=!0),r.query_params&&(J.query_params=r.query_params),T()})["catch"](function(e){y("getCheckpoint rejected with ",e)})}var A,O=[],k={seq:0,changes:[],docs:[]},q=!1,R=!1,D=!1,C=0,L=r.continuous||r.live||!1,I=r.batch_size||100,N=r.batches_limit||10,j=!1,B=r.doc_ids,F={cancelled:!1},M=new p(t,n,e,F),P=[],U=[];s=s||{ok:!0,start_time:new Date,docs_read:0,docs_written:0,doc_write_failures:0,errors:[]};var J={};o.ready(t,n),o.once("cancel",b),"function"==typeof r.onChange&&o.on("change",r.onChange),"function"==typeof r.complete&&(o.once("error",r.complete),o.once("complete",function(e){r.complete(null,e)})),"undefined"==typeof r.since?x():(q=!0,M.writeCheckpoint(r.since).then(function(){return q=!1,F.cancelled?void b():(C=r.since,void x())})["catch"](function(e){throw q=!1,y("writeCheckpoint completed with error",e),e}))}function u(e,t){var n=t.PouchConstructor;return"string"==typeof e?new n(e):e.then?e:l.Promise.resolve(e)}function f(e,t,n,r){"function"==typeof n&&(r=n,n={}),"undefined"==typeof n&&(n={}),n.complete||(n.complete=r||function(){}),n=l.clone(n),n.continuous=n.continuous||n.live,n.retry="retry"in n?n.retry:v,n.PouchConstructor=n.PouchConstructor||this;var o=new s(n);return u(e,n).then(function(e){return u(t,n).then(function(t){return a(e,t,n).then(function(r){c(r,e,t,n,o)})})})["catch"](function(e){o.emit("error",e),n.complete(e)}),o}var l=e(34),d=e(38).EventEmitter,p=e(14),h=50,v=!1;l.inherits(s,d),s.prototype.cancel=function(){this.cancelled=!0,this.state="cancelled",this.emit("cancel")},s.prototype.ready=function(e,t){function n(){o.cancel()}function r(){e.removeListener("destroyed",n),t.removeListener("destroyed",n)}var o=this;this.once("change",function(){("pending"===this.state||"stopped"===this.state)&&(o.state="active",o.emit("active"))}),e.once("destroyed",n),t.once("destroyed",n),this.then(r,r)},n.toPouch=u,n.replicate=f},{}],31:[function(e,t){"use strict";var n=e(15),r=e(34),o=r.Promise,i=e(38).EventEmitter;n.adapters={},n.preferredAdapters=e(8),n.prefix="_pouch_";var s=new i,a=["on","addListener","emit","listeners","once","removeAllListeners","removeListener","setMaxListeners"];a.forEach(function(e){n[e]=s[e].bind(s)}),n.setMaxListeners(0),n.parseAdapter=function(e,t){var o,i,s=e.match(/([a-z\-]*):\/\/(.*)/);if(s){if(e=/http(s?)/.test(s[1])?s[1]+"://"+s[2]:s[2],o=s[1],!n.adapters[o].valid())throw"Invalid adapter";return{name:e,adapter:s[1]}}var a="idb"in n.adapters&&"websql"in n.adapters&&r.hasLocalStorage()&&localStorage["_pouch__websqldb_"+n.prefix+e];if("undefined"!=typeof t&&t.db)i="leveldb";else for(var c=0;c<n.preferredAdapters.length;++c)if(i=n.preferredAdapters[c],i in n.adapters){if(a&&"idb"===i)continue;break}if(o=n.adapters[i],i&&o){var u="use_prefix"in o?o.use_prefix:!0;return{name:u?n.prefix+e:e,adapter:i}}throw"No valid adapter found"},n.destroy=r.toPromise(function(e,t,i){function s(){u.destroy(d,t,function(t,r){t?i(t):(n.emit("destroyed",e),n.emit(e,"destroyed"),i(null,r||{ok:!0}))})}("function"==typeof t||"undefined"==typeof t)&&(i=t,t={}),e&&"object"==typeof e&&(t=e,e=void 0),t.internal||console.log("PouchDB.destroy() is deprecated and will be removed. Please use db.destroy() instead.");var a=n.parseAdapter(t.name||e,t),c=a.name,u=n.adapters[a.adapter],f="use_prefix"in u?u.use_prefix:!0,l=f?c.replace(new RegExp("^"+n.prefix),""):c,d=("http"===a.adapter||"https"===a.adapter?"":t.prefix||"")+c,p=r.extend(!0,{},t,{adapter:a.adapter});new n(l,p,function(e,a){return e?i(e):void a.get("_local/_pouch_dependentDbs",function(e,c){if(e)return 404!==e.status?i(e):s();var u=c.dependentDbs,l=Object.keys(u).map(function(e){var o=f?e.replace(new RegExp("^"+n.prefix),""):e,i=r.extend(!0,t,a.__opts||{});return a.constructor.destroy(o,i)});o.all(l).then(s,function(e){i(e)})})})}),n.adapter=function(e,t){t.valid()&&(n.adapters[e]=t)},n.plugin=function(e){Object.keys(e).forEach(function(t){n.prototype[t]=e[t]})},n.defaults=function(e){function t(t,o,i){("function"==typeof o||"undefined"==typeof o)&&(i=o,o={}),t&&"object"==typeof t&&(o=t,t=void 0),o=r.extend(!0,{},e,o),n.call(this,t,o,i)}return r.inherits(t,n),t.destroy=r.toPromise(function(t,o,i){return("function"==typeof o||"undefined"==typeof o)&&(i=o,o={}),t&&"object"==typeof t&&(o=t,t=void 0),o=r.extend(!0,{},e,o),n.destroy(t,o,i)}),a.forEach(function(e){t[e]=s[e].bind(s)}),t.setMaxListeners(0),t.preferredAdapters=n.preferredAdapters.slice(),Object.keys(n).forEach(function(e){e in t||(t[e]=n[e])}),t},t.exports=n},{}],32:[function(e,t){"use strict";function n(e,t,n,s){return"function"==typeof n&&(s=n,n={}),"undefined"==typeof n&&(n={}),n=o.clone(n),n.PouchConstructor=n.PouchConstructor||this,e=i.toPouch(e,n),t=i.toPouch(t,n),new r(e,t,n,s)}function r(e,t,n,r){function i(e){v||(v=!0,d.emit("cancel",e))}function a(e){d.emit("change",{direction:"pull",change:e})}function c(e){d.emit("change",{direction:"push",change:e})}function u(e){d.emit("denied",{direction:"push",doc:e})}function f(e){d.emit("denied",{direction:"pull",doc:e})}function l(e){return function(t,n){var r="change"===t&&(n===a||n===c),o="cancel"===t&&n===i,s=t in _&&n===_[t];(r||o||s)&&(t in m||(m[t]={}),m[t][e]=!0,2===Object.keys(m[t]).length&&d.removeAllListeners(t))}}var d=this;this.canceled=!1;var p,h;"onChange"in n&&(p=n.onChange,delete n.onChange),"function"!=typeof r||n.complete?"complete"in n&&(h=n.complete,delete n.complete):h=r,this.push=s(e,t,n),this.pull=s(t,e,n);var v=!1,_={},m={};n.live&&(this.push.on("complete",d.pull.cancel.bind(d.pull)),this.pull.on("complete",d.push.cancel.bind(d.push))),this.on("newListener",function(e){"change"===e?(d.pull.on("change",a),d.push.on("change",c)):"denied"===e?(d.pull.on("denied",f),d.push.on("denied",u)):"cancel"===e?(d.pull.on("cancel",i),d.push.on("cancel",i)):"error"===e||"removeListener"===e||"complete"===e||e in _||(_[e]=function(t){d.emit(e,t)},d.pull.on(e,_[e]),d.push.on(e,_[e]))}),this.on("removeListener",function(e){"change"===e?(d.pull.removeListener("change",a),d.push.removeListener("change",c)):"cancel"===e?(d.pull.removeListener("cancel",i),d.push.removeListener("cancel",i)):e in _&&"function"==typeof _[e]&&(d.pull.removeListener(e,_[e]),d.push.removeListener(e,_[e]),delete _[e])}),this.pull.on("removeListener",l("pull")),this.push.on("removeListener",l("push"));var g=o.Promise.all([this.push,this.pull]).then(function(e){var t={push:e[0],pull:e[1]};return d.emit("complete",t),h&&h(null,t),d.removeAllListeners(),t},function(e){throw d.cancel(),d.emit("error",e),h&&h(e),d.removeAllListeners(),e});this.then=function(e,t){return g.then(e,t)},this["catch"]=function(e){return g["catch"](e)}}var o=e(34),i=e(30),s=i.replicate,a=e(38).EventEmitter;o.inherits(r,a),t.exports=n,r.prototype.cancel=function(){this.canceled||(this.canceled=!0,this.push.cancel(),this.pull.cancel())}},{}],33:[function(e,t){"use strict";function n(){this.isReady=!1,this.failed=!1,this.queue=[]}t.exports=n,n.prototype.execute=function(){var e,t;if(this.failed)for(;e=this.queue.shift();)"function"!=typeof e?(t=e.parameters[e.parameters.length-1],"function"==typeof t?t(this.failed):"changes"===e.name&&"function"==typeof t.complete&&t.complete(this.failed)):e(this.failed);else if(this.isReady)for(;e=this.queue.shift();)"function"==typeof e?e():e.task=this.db[e.name].apply(this.db,e.parameters)},n.prototype.fail=function(e){this.failed=e,this.execute()},n.prototype.ready=function(e){return this.failed?!1:0===arguments.length?this.isReady:(this.isReady=e?!0:!1,this.db=e,void this.execute())},n.prototype.addTask=function(e,t){if("function"!=typeof e){var n={name:e,parameters:t};return this.queue.push(n),this.failed&&this.execute(),n}this.queue.push(e),this.failed&&this.execute()}},{}],34:[function(e,t,n){(function(t,r){function o(){return"undefined"!=typeof chrome&&"undefined"!=typeof chrome.storage&&"undefined"!=typeof chrome.storage.local}function i(){if(!(this instanceof i))return new i;var e=this;u.call(this),this.isChrome=o(),this.listeners={},this.hasLocal=!1,this.isChrome||(this.hasLocal=n.hasLocalStorage()),this.isChrome?chrome.storage.onChanged.addListener(function(t){null!=t.db_name&&e.emit(t.dbName.newValue)}):this.hasLocal&&("undefined"!=typeof addEventListener?addEventListener("storage",function(t){e.emit(t.key)}):window.attachEvent("storage",function(t){e.emit(t.key)}))}var s=e(29);n.extend=e(65),n.ajax=e(16),n.createBlob=e(17),n.uuid=e(26),n.getArguments=e(36);var a=e(18),c=e(19),u=e(38).EventEmitter,f=e(64);n.Map=f.Map,n.Set=f.Set;var l=e(21);n.Promise="function"==typeof r.Promise?r.Promise:e(47);var d=n.Promise;n.lastIndexOf=function(e,t){for(var n=e.length-1;n>=0;n--)if(e.charAt(n)===t)return n;return-1},n.clone=function(e){return n.extend(!0,{},e)},n.pick=function(e,t){for(var n={},r=0,o=t.length;o>r;r++){var i=t[r];n[i]=e[i]}return n},n.inherits=e(43),n.call=n.getArguments(function(e){if(e.length){var t=e.shift();"function"==typeof t&&t.apply(this,e)}}),n.isLocalId=function(e){return/^_local/.test(e)},n.isDeleted=function(e,t){t||(t=s.winningRev(e));var n=t.indexOf("-");-1!==n&&(t=t.substring(n+1));var r=!1;return s.traverseRevTree(e.rev_tree,function(e,n,o,i,s){o===t&&(r=!!s.deleted)}),r},n.revExists=function(e,t){var n=!1;return s.traverseRevTree(e.rev_tree,function(e,r,o){r+"-"+o===t&&(n=!0)}),n},n.filterChange=function(e){var t={},n=e.filter&&"function"==typeof e.filter;return t.query=e.query_params,function(r){if(e.filter&&n&&!e.filter.call(this,r.doc,t))return!1;if(e.include_docs){if(!e.attachments)for(var o in r.doc._attachments)r.doc._attachments.hasOwnProperty(o)&&(r.doc._attachments[o].stub=!0)}else delete r.doc;return!0}},n.parseDoc=l.parseDoc,n.invalidIdError=l.invalidIdError,n.isCordova=function(){return"undefined"!=typeof cordova||"undefined"!=typeof PhoneGap||"undefined"!=typeof phonegap},n.hasLocalStorage=function(){if(o())return!1;try{return localStorage}catch(e){return!1}},n.Changes=i,n.inherits(i,u),i.prototype.addListener=function(e,r,o,i){function s(){if(a.listeners[r]){if(c)return void(c="waiting");c=!0,o.changes({style:i.style,include_docs:i.include_docs,attachments:i.attachments,conflicts:i.conflicts,continuous:!1,descending:!1,filter:i.filter,doc_ids:i.doc_ids,view:i.view,since:i.since,query_params:i.query_params}).on("change",function(e){e.seq>i.since&&!i.cancelled&&(i.since=e.seq,n.call(i.onChange,e))}).on("complete",function(){"waiting"===c&&t.nextTick(function(){a.notify(e)}),c=!1}).on("error",function(){c=!1})}}if(!this.listeners[r]){var a=this,c=!1;this.listeners[r]=s,this.on(e,s)
10
+ }},i.prototype.removeListener=function(e,t){t in this.listeners&&u.prototype.removeListener.call(this,e,this.listeners[t])},i.prototype.notifyLocalWindows=function(e){this.isChrome?chrome.storage.local.set({dbName:e}):this.hasLocal&&(localStorage[e]="a"===localStorage[e]?"b":"a")},i.prototype.notify=function(e){this.emit(e),this.notifyLocalWindows(e)},n.atob="function"==typeof atob?function(e){return atob(e)}:function(e){var t=new a(e,"base64");if(t.toString("base64")!==e)throw"Cannot base64 encode full string";return t.toString("binary")},n.btoa="function"==typeof btoa?function(e){return btoa(e)}:function(e){return new a(e,"binary").toString("base64")},n.fixBinary=function(e){if(!t.browser)return e;for(var n=e.length,r=new ArrayBuffer(n),o=new Uint8Array(r),i=0;n>i;i++)o[i]=e.charCodeAt(i);return r},n.readAsBinaryString=function(e,t){var r=new FileReader,o="function"==typeof r.readAsBinaryString;r.onloadend=function(e){var r=e.target.result||"";return o?t(r):void t(n.arrayBufferToBinaryString(r))},o?r.readAsBinaryString(e):r.readAsArrayBuffer(e)},n.readAsArrayBuffer=function(e,t){var n=new FileReader;n.onloadend=function(e){var n=e.target.result||new ArrayBuffer(0);t(n)},n.readAsArrayBuffer(e)},n.once=function(e){var t=!1;return n.getArguments(function(n){if(t)throw new Error("once called more than once");t=!0,e.apply(this,n)})},n.toPromise=function(e){return n.getArguments(function(r){var o,i=this,s="function"==typeof r[r.length-1]?r.pop():!1;s&&(o=function(e,n){t.nextTick(function(){s(e,n)})});var a=new d(function(t,o){var s;try{var a=n.once(function(e,n){e?o(e):t(n)});r.push(a),s=e.apply(i,r),s&&"function"==typeof s.then&&t(s)}catch(c){o(c)}});return o&&a.then(function(e){o(null,e)},o),a.cancel=function(){return this},a})},n.adapterFun=function(t,r){function o(e,t,n){if(i.enabled){for(var r=[e._db_name,t],o=0;o<n.length-1;o++)r.push(n[o]);i.apply(null,r);var s=n[n.length-1];n[n.length-1]=function(n,r){var o=[e._db_name,t];o=o.concat(n?["error",n]:["success",r]),i.apply(null,o),s(n,r)}}}var i=e(40)("pouchdb:api");return n.toPromise(n.getArguments(function(e){if(this._closed)return d.reject(new Error("database is closed"));var i=this;return o(i,t,e),this.taskqueue.isReady?r.apply(this,e):new n.Promise(function(n,r){i.taskqueue.addTask(function(o){o?r(o):n(i[t].apply(i,e))})})}))},n.arrayBufferToBinaryString=function(e){for(var t="",n=new Uint8Array(e),r=n.byteLength,o=0;r>o;o++)t+=String.fromCharCode(n[o]);return t},n.cancellableFun=function(e,t,r){r=r?n.clone(!0,{},r):{};var o=new u,i=r.complete||function(){},s=r.complete=n.once(function(e,t){e?i(e):(o.emit("end",t),i(null,t)),o.removeAllListeners()}),a=r.onChange||function(){},c=0;t.on("destroyed",function(){o.removeAllListeners()}),r.onChange=function(e){a(e),e.seq<=c||(c=e.seq,o.emit("change",e),e.deleted?o.emit("delete",e):1===e.changes.length&&"1-"===e.changes[0].rev.slice(0,1)?o.emit("create",e):o.emit("update",e))};var f=new d(function(e,t){r.complete=function(n,r){n?t(n):e(r)}});return f.then(function(e){s(null,e)},s),f.cancel=function(){f.isCancelled=!0,t.taskqueue.isReady&&r.complete(null,{status:"cancelled"})},t.taskqueue.isReady?e(t,r,f):t.taskqueue.addTask(function(){f.isCancelled?r.complete(null,{status:"cancelled"}):e(t,r,f)}),f.on=o.on.bind(o),f.once=o.once.bind(o),f.addListener=o.addListener.bind(o),f.removeListener=o.removeListener.bind(o),f.removeAllListeners=o.removeAllListeners.bind(o),f.setMaxListeners=o.setMaxListeners.bind(o),f.listeners=o.listeners.bind(o),f.emit=o.emit.bind(o),f},n.MD5=n.toPromise(e(20)),n.explain404=function(e){t.browser&&"console"in r&&"info"in console&&console.info("The above 404 is totally normal. "+e)},n.info=function(e){"undefined"!=typeof console&&"info"in console&&console.info(e)},n.parseUri=e(23),n.compare=function(e,t){return t>e?-1:e>t?1:0},n.updateDoc=function(e,t,r,o,i,a,u){if(n.revExists(e,t.metadata.rev))return r[o]=t,i();var f=n.isDeleted(e),l=n.isDeleted(t.metadata),d=/^1-/.test(t.metadata.rev);if(f&&!l&&u&&d){var p=t.data;p._rev=s.winningRev(e),p._id=t.metadata.id,t=n.parseDoc(p,u)}var h=s.merge(e.rev_tree,t.metadata.rev_tree[0],1e3),v=u&&(f&&l||!f&&"new_leaf"!==h.conflicts||f&&!l&&"new_branch"===h.conflicts);if(v){var _=c.error(c.REV_CONFLICT);return r[o]=_,i()}var m=t.metadata.rev;t.metadata.rev_tree=h.tree,e.rev_map&&(t.metadata.rev_map=e.rev_map);var g=s.winningRev(t.metadata);l=n.isDeleted(t.metadata,g);var y=0;(u||g===m)&&(y=f===l?0:l>f?-1:1),a(t,g,l,i,!0,y,o)},n.processDocs=function(e,t,r,o,i,a,u,f){function l(e,t,r){var o=s.winningRev(e.metadata),f=n.isDeleted(e.metadata,o);if("was_delete"in u&&f)return i[t]=c.error(c.MISSING_DOC,"deleted"),r();var l=f?0:1;a(e,o,f,r,!1,l,t)}function d(){++v===_&&f&&f()}if(e.length){var p=u.new_edits,h=new n.Map,v=0,_=e.length;e.forEach(function(e,r){if(e._id&&n.isLocalId(e._id))return void t[e._deleted?"_removeLocal":"_putLocal"](e,{ctx:o},function(e){i[r]=e?e:{ok:!0},d()});var s=e.metadata.id;h.has(s)?(_--,h.get(s).push([e,r])):h.set(s,[[e,r]])}),h.forEach(function(e,t){function o(){++c<e.length?s():d()}function s(){var s=e[c],u=s[0],f=s[1];r.has(t)?n.updateDoc(r.get(t),u,i,f,o,a,p):l(u,f,o)}var c=0;s()})}},n.preprocessAttachments=function(e,t,r){function o(e){try{return n.atob(e)}catch(t){var r=c.error(c.BAD_ARG,"Attachments need to be base64 encoded");return{error:r}}}function i(e,r){if(e.stub)return r();if("string"==typeof e.data){var i=o(e.data);if(i.error)return r(i.error);e.length=i.length,e.data="blob"===t?n.createBlob([n.fixBinary(i)],{type:e.content_type}):"base64"===t?n.btoa(i):i,n.MD5(i).then(function(t){e.digest="md5-"+t,r()})}else n.readAsArrayBuffer(e.data,function(o){"binary"===t?e.data=n.arrayBufferToBinaryString(o):"base64"===t&&(e.data=n.btoa(n.arrayBufferToBinaryString(o))),n.MD5(o).then(function(t){e.digest="md5-"+t,e.length=o.byteLength,r()})})}function s(){u++,e.length===u&&(a?r(a):r())}if(!e.length)return r();var a,u=0;e.forEach(function(e){function t(e){a=e,r++,r===n.length&&s()}var n=e.data&&e.data._attachments?Object.keys(e.data._attachments):[],r=0;if(!n.length)return s();for(var o in e.data._attachments)e.data._attachments.hasOwnProperty(o)&&i(e.data._attachments[o],t)})},n.compactTree=function(e){var t=[];return s.traverseRevTree(e.rev_tree,function(e,n,r,o,i){"available"!==i.status||e||(t.push(n+"-"+r),i.status="missing")}),t};var p=e(74);n.safeJsonParse=function(e){try{return JSON.parse(e)}catch(t){return p.parse(e)}},n.safeJsonStringify=function(e){try{return JSON.stringify(e)}catch(t){return p.stringify(e)}}}).call(this,e(39),"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],35:[function(e,t){t.exports="3.3.1"},{}],36:[function(e,t){"use strict";function n(e){return function(){var t=arguments.length;if(t){for(var n=[],r=-1;++r<t;)n[r]=arguments[r];return e.call(this,n)}return e.call(this,[])}}t.exports=n},{}],37:[function(){},{}],38:[function(e,t){function n(){this._events=this._events||{},this._maxListeners=this._maxListeners||void 0}function r(e){return"function"==typeof e}function o(e){return"number"==typeof e}function i(e){return"object"==typeof e&&null!==e}function s(e){return void 0===e}t.exports=n,n.EventEmitter=n,n.prototype._events=void 0,n.prototype._maxListeners=void 0,n.defaultMaxListeners=10,n.prototype.setMaxListeners=function(e){if(!o(e)||0>e||isNaN(e))throw TypeError("n must be a positive number");return this._maxListeners=e,this},n.prototype.emit=function(e){var t,n,o,a,c,u;if(this._events||(this._events={}),"error"===e&&(!this._events.error||i(this._events.error)&&!this._events.error.length)){if(t=arguments[1],t instanceof Error)throw t;throw TypeError('Uncaught, unspecified "error" event.')}if(n=this._events[e],s(n))return!1;if(r(n))switch(arguments.length){case 1:n.call(this);break;case 2:n.call(this,arguments[1]);break;case 3:n.call(this,arguments[1],arguments[2]);break;default:for(o=arguments.length,a=new Array(o-1),c=1;o>c;c++)a[c-1]=arguments[c];n.apply(this,a)}else if(i(n)){for(o=arguments.length,a=new Array(o-1),c=1;o>c;c++)a[c-1]=arguments[c];for(u=n.slice(),o=u.length,c=0;o>c;c++)u[c].apply(this,a)}return!0},n.prototype.addListener=function(e,t){var o;if(!r(t))throw TypeError("listener must be a function");if(this._events||(this._events={}),this._events.newListener&&this.emit("newListener",e,r(t.listener)?t.listener:t),this._events[e]?i(this._events[e])?this._events[e].push(t):this._events[e]=[this._events[e],t]:this._events[e]=t,i(this._events[e])&&!this._events[e].warned){var o;o=s(this._maxListeners)?n.defaultMaxListeners:this._maxListeners,o&&o>0&&this._events[e].length>o&&(this._events[e].warned=!0,console.error("(node) warning: possible EventEmitter memory leak detected. %d listeners added. Use emitter.setMaxListeners() to increase limit.",this._events[e].length),"function"==typeof console.trace&&console.trace())}return this},n.prototype.on=n.prototype.addListener,n.prototype.once=function(e,t){function n(){this.removeListener(e,n),o||(o=!0,t.apply(this,arguments))}if(!r(t))throw TypeError("listener must be a function");var o=!1;return n.listener=t,this.on(e,n),this},n.prototype.removeListener=function(e,t){var n,o,s,a;if(!r(t))throw TypeError("listener must be a function");if(!this._events||!this._events[e])return this;if(n=this._events[e],s=n.length,o=-1,n===t||r(n.listener)&&n.listener===t)delete this._events[e],this._events.removeListener&&this.emit("removeListener",e,t);else if(i(n)){for(a=s;a-->0;)if(n[a]===t||n[a].listener&&n[a].listener===t){o=a;break}if(0>o)return this;1===n.length?(n.length=0,delete this._events[e]):n.splice(o,1),this._events.removeListener&&this.emit("removeListener",e,t)}return this},n.prototype.removeAllListeners=function(e){var t,n;if(!this._events)return this;if(!this._events.removeListener)return 0===arguments.length?this._events={}:this._events[e]&&delete this._events[e],this;if(0===arguments.length){for(t in this._events)"removeListener"!==t&&this.removeAllListeners(t);return this.removeAllListeners("removeListener"),this._events={},this}if(n=this._events[e],r(n))this.removeListener(e,n);else for(;n.length;)this.removeListener(e,n[n.length-1]);return delete this._events[e],this},n.prototype.listeners=function(e){var t;return t=this._events&&this._events[e]?r(this._events[e])?[this._events[e]]:this._events[e].slice():[]},n.listenerCount=function(e,t){var n;return n=e._events&&e._events[t]?r(e._events[t])?1:e._events[t].length:0}},{}],39:[function(e,t){function n(){}var r=t.exports={};r.nextTick=function(){var e="undefined"!=typeof window&&window.setImmediate,t="undefined"!=typeof window&&window.MutationObserver,n="undefined"!=typeof window&&window.postMessage&&window.addEventListener;if(e)return function(e){return window.setImmediate(e)};var r=[];if(t){var o=document.createElement("div"),i=new MutationObserver(function(){var e=r.slice();r.length=0,e.forEach(function(e){e()})});return i.observe(o,{attributes:!0}),function(e){r.length||o.setAttribute("yes","no"),r.push(e)}}return n?(window.addEventListener("message",function(e){var t=e.source;if((t===window||null===t)&&"process-tick"===e.data&&(e.stopPropagation(),r.length>0)){var n=r.shift();n()}},!0),function(e){r.push(e),window.postMessage("process-tick","*")}):function(e){setTimeout(e,0)}}(),r.title="browser",r.browser=!0,r.env={},r.argv=[],r.on=n,r.addListener=n,r.once=n,r.off=n,r.removeListener=n,r.removeAllListeners=n,r.emit=n,r.binding=function(){throw new Error("process.binding is not supported")},r.cwd=function(){return"/"},r.chdir=function(){throw new Error("process.chdir is not supported")}},{}],40:[function(e,t,n){function r(){return"WebkitAppearance"in document.documentElement.style||window.console&&(console.firebug||console.exception&&console.table)||navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/)&&parseInt(RegExp.$1,10)>=31}function o(){var e=arguments,t=this.useColors;if(e[0]=(t?"%c":"")+this.namespace+(t?" %c":" ")+e[0]+(t?"%c ":" ")+"+"+n.humanize(this.diff),!t)return e;var r="color: "+this.color;e=[e[0],r,"color: inherit"].concat(Array.prototype.slice.call(e,1));var o=0,i=0;return e[0].replace(/%[a-z%]/g,function(e){"%"!==e&&(o++,"%c"===e&&(i=o))}),e.splice(i,0,r),e}function i(){return"object"==typeof console&&console.log&&Function.prototype.apply.call(console.log,console,arguments)}function s(e){try{null==e?u.removeItem("debug"):u.debug=e}catch(t){}}function a(){var e;try{e=u.debug}catch(t){}return e}function c(){try{return window.localStorage}catch(e){}}n=t.exports=e(41),n.log=i,n.formatArgs=o,n.save=s,n.load=a,n.useColors=r;var u;u="undefined"!=typeof chrome&&"undefined"!=typeof chrome.storage?chrome.storage.local:c(),n.colors=["lightseagreen","forestgreen","goldenrod","dodgerblue","darkorchid","crimson"],n.formatters.j=function(e){return JSON.stringify(e)},n.enable(a())},{}],41:[function(e,t,n){function r(){return n.colors[f++%n.colors.length]}function o(e){function t(){}function o(){var e=o,t=+new Date,i=t-(u||t);e.diff=i,e.prev=u,e.curr=t,u=t,null==e.useColors&&(e.useColors=n.useColors()),null==e.color&&e.useColors&&(e.color=r());var s=Array.prototype.slice.call(arguments);s[0]=n.coerce(s[0]),"string"!=typeof s[0]&&(s=["%o"].concat(s));var a=0;s[0]=s[0].replace(/%([a-z%])/g,function(t,r){if("%"===t)return t;a++;var o=n.formatters[r];if("function"==typeof o){var i=s[a];t=o.call(e,i),s.splice(a,1),a--}return t}),"function"==typeof n.formatArgs&&(s=n.formatArgs.apply(e,s));var c=o.log||n.log||console.log.bind(console);c.apply(e,s)}t.enabled=!1,o.enabled=!0;var i=n.enabled(e)?o:t;return i.namespace=e,i}function i(e){n.save(e);for(var t=(e||"").split(/[\s,]+/),r=t.length,o=0;r>o;o++)t[o]&&(e=t[o].replace(/\*/g,".*?"),"-"===e[0]?n.skips.push(new RegExp("^"+e.substr(1)+"$")):n.names.push(new RegExp("^"+e+"$")))}function s(){n.enable("")}function a(e){var t,r;for(t=0,r=n.skips.length;r>t;t++)if(n.skips[t].test(e))return!1;for(t=0,r=n.names.length;r>t;t++)if(n.names[t].test(e))return!0;return!1}function c(e){return e instanceof Error?e.stack||e.message:e}n=t.exports=o,n.coerce=c,n.disable=s,n.enable=i,n.enabled=a,n.humanize=e(42),n.names=[],n.skips=[],n.formatters={};var u,f=0},{}],42:[function(e,t){function n(e){var t=/^((?:\d+)?\.?\d+) *(ms|seconds?|s|minutes?|m|hours?|h|days?|d|years?|y)?$/i.exec(e);if(t){var n=parseFloat(t[1]),r=(t[2]||"ms").toLowerCase();switch(r){case"years":case"year":case"y":return n*f;case"days":case"day":case"d":return n*u;case"hours":case"hour":case"h":return n*c;case"minutes":case"minute":case"m":return n*a;case"seconds":case"second":case"s":return n*s;case"ms":return n}}}function r(e){return e>=u?Math.round(e/u)+"d":e>=c?Math.round(e/c)+"h":e>=a?Math.round(e/a)+"m":e>=s?Math.round(e/s)+"s":e+"ms"}function o(e){return i(e,u,"day")||i(e,c,"hour")||i(e,a,"minute")||i(e,s,"second")||e+" ms"}function i(e,t,n){return t>e?void 0:1.5*t>e?Math.floor(e/t)+" "+n:Math.ceil(e/t)+" "+n+"s"}var s=1e3,a=60*s,c=60*a,u=24*c,f=365.25*u;t.exports=function(e,t){return t=t||{},"string"==typeof e?n(e):t["long"]?o(e):r(e)}},{}],43:[function(e,t){t.exports="function"==typeof Object.create?function(e,t){e.super_=t,e.prototype=Object.create(t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}})}:function(e,t){e.super_=t;var n=function(){};n.prototype=t.prototype,e.prototype=new n,e.prototype.constructor=e}},{}],44:[function(e,t){"use strict";function n(){}t.exports=n},{}],45:[function(e,t){"use strict";function n(e){function t(e,t){function r(e){u[t]=e,++f===n&!c&&(c=!0,a.resolve(d,u))}i(e).then(r,function(e){c||(c=!0,a.reject(d,e))})}if("[object Array]"!==Object.prototype.toString.call(e))return o(new TypeError("must be an array"));var n=e.length,c=!1;if(!n)return i([]);for(var u=new Array(n),f=0,l=-1,d=new r(s);++l<n;)t(e[l],l);return d}var r=e(48),o=e(51),i=e(52),s=e(44),a=e(46);t.exports=n},{}],46:[function(e,t,n){"use strict";function r(e){var t=e&&e.then;return e&&"object"==typeof e&&"function"==typeof t?function(){t.apply(e,arguments)}:void 0}var o=e(55),i=e(53),s=e(54);n.resolve=function(e,t){var a=o(r,t);if("error"===a.status)return n.reject(e,a.value);var c=a.value;if(c)i.safely(e,c);else{e.state=s.FULFILLED,e.outcome=t;for(var u=-1,f=e.queue.length;++u<f;)e.queue[u].callFulfilled(t)}return e},n.reject=function(e,t){e.state=s.REJECTED,e.outcome=t;for(var n=-1,r=e.queue.length;++n<r;)e.queue[n].callRejected(t);return e}},{}],47:[function(e,t,n){t.exports=n=e(48),n.resolve=e(52),n.reject=e(51),n.all=e(45),n.race=e(50)},{}],48:[function(e,t){"use strict";function n(e){if(!(this instanceof n))return new n(e);if("function"!=typeof e)throw new TypeError("resolver must be a function");this.state=s.PENDING,this.queue=[],this.outcome=void 0,e!==o&&i.safely(this,e)}var r=e(56),o=e(44),i=e(53),s=e(54),a=e(49);t.exports=n,n.prototype["catch"]=function(e){return this.then(null,e)},n.prototype.then=function(e,t){if("function"!=typeof e&&this.state===s.FULFILLED||"function"!=typeof t&&this.state===s.REJECTED)return this;var i=new n(o);if(this.state!==s.PENDING){var c=this.state===s.FULFILLED?e:t;r(i,c,this.outcome)}else this.queue.push(new a(i,e,t));return i}},{}],49:[function(e,t){"use strict";function n(e,t,n){this.promise=e,"function"==typeof t&&(this.onFulfilled=t,this.callFulfilled=this.otherCallFulfilled),"function"==typeof n&&(this.onRejected=n,this.callRejected=this.otherCallRejected)}var r=e(46),o=e(56);t.exports=n,n.prototype.callFulfilled=function(e){r.resolve(this.promise,e)},n.prototype.otherCallFulfilled=function(e){o(this.promise,this.onFulfilled,e)},n.prototype.callRejected=function(e){r.reject(this.promise,e)},n.prototype.otherCallRejected=function(e){o(this.promise,this.onRejected,e)}},{}],50:[function(e,t){"use strict";function n(e){function t(e){i(e).then(function(e){c||(c=!0,a.resolve(f,e))},function(e){c||(c=!0,a.reject(f,e))})}if("[object Array]"!==Object.prototype.toString.call(e))return o(new TypeError("must be an array"));var n=e.length,c=!1;if(!n)return i([]);for(var u=-1,f=new r(s);++u<n;)t(e[u]);return f}var r=e(48),o=e(51),i=e(52),s=e(44),a=e(46);t.exports=n},{}],51:[function(e,t){"use strict";function n(e){var t=new r(o);return i.reject(t,e)}var r=e(48),o=e(44),i=e(46);t.exports=n},{}],52:[function(e,t){"use strict";function n(e){if(e)return e instanceof r?e:i.resolve(new r(o),e);var t=typeof e;switch(t){case"boolean":return s;case"undefined":return c;case"object":return a;case"number":return u;case"string":return f}}var r=e(48),o=e(44),i=e(46);t.exports=n;var s=i.resolve(new r(o),!1),a=i.resolve(new r(o),null),c=i.resolve(new r(o),void 0),u=i.resolve(new r(o),0),f=i.resolve(new r(o),"")},{}],53:[function(e,t,n){"use strict";function r(e,t){function n(t){a||(a=!0,o.reject(e,t))}function r(t){a||(a=!0,o.resolve(e,t))}function s(){t(r,n)}var a=!1,c=i(s);"error"===c.status&&n(c.value)}var o=e(46),i=e(55);n.safely=r},{}],54:[function(e,t,n){n.REJECTED=["REJECTED"],n.FULFILLED=["FULFILLED"],n.PENDING=["PENDING"]},{}],55:[function(e,t){"use strict";function n(e,t){var n={};try{n.value=e(t),n.status="success"}catch(r){n.status="error",n.value=r}return n}t.exports=n},{}],56:[function(e,t){"use strict";function n(e,t,n){r(function(){var r;try{r=t(n)}catch(i){return o.reject(e,i)}r===e?o.reject(e,new TypeError("Cannot resolve promise with itself")):o.resolve(e,r)})}var r=e(57),o=e(46);t.exports=n},{}],57:[function(e,t){"use strict";function n(){o=!0;for(var e,t,n=a.length;n;){for(t=a,a=[],e=-1;++e<n;)t[e]();n=a.length}o=!1}function r(e){1!==a.push(e)||o||i()}for(var o,i,s=[e(37),e(59),e(58),e(60),e(61)],a=[],c=-1,u=s.length;++c<u;)if(s[c]&&s[c].test&&s[c].test()){i=s[c].install(n);break}t.exports=r},{}],58:[function(e,t,n){(function(e){"use strict";n.test=function(){return e.setImmediate?!1:"undefined"!=typeof e.MessageChannel},n.install=function(t){var n=new e.MessageChannel;return n.port1.onmessage=t,function(){n.port2.postMessage(0)}}}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],59:[function(e,t,n){(function(e){"use strict";var t=e.MutationObserver||e.WebKitMutationObserver;n.test=function(){return t},n.install=function(n){var r=0,o=new t(n),i=e.document.createTextNode("");return o.observe(i,{characterData:!0}),function(){i.data=r=++r%2}}}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],60:[function(e,t,n){(function(e){"use strict";n.test=function(){return"document"in e&&"onreadystatechange"in e.document.createElement("script")},n.install=function(t){return function(){var n=e.document.createElement("script");return n.onreadystatechange=function(){t(),n.onreadystatechange=null,n.parentNode.removeChild(n),n=null},e.document.documentElement.appendChild(n),t}}}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],61:[function(e,t,n){"use strict";n.test=function(){return!0},n.install=function(e){return function(){setTimeout(e,0)}}},{}],62:[function(e,t,n){"use strict";function r(e){if(null!==e)switch(typeof e){case"boolean":return e?1:0;case"number":return f(e);case"string":return e.replace(/\u0002/g,"").replace(/\u0001/g,"").replace(/\u0000/g,"");case"object":var t=Array.isArray(e),r=t?e:Object.keys(e),o=-1,i=r.length,s="";if(t)for(;++o<i;)s+=n.toIndexableString(r[o]);else for(;++o<i;){var a=r[o];s+=n.toIndexableString(a)+n.toIndexableString(e[a])}return s}return""}function o(e,t){var n,r=t,o="1"===e[t];if(o)n=0,t++;else{var i="0"===e[t];t++;var s="",a=e.substring(t,t+d),c=parseInt(a,10)+l;for(i&&(c=-c),t+=d;;){var u=e[t];if("\x00"===u)break;s+=u,t++}s=s.split("."),n=1===s.length?parseInt(s,10):parseFloat(s[0]+"."+s[1]),i&&(n-=10),0!==c&&(n=parseFloat(n+"e"+c))}return{num:n,length:t-r}}function i(e,t){var n=e.pop();if(t.length){var r=t[t.length-1];n===r.element&&(t.pop(),r=t[t.length-1]);var o=r.element,i=r.index;if(Array.isArray(o))o.push(n);else if(i===e.length-2){var s=e.pop();o[s]=n}else e.push(n)}}function s(e,t){for(var r=Math.min(e.length,t.length),o=0;r>o;o++){var i=n.collate(e[o],t[o]);if(0!==i)return i}return e.length===t.length?0:e.length>t.length?1:-1}function a(e,t){return e===t?0:e>t?1:-1}function c(e,t){for(var r=Object.keys(e),o=Object.keys(t),i=Math.min(r.length,o.length),s=0;i>s;s++){var a=n.collate(r[s],o[s]);if(0!==a)return a;if(a=n.collate(e[r[s]],t[o[s]]),0!==a)return a}return r.length===o.length?0:r.length>o.length?1:-1}function u(e){var t=["boolean","number","string","object"],n=t.indexOf(typeof e);return~n?null===e?1:Array.isArray(e)?5:3>n?n+2:n+3:Array.isArray(e)?5:void 0}function f(e){if(0===e)return"1";var t=e.toExponential().split(/e\+?/),n=parseInt(t[1],10),r=0>e,o=r?"0":"2",i=(r?-n:n)-l,s=h.padLeft(i.toString(),"0",d);o+=p+s;var a=Math.abs(parseFloat(t[0]));r&&(a=10-a);var c=a.toFixed(20);return c=c.replace(/\.?0+$/,""),o+=p+c}var l=-324,d=3,p="",h=e(63);n.collate=function(e,t){if(e===t)return 0;e=n.normalizeKey(e),t=n.normalizeKey(t);var r=u(e),o=u(t);if(r-o!==0)return r-o;if(null===e)return 0;switch(typeof e){case"number":return e-t;case"boolean":return e===t?0:t>e?-1:1;case"string":return a(e,t)}return Array.isArray(e)?s(e,t):c(e,t)},n.normalizeKey=function(e){switch(typeof e){case"undefined":return null;case"number":return 1/0===e||e===-1/0||isNaN(e)?null:e;case"object":var t=e;if(Array.isArray(e)){var r=e.length;e=new Array(r);for(var o=0;r>o;o++)e[o]=n.normalizeKey(t[o])}else{if(e instanceof Date)return e.toJSON();if(null!==e){e={};for(var i in t)if(t.hasOwnProperty(i)){var s=t[i];"undefined"!=typeof s&&(e[i]=n.normalizeKey(s))}}}}return e},n.toIndexableString=function(e){var t="\x00";return e=n.normalizeKey(e),u(e)+p+r(e)+t},n.parseIndexableString=function(e){for(var t=[],n=[],r=0;;){var s=e[r++];if("\x00"!==s)switch(s){case"1":t.push(null);break;case"2":t.push("1"===e[r]),r++;break;case"3":var a=o(e,r);t.push(a.num),r+=a.length;break;case"4":for(var c="";;){var u=e[r];if("\x00"===u)break;c+=u,r++}c=c.replace(/\u0001\u0001/g,"\x00").replace(/\u0001\u0002/g,"").replace(/\u0002\u0002/g,""),t.push(c);break;case"5":var f={element:[],index:t.length};t.push(f.element),n.push(f);break;case"6":var l={element:{},index:t.length};t.push(l.element),n.push(l);break;default:throw new Error("bad collationIndex or unexpectedly reached end of input: "+s)}else{if(1===t.length)return t.pop();i(t,n)}}}},{}],63:[function(e,t,n){"use strict";function r(e,t,n){for(var r="",o=n-e.length;r.length<o;)r+=t;return r}n.padLeft=function(e,t,n){var o=r(e,t,n);return o+e},n.padRight=function(e,t,n){var o=r(e,t,n);return e+o},n.stringLexCompare=function(e,t){var n,r=e.length,o=t.length;for(n=0;r>n;n++){if(n===o)return 1;var i=e.charAt(n),s=t.charAt(n);if(i!==s)return s>i?-1:1}return o>r?-1:0},n.intToDecimalForm=function(e){var t=0>e,n="";do{var r=t?-Math.ceil(e%10):Math.floor(e%10);n=r+n,e=t?Math.ceil(e/10):Math.floor(e/10)}while(e);return t&&"0"!==n&&(n="-"+n),n}},{}],64:[function(e,t,n){"use strict";function r(){this.store={}}function o(e){if(this.store=new r,e&&Array.isArray(e))for(var t=0,n=e.length;n>t;t++)this.add(e[t])}n.Map=r,n.Set=o,r.prototype.mangle=function(e){if("string"!=typeof e)throw new TypeError("key must be a string but Got "+e);return"$"+e},r.prototype.unmangle=function(e){return e.substring(1)},r.prototype.get=function(e){var t=this.mangle(e);return t in this.store?this.store[t]:void 0},r.prototype.set=function(e,t){var n=this.mangle(e);return this.store[n]=t,!0},r.prototype.has=function(e){var t=this.mangle(e);return t in this.store},r.prototype["delete"]=function(e){var t=this.mangle(e);return t in this.store?(delete this.store[t],!0):!1},r.prototype.forEach=function(e){var t=this,n=Object.keys(t.store);n.forEach(function(n){var r=t.store[n];n=t.unmangle(n),e(r,n)})},o.prototype.add=function(e){return this.store.set(e,!0)},o.prototype.has=function(e){return this.store.has(e)},o.prototype["delete"]=function(e){return this.store["delete"](e)}},{}],65:[function(e,t){"use strict";function n(e){return null===e?String(e):"object"==typeof e||"function"==typeof e?c[d.call(e)]||"object":typeof e}function r(e){return null!==e&&e===e.window}function o(e){if(!e||"object"!==n(e)||e.nodeType||r(e))return!1;try{if(e.constructor&&!p.call(e,"constructor")&&!p.call(e.constructor.prototype,"isPrototypeOf"))return!1}catch(t){return!1}var o;for(o in e);return void 0===o||p.call(e,o)}function i(e){return"function"===n(e)}function s(){for(var e=[],t=-1,n=arguments.length,r=new Array(n);++t<n;)r[t]=arguments[t];var o={};e.push({args:r,result:{container:o,key:"key"}});for(var i;i=e.pop();)a(e,i.args,i.result);return o.key}function a(e,t,n){var r,s,a,c,u,f,l,d=t[0]||{},p=1,v=t.length,_=!1,m=/\d+/;for("boolean"==typeof d&&(_=d,d=t[1]||{},p=2),"object"==typeof d||i(d)||(d={}),v===p&&(d=this,--p);v>p;p++)if(null!=(r=t[p])){l=h(r);for(s in r)if(!(s in Object.prototype)){if(l&&!m.test(s))continue;if(a=d[s],c=r[s],d===c)continue;_&&c&&(o(c)||(u=h(c)))?(u?(u=!1,f=a&&h(a)?a:[]):f=a&&o(a)?a:{},e.push({args:[_,f,c],result:{container:d,key:s}})):void 0!==c&&(h(r)&&i(c)||(d[s]=c))}}n.container[n.key]=d}for(var c={},u=["Boolean","Number","String","Function","Array","Date","RegExp","Object","Error"],f=0;f<u.length;f++){var l=u[f];c["[object "+l+"]"]=l.toLowerCase()}var d=c.toString,p=c.hasOwnProperty,h=Array.isArray||function(e){return"array"===n(e)};t.exports=s},{}],66:[function(e,t){"use strict";var n=e(70),r=e(71),o=r.Promise;t.exports=function(e){var t=e.db,i=e.viewName,s=e.map,a=e.reduce,c=e.temporary,u=s.toString()+(a&&a.toString())+"undefined";if(!c&&t._cachedViews){var f=t._cachedViews[u];if(f)return o.resolve(f)}return t.info().then(function(e){function o(e){e.views=e.views||{};var t=i;-1===t.indexOf("/")&&(t=i+"/"+i);var n=e.views[t]=e.views[t]||{};if(!n[f])return n[f]=!0,e}var f=e.db_name+"-mrview-"+(c?"temp":r.MD5(u));return n(t,"_local/mrviews",o).then(function(){return t.registerDependentDatabase(f).then(function(e){var n=e.db;n.auto_compaction=!0;var r={name:f,db:n,sourceDB:t,adapter:t.adapter,mapFun:s,reduceFun:a};return r.db.get("_local/lastSeq")["catch"](function(e){if(404!==e.status)throw e}).then(function(e){return r.seq=e?e.seq:0,c||(t._cachedViews=t._cachedViews||{},t._cachedViews[u]=r,r.db.on("destroyed",function(){delete t._cachedViews[u]})),r})})})})}},{}],67:[function(_dereq_,module,exports){"use strict";module.exports=function(func,emit,sum,log,isArray,toJSON){return eval("'use strict'; ("+func.replace(/;\s*$/,"")+");")}},{}],68:[function(e,t,n){(function(t){"use strict";function r(e){return-1===e.indexOf("/")?[e,e]:e.split("/")}function o(e){return 1===e.length&&/^1-/.test(e[0].rev)}function i(e,t,n){try{return{output:t.apply(null,n)}}catch(r){return e.emit("error",r),{error:r}}}function s(e,t){var n=D(e.key,t.key);return 0!==n?n:D(e.value,t.value)}function a(e,t,n){return n=n||0,"number"==typeof t?e.slice(n,t+n):n>0?e.slice(n):e}function c(e){var t=e.value,n=t&&"object"==typeof t&&t._id||e.id;return n}function u(e){var t=new Error("builtin "+e+" function requires map values to be numbers or number arrays");return t.name="invalid_value",t.status=500,t}function f(e){for(var t=0,n=0,r=e.length;r>n;n++){var o=e[n];if("number"!=typeof o){if(!Array.isArray(o))throw u("_sum");t="number"==typeof t?[t]:t;for(var i=0,s=o.length;s>i;i++){var a=o[i];if("number"!=typeof a)throw u("_sum");"undefined"==typeof t[i]?t.push(a):t[i]+=a}}else"number"==typeof t?t+=o:t[0]+=o}return t}function l(e,t,n,r){var o=t[e];"undefined"!=typeof o&&(r&&(o=encodeURIComponent(JSON.stringify(o))),n.push(e+"="+o))}function d(e,t){var n=e.descending?"endkey":"startkey",r=e.descending?"startkey":"endkey";if("undefined"!=typeof e[n]&&"undefined"!=typeof e[r]&&D(e[n],e[r])>0)throw new A("No rows can match your key range, reverse your start_key and end_key or set {descending : true}");if(t.reduce&&e.reduce!==!1){if(e.include_docs)throw new A("{include_docs:true} is invalid for reduce");if(e.keys&&e.keys.length>1&&!e.group&&!e.group_level)throw new A("Multi-key fetches for reduce views must use {group: true}")}if(e.group_level){if("number"!=typeof e.group_level)throw new A('Invalid value for integer: "'+e.group_level+'"');if(e.group_level<0)throw new A('Invalid value for positive integer: "'+e.group_level+'"')}}function p(e,t,n){var o,i=[],s="GET";if(l("reduce",n,i),l("include_docs",n,i),l("attachments",n,i),l("limit",n,i),l("descending",n,i),l("group",n,i),l("group_level",n,i),l("skip",n,i),l("stale",n,i),l("conflicts",n,i),l("startkey",n,i,!0),l("endkey",n,i,!0),l("inclusive_end",n,i),l("key",n,i,!0),i=i.join("&"),i=""===i?"":"?"+i,"undefined"!=typeof n.keys){var a=2e3,c="keys="+encodeURIComponent(JSON.stringify(n.keys));c.length+i.length+1<=a?i+=("?"===i[0]?"&":"?")+c:(s="POST","string"==typeof t?o=JSON.stringify({keys:n.keys}):t.keys=n.keys)}if("string"==typeof t){var u=r(t);return e.request({method:s,url:"_design/"+u[0]+"/_view/"+u[1]+i,body:o})}return o=o||{},Object.keys(t).forEach(function(e){o[e]=Array.isArray(t[e])?t[e]:t[e].toString()}),e.request({method:"POST",url:"_temp_view"+i,body:o})}function h(e){return function(t){if(404===t.status)return e;throw t}}function v(e,t,n){function r(){return o(l)?B.resolve(c):t.db.get(a)["catch"](h(c))}function i(e){return e.keys.length?t.db.allDocs({keys:e.keys,include_docs:!0}):B.resolve({rows:[]})}function s(e,t){for(var n=[],r={},o=0,i=t.rows.length;i>o;o++){var s=t.rows[o],a=s.doc;if(a&&(n.push(a),r[a._id]=!0,a._deleted=!f[a._id],!a._deleted)){var c=f[a._id];"value"in c&&(a.value=c.value)}}var u=Object.keys(f);return u.forEach(function(e){if(!r[e]){var t={_id:e},o=f[e];"value"in o&&(t.value=o.value),n.push(t)}}),e.keys=j.uniq(u.concat(e.keys)),n.push(e),n}var a="_local/doc_"+e,c={_id:a,keys:[]},u=n[e],f=u.indexableKeysToKeyValues,l=u.changes;return r().then(function(e){return i(e).then(function(t){return s(e,t)})})}function _(e,t,n){var r="_local/lastSeq";return e.db.get(r)["catch"](h({_id:r,seq:0})).then(function(r){var o=Object.keys(t);return B.all(o.map(function(n){return v(n,e,t)})).then(function(t){var o=j.flatten(t);
11
+ return r.seq=n,o.push(r),e.db.bulkDocs({docs:o})})})}function m(e){var t="string"==typeof e?e:e.name,n=F[t];return n||(n=F[t]=new R),n}function g(e){return j.sequentialize(m(e),function(){return y(e)})()}function y(e){function t(e,t){var n={id:o._id,key:L(e)};"undefined"!=typeof t&&null!==t&&(n.value=L(t)),r.push(n)}function n(t,n){return function(){return _(e,t,n)}}var r,o,a;if("function"==typeof e.mapFun&&2===e.mapFun.length){var c=e.mapFun;a=function(e){return c(e,t)}}else a=N(e.mapFun.toString(),t,f,k,Array.isArray,JSON.parse);var u=e.seq||0,l=new R;return new B(function(t,c){function f(){l.finish().then(function(){e.seq=u,t()})}function d(){function t(e){c(e)}e.sourceDB.changes({conflicts:!0,include_docs:!0,style:"all_docs",since:u,limit:P}).on("complete",function(t){var c=t.results;if(!c.length)return f();for(var p={},h=0,v=c.length;v>h;h++){var _=c[h];if("_"!==_.doc._id[0]){r=[],o=_.doc,o._deleted||i(e.sourceDB,a,[o]),r.sort(s);for(var m,g={},y=0,b=r.length;b>y;y++){var E=r[y],w=[E.key,E.id];E.key===m&&w.push(y);var S=C(w);g[S]=E,m=E.key}p[_.doc._id]={indexableKeysToKeyValues:g,changes:_.changes}}u=_.seq}return l.add(n(p,u)),c.length<P?f():d()}).on("error",t)}d()})}function b(e,t,n){0===n.group_level&&delete n.group_level;var r,o=n.group||n.group_level;r=U[e.reduceFun]?U[e.reduceFun]:N(e.reduceFun.toString(),null,f,k,Array.isArray,JSON.parse);var s=[],c=n.group_level;t.forEach(function(e){var t=s[s.length-1],n=o?e.key:null;return o&&Array.isArray(n)&&"number"==typeof c&&(n=n.length>c?n.slice(0,c):n),t&&0===D(t.key[0][0],n)?(t.key.push([n,e.id]),void t.value.push(e.value)):void s.push({key:[[n,e.id]],value:[e.value]})});for(var u=0,l=s.length;l>u;u++){var d=s[u],p=i(e.sourceDB,r,[d.key,d.value,!1]);d.value=p.error?null:p.output,d.key=d.key[0][0]}return{rows:a(s,n.limit,n.skip)}}function E(e,t){return j.sequentialize(m(e),function(){return w(e,t)})()}function w(e,t){function n(t){return t.include_docs=!0,e.db.allDocs(t).then(function(e){return o=e.total_rows,e.rows.map(function(e){if("value"in e.doc&&"object"==typeof e.doc.value&&null!==e.doc.value){var t=Object.keys(e.doc.value).sort(),n=["id","key","value"];if(!(n>t||t>n))return e.doc.value}var r=q.parseIndexableString(e.doc._id);return{key:r[0],id:r[1],value:"value"in e.doc?e.doc.value:null}})})}function r(n){var r;if(r=i?b(e,n,t):{total_rows:o,offset:s,rows:n},t.include_docs){var a=j.uniq(n.map(c));return e.sourceDB.allDocs({keys:a,include_docs:!0,conflicts:t.conflicts,attachments:t.attachments}).then(function(e){var t={};return e.rows.forEach(function(e){e.doc&&(t["$"+e.id]=e.doc)}),n.forEach(function(e){var n=c(e),r=t["$"+n];r&&(e.doc=r)}),r})}return r}var o,i=e.reduceFun&&t.reduce!==!1,s=t.skip||0;"undefined"==typeof t.keys||t.keys.length||(t.limit=0,delete t.keys);var a=function(e){return e.reduce(function(e,t){return e.concat(t)})};if("undefined"!=typeof t.keys){var u=t.keys,f=u.map(function(e){var t={startkey:C([e]),endkey:C([e,{}])};return n(t)});return B.all(f).then(a).then(r)}var l={descending:t.descending};if("undefined"!=typeof t.startkey&&(l.startkey=C(t.descending?[t.startkey,{}]:[t.startkey])),"undefined"!=typeof t.endkey){var d=t.inclusive_end!==!1;t.descending&&(d=!d),l.endkey=C(d?[t.endkey,{}]:[t.endkey])}if("undefined"!=typeof t.key){var p=C([t.key]),h=C([t.key,{}]);l.descending?(l.endkey=p,l.startkey=h):(l.startkey=p,l.endkey=h)}return i||("number"==typeof t.limit&&(l.limit=t.limit),l.skip=s),n(l).then(r)}function S(e){return e.request({method:"POST",url:"_view_cleanup"})}function T(e){return e.get("_local/mrviews").then(function(t){var n={};Object.keys(t.views).forEach(function(e){var t=r(e),o="_design/"+t[0],i=t[1];n[o]=n[o]||{},n[o][i]=!0});var o={keys:Object.keys(n),include_docs:!0};return e.allDocs(o).then(function(r){var o={};r.rows.forEach(function(e){var r=e.key.substring(8);Object.keys(n[e.key]).forEach(function(n){var i=r+"/"+n;t.views[i]||(i=n);var s=Object.keys(t.views[i]),a=e.doc&&e.doc.views&&e.doc.views[n];s.forEach(function(e){o[e]=o[e]||a})})});var i=Object.keys(o).filter(function(e){return!o[e]}),s=i.map(function(t){return j.sequentialize(m(t),function(){return e.constructor.destroy(t,e.__opts)})()});return B.all(s).then(function(){return{ok:!0}})})},h({ok:!0}))}function x(e,n,o){if("http"===e.type())return p(e,n,o);if("string"!=typeof n){d(o,n);var i={db:e,viewName:"temp_view/temp_view",map:n.map,reduce:n.reduce,temporary:!0};return M.add(function(){return I(i).then(function(e){function t(){return e.db.destroy()}return j.fin(g(e).then(function(){return E(e,o)}),t)})}),M.finish()}var s=n,a=r(s),c=a[0],u=a[1];return e.get("_design/"+c).then(function(n){var r=n.views&&n.views[u];if(!r||"string"!=typeof r.map)throw new O("ddoc "+c+" has no view named "+u);d(o,r);var i={db:e,viewName:s,map:r.map,reduce:r.reduce};return I(i).then(function(e){return"ok"===o.stale||"update_after"===o.stale?("update_after"===o.stale&&t.nextTick(function(){g(e)}),E(e,o)):g(e).then(function(){return E(e,o)})})})}function A(e){this.status=400,this.name="query_parse_error",this.message=e,this.error=!0;try{Error.captureStackTrace(this,A)}catch(t){}}function O(e){this.status=404,this.name="not_found",this.message=e,this.error=!0;try{Error.captureStackTrace(this,O)}catch(t){}}var k,q=e(62),R=e(69),D=q.collate,C=q.toIndexableString,L=q.normalizeKey,I=e(66),N=e(67);k="undefined"!=typeof console&&"function"==typeof console.log?Function.prototype.bind.call(console.log,console):function(){};var j=e(71),B=j.Promise,F={},M=new R,P=50,U={_sum:function(e,t){return f(t)},_count:function(e,t){return t.length},_stats:function(e,t){function n(e){for(var t=0,n=0,r=e.length;r>n;n++){var o=e[n];t+=o*o}return t}return{sum:f(t),min:Math.min.apply(null,t),max:Math.max.apply(null,t),count:t.length,sumsqr:n(t)}}};n.viewCleanup=j.callbackify(function(){var e=this;return"http"===e.type()?S(e):T(e)}),n.query=function(e,t,n){"function"==typeof t&&(n=t,t={}),t=j.extend(!0,{},t),"function"==typeof e&&(e={map:e});var r=this,o=B.resolve().then(function(){return x(r,e,t)});return j.promisedCallback(o,n),o},j.inherits(A,Error),j.inherits(O,Error)}).call(this,e(39))},{}],69:[function(e,t){"use strict";function n(){this.promise=new r(function(e){e()})}var r=e(71).Promise;n.prototype.add=function(e){return this.promise=this.promise["catch"](function(){}).then(function(){return e()}),this.promise},n.prototype.finish=function(){return this.promise},t.exports=n},{}],70:[function(e,t){"use strict";var n=e(72).upsert;t.exports=function(e,t,r){return n.apply(e,[t,r])}},{}],71:[function(e,t,n){(function(t,r){"use strict";n.Promise="function"==typeof r.Promise?r.Promise:e(47),n.inherits=e(43),n.extend=e(65);var o=e(36);n.promisedCallback=function(e,n){return n&&e.then(function(e){t.nextTick(function(){n(null,e)})},function(e){t.nextTick(function(){n(e)})}),e},n.callbackify=function(e){return o(function(t){var r=t.pop(),o=e.apply(this,t);return"function"==typeof r&&n.promisedCallback(o,r),o})},n.fin=function(e,t){return e.then(function(e){var n=t();return"function"==typeof n.then?n.then(function(){return e}):e},function(e){var n=t();if("function"==typeof n.then)return n.then(function(){throw e});throw e})},n.sequentialize=function(e,t){return function(){var n=arguments,r=this;return e.add(function(){return t.apply(r,n)})}},n.flatten=function(e){for(var t=[],n=0,r=e.length;r>n;n++)t=t.concat(e[n]);return t},n.uniq=function(e){for(var t={},n=0,r=e.length;r>n;n++)t["$"+e[n]]=!0;var o=Object.keys(t),i=new Array(o.length);for(n=0,r=o.length;r>n;n++)i[n]=o[n].substring(1);return i};var i=e(37),s=e(73);n.MD5=function(e){return t.browser?s.hash(e):i.createHash("md5").update(e).digest("hex")}}).call(this,e(39),"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],72:[function(e,t,n){(function(t){"use strict";function r(e,t,n){return new i(function(r,i){return"string"!=typeof t?i(new Error("doc id is required")):void e.get(t,function(s,a){if(s){if(404!==s.status)return i(s);a={}}var c=n(a);return c?(c._id=t,c._rev=a._rev,void r(o(e,c,n))):r({updated:!1,rev:a._rev})})})}function o(e,t,n){return e.put(t).then(function(e){return{updated:!0,rev:e.rev}},function(o){if(409!==o.status)throw o;return r(e,t._id,n)})}var i;i="undefined"!=typeof window&&window.PouchDB?window.PouchDB.utils.Promise:"function"==typeof t.Promise?t.Promise:e(47),n.upsert=function(e,t,n){var o=this,i=r(o,e,t);return"function"!=typeof n?i:void i.then(function(e){n(null,e)},n)},n.putIfNotExists=function(e,t,n){var o=this;"string"!=typeof e&&(n=t,t=e,e=t._id);var i=function(e){return e._rev?!1:t},s=r(o,e,i);return"function"!=typeof n?s:void s.then(function(e){n(null,e)},n)},"undefined"!=typeof window&&window.PouchDB&&window.PouchDB.plugin(n)}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],73:[function(e,t,n){!function(e){if("object"==typeof n)t.exports=e();else if("function"==typeof define&&define.amd)define(e);else{var r;try{r=window}catch(o){r=self}r.SparkMD5=e()}}(function(){"use strict";var e=function(e,t){return e+t&4294967295},t=function(t,n,r,o,i,s){return n=e(e(n,t),e(o,s)),e(n<<i|n>>>32-i,r)},n=function(e,n,r,o,i,s,a){return t(n&r|~n&o,e,n,i,s,a)},r=function(e,n,r,o,i,s,a){return t(n&o|r&~o,e,n,i,s,a)},o=function(e,n,r,o,i,s,a){return t(n^r^o,e,n,i,s,a)},i=function(e,n,r,o,i,s,a){return t(r^(n|~o),e,n,i,s,a)},s=function(t,s){var a=t[0],c=t[1],u=t[2],f=t[3];a=n(a,c,u,f,s[0],7,-680876936),f=n(f,a,c,u,s[1],12,-389564586),u=n(u,f,a,c,s[2],17,606105819),c=n(c,u,f,a,s[3],22,-1044525330),a=n(a,c,u,f,s[4],7,-176418897),f=n(f,a,c,u,s[5],12,1200080426),u=n(u,f,a,c,s[6],17,-1473231341),c=n(c,u,f,a,s[7],22,-45705983),a=n(a,c,u,f,s[8],7,1770035416),f=n(f,a,c,u,s[9],12,-1958414417),u=n(u,f,a,c,s[10],17,-42063),c=n(c,u,f,a,s[11],22,-1990404162),a=n(a,c,u,f,s[12],7,1804603682),f=n(f,a,c,u,s[13],12,-40341101),u=n(u,f,a,c,s[14],17,-1502002290),c=n(c,u,f,a,s[15],22,1236535329),a=r(a,c,u,f,s[1],5,-165796510),f=r(f,a,c,u,s[6],9,-1069501632),u=r(u,f,a,c,s[11],14,643717713),c=r(c,u,f,a,s[0],20,-373897302),a=r(a,c,u,f,s[5],5,-701558691),f=r(f,a,c,u,s[10],9,38016083),u=r(u,f,a,c,s[15],14,-660478335),c=r(c,u,f,a,s[4],20,-405537848),a=r(a,c,u,f,s[9],5,568446438),f=r(f,a,c,u,s[14],9,-1019803690),u=r(u,f,a,c,s[3],14,-187363961),c=r(c,u,f,a,s[8],20,1163531501),a=r(a,c,u,f,s[13],5,-1444681467),f=r(f,a,c,u,s[2],9,-51403784),u=r(u,f,a,c,s[7],14,1735328473),c=r(c,u,f,a,s[12],20,-1926607734),a=o(a,c,u,f,s[5],4,-378558),f=o(f,a,c,u,s[8],11,-2022574463),u=o(u,f,a,c,s[11],16,1839030562),c=o(c,u,f,a,s[14],23,-35309556),a=o(a,c,u,f,s[1],4,-1530992060),f=o(f,a,c,u,s[4],11,1272893353),u=o(u,f,a,c,s[7],16,-155497632),c=o(c,u,f,a,s[10],23,-1094730640),a=o(a,c,u,f,s[13],4,681279174),f=o(f,a,c,u,s[0],11,-358537222),u=o(u,f,a,c,s[3],16,-722521979),c=o(c,u,f,a,s[6],23,76029189),a=o(a,c,u,f,s[9],4,-640364487),f=o(f,a,c,u,s[12],11,-421815835),u=o(u,f,a,c,s[15],16,530742520),c=o(c,u,f,a,s[2],23,-995338651),a=i(a,c,u,f,s[0],6,-198630844),f=i(f,a,c,u,s[7],10,1126891415),u=i(u,f,a,c,s[14],15,-1416354905),c=i(c,u,f,a,s[5],21,-57434055),a=i(a,c,u,f,s[12],6,1700485571),f=i(f,a,c,u,s[3],10,-1894986606),u=i(u,f,a,c,s[10],15,-1051523),c=i(c,u,f,a,s[1],21,-2054922799),a=i(a,c,u,f,s[8],6,1873313359),f=i(f,a,c,u,s[15],10,-30611744),u=i(u,f,a,c,s[6],15,-1560198380),c=i(c,u,f,a,s[13],21,1309151649),a=i(a,c,u,f,s[4],6,-145523070),f=i(f,a,c,u,s[11],10,-1120210379),u=i(u,f,a,c,s[2],15,718787259),c=i(c,u,f,a,s[9],21,-343485551),t[0]=e(a,t[0]),t[1]=e(c,t[1]),t[2]=e(u,t[2]),t[3]=e(f,t[3])},a=function(e){var t,n=[];for(t=0;64>t;t+=4)n[t>>2]=e.charCodeAt(t)+(e.charCodeAt(t+1)<<8)+(e.charCodeAt(t+2)<<16)+(e.charCodeAt(t+3)<<24);return n},c=function(e){var t,n=[];for(t=0;64>t;t+=4)n[t>>2]=e[t]+(e[t+1]<<8)+(e[t+2]<<16)+(e[t+3]<<24);return n},u=function(e){var t,n,r,o,i,c,u=e.length,f=[1732584193,-271733879,-1732584194,271733878];for(t=64;u>=t;t+=64)s(f,a(e.substring(t-64,t)));for(e=e.substring(t-64),n=e.length,r=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],t=0;n>t;t+=1)r[t>>2]|=e.charCodeAt(t)<<(t%4<<3);if(r[t>>2]|=128<<(t%4<<3),t>55)for(s(f,r),t=0;16>t;t+=1)r[t]=0;return o=8*u,o=o.toString(16).match(/(.*?)(.{0,8})$/),i=parseInt(o[2],16),c=parseInt(o[1],16)||0,r[14]=i,r[15]=c,s(f,r),f},f=function(e){var t,n,r,o,i,a,u=e.length,f=[1732584193,-271733879,-1732584194,271733878];for(t=64;u>=t;t+=64)s(f,c(e.subarray(t-64,t)));for(e=u>t-64?e.subarray(t-64):new Uint8Array(0),n=e.length,r=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],t=0;n>t;t+=1)r[t>>2]|=e[t]<<(t%4<<3);if(r[t>>2]|=128<<(t%4<<3),t>55)for(s(f,r),t=0;16>t;t+=1)r[t]=0;return o=8*u,o=o.toString(16).match(/(.*?)(.{0,8})$/),i=parseInt(o[2],16),a=parseInt(o[1],16)||0,r[14]=i,r[15]=a,s(f,r),f},l=["0","1","2","3","4","5","6","7","8","9","a","b","c","d","e","f"],d=function(e){var t,n="";for(t=0;4>t;t+=1)n+=l[e>>8*t+4&15]+l[e>>8*t&15];return n},p=function(e){var t;for(t=0;t<e.length;t+=1)e[t]=d(e[t]);return e.join("")},h=function(e){return p(u(e))},v=function(){this.reset()};return"5d41402abc4b2a76b9719d911017c592"!==h("hello")&&(e=function(e,t){var n=(65535&e)+(65535&t),r=(e>>16)+(t>>16)+(n>>16);return r<<16|65535&n}),v.prototype.append=function(e){return/[\u0080-\uFFFF]/.test(e)&&(e=unescape(encodeURIComponent(e))),this.appendBinary(e),this},v.prototype.appendBinary=function(e){this._buff+=e,this._length+=e.length;var t,n=this._buff.length;for(t=64;n>=t;t+=64)s(this._state,a(this._buff.substring(t-64,t)));return this._buff=this._buff.substr(t-64),this},v.prototype.end=function(e){var t,n,r=this._buff,o=r.length,i=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0];for(t=0;o>t;t+=1)i[t>>2]|=r.charCodeAt(t)<<(t%4<<3);return this._finish(i,o),n=e?this._state:p(this._state),this.reset(),n},v.prototype._finish=function(e,t){var n,r,o,i=t;if(e[i>>2]|=128<<(i%4<<3),i>55)for(s(this._state,e),i=0;16>i;i+=1)e[i]=0;n=8*this._length,n=n.toString(16).match(/(.*?)(.{0,8})$/),r=parseInt(n[2],16),o=parseInt(n[1],16)||0,e[14]=r,e[15]=o,s(this._state,e)},v.prototype.reset=function(){return this._buff="",this._length=0,this._state=[1732584193,-271733879,-1732584194,271733878],this},v.prototype.destroy=function(){delete this._state,delete this._buff,delete this._length},v.hash=function(e,t){/[\u0080-\uFFFF]/.test(e)&&(e=unescape(encodeURIComponent(e)));var n=u(e);return t?n:p(n)},v.hashBinary=function(e,t){var n=u(e);return t?n:p(n)},v.ArrayBuffer=function(){this.reset()},v.ArrayBuffer.prototype.append=function(e){var t,n=this._concatArrayBuffer(this._buff,e),r=n.length;for(this._length+=e.byteLength,t=64;r>=t;t+=64)s(this._state,c(n.subarray(t-64,t)));return this._buff=r>t-64?n.subarray(t-64):new Uint8Array(0),this},v.ArrayBuffer.prototype.end=function(e){var t,n,r=this._buff,o=r.length,i=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0];for(t=0;o>t;t+=1)i[t>>2]|=r[t]<<(t%4<<3);return this._finish(i,o),n=e?this._state:p(this._state),this.reset(),n},v.ArrayBuffer.prototype._finish=v.prototype._finish,v.ArrayBuffer.prototype.reset=function(){return this._buff=new Uint8Array(0),this._length=0,this._state=[1732584193,-271733879,-1732584194,271733878],this},v.ArrayBuffer.prototype.destroy=v.prototype.destroy,v.ArrayBuffer.prototype._concatArrayBuffer=function(e,t){var n=e.length,r=new Uint8Array(n+t.byteLength);return r.set(e),r.set(new Uint8Array(t),n),r},v.ArrayBuffer.hash=function(e,t){var n=f(new Uint8Array(e));return t?n:p(n)},v})},{}],74:[function(e,t,n){"use strict";function r(e,t,n){var r=n[n.length-1];e===r.element&&(n.pop(),r=n[n.length-1]);var o=r.element,i=r.index;if(Array.isArray(o))o.push(e);else if(i===t.length-2){var s=t.pop();o[s]=e}else t.push(e)}n.stringify=function(e){var t=[];t.push({obj:e});for(var n,r,o,i,s,a,c,u,f,l,d,p="";n=t.pop();)if(r=n.obj,o=n.prefix||"",i=n.val||"",p+=o,i)p+=i;else if("object"!=typeof r)p+="undefined"==typeof r?null:JSON.stringify(r);else if(null===r)p+="null";else if(Array.isArray(r)){for(t.push({val:"]"}),s=r.length-1;s>=0;s--)a=0===s?"":",",t.push({obj:r[s],prefix:a});t.push({val:"["})}else{c=[];for(u in r)r.hasOwnProperty(u)&&c.push(u);for(t.push({val:"}"}),s=c.length-1;s>=0;s--)f=c[s],l=r[f],d=s>0?",":"",d+=JSON.stringify(f)+":",t.push({obj:l,prefix:d});t.push({val:"{"})}return p},n.parse=function(e){for(var t,n,o,i,s,a,c,u,f,l=[],d=[],p=0;;)if(t=e[p++],"}"!==t&&"]"!==t&&"undefined"!=typeof t)switch(t){case" ":case" ":case"\n":case":":case",":break;case"n":p+=3,r(null,l,d);break;case"t":p+=3,r(!0,l,d);break;case"f":p+=4,r(!1,l,d);break;case"0":case"1":case"2":case"3":case"4":case"5":case"6":case"7":case"8":case"9":case"-":for(n="",p--;;){if(o=e[p++],!/[\d\.\-e\+]/.test(o)){p--;break}n+=o}r(parseFloat(n),l,d);break;case'"':for(i="",s=void 0,a=0;;){if(c=e[p++],'"'===c&&("\\"!==s||a%2!==1))break;i+=c,s=c,"\\"===s?a++:a=0}r(JSON.parse('"'+i+'"'),l,d);break;case"[":u={element:[],index:l.length},l.push(u.element),d.push(u);break;case"{":f={element:{},index:l.length},l.push(f.element),d.push(f);break;default:throw new Error("unexpectedly reached end of input: "+t)}else{if(1===l.length)return l.pop();r(l.pop(),l,d)}}},{}],75:[function(e,t){(function(n){"use strict";var r=e(31);t.exports=r,r.ajax=e(16),r.utils=e(34),r.Errors=e(19),r.replicate=e(30).replicate,r.sync=e(32),r.version=e(35);var o=e(2);if(r.adapter("http",o),r.adapter("https",o),r.adapter("idb",e(7)),r.adapter("websql",e(12)),r.plugin(e(68)),!n.browser){var i=e(37);r.adapter("ldb",i),r.adapter("leveldb",i)}}).call(this,e(39))},{}]},{},[75])(75)});
@@ -0,0 +1,109 @@
1
+ require "spec_helper"
2
+
3
+ describe "Replication" do
4
+ let(:name) { "I'm a big boy now" }
5
+
6
+ describe "PouchDB.replicate" do
7
+ async "replicates passing names as Strings" do
8
+ with_new_database do |source|
9
+ with_new_database do |target|
10
+ stream = PouchDB.replicate(source.name, target.name)
11
+
12
+ synced = false
13
+
14
+ stream.on "change" do
15
+ target.get("my-calvins").then do |d|
16
+ synced = true
17
+ end
18
+ end
19
+
20
+ source.put(_id: "my-calvins", name: name)
21
+
22
+ delayed(1.0) do |p|
23
+ p.resolve(synced)
24
+ end.then do |s|
25
+ target.get("my-calvins").then do |doc|
26
+ async do
27
+ expect(doc["name"]).to eq(name)
28
+ end
29
+ end
30
+ end
31
+ end
32
+ end
33
+ end
34
+
35
+ async "replicates passing Databases" do
36
+ with_new_database do |source|
37
+ with_new_database do |target|
38
+ stream = PouchDB.replicate(source, target)
39
+
40
+ synced = false
41
+
42
+ stream.on "change" do
43
+ target.get("my-calvins").then do |d|
44
+ synced = true
45
+ end
46
+ end
47
+
48
+ source.put(_id: "my-calvins", name: name)
49
+
50
+ delayed(1.0) do |p|
51
+ p.resolve(synced)
52
+ end.then do |s|
53
+ target.get("my-calvins").then do |doc|
54
+ async do
55
+ expect(doc["name"]).to eq(name)
56
+ end
57
+ end
58
+ end
59
+ end
60
+ end
61
+ end
62
+ end
63
+
64
+ describe "PouchDB::Database#replicate" do
65
+ async "replicates to remote" do
66
+ with_new_database do |source|
67
+ with_new_database do |target|
68
+ stream = source.replicate.to(target.name)
69
+
70
+ source.put(_id: "my-calvins", name: name)
71
+
72
+ delayed(1.0) do |p|
73
+ p.resolve
74
+ end.then do |s|
75
+ target.get("my-calvins").then do |doc|
76
+ async do
77
+ expect(doc["name"]).to eq(name)
78
+ end
79
+ end
80
+ end.always do
81
+ stream.cancel
82
+ end
83
+ end
84
+ end
85
+ end
86
+
87
+ async "replicats from remote" do
88
+ with_new_database do |source|
89
+ with_new_database do |target|
90
+ stream = source.replicate.from(target.name)
91
+
92
+ target.put(_id: "my-calvins", name: name)
93
+
94
+ delayed(1.0) do |p|
95
+ p.resolve
96
+ end.then do |s|
97
+ source.get("my-calvins").then do |doc|
98
+ async do
99
+ expect(doc["name"]).to eq(name)
100
+ end
101
+ end
102
+ end.always do
103
+ stream.cancel
104
+ end
105
+ end
106
+ end
107
+ end
108
+ end
109
+ end
@@ -0,0 +1,32 @@
1
+ require "opal-rspec"
2
+ require "opal-pouchdb"
3
+
4
+ def with_new_database(add_failure_handler = true)
5
+ database_name = "test_opal_pouchdb_database-#{rand(1337)}-#{rand(7331)}"
6
+ promise = yield PouchDB::Database.new(name: database_name)
7
+
8
+ if add_failure_handler
9
+ promise = promise.fail do |error|
10
+ run_async do
11
+ fail error
12
+ end
13
+ end
14
+ end
15
+
16
+ promise.always do
17
+ destroy_database(database_name)
18
+ end
19
+ end
20
+
21
+ def destroy_database(name)
22
+ %x{
23
+ var db = new PouchDB(name);
24
+ db.destroy()
25
+ }
26
+ end
27
+
28
+ def delayed(delay_by, &blk)
29
+ promise = Promise.new
30
+ $global.setTimeout(-> { blk.call(promise) }, delay_by * 1000)
31
+ promise
32
+ end
@@ -0,0 +1,82 @@
1
+ require "spec_helper"
2
+
3
+ describe "Synchronization" do
4
+ let(:name) { "I'm a big boy now" }
5
+
6
+ describe "PouchDB.sync" do
7
+ async "performs bidirectional sync passing Strings" do
8
+ with_new_database do |source|
9
+ with_new_database do |target|
10
+ stream = PouchDB.sync(source.name, target.name)
11
+
12
+ source.put(_id: "my-calvins", name: name)
13
+ target.put(_id: "your-calvins", name: name)
14
+
15
+ delayed(1.0) do |p|
16
+ source.get("your-calvins").then do |d0|
17
+ target.get("my-calvins").then do |d1|
18
+ p.resolve([d0, d1])
19
+ end
20
+ end
21
+ end.then do |d0, d1|
22
+ async do
23
+ expect(d0["_id"]).to eq("your-calvins")
24
+ expect(d1["_id"]).to eq("my-calvins")
25
+ end
26
+ end
27
+ end
28
+ end
29
+ end
30
+
31
+ async "performs bidirectional sync passing Databases" do
32
+ with_new_database do |source|
33
+ with_new_database do |target|
34
+ stream = PouchDB.sync(source, target)
35
+
36
+ source.put(_id: "my-calvins", name: name)
37
+ target.put(_id: "your-calvins", name: name)
38
+
39
+ delayed(1.0) do |p|
40
+ source.get("your-calvins").then do |d0|
41
+ target.get("my-calvins").then do |d1|
42
+ p.resolve([d0, d1])
43
+ end
44
+ end
45
+ end.then do |d0, d1|
46
+ async do
47
+ expect(d0["_id"]).to eq("your-calvins")
48
+ expect(d1["_id"]).to eq("my-calvins")
49
+ end
50
+ end
51
+ end
52
+ end
53
+ end
54
+ end
55
+
56
+ describe "PouchDB::Database#sync" do
57
+ async "performs bidirectional sync" do
58
+ with_new_database do |source|
59
+ with_new_database do |target|
60
+ stream = source.sync(target)
61
+
62
+ source.put(_id: "my-calvins", name: name)
63
+ target.put(_id: "your-calvins", name: name)
64
+
65
+ delayed(1.0) do |p|
66
+ source.get("your-calvins").then do |d0|
67
+ target.get("my-calvins").then do |d1|
68
+ p.resolve([d0, d1])
69
+ end
70
+ end
71
+ end.then do |d0, d1|
72
+ async do
73
+ expect(d0["_id"]).to eq("your-calvins")
74
+ expect(d1["_id"]).to eq("my-calvins")
75
+ end
76
+ end
77
+ end
78
+ end
79
+ end
80
+
81
+ end
82
+ end
metadata ADDED
@@ -0,0 +1,139 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: opal-pouchdb
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.1
5
+ platform: ruby
6
+ authors:
7
+ - Vitor Capela
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-04-08 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: opal
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: 0.7.0
20
+ - - "<"
21
+ - !ruby/object:Gem::Version
22
+ version: 0.9.0
23
+ type: :runtime
24
+ prerelease: false
25
+ version_requirements: !ruby/object:Gem::Requirement
26
+ requirements:
27
+ - - ">="
28
+ - !ruby/object:Gem::Version
29
+ version: 0.7.0
30
+ - - "<"
31
+ - !ruby/object:Gem::Version
32
+ version: 0.9.0
33
+ - !ruby/object:Gem::Dependency
34
+ name: opal-rspec
35
+ requirement: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - "~>"
38
+ - !ruby/object:Gem::Version
39
+ version: 0.4.0
40
+ type: :development
41
+ prerelease: false
42
+ version_requirements: !ruby/object:Gem::Requirement
43
+ requirements:
44
+ - - "~>"
45
+ - !ruby/object:Gem::Version
46
+ version: 0.4.0
47
+ - !ruby/object:Gem::Dependency
48
+ name: yard
49
+ requirement: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - ">="
52
+ - !ruby/object:Gem::Version
53
+ version: '0'
54
+ type: :development
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ requirements:
58
+ - - ">="
59
+ - !ruby/object:Gem::Version
60
+ version: '0'
61
+ - !ruby/object:Gem::Dependency
62
+ name: rake
63
+ requirement: !ruby/object:Gem::Requirement
64
+ requirements:
65
+ - - ">="
66
+ - !ruby/object:Gem::Version
67
+ version: '0'
68
+ type: :development
69
+ prerelease: false
70
+ version_requirements: !ruby/object:Gem::Requirement
71
+ requirements:
72
+ - - ">="
73
+ - !ruby/object:Gem::Version
74
+ version: '0'
75
+ description: An Opal bridge to the PouchDB database library
76
+ email: dodecaphonic@gmail.com
77
+ executables: []
78
+ extensions: []
79
+ extra_rdoc_files: []
80
+ files:
81
+ - ".gitignore"
82
+ - ".travis.yml"
83
+ - Gemfile
84
+ - LICENSE
85
+ - README.md
86
+ - Rakefile
87
+ - config.ru
88
+ - lib/opal-pouchdb.rb
89
+ - lib/opal/pouchdb.rb
90
+ - lib/opal/pouchdb/version.rb
91
+ - opal-pouchdb.gemspec
92
+ - opal/opal-pouchdb.rb
93
+ - opal/pouchdb/all_documents.rb
94
+ - opal/pouchdb/conversion.rb
95
+ - opal/pouchdb/database.rb
96
+ - opal/pouchdb/event_emitter.rb
97
+ - opal/pouchdb/replication.rb
98
+ - opal/pouchdb/row.rb
99
+ - spec/database_events_spec.rb
100
+ - spec/database_spec.rb
101
+ - spec/pouchdb/es5-shim.min.js
102
+ - spec/pouchdb/index.html.erb
103
+ - spec/pouchdb/pouchdb.js
104
+ - spec/replication_spec.rb
105
+ - spec/spec_helper.rb
106
+ - spec/sync_spec.rb
107
+ homepage: https://github.com/dodecaphonic/opal-pouchdb
108
+ licenses: []
109
+ metadata: {}
110
+ post_install_message:
111
+ rdoc_options: []
112
+ require_paths:
113
+ - lib
114
+ required_ruby_version: !ruby/object:Gem::Requirement
115
+ requirements:
116
+ - - ">="
117
+ - !ruby/object:Gem::Version
118
+ version: '0'
119
+ required_rubygems_version: !ruby/object:Gem::Requirement
120
+ requirements:
121
+ - - ">="
122
+ - !ruby/object:Gem::Version
123
+ version: '0'
124
+ requirements: []
125
+ rubyforge_project:
126
+ rubygems_version: 2.4.5
127
+ signing_key:
128
+ specification_version: 4
129
+ summary: Opal bridge to PouchDB
130
+ test_files:
131
+ - spec/database_events_spec.rb
132
+ - spec/database_spec.rb
133
+ - spec/pouchdb/es5-shim.min.js
134
+ - spec/pouchdb/index.html.erb
135
+ - spec/pouchdb/pouchdb.js
136
+ - spec/replication_spec.rb
137
+ - spec/spec_helper.rb
138
+ - spec/sync_spec.rb
139
+ has_rdoc: