@enbox/crypto 0.0.2 → 0.0.4
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/README.md +34 -102
- package/dist/browser.mjs +6 -10
- package/dist/browser.mjs.map +4 -4
- package/dist/esm/algorithms/aes-ctr.js +1 -1
- package/dist/esm/algorithms/aes-gcm.js +35 -2
- package/dist/esm/algorithms/aes-gcm.js.map +1 -1
- package/dist/esm/algorithms/aes-kw.js +154 -0
- package/dist/esm/algorithms/aes-kw.js.map +1 -0
- package/dist/esm/algorithms/ecdsa.js +119 -6
- package/dist/esm/algorithms/ecdsa.js.map +1 -1
- package/dist/esm/algorithms/eddsa.js +99 -6
- package/dist/esm/algorithms/eddsa.js.map +1 -1
- package/dist/esm/algorithms/hkdf.js +53 -0
- package/dist/esm/algorithms/hkdf.js.map +1 -0
- package/dist/esm/algorithms/pbkdf2.js +55 -0
- package/dist/esm/algorithms/pbkdf2.js.map +1 -0
- package/dist/esm/algorithms/sha-2.js +2 -2
- package/dist/esm/algorithms/sha-2.js.map +1 -1
- package/dist/esm/algorithms/x25519.js +125 -0
- package/dist/esm/algorithms/x25519.js.map +1 -0
- package/dist/esm/crypto-error.js +41 -0
- package/dist/esm/crypto-error.js.map +1 -0
- package/dist/esm/index.js +8 -0
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/jose/jwk.js +52 -26
- package/dist/esm/jose/jwk.js.map +1 -1
- package/dist/esm/local-key-manager.js +9 -3
- package/dist/esm/local-key-manager.js.map +1 -1
- package/dist/esm/primitives/aes-ctr.js.map +1 -1
- package/dist/esm/primitives/aes-gcm.js.map +1 -1
- package/dist/esm/primitives/aes-kw.js +246 -0
- package/dist/esm/primitives/aes-kw.js.map +1 -0
- package/dist/esm/primitives/concat-kdf.js +1 -1
- package/dist/esm/primitives/concat-kdf.js.map +1 -1
- package/dist/esm/primitives/ecies-secp256k1.js +79 -0
- package/dist/esm/primitives/ecies-secp256k1.js.map +1 -0
- package/dist/esm/primitives/ed25519.js +3 -3
- package/dist/esm/primitives/ed25519.js.map +1 -1
- package/dist/esm/primitives/hkdf.js +79 -0
- package/dist/esm/primitives/hkdf.js.map +1 -0
- package/dist/esm/primitives/pbkdf2.js +49 -0
- package/dist/esm/primitives/pbkdf2.js.map +1 -1
- package/dist/esm/primitives/secp256k1.js +4 -4
- package/dist/esm/primitives/secp256k1.js.map +1 -1
- package/dist/esm/primitives/secp256r1.js +4 -4
- package/dist/esm/primitives/secp256r1.js.map +1 -1
- package/dist/esm/primitives/x25519.js +10 -17
- package/dist/esm/primitives/x25519.js.map +1 -1
- package/dist/esm/primitives/xchacha20-poly1305.js +48 -3
- package/dist/esm/primitives/xchacha20-poly1305.js.map +1 -1
- package/dist/esm/primitives/xchacha20.js +1 -1
- package/dist/esm/primitives/xchacha20.js.map +1 -1
- package/dist/esm/utils.js +30 -0
- package/dist/esm/utils.js.map +1 -1
- package/dist/types/algorithms/aes-ctr.d.ts +2 -2
- package/dist/types/algorithms/aes-ctr.d.ts.map +1 -1
- package/dist/types/algorithms/aes-gcm.d.ts +25 -5
- package/dist/types/algorithms/aes-gcm.d.ts.map +1 -1
- package/dist/types/algorithms/aes-kw.d.ts +129 -0
- package/dist/types/algorithms/aes-kw.d.ts.map +1 -0
- package/dist/types/algorithms/ecdsa.d.ts +49 -4
- package/dist/types/algorithms/ecdsa.d.ts.map +1 -1
- package/dist/types/algorithms/eddsa.d.ts +49 -4
- package/dist/types/algorithms/eddsa.d.ts.map +1 -1
- package/dist/types/algorithms/hkdf.d.ts +35 -0
- package/dist/types/algorithms/hkdf.d.ts.map +1 -0
- package/dist/types/algorithms/pbkdf2.d.ts +35 -0
- package/dist/types/algorithms/pbkdf2.d.ts.map +1 -0
- package/dist/types/algorithms/sha-2.d.ts +2 -2
- package/dist/types/algorithms/sha-2.d.ts.map +1 -1
- package/dist/types/algorithms/x25519.d.ts +76 -0
- package/dist/types/algorithms/x25519.d.ts.map +1 -0
- package/dist/types/crypto-error.d.ts +29 -0
- package/dist/types/crypto-error.d.ts.map +1 -0
- package/dist/types/index.d.ts +8 -0
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/jose/jwk.d.ts.map +1 -1
- package/dist/types/local-key-manager.d.ts +6 -6
- package/dist/types/local-key-manager.d.ts.map +1 -1
- package/dist/types/primitives/aes-kw.d.ts +103 -0
- package/dist/types/primitives/aes-kw.d.ts.map +1 -0
- package/dist/types/primitives/concat-kdf.d.ts +1 -1
- package/dist/types/primitives/concat-kdf.d.ts.map +1 -1
- package/dist/types/primitives/ecies-secp256k1.d.ts +53 -0
- package/dist/types/primitives/ecies-secp256k1.d.ts.map +1 -0
- package/dist/types/primitives/hkdf.d.ts +90 -0
- package/dist/types/primitives/hkdf.d.ts.map +1 -0
- package/dist/types/primitives/pbkdf2.d.ts +58 -0
- package/dist/types/primitives/pbkdf2.d.ts.map +1 -1
- package/dist/types/primitives/x25519.d.ts +9 -16
- package/dist/types/primitives/x25519.d.ts.map +1 -1
- package/dist/types/primitives/xchacha20-poly1305.d.ts +47 -0
- package/dist/types/primitives/xchacha20-poly1305.d.ts.map +1 -1
- package/dist/types/types/cipher.d.ts +1 -1
- package/dist/types/types/crypto-api.d.ts +54 -6
- package/dist/types/types/crypto-api.d.ts.map +1 -1
- package/dist/types/types/key-converter.d.ts +37 -15
- package/dist/types/types/key-converter.d.ts.map +1 -1
- package/dist/types/types/key-deriver.d.ts +41 -0
- package/dist/types/types/key-deriver.d.ts.map +1 -1
- package/dist/types/types/key-io.d.ts +37 -0
- package/dist/types/types/key-io.d.ts.map +1 -1
- package/dist/types/types/params-direct.d.ts +96 -1
- package/dist/types/types/params-direct.d.ts.map +1 -1
- package/dist/types/types/params-kms.d.ts +55 -0
- package/dist/types/types/params-kms.d.ts.map +1 -1
- package/dist/types/utils.d.ts +19 -0
- package/dist/types/utils.d.ts.map +1 -1
- package/dist/utils.js +1 -1
- package/dist/utils.js.map +4 -4
- package/package.json +29 -45
- package/src/algorithms/aes-ctr.ts +2 -2
- package/src/algorithms/aes-gcm.ts +41 -4
- package/src/algorithms/aes-kw.ts +182 -0
- package/src/algorithms/ecdsa.ts +145 -8
- package/src/algorithms/eddsa.ts +117 -10
- package/src/algorithms/hkdf.ts +54 -0
- package/src/algorithms/pbkdf2.ts +57 -0
- package/src/algorithms/sha-2.ts +3 -3
- package/src/algorithms/x25519.ts +153 -0
- package/src/crypto-error.ts +45 -0
- package/src/index.ts +8 -0
- package/src/jose/jwk.ts +32 -32
- package/src/local-key-manager.ts +22 -16
- package/src/primitives/aes-ctr.ts +1 -1
- package/src/primitives/aes-gcm.ts +5 -5
- package/src/primitives/aes-kw.ts +269 -0
- package/src/primitives/concat-kdf.ts +4 -2
- package/src/primitives/ecies-secp256k1.ts +113 -0
- package/src/primitives/ed25519.ts +6 -6
- package/src/primitives/hkdf.ts +121 -0
- package/src/primitives/pbkdf2.ts +91 -0
- package/src/primitives/secp256k1.ts +6 -6
- package/src/primitives/secp256r1.ts +6 -6
- package/src/primitives/x25519.ts +12 -19
- package/src/primitives/xchacha20-poly1305.ts +57 -4
- package/src/primitives/xchacha20.ts +1 -1
- package/src/types/cipher.ts +1 -1
- package/src/types/crypto-api.ts +129 -11
- package/src/types/key-converter.ts +33 -7
- package/src/types/key-deriver.ts +49 -0
- package/src/types/key-io.ts +40 -0
- package/src/types/params-direct.ts +118 -1
- package/src/types/params-kms.ts +67 -0
- package/src/utils.ts +55 -2
- package/dist/browser.js +0 -64
- package/dist/browser.js.map +0 -7
- package/dist/cjs/algorithms/aes-ctr.js +0 -188
- package/dist/cjs/algorithms/aes-ctr.js.map +0 -1
- package/dist/cjs/algorithms/aes-gcm.js +0 -196
- package/dist/cjs/algorithms/aes-gcm.js.map +0 -1
- package/dist/cjs/algorithms/crypto-algorithm.js +0 -13
- package/dist/cjs/algorithms/crypto-algorithm.js.map +0 -1
- package/dist/cjs/algorithms/ecdsa.js +0 -352
- package/dist/cjs/algorithms/ecdsa.js.map +0 -1
- package/dist/cjs/algorithms/eddsa.js +0 -325
- package/dist/cjs/algorithms/eddsa.js.map +0 -1
- package/dist/cjs/algorithms/sha-2.js +0 -119
- package/dist/cjs/algorithms/sha-2.js.map +0 -1
- package/dist/cjs/index.js +0 -41
- package/dist/cjs/index.js.map +0 -1
- package/dist/cjs/jose/jwe.js +0 -3
- package/dist/cjs/jose/jwe.js.map +0 -1
- package/dist/cjs/jose/jwk.js +0 -278
- package/dist/cjs/jose/jwk.js.map +0 -1
- package/dist/cjs/jose/jws.js +0 -3
- package/dist/cjs/jose/jws.js.map +0 -1
- package/dist/cjs/jose/jwt.js +0 -3
- package/dist/cjs/jose/jwt.js.map +0 -1
- package/dist/cjs/jose/utils.js +0 -60
- package/dist/cjs/jose/utils.js.map +0 -1
- package/dist/cjs/local-key-manager.js +0 -521
- package/dist/cjs/local-key-manager.js.map +0 -1
- package/dist/cjs/package.json +0 -1
- package/dist/cjs/primitives/aes-ctr.js +0 -398
- package/dist/cjs/primitives/aes-ctr.js.map +0 -1
- package/dist/cjs/primitives/aes-gcm.js +0 -425
- package/dist/cjs/primitives/aes-gcm.js.map +0 -1
- package/dist/cjs/primitives/concat-kdf.js +0 -215
- package/dist/cjs/primitives/concat-kdf.js.map +0 -1
- package/dist/cjs/primitives/ed25519.js +0 -651
- package/dist/cjs/primitives/ed25519.js.map +0 -1
- package/dist/cjs/primitives/pbkdf2.js +0 -120
- package/dist/cjs/primitives/pbkdf2.js.map +0 -1
- package/dist/cjs/primitives/secp256k1.js +0 -958
- package/dist/cjs/primitives/secp256k1.js.map +0 -1
- package/dist/cjs/primitives/secp256r1.js +0 -959
- package/dist/cjs/primitives/secp256r1.js.map +0 -1
- package/dist/cjs/primitives/sha256.js +0 -93
- package/dist/cjs/primitives/sha256.js.map +0 -1
- package/dist/cjs/primitives/x25519.js +0 -498
- package/dist/cjs/primitives/x25519.js.map +0 -1
- package/dist/cjs/primitives/xchacha20-poly1305.js +0 -340
- package/dist/cjs/primitives/xchacha20-poly1305.js.map +0 -1
- package/dist/cjs/primitives/xchacha20.js +0 -316
- package/dist/cjs/primitives/xchacha20.js.map +0 -1
- package/dist/cjs/types/cipher.js +0 -3
- package/dist/cjs/types/cipher.js.map +0 -1
- package/dist/cjs/types/crypto-api.js +0 -3
- package/dist/cjs/types/crypto-api.js.map +0 -1
- package/dist/cjs/types/hasher.js +0 -3
- package/dist/cjs/types/hasher.js.map +0 -1
- package/dist/cjs/types/identifier.js +0 -3
- package/dist/cjs/types/identifier.js.map +0 -1
- package/dist/cjs/types/key-compressor.js +0 -3
- package/dist/cjs/types/key-compressor.js.map +0 -1
- package/dist/cjs/types/key-converter.js +0 -3
- package/dist/cjs/types/key-converter.js.map +0 -1
- package/dist/cjs/types/key-deriver.js +0 -3
- package/dist/cjs/types/key-deriver.js.map +0 -1
- package/dist/cjs/types/key-generator.js +0 -3
- package/dist/cjs/types/key-generator.js.map +0 -1
- package/dist/cjs/types/key-io.js +0 -3
- package/dist/cjs/types/key-io.js.map +0 -1
- package/dist/cjs/types/key-wrapper.js +0 -3
- package/dist/cjs/types/key-wrapper.js.map +0 -1
- package/dist/cjs/types/params-direct.js +0 -3
- package/dist/cjs/types/params-direct.js.map +0 -1
- package/dist/cjs/types/params-enclosed.js +0 -3
- package/dist/cjs/types/params-enclosed.js.map +0 -1
- package/dist/cjs/types/params-kms.js +0 -3
- package/dist/cjs/types/params-kms.js.map +0 -1
- package/dist/cjs/types/signer.js +0 -3
- package/dist/cjs/types/signer.js.map +0 -1
- package/dist/cjs/utils.js +0 -173
- package/dist/cjs/utils.js.map +0 -1
package/dist/browser.mjs
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
var a0=Object.create;var ks=Object.defineProperty;var c0=Object.getOwnPropertyDescriptor;var f0=Object.getOwnPropertyNames;var u0=Object.getPrototypeOf,l0=Object.prototype.hasOwnProperty;var M=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports),Yf=(t,e)=>{for(var r in e)ks(t,r,{get:e[r],enumerable:!0})},d0=(t,e,r,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of f0(e))!l0.call(t,i)&&i!==r&&ks(t,i,{get:()=>e[i],enumerable:!(n=c0(e,i))||n.enumerable});return t};var ji=(t,e,r)=>(r=t!=null?a0(u0(t)):{},d0(e||!t||!t.__esModule?ks(r,"default",{value:t,enumerable:!0}):r,t));var Xf=M((R_,Zf)=>{var h0=typeof performance=="object"&&performance&&typeof performance.now=="function"?performance:Date,Fi=()=>h0.now(),p0=t=>t&&t===Math.floor(t)&&t>0&&isFinite(t),Ps=t=>t===1/0||p0(t),Is=class t{constructor({max:e=1/0,ttl:r,updateAgeOnGet:n=!1,checkAgeOnGet:i=!1,noUpdateTTL:o=!1,dispose:s,noDisposeOnSet:a=!1}={}){if(this.expirations=Object.create(null),this.data=new Map,this.expirationMap=new Map,r!==void 0&&!Ps(r))throw new TypeError("ttl must be positive integer or Infinity if set");if(!Ps(e))throw new TypeError("max must be positive integer or Infinity");if(this.ttl=r,this.max=e,this.updateAgeOnGet=!!n,this.checkAgeOnGet=!!i,this.noUpdateTTL=!!o,this.noDisposeOnSet=!!a,s!==void 0){if(typeof s!="function")throw new TypeError("dispose must be function if set");this.dispose=s}this.timer=void 0,this.timerExpiration=void 0}setTimer(e,r){if(this.timerExpiration<e)return;this.timer&&clearTimeout(this.timer);let n=setTimeout(()=>{this.timer=void 0,this.timerExpiration=void 0,this.purgeStale();for(let i in this.expirations){this.setTimer(i,i-Fi());break}},r);n.unref&&n.unref(),this.timerExpiration=e,this.timer=n}cancelTimer(){this.timer&&(clearTimeout(this.timer),this.timerExpiration=void 0,this.timer=void 0)}cancelTimers(){return process.emitWarning('TTLCache.cancelTimers has been renamed to TTLCache.cancelTimer (no "s"), and will be removed in the next major version update'),this.cancelTimer()}clear(){let e=this.dispose!==t.prototype.dispose?[...this]:[];this.data.clear(),this.expirationMap.clear(),this.cancelTimer(),this.expirations=Object.create(null);for(let[r,n]of e)this.dispose(n,r,"delete")}setTTL(e,r=this.ttl){let n=this.expirationMap.get(e);if(n!==void 0){let i=this.expirations[n];!i||i.length<=1?delete this.expirations[n]:this.expirations[n]=i.filter(o=>o!==e)}if(r!==1/0){let i=Math.floor(Fi()+r);this.expirationMap.set(e,i),this.expirations[i]||(this.expirations[i]=[],this.setTimer(i,r)),this.expirations[i].push(e)}else this.expirationMap.set(e,1/0)}set(e,r,{ttl:n=this.ttl,noUpdateTTL:i=this.noUpdateTTL,noDisposeOnSet:o=this.noDisposeOnSet}={}){if(!Ps(n))throw new TypeError("ttl must be positive integer or Infinity");if(this.expirationMap.has(e)){i||this.setTTL(e,n);let s=this.data.get(e);s!==r&&(this.data.set(e,r),o||this.dispose(s,e,"set"))}else this.setTTL(e,n),this.data.set(e,r);for(;this.size>this.max;)this.purgeToCapacity();return this}has(e){return this.data.has(e)}getRemainingTTL(e){let r=this.expirationMap.get(e);return r===1/0?r:r!==void 0?Math.max(0,Math.ceil(r-Fi())):0}get(e,{updateAgeOnGet:r=this.updateAgeOnGet,ttl:n=this.ttl,checkAgeOnGet:i=this.checkAgeOnGet}={}){let o=this.data.get(e);if(i&&this.getRemainingTTL(e)===0){this.delete(e);return}return r&&this.setTTL(e,n),o}dispose(e,r){}delete(e){let r=this.expirationMap.get(e);if(r!==void 0){let n=this.data.get(e);this.data.delete(e),this.expirationMap.delete(e);let i=this.expirations[r];return i&&(i.length<=1?delete this.expirations[r]:this.expirations[r]=i.filter(o=>o!==e)),this.dispose(n,e,"delete"),this.size===0&&this.cancelTimer(),!0}return!1}purgeToCapacity(){for(let e in this.expirations){let r=this.expirations[e];if(this.size-r.length>=this.max){delete this.expirations[e];let n=[];for(let i of r)n.push([i,this.data.get(i)]),this.data.delete(i),this.expirationMap.delete(i);for(let[i,o]of n)this.dispose(o,i,"evict")}else{let n=this.size-this.max,i=[];for(let o of r.splice(0,n))i.push([o,this.data.get(o)]),this.data.delete(o),this.expirationMap.delete(o);for(let[o,s]of i)this.dispose(s,o,"evict");return}}}get size(){return this.data.size}purgeStale(){let e=Math.ceil(Fi());for(let r in this.expirations){if(r==="Infinity"||r>e)return;let n=[...this.expirations[r]||[]],i=[];delete this.expirations[r];for(let o of n)i.push([o,this.data.get(o)]),this.data.delete(o),this.expirationMap.delete(o);for(let[o,s]of i)this.dispose(s,o,"stale")}this.size===0&&this.cancelTimer()}*entries(){for(let e in this.expirations)for(let r of this.expirations[e])yield[r,this.data.get(r)]}*keys(){for(let e in this.expirations)for(let r of this.expirations[e])yield r}*values(){for(let e in this.expirations)for(let r of this.expirations[e])yield this.data.get(r)}[Symbol.iterator](){return this.entries()}};Zf.exports=Is});var yu=M(pu=>{"use strict";pu.supports=function(...e){let r=e.reduce((n,i)=>Object.assign(n,i),{});return Object.assign(r,{snapshots:r.snapshots||!1,permanence:r.permanence||!1,seek:r.seek||!1,clear:r.clear||!1,getMany:r.getMany||!1,keyIterator:r.keyIterator||!1,valueIterator:r.valueIterator||!1,iteratorNextv:r.iteratorNextv||!1,iteratorAll:r.iteratorAll||!1,status:r.status||!1,createIfMissing:r.createIfMissing||!1,errorIfExists:r.errorIfExists||!1,deferredOpen:r.deferredOpen||!1,promises:r.promises||!1,streams:r.streams||!1,encodings:Object.assign({},r.encodings),events:Object.assign({},r.events),additionalMethods:Object.assign({},r.additionalMethods)})}});var ze=M((PA,wu)=>{"use strict";wu.exports=class extends Error{constructor(e,r){super(e||""),typeof r=="object"&&r!==null&&(r.code&&(this.code=String(r.code)),r.expected&&(this.expected=!0),r.transient&&(this.transient=!0),r.cause&&(this.cause=r.cause)),Error.captureStackTrace&&Error.captureStackTrace(this,this.constructor)}}});var gu=M(Vi=>{"use strict";Vi.byteLength=J0;Vi.toByteArray=Y0;Vi.fromByteArray=Q0;var at=[],Me=[],W0=typeof Uint8Array<"u"?Uint8Array:Array,Vs="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";for(Ar=0,mu=Vs.length;Ar<mu;++Ar)at[Ar]=Vs[Ar],Me[Vs.charCodeAt(Ar)]=Ar;var Ar,mu;Me[45]=62;Me[95]=63;function bu(t){var e=t.length;if(e%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var r=t.indexOf("=");r===-1&&(r=e);var n=r===e?0:4-r%4;return[r,n]}function J0(t){var e=bu(t),r=e[0],n=e[1];return(r+n)*3/4-n}function z0(t,e,r){return(e+r)*3/4-r}function Y0(t){var e,r=bu(t),n=r[0],i=r[1],o=new W0(z0(t,n,i)),s=0,a=i>0?n-4:n,c;for(c=0;c<a;c+=4)e=Me[t.charCodeAt(c)]<<18|Me[t.charCodeAt(c+1)]<<12|Me[t.charCodeAt(c+2)]<<6|Me[t.charCodeAt(c+3)],o[s++]=e>>16&255,o[s++]=e>>8&255,o[s++]=e&255;return i===2&&(e=Me[t.charCodeAt(c)]<<2|Me[t.charCodeAt(c+1)]>>4,o[s++]=e&255),i===1&&(e=Me[t.charCodeAt(c)]<<10|Me[t.charCodeAt(c+1)]<<4|Me[t.charCodeAt(c+2)]>>2,o[s++]=e>>8&255,o[s++]=e&255),o}function Z0(t){return at[t>>18&63]+at[t>>12&63]+at[t>>6&63]+at[t&63]}function X0(t,e,r){for(var n,i=[],o=e;o<r;o+=3)n=(t[o]<<16&16711680)+(t[o+1]<<8&65280)+(t[o+2]&255),i.push(Z0(n));return i.join("")}function Q0(t){for(var e,r=t.length,n=r%3,i=[],o=16383,s=0,a=r-n;s<a;s+=o)i.push(X0(t,s,s+o>a?a:s+o));return n===1?(e=t[r-1],i.push(at[e>>2]+at[e<<4&63]+"==")):n===2&&(e=(t[r-2]<<8)+t[r-1],i.push(at[e>>10]+at[e>>4&63]+at[e<<2&63]+"=")),i.join("")}});var xu=M(Hs=>{Hs.read=function(t,e,r,n,i){var o,s,a=i*8-n-1,c=(1<<a)-1,f=c>>1,u=-7,l=r?i-1:0,p=r?-1:1,h=t[e+l];for(l+=p,o=h&(1<<-u)-1,h>>=-u,u+=a;u>0;o=o*256+t[e+l],l+=p,u-=8);for(s=o&(1<<-u)-1,o>>=-u,u+=n;u>0;s=s*256+t[e+l],l+=p,u-=8);if(o===0)o=1-f;else{if(o===c)return s?NaN:(h?-1:1)*(1/0);s=s+Math.pow(2,n),o=o-f}return(h?-1:1)*s*Math.pow(2,o-n)};Hs.write=function(t,e,r,n,i,o){var s,a,c,f=o*8-i-1,u=(1<<f)-1,l=u>>1,p=i===23?Math.pow(2,-24)-Math.pow(2,-77):0,h=n?0:o-1,y=n?1:-1,d=e<0||e===0&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(a=isNaN(e)?1:0,s=u):(s=Math.floor(Math.log(e)/Math.LN2),e*(c=Math.pow(2,-s))<1&&(s--,c*=2),s+l>=1?e+=p/c:e+=p*Math.pow(2,1-l),e*c>=2&&(s++,c/=2),s+l>=u?(a=0,s=u):s+l>=1?(a=(e*c-1)*Math.pow(2,i),s=s+l):(a=e*Math.pow(2,l-1)*Math.pow(2,i),s=0));i>=8;t[r+h]=a&255,h+=y,a/=256,i-=8);for(s=s<<i|a,f+=i;f>0;t[r+h]=s&255,h+=y,s/=256,f-=8);t[r+h-y]|=d*128}});var qe=M(fn=>{"use strict";var Gs=gu(),an=xu(),Eu=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):null;fn.Buffer=x;fn.SlowBuffer=ow;fn.INSPECT_MAX_BYTES=50;var Hi=2147483647;fn.kMaxLength=Hi;x.TYPED_ARRAY_SUPPORT=ew();!x.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 ew(){try{let t=new Uint8Array(1),e={foo:function(){return 42}};return Object.setPrototypeOf(e,Uint8Array.prototype),Object.setPrototypeOf(t,e),t.foo()===42}catch{return!1}}Object.defineProperty(x.prototype,"parent",{enumerable:!0,get:function(){if(x.isBuffer(this))return this.buffer}});Object.defineProperty(x.prototype,"offset",{enumerable:!0,get:function(){if(x.isBuffer(this))return this.byteOffset}});function Bt(t){if(t>Hi)throw new RangeError('The value "'+t+'" is invalid for option "size"');let e=new Uint8Array(t);return Object.setPrototypeOf(e,x.prototype),e}function x(t,e,r){if(typeof t=="number"){if(typeof e=="string")throw new TypeError('The "string" argument must be of type string. Received type number');return Ys(t)}return vu(t,e,r)}x.poolSize=8192;function vu(t,e,r){if(typeof t=="string")return rw(t,e);if(ArrayBuffer.isView(t))return nw(t);if(t==null)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof t);if(ct(t,ArrayBuffer)||t&&ct(t.buffer,ArrayBuffer)||typeof SharedArrayBuffer<"u"&&(ct(t,SharedArrayBuffer)||t&&ct(t.buffer,SharedArrayBuffer)))return Js(t,e,r);if(typeof t=="number")throw new TypeError('The "value" argument must not be of type number. Received type number');let n=t.valueOf&&t.valueOf();if(n!=null&&n!==t)return x.from(n,e,r);let i=iw(t);if(i)return i;if(typeof Symbol<"u"&&Symbol.toPrimitive!=null&&typeof t[Symbol.toPrimitive]=="function")return x.from(t[Symbol.toPrimitive]("string"),e,r);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof t)}x.from=function(t,e,r){return vu(t,e,r)};Object.setPrototypeOf(x.prototype,Uint8Array.prototype);Object.setPrototypeOf(x,Uint8Array);function Bu(t){if(typeof t!="number")throw new TypeError('"size" argument must be of type number');if(t<0)throw new RangeError('The value "'+t+'" is invalid for option "size"')}function tw(t,e,r){return Bu(t),t<=0?Bt(t):e!==void 0?typeof r=="string"?Bt(t).fill(e,r):Bt(t).fill(e):Bt(t)}x.alloc=function(t,e,r){return tw(t,e,r)};function Ys(t){return Bu(t),Bt(t<0?0:Zs(t)|0)}x.allocUnsafe=function(t){return Ys(t)};x.allocUnsafeSlow=function(t){return Ys(t)};function rw(t,e){if((typeof e!="string"||e==="")&&(e="utf8"),!x.isEncoding(e))throw new TypeError("Unknown encoding: "+e);let r=Tu(t,e)|0,n=Bt(r),i=n.write(t,e);return i!==r&&(n=n.slice(0,i)),n}function Ws(t){let e=t.length<0?0:Zs(t.length)|0,r=Bt(e);for(let n=0;n<e;n+=1)r[n]=t[n]&255;return r}function nw(t){if(ct(t,Uint8Array)){let e=new Uint8Array(t);return Js(e.buffer,e.byteOffset,e.byteLength)}return Ws(t)}function Js(t,e,r){if(e<0||t.byteLength<e)throw new RangeError('"offset" is outside of buffer bounds');if(t.byteLength<e+(r||0))throw new RangeError('"length" is outside of buffer bounds');let n;return e===void 0&&r===void 0?n=new Uint8Array(t):r===void 0?n=new Uint8Array(t,e):n=new Uint8Array(t,e,r),Object.setPrototypeOf(n,x.prototype),n}function iw(t){if(x.isBuffer(t)){let e=Zs(t.length)|0,r=Bt(e);return r.length===0||t.copy(r,0,0,e),r}if(t.length!==void 0)return typeof t.length!="number"||Qs(t.length)?Bt(0):Ws(t);if(t.type==="Buffer"&&Array.isArray(t.data))return Ws(t.data)}function Zs(t){if(t>=Hi)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+Hi.toString(16)+" bytes");return t|0}function ow(t){return+t!=t&&(t=0),x.alloc(+t)}x.isBuffer=function(e){return e!=null&&e._isBuffer===!0&&e!==x.prototype};x.compare=function(e,r){if(ct(e,Uint8Array)&&(e=x.from(e,e.offset,e.byteLength)),ct(r,Uint8Array)&&(r=x.from(r,r.offset,r.byteLength)),!x.isBuffer(e)||!x.isBuffer(r))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(e===r)return 0;let n=e.length,i=r.length;for(let o=0,s=Math.min(n,i);o<s;++o)if(e[o]!==r[o]){n=e[o],i=r[o];break}return n<i?-1:i<n?1:0};x.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}};x.concat=function(e,r){if(!Array.isArray(e))throw new TypeError('"list" argument must be an Array of Buffers');if(e.length===0)return x.alloc(0);let n;if(r===void 0)for(r=0,n=0;n<e.length;++n)r+=e[n].length;let i=x.allocUnsafe(r),o=0;for(n=0;n<e.length;++n){let s=e[n];if(ct(s,Uint8Array))o+s.length>i.length?(x.isBuffer(s)||(s=x.from(s)),s.copy(i,o)):Uint8Array.prototype.set.call(i,s,o);else if(x.isBuffer(s))s.copy(i,o);else throw new TypeError('"list" argument must be an Array of Buffers');o+=s.length}return i};function Tu(t,e){if(x.isBuffer(t))return t.length;if(ArrayBuffer.isView(t)||ct(t,ArrayBuffer))return t.byteLength;if(typeof t!="string")throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof t);let r=t.length,n=arguments.length>2&&arguments[2]===!0;if(!n&&r===0)return 0;let i=!1;for(;;)switch(e){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":return zs(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return r*2;case"hex":return r>>>1;case"base64":return Ku(t).length;default:if(i)return n?-1:zs(t).length;e=(""+e).toLowerCase(),i=!0}}x.byteLength=Tu;function sw(t,e,r){let n=!1;if((e===void 0||e<0)&&(e=0),e>this.length||((r===void 0||r>this.length)&&(r=this.length),r<=0)||(r>>>=0,e>>>=0,r<=e))return"";for(t||(t="utf8");;)switch(t){case"hex":return ww(this,e,r);case"utf8":case"utf-8":return Pu(this,e,r);case"ascii":return pw(this,e,r);case"latin1":case"binary":return yw(this,e,r);case"base64":return dw(this,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return mw(this,e,r);default:if(n)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),n=!0}}x.prototype._isBuffer=!0;function Sr(t,e,r){let n=t[e];t[e]=t[r],t[r]=n}x.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 r=0;r<e;r+=2)Sr(this,r,r+1);return this};x.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 r=0;r<e;r+=4)Sr(this,r,r+3),Sr(this,r+1,r+2);return this};x.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 r=0;r<e;r+=8)Sr(this,r,r+7),Sr(this,r+1,r+6),Sr(this,r+2,r+5),Sr(this,r+3,r+4);return this};x.prototype.toString=function(){let e=this.length;return e===0?"":arguments.length===0?Pu(this,0,e):sw.apply(this,arguments)};x.prototype.toLocaleString=x.prototype.toString;x.prototype.equals=function(e){if(!x.isBuffer(e))throw new TypeError("Argument must be a Buffer");return this===e?!0:x.compare(this,e)===0};x.prototype.inspect=function(){let e="",r=fn.INSPECT_MAX_BYTES;return e=this.toString("hex",0,r).replace(/(.{2})/g,"$1 ").trim(),this.length>r&&(e+=" ... "),"<Buffer "+e+">"};Eu&&(x.prototype[Eu]=x.prototype.inspect);x.prototype.compare=function(e,r,n,i,o){if(ct(e,Uint8Array)&&(e=x.from(e,e.offset,e.byteLength)),!x.isBuffer(e))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof e);if(r===void 0&&(r=0),n===void 0&&(n=e?e.length:0),i===void 0&&(i=0),o===void 0&&(o=this.length),r<0||n>e.length||i<0||o>this.length)throw new RangeError("out of range index");if(i>=o&&r>=n)return 0;if(i>=o)return-1;if(r>=n)return 1;if(r>>>=0,n>>>=0,i>>>=0,o>>>=0,this===e)return 0;let s=o-i,a=n-r,c=Math.min(s,a),f=this.slice(i,o),u=e.slice(r,n);for(let l=0;l<c;++l)if(f[l]!==u[l]){s=f[l],a=u[l];break}return s<a?-1:a<s?1:0};function ku(t,e,r,n,i){if(t.length===0)return-1;if(typeof r=="string"?(n=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),r=+r,Qs(r)&&(r=i?0:t.length-1),r<0&&(r=t.length+r),r>=t.length){if(i)return-1;r=t.length-1}else if(r<0)if(i)r=0;else return-1;if(typeof e=="string"&&(e=x.from(e,n)),x.isBuffer(e))return e.length===0?-1:_u(t,e,r,n,i);if(typeof e=="number")return e=e&255,typeof Uint8Array.prototype.indexOf=="function"?i?Uint8Array.prototype.indexOf.call(t,e,r):Uint8Array.prototype.lastIndexOf.call(t,e,r):_u(t,[e],r,n,i);throw new TypeError("val must be string, number or Buffer")}function _u(t,e,r,n,i){let o=1,s=t.length,a=e.length;if(n!==void 0&&(n=String(n).toLowerCase(),n==="ucs2"||n==="ucs-2"||n==="utf16le"||n==="utf-16le")){if(t.length<2||e.length<2)return-1;o=2,s/=2,a/=2,r/=2}function c(u,l){return o===1?u[l]:u.readUInt16BE(l*o)}let f;if(i){let u=-1;for(f=r;f<s;f++)if(c(t,f)===c(e,u===-1?0:f-u)){if(u===-1&&(u=f),f-u+1===a)return u*o}else u!==-1&&(f-=f-u),u=-1}else for(r+a>s&&(r=s-a),f=r;f>=0;f--){let u=!0;for(let l=0;l<a;l++)if(c(t,f+l)!==c(e,l)){u=!1;break}if(u)return f}return-1}x.prototype.includes=function(e,r,n){return this.indexOf(e,r,n)!==-1};x.prototype.indexOf=function(e,r,n){return ku(this,e,r,n,!0)};x.prototype.lastIndexOf=function(e,r,n){return ku(this,e,r,n,!1)};function aw(t,e,r,n){r=Number(r)||0;let i=t.length-r;n?(n=Number(n),n>i&&(n=i)):n=i;let o=e.length;n>o/2&&(n=o/2);let s;for(s=0;s<n;++s){let a=parseInt(e.substr(s*2,2),16);if(Qs(a))return s;t[r+s]=a}return s}function cw(t,e,r,n){return Gi(zs(e,t.length-r),t,r,n)}function fw(t,e,r,n){return Gi(Ew(e),t,r,n)}function uw(t,e,r,n){return Gi(Ku(e),t,r,n)}function lw(t,e,r,n){return Gi(_w(e,t.length-r),t,r,n)}x.prototype.write=function(e,r,n,i){if(r===void 0)i="utf8",n=this.length,r=0;else if(n===void 0&&typeof r=="string")i=r,n=this.length,r=0;else if(isFinite(r))r=r>>>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 o=this.length-r;if((n===void 0||n>o)&&(n=o),e.length>0&&(n<0||r<0)||r>this.length)throw new RangeError("Attempt to write outside buffer bounds");i||(i="utf8");let s=!1;for(;;)switch(i){case"hex":return aw(this,e,r,n);case"utf8":case"utf-8":return cw(this,e,r,n);case"ascii":case"latin1":case"binary":return fw(this,e,r,n);case"base64":return uw(this,e,r,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return lw(this,e,r,n);default:if(s)throw new TypeError("Unknown encoding: "+i);i=(""+i).toLowerCase(),s=!0}};x.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function dw(t,e,r){return e===0&&r===t.length?Gs.fromByteArray(t):Gs.fromByteArray(t.slice(e,r))}function Pu(t,e,r){r=Math.min(t.length,r);let n=[],i=e;for(;i<r;){let o=t[i],s=null,a=o>239?4:o>223?3:o>191?2:1;if(i+a<=r){let c,f,u,l;switch(a){case 1:o<128&&(s=o);break;case 2:c=t[i+1],(c&192)===128&&(l=(o&31)<<6|c&63,l>127&&(s=l));break;case 3:c=t[i+1],f=t[i+2],(c&192)===128&&(f&192)===128&&(l=(o&15)<<12|(c&63)<<6|f&63,l>2047&&(l<55296||l>57343)&&(s=l));break;case 4:c=t[i+1],f=t[i+2],u=t[i+3],(c&192)===128&&(f&192)===128&&(u&192)===128&&(l=(o&15)<<18|(c&63)<<12|(f&63)<<6|u&63,l>65535&&l<1114112&&(s=l))}}s===null?(s=65533,a=1):s>65535&&(s-=65536,n.push(s>>>10&1023|55296),s=56320|s&1023),n.push(s),i+=a}return hw(n)}var Au=4096;function hw(t){let e=t.length;if(e<=Au)return String.fromCharCode.apply(String,t);let r="",n=0;for(;n<e;)r+=String.fromCharCode.apply(String,t.slice(n,n+=Au));return r}function pw(t,e,r){let n="";r=Math.min(t.length,r);for(let i=e;i<r;++i)n+=String.fromCharCode(t[i]&127);return n}function yw(t,e,r){let n="";r=Math.min(t.length,r);for(let i=e;i<r;++i)n+=String.fromCharCode(t[i]);return n}function ww(t,e,r){let n=t.length;(!e||e<0)&&(e=0),(!r||r<0||r>n)&&(r=n);let i="";for(let o=e;o<r;++o)i+=Aw[t[o]];return i}function mw(t,e,r){let n=t.slice(e,r),i="";for(let o=0;o<n.length-1;o+=2)i+=String.fromCharCode(n[o]+n[o+1]*256);return i}x.prototype.slice=function(e,r){let n=this.length;e=~~e,r=r===void 0?n:~~r,e<0?(e+=n,e<0&&(e=0)):e>n&&(e=n),r<0?(r+=n,r<0&&(r=0)):r>n&&(r=n),r<e&&(r=e);let i=this.subarray(e,r);return Object.setPrototypeOf(i,x.prototype),i};function me(t,e,r){if(t%1!==0||t<0)throw new RangeError("offset is not uint");if(t+e>r)throw new RangeError("Trying to access beyond buffer length")}x.prototype.readUintLE=x.prototype.readUIntLE=function(e,r,n){e=e>>>0,r=r>>>0,n||me(e,r,this.length);let i=this[e],o=1,s=0;for(;++s<r&&(o*=256);)i+=this[e+s]*o;return i};x.prototype.readUintBE=x.prototype.readUIntBE=function(e,r,n){e=e>>>0,r=r>>>0,n||me(e,r,this.length);let i=this[e+--r],o=1;for(;r>0&&(o*=256);)i+=this[e+--r]*o;return i};x.prototype.readUint8=x.prototype.readUInt8=function(e,r){return e=e>>>0,r||me(e,1,this.length),this[e]};x.prototype.readUint16LE=x.prototype.readUInt16LE=function(e,r){return e=e>>>0,r||me(e,2,this.length),this[e]|this[e+1]<<8};x.prototype.readUint16BE=x.prototype.readUInt16BE=function(e,r){return e=e>>>0,r||me(e,2,this.length),this[e]<<8|this[e+1]};x.prototype.readUint32LE=x.prototype.readUInt32LE=function(e,r){return e=e>>>0,r||me(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+this[e+3]*16777216};x.prototype.readUint32BE=x.prototype.readUInt32BE=function(e,r){return e=e>>>0,r||me(e,4,this.length),this[e]*16777216+(this[e+1]<<16|this[e+2]<<8|this[e+3])};x.prototype.readBigUInt64LE=Jt(function(e){e=e>>>0,cn(e,"offset");let r=this[e],n=this[e+7];(r===void 0||n===void 0)&&Xn(e,this.length-8);let i=r+this[++e]*2**8+this[++e]*2**16+this[++e]*2**24,o=this[++e]+this[++e]*2**8+this[++e]*2**16+n*2**24;return BigInt(i)+(BigInt(o)<<BigInt(32))});x.prototype.readBigUInt64BE=Jt(function(e){e=e>>>0,cn(e,"offset");let r=this[e],n=this[e+7];(r===void 0||n===void 0)&&Xn(e,this.length-8);let i=r*2**24+this[++e]*2**16+this[++e]*2**8+this[++e],o=this[++e]*2**24+this[++e]*2**16+this[++e]*2**8+n;return(BigInt(i)<<BigInt(32))+BigInt(o)});x.prototype.readIntLE=function(e,r,n){e=e>>>0,r=r>>>0,n||me(e,r,this.length);let i=this[e],o=1,s=0;for(;++s<r&&(o*=256);)i+=this[e+s]*o;return o*=128,i>=o&&(i-=Math.pow(2,8*r)),i};x.prototype.readIntBE=function(e,r,n){e=e>>>0,r=r>>>0,n||me(e,r,this.length);let i=r,o=1,s=this[e+--i];for(;i>0&&(o*=256);)s+=this[e+--i]*o;return o*=128,s>=o&&(s-=Math.pow(2,8*r)),s};x.prototype.readInt8=function(e,r){return e=e>>>0,r||me(e,1,this.length),this[e]&128?(255-this[e]+1)*-1:this[e]};x.prototype.readInt16LE=function(e,r){e=e>>>0,r||me(e,2,this.length);let n=this[e]|this[e+1]<<8;return n&32768?n|4294901760:n};x.prototype.readInt16BE=function(e,r){e=e>>>0,r||me(e,2,this.length);let n=this[e+1]|this[e]<<8;return n&32768?n|4294901760:n};x.prototype.readInt32LE=function(e,r){return e=e>>>0,r||me(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24};x.prototype.readInt32BE=function(e,r){return e=e>>>0,r||me(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]};x.prototype.readBigInt64LE=Jt(function(e){e=e>>>0,cn(e,"offset");let r=this[e],n=this[e+7];(r===void 0||n===void 0)&&Xn(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(r+this[++e]*2**8+this[++e]*2**16+this[++e]*2**24)});x.prototype.readBigInt64BE=Jt(function(e){e=e>>>0,cn(e,"offset");let r=this[e],n=this[e+7];(r===void 0||n===void 0)&&Xn(e,this.length-8);let i=(r<<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)});x.prototype.readFloatLE=function(e,r){return e=e>>>0,r||me(e,4,this.length),an.read(this,e,!0,23,4)};x.prototype.readFloatBE=function(e,r){return e=e>>>0,r||me(e,4,this.length),an.read(this,e,!1,23,4)};x.prototype.readDoubleLE=function(e,r){return e=e>>>0,r||me(e,8,this.length),an.read(this,e,!0,52,8)};x.prototype.readDoubleBE=function(e,r){return e=e>>>0,r||me(e,8,this.length),an.read(this,e,!1,52,8)};function Ie(t,e,r,n,i,o){if(!x.isBuffer(t))throw new TypeError('"buffer" argument must be a Buffer instance');if(e>i||e<o)throw new RangeError('"value" argument is out of bounds');if(r+n>t.length)throw new RangeError("Index out of range")}x.prototype.writeUintLE=x.prototype.writeUIntLE=function(e,r,n,i){if(e=+e,r=r>>>0,n=n>>>0,!i){let a=Math.pow(2,8*n)-1;Ie(this,e,r,n,a,0)}let o=1,s=0;for(this[r]=e&255;++s<n&&(o*=256);)this[r+s]=e/o&255;return r+n};x.prototype.writeUintBE=x.prototype.writeUIntBE=function(e,r,n,i){if(e=+e,r=r>>>0,n=n>>>0,!i){let a=Math.pow(2,8*n)-1;Ie(this,e,r,n,a,0)}let o=n-1,s=1;for(this[r+o]=e&255;--o>=0&&(s*=256);)this[r+o]=e/s&255;return r+n};x.prototype.writeUint8=x.prototype.writeUInt8=function(e,r,n){return e=+e,r=r>>>0,n||Ie(this,e,r,1,255,0),this[r]=e&255,r+1};x.prototype.writeUint16LE=x.prototype.writeUInt16LE=function(e,r,n){return e=+e,r=r>>>0,n||Ie(this,e,r,2,65535,0),this[r]=e&255,this[r+1]=e>>>8,r+2};x.prototype.writeUint16BE=x.prototype.writeUInt16BE=function(e,r,n){return e=+e,r=r>>>0,n||Ie(this,e,r,2,65535,0),this[r]=e>>>8,this[r+1]=e&255,r+2};x.prototype.writeUint32LE=x.prototype.writeUInt32LE=function(e,r,n){return e=+e,r=r>>>0,n||Ie(this,e,r,4,4294967295,0),this[r+3]=e>>>24,this[r+2]=e>>>16,this[r+1]=e>>>8,this[r]=e&255,r+4};x.prototype.writeUint32BE=x.prototype.writeUInt32BE=function(e,r,n){return e=+e,r=r>>>0,n||Ie(this,e,r,4,4294967295,0),this[r]=e>>>24,this[r+1]=e>>>16,this[r+2]=e>>>8,this[r+3]=e&255,r+4};function Iu(t,e,r,n,i){Ou(e,n,i,t,r,7);let o=Number(e&BigInt(4294967295));t[r++]=o,o=o>>8,t[r++]=o,o=o>>8,t[r++]=o,o=o>>8,t[r++]=o;let s=Number(e>>BigInt(32)&BigInt(4294967295));return t[r++]=s,s=s>>8,t[r++]=s,s=s>>8,t[r++]=s,s=s>>8,t[r++]=s,r}function Ru(t,e,r,n,i){Ou(e,n,i,t,r,7);let o=Number(e&BigInt(4294967295));t[r+7]=o,o=o>>8,t[r+6]=o,o=o>>8,t[r+5]=o,o=o>>8,t[r+4]=o;let s=Number(e>>BigInt(32)&BigInt(4294967295));return t[r+3]=s,s=s>>8,t[r+2]=s,s=s>>8,t[r+1]=s,s=s>>8,t[r]=s,r+8}x.prototype.writeBigUInt64LE=Jt(function(e,r=0){return Iu(this,e,r,BigInt(0),BigInt("0xffffffffffffffff"))});x.prototype.writeBigUInt64BE=Jt(function(e,r=0){return Ru(this,e,r,BigInt(0),BigInt("0xffffffffffffffff"))});x.prototype.writeIntLE=function(e,r,n,i){if(e=+e,r=r>>>0,!i){let c=Math.pow(2,8*n-1);Ie(this,e,r,n,c-1,-c)}let o=0,s=1,a=0;for(this[r]=e&255;++o<n&&(s*=256);)e<0&&a===0&&this[r+o-1]!==0&&(a=1),this[r+o]=(e/s>>0)-a&255;return r+n};x.prototype.writeIntBE=function(e,r,n,i){if(e=+e,r=r>>>0,!i){let c=Math.pow(2,8*n-1);Ie(this,e,r,n,c-1,-c)}let o=n-1,s=1,a=0;for(this[r+o]=e&255;--o>=0&&(s*=256);)e<0&&a===0&&this[r+o+1]!==0&&(a=1),this[r+o]=(e/s>>0)-a&255;return r+n};x.prototype.writeInt8=function(e,r,n){return e=+e,r=r>>>0,n||Ie(this,e,r,1,127,-128),e<0&&(e=255+e+1),this[r]=e&255,r+1};x.prototype.writeInt16LE=function(e,r,n){return e=+e,r=r>>>0,n||Ie(this,e,r,2,32767,-32768),this[r]=e&255,this[r+1]=e>>>8,r+2};x.prototype.writeInt16BE=function(e,r,n){return e=+e,r=r>>>0,n||Ie(this,e,r,2,32767,-32768),this[r]=e>>>8,this[r+1]=e&255,r+2};x.prototype.writeInt32LE=function(e,r,n){return e=+e,r=r>>>0,n||Ie(this,e,r,4,2147483647,-2147483648),this[r]=e&255,this[r+1]=e>>>8,this[r+2]=e>>>16,this[r+3]=e>>>24,r+4};x.prototype.writeInt32BE=function(e,r,n){return e=+e,r=r>>>0,n||Ie(this,e,r,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),this[r]=e>>>24,this[r+1]=e>>>16,this[r+2]=e>>>8,this[r+3]=e&255,r+4};x.prototype.writeBigInt64LE=Jt(function(e,r=0){return Iu(this,e,r,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});x.prototype.writeBigInt64BE=Jt(function(e,r=0){return Ru(this,e,r,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});function Uu(t,e,r,n,i,o){if(r+n>t.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function Cu(t,e,r,n,i){return e=+e,r=r>>>0,i||Uu(t,e,r,4,34028234663852886e22,-34028234663852886e22),an.write(t,e,r,n,23,4),r+4}x.prototype.writeFloatLE=function(e,r,n){return Cu(this,e,r,!0,n)};x.prototype.writeFloatBE=function(e,r,n){return Cu(this,e,r,!1,n)};function Lu(t,e,r,n,i){return e=+e,r=r>>>0,i||Uu(t,e,r,8,17976931348623157e292,-17976931348623157e292),an.write(t,e,r,n,52,8),r+8}x.prototype.writeDoubleLE=function(e,r,n){return Lu(this,e,r,!0,n)};x.prototype.writeDoubleBE=function(e,r,n){return Lu(this,e,r,!1,n)};x.prototype.copy=function(e,r,n,i){if(!x.isBuffer(e))throw new TypeError("argument should be a Buffer");if(n||(n=0),!i&&i!==0&&(i=this.length),r>=e.length&&(r=e.length),r||(r=0),i>0&&i<n&&(i=n),i===n||e.length===0||this.length===0)return 0;if(r<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-r<i-n&&(i=e.length-r+n);let o=i-n;return this===e&&typeof Uint8Array.prototype.copyWithin=="function"?this.copyWithin(r,n,i):Uint8Array.prototype.set.call(e,this.subarray(n,i),r),o};x.prototype.fill=function(e,r,n,i){if(typeof e=="string"){if(typeof r=="string"?(i=r,r=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"&&!x.isEncoding(i))throw new TypeError("Unknown encoding: "+i);if(e.length===1){let s=e.charCodeAt(0);(i==="utf8"&&s<128||i==="latin1")&&(e=s)}}else typeof e=="number"?e=e&255:typeof e=="boolean"&&(e=Number(e));if(r<0||this.length<r||this.length<n)throw new RangeError("Out of range index");if(n<=r)return this;r=r>>>0,n=n===void 0?this.length:n>>>0,e||(e=0);let o;if(typeof e=="number")for(o=r;o<n;++o)this[o]=e;else{let s=x.isBuffer(e)?e:x.from(e,i),a=s.length;if(a===0)throw new TypeError('The value "'+e+'" is invalid for argument "value"');for(o=0;o<n-r;++o)this[o+r]=s[o%a]}return this};var sn={};function Xs(t,e,r){sn[t]=class extends r{constructor(){super(),Object.defineProperty(this,"message",{value:e.apply(this,arguments),writable:!0,configurable:!0}),this.name=`${this.name} [${t}]`,this.stack,delete this.name}get code(){return t}set code(i){Object.defineProperty(this,"code",{configurable:!0,enumerable:!0,value:i,writable:!0})}toString(){return`${this.name} [${t}]: ${this.message}`}}}Xs("ERR_BUFFER_OUT_OF_BOUNDS",function(t){return t?`${t} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"},RangeError);Xs("ERR_INVALID_ARG_TYPE",function(t,e){return`The "${t}" argument must be of type number. Received type ${typeof e}`},TypeError);Xs("ERR_OUT_OF_RANGE",function(t,e,r){let n=`The value of "${t}" is out of range.`,i=r;return Number.isInteger(r)&&Math.abs(r)>2**32?i=Su(String(r)):typeof r=="bigint"&&(i=String(r),(r>BigInt(2)**BigInt(32)||r<-(BigInt(2)**BigInt(32)))&&(i=Su(i)),i+="n"),n+=` It must be ${e}. Received ${i}`,n},RangeError);function Su(t){let e="",r=t.length,n=t[0]==="-"?1:0;for(;r>=n+4;r-=3)e=`_${t.slice(r-3,r)}${e}`;return`${t.slice(0,r)}${e}`}function bw(t,e,r){cn(e,"offset"),(t[e]===void 0||t[e+r]===void 0)&&Xn(e,t.length-(r+1))}function Ou(t,e,r,n,i,o){if(t>r||t<e){let s=typeof e=="bigint"?"n":"",a;throw o>3?e===0||e===BigInt(0)?a=`>= 0${s} and < 2${s} ** ${(o+1)*8}${s}`:a=`>= -(2${s} ** ${(o+1)*8-1}${s}) and < 2 ** ${(o+1)*8-1}${s}`:a=`>= ${e}${s} and <= ${r}${s}`,new sn.ERR_OUT_OF_RANGE("value",a,t)}bw(n,i,o)}function cn(t,e){if(typeof t!="number")throw new sn.ERR_INVALID_ARG_TYPE(e,"number",t)}function Xn(t,e,r){throw Math.floor(t)!==t?(cn(t,r),new sn.ERR_OUT_OF_RANGE(r||"offset","an integer",t)):e<0?new sn.ERR_BUFFER_OUT_OF_BOUNDS:new sn.ERR_OUT_OF_RANGE(r||"offset",`>= ${r?1:0} and <= ${e}`,t)}var gw=/[^+/0-9A-Za-z-_]/g;function xw(t){if(t=t.split("=")[0],t=t.trim().replace(gw,""),t.length<2)return"";for(;t.length%4!==0;)t=t+"=";return t}function zs(t,e){e=e||1/0;let r,n=t.length,i=null,o=[];for(let s=0;s<n;++s){if(r=t.charCodeAt(s),r>55295&&r<57344){if(!i){if(r>56319){(e-=3)>-1&&o.push(239,191,189);continue}else if(s+1===n){(e-=3)>-1&&o.push(239,191,189);continue}i=r;continue}if(r<56320){(e-=3)>-1&&o.push(239,191,189),i=r;continue}r=(i-55296<<10|r-56320)+65536}else i&&(e-=3)>-1&&o.push(239,191,189);if(i=null,r<128){if((e-=1)<0)break;o.push(r)}else if(r<2048){if((e-=2)<0)break;o.push(r>>6|192,r&63|128)}else if(r<65536){if((e-=3)<0)break;o.push(r>>12|224,r>>6&63|128,r&63|128)}else if(r<1114112){if((e-=4)<0)break;o.push(r>>18|240,r>>12&63|128,r>>6&63|128,r&63|128)}else throw new Error("Invalid code point")}return o}function Ew(t){let e=[];for(let r=0;r<t.length;++r)e.push(t.charCodeAt(r)&255);return e}function _w(t,e){let r,n,i,o=[];for(let s=0;s<t.length&&!((e-=2)<0);++s)r=t.charCodeAt(s),n=r>>8,i=r%256,o.push(i),o.push(n);return o}function Ku(t){return Gs.toByteArray(xw(t))}function Gi(t,e,r,n){let i;for(i=0;i<n&&!(i+r>=e.length||i>=t.length);++i)e[i+r]=t[i];return i}function ct(t,e){return t instanceof e||t!=null&&t.constructor!=null&&t.constructor.name!=null&&t.constructor.name===e.name}function Qs(t){return t!==t}var Aw=function(){let t="0123456789abcdef",e=new Array(256);for(let r=0;r<16;++r){let n=r*16;for(let i=0;i<16;++i)e[n+i]=t[r]+t[i]}return e}();function Jt(t){return typeof BigInt>"u"?Sw:t}function Sw(){throw new Error("BigInt not supported")}});var ta=M((LA,Nu)=>{"use strict";var ea=null;Nu.exports=function(){return ea===null&&(ea={textEncoder:new TextEncoder,textDecoder:new TextDecoder}),ea}});var ia=M(Du=>{"use strict";var ra=ze(),vw=new Set(["buffer","view","utf8"]),na=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"||!vw.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 ra(`Encoding '${this.name}' cannot be transcoded to 'buffer'`,{code:"LEVEL_ENCODING_NOT_SUPPORTED"})}createViewTranscoder(){throw new ra(`Encoding '${this.name}' cannot be transcoded to 'view'`,{code:"LEVEL_ENCODING_NOT_SUPPORTED"})}createUTF8Transcoder(){throw new ra(`Encoding '${this.name}' cannot be transcoded to 'utf8'`,{code:"LEVEL_ENCODING_NOT_SUPPORTED"})}};Du.Encoding=na});var ca=M(Wi=>{"use strict";var{Buffer:sa}=qe()||{},{Encoding:aa}=ia(),Bw=ta(),Qn=class extends aa{constructor(e){super({...e,format:"buffer"})}createViewTranscoder(){return new ei({encode:this.encode,decode:e=>this.decode(sa.from(e.buffer,e.byteOffset,e.byteLength)),name:`${this.name}+view`})}createBufferTranscoder(){return this}},ei=class extends aa{constructor(e){super({...e,format:"view"})}createBufferTranscoder(){return new Qn({encode:e=>{let r=this.encode(e);return sa.from(r.buffer,r.byteOffset,r.byteLength)},decode:this.decode,name:`${this.name}+buffer`})}createViewTranscoder(){return this}},oa=class extends aa{constructor(e){super({...e,format:"utf8"})}createBufferTranscoder(){return new Qn({encode:e=>sa.from(this.encode(e),"utf8"),decode:e=>this.decode(e.toString("utf8")),name:`${this.name}+buffer`})}createViewTranscoder(){let{textEncoder:e,textDecoder:r}=Bw();return new ei({encode:n=>e.encode(this.encode(n)),decode:n=>this.decode(r.decode(n)),name:`${this.name}+view`})}createUTF8Transcoder(){return this}};Wi.BufferFormat=Qn;Wi.ViewFormat=ei;Wi.UTF8Format=oa});var Fu=M(vr=>{"use strict";var{Buffer:Ae}=qe()||{Buffer:{isBuffer:()=>!1}},{textEncoder:qu,textDecoder:Mu}=ta()(),{BufferFormat:ti,ViewFormat:fa,UTF8Format:ju}=ca(),Ji=t=>t;vr.utf8=new ju({encode:function(t){return Ae.isBuffer(t)?t.toString("utf8"):ArrayBuffer.isView(t)?Mu.decode(t):String(t)},decode:Ji,name:"utf8",createViewTranscoder(){return new fa({encode:function(t){return ArrayBuffer.isView(t)?t:qu.encode(t)},decode:function(t){return Mu.decode(t)},name:`${this.name}+view`})},createBufferTranscoder(){return new ti({encode:function(t){return Ae.isBuffer(t)?t:ArrayBuffer.isView(t)?Ae.from(t.buffer,t.byteOffset,t.byteLength):Ae.from(String(t),"utf8")},decode:function(t){return t.toString("utf8")},name:`${this.name}+buffer`})}});vr.json=new ju({encode:JSON.stringify,decode:JSON.parse,name:"json"});vr.buffer=new ti({encode:function(t){return Ae.isBuffer(t)?t:ArrayBuffer.isView(t)?Ae.from(t.buffer,t.byteOffset,t.byteLength):Ae.from(String(t),"utf8")},decode:Ji,name:"buffer",createViewTranscoder(){return new fa({encode:function(t){return ArrayBuffer.isView(t)?t:Ae.from(String(t),"utf8")},decode:function(t){return Ae.from(t.buffer,t.byteOffset,t.byteLength)},name:`${this.name}+view`})}});vr.view=new fa({encode:function(t){return ArrayBuffer.isView(t)?t:qu.encode(t)},decode:Ji,name:"view",createBufferTranscoder(){return new ti({encode:function(t){return Ae.isBuffer(t)?t:ArrayBuffer.isView(t)?Ae.from(t.buffer,t.byteOffset,t.byteLength):Ae.from(String(t),"utf8")},decode:Ji,name:`${this.name}+buffer`})}});vr.hex=new ti({encode:function(t){return Ae.isBuffer(t)?t:Ae.from(String(t),"hex")},decode:function(t){return t.toString("hex")},name:"hex"});vr.base64=new ti({encode:function(t){return Ae.isBuffer(t)?t:Ae.from(String(t),"base64")},decode:function(t){return t.toString("base64")},name:"base64"})});var Hu=M(Vu=>{"use strict";var $u=ze(),Yi=Fu(),{Encoding:Tw}=ia(),{BufferFormat:kw,ViewFormat:Pw,UTF8Format:Iw}=ca(),ri=Symbol("formats"),zi=Symbol("encodings"),Rw=new Set(["buffer","view","utf8"]),ua=class{constructor(e){if(Array.isArray(e)){if(!e.every(r=>Rw.has(r)))throw new TypeError("Format must be one of 'buffer', 'view', 'utf8'")}else throw new TypeError("The first argument 'formats' must be an array");this[zi]=new Map,this[ri]=new Set(e);for(let r in Yi)try{this.encoding(r)}catch(n){if(n.code!=="LEVEL_ENCODING_NOT_SUPPORTED")throw n}}encodings(){return Array.from(new Set(this[zi].values()))}encoding(e){let r=this[zi].get(e);if(r===void 0){if(typeof e=="string"&&e!==""){if(r=Ow[e],!r)throw new $u(`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");r=Uw(e)}let{name:n,format:i}=r;if(!this[ri].has(i))if(this[ri].has("view"))r=r.createViewTranscoder();else if(this[ri].has("buffer"))r=r.createBufferTranscoder();else if(this[ri].has("utf8"))r=r.createUTF8Transcoder();else throw new $u(`Encoding '${n}' cannot be transcoded`,{code:"LEVEL_ENCODING_NOT_SUPPORTED"});for(let o of[e,n,r.name,r.commonName])this[zi].set(o,r)}return r}};Vu.Transcoder=ua;function Uw(t){if(t instanceof Tw)return t;let e="type"in t&&typeof t.type=="string"?t.type:void 0,r=t.name||e||`anonymous-${Kw++}`;switch(Cw(t)){case"view":return new Pw({...t,name:r});case"utf8":return new Iw({...t,name:r});case"buffer":return new kw({...t,name:r});default:throw new TypeError("Format must be one of 'buffer', 'view', 'utf8'")}}function Cw(t){return"format"in t&&t.format!==void 0?t.format:"buffer"in t&&typeof t.buffer=="boolean"?t.buffer?"buffer":"utf8":"code"in t&&Number.isInteger(t.code)?"view":"buffer"}var Lw={binary:Yi.buffer,"utf-8":Yi.utf8},Ow={...Yi,...Lw},Kw=0});var ln=M((MA,la)=>{"use strict";var un=typeof Reflect=="object"?Reflect:null,Gu=un&&typeof un.apply=="function"?un.apply:function(e,r,n){return Function.prototype.apply.call(e,r,n)},Zi;un&&typeof un.ownKeys=="function"?Zi=un.ownKeys:Object.getOwnPropertySymbols?Zi=function(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:Zi=function(e){return Object.getOwnPropertyNames(e)};function Nw(t){console&&console.warn&&console.warn(t)}var Ju=Number.isNaN||function(e){return e!==e};function re(){re.init.call(this)}la.exports=re;la.exports.once=jw;re.EventEmitter=re;re.prototype._events=void 0;re.prototype._eventsCount=0;re.prototype._maxListeners=void 0;var Wu=10;function Xi(t){if(typeof t!="function")throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof t)}Object.defineProperty(re,"defaultMaxListeners",{enumerable:!0,get:function(){return Wu},set:function(t){if(typeof t!="number"||t<0||Ju(t))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+t+".");Wu=t}});re.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};re.prototype.setMaxListeners=function(e){if(typeof e!="number"||e<0||Ju(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 zu(t){return t._maxListeners===void 0?re.defaultMaxListeners:t._maxListeners}re.prototype.getMaxListeners=function(){return zu(this)};re.prototype.emit=function(e){for(var r=[],n=1;n<arguments.length;n++)r.push(arguments[n]);var i=e==="error",o=this._events;if(o!==void 0)i=i&&o.error===void 0;else if(!i)return!1;if(i){var s;if(r.length>0&&(s=r[0]),s instanceof Error)throw s;var a=new Error("Unhandled error."+(s?" ("+s.message+")":""));throw a.context=s,a}var c=o[e];if(c===void 0)return!1;if(typeof c=="function")Gu(c,this,r);else for(var f=c.length,u=el(c,f),n=0;n<f;++n)Gu(u[n],this,r);return!0};function Yu(t,e,r,n){var i,o,s;if(Xi(r),o=t._events,o===void 0?(o=t._events=Object.create(null),t._eventsCount=0):(o.newListener!==void 0&&(t.emit("newListener",e,r.listener?r.listener:r),o=t._events),s=o[e]),s===void 0)s=o[e]=r,++t._eventsCount;else if(typeof s=="function"?s=o[e]=n?[r,s]:[s,r]:n?s.unshift(r):s.push(r),i=zu(t),i>0&&s.length>i&&!s.warned){s.warned=!0;var a=new Error("Possible EventEmitter memory leak detected. "+s.length+" "+String(e)+" listeners added. Use emitter.setMaxListeners() to increase limit");a.name="MaxListenersExceededWarning",a.emitter=t,a.type=e,a.count=s.length,Nw(a)}return t}re.prototype.addListener=function(e,r){return Yu(this,e,r,!1)};re.prototype.on=re.prototype.addListener;re.prototype.prependListener=function(e,r){return Yu(this,e,r,!0)};function Dw(){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 Zu(t,e,r){var n={fired:!1,wrapFn:void 0,target:t,type:e,listener:r},i=Dw.bind(n);return i.listener=r,n.wrapFn=i,i}re.prototype.once=function(e,r){return Xi(r),this.on(e,Zu(this,e,r)),this};re.prototype.prependOnceListener=function(e,r){return Xi(r),this.prependListener(e,Zu(this,e,r)),this};re.prototype.removeListener=function(e,r){var n,i,o,s,a;if(Xi(r),i=this._events,i===void 0)return this;if(n=i[e],n===void 0)return this;if(n===r||n.listener===r)--this._eventsCount===0?this._events=Object.create(null):(delete i[e],i.removeListener&&this.emit("removeListener",e,n.listener||r));else if(typeof n!="function"){for(o=-1,s=n.length-1;s>=0;s--)if(n[s]===r||n[s].listener===r){a=n[s].listener,o=s;break}if(o<0)return this;o===0?n.shift():Mw(n,o),n.length===1&&(i[e]=n[0]),i.removeListener!==void 0&&this.emit("removeListener",e,a||r)}return this};re.prototype.off=re.prototype.removeListener;re.prototype.removeAllListeners=function(e){var r,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 o=Object.keys(n),s;for(i=0;i<o.length;++i)s=o[i],s!=="removeListener"&&this.removeAllListeners(s);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if(r=n[e],typeof r=="function")this.removeListener(e,r);else if(r!==void 0)for(i=r.length-1;i>=0;i--)this.removeListener(e,r[i]);return this};function Xu(t,e,r){var n=t._events;if(n===void 0)return[];var i=n[e];return i===void 0?[]:typeof i=="function"?r?[i.listener||i]:[i]:r?qw(i):el(i,i.length)}re.prototype.listeners=function(e){return Xu(this,e,!0)};re.prototype.rawListeners=function(e){return Xu(this,e,!1)};re.listenerCount=function(t,e){return typeof t.listenerCount=="function"?t.listenerCount(e):Qu.call(t,e)};re.prototype.listenerCount=Qu;function Qu(t){var e=this._events;if(e!==void 0){var r=e[t];if(typeof r=="function")return 1;if(r!==void 0)return r.length}return 0}re.prototype.eventNames=function(){return this._eventsCount>0?Zi(this._events):[]};function el(t,e){for(var r=new Array(e),n=0;n<e;++n)r[n]=t[n];return r}function Mw(t,e){for(;e+1<t.length;e++)t[e]=t[e+1];t.pop()}function qw(t){for(var e=new Array(t.length),r=0;r<e.length;++r)e[r]=t[r].listener||t[r];return e}function jw(t,e){return new Promise(function(r,n){function i(s){t.removeListener(e,o),n(s)}function o(){typeof t.removeListener=="function"&&t.removeListener("error",i),r([].slice.call(arguments))}tl(t,e,o,{once:!0}),e!=="error"&&Fw(t,i,{once:!0})})}function Fw(t,e,r){typeof t.on=="function"&&tl(t,"error",e,r)}function tl(t,e,r,n){if(typeof t.on=="function")n.once?t.once(e,r):t.on(e,r);else if(typeof t.addEventListener=="function")t.addEventListener(e,function i(o){n.once&&t.removeEventListener(e,i),r(o)});else throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof t)}});var nl=M((qA,rl)=>{rl.exports=typeof queueMicrotask=="function"?queueMicrotask:t=>Promise.resolve().then(t)});var ni=M(da=>{"use strict";var il=nl();da.fromCallback=function(t,e){if(t===void 0){var r=new Promise(function(n,i){t=function(o,s){o?i(o):n(s)}});t[e!==void 0?e:"promise"]=r}else if(typeof t!="function")throw new TypeError("Callback must be a function");return t};da.fromPromise=function(t,e){if(e===void 0)return t;t.then(function(r){il(()=>e(null,r))}).catch(function(r){il(()=>e(r))})}});var Qi=M(ha=>{"use strict";ha.getCallback=function(t,e){return typeof t=="function"?t:e};ha.getOptions=function(t,e){return typeof t=="object"&&t!==null?t:e!==void 0?e:{}}});var er=M(no=>{"use strict";var{fromCallback:pa}=ni(),Le=ze(),{getOptions:ya,getCallback:ol}=Qi(),Br=Symbol("promise"),dn=Symbol("callback"),ft=Symbol("working"),Tr=Symbol("handleOne"),Tt=Symbol("handleMany"),wa=Symbol("autoClose"),Xt=Symbol("finishWork"),ut=Symbol("returnMany"),zt=Symbol("closing"),ii=Symbol("handleClose"),eo=Symbol("closed"),oi=Symbol("closeCallbacks"),Zt=Symbol("keyEncoding"),kr=Symbol("valueEncoding"),ma=Symbol("abortOnClose"),to=Symbol("legacy"),ba=Symbol("keys"),ga=Symbol("values"),Yt=Symbol("limit"),je=Symbol("count"),ro=Object.freeze({}),$w=()=>{},sl=!1,si=class{constructor(e,r,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 r!="object"||r===null)throw new TypeError("The second argument must be an options object");this[eo]=!1,this[oi]=[],this[ft]=!1,this[zt]=!1,this[wa]=!1,this[dn]=null,this[Tr]=this[Tr].bind(this),this[Tt]=this[Tt].bind(this),this[ii]=this[ii].bind(this),this[Zt]=r[Zt],this[kr]=r[kr],this[to]=n,this[Yt]=Number.isInteger(r.limit)&&r.limit>=0?r.limit:1/0,this[je]=0,this[ma]=!!r.abortOnClose,this.db=e,this.db.attachResource(this),this.nextTick=e.nextTick}get count(){return this[je]}get limit(){return this[Yt]}next(e){let r;if(e===void 0)r=new Promise((n,i)=>{e=(o,s,a)=>{o?i(o):this[to]?s===void 0&&a===void 0?n():n([s,a]):n(s)}});else if(typeof e!="function")throw new TypeError("Callback must be a function");return this[zt]?this.nextTick(e,new Le("Iterator is not open: cannot call next() after close()",{code:"LEVEL_ITERATOR_NOT_OPEN"})):this[ft]?this.nextTick(e,new Le("Iterator is busy: cannot call next() until previous call has completed",{code:"LEVEL_ITERATOR_BUSY"})):(this[ft]=!0,this[dn]=e,this[je]>=this[Yt]?this.nextTick(this[Tr],null):this._next(this[Tr])),r}_next(e){this.nextTick(e)}nextv(e,r,n){return n=ol(r,n),n=pa(n,Br),r=ya(r,ro),Number.isInteger(e)?(this[zt]?this.nextTick(n,new Le("Iterator is not open: cannot call nextv() after close()",{code:"LEVEL_ITERATOR_NOT_OPEN"})):this[ft]?this.nextTick(n,new Le("Iterator is busy: cannot call nextv() until previous call has completed",{code:"LEVEL_ITERATOR_BUSY"})):(e<1&&(e=1),this[Yt]<1/0&&(e=Math.min(e,this[Yt]-this[je])),this[ft]=!0,this[dn]=n,e<=0?this.nextTick(this[Tt],null,[]):this._nextv(e,r,this[Tt])),n[Br]):(this.nextTick(n,new TypeError("The first argument 'size' must be an integer")),n[Br])}_nextv(e,r,n){let i=[],o=(s,a,c)=>{if(s)return n(s);if(this[to]?a===void 0&&c===void 0:a===void 0)return n(null,i);i.push(this[to]?[a,c]:a),i.length===e?n(null,i):this._next(o)};this._next(o)}all(e,r){return r=ol(e,r),r=pa(r,Br),e=ya(e,ro),this[zt]?this.nextTick(r,new Le("Iterator is not open: cannot call all() after close()",{code:"LEVEL_ITERATOR_NOT_OPEN"})):this[ft]?this.nextTick(r,new Le("Iterator is busy: cannot call all() until previous call has completed",{code:"LEVEL_ITERATOR_BUSY"})):(this[ft]=!0,this[dn]=r,this[wa]=!0,this[je]>=this[Yt]?this.nextTick(this[Tt],null,[]):this._all(e,this[Tt])),r[Br]}_all(e,r){let n=this[je],i=[],o=()=>{let a=this[Yt]<1/0?Math.min(1e3,this[Yt]-n):1e3;a<=0?this.nextTick(r,null,i):this._nextv(a,ro,s)},s=(a,c)=>{a?r(a):c.length===0?r(null,i):(i.push.apply(i,c),n+=c.length,o())};o()}[Xt](){let e=this[dn];return this[ma]&&e===null?$w:(this[ft]=!1,this[dn]=null,this[zt]&&this._close(this[ii]),e)}[ut](e,r,n){this[wa]?this.close(e.bind(null,r,n)):e(r,n)}seek(e,r){if(r=ya(r,ro),!this[zt]){if(this[ft])throw new Le("Iterator is busy: cannot call seek() until next() has completed",{code:"LEVEL_ITERATOR_BUSY"});{let n=this.db.keyEncoding(r.keyEncoding||this[Zt]),i=n.format;r.keyEncoding!==i&&(r={...r,keyEncoding:i});let o=this.db.prefixKey(n.encode(e),i);this._seek(o,r)}}}_seek(e,r){throw new Le("Iterator does not support seek()",{code:"LEVEL_NOT_SUPPORTED"})}close(e){return e=pa(e,Br),this[eo]?this.nextTick(e):this[zt]?this[oi].push(e):(this[zt]=!0,this[oi].push(e),this[ft]?this[ma]&&this[Xt]()(new Le("Aborted on iterator close()",{code:"LEVEL_ITERATOR_NOT_OPEN"})):this._close(this[ii])),e[Br]}_close(e){this.nextTick(e)}[ii](){this[eo]=!0,this.db.detachResource(this);let e=this[oi];this[oi]=[];for(let r of e)r()}async*[Symbol.asyncIterator](){try{let e;for(;(e=await this.next())!==void 0;)yield e}finally{this[eo]||await this.close()}}},hn=class extends si{constructor(e,r){super(e,r,!0),this[ba]=r.keys!==!1,this[ga]=r.values!==!1}[Tr](e,r,n){let i=this[Xt]();if(e)return i(e);try{r=this[ba]&&r!==void 0?this[Zt].decode(r):void 0,n=this[ga]&&n!==void 0?this[kr].decode(n):void 0}catch(o){return i(new Qt("entry",o))}r===void 0&&n===void 0||this[je]++,i(null,r,n)}[Tt](e,r){let n=this[Xt]();if(e)return this[ut](n,e);try{for(let i of r){let o=i[0],s=i[1];i[0]=this[ba]&&o!==void 0?this[Zt].decode(o):void 0,i[1]=this[ga]&&s!==void 0?this[kr].decode(s):void 0}}catch(i){return this[ut](n,new Qt("entries",i))}this[je]+=r.length,this[ut](n,null,r)}end(e){return!sl&&typeof console<"u"&&(sl=!0,console.warn(new Le("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)}},xa=class extends si{constructor(e,r){super(e,r,!1)}[Tr](e,r){let n=this[Xt]();if(e)return n(e);try{r=r!==void 0?this[Zt].decode(r):void 0}catch(i){return n(new Qt("key",i))}r!==void 0&&this[je]++,n(null,r)}[Tt](e,r){let n=this[Xt]();if(e)return this[ut](n,e);try{for(let i=0;i<r.length;i++){let o=r[i];r[i]=o!==void 0?this[Zt].decode(o):void 0}}catch(i){return this[ut](n,new Qt("keys",i))}this[je]+=r.length,this[ut](n,null,r)}},Ea=class extends si{constructor(e,r){super(e,r,!1)}[Tr](e,r){let n=this[Xt]();if(e)return n(e);try{r=r!==void 0?this[kr].decode(r):void 0}catch(i){return n(new Qt("value",i))}r!==void 0&&this[je]++,n(null,r)}[Tt](e,r){let n=this[Xt]();if(e)return this[ut](n,e);try{for(let i=0;i<r.length;i++){let o=r[i];r[i]=o!==void 0?this[kr].decode(o):void 0}}catch(i){return this[ut](n,new Qt("values",i))}this[je]+=r.length,this[ut](n,null,r)}},Qt=class extends Le{constructor(e,r){super(`Iterator could not decode ${e}`,{code:"LEVEL_DECODE_ERROR",cause:r})}};for(let t of["_ended property","_nexting property","_end method"])Object.defineProperty(hn.prototype,t.split(" ")[0],{get(){throw new Le(`The ${t} has been removed`,{code:"LEVEL_LEGACY"})},set(){throw new Le(`The ${t} has been removed`,{code:"LEVEL_LEGACY"})}});hn.keyEncoding=Zt;hn.valueEncoding=kr;no.AbstractIterator=hn;no.AbstractKeyIterator=xa;no.AbstractValueIterator=Ea});var al=M(_a=>{"use strict";var{AbstractKeyIterator:Vw,AbstractValueIterator:Hw}=er(),Pr=Symbol("iterator"),ai=Symbol("callback"),pn=Symbol("handleOne"),Ir=Symbol("handleMany"),ci=class extends Vw{constructor(e,r){super(e,r),this[Pr]=e.iterator({...r,keys:!0,values:!1}),this[pn]=this[pn].bind(this),this[Ir]=this[Ir].bind(this)}},io=class extends Hw{constructor(e,r){super(e,r),this[Pr]=e.iterator({...r,keys:!1,values:!0}),this[pn]=this[pn].bind(this),this[Ir]=this[Ir].bind(this)}};for(let t of[ci,io]){let e=t===ci,r=e?n=>n[0]:n=>n[1];t.prototype._next=function(n){this[ai]=n,this[Pr].next(this[pn])},t.prototype[pn]=function(n,i,o){let s=this[ai];n?s(n):s(null,e?i:o)},t.prototype._nextv=function(n,i,o){this[ai]=o,this[Pr].nextv(n,i,this[Ir])},t.prototype._all=function(n,i){this[ai]=i,this[Pr].all(n,this[Ir])},t.prototype[Ir]=function(n,i){let o=this[ai];n?o(n):o(null,i.map(r))},t.prototype._seek=function(n,i){this[Pr].seek(n,i)},t.prototype._close=function(n){this[Pr].close(n)}}_a.DefaultKeyIterator=ci;_a.DefaultValueIterator=io});var cl=M(uo=>{"use strict";var{AbstractIterator:Gw,AbstractKeyIterator:Ww,AbstractValueIterator:Jw}=er(),Aa=ze(),Re=Symbol("nut"),co=Symbol("undefer"),fo=Symbol("factory"),oo=class extends Gw{constructor(e,r){super(e,r),this[Re]=null,this[fo]=()=>e.iterator(r),this.db.defer(()=>this[co]())}},so=class extends Ww{constructor(e,r){super(e,r),this[Re]=null,this[fo]=()=>e.keys(r),this.db.defer(()=>this[co]())}},ao=class extends Jw{constructor(e,r){super(e,r),this[Re]=null,this[fo]=()=>e.values(r),this.db.defer(()=>this[co]())}};for(let t of[oo,so,ao])t.prototype[co]=function(){this.db.status==="open"&&(this[Re]=this[fo]())},t.prototype._next=function(e){this[Re]!==null?this[Re].next(e):this.db.status==="opening"?this.db.defer(()=>this._next(e)):this.nextTick(e,new Aa("Iterator is not open: cannot call next() after close()",{code:"LEVEL_ITERATOR_NOT_OPEN"}))},t.prototype._nextv=function(e,r,n){this[Re]!==null?this[Re].nextv(e,r,n):this.db.status==="opening"?this.db.defer(()=>this._nextv(e,r,n)):this.nextTick(n,new Aa("Iterator is not open: cannot call nextv() after close()",{code:"LEVEL_ITERATOR_NOT_OPEN"}))},t.prototype._all=function(e,r){this[Re]!==null?this[Re].all(r):this.db.status==="opening"?this.db.defer(()=>this._all(e,r)):this.nextTick(r,new Aa("Iterator is not open: cannot call all() after close()",{code:"LEVEL_ITERATOR_NOT_OPEN"}))},t.prototype._seek=function(e,r){this[Re]!==null?this[Re]._seek(e,r):this.db.status==="opening"&&this.db.defer(()=>this._seek(e,r))},t.prototype._close=function(e){this[Re]!==null?this[Re].close(e):this.db.status==="opening"?this.db.defer(()=>this._close(e)):this.nextTick(e)};uo.DeferredIterator=oo;uo.DeferredKeyIterator=so;uo.DeferredValueIterator=ao});var va=M(ul=>{"use strict";var{fromCallback:fl}=ni(),lo=ze(),{getCallback:zw,getOptions:Yw}=Qi(),ho=Symbol("promise"),Fe=Symbol("status"),yn=Symbol("operations"),fi=Symbol("finishClose"),wn=Symbol("closeCallbacks"),Sa=class{constructor(e){if(typeof e!="object"||e===null){let r=e===null?"null":typeof e;throw new TypeError(`The first argument must be an abstract-level database, received ${r}`)}this[yn]=[],this[wn]=[],this[Fe]="open",this[fi]=this[fi].bind(this),this.db=e,this.db.attachResource(this),this.nextTick=e.nextTick}get length(){return this[yn].length}put(e,r,n){if(this[Fe]!=="open")throw new lo("Batch is not open: cannot call put() after write() or close()",{code:"LEVEL_BATCH_NOT_OPEN"});let i=this.db._checkKey(e)||this.db._checkValue(r);if(i)throw i;let o=n&&n.sublevel!=null?n.sublevel:this.db,s=n,a=o.keyEncoding(n&&n.keyEncoding),c=o.valueEncoding(n&&n.valueEncoding),f=a.format;n={...n,keyEncoding:f,valueEncoding:c.format},o!==this.db&&(n.sublevel=null);let u=o.prefixKey(a.encode(e),f),l=c.encode(r);return this._put(u,l,n),this[yn].push({...s,type:"put",key:e,value:r}),this}_put(e,r,n){}del(e,r){if(this[Fe]!=="open")throw new lo("Batch is not open: cannot call del() after write() or close()",{code:"LEVEL_BATCH_NOT_OPEN"});let n=this.db._checkKey(e);if(n)throw n;let i=r&&r.sublevel!=null?r.sublevel:this.db,o=r,s=i.keyEncoding(r&&r.keyEncoding),a=s.format;return r={...r,keyEncoding:a},i!==this.db&&(r.sublevel=null),this._del(i.prefixKey(s.encode(e),a),r),this[yn].push({...o,type:"del",key:e}),this}_del(e,r){}clear(){if(this[Fe]!=="open")throw new lo("Batch is not open: cannot call clear() after write() or close()",{code:"LEVEL_BATCH_NOT_OPEN"});return this._clear(),this[yn]=[],this}_clear(){}write(e,r){return r=zw(e,r),r=fl(r,ho),e=Yw(e),this[Fe]!=="open"?this.nextTick(r,new lo("Batch is not open: cannot call write() after write() or close()",{code:"LEVEL_BATCH_NOT_OPEN"})):this.length===0?this.close(r):(this[Fe]="writing",this._write(e,n=>{this[Fe]="closing",this[wn].push(()=>r(n)),n||this.db.emit("batch",this[yn]),this._close(this[fi])})),r[ho]}_write(e,r){}close(e){return e=fl(e,ho),this[Fe]==="closing"?this[wn].push(e):this[Fe]==="closed"?this.nextTick(e):(this[wn].push(e),this[Fe]!=="writing"&&(this[Fe]="closing",this._close(this[fi]))),e[ho]}_close(e){this.nextTick(e)}[fi](){this[Fe]="closed",this.db.detachResource(this);let e=this[wn];this[wn]=[];for(let r of e)r()}};ul.AbstractChainedBatch=Sa});var dl=M(ll=>{"use strict";var{AbstractChainedBatch:Zw}=va(),Xw=ze(),mn=Symbol("encoded"),Ba=class extends Zw{constructor(e){super(e),this[mn]=[]}_put(e,r,n){this[mn].push({...n,type:"put",key:e,value:r})}_del(e,r){this[mn].push({...r,type:"del",key:e})}_clear(){this[mn]=[]}_write(e,r){this.db.status==="opening"?this.db.defer(()=>this._write(e,r)):this.db.status==="open"?this[mn].length===0?this.nextTick(r):this.db._batch(this[mn],e,r):this.nextTick(r,new Xw("Batch is not open: cannot call write() after write() or close()",{code:"LEVEL_BATCH_NOT_OPEN"}))}};ll.DefaultChainedBatch=Ba});var yl=M((JA,pl)=>{"use strict";var hl=ze(),Qw=Object.prototype.hasOwnProperty,em=new Set(["lt","lte","gt","gte"]);pl.exports=function(t,e){let r={};for(let n in t)if(Qw.call(t,n)&&!(n==="keyEncoding"||n==="valueEncoding")){if(n==="start"||n==="end")throw new hl(`The legacy range option '${n}' has been removed`,{code:"LEVEL_LEGACY"});if(n==="encoding")throw new hl("The levelup-style 'encoding' alias has been removed, use 'valueEncoding' instead",{code:"LEVEL_LEGACY"});em.has(n)?r[n]=e.encode(t[n]):r[n]=t[n]}return r.reverse=!!r.reverse,r.limit=Number.isInteger(r.limit)&&r.limit>=0?r.limit:-1,r}});var Ta=M((zA,ml)=>{var wl;ml.exports=typeof queueMicrotask=="function"?queueMicrotask.bind(typeof window<"u"?window:globalThis):t=>(wl||(wl=Promise.resolve())).then(t).catch(e=>setTimeout(()=>{throw e},0))});var xl=M((YA,gl)=>{"use strict";var bl=Ta();gl.exports=function(t,...e){e.length===0?bl(t):bl(()=>t(...e))}});var El=M(po=>{"use strict";var{AbstractIterator:tm,AbstractKeyIterator:rm,AbstractValueIterator:nm}=er(),bn=Symbol("unfix"),Ye=Symbol("iterator"),Rr=Symbol("handleOne"),tr=Symbol("handleMany"),kt=Symbol("callback"),ui=class extends tm{constructor(e,r,n,i){super(e,r),this[Ye]=n,this[bn]=i,this[Rr]=this[Rr].bind(this),this[tr]=this[tr].bind(this),this[kt]=null}[Rr](e,r,n){let i=this[kt];if(e)return i(e);r!==void 0&&(r=this[bn](r)),i(e,r,n)}[tr](e,r){let n=this[kt];if(e)return n(e);for(let i of r){let o=i[0];o!==void 0&&(i[0]=this[bn](o))}n(e,r)}},li=class extends rm{constructor(e,r,n,i){super(e,r),this[Ye]=n,this[bn]=i,this[Rr]=this[Rr].bind(this),this[tr]=this[tr].bind(this),this[kt]=null}[Rr](e,r){let n=this[kt];if(e)return n(e);r!==void 0&&(r=this[bn](r)),n(e,r)}[tr](e,r){let n=this[kt];if(e)return n(e);for(let i=0;i<r.length;i++){let o=r[i];o!==void 0&&(r[i]=this[bn](o))}n(e,r)}},di=class extends nm{constructor(e,r,n){super(e,r),this[Ye]=n}};for(let t of[ui,li])t.prototype._next=function(e){this[kt]=e,this[Ye].next(this[Rr])},t.prototype._nextv=function(e,r,n){this[kt]=n,this[Ye].nextv(e,r,this[tr])},t.prototype._all=function(e,r){this[kt]=r,this[Ye].all(e,this[tr])};for(let t of[di])t.prototype._next=function(e){this[Ye].next(e)},t.prototype._nextv=function(e,r,n){this[Ye].nextv(e,r,n)},t.prototype._all=function(e,r){this[Ye].all(e,r)};for(let t of[ui,li,di])t.prototype._seek=function(e,r){this[Ye].seek(e,r)},t.prototype._close=function(e){this[Ye].close(e)};po.AbstractSublevelIterator=ui;po.AbstractSublevelKeyIterator=li;po.AbstractSublevelValueIterator=di});var vl=M((XA,Sl)=>{"use strict";var ka=ze(),{Buffer:Ra}=qe()||{},{AbstractSublevelIterator:im,AbstractSublevelKeyIterator:om,AbstractSublevelValueIterator:sm}=El(),Pt=Symbol("prefix"),_l=Symbol("upperBound"),hi=Symbol("prefixRange"),Oe=Symbol("parent"),Pa=Symbol("unfix"),Al=new TextEncoder,am={separator:"!"};Sl.exports=function({AbstractLevel:t}){class e extends t{static defaults(n){if(typeof n=="string")throw new ka("The subleveldown string shorthand for { separator } has been removed",{code:"LEVEL_LEGACY"});if(n&&n.open)throw new ka("The subleveldown open option has been removed",{code:"LEVEL_LEGACY"});return n==null?am:n.separator?n:{...n,separator:"!"}}constructor(n,i,o){let{separator:s,manifest:a,...c}=e.defaults(o);i=fm(i,s);let f=s.charCodeAt(0)+1,u=n[Oe]||n;if(!Al.encode(i).every(h=>h>f&&h<127))throw new ka(`Prefix must use bytes > ${f} < 127`,{code:"LEVEL_INVALID_PREFIX"});super(cm(u,a),c);let l=(n.prefix||"")+s+i+s,p=l.slice(0,-1)+String.fromCharCode(f);this[Oe]=u,this[Pt]=new yo(l),this[_l]=new yo(p),this[Pa]=new Ua,this.nextTick=u.nextTick}prefixKey(n,i){if(i==="utf8")return this[Pt].utf8+n;if(n.byteLength===0)return this[Pt][i];if(i==="view"){let o=this[Pt].view,s=new Uint8Array(o.byteLength+n.byteLength);return s.set(o,0),s.set(n,o.byteLength),s}else{let o=this[Pt].buffer;return Ra.concat([o,n],o.byteLength+n.byteLength)}}[hi](n,i){n.gte!==void 0?n.gte=this.prefixKey(n.gte,i):n.gt!==void 0?n.gt=this.prefixKey(n.gt,i):n.gte=this[Pt][i],n.lte!==void 0?n.lte=this.prefixKey(n.lte,i):n.lt!==void 0?n.lt=this.prefixKey(n.lt,i):n.lte=this[_l][i]}get prefix(){return this[Pt].utf8}get db(){return this[Oe]}_open(n,i){this[Oe].open({passive:!0},i)}_put(n,i,o,s){this[Oe].put(n,i,o,s)}_get(n,i,o){this[Oe].get(n,i,o)}_getMany(n,i,o){this[Oe].getMany(n,i,o)}_del(n,i,o){this[Oe].del(n,i,o)}_batch(n,i,o){this[Oe].batch(n,i,o)}_clear(n,i){this[hi](n,n.keyEncoding),this[Oe].clear(n,i)}_iterator(n){this[hi](n,n.keyEncoding);let i=this[Oe].iterator(n),o=this[Pa].get(this[Pt].utf8.length,n.keyEncoding);return new im(this,n,i,o)}_keys(n){this[hi](n,n.keyEncoding);let i=this[Oe].keys(n),o=this[Pa].get(this[Pt].utf8.length,n.keyEncoding);return new om(this,n,i,o)}_values(n){this[hi](n,n.keyEncoding);let i=this[Oe].values(n);return new sm(this,n,i)}}return{AbstractSublevel:e}};var cm=function(t,e){return{...t.supports,createIfMissing:!1,errorIfExists:!1,events:{},additionalMethods:{},...e,encodings:{utf8:Ia(t,"utf8"),buffer:Ia(t,"buffer"),view:Ia(t,"view")}}},Ia=function(t,e){return t.supports.encodings[e]?t.keyEncoding(e).name===e:!1},yo=class{constructor(e){this.utf8=e,this.view=Al.encode(e),this.buffer=Ra?Ra.from(this.view.buffer,0,this.view.byteLength):{}}},Ua=class{constructor(){this.cache=new Map}get(e,r){let n=this.cache.get(r);return n===void 0&&(r==="view"?n=(function(i,o){return o.subarray(i)}).bind(null,e):n=(function(i,o){return o.slice(i)}).bind(null,e),this.cache.set(r,n)),n}},fm=function(t,e){let r=0,n=t.length;for(;r<n&&t[r]===e;)r++;for(;n>r&&t[n-1]===e;)n--;return t.slice(r,n)}});var Na=M(Ka=>{"use strict";var{supports:um}=yu(),{Transcoder:lm}=Hu(),{EventEmitter:dm}=ln(),{fromCallback:rr}=ni(),Ze=ze(),{AbstractIterator:Ur}=er(),{DefaultKeyIterator:hm,DefaultValueIterator:pm}=al(),{DeferredIterator:ym,DeferredKeyIterator:wm,DeferredValueIterator:mm}=cl(),{DefaultChainedBatch:Bl}=dl(),{getCallback:Cr,getOptions:nr}=Qi(),wo=yl(),J=Symbol("promise"),It=Symbol("landed"),Lr=Symbol("resources"),Ca=Symbol("closeResources"),pi=Symbol("operations"),yi=Symbol("undefer"),mo=Symbol("deferOpen"),Tl=Symbol("options"),X=Symbol("status"),Or=Symbol("defaultOptions"),gn=Symbol("transcoder"),bo=Symbol("keyEncoding"),La=Symbol("valueEncoding"),bm=()=>{},wi=class extends dm{constructor(e,r){if(super(),typeof e!="object"||e===null)throw new TypeError("The first argument 'manifest' must be an object");r=nr(r);let{keyEncoding:n,valueEncoding:i,passive:o,...s}=r;this[Lr]=new Set,this[pi]=[],this[mo]=!0,this[Tl]=s,this[X]="opening",this.supports=um(e,{status:!0,promises:!0,clear:!0,getMany:!0,deferredOpen:!0,snapshots:e.snapshots!==!1,permanence:e.permanence!==!1,keyIterator:!0,valueIterator:!0,iteratorNextv:!0,iteratorAll:!0,encodings:e.encodings||{},events:Object.assign({},e.events,{opening:!0,open:!0,closing:!0,closed:!0,put:!0,del:!0,batch:!0,clear:!0})}),this[gn]=new lm(gm(this)),this[bo]=this[gn].encoding(n||"utf8"),this[La]=this[gn].encoding(i||"utf8");for(let a of this[gn].encodings())this.supports.encodings[a.commonName]||(this.supports.encodings[a.commonName]=!0);this[Or]={empty:Object.freeze({}),entry:Object.freeze({keyEncoding:this[bo].commonName,valueEncoding:this[La].commonName}),key:Object.freeze({keyEncoding:this[bo].commonName})},this.nextTick(()=>{this[mo]&&this.open({passive:!1},bm)})}get status(){return this[X]}keyEncoding(e){return this[gn].encoding(e??this[bo])}valueEncoding(e){return this[gn].encoding(e??this[La])}open(e,r){r=Cr(e,r),r=rr(r,J),e={...this[Tl],...nr(e)},e.createIfMissing=e.createIfMissing!==!1,e.errorIfExists=!!e.errorIfExists;let n=i=>{this[X]==="closing"||this[X]==="opening"?this.once(It,i?()=>n(i):n):this[X]!=="open"?r(new Ze("Database is not open",{code:"LEVEL_DATABASE_NOT_OPEN",cause:i})):r()};return e.passive?this[X]==="opening"?this.once(It,n):this.nextTick(n):this[X]==="closed"||this[mo]?(this[mo]=!1,this[X]="opening",this.emit("opening"),this._open(e,i=>{if(i){this[X]="closed",this[Ca](()=>{this.emit(It),n(i)}),this[yi]();return}this[X]="open",this[yi](),this.emit(It),this[X]==="open"&&this.emit("open"),this[X]==="open"&&this.emit("ready"),n()})):this[X]==="open"?this.nextTick(n):this.once(It,()=>this.open(e,r)),r[J]}_open(e,r){this.nextTick(r)}close(e){e=rr(e,J);let r=n=>{this[X]==="opening"||this[X]==="closing"?this.once(It,n?r(n):r):this[X]!=="closed"?e(new Ze("Database is not closed",{code:"LEVEL_DATABASE_NOT_CLOSED",cause:n})):e()};if(this[X]==="open"){this[X]="closing",this.emit("closing");let n=i=>{this[X]="open",this[yi](),this.emit(It),r(i)};this[Ca](()=>{this._close(i=>{if(i)return n(i);this[X]="closed",this[yi](),this.emit(It),this[X]==="closed"&&this.emit("closed"),r()})})}else this[X]==="closed"?this.nextTick(r):this.once(It,()=>this.close(e));return e[J]}[Ca](e){if(this[Lr].size===0)return this.nextTick(e);let r=this[Lr].size,n=!0,i=()=>{--r===0&&(n?this.nextTick(e):e())};for(let o of this[Lr])o.close(i);n=!1,this[Lr].clear()}_close(e){this.nextTick(e)}get(e,r,n){if(n=Cr(r,n),n=rr(n,J),r=nr(r,this[Or].entry),this[X]==="opening")return this.defer(()=>this.get(e,r,n)),n[J];if(xn(this,n))return n[J];let i=this._checkKey(e);if(i)return this.nextTick(n,i),n[J];let o=this.keyEncoding(r.keyEncoding),s=this.valueEncoding(r.valueEncoding),a=o.format,c=s.format;return(r.keyEncoding!==a||r.valueEncoding!==c)&&(r=Object.assign({},r,{keyEncoding:a,valueEncoding:c})),this._get(this.prefixKey(o.encode(e),a),r,(f,u)=>{if(f)return(f.code==="LEVEL_NOT_FOUND"||f.notFound||/NotFound/i.test(f))&&(f.code||(f.code="LEVEL_NOT_FOUND"),f.notFound||(f.notFound=!0),f.status||(f.status=404)),n(f);try{u=s.decode(u)}catch(l){return n(new Ze("Could not decode value",{code:"LEVEL_DECODE_ERROR",cause:l}))}n(null,u)}),n[J]}_get(e,r,n){this.nextTick(n,new Error("NotFound"))}getMany(e,r,n){if(n=Cr(r,n),n=rr(n,J),r=nr(r,this[Or].entry),this[X]==="opening")return this.defer(()=>this.getMany(e,r,n)),n[J];if(xn(this,n))return n[J];if(!Array.isArray(e))return this.nextTick(n,new TypeError("The first argument 'keys' must be an array")),n[J];if(e.length===0)return this.nextTick(n,null,[]),n[J];let i=this.keyEncoding(r.keyEncoding),o=this.valueEncoding(r.valueEncoding),s=i.format,a=o.format;(r.keyEncoding!==s||r.valueEncoding!==a)&&(r=Object.assign({},r,{keyEncoding:s,valueEncoding:a}));let c=new Array(e.length);for(let f=0;f<e.length;f++){let u=e[f],l=this._checkKey(u);if(l)return this.nextTick(n,l),n[J];c[f]=this.prefixKey(i.encode(u),s)}return this._getMany(c,r,(f,u)=>{if(f)return n(f);try{for(let l=0;l<u.length;l++)u[l]!==void 0&&(u[l]=o.decode(u[l]))}catch(l){return n(new Ze(`Could not decode one or more of ${u.length} value(s)`,{code:"LEVEL_DECODE_ERROR",cause:l}))}n(null,u)}),n[J]}_getMany(e,r,n){this.nextTick(n,null,new Array(e.length).fill(void 0))}put(e,r,n,i){if(i=Cr(n,i),i=rr(i,J),n=nr(n,this[Or].entry),this[X]==="opening")return this.defer(()=>this.put(e,r,n,i)),i[J];if(xn(this,i))return i[J];let o=this._checkKey(e)||this._checkValue(r);if(o)return this.nextTick(i,o),i[J];let s=this.keyEncoding(n.keyEncoding),a=this.valueEncoding(n.valueEncoding),c=s.format,f=a.format;(n.keyEncoding!==c||n.valueEncoding!==f)&&(n=Object.assign({},n,{keyEncoding:c,valueEncoding:f}));let u=this.prefixKey(s.encode(e),c),l=a.encode(r);return this._put(u,l,n,p=>{if(p)return i(p);this.emit("put",e,r),i()}),i[J]}_put(e,r,n,i){this.nextTick(i)}del(e,r,n){if(n=Cr(r,n),n=rr(n,J),r=nr(r,this[Or].key),this[X]==="opening")return this.defer(()=>this.del(e,r,n)),n[J];if(xn(this,n))return n[J];let i=this._checkKey(e);if(i)return this.nextTick(n,i),n[J];let o=this.keyEncoding(r.keyEncoding),s=o.format;return r.keyEncoding!==s&&(r=Object.assign({},r,{keyEncoding:s})),this._del(this.prefixKey(o.encode(e),s),r,a=>{if(a)return n(a);this.emit("del",e),n()}),n[J]}_del(e,r,n){this.nextTick(n)}batch(e,r,n){if(!arguments.length){if(this[X]==="opening")return new Bl(this);if(this[X]!=="open")throw new Ze("Database is not open",{code:"LEVEL_DATABASE_NOT_OPEN"});return this._chainedBatch()}if(typeof e=="function"?n=e:n=Cr(r,n),n=rr(n,J),r=nr(r,this[Or].empty),this[X]==="opening")return this.defer(()=>this.batch(e,r,n)),n[J];if(xn(this,n))return n[J];if(!Array.isArray(e))return this.nextTick(n,new TypeError("The first argument 'operations' must be an array")),n[J];if(e.length===0)return this.nextTick(n),n[J];let i=new Array(e.length),{keyEncoding:o,valueEncoding:s,...a}=r;for(let c=0;c<e.length;c++){if(typeof e[c]!="object"||e[c]===null)return this.nextTick(n,new TypeError("A batch operation must be an object")),n[J];let f=Object.assign({},e[c]);if(f.type!=="put"&&f.type!=="del")return this.nextTick(n,new TypeError("A batch operation must have a type property that is 'put' or 'del'")),n[J];let u=this._checkKey(f.key);if(u)return this.nextTick(n,u),n[J];let l=f.sublevel!=null?f.sublevel:this,p=l.keyEncoding(f.keyEncoding||o),h=p.format;if(f.key=l.prefixKey(p.encode(f.key),h),f.keyEncoding=h,f.type==="put"){let y=this._checkValue(f.value);if(y)return this.nextTick(n,y),n[J];let d=l.valueEncoding(f.valueEncoding||s);f.value=d.encode(f.value),f.valueEncoding=d.format}l!==this&&(f.sublevel=null),i[c]=f}return this._batch(i,a,c=>{if(c)return n(c);this.emit("batch",e),n()}),n[J]}_batch(e,r,n){this.nextTick(n)}sublevel(e,r){return this._sublevel(e,Oa.defaults(r))}_sublevel(e,r){return new Oa(this,e,r)}prefixKey(e,r){return e}clear(e,r){if(r=Cr(e,r),r=rr(r,J),e=nr(e,this[Or].empty),this[X]==="opening")return this.defer(()=>this.clear(e,r)),r[J];if(xn(this,r))return r[J];let n=e,i=this.keyEncoding(e.keyEncoding);return e=wo(e,i),e.keyEncoding=i.format,e.limit===0?this.nextTick(r):this._clear(e,o=>{if(o)return r(o);this.emit("clear",n),r()}),r[J]}_clear(e,r){this.nextTick(r)}iterator(e){let r=this.keyEncoding(e&&e.keyEncoding),n=this.valueEncoding(e&&e.valueEncoding);if(e=wo(e,r),e.keys=e.keys!==!1,e.values=e.values!==!1,e[Ur.keyEncoding]=r,e[Ur.valueEncoding]=n,e.keyEncoding=r.format,e.valueEncoding=n.format,this[X]==="opening")return new ym(this,e);if(this[X]!=="open")throw new Ze("Database is not open",{code:"LEVEL_DATABASE_NOT_OPEN"});return this._iterator(e)}_iterator(e){return new Ur(this,e)}keys(e){let r=this.keyEncoding(e&&e.keyEncoding),n=this.valueEncoding(e&&e.valueEncoding);if(e=wo(e,r),e[Ur.keyEncoding]=r,e[Ur.valueEncoding]=n,e.keyEncoding=r.format,e.valueEncoding=n.format,this[X]==="opening")return new wm(this,e);if(this[X]!=="open")throw new Ze("Database is not open",{code:"LEVEL_DATABASE_NOT_OPEN"});return this._keys(e)}_keys(e){return new hm(this,e)}values(e){let r=this.keyEncoding(e&&e.keyEncoding),n=this.valueEncoding(e&&e.valueEncoding);if(e=wo(e,r),e[Ur.keyEncoding]=r,e[Ur.valueEncoding]=n,e.keyEncoding=r.format,e.valueEncoding=n.format,this[X]==="opening")return new mm(this,e);if(this[X]!=="open")throw new Ze("Database is not open",{code:"LEVEL_DATABASE_NOT_OPEN"});return this._values(e)}_values(e){return new pm(this,e)}defer(e){if(typeof e!="function")throw new TypeError("The first argument must be a function");this[pi].push(e)}[yi](){if(this[pi].length===0)return;let e=this[pi];this[pi]=[];for(let r of e)r()}attachResource(e){if(typeof e!="object"||e===null||typeof e.close!="function")throw new TypeError("The first argument must be a resource object");this[Lr].add(e)}detachResource(e){this[Lr].delete(e)}_chainedBatch(){return new Bl(this)}_checkKey(e){if(e==null)return new Ze("Key cannot be null or undefined",{code:"LEVEL_INVALID_KEY"})}_checkValue(e){if(e==null)return new Ze("Value cannot be null or undefined",{code:"LEVEL_INVALID_VALUE"})}};wi.prototype.nextTick=xl();var{AbstractSublevel:Oa}=vl()({AbstractLevel:wi});Ka.AbstractLevel=wi;Ka.AbstractSublevel=Oa;var xn=function(t,e){return t[X]!=="open"?(t.nextTick(e,new Ze("Database is not open",{code:"LEVEL_DATABASE_NOT_OPEN"})),!0):!1},gm=function(t){return Object.keys(t.supports.encodings).filter(e=>!!t.supports.encodings[e])}});var Da=M(Kr=>{"use strict";Kr.AbstractLevel=Na().AbstractLevel;Kr.AbstractSublevel=Na().AbstractSublevel;Kr.AbstractIterator=er().AbstractIterator;Kr.AbstractKeyIterator=er().AbstractKeyIterator;Kr.AbstractValueIterator=er().AbstractValueIterator;Kr.AbstractChainedBatch=va().AbstractChainedBatch});var Pl=M((tS,kl)=>{kl.exports=Em;var xm=Ta();function Em(t,e,r){if(typeof e!="number")throw new Error("second argument must be a Number");let n,i,o,s,a,c=!0,f;Array.isArray(t)?(n=[],o=i=t.length):(s=Object.keys(t),n={},o=i=s.length);function u(p){function h(){r&&r(p,n),r=null}c?xm(h):h()}function l(p,h,y){if(n[p]=y,h&&(a=!0),--o===0||h)u(h);else if(!a&&f<i){let d;s?(d=s[f],f+=1,t[d](function(w,m){l(d,w,m)})):(d=f,f+=1,t[d](function(w,m){l(d,w,m)}))}}f=e,o?s?s.some(function(p,h){return t[p](function(y,d){l(p,y,d)}),h===e-1}):t.some(function(p,h){return p(function(y,d){l(h,y,d)}),h===e-1}):u(null),c=!1}});var Ma=M((rS,Il)=>{"use strict";Il.exports=function(e){let r=e.gte!==void 0?e.gte:e.gt!==void 0?e.gt:void 0,n=e.lte!==void 0?e.lte:e.lt!==void 0?e.lt:void 0,i=e.gte===void 0,o=e.lte===void 0;return r!==void 0&&n!==void 0?IDBKeyRange.bound(r,n,i,o):r!==void 0?IDBKeyRange.lowerBound(r,i):n!==void 0?IDBKeyRange.upperBound(n,o):null}});var qa=M((nS,Rl)=>{"use strict";var _m=new TextEncoder;Rl.exports=function(t){return t instanceof Uint8Array?t:t instanceof ArrayBuffer?new Uint8Array(t):_m.encode(t)}});var Kl=M(Ol=>{"use strict";var{AbstractIterator:Am}=Da(),Ul=Ma(),go=qa(),lt=Symbol("cache"),Rt=Symbol("finished"),Ke=Symbol("options"),Ut=Symbol("currentOptions"),Nr=Symbol("position"),ja=Symbol("location"),En=Symbol("first"),Cl={},Fa=class extends Am{constructor(e,r,n){super(e,n),this[lt]=[],this[Rt]=this.limit===0,this[Ke]=n,this[Ut]={...n},this[Nr]=void 0,this[ja]=r,this[En]=!0}_nextv(e,r,n){if(this[En]=!1,this[Rt])return this.nextTick(n,null,[]);if(this[lt].length>0)return e=Math.min(e,this[lt].length),this.nextTick(n,null,this[lt].splice(0,e));this[Nr]!==void 0&&(this[Ke].reverse?(this[Ut].lt=this[Nr],this[Ut].lte=void 0):(this[Ut].gt=this[Nr],this[Ut].gte=void 0));let i;try{i=Ul(this[Ut])}catch{return this[Rt]=!0,this.nextTick(n,null,[])}let o=this.db.db.transaction([this[ja]],"readonly"),s=o.objectStore(this[ja]),a=[];if(this[Ke].reverse){let c=!this[Ke].values&&s.openKeyCursor?"openKeyCursor":"openCursor";s[c](i,"prev").onsuccess=f=>{let u=f.target.result;if(u){let{key:l,value:p}=u;this[Nr]=l,a.push([this[Ke].keys&&l!==void 0?go(l):void 0,this[Ke].values&&p!==void 0?go(p):void 0]),a.length<e?u.continue():Ll(o)}else this[Rt]=!0}}else{let c,f,u=()=>{if(c===void 0||f===void 0)return;let l=Math.max(c.length,f.length);l===0||e===1/0?this[Rt]=!0:this[Nr]=c[l-1],a.length=l;for(let p=0;p<l;p++){let h=c[p],y=f[p];a[p]=[this[Ke].keys&&h!==void 0?go(h):void 0,this[Ke].values&&y!==void 0?go(y):void 0]}Ll(o)};this[Ke].keys||e<1/0?s.getAllKeys(i,e<1/0?e:void 0).onsuccess=l=>{c=l.target.result,u()}:(c=[],this.nextTick(u)),this[Ke].values?s.getAll(i,e<1/0?e:void 0).onsuccess=l=>{f=l.target.result,u()}:(f=[],this.nextTick(u))}o.onabort=()=>{n(o.error||new Error("aborted by user")),n=null},o.oncomplete=()=>{n(null,a),n=null}}_next(e){if(this[lt].length>0){let[r,n]=this[lt].shift();this.nextTick(e,null,r,n)}else if(this[Rt])this.nextTick(e);else{let r=Math.min(100,this.limit-this.count);this[En]&&(this[En]=!1,r=1),this._nextv(r,Cl,(n,i)=>{if(n)return e(n);this[lt]=i,this._next(e)})}}_all(e,r){this[En]=!1;let n=this[lt].splice(0,this[lt].length),i=this.limit-this.count-n.length;if(i<=0)return this.nextTick(r,null,n);this._nextv(i,Cl,(o,s)=>{if(o)return r(o);n.length>0&&(s=n.concat(s)),r(null,s)})}_seek(e,r){this[En]=!0,this[lt]=[],this[Rt]=!1,this[Nr]=void 0,this[Ut]={...this[Ke]};let n;try{n=Ul(this[Ke])}catch{this[Rt]=!0;return}n!==null&&!n.includes(e)?this[Rt]=!0:this[Ke].reverse?this[Ut].lte=e:this[Ut].gte=e}};Ol.Iterator=Fa;function Ll(t){typeof t.commit=="function"&&t.commit()}});var Dl=M((oS,Nl)=>{"use strict";Nl.exports=function(e,r,n,i,o){if(i.limit===0)return e.nextTick(o);let s=e.db.transaction([r],"readwrite"),a=s.objectStore(r),c=0;s.oncomplete=function(){o()},s.onabort=function(){o(s.error||new Error("aborted by user"))};let f=a.openKeyCursor?"openKeyCursor":"openCursor",u=i.reverse?"prev":"next";a[f](n,u).onsuccess=function(l){let p=l.target.result;p&&(a.delete(p.key).onsuccess=function(){(i.limit<=0||++c<i.limit)&&p.continue()})}}});var Vl=M($l=>{"use strict";var{AbstractLevel:Sm}=Da(),Ml=ze(),vm=Pl(),{fromCallback:Bm}=ni(),{Iterator:Tm}=Kl(),ql=qa(),km=Dl(),Pm=Ma(),Fl="level-js-",mi=Symbol("idb"),$a=Symbol("namePrefix"),Ct=Symbol("location"),Va=Symbol("version"),Dr=Symbol("store"),bi=Symbol("onComplete"),jl=Symbol("promise"),xo=class extends Sm{constructor(e,r,n){if(typeof r=="function"||typeof n=="function")throw new Ml("The levelup-style callback argument has been removed",{code:"LEVEL_LEGACY"});let{prefix:i,version:o,...s}=r||{};if(super({encodings:{view:!0},snapshots:!1,createIfMissing:!1,errorIfExists:!1,seek:!0},s),typeof e!="string")throw new Error("constructor requires a location string argument");this[Ct]=e,this[$a]=i??Fl,this[Va]=parseInt(o||1,10),this[mi]=null}get location(){return this[Ct]}get namePrefix(){return this[$a]}get version(){return this[Va]}get db(){return this[mi]}get type(){return"browser-level"}_open(e,r){let n=indexedDB.open(this[$a]+this[Ct],this[Va]);n.onerror=function(){r(n.error||new Error("unknown error"))},n.onsuccess=()=>{this[mi]=n.result,r()},n.onupgradeneeded=i=>{let o=i.target.result;o.objectStoreNames.contains(this[Ct])||o.createObjectStore(this[Ct])}}[Dr](e){return this[mi].transaction([this[Ct]],e).objectStore(this[Ct])}[bi](e,r){let n=e.transaction;n.onabort=function(){r(n.error||new Error("aborted by user"))},n.oncomplete=function(){r(null,e.result)}}_get(e,r,n){let i=this[Dr]("readonly"),o;try{o=i.get(e)}catch(s){return this.nextTick(n,s)}this[bi](o,function(s,a){if(s)return n(s);if(a===void 0)return n(new Ml("Entry not found",{code:"LEVEL_NOT_FOUND"}));n(null,ql(a))})}_getMany(e,r,n){let i=this[Dr]("readonly"),o=e.map(s=>a=>{let c;try{c=i.get(s)}catch(f){return a(f)}c.onsuccess=()=>{let f=c.result;a(null,f===void 0?f:ql(f))},c.onerror=f=>{f.stopPropagation(),a(c.error)}});vm(o,16,n)}_del(e,r,n){let i=this[Dr]("readwrite"),o;try{o=i.delete(e)}catch(s){return this.nextTick(n,s)}this[bi](o,n)}_put(e,r,n,i){let o=this[Dr]("readwrite"),s;try{s=o.put(r,e)}catch(a){return this.nextTick(i,a)}this[bi](s,i)}_iterator(e){return new Tm(this,this[Ct],e)}_batch(e,r,n){let i=this[Dr]("readwrite"),o=i.transaction,s=0,a;o.onabort=function(){n(a||o.error||new Error("aborted by user"))},o.oncomplete=function(){n()};function c(){let f=e[s++],u=f.key,l;try{l=f.type==="del"?i.delete(u):i.put(f.value,u)}catch(p){a=p,o.abort();return}s<e.length?l.onsuccess=c:typeof o.commit=="function"&&o.commit()}c()}_clear(e,r){let n,i;try{n=Pm(e)}catch{return this.nextTick(r)}if(e.limit>=0)return km(this,this[Ct],n,e,r);try{let o=this[Dr]("readwrite");i=n?o.delete(n):o.clear()}catch(o){return this.nextTick(r,o)}this[bi](i,r)}_close(e){this[mi].close(),this.nextTick(e)}};xo.destroy=function(t,e,r){typeof e=="function"&&(r=e,e=Fl),r=Bm(r,jl);let n=indexedDB.deleteDatabase(e+t);return n.onsuccess=function(){r()},n.onerror=function(i){r(i)},r[jl]};$l.BrowserLevel=xo});var Gl=M(Hl=>{Hl.Level=Vl().BrowserLevel});var ce=M((lS,Wl)=>{"use strict";Wl.exports={ArrayIsArray(t){return Array.isArray(t)},ArrayPrototypeIncludes(t,e){return t.includes(e)},ArrayPrototypeIndexOf(t,e){return t.indexOf(e)},ArrayPrototypeJoin(t,e){return t.join(e)},ArrayPrototypeMap(t,e){return t.map(e)},ArrayPrototypePop(t,e){return t.pop(e)},ArrayPrototypePush(t,e){return t.push(e)},ArrayPrototypeSlice(t,e,r){return t.slice(e,r)},Error,FunctionPrototypeCall(t,e,...r){return t.call(e,...r)},FunctionPrototypeSymbolHasInstance(t,e){return Function.prototype[Symbol.hasInstance].call(t,e)},MathFloor:Math.floor,Number,NumberIsInteger:Number.isInteger,NumberIsNaN:Number.isNaN,NumberMAX_SAFE_INTEGER:Number.MAX_SAFE_INTEGER,NumberMIN_SAFE_INTEGER:Number.MIN_SAFE_INTEGER,NumberParseInt:Number.parseInt,ObjectDefineProperties(t,e){return Object.defineProperties(t,e)},ObjectDefineProperty(t,e,r){return Object.defineProperty(t,e,r)},ObjectGetOwnPropertyDescriptor(t,e){return Object.getOwnPropertyDescriptor(t,e)},ObjectKeys(t){return Object.keys(t)},ObjectSetPrototypeOf(t,e){return Object.setPrototypeOf(t,e)},Promise,PromisePrototypeCatch(t,e){return t.catch(e)},PromisePrototypeThen(t,e,r){return t.then(e,r)},PromiseReject(t){return Promise.reject(t)},PromiseResolve(t){return Promise.resolve(t)},ReflectApply:Reflect.apply,RegExpPrototypeTest(t,e){return t.test(e)},SafeSet:Set,String,StringPrototypeSlice(t,e,r){return t.slice(e,r)},StringPrototypeToLowerCase(t){return t.toLowerCase()},StringPrototypeToUpperCase(t){return t.toUpperCase()},StringPrototypeTrim(t){return t.trim()},Symbol,SymbolFor:Symbol.for,SymbolAsyncIterator:Symbol.asyncIterator,SymbolHasInstance:Symbol.hasInstance,SymbolIterator:Symbol.iterator,SymbolDispose:Symbol.dispose||Symbol("Symbol.dispose"),SymbolAsyncDispose:Symbol.asyncDispose||Symbol("Symbol.asyncDispose"),TypedArrayPrototypeSet(t,e,r){return t.set(e,r)},Boolean,Uint8Array}});var _n=M((dS,_o)=>{"use strict";var{AbortController:Jl,AbortSignal:Rm}=typeof self<"u"?self:typeof window<"u"?window:void 0;_o.exports=Jl;_o.exports.AbortSignal=Rm;_o.exports.default=Jl});var Se=M((hS,Ga)=>{"use strict";var Um=qe(),{kResistStopPropagation:Cm,SymbolDispose:Lm}=ce(),Om=globalThis.AbortSignal||_n().AbortSignal,Km=globalThis.AbortController||_n().AbortController,Nm=Object.getPrototypeOf(async function(){}).constructor,zl=globalThis.Blob||Um.Blob,Dm=typeof zl<"u"?function(e){return e instanceof zl}:function(e){return!1},Yl=(t,e)=>{if(t!==void 0&&(t===null||typeof t!="object"||!("aborted"in t)))throw new ERR_INVALID_ARG_TYPE(e,"AbortSignal",t)},Mm=(t,e)=>{if(typeof t!="function")throw new ERR_INVALID_ARG_TYPE(e,"Function",t)},Ha=class extends Error{constructor(e){if(!Array.isArray(e))throw new TypeError(`Expected input to be an Array, got ${typeof e}`);let r="";for(let n=0;n<e.length;n++)r+=` ${e[n].stack}
|
|
2
|
-
`;super(r),this.name="AggregateError",this.errors=e}};Ga.exports={AggregateError:Ha,kEmptyObject:Object.freeze({}),once(t){let e=!1;return function(...r){e||(e=!0,t.apply(this,r))}},createDeferredPromise:function(){let t,e;return{promise:new Promise((n,i)=>{t=n,e=i}),resolve:t,reject:e}},promisify(t){return new Promise((e,r)=>{t((n,...i)=>n?r(n):e(...i))})},debuglog(){return function(){}},format(t,...e){return t.replace(/%([sdifj])/g,function(...[r,n]){let i=e.shift();return n==="f"?i.toFixed(6):n==="j"?JSON.stringify(i):n==="s"&&typeof i=="object"?`${i.constructor!==Object?i.constructor.name:""} {}`.trim():i.toString()})},inspect(t){switch(typeof t){case"string":if(t.includes("'"))if(t.includes('"')){if(!t.includes("`")&&!t.includes("${"))return`\`${t}\``}else return`"${t}"`;return`'${t}'`;case"number":return isNaN(t)?"NaN":Object.is(t,-0)?String(t):t;case"bigint":return`${String(t)}n`;case"boolean":case"undefined":return String(t);case"object":return"{}"}},types:{isAsyncFunction(t){return t instanceof Nm},isArrayBufferView(t){return ArrayBuffer.isView(t)}},isBlob:Dm,deprecate(t,e){return t},addAbortListener:ln().addAbortListener||function(e,r){if(e===void 0)throw new ERR_INVALID_ARG_TYPE("signal","AbortSignal",e);Yl(e,"signal"),Mm(r,"listener");let n;return e.aborted?queueMicrotask(()=>r()):(e.addEventListener("abort",r,{__proto__:null,once:!0,[Cm]:!0}),n=()=>{e.removeEventListener("abort",r)}),{__proto__:null,[Lm](){var i;(i=n)===null||i===void 0||i()}}},AbortSignalAny:Om.any||function(e){if(e.length===1)return e[0];let r=new Km,n=()=>r.abort();return e.forEach(i=>{Yl(i,"signals"),i.addEventListener("abort",n,{once:!0})}),r.signal.addEventListener("abort",()=>{e.forEach(i=>i.removeEventListener("abort",n))},{once:!0}),r.signal}};Ga.exports.promisify.custom=Symbol.for("nodejs.util.promisify.custom")});var Te=M((pS,Ql)=>{"use strict";var{format:qm,inspect:Ao,AggregateError:jm}=Se(),Fm=globalThis.AggregateError||jm,$m=Symbol("kIsNodeError"),Vm=["string","function","number","object","Function","Object","boolean","bigint","symbol"],Hm=/^([A-Z][a-z0-9]*)+$/,Gm="__node_internal_",So={};function qr(t,e){if(!t)throw new So.ERR_INTERNAL_ASSERTION(e)}function Zl(t){let e="",r=t.length,n=t[0]==="-"?1:0;for(;r>=n+4;r-=3)e=`_${t.slice(r-3,r)}${e}`;return`${t.slice(0,r)}${e}`}function Wm(t,e,r){if(typeof e=="function")return qr(e.length<=r.length,`Code: ${t}; The provided arguments length (${r.length}) does not match the required ones (${e.length}).`),e(...r);let n=(e.match(/%[dfijoOs]/g)||[]).length;return qr(n===r.length,`Code: ${t}; The provided arguments length (${r.length}) does not match the required ones (${n}).`),r.length===0?e:qm(e,...r)}function xe(t,e,r){r||(r=Error);class n extends r{constructor(...o){super(Wm(t,e,o))}toString(){return`${this.name} [${t}]: ${this.message}`}}Object.defineProperties(n.prototype,{name:{value:r.name,writable:!0,enumerable:!1,configurable:!0},toString:{value(){return`${this.name} [${t}]: ${this.message}`},writable:!0,enumerable:!1,configurable:!0}}),n.prototype.code=t,n.prototype[$m]=!0,So[t]=n}function Xl(t){let e=Gm+t.name;return Object.defineProperty(t,"name",{value:e}),t}function Jm(t,e){if(t&&e&&t!==e){if(Array.isArray(e.errors))return e.errors.push(t),e;let r=new Fm([e,t],e.message);return r.code=e.code,r}return t||e}var Wa=class extends Error{constructor(e="The operation was aborted",r=void 0){if(r!==void 0&&typeof r!="object")throw new So.ERR_INVALID_ARG_TYPE("options","Object",r);super(e,r),this.code="ABORT_ERR",this.name="AbortError"}};xe("ERR_ASSERTION","%s",Error);xe("ERR_INVALID_ARG_TYPE",(t,e,r)=>{qr(typeof t=="string","'name' must be a string"),Array.isArray(e)||(e=[e]);let n="The ";t.endsWith(" argument")?n+=`${t} `:n+=`"${t}" ${t.includes(".")?"property":"argument"} `,n+="must be ";let i=[],o=[],s=[];for(let c of e)qr(typeof c=="string","All expected entries have to be of type string"),Vm.includes(c)?i.push(c.toLowerCase()):Hm.test(c)?o.push(c):(qr(c!=="object",'The value "object" should be written as "Object"'),s.push(c));if(o.length>0){let c=i.indexOf("object");c!==-1&&(i.splice(i,c,1),o.push("Object"))}if(i.length>0){switch(i.length){case 1:n+=`of type ${i[0]}`;break;case 2:n+=`one of type ${i[0]} or ${i[1]}`;break;default:{let c=i.pop();n+=`one of type ${i.join(", ")}, or ${c}`}}(o.length>0||s.length>0)&&(n+=" or ")}if(o.length>0){switch(o.length){case 1:n+=`an instance of ${o[0]}`;break;case 2:n+=`an instance of ${o[0]} or ${o[1]}`;break;default:{let c=o.pop();n+=`an instance of ${o.join(", ")}, or ${c}`}}s.length>0&&(n+=" or ")}switch(s.length){case 0:break;case 1:s[0].toLowerCase()!==s[0]&&(n+="an "),n+=`${s[0]}`;break;case 2:n+=`one of ${s[0]} or ${s[1]}`;break;default:{let c=s.pop();n+=`one of ${s.join(", ")}, or ${c}`}}if(r==null)n+=`. Received ${r}`;else if(typeof r=="function"&&r.name)n+=`. Received function ${r.name}`;else if(typeof r=="object"){var a;if((a=r.constructor)!==null&&a!==void 0&&a.name)n+=`. Received an instance of ${r.constructor.name}`;else{let c=Ao(r,{depth:-1});n+=`. Received ${c}`}}else{let c=Ao(r,{colors:!1});c.length>25&&(c=`${c.slice(0,25)}...`),n+=`. Received type ${typeof r} (${c})`}return n},TypeError);xe("ERR_INVALID_ARG_VALUE",(t,e,r="is invalid")=>{let n=Ao(e);return n.length>128&&(n=n.slice(0,128)+"..."),`The ${t.includes(".")?"property":"argument"} '${t}' ${r}. Received ${n}`},TypeError);xe("ERR_INVALID_RETURN_VALUE",(t,e,r)=>{var n;let i=r!=null&&(n=r.constructor)!==null&&n!==void 0&&n.name?`instance of ${r.constructor.name}`:`type ${typeof r}`;return`Expected ${t} to be returned from the "${e}" function but got ${i}.`},TypeError);xe("ERR_MISSING_ARGS",(...t)=>{qr(t.length>0,"At least one arg needs to be specified");let e,r=t.length;switch(t=(Array.isArray(t)?t:[t]).map(n=>`"${n}"`).join(" or "),r){case 1:e+=`The ${t[0]} argument`;break;case 2:e+=`The ${t[0]} and ${t[1]} arguments`;break;default:{let n=t.pop();e+=`The ${t.join(", ")}, and ${n} arguments`}break}return`${e} must be specified`},TypeError);xe("ERR_OUT_OF_RANGE",(t,e,r)=>{qr(e,'Missing "range" argument');let n;return Number.isInteger(r)&&Math.abs(r)>2**32?n=Zl(String(r)):typeof r=="bigint"?(n=String(r),(r>2n**32n||r<-(2n**32n))&&(n=Zl(n)),n+="n"):n=Ao(r),`The value of "${t}" is out of range. It must be ${e}. Received ${n}`},RangeError);xe("ERR_MULTIPLE_CALLBACK","Callback called multiple times",Error);xe("ERR_METHOD_NOT_IMPLEMENTED","The %s method is not implemented",Error);xe("ERR_STREAM_ALREADY_FINISHED","Cannot call %s after a stream was finished",Error);xe("ERR_STREAM_CANNOT_PIPE","Cannot pipe, not readable",Error);xe("ERR_STREAM_DESTROYED","Cannot call %s after a stream was destroyed",Error);xe("ERR_STREAM_NULL_VALUES","May not write null values to stream",TypeError);xe("ERR_STREAM_PREMATURE_CLOSE","Premature close",Error);xe("ERR_STREAM_PUSH_AFTER_EOF","stream.push() after EOF",Error);xe("ERR_STREAM_UNSHIFT_AFTER_END_EVENT","stream.unshift() after end event",Error);xe("ERR_STREAM_WRITE_AFTER_END","write after end",Error);xe("ERR_UNKNOWN_ENCODING","Unknown encoding: %s",TypeError);Ql.exports={AbortError:Wa,aggregateTwoErrors:Xl(Jm),hideStackFrames:Xl,codes:So}});var Sn=M((yS,fd)=>{"use strict";var{ArrayIsArray:za,ArrayPrototypeIncludes:nd,ArrayPrototypeJoin:id,ArrayPrototypeMap:zm,NumberIsInteger:Ya,NumberIsNaN:Ym,NumberMAX_SAFE_INTEGER:Zm,NumberMIN_SAFE_INTEGER:Xm,NumberParseInt:Qm,ObjectPrototypeHasOwnProperty:eb,RegExpPrototypeExec:od,String:tb,StringPrototypeToUpperCase:rb,StringPrototypeTrim:nb}=ce(),{hideStackFrames:$e,codes:{ERR_SOCKET_BAD_PORT:ib,ERR_INVALID_ARG_TYPE:ve,ERR_INVALID_ARG_VALUE:An,ERR_OUT_OF_RANGE:jr,ERR_UNKNOWN_SIGNAL:ed}}=Te(),{normalizeEncoding:ob}=Se(),{isAsyncFunction:sb,isArrayBufferView:ab}=Se().types,td={};function cb(t){return t===(t|0)}function fb(t){return t===t>>>0}var ub=/^[0-7]+$/,lb="must be a 32-bit unsigned integer or an octal string";function db(t,e,r){if(typeof t>"u"&&(t=r),typeof t=="string"){if(od(ub,t)===null)throw new An(e,t,lb);t=Qm(t,8)}return sd(t,e),t}var hb=$e((t,e,r=Xm,n=Zm)=>{if(typeof t!="number")throw new ve(e,"number",t);if(!Ya(t))throw new jr(e,"an integer",t);if(t<r||t>n)throw new jr(e,`>= ${r} && <= ${n}`,t)}),pb=$e((t,e,r=-2147483648,n=2147483647)=>{if(typeof t!="number")throw new ve(e,"number",t);if(!Ya(t))throw new jr(e,"an integer",t);if(t<r||t>n)throw new jr(e,`>= ${r} && <= ${n}`,t)}),sd=$e((t,e,r=!1)=>{if(typeof t!="number")throw new ve(e,"number",t);if(!Ya(t))throw new jr(e,"an integer",t);let n=r?1:0,i=4294967295;if(t<n||t>i)throw new jr(e,`>= ${n} && <= ${i}`,t)});function Za(t,e){if(typeof t!="string")throw new ve(e,"string",t)}function yb(t,e,r=void 0,n){if(typeof t!="number")throw new ve(e,"number",t);if(r!=null&&t<r||n!=null&&t>n||(r!=null||n!=null)&&Ym(t))throw new jr(e,`${r!=null?`>= ${r}`:""}${r!=null&&n!=null?" && ":""}${n!=null?`<= ${n}`:""}`,t)}var wb=$e((t,e,r)=>{if(!nd(r,t)){let i="must be one of: "+id(zm(r,o=>typeof o=="string"?`'${o}'`:tb(o)),", ");throw new An(e,t,i)}});function ad(t,e){if(typeof t!="boolean")throw new ve(e,"boolean",t)}function Ja(t,e,r){return t==null||!eb(t,e)?r:t[e]}var mb=$e((t,e,r=null)=>{let n=Ja(r,"allowArray",!1),i=Ja(r,"allowFunction",!1);if(!Ja(r,"nullable",!1)&&t===null||!n&&za(t)||typeof t!="object"&&(!i||typeof t!="function"))throw new ve(e,"Object",t)}),bb=$e((t,e)=>{if(t!=null&&typeof t!="object"&&typeof t!="function")throw new ve(e,"a dictionary",t)}),vo=$e((t,e,r=0)=>{if(!za(t))throw new ve(e,"Array",t);if(t.length<r){let n=`must be longer than ${r}`;throw new An(e,t,n)}});function gb(t,e){vo(t,e);for(let r=0;r<t.length;r++)Za(t[r],`${e}[${r}]`)}function xb(t,e){vo(t,e);for(let r=0;r<t.length;r++)ad(t[r],`${e}[${r}]`)}function Eb(t,e){vo(t,e);for(let r=0;r<t.length;r++){let n=t[r],i=`${e}[${r}]`;if(n==null)throw new ve(i,"AbortSignal",n);cd(n,i)}}function _b(t,e="signal"){if(Za(t,e),td[t]===void 0)throw td[rb(t)]!==void 0?new ed(t+" (signals must use all capital letters)"):new ed(t)}var Ab=$e((t,e="buffer")=>{if(!ab(t))throw new ve(e,["Buffer","TypedArray","DataView"],t)});function Sb(t,e){let r=ob(e),n=t.length;if(r==="hex"&&n%2!==0)throw new An("encoding",e,`is invalid for data of length ${n}`)}function vb(t,e="Port",r=!0){if(typeof t!="number"&&typeof t!="string"||typeof t=="string"&&nb(t).length===0||+t!==+t>>>0||t>65535||t===0&&!r)throw new ib(e,t,r);return t|0}var cd=$e((t,e)=>{if(t!==void 0&&(t===null||typeof t!="object"||!("aborted"in t)))throw new ve(e,"AbortSignal",t)}),Bb=$e((t,e)=>{if(typeof t!="function")throw new ve(e,"Function",t)}),Tb=$e((t,e)=>{if(typeof t!="function"||sb(t))throw new ve(e,"Function",t)}),kb=$e((t,e)=>{if(t!==void 0)throw new ve(e,"undefined",t)});function Pb(t,e,r){if(!nd(r,t))throw new ve(e,`('${id(r,"|")}')`,t)}var Ib=/^(?:<[^>]*>)(?:\s*;\s*[^;"\s]+(?:=(")?[^;"\s]*\1)?)*$/;function rd(t,e){if(typeof t>"u"||!od(Ib,t))throw new An(e,t,'must be an array or string of format "</styles.css>; rel=preload; as=style"')}function Rb(t){if(typeof t=="string")return rd(t,"hints"),t;if(za(t)){let e=t.length,r="";if(e===0)return r;for(let n=0;n<e;n++){let i=t[n];rd(i,"hints"),r+=i,n!==e-1&&(r+=", ")}return r}throw new An("hints",t,'must be an array or string of format "</styles.css>; rel=preload; as=style"')}fd.exports={isInt32:cb,isUint32:fb,parseFileMode:db,validateArray:vo,validateStringArray:gb,validateBooleanArray:xb,validateAbortSignalArray:Eb,validateBoolean:ad,validateBuffer:Ab,validateDictionary:bb,validateEncoding:Sb,validateFunction:Bb,validateInt32:pb,validateInteger:hb,validateNumber:yb,validateObject:mb,validateOneOf:wb,validatePlainFunction:Tb,validatePort:vb,validateSignalName:_b,validateString:Za,validateUint32:sd,validateUndefined:kb,validateUnion:Pb,validateAbortSignal:cd,validateLinkHeaderValue:Rb}});var ir=M((wS,hd)=>{var ue=hd.exports={},dt,ht;function Xa(){throw new Error("setTimeout has not been defined")}function Qa(){throw new Error("clearTimeout has not been defined")}(function(){try{typeof setTimeout=="function"?dt=setTimeout:dt=Xa}catch{dt=Xa}try{typeof clearTimeout=="function"?ht=clearTimeout:ht=Qa}catch{ht=Qa}})();function ud(t){if(dt===setTimeout)return setTimeout(t,0);if((dt===Xa||!dt)&&setTimeout)return dt=setTimeout,setTimeout(t,0);try{return dt(t,0)}catch{try{return dt.call(null,t,0)}catch{return dt.call(this,t,0)}}}function Ub(t){if(ht===clearTimeout)return clearTimeout(t);if((ht===Qa||!ht)&&clearTimeout)return ht=clearTimeout,clearTimeout(t);try{return ht(t)}catch{try{return ht.call(null,t)}catch{return ht.call(this,t)}}}var Lt=[],vn=!1,Fr,Bo=-1;function Cb(){!vn||!Fr||(vn=!1,Fr.length?Lt=Fr.concat(Lt):Bo=-1,Lt.length&&ld())}function ld(){if(!vn){var t=ud(Cb);vn=!0;for(var e=Lt.length;e;){for(Fr=Lt,Lt=[];++Bo<e;)Fr&&Fr[Bo].run();Bo=-1,e=Lt.length}Fr=null,vn=!1,Ub(t)}}ue.nextTick=function(t){var e=new Array(arguments.length-1);if(arguments.length>1)for(var r=1;r<arguments.length;r++)e[r-1]=arguments[r];Lt.push(new dd(t,e)),Lt.length===1&&!vn&&ud(ld)};function dd(t,e){this.fun=t,this.array=e}dd.prototype.run=function(){this.fun.apply(null,this.array)};ue.title="browser";ue.browser=!0;ue.env={};ue.argv=[];ue.version="";ue.versions={};function Ot(){}ue.on=Ot;ue.addListener=Ot;ue.once=Ot;ue.off=Ot;ue.removeListener=Ot;ue.removeAllListeners=Ot;ue.emit=Ot;ue.prependListener=Ot;ue.prependOnceListener=Ot;ue.listeners=function(t){return[]};ue.binding=function(t){throw new Error("process.binding is not supported")};ue.cwd=function(){return"/"};ue.chdir=function(t){throw new Error("process.chdir is not supported")};ue.umask=function(){return 0}});var yt=M((mS,kd)=>{"use strict";var{SymbolAsyncIterator:pd,SymbolIterator:yd,SymbolFor:$r}=ce(),wd=$r("nodejs.stream.destroyed"),md=$r("nodejs.stream.errored"),ec=$r("nodejs.stream.readable"),tc=$r("nodejs.stream.writable"),bd=$r("nodejs.stream.disturbed"),Lb=$r("nodejs.webstream.isClosedPromise"),Ob=$r("nodejs.webstream.controllerErrorFunction");function To(t,e=!1){var r;return!!(t&&typeof t.pipe=="function"&&typeof t.on=="function"&&(!e||typeof t.pause=="function"&&typeof t.resume=="function")&&(!t._writableState||((r=t._readableState)===null||r===void 0?void 0:r.readable)!==!1)&&(!t._writableState||t._readableState))}function ko(t){var e;return!!(t&&typeof t.write=="function"&&typeof t.on=="function"&&(!t._readableState||((e=t._writableState)===null||e===void 0?void 0:e.writable)!==!1))}function Kb(t){return!!(t&&typeof t.pipe=="function"&&t._readableState&&typeof t.on=="function"&&typeof t.write=="function")}function pt(t){return t&&(t._readableState||t._writableState||typeof t.write=="function"&&typeof t.on=="function"||typeof t.pipe=="function"&&typeof t.on=="function")}function gd(t){return!!(t&&!pt(t)&&typeof t.pipeThrough=="function"&&typeof t.getReader=="function"&&typeof t.cancel=="function")}function xd(t){return!!(t&&!pt(t)&&typeof t.getWriter=="function"&&typeof t.abort=="function")}function Ed(t){return!!(t&&!pt(t)&&typeof t.readable=="object"&&typeof t.writable=="object")}function Nb(t){return gd(t)||xd(t)||Ed(t)}function Db(t,e){return t==null?!1:e===!0?typeof t[pd]=="function":e===!1?typeof t[yd]=="function":typeof t[pd]=="function"||typeof t[yd]=="function"}function Po(t){if(!pt(t))return null;let e=t._writableState,r=t._readableState,n=e||r;return!!(t.destroyed||t[wd]||n!=null&&n.destroyed)}function _d(t){if(!ko(t))return null;if(t.writableEnded===!0)return!0;let e=t._writableState;return e!=null&&e.errored?!1:typeof e?.ended!="boolean"?null:e.ended}function Mb(t,e){if(!ko(t))return null;if(t.writableFinished===!0)return!0;let r=t._writableState;return r!=null&&r.errored?!1:typeof r?.finished!="boolean"?null:!!(r.finished||e===!1&&r.ended===!0&&r.length===0)}function qb(t){if(!To(t))return null;if(t.readableEnded===!0)return!0;let e=t._readableState;return!e||e.errored?!1:typeof e?.ended!="boolean"?null:e.ended}function Ad(t,e){if(!To(t))return null;let r=t._readableState;return r!=null&&r.errored?!1:typeof r?.endEmitted!="boolean"?null:!!(r.endEmitted||e===!1&&r.ended===!0&&r.length===0)}function Sd(t){return t&&t[ec]!=null?t[ec]:typeof t?.readable!="boolean"?null:Po(t)?!1:To(t)&&t.readable&&!Ad(t)}function vd(t){return t&&t[tc]!=null?t[tc]:typeof t?.writable!="boolean"?null:Po(t)?!1:ko(t)&&t.writable&&!_d(t)}function jb(t,e){return pt(t)?Po(t)?!0:!(e?.readable!==!1&&Sd(t)||e?.writable!==!1&&vd(t)):null}function Fb(t){var e,r;return pt(t)?t.writableErrored?t.writableErrored:(e=(r=t._writableState)===null||r===void 0?void 0:r.errored)!==null&&e!==void 0?e:null:null}function $b(t){var e,r;return pt(t)?t.readableErrored?t.readableErrored:(e=(r=t._readableState)===null||r===void 0?void 0:r.errored)!==null&&e!==void 0?e:null:null}function Vb(t){if(!pt(t))return null;if(typeof t.closed=="boolean")return t.closed;let e=t._writableState,r=t._readableState;return typeof e?.closed=="boolean"||typeof r?.closed=="boolean"?e?.closed||r?.closed:typeof t._closed=="boolean"&&Bd(t)?t._closed:null}function Bd(t){return typeof t._closed=="boolean"&&typeof t._defaultKeepAlive=="boolean"&&typeof t._removedConnection=="boolean"&&typeof t._removedContLen=="boolean"}function Td(t){return typeof t._sent100=="boolean"&&Bd(t)}function Hb(t){var e;return typeof t._consuming=="boolean"&&typeof t._dumped=="boolean"&&((e=t.req)===null||e===void 0?void 0:e.upgradeOrConnect)===void 0}function Gb(t){if(!pt(t))return null;let e=t._writableState,r=t._readableState,n=e||r;return!n&&Td(t)||!!(n&&n.autoDestroy&&n.emitClose&&n.closed===!1)}function Wb(t){var e;return!!(t&&((e=t[bd])!==null&&e!==void 0?e:t.readableDidRead||t.readableAborted))}function Jb(t){var e,r,n,i,o,s,a,c,f,u;return!!(t&&((e=(r=(n=(i=(o=(s=t[md])!==null&&s!==void 0?s:t.readableErrored)!==null&&o!==void 0?o:t.writableErrored)!==null&&i!==void 0?i:(a=t._readableState)===null||a===void 0?void 0:a.errorEmitted)!==null&&n!==void 0?n:(c=t._writableState)===null||c===void 0?void 0:c.errorEmitted)!==null&&r!==void 0?r:(f=t._readableState)===null||f===void 0?void 0:f.errored)!==null&&e!==void 0?e:!((u=t._writableState)===null||u===void 0)&&u.errored))}kd.exports={isDestroyed:Po,kIsDestroyed:wd,isDisturbed:Wb,kIsDisturbed:bd,isErrored:Jb,kIsErrored:md,isReadable:Sd,kIsReadable:ec,kIsClosedPromise:Lb,kControllerErrorFunction:Ob,kIsWritable:tc,isClosed:Vb,isDuplexNodeStream:Kb,isFinished:jb,isIterable:Db,isReadableNodeStream:To,isReadableStream:gd,isReadableEnded:qb,isReadableFinished:Ad,isReadableErrored:$b,isNodeStream:pt,isWebStream:Nb,isWritable:vd,isWritableNodeStream:ko,isWritableStream:xd,isWritableEnded:_d,isWritableFinished:Mb,isWritableErrored:Fb,isServerRequest:Hb,isServerResponse:Td,willEmitClose:Gb,isTransformStream:Ed}});var Kt=M((bS,sc)=>{var or=ir(),{AbortError:Nd,codes:zb}=Te(),{ERR_INVALID_ARG_TYPE:Yb,ERR_STREAM_PREMATURE_CLOSE:Pd}=zb,{kEmptyObject:nc,once:ic}=Se(),{validateAbortSignal:Zb,validateFunction:Xb,validateObject:Qb,validateBoolean:eg}=Sn(),{Promise:tg,PromisePrototypeThen:rg,SymbolDispose:Dd}=ce(),{isClosed:ng,isReadable:Id,isReadableNodeStream:rc,isReadableStream:ig,isReadableFinished:Rd,isReadableErrored:Ud,isWritable:Cd,isWritableNodeStream:Ld,isWritableStream:og,isWritableFinished:Od,isWritableErrored:Kd,isNodeStream:sg,willEmitClose:ag,kIsClosedPromise:cg}=yt(),Bn;function fg(t){return t.setHeader&&typeof t.abort=="function"}var oc=()=>{};function Md(t,e,r){var n,i;if(arguments.length===2?(r=e,e=nc):e==null?e=nc:Qb(e,"options"),Xb(r,"callback"),Zb(e.signal,"options.signal"),r=ic(r),ig(t)||og(t))return ug(t,e,r);if(!sg(t))throw new Yb("stream",["ReadableStream","WritableStream","Stream"],t);let o=(n=e.readable)!==null&&n!==void 0?n:rc(t),s=(i=e.writable)!==null&&i!==void 0?i:Ld(t),a=t._writableState,c=t._readableState,f=()=>{t.writable||p()},u=ag(t)&&rc(t)===o&&Ld(t)===s,l=Od(t,!1),p=()=>{l=!0,t.destroyed&&(u=!1),!(u&&(!t.readable||o))&&(!o||h)&&r.call(t)},h=Rd(t,!1),y=()=>{h=!0,t.destroyed&&(u=!1),!(u&&(!t.writable||s))&&(!s||l)&&r.call(t)},d=E=>{r.call(t,E)},w=ng(t),m=()=>{w=!0;let E=Kd(t)||Ud(t);if(E&&typeof E!="boolean")return r.call(t,E);if(o&&!h&&rc(t,!0)&&!Rd(t,!1))return r.call(t,new Pd);if(s&&!l&&!Od(t,!1))return r.call(t,new Pd);r.call(t)},A=()=>{w=!0;let E=Kd(t)||Ud(t);if(E&&typeof E!="boolean")return r.call(t,E);r.call(t)},g=()=>{t.req.on("finish",p)};fg(t)?(t.on("complete",p),u||t.on("abort",m),t.req?g():t.on("request",g)):s&&!a&&(t.on("end",f),t.on("close",f)),!u&&typeof t.aborted=="boolean"&&t.on("aborted",m),t.on("end",y),t.on("finish",p),e.error!==!1&&t.on("error",d),t.on("close",m),w?or.nextTick(m):a!=null&&a.errorEmitted||c!=null&&c.errorEmitted?u||or.nextTick(A):(!o&&(!u||Id(t))&&(l||Cd(t)===!1)||!s&&(!u||Cd(t))&&(h||Id(t)===!1)||c&&t.req&&t.aborted)&&or.nextTick(A);let _=()=>{r=oc,t.removeListener("aborted",m),t.removeListener("complete",p),t.removeListener("abort",m),t.removeListener("request",g),t.req&&t.req.removeListener("finish",p),t.removeListener("end",f),t.removeListener("close",f),t.removeListener("finish",p),t.removeListener("end",y),t.removeListener("error",d),t.removeListener("close",m)};if(e.signal&&!w){let E=()=>{let B=r;_(),B.call(t,new Nd(void 0,{cause:e.signal.reason}))};if(e.signal.aborted)or.nextTick(E);else{Bn=Bn||Se().addAbortListener;let B=Bn(e.signal,E),T=r;r=ic((...k)=>{B[Dd](),T.apply(t,k)})}}return _}function ug(t,e,r){let n=!1,i=oc;if(e.signal)if(i=()=>{n=!0,r.call(t,new Nd(void 0,{cause:e.signal.reason}))},e.signal.aborted)or.nextTick(i);else{Bn=Bn||Se().addAbortListener;let s=Bn(e.signal,i),a=r;r=ic((...c)=>{s[Dd](),a.apply(t,c)})}let o=(...s)=>{n||or.nextTick(()=>r.apply(t,s))};return rg(t[cg].promise,o,o),oc}function lg(t,e){var r;let n=!1;return e===null&&(e=nc),(r=e)!==null&&r!==void 0&&r.cleanup&&(eg(e.cleanup,"cleanup"),n=e.cleanup),new tg((i,o)=>{let s=Md(t,e,a=>{n&&s(),a?o(a):i()})})}sc.exports=Md;sc.exports.finished=lg});var Vr=M((gS,Wd)=>{"use strict";var wt=ir(),{aggregateTwoErrors:dg,codes:{ERR_MULTIPLE_CALLBACK:hg},AbortError:pg}=Te(),{Symbol:Fd}=ce(),{kIsDestroyed:yg,isDestroyed:wg,isFinished:mg,isServerRequest:bg}=yt(),$d=Fd("kDestroy"),ac=Fd("kConstruct");function Vd(t,e,r){t&&(t.stack,e&&!e.errored&&(e.errored=t),r&&!r.errored&&(r.errored=t))}function gg(t,e){let r=this._readableState,n=this._writableState,i=n||r;return n!=null&&n.destroyed||r!=null&&r.destroyed?(typeof e=="function"&&e(),this):(Vd(t,n,r),n&&(n.destroyed=!0),r&&(r.destroyed=!0),i.constructed?qd(this,t,e):this.once($d,function(o){qd(this,dg(o,t),e)}),this)}function qd(t,e,r){let n=!1;function i(o){if(n)return;n=!0;let s=t._readableState,a=t._writableState;Vd(o,a,s),a&&(a.closed=!0),s&&(s.closed=!0),typeof r=="function"&&r(o),o?wt.nextTick(xg,t,o):wt.nextTick(Hd,t)}try{t._destroy(e||null,i)}catch(o){i(o)}}function xg(t,e){cc(t,e),Hd(t)}function Hd(t){let e=t._readableState,r=t._writableState;r&&(r.closeEmitted=!0),e&&(e.closeEmitted=!0),(r!=null&&r.emitClose||e!=null&&e.emitClose)&&t.emit("close")}function cc(t,e){let r=t._readableState,n=t._writableState;n!=null&&n.errorEmitted||r!=null&&r.errorEmitted||(n&&(n.errorEmitted=!0),r&&(r.errorEmitted=!0),t.emit("error",e))}function Eg(){let t=this._readableState,e=this._writableState;t&&(t.constructed=!0,t.closed=!1,t.closeEmitted=!1,t.destroyed=!1,t.errored=null,t.errorEmitted=!1,t.reading=!1,t.ended=t.readable===!1,t.endEmitted=t.readable===!1),e&&(e.constructed=!0,e.destroyed=!1,e.closed=!1,e.closeEmitted=!1,e.errored=null,e.errorEmitted=!1,e.finalCalled=!1,e.prefinished=!1,e.ended=e.writable===!1,e.ending=e.writable===!1,e.finished=e.writable===!1)}function fc(t,e,r){let n=t._readableState,i=t._writableState;if(i!=null&&i.destroyed||n!=null&&n.destroyed)return this;n!=null&&n.autoDestroy||i!=null&&i.autoDestroy?t.destroy(e):e&&(e.stack,i&&!i.errored&&(i.errored=e),n&&!n.errored&&(n.errored=e),r?wt.nextTick(cc,t,e):cc(t,e))}function _g(t,e){if(typeof t._construct!="function")return;let r=t._readableState,n=t._writableState;r&&(r.constructed=!1),n&&(n.constructed=!1),t.once(ac,e),!(t.listenerCount(ac)>1)&&wt.nextTick(Ag,t)}function Ag(t){let e=!1;function r(n){if(e){fc(t,n??new hg);return}e=!0;let i=t._readableState,o=t._writableState,s=o||i;i&&(i.constructed=!0),o&&(o.constructed=!0),s.destroyed?t.emit($d,n):n?fc(t,n,!0):wt.nextTick(Sg,t)}try{t._construct(n=>{wt.nextTick(r,n)})}catch(n){wt.nextTick(r,n)}}function Sg(t){t.emit(ac)}function jd(t){return t?.setHeader&&typeof t.abort=="function"}function Gd(t){t.emit("close")}function vg(t,e){t.emit("error",e),wt.nextTick(Gd,t)}function Bg(t,e){!t||wg(t)||(!e&&!mg(t)&&(e=new pg),bg(t)?(t.socket=null,t.destroy(e)):jd(t)?t.abort():jd(t.req)?t.req.abort():typeof t.destroy=="function"?t.destroy(e):typeof t.close=="function"?t.close():e?wt.nextTick(vg,t,e):wt.nextTick(Gd,t),t.destroyed||(t[yg]=!0))}Wd.exports={construct:_g,destroyer:Bg,destroy:gg,undestroy:Eg,errorOrDestroy:fc}});var Uo=M((xS,zd)=>{"use strict";var{ArrayIsArray:Tg,ObjectSetPrototypeOf:Jd}=ce(),{EventEmitter:Io}=ln();function Ro(t){Io.call(this,t)}Jd(Ro.prototype,Io.prototype);Jd(Ro,Io);Ro.prototype.pipe=function(t,e){let r=this;function n(u){t.writable&&t.write(u)===!1&&r.pause&&r.pause()}r.on("data",n);function i(){r.readable&&r.resume&&r.resume()}t.on("drain",i),!t._isStdio&&(!e||e.end!==!1)&&(r.on("end",s),r.on("close",a));let o=!1;function s(){o||(o=!0,t.end())}function a(){o||(o=!0,typeof t.destroy=="function"&&t.destroy())}function c(u){f(),Io.listenerCount(this,"error")===0&&this.emit("error",u)}uc(r,"error",c),uc(t,"error",c);function f(){r.removeListener("data",n),t.removeListener("drain",i),r.removeListener("end",s),r.removeListener("close",a),r.removeListener("error",c),t.removeListener("error",c),r.removeListener("end",f),r.removeListener("close",f),t.removeListener("close",f)}return r.on("end",f),r.on("close",f),t.on("close",f),t.emit("pipe",r),t};function uc(t,e,r){if(typeof t.prependListener=="function")return t.prependListener(e,r);!t._events||!t._events[e]?t.on(e,r):Tg(t._events[e])?t._events[e].unshift(r):t._events[e]=[r,t._events[e]]}zd.exports={Stream:Ro,prependListener:uc}});var gi=M((ES,Co)=>{"use strict";var{SymbolDispose:kg}=ce(),{AbortError:Yd,codes:Pg}=Te(),{isNodeStream:Zd,isWebStream:Ig,kControllerErrorFunction:Rg}=yt(),Ug=Kt(),{ERR_INVALID_ARG_TYPE:Xd}=Pg,lc,Cg=(t,e)=>{if(typeof t!="object"||!("aborted"in t))throw new Xd(e,"AbortSignal",t)};Co.exports.addAbortSignal=function(e,r){if(Cg(e,"signal"),!Zd(r)&&!Ig(r))throw new Xd("stream",["ReadableStream","WritableStream","Stream"],r);return Co.exports.addAbortSignalNoValidate(e,r)};Co.exports.addAbortSignalNoValidate=function(t,e){if(typeof t!="object"||!("aborted"in t))return e;let r=Zd(e)?()=>{e.destroy(new Yd(void 0,{cause:t.reason}))}:()=>{e[Rg](new Yd(void 0,{cause:t.reason}))};if(t.aborted)r();else{lc=lc||Se().addAbortListener;let n=lc(t,r);Ug(e,n[kg])}return e}});var th=M((AS,eh)=>{"use strict";var{StringPrototypeSlice:Qd,SymbolIterator:Lg,TypedArrayPrototypeSet:Lo,Uint8Array:Og}=ce(),{Buffer:dc}=qe(),{inspect:Kg}=Se();eh.exports=class{constructor(){this.head=null,this.tail=null,this.length=0}push(e){let r={data:e,next:null};this.length>0?this.tail.next=r:this.head=r,this.tail=r,++this.length}unshift(e){let r={data:e,next:this.head};this.length===0&&(this.tail=r),this.head=r,++this.length}shift(){if(this.length===0)return;let e=this.head.data;return this.length===1?this.head=this.tail=null:this.head=this.head.next,--this.length,e}clear(){this.head=this.tail=null,this.length=0}join(e){if(this.length===0)return"";let r=this.head,n=""+r.data;for(;(r=r.next)!==null;)n+=e+r.data;return n}concat(e){if(this.length===0)return dc.alloc(0);let r=dc.allocUnsafe(e>>>0),n=this.head,i=0;for(;n;)Lo(r,n.data,i),i+=n.data.length,n=n.next;return r}consume(e,r){let n=this.head.data;if(e<n.length){let i=n.slice(0,e);return this.head.data=n.slice(e),i}return e===n.length?this.shift():r?this._getString(e):this._getBuffer(e)}first(){return this.head.data}*[Lg](){for(let e=this.head;e;e=e.next)yield e.data}_getString(e){let r="",n=this.head,i=0;do{let o=n.data;if(e>o.length)r+=o,e-=o.length;else{e===o.length?(r+=o,++i,n.next?this.head=n.next:this.head=this.tail=null):(r+=Qd(o,0,e),this.head=n,n.data=Qd(o,e));break}++i}while((n=n.next)!==null);return this.length-=i,r}_getBuffer(e){let r=dc.allocUnsafe(e),n=e,i=this.head,o=0;do{let s=i.data;if(e>s.length)Lo(r,s,n-e),e-=s.length;else{e===s.length?(Lo(r,s,n-e),++o,i.next?this.head=i.next:this.head=this.tail=null):(Lo(r,new Og(s.buffer,s.byteOffset,e),n-e),this.head=i,i.data=s.slice(e));break}++o}while((i=i.next)!==null);return this.length-=o,r}[Symbol.for("nodejs.util.inspect.custom")](e,r){return Kg(this,{...r,depth:0,customInspect:!1})}}});var xi=M((SS,oh)=>{"use strict";var{MathFloor:Ng,NumberIsInteger:Dg}=ce(),{validateInteger:Mg}=Sn(),{ERR_INVALID_ARG_VALUE:qg}=Te().codes,rh=16*1024,nh=16;function jg(t,e,r){return t.highWaterMark!=null?t.highWaterMark:e?t[r]:null}function ih(t){return t?nh:rh}function Fg(t,e){Mg(e,"value",0),t?nh=e:rh=e}function $g(t,e,r,n){let i=jg(e,n,r);if(i!=null){if(!Dg(i)||i<0){let o=n?`options.${r}`:"options.highWaterMark";throw new qg(o,i)}return Ng(i)}return ih(t.objectMode)}oh.exports={getHighWaterMark:$g,getDefaultHighWaterMark:ih,setDefaultHighWaterMark:Fg}});var ch=M((hc,ah)=>{var Oo=qe(),mt=Oo.Buffer;function sh(t,e){for(var r in t)e[r]=t[r]}mt.from&&mt.alloc&&mt.allocUnsafe&&mt.allocUnsafeSlow?ah.exports=Oo:(sh(Oo,hc),hc.Buffer=Hr);function Hr(t,e,r){return mt(t,e,r)}Hr.prototype=Object.create(mt.prototype);sh(mt,Hr);Hr.from=function(t,e,r){if(typeof t=="number")throw new TypeError("Argument must not be a number");return mt(t,e,r)};Hr.alloc=function(t,e,r){if(typeof t!="number")throw new TypeError("Argument must be a number");var n=mt(t);return e!==void 0?typeof r=="string"?n.fill(e,r):n.fill(e):n.fill(0),n};Hr.allocUnsafe=function(t){if(typeof t!="number")throw new TypeError("Argument must be a number");return mt(t)};Hr.allocUnsafeSlow=function(t){if(typeof t!="number")throw new TypeError("Argument must be a number");return Oo.SlowBuffer(t)}});var lh=M(uh=>{"use strict";var yc=ch().Buffer,fh=yc.isEncoding||function(t){switch(t=""+t,t&&t.toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":case"raw":return!0;default:return!1}};function Vg(t){if(!t)return"utf8";for(var e;;)switch(t){case"utf8":case"utf-8":return"utf8";case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return"utf16le";case"latin1":case"binary":return"latin1";case"base64":case"ascii":case"hex":return t;default:if(e)return;t=(""+t).toLowerCase(),e=!0}}function Hg(t){var e=Vg(t);if(typeof e!="string"&&(yc.isEncoding===fh||!fh(t)))throw new Error("Unknown encoding: "+t);return e||t}uh.StringDecoder=Ei;function Ei(t){this.encoding=Hg(t);var e;switch(this.encoding){case"utf16le":this.text=Zg,this.end=Xg,e=4;break;case"utf8":this.fillLast=Jg,e=4;break;case"base64":this.text=Qg,this.end=ex,e=3;break;default:this.write=tx,this.end=rx;return}this.lastNeed=0,this.lastTotal=0,this.lastChar=yc.allocUnsafe(e)}Ei.prototype.write=function(t){if(t.length===0)return"";var e,r;if(this.lastNeed){if(e=this.fillLast(t),e===void 0)return"";r=this.lastNeed,this.lastNeed=0}else r=0;return r<t.length?e?e+this.text(t,r):this.text(t,r):e||""};Ei.prototype.end=Yg;Ei.prototype.text=zg;Ei.prototype.fillLast=function(t){if(this.lastNeed<=t.length)return t.copy(this.lastChar,this.lastTotal-this.lastNeed,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal);t.copy(this.lastChar,this.lastTotal-this.lastNeed,0,t.length),this.lastNeed-=t.length};function pc(t){return t<=127?0:t>>5===6?2:t>>4===14?3:t>>3===30?4:t>>6===2?-1:-2}function Gg(t,e,r){var n=e.length-1;if(n<r)return 0;var i=pc(e[n]);return i>=0?(i>0&&(t.lastNeed=i-1),i):--n<r||i===-2?0:(i=pc(e[n]),i>=0?(i>0&&(t.lastNeed=i-2),i):--n<r||i===-2?0:(i=pc(e[n]),i>=0?(i>0&&(i===2?i=0:t.lastNeed=i-3),i):0))}function Wg(t,e,r){if((e[0]&192)!==128)return t.lastNeed=0,"\uFFFD";if(t.lastNeed>1&&e.length>1){if((e[1]&192)!==128)return t.lastNeed=1,"\uFFFD";if(t.lastNeed>2&&e.length>2&&(e[2]&192)!==128)return t.lastNeed=2,"\uFFFD"}}function Jg(t){var e=this.lastTotal-this.lastNeed,r=Wg(this,t,e);if(r!==void 0)return r;if(this.lastNeed<=t.length)return t.copy(this.lastChar,e,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal);t.copy(this.lastChar,e,0,t.length),this.lastNeed-=t.length}function zg(t,e){var r=Gg(this,t,e);if(!this.lastNeed)return t.toString("utf8",e);this.lastTotal=r;var n=t.length-(r-this.lastNeed);return t.copy(this.lastChar,0,n),t.toString("utf8",e,n)}function Yg(t){var e=t&&t.length?this.write(t):"";return this.lastNeed?e+"\uFFFD":e}function Zg(t,e){if((t.length-e)%2===0){var r=t.toString("utf16le",e);if(r){var n=r.charCodeAt(r.length-1);if(n>=55296&&n<=56319)return this.lastNeed=2,this.lastTotal=4,this.lastChar[0]=t[t.length-2],this.lastChar[1]=t[t.length-1],r.slice(0,-1)}return r}return this.lastNeed=1,this.lastTotal=2,this.lastChar[0]=t[t.length-1],t.toString("utf16le",e,t.length-1)}function Xg(t){var e=t&&t.length?this.write(t):"";if(this.lastNeed){var r=this.lastTotal-this.lastNeed;return e+this.lastChar.toString("utf16le",0,r)}return e}function Qg(t,e){var r=(t.length-e)%3;return r===0?t.toString("base64",e):(this.lastNeed=3-r,this.lastTotal=3,r===1?this.lastChar[0]=t[t.length-1]:(this.lastChar[0]=t[t.length-2],this.lastChar[1]=t[t.length-1]),t.toString("base64",e,t.length-r))}function ex(t){var e=t&&t.length?this.write(t):"";return this.lastNeed?e+this.lastChar.toString("base64",0,3-this.lastNeed):e}function tx(t){return t.toString(this.encoding)}function rx(t){return t&&t.length?this.write(t):""}});var wc=M((BS,yh)=>{"use strict";var dh=ir(),{PromisePrototypeThen:nx,SymbolAsyncIterator:hh,SymbolIterator:ph}=ce(),{Buffer:ix}=qe(),{ERR_INVALID_ARG_TYPE:ox,ERR_STREAM_NULL_VALUES:sx}=Te().codes;function ax(t,e,r){let n;if(typeof e=="string"||e instanceof ix)return new t({objectMode:!0,...r,read(){this.push(e),this.push(null)}});let i;if(e&&e[hh])i=!0,n=e[hh]();else if(e&&e[ph])i=!1,n=e[ph]();else throw new ox("iterable",["Iterable"],e);let o=new t({objectMode:!0,highWaterMark:1,...r}),s=!1;o._read=function(){s||(s=!0,c())},o._destroy=function(f,u){nx(a(f),()=>dh.nextTick(u,f),l=>dh.nextTick(u,l||f))};async function a(f){let u=f!=null,l=typeof n.throw=="function";if(u&&l){let{value:p,done:h}=await n.throw(f);if(await p,h)return}if(typeof n.return=="function"){let{value:p}=await n.return();await p}}async function c(){for(;;){try{let{value:f,done:u}=i?await n.next():n.next();if(u)o.push(null);else{let l=f&&typeof f.then=="function"?await f:f;if(l===null)throw s=!1,new sx;if(o.push(l))continue;s=!1}}catch(f){o.destroy(f)}break}}return o}yh.exports=ax});var Ai=M((TS,Ch)=>{var Xe=ir(),{ArrayPrototypeIndexOf:cx,NumberIsInteger:fx,NumberIsNaN:ux,NumberParseInt:lx,ObjectDefineProperties:Sc,ObjectKeys:dx,ObjectSetPrototypeOf:bh,Promise:gh,SafeSet:hx,SymbolAsyncDispose:px,SymbolAsyncIterator:yx,Symbol:wx}=ce();Ch.exports=z;z.ReadableState=Mo;var{EventEmitter:mx}=ln(),{Stream:sr,prependListener:bx}=Uo(),{Buffer:mc}=qe(),{addAbortSignal:gx}=gi(),xh=Kt(),Q=Se().debuglog("stream",t=>{Q=t}),xx=th(),Pn=Vr(),{getHighWaterMark:Ex,getDefaultHighWaterMark:_x}=xi(),{aggregateTwoErrors:wh,codes:{ERR_INVALID_ARG_TYPE:Ax,ERR_METHOD_NOT_IMPLEMENTED:Sx,ERR_OUT_OF_RANGE:vx,ERR_STREAM_PUSH_AFTER_EOF:Bx,ERR_STREAM_UNSHIFT_AFTER_END_EVENT:Tx},AbortError:kx}=Te(),{validateObject:Px}=Sn(),Gr=wx("kPaused"),{StringDecoder:Eh}=lh(),Ix=wc();bh(z.prototype,sr.prototype);bh(z,sr);var bc=()=>{},{errorOrDestroy:Tn}=Pn,kn=1,Rx=2,_h=4,_i=8,Ah=16,Ko=32,No=64,Sh=128,Ux=256,Cx=512,Lx=1024,_c=2048,Ac=4096,Ox=8192,Kx=16384,Nx=32768,vh=65536,Dx=1<<17,Mx=1<<18;function he(t){return{enumerable:!1,get(){return(this.state&t)!==0},set(e){e?this.state|=t:this.state&=~t}}}Sc(Mo.prototype,{objectMode:he(kn),ended:he(Rx),endEmitted:he(_h),reading:he(_i),constructed:he(Ah),sync:he(Ko),needReadable:he(No),emittedReadable:he(Sh),readableListening:he(Ux),resumeScheduled:he(Cx),errorEmitted:he(Lx),emitClose:he(_c),autoDestroy:he(Ac),destroyed:he(Ox),closed:he(Kx),closeEmitted:he(Nx),multiAwaitDrain:he(vh),readingMore:he(Dx),dataEmitted:he(Mx)});function Mo(t,e,r){typeof r!="boolean"&&(r=e instanceof bt()),this.state=_c|Ac|Ah|Ko,t&&t.objectMode&&(this.state|=kn),r&&t&&t.readableObjectMode&&(this.state|=kn),this.highWaterMark=t?Ex(this,t,"readableHighWaterMark",r):_x(!1),this.buffer=new xx,this.length=0,this.pipes=[],this.flowing=null,this[Gr]=null,t&&t.emitClose===!1&&(this.state&=~_c),t&&t.autoDestroy===!1&&(this.state&=~Ac),this.errored=null,this.defaultEncoding=t&&t.defaultEncoding||"utf8",this.awaitDrainWriters=null,this.decoder=null,this.encoding=null,t&&t.encoding&&(this.decoder=new Eh(t.encoding),this.encoding=t.encoding)}function z(t){if(!(this instanceof z))return new z(t);let e=this instanceof bt();this._readableState=new Mo(t,this,e),t&&(typeof t.read=="function"&&(this._read=t.read),typeof t.destroy=="function"&&(this._destroy=t.destroy),typeof t.construct=="function"&&(this._construct=t.construct),t.signal&&!e&&gx(t.signal,this)),sr.call(this,t),Pn.construct(this,()=>{this._readableState.needReadable&&Do(this,this._readableState)})}z.prototype.destroy=Pn.destroy;z.prototype._undestroy=Pn.undestroy;z.prototype._destroy=function(t,e){e(t)};z.prototype[mx.captureRejectionSymbol]=function(t){this.destroy(t)};z.prototype[px]=function(){let t;return this.destroyed||(t=this.readableEnded?null:new kx,this.destroy(t)),new gh((e,r)=>xh(this,n=>n&&n!==t?r(n):e(null)))};z.prototype.push=function(t,e){return Bh(this,t,e,!1)};z.prototype.unshift=function(t,e){return Bh(this,t,e,!0)};function Bh(t,e,r,n){Q("readableAddChunk",e);let i=t._readableState,o;if(i.state&kn||(typeof e=="string"?(r=r||i.defaultEncoding,i.encoding!==r&&(n&&i.encoding?e=mc.from(e,r).toString(i.encoding):(e=mc.from(e,r),r=""))):e instanceof mc?r="":sr._isUint8Array(e)?(e=sr._uint8ArrayToBuffer(e),r=""):e!=null&&(o=new Ax("chunk",["string","Buffer","Uint8Array"],e))),o)Tn(t,o);else if(e===null)i.state&=~_i,Fx(t,i);else if(i.state&kn||e&&e.length>0)if(n)if(i.state&_h)Tn(t,new Tx);else{if(i.destroyed||i.errored)return!1;gc(t,i,e,!0)}else if(i.ended)Tn(t,new Bx);else{if(i.destroyed||i.errored)return!1;i.state&=~_i,i.decoder&&!r?(e=i.decoder.write(e),i.objectMode||e.length!==0?gc(t,i,e,!1):Do(t,i)):gc(t,i,e,!1)}else n||(i.state&=~_i,Do(t,i));return!i.ended&&(i.length<i.highWaterMark||i.length===0)}function gc(t,e,r,n){e.flowing&&e.length===0&&!e.sync&&t.listenerCount("data")>0?(e.state&vh?e.awaitDrainWriters.clear():e.awaitDrainWriters=null,e.dataEmitted=!0,t.emit("data",r)):(e.length+=e.objectMode?1:r.length,n?e.buffer.unshift(r):e.buffer.push(r),e.state&No&&qo(t)),Do(t,e)}z.prototype.isPaused=function(){let t=this._readableState;return t[Gr]===!0||t.flowing===!1};z.prototype.setEncoding=function(t){let e=new Eh(t);this._readableState.decoder=e,this._readableState.encoding=this._readableState.decoder.encoding;let r=this._readableState.buffer,n="";for(let i of r)n+=e.write(i);return r.clear(),n!==""&&r.push(n),this._readableState.length=n.length,this};var qx=1073741824;function jx(t){if(t>qx)throw new vx("size","<= 1GiB",t);return t--,t|=t>>>1,t|=t>>>2,t|=t>>>4,t|=t>>>8,t|=t>>>16,t++,t}function mh(t,e){return t<=0||e.length===0&&e.ended?0:e.state&kn?1:ux(t)?e.flowing&&e.length?e.buffer.first().length:e.length:t<=e.length?t:e.ended?e.length:0}z.prototype.read=function(t){Q("read",t),t===void 0?t=NaN:fx(t)||(t=lx(t,10));let e=this._readableState,r=t;if(t>e.highWaterMark&&(e.highWaterMark=jx(t)),t!==0&&(e.state&=~Sh),t===0&&e.needReadable&&((e.highWaterMark!==0?e.length>=e.highWaterMark:e.length>0)||e.ended))return Q("read: emitReadable",e.length,e.ended),e.length===0&&e.ended?xc(this):qo(this),null;if(t=mh(t,e),t===0&&e.ended)return e.length===0&&xc(this),null;let n=(e.state&No)!==0;if(Q("need readable",n),(e.length===0||e.length-t<e.highWaterMark)&&(n=!0,Q("length less than watermark",n)),e.ended||e.reading||e.destroyed||e.errored||!e.constructed)n=!1,Q("reading, ended or constructing",n);else if(n){Q("do read"),e.state|=_i|Ko,e.length===0&&(e.state|=No);try{this._read(e.highWaterMark)}catch(o){Tn(this,o)}e.state&=~Ko,e.reading||(t=mh(r,e))}let i;return t>0?i=Rh(t,e):i=null,i===null?(e.needReadable=e.length<=e.highWaterMark,t=0):(e.length-=t,e.multiAwaitDrain?e.awaitDrainWriters.clear():e.awaitDrainWriters=null),e.length===0&&(e.ended||(e.needReadable=!0),r!==t&&e.ended&&xc(this)),i!==null&&!e.errorEmitted&&!e.closeEmitted&&(e.dataEmitted=!0,this.emit("data",i)),i};function Fx(t,e){if(Q("onEofChunk"),!e.ended){if(e.decoder){let r=e.decoder.end();r&&r.length&&(e.buffer.push(r),e.length+=e.objectMode?1:r.length)}e.ended=!0,e.sync?qo(t):(e.needReadable=!1,e.emittedReadable=!0,Th(t))}}function qo(t){let e=t._readableState;Q("emitReadable",e.needReadable,e.emittedReadable),e.needReadable=!1,e.emittedReadable||(Q("emitReadable",e.flowing),e.emittedReadable=!0,Xe.nextTick(Th,t))}function Th(t){let e=t._readableState;Q("emitReadable_",e.destroyed,e.length,e.ended),!e.destroyed&&!e.errored&&(e.length||e.ended)&&(t.emit("readable"),e.emittedReadable=!1),e.needReadable=!e.flowing&&!e.ended&&e.length<=e.highWaterMark,Ph(t)}function Do(t,e){!e.readingMore&&e.constructed&&(e.readingMore=!0,Xe.nextTick($x,t,e))}function $x(t,e){for(;!e.reading&&!e.ended&&(e.length<e.highWaterMark||e.flowing&&e.length===0);){let r=e.length;if(Q("maybeReadMore read 0"),t.read(0),r===e.length)break}e.readingMore=!1}z.prototype._read=function(t){throw new Sx("_read()")};z.prototype.pipe=function(t,e){let r=this,n=this._readableState;n.pipes.length===1&&(n.multiAwaitDrain||(n.multiAwaitDrain=!0,n.awaitDrainWriters=new hx(n.awaitDrainWriters?[n.awaitDrainWriters]:[]))),n.pipes.push(t),Q("pipe count=%d opts=%j",n.pipes.length,e);let o=(!e||e.end!==!1)&&t!==Xe.stdout&&t!==Xe.stderr?a:w;n.endEmitted?Xe.nextTick(o):r.once("end",o),t.on("unpipe",s);function s(m,A){Q("onunpipe"),m===r&&A&&A.hasUnpiped===!1&&(A.hasUnpiped=!0,u())}function a(){Q("onend"),t.end()}let c,f=!1;function u(){Q("cleanup"),t.removeListener("close",y),t.removeListener("finish",d),c&&t.removeListener("drain",c),t.removeListener("error",h),t.removeListener("unpipe",s),r.removeListener("end",a),r.removeListener("end",w),r.removeListener("data",p),f=!0,c&&n.awaitDrainWriters&&(!t._writableState||t._writableState.needDrain)&&c()}function l(){f||(n.pipes.length===1&&n.pipes[0]===t?(Q("false write response, pause",0),n.awaitDrainWriters=t,n.multiAwaitDrain=!1):n.pipes.length>1&&n.pipes.includes(t)&&(Q("false write response, pause",n.awaitDrainWriters.size),n.awaitDrainWriters.add(t)),r.pause()),c||(c=Vx(r,t),t.on("drain",c))}r.on("data",p);function p(m){Q("ondata");let A=t.write(m);Q("dest.write",A),A===!1&&l()}function h(m){if(Q("onerror",m),w(),t.removeListener("error",h),t.listenerCount("error")===0){let A=t._writableState||t._readableState;A&&!A.errorEmitted?Tn(t,m):t.emit("error",m)}}bx(t,"error",h);function y(){t.removeListener("finish",d),w()}t.once("close",y);function d(){Q("onfinish"),t.removeListener("close",y),w()}t.once("finish",d);function w(){Q("unpipe"),r.unpipe(t)}return t.emit("pipe",r),t.writableNeedDrain===!0?l():n.flowing||(Q("pipe resume"),r.resume()),t};function Vx(t,e){return function(){let n=t._readableState;n.awaitDrainWriters===e?(Q("pipeOnDrain",1),n.awaitDrainWriters=null):n.multiAwaitDrain&&(Q("pipeOnDrain",n.awaitDrainWriters.size),n.awaitDrainWriters.delete(e)),(!n.awaitDrainWriters||n.awaitDrainWriters.size===0)&&t.listenerCount("data")&&t.resume()}}z.prototype.unpipe=function(t){let e=this._readableState,r={hasUnpiped:!1};if(e.pipes.length===0)return this;if(!t){let i=e.pipes;e.pipes=[],this.pause();for(let o=0;o<i.length;o++)i[o].emit("unpipe",this,{hasUnpiped:!1});return this}let n=cx(e.pipes,t);return n===-1?this:(e.pipes.splice(n,1),e.pipes.length===0&&this.pause(),t.emit("unpipe",this,r),this)};z.prototype.on=function(t,e){let r=sr.prototype.on.call(this,t,e),n=this._readableState;return t==="data"?(n.readableListening=this.listenerCount("readable")>0,n.flowing!==!1&&this.resume()):t==="readable"&&!n.endEmitted&&!n.readableListening&&(n.readableListening=n.needReadable=!0,n.flowing=!1,n.emittedReadable=!1,Q("on readable",n.length,n.reading),n.length?qo(this):n.reading||Xe.nextTick(Hx,this)),r};z.prototype.addListener=z.prototype.on;z.prototype.removeListener=function(t,e){let r=sr.prototype.removeListener.call(this,t,e);return t==="readable"&&Xe.nextTick(kh,this),r};z.prototype.off=z.prototype.removeListener;z.prototype.removeAllListeners=function(t){let e=sr.prototype.removeAllListeners.apply(this,arguments);return(t==="readable"||t===void 0)&&Xe.nextTick(kh,this),e};function kh(t){let e=t._readableState;e.readableListening=t.listenerCount("readable")>0,e.resumeScheduled&&e[Gr]===!1?e.flowing=!0:t.listenerCount("data")>0?t.resume():e.readableListening||(e.flowing=null)}function Hx(t){Q("readable nexttick read 0"),t.read(0)}z.prototype.resume=function(){let t=this._readableState;return t.flowing||(Q("resume"),t.flowing=!t.readableListening,Gx(this,t)),t[Gr]=!1,this};function Gx(t,e){e.resumeScheduled||(e.resumeScheduled=!0,Xe.nextTick(Wx,t,e))}function Wx(t,e){Q("resume",e.reading),e.reading||t.read(0),e.resumeScheduled=!1,t.emit("resume"),Ph(t),e.flowing&&!e.reading&&t.read(0)}z.prototype.pause=function(){return Q("call pause flowing=%j",this._readableState.flowing),this._readableState.flowing!==!1&&(Q("pause"),this._readableState.flowing=!1,this.emit("pause")),this._readableState[Gr]=!0,this};function Ph(t){let e=t._readableState;for(Q("flow",e.flowing);e.flowing&&t.read()!==null;);}z.prototype.wrap=function(t){let e=!1;t.on("data",n=>{!this.push(n)&&t.pause&&(e=!0,t.pause())}),t.on("end",()=>{this.push(null)}),t.on("error",n=>{Tn(this,n)}),t.on("close",()=>{this.destroy()}),t.on("destroy",()=>{this.destroy()}),this._read=()=>{e&&t.resume&&(e=!1,t.resume())};let r=dx(t);for(let n=1;n<r.length;n++){let i=r[n];this[i]===void 0&&typeof t[i]=="function"&&(this[i]=t[i].bind(t))}return this};z.prototype[yx]=function(){return Ih(this)};z.prototype.iterator=function(t){return t!==void 0&&Px(t,"options"),Ih(this,t)};function Ih(t,e){typeof t.read!="function"&&(t=z.wrap(t,{objectMode:!0}));let r=Jx(t,e);return r.stream=t,r}async function*Jx(t,e){let r=bc;function n(s){this===t?(r(),r=bc):r=s}t.on("readable",n);let i,o=xh(t,{writable:!1},s=>{i=s?wh(i,s):null,r(),r=bc});try{for(;;){let s=t.destroyed?null:t.read();if(s!==null)yield s;else{if(i)throw i;if(i===null)return;await new gh(n)}}}catch(s){throw i=wh(i,s),i}finally{(i||e?.destroyOnReturn!==!1)&&(i===void 0||t._readableState.autoDestroy)?Pn.destroyer(t,null):(t.off("readable",n),o())}}Sc(z.prototype,{readable:{__proto__:null,get(){let t=this._readableState;return!!t&&t.readable!==!1&&!t.destroyed&&!t.errorEmitted&&!t.endEmitted},set(t){this._readableState&&(this._readableState.readable=!!t)}},readableDidRead:{__proto__:null,enumerable:!1,get:function(){return this._readableState.dataEmitted}},readableAborted:{__proto__:null,enumerable:!1,get:function(){return!!(this._readableState.readable!==!1&&(this._readableState.destroyed||this._readableState.errored)&&!this._readableState.endEmitted)}},readableHighWaterMark:{__proto__:null,enumerable:!1,get:function(){return this._readableState.highWaterMark}},readableBuffer:{__proto__:null,enumerable:!1,get:function(){return this._readableState&&this._readableState.buffer}},readableFlowing:{__proto__:null,enumerable:!1,get:function(){return this._readableState.flowing},set:function(t){this._readableState&&(this._readableState.flowing=t)}},readableLength:{__proto__:null,enumerable:!1,get(){return this._readableState.length}},readableObjectMode:{__proto__:null,enumerable:!1,get(){return this._readableState?this._readableState.objectMode:!1}},readableEncoding:{__proto__:null,enumerable:!1,get(){return this._readableState?this._readableState.encoding:null}},errored:{__proto__:null,enumerable:!1,get(){return this._readableState?this._readableState.errored:null}},closed:{__proto__:null,get(){return this._readableState?this._readableState.closed:!1}},destroyed:{__proto__:null,enumerable:!1,get(){return this._readableState?this._readableState.destroyed:!1},set(t){this._readableState&&(this._readableState.destroyed=t)}},readableEnded:{__proto__:null,enumerable:!1,get(){return this._readableState?this._readableState.endEmitted:!1}}});Sc(Mo.prototype,{pipesCount:{__proto__:null,get(){return this.pipes.length}},paused:{__proto__:null,get(){return this[Gr]!==!1},set(t){this[Gr]=!!t}}});z._fromList=Rh;function Rh(t,e){if(e.length===0)return null;let r;return e.objectMode?r=e.buffer.shift():!t||t>=e.length?(e.decoder?r=e.buffer.join(""):e.buffer.length===1?r=e.buffer.first():r=e.buffer.concat(e.length),e.buffer.clear()):r=e.buffer.consume(t,e.decoder),r}function xc(t){let e=t._readableState;Q("endReadable",e.endEmitted),e.endEmitted||(e.ended=!0,Xe.nextTick(zx,e,t))}function zx(t,e){if(Q("endReadableNT",t.endEmitted,t.length),!t.errored&&!t.closeEmitted&&!t.endEmitted&&t.length===0){if(t.endEmitted=!0,e.emit("end"),e.writable&&e.allowHalfOpen===!1)Xe.nextTick(Yx,e);else if(t.autoDestroy){let r=e._writableState;(!r||r.autoDestroy&&(r.finished||r.writable===!1))&&e.destroy()}}}function Yx(t){t.writable&&!t.writableEnded&&!t.destroyed&&t.end()}z.from=function(t,e){return Ix(z,t,e)};var Ec;function Uh(){return Ec===void 0&&(Ec={}),Ec}z.fromWeb=function(t,e){return Uh().newStreamReadableFromReadableStream(t,e)};z.toWeb=function(t,e){return Uh().newReadableStreamFromStreamReadable(t,e)};z.wrap=function(t,e){var r,n;return new z({objectMode:(r=(n=t.readableObjectMode)!==null&&n!==void 0?n:t.objectMode)!==null&&r!==void 0?r:!0,...e,destroy(i,o){Pn.destroyer(t,i),o(i)}}).wrap(t)}});var Ho=M((kS,Hh)=>{var Wr=ir(),{ArrayPrototypeSlice:Kh,Error:Zx,FunctionPrototypeSymbolHasInstance:Nh,ObjectDefineProperty:Dh,ObjectDefineProperties:Xx,ObjectSetPrototypeOf:Mh,StringPrototypeToLowerCase:Qx,Symbol:eE,SymbolHasInstance:tE}=ce();Hh.exports=fe;fe.WritableState=Bi;var{EventEmitter:rE}=ln(),Si=Uo().Stream,{Buffer:jo}=qe(),Vo=Vr(),{addAbortSignal:nE}=gi(),{getHighWaterMark:iE,getDefaultHighWaterMark:oE}=xi(),{ERR_INVALID_ARG_TYPE:sE,ERR_METHOD_NOT_IMPLEMENTED:aE,ERR_MULTIPLE_CALLBACK:qh,ERR_STREAM_CANNOT_PIPE:cE,ERR_STREAM_DESTROYED:vi,ERR_STREAM_ALREADY_FINISHED:fE,ERR_STREAM_NULL_VALUES:uE,ERR_STREAM_WRITE_AFTER_END:lE,ERR_UNKNOWN_ENCODING:jh}=Te().codes,{errorOrDestroy:In}=Vo;Mh(fe.prototype,Si.prototype);Mh(fe,Si);function Tc(){}var Rn=eE("kOnFinished");function Bi(t,e,r){typeof r!="boolean"&&(r=e instanceof bt()),this.objectMode=!!(t&&t.objectMode),r&&(this.objectMode=this.objectMode||!!(t&&t.writableObjectMode)),this.highWaterMark=t?iE(this,t,"writableHighWaterMark",r):oE(!1),this.finalCalled=!1,this.needDrain=!1,this.ending=!1,this.ended=!1,this.finished=!1,this.destroyed=!1;let n=!!(t&&t.decodeStrings===!1);this.decodeStrings=!n,this.defaultEncoding=t&&t.defaultEncoding||"utf8",this.length=0,this.writing=!1,this.corked=0,this.sync=!0,this.bufferProcessing=!1,this.onwrite=hE.bind(void 0,e),this.writecb=null,this.writelen=0,this.afterWriteTickInfo=null,$o(this),this.pendingcb=0,this.constructed=!0,this.prefinished=!1,this.errorEmitted=!1,this.emitClose=!t||t.emitClose!==!1,this.autoDestroy=!t||t.autoDestroy!==!1,this.errored=null,this.closed=!1,this.closeEmitted=!1,this[Rn]=[]}function $o(t){t.buffered=[],t.bufferedIndex=0,t.allBuffers=!0,t.allNoop=!0}Bi.prototype.getBuffer=function(){return Kh(this.buffered,this.bufferedIndex)};Dh(Bi.prototype,"bufferedRequestCount",{__proto__:null,get(){return this.buffered.length-this.bufferedIndex}});function fe(t){let e=this instanceof bt();if(!e&&!Nh(fe,this))return new fe(t);this._writableState=new Bi(t,this,e),t&&(typeof t.write=="function"&&(this._write=t.write),typeof t.writev=="function"&&(this._writev=t.writev),typeof t.destroy=="function"&&(this._destroy=t.destroy),typeof t.final=="function"&&(this._final=t.final),typeof t.construct=="function"&&(this._construct=t.construct),t.signal&&nE(t.signal,this)),Si.call(this,t),Vo.construct(this,()=>{let r=this._writableState;r.writing||Pc(this,r),Ic(this,r)})}Dh(fe,tE,{__proto__:null,value:function(t){return Nh(this,t)?!0:this!==fe?!1:t&&t._writableState instanceof Bi}});fe.prototype.pipe=function(){In(this,new cE)};function Fh(t,e,r,n){let i=t._writableState;if(typeof r=="function")n=r,r=i.defaultEncoding;else{if(!r)r=i.defaultEncoding;else if(r!=="buffer"&&!jo.isEncoding(r))throw new jh(r);typeof n!="function"&&(n=Tc)}if(e===null)throw new uE;if(!i.objectMode)if(typeof e=="string")i.decodeStrings!==!1&&(e=jo.from(e,r),r="buffer");else if(e instanceof jo)r="buffer";else if(Si._isUint8Array(e))e=Si._uint8ArrayToBuffer(e),r="buffer";else throw new sE("chunk",["string","Buffer","Uint8Array"],e);let o;return i.ending?o=new lE:i.destroyed&&(o=new vi("write")),o?(Wr.nextTick(n,o),In(t,o,!0),o):(i.pendingcb++,dE(t,i,e,r,n))}fe.prototype.write=function(t,e,r){return Fh(this,t,e,r)===!0};fe.prototype.cork=function(){this._writableState.corked++};fe.prototype.uncork=function(){let t=this._writableState;t.corked&&(t.corked--,t.writing||Pc(this,t))};fe.prototype.setDefaultEncoding=function(e){if(typeof e=="string"&&(e=Qx(e)),!jo.isEncoding(e))throw new jh(e);return this._writableState.defaultEncoding=e,this};function dE(t,e,r,n,i){let o=e.objectMode?1:r.length;e.length+=o;let s=e.length<e.highWaterMark;return s||(e.needDrain=!0),e.writing||e.corked||e.errored||!e.constructed?(e.buffered.push({chunk:r,encoding:n,callback:i}),e.allBuffers&&n!=="buffer"&&(e.allBuffers=!1),e.allNoop&&i!==Tc&&(e.allNoop=!1)):(e.writelen=o,e.writecb=i,e.writing=!0,e.sync=!0,t._write(r,n,e.onwrite),e.sync=!1),s&&!e.errored&&!e.destroyed}function Lh(t,e,r,n,i,o,s){e.writelen=n,e.writecb=s,e.writing=!0,e.sync=!0,e.destroyed?e.onwrite(new vi("write")):r?t._writev(i,e.onwrite):t._write(i,o,e.onwrite),e.sync=!1}function Oh(t,e,r,n){--e.pendingcb,n(r),kc(e),In(t,r)}function hE(t,e){let r=t._writableState,n=r.sync,i=r.writecb;if(typeof i!="function"){In(t,new qh);return}r.writing=!1,r.writecb=null,r.length-=r.writelen,r.writelen=0,e?(e.stack,r.errored||(r.errored=e),t._readableState&&!t._readableState.errored&&(t._readableState.errored=e),n?Wr.nextTick(Oh,t,r,e,i):Oh(t,r,e,i)):(r.buffered.length>r.bufferedIndex&&Pc(t,r),n?r.afterWriteTickInfo!==null&&r.afterWriteTickInfo.cb===i?r.afterWriteTickInfo.count++:(r.afterWriteTickInfo={count:1,cb:i,stream:t,state:r},Wr.nextTick(pE,r.afterWriteTickInfo)):$h(t,r,1,i))}function pE({stream:t,state:e,count:r,cb:n}){return e.afterWriteTickInfo=null,$h(t,e,r,n)}function $h(t,e,r,n){for(!e.ending&&!t.destroyed&&e.length===0&&e.needDrain&&(e.needDrain=!1,t.emit("drain"));r-- >0;)e.pendingcb--,n();e.destroyed&&kc(e),Ic(t,e)}function kc(t){if(t.writing)return;for(let i=t.bufferedIndex;i<t.buffered.length;++i){var e;let{chunk:o,callback:s}=t.buffered[i],a=t.objectMode?1:o.length;t.length-=a,s((e=t.errored)!==null&&e!==void 0?e:new vi("write"))}let r=t[Rn].splice(0);for(let i=0;i<r.length;i++){var n;r[i]((n=t.errored)!==null&&n!==void 0?n:new vi("end"))}$o(t)}function Pc(t,e){if(e.corked||e.bufferProcessing||e.destroyed||!e.constructed)return;let{buffered:r,bufferedIndex:n,objectMode:i}=e,o=r.length-n;if(!o)return;let s=n;if(e.bufferProcessing=!0,o>1&&t._writev){e.pendingcb-=o-1;let a=e.allNoop?Tc:f=>{for(let u=s;u<r.length;++u)r[u].callback(f)},c=e.allNoop&&s===0?r:Kh(r,s);c.allBuffers=e.allBuffers,Lh(t,e,!0,e.length,c,"",a),$o(e)}else{do{let{chunk:a,encoding:c,callback:f}=r[s];r[s++]=null;let u=i?1:a.length;Lh(t,e,!1,u,a,c,f)}while(s<r.length&&!e.writing);s===r.length?$o(e):s>256?(r.splice(0,s),e.bufferedIndex=0):e.bufferedIndex=s}e.bufferProcessing=!1}fe.prototype._write=function(t,e,r){if(this._writev)this._writev([{chunk:t,encoding:e}],r);else throw new aE("_write()")};fe.prototype._writev=null;fe.prototype.end=function(t,e,r){let n=this._writableState;typeof t=="function"?(r=t,t=null,e=null):typeof e=="function"&&(r=e,e=null);let i;if(t!=null){let o=Fh(this,t,e);o instanceof Zx&&(i=o)}return n.corked&&(n.corked=1,this.uncork()),i||(!n.errored&&!n.ending?(n.ending=!0,Ic(this,n,!0),n.ended=!0):n.finished?i=new fE("end"):n.destroyed&&(i=new vi("end"))),typeof r=="function"&&(i||n.finished?Wr.nextTick(r,i):n[Rn].push(r)),this};function Fo(t){return t.ending&&!t.destroyed&&t.constructed&&t.length===0&&!t.errored&&t.buffered.length===0&&!t.finished&&!t.writing&&!t.errorEmitted&&!t.closeEmitted}function yE(t,e){let r=!1;function n(i){if(r){In(t,i??qh());return}if(r=!0,e.pendingcb--,i){let o=e[Rn].splice(0);for(let s=0;s<o.length;s++)o[s](i);In(t,i,e.sync)}else Fo(e)&&(e.prefinished=!0,t.emit("prefinish"),e.pendingcb++,Wr.nextTick(Bc,t,e))}e.sync=!0,e.pendingcb++;try{t._final(n)}catch(i){n(i)}e.sync=!1}function wE(t,e){!e.prefinished&&!e.finalCalled&&(typeof t._final=="function"&&!e.destroyed?(e.finalCalled=!0,yE(t,e)):(e.prefinished=!0,t.emit("prefinish")))}function Ic(t,e,r){Fo(e)&&(wE(t,e),e.pendingcb===0&&(r?(e.pendingcb++,Wr.nextTick((n,i)=>{Fo(i)?Bc(n,i):i.pendingcb--},t,e)):Fo(e)&&(e.pendingcb++,Bc(t,e))))}function Bc(t,e){e.pendingcb--,e.finished=!0;let r=e[Rn].splice(0);for(let n=0;n<r.length;n++)r[n]();if(t.emit("finish"),e.autoDestroy){let n=t._readableState;(!n||n.autoDestroy&&(n.endEmitted||n.readable===!1))&&t.destroy()}}Xx(fe.prototype,{closed:{__proto__:null,get(){return this._writableState?this._writableState.closed:!1}},destroyed:{__proto__:null,get(){return this._writableState?this._writableState.destroyed:!1},set(t){this._writableState&&(this._writableState.destroyed=t)}},writable:{__proto__:null,get(){let t=this._writableState;return!!t&&t.writable!==!1&&!t.destroyed&&!t.errored&&!t.ending&&!t.ended},set(t){this._writableState&&(this._writableState.writable=!!t)}},writableFinished:{__proto__:null,get(){return this._writableState?this._writableState.finished:!1}},writableObjectMode:{__proto__:null,get(){return this._writableState?this._writableState.objectMode:!1}},writableBuffer:{__proto__:null,get(){return this._writableState&&this._writableState.getBuffer()}},writableEnded:{__proto__:null,get(){return this._writableState?this._writableState.ending:!1}},writableNeedDrain:{__proto__:null,get(){let t=this._writableState;return t?!t.destroyed&&!t.ending&&t.needDrain:!1}},writableHighWaterMark:{__proto__:null,get(){return this._writableState&&this._writableState.highWaterMark}},writableCorked:{__proto__:null,get(){return this._writableState?this._writableState.corked:0}},writableLength:{__proto__:null,get(){return this._writableState&&this._writableState.length}},errored:{__proto__:null,enumerable:!1,get(){return this._writableState?this._writableState.errored:null}},writableAborted:{__proto__:null,enumerable:!1,get:function(){return!!(this._writableState.writable!==!1&&(this._writableState.destroyed||this._writableState.errored)&&!this._writableState.finished)}}});var mE=Vo.destroy;fe.prototype.destroy=function(t,e){let r=this._writableState;return!r.destroyed&&(r.bufferedIndex<r.buffered.length||r[Rn].length)&&Wr.nextTick(kc,r),mE.call(this,t,e),this};fe.prototype._undestroy=Vo.undestroy;fe.prototype._destroy=function(t,e){e(t)};fe.prototype[rE.captureRejectionSymbol]=function(t){this.destroy(t)};var vc;function Vh(){return vc===void 0&&(vc={}),vc}fe.fromWeb=function(t,e){return Vh().newStreamWritableFromWritableStream(t,e)};fe.toWeb=function(t){return Vh().newWritableStreamFromStreamWritable(t)}});var sp=M((PS,op)=>{var Rc=ir(),bE=qe(),{isReadable:gE,isWritable:xE,isIterable:Gh,isNodeStream:EE,isReadableNodeStream:Wh,isWritableNodeStream:Jh,isDuplexNodeStream:_E,isReadableStream:zh,isWritableStream:Yh}=yt(),Zh=Kt(),{AbortError:np,codes:{ERR_INVALID_ARG_TYPE:AE,ERR_INVALID_RETURN_VALUE:Xh}}=Te(),{destroyer:Cn}=Vr(),SE=bt(),ip=Ai(),vE=Ho(),{createDeferredPromise:Qh}=Se(),ep=wc(),tp=globalThis.Blob||bE.Blob,BE=typeof tp<"u"?function(e){return e instanceof tp}:function(e){return!1},TE=globalThis.AbortController||_n().AbortController,{FunctionPrototypeCall:rp}=ce(),ar=class extends SE{constructor(e){super(e),e?.readable===!1&&(this._readableState.readable=!1,this._readableState.ended=!0,this._readableState.endEmitted=!0),e?.writable===!1&&(this._writableState.writable=!1,this._writableState.ending=!0,this._writableState.ended=!0,this._writableState.finished=!0)}};op.exports=function t(e,r){if(_E(e))return e;if(Wh(e))return Un({readable:e});if(Jh(e))return Un({writable:e});if(EE(e))return Un({writable:!1,readable:!1});if(zh(e))return Un({readable:ip.fromWeb(e)});if(Yh(e))return Un({writable:vE.fromWeb(e)});if(typeof e=="function"){let{value:i,write:o,final:s,destroy:a}=kE(e);if(Gh(i))return ep(ar,i,{objectMode:!0,write:o,final:s,destroy:a});let c=i?.then;if(typeof c=="function"){let f,u=rp(c,i,l=>{if(l!=null)throw new Xh("nully","body",l)},l=>{Cn(f,l)});return f=new ar({objectMode:!0,readable:!1,write:o,final(l){s(async()=>{try{await u,Rc.nextTick(l,null)}catch(p){Rc.nextTick(l,p)}})},destroy:a})}throw new Xh("Iterable, AsyncIterable or AsyncFunction",r,i)}if(BE(e))return t(e.arrayBuffer());if(Gh(e))return ep(ar,e,{objectMode:!0,writable:!1});if(zh(e?.readable)&&Yh(e?.writable))return ar.fromWeb(e);if(typeof e?.writable=="object"||typeof e?.readable=="object"){let i=e!=null&&e.readable?Wh(e?.readable)?e?.readable:t(e.readable):void 0,o=e!=null&&e.writable?Jh(e?.writable)?e?.writable:t(e.writable):void 0;return Un({readable:i,writable:o})}let n=e?.then;if(typeof n=="function"){let i;return rp(n,e,o=>{o!=null&&i.push(o),i.push(null)},o=>{Cn(i,o)}),i=new ar({objectMode:!0,writable:!1,read(){}})}throw new AE(r,["Blob","ReadableStream","WritableStream","Stream","Iterable","AsyncIterable","Function","{ readable, writable } pair","Promise"],e)};function kE(t){let{promise:e,resolve:r}=Qh(),n=new TE,i=n.signal;return{value:t(async function*(){for(;;){let s=e;e=null;let{chunk:a,done:c,cb:f}=await s;if(Rc.nextTick(f),c)return;if(i.aborted)throw new np(void 0,{cause:i.reason});({promise:e,resolve:r}=Qh()),yield a}}(),{signal:i}),write(s,a,c){let f=r;r=null,f({chunk:s,done:!1,cb:c})},final(s){let a=r;r=null,a({done:!0,cb:s})},destroy(s,a){n.abort(),a(s)}}}function Un(t){let e=t.readable&&typeof t.readable.read!="function"?ip.wrap(t.readable):t.readable,r=t.writable,n=!!gE(e),i=!!xE(r),o,s,a,c,f;function u(l){let p=c;c=null,p?p(l):l&&f.destroy(l)}return f=new ar({readableObjectMode:!!(e!=null&&e.readableObjectMode),writableObjectMode:!!(r!=null&&r.writableObjectMode),readable:n,writable:i}),i&&(Zh(r,l=>{i=!1,l&&Cn(e,l),u(l)}),f._write=function(l,p,h){r.write(l,p)?h():o=h},f._final=function(l){r.end(),s=l},r.on("drain",function(){if(o){let l=o;o=null,l()}}),r.on("finish",function(){if(s){let l=s;s=null,l()}})),n&&(Zh(e,l=>{n=!1,l&&Cn(e,l),u(l)}),e.on("readable",function(){if(a){let l=a;a=null,l()}}),e.on("end",function(){f.push(null)}),f._read=function(){for(;;){let l=e.read();if(l===null){a=f._read;return}if(!f.push(l))return}}),f._destroy=function(l,p){!l&&c!==null&&(l=new np),a=null,o=null,s=null,c===null?p(l):(c=p,Cn(r,l),Cn(e,l))},f}});var bt=M((IS,fp)=>{"use strict";var{ObjectDefineProperties:PE,ObjectGetOwnPropertyDescriptor:Nt,ObjectKeys:IE,ObjectSetPrototypeOf:ap}=ce();fp.exports=Qe;var Lc=Ai(),Ve=Ho();ap(Qe.prototype,Lc.prototype);ap(Qe,Lc);{let t=IE(Ve.prototype);for(let e=0;e<t.length;e++){let r=t[e];Qe.prototype[r]||(Qe.prototype[r]=Ve.prototype[r])}}function Qe(t){if(!(this instanceof Qe))return new Qe(t);Lc.call(this,t),Ve.call(this,t),t?(this.allowHalfOpen=t.allowHalfOpen!==!1,t.readable===!1&&(this._readableState.readable=!1,this._readableState.ended=!0,this._readableState.endEmitted=!0),t.writable===!1&&(this._writableState.writable=!1,this._writableState.ending=!0,this._writableState.ended=!0,this._writableState.finished=!0)):this.allowHalfOpen=!0}PE(Qe.prototype,{writable:{__proto__:null,...Nt(Ve.prototype,"writable")},writableHighWaterMark:{__proto__:null,...Nt(Ve.prototype,"writableHighWaterMark")},writableObjectMode:{__proto__:null,...Nt(Ve.prototype,"writableObjectMode")},writableBuffer:{__proto__:null,...Nt(Ve.prototype,"writableBuffer")},writableLength:{__proto__:null,...Nt(Ve.prototype,"writableLength")},writableFinished:{__proto__:null,...Nt(Ve.prototype,"writableFinished")},writableCorked:{__proto__:null,...Nt(Ve.prototype,"writableCorked")},writableEnded:{__proto__:null,...Nt(Ve.prototype,"writableEnded")},writableNeedDrain:{__proto__:null,...Nt(Ve.prototype,"writableNeedDrain")},destroyed:{__proto__:null,get(){return this._readableState===void 0||this._writableState===void 0?!1:this._readableState.destroyed&&this._writableState.destroyed},set(t){this._readableState&&this._writableState&&(this._readableState.destroyed=t,this._writableState.destroyed=t)}}});var Uc;function cp(){return Uc===void 0&&(Uc={}),Uc}Qe.fromWeb=function(t,e){return cp().newStreamDuplexFromReadableWritablePair(t,e)};Qe.toWeb=function(t){return cp().newReadableWritablePairFromDuplex(t)};var Cc;Qe.from=function(t){return Cc||(Cc=sp()),Cc(t,"body")}});var Nc=M((RS,lp)=>{"use strict";var{ObjectSetPrototypeOf:up,Symbol:RE}=ce();lp.exports=Dt;var{ERR_METHOD_NOT_IMPLEMENTED:UE}=Te().codes,Kc=bt(),{getHighWaterMark:CE}=xi();up(Dt.prototype,Kc.prototype);up(Dt,Kc);var Ti=RE("kCallback");function Dt(t){if(!(this instanceof Dt))return new Dt(t);let e=t?CE(this,t,"readableHighWaterMark",!0):null;e===0&&(t={...t,highWaterMark:null,readableHighWaterMark:e,writableHighWaterMark:t.writableHighWaterMark||0}),Kc.call(this,t),this._readableState.sync=!1,this[Ti]=null,t&&(typeof t.transform=="function"&&(this._transform=t.transform),typeof t.flush=="function"&&(this._flush=t.flush)),this.on("prefinish",LE)}function Oc(t){typeof this._flush=="function"&&!this.destroyed?this._flush((e,r)=>{if(e){t?t(e):this.destroy(e);return}r!=null&&this.push(r),this.push(null),t&&t()}):(this.push(null),t&&t())}function LE(){this._final!==Oc&&Oc.call(this)}Dt.prototype._final=Oc;Dt.prototype._transform=function(t,e,r){throw new UE("_transform()")};Dt.prototype._write=function(t,e,r){let n=this._readableState,i=this._writableState,o=n.length;this._transform(t,e,(s,a)=>{if(s){r(s);return}a!=null&&this.push(a),i.ended||o===n.length||n.length<n.highWaterMark?r():this[Ti]=r})};Dt.prototype._read=function(){if(this[Ti]){let t=this[Ti];this[Ti]=null,t()}}});var Mc=M((US,hp)=>{"use strict";var{ObjectSetPrototypeOf:dp}=ce();hp.exports=Ln;var Dc=Nc();dp(Ln.prototype,Dc.prototype);dp(Ln,Dc);function Ln(t){if(!(this instanceof Ln))return new Ln(t);Dc.call(this,t)}Ln.prototype._transform=function(t,e,r){r(null,t)}});var zo=M((CS,bp)=>{var ki=ir(),{ArrayIsArray:OE,Promise:KE,SymbolAsyncIterator:NE,SymbolDispose:DE}=ce(),Jo=Kt(),{once:ME}=Se(),qE=Vr(),pp=bt(),{aggregateTwoErrors:jE,codes:{ERR_INVALID_ARG_TYPE:Jc,ERR_INVALID_RETURN_VALUE:qc,ERR_MISSING_ARGS:FE,ERR_STREAM_DESTROYED:$E,ERR_STREAM_PREMATURE_CLOSE:VE},AbortError:HE}=Te(),{validateFunction:GE,validateAbortSignal:WE}=Sn(),{isIterable:Jr,isReadable:jc,isReadableNodeStream:Wo,isNodeStream:yp,isTransformStream:On,isWebStream:JE,isReadableStream:Fc,isReadableFinished:zE}=yt(),YE=globalThis.AbortController||_n().AbortController,$c,Vc,Hc;function wp(t,e,r){let n=!1;t.on("close",()=>{n=!0});let i=Jo(t,{readable:e,writable:r},o=>{n=!o});return{destroy:o=>{n||(n=!0,qE.destroyer(t,o||new $E("pipe")))},cleanup:i}}function ZE(t){return GE(t[t.length-1],"streams[stream.length - 1]"),t.pop()}function Gc(t){if(Jr(t))return t;if(Wo(t))return XE(t);throw new Jc("val",["Readable","Iterable","AsyncIterable"],t)}async function*XE(t){Vc||(Vc=Ai()),yield*Vc.prototype[NE].call(t)}async function Go(t,e,r,{end:n}){let i,o=null,s=f=>{if(f&&(i=f),o){let u=o;o=null,u()}},a=()=>new KE((f,u)=>{i?u(i):o=()=>{i?u(i):f()}});e.on("drain",s);let c=Jo(e,{readable:!1},s);try{e.writableNeedDrain&&await a();for await(let f of t)e.write(f)||await a();n&&(e.end(),await a()),r()}catch(f){r(i!==f?jE(i,f):f)}finally{c(),e.off("drain",s)}}async function Wc(t,e,r,{end:n}){On(e)&&(e=e.writable);let i=e.getWriter();try{for await(let o of t)await i.ready,i.write(o).catch(()=>{});await i.ready,n&&await i.close(),r()}catch(o){try{await i.abort(o),r(o)}catch(s){r(s)}}}function QE(...t){return mp(t,ME(ZE(t)))}function mp(t,e,r){if(t.length===1&&OE(t[0])&&(t=t[0]),t.length<2)throw new FE("streams");let n=new YE,i=n.signal,o=r?.signal,s=[];WE(o,"options.signal");function a(){y(new HE)}Hc=Hc||Se().addAbortListener;let c;o&&(c=Hc(o,a));let f,u,l=[],p=0;function h(g){y(g,--p===0)}function y(g,_){var E;if(g&&(!f||f.code==="ERR_STREAM_PREMATURE_CLOSE")&&(f=g),!(!f&&!_)){for(;l.length;)l.shift()(f);(E=c)===null||E===void 0||E[DE](),n.abort(),_&&(f||s.forEach(B=>B()),ki.nextTick(e,f,u))}}let d;for(let g=0;g<t.length;g++){let _=t[g],E=g<t.length-1,B=g>0,T=E||r?.end!==!1,k=g===t.length-1;if(yp(_)){let R=function(C){C&&C.name!=="AbortError"&&C.code!=="ERR_STREAM_PREMATURE_CLOSE"&&h(C)};var A=R;if(T){let{destroy:C,cleanup:L}=wp(_,E,B);l.push(C),jc(_)&&k&&s.push(L)}_.on("error",R),jc(_)&&k&&s.push(()=>{_.removeListener("error",R)})}if(g===0)if(typeof _=="function"){if(d=_({signal:i}),!Jr(d))throw new qc("Iterable, AsyncIterable or Stream","source",d)}else Jr(_)||Wo(_)||On(_)?d=_:d=pp.from(_);else if(typeof _=="function"){if(On(d)){var w;d=Gc((w=d)===null||w===void 0?void 0:w.readable)}else d=Gc(d);if(d=_(d,{signal:i}),E){if(!Jr(d,!0))throw new qc("AsyncIterable",`transform[${g-1}]`,d)}else{var m;$c||($c=Mc());let R=new $c({objectMode:!0}),C=(m=d)===null||m===void 0?void 0:m.then;if(typeof C=="function")p++,C.call(d,K=>{u=K,K!=null&&R.write(K),T&&R.end(),ki.nextTick(h)},K=>{R.destroy(K),ki.nextTick(h,K)});else if(Jr(d,!0))p++,Go(d,R,h,{end:T});else if(Fc(d)||On(d)){let K=d.readable||d;p++,Go(K,R,h,{end:T})}else throw new qc("AsyncIterable or Promise","destination",d);d=R;let{destroy:L,cleanup:j}=wp(d,!1,!0);l.push(L),k&&s.push(j)}}else if(yp(_)){if(Wo(d)){p+=2;let R=e1(d,_,h,{end:T});jc(_)&&k&&s.push(R)}else if(On(d)||Fc(d)){let R=d.readable||d;p++,Go(R,_,h,{end:T})}else if(Jr(d))p++,Go(d,_,h,{end:T});else throw new Jc("val",["Readable","Iterable","AsyncIterable","ReadableStream","TransformStream"],d);d=_}else if(JE(_)){if(Wo(d))p++,Wc(Gc(d),_,h,{end:T});else if(Fc(d)||Jr(d))p++,Wc(d,_,h,{end:T});else if(On(d))p++,Wc(d.readable,_,h,{end:T});else throw new Jc("val",["Readable","Iterable","AsyncIterable","ReadableStream","TransformStream"],d);d=_}else d=pp.from(_)}return(i!=null&&i.aborted||o!=null&&o.aborted)&&ki.nextTick(a),d}function e1(t,e,r,{end:n}){let i=!1;if(e.on("close",()=>{i||r(new VE)}),t.pipe(e,{end:!1}),n){let s=function(){i=!0,e.end()};var o=s;zE(t)?ki.nextTick(s):t.once("end",s)}else r();return Jo(t,{readable:!0,writable:!1},s=>{let a=t._readableState;s&&s.code==="ERR_STREAM_PREMATURE_CLOSE"&&a&&a.ended&&!a.errored&&!a.errorEmitted?t.once("end",r).once("error",r):r(s)}),Jo(e,{readable:!1,writable:!0},r)}bp.exports={pipelineImpl:mp,pipeline:QE}});var Yc=M((LS,Sp)=>{"use strict";var{pipeline:t1}=zo(),Yo=bt(),{destroyer:r1}=Vr(),{isNodeStream:Zo,isReadable:gp,isWritable:xp,isWebStream:zc,isTransformStream:zr,isWritableStream:Ep,isReadableStream:_p}=yt(),{AbortError:n1,codes:{ERR_INVALID_ARG_VALUE:Ap,ERR_MISSING_ARGS:i1}}=Te(),o1=Kt();Sp.exports=function(...e){if(e.length===0)throw new i1("streams");if(e.length===1)return Yo.from(e[0]);let r=[...e];if(typeof e[0]=="function"&&(e[0]=Yo.from(e[0])),typeof e[e.length-1]=="function"){let h=e.length-1;e[h]=Yo.from(e[h])}for(let h=0;h<e.length;++h)if(!(!Zo(e[h])&&!zc(e[h]))){if(h<e.length-1&&!(gp(e[h])||_p(e[h])||zr(e[h])))throw new Ap(`streams[${h}]`,r[h],"must be readable");if(h>0&&!(xp(e[h])||Ep(e[h])||zr(e[h])))throw new Ap(`streams[${h}]`,r[h],"must be writable")}let n,i,o,s,a;function c(h){let y=s;s=null,y?y(h):h?a.destroy(h):!p&&!l&&a.destroy()}let f=e[0],u=t1(e,c),l=!!(xp(f)||Ep(f)||zr(f)),p=!!(gp(u)||_p(u)||zr(u));if(a=new Yo({writableObjectMode:!!(f!=null&&f.writableObjectMode),readableObjectMode:!!(u!=null&&u.readableObjectMode),writable:l,readable:p}),l){if(Zo(f))a._write=function(y,d,w){f.write(y,d)?w():n=w},a._final=function(y){f.end(),i=y},f.on("drain",function(){if(n){let y=n;n=null,y()}});else if(zc(f)){let d=(zr(f)?f.writable:f).getWriter();a._write=async function(w,m,A){try{await d.ready,d.write(w).catch(()=>{}),A()}catch(g){A(g)}},a._final=async function(w){try{await d.ready,d.close().catch(()=>{}),i=w}catch(m){w(m)}}}let h=zr(u)?u.readable:u;o1(h,()=>{if(i){let y=i;i=null,y()}})}if(p){if(Zo(u))u.on("readable",function(){if(o){let h=o;o=null,h()}}),u.on("end",function(){a.push(null)}),a._read=function(){for(;;){let h=u.read();if(h===null){o=a._read;return}if(!a.push(h))return}};else if(zc(u)){let y=(zr(u)?u.readable:u).getReader();a._read=async function(){for(;;)try{let{value:d,done:w}=await y.read();if(!a.push(d))return;if(w){a.push(null);return}}catch{return}}}}return a._destroy=function(h,y){!h&&s!==null&&(h=new n1),o=null,n=null,i=null,s===null?y(h):(s=y,Zo(u)&&r1(u,h))},a}});var Lp=M((OS,Qc)=>{"use strict";var s1=globalThis.AbortController||_n().AbortController,{codes:{ERR_INVALID_ARG_VALUE:a1,ERR_INVALID_ARG_TYPE:Pi,ERR_MISSING_ARGS:c1,ERR_OUT_OF_RANGE:f1},AbortError:gt}=Te(),{validateAbortSignal:Yr,validateInteger:vp,validateObject:Zr}=Sn(),u1=ce().Symbol("kWeak"),l1=ce().Symbol("kResistStopPropagation"),{finished:d1}=Kt(),h1=Yc(),{addAbortSignalNoValidate:p1}=gi(),{isWritable:y1,isNodeStream:w1}=yt(),{deprecate:m1}=Se(),{ArrayPrototypePush:b1,Boolean:g1,MathFloor:Bp,Number:x1,NumberIsNaN:E1,Promise:Tp,PromiseReject:kp,PromiseResolve:_1,PromisePrototypeThen:Pp,Symbol:Rp}=ce(),Xo=Rp("kEmpty"),Ip=Rp("kEof");function A1(t,e){if(e!=null&&Zr(e,"options"),e?.signal!=null&&Yr(e.signal,"options.signal"),w1(t)&&!y1(t))throw new a1("stream",t,"must be writable");let r=h1(this,t);return e!=null&&e.signal&&p1(e.signal,r),r}function Qo(t,e){if(typeof t!="function")throw new Pi("fn",["Function","AsyncFunction"],t);e!=null&&Zr(e,"options"),e?.signal!=null&&Yr(e.signal,"options.signal");let r=1;e?.concurrency!=null&&(r=Bp(e.concurrency));let n=r-1;return e?.highWaterMark!=null&&(n=Bp(e.highWaterMark)),vp(r,"options.concurrency",1),vp(n,"options.highWaterMark",0),n+=r,(async function*(){let o=Se().AbortSignalAny([e?.signal].filter(g1)),s=this,a=[],c={signal:o},f,u,l=!1,p=0;function h(){l=!0,y()}function y(){p-=1,d()}function d(){u&&!l&&p<r&&a.length<n&&(u(),u=null)}async function w(){try{for await(let m of s){if(l)return;if(o.aborted)throw new gt;try{if(m=t(m,c),m===Xo)continue;m=_1(m)}catch(A){m=kp(A)}p+=1,Pp(m,y,h),a.push(m),f&&(f(),f=null),!l&&(a.length>=n||p>=r)&&await new Tp(A=>{u=A})}a.push(Ip)}catch(m){let A=kp(m);Pp(A,y,h),a.push(A)}finally{l=!0,f&&(f(),f=null)}}w();try{for(;;){for(;a.length>0;){let m=await a[0];if(m===Ip)return;if(o.aborted)throw new gt;m!==Xo&&(yield m),a.shift(),d()}await new Tp(m=>{f=m})}}finally{l=!0,u&&(u(),u=null)}}).call(this)}function S1(t=void 0){return t!=null&&Zr(t,"options"),t?.signal!=null&&Yr(t.signal,"options.signal"),(async function*(){let r=0;for await(let i of this){var n;if(t!=null&&(n=t.signal)!==null&&n!==void 0&&n.aborted)throw new gt({cause:t.signal.reason});yield[r++,i]}}).call(this)}async function Up(t,e=void 0){for await(let r of Xc.call(this,t,e))return!0;return!1}async function v1(t,e=void 0){if(typeof t!="function")throw new Pi("fn",["Function","AsyncFunction"],t);return!await Up.call(this,async(...r)=>!await t(...r),e)}async function B1(t,e){for await(let r of Xc.call(this,t,e))return r}async function T1(t,e){if(typeof t!="function")throw new Pi("fn",["Function","AsyncFunction"],t);async function r(n,i){return await t(n,i),Xo}for await(let n of Qo.call(this,r,e));}function Xc(t,e){if(typeof t!="function")throw new Pi("fn",["Function","AsyncFunction"],t);async function r(n,i){return await t(n,i)?n:Xo}return Qo.call(this,r,e)}var Zc=class extends c1{constructor(){super("reduce"),this.message="Reduce of an empty stream requires an initial value"}};async function k1(t,e,r){var n;if(typeof t!="function")throw new Pi("reducer",["Function","AsyncFunction"],t);r!=null&&Zr(r,"options"),r?.signal!=null&&Yr(r.signal,"options.signal");let i=arguments.length>1;if(r!=null&&(n=r.signal)!==null&&n!==void 0&&n.aborted){let f=new gt(void 0,{cause:r.signal.reason});throw this.once("error",()=>{}),await d1(this.destroy(f)),f}let o=new s1,s=o.signal;if(r!=null&&r.signal){let f={once:!0,[u1]:this,[l1]:!0};r.signal.addEventListener("abort",()=>o.abort(),f)}let a=!1;try{for await(let f of this){var c;if(a=!0,r!=null&&(c=r.signal)!==null&&c!==void 0&&c.aborted)throw new gt;i?e=await t(e,f,{signal:s}):(e=f,i=!0)}if(!a&&!i)throw new Zc}finally{o.abort()}return e}async function P1(t){t!=null&&Zr(t,"options"),t?.signal!=null&&Yr(t.signal,"options.signal");let e=[];for await(let n of this){var r;if(t!=null&&(r=t.signal)!==null&&r!==void 0&&r.aborted)throw new gt(void 0,{cause:t.signal.reason});b1(e,n)}return e}function I1(t,e){let r=Qo.call(this,t,e);return(async function*(){for await(let i of r)yield*i}).call(this)}function Cp(t){if(t=x1(t),E1(t))return 0;if(t<0)throw new f1("number",">= 0",t);return t}function R1(t,e=void 0){return e!=null&&Zr(e,"options"),e?.signal!=null&&Yr(e.signal,"options.signal"),t=Cp(t),(async function*(){var n;if(e!=null&&(n=e.signal)!==null&&n!==void 0&&n.aborted)throw new gt;for await(let o of this){var i;if(e!=null&&(i=e.signal)!==null&&i!==void 0&&i.aborted)throw new gt;t--<=0&&(yield o)}}).call(this)}function U1(t,e=void 0){return e!=null&&Zr(e,"options"),e?.signal!=null&&Yr(e.signal,"options.signal"),t=Cp(t),(async function*(){var n;if(e!=null&&(n=e.signal)!==null&&n!==void 0&&n.aborted)throw new gt;for await(let o of this){var i;if(e!=null&&(i=e.signal)!==null&&i!==void 0&&i.aborted)throw new gt;if(t-- >0&&(yield o),t<=0)return}}).call(this)}Qc.exports.streamReturningOperators={asIndexedPairs:m1(S1,"readable.asIndexedPairs will be removed in a future version."),drop:R1,filter:Xc,flatMap:I1,map:Qo,take:U1,compose:A1};Qc.exports.promiseReturningOperators={every:v1,forEach:T1,reduce:k1,toArray:P1,some:Up,find:B1}});var ef=M((KS,Op)=>{"use strict";var{ArrayPrototypePop:C1,Promise:L1}=ce(),{isIterable:O1,isNodeStream:K1,isWebStream:N1}=yt(),{pipelineImpl:D1}=zo(),{finished:M1}=Kt();tf();function q1(...t){return new L1((e,r)=>{let n,i,o=t[t.length-1];if(o&&typeof o=="object"&&!K1(o)&&!O1(o)&&!N1(o)){let s=C1(t);n=s.signal,i=s.end}D1(t,(s,a)=>{s?r(s):e(a)},{signal:n,end:i})})}Op.exports={finished:M1,pipeline:q1}});var tf=M((NS,Vp)=>{var{Buffer:j1}=qe(),{ObjectDefineProperty:Mt,ObjectKeys:Dp,ReflectApply:Mp}=ce(),{promisify:{custom:qp}}=Se(),{streamReturningOperators:Kp,promiseReturningOperators:Np}=Lp(),{codes:{ERR_ILLEGAL_CONSTRUCTOR:jp}}=Te(),F1=Yc(),{setDefaultHighWaterMark:$1,getDefaultHighWaterMark:V1}=xi(),{pipeline:Fp}=zo(),{destroyer:H1}=Vr(),$p=Kt(),rf=ef(),Ii=yt(),ie=Vp.exports=Uo().Stream;ie.isDestroyed=Ii.isDestroyed;ie.isDisturbed=Ii.isDisturbed;ie.isErrored=Ii.isErrored;ie.isReadable=Ii.isReadable;ie.isWritable=Ii.isWritable;ie.Readable=Ai();for(let t of Dp(Kp)){let r=function(...n){if(new.target)throw jp();return ie.Readable.from(Mp(e,this,n))};nf=r;let e=Kp[t];Mt(r,"name",{__proto__:null,value:e.name}),Mt(r,"length",{__proto__:null,value:e.length}),Mt(ie.Readable.prototype,t,{__proto__:null,value:r,enumerable:!1,configurable:!0,writable:!0})}var nf;for(let t of Dp(Np)){let r=function(...i){if(new.target)throw jp();return Mp(e,this,i)};nf=r;let e=Np[t];Mt(r,"name",{__proto__:null,value:e.name}),Mt(r,"length",{__proto__:null,value:e.length}),Mt(ie.Readable.prototype,t,{__proto__:null,value:r,enumerable:!1,configurable:!0,writable:!0})}var nf;ie.Writable=Ho();ie.Duplex=bt();ie.Transform=Nc();ie.PassThrough=Mc();ie.pipeline=Fp;var{addAbortSignal:G1}=gi();ie.addAbortSignal=G1;ie.finished=$p;ie.destroy=H1;ie.compose=F1;ie.setDefaultHighWaterMark=$1;ie.getDefaultHighWaterMark=V1;Mt(ie,"promises",{__proto__:null,configurable:!0,enumerable:!0,get(){return rf}});Mt(Fp,qp,{__proto__:null,enumerable:!0,get(){return rf.pipeline}});Mt($p,qp,{__proto__:null,enumerable:!0,get(){return rf.finished}});ie.Stream=ie;ie._isUint8Array=function(e){return e instanceof Uint8Array};ie._uint8ArrayToBuffer=function(e){return j1.from(e.buffer,e.byteOffset,e.byteLength)}});var of=M((DS,le)=>{"use strict";var pe=tf(),W1=ef(),J1=pe.Readable.destroy;le.exports=pe.Readable;le.exports._uint8ArrayToBuffer=pe._uint8ArrayToBuffer;le.exports._isUint8Array=pe._isUint8Array;le.exports.isDisturbed=pe.isDisturbed;le.exports.isErrored=pe.isErrored;le.exports.isReadable=pe.isReadable;le.exports.Readable=pe.Readable;le.exports.Writable=pe.Writable;le.exports.Duplex=pe.Duplex;le.exports.Transform=pe.Transform;le.exports.PassThrough=pe.PassThrough;le.exports.addAbortSignal=pe.addAbortSignal;le.exports.finished=pe.finished;le.exports.destroy=pe.destroy;le.exports.destroy=J1;le.exports.pipeline=pe.pipeline;le.exports.compose=pe.compose;Object.defineProperty(pe,"promises",{configurable:!0,enumerable:!0,get(){return W1}});le.exports.Stream=pe.Stream;le.exports.default=le.exports});var y0=ji(Xf(),1);var C_=new Uint8Array(0);function Qf(t,e){if(t===e)return!0;if(t.byteLength!==e.byteLength)return!1;for(let r=0;r<t.byteLength;r++)if(t[r]!==e[r])return!1;return!0}function rn(t){if(t instanceof Uint8Array&&t.constructor.name==="Uint8Array")return t;if(t instanceof ArrayBuffer)return new Uint8Array(t);if(ArrayBuffer.isView(t))return new Uint8Array(t.buffer,t.byteOffset,t.byteLength);throw new Error("Unknown type, must be binary type")}function m0(t,e){if(t.length>=255)throw new TypeError("Alphabet too long");for(var r=new Uint8Array(256),n=0;n<r.length;n++)r[n]=255;for(var i=0;i<t.length;i++){var o=t.charAt(i),s=o.charCodeAt(0);if(r[s]!==255)throw new TypeError(o+" is ambiguous");r[s]=i}var a=t.length,c=t.charAt(0),f=Math.log(a)/Math.log(256),u=Math.log(256)/Math.log(a);function l(y){if(y instanceof Uint8Array||(ArrayBuffer.isView(y)?y=new Uint8Array(y.buffer,y.byteOffset,y.byteLength):Array.isArray(y)&&(y=Uint8Array.from(y))),!(y instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(y.length===0)return"";for(var d=0,w=0,m=0,A=y.length;m!==A&&y[m]===0;)m++,d++;for(var g=(A-m)*u+1>>>0,_=new Uint8Array(g);m!==A;){for(var E=y[m],B=0,T=g-1;(E!==0||B<w)&&T!==-1;T--,B++)E+=256*_[T]>>>0,_[T]=E%a>>>0,E=E/a>>>0;if(E!==0)throw new Error("Non-zero carry");w=B,m++}for(var k=g-w;k!==g&&_[k]===0;)k++;for(var R=c.repeat(d);k<g;++k)R+=t.charAt(_[k]);return R}function p(y){if(typeof y!="string")throw new TypeError("Expected String");if(y.length===0)return new Uint8Array;var d=0;if(y[d]!==" "){for(var w=0,m=0;y[d]===c;)w++,d++;for(var A=(y.length-d)*f+1>>>0,g=new Uint8Array(A);y[d];){var _=r[y.charCodeAt(d)];if(_===255)return;for(var E=0,B=A-1;(_!==0||E<m)&&B!==-1;B--,E++)_+=a*g[B]>>>0,g[B]=_%256>>>0,_=_/256>>>0;if(_!==0)throw new Error("Non-zero carry");m=E,d++}if(y[d]!==" "){for(var T=A-m;T!==A&&g[T]===0;)T++;for(var k=new Uint8Array(w+(A-T)),R=w;T!==A;)k[R++]=g[T++];return k}}}function h(y){var d=p(y);if(d)return d;throw new Error(`Non-${e} character`)}return{encode:l,decodeUnsafe:p,decode:h}}var b0=m0,g0=b0,eu=g0;var Rs=class{name;prefix;baseEncode;constructor(e,r,n){this.name=e,this.prefix=r,this.baseEncode=n}encode(e){if(e instanceof Uint8Array)return`${this.prefix}${this.baseEncode(e)}`;throw Error("Unknown type, must be binary type")}},Us=class{name;prefix;baseDecode;prefixCodePoint;constructor(e,r,n){if(this.name=e,this.prefix=r,r.codePointAt(0)===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=r.codePointAt(0),this.baseDecode=n}decode(e){if(typeof e=="string"){if(e.codePointAt(0)!==this.prefixCodePoint)throw Error(`Unable to decode multibase string ${JSON.stringify(e)}, ${this.name} decoder only supports inputs prefixed with ${this.prefix}`);return this.baseDecode(e.slice(this.prefix.length))}else throw Error("Can only multibase decode strings")}or(e){return tu(this,e)}},Cs=class{decoders;constructor(e){this.decoders=e}or(e){return tu(this,e)}decode(e){let r=e[0],n=this.decoders[r];if(n!=null)return n.decode(e);throw RangeError(`Unable to decode multibase string ${JSON.stringify(e)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}};function tu(t,e){return new Cs({...t.decoders??{[t.prefix]:t},...e.decoders??{[e.prefix]:e}})}var Ls=class{name;prefix;baseEncode;baseDecode;encoder;decoder;constructor(e,r,n,i){this.name=e,this.prefix=r,this.baseEncode=n,this.baseDecode=i,this.encoder=new Rs(e,r,n),this.decoder=new Us(e,r,i)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}};function ru({name:t,prefix:e,encode:r,decode:n}){return new Ls(t,e,r,n)}function Os({name:t,prefix:e,alphabet:r}){let{encode:n,decode:i}=eu(r,t);return ru({prefix:e,name:t,encode:n,decode:o=>rn(i(o))})}function x0(t,e,r,n){let i={};for(let u=0;u<e.length;++u)i[e[u]]=u;let o=t.length;for(;t[o-1]==="=";)--o;let s=new Uint8Array(o*r/8|0),a=0,c=0,f=0;for(let u=0;u<o;++u){let l=i[t[u]];if(l===void 0)throw new SyntaxError(`Non-${n} character`);c=c<<r|l,a+=r,a>=8&&(a-=8,s[f++]=255&c>>a)}if(a>=r||255&c<<8-a)throw new SyntaxError("Unexpected end of data");return s}function E0(t,e,r){let n=e[e.length-1]==="=",i=(1<<r)-1,o="",s=0,a=0;for(let c=0;c<t.length;++c)for(a=a<<8|t[c],s+=8;s>r;)s-=r,o+=e[i&a>>s];if(s!==0&&(o+=e[i&a<<r-s]),n)for(;o.length*r&7;)o+="=";return o}function Be({name:t,prefix:e,bitsPerChar:r,alphabet:n}){return ru({prefix:e,name:t,encode(i){return E0(i,n,r)},decode(i){return x0(i,n,r,t)}})}var Gn=Be({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),M_=Be({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),q_=Be({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),j_=Be({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),F_=Be({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),$_=Be({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),V_=Be({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),H_=Be({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),Ks=Be({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var Pe=Os({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),J_=Os({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var Z_=Be({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),X_=Be({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),ot=Be({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),Q_=Be({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});function nu(t){return t.byteOffset!==0||t.byteLength!==t.buffer.byteLength}function iu(t){return typeof t!="object"||t===null?!1:typeof t[Symbol.asyncIterator]=="function"}function Wn(t){let r=Object.prototype.toString.call(t).match(/\s([a-zA-Z0-9]+)/),[n,i]=r;return i}var Jn=function(t,e,r,n){function i(o){return o instanceof r?o:new r(function(s){s(o)})}return new(r||(r=Promise))(function(o,s){function a(u){try{f(n.next(u))}catch(l){s(l)}}function c(u){try{f(n.throw(u))}catch(l){s(l)}}function f(u){u.done?o(u.value):i(u.value).then(a,c)}f((n=n.apply(t,e||[])).next())})},ou=function(t){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var e=t[Symbol.asyncIterator],r;return e?e.call(t):(t=typeof __values=="function"?__values(t):t[Symbol.iterator](),r={},n("next"),n("throw"),n("return"),r[Symbol.asyncIterator]=function(){return this},r);function n(o){r[o]=t[o]&&function(s){return new Promise(function(a,c){s=t[o](s),i(a,c,s.done,s.value)})}}function i(o,s,a,c){Promise.resolve(c).then(function(f){o({value:f,done:a})},s)}},$i=new TextEncoder,xr=new TextDecoder,q=class t{constructor(e,r){this.data=e,this.format=r}static arrayBuffer(e){return new t(e,"ArrayBuffer")}static asyncIterable(e){if(!iu(e))throw new TypeError("Input must be of type AsyncIterable.");return new t(e,"AsyncIterable")}static base32Z(e){return new t(e,"Base32Z")}static base58Btc(e){return new t(e,"Base58Btc")}static base64Url(e){return new t(e,"Base64Url")}static bufferSource(e){return new t(e,"BufferSource")}static hex(e){if(typeof e!="string")throw new TypeError("Hex input must be a string.");if(e.length%2!==0)throw new TypeError("Hex input must have an even number of characters.");return new t(e,"Hex")}static multibase(e){return new t(e,"Multibase")}static object(e){return new t(e,"Object")}static string(e){return new t(e,"String")}static uint8Array(e){return new t(e,"Uint8Array")}toArrayBuffer(){switch(this.format){case"Base58Btc":return Pe.baseDecode(this.data).buffer;case"Base64Url":return ot.baseDecode(this.data).buffer;case"BufferSource":{if(Wn(this.data)==="ArrayBuffer")return this.data;if(ArrayBuffer.isView(this.data))return nu(this.data)?this.data.buffer.slice(this.data.byteOffset,this.data.byteOffset+this.data.byteLength):this.data.buffer;throw new TypeError(`${this.format} value is not of type: ArrayBuffer, DataView, or TypedArray.`)}case"Hex":return this.toUint8Array().buffer;case"String":return this.toUint8Array().buffer;case"Uint8Array":return this.data.buffer;default:throw new TypeError(`Conversion from ${this.format} to ArrayBuffer is not supported.`)}}toArrayBufferAsync(){return Jn(this,void 0,void 0,function*(){switch(this.format){case"AsyncIterable":return yield(yield this.toBlobAsync()).arrayBuffer();default:throw new TypeError(`Asynchronous conversion from ${this.format} to ArrayBuffer is not supported.`)}})}toBase32Z(){switch(this.format){case"Uint8Array":return Ks.baseEncode(this.data);default:throw new TypeError(`Conversion from ${this.format} to Base64Z is not supported.`)}}toBase58Btc(){switch(this.format){case"ArrayBuffer":{let e=new Uint8Array(this.data);return Pe.baseEncode(e)}case"Multibase":return this.data.substring(1);case"Uint8Array":return Pe.baseEncode(this.data);default:throw new TypeError(`Conversion from ${this.format} to Base58Btc is not supported.`)}}toBase64Url(){switch(this.format){case"ArrayBuffer":{let e=new Uint8Array(this.data);return ot.baseEncode(e)}case"BufferSource":{let e=this.toUint8Array();return ot.baseEncode(e)}case"Object":{let e=JSON.stringify(this.data),r=$i.encode(e);return ot.baseEncode(r)}case"String":{let e=$i.encode(this.data);return ot.baseEncode(e)}case"Uint8Array":return ot.baseEncode(this.data);default:throw new TypeError(`Conversion from ${this.format} to Base64Url is not supported.`)}}toBlobAsync(){return Jn(this,void 0,void 0,function*(){var e,r,n,i;switch(this.format){case"AsyncIterable":{let c=[];try{for(var o=!0,s=ou(this.data),a;a=yield s.next(),e=a.done,!e;o=!0){i=a.value,o=!1;let u=i;c.push(u)}}catch(u){r={error:u}}finally{try{!o&&!e&&(n=s.return)&&(yield n.call(s))}finally{if(r)throw r.error}}return new Blob(c)}default:throw new TypeError(`Asynchronous conversion from ${this.format} to Blob is not supported.`)}})}toHex(){let e=Array.from({length:256},(r,n)=>n.toString(16).padStart(2,"0"));switch(this.format){case"ArrayBuffer":{let r=this.toUint8Array();return t.uint8Array(r).toHex()}case"Base64Url":{let r=this.toUint8Array();return t.uint8Array(r).toHex()}case"Uint8Array":{let r="";for(let n=0;n<this.data.length;n++)r+=e[this.data[n]];return r}default:throw new TypeError(`Conversion from ${this.format} to Hex is not supported.`)}}toMultibase(){switch(this.format){case"Base58Btc":return`z${this.data}`;default:throw new TypeError(`Conversion from ${this.format} to Multibase is not supported.`)}}toObject(){switch(this.format){case"Base64Url":{let e=ot.baseDecode(this.data),r=xr.decode(e);return JSON.parse(r)}case"String":return JSON.parse(this.data);case"Uint8Array":{let e=xr.decode(this.data);return JSON.parse(e)}default:throw new TypeError(`Conversion from ${this.format} to Object is not supported.`)}}toObjectAsync(){return Jn(this,void 0,void 0,function*(){switch(this.format){case"AsyncIterable":{let e=yield this.toStringAsync();return JSON.parse(e)}default:throw new TypeError(`Asynchronous conversion from ${this.format} to Object is not supported.`)}})}toString(){switch(this.format){case"ArrayBuffer":return xr.decode(this.data);case"Base64Url":{let e=ot.baseDecode(this.data);return xr.decode(e)}case"Object":return JSON.stringify(this.data);case"Uint8Array":return xr.decode(this.data);default:throw new TypeError(`Conversion from ${this.format} to String is not supported.`)}}toStringAsync(){return Jn(this,void 0,void 0,function*(){var e,r,n,i;switch(this.format){case"AsyncIterable":{let c="";try{for(var o=!0,s=ou(this.data),a;a=yield s.next(),e=a.done,!e;o=!0){i=a.value,o=!1;let f=i;typeof f=="string"?c+=f:c+=xr.decode(f,{stream:!0})}}catch(f){r={error:f}}finally{try{!o&&!e&&(n=s.return)&&(yield n.call(s))}finally{if(r)throw r.error}}return c+=xr.decode(void 0,{stream:!1}),c}default:throw new TypeError(`Asynchronous conversion from ${this.format} to String is not supported.`)}})}toUint8Array(){switch(this.format){case"ArrayBuffer":return new Uint8Array(this.data);case"Base32Z":return Ks.baseDecode(this.data);case"Base58Btc":return Pe.baseDecode(this.data);case"Base64Url":return ot.baseDecode(this.data);case"BufferSource":{let e=Wn(this.data);if(e==="Uint8Array")return this.data;if(e==="ArrayBuffer")return new Uint8Array(this.data);if(ArrayBuffer.isView(this.data))return new Uint8Array(this.data.buffer,this.data.byteOffset,this.data.byteLength);throw new TypeError(`${this.format} value is not of type: ArrayBuffer, DataView, or TypedArray.`)}case"Hex":{let e=new Uint8Array(this.data.length/2);for(let r=0;r<this.data.length;r+=2){let n=parseInt(this.data.substring(r,r+2),16);if(isNaN(n))throw new TypeError("Input is not a valid hexadecimal string.");e[r/2]=n}return e}case"Object":{let e=JSON.stringify(this.data);return $i.encode(e)}case"String":return $i.encode(this.data);default:throw new TypeError(`Conversion from ${this.format} to Uint8Array is not supported.`)}}toUint8ArrayAsync(){return Jn(this,void 0,void 0,function*(){switch(this.format){case"AsyncIterable":{let e=yield this.toArrayBufferAsync();return new Uint8Array(e)}default:throw new TypeError(`Asynchronous conversion from ${this.format} to Uint8Array is not supported.`)}})}};var zn;(function(t){t.Debug="debug",t.Silent="silent"})(zn||(zn={}));var Ns=class{constructor(){this.logLevel=zn.Silent}setLogLevel(e){this.logLevel=e}log(e){this.info(e)}info(e){this.logLevel!==zn.Silent&&console.info(e)}error(e){this.logLevel!==zn.Silent&&console.error(e)}},_0=new Ns;typeof window<"u"&&(window.web5logger=_0);var vt={};Yf(vt,{decode:()=>nn,encodeTo:()=>Er,encodingLength:()=>_r});var A0=cu,su=128,S0=127,v0=~S0,B0=Math.pow(2,31);function cu(t,e,r){e=e||[],r=r||0;for(var n=r;t>=B0;)e[r++]=t&255|su,t/=128;for(;t&v0;)e[r++]=t&255|su,t>>>=7;return e[r]=t|0,cu.bytes=r-n+1,e}var T0=Ds,k0=128,au=127;function Ds(t,n){var r=0,n=n||0,i=0,o=n,s,a=t.length;do{if(o>=a)throw Ds.bytes=0,new RangeError("Could not decode varint");s=t[o++],r+=i<28?(s&au)<<i:(s&au)*Math.pow(2,i),i+=7}while(s>=k0);return Ds.bytes=o-n,r}var P0=Math.pow(2,7),I0=Math.pow(2,14),R0=Math.pow(2,21),U0=Math.pow(2,28),C0=Math.pow(2,35),L0=Math.pow(2,42),O0=Math.pow(2,49),K0=Math.pow(2,56),N0=Math.pow(2,63),D0=function(t){return t<P0?1:t<I0?2:t<R0?3:t<U0?4:t<C0?5:t<L0?6:t<O0?7:t<K0?8:t<N0?9:10},M0={encode:A0,decode:T0,encodingLength:D0},q0=M0,Yn=q0;function nn(t,e=0){return[Yn.decode(t,e),Yn.decode.bytes]}function Er(t,e,r=0){return Yn.encode(t,e,r),e}function _r(t){return Yn.encodingLength(t)}function Ms(t,e){let r=e.byteLength,n=_r(t),i=n+_r(r),o=new Uint8Array(i+r);return Er(t,o,0),Er(r,o,n),o.set(e,i),new on(t,r,e,o)}function fu(t){let e=rn(t),[r,n]=nn(e),[i,o]=nn(e.subarray(n)),s=e.subarray(n+o);if(s.byteLength!==i)throw new Error("Incorrect length");return new on(r,i,s,e)}function uu(t,e){if(t===e)return!0;{let r=e;return t.code===r.code&&t.size===r.size&&r.bytes instanceof Uint8Array&&Qf(t.bytes,r.bytes)}}var on=class{code;size;digest;bytes;constructor(e,r,n,i){this.code=e,this.size=r,this.digest=n,this.bytes=i}};function lu(t,e){let{bytes:r,version:n}=t;switch(n){case 0:return F0(r,js(t),e??Pe.encoder);default:return $0(r,js(t),e??Gn.encoder)}}var du=new WeakMap;function js(t){let e=du.get(t);if(e==null){let r=new Map;return du.set(t,r),r}return e}var Fs=class t{code;version;multihash;bytes;"/";constructor(e,r,n,i){this.code=r,this.version=e,this.multihash=n,this.bytes=i,this["/"]=i}get asCID(){return this}get byteOffset(){return this.bytes.byteOffset}get byteLength(){return this.bytes.byteLength}toV0(){switch(this.version){case 0:return this;case 1:{let{code:e,multihash:r}=this;if(e!==Zn)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(r.code!==V0)throw new Error("Cannot convert non sha2-256 multihash CID to CIDv0");return t.createV0(r)}default:throw Error(`Can not convert CID version ${this.version} to version 0. This is a bug please report`)}}toV1(){switch(this.version){case 0:{let{code:e,digest:r}=this.multihash,n=Ms(e,r);return t.createV1(this.code,n)}case 1:return this;default:throw Error(`Can not convert CID version ${this.version} to version 1. This is a bug please report`)}}equals(e){return t.equals(this,e)}static equals(e,r){let n=r;return n!=null&&e.code===n.code&&e.version===n.version&&uu(e.multihash,n.multihash)}toString(e){return lu(this,e)}toJSON(){return{"/":lu(this)}}link(){return this}[Symbol.toStringTag]="CID";[Symbol.for("nodejs.util.inspect.custom")](){return`CID(${this.toString()})`}static asCID(e){if(e==null)return null;let r=e;if(r instanceof t)return r;if(r["/"]!=null&&r["/"]===r.bytes||r.asCID===r){let{version:n,code:i,multihash:o,bytes:s}=r;return new t(n,i,o,s??hu(n,i,o.bytes))}else if(r[H0]===!0){let{version:n,multihash:i,code:o}=r,s=fu(i);return t.create(n,o,s)}else return null}static create(e,r,n){if(typeof r!="number")throw new Error("String codecs are no longer supported");if(!(n.bytes instanceof Uint8Array))throw new Error("Invalid digest");switch(e){case 0:{if(r!==Zn)throw new Error(`Version 0 CID must use dag-pb (code: ${Zn}) block encoding`);return new t(e,r,n,n.bytes)}case 1:{let i=hu(e,r,n.bytes);return new t(e,r,n,i)}default:throw new Error("Invalid version")}}static createV0(e){return t.create(0,Zn,e)}static createV1(e,r){return t.create(1,e,r)}static decode(e){let[r,n]=t.decodeFirst(e);if(n.length!==0)throw new Error("Incorrect length");return r}static decodeFirst(e){let r=t.inspectBytes(e),n=r.size-r.multihashSize,i=rn(e.subarray(n,n+r.multihashSize));if(i.byteLength!==r.multihashSize)throw new Error("Incorrect length");let o=i.subarray(r.multihashSize-r.digestSize),s=new on(r.multihashCode,r.digestSize,o,i);return[r.version===0?t.createV0(s):t.createV1(r.codec,s),e.subarray(r.size)]}static inspectBytes(e){let r=0,n=()=>{let[l,p]=nn(e.subarray(r));return r+=p,l},i=n(),o=Zn;if(i===18?(i=0,r=0):o=n(),i!==0&&i!==1)throw new RangeError(`Invalid CID version ${i}`);let s=r,a=n(),c=n(),f=r+c,u=f-s;return{version:i,codec:o,multihashCode:a,digestSize:c,multihashSize:u,size:f}}static parse(e,r){let[n,i]=j0(e,r),o=t.decode(i);if(o.version===0&&e[0]!=="Q")throw Error("Version 0 CID string must not include multibase prefix");return js(o).set(n,e),o}};function j0(t,e){switch(t[0]){case"Q":{let r=e??Pe;return[Pe.prefix,r.decode(`${Pe.prefix}${t}`)]}case Pe.prefix:{let r=e??Pe;return[Pe.prefix,r.decode(t)]}case Gn.prefix:{let r=e??Gn;return[Gn.prefix,r.decode(t)]}default:{if(e==null)throw Error("To parse non base32 or base58btc encoded CID multibase decoder must be provided");return[t[0],e.decode(t)]}}}function F0(t,e,r){let{prefix:n}=r;if(n!==Pe.prefix)throw Error(`Cannot string encode V0 in ${r.name} encoding`);let i=e.get(n);if(i==null){let o=r.encode(t).slice(1);return e.set(n,o),o}else return i}function $0(t,e,r){let{prefix:n}=r,i=e.get(n);if(i==null){let o=r.encode(t);return e.set(n,o),o}else return i}var Zn=112,V0=18;function hu(t,e,r){let n=_r(t),i=n+_r(e),o=new Uint8Array(i+r.byteLength);return Er(t,o,0),Er(e,o,n),o.set(r,i),o}var H0=Symbol.for("@ipld/js-cid/CID");var st=class t{static addPrefix(e){var r;let{code:n,data:i,name:o}=e;if(!(o?!n:n))throw new Error("Either 'name' or 'code' must be defined, but not both.");if(n=t.codeToName.has(n)?n:t.nameToCode.get(o),n===void 0)throw new Error(`Unsupported multicodec: ${(r=e.name)!==null&&r!==void 0?r:e.code}`);let s=vt.encodingLength(n),a=new Uint8Array(s+i.byteLength);return a.set(i,s),vt.encodeTo(n,a),a}static getCodeFromData(e){let{prefixedData:r}=e,[n,i]=vt.decode(r);return n}static getCodeFromName(e){let{name:r}=e,n=t.nameToCode.get(r);if(n===void 0)throw new Error(`Unsupported multicodec: ${r}`);return n}static getNameFromCode(e){let{code:r}=e,n=t.codeToName.get(r);if(n===void 0)throw new Error(`Unsupported multicodec: ${r}`);return n}static registerCodec(e){t.codeToName.set(e.code,e.name),t.nameToCode.set(e.name,e.code)}static removePrefix(e){let{prefixedData:r}=e,[n,i]=vt.decode(r),o=t.codeToName.get(n);if(o===void 0)throw new Error(`Unsupported multicodec: ${n}`);return{code:n,data:r.slice(i),name:o}}};st.codeToName=new Map;st.nameToCode=new Map;st.registerCodec({code:237,name:"ed25519-pub"});st.registerCodec({code:4864,name:"ed25519-priv"});st.registerCodec({code:236,name:"x25519-pub"});st.registerCodec({code:4866,name:"x25519-priv"});st.registerCodec({code:231,name:"secp256k1-pub"});st.registerCodec({code:4865,name:"secp256k1-priv"});function $s(t){Object.keys(t).forEach(e=>{t[e]===void 0?delete t[e]:typeof t[e]=="object"&&$s(t[e])})}var Im=ji(Gl(),1),Mr=function(t,e,r,n){function i(o){return o instanceof r?o:new r(function(s){s(o)})}return new(r||(r=Promise))(function(o,s){function a(u){try{f(n.next(u))}catch(l){s(l)}}function c(u){try{f(n.throw(u))}catch(l){s(l)}}function f(u){u.done?o(u.value):i(u.value).then(a,c)}f((n=n.apply(t,e||[])).next())})};var Eo=class{constructor(){this.store=new Map}clear(){return Mr(this,void 0,void 0,function*(){this.store.clear()})}close(){return Mr(this,void 0,void 0,function*(){})}delete(e){return Mr(this,void 0,void 0,function*(){return this.store.delete(e)})}get(e){return Mr(this,void 0,void 0,function*(){return this.store.get(e)})}has(e){return Mr(this,void 0,void 0,function*(){return this.store.has(e)})}list(){return Mr(this,void 0,void 0,function*(){return Array.from(this.store.values())})}set(e,r){return Mr(this,void 0,void 0,function*(){this.store.set(e,r)})}};var z1=ji(of(),1);var Y1=ji(of(),1);function Z1(t){return t instanceof Uint8Array||t!=null&&typeof t=="object"&&t.constructor.name==="Uint8Array"}function es(t,...e){if(!Z1(t))throw new Error("Uint8Array expected");if(e.length>0&&!e.includes(t.length))throw new Error(`Uint8Array expected of length ${e}, not of length=${t.length}`)}function sf(t,e=!0){if(t.destroyed)throw new Error("Hash instance has been destroyed");if(e&&t.finished)throw new Error("Hash#digest() has already been called")}function Hp(t,e){es(t);let r=e.outputLen;if(t.length<r)throw new Error(`digestInto() expects output buffer of length at least ${r}`)}var qt=typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0;var rs=t=>new DataView(t.buffer,t.byteOffset,t.byteLength),et=(t,e)=>t<<32-e|t>>>e;var nv=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;function X1(t){if(typeof t!="string")throw new Error(`utf8ToBytes expected string, got ${typeof t}`);return new Uint8Array(new TextEncoder().encode(t))}function af(t){return typeof t=="string"&&(t=X1(t)),es(t),t}function cf(...t){let e=0;for(let n=0;n<t.length;n++){let i=t[n];es(i),e+=i.length}let r=new Uint8Array(e);for(let n=0,i=0;n<t.length;n++){let o=t[n];r.set(o,i),i+=o.length}return r}var ts=class{clone(){return this._cloneInto()}},iv={}.toString;function Gp(t){let e=n=>t().update(af(n)).digest(),r=t();return e.outputLen=r.outputLen,e.blockLen=r.blockLen,e.create=()=>t(),e}function Wp(t=32){if(qt&&typeof qt.getRandomValues=="function")return qt.getRandomValues(new Uint8Array(t));throw new Error("crypto.getRandomValues must be defined")}function Q1(t,e,r,n){if(typeof t.setBigUint64=="function")return t.setBigUint64(e,r,n);let i=BigInt(32),o=BigInt(4294967295),s=Number(r>>i&o),a=Number(r&o),c=n?4:0,f=n?0:4;t.setUint32(e+c,s,n),t.setUint32(e+f,a,n)}var Jp=(t,e,r)=>t&e^~t&r,zp=(t,e,r)=>t&e^t&r^e&r,ns=class extends ts{constructor(e,r,n,i){super(),this.blockLen=e,this.outputLen=r,this.padOffset=n,this.isLE=i,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(e),this.view=rs(this.buffer)}update(e){sf(this);let{view:r,buffer:n,blockLen:i}=this;e=af(e);let o=e.length;for(let s=0;s<o;){let a=Math.min(i-this.pos,o-s);if(a===i){let c=rs(e);for(;i<=o-s;s+=i)this.process(c,s);continue}n.set(e.subarray(s,s+a),this.pos),this.pos+=a,s+=a,this.pos===i&&(this.process(r,0),this.pos=0)}return this.length+=e.length,this.roundClean(),this}digestInto(e){sf(this),Hp(e,this),this.finished=!0;let{buffer:r,view:n,blockLen:i,isLE:o}=this,{pos:s}=this;r[s++]=128,this.buffer.subarray(s).fill(0),this.padOffset>i-s&&(this.process(n,0),s=0);for(let l=s;l<i;l++)r[l]=0;Q1(n,i-8,BigInt(this.length*8),o),this.process(n,0);let a=rs(e),c=this.outputLen;if(c%4)throw new Error("_sha2: outputLen should be aligned to 32bit");let f=c/4,u=this.get();if(f>u.length)throw new Error("_sha2: outputLen bigger than state");for(let l=0;l<f;l++)a.setUint32(4*l,u[l],o)}digest(){let{buffer:e,outputLen:r}=this;this.digestInto(e);let n=e.slice(0,r);return this.destroy(),n}_cloneInto(e){e||(e=new this.constructor),e.set(...this.get());let{blockLen:r,buffer:n,length:i,finished:o,destroyed:s,pos:a}=this;return e.length=i,e.pos=a,e.finished=o,e.destroyed=s,i%r&&e.buffer.set(n),e}};var e2=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),cr=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),fr=new Uint32Array(64),ff=class extends ns{constructor(){super(64,32,8,!1),this.A=cr[0]|0,this.B=cr[1]|0,this.C=cr[2]|0,this.D=cr[3]|0,this.E=cr[4]|0,this.F=cr[5]|0,this.G=cr[6]|0,this.H=cr[7]|0}get(){let{A:e,B:r,C:n,D:i,E:o,F:s,G:a,H:c}=this;return[e,r,n,i,o,s,a,c]}set(e,r,n,i,o,s,a,c){this.A=e|0,this.B=r|0,this.C=n|0,this.D=i|0,this.E=o|0,this.F=s|0,this.G=a|0,this.H=c|0}process(e,r){for(let l=0;l<16;l++,r+=4)fr[l]=e.getUint32(r,!1);for(let l=16;l<64;l++){let p=fr[l-15],h=fr[l-2],y=et(p,7)^et(p,18)^p>>>3,d=et(h,17)^et(h,19)^h>>>10;fr[l]=d+fr[l-7]+y+fr[l-16]|0}let{A:n,B:i,C:o,D:s,E:a,F:c,G:f,H:u}=this;for(let l=0;l<64;l++){let p=et(a,6)^et(a,11)^et(a,25),h=u+p+Jp(a,c,f)+e2[l]+fr[l]|0,d=(et(n,2)^et(n,13)^et(n,22))+zp(n,i,o)|0;u=f,f=c,c=a,a=s+h|0,s=o,o=i,i=n,n=h+d|0}n=n+this.A|0,i=i+this.B|0,o=o+this.C|0,s=s+this.D|0,a=a+this.E|0,c=c+this.F|0,f=f+this.G|0,u=u+this.H|0,this.set(n,i,o,s,a,c,f,u)}roundClean(){fr.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}};var xt=Gp(()=>new ff);var Kn=class{static async digest({data:e}){return xt(e)}};var He=class{};var is=class extends He{async digest({algorithm:e,data:r}){switch(e){case"SHA-256":return await Kn.digest({data:r})}}};function Yp(t){if(!Number.isSafeInteger(t)||t<0)throw new Error(`Wrong positive integer: ${t}`)}function t2(t){return t instanceof Uint8Array||t!=null&&typeof t=="object"&&t.constructor.name==="Uint8Array"}function uf(t,...e){if(!t2(t))throw new Error("Expected Uint8Array");if(e.length>0&&!e.includes(t.length))throw new Error(`Expected Uint8Array of length ${e}, not of length=${t.length}`)}function Zp(t){if(typeof t!="function"||typeof t.create!="function")throw new Error("Hash should be wrapped by utils.wrapConstructor");Yp(t.outputLen),Yp(t.blockLen)}function Nn(t,e=!0){if(t.destroyed)throw new Error("Hash instance has been destroyed");if(e&&t.finished)throw new Error("Hash#digest() has already been called")}function Xp(t,e){uf(t);let r=e.outputLen;if(t.length<r)throw new Error(`digestInto() expects output buffer of length at least ${r}`)}var os=typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0;function Qp(t){return t instanceof Uint8Array||t!=null&&typeof t=="object"&&t.constructor.name==="Uint8Array"}var ss=t=>new DataView(t.buffer,t.byteOffset,t.byteLength),tt=(t,e)=>t<<32-e|t>>>e,r2=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;if(!r2)throw new Error("Non little-endian hardware is not supported");function lf(t){if(typeof t!="string")throw new Error(`utf8ToBytes expected string, got ${typeof t}`);return new Uint8Array(new TextEncoder().encode(t))}function Ri(t){if(typeof t=="string"&&(t=lf(t)),!Qp(t))throw new Error(`expected Uint8Array, got ${typeof t}`);return t}function as(...t){let e=0;for(let n=0;n<t.length;n++){let i=t[n];if(!Qp(i))throw new Error("Uint8Array expected");e+=i.length}let r=new Uint8Array(e);for(let n=0,i=0;n<t.length;n++){let o=t[n];r.set(o,i),i+=o.length}return r}var Dn=class{clone(){return this._cloneInto()}},Ev={}.toString;function cs(t){let e=n=>t().update(Ri(n)).digest(),r=t();return e.outputLen=r.outputLen,e.blockLen=r.blockLen,e.create=()=>t(),e}function Ui(t=32){if(os&&typeof os.getRandomValues=="function")return os.getRandomValues(new Uint8Array(t));throw new Error("crypto.getRandomValues must be defined")}function n2(t,e,r,n){if(typeof t.setBigUint64=="function")return t.setBigUint64(e,r,n);let i=BigInt(32),o=BigInt(4294967295),s=Number(r>>i&o),a=Number(r&o),c=n?4:0,f=n?0:4;t.setUint32(e+c,s,n),t.setUint32(e+f,a,n)}var Mn=class extends Dn{constructor(e,r,n,i){super(),this.blockLen=e,this.outputLen=r,this.padOffset=n,this.isLE=i,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(e),this.view=ss(this.buffer)}update(e){Nn(this);let{view:r,buffer:n,blockLen:i}=this;e=Ri(e);let o=e.length;for(let s=0;s<o;){let a=Math.min(i-this.pos,o-s);if(a===i){let c=ss(e);for(;i<=o-s;s+=i)this.process(c,s);continue}n.set(e.subarray(s,s+a),this.pos),this.pos+=a,s+=a,this.pos===i&&(this.process(r,0),this.pos=0)}return this.length+=e.length,this.roundClean(),this}digestInto(e){Nn(this),Xp(e,this),this.finished=!0;let{buffer:r,view:n,blockLen:i,isLE:o}=this,{pos:s}=this;r[s++]=128,this.buffer.subarray(s).fill(0),this.padOffset>i-s&&(this.process(n,0),s=0);for(let l=s;l<i;l++)r[l]=0;n2(n,i-8,BigInt(this.length*8),o),this.process(n,0);let a=ss(e),c=this.outputLen;if(c%4)throw new Error("_sha2: outputLen should be aligned to 32bit");let f=c/4,u=this.get();if(f>u.length)throw new Error("_sha2: outputLen bigger than state");for(let l=0;l<f;l++)a.setUint32(4*l,u[l],o)}digest(){let{buffer:e,outputLen:r}=this;this.digestInto(e);let n=e.slice(0,r);return this.destroy(),n}_cloneInto(e){e||(e=new this.constructor),e.set(...this.get());let{blockLen:r,buffer:n,length:i,finished:o,destroyed:s,pos:a}=this;return e.length=i,e.pos=a,e.finished=o,e.destroyed=s,i%r&&e.buffer.set(n),e}};var i2=(t,e,r)=>t&e^~t&r,o2=(t,e,r)=>t&e^t&r^e&r,s2=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),ur=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),lr=new Uint32Array(64),df=class extends Mn{constructor(){super(64,32,8,!1),this.A=ur[0]|0,this.B=ur[1]|0,this.C=ur[2]|0,this.D=ur[3]|0,this.E=ur[4]|0,this.F=ur[5]|0,this.G=ur[6]|0,this.H=ur[7]|0}get(){let{A:e,B:r,C:n,D:i,E:o,F:s,G:a,H:c}=this;return[e,r,n,i,o,s,a,c]}set(e,r,n,i,o,s,a,c){this.A=e|0,this.B=r|0,this.C=n|0,this.D=i|0,this.E=o|0,this.F=s|0,this.G=a|0,this.H=c|0}process(e,r){for(let l=0;l<16;l++,r+=4)lr[l]=e.getUint32(r,!1);for(let l=16;l<64;l++){let p=lr[l-15],h=lr[l-2],y=tt(p,7)^tt(p,18)^p>>>3,d=tt(h,17)^tt(h,19)^h>>>10;lr[l]=d+lr[l-7]+y+lr[l-16]|0}let{A:n,B:i,C:o,D:s,E:a,F:c,G:f,H:u}=this;for(let l=0;l<64;l++){let p=tt(a,6)^tt(a,11)^tt(a,25),h=u+p+i2(a,c,f)+s2[l]+lr[l]|0,d=(tt(n,2)^tt(n,13)^tt(n,22))+o2(n,i,o)|0;u=f,f=c,c=a,a=s+h|0,s=o,o=i,i=n,n=h+d|0}n=n+this.A|0,i=i+this.B|0,o=o+this.C|0,s=s+this.D|0,a=a+this.E|0,c=c+this.F|0,f=f+this.G|0,u=u+this.H|0,this.set(n,i,o,s,a,c,f,u)}roundClean(){lr.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}};var fs=cs(()=>new df);var ls={};Yf(ls,{bitGet:()=>h2,bitLen:()=>d2,bitMask:()=>Ci,bitSet:()=>p2,bytesToHex:()=>Ft,bytesToNumberBE:()=>$t,bytesToNumberLE:()=>nt,concatBytes:()=>Ht,createHmacDrbg:()=>yf,ensureBytes:()=>oe,equalBytes:()=>u2,hexToBytes:()=>Xr,hexToNumber:()=>pf,isBytes:()=>rt,numberToBytesBE:()=>Ue,numberToBytesLE:()=>Vt,numberToHexUnpadded:()=>ny,numberToVarBytesBE:()=>f2,utf8ToBytes:()=>l2,validateObject:()=>Ge});var ry=BigInt(0),us=BigInt(1),a2=BigInt(2);function rt(t){return t instanceof Uint8Array||t!=null&&typeof t=="object"&&t.constructor.name==="Uint8Array"}var c2=Array.from({length:256},(t,e)=>e.toString(16).padStart(2,"0"));function Ft(t){if(!rt(t))throw new Error("Uint8Array expected");let e="";for(let r=0;r<t.length;r++)e+=c2[t[r]];return e}function ny(t){let e=t.toString(16);return e.length&1?`0${e}`:e}function pf(t){if(typeof t!="string")throw new Error("hex string expected, got "+typeof t);return BigInt(t===""?"0":`0x${t}`)}var jt={_0:48,_9:57,_A:65,_F:70,_a:97,_f:102};function ey(t){if(t>=jt._0&&t<=jt._9)return t-jt._0;if(t>=jt._A&&t<=jt._F)return t-(jt._A-10);if(t>=jt._a&&t<=jt._f)return t-(jt._a-10)}function Xr(t){if(typeof t!="string")throw new Error("hex string expected, got "+typeof t);let e=t.length,r=e/2;if(e%2)throw new Error("padded hex string expected, got unpadded hex of length "+e);let n=new Uint8Array(r);for(let i=0,o=0;i<r;i++,o+=2){let s=ey(t.charCodeAt(o)),a=ey(t.charCodeAt(o+1));if(s===void 0||a===void 0){let c=t[o]+t[o+1];throw new Error('hex string expected, got non-hex character "'+c+'" at index '+o)}n[i]=s*16+a}return n}function $t(t){return pf(Ft(t))}function nt(t){if(!rt(t))throw new Error("Uint8Array expected");return pf(Ft(Uint8Array.from(t).reverse()))}function Ue(t,e){return Xr(t.toString(16).padStart(e*2,"0"))}function Vt(t,e){return Ue(t,e).reverse()}function f2(t){return Xr(ny(t))}function oe(t,e,r){let n;if(typeof e=="string")try{n=Xr(e)}catch(o){throw new Error(`${t} must be valid hex string, got "${e}". Cause: ${o}`)}else if(rt(e))n=Uint8Array.from(e);else throw new Error(`${t} must be hex string or Uint8Array`);let i=n.length;if(typeof r=="number"&&i!==r)throw new Error(`${t} expected ${r} bytes, got ${i}`);return n}function Ht(...t){let e=0;for(let i=0;i<t.length;i++){let o=t[i];if(!rt(o))throw new Error("Uint8Array expected");e+=o.length}let r=new Uint8Array(e),n=0;for(let i=0;i<t.length;i++){let o=t[i];r.set(o,n),n+=o.length}return r}function u2(t,e){if(t.length!==e.length)return!1;let r=0;for(let n=0;n<t.length;n++)r|=t[n]^e[n];return r===0}function l2(t){if(typeof t!="string")throw new Error(`utf8ToBytes expected string, got ${typeof t}`);return new Uint8Array(new TextEncoder().encode(t))}function d2(t){let e;for(e=0;t>ry;t>>=us,e+=1);return e}function h2(t,e){return t>>BigInt(e)&us}var p2=(t,e,r)=>t|(r?us:ry)<<BigInt(e),Ci=t=>(a2<<BigInt(t-1))-us,hf=t=>new Uint8Array(t),ty=t=>Uint8Array.from(t);function yf(t,e,r){if(typeof t!="number"||t<2)throw new Error("hashLen must be a number");if(typeof e!="number"||e<2)throw new Error("qByteLen must be a number");if(typeof r!="function")throw new Error("hmacFn must be a function");let n=hf(t),i=hf(t),o=0,s=()=>{n.fill(1),i.fill(0),o=0},a=(...l)=>r(i,n,...l),c=(l=hf())=>{i=a(ty([0]),l),n=a(),l.length!==0&&(i=a(ty([1]),l),n=a())},f=()=>{if(o++>=1e3)throw new Error("drbg: tried 1000 values");let l=0,p=[];for(;l<e;){n=a();let h=n.slice();p.push(h),l+=n.length}return Ht(...p)};return(l,p)=>{s(),c(l);let h;for(;!(h=p(f()));)c();return s(),h}}var y2={bigint:t=>typeof t=="bigint",function:t=>typeof t=="function",boolean:t=>typeof t=="boolean",string:t=>typeof t=="string",stringOrUint8Array:t=>typeof t=="string"||rt(t),isSafeInteger:t=>Number.isSafeInteger(t),array:t=>Array.isArray(t),field:(t,e)=>e.Fp.isValid(t),hash:t=>typeof t=="function"&&Number.isSafeInteger(t.outputLen)};function Ge(t,e,r={}){let n=(i,o,s)=>{let a=y2[o];if(typeof a!="function")throw new Error(`Invalid validator "${o}", expected function`);let c=t[i];if(!(s&&c===void 0)&&!a(c,t))throw new Error(`Invalid param ${String(i)}=${c} (${typeof c}), expected ${o}`)};for(let[i,o]of Object.entries(e))n(i,o,!1);for(let[i,o]of Object.entries(r))n(i,o,!0);return t}var ye=BigInt(0),ae=BigInt(1),Qr=BigInt(2),w2=BigInt(3),wf=BigInt(4),iy=BigInt(5),oy=BigInt(8),m2=BigInt(9),b2=BigInt(16);function ee(t,e){let r=t%e;return r>=ye?r:e+r}function mf(t,e,r){if(r<=ye||e<ye)throw new Error("Expected power/modulo > 0");if(r===ae)return ye;let n=ae;for(;e>ye;)e&ae&&(n=n*t%r),t=t*t%r,e>>=ae;return n}function se(t,e,r){let n=t;for(;e-- >ye;)n*=n,n%=r;return n}function ds(t,e){if(t===ye||e<=ye)throw new Error(`invert: expected positive integers, got n=${t} mod=${e}`);let r=ee(t,e),n=e,i=ye,o=ae,s=ae,a=ye;for(;r!==ye;){let f=n/r,u=n%r,l=i-s*f,p=o-a*f;n=r,r=u,i=s,o=a,s=l,a=p}if(n!==ae)throw new Error("invert: does not exist");return ee(i,e)}function g2(t){let e=(t-ae)/Qr,r,n,i;for(r=t-ae,n=0;r%Qr===ye;r/=Qr,n++);for(i=Qr;i<t&&mf(i,e,t)!==t-ae;i++);if(n===1){let s=(t+ae)/wf;return function(c,f){let u=c.pow(f,s);if(!c.eql(c.sqr(u),f))throw new Error("Cannot find square root");return u}}let o=(r+ae)/Qr;return function(a,c){if(a.pow(c,e)===a.neg(a.ONE))throw new Error("Cannot find square root");let f=n,u=a.pow(a.mul(a.ONE,i),r),l=a.pow(c,o),p=a.pow(c,r);for(;!a.eql(p,a.ONE);){if(a.eql(p,a.ZERO))return a.ZERO;let h=1;for(let d=a.sqr(p);h<f&&!a.eql(d,a.ONE);h++)d=a.sqr(d);let y=a.pow(u,ae<<BigInt(f-h-1));u=a.sqr(y),l=a.mul(l,y),p=a.mul(p,u),f=h}return l}}function x2(t){if(t%wf===w2){let e=(t+ae)/wf;return function(n,i){let o=n.pow(i,e);if(!n.eql(n.sqr(o),i))throw new Error("Cannot find square root");return o}}if(t%oy===iy){let e=(t-iy)/oy;return function(n,i){let o=n.mul(i,Qr),s=n.pow(o,e),a=n.mul(i,s),c=n.mul(n.mul(a,Qr),s),f=n.mul(a,n.sub(c,n.ONE));if(!n.eql(n.sqr(f),i))throw new Error("Cannot find square root");return f}}return t%b2,g2(t)}var sy=(t,e)=>(ee(t,e)&ae)===ae,E2=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function bf(t){let e={ORDER:"bigint",MASK:"bigint",BYTES:"isSafeInteger",BITS:"isSafeInteger"},r=E2.reduce((n,i)=>(n[i]="function",n),e);return Ge(t,r)}function _2(t,e,r){if(r<ye)throw new Error("Expected power > 0");if(r===ye)return t.ONE;if(r===ae)return e;let n=t.ONE,i=e;for(;r>ye;)r&ae&&(n=t.mul(n,i)),i=t.sqr(i),r>>=ae;return n}function A2(t,e){let r=new Array(e.length),n=e.reduce((o,s,a)=>t.is0(s)?o:(r[a]=o,t.mul(o,s)),t.ONE),i=t.inv(n);return e.reduceRight((o,s,a)=>t.is0(s)?o:(r[a]=t.mul(o,r[a]),t.mul(o,s)),i),r}function gf(t,e){let r=e!==void 0?e:t.toString(2).length,n=Math.ceil(r/8);return{nBitLength:r,nByteLength:n}}function qn(t,e,r=!1,n={}){if(t<=ye)throw new Error(`Expected Field ORDER > 0, got ${t}`);let{nBitLength:i,nByteLength:o}=gf(t,e);if(o>2048)throw new Error("Field lengths over 2048 bytes are not supported");let s=x2(t),a=Object.freeze({ORDER:t,BITS:i,BYTES:o,MASK:Ci(i),ZERO:ye,ONE:ae,create:c=>ee(c,t),isValid:c=>{if(typeof c!="bigint")throw new Error(`Invalid field element: expected bigint, got ${typeof c}`);return ye<=c&&c<t},is0:c=>c===ye,isOdd:c=>(c&ae)===ae,neg:c=>ee(-c,t),eql:(c,f)=>c===f,sqr:c=>ee(c*c,t),add:(c,f)=>ee(c+f,t),sub:(c,f)=>ee(c-f,t),mul:(c,f)=>ee(c*f,t),pow:(c,f)=>_2(a,c,f),div:(c,f)=>ee(c*ds(f,t),t),sqrN:c=>c*c,addN:(c,f)=>c+f,subN:(c,f)=>c-f,mulN:(c,f)=>c*f,inv:c=>ds(c,t),sqrt:n.sqrt||(c=>s(a,c)),invertBatch:c=>A2(a,c),cmov:(c,f,u)=>u?f:c,toBytes:c=>r?Vt(c,o):Ue(c,o),fromBytes:c=>{if(c.length!==o)throw new Error(`Fp.fromBytes: expected ${o}, got ${c.length}`);return r?nt(c):$t(c)}});return Object.freeze(a)}function ay(t,e){if(!t.isOdd)throw new Error("Field doesn't have isOdd");let r=t.sqrt(e);return t.isOdd(r)?t.neg(r):r}function cy(t){if(typeof t!="bigint")throw new Error("field order must be bigint");let e=t.toString(2).length;return Math.ceil(e/8)}function xf(t){let e=cy(t);return e+Math.ceil(e/2)}function fy(t,e,r=!1){let n=t.length,i=cy(e),o=xf(e);if(n<16||n<o||n>1024)throw new Error(`expected ${o}-1024 bytes of input, got ${n}`);let s=r?$t(t):nt(t),a=ee(s,e-ae)+ae;return r?Vt(a,i):Ue(a,i)}var v2=BigInt(0),Ef=BigInt(1);function hs(t,e){let r=(i,o)=>{let s=o.negate();return i?s:o},n=i=>{let o=Math.ceil(e/i)+1,s=2**(i-1);return{windows:o,windowSize:s}};return{constTimeNegate:r,unsafeLadder(i,o){let s=t.ZERO,a=i;for(;o>v2;)o&Ef&&(s=s.add(a)),a=a.double(),o>>=Ef;return s},precomputeWindow(i,o){let{windows:s,windowSize:a}=n(o),c=[],f=i,u=f;for(let l=0;l<s;l++){u=f,c.push(u);for(let p=1;p<a;p++)u=u.add(f),c.push(u);f=u.double()}return c},wNAF(i,o,s){let{windows:a,windowSize:c}=n(i),f=t.ZERO,u=t.BASE,l=BigInt(2**i-1),p=2**i,h=BigInt(i);for(let y=0;y<a;y++){let d=y*c,w=Number(s&l);s>>=h,w>c&&(w-=p,s+=Ef);let m=d,A=d+Math.abs(w)-1,g=y%2!==0,_=w<0;w===0?u=u.add(r(g,o[m])):f=f.add(r(_,o[A]))}return{p:f,f:u}},wNAFCached(i,o,s,a){let c=i._WINDOW_SIZE||1,f=o.get(i);return f||(f=this.precomputeWindow(i,c),c!==1&&o.set(i,a(f))),this.wNAF(c,f,s)}}}function Li(t){return bf(t.Fp),Ge(t,{n:"bigint",h:"bigint",Gx:"field",Gy:"field"},{nBitLength:"isSafeInteger",nByteLength:"isSafeInteger"}),Object.freeze({...gf(t.n,t.nBitLength),...t,p:t.Fp.ORDER})}function B2(t){let e=Li(t);Ge(e,{a:"field",b:"field"},{allowedPrivateKeyLengths:"array",wrapPrivateKey:"boolean",isTorsionFree:"function",clearCofactor:"function",allowInfinityPoint:"boolean",fromBytes:"function",toBytes:"function"});let{endo:r,Fp:n,a:i}=e;if(r){if(!n.eql(i,n.ZERO))throw new Error("Endomorphism can only be defined for Koblitz curves that have a=0");if(typeof r!="object"||typeof r.beta!="bigint"||typeof r.splitScalar!="function")throw new Error("Expected endomorphism with beta: bigint and splitScalar: function")}return Object.freeze({...e})}var{bytesToNumberBE:T2,hexToBytes:k2}=ls,en={Err:class extends Error{constructor(e=""){super(e)}},_parseInt(t){let{Err:e}=en;if(t.length<2||t[0]!==2)throw new e("Invalid signature integer tag");let r=t[1],n=t.subarray(2,r+2);if(!r||n.length!==r)throw new e("Invalid signature integer: wrong length");if(n[0]&128)throw new e("Invalid signature integer: negative");if(n[0]===0&&!(n[1]&128))throw new e("Invalid signature integer: unnecessary leading zero");return{d:T2(n),l:t.subarray(r+2)}},toSig(t){let{Err:e}=en,r=typeof t=="string"?k2(t):t;if(!rt(r))throw new Error("ui8a expected");let n=r.length;if(n<2||r[0]!=48)throw new e("Invalid signature tag");if(r[1]!==n-2)throw new e("Invalid signature: incorrect length");let{d:i,l:o}=en._parseInt(r.subarray(2)),{d:s,l:a}=en._parseInt(o);if(a.length)throw new e("Invalid signature: left bytes after parsing");return{r:i,s}},hexFromSig(t){let e=f=>Number.parseInt(f[0],16)&8?"00"+f:f,r=f=>{let u=f.toString(16);return u.length&1?`0${u}`:u},n=e(r(t.s)),i=e(r(t.r)),o=n.length/2,s=i.length/2,a=r(o),c=r(s);return`30${r(s+o+4)}02${c}${i}02${a}${n}`}},Gt=BigInt(0),We=BigInt(1),Kv=BigInt(2),uy=BigInt(3),Nv=BigInt(4);function P2(t){let e=B2(t),{Fp:r}=e,n=e.toBytes||((y,d,w)=>{let m=d.toAffine();return Ht(Uint8Array.from([4]),r.toBytes(m.x),r.toBytes(m.y))}),i=e.fromBytes||(y=>{let d=y.subarray(1),w=r.fromBytes(d.subarray(0,r.BYTES)),m=r.fromBytes(d.subarray(r.BYTES,2*r.BYTES));return{x:w,y:m}});function o(y){let{a:d,b:w}=e,m=r.sqr(y),A=r.mul(m,y);return r.add(r.add(A,r.mul(y,d)),w)}if(!r.eql(r.sqr(e.Gy),o(e.Gx)))throw new Error("bad generator point: equation left != right");function s(y){return typeof y=="bigint"&&Gt<y&&y<e.n}function a(y){if(!s(y))throw new Error("Expected valid bigint: 0 < bigint < curve.n")}function c(y){let{allowedPrivateKeyLengths:d,nByteLength:w,wrapPrivateKey:m,n:A}=e;if(d&&typeof y!="bigint"){if(rt(y)&&(y=Ft(y)),typeof y!="string"||!d.includes(y.length))throw new Error("Invalid key");y=y.padStart(w*2,"0")}let g;try{g=typeof y=="bigint"?y:$t(oe("private key",y,w))}catch{throw new Error(`private key must be ${w} bytes, hex or bigint, not ${typeof y}`)}return m&&(g=ee(g,A)),a(g),g}let f=new Map;function u(y){if(!(y instanceof l))throw new Error("ProjectivePoint expected")}class l{constructor(d,w,m){if(this.px=d,this.py=w,this.pz=m,d==null||!r.isValid(d))throw new Error("x required");if(w==null||!r.isValid(w))throw new Error("y required");if(m==null||!r.isValid(m))throw new Error("z required")}static fromAffine(d){let{x:w,y:m}=d||{};if(!d||!r.isValid(w)||!r.isValid(m))throw new Error("invalid affine point");if(d instanceof l)throw new Error("projective point not allowed");let A=g=>r.eql(g,r.ZERO);return A(w)&&A(m)?l.ZERO:new l(w,m,r.ONE)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static normalizeZ(d){let w=r.invertBatch(d.map(m=>m.pz));return d.map((m,A)=>m.toAffine(w[A])).map(l.fromAffine)}static fromHex(d){let w=l.fromAffine(i(oe("pointHex",d)));return w.assertValidity(),w}static fromPrivateKey(d){return l.BASE.multiply(c(d))}_setWindowSize(d){this._WINDOW_SIZE=d,f.delete(this)}assertValidity(){if(this.is0()){if(e.allowInfinityPoint&&!r.is0(this.py))return;throw new Error("bad point: ZERO")}let{x:d,y:w}=this.toAffine();if(!r.isValid(d)||!r.isValid(w))throw new Error("bad point: x or y not FE");let m=r.sqr(w),A=o(d);if(!r.eql(m,A))throw new Error("bad point: equation left != right");if(!this.isTorsionFree())throw new Error("bad point: not in prime-order subgroup")}hasEvenY(){let{y:d}=this.toAffine();if(r.isOdd)return!r.isOdd(d);throw new Error("Field doesn't support isOdd")}equals(d){u(d);let{px:w,py:m,pz:A}=this,{px:g,py:_,pz:E}=d,B=r.eql(r.mul(w,E),r.mul(g,A)),T=r.eql(r.mul(m,E),r.mul(_,A));return B&&T}negate(){return new l(this.px,r.neg(this.py),this.pz)}double(){let{a:d,b:w}=e,m=r.mul(w,uy),{px:A,py:g,pz:_}=this,E=r.ZERO,B=r.ZERO,T=r.ZERO,k=r.mul(A,A),R=r.mul(g,g),C=r.mul(_,_),L=r.mul(A,g);return L=r.add(L,L),T=r.mul(A,_),T=r.add(T,T),E=r.mul(d,T),B=r.mul(m,C),B=r.add(E,B),E=r.sub(R,B),B=r.add(R,B),B=r.mul(E,B),E=r.mul(L,E),T=r.mul(m,T),C=r.mul(d,C),L=r.sub(k,C),L=r.mul(d,L),L=r.add(L,T),T=r.add(k,k),k=r.add(T,k),k=r.add(k,C),k=r.mul(k,L),B=r.add(B,k),C=r.mul(g,_),C=r.add(C,C),k=r.mul(C,L),E=r.sub(E,k),T=r.mul(C,R),T=r.add(T,T),T=r.add(T,T),new l(E,B,T)}add(d){u(d);let{px:w,py:m,pz:A}=this,{px:g,py:_,pz:E}=d,B=r.ZERO,T=r.ZERO,k=r.ZERO,R=e.a,C=r.mul(e.b,uy),L=r.mul(w,g),j=r.mul(m,_),K=r.mul(A,E),Y=r.add(w,m),S=r.add(g,_);Y=r.mul(Y,S),S=r.add(L,j),Y=r.sub(Y,S),S=r.add(w,A);let I=r.add(g,E);return S=r.mul(S,I),I=r.add(L,K),S=r.sub(S,I),I=r.add(m,A),B=r.add(_,E),I=r.mul(I,B),B=r.add(j,K),I=r.sub(I,B),k=r.mul(R,S),B=r.mul(C,K),k=r.add(B,k),B=r.sub(j,k),k=r.add(j,k),T=r.mul(B,k),j=r.add(L,L),j=r.add(j,L),K=r.mul(R,K),S=r.mul(C,S),j=r.add(j,K),K=r.sub(L,K),K=r.mul(R,K),S=r.add(S,K),L=r.mul(j,S),T=r.add(T,L),L=r.mul(I,S),B=r.mul(Y,B),B=r.sub(B,L),L=r.mul(Y,j),k=r.mul(I,k),k=r.add(k,L),new l(B,T,k)}subtract(d){return this.add(d.negate())}is0(){return this.equals(l.ZERO)}wNAF(d){return h.wNAFCached(this,f,d,w=>{let m=r.invertBatch(w.map(A=>A.pz));return w.map((A,g)=>A.toAffine(m[g])).map(l.fromAffine)})}multiplyUnsafe(d){let w=l.ZERO;if(d===Gt)return w;if(a(d),d===We)return this;let{endo:m}=e;if(!m)return h.unsafeLadder(this,d);let{k1neg:A,k1:g,k2neg:_,k2:E}=m.splitScalar(d),B=w,T=w,k=this;for(;g>Gt||E>Gt;)g&We&&(B=B.add(k)),E&We&&(T=T.add(k)),k=k.double(),g>>=We,E>>=We;return A&&(B=B.negate()),_&&(T=T.negate()),T=new l(r.mul(T.px,m.beta),T.py,T.pz),B.add(T)}multiply(d){a(d);let w=d,m,A,{endo:g}=e;if(g){let{k1neg:_,k1:E,k2neg:B,k2:T}=g.splitScalar(w),{p:k,f:R}=this.wNAF(E),{p:C,f:L}=this.wNAF(T);k=h.constTimeNegate(_,k),C=h.constTimeNegate(B,C),C=new l(r.mul(C.px,g.beta),C.py,C.pz),m=k.add(C),A=R.add(L)}else{let{p:_,f:E}=this.wNAF(w);m=_,A=E}return l.normalizeZ([m,A])[0]}multiplyAndAddUnsafe(d,w,m){let A=l.BASE,g=(E,B)=>B===Gt||B===We||!E.equals(A)?E.multiplyUnsafe(B):E.multiply(B),_=g(this,w).add(g(d,m));return _.is0()?void 0:_}toAffine(d){let{px:w,py:m,pz:A}=this,g=this.is0();d==null&&(d=g?r.ONE:r.inv(A));let _=r.mul(w,d),E=r.mul(m,d),B=r.mul(A,d);if(g)return{x:r.ZERO,y:r.ZERO};if(!r.eql(B,r.ONE))throw new Error("invZ was invalid");return{x:_,y:E}}isTorsionFree(){let{h:d,isTorsionFree:w}=e;if(d===We)return!0;if(w)return w(l,this);throw new Error("isTorsionFree() has not been declared for the elliptic curve")}clearCofactor(){let{h:d,clearCofactor:w}=e;return d===We?this:w?w(l,this):this.multiplyUnsafe(e.h)}toRawBytes(d=!0){return this.assertValidity(),n(l,this,d)}toHex(d=!0){return Ft(this.toRawBytes(d))}}l.BASE=new l(e.Gx,e.Gy,r.ONE),l.ZERO=new l(r.ZERO,r.ONE,r.ZERO);let p=e.nBitLength,h=hs(l,e.endo?Math.ceil(p/2):p);return{CURVE:e,ProjectivePoint:l,normPrivateKeyToScalar:c,weierstrassEquation:o,isWithinCurveOrder:s}}function I2(t){let e=Li(t);return Ge(e,{hash:"hash",hmac:"function",randomBytes:"function"},{bits2int:"function",bits2int_modN:"function",lowS:"boolean"}),Object.freeze({lowS:!0,...e})}function ly(t){let e=I2(t),{Fp:r,n}=e,i=r.BYTES+1,o=2*r.BYTES+1;function s(S){return Gt<S&&S<r.ORDER}function a(S){return ee(S,n)}function c(S){return ds(S,n)}let{ProjectivePoint:f,normPrivateKeyToScalar:u,weierstrassEquation:l,isWithinCurveOrder:p}=P2({...e,toBytes(S,I,N){let v=I.toAffine(),b=r.toBytes(v.x),P=Ht;return N?P(Uint8Array.from([I.hasEvenY()?2:3]),b):P(Uint8Array.from([4]),b,r.toBytes(v.y))},fromBytes(S){let I=S.length,N=S[0],v=S.subarray(1);if(I===i&&(N===2||N===3)){let b=$t(v);if(!s(b))throw new Error("Point is not on curve");let P=l(b),U=r.sqrt(P),O=(U&We)===We;return(N&1)===1!==O&&(U=r.neg(U)),{x:b,y:U}}else if(I===o&&N===4){let b=r.fromBytes(v.subarray(0,r.BYTES)),P=r.fromBytes(v.subarray(r.BYTES,2*r.BYTES));return{x:b,y:P}}else throw new Error(`Point of length ${I} was invalid. Expected ${i} compressed bytes or ${o} uncompressed bytes`)}}),h=S=>Ft(Ue(S,e.nByteLength));function y(S){let I=n>>We;return S>I}function d(S){return y(S)?a(-S):S}let w=(S,I,N)=>$t(S.slice(I,N));class m{constructor(I,N,v){this.r=I,this.s=N,this.recovery=v,this.assertValidity()}static fromCompact(I){let N=e.nByteLength;return I=oe("compactSignature",I,N*2),new m(w(I,0,N),w(I,N,2*N))}static fromDER(I){let{r:N,s:v}=en.toSig(oe("DER",I));return new m(N,v)}assertValidity(){if(!p(this.r))throw new Error("r must be 0 < r < CURVE.n");if(!p(this.s))throw new Error("s must be 0 < s < CURVE.n")}addRecoveryBit(I){return new m(this.r,this.s,I)}recoverPublicKey(I){let{r:N,s:v,recovery:b}=this,P=T(oe("msgHash",I));if(b==null||![0,1,2,3].includes(b))throw new Error("recovery id invalid");let U=b===2||b===3?N+e.n:N;if(U>=r.ORDER)throw new Error("recovery id 2 or 3 invalid");let O=b&1?"03":"02",F=f.fromHex(O+h(U)),$=c(U),Z=a(-P*$),V=a(v*$),H=f.BASE.multiplyAndAddUnsafe(F,Z,V);if(!H)throw new Error("point at infinify");return H.assertValidity(),H}hasHighS(){return y(this.s)}normalizeS(){return this.hasHighS()?new m(this.r,a(-this.s),this.recovery):this}toDERRawBytes(){return Xr(this.toDERHex())}toDERHex(){return en.hexFromSig({r:this.r,s:this.s})}toCompactRawBytes(){return Xr(this.toCompactHex())}toCompactHex(){return h(this.r)+h(this.s)}}let A={isValidPrivateKey(S){try{return u(S),!0}catch{return!1}},normPrivateKeyToScalar:u,randomPrivateKey:()=>{let S=xf(e.n);return fy(e.randomBytes(S),e.n)},precompute(S=8,I=f.BASE){return I._setWindowSize(S),I.multiply(BigInt(3)),I}};function g(S,I=!0){return f.fromPrivateKey(S).toRawBytes(I)}function _(S){let I=rt(S),N=typeof S=="string",v=(I||N)&&S.length;return I?v===i||v===o:N?v===2*i||v===2*o:S instanceof f}function E(S,I,N=!0){if(_(S))throw new Error("first arg must be private key");if(!_(I))throw new Error("second arg must be public key");return f.fromHex(I).multiply(u(S)).toRawBytes(N)}let B=e.bits2int||function(S){let I=$t(S),N=S.length*8-e.nBitLength;return N>0?I>>BigInt(N):I},T=e.bits2int_modN||function(S){return a(B(S))},k=Ci(e.nBitLength);function R(S){if(typeof S!="bigint")throw new Error("bigint expected");if(!(Gt<=S&&S<k))throw new Error(`bigint expected < 2^${e.nBitLength}`);return Ue(S,e.nByteLength)}function C(S,I,N=L){if(["recovered","canonical"].some(te=>te in N))throw new Error("sign() legacy options not supported");let{hash:v,randomBytes:b}=e,{lowS:P,prehash:U,extraEntropy:O}=N;P==null&&(P=!0),S=oe("msgHash",S),U&&(S=oe("prehashed msgHash",v(S)));let F=T(S),$=u(I),Z=[R($),R(F)];if(O!=null){let te=O===!0?b(r.BYTES):O;Z.push(oe("extraEntropy",te))}let V=Ht(...Z),H=F;function ne(te){let be=B(te);if(!p(be))return;let ge=c(be),de=f.BASE.multiply(be).toAffine(),_e=a(de.x);if(_e===Gt)return;let St=a(ge*a(H+_e*$));if(St===Gt)return;let gr=(de.x===_e?0:2)|Number(de.y&We),Hn=St;return P&&y(St)&&(Hn=d(St),gr^=1),new m(_e,Hn,gr)}return{seed:V,k2sig:ne}}let L={lowS:e.lowS,prehash:!1},j={lowS:e.lowS,prehash:!1};function K(S,I,N=L){let{seed:v,k2sig:b}=C(S,I,N),P=e;return yf(P.hash.outputLen,P.nByteLength,P.hmac)(v,b)}f.BASE._setWindowSize(8);function Y(S,I,N,v=j){let b=S;if(I=oe("msgHash",I),N=oe("publicKey",N),"strict"in v)throw new Error("options.strict was renamed to lowS");let{lowS:P,prehash:U}=v,O,F;try{if(typeof b=="string"||rt(b))try{O=m.fromDER(b)}catch(de){if(!(de instanceof en.Err))throw de;O=m.fromCompact(b)}else if(typeof b=="object"&&typeof b.r=="bigint"&&typeof b.s=="bigint"){let{r:de,s:_e}=b;O=new m(de,_e)}else throw new Error("PARSE");F=f.fromHex(N)}catch(de){if(de.message==="PARSE")throw new Error("signature must be Signature instance, Uint8Array or hex string");return!1}if(P&&O.hasHighS())return!1;U&&(I=e.hash(I));let{r:$,s:Z}=O,V=T(I),H=c(Z),ne=a(V*H),te=a($*H),be=f.BASE.multiplyAndAddUnsafe(F,ne,te)?.toAffine();return be?a(be.x)===$:!1}return{CURVE:e,getPublicKey:g,getSharedSecret:E,sign:K,verify:Y,ProjectivePoint:f,Signature:m,utils:A}}var ps=class extends Dn{constructor(e,r){super(),this.finished=!1,this.destroyed=!1,Zp(e);let n=Ri(r);if(this.iHash=e.create(),typeof this.iHash.update!="function")throw new Error("Expected instance of class which extends utils.Hash");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;let i=this.blockLen,o=new Uint8Array(i);o.set(n.length>i?e.create().update(n).digest():n);for(let s=0;s<o.length;s++)o[s]^=54;this.iHash.update(o),this.oHash=e.create();for(let s=0;s<o.length;s++)o[s]^=106;this.oHash.update(o),o.fill(0)}update(e){return Nn(this),this.iHash.update(e),this}digestInto(e){Nn(this),uf(e,this.outputLen),this.finished=!0,this.iHash.digestInto(e),this.oHash.update(e),this.oHash.digestInto(e),this.destroy()}digest(){let e=new Uint8Array(this.oHash.outputLen);return this.digestInto(e),e}_cloneInto(e){e||(e=Object.create(Object.getPrototypeOf(this),{}));let{oHash:r,iHash:n,finished:i,destroyed:o,blockLen:s,outputLen:a}=this;return e=e,e.finished=i,e.destroyed=o,e.blockLen=s,e.outputLen=a,e.oHash=r._cloneInto(e.oHash),e.iHash=n._cloneInto(e.iHash),e}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}},_f=(t,e,r)=>new ps(t,e).update(r).digest();_f.create=(t,e)=>new ps(t,e);function R2(t){return{hash:t,hmac:(e,...r)=>_f(t,e,as(...r)),randomBytes:Ui}}function ys(t,e){let r=n=>ly({...t,...R2(n)});return Object.freeze({...r(e),create:r})}var py=BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),dy=BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),U2=BigInt(1),Af=BigInt(2),hy=(t,e)=>(t+e/Af)/e;function C2(t){let e=py,r=BigInt(3),n=BigInt(6),i=BigInt(11),o=BigInt(22),s=BigInt(23),a=BigInt(44),c=BigInt(88),f=t*t*t%e,u=f*f*t%e,l=se(u,r,e)*u%e,p=se(l,r,e)*u%e,h=se(p,Af,e)*f%e,y=se(h,i,e)*h%e,d=se(y,o,e)*y%e,w=se(d,a,e)*d%e,m=se(w,c,e)*w%e,A=se(m,a,e)*d%e,g=se(A,r,e)*u%e,_=se(g,s,e)*y%e,E=se(_,n,e)*f%e,B=se(E,Af,e);if(!Sf.eql(Sf.sqr(B),t))throw new Error("Cannot find square root");return B}var Sf=qn(py,void 0,void 0,{sqrt:C2}),Ce=ys({a:BigInt(0),b:BigInt(7),Fp:Sf,n:dy,Gx:BigInt("55066263022277343669578718895168534326250603453777594175500187360389116729240"),Gy:BigInt("32670510020758816978083085130507043184471273380659243275938904335757337482424"),h:BigInt(1),lowS:!0,endo:{beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),splitScalar:t=>{let e=dy,r=BigInt("0x3086d221a7d46bcde86c90e49284eb15"),n=-U2*BigInt("0xe4437ed6010e88286f547fa90abfe4c3"),i=BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),o=r,s=BigInt("0x100000000000000000000000000000000"),a=hy(o*t,e),c=hy(-n*t,e),f=ee(t-a*r-c*i,e),u=ee(-a*n-c*o,e),l=f>s,p=u>s;if(l&&(f=e-f),p&&(u=e-u),f>s||u>s)throw new Error("splitScalar: Endomorphism failed, k="+t);return{k1neg:l,k1:f,k2neg:p,k2:u}}}},fs),zv=BigInt(0);var Yv=Ce.ProjectivePoint;function yy(t){let e=n=>{if(n!==null&&typeof n=="object"&&!Array.isArray(n)){let i=Object.keys(n).sort(),o={};for(let s of i)o[s]=e(n[s]);return o}return n},r=e(t);return JSON.stringify(r)}var vf="urn:jwk:";async function G({jwk:t}){let e=t.kty,r;if(e==="EC")r={crv:t.crv,kty:t.kty,x:t.x,y:t.y};else if(e==="oct")r={k:t.k,kty:t.kty};else if(e==="OKP")r={crv:t.crv,kty:t.kty,x:t.x};else if(e==="RSA")r={e:t.e,kty:t.kty,n:t.n};else throw new Error(`Unsupported key type: ${e}`);$s(r);let n=yy(r),i=q.string(n).toUint8Array(),o=await Kn.digest({data:i});return q.uint8Array(o).toBase64Url()}function Et(t){return!(!t||typeof t!="object"||!("kty"in t&&"crv"in t&&"x"in t&&"d"in t)||t.kty!=="EC"||typeof t.d!="string"||typeof t.x!="string")}function jn(t){return!(!t||typeof t!="object"||!("kty"in t&&"crv"in t&&"x"in t)||"d"in t||t.kty!=="EC"||typeof t.x!="string")}function dr(t){return!(!t||typeof t!="object"||!("kty"in t&&"k"in t)||t.kty!=="oct"||typeof t.k!="string")}function _t(t){return!(!t||typeof t!="object"||!("kty"in t&&"crv"in t&&"x"in t&&"d"in t)||t.kty!=="OKP"||typeof t.d!="string"||typeof t.x!="string")}function Fn(t){return!(!t||typeof t!="object"||"d"in t||!("kty"in t&&"crv"in t&&"x"in t)||t.kty!=="OKP"||typeof t.x!="string")}function wy(t){if(!t||typeof t!="object")return!1;switch(t.kty){case"EC":case"OKP":case"RSA":return"d"in t;case"oct":return"k"in t;default:return!1}}function r8(t){if(!t||typeof t!="object")return!1;switch(t.kty){case"EC":case"OKP":return"x"in t&&!("d"in t);case"RSA":return"n"in t&&"e"in t&&!("d"in t);default:return!1}}var hr=class t{static async adjustSignatureToLowS({signature:e}){let r=Ce.Signature.fromCompact(e);return r.hasHighS()?r.normalizeS().toCompactRawBytes():e}static async bytesToPrivateKey({privateKeyBytes:e}){let r=await t.getCurvePoint({keyBytes:e}),n={kty:"EC",crv:"secp256k1",d:q.uint8Array(e).toBase64Url(),x:q.uint8Array(r.x).toBase64Url(),y:q.uint8Array(r.y).toBase64Url()};return n.kid=await G({jwk:n}),n}static async bytesToPublicKey({publicKeyBytes:e}){let r=await t.getCurvePoint({keyBytes:e}),n={kty:"EC",crv:"secp256k1",x:q.uint8Array(r.x).toBase64Url(),y:q.uint8Array(r.y).toBase64Url()};return n.kid=await G({jwk:n}),n}static async compressPublicKey({publicKeyBytes:e}){return Ce.ProjectivePoint.fromHex(e).toRawBytes(!0)}static async computePublicKey({key:e}){let r=await t.privateKeyToBytes({privateKey:e}),n=await t.getCurvePoint({keyBytes:r}),i={kty:"EC",crv:"secp256k1",x:q.uint8Array(n.x).toBase64Url(),y:q.uint8Array(n.y).toBase64Url()};return i.kid=await G({jwk:i}),i}static async convertDerToCompactSignature({derSignature:e}){return Ce.Signature.fromDER(e).toCompactRawBytes()}static async decompressPublicKey({publicKeyBytes:e}){return Ce.ProjectivePoint.fromHex(e).toRawBytes(!1)}static async generateKey(){let e=Ce.utils.randomPrivateKey(),r=await t.bytesToPrivateKey({privateKeyBytes:e});return r.kid=await G({jwk:r}),r}static async getPublicKey({key:e}){if(!(Et(e)&&e.crv==="secp256k1"))throw new Error("Secp256k1: The provided key is not a secp256k1 private JWK.");let{d:r,...n}=e;return n.kid??=await G({jwk:n}),n}static async privateKeyToBytes({privateKey:e}){if(!Et(e))throw new Error("Secp256k1: The provided key is not a valid EC private key.");return q.base64Url(e.d).toUint8Array()}static async publicKeyToBytes({publicKey:e}){if(!(jn(e)&&e.y))throw new Error("Secp256k1: The provided key is not a valid EC public key.");let r=new Uint8Array([4]),n=q.base64Url(e.x).toUint8Array(),i=q.base64Url(e.y).toUint8Array();return new Uint8Array([...r,...n,...i])}static async sharedSecret({privateKeyA:e,publicKeyB:r}){if("x"in e&&"x"in r&&e.x===r.x)throw new Error("Secp256k1: ECDH shared secret cannot be computed from a single key pair's public and private keys.");let n=await t.privateKeyToBytes({privateKey:e}),i=await t.publicKeyToBytes({publicKey:r});return Ce.getSharedSecret(n,i,!0).slice(1)}static async sign({data:e,key:r}){let n=await t.privateKeyToBytes({privateKey:r}),i=xt(e);return Ce.sign(i,n).toCompactRawBytes()}static async validatePrivateKey({privateKeyBytes:e}){return Ce.utils.isValidPrivateKey(e)}static async validatePublicKey({publicKeyBytes:e}){try{Ce.ProjectivePoint.fromHex(e).assertValidity()}catch{return!1}return!0}static async verify({key:e,signature:r,data:n}){let i=await t.publicKeyToBytes({publicKey:e}),o=xt(n);return Ce.verify(r,o,i,{lowS:!1})}static async getCurvePoint({keyBytes:e}){e.byteLength===32&&(e=Ce.getPublicKey(e));let r=Ce.ProjectivePoint.fromHex(e),n=Ue(r.x,32),i=Ue(r.y,32);return{x:n,y:i}}};var my=qn(BigInt("0xffffffff00000001000000000000000000000000ffffffffffffffffffffffff")),L2=my.create(BigInt("-3")),O2=BigInt("0x5ac635d8aa3a93e7b3ebbd55769886bc651d06b0cc53b0f63bce3c3e27d2604b"),K2=ys({a:L2,b:O2,Fp:my,n:BigInt("0xffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc632551"),Gx:BigInt("0x6b17d1f2e12c4247f8bce6e563a440f277037d812deb33a0f4a13945d898c296"),Gy:BigInt("0x4fe342e2fe1a7f9b8ee7eb4a7c0f9e162bce33576b315ececbb6406837bf51f5"),h:BigInt(1),lowS:!1},fs),Ne=K2;var pr=class t{static async adjustSignatureToLowS({signature:e}){let r=Ne.Signature.fromCompact(e);return r.hasHighS()?r.normalizeS().toCompactRawBytes():e}static async bytesToPrivateKey({privateKeyBytes:e}){let r=await t.getCurvePoint({keyBytes:e}),n={kty:"EC",crv:"P-256",d:q.uint8Array(e).toBase64Url(),x:q.uint8Array(r.x).toBase64Url(),y:q.uint8Array(r.y).toBase64Url()};return n.kid=await G({jwk:n}),n}static async bytesToPublicKey({publicKeyBytes:e}){let r=await t.getCurvePoint({keyBytes:e}),n={kty:"EC",crv:"P-256",x:q.uint8Array(r.x).toBase64Url(),y:q.uint8Array(r.y).toBase64Url()};return n.kid=await G({jwk:n}),n}static async compressPublicKey({publicKeyBytes:e}){return Ne.ProjectivePoint.fromHex(e).toRawBytes(!0)}static async computePublicKey({key:e}){let r=await t.privateKeyToBytes({privateKey:e}),n=await t.getCurvePoint({keyBytes:r}),i={kty:"EC",crv:"P-256",x:q.uint8Array(n.x).toBase64Url(),y:q.uint8Array(n.y).toBase64Url()};return i.kid=await G({jwk:i}),i}static async convertDerToCompactSignature({derSignature:e}){return Ne.Signature.fromDER(e).toCompactRawBytes()}static async decompressPublicKey({publicKeyBytes:e}){return Ne.ProjectivePoint.fromHex(e).toRawBytes(!1)}static async generateKey(){let e=Ne.utils.randomPrivateKey(),r=await t.bytesToPrivateKey({privateKeyBytes:e});return r.kid=await G({jwk:r}),r}static async getPublicKey({key:e}){if(!(Et(e)&&e.crv==="P-256"))throw new Error("Secp256r1: The provided key is not a 'P-256' private JWK.");let{d:r,...n}=e;return n.kid??=await G({jwk:n}),n}static async privateKeyToBytes({privateKey:e}){if(!Et(e))throw new Error("Secp256r1: The provided key is not a valid EC private key.");return q.base64Url(e.d).toUint8Array()}static async publicKeyToBytes({publicKey:e}){if(!(jn(e)&&e.y))throw new Error("Secp256r1: The provided key is not a valid EC public key.");let r=new Uint8Array([4]),n=q.base64Url(e.x).toUint8Array(),i=q.base64Url(e.y).toUint8Array();return new Uint8Array([...r,...n,...i])}static async sharedSecret({privateKeyA:e,publicKeyB:r}){if("x"in e&&"x"in r&&e.x===r.x)throw new Error("Secp256r1: ECDH shared secret cannot be computed from a single key pair's public and private keys.");let n=await t.privateKeyToBytes({privateKey:e}),i=await t.publicKeyToBytes({publicKey:r});return Ne.getSharedSecret(n,i,!0).slice(1)}static async sign({data:e,key:r}){let n=await t.privateKeyToBytes({privateKey:r}),i=xt(e);return Ne.sign(i,n).toCompactRawBytes()}static async validatePrivateKey({privateKeyBytes:e}){return Ne.utils.isValidPrivateKey(e)}static async validatePublicKey({publicKeyBytes:e}){try{Ne.ProjectivePoint.fromHex(e).assertValidity()}catch{return!1}return!0}static async verify({key:e,signature:r,data:n}){let i=await t.publicKeyToBytes({publicKey:e}),o=xt(n);return Ne.verify(r,o,i,{lowS:!1})}static async getCurvePoint({keyBytes:e}){e.byteLength===32&&(e=Ne.getPublicKey(e));let r=Ne.ProjectivePoint.fromHex(e),n=Ue(r.x,32),i=Ue(r.y,32);return{x:n,y:i}}};var Oi=class extends He{async computePublicKey({key:e}){if(!Et(e))throw new TypeError("Invalid key provided. Must be an elliptic curve (EC) private key.");switch(e.crv){case"secp256k1":{let r=await hr.computePublicKey({key:e});return r.alg="ES256K",r}case"P-256":{let r=await pr.computePublicKey({key:e});return r.alg="ES256",r}default:throw new Error(`Unsupported curve: ${e.crv}`)}}async generateKey({algorithm:e}){switch(e){case"ES256K":case"secp256k1":{let r=await hr.generateKey();return r.alg="ES256K",r}case"ES256":case"secp256r1":{let r=await pr.generateKey();return r.alg="ES256",r}}}async getPublicKey({key:e}){if(!Et(e))throw new TypeError("Invalid key provided. Must be an elliptic curve (EC) private key.");switch(e.crv){case"secp256k1":{let r=await hr.getPublicKey({key:e});return r.alg="ES256K",r}case"P-256":{let r=await pr.getPublicKey({key:e});return r.alg="ES256",r}default:throw new Error(`Unsupported curve: ${e.crv}`)}}async sign({key:e,data:r}){if(!Et(e))throw new TypeError("Invalid key provided. Must be an elliptic curve (EC) private key.");switch(e.crv){case"secp256k1":return await hr.sign({key:e,data:r});case"P-256":return await pr.sign({key:e,data:r});default:throw new Error(`Unsupported curve: ${e.crv}`)}}async verify({key:e,signature:r,data:n}){if(!jn(e))throw new TypeError("Invalid key provided. Must be an elliptic curve (EC) public key.");switch(e.crv){case"secp256k1":return await hr.verify({key:e,signature:r,data:n});case"P-256":return await pr.verify({key:e,signature:r,data:n});default:throw new Error(`Unsupported curve: ${e.crv}`)}}};var ws=BigInt(4294967295),Bf=BigInt(32);function by(t,e=!1){return e?{h:Number(t&ws),l:Number(t>>Bf&ws)}:{h:Number(t>>Bf&ws)|0,l:Number(t&ws)|0}}function N2(t,e=!1){let r=new Uint32Array(t.length),n=new Uint32Array(t.length);for(let i=0;i<t.length;i++){let{h:o,l:s}=by(t[i],e);[r[i],n[i]]=[o,s]}return[r,n]}var D2=(t,e)=>BigInt(t>>>0)<<Bf|BigInt(e>>>0),M2=(t,e,r)=>t>>>r,q2=(t,e,r)=>t<<32-r|e>>>r,j2=(t,e,r)=>t>>>r|e<<32-r,F2=(t,e,r)=>t<<32-r|e>>>r,$2=(t,e,r)=>t<<64-r|e>>>r-32,V2=(t,e,r)=>t>>>r-32|e<<64-r,H2=(t,e)=>e,G2=(t,e)=>t,W2=(t,e,r)=>t<<r|e>>>32-r,J2=(t,e,r)=>e<<r|t>>>32-r,z2=(t,e,r)=>e<<r-32|t>>>64-r,Y2=(t,e,r)=>t<<r-32|e>>>64-r;function Z2(t,e,r,n){let i=(e>>>0)+(n>>>0);return{h:t+r+(i/2**32|0)|0,l:i|0}}var X2=(t,e,r)=>(t>>>0)+(e>>>0)+(r>>>0),Q2=(t,e,r,n)=>e+r+n+(t/2**32|0)|0,e_=(t,e,r,n)=>(t>>>0)+(e>>>0)+(r>>>0)+(n>>>0),t_=(t,e,r,n,i)=>e+r+n+i+(t/2**32|0)|0,r_=(t,e,r,n,i)=>(t>>>0)+(e>>>0)+(r>>>0)+(n>>>0)+(i>>>0),n_=(t,e,r,n,i,o)=>e+r+n+i+o+(t/2**32|0)|0;var i_={fromBig:by,split:N2,toBig:D2,shrSH:M2,shrSL:q2,rotrSH:j2,rotrSL:F2,rotrBH:$2,rotrBL:V2,rotr32H:H2,rotr32L:G2,rotlSH:W2,rotlSL:J2,rotlBH:z2,rotlBL:Y2,add:Z2,add3L:X2,add3H:Q2,add4L:e_,add4H:t_,add5H:n_,add5L:r_},W=i_;var[o_,s_]=W.split(["0x428a2f98d728ae22","0x7137449123ef65cd","0xb5c0fbcfec4d3b2f","0xe9b5dba58189dbbc","0x3956c25bf348b538","0x59f111f1b605d019","0x923f82a4af194f9b","0xab1c5ed5da6d8118","0xd807aa98a3030242","0x12835b0145706fbe","0x243185be4ee4b28c","0x550c7dc3d5ffb4e2","0x72be5d74f27b896f","0x80deb1fe3b1696b1","0x9bdc06a725c71235","0xc19bf174cf692694","0xe49b69c19ef14ad2","0xefbe4786384f25e3","0x0fc19dc68b8cd5b5","0x240ca1cc77ac9c65","0x2de92c6f592b0275","0x4a7484aa6ea6e483","0x5cb0a9dcbd41fbd4","0x76f988da831153b5","0x983e5152ee66dfab","0xa831c66d2db43210","0xb00327c898fb213f","0xbf597fc7beef0ee4","0xc6e00bf33da88fc2","0xd5a79147930aa725","0x06ca6351e003826f","0x142929670a0e6e70","0x27b70a8546d22ffc","0x2e1b21385c26c926","0x4d2c6dfc5ac42aed","0x53380d139d95b3df","0x650a73548baf63de","0x766a0abb3c77b2a8","0x81c2c92e47edaee6","0x92722c851482353b","0xa2bfe8a14cf10364","0xa81a664bbc423001","0xc24b8b70d0f89791","0xc76c51a30654be30","0xd192e819d6ef5218","0xd69906245565a910","0xf40e35855771202a","0x106aa07032bbd1b8","0x19a4c116b8d2d0c8","0x1e376c085141ab53","0x2748774cdf8eeb99","0x34b0bcb5e19b48a8","0x391c0cb3c5c95a63","0x4ed8aa4ae3418acb","0x5b9cca4f7763e373","0x682e6ff3d6b2b8a3","0x748f82ee5defb2fc","0x78a5636f43172f60","0x84c87814a1f0ab72","0x8cc702081a6439ec","0x90befffa23631e28","0xa4506cebde82bde9","0xbef9a3f7b2c67915","0xc67178f2e372532b","0xca273eceea26619c","0xd186b8c721c0c207","0xeada7dd6cde0eb1e","0xf57d4f7fee6ed178","0x06f067aa72176fba","0x0a637dc5a2c898a6","0x113f9804bef90dae","0x1b710b35131c471b","0x28db77f523047d84","0x32caab7b40c72493","0x3c9ebe0a15c9bebc","0x431d67c49c100d4c","0x4cc5d4becb3e42b6","0x597f299cfc657e2a","0x5fcb6fab3ad6faec","0x6c44198c4a475817"].map(t=>BigInt(t))),yr=new Uint32Array(80),wr=new Uint32Array(80),Tf=class extends Mn{constructor(){super(128,64,16,!1),this.Ah=1779033703,this.Al=-205731576,this.Bh=-1150833019,this.Bl=-2067093701,this.Ch=1013904242,this.Cl=-23791573,this.Dh=-1521486534,this.Dl=1595750129,this.Eh=1359893119,this.El=-1377402159,this.Fh=-1694144372,this.Fl=725511199,this.Gh=528734635,this.Gl=-79577749,this.Hh=1541459225,this.Hl=327033209}get(){let{Ah:e,Al:r,Bh:n,Bl:i,Ch:o,Cl:s,Dh:a,Dl:c,Eh:f,El:u,Fh:l,Fl:p,Gh:h,Gl:y,Hh:d,Hl:w}=this;return[e,r,n,i,o,s,a,c,f,u,l,p,h,y,d,w]}set(e,r,n,i,o,s,a,c,f,u,l,p,h,y,d,w){this.Ah=e|0,this.Al=r|0,this.Bh=n|0,this.Bl=i|0,this.Ch=o|0,this.Cl=s|0,this.Dh=a|0,this.Dl=c|0,this.Eh=f|0,this.El=u|0,this.Fh=l|0,this.Fl=p|0,this.Gh=h|0,this.Gl=y|0,this.Hh=d|0,this.Hl=w|0}process(e,r){for(let g=0;g<16;g++,r+=4)yr[g]=e.getUint32(r),wr[g]=e.getUint32(r+=4);for(let g=16;g<80;g++){let _=yr[g-15]|0,E=wr[g-15]|0,B=W.rotrSH(_,E,1)^W.rotrSH(_,E,8)^W.shrSH(_,E,7),T=W.rotrSL(_,E,1)^W.rotrSL(_,E,8)^W.shrSL(_,E,7),k=yr[g-2]|0,R=wr[g-2]|0,C=W.rotrSH(k,R,19)^W.rotrBH(k,R,61)^W.shrSH(k,R,6),L=W.rotrSL(k,R,19)^W.rotrBL(k,R,61)^W.shrSL(k,R,6),j=W.add4L(T,L,wr[g-7],wr[g-16]),K=W.add4H(j,B,C,yr[g-7],yr[g-16]);yr[g]=K|0,wr[g]=j|0}let{Ah:n,Al:i,Bh:o,Bl:s,Ch:a,Cl:c,Dh:f,Dl:u,Eh:l,El:p,Fh:h,Fl:y,Gh:d,Gl:w,Hh:m,Hl:A}=this;for(let g=0;g<80;g++){let _=W.rotrSH(l,p,14)^W.rotrSH(l,p,18)^W.rotrBH(l,p,41),E=W.rotrSL(l,p,14)^W.rotrSL(l,p,18)^W.rotrBL(l,p,41),B=l&h^~l&d,T=p&y^~p&w,k=W.add5L(A,E,T,s_[g],wr[g]),R=W.add5H(k,m,_,B,o_[g],yr[g]),C=k|0,L=W.rotrSH(n,i,28)^W.rotrBH(n,i,34)^W.rotrBH(n,i,39),j=W.rotrSL(n,i,28)^W.rotrBL(n,i,34)^W.rotrBL(n,i,39),K=n&o^n&a^o&a,Y=i&s^i&c^s&c;m=d|0,A=w|0,d=h|0,w=y|0,h=l|0,y=p|0,{h:l,l:p}=W.add(f|0,u|0,R|0,C|0),f=a|0,u=c|0,a=o|0,c=s|0,o=n|0,s=i|0;let S=W.add3L(C,j,Y);n=W.add3H(S,R,L,K),i=S|0}({h:n,l:i}=W.add(this.Ah|0,this.Al|0,n|0,i|0)),{h:o,l:s}=W.add(this.Bh|0,this.Bl|0,o|0,s|0),{h:a,l:c}=W.add(this.Ch|0,this.Cl|0,a|0,c|0),{h:f,l:u}=W.add(this.Dh|0,this.Dl|0,f|0,u|0),{h:l,l:p}=W.add(this.Eh|0,this.El|0,l|0,p|0),{h,l:y}=W.add(this.Fh|0,this.Fl|0,h|0,y|0),{h:d,l:w}=W.add(this.Gh|0,this.Gl|0,d|0,w|0),{h:m,l:A}=W.add(this.Hh|0,this.Hl|0,m|0,A|0),this.set(n,i,o,s,a,c,f,u,l,p,h,y,d,w,m,A)}roundClean(){yr.fill(0),wr.fill(0)}destroy(){this.buffer.fill(0),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}};var kf=cs(()=>new Tf);var it=BigInt(0),De=BigInt(1),ms=BigInt(2),a_=BigInt(8),c_={zip215:!0};function f_(t){let e=Li(t);return Ge(t,{hash:"function",a:"bigint",d:"bigint",randomBytes:"function"},{adjustScalarBytes:"function",domain:"function",uvRatio:"function",mapToCurve:"function"}),Object.freeze({...e})}function bs(t){let e=f_(t),{Fp:r,n,prehash:i,hash:o,randomBytes:s,nByteLength:a,h:c}=e,f=ms<<BigInt(a*8)-De,u=r.create,l=e.uvRatio||((v,b)=>{try{return{isValid:!0,value:r.sqrt(v*r.inv(b))}}catch{return{isValid:!1,value:it}}}),p=e.adjustScalarBytes||(v=>v),h=e.domain||((v,b,P)=>{if(b.length||P)throw new Error("Contexts/pre-hash are not supported");return v}),y=v=>typeof v=="bigint"&&it<v,d=(v,b)=>y(v)&&y(b)&&v<b,w=v=>v===it||d(v,f);function m(v,b){if(d(v,b))return v;throw new Error(`Expected valid scalar < ${b}, got ${typeof v} ${v}`)}function A(v){return v===it?v:m(v,n)}let g=new Map;function _(v){if(!(v instanceof E))throw new Error("ExtendedPoint expected")}class E{constructor(b,P,U,O){if(this.ex=b,this.ey=P,this.ez=U,this.et=O,!w(b))throw new Error("x required");if(!w(P))throw new Error("y required");if(!w(U))throw new Error("z required");if(!w(O))throw new Error("t required")}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static fromAffine(b){if(b instanceof E)throw new Error("extended point not allowed");let{x:P,y:U}=b||{};if(!w(P)||!w(U))throw new Error("invalid affine point");return new E(P,U,De,u(P*U))}static normalizeZ(b){let P=r.invertBatch(b.map(U=>U.ez));return b.map((U,O)=>U.toAffine(P[O])).map(E.fromAffine)}_setWindowSize(b){this._WINDOW_SIZE=b,g.delete(this)}assertValidity(){let{a:b,d:P}=e;if(this.is0())throw new Error("bad point: ZERO");let{ex:U,ey:O,ez:F,et:$}=this,Z=u(U*U),V=u(O*O),H=u(F*F),ne=u(H*H),te=u(Z*b),be=u(H*u(te+V)),ge=u(ne+u(P*u(Z*V)));if(be!==ge)throw new Error("bad point: equation left != right (1)");let de=u(U*O),_e=u(F*$);if(de!==_e)throw new Error("bad point: equation left != right (2)")}equals(b){_(b);let{ex:P,ey:U,ez:O}=this,{ex:F,ey:$,ez:Z}=b,V=u(P*Z),H=u(F*O),ne=u(U*Z),te=u($*O);return V===H&&ne===te}is0(){return this.equals(E.ZERO)}negate(){return new E(u(-this.ex),this.ey,this.ez,u(-this.et))}double(){let{a:b}=e,{ex:P,ey:U,ez:O}=this,F=u(P*P),$=u(U*U),Z=u(ms*u(O*O)),V=u(b*F),H=P+U,ne=u(u(H*H)-F-$),te=V+$,be=te-Z,ge=V-$,de=u(ne*be),_e=u(te*ge),St=u(ne*ge),gr=u(be*te);return new E(de,_e,gr,St)}add(b){_(b);let{a:P,d:U}=e,{ex:O,ey:F,ez:$,et:Z}=this,{ex:V,ey:H,ez:ne,et:te}=b;if(P===BigInt(-1)){let $f=u((F-O)*(H+V)),Vf=u((F+O)*(H-V)),Ts=u(Vf-$f);if(Ts===it)return this.double();let Hf=u($*ms*te),Gf=u(Z*ms*ne),Wf=Gf+Hf,Jf=Vf+$f,zf=Gf-Hf,n0=u(Wf*Ts),i0=u(Jf*zf),o0=u(Wf*zf),s0=u(Ts*Jf);return new E(n0,i0,s0,o0)}let be=u(O*V),ge=u(F*H),de=u(Z*U*te),_e=u($*ne),St=u((O+F)*(V+H)-be-ge),gr=_e-de,Hn=_e+de,Ff=u(ge-P*be),Qy=u(St*gr),e0=u(Hn*Ff),t0=u(St*Ff),r0=u(gr*Hn);return new E(Qy,e0,r0,t0)}subtract(b){return this.add(b.negate())}wNAF(b){return k.wNAFCached(this,g,b,E.normalizeZ)}multiply(b){let{p:P,f:U}=this.wNAF(m(b,n));return E.normalizeZ([P,U])[0]}multiplyUnsafe(b){let P=A(b);return P===it?T:this.equals(T)||P===De?this:this.equals(B)?this.wNAF(P).p:k.unsafeLadder(this,P)}isSmallOrder(){return this.multiplyUnsafe(c).is0()}isTorsionFree(){return k.unsafeLadder(this,n).is0()}toAffine(b){let{ex:P,ey:U,ez:O}=this,F=this.is0();b==null&&(b=F?a_:r.inv(O));let $=u(P*b),Z=u(U*b),V=u(O*b);if(F)return{x:it,y:De};if(V!==De)throw new Error("invZ was invalid");return{x:$,y:Z}}clearCofactor(){let{h:b}=e;return b===De?this:this.multiplyUnsafe(b)}static fromHex(b,P=!1){let{d:U,a:O}=e,F=r.BYTES;b=oe("pointHex",b,F);let $=b.slice(),Z=b[F-1];$[F-1]=Z&-129;let V=nt($);V===it||(P?m(V,f):m(V,r.ORDER));let H=u(V*V),ne=u(H-De),te=u(U*H-O),{isValid:be,value:ge}=l(ne,te);if(!be)throw new Error("Point.fromHex: invalid y coordinate");let de=(ge&De)===De,_e=(Z&128)!==0;if(!P&&ge===it&&_e)throw new Error("Point.fromHex: x=0 and x_0=1");return _e!==de&&(ge=u(-ge)),E.fromAffine({x:ge,y:V})}static fromPrivateKey(b){return L(b).point}toRawBytes(){let{x:b,y:P}=this.toAffine(),U=Vt(P,r.BYTES);return U[U.length-1]|=b&De?128:0,U}toHex(){return Ft(this.toRawBytes())}}E.BASE=new E(e.Gx,e.Gy,De,u(e.Gx*e.Gy)),E.ZERO=new E(it,De,De,it);let{BASE:B,ZERO:T}=E,k=hs(E,a*8);function R(v){return ee(v,n)}function C(v){return R(nt(v))}function L(v){let b=a;v=oe("private key",v,b);let P=oe("hashed private key",o(v),2*b),U=p(P.slice(0,b)),O=P.slice(b,2*b),F=C(U),$=B.multiply(F),Z=$.toRawBytes();return{head:U,prefix:O,scalar:F,point:$,pointBytes:Z}}function j(v){return L(v).pointBytes}function K(v=new Uint8Array,...b){let P=Ht(...b);return C(o(h(P,oe("context",v),!!i)))}function Y(v,b,P={}){v=oe("message",v),i&&(v=i(v));let{prefix:U,scalar:O,pointBytes:F}=L(b),$=K(P.context,U,v),Z=B.multiply($).toRawBytes(),V=K(P.context,Z,F,v),H=R($+V*O);A(H);let ne=Ht(Z,Vt(H,r.BYTES));return oe("result",ne,a*2)}let S=c_;function I(v,b,P,U=S){let{context:O,zip215:F}=U,$=r.BYTES;v=oe("signature",v,2*$),b=oe("message",b),i&&(b=i(b));let Z=nt(v.slice($,2*$)),V,H,ne;try{V=E.fromHex(P,F),H=E.fromHex(v.slice(0,$),F),ne=B.multiplyUnsafe(Z)}catch{return!1}if(!F&&V.isSmallOrder())return!1;let te=K(O,H.toRawBytes(),V.toRawBytes(),b);return H.add(V.multiplyUnsafe(te)).subtract(ne).clearCofactor().equals(E.ZERO)}return B._setWindowSize(8),{CURVE:e,getPublicKey:j,sign:Y,verify:I,ExtendedPoint:E,utils:{getExtendedPublicKey:L,randomPrivateKey:()=>s(r.BYTES),precompute(v=8,b=E.BASE){return b._setWindowSize(v),b.multiply(BigInt(3)),b}}}}var Ki=BigInt(0),Pf=BigInt(1);function u_(t){return Ge(t,{a:"bigint"},{montgomeryBits:"isSafeInteger",nByteLength:"isSafeInteger",adjustScalarBytes:"function",domain:"function",powPminus2:"function",Gu:"bigint"}),Object.freeze({...t})}function gy(t){let e=u_(t),{P:r}=e,n=g=>ee(g,r),i=e.montgomeryBits,o=Math.ceil(i/8),s=e.nByteLength,a=e.adjustScalarBytes||(g=>g),c=e.powPminus2||(g=>mf(g,r-BigInt(2),r));function f(g,_,E){let B=n(g*(_-E));return _=n(_-B),E=n(E+B),[_,E]}function u(g){if(typeof g=="bigint"&&Ki<=g&&g<r)return g;throw new Error("Expected valid scalar 0 < scalar < CURVE.P")}let l=(e.a-BigInt(2))/BigInt(4);function p(g,_){let E=u(g),B=u(_),T=E,k=Pf,R=Ki,C=E,L=Pf,j=Ki,K;for(let S=BigInt(i-1);S>=Ki;S--){let I=B>>S&Pf;j^=I,K=f(j,k,C),k=K[0],C=K[1],K=f(j,R,L),R=K[0],L=K[1],j=I;let N=k+R,v=n(N*N),b=k-R,P=n(b*b),U=v-P,O=C+L,F=C-L,$=n(F*N),Z=n(O*b),V=$+Z,H=$-Z;C=n(V*V),L=n(T*n(H*H)),k=n(v*P),R=n(U*(v+n(l*U)))}K=f(j,k,C),k=K[0],C=K[1],K=f(j,R,L),R=K[0],L=K[1];let Y=c(R);return n(k*Y)}function h(g){return Vt(n(g),o)}function y(g){let _=oe("u coordinate",g,o);return s===32&&(_[31]&=127),nt(_)}function d(g){let _=oe("scalar",g),E=_.length;if(E!==o&&E!==s)throw new Error(`Expected ${o} or ${s} bytes, got ${E}`);return nt(a(_))}function w(g,_){let E=y(_),B=d(g),T=p(E,B);if(T===Ki)throw new Error("Invalid private or public key received");return h(T)}let m=h(e.Gu);function A(g){return w(g,m)}return{scalarMult:w,scalarMultBase:A,getSharedSecret:(g,_)=>w(g,_),getPublicKey:g=>A(g),utils:{randomPrivateKey:()=>e.randomBytes(e.nByteLength)},GuBytes:m}}var Ni=BigInt("57896044618658097711785492504343953926634992332820282019728792003956564819949"),xy=BigInt("19681161376707505956807079304988542015446066515923890162744021073123829784752"),F8=BigInt(0),l_=BigInt(1),If=BigInt(2),d_=BigInt(5),Ey=BigInt(10),h_=BigInt(20),p_=BigInt(40),_y=BigInt(80);function Ay(t){let e=Ni,n=t*t%e*t%e,i=se(n,If,e)*n%e,o=se(i,l_,e)*t%e,s=se(o,d_,e)*o%e,a=se(s,Ey,e)*s%e,c=se(a,h_,e)*a%e,f=se(c,p_,e)*c%e,u=se(f,_y,e)*f%e,l=se(u,_y,e)*f%e,p=se(l,Ey,e)*s%e;return{pow_p_5_8:se(p,If,e)*t%e,b2:n}}function Sy(t){return t[0]&=248,t[31]&=127,t[31]|=64,t}function y_(t,e){let r=Ni,n=ee(e*e*e,r),i=ee(n*n*e,r),o=Ay(t*i).pow_p_5_8,s=ee(t*n*o,r),a=ee(e*s*s,r),c=s,f=ee(s*xy,r),u=a===t,l=a===ee(-t,r),p=a===ee(-t*xy,r);return u&&(s=c),(l||p)&&(s=f),sy(s,r)&&(s=ee(-s,r)),{isValid:u||l,value:s}}var Je=qn(Ni,void 0,!0),Di={a:BigInt(-1),d:BigInt("37095705934669439343138083508754565189542113879843219016388785533085940283555"),Fp:Je,n:BigInt("7237005577332262213973186563042994240857116359379907606001950938285454250989"),h:BigInt(8),Gx:BigInt("15112221349535400772501151409588531511454012693041857206046113283949847762202"),Gy:BigInt("46316835694926478169428394003475163141307993866256225615783033603165251855960"),hash:kf,randomBytes:Ui,adjustScalarBytes:Sy,uvRatio:y_},mr=bs(Di);function vy(t,e,r){if(e.length>255)throw new Error("Context is too big");return as(lf("SigEd25519 no Ed25519 collisions"),new Uint8Array([r?1:0,e.length]),e,t)}var $8=bs({...Di,domain:vy}),V8=bs({...Di,domain:vy,prehash:kf}),tn=gy({P:Ni,a:BigInt(486662),montgomeryBits:255,nByteLength:32,Gu:BigInt(9),powPminus2:t=>{let e=Ni,{pow_p_5_8:r,b2:n}=Ay(t);return ee(se(r,BigInt(3),e)*n,e)},adjustScalarBytes:Sy,randomBytes:Ui});function By(t){let{y:e}=mr.ExtendedPoint.fromHex(t),r=BigInt(1);return Je.toBytes(Je.create((r+e)*Je.inv(r-e)))}function Ty(t){let e=Di.hash(t.subarray(0,32));return Di.adjustScalarBytes(e).subarray(0,32)}var w_=(Je.ORDER+BigInt(3))/BigInt(8),H8=Je.pow(If,w_),G8=Je.sqrt(Je.neg(Je.ONE)),W8=(Je.ORDER-BigInt(5))/BigInt(8),J8=BigInt(486662);var z8=ay(Je,Je.neg(BigInt(486664)));var Y8=BigInt("25063068953384623474111414158702152701244531502492656460079210482610430750235"),Z8=BigInt("54469307008909316920995813868745141605393597292927456921205312896311721017578"),X8=BigInt("1159843021668779879193775521855586647937357759715417654439879720876111806838"),Q8=BigInt("40440834346308536858101042469323190826248399146238708352240133220865137265952");var eB=BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff");var br=class t{static async bytesToPrivateKey({privateKeyBytes:e}){let r=mr.getPublicKey(e),n={crv:"Ed25519",d:q.uint8Array(e).toBase64Url(),kty:"OKP",x:q.uint8Array(r).toBase64Url()};return n.kid=await G({jwk:n}),n}static async bytesToPublicKey({publicKeyBytes:e}){let r={kty:"OKP",crv:"Ed25519",x:q.uint8Array(e).toBase64Url()};return r.kid=await G({jwk:r}),r}static async computePublicKey({key:e}){let r=await t.privateKeyToBytes({privateKey:e}),n=mr.getPublicKey(r),i={kty:"OKP",crv:"Ed25519",x:q.uint8Array(n).toBase64Url()};return i.kid=await G({jwk:i}),i}static async convertPrivateKeyToX25519({privateKey:e}){let r=await t.privateKeyToBytes({privateKey:e}),n=Ty(r),i=tn.getPublicKey(n),o={kty:"OKP",crv:"X25519",d:q.uint8Array(n).toBase64Url(),x:q.uint8Array(i).toBase64Url()};return o.kid=await G({jwk:o}),o}static async convertPublicKeyToX25519({publicKey:e}){let r=await t.publicKeyToBytes({publicKey:e});if(!await t.validatePublicKey({publicKeyBytes:r}))throw new Error("Ed25519: Invalid public key.");let i=By(r),o={kty:"OKP",crv:"X25519",x:q.uint8Array(i).toBase64Url()};return o.kid=await G({jwk:o}),o}static async generateKey(){let e=mr.utils.randomPrivateKey(),r=await t.bytesToPrivateKey({privateKeyBytes:e});return r.kid=await G({jwk:r}),r}static async getPublicKey({key:e}){if(!(_t(e)&&e.crv==="Ed25519"))throw new Error("Ed25519: The provided key is not an Ed25519 private JWK.");let{d:r,...n}=e;return n.kid??=await G({jwk:n}),n}static async privateKeyToBytes({privateKey:e}){if(!_t(e))throw new Error("Ed25519: The provided key is not a valid OKP private key.");return q.base64Url(e.d).toUint8Array()}static async publicKeyToBytes({publicKey:e}){if(!Fn(e))throw new Error("Ed25519: The provided key is not a valid OKP public key.");return q.base64Url(e.x).toUint8Array()}static async sign({key:e,data:r}){let n=await t.privateKeyToBytes({privateKey:e});return mr.sign(r,n)}static async validatePublicKey({publicKeyBytes:e}){try{mr.ExtendedPoint.fromHex(e).assertValidity()}catch{return!1}return!0}static async verify({key:e,signature:r,data:n}){let i=await t.publicKeyToBytes({publicKey:e});return mr.verify(r,n,i)}};var gs=class extends He{async computePublicKey({key:e}){if(!_t(e))throw new TypeError("Invalid key provided. Must be an octet key pair (OKP) private key.");switch(e.crv){case"Ed25519":{let r=await br.computePublicKey({key:e});return r.alg="EdDSA",r}default:throw new Error(`Unsupported curve: ${e.crv}`)}}async generateKey({algorithm:e}){switch(e){case"Ed25519":{let r=await br.generateKey();return r.alg="EdDSA",r}}}async getPublicKey({key:e}){if(!_t(e))throw new TypeError("Invalid key provided. Must be an octet key pair (OKP) private key.");switch(e.crv){case"Ed25519":{let r=await br.getPublicKey({key:e});return r.alg="EdDSA",r}default:throw new Error(`Unsupported curve: ${e.crv}`)}}async sign({key:e,data:r}){if(!_t(e))throw new TypeError("Invalid key provided. Must be an octet key pair (OKP) private key.");switch(e.crv){case"Ed25519":return await br.sign({key:e,data:r});default:throw new Error(`Unsupported curve: ${e.crv}`)}}async verify({key:e,signature:r,data:n}){if(!Fn(e))throw new TypeError("Invalid key provided. Must be an octet key pair (OKP) public key.");switch(e.crv){case"Ed25519":return await br.verify({key:e,signature:r,data:n});default:throw new Error(`Unsupported curve: ${e.crv}`)}}};var Rf={Ed25519:{implementation:gs,names:["Ed25519"]},secp256k1:{implementation:Oi,names:["ES256K","secp256k1"]},secp256r1:{implementation:Oi,names:["ES256","secp256r1"]},"SHA-256":{implementation:is,names:["SHA-256"]}},ky=class{constructor(e){this._algorithmInstances=new Map;this._keyStore=e?.keyStore??new Eo}async digest({algorithm:e,data:r}){return await this.getAlgorithm({algorithm:e}).digest({algorithm:e,data:r})}async exportKey({keyUri:e}){return await this.getPrivateKey({keyUri:e})}async generateKey({algorithm:e}){let n=await this.getAlgorithm({algorithm:e}).generateKey({algorithm:e});if(n?.kid===void 0)throw new Error("Generated key is missing a required property: kid");let i=`${vf}${n.kid}`;return await this._keyStore.set(i,n),i}async getKeyUri({key:e}){let r=await G({jwk:e});return`${vf}${r}`}async getPublicKey({keyUri:e}){let r=await this.getPrivateKey({keyUri:e}),n=this.getAlgorithmName({key:r});return await this.getAlgorithm({algorithm:n}).getPublicKey({key:r})}async importKey({key:e}){if(!wy(e))throw new TypeError("Invalid key provided. Must be a private key in JWK format.");let r=structuredClone(e);r.kid??=await G({jwk:r});let n=await this.getKeyUri({key:r});return await this._keyStore.set(n,r),n}async sign({keyUri:e,data:r}){let n=await this.getPrivateKey({keyUri:e}),i=this.getAlgorithmName({key:n});return this.getAlgorithm({algorithm:i}).sign({data:r,key:n})}async verify({key:e,signature:r,data:n}){let i=this.getAlgorithmName({key:e});return this.getAlgorithm({algorithm:i}).verify({key:e,signature:r,data:n})}getAlgorithm({algorithm:e}){let r=Rf[e]?.implementation;if(!r)throw new Error(`Algorithm not supported: ${e}`);return this._algorithmInstances.has(r)||this._algorithmInstances.set(r,new r),this._algorithmInstances.get(r)}getAlgorithmName({key:e}){let r=e.alg,n=e.crv;for(let i in Rf){let o=Rf[i];if(r&&o.names.includes(r))return i;if(n&&o.names.includes(n))return i}throw new Error(`Unable to determine algorithm based on provided input: alg=${r}, crv=${n}`)}async getPrivateKey({keyUri:e}){let r=await this._keyStore.get(e);if(!r)throw new Error(`Key not found: ${e}`);return r}};var Py=class t{static getJoseSignatureAlgorithmFromPublicKey(e){let r={Ed25519:"EdDSA","P-256":"ES256","P-384":"ES384","P-521":"ES512",secp256k1:"ES256K"};if(e.alg&&Object.values(r).includes(e.alg))return e.alg;if(e.crv&&Object.keys(r).includes(e.crv))return r[e.crv];throw new Error(`Unable to determine algorithm based on provided input: alg=${e.alg}, crv=${e.crv}. Supported 'alg' values: ${Object.values(r).join(", ")}. Supported 'crv' values: ${Object.keys(r).join(", ")}.`)}static randomBytes(e){return Wp(e)}static randomUuid(){return qt.randomUUID()}static randomPin({length:e}){if(3>e||e>10)throw new Error("randomPin() can securely generate a PIN between 3 to 10 digits.");let r=Math.pow(10,e)-1,n;if(e<=6){let i=Math.pow(10,e);do{let o=t.randomBytes(Math.ceil(e/2));n=new DataView(o.buffer).getUint16(0,!1)%i}while(n>r)}else{let i=Math.pow(10,10);do{let o=t.randomBytes(4);n=new DataView(o.buffer).getUint32(0,!1)%i}while(n>r)}return n.toString().padStart(e,"0")}};var xs=typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0;function ke(){if(xs&&typeof xs.subtle=="object"&&xs.subtle!=null)return xs.subtle;throw new Error("crypto.subtle must be defined")}var Mi=128,Iy=[128,192,256],Es=Mi,$n=class{static async bytesToPrivateKey({privateKeyBytes:e}){let r={k:q.uint8Array(e).toBase64Url(),kty:"oct"};return r.kid=await G({jwk:r}),r}static async decrypt({key:e,data:r,counter:n,length:i}){if(n.byteLength!==Mi/8)throw new TypeError(`The counter must be ${Mi} bits in length`);if(i===0||i>Es)throw new TypeError(`The 'length' property must be in the range 1 to ${Es}`);let o=ke(),s=await o.importKey("jwk",e,{name:"AES-CTR"},!0,["decrypt"]),a=await o.decrypt({name:"AES-CTR",counter:n,length:i},s,r);return new Uint8Array(a)}static async encrypt({key:e,data:r,counter:n,length:i}){if(n.byteLength!==Mi/8)throw new TypeError(`The counter must be ${Mi} bits in length`);if(i===0||i>Es)throw new TypeError(`The 'length' property must be in the range 1 to ${Es}`);let o=ke(),s=await o.importKey("jwk",e,{name:"AES-CTR"},!0,["encrypt","decrypt"]),a=await o.encrypt({name:"AES-CTR",counter:n,length:i},s,r);return new Uint8Array(a)}static async generateKey({length:e}){if(!Iy.includes(e))throw new RangeError(`The key length is invalid: Must be ${Iy.join(", ")} bits`);let r=ke(),n=await r.generateKey({name:"AES-CTR",length:e},!0,["encrypt"]),{ext:i,key_ops:o,...s}=await r.exportKey("jwk",n);return s.kid=await G({jwk:s}),s}static async privateKeyToBytes({privateKey:e}){if(!dr(e))throw new Error("AesCtr: The provided key is not a valid oct private key.");return q.base64Url(e.k).toUint8Array()}};var Ry=class extends He{async decrypt(e){return $n.decrypt(e)}async encrypt(e){return $n.encrypt(e)}async generateKey({algorithm:e}){let r={A128CTR:128,A192CTR:192,A256CTR:256}[e],n=await $n.generateKey({length:r});return n.alg=e,n}};function qi(t){if(!Number.isSafeInteger(t)||t<0)throw new Error(`positive integer expected, not ${t}`)}function Uf(t){if(typeof t!="boolean")throw new Error(`boolean expected, not ${t}`)}function Cf(t){return t instanceof Uint8Array||t!=null&&typeof t=="object"&&t.constructor.name==="Uint8Array"}function we(t,...e){if(!Cf(t))throw new Error("Uint8Array expected");if(e.length>0&&!e.includes(t.length))throw new Error(`Uint8Array expected of length ${e}, not of length=${t.length}`)}function Lf(t,e=!0){if(t.destroyed)throw new Error("Hash instance has been destroyed");if(e&&t.finished)throw new Error("Hash#digest() has already been called")}function Uy(t,e){we(t);let r=e.outputLen;if(t.length<r)throw new Error(`digestInto() expects output buffer of length at least ${r}`)}var Wt=t=>new Uint32Array(t.buffer,t.byteOffset,Math.floor(t.byteLength/4)),Cy=t=>new DataView(t.buffer,t.byteOffset,t.byteLength),m_=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;if(!m_)throw new Error("Non little-endian hardware is not supported");function b_(t){if(typeof t!="string")throw new Error(`string expected, got ${typeof t}`);return new Uint8Array(new TextEncoder().encode(t))}function _s(t){if(typeof t=="string")t=b_(t);else if(Cf(t))t=t.slice();else throw new Error(`Uint8Array expected, got ${typeof t}`);return t}function Ly(t,e){if(e==null||typeof e!="object")throw new Error("options must be defined");return Object.assign(t,e)}function Oy(t,e){if(t.length!==e.length)return!1;let r=0;for(let n=0;n<t.length;n++)r|=t[n]^e[n];return r===0}var Of=(t,e)=>(Object.assign(e,t),e);function Kf(t,e,r,n){if(typeof t.setBigUint64=="function")return t.setBigUint64(e,r,n);let i=BigInt(32),o=BigInt(4294967295),s=Number(r>>i&o),a=Number(r&o),c=n?4:0,f=n?0:4;t.setUint32(e+c,s,n),t.setUint32(e+f,a,n)}var Ky={async encrypt(t,e,r,n){let i=ke(),o=await i.importKey("raw",t,e,!0,["encrypt"]),s=await i.encrypt(r,o,n);return new Uint8Array(s)},async decrypt(t,e,r,n){let i=ke(),o=await i.importKey("raw",t,e,!0,["decrypt"]),s=await i.decrypt(r,o,n);return new Uint8Array(s)}},At={CBC:"AES-CBC",CTR:"AES-CTR",GCM:"AES-GCM"};function g_(t,e,r){if(t===At.CBC)return{name:At.CBC,iv:e};if(t===At.CTR)return{name:At.CTR,counter:e,length:64};if(t===At.GCM)return r?{name:At.GCM,iv:e,additionalData:r}:{name:At.GCM,iv:e};throw new Error("unknown aes block mode")}function Nf(t){return(e,r,n)=>{we(e),we(r);let i={name:t,length:e.length*8},o=g_(t,r,n);return{encrypt(s){return we(s),Ky.encrypt(e,i,o,s)},decrypt(s){return we(s),Ky.decrypt(e,i,o,s)}}}}var LB=Nf(At.CBC),OB=Nf(At.CTR),KB=Nf(At.GCM);var As=96,Ny=[128,192,256],Ss=[96,104,112,120,128],Vn=class{static async bytesToPrivateKey({privateKeyBytes:e}){let r={k:q.uint8Array(e).toBase64Url(),kty:"oct"};return r.kid=await G({jwk:r}),r}static async decrypt({key:e,data:r,iv:n,additionalData:i,tagLength:o}){if(n.byteLength!==As/8)throw new TypeError(`The initialization vector must be ${As} bits in length`);if(o&&!Ss.includes(o))throw new RangeError(`The tag length is invalid: Must be ${Ss.join(", ")} bits`);let s=ke(),a=await s.importKey("jwk",e,{name:"AES-GCM"},!0,["decrypt"]),c={name:"AES-GCM",iv:n,...o&&{tagLength:o},...i&&{additionalData:i}},f=await s.decrypt(c,a,r);return new Uint8Array(f)}static async encrypt({data:e,iv:r,key:n,additionalData:i,tagLength:o}){if(r.byteLength!==As/8)throw new TypeError(`The initialization vector must be ${As} bits in length`);if(o&&!Ss.includes(o))throw new RangeError(`The tag length is invalid: Must be ${Ss.join(", ")} bits`);let s=ke(),a=await s.importKey("jwk",n,{name:"AES-GCM"},!0,["encrypt"]),c={name:"AES-GCM",iv:r,...o&&{tagLength:o},...i&&{additionalData:i}},f=await s.encrypt(c,a,e);return new Uint8Array(f)}static async generateKey({length:e}){if(!Ny.includes(e))throw new RangeError(`The key length is invalid: Must be ${Ny.join(", ")} bits`);let r=ke(),n=await r.generateKey({name:"AES-GCM",length:e},!0,["encrypt"]),{ext:i,key_ops:o,...s}=await r.exportKey("jwk",n);return s.kid=await G({jwk:s}),s}static async privateKeyToBytes({privateKey:e}){if(!dr(e))throw new Error("AesGcm: The provided key is not a valid oct private key.");return q.base64Url(e.k).toUint8Array()}};var Dy=class extends He{async decrypt(e){return Vn.decrypt(e)}async encrypt(e){return Vn.encrypt(e)}async generateKey({algorithm:e}){let r={A128GCM:128,A192GCM:192,A256GCM:256}[e],n=await Vn.generateKey({length:r});return n.alg=e,n}};var My=class t{static async deriveKey({keyDataLen:e,fixedInfo:r,sharedSecret:n}){let o=Math.ceil(e/256);if(o!==1)throw new Error(`Concat KDF with ${o} rounds not supported.`);let s=new Uint8Array(4);new DataView(s.buffer).setUint32(0,o);let a=t.computeFixedInfo(r);return xt(cf(s,n,a)).slice(0,e/8)}static computeFixedInfo(e){let r=t.toDataLenData({data:e.algorithmId}),n=t.toDataLenData({data:e.partyUInfo}),i=t.toDataLenData({data:e.partyVInfo}),o=t.toDataLenData({data:e.suppPubInfo,variableLength:!1}),s=t.toDataLenData({data:e.suppPrivInfo});return cf(r,n,i,o,s)}static toDataLenData({data:e,variableLength:r=!0}){let n,i=Wn(e);if(i==="Undefined")return new Uint8Array(0);if(r){let o=i==="Uint8Array"?e:new q(e,i).toUint8Array(),s=o.length;n=new Uint8Array(4+s),new DataView(n.buffer).setUint32(0,s),n.set(o,4)}else{if(typeof e!="number")throw TypeError("Fixed length input must be a number.");n=new Uint8Array(4),new DataView(n.buffer).setUint32(0,e)}return n}};var qy=class{static async deriveKey({hash:e,password:r,salt:n,iterations:i,length:o}){let s=await qt.subtle.importKey("raw",r,{name:"PBKDF2"},!1,["deriveBits"]),a=await qt.subtle.deriveBits({name:"PBKDF2",hash:e,salt:n,iterations:i},s,o);return new Uint8Array(a)}};var jy=class t{static async bytesToPrivateKey({privateKeyBytes:e}){let r=tn.getPublicKey(e),n={kty:"OKP",crv:"X25519",d:q.uint8Array(e).toBase64Url(),x:q.uint8Array(r).toBase64Url()};return n.kid=await G({jwk:n}),n}static async bytesToPublicKey({publicKeyBytes:e}){let r={kty:"OKP",crv:"X25519",x:q.uint8Array(e).toBase64Url()};return r.kid=await G({jwk:r}),r}static async computePublicKey({key:e}){let r=await t.privateKeyToBytes({privateKey:e}),n=tn.getPublicKey(r),i={kty:"OKP",crv:"X25519",x:q.uint8Array(n).toBase64Url()};return i.kid=await G({jwk:i}),i}static async generateKey(){let e=tn.utils.randomPrivateKey(),r=await t.bytesToPrivateKey({privateKeyBytes:e});return r.kid=await G({jwk:r}),r}static async getPublicKey({key:e}){if(!(_t(e)&&e.crv==="X25519"))throw new Error("X25519: The provided key is not an X25519 private JWK.");let{d:r,...n}=e;return n.kid??=await G({jwk:n}),n}static async privateKeyToBytes({privateKey:e}){if(!_t(e))throw new Error("X25519: The provided key is not a valid OKP private key.");return q.base64Url(e.d).toUint8Array()}static async publicKeyToBytes({publicKey:e}){if(!Fn(e))throw new Error("X25519: The provided key is not a valid OKP public key.");return q.base64Url(e.x).toUint8Array()}static async sharedSecret({privateKeyA:e,publicKeyB:r}){if("x"in e&&"x"in r&&e.x===r.x)throw new Error("X25519: ECDH shared secret cannot be computed from a single key pair's public and private keys.");let n=await t.privateKeyToBytes({privateKey:e}),i=await t.publicKeyToBytes({publicKey:r});return tn.getSharedSecret(n,i)}};var Ee=(t,e)=>t[e++]&255|(t[e++]&255)<<8,Df=class{constructor(e){this.blockLen=16,this.outputLen=16,this.buffer=new Uint8Array(16),this.r=new Uint16Array(10),this.h=new Uint16Array(10),this.pad=new Uint16Array(8),this.pos=0,this.finished=!1,e=_s(e),we(e,32);let r=Ee(e,0),n=Ee(e,2),i=Ee(e,4),o=Ee(e,6),s=Ee(e,8),a=Ee(e,10),c=Ee(e,12),f=Ee(e,14);this.r[0]=r&8191,this.r[1]=(r>>>13|n<<3)&8191,this.r[2]=(n>>>10|i<<6)&7939,this.r[3]=(i>>>7|o<<9)&8191,this.r[4]=(o>>>4|s<<12)&255,this.r[5]=s>>>1&8190,this.r[6]=(s>>>14|a<<2)&8191,this.r[7]=(a>>>11|c<<5)&8065,this.r[8]=(c>>>8|f<<8)&8191,this.r[9]=f>>>5&127;for(let u=0;u<8;u++)this.pad[u]=Ee(e,16+2*u)}process(e,r,n=!1){let i=n?0:2048,{h:o,r:s}=this,a=s[0],c=s[1],f=s[2],u=s[3],l=s[4],p=s[5],h=s[6],y=s[7],d=s[8],w=s[9],m=Ee(e,r+0),A=Ee(e,r+2),g=Ee(e,r+4),_=Ee(e,r+6),E=Ee(e,r+8),B=Ee(e,r+10),T=Ee(e,r+12),k=Ee(e,r+14),R=o[0]+(m&8191),C=o[1]+((m>>>13|A<<3)&8191),L=o[2]+((A>>>10|g<<6)&8191),j=o[3]+((g>>>7|_<<9)&8191),K=o[4]+((_>>>4|E<<12)&8191),Y=o[5]+(E>>>1&8191),S=o[6]+((E>>>14|B<<2)&8191),I=o[7]+((B>>>11|T<<5)&8191),N=o[8]+((T>>>8|k<<8)&8191),v=o[9]+(k>>>5|i),b=0,P=b+R*a+C*(5*w)+L*(5*d)+j*(5*y)+K*(5*h);b=P>>>13,P&=8191,P+=Y*(5*p)+S*(5*l)+I*(5*u)+N*(5*f)+v*(5*c),b+=P>>>13,P&=8191;let U=b+R*c+C*a+L*(5*w)+j*(5*d)+K*(5*y);b=U>>>13,U&=8191,U+=Y*(5*h)+S*(5*p)+I*(5*l)+N*(5*u)+v*(5*f),b+=U>>>13,U&=8191;let O=b+R*f+C*c+L*a+j*(5*w)+K*(5*d);b=O>>>13,O&=8191,O+=Y*(5*y)+S*(5*h)+I*(5*p)+N*(5*l)+v*(5*u),b+=O>>>13,O&=8191;let F=b+R*u+C*f+L*c+j*a+K*(5*w);b=F>>>13,F&=8191,F+=Y*(5*d)+S*(5*y)+I*(5*h)+N*(5*p)+v*(5*l),b+=F>>>13,F&=8191;let $=b+R*l+C*u+L*f+j*c+K*a;b=$>>>13,$&=8191,$+=Y*(5*w)+S*(5*d)+I*(5*y)+N*(5*h)+v*(5*p),b+=$>>>13,$&=8191;let Z=b+R*p+C*l+L*u+j*f+K*c;b=Z>>>13,Z&=8191,Z+=Y*a+S*(5*w)+I*(5*d)+N*(5*y)+v*(5*h),b+=Z>>>13,Z&=8191;let V=b+R*h+C*p+L*l+j*u+K*f;b=V>>>13,V&=8191,V+=Y*c+S*a+I*(5*w)+N*(5*d)+v*(5*y),b+=V>>>13,V&=8191;let H=b+R*y+C*h+L*p+j*l+K*u;b=H>>>13,H&=8191,H+=Y*f+S*c+I*a+N*(5*w)+v*(5*d),b+=H>>>13,H&=8191;let ne=b+R*d+C*y+L*h+j*p+K*l;b=ne>>>13,ne&=8191,ne+=Y*u+S*f+I*c+N*a+v*(5*w),b+=ne>>>13,ne&=8191;let te=b+R*w+C*d+L*y+j*h+K*p;b=te>>>13,te&=8191,te+=Y*l+S*u+I*f+N*c+v*a,b+=te>>>13,te&=8191,b=(b<<2)+b|0,b=b+P|0,P=b&8191,b=b>>>13,U+=b,o[0]=P,o[1]=U,o[2]=O,o[3]=F,o[4]=$,o[5]=Z,o[6]=V,o[7]=H,o[8]=ne,o[9]=te}finalize(){let{h:e,pad:r}=this,n=new Uint16Array(10),i=e[1]>>>13;e[1]&=8191;for(let a=2;a<10;a++)e[a]+=i,i=e[a]>>>13,e[a]&=8191;e[0]+=i*5,i=e[0]>>>13,e[0]&=8191,e[1]+=i,i=e[1]>>>13,e[1]&=8191,e[2]+=i,n[0]=e[0]+5,i=n[0]>>>13,n[0]&=8191;for(let a=1;a<10;a++)n[a]=e[a]+i,i=n[a]>>>13,n[a]&=8191;n[9]-=8192;let o=(i^1)-1;for(let a=0;a<10;a++)n[a]&=o;o=~o;for(let a=0;a<10;a++)e[a]=e[a]&o|n[a];e[0]=(e[0]|e[1]<<13)&65535,e[1]=(e[1]>>>3|e[2]<<10)&65535,e[2]=(e[2]>>>6|e[3]<<7)&65535,e[3]=(e[3]>>>9|e[4]<<4)&65535,e[4]=(e[4]>>>12|e[5]<<1|e[6]<<14)&65535,e[5]=(e[6]>>>2|e[7]<<11)&65535,e[6]=(e[7]>>>5|e[8]<<8)&65535,e[7]=(e[8]>>>8|e[9]<<5)&65535;let s=e[0]+r[0];e[0]=s&65535;for(let a=1;a<8;a++)s=(e[a]+r[a]|0)+(s>>>16)|0,e[a]=s&65535}update(e){Lf(this);let{buffer:r,blockLen:n}=this;e=_s(e);let i=e.length;for(let o=0;o<i;){let s=Math.min(n-this.pos,i-o);if(s===n){for(;n<=i-o;o+=n)this.process(e,o);continue}r.set(e.subarray(o,o+s),this.pos),this.pos+=s,o+=s,this.pos===n&&(this.process(r,0,!1),this.pos=0)}return this}destroy(){this.h.fill(0),this.r.fill(0),this.buffer.fill(0),this.pad.fill(0)}digestInto(e){Lf(this),Uy(e,this),this.finished=!0;let{buffer:r,h:n}=this,{pos:i}=this;if(i){for(r[i++]=1;i<16;i++)r[i]=0;this.process(r,0,!0)}this.finalize();let o=0;for(let s=0;s<8;s++)e[o++]=n[s]>>>0,e[o++]=n[s]>>>8;return e}digest(){let{buffer:e,outputLen:r}=this;this.digestInto(e);let n=e.slice(0,r);return this.destroy(),n}};function x_(t){let e=(n,i)=>t(i).update(_s(n)).digest(),r=t(new Uint8Array(32));return e.outputLen=r.outputLen,e.blockLen=r.blockLen,e.create=n=>t(n),e}var Fy=x_(t=>new Df(t));var Vy=t=>Uint8Array.from(t.split("").map(e=>e.charCodeAt(0))),E_=Vy("expand 16-byte k"),__=Vy("expand 32-byte k"),A_=Wt(E_),Hy=Wt(__),cT=Hy.slice();function D(t,e){return t<<e|t>>>32-e}function Mf(t){return t.byteOffset%4===0}var vs=64,S_=16,Gy=2**32-1,$y=new Uint32Array;function v_(t,e,r,n,i,o,s,a){let c=i.length,f=new Uint8Array(vs),u=Wt(f),l=Mf(i)&&Mf(o),p=l?Wt(i):$y,h=l?Wt(o):$y;for(let y=0;y<c;s++){if(t(e,r,n,u,s,a),s>=Gy)throw new Error("arx: counter overflow");let d=Math.min(vs,c-y);if(l&&d===vs){let w=y/4;if(y%4!==0)throw new Error("arx: invalid block position");for(let m=0,A;m<S_;m++)A=w+m,h[A]=p[A]^u[m];y+=vs;continue}for(let w=0,m;w<d;w++)m=y+w,o[m]=i[m]^f[w];y+=d}}function qf(t,e){let{allowShortKeys:r,extendNonceFn:n,counterLength:i,counterRight:o,rounds:s}=Ly({allowShortKeys:!1,counterLength:8,counterRight:!1,rounds:20},e);if(typeof t!="function")throw new Error("core must be a function");return qi(i),qi(s),Uf(o),Uf(r),(a,c,f,u,l=0)=>{we(a),we(c),we(f);let p=f.length;if(u||(u=new Uint8Array(p)),we(u),qi(l),l<0||l>=Gy)throw new Error("arx: counter overflow");if(u.length<p)throw new Error(`arx: output (${u.length}) is shorter than data (${p})`);let h=[],y=a.length,d,w;if(y===32)d=a.slice(),h.push(d),w=Hy;else if(y===16&&r)d=new Uint8Array(32),d.set(a),d.set(a,16),w=A_,h.push(d);else throw new Error(`arx: invalid 32-byte key, got length=${y}`);Mf(c)||(c=c.slice(),h.push(c));let m=Wt(d);if(n){if(c.length!==24)throw new Error("arx: extended nonce must be 24 bytes");n(w,m,Wt(c.subarray(0,16)),m),c=c.subarray(16)}let A=16-i;if(A!==c.length)throw new Error(`arx: nonce must be ${A} or 16 bytes`);if(A!==12){let _=new Uint8Array(12);_.set(c,o?0:12-c.length),c=_,h.push(c)}let g=Wt(c);for(v_(t,w,m,g,f,u,l,s);h.length>0;)h.pop().fill(0);return u}}function zy(t,e,r,n,i,o=20){let s=t[0],a=t[1],c=t[2],f=t[3],u=e[0],l=e[1],p=e[2],h=e[3],y=e[4],d=e[5],w=e[6],m=e[7],A=i,g=r[0],_=r[1],E=r[2],B=s,T=a,k=c,R=f,C=u,L=l,j=p,K=h,Y=y,S=d,I=w,N=m,v=A,b=g,P=_,U=E;for(let F=0;F<o;F+=2)B=B+C|0,v=D(v^B,16),Y=Y+v|0,C=D(C^Y,12),B=B+C|0,v=D(v^B,8),Y=Y+v|0,C=D(C^Y,7),T=T+L|0,b=D(b^T,16),S=S+b|0,L=D(L^S,12),T=T+L|0,b=D(b^T,8),S=S+b|0,L=D(L^S,7),k=k+j|0,P=D(P^k,16),I=I+P|0,j=D(j^I,12),k=k+j|0,P=D(P^k,8),I=I+P|0,j=D(j^I,7),R=R+K|0,U=D(U^R,16),N=N+U|0,K=D(K^N,12),R=R+K|0,U=D(U^R,8),N=N+U|0,K=D(K^N,7),B=B+L|0,U=D(U^B,16),I=I+U|0,L=D(L^I,12),B=B+L|0,U=D(U^B,8),I=I+U|0,L=D(L^I,7),T=T+j|0,v=D(v^T,16),N=N+v|0,j=D(j^N,12),T=T+j|0,v=D(v^T,8),N=N+v|0,j=D(j^N,7),k=k+K|0,b=D(b^k,16),Y=Y+b|0,K=D(K^Y,12),k=k+K|0,b=D(b^k,8),Y=Y+b|0,K=D(K^Y,7),R=R+C|0,P=D(P^R,16),S=S+P|0,C=D(C^S,12),R=R+C|0,P=D(P^R,8),S=S+P|0,C=D(C^S,7);let O=0;n[O++]=s+B|0,n[O++]=a+T|0,n[O++]=c+k|0,n[O++]=f+R|0,n[O++]=u+C|0,n[O++]=l+L|0,n[O++]=p+j|0,n[O++]=h+K|0,n[O++]=y+Y|0,n[O++]=d+S|0,n[O++]=w+I|0,n[O++]=m+N|0,n[O++]=A+v|0,n[O++]=g+b|0,n[O++]=_+P|0,n[O++]=E+U|0}function B_(t,e,r,n){let i=t[0],o=t[1],s=t[2],a=t[3],c=e[0],f=e[1],u=e[2],l=e[3],p=e[4],h=e[5],y=e[6],d=e[7],w=r[0],m=r[1],A=r[2],g=r[3];for(let E=0;E<20;E+=2)i=i+c|0,w=D(w^i,16),p=p+w|0,c=D(c^p,12),i=i+c|0,w=D(w^i,8),p=p+w|0,c=D(c^p,7),o=o+f|0,m=D(m^o,16),h=h+m|0,f=D(f^h,12),o=o+f|0,m=D(m^o,8),h=h+m|0,f=D(f^h,7),s=s+u|0,A=D(A^s,16),y=y+A|0,u=D(u^y,12),s=s+u|0,A=D(A^s,8),y=y+A|0,u=D(u^y,7),a=a+l|0,g=D(g^a,16),d=d+g|0,l=D(l^d,12),a=a+l|0,g=D(g^a,8),d=d+g|0,l=D(l^d,7),i=i+f|0,g=D(g^i,16),y=y+g|0,f=D(f^y,12),i=i+f|0,g=D(g^i,8),y=y+g|0,f=D(f^y,7),o=o+u|0,w=D(w^o,16),d=d+w|0,u=D(u^d,12),o=o+u|0,w=D(w^o,8),d=d+w|0,u=D(u^d,7),s=s+l|0,m=D(m^s,16),p=p+m|0,l=D(l^p,12),s=s+l|0,m=D(m^s,8),p=p+m|0,l=D(l^p,7),a=a+c|0,A=D(A^a,16),h=h+A|0,c=D(c^h,12),a=a+c|0,A=D(A^a,8),h=h+A|0,c=D(c^h,7);let _=0;n[_++]=i,n[_++]=o,n[_++]=s,n[_++]=a,n[_++]=w,n[_++]=m,n[_++]=A,n[_++]=g}var T_=qf(zy,{counterRight:!1,counterLength:4,allowShortKeys:!1}),Bs=qf(zy,{counterRight:!1,counterLength:8,extendNonceFn:B_,allowShortKeys:!1});var k_=new Uint8Array(16),Wy=(t,e)=>{t.update(e);let r=e.length%16;r&&t.update(k_.subarray(r))},P_=new Uint8Array(32);function Jy(t,e,r,n,i){let o=t(e,r,P_),s=Fy.create(o);i&&Wy(s,i),Wy(s,n);let a=new Uint8Array(16),c=Cy(a);Kf(c,0,BigInt(i?i.length:0),!0),Kf(c,8,BigInt(n.length),!0),s.update(a);let f=s.digest();return o.fill(0),f}var Yy=t=>(e,r,n)=>(we(e,32),we(r),{encrypt:(o,s)=>{let a=o.length,c=a+16;s?we(s,c):s=new Uint8Array(c),t(e,r,o,s,1);let f=Jy(t,e,r,s.subarray(0,-16),n);return s.set(f,a),s},decrypt:(o,s)=>{let a=o.length,c=a-16;if(a<16)throw new Error("encrypted data must be at least 16 bytes");s?we(s,c):s=new Uint8Array(c);let f=o.subarray(0,-16),u=o.subarray(-16),l=Jy(t,e,r,f,n);if(!Oy(u,l))throw new Error("invalid tag");return t(e,r,f,s,1),s}}),pT=Of({blockSize:64,nonceLength:12,tagLength:16},Yy(T_)),jf=Of({blockSize:64,nonceLength:24,tagLength:16},Yy(Bs));var Zy=class t{static async bytesToPrivateKey({privateKeyBytes:e}){let r={k:q.uint8Array(e).toBase64Url(),kty:"oct"};return r.kid=await G({jwk:r}),r}static async decrypt({data:e,key:r,nonce:n}){let i=await t.privateKeyToBytes({privateKey:r});return Bs(i,n,e)}static async encrypt({data:e,key:r,nonce:n}){let i=await t.privateKeyToBytes({privateKey:r});return Bs(i,n,e)}static async generateKey(){let e=ke(),r=await e.generateKey({name:"AES-CTR",length:256},!0,["encrypt"]),{alg:n,ext:i,key_ops:o,...s}=await e.exportKey("jwk",r);return s.kid=await G({jwk:s}),s}static async privateKeyToBytes({privateKey:e}){if(!dr(e))throw new Error("XChaCha20: The provided key is not a valid oct private key.");return q.base64Url(e.k).toUint8Array()}};var vT=16,Xy=class t{static async bytesToPrivateKey({privateKeyBytes:e}){let r={k:q.uint8Array(e).toBase64Url(),kty:"oct"};return r.kid=await G({jwk:r}),r}static async decrypt({data:e,key:r,nonce:n,additionalData:i}){let o=await t.privateKeyToBytes({privateKey:r});return jf(o,n,i).decrypt(e)}static async encrypt({data:e,key:r,nonce:n,additionalData:i}){let o=await t.privateKeyToBytes({privateKey:r});return jf(o,n,i).encrypt(e)}static async generateKey(){let e=ke(),r=await e.generateKey({name:"AES-CTR",length:256},!0,["encrypt"]),{alg:n,ext:i,key_ops:o,...s}=await e.exportKey("jwk",r);return s.kid=await G({jwk:s}),s}static async privateKeyToBytes({privateKey:e}){if(!dr(e))throw new Error("XChaCha20Poly1305: The provided key is not a valid oct private key.");return q.base64Url(e.k).toUint8Array()}};export{Ss as AES_GCM_TAG_LENGTHS,$n as AesCtr,Ry as AesCtrAlgorithm,Vn as AesGcm,Dy as AesGcmAlgorithm,My as ConcatKdf,He as CryptoAlgorithm,Py as CryptoUtils,Oi as EcdsaAlgorithm,br as Ed25519,gs as EdDsaAlgorithm,vf as KEY_URI_PREFIX_JWK,ky as LocalKeyManager,pr as P256,vT as POLY1305_TAG_LENGTH,qy as Pbkdf2,hr as Secp256k1,pr as Secp256r1,Kn as Sha256,is as Sha2Algorithm,jy as X25519,Zy as XChaCha20,Xy as XChaCha20Poly1305,yy as canonicalize,G as computeJwkThumbprint,Et as isEcPrivateJwk,jn as isEcPublicJwk,dr as isOctPrivateJwk,_t as isOkpPrivateJwk,Fn as isOkpPublicJwk,wy as isPrivateJwk,r8 as isPublicJwk};
|
|
1
|
+
var Vf=Object.create;var uo=Object.defineProperty;var qf=Object.getOwnPropertyDescriptor;var Ff=Object.getOwnPropertyNames;var $f=Object.getPrototypeOf,Wf=Object.prototype.hasOwnProperty;var Q=(r,t)=>()=>(t||r((t={exports:{}}).exports,t),t.exports),Bc=(r,t)=>{for(var e in t)uo(r,e,{get:t[e],enumerable:!0})},zf=(r,t,e,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of Ff(t))!Wf.call(r,i)&&i!==e&&uo(r,i,{get:()=>t[i],enumerable:!(n=qf(t,i))||n.enumerable});return r};var Pc=(r,t,e)=>(e=r!=null?Vf($f(r)):{},zf(t||!r||!r.__esModule?uo(e,"default",{value:r,enumerable:!0}):e,r));var Tc=Q((nd,Kc)=>{var Zf=typeof performance=="object"&&performance&&typeof performance.now=="function"?performance:Date,zn=()=>Zf.now(),Yf=r=>r&&r===Math.floor(r)&&r>0&&isFinite(r),fo=r=>r===1/0||Yf(r),lo=class r{constructor({max:t=1/0,ttl:e,updateAgeOnGet:n=!1,checkAgeOnGet:i=!1,noUpdateTTL:o=!1,dispose:s,noDisposeOnSet:c=!1}={}){if(this.expirations=Object.create(null),this.data=new Map,this.expirationMap=new Map,e!==void 0&&!fo(e))throw new TypeError("ttl must be positive integer or Infinity if set");if(!fo(t))throw new TypeError("max must be positive integer or Infinity");if(this.ttl=e,this.max=t,this.updateAgeOnGet=!!n,this.checkAgeOnGet=!!i,this.noUpdateTTL=!!o,this.noDisposeOnSet=!!c,s!==void 0){if(typeof s!="function")throw new TypeError("dispose must be function if set");this.dispose=s}this.timer=void 0,this.timerExpiration=void 0}setTimer(t,e){if(this.timerExpiration<t)return;this.timer&&clearTimeout(this.timer);let n=setTimeout(()=>{this.timer=void 0,this.timerExpiration=void 0,this.purgeStale();for(let i in this.expirations){this.setTimer(i,i-zn());break}},e);n.unref&&n.unref(),this.timerExpiration=t,this.timer=n}cancelTimer(){this.timer&&(clearTimeout(this.timer),this.timerExpiration=void 0,this.timer=void 0)}cancelTimers(){return process.emitWarning('TTLCache.cancelTimers has been renamed to TTLCache.cancelTimer (no "s"), and will be removed in the next major version update'),this.cancelTimer()}clear(){let t=this.dispose!==r.prototype.dispose?[...this]:[];this.data.clear(),this.expirationMap.clear(),this.cancelTimer(),this.expirations=Object.create(null);for(let[e,n]of t)this.dispose(n,e,"delete")}setTTL(t,e=this.ttl){let n=this.expirationMap.get(t);if(n!==void 0){let i=this.expirations[n];!i||i.length<=1?delete this.expirations[n]:this.expirations[n]=i.filter(o=>o!==t)}if(e!==1/0){let i=Math.floor(zn()+e);this.expirationMap.set(t,i),this.expirations[i]||(this.expirations[i]=[],this.setTimer(i,e)),this.expirations[i].push(t)}else this.expirationMap.set(t,1/0)}set(t,e,{ttl:n=this.ttl,noUpdateTTL:i=this.noUpdateTTL,noDisposeOnSet:o=this.noDisposeOnSet}={}){if(!fo(n))throw new TypeError("ttl must be positive integer or Infinity");if(this.expirationMap.has(t)){i||this.setTTL(t,n);let s=this.data.get(t);s!==e&&(this.data.set(t,e),o||this.dispose(s,t,"set"))}else this.setTTL(t,n),this.data.set(t,e);for(;this.size>this.max;)this.purgeToCapacity();return this}has(t){return this.data.has(t)}getRemainingTTL(t){let e=this.expirationMap.get(t);return e===1/0?e:e!==void 0?Math.max(0,Math.ceil(e-zn())):0}get(t,{updateAgeOnGet:e=this.updateAgeOnGet,ttl:n=this.ttl,checkAgeOnGet:i=this.checkAgeOnGet}={}){let o=this.data.get(t);if(i&&this.getRemainingTTL(t)===0){this.delete(t);return}return e&&this.setTTL(t,n),o}dispose(t,e){}delete(t){let e=this.expirationMap.get(t);if(e!==void 0){let n=this.data.get(t);this.data.delete(t),this.expirationMap.delete(t);let i=this.expirations[e];return i&&(i.length<=1?delete this.expirations[e]:this.expirations[e]=i.filter(o=>o!==t)),this.dispose(n,t,"delete"),this.size===0&&this.cancelTimer(),!0}return!1}purgeToCapacity(){for(let t in this.expirations){let e=this.expirations[t];if(this.size-e.length>=this.max){delete this.expirations[t];let n=[];for(let i of e)n.push([i,this.data.get(i)]),this.data.delete(i),this.expirationMap.delete(i);for(let[i,o]of n)this.dispose(o,i,"evict")}else{let n=this.size-this.max,i=[];for(let o of e.splice(0,n))i.push([o,this.data.get(o)]),this.data.delete(o),this.expirationMap.delete(o);for(let[o,s]of i)this.dispose(s,o,"evict");return}}}get size(){return this.data.size}purgeStale(){let t=Math.ceil(zn());for(let e in this.expirations){if(e==="Infinity"||e>t)return;let n=[...this.expirations[e]||[]],i=[];delete this.expirations[e];for(let o of n)i.push([o,this.data.get(o)]),this.data.delete(o),this.expirationMap.delete(o);for(let[o,s]of i)this.dispose(s,o,"stale")}this.size===0&&this.cancelTimer()}*entries(){for(let t in this.expirations)for(let e of this.expirations[t])yield[e,this.data.get(e)]}*keys(){for(let t in this.expirations)for(let e of this.expirations[t])yield e}*values(){for(let t in this.expirations)for(let e of this.expirations[t])yield this.data.get(e)}[Symbol.iterator](){return this.entries()}};Kc.exports=lo});var Vc=Q(Gc=>{"use strict";Gc.supports=function(...t){let e=t.reduce((n,i)=>Object.assign(n,i),{});return Object.assign(e,{snapshots:e.snapshots||!1,permanence:e.permanence||!1,seek:e.seek||!1,clear:e.clear||!1,getMany:e.getMany||!1,keyIterator:e.keyIterator||!1,valueIterator:e.valueIterator||!1,iteratorNextv:e.iteratorNextv||!1,iteratorAll:e.iteratorAll||!1,status:e.status||!1,createIfMissing:e.createIfMissing||!1,errorIfExists:e.errorIfExists||!1,deferredOpen:e.deferredOpen||!1,promises:e.promises||!1,streams:e.streams||!1,encodings:Object.assign({},e.encodings),events:Object.assign({},e.events),additionalMethods:Object.assign({},e.additionalMethods)})}});var Vt=Q((e0,qc)=>{"use strict";qc.exports=class extends Error{constructor(t,e){super(t||""),typeof e=="object"&&e!==null&&(e.code&&(this.code=String(e.code)),e.expected&&(this.expected=!0),e.transient&&(this.transient=!0),e.cause&&(this.cause=e.cause)),Error.captureStackTrace&&Error.captureStackTrace(this,this.constructor)}}});var Wc=Q(Yn=>{"use strict";Yn.byteLength=Il;Yn.toByteArray=_l;Yn.fromByteArray=Rl;var te=[],_t=[],Ul=typeof Uint8Array<"u"?Uint8Array:Array,Ko="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";for(or=0,Fc=Ko.length;or<Fc;++or)te[or]=Ko[or],_t[Ko.charCodeAt(or)]=or;var or,Fc;_t[45]=62;_t[95]=63;function $c(r){var t=r.length;if(t%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var e=r.indexOf("=");e===-1&&(e=t);var n=e===t?0:4-e%4;return[e,n]}function Il(r){var t=$c(r),e=t[0],n=t[1];return(e+n)*3/4-n}function Cl(r,t,e){return(t+e)*3/4-e}function _l(r){var t,e=$c(r),n=e[0],i=e[1],o=new Ul(Cl(r,n,i)),s=0,c=i>0?n-4:n,a;for(a=0;a<c;a+=4)t=_t[r.charCodeAt(a)]<<18|_t[r.charCodeAt(a+1)]<<12|_t[r.charCodeAt(a+2)]<<6|_t[r.charCodeAt(a+3)],o[s++]=t>>16&255,o[s++]=t>>8&255,o[s++]=t&255;return i===2&&(t=_t[r.charCodeAt(a)]<<2|_t[r.charCodeAt(a+1)]>>4,o[s++]=t&255),i===1&&(t=_t[r.charCodeAt(a)]<<10|_t[r.charCodeAt(a+1)]<<4|_t[r.charCodeAt(a+2)]>>2,o[s++]=t>>8&255,o[s++]=t&255),o}function Ll(r){return te[r>>18&63]+te[r>>12&63]+te[r>>6&63]+te[r&63]}function Ol(r,t,e){for(var n,i=[],o=t;o<e;o+=3)n=(r[o]<<16&16711680)+(r[o+1]<<8&65280)+(r[o+2]&255),i.push(Ll(n));return i.join("")}function Rl(r){for(var t,e=r.length,n=e%3,i=[],o=16383,s=0,c=e-n;s<c;s+=o)i.push(Ol(r,s,s+o>c?c:s+o));return n===1?(t=r[e-1],i.push(te[t>>2]+te[t<<4&63]+"==")):n===2&&(t=(r[e-2]<<8)+r[e-1],i.push(te[t>>10]+te[t>>4&63]+te[t<<2&63]+"=")),i.join("")}});var zc=Q(To=>{To.read=function(r,t,e,n,i){var o,s,c=i*8-n-1,a=(1<<c)-1,u=a>>1,f=-7,l=e?i-1:0,y=e?-1:1,m=r[t+l];for(l+=y,o=m&(1<<-f)-1,m>>=-f,f+=c;f>0;o=o*256+r[t+l],l+=y,f-=8);for(s=o&(1<<-f)-1,o>>=-f,f+=n;f>0;s=s*256+r[t+l],l+=y,f-=8);if(o===0)o=1-u;else{if(o===a)return s?NaN:(m?-1:1)*(1/0);s=s+Math.pow(2,n),o=o-u}return(m?-1:1)*s*Math.pow(2,o-n)};To.write=function(r,t,e,n,i,o){var s,c,a,u=o*8-i-1,f=(1<<u)-1,l=f>>1,y=i===23?Math.pow(2,-24)-Math.pow(2,-77):0,m=n?0:o-1,p=n?1:-1,h=t<0||t===0&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(c=isNaN(t)?1:0,s=f):(s=Math.floor(Math.log(t)/Math.LN2),t*(a=Math.pow(2,-s))<1&&(s--,a*=2),s+l>=1?t+=y/a:t+=y*Math.pow(2,1-l),t*a>=2&&(s++,a/=2),s+l>=f?(c=0,s=f):s+l>=1?(c=(t*a-1)*Math.pow(2,i),s=s+l):(c=t*Math.pow(2,l-1)*Math.pow(2,i),s=0));i>=8;r[e+m]=c&255,m+=p,c/=256,i-=8);for(s=s<<i|c,u+=i;u>0;r[e+m]=s&255,m+=p,s/=256,u-=8);r[e+m-p]|=h*128}});var ti=Q(Lr=>{"use strict";var So=Wc(),Cr=zc(),Zc=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):null;Lr.Buffer=E;Lr.SlowBuffer=Jl;Lr.INSPECT_MAX_BYTES=50;var Xn=2147483647;Lr.kMaxLength=Xn;E.TYPED_ARRAY_SUPPORT=Nl();!E.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 Nl(){try{let r=new Uint8Array(1),t={foo:function(){return 42}};return Object.setPrototypeOf(t,Uint8Array.prototype),Object.setPrototypeOf(r,t),r.foo()===42}catch{return!1}}Object.defineProperty(E.prototype,"parent",{enumerable:!0,get:function(){if(E.isBuffer(this))return this.buffer}});Object.defineProperty(E.prototype,"offset",{enumerable:!0,get:function(){if(E.isBuffer(this))return this.byteOffset}});function pe(r){if(r>Xn)throw new RangeError('The value "'+r+'" is invalid for option "size"');let t=new Uint8Array(r);return Object.setPrototypeOf(t,E.prototype),t}function E(r,t,e){if(typeof r=="number"){if(typeof t=="string")throw new TypeError('The "string" argument must be of type string. Received type number');return Co(r)}return ta(r,t,e)}E.poolSize=8192;function ta(r,t,e){if(typeof r=="string")return Ml(r,t);if(ArrayBuffer.isView(r))return jl(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(ee(r,ArrayBuffer)||r&&ee(r.buffer,ArrayBuffer)||typeof SharedArrayBuffer<"u"&&(ee(r,SharedArrayBuffer)||r&&ee(r.buffer,SharedArrayBuffer)))return Uo(r,t,e);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 E.from(n,t,e);let i=Hl(r);if(i)return i;if(typeof Symbol<"u"&&Symbol.toPrimitive!=null&&typeof r[Symbol.toPrimitive]=="function")return E.from(r[Symbol.toPrimitive]("string"),t,e);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof r)}E.from=function(r,t,e){return ta(r,t,e)};Object.setPrototypeOf(E.prototype,Uint8Array.prototype);Object.setPrototypeOf(E,Uint8Array);function ea(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 Dl(r,t,e){return ea(r),r<=0?pe(r):t!==void 0?typeof e=="string"?pe(r).fill(t,e):pe(r).fill(t):pe(r)}E.alloc=function(r,t,e){return Dl(r,t,e)};function Co(r){return ea(r),pe(r<0?0:_o(r)|0)}E.allocUnsafe=function(r){return Co(r)};E.allocUnsafeSlow=function(r){return Co(r)};function Ml(r,t){if((typeof t!="string"||t==="")&&(t="utf8"),!E.isEncoding(t))throw new TypeError("Unknown encoding: "+t);let e=ra(r,t)|0,n=pe(e),i=n.write(r,t);return i!==e&&(n=n.slice(0,i)),n}function ko(r){let t=r.length<0?0:_o(r.length)|0,e=pe(t);for(let n=0;n<t;n+=1)e[n]=r[n]&255;return e}function jl(r){if(ee(r,Uint8Array)){let t=new Uint8Array(r);return Uo(t.buffer,t.byteOffset,t.byteLength)}return ko(r)}function Uo(r,t,e){if(t<0||r.byteLength<t)throw new RangeError('"offset" is outside of buffer bounds');if(r.byteLength<t+(e||0))throw new RangeError('"length" is outside of buffer bounds');let n;return t===void 0&&e===void 0?n=new Uint8Array(r):e===void 0?n=new Uint8Array(r,t):n=new Uint8Array(r,t,e),Object.setPrototypeOf(n,E.prototype),n}function Hl(r){if(E.isBuffer(r)){let t=_o(r.length)|0,e=pe(t);return e.length===0||r.copy(e,0,0,t),e}if(r.length!==void 0)return typeof r.length!="number"||Oo(r.length)?pe(0):ko(r);if(r.type==="Buffer"&&Array.isArray(r.data))return ko(r.data)}function _o(r){if(r>=Xn)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+Xn.toString(16)+" bytes");return r|0}function Jl(r){return+r!=r&&(r=0),E.alloc(+r)}E.isBuffer=function(t){return t!=null&&t._isBuffer===!0&&t!==E.prototype};E.compare=function(t,e){if(ee(t,Uint8Array)&&(t=E.from(t,t.offset,t.byteLength)),ee(e,Uint8Array)&&(e=E.from(e,e.offset,e.byteLength)),!E.isBuffer(t)||!E.isBuffer(e))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(t===e)return 0;let n=t.length,i=e.length;for(let o=0,s=Math.min(n,i);o<s;++o)if(t[o]!==e[o]){n=t[o],i=e[o];break}return n<i?-1:i<n?1:0};E.isEncoding=function(t){switch(String(t).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}};E.concat=function(t,e){if(!Array.isArray(t))throw new TypeError('"list" argument must be an Array of Buffers');if(t.length===0)return E.alloc(0);let n;if(e===void 0)for(e=0,n=0;n<t.length;++n)e+=t[n].length;let i=E.allocUnsafe(e),o=0;for(n=0;n<t.length;++n){let s=t[n];if(ee(s,Uint8Array))o+s.length>i.length?(E.isBuffer(s)||(s=E.from(s)),s.copy(i,o)):Uint8Array.prototype.set.call(i,s,o);else if(E.isBuffer(s))s.copy(i,o);else throw new TypeError('"list" argument must be an Array of Buffers');o+=s.length}return i};function ra(r,t){if(E.isBuffer(r))return r.length;if(ArrayBuffer.isView(r)||ee(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 e=r.length,n=arguments.length>2&&arguments[2]===!0;if(!n&&e===0)return 0;let i=!1;for(;;)switch(t){case"ascii":case"latin1":case"binary":return e;case"utf8":case"utf-8":return Io(r).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return e*2;case"hex":return e>>>1;case"base64":return la(r).length;default:if(i)return n?-1:Io(r).length;t=(""+t).toLowerCase(),i=!0}}E.byteLength=ra;function Gl(r,t,e){let n=!1;if((t===void 0||t<0)&&(t=0),t>this.length||((e===void 0||e>this.length)&&(e=this.length),e<=0)||(e>>>=0,t>>>=0,e<=t))return"";for(r||(r="utf8");;)switch(r){case"hex":return Ql(this,t,e);case"utf8":case"utf-8":return ia(this,t,e);case"ascii":return Yl(this,t,e);case"latin1":case"binary":return Xl(this,t,e);case"base64":return zl(this,t,e);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return th(this,t,e);default:if(n)throw new TypeError("Unknown encoding: "+r);r=(r+"").toLowerCase(),n=!0}}E.prototype._isBuffer=!0;function sr(r,t,e){let n=r[t];r[t]=r[e],r[e]=n}E.prototype.swap16=function(){let t=this.length;if(t%2!==0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(let e=0;e<t;e+=2)sr(this,e,e+1);return this};E.prototype.swap32=function(){let t=this.length;if(t%4!==0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(let e=0;e<t;e+=4)sr(this,e,e+3),sr(this,e+1,e+2);return this};E.prototype.swap64=function(){let t=this.length;if(t%8!==0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(let e=0;e<t;e+=8)sr(this,e,e+7),sr(this,e+1,e+6),sr(this,e+2,e+5),sr(this,e+3,e+4);return this};E.prototype.toString=function(){let t=this.length;return t===0?"":arguments.length===0?ia(this,0,t):Gl.apply(this,arguments)};E.prototype.toLocaleString=E.prototype.toString;E.prototype.equals=function(t){if(!E.isBuffer(t))throw new TypeError("Argument must be a Buffer");return this===t?!0:E.compare(this,t)===0};E.prototype.inspect=function(){let t="",e=Lr.INSPECT_MAX_BYTES;return t=this.toString("hex",0,e).replace(/(.{2})/g,"$1 ").trim(),this.length>e&&(t+=" ... "),"<Buffer "+t+">"};Zc&&(E.prototype[Zc]=E.prototype.inspect);E.prototype.compare=function(t,e,n,i,o){if(ee(t,Uint8Array)&&(t=E.from(t,t.offset,t.byteLength)),!E.isBuffer(t))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof t);if(e===void 0&&(e=0),n===void 0&&(n=t?t.length:0),i===void 0&&(i=0),o===void 0&&(o=this.length),e<0||n>t.length||i<0||o>this.length)throw new RangeError("out of range index");if(i>=o&&e>=n)return 0;if(i>=o)return-1;if(e>=n)return 1;if(e>>>=0,n>>>=0,i>>>=0,o>>>=0,this===t)return 0;let s=o-i,c=n-e,a=Math.min(s,c),u=this.slice(i,o),f=t.slice(e,n);for(let l=0;l<a;++l)if(u[l]!==f[l]){s=u[l],c=f[l];break}return s<c?-1:c<s?1:0};function na(r,t,e,n,i){if(r.length===0)return-1;if(typeof e=="string"?(n=e,e=0):e>2147483647?e=2147483647:e<-2147483648&&(e=-2147483648),e=+e,Oo(e)&&(e=i?0:r.length-1),e<0&&(e=r.length+e),e>=r.length){if(i)return-1;e=r.length-1}else if(e<0)if(i)e=0;else return-1;if(typeof t=="string"&&(t=E.from(t,n)),E.isBuffer(t))return t.length===0?-1:Yc(r,t,e,n,i);if(typeof t=="number")return t=t&255,typeof Uint8Array.prototype.indexOf=="function"?i?Uint8Array.prototype.indexOf.call(r,t,e):Uint8Array.prototype.lastIndexOf.call(r,t,e):Yc(r,[t],e,n,i);throw new TypeError("val must be string, number or Buffer")}function Yc(r,t,e,n,i){let o=1,s=r.length,c=t.length;if(n!==void 0&&(n=String(n).toLowerCase(),n==="ucs2"||n==="ucs-2"||n==="utf16le"||n==="utf-16le")){if(r.length<2||t.length<2)return-1;o=2,s/=2,c/=2,e/=2}function a(f,l){return o===1?f[l]:f.readUInt16BE(l*o)}let u;if(i){let f=-1;for(u=e;u<s;u++)if(a(r,u)===a(t,f===-1?0:u-f)){if(f===-1&&(f=u),u-f+1===c)return f*o}else f!==-1&&(u-=u-f),f=-1}else for(e+c>s&&(e=s-c),u=e;u>=0;u--){let f=!0;for(let l=0;l<c;l++)if(a(r,u+l)!==a(t,l)){f=!1;break}if(f)return u}return-1}E.prototype.includes=function(t,e,n){return this.indexOf(t,e,n)!==-1};E.prototype.indexOf=function(t,e,n){return na(this,t,e,n,!0)};E.prototype.lastIndexOf=function(t,e,n){return na(this,t,e,n,!1)};function Vl(r,t,e,n){e=Number(e)||0;let i=r.length-e;n?(n=Number(n),n>i&&(n=i)):n=i;let o=t.length;n>o/2&&(n=o/2);let s;for(s=0;s<n;++s){let c=parseInt(t.substr(s*2,2),16);if(Oo(c))return s;r[e+s]=c}return s}function ql(r,t,e,n){return Qn(Io(t,r.length-e),r,e,n)}function Fl(r,t,e,n){return Qn(ih(t),r,e,n)}function $l(r,t,e,n){return Qn(la(t),r,e,n)}function Wl(r,t,e,n){return Qn(oh(t,r.length-e),r,e,n)}E.prototype.write=function(t,e,n,i){if(e===void 0)i="utf8",n=this.length,e=0;else if(n===void 0&&typeof e=="string")i=e,n=this.length,e=0;else if(isFinite(e))e=e>>>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 o=this.length-e;if((n===void 0||n>o)&&(n=o),t.length>0&&(n<0||e<0)||e>this.length)throw new RangeError("Attempt to write outside buffer bounds");i||(i="utf8");let s=!1;for(;;)switch(i){case"hex":return Vl(this,t,e,n);case"utf8":case"utf-8":return ql(this,t,e,n);case"ascii":case"latin1":case"binary":return Fl(this,t,e,n);case"base64":return $l(this,t,e,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return Wl(this,t,e,n);default:if(s)throw new TypeError("Unknown encoding: "+i);i=(""+i).toLowerCase(),s=!0}};E.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function zl(r,t,e){return t===0&&e===r.length?So.fromByteArray(r):So.fromByteArray(r.slice(t,e))}function ia(r,t,e){e=Math.min(r.length,e);let n=[],i=t;for(;i<e;){let o=r[i],s=null,c=o>239?4:o>223?3:o>191?2:1;if(i+c<=e){let a,u,f,l;switch(c){case 1:o<128&&(s=o);break;case 2:a=r[i+1],(a&192)===128&&(l=(o&31)<<6|a&63,l>127&&(s=l));break;case 3:a=r[i+1],u=r[i+2],(a&192)===128&&(u&192)===128&&(l=(o&15)<<12|(a&63)<<6|u&63,l>2047&&(l<55296||l>57343)&&(s=l));break;case 4:a=r[i+1],u=r[i+2],f=r[i+3],(a&192)===128&&(u&192)===128&&(f&192)===128&&(l=(o&15)<<18|(a&63)<<12|(u&63)<<6|f&63,l>65535&&l<1114112&&(s=l))}}s===null?(s=65533,c=1):s>65535&&(s-=65536,n.push(s>>>10&1023|55296),s=56320|s&1023),n.push(s),i+=c}return Zl(n)}var Xc=4096;function Zl(r){let t=r.length;if(t<=Xc)return String.fromCharCode.apply(String,r);let e="",n=0;for(;n<t;)e+=String.fromCharCode.apply(String,r.slice(n,n+=Xc));return e}function Yl(r,t,e){let n="";e=Math.min(r.length,e);for(let i=t;i<e;++i)n+=String.fromCharCode(r[i]&127);return n}function Xl(r,t,e){let n="";e=Math.min(r.length,e);for(let i=t;i<e;++i)n+=String.fromCharCode(r[i]);return n}function Ql(r,t,e){let n=r.length;(!t||t<0)&&(t=0),(!e||e<0||e>n)&&(e=n);let i="";for(let o=t;o<e;++o)i+=sh[r[o]];return i}function th(r,t,e){let n=r.slice(t,e),i="";for(let o=0;o<n.length-1;o+=2)i+=String.fromCharCode(n[o]+n[o+1]*256);return i}E.prototype.slice=function(t,e){let n=this.length;t=~~t,e=e===void 0?n:~~e,t<0?(t+=n,t<0&&(t=0)):t>n&&(t=n),e<0?(e+=n,e<0&&(e=0)):e>n&&(e=n),e<t&&(e=t);let i=this.subarray(t,e);return Object.setPrototypeOf(i,E.prototype),i};function ht(r,t,e){if(r%1!==0||r<0)throw new RangeError("offset is not uint");if(r+t>e)throw new RangeError("Trying to access beyond buffer length")}E.prototype.readUintLE=E.prototype.readUIntLE=function(t,e,n){t=t>>>0,e=e>>>0,n||ht(t,e,this.length);let i=this[t],o=1,s=0;for(;++s<e&&(o*=256);)i+=this[t+s]*o;return i};E.prototype.readUintBE=E.prototype.readUIntBE=function(t,e,n){t=t>>>0,e=e>>>0,n||ht(t,e,this.length);let i=this[t+--e],o=1;for(;e>0&&(o*=256);)i+=this[t+--e]*o;return i};E.prototype.readUint8=E.prototype.readUInt8=function(t,e){return t=t>>>0,e||ht(t,1,this.length),this[t]};E.prototype.readUint16LE=E.prototype.readUInt16LE=function(t,e){return t=t>>>0,e||ht(t,2,this.length),this[t]|this[t+1]<<8};E.prototype.readUint16BE=E.prototype.readUInt16BE=function(t,e){return t=t>>>0,e||ht(t,2,this.length),this[t]<<8|this[t+1]};E.prototype.readUint32LE=E.prototype.readUInt32LE=function(t,e){return t=t>>>0,e||ht(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+this[t+3]*16777216};E.prototype.readUint32BE=E.prototype.readUInt32BE=function(t,e){return t=t>>>0,e||ht(t,4,this.length),this[t]*16777216+(this[t+1]<<16|this[t+2]<<8|this[t+3])};E.prototype.readBigUInt64LE=Ue(function(t){t=t>>>0,_r(t,"offset");let e=this[t],n=this[t+7];(e===void 0||n===void 0)&&yn(t,this.length-8);let i=e+this[++t]*2**8+this[++t]*2**16+this[++t]*2**24,o=this[++t]+this[++t]*2**8+this[++t]*2**16+n*2**24;return BigInt(i)+(BigInt(o)<<BigInt(32))});E.prototype.readBigUInt64BE=Ue(function(t){t=t>>>0,_r(t,"offset");let e=this[t],n=this[t+7];(e===void 0||n===void 0)&&yn(t,this.length-8);let i=e*2**24+this[++t]*2**16+this[++t]*2**8+this[++t],o=this[++t]*2**24+this[++t]*2**16+this[++t]*2**8+n;return(BigInt(i)<<BigInt(32))+BigInt(o)});E.prototype.readIntLE=function(t,e,n){t=t>>>0,e=e>>>0,n||ht(t,e,this.length);let i=this[t],o=1,s=0;for(;++s<e&&(o*=256);)i+=this[t+s]*o;return o*=128,i>=o&&(i-=Math.pow(2,8*e)),i};E.prototype.readIntBE=function(t,e,n){t=t>>>0,e=e>>>0,n||ht(t,e,this.length);let i=e,o=1,s=this[t+--i];for(;i>0&&(o*=256);)s+=this[t+--i]*o;return o*=128,s>=o&&(s-=Math.pow(2,8*e)),s};E.prototype.readInt8=function(t,e){return t=t>>>0,e||ht(t,1,this.length),this[t]&128?(255-this[t]+1)*-1:this[t]};E.prototype.readInt16LE=function(t,e){t=t>>>0,e||ht(t,2,this.length);let n=this[t]|this[t+1]<<8;return n&32768?n|4294901760:n};E.prototype.readInt16BE=function(t,e){t=t>>>0,e||ht(t,2,this.length);let n=this[t+1]|this[t]<<8;return n&32768?n|4294901760:n};E.prototype.readInt32LE=function(t,e){return t=t>>>0,e||ht(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24};E.prototype.readInt32BE=function(t,e){return t=t>>>0,e||ht(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]};E.prototype.readBigInt64LE=Ue(function(t){t=t>>>0,_r(t,"offset");let e=this[t],n=this[t+7];(e===void 0||n===void 0)&&yn(t,this.length-8);let i=this[t+4]+this[t+5]*2**8+this[t+6]*2**16+(n<<24);return(BigInt(i)<<BigInt(32))+BigInt(e+this[++t]*2**8+this[++t]*2**16+this[++t]*2**24)});E.prototype.readBigInt64BE=Ue(function(t){t=t>>>0,_r(t,"offset");let e=this[t],n=this[t+7];(e===void 0||n===void 0)&&yn(t,this.length-8);let i=(e<<24)+this[++t]*2**16+this[++t]*2**8+this[++t];return(BigInt(i)<<BigInt(32))+BigInt(this[++t]*2**24+this[++t]*2**16+this[++t]*2**8+n)});E.prototype.readFloatLE=function(t,e){return t=t>>>0,e||ht(t,4,this.length),Cr.read(this,t,!0,23,4)};E.prototype.readFloatBE=function(t,e){return t=t>>>0,e||ht(t,4,this.length),Cr.read(this,t,!1,23,4)};E.prototype.readDoubleLE=function(t,e){return t=t>>>0,e||ht(t,8,this.length),Cr.read(this,t,!0,52,8)};E.prototype.readDoubleBE=function(t,e){return t=t>>>0,e||ht(t,8,this.length),Cr.read(this,t,!1,52,8)};function At(r,t,e,n,i,o){if(!E.isBuffer(r))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>i||t<o)throw new RangeError('"value" argument is out of bounds');if(e+n>r.length)throw new RangeError("Index out of range")}E.prototype.writeUintLE=E.prototype.writeUIntLE=function(t,e,n,i){if(t=+t,e=e>>>0,n=n>>>0,!i){let c=Math.pow(2,8*n)-1;At(this,t,e,n,c,0)}let o=1,s=0;for(this[e]=t&255;++s<n&&(o*=256);)this[e+s]=t/o&255;return e+n};E.prototype.writeUintBE=E.prototype.writeUIntBE=function(t,e,n,i){if(t=+t,e=e>>>0,n=n>>>0,!i){let c=Math.pow(2,8*n)-1;At(this,t,e,n,c,0)}let o=n-1,s=1;for(this[e+o]=t&255;--o>=0&&(s*=256);)this[e+o]=t/s&255;return e+n};E.prototype.writeUint8=E.prototype.writeUInt8=function(t,e,n){return t=+t,e=e>>>0,n||At(this,t,e,1,255,0),this[e]=t&255,e+1};E.prototype.writeUint16LE=E.prototype.writeUInt16LE=function(t,e,n){return t=+t,e=e>>>0,n||At(this,t,e,2,65535,0),this[e]=t&255,this[e+1]=t>>>8,e+2};E.prototype.writeUint16BE=E.prototype.writeUInt16BE=function(t,e,n){return t=+t,e=e>>>0,n||At(this,t,e,2,65535,0),this[e]=t>>>8,this[e+1]=t&255,e+2};E.prototype.writeUint32LE=E.prototype.writeUInt32LE=function(t,e,n){return t=+t,e=e>>>0,n||At(this,t,e,4,4294967295,0),this[e+3]=t>>>24,this[e+2]=t>>>16,this[e+1]=t>>>8,this[e]=t&255,e+4};E.prototype.writeUint32BE=E.prototype.writeUInt32BE=function(t,e,n){return t=+t,e=e>>>0,n||At(this,t,e,4,4294967295,0),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=t&255,e+4};function oa(r,t,e,n,i){fa(t,n,i,r,e,7);let o=Number(t&BigInt(4294967295));r[e++]=o,o=o>>8,r[e++]=o,o=o>>8,r[e++]=o,o=o>>8,r[e++]=o;let s=Number(t>>BigInt(32)&BigInt(4294967295));return r[e++]=s,s=s>>8,r[e++]=s,s=s>>8,r[e++]=s,s=s>>8,r[e++]=s,e}function sa(r,t,e,n,i){fa(t,n,i,r,e,7);let o=Number(t&BigInt(4294967295));r[e+7]=o,o=o>>8,r[e+6]=o,o=o>>8,r[e+5]=o,o=o>>8,r[e+4]=o;let s=Number(t>>BigInt(32)&BigInt(4294967295));return r[e+3]=s,s=s>>8,r[e+2]=s,s=s>>8,r[e+1]=s,s=s>>8,r[e]=s,e+8}E.prototype.writeBigUInt64LE=Ue(function(t,e=0){return oa(this,t,e,BigInt(0),BigInt("0xffffffffffffffff"))});E.prototype.writeBigUInt64BE=Ue(function(t,e=0){return sa(this,t,e,BigInt(0),BigInt("0xffffffffffffffff"))});E.prototype.writeIntLE=function(t,e,n,i){if(t=+t,e=e>>>0,!i){let a=Math.pow(2,8*n-1);At(this,t,e,n,a-1,-a)}let o=0,s=1,c=0;for(this[e]=t&255;++o<n&&(s*=256);)t<0&&c===0&&this[e+o-1]!==0&&(c=1),this[e+o]=(t/s>>0)-c&255;return e+n};E.prototype.writeIntBE=function(t,e,n,i){if(t=+t,e=e>>>0,!i){let a=Math.pow(2,8*n-1);At(this,t,e,n,a-1,-a)}let o=n-1,s=1,c=0;for(this[e+o]=t&255;--o>=0&&(s*=256);)t<0&&c===0&&this[e+o+1]!==0&&(c=1),this[e+o]=(t/s>>0)-c&255;return e+n};E.prototype.writeInt8=function(t,e,n){return t=+t,e=e>>>0,n||At(this,t,e,1,127,-128),t<0&&(t=255+t+1),this[e]=t&255,e+1};E.prototype.writeInt16LE=function(t,e,n){return t=+t,e=e>>>0,n||At(this,t,e,2,32767,-32768),this[e]=t&255,this[e+1]=t>>>8,e+2};E.prototype.writeInt16BE=function(t,e,n){return t=+t,e=e>>>0,n||At(this,t,e,2,32767,-32768),this[e]=t>>>8,this[e+1]=t&255,e+2};E.prototype.writeInt32LE=function(t,e,n){return t=+t,e=e>>>0,n||At(this,t,e,4,2147483647,-2147483648),this[e]=t&255,this[e+1]=t>>>8,this[e+2]=t>>>16,this[e+3]=t>>>24,e+4};E.prototype.writeInt32BE=function(t,e,n){return t=+t,e=e>>>0,n||At(this,t,e,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=t&255,e+4};E.prototype.writeBigInt64LE=Ue(function(t,e=0){return oa(this,t,e,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});E.prototype.writeBigInt64BE=Ue(function(t,e=0){return sa(this,t,e,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});function ca(r,t,e,n,i,o){if(e+n>r.length)throw new RangeError("Index out of range");if(e<0)throw new RangeError("Index out of range")}function aa(r,t,e,n,i){return t=+t,e=e>>>0,i||ca(r,t,e,4,34028234663852886e22,-34028234663852886e22),Cr.write(r,t,e,n,23,4),e+4}E.prototype.writeFloatLE=function(t,e,n){return aa(this,t,e,!0,n)};E.prototype.writeFloatBE=function(t,e,n){return aa(this,t,e,!1,n)};function ua(r,t,e,n,i){return t=+t,e=e>>>0,i||ca(r,t,e,8,17976931348623157e292,-17976931348623157e292),Cr.write(r,t,e,n,52,8),e+8}E.prototype.writeDoubleLE=function(t,e,n){return ua(this,t,e,!0,n)};E.prototype.writeDoubleBE=function(t,e,n){return ua(this,t,e,!1,n)};E.prototype.copy=function(t,e,n,i){if(!E.isBuffer(t))throw new TypeError("argument should be a Buffer");if(n||(n=0),!i&&i!==0&&(i=this.length),e>=t.length&&(e=t.length),e||(e=0),i>0&&i<n&&(i=n),i===n||t.length===0||this.length===0)return 0;if(e<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),t.length-e<i-n&&(i=t.length-e+n);let o=i-n;return this===t&&typeof Uint8Array.prototype.copyWithin=="function"?this.copyWithin(e,n,i):Uint8Array.prototype.set.call(t,this.subarray(n,i),e),o};E.prototype.fill=function(t,e,n,i){if(typeof t=="string"){if(typeof e=="string"?(i=e,e=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"&&!E.isEncoding(i))throw new TypeError("Unknown encoding: "+i);if(t.length===1){let s=t.charCodeAt(0);(i==="utf8"&&s<128||i==="latin1")&&(t=s)}}else typeof t=="number"?t=t&255:typeof t=="boolean"&&(t=Number(t));if(e<0||this.length<e||this.length<n)throw new RangeError("Out of range index");if(n<=e)return this;e=e>>>0,n=n===void 0?this.length:n>>>0,t||(t=0);let o;if(typeof t=="number")for(o=e;o<n;++o)this[o]=t;else{let s=E.isBuffer(t)?t:E.from(t,i),c=s.length;if(c===0)throw new TypeError('The value "'+t+'" is invalid for argument "value"');for(o=0;o<n-e;++o)this[o+e]=s[o%c]}return this};var Ir={};function Lo(r,t,e){Ir[r]=class extends e{constructor(){super(),Object.defineProperty(this,"message",{value:t.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}`}}}Lo("ERR_BUFFER_OUT_OF_BOUNDS",function(r){return r?`${r} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"},RangeError);Lo("ERR_INVALID_ARG_TYPE",function(r,t){return`The "${r}" argument must be of type number. Received type ${typeof t}`},TypeError);Lo("ERR_OUT_OF_RANGE",function(r,t,e){let n=`The value of "${r}" is out of range.`,i=e;return Number.isInteger(e)&&Math.abs(e)>2**32?i=Qc(String(e)):typeof e=="bigint"&&(i=String(e),(e>BigInt(2)**BigInt(32)||e<-(BigInt(2)**BigInt(32)))&&(i=Qc(i)),i+="n"),n+=` It must be ${t}. Received ${i}`,n},RangeError);function Qc(r){let t="",e=r.length,n=r[0]==="-"?1:0;for(;e>=n+4;e-=3)t=`_${r.slice(e-3,e)}${t}`;return`${r.slice(0,e)}${t}`}function eh(r,t,e){_r(t,"offset"),(r[t]===void 0||r[t+e]===void 0)&&yn(t,r.length-(e+1))}function fa(r,t,e,n,i,o){if(r>e||r<t){let s=typeof t=="bigint"?"n":"",c;throw o>3?t===0||t===BigInt(0)?c=`>= 0${s} and < 2${s} ** ${(o+1)*8}${s}`:c=`>= -(2${s} ** ${(o+1)*8-1}${s}) and < 2 ** ${(o+1)*8-1}${s}`:c=`>= ${t}${s} and <= ${e}${s}`,new Ir.ERR_OUT_OF_RANGE("value",c,r)}eh(n,i,o)}function _r(r,t){if(typeof r!="number")throw new Ir.ERR_INVALID_ARG_TYPE(t,"number",r)}function yn(r,t,e){throw Math.floor(r)!==r?(_r(r,e),new Ir.ERR_OUT_OF_RANGE(e||"offset","an integer",r)):t<0?new Ir.ERR_BUFFER_OUT_OF_BOUNDS:new Ir.ERR_OUT_OF_RANGE(e||"offset",`>= ${e?1:0} and <= ${t}`,r)}var rh=/[^+/0-9A-Za-z-_]/g;function nh(r){if(r=r.split("=")[0],r=r.trim().replace(rh,""),r.length<2)return"";for(;r.length%4!==0;)r=r+"=";return r}function Io(r,t){t=t||1/0;let e,n=r.length,i=null,o=[];for(let s=0;s<n;++s){if(e=r.charCodeAt(s),e>55295&&e<57344){if(!i){if(e>56319){(t-=3)>-1&&o.push(239,191,189);continue}else if(s+1===n){(t-=3)>-1&&o.push(239,191,189);continue}i=e;continue}if(e<56320){(t-=3)>-1&&o.push(239,191,189),i=e;continue}e=(i-55296<<10|e-56320)+65536}else i&&(t-=3)>-1&&o.push(239,191,189);if(i=null,e<128){if((t-=1)<0)break;o.push(e)}else if(e<2048){if((t-=2)<0)break;o.push(e>>6|192,e&63|128)}else if(e<65536){if((t-=3)<0)break;o.push(e>>12|224,e>>6&63|128,e&63|128)}else if(e<1114112){if((t-=4)<0)break;o.push(e>>18|240,e>>12&63|128,e>>6&63|128,e&63|128)}else throw new Error("Invalid code point")}return o}function ih(r){let t=[];for(let e=0;e<r.length;++e)t.push(r.charCodeAt(e)&255);return t}function oh(r,t){let e,n,i,o=[];for(let s=0;s<r.length&&!((t-=2)<0);++s)e=r.charCodeAt(s),n=e>>8,i=e%256,o.push(i),o.push(n);return o}function la(r){return So.toByteArray(nh(r))}function Qn(r,t,e,n){let i;for(i=0;i<n&&!(i+e>=t.length||i>=r.length);++i)t[i+e]=r[i];return i}function ee(r,t){return r instanceof t||r!=null&&r.constructor!=null&&r.constructor.name!=null&&r.constructor.name===t.name}function Oo(r){return r!==r}var sh=function(){let r="0123456789abcdef",t=new Array(256);for(let e=0;e<16;++e){let n=e*16;for(let i=0;i<16;++i)t[n+i]=r[e]+r[i]}return t}();function Ue(r){return typeof BigInt>"u"?ch:r}function ch(){throw new Error("BigInt not supported")}});var No=Q((s0,ha)=>{"use strict";var Ro=null;ha.exports=function(){return Ro===null&&(Ro={textEncoder:new TextEncoder,textDecoder:new TextDecoder}),Ro}});var jo=Q(ya=>{"use strict";var Do=Vt(),ah=new Set(["buffer","view","utf8"]),Mo=class{constructor(t){if(this.encode=t.encode||this.encode,this.decode=t.decode||this.decode,this.name=t.name||this.name,this.format=t.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"||!ah.has(this.format))throw new TypeError("The 'format' property must be one of 'buffer', 'view', 'utf8'");t.createViewTranscoder&&(this.createViewTranscoder=t.createViewTranscoder),t.createBufferTranscoder&&(this.createBufferTranscoder=t.createBufferTranscoder),t.createUTF8Transcoder&&(this.createUTF8Transcoder=t.createUTF8Transcoder)}get commonName(){return this.name.split("+")[0]}createBufferTranscoder(){throw new Do(`Encoding '${this.name}' cannot be transcoded to 'buffer'`,{code:"LEVEL_ENCODING_NOT_SUPPORTED"})}createViewTranscoder(){throw new Do(`Encoding '${this.name}' cannot be transcoded to 'view'`,{code:"LEVEL_ENCODING_NOT_SUPPORTED"})}createUTF8Transcoder(){throw new Do(`Encoding '${this.name}' cannot be transcoded to 'utf8'`,{code:"LEVEL_ENCODING_NOT_SUPPORTED"})}};ya.Encoding=Mo});var Vo=Q(ei=>{"use strict";var{Buffer:Jo}=ti()||{},{Encoding:Go}=jo(),uh=No(),pn=class extends Go{constructor(t){super({...t,format:"buffer"})}createViewTranscoder(){return new dn({encode:this.encode,decode:t=>this.decode(Jo.from(t.buffer,t.byteOffset,t.byteLength)),name:`${this.name}+view`})}createBufferTranscoder(){return this}},dn=class extends Go{constructor(t){super({...t,format:"view"})}createBufferTranscoder(){return new pn({encode:t=>{let e=this.encode(t);return Jo.from(e.buffer,e.byteOffset,e.byteLength)},decode:this.decode,name:`${this.name}+buffer`})}createViewTranscoder(){return this}},Ho=class extends Go{constructor(t){super({...t,format:"utf8"})}createBufferTranscoder(){return new pn({encode:t=>Jo.from(this.encode(t),"utf8"),decode:t=>this.decode(t.toString("utf8")),name:`${this.name}+buffer`})}createViewTranscoder(){let{textEncoder:t,textDecoder:e}=uh();return new dn({encode:n=>t.encode(this.encode(n)),decode:n=>this.decode(e.decode(n)),name:`${this.name}+view`})}createUTF8Transcoder(){return this}};ei.BufferFormat=pn;ei.ViewFormat=dn;ei.UTF8Format=Ho});var wa=Q(cr=>{"use strict";var{Buffer:wt}=ti()||{Buffer:{isBuffer:()=>!1}},{textEncoder:da,textDecoder:pa}=No()(),{BufferFormat:mn,ViewFormat:qo,UTF8Format:ma}=Vo(),ri=r=>r;cr.utf8=new ma({encode:function(r){return wt.isBuffer(r)?r.toString("utf8"):ArrayBuffer.isView(r)?pa.decode(r):String(r)},decode:ri,name:"utf8",createViewTranscoder(){return new qo({encode:function(r){return ArrayBuffer.isView(r)?r:da.encode(r)},decode:function(r){return pa.decode(r)},name:`${this.name}+view`})},createBufferTranscoder(){return new mn({encode:function(r){return wt.isBuffer(r)?r:ArrayBuffer.isView(r)?wt.from(r.buffer,r.byteOffset,r.byteLength):wt.from(String(r),"utf8")},decode:function(r){return r.toString("utf8")},name:`${this.name}+buffer`})}});cr.json=new ma({encode:JSON.stringify,decode:JSON.parse,name:"json"});cr.buffer=new mn({encode:function(r){return wt.isBuffer(r)?r:ArrayBuffer.isView(r)?wt.from(r.buffer,r.byteOffset,r.byteLength):wt.from(String(r),"utf8")},decode:ri,name:"buffer",createViewTranscoder(){return new qo({encode:function(r){return ArrayBuffer.isView(r)?r:wt.from(String(r),"utf8")},decode:function(r){return wt.from(r.buffer,r.byteOffset,r.byteLength)},name:`${this.name}+view`})}});cr.view=new qo({encode:function(r){return ArrayBuffer.isView(r)?r:da.encode(r)},decode:ri,name:"view",createBufferTranscoder(){return new mn({encode:function(r){return wt.isBuffer(r)?r:ArrayBuffer.isView(r)?wt.from(r.buffer,r.byteOffset,r.byteLength):wt.from(String(r),"utf8")},decode:ri,name:`${this.name}+buffer`})}});cr.hex=new mn({encode:function(r){return wt.isBuffer(r)?r:wt.from(String(r),"hex")},decode:function(r){return r.toString("hex")},name:"hex"});cr.base64=new mn({encode:function(r){return wt.isBuffer(r)?r:wt.from(String(r),"base64")},decode:function(r){return r.toString("base64")},name:"base64"})});var ba=Q(xa=>{"use strict";var ga=Vt(),ii=wa(),{Encoding:fh}=jo(),{BufferFormat:lh,ViewFormat:hh,UTF8Format:yh}=Vo(),wn=Symbol("formats"),ni=Symbol("encodings"),ph=new Set(["buffer","view","utf8"]),Fo=class{constructor(t){if(Array.isArray(t)){if(!t.every(e=>ph.has(e)))throw new TypeError("Format must be one of 'buffer', 'view', 'utf8'")}else throw new TypeError("The first argument 'formats' must be an array");this[ni]=new Map,this[wn]=new Set(t);for(let e in ii)try{this.encoding(e)}catch(n){if(n.code!=="LEVEL_ENCODING_NOT_SUPPORTED")throw n}}encodings(){return Array.from(new Set(this[ni].values()))}encoding(t){let e=this[ni].get(t);if(e===void 0){if(typeof t=="string"&&t!==""){if(e=gh[t],!e)throw new ga(`Encoding '${t}' is not found`,{code:"LEVEL_ENCODING_NOT_FOUND"})}else{if(typeof t!="object"||t===null)throw new TypeError("First argument 'encoding' must be a string or object");e=dh(t)}let{name:n,format:i}=e;if(!this[wn].has(i))if(this[wn].has("view"))e=e.createViewTranscoder();else if(this[wn].has("buffer"))e=e.createBufferTranscoder();else if(this[wn].has("utf8"))e=e.createUTF8Transcoder();else throw new ga(`Encoding '${n}' cannot be transcoded`,{code:"LEVEL_ENCODING_NOT_SUPPORTED"});for(let o of[t,n,e.name,e.commonName])this[ni].set(o,e)}return e}};xa.Transcoder=Fo;function dh(r){if(r instanceof fh)return r;let t="type"in r&&typeof r.type=="string"?r.type:void 0,e=r.name||t||`anonymous-${xh++}`;switch(mh(r)){case"view":return new hh({...r,name:e});case"utf8":return new yh({...r,name:e});case"buffer":return new lh({...r,name:e});default:throw new TypeError("Format must be one of 'buffer', 'view', 'utf8'")}}function mh(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 wh={binary:ii.buffer,"utf-8":ii.utf8},gh={...ii,...wh},xh=0});var va=Q((l0,$o)=>{"use strict";var bh=Object.prototype.hasOwnProperty,bt="~";function gn(){}Object.create&&(gn.prototype=Object.create(null),new gn().__proto__||(bt=!1));function Eh(r,t,e){this.fn=r,this.context=t,this.once=e||!1}function Ea(r,t,e,n,i){if(typeof e!="function")throw new TypeError("The listener must be a function");var o=new Eh(e,n||r,i),s=bt?bt+t:t;return r._events[s]?r._events[s].fn?r._events[s]=[r._events[s],o]:r._events[s].push(o):(r._events[s]=o,r._eventsCount++),r}function oi(r,t){--r._eventsCount===0?r._events=new gn:delete r._events[t]}function gt(){this._events=new gn,this._eventsCount=0}gt.prototype.eventNames=function(){var t=[],e,n;if(this._eventsCount===0)return t;for(n in e=this._events)bh.call(e,n)&&t.push(bt?n.slice(1):n);return Object.getOwnPropertySymbols?t.concat(Object.getOwnPropertySymbols(e)):t};gt.prototype.listeners=function(t){var e=bt?bt+t:t,n=this._events[e];if(!n)return[];if(n.fn)return[n.fn];for(var i=0,o=n.length,s=new Array(o);i<o;i++)s[i]=n[i].fn;return s};gt.prototype.listenerCount=function(t){var e=bt?bt+t:t,n=this._events[e];return n?n.fn?1:n.length:0};gt.prototype.emit=function(t,e,n,i,o,s){var c=bt?bt+t:t;if(!this._events[c])return!1;var a=this._events[c],u=arguments.length,f,l;if(a.fn){switch(a.once&&this.removeListener(t,a.fn,void 0,!0),u){case 1:return a.fn.call(a.context),!0;case 2:return a.fn.call(a.context,e),!0;case 3:return a.fn.call(a.context,e,n),!0;case 4:return a.fn.call(a.context,e,n,i),!0;case 5:return a.fn.call(a.context,e,n,i,o),!0;case 6:return a.fn.call(a.context,e,n,i,o,s),!0}for(l=1,f=new Array(u-1);l<u;l++)f[l-1]=arguments[l];a.fn.apply(a.context,f)}else{var y=a.length,m;for(l=0;l<y;l++)switch(a[l].once&&this.removeListener(t,a[l].fn,void 0,!0),u){case 1:a[l].fn.call(a[l].context);break;case 2:a[l].fn.call(a[l].context,e);break;case 3:a[l].fn.call(a[l].context,e,n);break;case 4:a[l].fn.call(a[l].context,e,n,i);break;default:if(!f)for(m=1,f=new Array(u-1);m<u;m++)f[m-1]=arguments[m];a[l].fn.apply(a[l].context,f)}}return!0};gt.prototype.on=function(t,e,n){return Ea(this,t,e,n,!1)};gt.prototype.once=function(t,e,n){return Ea(this,t,e,n,!0)};gt.prototype.removeListener=function(t,e,n,i){var o=bt?bt+t:t;if(!this._events[o])return this;if(!e)return oi(this,o),this;var s=this._events[o];if(s.fn)s.fn===e&&(!i||s.once)&&(!n||s.context===n)&&oi(this,o);else{for(var c=0,a=[],u=s.length;c<u;c++)(s[c].fn!==e||i&&!s[c].once||n&&s[c].context!==n)&&a.push(s[c]);a.length?this._events[o]=a.length===1?a[0]:a:oi(this,o)}return this};gt.prototype.removeAllListeners=function(t){var e;return t?(e=bt?bt+t:t,this._events[e]&&oi(this,e)):(this._events=new gn,this._eventsCount=0),this};gt.prototype.off=gt.prototype.removeListener;gt.prototype.addListener=gt.prototype.on;gt.prefixed=bt;gt.EventEmitter=gt;typeof $o<"u"&&($o.exports=gt)});var Ba=Q((h0,Aa)=>{Aa.exports=typeof queueMicrotask=="function"?queueMicrotask:r=>Promise.resolve().then(r)});var xn=Q(Wo=>{"use strict";var Pa=Ba();Wo.fromCallback=function(r,t){if(r===void 0){var e=new Promise(function(n,i){r=function(o,s){o?i(o):n(s)}});r[t!==void 0?t:"promise"]=e}else if(typeof r!="function")throw new TypeError("Callback must be a function");return r};Wo.fromPromise=function(r,t){if(t===void 0)return r;r.then(function(e){Pa(()=>t(null,e))}).catch(function(e){Pa(()=>t(e))})}});var si=Q(zo=>{"use strict";zo.getCallback=function(r,t){return typeof r=="function"?r:t};zo.getOptions=function(r,t){return typeof r=="object"&&r!==null?r:t!==void 0?t:{}}});var Re=Q(fi=>{"use strict";var{fromCallback:Zo}=xn(),Kt=Vt(),{getOptions:Yo,getCallback:Ka}=si(),ar=Symbol("promise"),Or=Symbol("callback"),re=Symbol("working"),ur=Symbol("handleOne"),de=Symbol("handleMany"),Xo=Symbol("autoClose"),Le=Symbol("finishWork"),ne=Symbol("returnMany"),Ie=Symbol("closing"),bn=Symbol("handleClose"),ci=Symbol("closed"),En=Symbol("closeCallbacks"),_e=Symbol("keyEncoding"),fr=Symbol("valueEncoding"),Qo=Symbol("abortOnClose"),ai=Symbol("legacy"),ts=Symbol("keys"),es=Symbol("values"),Ce=Symbol("limit"),Lt=Symbol("count"),ui=Object.freeze({}),vh=()=>{},Ta=!1,vn=class{constructor(t,e,n){if(typeof t!="object"||t===null){let i=t===null?"null":typeof t;throw new TypeError(`The first argument must be an abstract-level database, received ${i}`)}if(typeof e!="object"||e===null)throw new TypeError("The second argument must be an options object");this[ci]=!1,this[En]=[],this[re]=!1,this[Ie]=!1,this[Xo]=!1,this[Or]=null,this[ur]=this[ur].bind(this),this[de]=this[de].bind(this),this[bn]=this[bn].bind(this),this[_e]=e[_e],this[fr]=e[fr],this[ai]=n,this[Ce]=Number.isInteger(e.limit)&&e.limit>=0?e.limit:1/0,this[Lt]=0,this[Qo]=!!e.abortOnClose,this.db=t,this.db.attachResource(this),this.nextTick=t.nextTick}get count(){return this[Lt]}get limit(){return this[Ce]}next(t){let e;if(t===void 0)e=new Promise((n,i)=>{t=(o,s,c)=>{o?i(o):this[ai]?s===void 0&&c===void 0?n():n([s,c]):n(s)}});else if(typeof t!="function")throw new TypeError("Callback must be a function");return this[Ie]?this.nextTick(t,new Kt("Iterator is not open: cannot call next() after close()",{code:"LEVEL_ITERATOR_NOT_OPEN"})):this[re]?this.nextTick(t,new Kt("Iterator is busy: cannot call next() until previous call has completed",{code:"LEVEL_ITERATOR_BUSY"})):(this[re]=!0,this[Or]=t,this[Lt]>=this[Ce]?this.nextTick(this[ur],null):this._next(this[ur])),e}_next(t){this.nextTick(t)}nextv(t,e,n){return n=Ka(e,n),n=Zo(n,ar),e=Yo(e,ui),Number.isInteger(t)?(this[Ie]?this.nextTick(n,new Kt("Iterator is not open: cannot call nextv() after close()",{code:"LEVEL_ITERATOR_NOT_OPEN"})):this[re]?this.nextTick(n,new Kt("Iterator is busy: cannot call nextv() until previous call has completed",{code:"LEVEL_ITERATOR_BUSY"})):(t<1&&(t=1),this[Ce]<1/0&&(t=Math.min(t,this[Ce]-this[Lt])),this[re]=!0,this[Or]=n,t<=0?this.nextTick(this[de],null,[]):this._nextv(t,e,this[de])),n[ar]):(this.nextTick(n,new TypeError("The first argument 'size' must be an integer")),n[ar])}_nextv(t,e,n){let i=[],o=(s,c,a)=>{if(s)return n(s);if(this[ai]?c===void 0&&a===void 0:c===void 0)return n(null,i);i.push(this[ai]?[c,a]:c),i.length===t?n(null,i):this._next(o)};this._next(o)}all(t,e){return e=Ka(t,e),e=Zo(e,ar),t=Yo(t,ui),this[Ie]?this.nextTick(e,new Kt("Iterator is not open: cannot call all() after close()",{code:"LEVEL_ITERATOR_NOT_OPEN"})):this[re]?this.nextTick(e,new Kt("Iterator is busy: cannot call all() until previous call has completed",{code:"LEVEL_ITERATOR_BUSY"})):(this[re]=!0,this[Or]=e,this[Xo]=!0,this[Lt]>=this[Ce]?this.nextTick(this[de],null,[]):this._all(t,this[de])),e[ar]}_all(t,e){let n=this[Lt],i=[],o=()=>{let c=this[Ce]<1/0?Math.min(1e3,this[Ce]-n):1e3;c<=0?this.nextTick(e,null,i):this._nextv(c,ui,s)},s=(c,a)=>{c?e(c):a.length===0?e(null,i):(i.push.apply(i,a),n+=a.length,o())};o()}[Le](){let t=this[Or];return this[Qo]&&t===null?vh:(this[re]=!1,this[Or]=null,this[Ie]&&this._close(this[bn]),t)}[ne](t,e,n){this[Xo]?this.close(t.bind(null,e,n)):t(e,n)}seek(t,e){if(e=Yo(e,ui),!this[Ie]){if(this[re])throw new Kt("Iterator is busy: cannot call seek() until next() has completed",{code:"LEVEL_ITERATOR_BUSY"});{let n=this.db.keyEncoding(e.keyEncoding||this[_e]),i=n.format;e.keyEncoding!==i&&(e={...e,keyEncoding:i});let o=this.db.prefixKey(n.encode(t),i);this._seek(o,e)}}}_seek(t,e){throw new Kt("Iterator does not support seek()",{code:"LEVEL_NOT_SUPPORTED"})}close(t){return t=Zo(t,ar),this[ci]?this.nextTick(t):this[Ie]?this[En].push(t):(this[Ie]=!0,this[En].push(t),this[re]?this[Qo]&&this[Le]()(new Kt("Aborted on iterator close()",{code:"LEVEL_ITERATOR_NOT_OPEN"})):this._close(this[bn])),t[ar]}_close(t){this.nextTick(t)}[bn](){this[ci]=!0,this.db.detachResource(this);let t=this[En];this[En]=[];for(let e of t)e()}async*[Symbol.asyncIterator](){try{let t;for(;(t=await this.next())!==void 0;)yield t}finally{this[ci]||await this.close()}}},Rr=class extends vn{constructor(t,e){super(t,e,!0),this[ts]=e.keys!==!1,this[es]=e.values!==!1}[ur](t,e,n){let i=this[Le]();if(t)return i(t);try{e=this[ts]&&e!==void 0?this[_e].decode(e):void 0,n=this[es]&&n!==void 0?this[fr].decode(n):void 0}catch(o){return i(new Oe("entry",o))}e===void 0&&n===void 0||this[Lt]++,i(null,e,n)}[de](t,e){let n=this[Le]();if(t)return this[ne](n,t);try{for(let i of e){let o=i[0],s=i[1];i[0]=this[ts]&&o!==void 0?this[_e].decode(o):void 0,i[1]=this[es]&&s!==void 0?this[fr].decode(s):void 0}}catch(i){return this[ne](n,new Oe("entries",i))}this[Lt]+=e.length,this[ne](n,null,e)}end(t){return!Ta&&typeof console<"u"&&(Ta=!0,console.warn(new Kt("The iterator.end() method was renamed to close() and end() is an alias that will be removed in a future version",{code:"LEVEL_LEGACY"}))),this.close(t)}},rs=class extends vn{constructor(t,e){super(t,e,!1)}[ur](t,e){let n=this[Le]();if(t)return n(t);try{e=e!==void 0?this[_e].decode(e):void 0}catch(i){return n(new Oe("key",i))}e!==void 0&&this[Lt]++,n(null,e)}[de](t,e){let n=this[Le]();if(t)return this[ne](n,t);try{for(let i=0;i<e.length;i++){let o=e[i];e[i]=o!==void 0?this[_e].decode(o):void 0}}catch(i){return this[ne](n,new Oe("keys",i))}this[Lt]+=e.length,this[ne](n,null,e)}},ns=class extends vn{constructor(t,e){super(t,e,!1)}[ur](t,e){let n=this[Le]();if(t)return n(t);try{e=e!==void 0?this[fr].decode(e):void 0}catch(i){return n(new Oe("value",i))}e!==void 0&&this[Lt]++,n(null,e)}[de](t,e){let n=this[Le]();if(t)return this[ne](n,t);try{for(let i=0;i<e.length;i++){let o=e[i];e[i]=o!==void 0?this[fr].decode(o):void 0}}catch(i){return this[ne](n,new Oe("values",i))}this[Lt]+=e.length,this[ne](n,null,e)}},Oe=class extends Kt{constructor(t,e){super(`Iterator could not decode ${t}`,{code:"LEVEL_DECODE_ERROR",cause:e})}};for(let r of["_ended property","_nexting property","_end method"])Object.defineProperty(Rr.prototype,r.split(" ")[0],{get(){throw new Kt(`The ${r} has been removed`,{code:"LEVEL_LEGACY"})},set(){throw new Kt(`The ${r} has been removed`,{code:"LEVEL_LEGACY"})}});Rr.keyEncoding=_e;Rr.valueEncoding=fr;fi.AbstractIterator=Rr;fi.AbstractKeyIterator=rs;fi.AbstractValueIterator=ns});var Sa=Q(is=>{"use strict";var{AbstractKeyIterator:Ah,AbstractValueIterator:Bh}=Re(),lr=Symbol("iterator"),An=Symbol("callback"),Nr=Symbol("handleOne"),hr=Symbol("handleMany"),Bn=class extends Ah{constructor(t,e){super(t,e),this[lr]=t.iterator({...e,keys:!0,values:!1}),this[Nr]=this[Nr].bind(this),this[hr]=this[hr].bind(this)}},li=class extends Bh{constructor(t,e){super(t,e),this[lr]=t.iterator({...e,keys:!1,values:!0}),this[Nr]=this[Nr].bind(this),this[hr]=this[hr].bind(this)}};for(let r of[Bn,li]){let t=r===Bn,e=t?n=>n[0]:n=>n[1];r.prototype._next=function(n){this[An]=n,this[lr].next(this[Nr])},r.prototype[Nr]=function(n,i,o){let s=this[An];n?s(n):s(null,t?i:o)},r.prototype._nextv=function(n,i,o){this[An]=o,this[lr].nextv(n,i,this[hr])},r.prototype._all=function(n,i){this[An]=i,this[lr].all(n,this[hr])},r.prototype[hr]=function(n,i){let o=this[An];n?o(n):o(null,i.map(e))},r.prototype._seek=function(n,i){this[lr].seek(n,i)},r.prototype._close=function(n){this[lr].close(n)}}is.DefaultKeyIterator=Bn;is.DefaultValueIterator=li});var ka=Q(wi=>{"use strict";var{AbstractIterator:Ph,AbstractKeyIterator:Kh,AbstractValueIterator:Th}=Re(),os=Vt(),Bt=Symbol("nut"),di=Symbol("undefer"),mi=Symbol("factory"),hi=class extends Ph{constructor(t,e){super(t,e),this[Bt]=null,this[mi]=()=>t.iterator(e),this.db.defer(()=>this[di]())}},yi=class extends Kh{constructor(t,e){super(t,e),this[Bt]=null,this[mi]=()=>t.keys(e),this.db.defer(()=>this[di]())}},pi=class extends Th{constructor(t,e){super(t,e),this[Bt]=null,this[mi]=()=>t.values(e),this.db.defer(()=>this[di]())}};for(let r of[hi,yi,pi])r.prototype[di]=function(){this.db.status==="open"&&(this[Bt]=this[mi]())},r.prototype._next=function(t){this[Bt]!==null?this[Bt].next(t):this.db.status==="opening"?this.db.defer(()=>this._next(t)):this.nextTick(t,new os("Iterator is not open: cannot call next() after close()",{code:"LEVEL_ITERATOR_NOT_OPEN"}))},r.prototype._nextv=function(t,e,n){this[Bt]!==null?this[Bt].nextv(t,e,n):this.db.status==="opening"?this.db.defer(()=>this._nextv(t,e,n)):this.nextTick(n,new os("Iterator is not open: cannot call nextv() after close()",{code:"LEVEL_ITERATOR_NOT_OPEN"}))},r.prototype._all=function(t,e){this[Bt]!==null?this[Bt].all(e):this.db.status==="opening"?this.db.defer(()=>this._all(t,e)):this.nextTick(e,new os("Iterator is not open: cannot call all() after close()",{code:"LEVEL_ITERATOR_NOT_OPEN"}))},r.prototype._seek=function(t,e){this[Bt]!==null?this[Bt]._seek(t,e):this.db.status==="opening"&&this.db.defer(()=>this._seek(t,e))},r.prototype._close=function(t){this[Bt]!==null?this[Bt].close(t):this.db.status==="opening"?this.db.defer(()=>this._close(t)):this.nextTick(t)};wi.DeferredIterator=hi;wi.DeferredKeyIterator=yi;wi.DeferredValueIterator=pi});var cs=Q(Ia=>{"use strict";var{fromCallback:Ua}=xn(),gi=Vt(),{getCallback:Sh,getOptions:kh}=si(),xi=Symbol("promise"),Ot=Symbol("status"),Dr=Symbol("operations"),Pn=Symbol("finishClose"),Mr=Symbol("closeCallbacks"),ss=class{constructor(t){if(typeof t!="object"||t===null){let e=t===null?"null":typeof t;throw new TypeError(`The first argument must be an abstract-level database, received ${e}`)}this[Dr]=[],this[Mr]=[],this[Ot]="open",this[Pn]=this[Pn].bind(this),this.db=t,this.db.attachResource(this),this.nextTick=t.nextTick}get length(){return this[Dr].length}put(t,e,n){if(this[Ot]!=="open")throw new gi("Batch is not open: cannot call put() after write() or close()",{code:"LEVEL_BATCH_NOT_OPEN"});let i=this.db._checkKey(t)||this.db._checkValue(e);if(i)throw i;let o=n&&n.sublevel!=null?n.sublevel:this.db,s=n,c=o.keyEncoding(n&&n.keyEncoding),a=o.valueEncoding(n&&n.valueEncoding),u=c.format;n={...n,keyEncoding:u,valueEncoding:a.format},o!==this.db&&(n.sublevel=null);let f=o.prefixKey(c.encode(t),u),l=a.encode(e);return this._put(f,l,n),this[Dr].push({...s,type:"put",key:t,value:e}),this}_put(t,e,n){}del(t,e){if(this[Ot]!=="open")throw new gi("Batch is not open: cannot call del() after write() or close()",{code:"LEVEL_BATCH_NOT_OPEN"});let n=this.db._checkKey(t);if(n)throw n;let i=e&&e.sublevel!=null?e.sublevel:this.db,o=e,s=i.keyEncoding(e&&e.keyEncoding),c=s.format;return e={...e,keyEncoding:c},i!==this.db&&(e.sublevel=null),this._del(i.prefixKey(s.encode(t),c),e),this[Dr].push({...o,type:"del",key:t}),this}_del(t,e){}clear(){if(this[Ot]!=="open")throw new gi("Batch is not open: cannot call clear() after write() or close()",{code:"LEVEL_BATCH_NOT_OPEN"});return this._clear(),this[Dr]=[],this}_clear(){}write(t,e){return e=Sh(t,e),e=Ua(e,xi),t=kh(t),this[Ot]!=="open"?this.nextTick(e,new gi("Batch is not open: cannot call write() after write() or close()",{code:"LEVEL_BATCH_NOT_OPEN"})):this.length===0?this.close(e):(this[Ot]="writing",this._write(t,n=>{this[Ot]="closing",this[Mr].push(()=>e(n)),n||this.db.emit("batch",this[Dr]),this._close(this[Pn])})),e[xi]}_write(t,e){}close(t){return t=Ua(t,xi),this[Ot]==="closing"?this[Mr].push(t):this[Ot]==="closed"?this.nextTick(t):(this[Mr].push(t),this[Ot]!=="writing"&&(this[Ot]="closing",this._close(this[Pn]))),t[xi]}_close(t){this.nextTick(t)}[Pn](){this[Ot]="closed",this.db.detachResource(this);let t=this[Mr];this[Mr]=[];for(let e of t)e()}};Ia.AbstractChainedBatch=ss});var _a=Q(Ca=>{"use strict";var{AbstractChainedBatch:Uh}=cs(),Ih=Vt(),jr=Symbol("encoded"),as=class extends Uh{constructor(t){super(t),this[jr]=[]}_put(t,e,n){this[jr].push({...n,type:"put",key:t,value:e})}_del(t,e){this[jr].push({...e,type:"del",key:t})}_clear(){this[jr]=[]}_write(t,e){this.db.status==="opening"?this.db.defer(()=>this._write(t,e)):this.db.status==="open"?this[jr].length===0?this.nextTick(e):this.db._batch(this[jr],t,e):this.nextTick(e,new Ih("Batch is not open: cannot call write() after write() or close()",{code:"LEVEL_BATCH_NOT_OPEN"}))}};Ca.DefaultChainedBatch=as});var Ra=Q((b0,Oa)=>{"use strict";var La=Vt(),Ch=Object.prototype.hasOwnProperty,_h=new Set(["lt","lte","gt","gte"]);Oa.exports=function(r,t){let e={};for(let n in r)if(Ch.call(r,n)&&!(n==="keyEncoding"||n==="valueEncoding")){if(n==="start"||n==="end")throw new La(`The legacy range option '${n}' has been removed`,{code:"LEVEL_LEGACY"});if(n==="encoding")throw new La("The levelup-style 'encoding' alias has been removed, use 'valueEncoding' instead",{code:"LEVEL_LEGACY"});_h.has(n)?e[n]=t.encode(r[n]):e[n]=r[n]}return e.reverse=!!e.reverse,e.limit=Number.isInteger(e.limit)&&e.limit>=0?e.limit:-1,e}});var us=Q((E0,Da)=>{var Na;Da.exports=typeof queueMicrotask=="function"?queueMicrotask.bind(typeof window<"u"?window:globalThis):r=>(Na||(Na=Promise.resolve())).then(r).catch(t=>setTimeout(()=>{throw t},0))});var Ha=Q((v0,ja)=>{"use strict";var Ma=us();ja.exports=function(r,...t){t.length===0?Ma(r):Ma(()=>r(...t))}});var Ja=Q(bi=>{"use strict";var{AbstractIterator:Lh,AbstractKeyIterator:Oh,AbstractValueIterator:Rh}=Re(),Hr=Symbol("unfix"),qt=Symbol("iterator"),yr=Symbol("handleOne"),Ne=Symbol("handleMany"),me=Symbol("callback"),Kn=class extends Lh{constructor(t,e,n,i){super(t,e),this[qt]=n,this[Hr]=i,this[yr]=this[yr].bind(this),this[Ne]=this[Ne].bind(this),this[me]=null}[yr](t,e,n){let i=this[me];if(t)return i(t);e!==void 0&&(e=this[Hr](e)),i(t,e,n)}[Ne](t,e){let n=this[me];if(t)return n(t);for(let i of e){let o=i[0];o!==void 0&&(i[0]=this[Hr](o))}n(t,e)}},Tn=class extends Oh{constructor(t,e,n,i){super(t,e),this[qt]=n,this[Hr]=i,this[yr]=this[yr].bind(this),this[Ne]=this[Ne].bind(this),this[me]=null}[yr](t,e){let n=this[me];if(t)return n(t);e!==void 0&&(e=this[Hr](e)),n(t,e)}[Ne](t,e){let n=this[me];if(t)return n(t);for(let i=0;i<e.length;i++){let o=e[i];o!==void 0&&(e[i]=this[Hr](o))}n(t,e)}},Sn=class extends Rh{constructor(t,e,n){super(t,e),this[qt]=n}};for(let r of[Kn,Tn])r.prototype._next=function(t){this[me]=t,this[qt].next(this[yr])},r.prototype._nextv=function(t,e,n){this[me]=n,this[qt].nextv(t,e,this[Ne])},r.prototype._all=function(t,e){this[me]=e,this[qt].all(t,this[Ne])};for(let r of[Sn])r.prototype._next=function(t){this[qt].next(t)},r.prototype._nextv=function(t,e,n){this[qt].nextv(t,e,n)},r.prototype._all=function(t,e){this[qt].all(t,e)};for(let r of[Kn,Tn,Sn])r.prototype._seek=function(t,e){this[qt].seek(t,e)},r.prototype._close=function(t){this[qt].close(t)};bi.AbstractSublevelIterator=Kn;bi.AbstractSublevelKeyIterator=Tn;bi.AbstractSublevelValueIterator=Sn});var Fa=Q((B0,qa)=>{"use strict";var fs=Vt(),{Buffer:ys}=ti()||{},{AbstractSublevelIterator:Nh,AbstractSublevelKeyIterator:Dh,AbstractSublevelValueIterator:Mh}=Ja(),we=Symbol("prefix"),Ga=Symbol("upperBound"),kn=Symbol("prefixRange"),Tt=Symbol("parent"),ls=Symbol("unfix"),Va=new TextEncoder,jh={separator:"!"};qa.exports=function({AbstractLevel:r}){class t extends r{static defaults(n){if(typeof n=="string")throw new fs("The subleveldown string shorthand for { separator } has been removed",{code:"LEVEL_LEGACY"});if(n&&n.open)throw new fs("The subleveldown open option has been removed",{code:"LEVEL_LEGACY"});return n==null?jh:n.separator?n:{...n,separator:"!"}}constructor(n,i,o){let{separator:s,manifest:c,...a}=t.defaults(o);i=Jh(i,s);let u=s.charCodeAt(0)+1,f=n[Tt]||n;if(!Va.encode(i).every(m=>m>u&&m<127))throw new fs(`Prefix must use bytes > ${u} < 127`,{code:"LEVEL_INVALID_PREFIX"});super(Hh(f,c),a);let l=(n.prefix||"")+s+i+s,y=l.slice(0,-1)+String.fromCharCode(u);this[Tt]=f,this[we]=new Ei(l),this[Ga]=new Ei(y),this[ls]=new ps,this.nextTick=f.nextTick}prefixKey(n,i){if(i==="utf8")return this[we].utf8+n;if(n.byteLength===0)return this[we][i];if(i==="view"){let o=this[we].view,s=new Uint8Array(o.byteLength+n.byteLength);return s.set(o,0),s.set(n,o.byteLength),s}else{let o=this[we].buffer;return ys.concat([o,n],o.byteLength+n.byteLength)}}[kn](n,i){n.gte!==void 0?n.gte=this.prefixKey(n.gte,i):n.gt!==void 0?n.gt=this.prefixKey(n.gt,i):n.gte=this[we][i],n.lte!==void 0?n.lte=this.prefixKey(n.lte,i):n.lt!==void 0?n.lt=this.prefixKey(n.lt,i):n.lte=this[Ga][i]}get prefix(){return this[we].utf8}get db(){return this[Tt]}_open(n,i){this[Tt].open({passive:!0},i)}_put(n,i,o,s){this[Tt].put(n,i,o,s)}_get(n,i,o){this[Tt].get(n,i,o)}_getMany(n,i,o){this[Tt].getMany(n,i,o)}_del(n,i,o){this[Tt].del(n,i,o)}_batch(n,i,o){this[Tt].batch(n,i,o)}_clear(n,i){this[kn](n,n.keyEncoding),this[Tt].clear(n,i)}_iterator(n){this[kn](n,n.keyEncoding);let i=this[Tt].iterator(n),o=this[ls].get(this[we].utf8.length,n.keyEncoding);return new Nh(this,n,i,o)}_keys(n){this[kn](n,n.keyEncoding);let i=this[Tt].keys(n),o=this[ls].get(this[we].utf8.length,n.keyEncoding);return new Dh(this,n,i,o)}_values(n){this[kn](n,n.keyEncoding);let i=this[Tt].values(n);return new Mh(this,n,i)}}return{AbstractSublevel:t}};var Hh=function(r,t){return{...r.supports,createIfMissing:!1,errorIfExists:!1,events:{},additionalMethods:{},...t,encodings:{utf8:hs(r,"utf8"),buffer:hs(r,"buffer"),view:hs(r,"view")}}},hs=function(r,t){return r.supports.encodings[t]?r.keyEncoding(t).name===t:!1},Ei=class{constructor(t){this.utf8=t,this.view=Va.encode(t),this.buffer=ys?ys.from(this.view.buffer,0,this.view.byteLength):{}}},ps=class{constructor(){this.cache=new Map}get(t,e){let n=this.cache.get(e);return n===void 0&&(e==="view"?n=(function(i,o){return o.subarray(i)}).bind(null,t):n=(function(i,o){return o.slice(i)}).bind(null,t),this.cache.set(e,n)),n}},Jh=function(r,t){let e=0,n=r.length;for(;e<n&&r[e]===t;)e++;for(;n>e&&r[n-1]===t;)n--;return r.slice(e,n)}});var xs=Q(gs=>{"use strict";var{supports:Gh}=Vc(),{Transcoder:Vh}=ba(),{EventEmitter:qh}=va(),{fromCallback:De}=xn(),Ft=Vt(),{AbstractIterator:pr}=Re(),{DefaultKeyIterator:Fh,DefaultValueIterator:$h}=Sa(),{DeferredIterator:Wh,DeferredKeyIterator:zh,DeferredValueIterator:Zh}=ka(),{DefaultChainedBatch:$a}=_a(),{getCallback:dr,getOptions:Me}=si(),vi=Ra(),W=Symbol("promise"),ge=Symbol("landed"),mr=Symbol("resources"),ds=Symbol("closeResources"),Un=Symbol("operations"),In=Symbol("undefer"),Ai=Symbol("deferOpen"),Wa=Symbol("options"),X=Symbol("status"),wr=Symbol("defaultOptions"),Jr=Symbol("transcoder"),Bi=Symbol("keyEncoding"),ms=Symbol("valueEncoding"),Yh=()=>{},Cn=class extends qh{constructor(t,e){if(super(),typeof t!="object"||t===null)throw new TypeError("The first argument 'manifest' must be an object");e=Me(e);let{keyEncoding:n,valueEncoding:i,passive:o,...s}=e;this[mr]=new Set,this[Un]=[],this[Ai]=!0,this[Wa]=s,this[X]="opening",this.supports=Gh(t,{status:!0,promises:!0,clear:!0,getMany:!0,deferredOpen:!0,snapshots:t.snapshots!==!1,permanence:t.permanence!==!1,keyIterator:!0,valueIterator:!0,iteratorNextv:!0,iteratorAll:!0,encodings:t.encodings||{},events:Object.assign({},t.events,{opening:!0,open:!0,closing:!0,closed:!0,put:!0,del:!0,batch:!0,clear:!0})}),this[Jr]=new Vh(Xh(this)),this[Bi]=this[Jr].encoding(n||"utf8"),this[ms]=this[Jr].encoding(i||"utf8");for(let c of this[Jr].encodings())this.supports.encodings[c.commonName]||(this.supports.encodings[c.commonName]=!0);this[wr]={empty:Object.freeze({}),entry:Object.freeze({keyEncoding:this[Bi].commonName,valueEncoding:this[ms].commonName}),key:Object.freeze({keyEncoding:this[Bi].commonName})},this.nextTick(()=>{this[Ai]&&this.open({passive:!1},Yh)})}get status(){return this[X]}keyEncoding(t){return this[Jr].encoding(t??this[Bi])}valueEncoding(t){return this[Jr].encoding(t??this[ms])}open(t,e){e=dr(t,e),e=De(e,W),t={...this[Wa],...Me(t)},t.createIfMissing=t.createIfMissing!==!1,t.errorIfExists=!!t.errorIfExists;let n=i=>{this[X]==="closing"||this[X]==="opening"?this.once(ge,i?()=>n(i):n):this[X]!=="open"?e(new Ft("Database is not open",{code:"LEVEL_DATABASE_NOT_OPEN",cause:i})):e()};return t.passive?this[X]==="opening"?this.once(ge,n):this.nextTick(n):this[X]==="closed"||this[Ai]?(this[Ai]=!1,this[X]="opening",this.emit("opening"),this._open(t,i=>{if(i){this[X]="closed",this[ds](()=>{this.emit(ge),n(i)}),this[In]();return}this[X]="open",this[In](),this.emit(ge),this[X]==="open"&&this.emit("open"),this[X]==="open"&&this.emit("ready"),n()})):this[X]==="open"?this.nextTick(n):this.once(ge,()=>this.open(t,e)),e[W]}_open(t,e){this.nextTick(e)}close(t){t=De(t,W);let e=n=>{this[X]==="opening"||this[X]==="closing"?this.once(ge,n?e(n):e):this[X]!=="closed"?t(new Ft("Database is not closed",{code:"LEVEL_DATABASE_NOT_CLOSED",cause:n})):t()};if(this[X]==="open"){this[X]="closing",this.emit("closing");let n=i=>{this[X]="open",this[In](),this.emit(ge),e(i)};this[ds](()=>{this._close(i=>{if(i)return n(i);this[X]="closed",this[In](),this.emit(ge),this[X]==="closed"&&this.emit("closed"),e()})})}else this[X]==="closed"?this.nextTick(e):this.once(ge,()=>this.close(t));return t[W]}[ds](t){if(this[mr].size===0)return this.nextTick(t);let e=this[mr].size,n=!0,i=()=>{--e===0&&(n?this.nextTick(t):t())};for(let o of this[mr])o.close(i);n=!1,this[mr].clear()}_close(t){this.nextTick(t)}get(t,e,n){if(n=dr(e,n),n=De(n,W),e=Me(e,this[wr].entry),this[X]==="opening")return this.defer(()=>this.get(t,e,n)),n[W];if(Gr(this,n))return n[W];let i=this._checkKey(t);if(i)return this.nextTick(n,i),n[W];let o=this.keyEncoding(e.keyEncoding),s=this.valueEncoding(e.valueEncoding),c=o.format,a=s.format;return(e.keyEncoding!==c||e.valueEncoding!==a)&&(e=Object.assign({},e,{keyEncoding:c,valueEncoding:a})),this._get(this.prefixKey(o.encode(t),c),e,(u,f)=>{if(u)return(u.code==="LEVEL_NOT_FOUND"||u.notFound||/NotFound/i.test(u))&&(u.code||(u.code="LEVEL_NOT_FOUND"),u.notFound||(u.notFound=!0),u.status||(u.status=404)),n(u);try{f=s.decode(f)}catch(l){return n(new Ft("Could not decode value",{code:"LEVEL_DECODE_ERROR",cause:l}))}n(null,f)}),n[W]}_get(t,e,n){this.nextTick(n,new Error("NotFound"))}getMany(t,e,n){if(n=dr(e,n),n=De(n,W),e=Me(e,this[wr].entry),this[X]==="opening")return this.defer(()=>this.getMany(t,e,n)),n[W];if(Gr(this,n))return n[W];if(!Array.isArray(t))return this.nextTick(n,new TypeError("The first argument 'keys' must be an array")),n[W];if(t.length===0)return this.nextTick(n,null,[]),n[W];let i=this.keyEncoding(e.keyEncoding),o=this.valueEncoding(e.valueEncoding),s=i.format,c=o.format;(e.keyEncoding!==s||e.valueEncoding!==c)&&(e=Object.assign({},e,{keyEncoding:s,valueEncoding:c}));let a=new Array(t.length);for(let u=0;u<t.length;u++){let f=t[u],l=this._checkKey(f);if(l)return this.nextTick(n,l),n[W];a[u]=this.prefixKey(i.encode(f),s)}return this._getMany(a,e,(u,f)=>{if(u)return n(u);try{for(let l=0;l<f.length;l++)f[l]!==void 0&&(f[l]=o.decode(f[l]))}catch(l){return n(new Ft(`Could not decode one or more of ${f.length} value(s)`,{code:"LEVEL_DECODE_ERROR",cause:l}))}n(null,f)}),n[W]}_getMany(t,e,n){this.nextTick(n,null,new Array(t.length).fill(void 0))}put(t,e,n,i){if(i=dr(n,i),i=De(i,W),n=Me(n,this[wr].entry),this[X]==="opening")return this.defer(()=>this.put(t,e,n,i)),i[W];if(Gr(this,i))return i[W];let o=this._checkKey(t)||this._checkValue(e);if(o)return this.nextTick(i,o),i[W];let s=this.keyEncoding(n.keyEncoding),c=this.valueEncoding(n.valueEncoding),a=s.format,u=c.format;(n.keyEncoding!==a||n.valueEncoding!==u)&&(n=Object.assign({},n,{keyEncoding:a,valueEncoding:u}));let f=this.prefixKey(s.encode(t),a),l=c.encode(e);return this._put(f,l,n,y=>{if(y)return i(y);this.emit("put",t,e),i()}),i[W]}_put(t,e,n,i){this.nextTick(i)}del(t,e,n){if(n=dr(e,n),n=De(n,W),e=Me(e,this[wr].key),this[X]==="opening")return this.defer(()=>this.del(t,e,n)),n[W];if(Gr(this,n))return n[W];let i=this._checkKey(t);if(i)return this.nextTick(n,i),n[W];let o=this.keyEncoding(e.keyEncoding),s=o.format;return e.keyEncoding!==s&&(e=Object.assign({},e,{keyEncoding:s})),this._del(this.prefixKey(o.encode(t),s),e,c=>{if(c)return n(c);this.emit("del",t),n()}),n[W]}_del(t,e,n){this.nextTick(n)}batch(t,e,n){if(!arguments.length){if(this[X]==="opening")return new $a(this);if(this[X]!=="open")throw new Ft("Database is not open",{code:"LEVEL_DATABASE_NOT_OPEN"});return this._chainedBatch()}if(typeof t=="function"?n=t:n=dr(e,n),n=De(n,W),e=Me(e,this[wr].empty),this[X]==="opening")return this.defer(()=>this.batch(t,e,n)),n[W];if(Gr(this,n))return n[W];if(!Array.isArray(t))return this.nextTick(n,new TypeError("The first argument 'operations' must be an array")),n[W];if(t.length===0)return this.nextTick(n),n[W];let i=new Array(t.length),{keyEncoding:o,valueEncoding:s,...c}=e;for(let a=0;a<t.length;a++){if(typeof t[a]!="object"||t[a]===null)return this.nextTick(n,new TypeError("A batch operation must be an object")),n[W];let u=Object.assign({},t[a]);if(u.type!=="put"&&u.type!=="del")return this.nextTick(n,new TypeError("A batch operation must have a type property that is 'put' or 'del'")),n[W];let f=this._checkKey(u.key);if(f)return this.nextTick(n,f),n[W];let l=u.sublevel!=null?u.sublevel:this,y=l.keyEncoding(u.keyEncoding||o),m=y.format;if(u.key=l.prefixKey(y.encode(u.key),m),u.keyEncoding=m,u.type==="put"){let p=this._checkValue(u.value);if(p)return this.nextTick(n,p),n[W];let h=l.valueEncoding(u.valueEncoding||s);u.value=h.encode(u.value),u.valueEncoding=h.format}l!==this&&(u.sublevel=null),i[a]=u}return this._batch(i,c,a=>{if(a)return n(a);this.emit("batch",t),n()}),n[W]}_batch(t,e,n){this.nextTick(n)}sublevel(t,e){return this._sublevel(t,ws.defaults(e))}_sublevel(t,e){return new ws(this,t,e)}prefixKey(t,e){return t}clear(t,e){if(e=dr(t,e),e=De(e,W),t=Me(t,this[wr].empty),this[X]==="opening")return this.defer(()=>this.clear(t,e)),e[W];if(Gr(this,e))return e[W];let n=t,i=this.keyEncoding(t.keyEncoding);return t=vi(t,i),t.keyEncoding=i.format,t.limit===0?this.nextTick(e):this._clear(t,o=>{if(o)return e(o);this.emit("clear",n),e()}),e[W]}_clear(t,e){this.nextTick(e)}iterator(t){let e=this.keyEncoding(t&&t.keyEncoding),n=this.valueEncoding(t&&t.valueEncoding);if(t=vi(t,e),t.keys=t.keys!==!1,t.values=t.values!==!1,t[pr.keyEncoding]=e,t[pr.valueEncoding]=n,t.keyEncoding=e.format,t.valueEncoding=n.format,this[X]==="opening")return new Wh(this,t);if(this[X]!=="open")throw new Ft("Database is not open",{code:"LEVEL_DATABASE_NOT_OPEN"});return this._iterator(t)}_iterator(t){return new pr(this,t)}keys(t){let e=this.keyEncoding(t&&t.keyEncoding),n=this.valueEncoding(t&&t.valueEncoding);if(t=vi(t,e),t[pr.keyEncoding]=e,t[pr.valueEncoding]=n,t.keyEncoding=e.format,t.valueEncoding=n.format,this[X]==="opening")return new zh(this,t);if(this[X]!=="open")throw new Ft("Database is not open",{code:"LEVEL_DATABASE_NOT_OPEN"});return this._keys(t)}_keys(t){return new Fh(this,t)}values(t){let e=this.keyEncoding(t&&t.keyEncoding),n=this.valueEncoding(t&&t.valueEncoding);if(t=vi(t,e),t[pr.keyEncoding]=e,t[pr.valueEncoding]=n,t.keyEncoding=e.format,t.valueEncoding=n.format,this[X]==="opening")return new Zh(this,t);if(this[X]!=="open")throw new Ft("Database is not open",{code:"LEVEL_DATABASE_NOT_OPEN"});return this._values(t)}_values(t){return new $h(this,t)}defer(t){if(typeof t!="function")throw new TypeError("The first argument must be a function");this[Un].push(t)}[In](){if(this[Un].length===0)return;let t=this[Un];this[Un]=[];for(let e of t)e()}attachResource(t){if(typeof t!="object"||t===null||typeof t.close!="function")throw new TypeError("The first argument must be a resource object");this[mr].add(t)}detachResource(t){this[mr].delete(t)}_chainedBatch(){return new $a(this)}_checkKey(t){if(t==null)return new Ft("Key cannot be null or undefined",{code:"LEVEL_INVALID_KEY"})}_checkValue(t){if(t==null)return new Ft("Value cannot be null or undefined",{code:"LEVEL_INVALID_VALUE"})}};Cn.prototype.nextTick=Ha();var{AbstractSublevel:ws}=Fa()({AbstractLevel:Cn});gs.AbstractLevel=Cn;gs.AbstractSublevel=ws;var Gr=function(r,t){return r[X]!=="open"?(r.nextTick(t,new Ft("Database is not open",{code:"LEVEL_DATABASE_NOT_OPEN"})),!0):!1},Xh=function(r){return Object.keys(r.supports.encodings).filter(t=>!!r.supports.encodings[t])}});var bs=Q(gr=>{"use strict";gr.AbstractLevel=xs().AbstractLevel;gr.AbstractSublevel=xs().AbstractSublevel;gr.AbstractIterator=Re().AbstractIterator;gr.AbstractKeyIterator=Re().AbstractKeyIterator;gr.AbstractValueIterator=Re().AbstractValueIterator;gr.AbstractChainedBatch=cs().AbstractChainedBatch});var Za=Q((T0,za)=>{za.exports=ty;var Qh=us();function ty(r,t,e){if(typeof t!="number")throw new Error("second argument must be a Number");let n,i,o,s,c,a=!0,u;Array.isArray(r)?(n=[],o=i=r.length):(s=Object.keys(r),n={},o=i=s.length);function f(y){function m(){e&&e(y,n),e=null}a?Qh(m):m()}function l(y,m,p){if(n[y]=p,m&&(c=!0),--o===0||m)f(m);else if(!c&&u<i){let h;s?(h=s[u],u+=1,r[h](function(d,g){l(h,d,g)})):(h=u,u+=1,r[h](function(d,g){l(h,d,g)}))}}u=t,o?s?s.some(function(y,m){return r[y](function(p,h){l(y,p,h)}),m===t-1}):r.some(function(y,m){return y(function(p,h){l(m,p,h)}),m===t-1}):f(null),a=!1}});var Es=Q((S0,Ya)=>{"use strict";Ya.exports=function(t){let e=t.gte!==void 0?t.gte:t.gt!==void 0?t.gt:void 0,n=t.lte!==void 0?t.lte:t.lt!==void 0?t.lt:void 0,i=t.gte===void 0,o=t.lte===void 0;return e!==void 0&&n!==void 0?IDBKeyRange.bound(e,n,i,o):e!==void 0?IDBKeyRange.lowerBound(e,i):n!==void 0?IDBKeyRange.upperBound(n,o):null}});var vs=Q((k0,Xa)=>{"use strict";var ey=new TextEncoder;Xa.exports=function(r){return r instanceof Uint8Array?r:r instanceof ArrayBuffer?new Uint8Array(r):ey.encode(r)}});var nu=Q(ru=>{"use strict";var{AbstractIterator:ry}=bs(),Qa=Es(),Pi=vs(),ie=Symbol("cache"),xe=Symbol("finished"),St=Symbol("options"),be=Symbol("currentOptions"),xr=Symbol("position"),As=Symbol("location"),Vr=Symbol("first"),tu={},Bs=class extends ry{constructor(t,e,n){super(t,n),this[ie]=[],this[xe]=this.limit===0,this[St]=n,this[be]={...n},this[xr]=void 0,this[As]=e,this[Vr]=!0}_nextv(t,e,n){if(this[Vr]=!1,this[xe])return this.nextTick(n,null,[]);if(this[ie].length>0)return t=Math.min(t,this[ie].length),this.nextTick(n,null,this[ie].splice(0,t));this[xr]!==void 0&&(this[St].reverse?(this[be].lt=this[xr],this[be].lte=void 0):(this[be].gt=this[xr],this[be].gte=void 0));let i;try{i=Qa(this[be])}catch{return this[xe]=!0,this.nextTick(n,null,[])}let o=this.db.db.transaction([this[As]],"readonly"),s=o.objectStore(this[As]),c=[];if(this[St].reverse){let a=!this[St].values&&s.openKeyCursor?"openKeyCursor":"openCursor";s[a](i,"prev").onsuccess=u=>{let f=u.target.result;if(f){let{key:l,value:y}=f;this[xr]=l,c.push([this[St].keys&&l!==void 0?Pi(l):void 0,this[St].values&&y!==void 0?Pi(y):void 0]),c.length<t?f.continue():eu(o)}else this[xe]=!0}}else{let a,u,f=()=>{if(a===void 0||u===void 0)return;let l=Math.max(a.length,u.length);l===0||t===1/0?this[xe]=!0:this[xr]=a[l-1],c.length=l;for(let y=0;y<l;y++){let m=a[y],p=u[y];c[y]=[this[St].keys&&m!==void 0?Pi(m):void 0,this[St].values&&p!==void 0?Pi(p):void 0]}eu(o)};this[St].keys||t<1/0?s.getAllKeys(i,t<1/0?t:void 0).onsuccess=l=>{a=l.target.result,f()}:(a=[],this.nextTick(f)),this[St].values?s.getAll(i,t<1/0?t:void 0).onsuccess=l=>{u=l.target.result,f()}:(u=[],this.nextTick(f))}o.onabort=()=>{n(o.error||new Error("aborted by user")),n=null},o.oncomplete=()=>{n(null,c),n=null}}_next(t){if(this[ie].length>0){let[e,n]=this[ie].shift();this.nextTick(t,null,e,n)}else if(this[xe])this.nextTick(t);else{let e=Math.min(100,this.limit-this.count);this[Vr]&&(this[Vr]=!1,e=1),this._nextv(e,tu,(n,i)=>{if(n)return t(n);this[ie]=i,this._next(t)})}}_all(t,e){this[Vr]=!1;let n=this[ie].splice(0,this[ie].length),i=this.limit-this.count-n.length;if(i<=0)return this.nextTick(e,null,n);this._nextv(i,tu,(o,s)=>{if(o)return e(o);n.length>0&&(s=n.concat(s)),e(null,s)})}_seek(t,e){this[Vr]=!0,this[ie]=[],this[xe]=!1,this[xr]=void 0,this[be]={...this[St]};let n;try{n=Qa(this[St])}catch{this[xe]=!0;return}n!==null&&!n.includes(t)?this[xe]=!0:this[St].reverse?this[be].lte=t:this[be].gte=t}};ru.Iterator=Bs;function eu(r){typeof r.commit=="function"&&r.commit()}});var ou=Q((I0,iu)=>{"use strict";iu.exports=function(t,e,n,i,o){if(i.limit===0)return t.nextTick(o);let s=t.db.transaction([e],"readwrite"),c=s.objectStore(e),a=0;s.oncomplete=function(){o()},s.onabort=function(){o(s.error||new Error("aborted by user"))};let u=c.openKeyCursor?"openKeyCursor":"openCursor",f=i.reverse?"prev":"next";c[u](n,f).onsuccess=function(l){let y=l.target.result;y&&(c.delete(y.key).onsuccess=function(){(i.limit<=0||++a<i.limit)&&y.continue()})}}});var lu=Q(fu=>{"use strict";var{AbstractLevel:ny}=bs(),su=Vt(),iy=Za(),{fromCallback:oy}=xn(),{Iterator:sy}=nu(),cu=vs(),cy=ou(),ay=Es(),uu="level-js-",_n=Symbol("idb"),Ps=Symbol("namePrefix"),Ee=Symbol("location"),Ks=Symbol("version"),br=Symbol("store"),Ln=Symbol("onComplete"),au=Symbol("promise"),Ki=class extends ny{constructor(t,e,n){if(typeof e=="function"||typeof n=="function")throw new su("The levelup-style callback argument has been removed",{code:"LEVEL_LEGACY"});let{prefix:i,version:o,...s}=e||{};if(super({encodings:{view:!0},snapshots:!1,createIfMissing:!1,errorIfExists:!1,seek:!0},s),typeof t!="string")throw new Error("constructor requires a location string argument");this[Ee]=t,this[Ps]=i??uu,this[Ks]=parseInt(o||1,10),this[_n]=null}get location(){return this[Ee]}get namePrefix(){return this[Ps]}get version(){return this[Ks]}get db(){return this[_n]}get type(){return"browser-level"}_open(t,e){let n=indexedDB.open(this[Ps]+this[Ee],this[Ks]);n.onerror=function(){e(n.error||new Error("unknown error"))},n.onsuccess=()=>{this[_n]=n.result,e()},n.onupgradeneeded=i=>{let o=i.target.result;o.objectStoreNames.contains(this[Ee])||o.createObjectStore(this[Ee])}}[br](t){return this[_n].transaction([this[Ee]],t).objectStore(this[Ee])}[Ln](t,e){let n=t.transaction;n.onabort=function(){e(n.error||new Error("aborted by user"))},n.oncomplete=function(){e(null,t.result)}}_get(t,e,n){let i=this[br]("readonly"),o;try{o=i.get(t)}catch(s){return this.nextTick(n,s)}this[Ln](o,function(s,c){if(s)return n(s);if(c===void 0)return n(new su("Entry not found",{code:"LEVEL_NOT_FOUND"}));n(null,cu(c))})}_getMany(t,e,n){let i=this[br]("readonly"),o=t.map(s=>c=>{let a;try{a=i.get(s)}catch(u){return c(u)}a.onsuccess=()=>{let u=a.result;c(null,u===void 0?u:cu(u))},a.onerror=u=>{u.stopPropagation(),c(a.error)}});iy(o,16,n)}_del(t,e,n){let i=this[br]("readwrite"),o;try{o=i.delete(t)}catch(s){return this.nextTick(n,s)}this[Ln](o,n)}_put(t,e,n,i){let o=this[br]("readwrite"),s;try{s=o.put(e,t)}catch(c){return this.nextTick(i,c)}this[Ln](s,i)}_iterator(t){return new sy(this,this[Ee],t)}_batch(t,e,n){let i=this[br]("readwrite"),o=i.transaction,s=0,c;o.onabort=function(){n(c||o.error||new Error("aborted by user"))},o.oncomplete=function(){n()};function a(){let u=t[s++],f=u.key,l;try{l=u.type==="del"?i.delete(f):i.put(u.value,f)}catch(y){c=y,o.abort();return}s<t.length?l.onsuccess=a:typeof o.commit=="function"&&o.commit()}a()}_clear(t,e){let n,i;try{n=ay(t)}catch{return this.nextTick(e)}if(t.limit>=0)return cy(this,this[Ee],n,t,e);try{let o=this[br]("readwrite");i=n?o.delete(n):o.clear()}catch(o){return this.nextTick(e,o)}this[Ln](i,e)}_close(t){this[_n].close(),this.nextTick(t)}};Ki.destroy=function(r,t,e){typeof t=="function"&&(e=t,t=uu),e=oy(e,au);let n=indexedDB.deleteDatabase(t+r);return n.onsuccess=function(){e()},n.onerror=function(i){e(i)},e[au]};fu.BrowserLevel=Ki});var yu=Q(hu=>{hu.Level=lu().BrowserLevel});var nt=class r extends Error{constructor(e,n){super(n);this.code=e;this.name="CryptoError",Object.setPrototypeOf(this,new.target.prototype),Error.captureStackTrace&&Error.captureStackTrace(this,r)}},sn=(o=>(o.AlgorithmNotSupported="algorithmNotSupported",o.EncodingError="encodingError",o.InvalidJwe="invalidJwe",o.InvalidJwk="invalidJwk",o.OperationNotSupported="operationNotSupported",o))(sn||{});var Xf=Pc(Tc(),1);var od=new Uint8Array(0);function Sc(r,t){if(r===t)return!0;if(r.byteLength!==t.byteLength)return!1;for(let e=0;e<r.byteLength;e++)if(r[e]!==t[e])return!1;return!0}function Sr(r){if(r instanceof Uint8Array&&r.constructor.name==="Uint8Array")return r;if(r instanceof ArrayBuffer)return new Uint8Array(r);if(ArrayBuffer.isView(r))return new Uint8Array(r.buffer,r.byteOffset,r.byteLength);throw new Error("Unknown type, must be binary type")}function tl(r,t){if(r.length>=255)throw new TypeError("Alphabet too long");for(var e=new Uint8Array(256),n=0;n<e.length;n++)e[n]=255;for(var i=0;i<r.length;i++){var o=r.charAt(i),s=o.charCodeAt(0);if(e[s]!==255)throw new TypeError(o+" is ambiguous");e[s]=i}var c=r.length,a=r.charAt(0),u=Math.log(c)/Math.log(256),f=Math.log(256)/Math.log(c);function l(p){if(p instanceof Uint8Array||(ArrayBuffer.isView(p)?p=new Uint8Array(p.buffer,p.byteOffset,p.byteLength):Array.isArray(p)&&(p=Uint8Array.from(p))),!(p instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(p.length===0)return"";for(var h=0,d=0,g=0,b=p.length;g!==b&&p[g]===0;)g++,h++;for(var x=(b-g)*f+1>>>0,A=new Uint8Array(x);g!==b;){for(var v=p[g],K=0,k=x-1;(v!==0||K<d)&&k!==-1;k--,K++)v+=256*A[k]>>>0,A[k]=v%c>>>0,v=v/c>>>0;if(v!==0)throw new Error("Non-zero carry");d=K,g++}for(var T=x-d;T!==x&&A[T]===0;)T++;for(var L=a.repeat(h);T<x;++T)L+=r.charAt(A[T]);return L}function y(p){if(typeof p!="string")throw new TypeError("Expected String");if(p.length===0)return new Uint8Array;var h=0;if(p[h]!==" "){for(var d=0,g=0;p[h]===a;)d++,h++;for(var b=(p.length-h)*u+1>>>0,x=new Uint8Array(b);p[h];){var A=e[p.charCodeAt(h)];if(A===255)return;for(var v=0,K=b-1;(A!==0||v<g)&&K!==-1;K--,v++)A+=c*x[K]>>>0,x[K]=A%256>>>0,A=A/256>>>0;if(A!==0)throw new Error("Non-zero carry");g=v,h++}if(p[h]!==" "){for(var k=b-g;k!==b&&x[k]===0;)k++;for(var T=new Uint8Array(d+(b-k)),L=d;k!==b;)T[L++]=x[k++];return T}}}function m(p){var h=y(p);if(h)return h;throw new Error(`Non-${t} character`)}return{encode:l,decodeUnsafe:y,decode:m}}var el=tl,rl=el,kc=rl;var ho=class{name;prefix;baseEncode;constructor(t,e,n){this.name=t,this.prefix=e,this.baseEncode=n}encode(t){if(t instanceof Uint8Array)return`${this.prefix}${this.baseEncode(t)}`;throw Error("Unknown type, must be binary type")}},yo=class{name;prefix;baseDecode;prefixCodePoint;constructor(t,e,n){if(this.name=t,this.prefix=e,e.codePointAt(0)===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=e.codePointAt(0),this.baseDecode=n}decode(t){if(typeof t=="string"){if(t.codePointAt(0)!==this.prefixCodePoint)throw Error(`Unable to decode multibase string ${JSON.stringify(t)}, ${this.name} decoder only supports inputs prefixed with ${this.prefix}`);return this.baseDecode(t.slice(this.prefix.length))}else throw Error("Can only multibase decode strings")}or(t){return Uc(this,t)}},po=class{decoders;constructor(t){this.decoders=t}or(t){return Uc(this,t)}decode(t){let e=t[0],n=this.decoders[e];if(n!=null)return n.decode(t);throw RangeError(`Unable to decode multibase string ${JSON.stringify(t)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}};function Uc(r,t){return new po({...r.decoders??{[r.prefix]:r},...t.decoders??{[t.prefix]:t}})}var mo=class{name;prefix;baseEncode;baseDecode;encoder;decoder;constructor(t,e,n,i){this.name=t,this.prefix=e,this.baseEncode=n,this.baseDecode=i,this.encoder=new ho(t,e,n),this.decoder=new yo(t,e,i)}encode(t){return this.encoder.encode(t)}decode(t){return this.decoder.decode(t)}};function Ic({name:r,prefix:t,encode:e,decode:n}){return new mo(r,t,e,n)}function wo({name:r,prefix:t,alphabet:e}){let{encode:n,decode:i}=kc(e,r);return Ic({prefix:t,name:r,encode:n,decode:o=>Sr(i(o))})}function nl(r,t,e,n){let i={};for(let f=0;f<t.length;++f)i[t[f]]=f;let o=r.length;for(;r[o-1]==="=";)--o;let s=new Uint8Array(o*e/8|0),c=0,a=0,u=0;for(let f=0;f<o;++f){let l=i[r[f]];if(l===void 0)throw new SyntaxError(`Non-${n} character`);a=a<<e|l,c+=e,c>=8&&(c-=8,s[u++]=255&a>>c)}if(c>=e||255&a<<8-c)throw new SyntaxError("Unexpected end of data");return s}function il(r,t,e){let n=t[t.length-1]==="=",i=(1<<e)-1,o="",s=0,c=0;for(let a=0;a<r.length;++a)for(c=c<<8|r[a],s+=8;s>e;)s-=e,o+=t[i&c>>s];if(s!==0&&(o+=t[i&c<<e-s]),n)for(;o.length*e&7;)o+="=";return o}function xt({name:r,prefix:t,bitsPerChar:e,alphabet:n}){return Ic({prefix:t,name:r,encode(i){return il(i,n,e)},decode(i){return nl(i,n,e,r)}})}var cn=xt({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),ld=xt({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),hd=xt({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),yd=xt({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),pd=xt({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),dd=xt({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),md=xt({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),wd=xt({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),go=xt({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var vt=wo({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),bd=wo({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var Ad=xt({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),Bd=xt({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),Xt=xt({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),Pd=xt({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});function Cc(r){return r.byteOffset!==0||r.byteLength!==r.buffer.byteLength}function _c(r){return typeof r!="object"||r===null?!1:typeof r[Symbol.asyncIterator]=="function"}function an(r){let e=Object.prototype.toString.call(r).match(/\s([a-zA-Z0-9]+)/),[n,i]=e;return i}var un=function(r,t,e,n){function i(o){return o instanceof e?o:new e(function(s){s(o)})}return new(e||(e=Promise))(function(o,s){function c(f){try{u(n.next(f))}catch(l){s(l)}}function a(f){try{u(n.throw(f))}catch(l){s(l)}}function u(f){f.done?o(f.value):i(f.value).then(c,a)}u((n=n.apply(r,t||[])).next())})},Lc=function(r){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var t=r[Symbol.asyncIterator],e;return t?t.call(r):(r=typeof __values=="function"?__values(r):r[Symbol.iterator](),e={},n("next"),n("throw"),n("return"),e[Symbol.asyncIterator]=function(){return this},e);function n(o){e[o]=r[o]&&function(s){return new Promise(function(c,a){s=r[o](s),i(c,a,s.done,s.value)})}}function i(o,s,c,a){Promise.resolve(a).then(function(u){o({value:u,done:c})},s)}},Zn=new TextEncoder,rr=new TextDecoder,N=class r{constructor(t,e){this.data=t,this.format=e}static arrayBuffer(t){return new r(t,"ArrayBuffer")}static asyncIterable(t){if(!_c(t))throw new TypeError("Input must be of type AsyncIterable.");return new r(t,"AsyncIterable")}static base32Z(t){return new r(t,"Base32Z")}static base58Btc(t){return new r(t,"Base58Btc")}static base64Url(t){return new r(t,"Base64Url")}static bufferSource(t){return new r(t,"BufferSource")}static hex(t){if(typeof t!="string")throw new TypeError("Hex input must be a string.");if(t.length%2!==0)throw new TypeError("Hex input must have an even number of characters.");return new r(t,"Hex")}static multibase(t){return new r(t,"Multibase")}static object(t){return new r(t,"Object")}static string(t){return new r(t,"String")}static uint8Array(t){return new r(t,"Uint8Array")}toArrayBuffer(){switch(this.format){case"Base58Btc":return vt.baseDecode(this.data).buffer;case"Base64Url":return Xt.baseDecode(this.data).buffer;case"BufferSource":{if(an(this.data)==="ArrayBuffer")return this.data;if(ArrayBuffer.isView(this.data))return Cc(this.data)?this.data.buffer.slice(this.data.byteOffset,this.data.byteOffset+this.data.byteLength):this.data.buffer;throw new TypeError(`${this.format} value is not of type: ArrayBuffer, DataView, or TypedArray.`)}case"Hex":return this.toUint8Array().buffer;case"String":return this.toUint8Array().buffer;case"Uint8Array":return this.data.buffer;default:throw new TypeError(`Conversion from ${this.format} to ArrayBuffer is not supported.`)}}toArrayBufferAsync(){return un(this,void 0,void 0,function*(){switch(this.format){case"AsyncIterable":return yield(yield this.toBlobAsync()).arrayBuffer();default:throw new TypeError(`Asynchronous conversion from ${this.format} to ArrayBuffer is not supported.`)}})}toBase32Z(){switch(this.format){case"Uint8Array":return go.baseEncode(this.data);default:throw new TypeError(`Conversion from ${this.format} to Base64Z is not supported.`)}}toBase58Btc(){switch(this.format){case"ArrayBuffer":{let t=new Uint8Array(this.data);return vt.baseEncode(t)}case"Multibase":return this.data.substring(1);case"Uint8Array":return vt.baseEncode(this.data);default:throw new TypeError(`Conversion from ${this.format} to Base58Btc is not supported.`)}}toBase64Url(){switch(this.format){case"ArrayBuffer":{let t=new Uint8Array(this.data);return Xt.baseEncode(t)}case"BufferSource":{let t=this.toUint8Array();return Xt.baseEncode(t)}case"Object":{let t=JSON.stringify(this.data),e=Zn.encode(t);return Xt.baseEncode(e)}case"String":{let t=Zn.encode(this.data);return Xt.baseEncode(t)}case"Uint8Array":return Xt.baseEncode(this.data);default:throw new TypeError(`Conversion from ${this.format} to Base64Url is not supported.`)}}toBlobAsync(){return un(this,void 0,void 0,function*(){var t,e,n,i;switch(this.format){case"AsyncIterable":{let a=[];try{for(var o=!0,s=Lc(this.data),c;c=yield s.next(),t=c.done,!t;o=!0){i=c.value,o=!1;let f=i;a.push(f)}}catch(f){e={error:f}}finally{try{!o&&!t&&(n=s.return)&&(yield n.call(s))}finally{if(e)throw e.error}}return new Blob(a)}default:throw new TypeError(`Asynchronous conversion from ${this.format} to Blob is not supported.`)}})}toHex(){let t=Array.from({length:256},(e,n)=>n.toString(16).padStart(2,"0"));switch(this.format){case"ArrayBuffer":{let e=this.toUint8Array();return r.uint8Array(e).toHex()}case"Base64Url":{let e=this.toUint8Array();return r.uint8Array(e).toHex()}case"Uint8Array":{let e="";for(let n=0;n<this.data.length;n++)e+=t[this.data[n]];return e}default:throw new TypeError(`Conversion from ${this.format} to Hex is not supported.`)}}toMultibase(){switch(this.format){case"Base58Btc":return`z${this.data}`;default:throw new TypeError(`Conversion from ${this.format} to Multibase is not supported.`)}}toObject(){switch(this.format){case"Base64Url":{let t=Xt.baseDecode(this.data),e=rr.decode(t);return JSON.parse(e)}case"String":return JSON.parse(this.data);case"Uint8Array":{let t=rr.decode(this.data);return JSON.parse(t)}default:throw new TypeError(`Conversion from ${this.format} to Object is not supported.`)}}toObjectAsync(){return un(this,void 0,void 0,function*(){switch(this.format){case"AsyncIterable":{let t=yield this.toStringAsync();return JSON.parse(t)}default:throw new TypeError(`Asynchronous conversion from ${this.format} to Object is not supported.`)}})}toString(){switch(this.format){case"ArrayBuffer":return rr.decode(this.data);case"Base64Url":{let t=Xt.baseDecode(this.data);return rr.decode(t)}case"Object":return JSON.stringify(this.data);case"Uint8Array":return rr.decode(this.data);default:throw new TypeError(`Conversion from ${this.format} to String is not supported.`)}}toStringAsync(){return un(this,void 0,void 0,function*(){var t,e,n,i;switch(this.format){case"AsyncIterable":{let a="";try{for(var o=!0,s=Lc(this.data),c;c=yield s.next(),t=c.done,!t;o=!0){i=c.value,o=!1;let u=i;typeof u=="string"?a+=u:a+=rr.decode(u,{stream:!0})}}catch(u){e={error:u}}finally{try{!o&&!t&&(n=s.return)&&(yield n.call(s))}finally{if(e)throw e.error}}return a+=rr.decode(void 0,{stream:!1}),a}default:throw new TypeError(`Asynchronous conversion from ${this.format} to String is not supported.`)}})}toUint8Array(){switch(this.format){case"ArrayBuffer":return new Uint8Array(this.data);case"Base32Z":return go.baseDecode(this.data);case"Base58Btc":return vt.baseDecode(this.data);case"Base64Url":return Xt.baseDecode(this.data);case"BufferSource":{let t=an(this.data);if(t==="Uint8Array")return this.data;if(t==="ArrayBuffer")return new Uint8Array(this.data);if(ArrayBuffer.isView(this.data))return new Uint8Array(this.data.buffer,this.data.byteOffset,this.data.byteLength);throw new TypeError(`${this.format} value is not of type: ArrayBuffer, DataView, or TypedArray.`)}case"Hex":{let t=new Uint8Array(this.data.length/2);for(let e=0;e<this.data.length;e+=2){let n=parseInt(this.data.substring(e,e+2),16);if(isNaN(n))throw new TypeError("Input is not a valid hexadecimal string.");t[e/2]=n}return t}case"Object":{let t=JSON.stringify(this.data);return Zn.encode(t)}case"String":return Zn.encode(this.data);default:throw new TypeError(`Conversion from ${this.format} to Uint8Array is not supported.`)}}toUint8ArrayAsync(){return un(this,void 0,void 0,function*(){switch(this.format){case"AsyncIterable":{let t=yield this.toArrayBufferAsync();return new Uint8Array(t)}default:throw new TypeError(`Asynchronous conversion from ${this.format} to Uint8Array is not supported.`)}})}};var fn;(function(r){r.Debug="debug",r.Silent="silent"})(fn||(fn={}));var xo=class{constructor(){this.logLevel=fn.Silent}setLogLevel(t){this.logLevel=t}log(t){this.info(t)}info(t){this.logLevel!==fn.Silent&&console.info(t)}error(t){this.logLevel!==fn.Silent&&console.error(t)}},ol=new xo;typeof window<"u"&&(window.web5logger=ol);var ye={};Bc(ye,{decode:()=>kr,encodeTo:()=>nr,encodingLength:()=>ir});var sl=Nc,Oc=128,cl=127,al=~cl,ul=Math.pow(2,31);function Nc(r,t,e){t=t||[],e=e||0;for(var n=e;r>=ul;)t[e++]=r&255|Oc,r/=128;for(;r&al;)t[e++]=r&255|Oc,r>>>=7;return t[e]=r|0,Nc.bytes=e-n+1,t}var fl=bo,ll=128,Rc=127;function bo(r,n){var e=0,n=n||0,i=0,o=n,s,c=r.length;do{if(o>=c)throw bo.bytes=0,new RangeError("Could not decode varint");s=r[o++],e+=i<28?(s&Rc)<<i:(s&Rc)*Math.pow(2,i),i+=7}while(s>=ll);return bo.bytes=o-n,e}var hl=Math.pow(2,7),yl=Math.pow(2,14),pl=Math.pow(2,21),dl=Math.pow(2,28),ml=Math.pow(2,35),wl=Math.pow(2,42),gl=Math.pow(2,49),xl=Math.pow(2,56),bl=Math.pow(2,63),El=function(r){return r<hl?1:r<yl?2:r<pl?3:r<dl?4:r<ml?5:r<wl?6:r<gl?7:r<xl?8:r<bl?9:10},vl={encode:sl,decode:fl,encodingLength:El},Al=vl,ln=Al;function kr(r,t=0){return[ln.decode(r,t),ln.decode.bytes]}function nr(r,t,e=0){return ln.encode(r,t,e),t}function ir(r){return ln.encodingLength(r)}function Eo(r,t){let e=t.byteLength,n=ir(r),i=n+ir(e),o=new Uint8Array(i+e);return nr(r,o,0),nr(e,o,n),o.set(t,i),new Ur(r,e,t,o)}function Dc(r){let t=Sr(r),[e,n]=kr(t),[i,o]=kr(t.subarray(n)),s=t.subarray(n+o);if(s.byteLength!==i)throw new Error("Incorrect length");return new Ur(e,i,s,t)}function Mc(r,t){if(r===t)return!0;{let e=t;return r.code===e.code&&r.size===e.size&&e.bytes instanceof Uint8Array&&Sc(r.bytes,e.bytes)}}var Ur=class{code;size;digest;bytes;constructor(t,e,n,i){this.code=t,this.size=e,this.digest=n,this.bytes=i}};function jc(r,t){let{bytes:e,version:n}=r;switch(n){case 0:return Pl(e,Ao(r),t??vt.encoder);default:return Kl(e,Ao(r),t??cn.encoder)}}var Hc=new WeakMap;function Ao(r){let t=Hc.get(r);if(t==null){let e=new Map;return Hc.set(r,e),e}return t}var Bo=class r{code;version;multihash;bytes;"/";constructor(t,e,n,i){this.code=e,this.version=t,this.multihash=n,this.bytes=i,this["/"]=i}get asCID(){return this}get byteOffset(){return this.bytes.byteOffset}get byteLength(){return this.bytes.byteLength}toV0(){switch(this.version){case 0:return this;case 1:{let{code:t,multihash:e}=this;if(t!==hn)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(e.code!==Tl)throw new Error("Cannot convert non sha2-256 multihash CID to CIDv0");return r.createV0(e)}default:throw Error(`Can not convert CID version ${this.version} to version 0. This is a bug please report`)}}toV1(){switch(this.version){case 0:{let{code:t,digest:e}=this.multihash,n=Eo(t,e);return r.createV1(this.code,n)}case 1:return this;default:throw Error(`Can not convert CID version ${this.version} to version 1. This is a bug please report`)}}equals(t){return r.equals(this,t)}static equals(t,e){let n=e;return n!=null&&t.code===n.code&&t.version===n.version&&Mc(t.multihash,n.multihash)}toString(t){return jc(this,t)}toJSON(){return{"/":jc(this)}}link(){return this}[Symbol.toStringTag]="CID";[Symbol.for("nodejs.util.inspect.custom")](){return`CID(${this.toString()})`}static asCID(t){if(t==null)return null;let e=t;if(e instanceof r)return e;if(e["/"]!=null&&e["/"]===e.bytes||e.asCID===e){let{version:n,code:i,multihash:o,bytes:s}=e;return new r(n,i,o,s??Jc(n,i,o.bytes))}else if(e[Sl]===!0){let{version:n,multihash:i,code:o}=e,s=Dc(i);return r.create(n,o,s)}else return null}static create(t,e,n){if(typeof e!="number")throw new Error("String codecs are no longer supported");if(!(n.bytes instanceof Uint8Array))throw new Error("Invalid digest");switch(t){case 0:{if(e!==hn)throw new Error(`Version 0 CID must use dag-pb (code: ${hn}) block encoding`);return new r(t,e,n,n.bytes)}case 1:{let i=Jc(t,e,n.bytes);return new r(t,e,n,i)}default:throw new Error("Invalid version")}}static createV0(t){return r.create(0,hn,t)}static createV1(t,e){return r.create(1,t,e)}static decode(t){let[e,n]=r.decodeFirst(t);if(n.length!==0)throw new Error("Incorrect length");return e}static decodeFirst(t){let e=r.inspectBytes(t),n=e.size-e.multihashSize,i=Sr(t.subarray(n,n+e.multihashSize));if(i.byteLength!==e.multihashSize)throw new Error("Incorrect length");let o=i.subarray(e.multihashSize-e.digestSize),s=new Ur(e.multihashCode,e.digestSize,o,i);return[e.version===0?r.createV0(s):r.createV1(e.codec,s),t.subarray(e.size)]}static inspectBytes(t){let e=0,n=()=>{let[l,y]=kr(t.subarray(e));return e+=y,l},i=n(),o=hn;if(i===18?(i=0,e=0):o=n(),i!==0&&i!==1)throw new RangeError(`Invalid CID version ${i}`);let s=e,c=n(),a=n(),u=e+a,f=u-s;return{version:i,codec:o,multihashCode:c,digestSize:a,multihashSize:f,size:u}}static parse(t,e){let[n,i]=Bl(t,e),o=r.decode(i);if(o.version===0&&t[0]!=="Q")throw Error("Version 0 CID string must not include multibase prefix");return Ao(o).set(n,t),o}};function Bl(r,t){switch(r[0]){case"Q":{let e=t??vt;return[vt.prefix,e.decode(`${vt.prefix}${r}`)]}case vt.prefix:{let e=t??vt;return[vt.prefix,e.decode(r)]}case cn.prefix:{let e=t??cn;return[cn.prefix,e.decode(r)]}default:{if(t==null)throw Error("To parse non base32 or base58btc encoded CID multibase decoder must be provided");return[r[0],t.decode(r)]}}}function Pl(r,t,e){let{prefix:n}=e;if(n!==vt.prefix)throw Error(`Cannot string encode V0 in ${e.name} encoding`);let i=t.get(n);if(i==null){let o=e.encode(r).slice(1);return t.set(n,o),o}else return i}function Kl(r,t,e){let{prefix:n}=e,i=t.get(n);if(i==null){let o=e.encode(r);return t.set(n,o),o}else return i}var hn=112,Tl=18;function Jc(r,t,e){let n=ir(r),i=n+ir(t),o=new Uint8Array(i+e.byteLength);return nr(r,o,0),nr(t,o,n),o.set(e,i),o}var Sl=Symbol.for("@ipld/js-cid/CID");var Qt=class r{static addPrefix(t){var e;let{code:n,data:i,name:o}=t;if(!(o?!n:n))throw new Error("Either 'name' or 'code' must be defined, but not both.");if(n=r.codeToName.has(n)?n:r.nameToCode.get(o),n===void 0)throw new Error(`Unsupported multicodec: ${(e=t.name)!==null&&e!==void 0?e:t.code}`);let s=ye.encodingLength(n),c=new Uint8Array(s+i.byteLength);return c.set(i,s),ye.encodeTo(n,c),c}static getCodeFromData(t){let{prefixedData:e}=t,[n,i]=ye.decode(e);return n}static getCodeFromName(t){let{name:e}=t,n=r.nameToCode.get(e);if(n===void 0)throw new Error(`Unsupported multicodec: ${e}`);return n}static getNameFromCode(t){let{code:e}=t,n=r.codeToName.get(e);if(n===void 0)throw new Error(`Unsupported multicodec: ${e}`);return n}static registerCodec(t){r.codeToName.set(t.code,t.name),r.nameToCode.set(t.name,t.code)}static removePrefix(t){let{prefixedData:e}=t,[n,i]=ye.decode(e),o=r.codeToName.get(n);if(o===void 0)throw new Error(`Unsupported multicodec: ${n}`);return{code:n,data:e.slice(i),name:o}}};Qt.codeToName=new Map;Qt.nameToCode=new Map;Qt.registerCodec({code:237,name:"ed25519-pub"});Qt.registerCodec({code:4864,name:"ed25519-priv"});Qt.registerCodec({code:236,name:"x25519-pub"});Qt.registerCodec({code:4866,name:"x25519-priv"});Qt.registerCodec({code:231,name:"secp256k1-pub"});Qt.registerCodec({code:4865,name:"secp256k1-priv"});function Po(r){Object.keys(r).forEach(t=>{r[t]===void 0?delete r[t]:typeof r[t]=="object"&&Po(r[t])})}var uy=Pc(yu(),1),Er=function(r,t,e,n){function i(o){return o instanceof e?o:new e(function(s){s(o)})}return new(e||(e=Promise))(function(o,s){function c(f){try{u(n.next(f))}catch(l){s(l)}}function a(f){try{u(n.throw(f))}catch(l){s(l)}}function u(f){f.done?o(f.value):i(f.value).then(c,a)}u((n=n.apply(r,t||[])).next())})};var Ti=class{constructor(){this.store=new Map}clear(){return Er(this,void 0,void 0,function*(){this.store.clear()})}close(){return Er(this,void 0,void 0,function*(){})}delete(t){return Er(this,void 0,void 0,function*(){return this.store.delete(t)})}get(t){return Er(this,void 0,void 0,function*(){return this.store.get(t)})}has(t){return Er(this,void 0,void 0,function*(){return this.store.has(t)})}list(){return Er(this,void 0,void 0,function*(){return Array.from(this.store.values())})}set(t,e){return Er(this,void 0,void 0,function*(){this.store.set(t,e)})}};var ut=class{};var ki={};Bc(ki,{bitGet:()=>my,bitLen:()=>dy,bitMask:()=>On,bitSet:()=>wy,bytesToHex:()=>Ae,bytesToNumberBE:()=>Be,bytesToNumberLE:()=>Wt,concatBytes:()=>Ke,createHmacDrbg:()=>ks,ensureBytes:()=>it,equalBytes:()=>yy,hexToBytes:()=>vr,hexToNumber:()=>Ss,isBytes:()=>$t,numberToBytesBE:()=>Pt,numberToBytesLE:()=>Pe,numberToHexUnpadded:()=>wu,numberToVarBytesBE:()=>hy,utf8ToBytes:()=>py,validateObject:()=>Rt});var mu=BigInt(0),Si=BigInt(1),fy=BigInt(2);function $t(r){return r instanceof Uint8Array||r!=null&&typeof r=="object"&&r.constructor.name==="Uint8Array"}var ly=Array.from({length:256},(r,t)=>t.toString(16).padStart(2,"0"));function Ae(r){if(!$t(r))throw new Error("Uint8Array expected");let t="";for(let e=0;e<r.length;e++)t+=ly[r[e]];return t}function wu(r){let t=r.toString(16);return t.length&1?`0${t}`:t}function Ss(r){if(typeof r!="string")throw new Error("hex string expected, got "+typeof r);return BigInt(r===""?"0":`0x${r}`)}var ve={_0:48,_9:57,_A:65,_F:70,_a:97,_f:102};function pu(r){if(r>=ve._0&&r<=ve._9)return r-ve._0;if(r>=ve._A&&r<=ve._F)return r-(ve._A-10);if(r>=ve._a&&r<=ve._f)return r-(ve._a-10)}function vr(r){if(typeof r!="string")throw new Error("hex string expected, got "+typeof r);let t=r.length,e=t/2;if(t%2)throw new Error("padded hex string expected, got unpadded hex of length "+t);let n=new Uint8Array(e);for(let i=0,o=0;i<e;i++,o+=2){let s=pu(r.charCodeAt(o)),c=pu(r.charCodeAt(o+1));if(s===void 0||c===void 0){let a=r[o]+r[o+1];throw new Error('hex string expected, got non-hex character "'+a+'" at index '+o)}n[i]=s*16+c}return n}function Be(r){return Ss(Ae(r))}function Wt(r){if(!$t(r))throw new Error("Uint8Array expected");return Ss(Ae(Uint8Array.from(r).reverse()))}function Pt(r,t){return vr(r.toString(16).padStart(t*2,"0"))}function Pe(r,t){return Pt(r,t).reverse()}function hy(r){return vr(wu(r))}function it(r,t,e){let n;if(typeof t=="string")try{n=vr(t)}catch(o){throw new Error(`${r} must be valid hex string, got "${t}". Cause: ${o}`)}else if($t(t))n=Uint8Array.from(t);else throw new Error(`${r} must be hex string or Uint8Array`);let i=n.length;if(typeof e=="number"&&i!==e)throw new Error(`${r} expected ${e} bytes, got ${i}`);return n}function Ke(...r){let t=0;for(let i=0;i<r.length;i++){let o=r[i];if(!$t(o))throw new Error("Uint8Array expected");t+=o.length}let e=new Uint8Array(t),n=0;for(let i=0;i<r.length;i++){let o=r[i];e.set(o,n),n+=o.length}return e}function yy(r,t){if(r.length!==t.length)return!1;let e=0;for(let n=0;n<r.length;n++)e|=r[n]^t[n];return e===0}function py(r){if(typeof r!="string")throw new Error(`utf8ToBytes expected string, got ${typeof r}`);return new Uint8Array(new TextEncoder().encode(r))}function dy(r){let t;for(t=0;r>mu;r>>=Si,t+=1);return t}function my(r,t){return r>>BigInt(t)&Si}var wy=(r,t,e)=>r|(e?Si:mu)<<BigInt(t),On=r=>(fy<<BigInt(r-1))-Si,Ts=r=>new Uint8Array(r),du=r=>Uint8Array.from(r);function ks(r,t,e){if(typeof r!="number"||r<2)throw new Error("hashLen must be a number");if(typeof t!="number"||t<2)throw new Error("qByteLen must be a number");if(typeof e!="function")throw new Error("hmacFn must be a function");let n=Ts(r),i=Ts(r),o=0,s=()=>{n.fill(1),i.fill(0),o=0},c=(...l)=>e(i,n,...l),a=(l=Ts())=>{i=c(du([0]),l),n=c(),l.length!==0&&(i=c(du([1]),l),n=c())},u=()=>{if(o++>=1e3)throw new Error("drbg: tried 1000 values");let l=0,y=[];for(;l<t;){n=c();let m=n.slice();y.push(m),l+=n.length}return Ke(...y)};return(l,y)=>{s(),a(l);let m;for(;!(m=y(u()));)a();return s(),m}}var gy={bigint:r=>typeof r=="bigint",function:r=>typeof r=="function",boolean:r=>typeof r=="boolean",string:r=>typeof r=="string",stringOrUint8Array:r=>typeof r=="string"||$t(r),isSafeInteger:r=>Number.isSafeInteger(r),array:r=>Array.isArray(r),field:(r,t)=>t.Fp.isValid(r),hash:r=>typeof r=="function"&&Number.isSafeInteger(r.outputLen)};function Rt(r,t,e={}){let n=(i,o,s)=>{let c=gy[o];if(typeof c!="function")throw new Error(`Invalid validator "${o}", expected function`);let a=r[i];if(!(s&&a===void 0)&&!c(a,r))throw new Error(`Invalid param ${String(i)}=${a} (${typeof a}), expected ${o}`)};for(let[i,o]of Object.entries(t))n(i,o,!1);for(let[i,o]of Object.entries(e))n(i,o,!0);return r}function gu(r){if(!Number.isSafeInteger(r)||r<0)throw new Error(`Wrong positive integer: ${r}`)}function xy(r){return r instanceof Uint8Array||r!=null&&typeof r=="object"&&r.constructor.name==="Uint8Array"}function Us(r,...t){if(!xy(r))throw new Error("Expected Uint8Array");if(t.length>0&&!t.includes(r.length))throw new Error(`Expected Uint8Array of length ${t}, not of length=${r.length}`)}function xu(r){if(typeof r!="function"||typeof r.create!="function")throw new Error("Hash should be wrapped by utils.wrapConstructor");gu(r.outputLen),gu(r.blockLen)}function qr(r,t=!0){if(r.destroyed)throw new Error("Hash instance has been destroyed");if(t&&r.finished)throw new Error("Hash#digest() has already been called")}function bu(r,t){Us(r);let e=t.outputLen;if(r.length<e)throw new Error(`digestInto() expects output buffer of length at least ${e}`)}var Ui=typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0;function Eu(r){return r instanceof Uint8Array||r!=null&&typeof r=="object"&&r.constructor.name==="Uint8Array"}var Ii=r=>new DataView(r.buffer,r.byteOffset,r.byteLength),zt=(r,t)=>r<<32-t|r>>>t,by=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;if(!by)throw new Error("Non little-endian hardware is not supported");function Is(r){if(typeof r!="string")throw new Error(`utf8ToBytes expected string, got ${typeof r}`);return new Uint8Array(new TextEncoder().encode(r))}function Rn(r){if(typeof r=="string"&&(r=Is(r)),!Eu(r))throw new Error(`expected Uint8Array, got ${typeof r}`);return r}function Ci(...r){let t=0;for(let n=0;n<r.length;n++){let i=r[n];if(!Eu(i))throw new Error("Uint8Array expected");t+=i.length}let e=new Uint8Array(t);for(let n=0,i=0;n<r.length;n++){let o=r[n];e.set(o,i),i+=o.length}return e}var Fr=class{clone(){return this._cloneInto()}},Z0={}.toString;function _i(r){let t=n=>r().update(Rn(n)).digest(),e=r();return t.outputLen=e.outputLen,t.blockLen=e.blockLen,t.create=()=>r(),t}function Nn(r=32){if(Ui&&typeof Ui.getRandomValues=="function")return Ui.getRandomValues(new Uint8Array(r));throw new Error("crypto.getRandomValues must be defined")}function Ey(r,t,e,n){if(typeof r.setBigUint64=="function")return r.setBigUint64(t,e,n);let i=BigInt(32),o=BigInt(4294967295),s=Number(e>>i&o),c=Number(e&o),a=n?4:0,u=n?0:4;r.setUint32(t+a,s,n),r.setUint32(t+u,c,n)}var $r=class extends Fr{constructor(t,e,n,i){super(),this.blockLen=t,this.outputLen=e,this.padOffset=n,this.isLE=i,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(t),this.view=Ii(this.buffer)}update(t){qr(this);let{view:e,buffer:n,blockLen:i}=this;t=Rn(t);let o=t.length;for(let s=0;s<o;){let c=Math.min(i-this.pos,o-s);if(c===i){let a=Ii(t);for(;i<=o-s;s+=i)this.process(a,s);continue}n.set(t.subarray(s,s+c),this.pos),this.pos+=c,s+=c,this.pos===i&&(this.process(e,0),this.pos=0)}return this.length+=t.length,this.roundClean(),this}digestInto(t){qr(this),bu(t,this),this.finished=!0;let{buffer:e,view:n,blockLen:i,isLE:o}=this,{pos:s}=this;e[s++]=128,this.buffer.subarray(s).fill(0),this.padOffset>i-s&&(this.process(n,0),s=0);for(let l=s;l<i;l++)e[l]=0;Ey(n,i-8,BigInt(this.length*8),o),this.process(n,0);let c=Ii(t),a=this.outputLen;if(a%4)throw new Error("_sha2: outputLen should be aligned to 32bit");let u=a/4,f=this.get();if(u>f.length)throw new Error("_sha2: outputLen bigger than state");for(let l=0;l<u;l++)c.setUint32(4*l,f[l],o)}digest(){let{buffer:t,outputLen:e}=this;this.digestInto(t);let n=t.slice(0,e);return this.destroy(),n}_cloneInto(t){t||(t=new this.constructor),t.set(...this.get());let{blockLen:e,buffer:n,length:i,finished:o,destroyed:s,pos:c}=this;return t.length=i,t.pos=c,t.finished=o,t.destroyed=s,i%e&&t.buffer.set(n),t}};var vy=(r,t,e)=>r&t^~r&e,Ay=(r,t,e)=>r&t^r&e^t&e,By=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),je=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),He=new Uint32Array(64),Cs=class extends $r{constructor(){super(64,32,8,!1),this.A=je[0]|0,this.B=je[1]|0,this.C=je[2]|0,this.D=je[3]|0,this.E=je[4]|0,this.F=je[5]|0,this.G=je[6]|0,this.H=je[7]|0}get(){let{A:t,B:e,C:n,D:i,E:o,F:s,G:c,H:a}=this;return[t,e,n,i,o,s,c,a]}set(t,e,n,i,o,s,c,a){this.A=t|0,this.B=e|0,this.C=n|0,this.D=i|0,this.E=o|0,this.F=s|0,this.G=c|0,this.H=a|0}process(t,e){for(let l=0;l<16;l++,e+=4)He[l]=t.getUint32(e,!1);for(let l=16;l<64;l++){let y=He[l-15],m=He[l-2],p=zt(y,7)^zt(y,18)^y>>>3,h=zt(m,17)^zt(m,19)^m>>>10;He[l]=h+He[l-7]+p+He[l-16]|0}let{A:n,B:i,C:o,D:s,E:c,F:a,G:u,H:f}=this;for(let l=0;l<64;l++){let y=zt(c,6)^zt(c,11)^zt(c,25),m=f+y+vy(c,a,u)+By[l]+He[l]|0,h=(zt(n,2)^zt(n,13)^zt(n,22))+Ay(n,i,o)|0;f=u,u=a,a=c,c=s+m|0,s=o,o=i,i=n,n=m+h|0}n=n+this.A|0,i=i+this.B|0,o=o+this.C|0,s=s+this.D|0,c=c+this.E|0,a=a+this.F|0,u=u+this.G|0,f=f+this.H|0,this.set(n,i,o,s,c,a,u,f)}roundClean(){He.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}};var Li=_i(()=>new Cs);var lt=BigInt(0),st=BigInt(1),Ar=BigInt(2),Py=BigInt(3),_s=BigInt(4),vu=BigInt(5),Au=BigInt(8),Ky=BigInt(9),Ty=BigInt(16);function tt(r,t){let e=r%t;return e>=lt?e:t+e}function Ls(r,t,e){if(e<=lt||t<lt)throw new Error("Expected power/modulo > 0");if(e===st)return lt;let n=st;for(;t>lt;)t&st&&(n=n*r%e),r=r*r%e,t>>=st;return n}function ot(r,t,e){let n=r;for(;t-- >lt;)n*=n,n%=e;return n}function Oi(r,t){if(r===lt||t<=lt)throw new Error(`invert: expected positive integers, got n=${r} mod=${t}`);let e=tt(r,t),n=t,i=lt,o=st,s=st,c=lt;for(;e!==lt;){let u=n/e,f=n%e,l=i-s*u,y=o-c*u;n=e,e=f,i=s,o=c,s=l,c=y}if(n!==st)throw new Error("invert: does not exist");return tt(i,t)}function Sy(r){let t=(r-st)/Ar,e,n,i;for(e=r-st,n=0;e%Ar===lt;e/=Ar,n++);for(i=Ar;i<r&&Ls(i,t,r)!==r-st;i++);if(n===1){let s=(r+st)/_s;return function(a,u){let f=a.pow(u,s);if(!a.eql(a.sqr(f),u))throw new Error("Cannot find square root");return f}}let o=(e+st)/Ar;return function(c,a){if(c.pow(a,t)===c.neg(c.ONE))throw new Error("Cannot find square root");let u=n,f=c.pow(c.mul(c.ONE,i),e),l=c.pow(a,o),y=c.pow(a,e);for(;!c.eql(y,c.ONE);){if(c.eql(y,c.ZERO))return c.ZERO;let m=1;for(let h=c.sqr(y);m<u&&!c.eql(h,c.ONE);m++)h=c.sqr(h);let p=c.pow(f,st<<BigInt(u-m-1));f=c.sqr(p),l=c.mul(l,p),y=c.mul(y,f),u=m}return l}}function ky(r){if(r%_s===Py){let t=(r+st)/_s;return function(n,i){let o=n.pow(i,t);if(!n.eql(n.sqr(o),i))throw new Error("Cannot find square root");return o}}if(r%Au===vu){let t=(r-vu)/Au;return function(n,i){let o=n.mul(i,Ar),s=n.pow(o,t),c=n.mul(i,s),a=n.mul(n.mul(c,Ar),s),u=n.mul(c,n.sub(a,n.ONE));if(!n.eql(n.sqr(u),i))throw new Error("Cannot find square root");return u}}return r%Ty,Sy(r)}var Bu=(r,t)=>(tt(r,t)&st)===st,Uy=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function Os(r){let t={ORDER:"bigint",MASK:"bigint",BYTES:"isSafeInteger",BITS:"isSafeInteger"},e=Uy.reduce((n,i)=>(n[i]="function",n),t);return Rt(r,e)}function Iy(r,t,e){if(e<lt)throw new Error("Expected power > 0");if(e===lt)return r.ONE;if(e===st)return t;let n=r.ONE,i=t;for(;e>lt;)e&st&&(n=r.mul(n,i)),i=r.sqr(i),e>>=st;return n}function Cy(r,t){let e=new Array(t.length),n=t.reduce((o,s,c)=>r.is0(s)?o:(e[c]=o,r.mul(o,s)),r.ONE),i=r.inv(n);return t.reduceRight((o,s,c)=>r.is0(s)?o:(e[c]=r.mul(o,e[c]),r.mul(o,s)),i),e}function Rs(r,t){let e=t!==void 0?t:r.toString(2).length,n=Math.ceil(e/8);return{nBitLength:e,nByteLength:n}}function Wr(r,t,e=!1,n={}){if(r<=lt)throw new Error(`Expected Field ORDER > 0, got ${r}`);let{nBitLength:i,nByteLength:o}=Rs(r,t);if(o>2048)throw new Error("Field lengths over 2048 bytes are not supported");let s=ky(r),c=Object.freeze({ORDER:r,BITS:i,BYTES:o,MASK:On(i),ZERO:lt,ONE:st,create:a=>tt(a,r),isValid:a=>{if(typeof a!="bigint")throw new Error(`Invalid field element: expected bigint, got ${typeof a}`);return lt<=a&&a<r},is0:a=>a===lt,isOdd:a=>(a&st)===st,neg:a=>tt(-a,r),eql:(a,u)=>a===u,sqr:a=>tt(a*a,r),add:(a,u)=>tt(a+u,r),sub:(a,u)=>tt(a-u,r),mul:(a,u)=>tt(a*u,r),pow:(a,u)=>Iy(c,a,u),div:(a,u)=>tt(a*Oi(u,r),r),sqrN:a=>a*a,addN:(a,u)=>a+u,subN:(a,u)=>a-u,mulN:(a,u)=>a*u,inv:a=>Oi(a,r),sqrt:n.sqrt||(a=>s(c,a)),invertBatch:a=>Cy(c,a),cmov:(a,u,f)=>f?u:a,toBytes:a=>e?Pe(a,o):Pt(a,o),fromBytes:a=>{if(a.length!==o)throw new Error(`Fp.fromBytes: expected ${o}, got ${a.length}`);return e?Wt(a):Be(a)}});return Object.freeze(c)}function Pu(r,t){if(!r.isOdd)throw new Error("Field doesn't have isOdd");let e=r.sqrt(t);return r.isOdd(e)?r.neg(e):e}function Ku(r){if(typeof r!="bigint")throw new Error("field order must be bigint");let t=r.toString(2).length;return Math.ceil(t/8)}function Ns(r){let t=Ku(r);return t+Math.ceil(t/2)}function Tu(r,t,e=!1){let n=r.length,i=Ku(t),o=Ns(t);if(n<16||n<o||n>1024)throw new Error(`expected ${o}-1024 bytes of input, got ${n}`);let s=e?Be(r):Wt(r),c=tt(s,t-st)+st;return e?Pe(c,i):Pt(c,i)}var Ly=BigInt(0),Ds=BigInt(1);function Ri(r,t){let e=(i,o)=>{let s=o.negate();return i?s:o},n=i=>{let o=Math.ceil(t/i)+1,s=2**(i-1);return{windows:o,windowSize:s}};return{constTimeNegate:e,unsafeLadder(i,o){let s=r.ZERO,c=i;for(;o>Ly;)o&Ds&&(s=s.add(c)),c=c.double(),o>>=Ds;return s},precomputeWindow(i,o){let{windows:s,windowSize:c}=n(o),a=[],u=i,f=u;for(let l=0;l<s;l++){f=u,a.push(f);for(let y=1;y<c;y++)f=f.add(u),a.push(f);u=f.double()}return a},wNAF(i,o,s){let{windows:c,windowSize:a}=n(i),u=r.ZERO,f=r.BASE,l=BigInt(2**i-1),y=2**i,m=BigInt(i);for(let p=0;p<c;p++){let h=p*a,d=Number(s&l);s>>=m,d>a&&(d-=y,s+=Ds);let g=h,b=h+Math.abs(d)-1,x=p%2!==0,A=d<0;d===0?f=f.add(e(x,o[g])):u=u.add(e(A,o[b]))}return{p:u,f}},wNAFCached(i,o,s,c){let a=i._WINDOW_SIZE||1,u=o.get(i);return u||(u=this.precomputeWindow(i,a),a!==1&&o.set(i,c(u))),this.wNAF(a,u,s)}}}function Dn(r){return Os(r.Fp),Rt(r,{n:"bigint",h:"bigint",Gx:"field",Gy:"field"},{nBitLength:"isSafeInteger",nByteLength:"isSafeInteger"}),Object.freeze({...Rs(r.n,r.nBitLength),...r,p:r.Fp.ORDER})}function Oy(r){let t=Dn(r);Rt(t,{a:"field",b:"field"},{allowedPrivateKeyLengths:"array",wrapPrivateKey:"boolean",isTorsionFree:"function",clearCofactor:"function",allowInfinityPoint:"boolean",fromBytes:"function",toBytes:"function"});let{endo:e,Fp:n,a:i}=t;if(e){if(!n.eql(i,n.ZERO))throw new Error("Endomorphism can only be defined for Koblitz curves that have a=0");if(typeof e!="object"||typeof e.beta!="bigint"||typeof e.splitScalar!="function")throw new Error("Expected endomorphism with beta: bigint and splitScalar: function")}return Object.freeze({...t})}var{bytesToNumberBE:Ry,hexToBytes:Ny}=ki,Br={Err:class extends Error{constructor(t=""){super(t)}},_parseInt(r){let{Err:t}=Br;if(r.length<2||r[0]!==2)throw new t("Invalid signature integer tag");let e=r[1],n=r.subarray(2,e+2);if(!e||n.length!==e)throw new t("Invalid signature integer: wrong length");if(n[0]&128)throw new t("Invalid signature integer: negative");if(n[0]===0&&!(n[1]&128))throw new t("Invalid signature integer: unnecessary leading zero");return{d:Ry(n),l:r.subarray(e+2)}},toSig(r){let{Err:t}=Br,e=typeof r=="string"?Ny(r):r;if(!$t(e))throw new Error("ui8a expected");let n=e.length;if(n<2||e[0]!=48)throw new t("Invalid signature tag");if(e[1]!==n-2)throw new t("Invalid signature: incorrect length");let{d:i,l:o}=Br._parseInt(e.subarray(2)),{d:s,l:c}=Br._parseInt(o);if(c.length)throw new t("Invalid signature: left bytes after parsing");return{r:i,s}},hexFromSig(r){let t=u=>Number.parseInt(u[0],16)&8?"00"+u:u,e=u=>{let f=u.toString(16);return f.length&1?`0${f}`:f},n=t(e(r.s)),i=t(e(r.r)),o=n.length/2,s=i.length/2,c=e(o),a=e(s);return`30${e(s+o+4)}02${a}${i}02${c}${n}`}},Te=BigInt(0),Nt=BigInt(1),lm=BigInt(2),Su=BigInt(3),hm=BigInt(4);function Dy(r){let t=Oy(r),{Fp:e}=t,n=t.toBytes||((p,h,d)=>{let g=h.toAffine();return Ke(Uint8Array.from([4]),e.toBytes(g.x),e.toBytes(g.y))}),i=t.fromBytes||(p=>{let h=p.subarray(1),d=e.fromBytes(h.subarray(0,e.BYTES)),g=e.fromBytes(h.subarray(e.BYTES,2*e.BYTES));return{x:d,y:g}});function o(p){let{a:h,b:d}=t,g=e.sqr(p),b=e.mul(g,p);return e.add(e.add(b,e.mul(p,h)),d)}if(!e.eql(e.sqr(t.Gy),o(t.Gx)))throw new Error("bad generator point: equation left != right");function s(p){return typeof p=="bigint"&&Te<p&&p<t.n}function c(p){if(!s(p))throw new Error("Expected valid bigint: 0 < bigint < curve.n")}function a(p){let{allowedPrivateKeyLengths:h,nByteLength:d,wrapPrivateKey:g,n:b}=t;if(h&&typeof p!="bigint"){if($t(p)&&(p=Ae(p)),typeof p!="string"||!h.includes(p.length))throw new Error("Invalid key");p=p.padStart(d*2,"0")}let x;try{x=typeof p=="bigint"?p:Be(it("private key",p,d))}catch{throw new Error(`private key must be ${d} bytes, hex or bigint, not ${typeof p}`)}return g&&(x=tt(x,b)),c(x),x}let u=new Map;function f(p){if(!(p instanceof l))throw new Error("ProjectivePoint expected")}class l{constructor(h,d,g){if(this.px=h,this.py=d,this.pz=g,h==null||!e.isValid(h))throw new Error("x required");if(d==null||!e.isValid(d))throw new Error("y required");if(g==null||!e.isValid(g))throw new Error("z required")}static fromAffine(h){let{x:d,y:g}=h||{};if(!h||!e.isValid(d)||!e.isValid(g))throw new Error("invalid affine point");if(h instanceof l)throw new Error("projective point not allowed");let b=x=>e.eql(x,e.ZERO);return b(d)&&b(g)?l.ZERO:new l(d,g,e.ONE)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static normalizeZ(h){let d=e.invertBatch(h.map(g=>g.pz));return h.map((g,b)=>g.toAffine(d[b])).map(l.fromAffine)}static fromHex(h){let d=l.fromAffine(i(it("pointHex",h)));return d.assertValidity(),d}static fromPrivateKey(h){return l.BASE.multiply(a(h))}_setWindowSize(h){this._WINDOW_SIZE=h,u.delete(this)}assertValidity(){if(this.is0()){if(t.allowInfinityPoint&&!e.is0(this.py))return;throw new Error("bad point: ZERO")}let{x:h,y:d}=this.toAffine();if(!e.isValid(h)||!e.isValid(d))throw new Error("bad point: x or y not FE");let g=e.sqr(d),b=o(h);if(!e.eql(g,b))throw new Error("bad point: equation left != right");if(!this.isTorsionFree())throw new Error("bad point: not in prime-order subgroup")}hasEvenY(){let{y:h}=this.toAffine();if(e.isOdd)return!e.isOdd(h);throw new Error("Field doesn't support isOdd")}equals(h){f(h);let{px:d,py:g,pz:b}=this,{px:x,py:A,pz:v}=h,K=e.eql(e.mul(d,v),e.mul(x,b)),k=e.eql(e.mul(g,v),e.mul(A,b));return K&&k}negate(){return new l(this.px,e.neg(this.py),this.pz)}double(){let{a:h,b:d}=t,g=e.mul(d,Su),{px:b,py:x,pz:A}=this,v=e.ZERO,K=e.ZERO,k=e.ZERO,T=e.mul(b,b),L=e.mul(x,x),O=e.mul(A,A),C=e.mul(b,x);return C=e.add(C,C),k=e.mul(b,A),k=e.add(k,k),v=e.mul(h,k),K=e.mul(g,O),K=e.add(v,K),v=e.sub(L,K),K=e.add(L,K),K=e.mul(v,K),v=e.mul(C,v),k=e.mul(g,k),O=e.mul(h,O),C=e.sub(T,O),C=e.mul(h,C),C=e.add(C,k),k=e.add(T,T),T=e.add(k,T),T=e.add(T,O),T=e.mul(T,C),K=e.add(K,T),O=e.mul(x,A),O=e.add(O,O),T=e.mul(O,C),v=e.sub(v,T),k=e.mul(O,L),k=e.add(k,k),k=e.add(k,k),new l(v,K,k)}add(h){f(h);let{px:d,py:g,pz:b}=this,{px:x,py:A,pz:v}=h,K=e.ZERO,k=e.ZERO,T=e.ZERO,L=t.a,O=e.mul(t.b,Su),C=e.mul(d,x),j=e.mul(g,A),M=e.mul(b,v),z=e.add(d,g),B=e.add(x,A);z=e.mul(z,B),B=e.add(C,j),z=e.sub(z,B),B=e.add(d,b);let U=e.add(x,v);return B=e.mul(B,U),U=e.add(C,M),B=e.sub(B,U),U=e.add(g,b),K=e.add(A,v),U=e.mul(U,K),K=e.add(j,M),U=e.sub(U,K),T=e.mul(L,B),K=e.mul(O,M),T=e.add(K,T),K=e.sub(j,T),T=e.add(j,T),k=e.mul(K,T),j=e.add(C,C),j=e.add(j,C),M=e.mul(L,M),B=e.mul(O,B),j=e.add(j,M),M=e.sub(C,M),M=e.mul(L,M),B=e.add(B,M),C=e.mul(j,B),k=e.add(k,C),C=e.mul(U,B),K=e.mul(z,K),K=e.sub(K,C),C=e.mul(z,j),T=e.mul(U,T),T=e.add(T,C),new l(K,k,T)}subtract(h){return this.add(h.negate())}is0(){return this.equals(l.ZERO)}wNAF(h){return m.wNAFCached(this,u,h,d=>{let g=e.invertBatch(d.map(b=>b.pz));return d.map((b,x)=>b.toAffine(g[x])).map(l.fromAffine)})}multiplyUnsafe(h){let d=l.ZERO;if(h===Te)return d;if(c(h),h===Nt)return this;let{endo:g}=t;if(!g)return m.unsafeLadder(this,h);let{k1neg:b,k1:x,k2neg:A,k2:v}=g.splitScalar(h),K=d,k=d,T=this;for(;x>Te||v>Te;)x&Nt&&(K=K.add(T)),v&Nt&&(k=k.add(T)),T=T.double(),x>>=Nt,v>>=Nt;return b&&(K=K.negate()),A&&(k=k.negate()),k=new l(e.mul(k.px,g.beta),k.py,k.pz),K.add(k)}multiply(h){c(h);let d=h,g,b,{endo:x}=t;if(x){let{k1neg:A,k1:v,k2neg:K,k2:k}=x.splitScalar(d),{p:T,f:L}=this.wNAF(v),{p:O,f:C}=this.wNAF(k);T=m.constTimeNegate(A,T),O=m.constTimeNegate(K,O),O=new l(e.mul(O.px,x.beta),O.py,O.pz),g=T.add(O),b=L.add(C)}else{let{p:A,f:v}=this.wNAF(d);g=A,b=v}return l.normalizeZ([g,b])[0]}multiplyAndAddUnsafe(h,d,g){let b=l.BASE,x=(v,K)=>K===Te||K===Nt||!v.equals(b)?v.multiplyUnsafe(K):v.multiply(K),A=x(this,d).add(x(h,g));return A.is0()?void 0:A}toAffine(h){let{px:d,py:g,pz:b}=this,x=this.is0();h==null&&(h=x?e.ONE:e.inv(b));let A=e.mul(d,h),v=e.mul(g,h),K=e.mul(b,h);if(x)return{x:e.ZERO,y:e.ZERO};if(!e.eql(K,e.ONE))throw new Error("invZ was invalid");return{x:A,y:v}}isTorsionFree(){let{h,isTorsionFree:d}=t;if(h===Nt)return!0;if(d)return d(l,this);throw new Error("isTorsionFree() has not been declared for the elliptic curve")}clearCofactor(){let{h,clearCofactor:d}=t;return h===Nt?this:d?d(l,this):this.multiplyUnsafe(t.h)}toRawBytes(h=!0){return this.assertValidity(),n(l,this,h)}toHex(h=!0){return Ae(this.toRawBytes(h))}}l.BASE=new l(t.Gx,t.Gy,e.ONE),l.ZERO=new l(e.ZERO,e.ONE,e.ZERO);let y=t.nBitLength,m=Ri(l,t.endo?Math.ceil(y/2):y);return{CURVE:t,ProjectivePoint:l,normPrivateKeyToScalar:a,weierstrassEquation:o,isWithinCurveOrder:s}}function My(r){let t=Dn(r);return Rt(t,{hash:"hash",hmac:"function",randomBytes:"function"},{bits2int:"function",bits2int_modN:"function",lowS:"boolean"}),Object.freeze({lowS:!0,...t})}function ku(r){let t=My(r),{Fp:e,n}=t,i=e.BYTES+1,o=2*e.BYTES+1;function s(B){return Te<B&&B<e.ORDER}function c(B){return tt(B,n)}function a(B){return Oi(B,n)}let{ProjectivePoint:u,normPrivateKeyToScalar:f,weierstrassEquation:l,isWithinCurveOrder:y}=Dy({...t,toBytes(B,U,R){let P=U.toAffine(),w=e.toBytes(P.x),S=Ke;return R?S(Uint8Array.from([U.hasEvenY()?2:3]),w):S(Uint8Array.from([4]),w,e.toBytes(P.y))},fromBytes(B){let U=B.length,R=B[0],P=B.subarray(1);if(U===i&&(R===2||R===3)){let w=Be(P);if(!s(w))throw new Error("Point is not on curve");let S=l(w),I=e.sqrt(S),_=(I&Nt)===Nt;return(R&1)===1!==_&&(I=e.neg(I)),{x:w,y:I}}else if(U===o&&R===4){let w=e.fromBytes(P.subarray(0,e.BYTES)),S=e.fromBytes(P.subarray(e.BYTES,2*e.BYTES));return{x:w,y:S}}else throw new Error(`Point of length ${U} was invalid. Expected ${i} compressed bytes or ${o} uncompressed bytes`)}}),m=B=>Ae(Pt(B,t.nByteLength));function p(B){let U=n>>Nt;return B>U}function h(B){return p(B)?c(-B):B}let d=(B,U,R)=>Be(B.slice(U,R));class g{constructor(U,R,P){this.r=U,this.s=R,this.recovery=P,this.assertValidity()}static fromCompact(U){let R=t.nByteLength;return U=it("compactSignature",U,R*2),new g(d(U,0,R),d(U,R,2*R))}static fromDER(U){let{r:R,s:P}=Br.toSig(it("DER",U));return new g(R,P)}assertValidity(){if(!y(this.r))throw new Error("r must be 0 < r < CURVE.n");if(!y(this.s))throw new Error("s must be 0 < s < CURVE.n")}addRecoveryBit(U){return new g(this.r,this.s,U)}recoverPublicKey(U){let{r:R,s:P,recovery:w}=this,S=k(it("msgHash",U));if(w==null||![0,1,2,3].includes(w))throw new Error("recovery id invalid");let I=w===2||w===3?R+t.n:R;if(I>=e.ORDER)throw new Error("recovery id 2 or 3 invalid");let _=w&1?"03":"02",H=u.fromHex(_+m(I)),J=a(I),Z=c(-S*J),q=c(P*J),F=u.BASE.multiplyAndAddUnsafe(H,Z,q);if(!F)throw new Error("point at infinify");return F.assertValidity(),F}hasHighS(){return p(this.s)}normalizeS(){return this.hasHighS()?new g(this.r,c(-this.s),this.recovery):this}toDERRawBytes(){return vr(this.toDERHex())}toDERHex(){return Br.hexFromSig({r:this.r,s:this.s})}toCompactRawBytes(){return vr(this.toCompactHex())}toCompactHex(){return m(this.r)+m(this.s)}}let b={isValidPrivateKey(B){try{return f(B),!0}catch{return!1}},normPrivateKeyToScalar:f,randomPrivateKey:()=>{let B=Ns(t.n);return Tu(t.randomBytes(B),t.n)},precompute(B=8,U=u.BASE){return U._setWindowSize(B),U.multiply(BigInt(3)),U}};function x(B,U=!0){return u.fromPrivateKey(B).toRawBytes(U)}function A(B){let U=$t(B),R=typeof B=="string",P=(U||R)&&B.length;return U?P===i||P===o:R?P===2*i||P===2*o:B instanceof u}function v(B,U,R=!0){if(A(B))throw new Error("first arg must be private key");if(!A(U))throw new Error("second arg must be public key");return u.fromHex(U).multiply(f(B)).toRawBytes(R)}let K=t.bits2int||function(B){let U=Be(B),R=B.length*8-t.nBitLength;return R>0?U>>BigInt(R):U},k=t.bits2int_modN||function(B){return c(K(B))},T=On(t.nBitLength);function L(B){if(typeof B!="bigint")throw new Error("bigint expected");if(!(Te<=B&&B<T))throw new Error(`bigint expected < 2^${t.nBitLength}`);return Pt(B,t.nByteLength)}function O(B,U,R=C){if(["recovered","canonical"].some(et=>et in R))throw new Error("sign() legacy options not supported");let{hash:P,randomBytes:w}=t,{lowS:S,prehash:I,extraEntropy:_}=R;S==null&&(S=!0),B=it("msgHash",B),I&&(B=it("prehashed msgHash",P(B)));let H=k(B),J=f(U),Z=[L(J),L(H)];if(_!=null){let et=_===!0?w(e.BYTES):_;Z.push(it("extraEntropy",et))}let q=Ke(...Z),F=H;function rt(et){let yt=K(et);if(!y(yt))return;let pt=a(yt),ft=u.BASE.multiply(yt).toAffine(),mt=c(ft.x);if(mt===Te)return;let he=c(pt*c(F+mt*J));if(he===Te)return;let er=(ft.x===mt?0:2)|Number(ft.y&Nt),on=he;return S&&p(he)&&(on=h(he),er^=1),new g(mt,on,er)}return{seed:q,k2sig:rt}}let C={lowS:t.lowS,prehash:!1},j={lowS:t.lowS,prehash:!1};function M(B,U,R=C){let{seed:P,k2sig:w}=O(B,U,R),S=t;return ks(S.hash.outputLen,S.nByteLength,S.hmac)(P,w)}u.BASE._setWindowSize(8);function z(B,U,R,P=j){let w=B;if(U=it("msgHash",U),R=it("publicKey",R),"strict"in P)throw new Error("options.strict was renamed to lowS");let{lowS:S,prehash:I}=P,_,H;try{if(typeof w=="string"||$t(w))try{_=g.fromDER(w)}catch(ft){if(!(ft instanceof Br.Err))throw ft;_=g.fromCompact(w)}else if(typeof w=="object"&&typeof w.r=="bigint"&&typeof w.s=="bigint"){let{r:ft,s:mt}=w;_=new g(ft,mt)}else throw new Error("PARSE");H=u.fromHex(R)}catch(ft){if(ft.message==="PARSE")throw new Error("signature must be Signature instance, Uint8Array or hex string");return!1}if(S&&_.hasHighS())return!1;I&&(U=t.hash(U));let{r:J,s:Z}=_,q=k(U),F=a(Z),rt=c(q*F),et=c(J*F),yt=u.BASE.multiplyAndAddUnsafe(H,rt,et)?.toAffine();return yt?c(yt.x)===J:!1}return{CURVE:t,getPublicKey:x,getSharedSecret:v,sign:M,verify:z,ProjectivePoint:u,Signature:g,utils:b}}var Ni=class extends Fr{constructor(t,e){super(),this.finished=!1,this.destroyed=!1,xu(t);let n=Rn(e);if(this.iHash=t.create(),typeof this.iHash.update!="function")throw new Error("Expected instance of class which extends utils.Hash");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;let i=this.blockLen,o=new Uint8Array(i);o.set(n.length>i?t.create().update(n).digest():n);for(let s=0;s<o.length;s++)o[s]^=54;this.iHash.update(o),this.oHash=t.create();for(let s=0;s<o.length;s++)o[s]^=106;this.oHash.update(o),o.fill(0)}update(t){return qr(this),this.iHash.update(t),this}digestInto(t){qr(this),Us(t,this.outputLen),this.finished=!0,this.iHash.digestInto(t),this.oHash.update(t),this.oHash.digestInto(t),this.destroy()}digest(){let t=new Uint8Array(this.oHash.outputLen);return this.digestInto(t),t}_cloneInto(t){t||(t=Object.create(Object.getPrototypeOf(this),{}));let{oHash:e,iHash:n,finished:i,destroyed:o,blockLen:s,outputLen:c}=this;return t=t,t.finished=i,t.destroyed=o,t.blockLen=s,t.outputLen=c,t.oHash=e._cloneInto(t.oHash),t.iHash=n._cloneInto(t.iHash),t}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}},Ms=(r,t,e)=>new Ni(r,t).update(e).digest();Ms.create=(r,t)=>new Ni(r,t);function jy(r){return{hash:r,hmac:(t,...e)=>Ms(r,t,Ci(...e)),randomBytes:Nn}}function Di(r,t){let e=n=>ku({...r,...jy(n)});return Object.freeze({...e(t),create:e})}var Cu=BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),Uu=BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),Hy=BigInt(1),js=BigInt(2),Iu=(r,t)=>(r+t/js)/t;function Jy(r){let t=Cu,e=BigInt(3),n=BigInt(6),i=BigInt(11),o=BigInt(22),s=BigInt(23),c=BigInt(44),a=BigInt(88),u=r*r*r%t,f=u*u*r%t,l=ot(f,e,t)*f%t,y=ot(l,e,t)*f%t,m=ot(y,js,t)*u%t,p=ot(m,i,t)*m%t,h=ot(p,o,t)*p%t,d=ot(h,c,t)*h%t,g=ot(d,a,t)*d%t,b=ot(g,c,t)*h%t,x=ot(b,e,t)*f%t,A=ot(x,s,t)*p%t,v=ot(A,n,t)*u%t,K=ot(v,js,t);if(!Hs.eql(Hs.sqr(K),r))throw new Error("Cannot find square root");return K}var Hs=Wr(Cu,void 0,void 0,{sqrt:Jy}),at=Di({a:BigInt(0),b:BigInt(7),Fp:Hs,n:Uu,Gx:BigInt("55066263022277343669578718895168534326250603453777594175500187360389116729240"),Gy:BigInt("32670510020758816978083085130507043184471273380659243275938904335757337482424"),h:BigInt(1),lowS:!0,endo:{beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),splitScalar:r=>{let t=Uu,e=BigInt("0x3086d221a7d46bcde86c90e49284eb15"),n=-Hy*BigInt("0xe4437ed6010e88286f547fa90abfe4c3"),i=BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),o=e,s=BigInt("0x100000000000000000000000000000000"),c=Iu(o*r,t),a=Iu(-n*r,t),u=tt(r-c*e-a*i,t),f=tt(-c*n-a*o,t),l=u>s,y=f>s;if(l&&(u=t-u),y&&(f=t-f),u>s||f>s)throw new Error("splitScalar: Endomorphism failed, k="+r);return{k1neg:l,k1:u,k2neg:y,k2:f}}}},Li),Bm=BigInt(0);var Pm=at.ProjectivePoint;function Mi(r){if(!Number.isSafeInteger(r)||r<0)throw new Error(`positive integer expected, not ${r}`)}function Gy(r){return r instanceof Uint8Array||r!=null&&typeof r=="object"&&r.constructor.name==="Uint8Array"}function zr(r,...t){if(!Gy(r))throw new Error("Uint8Array expected");if(t.length>0&&!t.includes(r.length))throw new Error(`Uint8Array expected of length ${t}, not of length=${r.length}`)}function Mn(r){if(typeof r!="function"||typeof r.create!="function")throw new Error("Hash should be wrapped by utils.wrapConstructor");Mi(r.outputLen),Mi(r.blockLen)}function Zr(r,t=!0){if(r.destroyed)throw new Error("Hash instance has been destroyed");if(t&&r.finished)throw new Error("Hash#digest() has already been called")}function _u(r,t){zr(r);let e=t.outputLen;if(r.length<e)throw new Error(`digestInto() expects output buffer of length at least ${e}`)}var Se=typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0;var ji=r=>new DataView(r.buffer,r.byteOffset,r.byteLength),Zt=(r,t)=>r<<32-t|r>>>t;var Im=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;function Vy(r){if(typeof r!="string")throw new Error(`utf8ToBytes expected string, got ${typeof r}`);return new Uint8Array(new TextEncoder().encode(r))}function Je(r){return typeof r=="string"&&(r=Vy(r)),zr(r),r}function Js(...r){let t=0;for(let n=0;n<r.length;n++){let i=r[n];zr(i),t+=i.length}let e=new Uint8Array(t);for(let n=0,i=0;n<r.length;n++){let o=r[n];e.set(o,i),i+=o.length}return e}var Yr=class{clone(){return this._cloneInto()}},Cm={}.toString;function Lu(r){let t=n=>r().update(Je(n)).digest(),e=r();return t.outputLen=e.outputLen,t.blockLen=e.blockLen,t.create=()=>r(),t}function Ou(r=32){if(Se&&typeof Se.getRandomValues=="function")return Se.getRandomValues(new Uint8Array(r));throw new Error("crypto.getRandomValues must be defined")}function qy(r,t,e,n){if(typeof r.setBigUint64=="function")return r.setBigUint64(t,e,n);let i=BigInt(32),o=BigInt(4294967295),s=Number(e>>i&o),c=Number(e&o),a=n?4:0,u=n?0:4;r.setUint32(t+a,s,n),r.setUint32(t+u,c,n)}var Ru=(r,t,e)=>r&t^~r&e,Nu=(r,t,e)=>r&t^r&e^t&e,Hi=class extends Yr{constructor(t,e,n,i){super(),this.blockLen=t,this.outputLen=e,this.padOffset=n,this.isLE=i,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(t),this.view=ji(this.buffer)}update(t){Zr(this);let{view:e,buffer:n,blockLen:i}=this;t=Je(t);let o=t.length;for(let s=0;s<o;){let c=Math.min(i-this.pos,o-s);if(c===i){let a=ji(t);for(;i<=o-s;s+=i)this.process(a,s);continue}n.set(t.subarray(s,s+c),this.pos),this.pos+=c,s+=c,this.pos===i&&(this.process(e,0),this.pos=0)}return this.length+=t.length,this.roundClean(),this}digestInto(t){Zr(this),_u(t,this),this.finished=!0;let{buffer:e,view:n,blockLen:i,isLE:o}=this,{pos:s}=this;e[s++]=128,this.buffer.subarray(s).fill(0),this.padOffset>i-s&&(this.process(n,0),s=0);for(let l=s;l<i;l++)e[l]=0;qy(n,i-8,BigInt(this.length*8),o),this.process(n,0);let c=ji(t),a=this.outputLen;if(a%4)throw new Error("_sha2: outputLen should be aligned to 32bit");let u=a/4,f=this.get();if(u>f.length)throw new Error("_sha2: outputLen bigger than state");for(let l=0;l<u;l++)c.setUint32(4*l,f[l],o)}digest(){let{buffer:t,outputLen:e}=this;this.digestInto(t);let n=t.slice(0,e);return this.destroy(),n}_cloneInto(t){t||(t=new this.constructor),t.set(...this.get());let{blockLen:e,buffer:n,length:i,finished:o,destroyed:s,pos:c}=this;return t.length=i,t.pos=c,t.finished=o,t.destroyed=s,i%e&&t.buffer.set(n),t}};var Fy=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),Ge=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),Ve=new Uint32Array(64),Gs=class extends Hi{constructor(){super(64,32,8,!1),this.A=Ge[0]|0,this.B=Ge[1]|0,this.C=Ge[2]|0,this.D=Ge[3]|0,this.E=Ge[4]|0,this.F=Ge[5]|0,this.G=Ge[6]|0,this.H=Ge[7]|0}get(){let{A:t,B:e,C:n,D:i,E:o,F:s,G:c,H:a}=this;return[t,e,n,i,o,s,c,a]}set(t,e,n,i,o,s,c,a){this.A=t|0,this.B=e|0,this.C=n|0,this.D=i|0,this.E=o|0,this.F=s|0,this.G=c|0,this.H=a|0}process(t,e){for(let l=0;l<16;l++,e+=4)Ve[l]=t.getUint32(e,!1);for(let l=16;l<64;l++){let y=Ve[l-15],m=Ve[l-2],p=Zt(y,7)^Zt(y,18)^y>>>3,h=Zt(m,17)^Zt(m,19)^m>>>10;Ve[l]=h+Ve[l-7]+p+Ve[l-16]|0}let{A:n,B:i,C:o,D:s,E:c,F:a,G:u,H:f}=this;for(let l=0;l<64;l++){let y=Zt(c,6)^Zt(c,11)^Zt(c,25),m=f+y+Ru(c,a,u)+Fy[l]+Ve[l]|0,h=(Zt(n,2)^Zt(n,13)^Zt(n,22))+Nu(n,i,o)|0;f=u,u=a,a=c,c=s+m|0,s=o,o=i,i=n,n=m+h|0}n=n+this.A|0,i=i+this.B|0,o=o+this.C|0,s=s+this.D|0,c=c+this.E|0,a=a+this.F|0,u=u+this.G|0,f=f+this.H|0,this.set(n,i,o,s,c,a,u,f)}roundClean(){Ve.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}};var kt=Lu(()=>new Gs);function Du(r){let t=n=>{if(n!==null&&typeof n=="object"&&!Array.isArray(n)){let i=Object.keys(n).sort(),o={};for(let s of i)o[s]=t(n[s]);return o}return n},e=t(r);return JSON.stringify(e)}var Xr=class{static async digest({data:t}){return kt(t)}};var Vs="urn:jwk:";async function G({jwk:r}){let t=r.kty,e;if(t==="EC")e={crv:r.crv,kty:r.kty,x:r.x,y:r.y};else if(t==="oct")e={k:r.k,kty:r.kty};else if(t==="OKP")e={crv:r.crv,kty:r.kty,x:r.x};else if(t==="RSA")e={e:r.e,kty:r.kty,n:r.n};else throw new Error(`Unsupported key type: ${t}`);Po(e);let n=Du(e),i=N.string(n).toUint8Array(),o=await Xr.digest({data:i});return N.uint8Array(o).toBase64Url()}function oe(r){return!(!r||typeof r!="object"||!("kty"in r&&"crv"in r&&"x"in r&&"d"in r)||r.kty!=="EC"||typeof r.d!="string"||typeof r.x!="string")}function Qr(r){return!(!r||typeof r!="object"||!("kty"in r&&"crv"in r&&"x"in r)||"d"in r||r.kty!=="EC"||typeof r.x!="string")}function se(r){return!(!r||typeof r!="object"||!("kty"in r&&"k"in r)||r.kty!=="oct"||typeof r.k!="string")}function Ut(r){return!(!r||typeof r!="object"||!("kty"in r&&"crv"in r&&"x"in r&&"d"in r)||r.kty!=="OKP"||typeof r.d!="string"||typeof r.x!="string")}function tn(r){return!(!r||typeof r!="object"||"d"in r||!("kty"in r&&"crv"in r&&"x"in r)||r.kty!=="OKP"||typeof r.x!="string")}function Mu(r){if(!r||typeof r!="object")return!1;switch(r.kty){case"EC":case"OKP":case"RSA":return"d"in r;case"oct":return"k"in r;default:return!1}}function Fm(r){if(!r||typeof r!="object")return!1;switch(r.kty){case"EC":case"OKP":return"x"in r&&!("d"in r);case"RSA":return"n"in r&&"e"in r&&!("d"in r);default:return!1}}var Dt=class r{static async adjustSignatureToLowS({signature:t}){let e=at.Signature.fromCompact(t);return e.hasHighS()?e.normalizeS().toCompactRawBytes():t}static async bytesToPrivateKey({privateKeyBytes:t}){let e=await r.getCurvePoint({keyBytes:t}),n={kty:"EC",crv:"secp256k1",d:N.uint8Array(t).toBase64Url(),x:N.uint8Array(e.x).toBase64Url(),y:N.uint8Array(e.y).toBase64Url()};return n.kid=await G({jwk:n}),n}static async bytesToPublicKey({publicKeyBytes:t}){let e=await r.getCurvePoint({keyBytes:t}),n={kty:"EC",crv:"secp256k1",x:N.uint8Array(e.x).toBase64Url(),y:N.uint8Array(e.y).toBase64Url()};return n.kid=await G({jwk:n}),n}static async compressPublicKey({publicKeyBytes:t}){return at.ProjectivePoint.fromHex(t).toRawBytes(!0)}static async computePublicKey({key:t}){let e=await r.privateKeyToBytes({privateKey:t}),n=await r.getCurvePoint({keyBytes:e}),i={kty:"EC",crv:"secp256k1",x:N.uint8Array(n.x).toBase64Url(),y:N.uint8Array(n.y).toBase64Url()};return i.kid=await G({jwk:i}),i}static async convertDerToCompactSignature({derSignature:t}){return at.Signature.fromDER(t).toCompactRawBytes()}static async decompressPublicKey({publicKeyBytes:t}){return at.ProjectivePoint.fromHex(t).toRawBytes(!1)}static async generateKey(){let t=at.utils.randomPrivateKey(),e=await r.bytesToPrivateKey({privateKeyBytes:t});return e.kid=await G({jwk:e}),e}static async getPublicKey({key:t}){if(!(oe(t)&&t.crv==="secp256k1"))throw new Error("Secp256k1: The provided key is not a secp256k1 private JWK.");let{d:e,...n}=t;return n.kid??=await G({jwk:n}),n}static async privateKeyToBytes({privateKey:t}){if(!oe(t))throw new Error("Secp256k1: The provided key is not a valid EC private key.");return N.base64Url(t.d).toUint8Array()}static async publicKeyToBytes({publicKey:t}){if(!(Qr(t)&&t.y))throw new Error("Secp256k1: The provided key is not a valid EC public key.");let e=new Uint8Array([4]),n=N.base64Url(t.x).toUint8Array(),i=N.base64Url(t.y).toUint8Array();return new Uint8Array([...e,...n,...i])}static async sharedSecret({privateKeyA:t,publicKeyB:e}){if("x"in t&&"x"in e&&t.x===e.x)throw new Error("Secp256k1: ECDH shared secret cannot be computed from a single key pair's public and private keys.");let n=await r.privateKeyToBytes({privateKey:t}),i=await r.publicKeyToBytes({publicKey:e});return at.getSharedSecret(n,i,!0).slice(1)}static async sign({data:t,key:e}){let n=await r.privateKeyToBytes({privateKey:e}),i=kt(t);return at.sign(i,n).toCompactRawBytes()}static async validatePrivateKey({privateKeyBytes:t}){return at.utils.isValidPrivateKey(t)}static async validatePublicKey({publicKeyBytes:t}){try{at.ProjectivePoint.fromHex(t).assertValidity()}catch{return!1}return!0}static async verify({key:t,signature:e,data:n}){let i=await r.publicKeyToBytes({publicKey:t}),o=kt(n);return at.verify(e,o,i,{lowS:!1})}static async getCurvePoint({keyBytes:t}){t.byteLength===32&&(t=at.getPublicKey(t));let e=at.ProjectivePoint.fromHex(t),n=Pt(e.x,32),i=Pt(e.y,32);return{x:n,y:i}}};var ju=Wr(BigInt("0xffffffff00000001000000000000000000000000ffffffffffffffffffffffff")),$y=ju.create(BigInt("-3")),Wy=BigInt("0x5ac635d8aa3a93e7b3ebbd55769886bc651d06b0cc53b0f63bce3c3e27d2604b"),zy=Di({a:$y,b:Wy,Fp:ju,n:BigInt("0xffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc632551"),Gx:BigInt("0x6b17d1f2e12c4247f8bce6e563a440f277037d812deb33a0f4a13945d898c296"),Gy:BigInt("0x4fe342e2fe1a7f9b8ee7eb4a7c0f9e162bce33576b315ececbb6406837bf51f5"),h:BigInt(1),lowS:!1},Li),It=zy;var Mt=class r{static async adjustSignatureToLowS({signature:t}){let e=It.Signature.fromCompact(t);return e.hasHighS()?e.normalizeS().toCompactRawBytes():t}static async bytesToPrivateKey({privateKeyBytes:t}){let e=await r.getCurvePoint({keyBytes:t}),n={kty:"EC",crv:"P-256",d:N.uint8Array(t).toBase64Url(),x:N.uint8Array(e.x).toBase64Url(),y:N.uint8Array(e.y).toBase64Url()};return n.kid=await G({jwk:n}),n}static async bytesToPublicKey({publicKeyBytes:t}){let e=await r.getCurvePoint({keyBytes:t}),n={kty:"EC",crv:"P-256",x:N.uint8Array(e.x).toBase64Url(),y:N.uint8Array(e.y).toBase64Url()};return n.kid=await G({jwk:n}),n}static async compressPublicKey({publicKeyBytes:t}){return It.ProjectivePoint.fromHex(t).toRawBytes(!0)}static async computePublicKey({key:t}){let e=await r.privateKeyToBytes({privateKey:t}),n=await r.getCurvePoint({keyBytes:e}),i={kty:"EC",crv:"P-256",x:N.uint8Array(n.x).toBase64Url(),y:N.uint8Array(n.y).toBase64Url()};return i.kid=await G({jwk:i}),i}static async convertDerToCompactSignature({derSignature:t}){return It.Signature.fromDER(t).toCompactRawBytes()}static async decompressPublicKey({publicKeyBytes:t}){return It.ProjectivePoint.fromHex(t).toRawBytes(!1)}static async generateKey(){let t=It.utils.randomPrivateKey(),e=await r.bytesToPrivateKey({privateKeyBytes:t});return e.kid=await G({jwk:e}),e}static async getPublicKey({key:t}){if(!(oe(t)&&t.crv==="P-256"))throw new Error("Secp256r1: The provided key is not a 'P-256' private JWK.");let{d:e,...n}=t;return n.kid??=await G({jwk:n}),n}static async privateKeyToBytes({privateKey:t}){if(!oe(t))throw new Error("Secp256r1: The provided key is not a valid EC private key.");return N.base64Url(t.d).toUint8Array()}static async publicKeyToBytes({publicKey:t}){if(!(Qr(t)&&t.y))throw new Error("Secp256r1: The provided key is not a valid EC public key.");let e=new Uint8Array([4]),n=N.base64Url(t.x).toUint8Array(),i=N.base64Url(t.y).toUint8Array();return new Uint8Array([...e,...n,...i])}static async sharedSecret({privateKeyA:t,publicKeyB:e}){if("x"in t&&"x"in e&&t.x===e.x)throw new Error("Secp256r1: ECDH shared secret cannot be computed from a single key pair's public and private keys.");let n=await r.privateKeyToBytes({privateKey:t}),i=await r.publicKeyToBytes({publicKey:e});return It.getSharedSecret(n,i,!0).slice(1)}static async sign({data:t,key:e}){let n=await r.privateKeyToBytes({privateKey:e}),i=kt(t);return It.sign(i,n).toCompactRawBytes()}static async validatePrivateKey({privateKeyBytes:t}){return It.utils.isValidPrivateKey(t)}static async validatePublicKey({publicKeyBytes:t}){try{It.ProjectivePoint.fromHex(t).assertValidity()}catch{return!1}return!0}static async verify({key:t,signature:e,data:n}){let i=await r.publicKeyToBytes({publicKey:t}),o=kt(n);return It.verify(e,o,i,{lowS:!1})}static async getCurvePoint({keyBytes:t}){t.byteLength===32&&(t=It.getPublicKey(t));let e=It.ProjectivePoint.fromHex(t),n=Pt(e.x,32),i=Pt(e.y,32);return{x:n,y:i}}};var jn=class extends ut{async bytesToPrivateKey({algorithm:t,privateKeyBytes:e}){switch(t){case"ES256K":case"secp256k1":{let n=await Dt.bytesToPrivateKey({privateKeyBytes:e});return n.alg="ES256K",n}case"ES256":case"secp256r1":{let n=await Mt.bytesToPrivateKey({privateKeyBytes:e});return n.alg="ES256",n}default:throw new nt("algorithmNotSupported",`Algorithm not supported: ${t}`)}}async bytesToPublicKey({algorithm:t,publicKeyBytes:e}){switch(t){case"ES256K":case"secp256k1":{let n=await Dt.bytesToPublicKey({publicKeyBytes:e});return n.alg="ES256K",n}case"ES256":case"secp256r1":{let n=await Mt.bytesToPublicKey({publicKeyBytes:e});return n.alg="ES256",n}default:throw new nt("algorithmNotSupported",`Algorithm not supported: ${t}`)}}async computePublicKey({key:t}){if(!oe(t))throw new TypeError("Invalid key provided. Must be an elliptic curve (EC) private key.");switch(t.crv){case"secp256k1":{let e=await Dt.computePublicKey({key:t});return e.alg="ES256K",e}case"P-256":{let e=await Mt.computePublicKey({key:t});return e.alg="ES256",e}default:throw new Error(`Unsupported curve: ${t.crv}`)}}async generateKey({algorithm:t}){switch(t){case"ES256K":case"secp256k1":{let e=await Dt.generateKey();return e.alg="ES256K",e}case"ES256":case"secp256r1":{let e=await Mt.generateKey();return e.alg="ES256",e}}}async getPublicKey({key:t}){if(!oe(t))throw new TypeError("Invalid key provided. Must be an elliptic curve (EC) private key.");switch(t.crv){case"secp256k1":{let e=await Dt.getPublicKey({key:t});return e.alg="ES256K",e}case"P-256":{let e=await Mt.getPublicKey({key:t});return e.alg="ES256",e}default:throw new Error(`Unsupported curve: ${t.crv}`)}}async sign({key:t,data:e}){if(!oe(t))throw new TypeError("Invalid key provided. Must be an elliptic curve (EC) private key.");switch(t.crv){case"secp256k1":return await Dt.sign({key:t,data:e});case"P-256":return await Mt.sign({key:t,data:e});default:throw new Error(`Unsupported curve: ${t.crv}`)}}async verify({key:t,signature:e,data:n}){if(!Qr(t))throw new TypeError("Invalid key provided. Must be an elliptic curve (EC) public key.");switch(t.crv){case"secp256k1":return await Dt.verify({key:t,signature:e,data:n});case"P-256":return await Mt.verify({key:t,signature:e,data:n});default:throw new Error(`Unsupported curve: ${t.crv}`)}}async privateKeyToBytes({privateKey:t}){switch(t.crv){case"secp256k1":return await Dt.privateKeyToBytes({privateKey:t});case"P-256":return await Mt.privateKeyToBytes({privateKey:t});default:throw new nt("algorithmNotSupported",`Curve not supported: ${t.crv}`)}}async publicKeyToBytes({publicKey:t}){switch(t.crv){case"secp256k1":return await Dt.publicKeyToBytes({publicKey:t});case"P-256":return await Mt.publicKeyToBytes({publicKey:t});default:throw new nt("algorithmNotSupported",`Curve not supported: ${t.crv}`)}}};var Ji=BigInt(4294967295),qs=BigInt(32);function Hu(r,t=!1){return t?{h:Number(r&Ji),l:Number(r>>qs&Ji)}:{h:Number(r>>qs&Ji)|0,l:Number(r&Ji)|0}}function Zy(r,t=!1){let e=new Uint32Array(r.length),n=new Uint32Array(r.length);for(let i=0;i<r.length;i++){let{h:o,l:s}=Hu(r[i],t);[e[i],n[i]]=[o,s]}return[e,n]}var Yy=(r,t)=>BigInt(r>>>0)<<qs|BigInt(t>>>0),Xy=(r,t,e)=>r>>>e,Qy=(r,t,e)=>r<<32-e|t>>>e,tp=(r,t,e)=>r>>>e|t<<32-e,ep=(r,t,e)=>r<<32-e|t>>>e,rp=(r,t,e)=>r<<64-e|t>>>e-32,np=(r,t,e)=>r>>>e-32|t<<64-e,ip=(r,t)=>t,op=(r,t)=>r,sp=(r,t,e)=>r<<e|t>>>32-e,cp=(r,t,e)=>t<<e|r>>>32-e,ap=(r,t,e)=>t<<e-32|r>>>64-e,up=(r,t,e)=>r<<e-32|t>>>64-e;function fp(r,t,e,n){let i=(t>>>0)+(n>>>0);return{h:r+e+(i/2**32|0)|0,l:i|0}}var lp=(r,t,e)=>(r>>>0)+(t>>>0)+(e>>>0),hp=(r,t,e,n)=>t+e+n+(r/2**32|0)|0,yp=(r,t,e,n)=>(r>>>0)+(t>>>0)+(e>>>0)+(n>>>0),pp=(r,t,e,n,i)=>t+e+n+i+(r/2**32|0)|0,dp=(r,t,e,n,i)=>(r>>>0)+(t>>>0)+(e>>>0)+(n>>>0)+(i>>>0),mp=(r,t,e,n,i,o)=>t+e+n+i+o+(r/2**32|0)|0;var wp={fromBig:Hu,split:Zy,toBig:Yy,shrSH:Xy,shrSL:Qy,rotrSH:tp,rotrSL:ep,rotrBH:rp,rotrBL:np,rotr32H:ip,rotr32L:op,rotlSH:sp,rotlSL:cp,rotlBH:ap,rotlBL:up,add:fp,add3L:lp,add3H:hp,add4L:yp,add4H:pp,add5H:mp,add5L:dp},$=wp;var[gp,xp]=$.split(["0x428a2f98d728ae22","0x7137449123ef65cd","0xb5c0fbcfec4d3b2f","0xe9b5dba58189dbbc","0x3956c25bf348b538","0x59f111f1b605d019","0x923f82a4af194f9b","0xab1c5ed5da6d8118","0xd807aa98a3030242","0x12835b0145706fbe","0x243185be4ee4b28c","0x550c7dc3d5ffb4e2","0x72be5d74f27b896f","0x80deb1fe3b1696b1","0x9bdc06a725c71235","0xc19bf174cf692694","0xe49b69c19ef14ad2","0xefbe4786384f25e3","0x0fc19dc68b8cd5b5","0x240ca1cc77ac9c65","0x2de92c6f592b0275","0x4a7484aa6ea6e483","0x5cb0a9dcbd41fbd4","0x76f988da831153b5","0x983e5152ee66dfab","0xa831c66d2db43210","0xb00327c898fb213f","0xbf597fc7beef0ee4","0xc6e00bf33da88fc2","0xd5a79147930aa725","0x06ca6351e003826f","0x142929670a0e6e70","0x27b70a8546d22ffc","0x2e1b21385c26c926","0x4d2c6dfc5ac42aed","0x53380d139d95b3df","0x650a73548baf63de","0x766a0abb3c77b2a8","0x81c2c92e47edaee6","0x92722c851482353b","0xa2bfe8a14cf10364","0xa81a664bbc423001","0xc24b8b70d0f89791","0xc76c51a30654be30","0xd192e819d6ef5218","0xd69906245565a910","0xf40e35855771202a","0x106aa07032bbd1b8","0x19a4c116b8d2d0c8","0x1e376c085141ab53","0x2748774cdf8eeb99","0x34b0bcb5e19b48a8","0x391c0cb3c5c95a63","0x4ed8aa4ae3418acb","0x5b9cca4f7763e373","0x682e6ff3d6b2b8a3","0x748f82ee5defb2fc","0x78a5636f43172f60","0x84c87814a1f0ab72","0x8cc702081a6439ec","0x90befffa23631e28","0xa4506cebde82bde9","0xbef9a3f7b2c67915","0xc67178f2e372532b","0xca273eceea26619c","0xd186b8c721c0c207","0xeada7dd6cde0eb1e","0xf57d4f7fee6ed178","0x06f067aa72176fba","0x0a637dc5a2c898a6","0x113f9804bef90dae","0x1b710b35131c471b","0x28db77f523047d84","0x32caab7b40c72493","0x3c9ebe0a15c9bebc","0x431d67c49c100d4c","0x4cc5d4becb3e42b6","0x597f299cfc657e2a","0x5fcb6fab3ad6faec","0x6c44198c4a475817"].map(r=>BigInt(r))),qe=new Uint32Array(80),Fe=new Uint32Array(80),Fs=class extends $r{constructor(){super(128,64,16,!1),this.Ah=1779033703,this.Al=-205731576,this.Bh=-1150833019,this.Bl=-2067093701,this.Ch=1013904242,this.Cl=-23791573,this.Dh=-1521486534,this.Dl=1595750129,this.Eh=1359893119,this.El=-1377402159,this.Fh=-1694144372,this.Fl=725511199,this.Gh=528734635,this.Gl=-79577749,this.Hh=1541459225,this.Hl=327033209}get(){let{Ah:t,Al:e,Bh:n,Bl:i,Ch:o,Cl:s,Dh:c,Dl:a,Eh:u,El:f,Fh:l,Fl:y,Gh:m,Gl:p,Hh:h,Hl:d}=this;return[t,e,n,i,o,s,c,a,u,f,l,y,m,p,h,d]}set(t,e,n,i,o,s,c,a,u,f,l,y,m,p,h,d){this.Ah=t|0,this.Al=e|0,this.Bh=n|0,this.Bl=i|0,this.Ch=o|0,this.Cl=s|0,this.Dh=c|0,this.Dl=a|0,this.Eh=u|0,this.El=f|0,this.Fh=l|0,this.Fl=y|0,this.Gh=m|0,this.Gl=p|0,this.Hh=h|0,this.Hl=d|0}process(t,e){for(let x=0;x<16;x++,e+=4)qe[x]=t.getUint32(e),Fe[x]=t.getUint32(e+=4);for(let x=16;x<80;x++){let A=qe[x-15]|0,v=Fe[x-15]|0,K=$.rotrSH(A,v,1)^$.rotrSH(A,v,8)^$.shrSH(A,v,7),k=$.rotrSL(A,v,1)^$.rotrSL(A,v,8)^$.shrSL(A,v,7),T=qe[x-2]|0,L=Fe[x-2]|0,O=$.rotrSH(T,L,19)^$.rotrBH(T,L,61)^$.shrSH(T,L,6),C=$.rotrSL(T,L,19)^$.rotrBL(T,L,61)^$.shrSL(T,L,6),j=$.add4L(k,C,Fe[x-7],Fe[x-16]),M=$.add4H(j,K,O,qe[x-7],qe[x-16]);qe[x]=M|0,Fe[x]=j|0}let{Ah:n,Al:i,Bh:o,Bl:s,Ch:c,Cl:a,Dh:u,Dl:f,Eh:l,El:y,Fh:m,Fl:p,Gh:h,Gl:d,Hh:g,Hl:b}=this;for(let x=0;x<80;x++){let A=$.rotrSH(l,y,14)^$.rotrSH(l,y,18)^$.rotrBH(l,y,41),v=$.rotrSL(l,y,14)^$.rotrSL(l,y,18)^$.rotrBL(l,y,41),K=l&m^~l&h,k=y&p^~y&d,T=$.add5L(b,v,k,xp[x],Fe[x]),L=$.add5H(T,g,A,K,gp[x],qe[x]),O=T|0,C=$.rotrSH(n,i,28)^$.rotrBH(n,i,34)^$.rotrBH(n,i,39),j=$.rotrSL(n,i,28)^$.rotrBL(n,i,34)^$.rotrBL(n,i,39),M=n&o^n&c^o&c,z=i&s^i&a^s&a;g=h|0,b=d|0,h=m|0,d=p|0,m=l|0,p=y|0,{h:l,l:y}=$.add(u|0,f|0,L|0,O|0),u=c|0,f=a|0,c=o|0,a=s|0,o=n|0,s=i|0;let B=$.add3L(O,j,z);n=$.add3H(B,L,C,M),i=B|0}({h:n,l:i}=$.add(this.Ah|0,this.Al|0,n|0,i|0)),{h:o,l:s}=$.add(this.Bh|0,this.Bl|0,o|0,s|0),{h:c,l:a}=$.add(this.Ch|0,this.Cl|0,c|0,a|0),{h:u,l:f}=$.add(this.Dh|0,this.Dl|0,u|0,f|0),{h:l,l:y}=$.add(this.Eh|0,this.El|0,l|0,y|0),{h:m,l:p}=$.add(this.Fh|0,this.Fl|0,m|0,p|0),{h,l:d}=$.add(this.Gh|0,this.Gl|0,h|0,d|0),{h:g,l:b}=$.add(this.Hh|0,this.Hl|0,g|0,b|0),this.set(n,i,o,s,c,a,u,f,l,y,m,p,h,d,g,b)}roundClean(){qe.fill(0),Fe.fill(0)}destroy(){this.buffer.fill(0),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}};var $s=_i(()=>new Fs);var Yt=BigInt(0),Ct=BigInt(1),Gi=BigInt(2),bp=BigInt(8),Ep={zip215:!0};function vp(r){let t=Dn(r);return Rt(r,{hash:"function",a:"bigint",d:"bigint",randomBytes:"function"},{adjustScalarBytes:"function",domain:"function",uvRatio:"function",mapToCurve:"function"}),Object.freeze({...t})}function Vi(r){let t=vp(r),{Fp:e,n,prehash:i,hash:o,randomBytes:s,nByteLength:c,h:a}=t,u=Gi<<BigInt(c*8)-Ct,f=e.create,l=t.uvRatio||((P,w)=>{try{return{isValid:!0,value:e.sqrt(P*e.inv(w))}}catch{return{isValid:!1,value:Yt}}}),y=t.adjustScalarBytes||(P=>P),m=t.domain||((P,w,S)=>{if(w.length||S)throw new Error("Contexts/pre-hash are not supported");return P}),p=P=>typeof P=="bigint"&&Yt<P,h=(P,w)=>p(P)&&p(w)&&P<w,d=P=>P===Yt||h(P,u);function g(P,w){if(h(P,w))return P;throw new Error(`Expected valid scalar < ${w}, got ${typeof P} ${P}`)}function b(P){return P===Yt?P:g(P,n)}let x=new Map;function A(P){if(!(P instanceof v))throw new Error("ExtendedPoint expected")}class v{constructor(w,S,I,_){if(this.ex=w,this.ey=S,this.ez=I,this.et=_,!d(w))throw new Error("x required");if(!d(S))throw new Error("y required");if(!d(I))throw new Error("z required");if(!d(_))throw new Error("t required")}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static fromAffine(w){if(w instanceof v)throw new Error("extended point not allowed");let{x:S,y:I}=w||{};if(!d(S)||!d(I))throw new Error("invalid affine point");return new v(S,I,Ct,f(S*I))}static normalizeZ(w){let S=e.invertBatch(w.map(I=>I.ez));return w.map((I,_)=>I.toAffine(S[_])).map(v.fromAffine)}_setWindowSize(w){this._WINDOW_SIZE=w,x.delete(this)}assertValidity(){let{a:w,d:S}=t;if(this.is0())throw new Error("bad point: ZERO");let{ex:I,ey:_,ez:H,et:J}=this,Z=f(I*I),q=f(_*_),F=f(H*H),rt=f(F*F),et=f(Z*w),yt=f(F*f(et+q)),pt=f(rt+f(S*f(Z*q)));if(yt!==pt)throw new Error("bad point: equation left != right (1)");let ft=f(I*_),mt=f(H*J);if(ft!==mt)throw new Error("bad point: equation left != right (2)")}equals(w){A(w);let{ex:S,ey:I,ez:_}=this,{ex:H,ey:J,ez:Z}=w,q=f(S*Z),F=f(H*_),rt=f(I*Z),et=f(J*_);return q===F&&rt===et}is0(){return this.equals(v.ZERO)}negate(){return new v(f(-this.ex),this.ey,this.ez,f(-this.et))}double(){let{a:w}=t,{ex:S,ey:I,ez:_}=this,H=f(S*S),J=f(I*I),Z=f(Gi*f(_*_)),q=f(w*H),F=S+I,rt=f(f(F*F)-H-J),et=q+J,yt=et-Z,pt=q-J,ft=f(rt*yt),mt=f(et*pt),he=f(rt*pt),er=f(yt*et);return new v(ft,mt,er,he)}add(w){A(w);let{a:S,d:I}=t,{ex:_,ey:H,ez:J,et:Z}=this,{ex:q,ey:F,ez:rt,et}=w;if(S===BigInt(-1)){let wc=f((H-_)*(F+q)),gc=f((H+_)*(F-q)),ao=f(gc-wc);if(ao===Yt)return this.double();let xc=f(J*Gi*et),bc=f(Z*Gi*rt),Ec=bc+xc,vc=gc+wc,Ac=bc-xc,jf=f(Ec*ao),Hf=f(vc*Ac),Jf=f(Ec*Ac),Gf=f(ao*vc);return new v(jf,Hf,Gf,Jf)}let yt=f(_*q),pt=f(H*F),ft=f(Z*I*et),mt=f(J*rt),he=f((_+H)*(q+F)-yt-pt),er=mt-ft,on=mt+ft,mc=f(pt-S*yt),Rf=f(he*er),Nf=f(on*mc),Df=f(he*mc),Mf=f(er*on);return new v(Rf,Nf,Mf,Df)}subtract(w){return this.add(w.negate())}wNAF(w){return T.wNAFCached(this,x,w,v.normalizeZ)}multiply(w){let{p:S,f:I}=this.wNAF(g(w,n));return v.normalizeZ([S,I])[0]}multiplyUnsafe(w){let S=b(w);return S===Yt?k:this.equals(k)||S===Ct?this:this.equals(K)?this.wNAF(S).p:T.unsafeLadder(this,S)}isSmallOrder(){return this.multiplyUnsafe(a).is0()}isTorsionFree(){return T.unsafeLadder(this,n).is0()}toAffine(w){let{ex:S,ey:I,ez:_}=this,H=this.is0();w==null&&(w=H?bp:e.inv(_));let J=f(S*w),Z=f(I*w),q=f(_*w);if(H)return{x:Yt,y:Ct};if(q!==Ct)throw new Error("invZ was invalid");return{x:J,y:Z}}clearCofactor(){let{h:w}=t;return w===Ct?this:this.multiplyUnsafe(w)}static fromHex(w,S=!1){let{d:I,a:_}=t,H=e.BYTES;w=it("pointHex",w,H);let J=w.slice(),Z=w[H-1];J[H-1]=Z&-129;let q=Wt(J);q===Yt||(S?g(q,u):g(q,e.ORDER));let F=f(q*q),rt=f(F-Ct),et=f(I*F-_),{isValid:yt,value:pt}=l(rt,et);if(!yt)throw new Error("Point.fromHex: invalid y coordinate");let ft=(pt&Ct)===Ct,mt=(Z&128)!==0;if(!S&&pt===Yt&&mt)throw new Error("Point.fromHex: x=0 and x_0=1");return mt!==ft&&(pt=f(-pt)),v.fromAffine({x:pt,y:q})}static fromPrivateKey(w){return C(w).point}toRawBytes(){let{x:w,y:S}=this.toAffine(),I=Pe(S,e.BYTES);return I[I.length-1]|=w&Ct?128:0,I}toHex(){return Ae(this.toRawBytes())}}v.BASE=new v(t.Gx,t.Gy,Ct,f(t.Gx*t.Gy)),v.ZERO=new v(Yt,Ct,Ct,Yt);let{BASE:K,ZERO:k}=v,T=Ri(v,c*8);function L(P){return tt(P,n)}function O(P){return L(Wt(P))}function C(P){let w=c;P=it("private key",P,w);let S=it("hashed private key",o(P),2*w),I=y(S.slice(0,w)),_=S.slice(w,2*w),H=O(I),J=K.multiply(H),Z=J.toRawBytes();return{head:I,prefix:_,scalar:H,point:J,pointBytes:Z}}function j(P){return C(P).pointBytes}function M(P=new Uint8Array,...w){let S=Ke(...w);return O(o(m(S,it("context",P),!!i)))}function z(P,w,S={}){P=it("message",P),i&&(P=i(P));let{prefix:I,scalar:_,pointBytes:H}=C(w),J=M(S.context,I,P),Z=K.multiply(J).toRawBytes(),q=M(S.context,Z,H,P),F=L(J+q*_);b(F);let rt=Ke(Z,Pe(F,e.BYTES));return it("result",rt,c*2)}let B=Ep;function U(P,w,S,I=B){let{context:_,zip215:H}=I,J=e.BYTES;P=it("signature",P,2*J),w=it("message",w),i&&(w=i(w));let Z=Wt(P.slice(J,2*J)),q,F,rt;try{q=v.fromHex(S,H),F=v.fromHex(P.slice(0,J),H),rt=K.multiplyUnsafe(Z)}catch{return!1}if(!H&&q.isSmallOrder())return!1;let et=M(_,F.toRawBytes(),q.toRawBytes(),w);return F.add(q.multiplyUnsafe(et)).subtract(rt).clearCofactor().equals(v.ZERO)}return K._setWindowSize(8),{CURVE:t,getPublicKey:j,sign:z,verify:U,ExtendedPoint:v,utils:{getExtendedPublicKey:C,randomPrivateKey:()=>s(e.BYTES),precompute(P=8,w=v.BASE){return w._setWindowSize(P),w.multiply(BigInt(3)),w}}}}var Hn=BigInt(0),Ws=BigInt(1);function Ap(r){return Rt(r,{a:"bigint"},{montgomeryBits:"isSafeInteger",nByteLength:"isSafeInteger",adjustScalarBytes:"function",domain:"function",powPminus2:"function",Gu:"bigint"}),Object.freeze({...r})}function Ju(r){let t=Ap(r),{P:e}=t,n=x=>tt(x,e),i=t.montgomeryBits,o=Math.ceil(i/8),s=t.nByteLength,c=t.adjustScalarBytes||(x=>x),a=t.powPminus2||(x=>Ls(x,e-BigInt(2),e));function u(x,A,v){let K=n(x*(A-v));return A=n(A-K),v=n(v+K),[A,v]}function f(x){if(typeof x=="bigint"&&Hn<=x&&x<e)return x;throw new Error("Expected valid scalar 0 < scalar < CURVE.P")}let l=(t.a-BigInt(2))/BigInt(4);function y(x,A){let v=f(x),K=f(A),k=v,T=Ws,L=Hn,O=v,C=Ws,j=Hn,M;for(let B=BigInt(i-1);B>=Hn;B--){let U=K>>B&Ws;j^=U,M=u(j,T,O),T=M[0],O=M[1],M=u(j,L,C),L=M[0],C=M[1],j=U;let R=T+L,P=n(R*R),w=T-L,S=n(w*w),I=P-S,_=O+C,H=O-C,J=n(H*R),Z=n(_*w),q=J+Z,F=J-Z;O=n(q*q),C=n(k*n(F*F)),T=n(P*S),L=n(I*(P+n(l*I)))}M=u(j,T,O),T=M[0],O=M[1],M=u(j,L,C),L=M[0],C=M[1];let z=a(L);return n(T*z)}function m(x){return Pe(n(x),o)}function p(x){let A=it("u coordinate",x,o);return s===32&&(A[31]&=127),Wt(A)}function h(x){let A=it("scalar",x),v=A.length;if(v!==o&&v!==s)throw new Error(`Expected ${o} or ${s} bytes, got ${v}`);return Wt(c(A))}function d(x,A){let v=p(A),K=h(x),k=y(v,K);if(k===Hn)throw new Error("Invalid private or public key received");return m(k)}let g=m(t.Gu);function b(x){return d(x,g)}return{scalarMult:d,scalarMultBase:b,getSharedSecret:(x,A)=>d(x,A),getPublicKey:x=>b(x),utils:{randomPrivateKey:()=>t.randomBytes(t.nByteLength)},GuBytes:g}}var Jn=BigInt("57896044618658097711785492504343953926634992332820282019728792003956564819949"),Gu=BigInt("19681161376707505956807079304988542015446066515923890162744021073123829784752"),_w=BigInt(0),Bp=BigInt(1),zs=BigInt(2),Pp=BigInt(5),Vu=BigInt(10),Kp=BigInt(20),Tp=BigInt(40),qu=BigInt(80);function Fu(r){let t=Jn,n=r*r%t*r%t,i=ot(n,zs,t)*n%t,o=ot(i,Bp,t)*r%t,s=ot(o,Pp,t)*o%t,c=ot(s,Vu,t)*s%t,a=ot(c,Kp,t)*c%t,u=ot(a,Tp,t)*a%t,f=ot(u,qu,t)*u%t,l=ot(f,qu,t)*u%t,y=ot(l,Vu,t)*s%t;return{pow_p_5_8:ot(y,zs,t)*r%t,b2:n}}function $u(r){return r[0]&=248,r[31]&=127,r[31]|=64,r}function Sp(r,t){let e=Jn,n=tt(t*t*t,e),i=tt(n*n*t,e),o=Fu(r*i).pow_p_5_8,s=tt(r*n*o,e),c=tt(t*s*s,e),a=s,u=tt(s*Gu,e),f=c===r,l=c===tt(-r,e),y=c===tt(-r*Gu,e);return f&&(s=a),(l||y)&&(s=u),Bu(s,e)&&(s=tt(-s,e)),{isValid:f||l,value:s}}var jt=Wr(Jn,void 0,!0),Gn={a:BigInt(-1),d:BigInt("37095705934669439343138083508754565189542113879843219016388785533085940283555"),Fp:jt,n:BigInt("7237005577332262213973186563042994240857116359379907606001950938285454250989"),h:BigInt(8),Gx:BigInt("15112221349535400772501151409588531511454012693041857206046113283949847762202"),Gy:BigInt("46316835694926478169428394003475163141307993866256225615783033603165251855960"),hash:$s,randomBytes:Nn,adjustScalarBytes:$u,uvRatio:Sp},$e=Vi(Gn);function Wu(r,t,e){if(t.length>255)throw new Error("Context is too big");return Ci(Is("SigEd25519 no Ed25519 collisions"),new Uint8Array([e?1:0,t.length]),t,r)}var Lw=Vi({...Gn,domain:Wu}),Ow=Vi({...Gn,domain:Wu,prehash:$s}),Pr=Ju({P:Jn,a:BigInt(486662),montgomeryBits:255,nByteLength:32,Gu:BigInt(9),powPminus2:r=>{let t=Jn,{pow_p_5_8:e,b2:n}=Fu(r);return tt(ot(e,BigInt(3),t)*n,t)},adjustScalarBytes:$u,randomBytes:Nn});function zu(r){let{y:t}=$e.ExtendedPoint.fromHex(r),e=BigInt(1);return jt.toBytes(jt.create((e+t)*jt.inv(e-t)))}function Zu(r){let t=Gn.hash(r.subarray(0,32));return Gn.adjustScalarBytes(t).subarray(0,32)}var kp=(jt.ORDER+BigInt(3))/BigInt(8),Rw=jt.pow(zs,kp),Nw=jt.sqrt(jt.neg(jt.ONE)),Dw=(jt.ORDER-BigInt(5))/BigInt(8),Mw=BigInt(486662);var jw=Pu(jt,jt.neg(BigInt(486664)));var Hw=BigInt("25063068953384623474111414158702152701244531502492656460079210482610430750235"),Jw=BigInt("54469307008909316920995813868745141605393597292927456921205312896311721017578"),Gw=BigInt("1159843021668779879193775521855586647937357759715417654439879720876111806838"),Vw=BigInt("40440834346308536858101042469323190826248399146238708352240133220865137265952");var qw=BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff");var Ht=class r{static async bytesToPrivateKey({privateKeyBytes:t}){let e=$e.getPublicKey(t),n={crv:"Ed25519",d:N.uint8Array(t).toBase64Url(),kty:"OKP",x:N.uint8Array(e).toBase64Url()};return n.kid=await G({jwk:n}),n}static async bytesToPublicKey({publicKeyBytes:t}){let e={kty:"OKP",crv:"Ed25519",x:N.uint8Array(t).toBase64Url()};return e.kid=await G({jwk:e}),e}static async computePublicKey({key:t}){let e=await r.privateKeyToBytes({privateKey:t}),n=$e.getPublicKey(e),i={kty:"OKP",crv:"Ed25519",x:N.uint8Array(n).toBase64Url()};return i.kid=await G({jwk:i}),i}static async convertPrivateKeyToX25519({privateKey:t}){let e=await r.privateKeyToBytes({privateKey:t}),n=Zu(e),i=Pr.getPublicKey(n),o={kty:"OKP",crv:"X25519",d:N.uint8Array(n).toBase64Url(),x:N.uint8Array(i).toBase64Url()};return o.kid=await G({jwk:o}),o}static async convertPublicKeyToX25519({publicKey:t}){let e=await r.publicKeyToBytes({publicKey:t});if(!await r.validatePublicKey({publicKeyBytes:e}))throw new Error("Ed25519: Invalid public key.");let i=zu(e),o={kty:"OKP",crv:"X25519",x:N.uint8Array(i).toBase64Url()};return o.kid=await G({jwk:o}),o}static async generateKey(){let t=$e.utils.randomPrivateKey(),e=await r.bytesToPrivateKey({privateKeyBytes:t});return e.kid=await G({jwk:e}),e}static async getPublicKey({key:t}){if(!(Ut(t)&&t.crv==="Ed25519"))throw new Error("Ed25519: The provided key is not an Ed25519 private JWK.");let{d:e,...n}=t;return n.kid??=await G({jwk:n}),n}static async privateKeyToBytes({privateKey:t}){if(!Ut(t))throw new Error("Ed25519: The provided key is not a valid OKP private key.");return N.base64Url(t.d).toUint8Array()}static async publicKeyToBytes({publicKey:t}){if(!tn(t))throw new Error("Ed25519: The provided key is not a valid OKP public key.");return N.base64Url(t.x).toUint8Array()}static async sign({key:t,data:e}){let n=await r.privateKeyToBytes({privateKey:t});return $e.sign(e,n)}static async validatePublicKey({publicKeyBytes:t}){try{$e.ExtendedPoint.fromHex(t).assertValidity()}catch{return!1}return!0}static async verify({key:t,signature:e,data:n}){let i=await r.publicKeyToBytes({publicKey:t});return $e.verify(e,n,i)}};var qi=class extends ut{async bytesToPrivateKey({algorithm:t,privateKeyBytes:e}){switch(t){case"Ed25519":{let n=await Ht.bytesToPrivateKey({privateKeyBytes:e});return n.alg="EdDSA",n}default:throw new nt("algorithmNotSupported",`Algorithm not supported: ${t}`)}}async bytesToPublicKey({algorithm:t,publicKeyBytes:e}){switch(t){case"Ed25519":{let n=await Ht.bytesToPublicKey({publicKeyBytes:e});return n.alg="EdDSA",n}default:throw new nt("algorithmNotSupported",`Algorithm not supported: ${t}`)}}async computePublicKey({key:t}){if(!Ut(t))throw new TypeError("Invalid key provided. Must be an octet key pair (OKP) private key.");switch(t.crv){case"Ed25519":{let e=await Ht.computePublicKey({key:t});return e.alg="EdDSA",e}default:throw new Error(`Unsupported curve: ${t.crv}`)}}async generateKey({algorithm:t}){switch(t){case"Ed25519":{let e=await Ht.generateKey();return e.alg="EdDSA",e}}}async getPublicKey({key:t}){if(!Ut(t))throw new TypeError("Invalid key provided. Must be an octet key pair (OKP) private key.");switch(t.crv){case"Ed25519":{let e=await Ht.getPublicKey({key:t});return e.alg="EdDSA",e}default:throw new Error(`Unsupported curve: ${t.crv}`)}}async sign({key:t,data:e}){if(!Ut(t))throw new TypeError("Invalid key provided. Must be an octet key pair (OKP) private key.");switch(t.crv){case"Ed25519":return await Ht.sign({key:t,data:e});default:throw new Error(`Unsupported curve: ${t.crv}`)}}async verify({key:t,signature:e,data:n}){if(!tn(t))throw new TypeError("Invalid key provided. Must be an octet key pair (OKP) public key.");switch(t.crv){case"Ed25519":return await Ht.verify({key:t,signature:e,data:n});default:throw new Error(`Unsupported curve: ${t.crv}`)}}async privateKeyToBytes({privateKey:t}){switch(t.crv){case"Ed25519":return await Ht.privateKeyToBytes({privateKey:t});default:throw new nt("algorithmNotSupported",`Curve not supported: ${t.crv}`)}}async publicKeyToBytes({publicKey:t}){switch(t.crv){case"Ed25519":return await Ht.publicKeyToBytes({publicKey:t});default:throw new nt("algorithmNotSupported",`Curve not supported: ${t.crv}`)}}};var Fi=class extends ut{async digest({algorithm:t,data:e}){switch(t){case"SHA-256":return await Xr.digest({data:e})}}};var We=class r{static async bytesToPrivateKey({privateKeyBytes:t}){let e=Pr.getPublicKey(t),n={kty:"OKP",crv:"X25519",d:N.uint8Array(t).toBase64Url(),x:N.uint8Array(e).toBase64Url()};return n.kid=await G({jwk:n}),n}static async bytesToPublicKey({publicKeyBytes:t}){let e={kty:"OKP",crv:"X25519",x:N.uint8Array(t).toBase64Url()};return e.kid=await G({jwk:e}),e}static async computePublicKey({key:t}){let e=await r.privateKeyToBytes({privateKey:t}),n=Pr.getPublicKey(e),i={kty:"OKP",crv:"X25519",x:N.uint8Array(n).toBase64Url()};return i.kid=await G({jwk:i}),i}static async generateKey(){let t=Pr.utils.randomPrivateKey(),e=await r.bytesToPrivateKey({privateKeyBytes:t});return e.kid=await G({jwk:e}),e}static async getPublicKey({key:t}){if(!(Ut(t)&&t.crv==="X25519"))throw new Error("X25519: The provided key is not an X25519 private JWK.");let{d:e,...n}=t;return n.kid??=await G({jwk:n}),n}static async privateKeyToBytes({privateKey:t}){if(!Ut(t))throw new Error("X25519: The provided key is not a valid OKP private key.");return N.base64Url(t.d).toUint8Array()}static async publicKeyToBytes({publicKey:t}){if(!tn(t))throw new Error("X25519: The provided key is not a valid OKP public key.");return N.base64Url(t.x).toUint8Array()}static async sharedSecret({privateKeyA:t,publicKeyB:e}){if("x"in t&&"x"in e&&t.x===e.x)throw new Error("X25519: ECDH shared secret cannot be computed from a single key pair's public and private keys.");let n=await r.privateKeyToBytes({privateKey:t}),i=await r.publicKeyToBytes({publicKey:e});return Pr.getSharedSecret(n,i)}};var $i=class extends ut{async bytesToPrivateKey({algorithm:t,privateKeyBytes:e}){switch(t){case"X25519":return We.bytesToPrivateKey({privateKeyBytes:e});default:throw new nt("algorithmNotSupported",`Algorithm not supported: ${t}`)}}async computePublicKey({key:t}){if(!Ut(t))throw new TypeError("Invalid key provided. Must be an octet key pair (OKP) private key.");switch(t.crv){case"X25519":return We.computePublicKey({key:t});default:throw new nt("algorithmNotSupported",`Unsupported curve: ${t.crv}`)}}async generateKey({algorithm:t}){switch(t){case"X25519":return We.generateKey();default:throw new nt("algorithmNotSupported",`Algorithm not supported: ${t}`)}}async getPublicKey({key:t}){if(!Ut(t))throw new TypeError("Invalid key provided. Must be an octet key pair (OKP) private key.");switch(t.crv){case"X25519":return We.getPublicKey({key:t});default:throw new nt("algorithmNotSupported",`Unsupported curve: ${t.crv}`)}}async privateKeyToBytes({privateKey:t}){return We.privateKeyToBytes({privateKey:t})}};var Zs={Ed25519:{implementation:qi,names:["Ed25519"]},secp256k1:{implementation:jn,names:["ES256K","secp256k1"]},secp256r1:{implementation:jn,names:["ES256","secp256r1"]},"SHA-256":{implementation:Fi,names:["SHA-256"]},X25519:{implementation:$i,names:["X25519"]}},Yu=class{constructor(t){this._algorithmInstances=new Map;this._keyStore=t?.keyStore??new Ti}async digest({algorithm:t,data:e}){return await this.getAlgorithm({algorithm:t}).digest({algorithm:t,data:e})}async exportKey({keyUri:t}){return await this.getPrivateKey({keyUri:t})}async generateKey({algorithm:t}){let n=await this.getAlgorithm({algorithm:t}).generateKey({algorithm:t});if(n?.kid===void 0)throw new Error("Generated key is missing a required property: kid");let i=`${Vs}${n.kid}`;return await this._keyStore.set(i,n),i}async getKeyUri({key:t}){let e=await G({jwk:t});return`${Vs}${e}`}async getPublicKey({keyUri:t}){let e=await this.getPrivateKey({keyUri:t}),n=this.getAlgorithmName({key:e});return await this.getAlgorithm({algorithm:n}).getPublicKey({key:e})}async importKey({key:t}){if(!Mu(t))throw new TypeError("Invalid key provided. Must be a private key in JWK format.");let e=structuredClone(t);e.kid??=await G({jwk:e});let n=await this.getKeyUri({key:e});return await this._keyStore.set(n,e),n}async sign({keyUri:t,data:e}){let n=await this.getPrivateKey({keyUri:t}),i=this.getAlgorithmName({key:n});return this.getAlgorithm({algorithm:i}).sign({data:e,key:n})}async verify({key:t,signature:e,data:n}){let i=this.getAlgorithmName({key:t});return this.getAlgorithm({algorithm:i}).verify({key:t,signature:e,data:n})}getAlgorithm({algorithm:t}){let e=Zs[t]?.implementation;if(!e)throw new Error(`Algorithm not supported: ${t}`);return this._algorithmInstances.has(e)||this._algorithmInstances.set(e,new e),this._algorithmInstances.get(e)}getAlgorithmName({key:t}){let e=t.alg,n=t.crv;for(let i in Zs){let o=Zs[i];if(e&&o.names.includes(e))return i;if(n&&o.names.includes(n))return i}throw new Error(`Unable to determine algorithm based on provided input: alg=${e}, crv=${n}`)}async getPrivateKey({keyUri:t}){let e=await this._keyStore.get(t);if(!e)throw new Error(`Key not found: ${t}`);return e}};var Xu=class r{static getJoseSignatureAlgorithmFromPublicKey(t){let e={Ed25519:"EdDSA","P-256":"ES256","P-384":"ES384","P-521":"ES512",secp256k1:"ES256K"};if(t.alg&&Object.values(e).includes(t.alg))return t.alg;if(t.crv&&Object.keys(e).includes(t.crv))return e[t.crv];throw new Error(`Unable to determine algorithm based on provided input: alg=${t.alg}, crv=${t.crv}. Supported 'alg' values: ${Object.values(e).join(", ")}. Supported 'crv' values: ${Object.keys(e).join(", ")}.`)}static randomBytes(t){return Ou(t)}static randomUuid(){return Se.randomUUID()}static randomPin({length:t}){if(3>t||t>10)throw new Error("randomPin() can securely generate a PIN between 3 to 10 digits.");let e=Math.pow(10,t)-1,n;if(t<=6){let i=Math.pow(10,t);do{let o=r.randomBytes(Math.ceil(t/2));n=new DataView(o.buffer).getUint16(0,!1)%i}while(n>e)}else{let i=Math.pow(10,10);do{let o=r.randomBytes(4);n=new DataView(o.buffer).getUint32(0,!1)%i}while(n>e)}return n.toString().padStart(t,"0")}};function Ag(r){return r!==null&&typeof r=="object"&&"encrypt"in r&&typeof r.encrypt=="function"&&"decrypt"in r&&typeof r.decrypt=="function"}function Bg(r){return r!==null&&typeof r=="object"&&"exportKey"in r&&typeof r.exportKey=="function"}function Pg(r){return r!==null&&typeof r=="object"&&"importKey"in r&&typeof r.importKey=="function"}function Kg(r){return r!==null&&typeof r=="object"&&"wrapKey"in r&&typeof r.wrapKey=="function"&&"unwrapKey"in r&&typeof r.unwrapKey=="function"}var Kr=typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0;function Ys(r=32){if(Kr&&typeof Kr.getRandomValues=="function")return Kr.getRandomValues(new Uint8Array(r));throw new Error("crypto.getRandomValues must be defined")}function ct(){if(Kr&&typeof Kr.subtle=="object"&&Kr.subtle!=null)return Kr.subtle;throw new Error("crypto.subtle must be defined")}var Vn=128,Qu=[128,192,256],Wi=Vn,en=class{static async bytesToPrivateKey({privateKeyBytes:t}){let e={k:N.uint8Array(t).toBase64Url(),kty:"oct"};return e.kid=await G({jwk:e}),e}static async decrypt({key:t,data:e,counter:n,length:i}){if(n.byteLength!==Vn/8)throw new TypeError(`The counter must be ${Vn} bits in length`);if(i===0||i>Wi)throw new TypeError(`The 'length' property must be in the range 1 to ${Wi}`);let o=ct(),s=await o.importKey("jwk",t,{name:"AES-CTR"},!0,["decrypt"]),c=await o.decrypt({name:"AES-CTR",counter:n,length:i},s,e);return new Uint8Array(c)}static async encrypt({key:t,data:e,counter:n,length:i}){if(n.byteLength!==Vn/8)throw new TypeError(`The counter must be ${Vn} bits in length`);if(i===0||i>Wi)throw new TypeError(`The 'length' property must be in the range 1 to ${Wi}`);let o=ct(),s=await o.importKey("jwk",t,{name:"AES-CTR"},!0,["encrypt","decrypt"]),c=await o.encrypt({name:"AES-CTR",counter:n,length:i},s,e);return new Uint8Array(c)}static async generateKey({length:t}){if(!Qu.includes(t))throw new RangeError(`The key length is invalid: Must be ${Qu.join(", ")} bits`);let e=ct(),n=await e.generateKey({name:"AES-CTR",length:t},!0,["encrypt"]),{ext:i,key_ops:o,...s}=await e.exportKey("jwk",n);return s.kid=await G({jwk:s}),s}static async privateKeyToBytes({privateKey:t}){if(!se(t))throw new Error("AesCtr: The provided key is not a valid oct private key.");return N.base64Url(t.k).toUint8Array()}};var tf=class extends ut{async decrypt(t){return en.decrypt(t)}async encrypt(t){return en.encrypt(t)}async generateKey({algorithm:t}){let e={A128CTR:128,A192CTR:192,A256CTR:256}[t],n=await en.generateKey({length:e});return n.alg=t,n}};function qn(r){if(!Number.isSafeInteger(r)||r<0)throw new Error(`positive integer expected, not ${r}`)}function Xs(r){if(typeof r!="boolean")throw new Error(`boolean expected, not ${r}`)}function Qs(r){return r instanceof Uint8Array||r!=null&&typeof r=="object"&&r.constructor.name==="Uint8Array"}function V(r,...t){if(!Qs(r))throw new Error("Uint8Array expected");if(t.length>0&&!t.includes(r.length))throw new Error(`Uint8Array expected of length ${t}, not of length=${r.length}`)}function ze(r,t=!0){if(r.destroyed)throw new Error("Hash instance has been destroyed");if(t&&r.finished)throw new Error("Hash#digest() has already been called")}function Fn(r,t){V(r);let e=t.outputLen;if(r.length<e)throw new Error(`digestInto() expects output buffer of length at least ${e}`)}var zi=r=>new Uint8Array(r.buffer,r.byteOffset,r.byteLength);var Y=r=>new Uint32Array(r.buffer,r.byteOffset,Math.floor(r.byteLength/4)),Ze=r=>new DataView(r.buffer,r.byteOffset,r.byteLength),Up=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;if(!Up)throw new Error("Non little-endian hardware is not supported");function Ip(r){if(typeof r!="string")throw new Error(`string expected, got ${typeof r}`);return new Uint8Array(new TextEncoder().encode(r))}function ce(r){if(typeof r=="string")r=Ip(r);else if(Qs(r))r=r.slice();else throw new Error(`Uint8Array expected, got ${typeof r}`);return r}function Zi(...r){let t=0;for(let n=0;n<r.length;n++){let i=r[n];V(i),t+=i.length}let e=new Uint8Array(t);for(let n=0,i=0;n<r.length;n++){let o=r[n];e.set(o,i),i+=o.length}return e}function ef(r,t){if(t==null||typeof t!="object")throw new Error("options must be defined");return Object.assign(r,t)}function $n(r,t){if(r.length!==t.length)return!1;let e=0;for(let n=0;n<r.length;n++)e|=r[n]^t[n];return e===0}var ae=(r,t)=>(Object.assign(t,r),t);function Tr(r,t,e,n){if(typeof r.setBigUint64=="function")return r.setBigUint64(t,e,n);let i=BigInt(32),o=BigInt(4294967295),s=Number(e>>i&o),c=Number(e&o),a=n?4:0,u=n?0:4;r.setUint32(t+a,s,n),r.setUint32(t+u,c,n)}var rf={async encrypt(r,t,e,n){let i=ct(),o=await i.importKey("raw",r,t,!0,["encrypt"]),s=await i.encrypt(e,o,n);return new Uint8Array(s)},async decrypt(r,t,e,n){let i=ct(),o=await i.importKey("raw",r,t,!0,["decrypt"]),s=await i.decrypt(e,o,n);return new Uint8Array(s)}},ue={CBC:"AES-CBC",CTR:"AES-CTR",GCM:"AES-GCM"};function Cp(r,t,e){if(r===ue.CBC)return{name:ue.CBC,iv:t};if(r===ue.CTR)return{name:ue.CTR,counter:t,length:64};if(r===ue.GCM)return e?{name:ue.GCM,iv:t,additionalData:e}:{name:ue.GCM,iv:t};throw new Error("unknown aes block mode")}function tc(r){return(t,e,n)=>{V(t),V(e);let i={name:r,length:t.length*8},o=Cp(r,e,n);return{encrypt(s){return V(s),rf.encrypt(t,i,o,s)},decrypt(s){return V(s),rf.decrypt(t,i,o,s)}}}}var Hg=tc(ue.CBC),Jg=tc(ue.CTR),Gg=tc(ue.GCM);var Yi=96,nf=[128,192,256],Xi=[96,104,112,120,128],Ye=class{static async bytesToPrivateKey({privateKeyBytes:t}){let e={k:N.uint8Array(t).toBase64Url(),kty:"oct"};return e.kid=await G({jwk:e}),e}static async decrypt({key:t,data:e,iv:n,additionalData:i,tagLength:o}){if(n.byteLength!==Yi/8)throw new TypeError(`The initialization vector must be ${Yi} bits in length`);if(o&&!Xi.includes(o))throw new RangeError(`The tag length is invalid: Must be ${Xi.join(", ")} bits`);let s=ct(),c=await s.importKey("jwk",t,{name:"AES-GCM"},!0,["decrypt"]),a={name:"AES-GCM",iv:n,...o&&{tagLength:o},...i&&{additionalData:i}},u=await s.decrypt(a,c,e);return new Uint8Array(u)}static async encrypt({data:t,iv:e,key:n,additionalData:i,tagLength:o}){if(e.byteLength!==Yi/8)throw new TypeError(`The initialization vector must be ${Yi} bits in length`);if(o&&!Xi.includes(o))throw new RangeError(`The tag length is invalid: Must be ${Xi.join(", ")} bits`);let s=ct(),c=await s.importKey("jwk",n,{name:"AES-GCM"},!0,["encrypt"]),a={name:"AES-GCM",iv:e,...o&&{tagLength:o},...i&&{additionalData:i}},u=await s.encrypt(a,c,t);return new Uint8Array(u)}static async generateKey({length:t}){if(!nf.includes(t))throw new RangeError(`The key length is invalid: Must be ${nf.join(", ")} bits`);let e=ct(),n=await e.generateKey({name:"AES-GCM",length:t},!0,["encrypt"]),{ext:i,key_ops:o,...s}=await e.exportKey("jwk",n);return s.kid=await G({jwk:s}),s}static async privateKeyToBytes({privateKey:t}){if(!se(t))throw new Error("AesGcm: The provided key is not a valid oct private key.");return N.base64Url(t.k).toUint8Array()}};var of=class extends ut{async bytesToPrivateKey({privateKeyBytes:t}){let e=await Ye.bytesToPrivateKey({privateKeyBytes:t});return e.alg={16:"A128GCM",24:"A192GCM",32:"A256GCM"}[t.length],e}async decrypt(t){return Ye.decrypt(t)}async encrypt(t){return Ye.encrypt(t)}async generateKey({algorithm:t}){let e={A128GCM:128,A192GCM:192,A256GCM:256}[t],n=await Ye.generateKey({length:e});return n.alg=t,n}async privateKeyToBytes({privateKey:t}){return await Ye.privateKeyToBytes({privateKey:t})}};var sf=[128,192,256],Xe=class{static async bytesToPrivateKey({privateKeyBytes:t}){let e={k:N.uint8Array(t).toBase64Url(),kty:"oct"};e.kid=await G({jwk:e});let n=t.length*8;return e.alg={128:"A128KW",192:"A192KW",256:"A256KW"}[n],e}static async generateKey({length:t}){if(!sf.includes(t))throw new RangeError(`The key length is invalid: Must be ${sf.join(", ")} bits`);let e=ct(),n=await e.generateKey({name:"AES-KW",length:t},!0,["wrapKey","unwrapKey"]),{ext:i,key_ops:o,...s}=await e.exportKey("jwk",n);return s.kid=await G({jwk:s}),s}static async privateKeyToBytes({privateKey:t}){if(!se(t))throw new Error("AesKw: The provided key is not a valid oct private key.");return N.base64Url(t.k).toUint8Array()}static async unwrapKey({wrappedKeyBytes:t,wrappedKeyAlgorithm:e,decryptionKey:n}){if(!("alg"in n&&n.alg))throw new nt("invalidJwk","The decryption key is missing the 'alg' property.");if(!["A128KW","A192KW","A256KW"].includes(n.alg))throw new nt("algorithmNotSupported",`The 'decryptionKey' algorithm is not supported: ${n.alg}`);let i=ct(),o=await i.importKey("jwk",n,{name:"AES-KW"},!0,["unwrapKey"]),s={A128KW:"AES-KW",A192KW:"AES-KW",A256KW:"AES-KW",A128GCM:"AES-GCM",A192GCM:"AES-GCM",A256GCM:"AES-GCM"}[e];if(!s)throw new nt("algorithmNotSupported",`The 'wrappedKeyAlgorithm' is not supported: ${e}`);let c=await i.unwrapKey("raw",t.buffer,o,"AES-KW",{name:s},!0,["unwrapKey"]),{ext:a,key_ops:u,...f}=await i.exportKey("jwk",c),l=f;return l.kid=await G({jwk:l}),l}static async wrapKey({unwrappedKey:t,encryptionKey:e}){if(!("alg"in e&&e.alg))throw new nt("invalidJwk","The encryption key is missing the 'alg' property.");if(!["A128KW","A192KW","A256KW"].includes(e.alg))throw new nt("algorithmNotSupported",`The 'encryptionKey' algorithm is not supported: ${e.alg}`);if(!("alg"in t&&t.alg))throw new nt("invalidJwk","The private key to wrap is missing the 'alg' property.");let n=ct(),i=await n.importKey("jwk",e,{name:"AES-KW"},!0,["wrapKey"]),o={A128KW:"AES-KW",A192KW:"AES-KW",A256KW:"AES-KW",A128GCM:"AES-GCM",A192GCM:"AES-GCM",A256GCM:"AES-GCM"}[t.alg];if(!o)throw new nt("algorithmNotSupported",`The 'unwrappedKey' algorithm is not supported: ${t.alg}`);let s=await n.importKey("jwk",t,{name:o},!0,["unwrapKey"]),c=await n.wrapKey("raw",s,i,"AES-KW");return new Uint8Array(c)}};var cf=class extends ut{async bytesToPrivateKey({privateKeyBytes:t}){let e=await Xe.bytesToPrivateKey({privateKeyBytes:t});return e.alg={16:"A128KW",24:"A192KW",32:"A256KW"}[t.length],e}async generateKey({algorithm:t}){let e={A128KW:128,A192KW:192,A256KW:256}[t],n=await Xe.generateKey({length:e});return n.alg=t,n}async privateKeyToBytes({privateKey:t}){return await Xe.privateKeyToBytes({privateKey:t})}async unwrapKey(t){return await Xe.unwrapKey(t)}async wrapKey(t){return Xe.wrapKey(t)}};var Qi=class{static async deriveKeyBytes({baseKeyBytes:t,length:e,hash:n,salt:i,info:o=new Uint8Array}){let s=ct(),c=await s.importKey("raw",t,{name:"HKDF"},!1,["deriveBits"]),a=typeof i=="string"?N.string(i).toUint8Array():i,u=typeof o=="string"?N.string(o).toUint8Array():o,f=await s.deriveBits({name:"HKDF",hash:n,salt:a,info:u},c,e);return new Uint8Array(f)}};var af=class extends ut{async deriveKeyBytes({algorithm:t,...e}){let n={"HKDF-256":"SHA-256","HKDF-384":"SHA-384","HKDF-512":"SHA-512"}[t];return await Qi.deriveKeyBytes({...e,hash:n})}};var to=class{static async deriveKey({hash:t,password:e,salt:n,iterations:i,length:o}){let s=await Se.subtle.importKey("raw",e,{name:"PBKDF2"},!1,["deriveBits"]),c=await Se.subtle.deriveBits({name:"PBKDF2",hash:t,salt:n,iterations:i},s,o);return new Uint8Array(c)}static async deriveKeyBytes({baseKeyBytes:t,hash:e,salt:n,iterations:i,length:o}){let s=ct(),c=await s.importKey("raw",t,{name:"PBKDF2"},!1,["deriveBits"]),a=await s.deriveBits({name:"PBKDF2",hash:e,salt:n,iterations:i},c,o);return new Uint8Array(a)}};var uf=class extends ut{async deriveKeyBytes({algorithm:t,...e}){let[,n]=t.split(/[-+]/),i={HS256:"SHA-256",HS384:"SHA-384",HS512:"SHA-512"}[n];return await to.deriveKeyBytes({...e,hash:i})}};var ff=class r{static async deriveKey({keyDataLen:t,fixedInfo:e,sharedSecret:n}){let o=Math.ceil(t/256);if(o!==1)throw new Error(`Concat KDF with ${o} rounds not supported.`);let s=new Uint8Array(4);new DataView(s.buffer).setUint32(0,o);let c=r.computeFixedInfo(e);return kt(Js(s,n,c)).slice(0,t/8)}static computeFixedInfo(t){let e=r.toDataLenData({data:t.algorithmId}),n=r.toDataLenData({data:t.partyUInfo}),i=r.toDataLenData({data:t.partyVInfo}),o=r.toDataLenData({data:t.suppPubInfo,variableLength:!1}),s=r.toDataLenData({data:t.suppPrivInfo});return Js(e,n,i,o,s)}static toDataLenData({data:t,variableLength:e=!0}){let n,i=an(t);if(i==="Undefined")return new Uint8Array(0);if(e){let o=i==="Uint8Array"?t:new N(t,i).toUint8Array(),s=o.length;n=new Uint8Array(4+s),new DataView(n.buffer).setUint32(0,s),n.set(o,4)}else{if(typeof t!="number")throw TypeError("Fixed length input must be a number.");n=new Uint8Array(4),new DataView(n.buffer).setUint32(0,t)}return n}};var ke=16,rc=new Uint8Array(16),fe=Y(rc),_p=225,Lp=(r,t,e,n)=>{let i=n&1;return{s3:e<<31|n>>>1,s2:t<<31|e>>>1,s1:r<<31|t>>>1,s0:r>>>1^_p<<24&-(i&1)}},Jt=r=>(r>>>0&255)<<24|(r>>>8&255)<<16|(r>>>16&255)<<8|r>>>24&255|0;function Op(r){r.reverse();let t=r[15]&1,e=0;for(let n=0;n<r.length;n++){let i=r[n];r[n]=i>>>1|e,e=(i&1)<<7}return r[0]^=-t&225,r}var Rp=r=>r>64*1024?8:r>1024?4:2,eo=class{constructor(t,e){this.blockLen=ke,this.outputLen=ke,this.s0=0,this.s1=0,this.s2=0,this.s3=0,this.finished=!1,t=ce(t),V(t,16);let n=Ze(t),i=n.getUint32(0,!1),o=n.getUint32(4,!1),s=n.getUint32(8,!1),c=n.getUint32(12,!1),a=[];for(let p=0;p<128;p++)a.push({s0:Jt(i),s1:Jt(o),s2:Jt(s),s3:Jt(c)}),{s0:i,s1:o,s2:s,s3:c}=Lp(i,o,s,c);let u=Rp(e||1024);if(![1,2,4,8].includes(u))throw new Error(`ghash: wrong window size=${u}, should be 2, 4 or 8`);this.W=u;let l=128/u,y=this.windowSize=2**u,m=[];for(let p=0;p<l;p++)for(let h=0;h<y;h++){let d=0,g=0,b=0,x=0;for(let A=0;A<u;A++){if(!(h>>>u-A-1&1))continue;let{s0:K,s1:k,s2:T,s3:L}=a[u*p+A];d^=K,g^=k,b^=T,x^=L}m.push({s0:d,s1:g,s2:b,s3:x})}this.t=m}_updateBlock(t,e,n,i){t^=this.s0,e^=this.s1,n^=this.s2,i^=this.s3;let{W:o,t:s,windowSize:c}=this,a=0,u=0,f=0,l=0,y=(1<<o)-1,m=0;for(let p of[t,e,n,i])for(let h=0;h<4;h++){let d=p>>>8*h&255;for(let g=8/o-1;g>=0;g--){let b=d>>>o*g&y,{s0:x,s1:A,s2:v,s3:K}=s[m*c+b];a^=x,u^=A,f^=v,l^=K,m+=1}}this.s0=a,this.s1=u,this.s2=f,this.s3=l}update(t){t=ce(t),ze(this);let e=Y(t),n=Math.floor(t.length/ke),i=t.length%ke;for(let o=0;o<n;o++)this._updateBlock(e[o*4+0],e[o*4+1],e[o*4+2],e[o*4+3]);return i&&(rc.set(t.subarray(n*ke)),this._updateBlock(fe[0],fe[1],fe[2],fe[3]),fe.fill(0)),this}destroy(){let{t}=this;for(let e of t)e.s0=0,e.s1=0,e.s2=0,e.s3=0}digestInto(t){ze(this),Fn(t,this),this.finished=!0;let{s0:e,s1:n,s2:i,s3:o}=this,s=Y(t);return s[0]=e,s[1]=n,s[2]=i,s[3]=o,t}digest(){let t=new Uint8Array(ke);return this.digestInto(t),this.destroy(),t}},ec=class extends eo{constructor(t,e){t=ce(t);let n=Op(t.slice());super(n,e),n.fill(0)}update(t){t=ce(t),ze(this);let e=Y(t),n=t.length%ke,i=Math.floor(t.length/ke);for(let o=0;o<i;o++)this._updateBlock(Jt(e[o*4+3]),Jt(e[o*4+2]),Jt(e[o*4+1]),Jt(e[o*4+0]));return n&&(rc.set(t.subarray(i*ke)),this._updateBlock(Jt(fe[3]),Jt(fe[2]),Jt(fe[1]),Jt(fe[0])),fe.fill(0)),this}digestInto(t){ze(this),Fn(t,this),this.finished=!0;let{s0:e,s1:n,s2:i,s3:o}=this,s=Y(t);return s[0]=e,s[1]=n,s[2]=i,s[3]=o,t.reverse()}};function lf(r){let t=(n,i)=>r(i,n.length).update(ce(n)).digest(),e=r(new Uint8Array(16),0);return t.outputLen=e.outputLen,t.blockLen=e.blockLen,t.create=(n,i)=>r(n,i),t}var nc=lf((r,t)=>new eo(r,t)),hf=lf((r,t)=>new ec(r,t));var Et=16,sc=4,ro=new Uint8Array(Et),Np=283;function cc(r){return r<<1^Np&-(r>>7)}function rn(r,t){let e=0;for(;t>0;t>>=1)e^=r&-(t&1),r=cc(r);return e}var oc=(()=>{let r=new Uint8Array(256);for(let e=0,n=1;e<256;e++,n^=cc(n))r[e]=n;let t=new Uint8Array(256);t[0]=99;for(let e=0;e<255;e++){let n=r[255-e];n|=n<<8,t[r[e]]=(n^n>>4^n>>5^n>>6^n>>7^99)&255}return t})(),Dp=oc.map((r,t)=>oc.indexOf(t)),Mp=r=>r<<24|r>>>8,ic=r=>r<<8|r>>>24;function yf(r,t){if(r.length!==256)throw new Error("Wrong sbox length");let e=new Uint32Array(256).map((u,f)=>t(r[f])),n=e.map(ic),i=n.map(ic),o=i.map(ic),s=new Uint32Array(256*256),c=new Uint32Array(256*256),a=new Uint16Array(256*256);for(let u=0;u<256;u++)for(let f=0;f<256;f++){let l=u*256+f;s[l]=e[u]^n[f],c[l]=i[u]^o[f],a[l]=r[u]<<8|r[f]}return{sbox:r,sbox2:a,T0:e,T1:n,T2:i,T3:o,T01:s,T23:c}}var ac=yf(oc,r=>rn(r,3)<<24|r<<16|r<<8|rn(r,2)),pf=yf(Dp,r=>rn(r,11)<<24|rn(r,13)<<16|rn(r,9)<<8|rn(r,14)),jp=(()=>{let r=new Uint8Array(16);for(let t=0,e=1;t<16;t++,e=cc(e))r[t]=e;return r})();function tr(r){V(r);let t=r.length;if(![16,24,32].includes(t))throw new Error(`aes: wrong key size: should be 16, 24 or 32, got: ${t}`);let{sbox2:e}=ac,n=Y(r),i=n.length,o=c=>le(e,c,c,c,c),s=new Uint32Array(t+28);s.set(n);for(let c=i;c<s.length;c++){let a=s[c-1];c%i===0?a=o(Mp(a))^jp[c/i-1]:i>6&&c%i===4&&(a=o(a)),s[c]=s[c-i]^a}return s}function df(r){let t=tr(r),e=t.slice(),n=t.length,{sbox2:i}=ac,{T0:o,T1:s,T2:c,T3:a}=pf;for(let u=0;u<n;u+=4)for(let f=0;f<4;f++)e[u+f]=t[n-u-4+f];t.fill(0);for(let u=4;u<n-4;u++){let f=e[u],l=le(i,f,f,f,f);e[u]=o[l&255]^s[l>>>8&255]^c[l>>>16&255]^a[l>>>24]}return e}function Qe(r,t,e,n,i,o){return r[e<<8&65280|n>>>8&255]^t[i>>>8&65280|o>>>24&255]}function le(r,t,e,n,i){return r[t&255|e&65280]|r[n>>>16&255|i>>>16&65280]<<16}function Gt(r,t,e,n,i){let{sbox2:o,T01:s,T23:c}=ac,a=0;t^=r[a++],e^=r[a++],n^=r[a++],i^=r[a++];let u=r.length/4-2;for(let p=0;p<u;p++){let h=r[a++]^Qe(s,c,t,e,n,i),d=r[a++]^Qe(s,c,e,n,i,t),g=r[a++]^Qe(s,c,n,i,t,e),b=r[a++]^Qe(s,c,i,t,e,n);t=h,e=d,n=g,i=b}let f=r[a++]^le(o,t,e,n,i),l=r[a++]^le(o,e,n,i,t),y=r[a++]^le(o,n,i,t,e),m=r[a++]^le(o,i,t,e,n);return{s0:f,s1:l,s2:y,s3:m}}function mf(r,t,e,n,i){let{sbox2:o,T01:s,T23:c}=pf,a=0;t^=r[a++],e^=r[a++],n^=r[a++],i^=r[a++];let u=r.length/4-2;for(let p=0;p<u;p++){let h=r[a++]^Qe(s,c,t,i,n,e),d=r[a++]^Qe(s,c,e,t,i,n),g=r[a++]^Qe(s,c,n,e,t,i),b=r[a++]^Qe(s,c,i,n,e,t);t=h,e=d,n=g,i=b}let f=r[a++]^le(o,t,i,n,e),l=r[a++]^le(o,e,t,i,n),y=r[a++]^le(o,n,e,t,i),m=r[a++]^le(o,i,n,e,t);return{s0:f,s1:l,s2:y,s3:m}}function nn(r,t){if(!t)return new Uint8Array(r);if(V(t),t.length<r)throw new Error(`aes: wrong destination length, expected at least ${r}, got: ${t.length}`);return t}function Hp(r,t,e,n){V(t,Et),V(e);let i=e.length;n=nn(i,n);let o=t,s=Y(o),{s0:c,s1:a,s2:u,s3:f}=Gt(r,s[0],s[1],s[2],s[3]),l=Y(e),y=Y(n);for(let p=0;p+4<=l.length;p+=4){y[p+0]=l[p+0]^c,y[p+1]=l[p+1]^a,y[p+2]=l[p+2]^u,y[p+3]=l[p+3]^f;let h=1;for(let d=o.length-1;d>=0;d--)h=h+(o[d]&255)|0,o[d]=h&255,h>>>=8;({s0:c,s1:a,s2:u,s3:f}=Gt(r,s[0],s[1],s[2],s[3]))}let m=Et*Math.floor(l.length/sc);if(m<i){let p=new Uint32Array([c,a,u,f]),h=zi(p);for(let d=m,g=0;d<i;d++,g++)n[d]=e[d]^h[g]}return n}function Wn(r,t,e,n,i){V(e,Et),V(n),i=nn(n.length,i);let o=e,s=Y(o),c=Ze(o),a=Y(n),u=Y(i),f=t?0:12,l=n.length,y=c.getUint32(f,t),{s0:m,s1:p,s2:h,s3:d}=Gt(r,s[0],s[1],s[2],s[3]);for(let b=0;b+4<=a.length;b+=4)u[b+0]=a[b+0]^m,u[b+1]=a[b+1]^p,u[b+2]=a[b+2]^h,u[b+3]=a[b+3]^d,y=y+1>>>0,c.setUint32(f,y,t),{s0:m,s1:p,s2:h,s3:d}=Gt(r,s[0],s[1],s[2],s[3]);let g=Et*Math.floor(a.length/sc);if(g<l){let b=new Uint32Array([m,p,h,d]),x=zi(b);for(let A=g,v=0;A<l;A++,v++)i[A]=n[A]^x[v]}return i}var Sx=ae({blockSize:16,nonceLength:16},function(t,e){V(t),V(e,Et);function n(i,o){let s=tr(t),c=e.slice(),a=Hp(s,c,i,o);return s.fill(0),c.fill(0),a}return{encrypt:(i,o)=>n(i,o),decrypt:(i,o)=>n(i,o)}});function wf(r){if(V(r),r.length%Et!==0)throw new Error(`aes/(cbc-ecb).decrypt ciphertext should consist of blocks with size ${Et}`)}function gf(r,t,e){let n=r.length,i=n%Et;if(!t&&i!==0)throw new Error("aec/(cbc-ecb): unpadded plaintext with disabled padding");let o=Y(r);if(t){let a=Et-i;a||(a=Et),n=n+a}let s=nn(n,e),c=Y(s);return{b:o,o:c,out:s}}function xf(r,t){if(!t)return r;let e=r.length;if(!e)throw new Error("aes/pcks5: empty ciphertext not allowed");let n=r[e-1];if(n<=0||n>16)throw new Error(`aes/pcks5: wrong padding byte: ${n}`);let i=r.subarray(0,-n);for(let o=0;o<n;o++)if(r[e-o-1]!==n)throw new Error("aes/pcks5: wrong padding");return i}function bf(r){let t=new Uint8Array(16),e=Y(t);t.set(r);let n=Et-r.length;for(let i=Et-n;i<Et;i++)t[i]=n;return e}var kx=ae({blockSize:16},function(t,e={}){V(t);let n=!e.disablePadding;return{encrypt:(i,o)=>{V(i);let{b:s,o:c,out:a}=gf(i,n,o),u=tr(t),f=0;for(;f+4<=s.length;){let{s0:l,s1:y,s2:m,s3:p}=Gt(u,s[f+0],s[f+1],s[f+2],s[f+3]);c[f++]=l,c[f++]=y,c[f++]=m,c[f++]=p}if(n){let l=bf(i.subarray(f*4)),{s0:y,s1:m,s2:p,s3:h}=Gt(u,l[0],l[1],l[2],l[3]);c[f++]=y,c[f++]=m,c[f++]=p,c[f++]=h}return u.fill(0),a},decrypt:(i,o)=>{wf(i);let s=df(t),c=nn(i.length,o),a=Y(i),u=Y(c);for(let f=0;f+4<=a.length;){let{s0:l,s1:y,s2:m,s3:p}=mf(s,a[f+0],a[f+1],a[f+2],a[f+3]);u[f++]=l,u[f++]=y,u[f++]=m,u[f++]=p}return s.fill(0),xf(c,n)}}}),Ux=ae({blockSize:16,nonceLength:16},function(t,e,n={}){V(t),V(e,16);let i=!n.disablePadding;return{encrypt:(o,s)=>{let c=tr(t),{b:a,o:u,out:f}=gf(o,i,s),l=Y(e),y=l[0],m=l[1],p=l[2],h=l[3],d=0;for(;d+4<=a.length;)y^=a[d+0],m^=a[d+1],p^=a[d+2],h^=a[d+3],{s0:y,s1:m,s2:p,s3:h}=Gt(c,y,m,p,h),u[d++]=y,u[d++]=m,u[d++]=p,u[d++]=h;if(i){let g=bf(o.subarray(d*4));y^=g[0],m^=g[1],p^=g[2],h^=g[3],{s0:y,s1:m,s2:p,s3:h}=Gt(c,y,m,p,h),u[d++]=y,u[d++]=m,u[d++]=p,u[d++]=h}return c.fill(0),f},decrypt:(o,s)=>{wf(o);let c=df(t),a=Y(e),u=nn(o.length,s),f=Y(o),l=Y(u),y=a[0],m=a[1],p=a[2],h=a[3];for(let d=0;d+4<=f.length;){let g=y,b=m,x=p,A=h;y=f[d+0],m=f[d+1],p=f[d+2],h=f[d+3];let{s0:v,s1:K,s2:k,s3:T}=mf(c,y,m,p,h);l[d++]=v^g,l[d++]=K^b,l[d++]=k^x,l[d++]=T^A}return c.fill(0),xf(u,i)}}}),Ix=ae({blockSize:16,nonceLength:16},function(t,e){V(t),V(e,16);function n(i,o,s){let c=tr(t),a=i.length;s=nn(a,s);let u=Y(i),f=Y(s),l=o?f:u,y=Y(e),m=y[0],p=y[1],h=y[2],d=y[3];for(let b=0;b+4<=u.length;){let{s0:x,s1:A,s2:v,s3:K}=Gt(c,m,p,h,d);f[b+0]=u[b+0]^x,f[b+1]=u[b+1]^A,f[b+2]=u[b+2]^v,f[b+3]=u[b+3]^K,m=l[b++],p=l[b++],h=l[b++],d=l[b++]}let g=Et*Math.floor(u.length/sc);if(g<a){({s0:m,s1:p,s2:h,s3:d}=Gt(c,m,p,h,d));let b=zi(new Uint32Array([m,p,h,d]));for(let x=g,A=0;x<a;x++,A++)s[x]=i[x]^b[A];b.fill(0)}return c.fill(0),s}return{encrypt:(i,o)=>n(i,!0,o),decrypt:(i,o)=>n(i,!1,o)}});function Ef(r,t,e,n,i){let o=r.create(e,n.length+(i?.length||0));i&&o.update(i),o.update(n);let s=new Uint8Array(16),c=Ze(s);return i&&Tr(c,0,BigInt(i.length*8),t),Tr(c,8,BigInt(n.length*8),t),o.update(s),o.digest()}var uc=ae({blockSize:16,nonceLength:12,tagLength:16},function(t,e,n){if(V(e),e.length===0)throw new Error("aes/gcm: empty nonce");let i=16;function o(c,a,u){let f=Ef(nc,!1,c,u,n);for(let l=0;l<a.length;l++)f[l]^=a[l];return f}function s(){let c=tr(t),a=ro.slice(),u=ro.slice();if(Wn(c,!1,u,u,a),e.length===12)u.set(e);else{let l=ro.slice(),y=Ze(l);Tr(y,8,BigInt(e.length*8),!1),nc.create(a).update(e).update(l).digestInto(u)}let f=Wn(c,!1,u,ro);return{xk:c,authKey:a,counter:u,tagMask:f}}return{encrypt:c=>{V(c);let{xk:a,authKey:u,counter:f,tagMask:l}=s(),y=new Uint8Array(c.length+i);Wn(a,!1,f,c,y);let m=o(u,l,y.subarray(0,y.length-i));return y.set(m,c.length),a.fill(0),y},decrypt:c=>{if(V(c),c.length<i)throw new Error(`aes/gcm: ciphertext less than tagLen (${i})`);let{xk:a,authKey:u,counter:f,tagMask:l}=s(),y=c.subarray(0,-i),m=c.subarray(-i),p=o(u,l,y);if(!$n(p,m))throw new Error("aes/gcm: invalid ghash tag");let h=Wn(a,!1,f,y);return u.fill(0),l.fill(0),a.fill(0),h}}}),no=(r,t,e)=>n=>{if(!Number.isSafeInteger(n)||t>n||n>e)throw new Error(`${r}: invalid value=${n}, must be [${t}..${e}]`)},Cx=ae({blockSize:16,nonceLength:12,tagLength:16},function(t,e,n){let o=no("AAD",0,68719476736),s=no("plaintext",0,2**36),c=no("nonce",12,12),a=no("ciphertext",16,2**36+16);V(e),c(e.length),n&&(V(n),o(n.length));function u(){let y=t.length;if(y!==16&&y!==24&&y!==32)throw new Error(`key length must be 16, 24 or 32 bytes, got: ${y} bytes`);let m=tr(t),p=new Uint8Array(y),h=new Uint8Array(16),d=Y(e),g=0,b=d[0],x=d[1],A=d[2],v=0;for(let K of[h,p].map(Y)){let k=Y(K);for(let T=0;T<k.length;T+=2){let{s0:L,s1:O}=Gt(m,g,b,x,A);k[T+0]=L,k[T+1]=O,g=++v}}return m.fill(0),{authKey:h,encKey:tr(p)}}function f(y,m,p){let h=Ef(hf,!0,m,p,n);for(let v=0;v<12;v++)h[v]^=e[v];h[15]&=127;let d=Y(h),g=d[0],b=d[1],x=d[2],A=d[3];return{s0:g,s1:b,s2:x,s3:A}=Gt(y,g,b,x,A),d[0]=g,d[1]=b,d[2]=x,d[3]=A,h}function l(y,m,p){let h=m.slice();return h[15]|=128,Wn(y,!0,h,p)}return{encrypt:y=>{V(y),s(y.length);let{encKey:m,authKey:p}=u(),h=f(m,p,y),d=new Uint8Array(y.length+16);return d.set(h,y.length),d.set(l(m,h,y)),m.fill(0),p.fill(0),d},decrypt:y=>{V(y),a(y.length);let m=y.subarray(-16),{encKey:p,authKey:h}=u(),d=l(p,m,y.subarray(0,-16)),g=f(p,h,d);if(p.fill(0),h.fill(0),!$n(m,g))throw new Error("invalid polyval tag");return d}}});var io=class extends Yr{constructor(t,e){super(),this.finished=!1,this.destroyed=!1,Mn(t);let n=Je(e);if(this.iHash=t.create(),typeof this.iHash.update!="function")throw new Error("Expected instance of class which extends utils.Hash");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;let i=this.blockLen,o=new Uint8Array(i);o.set(n.length>i?t.create().update(n).digest():n);for(let s=0;s<o.length;s++)o[s]^=54;this.iHash.update(o),this.oHash=t.create();for(let s=0;s<o.length;s++)o[s]^=106;this.oHash.update(o),o.fill(0)}update(t){return Zr(this),this.iHash.update(t),this}digestInto(t){Zr(this),zr(t,this.outputLen),this.finished=!0,this.iHash.digestInto(t),this.oHash.update(t),this.oHash.digestInto(t),this.destroy()}digest(){let t=new Uint8Array(this.oHash.outputLen);return this.digestInto(t),t}_cloneInto(t){t||(t=Object.create(Object.getPrototypeOf(this),{}));let{oHash:e,iHash:n,finished:i,destroyed:o,blockLen:s,outputLen:c}=this;return t=t,t.finished=i,t.destroyed=o,t.blockLen=s,t.outputLen=c,t.oHash=e._cloneInto(t.oHash),t.iHash=n._cloneInto(t.iHash),t}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}},oo=(r,t,e)=>new io(r,t).update(e).digest();oo.create=(r,t)=>new io(r,t);function Jp(r,t,e){return Mn(r),e===void 0&&(e=new Uint8Array(r.outputLen)),oo(r,Je(e),Je(t))}var fc=new Uint8Array([0]),vf=new Uint8Array;function Gp(r,t,e,n=32){if(Mn(r),Mi(n),n>255*r.outputLen)throw new Error("Length should be <= 255*HashLen");let i=Math.ceil(n/r.outputLen);e===void 0&&(e=vf);let o=new Uint8Array(i*r.outputLen),s=oo.create(r,t),c=s._cloneInto(),a=new Uint8Array(s.outputLen);for(let u=0;u<i;u++)fc[0]=u+1,c.update(u===0?vf:a).update(e).update(fc).digestInto(a),o.set(a,r.outputLen*u),s._cloneInto(c);return s.destroy(),c.destroy(),a.fill(0),fc.fill(0),o.slice(0,n)}var lc=(r,t,e,n,i)=>Gp(r,Jp(r,t,e),n,i);var Af=16,Vp=16,Bf=class{static encrypt(t,e){let n=at.utils.randomPrivateKey(),i=at.getPublicKey(n,!0),o=at.getPublicKey(n,!1),s=at.getSharedSecret(n,t,!1),c=lc(kt,Zi(o,s),void 0,void 0,32),a=Ys(Vp),u=uc(c,a).encrypt(e);return{ephemeralPublicKey:i,initializationVector:a,messageAuthenticationCode:u.subarray(u.length-Af),ciphertext:u.subarray(0,u.length-Af)}}static decrypt(t){let{privateKey:e,ephemeralPublicKey:n,initializationVector:i,messageAuthenticationCode:o,ciphertext:s}=t,c=at.ProjectivePoint.fromHex(n).toRawBytes(!1),a=at.getSharedSecret(e,n,!1),u=lc(kt,Zi(c,a),void 0,void 0,32),f=Zi(s,o);return uc(u,Uint8Array.from(i)).decrypt(f)}static get isEphemeralKeyCompressed(){return!0}};var dt=(r,t)=>r[t++]&255|(r[t++]&255)<<8,hc=class{constructor(t){this.blockLen=16,this.outputLen=16,this.buffer=new Uint8Array(16),this.r=new Uint16Array(10),this.h=new Uint16Array(10),this.pad=new Uint16Array(8),this.pos=0,this.finished=!1,t=ce(t),V(t,32);let e=dt(t,0),n=dt(t,2),i=dt(t,4),o=dt(t,6),s=dt(t,8),c=dt(t,10),a=dt(t,12),u=dt(t,14);this.r[0]=e&8191,this.r[1]=(e>>>13|n<<3)&8191,this.r[2]=(n>>>10|i<<6)&7939,this.r[3]=(i>>>7|o<<9)&8191,this.r[4]=(o>>>4|s<<12)&255,this.r[5]=s>>>1&8190,this.r[6]=(s>>>14|c<<2)&8191,this.r[7]=(c>>>11|a<<5)&8065,this.r[8]=(a>>>8|u<<8)&8191,this.r[9]=u>>>5&127;for(let f=0;f<8;f++)this.pad[f]=dt(t,16+2*f)}process(t,e,n=!1){let i=n?0:2048,{h:o,r:s}=this,c=s[0],a=s[1],u=s[2],f=s[3],l=s[4],y=s[5],m=s[6],p=s[7],h=s[8],d=s[9],g=dt(t,e+0),b=dt(t,e+2),x=dt(t,e+4),A=dt(t,e+6),v=dt(t,e+8),K=dt(t,e+10),k=dt(t,e+12),T=dt(t,e+14),L=o[0]+(g&8191),O=o[1]+((g>>>13|b<<3)&8191),C=o[2]+((b>>>10|x<<6)&8191),j=o[3]+((x>>>7|A<<9)&8191),M=o[4]+((A>>>4|v<<12)&8191),z=o[5]+(v>>>1&8191),B=o[6]+((v>>>14|K<<2)&8191),U=o[7]+((K>>>11|k<<5)&8191),R=o[8]+((k>>>8|T<<8)&8191),P=o[9]+(T>>>5|i),w=0,S=w+L*c+O*(5*d)+C*(5*h)+j*(5*p)+M*(5*m);w=S>>>13,S&=8191,S+=z*(5*y)+B*(5*l)+U*(5*f)+R*(5*u)+P*(5*a),w+=S>>>13,S&=8191;let I=w+L*a+O*c+C*(5*d)+j*(5*h)+M*(5*p);w=I>>>13,I&=8191,I+=z*(5*m)+B*(5*y)+U*(5*l)+R*(5*f)+P*(5*u),w+=I>>>13,I&=8191;let _=w+L*u+O*a+C*c+j*(5*d)+M*(5*h);w=_>>>13,_&=8191,_+=z*(5*p)+B*(5*m)+U*(5*y)+R*(5*l)+P*(5*f),w+=_>>>13,_&=8191;let H=w+L*f+O*u+C*a+j*c+M*(5*d);w=H>>>13,H&=8191,H+=z*(5*h)+B*(5*p)+U*(5*m)+R*(5*y)+P*(5*l),w+=H>>>13,H&=8191;let J=w+L*l+O*f+C*u+j*a+M*c;w=J>>>13,J&=8191,J+=z*(5*d)+B*(5*h)+U*(5*p)+R*(5*m)+P*(5*y),w+=J>>>13,J&=8191;let Z=w+L*y+O*l+C*f+j*u+M*a;w=Z>>>13,Z&=8191,Z+=z*c+B*(5*d)+U*(5*h)+R*(5*p)+P*(5*m),w+=Z>>>13,Z&=8191;let q=w+L*m+O*y+C*l+j*f+M*u;w=q>>>13,q&=8191,q+=z*a+B*c+U*(5*d)+R*(5*h)+P*(5*p),w+=q>>>13,q&=8191;let F=w+L*p+O*m+C*y+j*l+M*f;w=F>>>13,F&=8191,F+=z*u+B*a+U*c+R*(5*d)+P*(5*h),w+=F>>>13,F&=8191;let rt=w+L*h+O*p+C*m+j*y+M*l;w=rt>>>13,rt&=8191,rt+=z*f+B*u+U*a+R*c+P*(5*d),w+=rt>>>13,rt&=8191;let et=w+L*d+O*h+C*p+j*m+M*y;w=et>>>13,et&=8191,et+=z*l+B*f+U*u+R*a+P*c,w+=et>>>13,et&=8191,w=(w<<2)+w|0,w=w+S|0,S=w&8191,w=w>>>13,I+=w,o[0]=S,o[1]=I,o[2]=_,o[3]=H,o[4]=J,o[5]=Z,o[6]=q,o[7]=F,o[8]=rt,o[9]=et}finalize(){let{h:t,pad:e}=this,n=new Uint16Array(10),i=t[1]>>>13;t[1]&=8191;for(let c=2;c<10;c++)t[c]+=i,i=t[c]>>>13,t[c]&=8191;t[0]+=i*5,i=t[0]>>>13,t[0]&=8191,t[1]+=i,i=t[1]>>>13,t[1]&=8191,t[2]+=i,n[0]=t[0]+5,i=n[0]>>>13,n[0]&=8191;for(let c=1;c<10;c++)n[c]=t[c]+i,i=n[c]>>>13,n[c]&=8191;n[9]-=8192;let o=(i^1)-1;for(let c=0;c<10;c++)n[c]&=o;o=~o;for(let c=0;c<10;c++)t[c]=t[c]&o|n[c];t[0]=(t[0]|t[1]<<13)&65535,t[1]=(t[1]>>>3|t[2]<<10)&65535,t[2]=(t[2]>>>6|t[3]<<7)&65535,t[3]=(t[3]>>>9|t[4]<<4)&65535,t[4]=(t[4]>>>12|t[5]<<1|t[6]<<14)&65535,t[5]=(t[6]>>>2|t[7]<<11)&65535,t[6]=(t[7]>>>5|t[8]<<8)&65535,t[7]=(t[8]>>>8|t[9]<<5)&65535;let s=t[0]+e[0];t[0]=s&65535;for(let c=1;c<8;c++)s=(t[c]+e[c]|0)+(s>>>16)|0,t[c]=s&65535}update(t){ze(this);let{buffer:e,blockLen:n}=this;t=ce(t);let i=t.length;for(let o=0;o<i;){let s=Math.min(n-this.pos,i-o);if(s===n){for(;n<=i-o;o+=n)this.process(t,o);continue}e.set(t.subarray(o,o+s),this.pos),this.pos+=s,o+=s,this.pos===n&&(this.process(e,0,!1),this.pos=0)}return this}destroy(){this.h.fill(0),this.r.fill(0),this.buffer.fill(0),this.pad.fill(0)}digestInto(t){ze(this),Fn(t,this),this.finished=!0;let{buffer:e,h:n}=this,{pos:i}=this;if(i){for(e[i++]=1;i<16;i++)e[i]=0;this.process(e,0,!0)}this.finalize();let o=0;for(let s=0;s<8;s++)t[o++]=n[s]>>>0,t[o++]=n[s]>>>8;return t}digest(){let{buffer:t,outputLen:e}=this;this.digestInto(t);let n=t.slice(0,e);return this.destroy(),n}};function qp(r){let t=(n,i)=>r(i).update(ce(n)).digest(),e=r(new Uint8Array(32));return t.outputLen=e.outputLen,t.blockLen=e.blockLen,t.create=n=>r(n),t}var Pf=qp(r=>new hc(r));var Tf=r=>Uint8Array.from(r.split("").map(t=>t.charCodeAt(0))),Fp=Tf("expand 16-byte k"),$p=Tf("expand 32-byte k"),Wp=Y(Fp),Sf=Y($p),Qx=Sf.slice();function D(r,t){return r<<t|r>>>32-t}function yc(r){return r.byteOffset%4===0}var so=64,zp=16,kf=2**32-1,Kf=new Uint32Array;function Zp(r,t,e,n,i,o,s,c){let a=i.length,u=new Uint8Array(so),f=Y(u),l=yc(i)&&yc(o),y=l?Y(i):Kf,m=l?Y(o):Kf;for(let p=0;p<a;s++){if(r(t,e,n,f,s,c),s>=kf)throw new Error("arx: counter overflow");let h=Math.min(so,a-p);if(l&&h===so){let d=p/4;if(p%4!==0)throw new Error("arx: invalid block position");for(let g=0,b;g<zp;g++)b=d+g,m[b]=y[b]^f[g];p+=so;continue}for(let d=0,g;d<h;d++)g=p+d,o[g]=i[g]^u[d];p+=h}}function pc(r,t){let{allowShortKeys:e,extendNonceFn:n,counterLength:i,counterRight:o,rounds:s}=ef({allowShortKeys:!1,counterLength:8,counterRight:!1,rounds:20},t);if(typeof r!="function")throw new Error("core must be a function");return qn(i),qn(s),Xs(o),Xs(e),(c,a,u,f,l=0)=>{V(c),V(a),V(u);let y=u.length;if(f||(f=new Uint8Array(y)),V(f),qn(l),l<0||l>=kf)throw new Error("arx: counter overflow");if(f.length<y)throw new Error(`arx: output (${f.length}) is shorter than data (${y})`);let m=[],p=c.length,h,d;if(p===32)h=c.slice(),m.push(h),d=Sf;else if(p===16&&e)h=new Uint8Array(32),h.set(c),h.set(c,16),d=Wp,m.push(h);else throw new Error(`arx: invalid 32-byte key, got length=${p}`);yc(a)||(a=a.slice(),m.push(a));let g=Y(h);if(n){if(a.length!==24)throw new Error("arx: extended nonce must be 24 bytes");n(d,g,Y(a.subarray(0,16)),g),a=a.subarray(16)}let b=16-i;if(b!==a.length)throw new Error(`arx: nonce must be ${b} or 16 bytes`);if(b!==12){let A=new Uint8Array(12);A.set(a,o?0:12-a.length),a=A,m.push(a)}let x=Y(a);for(Zp(r,d,g,x,u,f,l,s);m.length>0;)m.pop().fill(0);return f}}function Cf(r,t,e,n,i,o=20){let s=r[0],c=r[1],a=r[2],u=r[3],f=t[0],l=t[1],y=t[2],m=t[3],p=t[4],h=t[5],d=t[6],g=t[7],b=i,x=e[0],A=e[1],v=e[2],K=s,k=c,T=a,L=u,O=f,C=l,j=y,M=m,z=p,B=h,U=d,R=g,P=b,w=x,S=A,I=v;for(let H=0;H<o;H+=2)K=K+O|0,P=D(P^K,16),z=z+P|0,O=D(O^z,12),K=K+O|0,P=D(P^K,8),z=z+P|0,O=D(O^z,7),k=k+C|0,w=D(w^k,16),B=B+w|0,C=D(C^B,12),k=k+C|0,w=D(w^k,8),B=B+w|0,C=D(C^B,7),T=T+j|0,S=D(S^T,16),U=U+S|0,j=D(j^U,12),T=T+j|0,S=D(S^T,8),U=U+S|0,j=D(j^U,7),L=L+M|0,I=D(I^L,16),R=R+I|0,M=D(M^R,12),L=L+M|0,I=D(I^L,8),R=R+I|0,M=D(M^R,7),K=K+C|0,I=D(I^K,16),U=U+I|0,C=D(C^U,12),K=K+C|0,I=D(I^K,8),U=U+I|0,C=D(C^U,7),k=k+j|0,P=D(P^k,16),R=R+P|0,j=D(j^R,12),k=k+j|0,P=D(P^k,8),R=R+P|0,j=D(j^R,7),T=T+M|0,w=D(w^T,16),z=z+w|0,M=D(M^z,12),T=T+M|0,w=D(w^T,8),z=z+w|0,M=D(M^z,7),L=L+O|0,S=D(S^L,16),B=B+S|0,O=D(O^B,12),L=L+O|0,S=D(S^L,8),B=B+S|0,O=D(O^B,7);let _=0;n[_++]=s+K|0,n[_++]=c+k|0,n[_++]=a+T|0,n[_++]=u+L|0,n[_++]=f+O|0,n[_++]=l+C|0,n[_++]=y+j|0,n[_++]=m+M|0,n[_++]=p+z|0,n[_++]=h+B|0,n[_++]=d+U|0,n[_++]=g+R|0,n[_++]=b+P|0,n[_++]=x+w|0,n[_++]=A+S|0,n[_++]=v+I|0}function Yp(r,t,e,n){let i=r[0],o=r[1],s=r[2],c=r[3],a=t[0],u=t[1],f=t[2],l=t[3],y=t[4],m=t[5],p=t[6],h=t[7],d=e[0],g=e[1],b=e[2],x=e[3];for(let v=0;v<20;v+=2)i=i+a|0,d=D(d^i,16),y=y+d|0,a=D(a^y,12),i=i+a|0,d=D(d^i,8),y=y+d|0,a=D(a^y,7),o=o+u|0,g=D(g^o,16),m=m+g|0,u=D(u^m,12),o=o+u|0,g=D(g^o,8),m=m+g|0,u=D(u^m,7),s=s+f|0,b=D(b^s,16),p=p+b|0,f=D(f^p,12),s=s+f|0,b=D(b^s,8),p=p+b|0,f=D(f^p,7),c=c+l|0,x=D(x^c,16),h=h+x|0,l=D(l^h,12),c=c+l|0,x=D(x^c,8),h=h+x|0,l=D(l^h,7),i=i+u|0,x=D(x^i,16),p=p+x|0,u=D(u^p,12),i=i+u|0,x=D(x^i,8),p=p+x|0,u=D(u^p,7),o=o+f|0,d=D(d^o,16),h=h+d|0,f=D(f^h,12),o=o+f|0,d=D(d^o,8),h=h+d|0,f=D(f^h,7),s=s+l|0,g=D(g^s,16),y=y+g|0,l=D(l^y,12),s=s+l|0,g=D(g^s,8),y=y+g|0,l=D(l^y,7),c=c+a|0,b=D(b^c,16),m=m+b|0,a=D(a^m,12),c=c+a|0,b=D(b^c,8),m=m+b|0,a=D(a^m,7);let A=0;n[A++]=i,n[A++]=o,n[A++]=s,n[A++]=c,n[A++]=d,n[A++]=g,n[A++]=b,n[A++]=x}var Xp=pc(Cf,{counterRight:!1,counterLength:4,allowShortKeys:!1}),co=pc(Cf,{counterRight:!1,counterLength:8,extendNonceFn:Yp,allowShortKeys:!1});var Qp=new Uint8Array(16),Uf=(r,t)=>{r.update(t);let e=t.length%16;e&&r.update(Qp.subarray(e))},td=new Uint8Array(32);function If(r,t,e,n,i){let o=r(t,e,td),s=Pf.create(o);i&&Uf(s,i),Uf(s,n);let c=new Uint8Array(16),a=Ze(c);Tr(a,0,BigInt(i?i.length:0),!0),Tr(a,8,BigInt(n.length),!0),s.update(c);let u=s.digest();return o.fill(0),u}var _f=r=>(t,e,n)=>(V(t,32),V(e),{encrypt:(o,s)=>{let c=o.length,a=c+16;s?V(s,a):s=new Uint8Array(a),r(t,e,o,s,1);let u=If(r,t,e,s.subarray(0,-16),n);return s.set(u,c),s},decrypt:(o,s)=>{let c=o.length,a=c-16;if(c<16)throw new Error("encrypted data must be at least 16 bytes");s?V(s,a):s=new Uint8Array(a);let u=o.subarray(0,-16),f=o.subarray(-16),l=If(r,t,e,u,n);if(!$n(f,l))throw new Error("invalid tag");return r(t,e,u,s,1),s}}),ob=ae({blockSize:64,nonceLength:12,tagLength:16},_f(Xp)),dc=ae({blockSize:64,nonceLength:24,tagLength:16},_f(co));var Lf=class r{static async bytesToPrivateKey({privateKeyBytes:t}){let e={k:N.uint8Array(t).toBase64Url(),kty:"oct"};return e.kid=await G({jwk:e}),e}static async decrypt({data:t,key:e,nonce:n}){let i=await r.privateKeyToBytes({privateKey:e});return co(i,n,t)}static async encrypt({data:t,key:e,nonce:n}){let i=await r.privateKeyToBytes({privateKey:e});return co(i,n,t)}static async generateKey(){let t=ct(),e=await t.generateKey({name:"AES-CTR",length:256},!0,["encrypt"]),{alg:n,ext:i,key_ops:o,...s}=await t.exportKey("jwk",e);return s.kid=await G({jwk:s}),s}static async privateKeyToBytes({privateKey:t}){if(!se(t))throw new Error("XChaCha20: The provided key is not a valid oct private key.");return N.base64Url(t.k).toUint8Array()}};var mb=16,Of=class r{static async bytesToPrivateKey({privateKeyBytes:t}){let e={k:N.uint8Array(t).toBase64Url(),kty:"oct"};return e.kid=await G({jwk:e}),e}static async decrypt({data:t,key:e,nonce:n,additionalData:i}){let o=await r.privateKeyToBytes({privateKey:e});return r.decryptRaw({data:t,keyBytes:o,nonce:n,additionalData:i})}static async decryptRaw({data:t,keyBytes:e,nonce:n,additionalData:i}){return dc(e,n,i).decrypt(t)}static async encrypt({data:t,key:e,nonce:n,additionalData:i}){let o=await r.privateKeyToBytes({privateKey:e});return r.encryptRaw({data:t,keyBytes:o,nonce:n,additionalData:i})}static async encryptRaw({data:t,keyBytes:e,nonce:n,additionalData:i}){return dc(e,n,i).encrypt(t)}static async generateKey(){let t=ct(),e=await t.generateKey({name:"AES-CTR",length:256},!0,["encrypt"]),{alg:n,ext:i,key_ops:o,...s}=await t.exportKey("jwk",e);return s.kid=await G({jwk:s}),s}static async privateKeyToBytes({privateKey:t}){if(!se(t))throw new Error("XChaCha20Poly1305: The provided key is not a valid oct private key.");return N.base64Url(t.k).toUint8Array()}};export{Xi as AES_GCM_TAG_LENGTHS,en as AesCtr,tf as AesCtrAlgorithm,Ye as AesGcm,of as AesGcmAlgorithm,Xe as AesKw,cf as AesKwAlgorithm,ff as ConcatKdf,ut as CryptoAlgorithm,nt as CryptoError,sn as CryptoErrorCode,Xu as CryptoUtils,jn as EcdsaAlgorithm,Bf as EciesSecp256k1,Ht as Ed25519,qi as EdDsaAlgorithm,Qi as Hkdf,af as HkdfAlgorithm,Vs as KEY_URI_PREFIX_JWK,Yu as LocalKeyManager,Mt as P256,mb as POLY1305_TAG_LENGTH,to as Pbkdf2,uf as Pbkdf2Algorithm,Dt as Secp256k1,Mt as Secp256r1,Xr as Sha256,Fi as Sha2Algorithm,We as X25519,$i as X25519Algorithm,Lf as XChaCha20,Of as XChaCha20Poly1305,Du as canonicalize,G as computeJwkThumbprint,Ag as isCipher,oe as isEcPrivateJwk,Qr as isEcPublicJwk,Bg as isKeyExporter,Pg as isKeyImporter,Kg as isKeyWrapper,se as isOctPrivateJwk,Ut as isOkpPrivateJwk,tn as isOkpPublicJwk,Mu as isPrivateJwk,Fm as isPublicJwk};
|
|
3
2
|
/*! Bundled license information:
|
|
4
3
|
|
|
5
4
|
ieee754/index.js:
|
|
@@ -19,18 +18,12 @@ queue-microtask/index.js:
|
|
|
19
18
|
run-parallel-limit/index.js:
|
|
20
19
|
(*! run-parallel-limit. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> *)
|
|
21
20
|
|
|
22
|
-
|
|
23
|
-
(*!
|
|
24
|
-
|
|
25
|
-
@noble/hashes/esm/utils.js:
|
|
26
|
-
(*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) *)
|
|
21
|
+
@noble/curves/esm/abstract/utils.js:
|
|
22
|
+
(*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) *)
|
|
27
23
|
|
|
28
24
|
@noble/hashes/esm/utils.js:
|
|
29
25
|
(*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) *)
|
|
30
26
|
|
|
31
|
-
@noble/curves/esm/abstract/utils.js:
|
|
32
|
-
(*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) *)
|
|
33
|
-
|
|
34
27
|
@noble/curves/esm/abstract/modular.js:
|
|
35
28
|
(*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) *)
|
|
36
29
|
|
|
@@ -46,6 +39,9 @@ safe-buffer/index.js:
|
|
|
46
39
|
@noble/curves/esm/secp256k1.js:
|
|
47
40
|
(*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) *)
|
|
48
41
|
|
|
42
|
+
@noble/hashes/esm/utils.js:
|
|
43
|
+
(*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) *)
|
|
44
|
+
|
|
49
45
|
@noble/curves/esm/p256.js:
|
|
50
46
|
(*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) *)
|
|
51
47
|
|