@boredland/node-ts-cache 2.0.3 → 4.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.mts CHANGED
@@ -34,7 +34,10 @@ type CachedItem<T = unknown> = {
34
34
  type CachingOptions = {
35
35
  /** Number of milliseconds to expire the cached item - defaults to forever */
36
36
  ttl: number | null;
37
- /** Number of milliseconds to mark the cached item stale - defaults to the ttl */
37
+ /**
38
+ * Number of milliseconds to mark the cached item stale - defaults to the ttl.
39
+ * If staleTtl is less than ttl, it will be adjusted to ttl + staleTtl.
40
+ */
38
41
  staleTtl: number | null;
39
42
  /** (Default: JSON.stringify combination of className, methodName and call args) */
40
43
  calculateKey: (data: {
@@ -52,8 +55,7 @@ declare class CacheContainer {
52
55
  getItem<T>(key: string): Promise<{
53
56
  content: T;
54
57
  meta: {
55
- expired: boolean;
56
- stale: boolean;
58
+ state: 'fresh' | 'stale' | 'expired';
57
59
  createdAt: number;
58
60
  };
59
61
  } | undefined>;
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.mts","names":[],"sources":["../src/storage.ts","../src/cacheContainer.ts","../src/fallbackStorage.ts","../src/lruStorage.ts","../src/withCache.ts"],"sourcesContent":[],"mappings":"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"}
1
+ {"version":3,"file":"index.d.mts","names":[],"sources":["../src/storage.ts","../src/cacheContainer.ts","../src/fallbackStorage.ts","../src/lruStorage.ts","../src/withCache.ts"],"sourcesContent":[],"mappings":"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"}
package/dist/index.mjs CHANGED
@@ -1,2 +1,2 @@
1
- import{createRequire as e}from"node:module";import{debug as t}from"node:util";var n=Object.create,r=Object.defineProperty,i=Object.getOwnPropertyDescriptor,a=Object.getOwnPropertyNames,o=Object.getPrototypeOf,s=Object.prototype.hasOwnProperty,c=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),l=(e,t,n,o)=>{if(t&&typeof t==`object`||typeof t==`function`)for(var c=a(t),l=0,u=c.length,d;l<u;l++)d=c[l],!s.call(e,d)&&d!==n&&r(e,d,{get:(e=>t[e]).bind(null,d),enumerable:!(o=i(t,d))||o.enumerable});return e},u=(e,t,i)=>(i=e==null?{}:n(o(e)),l(t||!e||!e.__esModule?r(i,`default`,{value:e,enumerable:!0}):i,e)),d=e(import.meta.url);const f=t(`node-ts-cache`);var p=class{constructor(e){this.storage=e}async getItem(e){let t=await this.storage.getItem(e);if(!t)return;let n={content:t.content,meta:{createdAt:t.meta.createdAt,expired:this.isItemExpired(t),stale:this.isStaleItem(t)}};if(n.meta.expired&&!n.meta.stale){await this.unsetKey(e);return}return n}async setItem(e,t,n){let r={ttl:null,staleTtl:null,...n},i={createdAt:Date.now(),ttl:r.ttl,staleTtl:r.staleTtl};await this.storage.setItem(e,{meta:i,content:t})}async clear(){await this.storage.clear(),f(`Cleared cache`)}isItemExpired(e){return e.meta.ttl===null?!1:Date.now()>e.meta.createdAt+e.meta.ttl}isStaleItem(e){let t=e.meta.staleTtl??e.meta.ttl;return t===null?!1:Date.now()>e.meta.createdAt+t}async unsetKey(e){await this.storage.removeItem(e)}},m=class{storages;constructor(e){this.storages=e}async clear(){await Promise.all([...this.storages.map(e=>e.clear())])}async getItem(e){for(let t=0;t<this.storages.length;t++){let n=await this.storages[t]?.getItem(e);if(n!==void 0)return t!==0&&await Promise.all(this.storages.slice(0,t).map(t=>t.setItem(e,n))),n}}async setItem(e,t){let[n,...r]=this.storages;await n.setItem(e,t),Promise.all(r.map(n=>n.setItem(e,t)))}async removeItem(e){await Promise.all(this.storages.map(t=>t.removeItem(e)))}},h=c((e=>{var t=function(e,t){return e<t?-1:e>t?1:0},n=function(e,t){return e<t?1:e>t?-1:0};function r(e){return function(t,n){return e(n,t)}}function i(e){return e===2?function(e,t){return e[0]<t[0]?-1:e[0]>t[0]?1:e[1]<t[1]?-1:e[1]>t[1]?1:0}:function(t,n){for(var r=0;r<e;){if(t[r]<n[r])return-1;if(t[r]>n[r])return 1;r++}return 0}}e.DEFAULT_COMPARATOR=t,e.DEFAULT_REVERSE_COMPARATOR=n,e.reverseComparator=r,e.createTupleComparator=i})),g=c((e=>{e.ARRAY_BUFFER_SUPPORT=typeof ArrayBuffer<`u`,e.SYMBOL_SUPPORT=typeof Symbol<`u`})),_=c(((e,t)=>{var n=g(),r=n.ARRAY_BUFFER_SUPPORT,i=n.SYMBOL_SUPPORT;t.exports=function(e,t){var n,a,o,s,c;if(!e)throw Error(`obliterator/forEach: invalid iterable.`);if(typeof t!=`function`)throw Error(`obliterator/forEach: expecting a callback.`);if(Array.isArray(e)||r&&ArrayBuffer.isView(e)||typeof e==`string`||e.toString()===`[object Arguments]`){for(o=0,s=e.length;o<s;o++)t(e[o],o);return}if(typeof e.forEach==`function`){e.forEach(t);return}if(i&&Symbol.iterator in e&&typeof e.next!=`function`&&(e=e[Symbol.iterator]()),typeof e.next==`function`){for(n=e,o=0;c=n.next(),c.done!==!0;)t(c.value,o),o++;return}for(a in e)e.hasOwnProperty(a)&&t(e[a],a)}})),v=c(((e,t)=>{var n=h(),r=_(),i=n.DEFAULT_COMPARATOR,a=n.reverseComparator;function o(e){if(this.clear(),this.comparator=e||i,typeof this.comparator!=`function`)throw Error(`mnemonist/FibonacciHeap.constructor: given comparator should be a function.`)}o.prototype.clear=function(){this.root=null,this.min=null,this.size=0};function s(e){return{item:e,degree:0}}function c(e,t){e.root?(t.right=e.root.right,t.left=e.root,e.root.right.left=t,e.root.right=t):e.root=t}o.prototype.push=function(e){var t=s(e);return t.left=t,t.right=t,c(this,t),(!this.min||this.comparator(t.item,this.min.item)<=0)&&(this.min=t),++this.size},o.prototype.peek=function(){return this.min?this.min.item:void 0};function l(e){for(var t=[],n=e,r=!1;!(n===e&&r);)n===e&&(r=!0),t.push(n),n=n.right;return t}function u(e,t){e.root===t&&(e.root=t.right),t.left.right=t.right,t.right.left=t.left}function d(e,t){e.child?(t.right=e.child.right,t.left=e.child,e.child.right.left=t,e.child.right=t):e.child=t}function f(e,t,n){u(e,t),t.left=t,t.right=t,d(n,t),n.degree++,t.parent=n}function p(e){var t=Array(e.size),n=l(e.root),r,i,a,o,s,c;for(r=0,i=n.length;r<i;r++){for(a=n[r],s=a.degree;t[s];)o=t[s],e.comparator(a.item,o.item)>0&&(c=a,a=o,o=c),f(e,o,a),t[s]=null,s++;t[s]=a}for(r=0;r<e.size;r++)t[r]&&e.comparator(t[r].item,e.min.item)<=0&&(e.min=t[r])}o.prototype.pop=function(){if(this.size){var e=this.min;if(e.child){var t=l(e.child),n,r,i;for(r=0,i=t.length;r<i;r++)n=t[r],c(this,n),delete n.parent}return u(this,e),e===e.right?(this.min=null,this.root=null):(this.min=e.right,p(this)),this.size--,e.item}},o.prototype.inspect=function(){var e={size:this.size};return this.min&&`item`in this.min&&(e.top=this.min.item),Object.defineProperty(e,`constructor`,{value:o,enumerable:!1}),e},typeof Symbol<`u`&&(o.prototype[Symbol.for(`nodejs.util.inspect.custom`)]=o.prototype.inspect);function m(e){if(this.clear(),this.comparator=e||i,typeof this.comparator!=`function`)throw Error(`mnemonist/FibonacciHeap.constructor: given comparator should be a function.`);this.comparator=a(this.comparator)}m.prototype=o.prototype,o.from=function(e,t){var n=new o(t);return r(e,function(e){n.push(e)}),n},m.from=function(e,t){var n=new m(t);return r(e,function(e){n.push(e)}),n},o.MinFibonacciHeap=o,o.MaxFibonacciHeap=m,t.exports=o})),y=c((e=>{var t=2**8-1,n=2**16-1,r=2**32-1,i=2**7-1,a=2**15-1,o=2**31-1;e.getPointerArray=function(e){var i=e-1;if(i<=t)return Uint8Array;if(i<=n)return Uint16Array;if(i<=r)return Uint32Array;throw Error(`mnemonist: Pointer Array of size > 4294967295 is not supported.`)},e.getSignedPointerArray=function(e){var t=e-1;return t<=i?Int8Array:t<=a?Int16Array:t<=o?Int32Array:Float64Array},e.getNumberType=function(e){return e===(e|0)?Math.sign(e)===-1?e<=127&&e>=-128?Int8Array:e<=32767&&e>=-32768?Int16Array:Int32Array:e<=255?Uint8Array:e<=65535?Uint16Array:Uint32Array:Float64Array};var s={Uint8Array:1,Int8Array:2,Uint16Array:3,Int16Array:4,Uint32Array:5,Int32Array:6,Float32Array:7,Float64Array:8};e.getMinimalRepresentation=function(t,n){var r=null,i=0,a,o,c,l,u;for(l=0,u=t.length;l<u;l++)c=n?n(t[l]):t[l],o=e.getNumberType(c),a=s[o.name],a>i&&(i=a,r=o);return r},e.isTypedArray=function(e){return typeof ArrayBuffer<`u`&&ArrayBuffer.isView(e)},e.concat=function(){var e=0,t,n,r;for(t=0,r=arguments.length;t<r;t++)e+=arguments[t].length;var i=new arguments[0].constructor(e);for(t=0,n=0;t<r;t++)i.set(arguments[t],n),n+=arguments[t].length;return i},e.indices=function(t){for(var n=new(e.getPointerArray(t))(t),r=0;r<t;r++)n[r]=r;return n}})),b=c((e=>{var t=_(),n=y();function r(e){return Array.isArray(e)||n.isTypedArray(e)}function i(e){if(typeof e.length==`number`)return e.length;if(typeof e.size==`number`)return e.size}function a(e){var n=i(e),r=typeof n==`number`?Array(n):[],a=0;return t(e,function(e){r[a++]=e}),r}function o(e){var r=i(e),a=typeof r==`number`?n.getPointerArray(r):Array,o=typeof r==`number`?Array(r):[],s=typeof r==`number`?new a(r):[],c=0;return t(e,function(e){o[c]=e,s[c]=c++}),[o,s]}e.isArrayLike=r,e.guessLength=i,e.toArray=a,e.toArrayWithIndices=o})),x=c(((e,t)=>{var n=_(),r=h(),i=b(),a=r.DEFAULT_COMPARATOR,o=r.reverseComparator;function s(e,t,n,r){for(var i=t[r],a,o;r>n;){if(a=r-1>>1,o=t[a],e(i,o)<0){t[r]=o,r=a;continue}break}t[r]=i}function c(e,t,n){for(var r=t.length,i=n,a=t[n],o=2*n+1,c;o<r;)c=o+1,c<r&&e(t[o],t[c])>=0&&(o=c),t[n]=t[o],n=o,o=2*n+1;t[n]=a,s(e,t,i,n)}function l(e,t,n){t.push(n),s(e,t,0,t.length-1)}function u(e,t){var n=t.pop();if(t.length!==0){var r=t[0];return t[0]=n,c(e,t,0),r}return n}function d(e,t,n){if(t.length===0)throw Error(`mnemonist/heap.replace: cannot pop an empty heap.`);var r=t[0];return t[0]=n,c(e,t,0),r}function f(e,t,n){var r;return t.length!==0&&e(t[0],n)<0&&(r=t[0],t[0]=n,n=r,c(e,t,0)),n}function p(e,t){for(var n=t.length>>1;--n>=0;)c(e,t,n)}function m(e,t){for(var n=t.length,r=0,i=Array(n);r<n;)i[r++]=u(e,t);return i}function g(e,t,r){arguments.length===2&&(r=t,t=e,e=a);var s=o(e),c,l,u,f=1/0,m;if(t===1){if(i.isArrayLike(r)){for(c=0,l=r.length;c<l;c++)u=r[c],(f===1/0||e(u,f)<0)&&(f=u);return m=new r.constructor(1),m[0]=f,m}return n(r,function(t){(f===1/0||e(t,f)<0)&&(f=t)}),[f]}if(i.isArrayLike(r)){if(t>=r.length)return r.slice().sort(e);for(m=r.slice(0,t),p(s,m),c=t,l=r.length;c<l;c++)s(r[c],m[0])>0&&d(s,m,r[c]);return m.sort(e)}var h=i.guessLength(r);return h!==null&&h<t&&(t=h),m=Array(t),c=0,n(r,function(e){c<t?m[c]=e:(c===t&&p(s,m),s(e,m[0])>0&&d(s,m,e)),c++}),m.length>c&&(m.length=c),m.sort(e)}function v(e,t,r){arguments.length===2&&(r=t,t=e,e=a);var s=o(e),c,l,u,f=-1/0,m;if(t===1){if(i.isArrayLike(r)){for(c=0,l=r.length;c<l;c++)u=r[c],(f===-1/0||e(u,f)>0)&&(f=u);return m=new r.constructor(1),m[0]=f,m}return n(r,function(t){(f===-1/0||e(t,f)>0)&&(f=t)}),[f]}if(i.isArrayLike(r)){if(t>=r.length)return r.slice().sort(s);for(m=r.slice(0,t),p(e,m),c=t,l=r.length;c<l;c++)e(r[c],m[0])>0&&d(e,m,r[c]);return m.sort(s)}var h=i.guessLength(r);return h!==null&&h<t&&(t=h),m=Array(t),c=0,n(r,function(n){c<t?m[c]=n:(c===t&&p(e,m),e(n,m[0])>0&&d(e,m,n)),c++}),m.length>c&&(m.length=c),m.sort(s)}function y(e){if(this.clear(),this.comparator=e||a,typeof this.comparator!=`function`)throw Error(`mnemonist/Heap.constructor: given comparator should be a function.`)}y.prototype.clear=function(){this.items=[],this.size=0},y.prototype.push=function(e){return l(this.comparator,this.items,e),++this.size},y.prototype.peek=function(){return this.items[0]},y.prototype.pop=function(){return this.size!==0&&this.size--,u(this.comparator,this.items)},y.prototype.replace=function(e){return d(this.comparator,this.items,e)},y.prototype.pushpop=function(e){return f(this.comparator,this.items,e)},y.prototype.consume=function(){return this.size=0,m(this.comparator,this.items)},y.prototype.toArray=function(){return m(this.comparator,this.items.slice())},y.prototype.inspect=function(){var e=this.toArray();return Object.defineProperty(e,`constructor`,{value:y,enumerable:!1}),e},typeof Symbol<`u`&&(y.prototype[Symbol.for(`nodejs.util.inspect.custom`)]=y.prototype.inspect);function x(e){if(this.clear(),this.comparator=e||a,typeof this.comparator!=`function`)throw Error(`mnemonist/MaxHeap.constructor: given comparator should be a function.`);this.comparator=o(this.comparator)}x.prototype=y.prototype,y.from=function(e,t){var n=new y(t),r=i.isArrayLike(e)?e.slice():i.toArray(e);return p(n.comparator,r),n.items=r,n.size=r.length,n},x.from=function(e,t){var n=new x(t),r=i.isArrayLike(e)?e.slice():i.toArray(e);return p(n.comparator,r),n.items=r,n.size=r.length,n},y.siftUp=c,y.siftDown=s,y.push=l,y.pop=u,y.replace=d,y.pushpop=f,y.heapify=p,y.consume=m,y.nsmallest=g,y.nlargest=v,y.MinHeap=y,y.MaxHeap=x,t.exports=y})),S=c(((e,t)=>{var n=``;function r(e,t,n){for(var r=t.length,i=[],a=r,o=-1,s,c=0,l;a--;)o=Math.max(e[t[a]+n],o);for(l=o>>24&&32||o>>16&&24||o>>8&&16||8;c<l;c+=4){for(a=16;a--;)i[a]=[];for(a=r;a--;)i[e[t[a]+n]>>c&15].push(t[a]);for(s=0;s<16;s++)for(o=i[s].length;o--;)t[++a]=i[s][o]}}function i(e,t,n,r){return e[n]-e[r]||(n%3==2?e[n+1]-e[r+1]||t[n+2]-t[r+2]:t[n+1]-t[r+1])}function a(e,t){var n=[],o=[],s=2*t/3|0,c=t-s,l=s+1>>1,u=s,d=0,f,p=[],m=[];if(t===1)return[0];for(;u--;)n[u]=(u*3>>1)+1;for(u=3;u--;)r(e,n,u);for(d=o[(n[0]/3|0)+(n[0]%3==1?0:l)]=1,u=1;u<s;u++)(e[n[u]]!==e[n[u-1]]||e[n[u]+1]!==e[n[u-1]+1]||e[n[u]+2]!==e[n[u-1]+2])&&d++,o[(n[u]/3|0)+(n[u]%3==1?0:l)]=d;if(d<s)for(o=a(o,s),u=s;u--;)n[u]=o[u]<l?o[u]*3+1:(o[u]-l)*3+2;for(u=s;u--;)p[n[u]]=u;for(p[t]=-1,p[t+1]=-2,o=t%3==1?[t-1]:[],u=0;u<s;u++)n[u]%3==1&&o.push(n[u]-1);for(r(e,o,0),u=0,d=0,f=0;u<s&&d<c;)m[f++]=i(e,p,n[u],o[d])<0?n[u++]:o[d++];for(;u<s;)m[f++]=n[u++];for(;d<c;)m[f++]=o[d++];return m}function o(e){var t=e.length,n=t%3,r=Array(t+n),i,a;if(typeof e!=`string`){var o=Object.create(null);for(a=0;a<t;a++)o[e[a]]||(o[e[a]]=!0);var s=Object.create(null),c=Object.keys(o).sort();for(a=0,i=c.length;a<i;a++)s[c[a]]=a+1;for(a=0;a<t;a++)r[a]=s[e[a]]}else for(a=0;a<t;a++)r[a]=e.charCodeAt(a);for(a=t;a<t+n;a++)r[a]=0;return r}function s(e){this.hasArbitrarySequence=typeof e!=`string`,this.string=e,this.length=e.length,this.array=a(o(e),this.length)}s.prototype.toString=function(){return this.array.join(`,`)},s.prototype.toJSON=function(){return this.array},s.prototype.inspect=function(){for(var e=Array(this.length),t=0;t<this.length;t++)e[t]=this.string.slice(this.array[t]);return Object.defineProperty(e,`constructor`,{value:s,enumerable:!1}),e},typeof Symbol<`u`&&(s.prototype[Symbol.for(`nodejs.util.inspect.custom`)]=s.prototype.inspect);function c(e){if(this.hasArbitrarySequence=typeof e[0]!=`string`,this.size=e.length,this.hasArbitrarySequence){this.text=[];for(var t=0,r=this.size;t<r;t++)this.text.push.apply(this.text,e[t]),t<r-1&&this.text.push(n)}else this.text=e.join(n);this.firstLength=e[0].length,this.length=this.text.length,this.array=a(o(this.text),this.length)}c.prototype.longestCommonSubsequence=function(){var e=this.hasArbitrarySequence?[]:``,t,n,r,i,a;for(n=1;n<this.length;n++)if(i=this.array[n],a=this.array[n-1],!(i<this.firstLength&&a<this.firstLength)&&!(i>this.firstLength&&a>this.firstLength)){for(t=Math.min(this.length-i,this.length-a),r=0;r<t;r++)if(this.text[i+r]!==this.text[a+r]){t=r;break}t>e.length&&(e=this.text.slice(i,i+t))}return e},c.prototype.toString=function(){return this.array.join(`,`)},c.prototype.toJSON=function(){return this.array},c.prototype.inspect=function(){for(var e=Array(this.length),t=0;t<this.length;t++)e[t]=this.text.slice(this.array[t]);return Object.defineProperty(e,`constructor`,{value:c,enumerable:!1}),e},typeof Symbol<`u`&&(c.prototype[Symbol.for(`nodejs.util.inspect.custom`)]=c.prototype.inspect),s.GeneralizedSuffixArray=c,t.exports=s})),C=c(((e,t)=>{function n(e){if(typeof e!=`function`)throw Error(`obliterator/iterator: expecting a function!`);this.next=e}typeof Symbol<`u`&&(n.prototype[Symbol.iterator]=function(){return this}),n.of=function(){var e=arguments,t=e.length,r=0;return new n(function(){return r>=t?{done:!0}:{done:!1,value:e[r++]}})},n.empty=function(){return new n(function(){return{done:!0}})},n.fromSequence=function(e){var t=0,r=e.length;return new n(function(){return t>=r?{done:!0}:{done:!1,value:e[t++]}})},n.is=function(e){return e instanceof n?!0:typeof e==`object`&&!!e&&typeof e.next==`function`},t.exports=n})),w=c(((e,t)=>{var n=C(),r=_(),i=b(),a=y(),o=function(e){return Math.max(1,Math.ceil(e*1.5))},s=function(e){return new(a.getPointerArray(e))(e)};function c(e,t){if(arguments.length<1)throw Error(`mnemonist/vector: expecting at least a byte array constructor.`);var n=t||0,r=o,i=0,a=!1;typeof t==`object`&&(n=t.initialCapacity||0,i=t.initialLength||0,r=t.policy||r,a=t.factory===!0),this.factory=a?e:null,this.ArrayClass=e,this.length=i,this.capacity=Math.max(i,n),this.policy=r,this.array=new e(this.capacity)}c.prototype.set=function(e,t){if(this.length<e)throw Error(`Vector(`+this.ArrayClass.name+`).set: index out of bounds.`);return this.array[e]=t,this},c.prototype.get=function(e){if(!(this.length<e))return this.array[e]},c.prototype.applyPolicy=function(e){var t=this.policy(e||this.capacity);if(typeof t!=`number`||t<0)throw Error(`mnemonist/vector.applyPolicy: policy returned an invalid value (expecting a positive integer).`);if(t<=this.capacity)throw Error(`mnemonist/vector.applyPolicy: policy returned a less or equal capacity to allocate.`);return t},c.prototype.reallocate=function(e){if(e===this.capacity)return this;var t=this.array;if(e<this.length&&(this.length=e),e>this.capacity)if(this.factory===null?this.array=new this.ArrayClass(e):this.array=this.factory(e),a.isTypedArray(this.array))this.array.set(t,0);else for(var n=0,r=this.length;n<r;n++)this.array[n]=t[n];else this.array=t.slice(0,e);return this.capacity=e,this},c.prototype.grow=function(e){var t;if(typeof e==`number`){if(this.capacity>=e)return this;for(t=this.capacity;t<e;)t=this.applyPolicy(t);return this.reallocate(t),this}return t=this.applyPolicy(),this.reallocate(t),this},c.prototype.resize=function(e){return e===this.length?this:e<this.length?(this.length=e,this):(this.length=e,this.reallocate(e),this)},c.prototype.push=function(e){return this.capacity===this.length&&this.grow(),this.array[this.length++]=e,this.length},c.prototype.pop=function(){if(this.length!==0)return this.array[--this.length]},c.prototype.values=function(){var e=this.array,t=this.length,r=0;return new n(function(){if(r>=t)return{done:!0};var n=e[r];return r++,{value:n,done:!1}})},c.prototype.entries=function(){var e=this.array,t=this.length,r=0;return new n(function(){if(r>=t)return{done:!0};var n=e[r];return{value:[r++,n],done:!1}})},typeof Symbol<`u`&&(c.prototype[Symbol.iterator]=c.prototype.values),c.prototype.inspect=function(){var e=this.array.slice(0,this.length);return e.type=this.array.constructor.name,e.items=this.length,e.capacity=this.capacity,Object.defineProperty(e,`constructor`,{value:c,enumerable:!1}),e},typeof Symbol<`u`&&(c.prototype[Symbol.for(`nodejs.util.inspect.custom`)]=c.prototype.inspect),c.from=function(e,t,n){if(arguments.length<3&&(n=i.guessLength(e),typeof n!=`number`))throw Error(`mnemonist/vector.from: could not guess iterable length. Please provide desired capacity as last argument.`);var a=new c(t,n);return r(e,function(e){a.push(e)}),a};function l(e){var t=function(t){c.call(this,e,t)};for(var n in c.prototype)c.prototype.hasOwnProperty(n)&&(t.prototype[n]=c.prototype[n]);return t.from=function(t,n){return c.from(t,e,n)},typeof Symbol<`u`&&(t.prototype[Symbol.iterator]=t.prototype.values),t}c.Int8Vector=l(Int8Array),c.Uint8Vector=l(Uint8Array),c.Uint8ClampedVector=l(Uint8ClampedArray),c.Int16Vector=l(Int16Array),c.Uint16Vector=l(Uint16Array),c.Int32Vector=l(Int32Array),c.Uint32Vector=l(Uint32Array),c.Float32Vector=l(Float32Array),c.Float64Vector=l(Float64Array),c.PointerVector=l(s),t.exports=c})),T=c(((e,t)=>{var n=C(),r=_(),i=y(),a=b();function o(e,t,n){if(arguments.length<2&&(n=e,e=null,t=null),this.capacity=n,typeof this.capacity!=`number`||this.capacity<=0)throw Error(`mnemonist/lru-cache: capacity should be positive number.`);if(!isFinite(this.capacity)||Math.floor(this.capacity)!==this.capacity)throw Error(`mnemonist/lru-cache: capacity should be a finite positive integer.`);var r=i.getPointerArray(n);this.forward=new r(n),this.backward=new r(n),this.K=typeof e==`function`?new e(n):Array(n),this.V=typeof t==`function`?new t(n):Array(n),this.size=0,this.head=0,this.tail=0,this.items={}}o.prototype.clear=function(){this.size=0,this.head=0,this.tail=0,this.items={}},o.prototype.splayOnTop=function(e){var t=this.head;if(this.head===e)return this;var n=this.backward[e],r=this.forward[e];return this.tail===e?this.tail=n:this.backward[r]=n,this.forward[n]=r,this.backward[t]=e,this.head=e,this.forward[e]=t,this},o.prototype.set=function(e,t){var n=this.items[e];if(n!==void 0){this.splayOnTop(n),this.V[n]=t;return}this.size<this.capacity?n=this.size++:(n=this.tail,this.tail=this.backward[n],delete this.items[this.K[n]]),this.items[e]=n,this.K[n]=e,this.V[n]=t,this.forward[n]=this.head,this.backward[this.head]=n,this.head=n},o.prototype.setpop=function(e,t){var n=null,r=null,i=this.items[e];return i===void 0?(this.size<this.capacity?i=this.size++:(i=this.tail,this.tail=this.backward[i],n=this.V[i],r=this.K[i],delete this.items[r]),this.items[e]=i,this.K[i]=e,this.V[i]=t,this.forward[i]=this.head,this.backward[this.head]=i,this.head=i,r?{evicted:!0,key:r,value:n}:null):(this.splayOnTop(i),n=this.V[i],this.V[i]=t,{evicted:!1,key:e,value:n})},o.prototype.has=function(e){return e in this.items},o.prototype.get=function(e){var t=this.items[e];if(t!==void 0)return this.splayOnTop(t),this.V[t]},o.prototype.peek=function(e){var t=this.items[e];if(t!==void 0)return this.V[t]},o.prototype.forEach=function(e,t){t=arguments.length>1?t:this;for(var n=0,r=this.size,i=this.head,a=this.K,o=this.V,s=this.forward;n<r;)e.call(t,o[i],a[i],this),i=s[i],n++},o.prototype.keys=function(){var e=0,t=this.size,r=this.head,i=this.K,a=this.forward;return new n(function(){if(e>=t)return{done:!0};var n=i[r];return e++,e<t&&(r=a[r]),{done:!1,value:n}})},o.prototype.values=function(){var e=0,t=this.size,r=this.head,i=this.V,a=this.forward;return new n(function(){if(e>=t)return{done:!0};var n=i[r];return e++,e<t&&(r=a[r]),{done:!1,value:n}})},o.prototype.entries=function(){var e=0,t=this.size,r=this.head,i=this.K,a=this.V,o=this.forward;return new n(function(){if(e>=t)return{done:!0};var n=i[r],s=a[r];return e++,e<t&&(r=o[r]),{done:!1,value:[n,s]}})},typeof Symbol<`u`&&(o.prototype[Symbol.iterator]=o.prototype.entries),o.prototype.inspect=function(){for(var e=new Map,t=this.entries(),n;n=t.next(),!n.done;)e.set(n.value[0],n.value[1]);return Object.defineProperty(e,`constructor`,{value:o,enumerable:!1}),e},typeof Symbol<`u`&&(o.prototype[Symbol.for(`nodejs.util.inspect.custom`)]=o.prototype.inspect),o.from=function(e,t,n,i){if(arguments.length<2){if(i=a.guessLength(e),typeof i!=`number`)throw Error(`mnemonist/lru-cache.from: could not guess iterable length. Please provide desired capacity as last argument.`)}else arguments.length===2&&(i=t,t=null,n=null);var s=new o(t,n,i);return r(e,function(e,t){s.set(t,e)}),s},t.exports=o})),E=c(((e,t)=>{var n=T(),r=_(),i=y(),a=b();function o(e,t,n){if(arguments.length<2&&(n=e,e=null,t=null),this.capacity=n,typeof this.capacity!=`number`||this.capacity<=0)throw Error(`mnemonist/lru-map: capacity should be positive number.`);if(!isFinite(this.capacity)||Math.floor(this.capacity)!==this.capacity)throw Error(`mnemonist/lru-map: capacity should be a finite positive integer.`);var r=i.getPointerArray(n);this.forward=new r(n),this.backward=new r(n),this.K=typeof e==`function`?new e(n):Array(n),this.V=typeof t==`function`?new t(n):Array(n),this.size=0,this.head=0,this.tail=0,this.items=new Map}o.prototype.clear=function(){this.size=0,this.head=0,this.tail=0,this.items.clear()},o.prototype.set=function(e,t){var n=this.items.get(e);if(n!==void 0){this.splayOnTop(n),this.V[n]=t;return}this.size<this.capacity?n=this.size++:(n=this.tail,this.tail=this.backward[n],this.items.delete(this.K[n])),this.items.set(e,n),this.K[n]=e,this.V[n]=t,this.forward[n]=this.head,this.backward[this.head]=n,this.head=n},o.prototype.setpop=function(e,t){var n=null,r=null,i=this.items.get(e);return i===void 0?(this.size<this.capacity?i=this.size++:(i=this.tail,this.tail=this.backward[i],n=this.V[i],r=this.K[i],this.items.delete(r)),this.items.set(e,i),this.K[i]=e,this.V[i]=t,this.forward[i]=this.head,this.backward[this.head]=i,this.head=i,r?{evicted:!0,key:r,value:n}:null):(this.splayOnTop(i),n=this.V[i],this.V[i]=t,{evicted:!1,key:e,value:n})},o.prototype.has=function(e){return this.items.has(e)},o.prototype.get=function(e){var t=this.items.get(e);if(t!==void 0)return this.splayOnTop(t),this.V[t]},o.prototype.peek=function(e){var t=this.items.get(e);if(t!==void 0)return this.V[t]},o.prototype.splayOnTop=n.prototype.splayOnTop,o.prototype.forEach=n.prototype.forEach,o.prototype.keys=n.prototype.keys,o.prototype.values=n.prototype.values,o.prototype.entries=n.prototype.entries,typeof Symbol<`u`&&(o.prototype[Symbol.iterator]=o.prototype.entries),o.prototype.inspect=n.prototype.inspect,o.from=function(e,t,n,i){if(arguments.length<2){if(i=a.guessLength(e),typeof i!=`number`)throw Error(`mnemonist/lru-cache.from: could not guess iterable length. Please provide desired capacity as last argument.`)}else arguments.length===2&&(i=t,t=null,n=null);var s=new o(t,n,i);return r(e,function(e,t){s.set(t,e)}),s},t.exports=o})),D=c(((e,t)=>{var n=E(),r=_(),i=y(),a=b();function o(e,t,r){arguments.length<2?n.call(this,e):n.call(this,e,t,r),this.deleted=new(i.getPointerArray(this.capacity))(this.capacity),this.deletedSize=0}for(var s in n.prototype)o.prototype[s]=n.prototype[s];typeof Symbol<`u`&&(o.prototype[Symbol.iterator]=n.prototype[Symbol.iterator]),o.prototype.clear=function(){n.prototype.clear.call(this),this.deletedSize=0},o.prototype.set=function(e,t){var n=this.items.get(e);if(n!==void 0){this.splayOnTop(n),this.V[n]=t;return}this.size<this.capacity?(n=this.deletedSize>0?this.deleted[--this.deletedSize]:this.size,this.size++):(n=this.tail,this.tail=this.backward[n],this.items.delete(this.K[n])),this.items.set(e,n),this.K[n]=e,this.V[n]=t,this.forward[n]=this.head,this.backward[this.head]=n,this.head=n},o.prototype.setpop=function(e,t){var n=null,r=null,i=this.items.get(e);return i===void 0?(this.size<this.capacity?(i=this.deletedSize>0?this.deleted[--this.deletedSize]:this.size,this.size++):(i=this.tail,this.tail=this.backward[i],n=this.V[i],r=this.K[i],this.items.delete(r)),this.items.set(e,i),this.K[i]=e,this.V[i]=t,this.forward[i]=this.head,this.backward[this.head]=i,this.head=i,r?{evicted:!0,key:r,value:n}:null):(this.splayOnTop(i),n=this.V[i],this.V[i]=t,{evicted:!1,key:e,value:n})},o.prototype.delete=function(e){var t=this.items.get(e);if(t===void 0)return!1;if(this.items.delete(e),this.size===1)return this.size=0,this.head=0,this.tail=0,this.deletedSize=0,!0;var n=this.backward[t],r=this.forward[t];return this.head===t&&(this.head=r),this.tail===t&&(this.tail=n),this.forward[n]=r,this.backward[r]=n,this.size--,this.deleted[this.deletedSize++]=t,!0},o.prototype.remove=function(e,t=void 0){var n=this.items.get(e);if(n===void 0)return t;var r=this.V[n];if(this.items.delete(e),this.size===1)return this.size=0,this.head=0,this.tail=0,this.deletedSize=0,r;var i=this.backward[n],a=this.forward[n];return this.head===n&&(this.head=a),this.tail===n&&(this.tail=i),this.forward[i]=a,this.backward[a]=i,this.size--,this.deleted[this.deletedSize++]=n,r},o.from=function(e,t,n,i){if(arguments.length<2){if(i=a.guessLength(e),typeof i!=`number`)throw Error(`mnemonist/lru-map.from: could not guess iterable length. Please provide desired capacity as last argument.`)}else arguments.length===2&&(i=t,t=null,n=null);var s=new o(t,n,i);return r(e,function(e,t){s.set(t,e)}),s},t.exports=o})),O=u(v(),1),k=u(x(),1),A=u(S(),1),j=u(w(),1),M=u(D(),1);O.default.MinFibonacciHeap,O.default.MaxFibonacciHeap,k.default.MinHeap,k.default.MaxHeap,A.default.GeneralizedSuffixArray,j.default.Uint8Vector,j.default.Uint8ClampedVector,j.default.Int8Vector,j.default.Uint16Vector,j.default.Int16Vector,j.default.Uint32Vector,j.default.Int32Vector,j.default.Float32Vector,j.default.Float64Vector,j.default.PointerVector;var N=class{cache;constructor({max:e=1e4}={}){this.cache=new M.default(e)}async clear(){this.cache.clear()}async getItem(e){return this.cache.get(e)}async setItem(e,t){this.cache.set(e,t)}async removeItem(e){this.cache.delete(e)}},P=u(c(((e,t)=>{var n=Object.prototype.hasOwnProperty,r=`~`;function i(){}Object.create&&(i.prototype=Object.create(null),new i().__proto__||(r=!1));function a(e,t,n){this.fn=e,this.context=t,this.once=n||!1}function o(e,t,n,i,o){if(typeof n!=`function`)throw TypeError(`The listener must be a function`);var s=new a(n,i||e,o),c=r?r+t:t;return e._events[c]?e._events[c].fn?e._events[c]=[e._events[c],s]:e._events[c].push(s):(e._events[c]=s,e._eventsCount++),e}function s(e,t){--e._eventsCount===0?e._events=new i:delete e._events[t]}function c(){this._events=new i,this._eventsCount=0}c.prototype.eventNames=function(){var e=[],t,i;if(this._eventsCount===0)return e;for(i in t=this._events)n.call(t,i)&&e.push(r?i.slice(1):i);return Object.getOwnPropertySymbols?e.concat(Object.getOwnPropertySymbols(t)):e},c.prototype.listeners=function(e){var t=r?r+e:e,n=this._events[t];if(!n)return[];if(n.fn)return[n.fn];for(var i=0,a=n.length,o=Array(a);i<a;i++)o[i]=n[i].fn;return o},c.prototype.listenerCount=function(e){var t=r?r+e:e,n=this._events[t];return n?n.fn?1:n.length:0},c.prototype.emit=function(e,t,n,i,a,o){var s=r?r+e:e;if(!this._events[s])return!1;var c=this._events[s],l=arguments.length,u,d;if(c.fn){switch(c.once&&this.removeListener(e,c.fn,void 0,!0),l){case 1:return c.fn.call(c.context),!0;case 2:return c.fn.call(c.context,t),!0;case 3:return c.fn.call(c.context,t,n),!0;case 4:return c.fn.call(c.context,t,n,i),!0;case 5:return c.fn.call(c.context,t,n,i,a),!0;case 6:return c.fn.call(c.context,t,n,i,a,o),!0}for(d=1,u=Array(l-1);d<l;d++)u[d-1]=arguments[d];c.fn.apply(c.context,u)}else{var f=c.length,p;for(d=0;d<f;d++)switch(c[d].once&&this.removeListener(e,c[d].fn,void 0,!0),l){case 1:c[d].fn.call(c[d].context);break;case 2:c[d].fn.call(c[d].context,t);break;case 3:c[d].fn.call(c[d].context,t,n);break;case 4:c[d].fn.call(c[d].context,t,n,i);break;default:if(!u)for(p=1,u=Array(l-1);p<l;p++)u[p-1]=arguments[p];c[d].fn.apply(c[d].context,u)}}return!0},c.prototype.on=function(e,t,n){return o(this,e,t,n,!1)},c.prototype.once=function(e,t,n){return o(this,e,t,n,!0)},c.prototype.removeListener=function(e,t,n,i){var a=r?r+e:e;if(!this._events[a])return this;if(!t)return s(this,a),this;var o=this._events[a];if(o.fn)o.fn===t&&(!i||o.once)&&(!n||o.context===n)&&s(this,a);else{for(var c=0,l=[],u=o.length;c<u;c++)(o[c].fn!==t||i&&!o[c].once||n&&o[c].context!==n)&&l.push(o[c]);l.length?this._events[a]=l.length===1?l[0]:l:s(this,a)}return this},c.prototype.removeAllListeners=function(e){var t;return e?(t=r?r+e:e,this._events[t]&&s(this,t)):(this._events=new i,this._eventsCount=0),this},c.prototype.off=c.prototype.removeListener,c.prototype.addListener=c.prototype.on,c.prefixed=r,c.EventEmitter=c,t!==void 0&&(t.exports=c)}))(),1),F=class e extends Error{name=`TimeoutError`;constructor(t,n){super(t,n),Error.captureStackTrace?.(this,e)}};const I=e=>e.reason??new DOMException(`This operation was aborted.`,`AbortError`);function L(e,t){let{milliseconds:n,fallback:r,message:i,customTimers:a={setTimeout,clearTimeout},signal:o}=t,s,c,l=new Promise((t,l)=>{if(typeof n!=`number`||Math.sign(n)!==1)throw TypeError(`Expected \`milliseconds\` to be a positive number, got \`${n}\``);if(o?.aborted){l(I(o));return}if(o&&(c=()=>{l(I(o))},o.addEventListener(`abort`,c,{once:!0})),e.then(t,l),n===1/0)return;let u=new F;s=a.setTimeout.call(void 0,()=>{if(r){try{t(r())}catch(e){l(e)}return}typeof e.cancel==`function`&&e.cancel(),i===!1?t():i instanceof Error?l(i):(u.message=i??`Promise timed out after ${n} milliseconds`,l(u))},n)}).finally(()=>{l.clear(),c&&o&&o.removeEventListener(`abort`,c)});return l.clear=()=>{a.clearTimeout.call(void 0,s),s=void 0},l}function R(e,t,n){let r=0,i=e.length;for(;i>0;){let a=Math.trunc(i/2),o=r+a;n(e[o],t)<=0?(r=++o,i-=a+1):i=a}return r}var z=class{#e=[];enqueue(e,t){let{priority:n=0,id:r}=t??{},i={priority:n,id:r,run:e};if(this.size===0||this.#e[this.size-1].priority>=n){this.#e.push(i);return}let a=R(this.#e,i,(e,t)=>t.priority-e.priority);this.#e.splice(a,0,i)}setPriority(e,t){let n=this.#e.findIndex(t=>t.id===e);if(n===-1)throw ReferenceError(`No promise function with the id "${e}" exists in the queue.`);let[r]=this.#e.splice(n,1);this.enqueue(r.run,{priority:t,id:e})}dequeue(){return this.#e.shift()?.run}filter(e){return this.#e.filter(t=>t.priority===e.priority).map(e=>e.run)}get size(){return this.#e.length}},B=class extends P.default{#e;#t;#n=0;#r;#i=!1;#a=!1;#o;#s=0;#c=0;#l;#u;#d;#f;#p=0;#m;#h;#g=1n;#_=new Map;timeout;constructor(e){if(super(),e={carryoverIntervalCount:!1,intervalCap:1/0,interval:0,concurrency:1/0,autoStart:!0,queueClass:z,...e},!(typeof e.intervalCap==`number`&&e.intervalCap>=1))throw TypeError(`Expected \`intervalCap\` to be a number from 1 and up, got \`${e.intervalCap?.toString()??``}\` (${typeof e.intervalCap})`);if(e.interval===void 0||!(Number.isFinite(e.interval)&&e.interval>=0))throw TypeError(`Expected \`interval\` to be a finite number >= 0, got \`${e.interval?.toString()??``}\` (${typeof e.interval})`);if(this.#e=e.carryoverIntervalCount??e.carryoverConcurrencyCount??!1,this.#t=e.intervalCap===1/0||e.interval===0,this.#r=e.intervalCap,this.#o=e.interval,this.#d=new e.queueClass,this.#f=e.queueClass,this.concurrency=e.concurrency,e.timeout!==void 0&&!(Number.isFinite(e.timeout)&&e.timeout>0))throw TypeError(`Expected \`timeout\` to be a positive finite number, got \`${e.timeout}\` (${typeof e.timeout})`);this.timeout=e.timeout,this.#h=e.autoStart===!1,this.#M()}get#v(){return this.#t||this.#n<this.#r}get#y(){return this.#p<this.#m}#b(){this.#p--,this.#p===0&&this.emit(`pendingZero`),this.#E(),this.emit(`next`)}#x(){this.#O(),this.#D(),this.#u=void 0}get#S(){let e=Date.now();if(this.#l===void 0){let t=this.#s-e;if(t<0){if(this.#c>0){let t=e-this.#c;if(t<this.#o)return this.#C(this.#o-t),!0}this.#n=this.#e?this.#p:0}else return this.#C(t),!0}return!1}#C(e){this.#u===void 0&&(this.#u=setTimeout(()=>{this.#x()},e))}#w(){this.#l&&=(clearInterval(this.#l),void 0)}#T(){this.#u&&=(clearTimeout(this.#u),void 0)}#E(){if(this.#d.size===0)return this.#w(),this.emit(`empty`),this.#p===0&&(this.#T(),this.emit(`idle`)),!1;let e=!1;if(!this.#h){let t=!this.#S;if(this.#v&&this.#y){let n=this.#d.dequeue();this.#t||(this.#n++,this.#N()),this.emit(`active`),this.#c=Date.now(),n(),t&&this.#D(),e=!0}}return e}#D(){this.#t||this.#l!==void 0||(this.#l=setInterval(()=>{this.#O()},this.#o),this.#s=Date.now()+this.#o)}#O(){this.#n===0&&this.#p===0&&this.#l&&this.#w(),this.#n=this.#e?this.#p:0,this.#k(),this.#N()}#k(){for(;this.#E(););}get concurrency(){return this.#m}set concurrency(e){if(!(typeof e==`number`&&e>=1))throw TypeError(`Expected \`concurrency\` to be a number from 1 and up, got \`${e}\` (${typeof e})`);this.#m=e,this.#k()}async#A(e){return new Promise((t,n)=>{e.addEventListener(`abort`,()=>{n(e.reason)},{once:!0})})}setPriority(e,t){if(typeof t!=`number`||!Number.isFinite(t))throw TypeError(`Expected \`priority\` to be a finite number, got \`${t}\` (${typeof t})`);this.#d.setPriority(e,t)}async add(e,t={}){return t.id??=(this.#g++).toString(),t={timeout:this.timeout,...t},new Promise((n,r)=>{let i=Symbol(`task-${t.id}`);this.#d.enqueue(async()=>{this.#p++,this.#_.set(i,{id:t.id,priority:t.priority??0,startTime:Date.now(),timeout:t.timeout});try{try{t.signal?.throwIfAborted()}catch(e){throw this.#t||this.#n--,this.#_.delete(i),e}let r=e({signal:t.signal});t.timeout&&(r=L(Promise.resolve(r),{milliseconds:t.timeout,message:`Task timed out after ${t.timeout}ms (queue has ${this.#p} running, ${this.#d.size} waiting)`})),t.signal&&(r=Promise.race([r,this.#A(t.signal)]));let a=await r;n(a),this.emit(`completed`,a)}catch(e){r(e),this.emit(`error`,e)}finally{this.#_.delete(i),queueMicrotask(()=>{this.#b()})}},t),this.emit(`add`),this.#E()})}async addAll(e,t){return Promise.all(e.map(async e=>this.add(e,t)))}start(){return this.#h?(this.#h=!1,this.#k(),this):this}pause(){this.#h=!0}clear(){this.#d=new this.#f,this.#P()}async onEmpty(){this.#d.size!==0&&await this.#j(`empty`)}async onSizeLessThan(e){this.#d.size<e||await this.#j(`next`,()=>this.#d.size<e)}async onIdle(){this.#p===0&&this.#d.size===0||await this.#j(`idle`)}async onPendingZero(){this.#p!==0&&await this.#j(`pendingZero`)}async onRateLimit(){this.isRateLimited||await this.#j(`rateLimit`)}async onRateLimitCleared(){this.isRateLimited&&await this.#j(`rateLimitCleared`)}async onError(){return new Promise((e,t)=>{let n=e=>{this.off(`error`,n),t(e)};this.on(`error`,n)})}async#j(e,t){return new Promise(n=>{let r=()=>{t&&!t()||(this.off(e,r),n())};this.on(e,r)})}get size(){return this.#d.size}sizeBy(e){return this.#d.filter(e).length}get pending(){return this.#p}get isPaused(){return this.#h}#M(){this.#t||(this.on(`add`,()=>{this.#d.size>0&&this.#N()}),this.on(`next`,()=>{this.#N()}))}#N(){this.#t||this.#a||(this.#a=!0,queueMicrotask(()=>{this.#a=!1,this.#P()}))}#P(){let e=this.#i,t=!this.#t&&this.#n>=this.#r&&this.#d.size>0;t!==e&&(this.#i=t,this.emit(t?`rateLimit`:`rateLimitCleared`))}get isRateLimited(){return this.#i}get isSaturated(){return this.#p===this.#m&&this.#d.size>0||this.isRateLimited&&this.#d.size>0}get runningTasks(){return[...this.#_.values()].map(e=>({...e}))}},V=c((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.instanceOfHashable=e.guessType=e.guessObjectType=e.TYPE_MAP=void 0,e.TYPE_MAP={Array:`array`,Int8Array:`typedarray`,Uint8Array:`typedarray`,Uint8ClampedArray:`typedarray`,Int16Array:`typedarray`,Uint16Array:`typedarray`,Int32Array:`typedarray`,Uint32Array:`typedarray`,Float32Array:`typedarray`,Float64Array:`typedarray`,BigUint64Array:`typedarray`,BigInt64Array:`typedarray`,Buffer:`typedarray`,Map:`map`,Set:`set`,Date:`date`,String:`string`,Number:`number`,BigInt:`bigint`,Boolean:`boolean`,Object:`object`},e.guessObjectType=t=>{if(t===null)return`null`;if((0,e.instanceOfHashable)(t))return`hashable`;let n=t?.constructor?.name??`unknown`;return e.TYPE_MAP[n]||`unknown`},e.guessType=t=>{let n=typeof t;return n===`object`?(0,e.guessObjectType)(t):n},e.instanceOfHashable=e=>typeof e.toHashableString==`function`})),H=c((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e._mapSort=e._map=e._objectSort=e._object=e._setCoerce=e._set=e._setSort=e._setSortCoerce=e._typedArray=e._typedArraySort=e._array=e._arraySort=e._date=e._dateCoerce=e._functionTrim=e._functionTrimCoerce=e._function=e._functionCoerce=e._null=e._nullCoerce=e._undefined=e._undefinedCoerce=e._symbol=e._symbolCoerce=e._boolean=e._booleanCoerce=e._bigInt=e._bigIntCoerce=e._number=e._numberCoerce=e._stringTrim=e._stringTrimCoerce=e._string=e._stringCoerce=e._hashable=e.PREFIX=void 0;let t=V();e.PREFIX={string:`<:s>`,number:`<:n>`,bigint:`<:bi>`,boolean:`<:b>`,symbol:`<:smbl>`,undefined:`<:undf>`,null:`<:null>`,function:`<:func>`,array:``,date:`<:date>`,set:`<:set>`,map:`<:map>`};function n(e){return e.toHashableString()}e._hashable=n;function r(e){return e}e._stringCoerce=r;function i(t){return e.PREFIX.string+`:`+t}e._string=i;function a(e){return e.replace(/(\s+|\t|\r\n|\n|\r)/gm,` `).trim()}e._stringTrimCoerce=a;function o(t){return e.PREFIX.string+`:`+t.replace(/(\s+|\t|\r\n|\n|\r)/gm,` `).trim()}e._stringTrim=o;function s(e){return e.toString()}e._numberCoerce=s;function c(t){return`${e.PREFIX.number}:${t}`}e._number=c;function l(e){return e.toString()}e._bigIntCoerce=l;function u(t){return`${e.PREFIX.bigint}:${t.toString()}`}e._bigInt=u;function d(e){return e?`1`:`0`}e._booleanCoerce=d;function f(t){return e.PREFIX.boolean+`:`+t.toString()}e._boolean=f;function p(){return e.PREFIX.symbol}e._symbolCoerce=p;function m(t){return e.PREFIX.symbol+`:`+t.toString()}e._symbol=m;function h(){return``}e._undefinedCoerce=h;function g(){return e.PREFIX.undefined}e._undefined=g;function _(){return``}e._nullCoerce=_;function v(){return e.PREFIX.null}e._null=v;function y(e){return e.name+`=>`+e.toString()}e._functionCoerce=y;function b(t){return e.PREFIX.function+`:`+t.name+`=>`+t.toString()}e._function=b;function x(e){return e.name+`=>`+e.toString().replace(/(\s+|\t|\r\n|\n|\r)/gm,` `).trim()}e._functionTrimCoerce=x;function S(t){return e.PREFIX.function+`:`+t.name+`=>`+t.toString().replace(/(\s+|\t|\r\n|\n|\r)/gm,` `).trim()}e._functionTrim=S;function C(e){return e.toISOString()}e._dateCoerce=C;function w(t){return e.PREFIX.date+`:`+t.toISOString()}e._date=w;function T(e){let n=this;return`[`+e.map(e=>n[(0,t.guessType)(e)](e)).sort().toString()+`]`}e._arraySort=T;function E(e){let n=this;return`[`+e.map(e=>n[(0,t.guessType)(e)](e)).toString()+`]`}e._array=E;function D(e){let n=this;return`[`+Array.prototype.slice.call(e).map(e=>n[(0,t.guessType)(e)](e)).sort().toString()+`]`}e._typedArraySort=D;function O(e){let n=this;return`[`+Array.prototype.slice.call(e).map(e=>n[(0,t.guessType)(e)](e)).toString()+`]`}e._typedArray=O;function k(e){return T.call(this,Array.from(e))}e._setSortCoerce=k;function A(t){return`${e.PREFIX.set}:${T.call(this,Array.from(t))}`}e._setSort=A;function j(t){return`${e.PREFIX.set}:${E.call(this,Array.from(t))}`}e._set=j;function M(e){return E.call(this,Array.from(e))}e._setCoerce=M;function N(e){let n=this,r=Object.keys(e),i=[];for(let a of r){let r=e[a],o=(0,t.guessType)(r);i.push(a+`:`+n[o](r))}return`{`+i.toString()+`}`}e._object=N;function P(e){let n=this,r=Object.keys(e).sort(),i=[];for(let a of r){let r=e[a],o=(0,t.guessType)(r);i.push(a+`:`+n[o](r))}return`{`+i.toString()+`}`}e._objectSort=P;function F(e){let n=this,r=Array.from(e),i=[];for(let e of r){let[r,a]=e;i.push([n[(0,t.guessType)(r)](r),n[(0,t.guessType)(a)](a)])}return`[`+i.join(`;`)+`]`}e._map=F;function I(e){let n=this,r=Array.from(e),i=[];for(let e of r){let[r,a]=e;i.push([n[(0,t.guessType)(r)](r),n[(0,t.guessType)(a)](a)])}return`[`+i.sort().join(`;`)+`]`}e._mapSort=I})),U=c((e=>{var t=e&&e.__createBinding||(Object.create?(function(e,t,n,r){r===void 0&&(r=n);var i=Object.getOwnPropertyDescriptor(t,n);(!i||(`get`in i?!t.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,r,i)}):(function(e,t,n,r){r===void 0&&(r=n),e[r]=t[n]})),n=e&&e.__setModuleDefault||(Object.create?(function(e,t){Object.defineProperty(e,`default`,{enumerable:!0,value:t})}):function(e,t){e.default=t}),r=e&&e.__importStar||function(e){if(e&&e.__esModule)return e;var r={};if(e!=null)for(var i in e)i!==`default`&&Object.prototype.hasOwnProperty.call(e,i)&&t(r,e,i);return n(r,e),r};Object.defineProperty(e,`__esModule`,{value:!0}),e.objectSorter=void 0;let i=r(H()),a=V();e.objectSorter=e=>{let{sort:t,coerce:n,trim:r}={sort:!0,coerce:!0,trim:!1,...e},o={array:typeof t==`boolean`?t:t?.array??!1,typedArray:typeof t==`boolean`?!1:t?.typedArray??!1,object:typeof t==`boolean`?t:t?.object??!1,set:typeof t==`boolean`?t:t?.set??!1,map:typeof t==`boolean`?t:t?.map??!1},s={boolean:typeof n==`boolean`?n:n?.boolean??!1,number:typeof n==`boolean`?n:n?.number??!1,bigint:typeof n==`boolean`?n:n?.bigint??!1,string:typeof n==`boolean`?n:n?.string??!1,undefined:typeof n==`boolean`?n:n?.undefined??!1,null:typeof n==`boolean`?n:n?.null??!1,symbol:typeof n==`boolean`?n:n?.symbol??!1,function:typeof n==`boolean`?n:n?.function??!1,date:typeof n==`boolean`?n:n?.date??!1,set:typeof n==`boolean`?n:n?.set??!1},c={string:typeof r==`boolean`?r:r?.string??!1,function:typeof r==`boolean`?r:r?.function??!1},l={unknown:function(e){let t=e.constructor?.name??`unknonw`,n=`unknown`;return typeof e.toString==`function`?n=e.toString():Object.keys(e).length>0&&(n=JSON.stringify(e)),`<:${t}>:${n}`}};l.hashable=i._hashable.bind(l),c.string?l.string=s.string?i._stringTrimCoerce.bind(l):i._stringTrim.bind(l):l.string=s.string?i._stringCoerce.bind(l):i._string.bind(l),l.number=s.number?i._numberCoerce.bind(l):i._number.bind(l),l.bigint=s.bigint?i._bigIntCoerce.bind(l):i._bigInt.bind(l),l.boolean=s.boolean?i._booleanCoerce.bind(l):i._boolean.bind(l),l.symbol=s.symbol?i._symbolCoerce.bind(l):i._symbol.bind(l),l.undefined=s.undefined?i._undefinedCoerce.bind(l):i._undefined.bind(l),l.null=s.null?i._nullCoerce.bind(l):i._null.bind(l),c.function?l.function=s.function?i._functionTrimCoerce.bind(l):i._functionTrim.bind(l):l.function=s.function?i._functionCoerce.bind(l):i._function.bind(l),l.date=s.date?i._dateCoerce.bind(l):i._date.bind(l),l.array=o.array?i._arraySort.bind(l):i._array.bind(l),l.typedarray=o.typedArray?i._typedArraySort.bind(l):i._typedArray.bind(l),o.set?l.set=s.set?i._setSortCoerce.bind(l):i._setSort.bind(l):l.set=s.set?i._setCoerce.bind(l):i._set.bind(l),l.object=o.object?i._objectSort.bind(l):i._object.bind(l),l.map=o.map?i._mapSort.bind(l):i._map.bind(l);function u(e){return l[(0,a.guessType)(e)](e)}return u}}));const{hash:W}=(0,u(c((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.hasher=void 0;let t=d(`crypto`),n=U();e.hasher=e=>{let r=(0,n.objectSorter)(e);return{hash:(n,i)=>{let a=i?.alg||e?.alg||`sha256`,o=i?.enc||e?.enc||`hex`,s=r(n);return(0,t.createHash)(a).update(s).digest(o)},sort:r,sortObject:r}}}))(),1).hasher)({sort:!0,coerce:!0});var G=W;const K={},q=e=>(t,{cacheTimeMs:n,staleTimeMs:r=0,calculateKey:i=G,revalidationConcurrency:a=1,prefix:o=`default`,shouldStore:s=()=>!0}={})=>async(...c)=>{let l=`${t.name}:${o}:${i?i(c):G(c)}`,u=`${t.name}:${o}`;K[u]=K[u]??new B({concurrency:a}),K[u].concurrency=a;let d=await e.getItem(l),f=async()=>{let i=await t(...c);return s(i)&&await e.setItem(l,i,{ttl:n??null,staleTtl:r}),i};return n===0&&r===0?t(...c):d&&!d.meta.expired?d.content:d?.meta.expired&&d?.meta.stale?(K[u].runningTasks.some(e=>e.id===l&&e.startTime)||K[u].add(f,{id:l}),d.content):await f()};export{p as CacheContainer,m as FallbackStorage,N as LRUStorage,q as withCacheFactory};
1
+ import{createRequire as e}from"node:module";import{debug as t}from"node:util";var n=Object.create,r=Object.defineProperty,i=Object.getOwnPropertyDescriptor,a=Object.getOwnPropertyNames,o=Object.getPrototypeOf,s=Object.prototype.hasOwnProperty,c=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),l=(e,t,n,o)=>{if(t&&typeof t==`object`||typeof t==`function`)for(var c=a(t),l=0,u=c.length,d;l<u;l++)d=c[l],!s.call(e,d)&&d!==n&&r(e,d,{get:(e=>t[e]).bind(null,d),enumerable:!(o=i(t,d))||o.enumerable});return e},u=(e,t,i)=>(i=e==null?{}:n(o(e)),l(t||!e||!e.__esModule?r(i,`default`,{value:e,enumerable:!0}):i,e)),d=e(import.meta.url);const f=t(`node-ts-cache`);var p=class{constructor(e){this.storage=e}async getItem(e){let t=await this.storage.getItem(e);if(!t)return;let n=this.isStaleItem(t),r=this.isItemExpired(t),i;i=n?`stale`:r?`expired`:`fresh`;let a={content:t.content,meta:{...t.meta,state:i}};if(a.meta.state===`expired`){await this.unsetKey(e);return}return a}async setItem(e,t,n){let r={ttl:null,staleTtl:null,...n};r.staleTtl&&r.ttl&&r.staleTtl<r.ttl&&(f(`staleTtl (${r.staleTtl}ms) is less than ttl (${r.ttl}ms); adjusting staleTtl to be ttl+staleTtl`),r.staleTtl=r.ttl+r.staleTtl);let i={createdAt:Date.now(),ttl:r.ttl,staleTtl:r.staleTtl};await this.storage.setItem(e,{meta:i,content:t})}async clear(){await this.storage.clear(),f(`Cleared cache`)}isItemExpired(e){return e.meta.ttl===null?!1:Date.now()>e.meta.createdAt+e.meta.ttl}isStaleItem(e){return!this.isItemExpired(e)||e.meta.staleTtl==null?!1:Date.now()<=e.meta.createdAt+e.meta.staleTtl}async unsetKey(e){await this.storage.removeItem(e)}},m=class{storages;constructor(e){this.storages=e}async clear(){await Promise.all([...this.storages.map(e=>e.clear())])}async getItem(e){for(let t=0;t<this.storages.length;t++){let n=await this.storages[t]?.getItem(e);if(n!==void 0)return t!==0&&await Promise.all(this.storages.slice(0,t).map(t=>t.setItem(e,n))),n}}async setItem(e,t){let[n,...r]=this.storages;await n.setItem(e,t),Promise.all(r.map(n=>n.setItem(e,t)))}async removeItem(e){await Promise.all(this.storages.map(t=>t.removeItem(e)))}},h=c((e=>{var t=function(e,t){return e<t?-1:e>t?1:0},n=function(e,t){return e<t?1:e>t?-1:0};function r(e){return function(t,n){return e(n,t)}}function i(e){return e===2?function(e,t){return e[0]<t[0]?-1:e[0]>t[0]?1:e[1]<t[1]?-1:e[1]>t[1]?1:0}:function(t,n){for(var r=0;r<e;){if(t[r]<n[r])return-1;if(t[r]>n[r])return 1;r++}return 0}}e.DEFAULT_COMPARATOR=t,e.DEFAULT_REVERSE_COMPARATOR=n,e.reverseComparator=r,e.createTupleComparator=i})),g=c((e=>{e.ARRAY_BUFFER_SUPPORT=typeof ArrayBuffer<`u`,e.SYMBOL_SUPPORT=typeof Symbol<`u`})),_=c(((e,t)=>{var n=g(),r=n.ARRAY_BUFFER_SUPPORT,i=n.SYMBOL_SUPPORT;t.exports=function(e,t){var n,a,o,s,c;if(!e)throw Error(`obliterator/forEach: invalid iterable.`);if(typeof t!=`function`)throw Error(`obliterator/forEach: expecting a callback.`);if(Array.isArray(e)||r&&ArrayBuffer.isView(e)||typeof e==`string`||e.toString()===`[object Arguments]`){for(o=0,s=e.length;o<s;o++)t(e[o],o);return}if(typeof e.forEach==`function`){e.forEach(t);return}if(i&&Symbol.iterator in e&&typeof e.next!=`function`&&(e=e[Symbol.iterator]()),typeof e.next==`function`){for(n=e,o=0;c=n.next(),c.done!==!0;)t(c.value,o),o++;return}for(a in e)e.hasOwnProperty(a)&&t(e[a],a)}})),v=c(((e,t)=>{var n=h(),r=_(),i=n.DEFAULT_COMPARATOR,a=n.reverseComparator;function o(e){if(this.clear(),this.comparator=e||i,typeof this.comparator!=`function`)throw Error(`mnemonist/FibonacciHeap.constructor: given comparator should be a function.`)}o.prototype.clear=function(){this.root=null,this.min=null,this.size=0};function s(e){return{item:e,degree:0}}function c(e,t){e.root?(t.right=e.root.right,t.left=e.root,e.root.right.left=t,e.root.right=t):e.root=t}o.prototype.push=function(e){var t=s(e);return t.left=t,t.right=t,c(this,t),(!this.min||this.comparator(t.item,this.min.item)<=0)&&(this.min=t),++this.size},o.prototype.peek=function(){return this.min?this.min.item:void 0};function l(e){for(var t=[],n=e,r=!1;!(n===e&&r);)n===e&&(r=!0),t.push(n),n=n.right;return t}function u(e,t){e.root===t&&(e.root=t.right),t.left.right=t.right,t.right.left=t.left}function d(e,t){e.child?(t.right=e.child.right,t.left=e.child,e.child.right.left=t,e.child.right=t):e.child=t}function f(e,t,n){u(e,t),t.left=t,t.right=t,d(n,t),n.degree++,t.parent=n}function p(e){var t=Array(e.size),n=l(e.root),r,i,a,o,s,c;for(r=0,i=n.length;r<i;r++){for(a=n[r],s=a.degree;t[s];)o=t[s],e.comparator(a.item,o.item)>0&&(c=a,a=o,o=c),f(e,o,a),t[s]=null,s++;t[s]=a}for(r=0;r<e.size;r++)t[r]&&e.comparator(t[r].item,e.min.item)<=0&&(e.min=t[r])}o.prototype.pop=function(){if(this.size){var e=this.min;if(e.child){var t=l(e.child),n,r,i;for(r=0,i=t.length;r<i;r++)n=t[r],c(this,n),delete n.parent}return u(this,e),e===e.right?(this.min=null,this.root=null):(this.min=e.right,p(this)),this.size--,e.item}},o.prototype.inspect=function(){var e={size:this.size};return this.min&&`item`in this.min&&(e.top=this.min.item),Object.defineProperty(e,`constructor`,{value:o,enumerable:!1}),e},typeof Symbol<`u`&&(o.prototype[Symbol.for(`nodejs.util.inspect.custom`)]=o.prototype.inspect);function m(e){if(this.clear(),this.comparator=e||i,typeof this.comparator!=`function`)throw Error(`mnemonist/FibonacciHeap.constructor: given comparator should be a function.`);this.comparator=a(this.comparator)}m.prototype=o.prototype,o.from=function(e,t){var n=new o(t);return r(e,function(e){n.push(e)}),n},m.from=function(e,t){var n=new m(t);return r(e,function(e){n.push(e)}),n},o.MinFibonacciHeap=o,o.MaxFibonacciHeap=m,t.exports=o})),y=c((e=>{var t=2**8-1,n=2**16-1,r=2**32-1,i=2**7-1,a=2**15-1,o=2**31-1;e.getPointerArray=function(e){var i=e-1;if(i<=t)return Uint8Array;if(i<=n)return Uint16Array;if(i<=r)return Uint32Array;throw Error(`mnemonist: Pointer Array of size > 4294967295 is not supported.`)},e.getSignedPointerArray=function(e){var t=e-1;return t<=i?Int8Array:t<=a?Int16Array:t<=o?Int32Array:Float64Array},e.getNumberType=function(e){return e===(e|0)?Math.sign(e)===-1?e<=127&&e>=-128?Int8Array:e<=32767&&e>=-32768?Int16Array:Int32Array:e<=255?Uint8Array:e<=65535?Uint16Array:Uint32Array:Float64Array};var s={Uint8Array:1,Int8Array:2,Uint16Array:3,Int16Array:4,Uint32Array:5,Int32Array:6,Float32Array:7,Float64Array:8};e.getMinimalRepresentation=function(t,n){var r=null,i=0,a,o,c,l,u;for(l=0,u=t.length;l<u;l++)c=n?n(t[l]):t[l],o=e.getNumberType(c),a=s[o.name],a>i&&(i=a,r=o);return r},e.isTypedArray=function(e){return typeof ArrayBuffer<`u`&&ArrayBuffer.isView(e)},e.concat=function(){var e=0,t,n,r;for(t=0,r=arguments.length;t<r;t++)e+=arguments[t].length;var i=new arguments[0].constructor(e);for(t=0,n=0;t<r;t++)i.set(arguments[t],n),n+=arguments[t].length;return i},e.indices=function(t){for(var n=new(e.getPointerArray(t))(t),r=0;r<t;r++)n[r]=r;return n}})),b=c((e=>{var t=_(),n=y();function r(e){return Array.isArray(e)||n.isTypedArray(e)}function i(e){if(typeof e.length==`number`)return e.length;if(typeof e.size==`number`)return e.size}function a(e){var n=i(e),r=typeof n==`number`?Array(n):[],a=0;return t(e,function(e){r[a++]=e}),r}function o(e){var r=i(e),a=typeof r==`number`?n.getPointerArray(r):Array,o=typeof r==`number`?Array(r):[],s=typeof r==`number`?new a(r):[],c=0;return t(e,function(e){o[c]=e,s[c]=c++}),[o,s]}e.isArrayLike=r,e.guessLength=i,e.toArray=a,e.toArrayWithIndices=o})),x=c(((e,t)=>{var n=_(),r=h(),i=b(),a=r.DEFAULT_COMPARATOR,o=r.reverseComparator;function s(e,t,n,r){for(var i=t[r],a,o;r>n;){if(a=r-1>>1,o=t[a],e(i,o)<0){t[r]=o,r=a;continue}break}t[r]=i}function c(e,t,n){for(var r=t.length,i=n,a=t[n],o=2*n+1,c;o<r;)c=o+1,c<r&&e(t[o],t[c])>=0&&(o=c),t[n]=t[o],n=o,o=2*n+1;t[n]=a,s(e,t,i,n)}function l(e,t,n){t.push(n),s(e,t,0,t.length-1)}function u(e,t){var n=t.pop();if(t.length!==0){var r=t[0];return t[0]=n,c(e,t,0),r}return n}function d(e,t,n){if(t.length===0)throw Error(`mnemonist/heap.replace: cannot pop an empty heap.`);var r=t[0];return t[0]=n,c(e,t,0),r}function f(e,t,n){var r;return t.length!==0&&e(t[0],n)<0&&(r=t[0],t[0]=n,n=r,c(e,t,0)),n}function p(e,t){for(var n=t.length>>1;--n>=0;)c(e,t,n)}function m(e,t){for(var n=t.length,r=0,i=Array(n);r<n;)i[r++]=u(e,t);return i}function g(e,t,r){arguments.length===2&&(r=t,t=e,e=a);var s=o(e),c,l,u,f=1/0,m;if(t===1){if(i.isArrayLike(r)){for(c=0,l=r.length;c<l;c++)u=r[c],(f===1/0||e(u,f)<0)&&(f=u);return m=new r.constructor(1),m[0]=f,m}return n(r,function(t){(f===1/0||e(t,f)<0)&&(f=t)}),[f]}if(i.isArrayLike(r)){if(t>=r.length)return r.slice().sort(e);for(m=r.slice(0,t),p(s,m),c=t,l=r.length;c<l;c++)s(r[c],m[0])>0&&d(s,m,r[c]);return m.sort(e)}var h=i.guessLength(r);return h!==null&&h<t&&(t=h),m=Array(t),c=0,n(r,function(e){c<t?m[c]=e:(c===t&&p(s,m),s(e,m[0])>0&&d(s,m,e)),c++}),m.length>c&&(m.length=c),m.sort(e)}function v(e,t,r){arguments.length===2&&(r=t,t=e,e=a);var s=o(e),c,l,u,f=-1/0,m;if(t===1){if(i.isArrayLike(r)){for(c=0,l=r.length;c<l;c++)u=r[c],(f===-1/0||e(u,f)>0)&&(f=u);return m=new r.constructor(1),m[0]=f,m}return n(r,function(t){(f===-1/0||e(t,f)>0)&&(f=t)}),[f]}if(i.isArrayLike(r)){if(t>=r.length)return r.slice().sort(s);for(m=r.slice(0,t),p(e,m),c=t,l=r.length;c<l;c++)e(r[c],m[0])>0&&d(e,m,r[c]);return m.sort(s)}var h=i.guessLength(r);return h!==null&&h<t&&(t=h),m=Array(t),c=0,n(r,function(n){c<t?m[c]=n:(c===t&&p(e,m),e(n,m[0])>0&&d(e,m,n)),c++}),m.length>c&&(m.length=c),m.sort(s)}function y(e){if(this.clear(),this.comparator=e||a,typeof this.comparator!=`function`)throw Error(`mnemonist/Heap.constructor: given comparator should be a function.`)}y.prototype.clear=function(){this.items=[],this.size=0},y.prototype.push=function(e){return l(this.comparator,this.items,e),++this.size},y.prototype.peek=function(){return this.items[0]},y.prototype.pop=function(){return this.size!==0&&this.size--,u(this.comparator,this.items)},y.prototype.replace=function(e){return d(this.comparator,this.items,e)},y.prototype.pushpop=function(e){return f(this.comparator,this.items,e)},y.prototype.consume=function(){return this.size=0,m(this.comparator,this.items)},y.prototype.toArray=function(){return m(this.comparator,this.items.slice())},y.prototype.inspect=function(){var e=this.toArray();return Object.defineProperty(e,`constructor`,{value:y,enumerable:!1}),e},typeof Symbol<`u`&&(y.prototype[Symbol.for(`nodejs.util.inspect.custom`)]=y.prototype.inspect);function x(e){if(this.clear(),this.comparator=e||a,typeof this.comparator!=`function`)throw Error(`mnemonist/MaxHeap.constructor: given comparator should be a function.`);this.comparator=o(this.comparator)}x.prototype=y.prototype,y.from=function(e,t){var n=new y(t),r=i.isArrayLike(e)?e.slice():i.toArray(e);return p(n.comparator,r),n.items=r,n.size=r.length,n},x.from=function(e,t){var n=new x(t),r=i.isArrayLike(e)?e.slice():i.toArray(e);return p(n.comparator,r),n.items=r,n.size=r.length,n},y.siftUp=c,y.siftDown=s,y.push=l,y.pop=u,y.replace=d,y.pushpop=f,y.heapify=p,y.consume=m,y.nsmallest=g,y.nlargest=v,y.MinHeap=y,y.MaxHeap=x,t.exports=y})),S=c(((e,t)=>{var n=``;function r(e,t,n){for(var r=t.length,i=[],a=r,o=-1,s,c=0,l;a--;)o=Math.max(e[t[a]+n],o);for(l=o>>24&&32||o>>16&&24||o>>8&&16||8;c<l;c+=4){for(a=16;a--;)i[a]=[];for(a=r;a--;)i[e[t[a]+n]>>c&15].push(t[a]);for(s=0;s<16;s++)for(o=i[s].length;o--;)t[++a]=i[s][o]}}function i(e,t,n,r){return e[n]-e[r]||(n%3==2?e[n+1]-e[r+1]||t[n+2]-t[r+2]:t[n+1]-t[r+1])}function a(e,t){var n=[],o=[],s=2*t/3|0,c=t-s,l=s+1>>1,u=s,d=0,f,p=[],m=[];if(t===1)return[0];for(;u--;)n[u]=(u*3>>1)+1;for(u=3;u--;)r(e,n,u);for(d=o[(n[0]/3|0)+(n[0]%3==1?0:l)]=1,u=1;u<s;u++)(e[n[u]]!==e[n[u-1]]||e[n[u]+1]!==e[n[u-1]+1]||e[n[u]+2]!==e[n[u-1]+2])&&d++,o[(n[u]/3|0)+(n[u]%3==1?0:l)]=d;if(d<s)for(o=a(o,s),u=s;u--;)n[u]=o[u]<l?o[u]*3+1:(o[u]-l)*3+2;for(u=s;u--;)p[n[u]]=u;for(p[t]=-1,p[t+1]=-2,o=t%3==1?[t-1]:[],u=0;u<s;u++)n[u]%3==1&&o.push(n[u]-1);for(r(e,o,0),u=0,d=0,f=0;u<s&&d<c;)m[f++]=i(e,p,n[u],o[d])<0?n[u++]:o[d++];for(;u<s;)m[f++]=n[u++];for(;d<c;)m[f++]=o[d++];return m}function o(e){var t=e.length,n=t%3,r=Array(t+n),i,a;if(typeof e!=`string`){var o=Object.create(null);for(a=0;a<t;a++)o[e[a]]||(o[e[a]]=!0);var s=Object.create(null),c=Object.keys(o).sort();for(a=0,i=c.length;a<i;a++)s[c[a]]=a+1;for(a=0;a<t;a++)r[a]=s[e[a]]}else for(a=0;a<t;a++)r[a]=e.charCodeAt(a);for(a=t;a<t+n;a++)r[a]=0;return r}function s(e){this.hasArbitrarySequence=typeof e!=`string`,this.string=e,this.length=e.length,this.array=a(o(e),this.length)}s.prototype.toString=function(){return this.array.join(`,`)},s.prototype.toJSON=function(){return this.array},s.prototype.inspect=function(){for(var e=Array(this.length),t=0;t<this.length;t++)e[t]=this.string.slice(this.array[t]);return Object.defineProperty(e,`constructor`,{value:s,enumerable:!1}),e},typeof Symbol<`u`&&(s.prototype[Symbol.for(`nodejs.util.inspect.custom`)]=s.prototype.inspect);function c(e){if(this.hasArbitrarySequence=typeof e[0]!=`string`,this.size=e.length,this.hasArbitrarySequence){this.text=[];for(var t=0,r=this.size;t<r;t++)this.text.push.apply(this.text,e[t]),t<r-1&&this.text.push(n)}else this.text=e.join(n);this.firstLength=e[0].length,this.length=this.text.length,this.array=a(o(this.text),this.length)}c.prototype.longestCommonSubsequence=function(){var e=this.hasArbitrarySequence?[]:``,t,n,r,i,a;for(n=1;n<this.length;n++)if(i=this.array[n],a=this.array[n-1],!(i<this.firstLength&&a<this.firstLength)&&!(i>this.firstLength&&a>this.firstLength)){for(t=Math.min(this.length-i,this.length-a),r=0;r<t;r++)if(this.text[i+r]!==this.text[a+r]){t=r;break}t>e.length&&(e=this.text.slice(i,i+t))}return e},c.prototype.toString=function(){return this.array.join(`,`)},c.prototype.toJSON=function(){return this.array},c.prototype.inspect=function(){for(var e=Array(this.length),t=0;t<this.length;t++)e[t]=this.text.slice(this.array[t]);return Object.defineProperty(e,`constructor`,{value:c,enumerable:!1}),e},typeof Symbol<`u`&&(c.prototype[Symbol.for(`nodejs.util.inspect.custom`)]=c.prototype.inspect),s.GeneralizedSuffixArray=c,t.exports=s})),C=c(((e,t)=>{function n(e){if(typeof e!=`function`)throw Error(`obliterator/iterator: expecting a function!`);this.next=e}typeof Symbol<`u`&&(n.prototype[Symbol.iterator]=function(){return this}),n.of=function(){var e=arguments,t=e.length,r=0;return new n(function(){return r>=t?{done:!0}:{done:!1,value:e[r++]}})},n.empty=function(){return new n(function(){return{done:!0}})},n.fromSequence=function(e){var t=0,r=e.length;return new n(function(){return t>=r?{done:!0}:{done:!1,value:e[t++]}})},n.is=function(e){return e instanceof n?!0:typeof e==`object`&&!!e&&typeof e.next==`function`},t.exports=n})),w=c(((e,t)=>{var n=C(),r=_(),i=b(),a=y(),o=function(e){return Math.max(1,Math.ceil(e*1.5))},s=function(e){return new(a.getPointerArray(e))(e)};function c(e,t){if(arguments.length<1)throw Error(`mnemonist/vector: expecting at least a byte array constructor.`);var n=t||0,r=o,i=0,a=!1;typeof t==`object`&&(n=t.initialCapacity||0,i=t.initialLength||0,r=t.policy||r,a=t.factory===!0),this.factory=a?e:null,this.ArrayClass=e,this.length=i,this.capacity=Math.max(i,n),this.policy=r,this.array=new e(this.capacity)}c.prototype.set=function(e,t){if(this.length<e)throw Error(`Vector(`+this.ArrayClass.name+`).set: index out of bounds.`);return this.array[e]=t,this},c.prototype.get=function(e){if(!(this.length<e))return this.array[e]},c.prototype.applyPolicy=function(e){var t=this.policy(e||this.capacity);if(typeof t!=`number`||t<0)throw Error(`mnemonist/vector.applyPolicy: policy returned an invalid value (expecting a positive integer).`);if(t<=this.capacity)throw Error(`mnemonist/vector.applyPolicy: policy returned a less or equal capacity to allocate.`);return t},c.prototype.reallocate=function(e){if(e===this.capacity)return this;var t=this.array;if(e<this.length&&(this.length=e),e>this.capacity)if(this.factory===null?this.array=new this.ArrayClass(e):this.array=this.factory(e),a.isTypedArray(this.array))this.array.set(t,0);else for(var n=0,r=this.length;n<r;n++)this.array[n]=t[n];else this.array=t.slice(0,e);return this.capacity=e,this},c.prototype.grow=function(e){var t;if(typeof e==`number`){if(this.capacity>=e)return this;for(t=this.capacity;t<e;)t=this.applyPolicy(t);return this.reallocate(t),this}return t=this.applyPolicy(),this.reallocate(t),this},c.prototype.resize=function(e){return e===this.length?this:e<this.length?(this.length=e,this):(this.length=e,this.reallocate(e),this)},c.prototype.push=function(e){return this.capacity===this.length&&this.grow(),this.array[this.length++]=e,this.length},c.prototype.pop=function(){if(this.length!==0)return this.array[--this.length]},c.prototype.values=function(){var e=this.array,t=this.length,r=0;return new n(function(){if(r>=t)return{done:!0};var n=e[r];return r++,{value:n,done:!1}})},c.prototype.entries=function(){var e=this.array,t=this.length,r=0;return new n(function(){if(r>=t)return{done:!0};var n=e[r];return{value:[r++,n],done:!1}})},typeof Symbol<`u`&&(c.prototype[Symbol.iterator]=c.prototype.values),c.prototype.inspect=function(){var e=this.array.slice(0,this.length);return e.type=this.array.constructor.name,e.items=this.length,e.capacity=this.capacity,Object.defineProperty(e,`constructor`,{value:c,enumerable:!1}),e},typeof Symbol<`u`&&(c.prototype[Symbol.for(`nodejs.util.inspect.custom`)]=c.prototype.inspect),c.from=function(e,t,n){if(arguments.length<3&&(n=i.guessLength(e),typeof n!=`number`))throw Error(`mnemonist/vector.from: could not guess iterable length. Please provide desired capacity as last argument.`);var a=new c(t,n);return r(e,function(e){a.push(e)}),a};function l(e){var t=function(t){c.call(this,e,t)};for(var n in c.prototype)c.prototype.hasOwnProperty(n)&&(t.prototype[n]=c.prototype[n]);return t.from=function(t,n){return c.from(t,e,n)},typeof Symbol<`u`&&(t.prototype[Symbol.iterator]=t.prototype.values),t}c.Int8Vector=l(Int8Array),c.Uint8Vector=l(Uint8Array),c.Uint8ClampedVector=l(Uint8ClampedArray),c.Int16Vector=l(Int16Array),c.Uint16Vector=l(Uint16Array),c.Int32Vector=l(Int32Array),c.Uint32Vector=l(Uint32Array),c.Float32Vector=l(Float32Array),c.Float64Vector=l(Float64Array),c.PointerVector=l(s),t.exports=c})),T=c(((e,t)=>{var n=C(),r=_(),i=y(),a=b();function o(e,t,n){if(arguments.length<2&&(n=e,e=null,t=null),this.capacity=n,typeof this.capacity!=`number`||this.capacity<=0)throw Error(`mnemonist/lru-cache: capacity should be positive number.`);if(!isFinite(this.capacity)||Math.floor(this.capacity)!==this.capacity)throw Error(`mnemonist/lru-cache: capacity should be a finite positive integer.`);var r=i.getPointerArray(n);this.forward=new r(n),this.backward=new r(n),this.K=typeof e==`function`?new e(n):Array(n),this.V=typeof t==`function`?new t(n):Array(n),this.size=0,this.head=0,this.tail=0,this.items={}}o.prototype.clear=function(){this.size=0,this.head=0,this.tail=0,this.items={}},o.prototype.splayOnTop=function(e){var t=this.head;if(this.head===e)return this;var n=this.backward[e],r=this.forward[e];return this.tail===e?this.tail=n:this.backward[r]=n,this.forward[n]=r,this.backward[t]=e,this.head=e,this.forward[e]=t,this},o.prototype.set=function(e,t){var n=this.items[e];if(n!==void 0){this.splayOnTop(n),this.V[n]=t;return}this.size<this.capacity?n=this.size++:(n=this.tail,this.tail=this.backward[n],delete this.items[this.K[n]]),this.items[e]=n,this.K[n]=e,this.V[n]=t,this.forward[n]=this.head,this.backward[this.head]=n,this.head=n},o.prototype.setpop=function(e,t){var n=null,r=null,i=this.items[e];return i===void 0?(this.size<this.capacity?i=this.size++:(i=this.tail,this.tail=this.backward[i],n=this.V[i],r=this.K[i],delete this.items[r]),this.items[e]=i,this.K[i]=e,this.V[i]=t,this.forward[i]=this.head,this.backward[this.head]=i,this.head=i,r?{evicted:!0,key:r,value:n}:null):(this.splayOnTop(i),n=this.V[i],this.V[i]=t,{evicted:!1,key:e,value:n})},o.prototype.has=function(e){return e in this.items},o.prototype.get=function(e){var t=this.items[e];if(t!==void 0)return this.splayOnTop(t),this.V[t]},o.prototype.peek=function(e){var t=this.items[e];if(t!==void 0)return this.V[t]},o.prototype.forEach=function(e,t){t=arguments.length>1?t:this;for(var n=0,r=this.size,i=this.head,a=this.K,o=this.V,s=this.forward;n<r;)e.call(t,o[i],a[i],this),i=s[i],n++},o.prototype.keys=function(){var e=0,t=this.size,r=this.head,i=this.K,a=this.forward;return new n(function(){if(e>=t)return{done:!0};var n=i[r];return e++,e<t&&(r=a[r]),{done:!1,value:n}})},o.prototype.values=function(){var e=0,t=this.size,r=this.head,i=this.V,a=this.forward;return new n(function(){if(e>=t)return{done:!0};var n=i[r];return e++,e<t&&(r=a[r]),{done:!1,value:n}})},o.prototype.entries=function(){var e=0,t=this.size,r=this.head,i=this.K,a=this.V,o=this.forward;return new n(function(){if(e>=t)return{done:!0};var n=i[r],s=a[r];return e++,e<t&&(r=o[r]),{done:!1,value:[n,s]}})},typeof Symbol<`u`&&(o.prototype[Symbol.iterator]=o.prototype.entries),o.prototype.inspect=function(){for(var e=new Map,t=this.entries(),n;n=t.next(),!n.done;)e.set(n.value[0],n.value[1]);return Object.defineProperty(e,`constructor`,{value:o,enumerable:!1}),e},typeof Symbol<`u`&&(o.prototype[Symbol.for(`nodejs.util.inspect.custom`)]=o.prototype.inspect),o.from=function(e,t,n,i){if(arguments.length<2){if(i=a.guessLength(e),typeof i!=`number`)throw Error(`mnemonist/lru-cache.from: could not guess iterable length. Please provide desired capacity as last argument.`)}else arguments.length===2&&(i=t,t=null,n=null);var s=new o(t,n,i);return r(e,function(e,t){s.set(t,e)}),s},t.exports=o})),E=c(((e,t)=>{var n=T(),r=_(),i=y(),a=b();function o(e,t,n){if(arguments.length<2&&(n=e,e=null,t=null),this.capacity=n,typeof this.capacity!=`number`||this.capacity<=0)throw Error(`mnemonist/lru-map: capacity should be positive number.`);if(!isFinite(this.capacity)||Math.floor(this.capacity)!==this.capacity)throw Error(`mnemonist/lru-map: capacity should be a finite positive integer.`);var r=i.getPointerArray(n);this.forward=new r(n),this.backward=new r(n),this.K=typeof e==`function`?new e(n):Array(n),this.V=typeof t==`function`?new t(n):Array(n),this.size=0,this.head=0,this.tail=0,this.items=new Map}o.prototype.clear=function(){this.size=0,this.head=0,this.tail=0,this.items.clear()},o.prototype.set=function(e,t){var n=this.items.get(e);if(n!==void 0){this.splayOnTop(n),this.V[n]=t;return}this.size<this.capacity?n=this.size++:(n=this.tail,this.tail=this.backward[n],this.items.delete(this.K[n])),this.items.set(e,n),this.K[n]=e,this.V[n]=t,this.forward[n]=this.head,this.backward[this.head]=n,this.head=n},o.prototype.setpop=function(e,t){var n=null,r=null,i=this.items.get(e);return i===void 0?(this.size<this.capacity?i=this.size++:(i=this.tail,this.tail=this.backward[i],n=this.V[i],r=this.K[i],this.items.delete(r)),this.items.set(e,i),this.K[i]=e,this.V[i]=t,this.forward[i]=this.head,this.backward[this.head]=i,this.head=i,r?{evicted:!0,key:r,value:n}:null):(this.splayOnTop(i),n=this.V[i],this.V[i]=t,{evicted:!1,key:e,value:n})},o.prototype.has=function(e){return this.items.has(e)},o.prototype.get=function(e){var t=this.items.get(e);if(t!==void 0)return this.splayOnTop(t),this.V[t]},o.prototype.peek=function(e){var t=this.items.get(e);if(t!==void 0)return this.V[t]},o.prototype.splayOnTop=n.prototype.splayOnTop,o.prototype.forEach=n.prototype.forEach,o.prototype.keys=n.prototype.keys,o.prototype.values=n.prototype.values,o.prototype.entries=n.prototype.entries,typeof Symbol<`u`&&(o.prototype[Symbol.iterator]=o.prototype.entries),o.prototype.inspect=n.prototype.inspect,o.from=function(e,t,n,i){if(arguments.length<2){if(i=a.guessLength(e),typeof i!=`number`)throw Error(`mnemonist/lru-cache.from: could not guess iterable length. Please provide desired capacity as last argument.`)}else arguments.length===2&&(i=t,t=null,n=null);var s=new o(t,n,i);return r(e,function(e,t){s.set(t,e)}),s},t.exports=o})),D=c(((e,t)=>{var n=E(),r=_(),i=y(),a=b();function o(e,t,r){arguments.length<2?n.call(this,e):n.call(this,e,t,r),this.deleted=new(i.getPointerArray(this.capacity))(this.capacity),this.deletedSize=0}for(var s in n.prototype)o.prototype[s]=n.prototype[s];typeof Symbol<`u`&&(o.prototype[Symbol.iterator]=n.prototype[Symbol.iterator]),o.prototype.clear=function(){n.prototype.clear.call(this),this.deletedSize=0},o.prototype.set=function(e,t){var n=this.items.get(e);if(n!==void 0){this.splayOnTop(n),this.V[n]=t;return}this.size<this.capacity?(n=this.deletedSize>0?this.deleted[--this.deletedSize]:this.size,this.size++):(n=this.tail,this.tail=this.backward[n],this.items.delete(this.K[n])),this.items.set(e,n),this.K[n]=e,this.V[n]=t,this.forward[n]=this.head,this.backward[this.head]=n,this.head=n},o.prototype.setpop=function(e,t){var n=null,r=null,i=this.items.get(e);return i===void 0?(this.size<this.capacity?(i=this.deletedSize>0?this.deleted[--this.deletedSize]:this.size,this.size++):(i=this.tail,this.tail=this.backward[i],n=this.V[i],r=this.K[i],this.items.delete(r)),this.items.set(e,i),this.K[i]=e,this.V[i]=t,this.forward[i]=this.head,this.backward[this.head]=i,this.head=i,r?{evicted:!0,key:r,value:n}:null):(this.splayOnTop(i),n=this.V[i],this.V[i]=t,{evicted:!1,key:e,value:n})},o.prototype.delete=function(e){var t=this.items.get(e);if(t===void 0)return!1;if(this.items.delete(e),this.size===1)return this.size=0,this.head=0,this.tail=0,this.deletedSize=0,!0;var n=this.backward[t],r=this.forward[t];return this.head===t&&(this.head=r),this.tail===t&&(this.tail=n),this.forward[n]=r,this.backward[r]=n,this.size--,this.deleted[this.deletedSize++]=t,!0},o.prototype.remove=function(e,t=void 0){var n=this.items.get(e);if(n===void 0)return t;var r=this.V[n];if(this.items.delete(e),this.size===1)return this.size=0,this.head=0,this.tail=0,this.deletedSize=0,r;var i=this.backward[n],a=this.forward[n];return this.head===n&&(this.head=a),this.tail===n&&(this.tail=i),this.forward[i]=a,this.backward[a]=i,this.size--,this.deleted[this.deletedSize++]=n,r},o.from=function(e,t,n,i){if(arguments.length<2){if(i=a.guessLength(e),typeof i!=`number`)throw Error(`mnemonist/lru-map.from: could not guess iterable length. Please provide desired capacity as last argument.`)}else arguments.length===2&&(i=t,t=null,n=null);var s=new o(t,n,i);return r(e,function(e,t){s.set(t,e)}),s},t.exports=o})),O=u(v(),1),k=u(x(),1),A=u(S(),1),j=u(w(),1),M=u(D(),1);O.default.MinFibonacciHeap,O.default.MaxFibonacciHeap,k.default.MinHeap,k.default.MaxHeap,A.default.GeneralizedSuffixArray,j.default.Uint8Vector,j.default.Uint8ClampedVector,j.default.Int8Vector,j.default.Uint16Vector,j.default.Int16Vector,j.default.Uint32Vector,j.default.Int32Vector,j.default.Float32Vector,j.default.Float64Vector,j.default.PointerVector;var N=class{cache;constructor({max:e=1e4}={}){this.cache=new M.default(e)}async clear(){this.cache.clear()}async getItem(e){return this.cache.get(e)}async setItem(e,t){this.cache.set(e,t)}async removeItem(e){this.cache.delete(e)}},P=u(c(((e,t)=>{var n=Object.prototype.hasOwnProperty,r=`~`;function i(){}Object.create&&(i.prototype=Object.create(null),new i().__proto__||(r=!1));function a(e,t,n){this.fn=e,this.context=t,this.once=n||!1}function o(e,t,n,i,o){if(typeof n!=`function`)throw TypeError(`The listener must be a function`);var s=new a(n,i||e,o),c=r?r+t:t;return e._events[c]?e._events[c].fn?e._events[c]=[e._events[c],s]:e._events[c].push(s):(e._events[c]=s,e._eventsCount++),e}function s(e,t){--e._eventsCount===0?e._events=new i:delete e._events[t]}function c(){this._events=new i,this._eventsCount=0}c.prototype.eventNames=function(){var e=[],t,i;if(this._eventsCount===0)return e;for(i in t=this._events)n.call(t,i)&&e.push(r?i.slice(1):i);return Object.getOwnPropertySymbols?e.concat(Object.getOwnPropertySymbols(t)):e},c.prototype.listeners=function(e){var t=r?r+e:e,n=this._events[t];if(!n)return[];if(n.fn)return[n.fn];for(var i=0,a=n.length,o=Array(a);i<a;i++)o[i]=n[i].fn;return o},c.prototype.listenerCount=function(e){var t=r?r+e:e,n=this._events[t];return n?n.fn?1:n.length:0},c.prototype.emit=function(e,t,n,i,a,o){var s=r?r+e:e;if(!this._events[s])return!1;var c=this._events[s],l=arguments.length,u,d;if(c.fn){switch(c.once&&this.removeListener(e,c.fn,void 0,!0),l){case 1:return c.fn.call(c.context),!0;case 2:return c.fn.call(c.context,t),!0;case 3:return c.fn.call(c.context,t,n),!0;case 4:return c.fn.call(c.context,t,n,i),!0;case 5:return c.fn.call(c.context,t,n,i,a),!0;case 6:return c.fn.call(c.context,t,n,i,a,o),!0}for(d=1,u=Array(l-1);d<l;d++)u[d-1]=arguments[d];c.fn.apply(c.context,u)}else{var f=c.length,p;for(d=0;d<f;d++)switch(c[d].once&&this.removeListener(e,c[d].fn,void 0,!0),l){case 1:c[d].fn.call(c[d].context);break;case 2:c[d].fn.call(c[d].context,t);break;case 3:c[d].fn.call(c[d].context,t,n);break;case 4:c[d].fn.call(c[d].context,t,n,i);break;default:if(!u)for(p=1,u=Array(l-1);p<l;p++)u[p-1]=arguments[p];c[d].fn.apply(c[d].context,u)}}return!0},c.prototype.on=function(e,t,n){return o(this,e,t,n,!1)},c.prototype.once=function(e,t,n){return o(this,e,t,n,!0)},c.prototype.removeListener=function(e,t,n,i){var a=r?r+e:e;if(!this._events[a])return this;if(!t)return s(this,a),this;var o=this._events[a];if(o.fn)o.fn===t&&(!i||o.once)&&(!n||o.context===n)&&s(this,a);else{for(var c=0,l=[],u=o.length;c<u;c++)(o[c].fn!==t||i&&!o[c].once||n&&o[c].context!==n)&&l.push(o[c]);l.length?this._events[a]=l.length===1?l[0]:l:s(this,a)}return this},c.prototype.removeAllListeners=function(e){var t;return e?(t=r?r+e:e,this._events[t]&&s(this,t)):(this._events=new i,this._eventsCount=0),this},c.prototype.off=c.prototype.removeListener,c.prototype.addListener=c.prototype.on,c.prefixed=r,c.EventEmitter=c,t!==void 0&&(t.exports=c)}))(),1),F=class e extends Error{name=`TimeoutError`;constructor(t,n){super(t,n),Error.captureStackTrace?.(this,e)}};const I=e=>e.reason??new DOMException(`This operation was aborted.`,`AbortError`);function L(e,t){let{milliseconds:n,fallback:r,message:i,customTimers:a={setTimeout,clearTimeout},signal:o}=t,s,c,l=new Promise((t,l)=>{if(typeof n!=`number`||Math.sign(n)!==1)throw TypeError(`Expected \`milliseconds\` to be a positive number, got \`${n}\``);if(o?.aborted){l(I(o));return}if(o&&(c=()=>{l(I(o))},o.addEventListener(`abort`,c,{once:!0})),e.then(t,l),n===1/0)return;let u=new F;s=a.setTimeout.call(void 0,()=>{if(r){try{t(r())}catch(e){l(e)}return}typeof e.cancel==`function`&&e.cancel(),i===!1?t():i instanceof Error?l(i):(u.message=i??`Promise timed out after ${n} milliseconds`,l(u))},n)}).finally(()=>{l.clear(),c&&o&&o.removeEventListener(`abort`,c)});return l.clear=()=>{a.clearTimeout.call(void 0,s),s=void 0},l}function R(e,t,n){let r=0,i=e.length;for(;i>0;){let a=Math.trunc(i/2),o=r+a;n(e[o],t)<=0?(r=++o,i-=a+1):i=a}return r}var z=class{#e=[];enqueue(e,t){let{priority:n=0,id:r}=t??{},i={priority:n,id:r,run:e};if(this.size===0||this.#e[this.size-1].priority>=n){this.#e.push(i);return}let a=R(this.#e,i,(e,t)=>t.priority-e.priority);this.#e.splice(a,0,i)}setPriority(e,t){let n=this.#e.findIndex(t=>t.id===e);if(n===-1)throw ReferenceError(`No promise function with the id "${e}" exists in the queue.`);let[r]=this.#e.splice(n,1);this.enqueue(r.run,{priority:t,id:e})}dequeue(){return this.#e.shift()?.run}filter(e){return this.#e.filter(t=>t.priority===e.priority).map(e=>e.run)}get size(){return this.#e.length}},B=class extends P.default{#e;#t;#n=0;#r;#i=!1;#a=!1;#o;#s=0;#c=0;#l;#u;#d;#f;#p=0;#m;#h;#g=1n;#_=new Map;timeout;constructor(e){if(super(),e={carryoverIntervalCount:!1,intervalCap:1/0,interval:0,concurrency:1/0,autoStart:!0,queueClass:z,...e},!(typeof e.intervalCap==`number`&&e.intervalCap>=1))throw TypeError(`Expected \`intervalCap\` to be a number from 1 and up, got \`${e.intervalCap?.toString()??``}\` (${typeof e.intervalCap})`);if(e.interval===void 0||!(Number.isFinite(e.interval)&&e.interval>=0))throw TypeError(`Expected \`interval\` to be a finite number >= 0, got \`${e.interval?.toString()??``}\` (${typeof e.interval})`);if(this.#e=e.carryoverIntervalCount??e.carryoverConcurrencyCount??!1,this.#t=e.intervalCap===1/0||e.interval===0,this.#r=e.intervalCap,this.#o=e.interval,this.#d=new e.queueClass,this.#f=e.queueClass,this.concurrency=e.concurrency,e.timeout!==void 0&&!(Number.isFinite(e.timeout)&&e.timeout>0))throw TypeError(`Expected \`timeout\` to be a positive finite number, got \`${e.timeout}\` (${typeof e.timeout})`);this.timeout=e.timeout,this.#h=e.autoStart===!1,this.#M()}get#v(){return this.#t||this.#n<this.#r}get#y(){return this.#p<this.#m}#b(){this.#p--,this.#p===0&&this.emit(`pendingZero`),this.#E(),this.emit(`next`)}#x(){this.#O(),this.#D(),this.#u=void 0}get#S(){let e=Date.now();if(this.#l===void 0){let t=this.#s-e;if(t<0){if(this.#c>0){let t=e-this.#c;if(t<this.#o)return this.#C(this.#o-t),!0}this.#n=this.#e?this.#p:0}else return this.#C(t),!0}return!1}#C(e){this.#u===void 0&&(this.#u=setTimeout(()=>{this.#x()},e))}#w(){this.#l&&=(clearInterval(this.#l),void 0)}#T(){this.#u&&=(clearTimeout(this.#u),void 0)}#E(){if(this.#d.size===0)return this.#w(),this.emit(`empty`),this.#p===0&&(this.#T(),this.emit(`idle`)),!1;let e=!1;if(!this.#h){let t=!this.#S;if(this.#v&&this.#y){let n=this.#d.dequeue();this.#t||(this.#n++,this.#N()),this.emit(`active`),this.#c=Date.now(),n(),t&&this.#D(),e=!0}}return e}#D(){this.#t||this.#l!==void 0||(this.#l=setInterval(()=>{this.#O()},this.#o),this.#s=Date.now()+this.#o)}#O(){this.#n===0&&this.#p===0&&this.#l&&this.#w(),this.#n=this.#e?this.#p:0,this.#k(),this.#N()}#k(){for(;this.#E(););}get concurrency(){return this.#m}set concurrency(e){if(!(typeof e==`number`&&e>=1))throw TypeError(`Expected \`concurrency\` to be a number from 1 and up, got \`${e}\` (${typeof e})`);this.#m=e,this.#k()}async#A(e){return new Promise((t,n)=>{e.addEventListener(`abort`,()=>{n(e.reason)},{once:!0})})}setPriority(e,t){if(typeof t!=`number`||!Number.isFinite(t))throw TypeError(`Expected \`priority\` to be a finite number, got \`${t}\` (${typeof t})`);this.#d.setPriority(e,t)}async add(e,t={}){return t.id??=(this.#g++).toString(),t={timeout:this.timeout,...t},new Promise((n,r)=>{let i=Symbol(`task-${t.id}`);this.#d.enqueue(async()=>{this.#p++,this.#_.set(i,{id:t.id,priority:t.priority??0,startTime:Date.now(),timeout:t.timeout});try{try{t.signal?.throwIfAborted()}catch(e){throw this.#t||this.#n--,this.#_.delete(i),e}let r=e({signal:t.signal});t.timeout&&(r=L(Promise.resolve(r),{milliseconds:t.timeout,message:`Task timed out after ${t.timeout}ms (queue has ${this.#p} running, ${this.#d.size} waiting)`})),t.signal&&(r=Promise.race([r,this.#A(t.signal)]));let a=await r;n(a),this.emit(`completed`,a)}catch(e){r(e),this.emit(`error`,e)}finally{this.#_.delete(i),queueMicrotask(()=>{this.#b()})}},t),this.emit(`add`),this.#E()})}async addAll(e,t){return Promise.all(e.map(async e=>this.add(e,t)))}start(){return this.#h?(this.#h=!1,this.#k(),this):this}pause(){this.#h=!0}clear(){this.#d=new this.#f,this.#P()}async onEmpty(){this.#d.size!==0&&await this.#j(`empty`)}async onSizeLessThan(e){this.#d.size<e||await this.#j(`next`,()=>this.#d.size<e)}async onIdle(){this.#p===0&&this.#d.size===0||await this.#j(`idle`)}async onPendingZero(){this.#p!==0&&await this.#j(`pendingZero`)}async onRateLimit(){this.isRateLimited||await this.#j(`rateLimit`)}async onRateLimitCleared(){this.isRateLimited&&await this.#j(`rateLimitCleared`)}async onError(){return new Promise((e,t)=>{let n=e=>{this.off(`error`,n),t(e)};this.on(`error`,n)})}async#j(e,t){return new Promise(n=>{let r=()=>{t&&!t()||(this.off(e,r),n())};this.on(e,r)})}get size(){return this.#d.size}sizeBy(e){return this.#d.filter(e).length}get pending(){return this.#p}get isPaused(){return this.#h}#M(){this.#t||(this.on(`add`,()=>{this.#d.size>0&&this.#N()}),this.on(`next`,()=>{this.#N()}))}#N(){this.#t||this.#a||(this.#a=!0,queueMicrotask(()=>{this.#a=!1,this.#P()}))}#P(){let e=this.#i,t=!this.#t&&this.#n>=this.#r&&this.#d.size>0;t!==e&&(this.#i=t,this.emit(t?`rateLimit`:`rateLimitCleared`))}get isRateLimited(){return this.#i}get isSaturated(){return this.#p===this.#m&&this.#d.size>0||this.isRateLimited&&this.#d.size>0}get runningTasks(){return[...this.#_.values()].map(e=>({...e}))}},V=c((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.instanceOfHashable=e.guessType=e.guessObjectType=e.TYPE_MAP=void 0,e.TYPE_MAP={Array:`array`,Int8Array:`typedarray`,Uint8Array:`typedarray`,Uint8ClampedArray:`typedarray`,Int16Array:`typedarray`,Uint16Array:`typedarray`,Int32Array:`typedarray`,Uint32Array:`typedarray`,Float32Array:`typedarray`,Float64Array:`typedarray`,BigUint64Array:`typedarray`,BigInt64Array:`typedarray`,Buffer:`typedarray`,Map:`map`,Set:`set`,Date:`date`,String:`string`,Number:`number`,BigInt:`bigint`,Boolean:`boolean`,Object:`object`},e.guessObjectType=t=>{if(t===null)return`null`;if((0,e.instanceOfHashable)(t))return`hashable`;let n=t?.constructor?.name??`unknown`;return e.TYPE_MAP[n]||`unknown`},e.guessType=t=>{let n=typeof t;return n===`object`?(0,e.guessObjectType)(t):n},e.instanceOfHashable=e=>typeof e.toHashableString==`function`})),H=c((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e._mapSort=e._map=e._objectSort=e._object=e._setCoerce=e._set=e._setSort=e._setSortCoerce=e._typedArray=e._typedArraySort=e._array=e._arraySort=e._date=e._dateCoerce=e._functionTrim=e._functionTrimCoerce=e._function=e._functionCoerce=e._null=e._nullCoerce=e._undefined=e._undefinedCoerce=e._symbol=e._symbolCoerce=e._boolean=e._booleanCoerce=e._bigInt=e._bigIntCoerce=e._number=e._numberCoerce=e._stringTrim=e._stringTrimCoerce=e._string=e._stringCoerce=e._hashable=e.PREFIX=void 0;let t=V();e.PREFIX={string:`<:s>`,number:`<:n>`,bigint:`<:bi>`,boolean:`<:b>`,symbol:`<:smbl>`,undefined:`<:undf>`,null:`<:null>`,function:`<:func>`,array:``,date:`<:date>`,set:`<:set>`,map:`<:map>`};function n(e){return e.toHashableString()}e._hashable=n;function r(e){return e}e._stringCoerce=r;function i(t){return e.PREFIX.string+`:`+t}e._string=i;function a(e){return e.replace(/(\s+|\t|\r\n|\n|\r)/gm,` `).trim()}e._stringTrimCoerce=a;function o(t){return e.PREFIX.string+`:`+t.replace(/(\s+|\t|\r\n|\n|\r)/gm,` `).trim()}e._stringTrim=o;function s(e){return e.toString()}e._numberCoerce=s;function c(t){return`${e.PREFIX.number}:${t}`}e._number=c;function l(e){return e.toString()}e._bigIntCoerce=l;function u(t){return`${e.PREFIX.bigint}:${t.toString()}`}e._bigInt=u;function d(e){return e?`1`:`0`}e._booleanCoerce=d;function f(t){return e.PREFIX.boolean+`:`+t.toString()}e._boolean=f;function p(){return e.PREFIX.symbol}e._symbolCoerce=p;function m(t){return e.PREFIX.symbol+`:`+t.toString()}e._symbol=m;function h(){return``}e._undefinedCoerce=h;function g(){return e.PREFIX.undefined}e._undefined=g;function _(){return``}e._nullCoerce=_;function v(){return e.PREFIX.null}e._null=v;function y(e){return e.name+`=>`+e.toString()}e._functionCoerce=y;function b(t){return e.PREFIX.function+`:`+t.name+`=>`+t.toString()}e._function=b;function x(e){return e.name+`=>`+e.toString().replace(/(\s+|\t|\r\n|\n|\r)/gm,` `).trim()}e._functionTrimCoerce=x;function S(t){return e.PREFIX.function+`:`+t.name+`=>`+t.toString().replace(/(\s+|\t|\r\n|\n|\r)/gm,` `).trim()}e._functionTrim=S;function C(e){return e.toISOString()}e._dateCoerce=C;function w(t){return e.PREFIX.date+`:`+t.toISOString()}e._date=w;function T(e){let n=this;return`[`+e.map(e=>n[(0,t.guessType)(e)](e)).sort().toString()+`]`}e._arraySort=T;function E(e){let n=this;return`[`+e.map(e=>n[(0,t.guessType)(e)](e)).toString()+`]`}e._array=E;function D(e){let n=this;return`[`+Array.prototype.slice.call(e).map(e=>n[(0,t.guessType)(e)](e)).sort().toString()+`]`}e._typedArraySort=D;function O(e){let n=this;return`[`+Array.prototype.slice.call(e).map(e=>n[(0,t.guessType)(e)](e)).toString()+`]`}e._typedArray=O;function k(e){return T.call(this,Array.from(e))}e._setSortCoerce=k;function A(t){return`${e.PREFIX.set}:${T.call(this,Array.from(t))}`}e._setSort=A;function j(t){return`${e.PREFIX.set}:${E.call(this,Array.from(t))}`}e._set=j;function M(e){return E.call(this,Array.from(e))}e._setCoerce=M;function N(e){let n=this,r=Object.keys(e),i=[];for(let a of r){let r=e[a],o=(0,t.guessType)(r);i.push(a+`:`+n[o](r))}return`{`+i.toString()+`}`}e._object=N;function P(e){let n=this,r=Object.keys(e).sort(),i=[];for(let a of r){let r=e[a],o=(0,t.guessType)(r);i.push(a+`:`+n[o](r))}return`{`+i.toString()+`}`}e._objectSort=P;function F(e){let n=this,r=Array.from(e),i=[];for(let e of r){let[r,a]=e;i.push([n[(0,t.guessType)(r)](r),n[(0,t.guessType)(a)](a)])}return`[`+i.join(`;`)+`]`}e._map=F;function I(e){let n=this,r=Array.from(e),i=[];for(let e of r){let[r,a]=e;i.push([n[(0,t.guessType)(r)](r),n[(0,t.guessType)(a)](a)])}return`[`+i.sort().join(`;`)+`]`}e._mapSort=I})),U=c((e=>{var t=e&&e.__createBinding||(Object.create?(function(e,t,n,r){r===void 0&&(r=n);var i=Object.getOwnPropertyDescriptor(t,n);(!i||(`get`in i?!t.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,r,i)}):(function(e,t,n,r){r===void 0&&(r=n),e[r]=t[n]})),n=e&&e.__setModuleDefault||(Object.create?(function(e,t){Object.defineProperty(e,`default`,{enumerable:!0,value:t})}):function(e,t){e.default=t}),r=e&&e.__importStar||function(e){if(e&&e.__esModule)return e;var r={};if(e!=null)for(var i in e)i!==`default`&&Object.prototype.hasOwnProperty.call(e,i)&&t(r,e,i);return n(r,e),r};Object.defineProperty(e,`__esModule`,{value:!0}),e.objectSorter=void 0;let i=r(H()),a=V();e.objectSorter=e=>{let{sort:t,coerce:n,trim:r}={sort:!0,coerce:!0,trim:!1,...e},o={array:typeof t==`boolean`?t:t?.array??!1,typedArray:typeof t==`boolean`?!1:t?.typedArray??!1,object:typeof t==`boolean`?t:t?.object??!1,set:typeof t==`boolean`?t:t?.set??!1,map:typeof t==`boolean`?t:t?.map??!1},s={boolean:typeof n==`boolean`?n:n?.boolean??!1,number:typeof n==`boolean`?n:n?.number??!1,bigint:typeof n==`boolean`?n:n?.bigint??!1,string:typeof n==`boolean`?n:n?.string??!1,undefined:typeof n==`boolean`?n:n?.undefined??!1,null:typeof n==`boolean`?n:n?.null??!1,symbol:typeof n==`boolean`?n:n?.symbol??!1,function:typeof n==`boolean`?n:n?.function??!1,date:typeof n==`boolean`?n:n?.date??!1,set:typeof n==`boolean`?n:n?.set??!1},c={string:typeof r==`boolean`?r:r?.string??!1,function:typeof r==`boolean`?r:r?.function??!1},l={unknown:function(e){let t=e.constructor?.name??`unknonw`,n=`unknown`;return typeof e.toString==`function`?n=e.toString():Object.keys(e).length>0&&(n=JSON.stringify(e)),`<:${t}>:${n}`}};l.hashable=i._hashable.bind(l),c.string?l.string=s.string?i._stringTrimCoerce.bind(l):i._stringTrim.bind(l):l.string=s.string?i._stringCoerce.bind(l):i._string.bind(l),l.number=s.number?i._numberCoerce.bind(l):i._number.bind(l),l.bigint=s.bigint?i._bigIntCoerce.bind(l):i._bigInt.bind(l),l.boolean=s.boolean?i._booleanCoerce.bind(l):i._boolean.bind(l),l.symbol=s.symbol?i._symbolCoerce.bind(l):i._symbol.bind(l),l.undefined=s.undefined?i._undefinedCoerce.bind(l):i._undefined.bind(l),l.null=s.null?i._nullCoerce.bind(l):i._null.bind(l),c.function?l.function=s.function?i._functionTrimCoerce.bind(l):i._functionTrim.bind(l):l.function=s.function?i._functionCoerce.bind(l):i._function.bind(l),l.date=s.date?i._dateCoerce.bind(l):i._date.bind(l),l.array=o.array?i._arraySort.bind(l):i._array.bind(l),l.typedarray=o.typedArray?i._typedArraySort.bind(l):i._typedArray.bind(l),o.set?l.set=s.set?i._setSortCoerce.bind(l):i._setSort.bind(l):l.set=s.set?i._setCoerce.bind(l):i._set.bind(l),l.object=o.object?i._objectSort.bind(l):i._object.bind(l),l.map=o.map?i._mapSort.bind(l):i._map.bind(l);function u(e){return l[(0,a.guessType)(e)](e)}return u}}));const{hash:W}=(0,u(c((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.hasher=void 0;let t=d(`crypto`),n=U();e.hasher=e=>{let r=(0,n.objectSorter)(e);return{hash:(n,i)=>{let a=i?.alg||e?.alg||`sha256`,o=i?.enc||e?.enc||`hex`,s=r(n);return(0,t.createHash)(a).update(s).digest(o)},sort:r,sortObject:r}}}))(),1).hasher)({sort:!0,coerce:!0});var G=W;const K={},q=e=>(t,{cacheTimeMs:n,staleTimeMs:r=0,calculateKey:i=G,revalidationConcurrency:a=1,prefix:o=`default`,shouldStore:s=()=>!0}={})=>async(...c)=>{let l=`${t.name}:${o}:${i?i(c):G(c)}`,u=`${t.name}:${o}`;K[u]=K[u]??new B({concurrency:a}),K[u].concurrency=a;let d=await e.getItem(l),f=async()=>{let i=await t(...c);return s(i)&&await e.setItem(l,i,{ttl:n??null,staleTtl:r}),i};return n===0&&r===0?t(...c):d&&!d.meta.expired?d.content:d?.meta.expired&&d?.meta.stale?(K[u].runningTasks.some(e=>e.id===l&&e.startTime)||K[u].add(f,{id:l}),d.content):await f()};export{p as CacheContainer,m as FallbackStorage,N as LRUStorage,q as withCacheFactory};
2
2
  //# sourceMappingURL=index.mjs.map