/*! OpenPGP.js v6.0.0 - 2024-11-06 - this is LGPL licensed code, see LICENSE/our website https://openpgpjs.org/ for more information. */ "use strict";const e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};var t=require("module"),r=require("node:crypto"),n=require("crypto"),i="undefined"!=typeof document?document.currentScript:null;function s(e){var t=Object.create(null);return e&&Object.keys(e).forEach((function(r){if("default"!==r){var n=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(t,r,n.get?n:{enumerable:!0,get:function(){return e[r]}})}})),t.default=e,Object.freeze(t)}function a(e,t){return t.forEach((function(t){t&&"string"!=typeof t&&!Array.isArray(t)&&Object.keys(t).forEach((function(r){if("default"!==r&&!(r in e)){var n=Object.getOwnPropertyDescriptor(t,r);Object.defineProperty(e,r,n.get?n:{enumerable:!0,get:function(){return t[r]}})}}))})),Object.freeze(e)}var o=/*#__PURE__*/s(r),c=/*#__PURE__*/s(n);const h=Symbol("doneWritingPromise"),u=Symbol("doneWritingResolve"),l=Symbol("doneWritingReject"),y=Symbol("readingIndex");class f extends Array{constructor(){super(),Object.setPrototypeOf(this,f.prototype),this[h]=new Promise(((e,t)=>{this[u]=e,this[l]=t})),this[h].catch((()=>{}))}}function g(e){return e&&e.getReader&&Array.isArray(e)}function p(e){if(!g(e)){const t=e.getWriter(),r=t.releaseLock;return t.releaseLock=()=>{t.closed.catch((function(){})),r.call(t)},t}this.stream=e}function d(t){if(g(t))return"array";if(e.ReadableStream&&e.ReadableStream.prototype.isPrototypeOf(t))return"web";if(t&&!(e.ReadableStream&&t instanceof e.ReadableStream)&&"function"==typeof t._read&&"object"==typeof t._readableState)throw Error("Native Node streams are no longer supported: please manually convert the stream to a WebStream, using e.g. `stream.Readable.toWeb`");return!(!t||!t.getReader)&&"web-like"}function A(e){return Uint8Array.prototype.isPrototypeOf(e)}function w(e){if(1===e.length)return e[0];let t=0;for(let r=0;r(await this[h],this[y]===this.length?{value:void 0,done:!0}:{value:this[this[y]++],done:!1})}},f.prototype.readToEnd=async function(e){await this[h];const t=e(this.slice(this[y]));return this.length=0,t},f.prototype.clone=function(){const e=new f;return e[h]=this[h].then((()=>{e.push(...this)})),e},p.prototype.write=async function(e){this.stream.push(e)},p.prototype.close=async function(){this.stream[u]()},p.prototype.abort=async function(e){return this.stream[l](e),e},p.prototype.releaseLock=function(){},"object"==typeof e.process&&e.process.versions;const m=new WeakSet,b=Symbol("externalBuffer");function k(e){if(this.stream=e,e[b]&&(this[b]=e[b].slice()),g(e)){const t=e.getReader();return this._read=t.read.bind(t),this._releaseLock=()=>{},void(this._cancel=()=>{})}if(d(e)){const t=e.getReader();return this._read=t.read.bind(t),this._releaseLock=()=>{t.closed.catch((function(){})),t.releaseLock()},void(this._cancel=t.cancel.bind(t))}let t=!1;this._read=async()=>t||m.has(e)?{value:void 0,done:!0}:(t=!0,{value:e,done:!1}),this._releaseLock=()=>{if(t)try{m.add(e)}catch(e){}}}function E(e){return d(e)?e:new ReadableStream({start(t){t.enqueue(e),t.close()}})}function v(e){if(d(e))return e;const t=new f;return(async()=>{const r=N(t);await r.write(e),await r.close()})(),t}function B(e){return e.some((e=>d(e)&&!g(e)))?function(e){e=e.map(E);const t=K((async function(e){await Promise.all(n.map((t=>M(t,e))))}));let r=Promise.resolve();const n=e.map(((n,i)=>P(n,((n,s)=>(r=r.then((()=>I(n,t.writable,{preventClose:i!==e.length-1}))),r)))));return t.readable}(e):e.some((e=>g(e)))?function(e){const t=new f;let r=Promise.resolve();return e.forEach(((n,i)=>(r=r.then((()=>I(n,t,{preventClose:i!==e.length-1}))),r))),t}(e):"string"==typeof e[0]?e.join(""):w(e)}async function I(e,t,{preventClose:r=!1,preventAbort:n=!1,preventCancel:i=!1}={}){if(d(e)&&!g(e)){e=E(e);try{if(e[b]){const r=N(t);for(let t=0;t{t=e,r=n})),t=null,r=null)},close:n.close.bind(n),abort:n.error.bind(n)})}}function C(e,t=()=>{},r=()=>{}){if(g(e)){const n=new f;return(async()=>{const i=N(n);try{const n=await L(e),s=t(n),a=r();let o;o=void 0!==s&&void 0!==a?B([s,a]):void 0!==s?s:a,await i.write(o),await i.close()}catch(e){await i.abort(e)}})(),n}if(d(e))return S(e,{async transform(e,r){try{const n=await t(e);void 0!==n&&r.enqueue(n)}catch(e){r.error(e)}},async flush(e){try{const t=await r();void 0!==t&&e.enqueue(t)}catch(t){e.error(t)}}});const n=t(e),i=r();return void 0!==n&&void 0!==i?B([n,i]):void 0!==n?n:i}function P(e,t){if(d(e)&&!g(e)){let r;const n=new TransformStream({start(e){r=e}}),i=I(e,n.writable),s=K((async function(e){r.error(e),await i,await new Promise(setTimeout)}));return t(n.readable,s.writable),s.readable}e=v(e);const r=new f;return t(e,r),r}function U(e,t){let r;const n=P(e,((e,i)=>{const s=F(e);s.remainder=()=>(s.releaseLock(),I(e,i),n),r=t(s)}));return r}function D(e){if(g(e))return e.clone();if(d(e)){const t=function(e){if(g(e))throw Error("ArrayStream cannot be tee()d, use clone() instead");if(d(e)){const t=E(e).tee();return t[0][b]=t[1][b]=e[b],t}return[R(e),R(e)]}(e);return Q(e,t[0]),t[1]}return R(e)}function x(e){return g(e)?D(e):d(e)?new ReadableStream({start(t){const r=P(e,(async(e,r)=>{const n=F(e),i=N(r);try{for(;;){await i.ready;const{done:e,value:r}=await n.read();if(e){try{t.close()}catch(e){}return void await i.close()}try{t.enqueue(r)}catch(e){}await i.write(r)}}catch(e){t.error(e),await i.abort(e)}}));Q(e,r)}}):R(e)}function Q(e,t){Object.entries(Object.getOwnPropertyDescriptors(e.constructor.prototype)).forEach((([r,n])=>{"constructor"!==r&&(n.value?n.value=n.value.bind(t):n.get=n.get.bind(t),Object.defineProperty(e,r,n))}))}function R(e,t=0,r=1/0){if(g(e))throw Error("Not implemented");if(d(e)){if(t>=0&&r>=0){let n=0;return S(e,{transform(e,i){n=t&&i.enqueue(R(e,Math.max(t-n,0),r-n)),n+=e.length):i.terminate()}})}if(t<0&&(r<0||r===1/0)){let n=[];return C(e,(e=>{e.length>=-t?n=[e]:n.push(e)}),(()=>R(B(n),t,r)))}if(0===t&&r<0){let n;return C(e,(e=>{const i=n?B([n,e]):e;if(i.length>=-r)return n=R(i,r),R(i,t,r);n=i}))}return console.warn(`stream.slice(input, ${t}, ${r}) not implemented efficiently.`),T((async()=>R(await L(e),t,r)))}return e[b]&&(e=B(e[b].concat([e]))),A(e)?e.subarray(t,r===1/0?e.length:r):e.slice(t,r)}async function L(e,t=B){return g(e)?e.readToEnd(t):d(e)?F(e).readToEnd(t):e}async function M(e,t){if(d(e)){if(e.cancel){const r=await e.cancel(t);return await new Promise(setTimeout),r}if(e.destroy)return e.destroy(t),await new Promise(setTimeout),t}}function T(e){const t=new f;return(async()=>{const r=N(t);try{await r.write(await e()),await r.close()}catch(e){await r.abort(e)}})(),t}function F(e){return new k(e)}function N(e){return new p(e)}k.prototype.read=async function(){if(this[b]&&this[b].length){return{done:!1,value:this[b].shift()}}return this._read()},k.prototype.releaseLock=function(){this[b]&&(this.stream[b]=this[b]),this._releaseLock()},k.prototype.cancel=function(e){return this._cancel(e)},k.prototype.readLine=async function(){let e,t=[];for(;!e;){let{done:r,value:n}=await this.read();if(n+="",r)return t.length?B(t):void 0;const i=n.indexOf("\n")+1;i&&(e=B(t.concat(n.substr(0,i))),t=[]),i!==n.length&&t.push(n.substr(i))}return this.unshift(...t),e},k.prototype.readByte=async function(){const{done:e,value:t}=await this.read();if(e)return;const r=t[0];return this.unshift(R(t,1)),r},k.prototype.readBytes=async function(e){const t=[];let r=0;for(;;){const{done:n,value:i}=await this.read();if(n)return t.length?B(t):void 0;if(t.push(i),r+=i.length,r>=e){const r=B(t);return this.unshift(R(r,e)),R(r,0,e)}}},k.prototype.peekBytes=async function(e){const t=await this.readBytes(e);return this.unshift(t),t},k.prototype.unshift=function(...e){this[b]||(this[b]=[]),1===e.length&&A(e[0])&&this[b].length&&e[0].length&&this[b][0].byteOffset>=e[0].length?this[b][0]=new Uint8Array(this[b][0].buffer,this[b][0].byteOffset-e[0].length,this[b][0].byteLength+e[0].length):this[b].unshift(...e.filter((e=>e&&e.length)))},k.prototype.readToEnd=async function(e=B){const t=[];for(;;){const{done:e,value:r}=await this.read();if(e)break;t.push(r)}return e(t)};const O=Symbol("byValue");var H={curve:{nistP256:"nistP256",p256:"nistP256",nistP384:"nistP384",p384:"nistP384",nistP521:"nistP521",p521:"nistP521",secp256k1:"secp256k1",ed25519Legacy:"ed25519Legacy",ed25519:"ed25519Legacy",curve25519Legacy:"curve25519Legacy",curve25519:"curve25519Legacy",brainpoolP256r1:"brainpoolP256r1",brainpoolP384r1:"brainpoolP384r1",brainpoolP512r1:"brainpoolP512r1"},kdfFlags:{replace_fingerprint:1,replace_kdf_params:2},s2k:{simple:0,salted:1,iterated:3,argon2:4,gnu:101},publicKey:{rsaEncryptSign:1,rsaEncrypt:2,rsaSign:3,elgamal:16,dsa:17,ecdh:18,ecdsa:19,eddsaLegacy:22,aedh:23,aedsa:24,x25519:25,x448:26,ed25519:27,ed448:28,aead:100,hmac:101},symmetric:{idea:1,tripledes:2,cast5:3,blowfish:4,aes128:7,aes192:8,aes256:9,twofish:10},compression:{uncompressed:0,zip:1,zlib:2,bzip2:3},hash:{md5:1,sha1:2,ripemd:3,sha256:8,sha384:9,sha512:10,sha224:11,sha3_256:12,sha3_512:14},webHash:{"SHA-1":2,"SHA-256":8,"SHA-384":9,"SHA-512":10},aead:{eax:1,ocb:2,gcm:3,experimentalGCM:100},packet:{publicKeyEncryptedSessionKey:1,signature:2,symEncryptedSessionKey:3,onePassSignature:4,secretKey:5,publicKey:6,secretSubkey:7,compressedData:8,symmetricallyEncryptedData:9,marker:10,literalData:11,trust:12,userID:13,publicSubkey:14,userAttribute:17,symEncryptedIntegrityProtectedData:18,modificationDetectionCode:19,aeadEncryptedData:20,padding:21},literal:{binary:98,text:116,utf8:117,mime:109},signature:{binary:0,text:1,standalone:2,certGeneric:16,certPersona:17,certCasual:18,certPositive:19,certRevocation:48,subkeyBinding:24,keyBinding:25,key:31,keyRevocation:32,subkeyRevocation:40,timestamp:64,thirdParty:80},signatureSubpacket:{signatureCreationTime:2,signatureExpirationTime:3,exportableCertification:4,trustSignature:5,regularExpression:6,revocable:7,keyExpirationTime:9,placeholderBackwardsCompatibility:10,preferredSymmetricAlgorithms:11,revocationKey:12,issuerKeyID:16,notationData:20,preferredHashAlgorithms:21,preferredCompressionAlgorithms:22,keyServerPreferences:23,preferredKeyServer:24,primaryUserID:25,policyURI:26,keyFlags:27,signersUserID:28,reasonForRevocation:29,features:30,signatureTarget:31,embeddedSignature:32,issuerFingerprint:33,preferredAEADAlgorithms:34,preferredCipherSuites:39},keyFlags:{certifyKeys:1,signData:2,encryptCommunication:4,encryptStorage:8,splitPrivateKey:16,authentication:32,forwardedCommunication:64,sharedPrivateKey:128},armor:{multipartSection:0,multipartLast:1,signed:2,message:3,publicKey:4,privateKey:5,signature:6},reasonForRevocation:{noReason:0,keySuperseded:1,keyCompromised:2,keyRetired:3,userIDInvalid:32},features:{modificationDetection:1,aead:2,v5Keys:4,seipdv2:8},write:function(e,t){if("number"==typeof t&&(t=this.read(e,t)),void 0!==e[t])return e[t];throw Error("Invalid enum value.")},read:function(e,t){if(e[O]||(e[O]=[],Object.entries(e).forEach((([t,r])=>{e[O][r]=t}))),void 0!==e[O][t])return e[O][t];throw Error("Invalid enum value.")}},z={preferredHashAlgorithm:H.hash.sha512,preferredSymmetricAlgorithm:H.symmetric.aes256,preferredCompressionAlgorithm:H.compression.uncompressed,aeadProtect:!1,ignoreSEIPDv2FeatureFlag:!1,parseAEADEncryptedV4KeysAsLegacy:!1,preferredAEADAlgorithm:H.aead.gcm,aeadChunkSizeByte:12,v6Keys:!1,enableParsingV5Entities:!1,s2kType:H.s2k.iterated,s2kIterationCountByte:224,s2kArgon2Params:{passes:3,parallelism:4,memoryExponent:16},allowUnauthenticatedMessages:!1,allowUnauthenticatedStream:!1,allowForwardedMessages:!1,minRSABits:2047,passwordCollisionCheck:!1,allowInsecureDecryptionWithSigningKeys:!1,allowInsecureVerificationWithReformattedKeys:!1,allowMissingKeyFlags:!1,constantTimePKCS1Decryption:!1,constantTimePKCS1DecryptionSupportedSymmetricAlgorithms:new Set([H.symmetric.aes128,H.symmetric.aes192,H.symmetric.aes256]),ignoreUnsupportedPackets:!0,ignoreMalformedPackets:!1,additionalAllowedPackets:[],showVersion:!1,showComment:!1,versionString:"OpenPGP.js 6.0.0",commentString:"https://openpgpjs.org",maxUserIDLength:5120,knownNotations:[],nonDeterministicSignaturesViaNotation:!0,useEllipticFallback:!0,rejectHashAlgorithms:new Set([H.hash.md5,H.hash.ripemd]),rejectMessageHashAlgorithms:new Set([H.hash.md5,H.hash.ripemd,H.hash.sha1]),rejectPublicKeyAlgorithms:new Set([H.publicKey.elgamal,H.publicKey.dsa]),rejectCurves:new Set([H.curve.secp256k1])};const _=(()=>{try{return"development"===process.env.NODE_ENV}catch(e){}return!1})(),G={isString:function(e){return"string"==typeof e||e instanceof String},nodeRequire:t.createRequire("undefined"==typeof document?require("url").pathToFileURL(__filename).href:i&&"SCRIPT"===i.tagName.toUpperCase()&&i.src||new URL("openpgp.min.cjs",document.baseURI).href),isArray:function(e){return e instanceof Array},isUint8Array:A,isStream:d,getNobleCurve:async(e,t)=>{if(!z.useEllipticFallback)throw Error("This curve is only supported in the full build of OpenPGP.js");const{nobleCurves:r}=await Promise.resolve().then((function(){return ry}));switch(e){case H.publicKey.ecdh:case H.publicKey.ecdsa:{const e=r.get(t);if(!e)throw Error("Unsupported curve");return e}case H.publicKey.x448:return r.get("x448");case H.publicKey.ed448:return r.get("ed448");default:throw Error("Unsupported curve")}},readNumber:function(e){let t=0;for(let r=0;r>8*(t-n-1)&255;return r},readDate:function(e){const t=G.readNumber(e);return new Date(1e3*t)},writeDate:function(e){const t=Math.floor(e.getTime()/1e3);return G.writeNumber(t,4)},normalizeDate:function(e=Date.now()){return null===e||e===1/0?e:new Date(1e3*Math.floor(+e/1e3))},readMPI:function(e){const t=(e[0]<<8|e[1])+7>>>3;return G.readExactSubarray(e,2,2+t)},readExactSubarray:function(e,t,r){if(e.lengtht)throw Error("Input array too long");const r=new Uint8Array(t),n=t-e.length;return r.set(e,n),r},uint8ArrayToMPI:function(e){const t=G.uint8ArrayBitLength(e);if(0===t)throw Error("Zero MPI");const r=e.subarray(e.length-Math.ceil(t/8)),n=new Uint8Array([(65280&t)>>8,255&t]);return G.concatUint8Array([n,r])},uint8ArrayBitLength:function(e){let t;for(t=0;t>1);for(let r=0;r>1;r++)t[r]=parseInt(e.substr(r<<1,2),16);return t},uint8ArrayToHex:function(e){const t="0123456789abcdef";let r="";return e.forEach((e=>{r+=t[e>>4]+t[15&e]})),r},stringToUint8Array:function(e){return C(e,(e=>{if(!G.isString(e))throw Error("stringToUint8Array: Data must be in the form of a string");const t=new Uint8Array(e.length);for(let r=0;rr("",!0)))},decodeUTF8:function(e){const t=new TextDecoder("utf-8");function r(e,r=!1){return t.decode(e,{stream:!r})}return C(e,r,(()=>r(new Uint8Array,!0)))},concat:B,concatUint8Array:w,equalsUint8Array:function(e,t){if(!G.isUint8Array(e)||!G.isUint8Array(t))throw Error("Data must be in the form of a Uint8Array");if(e.length!==t.length)return!1;for(let r=0;r>>16;return 0!==r&&(e=r,t+=16),r=e>>8,0!==r&&(e=r,t+=8),r=e>>4,0!==r&&(e=r,t+=4),r=e>>2,0!==r&&(e=r,t+=2),r=e>>1,0!==r&&(e=r,t+=1),t},double:function(e){const t=new Uint8Array(e.length),r=e.length-1;for(let n=0;n>7;return t[r]=e[r]<<1^135*(e[0]>>7),t},shiftRight:function(e,t){if(t)for(let r=e.length-1;r>=0;r--)e[r]>>=t,r>0&&(e[r]|=e[r-1]<<8-t);return e},getWebCrypto:function(){const t=void 0!==e&&e.crypto&&e.crypto.subtle||this.getNodeCrypto()?.webcrypto.subtle;if(!t)throw Error("The WebCrypto API is not available");return t},getNodeCrypto:function(){return this.nodeRequire("crypto")},getNodeZlib:function(){return this.nodeRequire("zlib")},getNodeBuffer:function(){return(this.nodeRequire("buffer")||{}).Buffer},getHardwareConcurrency:function(){if("undefined"!=typeof navigator)return navigator.hardwareConcurrency||1;return this.nodeRequire("os").cpus().length},isEmailAddress:function(e){if(!G.isString(e))return!1;return/^[^\p{C}\p{Z}@<>\\]+@[^\p{C}\p{Z}@<>\\]+[^\p{C}\p{Z}\p{P}]$/u.test(e)},canonicalizeEOL:function(e){let t=!1;return C(e,(e=>{let r;t&&(e=G.concatUint8Array([new Uint8Array([13]),e])),13===e[e.length-1]?(t=!0,e=e.subarray(0,-1)):t=!1;const n=[];for(let t=0;r=e.indexOf(10,t)+1,r;t=r)13!==e[r-2]&&n.push(r);if(!n.length)return e;const i=new Uint8Array(e.length+n.length);let s=0;for(let t=0;tt?new Uint8Array([13]):void 0))},nativeEOL:function(e){let t=!1;return C(e,(e=>{let r;13===(e=t&&10!==e[0]?G.concatUint8Array([new Uint8Array([13]),e]):new Uint8Array(e))[e.length-1]?(t=!0,e=e.subarray(0,-1)):t=!1;let n=0;for(let t=0;t!==e.length;t=r){r=e.indexOf(13,t)+1,r||(r=e.length);const i=r-(10===e[r]?1:0);t&&e.copyWithin(n,t,i),n+=i-t}return e.subarray(0,n)}),(()=>t?new Uint8Array([13]):void 0))},removeTrailingSpaces:function(e){return e.split("\n").map((e=>{let t=e.length-1;for(;t>=0&&(" "===e[t]||"\t"===e[t]||"\r"===e[t]);t--);return e.substr(0,t+1)})).join("\n")},wrapError:function(e,t){if(!t)return Error(e);try{t.message=e+": "+t.message}catch(e){}return t},constructAllowedPackets:function(e){const t={};return e.forEach((e=>{if(!e.tag)throw Error("Invalid input: expected a packet class");t[e.tag]=e})),t},anyPromise:function(e){return new Promise((async(t,r)=>{let n;await Promise.all(e.map((async e=>{try{t(await e)}catch(e){n=e}}))),r(n)}))},selectUint8Array:function(e,t,r){const n=Math.max(t.length,r.length),i=new Uint8Array(n);let s=0;for(let n=0;n{t=G.concatUint8Array([t,e]);const r=[],n=Math.floor(t.length/45),i=45*n,s=q(t.subarray(0,i));for(let e=0;et.length?q(t)+"\n":""))}function Z(e){let t="";return C(e,(e=>{t+=e;let r=0;const n=[" ","\t","\r","\n"];for(let e=0;e0&&(i-r)%4!=0;i--)n.includes(t[i])&&r--;const s=V(t.substr(0,i));return t=t.substr(i),s}),(()=>V(t)))}function Y(e){return Z(e.replace(/-/g,"+").replace(/_/g,"/"))}function J(e,t){let r=W(e).replace(/[\r\n]/g,"");return r=r.replace(/[+]/g,"-").replace(/[/]/g,"_").replace(/[=]/g,""),r}function $(e){const t=e.match(/^-----BEGIN PGP (MESSAGE, PART \d+\/\d+|MESSAGE, PART \d+|SIGNED MESSAGE|MESSAGE|PUBLIC KEY BLOCK|PRIVATE KEY BLOCK|SIGNATURE)-----$/m);if(!t)throw Error("Unknown ASCII armor type");return/MESSAGE, PART \d+\/\d+/.test(t[1])?H.armor.multipartSection:/MESSAGE, PART \d+/.test(t[1])?H.armor.multipartLast:/SIGNED MESSAGE/.test(t[1])?H.armor.signed:/MESSAGE/.test(t[1])?H.armor.message:/PUBLIC KEY BLOCK/.test(t[1])?H.armor.publicKey:/PRIVATE KEY BLOCK/.test(t[1])?H.armor.privateKey:/SIGNATURE/.test(t[1])?H.armor.signature:void 0}function X(e,t){let r="";return t.showVersion&&(r+="Version: "+t.versionString+"\n"),t.showComment&&(r+="Comment: "+t.commentString+"\n"),e&&(r+="Comment: "+e+"\n"),r+="\n",r}function ee(e){const t=function(e){let t=13501623;return C(e,(e=>{const r=re?Math.floor(e.length/4):0,n=new Uint32Array(e.buffer,e.byteOffset,r);for(let e=0;e>24&255]^te[1][t>>16&255]^te[2][t>>8&255]^te[3][255&t];for(let n=4*r;n>8^te[0][255&t^e[n]]}),(()=>new Uint8Array([t,t>>8,t>>16])))}(e);return W(t)}j?(q=e=>j.from(e).toString("base64"),V=e=>{const t=j.from(e,"base64");return new Uint8Array(t.buffer,t.byteOffset,t.byteLength)}):(q=e=>btoa(G.uint8ArrayToString(e)),V=e=>G.stringToUint8Array(atob(e)));const te=[Array(255),Array(255),Array(255),Array(255)];for(let e=0;e<=255;e++){let t=e<<16;for(let e=0;e<8;e++)t=t<<1^(8388608&t?8801531:0);te[0][e]=(16711680&t)>>16|65280&t|(255&t)<<16}for(let e=0;e<=255;e++)te[1][e]=te[0][e]>>8^te[0][255&te[0][e]];for(let e=0;e<=255;e++)te[2][e]=te[1][e]>>8^te[0][255&te[1][e]];for(let e=0;e<=255;e++)te[3][e]=te[2][e]>>8^te[0][255&te[2][e]];const re=function(){const e=new ArrayBuffer(2);return new DataView(e).setInt16(0,255,!0),255===new Int16Array(e)[0]}();function ne(e){for(let t=0;t=0&&r!==e.length-1&&(t=e.slice(0,r)),t}function se(e){return new Promise((async(t,r)=>{try{const n=/^-----[^-]+-----$/m,i=/^[ \f\r\t\u00a0\u2000-\u200a\u202f\u205f\u3000]*$/;let s;const a=[];let o,c,h=a,u=[];const l=Z(P(e,(async(e,y)=>{const f=F(e);try{for(;;){let e=await f.readLine();if(void 0===e)throw Error("Misformed armored text");if(e=G.removeTrailingSpaces(e.replace(/[\r\n]/g,"")),s)if(o)c||s!==H.armor.signed||(n.test(e)?(u=u.join("\r\n"),c=!0,ne(h),h=[],o=!1):u.push(e.replace(/^- /,"")));else if(n.test(e)&&r(Error("Mandatory blank line missing between armor headers and armor data")),i.test(e)){if(ne(h),o=!0,c||s!==H.armor.signed){t({text:u,data:l,headers:a,type:s});break}}else h.push(e);else n.test(e)&&(s=$(e))}}catch(e){return void r(e)}const g=N(y);try{for(;;){await g.ready;const{done:e,value:t}=await f.read();if(e)throw Error("Misformed armored text");const r=t+"";if(-1!==r.indexOf("=")||-1!==r.indexOf("-")){let e=await f.readToEnd();e.length||(e=""),e=r+e,e=G.removeTrailingSpaces(e.replace(/\r/g,""));const t=e.split(n);if(1===t.length)throw Error("Misformed armored text");const i=ie(t[0].slice(0,-1));await g.write(i);break}await g.write(r)}await g.ready,await g.close()}catch(e){await g.abort(e)}})))}catch(e){r(e)}})).then((async e=>(g(e.data)&&(e.data=await L(e.data)),e)))}function ae(e,t,r,n,i,s=!1,a=z){let o,c;e===H.armor.signed&&(o=t.text,c=t.hash,t=t.data);const h=s&&x(t),u=[];switch(e){case H.armor.multipartSection:u.push("-----BEGIN PGP MESSAGE, PART "+r+"/"+n+"-----\n"),u.push(X(i,a)),u.push(W(t)),h&&u.push("=",ee(h)),u.push("-----END PGP MESSAGE, PART "+r+"/"+n+"-----\n");break;case H.armor.multipartLast:u.push("-----BEGIN PGP MESSAGE, PART "+r+"-----\n"),u.push(X(i,a)),u.push(W(t)),h&&u.push("=",ee(h)),u.push("-----END PGP MESSAGE, PART "+r+"-----\n");break;case H.armor.signed:u.push("-----BEGIN PGP SIGNED MESSAGE-----\n"),u.push(c?`Hash: ${c}\n\n`:"\n"),u.push(o.replace(/^-/gm,"- -")),u.push("\n-----BEGIN PGP SIGNATURE-----\n"),u.push(X(i,a)),u.push(W(t)),h&&u.push("=",ee(h)),u.push("-----END PGP SIGNATURE-----\n");break;case H.armor.message:u.push("-----BEGIN PGP MESSAGE-----\n"),u.push(X(i,a)),u.push(W(t)),h&&u.push("=",ee(h)),u.push("-----END PGP MESSAGE-----\n");break;case H.armor.publicKey:u.push("-----BEGIN PGP PUBLIC KEY BLOCK-----\n"),u.push(X(i,a)),u.push(W(t)),h&&u.push("=",ee(h)),u.push("-----END PGP PUBLIC KEY BLOCK-----\n");break;case H.armor.privateKey:u.push("-----BEGIN PGP PRIVATE KEY BLOCK-----\n"),u.push(X(i,a)),u.push(W(t)),h&&u.push("=",ee(h)),u.push("-----END PGP PRIVATE KEY BLOCK-----\n");break;case H.armor.signature:u.push("-----BEGIN PGP SIGNATURE-----\n"),u.push(X(i,a)),u.push(W(t)),h&&u.push("=",ee(h)),u.push("-----END PGP SIGNATURE-----\n")}return G.concat(u)}async function oe(e){switch(e){case H.symmetric.aes128:case H.symmetric.aes192:case H.symmetric.aes256:throw Error("Not a legacy cipher");case H.symmetric.cast5:case H.symmetric.blowfish:case H.symmetric.twofish:case H.symmetric.tripledes:{const{legacyCiphers:t}=await Promise.resolve().then((function(){return Ay})),r=t.get(e);if(!r)throw Error("Unsupported cipher algorithm");return r}default:throw Error("Unsupported cipher algorithm")}}function ce(e){switch(e){case H.symmetric.aes128:case H.symmetric.aes192:case H.symmetric.aes256:case H.symmetric.twofish:return 16;case H.symmetric.blowfish:case H.symmetric.cast5:case H.symmetric.tripledes:return 8;default:throw Error("Unsupported cipher")}}function he(e){switch(e){case H.symmetric.aes128:case H.symmetric.blowfish:case H.symmetric.cast5:return 16;case H.symmetric.aes192:case H.symmetric.tripledes:return 24;case H.symmetric.aes256:case H.symmetric.twofish:return 32;default:throw Error("Unsupported cipher")}}function ue(e){return{keySize:he(e),blockSize:ce(e)}}var le=/*#__PURE__*/Object.freeze({__proto__:null,getCipherParams:ue,getLegacyCipher:oe});function ye(e,t){let r=e[0],n=e[1],i=e[2],s=e[3];r=ge(r,n,i,s,t[0],7,-680876936),s=ge(s,r,n,i,t[1],12,-389564586),i=ge(i,s,r,n,t[2],17,606105819),n=ge(n,i,s,r,t[3],22,-1044525330),r=ge(r,n,i,s,t[4],7,-176418897),s=ge(s,r,n,i,t[5],12,1200080426),i=ge(i,s,r,n,t[6],17,-1473231341),n=ge(n,i,s,r,t[7],22,-45705983),r=ge(r,n,i,s,t[8],7,1770035416),s=ge(s,r,n,i,t[9],12,-1958414417),i=ge(i,s,r,n,t[10],17,-42063),n=ge(n,i,s,r,t[11],22,-1990404162),r=ge(r,n,i,s,t[12],7,1804603682),s=ge(s,r,n,i,t[13],12,-40341101),i=ge(i,s,r,n,t[14],17,-1502002290),n=ge(n,i,s,r,t[15],22,1236535329),r=pe(r,n,i,s,t[1],5,-165796510),s=pe(s,r,n,i,t[6],9,-1069501632),i=pe(i,s,r,n,t[11],14,643717713),n=pe(n,i,s,r,t[0],20,-373897302),r=pe(r,n,i,s,t[5],5,-701558691),s=pe(s,r,n,i,t[10],9,38016083),i=pe(i,s,r,n,t[15],14,-660478335),n=pe(n,i,s,r,t[4],20,-405537848),r=pe(r,n,i,s,t[9],5,568446438),s=pe(s,r,n,i,t[14],9,-1019803690),i=pe(i,s,r,n,t[3],14,-187363961),n=pe(n,i,s,r,t[8],20,1163531501),r=pe(r,n,i,s,t[13],5,-1444681467),s=pe(s,r,n,i,t[2],9,-51403784),i=pe(i,s,r,n,t[7],14,1735328473),n=pe(n,i,s,r,t[12],20,-1926607734),r=de(r,n,i,s,t[5],4,-378558),s=de(s,r,n,i,t[8],11,-2022574463),i=de(i,s,r,n,t[11],16,1839030562),n=de(n,i,s,r,t[14],23,-35309556),r=de(r,n,i,s,t[1],4,-1530992060),s=de(s,r,n,i,t[4],11,1272893353),i=de(i,s,r,n,t[7],16,-155497632),n=de(n,i,s,r,t[10],23,-1094730640),r=de(r,n,i,s,t[13],4,681279174),s=de(s,r,n,i,t[0],11,-358537222),i=de(i,s,r,n,t[3],16,-722521979),n=de(n,i,s,r,t[6],23,76029189),r=de(r,n,i,s,t[9],4,-640364487),s=de(s,r,n,i,t[12],11,-421815835),i=de(i,s,r,n,t[15],16,530742520),n=de(n,i,s,r,t[2],23,-995338651),r=Ae(r,n,i,s,t[0],6,-198630844),s=Ae(s,r,n,i,t[7],10,1126891415),i=Ae(i,s,r,n,t[14],15,-1416354905),n=Ae(n,i,s,r,t[5],21,-57434055),r=Ae(r,n,i,s,t[12],6,1700485571),s=Ae(s,r,n,i,t[3],10,-1894986606),i=Ae(i,s,r,n,t[10],15,-1051523),n=Ae(n,i,s,r,t[1],21,-2054922799),r=Ae(r,n,i,s,t[8],6,1873313359),s=Ae(s,r,n,i,t[15],10,-30611744),i=Ae(i,s,r,n,t[6],15,-1560198380),n=Ae(n,i,s,r,t[13],21,1309151649),r=Ae(r,n,i,s,t[4],6,-145523070),s=Ae(s,r,n,i,t[11],10,-1120210379),i=Ae(i,s,r,n,t[2],15,718787259),n=Ae(n,i,s,r,t[9],21,-343485551),e[0]=ke(r,e[0]),e[1]=ke(n,e[1]),e[2]=ke(i,e[2]),e[3]=ke(s,e[3])}function fe(e,t,r,n,i,s){return t=ke(ke(t,e),ke(n,s)),ke(t<>>32-i,r)}function ge(e,t,r,n,i,s,a){return fe(t&r|~t&n,e,t,i,s,a)}function pe(e,t,r,n,i,s,a){return fe(t&n|r&~n,e,t,i,s,a)}function de(e,t,r,n,i,s,a){return fe(t^r^n,e,t,i,s,a)}function Ae(e,t,r,n,i,s,a){return fe(r^(t|~n),e,t,i,s,a)}function we(e){const t=[];let r;for(r=0;r<64;r+=4)t[r>>2]=e.charCodeAt(r)+(e.charCodeAt(r+1)<<8)+(e.charCodeAt(r+2)<<16)+(e.charCodeAt(r+3)<<24);return t}const me="0123456789abcdef".split("");function be(e){let t="",r=0;for(;r<4;r++)t+=me[e>>8*r+4&15]+me[e>>8*r&15];return t}function ke(e,t){return e+t&4294967295}const Ee=G.getWebCrypto(),ve=G.getNodeCrypto(),Be=ve&&ve.getHashes();function Ie(e){if(ve&&Be.includes(e))return async function(t){const r=ve.createHash(e);return C(t,(e=>{r.update(e)}),(()=>new Uint8Array(r.digest())))}}function Se(e,t){const r=async()=>{const{nobleHashes:t}=await Promise.resolve().then((function(){return My})),r=t.get(e);if(!r)throw Error("Unsupported hash");return r};return async function(e){if(g(e)&&(e=await L(e)),G.isStream(e)){const t=(await r()).create();return C(e,(e=>{t.update(e)}),(()=>t.digest()))}if(Ee&&t)return new Uint8Array(await Ee.digest(t,e));return(await r())(e)}}var Ke={md5:Ie("md5")||async function(e){const t=function(e){const t=e.length,r=[1732584193,-271733879,-1732584194,271733878];let n;for(n=64;n<=e.length;n+=64)ye(r,we(e.substring(n-64,n)));e=e.substring(n-64);const i=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0];for(n=0;n>2]|=e.charCodeAt(n)<<(n%4<<3);if(i[n>>2]|=128<<(n%4<<3),n>55)for(ye(r,i),n=0;n<16;n++)i[n]=0;return i[14]=8*t,ye(r,i),r}(G.uint8ArrayToString(e));return G.hexToUint8Array(function(e){for(let t=0;t0&&!t.includes(e.length))throw Error(`Uint8Array expected of length ${t}, not of length=${e.length}`)}function Ue(e,t=!0){if(e.destroyed)throw Error("Hash instance has been destroyed");if(t&&e.finished)throw Error("Hash#digest() has already been called")}function De(e,t){Pe(e);const r=t.outputLen;if(e.lengthnew Uint8Array(e.buffer,e.byteOffset,e.byteLength),Qe=e=>new Uint32Array(e.buffer,e.byteOffset,Math.floor(e.byteLength/4)),Re=e=>new DataView(e.buffer,e.byteOffset,e.byteLength);if(!(68===new Uint8Array(new Uint32Array([287454020]).buffer)[0]))throw Error("Non little-endian hardware is not supported");function Le(e){if("string"==typeof e)e=function(e){if("string"!=typeof e)throw Error("string expected, got "+typeof e);return new Uint8Array((new TextEncoder).encode(e))}(e);else{if(!Ce(e))throw Error("Uint8Array expected, got "+typeof e);e=Oe(e)}return e}function Me(e,t){if(e.length!==t.length)return!1;let r=0;for(let n=0;n(Object.assign(t,e),t);function Fe(e,t,r,n){if("function"==typeof e.setBigUint64)return e.setBigUint64(t,r,n);const i=BigInt(32),s=BigInt(4294967295),a=Number(r>>i&s),o=Number(r&s);e.setUint32(t+0,a,n),e.setUint32(t+4,o,n)}function Ne(e){return e.byteOffset%4==0}function Oe(e){return Uint8Array.from(e)}function He(...e){for(let t=0;t(e>>>0&255)<<24|(e>>>8&255)<<16|(e>>>16&255)<<8|e>>>24&255;class qe{constructor(e,t){this.blockLen=ze,this.outputLen=ze,this.s0=0,this.s1=0,this.s2=0,this.s3=0,this.finished=!1,Pe(e=Le(e),16);const r=Re(e);let n=r.getUint32(0,!1),i=r.getUint32(4,!1),s=r.getUint32(8,!1),a=r.getUint32(12,!1);const o=[];for(let e=0;e<128;e++)o.push({s0:je(n),s1:je(i),s2:je(s),s3:je(a)}),({s0:n,s1:i,s2:s,s3:a}={s3:(u=s)<<31|(l=a)>>>1,s2:(h=i)<<31|u>>>1,s1:(c=n)<<31|h>>>1,s0:c>>>1^225<<24&-(1&l)});var c,h,u,l;const y=(e=>e>65536?8:e>1024?4:2)(t||1024);if(![1,2,4,8].includes(y))throw Error(`ghash: wrong window size=${y}, should be 2, 4 or 8`);this.W=y;const f=128/y,g=this.windowSize=2**y,p=[];for(let e=0;e>>y-a-1&1))continue;const{s0:c,s1:h,s2:u,s3:l}=o[y*e+a];r^=c,n^=h,i^=u,s^=l}p.push({s0:r,s1:n,s2:i,s3:s})}this.t=p}_updateBlock(e,t,r,n){e^=this.s0,t^=this.s1,r^=this.s2,n^=this.s3;const{W:i,t:s,windowSize:a}=this;let o=0,c=0,h=0,u=0;const l=(1<>>8*e&255;for(let e=8/i-1;e>=0;e--){const r=t>>>i*e&l,{s0:n,s1:f,s2:g,s3:p}=s[y*a+r];o^=n,c^=f,h^=g,u^=p,y+=1}}this.s0=o,this.s1=c,this.s2=h,this.s3=u}update(e){e=Le(e),Ue(this);const t=Qe(e),r=Math.floor(e.length/ze),n=e.length%ze;for(let e=0;e>>1|r,r=(1&n)<<7}return e[0]^=225&-t,e}(Oe(e=Le(e)));super(r,t),He(r)}update(e){e=Le(e),Ue(this);const t=Qe(e),r=e.length%ze,n=Math.floor(e.length/ze);for(let e=0;ee(r,t.length).update(Le(t)).digest(),r=e(new Uint8Array(16),0);return t.outputLen=r.outputLen,t.blockLen=r.blockLen,t.create=(t,r)=>e(t,r),t}const Ze=We(((e,t)=>new qe(e,t)));We(((e,t)=>new Ve(e,t)));const Ye=16,Je=new Uint8Array(Ye),$e=283;function Xe(e){return e<<1^$e&-(e>>7)}function et(e,t){let r=0;for(;t>0;t>>=1)r^=e&-(1&t),e=Xe(e);return r}const tt=/* @__PURE__ */(()=>{const e=new Uint8Array(256);for(let t=0,r=1;t<256;t++,r^=Xe(r))e[t]=r;const t=new Uint8Array(256);t[0]=99;for(let r=0;r<255;r++){let n=e[255-r];n|=n<<8,t[e[r]]=255&(n^n>>4^n>>5^n>>6^n>>7^99)}return He(e),t})(),rt=/* @__PURE__ */tt.map(((e,t)=>tt.indexOf(t))),nt=e=>e<<24|e>>>8,it=e=>e<<8|e>>>24,st=e=>e<<24&4278190080|e<<8&16711680|e>>>8&65280|e>>>24&255;function at(e,t){if(256!==e.length)throw Error("Wrong sbox length");const r=new Uint32Array(256).map(((r,n)=>t(e[n]))),n=r.map(it),i=n.map(it),s=i.map(it),a=new Uint32Array(65536),o=new Uint32Array(65536),c=new Uint16Array(65536);for(let t=0;t<256;t++)for(let h=0;h<256;h++){const u=256*t+h;a[u]=r[t]^n[h],o[u]=i[t]^s[h],c[u]=e[t]<<8|e[h]}return{sbox:e,sbox2:c,T0:r,T1:n,T2:i,T3:s,T01:a,T23:o}}const ot=/* @__PURE__ */at(tt,(e=>et(e,3)<<24|e<<16|e<<8|et(e,2))),ct=/* @__PURE__ */at(rt,(e=>et(e,11)<<24|et(e,13)<<16|et(e,9)<<8|et(e,14))),ht=/* @__PURE__ */(()=>{const e=new Uint8Array(16);for(let t=0,r=1;t<16;t++,r=Xe(r))e[t]=r;return e})();function ut(e){Pe(e);const t=e.length;if(![16,24,32].includes(t))throw Error("aes: wrong key size: should be 16, 24 or 32, got: "+t);const{sbox2:r}=ot,n=[];Ne(e)||n.push(e=Oe(e));const i=Qe(e),s=i.length,a=e=>ft(r,e,e,e,e),o=new Uint32Array(t+28);o.set(i);for(let e=s;e6&&e%s==4&&(t=a(t)),o[e]=o[e-s]^t}return He(...n),o}function lt(e){const t=ut(e),r=t.slice(),n=t.length,{sbox2:i}=ot,{T0:s,T1:a,T2:o,T3:c}=ct;for(let e=0;e>>8&255]^o[n>>>16&255]^c[n>>>24]}return r}function yt(e,t,r,n,i,s){return e[r<<8&65280|n>>>8&255]^t[i>>>8&65280|s>>>24&255]}function ft(e,t,r,n,i){return e[255&t|65280&r]|e[n>>>16&255|i>>>16&65280]<<16}function gt(e,t,r,n,i){const{sbox2:s,T01:a,T23:o}=ot;let c=0;t^=e[c++],r^=e[c++],n^=e[c++],i^=e[c++];const h=e.length/4-2;for(let s=0;s=0;e--)r=r+(255&s[e])|0,s[e]=255&r,r>>>=8;({s0:o,s1:c,s2:h,s3:u}=gt(e,a[0],a[1],a[2],a[3]))}const f=Ye*Math.floor(l.length/4);if(f>>0,o.setUint32(u,y,t),({s0:f,s1:g,s2:p,s3:d}=gt(e,a[0],a[1],a[2],a[3]));const A=Ye*Math.floor(c.length/4);if(Ar(e,t),decrypt:(e,t)=>r(e,t)}}));const bt=Te({blockSize:16,nonceLength:16},(function(e,t,r={}){Pe(e),Pe(t,16);const n=!r.disablePadding;return{encrypt(r,i){const s=ut(e),{b:a,o,out:c}=function(e,t,r){Pe(e);let n=e.length;const i=n%Ye;if(!t&&0!==i)throw Error("aec/(cbc-ecb): unpadded plaintext with disabled padding");Ne(e)||(e=Oe(e));const s=Qe(e);if(t){let e=Ye-i;e||(e=Ye),n+=e}const a=dt(n,r);return{b:s,o:Qe(a),out:a}}(r,n,i);let h=t;const u=[s];Ne(h)||u.push(h=Oe(h));const l=Qe(h);let y=l[0],f=l[1],g=l[2],p=l[3],d=0;for(;d+4<=a.length;)y^=a[d+0],f^=a[d+1],g^=a[d+2],p^=a[d+3],({s0:y,s1:f,s2:g,s3:p}=gt(s,y,f,g,p)),o[d++]=y,o[d++]=f,o[d++]=g,o[d++]=p;if(n){const e=function(e){const t=new Uint8Array(16),r=Qe(t);t.set(e);const n=Ye-e.length;for(let e=Ye-n;e16)throw Error("aes/pcks5: wrong padding");const i=e.subarray(0,-n);for(let t=0;tr(e,!0,t),decrypt:(e,t)=>r(e,!1,t)}}));const Et=Te({blockSize:16,nonceLength:12,tagLength:16},(function(e,t,r){if(Pe(e),Pe(t),void 0!==r&&Pe(r),t.length<8)throw Error("aes/gcm: invalid nonce length");const n=16;function i(e,t,n){const i=function(e,t,r,n,i){const s=null==i?0:i.length,a=e.create(r,n.length+s);i&&a.update(i),a.update(n);const o=new Uint8Array(16),c=Re(o);i&&Fe(c,0,BigInt(8*s),t),Fe(c,8,BigInt(8*n.length),t),a.update(o);const h=a.digest();return He(o),h}(Ze,!1,e,n,r);for(let e=0;e=2**32)throw Error("plaintext should be less than 4gb");const r=ut(e);if(16===t.length)Bt(r,t);else{const e=Qe(t);let n=e[0],i=e[1];for(let t=0,s=1;t<6;t++)for(let t=2;t=2**32)throw Error("ciphertext should be less than 4gb");const r=lt(e),n=t.length/8-1;if(1===n)It(r,t);else{const e=Qe(t);let i=e[0],s=e[1];for(let t=0,a=6*n;t<6;t++)for(let t=2*n;t>=1;t-=2,a--){s^=st(a);const{s0:n,s1:o,s2:c,s3:h}=pt(r,i,s,e[t],e[t+1]);i=n,s=o,e[t]=c,e[t+1]=h}e[0]=i,e[1]=s}r.fill(0)}},Kt=new Uint8Array(8).fill(166),Ct=Te({blockSize:8},(e=>({encrypt(t){if(Pe(t),!t.length||t.length%8!=0)throw Error("invalid plaintext length");if(8===t.length)throw Error("8-byte keys not allowed in AESKW, use AESKWP instead");const r=function(...e){let t=0;for(let r=0;r!0),(()=>!1))}async _runCBC(e,t){const r="AES-CBC";this.keyRef=this.keyRef||await Ut.importKey("raw",this.key,r,!1,["encrypt"]);const n=await Ut.encrypt({name:r,iv:t||this.zeroBlock},this.keyRef,e);return new Uint8Array(n).subarray(0,e.length)}async encryptChunk(e){const t=this.nextBlock.length-this.i,r=e.subarray(0,t);if(this.nextBlock.set(r,this.i),this.i+e.length>=2*this.blockSize){const r=(e.length-t)%this.blockSize,n=G.concatUint8Array([this.nextBlock,e.subarray(t,e.length-r)]),i=G.concatUint8Array([this.prevBlock,n.subarray(0,n.length-this.blockSize)]),s=await this._runCBC(i);return Mt(s,n),this.prevBlock=s.slice(-this.blockSize),r>0&&this.nextBlock.set(e.subarray(-r)),this.i=r,s}let n;if(this.i+=r.length,this.i===this.nextBlock.length){const t=this.nextBlock;n=await this._runCBC(this.prevBlock),Mt(n,t),this.prevBlock=n.slice(),this.i=0;const i=e.subarray(r.length);this.nextBlock.set(i,this.i),this.i+=i.length}else n=new Uint8Array;return n}async finish(){let e;if(0===this.i)e=new Uint8Array;else{this.nextBlock=this.nextBlock.subarray(0,this.i);const t=this.nextBlock,r=await this._runCBC(this.prevBlock);Mt(r,t),e=r.subarray(0,t.length)}return this.clearSensitiveData(),e}clearSensitiveData(){this.nextBlock.fill(0),this.prevBlock.fill(0),this.keyRef=null,this.key=null}async encrypt(e){const t=(await this._runCBC(G.concatUint8Array([new Uint8Array(this.blockSize),e]),this.iv)).subarray(0,e.length);return Mt(t,e),this.clearSensitiveData(),t}}class Lt{constructor(e,t,r,n){this.forEncryption=e;const{blockSize:i}=ue(t);this.key=Pt.expandKeyLE(r),n.byteOffset%4!=0&&(n=n.slice()),this.prevBlock=Tt(n),this.nextBlock=new Uint8Array(i),this.i=0,this.blockSize=i}_runCFB(e){const t=Tt(e),r=new Uint8Array(e.length),n=Tt(r);for(let e=0;e+4<=n.length;e+=4){const{s0:r,s1:i,s2:s,s3:a}=Pt.encrypt(this.key,this.prevBlock[0],this.prevBlock[1],this.prevBlock[2],this.prevBlock[3]);n[e+0]=t[e+0]^r,n[e+1]=t[e+1]^i,n[e+2]=t[e+2]^s,n[e+3]=t[e+3]^a,this.prevBlock=(this.forEncryption?n:t).slice(e,e+4)}return r}async processChunk(e){const t=this.nextBlock.length-this.i,r=e.subarray(0,t);if(this.nextBlock.set(r,this.i),this.i+e.length>=2*this.blockSize){const r=(e.length-t)%this.blockSize,n=G.concatUint8Array([this.nextBlock,e.subarray(t,e.length-r)]),i=this._runCFB(n);return r>0&&this.nextBlock.set(e.subarray(-r)),this.i=r,i}let n;if(this.i+=r.length,this.i===this.nextBlock.length){n=this._runCFB(this.nextBlock),this.i=0;const t=e.subarray(r.length);this.nextBlock.set(t,this.i),this.i+=t.length}else n=new Uint8Array;return n}async finish(){let e;if(0===this.i)e=new Uint8Array;else{e=this._runCFB(this.nextBlock).subarray(0,this.i)}return this.clearSensitiveData(),e}clearSensitiveData(){this.nextBlock.fill(0),this.prevBlock.fill(0),this.key.fill(0)}}function Mt(e,t){const r=Math.min(e.length,t.length);for(let n=0;nnew Uint32Array(e.buffer,e.byteOffset,Math.floor(e.byteLength/4));var Ft=/*#__PURE__*/Object.freeze({__proto__:null,decrypt:async function(e,t,r,n){const i=H.read(H.symmetric,e);if(Dt&&Qt[i])return function(e,t,r,n){const i=H.read(H.symmetric,e),s=new Dt.createDecipheriv(Qt[i],t,n);return C(r,(e=>new Uint8Array(s.update(e))))}(e,t,r,n);if(G.isAES(e))return async function(e,t,r,n){if(G.isStream(r)){const i=new Lt(!1,e,t,n);return C(r,(e=>i.processChunk(e)),(()=>i.finish()))}return kt(t,n).decrypt(r)}(e,t,r,n);const s=new(await oe(e))(t),a=s.blockSize;let o=n,c=new Uint8Array;const h=e=>{e&&(c=G.concatUint8Array([c,e]));const t=new Uint8Array(c.length);let r,n=0;for(;e?c.length>=a:c.length;){const e=s.encrypt(o);for(o=c.subarray(0,a),r=0;rnew Uint8Array(s.update(e))))}(e,t,r,n);if(G.isAES(e))return async function(e,t,r,n){if(Ut&&await Rt.isSupported(e)){const i=new Rt(e,t,n);return G.isStream(r)?C(r,(e=>i.encryptChunk(e)),(()=>i.finish())):i.encrypt(r)}if(G.isStream(r)){const i=new Lt(!0,e,t,n);return C(r,(e=>i.processChunk(e)),(()=>i.finish()))}return kt(t,n).encrypt(r)}(e,t,r,n);const a=new(await oe(e))(t),o=a.blockSize,c=n.slice();let h=new Uint8Array;const u=e=>{e&&(h=G.concatUint8Array([h,e]));const t=new Uint8Array(h.length);let r,n=0;for(;e?h.length>=o:h.length;){const e=a.encrypt(c);for(r=0;ri.encrypt(e),a=e=>i.decrypt(e);let o;function c(e,t,r,i){const a=t.length/ir|0;!function(e,t){const r=G.nbits(Math.max(e.length,t.length)/ir|0)-1;for(let e=n+1;e<=r;e++)o[e]=G.double(o[e-1]);n=r}(t,i);const c=G.concatUint8Array([hr.subarray(0,15-r.length),ur,r]),h=63&c[15];c[15]&=192;const u=s(c),l=G.concatUint8Array([u,cr(u.subarray(0,8),u.subarray(1,9))]),y=G.shiftRight(l.subarray(0+(h>>3),17+(h>>3)),8-(7&h)).subarray(1),f=new Uint8Array(ir),g=new Uint8Array(t.length+sr);let p,d=0;for(p=0;p{r+=t[e>>4]+t[15&e]})),BigInt("0x0"+r)}function Er(e,t){const r=e%t;return rmr;){const e=n&br;n>>=br;s=e?s*i%r:s,i=i*i%r}return s}function Br(e){return e>=mr?e:-e}function Ir(e,t){const{gcd:r,x:n}=function(e,t){let r=BigInt(0),n=BigInt(1),i=BigInt(1),s=BigInt(0),a=Br(e),o=Br(t);const c=eNumber.MAX_SAFE_INTEGER)throw Error("Number can only safely store up to 53 bits");return t}function Kr(e,t){return(e>>BigInt(t)&br)===mr?0:1}function Cr(e){const t=e>=br)!==t;)r++;return r}function Pr(e){const t=e>=r)!==t;)n++;return n}function Ur(e,t="be",r){let n=e.toString(16);n.length%2==1&&(n="0"+n);const i=n.length/2,s=new Uint8Array(r||i),a=r?r-i:0;let o=0;for(;oe&&(a=Er(a,i<Er(e,r)!==t))}(e)&&(!!function(e,t=BigInt(2)){return vr(t,e-Lr,e)===Lr}(e)&&!!function(e,t){const r=Cr(e);t||(t=Math.max(1,r/48|0));const n=e-Lr;let i=0;for(;!Kr(n,i);)i++;const s=e>>BigInt(i);for(;t>0;t--){let t,r=vr(Qr(BigInt(2),n),s,e);if(r!==Lr&&r!==n){for(t=1;tBigInt(e)));const Nr=[];function Or(e,t){const r=e.length;if(r>t-11)throw Error("Message too long");const n=function(e){const t=new Uint8Array(e);let r=0;for(;r=8&!n;if(t)return G.selectUint8Array(a,s,t);if(a)return s;throw Error("Decryption error")}function zr(e,t,r){let n;if(t.length!==Ke.getHashByteLength(e))throw Error("Invalid hash length");const i=new Uint8Array(Nr[e].length);for(n=0;n=t)throw Error("Data too large.");const c=Er(n,s-qr),h=Er(n,i-qr),u=Qr(BigInt(2),t),l=vr(Ir(u,t),r,t);e=Er(e*l,t);const y=vr(e,h,i),f=vr(e,c,s),g=Er(a*(f-y),s);let p=g*i+y;return p=Er(p*u,t),Hr(Ur(p,"be",Pr(t)),o)}(e,t,r,n,i,s,a,o)},encrypt:async function(e,t,r){return G.getNodeCrypto()?async function(e,t,r){const n=Wr(t,r),i={key:n,format:"jwk",type:"pkcs1",padding:jr.constants.RSA_PKCS1_PADDING};return new Uint8Array(jr.publicEncrypt(i,e))}(e,t,r):async function(e,t,r){if(t=kr(t),e=kr(Or(e,Pr(t))),r=kr(r),e>=t)throw Error("Message size cannot exceed modulus size");return Ur(vr(e,r,t),"be",Pr(t))}(e,t,r)},generate:async function(e,t){if(t=BigInt(t),G.getWebCrypto()){const r={name:"RSASSA-PKCS1-v1_5",modulusLength:e,publicExponent:Ur(t),hash:{name:"SHA-1"}},n=await Gr.generateKey(r,!0,["sign","verify"]);return Zr(await Gr.exportKey("jwk",n.privateKey),t)}if(G.getNodeCrypto()){const r={modulusLength:e,publicExponent:Sr(t),publicKeyEncoding:{type:"pkcs1",format:"jwk"},privateKeyEncoding:{type:"pkcs1",format:"jwk"}},n=await new Promise(((e,t)=>{jr.generateKeyPair("rsa",r,((r,n,i)=>{r?t(r):e(i)}))}));return Zr(n,t)}let r,n,i;do{n=Mr(e-(e>>1),t,40),r=Mr(e>>1,t,40),i=r*n}while(Cr(i)!==e);const s=(r-qr)*(n-qr);return n=r.length)throw Error("Digest size cannot exceed key modulus size");if(t&&!G.isStream(t))if(G.getWebCrypto())try{return await async function(e,t,r,n,i,s,a,o){const c=await Vr(r,n,i,s,a,o),h={name:"RSASSA-PKCS1-v1_5",hash:{name:e}},u=await Gr.importKey("jwk",c,h,!1,["sign"]);return new Uint8Array(await Gr.sign("RSASSA-PKCS1-v1_5",u,t))}(H.read(H.webHash,e),t,r,n,i,s,a,o)}catch(e){G.printDebugError(e)}else if(G.getNodeCrypto())return async function(e,t,r,n,i,s,a,o){const c=jr.createSign(H.read(H.hash,e));c.write(t),c.end();const h=await Vr(r,n,i,s,a,o);return new Uint8Array(c.sign({key:h,format:"jwk",type:"pkcs1"}))}(e,t,r,n,i,s,a,o);return async function(e,t,r,n){t=kr(t);const i=kr(zr(e,n,Pr(t)));return r=kr(r),Ur(vr(i,r,t),"be",Pr(t))}(e,r,i,c)},validateParams:async function(e,t,r,n,i,s){if(e=kr(e),(n=kr(n))*(i=kr(i))!==e)return!1;const a=BigInt(2);if(Er(n*(s=kr(s)),i)!==BigInt(1))return!1;t=kr(t),r=kr(r);const o=Qr(a,a<=r)throw Error("Signature size cannot exceed modulus size");const s=Ur(vr(t,n,r),"be",Pr(r)),a=zr(e,i,Pr(r));return G.equalsUint8Array(s,a)}(e,r,n,i,s)}});const Jr=BigInt(1);var $r=/*#__PURE__*/Object.freeze({__proto__:null,decrypt:async function(e,t,r,n,i){return e=kr(e),t=kr(t),r=kr(r),Hr(Ur(Er(Ir(vr(e,n=kr(n),r),r)*t,r),"be",Pr(r)),i)},encrypt:async function(e,t,r,n){t=kr(t),r=kr(r),n=kr(n);const i=kr(Or(e,Pr(t))),s=Qr(Jr,t-Jr);return{c1:Ur(vr(r,s,t)),c2:Ur(Er(vr(n,s,t)*i,t))}},validateParams:async function(e,t,r,n){if(e=kr(e),t=kr(t),r=kr(r),t<=Jr||t>=e)return!1;const i=BigInt(Cr(e));if(i>24&255,e[t+1]=r>>16&255,e[t+2]=r>>8&255,e[t+3]=255&r,e[t+4]=n>>24&255,e[t+5]=n>>16&255,e[t+6]=n>>8&255,e[t+7]=255&n}function gn(e,t,r,n){return function(e,t,r,n,i){var s,a=0;for(s=0;s>>8)-1}(e,t,r,n,32)}function pn(e,t){var r;for(r=0;r<16;r++)e[r]=0|t[r]}function dn(e){var t,r,n=1;for(t=0;t<16;t++)r=e[t]+n+65535,n=Math.floor(r/65536),e[t]=r-65536*n;e[0]+=n-1+37*(n-1)}function An(e,t,r){for(var n,i=~(r-1),s=0;s<16;s++)n=i&(e[s]^t[s]),e[s]^=n,t[s]^=n}function wn(e,t){var r,n,i,s=tn(),a=tn();for(r=0;r<16;r++)a[r]=t[r];for(dn(a),dn(a),dn(a),n=0;n<2;n++){for(s[0]=a[0]-65517,r=1;r<15;r++)s[r]=a[r]-65535-(s[r-1]>>16&1),s[r-1]&=65535;s[15]=a[15]-32767-(s[14]>>16&1),i=s[15]>>16&1,s[14]&=65535,An(a,s,1-i)}for(r=0;r<16;r++)e[2*r]=255&a[r],e[2*r+1]=a[r]>>8}function mn(e,t){var r=new Uint8Array(32),n=new Uint8Array(32);return wn(r,e),wn(n,t),gn(r,0,n,0)}function bn(e){var t=new Uint8Array(32);return wn(t,e),1&t[0]}function kn(e,t){var r;for(r=0;r<16;r++)e[r]=t[2*r]+(t[2*r+1]<<8);e[15]&=32767}function En(e,t,r){for(var n=0;n<16;n++)e[n]=t[n]+r[n]}function vn(e,t,r){for(var n=0;n<16;n++)e[n]=t[n]-r[n]}function Bn(e,t,r){var n,i,s=0,a=0,o=0,c=0,h=0,u=0,l=0,y=0,f=0,g=0,p=0,d=0,A=0,w=0,m=0,b=0,k=0,E=0,v=0,B=0,I=0,S=0,K=0,C=0,P=0,U=0,D=0,x=0,Q=0,R=0,L=0,M=r[0],T=r[1],F=r[2],N=r[3],O=r[4],H=r[5],z=r[6],_=r[7],G=r[8],j=r[9],q=r[10],V=r[11],W=r[12],Z=r[13],Y=r[14],J=r[15];s+=(n=t[0])*M,a+=n*T,o+=n*F,c+=n*N,h+=n*O,u+=n*H,l+=n*z,y+=n*_,f+=n*G,g+=n*j,p+=n*q,d+=n*V,A+=n*W,w+=n*Z,m+=n*Y,b+=n*J,a+=(n=t[1])*M,o+=n*T,c+=n*F,h+=n*N,u+=n*O,l+=n*H,y+=n*z,f+=n*_,g+=n*G,p+=n*j,d+=n*q,A+=n*V,w+=n*W,m+=n*Z,b+=n*Y,k+=n*J,o+=(n=t[2])*M,c+=n*T,h+=n*F,u+=n*N,l+=n*O,y+=n*H,f+=n*z,g+=n*_,p+=n*G,d+=n*j,A+=n*q,w+=n*V,m+=n*W,b+=n*Z,k+=n*Y,E+=n*J,c+=(n=t[3])*M,h+=n*T,u+=n*F,l+=n*N,y+=n*O,f+=n*H,g+=n*z,p+=n*_,d+=n*G,A+=n*j,w+=n*q,m+=n*V,b+=n*W,k+=n*Z,E+=n*Y,v+=n*J,h+=(n=t[4])*M,u+=n*T,l+=n*F,y+=n*N,f+=n*O,g+=n*H,p+=n*z,d+=n*_,A+=n*G,w+=n*j,m+=n*q,b+=n*V,k+=n*W,E+=n*Z,v+=n*Y,B+=n*J,u+=(n=t[5])*M,l+=n*T,y+=n*F,f+=n*N,g+=n*O,p+=n*H,d+=n*z,A+=n*_,w+=n*G,m+=n*j,b+=n*q,k+=n*V,E+=n*W,v+=n*Z,B+=n*Y,I+=n*J,l+=(n=t[6])*M,y+=n*T,f+=n*F,g+=n*N,p+=n*O,d+=n*H,A+=n*z,w+=n*_,m+=n*G,b+=n*j,k+=n*q,E+=n*V,v+=n*W,B+=n*Z,I+=n*Y,S+=n*J,y+=(n=t[7])*M,f+=n*T,g+=n*F,p+=n*N,d+=n*O,A+=n*H,w+=n*z,m+=n*_,b+=n*G,k+=n*j,E+=n*q,v+=n*V,B+=n*W,I+=n*Z,S+=n*Y,K+=n*J,f+=(n=t[8])*M,g+=n*T,p+=n*F,d+=n*N,A+=n*O,w+=n*H,m+=n*z,b+=n*_,k+=n*G,E+=n*j,v+=n*q,B+=n*V,I+=n*W,S+=n*Z,K+=n*Y,C+=n*J,g+=(n=t[9])*M,p+=n*T,d+=n*F,A+=n*N,w+=n*O,m+=n*H,b+=n*z,k+=n*_,E+=n*G,v+=n*j,B+=n*q,I+=n*V,S+=n*W,K+=n*Z,C+=n*Y,P+=n*J,p+=(n=t[10])*M,d+=n*T,A+=n*F,w+=n*N,m+=n*O,b+=n*H,k+=n*z,E+=n*_,v+=n*G,B+=n*j,I+=n*q,S+=n*V,K+=n*W,C+=n*Z,P+=n*Y,U+=n*J,d+=(n=t[11])*M,A+=n*T,w+=n*F,m+=n*N,b+=n*O,k+=n*H,E+=n*z,v+=n*_,B+=n*G,I+=n*j,S+=n*q,K+=n*V,C+=n*W,P+=n*Z,U+=n*Y,D+=n*J,A+=(n=t[12])*M,w+=n*T,m+=n*F,b+=n*N,k+=n*O,E+=n*H,v+=n*z,B+=n*_,I+=n*G,S+=n*j,K+=n*q,C+=n*V,P+=n*W,U+=n*Z,D+=n*Y,x+=n*J,w+=(n=t[13])*M,m+=n*T,b+=n*F,k+=n*N,E+=n*O,v+=n*H,B+=n*z,I+=n*_,S+=n*G,K+=n*j,C+=n*q,P+=n*V,U+=n*W,D+=n*Z,x+=n*Y,Q+=n*J,m+=(n=t[14])*M,b+=n*T,k+=n*F,E+=n*N,v+=n*O,B+=n*H,I+=n*z,S+=n*_,K+=n*G,C+=n*j,P+=n*q,U+=n*V,D+=n*W,x+=n*Z,Q+=n*Y,R+=n*J,b+=(n=t[15])*M,a+=38*(E+=n*F),o+=38*(v+=n*N),c+=38*(B+=n*O),h+=38*(I+=n*H),u+=38*(S+=n*z),l+=38*(K+=n*_),y+=38*(C+=n*G),f+=38*(P+=n*j),g+=38*(U+=n*q),p+=38*(D+=n*V),d+=38*(x+=n*W),A+=38*(Q+=n*Z),w+=38*(R+=n*Y),m+=38*(L+=n*J),s=(n=(s+=38*(k+=n*T))+(i=1)+65535)-65536*(i=Math.floor(n/65536)),a=(n=a+i+65535)-65536*(i=Math.floor(n/65536)),o=(n=o+i+65535)-65536*(i=Math.floor(n/65536)),c=(n=c+i+65535)-65536*(i=Math.floor(n/65536)),h=(n=h+i+65535)-65536*(i=Math.floor(n/65536)),u=(n=u+i+65535)-65536*(i=Math.floor(n/65536)),l=(n=l+i+65535)-65536*(i=Math.floor(n/65536)),y=(n=y+i+65535)-65536*(i=Math.floor(n/65536)),f=(n=f+i+65535)-65536*(i=Math.floor(n/65536)),g=(n=g+i+65535)-65536*(i=Math.floor(n/65536)),p=(n=p+i+65535)-65536*(i=Math.floor(n/65536)),d=(n=d+i+65535)-65536*(i=Math.floor(n/65536)),A=(n=A+i+65535)-65536*(i=Math.floor(n/65536)),w=(n=w+i+65535)-65536*(i=Math.floor(n/65536)),m=(n=m+i+65535)-65536*(i=Math.floor(n/65536)),b=(n=b+i+65535)-65536*(i=Math.floor(n/65536)),s=(n=(s+=i-1+37*(i-1))+(i=1)+65535)-65536*(i=Math.floor(n/65536)),a=(n=a+i+65535)-65536*(i=Math.floor(n/65536)),o=(n=o+i+65535)-65536*(i=Math.floor(n/65536)),c=(n=c+i+65535)-65536*(i=Math.floor(n/65536)),h=(n=h+i+65535)-65536*(i=Math.floor(n/65536)),u=(n=u+i+65535)-65536*(i=Math.floor(n/65536)),l=(n=l+i+65535)-65536*(i=Math.floor(n/65536)),y=(n=y+i+65535)-65536*(i=Math.floor(n/65536)),f=(n=f+i+65535)-65536*(i=Math.floor(n/65536)),g=(n=g+i+65535)-65536*(i=Math.floor(n/65536)),p=(n=p+i+65535)-65536*(i=Math.floor(n/65536)),d=(n=d+i+65535)-65536*(i=Math.floor(n/65536)),A=(n=A+i+65535)-65536*(i=Math.floor(n/65536)),w=(n=w+i+65535)-65536*(i=Math.floor(n/65536)),m=(n=m+i+65535)-65536*(i=Math.floor(n/65536)),b=(n=b+i+65535)-65536*(i=Math.floor(n/65536)),s+=i-1+37*(i-1),e[0]=s,e[1]=a,e[2]=o,e[3]=c,e[4]=h,e[5]=u,e[6]=l,e[7]=y,e[8]=f,e[9]=g,e[10]=p,e[11]=d,e[12]=A,e[13]=w,e[14]=m,e[15]=b}function In(e,t){Bn(e,t,t)}function Sn(e,t){var r,n=tn();for(r=0;r<16;r++)n[r]=t[r];for(r=253;r>=0;r--)In(n,n),2!==r&&4!==r&&Bn(n,n,t);for(r=0;r<16;r++)e[r]=n[r]}function Kn(e,t,r){var n,i,s=new Uint8Array(32),a=new Float64Array(80),o=tn(),c=tn(),h=tn(),u=tn(),l=tn(),y=tn();for(i=0;i<31;i++)s[i]=t[i];for(s[31]=127&t[31]|64,s[0]&=248,kn(a,r),i=0;i<16;i++)c[i]=a[i],u[i]=o[i]=h[i]=0;for(o[0]=u[0]=1,i=254;i>=0;--i)An(o,c,n=s[i>>>3]>>>(7&i)&1),An(h,u,n),En(l,o,h),vn(o,o,h),En(h,c,u),vn(c,c,u),In(u,l),In(y,o),Bn(o,h,o),Bn(h,c,l),En(l,o,h),vn(o,o,h),In(c,o),vn(h,u,y),Bn(o,h,on),En(o,o,u),Bn(h,h,o),Bn(o,u,y),Bn(u,c,a),In(c,l),An(o,c,n),An(h,u,n);for(i=0;i<16;i++)a[i+16]=o[i],a[i+32]=h[i],a[i+48]=c[i],a[i+64]=u[i];var f=a.subarray(32),g=a.subarray(16);return Sn(f,f),Bn(g,g,f),wn(e,g),0}function Cn(e,t){return Kn(e,t,nn)}var Pn=[1116352408,3609767458,1899447441,602891725,3049323471,3964484399,3921009573,2173295548,961987163,4081628472,1508970993,3053834265,2453635748,2937671579,2870763221,3664609560,3624381080,2734883394,310598401,1164996542,607225278,1323610764,1426881987,3590304994,1925078388,4068182383,2162078206,991336113,2614888103,633803317,3248222580,3479774868,3835390401,2666613458,4022224774,944711139,264347078,2341262773,604807628,2007800933,770255983,1495990901,1249150122,1856431235,1555081692,3175218132,1996064986,2198950837,2554220882,3999719339,2821834349,766784016,2952996808,2566594879,3210313671,3203337956,3336571891,1034457026,3584528711,2466948901,113926993,3758326383,338241895,168717936,666307205,1188179964,773529912,1546045734,1294757372,1522805485,1396182291,2643833823,1695183700,2343527390,1986661051,1014477480,2177026350,1206759142,2456956037,344077627,2730485921,1290863460,2820302411,3158454273,3259730800,3505952657,3345764771,106217008,3516065817,3606008344,3600352804,1432725776,4094571909,1467031594,275423344,851169720,430227734,3100823752,506948616,1363258195,659060556,3750685593,883997877,3785050280,958139571,3318307427,1322822218,3812723403,1537002063,2003034995,1747873779,3602036899,1955562222,1575990012,2024104815,1125592928,2227730452,2716904306,2361852424,442776044,2428436474,593698344,2756734187,3733110249,3204031479,2999351573,3329325298,3815920427,3391569614,3928383900,3515267271,566280711,3940187606,3454069534,4118630271,4000239992,116418474,1914138554,174292421,2731055270,289380356,3203993006,460393269,320620315,685471733,587496836,852142971,1086792851,1017036298,365543100,1126000580,2618297676,1288033470,3409855158,1501505948,4234509866,1607167915,987167468,1816402316,1246189591];function Un(e,t,r,n){for(var i,s,a,o,c,h,u,l,y,f,g,p,d,A,w,m,b,k,E,v,B,I,S,K,C,P,U=new Int32Array(16),D=new Int32Array(16),x=e[0],Q=e[1],R=e[2],L=e[3],M=e[4],T=e[5],F=e[6],N=e[7],O=t[0],H=t[1],z=t[2],_=t[3],G=t[4],j=t[5],q=t[6],V=t[7],W=0;n>=128;){for(E=0;E<16;E++)v=8*E+W,U[E]=r[v+0]<<24|r[v+1]<<16|r[v+2]<<8|r[v+3],D[E]=r[v+4]<<24|r[v+5]<<16|r[v+6]<<8|r[v+7];for(E=0;E<80;E++)if(i=x,s=Q,a=R,o=L,c=M,h=T,u=F,N,y=O,f=H,g=z,p=_,d=G,A=j,w=q,V,S=65535&(I=V),K=I>>>16,C=65535&(B=N),P=B>>>16,S+=65535&(I=(G>>>14|M<<18)^(G>>>18|M<<14)^(M>>>9|G<<23)),K+=I>>>16,C+=65535&(B=(M>>>14|G<<18)^(M>>>18|G<<14)^(G>>>9|M<<23)),P+=B>>>16,S+=65535&(I=G&j^~G&q),K+=I>>>16,C+=65535&(B=M&T^~M&F),P+=B>>>16,B=Pn[2*E],S+=65535&(I=Pn[2*E+1]),K+=I>>>16,C+=65535&B,P+=B>>>16,B=U[E%16],K+=(I=D[E%16])>>>16,C+=65535&B,P+=B>>>16,C+=(K+=(S+=65535&I)>>>16)>>>16,S=65535&(I=k=65535&S|K<<16),K=I>>>16,C=65535&(B=b=65535&C|(P+=C>>>16)<<16),P=B>>>16,S+=65535&(I=(O>>>28|x<<4)^(x>>>2|O<<30)^(x>>>7|O<<25)),K+=I>>>16,C+=65535&(B=(x>>>28|O<<4)^(O>>>2|x<<30)^(O>>>7|x<<25)),P+=B>>>16,K+=(I=O&H^O&z^H&z)>>>16,C+=65535&(B=x&Q^x&R^Q&R),P+=B>>>16,l=65535&(C+=(K+=(S+=65535&I)>>>16)>>>16)|(P+=C>>>16)<<16,m=65535&S|K<<16,S=65535&(I=p),K=I>>>16,C=65535&(B=o),P=B>>>16,K+=(I=k)>>>16,C+=65535&(B=b),P+=B>>>16,Q=i,R=s,L=a,M=o=65535&(C+=(K+=(S+=65535&I)>>>16)>>>16)|(P+=C>>>16)<<16,T=c,F=h,N=u,x=l,H=y,z=f,_=g,G=p=65535&S|K<<16,j=d,q=A,V=w,O=m,E%16==15)for(v=0;v<16;v++)B=U[v],S=65535&(I=D[v]),K=I>>>16,C=65535&B,P=B>>>16,B=U[(v+9)%16],S+=65535&(I=D[(v+9)%16]),K+=I>>>16,C+=65535&B,P+=B>>>16,b=U[(v+1)%16],S+=65535&(I=((k=D[(v+1)%16])>>>1|b<<31)^(k>>>8|b<<24)^(k>>>7|b<<25)),K+=I>>>16,C+=65535&(B=(b>>>1|k<<31)^(b>>>8|k<<24)^b>>>7),P+=B>>>16,b=U[(v+14)%16],K+=(I=((k=D[(v+14)%16])>>>19|b<<13)^(b>>>29|k<<3)^(k>>>6|b<<26))>>>16,C+=65535&(B=(b>>>19|k<<13)^(k>>>29|b<<3)^b>>>6),P+=B>>>16,P+=(C+=(K+=(S+=65535&I)>>>16)>>>16)>>>16,U[v]=65535&C|P<<16,D[v]=65535&S|K<<16;S=65535&(I=O),K=I>>>16,C=65535&(B=x),P=B>>>16,B=e[0],K+=(I=t[0])>>>16,C+=65535&B,P+=B>>>16,P+=(C+=(K+=(S+=65535&I)>>>16)>>>16)>>>16,e[0]=x=65535&C|P<<16,t[0]=O=65535&S|K<<16,S=65535&(I=H),K=I>>>16,C=65535&(B=Q),P=B>>>16,B=e[1],K+=(I=t[1])>>>16,C+=65535&B,P+=B>>>16,P+=(C+=(K+=(S+=65535&I)>>>16)>>>16)>>>16,e[1]=Q=65535&C|P<<16,t[1]=H=65535&S|K<<16,S=65535&(I=z),K=I>>>16,C=65535&(B=R),P=B>>>16,B=e[2],K+=(I=t[2])>>>16,C+=65535&B,P+=B>>>16,P+=(C+=(K+=(S+=65535&I)>>>16)>>>16)>>>16,e[2]=R=65535&C|P<<16,t[2]=z=65535&S|K<<16,S=65535&(I=_),K=I>>>16,C=65535&(B=L),P=B>>>16,B=e[3],K+=(I=t[3])>>>16,C+=65535&B,P+=B>>>16,P+=(C+=(K+=(S+=65535&I)>>>16)>>>16)>>>16,e[3]=L=65535&C|P<<16,t[3]=_=65535&S|K<<16,S=65535&(I=G),K=I>>>16,C=65535&(B=M),P=B>>>16,B=e[4],K+=(I=t[4])>>>16,C+=65535&B,P+=B>>>16,P+=(C+=(K+=(S+=65535&I)>>>16)>>>16)>>>16,e[4]=M=65535&C|P<<16,t[4]=G=65535&S|K<<16,S=65535&(I=j),K=I>>>16,C=65535&(B=T),P=B>>>16,B=e[5],K+=(I=t[5])>>>16,C+=65535&B,P+=B>>>16,P+=(C+=(K+=(S+=65535&I)>>>16)>>>16)>>>16,e[5]=T=65535&C|P<<16,t[5]=j=65535&S|K<<16,S=65535&(I=q),K=I>>>16,C=65535&(B=F),P=B>>>16,B=e[6],K+=(I=t[6])>>>16,C+=65535&B,P+=B>>>16,P+=(C+=(K+=(S+=65535&I)>>>16)>>>16)>>>16,e[6]=F=65535&C|P<<16,t[6]=q=65535&S|K<<16,S=65535&(I=V),K=I>>>16,C=65535&(B=N),P=B>>>16,B=e[7],K+=(I=t[7])>>>16,C+=65535&B,P+=B>>>16,P+=(C+=(K+=(S+=65535&I)>>>16)>>>16)>>>16,e[7]=N=65535&C|P<<16,t[7]=V=65535&S|K<<16,W+=128,n-=128}return n}function Dn(e,t,r){var n,i=new Int32Array(8),s=new Int32Array(8),a=new Uint8Array(256),o=r;for(i[0]=1779033703,i[1]=3144134277,i[2]=1013904242,i[3]=2773480762,i[4]=1359893119,i[5]=2600822924,i[6]=528734635,i[7]=1541459225,s[0]=4089235720,s[1]=2227873595,s[2]=4271175723,s[3]=1595750129,s[4]=2917565137,s[5]=725511199,s[6]=4215389547,s[7]=327033209,Un(i,s,t,r),r%=128,n=0;n=0;--i)Qn(e,t,n=r[i/8|0]>>(7&i)&1),xn(t,e),xn(e,e),Qn(e,t,n)}function Mn(e,t){var r=[tn(),tn(),tn(),tn()];pn(r[0],un),pn(r[1],ln),pn(r[2],an),Bn(r[3],un,ln),Ln(e,r,t)}function Tn(e,t,r){var n,i=new Uint8Array(64),s=[tn(),tn(),tn(),tn()];for(r||rn(t,32),Dn(i,t,32),i[0]&=248,i[31]&=127,i[31]|=64,Mn(s,i),Rn(e,s),n=0;n<32;n++)t[n+32]=e[n];return 0}var Fn=new Float64Array([237,211,245,92,26,99,18,88,214,156,247,162,222,249,222,20,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,16]);function Nn(e,t){var r,n,i,s;for(n=63;n>=32;--n){for(r=0,i=n-32,s=n-12;i>4)*Fn[i],r=t[i]>>8,t[i]&=255;for(i=0;i<32;i++)t[i]-=r*Fn[i];for(n=0;n<32;n++)t[n+1]+=t[n]>>8,e[n]=255&t[n]}function On(e){var t,r=new Float64Array(64);for(t=0;t<64;t++)r[t]=e[t];for(t=0;t<64;t++)e[t]=0;Nn(e,r)}function Hn(e,t){var r=tn(),n=tn(),i=tn(),s=tn(),a=tn(),o=tn(),c=tn();return pn(e[2],an),kn(e[1],t),In(i,e[1]),Bn(s,i,cn),vn(i,i,e[2]),En(s,e[2],s),In(a,s),In(o,a),Bn(c,o,a),Bn(r,c,i),Bn(r,r,s),function(e,t){var r,n=tn();for(r=0;r<16;r++)n[r]=t[r];for(r=250;r>=0;r--)In(n,n),1!==r&&Bn(n,n,t);for(r=0;r<16;r++)e[r]=n[r]}(r,r),Bn(r,r,i),Bn(r,r,s),Bn(r,r,s),Bn(e[0],r,s),In(n,e[0]),Bn(n,n,s),mn(n,i)&&Bn(e[0],e[0],yn),In(n,e[0]),Bn(n,n,s),mn(n,i)?-1:(bn(e[0])===t[31]>>7&&vn(e[0],sn,e[0]),Bn(e[3],e[0],e[1]),0)}var zn=64;function _n(){for(var e=0;e=0},en.sign.keyPair=function(){var e=new Uint8Array(32),t=new Uint8Array(64);return Tn(e,t),{publicKey:e,secretKey:t}},en.sign.keyPair.fromSecretKey=function(e){if(_n(e),64!==e.length)throw Error("bad secret key size");for(var t=new Uint8Array(32),r=0;r=1){const t=e[0];if(e.length>=1+t)return this.oid=e.subarray(1,1+t),1+this.oid.length}throw Error("Invalid oid")}write(){return G.concatUint8Array([new Uint8Array([this.oid.length]),this.oid])}toHex(){return G.uint8ArrayToHex(this.oid)}getName(){const e=Gn[this.toHex()];if(!e)throw Error("Unknown curve object identifier.");return e}}function qn(e){let t,r=0;const n=e[0];return n<192?([r]=e,t=1):n<255?(r=(e[0]-192<<8)+e[1]+192,t=2):255===n&&(r=G.readNumber(e.subarray(1,5)),t=5),{len:r,offset:t}}function Vn(e){return e<192?new Uint8Array([e]):e>191&&e<8384?new Uint8Array([192+(e-192>>8),e-192&255]):G.concatUint8Array([new Uint8Array([255]),G.writeNumber(e,4)])}function Wn(e){if(e<0||e>30)throw Error("Partial Length power must be between 1 and 30");return new Uint8Array([224+e])}function Zn(e){return new Uint8Array([192|e])}function Yn(e,t){return G.concatUint8Array([Zn(e),Vn(t)])}function Jn(e){return[H.packet.literalData,H.packet.compressedData,H.packet.symmetricallyEncryptedData,H.packet.symEncryptedIntegrityProtectedData,H.packet.aeadEncryptedData].includes(e)}async function $n(e,t){const r=F(e);let n,i;try{const s=await r.peekBytes(2);if(!s||s.length<2||!(128&s[0]))throw Error("Error during parsing. This message / key probably does not conform to a valid OpenPGP format.");const a=await r.readByte();let o,c,h=-1,u=-1;u=0,64&a&&(u=1),u?h=63&a:(h=(63&a)>>2,c=3&a);const l=Jn(h);let y,g=null;if(l){if("array"===G.isStream(e)){const e=new f;n=N(e),g=e}else{const e=new TransformStream;n=N(e.writable),g=e.readable}i=t({tag:h,packet:g})}else g=[];do{if(u){const e=await r.readByte();if(y=!1,e<192)o=e;else if(e>=192&&e<224)o=(e-192<<8)+await r.readByte()+192;else if(e>223&&e<255){if(o=1<<(31&e),y=!0,!l)throw new TypeError("This packet type does not support partial lengths.")}else o=await r.readByte()<<24|await r.readByte()<<16|await r.readByte()<<8|await r.readByte()}else switch(c){case 0:o=await r.readByte();break;case 1:o=await r.readByte()<<8|await r.readByte();break;case 2:o=await r.readByte()<<24|await r.readByte()<<16|await r.readByte()<<8|await r.readByte();break;default:o=1/0}if(o>0){let e=0;for(;;){n&&await n.ready;const{done:t,value:i}=await r.read();if(t){if(o===1/0)break;throw Error("Unexpected end of packet")}const s=o===1/0?i:i.subarray(0,o-e);if(n?await n.write(s):g.push(s),e+=i.length,e>=o){r.unshift(i.subarray(o-e+i.length));break}}}}while(y);const p=await r.peekBytes(l?1/0:2);return n?(await n.ready,await n.close()):(g=G.concatUint8Array(g),await t({tag:h,packet:g})),!p||!p.length}catch(e){if(n)return await n.abort(e),!0;throw e}finally{n&&await i,r.releaseLock()}}class Xn extends Error{constructor(...e){super(...e),Error.captureStackTrace&&Error.captureStackTrace(this,Xn),this.name="UnsupportedError"}}class ei extends Xn{constructor(...e){super(...e),Error.captureStackTrace&&Error.captureStackTrace(this,Xn),this.name="UnknownPacketError"}}class ti{constructor(e,t){this.tag=e,this.rawContent=t}write(){return this.rawContent}} /*! noble-ed25519 - MIT License (c) 2019 Paul Miller (paulmillr.com) */const ri=BigInt(0),ni=BigInt(1),ii=BigInt(2),si=BigInt(8),ai=BigInt("7237005577332262213973186563042994240857116359379907606001950938285454250989"),oi=Object.freeze({a:BigInt(-1),d:BigInt("37095705934669439343138083508754565189542113879843219016388785533085940283555"),P:BigInt("57896044618658097711785492504343953926634992332820282019728792003956564819949"),l:ai,n:ai,h:BigInt(8),Gx:BigInt("15112221349535400772501151409588531511454012693041857206046113283949847762202"),Gy:BigInt("46316835694926478169428394003475163141307993866256225615783033603165251855960")}),ci=BigInt("0x10000000000000000000000000000000000000000000000000000000000000000"),hi=BigInt("19681161376707505956807079304988542015446066515923890162744021073123829784752");BigInt("6853475219497561581579357271197624642482790079785650197046958215289687604742");const ui=BigInt("25063068953384623474111414158702152701244531502492656460079210482610430750235"),li=BigInt("54469307008909316920995813868745141605393597292927456921205312896311721017578"),yi=BigInt("1159843021668779879193775521855586647937357759715417654439879720876111806838"),fi=BigInt("40440834346308536858101042469323190826248399146238708352240133220865137265952");class gi{constructor(e,t,r,n){this.x=e,this.y=t,this.z=r,this.t=n}static fromAffine(e){if(!(e instanceof ki))throw new TypeError("ExtendedPoint#fromAffine: expected Point");return e.equals(ki.ZERO)?gi.ZERO:new gi(e.x,e.y,ni,Qi(e.x*e.y))}static toAffineBatch(e){const t=function(e,t=oi.P){const r=Array(e.length),n=e.reduce(((e,n,i)=>n===ri?e:(r[i]=e,Qi(e*n,t))),ni),i=Ri(n,t);return e.reduceRight(((e,n,i)=>n===ri?e:(r[i]=Qi(e*r[i],t),Qi(e*n,t))),i),r}(e.map((e=>e.z)));return e.map(((e,r)=>e.toAffine(t[r])))}static normalizeZ(e){return this.toAffineBatch(e).map(this.fromAffine)}equals(e){di(e);const{x:t,y:r,z:n}=this,{x:i,y:s,z:a}=e,o=Qi(t*a),c=Qi(i*n),h=Qi(r*a),u=Qi(s*n);return o===c&&h===u}negate(){return new gi(Qi(-this.x),this.y,this.z,Qi(-this.t))}double(){const{x:e,y:t,z:r}=this,{a:n}=oi,i=Qi(e*e),s=Qi(t*t),a=Qi(ii*Qi(r*r)),o=Qi(n*i),c=e+t,h=Qi(Qi(c*c)-i-s),u=o+s,l=u-a,y=o-s,f=Qi(h*l),g=Qi(u*y),p=Qi(h*y),d=Qi(l*u);return new gi(f,g,d,p)}add(e){di(e);const{x:t,y:r,z:n,t:i}=this,{x:s,y:a,z:o,t:c}=e,h=Qi((r-t)*(a+s)),u=Qi((r+t)*(a-s)),l=Qi(u-h);if(l===ri)return this.double();const y=Qi(n*ii*c),f=Qi(i*ii*o),g=f+y,p=u+h,d=f-y,A=Qi(g*l),w=Qi(p*d),m=Qi(g*d),b=Qi(l*p);return new gi(A,w,b,m)}subtract(e){return this.add(e.negate())}precomputeWindow(e){const t=1+256/e,r=[];let n=this,i=n;for(let s=0;s>=u,a>o&&(a-=h,e+=ni);const l=r,y=r+Math.abs(a)-1,f=t%2!=0,g=a<0;0===a?s=s.add(pi(f,n[l])):i=i.add(pi(g,n[y]))}return gi.normalizeZ([i,s])[0]}multiply(e,t){return this.wNAF(Oi(e,oi.l),t)}multiplyUnsafe(e){let t=Oi(e,oi.l,!1);const r=gi.BASE,n=gi.ZERO;if(t===ri)return n;if(this.equals(n)||t===ni)return this;if(this.equals(r))return this.wNAF(t);let i=n,s=this;for(;t>ri;)t&ni&&(i=i.add(s)),s=s.double(),t>>=ni;return i}isSmallOrder(){return this.multiplyUnsafe(oi.h).equals(gi.ZERO)}isTorsionFree(){let e=this.multiplyUnsafe(oi.l/ii).double();return oi.l%ii&&(e=e.add(this)),e.equals(gi.ZERO)}toAffine(e){const{x:t,y:r,z:n}=this,i=this.equals(gi.ZERO);null==e&&(e=i?si:Ri(n));const s=Qi(t*e),a=Qi(r*e),o=Qi(n*e);if(i)return ki.ZERO;if(o!==ni)throw Error("invZ was invalid");return new ki(s,a)}fromRistrettoBytes(){wi()}toRistrettoBytes(){wi()}fromRistrettoHash(){wi()}}function pi(e,t){const r=t.negate();return e?r:t}function di(e){if(!(e instanceof gi))throw new TypeError("ExtendedPoint expected")}function Ai(e){if(!(e instanceof mi))throw new TypeError("RistrettoPoint expected")}function wi(){throw Error("Legacy method: switch to RistrettoPoint")}gi.BASE=new gi(oi.Gx,oi.Gy,ni,Qi(oi.Gx*oi.Gy)),gi.ZERO=new gi(ri,ni,ni,ri);class mi{constructor(e){this.ep=e}static calcElligatorRistrettoMap(e){const{d:t}=oi,r=Qi(hi*e*e),n=Qi((r+ni)*yi);let i=BigInt(-1);const s=Qi((i-t*r)*Qi(r+t));let{isValid:a,value:o}=Mi(n,s),c=Qi(o*e);Pi(c)||(c=Qi(-c)),a||(o=c),a||(i=r);const h=Qi(i*(r-ni)*fi-s),u=o*o,l=Qi((o+o)*s),y=Qi(h*ui),f=Qi(ni-u),g=Qi(ni+u);return new gi(Qi(l*g),Qi(f*y),Qi(y*g),Qi(l*f))}static hashToCurve(e){const t=xi((e=Ni(e,64)).slice(0,32)),r=this.calcElligatorRistrettoMap(t),n=xi(e.slice(32,64)),i=this.calcElligatorRistrettoMap(n);return new mi(r.add(i))}static fromHex(e){e=Ni(e,32);const{a:t,d:r}=oi,n="RistrettoPoint.fromHex: the hex is not valid encoding of RistrettoPoint",i=xi(e);if(!function(e,t){if(e.length!==t.length)return!1;for(let r=0;r=n)throw Error("Expected 0 < hex < P");if(!t&&s>=ci)throw Error("Expected 0 < hex < 2**256");const a=Qi(s*s),o=Qi(a-ni),c=Qi(r*a+ni);let{isValid:h,value:u}=Mi(o,c);if(!h)throw Error("Point.fromHex: invalid y coordinate");const l=(u&ni)===ni;return!!(128&e[31])!==l&&(u=Qi(-u)),new ki(u,s)}static async fromPrivateKey(e){return(await zi(e)).point}toRawBytes(){const e=Ci(this.y);return e[31]|=this.x&ni?128:0,e}toHex(){return Ii(this.toRawBytes())}toX25519(){const{y:e}=this;return Ci(Qi((ni+e)*Ri(ni-e)))}isTorsionFree(){return gi.fromAffine(this).isTorsionFree()}equals(e){return this.x===e.x&&this.y===e.y}negate(){return new ki(Qi(-this.x),this.y)}add(e){return gi.fromAffine(this).add(gi.fromAffine(e)).toAffine()}subtract(e){return this.add(e.negate())}multiply(e){return gi.fromAffine(this).multiply(e,this).toAffine()}}ki.BASE=new ki(oi.Gx,oi.Gy),ki.ZERO=new ki(ri,ni);let Ei=class e{constructor(e,t){this.r=e,this.s=t,this.assertValidity()}static fromHex(t){const r=Ni(t,64),n=ki.fromHex(r.slice(0,32),!1),i=Ui(r.slice(32,64));return new e(n,i)}assertValidity(){const{r:e,s:t}=this;if(!(e instanceof ki))throw Error("Expected Point instance");return Oi(t,oi.l,!1),this}toRawBytes(){const e=new Uint8Array(64);return e.set(this.r.toRawBytes()),e.set(Ci(this.s),32),e}toHex(){return Ii(this.toRawBytes())}};function vi(...e){if(!e.every((e=>e instanceof Uint8Array)))throw Error("Expected Uint8Array list");if(1===e.length)return e[0];const t=e.reduce(((e,t)=>e+t.length),0),r=new Uint8Array(t);for(let t=0,n=0;tt.toString(16).padStart(2,"0")));function Ii(e){if(!(e instanceof Uint8Array))throw Error("Uint8Array expected");let t="";for(let r=0;r=ri?r:t+r}function Ri(e,t=oi.P){if(e===ri||t<=ri)throw Error(`invert: expected positive integers, got n=${e} mod=${t}`);let r=Qi(e,t),n=t,i=ri,s=ni;for(;r!==ri;){const e=n%r,t=i-s*(n/r);n=r,r=e,i=s,s=t}if(n!==ni)throw Error("invert: does not exist");return Qi(i,t)}function Li(e,t){const{P:r}=oi;let n=e;for(;t-- >ri;)n*=n,n%=r;return n}function Mi(e,t){const r=Qi(t*t*t),n=function(e){const{P:t}=oi,r=BigInt(5),n=BigInt(10),i=BigInt(20),s=BigInt(40),a=BigInt(80),o=e*e%t*e%t,c=Li(o,ii)*o%t,h=Li(c,ni)*e%t,u=Li(h,r)*h%t,l=Li(u,n)*u%t,y=Li(l,i)*l%t,f=Li(y,s)*y%t,g=Li(f,a)*f%t,p=Li(g,a)*f%t,d=Li(p,n)*u%t;return{pow_p_5_8:Li(d,ii)*e%t,b2:o}}(e*Qi(r*r*t)).pow_p_5_8;let i=Qi(e*r*n);const s=Qi(t*i*i),a=i,o=Qi(i*hi),c=s===e,h=s===Qi(-e),u=s===Qi(-e*hi);return c&&(i=a),(h||u)&&(i=o),Pi(i)&&(i=Qi(-i)),{isValid:c||h,value:i}}function Ti(e){return Mi(ni,e)}function Fi(e){return Qi(Ui(e),oi.l)}function Ni(e,t){const r=e instanceof Uint8Array?Uint8Array.from(e):Si(e);if("number"==typeof t&&r.length!==t)throw Error(`Expected ${t} bytes`);return r}function Oi(e,t,r=!0){if(!t)throw new TypeError("Specify max value");if("number"==typeof e&&Number.isSafeInteger(e)&&(e=BigInt(e)),"bigint"==typeof e&&e{if((e=Ni(e)).length<40||e.length>1024)throw Error("Expected 40-1024 bytes of private key as per FIPS 186");return Qi(Ui(e),oi.l-ni)+ni},randomBytes:(e=32)=>{if(Gi.web)return Gi.web.getRandomValues(new Uint8Array(e));if(Gi.node){const{randomBytes:t}=Gi.node;return new Uint8Array(t(e).buffer)}throw Error("The environment doesn't have randomBytes function")},randomPrivateKey:()=>ji.randomBytes(32),sha512:async(...e)=>{const t=vi(...e);if(Gi.web){const e=await Gi.web.subtle.digest("SHA-512",t.buffer);return new Uint8Array(e)}if(Gi.node)return Uint8Array.from(Gi.node.createHash("sha512").update(t).digest());throw Error("The environment doesn't have sha512 function")},precompute(e=8,t=ki.BASE){const r=t.equals(ki.BASE)?t:new ki(t.x,t.y);return r._setWindowSize(e),r.multiply(ii),r},sha512Sync:void 0};async function qi(e){switch(e){case H.publicKey.ed25519:try{const e=G.getWebCrypto(),t=await e.generateKey("Ed25519",!0,["sign","verify"]),r=await e.exportKey("jwk",t.privateKey),n=await e.exportKey("jwk",t.publicKey);return{A:new Uint8Array(Y(n.x)),seed:Y(r.d)}}catch(t){if("NotSupportedError"!==t.name&&"OperationError"!==t.name)throw t;const r=xr(Zi(e)),{publicKey:n}=en.sign.keyPair.fromSeed(r);return{A:n,seed:r}}case H.publicKey.ed448:{const e=await G.getNobleCurve(H.publicKey.ed448),t=e.utils.randomPrivateKey();return{A:e.getPublicKey(t),seed:t}}default:throw Error("Unsupported EdDSA algorithm")}}async function Vi(e,t,r,n,i,s){if(Ke.getHashByteLength(t)Hi,set(e){Hi||(Hi=e)}}});const Ji=(e,t)=>{if(e===H.publicKey.ed25519){return{kty:"OKP",crv:"Ed25519",x:J(t),ext:!0}}throw Error("Unsupported EdDSA algorithm")},$i=(e,t,r)=>{if(e===H.publicKey.ed25519){const n=Ji(e,t);return n.d=J(r),n}throw Error("Unsupported EdDSA algorithm")};var Xi=/*#__PURE__*/Object.freeze({__proto__:null,generate:qi,getPayloadSize:Zi,getPreferredHashAlgo:Yi,sign:Vi,validateParams:async function(e,t,r){switch(e){case H.publicKey.ed25519:{const{publicKey:e}=en.sign.keyPair.fromSeed(r);return G.equalsUint8Array(t,e)}case H.publicKey.ed448:{const e=(await G.getNobleCurve(H.publicKey.ed448)).getPublicKey(r);return G.equalsUint8Array(t,e)}default:return!1}},verify:Wi});const es=G.getWebCrypto();async function ts(e,t,r){const{keySize:n}=ue(e);if(!G.isAES(e)||t.length!==n)throw Error("Unexpected algorithm or key size");try{const e=await es.importKey("raw",t,{name:"AES-KW"},!1,["wrapKey"]),n=await es.importKey("raw",r,{name:"HMAC",hash:"SHA-256"},!0,["sign"]),i=await es.wrapKey("raw",n,e,{name:"AES-KW"});return new Uint8Array(i)}catch(e){if("NotSupportedError"!==e.name&&(24!==t.length||"OperationError"!==e.name))throw e;G.printDebugError("Browser did not support operation: "+e.message)}return Ct(t).encrypt(r)}async function rs(e,t,r){const{keySize:n}=ue(e);if(!G.isAES(e)||t.length!==n)throw Error("Unexpected algorithm or key size");let i;try{i=await es.importKey("raw",t,{name:"AES-KW"},!1,["unwrapKey"])}catch(e){if("NotSupportedError"!==e.name&&(24!==t.length||"OperationError"!==e.name))throw e;return G.printDebugError("Browser did not support operation: "+e.message),Ct(t).decrypt(r)}try{const e=await es.unwrapKey("raw",r,i,{name:"AES-KW"},{name:"HMAC",hash:"SHA-256"},!0,["sign"]);return new Uint8Array(await es.exportKey("raw",e))}catch(e){if("OperationError"===e.name)throw Error("Key Data Integrity failed");throw e}}var ns=/*#__PURE__*/Object.freeze({__proto__:null,unwrap:rs,wrap:ts});const is=G.getWebCrypto();async function ss(e,t,r,n,i){const s=H.read(H.webHash,e);if(!s)throw Error("Hash algo not supported with HKDF");const a=await is.importKey("raw",t,"HKDF",!1,["deriveBits"]),o=await is.deriveBits({name:"HKDF",hash:s,salt:r,info:n},a,8*i);return new Uint8Array(o)}const as={x25519:G.encodeUTF8("OpenPGP X25519"),x448:G.encodeUTF8("OpenPGP X448")};async function os(e){switch(e){case H.publicKey.x25519:{const e=xr(32),{publicKey:t}=en.box.keyPair.fromSecretKey(e);return{A:t,k:e}}case H.publicKey.x448:{const e=await G.getNobleCurve(H.publicKey.x448),t=e.utils.randomPrivateKey();return{A:e.getPublicKey(t),k:t}}default:throw Error("Unsupported ECDH algorithm")}}function cs(e){switch(e){case H.publicKey.x25519:return 32;case H.publicKey.x448:return 56;default:throw Error("Unsupported ECDH algorithm")}}async function hs(e,t){switch(e){case H.publicKey.x25519:{const r=xr(cs(e)),n=en.scalarMult(r,t);ls(n);const{publicKey:i}=en.box.keyPair.fromSecretKey(r);return{ephemeralPublicKey:i,sharedSecret:n}}case H.publicKey.x448:{const e=await G.getNobleCurve(H.publicKey.x448),r=e.utils.randomPrivateKey(),n=e.getSharedSecret(r,t);ls(n);return{ephemeralPublicKey:e.getPublicKey(r),sharedSecret:n}}default:throw Error("Unsupported ECDH algorithm")}}async function us(e,t,r,n){switch(e){case H.publicKey.x25519:{const e=en.scalarMult(n,t);return ls(e),e}case H.publicKey.x448:{const e=(await G.getNobleCurve(H.publicKey.x448)).getSharedSecret(n,t);return ls(e),e}default:throw Error("Unsupported ECDH algorithm")}}function ls(e){let t=0;for(let r=0;r0===s[0]&&Us(a,r,s.subarray(1),i);if(n&&!G.isStream(n))switch(a.type){case"web":try{const e=await async function(e,t,{r,s:n},i,s){const a=Bs(e.payloadSize,ps[e.name],s),o=await Ss.importKey("jwk",a,{name:"ECDSA",namedCurve:ps[e.name],hash:{name:H.read(H.webHash,e.hash)}},!1,["verify"]),c=G.concatUint8Array([r,n]).buffer;return Ss.verify({name:"ECDSA",namedCurve:ps[e.name],hash:{name:H.read(H.webHash,t)}},o,c,i)}(a,t,r,n,i);return e||o()}catch(e){if("nistP521"!==a.name&&("DataError"===e.name||"OperationError"===e.name))throw e;G.printDebugError("Browser did not support verifying: "+e.message)}break;case"node":{const e=await async function(e,t,{r,s:n},i,s){const a=G.nodeRequire("eckey-utils"),o=G.getNodeBuffer(),{publicKey:c}=a.generateDer({curveName:As[e.name],publicKey:o.from(s)}),h=Ks.createVerify(H.read(H.hash,t));h.write(i),h.end();const u=G.concatUint8Array([r,n]);try{return h.verify({key:c,format:"der",type:"spki",dsaEncoding:"ieee-p1363"},u)}catch(e){return!1}}(a,t,r,n,i);return e||o()}}return await Us(a,r,s,i)||o()}async function Us(e,t,r,n){return(await G.getNobleCurve(H.publicKey.ecdsa,e.name)).verify(G.concatUint8Array([t.r,t.s]),r,n,{lowS:!1})}var Ds=/*#__PURE__*/Object.freeze({__proto__:null,sign:Cs,validateParams:async function(e,t,r){const n=new ms(e);if(n.keyType!==H.publicKey.ecdsa)return!1;switch(n.type){case"web":case"node":{const n=xr(8),i=H.hash.sha256,s=await Ke.digest(i,n);try{const a=await Cs(e,i,n,t,r,s);return await Ps(e,i,a,n,t,s)}catch(e){return!1}}default:return bs(H.publicKey.ecdsa,e,t,r)}},verify:Ps});var xs=/*#__PURE__*/Object.freeze({__proto__:null,sign:async function(e,t,r,n,i,s){if(ks(new ms(e),n),Ke.getHashByteLength(t)0){const r=e[t-1];if(r>=1){const n=e.subarray(t-r),i=new Uint8Array(r).fill(r);if(G.equalsUint8Array(n,i))return e.subarray(0,t-r)}}throw Error("Invalid padding")}var Ls=/*#__PURE__*/Object.freeze({__proto__:null,decode:Rs,encode:Qs});const Ms=G.getWebCrypto(),Ts=G.getNodeCrypto();function Fs(e,t,r,n){return G.concatUint8Array([t.write(),new Uint8Array([e]),r.write(!0),G.stringToUint8Array("Anonymous Sender "),r.replacementFingerprint||n])}async function Ns(e,t,r,n,i=!1,s=!1){let a;if(i){for(a=0;a=0&&0===t[a];a--);t=t.subarray(0,a+1)}return(await Ke.digest(e,G.concatUint8Array([new Uint8Array([0,0,0,1]),t,n]))).subarray(0,r)}async function Os(e,t){switch(e.type){case"curve25519Legacy":{const{sharedSecret:r,ephemeralPublicKey:n}=await hs(H.publicKey.x25519,t.subarray(1));return{publicKey:G.concatUint8Array([new Uint8Array([e.wireFormatLeadingByte]),n]),sharedKey:r}}case"web":if(e.web&&G.getWebCrypto())try{return await async function(e,t){const r=Bs(e.payloadSize,e.web,t);let n=Ms.generateKey({name:"ECDH",namedCurve:e.web},!0,["deriveKey","deriveBits"]),i=Ms.importKey("jwk",r,{name:"ECDH",namedCurve:e.web},!1,[]);[n,i]=await Promise.all([n,i]);let s=Ms.deriveBits({name:"ECDH",namedCurve:e.web,public:i},n.privateKey,e.sharedSize),a=Ms.exportKey("jwk",n.publicKey);[s,a]=await Promise.all([s,a]);const o=new Uint8Array(s),c=new Uint8Array(vs(a,e.wireFormatLeadingByte));return{publicKey:c,sharedKey:o}}(e,t)}catch(r){return G.printDebugError(r),_s(e,t)}break;case"node":return async function(e,t){const r=Ts.createECDH(e.node);r.generateKeys();const n=new Uint8Array(r.computeSecret(t)),i=new Uint8Array(r.getPublicKey());return{publicKey:i,sharedKey:n}}(e,t);default:return _s(e,t)}}async function Hs(e,t,r,n){if(n.length!==e.payloadSize){const t=new Uint8Array(e.payloadSize);t.set(n,e.payloadSize-n.length),n=t}switch(e.type){case"curve25519Legacy":{const e=n.slice().reverse();return{secretKey:e,sharedKey:await us(H.publicKey.x25519,t.subarray(1),r.subarray(1),e)}}case"web":if(e.web&&G.getWebCrypto())try{return await async function(e,t,r,n){const i=Is(e.payloadSize,e.web,r,n);let s=Ms.importKey("jwk",i,{name:"ECDH",namedCurve:e.web},!0,["deriveKey","deriveBits"]);const a=Bs(e.payloadSize,e.web,t);let o=Ms.importKey("jwk",a,{name:"ECDH",namedCurve:e.web},!0,[]);[s,o]=await Promise.all([s,o]);let c=Ms.deriveBits({name:"ECDH",namedCurve:e.web,public:o},s,e.sharedSize),h=Ms.exportKey("jwk",s);[c,h]=await Promise.all([c,h]);const u=new Uint8Array(c);return{secretKey:Y(h.d),sharedKey:u}}(e,t,r,n)}catch(r){return G.printDebugError(r),zs(e,t,n)}break;case"node":return async function(e,t,r){const n=Ts.createECDH(e.node);n.setPrivateKey(r);const i=new Uint8Array(n.computeSecret(t));return{secretKey:new Uint8Array(n.getPrivateKey()),sharedKey:i}}(e,t,n);default:return zs(e,t,n)}}async function zs(e,t,r){return{secretKey:r,sharedKey:(await G.getNobleCurve(H.publicKey.ecdh,e.name)).getSharedSecret(r,t).subarray(1)}}async function _s(e,t){const r=await G.getNobleCurve(H.publicKey.ecdh,e.name),{publicKey:n,privateKey:i}=await e.genKeyPair();return{publicKey:n,sharedKey:r.getSharedSecret(i,t).subarray(1)}}var Gs=/*#__PURE__*/Object.freeze({__proto__:null,decrypt:async function(e,t,r,n,i,s,a){const o=new ms(e);ks(o,i),ks(o,r);const{sharedKey:c}=await Hs(o,r,i,s),h=Fs(H.publicKey.ecdh,e,t,a),{keySize:u}=ue(t.cipher);let l;for(let e=0;e<3;e++)try{const r=await Ns(t.hash,c,u,h,1===e,2===e);return Rs(await rs(t.cipher,r,n))}catch(e){l=e}throw l},encrypt:async function(e,t,r,n,i){const s=Qs(r),a=new ms(e);ks(a,n);const{publicKey:o,sharedKey:c}=await Os(a,n),h=Fs(H.publicKey.ecdh,e,t,i),{keySize:u}=ue(t.cipher),l=await Ns(t.hash,c,u,h);return{publicKey:o,wrappedKey:await ts(t.cipher,l,s)}},validateParams:async function(e,t,r){return bs(H.publicKey.ecdh,e,t,r)}}),js=/*#__PURE__*/Object.freeze({__proto__:null,CurveWithOID:ms,ecdh:Gs,ecdhX:ys,ecdsa:Ds,eddsa:Xi,eddsaLegacy:xs,generate:async function(e){const t=new ms(e),{oid:r,hash:n,cipher:i}=t,s=await t.genKeyPair();return{oid:r,Q:s.publicKey,secret:G.leftPad(s.privateKey,t.payloadSize),hash:n,cipher:i}},getPreferredHashAlgo:function(e){return ws[e.getName()].hash}});const qs=BigInt(0),Vs=BigInt(1);var Ws=/*#__PURE__*/Object.freeze({__proto__:null,sign:async function(e,t,r,n,i,s){const a=BigInt(0);let o,c,h,u;n=kr(n),i=kr(i),r=kr(r),s=kr(s),r=Er(r,n),s=Er(s,i);const l=Er(kr(t.subarray(0,Pr(i))),i);for(;;){if(o=Qr(Vs,i),c=Er(vr(r,o,n),i),c===a)continue;const e=Er(s*c,i);if(u=Er(l+e,i),h=Er(Ir(o,i)*u,i),h!==a)break}return{r:Ur(c,"be",Pr(n)),s:Ur(h,"be",Pr(n))}},validateParams:async function(e,t,r,n,i){if(e=kr(e),t=kr(t),r=kr(r),n=kr(n),r<=Vs||r>=e)return!1;if(Er(e-Vs,t)!==qs)return!1;if(vr(r,t,e)!==Vs)return!1;const s=BigInt(Cr(t));if(s=a||r<=qs||r>=a)return G.printDebug("invalid DSA Signature"),!1;const c=Er(kr(n.subarray(0,Pr(a))),a),h=Ir(r,a);if(h===qs)return G.printDebug("invalid DSA Signature"),!1;i=Er(i,s),o=Er(o,s);const u=Er(c*h,a),l=Er(t*h,a);return Er(Er(vr(i,u,s)*vr(o,l,s),s),a)===t}});const Zs=new Set([H.hash.sha1,H.hash.sha256,H.hash.sha512]),Ys=G.getWebCrypto(),Js=G.getNodeCrypto();var $s={rsa:Yr,elgamal:$r,elliptic:js,dsa:Ws,hmac:/*#__PURE__*/Object.freeze({__proto__:null,generate:async function(e){if(!Zs.has(e))throw Error("Unsupported hash algorithm.");const t=H.read(H.webHash,e),r=Ys||Js.webcrypto.subtle,n=await r.generateKey({name:"HMAC",hash:{name:t}},!0,["sign","verify"]),i=await r.exportKey("raw",n);return new Uint8Array(i)},sign:async function(e,t,r){if(!Zs.has(e))throw Error("Unsupported hash algorithm.");const n=H.read(H.webHash,e),i=Ys||Js.webcrypto.subtle,s=await i.importKey("raw",t,{name:"HMAC",hash:{name:n}},!1,["sign"]),a=await i.sign("HMAC",s,r);return new Uint8Array(a)},verify:async function(e,t,r,n){if(!Zs.has(e))throw Error("Unsupported hash algorithm.");const i=H.read(H.webHash,e),s=Ys||Js.webcrypto.subtle,a=await s.importKey("raw",t,{name:"HMAC",hash:{name:i}},!1,["verify"]);return s.verify("HMAC",a,r,n)}})};class Xs{constructor(e){if(void 0===e&&(e=new Uint8Array([])),!G.isUint8Array(e))throw Error("data must be in the form of a Uint8Array");this.data=e,this.length=this.data.byteLength}write(){return G.concatUint8Array([new Uint8Array([this.length]),this.data])}read(e){if(e.length>=1){const t=e[0];if(e.length>=t+1)return this.data=e.subarray(1,1+t),this.length=t,1+t}throw Error("Invalid octet string")}}var ea=/*#__PURE__*/Object.freeze({__proto__:null,parseSignatureParams:function(e,t){let r=0;switch(e){case H.publicKey.rsaEncryptSign:case H.publicKey.rsaEncrypt:case H.publicKey.rsaSign:{const e=G.readMPI(t.subarray(r));return r+=e.length+2,{read:r,signatureParams:{s:e}}}case H.publicKey.dsa:case H.publicKey.ecdsa:{const e=G.readMPI(t.subarray(r));r+=e.length+2;const n=G.readMPI(t.subarray(r));return r+=n.length+2,{read:r,signatureParams:{r:e,s:n}}}case H.publicKey.eddsaLegacy:{const e=G.readMPI(t.subarray(r));r+=e.length+2;const n=G.readMPI(t.subarray(r));return r+=n.length+2,{read:r,signatureParams:{r:e,s:n}}}case H.publicKey.ed25519:case H.publicKey.ed448:{const n=2*$s.elliptic.eddsa.getPayloadSize(e),i=G.readExactSubarray(t,r,r+n);return r+=i.length,{read:r,signatureParams:{RS:i}}}case H.publicKey.hmac:{const e=new Xs;return r+=e.read(t.subarray(r)),{read:r,signatureParams:{mac:e}}}default:throw new Xn("Unknown signature algorithm.")}},sign:async function(e,t,r,n,i,s){if(!r||!n)throw Error("Missing key parameters");switch(e){case H.publicKey.rsaEncryptSign:case H.publicKey.rsaEncrypt:case H.publicKey.rsaSign:{const{n:e,e:a}=r,{d:o,p:c,q:h,u}=n;return{s:await $s.rsa.sign(t,i,e,a,o,c,h,u,s)}}case H.publicKey.dsa:{const{g:e,p:i,q:a}=r,{x:o}=n;return $s.dsa.sign(t,s,e,i,a,o)}case H.publicKey.elgamal:throw Error("Signing with Elgamal is not defined in the OpenPGP standard.");case H.publicKey.ecdsa:{const{oid:e,Q:a}=r,{d:o}=n;return $s.elliptic.ecdsa.sign(e,t,i,a,o,s)}case H.publicKey.eddsaLegacy:{const{oid:e,Q:a}=r,{seed:o}=n;return $s.elliptic.eddsaLegacy.sign(e,t,i,a,o,s)}case H.publicKey.ed25519:case H.publicKey.ed448:{const{A:a}=r,{seed:o}=n;return $s.elliptic.eddsa.sign(e,t,i,a,o,s)}case H.publicKey.hmac:{const{cipher:e}=r,{keyMaterial:t}=n,i=await $s.hmac.sign(e.getValue(),t,s);return{mac:new Xs(i)}}default:throw Error("Unknown signature algorithm.")}},verify:async function(e,t,r,n,i,s,a){switch(e){case H.publicKey.rsaEncryptSign:case H.publicKey.rsaEncrypt:case H.publicKey.rsaSign:{const{n:e,e:i}=n,o=G.leftPad(r.s,e.length);return $s.rsa.verify(t,s,o,e,i,a)}case H.publicKey.dsa:{const{g:e,p:i,q:s,y:o}=n,{r:c,s:h}=r;return $s.dsa.verify(t,c,h,a,e,i,s,o)}case H.publicKey.ecdsa:{const{oid:e,Q:i}=n,o=new $s.elliptic.CurveWithOID(e).payloadSize,c=G.leftPad(r.r,o),h=G.leftPad(r.s,o);return $s.elliptic.ecdsa.verify(e,t,{r:c,s:h},s,i,a)}case H.publicKey.eddsaLegacy:{const{oid:e,Q:i}=n,o=new $s.elliptic.CurveWithOID(e).payloadSize,c=G.leftPad(r.r,o),h=G.leftPad(r.s,o);return $s.elliptic.eddsaLegacy.verify(e,t,{r:c,s:h},s,i,a)}case H.publicKey.ed25519:case H.publicKey.ed448:{const{A:i}=n;return $s.elliptic.eddsa.verify(e,t,r,s,i,a)}case H.publicKey.hmac:{if(!i)throw Error("Cannot verify HMAC signature with symmetric key missing private parameters");const{cipher:e}=n,{keyMaterial:t}=i;return $s.hmac.verify(e.getValue(),t,r.mac.data,a)}default:throw Error("Unknown signature algorithm.")}}});class ta{constructor(e){e&&(this.data=e)}read(e){if(e.length>=1){const t=e[0];if(e.length>=1+t)return this.data=e.subarray(1,1+t),1+this.data.length}throw Error("Invalid symmetric key")}write(){return G.concatUint8Array([new Uint8Array([this.data.length]),this.data])}}class ra{constructor(e){if(e){const{version:t,hash:r,cipher:n,replacementFingerprint:i}=e;this.version=t||1,this.hash=r,this.cipher=n,this.replacementFingerprint=i}else this.version=null,this.hash=null,this.cipher=null,this.replacementFingerprint=null}read(e){if(e.length<4||1!==e[1]&&255!==e[1])throw new Xn("Cannot read KDFParams");const t=e[0];this.version=e[1],this.hash=e[2],this.cipher=e[3];let r=4;if(255===this.version){const n=t-r+1;this.replacementFingerprint=e.slice(r,r+n),r+=n}return r}write(e){if(!this.version||1===this.version||e)return new Uint8Array([3,1,this.hash,this.cipher]);return G.concatUint8Array([new Uint8Array([3+this.replacementFingerprint.length,this.version,this.hash,this.cipher]),this.replacementFingerprint])}}const na=e=>class{constructor(e){this.data=void 0===e?null:e}read(t){const r=t[0];return this.data=H.write(e,r),1}write(){return new Uint8Array([this.data])}getName(){return H.read(e,this.data)}getValue(){return this.data}},ia=na(H.aead),sa=na(H.symmetric),aa=na(H.hash);class oa{static fromObject({wrappedKey:e,algorithm:t}){const r=new oa;return r.wrappedKey=e,r.algorithm=t,r}read(e){let t=0,r=e[t++];this.algorithm=r%2?e[t++]:null,r-=r%2,this.wrappedKey=G.readExactSubarray(e,t,t+r),t+=r}write(){return G.concatUint8Array([this.algorithm?new Uint8Array([this.wrappedKey.length+1,this.algorithm]):new Uint8Array([this.wrappedKey.length]),this.wrappedKey])}}async function ca(e,t){const r=xr(32);return{privateParams:{hashSeed:r,keyMaterial:e},publicParams:{cipher:t,digest:await Ke.sha256(r)}}}function ha(e){const{keySize:t}=ue(e);return xr(t)}function ua(e){const t=H.read(H.aead,e);return wr[t]}function la(e){try{e.getName()}catch(e){throw new Xn("Unknown curve OID")}}function ya(e,t){switch(e){case H.publicKey.ecdsa:case H.publicKey.ecdh:case H.publicKey.eddsaLegacy:return new $s.elliptic.CurveWithOID(t).payloadSize;case H.publicKey.ed25519:case H.publicKey.ed448:return $s.elliptic.eddsa.getPayloadSize(e);case H.publicKey.x25519:case H.publicKey.x448:return $s.elliptic.ecdhX.getPayloadSize(e);default:throw Error("Unknown elliptic algo")}}var fa=/*#__PURE__*/Object.freeze({__proto__:null,generateParams:async function(e,t,r,n){switch(e){case H.publicKey.rsaEncrypt:case H.publicKey.rsaEncryptSign:case H.publicKey.rsaSign:return $s.rsa.generate(t,65537).then((({n:e,e:t,d:r,p:n,q:i,u:s})=>({privateParams:{d:r,p:n,q:i,u:s},publicParams:{n:e,e:t}})));case H.publicKey.ecdsa:return $s.elliptic.generate(r).then((({oid:e,Q:t,secret:r})=>({privateParams:{d:r},publicParams:{oid:new jn(e),Q:t}})));case H.publicKey.eddsaLegacy:return $s.elliptic.generate(r).then((({oid:e,Q:t,secret:r})=>({privateParams:{seed:r},publicParams:{oid:new jn(e),Q:t}})));case H.publicKey.ecdh:return $s.elliptic.generate(r).then((({oid:e,Q:t,secret:r,hash:n,cipher:i})=>({privateParams:{d:r},publicParams:{oid:new jn(e),Q:t,kdfParams:new ra({hash:n,cipher:i})}})));case H.publicKey.ed25519:case H.publicKey.ed448:return $s.elliptic.eddsa.generate(e).then((({A:e,seed:t})=>({privateParams:{seed:t},publicParams:{A:e}})));case H.publicKey.x25519:case H.publicKey.x448:return $s.elliptic.ecdhX.generate(e).then((({A:e,k:t})=>({privateParams:{k:t},publicParams:{A:e}})));case H.publicKey.hmac:return ca(await $s.hmac.generate(n),new aa(n));case H.publicKey.aead:return ca(ha(n),new sa(n));case H.publicKey.dsa:case H.publicKey.elgamal:throw Error("Unsupported algorithm for key generation.");default:throw Error("Unknown public key algorithm.")}},generateSessionKey:ha,getAEADMode:ua,getCipherParams:ue,getCurvePayloadSize:ya,getPreferredCurveHashAlgo:function(e,t){switch(e){case H.publicKey.ecdsa:case H.publicKey.eddsaLegacy:return $s.elliptic.getPreferredHashAlgo(t);case H.publicKey.ed25519:case H.publicKey.ed448:return $s.elliptic.eddsa.getPreferredHashAlgo(e);default:throw Error("Unknown elliptic signing algo")}},getPrefixRandom:async function(e){const{blockSize:t}=ue(e),r=await xr(t),n=new Uint8Array([r[r.length-2],r[r.length-1]]);return G.concat([r,n])},parseEncSessionKeyParams:function(e,t){let r=0;switch(e){case H.publicKey.rsaEncrypt:case H.publicKey.rsaEncryptSign:return{c:G.readMPI(t.subarray(r))};case H.publicKey.elgamal:{const e=G.readMPI(t.subarray(r));r+=e.length+2;return{c1:e,c2:G.readMPI(t.subarray(r))}}case H.publicKey.ecdh:{const e=G.readMPI(t.subarray(r));r+=e.length+2;const n=new ta;return n.read(t.subarray(r)),{V:e,C:n}}case H.publicKey.x25519:case H.publicKey.x448:{const n=ya(e),i=G.readExactSubarray(t,r,r+n);r+=i.length;const s=new oa;return s.read(t.subarray(r)),{ephemeralPublicKey:i,C:s}}case H.publicKey.aead:{const e=new ia;r+=e.read(t.subarray(r));const{ivLength:n}=ua(e.getValue()),i=t.subarray(r,r+n);r+=n;const s=new Xs;return r+=s.read(t.subarray(r)),{aeadMode:e,iv:i,c:s}}default:throw new Xn("Unknown public key encryption algorithm.")}},parsePrivateKeyParams:function(e,t,r){let n=0;switch(e){case H.publicKey.rsaEncrypt:case H.publicKey.rsaEncryptSign:case H.publicKey.rsaSign:{const e=G.readMPI(t.subarray(n));n+=e.length+2;const r=G.readMPI(t.subarray(n));n+=r.length+2;const i=G.readMPI(t.subarray(n));n+=i.length+2;const s=G.readMPI(t.subarray(n));return n+=s.length+2,{read:n,privateParams:{d:e,p:r,q:i,u:s}}}case H.publicKey.dsa:case H.publicKey.elgamal:{const e=G.readMPI(t.subarray(n));return n+=e.length+2,{read:n,privateParams:{x:e}}}case H.publicKey.ecdsa:case H.publicKey.ecdh:{const i=ya(e,r.oid);let s=G.readMPI(t.subarray(n));return n+=s.length+2,s=G.leftPad(s,i),{read:n,privateParams:{d:s}}}case H.publicKey.eddsaLegacy:{const i=ya(e,r.oid);if(r.oid.getName()!==H.curve.ed25519Legacy)throw Error("Unexpected OID for eddsaLegacy");let s=G.readMPI(t.subarray(n));return n+=s.length+2,s=G.leftPad(s,i),{read:n,privateParams:{seed:s}}}case H.publicKey.ed25519:case H.publicKey.ed448:{const r=ya(e),i=G.readExactSubarray(t,n,n+r);return n+=i.length,{read:n,privateParams:{seed:i}}}case H.publicKey.x25519:case H.publicKey.x448:{const r=ya(e),i=G.readExactSubarray(t,n,n+r);return n+=i.length,{read:n,privateParams:{k:i}}}case H.publicKey.hmac:{const{cipher:e}=r,i=Ke.getHashByteLength(e.getValue()),s=t.subarray(n,n+32);n+=32;const a=t.subarray(n,n+i);return n+=i,{read:n,privateParams:{hashSeed:s,keyMaterial:a}}}case H.publicKey.aead:{const{cipher:e}=r,i=t.subarray(n,n+32);n+=32;const{keySize:s}=ue(e.getValue()),a=t.subarray(n,n+s);return n+=s,{read:n,privateParams:{hashSeed:i,keyMaterial:a}}}default:throw new Xn("Unknown public key encryption algorithm.")}},parsePublicKeyParams:function(e,t){let r=0;switch(e){case H.publicKey.rsaEncrypt:case H.publicKey.rsaEncryptSign:case H.publicKey.rsaSign:{const e=G.readMPI(t.subarray(r));r+=e.length+2;const n=G.readMPI(t.subarray(r));return r+=n.length+2,{read:r,publicParams:{n:e,e:n}}}case H.publicKey.dsa:{const e=G.readMPI(t.subarray(r));r+=e.length+2;const n=G.readMPI(t.subarray(r));r+=n.length+2;const i=G.readMPI(t.subarray(r));r+=i.length+2;const s=G.readMPI(t.subarray(r));return r+=s.length+2,{read:r,publicParams:{p:e,q:n,g:i,y:s}}}case H.publicKey.elgamal:{const e=G.readMPI(t.subarray(r));r+=e.length+2;const n=G.readMPI(t.subarray(r));r+=n.length+2;const i=G.readMPI(t.subarray(r));return r+=i.length+2,{read:r,publicParams:{p:e,g:n,y:i}}}case H.publicKey.ecdsa:{const e=new jn;r+=e.read(t),la(e);const n=G.readMPI(t.subarray(r));return r+=n.length+2,{read:r,publicParams:{oid:e,Q:n}}}case H.publicKey.eddsaLegacy:{const e=new jn;if(r+=e.read(t),la(e),e.getName()!==H.curve.ed25519Legacy)throw Error("Unexpected OID for eddsaLegacy");let n=G.readMPI(t.subarray(r));return r+=n.length+2,n=G.leftPad(n,33),{read:r,publicParams:{oid:e,Q:n}}}case H.publicKey.ecdh:{const e=new jn;r+=e.read(t),la(e);const n=G.readMPI(t.subarray(r));r+=n.length+2;const i=new ra;return r+=i.read(t.subarray(r)),{read:r,publicParams:{oid:e,Q:n,kdfParams:i}}}case H.publicKey.ed25519:case H.publicKey.ed448:case H.publicKey.x25519:case H.publicKey.x448:{const n=G.readExactSubarray(t,r,r+ya(e));return r+=n.length,{read:r,publicParams:{A:n}}}case H.publicKey.hmac:case H.publicKey.aead:{const e=new sa;r+=e.read(t);const n=Ke.getHashByteLength(H.hash.sha256),i=t.subarray(r,r+n);return r+=n,{read:r,publicParams:{cipher:e,digest:i}}}default:throw new Xn("Unknown public key encryption algorithm.")}},publicKeyDecrypt:async function(e,t,r,n,i,s){switch(e){case H.publicKey.rsaEncryptSign:case H.publicKey.rsaEncrypt:{const{c:e}=n,{n:i,e:a}=t,{d:o,p:c,q:h,u}=r;return $s.rsa.decrypt(e,i,a,o,c,h,u,s)}case H.publicKey.elgamal:{const{c1:e,c2:i}=n,a=t.p,o=r.x;return $s.elgamal.decrypt(e,i,a,o,s)}case H.publicKey.ecdh:{const{oid:e,Q:s,kdfParams:a}=t,{d:o}=r,{V:c,C:h}=n;return $s.elliptic.ecdh.decrypt(e,a,c,h.data,s,o,i)}case H.publicKey.x25519:case H.publicKey.x448:{const{A:i}=t,{k:s}=r,{ephemeralPublicKey:a,C:o}=n;if(null!==o.algorithm&&!G.isAES(o.algorithm))throw Error("AES session key expected");return $s.elliptic.ecdhX.decrypt(e,a,o.wrappedKey,i,s)}case H.publicKey.aead:{const{cipher:e}=t,i=e.getValue(),{keyMaterial:s}=r,{aeadMode:a,iv:o,c}=n,h=ua(a.getValue());return(await h(i,s)).decrypt(c.data,o,new Uint8Array)}default:throw Error("Unknown public key encryption algorithm.")}},publicKeyEncrypt:async function(e,t,r,n,i,s){switch(e){case H.publicKey.rsaEncrypt:case H.publicKey.rsaEncryptSign:{const{n:e,e:t}=r;return{c:await $s.rsa.encrypt(i,e,t)}}case H.publicKey.elgamal:{const{p:e,g:t,y:n}=r;return $s.elgamal.encrypt(i,e,t,n)}case H.publicKey.ecdh:{const{oid:e,Q:t,kdfParams:n}=r,{publicKey:a,wrappedKey:o}=await $s.elliptic.ecdh.encrypt(e,n,i,t,s);return{V:a,C:new ta(o)}}case H.publicKey.x25519:case H.publicKey.x448:{if(t&&!G.isAES(t))throw Error("X25519 and X448 keys can only encrypt AES session keys");const{A:n}=r,{ephemeralPublicKey:s,wrappedKey:a}=await $s.elliptic.ecdhX.encrypt(e,i,n);return{ephemeralPublicKey:s,C:oa.fromObject({algorithm:t,wrappedKey:a})}}case H.publicKey.aead:{if(!n)throw Error("Cannot encrypt with symmetric key missing private parameters");const{cipher:e}=r,t=e.getValue(),{keyMaterial:s}=n,a=z.preferredAEADAlgorithm,o=ua(z.preferredAEADAlgorithm),{ivLength:c}=o,h=xr(c),u=await o(t,s),l=await u.encrypt(i,h,new Uint8Array);return{aeadMode:new ia(a),iv:h,c:new Xs(l)}}default:return[]}},serializeParams:function(e,t){const r=new Set([H.publicKey.ed25519,H.publicKey.x25519,H.publicKey.ed448,H.publicKey.x448,H.publicKey.aead,H.publicKey.hmac]),n=Object.keys(t).map((n=>{const i=t[n];return G.isUint8Array(i)?r.has(e)?i:G.uint8ArrayToMPI(i):i.write()}));return G.concatUint8Array(n)},validateParams:async function(e,t,r){if(!t||!r)throw Error("Missing key parameters");switch(e){case H.publicKey.rsaEncrypt:case H.publicKey.rsaEncryptSign:case H.publicKey.rsaSign:{const{n:e,e:n}=t,{d:i,p:s,q:a,u:o}=r;return $s.rsa.validateParams(e,n,i,s,a,o)}case H.publicKey.dsa:{const{p:e,q:n,g:i,y:s}=t,{x:a}=r;return $s.dsa.validateParams(e,n,i,s,a)}case H.publicKey.elgamal:{const{p:e,g:n,y:i}=t,{x:s}=r;return $s.elgamal.validateParams(e,n,i,s)}case H.publicKey.ecdsa:case H.publicKey.ecdh:{const n=$s.elliptic[H.read(H.publicKey,e)],{oid:i,Q:s}=t,{d:a}=r;return n.validateParams(i,s,a)}case H.publicKey.eddsaLegacy:{const{Q:e,oid:n}=t,{seed:i}=r;return $s.elliptic.eddsaLegacy.validateParams(n,e,i)}case H.publicKey.ed25519:case H.publicKey.ed448:{const{A:n}=t,{seed:i}=r;return $s.elliptic.eddsa.validateParams(e,n,i)}case H.publicKey.x25519:case H.publicKey.x448:{const{A:n}=t,{k:i}=r;return $s.elliptic.ecdhX.validateParams(e,n,i)}case H.publicKey.hmac:{const{cipher:e,digest:n}=t,{hashSeed:i,keyMaterial:s}=r;return Ke.getHashByteLength(e.getValue())===s.length&&G.equalsUint8Array(n,await Ke.sha256(i))}case H.publicKey.aead:{const{cipher:e,digest:n}=t,{hashSeed:i,keyMaterial:s}=r,{keySize:a}=ue(e.getValue());return a===s.length&&G.equalsUint8Array(n,await Ke.sha256(i))}default:throw Error("Unknown public key algorithm.")}}});const ga={cipher:le,hash:Ke,mode:wr,publicKey:$s,signature:ea,random:Rr,pkcs1:_r,pkcs5:Ls,aesKW:ns};Object.assign(ga,fa);class pa extends Error{constructor(...e){super(...e),Error.captureStackTrace&&Error.captureStackTrace(this,pa),this.name="Argon2OutOfMemoryError"}}let da,Aa,wa=2<<19;class ma{static get ARGON2_WASM_MEMORY_THRESHOLD_RELOAD(){return wa}static set ARGON2_WASM_MEMORY_THRESHOLD_RELOAD(e){wa=e}static reloadWasmModule(){da&&(Aa=da(),Aa.catch((()=>{})))}constructor(e=z){const{passes:t,parallelism:r,memoryExponent:n}=e.s2kArgon2Params;this.type="argon2",this.salt=null,this.t=t,this.p=r,this.encodedM=n}generateSalt(){this.salt=ga.random.getRandomBytes(16)}read(e){let t=0;return this.salt=e.subarray(t,t+16),t+=16,this.t=e[t++],this.p=e[t++],this.encodedM=e[t++],t}write(){const e=[new Uint8Array([H.write(H.s2k,this.type)]),this.salt,new Uint8Array([this.t,this.p,this.encodedM])];return G.concatUint8Array(e)}async produceKey(e,t){const r=2<ma.ARGON2_WASM_MEMORY_THRESHOLD_RELOAD&&ma.reloadWasmModule(),i}catch(e){throw e.message&&(e.message.includes("Unable to grow instance memory")||e.message.includes("failed to grow memory")||e.message.includes("WebAssembly.Memory.grow")||e.message.includes("Out of memory"))?new pa("Could not allocate required memory for Argon2"):e}}}class ba{constructor(e,t=z){this.algorithm=H.hash.sha256,this.type=H.read(H.s2k,e),this.c=t.s2kIterationCountByte,this.salt=null}generateSalt(){switch(this.type){case"salted":case"iterated":this.salt=ga.random.getRandomBytes(8)}}getCount(){return 16+(15&this.c)<<6+(this.c>>4)}read(e){let t=0;switch(this.algorithm=e[t++],this.type){case"simple":break;case"salted":this.salt=e.subarray(t,t+8),t+=8;break;case"iterated":this.salt=e.subarray(t,t+8),t+=8,this.c=e[t++];break;case"gnu":if("GNU"!==G.uint8ArrayToString(e.subarray(t,t+3)))throw new Xn("Unknown s2k type.");t+=3;if(1001!==1e3+e[t++])throw new Xn("Unknown s2k gnu protection mode.");this.type="gnu-dummy";break;default:throw new Xn("Unknown s2k type.")}return t}write(){if("gnu-dummy"===this.type)return new Uint8Array([101,0,...G.stringToUint8Array("GNU"),1]);const e=[new Uint8Array([H.write(H.s2k,this.type),this.algorithm])];switch(this.type){case"simple":break;case"salted":e.push(this.salt);break;case"iterated":e.push(this.salt),e.push(new Uint8Array([this.c]));break;case"gnu":throw Error("GNU s2k type not supported.");default:throw Error("Unknown s2k type.")}return G.concatUint8Array(e)}async produceKey(e,t){e=G.encodeUTF8(e);const r=[];let n=0,i=0;for(;n>>1|(21845&Na)<<1;Oa=(61680&(Oa=(52428&Oa)>>>2|(13107&Oa)<<2))>>>4|(3855&Oa)<<4,Fa[Na]=((65280&Oa)>>>8|(255&Oa)<<8)>>>1}var Ha=function(e,t,r){for(var n=e.length,i=0,s=new Sa(t);i>>c]=h}else for(a=new Sa(n),i=0;i>>15-e[i]);return a},za=new Ia(288);for(Na=0;Na<144;++Na)za[Na]=8;for(Na=144;Na<256;++Na)za[Na]=9;for(Na=256;Na<280;++Na)za[Na]=7;for(Na=280;Na<288;++Na)za[Na]=8;var _a=new Ia(32);for(Na=0;Na<32;++Na)_a[Na]=5;var Ga=/*#__PURE__*/Ha(za,9,0),ja=/*#__PURE__*/Ha(za,9,1),qa=/*#__PURE__*/Ha(_a,5,0),Va=/*#__PURE__*/Ha(_a,5,1),Wa=function(e){for(var t=e[0],r=1;rt&&(t=e[r]);return t},Za=function(e,t,r){var n=t/8|0;return(e[n]|e[n+1]<<8)>>(7&t)&r},Ya=function(e,t){var r=t/8|0;return(e[r]|e[r+1]<<8|e[r+2]<<16)>>(7&t)},Ja=function(e){return(e+7)/8|0},$a=function(e,t,r){(null==t||t<0)&&(t=0),(null==r||r>e.length)&&(r=e.length);var n=new(2==e.BYTES_PER_ELEMENT?Sa:4==e.BYTES_PER_ELEMENT?Ka:Ia)(r-t);return n.set(e.subarray(t,r)),n},Xa=["unexpected EOF","invalid block type","invalid length/literal","invalid distance","stream finished","no stream handler",,"no callback","invalid UTF-8 data","extra field too long","date not in range 1980-2099","filename too long","stream finishing","invalid zip data"],eo=function(e,t,r){var n=Error(t||Xa[e]);if(n.code=e,Error.captureStackTrace&&Error.captureStackTrace(n,eo),!r)throw n;return n},to=function(e,t,r){r<<=7&t;var n=t/8|0;e[n]|=r,e[n+1]|=r>>>8},ro=function(e,t,r){r<<=7&t;var n=t/8|0;e[n]|=r,e[n+1]|=r>>>8,e[n+2]|=r>>>16},no=function(e,t){for(var r=[],n=0;ny&&(y=s[n].s);var f=new Sa(y+1),g=io(r[u-1],f,0);if(g>t){n=0;var p=0,d=g-t,A=1<t))break;p+=A-(1<>>=d;p>0;){var m=s[n].s;f[m]=0&&p;--n){var b=s[n].s;f[b]==t&&(--f[b],++p)}g=t}return[new Ia(f),g]},io=function(e,t,r){return-1==e.s?Math.max(io(e.l,t,r+1),io(e.r,t,r+1)):t[e.s]=r},so=function(e){for(var t=e.length;t&&!e[--t];);for(var r=new Sa(++t),n=0,i=e[0],s=1,a=function(e){r[n++]=e},o=1;o<=t;++o)if(e[o]==i&&o!=t)++s;else{if(!i&&s>2){for(;s>138;s-=138)a(32754);s>2&&(a(s>10?s-11<<5|28690:s-3<<5|12305),s=0)}else if(s>3){for(a(i),--s;s>6;s-=6)a(8304);s>2&&(a(s-3<<5|8208),s=0)}for(;s--;)a(i);s=1,i=e[o]}return[r.subarray(0,n),t]},ao=function(e,t){for(var r=0,n=0;n>>8,e[i+2]=255^e[i],e[i+3]=255^e[i+1];for(var s=0;s4&&!S[Ua[C-1]];--C);var P,U,D,x,Q=h+5<<3,R=ao(i,za)+ao(s,_a)+a,L=ao(i,y)+ao(s,p)+a+14+3*C+ao(v,S)+(2*v[16]+3*v[17]+7*v[18]);if(Q<=R&&Q<=L)return oo(t,u,e.subarray(c,c+h));if(to(t,u,1+(L15&&(to(t,u,N[B]>>>5&127),u+=N[B]>>>12)}}}else P=Ga,U=za,D=qa,x=_a;for(B=0;B255){O=n[B]>>>18&31;ro(t,u,P[O+257]),u+=U[O+257],O>7&&(to(t,u,n[B]>>>23&31),u+=Ca[O]);var H=31&n[B];ro(t,u,D[H]),u+=x[H],H>3&&(ro(t,u,n[B]>>>5&8191),u+=Pa[H])}else ro(t,u,P[n[B]]),u+=U[n[B]];return ro(t,u,P[256]),u+U[256]},ho=/*#__PURE__*/new Ka([65540,131080,131088,131104,262176,1048704,1048832,2114560,2117632]),uo=/*#__PURE__*/new Ia(0),lo=function(e,t,r,n,i){return function(e,t,r,n,i,s){var a=e.length,o=new Ia(n+a+5*(1+Math.ceil(a/7e3))+i),c=o.subarray(n,o.length-i),h=0;if(!t||a<8)for(var u=0;u<=a;u+=65535){var l=u+65535;l>=a&&(c[h>>3]=s),h=oo(c,h+1,e.subarray(u,l))}else{for(var y=ho[t-1],f=y>>>13,g=8191&y,p=(1<7e3||S>24576)&&x>423){h=co(e,c,0,k,E,v,I,S,C,u-C,h),S=B=I=0,C=u;for(var Q=0;Q<286;++Q)E[Q]=0;for(Q=0;Q<30;++Q)v[Q]=0}var R=2,L=0,M=g,T=U-D&32767;if(x>2&&P==b(u-T))for(var F=Math.min(f,x)-1,N=Math.min(32767,u),O=Math.min(258,x);T<=N&&--M&&U!=D;){if(e[u+R]==e[u+R-T]){for(var H=0;HR){if(R=H,L=T,H>F)break;var z=Math.min(T,H-2),_=0;for(Q=0;Q_&&(_=j,D=G)}}}T+=(U=D)-(D=d[U])+32768&32767}if(L){k[S++]=268435456|Ra[R]<<18|Ta[L];var q=31&Ra[R],V=31&Ta[L];I+=Ca[q]+Pa[V],++E[257+q],++v[V],K=u+R,++B}else k[S++]=e[u],++E[e[u]]}}h=co(e,c,s,k,E,v,I,S,C,u-C,h),!s&&7&h&&(h=oo(c,h+1,uo))}return $a(o,0,n+Ja(h)+i)}(e,null==t.level?6:t.level,null==t.mem?Math.ceil(1.5*Math.max(8,Math.min(13,Math.log(e.length)))):12+t.mem,r,n,!i)},yo=/*#__PURE__*/function(){function e(e,t){t||"function"!=typeof e||(t=e,e={}),this.ondata=t,this.o=e||{}}return e.prototype.p=function(e,t){this.ondata(lo(e,this.o,0,0,!t),t)},e.prototype.push=function(e,t){this.ondata||eo(5),this.d&&eo(4),this.d=t,this.p(e,t||!1)},e}(),fo=/*#__PURE__*/function(){function e(e){this.s={},this.p=new Ia(0),this.ondata=e}return e.prototype.e=function(e){this.ondata||eo(5),this.d&&eo(4);var t=this.p.length,r=new Ia(t+e.length);r.set(this.p),r.set(e,t),this.p=r},e.prototype.c=function(e){this.d=this.s.i=e||!1;var t=this.s.b,r=function(e,t,r){var n=e.length;if(!n||r&&r.f&&!r.l)return t||new Ia(0);var i=!t||r,s=!r||r.i;r||(r={}),t||(t=new Ia(3*n));var a=function(e){var r=t.length;if(e>r){var n=new Ia(Math.max(2*r,e));n.set(t),t=n}},o=r.f||0,c=r.p||0,h=r.b||0,u=r.l,l=r.d,y=r.m,f=r.n,g=8*n;do{if(!u){o=Za(e,c,1);var p=Za(e,c+1,3);if(c+=3,!p){var d=e[(K=Ja(c)+4)-4]|e[K-3]<<8,A=K+d;if(A>n){s&&eo(0);break}i&&a(h+d),t.set(e.subarray(K,A),h),r.b=h+=d,r.p=c=8*A,r.f=o;continue}if(1==p)u=ja,l=Va,y=9,f=5;else if(2==p){var w=Za(e,c,31)+257,m=Za(e,c+10,15)+4,b=w+Za(e,c+5,31)+1;c+=14;for(var k=new Ia(b),E=new Ia(19),v=0;v>>4)<16)k[v++]=K;else{var P=0,U=0;for(16==K?(U=3+Za(e,c,3),c+=2,P=k[v-1]):17==K?(U=3+Za(e,c,7),c+=3):18==K&&(U=11+Za(e,c,127),c+=7);U--;)k[v++]=P}}var D=k.subarray(0,w),x=k.subarray(w);y=Wa(D),f=Wa(x),u=Ha(D,y,1),l=Ha(x,f,1)}else eo(1);if(c>g){s&&eo(0);break}}i&&a(h+131072);for(var Q=(1<>>4;if((c+=15&P)>g){s&&eo(0);break}if(P||eo(2),M<256)t[h++]=M;else{if(256==M){L=c,u=null;break}var T=M-254;if(M>264){var F=Ca[v=M-257];T=Za(e,c,(1<>>4;if(N||eo(3),c+=15&N,x=Ma[O],O>3&&(F=Pa[O],x+=Ya(e,c)&(1<g){s&&eo(0);break}i&&a(h+131072);for(var H=h+T;h>16),i=(65535&i)+15*(i>>16)}r=t,n=i},d:function(){return(255&(r%=65521))<<24|r>>>8<<16|(255&(n%=65521))<<8|n>>>8}}),this.v=1,yo.call(this,e,t)}return e.prototype.push=function(e,t){yo.prototype.push.call(this,e,t)},e.prototype.p=function(e,t){this.c.p(e);var r=lo(e,this.o,this.v&&2,t&&4,!t);this.v&&(function(e,t){var r=t.level,n=0==r?0:r<6?1:9==r?3:2;e[0]=120,e[1]=n<<6|(n?32-2*n:1)}(r,this.o),this.v=0),t&&function(e,t,r){for(;r;++t)e[t]=r,r>>>=8}(r,r.length-4,this.c.d()),this.ondata(r,t)},e}(),po=/*#__PURE__*/function(){function e(e){this.v=1,fo.call(this,e)}return e.prototype.push=function(e,t){if(fo.prototype.e.call(this,e),this.v){if(this.p.length<2&&!t)return;this.p=this.p.subarray(2),this.v=0}t&&(this.p.length<4&&eo(6,"invalid zlib data"),this.p=this.p.subarray(0,-4)),fo.prototype.c.call(this,t)},e}(),Ao="undefined"!=typeof TextDecoder&&/*#__PURE__*/new TextDecoder;try{Ao.decode(uo,{stream:!0}),1}catch(e){}class wo{static get tag(){return H.packet.literalData}constructor(e=new Date){this.format=H.literal.utf8,this.date=G.normalizeDate(e),this.text=null,this.data=null,this.filename=""}setText(e,t=H.literal.utf8){this.format=t,this.text=e,this.data=null}getText(e=!1){return(null===this.text||G.isStream(this.text))&&(this.text=G.decodeUTF8(G.nativeEOL(this.getBytes(e)))),this.text}setBytes(e,t){this.format=t,this.data=e,this.text=null}getBytes(e=!1){return null===this.data&&(this.data=G.canonicalizeEOL(G.encodeUTF8(this.text))),e?x(this.data):this.data}setFilename(e){this.filename=e}getFilename(){return this.filename}async read(e){await U(e,(async e=>{const t=await e.readByte(),r=await e.readByte();this.filename=G.decodeUTF8(await e.readBytes(r)),this.date=G.readDate(await e.readBytes(4));let n=e.remainder();g(n)&&(n=await L(n)),this.setBytes(n,t)}))}writeHeader(){const e=G.encodeUTF8(this.filename),t=new Uint8Array([e.length]),r=new Uint8Array([this.format]),n=G.writeDate(this.date);return G.concatUint8Array([r,t,e,n])}write(){const e=this.writeHeader(),t=this.getBytes();return G.concat([e,t])}}class mo{constructor(){this.bytes=""}read(e){return this.bytes=G.uint8ArrayToString(e.subarray(0,8)),this.bytes.length}write(){return G.stringToUint8Array(this.bytes)}toHex(){return G.uint8ArrayToHex(G.stringToUint8Array(this.bytes))}equals(e,t=!1){return t&&(e.isWildcard()||this.isWildcard())||this.bytes===e.bytes}isNull(){return""===this.bytes}isWildcard(){return/^0+$/.test(this.toHex())}static mapToHex(e){return e.toHex()}static fromID(e){const t=new mo;return t.read(G.hexToUint8Array(e)),t}static wildcard(){const e=new mo;return e.read(new Uint8Array(8)),e}}const bo=Symbol("verified"),ko="salt@notations.openpgpjs.org",Eo=new Set([H.signatureSubpacket.issuerKeyID,H.signatureSubpacket.issuerFingerprint,H.signatureSubpacket.embeddedSignature]);class vo{static get tag(){return H.packet.signature}constructor(){this.version=null,this.signatureType=null,this.hashAlgorithm=null,this.publicKeyAlgorithm=null,this.signatureData=null,this.unhashedSubpackets=[],this.unknownSubpackets=[],this.signedHashValue=null,this.salt=null,this.created=null,this.signatureExpirationTime=null,this.signatureNeverExpires=!0,this.exportable=null,this.trustLevel=null,this.trustAmount=null,this.regularExpression=null,this.revocable=null,this.keyExpirationTime=null,this.keyNeverExpires=null,this.preferredSymmetricAlgorithms=null,this.revocationKeyClass=null,this.revocationKeyAlgorithm=null,this.revocationKeyFingerprint=null,this.issuerKeyID=new mo,this.rawNotations=[],this.notations={},this.preferredHashAlgorithms=null,this.preferredCompressionAlgorithms=null,this.keyServerPreferences=null,this.preferredKeyServer=null,this.isPrimaryUserID=null,this.policyURI=null,this.keyFlags=null,this.signersUserID=null,this.reasonForRevocationFlag=null,this.reasonForRevocationString=null,this.features=null,this.signatureTargetPublicKeyAlgorithm=null,this.signatureTargetHashAlgorithm=null,this.signatureTargetHash=null,this.embeddedSignature=null,this.issuerKeyVersion=null,this.issuerFingerprint=null,this.preferredAEADAlgorithms=null,this.preferredCipherSuites=null,this.revoked=null,this[bo]=null}read(e,t=z){let r=0;if(this.version=e[r++],5===this.version&&!t.enableParsingV5Entities)throw new Xn("Support for v5 entities is disabled; turn on `config.enableParsingV5Entities` if needed");if(4!==this.version&&5!==this.version&&6!==this.version)throw new Xn(`Version ${this.version} of the signature packet is unsupported.`);if(this.signatureType=e[r++],this.publicKeyAlgorithm=e[r++],this.hashAlgorithm=e[r++],r+=this.readSubPackets(e.subarray(r,e.length),!0),!this.created)throw Error("Missing signature creation time subpacket.");if(this.signatureData=e.subarray(0,r),r+=this.readSubPackets(e.subarray(r,e.length),!1),this.signedHashValue=e.subarray(r,r+2),r+=2,6===this.version){const t=e[r++];this.salt=e.subarray(r,r+t),r+=t}const n=e.subarray(r,e.length),{read:i,signatureParams:s}=ga.signature.parseSignatureParams(this.publicKeyAlgorithm,n);if(iga.serializeParams(this.publicKeyAlgorithm,await this.params))):ga.serializeParams(this.publicKeyAlgorithm,this.params)}write(){const e=[];return e.push(this.signatureData),e.push(this.writeUnhashedSubPackets()),e.push(this.signedHashValue),6===this.version&&(e.push(new Uint8Array([this.salt.length])),e.push(this.salt)),e.push(this.writeParams()),G.concat(e)}async sign(e,t,r=new Date,n=!1,i){this.version=e.version,this.created=G.normalizeDate(r),this.issuerKeyVersion=e.version,this.issuerFingerprint=e.getFingerprintBytes(),this.issuerKeyID=e.getKeyID();const s=[new Uint8Array([this.version,this.signatureType,this.publicKeyAlgorithm,this.hashAlgorithm])];if(6===this.version){const e=Io(this.hashAlgorithm);if(null===this.salt)this.salt=ga.random.getRandomBytes(e);else if(e!==this.salt.length)throw Error("Provided salt does not have the required length")}else if(i.nonDeterministicSignaturesViaNotation){if(0!==this.rawNotations.filter((({name:e})=>e===ko)).length)throw Error("Unexpected existing salt notation");{const e=ga.random.getRandomBytes(Io(this.hashAlgorithm));this.rawNotations.push({name:ko,value:e,humanReadable:!1,critical:!1})}}s.push(this.writeHashedSubPackets()),this.unhashedSubpackets=[],this.signatureData=G.concat(s);const a=this.toHash(this.signatureType,t,n),o=await this.hash(this.signatureType,t,a,n);this.signedHashValue=R(D(o),0,2);const c=async()=>ga.signature.sign(this.publicKeyAlgorithm,this.hashAlgorithm,e.publicParams,e.privateParams,a,await L(o));G.isStream(o)?this.params=c():(this.params=await c(),this[bo]=!0)}writeHashedSubPackets(){const e=H.signatureSubpacket,t=[];let r;if(null===this.created)throw Error("Missing signature creation time");t.push(Bo(e.signatureCreationTime,!0,G.writeDate(this.created))),null!==this.signatureExpirationTime&&t.push(Bo(e.signatureExpirationTime,!0,G.writeNumber(this.signatureExpirationTime,4))),null!==this.exportable&&t.push(Bo(e.exportableCertification,!0,new Uint8Array([this.exportable?1:0]))),null!==this.trustLevel&&(r=new Uint8Array([this.trustLevel,this.trustAmount]),t.push(Bo(e.trustSignature,!0,r))),null!==this.regularExpression&&t.push(Bo(e.regularExpression,!0,this.regularExpression)),null!==this.revocable&&t.push(Bo(e.revocable,!0,new Uint8Array([this.revocable?1:0]))),null!==this.keyExpirationTime&&t.push(Bo(e.keyExpirationTime,!0,G.writeNumber(this.keyExpirationTime,4))),null!==this.preferredSymmetricAlgorithms&&(r=G.stringToUint8Array(G.uint8ArrayToString(this.preferredSymmetricAlgorithms)),t.push(Bo(e.preferredSymmetricAlgorithms,!1,r))),null!==this.revocationKeyClass&&(r=new Uint8Array([this.revocationKeyClass,this.revocationKeyAlgorithm]),r=G.concat([r,this.revocationKeyFingerprint]),t.push(Bo(e.revocationKey,!1,r))),!this.issuerKeyID.isNull()&&this.issuerKeyVersion<5&&t.push(Bo(e.issuerKeyID,!0,this.issuerKeyID.write())),this.rawNotations.forEach((({name:n,value:i,humanReadable:s,critical:a})=>{r=[new Uint8Array([s?128:0,0,0,0])];const o=G.encodeUTF8(n);r.push(G.writeNumber(o.length,2)),r.push(G.writeNumber(i.length,2)),r.push(o),r.push(i),r=G.concat(r),t.push(Bo(e.notationData,a,r))})),null!==this.preferredHashAlgorithms&&(r=G.stringToUint8Array(G.uint8ArrayToString(this.preferredHashAlgorithms)),t.push(Bo(e.preferredHashAlgorithms,!1,r))),null!==this.preferredCompressionAlgorithms&&(r=G.stringToUint8Array(G.uint8ArrayToString(this.preferredCompressionAlgorithms)),t.push(Bo(e.preferredCompressionAlgorithms,!1,r))),null!==this.keyServerPreferences&&(r=G.stringToUint8Array(G.uint8ArrayToString(this.keyServerPreferences)),t.push(Bo(e.keyServerPreferences,!1,r))),null!==this.preferredKeyServer&&t.push(Bo(e.preferredKeyServer,!1,G.encodeUTF8(this.preferredKeyServer))),null!==this.isPrimaryUserID&&t.push(Bo(e.primaryUserID,!1,new Uint8Array([this.isPrimaryUserID?1:0]))),null!==this.policyURI&&t.push(Bo(e.policyURI,!1,G.encodeUTF8(this.policyURI))),null!==this.keyFlags&&(r=G.stringToUint8Array(G.uint8ArrayToString(this.keyFlags)),t.push(Bo(e.keyFlags,!0,r))),null!==this.signersUserID&&t.push(Bo(e.signersUserID,!1,G.encodeUTF8(this.signersUserID))),null!==this.reasonForRevocationFlag&&(r=G.stringToUint8Array(String.fromCharCode(this.reasonForRevocationFlag)+this.reasonForRevocationString),t.push(Bo(e.reasonForRevocation,!0,r))),null!==this.features&&(r=G.stringToUint8Array(G.uint8ArrayToString(this.features)),t.push(Bo(e.features,!1,r))),null!==this.signatureTargetPublicKeyAlgorithm&&(r=[new Uint8Array([this.signatureTargetPublicKeyAlgorithm,this.signatureTargetHashAlgorithm])],r.push(G.stringToUint8Array(this.signatureTargetHash)),r=G.concat(r),t.push(Bo(e.signatureTarget,!0,r))),null!==this.embeddedSignature&&t.push(Bo(e.embeddedSignature,!0,this.embeddedSignature.write())),null!==this.issuerFingerprint&&(r=[new Uint8Array([this.issuerKeyVersion]),this.issuerFingerprint],r=G.concat(r),t.push(Bo(e.issuerFingerprint,this.version>=5,r))),null!==this.preferredAEADAlgorithms&&(r=G.stringToUint8Array(G.uint8ArrayToString(this.preferredAEADAlgorithms)),t.push(Bo(e.preferredAEADAlgorithms,!1,r))),null!==this.preferredCipherSuites&&(r=new Uint8Array([].concat(...this.preferredCipherSuites)),t.push(Bo(e.preferredCipherSuites,!1,r)));const n=G.concat(t),i=G.writeNumber(n.length,6===this.version?4:2);return G.concat([i,n])}writeUnhashedSubPackets(){const e=this.unhashedSubpackets.map((({type:e,critical:t,body:r})=>Bo(e,t,r))),t=G.concat(e),r=G.writeNumber(t.length,6===this.version?4:2);return G.concat([r,t])}readSubPacket(e,t=!0){let r=0;const n=!!(128&e[r]),i=127&e[r];if(r++,t||(this.unhashedSubpackets.push({type:i,critical:n,body:e.subarray(r,e.length)}),Eo.has(i)))switch(i){case H.signatureSubpacket.signatureCreationTime:this.created=G.readDate(e.subarray(r,e.length));break;case H.signatureSubpacket.signatureExpirationTime:{const t=G.readNumber(e.subarray(r,e.length));this.signatureNeverExpires=0===t,this.signatureExpirationTime=t;break}case H.signatureSubpacket.exportableCertification:this.exportable=1===e[r++];break;case H.signatureSubpacket.trustSignature:this.trustLevel=e[r++],this.trustAmount=e[r++];break;case H.signatureSubpacket.regularExpression:this.regularExpression=e[r];break;case H.signatureSubpacket.revocable:this.revocable=1===e[r++];break;case H.signatureSubpacket.keyExpirationTime:{const t=G.readNumber(e.subarray(r,e.length));this.keyExpirationTime=t,this.keyNeverExpires=0===t;break}case H.signatureSubpacket.preferredSymmetricAlgorithms:this.preferredSymmetricAlgorithms=[...e.subarray(r,e.length)];break;case H.signatureSubpacket.revocationKey:this.revocationKeyClass=e[r++],this.revocationKeyAlgorithm=e[r++],this.revocationKeyFingerprint=e.subarray(r,r+20);break;case H.signatureSubpacket.issuerKeyID:if(4===this.version)this.issuerKeyID.read(e.subarray(r,e.length));else if(t)throw Error("Unexpected Issuer Key ID subpacket");break;case H.signatureSubpacket.notationData:{const t=!!(128&e[r]);r+=4;const i=G.readNumber(e.subarray(r,r+2));r+=2;const s=G.readNumber(e.subarray(r,r+2));r+=2;const a=G.decodeUTF8(e.subarray(r,r+i)),o=e.subarray(r+i,r+i+s);this.rawNotations.push({name:a,humanReadable:t,value:o,critical:n}),t&&(this.notations[a]=G.decodeUTF8(o));break}case H.signatureSubpacket.preferredHashAlgorithms:this.preferredHashAlgorithms=[...e.subarray(r,e.length)];break;case H.signatureSubpacket.preferredCompressionAlgorithms:this.preferredCompressionAlgorithms=[...e.subarray(r,e.length)];break;case H.signatureSubpacket.keyServerPreferences:this.keyServerPreferences=[...e.subarray(r,e.length)];break;case H.signatureSubpacket.preferredKeyServer:this.preferredKeyServer=G.decodeUTF8(e.subarray(r,e.length));break;case H.signatureSubpacket.primaryUserID:this.isPrimaryUserID=0!==e[r++];break;case H.signatureSubpacket.policyURI:this.policyURI=G.decodeUTF8(e.subarray(r,e.length));break;case H.signatureSubpacket.keyFlags:this.keyFlags=[...e.subarray(r,e.length)];break;case H.signatureSubpacket.signersUserID:this.signersUserID=G.decodeUTF8(e.subarray(r,e.length));break;case H.signatureSubpacket.reasonForRevocation:this.reasonForRevocationFlag=e[r++],this.reasonForRevocationString=G.decodeUTF8(e.subarray(r,e.length));break;case H.signatureSubpacket.features:this.features=[...e.subarray(r,e.length)];break;case H.signatureSubpacket.signatureTarget:{this.signatureTargetPublicKeyAlgorithm=e[r++],this.signatureTargetHashAlgorithm=e[r++];const t=ga.getHashByteLength(this.signatureTargetHashAlgorithm);this.signatureTargetHash=G.uint8ArrayToString(e.subarray(r,r+t));break}case H.signatureSubpacket.embeddedSignature:this.embeddedSignature=new vo,this.embeddedSignature.read(e.subarray(r,e.length));break;case H.signatureSubpacket.issuerFingerprint:this.issuerKeyVersion=e[r++],this.issuerFingerprint=e.subarray(r,e.length),this.issuerKeyVersion>=5?this.issuerKeyID.read(this.issuerFingerprint):this.issuerKeyID.read(this.issuerFingerprint.subarray(-8));break;case H.signatureSubpacket.preferredAEADAlgorithms:this.preferredAEADAlgorithms=[...e.subarray(r,e.length)];break;case H.signatureSubpacket.preferredCipherSuites:this.preferredCipherSuites=[];for(let t=r;t{r+=e.length}),(()=>{const n=[];return 5!==this.version||this.signatureType!==H.signature.binary&&this.signatureType!==H.signature.text||(t?n.push(new Uint8Array(6)):n.push(e.writeHeader())),n.push(new Uint8Array([this.version,255])),5===this.version&&n.push(new Uint8Array(4)),n.push(G.writeNumber(r,4)),G.concat(n)}))}toHash(e,t,r=!1){const n=this.toSign(e,t);return G.concat([this.salt||new Uint8Array,n,this.signatureData,this.calculateTrailer(t,r)])}async hash(e,t,r,n=!1){if(6===this.version&&this.salt.length!==Io(this.hashAlgorithm))throw Error("Signature salt does not have the expected length");return r||(r=this.toHash(e,t,n)),ga.hash.digest(this.hashAlgorithm,r)}async verify(e,t,r,n=new Date,i=!1,s=z){if(!this.issuerKeyID.equals(e.getKeyID()))throw Error("Signature was not issued by the given public key");if(this.publicKeyAlgorithm!==e.algorithm)throw Error("Public key algorithm used to sign signature does not match issuer key algorithm.");const a=t===H.signature.binary||t===H.signature.text;if(!(this[bo]&&!a)){let n,s;if(this.hashed?s=await this.hashed:(n=this.toHash(t,r,i),s=await this.hash(t,r,n)),s=await L(s),this.signedHashValue[0]!==s[0]||this.signedHashValue[1]!==s[1])throw Error("Signed digest did not match");this.params=await this.params;const a=this.publicKeyAlgorithm===H.publicKey.hmac?e.privateParams:null;if(this[bo]=await ga.signature.verify(this.publicKeyAlgorithm,this.hashAlgorithm,this.params,e.publicParams,a,n,s),!this[bo])throw Error("Signature verification failed")}const o=G.normalizeDate(n);if(o&&this.created>o)throw Error("Signature creation time is in the future");if(o&&o>=this.getExpirationTime())throw Error("Signature is expired");if(s.rejectHashAlgorithms.has(this.hashAlgorithm))throw Error("Insecure hash algorithm: "+H.read(H.hash,this.hashAlgorithm).toUpperCase());if(s.rejectMessageHashAlgorithms.has(this.hashAlgorithm)&&[H.signature.binary,H.signature.text].includes(this.signatureType))throw Error("Insecure message hash algorithm: "+H.read(H.hash,this.hashAlgorithm).toUpperCase());if(this.unknownSubpackets.forEach((({type:e,critical:t})=>{if(t)throw Error("Unknown critical signature subpacket type "+e)})),this.rawNotations.forEach((({name:e,critical:t})=>{if(t&&s.knownNotations.indexOf(e)<0)throw Error("Unknown critical notation: "+e)})),null!==this.revocationKeyClass)throw Error("This key is intended to be revoked with an authorized key, which OpenPGP.js does not support.")}isExpired(e=new Date){const t=G.normalizeDate(e);return null!==t&&!(this.created<=t&&tvo.prototype.calculateTrailer.apply(await this.correspondingSig,e)))}async verify(){const e=await this.correspondingSig;if(!e||e.constructor.tag!==H.packet.signature)throw Error("Corresponding signature packet missing");if(e.signatureType!==this.signatureType||e.hashAlgorithm!==this.hashAlgorithm||e.publicKeyAlgorithm!==this.publicKeyAlgorithm||!e.issuerKeyID.equals(this.issuerKeyID)||3===this.version&&6===e.version||6===this.version&&6!==e.version||6===this.version&&!G.equalsUint8Array(e.issuerFingerprint,this.issuerFingerprint)||6===this.version&&!G.equalsUint8Array(e.salt,this.salt))throw Error("Corresponding signature packet does not match one-pass signature packet");return e.hashed=this.hashed,e.verify.apply(e,arguments)}}function Ko(e,t){if(!t[e]){let t;try{t=H.read(H.packet,e)}catch(t){throw new ei("Unknown packet type with tag: "+e)}throw Error("Packet not allowed in this context: "+t)}return new t[e]}So.prototype.hash=vo.prototype.hash,So.prototype.toHash=vo.prototype.toHash,So.prototype.toSign=vo.prototype.toSign;class Co extends Array{static async fromBinary(e,t,r=z){const n=new Co;return await n.read(e,t,r),n}async read(e,t,r=z){r.additionalAllowedPackets.length&&(t={...t,...G.constructAllowedPackets(r.additionalAllowedPackets)}),this.stream=P(e,(async(e,n)=>{const i=N(n);try{for(;;){await i.ready;if(await $n(e,(async e=>{try{if(e.tag===H.packet.marker||e.tag===H.packet.trust||e.tag===H.packet.padding)return;const n=Ko(e.tag,t);n.packets=new Co,n.fromStream=G.isStream(e.packet),await n.read(e.packet,r),await i.write(n)}catch(t){if(t instanceof ei){if(!(e.tag<=39))return;await i.abort(t)}const n=!r.ignoreUnsupportedPackets&&t instanceof Xn,s=!(r.ignoreMalformedPackets||t instanceof Xn);if(n||s||Jn(e.tag))await i.abort(t);else{const t=new ti(e.tag,e.packet);await i.write(t)}G.printDebugError(t)}})))return await i.ready,void await i.close()}}catch(e){await i.abort(e)}}));const n=F(this.stream);for(;;){const{done:e,value:t}=await n.read();if(e?this.stream=null:this.push(t),e||Jn(t.constructor.tag))break}n.releaseLock()}write(){const e=[];for(let t=0;t{if(t.push(e),i+=e.length,i>=s){const e=Math.min(Math.log(i)/Math.LN2|0,30),r=2**e,n=G.concat([Wn(e)].concat(t));return t=[n.subarray(1+r)],i=t[0].length,n.subarray(0,1+r)}}),(()=>G.concat([Vn(i)].concat(t)))))}else{if(G.isStream(n)){let t=0;e.push(C(D(n),(e=>{t+=e.length}),(()=>Yn(r,t))))}else e.push(Yn(r,n.length));e.push(n)}}return G.concat(e)}filterByTag(...e){const t=new Co,r=e=>t=>e===t;for(let n=0;nt.constructor.tag===e))}indexOfTag(...e){const t=[],r=this,n=e=>t=>e===t;for(let i=0;i{this.algorithm=await e.readByte(),this.compressed=e.remainder(),await this.decompress(t)}))}write(){return null===this.compressed&&this.compress(),G.concat([new Uint8Array([this.algorithm]),this.compressed])}async decompress(e=z){const t=H.read(H.compression,this.algorithm),r=Lo[t];if(!r)throw Error(t+" decompression not supported");this.packets=await Co.fromBinary(await r(this.compressed),Po,e)}compress(){const e=H.read(H.compression,this.algorithm),t=Ro[e];if(!t)throw Error(e+" compression not supported");this.compressed=t(this.packets.write())}}function Do(e,t){return r=>{if(!G.isStream(r)||g(r))return T((()=>L(r).then((e=>new Promise(((r,n)=>{const i=new t;i.ondata=e=>{r(e)};try{i.push(e,!0)}catch(e){n(e)}}))))));if(e)try{const t=e();return r.pipeThrough(t)}catch(e){if("TypeError"!==e.name)throw e}const n=r.getReader(),i=new t;return new ReadableStream({async start(e){for(i.ondata=async(t,r)=>{e.enqueue(t),r&&e.close()};;){const{done:e,value:t}=await n.read();if(e)return void i.push(new Uint8Array,!0);t.length&&i.push(t)}}})}}function xo(){return async function(e){const{decode:t}=await Promise.resolve().then((function(){return Of}));return T((async()=>t(await L(e))))}}const Qo=e=>({compressor:"undefined"!=typeof CompressionStream&&(()=>new CompressionStream(e)),decompressor:"undefined"!=typeof DecompressionStream&&(()=>new DecompressionStream(e))}),Ro={zip:/*#__PURE__*/Do(Qo("deflate-raw").compressor,yo),zlib:/*#__PURE__*/Do(Qo("deflate").compressor,go)},Lo={uncompressed:e=>e,zip:/*#__PURE__*/Do(Qo("deflate-raw").decompressor,fo),zlib:/*#__PURE__*/Do(Qo("deflate").decompressor,po),bzip2:/*#__PURE__*/xo()},Mo=/*#__PURE__*/G.constructAllowedPackets([wo,Uo,So,vo]);class To{static get tag(){return H.packet.symEncryptedIntegrityProtectedData}static fromObject({version:e,aeadAlgorithm:t}){if(1!==e&&2!==e)throw Error("Unsupported SEIPD version");const r=new To;return r.version=e,2===e&&(r.aeadAlgorithm=t),r}constructor(){this.version=null,this.cipherAlgorithm=null,this.aeadAlgorithm=null,this.chunkSizeByte=null,this.salt=null,this.encrypted=null,this.packets=null}async read(e){await U(e,(async e=>{if(this.version=await e.readByte(),1!==this.version&&2!==this.version)throw new Xn(`Version ${this.version} of the SEIP packet is unsupported.`);2===this.version&&(this.cipherAlgorithm=await e.readByte(),this.aeadAlgorithm=await e.readByte(),this.chunkSizeByte=await e.readByte(),this.salt=await e.readBytes(32)),this.encrypted=e.remainder()}))}write(){return 2===this.version?G.concat([new Uint8Array([this.version,this.cipherAlgorithm,this.aeadAlgorithm,this.chunkSizeByte]),this.salt,this.encrypted]):G.concat([new Uint8Array([this.version]),this.encrypted])}async encrypt(e,t,r=z){const{blockSize:n,keySize:i}=ga.getCipherParams(e);if(t.length!==i)throw Error("Unexpected session key size");let s=this.packets.write();if(g(s)&&(s=await L(s)),2===this.version)this.cipherAlgorithm=e,this.salt=ga.random.getRandomBytes(32),this.chunkSizeByte=r.aeadChunkSizeByte,this.encrypted=await Fo(this,"encrypt",t,s);else{const i=await ga.getPrefixRandom(e),a=new Uint8Array([211,20]),o=G.concat([i,s,a]),c=await ga.hash.sha1(x(o)),h=G.concat([o,c]);this.encrypted=await ga.mode.cfb.encrypt(e,t,h,new Uint8Array(n),r)}return!0}async decrypt(e,t,r=z){if(t.length!==ga.getCipherParams(e).keySize)throw Error("Unexpected session key size");let n,i=D(this.encrypted);if(g(i)&&(i=await L(i)),2===this.version){if(this.cipherAlgorithm!==e)throw Error("Unexpected session key algorithm");n=await Fo(this,"decrypt",t,i)}else{const{blockSize:s}=ga.getCipherParams(e),a=await ga.mode.cfb.decrypt(e,t,i,new Uint8Array(s)),o=R(x(a),-20),c=R(a,0,-20),h=Promise.all([L(await ga.hash.sha1(x(c))),L(o)]).then((([e,t])=>{if(!G.equalsUint8Array(e,t))throw Error("Modification detected.");return new Uint8Array})),u=R(c,s+2);n=R(u,0,-2),n=B([n,T((()=>h))]),G.isStream(i)&&r.allowUnauthenticatedStream||(n=await L(n))}return this.packets=await Co.fromBinary(n,Mo,r),!0}}async function Fo(e,t,r,n){const i=e instanceof To&&2===e.version,s=!i&&e.constructor.tag===H.packet.aeadEncryptedData;if(!i&&!s)throw Error("Unexpected packet type");const a=ga.getAEADMode(e.aeadAlgorithm),o="decrypt"===t?a.tagLength:0,c="encrypt"===t?a.tagLength:0,h=2**(e.chunkSizeByte+6)+o,u=s?8:0,l=new ArrayBuffer(13+u),y=new Uint8Array(l,0,5+u),f=new Uint8Array(l),g=new DataView(l),p=new Uint8Array(l,5,8);y.set([192|e.constructor.tag,e.version,e.cipherAlgorithm,e.aeadAlgorithm,e.chunkSizeByte],0);let d,A,w=0,m=Promise.resolve(),b=0,k=0;if(i){const{keySize:t}=ga.getCipherParams(e.cipherAlgorithm),{ivLength:n}=a,i=new Uint8Array(l,0,5),s=await ss(H.hash.sha256,r,e.salt,i,t+n);r=s.subarray(0,t),d=s.subarray(t),d.fill(0,d.length-8),A=new DataView(d.buffer,d.byteOffset,d.byteLength)}else d=e.iv;const E=await a(e.cipherAlgorithm,r);return P(n,(async(r,n)=>{if("array"!==G.isStream(r)){const t=new TransformStream({},{highWaterMark:G.getHardwareConcurrency()*2**(e.chunkSizeByte+6),size:e=>e.length});I(t.readable,n),n=t.writable}const s=F(r),a=N(n);try{for(;;){let e=await s.readBytes(h+o)||new Uint8Array;const r=e.subarray(e.length-o);let n,l,v;if(e=e.subarray(0,e.length-o),i)v=d;else{v=d.slice();for(let e=0;e<8;e++)v[d.length-8+e]^=p[e]}if(!w||e.length?(s.unshift(r),n=E[t](e,v,y),n.catch((()=>{})),k+=e.length-o+c):(g.setInt32(5+u+4,b),n=E[t](r,v,f),n.catch((()=>{})),k+=c,l=!0),b+=e.length-o,m=m.then((()=>n)).then((async e=>{await a.ready,await a.write(e),k-=e.length})).catch((e=>a.abort(e))),(l||k>a.desiredSize)&&await m,l){await a.close();break}i?A.setInt32(d.length-4,++w):g.setInt32(9,++w)}}catch(e){await a.ready.catch((()=>{})),await a.abort(e)}}))}const No=/*#__PURE__*/G.constructAllowedPackets([wo,Uo,So,vo]);class Oo{static get tag(){return H.packet.aeadEncryptedData}constructor(){this.version=1,this.cipherAlgorithm=null,this.aeadAlgorithm=H.aead.eax,this.chunkSizeByte=null,this.iv=null,this.encrypted=null,this.packets=null}async read(e){await U(e,(async e=>{const t=await e.readByte();if(1!==t)throw new Xn(`Version ${t} of the AEAD-encrypted data packet is not supported.`);this.cipherAlgorithm=await e.readByte(),this.aeadAlgorithm=await e.readByte(),this.chunkSizeByte=await e.readByte();const r=ga.getAEADMode(this.aeadAlgorithm);this.iv=await e.readBytes(r.ivLength),this.encrypted=e.remainder()}))}write(){return G.concat([new Uint8Array([this.version,this.cipherAlgorithm,this.aeadAlgorithm,this.chunkSizeByte]),this.iv,this.encrypted])}async decrypt(e,t,r=z){this.packets=await Co.fromBinary(await Fo(this,"decrypt",t,D(this.encrypted)),No,r)}async encrypt(e,t,r=z){this.cipherAlgorithm=e;const{ivLength:n}=ga.getAEADMode(this.aeadAlgorithm);this.iv=ga.random.getRandomBytes(n),this.chunkSizeByte=r.aeadChunkSizeByte;const i=this.packets.write();this.encrypted=await Fo(this,"encrypt",t,i)}}class Ho{static get tag(){return H.packet.publicKeyEncryptedSessionKey}constructor(){this.version=null,this.publicKeyID=new mo,this.publicKeyVersion=null,this.publicKeyFingerprint=null,this.publicKeyAlgorithm=null,this.sessionKey=null,this.sessionKeyAlgorithm=null,this.encrypted={}}static fromObject({version:e,encryptionKeyPacket:t,anonymousRecipient:r,sessionKey:n,sessionKeyAlgorithm:i}){const s=new Ho;if(3!==e&&6!==e)throw Error("Unsupported PKESK version");return s.version=e,6===e&&(s.publicKeyVersion=r?null:t.version,s.publicKeyFingerprint=r?null:t.getFingerprintBytes()),s.publicKeyID=r?mo.wildcard():t.getKeyID(),s.publicKeyAlgorithm=t.algorithm,s.sessionKey=n,s.sessionKeyAlgorithm=i,s}read(e){let t=0;if(this.version=e[t++],3!==this.version&&6!==this.version)throw new Xn(`Version ${this.version} of the PKESK packet is unsupported.`);if(6===this.version){const r=e[t++];if(r){this.publicKeyVersion=e[t++];const n=r-1;this.publicKeyFingerprint=e.subarray(t,t+n),t+=n,this.publicKeyVersion>=5?this.publicKeyID.read(this.publicKeyFingerprint):this.publicKeyID.read(this.publicKeyFingerprint.subarray(-8))}else this.publicKeyID=mo.wildcard()}else t+=this.publicKeyID.read(e.subarray(t,t+8));if(this.publicKeyAlgorithm=e[t++],this.encrypted=ga.parseEncSessionKeyParams(this.publicKeyAlgorithm,e.subarray(t)),this.publicKeyAlgorithm===H.publicKey.x25519||this.publicKeyAlgorithm===H.publicKey.x448)if(3===this.version)this.sessionKeyAlgorithm=H.write(H.symmetric,this.encrypted.C.algorithm);else if(null!==this.encrypted.C.algorithm)throw Error("Unexpected cleartext symmetric algorithm")}write(){const e=[new Uint8Array([this.version])];return 6===this.version?null!==this.publicKeyFingerprint?(e.push(new Uint8Array([this.publicKeyFingerprint.length+1,this.publicKeyVersion])),e.push(this.publicKeyFingerprint)):e.push(new Uint8Array([0])):e.push(this.publicKeyID.write()),e.push(new Uint8Array([this.publicKeyAlgorithm]),ga.serializeParams(this.publicKeyAlgorithm,this.encrypted)),G.concatUint8Array(e)}async encrypt(e){const t=H.write(H.publicKey,this.publicKeyAlgorithm),r=3===this.version?this.sessionKeyAlgorithm:null,n=5===e.version?e.getFingerprintBytes().subarray(0,20):e.getFingerprintBytes(),i=zo(this.version,t,r,this.sessionKey),s=t===H.publicKey.aead?e.privateParams:null;this.encrypted=await ga.publicKeyEncrypt(t,r,e.publicParams,s,i,n)}async decrypt(e,t){if(this.publicKeyAlgorithm!==e.algorithm)throw Error("Decryption error");const r=t?zo(this.version,this.publicKeyAlgorithm,t.sessionKeyAlgorithm,t.sessionKey):null,n=5===e.version?e.getFingerprintBytes().subarray(0,20):e.getFingerprintBytes(),i=await ga.publicKeyDecrypt(this.publicKeyAlgorithm,e.publicParams,e.privateParams,this.encrypted,n,r),{sessionKey:s,sessionKeyAlgorithm:a}=function(e,t,r,n){switch(t){case H.publicKey.rsaEncrypt:case H.publicKey.rsaEncryptSign:case H.publicKey.elgamal:case H.publicKey.ecdh:case H.publicKey.aead:{const t=r.subarray(0,r.length-2),i=r.subarray(r.length-2),s=G.writeChecksum(t.subarray(t.length%8)),a=s[0]===i[0]&s[1]===i[1],o=6===e?{sessionKeyAlgorithm:null,sessionKey:t}:{sessionKeyAlgorithm:t[0],sessionKey:t.subarray(1)};if(n){const t=a&o.sessionKeyAlgorithm===n.sessionKeyAlgorithm&o.sessionKey.length===n.sessionKey.length;return{sessionKey:G.selectUint8Array(t,o.sessionKey,n.sessionKey),sessionKeyAlgorithm:6===e?null:G.selectUint8(t,o.sessionKeyAlgorithm,n.sessionKeyAlgorithm)}}if(a&&(6===e||H.read(H.symmetric,o.sessionKeyAlgorithm)))return o;throw Error("Decryption error")}case H.publicKey.x25519:case H.publicKey.x448:return{sessionKeyAlgorithm:null,sessionKey:r};default:throw Error("Unsupported public key algorithm")}}(this.version,this.publicKeyAlgorithm,i,t);if(3===this.version){const e=this.publicKeyAlgorithm!==H.publicKey.x25519&&this.publicKeyAlgorithm!==H.publicKey.x448;if(this.sessionKeyAlgorithm=e?a:this.sessionKeyAlgorithm,s.length!==ga.getCipherParams(this.sessionKeyAlgorithm).keySize)throw Error("Unexpected session key size")}this.sessionKey=s}}function zo(e,t,r,n){switch(t){case H.publicKey.rsaEncrypt:case H.publicKey.rsaEncryptSign:case H.publicKey.elgamal:case H.publicKey.ecdh:case H.publicKey.aead:return G.concatUint8Array([new Uint8Array(6===e?[]:[r]),n,G.writeChecksum(n.subarray(n.length%8))]);case H.publicKey.x25519:case H.publicKey.x448:return n;default:throw Error("Unsupported public key algorithm")}}class _o{static get tag(){return H.packet.symEncryptedSessionKey}constructor(e=z){this.version=e.aeadProtect?6:4,this.sessionKey=null,this.sessionKeyEncryptionAlgorithm=null,this.sessionKeyAlgorithm=null,this.aeadAlgorithm=H.write(H.aead,e.preferredAEADAlgorithm),this.encrypted=null,this.s2k=null,this.iv=null}read(e){let t=0;if(this.version=e[t++],4!==this.version&&5!==this.version&&6!==this.version)throw new Xn(`Version ${this.version} of the SKESK packet is unsupported.`);6===this.version&&t++;const r=e[t++];this.version>=5&&(this.aeadAlgorithm=e[t++],6===this.version&&t++);const n=e[t++];if(this.s2k=Ea(n),t+=this.s2k.read(e.subarray(t,e.length)),this.version>=5){const r=ga.getAEADMode(this.aeadAlgorithm);this.iv=e.subarray(t,t+=r.ivLength)}this.version>=5||t=5){const e=ga.getAEADMode(this.aeadAlgorithm),r=new Uint8Array([192|_o.tag,this.version,this.sessionKeyEncryptionAlgorithm,this.aeadAlgorithm]),s=6===this.version?await ss(H.hash.sha256,i,new Uint8Array,r,n):i,a=await e(t,s);this.sessionKey=await a.decrypt(this.encrypted,this.iv,r)}else if(null!==this.encrypted){const e=await ga.mode.cfb.decrypt(t,i,this.encrypted,new Uint8Array(r));if(this.sessionKeyAlgorithm=H.write(H.symmetric,e[0]),this.sessionKey=e.subarray(1,e.length),this.sessionKey.length!==ga.getCipherParams(this.sessionKeyAlgorithm).keySize)throw Error("Unexpected session key size")}else this.sessionKey=i}async encrypt(e,t=z){const r=null!==this.sessionKeyEncryptionAlgorithm?this.sessionKeyEncryptionAlgorithm:this.sessionKeyAlgorithm;this.sessionKeyEncryptionAlgorithm=r,this.s2k=va(t),this.s2k.generateSalt();const{blockSize:n,keySize:i}=ga.getCipherParams(r),s=await this.s2k.produceKey(e,i);if(null===this.sessionKey&&(this.sessionKey=ga.generateSessionKey(this.sessionKeyAlgorithm)),this.version>=5){const e=ga.getAEADMode(this.aeadAlgorithm);this.iv=ga.random.getRandomBytes(e.ivLength);const t=new Uint8Array([192|_o.tag,this.version,this.sessionKeyEncryptionAlgorithm,this.aeadAlgorithm]),n=6===this.version?await ss(H.hash.sha256,s,new Uint8Array,t,i):s,a=await e(r,n);this.encrypted=await a.encrypt(this.sessionKey,this.iv,t)}else{const e=G.concatUint8Array([new Uint8Array([this.sessionKeyAlgorithm]),this.sessionKey]);this.encrypted=await ga.mode.cfb.encrypt(r,s,e,new Uint8Array(n),t)}}}class Go{static get tag(){return H.packet.publicKey}constructor(e=new Date,t=z){this.version=t.v6Keys?6:4,this.created=G.normalizeDate(e),this.algorithm=null,this.publicParams=null,this.expirationTimeV3=0,this.fingerprint=null,this.keyID=null}static fromSecretKeyPacket(e){const t=new Go,{version:r,created:n,algorithm:i,publicParams:s,keyID:a,fingerprint:o}=e;return t.version=r,t.created=n,t.algorithm=i,t.publicParams=s,t.keyID=a,t.fingerprint=o,t}async read(e,t=z){let r=0;if(this.version=e[r++],5===this.version&&!t.enableParsingV5Entities)throw new Xn("Support for parsing v5 entities is disabled; turn on `config.enableParsingV5Entities` if needed");if(4===this.version||5===this.version||6===this.version){this.created=G.readDate(e.subarray(r,r+4)),r+=4,this.algorithm=e[r++],this.version>=5&&(r+=4);const{read:t,publicParams:n}=ga.parsePublicKeyParams(this.algorithm,e.subarray(r));if(6===this.version&&n.oid&&(n.oid.getName()===H.curve.curve25519Legacy||n.oid.getName()===H.curve.ed25519Legacy))throw Error("Legacy curve25519 cannot be used with v6 keys");return this.publicParams=n,r+=t,await this.computeFingerprintAndKeyID(),r}throw new Xn(`Version ${this.version} of the key packet is unsupported.`)}write(){const e=[];e.push(new Uint8Array([this.version])),e.push(G.writeDate(this.created)),e.push(new Uint8Array([this.algorithm]));const t=ga.serializeParams(this.algorithm,this.publicParams);return this.version>=5&&e.push(G.writeNumber(t.length,4)),e.push(t),G.concatUint8Array(e)}writeForHash(e){const t=this.writePublicKey(),r=149+e,n=e>=5?4:2;return G.concatUint8Array([new Uint8Array([r]),G.writeNumber(t.length,n),t])}isDecrypted(){return null}getCreationTime(){return this.created}getKeyID(){return this.keyID}async computeFingerprintAndKeyID(){if(await this.computeFingerprint(),this.keyID=new mo,this.version>=5)this.keyID.read(this.fingerprint.subarray(0,8));else{if(4!==this.version)throw Error("Unsupported key version");this.keyID.read(this.fingerprint.subarray(12,20))}}async computeFingerprint(){const e=this.writeForHash(this.version);if(this.version>=5)this.fingerprint=await ga.hash.sha256(e);else{if(4!==this.version)throw Error("Unsupported key version");this.fingerprint=await ga.hash.sha1(e)}}getFingerprintBytes(){return this.fingerprint}getFingerprint(){return G.uint8ArrayToHex(this.getFingerprintBytes())}hasSameFingerprintAs(e){return this.version===e.version&&G.equalsUint8Array(this.writePublicKey(),e.writePublicKey())}getAlgorithmInfo(){const e={};e.algorithm=H.read(H.publicKey,this.algorithm);const t=this.publicParams.n||this.publicParams.p;return t?e.bits=G.uint8ArrayBitLength(t):this.publicParams.oid?e.curve=this.publicParams.oid.getName():this.publicParams.cipher&&(e.symmetric=this.publicParams.cipher.getName()),e}}Go.prototype.readPublicKey=Go.prototype.read,Go.prototype.writePublicKey=Go.prototype.write;const jo=/*#__PURE__*/G.constructAllowedPackets([wo,Uo,So,vo]);class qo{static get tag(){return H.packet.symmetricallyEncryptedData}constructor(){this.encrypted=null,this.packets=null}read(e){this.encrypted=e}write(){return this.encrypted}async decrypt(e,t,r=z){if(!r.allowUnauthenticatedMessages)throw Error("Message is not authenticated.");const{blockSize:n}=ga.getCipherParams(e),i=await L(D(this.encrypted)),s=await ga.mode.cfb.decrypt(e,t,i.subarray(n+2),i.subarray(2,n+2));this.packets=await Co.fromBinary(s,jo,r)}async encrypt(e,t,r=z){const n=this.packets.write(),{blockSize:i}=ga.getCipherParams(e),s=await ga.getPrefixRandom(e),a=await ga.mode.cfb.encrypt(e,t,s,new Uint8Array(i),r),o=await ga.mode.cfb.encrypt(e,t,n,a.subarray(2),r);this.encrypted=G.concat([a,o])}}class Vo extends Go{static get tag(){return H.packet.publicSubkey}constructor(e,t){super(e,t)}static fromSecretSubkeyPacket(e){const t=new Vo,{version:r,created:n,algorithm:i,publicParams:s,keyID:a,fingerprint:o}=e;return t.version=r,t.created=n,t.algorithm=i,t.publicParams=s,t.keyID=a,t.fingerprint=o,t}}class Wo{static get tag(){return H.packet.userAttribute}constructor(){this.attributes=[]}read(e){let t=0;for(;t{this.privateParams[e].fill(0),delete this.privateParams[e]})),this.privateParams=null,this.isEncrypted=!0)}}async function Yo(e,t,r,n,i,s,a){if("argon2"===t.type&&!i)throw Error("Using Argon2 S2K without AEAD is not allowed");if("simple"===t.type&&6===e)throw Error("Using Simple S2K with version 6 keys is not allowed");const{keySize:o}=ga.getCipherParams(n),c=await t.produceKey(r,o);if(!i||5===e||a)return c;const h=G.concatUint8Array([s,new Uint8Array([e,n,i])]);return ss(H.hash.sha256,c,new Uint8Array,h,o)}class Jo{static get tag(){return H.packet.userID}constructor(){this.userID="",this.name="",this.email="",this.comment=""}static fromObject(e){if(G.isString(e)||e.name&&!G.isString(e.name)||e.email&&!G.isEmailAddress(e.email)||e.comment&&!G.isString(e.comment))throw Error("Invalid user ID format");const t=new Jo;Object.assign(t,e);const r=[];return t.name&&r.push(t.name),t.comment&&r.push(`(${t.comment})`),t.email&&r.push(`<${t.email}>`),t.userID=r.join(" "),t}read(e,t=z){const r=G.decodeUTF8(e);if(r.length>t.maxUserIDLength)throw Error("User ID string is too long");const n=/^(?[^()]+\s+)?(?\([^()]+\)\s+)?(?<\S+@\S+>)$/.exec(r);if(null!==n){const{name:e,comment:t,email:r}=n.groups;this.comment=t?.replace(/^\(|\)|\s$/g,"").trim()||"",this.name=e?.trim()||"",this.email=r.substring(1,r.length-1)}else/^[^\s@]+@[^\s@]+$/.test(r)&&(this.email=r);this.userID=r}write(){return G.encodeUTF8(this.userID)}equals(e){return e&&e.userID===this.userID}}class $o extends Zo{static get tag(){return H.packet.secretSubkey}constructor(e=new Date,t=z){super(e,t)}}const Xo=/*#__PURE__*/G.constructAllowedPackets([vo]);class ec{constructor(e){this.packets=e||new Co}write(){return this.packets.write()}armor(e=z){const t=this.packets.some((e=>e.constructor.tag===vo.tag&&6!==e.version));return ae(H.armor.signature,this.write(),void 0,void 0,void 0,t,e)}getSigningKeyIDs(){return this.packets.map((e=>e.issuerKeyID))}}async function tc(e,t){const r=new $o(e.date,t);return r.packets=null,r.algorithm=H.write(H.publicKey,e.algorithm),await r.generate(e.rsaBits,e.curve,e.symmetric),await r.computeFingerprintAndKeyID(),r}async function rc(e,t){const r=new Zo(e.date,t);return r.packets=null,r.algorithm=H.write(H.publicKey,e.algorithm),await r.generate(e.rsaBits,e.curve,e.symmetric),await r.computeFingerprintAndKeyID(),r}async function nc(e,t,r,n,i=new Date,s){let a,o;for(let c=e.length-1;c>=0;c--)try{(!a||e[c].created>=a.created)&&(await e[c].verify(t,r,n,i,void 0,s),a=e[c])}catch(e){o=e}if(!a)throw G.wrapError(`Could not find valid ${H.read(H.signature,r)} signature in key ${t.getKeyID().toHex()}`.replace("certGeneric ","self-").replace(/([a-z])([A-Z])/g,((e,t,r)=>t+" "+r.toLowerCase())),o);return a}function ic(e,t,r=new Date){const n=G.normalizeDate(r);if(null!==n){const r=hc(e,t);return!(e.created<=n&&n0&&(s.keyExpirationTime=r.keyExpirationTime,s.keyNeverExpires=!1);return await ac(i,[],t,s,r.date,void 0,void 0,void 0,n)}async function ac(e,t,r,n,i,s,a=[],o=!1,c){if(r.isDummy())throw Error("Cannot sign with a gnu-dummy key.");if(!r.isDecrypted())throw Error("Signing key is not decrypted.");const h=new vo;return Object.assign(h,n),h.publicKeyAlgorithm=r.algorithm,h.hashAlgorithm=await async function(e,t,r=new Date,n=[],i){const s=H.hash.sha256,a=i.preferredHashAlgorithm,o=await Promise.all(e.map((async(e,t)=>(await e.getPrimarySelfSignature(r,n[t],i)).preferredHashAlgorithms))),c=new Map;for(const e of o)for(const t of e)try{const e=H.write(H.hash,t);c.set(e,c.has(e)?c.get(e)+1:1)}catch{}const h=t=>0===e.length||c.get(t)===e.length||t===s,u=()=>{if(0===c.size)return s;const e=Array.from(c.keys()).filter((e=>h(e))).sort(((e,t)=>ga.hash.getHashByteLength(e)-ga.hash.getHashByteLength(t)))[0];return ga.hash.getHashByteLength(e)>=ga.hash.getHashByteLength(s)?e:s};if(new Set([H.publicKey.ecdsa,H.publicKey.eddsaLegacy,H.publicKey.ed25519,H.publicKey.ed448]).has(t.algorithm)){const e=ga.getPreferredCurveHashAlgo(t.algorithm,t.publicParams.oid),r=h(a),n=ga.hash.getHashByteLength(a)>=ga.hash.getHashByteLength(e);if(r&&n)return a;{const t=u();return ga.hash.getHashByteLength(t)>=ga.hash.getHashByteLength(e)?t:e}}return h(a)?a:u()}(t,r,i,s,c),h.rawNotations=[...a],await h.sign(r,e,i,o,c),h}async function oc(e,t,r,n=new Date,i){(e=e[r])&&(t[r].length?await Promise.all(e.map((async function(e){e.isExpired(n)||i&&!await i(e)||t[r].some((function(t){return G.equalsUint8Array(t.writeParams(),e.writeParams())}))||t[r].push(e)}))):t[r]=e)}async function cc(e,t,r,n,i,s,a=new Date,o){s=s||e;const c=[];return await Promise.all(n.map((async function(e){try{if(!i||e.issuerKeyID.equals(i.issuerKeyID)){const n=![H.reasonForRevocation.keyRetired,H.reasonForRevocation.keySuperseded,H.reasonForRevocation.userIDInvalid].includes(e.reasonForRevocationFlag);await e.verify(s,t,r,n?null:a,!1,o),c.push(e.issuerKeyID)}}catch(e){}}))),i?(i.revoked=!!c.some((e=>e.equals(i.issuerKeyID)))||(i.revoked||!1),i.revoked):c.length>0}function hc(e,t){let r;return!1===t.keyNeverExpires&&(r=e.created.getTime()+1e3*t.keyExpirationTime),r?new Date(r):1/0}function uc(e,t={}){if(e.type=e.type||t.type,e.curve=e.curve||t.curve,e.rsaBits=e.rsaBits||t.rsaBits,e.symmetricHash=e.symmetricHash||t.symmetricHash,e.symmetricCipher=e.symmetricCipher||t.symmetricCipher,e.keyExpirationTime=void 0!==e.keyExpirationTime?e.keyExpirationTime:t.keyExpirationTime,e.passphrase=G.isString(e.passphrase)?e.passphrase:t.passphrase,e.date=e.date||t.date,e.sign=e.sign||!1,e.forwarding=e.forwarding||!1,e.sign&&e.forwarding)throw Error('Incompatible options: "sign" and "forwarding" cannot be set together');switch(e.type){case"ecc":try{e.curve=H.write(H.curve,e.curve)}catch(e){throw Error("Unknown curve")}e.curve!==H.curve.ed25519Legacy&&e.curve!==H.curve.curve25519Legacy&&"ed25519"!==e.curve&&"curve25519"!==e.curve||(e.curve=e.sign?H.curve.ed25519Legacy:H.curve.curve25519Legacy),e.sign?e.algorithm=e.curve===H.curve.ed25519Legacy?H.publicKey.eddsaLegacy:H.publicKey.ecdsa:e.algorithm=H.publicKey.ecdh;break;case"curve25519":e.algorithm=e.sign?H.publicKey.ed25519:H.publicKey.x25519;break;case"curve448":e.algorithm=e.sign?H.publicKey.ed448:H.publicKey.x448;break;case"rsa":e.algorithm=H.publicKey.rsaEncryptSign;break;case"symmetric":if(e.sign){e.algorithm=H.publicKey.hmac;try{e.symmetric=H.write(H.hash,e.symmetricHash)}catch(e){throw Error("Unknown hash algorithm")}}else{e.algorithm=H.publicKey.aead;try{e.symmetric=H.write(H.symmetric,e.symmetricCipher)}catch(e){throw Error("Unknown symmetric algorithm")}}break;default:throw Error("Unsupported key type "+e.type)}return e}function lc(e,t,r){switch(e.algorithm){case H.publicKey.rsaEncryptSign:case H.publicKey.rsaSign:case H.publicKey.dsa:case H.publicKey.ecdsa:case H.publicKey.eddsaLegacy:case H.publicKey.ed25519:case H.publicKey.ed448:case H.publicKey.hmac:if(!t.keyFlags&&!r.allowMissingKeyFlags)throw Error("None of the key flags is set: consider passing `config.allowMissingKeyFlags`");return!t.keyFlags||!!(t.keyFlags[0]&H.keyFlags.signData);default:return!1}}function yc(e,t,r){switch(e.algorithm){case H.publicKey.rsaEncryptSign:case H.publicKey.rsaEncrypt:case H.publicKey.elgamal:case H.publicKey.ecdh:case H.publicKey.x25519:case H.publicKey.x448:case H.publicKey.aead:if(!t.keyFlags&&!r.allowMissingKeyFlags)throw Error("None of the key flags is set: consider passing `config.allowMissingKeyFlags`");return!t.keyFlags||!!(t.keyFlags[0]&H.keyFlags.encryptCommunication)||!!(t.keyFlags[0]&H.keyFlags.encryptStorage);default:return!1}}function fc(e,t,r){if(!t.keyFlags&&!r.allowMissingKeyFlags)throw Error("None of the key flags is set: consider passing `config.allowMissingKeyFlags`");switch(e.algorithm){case H.publicKey.rsaEncryptSign:case H.publicKey.rsaEncrypt:case H.publicKey.elgamal:case H.publicKey.ecdh:case H.publicKey.x25519:case H.publicKey.x448:return!(!(!t.keyFlags||!!(t.keyFlags[0]&H.keyFlags.signData))||!r.allowInsecureDecryptionWithSigningKeys)||(!t.keyFlags||!!(t.keyFlags[0]&H.keyFlags.encryptCommunication)||!!(t.keyFlags[0]&H.keyFlags.encryptStorage)||r.allowForwardedMessages&&!!(t.keyFlags[0]&H.keyFlags.forwardedCommunication));default:return!1}}function gc(e,t){const r=H.write(H.publicKey,e.algorithm),n=e.getAlgorithmInfo();if(t.rejectPublicKeyAlgorithms.has(r))throw Error(n.algorithm+" keys are considered too weak.");switch(r){case H.publicKey.rsaEncryptSign:case H.publicKey.rsaSign:case H.publicKey.rsaEncrypt:if(n.bitse.getKeys(o).length>0));return 0===c.length?null:(await Promise.all(c.map((async t=>{const s=await t.getSigningKey(o,e.created,void 0,n);if(e.revoked||await i.isRevoked(e,s.keyPacket,r,n))throw Error("User certificate is revoked");try{await e.verify(s.keyPacket,H.signature.certGeneric,a,r,void 0,n)}catch(e){throw G.wrapError("User certificate is invalid",e)}}))),!0)}async verifyAllCertifications(e,t=new Date,r){const n=this,i=this.selfCertifications.concat(this.otherCertifications);return Promise.all(i.map((async i=>({keyID:i.issuerKeyID,valid:await n.verifyCertificate(i,e,t,r).catch((()=>!1))}))))}async verify(e=new Date,t){if(!this.selfCertifications.length)throw Error("No self-certifications found");const r=this,n=this.mainKey.keyPacket,i={userID:this.userID,userAttribute:this.userAttribute,key:n};let s;for(let a=this.selfCertifications.length-1;a>=0;a--)try{const s=this.selfCertifications[a];if(s.revoked||await r.isRevoked(s,void 0,e,t))throw Error("Self-certification is revoked");try{await s.verify(n,H.signature.certGeneric,i,e,void 0,t)}catch(e){throw G.wrapError("Self-certification is invalid",e)}return!0}catch(e){s=e}throw s}async update(e,t,r){const n=this.mainKey.keyPacket,i={userID:this.userID,userAttribute:this.userAttribute,key:n};await oc(e,this,"selfCertifications",t,(async function(e){try{return await e.verify(n,H.signature.certGeneric,i,t,!1,r),!0}catch(e){return!1}})),await oc(e,this,"otherCertifications",t),await oc(e,this,"revocationSignatures",t,(function(e){return cc(n,H.signature.certRevocation,i,[e],void 0,void 0,t,r)}))}async revoke(e,{flag:t=H.reasonForRevocation.noReason,string:r=""}={},n=new Date,i=z){const s={userID:this.userID,userAttribute:this.userAttribute,key:e},a=new pc(s.userID||s.userAttribute,this.mainKey);return a.revocationSignatures.push(await ac(s,[],e,{signatureType:H.signature.certRevocation,reasonForRevocationFlag:H.write(H.reasonForRevocation,t),reasonForRevocationString:r},n,void 0,void 0,!1,i)),await a.update(this),a}}class dc{constructor(e,t){this.keyPacket=e,this.bindingSignatures=[],this.revocationSignatures=[],this.mainKey=t}toPacketList(){const e=new Co;return e.push(this.keyPacket),e.push(...this.revocationSignatures),e.push(...this.bindingSignatures),e}clone(){const e=new dc(this.keyPacket,this.mainKey);return e.bindingSignatures=[...this.bindingSignatures],e.revocationSignatures=[...this.revocationSignatures],e}async isRevoked(e,t,r=new Date,n=z){const i=this.mainKey.keyPacket;return cc(i,H.signature.subkeyRevocation,{key:i,bind:this.keyPacket},this.revocationSignatures,e,t,r,n)}async verify(e=new Date,t=z){const r=this.mainKey.keyPacket,n={key:r,bind:this.keyPacket},i=await nc(this.bindingSignatures,r,H.signature.subkeyBinding,n,e,t);if(i.revoked||await this.isRevoked(i,null,e,t))throw Error("Subkey is revoked");if(ic(this.keyPacket,i,e))throw Error("Subkey is expired");return i}async getExpirationTime(e=new Date,t=z){const r=this.mainKey.keyPacket,n={key:r,bind:this.keyPacket};let i;try{i=await nc(this.bindingSignatures,r,H.signature.subkeyBinding,n,e,t)}catch(e){return null}const s=hc(this.keyPacket,i),a=i.getExpirationTime();return si.bindingSignatures[t].created&&(i.bindingSignatures[t]=e),!1;try{return await e.verify(n,H.signature.subkeyBinding,s,t,void 0,r),!0}catch(e){return!1}})),await oc(e,this,"revocationSignatures",t,(function(e){return cc(n,H.signature.subkeyRevocation,s,[e],void 0,void 0,t,r)}))}async revoke(e,{flag:t=H.reasonForRevocation.noReason,string:r=""}={},n=new Date,i=z){const s={key:e,bind:this.keyPacket},a=new dc(this.keyPacket,this.mainKey);return a.revocationSignatures.push(await ac(s,[],e,{signatureType:H.signature.subkeyRevocation,reasonForRevocationFlag:H.write(H.reasonForRevocation,t),reasonForRevocationString:r},n,void 0,void 0,!1,i)),await a.update(this),a}hasSameFingerprintAs(e){return this.keyPacket.hasSameFingerprintAs(e.keyPacket||e)}}["getKeyID","getFingerprint","getAlgorithmInfo","getCreationTime","isDecrypted"].forEach((e=>{dc.prototype[e]=function(){return this.keyPacket[e]()}}));const Ac=/*#__PURE__*/G.constructAllowedPackets([vo]),wc=new Set([H.packet.publicKey,H.packet.privateKey]),mc=new Set([H.packet.publicKey,H.packet.privateKey,H.packet.publicSubkey,H.packet.privateSubkey]);class bc{packetListToStructure(e,t=new Set){let r,n,i,s;for(const a of e){if(a instanceof ti){mc.has(a.tag)&&!s&&(s=wc.has(a.tag)?wc:mc);continue}const e=a.constructor.tag;if(s){if(!s.has(e))continue;s=null}if(t.has(e))throw Error("Unexpected packet type: "+e);switch(e){case H.packet.publicKey:case H.packet.secretKey:if(this.keyPacket)throw Error("Key block contains multiple keys");if(this.keyPacket=a,n=this.getKeyID(),!n)throw Error("Missing Key ID");break;case H.packet.userID:case H.packet.userAttribute:r=new pc(a,this),this.users.push(r);break;case H.packet.publicSubkey:case H.packet.secretSubkey:r=null,i=new dc(a,this),this.subkeys.push(i);break;case H.packet.signature:switch(a.signatureType){case H.signature.certGeneric:case H.signature.certPersona:case H.signature.certCasual:case H.signature.certPositive:if(!r){G.printDebug("Dropping certification signatures without preceding user packet");continue}a.issuerKeyID.equals(n)?r.selfCertifications.push(a):r.otherCertifications.push(a);break;case H.signature.certRevocation:r?r.revocationSignatures.push(a):this.directSignatures.push(a);break;case H.signature.key:this.directSignatures.push(a);break;case H.signature.subkeyBinding:if(!i){G.printDebug("Dropping subkey binding signature without preceding subkey packet");continue}i.bindingSignatures.push(a);break;case H.signature.keyRevocation:this.revocationSignatures.push(a);break;case H.signature.subkeyRevocation:if(!i){G.printDebug("Dropping subkey revocation signature without preceding subkey packet");continue}i.revocationSignatures.push(a)}}}}toPacketList(){const e=new Co;return e.push(this.keyPacket),e.push(...this.revocationSignatures),e.push(...this.directSignatures),this.users.map((t=>e.push(...t.toPacketList()))),this.subkeys.map((t=>e.push(...t.toPacketList()))),e}clone(e=!1){const t=new this.constructor(this.toPacketList());return e&&t.getKeys().forEach((e=>{if(e.keyPacket=Object.create(Object.getPrototypeOf(e.keyPacket),Object.getOwnPropertyDescriptors(e.keyPacket)),!e.keyPacket.isDecrypted())return;const t={};Object.keys(e.keyPacket.privateParams).forEach((r=>{t[r]=new Uint8Array(e.keyPacket.privateParams[r])})),e.keyPacket.privateParams=t})),t}getSubkeys(e=null){return this.subkeys.filter((t=>!e||t.getKeyID().equals(e,!0)))}getKeys(e=null){const t=[];return e&&!this.getKeyID().equals(e,!0)||t.push(this),t.concat(this.getSubkeys(e))}getKeyIDs(){return this.getKeys().map((e=>e.getKeyID()))}getUserIDs(){return this.users.map((e=>e.userID?e.userID.userID:null)).filter((e=>null!==e))}write(){return this.toPacketList().write()}async getSigningKey(e=null,t=new Date,r={},n=z){await this.verifyPrimaryKey(t,r,n);const i=this.keyPacket;try{gc(i,n)}catch(e){throw G.wrapError("Could not verify primary key",e)}const s=this.subkeys.slice().sort(((e,t)=>t.keyPacket.created-e.keyPacket.created));let a;for(const r of s)if(!e||r.getKeyID().equals(e))try{await r.verify(t,n);const e={key:i,bind:r.keyPacket},s=await nc(r.bindingSignatures,i,H.signature.subkeyBinding,e,t,n);if(!lc(r.keyPacket,s,n))continue;if(!s.embeddedSignature)throw Error("Missing embedded signature");return await nc([s.embeddedSignature],r.keyPacket,H.signature.keyBinding,e,t,n),gc(r.keyPacket,n),r}catch(e){a=e}try{const s=await this.getPrimarySelfSignature(t,r,n);if((!e||i.getKeyID().equals(e))&&lc(i,s,n))return gc(i,n),this}catch(e){a=e}throw G.wrapError("Could not find valid signing key packet in key "+this.getKeyID().toHex(),a)}async getEncryptionKey(e,t=new Date,r={},n=z){await this.verifyPrimaryKey(t,r,n);const i=this.keyPacket;try{gc(i,n)}catch(e){throw G.wrapError("Could not verify primary key",e)}const s=this.subkeys.slice().sort(((e,t)=>t.keyPacket.created-e.keyPacket.created));let a;for(const r of s)if(!e||r.getKeyID().equals(e))try{await r.verify(t,n);const e={key:i,bind:r.keyPacket},s=await nc(r.bindingSignatures,i,H.signature.subkeyBinding,e,t,n);if(yc(r.keyPacket,s,n))return gc(r.keyPacket,n),r}catch(e){a=e}try{const s=await this.getPrimarySelfSignature(t,r,n);if((!e||i.getKeyID().equals(e))&&yc(i,s,n))return gc(i,n),this}catch(e){a=e}throw G.wrapError("Could not find valid encryption key packet in key "+this.getKeyID().toHex(),a)}async isRevoked(e,t,r=new Date,n=z){return cc(this.keyPacket,H.signature.keyRevocation,{key:this.keyPacket},this.revocationSignatures,e,t,r,n)}async verifyPrimaryKey(e=new Date,t={},r=z){const n=this.keyPacket;if(await this.isRevoked(null,null,e,r))throw Error("Primary key is revoked");if(ic(n,await this.getPrimarySelfSignature(e,t,r),e))throw Error("Primary key is expired");if(6!==n.version){const t=await nc(this.directSignatures,n,H.signature.key,{key:n},e,r).catch((()=>{}));if(t&&ic(n,t,e))throw Error("Primary key is expired")}}async getExpirationTime(e,t=z){let r;try{const n=await this.getPrimarySelfSignature(null,e,t),i=hc(this.keyPacket,n),s=n.getExpirationTime(),a=6!==this.keyPacket.version&&await nc(this.directSignatures,this.keyPacket,H.signature.key,{key:this.keyPacket},null,t).catch((()=>{}));if(a){const e=hc(this.keyPacket,a);r=Math.min(i,s,e)}else r=ie.subkeys.some((e=>t.hasSameFingerprintAs(e)))))))throw Error("Cannot update public key with private key if subkeys mismatch");return e.update(this,r)}const n=this.clone();return await oc(e,n,"revocationSignatures",t,(i=>cc(n.keyPacket,H.signature.keyRevocation,n,[i],null,e.keyPacket,t,r))),await oc(e,n,"directSignatures",t),await Promise.all(e.users.map((async e=>{const i=n.users.filter((t=>e.userID&&e.userID.equals(t.userID)||e.userAttribute&&e.userAttribute.equals(t.userAttribute)));if(i.length>0)await Promise.all(i.map((n=>n.update(e,t,r))));else{const t=e.clone();t.mainKey=n,n.users.push(t)}}))),await Promise.all(e.subkeys.map((async e=>{const i=n.subkeys.filter((t=>t.hasSameFingerprintAs(e)));if(i.length>0)await Promise.all(i.map((n=>n.update(e,t,r))));else{const t=e.clone();t.mainKey=n,n.subkeys.push(t)}}))),n}async getRevocationCertificate(e=new Date,t=z){const r={key:this.keyPacket},n=await nc(this.revocationSignatures,this.keyPacket,H.signature.keyRevocation,r,e,t),i=new Co;i.push(n);const s=6!==this.keyPacket.version;return ae(H.armor.publicKey,i.write(),null,null,"This is a revocation certificate",s,t)}async applyRevocationCertificate(e,t=new Date,r=z){const n=await se(e),i=(await Co.fromBinary(n.data,Ac,r)).findPacket(H.packet.signature);if(!i||i.signatureType!==H.signature.keyRevocation)throw Error("Could not find revocation signature packet");if(!i.issuerKeyID.equals(this.getKeyID()))throw Error("Revocation signature does not match key");try{await i.verify(this.keyPacket,H.signature.keyRevocation,{key:this.keyPacket},t,void 0,r)}catch(e){throw G.wrapError("Could not verify revocation signature",e)}const s=this.clone();return s.revocationSignatures.push(i),s}async signPrimaryUser(e,t,r,n=z){const{index:i,user:s}=await this.getPrimaryUser(t,r,n),a=await s.certify(e,t,n),o=this.clone();return o.users[i]=a,o}async signAllUsers(e,t=new Date,r=z){const n=this.clone();return n.users=await Promise.all(this.users.map((function(n){return n.certify(e,t,r)}))),n}async verifyPrimaryUser(e,t=new Date,r,n=z){const i=this.keyPacket,{user:s}=await this.getPrimaryUser(t,r,n);return e?await s.verifyAllCertifications(e,t,n):[{keyID:i.getKeyID(),valid:await s.verify(t,n).catch((()=>!1))}]}async verifyAllUsers(e,t=new Date,r=z){const n=this.keyPacket,i=[];return await Promise.all(this.users.map((async s=>{const a=e?await s.verifyAllCertifications(e,t,r):[{keyID:n.getKeyID(),valid:await s.verify(t,r).catch((()=>!1))}];i.push(...a.map((e=>({userID:s.userID?s.userID.userID:null,userAttribute:s.userAttribute,keyID:e.keyID,valid:e.valid}))))}))),i}}["getKeyID","getFingerprint","getAlgorithmInfo","getCreationTime","hasSameFingerprintAs"].forEach((e=>{bc.prototype[e]=dc.prototype[e]}));class kc extends bc{constructor(e){if(super(),this.keyPacket=null,this.revocationSignatures=[],this.directSignatures=[],this.users=[],this.subkeys=[],e&&(this.packetListToStructure(e,new Set([H.packet.secretKey,H.packet.secretSubkey])),!this.keyPacket))throw Error("Invalid key: missing public-key packet")}isPrivate(){return!1}toPublic(){return this}armor(e=z){const t=6!==this.keyPacket.version;return ae(H.armor.publicKey,this.toPacketList().write(),void 0,void 0,void 0,t,e)}}class Ec extends kc{constructor(e){if(super(),this.packetListToStructure(e,new Set([H.packet.publicKey,H.packet.publicSubkey])),!this.keyPacket)throw Error("Invalid key: missing private-key packet")}isPrivate(){return!0}toPublic(){const e=new Co,t=this.toPacketList();let r=!1;for(const n of t)if(!r||n.constructor.tag!==H.packet.Signature)switch(r&&(r=!1),n.constructor.tag){case H.packet.secretKey:{if(n.algorithm===H.publicKey.aead||n.algorithm===H.publicKey.hmac)throw Error("Cannot create public key from symmetric private");const t=Go.fromSecretKeyPacket(n);e.push(t);break}case H.packet.secretSubkey:{if(n.algorithm===H.publicKey.aead||n.algorithm===H.publicKey.hmac){r=!0;break}const t=Vo.fromSecretSubkeyPacket(n);e.push(t);break}default:e.push(n)}return new kc(e)}armor(e=z){const t=6!==this.keyPacket.version;return ae(H.armor.privateKey,this.toPacketList().write(),void 0,void 0,void 0,t,e)}async getDecryptionKeys(e,t=new Date,r={},n=z){const i=this.keyPacket,s=[];let a=null;for(let r=0;re.isDecrypted()))}async validate(e=z){if(!this.isPrivate())throw Error("Cannot validate a public key");let t;if(this.keyPacket.isDummy()){const r=await this.getSigningKey(null,null,void 0,{...e,rejectPublicKeyAlgorithms:new Set,minRSABits:0});r&&!r.keyPacket.isDummy()&&(t=r.keyPacket)}else t=this.keyPacket;if(t)return t.validate();{const e=this.getKeys();if(e.map((e=>e.keyPacket.isDummy())).every(Boolean))throw Error("Cannot validate an all-gnu-dummy key");return Promise.all(e.map((async e=>e.keyPacket.validate())))}}clearPrivateParams(){this.getKeys().forEach((({keyPacket:e})=>{e.isDecrypted()&&e.clearPrivateParams()}))}async revoke({flag:e=H.reasonForRevocation.noReason,string:t=""}={},r=new Date,n=z){if(!this.isPrivate())throw Error("Need private key for revoking");const i={key:this.keyPacket},s=this.clone();return s.revocationSignatures.push(await ac(i,[],this.keyPacket,{signatureType:H.signature.keyRevocation,reasonForRevocationFlag:H.write(H.reasonForRevocation,e),reasonForRevocationString:t},r,void 0,void 0,void 0,n)),s}async addSubkey(e={}){const t={...z,...e.config};if(e.passphrase)throw Error("Subkey could not be encrypted here, please encrypt whole key");if(e.rsaBitse!==t))]}function a(){const t={};t.keyFlags=[H.keyFlags.certifyKeys|H.keyFlags.signData];const i=s([H.symmetric.aes256,H.symmetric.aes128],n.preferredSymmetricAlgorithm);if(t.preferredSymmetricAlgorithms=i,n.aeadProtect){const e=s([H.aead.gcm,H.aead.eax,H.aead.ocb],n.preferredAEADAlgorithm);t.preferredCipherSuites=e.flatMap((e=>i.map((t=>[t,e]))))}return t.preferredHashAlgorithms=s([H.hash.sha256,H.hash.sha512,...6===e.version?[H.hash.sha3_256,H.hash.sha3_512]:[]],n.preferredHashAlgorithm),t.preferredCompressionAlgorithms=s([H.compression.uncompressed,H.compression.zlib,H.compression.zip],n.preferredCompressionAlgorithm),t.features=[0],t.features[0]|=H.features.modificationDetection,n.aeadProtect&&(t.features[0]|=H.features.seipdv2),r.keyExpirationTime>0&&(t.keyExpirationTime=r.keyExpirationTime,t.keyNeverExpires=!1),t}if(i.push(e),6===e.version){const t={key:e},s=a();s.signatureType=H.signature.key;const o=await ac(t,[],e,s,r.date,void 0,void 0,void 0,n);i.push(o)}await Promise.all(r.userIDs.map((async function(t,i){const s=Jo.fromObject(t),o={userID:s,key:e},c=6!==e.version?a():{};c.signatureType=H.signature.certPositive,0===i&&(c.isPrimaryUserID=!0);return{userIDPacket:s,signaturePacket:await ac(o,[],e,c,r.date,void 0,void 0,void 0,n)}}))).then((e=>{e.forEach((({userIDPacket:e,signaturePacket:t})=>{i.push(e),i.push(t)}))})),await Promise.all(t.map((async function(t,i){const s=r.subkeys[i];return{secretSubkeyPacket:t,subkeySignaturePacket:await sc(t,e,s,n)}}))).then((e=>{e.forEach((({secretSubkeyPacket:e,subkeySignaturePacket:t})=>{i.push(e),i.push(t)}))}));const o={key:e};return i.push(await ac(o,[],e,{signatureType:H.signature.keyRevocation,reasonForRevocationFlag:H.reasonForRevocation.noReason,reasonForRevocationString:""},r.date,void 0,void 0,void 0,n)),r.passphrase&&e.clearPrivateParams(),await Promise.all(t.map((async function(e,t){r.subkeys[t].passphrase&&e.clearPrivateParams()}))),new Ec(i)}const Sc=/*#__PURE__*/G.constructAllowedPackets([wo,Uo,Oo,To,qo,Ho,_o,So,vo]),Kc=/*#__PURE__*/G.constructAllowedPackets([_o]),Cc=/*#__PURE__*/G.constructAllowedPackets([vo]);class Pc{constructor(e){this.packets=e||new Co}getEncryptionKeyIDs(){const e=[];return this.packets.filterByTag(H.packet.publicKeyEncryptedSessionKey).forEach((function(t){e.push(t.publicKeyID)})),e}getSigningKeyIDs(){const e=this.unwrapCompressed(),t=e.packets.filterByTag(H.packet.onePassSignature);if(t.length>0)return t.map((e=>e.issuerKeyID));return e.packets.filterByTag(H.packet.signature).map((e=>e.issuerKeyID))}async decrypt(e,t,r,n=new Date,i=z){const s=this.packets.filterByTag(H.packet.symmetricallyEncryptedData,H.packet.symEncryptedIntegrityProtectedData,H.packet.aeadEncryptedData);if(0===s.length)throw Error("No encrypted data found");const a=s[0],o=a.cipherAlgorithm,c=r||await this.decryptSessionKeys(e,t,o,n,i);let h=null;const u=Promise.all(c.map((async({algorithm:e,data:t})=>{if(!G.isUint8Array(t)||!a.cipherAlgorithm&&!G.isString(e))throw Error("Invalid session key for decryption.");try{const r=a.cipherAlgorithm||H.write(H.symmetric,e);await a.decrypt(r,t,i)}catch(e){G.printDebugError(e),h=e}})));if(M(a.encrypted),a.encrypted=null,await u,!a.packets||!a.packets.length)throw h||Error("Decryption failed.");const l=new Pc(a.packets);return a.packets=new Co,l}async decryptSessionKeys(e,t,r,n=new Date,i=z){let s,a=[];if(t){const e=this.packets.filterByTag(H.packet.symEncryptedSessionKey);if(0===e.length)throw Error("No symmetrically encrypted session key packet found.");await Promise.all(t.map((async function(t,r){let n;n=r?await Co.fromBinary(e.write(),Kc,i):e,await Promise.all(n.map((async function(e){try{await e.decrypt(t),a.push(e)}catch(e){G.printDebugError(e),e instanceof pa&&(s=e)}})))})))}else{if(!e)throw Error("No key or password specified.");{const t=this.packets.filterByTag(H.packet.publicKeyEncryptedSessionKey);if(0===t.length)throw Error("No public key encrypted session key packet found.");await Promise.all(t.map((async function(t){await Promise.all(e.map((async function(e){let o;try{o=(await e.getDecryptionKeys(t.publicKeyID,null,void 0,i)).map((e=>e.keyPacket))}catch(e){return void(s=e)}let c=[H.symmetric.aes256,H.symmetric.aes128,H.symmetric.tripledes,H.symmetric.cast5];try{const t=await e.getPrimarySelfSignature(n,void 0,i);t.preferredSymmetricAlgorithms&&(c=c.concat(t.preferredSymmetricAlgorithms))}catch(e){}await Promise.all(o.map((async function(e){if(!e.isDecrypted())throw Error("Decryption key is not decrypted.");if(i.constantTimePKCS1Decryption&&(t.publicKeyAlgorithm===H.publicKey.rsaEncrypt||t.publicKeyAlgorithm===H.publicKey.rsaEncryptSign||t.publicKeyAlgorithm===H.publicKey.rsaSign||t.publicKeyAlgorithm===H.publicKey.elgamal)){const n=t.write();await Promise.all((r?[r]:Array.from(i.constantTimePKCS1DecryptionSupportedSymmetricAlgorithms)).map((async t=>{const r=new Ho;r.read(n);const i={sessionKeyAlgorithm:t,sessionKey:ga.generateSessionKey(t)};try{await r.decrypt(e,i),a.push(r)}catch(e){G.printDebugError(e),s=e}})))}else try{await t.decrypt(e);const n=r||t.sessionKeyAlgorithm;if(n&&!c.includes(H.write(H.symmetric,n)))throw Error("A non-preferred symmetric algorithm was used.");a.push(t)}catch(e){G.printDebugError(e),s=e}})))}))),M(t.encrypted),t.encrypted=null})))}}if(a.length>0){if(a.length>1){const e=new Set;a=a.filter((t=>{const r=t.sessionKeyAlgorithm+G.uint8ArrayToString(t.sessionKey);return!e.has(r)&&(e.add(r),!0)}))}return a.map((e=>({data:e.sessionKey,algorithm:e.sessionKeyAlgorithm&&H.read(H.symmetric,e.sessionKeyAlgorithm)})))}throw s||Error("Session key decryption failed.")}getLiteralData(){const e=this.unwrapCompressed().packets.findPacket(H.packet.literalData);return e&&e.getBytes()||null}getFilename(){const e=this.unwrapCompressed().packets.findPacket(H.packet.literalData);return e&&e.getFilename()||null}getText(){const e=this.unwrapCompressed().packets.findPacket(H.packet.literalData);return e?e.getText():null}static async generateSessionKey(e=[],t=new Date,r=[],n=z){const{symmetricAlgo:i,aeadAlgo:s}=await async function(e=[],t=new Date,r=[],n=z){const i=await Promise.all(e.map(((e,i)=>e.getPrimarySelfSignature(t,r[i],n))));if(e.length?!n.ignoreSEIPDv2FeatureFlag&&i.every((e=>e.features&&e.features[0]&H.features.seipdv2)):n.aeadProtect){const e={symmetricAlgo:H.symmetric.aes128,aeadAlgo:H.aead.ocb},t=[{symmetricAlgo:n.preferredSymmetricAlgorithm,aeadAlgo:n.preferredAEADAlgorithm},{symmetricAlgo:n.preferredSymmetricAlgorithm,aeadAlgo:H.aead.ocb},{symmetricAlgo:H.symmetric.aes128,aeadAlgo:n.preferredAEADAlgorithm}];for(const e of t)if(i.every((t=>t.preferredCipherSuites&&t.preferredCipherSuites.some((t=>t[0]===e.symmetricAlgo&&t[1]===e.aeadAlgo)))))return e;return e}const s=H.symmetric.aes128,a=n.preferredSymmetricAlgorithm;return{symmetricAlgo:i.every((e=>e.preferredSymmetricAlgorithms&&e.preferredSymmetricAlgorithms.includes(a)))?a:s,aeadAlgo:void 0}}(e,t,r,n),a=H.read(H.symmetric,i),o=s?H.read(H.aead,s):void 0;await Promise.all(e.map((e=>e.getEncryptionKey().catch((()=>null)).then((e=>{if(e&&(e.keyPacket.algorithm===H.publicKey.x25519||e.keyPacket.algorithm===H.publicKey.x448)&&!o&&!G.isAES(i))throw Error("Could not generate a session key compatible with the given `encryptionKeys`: X22519 and X448 keys can only be used to encrypt AES session keys; change `config.preferredSymmetricAlgorithm` accordingly.")})))));return{data:ga.generateSessionKey(i),algorithm:a,aeadAlgorithm:o}}async encrypt(e,t,r,n=!1,i=[],s=new Date,a=[],o=z){if(r){if(!G.isUint8Array(r.data)||!G.isString(r.algorithm))throw Error("Invalid session key for encryption.")}else if(e&&e.length)r=await Pc.generateSessionKey(e,s,a,o);else{if(!t||!t.length)throw Error("No keys, passwords, or session key provided.");r=await Pc.generateSessionKey(void 0,void 0,void 0,o)}const{data:c,algorithm:h,aeadAlgorithm:u}=r,l=await Pc.encryptSessionKey(c,h,u,e,t,n,i,s,a,o),y=To.fromObject({version:u?2:1,aeadAlgorithm:u?H.write(H.aead,u):null});y.packets=this.packets;const f=H.write(H.symmetric,h);return await y.encrypt(f,c,o),l.packets.push(y),y.packets=new Co,l}static async encryptSessionKey(e,t,r,n,i,s=!1,a=[],o=new Date,c=[],h=z){const u=new Co,l=H.write(H.symmetric,t),y=r&&H.write(H.aead,r);if(n){const t=await Promise.all(n.map((async function(t,r){const n=await t.getEncryptionKey(a[r],o,c,h),i=Ho.fromObject({version:y?6:3,encryptionKeyPacket:n.keyPacket,anonymousRecipient:s,sessionKey:e,sessionKeyAlgorithm:l});return await i.encrypt(n.keyPacket),delete i.sessionKey,i})));u.push(...t)}if(i){const t=async function(e,t){try{return await e.decrypt(t),1}catch(e){return 0}},r=(e,t)=>e+t,n=async function(e,s,a,o){const c=new _o(h);if(c.sessionKey=e,c.sessionKeyAlgorithm=s,a&&(c.aeadAlgorithm=a),await c.encrypt(o,h),h.passwordCollisionCheck){if(1!==(await Promise.all(i.map((e=>t(c,e))))).reduce(r))return n(e,s,o)}return delete c.sessionKey,c},s=await Promise.all(i.map((t=>n(e,l,y,t))));u.push(...s)}return new Pc(u)}async sign(e=[],t=[],r=null,n=[],i=new Date,s=[],a=[],o=[],c=z){const h=new Co,u=this.packets.findPacket(H.packet.literalData);if(!u)throw Error("No literal data packet to sign.");const l=await Uc(u,e,t,r,n,i,s,a,o,!1,c),y=l.map(((e,t)=>So.fromSignaturePacket(e,0===t))).reverse();return h.push(...y),h.push(u),h.push(...l),new Pc(h)}compress(e,t=z){if(e===H.compression.uncompressed)return this;const r=new Uo(t);r.algorithm=e,r.packets=this.packets;const n=new Co;return n.push(r),new Pc(n)}async signDetached(e=[],t=[],r=null,n=[],i=[],s=new Date,a=[],o=[],c=z){const h=this.packets.findPacket(H.packet.literalData);if(!h)throw Error("No literal data packet to sign.");return new ec(await Uc(h,e,t,r,n,i,s,a,o,!0,c))}async verify(e,t=new Date,r=z){const n=this.unwrapCompressed(),i=n.packets.filterByTag(H.packet.literalData);if(1!==i.length)throw Error("Can only verify message with one literal data packet.");g(n.packets.stream)&&n.packets.push(...await L(n.packets.stream,(e=>e||[])));const s=n.packets.filterByTag(H.packet.onePassSignature).reverse(),a=n.packets.filterByTag(H.packet.signature);return s.length&&!a.length&&G.isStream(n.packets.stream)&&!g(n.packets.stream)?(await Promise.all(s.map((async e=>{e.correspondingSig=new Promise(((t,r)=>{e.correspondingSigResolve=t,e.correspondingSigReject=r})),e.signatureData=T((async()=>(await e.correspondingSig).signatureData)),e.hashed=L(await e.hash(e.signatureType,i[0],void 0,!1)),e.hashed.catch((()=>{}))}))),n.packets.stream=P(n.packets.stream,(async(e,t)=>{const r=F(e),n=N(t);try{for(let e=0;e{t.correspondingSigReject(e)})),await n.abort(e)}})),Dc(s,i,e,t,!1,r)):Dc(a,i,e,t,!1,r)}verifyDetached(e,t,r=new Date,n=z){const i=this.unwrapCompressed().packets.filterByTag(H.packet.literalData);if(1!==i.length)throw Error("Can only verify message with one literal data packet.");return Dc(e.packets.filterByTag(H.packet.signature),i,t,r,!0,n)}unwrapCompressed(){const e=this.packets.filterByTag(H.packet.compressedData);return e.length?new Pc(e[0].packets):this}async appendSignature(e,t=z){await this.packets.read(G.isUint8Array(e)?e:(await se(e)).data,Cc,t)}write(){return this.packets.write()}armor(e=z){const t=this.packets[this.packets.length-1],r=t.constructor.tag===To.tag?2!==t.version:this.packets.some((e=>e.constructor.tag===vo.tag&&6!==e.version));return ae(H.armor.message,this.write(),null,null,null,r,e)}}async function Uc(e,t,r=[],n=null,i=[],s=new Date,a=[],o=[],c=[],h=!1,u=z){const l=new Co,y=null===e.text?H.signature.binary:H.signature.text;if(await Promise.all(t.map((async(t,n)=>{const l=a[n];if(!t.isPrivate())throw Error("Need private key for signing");const f=await t.getSigningKey(i[n],s,l,u);return ac(e,r.length?r:[t],f.keyPacket,{signatureType:y},s,o,c,h,u)}))).then((e=>{l.push(...e)})),n){const e=n.packets.filterByTag(H.packet.signature);l.push(...e)}return l}async function Dc(e,t,r,n=new Date,i=!1,s=z){return Promise.all(e.filter((function(e){return["text","binary"].includes(H.read(H.signature,e.signatureType))})).map((async function(e){return async function(e,t,r,n=new Date,i=!1,s=z){let a,o;for(const t of r){const r=t.getKeys(e.issuerKeyID);if(r.length>0){a=t,o=r[0];break}}const c=e instanceof So?e.correspondingSig:e,h={keyID:e.issuerKeyID,verified:(async()=>{if(!o)throw Error("Could not find signing key with key ID "+e.issuerKeyID.toHex());await e.verify(o.keyPacket,e.signatureType,t[0],n,i,s);const r=await c;if(o.getCreationTime()>r.created)throw Error("Key is newer than the signature");try{await a.getSigningKey(o.getKeyID(),r.created,void 0,s)}catch(e){if(!s.allowInsecureVerificationWithReformattedKeys||!e.message.match(/Signature creation time is in the future/))throw e;await a.getSigningKey(o.getKeyID(),n,void 0,s)}return!0})(),signature:(async()=>{const e=await c,t=new Co;return e&&t.push(e),new ec(t)})()};return h.signature.catch((()=>{})),h.verified.catch((()=>{})),h}(e,t,r,n,i,s)})))}const xc=/*#__PURE__*/G.constructAllowedPackets([vo]);class Qc{constructor(e,t){if(this.text=G.removeTrailingSpaces(e).replace(/\r?\n/g,"\r\n"),t&&!(t instanceof ec))throw Error("Invalid signature input");this.signature=t||new ec(new Co)}getSigningKeyIDs(){const e=[];return this.signature.packets.forEach((function(t){e.push(t.issuerKeyID)})),e}async sign(e,t=[],r=null,n=[],i=new Date,s=[],a=[],o=[],c=z){const h=new wo;h.setText(this.text);const u=new ec(await Uc(h,e,t,r,n,i,s,a,o,!0,c));return new Qc(this.text,u)}verify(e,t=new Date,r=z){const n=this.signature.packets.filterByTag(H.packet.signature),i=new wo;return i.setText(this.text),Dc(n,[i],e,t,!0,r)}getText(){return this.text.replace(/\r\n/g,"\n")}armor(e=z){const t=this.signature.packets.some((e=>6!==e.version)),r={hash:t?Array.from(new Set(this.signature.packets.map((e=>H.read(H.hash,e.hashAlgorithm).toUpperCase())))).join():null,text:this.text,data:this.signature.packets.write()};return ae(H.armor.signed,r,void 0,void 0,void 0,t,e)}}function Rc(e){if(!(e instanceof Pc))throw Error("Parameter [message] needs to be of type Message")}function Lc(e){if(!(e instanceof Qc||e instanceof Pc))throw Error("Parameter [message] needs to be of type Message or CleartextMessage")}function Mc(e){if("armored"!==e&&"binary"!==e&&"object"!==e)throw Error("Unsupported format "+e)}const Tc=Object.keys(z).length;function Fc(e){const t=Object.keys(e);if(t.length!==Tc)for(const e of t)if(void 0===z[e])throw Error("Unknown config property: "+e)}function Nc(e){return e&&!G.isArray(e)&&(e=[e]),e}async function Oc(e){return"array"===G.isStream(e)?L(e):e}function Hc(e,t){e.data=P(t.packets.stream,(async(t,r)=>{await I(e.data,r,{preventClose:!0});const n=N(r);try{await L(t,(e=>e)),await n.close()}catch(e){await n.abort(e)}}))}function zc(e,t,r){switch(t){case"object":return e;case"armored":return e.armor(r);case"binary":return e.write();default:throw Error("Unsupported format "+t)}}function _c(e){if(!Number.isSafeInteger(e)||e<0)throw Error("positive integer expected, not "+e)}function Gc(e,...t){if(!((r=e)instanceof Uint8Array||null!=r&&"object"==typeof r&&"Uint8Array"===r.constructor.name))throw Error("Uint8Array expected");var r;if(t.length>0&&!t.includes(e.length))throw Error(`Uint8Array expected of length ${t}, not of length=${e.length}`)}function jc(e,t=!0){if(e.destroyed)throw Error("Hash instance has been destroyed");if(t&&e.finished)throw Error("Hash#digest() has already been called")}function qc(e,t){Gc(e);const r=t.outputLen;if(e.lengthnew DataView(e.buffer,e.byteOffset,e.byteLength),Zc=(e,t)=>e<<32-t|e>>>t,Yc=(e,t)=>e<>>32-t>>>0,Jc=68===new Uint8Array(new Uint32Array([287454020]).buffer)[0]; /*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */function $c(e){for(let r=0;r>>8&65280|t>>>24&255;var t}function Xc(e){if("string"!=typeof e)throw Error("utf8ToBytes expected string, got "+typeof e);return new Uint8Array((new TextEncoder).encode(e))}function eh(e){return"string"==typeof e&&(e=Xc(e)),Gc(e),e}function th(...e){let t=0;for(let r=0;re().update(eh(t)).digest(),r=e();return t.outputLen=r.outputLen,t.blockLen=r.blockLen,t.create=()=>e(),t}function ih(e=32){if(Vc&&"function"==typeof Vc.getRandomValues)return Vc.getRandomValues(new Uint8Array(e));if(Vc&&"function"==typeof Vc.randomBytes)return Vc.randomBytes(e);throw Error("crypto.getRandomValues must be defined")}const sh=(e,t,r)=>e&t^~e&r,ah=(e,t,r)=>e&t^e&r^t&r;class oh extends rh{constructor(e,t,r,n){super(),this.blockLen=e,this.outputLen=t,this.padOffset=r,this.isLE=n,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(e),this.view=Wc(this.buffer)}update(e){jc(this);const{view:t,buffer:r,blockLen:n}=this,i=(e=eh(e)).length;for(let s=0;sn-s&&(this.process(r,0),s=0);for(let e=s;e>i&s),o=Number(r&s),c=n?4:0,h=n?0:4;e.setUint32(t+c,a,n),e.setUint32(t+h,o,n)}(r,n-8,BigInt(8*this.length),i),this.process(r,0);const a=Wc(e),o=this.outputLen;if(o%4)throw Error("_sha2: outputLen should be aligned to 32bit");const c=o/4,h=this.get();if(c>h.length)throw Error("_sha2: outputLen bigger than state");for(let e=0;e>>3,i=Zc(r,17)^Zc(r,19)^r>>>10;uh[e]=i+uh[e-7]+n+uh[e-16]|0}let{A:r,B:n,C:i,D:s,E:a,F:o,G:c,H:h}=this;for(let e=0;e<64;e++){const t=h+(Zc(a,6)^Zc(a,11)^Zc(a,25))+sh(a,o,c)+ch[e]+uh[e]|0,u=(Zc(r,2)^Zc(r,13)^Zc(r,22))+ah(r,n,i)|0;h=c,c=o,o=a,a=s+t|0,s=i,i=n,n=r,r=t+u|0}r=r+this.A|0,n=n+this.B|0,i=i+this.C|0,s=s+this.D|0,a=a+this.E|0,o=o+this.F|0,c=c+this.G|0,h=h+this.H|0,this.set(r,n,i,s,a,o,c,h)}roundClean(){uh.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}}class yh extends lh{constructor(){super(),this.A=-1056596264,this.B=914150663,this.C=812702999,this.D=-150054599,this.E=-4191439,this.F=1750603025,this.G=1694076839,this.H=-1090891868,this.outputLen=28}}const fh=/* @__PURE__ */nh((()=>new lh)),gh=/* @__PURE__ */nh((()=>new yh));class ph extends rh{constructor(e,t){super(),this.finished=!1,this.destroyed=!1,function(e){if("function"!=typeof e||"function"!=typeof e.create)throw Error("Hash should be wrapped by utils.wrapConstructor");_c(e.outputLen),_c(e.blockLen)}(e);const r=eh(t);if(this.iHash=e.create(),"function"!=typeof this.iHash.update)throw Error("Expected instance of class which extends utils.Hash");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;const n=this.blockLen,i=new Uint8Array(n);i.set(r.length>n?e.create().update(r).digest():r);for(let e=0;enew ph(e,t).update(r).digest();dh.create=(e,t)=>new ph(e,t) /*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */;const Ah=/* @__PURE__ */BigInt(0),wh=/* @__PURE__ */BigInt(1),mh=/* @__PURE__ */BigInt(2);function bh(e){return e instanceof Uint8Array||null!=e&&"object"==typeof e&&"Uint8Array"===e.constructor.name}function kh(e){if(!bh(e))throw Error("Uint8Array expected")}function Eh(e,t){if("boolean"!=typeof t)throw Error(`${e} must be valid boolean, got "${t}".`)}const vh=/* @__PURE__ */Array.from({length:256},((e,t)=>t.toString(16).padStart(2,"0")));function Bh(e){kh(e);let t="";for(let r=0;r=Kh._0&&e<=Kh._9?e-Kh._0:e>=Kh._A&&e<=Kh._F?e-(Kh._A-10):e>=Kh._a&&e<=Kh._f?e-(Kh._a-10):void 0}function Ph(e){if("string"!=typeof e)throw Error("hex string expected, got "+typeof e);const t=e.length,r=t/2;if(t%2)throw Error("padded hex string expected, got unpadded hex of length "+t);const n=new Uint8Array(r);for(let t=0,i=0;t"bigint"==typeof e&&Ah<=e;function Th(e,t,r){return Mh(e)&&Mh(t)&&Mh(r)&&t<=e&&eAh;e>>=wh,t+=1);return t}const Oh=e=>(mh<new Uint8Array(e),zh=e=>Uint8Array.from(e);function _h(e,t,r){if("number"!=typeof e||e<2)throw Error("hashLen must be a number");if("number"!=typeof t||t<2)throw Error("qByteLen must be a number");if("function"!=typeof r)throw Error("hmacFn must be a function");let n=Hh(e),i=Hh(e),s=0;const a=()=>{n.fill(1),i.fill(0),s=0},o=(...e)=>r(i,n,...e),c=(e=Hh())=>{i=o(zh([0]),e),n=o(),0!==e.length&&(i=o(zh([1]),e),n=o())},h=()=>{if(s++>=1e3)throw Error("drbg: tried 1000 values");let e=0;const r=[];for(;e{let r;for(a(),c(e);!(r=t(h()));)c();return a(),r}}const Gh={bigint:e=>"bigint"==typeof e,function:e=>"function"==typeof e,boolean:e=>"boolean"==typeof e,string:e=>"string"==typeof e,stringOrUint8Array:e=>"string"==typeof e||bh(e),isSafeInteger:e=>Number.isSafeInteger(e),array:e=>Array.isArray(e),field:(e,t)=>t.Fp.isValid(e),hash:e=>"function"==typeof e&&Number.isSafeInteger(e.outputLen)};function jh(e,t,r={}){const n=(t,r,n)=>{const i=Gh[r];if("function"!=typeof i)throw Error(`Invalid validator "${r}", expected function`);const s=e[t];if(!(n&&void 0===s||i(s,e)))throw Error(`Invalid param ${t+""}=${s} (${typeof s}), expected ${r}`)};for(const[e,r]of Object.entries(t))n(e,r,!1);for(const[e,t]of Object.entries(r))n(e,t,!0);return e}function qh(e){const t=new WeakMap;return(r,...n)=>{const i=t.get(r);if(void 0!==i)return i;const s=e(r,...n);return t.set(r,s),s}}var Vh=/*#__PURE__*/Object.freeze({__proto__:null,aInRange:Fh,abool:Eh,abytes:kh,bitGet:function(e,t){return e>>BigInt(t)&wh},bitLen:Nh,bitMask:Oh,bitSet:function(e,t,r){return e|(r?wh:Ah)<{throw Error("not implemented")},numberToBytesBE:xh,numberToBytesLE:Qh,numberToHexUnpadded:Ih,numberToVarBytesBE:function(e){return Ph(Ih(e))},utf8ToBytes:function(e){if("string"!=typeof e)throw Error("utf8ToBytes expected string, got "+typeof e);return new Uint8Array((new TextEncoder).encode(e))},validateObject:jh}); /*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const Wh=BigInt(0),Zh=BigInt(1),Yh=BigInt(2),Jh=BigInt(3),$h=BigInt(4),Xh=BigInt(5),eu=BigInt(8);function tu(e,t){const r=e%t;return r>=Wh?r:t+r}function ru(e,t,r){if(r<=Wh||t 0");if(r===Zh)return Wh;let n=Zh;for(;t>Wh;)t&Zh&&(n=n*e%r),e=e*e%r,t>>=Zh;return n}function nu(e,t,r){let n=e;for(;t-- >Wh;)n*=n,n%=r;return n}function iu(e,t){if(e===Wh||t<=Wh)throw Error(`invert: expected positive integers, got n=${e} mod=${t}`);let r=tu(e,t),n=t,i=Wh,s=Zh;for(;r!==Wh;){const e=n%r,t=i-s*(n/r);n=r,r=e,i=s,s=t}if(n!==Zh)throw Error("invert: does not exist");return tu(i,t)}function su(e){if(e%$h===Jh){const t=(e+Zh)/$h;return function(e,r){const n=e.pow(r,t);if(!e.eql(e.sqr(n),r))throw Error("Cannot find square root");return n}}if(e%eu===Xh){const t=(e-Xh)/eu;return function(e,r){const n=e.mul(r,Yh),i=e.pow(n,t),s=e.mul(r,i),a=e.mul(e.mul(s,Yh),i),o=e.mul(s,e.sub(a,e.ONE));if(!e.eql(e.sqr(o),r))throw Error("Cannot find square root");return o}}return function(e){const t=(e-Zh)/Yh;let r,n,i;for(r=e-Zh,n=0;r%Yh===Wh;r/=Yh,n++);for(i=Yh;i 0, got "+e);const{nBitLength:i,nByteLength:s}=ou(e,t);if(s>2048)throw Error("Field lengths over 2048 bytes are not supported");const a=su(e),o=Object.freeze({ORDER:e,BITS:i,BYTES:s,MASK:Oh(i),ZERO:Wh,ONE:Zh,create:t=>tu(t,e),isValid:t=>{if("bigint"!=typeof t)throw Error("Invalid field element: expected bigint, got "+typeof t);return Wh<=t&&te===Wh,isOdd:e=>(e&Zh)===Zh,neg:t=>tu(-t,e),eql:(e,t)=>e===t,sqr:t=>tu(t*t,e),add:(t,r)=>tu(t+r,e),sub:(t,r)=>tu(t-r,e),mul:(t,r)=>tu(t*r,e),pow:(e,t)=>function(e,t,r){if(r 0");if(r===Wh)return e.ONE;if(r===Zh)return t;let n=e.ONE,i=t;for(;r>Wh;)r&Zh&&(n=e.mul(n,i)),i=e.sqr(i),r>>=Zh;return n}(o,e,t),div:(t,r)=>tu(t*iu(r,e),e),sqrN:e=>e*e,addN:(e,t)=>e+t,subN:(e,t)=>e-t,mulN:(e,t)=>e*t,inv:t=>iu(t,e),sqrt:n.sqrt||(e=>a(o,e)),invertBatch:e=>function(e,t){const r=Array(t.length),n=t.reduce(((t,n,i)=>e.is0(n)?t:(r[i]=t,e.mul(t,n))),e.ONE),i=e.inv(n);return t.reduceRight(((t,n,i)=>e.is0(n)?t:(r[i]=e.mul(t,r[i]),e.mul(t,n))),i),r}(o,e),cmov:(e,t,r)=>r?t:e,toBytes:e=>r?Qh(e,s):xh(e,s),fromBytes:e=>{if(e.length!==s)throw Error(`Fp.fromBytes: expected ${s}, got ${e.length}`);return r?Dh(e):Uh(e)}});return Object.freeze(o)}function hu(e){if("bigint"!=typeof e)throw Error("field order must be bigint");const t=e.toString(2).length;return Math.ceil(t/8)}function uu(e){const t=hu(e);return t+Math.ceil(t/2)} /*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */ const lu=BigInt(0),yu=BigInt(1),fu=new WeakMap,gu=new WeakMap;function pu(e,t){const r=(e,t)=>{const r=t.negate();return e?r:t},n=e=>{if(!Number.isSafeInteger(e)||e<=0||e>t)throw Error(`Wrong window size=${e}, should be [1..${t}]`)},i=e=>{n(e);return{windows:Math.ceil(t/e)+1,windowSize:2**(e-1)}};return{constTimeNegate:r,unsafeLadder(t,r){let n=e.ZERO,i=t;for(;r>lu;)r&yu&&(n=n.add(i)),i=i.double(),r>>=yu;return n},precomputeWindow(e,t){const{windows:r,windowSize:n}=i(t),s=[];let a=e,o=a;for(let e=0;e>=y,i>o&&(i-=l,s+=yu);const a=t,f=t+Math.abs(i)-1,g=e%2!=0,p=i<0;0===i?h=h.add(r(g,n[a])):c=c.add(r(p,n[f]))}return{p:c,f:h}},wNAFCached(e,t,r){const n=gu.get(e)||1;let i=fu.get(e);return i||(i=this.precomputeWindow(e,n),1!==n&&fu.set(e,r(i))),this.wNAF(n,i,t)},setWindowSize(e,t){n(t),gu.set(e,t),fu.delete(e)}}}function du(e,t,r,n){if(!Array.isArray(r)||!Array.isArray(n)||n.length!==r.length)throw Error("arrays of points and scalars must have equal length");n.forEach(((e,r)=>{if(!t.isValid(e))throw Error("wrong scalar at index "+r)})),r.forEach(((t,r)=>{if(!(t instanceof e))throw Error("wrong point at index "+r)}));const i=Nh(BigInt(r.length)),s=i>12?i-3:i>4?i-2:i?2:1,a=(1<=0;t-=s){o.fill(e.ZERO);for(let e=0;e>BigInt(t)&BigInt(a));o[s]=o[s].add(r[e])}let i=e.ZERO;for(let t=o.length-1,r=e.ZERO;t>0;t--)r=r.add(o[t]),i=i.add(r);if(h=h.add(i),0!==t)for(let e=0;e(e[t]="function",e)),{ORDER:"bigint",MASK:"bigint",BYTES:"isSafeInteger",BITS:"isSafeInteger"})),jh(e,{n:"bigint",h:"bigint",Gx:"field",Gy:"field"},{nBitLength:"isSafeInteger",nByteLength:"isSafeInteger"}),Object.freeze({...ou(e.n,e.nBitLength),...e,p:e.Fp.ORDER})} /*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */function wu(e){void 0!==e.lowS&&Eh("lowS",e.lowS),void 0!==e.prehash&&Eh("prehash",e.prehash)}const{bytesToNumberBE:mu,hexToBytes:bu}=Vh,ku={Err:class extends Error{constructor(e=""){super(e)}},_tlv:{encode:(e,t)=>{const{Err:r}=ku;if(e<0||e>256)throw new r("tlv.encode: wrong tag");if(1&t.length)throw new r("tlv.encode: unpadded data");const n=t.length/2,i=Ih(n);if(i.length/2&128)throw new r("tlv.encode: long form length too big");const s=n>127?Ih(i.length/2|128):"";return`${Ih(e)}${s}${i}${t}`},decode(e,t){const{Err:r}=ku;let n=0;if(e<0||e>256)throw new r("tlv.encode: wrong tag");if(t.length<2||t[n++]!==e)throw new r("tlv.decode: wrong tlv");const i=t[n++];let s=0;if(!!(128&i)){const e=127&i;if(!e)throw new r("tlv.decode(long): indefinite length not supported");if(e>4)throw new r("tlv.decode(long): byte length is too big");const a=t.subarray(n,n+e);if(a.length!==e)throw new r("tlv.decode: length bytes not complete");if(0===a[0])throw new r("tlv.decode(long): zero leftmost byte");for(const e of a)s=s<<8|e;if(n+=e,s<128)throw new r("tlv.decode(long): not minimal encoding")}else s=i;const a=t.subarray(n,n+s);if(a.length!==s)throw new r("tlv.decode: wrong value length");return{v:a,l:t.subarray(n+s)}}},_int:{encode(e){const{Err:t}=ku;if(e{const i=t.toAffine();return Lh(Uint8Array.from([4]),r.toBytes(i.x),r.toBytes(i.y))}),s=t.fromBytes||(e=>{const t=e.subarray(1);return{x:r.fromBytes(t.subarray(0,r.BYTES)),y:r.fromBytes(t.subarray(r.BYTES,2*r.BYTES))}});function a(e){const{a:n,b:i}=t,s=r.sqr(e),a=r.mul(s,e);return r.add(r.add(a,r.mul(e,n)),i)}if(!r.eql(r.sqr(t.Gy),a(t.Gx)))throw Error("bad generator point: equation left != right");function o(e){const{allowedPrivateKeyLengths:r,nByteLength:n,wrapPrivateKey:i,n:s}=t;if(r&&"bigint"!=typeof e){if(bh(e)&&(e=Bh(e)),"string"!=typeof e||!r.includes(e.length))throw Error("Invalid key");e=e.padStart(2*n,"0")}let a;try{a="bigint"==typeof e?e:Uh(Rh("private key",e,n))}catch(t){throw Error(`private key must be ${n} bytes, hex or bigint, not ${typeof e}`)}return i&&(a=tu(a,s)),Fh("private key",a,vu,s),a}function c(e){if(!(e instanceof l))throw Error("ProjectivePoint expected")}const h=qh(((e,t)=>{const{px:n,py:i,pz:s}=e;if(r.eql(s,r.ONE))return{x:n,y:i};const a=e.is0();null==t&&(t=a?r.ONE:r.inv(s));const o=r.mul(n,t),c=r.mul(i,t),h=r.mul(s,t);if(a)return{x:r.ZERO,y:r.ZERO};if(!r.eql(h,r.ONE))throw Error("invZ was invalid");return{x:o,y:c}})),u=qh((e=>{if(e.is0()){if(t.allowInfinityPoint&&!r.is0(e.py))return;throw Error("bad point: ZERO")}const{x:n,y:i}=e.toAffine();if(!r.isValid(n)||!r.isValid(i))throw Error("bad point: x or y not FE");const s=r.sqr(i),o=a(n);if(!r.eql(s,o))throw Error("bad point: equation left != right");if(!e.isTorsionFree())throw Error("bad point: not in prime-order subgroup");return!0}));class l{constructor(e,t,n){if(this.px=e,this.py=t,this.pz=n,null==e||!r.isValid(e))throw Error("x required");if(null==t||!r.isValid(t))throw Error("y required");if(null==n||!r.isValid(n))throw Error("z required");Object.freeze(this)}static fromAffine(e){const{x:t,y:n}=e||{};if(!e||!r.isValid(t)||!r.isValid(n))throw Error("invalid affine point");if(e instanceof l)throw Error("projective point not allowed");const i=e=>r.eql(e,r.ZERO);return i(t)&&i(n)?l.ZERO:new l(t,n,r.ONE)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static normalizeZ(e){const t=r.invertBatch(e.map((e=>e.pz)));return e.map(((e,r)=>e.toAffine(t[r]))).map(l.fromAffine)}static fromHex(e){const t=l.fromAffine(s(Rh("pointHex",e)));return t.assertValidity(),t}static fromPrivateKey(e){return l.BASE.multiply(o(e))}static msm(e,t){return du(l,n,e,t)}_setWindowSize(e){f.setWindowSize(this,e)}assertValidity(){u(this)}hasEvenY(){const{y:e}=this.toAffine();if(r.isOdd)return!r.isOdd(e);throw Error("Field doesn't support isOdd")}equals(e){c(e);const{px:t,py:n,pz:i}=this,{px:s,py:a,pz:o}=e,h=r.eql(r.mul(t,o),r.mul(s,i)),u=r.eql(r.mul(n,o),r.mul(a,i));return h&&u}negate(){return new l(this.px,r.neg(this.py),this.pz)}double(){const{a:e,b:n}=t,i=r.mul(n,Bu),{px:s,py:a,pz:o}=this;let c=r.ZERO,h=r.ZERO,u=r.ZERO,y=r.mul(s,s),f=r.mul(a,a),g=r.mul(o,o),p=r.mul(s,a);return p=r.add(p,p),u=r.mul(s,o),u=r.add(u,u),c=r.mul(e,u),h=r.mul(i,g),h=r.add(c,h),c=r.sub(f,h),h=r.add(f,h),h=r.mul(c,h),c=r.mul(p,c),u=r.mul(i,u),g=r.mul(e,g),p=r.sub(y,g),p=r.mul(e,p),p=r.add(p,u),u=r.add(y,y),y=r.add(u,y),y=r.add(y,g),y=r.mul(y,p),h=r.add(h,y),g=r.mul(a,o),g=r.add(g,g),y=r.mul(g,p),c=r.sub(c,y),u=r.mul(g,f),u=r.add(u,u),u=r.add(u,u),new l(c,h,u)}add(e){c(e);const{px:n,py:i,pz:s}=this,{px:a,py:o,pz:h}=e;let u=r.ZERO,y=r.ZERO,f=r.ZERO;const g=t.a,p=r.mul(t.b,Bu);let d=r.mul(n,a),A=r.mul(i,o),w=r.mul(s,h),m=r.add(n,i),b=r.add(a,o);m=r.mul(m,b),b=r.add(d,A),m=r.sub(m,b),b=r.add(n,s);let k=r.add(a,h);return b=r.mul(b,k),k=r.add(d,w),b=r.sub(b,k),k=r.add(i,s),u=r.add(o,h),k=r.mul(k,u),u=r.add(A,w),k=r.sub(k,u),f=r.mul(g,b),u=r.mul(p,w),f=r.add(u,f),u=r.sub(A,f),f=r.add(A,f),y=r.mul(u,f),A=r.add(d,d),A=r.add(A,d),w=r.mul(g,w),b=r.mul(p,b),A=r.add(A,w),w=r.sub(d,w),w=r.mul(g,w),b=r.add(b,w),d=r.mul(A,b),y=r.add(y,d),d=r.mul(k,b),u=r.mul(m,u),u=r.sub(u,d),d=r.mul(m,A),f=r.mul(k,f),f=r.add(f,d),new l(u,y,f)}subtract(e){return this.add(e.negate())}is0(){return this.equals(l.ZERO)}wNAF(e){return f.wNAFCached(this,e,l.normalizeZ)}multiplyUnsafe(e){Fh("scalar",e,Eu,t.n);const n=l.ZERO;if(e===Eu)return n;if(e===vu)return this;const{endo:i}=t;if(!i)return f.unsafeLadder(this,e);let{k1neg:s,k1:a,k2neg:o,k2:c}=i.splitScalar(e),h=n,u=n,y=this;for(;a>Eu||c>Eu;)a&vu&&(h=h.add(y)),c&vu&&(u=u.add(y)),y=y.double(),a>>=vu,c>>=vu;return s&&(h=h.negate()),o&&(u=u.negate()),u=new l(r.mul(u.px,i.beta),u.py,u.pz),h.add(u)}multiply(e){const{endo:n,n:i}=t;let s,a;if(Fh("scalar",e,vu,i),n){const{k1neg:t,k1:i,k2neg:o,k2:c}=n.splitScalar(e);let{p:h,f:u}=this.wNAF(i),{p:y,f:g}=this.wNAF(c);h=f.constTimeNegate(t,h),y=f.constTimeNegate(o,y),y=new l(r.mul(y.px,n.beta),y.py,y.pz),s=h.add(y),a=u.add(g)}else{const{p:t,f:r}=this.wNAF(e);s=t,a=r}return l.normalizeZ([s,a])[0]}multiplyAndAddUnsafe(e,t,r){const n=l.BASE,i=(e,t)=>t!==Eu&&t!==vu&&e.equals(n)?e.multiply(t):e.multiplyUnsafe(t),s=i(this,t).add(i(e,r));return s.is0()?void 0:s}toAffine(e){return h(this,e)}isTorsionFree(){const{h:e,isTorsionFree:r}=t;if(e===vu)return!0;if(r)return r(l,this);throw Error("isTorsionFree() has not been declared for the elliptic curve")}clearCofactor(){const{h:e,clearCofactor:r}=t;return e===vu?this:r?r(l,this):this.multiplyUnsafe(t.h)}toRawBytes(e=!0){return Eh("isCompressed",e),this.assertValidity(),i(l,this,e)}toHex(e=!0){return Eh("isCompressed",e),Bh(this.toRawBytes(e))}}l.BASE=new l(t.Gx,t.Gy,r.ONE),l.ZERO=new l(r.ZERO,r.ONE,r.ZERO);const y=t.nBitLength,f=pu(l,t.endo?Math.ceil(y/2):y);return{CURVE:t,ProjectivePoint:l,normPrivateKeyToScalar:o,weierstrassEquation:a,isWithinCurveOrder:function(e){return Th(e,vu,t.n)}}}function Su(e){const t=function(e){const t=Au(e);return jh(t,{hash:"hash",hmac:"function",randomBytes:"function"},{bits2int:"function",bits2int_modN:"function",lowS:"boolean"}),Object.freeze({lowS:!0,...t})}(e),{Fp:r,n}=t,i=r.BYTES+1,s=2*r.BYTES+1;function a(e){return tu(e,n)}function o(e){return iu(e,n)}const{ProjectivePoint:c,normPrivateKeyToScalar:h,weierstrassEquation:u,isWithinCurveOrder:l}=Iu({...t,toBytes(e,t,n){const i=t.toAffine(),s=r.toBytes(i.x),a=Lh;return Eh("isCompressed",n),n?a(Uint8Array.from([t.hasEvenY()?2:3]),s):a(Uint8Array.from([4]),s,r.toBytes(i.y))},fromBytes(e){const t=e.length,n=e[0],a=e.subarray(1);if(t!==i||2!==n&&3!==n){if(t===s&&4===n){return{x:r.fromBytes(a.subarray(0,r.BYTES)),y:r.fromBytes(a.subarray(r.BYTES,2*r.BYTES))}}throw Error(`Point of length ${t} was invalid. Expected ${i} compressed bytes or ${s} uncompressed bytes`)}{const e=Uh(a);if(!Th(e,vu,r.ORDER))throw Error("Point is not on curve");const t=u(e);let i;try{i=r.sqrt(t)}catch(e){const t=e instanceof Error?": "+e.message:"";throw Error("Point is not on curve"+t)}return!(1&~n)!==((i&vu)===vu)&&(i=r.neg(i)),{x:e,y:i}}}}),y=e=>Bh(xh(e,t.nByteLength));function f(e){return e>n>>vu}const g=(e,t,r)=>Uh(e.slice(t,r));class p{constructor(e,t,r){this.r=e,this.s=t,this.recovery=r,this.assertValidity()}static fromCompact(e){const r=t.nByteLength;return e=Rh("compactSignature",e,2*r),new p(g(e,0,r),g(e,r,2*r))}static fromDER(e){const{r:t,s:r}=ku.toSig(Rh("DER",e));return new p(t,r)}assertValidity(){Fh("r",this.r,vu,n),Fh("s",this.s,vu,n)}addRecoveryBit(e){return new p(this.r,this.s,e)}recoverPublicKey(e){const{r:n,s:i,recovery:s}=this,h=m(Rh("msgHash",e));if(null==s||![0,1,2,3].includes(s))throw Error("recovery id invalid");const u=2===s||3===s?n+t.n:n;if(u>=r.ORDER)throw Error("recovery id 2 or 3 invalid");const l=1&s?"03":"02",f=c.fromHex(l+y(u)),g=o(u),p=a(-h*g),d=a(i*g),A=c.BASE.multiplyAndAddUnsafe(f,p,d);if(!A)throw Error("point at infinify");return A.assertValidity(),A}hasHighS(){return f(this.s)}normalizeS(){return this.hasHighS()?new p(this.r,a(-this.s),this.recovery):this}toDERRawBytes(){return Ph(this.toDERHex())}toDERHex(){return ku.hexFromSig({r:this.r,s:this.s})}toCompactRawBytes(){return Ph(this.toCompactHex())}toCompactHex(){return y(this.r)+y(this.s)}}const d={isValidPrivateKey(e){try{return h(e),!0}catch(e){return!1}},normPrivateKeyToScalar:h,randomPrivateKey:()=>{const e=uu(t.n);return function(e,t,r=!1){const n=e.length,i=hu(t),s=uu(t);if(n<16||n1024)throw Error(`expected ${s}-1024 bytes of input, got ${n}`);const a=tu(r?Uh(e):Dh(e),t-Zh)+Zh;return r?Qh(a,i):xh(a,i)}(t.randomBytes(e),t.n)},precompute:(e=8,t=c.BASE)=>(t._setWindowSize(e),t.multiply(BigInt(3)),t)};function A(e){const t=bh(e),r="string"==typeof e,n=(t||r)&&e.length;return t?n===i||n===s:r?n===2*i||n===2*s:e instanceof c}const w=t.bits2int||function(e){const r=Uh(e),n=8*e.length-t.nBitLength;return n>0?r>>BigInt(n):r},m=t.bits2int_modN||function(e){return a(w(e))},b=Oh(t.nBitLength);function k(e){return Fh("num < 2^"+t.nBitLength,e,Eu,b),xh(e,t.nByteLength)}function E(e,n,i=v){if(["recovered","canonical"].some((e=>e in i)))throw Error("sign() legacy options not supported");const{hash:s,randomBytes:u}=t;let{lowS:y,prehash:g,extraEntropy:d}=i;null==y&&(y=!0),e=Rh("msgHash",e),wu(i),g&&(e=Rh("prehashed msgHash",s(e)));const A=m(e),b=h(n),E=[k(b),k(A)];if(null!=d&&!1!==d){const e=!0===d?u(r.BYTES):d;E.push(Rh("extraEntropy",e))}const B=Lh(...E),I=A;return{seed:B,k2sig:function(e){const t=w(e);if(!l(t))return;const r=o(t),n=c.BASE.multiply(t).toAffine(),i=a(n.x);if(i===Eu)return;const s=a(r*a(I+i*b));if(s===Eu)return;let h=(n.x===i?0:2)|Number(n.y&vu),u=s;return y&&f(s)&&(u=function(e){return f(e)?a(-e):e}(s),h^=1),new p(i,u,h)}}}const v={lowS:t.lowS,prehash:!1},B={lowS:t.lowS,prehash:!1};return c.BASE._setWindowSize(8),{CURVE:t,getPublicKey:function(e,t=!0){return c.fromPrivateKey(e).toRawBytes(t)},getSharedSecret:function(e,t,r=!0){if(A(e))throw Error("first arg must be private key");if(!A(t))throw Error("second arg must be public key");return c.fromHex(t).multiply(h(e)).toRawBytes(r)},sign:function(e,r,n=v){const{seed:i,k2sig:s}=E(e,r,n),a=t;return _h(a.hash.outputLen,a.nByteLength,a.hmac)(i,s)},verify:function(e,r,n,i=B){const s=e;if(r=Rh("msgHash",r),n=Rh("publicKey",n),"strict"in i)throw Error("options.strict was renamed to lowS");wu(i);const{lowS:h,prehash:u}=i;let l,y;try{if("string"==typeof s||bh(s))try{l=p.fromDER(s)}catch(e){if(!(e instanceof ku.Err))throw e;l=p.fromCompact(s)}else{if("object"!=typeof s||"bigint"!=typeof s.r||"bigint"!=typeof s.s)throw Error("PARSE");{const{r:e,s:t}=s;l=new p(e,t)}}y=c.fromHex(n)}catch(e){if("PARSE"===e.message)throw Error("signature must be Signature instance, Uint8Array or hex string");return!1}if(h&&l.hasHighS())return!1;u&&(r=t.hash(r));const{r:f,s:g}=l,d=m(r),A=o(g),w=a(d*A),b=a(f*A),k=c.BASE.multiplyAndAddUnsafe(y,w,b)?.toAffine();return!!k&&a(k.x)===f},ProjectivePoint:c,Signature:p,utils:d}} /*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */function Ku(e){return{hash:e,hmac:(t,...r)=>dh(e,t,th(...r)),randomBytes:ih}}function Cu(e,t){const r=t=>Su({...e,...Ku(t)});return Object.freeze({...r(t),create:r})} /*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */BigInt(4);const Pu=cu(BigInt("0xffffffff00000001000000000000000000000000ffffffffffffffffffffffff")),Uu=Cu({a:Pu.create(BigInt("-3")),b:BigInt("0x5ac635d8aa3a93e7b3ebbd55769886bc651d06b0cc53b0f63bce3c3e27d2604b"),Fp:Pu,n:BigInt("0xffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc632551"),Gx:BigInt("0x6b17d1f2e12c4247f8bce6e563a440f277037d812deb33a0f4a13945d898c296"),Gy:BigInt("0x4fe342e2fe1a7f9b8ee7eb4a7c0f9e162bce33576b315ececbb6406837bf51f5"),h:BigInt(1),lowS:!1},fh),Du=/* @__PURE__ */BigInt(2**32-1),xu=/* @__PURE__ */BigInt(32);function Qu(e,t=!1){return t?{h:Number(e&Du),l:Number(e>>xu&Du)}:{h:0|Number(e>>xu&Du),l:0|Number(e&Du)}}function Ru(e,t=!1){let r=new Uint32Array(e.length),n=new Uint32Array(e.length);for(let i=0;ie<>>32-r,Mu=(e,t,r)=>t<>>32-r,Tu=(e,t,r)=>t<>>64-r,Fu=(e,t,r)=>e<>>64-r;const Nu={fromBig:Qu,split:Ru,toBig:(e,t)=>BigInt(e>>>0)<>>0),shrSH:(e,t,r)=>e>>>r,shrSL:(e,t,r)=>e<<32-r|t>>>r,rotrSH:(e,t,r)=>e>>>r|t<<32-r,rotrSL:(e,t,r)=>e<<32-r|t>>>r,rotrBH:(e,t,r)=>e<<64-r|t>>>r-32,rotrBL:(e,t,r)=>e>>>r-32|t<<64-r,rotr32H:(e,t)=>t,rotr32L:(e,t)=>e,rotlSH:Lu,rotlSL:Mu,rotlBH:Tu,rotlBL:Fu,add:function(e,t,r,n){const i=(t>>>0)+(n>>>0);return{h:e+r+(i/2**32|0)|0,l:0|i}},add3L:(e,t,r)=>(e>>>0)+(t>>>0)+(r>>>0),add3H:(e,t,r,n)=>t+r+n+(e/2**32|0)|0,add4L:(e,t,r,n)=>(e>>>0)+(t>>>0)+(r>>>0)+(n>>>0),add4H:(e,t,r,n,i)=>t+r+n+i+(e/2**32|0)|0,add5H:(e,t,r,n,i,s)=>t+r+n+i+s+(e/2**32|0)|0,add5L:(e,t,r,n,i)=>(e>>>0)+(t>>>0)+(r>>>0)+(n>>>0)+(i>>>0)},[Ou,Hu]=/* @__PURE__ */(()=>Nu.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((e=>BigInt(e)))))(),zu=/* @__PURE__ */new Uint32Array(80),_u=/* @__PURE__ */new Uint32Array(80);class Gu extends oh{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(){const{Ah:e,Al:t,Bh:r,Bl:n,Ch:i,Cl:s,Dh:a,Dl:o,Eh:c,El:h,Fh:u,Fl:l,Gh:y,Gl:f,Hh:g,Hl:p}=this;return[e,t,r,n,i,s,a,o,c,h,u,l,y,f,g,p]}set(e,t,r,n,i,s,a,o,c,h,u,l,y,f,g,p){this.Ah=0|e,this.Al=0|t,this.Bh=0|r,this.Bl=0|n,this.Ch=0|i,this.Cl=0|s,this.Dh=0|a,this.Dl=0|o,this.Eh=0|c,this.El=0|h,this.Fh=0|u,this.Fl=0|l,this.Gh=0|y,this.Gl=0|f,this.Hh=0|g,this.Hl=0|p}process(e,t){for(let r=0;r<16;r++,t+=4)zu[r]=e.getUint32(t),_u[r]=e.getUint32(t+=4);for(let e=16;e<80;e++){const t=0|zu[e-15],r=0|_u[e-15],n=Nu.rotrSH(t,r,1)^Nu.rotrSH(t,r,8)^Nu.shrSH(t,r,7),i=Nu.rotrSL(t,r,1)^Nu.rotrSL(t,r,8)^Nu.shrSL(t,r,7),s=0|zu[e-2],a=0|_u[e-2],o=Nu.rotrSH(s,a,19)^Nu.rotrBH(s,a,61)^Nu.shrSH(s,a,6),c=Nu.rotrSL(s,a,19)^Nu.rotrBL(s,a,61)^Nu.shrSL(s,a,6),h=Nu.add4L(i,c,_u[e-7],_u[e-16]),u=Nu.add4H(h,n,o,zu[e-7],zu[e-16]);zu[e]=0|u,_u[e]=0|h}let{Ah:r,Al:n,Bh:i,Bl:s,Ch:a,Cl:o,Dh:c,Dl:h,Eh:u,El:l,Fh:y,Fl:f,Gh:g,Gl:p,Hh:d,Hl:A}=this;for(let e=0;e<80;e++){const t=Nu.rotrSH(u,l,14)^Nu.rotrSH(u,l,18)^Nu.rotrBH(u,l,41),w=Nu.rotrSL(u,l,14)^Nu.rotrSL(u,l,18)^Nu.rotrBL(u,l,41),m=u&y^~u&g,b=l&f^~l&p,k=Nu.add5L(A,w,b,Hu[e],_u[e]),E=Nu.add5H(k,d,t,m,Ou[e],zu[e]),v=0|k,B=Nu.rotrSH(r,n,28)^Nu.rotrBH(r,n,34)^Nu.rotrBH(r,n,39),I=Nu.rotrSL(r,n,28)^Nu.rotrBL(r,n,34)^Nu.rotrBL(r,n,39),S=r&i^r&a^i&a,K=n&s^n&o^s&o;d=0|g,A=0|p,g=0|y,p=0|f,y=0|u,f=0|l,({h:u,l}=Nu.add(0|c,0|h,0|E,0|v)),c=0|a,h=0|o,a=0|i,o=0|s,i=0|r,s=0|n;const C=Nu.add3L(v,I,K);r=Nu.add3H(C,E,B,S),n=0|C}({h:r,l:n}=Nu.add(0|this.Ah,0|this.Al,0|r,0|n)),({h:i,l:s}=Nu.add(0|this.Bh,0|this.Bl,0|i,0|s)),({h:a,l:o}=Nu.add(0|this.Ch,0|this.Cl,0|a,0|o)),({h:c,l:h}=Nu.add(0|this.Dh,0|this.Dl,0|c,0|h)),({h:u,l}=Nu.add(0|this.Eh,0|this.El,0|u,0|l)),({h:y,l:f}=Nu.add(0|this.Fh,0|this.Fl,0|y,0|f)),({h:g,l:p}=Nu.add(0|this.Gh,0|this.Gl,0|g,0|p)),({h:d,l:A}=Nu.add(0|this.Hh,0|this.Hl,0|d,0|A)),this.set(r,n,i,s,a,o,c,h,u,l,y,f,g,p,d,A)}roundClean(){zu.fill(0),_u.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)}}class ju extends Gu{constructor(){super(),this.Ah=-876896931,this.Al=-1056596264,this.Bh=1654270250,this.Bl=914150663,this.Ch=-1856437926,this.Cl=812702999,this.Dh=355462360,this.Dl=-150054599,this.Eh=1731405415,this.El=-4191439,this.Fh=-1900787065,this.Fl=1750603025,this.Gh=-619958771,this.Gl=1694076839,this.Hh=1203062813,this.Hl=-1090891868,this.outputLen=48}}const qu=/* @__PURE__ */nh((()=>new Gu)),Vu=/* @__PURE__ */nh((()=>new ju)),Wu=cu(BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffeffffffff0000000000000000ffffffff")),Zu=Cu({a:Wu.create(BigInt("-3")),b:BigInt("0xb3312fa7e23ee7e4988e056be3f82d19181d9c6efe8141120314088f5013875ac656398d8a2ed19d2a85c8edd3ec2aef"),Fp:Wu,n:BigInt("0xffffffffffffffffffffffffffffffffffffffffffffffffc7634d81f4372ddf581a0db248b0a77aecec196accc52973"),Gx:BigInt("0xaa87ca22be8b05378eb1c71ef320ad746e1d3b628ba79b9859f741e082542a385502f25dbf55296c3a545e3872760ab7"),Gy:BigInt("0x3617de4a96262c6f5d9e98bf9292dc29f8f41dbd289a147ce9da3113b5f0b8c00a60b1ce1d7e819d7a431d7c90ea0e5f"),h:BigInt(1),lowS:!1},Vu),Yu=cu(BigInt("0x1ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff")),Ju={a:Yu.create(BigInt("-3")),b:BigInt("0x0051953eb9618e1c9a1f929a21a0b68540eea2da725b99b315f3b8b489918ef109e156193951ec7e937b1652c0bd3bb1bf073573df883d2c34f1ef451fd46b503f00"),Fp:Yu,n:BigInt("0x01fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffa51868783bf2f966b7fcc0148f709a5d03bb5c9b8899c47aebb6fb71e91386409"),Gx:BigInt("0x00c6858e06b70404e9cd9e3ecb662395b4429c648139053fb521f828af606b4d3dbaa14b5e77efe75928fe1dc127a2ffa8de3348b3c1856a429bf97e7e31c2e5bd66"),Gy:BigInt("0x011839296a789a3bc0045c8a5fb42c7d1bd998f54449579b446817afbd17273e662c97ee72995ef42640c550b9013fad0761353c7086a272c24088be94769fd16650"),h:BigInt(1)},$u=Cu({a:Ju.a,b:Ju.b,Fp:Yu,n:Ju.n,Gx:Ju.Gx,Gy:Ju.Gy,h:Ju.h,lowS:!1,allowedPrivateKeyLengths:[130,131,132]},qu),Xu=[],el=[],tl=[],rl=/* @__PURE__ */BigInt(0),nl=/* @__PURE__ */BigInt(1),il=/* @__PURE__ */BigInt(2),sl=/* @__PURE__ */BigInt(7),al=/* @__PURE__ */BigInt(256),ol=/* @__PURE__ */BigInt(113);for(let e=0,t=nl,r=1,n=0;e<24;e++){[r,n]=[n,(2*r+3*n)%5],Xu.push(2*(5*n+r)),el.push((e+1)*(e+2)/2%64);let i=rl;for(let e=0;e<7;e++)t=(t<>sl)*ol)%al,t&il&&(i^=nl<<(nl<r>32?Tu(e,t,r):Lu(e,t,r),ll=(e,t,r)=>r>32?Fu(e,t,r):Mu(e,t,r);class yl extends rh{constructor(e,t,r,n=!1,i=24){if(super(),this.blockLen=e,this.suffix=t,this.outputLen=r,this.enableXOF=n,this.rounds=i,this.pos=0,this.posOut=0,this.finished=!1,this.destroyed=!1,_c(r),0>=this.blockLen||this.blockLen>=200)throw Error("Sha3 supports only keccak-f1600 function");var s;this.state=new Uint8Array(200),this.state32=(s=this.state,new Uint32Array(s.buffer,s.byteOffset,Math.floor(s.byteLength/4)))}keccak(){Jc||$c(this.state32),function(e,t=24){const r=new Uint32Array(10);for(let n=24-t;n<24;n++){for(let t=0;t<10;t++)r[t]=e[t]^e[t+10]^e[t+20]^e[t+30]^e[t+40];for(let t=0;t<10;t+=2){const n=(t+8)%10,i=(t+2)%10,s=r[i],a=r[i+1],o=ul(s,a,1)^r[n],c=ll(s,a,1)^r[n+1];for(let r=0;r<50;r+=10)e[t+r]^=o,e[t+r+1]^=c}let t=e[2],i=e[3];for(let r=0;r<24;r++){const n=el[r],s=ul(t,i,n),a=ll(t,i,n),o=Xu[r];t=e[o],i=e[o+1],e[o]=s,e[o+1]=a}for(let t=0;t<50;t+=10){for(let n=0;n<10;n++)r[n]=e[t+n];for(let n=0;n<10;n++)e[t+n]^=~r[(n+2)%10]&r[(n+4)%10]}e[0]^=cl[n],e[1]^=hl[n]}r.fill(0)}(this.state32,this.rounds),Jc||$c(this.state32),this.posOut=0,this.pos=0}update(e){jc(this);const{blockLen:t,state:r}=this,n=(e=eh(e)).length;for(let i=0;i=r&&this.keccak();const s=Math.min(r-this.posOut,i-n);e.set(t.subarray(this.posOut,this.posOut+s),n),this.posOut+=s,n+=s}return e}xofInto(e){if(!this.enableXOF)throw Error("XOF is not possible for this instance");return this.writeInto(e)}xof(e){return _c(e),this.xofInto(new Uint8Array(e))}digestInto(e){if(qc(e,this),this.finished)throw Error("digest() was already called");return this.writeInto(e),this.destroy(),e}digest(){return this.digestInto(new Uint8Array(this.outputLen))}destroy(){this.destroyed=!0,this.state.fill(0)}_cloneInto(e){const{blockLen:t,suffix:r,outputLen:n,rounds:i,enableXOF:s}=this;return e||(e=new yl(t,r,n,s,i)),e.state32.set(this.state32),e.pos=this.pos,e.posOut=this.posOut,e.finished=this.finished,e.rounds=i,e.suffix=r,e.outputLen=n,e.enableXOF=s,e.destroyed=this.destroyed,e}}const fl=(e,t,r)=>nh((()=>new yl(t,e,r))),gl=/* @__PURE__ */fl(6,136,32),pl=/* @__PURE__ */fl(6,72,64),dl=/* @__PURE__ */((e,t,r)=>function(e){const t=(t,r)=>e(r).update(eh(t)).digest(),r=e({});return t.outputLen=r.outputLen,t.blockLen=r.blockLen,t.create=t=>e(t),t}(((n={})=>new yl(t,e,void 0===n.dkLen?r:n.dkLen,!0))))(31,136,32),Al=BigInt(0),wl=BigInt(1),ml=BigInt(2),bl=BigInt(8),kl={zip215:!0};function El(e){const t=function(e){const t=Au(e);return jh(e,{hash:"function",a:"bigint",d:"bigint",randomBytes:"function"},{adjustScalarBytes:"function",domain:"function",uvRatio:"function",mapToCurve:"function"}),Object.freeze({...t})}(e),{Fp:r,n,prehash:i,hash:s,randomBytes:a,nByteLength:o,h:c}=t,h=ml<{try{return{isValid:!0,value:r.sqrt(e*r.inv(t))}}catch(e){return{isValid:!1,value:Al}}}),f=t.adjustScalarBytes||(e=>e),g=t.domain||((e,t,r)=>{if(Eh("phflag",r),t.length||r)throw Error("Contexts/pre-hash are not supported");return e});function p(e,t){Fh("coordinate "+e,t,Al,h)}function d(e){if(!(e instanceof m))throw Error("ExtendedPoint expected")}const A=qh(((e,t)=>{const{ex:n,ey:i,ez:s}=e,a=e.is0();null==t&&(t=a?bl:r.inv(s));const o=u(n*t),c=u(i*t),h=u(s*t);if(a)return{x:Al,y:wl};if(h!==wl)throw Error("invZ was invalid");return{x:o,y:c}})),w=qh((e=>{const{a:r,d:n}=t;if(e.is0())throw Error("bad point: ZERO");const{ex:i,ey:s,ez:a,et:o}=e,c=u(i*i),h=u(s*s),l=u(a*a),y=u(l*l),f=u(c*r);if(u(l*u(f+h))!==u(y+u(n*u(c*h))))throw Error("bad point: equation left != right (1)");if(u(i*s)!==u(a*o))throw Error("bad point: equation left != right (2)");return!0}));class m{constructor(e,t,r,n){this.ex=e,this.ey=t,this.ez=r,this.et=n,p("x",e),p("y",t),p("z",r),p("t",n),Object.freeze(this)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static fromAffine(e){if(e instanceof m)throw Error("extended point not allowed");const{x:t,y:r}=e||{};return p("x",t),p("y",r),new m(t,r,wl,u(t*r))}static normalizeZ(e){const t=r.invertBatch(e.map((e=>e.ez)));return e.map(((e,r)=>e.toAffine(t[r]))).map(m.fromAffine)}static msm(e,t){return du(m,l,e,t)}_setWindowSize(e){E.setWindowSize(this,e)}assertValidity(){w(this)}equals(e){d(e);const{ex:t,ey:r,ez:n}=this,{ex:i,ey:s,ez:a}=e,o=u(t*a),c=u(i*n),h=u(r*a),l=u(s*n);return o===c&&h===l}is0(){return this.equals(m.ZERO)}negate(){return new m(u(-this.ex),this.ey,this.ez,u(-this.et))}double(){const{a:e}=t,{ex:r,ey:n,ez:i}=this,s=u(r*r),a=u(n*n),o=u(ml*u(i*i)),c=u(e*s),h=r+n,l=u(u(h*h)-s-a),y=c+a,f=y-o,g=c-a,p=u(l*f),d=u(y*g),A=u(l*g),w=u(f*y);return new m(p,d,w,A)}add(e){d(e);const{a:r,d:n}=t,{ex:i,ey:s,ez:a,et:o}=this,{ex:c,ey:h,ez:l,et:y}=e;if(r===BigInt(-1)){const e=u((s-i)*(h+c)),t=u((s+i)*(h-c)),r=u(t-e);if(r===Al)return this.double();const n=u(a*ml*y),f=u(o*ml*l),g=f+n,p=t+e,d=f-n,A=u(g*r),w=u(p*d),b=u(g*d),k=u(r*p);return new m(A,w,k,b)}const f=u(i*c),g=u(s*h),p=u(o*n*y),A=u(a*l),w=u((i+s)*(c+h)-f-g),b=A-p,k=A+p,E=u(g-r*f),v=u(w*b),B=u(k*E),I=u(w*E),S=u(b*k);return new m(v,B,S,I)}subtract(e){return this.add(e.negate())}wNAF(e){return E.wNAFCached(this,e,m.normalizeZ)}multiply(e){const t=e;Fh("scalar",t,wl,n);const{p:r,f:i}=this.wNAF(t);return m.normalizeZ([r,i])[0]}multiplyUnsafe(e){const t=e;return Fh("scalar",t,Al,n),t===Al?k:this.equals(k)||t===wl?this:this.equals(b)?this.wNAF(t).p:E.unsafeLadder(this,t)}isSmallOrder(){return this.multiplyUnsafe(c).is0()}isTorsionFree(){return E.unsafeLadder(this,n).is0()}toAffine(e){return A(this,e)}clearCofactor(){const{h:e}=t;return e===wl?this:this.multiplyUnsafe(e)}static fromHex(e,n=!1){const{d:i,a:s}=t,a=r.BYTES;e=Rh("pointHex",e,a),Eh("zip215",n);const o=e.slice(),c=e[a-1];o[a-1]=-129&c;const l=Dh(o),f=n?h:r.ORDER;Fh("pointHex.y",l,Al,f);const g=u(l*l),p=u(g-wl),d=u(i*g-s);let{isValid:A,value:w}=y(p,d);if(!A)throw Error("Point.fromHex: invalid y coordinate");const b=(w&wl)===wl,k=!!(128&c);if(!n&&w===Al&&k)throw Error("Point.fromHex: x=0 and x_0=1");return k!==b&&(w=u(-w)),m.fromAffine({x:w,y:l})}static fromPrivateKey(e){return I(e).point}toRawBytes(){const{x:e,y:t}=this.toAffine(),n=Qh(t,r.BYTES);return n[n.length-1]|=e&wl?128:0,n}toHex(){return Bh(this.toRawBytes())}}m.BASE=new m(t.Gx,t.Gy,wl,u(t.Gx*t.Gy)),m.ZERO=new m(Al,wl,wl,Al);const{BASE:b,ZERO:k}=m,E=pu(m,8*o);function v(e){return tu(e,n)}function B(e){return v(Dh(e))}function I(e){const t=o;e=Rh("private key",e,t);const r=Rh("hashed private key",s(e),2*t),n=f(r.slice(0,t)),i=r.slice(t,2*t),a=B(n),c=b.multiply(a),h=c.toRawBytes();return{head:n,prefix:i,scalar:a,point:c,pointBytes:h}}function S(e=new Uint8Array,...t){const r=Lh(...t);return B(s(g(r,Rh("context",e),!!i)))}const K=kl;b._setWindowSize(8);return{CURVE:t,getPublicKey:function(e){return I(e).pointBytes},sign:function(e,t,s={}){e=Rh("message",e),i&&(e=i(e));const{prefix:a,scalar:c,pointBytes:h}=I(t),u=S(s.context,a,e),l=b.multiply(u).toRawBytes(),y=v(u+S(s.context,l,h,e)*c);return Fh("signature.s",y,Al,n),Rh("result",Lh(l,Qh(y,r.BYTES)),2*o)},verify:function(e,t,n,s=K){const{context:a,zip215:o}=s,c=r.BYTES;e=Rh("signature",e,2*c),t=Rh("message",t),void 0!==o&&Eh("zip215",o),i&&(t=i(t));const h=Dh(e.slice(c,2*c));let u,l,y;try{u=m.fromHex(n,o),l=m.fromHex(e.slice(0,c),o),y=b.multiplyUnsafe(h)}catch(e){return!1}if(!o&&u.isSmallOrder())return!1;const f=S(a,l.toRawBytes(),u.toRawBytes(),t);return l.add(u.multiplyUnsafe(f)).subtract(y).clearCofactor().equals(m.ZERO)},ExtendedPoint:m,utils:{getExtendedPublicKey:I,randomPrivateKey:()=>a(r.BYTES),precompute:(e=8,t=m.BASE)=>(t._setWindowSize(e),t.multiply(BigInt(3)),t)}}} /*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const vl=BigInt(0),Bl=BigInt(1);function Il(e){const t=(jh(r=e,{a:"bigint"},{montgomeryBits:"isSafeInteger",nByteLength:"isSafeInteger",adjustScalarBytes:"function",domain:"function",powPminus2:"function",Gu:"bigint"}),Object.freeze({...r}));var r;const{P:n}=t,i=e=>tu(e,n),s=t.montgomeryBits,a=Math.ceil(s/8),o=t.nByteLength,c=t.adjustScalarBytes||(e=>e),h=t.powPminus2||(e=>ru(e,n-BigInt(2),n));function u(e,t,r){const n=i(e*(t-r));return[t=i(t-n),r=i(r+n)]}const l=(t.a-BigInt(2))/BigInt(4);function y(e){return Qh(i(e),a)}function f(e,t){const r=function(e){const t=Rh("u coordinate",e,a);return 32===o&&(t[31]&=127),Dh(t)}(t),f=function(e){const t=Rh("scalar",e),r=t.length;if(r!==a&&r!==o)throw Error(`Expected ${a} or ${o} bytes, got ${r}`);return Dh(c(t))}(e),g=function(e,t){Fh("u",e,vl,n),Fh("scalar",t,vl,n);const r=t,a=e;let o,c=Bl,y=vl,f=e,g=Bl,p=vl;for(let e=BigInt(s-1);e>=vl;e--){const t=r>>e&Bl;p^=t,o=u(p,c,f),c=o[0],f=o[1],o=u(p,y,g),y=o[0],g=o[1],p=t;const n=c+y,s=i(n*n),h=c-y,d=i(h*h),A=s-d,w=f+g,m=i((f-g)*n),b=i(w*h),k=m+b,E=m-b;f=i(k*k),g=i(a*i(E*E)),c=i(s*d),y=i(A*(s+i(l*A)))}o=u(p,c,f),c=o[0],f=o[1],o=u(p,y,g),y=o[0],g=o[1];const d=h(y);return i(c*d)}(r,f);if(g===vl)throw Error("Invalid private or public key received");return y(g)}const g=y(t.Gu);function p(e){return f(e,g)}return{scalarMult:f,scalarMultBase:p,getSharedSecret:(e,t)=>f(e,t),getPublicKey:e=>p(e),utils:{randomPrivateKey:()=>t.randomBytes(t.nByteLength)},GuBytes:g}} /*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const Sl=nh((()=>dl.create({dkLen:114}))),Kl=(nh((()=>dl.create({dkLen:64}))),BigInt("726838724295606890549323807888004534353641360687318060281490199180612328166730772686396383698676545930088884461843637361053498018365439")),Cl=BigInt(1),Pl=BigInt(2),Ul=BigInt(3);BigInt(4);const Dl=BigInt(11),xl=BigInt(22),Ql=BigInt(44),Rl=BigInt(88),Ll=BigInt(223);function Ml(e){const t=Kl,r=e*e*e%t,n=r*r*e%t,i=nu(n,Ul,t)*n%t,s=nu(i,Ul,t)*n%t,a=nu(s,Pl,t)*r%t,o=nu(a,Dl,t)*a%t,c=nu(o,xl,t)*o%t,h=nu(c,Ql,t)*c%t,u=nu(h,Rl,t)*h%t,l=nu(u,Ql,t)*c%t,y=nu(l,Pl,t)*r%t,f=nu(y,Cl,t)*e%t;return nu(f,Ll,t)*y%t}function Tl(e){return e[0]&=252,e[55]|=128,e[56]=0,e}const Fl=cu(Kl,456,!0),Nl={a:BigInt(1),d:BigInt("726838724295606890549323807888004534353641360687318060281490199180612328166730772686396383698676545930088884461843637361053498018326358"),Fp:Fl,n:BigInt("181709681073901722637330951972001133588410340171829515070372549795146003961539585716195755291692375963310293709091662304773755859649779"),nBitLength:456,h:BigInt(4),Gx:BigInt("224580040295924300187604334099896036246789641632564134246125461686950415467406032909029192869357953282578032075146446173674602635247710"),Gy:BigInt("298819210078481492676017930443930673437544040154080242095928241372331506189835876003536878655418784733982303233503462500531545062832660"),hash:Sl,randomBytes:ih,adjustScalarBytes:Tl,domain:(e,t,r)=>{if(t.length>255)throw Error("Context is too big: "+t.length);return th(Xc("SigEd448"),new Uint8Array([r?1:0,t.length]),t,e)},uvRatio:function(e,t){const r=Kl,n=tu(e*e*t,r),i=tu(n*e,r),s=tu(i*n*t,r),a=tu(i*Ml(s),r),o=tu(a*a,r);return{isValid:tu(o*t,r)===e,value:a}}},Ol=/* @__PURE__ */El(Nl),Hl=/* @__PURE__ */(()=>Il({a:BigInt(156326),montgomeryBits:448,nByteLength:56,P:Kl,Gu:BigInt(5),powPminus2:e=>{const t=Kl;return tu(nu(Ml(e),BigInt(2),t)*e,t)},adjustScalarBytes:Tl,randomBytes:ih}))();Fl.ORDER,BigInt(3),BigInt(4),BigInt(156326),BigInt("39082"),BigInt("78163"),BigInt("98944233647732219769177004876929019128417576295529901074099889598043702116001257856802131563896515373927712232092845883226922417596214"),BigInt("315019913931389607337177038330951043522456072897266928557328499619017160722351061360252776265186336876723201881398623946864393857820716"),BigInt("0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"); /*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */ const zl=BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),_l=BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),Gl=BigInt(1),jl=BigInt(2),ql=(e,t)=>(e+t/jl)/t;const Vl=cu(zl,void 0,void 0,{sqrt:function(e){const t=zl,r=BigInt(3),n=BigInt(6),i=BigInt(11),s=BigInt(22),a=BigInt(23),o=BigInt(44),c=BigInt(88),h=e*e*e%t,u=h*h*e%t,l=nu(u,r,t)*u%t,y=nu(l,r,t)*u%t,f=nu(y,jl,t)*h%t,g=nu(f,i,t)*f%t,p=nu(g,s,t)*g%t,d=nu(p,o,t)*p%t,A=nu(d,c,t)*d%t,w=nu(A,o,t)*p%t,m=nu(w,r,t)*u%t,b=nu(m,a,t)*g%t,k=nu(b,n,t)*h%t,E=nu(k,jl,t);if(!Vl.eql(Vl.sqr(E),e))throw Error("Cannot find square root");return E}}),Wl=Cu({a:BigInt(0),b:BigInt(7),Fp:Vl,n:_l,Gx:BigInt("55066263022277343669578718895168534326250603453777594175500187360389116729240"),Gy:BigInt("32670510020758816978083085130507043184471273380659243275938904335757337482424"),h:BigInt(1),lowS:!0,endo:{beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),splitScalar:e=>{const t=_l,r=BigInt("0x3086d221a7d46bcde86c90e49284eb15"),n=-Gl*BigInt("0xe4437ed6010e88286f547fa90abfe4c3"),i=BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),s=r,a=BigInt("0x100000000000000000000000000000000"),o=ql(s*e,t),c=ql(-n*e,t);let h=tu(e-o*r-c*i,t),u=tu(-o*n-c*s,t);const l=h>a,y=u>a;if(l&&(h=t-h),y&&(u=t-u),h>a||u>a)throw Error("splitScalar: Endomorphism failed, k="+e);return{k1neg:l,k1:h,k2neg:y,k2:u}}}},fh);BigInt(0),Wl.ProjectivePoint;const Zl=cu(BigInt("0xa9fb57dba1eea9bc3e660a909d838d726e3bf623d52620282013481d1f6e5377")),Yl=Cu({a:Zl.create(BigInt("0x7d5a0975fc2c3057eef67530417affe7fb8055c126dc5c6ce94a4b44f330b5d9")),b:BigInt("0x26dc5c6ce94a4b44f330b5d9bbd77cbf958416295cf7e1ce6bccdc18ff8c07b6"),Fp:Zl,n:BigInt("0xa9fb57dba1eea9bc3e660a909d838d718c397aa3b561a6f7901e0e82974856a7"),Gx:BigInt("0x8bd2aeb9cb7e57cb2c4b482ffc81b7afb9de27e1e3bd23c23a4453bd9ace3262"),Gy:BigInt("0x547ef835c3dac4fd97f8461a14611dc9c27745132ded8e545c1d54c72f046997"),h:BigInt(1),lowS:!1},fh),Jl=cu(BigInt("0x8cb91e82a3386d280f5d6f7e50e641df152f7109ed5456b412b1da197fb71123acd3a729901d1a71874700133107ec53")),$l=Cu({a:Jl.create(BigInt("0x7bc382c63d8c150c3c72080ace05afa0c2bea28e4fb22787139165efba91f90f8aa5814a503ad4eb04a8c7dd22ce2826")),b:BigInt("0x04a8c7dd22ce28268b39b55416f0447c2fb77de107dcd2a62e880ea53eeb62d57cb4390295dbc9943ab78696fa504c11"),Fp:Jl,n:BigInt("0x8cb91e82a3386d280f5d6f7e50e641df152f7109ed5456b31f166e6cac0425a7cf3ab6af6b7fc3103b883202e9046565"),Gx:BigInt("0x1d1c64f068cf45ffa2a63a81b7c13f6b8847a3e77ef14fe3db7fcafe0cbd10e8e826e03436d646aaef87b2e247d4af1e"),Gy:BigInt("0x8abe1d7520f9c2a45cb1eb8e95cfd55262b70b29feec5864e19c054ff99129280e4646217791811142820341263c5315"),h:BigInt(1),lowS:!1},Vu),Xl=cu(BigInt("0xaadd9db8dbe9c48b3fd4e6ae33c9fc07cb308db3b3c9d20ed6639cca703308717d4d9b009bc66842aecda12ae6a380e62881ff2f2d82c68528aa6056583a48f3")),ey=Cu({a:Xl.create(BigInt("0x7830a3318b603b89e2327145ac234cc594cbdd8d3df91610a83441caea9863bc2ded5d5aa8253aa10a2ef1c98b9ac8b57f1117a72bf2c7b9e7c1ac4d77fc94ca")),b:BigInt("0x3df91610a83441caea9863bc2ded5d5aa8253aa10a2ef1c98b9ac8b57f1117a72bf2c7b9e7c1ac4d77fc94cadc083e67984050b75ebae5dd2809bd638016f723"),Fp:Xl,n:BigInt("0xaadd9db8dbe9c48b3fd4e6ae33c9fc07cb308db3b3c9d20ed6639cca70330870553e5c414ca92619418661197fac10471db1d381085ddaddb58796829ca90069"),Gx:BigInt("0x81aee4bdd82ed9645a21322e9c4c6a9385ed9f70b5d916c1b43b62eef4d0098eff3b1f78e2d0d48d50d1687b93b97d5f7c6d5047406a5e688b352209bcb9f822"),Gy:BigInt("0x7dde385d566332ecc0eabfa9cf7822fdf209f70024a57b1aa000c55b881f8111b2dcde494a5f485e5bca4bd88a2763aed1ca2b2fa8f0540678cd1e0f3ad80892"),h:BigInt(1),lowS:!1},qu),ty=new Map(Object.entries({nistP256:Uu,nistP384:Zu,nistP521:$u,brainpoolP256r1:Yl,brainpoolP384r1:$l,brainpoolP512r1:ey,secp256k1:Wl,x448:Hl,ed448:Ol}));var ry=/*#__PURE__*/Object.freeze({__proto__:null,nobleCurves:ty});function ny(e,t,r,n,i,s){const a=[16843776,0,65536,16843780,16842756,66564,4,65536,1024,16843776,16843780,1024,16778244,16842756,16777216,4,1028,16778240,16778240,66560,66560,16842752,16842752,16778244,65540,16777220,16777220,65540,0,1028,66564,16777216,65536,16843780,4,16842752,16843776,16777216,16777216,1024,16842756,65536,66560,16777220,1024,4,16778244,66564,16843780,65540,16842752,16778244,16777220,1028,66564,16843776,1028,16778240,16778240,0,65540,66560,0,16842756],o=[-2146402272,-2147450880,32768,1081376,1048576,32,-2146435040,-2147450848,-2147483616,-2146402272,-2146402304,-2147483648,-2147450880,1048576,32,-2146435040,1081344,1048608,-2147450848,0,-2147483648,32768,1081376,-2146435072,1048608,-2147483616,0,1081344,32800,-2146402304,-2146435072,32800,0,1081376,-2146435040,1048576,-2147450848,-2146435072,-2146402304,32768,-2146435072,-2147450880,32,-2146402272,1081376,32,32768,-2147483648,32800,-2146402304,1048576,-2147483616,1048608,-2147450848,-2147483616,1048608,1081344,0,-2147450880,32800,-2147483648,-2146435040,-2146402272,1081344],c=[520,134349312,0,134348808,134218240,0,131592,134218240,131080,134217736,134217736,131072,134349320,131080,134348800,520,134217728,8,134349312,512,131584,134348800,134348808,131592,134218248,131584,131072,134218248,8,134349320,512,134217728,134349312,134217728,131080,520,131072,134349312,134218240,0,512,131080,134349320,134218240,134217736,512,0,134348808,134218248,131072,134217728,134349320,8,131592,131584,134217736,134348800,134218248,520,134348800,131592,8,134348808,131584],h=[8396801,8321,8321,128,8396928,8388737,8388609,8193,0,8396800,8396800,8396929,129,0,8388736,8388609,1,8192,8388608,8396801,128,8388608,8193,8320,8388737,1,8320,8388736,8192,8396928,8396929,129,8388736,8388609,8396800,8396929,129,0,0,8396800,8320,8388736,8388737,1,8396801,8321,8321,128,8396929,129,1,8192,8388609,8193,8396928,8388737,8193,8320,8388608,8396801,128,8388608,8192,8396928],u=[256,34078976,34078720,1107296512,524288,256,1073741824,34078720,1074266368,524288,33554688,1074266368,1107296512,1107820544,524544,1073741824,33554432,1074266112,1074266112,0,1073742080,1107820800,1107820800,33554688,1107820544,1073742080,0,1107296256,34078976,33554432,1107296256,524544,524288,1107296512,256,33554432,1073741824,34078720,1107296512,1074266368,33554688,1073741824,1107820544,34078976,1074266368,256,33554432,1107820544,1107820800,524544,1107296256,1107820800,34078720,0,1074266112,1107296256,524544,33554688,1073742080,524288,0,1074266112,34078976,1073742080],l=[536870928,541065216,16384,541081616,541065216,16,541081616,4194304,536887296,4210704,4194304,536870928,4194320,536887296,536870912,16400,0,4194320,536887312,16384,4210688,536887312,16,541065232,541065232,0,4210704,541081600,16400,4210688,541081600,536870912,536887296,16,541065232,4210688,541081616,4194304,16400,536870928,4194304,536887296,536870912,16400,536870928,541081616,4210688,541065216,4210704,541081600,0,541065232,16,16384,541065216,4210704,16384,4194320,536887312,0,541081600,536870912,4194320,536887312],y=[2097152,69206018,67110914,0,2048,67110914,2099202,69208064,69208066,2097152,0,67108866,2,67108864,69206018,2050,67110912,2099202,2097154,67110912,67108866,69206016,69208064,2097154,69206016,2048,2050,69208066,2099200,2,67108864,2099200,67108864,2099200,2097152,67110914,67110914,69206018,69206018,2,2097154,67108864,67110912,2097152,69208064,2050,2099202,69208064,2050,67108866,69208066,69206016,2099200,0,2,69208066,0,2099202,69206016,2048,67108866,67110912,2048,2097154],f=[268439616,4096,262144,268701760,268435456,268439616,64,268435456,262208,268697600,268701760,266240,268701696,266304,4096,64,268697600,268435520,268439552,4160,266240,262208,268697664,268701696,4160,0,0,268697664,268435520,268439552,266304,262144,266304,262144,268701696,4096,64,268697664,4096,266304,268439552,64,268435520,268697600,268697664,268435456,262144,268439616,0,268701760,262208,268435520,268697600,268439552,268439616,0,268701760,266240,266240,4160,4160,262208,268435456,268701696];let g,p,d,A,w,m,b,k,E,v,B=0,I=t.length;const S=32===e.length?3:9;k=3===S?r?[0,32,2]:[30,-2,-2]:r?[0,32,2,62,30,-2,64,96,2]:[94,62,-2,32,64,2,30,-2,-2],r&&(t=function(e){const t=8-e.length%8;let r;if(!(t<8)){if(8===t)return e;throw Error("des: invalid padding")}r=0;const n=new Uint8Array(e.length+t);for(let t=0;t>>4^b),b^=d,m^=d<<4,d=65535&(m>>>16^b),b^=d,m^=d<<16,d=858993459&(b>>>2^m),m^=d,b^=d<<2,d=16711935&(b>>>8^m),m^=d,b^=d<<8,d=1431655765&(m>>>1^b),b^=d,m^=d<<1,m=m<<1|m>>>31,b=b<<1|b>>>31,p=0;p>>4|b<<28)^e[g+1],d=m,m=b,b=d^(o[A>>>24&63]|h[A>>>16&63]|l[A>>>8&63]|f[63&A]|a[w>>>24&63]|c[w>>>16&63]|u[w>>>8&63]|y[63&w]);d=m,m=b,b=d}m=m>>>1|m<<31,b=b>>>1|b<<31,d=1431655765&(m>>>1^b),b^=d,m^=d<<1,d=16711935&(b>>>8^m),m^=d,b^=d<<8,d=858993459&(b>>>2^m),m^=d,b^=d<<2,d=65535&(m>>>16^b),b^=d,m^=d<<16,d=252645135&(m>>>4^b),b^=d,m^=d<<4,K[C++]=m>>>24,K[C++]=m>>>16&255,K[C++]=m>>>8&255,K[C++]=255&m,K[C++]=b>>>24,K[C++]=b>>>16&255,K[C++]=b>>>8&255,K[C++]=255&b}return r||(K=function(e){let t,r=null;if(t=0,!r){for(r=1;e[e.length-r]===t;)r++;r--}return e.subarray(0,e.length-r)}(K)),K}function iy(e){const t=[0,4,536870912,536870916,65536,65540,536936448,536936452,512,516,536871424,536871428,66048,66052,536936960,536936964],r=[0,1,1048576,1048577,67108864,67108865,68157440,68157441,256,257,1048832,1048833,67109120,67109121,68157696,68157697],n=[0,8,2048,2056,16777216,16777224,16779264,16779272,0,8,2048,2056,16777216,16777224,16779264,16779272],i=[0,2097152,134217728,136314880,8192,2105344,134225920,136323072,131072,2228224,134348800,136445952,139264,2236416,134356992,136454144],s=[0,262144,16,262160,0,262144,16,262160,4096,266240,4112,266256,4096,266240,4112,266256],a=[0,1024,32,1056,0,1024,32,1056,33554432,33555456,33554464,33555488,33554432,33555456,33554464,33555488],o=[0,268435456,524288,268959744,2,268435458,524290,268959746,0,268435456,524288,268959744,2,268435458,524290,268959746],c=[0,65536,2048,67584,536870912,536936448,536872960,536938496,131072,196608,133120,198656,537001984,537067520,537004032,537069568],h=[0,262144,0,262144,2,262146,2,262146,33554432,33816576,33554432,33816576,33554434,33816578,33554434,33816578],u=[0,268435456,8,268435464,0,268435456,8,268435464,1024,268436480,1032,268436488,1024,268436480,1032,268436488],l=[0,32,0,32,1048576,1048608,1048576,1048608,8192,8224,8192,8224,1056768,1056800,1056768,1056800],y=[0,16777216,512,16777728,2097152,18874368,2097664,18874880,67108864,83886080,67109376,83886592,69206016,85983232,69206528,85983744],f=[0,4096,134217728,134221824,524288,528384,134742016,134746112,16,4112,134217744,134221840,524304,528400,134742032,134746128],g=[0,4,256,260,0,4,256,260,1,5,257,261,1,5,257,261],p=e.length>8?3:1,d=Array(32*p),A=[0,0,1,1,1,1,1,1,0,1,1,1,1,1,1,0];let w,m,b,k=0,E=0;for(let v=0;v>>4^v),v^=b,p^=b<<4,b=65535&(v>>>-16^p),p^=b,v^=b<<-16,b=858993459&(p>>>2^v),v^=b,p^=b<<2,b=65535&(v>>>-16^p),p^=b,v^=b<<-16,b=1431655765&(p>>>1^v),v^=b,p^=b<<1,b=16711935&(v>>>8^p),p^=b,v^=b<<8,b=1431655765&(p>>>1^v),v^=b,p^=b<<1,b=p<<8|v>>>20&240,p=v<<24|v<<8&16711680|v>>>8&65280|v>>>24&240,v=b;for(let e=0;e<16;e++)A[e]?(p=p<<2|p>>>26,v=v<<2|v>>>26):(p=p<<1|p>>>27,v=v<<1|v>>>27),p&=-15,v&=-15,w=t[p>>>28]|r[p>>>24&15]|n[p>>>20&15]|i[p>>>16&15]|s[p>>>12&15]|a[p>>>8&15]|o[p>>>4&15],m=c[v>>>28]|h[v>>>24&15]|u[v>>>20&15]|l[v>>>16&15]|y[v>>>12&15]|f[v>>>8&15]|g[v>>>4&15],b=65535&(m>>>16^w),d[E++]=w^b,d[E++]=m^b<<16}return d}function sy(e){this.key=[];for(let t=0;t<3;t++)this.key.push(new Uint8Array(e.subarray(8*t,8*t+8)));this.encrypt=function(e){return ny(iy(this.key[2]),ny(iy(this.key[1]),ny(iy(this.key[0]),e,!0),!1),!0)}}function ay(){this.BlockSize=8,this.KeySize=16,this.setKey=function(e){if(this.masking=Array(16),this.rotate=Array(16),this.reset(),e.length!==this.KeySize)throw Error("CAST-128: keys must be 16 bytes");return this.keySchedule(e),!0},this.reset=function(){for(let e=0;e<16;e++)this.masking[e]=0,this.rotate[e]=0},this.getBlockSize=function(){return this.BlockSize},this.encrypt=function(e){const t=Array(e.length);for(let s=0;s>>24&255,t[s+1]=c>>>16&255,t[s+2]=c>>>8&255,t[s+3]=255&c,t[s+4]=o>>>24&255,t[s+5]=o>>>16&255,t[s+6]=o>>>8&255,t[s+7]=255&o}return t},this.decrypt=function(e){const t=Array(e.length);for(let s=0;s>>24&255,t[s+1]=c>>>16&255,t[s+2]=c>>>8&255,t[s+3]=255&c,t[s+4]=o>>>24&255,t[s+5]=o>>16&255,t[s+6]=o>>8&255,t[s+7]=255&o}return t};const e=[,,,,];e[0]=[,,,,],e[0][0]=[4,0,13,15,12,14,8],e[0][1]=[5,2,16,18,17,19,10],e[0][2]=[6,3,23,22,21,20,9],e[0][3]=[7,1,26,25,27,24,11],e[1]=[,,,,],e[1][0]=[0,6,21,23,20,22,16],e[1][1]=[1,4,0,2,1,3,18],e[1][2]=[2,5,7,6,5,4,17],e[1][3]=[3,7,10,9,11,8,19],e[2]=[,,,,],e[2][0]=[4,0,13,15,12,14,8],e[2][1]=[5,2,16,18,17,19,10],e[2][2]=[6,3,23,22,21,20,9],e[2][3]=[7,1,26,25,27,24,11],e[3]=[,,,,],e[3][0]=[0,6,21,23,20,22,16],e[3][1]=[1,4,0,2,1,3,18],e[3][2]=[2,5,7,6,5,4,17],e[3][3]=[3,7,10,9,11,8,19];const t=[,,,,];function r(e,t,r){const n=t+e,i=n<>>32-r;return(s[0][i>>>24]^s[1][i>>>16&255])-s[2][i>>>8&255]+s[3][255&i]}function n(e,t,r){const n=t^e,i=n<>>32-r;return s[0][i>>>24]-s[1][i>>>16&255]+s[2][i>>>8&255]^s[3][255&i]}function i(e,t,r){const n=t-e,i=n<>>32-r;return(s[0][i>>>24]+s[1][i>>>16&255]^s[2][i>>>8&255])-s[3][255&i]}t[0]=[,,,,],t[0][0]=[24,25,23,22,18],t[0][1]=[26,27,21,20,22],t[0][2]=[28,29,19,18,25],t[0][3]=[30,31,17,16,28],t[1]=[,,,,],t[1][0]=[3,2,12,13,8],t[1][1]=[1,0,14,15,13],t[1][2]=[7,6,8,9,3],t[1][3]=[5,4,10,11,7],t[2]=[,,,,],t[2][0]=[19,18,28,29,25],t[2][1]=[17,16,30,31,28],t[2][2]=[23,22,24,25,18],t[2][3]=[21,20,26,27,22],t[3]=[,,,,],t[3][0]=[8,9,7,6,3],t[3][1]=[10,11,5,4,7],t[3][2]=[12,13,3,2,8],t[3][3]=[14,15,1,0,13],this.keySchedule=function(r){const n=[,,,,,,,,],i=Array(32);let a;for(let e=0;e<4;e++)a=4*e,n[e]=r[a]<<24|r[a+1]<<16|r[a+2]<<8|r[a+3];const o=[6,7,4,5];let c,h=0;for(let r=0;r<2;r++)for(let r=0;r<4;r++){for(a=0;a<4;a++){const t=e[r][a];c=n[t[1]],c^=s[4][n[t[2]>>>2]>>>24-8*(3&t[2])&255],c^=s[5][n[t[3]>>>2]>>>24-8*(3&t[3])&255],c^=s[6][n[t[4]>>>2]>>>24-8*(3&t[4])&255],c^=s[7][n[t[5]>>>2]>>>24-8*(3&t[5])&255],c^=s[o[a]][n[t[6]>>>2]>>>24-8*(3&t[6])&255],n[t[0]]=c}for(a=0;a<4;a++){const e=t[r][a];c=s[4][n[e[0]>>>2]>>>24-8*(3&e[0])&255],c^=s[5][n[e[1]>>>2]>>>24-8*(3&e[1])&255],c^=s[6][n[e[2]>>>2]>>>24-8*(3&e[2])&255],c^=s[7][n[e[3]>>>2]>>>24-8*(3&e[3])&255],c^=s[4+a][n[e[4]>>>2]>>>24-8*(3&e[4])&255],i[h]=c,h++}}for(let e=0;e<16;e++)this.masking[e]=i[e],this.rotate[e]=31&i[16+e]};const s=[,,,,,,,,];s[0]=[821772500,2678128395,1810681135,1059425402,505495343,2617265619,1610868032,3483355465,3218386727,2294005173,3791863952,2563806837,1852023008,365126098,3269944861,584384398,677919599,3229601881,4280515016,2002735330,1136869587,3744433750,2289869850,2731719981,2714362070,879511577,1639411079,575934255,717107937,2857637483,576097850,2731753936,1725645e3,2810460463,5111599,767152862,2543075244,1251459544,1383482551,3052681127,3089939183,3612463449,1878520045,1510570527,2189125840,2431448366,582008916,3163445557,1265446783,1354458274,3529918736,3202711853,3073581712,3912963487,3029263377,1275016285,4249207360,2905708351,3304509486,1442611557,3585198765,2712415662,2731849581,3248163920,2283946226,208555832,2766454743,1331405426,1447828783,3315356441,3108627284,2957404670,2981538698,3339933917,1669711173,286233437,1465092821,1782121619,3862771680,710211251,980974943,1651941557,430374111,2051154026,704238805,4128970897,3144820574,2857402727,948965521,3333752299,2227686284,718756367,2269778983,2731643755,718440111,2857816721,3616097120,1113355533,2478022182,410092745,1811985197,1944238868,2696854588,1415722873,1682284203,1060277122,1998114690,1503841958,82706478,2315155686,1068173648,845149890,2167947013,1768146376,1993038550,3566826697,3390574031,940016341,3355073782,2328040721,904371731,1205506512,4094660742,2816623006,825647681,85914773,2857843460,1249926541,1417871568,3287612,3211054559,3126306446,1975924523,1353700161,2814456437,2438597621,1800716203,722146342,2873936343,1151126914,4160483941,2877670899,458611604,2866078500,3483680063,770352098,2652916994,3367839148,3940505011,3585973912,3809620402,718646636,2504206814,2914927912,3631288169,2857486607,2860018678,575749918,2857478043,718488780,2069512688,3548183469,453416197,1106044049,3032691430,52586708,3378514636,3459808877,3211506028,1785789304,218356169,3571399134,3759170522,1194783844,1523787992,3007827094,1975193539,2555452411,1341901877,3045838698,3776907964,3217423946,2802510864,2889438986,1057244207,1636348243,3761863214,1462225785,2632663439,481089165,718503062,24497053,3332243209,3344655856,3655024856,3960371065,1195698900,2971415156,3710176158,2115785917,4027663609,3525578417,2524296189,2745972565,3564906415,1372086093,1452307862,2780501478,1476592880,3389271281,18495466,2378148571,901398090,891748256,3279637769,3157290713,2560960102,1447622437,4284372637,216884176,2086908623,1879786977,3588903153,2242455666,2938092967,3559082096,2810645491,758861177,1121993112,215018983,642190776,4169236812,1196255959,2081185372,3508738393,941322904,4124243163,2877523539,1848581667,2205260958,3180453958,2589345134,3694731276,550028657,2519456284,3789985535,2973870856,2093648313,443148163,46942275,2734146937,1117713533,1115362972,1523183689,3717140224,1551984063],s[1]=[522195092,4010518363,1776537470,960447360,4267822970,4005896314,1435016340,1929119313,2913464185,1310552629,3579470798,3724818106,2579771631,1594623892,417127293,2715217907,2696228731,1508390405,3994398868,3925858569,3695444102,4019471449,3129199795,3770928635,3520741761,990456497,4187484609,2783367035,21106139,3840405339,631373633,3783325702,532942976,396095098,3548038825,4267192484,2564721535,2011709262,2039648873,620404603,3776170075,2898526339,3612357925,4159332703,1645490516,223693667,1567101217,3362177881,1029951347,3470931136,3570957959,1550265121,119497089,972513919,907948164,3840628539,1613718692,3594177948,465323573,2659255085,654439692,2575596212,2699288441,3127702412,277098644,624404830,4100943870,2717858591,546110314,2403699828,3655377447,1321679412,4236791657,1045293279,4010672264,895050893,2319792268,494945126,1914543101,2777056443,3894764339,2219737618,311263384,4275257268,3458730721,669096869,3584475730,3835122877,3319158237,3949359204,2005142349,2713102337,2228954793,3769984788,569394103,3855636576,1425027204,108000370,2736431443,3671869269,3043122623,1750473702,2211081108,762237499,3972989403,2798899386,3061857628,2943854345,867476300,964413654,1591880597,1594774276,2179821409,552026980,3026064248,3726140315,2283577634,3110545105,2152310760,582474363,1582640421,1383256631,2043843868,3322775884,1217180674,463797851,2763038571,480777679,2718707717,2289164131,3118346187,214354409,200212307,3810608407,3025414197,2674075964,3997296425,1847405948,1342460550,510035443,4080271814,815934613,833030224,1620250387,1945732119,2703661145,3966000196,1388869545,3456054182,2687178561,2092620194,562037615,1356438536,3409922145,3261847397,1688467115,2150901366,631725691,3840332284,549916902,3455104640,394546491,837744717,2114462948,751520235,2221554606,2415360136,3999097078,2063029875,803036379,2702586305,821456707,3019566164,360699898,4018502092,3511869016,3677355358,2402471449,812317050,49299192,2570164949,3259169295,2816732080,3331213574,3101303564,2156015656,3705598920,3546263921,143268808,3200304480,1638124008,3165189453,3341807610,578956953,2193977524,3638120073,2333881532,807278310,658237817,2969561766,1641658566,11683945,3086995007,148645947,1138423386,4158756760,1981396783,2401016740,3699783584,380097457,2680394679,2803068651,3334260286,441530178,4016580796,1375954390,761952171,891809099,2183123478,157052462,3683840763,1592404427,341349109,2438483839,1417898363,644327628,2233032776,2353769706,2201510100,220455161,1815641738,182899273,2995019788,3627381533,3702638151,2890684138,1052606899,588164016,1681439879,4038439418,2405343923,4229449282,167996282,1336969661,1688053129,2739224926,1543734051,1046297529,1138201970,2121126012,115334942,1819067631,1902159161,1941945968,2206692869,1159982321],s[2]=[2381300288,637164959,3952098751,3893414151,1197506559,916448331,2350892612,2932787856,3199334847,4009478890,3905886544,1373570990,2450425862,4037870920,3778841987,2456817877,286293407,124026297,3001279700,1028597854,3115296800,4208886496,2691114635,2188540206,1430237888,1218109995,3572471700,308166588,570424558,2187009021,2455094765,307733056,1310360322,3135275007,1384269543,2388071438,863238079,2359263624,2801553128,3380786597,2831162807,1470087780,1728663345,4072488799,1090516929,532123132,2389430977,1132193179,2578464191,3051079243,1670234342,1434557849,2711078940,1241591150,3314043432,3435360113,3091448339,1812415473,2198440252,267246943,796911696,3619716990,38830015,1526438404,2806502096,374413614,2943401790,1489179520,1603809326,1920779204,168801282,260042626,2358705581,1563175598,2397674057,1356499128,2217211040,514611088,2037363785,2186468373,4022173083,2792511869,2913485016,1173701892,4200428547,3896427269,1334932762,2455136706,602925377,2835607854,1613172210,41346230,2499634548,2457437618,2188827595,41386358,4172255629,1313404830,2405527007,3801973774,2217704835,873260488,2528884354,2478092616,4012915883,2555359016,2006953883,2463913485,575479328,2218240648,2099895446,660001756,2341502190,3038761536,3888151779,3848713377,3286851934,1022894237,1620365795,3449594689,1551255054,15374395,3570825345,4249311020,4151111129,3181912732,310226346,1133119310,530038928,136043402,2476768958,3107506709,2544909567,1036173560,2367337196,1681395281,1758231547,3641649032,306774401,1575354324,3716085866,1990386196,3114533736,2455606671,1262092282,3124342505,2768229131,4210529083,1833535011,423410938,660763973,2187129978,1639812e3,3508421329,3467445492,310289298,272797111,2188552562,2456863912,310240523,677093832,1013118031,901835429,3892695601,1116285435,3036471170,1337354835,243122523,520626091,277223598,4244441197,4194248841,1766575121,594173102,316590669,742362309,3536858622,4176435350,3838792410,2501204839,1229605004,3115755532,1552908988,2312334149,979407927,3959474601,1148277331,176638793,3614686272,2083809052,40992502,1340822838,2731552767,3535757508,3560899520,1354035053,122129617,7215240,2732932949,3118912700,2718203926,2539075635,3609230695,3725561661,1928887091,2882293555,1988674909,2063640240,2491088897,1459647954,4189817080,2302804382,1113892351,2237858528,1927010603,4002880361,1856122846,1594404395,2944033133,3855189863,3474975698,1643104450,4054590833,3431086530,1730235576,2984608721,3084664418,2131803598,4178205752,267404349,1617849798,1616132681,1462223176,736725533,2327058232,551665188,2945899023,1749386277,2575514597,1611482493,674206544,2201269090,3642560800,728599968,1680547377,2620414464,1388111496,453204106,4156223445,1094905244,2754698257,2201108165,3757000246,2704524545,3922940700,3996465027],s[3]=[2645754912,532081118,2814278639,3530793624,1246723035,1689095255,2236679235,4194438865,2116582143,3859789411,157234593,2045505824,4245003587,1687664561,4083425123,605965023,672431967,1336064205,3376611392,214114848,4258466608,3232053071,489488601,605322005,3998028058,264917351,1912574028,756637694,436560991,202637054,135989450,85393697,2152923392,3896401662,2895836408,2145855233,3535335007,115294817,3147733898,1922296357,3464822751,4117858305,1037454084,2725193275,2127856640,1417604070,1148013728,1827919605,642362335,2929772533,909348033,1346338451,3547799649,297154785,1917849091,4161712827,2883604526,3968694238,1469521537,3780077382,3375584256,1763717519,136166297,4290970789,1295325189,2134727907,2798151366,1566297257,3672928234,2677174161,2672173615,965822077,2780786062,289653839,1133871874,3491843819,35685304,1068898316,418943774,672553190,642281022,2346158704,1954014401,3037126780,4079815205,2030668546,3840588673,672283427,1776201016,359975446,3750173538,555499703,2769985273,1324923,69110472,152125443,3176785106,3822147285,1340634837,798073664,1434183902,15393959,216384236,1303690150,3881221631,3711134124,3960975413,106373927,2578434224,1455997841,1801814300,1578393881,1854262133,3188178946,3258078583,2302670060,1539295533,3505142565,3078625975,2372746020,549938159,3278284284,2620926080,181285381,2865321098,3970029511,68876850,488006234,1728155692,2608167508,836007927,2435231793,919367643,3339422534,3655756360,1457871481,40520939,1380155135,797931188,234455205,2255801827,3990488299,397000196,739833055,3077865373,2871719860,4022553888,772369276,390177364,3853951029,557662966,740064294,1640166671,1699928825,3535942136,622006121,3625353122,68743880,1742502,219489963,1664179233,1577743084,1236991741,410585305,2366487942,823226535,1050371084,3426619607,3586839478,212779912,4147118561,1819446015,1911218849,530248558,3486241071,3252585495,2886188651,3410272728,2342195030,20547779,2982490058,3032363469,3631753222,312714466,1870521650,1493008054,3491686656,615382978,4103671749,2534517445,1932181,2196105170,278426614,6369430,3274544417,2913018367,697336853,2143000447,2946413531,701099306,1558357093,2805003052,3500818408,2321334417,3567135975,216290473,3591032198,23009561,1996984579,3735042806,2024298078,3739440863,569400510,2339758983,3016033873,3097871343,3639523026,3844324983,3256173865,795471839,2951117563,4101031090,4091603803,3603732598,971261452,534414648,428311343,3389027175,2844869880,694888862,1227866773,2456207019,3043454569,2614353370,3749578031,3676663836,459166190,4132644070,1794958188,51825668,2252611902,3084671440,2036672799,3436641603,1099053433,2469121526,3059204941,1323291266,2061838604,1018778475,2233344254,2553501054,334295216,3556750194,1065731521,183467730],s[4]=[2127105028,745436345,2601412319,2788391185,3093987327,500390133,1155374404,389092991,150729210,3891597772,3523549952,1935325696,716645080,946045387,2901812282,1774124410,3869435775,4039581901,3293136918,3438657920,948246080,363898952,3867875531,1286266623,1598556673,68334250,630723836,1104211938,1312863373,613332731,2377784574,1101634306,441780740,3129959883,1917973735,2510624549,3238456535,2544211978,3308894634,1299840618,4076074851,1756332096,3977027158,297047435,3790297736,2265573040,3621810518,1311375015,1667687725,47300608,3299642885,2474112369,201668394,1468347890,576830978,3594690761,3742605952,1958042578,1747032512,3558991340,1408974056,3366841779,682131401,1033214337,1545599232,4265137049,206503691,103024618,2855227313,1337551222,2428998917,2963842932,4015366655,3852247746,2796956967,3865723491,3747938335,247794022,3755824572,702416469,2434691994,397379957,851939612,2314769512,218229120,1380406772,62274761,214451378,3170103466,2276210409,3845813286,28563499,446592073,1693330814,3453727194,29968656,3093872512,220656637,2470637031,77972100,1667708854,1358280214,4064765667,2395616961,325977563,4277240721,4220025399,3605526484,3355147721,811859167,3069544926,3962126810,652502677,3075892249,4132761541,3498924215,1217549313,3250244479,3858715919,3053989961,1538642152,2279026266,2875879137,574252750,3324769229,2651358713,1758150215,141295887,2719868960,3515574750,4093007735,4194485238,1082055363,3417560400,395511885,2966884026,179534037,3646028556,3738688086,1092926436,2496269142,257381841,3772900718,1636087230,1477059743,2499234752,3811018894,2675660129,3285975680,90732309,1684827095,1150307763,1723134115,3237045386,1769919919,1240018934,815675215,750138730,2239792499,1234303040,1995484674,138143821,675421338,1145607174,1936608440,3238603024,2345230278,2105974004,323969391,779555213,3004902369,2861610098,1017501463,2098600890,2628620304,2940611490,2682542546,1171473753,3656571411,3687208071,4091869518,393037935,159126506,1662887367,1147106178,391545844,3452332695,1891500680,3016609650,1851642611,546529401,1167818917,3194020571,2848076033,3953471836,575554290,475796850,4134673196,450035699,2351251534,844027695,1080539133,86184846,1554234488,3692025454,1972511363,2018339607,1491841390,1141460869,1061690759,4244549243,2008416118,2351104703,2868147542,1598468138,722020353,1027143159,212344630,1387219594,1725294528,3745187956,2500153616,458938280,4129215917,1828119673,544571780,3503225445,2297937496,1241802790,267843827,2694610800,1397140384,1558801448,3782667683,1806446719,929573330,2234912681,400817706,616011623,4121520928,3603768725,1761550015,1968522284,4053731006,4192232858,4005120285,872482584,3140537016,3894607381,2287405443,1963876937,3663887957,1584857e3,2975024454,1833426440,4025083860],s[5]=[4143615901,749497569,1285769319,3795025788,2514159847,23610292,3974978748,844452780,3214870880,3751928557,2213566365,1676510905,448177848,3730751033,4086298418,2307502392,871450977,3222878141,4110862042,3831651966,2735270553,1310974780,2043402188,1218528103,2736035353,4274605013,2702448458,3936360550,2693061421,162023535,2827510090,687910808,23484817,3784910947,3371371616,779677500,3503626546,3473927188,4157212626,3500679282,4248902014,2466621104,3899384794,1958663117,925738300,1283408968,3669349440,1840910019,137959847,2679828185,1239142320,1315376211,1547541505,1690155329,739140458,3128809933,3933172616,3876308834,905091803,1548541325,4040461708,3095483362,144808038,451078856,676114313,2861728291,2469707347,993665471,373509091,2599041286,4025009006,4170239449,2149739950,3275793571,3749616649,2794760199,1534877388,572371878,2590613551,1753320020,3467782511,1405125690,4270405205,633333386,3026356924,3475123903,632057672,2846462855,1404951397,3882875879,3915906424,195638627,2385783745,3902872553,1233155085,3355999740,2380578713,2702246304,2144565621,3663341248,3894384975,2502479241,4248018925,3094885567,1594115437,572884632,3385116731,767645374,1331858858,1475698373,3793881790,3532746431,1321687957,619889600,1121017241,3440213920,2070816767,2833025776,1933951238,4095615791,890643334,3874130214,859025556,360630002,925594799,1764062180,3920222280,4078305929,979562269,2810700344,4087740022,1949714515,546639971,1165388173,3069891591,1495988560,922170659,1291546247,2107952832,1813327274,3406010024,3306028637,4241950635,153207855,2313154747,1608695416,1150242611,1967526857,721801357,1220138373,3691287617,3356069787,2112743302,3281662835,1111556101,1778980689,250857638,2298507990,673216130,2846488510,3207751581,3562756981,3008625920,3417367384,2198807050,529510932,3547516680,3426503187,2364944742,102533054,2294910856,1617093527,1204784762,3066581635,1019391227,1069574518,1317995090,1691889997,3661132003,510022745,3238594800,1362108837,1817929911,2184153760,805817662,1953603311,3699844737,120799444,2118332377,207536705,2282301548,4120041617,145305846,2508124933,3086745533,3261524335,1877257368,2977164480,3160454186,2503252186,4221677074,759945014,254147243,2767453419,3801518371,629083197,2471014217,907280572,3900796746,940896768,2751021123,2625262786,3161476951,3661752313,3260732218,1425318020,2977912069,1496677566,3988592072,2140652971,3126511541,3069632175,977771578,1392695845,1698528874,1411812681,1369733098,1343739227,3620887944,1142123638,67414216,3102056737,3088749194,1626167401,2546293654,3941374235,697522451,33404913,143560186,2595682037,994885535,1247667115,3859094837,2699155541,3547024625,4114935275,2968073508,3199963069,2732024527,1237921620,951448369,1898488916,1211705605,2790989240,2233243581,3598044975],s[6]=[2246066201,858518887,1714274303,3485882003,713916271,2879113490,3730835617,539548191,36158695,1298409750,419087104,1358007170,749914897,2989680476,1261868530,2995193822,2690628854,3443622377,3780124940,3796824509,2976433025,4259637129,1551479e3,512490819,1296650241,951993153,2436689437,2460458047,144139966,3136204276,310820559,3068840729,643875328,1969602020,1680088954,2185813161,3283332454,672358534,198762408,896343282,276269502,3014846926,84060815,197145886,376173866,3943890818,3813173521,3545068822,1316698879,1598252827,2633424951,1233235075,859989710,2358460855,3503838400,3409603720,1203513385,1193654839,2792018475,2060853022,207403770,1144516871,3068631394,1121114134,177607304,3785736302,326409831,1929119770,2983279095,4183308101,3474579288,3200513878,3228482096,119610148,1170376745,3378393471,3163473169,951863017,3337026068,3135789130,2907618374,1183797387,2015970143,4045674555,2182986399,2952138740,3928772205,384012900,2454997643,10178499,2879818989,2596892536,111523738,2995089006,451689641,3196290696,235406569,1441906262,3890558523,3013735005,4158569349,1644036924,376726067,1006849064,3664579700,2041234796,1021632941,1374734338,2566452058,371631263,4007144233,490221539,206551450,3140638584,1053219195,1853335209,3412429660,3562156231,735133835,1623211703,3104214392,2738312436,4096837757,3366392578,3110964274,3956598718,3196820781,2038037254,3877786376,2339753847,300912036,3766732888,2372630639,1516443558,4200396704,1574567987,4069441456,4122592016,2699739776,146372218,2748961456,2043888151,35287437,2596680554,655490400,1132482787,110692520,1031794116,2188192751,1324057718,1217253157,919197030,686247489,3261139658,1028237775,3135486431,3059715558,2460921700,986174950,2661811465,4062904701,2752986992,3709736643,367056889,1353824391,731860949,1650113154,1778481506,784341916,357075625,3608602432,1074092588,2480052770,3811426202,92751289,877911070,3600361838,1231880047,480201094,3756190983,3094495953,434011822,87971354,363687820,1717726236,1901380172,3926403882,2481662265,400339184,1490350766,2661455099,1389319756,2558787174,784598401,1983468483,30828846,3550527752,2716276238,3841122214,1765724805,1955612312,1277890269,1333098070,1564029816,2704417615,1026694237,3287671188,1260819201,3349086767,1016692350,1582273796,1073413053,1995943182,694588404,1025494639,3323872702,3551898420,4146854327,453260480,1316140391,1435673405,3038941953,3486689407,1622062951,403978347,817677117,950059133,4246079218,3278066075,1486738320,1417279718,481875527,2549965225,3933690356,760697757,1452955855,3897451437,1177426808,1702951038,4085348628,2447005172,1084371187,3516436277,3068336338,1073369276,1027665953,3284188590,1230553676,1368340146,2226246512,267243139,2274220762,4070734279,2497715176,2423353163,2504755875],s[7]=[3793104909,3151888380,2817252029,895778965,2005530807,3871412763,237245952,86829237,296341424,3851759377,3974600970,2475086196,709006108,1994621201,2972577594,937287164,3734691505,168608556,3189338153,2225080640,3139713551,3033610191,3025041904,77524477,185966941,1208824168,2344345178,1721625922,3354191921,1066374631,1927223579,1971335949,2483503697,1551748602,2881383779,2856329572,3003241482,48746954,1398218158,2050065058,313056748,4255789917,393167848,1912293076,940740642,3465845460,3091687853,2522601570,2197016661,1727764327,364383054,492521376,1291706479,3264136376,1474851438,1685747964,2575719748,1619776915,1814040067,970743798,1561002147,2925768690,2123093554,1880132620,3151188041,697884420,2550985770,2607674513,2659114323,110200136,1489731079,997519150,1378877361,3527870668,478029773,2766872923,1022481122,431258168,1112503832,897933369,2635587303,669726182,3383752315,918222264,163866573,3246985393,3776823163,114105080,1903216136,761148244,3571337562,1690750982,3166750252,1037045171,1888456500,2010454850,642736655,616092351,365016990,1185228132,4174898510,1043824992,2023083429,2241598885,3863320456,3279669087,3674716684,108438443,2132974366,830746235,606445527,4173263986,2204105912,1844756978,2532684181,4245352700,2969441100,3796921661,1335562986,4061524517,2720232303,2679424040,634407289,885462008,3294724487,3933892248,2094100220,339117932,4048830727,3202280980,1458155303,2689246273,1022871705,2464987878,3714515309,353796843,2822958815,4256850100,4052777845,551748367,618185374,3778635579,4020649912,1904685140,3069366075,2670879810,3407193292,2954511620,4058283405,2219449317,3135758300,1120655984,3447565834,1474845562,3577699062,550456716,3466908712,2043752612,881257467,869518812,2005220179,938474677,3305539448,3850417126,1315485940,3318264702,226533026,965733244,321539988,1136104718,804158748,573969341,3708209826,937399083,3290727049,2901666755,1461057207,4013193437,4066861423,3242773476,2421326174,1581322155,3028952165,786071460,3900391652,3918438532,1485433313,4023619836,3708277595,3678951060,953673138,1467089153,1930354364,1533292819,2492563023,1346121658,1685000834,1965281866,3765933717,4190206607,2052792609,3515332758,690371149,3125873887,2180283551,2903598061,3933952357,436236910,289419410,14314871,1242357089,2904507907,1616633776,2666382180,585885352,3471299210,2699507360,1432659641,277164553,3354103607,770115018,2303809295,3741942315,3177781868,2853364978,2269453327,3774259834,987383833,1290892879,225909803,1741533526,890078084,1496906255,1111072499,916028167,243534141,1252605537,2204162171,531204876,290011180,3916834213,102027703,237315147,209093447,1486785922,220223953,2758195998,4175039106,82940208,3127791296,2569425252,518464269,1353887104,3941492737,2377294467,3935040926]}function oy(e){this.cast5=new ay,this.cast5.setKey(e),this.encrypt=function(e){return this.cast5.encrypt(e)}}sy.keySize=sy.prototype.keySize=24,sy.blockSize=sy.prototype.blockSize=8,oy.blockSize=oy.prototype.blockSize=8,oy.keySize=oy.prototype.keySize=16;const cy=4294967295;function hy(e,t){return(e<>>32-t)&cy}function uy(e,t){return e[t]|e[t+1]<<8|e[t+2]<<16|e[t+3]<<24}function ly(e,t,r){e.splice(t,4,255&r,r>>>8&255,r>>>16&255,r>>>24&255)}function yy(e,t){return e>>>8*t&255}function fy(e){this.tf=function(){let e=null,t=null,r=-1,n=[],i=[[],[],[],[]];function s(e){return i[0][yy(e,0)]^i[1][yy(e,1)]^i[2][yy(e,2)]^i[3][yy(e,3)]}function a(e){return i[0][yy(e,3)]^i[1][yy(e,0)]^i[2][yy(e,1)]^i[3][yy(e,2)]}function o(e,t){let r=s(t[0]),i=a(t[1]);t[2]=hy(t[2]^r+i+n[4*e+8]&cy,31),t[3]=hy(t[3],1)^r+2*i+n[4*e+9]&cy,r=s(t[2]),i=a(t[3]),t[0]=hy(t[0]^r+i+n[4*e+10]&cy,31),t[1]=hy(t[1],1)^r+2*i+n[4*e+11]&cy}function c(e,t){let r=s(t[0]),i=a(t[1]);t[2]=hy(t[2],1)^r+i+n[4*e+10]&cy,t[3]=hy(t[3]^r+2*i+n[4*e+11]&cy,31),r=s(t[2]),i=a(t[3]),t[0]=hy(t[0],1)^r+i+n[4*e+8]&cy,t[1]=hy(t[1]^r+2*i+n[4*e+9]&cy,31)}return{name:"twofish",blocksize:16,open:function(t){let r,s,a,o,c;e=t;const h=[],u=[],l=[];let y;const f=[];let g,p,d;const A=[[8,1,7,13,6,15,3,2,0,11,5,9,14,12,10,4],[2,8,11,13,15,7,6,14,3,1,9,4,0,10,12,5]],w=[[14,12,11,8,1,2,3,5,15,4,10,6,7,0,9,13],[1,14,2,11,4,12,3,7,6,13,10,5,15,9,0,8]],m=[[11,10,5,14,6,13,9,0,12,8,15,3,2,4,7,1],[4,12,7,5,1,6,9,10,0,14,13,8,2,11,3,15]],b=[[13,7,15,4,1,2,6,14,9,11,3,0,8,5,12,10],[11,9,5,1,12,3,13,14,6,4,7,15,2,0,8,10]],k=[0,8,1,9,2,10,3,11,4,12,5,13,6,14,7,15],E=[0,9,2,11,4,13,6,15,8,1,10,3,12,5,14,7],v=[[],[]],B=[[],[],[],[]];function I(e){return e^e>>2^[0,90,180,238][3&e]}function S(e){return e^e>>1^e>>2^[0,238,180,90][3&e]}function K(e,t){let r,n,i;for(r=0;r<8;r++)n=t>>>24,t=t<<8&cy|e>>>24,e=e<<8&cy,i=n<<1,128&n&&(i^=333),t^=n^i<<16,i^=n>>>1,1&n&&(i^=166),t^=i<<24|i<<8;return t}function C(e,t){const r=t>>4,n=15&t,i=A[e][r^n],s=w[e][k[n]^E[r]];return b[e][k[s]^E[i]]<<4|m[e][i^s]}function P(e,t){let r=yy(e,0),n=yy(e,1),i=yy(e,2),s=yy(e,3);switch(y){case 4:r=v[1][r]^yy(t[3],0),n=v[0][n]^yy(t[3],1),i=v[0][i]^yy(t[3],2),s=v[1][s]^yy(t[3],3);case 3:r=v[1][r]^yy(t[2],0),n=v[1][n]^yy(t[2],1),i=v[0][i]^yy(t[2],2),s=v[0][s]^yy(t[2],3);case 2:r=v[0][v[0][r]^yy(t[1],0)]^yy(t[0],0),n=v[0][v[1][n]^yy(t[1],1)]^yy(t[0],1),i=v[1][v[0][i]^yy(t[1],2)]^yy(t[0],2),s=v[1][v[1][s]^yy(t[1],3)]^yy(t[0],3)}return B[0][r]^B[1][n]^B[2][i]^B[3][s]}for(e=e.slice(0,32),r=e.length;16!==r&&24!==r&&32!==r;)e[r++]=0;for(r=0;r>2]=uy(e,r);for(r=0;r<256;r++)v[0][r]=C(0,r),v[1][r]=C(1,r);for(r=0;r<256;r++)g=v[1][r],p=I(g),d=S(g),B[0][r]=g+(p<<8)+(d<<16)+(d<<24),B[2][r]=p+(d<<8)+(g<<16)+(d<<24),g=v[0][r],p=I(g),d=S(g),B[1][r]=d+(d<<8)+(p<<16)+(g<<24),B[3][r]=p+(g<<8)+(d<<16)+(p<<24);for(y=l.length/2,r=0;r=0;e--)c(e,s);ly(t,r,s[2]^n[0]),ly(t,r+4,s[3]^n[1]),ly(t,r+8,s[0]^n[2]),ly(t,r+12,s[1]^n[3]),r+=16},finalize:function(){return t}}}(),this.tf.open(Array.from(e),0),this.encrypt=function(e){return this.tf.encrypt(Array.from(e),0)}}function gy(){}function py(e){this.bf=new gy,this.bf.init(e),this.encrypt=function(e){return this.bf.encryptBlock(e)}}fy.keySize=fy.prototype.keySize=32,fy.blockSize=fy.prototype.blockSize=16,gy.prototype.BLOCKSIZE=8,gy.prototype.SBOXES=[[3509652390,2564797868,805139163,3491422135,3101798381,1780907670,3128725573,4046225305,614570311,3012652279,134345442,2240740374,1667834072,1901547113,2757295779,4103290238,227898511,1921955416,1904987480,2182433518,2069144605,3260701109,2620446009,720527379,3318853667,677414384,3393288472,3101374703,2390351024,1614419982,1822297739,2954791486,3608508353,3174124327,2024746970,1432378464,3864339955,2857741204,1464375394,1676153920,1439316330,715854006,3033291828,289532110,2706671279,2087905683,3018724369,1668267050,732546397,1947742710,3462151702,2609353502,2950085171,1814351708,2050118529,680887927,999245976,1800124847,3300911131,1713906067,1641548236,4213287313,1216130144,1575780402,4018429277,3917837745,3693486850,3949271944,596196993,3549867205,258830323,2213823033,772490370,2760122372,1774776394,2652871518,566650946,4142492826,1728879713,2882767088,1783734482,3629395816,2517608232,2874225571,1861159788,326777828,3124490320,2130389656,2716951837,967770486,1724537150,2185432712,2364442137,1164943284,2105845187,998989502,3765401048,2244026483,1075463327,1455516326,1322494562,910128902,469688178,1117454909,936433444,3490320968,3675253459,1240580251,122909385,2157517691,634681816,4142456567,3825094682,3061402683,2540495037,79693498,3249098678,1084186820,1583128258,426386531,1761308591,1047286709,322548459,995290223,1845252383,2603652396,3431023940,2942221577,3202600964,3727903485,1712269319,422464435,3234572375,1170764815,3523960633,3117677531,1434042557,442511882,3600875718,1076654713,1738483198,4213154764,2393238008,3677496056,1014306527,4251020053,793779912,2902807211,842905082,4246964064,1395751752,1040244610,2656851899,3396308128,445077038,3742853595,3577915638,679411651,2892444358,2354009459,1767581616,3150600392,3791627101,3102740896,284835224,4246832056,1258075500,768725851,2589189241,3069724005,3532540348,1274779536,3789419226,2764799539,1660621633,3471099624,4011903706,913787905,3497959166,737222580,2514213453,2928710040,3937242737,1804850592,3499020752,2949064160,2386320175,2390070455,2415321851,4061277028,2290661394,2416832540,1336762016,1754252060,3520065937,3014181293,791618072,3188594551,3933548030,2332172193,3852520463,3043980520,413987798,3465142937,3030929376,4245938359,2093235073,3534596313,375366246,2157278981,2479649556,555357303,3870105701,2008414854,3344188149,4221384143,3956125452,2067696032,3594591187,2921233993,2428461,544322398,577241275,1471733935,610547355,4027169054,1432588573,1507829418,2025931657,3646575487,545086370,48609733,2200306550,1653985193,298326376,1316178497,3007786442,2064951626,458293330,2589141269,3591329599,3164325604,727753846,2179363840,146436021,1461446943,4069977195,705550613,3059967265,3887724982,4281599278,3313849956,1404054877,2845806497,146425753,1854211946],[1266315497,3048417604,3681880366,3289982499,290971e4,1235738493,2632868024,2414719590,3970600049,1771706367,1449415276,3266420449,422970021,1963543593,2690192192,3826793022,1062508698,1531092325,1804592342,2583117782,2714934279,4024971509,1294809318,4028980673,1289560198,2221992742,1669523910,35572830,157838143,1052438473,1016535060,1802137761,1753167236,1386275462,3080475397,2857371447,1040679964,2145300060,2390574316,1461121720,2956646967,4031777805,4028374788,33600511,2920084762,1018524850,629373528,3691585981,3515945977,2091462646,2486323059,586499841,988145025,935516892,3367335476,2599673255,2839830854,265290510,3972581182,2759138881,3795373465,1005194799,847297441,406762289,1314163512,1332590856,1866599683,4127851711,750260880,613907577,1450815602,3165620655,3734664991,3650291728,3012275730,3704569646,1427272223,778793252,1343938022,2676280711,2052605720,1946737175,3164576444,3914038668,3967478842,3682934266,1661551462,3294938066,4011595847,840292616,3712170807,616741398,312560963,711312465,1351876610,322626781,1910503582,271666773,2175563734,1594956187,70604529,3617834859,1007753275,1495573769,4069517037,2549218298,2663038764,504708206,2263041392,3941167025,2249088522,1514023603,1998579484,1312622330,694541497,2582060303,2151582166,1382467621,776784248,2618340202,3323268794,2497899128,2784771155,503983604,4076293799,907881277,423175695,432175456,1378068232,4145222326,3954048622,3938656102,3820766613,2793130115,2977904593,26017576,3274890735,3194772133,1700274565,1756076034,4006520079,3677328699,720338349,1533947780,354530856,688349552,3973924725,1637815568,332179504,3949051286,53804574,2852348879,3044236432,1282449977,3583942155,3416972820,4006381244,1617046695,2628476075,3002303598,1686838959,431878346,2686675385,1700445008,1080580658,1009431731,832498133,3223435511,2605976345,2271191193,2516031870,1648197032,4164389018,2548247927,300782431,375919233,238389289,3353747414,2531188641,2019080857,1475708069,455242339,2609103871,448939670,3451063019,1395535956,2413381860,1841049896,1491858159,885456874,4264095073,4001119347,1565136089,3898914787,1108368660,540939232,1173283510,2745871338,3681308437,4207628240,3343053890,4016749493,1699691293,1103962373,3625875870,2256883143,3830138730,1031889488,3479347698,1535977030,4236805024,3251091107,2132092099,1774941330,1199868427,1452454533,157007616,2904115357,342012276,595725824,1480756522,206960106,497939518,591360097,863170706,2375253569,3596610801,1814182875,2094937945,3421402208,1082520231,3463918190,2785509508,435703966,3908032597,1641649973,2842273706,3305899714,1510255612,2148256476,2655287854,3276092548,4258621189,236887753,3681803219,274041037,1734335097,3815195456,3317970021,1899903192,1026095262,4050517792,356393447,2410691914,3873677099,3682840055],[3913112168,2491498743,4132185628,2489919796,1091903735,1979897079,3170134830,3567386728,3557303409,857797738,1136121015,1342202287,507115054,2535736646,337727348,3213592640,1301675037,2528481711,1895095763,1721773893,3216771564,62756741,2142006736,835421444,2531993523,1442658625,3659876326,2882144922,676362277,1392781812,170690266,3921047035,1759253602,3611846912,1745797284,664899054,1329594018,3901205900,3045908486,2062866102,2865634940,3543621612,3464012697,1080764994,553557557,3656615353,3996768171,991055499,499776247,1265440854,648242737,3940784050,980351604,3713745714,1749149687,3396870395,4211799374,3640570775,1161844396,3125318951,1431517754,545492359,4268468663,3499529547,1437099964,2702547544,3433638243,2581715763,2787789398,1060185593,1593081372,2418618748,4260947970,69676912,2159744348,86519011,2512459080,3838209314,1220612927,3339683548,133810670,1090789135,1078426020,1569222167,845107691,3583754449,4072456591,1091646820,628848692,1613405280,3757631651,526609435,236106946,48312990,2942717905,3402727701,1797494240,859738849,992217954,4005476642,2243076622,3870952857,3732016268,765654824,3490871365,2511836413,1685915746,3888969200,1414112111,2273134842,3281911079,4080962846,172450625,2569994100,980381355,4109958455,2819808352,2716589560,2568741196,3681446669,3329971472,1835478071,660984891,3704678404,4045999559,3422617507,3040415634,1762651403,1719377915,3470491036,2693910283,3642056355,3138596744,1364962596,2073328063,1983633131,926494387,3423689081,2150032023,4096667949,1749200295,3328846651,309677260,2016342300,1779581495,3079819751,111262694,1274766160,443224088,298511866,1025883608,3806446537,1145181785,168956806,3641502830,3584813610,1689216846,3666258015,3200248200,1692713982,2646376535,4042768518,1618508792,1610833997,3523052358,4130873264,2001055236,3610705100,2202168115,4028541809,2961195399,1006657119,2006996926,3186142756,1430667929,3210227297,1314452623,4074634658,4101304120,2273951170,1399257539,3367210612,3027628629,1190975929,2062231137,2333990788,2221543033,2438960610,1181637006,548689776,2362791313,3372408396,3104550113,3145860560,296247880,1970579870,3078560182,3769228297,1714227617,3291629107,3898220290,166772364,1251581989,493813264,448347421,195405023,2709975567,677966185,3703036547,1463355134,2715995803,1338867538,1343315457,2802222074,2684532164,233230375,2599980071,2000651841,3277868038,1638401717,4028070440,3237316320,6314154,819756386,300326615,590932579,1405279636,3267499572,3150704214,2428286686,3959192993,3461946742,1862657033,1266418056,963775037,2089974820,2263052895,1917689273,448879540,3550394620,3981727096,150775221,3627908307,1303187396,508620638,2975983352,2726630617,1817252668,1876281319,1457606340,908771278,3720792119,3617206836,2455994898,1729034894,1080033504],[976866871,3556439503,2881648439,1522871579,1555064734,1336096578,3548522304,2579274686,3574697629,3205460757,3593280638,3338716283,3079412587,564236357,2993598910,1781952180,1464380207,3163844217,3332601554,1699332808,1393555694,1183702653,3581086237,1288719814,691649499,2847557200,2895455976,3193889540,2717570544,1781354906,1676643554,2592534050,3230253752,1126444790,2770207658,2633158820,2210423226,2615765581,2414155088,3127139286,673620729,2805611233,1269405062,4015350505,3341807571,4149409754,1057255273,2012875353,2162469141,2276492801,2601117357,993977747,3918593370,2654263191,753973209,36408145,2530585658,25011837,3520020182,2088578344,530523599,2918365339,1524020338,1518925132,3760827505,3759777254,1202760957,3985898139,3906192525,674977740,4174734889,2031300136,2019492241,3983892565,4153806404,3822280332,352677332,2297720250,60907813,90501309,3286998549,1016092578,2535922412,2839152426,457141659,509813237,4120667899,652014361,1966332200,2975202805,55981186,2327461051,676427537,3255491064,2882294119,3433927263,1307055953,942726286,933058658,2468411793,3933900994,4215176142,1361170020,2001714738,2830558078,3274259782,1222529897,1679025792,2729314320,3714953764,1770335741,151462246,3013232138,1682292957,1483529935,471910574,1539241949,458788160,3436315007,1807016891,3718408830,978976581,1043663428,3165965781,1927990952,4200891579,2372276910,3208408903,3533431907,1412390302,2931980059,4132332400,1947078029,3881505623,4168226417,2941484381,1077988104,1320477388,886195818,18198404,3786409e3,2509781533,112762804,3463356488,1866414978,891333506,18488651,661792760,1628790961,3885187036,3141171499,876946877,2693282273,1372485963,791857591,2686433993,3759982718,3167212022,3472953795,2716379847,445679433,3561995674,3504004811,3574258232,54117162,3331405415,2381918588,3769707343,4154350007,1140177722,4074052095,668550556,3214352940,367459370,261225585,2610173221,4209349473,3468074219,3265815641,314222801,3066103646,3808782860,282218597,3406013506,3773591054,379116347,1285071038,846784868,2669647154,3771962079,3550491691,2305946142,453669953,1268987020,3317592352,3279303384,3744833421,2610507566,3859509063,266596637,3847019092,517658769,3462560207,3443424879,370717030,4247526661,2224018117,4143653529,4112773975,2788324899,2477274417,1456262402,2901442914,1517677493,1846949527,2295493580,3734397586,2176403920,1280348187,1908823572,3871786941,846861322,1172426758,3287448474,3383383037,1655181056,3139813346,901632758,1897031941,2986607138,3066810236,3447102507,1393639104,373351379,950779232,625454576,3124240540,4148612726,2007998917,544563296,2244738638,2330496472,2058025392,1291430526,424198748,50039436,29584100,3605783033,2429876329,2791104160,1057563949,3255363231,3075367218,3463963227,1469046755,985887462]],gy.prototype.PARRAY=[608135816,2242054355,320440878,57701188,2752067618,698298832,137296536,3964562569,1160258022,953160567,3193202383,887688300,3232508343,3380367581,1065670069,3041331479,2450970073,2306472731],gy.prototype.NN=16,gy.prototype._clean=function(e){if(e<0){e=(2147483647&e)+2147483648}return e},gy.prototype._F=function(e){let t;const r=255&e,n=255&(e>>>=8),i=255&(e>>>=8),s=255&(e>>>=8);return t=this.sboxes[0][s]+this.sboxes[1][i],t^=this.sboxes[2][n],t+=this.sboxes[3][r],t},gy.prototype._encryptBlock=function(e){let t,r=e[0],n=e[1];for(t=0;t>>24-8*t&255,i[t+n]=r[1]>>>24-8*t&255;return i},gy.prototype._decryptBlock=function(e){let t,r=e[0],n=e[1];for(t=this.NN+1;t>1;--t){r^=this.parray[t],n=this._F(r)^n;const e=r;r=n,n=e}r^=this.parray[1],n^=this.parray[0],e[0]=this._clean(n),e[1]=this._clean(r)},gy.prototype.init=function(e){let t,r=0;for(this.parray=[],t=0;t=e.length&&(r=0);this.parray[t]=this.PARRAY[t]^n}for(this.sboxes=[],t=0;t<4;++t)for(this.sboxes[t]=[],r=0;r<256;++r)this.sboxes[t][r]=this.SBOXES[t][r];const n=[0,0];for(t=0;tnew by)),Ey=/* @__PURE__ */new Uint8Array([7,4,13,1,10,6,15,3,12,0,9,5,2,14,11,8]),vy=/* @__PURE__ */new Uint8Array(Array(16).fill(0).map(((e,t)=>t))),By=/* @__PURE__ */vy.map((e=>(9*e+5)%16));let Iy=[vy],Sy=[By];for(let e=0;e<4;e++)for(let t of[Iy,Sy])t.push(t[e].map((e=>Ey[e])));const Ky=/* @__PURE__ */[[11,14,15,12,5,8,7,9,11,13,14,15,6,7,9,8],[12,13,11,15,6,9,9,7,12,15,11,13,7,8,7,7],[13,15,14,11,7,7,6,8,13,14,13,12,5,5,6,9],[14,11,12,14,8,6,5,5,15,12,15,14,9,9,8,6],[15,12,13,13,9,5,8,6,14,11,12,11,8,6,5,5]].map((e=>new Uint8Array(e))),Cy=/* @__PURE__ */Iy.map(((e,t)=>e.map((e=>Ky[t][e])))),Py=/* @__PURE__ */Sy.map(((e,t)=>e.map((e=>Ky[t][e])))),Uy=/* @__PURE__ */new Uint32Array([0,1518500249,1859775393,2400959708,2840853838]),Dy=/* @__PURE__ */new Uint32Array([1352829926,1548603684,1836072691,2053994217,0]);function xy(e,t,r,n){return 0===e?t^r^n:1===e?t&r|~t&n:2===e?(t|~r)^n:3===e?t&n|r&~n:t^(r|~n)}const Qy=/* @__PURE__ */new Uint32Array(16);class Ry extends oh{constructor(){super(64,20,8,!0),this.h0=1732584193,this.h1=-271733879,this.h2=-1732584194,this.h3=271733878,this.h4=-1009589776}get(){const{h0:e,h1:t,h2:r,h3:n,h4:i}=this;return[e,t,r,n,i]}set(e,t,r,n,i){this.h0=0|e,this.h1=0|t,this.h2=0|r,this.h3=0|n,this.h4=0|i}process(e,t){for(let r=0;r<16;r++,t+=4)Qy[r]=e.getUint32(t,!0);let r=0|this.h0,n=r,i=0|this.h1,s=i,a=0|this.h2,o=a,c=0|this.h3,h=c,u=0|this.h4,l=u;for(let e=0;e<5;e++){const t=4-e,y=Uy[e],f=Dy[e],g=Iy[e],p=Sy[e],d=Cy[e],A=Py[e];for(let t=0;t<16;t++){const n=Yc(r+xy(e,i,a,c)+Qy[g[t]]+y,d[t])+u|0;r=u,u=c,c=0|Yc(a,10),a=i,i=n}for(let e=0;e<16;e++){const r=Yc(n+xy(t,s,o,h)+Qy[p[e]]+f,A[e])+l|0;n=l,l=h,h=0|Yc(o,10),o=s,s=r}}this.set(this.h1+a+h|0,this.h2+c+l|0,this.h3+u+n|0,this.h4+r+s|0,this.h0+i+o|0)}roundClean(){Qy.fill(0)}destroy(){this.destroyed=!0,this.buffer.fill(0),this.set(0,0,0,0,0)}}const Ly=new Map(Object.entries({sha1:ky,sha224:gh,sha256:fh,sha384:Vu,sha512:qu,sha3_256:gl,sha3_512:pl,ripemd160:/* @__PURE__ */nh((()=>new Ry))}));var My=/*#__PURE__*/Object.freeze({__proto__:null,nobleHashes:Ly});function Ty(e,t,r,n){e[t]+=r[n],e[t+1]+=r[n+1]+(e[t]>>24^h<<8,e[n+1]=h>>>24^c<<8,Ty(e,r,e,n),Ty(e,r,t,o),c=e[s]^e[r],h=e[s+1]^e[r+1],e[s]=c>>>16^h<<16,e[s+1]=h>>>16^c<<16,Ty(e,i,e,s),c=e[n]^e[i],h=e[n+1]^e[i+1],e[n]=h>>>31^c<<1,e[n+1]=c>>>31^h<<1}const Oy=new Uint32Array([4089235720,1779033703,2227873595,3144134277,4271175723,1013904242,1595750129,2773480762,2917565137,1359893119,725511199,2600822924,4215389547,528734635,327033209,1541459225]),Hy=new Uint8Array([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,14,10,4,8,9,15,13,6,1,12,0,2,11,7,5,3,11,8,12,0,5,2,15,13,10,14,3,6,7,1,9,4,7,9,3,1,13,12,11,14,2,6,5,10,4,0,15,8,9,0,5,7,2,4,10,15,14,1,11,12,6,8,3,13,2,12,6,10,0,11,8,3,4,13,7,5,15,14,1,9,12,5,1,15,14,13,4,10,0,7,6,3,9,2,8,11,13,11,7,14,12,1,3,9,5,0,15,4,8,6,2,10,6,15,14,9,11,3,0,8,12,2,13,7,1,4,10,5,10,2,8,4,7,6,1,5,15,11,9,14,3,12,13,0,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,14,10,4,8,9,15,13,6,1,12,0,2,11,7,5,3].map((e=>2*e)));function zy(e,t){const r=new Uint32Array(32),n=new Uint32Array(e.b.buffer,e.b.byteOffset,32);for(let t=0;t<16;t++)r[t]=e.h[t],r[t+16]=Oy[t];r[24]^=e.t0[0],r[25]^=e.t0[1];const i=t?4294967295:0;r[28]^=i,r[29]^=i;for(let e=0;e<12;e++){const t=e<<4;Ny(r,n,0,8,16,24,Hy[t+0],Hy[t+1]),Ny(r,n,2,10,18,26,Hy[t+2],Hy[t+3]),Ny(r,n,4,12,20,28,Hy[t+4],Hy[t+5]),Ny(r,n,6,14,22,30,Hy[t+6],Hy[t+7]),Ny(r,n,0,10,20,30,Hy[t+8],Hy[t+9]),Ny(r,n,2,12,22,24,Hy[t+10],Hy[t+11]),Ny(r,n,4,14,16,26,Hy[t+12],Hy[t+13]),Ny(r,n,6,8,18,28,Hy[t+14],Hy[t+15])}for(let t=0;t<16;t++)e.h[t]^=r[t]^r[t+16]}class _y{constructor(e,t,r,n){const i=new Uint8Array(64);this.S={b:new Uint8Array(qy),h:new Uint32Array(jy/4),t0:new Uint32Array(2),c:0,outlen:e},i[0]=e,t&&(i[1]=t.length),i[2]=1,i[3]=1,r&&i.set(r,32),n&&i.set(n,48);const s=new Uint32Array(i.buffer,i.byteOffset,i.length/Uint32Array.BYTES_PER_ELEMENT);for(let e=0;e<16;e++)this.S.h[e]=Oy[e]^s[e];if(t){const e=new Uint8Array(qy);e.set(t),this.update(e)}}update(e){if(!(e instanceof Uint8Array))throw Error("Input must be Uint8Array or Buffer");let t=0;for(;t>2]>>8*(3&e);return this.S.h=null,t.buffer}}function Gy(e,t,r,n){if(e>jy)throw Error(`outlen must be at most ${jy} (given: ${e})`);return new _y(e,t,r,n)}const jy=64,qy=128,Vy=2,Wy=19,Zy=4294967295,Yy=4,Jy=4294967295,$y=8,Xy=4294967295,ef=8,tf=4294967295,rf=4294967295,nf=32,sf=1024,af=64,of=205===new Uint8Array(new Uint16Array([43981]).buffer)[0];function cf(e,t,r){return e[r+0]=t,e[r+1]=t>>8,e[r+2]=t>>16,e[r+3]=t>>24,e}function hf(e,t,r){if(t>Number.MAX_SAFE_INTEGER)throw Error("LE64: large numbers unsupported");let n=t;for(let t=r;t{if(tn)throw Error(`${e} size should be between ${r} and ${n} bytes`)};if(e!==Vy||t!==Wy)throw Error("Unsupported type or version");return u("password",n,ef,Xy),u("salt",i,$y,Jy),u("tag",r,Yy,Zy),u("memory",c,8*o,tf),s&&u("associated data",s,0,rf),a&&u("secret",a,0,nf),{type:e,version:t,tagLength:r,password:n,salt:i,ad:s,secret:a,lanes:o,memorySize:c,passes:h}}({type:Vy,version:Wy,...e}),{G:i,G2:s,xor:a,getLZ:o}=r.exports,c={},h={};h.G=i,h.G2=s,h.XOR=a;const u=4*n.lanes*Math.floor(n.memorySize/(4*n.lanes)),l=u*sf+10*pf;if(t.buffer.byteLength{r.set(e,n),n+=e.length})),r}(i));const s=t.digest();return new Uint8Array(s)}(n),m=u/n.lanes,b=Array(n.lanes).fill(null).map((()=>Array(m))),k=(e,t)=>(b[e][t]=d.subarray(e*m*1024+1024*t,e*m*1024+1024*t+sf),b[e][t]);for(let e=0;e0?b[i][c-1]:b[i][m-1],u=r?a.next().value:h;o(f.byteOffset,u.byteOffset,i,n.lanes,e,t,s,4,E);const l=f[0],y=f[1];0===e&&k(i,c),yf(g,h,b[l][y],e>0?p:b[i][c]),e>0&&lf(g,b[i][c],p,b[i][c])}}}const v=b[0][m-1];for(let e=1;eAf(e,{instance:n.instance,memory:r})}function bf(e,t,r,n){return function(e,t){var r=WebAssembly.instantiate,n=WebAssembly.compile;return t?r(e,t):n(e)}(Buffer.from(r,"base64"),n)}var kf=/*#__PURE__*/Object.freeze({__proto__:null,default:async()=>mf((e=>bf(0,0,"AGFzbQEAAAABKwdgBH9/f38AYAABf2AAAGADf39/AGAJf39/f39/f39/AX9gAX8AYAF/AX8CEwEDZW52Bm1lbW9yeQIBkAiAgAQDCgkCAwAABAEFBgEEBQFwAQICBgkBfwFBkIjAAgsHfQoDeG9yAAEBRwACAkcyAAMFZ2V0TFoABBlfX2luZGlyZWN0X2Z1bmN0aW9uX3RhYmxlAQALX2luaXRpYWxpemUAABBfX2Vycm5vX2xvY2F0aW9uAAgJc3RhY2tTYXZlAAUMc3RhY2tSZXN0b3JlAAYKc3RhY2tBbGxvYwAHCQcBAEEBCwEACs0gCQMAAQtYAQJ/A0AgACAEQQR0IgNqIAIgA2r9AAQAIAEgA2r9AAQA/VH9CwQAIAAgA0EQciIDaiACIANq/QAEACABIANq/QAEAP1R/QsEACAEQQJqIgRBwABHDQALC7ceAgt7A38DQCADIBFBBHQiD2ogASAPav0ABAAgACAPav0ABAD9USIF/QsEACACIA9qIAX9CwQAIAMgD0EQciIPaiABIA9q/QAEACAAIA9q/QAEAP1RIgX9CwQAIAIgD2ogBf0LBAAgEUECaiIRQcAARw0ACwNAIAMgEEEHdGoiAEEQaiAA/QAEcCAA/QAEMCIFIAD9AAQQIgT9zgEgBSAF/Q0AAQIDCAkKCwABAgMICQoLIAQgBP0NAAECAwgJCgsAAQIDCAkKC/3eAUEB/csB/c4BIgT9USIJQSD9ywEgCUEg/c0B/VAiCSAA/QAEUCIG/c4BIAkgCf0NAAECAwgJCgsAAQIDCAkKCyAGIAb9DQABAgMICQoLAAECAwgJCgv93gFBAf3LAf3OASIGIAX9USIFQSj9ywEgBUEY/c0B/VAiCCAE/c4BIAggCP0NAAECAwgJCgsAAQIDCAkKCyAEIAT9DQABAgMICQoLAAECAwgJCgv93gFBAf3LAf3OASIKIAogCf1RIgVBMP3LASAFQRD9zQH9UCIFIAb9zgEgBSAF/Q0AAQIDCAkKCwABAgMICQoLIAYgBv0NAAECAwgJCgsAAQIDCAkKC/3eAUEB/csB/c4BIgkgCP1RIgRBAf3LASAEQT/9zQH9UCIMIAD9AARgIAD9AAQgIgQgAP0ABAAiBv3OASAEIAT9DQABAgMICQoLAAECAwgJCgsgBiAG/Q0AAQIDCAkKCwABAgMICQoL/d4BQQH9ywH9zgEiBv1RIghBIP3LASAIQSD9zQH9UCIIIABBQGsiAf0ABAAiB/3OASAIIAj9DQABAgMICQoLAAECAwgJCgsgByAH/Q0AAQIDCAkKCwABAgMICQoL/d4BQQH9ywH9zgEiByAE/VEiBEEo/csBIARBGP3NAf1QIgsgBv3OASALIAv9DQABAgMICQoLAAECAwgJCgsgBiAG/Q0AAQIDCAkKCwABAgMICQoL/d4BQQH9ywH9zgEiBiAI/VEiBEEw/csBIARBEP3NAf1QIgQgB/3OASAEIAT9DQABAgMICQoLAAECAwgJCgsgByAH/Q0AAQIDCAkKCwABAgMICQoL/d4BQQH9ywH9zgEiCCAL/VEiB0EB/csBIAdBP/3NAf1QIg0gDf0NAAECAwQFBgcQERITFBUWF/0NCAkKCwwNDg8YGRobHB0eHyIH/c4BIAcgB/0NAAECAwgJCgsAAQIDCAkKCyAKIAr9DQABAgMICQoLAAECAwgJCgv93gFBAf3LAf3OASIKIAQgBSAF/Q0AAQIDBAUGBxAREhMUFRYX/Q0ICQoLDA0ODxgZGhscHR4f/VEiC0Eg/csBIAtBIP3NAf1QIgsgCP3OASALIAv9DQABAgMICQoLAAECAwgJCgsgCCAI/Q0AAQIDCAkKCwABAgMICQoL/d4BQQH9ywH9zgEiCCAH/VEiB0Eo/csBIAdBGP3NAf1QIgcgCv3OASAHIAf9DQABAgMICQoLAAECAwgJCgsgCiAK/Q0AAQIDCAkKCwABAgMICQoL/d4BQQH9ywH9zgEiDv0LBAAgACAGIA0gDCAM/Q0AAQIDBAUGBxAREhMUFRYX/Q0ICQoLDA0ODxgZGhscHR4fIgr9zgEgCiAK/Q0AAQIDCAkKCwABAgMICQoLIAYgBv0NAAECAwgJCgsAAQIDCAkKC/3eAUEB/csB/c4BIgYgBSAEIAT9DQABAgMEBQYHEBESExQVFhf9DQgJCgsMDQ4PGBkaGxwdHh/9USIFQSD9ywEgBUEg/c0B/VAiBSAJ/c4BIAUgBf0NAAECAwgJCgsAAQIDCAkKCyAJIAn9DQABAgMICQoLAAECAwgJCgv93gFBAf3LAf3OASIJIAr9USIEQSj9ywEgBEEY/c0B/VAiCiAG/c4BIAogCv0NAAECAwgJCgsAAQIDCAkKCyAGIAb9DQABAgMICQoLAAECAwgJCgv93gFBAf3LAf3OASIE/QsEACAAIAQgBf1RIgVBMP3LASAFQRD9zQH9UCIFIA4gC/1RIgRBMP3LASAEQRD9zQH9UCIEIAT9DQABAgMEBQYHEBESExQVFhf9DQgJCgsMDQ4PGBkaGxwdHh/9CwRgIAAgBCAFIAX9DQABAgMEBQYHEBESExQVFhf9DQgJCgsMDQ4PGBkaGxwdHh/9CwRwIAEgBCAI/c4BIAQgBP0NAAECAwgJCgsAAQIDCAkKCyAIIAj9DQABAgMICQoLAAECAwgJCgv93gFBAf3LAf3OASIE/QsEACAAIAUgCf3OASAFIAX9DQABAgMICQoLAAECAwgJCgsgCSAJ/Q0AAQIDCAkKCwABAgMICQoL/d4BQQH9ywH9zgEiCf0LBFAgACAEIAf9USIFQQH9ywEgBUE//c0B/VAiBSAJIAr9USIEQQH9ywEgBEE//c0B/VAiBCAE/Q0AAQIDBAUGBxAREhMUFRYX/Q0ICQoLDA0ODxgZGhscHR4f/QsEICAAIAQgBSAF/Q0AAQIDBAUGBxAREhMUFRYX/Q0ICQoLDA0ODxgZGhscHR4f/QsEMCAQQQFqIhBBCEcNAAtBACEQA0AgAyAQQQR0aiIAQYABaiAA/QAEgAcgAP0ABIADIgUgAP0ABIABIgT9zgEgBSAF/Q0AAQIDCAkKCwABAgMICQoLIAQgBP0NAAECAwgJCgsAAQIDCAkKC/3eAUEB/csB/c4BIgT9USIJQSD9ywEgCUEg/c0B/VAiCSAA/QAEgAUiBv3OASAJIAn9DQABAgMICQoLAAECAwgJCgsgBiAG/Q0AAQIDCAkKCwABAgMICQoL/d4BQQH9ywH9zgEiBiAF/VEiBUEo/csBIAVBGP3NAf1QIgggBP3OASAIIAj9DQABAgMICQoLAAECAwgJCgsgBCAE/Q0AAQIDCAkKCwABAgMICQoL/d4BQQH9ywH9zgEiCiAKIAn9USIFQTD9ywEgBUEQ/c0B/VAiBSAG/c4BIAUgBf0NAAECAwgJCgsAAQIDCAkKCyAGIAb9DQABAgMICQoLAAECAwgJCgv93gFBAf3LAf3OASIJIAj9USIEQQH9ywEgBEE//c0B/VAiDCAA/QAEgAYgAP0ABIACIgQgAP0ABAAiBv3OASAEIAT9DQABAgMICQoLAAECAwgJCgsgBiAG/Q0AAQIDCAkKCwABAgMICQoL/d4BQQH9ywH9zgEiBv1RIghBIP3LASAIQSD9zQH9UCIIIAD9AASABCIH/c4BIAggCP0NAAECAwgJCgsAAQIDCAkKCyAHIAf9DQABAgMICQoLAAECAwgJCgv93gFBAf3LAf3OASIHIAT9USIEQSj9ywEgBEEY/c0B/VAiCyAG/c4BIAsgC/0NAAECAwgJCgsAAQIDCAkKCyAGIAb9DQABAgMICQoLAAECAwgJCgv93gFBAf3LAf3OASIGIAj9USIEQTD9ywEgBEEQ/c0B/VAiBCAH/c4BIAQgBP0NAAECAwgJCgsAAQIDCAkKCyAHIAf9DQABAgMICQoLAAECAwgJCgv93gFBAf3LAf3OASIIIAv9USIHQQH9ywEgB0E//c0B/VAiDSAN/Q0AAQIDBAUGBxAREhMUFRYX/Q0ICQoLDA0ODxgZGhscHR4fIgf9zgEgByAH/Q0AAQIDCAkKCwABAgMICQoLIAogCv0NAAECAwgJCgsAAQIDCAkKC/3eAUEB/csB/c4BIgogBCAFIAX9DQABAgMEBQYHEBESExQVFhf9DQgJCgsMDQ4PGBkaGxwdHh/9USILQSD9ywEgC0Eg/c0B/VAiCyAI/c4BIAsgC/0NAAECAwgJCgsAAQIDCAkKCyAIIAj9DQABAgMICQoLAAECAwgJCgv93gFBAf3LAf3OASIIIAf9USIHQSj9ywEgB0EY/c0B/VAiByAK/c4BIAcgB/0NAAECAwgJCgsAAQIDCAkKCyAKIAr9DQABAgMICQoLAAECAwgJCgv93gFBAf3LAf3OASIO/QsEACAAIAYgDSAMIAz9DQABAgMEBQYHEBESExQVFhf9DQgJCgsMDQ4PGBkaGxwdHh8iCv3OASAKIAr9DQABAgMICQoLAAECAwgJCgsgBiAG/Q0AAQIDCAkKCwABAgMICQoL/d4BQQH9ywH9zgEiBiAFIAQgBP0NAAECAwQFBgcQERITFBUWF/0NCAkKCwwNDg8YGRobHB0eH/1RIgVBIP3LASAFQSD9zQH9UCIFIAn9zgEgBSAF/Q0AAQIDCAkKCwABAgMICQoLIAkgCf0NAAECAwgJCgsAAQIDCAkKC/3eAUEB/csB/c4BIgkgCv1RIgRBKP3LASAEQRj9zQH9UCIKIAb9zgEgCiAK/Q0AAQIDCAkKCwABAgMICQoLIAYgBv0NAAECAwgJCgsAAQIDCAkKC/3eAUEB/csB/c4BIgT9CwQAIAAgBCAF/VEiBUEw/csBIAVBEP3NAf1QIgUgDiAL/VEiBEEw/csBIARBEP3NAf1QIgQgBP0NAAECAwQFBgcQERITFBUWF/0NCAkKCwwNDg8YGRobHB0eH/0LBIAGIAAgBCAFIAX9DQABAgMEBQYHEBESExQVFhf9DQgJCgsMDQ4PGBkaGxwdHh/9CwSAByAAIAQgCP3OASAEIAT9DQABAgMICQoLAAECAwgJCgsgCCAI/Q0AAQIDCAkKCwABAgMICQoL/d4BQQH9ywH9zgEiBP0LBIAEIAAgBSAJ/c4BIAUgBf0NAAECAwgJCgsAAQIDCAkKCyAJIAn9DQABAgMICQoLAAECAwgJCgv93gFBAf3LAf3OASIJ/QsEgAUgACAEIAf9USIFQQH9ywEgBUE//c0B/VAiBSAJIAr9USIEQQH9ywEgBEE//c0B/VAiBCAE/Q0AAQIDBAUGBxAREhMUFRYX/Q0ICQoLDA0ODxgZGhscHR4f/QsEgAIgACAEIAUgBf0NAAECAwQFBgcQERITFBUWF/0NCAkKCwwNDg8YGRobHB0eH/0LBIADIBBBAWoiEEEIRw0AC0EAIRADQCACIBBBBHQiAGoiASAAIANq/QAEACAB/QAEAP1R/QsEACACIABBEHIiAWoiDyABIANq/QAEACAP/QAEAP1R/QsEACACIABBIHIiAWoiDyABIANq/QAEACAP/QAEAP1R/QsEACACIABBMHIiAGoiASAAIANq/QAEACAB/QAEAP1R/QsEACAQQQRqIhBBwABHDQALCxYAIAAgASACIAMQAiAAIAIgAiADEAILewIBfwF+IAIhCSABNQIAIQogBCAFcgRAIAEoAgQgA3AhCQsgACAJNgIAIAAgB0EBayAFIAQbIAhsIAZBAWtBAEF/IAYbIAIgCUYbaiIBIAVBAWogCGxBACAEG2ogAa0gCiAKfkIgiH5CIIinQX9zaiAHIAhscDYCBCAACwQAIwALBgAgACQACxAAIwAgAGtBcHEiACQAIAALBQBBgAgL",e)),(e=>bf(0,0,"AGFzbQEAAAABPwhgBH9/f38AYAABf2AAAGADf39/AGARf39/f39/f39/f39/f39/f38AYAl/f39/f39/f38Bf2ABfwBgAX8BfwITAQNlbnYGbWVtb3J5AgGQCICABAMLCgIDBAAABQEGBwEEBQFwAQICBgkBfwFBkIjAAgsHfQoDeG9yAAEBRwADAkcyAAQFZ2V0TFoABRlfX2luZGlyZWN0X2Z1bmN0aW9uX3RhYmxlAQALX2luaXRpYWxpemUAABBfX2Vycm5vX2xvY2F0aW9uAAkJc3RhY2tTYXZlAAYMc3RhY2tSZXN0b3JlAAcKc3RhY2tBbGxvYwAICQcBAEEBCwEACssaCgMAAQtQAQJ/A0AgACAEQQN0IgNqIAIgA2opAwAgASADaikDAIU3AwAgACADQQhyIgNqIAIgA2opAwAgASADaikDAIU3AwAgBEECaiIEQYABRw0ACwveDwICfgF/IAAgAUEDdGoiEyATKQMAIhEgACAFQQN0aiIBKQMAIhJ8IBFCAYZC/v///x+DIBJC/////w+DfnwiETcDACAAIA1BA3RqIgUgESAFKQMAhUIgiSIRNwMAIAAgCUEDdGoiCSARIAkpAwAiEnwgEUL/////D4MgEkIBhkL+////H4N+fCIRNwMAIAEgESABKQMAhUIoiSIRNwMAIBMgESATKQMAIhJ8IBFC/////w+DIBJCAYZC/v///x+DfnwiETcDACAFIBEgBSkDAIVCMIkiETcDACAJIBEgCSkDACISfCARQv////8PgyASQgGGQv7///8fg358IhE3AwAgASARIAEpAwCFQgGJNwMAIAAgAkEDdGoiDSANKQMAIhEgACAGQQN0aiICKQMAIhJ8IBFCAYZC/v///x+DIBJC/////w+DfnwiETcDACAAIA5BA3RqIgYgESAGKQMAhUIgiSIRNwMAIAAgCkEDdGoiCiARIAopAwAiEnwgEUL/////D4MgEkIBhkL+////H4N+fCIRNwMAIAIgESACKQMAhUIoiSIRNwMAIA0gESANKQMAIhJ8IBFC/////w+DIBJCAYZC/v///x+DfnwiETcDACAGIBEgBikDAIVCMIkiETcDACAKIBEgCikDACISfCARQv////8PgyASQgGGQv7///8fg358IhE3AwAgAiARIAIpAwCFQgGJNwMAIAAgA0EDdGoiDiAOKQMAIhEgACAHQQN0aiIDKQMAIhJ8IBFCAYZC/v///x+DIBJC/////w+DfnwiETcDACAAIA9BA3RqIgcgESAHKQMAhUIgiSIRNwMAIAAgC0EDdGoiCyARIAspAwAiEnwgEUL/////D4MgEkIBhkL+////H4N+fCIRNwMAIAMgESADKQMAhUIoiSIRNwMAIA4gESAOKQMAIhJ8IBFC/////w+DIBJCAYZC/v///x+DfnwiETcDACAHIBEgBykDAIVCMIkiETcDACALIBEgCykDACISfCARQv////8PgyASQgGGQv7///8fg358IhE3AwAgAyARIAMpAwCFQgGJNwMAIAAgBEEDdGoiDyAPKQMAIhEgACAIQQN0aiIEKQMAIhJ8IBFCAYZC/v///x+DIBJC/////w+DfnwiETcDACAAIBBBA3RqIgggESAIKQMAhUIgiSIRNwMAIAAgDEEDdGoiACARIAApAwAiEnwgEUL/////D4MgEkIBhkL+////H4N+fCIRNwMAIAQgESAEKQMAhUIoiSIRNwMAIA8gESAPKQMAIhJ8IBFC/////w+DIBJCAYZC/v///x+DfnwiETcDACAIIBEgCCkDAIVCMIkiETcDACAAIBEgACkDACISfCARQv////8PgyASQgGGQv7///8fg358IhE3AwAgBCARIAQpAwCFQgGJNwMAIBMgEykDACIRIAIpAwAiEnwgEUIBhkL+////H4MgEkL/////D4N+fCIRNwMAIAggESAIKQMAhUIgiSIRNwMAIAsgESALKQMAIhJ8IBFC/////w+DIBJCAYZC/v///x+DfnwiETcDACACIBEgAikDAIVCKIkiETcDACATIBEgEykDACISfCARQv////8PgyASQgGGQv7///8fg358IhE3AwAgCCARIAgpAwCFQjCJIhE3AwAgCyARIAspAwAiEnwgEUL/////D4MgEkIBhkL+////H4N+fCIRNwMAIAIgESACKQMAhUIBiTcDACANIA0pAwAiESADKQMAIhJ8IBFCAYZC/v///x+DIBJC/////w+DfnwiETcDACAFIBEgBSkDAIVCIIkiETcDACAAIBEgACkDACISfCARQv////8PgyASQgGGQv7///8fg358IhE3AwAgAyARIAMpAwCFQiiJIhE3AwAgDSARIA0pAwAiEnwgEUL/////D4MgEkIBhkL+////H4N+fCIRNwMAIAUgESAFKQMAhUIwiSIRNwMAIAAgESAAKQMAIhJ8IBFC/////w+DIBJCAYZC/v///x+DfnwiETcDACADIBEgAykDAIVCAYk3AwAgDiAOKQMAIhEgBCkDACISfCARQgGGQv7///8fgyASQv////8Pg358IhE3AwAgBiARIAYpAwCFQiCJIhE3AwAgCSARIAkpAwAiEnwgEUL/////D4MgEkIBhkL+////H4N+fCIRNwMAIAQgESAEKQMAhUIoiSIRNwMAIA4gESAOKQMAIhJ8IBFC/////w+DIBJCAYZC/v///x+DfnwiETcDACAGIBEgBikDAIVCMIkiETcDACAJIBEgCSkDACISfCARQv////8PgyASQgGGQv7///8fg358IhE3AwAgBCARIAQpAwCFQgGJNwMAIA8gDykDACIRIAEpAwAiEnwgEUIBhkL+////H4MgEkL/////D4N+fCIRNwMAIAcgESAHKQMAhUIgiSIRNwMAIAogESAKKQMAIhJ8IBFC/////w+DIBJCAYZC/v///x+DfnwiETcDACABIBEgASkDAIVCKIkiETcDACAPIBEgDykDACISfCARQv////8PgyASQgGGQv7///8fg358IhE3AwAgByARIAcpAwCFQjCJIhE3AwAgCiARIAopAwAiEnwgEUL/////D4MgEkIBhkL+////H4N+fCIRNwMAIAEgESABKQMAhUIBiTcDAAvdCAEPfwNAIAIgBUEDdCIGaiABIAZqKQMAIAAgBmopAwCFNwMAIAIgBkEIciIGaiABIAZqKQMAIAAgBmopAwCFNwMAIAVBAmoiBUGAAUcNAAsDQCADIARBA3QiAGogACACaikDADcDACADIARBAXIiAEEDdCIBaiABIAJqKQMANwMAIAMgBEECciIBQQN0IgVqIAIgBWopAwA3AwAgAyAEQQNyIgVBA3QiBmogAiAGaikDADcDACADIARBBHIiBkEDdCIHaiACIAdqKQMANwMAIAMgBEEFciIHQQN0IghqIAIgCGopAwA3AwAgAyAEQQZyIghBA3QiCWogAiAJaikDADcDACADIARBB3IiCUEDdCIKaiACIApqKQMANwMAIAMgBEEIciIKQQN0IgtqIAIgC2opAwA3AwAgAyAEQQlyIgtBA3QiDGogAiAMaikDADcDACADIARBCnIiDEEDdCINaiACIA1qKQMANwMAIAMgBEELciINQQN0Ig5qIAIgDmopAwA3AwAgAyAEQQxyIg5BA3QiD2ogAiAPaikDADcDACADIARBDXIiD0EDdCIQaiACIBBqKQMANwMAIAMgBEEOciIQQQN0IhFqIAIgEWopAwA3AwAgAyAEQQ9yIhFBA3QiEmogAiASaikDADcDACADIARB//8DcSAAQf//A3EgAUH//wNxIAVB//8DcSAGQf//A3EgB0H//wNxIAhB//8DcSAJQf//A3EgCkH//wNxIAtB//8DcSAMQf//A3EgDUH//wNxIA5B//8DcSAPQf//A3EgEEH//wNxIBFB//8DcRACIARB8ABJIQAgBEEQaiEEIAANAAtBACEBIANBAEEBQRBBEUEgQSFBMEExQcAAQcEAQdAAQdEAQeAAQeEAQfAAQfEAEAIgA0ECQQNBEkETQSJBI0EyQTNBwgBBwwBB0gBB0wBB4gBB4wBB8gBB8wAQAiADQQRBBUEUQRVBJEElQTRBNUHEAEHFAEHUAEHVAEHkAEHlAEH0AEH1ABACIANBBkEHQRZBF0EmQSdBNkE3QcYAQccAQdYAQdcAQeYAQecAQfYAQfcAEAIgA0EIQQlBGEEZQShBKUE4QTlByABByQBB2ABB2QBB6ABB6QBB+ABB+QAQAiADQQpBC0EaQRtBKkErQTpBO0HKAEHLAEHaAEHbAEHqAEHrAEH6AEH7ABACIANBDEENQRxBHUEsQS1BPEE9QcwAQc0AQdwAQd0AQewAQe0AQfwAQf0AEAIgA0EOQQ9BHkEfQS5BL0E+QT9BzgBBzwBB3gBB3wBB7gBB7wBB/gBB/wAQAgNAIAIgAUEDdCIAaiIEIAAgA2opAwAgBCkDAIU3AwAgAiAAQQhyIgRqIgUgAyAEaikDACAFKQMAhTcDACACIABBEHIiBGoiBSADIARqKQMAIAUpAwCFNwMAIAIgAEEYciIAaiIEIAAgA2opAwAgBCkDAIU3AwAgAUEEaiIBQYABRw0ACwsWACAAIAEgAiADEAMgACACIAIgAxADC3sCAX8BfiACIQkgATUCACEKIAQgBXIEQCABKAIEIANwIQkLIAAgCTYCACAAIAdBAWsgBSAEGyAIbCAGQQFrQQBBfyAGGyACIAlGG2oiASAFQQFqIAhsQQAgBBtqIAGtIAogCn5CIIh+QiCIp0F/c2ogByAIbHA2AgQgAAsEACMACwYAIAAkAAsQACMAIABrQXBxIgAkACAACwUAQYAICw==",e)))}),Ef=[0,1,3,7,15,31,63,127,255],vf=function(e){this.stream=e,this.bitOffset=0,this.curByte=0,this.hasByte=!1};vf.prototype._ensureByte=function(){this.hasByte||(this.curByte=this.stream.readByte(),this.hasByte=!0)},vf.prototype.read=function(e){for(var t=0;e>0;){this._ensureByte();var r=8-this.bitOffset;if(e>=r)t<<=r,t|=Ef[r]&this.curByte,this.hasByte=!1,this.bitOffset=0,e-=r;else{t<<=e;var n=r-e;t|=(this.curByte&Ef[e]<>n,this.bitOffset+=e,e=0}}return t},vf.prototype.seek=function(e){var t=e%8,r=(e-t)/8;this.bitOffset=t,this.stream.seek(r),this.hasByte=!1},vf.prototype.pi=function(){var e,t=new Uint8Array(6);for(e=0;e("00"+e.toString(16)).slice(-2))).join("")}(t)};var Bf=vf,If=function(){};If.prototype.readByte=function(){throw Error("abstract method readByte() not implemented")},If.prototype.read=function(e,t,r){for(var n=0;n>>0},this.updateCRC=function(t){e=e<<8^Sf[255&(e>>>24^t)]},this.updateCRCRun=function(t,r){for(;r-- >0;)e=e<<8^Sf[255&(e>>>24^t)]}}),Pf=Bf,Uf=Kf,Df=Cf,xf=function(e,t){var r,n=e[t];for(r=t;r>0;r--)e[r]=e[r-1];return e[0]=n,n},Qf={OK:0,LAST_BLOCK:-1,NOT_BZIP_DATA:-2,UNEXPECTED_INPUT_EOF:-3,UNEXPECTED_OUTPUT_EOF:-4,DATA_ERROR:-5,OUT_OF_MEMORY:-6,OBSOLETE_INPUT:-7,END_OF_BLOCK:-8},Rf={};Rf[Qf.LAST_BLOCK]="Bad file checksum",Rf[Qf.NOT_BZIP_DATA]="Not bzip data",Rf[Qf.UNEXPECTED_INPUT_EOF]="Unexpected input EOF",Rf[Qf.UNEXPECTED_OUTPUT_EOF]="Unexpected output EOF",Rf[Qf.DATA_ERROR]="Data error",Rf[Qf.OUT_OF_MEMORY]="Out of memory",Rf[Qf.OBSOLETE_INPUT]="Obsolete (pre 0.9.5) bzip format not supported.";var Lf=function(e,t){var r=Rf[e]||"unknown error";t&&(r+=": "+t);var n=new TypeError(r);throw n.errorCode=e,n},Mf=function(e,t){this.writePos=this.writeCurrent=this.writeCount=0,this._start_bunzip(e,t)};Mf.prototype._init_block=function(){return this._get_next_block()?(this.blockCRC=new Df,!0):(this.writeCount=-1,!1)},Mf.prototype._start_bunzip=function(e,t){var r=new Uint8Array(4);4===e.read(r,0,4)&&"BZh"===String.fromCharCode(r[0],r[1],r[2])||Lf(Qf.NOT_BZIP_DATA,"bad magic");var n=r[3]-48;(n<1||n>9)&&Lf(Qf.NOT_BZIP_DATA,"level out of range"),this.reader=new Pf(e),this.dbufSize=1e5*n,this.nextoutput=0,this.outputStream=t,this.streamCRC=0},Mf.prototype._get_next_block=function(){var e,t,r,n=this.reader,i=n.pi();if("177245385090"===i)return!1;"314159265359"!==i&&Lf(Qf.NOT_BZIP_DATA),this.targetBlockCRC=n.read(32)>>>0,this.streamCRC=(this.targetBlockCRC^(this.streamCRC<<1|this.streamCRC>>>31))>>>0,n.read(1)&&Lf(Qf.OBSOLETE_INPUT);var s=n.read(24);s>this.dbufSize&&Lf(Qf.DATA_ERROR,"initial position out of bounds");var a=n.read(16),o=new Uint8Array(256),c=0;for(e=0;e<16;e++)if(a&1<<15-e){var h=16*e;for(r=n.read(16),t=0;t<16;t++)r&1<<15-t&&(o[c++]=h+t)}var u=n.read(3);(u<2||u>6)&&Lf(Qf.DATA_ERROR);var l=n.read(15);0===l&&Lf(Qf.DATA_ERROR);var y=new Uint8Array(256);for(e=0;e=u&&Lf(Qf.DATA_ERROR);f[e]=xf(y,t)}var g,p=c+2,d=[];for(t=0;t20)&&Lf(Qf.DATA_ERROR),n.read(1);)n.read(1)?a--:a++;m[e]=a}for(A=w=m[0],e=1;ew?w=m[e]:m[e]=l&&Lf(Qf.DATA_ERROR),g=d[f[S++]]),e=g.minLen,t=n.read(e);e>g.maxLen&&Lf(Qf.DATA_ERROR),!(t<=g.limit[e]);e++)t=t<<1|n.read(1);((t-=g.base[e])<0||t>=258)&&Lf(Qf.DATA_ERROR);var C=g.permute[t];if(0!==C&&1!==C){if(B)for(B=0,I+a>this.dbufSize&&Lf(Qf.DATA_ERROR),E[v=o[y[0]]]+=a;a--;)K[I++]=v;if(C>c)break;I>=this.dbufSize&&Lf(Qf.DATA_ERROR),E[v=o[v=xf(y,e=C-1)]]++,K[I++]=v}else B||(B=1,a=0),a+=0===C?B:2*B,B<<=1}for((s<0||s>=I)&&Lf(Qf.DATA_ERROR),t=0,e=0;e<256;e++)r=t+E[e],E[e]=t,t=r;for(e=0;e>=8,D=-1),this.writePos=P,this.writeCurrent=U,this.writeCount=I,this.writeRun=D,!0},Mf.prototype._read_bunzip=function(e,t){var r,n,i;if(this.writeCount<0)return 0;var s=this.dbuf,a=this.writePos,o=this.writeCurrent,c=this.writeCount;this.outputsize;for(var h=this.writeRun;c;){for(c--,n=o,o=255&(a=s[a]),a>>=8,3==h++?(r=o,i=n,o=-1):(r=1,i=o),this.blockCRC.updateCRCRun(i,r);r--;)this.outputStream.writeByte(i),this.nextoutput++;o!=n&&(h=0)}return this.writeCount=c,this.blockCRC.getCRC()!==this.targetBlockCRC&&Lf(Qf.DATA_ERROR,"Bad block CRC (got "+this.blockCRC.getCRC().toString(16)+" expected "+this.targetBlockCRC.toString(16)+")"),this.nextoutput};var Tf=function(e){if("readByte"in e)return e;var t=new Uf;return t.pos=0,t.readByte=function(){return e[this.pos++]},t.seek=function(e){this.pos=e},t.eof=function(){return this.pos>=e.length},t},Ff=function(e){var t=new Uf,r=!0;if(e)if("number"==typeof e)t.buffer=new Uint8Array(e),r=!1;else{if("writeByte"in e)return e;t.buffer=e,r=!1}else t.buffer=new Uint8Array(16384);return t.pos=0,t.writeByte=function(e){if(r&&this.pos>=this.buffer.length){var t=new Uint8Array(2*this.buffer.length);t.set(this.buffer),this.buffer=t}this.buffer[this.pos++]=e},t.getBuffer=function(){if(this.pos!==this.buffer.length){if(!r)throw new TypeError("outputsize does not match decoded input");var e=new Uint8Array(this.pos);e.set(this.buffer.subarray(0,this.pos)),this.buffer=e}return this.buffer},t._coerced=!0,t};var Nf={Bunzip:Mf,Stream:Uf,Err:Qf,decode:function(e,t,r){for(var n=Tf(e),i=Ff(t),s=new Mf(n,i);!("eof"in n)||!n.eof();)if(s._init_block())s._read_bunzip();else{var a=s.reader.read(32)>>>0;if(a!==s.streamCRC&&Lf(Qf.DATA_ERROR,"Bad stream CRC (got "+s.streamCRC.toString(16)+" expected "+a.toString(16)+")"),!r||!("eof"in n)||n.eof())break;s._start_bunzip(n,i)}if("getBuffer"in i)return i.getBuffer()},decodeBlock:function(e,t,r){var n=Tf(e),i=Ff(r),s=new Mf(n,i);if(s.reader.seek(t),s._get_next_block()&&(s.blockCRC=new Df,s.writeCopies=0,s._read_bunzip()),"getBuffer"in i)return i.getBuffer()},table:function(e,t,r){var n=new Uf;n.delegate=Tf(e),n.pos=0,n.readByte=function(){return this.pos++,this.delegate.readByte()},n.delegate.eof&&(n.eof=n.delegate.eof.bind(n.delegate));var i=new Uf;i.pos=0,i.writeByte=function(){this.pos++};for(var s=new Mf(n,i),a=s.dbufSize;!("eof"in n)||!n.eof();){var o=8*n.pos+s.reader.bitOffset;if(s.reader.hasByte&&(o-=8),s._init_block()){var c=i.pos;s._read_bunzip(),t(o,i.pos-c)}else{if(s.reader.read(32),!r||!("eof"in n)||n.eof())break;s._start_bunzip(n,i),console.assert(s.dbufSize===a,"shouldn't change block size within multistream file")}}}},Of=/*#__PURE__*/a({__proto__:null},[Nf]);exports.AEADEncryptedDataPacket=Oo,exports.Argon2OutOfMemoryError=pa,exports.Argon2S2K=ma,exports.CleartextMessage=Qc,exports.CompressedDataPacket=Uo,exports.KDFParams=ra,exports.LiteralDataPacket=wo,exports.MarkerPacket=class{static get tag(){return H.packet.marker}read(e){return 80===e[0]&&71===e[1]&&80===e[2]}write(){return new Uint8Array([80,71,80])}},exports.Message=Pc,exports.OnePassSignaturePacket=So,exports.PacketList=Co,exports.PaddingPacket=class{static get tag(){return H.packet.padding}constructor(){this.padding=null}read(e){}write(){return this.padding}async createPadding(e){this.padding=await ga.random.getRandomBytes(e)}},exports.PrivateKey=Ec,exports.PublicKey=kc,exports.PublicKeyEncryptedSessionKeyPacket=Ho,exports.PublicKeyPacket=Go,exports.PublicSubkeyPacket=Vo,exports.SecretKeyPacket=Zo,exports.SecretSubkeyPacket=$o,exports.Signature=ec,exports.SignaturePacket=vo,exports.Subkey=dc,exports.SymEncryptedIntegrityProtectedDataPacket=To,exports.SymEncryptedSessionKeyPacket=_o,exports.SymmetricallyEncryptedDataPacket=qo,exports.TrustPacket=class{static get tag(){return H.packet.trust}read(){throw new Xn("Trust packets are not supported")}write(){throw new Xn("Trust packets are not supported")}},exports.UnparseablePacket=ti,exports.UserAttributePacket=Wo,exports.UserIDPacket=Jo,exports.armor=ae,exports.config=z,exports.createCleartextMessage=async function({text:e,...t}){if(!e)throw Error("createCleartextMessage: must pass options object containing `text`");if(!G.isString(e))throw Error("createCleartextMessage: options.text must be a string");const r=Object.keys(t);if(r.length>0)throw Error("Unknown option: "+r.join(", "));return new Qc(e)},exports.createMessage=async function({text:e,binary:t,filename:r,date:n=new Date,format:i=(void 0!==e?"utf8":"binary"),...s}){const a=void 0!==e?e:t;if(void 0===a)throw Error("createMessage: must pass options object containing `text` or `binary`");if(e&&!G.isString(e)&&!G.isStream(e))throw Error("createMessage: options.text must be a string or stream");if(t&&!G.isUint8Array(t)&&!G.isStream(t))throw Error("createMessage: options.binary must be a Uint8Array or stream");const o=Object.keys(s);if(o.length>0)throw Error("Unknown option: "+o.join(", "));const c=G.isStream(a),h=new wo(n);void 0!==e?h.setText(a,H.write(H.literal,i)):h.setBytes(a,H.write(H.literal,i)),void 0!==r&&h.setFilename(r);const u=new Co;u.push(h);const l=new Pc(u);return l.fromStream=c,l},exports.decrypt=async function({message:e,decryptionKeys:t,passwords:r,sessionKeys:n,verificationKeys:i,expectSigned:s=!1,format:a="utf8",signature:o=null,date:c=new Date,config:h,...u}){if(Fc(h={...z,...h}),Rc(e),i=Nc(i),t=Nc(t),r=Nc(r),n=Nc(n),u.privateKeys)throw Error("The `privateKeys` option has been removed from openpgp.decrypt, pass `decryptionKeys` instead");if(u.publicKeys)throw Error("The `publicKeys` option has been removed from openpgp.decrypt, pass `verificationKeys` instead");const l=Object.keys(u);if(l.length>0)throw Error("Unknown option: "+l.join(", "));try{const u=await e.decrypt(t,r,n,c,h);i||(i=[]);const l={};if(l.signatures=o?await u.verifyDetached(o,i,c,h):await u.verify(i,c,h),l.data="binary"===a?u.getLiteralData():u.getText(),l.filename=u.getFilename(),Hc(l,e),s){if(0===i.length)throw Error("Verification keys are required to verify message signatures");if(0===l.signatures.length)throw Error("Message is not signed");l.data=B([l.data,T((async()=>{await G.anyPromise(l.signatures.map((e=>e.verified)))}))])}return l.data=await Oc(l.data),l}catch(e){throw G.wrapError("Error decrypting message",e)}},exports.decryptKey=async function({privateKey:e,passphrase:t,config:r,...n}){Fc(r={...z,...r});const i=Object.keys(n);if(i.length>0)throw Error("Unknown option: "+i.join(", "));if(!e.isPrivate())throw Error("Cannot decrypt a public key");const s=e.clone(!0),a=G.isArray(t)?t:[t];try{return await Promise.all(s.getKeys().map((e=>G.anyPromise(a.map((t=>e.keyPacket.decrypt(t))))))),await s.validate(r),s}catch(e){throw s.clearPrivateParams(),G.wrapError("Error decrypting private key",e)}},exports.decryptSessionKeys=async function({message:e,decryptionKeys:t,passwords:r,date:n=new Date,config:i,...s}){if(Fc(i={...z,...i}),Rc(e),t=Nc(t),r=Nc(r),s.privateKeys)throw Error("The `privateKeys` option has been removed from openpgp.decryptSessionKeys, pass `decryptionKeys` instead");const a=Object.keys(s);if(a.length>0)throw Error("Unknown option: "+a.join(", "));try{return await e.decryptSessionKeys(t,r,void 0,n,i)}catch(e){throw G.wrapError("Error decrypting session keys",e)}},exports.encrypt=async function({message:e,encryptionKeys:t,signingKeys:r,passwords:n,sessionKey:i,format:s="armored",signature:a=null,wildcard:o=!1,signingKeyIDs:c=[],encryptionKeyIDs:h=[],date:u=new Date,signingUserIDs:l=[],encryptionUserIDs:y=[],signatureNotations:f=[],config:g,...p}){if(Fc(g={...z,...g}),Rc(e),Mc(s),t=Nc(t),r=Nc(r),n=Nc(n),c=Nc(c),h=Nc(h),l=Nc(l),y=Nc(y),f=Nc(f),p.detached)throw Error("The `detached` option has been removed from openpgp.encrypt, separately call openpgp.sign instead. Don't forget to remove the `privateKeys` option as well.");if(p.publicKeys)throw Error("The `publicKeys` option has been removed from openpgp.encrypt, pass `encryptionKeys` instead");if(p.privateKeys)throw Error("The `privateKeys` option has been removed from openpgp.encrypt, pass `signingKeys` instead");if(void 0!==p.armor)throw Error("The `armor` option has been removed from openpgp.encrypt, pass `format` instead.");const d=Object.keys(p);if(d.length>0)throw Error("Unknown option: "+d.join(", "));r||(r=[]);try{if((r.length||a)&&(e=await e.sign(r,t,a,c,u,l,h,f,g)),e=e.compress(await async function(e=[],t=new Date,r=[],n=z){const i=H.compression.uncompressed,s=n.preferredCompressionAlgorithm,a=await Promise.all(e.map((async function(e,i){const a=(await e.getPrimarySelfSignature(t,r[i],n)).preferredCompressionAlgorithms;return!!a&&a.indexOf(s)>=0})));return a.every(Boolean)?s:i}(t,u,y,g),g),e=await e.encrypt(t,n,i,o,h,u,y,g),"object"===s)return e;const p="armored"===s?e.armor(g):e.write();return await Oc(p)}catch(e){throw G.wrapError("Error encrypting message",e)}},exports.encryptKey=async function({privateKey:e,passphrase:t,config:r,...n}){Fc(r={...z,...r});const i=Object.keys(n);if(i.length>0)throw Error("Unknown option: "+i.join(", "));if(!e.isPrivate())throw Error("Cannot encrypt a public key");const s=e.clone(!0),a=s.getKeys(),o=G.isArray(t)?t:Array(a.length).fill(t);if(o.length!==a.length)throw Error("Invalid number of passphrases given for key encryption");try{return await Promise.all(a.map((async(e,t)=>{const{keyPacket:n}=e;await n.encrypt(o[t],r),n.clearPrivateParams()}))),s}catch(e){throw s.clearPrivateParams(),G.wrapError("Error encrypting private key",e)}},exports.encryptSessionKey=async function({data:e,algorithm:t,aeadAlgorithm:r,encryptionKeys:n,passwords:i,format:s="armored",wildcard:a=!1,encryptionKeyIDs:o=[],date:c=new Date,encryptionUserIDs:h=[],config:u,...l}){if(Fc(u={...z,...u}),function(e){if(!G.isUint8Array(e))throw Error("Parameter [data] must be of type Uint8Array")}(e),function(e,t){if(!G.isString(e))throw Error("Parameter ["+t+"] must be of type String")}(t,"algorithm"),Mc(s),n=Nc(n),i=Nc(i),o=Nc(o),h=Nc(h),l.publicKeys)throw Error("The `publicKeys` option has been removed from openpgp.encryptSessionKey, pass `encryptionKeys` instead");const y=Object.keys(l);if(y.length>0)throw Error("Unknown option: "+y.join(", "));if(!(n&&0!==n.length||i&&0!==i.length))throw Error("No encryption keys or passwords provided.");try{return zc(await Pc.encryptSessionKey(e,t,r,n,i,a,o,c,h,u),s,u)}catch(e){throw G.wrapError("Error encrypting session key",e)}},exports.enums=H,exports.generateKey=async function({userIDs:e=[],passphrase:t,type:r,curve:n,rsaBits:i=4096,symmetricHash:s="sha256",symmetricCipher:a="aes256",keyExpirationTime:o=0,date:c=new Date,subkeys:h=[{}],format:u="armored",config:l,...y}){Fc(l={...z,...l}),r||n?(r=r||"ecc",n=n||"curve25519Legacy"):(r=l.v6Keys?"curve25519":"ecc",n="curve25519Legacy"),e=Nc(e);const f=Object.keys(y);if(f.length>0)throw Error("Unknown option: "+f.join(", "));if(0===e.length&&!l.v6Keys)throw Error("UserIDs are required for V4 keys");if("rsa"===r&&iuc(e.subkeys[r],e)));let r=[rc(e,t)];r=r.concat(e.subkeys.map((e=>tc(e,t))));const n=await Promise.all(r),i=await Ic(n[0],n.slice(1),e,t),s=await i.getRevocationCertificate(e.date,t);return i.revocationSignatures=[],{key:i,revocationCertificate:s}}(g,l);return e.getKeys().forEach((({keyPacket:e})=>gc(e,l))),{privateKey:zc(e,u,l),publicKey:"symmetric"!==r?zc(e.toPublic(),u,l):null,revocationCertificate:t}}catch(e){throw G.wrapError("Error generating keypair",e)}},exports.generateSessionKey=async function({encryptionKeys:e,date:t=new Date,encryptionUserIDs:r=[],config:n,...i}){if(Fc(n={...z,...n}),e=Nc(e),r=Nc(r),i.publicKeys)throw Error("The `publicKeys` option has been removed from openpgp.generateSessionKey, pass `encryptionKeys` instead");const s=Object.keys(i);if(s.length>0)throw Error("Unknown option: "+s.join(", "));try{return await Pc.generateSessionKey(e,t,r,n)}catch(e){throw G.wrapError("Error generating session key",e)}},exports.readCleartextMessage=async function({cleartextMessage:e,config:t,...r}){if(t={...z,...t},!e)throw Error("readCleartextMessage: must pass options object containing `cleartextMessage`");if(!G.isString(e))throw Error("readCleartextMessage: options.cleartextMessage must be a string");const n=Object.keys(r);if(n.length>0)throw Error("Unknown option: "+n.join(", "));const i=await se(e);if(i.type!==H.armor.signed)throw Error("No cleartext signed message.");const s=await Co.fromBinary(i.data,xc,t);!function(e,t){const r=function(e){const r=e=>t=>e.hashAlgorithm===t;for(let n=0;n{const t=e.match(/^Hash: (.+)$/);if(!t)throw Error('Only "Hash" header allowed in cleartext signed message');{const e=t[1].replace(/\s/g,"").split(",").map((e=>{try{return H.write(H.hash,e.toLowerCase())}catch(t){throw Error("Unknown hash algorithm in armor header: "+e.toLowerCase())}}));n.push(...e)}})),n.length&&!r(n))throw Error("Hash algorithm mismatch in armor header and signature")}(i.headers,s);const a=new ec(s);return new Qc(i.text,a)},exports.readKey=async function({armoredKey:e,binaryKey:t,config:r,...n}){if(r={...z,...r},!e&&!t)throw Error("readKey: must pass options object containing `armoredKey` or `binaryKey`");if(e&&!G.isString(e))throw Error("readKey: options.armoredKey must be a string");if(t&&!G.isUint8Array(t))throw Error("readKey: options.binaryKey must be a Uint8Array");const i=Object.keys(n);if(i.length>0)throw Error("Unknown option: "+i.join(", "));let s;if(e){const{type:t,data:r}=await se(e);if(t!==H.armor.publicKey&&t!==H.armor.privateKey)throw Error("Armored text not of type key");s=r}else s=t;const a=await Co.fromBinary(s,vc,r),o=a.indexOfTag(H.packet.publicKey,H.packet.secretKey);if(0===o.length)throw Error("No key packet found");return Bc(a.slice(o[0],o[1]))},exports.readKeys=async function({armoredKeys:e,binaryKeys:t,config:r,...n}){r={...z,...r};let i=e||t;if(!i)throw Error("readKeys: must pass options object containing `armoredKeys` or `binaryKeys`");if(e&&!G.isString(e))throw Error("readKeys: options.armoredKeys must be a string");if(t&&!G.isUint8Array(t))throw Error("readKeys: options.binaryKeys must be a Uint8Array");const s=Object.keys(n);if(s.length>0)throw Error("Unknown option: "+s.join(", "));if(e){const{type:t,data:r}=await se(e);if(t!==H.armor.publicKey&&t!==H.armor.privateKey)throw Error("Armored text not of type key");i=r}const a=[],o=await Co.fromBinary(i,vc,r),c=o.indexOfTag(H.packet.publicKey,H.packet.secretKey);if(0===c.length)throw Error("No key packet found");for(let e=0;e0)throw Error("Unknown option: "+s.join(", "));const a=G.isStream(i);if(e){const{type:e,data:t}=await se(i);if(e!==H.armor.message)throw Error("Armored text not of type message");i=t}const o=await Co.fromBinary(i,Sc,r),c=new Pc(o);return c.fromStream=a,c},exports.readPrivateKey=async function({armoredKey:e,binaryKey:t,config:r,...n}){if(r={...z,...r},!e&&!t)throw Error("readPrivateKey: must pass options object containing `armoredKey` or `binaryKey`");if(e&&!G.isString(e))throw Error("readPrivateKey: options.armoredKey must be a string");if(t&&!G.isUint8Array(t))throw Error("readPrivateKey: options.binaryKey must be a Uint8Array");const i=Object.keys(n);if(i.length>0)throw Error("Unknown option: "+i.join(", "));let s;if(e){const{type:t,data:r}=await se(e);if(t!==H.armor.privateKey)throw Error("Armored text not of type private key");s=r}else s=t;const a=await Co.fromBinary(s,vc,r),o=a.indexOfTag(H.packet.publicKey,H.packet.secretKey);for(let e=0;e0)throw Error("Unknown option: "+s.join(", "));if(e){const{type:e,data:t}=await se(i);if(e!==H.armor.signature)throw Error("Armored text not of type signature");i=t}const a=await Co.fromBinary(i,Xo,r);return new ec(a)},exports.reformatKey=async function({privateKey:e,userIDs:t=[],passphrase:r,keyExpirationTime:n=0,date:i,format:s="armored",config:a,...o}){Fc(a={...z,...a}),t=Nc(t);const c=Object.keys(o);if(c.length>0)throw Error("Unknown option: "+c.join(", "));if(0===t.length&&6!==e.keyPacket.version)throw Error("UserIDs are required for V4 keys");const h={privateKey:e,userIDs:t,passphrase:r,keyExpirationTime:n,date:i};try{const{key:e,revocationCertificate:t}=await async function(e,t){e=o(e);const{privateKey:r}=e;if(!r.isPrivate())throw Error("Cannot reformat a public key");if(r.keyPacket.isDummy())throw Error("Cannot reformat a gnu-dummy primary key");if(!r.getKeys().every((({keyPacket:e})=>e.isDecrypted())))throw Error("Key is not decrypted");const n=r.keyPacket;e.subkeys||(e.subkeys=await Promise.all(r.subkeys.map((async e=>{const r=e.keyPacket,i={key:n,bind:r},s=await nc(e.bindingSignatures,n,H.signature.subkeyBinding,i,null,t).catch((()=>({})));return{sign:s.keyFlags&&s.keyFlags[0]&H.keyFlags.signData,forwarding:s.keyFlags&&s.keyFlags[0]&H.keyFlags.forwardedCommunication}}))));const i=r.subkeys.map((e=>e.keyPacket));if(e.subkeys.length!==i.length)throw Error("Number of subkey options does not match number of subkeys");e.subkeys=e.subkeys.map((t=>o(t,e)));const s=await Ic(n,i,e,t),a=await s.getRevocationCertificate(e.date,t);return s.revocationSignatures=[],{key:s,revocationCertificate:a};function o(e,t={}){return e.keyExpirationTime=e.keyExpirationTime||t.keyExpirationTime,e.passphrase=G.isString(e.passphrase)?e.passphrase:t.passphrase,e.date=e.date||t.date,e}}(h,a);return{privateKey:zc(e,s,a),publicKey:zc(e.toPublic(),s,a),revocationCertificate:t}}catch(e){throw G.wrapError("Error reformatting keypair",e)}},exports.revokeKey=async function({key:e,revocationCertificate:t,reasonForRevocation:r,date:n=new Date,format:i="armored",config:s,...a}){Fc(s={...z,...s});const o=Object.keys(a);if(o.length>0)throw Error("Unknown option: "+o.join(", "));try{const a=t?await e.applyRevocationCertificate(t,n,s):await e.revoke(r,n,s);return a.isPrivate()?{privateKey:zc(a,i,s),publicKey:zc(a.toPublic(),i,s)}:{privateKey:null,publicKey:zc(a,i,s)}}catch(e){throw G.wrapError("Error revoking key",e)}},exports.sign=async function({message:e,signingKeys:t,recipientKeys:r=[],format:n="armored",detached:i=!1,signingKeyIDs:s=[],date:a=new Date,signingUserIDs:o=[],recipientUserIDs:c=[],signatureNotations:h=[],config:u,...l}){if(Fc(u={...z,...u}),Lc(e),Mc(n),t=Nc(t),s=Nc(s),o=Nc(o),r=Nc(r),c=Nc(c),h=Nc(h),l.privateKeys)throw Error("The `privateKeys` option has been removed from openpgp.sign, pass `signingKeys` instead");if(void 0!==l.armor)throw Error("The `armor` option has been removed from openpgp.sign, pass `format` instead.");const y=Object.keys(l);if(y.length>0)throw Error("Unknown option: "+y.join(", "));if(e instanceof Qc&&"binary"===n)throw Error("Cannot return signed cleartext message in binary format");if(e instanceof Qc&&i)throw Error("Cannot detach-sign a cleartext message");if(!t||0===t.length)throw Error("No signing keys provided");try{let l;if(l=i?await e.signDetached(t,r,void 0,s,a,o,c,h,u):await e.sign(t,r,void 0,s,a,o,c,h,u),"object"===n)return l;return l="armored"===n?l.armor(u):l.write(),i&&(l=P(e.packets.write(),(async(e,t)=>{await Promise.all([I(l,t),L(e).catch((()=>{}))])}))),await Oc(l)}catch(e){throw G.wrapError("Error signing message",e)}},exports.unarmor=se,exports.verify=async function({message:e,verificationKeys:t,expectSigned:r=!1,format:n="utf8",signature:i=null,date:s=new Date,config:a,...o}){if(Fc(a={...z,...a}),Lc(e),t=Nc(t),o.publicKeys)throw Error("The `publicKeys` option has been removed from openpgp.verify, pass `verificationKeys` instead");const c=Object.keys(o);if(c.length>0)throw Error("Unknown option: "+c.join(", "));if(e instanceof Qc&&"binary"===n)throw Error("Can't return cleartext message data as binary");if(e instanceof Qc&&i)throw Error("Can't verify detached cleartext signature");try{const o={};if(o.signatures=i?await e.verifyDetached(i,t,s,a):await e.verify(t,s,a),o.data="binary"===n?e.getLiteralData():e.getText(),e.fromStream&&!i&&Hc(o,e),r){if(0===o.signatures.length)throw Error("Message is not signed");o.data=B([o.data,T((async()=>{await G.anyPromise(o.signatures.map((e=>e.verified)))}))])}return o.data=await Oc(o.data),o}catch(e){throw G.wrapError("Error verifying signed message",e)}}; //# sourceMappingURL=openpgp.min.cjs.map