@tinacms/search-index
Version:
A network resilient, persistent full-text search library for the browser and Node.js
2 lines • 169 kB
JavaScript
/*! For license information please see search-index-3.5.2.js.LICENSE.txt */
var SearchIndex;(()=>{var t={7478:(t,e,n)=>{const r=n(4986),{BrowserLevel:i}=n(1708);t.exports=({name:t="fii",...e})=>r({db:new i(t),...e})},4986:(t,e,n)=>{const r=n(819),i=n(2001),o=n(7489),s=t=>void 0===t?void 0:t.map((t=>(t._match=t._match.flat(1/0).map((t=>"string"==typeof t?JSON.parse(t):t)).sort(((t,e)=>t.FIELD<e.FIELD?-1:t.FIELD>e.FIELD?1:t.VALUE<e.VALUE?-1:t.VALUE>e.VALUE?1:t.SCORE<e.SCORE?-1:t.SCORE>e.SCORE?1:0)),t))),a=t=>{const e=r(t),n=i(t);return n.TIMESTAMP_CREATED().then((()=>({AGGREGATION_FILTER:e.AGGREGATION_FILTER,AND:(t,n)=>e.INTERSECTION(t,n).then(s),BUCKET:e.BUCKET,BUCKETS:e.BUCKETS,CREATED:e.CREATED,DELETE:n.DELETE,DISTINCT:e.DISTINCT,EXIST:e.EXIST,EXPORT:e.EXPORT,FACETS:e.FACETS,FIELDS:e.FIELDS,GET:(t,n)=>e.GET(t,n).then(s),IMPORT:n.IMPORT,LAST_UPDATED:e.LAST_UPDATED,LEVEL_OPTIONS:o,MAX:e.MAX,MIN:e.MIN,NOT:(...t)=>e.SET_SUBTRACTION(...t).then(s),OBJECT:e.OBJECT,OR:(t,n)=>e.UNION(t,n).then((t=>t.union)).then(s),PUT:n.PUT,SORT:e.SORT,STORE:t._db,TIMESTAMP_LAST_UPDATED:n.TIMESTAMP_LAST_UPDATED,parseToken:e.parseToken})))};t.exports=t=>((t={})=>new Promise(((e,n)=>{const r=(t=Object.assign({caseSensitive:!0,isLeaf:t=>"string"==typeof t||"number"==typeof t,stopwords:[],doNotIndexField:[],storeVectors:!0,docExistsSpace:"DOC"},t)).db;r.open((i=>i?n(i):e(Object.assign(t,{_db:r}))))})))(t).then(a)},7489:(t,e,n)=>{const r=n(2483);t.exports={keyEncoding:r,valueEncoding:"json"}},2983:t=>{const e=null,n=void 0;t.exports=(t,r)=>new Promise(((i,o)=>{if(Array.isArray(t))return o(new Error("token cannot be Array"));if(void 0===t&&(t={}),"string"==typeof t){if(-1===t.indexOf(":"))return i({FIELD:r,VALUE:{GTE:t,LTE:t}});const[e,...n]=t.split(":");return i({FIELD:[e],VALUE:{GTE:n.join(":"),LTE:n.join(":")}})}return"number"==typeof t&&(t={VALUE:{GTE:t,LTE:t}}),null===t.VALUE&&(t.VALUE={GTE:null,LTE:null}),"string"!=typeof t.VALUE&&"number"!=typeof t.VALUE||(t.VALUE={GTE:t.VALUE,LTE:t.VALUE}),void 0!==t.VALUE&&Object.keys(t.VALUE).length||(t.VALUE={GTE:e,LTE:n}),void 0===t.VALUE.GTE&&(t.VALUE.GTE=e),void 0===t.VALUE.LTE&&(t.VALUE.LTE=n),t.VALUE=Object.assign(t.VALUE,{GTE:t.VALUE.GTE,LTE:t.VALUE.LTE}),void 0===t.FIELD?i(Object.assign(t,{FIELD:r})):(t.FIELD=[t.FIELD].flat(),i(t))}))},819:(t,e,n)=>{const r=n(2983),i=n(2483),{EntryStream:o}=n(6741),s=n(7489);i.LO=null,i.HI=void 0,t.exports=t=>{const e=t=>"string"==typeof t,n=async t=>r(t,await l()),a=async(e,r=(t=>new Promise((e=>e(t)))))=>new Promise((async(i,o)=>{const s=t=>void 0===t?i(void 0):t instanceof Promise?i(t):void 0;try{s(e),e=await n(e),e=await(e=>{const n=e=>t.caseSensitive||"string"!=typeof e?e:e.toLowerCase();return{FIELD:e.FIELD.map(n),VALUE:{GTE:n(e.VALUE.GTE),LTE:n(e.VALUE.LTE)}}})(e),e=await(e=>e.VALUE.GTE===e.VALUE.LTE&&t.stopwords.includes(e.VALUE.GTE)?void 0:e)(e),s(e=await(e=>void 0===e?u(void 0):e.VALUE.GTE===e.VALUE.LTE&&t.queryReplace&&t.queryReplace[e.VALUE.GTE]?c(t.queryReplace[e.VALUE.GTE].map((t=>({FIELD:e.FIELD,VALUE:{GTE:t,LTE:t}})))).then((t=>t.union)):e)(e)),s(e=await r(e))}catch(t){return o(t)}return Array.isArray(e)?i(e):i(u(e))})),c=async(t,e)=>Promise.all(t.map((t=>a(t,e)))).then((t=>{const e=t.flat(1/0).reduce(((t,e)=>(e&&t.set(e._id,[...t.get(e._id)||[],e._match]),t)),new Map);return{sumTokensMinusStopwords:t.filter((t=>t)).length,union:Array.from(e.keys()).map((t=>({_id:t,_match:e.get(t)})))}})),h=(t,e,n)=>{const r=[];return void 0===e&&"number"!=typeof e||r.push(e),n&&r.push(i.HI),["IDX",t,r]},u=e=>new Promise((n=>{if(void 0===e)return n(void 0);const r=new Map;return Promise.all(e.FIELD.map((n=>new Promise((i=>new o(t._db,{gte:h(n,e.VALUE.GTE),lte:h(n,e.VALUE.LTE,!0),limit:e.LIMIT,reverse:e.REVERSE,...s}).on("data",(t=>t.value.forEach((e=>r.set(e,[...r.get(e)||[],JSON.stringify({FIELD:t.key[1],VALUE:t.key[2][0],SCORE:t.key[2][1]})]))))).on("end",i)))))).then((()=>n(Array.from(r.keys()).map((t=>({_id:t,_match:r.get(t)}))))))})),l=()=>new Promise((e=>{const n=[];new o(t._db,{gte:["FIELD",i.LO],lte:["FIELD",i.HI],...s}).on("data",(t=>n.push(t.value))).on("end",(()=>e(n)))})),f=(t,e)=>e&&0!==e.length?(e=new Set(e.map((t=>t._id))),t.map((t=>Object.assign(t,{_id:[...new Set([...t._id].filter((t=>e.has(t))))]})))):t,d=async t=>n(t).then((t=>a(t).then((e=>Object.assign(t,{_id:[...e.reduce(((t,e)=>t.add(e._id)),new Set)].sort(),VALUE:t.VALUE}))))),p=e=>new Promise(((n,r)=>{const i=[];new o(t._db,{...e,...s}).on("data",(t=>{i.push(t)})).on("end",(()=>n(i)))})),y=(t,e)=>n(t).then((t=>u(Object.assign(t,{LIMIT:1,REVERSE:e})))).then((t=>t.length?JSON.parse(t.pop()._match.pop()).VALUE:null)),g=t=>n(t).then((t=>Promise.all(t.FIELD.map((e=>{let n=t.VALUE.LTE;void 0!==t.VALUE.LTE&&"number"!=typeof t.VALUE.LTE&&(n+="○");let r=t.VALUE.GTE;return t.VALUE.GTE&&"number"!=typeof t.VALUE.GTE&&(r+=" "),p({gte:h(e,r),lte:h(e,n,!0),keys:!0,values:!1}).then((t=>t.map((({key:t})=>({FIELD:t[1],VALUE:t[2][0]})))))}))))).then((t=>t.flat())),b=t=>n(t).then((t=>Promise.all(t.FIELD.map((e=>p({gte:h(e,t.VALUE.GTE),lte:h(e,t.VALUE.LTE,!0)}).then((t=>t.map((t=>({FIELD:t.key[1],VALUE:t.key[2][0],_id:t.value})))))))))).then((t=>t.flat())),E=new Intl.Collator("en",{numeric:!0,sensitivity:"base"});return{AGGREGATE:({BUCKETS:t,FACETS:e,QUERY:n})=>Promise.all([t,e,n]).then((([t=[],e=[],n=[]])=>({BUCKETS:f(t.flat(),n),FACETS:f(e.flat(),n),RESULT:n}))),AGGREGATION_FILTER:f,BUCKET:d,BUCKETS:(...t)=>Promise.all(t.map(d)),CREATED:()=>t._db.get(["~CREATED"],s),DISTINCT:(...t)=>Promise.all(t.length?t.map(g):[g({})]).then((t=>[...t.flat().reduce(((t,e)=>t.add(JSON.stringify(e))),new Set)].map(JSON.parse))),EXIST:(...e)=>Promise.all(e.map((e=>t._db.get([t.docExistsSpace,e],s).catch((t=>null))))).then((t=>t.reduce(((t,n,r)=>(null!=n&&t.push(e[r]),t)),[]))),EXPORT:p,FACETS:(...t)=>Promise.all(t.length?t.map(b):[b({})]).then((t=>[...t.flat().reduce(((t,e)=>t.add(JSON.stringify(e))),new Set)].map(JSON.parse))),FIELDS:l,GET:a,INTERSECTION:(t,e)=>c(t,e).then((t=>t.union.filter((e=>e._match.length===t.sumTokensMinusStopwords)))),LAST_UPDATED:()=>t._db.get(["~LAST_UPDATED"],s),MAX:t=>y(t,!0),MIN:y,OBJECT:e=>Promise.all(e.map((e=>t._db.get(["DOC",e._id],s).catch((t=>null))))).then((t=>e.map(((e,n)=>(e._object=t[n],e))))),SET_SUBTRACTION:(t,n)=>Promise.all([e(t)?a(t):t,e(n)?a(n):n]).then((([t,e])=>t.filter((t=>-1===e.map((t=>t._id)).indexOf(t._id))))),SORT:t=>new Promise((e=>e(t.sort(((t,e)=>E.compare(t._id,e._id)))))),UNION:c,parseToken:n}}},2001:(t,e,n)=>{const r=n(3692),i=n(819),o=n(7489);t.exports=t=>{let e=0;const n=(e,n)=>{if(null==e._object)return{_id:e._id,keys:[]};const i=[];return r(e._object).forEach((function(e){const r=this.path.filter((t=>!Number.isInteger(+t))).join(".");if("_id"!==r&&!n.doNotIndexField.filter((t=>r.startsWith(t))).length&&t.isLeaf(this.node)){if(!t.stopwords.includes(this.node)){const e=JSON.stringify([r,[this.node].flat(1/0)]);i.push(t.caseSensitive?e:e.toLowerCase())}this.update(this.node,!0)}})),{_id:e._id,keys:i}},s=(t,e)=>(e.keys.forEach((n=>{t[n]=t[n]||[],t[n].push(e._id)})),t),a=(r,a,c,h,u)=>new Promise((l=>{r=r.map((t=>{var n;return t._id=void 0===(n=t._id)?++e:"string"==typeof n||"number"==typeof n?n:void 0,t._object&&(t._object._id=t._id),t})),u=Object.assign(t,u),i(t).EXIST(...r.map((t=>t._id))).then((t=>((t,e,n)=>{const r=Object.keys(t);return Promise.all(r.map((t=>["IDX",...JSON.parse(t)])).map((t=>new Promise(((n,r)=>e.get(t,o).then(n).catch((t=>n([])))))))).then((e=>e.map(((e,i)=>{const o=new Set(e),s=new Set(t[r[i]]);if("put"===n)return{key:["IDX",...JSON.parse(r[i])],type:n,value:[...new Set([...o,...s])].sort()};if("del"===n){const t=[...new Set([...o].filter((t=>!s.has(t))))];return{key:["IDX",...JSON.parse(r[i])],type:0===t.length?"del":"put",value:t}}return e}))))})(((t,e)=>t.map((t=>n(t,e))).reduce(s,{}))(r,u),a,c).then((e=>a.batch(e.concat(u.storeVectors?((t,e)=>t.map((t=>({key:["DOC",t._id],type:e,value:t._object}))))(r,c):[]).concat((t=>[...new Set(t.map((t=>t.key[1].split(":")[0])))].map((t=>({type:"put",key:["FIELD",t],value:t}))))(e)),o,(e=>l(r.map((e=>{let n;return"put"===c?n=t.includes(e._id)?"UPDATED":"CREATED":"del"===c&&(n=null===e._object?"FAILED":"DELETED"),{_id:e._id,operation:h,status:n}})))))))))})),c=e=>t._db.put(["~LAST_UPDATED"],Date.now(),o).then((()=>e));return{DELETE:e=>i(t).OBJECT(e.map((t=>({_id:t})))).then((e=>a(e,t._db,"del","DELETE",{}))).then(c),IMPORT:e=>t._db.clear().then((()=>t._db.batch(e.map((t=>Object.assign(t,{type:"put"}))),o))),PUT:(e,n={})=>a(e.map((t=>({_id:t._id,_object:t}))),t._db,"put","PUT",n).then(c),TIMESTAMP_CREATED:()=>t._db.get(["~CREATED"],o).then().catch((e=>t._db.put(["~CREATED"],Date.now(),o).then(c))),TIMESTAMP_LAST_UPDATED:c}}},9464:(t,e,n)=>{"use strict";const{fromCallback:r}=n(6957),i=n(4473),{getCallback:o,getOptions:s}=n(2520),a=Symbol("promise"),c=Symbol("status"),h=Symbol("operations"),u=Symbol("finishClose"),l=Symbol("closeCallbacks");e.AbstractChainedBatch=class{constructor(t){if("object"!=typeof t||null===t)throw new TypeError("The first argument must be an abstract-level database, received "+(null===t?"null":typeof t));this[h]=[],this[l]=[],this[c]="open",this[u]=this[u].bind(this),this.db=t,this.db.attachResource(this),this.nextTick=t.nextTick}get length(){return this[h].length}put(t,e,n){if("open"!==this[c])throw new i("Batch is not open: cannot call put() after write() or close()",{code:"LEVEL_BATCH_NOT_OPEN"});const r=this.db._checkKey(t)||this.db._checkValue(e);if(r)throw r;const o=n&&null!=n.sublevel?n.sublevel:this.db,s=n,a=o.keyEncoding(n&&n.keyEncoding),u=o.valueEncoding(n&&n.valueEncoding),l=a.format;n={...n,keyEncoding:l,valueEncoding:u.format},o!==this.db&&(n.sublevel=null);const f=o.prefixKey(a.encode(t),l),d=u.encode(e);return this._put(f,d,n),this[h].push({...s,type:"put",key:t,value:e}),this}_put(t,e,n){}del(t,e){if("open"!==this[c])throw new i("Batch is not open: cannot call del() after write() or close()",{code:"LEVEL_BATCH_NOT_OPEN"});const n=this.db._checkKey(t);if(n)throw n;const r=e&&null!=e.sublevel?e.sublevel:this.db,o=e,s=r.keyEncoding(e&&e.keyEncoding),a=s.format;return e={...e,keyEncoding:a},r!==this.db&&(e.sublevel=null),this._del(r.prefixKey(s.encode(t),a),e),this[h].push({...o,type:"del",key:t}),this}_del(t,e){}clear(){if("open"!==this[c])throw new i("Batch is not open: cannot call clear() after write() or close()",{code:"LEVEL_BATCH_NOT_OPEN"});return this._clear(),this[h]=[],this}_clear(){}write(t,e){return e=o(t,e),e=r(e,a),t=s(t),"open"!==this[c]?this.nextTick(e,new i("Batch is not open: cannot call write() after write() or close()",{code:"LEVEL_BATCH_NOT_OPEN"})):0===this.length?this.close(e):(this[c]="writing",this._write(t,(t=>{this[c]="closing",this[l].push((()=>e(t))),t||this.db.emit("batch",this[h]),this._close(this[u])}))),e[a]}_write(t,e){}close(t){return t=r(t,a),"closing"===this[c]?this[l].push(t):"closed"===this[c]?this.nextTick(t):(this[l].push(t),"writing"!==this[c]&&(this[c]="closing",this._close(this[u]))),t[a]}_close(t){this.nextTick(t)}[u](){this[c]="closed",this.db.detachResource(this);const t=this[l];this[l]=[];for(const e of t)e()}}},3961:(t,e,n)=>{"use strict";const{fromCallback:r}=n(6957),i=n(4473),{getOptions:o,getCallback:s}=n(2520),a=Symbol("promise"),c=Symbol("callback"),h=Symbol("working"),u=Symbol("handleOne"),l=Symbol("handleMany"),f=Symbol("autoClose"),d=Symbol("finishWork"),p=Symbol("returnMany"),y=Symbol("closing"),g=Symbol("handleClose"),b=Symbol("closed"),E=Symbol("closeCallbacks"),m=Symbol("keyEncoding"),v=Symbol("valueEncoding"),w=Symbol("abortOnClose"),_=Symbol("legacy"),T=Symbol("keys"),S=Symbol("values"),L=Symbol("limit"),O=Symbol("count"),A=Object.freeze({}),k=()=>{};let x=!1;class R{constructor(t,e,n){if("object"!=typeof t||null===t)throw new TypeError("The first argument must be an abstract-level database, received "+(null===t?"null":typeof t));if("object"!=typeof e||null===e)throw new TypeError("The second argument must be an options object");this[b]=!1,this[E]=[],this[h]=!1,this[y]=!1,this[f]=!1,this[c]=null,this[u]=this[u].bind(this),this[l]=this[l].bind(this),this[g]=this[g].bind(this),this[m]=e[m],this[v]=e[v],this[_]=n,this[L]=Number.isInteger(e.limit)&&e.limit>=0?e.limit:1/0,this[O]=0,this[w]=!!e.abortOnClose,this.db=t,this.db.attachResource(this),this.nextTick=t.nextTick}get count(){return this[O]}get limit(){return this[L]}next(t){let e;if(void 0===t)e=new Promise(((e,n)=>{t=(t,r,i)=>{t?n(t):this[_]?void 0===r&&void 0===i?e():e([r,i]):e(r)}}));else if("function"!=typeof t)throw new TypeError("Callback must be a function");return this[y]?this.nextTick(t,new i("Iterator is not open: cannot call next() after close()",{code:"LEVEL_ITERATOR_NOT_OPEN"})):this[h]?this.nextTick(t,new i("Iterator is busy: cannot call next() until previous call has completed",{code:"LEVEL_ITERATOR_BUSY"})):(this[h]=!0,this[c]=t,this[O]>=this[L]?this.nextTick(this[u],null):this._next(this[u])),e}_next(t){this.nextTick(t)}nextv(t,e,n){return n=s(e,n),n=r(n,a),e=o(e,A),Number.isInteger(t)?(this[y]?this.nextTick(n,new i("Iterator is not open: cannot call nextv() after close()",{code:"LEVEL_ITERATOR_NOT_OPEN"})):this[h]?this.nextTick(n,new i("Iterator is busy: cannot call nextv() until previous call has completed",{code:"LEVEL_ITERATOR_BUSY"})):(t<1&&(t=1),this[L]<1/0&&(t=Math.min(t,this[L]-this[O])),this[h]=!0,this[c]=n,t<=0?this.nextTick(this[l],null,[]):this._nextv(t,e,this[l])),n[a]):(this.nextTick(n,new TypeError("The first argument 'size' must be an integer")),n[a])}_nextv(t,e,n){const r=[],i=(e,o,s)=>e?n(e):(this[_]?void 0===o&&void 0===s:void 0===o)?n(null,r):(r.push(this[_]?[o,s]:o),void(r.length===t?n(null,r):this._next(i)));this._next(i)}all(t,e){return e=s(t,e),e=r(e,a),t=o(t,A),this[y]?this.nextTick(e,new i("Iterator is not open: cannot call all() after close()",{code:"LEVEL_ITERATOR_NOT_OPEN"})):this[h]?this.nextTick(e,new i("Iterator is busy: cannot call all() until previous call has completed",{code:"LEVEL_ITERATOR_BUSY"})):(this[h]=!0,this[c]=e,this[f]=!0,this[O]>=this[L]?this.nextTick(this[l],null,[]):this._all(t,this[l])),e[a]}_all(t,e){let n=this[O];const r=[],i=()=>{const t=this[L]<1/0?Math.min(1e3,this[L]-n):1e3;t<=0?this.nextTick(e,null,r):this._nextv(t,A,o)},o=(t,o)=>{t?e(t):0===o.length?e(null,r):(r.push.apply(r,o),n+=o.length,i())};i()}[d](){const t=this[c];return this[w]&&null===t?k:(this[h]=!1,this[c]=null,this[y]&&this._close(this[g]),t)}[p](t,e,n){this[f]?this.close(t.bind(null,e,n)):t(e,n)}seek(t,e){if(e=o(e,A),this[y]);else{if(this[h])throw new i("Iterator is busy: cannot call seek() until next() has completed",{code:"LEVEL_ITERATOR_BUSY"});{const n=this.db.keyEncoding(e.keyEncoding||this[m]),r=n.format;e.keyEncoding!==r&&(e={...e,keyEncoding:r});const i=this.db.prefixKey(n.encode(t),r);this._seek(i,e)}}}_seek(t,e){throw new i("Iterator does not support seek()",{code:"LEVEL_NOT_SUPPORTED"})}close(t){return t=r(t,a),this[b]?this.nextTick(t):this[y]?this[E].push(t):(this[y]=!0,this[E].push(t),this[h]?this[w]&&this[d]()(new i("Aborted on iterator close()",{code:"LEVEL_ITERATOR_NOT_OPEN"})):this._close(this[g])),t[a]}_close(t){this.nextTick(t)}[g](){this[b]=!0,this.db.detachResource(this);const t=this[E];this[E]=[];for(const e of t)e()}async*[Symbol.asyncIterator](){try{let t;for(;void 0!==(t=await this.next());)yield t}finally{this[b]||await this.close()}}}class I extends R{constructor(t,e){super(t,e,!0),this[T]=!1!==e.keys,this[S]=!1!==e.values}[u](t,e,n){const r=this[d]();if(t)return r(t);try{e=this[T]&&void 0!==e?this[m].decode(e):void 0,n=this[S]&&void 0!==n?this[v].decode(n):void 0}catch(t){return r(new C("entry",t))}void 0===e&&void 0===n||this[O]++,r(null,e,n)}[l](t,e){const n=this[d]();if(t)return this[p](n,t);try{for(const t of e){const e=t[0],n=t[1];t[0]=this[T]&&void 0!==e?this[m].decode(e):void 0,t[1]=this[S]&&void 0!==n?this[v].decode(n):void 0}}catch(t){return this[p](n,new C("entries",t))}this[O]+=e.length,this[p](n,null,e)}end(t){return x||"undefined"==typeof console||(x=!0,console.warn(new i("The iterator.end() method was renamed to close() and end() is an alias that will be removed in a future version",{code:"LEVEL_LEGACY"}))),this.close(t)}}class C extends i{constructor(t,e){super(`Iterator could not decode ${t}`,{code:"LEVEL_DECODE_ERROR",cause:e})}}for(const t of["_ended property","_nexting property","_end method"])Object.defineProperty(I.prototype,t.split(" ")[0],{get(){throw new i(`The ${t} has been removed`,{code:"LEVEL_LEGACY"})},set(){throw new i(`The ${t} has been removed`,{code:"LEVEL_LEGACY"})}});I.keyEncoding=m,I.valueEncoding=v,e.AbstractIterator=I,e.AbstractKeyIterator=class extends R{constructor(t,e){super(t,e,!1)}[u](t,e){const n=this[d]();if(t)return n(t);try{e=void 0!==e?this[m].decode(e):void 0}catch(t){return n(new C("key",t))}void 0!==e&&this[O]++,n(null,e)}[l](t,e){const n=this[d]();if(t)return this[p](n,t);try{for(let t=0;t<e.length;t++){const n=e[t];e[t]=void 0!==n?this[m].decode(n):void 0}}catch(t){return this[p](n,new C("keys",t))}this[O]+=e.length,this[p](n,null,e)}},e.AbstractValueIterator=class extends R{constructor(t,e){super(t,e,!1)}[u](t,e){const n=this[d]();if(t)return n(t);try{e=void 0!==e?this[v].decode(e):void 0}catch(t){return n(new C("value",t))}void 0!==e&&this[O]++,n(null,e)}[l](t,e){const n=this[d]();if(t)return this[p](n,t);try{for(let t=0;t<e.length;t++){const n=e[t];e[t]=void 0!==n?this[v].decode(n):void 0}}catch(t){return this[p](n,new C("values",t))}this[O]+=e.length,this[p](n,null,e)}}},9071:(t,e,n)=>{"use strict";const{supports:r}=n(3658),{Transcoder:i}=n(8499),{EventEmitter:o}=n(7187),{fromCallback:s}=n(6957),a=n(4473),{AbstractIterator:c}=n(3961),{DefaultKeyIterator:h,DefaultValueIterator:u}=n(5429),{DeferredIterator:l,DeferredKeyIterator:f,DeferredValueIterator:d}=n(593),{DefaultChainedBatch:p}=n(4765),{getCallback:y,getOptions:g}=n(2520),b=n(56),E=Symbol("promise"),m=Symbol("landed"),v=Symbol("resources"),w=Symbol("closeResources"),_=Symbol("operations"),T=Symbol("undefer"),S=Symbol("deferOpen"),L=Symbol("options"),O=Symbol("status"),A=Symbol("defaultOptions"),k=Symbol("transcoder"),x=Symbol("keyEncoding"),R=Symbol("valueEncoding"),I=()=>{};class C extends o{constructor(t,e){if(super(),"object"!=typeof t||null===t)throw new TypeError("The first argument 'manifest' must be an object");e=g(e);const{keyEncoding:n,valueEncoding:o,passive:s,...a}=e;this[v]=new Set,this[_]=[],this[S]=!0,this[L]=a,this[O]="opening",this.supports=r(t,{status:!0,promises:!0,clear:!0,getMany:!0,deferredOpen:!0,snapshots:!1!==t.snapshots,permanence:!1!==t.permanence,keyIterator:!0,valueIterator:!0,iteratorNextv:!0,iteratorAll:!0,encodings:t.encodings||{},events:Object.assign({},t.events,{opening:!0,open:!0,closing:!0,closed:!0,put:!0,del:!0,batch:!0,clear:!0})}),this[k]=new i(U(this)),this[x]=this[k].encoding(n||"utf8"),this[R]=this[k].encoding(o||"utf8");for(const t of this[k].encodings())this.supports.encodings[t.commonName]||(this.supports.encodings[t.commonName]=!0);this[A]={empty:Object.freeze({}),entry:Object.freeze({keyEncoding:this[x].commonName,valueEncoding:this[R].commonName}),key:Object.freeze({keyEncoding:this[x].commonName})},this.nextTick((()=>{this[S]&&this.open({passive:!1},I)}))}get status(){return this[O]}keyEncoding(t){return this[k].encoding(null!=t?t:this[x])}valueEncoding(t){return this[k].encoding(null!=t?t:this[R])}open(t,e){e=y(t,e),e=s(e,E),(t={...this[L],...g(t)}).createIfMissing=!1!==t.createIfMissing,t.errorIfExists=!!t.errorIfExists;const n=t=>{"closing"===this[O]||"opening"===this[O]?this.once(m,t?()=>n(t):n):"open"!==this[O]?e(new a("Database is not open",{code:"LEVEL_DATABASE_NOT_OPEN",cause:t})):e()};return t.passive?"opening"===this[O]?this.once(m,n):this.nextTick(n):"closed"===this[O]||this[S]?(this[S]=!1,this[O]="opening",this.emit("opening"),this._open(t,(t=>{if(t)return this[O]="closed",this[w]((()=>{this.emit(m),n(t)})),void this[T]();this[O]="open",this[T](),this.emit(m),"open"===this[O]&&this.emit("open"),"open"===this[O]&&this.emit("ready"),n()}))):"open"===this[O]?this.nextTick(n):this.once(m,(()=>this.open(t,e))),e[E]}_open(t,e){this.nextTick(e)}close(t){t=s(t,E);const e=n=>{"opening"===this[O]||"closing"===this[O]?this.once(m,n?e(n):e):"closed"!==this[O]?t(new a("Database is not closed",{code:"LEVEL_DATABASE_NOT_CLOSED",cause:n})):t()};if("open"===this[O]){this[O]="closing",this.emit("closing");const t=t=>{this[O]="open",this[T](),this.emit(m),e(t)};this[w]((()=>{this._close((n=>{if(n)return t(n);this[O]="closed",this[T](),this.emit(m),"closed"===this[O]&&this.emit("closed"),e()}))}))}else"closed"===this[O]?this.nextTick(e):this.once(m,(()=>this.close(t)));return t[E]}[w](t){if(0===this[v].size)return this.nextTick(t);let e=this[v].size,n=!0;const r=()=>{0==--e&&(n?this.nextTick(t):t())};for(const t of this[v])t.close(r);n=!1,this[v].clear()}_close(t){this.nextTick(t)}get(t,e,n){if(n=y(e,n),n=s(n,E),e=g(e,this[A].entry),"opening"===this[O])return this.defer((()=>this.get(t,e,n))),n[E];if(D(this,n))return n[E];const r=this._checkKey(t);if(r)return this.nextTick(n,r),n[E];const i=this.keyEncoding(e.keyEncoding),o=this.valueEncoding(e.valueEncoding),c=i.format,h=o.format;return e.keyEncoding===c&&e.valueEncoding===h||(e=Object.assign({},e,{keyEncoding:c,valueEncoding:h})),this._get(this.prefixKey(i.encode(t),c),e,((t,e)=>{if(t)return("LEVEL_NOT_FOUND"===t.code||t.notFound||/NotFound/i.test(t))&&(t.code||(t.code="LEVEL_NOT_FOUND"),t.notFound||(t.notFound=!0),t.status||(t.status=404)),n(t);try{e=o.decode(e)}catch(t){return n(new a("Could not decode value",{code:"LEVEL_DECODE_ERROR",cause:t}))}n(null,e)})),n[E]}_get(t,e,n){this.nextTick(n,new Error("NotFound"))}getMany(t,e,n){if(n=y(e,n),n=s(n,E),e=g(e,this[A].entry),"opening"===this[O])return this.defer((()=>this.getMany(t,e,n))),n[E];if(D(this,n))return n[E];if(!Array.isArray(t))return this.nextTick(n,new TypeError("The first argument 'keys' must be an array")),n[E];if(0===t.length)return this.nextTick(n,null,[]),n[E];const r=this.keyEncoding(e.keyEncoding),i=this.valueEncoding(e.valueEncoding),o=r.format,c=i.format;e.keyEncoding===o&&e.valueEncoding===c||(e=Object.assign({},e,{keyEncoding:o,valueEncoding:c}));const h=new Array(t.length);for(let e=0;e<t.length;e++){const i=t[e],s=this._checkKey(i);if(s)return this.nextTick(n,s),n[E];h[e]=this.prefixKey(r.encode(i),o)}return this._getMany(h,e,((t,e)=>{if(t)return n(t);try{for(let t=0;t<e.length;t++)void 0!==e[t]&&(e[t]=i.decode(e[t]))}catch(t){return n(new a(`Could not decode one or more of ${e.length} value(s)`,{code:"LEVEL_DECODE_ERROR",cause:t}))}n(null,e)})),n[E]}_getMany(t,e,n){this.nextTick(n,null,new Array(t.length).fill(void 0))}put(t,e,n,r){if(r=y(n,r),r=s(r,E),n=g(n,this[A].entry),"opening"===this[O])return this.defer((()=>this.put(t,e,n,r))),r[E];if(D(this,r))return r[E];const i=this._checkKey(t)||this._checkValue(e);if(i)return this.nextTick(r,i),r[E];const o=this.keyEncoding(n.keyEncoding),a=this.valueEncoding(n.valueEncoding),c=o.format,h=a.format;n.keyEncoding===c&&n.valueEncoding===h||(n=Object.assign({},n,{keyEncoding:c,valueEncoding:h}));const u=this.prefixKey(o.encode(t),c),l=a.encode(e);return this._put(u,l,n,(n=>{if(n)return r(n);this.emit("put",t,e),r()})),r[E]}_put(t,e,n,r){this.nextTick(r)}del(t,e,n){if(n=y(e,n),n=s(n,E),e=g(e,this[A].key),"opening"===this[O])return this.defer((()=>this.del(t,e,n))),n[E];if(D(this,n))return n[E];const r=this._checkKey(t);if(r)return this.nextTick(n,r),n[E];const i=this.keyEncoding(e.keyEncoding),o=i.format;return e.keyEncoding!==o&&(e=Object.assign({},e,{keyEncoding:o})),this._del(this.prefixKey(i.encode(t),o),e,(e=>{if(e)return n(e);this.emit("del",t),n()})),n[E]}_del(t,e,n){this.nextTick(n)}batch(t,e,n){if(!arguments.length){if("opening"===this[O])return new p(this);if("open"!==this[O])throw new a("Database is not open",{code:"LEVEL_DATABASE_NOT_OPEN"});return this._chainedBatch()}if(n="function"==typeof t?t:y(e,n),n=s(n,E),e=g(e,this[A].empty),"opening"===this[O])return this.defer((()=>this.batch(t,e,n))),n[E];if(D(this,n))return n[E];if(!Array.isArray(t))return this.nextTick(n,new TypeError("The first argument 'operations' must be an array")),n[E];if(0===t.length)return this.nextTick(n),n[E];const r=new Array(t.length),{keyEncoding:i,valueEncoding:o,...c}=e;for(let e=0;e<t.length;e++){if("object"!=typeof t[e]||null===t[e])return this.nextTick(n,new TypeError("A batch operation must be an object")),n[E];const s=Object.assign({},t[e]);if("put"!==s.type&&"del"!==s.type)return this.nextTick(n,new TypeError("A batch operation must have a type property that is 'put' or 'del'")),n[E];const a=this._checkKey(s.key);if(a)return this.nextTick(n,a),n[E];const c=null!=s.sublevel?s.sublevel:this,h=c.keyEncoding(s.keyEncoding||i),u=h.format;if(s.key=c.prefixKey(h.encode(s.key),u),s.keyEncoding=u,"put"===s.type){const t=this._checkValue(s.value);if(t)return this.nextTick(n,t),n[E];const e=c.valueEncoding(s.valueEncoding||o);s.value=e.encode(s.value),s.valueEncoding=e.format}c!==this&&(s.sublevel=null),r[e]=s}return this._batch(r,c,(e=>{if(e)return n(e);this.emit("batch",t),n()})),n[E]}_batch(t,e,n){this.nextTick(n)}sublevel(t,e){return this._sublevel(t,N.defaults(e))}_sublevel(t,e){return new N(this,t,e)}prefixKey(t,e){return t}clear(t,e){if(e=y(t,e),e=s(e,E),t=g(t,this[A].empty),"opening"===this[O])return this.defer((()=>this.clear(t,e))),e[E];if(D(this,e))return e[E];const n=t,r=this.keyEncoding(t.keyEncoding);return(t=b(t,r)).keyEncoding=r.format,0===t.limit?this.nextTick(e):this._clear(t,(t=>{if(t)return e(t);this.emit("clear",n),e()})),e[E]}_clear(t,e){this.nextTick(e)}iterator(t){const e=this.keyEncoding(t&&t.keyEncoding),n=this.valueEncoding(t&&t.valueEncoding);if((t=b(t,e)).keys=!1!==t.keys,t.values=!1!==t.values,t[c.keyEncoding]=e,t[c.valueEncoding]=n,t.keyEncoding=e.format,t.valueEncoding=n.format,"opening"===this[O])return new l(this,t);if("open"!==this[O])throw new a("Database is not open",{code:"LEVEL_DATABASE_NOT_OPEN"});return this._iterator(t)}_iterator(t){return new c(this,t)}keys(t){const e=this.keyEncoding(t&&t.keyEncoding),n=this.valueEncoding(t&&t.valueEncoding);if((t=b(t,e))[c.keyEncoding]=e,t[c.valueEncoding]=n,t.keyEncoding=e.format,t.valueEncoding=n.format,"opening"===this[O])return new f(this,t);if("open"!==this[O])throw new a("Database is not open",{code:"LEVEL_DATABASE_NOT_OPEN"});return this._keys(t)}_keys(t){return new h(this,t)}values(t){const e=this.keyEncoding(t&&t.keyEncoding),n=this.valueEncoding(t&&t.valueEncoding);if((t=b(t,e))[c.keyEncoding]=e,t[c.valueEncoding]=n,t.keyEncoding=e.format,t.valueEncoding=n.format,"opening"===this[O])return new d(this,t);if("open"!==this[O])throw new a("Database is not open",{code:"LEVEL_DATABASE_NOT_OPEN"});return this._values(t)}_values(t){return new u(this,t)}defer(t){if("function"!=typeof t)throw new TypeError("The first argument must be a function");this[_].push(t)}[T](){if(0===this[_].length)return;const t=this[_];this[_]=[];for(const e of t)e()}attachResource(t){if("object"!=typeof t||null===t||"function"!=typeof t.close)throw new TypeError("The first argument must be a resource object");this[v].add(t)}detachResource(t){this[v].delete(t)}_chainedBatch(){return new p(this)}_checkKey(t){if(null==t)return new a("Key cannot be null or undefined",{code:"LEVEL_INVALID_KEY"})}_checkValue(t){if(null==t)return new a("Value cannot be null or undefined",{code:"LEVEL_INVALID_VALUE"})}}C.prototype.nextTick=n(6909);const{AbstractSublevel:N}=n(9650)({AbstractLevel:C});e.AbstractLevel=C,e.AbstractSublevel=N;const D=function(t,e){return"open"!==t[O]&&(t.nextTick(e,new a("Database is not open",{code:"LEVEL_DATABASE_NOT_OPEN"})),!0)},U=function(t){return Object.keys(t.supports.encodings).filter((e=>!!t.supports.encodings[e]))}},875:(t,e,n)=>{"use strict";e.AbstractLevel=n(9071).AbstractLevel,e.AbstractSublevel=n(9071).AbstractSublevel,e.AbstractIterator=n(3961).AbstractIterator,e.AbstractKeyIterator=n(3961).AbstractKeyIterator,e.AbstractValueIterator=n(3961).AbstractValueIterator,e.AbstractChainedBatch=n(9464).AbstractChainedBatch},2970:(t,e,n)=>{"use strict";const{AbstractIterator:r,AbstractKeyIterator:i,AbstractValueIterator:o}=n(3961),s=Symbol("unfix"),a=Symbol("iterator"),c=Symbol("handleOne"),h=Symbol("handleMany"),u=Symbol("callback");class l extends r{constructor(t,e,n,r){super(t,e),this[a]=n,this[s]=r,this[c]=this[c].bind(this),this[h]=this[h].bind(this),this[u]=null}[c](t,e,n){const r=this[u];if(t)return r(t);void 0!==e&&(e=this[s](e)),r(t,e,n)}[h](t,e){const n=this[u];if(t)return n(t);for(const t of e){const e=t[0];void 0!==e&&(t[0]=this[s](e))}n(t,e)}}class f extends i{constructor(t,e,n,r){super(t,e),this[a]=n,this[s]=r,this[c]=this[c].bind(this),this[h]=this[h].bind(this),this[u]=null}[c](t,e){const n=this[u];if(t)return n(t);void 0!==e&&(e=this[s](e)),n(t,e)}[h](t,e){const n=this[u];if(t)return n(t);for(let t=0;t<e.length;t++){const n=e[t];void 0!==n&&(e[t]=this[s](n))}n(t,e)}}class d extends o{constructor(t,e,n){super(t,e),this[a]=n}}for(const t of[l,f])t.prototype._next=function(t){this[u]=t,this[a].next(this[c])},t.prototype._nextv=function(t,e,n){this[u]=n,this[a].nextv(t,e,this[h])},t.prototype._all=function(t,e){this[u]=e,this[a].all(t,this[h])};for(const t of[d])t.prototype._next=function(t){this[a].next(t)},t.prototype._nextv=function(t,e,n){this[a].nextv(t,e,n)},t.prototype._all=function(t,e){this[a].all(t,e)};for(const t of[l,f,d])t.prototype._seek=function(t,e){this[a].seek(t,e)},t.prototype._close=function(t){this[a].close(t)};e.AbstractSublevelIterator=l,e.AbstractSublevelKeyIterator=f,e.AbstractSublevelValueIterator=d},9650:(t,e,n)=>{"use strict";const r=n(4473),{Buffer:i}=n(8764)||{},{AbstractSublevelIterator:o,AbstractSublevelKeyIterator:s,AbstractSublevelValueIterator:a}=n(2970),c=Symbol("prefix"),h=Symbol("upperBound"),u=Symbol("prefixRange"),l=Symbol("parent"),f=Symbol("unfix"),d=new TextEncoder,p={separator:"!"};t.exports=function({AbstractLevel:t}){class e extends t{static defaults(t){if("string"==typeof t)throw new r("The subleveldown string shorthand for { separator } has been removed",{code:"LEVEL_LEGACY"});if(t&&t.open)throw new r("The subleveldown open option has been removed",{code:"LEVEL_LEGACY"});return null==t?p:t.separator?t:{...t,separator:"!"}}constructor(t,n,i){const{separator:o,manifest:s,...a}=e.defaults(i);n=m(n,o);const u=o.charCodeAt(0)+1,p=t[l]||t;if(!d.encode(n).every((t=>t>u&&t<127)))throw new r(`Prefix must use bytes > ${u} < 127`,{code:"LEVEL_INVALID_PREFIX"});super(y(p,s),a);const g=(t.prefix||"")+o+n+o,v=g.slice(0,-1)+String.fromCharCode(u);this[l]=p,this[c]=new b(g),this[h]=new b(v),this[f]=new E,this.nextTick=p.nextTick}prefixKey(t,e){if("utf8"===e)return this[c].utf8+t;if(0===t.byteLength)return this[c][e];if("view"===e){const e=this[c].view,n=new Uint8Array(e.byteLength+t.byteLength);return n.set(e,0),n.set(t,e.byteLength),n}{const e=this[c].buffer;return i.concat([e,t],e.byteLength+t.byteLength)}}[u](t,e){void 0!==t.gte?t.gte=this.prefixKey(t.gte,e):void 0!==t.gt?t.gt=this.prefixKey(t.gt,e):t.gte=this[c][e],void 0!==t.lte?t.lte=this.prefixKey(t.lte,e):void 0!==t.lt?t.lt=this.prefixKey(t.lt,e):t.lte=this[h][e]}get prefix(){return this[c].utf8}get db(){return this[l]}_open(t,e){this[l].open({passive:!0},e)}_put(t,e,n,r){this[l].put(t,e,n,r)}_get(t,e,n){this[l].get(t,e,n)}_getMany(t,e,n){this[l].getMany(t,e,n)}_del(t,e,n){this[l].del(t,e,n)}_batch(t,e,n){this[l].batch(t,e,n)}_clear(t,e){this[u](t,t.keyEncoding),this[l].clear(t,e)}_iterator(t){this[u](t,t.keyEncoding);const e=this[l].iterator(t),n=this[f].get(this[c].utf8.length,t.keyEncoding);return new o(this,t,e,n)}_keys(t){this[u](t,t.keyEncoding);const e=this[l].keys(t),n=this[f].get(this[c].utf8.length,t.keyEncoding);return new s(this,t,e,n)}_values(t){this[u](t,t.keyEncoding);const e=this[l].values(t);return new a(this,t,e)}}return{AbstractSublevel:e}};const y=function(t,e){return{...t.supports,createIfMissing:!1,errorIfExists:!1,events:{},additionalMethods:{},...e,encodings:{utf8:g(t,"utf8"),buffer:g(t,"buffer"),view:g(t,"view")}}},g=function(t,e){return!!t.supports.encodings[e]&&t.keyEncoding(e).name===e};class b{constructor(t){this.utf8=t,this.view=d.encode(t),this.buffer=i?i.from(this.view.buffer,0,this.view.byteLength):{}}}class E{constructor(){this.cache=new Map}get(t,e){let n=this.cache.get(e);return void 0===n&&(n="view"===e?function(t,e){return e.subarray(t)}.bind(null,t):function(t,e){return e.slice(t)}.bind(null,t),this.cache.set(e,n)),n}}const m=function(t,e){let n=0,r=t.length;for(;n<r&&t[n]===e;)n++;for(;r>n&&t[r-1]===e;)r--;return t.slice(n,r)}},2520:(t,e)=>{"use strict";e.getCallback=function(t,e){return"function"==typeof t?t:e},e.getOptions=function(t,e){return"object"==typeof t&&null!==t?t:void 0!==e?e:{}}},4765:(t,e,n)=>{"use strict";const{AbstractChainedBatch:r}=n(9464),i=n(4473),o=Symbol("encoded");e.DefaultChainedBatch=class extends r{constructor(t){super(t),this[o]=[]}_put(t,e,n){this[o].push({...n,type:"put",key:t,value:e})}_del(t,e){this[o].push({...e,type:"del",key:t})}_clear(){this[o]=[]}_write(t,e){"opening"===this.db.status?this.db.defer((()=>this._write(t,e))):"open"===this.db.status?0===this[o].length?this.nextTick(e):this.db._batch(this[o],t,e):this.nextTick(e,new i("Batch is not open: cannot call write() after write() or close()",{code:"LEVEL_BATCH_NOT_OPEN"}))}}},5429:(t,e,n)=>{"use strict";const{AbstractKeyIterator:r,AbstractValueIterator:i}=n(3961),o=Symbol("iterator"),s=Symbol("callback"),a=Symbol("handleOne"),c=Symbol("handleMany");class h extends r{constructor(t,e){super(t,e),this[o]=t.iterator({...e,keys:!0,values:!1}),this[a]=this[a].bind(this),this[c]=this[c].bind(this)}}class u extends i{constructor(t,e){super(t,e),this[o]=t.iterator({...e,keys:!1,values:!0}),this[a]=this[a].bind(this),this[c]=this[c].bind(this)}}for(const t of[h,u]){const e=t===h,n=e?t=>t[0]:t=>t[1];t.prototype._next=function(t){this[s]=t,this[o].next(this[a])},t.prototype[a]=function(t,n,r){const i=this[s];t?i(t):i(null,e?n:r)},t.prototype._nextv=function(t,e,n){this[s]=n,this[o].nextv(t,e,this[c])},t.prototype._all=function(t,e){this[s]=e,this[o].all(t,this[c])},t.prototype[c]=function(t,e){const r=this[s];t?r(t):r(null,e.map(n))},t.prototype._seek=function(t,e){this[o].seek(t,e)},t.prototype._close=function(t){this[o].close(t)}}e.DefaultKeyIterator=h,e.DefaultValueIterator=u},593:(t,e,n)=>{"use strict";const{AbstractIterator:r,AbstractKeyIterator:i,AbstractValueIterator:o}=n(3961),s=n(4473),a=Symbol("nut"),c=Symbol("undefer"),h=Symbol("factory");class u extends r{constructor(t,e){super(t,e),this[a]=null,this[h]=()=>t.iterator(e),this.db.defer((()=>this[c]()))}}class l extends i{constructor(t,e){super(t,e),this[a]=null,this[h]=()=>t.keys(e),this.db.defer((()=>this[c]()))}}class f extends o{constructor(t,e){super(t,e),this[a]=null,this[h]=()=>t.values(e),this.db.defer((()=>this[c]()))}}for(const t of[u,l,f])t.prototype[c]=function(){"open"===this.db.status&&(this[a]=this[h]())},t.prototype._next=function(t){null!==this[a]?this[a].next(t):"opening"===this.db.status?this.db.defer((()=>this._next(t))):this.nextTick(t,new s("Iterator is not open: cannot call next() after close()",{code:"LEVEL_ITERATOR_NOT_OPEN"}))},t.prototype._nextv=function(t,e,n){null!==this[a]?this[a].nextv(t,e,n):"opening"===this.db.status?this.db.defer((()=>this._nextv(t,e,n))):this.nextTick(n,new s("Iterator is not open: cannot call nextv() after close()",{code:"LEVEL_ITERATOR_NOT_OPEN"}))},t.prototype._all=function(t,e){null!==this[a]?this[a].all(e):"opening"===this.db.status?this.db.defer((()=>this._all(t,e))):this.nextTick(e,new s("Iterator is not open: cannot call all() after close()",{code:"LEVEL_ITERATOR_NOT_OPEN"}))},t.prototype._seek=function(t,e){null!==this[a]?this[a]._seek(t,e):"opening"===this.db.status&&this.db.defer((()=>this._seek(t,e)))},t.prototype._close=function(t){null!==this[a]?this[a].close(t):"opening"===this.db.status?this.db.defer((()=>this._close(t))):this.nextTick(t)};e.DeferredIterator=u,e.DeferredKeyIterator=l,e.DeferredValueIterator=f},6909:(t,e,n)=>{"use strict";const r=n(4375);t.exports=function(t,...e){0===e.length?r(t):r((()=>t(...e)))}},56:(t,e,n)=>{"use strict";const r=n(4473),i=Object.prototype.hasOwnProperty,o=new Set(["lt","lte","gt","gte"]);t.exports=function(t,e){const n={};for(const s in t)if(i.call(t,s)&&"keyEncoding"!==s&&"valueEncoding"!==s){if("start"===s||"end"===s)throw new r(`The legacy range option '${s}' has been removed`,{code:"LEVEL_LEGACY"});if("encoding"===s)throw new r("The levelup-style 'encoding' alias has been removed, use 'valueEncoding' instead",{code:"LEVEL_LEGACY"});o.has(s)?n[s]=e.encode(t[s]):n[s]=t[s]}return n.reverse=!!n.reverse,n.limit=Number.isInteger(n.limit)&&n.limit>=0?n.limit:-1,n}},3658:(t,e)=>{"use strict";e.supports=function(...t){const e=t.reduce(((t,e)=>Object.assign(t,e)),{});return Object.assign(e,{snapshots:e.snapshots||!1,permanence:e.permanence||!1,seek:e.seek||!1,clear:e.clear||!1,getMany:e.getMany||!1,keyIterator:e.keyIterator||!1,valueIterator:e.valueIterator||!1,iteratorNextv:e.iteratorNextv||!1,iteratorAll:e.iteratorAll||!1,status:e.status||!1,createIfMissing:e.createIfMissing||!1,errorIfExists:e.errorIfExists||!1,deferredOpen:e.deferredOpen||!1,promises:e.promises||!1,streams:e.streams||!1,encodings:Object.assign({},e.encodings),events:Object.assign({},e.events),additionalMethods:Object.assign({},e.additionalMethods)})}},9742:(t,e)=>{"use strict";e.byteLength=function(t){var e=a(t),n=e[0],r=e[1];return 3*(n+r)/4-r},e.toByteArray=function(t){var e,n,o=a(t),s=o[0],c=o[1],h=new i(function(t,e,n){return 3*(e+n)/4-n}(0,s,c)),u=0,l=c>0?s-4:s;for(n=0;n<l;n+=4)e=r[t.charCodeAt(n)]<<18|r[t.charCodeAt(n+1)]<<12|r[t.charCodeAt(n+2)]<<6|r[t.charCodeAt(n+3)],h[u++]=e>>16&255,h[u++]=e>>8&255,h[u++]=255&e;return 2===c&&(e=r[t.charCodeAt(n)]<<2|r[t.charCodeAt(n+1)]>>4,h[u++]=255&e),1===c&&(e=r[t.charCodeAt(n)]<<10|r[t.charCodeAt(n+1)]<<4|r[t.charCodeAt(n+2)]>>2,h[u++]=e>>8&255,h[u++]=255&e),h},e.fromByteArray=function(t){for(var e,r=t.length,i=r%3,o=[],s=16383,a=0,h=r-i;a<h;a+=s)o.push(c(t,a,a+s>h?h:a+s));return 1===i?(e=t[r-1],o.push(n[e>>2]+n[e<<4&63]+"==")):2===i&&(e=(t[r-2]<<8)+t[r-1],o.push(n[e>>10]+n[e>>4&63]+n[e<<2&63]+"=")),o.join("")};for(var n=[],r=[],i="undefined"!=typeof Uint8Array?Uint8Array:Array,o="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",s=0;s<64;++s)n[s]=o[s],r[o.charCodeAt(s)]=s;function a(t){var e=t.length;if(e%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var n=t.indexOf("=");return-1===n&&(n=e),[n,n===e?0:4-n%4]}function c(t,e,r){for(var i,o,s=[],a=e;a<r;a+=3)i=(t[a]<<16&16711680)+(t[a+1]<<8&65280)+(255&t[a+2]),s.push(n[(o=i)>>18&63]+n[o>>12&63]+n[o>>6&63]+n[63&o]);return s.join("")}r["-".charCodeAt(0)]=62,r["_".charCodeAt(0)]=63},1708:(t,e,n)=>{"use strict";const{AbstractLevel:r}=n(875),i=n(4473),o=n(9967),{fromCallback:s}=n(6957),{Iterator:a}=n(8212),c=n(9687),h=n(9968),u=n(1217),l="level-js-",f=Symbol("idb"),d=Symbol("namePrefix"),p=Symbol("location"),y=Symbol("version"),g=Symbol("store"),b=Symbol("onComplete"),E=Symbol("promise");class m extends r{constructor(t,e,n){if("function"==typeof e||"function"==typeof n)throw new i("The levelup-style callback argument has been removed",{code:"LEVEL_LEGACY"});const{prefix:r,version:o,...s}=e||{};if(super({encodings:{view:!0},snapshots:!1,createIfMissing:!1,errorIfExists:!1,seek:!0},s),"string"!=typeof t)throw new Error("constructor requires a location string argument");this[p]=t,this[d]=null==r?l:r,this[y]=parseInt(o||1,10),this[f]=null}get location(){return this[p]}get namePrefix(){return this[d]}get version(){return this[y]}get db(){return this[f]}get type(){return"browser-level"}_open(t,e){const n=indexedDB.open(this[d]+this[p],this[y]);n.onerror=function(){e(n.error||new Error("unknown error"))},n.onsuccess=()=>{this[f]=n.result,e()},n.onupgradeneeded=t=>{const e=t.target.result;e.objectStoreNames.contains(this[p])||e.createObjectStore(this[p])}}[g](t){return this[f].transaction([this[p]],t).objectStore(this[p])}[b](t,e){const n=t.transaction;n.onabort=function(){e(n.error||new Error("aborted by user"))},n.oncomplete=function(){e(null,t.result)}}_get(t,e,n){const r=this[g]("readonly");let o;try{o=r.get(t)}catch(t){return this.nextTick(n,t)}this[b](o,(function(t,e){return t?n(t):void 0===e?n(new i("Entry not found",{code:"LEVEL_NOT_FOUND"})):void n(null,c(e))}))}_getMany(t,e,n){const r=this[g]("readonly"),i=t.map((t=>e=>{let n;try{n=r.get(t)}catch(t){return e(t)}n.onsuccess=()=>{const t=n.result;e(null,void 0===t?t:c(t))},n.onerror=t=>{t.stopPropagation(),e(n.error)}}));o(i,16,n)}_del(t,e,n){const r=this[g]("readwrite");let i;try{i=r.delete(t)}catch(t){return this.nextTick(n,t)}this[b](i,n)}_put(t,e,n,r){const i=this[g]("readwrite");let o;try{o=i.put(e,t)}catch(t){return this.nextTick(r,t)}this[b](o,r)}_iterator(t){return new a(this,this[p],t)}_batch(t,e,n){const r=this[g]("readwrite"),i=r.transaction;let o,s=0;i.onabort=function(){n(o||i.error||new Error("aborted by user"))},i.oncomplete=function(){n()},function e(){const n=t[s++],a=n.key;let c;try{c="del"===n.type?r.delete(a):r.put(n.value,a)}catch(t){return o=t,void i.abort()}s<t.length?c.onsuccess=e:"function"==typeof i.commit&&i.commit()}()}_clear(t,e){let n,r;try{n=u(t)}catch(t){return this.nextTick(e)}if(t.limit>=0)return h(this,this[p],n,t,e);try{const t=this[g]("readwrite");r=n?t.delete(n):t.clear()}catch(t){return this.nextTick(e,t)}this[b](r,e)}_close(t){this[f].close(),this.nextTick(t)}}m.destroy=function(t,e,n){"function"==typeof e&&(n=e,e=l),n=s(n,E);const r=indexedDB.deleteDatabase(e+t);return r.onsuccess=function(){n()},r.onerror=function(t){n(t)},n[E]},e.BrowserLevel=m},8212:(t,e,n)=>{"use strict";const{AbstractIterator:r}=n(875),i=n(1217),o=n(9687),s=Symbol("cache"),a=Symbol("finished"),c=Symbol("options"),h=Symbol("currentOptions"),u=Symbol("position"),l=Symbol("location"),f=Symbol("first"),d={};function p(t){"function"==typeof t.commit&&t.commit()}e.Iterator=class extends r{constructor(t,e,n){super(t,n),this[s]=[],this[a]=0===this.limit,this[c]=n,this[h]={...n},this[u]=void 0,this[l]=e,this[f]=!0}_nextv(t,e,n){if(this[f]=!1,this[a])return this.nextTick(n,null,[]);if(this[s].length>0)return t=Math.min(t,this[s].length),this.nextTick(n,null,this[s].splice(0,t));let r;void 0!==this[u]&&(this[c].reverse?(this[h].lt=this[u],this[h].lte=void 0):(this[h].gt=this[u],this[h].gte=void 0));try{r=i(this[h])}catch(t){return this[a]=!0,this.nextTick(n,null,[])}const d=this.db.db.transaction([this[l]],"readonly"),y=d.objectStore(this[l]),g=[];if(this[c].reverse)y[!this[c].values&&y.openKeyCursor?"openKeyCursor":"openCursor"](r,"prev").onsuccess=e=>{const n=e.target.result;if(n){const{key:e,value:r}=n;this[u]=e,g.push([this[c].keys&&void 0!==e?o(e):void 0,this[c].values&&void 0!==r?o(r):void 0]),g.length<t?n.continue():p(d)}else this[a]=!0};else{let e,n;const i=()=>{if(void 0===e||void 0===n)return;const r=Math.max(e.length,n.length);0===r||t===1/0?this[a]=!0:this[u]=e[r-1],g.length=r;for(let t=0;t<r;t++){const r=e[t],i=n[t];g[t]=[this[c].keys&&void 0!==r?o(r):void 0,this[c].values&&void 0!==i?o(i):void 0]}p(d)};this[c].keys||t<1/0?y.getAllKeys(r,t<1/0?t:void 0).onsuccess=t=>{e=t.target.result,i()}:(e=[],this.nextTick(i)),this[c].values?y.getAll(r,t<1/0?t:void 0).onsuccess=t=>{n=t.target.result,i()}:(n=[],this.nextTick(i))}d.onabort=()=>{n(d.error||new Error("aborted by user")),n=null},d.oncomplete=()=>{n(null,g),n=null}}_next(t){if(this[s].length>0){const[e,n]=this[s].shift();this.nextTick(t,null,e,n)}else if(this[a])this.nextTick(t);else{let e=Math.min(100,this.limit-this.count);this[f]&&(this[f]=!1,e=1),this._nextv(e,d,((e,n)=>{if(e)return t(e);this[s]=n,this._next(t)}))}}_all(t,e){this[f]=!1;const n=this[s].splice(0,this[s].length),r=this.limit-this.count-n.length;if(r<=0)return this.nextTick(e,null,n);this._nextv(r,d,((t,r)=>{if(t)return e(t);n.length>0&&(r=n.concat(r)),e(null,r)}))}_seek(t,e){let n;this[f]=!0,this[s]=[],this[a]=!1,this[u]=void 0,this[h]={...this[c]};try{n=i(this[c])}catch(t){return void(this[a]=!0)}null===n||n.includes(t)?this[c].reverse?this[h].lte=t:this[h].gte=t:this[a]=!0}}},9968:t=>{"use strict";t.exports=function(t,e,n,r,i){if(0===r.limit)return t.nextTick(i);const o=t.db.transaction([e],"readwrite"),s=o.objectStore(e);let a=0;o.oncomplete=function(){i()},o.onabort=function(){i(o.error||new Error("aborted by user"))};const c=s.openKeyCursor?"openKeyCursor":"openCursor",h=r.reverse?"prev":"next";s[c](n,h).onsuccess=function(t){const e=t.target.result;e&&(s.delete(e.key).onsuccess=function(){(r.limit<=0||++a<r.limit)&&e.continue()})}}},9687:t=>{"use strict";const e=new TextEncoder;t.exports=function(t){return t instanceof Uint8Array?t:t instanceof ArrayBuffer?new Uint8Array(t):e.encode(t)}},1217:t=>{"use strict";t.exports=function(t){const e=void 0!==t.gte?t.gte:void 0!==t.gt?t.gt:void 0,n=void 0!==t.lte?t.lte:void 0!==t.lt?t.lt:void 0,r=void 0===t.gte,i=void 0===t.lte;return void 0!==e&&void 0!==n?IDBKeyRange.bound(e,n,r,i):void 0!==e?IDBKeyRange.lowerBound(e,r):void 0!==n?IDBKeyRange.upperBound(n,i):null}},8764:(t,e,n)=>{"use strict";const r=n(9742),i=n(645),o="function"==typeof Symbol&&"function"==typeof Symbol.for?Symbol.for("nodejs.util.inspect.custom"):null;e.Buffer=c,e.SlowBuffer=function(t){return+t!=t&&(t=0),c.alloc(+t)},e.INSPECT_MAX_BYTES=50;const s=2147483647;function a(t){if(t>s)throw new RangeError('The value "'+t+'" is invalid for option "size"');const e=new Uint8Array(t);return Object.setPrototypeOf(e,c.prototype),e}function c(t,e,n){if("number"==typeof t){if("string"==typeof e)throw new TypeError('The "string" argument must be of type string. Received type number');return l(t)}return h(t,e,n)}function h(t,e,n){if("string"==typeof t)return function(t,e){if("string"==typeof e&&""!==e||(e="utf8"),!c.isEncoding(e))throw new TypeError("Unknown encoding: "+e);const n=0|y(t,e);let r=a(n);const i=r.write(t,e);return i!==n&&(r=r.slice(0,i)),r}(t,e);if(ArrayBuffer.isView(t))return function(t){if(Y(t,Uint8Array)){const e=new Uint8Array(t);return d(e.buffer,e.byteOffset,e.byteLength)}return f(t)}(t);if(null==t)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof t);if(Y(t,ArrayBuffer)||t&&Y(t.buffer,ArrayBuffer))return d(t,e,n);if("undefined"!=typeof SharedArrayBuffer&&(Y(t,SharedArrayBuffer)||t&&Y(t.buffer,SharedArrayBuffer)))return d(t,e,n);if("number"==typeof t)throw new TypeError('The "value" argument must not be of type number. Received type number');const r=t.valueOf&&t.valueOf();if(null!=r&&r!==t)return c.from(r,e,n);const i=function(t){if(c.isBuffer(t)){const e=0|p(t.length),n=a(e);return 0===n.length||t.copy(n,0,0,e),n}return void 0!==t.length?"number"!=typeof t.length||J(t.length)?a(0):f(t):"Buffer"===t.type&&Array.isArray(t.data)?f(t.data):void 0}(t);if(i)return i;if("undefined"!=typeof Symbol&&null!=Symbol.toPrimitive&&"function"==typeof t[Symbol.toPrimitive])return c.from(t[Symbol.toPrimitive]("string"),e,n);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof t)}function u(t){if("number"!=typeof t)throw new TypeError('"size" argument must be of type number');if(t<0)throw new RangeError('The value "'+t+'" is invalid for option "size"')}function l(t){return u(t),a(t<0?0:0|p(t))}function f(t){const e=t.length<0?0:0|p(t.length),n=a(e);for(let r=0;r<e;r+=1)n[r]=255&t[r];return n}function d(t,e,n){if(e<0||t.byteLength<e)throw new RangeError('"offset" is outside of buffer bounds');if(t.byteLength<e+(n||0))throw new RangeError('"length" is outside of buffer bounds');let r;return r=void 0===e&&void 0===n?new Uint8Array(t):void 0===n?new Uint8Array(t,e):new Uint8Array(t,e,n),Object.setPrototypeOf(r,c.prototype),r}function p(t){if(t>=s)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+s.toString(16)+" bytes");return 0|t}function y(t,e){if(c.isBuffer(t))return t.length;if(ArrayBuffer.isView(t)||Y(t,ArrayBuffer))return t.byteLength;if("string"!=typeof t)throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof t);const n=t.length,r=arguments.length>2&&!0===arguments[2];if(!r&&0===n)return 0;let i=!1;for(;;)switch(e){case"ascii":case"latin1":case"binary":return n;case"utf8":case"utf-8":return $(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*n;case"hex":return n>>>1;case"base64":return q(t).length;default:if(i)return r?-1:$(t).length;e=(""+e).toLowerCase(),i=!0}}function g(t,e,n){let r=!1;if((void 0===e||e<0)&&(e=0),e>this.length)return"";if((void 0===n||n>this.length)&&(n=this.length),n<=0)return"";if((n>>>=0)<=(e>>>=0))return"";for(t||(t="utf8");;)switch(t){case"hex":return R(this,e,n);case"utf8":case"utf-8":return O(this,e,n);case"ascii":return k(this,e,n);case"latin1":case"binary":return x(this,e,n);case"base64":return L(this,e,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return I(this,e,n);default:if(r)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),r=!0}}function b(t,e,n){const r=t[e];t[e]=t[n],t[n]=r}function E(t,e,n,r,i){if(0===t.length)return-1;if("string"==typeof n?(r=n,n=0):n>2147483647?n=2147483647:n<-2147483648&&(n=-2147483648),J(n=+n)&&(n=i?0:t.length-1),n<0&&(n=t.length+n),n>=t.length){if(i)return-1;n=t.length-1}else if(n<0){if(!i)return-1;n=0}if("string"==typeof e&&(e=c.from(e,r)),c.isBuffer(e))return 0===e.length?-1:m(t,e,n,r,i);if("number"==typeof e)return e&=255,"function"==typeof Uint8Array.prototype.indexOf?i?Uint8Array.prototype.indexOf.call(t,e,n):Uint8Array.prototype.lastIndexOf.call(t,e,n):m(t,[e],n,r,i);throw new TypeError("val must be string, number or Buffer")}function m(t,e,n,r,i){let o,s=1,a=t.length,c=e.length;if(void 0!==r&&("ucs2"===(r=String(r).toLowerCase())||"ucs-2"===r||"utf16le"===r||"utf-16le"===r)){if(t.length<2||e.length<