UNPKG

59.5 kBJavaScriptView Raw
1// PouchDB indexeddb plugin 9.0.0
2!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){return o(t[s][1][e]||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){var r=Object.create||function(e){var t=function(){};return t.prototype=e,new t},o=Object.keys||function(e){var t=[];for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.push(n);return n},i=Function.prototype.bind||function(e){var t=this;return function(){return t.apply(e,arguments)}};function s(){this._events&&Object.prototype.hasOwnProperty.call(this,"_events")||(this._events=r(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0}t.exports=s,s.EventEmitter=s,s.prototype._events=void 0,s.prototype._maxListeners=void 0;var a,u=10;try{var c={};Object.defineProperty&&Object.defineProperty(c,"x",{value:0}),a=0===c.x}catch(e){a=!1}function f(e){return void 0===e._maxListeners?s.defaultMaxListeners:e._maxListeners}function l(e,t,n){if(t)e.call(n);else for(var r=e.length,o=w(e,r),i=0;i<r;++i)o[i].call(n)}function d(e,t,n,r){if(t)e.call(n,r);else for(var o=e.length,i=w(e,o),s=0;s<o;++s)i[s].call(n,r)}function h(e,t,n,r,o){if(t)e.call(n,r,o);else for(var i=e.length,s=w(e,i),a=0;a<i;++a)s[a].call(n,r,o)}function p(e,t,n,r,o,i){if(t)e.call(n,r,o,i);else for(var s=e.length,a=w(e,s),u=0;u<s;++u)a[u].call(n,r,o,i)}function v(e,t,n,r){if(t)e.apply(n,r);else for(var o=e.length,i=w(e,o),s=0;s<o;++s)i[s].apply(n,r)}function _(e,t,n,o){var i,s,a;if("function"!=typeof n)throw new TypeError('"listener" argument must be a function');if((s=e._events)?(s.newListener&&(e.emit("newListener",t,n.listener?n.listener:n),s=e._events),a=s[t]):(s=e._events=r(null),e._eventsCount=0),a){if("function"==typeof a?a=s[t]=o?[n,a]:[a,n]:o?a.unshift(n):a.push(n),!a.warned&&(i=f(e))&&i>0&&a.length>i){a.warned=!0;var u=new Error("Possible EventEmitter memory leak detected. "+a.length+' "'+String(t)+'" listeners added. Use emitter.setMaxListeners() to increase limit.');u.name="MaxListenersExceededWarning",u.emitter=e,u.type=t,u.count=a.length,"object"==typeof console&&console.warn&&console.warn("%s: %s",u.name,u.message)}}else a=s[t]=n,++e._eventsCount;return e}function y(){if(!this.fired)switch(this.target.removeListener(this.type,this.wrapFn),this.fired=!0,arguments.length){case 0:return this.listener.call(this.target);case 1:return this.listener.call(this.target,arguments[0]);case 2:return this.listener.call(this.target,arguments[0],arguments[1]);case 3:return this.listener.call(this.target,arguments[0],arguments[1],arguments[2]);default:for(var e=new Array(arguments.length),t=0;t<e.length;++t)e[t]=arguments[t];this.listener.apply(this.target,e)}}function m(e,t,n){var r={fired:!1,wrapFn:void 0,target:e,type:t,listener:n},o=i.call(y,r);return o.listener=n,r.wrapFn=o,o}function g(e,t,n){var r=e._events;if(!r)return[];var o=r[t];return o?"function"==typeof o?n?[o.listener||o]:[o]:n?function(e){for(var t=new Array(e.length),n=0;n<t.length;++n)t[n]=e[n].listener||e[n];return t}(o):w(o,o.length):[]}function b(e){var t=this._events;if(t){var n=t[e];if("function"==typeof n)return 1;if(n)return n.length}return 0}function w(e,t){for(var n=new Array(t),r=0;r<t;++r)n[r]=e[r];return n}a?Object.defineProperty(s,"defaultMaxListeners",{enumerable:!0,get:function(){return u},set:function(e){if("number"!=typeof e||e<0||e!=e)throw new TypeError('"defaultMaxListeners" must be a positive number');u=e}}):s.defaultMaxListeners=u,s.prototype.setMaxListeners=function(e){if("number"!=typeof e||e<0||isNaN(e))throw new TypeError('"n" argument must be a positive number');return this._maxListeners=e,this},s.prototype.getMaxListeners=function(){return f(this)},s.prototype.emit=function(e){var t,n,r,o,i,s,a="error"===e;if(s=this._events)a=a&&null==s.error;else if(!a)return!1;if(a){if(arguments.length>1&&(t=arguments[1]),t instanceof Error)throw t;var u=new Error('Unhandled "error" event. ('+t+")");throw u.context=t,u}if(!(n=s[e]))return!1;var c="function"==typeof n;switch(r=arguments.length){case 1:l(n,c,this);break;case 2:d(n,c,this,arguments[1]);break;case 3:h(n,c,this,arguments[1],arguments[2]);break;case 4:p(n,c,this,arguments[1],arguments[2],arguments[3]);break;default:for(o=new Array(r-1),i=1;i<r;i++)o[i-1]=arguments[i];v(n,c,this,o)}return!0},s.prototype.addListener=function(e,t){return _(this,e,t,!1)},s.prototype.on=s.prototype.addListener,s.prototype.prependListener=function(e,t){return _(this,e,t,!0)},s.prototype.once=function(e,t){if("function"!=typeof t)throw new TypeError('"listener" argument must be a function');return this.on(e,m(this,e,t)),this},s.prototype.prependOnceListener=function(e,t){if("function"!=typeof t)throw new TypeError('"listener" argument must be a function');return this.prependListener(e,m(this,e,t)),this},s.prototype.removeListener=function(e,t){var n,o,i,s,a;if("function"!=typeof t)throw new TypeError('"listener" argument must be a function');if(!(o=this._events))return this;if(!(n=o[e]))return this;if(n===t||n.listener===t)0==--this._eventsCount?this._events=r(null):(delete o[e],o.removeListener&&this.emit("removeListener",e,n.listener||t));else if("function"!=typeof n){for(i=-1,s=n.length-1;s>=0;s--)if(n[s]===t||n[s].listener===t){a=n[s].listener,i=s;break}if(i<0)return this;0===i?n.shift():function(e,t){for(var n=t,r=n+1,o=e.length;r<o;n+=1,r+=1)e[n]=e[r];e.pop()}(n,i),1===n.length&&(o[e]=n[0]),o.removeListener&&this.emit("removeListener",e,a||t)}return this},s.prototype.removeAllListeners=function(e){var t,n,i;if(!(n=this._events))return this;if(!n.removeListener)return 0===arguments.length?(this._events=r(null),this._eventsCount=0):n[e]&&(0==--this._eventsCount?this._events=r(null):delete n[e]),this;if(0===arguments.length){var s,a=o(n);for(i=0;i<a.length;++i)"removeListener"!==(s=a[i])&&this.removeAllListeners(s);return this.removeAllListeners("removeListener"),this._events=r(null),this._eventsCount=0,this}if("function"==typeof(t=n[e]))this.removeListener(e,t);else if(t)for(i=t.length-1;i>=0;i--)this.removeListener(e,t[i]);return this},s.prototype.listeners=function(e){return g(this,e,!0)},s.prototype.rawListeners=function(e){return g(this,e,!1)},s.listenerCount=function(e,t){return"function"==typeof e.listenerCount?e.listenerCount(t):b.call(e,t)},s.prototype.listenerCount=b,s.prototype.eventNames=function(){return this._eventsCount>0?Reflect.ownKeys(this._events):[]}},{}],2:[function(e,t,n){!function(e){if("object"==typeof n)t.exports=e();else if("function"==typeof define&&define.amd)define(e);else{var r;try{r=window}catch(e){r=self}r.SparkMD5=e()}}((function(e){"use strict";var t=["0","1","2","3","4","5","6","7","8","9","a","b","c","d","e","f"];function n(e,t){var n=e[0],r=e[1],o=e[2],i=e[3];r=((r+=((o=((o+=((i=((i+=((n=((n+=(r&o|~r&i)+t[0]-680876936|0)<<7|n>>>25)+r|0)&r|~n&o)+t[1]-389564586|0)<<12|i>>>20)+n|0)&n|~i&r)+t[2]+606105819|0)<<17|o>>>15)+i|0)&i|~o&n)+t[3]-1044525330|0)<<22|r>>>10)+o|0,r=((r+=((o=((o+=((i=((i+=((n=((n+=(r&o|~r&i)+t[4]-176418897|0)<<7|n>>>25)+r|0)&r|~n&o)+t[5]+1200080426|0)<<12|i>>>20)+n|0)&n|~i&r)+t[6]-1473231341|0)<<17|o>>>15)+i|0)&i|~o&n)+t[7]-45705983|0)<<22|r>>>10)+o|0,r=((r+=((o=((o+=((i=((i+=((n=((n+=(r&o|~r&i)+t[8]+1770035416|0)<<7|n>>>25)+r|0)&r|~n&o)+t[9]-1958414417|0)<<12|i>>>20)+n|0)&n|~i&r)+t[10]-42063|0)<<17|o>>>15)+i|0)&i|~o&n)+t[11]-1990404162|0)<<22|r>>>10)+o|0,r=((r+=((o=((o+=((i=((i+=((n=((n+=(r&o|~r&i)+t[12]+1804603682|0)<<7|n>>>25)+r|0)&r|~n&o)+t[13]-40341101|0)<<12|i>>>20)+n|0)&n|~i&r)+t[14]-1502002290|0)<<17|o>>>15)+i|0)&i|~o&n)+t[15]+1236535329|0)<<22|r>>>10)+o|0,r=((r+=((o=((o+=((i=((i+=((n=((n+=(r&i|o&~i)+t[1]-165796510|0)<<5|n>>>27)+r|0)&o|r&~o)+t[6]-1069501632|0)<<9|i>>>23)+n|0)&r|n&~r)+t[11]+643717713|0)<<14|o>>>18)+i|0)&n|i&~n)+t[0]-373897302|0)<<20|r>>>12)+o|0,r=((r+=((o=((o+=((i=((i+=((n=((n+=(r&i|o&~i)+t[5]-701558691|0)<<5|n>>>27)+r|0)&o|r&~o)+t[10]+38016083|0)<<9|i>>>23)+n|0)&r|n&~r)+t[15]-660478335|0)<<14|o>>>18)+i|0)&n|i&~n)+t[4]-405537848|0)<<20|r>>>12)+o|0,r=((r+=((o=((o+=((i=((i+=((n=((n+=(r&i|o&~i)+t[9]+568446438|0)<<5|n>>>27)+r|0)&o|r&~o)+t[14]-1019803690|0)<<9|i>>>23)+n|0)&r|n&~r)+t[3]-187363961|0)<<14|o>>>18)+i|0)&n|i&~n)+t[8]+1163531501|0)<<20|r>>>12)+o|0,r=((r+=((o=((o+=((i=((i+=((n=((n+=(r&i|o&~i)+t[13]-1444681467|0)<<5|n>>>27)+r|0)&o|r&~o)+t[2]-51403784|0)<<9|i>>>23)+n|0)&r|n&~r)+t[7]+1735328473|0)<<14|o>>>18)+i|0)&n|i&~n)+t[12]-1926607734|0)<<20|r>>>12)+o|0,r=((r+=((o=((o+=((i=((i+=((n=((n+=(r^o^i)+t[5]-378558|0)<<4|n>>>28)+r|0)^r^o)+t[8]-2022574463|0)<<11|i>>>21)+n|0)^n^r)+t[11]+1839030562|0)<<16|o>>>16)+i|0)^i^n)+t[14]-35309556|0)<<23|r>>>9)+o|0,r=((r+=((o=((o+=((i=((i+=((n=((n+=(r^o^i)+t[1]-1530992060|0)<<4|n>>>28)+r|0)^r^o)+t[4]+1272893353|0)<<11|i>>>21)+n|0)^n^r)+t[7]-155497632|0)<<16|o>>>16)+i|0)^i^n)+t[10]-1094730640|0)<<23|r>>>9)+o|0,r=((r+=((o=((o+=((i=((i+=((n=((n+=(r^o^i)+t[13]+681279174|0)<<4|n>>>28)+r|0)^r^o)+t[0]-358537222|0)<<11|i>>>21)+n|0)^n^r)+t[3]-722521979|0)<<16|o>>>16)+i|0)^i^n)+t[6]+76029189|0)<<23|r>>>9)+o|0,r=((r+=((o=((o+=((i=((i+=((n=((n+=(r^o^i)+t[9]-640364487|0)<<4|n>>>28)+r|0)^r^o)+t[12]-421815835|0)<<11|i>>>21)+n|0)^n^r)+t[15]+530742520|0)<<16|o>>>16)+i|0)^i^n)+t[2]-995338651|0)<<23|r>>>9)+o|0,r=((r+=((i=((i+=(r^((n=((n+=(o^(r|~i))+t[0]-198630844|0)<<6|n>>>26)+r|0)|~o))+t[7]+1126891415|0)<<10|i>>>22)+n|0)^((o=((o+=(n^(i|~r))+t[14]-1416354905|0)<<15|o>>>17)+i|0)|~n))+t[5]-57434055|0)<<21|r>>>11)+o|0,r=((r+=((i=((i+=(r^((n=((n+=(o^(r|~i))+t[12]+1700485571|0)<<6|n>>>26)+r|0)|~o))+t[3]-1894986606|0)<<10|i>>>22)+n|0)^((o=((o+=(n^(i|~r))+t[10]-1051523|0)<<15|o>>>17)+i|0)|~n))+t[1]-2054922799|0)<<21|r>>>11)+o|0,r=((r+=((i=((i+=(r^((n=((n+=(o^(r|~i))+t[8]+1873313359|0)<<6|n>>>26)+r|0)|~o))+t[15]-30611744|0)<<10|i>>>22)+n|0)^((o=((o+=(n^(i|~r))+t[6]-1560198380|0)<<15|o>>>17)+i|0)|~n))+t[13]+1309151649|0)<<21|r>>>11)+o|0,r=((r+=((i=((i+=(r^((n=((n+=(o^(r|~i))+t[4]-145523070|0)<<6|n>>>26)+r|0)|~o))+t[11]-1120210379|0)<<10|i>>>22)+n|0)^((o=((o+=(n^(i|~r))+t[2]+718787259|0)<<15|o>>>17)+i|0)|~n))+t[9]-343485551|0)<<21|r>>>11)+o|0,e[0]=n+e[0]|0,e[1]=r+e[1]|0,e[2]=o+e[2]|0,e[3]=i+e[3]|0}function r(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 o(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 i(e){var t,o,i,s,a,u,c=e.length,f=[1732584193,-271733879,-1732584194,271733878];for(t=64;t<=c;t+=64)n(f,r(e.substring(t-64,t)));for(o=(e=e.substring(t-64)).length,i=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],t=0;t<o;t+=1)i[t>>2]|=e.charCodeAt(t)<<(t%4<<3);if(i[t>>2]|=128<<(t%4<<3),t>55)for(n(f,i),t=0;t<16;t+=1)i[t]=0;return s=(s=8*c).toString(16).match(/(.*?)(.{0,8})$/),a=parseInt(s[2],16),u=parseInt(s[1],16)||0,i[14]=a,i[15]=u,n(f,i),f}function s(e){var n,r="";for(n=0;n<4;n+=1)r+=t[e>>8*n+4&15]+t[e>>8*n&15];return r}function a(e){var t;for(t=0;t<e.length;t+=1)e[t]=s(e[t]);return e.join("")}function u(e){return/[\u0080-\uFFFF]/.test(e)&&(e=unescape(encodeURIComponent(e))),e}function c(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 f(){this.reset()}return"5d41402abc4b2a76b9719d911017c592"!==a(i("hello"))&&function(e,t){var n=(65535&e)+(65535&t);return(e>>16)+(t>>16)+(n>>16)<<16|65535&n},"undefined"==typeof ArrayBuffer||ArrayBuffer.prototype.slice||function(){function t(e,t){return(e=0|e||0)<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)}}(),f.prototype.append=function(e){return this.appendBinary(u(e)),this},f.prototype.appendBinary=function(e){this._buff+=e,this._length+=e.length;var t,o=this._buff.length;for(t=64;t<=o;t+=64)n(this._hash,r(this._buff.substring(t-64,t)));return this._buff=this._buff.substring(t-64),this},f.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=a(this._hash),e&&(n=c(n)),this.reset(),n},f.prototype.reset=function(){return this._buff="",this._length=0,this._hash=[1732584193,-271733879,-1732584194,271733878],this},f.prototype.getState=function(){return{buff:this._buff,length:this._length,hash:this._hash.slice()}},f.prototype.setState=function(e){return this._buff=e.buff,this._length=e.length,this._hash=e.hash,this},f.prototype.destroy=function(){delete this._hash,delete this._buff,delete this._length},f.prototype._finish=function(e,t){var r,o,i,s=t;if(e[s>>2]|=128<<(s%4<<3),s>55)for(n(this._hash,e),s=0;s<16;s+=1)e[s]=0;r=(r=8*this._length).toString(16).match(/(.*?)(.{0,8})$/),o=parseInt(r[2],16),i=parseInt(r[1],16)||0,e[14]=o,e[15]=i,n(this._hash,e)},f.hash=function(e,t){return f.hashBinary(u(e),t)},f.hashBinary=function(e,t){var n=a(i(e));return t?c(n):n},f.ArrayBuffer=function(){this.reset()},f.ArrayBuffer.prototype.append=function(e){var t,r,i,s,a,u=(r=this._buff.buffer,i=e,s=!0,(a=new Uint8Array(r.byteLength+i.byteLength)).set(new Uint8Array(r)),a.set(new Uint8Array(i),r.byteLength),s?a:a.buffer),c=u.length;for(this._length+=e.byteLength,t=64;t<=c;t+=64)n(this._hash,o(u.subarray(t-64,t)));return this._buff=t-64<c?new Uint8Array(u.buffer.slice(t-64)):new Uint8Array(0),this},f.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=a(this._hash),e&&(n=c(n)),this.reset(),n},f.ArrayBuffer.prototype.reset=function(){return this._buff=new Uint8Array(0),this._length=0,this._hash=[1732584193,-271733879,-1732584194,271733878],this},f.ArrayBuffer.prototype.getState=function(){var e,t=f.prototype.getState.call(this);return t.buff=(e=t.buff,String.fromCharCode.apply(null,new Uint8Array(e))),t},f.ArrayBuffer.prototype.setState=function(e){return e.buff=function(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}(e.buff,!0),f.prototype.setState.call(this,e)},f.ArrayBuffer.prototype.destroy=f.prototype.destroy,f.ArrayBuffer.prototype._finish=f.prototype._finish,f.ArrayBuffer.hash=function(e,t){var r=a(function(e){var t,r,i,s,a,u,c=e.length,f=[1732584193,-271733879,-1732584194,271733878];for(t=64;t<=c;t+=64)n(f,o(e.subarray(t-64,t)));for(r=(e=t-64<c?e.subarray(t-64):new Uint8Array(0)).length,i=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],t=0;t<r;t+=1)i[t>>2]|=e[t]<<(t%4<<3);if(i[t>>2]|=128<<(t%4<<3),t>55)for(n(f,i),t=0;t<16;t+=1)i[t]=0;return s=(s=8*c).toString(16).match(/(.*?)(.{0,8})$/),a=parseInt(s[2],16),u=parseInt(s[1],16)||0,i[14]=a,i[15]=u,n(f,i),f}(new Uint8Array(e)));return t?c(r):r},f}))},{}],3:[function(e,t,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0}),Object.defineProperty(n,"v1",{enumerable:!0,get:function(){return r.default}}),Object.defineProperty(n,"v3",{enumerable:!0,get:function(){return o.default}}),Object.defineProperty(n,"v4",{enumerable:!0,get:function(){return i.default}}),Object.defineProperty(n,"v5",{enumerable:!0,get:function(){return s.default}}),Object.defineProperty(n,"NIL",{enumerable:!0,get:function(){return a.default}}),Object.defineProperty(n,"version",{enumerable:!0,get:function(){return u.default}}),Object.defineProperty(n,"validate",{enumerable:!0,get:function(){return c.default}}),Object.defineProperty(n,"stringify",{enumerable:!0,get:function(){return f.default}}),Object.defineProperty(n,"parse",{enumerable:!0,get:function(){return l.default}});var r=d(e("./v1.js")),o=d(e("./v3.js")),i=d(e("./v4.js")),s=d(e("./v5.js")),a=d(e("./nil.js")),u=d(e("./version.js")),c=d(e("./validate.js")),f=d(e("./stringify.js")),l=d(e("./parse.js"));function d(e){return e&&e.__esModule?e:{default:e}}},{"./nil.js":5,"./parse.js":6,"./stringify.js":10,"./v1.js":11,"./v3.js":12,"./v4.js":14,"./v5.js":15,"./validate.js":16,"./version.js":17}],4:[function(e,t,n){"use strict";function r(e){return 14+(e+64>>>9<<4)+1}function o(e,t){const n=(65535&e)+(65535&t);return(e>>16)+(t>>16)+(n>>16)<<16|65535&n}function i(e,t,n,r,i,s){return o((a=o(o(t,e),o(r,s)))<<(u=i)|a>>>32-u,n);var a,u}function s(e,t,n,r,o,s,a){return i(t&n|~t&r,e,t,o,s,a)}function a(e,t,n,r,o,s,a){return i(t&r|n&~r,e,t,o,s,a)}function u(e,t,n,r,o,s,a){return i(t^n^r,e,t,o,s,a)}function c(e,t,n,r,o,s,a){return i(n^(t|~r),e,t,o,s,a)}Object.defineProperty(n,"__esModule",{value:!0}),n.default=void 0;var f=function(e){if("string"==typeof e){const t=unescape(encodeURIComponent(e));e=new Uint8Array(t.length);for(let n=0;n<t.length;++n)e[n]=t.charCodeAt(n)}return function(e){const t=[],n=32*e.length;for(let r=0;r<n;r+=8){const n=e[r>>5]>>>r%32&255,o=parseInt("0123456789abcdef".charAt(n>>>4&15)+"0123456789abcdef".charAt(15&n),16);t.push(o)}return t}(function(e,t){e[t>>5]|=128<<t%32,e[r(t)-1]=t;let n=1732584193,i=-271733879,f=-1732584194,l=271733878;for(let t=0;t<e.length;t+=16){const r=n,d=i,h=f,p=l;n=s(n,i,f,l,e[t],7,-680876936),l=s(l,n,i,f,e[t+1],12,-389564586),f=s(f,l,n,i,e[t+2],17,606105819),i=s(i,f,l,n,e[t+3],22,-1044525330),n=s(n,i,f,l,e[t+4],7,-176418897),l=s(l,n,i,f,e[t+5],12,1200080426),f=s(f,l,n,i,e[t+6],17,-1473231341),i=s(i,f,l,n,e[t+7],22,-45705983),n=s(n,i,f,l,e[t+8],7,1770035416),l=s(l,n,i,f,e[t+9],12,-1958414417),f=s(f,l,n,i,e[t+10],17,-42063),i=s(i,f,l,n,e[t+11],22,-1990404162),n=s(n,i,f,l,e[t+12],7,1804603682),l=s(l,n,i,f,e[t+13],12,-40341101),f=s(f,l,n,i,e[t+14],17,-1502002290),i=s(i,f,l,n,e[t+15],22,1236535329),n=a(n,i,f,l,e[t+1],5,-165796510),l=a(l,n,i,f,e[t+6],9,-1069501632),f=a(f,l,n,i,e[t+11],14,643717713),i=a(i,f,l,n,e[t],20,-373897302),n=a(n,i,f,l,e[t+5],5,-701558691),l=a(l,n,i,f,e[t+10],9,38016083),f=a(f,l,n,i,e[t+15],14,-660478335),i=a(i,f,l,n,e[t+4],20,-405537848),n=a(n,i,f,l,e[t+9],5,568446438),l=a(l,n,i,f,e[t+14],9,-1019803690),f=a(f,l,n,i,e[t+3],14,-187363961),i=a(i,f,l,n,e[t+8],20,1163531501),n=a(n,i,f,l,e[t+13],5,-1444681467),l=a(l,n,i,f,e[t+2],9,-51403784),f=a(f,l,n,i,e[t+7],14,1735328473),i=a(i,f,l,n,e[t+12],20,-1926607734),n=u(n,i,f,l,e[t+5],4,-378558),l=u(l,n,i,f,e[t+8],11,-2022574463),f=u(f,l,n,i,e[t+11],16,1839030562),i=u(i,f,l,n,e[t+14],23,-35309556),n=u(n,i,f,l,e[t+1],4,-1530992060),l=u(l,n,i,f,e[t+4],11,1272893353),f=u(f,l,n,i,e[t+7],16,-155497632),i=u(i,f,l,n,e[t+10],23,-1094730640),n=u(n,i,f,l,e[t+13],4,681279174),l=u(l,n,i,f,e[t],11,-358537222),f=u(f,l,n,i,e[t+3],16,-722521979),i=u(i,f,l,n,e[t+6],23,76029189),n=u(n,i,f,l,e[t+9],4,-640364487),l=u(l,n,i,f,e[t+12],11,-421815835),f=u(f,l,n,i,e[t+15],16,530742520),i=u(i,f,l,n,e[t+2],23,-995338651),n=c(n,i,f,l,e[t],6,-198630844),l=c(l,n,i,f,e[t+7],10,1126891415),f=c(f,l,n,i,e[t+14],15,-1416354905),i=c(i,f,l,n,e[t+5],21,-57434055),n=c(n,i,f,l,e[t+12],6,1700485571),l=c(l,n,i,f,e[t+3],10,-1894986606),f=c(f,l,n,i,e[t+10],15,-1051523),i=c(i,f,l,n,e[t+1],21,-2054922799),n=c(n,i,f,l,e[t+8],6,1873313359),l=c(l,n,i,f,e[t+15],10,-30611744),f=c(f,l,n,i,e[t+6],15,-1560198380),i=c(i,f,l,n,e[t+13],21,1309151649),n=c(n,i,f,l,e[t+4],6,-145523070),l=c(l,n,i,f,e[t+11],10,-1120210379),f=c(f,l,n,i,e[t+2],15,718787259),i=c(i,f,l,n,e[t+9],21,-343485551),n=o(n,r),i=o(i,d),f=o(f,h),l=o(l,p)}return[n,i,f,l]}(function(e){if(0===e.length)return[];const t=8*e.length,n=new Uint32Array(r(t));for(let r=0;r<t;r+=8)n[r>>5]|=(255&e[r/8])<<r%32;return n}(e),8*e.length))};n.default=f},{}],5:[function(e,t,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0}),n.default=void 0;n.default="00000000-0000-0000-0000-000000000000"},{}],6:[function(e,t,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0}),n.default=void 0;var r,o=(r=e("./validate.js"))&&r.__esModule?r:{default:r};var i=function(e){if(!(0,o.default)(e))throw TypeError("Invalid UUID");let t;const n=new Uint8Array(16);return n[0]=(t=parseInt(e.slice(0,8),16))>>>24,n[1]=t>>>16&255,n[2]=t>>>8&255,n[3]=255&t,n[4]=(t=parseInt(e.slice(9,13),16))>>>8,n[5]=255&t,n[6]=(t=parseInt(e.slice(14,18),16))>>>8,n[7]=255&t,n[8]=(t=parseInt(e.slice(19,23),16))>>>8,n[9]=255&t,n[10]=(t=parseInt(e.slice(24,36),16))/1099511627776&255,n[11]=t/4294967296&255,n[12]=t>>>24&255,n[13]=t>>>16&255,n[14]=t>>>8&255,n[15]=255&t,n};n.default=i},{"./validate.js":16}],7:[function(e,t,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0}),n.default=void 0;n.default=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i},{}],8:[function(e,t,n){"use strict";let r;Object.defineProperty(n,"__esModule",{value:!0}),n.default=function(){if(!r&&(r="undefined"!=typeof crypto&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||"undefined"!=typeof msCrypto&&"function"==typeof msCrypto.getRandomValues&&msCrypto.getRandomValues.bind(msCrypto),!r))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return r(o)};const o=new Uint8Array(16)},{}],9:[function(e,t,n){"use strict";function r(e,t,n,r){switch(e){case 0:return t&n^~t&r;case 1:return t^n^r;case 2:return t&n^t&r^n&r;case 3:return t^n^r}}function o(e,t){return e<<t|e>>>32-t}Object.defineProperty(n,"__esModule",{value:!0}),n.default=void 0;var i=function(e){const t=[1518500249,1859775393,2400959708,3395469782],n=[1732584193,4023233417,2562383102,271733878,3285377520];if("string"==typeof e){const t=unescape(encodeURIComponent(e));e=[];for(let n=0;n<t.length;++n)e.push(t.charCodeAt(n))}else Array.isArray(e)||(e=Array.prototype.slice.call(e));e.push(128);const i=e.length/4+2,s=Math.ceil(i/16),a=new Array(s);for(let t=0;t<s;++t){const n=new Uint32Array(16);for(let r=0;r<16;++r)n[r]=e[64*t+4*r]<<24|e[64*t+4*r+1]<<16|e[64*t+4*r+2]<<8|e[64*t+4*r+3];a[t]=n}a[s-1][14]=8*(e.length-1)/Math.pow(2,32),a[s-1][14]=Math.floor(a[s-1][14]),a[s-1][15]=8*(e.length-1)&4294967295;for(let e=0;e<s;++e){const i=new Uint32Array(80);for(let t=0;t<16;++t)i[t]=a[e][t];for(let e=16;e<80;++e)i[e]=o(i[e-3]^i[e-8]^i[e-14]^i[e-16],1);let s=n[0],u=n[1],c=n[2],f=n[3],l=n[4];for(let e=0;e<80;++e){const n=Math.floor(e/20),a=o(s,5)+r(n,u,c,f)+l+t[n]+i[e]>>>0;l=f,f=c,c=o(u,30)>>>0,u=s,s=a}n[0]=n[0]+s>>>0,n[1]=n[1]+u>>>0,n[2]=n[2]+c>>>0,n[3]=n[3]+f>>>0,n[4]=n[4]+l>>>0}return[n[0]>>24&255,n[0]>>16&255,n[0]>>8&255,255&n[0],n[1]>>24&255,n[1]>>16&255,n[1]>>8&255,255&n[1],n[2]>>24&255,n[2]>>16&255,n[2]>>8&255,255&n[2],n[3]>>24&255,n[3]>>16&255,n[3]>>8&255,255&n[3],n[4]>>24&255,n[4]>>16&255,n[4]>>8&255,255&n[4]]};n.default=i},{}],10:[function(e,t,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0}),n.default=void 0;var r,o=(r=e("./validate.js"))&&r.__esModule?r:{default:r};const i=[];for(let e=0;e<256;++e)i.push((e+256).toString(16).substr(1));var s=function(e,t=0){const n=(i[e[t+0]]+i[e[t+1]]+i[e[t+2]]+i[e[t+3]]+"-"+i[e[t+4]]+i[e[t+5]]+"-"+i[e[t+6]]+i[e[t+7]]+"-"+i[e[t+8]]+i[e[t+9]]+"-"+i[e[t+10]]+i[e[t+11]]+i[e[t+12]]+i[e[t+13]]+i[e[t+14]]+i[e[t+15]]).toLowerCase();if(!(0,o.default)(n))throw TypeError("Stringified UUID is invalid");return n};n.default=s},{"./validate.js":16}],11:[function(e,t,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0}),n.default=void 0;var r=i(e("./rng.js")),o=i(e("./stringify.js"));function i(e){return e&&e.__esModule?e:{default:e}}let s,a,u=0,c=0;var f=function(e,t,n){let i=t&&n||0;const f=t||new Array(16);let l=(e=e||{}).node||s,d=void 0!==e.clockseq?e.clockseq:a;if(null==l||null==d){const t=e.random||(e.rng||r.default)();null==l&&(l=s=[1|t[0],t[1],t[2],t[3],t[4],t[5]]),null==d&&(d=a=16383&(t[6]<<8|t[7]))}let h=void 0!==e.msecs?e.msecs:Date.now(),p=void 0!==e.nsecs?e.nsecs:c+1;const v=h-u+(p-c)/1e4;if(v<0&&void 0===e.clockseq&&(d=d+1&16383),(v<0||h>u)&&void 0===e.nsecs&&(p=0),p>=1e4)throw new Error("uuid.v1(): Can't create more than 10M uuids/sec");u=h,c=p,a=d,h+=122192928e5;const _=(1e4*(268435455&h)+p)%4294967296;f[i++]=_>>>24&255,f[i++]=_>>>16&255,f[i++]=_>>>8&255,f[i++]=255&_;const y=h/4294967296*1e4&268435455;f[i++]=y>>>8&255,f[i++]=255&y,f[i++]=y>>>24&15|16,f[i++]=y>>>16&255,f[i++]=d>>>8|128,f[i++]=255&d;for(let e=0;e<6;++e)f[i+e]=l[e];return t||(0,o.default)(f)};n.default=f},{"./rng.js":8,"./stringify.js":10}],12:[function(e,t,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0}),n.default=void 0;var r=i(e("./v35.js")),o=i(e("./md5.js"));function i(e){return e&&e.__esModule?e:{default:e}}var s=(0,r.default)("v3",48,o.default);n.default=s},{"./md5.js":4,"./v35.js":13}],13:[function(e,t,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0}),n.default=function(e,t,n){function i(e,i,s,a){if("string"==typeof e&&(e=function(e){e=unescape(encodeURIComponent(e));const t=[];for(let n=0;n<e.length;++n)t.push(e.charCodeAt(n));return t}(e)),"string"==typeof i&&(i=(0,o.default)(i)),16!==i.length)throw TypeError("Namespace must be array-like (16 iterable integer values, 0-255)");let u=new Uint8Array(16+e.length);if(u.set(i),u.set(e,i.length),u=n(u),u[6]=15&u[6]|t,u[8]=63&u[8]|128,s){a=a||0;for(let e=0;e<16;++e)s[a+e]=u[e];return s}return(0,r.default)(u)}try{i.name=e}catch(e){}return i.DNS=s,i.URL=a,i},n.URL=n.DNS=void 0;var r=i(e("./stringify.js")),o=i(e("./parse.js"));function i(e){return e&&e.__esModule?e:{default:e}}const s="6ba7b810-9dad-11d1-80b4-00c04fd430c8";n.DNS=s;const a="6ba7b811-9dad-11d1-80b4-00c04fd430c8";n.URL=a},{"./parse.js":6,"./stringify.js":10}],14:[function(e,t,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0}),n.default=void 0;var r=i(e("./rng.js")),o=i(e("./stringify.js"));function i(e){return e&&e.__esModule?e:{default:e}}var s=function(e,t,n){const i=(e=e||{}).random||(e.rng||r.default)();if(i[6]=15&i[6]|64,i[8]=63&i[8]|128,t){n=n||0;for(let e=0;e<16;++e)t[n+e]=i[e];return t}return(0,o.default)(i)};n.default=s},{"./rng.js":8,"./stringify.js":10}],15:[function(e,t,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0}),n.default=void 0;var r=i(e("./v35.js")),o=i(e("./sha1.js"));function i(e){return e&&e.__esModule?e:{default:e}}var s=(0,r.default)("v5",80,o.default);n.default=s},{"./sha1.js":9,"./v35.js":13}],16:[function(e,t,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0}),n.default=void 0;var r,o=(r=e("./regex.js"))&&r.__esModule?r:{default:r};var i=function(e){return"string"==typeof e&&o.default.test(e)};n.default=i},{"./regex.js":7}],17:[function(e,t,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0}),n.default=void 0;var r,o=(r=e("./validate.js"))&&r.__esModule?r:{default:r};var i=function(e){if(!(0,o.default)(e))throw TypeError("Invalid UUID");return parseInt(e.substr(14,1),16)};n.default=i},{"./validate.js":16}],18:[function(e,t,n){"use strict";function r(e){return e&&"object"==typeof e&&"default"in e?e.default:e}var o=r(e("events")),i=e("uuid"),s=r(e("spark-md5"));var a,u=Function.prototype.toString,c=u.call(Object);function f(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]=f(e[n]);return t}if(e instanceof Date&&isFinite(e))return e.toISOString();if(function(e){return"undefined"!=typeof ArrayBuffer&&e instanceof ArrayBuffer||"undefined"!=typeof Blob&&e instanceof Blob}(e))return function(e){return e instanceof ArrayBuffer?e.slice(0):e.slice(0,e.size,e.type)}(e);if(!function(e){var t=Object.getPrototypeOf(e);if(null===t)return!0;var n=t.constructor;return"function"==typeof n&&n instanceof n&&u.call(n)==c}(e))return e;for(n in t={},e)if(Object.prototype.hasOwnProperty.call(e,n)){var o=f(e[n]);void 0!==o&&(t[n]=o)}return t}try{localStorage.setItem("_pouch_check_localstorage",1),a=!!localStorage.getItem("_pouch_check_localstorage")}catch(e){a=!1}function l(){return a}const d="function"==typeof queueMicrotask?queueMicrotask:function(e){Promise.resolve().then(e)};class h extends Error{constructor(e,t,n){super(),this.status=e,this.name=t,this.message=n,this.error=!0}toString(){return JSON.stringify({status:this.status,name:this.name,message:this.message,reason:this.reason})}}new h(401,"unauthorized","Name or password is incorrect."),new h(400,"bad_request","Missing JSON list of 'docs'");var p=new h(404,"not_found","missing"),v=new h(409,"conflict","Document update conflict"),_=new h(400,"bad_request","_id field must contain a string"),y=new h(412,"missing_id","_id is required for puts"),m=new h(400,"bad_request","Only reserved document ids may start with underscore."),g=(new h(412,"precondition_failed","Database not open"),new h(500,"unknown_error","Database encountered an unknown error")),b=new h(500,"badarg","Some query argument is invalid"),w=(new h(400,"invalid_request","Request was invalid"),new h(400,"query_parse_error","Some query parameter is invalid"),new h(500,"doc_validation","Bad special document member")),j=new h(400,"bad_request","Something wrong with the request"),A=(new h(400,"bad_request","Document must be a JSON object"),new h(404,"not_found","Database not found"),new h(500,"indexed_db_went_bad","unknown")),x=(new h(500,"web_sql_went_bad","unknown"),new h(500,"levelDB_went_went_bad","unknown"),new h(403,"forbidden","Forbidden by design doc validate_doc_update function"),new h(400,"bad_request","Invalid rev format")),O=(new h(412,"file_exists","The database could not be created, the file already exists."),new h(412,"missing_stub","A pre-existing attachment stub wasn't found"));new h(413,"invalid_url","Provided URL is invalid");function k(e,t){function n(t){for(var n=Object.getOwnPropertyNames(e),r=0,o=n.length;r<o;r++)"function"!=typeof e[n[r]]&&(this[n[r]]=e[n[r]]);void 0===this.stack&&(this.stack=(new Error).stack),void 0!==t&&(this.reason=t)}return n.prototype=h.prototype,new n(t)}function S(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&&function(e,t,n){try{return!e(t,n)}catch(e){var r="Filter function threw: "+e.toString();return k(j,r)}}(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)Object.prototype.hasOwnProperty.call(r.doc._attachments,i)&&(r.doc._attachments[i].stub=!0)}else delete r.doc;return!0}}var B=function(e){return atob(e)},P=function(e){return btoa(e)};function C(e,t){e=e||[],t=t||{};try{return new Blob(e,t)}catch(o){if("TypeError"!==o.name)throw o;for(var n=new("undefined"!=typeof BlobBuilder?BlobBuilder:"undefined"!=typeof MSBlobBuilder?MSBlobBuilder:"undefined"!=typeof MozBlobBuilder?MozBlobBuilder:WebKitBlobBuilder),r=0;r<e.length;r+=1)n.append(e[r]);return n.getBlob(t.type)}}function I(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 L(e,t){return C([I(e)],{type:t})}function E(e,t){return L(B(e),t)}function M(e,t){var n=new FileReader,r="function"==typeof n.readAsBinaryString;n.onloadend=function(e){var n=e.target.result||"";if(r)return t(n);t(function(e){for(var t="",n=new Uint8Array(e),r=n.byteLength,o=0;o<r;o++)t+=String.fromCharCode(n[o]);return t}(n))},r?n.readAsBinaryString(e):n.readAsArrayBuffer(e)}function q(e,t){!function(e,t){M(e,(function(e){t(e)}))}(e,(function(e){t(P(e))}))}var D=self.setImmediate||self.setTimeout;function R(e,t,n,r,o){(n>0||r<t.size)&&(t=t.slice(n,r)),function(e,t){var n=new FileReader;n.onloadend=function(e){var n=e.target.result||new ArrayBuffer(0);t(n)},n.readAsArrayBuffer(e)}(t,(function(t){e.append(t),o()}))}function U(e,t,n,r,o){(n>0||r<t.length)&&(t=t.substring(n,r)),e.appendBinary(t),o()}function N(e,t){var n="string"==typeof e,r=n?e.length:e.size,o=Math.min(32768,r),i=Math.ceil(r/o),a=0,u=n?new s:new s.ArrayBuffer,c=n?U:R;function f(){D(d)}function l(){var e=function(e){return P(e)}(u.end(!0));t(e),u.destroy()}function d(){var t=a*o,n=t+o;a++,c(u,e,t,n,a<i?f:l)}d()}function T(e,t){if(!t)return i.v4().replace(/-/g,"").toLowerCase();var n,r=Object.assign({},e);return delete r._rev_tree,n=JSON.stringify(r),s.hash(n)}var F=i.v4;function K(e){return e.reduce((function(e,t){return e[t]=!0,e}),{})}var z=K(["_id","_rev","_access","_attachments","_deleted","_revisions","_revs_info","_conflicts","_deleted_conflicts","_local_seq","_rev_tree","_replication_id","_replication_state","_replication_state_time","_replication_state_reason","_replication_stats","_removed"]),W=K(["_access","_attachments","_replication_id","_replication_state","_replication_state_time","_replication_state_reason","_replication_stats"]);function V(e){if(!/^\d+-/.test(e))return k(x);var t=e.indexOf("-"),n=e.substring(0,t),r=e.substring(t+1);return{prefix:parseInt(n,10),id:r}}function $(e,t,n){var r,o,i;n||(n={deterministic_revs:!0});var s={status:"available"};if(e._deleted&&(s.deleted=!0),t)if(e._id||(e._id=F()),o=T(e,n.deterministic_revs),e._rev){if((i=V(e._rev)).error)return i;e._rev_tree=[{pos:i.prefix,ids:[i.id,{status:"missing"},[[o,s,[]]]]}],r=i.prefix+1}else e._rev_tree=[{pos:1,ids:[o,s,[]]}],r=1;else if(e._revisions&&(e._rev_tree=function(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}]}(e._revisions,s),r=e._revisions.start,o=e._revisions.ids[0]),!e._rev_tree){if((i=V(e._rev)).error)return i;r=i.prefix,o=i.id,e._rev_tree=[{pos:r,ids:[o,s,[]]}]}!function(e){var t;if(e?"string"!=typeof e?t=k(_):/^_/.test(e)&&!/^_(design|local)/.test(e)&&(t=k(m)):t=k(y),t)throw t}(e._id),e._rev=r+"-"+o;var a={metadata:{},data:{}};for(var u in e)if(Object.prototype.hasOwnProperty.call(e,u)){var c="_"===u[0];if(c&&!z[u]){var f=k(w,u);throw f.message=w.message+": "+u,f}c&&!W[u]?a.metadata[u.slice(1)]=e[u]:a.data[u]=e[u]}return a}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 G(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 Y(e){for(var t=J(e),n=function(e){var t=[];G(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}(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 H(e,t){return e.pos-t.pos}function Q(e,t,n){var r=function(e,t,n){for(var r,o=0,i=e.length;o<i;)n(e[r=o+i>>>1],t)<0?o=r+1:i=r;return o}(e,t,n);e.splice(r,0,t)}function X(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 ee(e,t){return e[0]<t[0]?-1:1}function te(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",Q(i[2],s[2][a],ee))}else r="new_leaf",i[2][0]=s[2][a]}return{conflicts:r,tree:e}}function ne(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=te(c.ids,t.ids),o.push({pos:c.pos,ids:r.tree}),i=i||r.conflicts,s=!0;else if(!0!==n){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 _=v.ids[2],y=0,m=_.length;y<m;y++)p.push({ids:_[y],diff:v.diff-1,parent:v.ids,parentIdx:y});else v.ids[0]===l.ids[0]&&h.push(v)}var g=h[0];g?(r=te(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(H),{tree:o,conflicts:i||"internal_node"}}function re(e,t,n){var r=ne(e,t),o=function(e,t){for(var n,r,o=function(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()}(e),i=0,s=o.length;i<s;i++){var a,u=o[i],c=u.ids;if(c.length>t){n||(n={});var f=c.length-t;a={pos:u.pos+f,ids:X(c,f)};for(var l=0;l<f;l++){var d=u.pos+l+"-"+c[l].id;n[d]=!0}}else a={pos:u.pos,ids:X(c,0)};r=r?ne(r,a,!0).tree:[a]}return n&&G(r,(function(e,t,r){delete n[t+"-"+r]})),{tree:r,revs:n?Object.keys(n):[]}}(r.tree,n);return{tree:o.tree,stemmedRevs:o.revs,conflicts:r.conflicts}}function oe(e,t){return e.flatMap(e=>(e=function(e,t){const n=f(e),r=[n];let o;for(;o=r.pop();){const{pos:e,ids:[i,,s],parent:a}=o,u=0===s.length,c=`${e}-${i}`;if(u&&c===t)return a?(a.ids[2]=a.ids[2].filter((function(e){return e[0]!==i})),n):null;for(let t=0,n=s.length;t<n;t++)r.push({pos:e+1,ids:s[t],parent:o})}return n}(e,t))?[e]:[])}function ie(e){return"string"==typeof e&&e.startsWith("_local/")}const se=Number.MIN_SAFE_INTEGER,ae=Number.MIN_SAFE_INTEGER+1,ue=Number.MIN_SAFE_INTEGER+2,ce=/^[^a-zA-Z$]|[^a-zA-Z0-9$]+/,fe=/\\.|(^|\.)[^a-zA-Z$]|[^a-zA-Z0-9$.]+/;const le=new RegExp(ce.source,"g"),de=new RegExp(fe.source,"g"),he="\\".charCodeAt(0),pe=".".charCodeAt(0);function ve(e,t){const n=function(e){let n="";for(let r=0;r<e.length;r++){const o=e.charCodeAt(r);if(o===pe&&t&&0===r)n+=".";else{if(o===he&&t)continue;n+="_c"+o+"_"}}return n};return t?e.replace(de,n):e.replace(le,n)}function _e(e){if(!function e(t){for(const r of Object.keys(t)){if(n=r,void 0?fe.test(n):ce.test(n))return!0;if(null===t[r]||"boolean"==typeof t[r])return!0;if("object"==typeof t[r])return e(t[r])}var n}(e))return!1;const t=Array.isArray(e),n=t?[]:{};return Object.keys(e).forEach((function(r){const o=t?r:ve(r);null===e[r]?n[o]=se:"boolean"==typeof e[r]?n[o]=e[r]?ue:ae:"object"==typeof e[r]?n[o]=_e(e[r]):n[o]=e[r]})),n}function ye(e){return function(t){let n="unknown_error";t.target&&t.target.error&&(n=t.target.error.name||t.target.error.message),e(k(A,n,t.type))}}function me(e,t,n,r,o){if(delete n._attachments[e].stub,"base64"===o){if(r){const r=t.attachments[n._attachments[e].digest];n._attachments[e].data=E(r.data,r.content_type)}else n._attachments[e].data=t.attachments[n._attachments[e].digest].data;return delete n._attachments[e].length,Promise.resolve()}return r?(n._attachments[e].data=t.attachments[n._attachments[e].digest].data,Promise.resolve()):new Promise((function(r){M(t.attachments[n._attachments[e].digest].data,(function(t){n._attachments[e].data=P(t),delete n._attachments[e].length,r()}))}))}function ge(e,t){return(e.views[t].options&&e.views[t].options.def&&e.views[t].options.def.fields||[]).map((function(e){return"string"==typeof e?e:Object.keys(e)[0]}))}function be(e){return"_find_idx/"+e.join("/")}const we=Math.pow(10,13);function je(e,t){const n=e.transaction.objectStore("docs");n.getAll(IDBKeyRange.bound("_design/","_design/\uffff")).onsuccess=function(e){const r=e.target.result,o=Array.from(n.indexNames),i=r.filter((function(e){return 0===e.deleted&&e.revs[e.rev].data.views})).map((function(e){return e.revs[e.rev].data})).reduce((function(e,t){return Object.keys(t.views).reduce((function(e,n){const r=ge(t,n);return r&&r.length>0&&(e[be(r)]=function(e){return["deleted"].concat(e.map((function(e){return["_id","_rev","_deleted","_attachments"].includes(e)?e.substr(1):"data."+ve(e,!0)})))}(r)),e}),e)}),{}),s=Object.keys(i),a=["seq","deleted,id"];o.forEach((function(e){-1===a.indexOf(e)&&-1===s.indexOf(e)&&n.deleteIndex(e)}));const u=s.filter((function(e){return-1===o.indexOf(e)}));try{u.forEach((function(e){n.createIndex(e,i[e])}))}catch(e){t(e)}}}function Ae(e,t,n,r,o){const i=n.versionChangedWhileOpen?indexedDB.open(n.name):indexedDB.open(n.name,2*we+(new Date).getTime());i.onupgradeneeded=function(e){if(e.oldVersion>0&&e.oldVersion<we)throw new Error('Incorrect adapter: you should specify the "idb" adapter to open this DB');if(0===e.oldVersion&&e.newVersion<we)throw indexedDB.deleteDatabase(n.name),new Error("Database was deleted while open");const t=e.target.transaction,r=e.target.result,s=(a=e.oldVersion,Math.floor(a/we));var a;if(function(e,t,n,r){if(r<1){t.createObjectStore("docs",{keyPath:"id"}).createIndex("seq","seq",{unique:!0}),t.createObjectStore("meta",{keyPath:"id"})}if(r<2){const t=n.objectStore("docs");t.createIndex("deleted,id",["deleted","id"],{unique:!0}),e.includes("-mrview-")&&t.deleteIndex("seq")}}(n.name,r,t,s),je(i,o),s<2){const e=i.transaction.objectStore("docs"),t=i.transaction.objectStore("meta");e.openCursor().onsuccess=e=>{const n=e.target.result;if(!n)return;const r=n.value;if(!ie(r.id))return n.continue();t.put(r).onsuccess=()=>{n.delete(r).onsuccess=()=>{n.continue()}}}}},i.onblocked=function(e){console.error("onblocked, this should never happen",e)},i.onsuccess=function(o){const i=o.target.result;i.onabort=function(t){console.error("Database has a global failure",t.target.error),delete e[n.name],i.close()},i.onversionchange=function(){console.log("Database was made stale, closing handle"),e[n.name].versionChangedWhileOpen=!0,i.close()},i.onclose=function(){console.log("Database was made stale, closing handle"),n.name in e&&(e[n.name].versionChangedWhileOpen=!0)};let s={id:"meta"};const a=i.transaction(["meta"],"readwrite");a.oncomplete=function(){r({idb:i,metadata:s})};const u=a.objectStore("meta");u.get("meta").onsuccess=function(e){s=e.target.result||s;let n=!1;if("doc_count"in s||(n=!0,s.doc_count=0),"seq"in s||(n=!0,s.seq=0),"db_uuid"in s||(n=!0,s.db_uuid=F()),"idb_attachment_format"in s)n&&(t.blobSupport=s.idb_attachment_format,u.put(s));else{(function(e,t,n){return new Promise((function(r){var o=C([""]);let i;if("function"==typeof n){const r=n(o);i=e.objectStore(t).put(r)}else{const r=n;i=e.objectStore(t).put(o,r)}i.onsuccess=function(){var e=navigator.userAgent.match(/Chrome\/(\d+)/),t=navigator.userAgent.match(/Edge\//);r(t||!e||parseInt(e[1],10)>=43)},i.onerror=e.onabort=function(e){e.preventDefault(),e.stopPropagation(),r(!1)}})).catch((function(){return!1}))})(a,"meta",e=>({id:"blob-support",blob:e})).then(e=>{t.blobSupport=s.idb_attachment_format=e?"binary":"base64",u.put(s)})}}},i.onerror=function(e){o(e.target.error)}}function xe(e,t,n){return e[n.name]&&!e[n.name].versionChangedWhileOpen||(n.versionChangedWhileOpen=e[n.name]&&e[n.name].versionChangedWhileOpen,e[n.name]=new Promise((function(r,o){Ae(e,t,n,r,o)}))),e[n.name]}function Oe(e,t,n,r){if(e.error)return r(e.error);e.txn.objectStore("docs").get(t).onsuccess=function(t){const o=t.target.result;let i;if(i=n.rev?n.latest?function(e,t){for(var n,r=t.rev_tree.slice();n=r.pop();){var o=n.pos,i=n.ids,s=i[0],a=i[1],u=i[2],c=0===u.length,f=n.history?n.history.slice():[];if(f.push({id:s,pos:o,opts:a}),c)for(var l=0,d=f.length;l<d;l++){var h=f[l];if(h.pos+"-"+h.id===e)return o+"-"+s}for(var p=0,v=u.length;p<v;p++)r.push({pos:o+1,ids:u[p],history:f})}throw new Error("Unable to resolve latest revision for id "+t.id+", rev "+e)}(n.rev,o):n.rev:o&&o.rev,!o||o.deleted&&!n.rev||!(i in o.revs))return void r(k(p,"missing"));const s=o.revs[i].data;s._id=o.id,s._rev=i,r(null,{doc:s,metadata:o,ctx:e})}}function ke(e,t,n,r,o){if(ie(e))return void o(k(p,"missing"));const i=r.metadata.attachments[n.digest].data;if("string"!=typeof i)return r.binary?o(null,i):void M(i,(function(e){o(null,P(e))}));r.binary?o(null,E(i,n.content_type)):o(null,i)}function Se(e,t,n,r,o,i,s){let a,u;const c=[],f=[];let l;const d=o.revs_limit||1e3,h=-1===o.name.indexOf("-mrview-"),_=o.auto_compaction;function y(e){return ie(e.id)?1:d}function m(e,t){let i=0;const s={};function a(a){a.target.result&&(s[a.target.result.id]=a.target.result),++i===t.length&&function(e,t,i){t.forEach((function(t,s){let a;if("was_delete"in n&&!Object.prototype.hasOwnProperty.call(i,t.id))a=k(p,"deleted");else if(n.new_edits&&!Object.prototype.hasOwnProperty.call(i,t.id)&&function(e){return"missing"===e.rev_tree[0].ids[1].status}(t))a=k(v);else if(Object.prototype.hasOwnProperty.call(i,t.id)){if(a=function(e,t,r){if(t.rev in r.revs&&!n.new_edits)return!1;const i=/^1-/.test(t.rev);if(r.deleted&&!t.deleted&&n.new_edits&&i){const e=t.revs[t.rev].data;e._rev=r.rev,e._id=r.id,t=j($(e,n.new_edits,o))}const s=re(r.rev_tree,t.rev_tree[0],y(t));t.stemmedRevs=s.stemmedRevs,t.rev_tree=s.tree;const a=r.revs;a[t.rev]=t.revs[t.rev],t.revs=a,t.attachments=r.attachments;if(n.new_edits&&(r.deleted&&t.deleted||!r.deleted&&"new_leaf"!==s.conflicts||r.deleted&&!t.deleted&&"new_branch"===s.conflicts||r.rev===t.rev))return k(v);return t.wasDeleted=r.deleted,t}(0,t,i[t.id]),0==a)return}else{const e=re([],t.rev_tree[0],y(t));t.rev_tree=e.tree,t.stemmedRevs=e.stemmedRevs,a=t,a.isNewDoc=!0,a.wasDeleted=t.revs[t.rev].deleted?1:0}a.error?c[s]=a:(i[a.id]=a,l=s,function(e,t,n){const o=J(t),i=t.rev,s=ie(t.id),a=t.revs[o].data,f=t.isNewDoc;if(h){const e=_e(a);e?(t.data=e,delete t.data._attachments):t.data=a}else t.data=a;if(t.rev=o,t.deleted=t.revs[o].deleted?1:0,!s){t.seq=++r.seq;let e=0;t.isNewDoc?e=t.deleted?0:1:t.wasDeleted!==t.deleted&&(e=t.deleted?-1:1),r.doc_count+=e}delete t.isNewDoc,delete t.wasDeleted;let l=t.stemmedRevs||[];if(_&&!f){const e=function(e){var t=[];return G(e.rev_tree,(function(e,n,r,o,i){"available"!==i.status||e||(t.push(n+"-"+r),i.status="missing")})),t}(t);e.length&&(l=l.concat(e))}l.length&&l.forEach((function(e){delete t.revs[e]}));delete t.stemmedRevs,"attachments"in t||(t.attachments={});if(a._attachments)for(const n in a._attachments){const r=a._attachments[n];if(r.stub){if(!(r.digest in t.attachments))return u=k(O),void e.abort();w(t,i,r.digest)&&(t.attachments[r.digest].revs[i]=!0)}else t.attachments[r.digest]=r,t.attachments[r.digest].revs={},t.attachments[r.digest].revs[i]=!0,a._attachments[n]={stub:!0,digest:r.digest,content_type:r.content_type,length:r.length,revpos:parseInt(i,10)}}if(s&&t.deleted)return e.objectStore("meta").delete(t.id).onsuccess=function(){c[n]={ok:!0,id:t.id,rev:"0-0"}},void A(n);const d=s?"meta":"docs";e.objectStore(d).put(t).onsuccess=function(){c[n]={ok:!0,id:t.id,rev:i},A(n)}}(e,a,s))}))}(e,t,s)}t.forEach((function(t){const n=ie(t.id)?"meta":"docs";e.objectStore(n).get(t.id).onsuccess=a}))}function w(e,t,n){return e.revs[t]&&e.revs[t].data._attachments&&Object.values(e.revs[t].data._attachments).find((function(e){return e.digest===n}))}function j(e){const t={id:e.metadata.id,rev:e.metadata.rev,rev_tree:e.metadata.rev_tree,revs:e.metadata.revs||{}};return t.revs[t.rev]={data:e.data,deleted:e.metadata.deleted},t}function A(e){e===l&&a.objectStore("meta").put(r)}for(let e=0,r=t.docs.length;e<r;e++){let r;try{r=$(t.docs[e],n.new_edits,o)}catch(e){r=e}if(r.error)return s(r);f.push(j(r))}(function(){const e=f.map((function(e){const t=e.revs[e.rev].data;if(!t._attachments)return Promise.resolve(t);const n=Object.keys(t._attachments).map((function(e){return t._attachments[e].name=e,function(e){if(e.stub)return Promise.resolve(e);let t;if("string"==typeof e.data){try{t=B(e.data)}catch(e){return Promise.reject(k(b,"Attachment is not a valid base64 string"))}"binary"===r.idb_attachment_format&&(e.data=L(t,e.content_type))}else if(t=e.data,"base64"===r.idb_attachment_format)return new Promise(n=>{q(e.data,(function(r){e.data=r,N(t,(function(r){e.digest="md5-"+r,e.length=t.size||t.length||0,n(e)}))}))});return new Promise((function(n){N(t,(function(r){e.digest="md5-"+r,e.length=t.size||t.length||0,n(e)}))}))}(t._attachments[e])}));return Promise.all(n).then((function(e){const n={};return e.forEach((function(e){n[e.name]=e,delete e.name})),t._attachments=n,t}))}));return Promise.all(e)})().then((function(){e._openTransactionSafely(["docs","meta"],"readwrite",(function(e,t){if(e)return s(e);a=t,a.onabort=function(){s(u||k(g,"transaction was aborted"))},a.ontimeout=ye(s),a.oncomplete=function(){i.notify(o.name),s(null,c)},m(a,f)}))})).catch((function(e){s(e)}))}function Be(e,t,n,r,o,i){try{return o?IDBKeyRange.only([0,o]):i?IDBKeyRange.bound(t,e,!r,!n):IDBKeyRange.bound(e,t,!n,!r)}catch(e){return{error:e}}}function Pe(e,t,n,r){if("DataError"===n.name&&0===n.code){const n={total_rows:t.doc_count,offset:e.skip,rows:[]};return e.update_seq&&(n.update_seq=t.seq),r(null,n)}r(k(A,n.name,n.message))}function Ce(e,t,n,r){if(e.error)return r(e.error);if(0===n.limit){const e={total_rows:t.doc_count,offset:n.skip,rows:[]};return n.update_seq&&(e.update_seq=t.seq),r(null,e)}const o=[],i=[],s="key"in n&&n.key,a="keys"in n&&n.keys;let u=n.skip||0,c="number"==typeof n.limit?n.limit:void 0;const f=!1!==n.inclusive_end,l="descending"in n&&n.descending?"prev":null,d="startkey"in n?n.startkey:l?"\uffff":"",h="endkey"in n?n.endkey:l?"":"\uffff",p=e.txn.objectStore("docs");if(a){e.txn.oncomplete=y;return function(e,t,n){const r=new Array(e.length);let o=0;e.forEach((function(i,s){t.get(i).onsuccess=function(t){t.target.result?r[s]=t.target.result:r[s]={key:i,error:"not_found"},o++,o===e.length&&r.forEach((function(e){n(e)}))}}))}(a,p,e=>{if(e.error)return o.push(e);const t={id:e.id,key:e.id,value:{rev:e.rev}};e.deleted?(t.value.deleted=!0,t.doc=null):n.include_docs&&_(t,e),o.push(t)})}let v=Be([0,d],[0,h],!0,f,s,l);if(v.error)return Pe(n,t,v.error,r);function _(e,r){const o=r.revs[r.rev].data;if(e.doc=o,e.doc._id=r.id,e.doc._rev=r.rev,n.conflicts){const t=Y(r);t.length&&(e.doc._conflicts=t)}if(n.attachments&&o._attachments)for(const s in o._attachments)i.push(me(s,r,e.doc,n.binary,t.idb_attachment_format))}function y(){const e={total_rows:t.doc_count,offset:0,rows:o};n.update_seq&&(e.update_seq=t.seq),i.length?Promise.all(i).then((function(){r(null,e)})):r(null,e)}e.txn.oncomplete=y;const m=p.index("deleted,id");if(u||c){let o,i=c>0;m.openKeyCursor(v,l||"next").onsuccess=a=>{const d=a.target.result;if(u)return d?(d.advance(u),void(u=0)):e.txn.commit();if(void 0===o&&(o=d&&d.key,!o))return e.txn.commit();if(c){if(c>1&&d)return d.advance(c-1),void(c=void 0);c=void 0}if(i&&(i=d&&d.key),i||(i=l?v.lower:v.upper),v=Be(o,i,!0,f,s,l),v.error)return e.txn.abort(),Pe(n,t,v.error,r);g()}}else g();async function g(){let t=v;do{t=await r(t)}while(t);return l&&o.reverse(),e.txn.commit();function r(e){return new Promise(t=>{m.getAll(e,100).onsuccess=r=>{const i=r.target.result;for(let e=0;e<i.length;++e){const t=i[e],r={id:t.id,key:t.id,value:{rev:t.rev}};n.include_docs&&_(r,t),o.push(r)}if(i.length>=100){const n=[0,i[i.length-1].id],r=l?e.upper:n,o=l?n:e.upper;if(r[1]!==o[1]){return t(Be(r,o,!!l,!l&&f,s,l))}}return t()}})}}}function Ie(e,t,n){if(e.error)return n(e.error);e.txn.objectStore("docs").get(t).onsuccess=function(e){e.target.result?n(null,e.target.result.rev_tree):n(k(p))}}function Le(e,t,n,r){if(e.error)return r(e.error);const o=e.txn.objectStore("docs");o.get(t).onsuccess=function(e){const t=e.target.result;G(t.rev_tree,(function(e,t,r,o,i){const s=t+"-"+r;-1!==n.indexOf(s)&&(i.status="missing")}));const r=[];n.forEach((function(e){if(e in t.revs){if(t.revs[e].data._attachments)for(const n in t.revs[e].data._attachments)r.push(t.revs[e].data._attachments[n].digest);delete t.revs[e]}})),r.forEach((function(e){n.forEach((function(n){delete t.attachments[e].revs[n]})),Object.keys(t.attachments[e].revs).length||delete t.attachments[e]})),o.put(t)},e.txn.oncomplete=function(){r()}}const Ee=Number.NEGATIVE_INFINITY,Me=[[[[[[[[[[[[]]]]]]]]]]]];function qe(e){const t=e.revs[e.rev].data;return t._id=e.id,t._rev=e.rev,e.deleted&&(t._deleted=!0),t}function De(e,t,n,r){const o=this,i=t.split("/");return new Promise((function(e,s){o.get("_design/"+i[0]).then((function(a){if(function(e,t){return t in e.views&&e.views[t].options&&e.views[t].options.def&&e.views[t].options.def.partial_filter_selector}(a,i[1]))return r(t,n).then(e,s);const u=ge(a,i[1]);if(!u)throw new Error("ddoc "+a._id+" with view "+i[1]+" does not have map.options.def.fields defined.");let c=n.skip,f=Number.isInteger(n.limit)&&n.limit;return function e(t,n,r){const o=be(n);return new Promise((function(i){t._openTransactionSafely(["docs"],"readonly",(function(s,a){if(s)return ye(r)(s);a.onabort=ye(r),a.ontimeout=ye(r);-1===Array.from(a.objectStore("docs").indexNames).indexOf(o)?t._freshen().then((function(){return e(t,n,r)})).then(i):i(a.objectStore("docs").index(o))}))}))}(o,u,s).then((function(t){const r=function(e){function t(e,t){return void 0!==e[t]}function n(e,t){return[0].concat(e).map((function(e){if(null===e&&t)return se;if(!0===e)return ue;if(!1===e)return ae;if(!t){if(null===e)return Ee;if(Object.prototype.hasOwnProperty.call(e,"\uffff"))return Me}return e}))}if(t(e,"inclusive_end")||(e.inclusive_end=!0),t(e,"inclusive_start")||(e.inclusive_start=!0),e.descending){const t=e.startkey,n=e.inclusive_start;e.startkey=e.endkey,e.endkey=t,e.inclusive_start=e.inclusive_end,e.inclusive_end=n}try{return t(e,"key")?IDBKeyRange.only(n(e.key,!0)):t(e,"startkey")&&!t(e,"endkey")?IDBKeyRange.bound(n(e.startkey),[1],!e.inclusive_start,!0):!t(e,"startkey")&&t(e,"endkey")?IDBKeyRange.upperBound(n(e.endkey),!e.inclusive_end):t(e,"startkey")&&t(e,"endkey")?IDBKeyRange.bound(n(e.startkey),n(e.endkey),!e.inclusive_start,!e.inclusive_end):IDBKeyRange.only([0])}catch(t){throw console.error("Could not generate keyRange",t,e),Error("Could not generate key range with "+JSON.stringify(e))}}(n),o=t.openCursor(r,n.descending?"prev":"next"),i=[];o.onerror=ye(s),o.onsuccess=function(t){const n=t.target.result;return n&&0!==f?c?(n.advance(c),void(c=!1)):(f&&(f-=1),i.push({doc:qe(n.value)}),void n.continue()):e({rows:i})}}))})).catch(s)}))}function Re(e,t){return t()}function Ue(e,t,n,r){if(e.error)return r(e.error);const o=e.txn.objectStore("docs"),i=[];let s=!1;o.get(t).onsuccess=e=>{const t=e.target.result;for(const e of n)t.rev_tree=oe(t.rev_tree,e),delete t.revs[e],i.push(e);if(0===t.rev_tree.length)return o.delete(t.id),void(s=!0);t.rev=J(t),t.data=t.revs[t.rev].data,t.attachments=function(e,t){if(!e.attachments)return{};for(let n in e.attachments){const r=e.attachments[n];for(let e of t)r.revs[e]&&delete r.revs[e];0===Object.keys(r.revs).length&&delete e.attachments[n]}return e.attachments}(t,n),o.put(t)},e.txn.oncomplete=function(){r(null,{ok:!0,deletedRevs:i,documentWasRemovedCompletely:s})}}const Ne=new class extends o{constructor(){super(),this._listeners={},l()&&addEventListener("storage",e=>{this.emit(e.key)})}addListener(e,t,n,r){if(!this._listeners[t]){var o=!1,i=this;this._listeners[t]=s,this.on(e,s)}function s(){if(i._listeners[t])if(o)o="waiting";else{o=!0;var e=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}(r,["style","include_docs","attachments","conflicts","filter","doc_ids","view","since","query_params","binary","return_docs"]);n.changes(e).on("change",(function(e){e.seq>r.since&&!r.cancelled&&(r.since=e.seq,r.onChange(e))})).on("complete",(function(){"waiting"===o&&d(s),o=!1})).on("error",(function(){o=!1}))}}}removeListener(e,t){t in this._listeners&&(super.removeListener(e,this._listeners[t]),delete this._listeners[t])}notifyLocalWindows(e){l()&&(localStorage[e]="a"===localStorage[e]?"b":"a")}notify(e){this.emit(e),this.notifyLocalWindows(e)}},Te={};function Fe(e,t){e.view_adapter&&console.log("Please note that the indexeddb adapter manages _find indexes itself, therefore it is not using your specified view_adapter");const n=this;let r={};const o=function(t){return function(){const o=Array.prototype.slice.call(arguments);xe(Te,n,e).then((function(e){r=e.metadata,o.unshift(e.idb),t.apply(n,o)})).catch((function(e){const t=o.pop();"function"==typeof t?t(e):console.error(e)}))}},i=function(t){return function(){const o=Array.prototype.slice.call(arguments);return xe(Te,n,e).then((function(e){return r=e.metadata,o.unshift(e.idb),t.apply(n,o)}))}},s=function(t,o,i){return i=i||"readonly",function(){const s=Array.prototype.slice.call(arguments),a={};xe(Te,n,e).then((function(e){r=e.metadata,a.txn=e.idb.transaction(o,i)})).catch((function(e){console.error("Failed to establish transaction safely"),console.error(e),a.error=e})).then((function(){s.unshift(a),t.apply(n,s)}))}};n._openTransactionSafely=function(e,t,n){s((function(e,t){t(e.error,e.txn)}),e,t)(n)},n._remote=!1,n.type=function(){return"indexeddb"},n._id=o((function(e,t){t(null,r.db_uuid)})),n._info=o((function(e,t){return function(e,t){t(null,{doc_count:e.doc_count,update_seq:e.seq})}(r,t)})),n._get=s(Oe,["docs"]),n._getLocal=s((function(e,t,r){return function(e,t,n,r){if(e.error)return r(e.error);e.txn.objectStore("meta").get(t).onsuccess=function(e){const t=e.target.result;if(!t)return void r(k(p,"missing"));const o=t.revs[t.rev].data;if(o._id=t.id,o._rev=t.rev,o._attachments){const e=[];for(const r in o._attachments)e.push(me(r,t,o,!1,n.blobSupport));Promise.all(e).then(()=>r(null,o)).catch(r)}else r(null,o)}}(e,t,n,r)}),["meta"]),n._bulkDocs=o((function(t,o,i,s){Se(n,o,i,r,e,Ne,s)})),n._allDocs=s((function(e,t,n){Ce(e,r,t,n)}),["docs"]),n._getAttachment=ke,n._changes=s((function(t,r){!function(e,t,n,r,o){if(e.error)return o.complete(e.error);if(o.continuous){const e=r.name+":"+F();return t.addListener(r.name,e,n,o),t.notify(r.name),{cancel:function(){t.removeListener(r.name,e)}}}let i="limit"in o?o.limit:-1;0===i&&(i=1);const s=e.txn.objectStore("docs").index("seq"),a=S(o);let u=0,c=o.since||0;const f=[],l=[];let d;d=o.descending?s.openCursor(null,"prev"):s.openCursor(IDBKeyRange.lowerBound(o.since,!0)),e.txn.oncomplete=function(){Promise.all(l).then((function(){o.complete(null,{results:f,last_seq:c})}))},d.onsuccess=function(e){if(!e.target.result)return;const t=e.target.result,r=t.value;if(r.data=r.revs[r.rev].data,r.data._id=r.id,r.data._rev=r.rev,r.deleted&&(r.data._deleted=!0),o.doc_ids&&-1===o.doc_ids.indexOf(r.id))return t.continue();const s=o.processChange(r.data,r,o);s.seq=r.seq,c=r.seq;const d=a(s);if("object"==typeof d)return o.complete(d);if(d)if(u++,o.return_docs&&f.push(s),o.include_docs&&o.attachments&&r.data._attachments){const e=[];for(const t in r.data._attachments){const i=me(t,r,s.doc,o.binary,n.blobSupport);e.push(i),l.push(i)}Promise.all(e).then((function(){o.onChange(s)}))}else o.onChange(s);u!==i&&t.continue()}}(t,Ne,n,e,r)}),["docs"]),n._getRevisionTree=s(Ie,["docs"]),n._doCompaction=s(Le,["docs"],"readwrite"),n._customFindAbstractMapper={query:i(De),viewCleanup:i(Re)},n._destroy=function(t,n){return function(e,t,n,r){function o(){indexedDB.deleteDatabase(e.name).onsuccess=function(){delete t[e.name],r(null,{ok:!0})}}n.removeAllListeners(e.name),e.name in t?t[e.name].then((function(e){e.idb.close(),o()})):o()}(e,Te,Ne,n)},n._close=o((function(t,n){delete Te[e.name],t.close(),n()})),n._freshen=function(){return new Promise((function(e){n._close((function(){o(e)()}))}))},n._purge=s(Ue,["docs"],"readwrite"),setTimeout((function(){t(null,n)}))}Fe.valid=function(){return!0},"undefined"==typeof PouchDB?function(e){if("undefined"!=typeof console&&"function"==typeof console[e]){var t=Array.prototype.slice.call(arguments,1);console[e].apply(console,t)}}("error",'indexeddb adapter plugin error: Cannot find global "PouchDB" object! Did you remember to include pouchdb.js?'):PouchDB.plugin((function(e){e.adapter("indexeddb",Fe,!0)}))},{events:1,"spark-md5":2,uuid:3}]},{},[18]);
3//# sourceMappingURL=pouchdb.indexeddb.min.js.map
\No newline at end of file