datastore-level
Version:
Datastore implementation with level(up|down) backend
2 lines • 112 kB
JavaScript
(function (root, factory) {(typeof module === 'object' && module.exports) ? module.exports = factory() : root.DatastoreLevel = factory()}(typeof self !== 'undefined' ? self : this, function () {
"use strict";var DatastoreLevel=(()=>{var mo=Object.create;var Vt=Object.defineProperty;var go=Object.getOwnPropertyDescriptor;var wo=Object.getOwnPropertyNames;var xo=Object.getPrototypeOf,Eo=Object.prototype.hasOwnProperty;var x=(r,e)=>()=>(e||r((e={exports:{}}).exports,e),e.exports),O=(r,e)=>{for(var t in e)Vt(r,t,{get:e[t],enumerable:!0})},ni=(r,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of wo(e))!Eo.call(r,i)&&i!==t&&Vt(r,i,{get:()=>e[i],enumerable:!(n=go(e,i))||n.enumerable});return r};var bo=(r,e,t)=>(t=r!=null?mo(xo(r)):{},ni(e||!r||!r.__esModule?Vt(t,"default",{value:r,enumerable:!0}):t,r)),vo=r=>ni(Vt({},"__esModule",{value:!0}),r);var Ri=x(Ni=>{"use strict";Ni.supports=function(...e){let t=e.reduce((n,i)=>Object.assign(n,i),{});return Object.assign(t,{snapshots:t.snapshots||!1,permanence:t.permanence||!1,seek:t.seek||!1,clear:t.clear||!1,getMany:t.getMany||!1,keyIterator:t.keyIterator||!1,valueIterator:t.valueIterator||!1,iteratorNextv:t.iteratorNextv||!1,iteratorAll:t.iteratorAll||!1,status:t.status||!1,createIfMissing:t.createIfMissing||!1,errorIfExists:t.errorIfExists||!1,deferredOpen:t.deferredOpen||!1,promises:t.promises||!1,streams:t.streams||!1,encodings:Object.assign({},t.encodings),events:Object.assign({},t.events),additionalMethods:Object.assign({},t.additionalMethods)})}});var G=x((Ul,Ui)=>{"use strict";Ui.exports=class extends Error{constructor(e,t){super(e||""),typeof t=="object"&&t!==null&&(t.code&&(this.code=String(t.code)),t.expected&&(this.expected=!0),t.transient&&(this.transient=!0),t.cause&&(this.cause=t.cause)),Error.captureStackTrace&&Error.captureStackTrace(this,this.constructor)}}});var Pi=x(Xt=>{"use strict";Xt.byteLength=fc;Xt.toByteArray=hc;Xt.fromByteArray=pc;var J=[],$=[],cc=typeof Uint8Array<"u"?Uint8Array:Array,en="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";for(Te=0,Di=en.length;Te<Di;++Te)J[Te]=en[Te],$[en.charCodeAt(Te)]=Te;var Te,Di;$[45]=62;$[95]=63;function Mi(r){var e=r.length;if(e%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var t=r.indexOf("=");t===-1&&(t=e);var n=t===e?0:4-t%4;return[t,n]}function fc(r){var e=Mi(r),t=e[0],n=e[1];return(t+n)*3/4-n}function ac(r,e,t){return(e+t)*3/4-t}function hc(r){var e,t=Mi(r),n=t[0],i=t[1],s=new cc(ac(r,n,i)),o=0,u=i>0?n-4:n,c;for(c=0;c<u;c+=4)e=$[r.charCodeAt(c)]<<18|$[r.charCodeAt(c+1)]<<12|$[r.charCodeAt(c+2)]<<6|$[r.charCodeAt(c+3)],s[o++]=e>>16&255,s[o++]=e>>8&255,s[o++]=e&255;return i===2&&(e=$[r.charCodeAt(c)]<<2|$[r.charCodeAt(c+1)]>>4,s[o++]=e&255),i===1&&(e=$[r.charCodeAt(c)]<<10|$[r.charCodeAt(c+1)]<<4|$[r.charCodeAt(c+2)]>>2,s[o++]=e>>8&255,s[o++]=e&255),s}function lc(r){return J[r>>18&63]+J[r>>12&63]+J[r>>6&63]+J[r&63]}function dc(r,e,t){for(var n,i=[],s=e;s<t;s+=3)n=(r[s]<<16&16711680)+(r[s+1]<<8&65280)+(r[s+2]&255),i.push(lc(n));return i.join("")}function pc(r){for(var e,t=r.length,n=t%3,i=[],s=16383,o=0,u=t-n;o<u;o+=s)i.push(dc(r,o,o+s>u?u:o+s));return n===1?(e=r[t-1],i.push(J[e>>2]+J[e<<4&63]+"==")):n===2&&(e=(r[t-2]<<8)+r[t-1],i.push(J[e>>10]+J[e>>4&63]+J[e<<2&63]+"=")),i.join("")}});var Vi=x(tn=>{tn.read=function(r,e,t,n,i){var s,o,u=i*8-n-1,c=(1<<u)-1,h=c>>1,a=-7,l=t?i-1:0,d=t?-1:1,g=r[e+l];for(l+=d,s=g&(1<<-a)-1,g>>=-a,a+=u;a>0;s=s*256+r[e+l],l+=d,a-=8);for(o=s&(1<<-a)-1,s>>=-a,a+=n;a>0;o=o*256+r[e+l],l+=d,a-=8);if(s===0)s=1-h;else{if(s===c)return o?NaN:(g?-1:1)*(1/0);o=o+Math.pow(2,n),s=s-h}return(g?-1:1)*o*Math.pow(2,s-n)};tn.write=function(r,e,t,n,i,s){var o,u,c,h=s*8-i-1,a=(1<<h)-1,l=a>>1,d=i===23?Math.pow(2,-24)-Math.pow(2,-77):0,g=n?0:s-1,p=n?1:-1,y=e<0||e===0&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(u=isNaN(e)?1:0,o=a):(o=Math.floor(Math.log(e)/Math.LN2),e*(c=Math.pow(2,-o))<1&&(o--,c*=2),o+l>=1?e+=d/c:e+=d*Math.pow(2,1-l),e*c>=2&&(o++,c/=2),o+l>=a?(u=0,o=a):o+l>=1?(u=(e*c-1)*Math.pow(2,i),o=o+l):(u=e*Math.pow(2,l-1)*Math.pow(2,i),o=0));i>=8;r[t+g]=u&255,g+=p,u/=256,i-=8);for(o=o<<i|u,h+=i;h>0;r[t+g]=o&255,g+=p,o/=256,h-=8);r[t+g-p]|=y*128}});var er=x(Ze=>{"use strict";var rn=Pi(),Je=Vi(),$i=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):null;Ze.Buffer=f;Ze.SlowBuffer=Ec;Ze.INSPECT_MAX_BYTES=50;var Zt=2147483647;Ze.kMaxLength=Zt;f.TYPED_ARRAY_SUPPORT=yc();!f.TYPED_ARRAY_SUPPORT&&typeof console<"u"&&typeof console.error=="function"&&console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support.");function yc(){try{let r=new Uint8Array(1),e={foo:function(){return 42}};return Object.setPrototypeOf(e,Uint8Array.prototype),Object.setPrototypeOf(r,e),r.foo()===42}catch{return!1}}Object.defineProperty(f.prototype,"parent",{enumerable:!0,get:function(){if(f.isBuffer(this))return this.buffer}});Object.defineProperty(f.prototype,"offset",{enumerable:!0,get:function(){if(f.isBuffer(this))return this.byteOffset}});function ne(r){if(r>Zt)throw new RangeError('The value "'+r+'" is invalid for option "size"');let e=new Uint8Array(r);return Object.setPrototypeOf(e,f.prototype),e}function f(r,e,t){if(typeof r=="number"){if(typeof e=="string")throw new TypeError('The "string" argument must be of type string. Received type number');return un(r)}return zi(r,e,t)}f.poolSize=8192;function zi(r,e,t){if(typeof r=="string")return gc(r,e);if(ArrayBuffer.isView(r))return wc(r);if(r==null)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof r);if(X(r,ArrayBuffer)||r&&X(r.buffer,ArrayBuffer)||typeof SharedArrayBuffer<"u"&&(X(r,SharedArrayBuffer)||r&&X(r.buffer,SharedArrayBuffer)))return sn(r,e,t);if(typeof r=="number")throw new TypeError('The "value" argument must not be of type number. Received type number');let n=r.valueOf&&r.valueOf();if(n!=null&&n!==r)return f.from(n,e,t);let i=xc(r);if(i)return i;if(typeof Symbol<"u"&&Symbol.toPrimitive!=null&&typeof r[Symbol.toPrimitive]=="function")return f.from(r[Symbol.toPrimitive]("string"),e,t);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof r)}f.from=function(r,e,t){return zi(r,e,t)};Object.setPrototypeOf(f.prototype,Uint8Array.prototype);Object.setPrototypeOf(f,Uint8Array);function Gi(r){if(typeof r!="number")throw new TypeError('"size" argument must be of type number');if(r<0)throw new RangeError('The value "'+r+'" is invalid for option "size"')}function mc(r,e,t){return Gi(r),r<=0?ne(r):e!==void 0?typeof t=="string"?ne(r).fill(e,t):ne(r).fill(e):ne(r)}f.alloc=function(r,e,t){return mc(r,e,t)};function un(r){return Gi(r),ne(r<0?0:cn(r)|0)}f.allocUnsafe=function(r){return un(r)};f.allocUnsafeSlow=function(r){return un(r)};function gc(r,e){if((typeof e!="string"||e==="")&&(e="utf8"),!f.isEncoding(e))throw new TypeError("Unknown encoding: "+e);let t=Wi(r,e)|0,n=ne(t),i=n.write(r,e);return i!==t&&(n=n.slice(0,i)),n}function nn(r){let e=r.length<0?0:cn(r.length)|0,t=ne(e);for(let n=0;n<e;n+=1)t[n]=r[n]&255;return t}function wc(r){if(X(r,Uint8Array)){let e=new Uint8Array(r);return sn(e.buffer,e.byteOffset,e.byteLength)}return nn(r)}function sn(r,e,t){if(e<0||r.byteLength<e)throw new RangeError('"offset" is outside of buffer bounds');if(r.byteLength<e+(t||0))throw new RangeError('"length" is outside of buffer bounds');let n;return e===void 0&&t===void 0?n=new Uint8Array(r):t===void 0?n=new Uint8Array(r,e):n=new Uint8Array(r,e,t),Object.setPrototypeOf(n,f.prototype),n}function xc(r){if(f.isBuffer(r)){let e=cn(r.length)|0,t=ne(e);return t.length===0||r.copy(t,0,0,e),t}if(r.length!==void 0)return typeof r.length!="number"||an(r.length)?ne(0):nn(r);if(r.type==="Buffer"&&Array.isArray(r.data))return nn(r.data)}function cn(r){if(r>=Zt)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+Zt.toString(16)+" bytes");return r|0}function Ec(r){return+r!=r&&(r=0),f.alloc(+r)}f.isBuffer=function(e){return e!=null&&e._isBuffer===!0&&e!==f.prototype};f.compare=function(e,t){if(X(e,Uint8Array)&&(e=f.from(e,e.offset,e.byteLength)),X(t,Uint8Array)&&(t=f.from(t,t.offset,t.byteLength)),!f.isBuffer(e)||!f.isBuffer(t))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(e===t)return 0;let n=e.length,i=t.length;for(let s=0,o=Math.min(n,i);s<o;++s)if(e[s]!==t[s]){n=e[s],i=t[s];break}return n<i?-1:i<n?1:0};f.isEncoding=function(e){switch(String(e).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}};f.concat=function(e,t){if(!Array.isArray(e))throw new TypeError('"list" argument must be an Array of Buffers');if(e.length===0)return f.alloc(0);let n;if(t===void 0)for(t=0,n=0;n<e.length;++n)t+=e[n].length;let i=f.allocUnsafe(t),s=0;for(n=0;n<e.length;++n){let o=e[n];if(X(o,Uint8Array))s+o.length>i.length?(f.isBuffer(o)||(o=f.from(o)),o.copy(i,s)):Uint8Array.prototype.set.call(i,o,s);else if(f.isBuffer(o))o.copy(i,s);else throw new TypeError('"list" argument must be an Array of Buffers');s+=o.length}return i};function Wi(r,e){if(f.isBuffer(r))return r.length;if(ArrayBuffer.isView(r)||X(r,ArrayBuffer))return r.byteLength;if(typeof r!="string")throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof r);let t=r.length,n=arguments.length>2&&arguments[2]===!0;if(!n&&t===0)return 0;let i=!1;for(;;)switch(e){case"ascii":case"latin1":case"binary":return t;case"utf8":case"utf-8":return on(r).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return t*2;case"hex":return t>>>1;case"base64":return rs(r).length;default:if(i)return n?-1:on(r).length;e=(""+e).toLowerCase(),i=!0}}f.byteLength=Wi;function bc(r,e,t){let n=!1;if((e===void 0||e<0)&&(e=0),e>this.length||((t===void 0||t>this.length)&&(t=this.length),t<=0)||(t>>>=0,e>>>=0,t<=e))return"";for(r||(r="utf8");;)switch(r){case"hex":return Lc(this,e,t);case"utf8":case"utf-8":return Yi(this,e,t);case"ascii":return Bc(this,e,t);case"latin1":case"binary":return Fc(this,e,t);case"base64":return Cc(this,e,t);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return Oc(this,e,t);default:if(n)throw new TypeError("Unknown encoding: "+r);r=(r+"").toLowerCase(),n=!0}}f.prototype._isBuffer=!0;function Be(r,e,t){let n=r[e];r[e]=r[t],r[t]=n}f.prototype.swap16=function(){let e=this.length;if(e%2!==0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(let t=0;t<e;t+=2)Be(this,t,t+1);return this};f.prototype.swap32=function(){let e=this.length;if(e%4!==0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(let t=0;t<e;t+=4)Be(this,t,t+3),Be(this,t+1,t+2);return this};f.prototype.swap64=function(){let e=this.length;if(e%8!==0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(let t=0;t<e;t+=8)Be(this,t,t+7),Be(this,t+1,t+6),Be(this,t+2,t+5),Be(this,t+3,t+4);return this};f.prototype.toString=function(){let e=this.length;return e===0?"":arguments.length===0?Yi(this,0,e):bc.apply(this,arguments)};f.prototype.toLocaleString=f.prototype.toString;f.prototype.equals=function(e){if(!f.isBuffer(e))throw new TypeError("Argument must be a Buffer");return this===e?!0:f.compare(this,e)===0};f.prototype.inspect=function(){let e="",t=Ze.INSPECT_MAX_BYTES;return e=this.toString("hex",0,t).replace(/(.{2})/g,"$1 ").trim(),this.length>t&&(e+=" ... "),"<Buffer "+e+">"};$i&&(f.prototype[$i]=f.prototype.inspect);f.prototype.compare=function(e,t,n,i,s){if(X(e,Uint8Array)&&(e=f.from(e,e.offset,e.byteLength)),!f.isBuffer(e))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof e);if(t===void 0&&(t=0),n===void 0&&(n=e?e.length:0),i===void 0&&(i=0),s===void 0&&(s=this.length),t<0||n>e.length||i<0||s>this.length)throw new RangeError("out of range index");if(i>=s&&t>=n)return 0;if(i>=s)return-1;if(t>=n)return 1;if(t>>>=0,n>>>=0,i>>>=0,s>>>=0,this===e)return 0;let o=s-i,u=n-t,c=Math.min(o,u),h=this.slice(i,s),a=e.slice(t,n);for(let l=0;l<c;++l)if(h[l]!==a[l]){o=h[l],u=a[l];break}return o<u?-1:u<o?1:0};function Hi(r,e,t,n,i){if(r.length===0)return-1;if(typeof t=="string"?(n=t,t=0):t>2147483647?t=2147483647:t<-2147483648&&(t=-2147483648),t=+t,an(t)&&(t=i?0:r.length-1),t<0&&(t=r.length+t),t>=r.length){if(i)return-1;t=r.length-1}else if(t<0)if(i)t=0;else return-1;if(typeof e=="string"&&(e=f.from(e,n)),f.isBuffer(e))return e.length===0?-1:Ki(r,e,t,n,i);if(typeof e=="number")return e=e&255,typeof Uint8Array.prototype.indexOf=="function"?i?Uint8Array.prototype.indexOf.call(r,e,t):Uint8Array.prototype.lastIndexOf.call(r,e,t):Ki(r,[e],t,n,i);throw new TypeError("val must be string, number or Buffer")}function Ki(r,e,t,n,i){let s=1,o=r.length,u=e.length;if(n!==void 0&&(n=String(n).toLowerCase(),n==="ucs2"||n==="ucs-2"||n==="utf16le"||n==="utf-16le")){if(r.length<2||e.length<2)return-1;s=2,o/=2,u/=2,t/=2}function c(a,l){return s===1?a[l]:a.readUInt16BE(l*s)}let h;if(i){let a=-1;for(h=t;h<o;h++)if(c(r,h)===c(e,a===-1?0:h-a)){if(a===-1&&(a=h),h-a+1===u)return a*s}else a!==-1&&(h-=h-a),a=-1}else for(t+u>o&&(t=o-u),h=t;h>=0;h--){let a=!0;for(let l=0;l<u;l++)if(c(r,h+l)!==c(e,l)){a=!1;break}if(a)return h}return-1}f.prototype.includes=function(e,t,n){return this.indexOf(e,t,n)!==-1};f.prototype.indexOf=function(e,t,n){return Hi(this,e,t,n,!0)};f.prototype.lastIndexOf=function(e,t,n){return Hi(this,e,t,n,!1)};function vc(r,e,t,n){t=Number(t)||0;let i=r.length-t;n?(n=Number(n),n>i&&(n=i)):n=i;let s=e.length;n>s/2&&(n=s/2);let o;for(o=0;o<n;++o){let u=parseInt(e.substr(o*2,2),16);if(an(u))return o;r[t+o]=u}return o}function Ac(r,e,t,n){return Qt(on(e,r.length-t),r,t,n)}function Sc(r,e,t,n){return Qt(Uc(e),r,t,n)}function _c(r,e,t,n){return Qt(rs(e),r,t,n)}function Ic(r,e,t,n){return Qt(Dc(e,r.length-t),r,t,n)}f.prototype.write=function(e,t,n,i){if(t===void 0)i="utf8",n=this.length,t=0;else if(n===void 0&&typeof t=="string")i=t,n=this.length,t=0;else if(isFinite(t))t=t>>>0,isFinite(n)?(n=n>>>0,i===void 0&&(i="utf8")):(i=n,n=void 0);else throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");let s=this.length-t;if((n===void 0||n>s)&&(n=s),e.length>0&&(n<0||t<0)||t>this.length)throw new RangeError("Attempt to write outside buffer bounds");i||(i="utf8");let o=!1;for(;;)switch(i){case"hex":return vc(this,e,t,n);case"utf8":case"utf-8":return Ac(this,e,t,n);case"ascii":case"latin1":case"binary":return Sc(this,e,t,n);case"base64":return _c(this,e,t,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return Ic(this,e,t,n);default:if(o)throw new TypeError("Unknown encoding: "+i);i=(""+i).toLowerCase(),o=!0}};f.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function Cc(r,e,t){return e===0&&t===r.length?rn.fromByteArray(r):rn.fromByteArray(r.slice(e,t))}function Yi(r,e,t){t=Math.min(r.length,t);let n=[],i=e;for(;i<t;){let s=r[i],o=null,u=s>239?4:s>223?3:s>191?2:1;if(i+u<=t){let c,h,a,l;switch(u){case 1:s<128&&(o=s);break;case 2:c=r[i+1],(c&192)===128&&(l=(s&31)<<6|c&63,l>127&&(o=l));break;case 3:c=r[i+1],h=r[i+2],(c&192)===128&&(h&192)===128&&(l=(s&15)<<12|(c&63)<<6|h&63,l>2047&&(l<55296||l>57343)&&(o=l));break;case 4:c=r[i+1],h=r[i+2],a=r[i+3],(c&192)===128&&(h&192)===128&&(a&192)===128&&(l=(s&15)<<18|(c&63)<<12|(h&63)<<6|a&63,l>65535&&l<1114112&&(o=l))}}o===null?(o=65533,u=1):o>65535&&(o-=65536,n.push(o>>>10&1023|55296),o=56320|o&1023),n.push(o),i+=u}return Tc(n)}var ji=4096;function Tc(r){let e=r.length;if(e<=ji)return String.fromCharCode.apply(String,r);let t="",n=0;for(;n<e;)t+=String.fromCharCode.apply(String,r.slice(n,n+=ji));return t}function Bc(r,e,t){let n="";t=Math.min(r.length,t);for(let i=e;i<t;++i)n+=String.fromCharCode(r[i]&127);return n}function Fc(r,e,t){let n="";t=Math.min(r.length,t);for(let i=e;i<t;++i)n+=String.fromCharCode(r[i]);return n}function Lc(r,e,t){let n=r.length;(!e||e<0)&&(e=0),(!t||t<0||t>n)&&(t=n);let i="";for(let s=e;s<t;++s)i+=Mc[r[s]];return i}function Oc(r,e,t){let n=r.slice(e,t),i="";for(let s=0;s<n.length-1;s+=2)i+=String.fromCharCode(n[s]+n[s+1]*256);return i}f.prototype.slice=function(e,t){let n=this.length;e=~~e,t=t===void 0?n:~~t,e<0?(e+=n,e<0&&(e=0)):e>n&&(e=n),t<0?(t+=n,t<0&&(t=0)):t>n&&(t=n),t<e&&(t=e);let i=this.subarray(e,t);return Object.setPrototypeOf(i,f.prototype),i};function S(r,e,t){if(r%1!==0||r<0)throw new RangeError("offset is not uint");if(r+e>t)throw new RangeError("Trying to access beyond buffer length")}f.prototype.readUintLE=f.prototype.readUIntLE=function(e,t,n){e=e>>>0,t=t>>>0,n||S(e,t,this.length);let i=this[e],s=1,o=0;for(;++o<t&&(s*=256);)i+=this[e+o]*s;return i};f.prototype.readUintBE=f.prototype.readUIntBE=function(e,t,n){e=e>>>0,t=t>>>0,n||S(e,t,this.length);let i=this[e+--t],s=1;for(;t>0&&(s*=256);)i+=this[e+--t]*s;return i};f.prototype.readUint8=f.prototype.readUInt8=function(e,t){return e=e>>>0,t||S(e,1,this.length),this[e]};f.prototype.readUint16LE=f.prototype.readUInt16LE=function(e,t){return e=e>>>0,t||S(e,2,this.length),this[e]|this[e+1]<<8};f.prototype.readUint16BE=f.prototype.readUInt16BE=function(e,t){return e=e>>>0,t||S(e,2,this.length),this[e]<<8|this[e+1]};f.prototype.readUint32LE=f.prototype.readUInt32LE=function(e,t){return e=e>>>0,t||S(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+this[e+3]*16777216};f.prototype.readUint32BE=f.prototype.readUInt32BE=function(e,t){return e=e>>>0,t||S(e,4,this.length),this[e]*16777216+(this[e+1]<<16|this[e+2]<<8|this[e+3])};f.prototype.readBigUInt64LE=de(function(e){e=e>>>0,Xe(e,"offset");let t=this[e],n=this[e+7];(t===void 0||n===void 0)&&xt(e,this.length-8);let i=t+this[++e]*2**8+this[++e]*2**16+this[++e]*2**24,s=this[++e]+this[++e]*2**8+this[++e]*2**16+n*2**24;return BigInt(i)+(BigInt(s)<<BigInt(32))});f.prototype.readBigUInt64BE=de(function(e){e=e>>>0,Xe(e,"offset");let t=this[e],n=this[e+7];(t===void 0||n===void 0)&&xt(e,this.length-8);let i=t*2**24+this[++e]*2**16+this[++e]*2**8+this[++e],s=this[++e]*2**24+this[++e]*2**16+this[++e]*2**8+n;return(BigInt(i)<<BigInt(32))+BigInt(s)});f.prototype.readIntLE=function(e,t,n){e=e>>>0,t=t>>>0,n||S(e,t,this.length);let i=this[e],s=1,o=0;for(;++o<t&&(s*=256);)i+=this[e+o]*s;return s*=128,i>=s&&(i-=Math.pow(2,8*t)),i};f.prototype.readIntBE=function(e,t,n){e=e>>>0,t=t>>>0,n||S(e,t,this.length);let i=t,s=1,o=this[e+--i];for(;i>0&&(s*=256);)o+=this[e+--i]*s;return s*=128,o>=s&&(o-=Math.pow(2,8*t)),o};f.prototype.readInt8=function(e,t){return e=e>>>0,t||S(e,1,this.length),this[e]&128?(255-this[e]+1)*-1:this[e]};f.prototype.readInt16LE=function(e,t){e=e>>>0,t||S(e,2,this.length);let n=this[e]|this[e+1]<<8;return n&32768?n|4294901760:n};f.prototype.readInt16BE=function(e,t){e=e>>>0,t||S(e,2,this.length);let n=this[e+1]|this[e]<<8;return n&32768?n|4294901760:n};f.prototype.readInt32LE=function(e,t){return e=e>>>0,t||S(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24};f.prototype.readInt32BE=function(e,t){return e=e>>>0,t||S(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]};f.prototype.readBigInt64LE=de(function(e){e=e>>>0,Xe(e,"offset");let t=this[e],n=this[e+7];(t===void 0||n===void 0)&&xt(e,this.length-8);let i=this[e+4]+this[e+5]*2**8+this[e+6]*2**16+(n<<24);return(BigInt(i)<<BigInt(32))+BigInt(t+this[++e]*2**8+this[++e]*2**16+this[++e]*2**24)});f.prototype.readBigInt64BE=de(function(e){e=e>>>0,Xe(e,"offset");let t=this[e],n=this[e+7];(t===void 0||n===void 0)&&xt(e,this.length-8);let i=(t<<24)+this[++e]*2**16+this[++e]*2**8+this[++e];return(BigInt(i)<<BigInt(32))+BigInt(this[++e]*2**24+this[++e]*2**16+this[++e]*2**8+n)});f.prototype.readFloatLE=function(e,t){return e=e>>>0,t||S(e,4,this.length),Je.read(this,e,!0,23,4)};f.prototype.readFloatBE=function(e,t){return e=e>>>0,t||S(e,4,this.length),Je.read(this,e,!1,23,4)};f.prototype.readDoubleLE=function(e,t){return e=e>>>0,t||S(e,8,this.length),Je.read(this,e,!0,52,8)};f.prototype.readDoubleBE=function(e,t){return e=e>>>0,t||S(e,8,this.length),Je.read(this,e,!1,52,8)};function B(r,e,t,n,i,s){if(!f.isBuffer(r))throw new TypeError('"buffer" argument must be a Buffer instance');if(e>i||e<s)throw new RangeError('"value" argument is out of bounds');if(t+n>r.length)throw new RangeError("Index out of range")}f.prototype.writeUintLE=f.prototype.writeUIntLE=function(e,t,n,i){if(e=+e,t=t>>>0,n=n>>>0,!i){let u=Math.pow(2,8*n)-1;B(this,e,t,n,u,0)}let s=1,o=0;for(this[t]=e&255;++o<n&&(s*=256);)this[t+o]=e/s&255;return t+n};f.prototype.writeUintBE=f.prototype.writeUIntBE=function(e,t,n,i){if(e=+e,t=t>>>0,n=n>>>0,!i){let u=Math.pow(2,8*n)-1;B(this,e,t,n,u,0)}let s=n-1,o=1;for(this[t+s]=e&255;--s>=0&&(o*=256);)this[t+s]=e/o&255;return t+n};f.prototype.writeUint8=f.prototype.writeUInt8=function(e,t,n){return e=+e,t=t>>>0,n||B(this,e,t,1,255,0),this[t]=e&255,t+1};f.prototype.writeUint16LE=f.prototype.writeUInt16LE=function(e,t,n){return e=+e,t=t>>>0,n||B(this,e,t,2,65535,0),this[t]=e&255,this[t+1]=e>>>8,t+2};f.prototype.writeUint16BE=f.prototype.writeUInt16BE=function(e,t,n){return e=+e,t=t>>>0,n||B(this,e,t,2,65535,0),this[t]=e>>>8,this[t+1]=e&255,t+2};f.prototype.writeUint32LE=f.prototype.writeUInt32LE=function(e,t,n){return e=+e,t=t>>>0,n||B(this,e,t,4,4294967295,0),this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=e&255,t+4};f.prototype.writeUint32BE=f.prototype.writeUInt32BE=function(e,t,n){return e=+e,t=t>>>0,n||B(this,e,t,4,4294967295,0),this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=e&255,t+4};function Ji(r,e,t,n,i){ts(e,n,i,r,t,7);let s=Number(e&BigInt(4294967295));r[t++]=s,s=s>>8,r[t++]=s,s=s>>8,r[t++]=s,s=s>>8,r[t++]=s;let o=Number(e>>BigInt(32)&BigInt(4294967295));return r[t++]=o,o=o>>8,r[t++]=o,o=o>>8,r[t++]=o,o=o>>8,r[t++]=o,t}function Xi(r,e,t,n,i){ts(e,n,i,r,t,7);let s=Number(e&BigInt(4294967295));r[t+7]=s,s=s>>8,r[t+6]=s,s=s>>8,r[t+5]=s,s=s>>8,r[t+4]=s;let o=Number(e>>BigInt(32)&BigInt(4294967295));return r[t+3]=o,o=o>>8,r[t+2]=o,o=o>>8,r[t+1]=o,o=o>>8,r[t]=o,t+8}f.prototype.writeBigUInt64LE=de(function(e,t=0){return Ji(this,e,t,BigInt(0),BigInt("0xffffffffffffffff"))});f.prototype.writeBigUInt64BE=de(function(e,t=0){return Xi(this,e,t,BigInt(0),BigInt("0xffffffffffffffff"))});f.prototype.writeIntLE=function(e,t,n,i){if(e=+e,t=t>>>0,!i){let c=Math.pow(2,8*n-1);B(this,e,t,n,c-1,-c)}let s=0,o=1,u=0;for(this[t]=e&255;++s<n&&(o*=256);)e<0&&u===0&&this[t+s-1]!==0&&(u=1),this[t+s]=(e/o>>0)-u&255;return t+n};f.prototype.writeIntBE=function(e,t,n,i){if(e=+e,t=t>>>0,!i){let c=Math.pow(2,8*n-1);B(this,e,t,n,c-1,-c)}let s=n-1,o=1,u=0;for(this[t+s]=e&255;--s>=0&&(o*=256);)e<0&&u===0&&this[t+s+1]!==0&&(u=1),this[t+s]=(e/o>>0)-u&255;return t+n};f.prototype.writeInt8=function(e,t,n){return e=+e,t=t>>>0,n||B(this,e,t,1,127,-128),e<0&&(e=255+e+1),this[t]=e&255,t+1};f.prototype.writeInt16LE=function(e,t,n){return e=+e,t=t>>>0,n||B(this,e,t,2,32767,-32768),this[t]=e&255,this[t+1]=e>>>8,t+2};f.prototype.writeInt16BE=function(e,t,n){return e=+e,t=t>>>0,n||B(this,e,t,2,32767,-32768),this[t]=e>>>8,this[t+1]=e&255,t+2};f.prototype.writeInt32LE=function(e,t,n){return e=+e,t=t>>>0,n||B(this,e,t,4,2147483647,-2147483648),this[t]=e&255,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24,t+4};f.prototype.writeInt32BE=function(e,t,n){return e=+e,t=t>>>0,n||B(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=e&255,t+4};f.prototype.writeBigInt64LE=de(function(e,t=0){return Ji(this,e,t,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});f.prototype.writeBigInt64BE=de(function(e,t=0){return Xi(this,e,t,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});function Zi(r,e,t,n,i,s){if(t+n>r.length)throw new RangeError("Index out of range");if(t<0)throw new RangeError("Index out of range")}function Qi(r,e,t,n,i){return e=+e,t=t>>>0,i||Zi(r,e,t,4,34028234663852886e22,-34028234663852886e22),Je.write(r,e,t,n,23,4),t+4}f.prototype.writeFloatLE=function(e,t,n){return Qi(this,e,t,!0,n)};f.prototype.writeFloatBE=function(e,t,n){return Qi(this,e,t,!1,n)};function es(r,e,t,n,i){return e=+e,t=t>>>0,i||Zi(r,e,t,8,17976931348623157e292,-17976931348623157e292),Je.write(r,e,t,n,52,8),t+8}f.prototype.writeDoubleLE=function(e,t,n){return es(this,e,t,!0,n)};f.prototype.writeDoubleBE=function(e,t,n){return es(this,e,t,!1,n)};f.prototype.copy=function(e,t,n,i){if(!f.isBuffer(e))throw new TypeError("argument should be a Buffer");if(n||(n=0),!i&&i!==0&&(i=this.length),t>=e.length&&(t=e.length),t||(t=0),i>0&&i<n&&(i=n),i===n||e.length===0||this.length===0)return 0;if(t<0)throw new RangeError("targetStart out of bounds");if(n<0||n>=this.length)throw new RangeError("Index out of range");if(i<0)throw new RangeError("sourceEnd out of bounds");i>this.length&&(i=this.length),e.length-t<i-n&&(i=e.length-t+n);let s=i-n;return this===e&&typeof Uint8Array.prototype.copyWithin=="function"?this.copyWithin(t,n,i):Uint8Array.prototype.set.call(e,this.subarray(n,i),t),s};f.prototype.fill=function(e,t,n,i){if(typeof e=="string"){if(typeof t=="string"?(i=t,t=0,n=this.length):typeof n=="string"&&(i=n,n=this.length),i!==void 0&&typeof i!="string")throw new TypeError("encoding must be a string");if(typeof i=="string"&&!f.isEncoding(i))throw new TypeError("Unknown encoding: "+i);if(e.length===1){let o=e.charCodeAt(0);(i==="utf8"&&o<128||i==="latin1")&&(e=o)}}else typeof e=="number"?e=e&255:typeof e=="boolean"&&(e=Number(e));if(t<0||this.length<t||this.length<n)throw new RangeError("Out of range index");if(n<=t)return this;t=t>>>0,n=n===void 0?this.length:n>>>0,e||(e=0);let s;if(typeof e=="number")for(s=t;s<n;++s)this[s]=e;else{let o=f.isBuffer(e)?e:f.from(e,i),u=o.length;if(u===0)throw new TypeError('The value "'+e+'" is invalid for argument "value"');for(s=0;s<n-t;++s)this[s+t]=o[s%u]}return this};var Ye={};function fn(r,e,t){Ye[r]=class extends t{constructor(){super(),Object.defineProperty(this,"message",{value:e.apply(this,arguments),writable:!0,configurable:!0}),this.name=`${this.name} [${r}]`,this.stack,delete this.name}get code(){return r}set code(i){Object.defineProperty(this,"code",{configurable:!0,enumerable:!0,value:i,writable:!0})}toString(){return`${this.name} [${r}]: ${this.message}`}}}fn("ERR_BUFFER_OUT_OF_BOUNDS",function(r){return r?`${r} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"},RangeError);fn("ERR_INVALID_ARG_TYPE",function(r,e){return`The "${r}" argument must be of type number. Received type ${typeof e}`},TypeError);fn("ERR_OUT_OF_RANGE",function(r,e,t){let n=`The value of "${r}" is out of range.`,i=t;return Number.isInteger(t)&&Math.abs(t)>2**32?i=qi(String(t)):typeof t=="bigint"&&(i=String(t),(t>BigInt(2)**BigInt(32)||t<-(BigInt(2)**BigInt(32)))&&(i=qi(i)),i+="n"),n+=` It must be ${e}. Received ${i}`,n},RangeError);function qi(r){let e="",t=r.length,n=r[0]==="-"?1:0;for(;t>=n+4;t-=3)e=`_${r.slice(t-3,t)}${e}`;return`${r.slice(0,t)}${e}`}function kc(r,e,t){Xe(e,"offset"),(r[e]===void 0||r[e+t]===void 0)&&xt(e,r.length-(t+1))}function ts(r,e,t,n,i,s){if(r>t||r<e){let o=typeof e=="bigint"?"n":"",u;throw s>3?e===0||e===BigInt(0)?u=`>= 0${o} and < 2${o} ** ${(s+1)*8}${o}`:u=`>= -(2${o} ** ${(s+1)*8-1}${o}) and < 2 ** ${(s+1)*8-1}${o}`:u=`>= ${e}${o} and <= ${t}${o}`,new Ye.ERR_OUT_OF_RANGE("value",u,r)}kc(n,i,s)}function Xe(r,e){if(typeof r!="number")throw new Ye.ERR_INVALID_ARG_TYPE(e,"number",r)}function xt(r,e,t){throw Math.floor(r)!==r?(Xe(r,t),new Ye.ERR_OUT_OF_RANGE(t||"offset","an integer",r)):e<0?new Ye.ERR_BUFFER_OUT_OF_BOUNDS:new Ye.ERR_OUT_OF_RANGE(t||"offset",`>= ${t?1:0} and <= ${e}`,r)}var Nc=/[^+/0-9A-Za-z-_]/g;function Rc(r){if(r=r.split("=")[0],r=r.trim().replace(Nc,""),r.length<2)return"";for(;r.length%4!==0;)r=r+"=";return r}function on(r,e){e=e||1/0;let t,n=r.length,i=null,s=[];for(let o=0;o<n;++o){if(t=r.charCodeAt(o),t>55295&&t<57344){if(!i){if(t>56319){(e-=3)>-1&&s.push(239,191,189);continue}else if(o+1===n){(e-=3)>-1&&s.push(239,191,189);continue}i=t;continue}if(t<56320){(e-=3)>-1&&s.push(239,191,189),i=t;continue}t=(i-55296<<10|t-56320)+65536}else i&&(e-=3)>-1&&s.push(239,191,189);if(i=null,t<128){if((e-=1)<0)break;s.push(t)}else if(t<2048){if((e-=2)<0)break;s.push(t>>6|192,t&63|128)}else if(t<65536){if((e-=3)<0)break;s.push(t>>12|224,t>>6&63|128,t&63|128)}else if(t<1114112){if((e-=4)<0)break;s.push(t>>18|240,t>>12&63|128,t>>6&63|128,t&63|128)}else throw new Error("Invalid code point")}return s}function Uc(r){let e=[];for(let t=0;t<r.length;++t)e.push(r.charCodeAt(t)&255);return e}function Dc(r,e){let t,n,i,s=[];for(let o=0;o<r.length&&!((e-=2)<0);++o)t=r.charCodeAt(o),n=t>>8,i=t%256,s.push(i),s.push(n);return s}function rs(r){return rn.toByteArray(Rc(r))}function Qt(r,e,t,n){let i;for(i=0;i<n&&!(i+t>=e.length||i>=r.length);++i)e[i+t]=r[i];return i}function X(r,e){return r instanceof e||r!=null&&r.constructor!=null&&r.constructor.name!=null&&r.constructor.name===e.name}function an(r){return r!==r}var Mc=function(){let r="0123456789abcdef",e=new Array(256);for(let t=0;t<16;++t){let n=t*16;for(let i=0;i<16;++i)e[n+i]=r[t]+r[i]}return e}();function de(r){return typeof BigInt>"u"?Pc:r}function Pc(){throw new Error("BigInt not supported")}});var ln=x(($l,ns)=>{"use strict";var hn=null;ns.exports=function(){return hn===null&&(hn={textEncoder:new TextEncoder,textDecoder:new TextDecoder}),hn}});var yn=x(is=>{"use strict";var dn=G(),Vc=new Set(["buffer","view","utf8"]),pn=class{constructor(e){if(this.encode=e.encode||this.encode,this.decode=e.decode||this.decode,this.name=e.name||this.name,this.format=e.format||this.format,typeof this.encode!="function")throw new TypeError("The 'encode' property must be a function");if(typeof this.decode!="function")throw new TypeError("The 'decode' property must be a function");if(this.encode=this.encode.bind(this),this.decode=this.decode.bind(this),typeof this.name!="string"||this.name==="")throw new TypeError("The 'name' property must be a string");if(typeof this.format!="string"||!Vc.has(this.format))throw new TypeError("The 'format' property must be one of 'buffer', 'view', 'utf8'");e.createViewTranscoder&&(this.createViewTranscoder=e.createViewTranscoder),e.createBufferTranscoder&&(this.createBufferTranscoder=e.createBufferTranscoder),e.createUTF8Transcoder&&(this.createUTF8Transcoder=e.createUTF8Transcoder)}get commonName(){return this.name.split("+")[0]}createBufferTranscoder(){throw new dn(`Encoding '${this.name}' cannot be transcoded to 'buffer'`,{code:"LEVEL_ENCODING_NOT_SUPPORTED"})}createViewTranscoder(){throw new dn(`Encoding '${this.name}' cannot be transcoded to 'view'`,{code:"LEVEL_ENCODING_NOT_SUPPORTED"})}createUTF8Transcoder(){throw new dn(`Encoding '${this.name}' cannot be transcoded to 'utf8'`,{code:"LEVEL_ENCODING_NOT_SUPPORTED"})}};is.Encoding=pn});var xn=x(tr=>{"use strict";var{Buffer:gn}=er()||{},{Encoding:wn}=yn(),$c=ln(),Et=class extends wn{constructor(e){super({...e,format:"buffer"})}createViewTranscoder(){return new bt({encode:this.encode,decode:e=>this.decode(gn.from(e.buffer,e.byteOffset,e.byteLength)),name:`${this.name}+view`})}createBufferTranscoder(){return this}},bt=class extends wn{constructor(e){super({...e,format:"view"})}createBufferTranscoder(){return new Et({encode:e=>{let t=this.encode(e);return gn.from(t.buffer,t.byteOffset,t.byteLength)},decode:this.decode,name:`${this.name}+buffer`})}createViewTranscoder(){return this}},mn=class extends wn{constructor(e){super({...e,format:"utf8"})}createBufferTranscoder(){return new Et({encode:e=>gn.from(this.encode(e),"utf8"),decode:e=>this.decode(e.toString("utf8")),name:`${this.name}+buffer`})}createViewTranscoder(){let{textEncoder:e,textDecoder:t}=$c();return new bt({encode:n=>e.encode(this.encode(n)),decode:n=>this.decode(t.decode(n)),name:`${this.name}+view`})}createUTF8Transcoder(){return this}};tr.BufferFormat=Et;tr.ViewFormat=bt;tr.UTF8Format=mn});var cs=x(Fe=>{"use strict";var{Buffer:I}=er()||{Buffer:{isBuffer:()=>!1}},{textEncoder:os,textDecoder:ss}=ln()(),{BufferFormat:vt,ViewFormat:En,UTF8Format:us}=xn(),rr=r=>r;Fe.utf8=new us({encode:function(r){return I.isBuffer(r)?r.toString("utf8"):ArrayBuffer.isView(r)?ss.decode(r):String(r)},decode:rr,name:"utf8",createViewTranscoder(){return new En({encode:function(r){return ArrayBuffer.isView(r)?r:os.encode(r)},decode:function(r){return ss.decode(r)},name:`${this.name}+view`})},createBufferTranscoder(){return new vt({encode:function(r){return I.isBuffer(r)?r:ArrayBuffer.isView(r)?I.from(r.buffer,r.byteOffset,r.byteLength):I.from(String(r),"utf8")},decode:function(r){return r.toString("utf8")},name:`${this.name}+buffer`})}});Fe.json=new us({encode:JSON.stringify,decode:JSON.parse,name:"json"});Fe.buffer=new vt({encode:function(r){return I.isBuffer(r)?r:ArrayBuffer.isView(r)?I.from(r.buffer,r.byteOffset,r.byteLength):I.from(String(r),"utf8")},decode:rr,name:"buffer",createViewTranscoder(){return new En({encode:function(r){return ArrayBuffer.isView(r)?r:I.from(String(r),"utf8")},decode:function(r){return I.from(r.buffer,r.byteOffset,r.byteLength)},name:`${this.name}+view`})}});Fe.view=new En({encode:function(r){return ArrayBuffer.isView(r)?r:os.encode(r)},decode:rr,name:"view",createBufferTranscoder(){return new vt({encode:function(r){return I.isBuffer(r)?r:ArrayBuffer.isView(r)?I.from(r.buffer,r.byteOffset,r.byteLength):I.from(String(r),"utf8")},decode:rr,name:`${this.name}+buffer`})}});Fe.hex=new vt({encode:function(r){return I.isBuffer(r)?r:I.from(String(r),"hex")},decode:function(r){return r.toString("hex")},name:"hex"});Fe.base64=new vt({encode:function(r){return I.isBuffer(r)?r:I.from(String(r),"base64")},decode:function(r){return r.toString("base64")},name:"base64"})});var hs=x(as=>{"use strict";var fs=G(),ir=cs(),{Encoding:Kc}=yn(),{BufferFormat:jc,ViewFormat:qc,UTF8Format:zc}=xn(),At=Symbol("formats"),nr=Symbol("encodings"),Gc=new Set(["buffer","view","utf8"]),bn=class{constructor(e){if(Array.isArray(e)){if(!e.every(t=>Gc.has(t)))throw new TypeError("Format must be one of 'buffer', 'view', 'utf8'")}else throw new TypeError("The first argument 'formats' must be an array");this[nr]=new Map,this[At]=new Set(e);for(let t in ir)try{this.encoding(t)}catch(n){if(n.code!=="LEVEL_ENCODING_NOT_SUPPORTED")throw n}}encodings(){return Array.from(new Set(this[nr].values()))}encoding(e){let t=this[nr].get(e);if(t===void 0){if(typeof e=="string"&&e!==""){if(t=Jc[e],!t)throw new fs(`Encoding '${e}' is not found`,{code:"LEVEL_ENCODING_NOT_FOUND"})}else{if(typeof e!="object"||e===null)throw new TypeError("First argument 'encoding' must be a string or object");t=Wc(e)}let{name:n,format:i}=t;if(!this[At].has(i))if(this[At].has("view"))t=t.createViewTranscoder();else if(this[At].has("buffer"))t=t.createBufferTranscoder();else if(this[At].has("utf8"))t=t.createUTF8Transcoder();else throw new fs(`Encoding '${n}' cannot be transcoded`,{code:"LEVEL_ENCODING_NOT_SUPPORTED"});for(let s of[e,n,t.name,t.commonName])this[nr].set(s,t)}return t}};as.Transcoder=bn;function Wc(r){if(r instanceof Kc)return r;let e="type"in r&&typeof r.type=="string"?r.type:void 0,t=r.name||e||`anonymous-${Xc++}`;switch(Hc(r)){case"view":return new qc({...r,name:t});case"utf8":return new zc({...r,name:t});case"buffer":return new jc({...r,name:t});default:throw new TypeError("Format must be one of 'buffer', 'view', 'utf8'")}}function Hc(r){return"format"in r&&r.format!==void 0?r.format:"buffer"in r&&typeof r.buffer=="boolean"?r.buffer?"buffer":"utf8":"code"in r&&Number.isInteger(r.code)?"view":"buffer"}var Yc={binary:ir.buffer,"utf-8":ir.utf8},Jc={...ir,...Yc},Xc=0});var vs=x((Gl,vn)=>{"use strict";var Qe=typeof Reflect=="object"?Reflect:null,ls=Qe&&typeof Qe.apply=="function"?Qe.apply:function(e,t,n){return Function.prototype.apply.call(e,t,n)},sr;Qe&&typeof Qe.ownKeys=="function"?sr=Qe.ownKeys:Object.getOwnPropertySymbols?sr=function(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:sr=function(e){return Object.getOwnPropertyNames(e)};function Zc(r){console&&console.warn&&console.warn(r)}var ps=Number.isNaN||function(e){return e!==e};function E(){E.init.call(this)}vn.exports=E;vn.exports.once=rf;E.EventEmitter=E;E.prototype._events=void 0;E.prototype._eventsCount=0;E.prototype._maxListeners=void 0;var ds=10;function or(r){if(typeof r!="function")throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof r)}Object.defineProperty(E,"defaultMaxListeners",{enumerable:!0,get:function(){return ds},set:function(r){if(typeof r!="number"||r<0||ps(r))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+r+".");ds=r}});E.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};E.prototype.setMaxListeners=function(e){if(typeof e!="number"||e<0||ps(e))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+e+".");return this._maxListeners=e,this};function ys(r){return r._maxListeners===void 0?E.defaultMaxListeners:r._maxListeners}E.prototype.getMaxListeners=function(){return ys(this)};E.prototype.emit=function(e){for(var t=[],n=1;n<arguments.length;n++)t.push(arguments[n]);var i=e==="error",s=this._events;if(s!==void 0)i=i&&s.error===void 0;else if(!i)return!1;if(i){var o;if(t.length>0&&(o=t[0]),o instanceof Error)throw o;var u=new Error("Unhandled error."+(o?" ("+o.message+")":""));throw u.context=o,u}var c=s[e];if(c===void 0)return!1;if(typeof c=="function")ls(c,this,t);else for(var h=c.length,a=Es(c,h),n=0;n<h;++n)ls(a[n],this,t);return!0};function ms(r,e,t,n){var i,s,o;if(or(t),s=r._events,s===void 0?(s=r._events=Object.create(null),r._eventsCount=0):(s.newListener!==void 0&&(r.emit("newListener",e,t.listener?t.listener:t),s=r._events),o=s[e]),o===void 0)o=s[e]=t,++r._eventsCount;else if(typeof o=="function"?o=s[e]=n?[t,o]:[o,t]:n?o.unshift(t):o.push(t),i=ys(r),i>0&&o.length>i&&!o.warned){o.warned=!0;var u=new Error("Possible EventEmitter memory leak detected. "+o.length+" "+String(e)+" listeners added. Use emitter.setMaxListeners() to increase limit");u.name="MaxListenersExceededWarning",u.emitter=r,u.type=e,u.count=o.length,Zc(u)}return r}E.prototype.addListener=function(e,t){return ms(this,e,t,!1)};E.prototype.on=E.prototype.addListener;E.prototype.prependListener=function(e,t){return ms(this,e,t,!0)};function Qc(){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 gs(r,e,t){var n={fired:!1,wrapFn:void 0,target:r,type:e,listener:t},i=Qc.bind(n);return i.listener=t,n.wrapFn=i,i}E.prototype.once=function(e,t){return or(t),this.on(e,gs(this,e,t)),this};E.prototype.prependOnceListener=function(e,t){return or(t),this.prependListener(e,gs(this,e,t)),this};E.prototype.removeListener=function(e,t){var n,i,s,o,u;if(or(t),i=this._events,i===void 0)return this;if(n=i[e],n===void 0)return this;if(n===t||n.listener===t)--this._eventsCount===0?this._events=Object.create(null):(delete i[e],i.removeListener&&this.emit("removeListener",e,n.listener||t));else if(typeof n!="function"){for(s=-1,o=n.length-1;o>=0;o--)if(n[o]===t||n[o].listener===t){u=n[o].listener,s=o;break}if(s<0)return this;s===0?n.shift():ef(n,s),n.length===1&&(i[e]=n[0]),i.removeListener!==void 0&&this.emit("removeListener",e,u||t)}return this};E.prototype.off=E.prototype.removeListener;E.prototype.removeAllListeners=function(e){var t,n,i;if(n=this._events,n===void 0)return this;if(n.removeListener===void 0)return arguments.length===0?(this._events=Object.create(null),this._eventsCount=0):n[e]!==void 0&&(--this._eventsCount===0?this._events=Object.create(null):delete n[e]),this;if(arguments.length===0){var s=Object.keys(n),o;for(i=0;i<s.length;++i)o=s[i],o!=="removeListener"&&this.removeAllListeners(o);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if(t=n[e],typeof t=="function")this.removeListener(e,t);else if(t!==void 0)for(i=t.length-1;i>=0;i--)this.removeListener(e,t[i]);return this};function ws(r,e,t){var n=r._events;if(n===void 0)return[];var i=n[e];return i===void 0?[]:typeof i=="function"?t?[i.listener||i]:[i]:t?tf(i):Es(i,i.length)}E.prototype.listeners=function(e){return ws(this,e,!0)};E.prototype.rawListeners=function(e){return ws(this,e,!1)};E.listenerCount=function(r,e){return typeof r.listenerCount=="function"?r.listenerCount(e):xs.call(r,e)};E.prototype.listenerCount=xs;function xs(r){var e=this._events;if(e!==void 0){var t=e[r];if(typeof t=="function")return 1;if(t!==void 0)return t.length}return 0}E.prototype.eventNames=function(){return this._eventsCount>0?sr(this._events):[]};function Es(r,e){for(var t=new Array(e),n=0;n<e;++n)t[n]=r[n];return t}function ef(r,e){for(;e+1<r.length;e++)r[e]=r[e+1];r.pop()}function tf(r){for(var e=new Array(r.length),t=0;t<e.length;++t)e[t]=r[t].listener||r[t];return e}function rf(r,e){return new Promise(function(t,n){function i(o){r.removeListener(e,s),n(o)}function s(){typeof r.removeListener=="function"&&r.removeListener("error",i),t([].slice.call(arguments))}bs(r,e,s,{once:!0}),e!=="error"&&nf(r,i,{once:!0})})}function nf(r,e,t){typeof r.on=="function"&&bs(r,"error",e,t)}function bs(r,e,t,n){if(typeof r.on=="function")n.once?r.once(e,t):r.on(e,t);else if(typeof r.addEventListener=="function")r.addEventListener(e,function i(s){n.once&&r.removeEventListener(e,i),t(s)});else throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof r)}});var Ss=x((Wl,As)=>{As.exports=typeof queueMicrotask=="function"?queueMicrotask:r=>Promise.resolve().then(r)});var St=x(An=>{"use strict";var _s=Ss();An.fromCallback=function(r,e){if(r===void 0){var t=new Promise(function(n,i){r=function(s,o){s?i(s):n(o)}});r[e!==void 0?e:"promise"]=t}else if(typeof r!="function")throw new TypeError("Callback must be a function");return r};An.fromPromise=function(r,e){if(e===void 0)return r;r.then(function(t){_s(()=>e(null,t))}).catch(function(t){_s(()=>e(t))})}});var ur=x(Sn=>{"use strict";Sn.getCallback=function(r,e){return typeof r=="function"?r:e};Sn.getOptions=function(r,e){return typeof r=="object"&&r!==null?r:e!==void 0?e:{}}});var xe=x(hr=>{"use strict";var{fromCallback:_n}=St(),N=G(),{getOptions:In,getCallback:Is}=ur(),Le=Symbol("promise"),et=Symbol("callback"),Z=Symbol("working"),Oe=Symbol("handleOne"),ie=Symbol("handleMany"),Cn=Symbol("autoClose"),ge=Symbol("finishWork"),Q=Symbol("returnMany"),pe=Symbol("closing"),_t=Symbol("handleClose"),cr=Symbol("closed"),It=Symbol("closeCallbacks"),me=Symbol("keyEncoding"),ke=Symbol("valueEncoding"),Tn=Symbol("abortOnClose"),fr=Symbol("legacy"),Bn=Symbol("keys"),Fn=Symbol("values"),ye=Symbol("limit"),K=Symbol("count"),ar=Object.freeze({}),sf=()=>{},Cs=!1,Ct=class{constructor(e,t,n){if(typeof e!="object"||e===null){let i=e===null?"null":typeof e;throw new TypeError(`The first argument must be an abstract-level database, received ${i}`)}if(typeof t!="object"||t===null)throw new TypeError("The second argument must be an options object");this[cr]=!1,this[It]=[],this[Z]=!1,this[pe]=!1,this[Cn]=!1,this[et]=null,this[Oe]=this[Oe].bind(this),this[ie]=this[ie].bind(this),this[_t]=this[_t].bind(this),this[me]=t[me],this[ke]=t[ke],this[fr]=n,this[ye]=Number.isInteger(t.limit)&&t.limit>=0?t.limit:1/0,this[K]=0,this[Tn]=!!t.abortOnClose,this.db=e,this.db.attachResource(this),this.nextTick=e.nextTick}get count(){return this[K]}get limit(){return this[ye]}next(e){let t;if(e===void 0)t=new Promise((n,i)=>{e=(s,o,u)=>{s?i(s):this[fr]?o===void 0&&u===void 0?n():n([o,u]):n(o)}});else if(typeof e!="function")throw new TypeError("Callback must be a function");return this[pe]?this.nextTick(e,new N("Iterator is not open: cannot call next() after close()",{code:"LEVEL_ITERATOR_NOT_OPEN"})):this[Z]?this.nextTick(e,new N("Iterator is busy: cannot call next() until previous call has completed",{code:"LEVEL_ITERATOR_BUSY"})):(this[Z]=!0,this[et]=e,this[K]>=this[ye]?this.nextTick(this[Oe],null):this._next(this[Oe])),t}_next(e){this.nextTick(e)}nextv(e,t,n){return n=Is(t,n),n=_n(n,Le),t=In(t,ar),Number.isInteger(e)?(this[pe]?this.nextTick(n,new N("Iterator is not open: cannot call nextv() after close()",{code:"LEVEL_ITERATOR_NOT_OPEN"})):this[Z]?this.nextTick(n,new N("Iterator is busy: cannot call nextv() until previous call has completed",{code:"LEVEL_ITERATOR_BUSY"})):(e<1&&(e=1),this[ye]<1/0&&(e=Math.min(e,this[ye]-this[K])),this[Z]=!0,this[et]=n,e<=0?this.nextTick(this[ie],null,[]):this._nextv(e,t,this[ie])),n[Le]):(this.nextTick(n,new TypeError("The first argument 'size' must be an integer")),n[Le])}_nextv(e,t,n){let i=[],s=(o,u,c)=>{if(o)return n(o);if(this[fr]?u===void 0&&c===void 0:u===void 0)return n(null,i);i.push(this[fr]?[u,c]:u),i.length===e?n(null,i):this._next(s)};this._next(s)}all(e,t){return t=Is(e,t),t=_n(t,Le),e=In(e,ar),this[pe]?this.nextTick(t,new N("Iterator is not open: cannot call all() after close()",{code:"LEVEL_ITERATOR_NOT_OPEN"})):this[Z]?this.nextTick(t,new N("Iterator is busy: cannot call all() until previous call has completed",{code:"LEVEL_ITERATOR_BUSY"})):(this[Z]=!0,this[et]=t,this[Cn]=!0,this[K]>=this[ye]?this.nextTick(this[ie],null,[]):this._all(e,this[ie])),t[Le]}_all(e,t){let n=this[K],i=[],s=()=>{let u=this[ye]<1/0?Math.min(1e3,this[ye]-n):1e3;u<=0?this.nextTick(t,null,i):this._nextv(u,ar,o)},o=(u,c)=>{u?t(u):c.length===0?t(null,i):(i.push.apply(i,c),n+=c.length,s())};s()}[ge](){let e=this[et];return this[Tn]&&e===null?sf:(this[Z]=!1,this[et]=null,this[pe]&&this._close(this[_t]),e)}[Q](e,t,n){this[Cn]?this.close(e.bind(null,t,n)):e(t,n)}seek(e,t){if(t=In(t,ar),!this[pe]){if(this[Z])throw new N("Iterator is busy: cannot call seek() until next() has completed",{code:"LEVEL_ITERATOR_BUSY"});{let n=this.db.keyEncoding(t.keyEncoding||this[me]),i=n.format;t.keyEncoding!==i&&(t={...t,keyEncoding:i});let s=this.db.prefixKey(n.encode(e),i);this._seek(s,t)}}}_seek(e,t){throw new N("Iterator does not support seek()",{code:"LEVEL_NOT_SUPPORTED"})}close(e){return e=_n(e,Le),this[cr]?this.nextTick(e):this[pe]?this[It].push(e):(this[pe]=!0,this[It].push(e),this[Z]?this[Tn]&&this[ge]()(new N("Aborted on iterator close()",{code:"LEVEL_ITERATOR_NOT_OPEN"})):this._close(this[_t])),e[Le]}_close(e){this.nextTick(e)}[_t](){this[cr]=!0,this.db.detachResource(this);let e=this[It];this[It]=[];for(let t of e)t()}async*[Symbol.asyncIterator](){try{let e;for(;(e=await this.next())!==void 0;)yield e}finally{this[cr]||await this.close()}}},tt=class extends Ct{constructor(e,t){super(e,t,!0),this[Bn]=t.keys!==!1,this[Fn]=t.values!==!1}[Oe](e,t,n){let i=this[ge]();if(e)return i(e);try{t=this[Bn]&&t!==void 0?this[me].decode(t):void 0,n=this[Fn]&&n!==void 0?this[ke].decode(n):void 0}catch(s){return i(new we("entry",s))}t===void 0&&n===void 0||this[K]++,i(null,t,n)}[ie](e,t){let n=this[ge]();if(e)return this[Q](n,e);try{for(let i of t){let s=i[0],o=i[1];i[0]=this[Bn]&&s!==void 0?this[me].decode(s):void 0,i[1]=this[Fn]&&o!==void 0?this[ke].decode(o):void 0}}catch(i){return this[Q](n,new we("entries",i))}this[K]+=t.length,this[Q](n,null,t)}end(e){return!Cs&&typeof console<"u"&&(Cs=!0,console.warn(new N("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(e)}},Ln=class extends Ct{constructor(e,t){super(e,t,!1)}[Oe](e,t){let n=this[ge]();if(e)return n(e);try{t=t!==void 0?this[me].decode(t):void 0}catch(i){return n(new we("key",i))}t!==void 0&&this[K]++,n(null,t)}[ie](e,t){let n=this[ge]();if(e)return this[Q](n,e);try{for(let i=0;i<t.length;i++){let s=t[i];t[i]=s!==void 0?this[me].decode(s):void 0}}catch(i){return this[Q](n,new we("keys",i))}this[K]+=t.length,this[Q](n,null,t)}},On=class extends Ct{constructor(e,t){super(e,t,!1)}[Oe](e,t){let n=this[ge]();if(e)return n(e);try{t=t!==void 0?this[ke].decode(t):void 0}catch(i){return n(new we("value",i))}t!==void 0&&this[K]++,n(null,t)}[ie](e,t){let n=this[ge]();if(e)return this[Q](n,e);try{for(let i=0;i<t.length;i++){let s=t[i];t[i]=s!==void 0?this[ke].decode(s):void 0}}catch(i){return this[Q](n,new we("values",i))}this[K]+=t.length,this[Q](n,null,t)}},we=class extends N{constructor(e,t){super(`Iterator could not decode ${e}`,{code:"LEVEL_DECODE_ERROR",cause:t})}};for(let r of["_ended property","_nexting property","_end method"])Object.defineProperty(tt.prototype,r.split(" ")[0],{get(){throw new N(`The ${r} has been removed`,{code:"LEVEL_LEGACY"})},set(){throw new N(`The ${r} has been removed`,{code:"LEVEL_LEGACY"})}});tt.keyEncoding=me;tt.valueEncoding=ke;hr.AbstractIterator=tt;hr.AbstractKeyIterator=Ln;hr.AbstractValueIterator=On});var Ts=x(kn=>{"use strict";var{AbstractKeyIterator:of,AbstractValueIterator:uf}=xe(),Ne=Symbol("iterator"),Tt=Symbol("callback"),rt=Symbol("handleOne"),Re=Symbol("handleMany"),Bt=class extends of{constructor(e,t){super(e,t),this[Ne]=e.iterator({...t,keys:!0,values:!1}),this[rt]=this[rt].bind(this),this[Re]=this[Re].bind(this)}},lr=class extends uf{constructor(e,t){super(e,t),this[Ne]=e.iterator({...t,keys:!1,values:!0}),this[rt]=this[rt].bind(this),this[Re]=this[Re].bind(this)}};for(let r of[Bt,lr]){let e=r===Bt,t=e?n=>n[0]:n=>n[1];r.prototype._next=function(n){this[Tt]=n,this[Ne].next(this[rt])},r.prototype[rt]=function(n,i,s){let o=this[Tt];n?o(n):o(null,e?i:s)},r.prototype._nextv=function(n,i,s){this[Tt]=s,this[Ne].nextv(n,i,this[Re])},r.prototype._all=function(n,i){this[Tt]=i,this[Ne].all(n,this[Re])},r.prototype[Re]=function(n,i){let s=this[Tt];n?s(n):s(null,i.map(t))},r.pro