UNPKG

pouchdb

Version:

PouchDB is a pocket-sized database

8 lines 142 kB
// PouchDB 6.0.4 // // (c) 2012-2016 Dale Harvey and the PouchDB team // PouchDB may be freely distributed under the Apache license, version 2.0. // For all details and documentation: // http://pouchdb.com !function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var t;t="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this,t.PouchDB=e()}}(function(){var e;return function e(t,n,r){function o(s,a){if(!n[s]){if(!t[s]){var u="function"==typeof require&&require;if(!a&&u)return u(s,!0);if(i)return i(s,!0);var c=new Error("Cannot find module '"+s+"'");throw c.code="MODULE_NOT_FOUND",c}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,n){"use strict";function r(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=r},{}],2:[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?n.storage.removeItem("debug"):n.storage.debug=e}catch(e){}}function a(){var e;try{e=n.storage.debug}catch(e){}return e}function u(){try{return window.localStorage}catch(e){}}n=t.exports=e(3),n.log=i,n.formatArgs=o,n.save=s,n.load=a,n.useColors=r,n.storage="undefined"!=typeof chrome&&"undefined"!=typeof chrome.storage?chrome.storage.local:u(),n.colors=["lightseagreen","forestgreen","goldenrod","dodgerblue","darkorchid","crimson"],n.formatters.j=function(e){return JSON.stringify(e)},n.enable(a())},{3:3}],3:[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-(c||t);e.diff=i,e.prev=c,e.curr=t,c=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 u=o.log||n.log||console.log.bind(console);u.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;o<r;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;t<r;t++)if(n.skips[t].test(e))return!1;for(t=0,r=n.names.length;t<r;t++)if(n.names[t].test(e))return!0;return!1}function u(e){return e instanceof Error?e.stack||e.message:e}n=t.exports=o,n.coerce=u,n.disable=s,n.enable=i,n.enabled=a,n.humanize=e(10),n.names=[],n.skips=[],n.formatters={};var c,f=0},{10:10}],4:[function(t,n,r){!function(t,o){"function"==typeof e&&e.amd?e([],o):"object"==typeof r?n.exports=o():(t.PromisePool=o(),t.promisePool=t.PromisePool)}(this,function(){"use strict";var e=function(){this._listeners={}};e.prototype.addEventListener=function(e,t){this._listeners[e]=this._listeners[e]||[],this._listeners[e].indexOf(t)<0&&this._listeners[e].push(t)},e.prototype.removeEventListener=function(e,t){if(this._listeners[e]){var n=this._listeners[e].indexOf(t);n>=0&&this._listeners[e].splice(n,1)}},e.prototype.dispatchEvent=function(e){if(this._listeners[e.type]&&this._listeners[e.type].length)for(var t=this._listeners[e.type].slice(),n=0,r=t.length;n<r;++n)t[n].call(this,e)};var t=function(e){return"function"==typeof e.constructor&&"GeneratorFunction"===e.constructor.name},n=function(e){return{next:function(){var t=e();return t?{value:t}:{done:!0}}}},r=function(e){var t=!1;return{next:function(){return t?{done:!0}:(t=!0,{value:e})}}},o=function(e,o){var i=typeof e;if("object"===i){if("function"==typeof e.next)return e;if("function"==typeof e.then)return r(e)}return"function"===i?t(e)?e():n(e):r(o.resolve(e))},i=function(e,t,n){this.target=e,this.type=t,this.data=n},s=function(t,n,r){if(e.call(this),"number"!=typeof n||Math.floor(n)!==n||n<1)throw new Error("Invalid concurrency");this._concurrency=n,this._options=r||{},this._options.promise=this._options.promise||Promise,this._iterator=o(t,this._options.promise),this._done=!1,this._size=0,this._promise=null,this._callbacks=null};return s.prototype=new e,s.prototype.constructor=s,s.prototype.concurrency=function(e){return"undefined"!=typeof e&&(this._concurrency=e,this.active()&&this._proceed()),this._concurrency},s.prototype.size=function(){return this._size},s.prototype.active=function(){return!!this._promise},s.prototype.promise=function(){return this._promise},s.prototype.start=function(){var e=this,t=this._options.promise;return this._promise=new t(function(t,n){e._callbacks={reject:n,resolve:t},e._proceed()}),this._promise},s.prototype._fireEvent=function(e,t){this.dispatchEvent(new i(this,e,t))},s.prototype._settle=function(e){e?this._callbacks.reject(e):this._callbacks.resolve(),this._promise=null,this._callbacks=null},s.prototype._onPooledPromiseFulfilled=function(e,t){this._size--,this.active()&&(this._fireEvent("fulfilled",{promise:e,result:t}),this._proceed())},s.prototype._onPooledPromiseRejected=function(e,t){this._size--,this.active()&&(this._fireEvent("rejected",{promise:e,error:t}),this._settle(t||new Error("Unknown error")))},s.prototype._trackPromise=function(e){var t=this;e.then(function(n){t._onPooledPromiseFulfilled(e,n)},function(n){t._onPooledPromiseRejected(e,n)}).catch(function(e){t._settle(new Error("Promise processing failed: "+e))})},s.prototype._proceed=function(){if(!this._done){for(var e=null;this._size<this._concurrency&&!(e=this._iterator.next()).done;)this._size++,this._trackPromise(e.value);this._done=null===e||!!e.done}this._done&&0===this._size&&this._settle()},s.PromisePoolEvent=i,s.PromisePool=s,s})},{}],5:[function(e,t,n){function r(){this._events=this._events||{},this._maxListeners=this._maxListeners||void 0}function o(e){return"function"==typeof e}function i(e){return"number"==typeof e}function s(e){return"object"==typeof e&&null!==e}function a(e){return void 0===e}t.exports=r,r.EventEmitter=r,r.prototype._events=void 0,r.prototype._maxListeners=void 0,r.defaultMaxListeners=10,r.prototype.setMaxListeners=function(e){if(!i(e)||e<0||isNaN(e))throw TypeError("n must be a positive number");return this._maxListeners=e,this},r.prototype.emit=function(e){var t,n,r,i,u,c;if(this._events||(this._events={}),"error"===e&&(!this._events.error||s(this._events.error)&&!this._events.error.length)){if(t=arguments[1],t instanceof Error)throw t;var f=new Error('Uncaught, unspecified "error" event. ('+t+")");throw f.context=t,f}if(n=this._events[e],a(n))return!1;if(o(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:i=Array.prototype.slice.call(arguments,1),n.apply(this,i)}else if(s(n))for(i=Array.prototype.slice.call(arguments,1),c=n.slice(),r=c.length,u=0;u<r;u++)c[u].apply(this,i);return!0},r.prototype.addListener=function(e,t){var n;if(!o(t))throw TypeError("listener must be a function");return this._events||(this._events={}),this._events.newListener&&this.emit("newListener",e,o(t.listener)?t.listener:t),this._events[e]?s(this._events[e])?this._events[e].push(t):this._events[e]=[this._events[e],t]:this._events[e]=t,s(this._events[e])&&!this._events[e].warned&&(n=a(this._maxListeners)?r.defaultMaxListeners:this._maxListeners,n&&n>0&&this._events[e].length>n&&(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())),this},r.prototype.on=r.prototype.addListener,r.prototype.once=function(e,t){function n(){this.removeListener(e,n),r||(r=!0,t.apply(this,arguments))}if(!o(t))throw TypeError("listener must be a function");var r=!1;return n.listener=t,this.on(e,n),this},r.prototype.removeListener=function(e,t){var n,r,i,a;if(!o(t))throw TypeError("listener must be a function");if(!this._events||!this._events[e])return this;if(n=this._events[e],i=n.length,r=-1,n===t||o(n.listener)&&n.listener===t)delete this._events[e],this._events.removeListener&&this.emit("removeListener",e,t);else if(s(n)){for(a=i;a-- >0;)if(n[a]===t||n[a].listener&&n[a].listener===t){r=a;break}if(r<0)return this;1===n.length?(n.length=0,delete this._events[e]):n.splice(r,1),this._events.removeListener&&this.emit("removeListener",e,t)}return this},r.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],o(n))this.removeListener(e,n);else if(n)for(;n.length;)this.removeListener(e,n[n.length-1]);return delete this._events[e],this},r.prototype.listeners=function(e){var t;return t=this._events&&this._events[e]?o(this._events[e])?[this._events[e]]:this._events[e].slice():[]},r.prototype.listenerCount=function(e){if(this._events){var t=this._events[e];if(o(t))return 1;if(t)return t.length}return 0},r.listenerCount=function(e,t){return e.listenerCount(t)}},{}],6:[function(e,t,n){(function(e){"use strict";function n(){f=!0;for(var e,t,n=l.length;n;){for(t=l,l=[],e=-1;++e<n;)t[e]();n=l.length}f=!1}function r(e){1!==l.push(e)||f||o()}var o,i=e.MutationObserver||e.WebKitMutationObserver;if(i){var s=0,a=new i(n),u=e.document.createTextNode("");a.observe(u,{characterData:!0}),o=function(){u.data=s=++s%2}}else if(e.setImmediate||"undefined"==typeof e.MessageChannel)o="document"in e&&"onreadystatechange"in e.document.createElement("script")?function(){var t=e.document.createElement("script");t.onreadystatechange=function(){n(),t.onreadystatechange=null,t.parentNode.removeChild(t),t=null},e.document.documentElement.appendChild(t)}:function(){setTimeout(n,0)};else{var c=new e.MessageChannel;c.port1.onmessage=n,o=function(){c.port2.postMessage(0)}}var f,l=[];t.exports=r}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],7:[function(e,t,n){"function"==typeof Object.create?t.exports=function(e,t){e.super_=t,e.prototype=Object.create(t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}})}:t.exports=function(e,t){e.super_=t;var n=function(){};n.prototype=t.prototype,e.prototype=new n,e.prototype.constructor=e}},{}],8:[function(e,t,n){(function(e){e("object"==typeof n?n:this)}).call(this,function(e){var t=Array.prototype.slice,n=Array.prototype.forEach,r=function(e){if("object"!=typeof e)throw e+" is not an object";var o=t.call(arguments,1);return n.call(o,function(t){if(t)for(var n in t)"object"==typeof t[n]&&e[n]?r.call(e,e[n],t[n]):e[n]=t[n]}),e};e.extend=r})},{}],9:[function(e,t,n){"use strict";function r(){}function o(e){if("function"!=typeof e)throw new TypeError("resolver must be a function");this.state=m,this.queue=[],this.outcome=void 0,e!==r&&u(this,e)}function i(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)}function s(e,t,n){p(function(){var r;try{r=t(n)}catch(t){return v.reject(e,t)}r===e?v.reject(e,new TypeError("Cannot resolve promise with itself")):v.resolve(e,r)})}function a(e){var t=e&&e.then;if(e&&"object"==typeof e&&"function"==typeof t)return function(){t.apply(e,arguments)}}function u(e,t){function n(t){i||(i=!0,v.reject(e,t))}function r(t){i||(i=!0,v.resolve(e,t))}function o(){t(r,n)}var i=!1,s=c(o);"error"===s.status&&n(s.value)}function c(e,t){var n={};try{n.value=e(t),n.status="success"}catch(e){n.status="error",n.value=e}return n}function f(e){return e instanceof this?e:v.resolve(new this(r),e)}function l(e){var t=new this(r);return v.reject(t,e)}function d(e){function t(e,t){function r(e){s[t]=e,++a!==o||i||(i=!0,v.resolve(c,s))}n.resolve(e).then(r,function(e){i||(i=!0,v.reject(c,e))})}var n=this;if("[object Array]"!==Object.prototype.toString.call(e))return this.reject(new TypeError("must be an array"));var o=e.length,i=!1;if(!o)return this.resolve([]);for(var s=new Array(o),a=0,u=-1,c=new this(r);++u<o;)t(e[u],u);return c}function h(e){function t(e){n.resolve(e).then(function(e){i||(i=!0,v.resolve(a,e))},function(e){i||(i=!0,v.reject(a,e))})}var n=this;if("[object Array]"!==Object.prototype.toString.call(e))return this.reject(new TypeError("must be an array"));var o=e.length,i=!1;if(!o)return this.resolve([]);for(var s=-1,a=new this(r);++s<o;)t(e[s]);return a}var p=e(6),v={},y=["REJECTED"],_=["FULFILLED"],m=["PENDING"];t.exports=o,o.prototype.catch=function(e){return this.then(null,e)},o.prototype.then=function(e,t){if("function"!=typeof e&&this.state===_||"function"!=typeof t&&this.state===y)return this;var n=new this.constructor(r);if(this.state!==m){var o=this.state===_?e:t;s(n,o,this.outcome)}else this.queue.push(new i(n,e,t));return n},i.prototype.callFulfilled=function(e){v.resolve(this.promise,e)},i.prototype.otherCallFulfilled=function(e){s(this.promise,this.onFulfilled,e)},i.prototype.callRejected=function(e){v.reject(this.promise,e)},i.prototype.otherCallRejected=function(e){s(this.promise,this.onRejected,e)},v.resolve=function(e,t){var n=c(a,t);if("error"===n.status)return v.reject(e,n.value);var r=n.value;if(r)u(e,r);else{e.state=_,e.outcome=t;for(var o=-1,i=e.queue.length;++o<i;)e.queue[o].callFulfilled(t)}return e},v.reject=function(e,t){e.state=y,e.outcome=t;for(var n=-1,r=e.queue.length;++n<r;)e.queue[n].callRejected(t);return e},o.resolve=f,o.reject=l,o.all=d,o.race=h},{6:6}],10:[function(e,t,n){function r(e){if(e=""+e,!(e.length>1e4)){var t=/^((?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|years?|yrs?|y)?$/i.exec(e);if(t){var n=parseFloat(t[1]),r=(t[2]||"ms").toLowerCase();switch(r){case"years":case"year":case"yrs":case"yr":case"y":return n*l;case"days":case"day":case"d":return n*f;case"hours":case"hour":case"hrs":case"hr":case"h":return n*c;case"minutes":case"minute":case"mins":case"min":case"m":return n*u;case"seconds":case"second":case"secs":case"sec":case"s":return n*a;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return n}}}}function o(e){return e>=f?Math.round(e/f)+"d":e>=c?Math.round(e/c)+"h":e>=u?Math.round(e/u)+"m":e>=a?Math.round(e/a)+"s":e+"ms"}function i(e){return s(e,f,"day")||s(e,c,"hour")||s(e,u,"minute")||s(e,a,"second")||e+" ms"}function s(e,t,n){if(!(e<t))return e<1.5*t?Math.floor(e/t)+" "+n:Math.ceil(e/t)+" "+n+"s"}var a=1e3,u=60*a,c=60*u,f=24*c,l=365.25*f;t.exports=function(e,t){return t=t||{},"string"==typeof e?r(e):t.long?i(e):o(e)}},{}],11:[function(e,t,n){function r(){throw new Error("setTimeout has not been defined")}function o(){throw new Error("clearTimeout has not been defined")}function i(e){if(l===setTimeout)return setTimeout(e,0);if((l===r||!l)&&setTimeout)return l=setTimeout,setTimeout(e,0);try{return l(e,0)}catch(t){try{return l.call(null,e,0)}catch(t){return l.call(this,e,0)}}}function s(e){if(d===clearTimeout)return clearTimeout(e);if((d===o||!d)&&clearTimeout)return d=clearTimeout,clearTimeout(e);try{return d(e)}catch(t){try{return d.call(null,e)}catch(t){return d.call(this,e)}}}function a(){y&&p&&(y=!1,p.length?v=p.concat(v):_=-1,v.length&&u())}function u(){if(!y){var e=i(a);y=!0;for(var t=v.length;t;){for(p=v,v=[];++_<t;)p&&p[_].run();_=-1,t=v.length}p=null,y=!1,s(e)}}function c(e,t){this.fun=e,this.array=t}function f(){}var l,d,h=t.exports={};!function(){try{l="function"==typeof setTimeout?setTimeout:r}catch(e){l=r}try{d="function"==typeof clearTimeout?clearTimeout:o}catch(e){d=o}}();var p,v=[],y=!1,_=-1;h.nextTick=function(e){var t=new Array(arguments.length-1);if(arguments.length>1)for(var n=1;n<arguments.length;n++)t[n-1]=arguments[n];v.push(new c(e,t)),1!==v.length||y||i(u)},c.prototype.run=function(){this.fun.apply(null,this.array)},h.title="browser",h.browser=!0,h.env={},h.argv=[],h.version="",h.versions={},h.on=f,h.addListener=f,h.once=f,h.off=f,h.removeListener=f,h.removeAllListeners=f,h.emit=f,h.binding=function(e){throw new Error("process.binding is not supported")},h.cwd=function(){return"/"},h.chdir=function(e){throw new Error("process.chdir is not supported")},h.umask=function(){return 0}},{}],12:[function(e,t,n){(function(){var e={}.hasOwnProperty,n=[].slice;t.exports=function(t,r){var o,i,s,a;i=[],a=[];for(o in r)e.call(r,o)&&(s=r[o],"this"!==o&&(i.push(o),a.push(s)));return Function.apply(null,n.call(i).concat([t])).apply(r.this,a)}}).call(this)},{}],13:[function(t,n,r){!function(t){if("object"==typeof r)n.exports=t();else if("function"==typeof e&&e.amd)e(t);else{var o;try{o=window}catch(e){o=self}o.SparkMD5=t()}}(function(e){"use strict";function t(e,t,n,r,o,i){return t=g(g(t,e),g(r,i)),g(t<<o|t>>>32-o,n)}function n(e,n,r,o,i,s,a){return t(n&r|~n&o,e,n,i,s,a)}function r(e,n,r,o,i,s,a){return t(n&o|r&~o,e,n,i,s,a)}function o(e,n,r,o,i,s,a){return t(n^r^o,e,n,i,s,a)}function i(e,n,r,o,i,s,a){return t(r^(n|~o),e,n,i,s,a)}function s(e,t){var s=e[0],a=e[1],u=e[2],c=e[3];s=n(s,a,u,c,t[0],7,-680876936),c=n(c,s,a,u,t[1],12,-389564586),u=n(u,c,s,a,t[2],17,606105819),a=n(a,u,c,s,t[3],22,-1044525330),s=n(s,a,u,c,t[4],7,-176418897),c=n(c,s,a,u,t[5],12,1200080426),u=n(u,c,s,a,t[6],17,-1473231341),a=n(a,u,c,s,t[7],22,-45705983),s=n(s,a,u,c,t[8],7,1770035416),c=n(c,s,a,u,t[9],12,-1958414417),u=n(u,c,s,a,t[10],17,-42063),a=n(a,u,c,s,t[11],22,-1990404162),s=n(s,a,u,c,t[12],7,1804603682),c=n(c,s,a,u,t[13],12,-40341101),u=n(u,c,s,a,t[14],17,-1502002290),a=n(a,u,c,s,t[15],22,1236535329),s=r(s,a,u,c,t[1],5,-165796510),c=r(c,s,a,u,t[6],9,-1069501632),u=r(u,c,s,a,t[11],14,643717713),a=r(a,u,c,s,t[0],20,-373897302),s=r(s,a,u,c,t[5],5,-701558691),c=r(c,s,a,u,t[10],9,38016083),u=r(u,c,s,a,t[15],14,-660478335),a=r(a,u,c,s,t[4],20,-405537848),s=r(s,a,u,c,t[9],5,568446438),c=r(c,s,a,u,t[14],9,-1019803690),u=r(u,c,s,a,t[3],14,-187363961),a=r(a,u,c,s,t[8],20,1163531501),s=r(s,a,u,c,t[13],5,-1444681467),c=r(c,s,a,u,t[2],9,-51403784),u=r(u,c,s,a,t[7],14,1735328473),a=r(a,u,c,s,t[12],20,-1926607734),s=o(s,a,u,c,t[5],4,-378558),c=o(c,s,a,u,t[8],11,-2022574463),u=o(u,c,s,a,t[11],16,1839030562),a=o(a,u,c,s,t[14],23,-35309556),s=o(s,a,u,c,t[1],4,-1530992060),c=o(c,s,a,u,t[4],11,1272893353),u=o(u,c,s,a,t[7],16,-155497632),a=o(a,u,c,s,t[10],23,-1094730640),s=o(s,a,u,c,t[13],4,681279174),c=o(c,s,a,u,t[0],11,-358537222),u=o(u,c,s,a,t[3],16,-722521979),a=o(a,u,c,s,t[6],23,76029189),s=o(s,a,u,c,t[9],4,-640364487),c=o(c,s,a,u,t[12],11,-421815835),u=o(u,c,s,a,t[15],16,530742520),a=o(a,u,c,s,t[2],23,-995338651),s=i(s,a,u,c,t[0],6,-198630844),c=i(c,s,a,u,t[7],10,1126891415),u=i(u,c,s,a,t[14],15,-1416354905),a=i(a,u,c,s,t[5],21,-57434055),s=i(s,a,u,c,t[12],6,1700485571),c=i(c,s,a,u,t[3],10,-1894986606),u=i(u,c,s,a,t[10],15,-1051523),a=i(a,u,c,s,t[1],21,-2054922799),s=i(s,a,u,c,t[8],6,1873313359),c=i(c,s,a,u,t[15],10,-30611744),u=i(u,c,s,a,t[6],15,-1560198380),a=i(a,u,c,s,t[13],21,1309151649),s=i(s,a,u,c,t[4],6,-145523070),c=i(c,s,a,u,t[11],10,-1120210379),u=i(u,c,s,a,t[2],15,718787259),a=i(a,u,c,s,t[9],21,-343485551),e[0]=g(s,e[0]),e[1]=g(a,e[1]),e[2]=g(u,e[2]),e[3]=g(c,e[3])}function a(e){var t,n=[];for(t=0;t<64;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}function u(e){var t,n=[];for(t=0;t<64;t+=4)n[t>>2]=e[t]+(e[t+1]<<8)+(e[t+2]<<16)+(e[t+3]<<24);return n}function c(e){var t,n,r,o,i,u,c=e.length,f=[1732584193,-271733879,-1732584194,271733878];for(t=64;t<=c;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;t<n;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;t<16;t+=1)r[t]=0;return o=8*c,o=o.toString(16).match(/(.*?)(.{0,8})$/),i=parseInt(o[2],16),u=parseInt(o[1],16)||0,r[14]=i,r[15]=u,s(f,r),f}function f(e){var t,n,r,o,i,a,c=e.length,f=[1732584193,-271733879,-1732584194,271733878];for(t=64;t<=c;t+=64)s(f,u(e.subarray(t-64,t)));for(e=t-64<c?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;t<n;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;t<16;t+=1)r[t]=0;return o=8*c,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}function l(e){var t,n="";for(t=0;t<4;t+=1)n+=b[e>>8*t+4&15]+b[e>>8*t&15];return n}function d(e){var t;for(t=0;t<e.length;t+=1)e[t]=l(e[t]);return e.join("")}function h(e){return/[\u0080-\uFFFF]/.test(e)&&(e=unescape(encodeURIComponent(e))),e}function p(e,t){var n,r=e.length,o=new ArrayBuffer(r),i=new Uint8Array(o);for(n=0;n<r;n+=1)i[n]=e.charCodeAt(n);return t?i:o}function v(e){return String.fromCharCode.apply(null,new Uint8Array(e))}function y(e,t,n){var r=new Uint8Array(e.byteLength+t.byteLength);return r.set(new Uint8Array(e)),r.set(new Uint8Array(t),e.byteLength),n?r:r.buffer}function _(e){var t,n=[],r=e.length;for(t=0;t<r-1;t+=2)n.push(parseInt(e.substr(t,2),16));return String.fromCharCode.apply(String,n)}function m(){this.reset()}var g=function(e,t){return e+t&4294967295},b=["0","1","2","3","4","5","6","7","8","9","a","b","c","d","e","f"];return"5d41402abc4b2a76b9719d911017c592"!==d(c("hello"))&&(g=function(e,t){var n=(65535&e)+(65535&t),r=(e>>16)+(t>>16)+(n>>16);return r<<16|65535&n}),"undefined"==typeof ArrayBuffer||ArrayBuffer.prototype.slice||!function(){function t(e,t){return e=0|e||0,e<0?Math.max(e+t,0):Math.min(e,t)}ArrayBuffer.prototype.slice=function(n,r){var o,i,s,a,u=this.byteLength,c=t(n,u),f=u;return r!==e&&(f=t(r,u)),c>f?new ArrayBuffer(0):(o=f-c,i=new ArrayBuffer(o),s=new Uint8Array(i),a=new Uint8Array(this,c,o),s.set(a),i)}}(),m.prototype.append=function(e){return this.appendBinary(h(e)),this},m.prototype.appendBinary=function(e){this._buff+=e,this._length+=e.length;var t,n=this._buff.length;for(t=64;t<=n;t+=64)s(this._hash,a(this._buff.substring(t-64,t)));return this._buff=this._buff.substring(t-64),this},m.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;t<o;t+=1)i[t>>2]|=r.charCodeAt(t)<<(t%4<<3);return this._finish(i,o),n=d(this._hash),e&&(n=_(n)),this.reset(),n},m.prototype.reset=function(){return this._buff="",this._length=0,this._hash=[1732584193,-271733879,-1732584194,271733878],this},m.prototype.getState=function(){return{buff:this._buff,length:this._length,hash:this._hash}},m.prototype.setState=function(e){return this._buff=e.buff,this._length=e.length,this._hash=e.hash,this},m.prototype.destroy=function(){delete this._hash,delete this._buff,delete this._length},m.prototype._finish=function(e,t){var n,r,o,i=t;if(e[i>>2]|=128<<(i%4<<3),i>55)for(s(this._hash,e),i=0;i<16;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._hash,e)},m.hash=function(e,t){return m.hashBinary(h(e),t)},m.hashBinary=function(e,t){var n=c(e),r=d(n);return t?_(r):r},m.ArrayBuffer=function(){this.reset()},m.ArrayBuffer.prototype.append=function(e){var t,n=y(this._buff.buffer,e,!0),r=n.length;for(this._length+=e.byteLength,t=64;t<=r;t+=64)s(this._hash,u(n.subarray(t-64,t)));return this._buff=t-64<r?new Uint8Array(n.buffer.slice(t-64)):new Uint8Array(0),this},m.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;t<o;t+=1)i[t>>2]|=r[t]<<(t%4<<3);return this._finish(i,o),n=d(this._hash),e&&(n=_(n)),this.reset(),n},m.ArrayBuffer.prototype.reset=function(){return this._buff=new Uint8Array(0),this._length=0,this._hash=[1732584193,-271733879,-1732584194,271733878],this},m.ArrayBuffer.prototype.getState=function(){var e=m.prototype.getState.call(this);return e.buff=v(e.buff),e},m.ArrayBuffer.prototype.setState=function(e){return e.buff=p(e.buff,!0),m.prototype.setState.call(this,e)},m.ArrayBuffer.prototype.destroy=m.prototype.destroy,m.ArrayBuffer.prototype._finish=m.prototype._finish,m.ArrayBuffer.hash=function(e,t){var n=f(new Uint8Array(e)),r=d(n);return t?_(r):r},m})},{}],14:[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,u,c,f,l,d,h="";n=t.pop();)if(r=n.obj,o=n.prefix||"",i=n.val||"",h+=o,i)h+=i;else if("object"!=typeof r)h+="undefined"==typeof r?null:JSON.stringify(r);else if(null===r)h+="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{u=[];for(c in r)r.hasOwnProperty(c)&&u.push(c);for(t.push({val:"}"}),s=u.length-1;s>=0;s--)f=u[s],l=r[f],d=s>0?",":"",d+=JSON.stringify(f)+":",t.push({obj:l,prefix:d});t.push({val:"{"})}return h},n.parse=function(e){for(var t,n,o,i,s,a,u,c,f,l=[],d=[],h=0;;)if(t=e[h++],"}"!==t&&"]"!==t&&"undefined"!=typeof t)switch(t){case" ":case"\t":case"\n":case":":case",":break;case"n":h+=3,r(null,l,d);break;case"t":h+=3,r(!0,l,d);break;case"f":h+=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="",h--;;){if(o=e[h++],!/[\d\.\-e\+]/.test(o)){h--;break}n+=o}r(parseFloat(n),l,d);break;case'"':for(i="",s=void 0,a=0;;){if(u=e[h++],'"'===u&&("\\"!==s||a%2!==1))break;i+=u,s=u,"\\"===s?a++:a=0}r(JSON.parse('"'+i+'"'),l,d);break;case"[":c={element:[],index:l.length},l.push(c.element),d.push(c);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)}}},{}],15:[function(e,t,n){(function(n,r){"use strict";function o(e){return e&&"object"==typeof e&&"default"in e?e.default:e}function i(e){return"$"+e}function s(e){return e.substring(1)}function a(){this.store={}}function u(e){if(this.store=new a,e&&Array.isArray(e))for(var t=0,n=e.length;t<n;t++)this.add(e[t])}function c(e){return"undefined"!=typeof ArrayBuffer&&e instanceof ArrayBuffer||"undefined"!=typeof Blob&&e instanceof Blob}function f(e){if("function"==typeof e.slice)return e.slice(0);var t=new ArrayBuffer(e.byteLength),n=new Uint8Array(t),r=new Uint8Array(e);return n.set(r),t}function l(e){if(e instanceof ArrayBuffer)return f(e);var t=e.size,n=e.type;return"function"==typeof e.slice?e.slice(0,t,n):e.webkitSlice(0,t,n)}function d(e){var t=Object.getPrototypeOf(e);if(null===t)return!0;var n=t.constructor;return"function"==typeof n&&n instanceof n&&Vr.call(n)==Qr}function h(e){var t,n,r;if(!e||"object"!=typeof e)return e;if(Array.isArray(e)){for(t=[],n=0,r=e.length;n<r;n++)t[n]=h(e[n]);return t}if(e instanceof Date)return e.toISOString();if(c(e))return l(e);if(!d(e))return e;t={};for(n in e)if(Object.prototype.hasOwnProperty.call(e,n)){var o=h(e[n]);"undefined"!=typeof o&&(t[n]=o)}return t}function p(e){var t=!1;return Hr(function(n){if(t)throw new Error("once called more than once");t=!0,e.apply(this,n)})}function v(e){return Hr(function(t){t=h(t);var r,o=this,i="function"==typeof t[t.length-1]&&t.pop();i&&(r=function(e,t){n.nextTick(function(){i(e,t)})});var s=new Xr(function(n,r){var i;try{var s=p(function(e,t){e?r(e):n(t)});t.push(s),i=e.apply(o,t),i&&"function"==typeof i.then&&n(i)}catch(e){r(e)}});return r&&s.then(function(e){r(null,e)},r),s})}function y(e,t){function n(e,t,n){if($r.enabled){for(var r=[e.name,t],o=0;o<n.length-1;o++)r.push(n[o]);$r.apply(null,r);var i=n[n.length-1];n[n.length-1]=function(n,r){var o=[e.name,t];o=o.concat(n?["error",n]:["success",r]),$r.apply(null,o),i(n,r)}}}return v(Hr(function(r){if(this._closed)return Xr.reject(new Error("database is closed"));if(this._destroyed)return Xr.reject(new Error("database is destroyed"));var o=this;return n(o,e,r),this.taskqueue.isReady?t.apply(this,r):new Xr(function(t,n){o.taskqueue.addTask(function(i){i?n(i):t(o[e].apply(o,r))})})}))}function _(e,t){for(var n={},r=0,o=t.length;r<o;r++){var i=t[r];i in e&&(n[i]=e[i])}return n}function m(e){return e}function g(e){return[{ok:e}]}function b(e,t,n){function r(){var e=[];d.forEach(function(t){t.docs.forEach(function(n){e.push({id:t.id,docs:[n]})})}),n(null,{results:e})}function o(){++l===f&&r()}function i(e,t,n){d[e]={id:t,docs:n},o()}function s(){if(!(p>=h.length)){var e=Math.min(p+Yr,h.length),t=h.slice(p,e);a(t,p),p+=t.length}}function a(n,r){n.forEach(function(n,o){var a=r+o,u=c[n],f=_(u[0],["atts_since","attachments"]);f.open_revs=u.map(function(e){return e.rev}),f.open_revs=f.open_revs.filter(m);var l=m;0===f.open_revs.length&&(delete f.open_revs,l=g),["revs","attachments","binary","ajax"].forEach(function(e){e in t&&(f[e]=t[e])}),e.get(n,f,function(e,t){var r;r=e?[{error:e}]:l(t),i(a,n,r),s()})})}var u=t.docs,c={};u.forEach(function(e){e.id in c?c[e.id].push(e):c[e.id]=[e]});var f=Object.keys(c).length,l=0,d=new Array(f),h=Object.keys(c),p=0;s()}function w(){return"undefined"!=typeof chrome&&"undefined"!=typeof chrome.storage&&"undefined"!=typeof chrome.storage.local}function E(){return Gr}function k(e){w()?chrome.storage.onChanged.addListener(function(t){null!=t.db_name&&e.emit(t.dbName.newValue)}):E()&&("undefined"!=typeof addEventListener?addEventListener("storage",function(t){e.emit(t.key)}):window.attachEvent("storage",function(t){e.emit(t.key)}))}function S(){Mr.EventEmitter.call(this),this._listeners={},k(this)}function q(e){if("undefined"!==console&&e in console){var t=Array.prototype.slice.call(arguments,1);console[e].apply(console,t)}}function x(e,t){var n=6e5;e=parseInt(e,10)||0,t=parseInt(t,10),t!==t||t<=e?t=(e||1)<<1:t+=1,t>n&&(e=n>>1,t=n);var r=Math.random(),o=t-e;return~~(o*r+e)}function A(e){var t=0;return e||(t=2e3),x(e,t)}function T(e,t){q("info","The above "+e+" is totally normal. "+t)}function O(e){Error.call(this,e.reason),this.status=e.status,this.name=e.error,this.message=e.reason,this.error=!0}function j(e,t){function n(t){for(var n in e)"function"!=typeof e[n]&&(this[n]=e[n]);void 0!==t&&(this.reason=t)}return n.prototype=O.prototype,new n(t)}function C(e){if("object"!=typeof e){var t=e;e=so,e.data=t}return"error"in e&&"conflict"===e.error&&(e.name="conflict",e.status=409),"name"in e||(e.name=e.error||"unknown"),"status"in e||(e.status=500),"message"in e||(e.message=e.message||e.reason),e}function L(e,t,n){try{return!e(t,n)}catch(e){var r="Filter function threw: "+e.toString();return j(fo,r)}}function I(e){var t={},n=e.filter&&"function"==typeof e.filter;return t.query=e.query_params,function(r){r.doc||(r.doc={});var o=n&&L(e.filter,r.doc,t);if("object"==typeof o)return o;if(o)return!1;if(e.include_docs){if(!e.attachments)for(var i in r.doc._attachments)r.doc._attachments.hasOwnProperty(i)&&(r.doc._attachments[i].stub=!0)}else delete r.doc;return!0}}function R(e){for(var t=[],n=0,r=e.length;n<r;n++)t=t.concat(e[n]);return t}function D(e){var t;if(e?"string"!=typeof e?t=j(no):/^_/.test(e)&&!/^_(design|local)/.test(e)&&(t=j(oo)):t=j(ro), t)throw t}function N(e,t){return"listenerCount"in e?e.listenerCount(t):Mr.EventEmitter.listenerCount(e,t)}function B(e){if(!e)return null;var t=e.split("/");return 2===t.length?t:1===t.length?[e,e]:null}function F(e){var t=B(e);return t?t.join("/"):null}function P(e){for(var t=bo.exec(e),n={},r=14;r--;){var o=_o[r],i=t[r]||"",s=["user","password"].indexOf(o)!==-1;n[o]=s?decodeURIComponent(i):i}return n[mo]={},n[_o[12]].replace(go,function(e,t,r){t&&(n[mo][t]=r)}),n}function U(e,t,n){return new Xr(function(r,o){e.get(t,function(i,s){if(i){if(404!==i.status)return o(i);s={}}var a=s._rev,u=n(s);return u?(u._id=t,u._rev=a,void r(M(e,u,n))):r({updated:!1,rev:a})})})}function M(e,t,n){return e.put(t).then(function(e){return{updated:!0,rev:e.rev}},function(r){if(409!==r.status)throw r;return U(e,t._id,n)})}function H(e){return 0|Math.random()*e}function W(e,t){t=t||wo.length;var n="",r=-1;if(e){for(;++r<e;)n+=wo[H(t)];return n}for(;++r<36;)switch(r){case 8:case 13:case 18:case 23:n+="-";break;case 19:n+=wo[3&H(16)|8];break;default:n+=wo[H(16)]}return n}function J(e){for(var t,n,r,o,i=e.rev_tree.slice();o=i.pop();){var s=o.ids,a=s[2],u=o.pos;if(a.length)for(var c=0,f=a.length;c<f;c++)i.push({pos:u+1,ids:a[c]});else{var l=!!s[1].deleted,d=s[0];t&&!(r!==l?r:n!==u?n<u:t<d)||(t=d,n=u,r=l)}}return n+"-"+t}function K(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]),u=0,c=s.length;u<c;u++)r.push({pos:o+1,ids:s[u],ctx:a})}function z(e,t){return e.pos-t.pos}function X(e){var t=[];K(e,function(e,n,r,o,i){e&&t.push({rev:n+"-"+r,pos:n,opts:i})}),t.sort(z).reverse();for(var n=0,r=t.length;n<r;n++)delete t[n].pos;return t}function G(e){for(var t=J(e),n=X(e.rev_tree),r=[],o=0,i=n.length;o<i;o++){var s=n[o];s.rev===t||s.opts.deleted||r.push(s.rev)}return r}function V(e){var t=[];return K(e.rev_tree,function(e,n,r,o,i){"available"!==i.status||e||(t.push(n+"-"+r),i.status="missing")}),t}function Q(e){for(var t,n=[],r=e.slice();t=r.pop();){var o=t.pos,i=t.ids,s=i[0],a=i[1],u=i[2],c=0===u.length,f=t.history?t.history.slice():[];f.push({id:s,opts:a}),c&&n.push({pos:o+1-f.length,ids:f});for(var l=0,d=u.length;l<d;l++)r.push({pos:o+1,ids:u[l],history:f})}return n.reverse()}function $(e,t){return e.pos-t.pos}function Y(e,t,n){for(var r,o=0,i=e.length;o<i;)r=o+i>>>1,n(e[r],t)<0?o=r+1:i=r;return o}function Z(e,t,n){var r=Y(e,t,n);e.splice(r,0,t)}function ee(e,t){for(var n,r,o=t,i=e.length;o<i;o++){var s=e[o],a=[s.id,s.opts,[]];r?(r[2].push(a),r=a):n=r=a}return n}function te(e,t){return e[0]<t[0]?-1:1}function ne(e,t){for(var n=[{tree1:e,tree2:t}],r=!1;n.length>0;){var o=n.pop(),i=o.tree1,s=o.tree2;(i[1].status||s[1].status)&&(i[1].status="available"===i[1].status||"available"===s[1].status?"available":"missing");for(var a=0;a<s[2].length;a++)if(i[2][0]){for(var u=!1,c=0;c<i[2].length;c++)i[2][c][0]===s[2][a][0]&&(n.push({tree1:i[2][c],tree2:s[2][a]}),u=!0);u||(r="new_branch",Z(i[2],s[2][a],te))}else r="new_leaf",i[2][0]=s[2][a]}return{conflicts:r,tree:e}}function re(e,t,n){var r,o=[],i=!1,s=!1;if(!e.length)return{tree:[t],conflicts:"new_leaf"};for(var a=0,u=e.length;a<u;a++){var c=e[a];if(c.pos===t.pos&&c.ids[0]===t.ids[0])r=ne(c.ids,t.ids),o.push({pos:c.pos,ids:r.tree}),i=i||r.conflicts,s=!0;else if(n!==!0){var f=c.pos<t.pos?c:t,l=c.pos<t.pos?t:c,d=l.pos-f.pos,h=[],p=[];for(p.push({ids:f.ids,diff:d,parent:null,parentIdx:null});p.length>0;){var v=p.pop();if(0!==v.diff)for(var y=v.ids[2],_=0,m=y.length;_<m;_++)p.push({ids:y[_],diff:v.diff-1,parent:v.ids,parentIdx:_});else v.ids[0]===l.ids[0]&&h.push(v)}var g=h[0];g?(r=ne(g.ids,l.ids),g.parent[2][g.parentIdx]=r.tree,o.push({pos:f.pos,ids:f.ids}),i=i||r.conflicts,s=!0):o.push(c)}else o.push(c)}return s||o.push(t),o.sort($),{tree:o,conflicts:i||"internal_node"}}function oe(e,t){for(var n,r=Q(e),o={},i=0,s=r.length;i<s;i++){for(var a=r[i],u=a.ids,c=Math.max(0,u.length-t),f={pos:a.pos+c,ids:ee(u,c)},l=0;l<c;l++){var d=a.pos+l+"-"+u[l].id;o[d]=!0}n=n?re(n,f,!0).tree:[f]}return K(n,function(e,t,n){delete o[t+"-"+n]}),{tree:n,revs:Object.keys(o)}}function ie(e,t,n){var r=re(e,t),o=oe(r.tree,n);return{tree:o.tree,stemmedRevs:o.revs,conflicts:r.conflicts}}function se(e,t){for(var n,r=e.slice(),o=t.split("-"),i=parseInt(o[0],10),s=o[1];n=r.pop();){if(n.pos===i&&n.ids[0]===s)return!0;for(var a=n.ids[2],u=0,c=a.length;u<c;u++)r.push({pos:n.pos+1,ids:a[u]})}return!1}function ae(e){return e.ids}function ue(e,t){t||(t=J(e));for(var n,r=t.substring(t.indexOf("-")+1),o=e.rev_tree.map(ae);n=o.pop();){if(n[0]===r)return!!n[1].deleted;o=o.concat(n[2])}}function ce(e){return/^_local/.test(e)}function fe(e){return Wr('"use strict";\nreturn '+e+";",{})}function le(e){var t=["return function(doc) {",' "use strict";'," var emitted = false;"," var emit = function (a, b) {"," emitted = true;"," };"," var view = "+e+";"," view(doc);"," if (emitted) {"," return true;"," }","};"].join("\n");return Wr(t,{})}function de(e,t){try{e.emit("change",t)}catch(e){q("error",'Error in .on("change", function):',e)}}function he(e,t,n){function r(){o.cancel()}Mr.EventEmitter.call(this);var o=this;this.db=e,t=t?h(t):{};var i=t.complete=p(function(t,n){t?N(o,"error")>0&&o.emit("error",t):o.emit("complete",n),o.removeAllListeners(),e.removeListener("destroyed",r)});n&&(o.on("complete",function(e){n(null,e)}),o.on("error",n)),e.once("destroyed",r),t.onChange=function(e){t.isCancelled||de(o,e)};var s=new Xr(function(e,n){t.complete=function(t,r){t?n(t):e(r)}});o.once("cancel",function(){e.removeListener("destroyed",r),t.complete(null,{status:"cancelled"})}),this.then=s.then.bind(s),this.catch=s.catch.bind(s),this.then(function(e){i(null,e)},i),e.taskqueue.isReady?o.doChanges(t):e.taskqueue.addTask(function(e){e?t.complete(e):o.isCancelled?o.emit("cancel"):o.doChanges(t)})}function pe(e,t,n){var r=[{rev:e._rev}];"all_docs"===n.style&&(r=X(t.rev_tree).map(function(e){return{rev:e.rev}}));var o={id:t.id,changes:r,doc:e};return ue(t,e._rev)&&(o.deleted=!0),n.conflicts&&(o.doc._conflicts=G(t),o.doc._conflicts.length||delete o.doc._conflicts),o}function ve(e,t){return e<t?-1:e>t?1:0}function ye(e,t){for(var n=0;n<e.length;n++)if(t(e[n],n)===!0)return e[n]}function _e(e){return function(t,n){t||n[0]&&n[0].error?e(t||n[0]):e(null,n.length?n[0]:n)}}function me(e){for(var t=0;t<e.length;t++){var n=e[t];if(n._deleted)delete n._attachments;else if(n._attachments)for(var r=Object.keys(n._attachments),o=0;o<r.length;o++){var i=r[o];n._attachments[i]=_(n._attachments[i],["data","digest","content_type","length","revpos","stub"])}}}function ge(e,t){var n=ve(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 ve(r,o)}function be(e){var t={},n=[];return K(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){void 0===t[e.from]?t[e.from]=1+t[e.to]:t[e.from]=Math.min(t[e.from],1+t[e.to])}),t}function we(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 Xr.all(r.map(function(n){var r=Br.extend({key:n,deleted:"ok"},t);return["limit","skip","keys"].forEach(function(e){delete r[e]}),new Xr(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 Ee(e){var t=e._compactionQueue[0],r=t.opts,o=t.callback;e.get("_local/compaction").catch(function(){return!1}).then(function(t){t&&t.last_seq&&(r.last_seq=t.last_seq),e._compact(r,function(t,r){t?o(t):o(null,r),n.nextTick(function(){e._compactionQueue.shift(),e._compactionQueue.length&&Ee(e)})})})}function ke(e){return"_"===e.charAt(0)&&e+"is not a valid attachment name, attachment names cannot start with '_'"}function Se(){Mr.EventEmitter.call(this)}function qe(){this.isReady=!1,this.failed=!1,this.queue=[]}function xe(e,t){var n=e.match(/([a-z\-]*):\/\/(.*)/);if(n)return e=/http(s?)/.test(n[1])?n[1]+"://"+n[2]:n[2],{name:e,adapter:n[1]};var r,o="idb"in Te.adapters&&"websql"in Te.adapters&&E()&&localStorage["_pouch__websqldb_"+Te.prefix+e];if(t.adapter)r=t.adapter;else if("undefined"!=typeof t&&t.db)r="leveldb";else for(var i=0;i<Te.preferredAdapters.length;++i){r=Te.preferredAdapters[i];{if(!o||"idb"!==r)break;q("log",'PouchDB is downgrading "'+e+'" to WebSQL to avoid data loss, because it was already opened with WebSQL.')}}var s=Te.adapters[r],a=!(s&&"use_prefix"in s)||s.use_prefix;return{name:a?Te.prefix+e:e,adapter:r}}function Ae(e){function t(){e.constructor.emit("destroyed",e.name)}function n(){e.removeListener("destroyed",t),e.emit("destroyed",e)}var r=e.constructor._destructionListeners;e.once("destroyed",t),r.has(e.name)||r.set(e.name,[]),r.get(e.name).push(n)}function Te(e,t){if(!(this instanceof Te))return new Te(e,t);var n=this;if(t=t||{},e&&"object"==typeof e&&(t=e,e=t.name,delete t.name),this.__opts=t=h(t),n.auto_compaction=t.auto_compaction,n.prefix=Te.prefix,"string"!=typeof e)throw new Error("Missing/invalid DB name");var r=(t.prefix||"")+e,o=xe(r,t);if(t.name=o.name,t.adapter=t.adapter||o.adapter,n.name=e,n._adapter=t.adapter,Fr("pouchdb:adapter")("Picked adapter: "+t.adapter),!Te.adapters[t.adapter]||!Te.adapters[t.adapter].valid())throw new Error("Invalid Adapter: "+t.adapter);Se.call(n),n.taskqueue=new qe,n.adapter=t.adapter,Te.adapters[t.adapter].call(n,t,function(e){return e?n.taskqueue.fail(e):(Ae(n),n.emit("created",n),Te.emit("created",n.name),void n.taskqueue.ready(n))})}function Oe(e){Object.keys(Mr.EventEmitter.prototype).forEach(function(t){"function"==typeof Mr.EventEmitter.prototype[t]&&(e[t]=Eo[t].bind(Eo))});var t=e._destructionListeners=new a;e.on("destroyed",function(e){t.get(e).forEach(function(e){e()}),t.delete(e)})}function je(e){return e.reduce(function(e,t){return e[t]=!0,e},{})}function Ce(e){if(!/^\d+\-./.test(e))return j(vo);var t=e.indexOf("-"),n=e.substring(0,t),r=e.substring(t+1);return{prefix:parseInt(n,10),id:r}}function Le(e,t){for(var n=e.start-e.ids.length+1,r=e.ids,o=[r[0],t,[]],i=1,s=r.length;i<s;i++)o=[r[i],{status:"missing"},[o]];return[{pos:n,ids:o}]}function Ie(e,t){var n,r,o,i={status:"available"};if(e._deleted&&(i.deleted=!0),t)if(e._id||(e._id=W()),r=W(32,16).toLowerCase(),e._rev){if(o=Ce(e._rev),o.error)return o;e._rev_tree=[{pos:o.prefix,ids:[o.id,{status:"missing"},[[r,i,[]]]]}],n=o.prefix+1}else e._rev_tree=[{pos:1,ids:[r,i,[]]}],n=1;else if(e._revisions&&(e._rev_tree=Le(e._revisions,i),n=e._revisions.start,r=e._revisions.ids[0]),!e._rev_tree){if(o=Ce(e._rev),o.error)return o;n=o.prefix,r=o.id,e._rev_tree=[{pos:n,ids:[r,i,[]]}]}D(e._id),e._rev=n+"-"+r;var s={metadata:{},data:{}};for(var a in e)if(Object.prototype.hasOwnProperty.call(e,a)){var u="_"===a[0];if(u&&!qo[a]){var c=j(co,a);throw c.message=co.message+": "+a,c}u&&!xo[a]?s.metadata[a.slice(1)]=e[a]:s.data[a]=e[a]}return s}function Re(e,t){e=e||[],t=t||{};try{return new Blob(e,t)}catch(i){if("TypeError"!==i.name)throw i;for(var n="undefined"!=typeof BlobBuilder?BlobBuilder:"undefined"!=typeof MSBlobBuilder?MSBlobBuilder:"undefined"!=typeof MozBlobBuilder?MozBlobBuilder:WebKitBlobBuilder,r=new n,o=0;o<e.length;o+=1)r.append(e[o]);return r.getBlob(t.type)}}function De(e){for(var t=e.length,n=new ArrayBuffer(t),r=new Uint8Array(n),o=0;o<t;o++)r[o]=e.charCodeAt(o);return n}function Ne(e,t){return Re([De(e)],{type:t})}function Be(e,t){return Ne(Ao(e),t)}function Fe(e){for(var t="",n=new Uint8Array(e),r=n.byteLength,o=0;o<r;o++)t+=String.fromCharCode(n[o]);return t}function Pe(e,t){if("undefined"==typeof FileReader)return t(Fe((new FileReaderSync).readAsArrayBuffer(e)));var n=new FileReader,r="function"==typeof n.readAsBinaryString;n.onloadend=function(e){var n=e.target.result||"";return r?t(n):void t(Fe(n))},r?n.readAsBinaryString(e):n.readAsArrayBuffer(e)}function Ue(e,t){Pe(e,function(e){t(e)})}function Me(e,t){Ue(e,function(e){t(To(e))})}function He(e,t){if("undefined"==typeof FileReader)return t((new FileReaderSync).readAsArrayBuffer(e));var n=new FileReader;n.onloadend=function(e){var n=e.target.result||new ArrayBuffer(0);t(n)},n.readAsArrayBuffer(e)}function We(e){return To(e)}function Je(e,t,n){return e.webkitSlice?e.webkitSlice(t,n):e.slice(t,n)}function Ke(e,t,n,r,o){(n>0||r<t.size)&&(t=Je(t,n,r)),He(t,function(t){e.append(t),o()})}function ze(e,t,n,r,o){(n>0||r<t.length)&&(t=t.substring(n,r)),e.appendBinary(t),o()}function Xe(e,t){function n(){Oo(o)}function r(){var e=f.end(!0),n=We(e);t(n),f.destroy()}function o(){var t=c*a,o=t+a;c++,c<u?l(f,e,t,o,n):l(f,e,t,o,r)}var i="string"==typeof e,s=i?e.length:e.size,a=Math.min(jo,s),u=Math.ceil(s/a),c=0,f=i?new Jr:new Jr.ArrayBuffer,l=i?ze:Ke;o()}function Ge(e){return Jr.hash(e)}function Ve(e){try{return Ao(e)}catch(e){var t=j(ao,"Attachment is not a valid base64 string");return{error:t}}}function Qe(e,t,n){var r=Ve(e.data);return r.error?n(r.error):(e.length=r.length,"blob"===t?e.data=Ne(r,e.content_type):"base64"===t?e.data=To(r):e.data=r,void Xe(r,function(t){e.digest="md5-"+t,n()}))}function $e(e,t,n){Xe(e.data,function(r){e.digest="md5-"+r,e.length=e.data.size||e.data.length||0,"binary"===t?Ue(e.data,function(t){e.data=t,n()}):"base64"===t?Me(e.data,function(t){e.data=t,n()}):n()})}function Ye(e,t,n){return e.stub?n():void("string"==typeof e.data?Qe(e,t,n):$e(e,t,n))}function Ze(e,t,n){function r(){i++,e.length===i&&(o?n(o):n())}if(!e.length)return n();var o,i=0;e.forEach(function(e){function n(e){o=e,s++,s===i.length&&r()}var i=e.data&&e.data._attachments?Object.keys(e.data._attachments):[],s=0;if(!i.length)return r();for(var a in e.data._attachments)e.data._attachments.hasOwnProperty(a)&&Ye(e.data._attachments[a],t,n)})}function et(e,t,n,r,o,i,s,a){if(se(t.rev_tree,n.metadata.rev))return r[o]=n,i();var u=t.winningRev||J(t),c="deleted"in t?t.deleted:ue(t,u),f="deleted"in n.metadata?n.metadata.deleted:ue(n.metadata),l=/^1-/.test(n.metadata.rev);if(c&&!f&&a&&l){var d=n.data;d._rev=u,d._id=n.metadata.id,n=Ie(d,a)}var h=ie(t.rev_tree,n.metadata.rev_tree[0],e),p=a&&(c&&f||!c&&"new_leaf"!==h.conflicts||c&&!f&&"new_branch"===h.conflicts);if(p){var v=j(to);return r[o]=v,i()}var y=n.metadata.rev;n.metadata.rev_tree=h.tree,n.stemmedRevs=h.stemmedRevs||[],t.rev_map&&(n.metadata.rev_map=t.rev_map);var _,m=J(n.metadata),g=ue(n.metadata,m),b=c===g?0:c<g?-1:1;_=y===m?g:ue(n.metadata,y),s(n,m,g,_,!0,b,o,i)}function tt(e){return"missing"===e.metadata.rev_tree[0].ids[1].status}function nt(e,t,n,r,o,i,s,u,c){function f(e,t,n){var r=J(e.metadata),o=ue(e.metadata,r);if("was_delete"in u&&o)return i[t]=j(eo,"deleted"),n();var a=d&&tt(e);if(a){var c=j(to);return i[t]=c,n()}var f=o?0:1;s(e,r,o,o,!1,f,t,n)}function l(){++p===v&&c&&c()}e=e||1e3;var d=u.new_edits,h=new a,p=0,v=t.length;t.forEach(function(e,t){if(e._id&&ce(e._id)){var r=e._deleted?"_removeLocal":"_putLocal";return void n[r](e,{ctx:o},function(e,n){i[t]=e||n,l()})}var s=e.metadata.id;h.has(s)?(v--,h.get(s).push([e,t])):h.set(s,[[e,t]])}),h.forEach(function(t,n){function o(){++u<t.length?a():l()}function a(){var a=t[u],c=a[0],l=a[1];if(r.has(n))et(e,r.get(n),c,i,l,o,s,d);else{var h=ie([],c.metadata.rev_tree[0],e);c.metadata.rev_tree=h.tree,c.stemmedRevs=h.stemmedRevs||[],f(c,l,o)}}var u=0;a()})}function rt(e){try{return JSON.parse(e)}catch(t){return Kr.parse(e)}}function ot(e){return e.length<5e4?JSON.parse(e):rt(e)}function it(e){try{return JSON.stringify(e)}catch(t){return Kr.stringify(e)}}function st(e,t,n,r){try{e.apply(t,n)}catch(e){r.emit("error",e)}}function at(e){if(!Po.running&&Po.queue.length){Po.running=!0;var t=Po.queue.shift();t.action(function(r,o){st(t.callback,this,[r,o],e),Po.running=!1,n.nextTick(function(){at(e)})})}}function ut(e){return function(t){var n="unknown_error";t.target&&t.target.error&&(n=t.target.error.name||t.target.error.message),e(j(ho,n,t.type))}}function ct(e,t,n){return{data:it(e),winningRev:t,deletedOrLocal:n?"1":"0",seq:e.seq,id:e.id}}function ft(e){if(!e)return null;var t=ot(e.data);return t.winningRev=e.winningRev,t.deleted="1"===e.deletedOrLocal,t.seq=e.seq,t}function lt(e){if(!e)return e;var t=e._doc_id_rev.lastIndexOf(":");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}function dt(e,t,n,r){n?r(e?"string"!=typeof e?e:Be(e,t):Re([""],{type:t})):e?"string"!=typeof e?Pe(e,function(e){r(To(e))}):r(e):r("")}function ht(e,t,n,r){function o(){++a===s.length&&r&&r()}function i(e,t){var r=e._attachments[t],i=r.digest,s=n.objectStore(Ro).get(i);s.onsuccess=function(e){r.body=e.target.result.body,o()}}var s=Object.keys(e._attachments||{});if(!s.length)return r&&r();var a=0;s.forEach(function(n){t.attachments&&t.include_docs?i(e,n):(e._attachments[n].stub=!0,o())})}function pt(e,t){return Xr.all(e.map(function(e){if(e.doc&&e.doc._attachments){var n=Object.keys(e.doc._attachments);return Xr.all(n.map(function(n){var r=e.doc._attachments[n];if("body"in r){var o=r.body,i=r.content_type;return new Xr(function(s){dt(o,i,t,function(t){e.doc._attachments[n]=Br.extend(_(r,["digest","content_type"]),{data:t}),s()})})}}))}}))}function vt(e,t,n){function r(){c--,c||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||a.delete(e)}})}var i=[],s=n.objectStore(Io),a=n.objectStore(Ro),u=n.objectStore(Do),c=e.length;e.forEach(function(e){var n=s.index("_doc_id_rev"),o=t+"::"+e;n.getKey(o).onsuccess=function(e){var t=e.target.result;if("number"!=typeof t)return r();s.delete(t);var n=u.index("seq").openCursor(IDBKeyRange.only(t));n.onsuccess=function(e){var t=e.target.result;if(t)