text: /**
   * @license
   * Copyright (c) 2014, 2020, Oracle and/or its affiliates.
   * Licensed under The Universal Permissive License (UPL), Version 1.0
   * as shown at https://oss.oracle.com/licenses/upl/
   * @ignore
   */
  !function a(b,c,d){function e(g,h){if(!c[g]){if(!b[g]){var i="function"==typeof require&&require;if(!h&&i)return i(g,!0);if(f)return f(g,!0);var j=new Error("Cannot find module '"+g+"'");throw j.code="MODULE_NOT_FOUND",j}var k=c[g]={exports:{}};b[g][0].call(k.exports,function(a){var c=b[g][1][a];return e(c||a)},k,k.exports,a,b,c,d)}return c[g].exports}for(var f="function"==typeof require&&require,g=0;g<d.length;g++)e(d[g]);return e}({1:[function(a,b,c){"use strict";function d(a){return function(){var b=arguments.length;if(b){for(var c=[],d=-1;++d<b;)c[d]=arguments[d];return a.call(this,c)}return a.call(this,[])}}b.exports=d},{}],2:[function(a,b,c){function d(){this._events=this._events||{},this._maxListeners=this._maxListeners||void 0}function e(a){return"function"==typeof a}function f(a){return"number"==typeof a}function g(a){return"object"==typeof a&&null!==a}function h(a){return void 0===a}b.exports=d,d.EventEmitter=d,d.prototype._events=void 0,d.prototype._maxListeners=void 0,d.defaultMaxListeners=10,d.prototype.setMaxListeners=function(a){if(!f(a)||a<0||isNaN(a))throw TypeError("n must be a positive number");return this._maxListeners=a,this},d.prototype.emit=function(a){var b,c,d,f,i,j;if(this._events||(this._events={}),"error"===a&&(!this._events.error||g(this._events.error)&&!this._events.error.length)){if((b=arguments[1])instanceof Error)throw b;var k=new Error('Uncaught, unspecified "error" event. ('+b+")");throw k.context=b,k}if(c=this._events[a],h(c))return!1;if(e(c))switch(arguments.length){case 1:c.call(this);break;case 2:c.call(this,arguments[1]);break;case 3:c.call(this,arguments[1],arguments[2]);break;default:f=Array.prototype.slice.call(arguments,1),c.apply(this,f)}else if(g(c))for(f=Array.prototype.slice.call(arguments,1),j=c.slice(),d=j.length,i=0;i<d;i++)j[i].apply(this,f);return!0},d.prototype.addListener=function(a,b){var c;if(!e(b))throw TypeError("listener must be a function");return this._events||(this._events={}),this._events.newListener&&this.emit("newListener",a,e(b.listener)?b.listener:b),this._events[a]?g(this._events[a])?this._events[a].push(b):this._events[a]=[this._events[a],b]:this._events[a]=b,g(this._events[a])&&!this._events[a].warned&&(c=h(this._maxListeners)?d.defaultMaxListeners:this._maxListeners)&&c>0&&this._events[a].length>c&&(this._events[a].warned=!0,console.error("(node) warning: possible EventEmitter memory leak detected. %d listeners added. Use emitter.setMaxListeners() to increase limit.",this._events[a].length),"function"==typeof console.trace&&console.trace()),this},d.prototype.on=d.prototype.addListener,d.prototype.once=function(a,b){function c(){this.removeListener(a,c),d||(d=!0,b.apply(this,arguments))}if(!e(b))throw TypeError("listener must be a function");var d=!1;return c.listener=b,this.on(a,c),this},d.prototype.removeListener=function(a,b){var c,d,f,h;if(!e(b))throw TypeError("listener must be a function");if(!this._events||!this._events[a])return this;if(c=this._events[a],f=c.length,d=-1,c===b||e(c.listener)&&c.listener===b)delete this._events[a],this._events.removeListener&&this.emit("removeListener",a,b);else if(g(c)){for(h=f;h-- >0;)if(c[h]===b||c[h].listener&&c[h].listener===b){d=h;break}if(d<0)return this;1===c.length?(c.length=0,delete this._events[a]):c.splice(d,1),this._events.removeListener&&this.emit("removeListener",a,b)}return this},d.prototype.removeAllListeners=function(a){var b,c;if(!this._events)return this;if(!this._events.removeListener)return 0===arguments.length?this._events={}:this._events[a]&&delete this._events[a],this;if(0===arguments.length){for(b in this._events)"removeListener"!==b&&this.removeAllListeners(b);return this.removeAllListeners("removeListener"),this._events={},this}if(c=this._events[a],e(c))this.removeListener(a,c);else if(c)for(;c.length;)this.removeListener(a,c[c.length-1]);return delete this._events[a],this},d.prototype.listeners=function(a){return this._events&&this._events[a]?e(this._events[a])?[this._events[a]]:this._events[a].slice():[]},d.prototype.listenerCount=function(a){if(this._events){var b=this._events[a];if(e(b))return 1;if(b)return b.length}return 0},d.listenerCount=function(a,b){return a.listenerCount(b)}},{}],3:[function(a,b,c){(function(a){"use strict";function c(){k=!0;for(var a,b,c=l.length;c;){for(b=l,l=[],a=-1;++a<c;)b[a]();c=l.length}k=!1}function d(a){1!==l.push(a)||k||e()}var e,f=a.MutationObserver||a.WebKitMutationObserver;if(f){var g=0,h=new f(c),i=a.document.createTextNode("");h.observe(i,{characterData:!0}),e=function(){i.data=g=++g%2}}else if(a.setImmediate||void 0===a.MessageChannel)e="document"in a&&"onreadystatechange"in a.document.createElement("script")?function(){var b=a.document.createElement("script");b.onreadystatechange=function(){c(),b.onreadystatechange=null,b.parentNode.removeChild(b),b=null},a.document.documentElement.appendChild(b)}:function(){setTimeout(c,0)};else{var j=new a.MessageChannel;j.port1.onmessage=c,e=function(){j.port2.postMessage(0)}}var k,l=[];b.exports=d}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],4:[function(a,b,c){"function"==typeof Object.create?b.exports=function(a,b){a.super_=b,a.prototype=Object.create(b.prototype,{constructor:{value:a,enumerable:!1,writable:!0,configurable:!0}})}:b.exports=function(a,b){a.super_=b;var c=function(){};c.prototype=b.prototype,a.prototype=new c,a.prototype.constructor=a}},{}],5:[function(a,b,c){"use strict";function d(){}function e(a){if("function"!=typeof a)throw new TypeError("resolver must be a function");this.state=s,this.queue=[],this.outcome=void 0,a!==d&&i(this,a)}function f(a,b,c){this.promise=a,"function"==typeof b&&(this.onFulfilled=b,this.callFulfilled=this.otherCallFulfilled),"function"==typeof c&&(this.onRejected=c,this.callRejected=this.otherCallRejected)}function g(a,b,c){o(function(){var d;try{d=b(c)}catch(b){return p.reject(a,b)}d===a?p.reject(a,new TypeError("Cannot resolve promise with itself")):p.resolve(a,d)})}function h(a){var b=a&&a.then;if(a&&("object"==typeof a||"function"==typeof a)&&"function"==typeof b)return function(){b.apply(a,arguments)}}function i(a,b){function c(b){f||(f=!0,p.reject(a,b))}function d(b){f||(f=!0,p.resolve(a,b))}function e(){b(d,c)}var f=!1,g=j(e);"error"===g.status&&c(g.value)}function j(a,b){var c={};try{c.value=a(b),c.status="success"}catch(a){c.status="error",c.value=a}return c}function k(a){return a instanceof this?a:p.resolve(new this(d),a)}function l(a){var b=new this(d);return p.reject(b,a)}function m(a){var b=this;if("[object Array]"!==Object.prototype.toString.call(a))return this.reject(new TypeError("must be an array"));var c=a.length,e=!1;if(!c)return this.resolve([]);for(var f=new Array(c),g=0,h=-1,i=new this(d);++h<c;)!function(a,d){function h(a){f[d]=a,++g!==c||e||(e=!0,p.resolve(i,f))}b.resolve(a).then(h,function(a){e||(e=!0,p.reject(i,a))})}(a[h],h);return i}function n(a){var b=this;if("[object Array]"!==Object.prototype.toString.call(a))return this.reject(new TypeError("must be an array"));var c=a.length,e=!1;if(!c)return this.resolve([]);for(var f=-1,g=new this(d);++f<c;)!function(a){b.resolve(a).then(function(a){e||(e=!0,p.resolve(g,a))},function(a){e||(e=!0,p.reject(g,a))})}(a[f]);return g}var o=a(3),p={},q=["REJECTED"],r=["FULFILLED"],s=["PENDING"];b.exports=e,e.prototype.catch=function(a){return this.then(null,a)},e.prototype.then=function(a,b){if("function"!=typeof a&&this.state===r||"function"!=typeof b&&this.state===q)return this;var c=new this.constructor(d);if(this.state!==s){g(c,this.state===r?a:b,this.outcome)}else this.queue.push(new f(c,a,b));return c},f.prototype.callFulfilled=function(a){p.resolve(this.promise,a)},f.prototype.otherCallFulfilled=function(a){g(this.promise,this.onFulfilled,a)},f.prototype.callRejected=function(a){p.reject(this.promise,a)},f.prototype.otherCallRejected=function(a){g(this.promise,this.onRejected,a)},p.resolve=function(a,b){var c=j(h,b);if("error"===c.status)return p.reject(a,c.value);var d=c.value;if(d)i(a,d);else{a.state=r,a.outcome=b;for(var e=-1,f=a.queue.length;++e<f;)a.queue[e].callFulfilled(b)}return a},p.reject=function(a,b){a.state=q,a.outcome=b;for(var c=-1,d=a.queue.length;++c<d;)a.queue[c].callRejected(b);return a},e.resolve=k,e.reject=l,e.all=m,e.race=n},{3:3}],6:[function(a,b,c){function d(){throw new Error("setTimeout has not been defined")}function e(){throw new Error("clearTimeout has not been defined")}function f(a){if(l===setTimeout)return setTimeout(a,0);if((l===d||!l)&&setTimeout)return l=setTimeout,setTimeout(a,0);try{return l(a,0)}catch(b){try{return l.call(null,a,0)}catch(b){return l.call(this,a,0)}}}function g(a){if(m===clearTimeout)return clearTimeout(a);if((m===e||!m)&&clearTimeout)return m=clearTimeout,clearTimeout(a);try{return m(a)}catch(b){try{return m.call(null,a)}catch(b){return m.call(this,a)}}}function h(){q&&o&&(q=!1,o.length?p=o.concat(p):r=-1,p.length&&i())}function i(){if(!q){var a=f(h);q=!0;for(var b=p.length;b;){for(o=p,p=[];++r<b;)o&&o[r].run();r=-1,b=p.length}o=null,q=!1,g(a)}}function j(a,b){this.fun=a,this.array=b}function k(){}var l,m,n=b.exports={};!function(){try{l="function"==typeof setTimeout?setTimeout:d}catch(a){l=d}try{m="function"==typeof clearTimeout?clearTimeout:e}catch(a){m=e}}();var o,p=[],q=!1,r=-1;n.nextTick=function(a){var b=new Array(arguments.length-1);if(arguments.length>1)for(var c=1;c<arguments.length;c++)b[c-1]=arguments[c];p.push(new j(a,b)),1!==p.length||q||f(i)},j.prototype.run=function(){this.fun.apply(null,this.array)},n.title="browser",n.browser=!0,n.env={},n.argv=[],n.version="",n.versions={},n.on=k,n.addListener=k,n.once=k,n.off=k,n.removeListener=k,n.removeAllListeners=k,n.emit=k,n.prependListener=k,n.prependOnceListener=k,n.listeners=function(a){return[]},n.binding=function(a){throw new Error("process.binding is not supported")},n.cwd=function(){return"/"},n.chdir=function(a){throw new Error("process.chdir is not supported")},n.umask=function(){return 0}},{}],7:[function(a,b,c){!function(a){if("object"==typeof c)b.exports=a();else if("function"==typeof define&&define.amd)define(a);else{var d;try{d=window}catch(a){d=self}d.SparkMD5=a()}}(function(a){"use strict";function b(a,b){var c=a[0],d=a[1],e=a[2],f=a[3];c+=(d&e|~d&f)+b[0]-680876936|0,c=(c<<7|c>>>25)+d|0,f+=(c&d|~c&e)+b[1]-389564586|0,f=(f<<12|f>>>20)+c|0,e+=(f&c|~f&d)+b[2]+606105819|0,e=(e<<17|e>>>15)+f|0,d+=(e&f|~e&c)+b[3]-1044525330|0,d=(d<<22|d>>>10)+e|0,c+=(d&e|~d&f)+b[4]-176418897|0,c=(c<<7|c>>>25)+d|0,f+=(c&d|~c&e)+b[5]+1200080426|0,f=(f<<12|f>>>20)+c|0,e+=(f&c|~f&d)+b[6]-1473231341|0,e=(e<<17|e>>>15)+f|0,d+=(e&f|~e&c)+b[7]-45705983|0,d=(d<<22|d>>>10)+e|0,c+=(d&e|~d&f)+b[8]+1770035416|0,c=(c<<7|c>>>25)+d|0,f+=(c&d|~c&e)+b[9]-1958414417|0,f=(f<<12|f>>>20)+c|0,e+=(f&c|~f&d)+b[10]-42063|0,e=(e<<17|e>>>15)+f|0,d+=(e&f|~e&c)+b[11]-1990404162|0,d=(d<<22|d>>>10)+e|0,c+=(d&e|~d&f)+b[12]+1804603682|0,c=(c<<7|c>>>25)+d|0,f+=(c&d|~c&e)+b[13]-40341101|0,f=(f<<12|f>>>20)+c|0,e+=(f&c|~f&d)+b[14]-1502002290|0,e=(e<<17|e>>>15)+f|0,d+=(e&f|~e&c)+b[15]+1236535329|0,d=(d<<22|d>>>10)+e|0,c+=(d&f|e&~f)+b[1]-165796510|0,c=(c<<5|c>>>27)+d|0,f+=(c&e|d&~e)+b[6]-1069501632|0,f=(f<<9|f>>>23)+c|0,e+=(f&d|c&~d)+b[11]+643717713|0,e=(e<<14|e>>>18)+f|0,d+=(e&c|f&~c)+b[0]-373897302|0,d=(d<<20|d>>>12)+e|0,c+=(d&f|e&~f)+b[5]-701558691|0,c=(c<<5|c>>>27)+d|0,f+=(c&e|d&~e)+b[10]+38016083|0,f=(f<<9|f>>>23)+c|0,e+=(f&d|c&~d)+b[15]-660478335|0,e=(e<<14|e>>>18)+f|0,d+=(e&c|f&~c)+b[4]-405537848|0,d=(d<<20|d>>>12)+e|0,c+=(d&f|e&~f)+b[9]+568446438|0,c=(c<<5|c>>>27)+d|0,f+=(c&e|d&~e)+b[14]-1019803690|0,f=(f<<9|f>>>23)+c|0,e+=(f&d|c&~d)+b[3]-187363961|0,e=(e<<14|e>>>18)+f|0,d+=(e&c|f&~c)+b[8]+1163531501|0,d=(d<<20|d>>>12)+e|0,c+=(d&f|e&~f)+b[13]-1444681467|0,c=(c<<5|c>>>27)+d|0,f+=(c&e|d&~e)+b[2]-51403784|0,f=(f<<9|f>>>23)+c|0,e+=(f&d|c&~d)+b[7]+1735328473|0,e=(e<<14|e>>>18)+f|0,d+=(e&c|f&~c)+b[12]-1926607734|0,d=(d<<20|d>>>12)+e|0,c+=(d^e^f)+b[5]-378558|0,c=(c<<4|c>>>28)+d|0,f+=(c^d^e)+b[8]-2022574463|0,f=(f<<11|f>>>21)+c|0,e+=(f^c^d)+b[11]+1839030562|0,e=(e<<16|e>>>16)+f|0,d+=(e^f^c)+b[14]-35309556|0,d=(d<<23|d>>>9)+e|0,c+=(d^e^f)+b[1]-1530992060|0,c=(c<<4|c>>>28)+d|0,f+=(c^d^e)+b[4]+1272893353|0,f=(f<<11|f>>>21)+c|0,e+=(f^c^d)+b[7]-155497632|0,e=(e<<16|e>>>16)+f|0,d+=(e^f^c)+b[10]-1094730640|0,d=(d<<23|d>>>9)+e|0,c+=(d^e^f)+b[13]+681279174|0,c=(c<<4|c>>>28)+d|0,f+=(c^d^e)+b[0]-358537222|0,f=(f<<11|f>>>21)+c|0,e+=(f^c^d)+b[3]-722521979|0,e=(e<<16|e>>>16)+f|0,d+=(e^f^c)+b[6]+76029189|0,d=(d<<23|d>>>9)+e|0,c+=(d^e^f)+b[9]-640364487|0,c=(c<<4|c>>>28)+d|0,f+=(c^d^e)+b[12]-421815835|0,f=(f<<11|f>>>21)+c|0,e+=(f^c^d)+b[15]+530742520|0,e=(e<<16|e>>>16)+f|0,d+=(e^f^c)+b[2]-995338651|0,d=(d<<23|d>>>9)+e|0,c+=(e^(d|~f))+b[0]-198630844|0,c=(c<<6|c>>>26)+d|0,f+=(d^(c|~e))+b[7]+1126891415|0,f=(f<<10|f>>>22)+c|0,e+=(c^(f|~d))+b[14]-1416354905|0,e=(e<<15|e>>>17)+f|0,d+=(f^(e|~c))+b[5]-57434055|0,d=(d<<21|d>>>11)+e|0,c+=(e^(d|~f))+b[12]+1700485571|0,c=(c<<6|c>>>26)+d|0,f+=(d^(c|~e))+b[3]-1894986606|0,f=(f<<10|f>>>22)+c|0,e+=(c^(f|~d))+b[10]-1051523|0,e=(e<<15|e>>>17)+f|0,d+=(f^(e|~c))+b[1]-2054922799|0,d=(d<<21|d>>>11)+e|0,c+=(e^(d|~f))+b[8]+1873313359|0,c=(c<<6|c>>>26)+d|0,f+=(d^(c|~e))+b[15]-30611744|0,f=(f<<10|f>>>22)+c|0,e+=(c^(f|~d))+b[6]-1560198380|0,e=(e<<15|e>>>17)+f|0,d+=(f^(e|~c))+b[13]+1309151649|0,d=(d<<21|d>>>11)+e|0,c+=(e^(d|~f))+b[4]-145523070|0,c=(c<<6|c>>>26)+d|0,f+=(d^(c|~e))+b[11]-1120210379|0,f=(f<<10|f>>>22)+c|0,e+=(c^(f|~d))+b[2]+718787259|0,e=(e<<15|e>>>17)+f|0,d+=(f^(e|~c))+b[9]-343485551|0,d=(d<<21|d>>>11)+e|0,a[0]=c+a[0]|0,a[1]=d+a[1]|0,a[2]=e+a[2]|0,a[3]=f+a[3]|0}function c(a){var b,c=[];for(b=0;b<64;b+=4)c[b>>2]=a.charCodeAt(b)+(a.charCodeAt(b+1)<<8)+(a.charCodeAt(b+2)<<16)+(a.charCodeAt(b+3)<<24);return c}function d(a){var b,c=[];for(b=0;b<64;b+=4)c[b>>2]=a[b]+(a[b+1]<<8)+(a[b+2]<<16)+(a[b+3]<<24);return c}function e(a){var d,e,f,g,h,i,j=a.length,k=[1732584193,-271733879,-1732584194,271733878];for(d=64;d<=j;d+=64)b(k,c(a.substring(d-64,d)));for(a=a.substring(d-64),e=a.length,f=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],d=0;d<e;d+=1)f[d>>2]|=a.charCodeAt(d)<<(d%4<<3);if(f[d>>2]|=128<<(d%4<<3),d>55)for(b(k,f),d=0;d<16;d+=1)f[d]=0;return g=8*j,g=g.toString(16).match(/(.*?)(.{0,8})$/),h=parseInt(g[2],16),i=parseInt(g[1],16)||0,f[14]=h,f[15]=i,b(k,f),k}function f(a){var c,e,f,g,h,i,j=a.length,k=[1732584193,-271733879,-1732584194,271733878];for(c=64;c<=j;c+=64)b(k,d(a.subarray(c-64,c)));for(a=c-64<j?a.subarray(c-64):new Uint8Array(0),e=a.length,f=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],c=0;c<e;c+=1)f[c>>2]|=a[c]<<(c%4<<3);if(f[c>>2]|=128<<(c%4<<3),c>55)for(b(k,f),c=0;c<16;c+=1)f[c]=0;return g=8*j,g=g.toString(16).match(/(.*?)(.{0,8})$/),h=parseInt(g[2],16),i=parseInt(g[1],16)||0,f[14]=h,f[15]=i,b(k,f),k}function g(a){var b,c="";for(b=0;b<4;b+=1)c+=o[a>>8*b+4&15]+o[a>>8*b&15];return c}function h(a){var b;for(b=0;b<a.length;b+=1)a[b]=g(a[b]);return a.join("")}function i(a){return/[\u0080-\uFFFF]/.test(a)&&(a=unescape(encodeURIComponent(a))),a}function j(a,b){var c,d=a.length,e=new ArrayBuffer(d),f=new Uint8Array(e);for(c=0;c<d;c+=1)f[c]=a.charCodeAt(c);return b?f:e}function k(a){return String.fromCharCode.apply(null,new Uint8Array(a))}function l(a,b,c){var d=new Uint8Array(a.byteLength+b.byteLength);return d.set(new Uint8Array(a)),d.set(new Uint8Array(b),a.byteLength),c?d:d.buffer}function m(a){var b,c=[],d=a.length;for(b=0;b<d-1;b+=2)c.push(parseInt(a.substr(b,2),16));return String.fromCharCode.apply(String,c)}function n(){this.reset()}var o=["0","1","2","3","4","5","6","7","8","9","a","b","c","d","e","f"];return"5d41402abc4b2a76b9719d911017c592"!==h(e("hello"))&&function(a,b){var c=(65535&a)+(65535&b);return(a>>16)+(b>>16)+(c>>16)<<16|65535&c},"undefined"==typeof ArrayBuffer||ArrayBuffer.prototype.slice||function(){function b(a,b){return a=0|a||0,a<0?Math.max(a+b,0):Math.min(a,b)}ArrayBuffer.prototype.slice=function(c,d){var e,f,g,h,i=this.byteLength,j=b(c,i),k=i;return d!==a&&(k=b(d,i)),j>k?new ArrayBuffer(0):(e=k-j,f=new ArrayBuffer(e),g=new Uint8Array(f),h=new Uint8Array(this,j,e),g.set(h),f)}}(),n.prototype.append=function(a){return this.appendBinary(i(a)),this},n.prototype.appendBinary=function(a){this._buff+=a,this._length+=a.length;var d,e=this._buff.length;for(d=64;d<=e;d+=64)b(this._hash,c(this._buff.substring(d-64,d)));return this._buff=this._buff.substring(d-64),this},n.prototype.end=function(a){var b,c,d=this._buff,e=d.length,f=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0];for(b=0;b<e;b+=1)f[b>>2]|=d.charCodeAt(b)<<(b%4<<3);return this._finish(f,e),c=h(this._hash),a&&(c=m(c)),this.reset(),c},n.prototype.reset=function(){return this._buff="",this._length=0,this._hash=[1732584193,-271733879,-1732584194,271733878],this},n.prototype.getState=function(){return{buff:this._buff,length:this._length,hash:this._hash}},n.prototype.setState=function(a){return this._buff=a.buff,this._length=a.length,this._hash=a.hash,this},n.prototype.destroy=function(){delete this._hash,delete this._buff,delete this._length},n.prototype._finish=function(a,c){var d,e,f,g=c;if(a[g>>2]|=128<<(g%4<<3),g>55)for(b(this._hash,a),g=0;g<16;g+=1)a[g]=0;d=8*this._length,d=d.toString(16).match(/(.*?)(.{0,8})$/),e=parseInt(d[2],16),f=parseInt(d[1],16)||0,a[14]=e,a[15]=f,b(this._hash,a)},n.hash=function(a,b){return n.hashBinary(i(a),b)},n.hashBinary=function(a,b){var c=e(a),d=h(c);return b?m(d):d},n.ArrayBuffer=function(){this.reset()},n.ArrayBuffer.prototype.append=function(a){var c,e=l(this._buff.buffer,a,!0),f=e.length;for(this._length+=a.byteLength,c=64;c<=f;c+=64)b(this._hash,d(e.subarray(c-64,c)));return this._buff=c-64<f?new Uint8Array(e.buffer.slice(c-64)):new Uint8Array(0),this},n.ArrayBuffer.prototype.end=function(a){var b,c,d=this._buff,e=d.length,f=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0];for(b=0;b<e;b+=1)f[b>>2]|=d[b]<<(b%4<<3);return this._finish(f,e),c=h(this._hash),a&&(c=m(c)),this.reset(),c},n.ArrayBuffer.prototype.reset=function(){return this._buff=new Uint8Array(0),this._length=0,this._hash=[1732584193,-271733879,-1732584194,271733878],this},n.ArrayBuffer.prototype.getState=function(){var a=n.prototype.getState.call(this);return a.buff=k(a.buff),a},n.ArrayBuffer.prototype.setState=function(a){return a.buff=j(a.buff,!0),n.prototype.setState.call(this,a)},n.ArrayBuffer.prototype.destroy=n.prototype.destroy,n.ArrayBuffer.prototype._finish=n.prototype._finish,n.ArrayBuffer.hash=function(a,b){var c=f(new Uint8Array(a)),d=h(c);return b?m(d):d},n})},{}],8:[function(a,b,c){var d=a(11),e=a(12),f=e;f.v1=d,f.v4=e,b.exports=f},{11:11,12:12}],9:[function(a,b,c){function d(a,b){var c=b||0,d=e;return d[a[c++]]+d[a[c++]]+d[a[c++]]+d[a[c++]]+"-"+d[a[c++]]+d[a[c++]]+"-"+d[a[c++]]+d[a[c++]]+"-"+d[a[c++]]+d[a[c++]]+"-"+d[a[c++]]+d[a[c++]]+d[a[c++]]+d[a[c++]]+d[a[c++]]+d[a[c++]]}for(var e=[],f=0;f<256;++f)e[f]=(f+256).toString(16).substr(1);b.exports=d},{}],10:[function(a,b,c){(function(a){var c,d=a.crypto||a.msCrypto;if(d&&d.getRandomValues){var e=new Uint8Array(16);c=function(){return d.getRandomValues(e),e}}if(!c){var f=new Array(16);c=function(){for(var a,b=0;b<16;b++)0==(3&b)&&(a=4294967296*Math.random()),f[b]=a>>>((3&b)<<3)&255;return f}}b.exports=c}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],11:[function(a,b,c){function d(a,b,c){var d=b&&c||0,e=b||[];a=a||{};var g=void 0!==a.clockseq?a.clockseq:i,l=void 0!==a.msecs?a.msecs:(new Date).getTime(),m=void 0!==a.nsecs?a.nsecs:k+1,n=l-j+(m-k)/1e4;if(n<0&&void 0===a.clockseq&&(g=g+1&16383),(n<0||l>j)&&void 0===a.nsecs&&(m=0),m>=1e4)throw new Error("uuid.v1(): Can't create more than 10M uuids/sec");j=l,k=m,i=g,l+=122192928e5;var o=(1e4*(268435455&l)+m)%4294967296;e[d++]=o>>>24&255,e[d++]=o>>>16&255,e[d++]=o>>>8&255,e[d++]=255&o;var p=l/4294967296*1e4&268435455;e[d++]=p>>>8&255,e[d++]=255&p,e[d++]=p>>>24&15|16,e[d++]=p>>>16&255,e[d++]=g>>>8|128,e[d++]=255&g;for(var q=a.node||h,r=0;r<6;++r)e[d+r]=q[r];return b||f(e)}var e=a(10),f=a(9),g=e(),h=[1|g[0],g[1],g[2],g[3],g[4],g[5]],i=16383&(g[6]<<8|g[7]),j=0,k=0;b.exports=d},{10:10,9:9}],12:[function(a,b,c){function d(a,b,c){var d=b&&c||0;"string"==typeof a&&(b="binary"==a?new Array(16):null,a=null),a=a||{};var g=a.random||(a.rng||e)();if(g[6]=15&g[6]|64,g[8]=63&g[8]|128,b)for(var h=0;h<16;++h)b[d+h]=g[h];return b||f(g)}var e=a(10),f=a(9);b.exports=d},{10:10,9:9}],13:[function(a,b,c){(function(b){"use strict";function c(a){return a&&"object"==typeof a&&"default"in a?a.default:a}function d(a){return"undefined"!=typeof ArrayBuffer&&a instanceof ArrayBuffer||"undefined"!=typeof Blob&&a instanceof Blob}function e(a){if("function"==typeof a.slice)return a.slice(0);var b=new ArrayBuffer(a.byteLength),c=new Uint8Array(b),d=new Uint8Array(a);return c.set(d),b}function f(a){if(a instanceof ArrayBuffer)return e(a);var b=a.size,c=a.type;return"function"==typeof a.slice?a.slice(0,b,c):a.webkitSlice(0,b,c)}function g(a){var b=Object.getPrototypeOf(a);if(null===b)return!0;var c=b.constructor;return"function"==typeof c&&c instanceof c&&Yb.call(c)==Zb}function h(a){var b,c,e;if(!a||"object"!=typeof a)return a;if(Array.isArray(a)){for(b=[],c=0,e=a.length;c<e;c++)b[c]=h(a[c]);return b}if(a instanceof Date)return a.toISOString();if(d(a))return f(a);if(!g(a))return a;b={};for(c in a)if(Object.prototype.hasOwnProperty.call(a,c)){var i=h(a[c]);void 0!==i&&(b[c]=i)}return b}function i(a){var b=!1;return Sb(function(c){if(b)throw new Error("once called more than once");b=!0,a.apply(this,c)})}function j(a){return Sb(function(b){b=h(b);var c=this,d="function"==typeof b[b.length-1]&&b.pop(),e=new Xb(function(d,e){var f;try{var g=i(function(a,b){a?e(a):d(b)});b.push(g),f=a.apply(c,b),f&&"function"==typeof f.then&&d(f)}catch(a){e(a)}});return d&&e.then(function(a){d(null,a)},d),e})}function k(a){return"$"+a}function l(a){return a.substring(1)}function m(){this._store={}}function n(a){if(this._store=new m,a&&Array.isArray(a))for(var b=0,c=a.length;b<c;b++)this.add(a[b])}function o(a,b){for(var c={},d=0,e=b.length;d<e;d++){var f=b[d];f in a&&(c[f]=a[f])}return c}function p(){return"undefined"!=typeof chrome&&void 0!==chrome.storage&&void 0!==chrome.storage.local}function q(){return ac}function r(a){p()?chrome.storage.onChanged.addListener(function(b){null!=b.db_name&&a.emit(b.dbName.newValue)}):q()&&("undefined"!=typeof addEventListener?addEventListener("storage",function(b){a.emit(b.key)}):window.attachEvent("storage",function(b){a.emit(b.key)}))}function s(){Tb.EventEmitter.call(this),this._listeners={},r(this)}function t(a){if("undefined"!==console&&a in console){var b=Array.prototype.slice.call(arguments,1);console[a].apply(console,b)}}function u(a,b,c){Error.call(this,c),this.status=a,this.name=b,this.message=c,this.error=!0}function v(a){for(var b=[],c=0,d=a.length;c<d;c++)b=b.concat(a[c]);return b}function w(){}function x(a){return"boolean"==typeof a._remote?a._remote:"function"==typeof a.type&&(t("warn","db.type() is deprecated and will be removed in a future version of PouchDB"),"http"===a.type())}function y(a,b,c){return new Xb(function(d,e){a.get(b,function(f,g){if(f){if(404!==f.status)return e(f);g={}}var h=g._rev,i=c(g);if(!i)return d({updated:!1,rev:h});i._id=b,i._rev=h,d(z(a,i,c))})})}function z(a,b,c){return a.put(b).then(function(a){return{updated:!0,rev:a.rev}},function(d){if(409!==d.status)throw d;return y(a,b._id,c)})}function A(a){return a=h(a),a.index||(a.index={}),["type","name","ddoc"].forEach(function(b){a.index[b]&&(a[b]=a.index[b],delete a.index[b])}),a.fields&&(a.index.fields=a.fields,delete a.fields),a.type||(a.type="json"),a}function B(a,b,c){b=A(b),a.request({method:"POST",url:"_index",body:b},c)}function C(a,b,c){a.request({method:"POST",url:"_find",body:b},c)}function D(a,b,c){a.request({method:"POST",url:"_explain",body:b},c)}function E(a,b){a.request({method:"GET",url:"_index"},b)}function F(a,b,c){var d=b.ddoc,e=b.type||"json",f=b.name;if(!d)return c(new Error("you must provide an index's ddoc"));if(!f)return c(new Error("you must provide an index's name"));var g="_index/"+[d,e,f].map(encodeURIComponent).join("/");a.request({method:"DELETE",url:g},c)}function G(a,b){for(var c=a,d=0,e=b.length;d<e;d++){if(!(c=c[b[d]]))break}return c}function H(a,b,c){for(var d=0,e=b.length;d<e-1;d++){a=a[b[d]]={}}a[b[e-1]]=c}function I(a,b){return a<b?-1:a>b?1:0}function J(a){for(var b=[],c="",d=0,e=a.length;d<e;d++){var f=a[d];"."===f?d>0&&"\\"===a[d-1]?c=c.substring(0,c.length-1)+".":(b.push(c),c=""):c+=f}return b.push(c),b}function K(a){return ec.indexOf(a)>-1}function L(a){return Object.keys(a)[0]}function M(a){return a[L(a)]}function N(a){var b={};return a.forEach(function(a){Object.keys(a).forEach(function(c){var d=a[c];if("object"!=typeof d&&(d={$eq:d}),K(c))d instanceof Array?b[c]=d.map(function(a){return N([a])}):b[c]=N([d]);else{var e=b[c]=b[c]||{};Object.keys(d).forEach(function(a){var b=d[a];return"$gt"===a||"$gte"===a?O(a,b,e):"$lt"===a||"$lte"===a?P(a,b,e):"$ne"===a?Q(b,e):"$eq"===a?R(b,e):void(e[a]=b)})}})}),b}function O(a,b,c){void 0===c.$eq&&(void 0!==c.$gte?"$gte"===a?b>c.$gte&&(c.$gte=b):b>=c.$gte&&(delete c.$gte,c.$gt=b):void 0!==c.$gt?"$gte"===a?b>c.$gt&&(delete c.$gt,c.$gte=b):b>c.$gt&&(c.$gt=b):c[a]=b)}function P(a,b,c){void 0===c.$eq&&(void 0!==c.$lte?"$lte"===a?b<c.$lte&&(c.$lte=b):b<=c.$lte&&(delete c.$lte,c.$lt=b):void 0!==c.$lt?"$lte"===a?b<c.$lt&&(delete c.$lt,c.$lte=b):b<c.$lt&&(c.$lt=b):c[a]=b)}function Q(a,b){"$ne"in b?b.$ne.push(a):b.$ne=[a]}function R(a,b){delete b.$gt,delete b.$gte,delete b.$lt,delete b.$lte,delete b.$ne,b.$eq=a}function S(a){var b=h(a),c=!1;"$and"in b&&(b=N(b.$and),c=!0),["$or","$nor"].forEach(function(a){a in b&&b[a].forEach(function(a){for(var b=Object.keys(a),c=0;c<b.length;c++){var d=b[c],e=a[d];"object"==typeof e&&null!==e||(a[d]={$eq:e})}})}),"$not"in b&&(b.$not=N([b.$not]));for(var d=Object.keys(b),e=0;e<d.length;e++){var f=d[e],g=b[f];"object"!=typeof g||null===g?g={$eq:g}:"$ne"in g&&!c&&(g.$ne=[g.$ne]),b[f]=g}return b}function T(a,b,c){for(var d="",e=c-a.length;d.length<e;)d+=b;return d}function U(a,b,c){return T(a,b,c)+a}function V(a,b){if(a===b)return 0;a=W(a),b=W(b);var c=da(a),d=da(b);if(c-d!=0)return c-d;switch(typeof a){case"number":return a-b;case"boolean":return a<b?-1:1;case"string":return ba(a,b)}return Array.isArray(a)?aa(a,b):ca(a,b)}function W(a){switch(typeof a){case"undefined":return null;case"number":return a===1/0||a===-1/0||isNaN(a)?null:a;case"object":var b=a;if(Array.isArray(a)){var c=a.length;a=new Array(c);for(var d=0;d<c;d++)a[d]=W(b[d])}else{if(a instanceof Date)return a.toJSON();if(null!==a){a={};for(var e in b)if(b.hasOwnProperty(e)){var f=b[e];void 0!==f&&(a[e]=W(f))}}}}return a}function X(a){if(null!==a)switch(typeof a){case"boolean":return a?1:0;case"number":return ea(a);case"string":return a.replace(/\u0002/g,"").replace(/\u0001/g,"").replace(/\u0000/g,"");case"object":var b=Array.isArray(a),c=b?a:Object.keys(a),d=-1,e=c.length,f="";if(b)for(;++d<e;)f+=Y(c[d]);else for(;++d<e;){var g=c[d];f+=Y(g)+Y(a[g])}return f}return""}function Y(a){return a=W(a),da(a)+hc+X(a)+"\0"}function Z(a,b){var c,d=b;if("1"===a[b])c=0,b++;else{var e="0"===a[b];b++;var f="",g=a.substring(b,b+gc),h=parseInt(g,10)+fc;for(e&&(h=-h),b+=gc;;){var i=a[b];if("\0"===i)break;f+=i,b++}f=f.split("."),c=1===f.length?parseInt(f,10):parseFloat(f[0]+"."+f[1]),e&&(c-=10),0!==h&&(c=parseFloat(c+"e"+h))}return{num:c,length:b-d}}function $(a,b){var c=a.pop();if(b.length){var d=b[b.length-1];c===d.element&&(b.pop(),d=b[b.length-1]);var e=d.element,f=d.index;if(Array.isArray(e))e.push(c);else if(f===a.length-2){var g=a.pop();e[g]=c}else a.push(c)}}function _(a){for(var b=[],c=[],d=0;;){var e=a[d++];if("\0"!==e)switch(e){case"1":b.push(null);break;case"2":b.push("1"===a[d]),d++;break;case"3":var f=Z(a,d);b.push(f.num),d+=f.length;break;case"4":for(var g="";;){var h=a[d];if("\0"===h)break;g+=h,d++}g=g.replace(/\u0001\u0001/g,"\0").replace(/\u0001\u0002/g,"").replace(/\u0002\u0002/g,""),b.push(g);break;case"5":var i={element:[],index:b.length};b.push(i.element),c.push(i);break;case"6":var j={element:{},index:b.length};b.push(j.element),c.push(j);break;default:throw new Error("bad collationIndex or unexpectedly reached end of input: "+e)}else{if(1===b.length)return b.pop();$(b,c)}}}function aa(a,b){for(var c=Math.min(a.length,b.length),d=0;d<c;d++){var e=V(a[d],b[d]);if(0!==e)return e}return a.length===b.length?0:a.length>b.length?1:-1}function ba(a,b){return a===b?0:a>b?1:-1}function ca(a,b){for(var c=Object.keys(a),d=Object.keys(b),e=Math.min(c.length,d.length),f=0;f<e;f++){var g=V(c[f],d[f]);if(0!==g)return g;if(0!==(g=V(a[c[f]],b[d[f]])))return g}return c.length===d.length?0:c.length>d.length?1:-1}function da(a){var b=["boolean","number","string","object"],c=b.indexOf(typeof a);return~c?null===a?1:Array.isArray(a)?5:c<3?c+2:c+3:Array.isArray(a)?5:void 0}function ea(a){if(0===a)return"1";var b=a.toExponential().split(/e\+?/),c=parseInt(b[1],10),d=a<0,e=d?"0":"2",f=(d?-c:c)-fc,g=U(f.toString(),"0",gc);e+=hc+g;var h=Math.abs(parseFloat(b[0]));d&&(h=10-h);var i=h.toFixed(20);return i=i.replace(/\.?0+$/,""),e+=hc+i}function fa(a){function b(b){return a.map(function(a){var c=L(a),d=J(c);return G(b,d)})}return function(a,c){var d=b(a.doc),e=b(c.doc),f=V(d,e);return 0!==f?f:I(a.doc._id,c.doc._id)}}function ga(a,b,c){if(a=a.filter(function(a){return ha(a.doc,b.selector,c)}),b.sort){var d=fa(b.sort);a=a.sort(d),"string"!=typeof b.sort[0]&&"desc"===M(b.sort[0])&&(a=a.reverse())}if("limit"in b||"skip"in b){var e=b.skip||0,f=("limit"in b?b.limit:a.length)+e;a=a.slice(e,f)}return a}function ha(a,b,c){return c.every(function(c){var d=b[c],e=J(c),f=G(a,e);return K(c)?ja(c,d,a):ia(d,a,e,f)})}function ia(a,b,c,d){return!a||Object.keys(a).every(function(e){var f=a[e];return ka(e,b,f,c,d)})}function ja(a,b,c){return"$or"===a?b.some(function(a){return ha(c,a,Object.keys(a))}):"$not"===a?!ha(c,b,Object.keys(b)):!b.find(function(a){return ha(c,a,Object.keys(a))})}function ka(a,b,c,d,e){if(!ic[a])throw new Error('unknown operator "'+a+'" - should be one of $eq, $lte, $lt, $gt, $gte, $exists, $ne, $in, $nin, $size, $mod, $regex, $elemMatch, $type, $allMatch or $all');return ic[a](b,c,d,e)}function la(a){return void 0!==a&&null!==a}function ma(a){return void 0!==a}function na(a,b){var c=b[0],d=b[1];if(0===c)throw new Error("Bad divisor, cannot divide by zero");if(parseInt(c,10)!==c)throw new Error("Divisor is not an integer");if(parseInt(d,10)!==d)throw new Error("Modulus is not an integer");return parseInt(a,10)===a&&a%c===d}function oa(a,b){return b.some(function(b){return a instanceof Array?a.indexOf(b)>-1:a===b})}function pa(a,b){return b.every(function(b){return a.indexOf(b)>-1})}function qa(a,b){return a.length===b}function ra(a,b){return new RegExp(b).test(a)}function sa(a,b){switch(b){case"null":return null===a;case"boolean":return"boolean"==typeof a;case"number":return"number"==typeof a;case"string":return"string"==typeof a;case"array":return a instanceof Array;case"object":return"[object Object]"==={}.toString.call(a)}throw new Error(b+" not supported as a type.Please use one of object, string, array, number, boolean or null.")}function ta(a){return function(){for(var b=arguments.length,c=new Array(b),d=-1;++d<b;)c[d]=arguments[d];return a.call(this,c)}}function ua(a){return ta(function(b){var c=b.pop(),d=a.apply(this,b);return va(d,c),d})}function va(a,c){return a.then(function(a){b.nextTick(function(){c(null,a)})},function(a){b.nextTick(function(){c(a)})}),a}function wa(a){for(var b={},c=0,d=a.length;c<d;c++)b=cc(b,a[c]);return b}function xa(a,b){for(var c={},d=0,e=b.length;d<e;d++){var f=J(b[d]),g=G(a,f);void 0!==g&&H(c,f,g)}return c}function ya(a,b){for(var c=0,d=Math.min(a.length,b.length);c<d;c++)if(a[c]!==b[c])return!1;return!0}function za(a,b){return!(a.length>b.length)&&ya(a,b)}function Aa(a,b){a=a.slice();for(var c=0,d=b.length;c<d;c++){var e=b[c];if(!a.length)break;var f=a.indexOf(e);if(-1===f)return!1;a.splice(f,1)}return!0}function Ba(a){
  for(var b={},c=0,d=a.length;c<d;c++)b[a[c]]=!0;return b}function Ca(a,b){for(var c=null,d=-1,e=0,f=a.length;e<f;e++){var g=a[e],h=b(g);h>d&&(d=h,c=g)}return c}function Da(a,b){if(a.length!==b.length)return!1;for(var c=0,d=a.length;c<d;c++)if(a[c]!==b[c])return!1;return!0}function Ea(a){for(var b={},c=0;c<a.length;c++)b["$"+a[c]]=!0;return Object.keys(b).map(function(a){return a.substring(1)})}function Fa(a,b){a=a||[],b=b||{};try{return new Blob(a,b)}catch(f){if("TypeError"!==f.name)throw f;for(var c="undefined"!=typeof BlobBuilder?BlobBuilder:"undefined"!=typeof MSBlobBuilder?MSBlobBuilder:"undefined"!=typeof MozBlobBuilder?MozBlobBuilder:WebKitBlobBuilder,d=new c,e=0;e<a.length;e+=1)d.append(a[e]);return d.getBlob(b.type)}}function Ga(a){for(var b=a.length,c=new ArrayBuffer(b),d=new Uint8Array(c),e=0;e<b;e++)d[e]=a.charCodeAt(e);return c}function Ha(a,b){return Fa([Ga(a)],{type:b})}function Ia(a,b){return Ha(kc(a),b)}function Ja(){this.promise=new Xb(function(a){a()})}function Ka(a){return Wb.hash(a)}function La(a){if(!a)return"undefined";switch(typeof a){case"function":case"string":return a.toString();default:return JSON.stringify(a)}}function Ma(a,b){return La(a)+La(b)+"undefined"}function Na(a,b,c,d,e,f){var g,h=Ma(c,d);if(!e&&(g=a._cachedViews=a._cachedViews||{},g[h]))return g[h];var i=a.info().then(function(i){function j(a){a.views=a.views||{};var c=b;-1===c.indexOf("/")&&(c=b+"/"+b);var d=a.views[c]=a.views[c]||{};if(!d[k])return d[k]=!0,a}var k=i.db_name+"-mrview-"+(e?"temp":Ka(h));return y(a,"_local/"+f,j).then(function(){return a.registerDependentDatabase(k).then(function(b){var e=b.db;e.auto_compaction=!0;var f={name:k,db:e,sourceDB:a,adapter:a.adapter,mapFun:c,reduceFun:d};return f.db.get("_local/lastSeq").catch(function(a){if(404!==a.status)throw a}).then(function(a){return f.seq=a?a.seq:0,g&&f.db.once("destroyed",function(){delete g[h]}),f})})})});return g&&(g[h]=i),i}function Oa(a){this.status=400,this.name="query_parse_error",this.message=a,this.error=!0;try{Error.captureStackTrace(this,Oa)}catch(a){}}function Pa(a){this.status=404,this.name="not_found",this.message=a,this.error=!0;try{Error.captureStackTrace(this,Pa)}catch(a){}}function Qa(a){this.status=500,this.name="invalid_value",this.message=a,this.error=!0;try{Error.captureStackTrace(this,Qa)}catch(a){}}function Ra(a,b){return b&&a.then(function(a){Vb(function(){b(null,a)})},function(a){Vb(function(){b(a)})}),a}function Sa(a){return Sb(function(b){var c=b.pop(),d=a.apply(this,b);return"function"==typeof c&&Ra(d,c),d})}function Ta(a,b){return a.then(function(a){return b().then(function(){return a})},function(a){return b().then(function(){throw a})})}function Ua(a,b){return function(){var c=arguments,d=this;return a.add(function(){return b.apply(d,c)})}}function Va(a){var b=new $b(a),c=new Array(b.size),d=-1;return b.forEach(function(a){c[++d]=a}),c}function Wa(a){var b=new Array(a.size),c=-1;return a.forEach(function(a,d){b[++c]=d}),b}function Xa(a){return-1===a.indexOf("/")?[a,a]:a.split("/")}function Ya(a){return 1===a.length&&/^1-/.test(a[0].rev)}function Za(a,b){try{a.emit("error",b)}catch(a){t("error","The user's map/reduce function threw an uncaught error.\nYou can debug this error by doing:\nmyDatabase.on('error', function (err) { debugger; });\nPlease double-check your map/reduce function."),t("error",b)}}function $a(a,b){return function(c){for(var d=[],e=0,f=a.length;e<f;e++){for(var g=J(a[e]),h=c,i=0,j=g.length;i<j;i++){if(!(h=h[g[i]]))return}d.push(h)}b(d)}}function _a(a,b){var c=J(a);return function(a){for(var d=a,e=0,f=c.length;e<f;e++){if(!(d=d[c[e]]))return}b(d)}}function ab(a,b){return function(c){b(c[a])}}function bb(a,b){return function(c){for(var d=[],e=0,f=a.length;e<f;e++)d.push(c[a[e]]);b(d)}}function cb(a){for(var b=0,c=a.length;b<c;b++){if(-1!==a[b].indexOf("."))return!1}return!0}function db(a,b){var c=cb(a),d=1===a.length;return c?d?ab(a[0],b):bb(a,b):d?_a(a[0],b):$a(a,b)}function eb(a,b){return db(Object.keys(a.fields),b)}function fb(){throw new Error("reduce not supported")}function gb(a,b){var c=a.views[b];if(!c.map||!c.map.fields)throw new Error("ddoc "+a._id+" with view "+b+" doesn't have map.fields defined. maybe it wasn't created by this plugin?")}function hb(a){if(!Array.isArray(a))throw new Error("invalid sort json - should be an array");return a.map(function(a){if("string"==typeof a){var b={};return b[a]="asc",b}return a})}function ib(a){var b=[];return"string"==typeof a?b.push(a):b=a,b.map(function(a){return a.replace("_design/","")})}function jb(a){return a.fields=a.fields.map(function(a){if("string"==typeof a){var b={};return b[a]="asc",b}return a}),a}function kb(a,b){for(var c=[],d=0;d<b.def.fields.length;d++){var e=L(b.def.fields[d]);c.push(a[e])}return c}function lb(a,b,c){for(var d=c.def.fields,e=0,f=a.length;e<f;e++){var g=a[e],h=kb(g.doc,c);if(1===d.length)h=h[0];else for(;h.length>b.length;)h.pop();if(Math.abs(V(h,b))>0)break}return e>0?a.slice(e):a}function mb(a){var b=h(a);return delete b.startkey,delete b.endkey,delete b.inclusive_start,delete b.inclusive_end,"endkey"in a&&(b.startkey=a.endkey),"startkey"in a&&(b.endkey=a.startkey),"inclusive_start"in a&&(b.inclusive_end=a.inclusive_start),"inclusive_end"in a&&(b.inclusive_start=a.inclusive_end),b}function nb(a){var b=a.fields.filter(function(a){return"asc"===M(a)});if(0!==b.length&&b.length!==a.fields.length)throw new Error("unsupported mixed sorting")}function ob(a,b){if(b.defaultUsed&&a.sort){var c=a.sort.filter(function(a){return"_id"!==Object.keys(a)[0]}).map(function(a){return Object.keys(a)[0]});if(c.length>0)throw new Error('Cannot sort on field(s) "'+c.join(",")+'" when using the default index')}b.defaultUsed}function pb(a){if("object"!=typeof a.selector)throw new Error("you must provide a selector when you find()")}function qb(a,b){var c,d=Object.keys(a),e=b?b.map(L):[];return c=d.length>=e.length?d:e,0===e.length?{fields:c}:(c=c.sort(function(a,b){var c=e.indexOf(a);-1===c&&(c=Number.MAX_VALUE);var d=e.indexOf(b);return-1===d&&(d=Number.MAX_VALUE),c<d?-1:c>d?1:0}),{fields:c,sortOrder:b.map(L)})}function rb(a,b){function c(){return f||(f=Ka(JSON.stringify(b)))}function d(a){return a._rev&&"query"!==a.language&&(k=!0),a.language="query",a.views=a.views||{},!(l=!!a.views[g])&&(a.views[g]={map:{fields:wa(b.index.fields)},reduce:"_count",options:{def:e}},a)}b=A(b);var e=h(b.index);b.index=jb(b.index),nb(b.index);var f,g=b.name||"idx-"+c(),i=b.ddoc||"idx-"+c(),j="_design/"+i,k=!1,l=!1;return a.constructor.emit("debug",["find","creating index",j]),y(a,j,d).then(function(){if(k)throw new Error('invalid language for ddoc with id "'+j+'" (should be "query")')}).then(function(){var b=i+"/"+g;return oc.query.call(a,b,{limit:0,reduce:!1}).then(function(){return{id:j,name:g,result:l?"exists":"created"}})})}function sb(a){return a.allDocs({startkey:"_design/",endkey:"_design/",include_docs:!0}).then(function(a){var b={indexes:[{ddoc:null,name:"_all_docs",type:"special",def:{fields:[{_id:"asc"}]}}]};return b.indexes=jc(b.indexes,a.rows.filter(function(a){return"query"===a.doc.language}).map(function(a){return(void 0!==a.doc.views?Object.keys(a.doc.views):[]).map(function(b){var c=a.doc.views[b];return{ddoc:a.id,name:b,type:"json",def:jb(c.options.def)}})})),b.indexes.sort(function(a,b){return I(a.name,b.name)}),b.total_rows=b.indexes.length,b})}function tb(a,b){for(var c=a.def.fields.map(L),d=0,e=c.length;d<e;d++){if(b===c[d])return!0}return!1}function ub(a,b){return"$eq"!==L(a[b])}function vb(a,b){var c=b.def.fields.map(L);return a.slice().sort(function(a,b){var d=c.indexOf(a),e=c.indexOf(b);return-1===d&&(d=Number.MAX_VALUE),-1===e&&(e=Number.MAX_VALUE),I(d,e)})}function wb(a,b,c){c=vb(c,a);for(var d=!1,e=0,f=c.length;e<f;e++){var g=c[e];if(d||!tb(a,g))return c.slice(e);e<f-1&&ub(b,g)&&(d=!0)}return[]}function xb(a){var b=[];return Object.keys(a).forEach(function(c){var d=a[c];Object.keys(d).forEach(function(a){"$ne"===a&&b.push(c)})}),b}function yb(a,b,c,d){return vb(Ea(jc(a,wb(b,c,d),xb(c))),b)}function zb(a,b,c){if(b){var d=za(b,a),e=ya(c,a);return d&&e}return Aa(c,a)}function Ab(a){return-1===rc.indexOf(a)}function Bb(a,b){var c=a[0],d=b[c];return void 0===d||!!Object.keys(d).some(function(a){return!Ab(a)})&&!(1===Object.keys(d).length&&"$ne"===L(d))}function Cb(a,b,c,d){var e=a.def.fields.map(L);return!!zb(e,b,c)&&Bb(e,d)}function Db(a,b,c,d){return d.reduce(function(d,e){return Cb(e,c,b,a)&&d.push(e),d},[])}function Eb(a,b,c,d,e){function f(a){for(var b=a.def.fields.map(L),c=0,d=0,e=b.length;d<e;d++){var f=b[d];i[f]&&c++}return c}var g=Db(a,b,c,d);if(0===g.length){if(e)throw{error:"no_usable_index",message:"There is no index available for this selector."};var h=d[0];return h.defaultUsed=!0,h}if(1===g.length&&!e)return g[0];var i=Ba(b);if(e){var j="_design/"+e[0],k=2===e.length&&e[1],l=g.find(function(a){return!(!k||a.ddoc!==j||k!==a.name)||a.ddoc===j});if(!l)throw{error:"unknown_error",message:"Could not find that index or could not use that index for the query"};return l}return Ca(g,f)}function Fb(a,b){switch(a){case"$eq":return{key:b};case"$lte":return{endkey:b};case"$gte":return{startkey:b};case"$lt":return{endkey:b,inclusive_end:!1};case"$gt":return{startkey:b,inclusive_start:!1}}}function Gb(a,b){var c,d=L(b.def.fields[0]),e=a[d]||{},f=[],g=Object.keys(e);return g.forEach(function(a){if(Ab(a))return void f.push(d);var b=e[a],g=Fb(a,b);c=c?wa([c,g]):g}),{queryOpts:c,inMemoryFields:f}}function Hb(a,b){switch(a){case"$eq":return{startkey:b,endkey:b};case"$lte":return{endkey:b};case"$gte":return{startkey:b};case"$lt":return{endkey:b,inclusive_end:!1};case"$gt":return{startkey:b,inclusive_start:!1}}}function Ib(a,b){function c(a){!1!==d&&h.push(pc),!1!==e&&i.push(qc),g=f.slice(a)}for(var d,e,f=b.def.fields.map(L),g=[],h=[],i=[],j=0,k=f.length;j<k;j++){var l=f[j],m=a[l];if(!m||!Object.keys(m).length){c(j);break}if(j>0){if(Object.keys(m).some(Ab)){c(j);break}var n="$gt"in m||"$gte"in m||"$lt"in m||"$lte"in m,o=Object.keys(a[f[j-1]]),p=Da(o,["$eq"]),q=Da(o,Object.keys(m));if(n&&!p&&!q){c(j);break}}for(var r=Object.keys(m),s=null,t=0;t<r.length;t++){var u=r[t],v=m[u],w=Hb(u,v);s=s?wa([s,w]):w}h.push("startkey"in s?s.startkey:pc),i.push("endkey"in s?s.endkey:qc),"inclusive_start"in s&&(d=s.inclusive_start),"inclusive_end"in s&&(e=s.inclusive_end)}var x={startkey:h,endkey:i};return void 0!==d&&(x.inclusive_start=d),void 0!==e&&(x.inclusive_end=e),{queryOpts:x,inMemoryFields:g}}function Jb(a){return{queryOpts:{startkey:null},inMemoryFields:[Object.keys(a)]}}function Kb(a,b){return b.defaultUsed?Jb(a,b):1===b.def.fields.length?Gb(a,b):Ib(a,b)}function Lb(a,b){var c=a.selector,d=a.sort,e=qb(c,d),f=e.fields,g=e.sortOrder,h=Eb(c,f,g,b,a.use_index),i=Kb(c,h);return{queryOpts:i.queryOpts,index:h,inMemoryFields:yb(i.inMemoryFields,h,c,f)}}function Mb(a){return a.ddoc.substring(8)+"/"+a.name}function Nb(a,b){var c=h(b);return c.descending?("endkey"in c&&"string"!=typeof c.endkey&&(c.endkey=""),"startkey"in c&&"string"!=typeof c.startkey&&(c.limit=0)):("startkey"in c&&"string"!=typeof c.startkey&&(c.startkey=""),"endkey"in c&&"string"!=typeof c.endkey&&(c.limit=0)),"key"in c&&"string"!=typeof c.key&&(c.limit=0),a.allDocs(c).then(function(a){return a.rows=a.rows.filter(function(a){return!/^_design\//.test(a.id)}),a})}function Ob(a,b,c){return b.selector&&(b.selector=S(b.selector)),b.sort&&(b.sort=hb(b.sort)),b.use_index&&(b.use_index=ib(b.use_index)),pb(b),sb(a).then(function(d){a.constructor.emit("debug",["find","planning query",b]);var e=Lb(b,d.indexes);a.constructor.emit("debug",["find","query plan",e]);var f=e.index;ob(b,f);var g=cc({include_docs:!0,reduce:!1},e.queryOpts);return"startkey"in g&&"endkey"in g&&V(g.startkey,g.endkey)>0?{docs:[]}:(b.sort&&"string"!=typeof b.sort[0]&&"desc"===M(b.sort[0])&&(g.descending=!0,g=mb(g)),e.inMemoryFields.length||("limit"in b&&(g.limit=b.limit),"skip"in b&&(g.skip=b.skip)),c?Xb.resolve(e,g):Xb.resolve().then(function(){if("_all_docs"===f.name)return Nb(a,g);var b=Mb(f);return oc.query.call(a,b,g)}).then(function(a){!1===g.inclusive_start&&(a.rows=lb(a.rows,g.startkey,f)),e.inMemoryFields.length&&(a.rows=ga(a.rows,b,e.inMemoryFields));var c={docs:a.rows.map(function(a){var c=a.doc;return b.fields?xa(c,b.fields):c})};return f.defaultUsed&&(c.warning="no matching index found, create an index to optimize query time"),c}))})}function Pb(a,b){return Ob(a,b,!0).then(function(c){return{dbname:a.name,index:c.index,selector:b.selector,range:{start_key:c.queryOpts.startkey,end_key:c.queryOpts.endkey},opts:{use_index:b.use_index||[],bookmark:"nil",limit:b.limit,skip:b.skip,sort:b.sort||{},fields:b.fields,conflicts:!1,r:[49]},limit:b.limit,skip:b.skip||0,fields:b.fields}})}function Qb(a,b){function c(a){return 1===Object.keys(a.views).length&&a.views[e]?{_id:d,_deleted:!0}:(delete a.views[e],a)}if(!b.ddoc)throw new Error("you must supply an index.ddoc when deleting");if(!b.name)throw new Error("you must supply an index.name when deleting");var d=b.ddoc,e=b.name;return y(a,d,c).then(function(){return oc.viewCleanup.apply(a)}).then(function(){return{ok:!0}})}var Rb=(c(a(8)),c(a(5))),Sb=c(a(1)),Tb=a(2),Ub=c(a(4)),Vb=c(a(3)),Wb=c(a(7)),Xb="function"==typeof Promise?Promise:Rb,Yb=Function.prototype.toString,Zb=Yb.call(Object);m.prototype.get=function(a){var b=k(a);return this._store[b]},m.prototype.set=function(a,b){var c=k(a);return this._store[c]=b,!0},m.prototype.has=function(a){return k(a)in this._store},m.prototype.delete=function(a){var b=k(a),c=b in this._store;return delete this._store[b],c},m.prototype.forEach=function(a){for(var b=Object.keys(this._store),c=0,d=b.length;c<d;c++){var e=b[c],f=this._store[e];e=l(e),a(f,e)}},Object.defineProperty(m.prototype,"size",{get:function(){return Object.keys(this._store).length}}),n.prototype.add=function(a){return this._store.set(a,!0)},n.prototype.has=function(a){return this._store.has(a)},n.prototype.forEach=function(a){this._store.forEach(function(b,c){a(c)})},Object.defineProperty(n.prototype,"size",{get:function(){return this._store.size}});var $b,_b;!function(){if("undefined"==typeof Symbol||"undefined"==typeof Map||"undefined"==typeof Set)return!1;var a=Object.getOwnPropertyDescriptor(Map,Symbol.species);return a&&"get"in a&&Map[Symbol.species]===Map}()?($b=n,_b=m):($b=Set,_b=Map);var ac;if(p())ac=!1;else try{localStorage.setItem("_pouch_check_localstorage",1),ac=!!localStorage.getItem("_pouch_check_localstorage")}catch(a){ac=!1}Ub(s,Tb.EventEmitter),s.prototype.addListener=function(a,b,c,d){function e(){function a(){g=!1}if(f._listeners[b]){if(g)return void(g="waiting");g=!0;var h=o(d,["style","include_docs","attachments","conflicts","filter","doc_ids","view","since","query_params","binary"]);c.changes(h).on("change",function(a){a.seq>d.since&&!d.cancelled&&(d.since=a.seq,d.onChange(a))}).on("complete",function(){"waiting"===g&&Vb(e),g=!1}).on("error",a)}}if(!this._listeners[b]){var f=this,g=!1;this._listeners[b]=e,this.on(a,e)}},s.prototype.removeListener=function(a,b){b in this._listeners&&(Tb.EventEmitter.prototype.removeListener.call(this,a,this._listeners[b]),delete this._listeners[b])},s.prototype.notifyLocalWindows=function(a){p()?chrome.storage.local.set({dbName:a}):q()&&(localStorage[a]="a"===localStorage[a]?"b":"a")},s.prototype.notify=function(a){this.emit(a),this.notifyLocalWindows(a)};var bc;bc="function"==typeof Object.assign?Object.assign:function(a){for(var b=Object(a),c=1;c<arguments.length;c++){var d=arguments[c];if(null!=d)for(var e in d)Object.prototype.hasOwnProperty.call(d,e)&&(b[e]=d[e])}return b};var cc=bc;Ub(u,Error),u.prototype.toString=function(){return JSON.stringify({status:this.status,name:this.name,message:this.message,reason:this.reason})};var dc=(new u(401,"unauthorized","Name or password is incorrect."),new u(400,"bad_request","Missing JSON list of 'docs'"),new u(404,"not_found","missing"),new u(409,"conflict","Document update conflict"),new u(400,"bad_request","_id field must contain a string"),new u(412,"missing_id","_id is required for puts"),new u(400,"bad_request","Only reserved document ids may start with underscore."),new u(412,"precondition_failed","Database not open"),new u(500,"unknown_error","Database encountered an unknown error"),new u(500,"badarg","Some query argument is invalid"),new u(400,"invalid_request","Request was invalid"),new u(400,"query_parse_error","Some query parameter is invalid"),new u(500,"doc_validation","Bad special document member"),new u(400,"bad_request","Something wrong with the request"),new u(400,"bad_request","Document must be a JSON object"),new u(404,"not_found","Database not found"),new u(500,"indexed_db_went_bad","unknown"),new u(500,"web_sql_went_bad","unknown"),new u(500,"levelDB_went_went_bad","unknown"),new u(403,"forbidden","Forbidden by design doc validate_doc_update function"),new u(400,"bad_request","Invalid rev format"),new u(412,"file_exists","The database could not be created, the file already exists."),new u(412,"missing_stub","A pre-existing attachment stub wasn't found"),new u(413,"invalid_url","Provided URL is invalid"),w.name);var ec=["$or","$nor","$not"],fc=-324,gc=3,hc="",ic={$elemMatch:function(a,b,c,d){return!!Array.isArray(d)&&(0!==d.length&&("object"==typeof d[0]?d.some(function(a){return ha(a,b,Object.keys(b))}):d.some(function(d){return ia(b,a,c,d)})))},$allMatch:function(a,b,c,d){return!!Array.isArray(d)&&(0!==d.length&&("object"==typeof d[0]?d.every(function(a){return ha(a,b,Object.keys(b))}):d.every(function(d){return ia(b,a,c,d)})))},$eq:function(a,b,c,d){return ma(d)&&0===V(d,b)},$gte:function(a,b,c,d){return ma(d)&&V(d,b)>=0},$gt:function(a,b,c,d){return ma(d)&&V(d,b)>0},$lte:function(a,b,c,d){return ma(d)&&V(d,b)<=0},$lt:function(a,b,c,d){return ma(d)&&V(d,b)<0},$exists:function(a,b,c,d){return b?ma(d):!ma(d)},$mod:function(a,b,c,d){return la(d)&&na(d,b)},$ne:function(a,b,c,d){return b.every(function(a){return 0!==V(d,a)})},$in:function(a,b,c,d){return la(d)&&oa(d,b)},$nin:function(a,b,c,d){return la(d)&&!oa(d,b)},$size:function(a,b,c,d){return la(d)&&qa(d,b)},$all:function(a,b,c,d){return Array.isArray(d)&&pa(d,b)},$regex:function(a,b,c,d){return la(d)&&ra(d,b)},$type:function(a,b,c,d){return sa(d,b)}},jc=ta(function(a){for(var b=[],c=0,d=a.length;c<d;c++){var e=a[c];Array.isArray(e)?b=b.concat(jc.apply(null,e)):b.push(e)}return b}),kc=function(a){return atob(a)};Ja.prototype.add=function(a){return this.promise=this.promise.catch(function(){}).then(function(){return a()}),this.promise},Ja.prototype.finish=function(){return this.promise},Ub(Oa,Error),Ub(Pa,Error),Ub(Qa,Error);var lc={},mc=new Ja,nc=50,oc=function(a,b,c,d){function e(a,b,c){try{b(c)}catch(b){Za(a,b)}}function f(a,b,c,d,e){try{return{output:b(c,d,e)}}catch(b){return Za(a,b),{error:b}}}function g(a,b){var c=V(a.key,b.key);return 0!==c?c:V(a.value,b.value)}function h(a,b,c){return c=c||0,"number"==typeof b?a.slice(c,b+c):c>0?a.slice(c):a}function i(a){var b=a.value;return b&&"object"==typeof b&&b._id||a.id}function j(a){a.rows.forEach(function(a){var b=a.doc&&a.doc._attachments;b&&Object.keys(b).forEach(function(a){var c=b[a];b[a].data=Ia(c.data,c.content_type)})})}function k(a){return function(b){return a.include_docs&&a.attachments&&a.binary&&j(b),b}}function l(a,b,c,d){var e=b[a];void 0!==e&&(d&&(e=encodeURIComponent(JSON.stringify(e))),c.push(a+"="+e))}function m(a){if(void 0!==a){var b=Number(a);return isNaN(b)||b!==parseInt(a,10)?a:b}}function n(a){return a.group_level=m(a.group_level),a.limit=m(a.limit),a.skip=m(a.skip),a}function o(a){if(a){if("number"!=typeof a)return new Oa('Invalid value for integer: "'+a+'"');if(a<0)return new Oa('Invalid value for positive integer: "'+a+'"')}}function p(a,b){var c=a.descending?"endkey":"startkey",d=a.descending?"startkey":"endkey";if(void 0!==a[c]&&void 0!==a[d]&&V(a[c],a[d])>0)throw new Oa("No rows can match your key range, reverse your start_key and end_key or set {descending : true}");if(b.reduce&&!1!==a.reduce){if(a.include_docs)throw new Oa("{include_docs:true} is invalid for reduce");if(a.keys&&a.keys.length>1&&!a.group&&!a.group_level)throw new Oa("Multi-key fetches for reduce views must use {group: true}")}["group_level","limit","skip"].forEach(function(b){var c=o(a[b]);if(c)throw c})}function q(a,b,c){var d,e=[],f="GET";if(l("reduce",c,e),l("include_docs",c,e),l("attachments",c,e),l("limit",c,e),l("descending",c,e),l("group",c,e),l("group_level",c,e),l("skip",c,e),l("stale",c,e),l("conflicts",c,e),l("startkey",c,e,!0),l("start_key",c,e,!0),l("endkey",c,e,!0),l("end_key",c,e,!0),l("inclusive_end",c,e),l("key",c,e,!0),e=e.join("&"),e=""===e?"":"?"+e,void 0!==c.keys){var g="keys="+encodeURIComponent(JSON.stringify(c.keys));g.length+e.length+1<=2e3?e+=("?"===e[0]?"&":"?")+g:(f="POST","string"==typeof b?d={keys:c.keys}:b.keys=c.keys)}if("string"==typeof b){var h=Xa(b);return a.request({method:f,url:"_design/"+h[0]+"/_view/"+h[1]+e,body:d}).then(function(a){return a.rows.forEach(function(a){if(a.value&&a.value.error&&"builtin_reduce_error"===a.value.error)throw new Error(a.reason)}),a}).then(k(c))}return d=d||{},Object.keys(b).forEach(function(a){Array.isArray(b[a])?d[a]=b[a]:d[a]=b[a].toString()}),a.request({method:"POST",url:"_temp_view"+e,body:d}).then(k(c))}function r(a,b,c){return new Xb(function(d,e){a._query(b,c,function(a,b){if(a)return e(a);d(b)})})}function s(a){return new Xb(function(b,c){a._viewCleanup(function(a,d){if(a)return c(a);b(d)})})}function t(a){return function(b){if(404===b.status)return a;throw b}}function u(a,b,c){function d(a){return a.keys.length?b.db.allDocs({keys:a.keys,include_docs:!0}):Xb.resolve({rows:[]})}function e(a,b){for(var c=[],d=new $b,e=0,f=b.rows.length;e<f;e++){var g=b.rows[e],h=g.doc;if(h&&(c.push(h),d.add(h._id),h._deleted=!i.has(h._id),!h._deleted)){var j=i.get(h._id);"value"in j&&(h.value=j.value)}}var k=Wa(i);return k.forEach(function(a){if(!d.has(a)){var b={_id:a},e=i.get(a);"value"in e&&(b.value=e.value),c.push(b)}}),a.keys=Va(k.concat(a.keys)),c.push(a),c}var f="_local/doc_"+a,g={_id:f,keys:[]},h=c.get(a),i=h[0],j=h[1];return function(){return Ya(j)?Xb.resolve(g):b.db.get(f).catch(t(g))}().then(function(a){return d(a).then(function(b){return e(a,b)})})}function w(a,b,c){return a.db.get("_local/lastSeq").catch(t({_id:"_local/lastSeq",seq:0})).then(function(d){var e=Wa(b);return Xb.all(e.map(function(c){return u(c,a,b)})).then(function(b){var e=v(b);return d.seq=c,e.push(d),a.db.bulkDocs({docs:e})})})}function y(a){var b="string"==typeof a?a:a.name,c=lc[b];return c||(c=lc[b]=new Ja),c}function z(a){return Ua(y(a),function(){return A(a)})()}function A(a){function c(a,b){var c={id:l._id,key:W(a)};void 0!==b&&null!==b&&(c.value=W(b)),k.push(c)}function d(b,c){return function(){return w(a,b,c)}}function f(){return a.sourceDB.changes({conflicts:!0,include_docs:!0,style:"all_docs",since:n,limit:nc}).then(h)}function h(a){var b=a.results;if(b.length){var c=i(b);if(o.add(d(c,n)),!(b.length<nc))return f()}}function i(b){for(var c=new _b,d=0,f=b.length;d<f;d++){var h=b[d];if("_"!==h.doc._id[0]){k=[],l=h.doc,l._deleted||e(a.sourceDB,m,l),k.sort(g);var i=j(k);c.set(h.doc._id,[i,h.changes])}n=h.seq}return c}function j(a){for(var b,c=new _b,d=0,e=a.length;d<e;d++){var f=a[d],g=[f.key,f.id];d>0&&0===V(f.key,b)&&g.push(d),c.set(Y(g),f),b=f.key}return c}var k,l,m=b(a.mapFun,c),n=a.seq||0,o=new Ja;return f().then(function(){return o.finish()}).then(function(){a.seq=n})}function B(a,b,d){0===d.group_level&&delete d.group_level;var e=d.group||d.group_level,g=c(a.reduceFun),i=[],j=isNaN(d.group_level)?Number.POSITIVE_INFINITY:d.group_level;b.forEach(function(a){var b=i[i.length-1],c=e?a.key:null;if(e&&Array.isArray(c)&&(c=c.slice(0,j)),b&&0===V(b.groupKey,c))return b.keys.push([a.key,a.id]),void b.values.push(a.value);i.push({keys:[[a.key,a.id]],values:[a.value],groupKey:c})}),b=[];for(var k=0,l=i.length;k<l;k++){var m=i[k],n=f(a.sourceDB,g,m.keys,m.values,!1);if(n.error&&n.error instanceof Qa)throw n.error;b.push({value:n.error?null:n.output,key:m.groupKey})}return{rows:h(b,d.limit,d.skip)}}function C(a,b){return Ua(y(a),function(){return D(a,b)})()}function D(a,b){function c(b){return b.include_docs=!0,a.db.allDocs(b).then(function(a){return e=a.total_rows,a.rows.map(function(a){if("value"in a.doc&&"object"==typeof a.doc.value&&null!==a.doc.value){var b=Object.keys(a.doc.value).sort(),c=["id","key","value"];if(!(b<c||b>c))return a.doc.value}var d=_(a.doc._id);return{key:d[0],id:d[1],value:"value"in a.doc?a.doc.value:null}})})}function d(c){var d;if(d=f?B(a,c,b):{total_rows:e,offset:g,rows:c},b.include_docs){var h=Va(c.map(i));return a.sourceDB.allDocs({keys:h,include_docs:!0,conflicts:b.conflicts,attachments:b.attachments,binary:b.binary}).then(function(a){var b=new _b;return a.rows.forEach(function(a){b.set(a.id,a.doc)}),c.forEach(function(a){var c=i(a),d=b.get(c);d&&(a.doc=d)}),d})}return d}var e,f=a.reduceFun&&!1!==b.reduce,g=b.skip||0;if(void 0===b.keys||b.keys.length||(b.limit=0,delete b.keys),void 0!==b.keys){var h=b.keys,j=h.map(function(a){return c({startkey:Y([a]),endkey:Y([a,{}])})});return Xb.all(j).then(v).then(d)}var k,l,m={descending:b.descending};if("start_key"in b&&(k=b.start_key),"startkey"in b&&(k=b.startkey),"end_key"in b&&(l=b.end_key),"endkey"in b&&(l=b.endkey),void 0!==k&&(m.startkey=Y(b.descending?[k,{}]:[k])),void 0!==l){var n=!1!==b.inclusive_end;b.descending&&(n=!n),m.endkey=Y(n?[l,{}]:[l])}if(void 0!==b.key){var o=Y([b.key]),p=Y([b.key,{}]);m.descending?(m.endkey=o,m.startkey=p):(m.startkey=o,m.endkey=p)}return f||("number"==typeof b.limit&&(m.limit=b.limit),m.skip=g),c(m).then(d)}function E(a){return a.request({method:"POST",url:"_view_cleanup"})}function F(b){return b.get("_local/"+a).then(function(a){var c=new _b;Object.keys(a.views).forEach(function(a){var b=Xa(a),d="_design/"+b[0],e=b[1],f=c.get(d);f||(f=new $b,c.set(d,f)),f.add(e)});var d={keys:Wa(c),include_docs:!0};return b.allDocs(d).then(function(d){var e={};d.rows.forEach(function(b){var d=b.key.substring(8);c.get(b.key).forEach(function(c){var f=d+"/"+c;a.views[f]||(f=c);var g=Object.keys(a.views[f]),h=b.doc&&b.doc.views&&b.doc.views[c];g.forEach(function(a){e[a]=e[a]||h})})});var f=Object.keys(e).filter(function(a){return!e[a]}),g=f.map(function(a){return Ua(y(a),function(){return new b.constructor(a,b.__opts).destroy()})()});return Xb.all(g).then(function(){return{ok:!0}})})},t({ok:!0}))}function G(b,c,e){if("function"==typeof b._query)return r(b,c,e);if(x(b))return q(b,c,e);if("string"!=typeof c)return p(e,c),mc.add(function(){return Na(b,"temp_view/temp_view",c.map,c.reduce,!0,a).then(function(a){return Ta(z(a).then(function(){return C(a,e)}),function(){return a.db.destroy()})})}),mc.finish();var f=c,g=Xa(f),h=g[0],i=g[1];return b.get("_design/"+h).then(function(c){var g=c.views&&c.views[i];if(!g)throw new Pa("ddoc "+c._id+" has no view named "+i);return d(c,i),p(e,g),Na(b,f,g.map,g.reduce,!1,a).then(function(a){return"ok"===e.stale||"update_after"===e.stale?("update_after"===e.stale&&Vb(function(){z(a)}),C(a,e)):z(a).then(function(){return C(a,e)})})})}function H(a,b,c){var d=this;"function"==typeof b&&(c=b,b={}),b=b?n(b):{},"function"==typeof a&&(a={map:a});var e=Xb.resolve().then(function(){return G(d,a,b)});return Ra(e,c),e}return{query:H,viewCleanup:Sa(function(){var a=this;return"function"==typeof a._viewCleanup?s(a):x(a)?E(a):F(a)})}}("indexes",eb,fb,gb),pc=null,qc={"":{}},rc=["$eq","$gt","$gte","$lt","$lte"],sc=ua(rb),tc=ua(Ob),uc=ua(Pb),vc=ua(sb),wc=ua(Qb),xc={};xc.createIndex=j(function(a,b){if("object"!=typeof a)return b(new Error("you must provide an index to create"));(x(this)?B:sc)(this,a,b)}),xc.find=j(function(a,b){if(void 0===b&&(b=a,a=void 0),"object"!=typeof a)return b(new Error("you must provide search parameters to find()"));(x(this)?C:tc)(this,a,b)}),xc.explain=j(function(a,b){if(void 0===b&&(b=a,a=void 0),"object"!=typeof a)return b(new Error("you must provide search parameters to explain()"));(x(this)?D:uc)(this,a,b)}),xc.getIndexes=j(function(a){(x(this)?E:vc)(this,a)}),xc.deleteIndex=j(function(a,b){if("object"!=typeof a)return b(new Error("you must provide an index to delete"));(x(this)?F:wc)(this,a,b)}),"undefined"==typeof PouchDB?t("error",'pouchdb-find plugin error: Cannot find global "PouchDB" object! Did you remember to include pouchdb.js?'):PouchDB.plugin(xc)}).call(this,a(6))},{1:1,2:2,3:3,4:4,5:5,6:6,7:7,8:8}]},{},[13]);
  //# sourceMappingURL=pouchdb.find.js.map