com.vaadin.polymer.public.bower_components.pouchdb.dist.pouchdb.find.min.js Maven / Gradle / Ivy
The newest version!
// pouchdb-find plugin 6.3.4
// Based on Mango: https://github.com/cloudant/mango
//
// (c) 2012-2017 Dale Harvey and the PouchDB team
// PouchDB may be freely distributed under the Apache license, version 2.0.
// For all details and documentation:
// http://pouchdb.com
!function e(t,n,r){function i(u,s){if(!n[u]){if(!t[u]){var a="function"==typeof require&&require;if(!s&&a)return a(u,!0);if(o)return o(u,!0);var c=new Error("Cannot find module '"+u+"'");throw c.code="MODULE_NOT_FOUND",c}var f=n[u]={exports:{}};t[u][0].call(f.exports,function(e){var n=t[u][1][e];return i(n||e)},f,f.exports,e,t,n,r)}return n[u].exports}for(var o="function"==typeof require&&require,u=0;u0&&this._events[e].length>n&&(this._events[e].warned=!0,console.error("(node) warning: possible EventEmitter memory leak detected. %d listeners added. Use emitter.setMaxListeners() to increase limit.",this._events[e].length),"function"==typeof console.trace&&console.trace()),this},r.prototype.on=r.prototype.addListener,r.prototype.once=function(e,t){function n(){this.removeListener(e,n),r||(r=!0,t.apply(this,arguments))}if(!i(t))throw TypeError("listener must be a function");var r=!1;return n.listener=t,this.on(e,n),this},r.prototype.removeListener=function(e,t){var n,r,o,s;if(!i(t))throw TypeError("listener must be a function");if(!this._events||!this._events[e])return this;if(n=this._events[e],o=n.length,r=-1,n===t||i(n.listener)&&n.listener===t)delete this._events[e],this._events.removeListener&&this.emit("removeListener",e,t);else if(u(n)){for(s=o;s-- >0;)if(n[s]===t||n[s].listener&&n[s].listener===t){r=s;break}if(r<0)return this;1===n.length?(n.length=0,delete this._events[e]):n.splice(r,1),this._events.removeListener&&this.emit("removeListener",e,t)}return this},r.prototype.removeAllListeners=function(e){var t,n;if(!this._events)return this;if(!this._events.removeListener)return 0===arguments.length?this._events={}:this._events[e]&&delete this._events[e],this;if(0===arguments.length){for(t in this._events)"removeListener"!==t&&this.removeAllListeners(t);return this.removeAllListeners("removeListener"),this._events={},this}if(n=this._events[e],i(n))this.removeListener(e,n);else if(n)for(;n.length;)this.removeListener(e,n[n.length-1]);return delete this._events[e],this},r.prototype.listeners=function(e){return this._events&&this._events[e]?i(this._events[e])?[this._events[e]]:this._events[e].slice():[]},r.prototype.listenerCount=function(e){if(this._events){var t=this._events[e];if(i(t))return 1;if(t)return t.length}return 0},r.listenerCount=function(e,t){return e.listenerCount(t)}},{}],3:[function(e,t,n){(function(e){"use strict";function n(){f=!0;for(var e,t,n=l.length;n;){for(t=l,l=[],e=-1;++e1)for(var n=1;n>>25)+r|0,o+=(n&r|~n&i)+t[1]-389564586|0,o=(o<<12|o>>>20)+n|0,i+=(o&n|~o&r)+t[2]+606105819|0,i=(i<<17|i>>>15)+o|0,r+=(i&o|~i&n)+t[3]-1044525330|0,r=(r<<22|r>>>10)+i|0,n+=(r&i|~r&o)+t[4]-176418897|0,n=(n<<7|n>>>25)+r|0,o+=(n&r|~n&i)+t[5]+1200080426|0,o=(o<<12|o>>>20)+n|0,i+=(o&n|~o&r)+t[6]-1473231341|0,i=(i<<17|i>>>15)+o|0,r+=(i&o|~i&n)+t[7]-45705983|0,r=(r<<22|r>>>10)+i|0,n+=(r&i|~r&o)+t[8]+1770035416|0,n=(n<<7|n>>>25)+r|0,o+=(n&r|~n&i)+t[9]-1958414417|0,o=(o<<12|o>>>20)+n|0,i+=(o&n|~o&r)+t[10]-42063|0,i=(i<<17|i>>>15)+o|0,r+=(i&o|~i&n)+t[11]-1990404162|0,r=(r<<22|r>>>10)+i|0,n+=(r&i|~r&o)+t[12]+1804603682|0,n=(n<<7|n>>>25)+r|0,o+=(n&r|~n&i)+t[13]-40341101|0,o=(o<<12|o>>>20)+n|0,i+=(o&n|~o&r)+t[14]-1502002290|0,i=(i<<17|i>>>15)+o|0,r+=(i&o|~i&n)+t[15]+1236535329|0,r=(r<<22|r>>>10)+i|0,n+=(r&o|i&~o)+t[1]-165796510|0,n=(n<<5|n>>>27)+r|0,o+=(n&i|r&~i)+t[6]-1069501632|0,o=(o<<9|o>>>23)+n|0,i+=(o&r|n&~r)+t[11]+643717713|0,i=(i<<14|i>>>18)+o|0,r+=(i&n|o&~n)+t[0]-373897302|0,r=(r<<20|r>>>12)+i|0,n+=(r&o|i&~o)+t[5]-701558691|0,n=(n<<5|n>>>27)+r|0,o+=(n&i|r&~i)+t[10]+38016083|0,o=(o<<9|o>>>23)+n|0,i+=(o&r|n&~r)+t[15]-660478335|0,i=(i<<14|i>>>18)+o|0,r+=(i&n|o&~n)+t[4]-405537848|0,r=(r<<20|r>>>12)+i|0,n+=(r&o|i&~o)+t[9]+568446438|0,n=(n<<5|n>>>27)+r|0,o+=(n&i|r&~i)+t[14]-1019803690|0,o=(o<<9|o>>>23)+n|0,i+=(o&r|n&~r)+t[3]-187363961|0,i=(i<<14|i>>>18)+o|0,r+=(i&n|o&~n)+t[8]+1163531501|0,r=(r<<20|r>>>12)+i|0,n+=(r&o|i&~o)+t[13]-1444681467|0,n=(n<<5|n>>>27)+r|0,o+=(n&i|r&~i)+t[2]-51403784|0,o=(o<<9|o>>>23)+n|0,i+=(o&r|n&~r)+t[7]+1735328473|0,i=(i<<14|i>>>18)+o|0,r+=(i&n|o&~n)+t[12]-1926607734|0,r=(r<<20|r>>>12)+i|0,n+=(r^i^o)+t[5]-378558|0,n=(n<<4|n>>>28)+r|0,o+=(n^r^i)+t[8]-2022574463|0,o=(o<<11|o>>>21)+n|0,i+=(o^n^r)+t[11]+1839030562|0,i=(i<<16|i>>>16)+o|0,r+=(i^o^n)+t[14]-35309556|0,r=(r<<23|r>>>9)+i|0,n+=(r^i^o)+t[1]-1530992060|0,n=(n<<4|n>>>28)+r|0,o+=(n^r^i)+t[4]+1272893353|0,o=(o<<11|o>>>21)+n|0,i+=(o^n^r)+t[7]-155497632|0,i=(i<<16|i>>>16)+o|0,r+=(i^o^n)+t[10]-1094730640|0,r=(r<<23|r>>>9)+i|0,n+=(r^i^o)+t[13]+681279174|0,n=(n<<4|n>>>28)+r|0,o+=(n^r^i)+t[0]-358537222|0,o=(o<<11|o>>>21)+n|0,i+=(o^n^r)+t[3]-722521979|0,i=(i<<16|i>>>16)+o|0,r+=(i^o^n)+t[6]+76029189|0,r=(r<<23|r>>>9)+i|0,n+=(r^i^o)+t[9]-640364487|0,n=(n<<4|n>>>28)+r|0,o+=(n^r^i)+t[12]-421815835|0,o=(o<<11|o>>>21)+n|0,i+=(o^n^r)+t[15]+530742520|0,i=(i<<16|i>>>16)+o|0,r+=(i^o^n)+t[2]-995338651|0,r=(r<<23|r>>>9)+i|0,n+=(i^(r|~o))+t[0]-198630844|0,n=(n<<6|n>>>26)+r|0,o+=(r^(n|~i))+t[7]+1126891415|0,o=(o<<10|o>>>22)+n|0,i+=(n^(o|~r))+t[14]-1416354905|0,i=(i<<15|i>>>17)+o|0,r+=(o^(i|~n))+t[5]-57434055|0,r=(r<<21|r>>>11)+i|0,n+=(i^(r|~o))+t[12]+1700485571|0,n=(n<<6|n>>>26)+r|0,o+=(r^(n|~i))+t[3]-1894986606|0,o=(o<<10|o>>>22)+n|0,i+=(n^(o|~r))+t[10]-1051523|0,i=(i<<15|i>>>17)+o|0,r+=(o^(i|~n))+t[1]-2054922799|0,r=(r<<21|r>>>11)+i|0,n+=(i^(r|~o))+t[8]+1873313359|0,n=(n<<6|n>>>26)+r|0,o+=(r^(n|~i))+t[15]-30611744|0,o=(o<<10|o>>>22)+n|0,i+=(n^(o|~r))+t[6]-1560198380|0,i=(i<<15|i>>>17)+o|0,r+=(o^(i|~n))+t[13]+1309151649|0,r=(r<<21|r>>>11)+i|0,n+=(i^(r|~o))+t[4]-145523070|0,n=(n<<6|n>>>26)+r|0,o+=(r^(n|~i))+t[11]-1120210379|0,o=(o<<10|o>>>22)+n|0,i+=(n^(o|~r))+t[2]+718787259|0,i=(i<<15|i>>>17)+o|0,r+=(o^(i|~n))+t[9]-343485551|0,r=(r<<21|r>>>11)+i|0,e[0]=n+e[0]|0,e[1]=r+e[1]|0,e[2]=i+e[2]|0,e[3]=o+e[3]|0}function n(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 r(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 r,i,o,u,s,a,c=e.length,f=[1732584193,-271733879,-1732584194,271733878];for(r=64;r<=c;r+=64)t(f,n(e.substring(r-64,r)));for(e=e.substring(r-64),i=e.length,o=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],r=0;r>2]|=e.charCodeAt(r)<<(r%4<<3);if(o[r>>2]|=128<<(r%4<<3),r>55)for(t(f,o),r=0;r<16;r+=1)o[r]=0;return u=8*c,u=u.toString(16).match(/(.*?)(.{0,8})$/),s=parseInt(u[2],16),a=parseInt(u[1],16)||0,o[14]=s,o[15]=a,t(f,o),f}function o(e){var n,i,o,u,s,a,c=e.length,f=[1732584193,-271733879,-1732584194,271733878];for(n=64;n<=c;n+=64)t(f,r(e.subarray(n-64,n)));for(e=n-64>2]|=e[n]<<(n%4<<3);if(o[n>>2]|=128<<(n%4<<3),n>55)for(t(f,o),n=0;n<16;n+=1)o[n]=0;return u=8*c,u=u.toString(16).match(/(.*?)(.{0,8})$/),s=parseInt(u[2],16),a=parseInt(u[1],16)||0,o[14]=s,o[15]=a,t(f,o),f}function u(e){var t,n="";for(t=0;t<4;t+=1)n+=v[e>>8*t+4&15]+v[e>>8*t&15];return n}function s(e){var t;for(t=0;t>16)+(t>>16)+(n>>16)<<16|65535&n},"undefined"==typeof ArrayBuffer||ArrayBuffer.prototype.slice||function(){function t(e,t){return e=0|e||0,e<0?Math.max(e+t,0):Math.min(e,t)}ArrayBuffer.prototype.slice=function(n,r){var i,o,u,s,a=this.byteLength,c=t(n,a),f=a;return r!==e&&(f=t(r,a)),c>f?new ArrayBuffer(0):(i=f-c,o=new ArrayBuffer(i),u=new Uint8Array(o),s=new Uint8Array(this,c,i),u.set(s),o)}}(),h.prototype.append=function(e){return this.appendBinary(a(e)),this},h.prototype.appendBinary=function(e){this._buff+=e,this._length+=e.length;var r,i=this._buff.length;for(r=64;r<=i;r+=64)t(this._hash,n(this._buff.substring(r-64,r)));return this._buff=this._buff.substring(r-64),this},h.prototype.end=function(e){var t,n,r=this._buff,i=r.length,o=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0];for(t=0;t>2]|=r.charCodeAt(t)<<(t%4<<3);return this._finish(o,i),n=s(this._hash),e&&(n=d(n)),this.reset(),n},h.prototype.reset=function(){return this._buff="",this._length=0,this._hash=[1732584193,-271733879,-1732584194,271733878],this},h.prototype.getState=function(){return{buff:this._buff,length:this._length,hash:this._hash}},h.prototype.setState=function(e){return this._buff=e.buff,this._length=e.length,this._hash=e.hash,this},h.prototype.destroy=function(){delete this._hash,delete this._buff,delete this._length},h.prototype._finish=function(e,n){var r,i,o,u=n;if(e[u>>2]|=128<<(u%4<<3),u>55)for(t(this._hash,e),u=0;u<16;u+=1)e[u]=0;r=8*this._length,r=r.toString(16).match(/(.*?)(.{0,8})$/),i=parseInt(r[2],16),o=parseInt(r[1],16)||0,e[14]=i,e[15]=o,t(this._hash,e)},h.hash=function(e,t){return h.hashBinary(a(e),t)},h.hashBinary=function(e,t){var n=i(e),r=s(n);return t?d(r):r},h.ArrayBuffer=function(){this.reset()},h.ArrayBuffer.prototype.append=function(e){var n,i=l(this._buff.buffer,e,!0),o=i.length;for(this._length+=e.byteLength,n=64;n<=o;n+=64)t(this._hash,r(i.subarray(n-64,n)));return this._buff=n-64>2]|=r[t]<<(t%4<<3);return this._finish(o,i),n=s(this._hash),e&&(n=d(n)),this.reset(),n},h.ArrayBuffer.prototype.reset=function(){return this._buff=new Uint8Array(0),this._length=0,this._hash=[1732584193,-271733879,-1732584194,271733878],this},h.ArrayBuffer.prototype.getState=function(){var e=h.prototype.getState.call(this);return e.buff=f(e.buff),e},h.ArrayBuffer.prototype.setState=function(e){return e.buff=c(e.buff,!0),h.prototype.setState.call(this,e)},h.ArrayBuffer.prototype.destroy=h.prototype.destroy,h.ArrayBuffer.prototype._finish=h.prototype._finish,h.ArrayBuffer.hash=function(e,t){var n=o(new Uint8Array(e)),r=s(n);return t?d(r):r},h})},{}],8:[function(e,t,n){var r=e(11),i=e(12),o=i;o.v1=r,o.v4=i,t.exports=o},{11:11,12:12}],9:[function(e,t,n){function r(e,t){var n=t||0,r=i;return r[e[n++]]+r[e[n++]]+r[e[n++]]+r[e[n++]]+"-"+r[e[n++]]+r[e[n++]]+"-"+r[e[n++]]+r[e[n++]]+"-"+r[e[n++]]+r[e[n++]]+"-"+r[e[n++]]+r[e[n++]]+r[e[n++]]+r[e[n++]]+r[e[n++]]+r[e[n++]]}for(var i=[],o=0;o<256;++o)i[o]=(o+256).toString(16).substr(1);t.exports=r},{}],10:[function(e,t,n){(function(e){var n,r=e.crypto||e.msCrypto;if(r&&r.getRandomValues){var i=new Uint8Array(16);n=function(){return r.getRandomValues(i),i}}if(!n){var o=new Array(16);n=function(){for(var e,t=0;t<16;t++)0==(3&t)&&(e=4294967296*Math.random()),o[t]=e>>>((3&t)<<3)&255;return o}}t.exports=n}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],11:[function(e,t,n){function r(e,t,n){var r=t&&n||0,i=t||[];e=e||{};var u=void 0!==e.clockseq?e.clockseq:a,l=void 0!==e.msecs?e.msecs:(new Date).getTime(),d=void 0!==e.nsecs?e.nsecs:f+1,h=l-c+(d-f)/1e4;if(h<0&&void 0===e.clockseq&&(u=u+1&16383),(h<0||l>c)&&void 0===e.nsecs&&(d=0),d>=1e4)throw new Error("uuid.v1(): Can't create more than 10M uuids/sec");c=l,f=d,a=u,l+=122192928e5;var v=(1e4*(268435455&l)+d)%4294967296;i[r++]=v>>>24&255,i[r++]=v>>>16&255,i[r++]=v>>>8&255,i[r++]=255&v;var p=l/4294967296*1e4&268435455;i[r++]=p>>>8&255,i[r++]=255&p,i[r++]=p>>>24&15|16,i[r++]=p>>>16&255,i[r++]=u>>>8|128,i[r++]=255&u;for(var y=e.node||s,g=0;g<6;++g)i[r+g]=y[g];return t||o(i)}var i=e(10),o=e(9),u=i(),s=[1|u[0],u[1],u[2],u[3],u[4],u[5]],a=16383&(u[6]<<8|u[7]),c=0,f=0;t.exports=r},{10:10,9:9}],12:[function(e,t,n){function r(e,t,n){var r=t&&n||0;"string"==typeof e&&(t="binary"==e?new Array(16):null,e=null),e=e||{};var u=e.random||(e.rng||i)();if(u[6]=15&u[6]|64,u[8]=63&u[8]|128,t)for(var s=0;s<16;++s)t[r+s]=u[s];return t||o(u)}var i=e(10),o=e(9);t.exports=r},{10:10,9:9}],13:[function(e,t,n){(function(t){"use strict";function n(e){return e&&"object"==typeof e&&"default"in e?e.default:e}function r(e){return"undefined"!=typeof ArrayBuffer&&e instanceof ArrayBuffer||"undefined"!=typeof Blob&&e instanceof Blob}function i(e){if("function"==typeof e.slice)return e.slice(0);var t=new ArrayBuffer(e.byteLength),n=new Uint8Array(t),r=new Uint8Array(e);return n.set(r),t}function o(e){if(e instanceof ArrayBuffer)return i(e);var t=e.size,n=e.type;return"function"==typeof e.slice?e.slice(0,t,n):e.webkitSlice(0,t,n)}function u(e){var t=Object.getPrototypeOf(e);if(null===t)return!0;var n=t.constructor;return"function"==typeof n&&n instanceof n&&Yt.call(n)==Ht}function s(e){var t,n,i;if(!e||"object"!=typeof e)return e;if(Array.isArray(e)){for(t=[],n=0,i=e.length;nt?1:0}function C(e){for(var t=[],n="",r=0,i=e.length;r0&&"\\"===e[r-1]?n=n.substring(0,n.length-1)+".":(t.push(n),n=""):n+=o}return t.push(n),t}function D(e){return on.indexOf(e)>-1}function I(e){return Object.keys(e)[0]}function U(e){return e[I(e)]}function F(e){var t={};return e.forEach(function(e){Object.keys(e).forEach(function(n){var r=e[n];if("object"!=typeof r&&(r={$eq:r}),D(n))r instanceof Array?t[n]=r.map(function(e){return F([e])}):t[n]=F([r]);else{var i=t[n]=t[n]||{};Object.keys(r).forEach(function(e){var t=r[e];return"$gt"===e||"$gte"===e?N(e,t,i):"$lt"===e||"$lte"===e?P(e,t,i):"$ne"===e?R(t,i):"$eq"===e?z(t,i):void(i[e]=t)})}})}),t}function N(e,t,n){void 0===n.$eq&&(void 0!==n.$gte?"$gte"===e?t>n.$gte&&(n.$gte=t):t>=n.$gte&&(delete n.$gte,n.$gt=t):void 0!==n.$gt?"$gte"===e?t>n.$gt&&(delete n.$gt,n.$gte=t):t>n.$gt&&(n.$gt=t):n[e]=t)}function P(e,t,n){void 0===n.$eq&&(void 0!==n.$lte?"$lte"===e?tt.length?1:-1}function te(e,t){return e===t?0:e>t?1:-1}function ne(e,t){for(var n=Object.keys(e),r=Object.keys(t),i=Math.min(n.length,r.length),o=0;or.length?1:-1}function re(e){var t=["boolean","number","string","object"],n=t.indexOf(typeof e);return~n?null===e?1:Array.isArray(e)?5:n<3?n+2:n+3:Array.isArray(e)?5:void 0}function ie(e){if(0===e)return"1";var t=e.toExponential().split(/e\+?/),n=parseInt(t[1],10),r=e<0,i=r?"0":"2",o=(r?-n:n)-un,u=K(o.toString(),"0",sn);i+=an+u;var s=Math.abs(parseFloat(t[0]));r&&(s=10-s);var a=s.toFixed(20);return a=a.replace(/\.?0+$/,""),i+=an+a}function oe(e){function t(t){return e.map(function(e){var n=I(e),r=C(n);return B(t,r)})}return function(e,n){var r=t(e.doc),i=t(n.doc),o=W(r,i);return 0!==o?o:M(e.doc._id,n.doc._id)}}function ue(e,t,n){if(e=e.filter(function(e){return se(e.doc,t.selector,n)}),t.sort){var r=oe(t.sort);e=e.sort(r),"string"!=typeof t.sort[0]&&"desc"===U(t.sort[0])&&(e=e.reverse())}if("limit"in t||"skip"in t){var i=t.skip||0,o=("limit"in t?t.limit:e.length)+i;e=e.slice(i,o)}return e}function se(e,t,n){return n.every(function(n){var r=t[n],i=C(n),o=B(e,i);return D(n)?ce(n,r,e):ae(r,e,i,o)})}function ae(e,t,n,r){return!e||Object.keys(e).every(function(i){var o=e[i];return fe(i,t,o,n,r)})}function ce(e,t,n){return"$or"===e?t.some(function(e){return se(n,e,Object.keys(e))}):"$not"===e?!se(n,t,Object.keys(t)):!t.find(function(e){return se(n,e,Object.keys(e))})}function fe(e,t,n,r,i){if(!cn[e])throw new Error('unknown operator "'+e+'" - should be one of $eq, $lte, $lt, $gt, $gte, $exists, $ne, $in, $nin, $size, $mod, $regex, $elemMatch, $type, $allMatch or $all');return cn[e](t,n,r,i)}function le(e){return void 0!==e&&null!==e}function de(e){return void 0!==e}function he(e,t){var n=t[0],r=t[1];if(0===n)throw new Error("Bad divisor, cannot divide by zero");if(parseInt(n,10)!==n)throw new Error("Divisor is not an integer");if(parseInt(r,10)!==r)throw new Error("Modulus is not an integer");return parseInt(e,10)===e&&e%n===r}function ve(e,t){return t.some(function(t){return e instanceof Array?e.indexOf(t)>-1:e===t})}function pe(e,t){return t.every(function(t){return e.indexOf(t)>-1})}function ye(e,t){return e.length===t}function ge(e,t){return new RegExp(t).test(e)}function me(e,t){switch(t){case"null":return null===e;case"boolean":return"boolean"==typeof e;case"number":return"number"==typeof e;case"string":return"string"==typeof e;case"array":return e instanceof Array;case"object":return"[object Object]"==={}.toString.call(e)}throw new Error(t+" not supported as a type.Please use one of object, string, array, number, boolean or null.")}function _e(e){return function(){for(var t=arguments.length,n=new Array(t),r=-1;++rt.length)&&xe(e,t)}function Ee(e,t){e=e.slice();for(var n=0,r=t.length;nr&&(r=s,n=u)}return n}function qe(e,t){if(e.length!==t.length)return!1;for(var n=0,r=e.length;nt.length;)s.pop();if(Math.abs(W(s,t))>0)break}return i>0?e.slice(i):e}function dt(e){var t=s(e);return delete t.startkey,delete t.endkey,delete t.inclusive_start,delete t.inclusive_end,"endkey"in e&&(t.startkey=e.endkey),"startkey"in e&&(t.endkey=e.startkey),"inclusive_start"in e&&(t.inclusive_end=e.inclusive_start),"inclusive_end"in e&&(t.inclusive_start=e.inclusive_end),t}function ht(e){var t=e.fields.filter(function(e){return"asc"===U(e)});if(0!==t.length&&t.length!==e.fields.length)throw new Error("unsupported mixed sorting")}function vt(e,t){if(t.defaultUsed&&e.sort){var n=e.sort.filter(function(e){return"_id"!==Object.keys(e)[0]}).map(function(e){return Object.keys(e)[0]});if(n.length>0)throw new Error('Cannot sort on field(s) "'+n.join(",")+'" when using the default index')}t.defaultUsed}function pt(e){if("object"!=typeof e.selector)throw new Error("you must provide a selector when you find()")}function yt(e,t){var n,r=Object.keys(e),i=t?t.map(I):[];return n=r.length>=i.length?r:i,0===i.length?{fields:n}:(n=n.sort(function(e,t){var n=i.indexOf(e);-1===n&&(n=Number.MAX_VALUE);var r=i.indexOf(t);return-1===r&&(r=Number.MAX_VALUE),nr?1:0}),{fields:n,sortOrder:t.map(I)})}function gt(e,t){function n(){return o||(o=De(JSON.stringify(t)))}function r(e){return e._rev&&"query"!==e.language&&(f=!0),e.language="query",e.views=e.views||{},!(l=!!e.views[u])&&(e.views[u]={map:{fields:ke(t.index.fields)},reduce:"_count",options:{def:i}},e)}t=E(t);var i=s(t.index);t.index=ct(t.index),ht(t.index);var o,u=t.name||"idx-"+n(),a=t.ddoc||"idx-"+n(),c="_design/"+a,f=!1,l=!1;return e.constructor.emit("debug",["find","creating index",c]),x(e,c,r).then(function(){if(f)throw new Error('invalid language for ddoc with id "'+c+'" (should be "query")')}).then(function(){var t=a+"/"+u;return pn.query.call(e,t,{limit:0,reduce:!1}).then(function(){return{id:c,name:u,result:l?"exists":"created"}})})}function mt(e){return e.allDocs({startkey:"_design/",endkey:"_design/",include_docs:!0}).then(function(e){var t={indexes:[{ddoc:null,name:"_all_docs",type:"special",def:{fields:[{_id:"asc"}]}}]};return t.indexes=fn(t.indexes,e.rows.filter(function(e){return"query"===e.doc.language}).map(function(e){return(void 0!==e.doc.views?Object.keys(e.doc.views):[]).map(function(t){var n=e.doc.views[t];return{ddoc:e.id,name:t,type:"json",def:ct(n.options.def)}})})),t.indexes.sort(function(e,t){return M(e.name,t.name)}),t.total_rows=t.indexes.length,t})}function _t(e,t){for(var n=e.def.fields.map(I),r=0,i=n.length;r0){if(Object.keys(d).some(Et)){n(c);break}var h="$gt"in d||"$gte"in d||"$lt"in d||"$lte"in d,v=Object.keys(e[o[c-1]]),p=qe(v,["$eq"]),y=qe(v,Object.keys(d));if(h&&!p&&!y){n(c);break}}for(var g=Object.keys(d),m=null,_=0;_0?{docs:[]}:(t.sort&&"string"!=typeof t.sort[0]&&"desc"===U(t.sort[0])&&(u.descending=!0,u=dt(u)),i.inMemoryFields.length||("limit"in t&&(u.limit=t.limit),"skip"in t&&(u.skip=t.skip)),n?Gt.resolve(i,u):Gt.resolve().then(function(){if("_all_docs"===o.name)return Ft(e,u);var t=Ut(o);return pn.query.call(e,t,u)}).then(function(e){!1===u.inclusive_start&&(e.rows=lt(e.rows,u.startkey,o)),i.inMemoryFields.length&&(e.rows=ue(e.rows,t,i.inMemoryFields));var n={docs:e.rows.map(function(e){var n=e.doc;return t.fields?$e(n,t.fields):n})};return o.defaultUsed&&(n.warning="no matching index found, create an index to optimize query time"),n}))})}function Pt(e,t){return Nt(e,t,!0).then(function(n){return{dbname:e.name,index:n.index,selector:t.selector,range:{start_key:n.queryOpts.startkey,end_key:n.queryOpts.endkey},opts:{use_index:t.use_index||[],bookmark:"nil",limit:t.limit,skip:t.skip,sort:t.sort||{},fields:t.fields,conflicts:!1,r:[49]},limit:t.limit,skip:t.skip||0,fields:t.fields}})}function Rt(e,t){function n(e){return 1===Object.keys(e.views).length&&e.views[i]?{_id:r,_deleted:!0}:(delete e.views[i],e)}if(!t.ddoc)throw new Error("you must supply an index.ddoc when deleting");if(!t.name)throw new Error("you must supply an index.name when deleting");var r=t.ddoc,i=t.name;return x(e,r,n).then(function(){return pn.viewCleanup.apply(e)}).then(function(){return{ok:!0}})}var zt=(n(e(8)),n(e(5))),Vt=n(e(1)),Jt=e(2),Kt=n(e(4)),Wt=n(e(3)),Xt=n(e(7)),Gt="function"==typeof Promise?Promise:zt,Yt=Function.prototype.toString,Ht=Yt.call(Object);d.prototype.get=function(e){var t=f(e);return this._store[t]},d.prototype.set=function(e,t){var n=f(e);return this._store[n]=t,!0},d.prototype.has=function(e){return f(e)in this._store},d.prototype.delete=function(e){var t=f(e),n=t in this._store;return delete this._store[t],n},d.prototype.forEach=function(e){for(var t=Object.keys(this._store),n=0,r=t.length;nr.since&&!r.cancelled&&(r.since=e.seq,r.onChange(e))}).on("complete",function(){"waiting"===u&&Wt(i),u=!1}).on("error",e)}}if(!this._listeners[t]){var o=this,u=!1;this._listeners[t]=i,this.on(e,i)}},m.prototype.removeListener=function(e,t){t in this._listeners&&(Jt.EventEmitter.prototype.removeListener.call(this,e,this._listeners[t]),delete this._listeners[t])},m.prototype.notifyLocalWindows=function(e){p()?chrome.storage.local.set({dbName:e}):y()&&(localStorage[e]="a"===localStorage[e]?"b":"a")},m.prototype.notify=function(e){this.emit(e),this.notifyLocalWindows(e)};var tn;tn="function"==typeof Object.assign?Object.assign:function(e){for(var t=Object(e),n=1;n=0},$gt:function(e,t,n,r){return de(r)&&W(r,t)>0},$lte:function(e,t,n,r){return de(r)&&W(r,t)<=0},$lt:function(e,t,n,r){return de(r)&&W(r,t)<0},$exists:function(e,t,n,r){return t?de(r):!de(r)},$mod:function(e,t,n,r){return le(r)&&he(r,t)},$ne:function(e,t,n,r){return t.every(function(e){return 0!==W(r,e)})},$in:function(e,t,n,r){return le(r)&&ve(r,t)},$nin:function(e,t,n,r){return le(r)&&!ve(r,t)},$size:function(e,t,n,r){return le(r)&&ye(r,t)},$all:function(e,t,n,r){return Array.isArray(r)&&pe(r,t)},$regex:function(e,t,n,r){return le(r)&&ge(r,t)},$type:function(e,t,n,r){return me(r,t)}},fn=_e(function(e){for(var t=[],n=0,r=e.length;n0?e.slice(n):e}function a(e){var t=e.value;return t&&"object"==typeof t&&t._id||e.id}function c(e){e.rows.forEach(function(e){var t=e.doc&&e.doc._attachments;t&&Object.keys(t).forEach(function(e){var n=t[e];t[e].data=Me(n.data,n.content_type)})})}function f(e){return function(t){return e.include_docs&&e.attachments&&e.binary&&c(t),t}}function l(e,t,n,r){var i=t[e];void 0!==i&&(r&&(i=encodeURIComponent(JSON.stringify(i))),n.push(e+"="+i))}function d(e){if(void 0!==e){var t=Number(e);return isNaN(t)||t!==parseInt(e,10)?e:t}}function h(e){return e.group_level=d(e.group_level),e.limit=d(e.limit),e.skip=d(e.skip),e}function v(e){if(e){if("number"!=typeof e)return new Ne('Invalid value for integer: "'+e+'"');if(e<0)return new Ne('Invalid value for positive integer: "'+e+'"')}}function p(e,t){var n=e.descending?"endkey":"startkey",r=e.descending?"startkey":"endkey";if(void 0!==e[n]&&void 0!==e[r]&&W(e[n],e[r])>0)throw new Ne("No rows can match your key range, reverse your start_key and end_key or set {descending : true}");if(t.reduce&&!1!==e.reduce){if(e.include_docs)throw new Ne("{include_docs:true} is invalid for reduce");if(e.keys&&e.keys.length>1&&!e.group&&!e.group_level)throw new Ne("Multi-key fetches for reduce views must use {group: true}")}["group_level","limit","skip"].forEach(function(t){var n=v(e[t]);if(n)throw n})}function y(e,t,n){var r,i=[],o="GET";if(l("reduce",n,i),l("include_docs",n,i),l("attachments",n,i),l("limit",n,i),l("descending",n,i),l("group",n,i),l("group_level",n,i),l("skip",n,i),l("stale",n,i),l("conflicts",n,i),l("startkey",n,i,!0),l("start_key",n,i,!0),l("endkey",n,i,!0),l("end_key",n,i,!0),l("inclusive_end",n,i),l("key",n,i,!0),i=i.join("&"),i=""===i?"":"?"+i,void 0!==n.keys){var u="keys="+encodeURIComponent(JSON.stringify(n.keys));u.length+i.length+1<=2e3?i+=("?"===i[0]?"&":"?")+u:(o="POST","string"==typeof t?r={keys:n.keys}:t.keys=n.keys)}if("string"==typeof t){var s=Ge(t);return e.request({method:o,url:"_design/"+s[0]+"/_view/"+s[1]+i,body:r}).then(function(e){return e.rows.forEach(function(e){if(e.value&&e.value.error&&"builtin_reduce_error"===e.value.error)throw new Error(e.reason)}),e}).then(f(n))}return r=r||{},Object.keys(t).forEach(function(e){Array.isArray(t[e])?r[e]=t[e]:r[e]=t[e].toString()}),e.request({method:"POST",url:"_temp_view"+i,body:r}).then(f(n))}function g(e,t,n){return new Gt(function(r,i){e._query(t,n,function(e,t){if(e)return i(e);r(t)})})}function m(e){return new Gt(function(t,n){e._viewCleanup(function(e,r){if(e)return n(e);t(r)})})}function _(e){return function(t){if(404===t.status)return e;throw t}}function w(e,t,n){function r(e){return e.keys.length?t.db.allDocs({keys:e.keys,include_docs:!0}):Gt.resolve({rows:[]})}function i(e,t){for(var n=[],r=new Qt,i=0,o=t.rows.length;i0&&0===W(o.key,t)&&u.push(r),n.set(Y(u),o),t=o.key}return n}var f,l,d=t(e.mapFun,n),h=e.seq||0,v=new Ce;return o().then(function(){return v.finish()}).then(function(){e.seq=h})}function O(e,t,r){0===r.group_level&&delete r.group_level;var i=r.group||r.group_level,u=n(e.reduceFun),a=[],c=isNaN(r.group_level)?Number.POSITIVE_INFINITY:r.group_level;t.forEach(function(e){var t=a[a.length-1],n=i?e.key:null;if(i&&Array.isArray(n)&&(n=n.slice(0,c)),t&&0===W(t.groupKey,n))return t.keys.push([e.key,e.id]),void t.values.push(e.value);a.push({keys:[[e.key,e.id]],values:[e.value],groupKey:n})}),t=[];for(var f=0,l=a.length;fn))return e.doc.value}var r=Z(e.doc._id);return{key:r[0],id:r[1],value:"value"in e.doc?e.doc.value:null}})})}function r(n){var r;if(r=o?O(e,n,t):{total_rows:i,offset:u,rows:n},t.include_docs){var s=We(n.map(a));return e.sourceDB.allDocs({keys:s,include_docs:!0,conflicts:t.conflicts,attachments:t.attachments,binary:t.binary}).then(function(e){var t=new Zt;return e.rows.forEach(function(e){t.set(e.id,e.doc)}),n.forEach(function(e){var n=a(e),r=t.get(n);r&&(e.doc=r)}),r})}return r}var i,o=e.reduceFun&&!1!==t.reduce,u=t.skip||0;if(void 0===t.keys||t.keys.length||(t.limit=0,delete t.keys),void 0!==t.keys){var s=t.keys,c=s.map(function(e){return n({startkey:Y([e]),endkey:Y([e,{}])})});return Gt.all(c).then(b).then(r)}var f,l,d={descending:t.descending};if("start_key"in t&&(f=t.start_key),"startkey"in t&&(f=t.startkey),"end_key"in t&&(l=t.end_key),"endkey"in t&&(l=t.endkey),void 0!==f&&(d.startkey=Y(t.descending?[f,{}]:[f])),void 0!==l){var h=!1!==t.inclusive_end;t.descending&&(h=!h),d.endkey=Y(h?[l,{}]:[l])}if(void 0!==t.key){var v=Y([t.key]),p=Y([t.key,{}]);d.descending?(d.endkey=v,d.startkey=p):(d.startkey=v,d.endkey=p)}return o||("number"==typeof t.limit&&(d.limit=t.limit),d.skip=u),n(d).then(r)}function S(e){return e.request({method:"POST",url:"_view_cleanup"})}function L(t){return t.get("_local/"+e).then(function(e){var n=new Zt;Object.keys(e.views).forEach(function(e){var t=Ge(e),r="_design/"+t[0],i=t[1],o=n.get(r);o||(o=new Qt,n.set(r,o)),o.add(i)});var r={keys:Xe(n),include_docs:!0};return t.allDocs(r).then(function(r){var i={};r.rows.forEach(function(t){var r=t.key.substring(8);n.get(t.key).forEach(function(n){var o=r+"/"+n;e.views[o]||(o=n);var u=Object.keys(e.views[o]),s=t.doc&&t.doc.views&&t.doc.views[n];u.forEach(function(e){i[e]=i[e]||s})})});var o=Object.keys(i).filter(function(e){return!i[e]}),u=o.map(function(e){return Ke(x(e),function(){return new t.constructor(e,t.__opts).destroy()})()});return Gt.all(u).then(function(){return{ok:!0}})})},_({ok:!0}))}function B(t,n,i){if("function"==typeof t._query)return g(t,n,i);if($(t))return y(t,n,i);if("string"!=typeof n)return p(i,n),hn.add(function(){return Fe(t,"temp_view/temp_view",n.map,n.reduce,!0,e).then(function(e){return Je(j(e).then(function(){return A(e,i)}),function(){return e.db.destroy()})})}),hn.finish();var o=n,u=Ge(o),s=u[0],a=u[1];return t.get("_design/"+s).then(function(n){var u=n.views&&n.views[a];if(!u)throw new Pe("ddoc "+n._id+" has no view named "+a);return r(n,a),p(i,u),Fe(t,o,u.map,u.reduce,!1,e).then(function(e){return"ok"===i.stale||"update_after"===i.stale?("update_after"===i.stale&&Wt(function(){j(e)}),A(e,i)):j(e).then(function(){return A(e,i)})})})}function T(e,t,n){var r=this;"function"==typeof t&&(n=t,t={}),t=t?h(t):{},"function"==typeof e&&(e={map:e});var i=Gt.resolve().then(function(){return B(r,e,t)});return ze(i,n),i}return{query:T,viewCleanup:Ve(function(){var e=this;return"function"==typeof e._viewCleanup?m(e):$(e)?S(e):L(e)})}}("indexes",it,ot,ut),yn=null,gn={"":{}},mn=["$eq","$gt","$gte","$lt","$lte"],_n=we(gt),wn=we(Nt),bn=we(Pt),kn=we(mt),$n=we(Rt),xn={};xn.createIndex=c(function(e,t){if("object"!=typeof e)return t(new Error("you must provide an index to create"));($(this)?O:_n)(this,e,t)}),xn.find=c(function(e,t){if(void 0===t&&(t=e,e=void 0),"object"!=typeof e)return t(new Error("you must provide search parameters to find()"));($(this)?A:wn)(this,e,t)}),xn.explain=c(function(e,t){if(void 0===t&&(t=e,e=void 0),"object"!=typeof e)return t(new Error("you must provide search parameters to explain()"));($(this)?q:bn)(this,e,t)}),xn.getIndexes=c(function(e){($(this)?S:kn)(this,e)}),xn.deleteIndex=c(function(e,t){if("object"!=typeof e)return t(new Error("you must provide an index to delete"));($(this)?L:$n)(this,e,t)}),"undefined"==typeof PouchDB?_("error",'pouchdb-find plugin error: Cannot find global "PouchDB" object! Did you remember to include pouchdb.js?'):PouchDB.plugin(xn)}).call(this,e(6))},{1:1,2:2,3:3,4:4,5:5,6:6,7:7,8:8}]},{},[13]);
© 2015 - 2024 Weber Informatics LLC | Privacy Policy