snow-cms 1.0.4 → 1.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,4 @@
1
- import{m as Z,T as ke,i as G,X as Ue,u as $e,g as we,f as ae,Y as Te,P as un,e as Ae,K as W,j as ce,b as Oe}from"./index-browser.es2.js";import{c as z,h as oe,t as U,n as je,p as cn,a as Be,b as Le,g as ze,d as fn,e as fe,i as Je,s as dn,j as V,m as de}from"./index.es9.js";import"./index.js";class J extends Error{constructor(e){super(),this.status=400,this.name="query_parse_error",this.message=e,this.error=!0;try{Error.captureStackTrace(this,J)}catch{}}}class Ie extends Error{constructor(e){super(),this.status=404,this.name="not_found",this.message=e,this.error=!0;try{Error.captureStackTrace(this,Ie)}catch{}}}class Ee extends Error{constructor(e){super(),this.status=500,this.name="invalid_value",this.message=e,this.error=!0;try{Error.captureStackTrace(this,Ee)}catch{}}}function Ge(n,e){return e&&n.then(function(t){Z(function(){e(null,t)})},function(t){Z(function(){e(t)})}),n}function ln(n){return function(...e){var t=e.pop(),r=n.apply(this,e);return typeof t=="function"&&Ge(r,t),r}}function yn(n,e){return n.then(function(t){return e().then(function(){return t})},function(t){return e().then(function(){throw t})})}function ge(n,e){return function(){var t=arguments,r=this;return n.add(function(){return e.apply(r,t)})}}function Ce(n){var e=new ke(n),t=new Array(e.size),r=-1;return e.forEach(function(o){t[++r]=o}),t}function pe(n){var e=new Array(n.size),t=-1;return n.forEach(function(r,o){e[++t]=o}),e}class xe{constructor(){this.promise=new Promise(function(e){e()})}add(e){return this.promise=this.promise.catch(function(){}).then(function(){return e()}),this.promise}finish(){return this.promise}}function Pe(n){if(!n)return"undefined";switch(typeof n){case"function":return n.toString();case"string":return n.toString();default:return JSON.stringify(n)}}function hn(n,e){return Pe(n)+Pe(e)+"undefined"}async function Ne(n,e,t,r,o,c){const u=hn(t,r);let d;if(!o&&(d=n._cachedViews=n._cachedViews||{},d[u]))return d[u];const g=n.info().then(async function(k){const M=k.db_name+"-mrview-"+(o?"temp":Ue(u));function p(j){j.views=j.views||{};let Q=e;Q.indexOf("/")===-1&&(Q=e+"/"+e);const B=j.views[Q]=j.views[Q]||{};if(!B[M])return B[M]=!0,j}await $e(n,"_local/"+c,p);const K=(await n.registerDependentDatabase(M)).db;K.auto_compaction=!0;const P={name:M,db:K,sourceDB:n,adapter:n.adapter,mapFun:t,reduceFun:r};let N;try{N=await P.db.get("_local/lastSeq")}catch(j){if(j.status!==404)throw j}return P.seq=N?N.seq:0,d&&P.db.once("destroyed",function(){delete d[u]}),P});return d&&(d[u]=g),g}var Ve={},Qe=new xe,vn=50;function me(n){return n.indexOf("/")===-1?[n,n]:n.split("/")}function gn(n){return n.length===1&&/^1-/.test(n[0].rev)}function Re(n,e,t){try{n.emit("error",e)}catch{Ae("error",`The user's map/reduce function threw an uncaught error.
1
+ import{j as he,i as z,T as Ae,u as ke,g as pe,L as st,d as Oe,b as re,c as ot}from"./index-browser.es2.js";import{c as U,h as D,t as B,n as $e,p as ct,a as Ne,b as Pe,g as Ve,d as at,e as ie,i as Ce,s as ut,j as C,m as se}from"./index.es9.js";import"./index.js";class q extends Error{constructor(t){super(),this.status=400,this.name="query_parse_error",this.message=t,this.error=!0;try{Error.captureStackTrace(this,q)}catch{}}}class we extends Error{constructor(t){super(),this.status=404,this.name="not_found",this.message=t,this.error=!0;try{Error.captureStackTrace(this,we)}catch{}}}class _e extends Error{constructor(t){super(),this.status=500,this.name="invalid_value",this.message=t,this.error=!0;try{Error.captureStackTrace(this,_e)}catch{}}}function Qe(e,t){return t&&e.then(function(n){he(function(){t(null,n)})},function(n){he(function(){t(n)})}),e}function lt(e){return function(...t){var n=t.pop(),i=e.apply(this,t);return typeof n=="function"&&Qe(i,n),i}}function dt(e,t){return e.then(function(n){return t().then(function(){return n})},function(n){return t().then(function(){throw n})})}function le(e,t){return function(){var n=arguments,i=this;return e.add(function(){return t.apply(i,n)})}}function Ie(e){var t=new Set(e),n=new Array(t.size),i=-1;return t.forEach(function(o){n[++i]=o}),n}function de(e){var t=new Array(e.size),n=-1;return e.forEach(function(i,o){t[++n]=o}),t}class ge{constructor(){this.promise=Promise.resolve()}add(t){return this.promise=this.promise.catch(()=>{}).then(()=>t()),this.promise}finish(){return this.promise}}function Se(e){if(!e)return"undefined";switch(typeof e){case"function":return e.toString();case"string":return e.toString();default:return JSON.stringify(e)}}function ft(e,t){return Se(e)+Se(t)+"undefined"}async function je(e,t,n,i,o,l){const u=ft(n,i);let p;if(!o&&(p=e._cachedViews=e._cachedViews||{},p[u]))return p[u];const g=e.info().then(async function(S){const v=S.db_name+"-mrview-"+(o?"temp":Ae(u));function m(F){F.views=F.views||{};let P=t;P.indexOf("/")===-1&&(P=t+"/"+t);const Q=F.views[P]=F.views[P]||{};if(!Q[v])return Q[v]=!0,F}await ke(e,"_local/"+l,m);const E=(await e.registerDependentDatabase(v)).db;E.auto_compaction=!0;const K={name:v,db:E,sourceDB:e,adapter:e.adapter,mapFun:n,reduceFun:i};let j;try{j=await K.db.get("_local/lastSeq")}catch(F){if(F.status!==404)throw F}return K.seq=j?j.seq:0,p&&K.db.once("destroyed",function(){delete p[u]}),K});return p&&(p[u]=g),g}const Me={},Te=new ge,yt=50;function fe(e){return e.indexOf("/")===-1?[e,e]:e.split("/")}function ht(e){return e.length===1&&/^1-/.test(e[0].rev)}function Ee(e,t,n){try{e.emit("error",t)}catch{Oe("error",`The user's map/reduce function threw an uncaught error.
2
2
  You can debug this error by doing:
3
3
  myDatabase.on('error', function (err) { debugger; });
4
- Please double-check your map/reduce function.`),Ae("error",e,t)}}function pn(n,e,t,r){function o(i,a,s){try{a(s)}catch(f){Re(i,f,{fun:a,doc:s})}}function c(i,a,s,f,h){try{return{output:a(s,f,h)}}catch(_){return Re(i,_,{fun:a,keys:s,values:f,rereduce:h}),{error:_}}}function u(i,a){const s=z(i.key,a.key);return s!==0?s:z(i.value,a.value)}function d(i,a,s){return s=s||0,typeof a=="number"?i.slice(s,a+s):s>0?i.slice(s):i}function g(i){const a=i.value;return a&&typeof a=="object"&&a._id||i.id}function k(i){i.rows.forEach(function(a){const s=a.doc&&a.doc._attachments;s&&Object.keys(s).forEach(function(f){const h=s[f];s[f].data=un(h.data,h.content_type)})})}function M(i){return function(a){return i.include_docs&&i.attachments&&i.binary&&k(a),a}}function p(i,a,s,f){let h=a[i];typeof h<"u"&&(f&&(h=encodeURIComponent(JSON.stringify(h))),s.push(i+"="+h))}function E(i){if(typeof i<"u"){const a=Number(i);return!isNaN(a)&&a===parseInt(i,10)?a:i}}function K(i){return i.group_level=E(i.group_level),i.limit=E(i.limit),i.skip=E(i.skip),i}function P(i){if(i){if(typeof i!="number")return new J(`Invalid value for integer: "${i}"`);if(i<0)return new J(`Invalid value for positive integer: "${i}"`)}}function N(i,a){const s=i.descending?"endkey":"startkey",f=i.descending?"startkey":"endkey";if(typeof i[s]<"u"&&typeof i[f]<"u"&&z(i[s],i[f])>0)throw new J("No rows can match your key range, reverse your start_key and end_key or set {descending : true}");if(a.reduce&&i.reduce!==!1){if(i.include_docs)throw new J("{include_docs:true} is invalid for reduce");if(i.keys&&i.keys.length>1&&!i.group&&!i.group_level)throw new J("Multi-key fetches for reduce views must use {group: true}")}["group_level","limit","skip"].forEach(function(h){const _=P(i[h]);if(_)throw _})}async function j(i,a,s){let f=[],h,_="GET",O;if(p("reduce",s,f),p("include_docs",s,f),p("attachments",s,f),p("limit",s,f),p("descending",s,f),p("group",s,f),p("group_level",s,f),p("skip",s,f),p("stale",s,f),p("conflicts",s,f),p("startkey",s,f,!0),p("start_key",s,f,!0),p("endkey",s,f,!0),p("end_key",s,f,!0),p("inclusive_end",s,f),p("key",s,f,!0),p("update_seq",s,f),f=f.join("&"),f=f===""?"":"?"+f,typeof s.keys<"u"){const m=`keys=${encodeURIComponent(JSON.stringify(s.keys))}`;m.length+f.length+1<=2e3?f+=(f[0]==="?"?"&":"?")+m:(_="POST",typeof a=="string"?h={keys:s.keys}:a.keys=s.keys)}if(typeof a=="string"){const l=me(a),m=await i.fetch("_design/"+l[0]+"/_view/"+l[1]+f,{headers:new oe({"Content-Type":"application/json"}),method:_,body:JSON.stringify(h)});O=m.ok;const b=await m.json();if(!O)throw b.status=m.status,we(b);return b.rows.forEach(function(x){if(x.value&&x.value.error&&x.value.error==="builtin_reduce_error")throw new Error(x.reason)}),new Promise(function(x){x(b)}).then(M(s))}h=h||{},Object.keys(a).forEach(function(l){Array.isArray(a[l])?h[l]=a[l]:h[l]=a[l].toString()});const y=await i.fetch("_temp_view"+f,{headers:new oe({"Content-Type":"application/json"}),method:"POST",body:JSON.stringify(h)});O=y.ok;const v=await y.json();if(!O)throw v.status=y.status,we(v);return new Promise(function(l){l(v)}).then(M(s))}function Q(i,a,s){return new Promise(function(f,h){i._query(a,s,function(_,O){if(_)return h(_);f(O)})})}function B(i){return new Promise(function(a,s){i._viewCleanup(function(f,h){if(f)return s(f);a(h)})})}function A(i){return function(a){if(a.status===404)return i;throw a}}async function H(i,a,s){const f="_local/doc_"+i,h={_id:f,keys:[]},_=s.get(i),O=_[0],y=_[1];function v(){return gn(y)?Promise.resolve(h):a.db.get(f).catch(A(h))}function l(C){return C.keys.length?a.db.allDocs({keys:C.keys,include_docs:!0}):Promise.resolve({rows:[]})}function m(C,R){const q=[],re=new ke;for(let w=0,$=R.rows.length;w<$;w++){const T=R.rows[w].doc;if(T&&(q.push(T),re.add(T._id),T._deleted=!O.has(T._id),!T._deleted)){const F=O.get(T._id);"value"in F&&(T.value=F.value)}}const ie=pe(O);return ie.forEach(function(w){if(!re.has(w)){const $={_id:w},I=O.get(w);"value"in I&&($.value=I.value),q.push($)}}),C.keys=Ce(ie.concat(C.keys)),q.push(C),q}const b=await v(),x=await l(b);return m(b,x)}function te(i){return i.sourceDB.get("_local/purges").then(function(a){const s=a.purgeSeq;return i.db.get("_local/purgeSeq").then(function(f){return f._rev}).catch(function(f){if(f.status!==404)throw f}).then(function(f){return i.db.put({_id:"_local/purgeSeq",_rev:f,purgeSeq:s})})}).catch(function(a){if(a.status!==404)throw a})}function le(i,a,s){var f="_local/lastSeq";return i.db.get(f).catch(A({_id:f,seq:0})).then(function(h){var _=pe(a);return Promise.all(_.map(function(O){return H(O,i,a)})).then(function(O){var y=Te(O);return h.seq=s,y.push(h),i.db.bulkDocs({docs:y})}).then(()=>te(i))})}function X(i){const a=typeof i=="string"?i:i.name;let s=Ve[a];return s||(s=Ve[a]=new xe),s}async function L(i,a){return ge(X(i),function(){return ye(i,a)})()}async function ye(i,a){let s,f,h;function _(w,$){const I={id:f._id,key:je(w)};typeof $<"u"&&$!==null&&(I.value=je($)),s.push(I)}const O=e(i.mapFun,_);let y=i.seq||0;function v(){return i.sourceDB.info().then(function(w){h=i.sourceDB.activeTasks.add({name:"view_indexing",total_items:w.update_seq-y})})}function l(w,$){return function(){return le(i,w,$)}}let m=0;const b={view:i.name,indexed_docs:m};i.sourceDB.emit("indexing",b);const x=new xe;async function C(){const w=await i.sourceDB.changes({return_docs:!0,conflicts:!0,include_docs:!0,style:"all_docs",since:y,limit:a.changes_batch_size}),$=await R();return q(w,$)}function R(){return i.db.get("_local/purgeSeq").then(function(w){return w.purgeSeq}).catch(function(w){if(w&&w.status!==404)throw w;return-1}).then(function(w){return i.sourceDB.get("_local/purges").then(function($){const I=$.purges.filter(function(F,S){return S>w}).map(F=>F.docId),T=I.filter(function(F,S){return I.indexOf(F)===S});return Promise.all(T.map(function(F){return i.sourceDB.get(F).then(function(S){return{docId:F,doc:S}}).catch(function(S){if(S.status!==404)throw S;return{docId:F}})}))}).catch(function($){if($&&$.status!==404)throw $;return[]})})}function q(w,$){var I=w.results;if(!I.length&&!$.length)return;for(let S of $)if(I.findIndex(function(Y){return Y.id===S.docId})<0){const Y={_id:S.docId,doc:{_id:S.docId,_deleted:1},changes:[]};S.doc&&(Y.doc=S.doc,Y.changes.push({rev:S.doc._rev})),I.push(Y)}var T=re(I);x.add(l(T,y)),m=m+I.length;const F={view:i.name,last_seq:w.last_seq,results_count:I.length,indexed_docs:m};if(i.sourceDB.emit("indexing",F),i.sourceDB.activeTasks.update(h,{completed_items:m}),!(I.length<a.changes_batch_size))return C()}function re(w){const $=new ae;for(let I=0,T=w.length;I<T;I++){const F=w[I];if(F.doc._id[0]!=="_"){s=[],f=F.doc,f._deleted||o(i.sourceDB,O,f),s.sort(u);const S=ie(s);$.set(F.doc._id,[S,F.changes])}y=F.seq}return $}function ie(w){const $=new ae;let I;for(let T=0,F=w.length;T<F;T++){const S=w[T],ve=[S.key,S.id];T>0&&z(S.key,I)===0&&ve.push(T),$.set(U(ve),S),I=S.key}return $}try{await v(),await C(),await x.finish(),i.seq=y,i.sourceDB.activeTasks.remove(h)}catch(w){i.sourceDB.activeTasks.remove(h,w)}}function en(i,a,s){s.group_level===0&&delete s.group_level;const f=s.group||s.group_level,h=t(i.reduceFun),_=[],O=isNaN(s.group_level)?Number.POSITIVE_INFINITY:s.group_level;a.forEach(function(y){const v=_[_.length-1];let l=f?y.key:null;if(f&&Array.isArray(l)&&(l=l.slice(0,O)),v&&z(v.groupKey,l)===0){v.keys.push([y.key,y.id]),v.values.push(y.value);return}_.push({keys:[[y.key,y.id]],values:[y.value],groupKey:l})}),a=[];for(let y=0,v=_.length;y<v;y++){const l=_[y],m=c(i.sourceDB,h,l.keys,l.values,!1);if(m.error&&m.error instanceof Ee)throw m.error;a.push({value:m.error?null:m.output,key:l.groupKey})}return{rows:d(a,s.limit,s.skip)}}function he(i,a){return ge(X(i),function(){return nn(i,a)})()}async function nn(i,a){let s;const f=i.reduceFun&&a.reduce!==!1,h=a.skip||0;typeof a.keys<"u"&&!a.keys.length&&(a.limit=0,delete a.keys);async function _(y){y.include_docs=!0;const v=await i.db.allDocs(y);return s=v.total_rows,v.rows.map(function(l){if("value"in l.doc&&typeof l.doc.value=="object"&&l.doc.value!==null){const b=Object.keys(l.doc.value).sort(),x=["id","key","value"];if(!(b<x||b>x))return l.doc.value}const m=cn(l.doc._id);return{key:m[0],id:m[1],value:"value"in l.doc?l.doc.value:null}})}async function O(y){let v;if(f?v=en(i,y,a):typeof a.keys>"u"?v={total_rows:s,offset:h,rows:y}:v={total_rows:s,offset:h,rows:d(y,a.limit,a.skip)},a.update_seq&&(v.update_seq=i.seq),a.include_docs){const m=Ce(y.map(g)),b=await i.sourceDB.allDocs({keys:m,include_docs:!0,conflicts:a.conflicts,attachments:a.attachments,binary:a.binary});var l=new ae;return b.rows.forEach(function(x){l.set(x.id,x.doc)}),y.forEach(function(x){var C=g(x),R=l.get(C);R&&(x.doc=R)}),v}else return v}if(typeof a.keys<"u"){const v=a.keys.map(function(b){const x={startkey:U([b]),endkey:U([b,{}])};return a.update_seq&&(x.update_seq=!0),_(x)}),l=await Promise.all(v),m=Te(l);return O(m)}else{const y={descending:a.descending};a.update_seq&&(y.update_seq=!0);let v,l;if("start_key"in a&&(v=a.start_key),"startkey"in a&&(v=a.startkey),"end_key"in a&&(l=a.end_key),"endkey"in a&&(l=a.endkey),typeof v<"u"&&(y.startkey=a.descending?U([v,{}]):U([v])),typeof l<"u"){let b=a.inclusive_end!==!1;a.descending&&(b=!b),y.endkey=U(b?[l,{}]:[l])}if(typeof a.key<"u"){const b=U([a.key]),x=U([a.key,{}]);y.descending?(y.endkey=b,y.startkey=x):(y.startkey=b,y.endkey=x)}f||(typeof a.limit=="number"&&(y.limit=a.limit),y.skip=h);const m=await _(y);return O(m)}}async function tn(i){return(await i.fetch("_view_cleanup",{headers:new oe({"Content-Type":"application/json"}),method:"POST"})).json()}async function rn(i){try{const a=await i.get("_local/"+n),s=new ae;Object.keys(a.views).forEach(function(v){const l=me(v),m="_design/"+l[0],b=l[1];let x=s.get(m);x||(x=new ke,s.set(m,x)),x.add(b)});const f={keys:pe(s),include_docs:!0},h=await i.allDocs(f),_={};h.rows.forEach(function(v){const l=v.key.substring(8);s.get(v.key).forEach(function(m){let b=l+"/"+m;a.views[b]||(b=m);const x=Object.keys(a.views[b]),C=v.doc&&v.doc.views&&v.doc.views[m];x.forEach(function(R){_[R]=_[R]||C})})});const y=Object.keys(_).filter(function(v){return!_[v]}).map(function(v){return ge(X(v),function(){return new i.constructor(v,i.__opts).destroy()})()});return Promise.all(y).then(function(){return{ok:!0}})}catch(a){if(a.status===404)return{ok:!0};throw a}}async function an(i,a,s){if(typeof i._query=="function")return Q(i,a,s);if(G(i))return j(i,a,s);const f={changes_batch_size:i.__opts.view_update_changes_batch_size||vn};if(typeof a!="string")return N(s,a),Qe.add(async function(){const h=await Ne(i,"temp_view/temp_view",a.map,a.reduce,!0,n);return yn(L(h,f).then(function(){return he(h,s)}),function(){return h.db.destroy()})}),Qe.finish();{const h=a,_=me(h),O=_[0],y=_[1],v=await i.get("_design/"+O);if(a=v.views&&v.views[y],!a)throw new Ie(`ddoc ${v._id} has no view named ${y}`);r(v,y),N(s,a);const l=await Ne(i,h,a.map,a.reduce,!1,n);return s.stale==="ok"||s.stale==="update_after"?(s.stale==="update_after"&&Z(function(){L(l,f)}),he(l,s)):(await L(l,f),he(l,s))}}function on(i,a,s){const f=this;typeof a=="function"&&(s=a,a={}),a=a?K(a):{},typeof i=="function"&&(i={map:i});const h=Promise.resolve().then(function(){return an(f,i,a)});return Ge(h,s),h}const sn=ln(function(){const i=this;return typeof i._viewCleanup=="function"?B(i):G(i)?tn(i):rn(i)});return{query:on,viewCleanup:sn}}function Xe(n){return n=ce(n),n.index||(n.index={}),["type","name","ddoc"].forEach(function(e){n.index[e]&&(n[e]=n.index[e],delete n.index[e])}),n.fields&&(n.index.fields=n.fields,delete n.fields),n.type||(n.type="json"),n}function mn(n,e,t){var r="",o=e,c=!0;if(["$in","$nin","$or","$and","$mod","$nor","$all"].indexOf(n)!==-1&&(Array.isArray(e)||(r="Query operator "+n+" must be an array.")),["$not","$elemMatch","$allMatch"].indexOf(n)!==-1&&(!Array.isArray(e)&&typeof e=="object"&&e!==null||(r="Query operator "+n+" must be an object.")),n==="$mod"&&Array.isArray(e))if(e.length!==2)r="Query operator $mod must be in the format [divisor, remainder], where divisor and remainder are both integers.";else{var u=e[0],d=e[1];u===0&&(r="Query operator $mod's divisor cannot be 0, cannot divide by zero.",c=!1),(typeof u!="number"||parseInt(u,10)!==u)&&(r="Query operator $mod's divisor is not an integer.",o=u),parseInt(d,10)!==d&&(r="Query operator $mod's remainder is not an integer.",o=d)}if(n==="$exists"&&typeof e!="boolean"&&(r="Query operator $exists must be a boolean."),n==="$type"){var g=["null","boolean","number","string","array","object"],k='"'+g.slice(0,g.length-1).join('", "')+'", or "'+g[g.length-1]+'"';(typeof e!="string"||g.indexOf(e)==-1)&&(r="Query operator $type must be a string. Supported values: "+k+".")}if(n==="$size"&&parseInt(e,10)!==e&&(r="Query operator $size must be a integer."),n==="$regex"&&typeof e!="string"&&(t?r="Query operator $regex must be a string.":e instanceof RegExp||(r="Query operator $regex must be a string or an instance of a javascript regular expression.")),r){if(c){var M=o===null?" ":Array.isArray(o)?" array":" "+typeof o,p=typeof o=="object"&&o!==null?JSON.stringify(o,null," "):o;r+=" Received"+M+": "+p}throw new Error(r)}}var _n=["$all","$allMatch","$and","$elemMatch","$exists","$in","$mod","$nin","$nor","$not","$or","$regex","$size","$type"],kn=["$in","$nin","$mod","$all"],wn=["$eq","$gt","$gte","$lt","$lte"];function se(n,e){if(Array.isArray(n))for(var t of n)typeof t=="object"&&u!==null&&se(t,e);else for(var r=Object.keys(n),o=0;o<r.length;o++){var c=r[o],u=n[c];_n.indexOf(c)!==-1&&mn(c,u,e),wn.indexOf(c)===-1&&kn.indexOf(c)===-1&&typeof u=="object"&&u!==null&&se(u,e)}}function D(n,e,t,r){var o,c;t.headers=new oe({"Content-type":"application/json"}),n.fetch(e,t).then(function(u){return o=u.status,c=u.ok,u.json()}).then(function(u){if(c)r(null,u);else{u.status=o;var d=we(u);r(d)}}).catch(r)}function xn(n,e,t){e=Xe(e),D(n,"_index",{method:"POST",body:JSON.stringify(e)},t)}function bn(n,e,t){se(e.selector,!0),D(n,"_find",{method:"POST",body:JSON.stringify(e)},t)}function $n(n,e,t){D(n,"_explain",{method:"POST",body:JSON.stringify(e)},t)}function On(n,e){D(n,"_index",{method:"GET"},e)}function In(n,e,t){var r=e.ddoc,o=e.type||"json",c=e.name;if(!r)return t(new Error("you must provide an index's ddoc"));if(!c)return t(new Error("you must provide an index's name"));var u="_index/"+[r,o,c].map(encodeURIComponent).join("/");D(n,u,{method:"DELETE"},t)}function ee(n){return function(...e){var t=e.pop(),r=n.apply(this,e);return En(r,t),r}}function En(n,e){return n.then(function(t){Z(function(){e(null,t)})},function(t){Z(function(){e(t)})}),n}var Se=function(...n){for(var e=[],t=0,r=n.length;t<r;t++){var o=n[t];Array.isArray(o)?e=e.concat(Se.apply(null,o)):e.push(o)}return e};function Me(n){for(var e={},t=0,r=n.length;t<r;t++)e=Oe(e,n[t]);return e}function Sn(n,e){for(var t={},r=0,o=e.length;r<o;r++){var c=fe(e[r]),u=Je(n,c);typeof u<"u"&&dn(t,c,u)}return t}function qe(n,e){for(var t=0,r=Math.min(n.length,e.length);t<r;t++)if(n[t]!==e[t])return!1;return!0}function Mn(n,e){return n.length>e.length?!1:qe(n,e)}function Fn(n,e){n=n.slice();for(var t=0,r=e.length;t<r;t++){var o=e[t];if(!n.length)break;var c=n.indexOf(o);if(c===-1)return!1;n.splice(c,1)}return!0}function Tn(n){for(var e={},t=0,r=n.length;t<r;t++)e[n[t]]=!0;return e}function An(n,e){for(var t=null,r=-1,o=0,c=n.length;o<c;o++){var u=n[o],d=e(u);d>r&&(r=d,t=u)}return t}function Ke(n,e){if(n.length!==e.length)return!1;for(var t=0,r=n.length;t<r;t++)if(n[t]!==e[t])return!1;return!0}function jn(n){for(var e={},t=0;t<n.length;t++)e["$"+n[t]]=!0;return Object.keys(e).map(function(r){return r.substring(1)})}function Cn(n,e,t){return function(r){if(!(t&&!de(r,t))){for(var o=[],c=0,u=n.length;c<u;c++){for(var d=fe(n[c]),g=r,k=0,M=d.length;k<M;k++){var p=d[k];if(g=g[p],typeof g>"u")return}o.push(g)}e(o)}}}function Pn(n,e,t){var r=fe(n);return function(o){if(!(t&&!de(o,t))){for(var c=o,u=0,d=r.length;u<d;u++){var g=r[u];if(c=c[g],typeof c>"u")return}e(c)}}}function Nn(n,e,t){return function(r){t&&!de(r,t)||e(r[n])}}function Vn(n,e,t){return function(r){if(!(t&&!de(r,t))){for(var o=[],c=0,u=n.length;c<u;c++)o.push(r[n[c]]);e(o)}}}function Qn(n){for(var e=0,t=n.length;e<t;e++){var r=n[e];if(r.indexOf(".")!==-1)return!1}return!0}function Rn(n,e,t){var r=Qn(n),o=n.length===1;return r?o?Nn(n[0],e,t):Vn(n,e,t):o?Pn(n[0],e,t):Cn(n,e,t)}function Kn(n,e){const t=Object.keys(n.fields),r=n.partial_filter_selector;return Rn(t,e,r)}function Un(){throw new Error("reduce not supported")}function Bn(n,e){var t=n.views[e];if(!t.map||!t.map.fields)throw new Error("ddoc "+n._id+" with view "+e+" doesn't have map.fields defined. maybe it wasn't created by this plugin?")}var _e=pn("indexes",Kn,Un,Bn);function Fe(n){return n._customFindAbstractMapper?{query:function(t,r){var o=_e.query.bind(this);return n._customFindAbstractMapper.query.call(this,t,r,o)},viewCleanup:function(){var t=_e.viewCleanup.bind(this);return n._customFindAbstractMapper.viewCleanup.call(this,t)}}:_e}function Ln(n){if(!Array.isArray(n))throw new Error("invalid sort json - should be an array");return n.map(function(e){if(typeof e=="string"){var t={};return t[e]="asc",t}else return e})}function zn(n){var e=[];return typeof n=="string"?e.push(n):e=n,e.map(function(t){return t.replace("_design/","")})}function He(n){return n.fields=n.fields.map(function(e){if(typeof e=="string"){var t={};return t[e]="asc",t}return e}),n.partial_filter_selector&&(n.partial_filter_selector=Le(n.partial_filter_selector)),n}function Jn(n,e){for(var t=[],r=0;r<e.def.fields.length;r++){var o=V(e.def.fields[r]);t.push(Je(n,fe(o)))}return t}function Gn(n,e,t){for(var r=t.def.fields,o=0,c=n.length;o<c;o++){var u=n[o],d=Jn(u.doc,t);if(r.length===1)d=d[0];else for(;d.length>e.length;)d.pop();if(Math.abs(z(d,e))>0)break}return o>0?n.slice(o):n}function Xn(n){var e=ce(n);return delete e.startkey,delete e.endkey,delete e.inclusive_start,delete e.inclusive_end,"endkey"in n&&(e.startkey=n.endkey),"startkey"in n&&(e.endkey=n.startkey),"inclusive_start"in n&&(e.inclusive_end=n.inclusive_start),"inclusive_end"in n&&(e.inclusive_start=n.inclusive_end),e}function qn(n){var e=n.fields.filter(function(t){return ze(t)==="asc"});if(e.length!==0&&e.length!==n.fields.length)throw new Error("unsupported mixed sorting")}function Hn(n,e){if(e.defaultUsed&&n.sort){var t=n.sort.filter(function(r){return Object.keys(r)[0]!=="_id"}).map(function(r){return Object.keys(r)[0]});if(t.length>0)throw new Error('Cannot sort on field(s) "'+t.join(",")+'" when using the default index')}e.defaultUsed}function Yn(n){if(typeof n.selector!="object")throw new Error("you must provide a selector when you find()")}function Zn(n,e){var t=Object.keys(n),r=e?e.map(V):[],o;return t.length>=r.length?o=t:o=r,r.length===0?{fields:o}:(o=o.sort(function(c,u){var d=r.indexOf(c);d===-1&&(d=Number.MAX_VALUE);var g=r.indexOf(u);return g===-1&&(g=Number.MAX_VALUE),d<g?-1:d>g?1:0}),{fields:o,sortOrder:e.map(V)})}function Wn(n,e){e=Xe(e);var t=ce(e.index);e.index=He(e.index),qn(e.index);var r;function o(){return r||(r=Ue(JSON.stringify(e)))}var c=e.name||"idx-"+o(),u=e.ddoc||"idx-"+o(),d="_design/"+u,g=!1,k=!1;function M(p){return p._rev&&p.language!=="query"&&(g=!0),p.language="query",p.views=p.views||{},k=!!p.views[c],k?!1:(p.views[c]={map:{fields:Me(e.index.fields),partial_filter_selector:e.index.partial_filter_selector},reduce:"_count",options:{def:t}},p)}return n.constructor.emit("debug",["find","creating index",d]),$e(n,d,M).then(function(){if(g)throw new Error('invalid language for ddoc with id "'+d+'" (should be "query")')}).then(function(){var p=u+"/"+c;return Fe(n).query.call(n,p,{limit:0,reduce:!1}).then(function(){return{id:d,name:c,result:k?"exists":"created"}})})}function Ye(n){return n.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=Se(t.indexes,e.rows.filter(function(r){return r.doc.language==="query"}).map(function(r){var o=r.doc.views!==void 0?Object.keys(r.doc.views):[];return o.map(function(c){var u=r.doc.views[c];return{ddoc:r.id,name:c,type:"json",def:He(u.options.def)}})})),t.indexes.sort(function(r,o){return Be(r.name,o.name)}),t.total_rows=t.indexes.length,t})}var ue=null,be={"￿":{}};const Dn={queryOpts:{limit:0,startkey:be,endkey:ue},inMemoryFields:[]};function et(n,e){for(var t=n.def.fields.map(V),r=0,o=t.length;r<o;r++){var c=t[r];if(e===c)return!0}return!1}function nt(n,e){var t=n[e],r=V(t);return r!=="$eq"}function Ze(n,e){var t=e.def.fields.map(V);return n.slice().sort(function(r,o){var c=t.indexOf(r),u=t.indexOf(o);return c===-1&&(c=Number.MAX_VALUE),u===-1&&(u=Number.MAX_VALUE),Be(c,u)})}function tt(n,e,t){t=Ze(t,n);for(var r=!1,o=0,c=t.length;o<c;o++){var u=t[o];if(r||!et(n,u))return t.slice(o);o<c-1&&nt(e,u)&&(r=!0)}return[]}function rt(n){var e=[];return Object.keys(n).forEach(function(t){var r=n[t];Object.keys(r).forEach(function(o){o==="$ne"&&e.push(t)})}),e}function it(n,e,t,r){var o=Se(n,tt(e,t,r),rt(t));return Ze(jn(o),e)}function at(n,e,t){if(e){var r=Mn(e,n),o=qe(t,n);return r&&o}return Fn(t,n)}var ot=["$eq","$gt","$gte","$lt","$lte"];function We(n){return ot.indexOf(n)===-1}function st(n,e){var t=n[0],r=e[t];if(typeof r>"u")return!0;var o=Object.keys(r).length===1&&V(r)==="$ne";return!o}function ut(n,e,t,r){var o=n.def.fields.map(V),c=at(o,e,t);return c?st(o,r):!1}function ct(n,e,t,r){return r.filter(function(o){return ut(o,t,e,n)})}function ft(n,e,t,r,o){var c=ct(n,e,t,r);if(c.length===0){if(o)throw{error:"no_usable_index",message:"There is no index available for this selector."};var u=r[0];return u.defaultUsed=!0,u}if(c.length===1&&!o)return c[0];var d=Tn(e);function g(E){for(var K=E.def.fields.map(V),P=0,N=0,j=K.length;N<j;N++){var Q=K[N];d[Q]&&P++}return P}if(o){var k="_design/"+o[0],M=o.length===2?o[1]:!1,p=c.find(function(E){return!!(M&&E.ddoc===k&&M===E.name||E.ddoc===k)});if(!p)throw{error:"unknown_error",message:"Could not find that index or could not use that index for the query"};return p}return An(c,g)}function dt(n,e){switch(n){case"$eq":return{key:e};case"$lte":return{endkey:e};case"$gte":return{startkey:e};case"$lt":return{endkey:e,inclusive_end:!1};case"$gt":return{startkey:e,inclusive_start:!1}}return{startkey:ue}}function lt(n,e){var t=V(e.def.fields[0]),r=n[t]||{},o=[],c=Object.keys(r),u;return c.forEach(function(d){We(d)&&o.push(t);var g=r[d],k=dt(d,g);u?u=Me([u,k]):u=k}),{queryOpts:u,inMemoryFields:o}}function yt(n,e){switch(n){case"$eq":return{startkey:e,endkey:e};case"$lte":return{endkey:e};case"$gte":return{startkey:e};case"$lt":return{endkey:e,inclusive_end:!1};case"$gt":return{startkey:e,inclusive_start:!1}}}function ht(n,e){var t=e.def.fields.map(V),r=[],o=[],c=[],u,d;function g(ye){u!==!1&&o.push(ue),d!==!1&&c.push(be),r=t.slice(ye)}for(var k=0,M=t.length;k<M;k++){var p=t[k],E=n[p];if(!E||!Object.keys(E).length){g(k);break}else if(Object.keys(E).some(We)){g(k);break}else if(k>0){var K="$gt"in E||"$gte"in E||"$lt"in E||"$lte"in E,P=Object.keys(n[t[k-1]]),N=Ke(P,["$eq"]),j=Ke(P,Object.keys(E)),Q=K&&!N&&!j;if(Q){g(k);break}}for(var B=Object.keys(E),A=null,H=0;H<B.length;H++){var te=B[H],le=E[te],X=yt(te,le);A?A=Me([A,X]):A=X}o.push("startkey"in A?A.startkey:ue),c.push("endkey"in A?A.endkey:be),"inclusive_start"in A&&(u=A.inclusive_start),"inclusive_end"in A&&(d=A.inclusive_end)}var L={startkey:o,endkey:c};return typeof u<"u"&&(L.inclusive_start=u),typeof d<"u"&&(L.inclusive_end=d),{queryOpts:L,inMemoryFields:r}}function vt(n){return Object.keys(n).map(function(t){return n[t]}).some(function(t){return typeof t=="object"&&Object.keys(t).length===0})}function gt(n){return{queryOpts:{startkey:null},inMemoryFields:[Object.keys(n)]}}function pt(n,e){return e.defaultUsed?gt(n):e.def.fields.length===1?lt(n,e):ht(n,e)}function mt(n,e){var t=n.selector,r=n.sort;if(vt(t))return Oe({},Dn,{index:e[0]});var o=Zn(t,r),c=o.fields,u=o.sortOrder,d=ft(t,c,u,e,n.use_index),g=pt(t,d),k=g.queryOpts,M=g.inMemoryFields,p=it(M,d,t,c),E={queryOpts:k,index:d,inMemoryFields:p};return E}function _t(n){return n.ddoc.substring(8)+"/"+n.name}function kt(n,e){var t=ce(e);return t.descending?("endkey"in t&&typeof t.endkey!="string"&&(t.endkey=""),"startkey"in t&&typeof t.startkey!="string"&&(t.limit=0)):("startkey"in t&&typeof t.startkey!="string"&&(t.startkey=""),"endkey"in t&&typeof t.endkey!="string"&&(t.limit=0)),"key"in t&&typeof t.key!="string"&&(t.limit=0),t.limit>0&&t.indexes_count&&(t.original_limit=t.limit,t.limit+=t.indexes_count),n.allDocs(t).then(function(r){return r.rows=r.rows.filter(function(o){return!/^_design\//.test(o.id)}),t.original_limit&&(t.limit=t.original_limit),r.rows=r.rows.slice(0,t.limit),r})}function De(n,e,t){return e.selector&&(se(e.selector,!1),e.selector=Le(e.selector)),e.sort&&(e.sort=Ln(e.sort)),e.use_index&&(e.use_index=zn(e.use_index)),Yn(e),Ye(n).then(function(r){n.constructor.emit("debug",["find","planning query",e]);var o=mt(e,r.indexes);n.constructor.emit("debug",["find","query plan",o]);var c=o.index;Hn(e,c);var u=Oe({include_docs:!0,reduce:!1,indexes_count:r.total_rows},o.queryOpts);if("startkey"in u&&"endkey"in u&&z(u.startkey,u.endkey)>0)return{docs:[]};var d=e.sort&&typeof e.sort[0]!="string"&&ze(e.sort[0])==="desc";return d&&(u.descending=!0,u=Xn(u)),o.inMemoryFields.length||("limit"in e&&(u.limit=e.limit),"skip"in e&&(u.skip=e.skip)),t?Promise.resolve(o,u):Promise.resolve().then(function(){if(c.name==="_all_docs")return kt(n,u);var g=_t(c);return Fe(n).query.call(n,g,u)}).then(function(g){u.inclusive_start===!1&&(g.rows=Gn(g.rows,u.startkey,c)),o.inMemoryFields.length&&(g.rows=fn(g.rows,e,o.inMemoryFields));var k={docs:g.rows.map(function(M){var p=M.doc;return e.fields?Sn(p,e.fields):p})};return c.defaultUsed&&(k.warning="No matching index found, create an index to optimize query time."),k})})}function wt(n,e){return De(n,e,!0).then(function(t){return{dbname:n.name,index:t.index,selector:e.selector,range:{start_key:t.queryOpts.startkey,end_key:t.queryOpts.endkey},opts:{use_index:e.use_index||[],bookmark:"nil",limit:e.limit,skip:e.skip,sort:e.sort||{},fields:e.fields,conflicts:!1,r:[49]},limit:e.limit,skip:e.skip||0,fields:e.fields}})}function xt(n,e){if(!e.ddoc)throw new Error("you must supply an index.ddoc when deleting");if(!e.name)throw new Error("you must supply an index.name when deleting");var t=e.ddoc,r=e.name;function o(c){return Object.keys(c.views).length===1&&c.views[r]?{_id:t,_deleted:!0}:(delete c.views[r],c)}return $e(n,t,o).then(function(){return Fe(n).viewCleanup.apply(n)}).then(function(){return{ok:!0}})}var bt=ee(Wn),$t=ee(De),Ot=ee(wt),It=ee(Ye),Et=ee(xt),ne={};ne.createIndex=W(function(n,e){if(typeof n!="object")return e(new Error("you must provide an index to create"));var t=G(this)?xn:bt;t(this,n,e)});ne.find=W(function(n,e){if(typeof e>"u"&&(e=n,n=void 0),typeof n!="object")return e(new Error("you must provide search parameters to find()"));var t=G(this)?bn:$t;t(this,n,e)});ne.explain=W(function(n,e){if(typeof e>"u"&&(e=n,n=void 0),typeof n!="object")return e(new Error("you must provide search parameters to explain()"));var t=G(this)?$n:Ot;t(this,n,e)});ne.getIndexes=W(function(n){var e=G(this)?On:It;e(this,n)});ne.deleteIndex=W(function(n,e){if(typeof n!="object")return e(new Error("you must provide an index to delete"));var t=G(this)?In:Et;t(this,n,e)});export{ne as default};
4
+ Please double-check your map/reduce function.`),Oe("error",t,n)}}function pt(e,t,n,i){function o(r,s,c){try{s(c)}catch(a){Ee(r,a,{fun:s,doc:c})}}function l(r,s,c,a,f){try{return{output:s(c,a,f)}}catch(k){return Ee(r,k,{fun:s,keys:c,values:a,rereduce:f}),{error:k}}}function u(r,s){const c=U(r.key,s.key);return c!==0?c:U(r.value,s.value)}function p(r,s,c){return c=c||0,typeof s=="number"?r.slice(c,s+c):c>0?r.slice(c):r}function g(r){const s=r.value;return s&&typeof s=="object"&&s._id||r.id}function S(r){for(const s of r.rows){const c=s.doc&&s.doc._attachments;if(c)for(const a of Object.keys(c)){const f=c[a];c[a].data=st(f.data,f.content_type)}}}function v(r){return function(s){return r.include_docs&&r.attachments&&r.binary&&S(s),s}}function m(r,s,c,a){let f=s[r];typeof f<"u"&&(a&&(f=encodeURIComponent(JSON.stringify(f))),c.push(r+"="+f))}function T(r){if(typeof r<"u"){const s=Number(r);return!isNaN(s)&&s===parseInt(r,10)?s:r}}function E(r){return r.group_level=T(r.group_level),r.limit=T(r.limit),r.skip=T(r.skip),r}function K(r){if(r){if(typeof r!="number")return new q(`Invalid value for integer: "${r}"`);if(r<0)return new q(`Invalid value for positive integer: "${r}"`)}}function j(r,s){const c=r.descending?"endkey":"startkey",a=r.descending?"startkey":"endkey";if(typeof r[c]<"u"&&typeof r[a]<"u"&&U(r[c],r[a])>0)throw new q("No rows can match your key range, reverse your start_key and end_key or set {descending : true}");if(s.reduce&&r.reduce!==!1){if(r.include_docs)throw new q("{include_docs:true} is invalid for reduce");if(r.keys&&r.keys.length>1&&!r.group&&!r.group_level)throw new q("Multi-key fetches for reduce views must use {group: true}")}for(const f of["group_level","limit","skip"]){const k=K(r[f]);if(k)throw k}}async function F(r,s,c){let a=[],f,k="GET",I;if(m("reduce",c,a),m("include_docs",c,a),m("attachments",c,a),m("limit",c,a),m("descending",c,a),m("group",c,a),m("group_level",c,a),m("skip",c,a),m("stale",c,a),m("conflicts",c,a),m("startkey",c,a,!0),m("start_key",c,a,!0),m("endkey",c,a,!0),m("end_key",c,a,!0),m("inclusive_end",c,a),m("key",c,a,!0),m("update_seq",c,a),a=a.join("&"),a=a===""?"":"?"+a,typeof c.keys<"u"){const b=`keys=${encodeURIComponent(JSON.stringify(c.keys))}`;b.length+a.length+1<=2e3?a+=(a[0]==="?"?"&":"?")+b:(k="POST",typeof s=="string"?f={keys:c.keys}:s.keys=c.keys)}if(typeof s=="string"){const h=fe(s),b=await r.fetch("_design/"+h[0]+"/_view/"+h[1]+a,{headers:new D({"Content-Type":"application/json"}),method:k,body:JSON.stringify(f)});I=b.ok;const _=await b.json();if(!I)throw _.status=b.status,pe(_);for(const w of _.rows)if(w.value&&w.value.error&&w.value.error==="builtin_reduce_error")throw new Error(w.reason);return new Promise(function(w){w(_)}).then(v(c))}f=f||{};for(const h of Object.keys(s))Array.isArray(s[h])?f[h]=s[h]:f[h]=s[h].toString();const d=await r.fetch("_temp_view"+a,{headers:new D({"Content-Type":"application/json"}),method:"POST",body:JSON.stringify(f)});I=d.ok;const y=await d.json();if(!I)throw y.status=d.status,pe(y);return new Promise(function(h){h(y)}).then(v(c))}function P(r,s,c){return new Promise(function(a,f){r._query(s,c,function(k,I){if(k)return f(k);a(I)})})}function Q(r){return new Promise(function(s,c){r._viewCleanup(function(a,f){if(a)return c(a);s(f)})})}function L(r){return function(s){if(s.status===404)return r;throw s}}async function xe(r,s,c){const a="_local/doc_"+r,f={_id:a,keys:[]},k=c.get(r),I=k[0],d=k[1];function y(){return ht(d)?Promise.resolve(f):s.db.get(a).catch(L(f))}function h(A){return A.keys.length?s.db.allDocs({keys:A.keys,include_docs:!0}):Promise.resolve({rows:[]})}function b(A,R){const G=[],W=new Set;for(const $ of R.rows){const x=$.doc;if(x&&(G.push(x),W.add(x._id),x._deleted=!I.has(x._id),!x._deleted)){const O=I.get(x._id);"value"in O&&(x.value=O.value)}}const Z=de(I);for(const $ of Z)if(!W.has($)){const x={_id:$},O=I.get($);"value"in O&&(x.value=O.value),G.push(x)}return A.keys=Ie(Z.concat(A.keys)),G.push(A),G}const _=await y(),w=await h(_);return b(_,w)}function He(r){return r.sourceDB.get("_local/purges").then(function(s){const c=s.purgeSeq;return r.db.get("_local/purgeSeq").then(function(a){return a._rev}).catch(L(void 0)).then(function(a){return r.db.put({_id:"_local/purgeSeq",_rev:a,purgeSeq:c})})}).catch(function(s){if(s.status!==404)throw s})}function Ye(r,s,c){var a="_local/lastSeq";return r.db.get(a).catch(L({_id:a,seq:0})).then(function(f){var k=de(s);return Promise.all(k.map(function(I){return xe(I,r,s)})).then(function(I){var d=I.flat();return f.seq=c,d.push(f),r.db.bulkDocs({docs:d})}).then(()=>He(r))})}function oe(r){const s=typeof r=="string"?r:r.name;let c=Me[s];return c||(c=Me[s]=new ge),c}async function ce(r,s){return le(oe(r),function(){return We(r,s)})()}async function We(r,s){let c,a,f;function k($,x){const O={id:a._id,key:$e($)};typeof x<"u"&&x!==null&&(O.value=$e(x)),c.push(O)}const I=t(r.mapFun,k);let d=r.seq||0;function y(){return r.sourceDB.info().then(function($){f=r.sourceDB.activeTasks.add({name:"view_indexing",total_items:$.update_seq-d})})}function h($,x){return function(){return Ye(r,$,x)}}let b=0;const _={view:r.name,indexed_docs:b};r.sourceDB.emit("indexing",_);const w=new ge;async function A(){const $=await r.sourceDB.changes({return_docs:!0,conflicts:!0,include_docs:!0,style:"all_docs",since:d,limit:s.changes_batch_size}),x=await R();return G($,x)}function R(){return r.db.get("_local/purgeSeq").then(function($){return $.purgeSeq}).catch(L(-1)).then(function($){return r.sourceDB.get("_local/purges").then(function(x){const O=x.purges.filter(function(N,M){return M>$}).map(N=>N.docId),V=O.filter(function(N,M){return O.indexOf(N)===M});return Promise.all(V.map(function(N){return r.sourceDB.get(N).then(function(M){return{docId:N,doc:M}}).catch(L({docId:N}))}))}).catch(L([]))})}function G($,x){const O=$.results;if(!O.length&&!x.length)return;for(const M of x)if(O.findIndex(function(J){return J.id===M.docId})<0){const J={_id:M.docId,doc:{_id:M.docId,_deleted:1},changes:[]};M.doc&&(J.doc=M.doc,J.changes.push({rev:M.doc._rev})),O.push(J)}const V=W(O);w.add(h(V,d)),b=b+O.length;const N={view:r.name,last_seq:$.last_seq,results_count:O.length,indexed_docs:b};if(r.sourceDB.emit("indexing",N),r.sourceDB.activeTasks.update(f,{completed_items:b}),!(O.length<s.changes_batch_size))return A()}function W($){const x=new Map;for(const O of $){if(O.doc._id[0]!=="_"){c=[],a=O.doc,a._deleted||o(r.sourceDB,I,a),c.sort(u);const V=Z(c);x.set(O.doc._id,[V,O.changes])}d=O.seq}return x}function Z($){const x=new Map;let O;for(let V=0,N=$.length;V<N;V++){const M=$[V],ue=[M.key,M.id];V>0&&U(M.key,O)===0&&ue.push(V),x.set(B(ue),M),O=M.key}return x}try{await y(),await A(),await w.finish(),r.seq=d,r.sourceDB.activeTasks.remove(f)}catch($){r.sourceDB.activeTasks.remove(f,$)}}function Ze(r,s,c){c.group_level===0&&delete c.group_level;const a=c.group||c.group_level,f=n(r.reduceFun),k=[],I=isNaN(c.group_level)?Number.POSITIVE_INFINITY:c.group_level;for(const d of s){const y=k[k.length-1];let h=a?d.key:null;if(a&&Array.isArray(h)&&(h=h.slice(0,I)),y&&U(y.groupKey,h)===0){y.keys.push([d.key,d.id]),y.values.push(d.value);continue}k.push({keys:[[d.key,d.id]],values:[d.value],groupKey:h})}s=[];for(const d of k){const y=l(r.sourceDB,f,d.keys,d.values,!1);if(y.error&&y.error instanceof _e)throw y.error;s.push({value:y.error?null:y.output,key:d.groupKey})}return{rows:p(s,c.limit,c.skip)}}function ae(r,s){return le(oe(r),function(){return De(r,s)})()}async function De(r,s){let c;const a=r.reduceFun&&s.reduce!==!1,f=s.skip||0;typeof s.keys<"u"&&!s.keys.length&&(s.limit=0,delete s.keys);async function k(d){d.include_docs=!0;const y=await r.db.allDocs(d);return c=y.total_rows,y.rows.map(function(h){if("value"in h.doc&&typeof h.doc.value=="object"&&h.doc.value!==null){const _=Object.keys(h.doc.value).sort(),w=["id","key","value"];if(!(_<w||_>w))return h.doc.value}const b=ct(h.doc._id);return{key:b[0],id:b[1],value:"value"in h.doc?h.doc.value:null}})}async function I(d){let y;if(a?y=Ze(r,d,s):typeof s.keys>"u"?y={total_rows:c,offset:f,rows:d}:y={total_rows:c,offset:f,rows:p(d,s.limit,s.skip)},s.update_seq&&(y.update_seq=r.seq),s.include_docs){const h=Ie(d.map(g)),b=await r.sourceDB.allDocs({keys:h,include_docs:!0,conflicts:s.conflicts,attachments:s.attachments,binary:s.binary}),_=new Map;for(const w of b.rows)_.set(w.id,w.doc);for(const w of d){const A=g(w),R=_.get(A);R&&(w.doc=R)}}return y}if(typeof s.keys<"u"){const y=s.keys.map(function(_){const w={startkey:B([_]),endkey:B([_,{}])};return s.update_seq&&(w.update_seq=!0),k(w)}),b=(await Promise.all(y)).flat();return I(b)}else{const d={descending:s.descending};s.update_seq&&(d.update_seq=!0);let y,h;if("start_key"in s&&(y=s.start_key),"startkey"in s&&(y=s.startkey),"end_key"in s&&(h=s.end_key),"endkey"in s&&(h=s.endkey),typeof y<"u"&&(d.startkey=s.descending?B([y,{}]):B([y])),typeof h<"u"){let _=s.inclusive_end!==!1;s.descending&&(_=!_),d.endkey=B(_?[h,{}]:[h])}if(typeof s.key<"u"){const _=B([s.key]),w=B([s.key,{}]);d.descending?(d.endkey=_,d.startkey=w):(d.startkey=_,d.endkey=w)}a||(typeof s.limit=="number"&&(d.limit=s.limit),d.skip=f);const b=await k(d);return I(b)}}async function et(r){return(await r.fetch("_view_cleanup",{headers:new D({"Content-Type":"application/json"}),method:"POST"})).json()}async function tt(r){try{const s=await r.get("_local/"+e),c=new Map;for(const y of Object.keys(s.views)){const h=fe(y),b="_design/"+h[0],_=h[1];let w=c.get(b);w||(w=new Set,c.set(b,w)),w.add(_)}const a={keys:de(c),include_docs:!0},f=await r.allDocs(a),k={};for(const y of f.rows){const h=y.key.substring(8);for(const b of c.get(y.key)){let _=h+"/"+b;s.views[_]||(_=b);const w=Object.keys(s.views[_]),A=y.doc&&y.doc.views&&y.doc.views[b];for(const R of w)k[R]=k[R]||A}}const d=Object.keys(k).filter(function(y){return!k[y]}).map(function(y){return le(oe(y),function(){return new r.constructor(y,r.__opts).destroy()})()});return Promise.all(d).then(function(){return{ok:!0}})}catch(s){if(s.status===404)return{ok:!0};throw s}}async function nt(r,s,c){if(typeof r._query=="function")return P(r,s,c);if(z(r))return F(r,s,c);const a={changes_batch_size:r.__opts.view_update_changes_batch_size||yt};if(typeof s!="string")return j(c,s),Te.add(async function(){const f=await je(r,"temp_view/temp_view",s.map,s.reduce,!0,e);return dt(ce(f,a).then(function(){return ae(f,c)}),function(){return f.db.destroy()})}),Te.finish();{const f=s,k=fe(f),I=k[0],d=k[1],y=await r.get("_design/"+I);if(s=y.views&&y.views[d],!s)throw new we(`ddoc ${y._id} has no view named ${d}`);i(y,d),j(c,s);const h=await je(r,f,s.map,s.reduce,!1,e);return c.stale==="ok"||c.stale==="update_after"?(c.stale==="update_after"&&he(function(){ce(h,a)}),ae(h,c)):(await ce(h,a),ae(h,c))}}function rt(r,s,c){const a=this;typeof s=="function"&&(c=s,s={}),s=s?E(s):{},typeof r=="function"&&(r={map:r});const f=Promise.resolve().then(function(){return nt(a,r,s)});return Qe(f,c),f}const it=lt(function(){const r=this;return typeof r._viewCleanup=="function"?Q(r):z(r)?et(r):tt(r)});return{query:rt,viewCleanup:it}}const gt=(...e)=>e.flat(1/0),Re=(...e)=>{let t=[];for(const n of e)Array.isArray(n)?t=t.concat(Re(...n)):t.push(n);return t},Ke=typeof Array.prototype.flat=="function"?gt:Re;function ve(e){const t={};for(const n of e)Object.assign(t,n);return t}function mt(e,t){const n={};for(const i of t){const o=ie(i),l=Ce(e,o);typeof l<"u"&&ut(n,o,l)}return n}function Le(e,t){for(let n=0,i=Math.min(e.length,t.length);n<i;n++)if(e[n]!==t[n])return!1;return!0}function kt(e,t){return e.length>t.length?!1:Le(e,t)}function wt(e,t){e=e.slice();for(const n of t){if(!e.length)break;const i=e.indexOf(n);if(i===-1)return!1;e.splice(i,1)}return!0}function _t(e){const t={};for(const n of e)t[n]=!0;return t}function vt(e,t){let n=null,i=-1;for(const o of e){const l=t(o);l>i&&(i=l,n=o)}return n}function Fe(e,t){if(e.length!==t.length)return!1;for(let n=0,i=e.length;n<i;n++)if(e[n]!==t[n])return!1;return!0}function bt(e){return Array.from(new Set(e))}function X(e){return function(...t){const n=t[t.length-1];if(typeof n=="function"){const i=n.bind(null,null),o=n.bind(null);e.apply(this,t.slice(0,-1)).then(i,o)}else return e.apply(this,t)}}function Be(e){e=re(e),e.index||(e.index={});for(const t of["type","name","ddoc"])e.index[t]&&(e[t]=e.index[t],delete e.index[t]);return e.fields&&(e.index.fields=e.fields,delete e.fields),e.type||(e.type="json"),e}function ee(e){return typeof e=="object"&&e!==null}function xt(e,t,n){let i="",o=t,l=!0;if(["$in","$nin","$or","$and","$mod","$nor","$all"].indexOf(e)!==-1&&(Array.isArray(t)||(i="Query operator "+e+" must be an array.")),["$not","$elemMatch","$allMatch"].indexOf(e)!==-1&&(!Array.isArray(t)&&ee(t)||(i="Query operator "+e+" must be an object.")),e==="$mod"&&Array.isArray(t))if(t.length!==2)i="Query operator $mod must be in the format [divisor, remainder], where divisor and remainder are both integers.";else{const u=t[0],p=t[1];u===0&&(i="Query operator $mod's divisor cannot be 0, cannot divide by zero.",l=!1),(typeof u!="number"||parseInt(u,10)!==u)&&(i="Query operator $mod's divisor is not an integer.",o=u),parseInt(p,10)!==p&&(i="Query operator $mod's remainder is not an integer.",o=p)}if(e==="$exists"&&typeof t!="boolean"&&(i="Query operator $exists must be a boolean."),e==="$type"){const u=["null","boolean","number","string","array","object"],p='"'+u.slice(0,u.length-1).join('", "')+'", or "'+u[u.length-1]+'"';(typeof t!="string"||u.indexOf(t)==-1)&&(i="Query operator $type must be a string. Supported values: "+p+".")}if(e==="$size"&&parseInt(t,10)!==t&&(i="Query operator $size must be a integer."),e==="$regex"&&typeof t!="string"&&(n?i="Query operator $regex must be a string.":t instanceof RegExp||(i="Query operator $regex must be a string or an instance of a javascript regular expression.")),i){if(l){const u=o===null?" ":Array.isArray(o)?" array":" "+typeof o,p=ee(o)?JSON.stringify(o,null," "):o;i+=" Received"+u+": "+p}throw new Error(i)}}const Ot=["$all","$allMatch","$and","$elemMatch","$exists","$in","$mod","$nin","$nor","$not","$or","$regex","$size","$type"],$t=["$in","$nin","$mod","$all"],It=["$eq","$gt","$gte","$lt","$lte"];function te(e,t){if(Array.isArray(e))for(const n of e)ee(n)&&te(n,t);else for(const[n,i]of Object.entries(e))Ot.indexOf(n)!==-1&&xt(n,i,t),It.indexOf(n)===-1&&$t.indexOf(n)===-1&&ee(i)&&te(i,t)}async function H(e,t,n){n.body&&(n.body=JSON.stringify(n.body),n.headers=new D({"Content-type":"application/json"}));const i=await e.fetch(t,n),o=await i.json();if(!i.ok){o.status=i.status;const l=ot(o);throw pe(l)}return o}async function St(e,t){return await H(e,"_index",{method:"POST",body:Be(t)})}async function jt(e,t){return te(t.selector,!0),await H(e,"_find",{method:"POST",body:t})}async function Mt(e,t){return await H(e,"_explain",{method:"POST",body:t})}async function Tt(e){return await H(e,"_index",{method:"GET"})}async function Et(e,t){const n=t.ddoc,i=t.type||"json",o=t.name;if(!n)throw new Error("you must provide an index's ddoc");if(!o)throw new Error("you must provide an index's name");const l="_index/"+[n,i,o].map(encodeURIComponent).join("/");return await H(e,l,{method:"DELETE"})}function Ue(e,t){for(const n of t)if(e=e[n],e===void 0)return;return e}function Ft(e,t,n){return function(i){if(n&&!se(i,n))return;const o=[];for(const l of e){const u=Ue(i,ie(l));if(u===void 0)return;o.push(u)}t(o)}}function At(e,t,n){const i=ie(e);return function(o){if(n&&!se(o,n))return;const l=Ue(o,i);l!==void 0&&t(l)}}function Nt(e,t,n){return function(i){n&&!se(i,n)||t(i[e])}}function Pt(e,t,n){return function(i){if(n&&!se(i,n))return;const o=e.map(l=>i[l]);t(o)}}function Vt(e){return e.every(t=>t.indexOf(".")===-1)}function Ct(e,t,n){const i=Vt(e),o=e.length===1;return i?o?Nt(e[0],t,n):Pt(e,t,n):o?At(e[0],t,n):Ft(e,t,n)}function Qt(e,t){const n=Object.keys(e.fields),i=e.partial_filter_selector;return Ct(n,t,i)}function Rt(){throw new Error("reduce not supported")}function Kt(e,t){const n=e.views[t];if(!n.map||!n.map.fields)throw new Error("ddoc "+e._id+" with view "+t+" doesn't have map.fields defined. maybe it wasn't created by this plugin?")}const ye=pt("indexes",Qt,Rt,Kt);function be(e){return e._customFindAbstractMapper?{query:function(n,i){const o=ye.query.bind(this);return e._customFindAbstractMapper.query.call(this,n,i,o)},viewCleanup:function(){const n=ye.viewCleanup.bind(this);return e._customFindAbstractMapper.viewCleanup.call(this,n)}}:ye}function Lt(e){if(!Array.isArray(e))throw new Error("invalid sort json - should be an array");return e.map(function(t){if(typeof t=="string"){const n={};return n[t]="asc",n}else return t})}const Bt=/^_design\//;function Ut(e){let t=[];return typeof e=="string"?t.push(e):t=e,t.map(function(n){return n.replace(Bt,"")})}function qe(e){return e.fields=e.fields.map(function(t){if(typeof t=="string"){const n={};return n[t]="asc",n}return t}),e.partial_filter_selector&&(e.partial_filter_selector=Pe(e.partial_filter_selector)),e}function qt(e,t){return t.def.fields.map(n=>{const i=C(n);return Ce(e,ie(i))})}function zt(e,t,n){const i=n.def.fields;let o=0;for(const l of e){let u=qt(l.doc,n);if(i.length===1)u=u[0];else for(;u.length>t.length;)u.pop();if(Math.abs(U(u,t))>0)break;++o}return o>0?e.slice(o):e}function Gt(e){const t=re(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 Jt(e){const t=e.fields.filter(function(n){return Ve(n)==="asc"});if(t.length!==0&&t.length!==e.fields.length)throw new Error("unsupported mixed sorting")}function Xt(e,t){if(t.defaultUsed&&e.sort){const n=e.sort.filter(function(i){return Object.keys(i)[0]!=="_id"}).map(function(i){return Object.keys(i)[0]});if(n.length>0)throw new Error('Cannot sort on field(s) "'+n.join(",")+'" when using the default index')}t.defaultUsed}function Ht(e){if(typeof e.selector!="object")throw new Error("you must provide a selector when you find()")}function Yt(e,t){const n=Object.keys(e),i=t?t.map(C):[];let o;return n.length>=i.length?o=n:o=i,i.length===0?{fields:o}:(o=o.sort(function(l,u){let p=i.indexOf(l);p===-1&&(p=Number.MAX_VALUE);let g=i.indexOf(u);return g===-1&&(g=Number.MAX_VALUE),p<g?-1:p>g?1:0}),{fields:o,sortOrder:t.map(C)})}async function Wt(e,t){t=Be(t);const n=re(t.index);t.index=qe(t.index),Jt(t.index);let i;function o(){return i||(i=Ae(JSON.stringify(t)))}const l=t.name||"idx-"+o(),u=t.ddoc||"idx-"+o(),p="_design/"+u;let g=!1,S=!1;function v(T){return T._rev&&T.language!=="query"&&(g=!0),T.language="query",T.views=T.views||{},S=!!T.views[l],S?!1:(T.views[l]={map:{fields:ve(t.index.fields),partial_filter_selector:t.index.partial_filter_selector},reduce:"_count",options:{def:n}},T)}if(e.constructor.emit("debug",["find","creating index",p]),await ke(e,p,v),g)throw new Error('invalid language for ddoc with id "'+p+'" (should be "query")');const m=u+"/"+l;return await be(e).query.call(e,m,{limit:0,reduce:!1}),{id:p,name:l,result:S?"exists":"created"}}async function ze(e){const t=await e.allDocs({startkey:"_design/",endkey:"_design/￿",include_docs:!0}),n={indexes:[{ddoc:null,name:"_all_docs",type:"special",def:{fields:[{_id:"asc"}]}}]};return n.indexes=Ke(n.indexes,t.rows.filter(function(i){return i.doc.language==="query"}).map(function(i){return(i.doc.views!==void 0?Object.keys(i.doc.views):[]).map(function(l){const u=i.doc.views[l];return{ddoc:i.id,name:l,type:"json",def:qe(u.options.def)}})})),n.indexes.sort(function(i,o){return Ne(i.name,o.name)}),n.total_rows=n.indexes.length,n}const ne=null,me={"￿":{}},Zt={queryOpts:{limit:0,startkey:me,endkey:ne},inMemoryFields:[]};function Dt(e,t){return e.def.fields.some(n=>C(n)===t)}function en(e,t){const n=e[t];return C(n)!=="$eq"}function Ge(e,t){const n=t.def.fields.map(C);return e.slice().sort(function(i,o){let l=n.indexOf(i),u=n.indexOf(o);return l===-1&&(l=Number.MAX_VALUE),u===-1&&(u=Number.MAX_VALUE),Ne(l,u)})}function tn(e,t,n){n=Ge(n,e);let i=!1;for(let o=0,l=n.length;o<l;o++){const u=n[o];if(i||!Dt(e,u))return n.slice(o);o<l-1&&en(t,u)&&(i=!0)}return[]}function nn(e){const t=[];for(const[n,i]of Object.entries(e))for(const o of Object.keys(i))o==="$ne"&&t.push(n);return t}function rn(e,t,n,i){const o=Ke(e,tn(t,n,i),nn(n));return Ge(bt(o),t)}function sn(e,t,n){if(t){const i=kt(t,e),o=Le(n,e);return i&&o}return wt(n,e)}const on=["$eq","$gt","$gte","$lt","$lte"];function Je(e){return on.indexOf(e)===-1}function cn(e,t){const n=e[0],i=t[n];return typeof i>"u"?!0:!(Object.keys(i).length===1&&C(i)==="$ne")}function an(e,t,n,i){const o=e.def.fields.map(C);return sn(o,t,n)?cn(o,i):!1}function un(e,t,n,i){return i.filter(function(o){return an(o,n,t,e)})}function ln(e,t,n,i,o){const l=un(e,t,n,i);if(l.length===0){if(o)throw{error:"no_usable_index",message:"There is no index available for this selector."};const g=i[0];return g.defaultUsed=!0,g}if(l.length===1&&!o)return l[0];const u=_t(t);function p(g){const S=g.def.fields.map(C);let v=0;for(const m of S)u[m]&&v++;return v}if(o){const g="_design/"+o[0],S=o.length===2?o[1]:!1,v=l.find(function(m){return!!(S&&m.ddoc===g&&S===m.name||m.ddoc===g)});if(!v)throw{error:"unknown_error",message:"Could not find that index or could not use that index for the query"};return v}return vt(l,p)}function dn(e,t){switch(e){case"$eq":return{key:t};case"$lte":return{endkey:t};case"$gte":return{startkey:t};case"$lt":return{endkey:t,inclusive_end:!1};case"$gt":return{startkey:t,inclusive_start:!1}}return{startkey:ne}}function fn(e,t){const n=C(t.def.fields[0]),i=e[n]||{},o=[],l=Object.keys(i);let u;for(const p of l){Je(p)&&o.push(n);const g=i[p],S=dn(p,g);u?u=ve([u,S]):u=S}return{queryOpts:u,inMemoryFields:o}}function yn(e,t){switch(e){case"$eq":return{startkey:t,endkey:t};case"$lte":return{endkey:t};case"$gte":return{startkey:t};case"$lt":return{endkey:t,inclusive_end:!1};case"$gt":return{startkey:t,inclusive_start:!1}}}function hn(e,t){const n=t.def.fields.map(C);let i=[];const o=[],l=[];let u,p;function g(v){u!==!1&&o.push(ne),p!==!1&&l.push(me),i=n.slice(v)}for(let v=0,m=n.length;v<m;v++){const T=n[v],E=e[T];if(!E||!Object.keys(E).length){g(v);break}else if(Object.keys(E).some(Je)){g(v);break}else if(v>0){const F="$gt"in E||"$gte"in E||"$lt"in E||"$lte"in E,P=Object.keys(e[n[v-1]]),Q=Fe(P,["$eq"]),L=Fe(P,Object.keys(E));if(F&&!Q&&!L){g(v);break}}const K=Object.keys(E);let j=null;for(const F of K){const P=E[F],Q=yn(F,P);j?j=ve([j,Q]):j=Q}o.push("startkey"in j?j.startkey:ne),l.push("endkey"in j?j.endkey:me),"inclusive_start"in j&&(u=j.inclusive_start),"inclusive_end"in j&&(p=j.inclusive_end)}const S={startkey:o,endkey:l};return typeof u<"u"&&(S.inclusive_start=u),typeof p<"u"&&(S.inclusive_end=p),{queryOpts:S,inMemoryFields:i}}function pn(e){return Object.keys(e).map(function(n){return e[n]}).some(function(n){return typeof n=="object"&&Object.keys(n).length===0})}function gn(e){return{queryOpts:{startkey:null},inMemoryFields:[Object.keys(e)]}}function mn(e,t){return t.defaultUsed?gn(e):t.def.fields.length===1?fn(e,t):hn(e,t)}function kn(e,t){const n=e.selector,i=e.sort;if(pn(n))return Object.assign({},Zt,{index:t[0]});const o=Yt(n,i),l=o.fields,u=o.sortOrder,p=ln(n,l,u,t,e.use_index),g=mn(n,p),S=g.queryOpts,v=g.inMemoryFields,m=rn(v,p,n,l);return{queryOpts:S,index:p,inMemoryFields:m}}function wn(e){return e.ddoc.substring(8)+"/"+e.name}async function _n(e,t){const n=re(t);n.descending?("endkey"in n&&typeof n.endkey!="string"&&(n.endkey=""),"startkey"in n&&typeof n.startkey!="string"&&(n.limit=0)):("startkey"in n&&typeof n.startkey!="string"&&(n.startkey=""),"endkey"in n&&typeof n.endkey!="string"&&(n.limit=0)),"key"in n&&typeof n.key!="string"&&(n.limit=0),n.limit>0&&n.indexes_count&&(n.original_limit=n.limit,n.limit+=n.indexes_count);const i=await e.allDocs(n);return i.rows=i.rows.filter(function(o){return!/^_design\//.test(o.id)}),n.original_limit&&(n.limit=n.original_limit),i.rows=i.rows.slice(0,n.limit),i}async function vn(e,t,n){return n.name==="_all_docs"?_n(e,t):be(e).query.call(e,wn(n),t)}async function Xe(e,t,n){t.selector&&(te(t.selector,!1),t.selector=Pe(t.selector)),t.sort&&(t.sort=Lt(t.sort)),t.use_index&&(t.use_index=Ut(t.use_index)),"limit"in t||(t.limit=25),Ht(t);const i=await ze(e);e.constructor.emit("debug",["find","planning query",t]);const o=kn(t,i.indexes);e.constructor.emit("debug",["find","query plan",o]);const l=o.index;Xt(t,l);let u=Object.assign({include_docs:!0,reduce:!1,indexes_count:i.total_rows},o.queryOpts);if("startkey"in u&&"endkey"in u&&U(u.startkey,u.endkey)>0)return{docs:[]};if(t.sort&&typeof t.sort[0]!="string"&&Ve(t.sort[0])==="desc"&&(u.descending=!0,u=Gt(u)),o.inMemoryFields.length||(u.limit=t.limit,"skip"in t&&(u.skip=t.skip)),n)return Promise.resolve(o,u);const g=await vn(e,u,l);u.inclusive_start===!1&&(g.rows=zt(g.rows,u.startkey,l)),o.inMemoryFields.length&&(g.rows=at(g.rows,t,o.inMemoryFields));const S={docs:g.rows.map(function(v){const m=v.doc;return t.fields?mt(m,t.fields):m})};return l.defaultUsed&&(S.warning="No matching index found, create an index to optimize query time."),S}async function bn(e,t){const n=await Xe(e,t,!0);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}}async function xn(e,t){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");const n=t.ddoc,i=t.name;function o(l){return Object.keys(l.views).length===1&&l.views[i]?{_id:n,_deleted:!0}:(delete l.views[i],l)}return await ke(e,n,o),await be(e).viewCleanup.apply(e),{ok:!0}}const Y={};Y.createIndex=X(async function(e){if(typeof e!="object")throw new Error("you must provide an index to create");return(z(this)?St:Wt)(this,e)});Y.find=X(async function(e){if(typeof e!="object")throw new Error("you must provide search parameters to find()");return(z(this)?jt:Xe)(this,e)});Y.explain=X(async function(e){if(typeof e!="object")throw new Error("you must provide search parameters to explain()");return(z(this)?Mt:bn)(this,e)});Y.getIndexes=X(async function(){return(z(this)?Tt:ze)(this)});Y.deleteIndex=X(async function(e){if(typeof e!="object")throw new Error("you must provide an index to delete");return(z(this)?Et:xn)(this,e)});export{Y as default};
@@ -1 +1 @@
1
- import{a as Re,c as L,g as Y}from"./index.js";function z(e){return"$"+e}function ce(e){return e.substring(1)}function R(){this._store={}}R.prototype.get=function(e){var t=z(e);return this._store[t]};R.prototype.set=function(e,t){var i=z(e);return this._store[i]=t,!0};R.prototype.has=function(e){var t=z(e);return t in this._store};R.prototype.keys=function(){return Object.keys(this._store).map(e=>ce(e))};R.prototype.delete=function(e){var t=z(e),i=t in this._store;return delete this._store[t],i};R.prototype.forEach=function(e){for(var t=Object.keys(this._store),i=0,u=t.length;i<u;i++){var a=t[i],l=this._store[a];a=ce(a),e(l,a)}};Object.defineProperty(R.prototype,"size",{get:function(){return Object.keys(this._store).length}});function P(e){if(this._store=new R,e&&Array.isArray(e))for(var t=0,i=e.length;t<i;t++)this.add(e[t])}P.prototype.add=function(e){return this._store.set(e,!0)};P.prototype.has=function(e){return this._store.has(e)};P.prototype.forEach=function(e){this._store.forEach(function(t,i){e(i)})};Object.defineProperty(P.prototype,"size",{get:function(){return this._store.size}});function Me(){if(typeof Symbol>"u"||typeof Map>"u"||typeof Set>"u")return!1;var e=Object.getOwnPropertyDescriptor(Map,Symbol.species);return e&&"get"in e&&Map[Symbol.species]===Map}var oe,W;Me()?(oe=Set,W=Map):(oe=P,W=R);const Ie={},xe=Object.freeze(Object.defineProperty({__proto__:null,default:Ie},Symbol.toStringTag,{value:"Module"})),Ne=Re(xe);var Z={};Z.test=function(){return typeof L.queueMicrotask=="function"};Z.install=function(e){return function(){L.queueMicrotask(e)}};var k={},le=L.MutationObserver||L.WebKitMutationObserver;k.test=function(){return le};k.install=function(e){var t=0,i=new le(e),u=L.document.createTextNode("");return i.observe(u,{characterData:!0}),function(){u.data=t=++t%2}};var ee={};ee.test=function(){return L.setImmediate?!1:typeof L.MessageChannel<"u"};ee.install=function(e){var t=new L.MessageChannel;return t.port1.onmessage=e,function(){t.port2.postMessage(0)}};var te={};te.test=function(){return"document"in L&&"onreadystatechange"in L.document.createElement("script")};te.install=function(e){return function(){var t=L.document.createElement("script");return t.onreadystatechange=function(){e(),t.onreadystatechange=null,t.parentNode.removeChild(t),t=null},L.document.documentElement.appendChild(t),e}};var ne={};ne.test=function(){return!0};ne.install=function(e){return function(){setTimeout(e,0)}};var D=[Ne,Z,k,ee,te,ne],x,I,U=-1,M=[],K=!1;function Te(){!x||!I||(x=!1,I.length?M=I.concat(M):U=-1,M.length&&he())}function he(){if(!x){K=!1,x=!0;for(var e=M.length,t=setTimeout(Te);e;){for(I=M,M=[];I&&++U<e;)I[U].run();U=-1,e=M.length}I=null,U=-1,x=!1,clearTimeout(t)}}var pe,T=-1,De=D.length;for(;++T<De;)if(D[T]&&D[T].test&&D[T].test()){pe=D[T].install(he);break}function de(e,t){this.fun=e,this.array=t}de.prototype.run=function(){var e=this.fun,t=this.array;switch(t.length){case 0:return e();case 1:return e(t[0]);case 2:return e(t[0],t[1]);case 3:return e(t[0],t[1],t[2]);default:return e.apply(null,t)}};var Ue=Pe;function Pe(e){var t=new Array(arguments.length-1);if(arguments.length>1)for(var i=1;i<arguments.length;i++)t[i-1]=arguments[i];M.push(new de(e,t)),!K&&!x&&(K=!0,pe())}const Fe=Y(Ue);class y extends Error{constructor(t,i,u){super(),this.status=t,this.name=i,this.message=u,this.error=!0}toString(){return JSON.stringify({status:this.status,name:this.name,message:this.message,reason:this.reason})}}new y(401,"unauthorized","Name or password is incorrect.");var Dt=new y(400,"bad_request","Missing JSON list of 'docs'"),Ut=new y(404,"not_found","missing"),Pt=new y(409,"conflict","Document update conflict"),qe=new y(400,"bad_request","_id field must contain a string"),je=new y(412,"missing_id","_id is required for puts"),ze=new y(400,"bad_request","Only reserved document ids may start with underscore.");new y(412,"precondition_failed","Database not open");var $e=new y(500,"unknown_error","Database encountered an unknown error"),Ft=new y(500,"badarg","Some query argument is invalid");new y(400,"invalid_request","Request was invalid");var qt=new y(400,"query_parse_error","Some query parameter is invalid"),jt=new y(500,"doc_validation","Bad special document member"),Ve=new y(400,"bad_request","Something wrong with the request"),zt=new y(400,"bad_request","Document must be a JSON object");new y(404,"not_found","Database not found");var $t=new y(500,"indexed_db_went_bad","unknown");new y(500,"web_sql_went_bad","unknown");new y(500,"levelDB_went_went_bad","unknown");new y(403,"forbidden","Forbidden by design doc validate_doc_update function");var Vt=new y(400,"bad_request","Invalid rev format");new y(412,"file_exists","The database could not be created, the file already exists.");var Gt=new y(412,"missing_stub","A pre-existing attachment stub wasn't found");new y(413,"invalid_url","Provided URL is invalid");function q(e,t){function i(u){for(var a=Object.getOwnPropertyNames(e),l=0,h=a.length;l<h;l++)typeof e[a[l]]!="function"&&(this[a[l]]=e[a[l]]);this.stack===void 0&&(this.stack=new Error().stack),u!==void 0&&(this.reason=u)}return i.prototype=y.prototype,new i(t)}function Wt(e){if(typeof e!="object"){var t=e;e=$e,e.data=t}return"error"in e&&e.error==="conflict"&&(e.name="conflict",e.status=409),"name"in e||(e.name=e.error||"unknown"),"status"in e||(e.status=500),"message"in e||(e.message=e.message||e.reason),"stack"in e||(e.stack=new Error().stack),e}var re={exports:{}},N=typeof Reflect=="object"?Reflect:null,se=N&&typeof N.apply=="function"?N.apply:function(t,i,u){return Function.prototype.apply.call(t,i,u)},j;N&&typeof N.ownKeys=="function"?j=N.ownKeys:Object.getOwnPropertySymbols?j=function(t){return Object.getOwnPropertyNames(t).concat(Object.getOwnPropertySymbols(t))}:j=function(t){return Object.getOwnPropertyNames(t)};function Ge(e){console&&console.warn&&console.warn(e)}var ve=Number.isNaN||function(t){return t!==t};function v(){v.init.call(this)}re.exports=v;re.exports.once=Qe;v.EventEmitter=v;v.prototype._events=void 0;v.prototype._eventsCount=0;v.prototype._maxListeners=void 0;var ae=10;function $(e){if(typeof e!="function")throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof e)}Object.defineProperty(v,"defaultMaxListeners",{enumerable:!0,get:function(){return ae},set:function(e){if(typeof e!="number"||e<0||ve(e))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+e+".");ae=e}});v.init=function(){(this._events===void 0||this._events===Object.getPrototypeOf(this)._events)&&(this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0};v.prototype.setMaxListeners=function(t){if(typeof t!="number"||t<0||ve(t))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+t+".");return this._maxListeners=t,this};function ye(e){return e._maxListeners===void 0?v.defaultMaxListeners:e._maxListeners}v.prototype.getMaxListeners=function(){return ye(this)};v.prototype.emit=function(t){for(var i=[],u=1;u<arguments.length;u++)i.push(arguments[u]);var a=t==="error",l=this._events;if(l!==void 0)a=a&&l.error===void 0;else if(!a)return!1;if(a){var h;if(i.length>0&&(h=i[0]),h instanceof Error)throw h;var d=new Error("Unhandled error."+(h?" ("+h.message+")":""));throw d.context=h,d}var m=l[t];if(m===void 0)return!1;if(typeof m=="function")se(m,this,i);else for(var A=m.length,w=be(m,A),u=0;u<A;++u)se(w[u],this,i);return!0};function ge(e,t,i,u){var a,l,h;if($(i),l=e._events,l===void 0?(l=e._events=Object.create(null),e._eventsCount=0):(l.newListener!==void 0&&(e.emit("newListener",t,i.listener?i.listener:i),l=e._events),h=l[t]),h===void 0)h=l[t]=i,++e._eventsCount;else if(typeof h=="function"?h=l[t]=u?[i,h]:[h,i]:u?h.unshift(i):h.push(i),a=ye(e),a>0&&h.length>a&&!h.warned){h.warned=!0;var d=new Error("Possible EventEmitter memory leak detected. "+h.length+" "+String(t)+" listeners added. Use emitter.setMaxListeners() to increase limit");d.name="MaxListenersExceededWarning",d.emitter=e,d.type=t,d.count=h.length,Ge(d)}return e}v.prototype.addListener=function(t,i){return ge(this,t,i,!1)};v.prototype.on=v.prototype.addListener;v.prototype.prependListener=function(t,i){return ge(this,t,i,!0)};function We(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,arguments.length===0?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function me(e,t,i){var u={fired:!1,wrapFn:void 0,target:e,type:t,listener:i},a=We.bind(u);return a.listener=i,u.wrapFn=a,a}v.prototype.once=function(t,i){return $(i),this.on(t,me(this,t,i)),this};v.prototype.prependOnceListener=function(t,i){return $(i),this.prependListener(t,me(this,t,i)),this};v.prototype.removeListener=function(t,i){var u,a,l,h,d;if($(i),a=this._events,a===void 0)return this;if(u=a[t],u===void 0)return this;if(u===i||u.listener===i)--this._eventsCount===0?this._events=Object.create(null):(delete a[t],a.removeListener&&this.emit("removeListener",t,u.listener||i));else if(typeof u!="function"){for(l=-1,h=u.length-1;h>=0;h--)if(u[h]===i||u[h].listener===i){d=u[h].listener,l=h;break}if(l<0)return this;l===0?u.shift():Ke(u,l),u.length===1&&(a[t]=u[0]),a.removeListener!==void 0&&this.emit("removeListener",t,d||i)}return this};v.prototype.off=v.prototype.removeListener;v.prototype.removeAllListeners=function(t){var i,u,a;if(u=this._events,u===void 0)return this;if(u.removeListener===void 0)return arguments.length===0?(this._events=Object.create(null),this._eventsCount=0):u[t]!==void 0&&(--this._eventsCount===0?this._events=Object.create(null):delete u[t]),this;if(arguments.length===0){var l=Object.keys(u),h;for(a=0;a<l.length;++a)h=l[a],h!=="removeListener"&&this.removeAllListeners(h);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if(i=u[t],typeof i=="function")this.removeListener(t,i);else if(i!==void 0)for(a=i.length-1;a>=0;a--)this.removeListener(t,i[a]);return this};function _e(e,t,i){var u=e._events;if(u===void 0)return[];var a=u[t];return a===void 0?[]:typeof a=="function"?i?[a.listener||a]:[a]:i?Je(a):be(a,a.length)}v.prototype.listeners=function(t){return _e(this,t,!0)};v.prototype.rawListeners=function(t){return _e(this,t,!1)};v.listenerCount=function(e,t){return typeof e.listenerCount=="function"?e.listenerCount(t):we.call(e,t)};v.prototype.listenerCount=we;function we(e){var t=this._events;if(t!==void 0){var i=t[e];if(typeof i=="function")return 1;if(i!==void 0)return i.length}return 0}v.prototype.eventNames=function(){return this._eventsCount>0?j(this._events):[]};function be(e,t){for(var i=new Array(t),u=0;u<t;++u)i[u]=e[u];return i}function Ke(e,t){for(;t+1<e.length;t++)e[t]=e[t+1];e.pop()}function Je(e){for(var t=new Array(e.length),i=0;i<t.length;++i)t[i]=e[i].listener||e[i];return t}function Qe(e,t){return new Promise(function(i,u){function a(h){e.removeListener(t,l),u(h)}function l(){typeof e.removeListener=="function"&&e.removeListener("error",a),i([].slice.call(arguments))}Ae(e,t,l,{once:!0}),t!=="error"&&He(e,a,{once:!0})})}function He(e,t,i){typeof e.on=="function"&&Ae(e,"error",t,i)}function Ae(e,t,i,u){if(typeof e.on=="function")u.once?e.once(t,i):e.on(t,i);else if(typeof e.addEventListener=="function")e.addEventListener(t,function a(l){u.once&&e.removeEventListener(t,a),i(l)});else throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof e)}var Xe=re.exports;const Be=Y(Xe);var F,Ye=new Uint8Array(16);function Ze(){if(!F&&(F=typeof crypto<"u"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||typeof msCrypto<"u"&&typeof msCrypto.getRandomValues=="function"&&msCrypto.getRandomValues.bind(msCrypto),!F))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return F(Ye)}const ke=/^(?:[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;function et(e){return typeof e=="string"&&ke.test(e)}var b=[];for(var G=0;G<256;++G)b.push((G+256).toString(16).substr(1));function tt(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,i=(b[e[t+0]]+b[e[t+1]]+b[e[t+2]]+b[e[t+3]]+"-"+b[e[t+4]]+b[e[t+5]]+"-"+b[e[t+6]]+b[e[t+7]]+"-"+b[e[t+8]]+b[e[t+9]]+"-"+b[e[t+10]]+b[e[t+11]]+b[e[t+12]]+b[e[t+13]]+b[e[t+14]]+b[e[t+15]]).toLowerCase();if(!et(i))throw TypeError("Stringified UUID is invalid");return i}function Ee(e,t,i){e=e||{};var u=e.random||(e.rng||Ze)();if(u[6]=u[6]&15|64,u[8]=u[8]&63|128,t){i=i||0;for(var a=0;a<16;++a)t[i+a]=u[a];return t}return tt(u)}var nt=function(e){return atob(e)},Le=function(e){return btoa(e)};function rt(e,t){e=e||[],t=t||{};try{return new Blob(e,t)}catch(l){if(l.name!=="TypeError")throw l;for(var i=typeof BlobBuilder<"u"?BlobBuilder:typeof MSBlobBuilder<"u"?MSBlobBuilder:typeof MozBlobBuilder<"u"?MozBlobBuilder:WebKitBlobBuilder,u=new i,a=0;a<e.length;a+=1)u.append(e[a]);return u.getBlob(t.type)}}function it(e){for(var t=e.length,i=new ArrayBuffer(t),u=new Uint8Array(i),a=0;a<t;a++)u[a]=e.charCodeAt(a);return i}function ot(e,t){return rt([it(e)],{type:t})}function Kt(e,t){return ot(nt(e),t)}function st(e){for(var t="",i=new Uint8Array(e),u=i.byteLength,a=0;a<u;a++)t+=String.fromCharCode(i[a]);return t}function at(e,t){var i=new FileReader,u=typeof i.readAsBinaryString=="function";i.onloadend=function(a){var l=a.target.result||"";if(u)return t(l);t(st(l))},u?i.readAsBinaryString(e):i.readAsArrayBuffer(e)}function ut(e,t){at(e,function(i){t(i)})}function Jt(e,t){ut(e,function(i){t(Le(i))})}function ft(e,t){var i=new FileReader;i.onloadend=function(u){var a=u.target.result||new ArrayBuffer(0);t(a)},i.readAsArrayBuffer(e)}var Se={exports:{}};(function(e,t){(function(i){e.exports=i()})(function(i){var u=["0","1","2","3","4","5","6","7","8","9","a","b","c","d","e","f"];function a(c,f){var r=c[0],n=c[1],s=c[2],o=c[3];r+=(n&s|~n&o)+f[0]-680876936|0,r=(r<<7|r>>>25)+n|0,o+=(r&n|~r&s)+f[1]-389564586|0,o=(o<<12|o>>>20)+r|0,s+=(o&r|~o&n)+f[2]+606105819|0,s=(s<<17|s>>>15)+o|0,n+=(s&o|~s&r)+f[3]-1044525330|0,n=(n<<22|n>>>10)+s|0,r+=(n&s|~n&o)+f[4]-176418897|0,r=(r<<7|r>>>25)+n|0,o+=(r&n|~r&s)+f[5]+1200080426|0,o=(o<<12|o>>>20)+r|0,s+=(o&r|~o&n)+f[6]-1473231341|0,s=(s<<17|s>>>15)+o|0,n+=(s&o|~s&r)+f[7]-45705983|0,n=(n<<22|n>>>10)+s|0,r+=(n&s|~n&o)+f[8]+1770035416|0,r=(r<<7|r>>>25)+n|0,o+=(r&n|~r&s)+f[9]-1958414417|0,o=(o<<12|o>>>20)+r|0,s+=(o&r|~o&n)+f[10]-42063|0,s=(s<<17|s>>>15)+o|0,n+=(s&o|~s&r)+f[11]-1990404162|0,n=(n<<22|n>>>10)+s|0,r+=(n&s|~n&o)+f[12]+1804603682|0,r=(r<<7|r>>>25)+n|0,o+=(r&n|~r&s)+f[13]-40341101|0,o=(o<<12|o>>>20)+r|0,s+=(o&r|~o&n)+f[14]-1502002290|0,s=(s<<17|s>>>15)+o|0,n+=(s&o|~s&r)+f[15]+1236535329|0,n=(n<<22|n>>>10)+s|0,r+=(n&o|s&~o)+f[1]-165796510|0,r=(r<<5|r>>>27)+n|0,o+=(r&s|n&~s)+f[6]-1069501632|0,o=(o<<9|o>>>23)+r|0,s+=(o&n|r&~n)+f[11]+643717713|0,s=(s<<14|s>>>18)+o|0,n+=(s&r|o&~r)+f[0]-373897302|0,n=(n<<20|n>>>12)+s|0,r+=(n&o|s&~o)+f[5]-701558691|0,r=(r<<5|r>>>27)+n|0,o+=(r&s|n&~s)+f[10]+38016083|0,o=(o<<9|o>>>23)+r|0,s+=(o&n|r&~n)+f[15]-660478335|0,s=(s<<14|s>>>18)+o|0,n+=(s&r|o&~r)+f[4]-405537848|0,n=(n<<20|n>>>12)+s|0,r+=(n&o|s&~o)+f[9]+568446438|0,r=(r<<5|r>>>27)+n|0,o+=(r&s|n&~s)+f[14]-1019803690|0,o=(o<<9|o>>>23)+r|0,s+=(o&n|r&~n)+f[3]-187363961|0,s=(s<<14|s>>>18)+o|0,n+=(s&r|o&~r)+f[8]+1163531501|0,n=(n<<20|n>>>12)+s|0,r+=(n&o|s&~o)+f[13]-1444681467|0,r=(r<<5|r>>>27)+n|0,o+=(r&s|n&~s)+f[2]-51403784|0,o=(o<<9|o>>>23)+r|0,s+=(o&n|r&~n)+f[7]+1735328473|0,s=(s<<14|s>>>18)+o|0,n+=(s&r|o&~r)+f[12]-1926607734|0,n=(n<<20|n>>>12)+s|0,r+=(n^s^o)+f[5]-378558|0,r=(r<<4|r>>>28)+n|0,o+=(r^n^s)+f[8]-2022574463|0,o=(o<<11|o>>>21)+r|0,s+=(o^r^n)+f[11]+1839030562|0,s=(s<<16|s>>>16)+o|0,n+=(s^o^r)+f[14]-35309556|0,n=(n<<23|n>>>9)+s|0,r+=(n^s^o)+f[1]-1530992060|0,r=(r<<4|r>>>28)+n|0,o+=(r^n^s)+f[4]+1272893353|0,o=(o<<11|o>>>21)+r|0,s+=(o^r^n)+f[7]-155497632|0,s=(s<<16|s>>>16)+o|0,n+=(s^o^r)+f[10]-1094730640|0,n=(n<<23|n>>>9)+s|0,r+=(n^s^o)+f[13]+681279174|0,r=(r<<4|r>>>28)+n|0,o+=(r^n^s)+f[0]-358537222|0,o=(o<<11|o>>>21)+r|0,s+=(o^r^n)+f[3]-722521979|0,s=(s<<16|s>>>16)+o|0,n+=(s^o^r)+f[6]+76029189|0,n=(n<<23|n>>>9)+s|0,r+=(n^s^o)+f[9]-640364487|0,r=(r<<4|r>>>28)+n|0,o+=(r^n^s)+f[12]-421815835|0,o=(o<<11|o>>>21)+r|0,s+=(o^r^n)+f[15]+530742520|0,s=(s<<16|s>>>16)+o|0,n+=(s^o^r)+f[2]-995338651|0,n=(n<<23|n>>>9)+s|0,r+=(s^(n|~o))+f[0]-198630844|0,r=(r<<6|r>>>26)+n|0,o+=(n^(r|~s))+f[7]+1126891415|0,o=(o<<10|o>>>22)+r|0,s+=(r^(o|~n))+f[14]-1416354905|0,s=(s<<15|s>>>17)+o|0,n+=(o^(s|~r))+f[5]-57434055|0,n=(n<<21|n>>>11)+s|0,r+=(s^(n|~o))+f[12]+1700485571|0,r=(r<<6|r>>>26)+n|0,o+=(n^(r|~s))+f[3]-1894986606|0,o=(o<<10|o>>>22)+r|0,s+=(r^(o|~n))+f[10]-1051523|0,s=(s<<15|s>>>17)+o|0,n+=(o^(s|~r))+f[1]-2054922799|0,n=(n<<21|n>>>11)+s|0,r+=(s^(n|~o))+f[8]+1873313359|0,r=(r<<6|r>>>26)+n|0,o+=(n^(r|~s))+f[15]-30611744|0,o=(o<<10|o>>>22)+r|0,s+=(r^(o|~n))+f[6]-1560198380|0,s=(s<<15|s>>>17)+o|0,n+=(o^(s|~r))+f[13]+1309151649|0,n=(n<<21|n>>>11)+s|0,r+=(s^(n|~o))+f[4]-145523070|0,r=(r<<6|r>>>26)+n|0,o+=(n^(r|~s))+f[11]-1120210379|0,o=(o<<10|o>>>22)+r|0,s+=(r^(o|~n))+f[2]+718787259|0,s=(s<<15|s>>>17)+o|0,n+=(o^(s|~r))+f[9]-343485551|0,n=(n<<21|n>>>11)+s|0,c[0]=r+c[0]|0,c[1]=n+c[1]|0,c[2]=s+c[2]|0,c[3]=o+c[3]|0}function l(c){var f=[],r;for(r=0;r<64;r+=4)f[r>>2]=c.charCodeAt(r)+(c.charCodeAt(r+1)<<8)+(c.charCodeAt(r+2)<<16)+(c.charCodeAt(r+3)<<24);return f}function h(c){var f=[],r;for(r=0;r<64;r+=4)f[r>>2]=c[r]+(c[r+1]<<8)+(c[r+2]<<16)+(c[r+3]<<24);return f}function d(c){var f=c.length,r=[1732584193,-271733879,-1732584194,271733878],n,s,o,g,S,E;for(n=64;n<=f;n+=64)a(r,l(c.substring(n-64,n)));for(c=c.substring(n-64),s=c.length,o=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],n=0;n<s;n+=1)o[n>>2]|=c.charCodeAt(n)<<(n%4<<3);if(o[n>>2]|=128<<(n%4<<3),n>55)for(a(r,o),n=0;n<16;n+=1)o[n]=0;return g=f*8,g=g.toString(16).match(/(.*?)(.{0,8})$/),S=parseInt(g[2],16),E=parseInt(g[1],16)||0,o[14]=S,o[15]=E,a(r,o),r}function m(c){var f=c.length,r=[1732584193,-271733879,-1732584194,271733878],n,s,o,g,S,E;for(n=64;n<=f;n+=64)a(r,h(c.subarray(n-64,n)));for(c=n-64<f?c.subarray(n-64):new Uint8Array(0),s=c.length,o=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],n=0;n<s;n+=1)o[n>>2]|=c[n]<<(n%4<<3);if(o[n>>2]|=128<<(n%4<<3),n>55)for(a(r,o),n=0;n<16;n+=1)o[n]=0;return g=f*8,g=g.toString(16).match(/(.*?)(.{0,8})$/),S=parseInt(g[2],16),E=parseInt(g[1],16)||0,o[14]=S,o[15]=E,a(r,o),r}function A(c){var f="",r;for(r=0;r<4;r+=1)f+=u[c>>r*8+4&15]+u[c>>r*8&15];return f}function w(c){var f;for(f=0;f<c.length;f+=1)c[f]=A(c[f]);return c.join("")}w(d("hello")),typeof ArrayBuffer<"u"&&!ArrayBuffer.prototype.slice&&function(){function c(f,r){return f=f|0||0,f<0?Math.max(f+r,0):Math.min(f,r)}ArrayBuffer.prototype.slice=function(f,r){var n=this.byteLength,s=c(f,n),o=n,g,S,E,ie;return r!==i&&(o=c(r,n)),s>o?new ArrayBuffer(0):(g=o-s,S=new ArrayBuffer(g),E=new Uint8Array(S),ie=new Uint8Array(this,s,g),E.set(ie),S)}}();function O(c){return/[\u0080-\uFFFF]/.test(c)&&(c=unescape(encodeURIComponent(c))),c}function B(c,f){var r=c.length,n=new ArrayBuffer(r),s=new Uint8Array(n),o;for(o=0;o<r;o+=1)s[o]=c.charCodeAt(o);return f?s:n}function C(c){return String.fromCharCode.apply(null,new Uint8Array(c))}function V(c,f,r){var n=new Uint8Array(c.byteLength+f.byteLength);return n.set(new Uint8Array(c)),n.set(new Uint8Array(f),c.byteLength),n}function _(c){var f=[],r=c.length,n;for(n=0;n<r-1;n+=2)f.push(parseInt(c.substr(n,2),16));return String.fromCharCode.apply(String,f)}function p(){this.reset()}return p.prototype.append=function(c){return this.appendBinary(O(c)),this},p.prototype.appendBinary=function(c){this._buff+=c,this._length+=c.length;var f=this._buff.length,r;for(r=64;r<=f;r+=64)a(this._hash,l(this._buff.substring(r-64,r)));return this._buff=this._buff.substring(r-64),this},p.prototype.end=function(c){var f=this._buff,r=f.length,n,s=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],o;for(n=0;n<r;n+=1)s[n>>2]|=f.charCodeAt(n)<<(n%4<<3);return this._finish(s,r),o=w(this._hash),c&&(o=_(o)),this.reset(),o},p.prototype.reset=function(){return this._buff="",this._length=0,this._hash=[1732584193,-271733879,-1732584194,271733878],this},p.prototype.getState=function(){return{buff:this._buff,length:this._length,hash:this._hash.slice()}},p.prototype.setState=function(c){return this._buff=c.buff,this._length=c.length,this._hash=c.hash,this},p.prototype.destroy=function(){delete this._hash,delete this._buff,delete this._length},p.prototype._finish=function(c,f){var r=f,n,s,o;if(c[r>>2]|=128<<(r%4<<3),r>55)for(a(this._hash,c),r=0;r<16;r+=1)c[r]=0;n=this._length*8,n=n.toString(16).match(/(.*?)(.{0,8})$/),s=parseInt(n[2],16),o=parseInt(n[1],16)||0,c[14]=s,c[15]=o,a(this._hash,c)},p.hash=function(c,f){return p.hashBinary(O(c),f)},p.hashBinary=function(c,f){var r=d(c),n=w(r);return f?_(n):n},p.ArrayBuffer=function(){this.reset()},p.ArrayBuffer.prototype.append=function(c){var f=V(this._buff.buffer,c),r=f.length,n;for(this._length+=c.byteLength,n=64;n<=r;n+=64)a(this._hash,h(f.subarray(n-64,n)));return this._buff=n-64<r?new Uint8Array(f.buffer.slice(n-64)):new Uint8Array(0),this},p.ArrayBuffer.prototype.end=function(c){var f=this._buff,r=f.length,n=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],s,o;for(s=0;s<r;s+=1)n[s>>2]|=f[s]<<(s%4<<3);return this._finish(n,r),o=w(this._hash),c&&(o=_(o)),this.reset(),o},p.ArrayBuffer.prototype.reset=function(){return this._buff=new Uint8Array(0),this._length=0,this._hash=[1732584193,-271733879,-1732584194,271733878],this},p.ArrayBuffer.prototype.getState=function(){var c=p.prototype.getState.call(this);return c.buff=C(c.buff),c},p.ArrayBuffer.prototype.setState=function(c){return c.buff=B(c.buff,!0),p.prototype.setState.call(this,c)},p.ArrayBuffer.prototype.destroy=p.prototype.destroy,p.ArrayBuffer.prototype._finish=p.prototype._finish,p.ArrayBuffer.hash=function(c,f){var r=m(new Uint8Array(c)),n=w(r);return f?_(n):n},p})})(Se);var ct=Se.exports;const J=Y(ct);var lt=self.setImmediate||self.setTimeout,ht=32768;function pt(e){return Le(e)}function dt(e,t,i){return e.webkitSlice?e.webkitSlice(t,i):e.slice(t,i)}function vt(e,t,i,u,a){(i>0||u<t.size)&&(t=dt(t,i,u)),ft(t,function(l){e.append(l),a()})}function yt(e,t,i,u,a){(i>0||u<t.length)&&(t=t.substring(i,u)),e.appendBinary(t),a()}function Qt(e,t){var i=typeof e=="string",u=i?e.length:e.size,a=Math.min(ht,u),l=Math.ceil(u/a),h=0,d=i?new J:new J.ArrayBuffer,m=i?yt:vt;function A(){lt(O)}function w(){var B=d.end(!0),C=pt(B);t(C),d.destroy()}function O(){var B=h*a,C=B+a;h++,h<l?m(d,e,B,C,A):m(d,e,B,C,w)}O()}function gt(e){return J.hash(e)}function mt(e){return typeof ArrayBuffer<"u"&&e instanceof ArrayBuffer||typeof Blob<"u"&&e instanceof Blob}function _t(e){if(typeof e.slice=="function")return e.slice(0);var t=new ArrayBuffer(e.byteLength),i=new Uint8Array(t),u=new Uint8Array(e);return i.set(u),t}function wt(e){if(e instanceof ArrayBuffer)return _t(e);var t=e.size,i=e.type;return typeof e.slice=="function"?e.slice(0,t,i):e.webkitSlice(0,t,i)}var Oe=Function.prototype.toString,bt=Oe.call(Object);function At(e){var t=Object.getPrototypeOf(e);if(t===null)return!0;var i=t.constructor;return typeof i=="function"&&i instanceof i&&Oe.call(i)==bt}function Q(e){var t,i,u;if(!e||typeof e!="object")return e;if(Array.isArray(e)){for(t=[],i=0,u=e.length;i<u;i++)t[i]=Q(e[i]);return t}if(e instanceof Date&&isFinite(e))return e.toISOString();if(mt(e))return wt(e);if(!At(e))return e;t={};for(i in e)if(Object.prototype.hasOwnProperty.call(e,i)){var a=Q(e[i]);typeof a<"u"&&(t[i]=a)}return t}function Bt(e){var t=!1;return function(...i){if(t)throw new Error("once called more than once");t=!0,e.apply(this,i)}}function Et(e){return function(...t){t=Q(t);var i=this,u=typeof t[t.length-1]=="function"?t.pop():!1,a=new Promise(function(l,h){var d;try{var m=Bt(function(A,w){A?h(A):l(w)});t.push(m),d=e.apply(i,t),d&&typeof d.then=="function"&&l(d)}catch(A){h(A)}});return u&&a.then(function(l){u(null,l)},u),a}}function Lt(e,t,i){if(e.constructor.listeners("debug").length){for(var u=["api",e.name,t],a=0;a<i.length-1;a++)u.push(i[a]);e.constructor.emit("debug",u);var l=i[i.length-1];i[i.length-1]=function(h,d){var m=["api",e.name,t];m=m.concat(h?["error",h]:["success",d]),e.constructor.emit("debug",m),l(h,d)}}}function Ht(e,t){return Et(function(...i){if(this._closed)return Promise.reject(new Error("database is closed"));if(this._destroyed)return Promise.reject(new Error("database is destroyed"));var u=this;return Lt(u,e,i),this.taskqueue.isReady?t.apply(this,i):new Promise(function(a,l){u.taskqueue.addTask(function(h){h?l(h):a(u[e].apply(u,i))})})})}function Ce(e,t){for(var i={},u=0,a=t.length;u<a;u++){var l=t[u];l in e&&(i[l]=e[l])}return i}var St=6;function ue(e){return e}function Ot(e){return[{ok:e}]}function Xt(e,t,i){var u=t.docs,a=new W;u.forEach(function(_){a.has(_.id)?a.get(_.id).push(_):a.set(_.id,[_])});var l=a.size,h=0,d=new Array(l);function m(){var _=[];d.forEach(function(p){p.docs.forEach(function(c){_.push({id:p.id,docs:[c]})})}),i(null,{results:_})}function A(){++h===l&&m()}function w(_,p,c){d[_]={id:p,docs:c},A()}var O=[];a.forEach(function(_,p){O.push(p)});var B=0;function C(){if(!(B>=O.length)){var _=Math.min(B+St,O.length),p=O.slice(B,_);V(p,B),B+=p.length}}function V(_,p){_.forEach(function(c,f){var r=p+f,n=a.get(c),s=Ce(n[0],["atts_since","attachments"]);s.open_revs=n.map(function(g){return g.rev}),s.open_revs=s.open_revs.filter(ue);var o=ue;s.open_revs.length===0&&(delete s.open_revs,o=Ot),["revs","attachments","binary","ajax","latest"].forEach(function(g){g in t&&(s[g]=t[g])}),e.get(c,s,function(g,S){var E;g?E=[{error:g}]:E=o(S),w(r,c,E),C()})})}C()}var H;try{localStorage.setItem("_pouch_check_localstorage",1),H=!!localStorage.getItem("_pouch_check_localstorage")}catch{H=!1}function fe(){return H}class Yt extends Be{constructor(){super(),this._listeners={},fe()&&addEventListener("storage",t=>{this.emit(t.key)})}addListener(t,i,u,a){if(this._listeners[i])return;var l=!1,h=this;function d(){if(!h._listeners[i])return;if(l){l="waiting";return}l=!0;var m=Ce(a,["style","include_docs","attachments","conflicts","filter","doc_ids","view","since","query_params","binary","return_docs"]);function A(){l=!1}u.changes(m).on("change",function(w){w.seq>a.since&&!a.cancelled&&(a.since=w.seq,a.onChange(w))}).on("complete",function(){l==="waiting"&&Fe(d),l=!1}).on("error",A)}this._listeners[i]=d,this.on(t,d)}removeListener(t,i){i in this._listeners&&(super.removeListener(t,this._listeners[i]),delete this._listeners[i])}notifyLocalWindows(t){fe()&&(localStorage[t]=localStorage[t]==="a"?"b":"a")}notify(t){this.emit(t),this.notifyLocalWindows(t)}}function Ct(e){if(typeof console<"u"&&typeof console[e]=="function"){var t=Array.prototype.slice.call(arguments,1);console[e].apply(console,t)}}var X;typeof Object.assign=="function"?X=Object.assign:X=function(e){for(var t=Object(e),i=1;i<arguments.length;i++){var u=arguments[i];if(u!=null)for(var a in u)Object.prototype.hasOwnProperty.call(u,a)&&(t[a]=u[a])}return t};var Rt=X;function Mt(e,t,i){try{return!e(t,i)}catch(a){var u="Filter function threw: "+a.toString();return q(Ve,u)}}function Zt(e){var t={},i=e.filter&&typeof e.filter=="function";return t.query=e.query_params,function(a){a.doc||(a.doc={});var l=i&&Mt(e.filter,a.doc,t);if(typeof l=="object")return l;if(l)return!1;if(!e.include_docs)delete a.doc;else if(!e.attachments)for(var h in a.doc._attachments)Object.prototype.hasOwnProperty.call(a.doc._attachments,h)&&(a.doc._attachments[h].stub=!0);return!0}}function kt(e){for(var t=[],i=0,u=e.length;i<u;i++)t=t.concat(e[i]);return t}function en(e){var t;if(e?typeof e!="string"?t=q(qe):/^_/.test(e)&&!/^_(design|local)/.test(e)&&(t=q(ze)):t=q(je),t)throw t}function tn(e){return typeof e._remote=="boolean"?e._remote:typeof e.type=="function"?(Ct("warn","db.type() is deprecated and will be removed in a future version of PouchDB"),e.type()==="http"):!1}function nn(e,t){return"listenerCount"in e?e.listenerCount(t):Be.listenerCount(e,t)}function It(e){if(!e)return null;var t=e.split("/");return t.length===2?t:t.length===1?[e,e]:null}function rn(e){var t=It(e);return t?t.join("/"):null}function on(e,t){var i=[],u=[];for(var a in t)Object.prototype.hasOwnProperty.call(t,a)&&(i.push(a),u.push(t[a]));return i.push(e),Function.apply(null,i).apply(null,u)}function xt(e,t,i){return e.get(t).catch(function(u){if(u.status!==404)throw u;return{}}).then(function(u){var a=u._rev,l=i(u);return l?(l._id=t,l._rev=a,Nt(e,l,i)):{updated:!1,rev:a}})}function Nt(e,t,i){return e.put(t).then(function(u){return{updated:!0,rev:u.rev}},function(u){if(u.status!==409)throw u;return xt(e,t._id,i)})}function sn(e,t){if(!t)return Ee().replace(/-/g,"").toLowerCase();var i=Rt({},e);return delete i._rev_tree,gt(JSON.stringify(i))}var an=Ee;export{Qt as A,Ve as B,nt as C,jt as D,Be as E,Ft as F,ut as G,Jt as H,qe as I,Yt as J,Et as K,$t as L,Ut as M,zt as N,rt as O,Kt as P,qt as Q,Pt as R,at as S,oe as T,$e as U,Zt as V,Gt as W,gt as X,kt as Y,Ht as a,Rt as b,q as c,en as d,Ct as e,W as f,Wt as g,Xt as h,tn as i,Q as j,Ce as k,nn as l,Fe as m,rn as n,Bt as o,It as p,Vt as q,sn as r,on as s,Dt as t,xt as u,Ee as v,fe as w,an as x,ot as y,Le as z};
1
+ import{g as G}from"./index.js";class y extends Error{constructor(t,o,u){super(),this.status=t,this.name=o,this.message=u,this.error=!0}toString(){return JSON.stringify({status:this.status,name:this.name,message:this.message,reason:this.reason})}}new y(401,"unauthorized","Name or password is incorrect.");var ke=new y(400,"bad_request","Missing JSON list of 'docs'"),et=new y(404,"not_found","missing"),tt=new y(409,"conflict","Document update conflict"),oe=new y(400,"bad_request","_id field must contain a string"),se=new y(412,"missing_id","_id is required for puts"),ae=new y(400,"bad_request","Only reserved document ids may start with underscore.");new y(412,"precondition_failed","Database not open");var ue=new y(500,"unknown_error","Database encountered an unknown error"),nt=new y(500,"badarg","Some query argument is invalid");new y(400,"invalid_request","Request was invalid");var rt=new y(400,"query_parse_error","Some query parameter is invalid"),it=new y(500,"doc_validation","Bad special document member"),fe=new y(400,"bad_request","Something wrong with the request"),ot=new y(400,"bad_request","Document must be a JSON object");new y(404,"not_found","Database not found");var st=new y(500,"indexed_db_went_bad","unknown");new y(500,"web_sql_went_bad","unknown");new y(500,"levelDB_went_went_bad","unknown");new y(403,"forbidden","Forbidden by design doc validate_doc_update function");var at=new y(400,"bad_request","Invalid rev format");new y(412,"file_exists","The database could not be created, the file already exists.");var ut=new y(412,"missing_stub","A pre-existing attachment stub wasn't found");new y(413,"invalid_url","Provided URL is invalid");function x(e,t){function o(u){for(var a=Object.getOwnPropertyNames(e),l=0,h=a.length;l<h;l++)typeof e[a[l]]!="function"&&(this[a[l]]=e[a[l]]);this.stack===void 0&&(this.stack=new Error().stack),u!==void 0&&(this.reason=u)}return o.prototype=y.prototype,new o(t)}function ft(e){if(typeof e!="object"){var t=e;e=ue,e.data=t}return"error"in e&&e.error==="conflict"&&(e.name="conflict",e.status=409),"name"in e||(e.name=e.error||"unknown"),"status"in e||(e.status=500),"message"in e||(e.message=e.message||e.reason),"stack"in e||(e.stack=new Error().stack),e}var P={exports:{}},O=typeof Reflect=="object"?Reflect:null,j=O&&typeof O.apply=="function"?O.apply:function(t,o,u){return Function.prototype.apply.call(t,o,u)},I;O&&typeof O.ownKeys=="function"?I=O.ownKeys:Object.getOwnPropertySymbols?I=function(t){return Object.getOwnPropertyNames(t).concat(Object.getOwnPropertySymbols(t))}:I=function(t){return Object.getOwnPropertyNames(t)};function ce(e){console&&console.warn&&console.warn(e)}var W=Number.isNaN||function(t){return t!==t};function v(){v.init.call(this)}P.exports=v;P.exports.once=pe;v.EventEmitter=v;v.prototype._events=void 0;v.prototype._eventsCount=0;v.prototype._maxListeners=void 0;var V=10;function M(e){if(typeof e!="function")throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof e)}Object.defineProperty(v,"defaultMaxListeners",{enumerable:!0,get:function(){return V},set:function(e){if(typeof e!="number"||e<0||W(e))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+e+".");V=e}});v.init=function(){(this._events===void 0||this._events===Object.getPrototypeOf(this)._events)&&(this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0};v.prototype.setMaxListeners=function(t){if(typeof t!="number"||t<0||W(t))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+t+".");return this._maxListeners=t,this};function J(e){return e._maxListeners===void 0?v.defaultMaxListeners:e._maxListeners}v.prototype.getMaxListeners=function(){return J(this)};v.prototype.emit=function(t){for(var o=[],u=1;u<arguments.length;u++)o.push(arguments[u]);var a=t==="error",l=this._events;if(l!==void 0)a=a&&l.error===void 0;else if(!a)return!1;if(a){var h;if(o.length>0&&(h=o[0]),h instanceof Error)throw h;var p=new Error("Unhandled error."+(h?" ("+h.message+")":""));throw p.context=h,p}var m=l[t];if(m===void 0)return!1;if(typeof m=="function")j(m,this,o);else for(var A=m.length,w=Y(m,A),u=0;u<A;++u)j(w[u],this,o);return!0};function $(e,t,o,u){var a,l,h;if(M(o),l=e._events,l===void 0?(l=e._events=Object.create(null),e._eventsCount=0):(l.newListener!==void 0&&(e.emit("newListener",t,o.listener?o.listener:o),l=e._events),h=l[t]),h===void 0)h=l[t]=o,++e._eventsCount;else if(typeof h=="function"?h=l[t]=u?[o,h]:[h,o]:u?h.unshift(o):h.push(o),a=J(e),a>0&&h.length>a&&!h.warned){h.warned=!0;var p=new Error("Possible EventEmitter memory leak detected. "+h.length+" "+String(t)+" listeners added. Use emitter.setMaxListeners() to increase limit");p.name="MaxListenersExceededWarning",p.emitter=e,p.type=t,p.count=h.length,ce(p)}return e}v.prototype.addListener=function(t,o){return $(this,t,o,!1)};v.prototype.on=v.prototype.addListener;v.prototype.prependListener=function(t,o){return $(this,t,o,!0)};function le(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,arguments.length===0?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function H(e,t,o){var u={fired:!1,wrapFn:void 0,target:e,type:t,listener:o},a=le.bind(u);return a.listener=o,u.wrapFn=a,a}v.prototype.once=function(t,o){return M(o),this.on(t,H(this,t,o)),this};v.prototype.prependOnceListener=function(t,o){return M(o),this.prependListener(t,H(this,t,o)),this};v.prototype.removeListener=function(t,o){var u,a,l,h,p;if(M(o),a=this._events,a===void 0)return this;if(u=a[t],u===void 0)return this;if(u===o||u.listener===o)--this._eventsCount===0?this._events=Object.create(null):(delete a[t],a.removeListener&&this.emit("removeListener",t,u.listener||o));else if(typeof u!="function"){for(l=-1,h=u.length-1;h>=0;h--)if(u[h]===o||u[h].listener===o){p=u[h].listener,l=h;break}if(l<0)return this;l===0?u.shift():he(u,l),u.length===1&&(a[t]=u[0]),a.removeListener!==void 0&&this.emit("removeListener",t,p||o)}return this};v.prototype.off=v.prototype.removeListener;v.prototype.removeAllListeners=function(t){var o,u,a;if(u=this._events,u===void 0)return this;if(u.removeListener===void 0)return arguments.length===0?(this._events=Object.create(null),this._eventsCount=0):u[t]!==void 0&&(--this._eventsCount===0?this._events=Object.create(null):delete u[t]),this;if(arguments.length===0){var l=Object.keys(u),h;for(a=0;a<l.length;++a)h=l[a],h!=="removeListener"&&this.removeAllListeners(h);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if(o=u[t],typeof o=="function")this.removeListener(t,o);else if(o!==void 0)for(a=o.length-1;a>=0;a--)this.removeListener(t,o[a]);return this};function Q(e,t,o){var u=e._events;if(u===void 0)return[];var a=u[t];return a===void 0?[]:typeof a=="function"?o?[a.listener||a]:[a]:o?de(a):Y(a,a.length)}v.prototype.listeners=function(t){return Q(this,t,!0)};v.prototype.rawListeners=function(t){return Q(this,t,!1)};v.listenerCount=function(e,t){return typeof e.listenerCount=="function"?e.listenerCount(t):X.call(e,t)};v.prototype.listenerCount=X;function X(e){var t=this._events;if(t!==void 0){var o=t[e];if(typeof o=="function")return 1;if(o!==void 0)return o.length}return 0}v.prototype.eventNames=function(){return this._eventsCount>0?I(this._events):[]};function Y(e,t){for(var o=new Array(t),u=0;u<t;++u)o[u]=e[u];return o}function he(e,t){for(;t+1<e.length;t++)e[t]=e[t+1];e.pop()}function de(e){for(var t=new Array(e.length),o=0;o<t.length;++o)t[o]=e[o].listener||e[o];return t}function pe(e,t){return new Promise(function(o,u){function a(h){e.removeListener(t,l),u(h)}function l(){typeof e.removeListener=="function"&&e.removeListener("error",a),o([].slice.call(arguments))}Z(e,t,l,{once:!0}),t!=="error"&&ve(e,a,{once:!0})})}function ve(e,t,o){typeof e.on=="function"&&Z(e,"error",t,o)}function Z(e,t,o,u){if(typeof e.on=="function")u.once?e.once(t,o):e.on(t,o);else if(typeof e.addEventListener=="function")e.addEventListener(t,function a(l){u.once&&e.removeEventListener(t,a),o(l)});else throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof e)}var ye=P.exports;const k=G(ye);var R,ge=new Uint8Array(16);function me(){if(!R&&(R=typeof crypto<"u"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||typeof msCrypto<"u"&&typeof msCrypto.getRandomValues=="function"&&msCrypto.getRandomValues.bind(msCrypto),!R))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return R(ge)}const _e=/^(?:[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;function we(e){return typeof e=="string"&&_e.test(e)}var b=[];for(var D=0;D<256;++D)b.push((D+256).toString(16).substr(1));function be(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,o=(b[e[t+0]]+b[e[t+1]]+b[e[t+2]]+b[e[t+3]]+"-"+b[e[t+4]]+b[e[t+5]]+"-"+b[e[t+6]]+b[e[t+7]]+"-"+b[e[t+8]]+b[e[t+9]]+"-"+b[e[t+10]]+b[e[t+11]]+b[e[t+12]]+b[e[t+13]]+b[e[t+14]]+b[e[t+15]]).toLowerCase();if(!we(o))throw TypeError("Stringified UUID is invalid");return o}function ee(e,t,o){e=e||{};var u=e.random||(e.rng||me)();if(u[6]=u[6]&15|64,u[8]=u[8]&63|128,t){o=o||0;for(var a=0;a<16;++a)t[o+a]=u[a];return t}return be(u)}var Ae=function(e){return atob(e)},te=function(e){return btoa(e)};function Be(e,t){e=e||[],t=t||{};try{return new Blob(e,t)}catch(l){if(l.name!=="TypeError")throw l;for(var o=typeof BlobBuilder<"u"?BlobBuilder:typeof MSBlobBuilder<"u"?MSBlobBuilder:typeof MozBlobBuilder<"u"?MozBlobBuilder:WebKitBlobBuilder,u=new o,a=0;a<e.length;a+=1)u.append(e[a]);return u.getBlob(t.type)}}function Le(e){for(var t=e.length,o=new ArrayBuffer(t),u=new Uint8Array(o),a=0;a<t;a++)u[a]=e.charCodeAt(a);return o}function Se(e,t){return Be([Le(e)],{type:t})}function ct(e,t){return Se(Ae(e),t)}function Ee(e){for(var t="",o=new Uint8Array(e),u=o.byteLength,a=0;a<u;a++)t+=String.fromCharCode(o[a]);return t}function Ce(e,t){var o=new FileReader,u=typeof o.readAsBinaryString=="function";o.onloadend=function(a){var l=a.target.result||"";if(u)return t(l);t(Ee(l))},u?o.readAsBinaryString(e):o.readAsArrayBuffer(e)}function Oe(e,t){Ce(e,function(o){t(o)})}function lt(e,t){Oe(e,function(o){t(te(o))})}function Re(e,t){var o=new FileReader;o.onloadend=function(u){var a=u.target.result||new ArrayBuffer(0);t(a)},o.readAsArrayBuffer(e)}var ne={exports:{}};(function(e,t){(function(o){e.exports=o()})(function(o){var u=["0","1","2","3","4","5","6","7","8","9","a","b","c","d","e","f"];function a(c,f){var r=c[0],n=c[1],s=c[2],i=c[3];r+=(n&s|~n&i)+f[0]-680876936|0,r=(r<<7|r>>>25)+n|0,i+=(r&n|~r&s)+f[1]-389564586|0,i=(i<<12|i>>>20)+r|0,s+=(i&r|~i&n)+f[2]+606105819|0,s=(s<<17|s>>>15)+i|0,n+=(s&i|~s&r)+f[3]-1044525330|0,n=(n<<22|n>>>10)+s|0,r+=(n&s|~n&i)+f[4]-176418897|0,r=(r<<7|r>>>25)+n|0,i+=(r&n|~r&s)+f[5]+1200080426|0,i=(i<<12|i>>>20)+r|0,s+=(i&r|~i&n)+f[6]-1473231341|0,s=(s<<17|s>>>15)+i|0,n+=(s&i|~s&r)+f[7]-45705983|0,n=(n<<22|n>>>10)+s|0,r+=(n&s|~n&i)+f[8]+1770035416|0,r=(r<<7|r>>>25)+n|0,i+=(r&n|~r&s)+f[9]-1958414417|0,i=(i<<12|i>>>20)+r|0,s+=(i&r|~i&n)+f[10]-42063|0,s=(s<<17|s>>>15)+i|0,n+=(s&i|~s&r)+f[11]-1990404162|0,n=(n<<22|n>>>10)+s|0,r+=(n&s|~n&i)+f[12]+1804603682|0,r=(r<<7|r>>>25)+n|0,i+=(r&n|~r&s)+f[13]-40341101|0,i=(i<<12|i>>>20)+r|0,s+=(i&r|~i&n)+f[14]-1502002290|0,s=(s<<17|s>>>15)+i|0,n+=(s&i|~s&r)+f[15]+1236535329|0,n=(n<<22|n>>>10)+s|0,r+=(n&i|s&~i)+f[1]-165796510|0,r=(r<<5|r>>>27)+n|0,i+=(r&s|n&~s)+f[6]-1069501632|0,i=(i<<9|i>>>23)+r|0,s+=(i&n|r&~n)+f[11]+643717713|0,s=(s<<14|s>>>18)+i|0,n+=(s&r|i&~r)+f[0]-373897302|0,n=(n<<20|n>>>12)+s|0,r+=(n&i|s&~i)+f[5]-701558691|0,r=(r<<5|r>>>27)+n|0,i+=(r&s|n&~s)+f[10]+38016083|0,i=(i<<9|i>>>23)+r|0,s+=(i&n|r&~n)+f[15]-660478335|0,s=(s<<14|s>>>18)+i|0,n+=(s&r|i&~r)+f[4]-405537848|0,n=(n<<20|n>>>12)+s|0,r+=(n&i|s&~i)+f[9]+568446438|0,r=(r<<5|r>>>27)+n|0,i+=(r&s|n&~s)+f[14]-1019803690|0,i=(i<<9|i>>>23)+r|0,s+=(i&n|r&~n)+f[3]-187363961|0,s=(s<<14|s>>>18)+i|0,n+=(s&r|i&~r)+f[8]+1163531501|0,n=(n<<20|n>>>12)+s|0,r+=(n&i|s&~i)+f[13]-1444681467|0,r=(r<<5|r>>>27)+n|0,i+=(r&s|n&~s)+f[2]-51403784|0,i=(i<<9|i>>>23)+r|0,s+=(i&n|r&~n)+f[7]+1735328473|0,s=(s<<14|s>>>18)+i|0,n+=(s&r|i&~r)+f[12]-1926607734|0,n=(n<<20|n>>>12)+s|0,r+=(n^s^i)+f[5]-378558|0,r=(r<<4|r>>>28)+n|0,i+=(r^n^s)+f[8]-2022574463|0,i=(i<<11|i>>>21)+r|0,s+=(i^r^n)+f[11]+1839030562|0,s=(s<<16|s>>>16)+i|0,n+=(s^i^r)+f[14]-35309556|0,n=(n<<23|n>>>9)+s|0,r+=(n^s^i)+f[1]-1530992060|0,r=(r<<4|r>>>28)+n|0,i+=(r^n^s)+f[4]+1272893353|0,i=(i<<11|i>>>21)+r|0,s+=(i^r^n)+f[7]-155497632|0,s=(s<<16|s>>>16)+i|0,n+=(s^i^r)+f[10]-1094730640|0,n=(n<<23|n>>>9)+s|0,r+=(n^s^i)+f[13]+681279174|0,r=(r<<4|r>>>28)+n|0,i+=(r^n^s)+f[0]-358537222|0,i=(i<<11|i>>>21)+r|0,s+=(i^r^n)+f[3]-722521979|0,s=(s<<16|s>>>16)+i|0,n+=(s^i^r)+f[6]+76029189|0,n=(n<<23|n>>>9)+s|0,r+=(n^s^i)+f[9]-640364487|0,r=(r<<4|r>>>28)+n|0,i+=(r^n^s)+f[12]-421815835|0,i=(i<<11|i>>>21)+r|0,s+=(i^r^n)+f[15]+530742520|0,s=(s<<16|s>>>16)+i|0,n+=(s^i^r)+f[2]-995338651|0,n=(n<<23|n>>>9)+s|0,r+=(s^(n|~i))+f[0]-198630844|0,r=(r<<6|r>>>26)+n|0,i+=(n^(r|~s))+f[7]+1126891415|0,i=(i<<10|i>>>22)+r|0,s+=(r^(i|~n))+f[14]-1416354905|0,s=(s<<15|s>>>17)+i|0,n+=(i^(s|~r))+f[5]-57434055|0,n=(n<<21|n>>>11)+s|0,r+=(s^(n|~i))+f[12]+1700485571|0,r=(r<<6|r>>>26)+n|0,i+=(n^(r|~s))+f[3]-1894986606|0,i=(i<<10|i>>>22)+r|0,s+=(r^(i|~n))+f[10]-1051523|0,s=(s<<15|s>>>17)+i|0,n+=(i^(s|~r))+f[1]-2054922799|0,n=(n<<21|n>>>11)+s|0,r+=(s^(n|~i))+f[8]+1873313359|0,r=(r<<6|r>>>26)+n|0,i+=(n^(r|~s))+f[15]-30611744|0,i=(i<<10|i>>>22)+r|0,s+=(r^(i|~n))+f[6]-1560198380|0,s=(s<<15|s>>>17)+i|0,n+=(i^(s|~r))+f[13]+1309151649|0,n=(n<<21|n>>>11)+s|0,r+=(s^(n|~i))+f[4]-145523070|0,r=(r<<6|r>>>26)+n|0,i+=(n^(r|~s))+f[11]-1120210379|0,i=(i<<10|i>>>22)+r|0,s+=(r^(i|~n))+f[2]+718787259|0,s=(s<<15|s>>>17)+i|0,n+=(i^(s|~r))+f[9]-343485551|0,n=(n<<21|n>>>11)+s|0,c[0]=r+c[0]|0,c[1]=n+c[1]|0,c[2]=s+c[2]|0,c[3]=i+c[3]|0}function l(c){var f=[],r;for(r=0;r<64;r+=4)f[r>>2]=c.charCodeAt(r)+(c.charCodeAt(r+1)<<8)+(c.charCodeAt(r+2)<<16)+(c.charCodeAt(r+3)<<24);return f}function h(c){var f=[],r;for(r=0;r<64;r+=4)f[r>>2]=c[r]+(c[r+1]<<8)+(c[r+2]<<16)+(c[r+3]<<24);return f}function p(c){var f=c.length,r=[1732584193,-271733879,-1732584194,271733878],n,s,i,g,S,L;for(n=64;n<=f;n+=64)a(r,l(c.substring(n-64,n)));for(c=c.substring(n-64),s=c.length,i=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],n=0;n<s;n+=1)i[n>>2]|=c.charCodeAt(n)<<(n%4<<3);if(i[n>>2]|=128<<(n%4<<3),n>55)for(a(r,i),n=0;n<16;n+=1)i[n]=0;return g=f*8,g=g.toString(16).match(/(.*?)(.{0,8})$/),S=parseInt(g[2],16),L=parseInt(g[1],16)||0,i[14]=S,i[15]=L,a(r,i),r}function m(c){var f=c.length,r=[1732584193,-271733879,-1732584194,271733878],n,s,i,g,S,L;for(n=64;n<=f;n+=64)a(r,h(c.subarray(n-64,n)));for(c=n-64<f?c.subarray(n-64):new Uint8Array(0),s=c.length,i=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],n=0;n<s;n+=1)i[n>>2]|=c[n]<<(n%4<<3);if(i[n>>2]|=128<<(n%4<<3),n>55)for(a(r,i),n=0;n<16;n+=1)i[n]=0;return g=f*8,g=g.toString(16).match(/(.*?)(.{0,8})$/),S=parseInt(g[2],16),L=parseInt(g[1],16)||0,i[14]=S,i[15]=L,a(r,i),r}function A(c){var f="",r;for(r=0;r<4;r+=1)f+=u[c>>r*8+4&15]+u[c>>r*8&15];return f}function w(c){var f;for(f=0;f<c.length;f+=1)c[f]=A(c[f]);return c.join("")}w(p("hello")),typeof ArrayBuffer<"u"&&!ArrayBuffer.prototype.slice&&function(){function c(f,r){return f=f|0||0,f<0?Math.max(f+r,0):Math.min(f,r)}ArrayBuffer.prototype.slice=function(f,r){var n=this.byteLength,s=c(f,n),i=n,g,S,L,q;return r!==o&&(i=c(r,n)),s>i?new ArrayBuffer(0):(g=i-s,S=new ArrayBuffer(g),L=new Uint8Array(S),q=new Uint8Array(this,s,g),L.set(q),S)}}();function E(c){return/[\u0080-\uFFFF]/.test(c)&&(c=unescape(encodeURIComponent(c))),c}function B(c,f){var r=c.length,n=new ArrayBuffer(r),s=new Uint8Array(n),i;for(i=0;i<r;i+=1)s[i]=c.charCodeAt(i);return f?s:n}function C(c){return String.fromCharCode.apply(null,new Uint8Array(c))}function N(c,f,r){var n=new Uint8Array(c.byteLength+f.byteLength);return n.set(new Uint8Array(c)),n.set(new Uint8Array(f),c.byteLength),n}function _(c){var f=[],r=c.length,n;for(n=0;n<r-1;n+=2)f.push(parseInt(c.substr(n,2),16));return String.fromCharCode.apply(String,f)}function d(){this.reset()}return d.prototype.append=function(c){return this.appendBinary(E(c)),this},d.prototype.appendBinary=function(c){this._buff+=c,this._length+=c.length;var f=this._buff.length,r;for(r=64;r<=f;r+=64)a(this._hash,l(this._buff.substring(r-64,r)));return this._buff=this._buff.substring(r-64),this},d.prototype.end=function(c){var f=this._buff,r=f.length,n,s=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],i;for(n=0;n<r;n+=1)s[n>>2]|=f.charCodeAt(n)<<(n%4<<3);return this._finish(s,r),i=w(this._hash),c&&(i=_(i)),this.reset(),i},d.prototype.reset=function(){return this._buff="",this._length=0,this._hash=[1732584193,-271733879,-1732584194,271733878],this},d.prototype.getState=function(){return{buff:this._buff,length:this._length,hash:this._hash.slice()}},d.prototype.setState=function(c){return this._buff=c.buff,this._length=c.length,this._hash=c.hash,this},d.prototype.destroy=function(){delete this._hash,delete this._buff,delete this._length},d.prototype._finish=function(c,f){var r=f,n,s,i;if(c[r>>2]|=128<<(r%4<<3),r>55)for(a(this._hash,c),r=0;r<16;r+=1)c[r]=0;n=this._length*8,n=n.toString(16).match(/(.*?)(.{0,8})$/),s=parseInt(n[2],16),i=parseInt(n[1],16)||0,c[14]=s,c[15]=i,a(this._hash,c)},d.hash=function(c,f){return d.hashBinary(E(c),f)},d.hashBinary=function(c,f){var r=p(c),n=w(r);return f?_(n):n},d.ArrayBuffer=function(){this.reset()},d.ArrayBuffer.prototype.append=function(c){var f=N(this._buff.buffer,c),r=f.length,n;for(this._length+=c.byteLength,n=64;n<=r;n+=64)a(this._hash,h(f.subarray(n-64,n)));return this._buff=n-64<r?new Uint8Array(f.buffer.slice(n-64)):new Uint8Array(0),this},d.ArrayBuffer.prototype.end=function(c){var f=this._buff,r=f.length,n=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],s,i;for(s=0;s<r;s+=1)n[s>>2]|=f[s]<<(s%4<<3);return this._finish(n,r),i=w(this._hash),c&&(i=_(i)),this.reset(),i},d.ArrayBuffer.prototype.reset=function(){return this._buff=new Uint8Array(0),this._length=0,this._hash=[1732584193,-271733879,-1732584194,271733878],this},d.ArrayBuffer.prototype.getState=function(){var c=d.prototype.getState.call(this);return c.buff=C(c.buff),c},d.ArrayBuffer.prototype.setState=function(c){return c.buff=B(c.buff,!0),d.prototype.setState.call(this,c)},d.ArrayBuffer.prototype.destroy=d.prototype.destroy,d.ArrayBuffer.prototype._finish=d.prototype._finish,d.ArrayBuffer.hash=function(c,f){var r=m(new Uint8Array(c)),n=w(r);return f?_(n):n},d})})(ne);var xe=ne.exports;const T=G(xe);var Ie=self.setImmediate||self.setTimeout,Me=32768;function Ne(e){return te(e)}function De(e,t,o,u,a){(o>0||u<t.size)&&(t=t.slice(o,u)),Re(t,function(l){e.append(l),a()})}function Te(e,t,o,u,a){(o>0||u<t.length)&&(t=t.substring(o,u)),e.appendBinary(t),a()}function ht(e,t){var o=typeof e=="string",u=o?e.length:e.size,a=Math.min(Me,u),l=Math.ceil(u/a),h=0,p=o?new T:new T.ArrayBuffer,m=o?Te:De;function A(){Ie(E)}function w(){var B=p.end(!0),C=Ne(B);t(C),p.destroy()}function E(){var B=h*a,C=B+a;h++,h<l?m(p,e,B,C,A):m(p,e,B,C,w)}E()}function Ue(e){return T.hash(e)}function Fe(e){return typeof ArrayBuffer<"u"&&e instanceof ArrayBuffer||typeof Blob<"u"&&e instanceof Blob}function Pe(e){return e instanceof ArrayBuffer?e.slice(0):e.slice(0,e.size,e.type)}var re=Function.prototype.toString,qe=re.call(Object);function je(e){var t=Object.getPrototypeOf(e);if(t===null)return!0;var o=t.constructor;return typeof o=="function"&&o instanceof o&&re.call(o)==qe}function U(e){var t,o,u;if(!e||typeof e!="object")return e;if(Array.isArray(e)){for(t=[],o=0,u=e.length;o<u;o++)t[o]=U(e[o]);return t}if(e instanceof Date&&isFinite(e))return e.toISOString();if(Fe(e))return Pe(e);if(!je(e))return e;t={};for(o in e)if(Object.prototype.hasOwnProperty.call(e,o)){var a=U(e[o]);typeof a<"u"&&(t[o]=a)}return t}function Ve(e){var t=!1;return function(...o){if(t)throw new Error("once called more than once");t=!0,e.apply(this,o)}}function ze(e){return function(...t){t=U(t);var o=this,u=typeof t[t.length-1]=="function"?t.pop():!1,a=new Promise(function(l,h){var p;try{var m=Ve(function(A,w){A?h(A):l(w)});t.push(m),p=e.apply(o,t),p&&typeof p.then=="function"&&l(p)}catch(A){h(A)}});return u&&a.then(function(l){u(null,l)},u),a}}function Ke(e,t,o){if(e.constructor.listeners("debug").length){for(var u=["api",e.name,t],a=0;a<o.length-1;a++)u.push(o[a]);e.constructor.emit("debug",u);var l=o[o.length-1];o[o.length-1]=function(h,p){var m=["api",e.name,t];m=m.concat(h?["error",h]:["success",p]),e.constructor.emit("debug",m),l(h,p)}}}function dt(e,t){return ze(function(...o){if(this._closed)return Promise.reject(new Error("database is closed"));if(this._destroyed)return Promise.reject(new Error("database is destroyed"));var u=this;return Ke(u,e,o),this.taskqueue.isReady?t.apply(this,o):new Promise(function(a,l){u.taskqueue.addTask(function(h){h?l(h):a(u[e].apply(u,o))})})})}function ie(e,t){for(var o={},u=0,a=t.length;u<a;u++){var l=t[u];l in e&&(o[l]=e[l])}return o}var Ge=6;function z(e){return e}function We(e){return[{ok:e}]}function pt(e,t,o){var u=t.docs,a=new Map;u.forEach(function(_){a.has(_.id)?a.get(_.id).push(_):a.set(_.id,[_])});var l=a.size,h=0,p=new Array(l);function m(){var _=[];p.forEach(function(d){d.docs.forEach(function(c){_.push({id:d.id,docs:[c]})})}),o(null,{results:_})}function A(){++h===l&&m()}function w(_,d,c){p[_]={id:d,docs:c},A()}var E=[];a.forEach(function(_,d){E.push(d)});var B=0;function C(){if(!(B>=E.length)){var _=Math.min(B+Ge,E.length),d=E.slice(B,_);N(d,B),B+=d.length}}function N(_,d){_.forEach(function(c,f){var r=d+f,n=a.get(c),s=ie(n[0],["atts_since","attachments"]);s.open_revs=n.map(function(g){return g.rev}),s.open_revs=s.open_revs.filter(z);var i=z;s.open_revs.length===0&&(delete s.open_revs,i=We),["revs","attachments","binary","ajax","latest"].forEach(function(g){g in t&&(s[g]=t[g])}),e.get(c,s,function(g,S){var L;g?L=[{error:g}]:L=i(S),w(r,c,L),C()})})}C()}var F;try{localStorage.setItem("_pouch_check_localstorage",1),F=!!localStorage.getItem("_pouch_check_localstorage")}catch{F=!1}function K(){return F}const Je=typeof queueMicrotask=="function"?queueMicrotask:function(t){Promise.resolve().then(t)};class vt extends k{constructor(){super(),this._listeners={},K()&&addEventListener("storage",t=>{this.emit(t.key)})}addListener(t,o,u,a){if(this._listeners[o])return;var l=!1,h=this;function p(){if(!h._listeners[o])return;if(l){l="waiting";return}l=!0;var m=ie(a,["style","include_docs","attachments","conflicts","filter","doc_ids","view","since","query_params","binary","return_docs"]);function A(){l=!1}u.changes(m).on("change",function(w){w.seq>a.since&&!a.cancelled&&(a.since=w.seq,a.onChange(w))}).on("complete",function(){l==="waiting"&&Je(p),l=!1}).on("error",A)}this._listeners[o]=p,this.on(t,p)}removeListener(t,o){o in this._listeners&&(super.removeListener(t,this._listeners[o]),delete this._listeners[o])}notifyLocalWindows(t){K()&&(localStorage[t]=localStorage[t]==="a"?"b":"a")}notify(t){this.emit(t),this.notifyLocalWindows(t)}}function $e(e){if(typeof console<"u"&&typeof console[e]=="function"){var t=Array.prototype.slice.call(arguments,1);console[e].apply(console,t)}}function He(e,t,o){try{return!e(t,o)}catch(a){var u="Filter function threw: "+a.toString();return x(fe,u)}}function yt(e){var t={},o=e.filter&&typeof e.filter=="function";return t.query=e.query_params,function(a){a.doc||(a.doc={});var l=o&&He(e.filter,a.doc,t);if(typeof l=="object")return l;if(l)return!1;if(!e.include_docs)delete a.doc;else if(!e.attachments)for(var h in a.doc._attachments)Object.prototype.hasOwnProperty.call(a.doc._attachments,h)&&(a.doc._attachments[h].stub=!0);return!0}}function gt(e){var t;if(e?typeof e!="string"?t=x(oe):/^_/.test(e)&&!/^_(design|local)/.test(e)&&(t=x(ae)):t=x(se),t)throw t}function mt(e){return typeof e._remote=="boolean"?e._remote:typeof e.type=="function"?($e("warn","db.type() is deprecated and will be removed in a future version of PouchDB"),e.type()==="http"):!1}function _t(e,t){return"listenerCount"in e?e.listenerCount(t):k.listenerCount(e,t)}function Qe(e){if(!e)return null;var t=e.split("/");return t.length===2?t:t.length===1?[e,e]:null}function wt(e){var t=Qe(e);return t?t.join("/"):null}function bt(e,t){var o=[],u=[];for(var a in t)Object.prototype.hasOwnProperty.call(t,a)&&(o.push(a),u.push(t[a]));return o.push(e),Function.apply(null,o).apply(null,u)}function Xe(e,t,o){return e.get(t).catch(function(u){if(u.status!==404)throw u;return{}}).then(function(u){var a=u._rev,l=o(u);return l?(l._id=t,l._rev=a,Ye(e,l,o)):{updated:!1,rev:a}})}function Ye(e,t,o){return e.put(t).then(function(u){return{updated:!0,rev:u.rev}},function(u){if(u.status!==409)throw u;return Xe(e,t._id,o)})}function At(e,t){if(!t)return ee().replace(/-/g,"").toLowerCase();var o=Object.assign({},e);return delete o._rev_tree,Ue(JSON.stringify(o))}var Bt=ee;export{Ae as A,fe as B,nt as C,it as D,k as E,Oe as F,lt as G,vt as H,at as I,ze as J,st as K,ct as L,et as M,ot as N,Ce as O,yt as P,rt as Q,tt as R,ut as S,Ue as T,ue as U,dt as a,U as b,x as c,$e as d,gt as e,pt as f,ft as g,ie as h,mt as i,Je as j,oe as k,_t as l,ke as m,wt as n,Ve as o,Qe as p,K as q,At as r,bt as s,Be as t,Xe as u,ee as v,Bt as w,Se as x,te as y,ht as z};