/*! OpenPGP.js v6.0.1 - 2024-11-21 - 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="undefined"!=typeof document?document.currentScript:null;function i(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 s(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 a=/*#__PURE__*/i(r);const o=Symbol("doneWritingPromise"),c=Symbol("doneWritingResolve"),h=Symbol("doneWritingReject"),u=Symbol("readingIndex");class l extends Array{constructor(){super(),Object.setPrototypeOf(this,l.prototype),this[o]=new Promise(((e,t)=>{this[c]=e,this[h]=t})),this[o].catch((()=>{}))}}function y(e){return e&&e.getReader&&Array.isArray(e)}function f(e){if(!y(e)){const t=e.getWriter(),r=t.releaseLock;return t.releaseLock=()=>{t.closed.catch((function(){})),r.call(t)},t}this.stream=e}function g(t){if(y(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 p(e){return Uint8Array.prototype.isPrototypeOf(e)}function d(e){if(1===e.length)return e[0];let t=0;for(let r=0;r(await this[o],this[u]===this.length?{value:void 0,done:!0}:{value:this[this[u]++],done:!1})}},l.prototype.readToEnd=async function(e){await this[o];const t=e(this.slice(this[u]));return this.length=0,t},l.prototype.clone=function(){const e=new l;return e[o]=this[o].then((()=>{e.push(...this)})),e},f.prototype.write=async function(e){this.stream.push(e)},f.prototype.close=async function(){this.stream[c]()},f.prototype.abort=async function(e){return this.stream[h](e),e},f.prototype.releaseLock=function(){},"object"==typeof e.process&&e.process.versions;const A=new WeakSet,w=Symbol("externalBuffer");function m(e){if(this.stream=e,e[w]&&(this[w]=e[w].slice()),y(e)){const t=e.getReader();return this._read=t.read.bind(t),this._releaseLock=()=>{},void(this._cancel=()=>{})}if(g(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||A.has(e)?{value:void 0,done:!0}:(t=!0,{value:e,done:!1}),this._releaseLock=()=>{if(t)try{A.add(e)}catch(e){}}}function b(e){return g(e)?e:new ReadableStream({start(t){t.enqueue(e),t.close()}})}function k(e){if(g(e))return e;const t=new l;return(async()=>{const r=M(t);await r.write(e),await r.close()})(),t}function E(e){return e.some((e=>g(e)&&!y(e)))?function(e){e=e.map(b);const t=I((async function(e){await Promise.all(n.map((t=>R(t,e))))}));let r=Promise.resolve();const n=e.map(((n,i)=>K(n,((n,s)=>(r=r.then((()=>v(n,t.writable,{preventClose:i!==e.length-1}))),r)))));return t.readable}(e):e.some((e=>y(e)))?function(e){const t=new l;let r=Promise.resolve();return e.forEach(((n,i)=>(r=r.then((()=>v(n,t,{preventClose:i!==e.length-1}))),r))),t}(e):"string"==typeof e[0]?e.join(""):d(e)}async function v(e,t,{preventClose:r=!1,preventAbort:n=!1,preventCancel:i=!1}={}){if(g(e)&&!y(e)){e=b(e);try{if(e[w]){const r=M(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 S(e,t=()=>{},r=()=>{}){if(y(e)){const n=new l;return(async()=>{const i=M(n);try{const n=await Q(e),s=t(n),a=r();let o;o=void 0!==s&&void 0!==a?E([s,a]):void 0!==s?s:a,await i.write(o),await i.close()}catch(e){await i.abort(e)}})(),n}if(g(e))return B(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?E([n,i]):void 0!==n?n:i}function K(e,t){if(g(e)&&!y(e)){let r;const n=new TransformStream({start(e){r=e}}),i=v(e,n.writable),s=I((async function(e){r.error(e),await i,await new Promise(setTimeout)}));return t(n.readable,s.writable),s.readable}e=k(e);const r=new l;return t(e,r),r}function C(e,t){let r;const n=K(e,((e,i)=>{const s=T(e);s.remainder=()=>(s.releaseLock(),v(e,i),n),r=t(s)}));return r}function P(e){if(y(e))return e.clone();if(g(e)){const t=function(e){if(y(e))throw Error("ArrayStream cannot be tee()d, use clone() instead");if(g(e)){const t=b(e).tee();return t[0][w]=t[1][w]=e[w],t}return[x(e),x(e)]}(e);return U(e,t[0]),t[1]}return x(e)}function D(e){return y(e)?P(e):g(e)?new ReadableStream({start(t){const r=K(e,(async(e,r)=>{const n=T(e),i=M(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)}}));U(e,r)}}):x(e)}function U(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 x(e,t=0,r=1/0){if(y(e))throw Error("Not implemented");if(g(e)){if(t>=0&&r>=0){let n=0;return B(e,{transform(e,i){n=t&&i.enqueue(x(e,Math.max(t-n,0),r-n)),n+=e.length):i.terminate()}})}if(t<0&&(r<0||r===1/0)){let n=[];return S(e,(e=>{e.length>=-t?n=[e]:n.push(e)}),(()=>x(E(n),t,r)))}if(0===t&&r<0){let n;return S(e,(e=>{const i=n?E([n,e]):e;if(i.length>=-r)return n=x(i,r),x(i,t,r);n=i}))}return console.warn(`stream.slice(input, ${t}, ${r}) not implemented efficiently.`),L((async()=>x(await Q(e),t,r)))}return e[w]&&(e=E(e[w].concat([e]))),p(e)?e.subarray(t,r===1/0?e.length:r):e.slice(t,r)}async function Q(e,t=E){return y(e)?e.readToEnd(t):g(e)?T(e).readToEnd(t):e}async function R(e,t){if(g(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 L(e){const t=new l;return(async()=>{const r=M(t);try{await r.write(await e()),await r.close()}catch(e){await r.abort(e)}})(),t}function T(e){return new m(e)}function M(e){return new f(e)}m.prototype.read=async function(){if(this[w]&&this[w].length){return{done:!1,value:this[w].shift()}}return this._read()},m.prototype.releaseLock=function(){this[w]&&(this.stream[w]=this[w]),this._releaseLock()},m.prototype.cancel=function(e){return this._cancel(e)},m.prototype.readLine=async function(){let e,t=[];for(;!e;){let{done:r,value:n}=await this.read();if(n+="",r)return t.length?E(t):void 0;const i=n.indexOf("\n")+1;i&&(e=E(t.concat(n.substr(0,i))),t=[]),i!==n.length&&t.push(n.substr(i))}return this.unshift(...t),e},m.prototype.readByte=async function(){const{done:e,value:t}=await this.read();if(e)return;const r=t[0];return this.unshift(x(t,1)),r},m.prototype.readBytes=async function(e){const t=[];let r=0;for(;;){const{done:n,value:i}=await this.read();if(n)return t.length?E(t):void 0;if(t.push(i),r+=i.length,r>=e){const r=E(t);return this.unshift(x(r,e)),x(r,0,e)}}},m.prototype.peekBytes=async function(e){const t=await this.readBytes(e);return this.unshift(t),t},m.prototype.unshift=function(...e){this[w]||(this[w]=[]),1===e.length&&p(e[0])&&this[w].length&&e[0].length&&this[w][0].byteOffset>=e[0].length?this[w][0]=new Uint8Array(this[w][0].buffer,this[w][0].byteOffset-e[0].length,this[w][0].byteLength+e[0].length):this[w].unshift(...e.filter((e=>e&&e.length)))},m.prototype.readToEnd=async function(e=E){const t=[];for(;;){const{done:e,value:r}=await this.read();if(e)break;t.push(r)}return e(t)};const N=Symbol("byValue");var F={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"},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},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,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[N]||(e[N]=[],Object.entries(e).forEach((([t,r])=>{e[N][r]=t}))),void 0!==e[N][t])return e[N][t];throw Error("Invalid enum value.")}},O={preferredHashAlgorithm:F.hash.sha512,preferredSymmetricAlgorithm:F.symmetric.aes256,preferredCompressionAlgorithm:F.compression.uncompressed,aeadProtect:!1,parseAEADEncryptedV4KeysAsLegacy:!1,preferredAEADAlgorithm:F.aead.gcm,aeadChunkSizeByte:12,v6Keys:!1,enableParsingV5Entities:!1,s2kType:F.s2k.iterated,s2kIterationCountByte:224,s2kArgon2Params:{passes:3,parallelism:4,memoryExponent:16},allowUnauthenticatedMessages:!1,allowUnauthenticatedStream:!1,minRSABits:2047,passwordCollisionCheck:!1,allowInsecureDecryptionWithSigningKeys:!1,allowInsecureVerificationWithReformattedKeys:!1,allowMissingKeyFlags:!1,constantTimePKCS1Decryption:!1,constantTimePKCS1DecryptionSupportedSymmetricAlgorithms:new Set([F.symmetric.aes128,F.symmetric.aes192,F.symmetric.aes256]),ignoreUnsupportedPackets:!0,ignoreMalformedPackets:!1,additionalAllowedPackets:[],showVersion:!1,showComment:!1,versionString:"OpenPGP.js 6.0.1",commentString:"https://openpgpjs.org",maxUserIDLength:5120,knownNotations:[],nonDeterministicSignaturesViaNotation:!0,useEllipticFallback:!0,rejectHashAlgorithms:new Set([F.hash.md5,F.hash.ripemd]),rejectMessageHashAlgorithms:new Set([F.hash.md5,F.hash.ripemd,F.hash.sha1]),rejectPublicKeyAlgorithms:new Set([F.publicKey.elgamal,F.publicKey.dsa]),rejectCurves:new Set([F.curve.secp256k1])};const H=(()=>{try{return"development"===process.env.NODE_ENV}catch(e){}return!1})(),z={isString:function(e){return"string"==typeof e||e instanceof String},nodeRequire:t.createRequire("undefined"==typeof document?require("url").pathToFileURL(__filename).href:n&&"SCRIPT"===n.tagName.toUpperCase()&&n.src||new URL("openpgp.min.cjs",document.baseURI).href),isArray:function(e){return e instanceof Array},isUint8Array:p,isStream:g,getNobleCurve:async(e,t)=>{if(!O.useEllipticFallback)throw Error("This curve is only supported in the full build of OpenPGP.js");const{nobleCurves:r}=await Promise.resolve().then((function(){return $u}));switch(e){case F.publicKey.ecdh:case F.publicKey.ecdsa:{const e=r.get(t);if(!e)throw Error("Unsupported curve");return e}case F.publicKey.x448:return r.get("x448");case F.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=z.readNumber(e);return new Date(1e3*t)},writeDate:function(e){const t=Math.floor(e.getTime()/1e3);return z.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 z.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=z.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 z.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 S(e,(e=>{if(!z.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 S(e,r,(()=>r(new Uint8Array,!0)))},concat:E,concatUint8Array:d,equalsUint8Array:function(e,t){if(!z.isUint8Array(e)||!z.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(!z.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 S(e,(e=>{let r;t&&(e=z.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 S(e,(e=>{let r;13===(e=t&&10!==e[0]?z.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=z.concatUint8Array([t,e]);const r=[],n=Math.floor(t.length/45),i=45*n,s=G(t.subarray(0,i));for(let e=0;et.length?G(t)+"\n":""))}function V(e){let t="";return S(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=j(t.substr(0,i));return t=t.substr(i),s}),(()=>j(t)))}function J(e){return V(e.replace(/-/g,"+").replace(/_/g,"/"))}function Y(e,t){let r=q(e).replace(/[\r\n]/g,"");return r=r.replace(/[+]/g,"-").replace(/[/]/g,"_").replace(/[=]/g,""),r}function W(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])?F.armor.multipartSection:/MESSAGE, PART \d+/.test(t[1])?F.armor.multipartLast:/SIGNED MESSAGE/.test(t[1])?F.armor.signed:/MESSAGE/.test(t[1])?F.armor.message:/PUBLIC KEY BLOCK/.test(t[1])?F.armor.publicKey:/PRIVATE KEY BLOCK/.test(t[1])?F.armor.privateKey:/SIGNATURE/.test(t[1])?F.armor.signature:void 0}function Z(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 $(e){const t=function(e){let t=13501623;return S(e,(e=>{const r=ee?Math.floor(e.length/4):0,n=new Uint32Array(e.buffer,e.byteOffset,r);for(let e=0;e>24&255]^X[1][t>>16&255]^X[2][t>>8&255]^X[3][255&t];for(let n=4*r;n>8^X[0][255&t^e[n]]}),(()=>new Uint8Array([t,t>>8,t>>16])))}(e);return q(t)}_?(G=e=>_.from(e).toString("base64"),j=e=>{const t=_.from(e,"base64");return new Uint8Array(t.buffer,t.byteOffset,t.byteLength)}):(G=e=>btoa(z.uint8ArrayToString(e)),j=e=>z.stringToUint8Array(atob(e)));const X=[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);X[0][e]=(16711680&t)>>16|65280&t|(255&t)<<16}for(let e=0;e<=255;e++)X[1][e]=X[0][e]>>8^X[0][255&X[0][e]];for(let e=0;e<=255;e++)X[2][e]=X[1][e]>>8^X[0][255&X[1][e]];for(let e=0;e<=255;e++)X[3][e]=X[2][e]>>8^X[0][255&X[2][e]];const ee=function(){const e=new ArrayBuffer(2);return new DataView(e).setInt16(0,255,!0),255===new Int16Array(e)[0]}();function te(e){for(let t=0;t=0&&r!==e.length-1&&(t=e.slice(0,r)),t}function ne(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=V(K(e,(async(e,y)=>{const f=T(e);try{for(;;){let e=await f.readLine();if(void 0===e)throw Error("Misformed armored text");if(e=z.removeTrailingSpaces(e.replace(/[\r\n]/g,"")),s)if(o)c||s!==F.armor.signed||(n.test(e)?(u=u.join("\r\n"),c=!0,te(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(te(h),o=!0,c||s!==F.armor.signed){t({text:u,data:l,headers:a,type:s});break}}else h.push(e);else n.test(e)&&(s=W(e))}}catch(e){return void r(e)}const g=M(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=z.removeTrailingSpaces(e.replace(/\r/g,""));const t=e.split(n);if(1===t.length)throw Error("Misformed armored text");const i=re(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=>(y(e.data)&&(e.data=await Q(e.data)),e)))}function ie(e,t,r,n,i,s=!1,a=O){let o,c;e===F.armor.signed&&(o=t.text,c=t.hash,t=t.data);const h=s&&D(t),u=[];switch(e){case F.armor.multipartSection:u.push("-----BEGIN PGP MESSAGE, PART "+r+"/"+n+"-----\n"),u.push(Z(i,a)),u.push(q(t)),h&&u.push("=",$(h)),u.push("-----END PGP MESSAGE, PART "+r+"/"+n+"-----\n");break;case F.armor.multipartLast:u.push("-----BEGIN PGP MESSAGE, PART "+r+"-----\n"),u.push(Z(i,a)),u.push(q(t)),h&&u.push("=",$(h)),u.push("-----END PGP MESSAGE, PART "+r+"-----\n");break;case F.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(Z(i,a)),u.push(q(t)),h&&u.push("=",$(h)),u.push("-----END PGP SIGNATURE-----\n");break;case F.armor.message:u.push("-----BEGIN PGP MESSAGE-----\n"),u.push(Z(i,a)),u.push(q(t)),h&&u.push("=",$(h)),u.push("-----END PGP MESSAGE-----\n");break;case F.armor.publicKey:u.push("-----BEGIN PGP PUBLIC KEY BLOCK-----\n"),u.push(Z(i,a)),u.push(q(t)),h&&u.push("=",$(h)),u.push("-----END PGP PUBLIC KEY BLOCK-----\n");break;case F.armor.privateKey:u.push("-----BEGIN PGP PRIVATE KEY BLOCK-----\n"),u.push(Z(i,a)),u.push(q(t)),h&&u.push("=",$(h)),u.push("-----END PGP PRIVATE KEY BLOCK-----\n");break;case F.armor.signature:u.push("-----BEGIN PGP SIGNATURE-----\n"),u.push(Z(i,a)),u.push(q(t)),h&&u.push("=",$(h)),u.push("-----END PGP SIGNATURE-----\n")}return z.concat(u)}async function se(e){switch(e){case F.symmetric.aes128:case F.symmetric.aes192:case F.symmetric.aes256:throw Error("Not a legacy cipher");case F.symmetric.cast5:case F.symmetric.blowfish:case F.symmetric.twofish:case F.symmetric.tripledes:{const{legacyCiphers:t}=await Promise.resolve().then((function(){return fl})),r=t.get(e);if(!r)throw Error("Unsupported cipher algorithm");return r}default:throw Error("Unsupported cipher algorithm")}}function ae(e){switch(e){case F.symmetric.aes128:case F.symmetric.aes192:case F.symmetric.aes256:case F.symmetric.twofish:return 16;case F.symmetric.blowfish:case F.symmetric.cast5:case F.symmetric.tripledes:return 8;default:throw Error("Unsupported cipher")}}function oe(e){switch(e){case F.symmetric.aes128:case F.symmetric.blowfish:case F.symmetric.cast5:return 16;case F.symmetric.aes192:case F.symmetric.tripledes:return 24;case F.symmetric.aes256:case F.symmetric.twofish:return 32;default:throw Error("Unsupported cipher")}}function ce(e){return{keySize:oe(e),blockSize:ae(e)}}var he=/*#__PURE__*/Object.freeze({__proto__:null,getCipherParams:ce,getLegacyCipher:se});function ue(e,t){let r=e[0],n=e[1],i=e[2],s=e[3];r=ye(r,n,i,s,t[0],7,-680876936),s=ye(s,r,n,i,t[1],12,-389564586),i=ye(i,s,r,n,t[2],17,606105819),n=ye(n,i,s,r,t[3],22,-1044525330),r=ye(r,n,i,s,t[4],7,-176418897),s=ye(s,r,n,i,t[5],12,1200080426),i=ye(i,s,r,n,t[6],17,-1473231341),n=ye(n,i,s,r,t[7],22,-45705983),r=ye(r,n,i,s,t[8],7,1770035416),s=ye(s,r,n,i,t[9],12,-1958414417),i=ye(i,s,r,n,t[10],17,-42063),n=ye(n,i,s,r,t[11],22,-1990404162),r=ye(r,n,i,s,t[12],7,1804603682),s=ye(s,r,n,i,t[13],12,-40341101),i=ye(i,s,r,n,t[14],17,-1502002290),n=ye(n,i,s,r,t[15],22,1236535329),r=fe(r,n,i,s,t[1],5,-165796510),s=fe(s,r,n,i,t[6],9,-1069501632),i=fe(i,s,r,n,t[11],14,643717713),n=fe(n,i,s,r,t[0],20,-373897302),r=fe(r,n,i,s,t[5],5,-701558691),s=fe(s,r,n,i,t[10],9,38016083),i=fe(i,s,r,n,t[15],14,-660478335),n=fe(n,i,s,r,t[4],20,-405537848),r=fe(r,n,i,s,t[9],5,568446438),s=fe(s,r,n,i,t[14],9,-1019803690),i=fe(i,s,r,n,t[3],14,-187363961),n=fe(n,i,s,r,t[8],20,1163531501),r=fe(r,n,i,s,t[13],5,-1444681467),s=fe(s,r,n,i,t[2],9,-51403784),i=fe(i,s,r,n,t[7],14,1735328473),n=fe(n,i,s,r,t[12],20,-1926607734),r=ge(r,n,i,s,t[5],4,-378558),s=ge(s,r,n,i,t[8],11,-2022574463),i=ge(i,s,r,n,t[11],16,1839030562),n=ge(n,i,s,r,t[14],23,-35309556),r=ge(r,n,i,s,t[1],4,-1530992060),s=ge(s,r,n,i,t[4],11,1272893353),i=ge(i,s,r,n,t[7],16,-155497632),n=ge(n,i,s,r,t[10],23,-1094730640),r=ge(r,n,i,s,t[13],4,681279174),s=ge(s,r,n,i,t[0],11,-358537222),i=ge(i,s,r,n,t[3],16,-722521979),n=ge(n,i,s,r,t[6],23,76029189),r=ge(r,n,i,s,t[9],4,-640364487),s=ge(s,r,n,i,t[12],11,-421815835),i=ge(i,s,r,n,t[15],16,530742520),n=ge(n,i,s,r,t[2],23,-995338651),r=pe(r,n,i,s,t[0],6,-198630844),s=pe(s,r,n,i,t[7],10,1126891415),i=pe(i,s,r,n,t[14],15,-1416354905),n=pe(n,i,s,r,t[5],21,-57434055),r=pe(r,n,i,s,t[12],6,1700485571),s=pe(s,r,n,i,t[3],10,-1894986606),i=pe(i,s,r,n,t[10],15,-1051523),n=pe(n,i,s,r,t[1],21,-2054922799),r=pe(r,n,i,s,t[8],6,1873313359),s=pe(s,r,n,i,t[15],10,-30611744),i=pe(i,s,r,n,t[6],15,-1560198380),n=pe(n,i,s,r,t[13],21,1309151649),r=pe(r,n,i,s,t[4],6,-145523070),s=pe(s,r,n,i,t[11],10,-1120210379),i=pe(i,s,r,n,t[2],15,718787259),n=pe(n,i,s,r,t[9],21,-343485551),e[0]=me(r,e[0]),e[1]=me(n,e[1]),e[2]=me(i,e[2]),e[3]=me(s,e[3])}function le(e,t,r,n,i,s){return t=me(me(t,e),me(n,s)),me(t<>>32-i,r)}function ye(e,t,r,n,i,s,a){return le(t&r|~t&n,e,t,i,s,a)}function fe(e,t,r,n,i,s,a){return le(t&n|r&~n,e,t,i,s,a)}function ge(e,t,r,n,i,s,a){return le(t^r^n,e,t,i,s,a)}function pe(e,t,r,n,i,s,a){return le(r^(t|~n),e,t,i,s,a)}function de(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 Ae="0123456789abcdef".split("");function we(e){let t="",r=0;for(;r<4;r++)t+=Ae[e>>8*r+4&15]+Ae[e>>8*r&15];return t}function me(e,t){return e+t&4294967295}const be=z.getWebCrypto(),ke=z.getNodeCrypto(),Ee=ke&&ke.getHashes();function ve(e){if(ke&&Ee.includes(e))return async function(t){const r=ke.createHash(e);return S(t,(e=>{r.update(e)}),(()=>new Uint8Array(r.digest())))}}function Be(e,t){const r=async()=>{const{nobleHashes:t}=await Promise.resolve().then((function(){return xl})),r=t.get(e);if(!r)throw Error("Unsupported hash");return r};return async function(e){if(y(e)&&(e=await Q(e)),z.isStream(e)){const t=(await r()).create();return S(e,(e=>{t.update(e)}),(()=>t.digest()))}if(be&&t)return new Uint8Array(await be.digest(t,e));return(await r())(e)}}var Ie={md5:ve("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)ue(r,de(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(ue(r,i),n=0;n<16;n++)i[n]=0;return i[14]=8*t,ue(r,i),r}(z.uint8ArrayToString(e));return z.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 Ce(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 Pe(e,t){Ke(e);const r=t.outputLen;if(e.lengthnew Uint8Array(e.buffer,e.byteOffset,e.byteLength),Ue=e=>new Uint32Array(e.buffer,e.byteOffset,Math.floor(e.byteLength/4)),xe=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 Qe(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(!Se(e))throw Error("Uint8Array expected, got "+typeof e);e=Ne(e)}return e}function Re(e,t){if(e.length!==t.length)return!1;let r=0;for(let n=0;n(Object.assign(t,e),t);function Te(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 Me(e){return e.byteOffset%4==0}function Ne(e){return Uint8Array.from(e)}function Fe(...e){for(let t=0;t(e>>>0&255)<<24|(e>>>8&255)<<16|(e>>>16&255)<<8|e>>>24&255;class Ge{constructor(e,t){this.blockLen=Oe,this.outputLen=Oe,this.s0=0,this.s1=0,this.s2=0,this.s3=0,this.finished=!1,Ke(e=Qe(e),16);const r=xe(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:_e(n),s1:_e(i),s2:_e(s),s3:_e(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=Qe(e),Ce(this);const t=Ue(e),r=Math.floor(e.length/Oe),n=e.length%Oe;for(let e=0;e>>1|r,r=(1&n)<<7}return e[0]^=225&-t,e}(Ne(e=Qe(e)));super(r,t),Fe(r)}update(e){e=Qe(e),Ce(this);const t=Ue(e),r=e.length%Oe,n=Math.floor(e.length/Oe);for(let e=0;ee(r,t.length).update(Qe(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 Ve=qe(((e,t)=>new Ge(e,t)));qe(((e,t)=>new je(e,t)));const Je=16,Ye=new Uint8Array(Je),We=283;function Ze(e){return e<<1^We&-(e>>7)}function $e(e,t){let r=0;for(;t>0;t>>=1)r^=e&-(1&t),e=Ze(e);return r}const Xe=/* @__PURE__ */(()=>{const e=new Uint8Array(256);for(let t=0,r=1;t<256;t++,r^=Ze(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 Fe(e),t})(),et=/* @__PURE__ */Xe.map(((e,t)=>Xe.indexOf(t))),tt=e=>e<<24|e>>>8,rt=e=>e<<8|e>>>24,nt=e=>e<<24&4278190080|e<<8&16711680|e>>>8&65280|e>>>24&255;function it(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(rt),i=n.map(rt),s=i.map(rt),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 st=/* @__PURE__ */it(Xe,(e=>$e(e,3)<<24|e<<16|e<<8|$e(e,2))),at=/* @__PURE__ */it(et,(e=>$e(e,11)<<24|$e(e,13)<<16|$e(e,9)<<8|$e(e,14))),ot=/* @__PURE__ */(()=>{const e=new Uint8Array(16);for(let t=0,r=1;t<16;t++,r=Ze(r))e[t]=r;return e})();function ct(e){Ke(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}=st,n=[];Me(e)||n.push(e=Ne(e));const i=Ue(e),s=i.length,a=e=>lt(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 Fe(...n),o}function ht(e){const t=ct(e),r=t.slice(),n=t.length,{sbox2:i}=st,{T0:s,T1:a,T2:o,T3:c}=at;for(let e=0;e>>8&255]^o[n>>>16&255]^c[n>>>24]}return r}function ut(e,t,r,n,i,s){return e[r<<8&65280|n>>>8&255]^t[i>>>8&65280|s>>>24&255]}function lt(e,t,r,n,i){return e[255&t|65280&r]|e[n>>>16&255|i>>>16&65280]<<16}function yt(e,t,r,n,i){const{sbox2:s,T01:a,T23:o}=st;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}=yt(e,a[0],a[1],a[2],a[3]))}const f=Je*Math.floor(l.length/4);if(f>>0,o.setUint32(u,y,t),({s0:f,s1:g,s2:p,s3:d}=yt(e,a[0],a[1],a[2],a[3]));const A=Je*Math.floor(c.length/4);if(Ar(e,t),decrypt:(e,t)=>r(e,t)}}));const wt=Le({blockSize:16,nonceLength:16},(function(e,t,r={}){Ke(e),Ke(t,16);const n=!r.disablePadding;return{encrypt(r,i){const s=ct(e),{b:a,o,out:c}=function(e,t,r){Ke(e);let n=e.length;const i=n%Je;if(!t&&0!==i)throw Error("aec/(cbc-ecb): unpadded plaintext with disabled padding");Me(e)||(e=Ne(e));const s=Ue(e);if(t){let e=Je-i;e||(e=Je),n+=e}const a=gt(n,r);return{b:s,o:Ue(a),out:a}}(r,n,i);let h=t;const u=[s];Me(h)||u.push(h=Ne(h));const l=Ue(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}=yt(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=Ue(t);t.set(e);const n=Je-e.length;for(let e=Je-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 bt=Le({blockSize:16,nonceLength:12,tagLength:16},(function(e,t,r){if(Ke(e),Ke(t),void 0!==r&&Ke(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=xe(o);i&&Te(c,0,BigInt(8*s),t),Te(c,8,BigInt(8*n.length),t),a.update(o);const h=a.digest();return Fe(o),h}(Ve,!1,e,n,r);for(let e=0;e=2**32)throw Error("plaintext should be less than 4gb");const r=ct(e);if(16===t.length)Et(r,t);else{const e=Ue(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=ht(e),n=t.length/8-1;if(1===n)vt(r,t);else{const e=Ue(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^=nt(a);const{s0:n,s1:o,s2:c,s3:h}=ft(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)}},It=new Uint8Array(8).fill(166),St=Le({blockSize:8},(e=>({encrypt(t){if(Ke(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 Ct.importKey("raw",this.key,r,!1,["encrypt"]);const n=await Ct.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=z.concatUint8Array([this.nextBlock,e.subarray(t,e.length-r)]),i=z.concatUint8Array([this.prevBlock,n.subarray(0,n.length-this.blockSize)]),s=await this._runCBC(i);return Rt(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),Rt(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);Rt(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(z.concatUint8Array([new Uint8Array(this.blockSize),e]),this.iv)).subarray(0,e.length);return Rt(t,e),this.clearSensitiveData(),t}}class Qt{constructor(e,t,r,n){this.forEncryption=e;const{blockSize:i}=ce(t);this.key=Kt.expandKeyLE(r),n.byteOffset%4!=0&&(n=n.slice()),this.prevBlock=Lt(n),this.nextBlock=new Uint8Array(i),this.i=0,this.blockSize=i}_runCFB(e){const t=Lt(e),r=new Uint8Array(e.length),n=Lt(r);for(let e=0;e+4<=n.length;e+=4){const{s0:r,s1:i,s2:s,s3:a}=Kt.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=z.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 Rt(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 Tt=/*#__PURE__*/Object.freeze({__proto__:null,decrypt:async function(e,t,r,n){const i=F.read(F.symmetric,e);if(Pt&&Ut[i])return function(e,t,r,n){const i=F.read(F.symmetric,e),s=new Pt.createDecipheriv(Ut[i],t,n);return S(r,(e=>new Uint8Array(s.update(e))))}(e,t,r,n);if(z.isAES(e))return async function(e,t,r,n){if(z.isStream(r)){const i=new Qt(!1,e,t,n);return S(r,(e=>i.processChunk(e)),(()=>i.finish()))}return mt(t,n).decrypt(r)}(e,t,r,n);const s=new(await se(e))(t),a=s.blockSize;let o=n,c=new Uint8Array;const h=e=>{e&&(c=z.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(z.isAES(e))return async function(e,t,r,n){if(Ct&&await xt.isSupported(e)){const i=new xt(e,t,n);return z.isStream(r)?S(r,(e=>i.encryptChunk(e)),(()=>i.finish())):i.encrypt(r)}if(z.isStream(r)){const i=new Qt(!0,e,t,n);return S(r,(e=>i.processChunk(e)),(()=>i.finish()))}return mt(t,n).encrypt(r)}(e,t,r,n);const a=new(await se(e))(t),o=a.blockSize,c=n.slice();let h=new Uint8Array;const u=e=>{e&&(h=z.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/rr|0;!function(e,t){const r=z.nbits(Math.max(e.length,t.length)/rr|0)-1;for(let e=n+1;e<=r;e++)o[e]=z.double(o[e-1]);n=r}(t,i);const c=z.concatUint8Array([or.subarray(0,15-r.length),cr,r]),h=63&c[15];c[15]&=192;const u=s(c),l=z.concatUint8Array([u,ar(u.subarray(0,8),u.subarray(1,9))]),y=z.shiftRight(l.subarray(0+(h>>3),17+(h>>3)),8-(7&h)).subarray(1),f=new Uint8Array(rr),g=new Uint8Array(t.length+nr);let p,d=0;for(p=0;p{r+=t[e>>4]+t[15&e]})),BigInt("0x0"+r)}function br(e,t){const r=e%t;return rAr;){const e=n≀n>>=wr;s=e?s*i%r:s,i=i*i%r}return s}function Er(e){return e>=Ar?e:-e}function vr(e,t){const{gcd:r,x:n}=function(e,t){let r=BigInt(0),n=BigInt(1),i=BigInt(1),s=BigInt(0),a=Er(e),o=Er(t);const c=eNumber.MAX_SAFE_INTEGER)throw Error("Number can only safely store up to 53 bits");return t}function Ir(e,t){return(e>>BigInt(t)&wr)===Ar?0:1}function Sr(e){const t=e>=wr)!==t;)r++;return r}function Kr(e){const t=e>=r)!==t;)n++;return n}function Cr(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=br(a,i<br(e,r)!==t))}(e)&&(!!function(e,t=BigInt(2)){return kr(t,e-Qr,e)===Qr}(e)&&!!function(e,t){const r=Sr(e);t||(t=Math.max(1,r/48|0));const n=e-Qr;let i=0;for(;!Ir(n,i);)i++;const s=e>>BigInt(i);for(;t>0;t--){let t,r=kr(Ur(BigInt(2),n),s,e);if(r!==Qr&&r!==n){for(t=1;tBigInt(e)));const Mr=[];function Nr(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 z.selectUint8Array(a,s,t);if(a)return s;throw Error("Decryption error")}function Or(e,t,r){let n;if(t.length!==Ie.getHashByteLength(e))throw Error("Invalid hash length");const i=new Uint8Array(Mr[e].length);for(n=0;n=t)throw Error("Data too large.");const c=br(n,s-Gr),h=br(n,i-Gr),u=Ur(BigInt(2),t),l=kr(vr(u,t),r,t);e=br(e*l,t);const y=kr(e,h,i),f=kr(e,c,s),g=br(a*(f-y),s);let p=g*i+y;return p=br(p*u,t),Fr(Cr(p,"be",Kr(t)),o)}(e,t,r,n,i,s,a,o)},encrypt:async function(e,t,r){return z.getNodeCrypto()?async function(e,t,r){const n=qr(t,r),i={key:n,format:"jwk",type:"pkcs1",padding:_r.constants.RSA_PKCS1_PADDING};return new Uint8Array(_r.publicEncrypt(i,e))}(e,t,r):async function(e,t,r){if(t=mr(t),e=mr(Nr(e,Kr(t))),r=mr(r),e>=t)throw Error("Message size cannot exceed modulus size");return Cr(kr(e,r,t),"be",Kr(t))}(e,t,r)},generate:async function(e,t){if(t=BigInt(t),z.getWebCrypto()){const r={name:"RSASSA-PKCS1-v1_5",modulusLength:e,publicExponent:Cr(t),hash:{name:"SHA-1"}},n=await zr.generateKey(r,!0,["sign","verify"]);return Vr(await zr.exportKey("jwk",n.privateKey),t)}if(z.getNodeCrypto()){const r={modulusLength:e,publicExponent:Br(t),publicKeyEncoding:{type:"pkcs1",format:"jwk"},privateKeyEncoding:{type:"pkcs1",format:"jwk"}},n=await new Promise(((e,t)=>{_r.generateKeyPair("rsa",r,((r,n,i)=>{r?t(r):e(i)}))}));return Vr(n,t)}let r,n,i;do{n=Rr(e-(e>>1),t,40),r=Rr(e>>1,t,40),i=r*n}while(Sr(i)!==e);const s=(r-Gr)*(n-Gr);return n=r.length)throw Error("Digest size cannot exceed key modulus size");if(t&&!z.isStream(t))if(z.getWebCrypto())try{return await async function(e,t,r,n,i,s,a,o){const c=await jr(r,n,i,s,a,o),h={name:"RSASSA-PKCS1-v1_5",hash:{name:e}},u=await zr.importKey("jwk",c,h,!1,["sign"]);return new Uint8Array(await zr.sign("RSASSA-PKCS1-v1_5",u,t))}(F.read(F.webHash,e),t,r,n,i,s,a,o)}catch(e){z.printDebugError(e)}else if(z.getNodeCrypto())return async function(e,t,r,n,i,s,a,o){const c=_r.createSign(F.read(F.hash,e));c.write(t),c.end();const h=await jr(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=mr(t);const i=mr(Or(e,n,Kr(t)));return r=mr(r),Cr(kr(i,r,t),"be",Kr(t))}(e,r,i,c)},validateParams:async function(e,t,r,n,i,s){if(e=mr(e),(n=mr(n))*(i=mr(i))!==e)return!1;const a=BigInt(2);if(br(n*(s=mr(s)),i)!==BigInt(1))return!1;t=mr(t),r=mr(r);const o=Ur(a,a<=r)throw Error("Signature size cannot exceed modulus size");const s=Cr(kr(t,n,r),"be",Kr(r)),a=Or(e,i,Kr(r));return z.equalsUint8Array(s,a)}(e,r,n,i,s)}});const Yr=BigInt(1);var Wr=/*#__PURE__*/Object.freeze({__proto__:null,decrypt:async function(e,t,r,n,i){return e=mr(e),t=mr(t),r=mr(r),Fr(Cr(br(vr(kr(e,n=mr(n),r),r)*t,r),"be",Kr(r)),i)},encrypt:async function(e,t,r,n){t=mr(t),r=mr(r),n=mr(n);const i=mr(Nr(e,Kr(t))),s=Ur(Yr,t-Yr);return{c1:Cr(kr(r,s,t)),c2:Cr(br(kr(n,s,t)*i,t))}},validateParams:async function(e,t,r,n){if(e=mr(e),t=mr(t),r=mr(r),t<=Yr||t>=e)return!1;const i=BigInt(Sr(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 yn(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 fn(e,t){var r;for(r=0;r<16;r++)e[r]=0|t[r]}function gn(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 pn(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 dn(e,t){var r,n,i,s=Xr(),a=Xr();for(r=0;r<16;r++)a[r]=t[r];for(gn(a),gn(a),gn(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,pn(a,s,1-i)}for(r=0;r<16;r++)e[2*r]=255&a[r],e[2*r+1]=a[r]>>8}function An(e,t){var r=new Uint8Array(32),n=new Uint8Array(32);return dn(r,e),dn(n,t),yn(r,0,n,0)}function wn(e){var t=new Uint8Array(32);return dn(t,e),1&t[0]}function mn(e,t){var r;for(r=0;r<16;r++)e[r]=t[2*r]+(t[2*r+1]<<8);e[15]&=32767}function bn(e,t,r){for(var n=0;n<16;n++)e[n]=t[n]+r[n]}function kn(e,t,r){for(var n=0;n<16;n++)e[n]=t[n]-r[n]}function En(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,D=0,U=0,x=0,Q=0,R=0,L=0,T=r[0],M=r[1],N=r[2],F=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],J=r[12],Y=r[13],W=r[14],Z=r[15];s+=(n=t[0])*T,a+=n*M,o+=n*N,c+=n*F,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*J,w+=n*Y,m+=n*W,b+=n*Z,a+=(n=t[1])*T,o+=n*M,c+=n*N,h+=n*F,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*J,m+=n*Y,b+=n*W,k+=n*Z,o+=(n=t[2])*T,c+=n*M,h+=n*N,u+=n*F,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*J,b+=n*Y,k+=n*W,E+=n*Z,c+=(n=t[3])*T,h+=n*M,u+=n*N,l+=n*F,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*J,k+=n*Y,E+=n*W,v+=n*Z,h+=(n=t[4])*T,u+=n*M,l+=n*N,y+=n*F,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*J,E+=n*Y,v+=n*W,B+=n*Z,u+=(n=t[5])*T,l+=n*M,y+=n*N,f+=n*F,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*J,v+=n*Y,B+=n*W,I+=n*Z,l+=(n=t[6])*T,y+=n*M,f+=n*N,g+=n*F,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*J,B+=n*Y,I+=n*W,S+=n*Z,y+=(n=t[7])*T,f+=n*M,g+=n*N,p+=n*F,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*J,I+=n*Y,S+=n*W,K+=n*Z,f+=(n=t[8])*T,g+=n*M,p+=n*N,d+=n*F,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*J,S+=n*Y,K+=n*W,C+=n*Z,g+=(n=t[9])*T,p+=n*M,d+=n*N,A+=n*F,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*J,K+=n*Y,C+=n*W,P+=n*Z,p+=(n=t[10])*T,d+=n*M,A+=n*N,w+=n*F,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*J,C+=n*Y,P+=n*W,D+=n*Z,d+=(n=t[11])*T,A+=n*M,w+=n*N,m+=n*F,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*J,P+=n*Y,D+=n*W,U+=n*Z,A+=(n=t[12])*T,w+=n*M,m+=n*N,b+=n*F,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*J,D+=n*Y,U+=n*W,x+=n*Z,w+=(n=t[13])*T,m+=n*M,b+=n*N,k+=n*F,E+=n*O,v+=n*H,B+=n*z,I+=n*_,S+=n*G,K+=n*j,C+=n*q,P+=n*V,D+=n*J,U+=n*Y,x+=n*W,Q+=n*Z,m+=(n=t[14])*T,b+=n*M,k+=n*N,E+=n*F,v+=n*O,B+=n*H,I+=n*z,S+=n*_,K+=n*G,C+=n*j,P+=n*q,D+=n*V,U+=n*J,x+=n*Y,Q+=n*W,R+=n*Z,b+=(n=t[15])*T,a+=38*(E+=n*N),o+=38*(v+=n*F),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*(D+=n*q),p+=38*(U+=n*V),d+=38*(x+=n*J),A+=38*(Q+=n*Y),w+=38*(R+=n*W),m+=38*(L+=n*Z),s=(n=(s+=38*(k+=n*M))+(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 vn(e,t){En(e,t,t)}function Bn(e,t){var r,n=Xr();for(r=0;r<16;r++)n[r]=t[r];for(r=253;r>=0;r--)vn(n,n),2!==r&&4!==r&&En(n,n,t);for(r=0;r<16;r++)e[r]=n[r]}function In(e,t,r){var n,i,s=new Uint8Array(32),a=new Float64Array(80),o=Xr(),c=Xr(),h=Xr(),u=Xr(),l=Xr(),y=Xr();for(i=0;i<31;i++)s[i]=t[i];for(s[31]=127&t[31]|64,s[0]&=248,mn(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)pn(o,c,n=s[i>>>3]>>>(7&i)&1),pn(h,u,n),bn(l,o,h),kn(o,o,h),bn(h,c,u),kn(c,c,u),vn(u,l),vn(y,o),En(o,h,o),En(h,c,l),bn(l,o,h),kn(o,o,h),vn(c,o),kn(h,u,y),En(o,h,sn),bn(o,o,u),En(h,h,o),En(o,u,y),En(u,c,a),vn(c,l),pn(o,c,n),pn(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 Bn(f,f),En(g,g,f),dn(e,g),0}function Sn(e,t){return In(e,t,tn)}var Kn=[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 Cn(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,D=new Int32Array(16),U=new Int32Array(16),x=e[0],Q=e[1],R=e[2],L=e[3],T=e[4],M=e[5],N=e[6],F=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],J=0;n>=128;){for(E=0;E<16;E++)v=8*E+J,D[E]=r[v+0]<<24|r[v+1]<<16|r[v+2]<<8|r[v+3],U[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=T,h=M,u=N,F,y=O,f=H,g=z,p=_,d=G,A=j,w=q,V,S=65535&(I=V),K=I>>>16,C=65535&(B=F),P=B>>>16,S+=65535&(I=(G>>>14|T<<18)^(G>>>18|T<<14)^(T>>>9|G<<23)),K+=I>>>16,C+=65535&(B=(T>>>14|G<<18)^(T>>>18|G<<14)^(G>>>9|T<<23)),P+=B>>>16,S+=65535&(I=G&j^~G&q),K+=I>>>16,C+=65535&(B=T&M^~T&N),P+=B>>>16,B=Kn[2*E],S+=65535&(I=Kn[2*E+1]),K+=I>>>16,C+=65535&B,P+=B>>>16,B=D[E%16],K+=(I=U[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,T=o=65535&(C+=(K+=(S+=65535&I)>>>16)>>>16)|(P+=C>>>16)<<16,M=c,N=h,F=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=D[v],S=65535&(I=U[v]),K=I>>>16,C=65535&B,P=B>>>16,B=D[(v+9)%16],S+=65535&(I=U[(v+9)%16]),K+=I>>>16,C+=65535&B,P+=B>>>16,b=D[(v+1)%16],S+=65535&(I=((k=U[(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=D[(v+14)%16],K+=(I=((k=U[(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,D[v]=65535&C|P<<16,U[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=T),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]=T=65535&C|P<<16,t[4]=G=65535&S|K<<16,S=65535&(I=j),K=I>>>16,C=65535&(B=M),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]=M=65535&C|P<<16,t[5]=j=65535&S|K<<16,S=65535&(I=q),K=I>>>16,C=65535&(B=N),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]=N=65535&C|P<<16,t[6]=q=65535&S|K<<16,S=65535&(I=V),K=I>>>16,C=65535&(B=F),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]=F=65535&C|P<<16,t[7]=V=65535&S|K<<16,J+=128,n-=128}return n}function Pn(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,Cn(i,s,t,r),r%=128,n=0;n=0;--i)Un(e,t,n=r[i/8|0]>>(7&i)&1),Dn(t,e),Dn(e,e),Un(e,t,n)}function Rn(e,t){var r=[Xr(),Xr(),Xr(),Xr()];fn(r[0],cn),fn(r[1],hn),fn(r[2],nn),En(r[3],cn,hn),Qn(e,r,t)}function Ln(e,t,r){var n,i=new Uint8Array(64),s=[Xr(),Xr(),Xr(),Xr()];for(r||en(t,32),Pn(i,t,32),i[0]&=248,i[31]&=127,i[31]|=64,Rn(s,i),xn(e,s),n=0;n<32;n++)t[n+32]=e[n];return 0}var Tn=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 Mn(e,t){var r,n,i,s;for(n=63;n>=32;--n){for(r=0,i=n-32,s=n-12;i>4)*Tn[i],r=t[i]>>8,t[i]&=255;for(i=0;i<32;i++)t[i]-=r*Tn[i];for(n=0;n<32;n++)t[n+1]+=t[n]>>8,e[n]=255&t[n]}function Nn(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;Mn(e,r)}function Fn(e,t){var r=Xr(),n=Xr(),i=Xr(),s=Xr(),a=Xr(),o=Xr(),c=Xr();return fn(e[2],nn),mn(e[1],t),vn(i,e[1]),En(s,i,an),kn(i,i,e[2]),bn(s,e[2],s),vn(a,s),vn(o,a),En(c,o,a),En(r,c,i),En(r,r,s),function(e,t){var r,n=Xr();for(r=0;r<16;r++)n[r]=t[r];for(r=250;r>=0;r--)vn(n,n),1!==r&&En(n,n,t);for(r=0;r<16;r++)e[r]=n[r]}(r,r),En(r,r,i),En(r,r,s),En(r,r,s),En(e[0],r,s),vn(n,e[0]),En(n,n,s),An(n,i)&&En(e[0],e[0],un),vn(n,e[0]),En(n,n,s),An(n,i)?-1:(wn(e[0])===t[31]>>7&&kn(e[0],rn,e[0]),En(e[3],e[0],e[1]),0)}var On=64;function Hn(){for(var e=0;e=0},$r.sign.keyPair=function(){var e=new Uint8Array(32),t=new Uint8Array(64);return Ln(e,t),{publicKey:e,secretKey:t}},$r.sign.keyPair.fromSecretKey=function(e){if(Hn(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 z.concatUint8Array([new Uint8Array([this.oid.length]),this.oid])}toHex(){return z.uint8ArrayToHex(this.oid)}getName(){const e=zn[this.toHex()];if(!e)throw Error("Unknown curve object identifier.");return e}}function Gn(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=z.readNumber(e.subarray(1,5)),t=5),{len:r,offset:t}}function jn(e){return e<192?new Uint8Array([e]):e>191&&e<8384?new Uint8Array([192+(e-192>>8),e-192&255]):z.concatUint8Array([new Uint8Array([255]),z.writeNumber(e,4)])}function qn(e){if(e<0||e>30)throw Error("Partial Length power must be between 1 and 30");return new Uint8Array([224+e])}function Vn(e){return new Uint8Array([192|e])}function Jn(e,t){return z.concatUint8Array([Vn(e),jn(t)])}function Yn(e){return[F.packet.literalData,F.packet.compressedData,F.packet.symmetricallyEncryptedData,F.packet.symEncryptedIntegrityProtectedData,F.packet.aeadEncryptedData].includes(e)}async function Wn(e,t){const r=T(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 y=Yn(h);let f,g=null;if(y){if("array"===z.isStream(e)){const e=new l;n=M(e),g=e}else{const e=new TransformStream;n=M(e.writable),g=e.readable}i=t({tag:h,packet:g})}else g=[];do{if(u){const e=await r.readByte();if(f=!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),f=!0,!y)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(f);const p=await r.peekBytes(y?1/0:2);return n?(await n.ready,await n.close()):(g=z.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 Zn extends Error{constructor(...e){super(...e),Error.captureStackTrace&&Error.captureStackTrace(this,Zn),this.name="UnsupportedError"}}class $n extends Zn{constructor(...e){super(...e),Error.captureStackTrace&&Error.captureStackTrace(this,Zn),this.name="UnknownPacketError"}}class Xn{constructor(e,t){this.tag=e,this.rawContent=t}write(){return this.rawContent}}async function ei(e){switch(e){case F.publicKey.ed25519:try{const e=z.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(J(n.x)),seed:J(r.d)}}catch(t){if("NotSupportedError"!==t.name&&"OperationError"!==t.name)throw t;const r=Dr(ni(e)),{publicKey:n}=$r.sign.keyPair.fromSeed(r);return{A:n,seed:r}}case F.publicKey.ed448:{const e=await z.getNobleCurve(F.publicKey.ed448),t=e.utils.randomPrivateKey();return{A:e.getPublicKey(t),seed:t}}default:throw Error("Unsupported EdDSA algorithm")}}async function ti(e,t,r,n,i,s){if(Ie.getHashByteLength(t){if(e===F.publicKey.ed25519){return{kty:"OKP",crv:"Ed25519",x:Y(t),ext:!0}}throw Error("Unsupported EdDSA algorithm")},ai=(e,t,r)=>{if(e===F.publicKey.ed25519){const n=si(e,t);return n.d=Y(r),n}throw Error("Unsupported EdDSA algorithm")};var oi=/*#__PURE__*/Object.freeze({__proto__:null,generate:ei,getPayloadSize:ni,getPreferredHashAlgo:ii,sign:ti,validateParams:async function(e,t,r){switch(e){case F.publicKey.ed25519:{const{publicKey:e}=$r.sign.keyPair.fromSeed(r);return z.equalsUint8Array(t,e)}case F.publicKey.ed448:{const e=(await z.getNobleCurve(F.publicKey.ed448)).getPublicKey(r);return z.equalsUint8Array(t,e)}default:return!1}},verify:ri});const ci=z.getWebCrypto();async function hi(e,t,r){const{keySize:n}=ce(e);if(!z.isAES(e)||t.length!==n)throw Error("Unexpected algorithm or key size");try{const e=await ci.importKey("raw",t,{name:"AES-KW"},!1,["wrapKey"]),n=await ci.importKey("raw",r,{name:"HMAC",hash:"SHA-256"},!0,["sign"]),i=await ci.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;z.printDebugError("Browser did not support operation: "+e.message)}return St(t).encrypt(r)}async function ui(e,t,r){const{keySize:n}=ce(e);if(!z.isAES(e)||t.length!==n)throw Error("Unexpected algorithm or key size");let i;try{i=await ci.importKey("raw",t,{name:"AES-KW"},!1,["unwrapKey"])}catch(e){if("NotSupportedError"!==e.name&&(24!==t.length||"OperationError"!==e.name))throw e;return z.printDebugError("Browser did not support operation: "+e.message),St(t).decrypt(r)}try{const e=await ci.unwrapKey("raw",r,i,{name:"AES-KW"},{name:"HMAC",hash:"SHA-256"},!0,["sign"]);return new Uint8Array(await ci.exportKey("raw",e))}catch(e){if("OperationError"===e.name)throw Error("Key Data Integrity failed");throw e}}var li=/*#__PURE__*/Object.freeze({__proto__:null,unwrap:ui,wrap:hi});const yi=z.getWebCrypto();async function fi(e,t,r,n,i){const s=F.read(F.webHash,e);if(!s)throw Error("Hash algo not supported with HKDF");const a=await yi.importKey("raw",t,"HKDF",!1,["deriveBits"]),o=await yi.deriveBits({name:"HKDF",hash:s,salt:r,info:n},a,8*i);return new Uint8Array(o)}const gi={x25519:z.encodeUTF8("OpenPGP X25519"),x448:z.encodeUTF8("OpenPGP X448")};async function pi(e){switch(e){case F.publicKey.x25519:{const e=Dr(32),{publicKey:t}=$r.box.keyPair.fromSecretKey(e);return{A:t,k:e}}case F.publicKey.x448:{const e=await z.getNobleCurve(F.publicKey.x448),t=e.utils.randomPrivateKey();return{A:e.getPublicKey(t),k:t}}default:throw Error("Unsupported ECDH algorithm")}}function di(e){switch(e){case F.publicKey.x25519:return 32;case F.publicKey.x448:return 56;default:throw Error("Unsupported ECDH algorithm")}}async function Ai(e,t){switch(e){case F.publicKey.x25519:{const r=Dr(di(e)),n=$r.scalarMult(r,t);mi(n);const{publicKey:i}=$r.box.keyPair.fromSecretKey(r);return{ephemeralPublicKey:i,sharedSecret:n}}case F.publicKey.x448:{const e=await z.getNobleCurve(F.publicKey.x448),r=e.utils.randomPrivateKey(),n=e.getSharedSecret(r,t);mi(n);return{ephemeralPublicKey:e.getPublicKey(r),sharedSecret:n}}default:throw Error("Unsupported ECDH algorithm")}}async function wi(e,t,r,n){switch(e){case F.publicKey.x25519:{const e=$r.scalarMult(n,t);return mi(e),e}case F.publicKey.x448:{const e=(await z.getNobleCurve(F.publicKey.x448)).getSharedSecret(n,t);return mi(e),e}default:throw Error("Unsupported ECDH algorithm")}}function mi(e){let t=0;for(let r=0;r0===s[0]&&Ni(a,r,s.subarray(1),i);if(n&&!z.isStream(n))switch(a.type){case"web":try{const e=await async function(e,t,{r,s:n},i,s){const a=xi(e.payloadSize,vi[e.name],s),o=await Ri.importKey("jwk",a,{name:"ECDSA",namedCurve:vi[e.name],hash:{name:F.read(F.webHash,e.hash)}},!1,["verify"]),c=z.concatUint8Array([r,n]).buffer;return Ri.verify({name:"ECDSA",namedCurve:vi[e.name],hash:{name:F.read(F.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;z.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=z.nodeRequire("eckey-utils"),o=z.getNodeBuffer(),{publicKey:c}=a.generateDer({curveName:Ii[e.name],publicKey:o.from(s)}),h=Li.createVerify(F.read(F.hash,t));h.write(i),h.end();const u=z.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 Ni(a,r,s,i)||o()}async function Ni(e,t,r,n){return(await z.getNobleCurve(F.publicKey.ecdsa,e.name)).verify(z.concatUint8Array([t.r,t.s]),r,n,{lowS:!1})}var Fi=/*#__PURE__*/Object.freeze({__proto__:null,sign:Ti,validateParams:async function(e,t,r){const n=new Ki(e);if(n.keyType!==F.publicKey.ecdsa)return!1;switch(n.type){case"web":case"node":{const n=Dr(8),i=F.hash.sha256,s=await Ie.digest(i,n);try{const a=await Ti(e,i,n,t,r,s);return await Mi(e,i,a,n,t,s)}catch(e){return!1}}default:return Ci(F.publicKey.ecdsa,e,t,r)}},verify:Mi});var Oi=/*#__PURE__*/Object.freeze({__proto__:null,sign:async function(e,t,r,n,i,s){if(Pi(new Ki(e),n),Ie.getHashByteLength(t)0){const r=e[t-1];if(r>=1){const n=e.subarray(t-r),i=new Uint8Array(r).fill(r);if(z.equalsUint8Array(n,i))return e.subarray(0,t-r)}}throw Error("Invalid padding")}var _i=/*#__PURE__*/Object.freeze({__proto__:null,decode:zi,encode:Hi});const Gi=z.getWebCrypto(),ji=z.getNodeCrypto();function qi(e,t,r,n){return z.concatUint8Array([t.write(),new Uint8Array([e]),r.write(),z.stringToUint8Array("Anonymous Sender "),n])}async function Vi(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 Ie.digest(e,z.concatUint8Array([new Uint8Array([0,0,0,1]),t,n]))).subarray(0,r)}async function Ji(e,t){switch(e.type){case"curve25519Legacy":{const{sharedSecret:r,ephemeralPublicKey:n}=await Ai(F.publicKey.x25519,t.subarray(1));return{publicKey:z.concatUint8Array([new Uint8Array([e.wireFormatLeadingByte]),n]),sharedKey:r}}case"web":if(e.web&&z.getWebCrypto())try{return await async function(e,t){const r=xi(e.payloadSize,e.web,t);let n=Gi.generateKey({name:"ECDH",namedCurve:e.web},!0,["deriveKey","deriveBits"]),i=Gi.importKey("jwk",r,{name:"ECDH",namedCurve:e.web},!1,[]);[n,i]=await Promise.all([n,i]);let s=Gi.deriveBits({name:"ECDH",namedCurve:e.web,public:i},n.privateKey,e.sharedSize),a=Gi.exportKey("jwk",n.publicKey);[s,a]=await Promise.all([s,a]);const o=new Uint8Array(s),c=new Uint8Array(Ui(a,e.wireFormatLeadingByte));return{publicKey:c,sharedKey:o}}(e,t)}catch(r){return z.printDebugError(r),Zi(e,t)}break;case"node":return async function(e,t){const r=ji.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 Zi(e,t)}}async function Yi(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 wi(F.publicKey.x25519,t.subarray(1),r.subarray(1),e)}}case"web":if(e.web&&z.getWebCrypto())try{return await async function(e,t,r,n){const i=Qi(e.payloadSize,e.web,r,n);let s=Gi.importKey("jwk",i,{name:"ECDH",namedCurve:e.web},!0,["deriveKey","deriveBits"]);const a=xi(e.payloadSize,e.web,t);let o=Gi.importKey("jwk",a,{name:"ECDH",namedCurve:e.web},!0,[]);[s,o]=await Promise.all([s,o]);let c=Gi.deriveBits({name:"ECDH",namedCurve:e.web,public:o},s,e.sharedSize),h=Gi.exportKey("jwk",s);[c,h]=await Promise.all([c,h]);const u=new Uint8Array(c);return{secretKey:J(h.d),sharedKey:u}}(e,t,r,n)}catch(r){return z.printDebugError(r),Wi(e,t,n)}break;case"node":return async function(e,t,r){const n=ji.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 Wi(e,t,n)}}async function Wi(e,t,r){return{secretKey:r,sharedKey:(await z.getNobleCurve(F.publicKey.ecdh,e.name)).getSharedSecret(r,t).subarray(1)}}async function Zi(e,t){const r=await z.getNobleCurve(F.publicKey.ecdh,e.name),{publicKey:n,privateKey:i}=await e.genKeyPair();return{publicKey:n,sharedKey:r.getSharedSecret(i,t).subarray(1)}}var $i=/*#__PURE__*/Object.freeze({__proto__:null,decrypt:async function(e,t,r,n,i,s,a){const o=new Ki(e);Pi(o,i),Pi(o,r);const{sharedKey:c}=await Yi(o,r,i,s),h=qi(F.publicKey.ecdh,e,t,a),{keySize:u}=ce(t.cipher);let l;for(let e=0;e<3;e++)try{const r=await Vi(t.hash,c,u,h,1===e,2===e);return zi(await ui(t.cipher,r,n))}catch(e){l=e}throw l},encrypt:async function(e,t,r,n,i){const s=Hi(r),a=new Ki(e);Pi(a,n);const{publicKey:o,sharedKey:c}=await Ji(a,n),h=qi(F.publicKey.ecdh,e,t,i),{keySize:u}=ce(t.cipher),l=await Vi(t.hash,c,u,h);return{publicKey:o,wrappedKey:await hi(t.cipher,l,s)}},validateParams:async function(e,t,r){return Ci(F.publicKey.ecdh,e,t,r)}}),Xi=/*#__PURE__*/Object.freeze({__proto__:null,CurveWithOID:Ki,ecdh:$i,ecdhX:bi,ecdsa:Fi,eddsa:oi,eddsaLegacy:Oi,generate:async function(e){const t=new Ki(e),{oid:r,hash:n,cipher:i}=t,s=await t.genKeyPair();return{oid:r,Q:s.publicKey,secret:z.leftPad(s.privateKey,t.payloadSize),hash:n,cipher:i}},getPreferredHashAlgo:function(e){return Si[e.getName()].hash}});const es=BigInt(0),ts=BigInt(1);var rs=/*#__PURE__*/Object.freeze({__proto__:null,sign:async function(e,t,r,n,i,s){const a=BigInt(0);let o,c,h,u;n=mr(n),i=mr(i),r=mr(r),s=mr(s),r=br(r,n),s=br(s,i);const l=br(mr(t.subarray(0,Kr(i))),i);for(;;){if(o=Ur(ts,i),c=br(kr(r,o,n),i),c===a)continue;const e=br(s*c,i);if(u=br(l+e,i),h=br(vr(o,i)*u,i),h!==a)break}return{r:Cr(c,"be",Kr(n)),s:Cr(h,"be",Kr(n))}},validateParams:async function(e,t,r,n,i){if(e=mr(e),t=mr(t),r=mr(r),n=mr(n),r<=ts||r>=e)return!1;if(br(e-ts,t)!==es)return!1;if(kr(r,t,e)!==ts)return!1;const s=BigInt(Sr(t));if(s=a||r<=es||r>=a)return z.printDebug("invalid DSA Signature"),!1;const c=br(mr(n.subarray(0,Kr(a))),a),h=vr(r,a);if(h===es)return z.printDebug("invalid DSA Signature"),!1;i=br(i,s),o=br(o,s);const u=br(c*h,a),l=br(t*h,a);return br(br(kr(i,u,s)*kr(o,l,s),s),a)===t}}),ns={rsa:Jr,elgamal:Wr,elliptic:Xi,dsa:rs};var is=/*#__PURE__*/Object.freeze({__proto__:null,parseSignatureParams:function(e,t){let r=0;switch(e){case F.publicKey.rsaEncryptSign:case F.publicKey.rsaEncrypt:case F.publicKey.rsaSign:{const e=z.readMPI(t.subarray(r));return r+=e.length+2,{read:r,signatureParams:{s:e}}}case F.publicKey.dsa:case F.publicKey.ecdsa:{const e=z.readMPI(t.subarray(r));r+=e.length+2;const n=z.readMPI(t.subarray(r));return r+=n.length+2,{read:r,signatureParams:{r:e,s:n}}}case F.publicKey.eddsaLegacy:{const e=z.readMPI(t.subarray(r));r+=e.length+2;const n=z.readMPI(t.subarray(r));return r+=n.length+2,{read:r,signatureParams:{r:e,s:n}}}case F.publicKey.ed25519:case F.publicKey.ed448:{const n=2*ns.elliptic.eddsa.getPayloadSize(e),i=z.readExactSubarray(t,r,r+n);return r+=i.length,{read:r,signatureParams:{RS:i}}}default:throw new Zn("Unknown signature algorithm.")}},sign:async function(e,t,r,n,i,s){if(!r||!n)throw Error("Missing key parameters");switch(e){case F.publicKey.rsaEncryptSign:case F.publicKey.rsaEncrypt:case F.publicKey.rsaSign:{const{n:e,e:a}=r,{d:o,p:c,q:h,u}=n;return{s:await ns.rsa.sign(t,i,e,a,o,c,h,u,s)}}case F.publicKey.dsa:{const{g:e,p:i,q:a}=r,{x:o}=n;return ns.dsa.sign(t,s,e,i,a,o)}case F.publicKey.elgamal:throw Error("Signing with Elgamal is not defined in the OpenPGP standard.");case F.publicKey.ecdsa:{const{oid:e,Q:a}=r,{d:o}=n;return ns.elliptic.ecdsa.sign(e,t,i,a,o,s)}case F.publicKey.eddsaLegacy:{const{oid:e,Q:a}=r,{seed:o}=n;return ns.elliptic.eddsaLegacy.sign(e,t,i,a,o,s)}case F.publicKey.ed25519:case F.publicKey.ed448:{const{A:a}=r,{seed:o}=n;return ns.elliptic.eddsa.sign(e,t,i,a,o,s)}default:throw Error("Unknown signature algorithm.")}},verify:async function(e,t,r,n,i,s){switch(e){case F.publicKey.rsaEncryptSign:case F.publicKey.rsaEncrypt:case F.publicKey.rsaSign:{const{n:e,e:a}=n,o=z.leftPad(r.s,e.length);return ns.rsa.verify(t,i,o,e,a,s)}case F.publicKey.dsa:{const{g:e,p:i,q:a,y:o}=n,{r:c,s:h}=r;return ns.dsa.verify(t,c,h,s,e,i,a,o)}case F.publicKey.ecdsa:{const{oid:e,Q:a}=n,o=new ns.elliptic.CurveWithOID(e).payloadSize,c=z.leftPad(r.r,o),h=z.leftPad(r.s,o);return ns.elliptic.ecdsa.verify(e,t,{r:c,s:h},i,a,s)}case F.publicKey.eddsaLegacy:{const{oid:e,Q:a}=n,o=new ns.elliptic.CurveWithOID(e).payloadSize,c=z.leftPad(r.r,o),h=z.leftPad(r.s,o);return ns.elliptic.eddsaLegacy.verify(e,t,{r:c,s:h},i,a,s)}case F.publicKey.ed25519:case F.publicKey.ed448:{const{A:a}=n;return ns.elliptic.eddsa.verify(e,t,r,i,a,s)}default:throw Error("Unknown signature algorithm.")}}});class ss{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 z.concatUint8Array([new Uint8Array([this.data.length]),this.data])}}class as{constructor(e){if(e){const{hash:t,cipher:r}=e;this.hash=t,this.cipher=r}else this.hash=null,this.cipher=null}read(e){if(e.length<4||3!==e[0]||1!==e[1])throw new Zn("Cannot read KDFParams");return this.hash=e[2],this.cipher=e[3],4}write(){return new Uint8Array([3,1,this.hash,this.cipher])}}class os{static fromObject({wrappedKey:e,algorithm:t}){const r=new os;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=z.readExactSubarray(e,t,t+r),t+=r}write(){return z.concatUint8Array([this.algorithm?new Uint8Array([this.wrappedKey.length+1,this.algorithm]):new Uint8Array([this.wrappedKey.length]),this.wrappedKey])}}function cs(e){try{e.getName()}catch(e){throw new Zn("Unknown curve OID")}}function hs(e,t){switch(e){case F.publicKey.ecdsa:case F.publicKey.ecdh:case F.publicKey.eddsaLegacy:return new ns.elliptic.CurveWithOID(t).payloadSize;case F.publicKey.ed25519:case F.publicKey.ed448:return ns.elliptic.eddsa.getPayloadSize(e);case F.publicKey.x25519:case F.publicKey.x448:return ns.elliptic.ecdhX.getPayloadSize(e);default:throw Error("Unknown elliptic algo")}}var us=/*#__PURE__*/Object.freeze({__proto__:null,generateParams:function(e,t,r){switch(e){case F.publicKey.rsaEncrypt:case F.publicKey.rsaEncryptSign:case F.publicKey.rsaSign:return ns.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 F.publicKey.ecdsa:return ns.elliptic.generate(r).then((({oid:e,Q:t,secret:r})=>({privateParams:{d:r},publicParams:{oid:new _n(e),Q:t}})));case F.publicKey.eddsaLegacy:return ns.elliptic.generate(r).then((({oid:e,Q:t,secret:r})=>({privateParams:{seed:r},publicParams:{oid:new _n(e),Q:t}})));case F.publicKey.ecdh:return ns.elliptic.generate(r).then((({oid:e,Q:t,secret:r,hash:n,cipher:i})=>({privateParams:{d:r},publicParams:{oid:new _n(e),Q:t,kdfParams:new as({hash:n,cipher:i})}})));case F.publicKey.ed25519:case F.publicKey.ed448:return ns.elliptic.eddsa.generate(e).then((({A:e,seed:t})=>({privateParams:{seed:t},publicParams:{A:e}})));case F.publicKey.x25519:case F.publicKey.x448:return ns.elliptic.ecdhX.generate(e).then((({A:e,k:t})=>({privateParams:{k:t},publicParams:{A:e}})));case F.publicKey.dsa:case F.publicKey.elgamal:throw Error("Unsupported algorithm for key generation.");default:throw Error("Unknown public key algorithm.")}},generateSessionKey:function(e){const{keySize:t}=ce(e);return Dr(t)},getAEADMode:function(e){const t=F.read(F.aead,e);return dr[t]},getCipherParams:ce,getCurvePayloadSize:hs,getPreferredCurveHashAlgo:function(e,t){switch(e){case F.publicKey.ecdsa:case F.publicKey.eddsaLegacy:return ns.elliptic.getPreferredHashAlgo(t);case F.publicKey.ed25519:case F.publicKey.ed448:return ns.elliptic.eddsa.getPreferredHashAlgo(e);default:throw Error("Unknown elliptic signing algo")}},getPrefixRandom:async function(e){const{blockSize:t}=ce(e),r=await Dr(t),n=new Uint8Array([r[r.length-2],r[r.length-1]]);return z.concat([r,n])},parseEncSessionKeyParams:function(e,t){let r=0;switch(e){case F.publicKey.rsaEncrypt:case F.publicKey.rsaEncryptSign:return{c:z.readMPI(t.subarray(r))};case F.publicKey.elgamal:{const e=z.readMPI(t.subarray(r));r+=e.length+2;return{c1:e,c2:z.readMPI(t.subarray(r))}}case F.publicKey.ecdh:{const e=z.readMPI(t.subarray(r));r+=e.length+2;const n=new ss;return n.read(t.subarray(r)),{V:e,C:n}}case F.publicKey.x25519:case F.publicKey.x448:{const n=hs(e),i=z.readExactSubarray(t,r,r+n);r+=i.length;const s=new os;return s.read(t.subarray(r)),{ephemeralPublicKey:i,C:s}}default:throw new Zn("Unknown public key encryption algorithm.")}},parsePrivateKeyParams:function(e,t,r){let n=0;switch(e){case F.publicKey.rsaEncrypt:case F.publicKey.rsaEncryptSign:case F.publicKey.rsaSign:{const e=z.readMPI(t.subarray(n));n+=e.length+2;const r=z.readMPI(t.subarray(n));n+=r.length+2;const i=z.readMPI(t.subarray(n));n+=i.length+2;const s=z.readMPI(t.subarray(n));return n+=s.length+2,{read:n,privateParams:{d:e,p:r,q:i,u:s}}}case F.publicKey.dsa:case F.publicKey.elgamal:{const e=z.readMPI(t.subarray(n));return n+=e.length+2,{read:n,privateParams:{x:e}}}case F.publicKey.ecdsa:case F.publicKey.ecdh:{const i=hs(e,r.oid);let s=z.readMPI(t.subarray(n));return n+=s.length+2,s=z.leftPad(s,i),{read:n,privateParams:{d:s}}}case F.publicKey.eddsaLegacy:{const i=hs(e,r.oid);if(r.oid.getName()!==F.curve.ed25519Legacy)throw Error("Unexpected OID for eddsaLegacy");let s=z.readMPI(t.subarray(n));return n+=s.length+2,s=z.leftPad(s,i),{read:n,privateParams:{seed:s}}}case F.publicKey.ed25519:case F.publicKey.ed448:{const r=hs(e),i=z.readExactSubarray(t,n,n+r);return n+=i.length,{read:n,privateParams:{seed:i}}}case F.publicKey.x25519:case F.publicKey.x448:{const r=hs(e),i=z.readExactSubarray(t,n,n+r);return n+=i.length,{read:n,privateParams:{k:i}}}default:throw new Zn("Unknown public key encryption algorithm.")}},parsePublicKeyParams:function(e,t){let r=0;switch(e){case F.publicKey.rsaEncrypt:case F.publicKey.rsaEncryptSign:case F.publicKey.rsaSign:{const e=z.readMPI(t.subarray(r));r+=e.length+2;const n=z.readMPI(t.subarray(r));return r+=n.length+2,{read:r,publicParams:{n:e,e:n}}}case F.publicKey.dsa:{const e=z.readMPI(t.subarray(r));r+=e.length+2;const n=z.readMPI(t.subarray(r));r+=n.length+2;const i=z.readMPI(t.subarray(r));r+=i.length+2;const s=z.readMPI(t.subarray(r));return r+=s.length+2,{read:r,publicParams:{p:e,q:n,g:i,y:s}}}case F.publicKey.elgamal:{const e=z.readMPI(t.subarray(r));r+=e.length+2;const n=z.readMPI(t.subarray(r));r+=n.length+2;const i=z.readMPI(t.subarray(r));return r+=i.length+2,{read:r,publicParams:{p:e,g:n,y:i}}}case F.publicKey.ecdsa:{const e=new _n;r+=e.read(t),cs(e);const n=z.readMPI(t.subarray(r));return r+=n.length+2,{read:r,publicParams:{oid:e,Q:n}}}case F.publicKey.eddsaLegacy:{const e=new _n;if(r+=e.read(t),cs(e),e.getName()!==F.curve.ed25519Legacy)throw Error("Unexpected OID for eddsaLegacy");let n=z.readMPI(t.subarray(r));return r+=n.length+2,n=z.leftPad(n,33),{read:r,publicParams:{oid:e,Q:n}}}case F.publicKey.ecdh:{const e=new _n;r+=e.read(t),cs(e);const n=z.readMPI(t.subarray(r));r+=n.length+2;const i=new as;return r+=i.read(t.subarray(r)),{read:r,publicParams:{oid:e,Q:n,kdfParams:i}}}case F.publicKey.ed25519:case F.publicKey.ed448:case F.publicKey.x25519:case F.publicKey.x448:{const n=z.readExactSubarray(t,r,r+hs(e));return r+=n.length,{read:r,publicParams:{A:n}}}default:throw new Zn("Unknown public key encryption algorithm.")}},publicKeyDecrypt:async function(e,t,r,n,i,s){switch(e){case F.publicKey.rsaEncryptSign:case F.publicKey.rsaEncrypt:{const{c:e}=n,{n:i,e:a}=t,{d:o,p:c,q:h,u}=r;return ns.rsa.decrypt(e,i,a,o,c,h,u,s)}case F.publicKey.elgamal:{const{c1:e,c2:i}=n,a=t.p,o=r.x;return ns.elgamal.decrypt(e,i,a,o,s)}case F.publicKey.ecdh:{const{oid:e,Q:s,kdfParams:a}=t,{d:o}=r,{V:c,C:h}=n;return ns.elliptic.ecdh.decrypt(e,a,c,h.data,s,o,i)}case F.publicKey.x25519:case F.publicKey.x448:{const{A:i}=t,{k:s}=r,{ephemeralPublicKey:a,C:o}=n;if(null!==o.algorithm&&!z.isAES(o.algorithm))throw Error("AES session key expected");return ns.elliptic.ecdhX.decrypt(e,a,o.wrappedKey,i,s)}default:throw Error("Unknown public key encryption algorithm.")}},publicKeyEncrypt:async function(e,t,r,n,i){switch(e){case F.publicKey.rsaEncrypt:case F.publicKey.rsaEncryptSign:{const{n:e,e:t}=r;return{c:await ns.rsa.encrypt(n,e,t)}}case F.publicKey.elgamal:{const{p:e,g:t,y:i}=r;return ns.elgamal.encrypt(n,e,t,i)}case F.publicKey.ecdh:{const{oid:e,Q:t,kdfParams:s}=r,{publicKey:a,wrappedKey:o}=await ns.elliptic.ecdh.encrypt(e,s,n,t,i);return{V:a,C:new ss(o)}}case F.publicKey.x25519:case F.publicKey.x448:{if(t&&!z.isAES(t))throw Error("X25519 and X448 keys can only encrypt AES session keys");const{A:i}=r,{ephemeralPublicKey:s,wrappedKey:a}=await ns.elliptic.ecdhX.encrypt(e,n,i);return{ephemeralPublicKey:s,C:os.fromObject({algorithm:t,wrappedKey:a})}}default:return[]}},serializeParams:function(e,t){const r=new Set([F.publicKey.ed25519,F.publicKey.x25519,F.publicKey.ed448,F.publicKey.x448]),n=Object.keys(t).map((n=>{const i=t[n];return z.isUint8Array(i)?r.has(e)?i:z.uint8ArrayToMPI(i):i.write()}));return z.concatUint8Array(n)},validateParams:async function(e,t,r){if(!t||!r)throw Error("Missing key parameters");switch(e){case F.publicKey.rsaEncrypt:case F.publicKey.rsaEncryptSign:case F.publicKey.rsaSign:{const{n:e,e:n}=t,{d:i,p:s,q:a,u:o}=r;return ns.rsa.validateParams(e,n,i,s,a,o)}case F.publicKey.dsa:{const{p:e,q:n,g:i,y:s}=t,{x:a}=r;return ns.dsa.validateParams(e,n,i,s,a)}case F.publicKey.elgamal:{const{p:e,g:n,y:i}=t,{x:s}=r;return ns.elgamal.validateParams(e,n,i,s)}case F.publicKey.ecdsa:case F.publicKey.ecdh:{const n=ns.elliptic[F.read(F.publicKey,e)],{oid:i,Q:s}=t,{d:a}=r;return n.validateParams(i,s,a)}case F.publicKey.eddsaLegacy:{const{Q:e,oid:n}=t,{seed:i}=r;return ns.elliptic.eddsaLegacy.validateParams(n,e,i)}case F.publicKey.ed25519:case F.publicKey.ed448:{const{A:n}=t,{seed:i}=r;return ns.elliptic.eddsa.validateParams(e,n,i)}case F.publicKey.x25519:case F.publicKey.x448:{const{A:n}=t,{k:i}=r;return ns.elliptic.ecdhX.validateParams(e,n,i)}default:throw Error("Unknown public key algorithm.")}}});const ls={cipher:he,hash:Ie,mode:dr,publicKey:ns,signature:is,random:xr,pkcs1:Hr,pkcs5:_i,aesKW:li};Object.assign(ls,us);class ys extends Error{constructor(...e){super(...e),Error.captureStackTrace&&Error.captureStackTrace(this,ys),this.name="Argon2OutOfMemoryError"}}let fs,gs;class ps{constructor(e=O){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=ls.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([F.write(F.s2k,this.type)]),this.salt,new Uint8Array([this.t,this.p,this.encodedM])];return z.concatUint8Array(e)}async produceKey(e,t){const r=2<1048576&&(gs=fs(),gs.catch((()=>{}))),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 ys("Could not allocate required memory for Argon2"):e}}}class ds{constructor(e,t=O){this.algorithm=F.hash.sha256,this.type=F.read(F.s2k,e),this.c=t.s2kIterationCountByte,this.salt=null}generateSalt(){switch(this.type){case"salted":case"iterated":this.salt=ls.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"!==z.uint8ArrayToString(e.subarray(t,t+3)))throw new Zn("Unknown s2k type.");t+=3;if(1001!==1e3+e[t++])throw new Zn("Unknown s2k gnu protection mode.");this.type="gnu-dummy";break;default:throw new Zn("Unknown s2k type.")}return t}write(){if("gnu-dummy"===this.type)return new Uint8Array([101,0,...z.stringToUint8Array("GNU"),1]);const e=[new Uint8Array([F.write(F.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 z.concatUint8Array(e)}async produceKey(e,t){e=z.encodeUTF8(e);const r=[];let n=0,i=0;for(;n>>1|(21845&Ls)<<1;Ts=(61680&(Ts=(52428&Ts)>>>2|(13107&Ts)<<2))>>>4|(3855&Ts)<<4,Rs[Ls]=((65280&Ts)>>>8|(255&Ts)<<8)>>>1}var Ms=function(e,t,r){for(var n=e.length,i=0,s=new Es(t);i>>c]=h}else for(a=new Es(n),i=0;i>>15-e[i]);return a},Ns=new ks(288);for(Ls=0;Ls<144;++Ls)Ns[Ls]=8;for(Ls=144;Ls<256;++Ls)Ns[Ls]=9;for(Ls=256;Ls<280;++Ls)Ns[Ls]=7;for(Ls=280;Ls<288;++Ls)Ns[Ls]=8;var Fs=new ks(32);for(Ls=0;Ls<32;++Ls)Fs[Ls]=5;var Os=/*#__PURE__*/Ms(Ns,9,0),Hs=/*#__PURE__*/Ms(Ns,9,1),zs=/*#__PURE__*/Ms(Fs,5,0),_s=/*#__PURE__*/Ms(Fs,5,1),Gs=function(e){for(var t=e[0],r=1;rt&&(t=e[r]);return t},js=function(e,t,r){var n=t/8|0;return(e[n]|e[n+1]<<8)>>(7&t)&r},qs=function(e,t){var r=t/8|0;return(e[r]|e[r+1]<<8|e[r+2]<<16)>>(7&t)},Vs=function(e){return(e+7)/8|0},Js=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?Es:4==e.BYTES_PER_ELEMENT?vs:ks)(r-t);return n.set(e.subarray(t,r)),n},Ys=["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"],Ws=function(e,t,r){var n=Error(t||Ys[e]);if(n.code=e,Error.captureStackTrace&&Error.captureStackTrace(n,Ws),!r)throw n;return n},Zs=function(e,t,r){r<<=7&t;var n=t/8|0;e[n]|=r,e[n+1]|=r>>>8},$s=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},Xs=function(e,t){for(var r=[],n=0;ny&&(y=s[n].s);var f=new Es(y+1),g=ea(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 ks(f),g]},ea=function(e,t,r){return-1==e.s?Math.max(ea(e.l,t,r+1),ea(e.r,t,r+1)):t[e.s]=r},ta=function(e){for(var t=e.length;t&&!e[--t];);for(var r=new Es(++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]},ra=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[Ss[C-1]];--C);var P,D,U,x,Q=h+5<<3,R=ra(i,Ns)+ra(s,Fs)+a,L=ra(i,y)+ra(s,p)+a+14+3*C+ra(v,S)+(2*v[16]+3*v[17]+7*v[18]);if(Q<=R&&Q<=L)return na(t,u,e.subarray(c,c+h));if(Zs(t,u,1+(L15&&(Zs(t,u,F[B]>>>5&127),u+=F[B]>>>12)}}}else P=Os,D=Ns,U=zs,x=Fs;for(B=0;B255){O=n[B]>>>18&31;$s(t,u,P[O+257]),u+=D[O+257],O>7&&(Zs(t,u,n[B]>>>23&31),u+=Bs[O]);var H=31&n[B];$s(t,u,U[H]),u+=x[H],H>3&&($s(t,u,n[B]>>>5&8191),u+=Is[H])}else $s(t,u,P[n[B]]),u+=D[n[B]];return $s(t,u,P[256]),u+D[256]},sa=/*#__PURE__*/new vs([65540,131080,131088,131104,262176,1048704,1048832,2114560,2117632]),aa=/*#__PURE__*/new ks(0),oa=function(e,t,r,n,i){return function(e,t,r,n,i,s){var a=e.length,o=new ks(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=na(c,h+1,e.subarray(u,l))}else{for(var y=sa[t-1],f=y>>>13,g=8191&y,p=(1<7e3||S>24576)&&x>423){h=ia(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,T=g,M=D-U&32767;if(x>2&&P==b(u-M))for(var N=Math.min(f,x)-1,F=Math.min(32767,u),O=Math.min(258,x);M<=F&&--T&&D!=U;){if(e[u+R]==e[u+R-M]){for(var H=0;HR){if(R=H,L=M,H>N)break;var z=Math.min(M,H-2),_=0;for(Q=0;Q_&&(_=j,U=G)}}}M+=(D=U)-(U=d[D])+32768&32767}if(L){k[S++]=268435456|Ds[R]<<18|Qs[L];var q=31&Ds[R],V=31&Qs[L];I+=Bs[q]+Is[V],++E[257+q],++v[V],K=u+R,++B}else k[S++]=e[u],++E[e[u]]}}h=ia(e,c,s,k,E,v,I,S,C,u-C,h),!s&&7&h&&(h=na(c,h+1,aa))}return Js(o,0,n+Vs(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)},ca=/*#__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(oa(e,this.o,0,0,!t),t)},e.prototype.push=function(e,t){this.ondata||Ws(5),this.d&&Ws(4),this.d=t,this.p(e,t||!1)},e}(),ha=/*#__PURE__*/function(){function e(e){this.s={},this.p=new ks(0),this.ondata=e}return e.prototype.e=function(e){this.ondata||Ws(5),this.d&&Ws(4);var t=this.p.length,r=new ks(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 ks(0);var i=!t||r,s=!r||r.i;r||(r={}),t||(t=new ks(3*n));var a=function(e){var r=t.length;if(e>r){var n=new ks(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=js(e,c,1);var p=js(e,c+1,3);if(c+=3,!p){var d=e[(K=Vs(c)+4)-4]|e[K-3]<<8,A=K+d;if(A>n){s&&Ws(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=Hs,l=_s,y=9,f=5;else if(2==p){var w=js(e,c,31)+257,m=js(e,c+10,15)+4,b=w+js(e,c+5,31)+1;c+=14;for(var k=new ks(b),E=new ks(19),v=0;v>>4)<16)k[v++]=K;else{var P=0,D=0;for(16==K?(D=3+js(e,c,3),c+=2,P=k[v-1]):17==K?(D=3+js(e,c,7),c+=3):18==K&&(D=11+js(e,c,127),c+=7);D--;)k[v++]=P}}var U=k.subarray(0,w),x=k.subarray(w);y=Gs(U),f=Gs(x),u=Ms(U,y,1),l=Ms(x,f,1)}else Ws(1);if(c>g){s&&Ws(0);break}}i&&a(h+131072);for(var Q=(1<>>4;if((c+=15&P)>g){s&&Ws(0);break}if(P||Ws(2),T<256)t[h++]=T;else{if(256==T){L=c,u=null;break}var M=T-254;if(T>264){var N=Bs[v=T-257];M=js(e,c,(1<>>4;if(F||Ws(3),c+=15&F,x=xs[O],O>3&&(N=Is[O],x+=qs(e,c)&(1<g){s&&Ws(0);break}i&&a(h+131072);for(var H=h+M;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,ca.call(this,e,t)}return e.prototype.push=function(e,t){ca.prototype.push.call(this,e,t)},e.prototype.p=function(e,t){this.c.p(e);var r=oa(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}(),la=/*#__PURE__*/function(){function e(e){this.v=1,ha.call(this,e)}return e.prototype.push=function(e,t){if(ha.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&&Ws(6,"invalid zlib data"),this.p=this.p.subarray(0,-4)),ha.prototype.c.call(this,t)},e}(),ya="undefined"!=typeof TextDecoder&&/*#__PURE__*/new TextDecoder;try{ya.decode(aa,{stream:!0}),1}catch(e){}class fa{static get tag(){return F.packet.literalData}constructor(e=new Date){this.format=F.literal.utf8,this.date=z.normalizeDate(e),this.text=null,this.data=null,this.filename=""}setText(e,t=F.literal.utf8){this.format=t,this.text=e,this.data=null}getText(e=!1){return(null===this.text||z.isStream(this.text))&&(this.text=z.decodeUTF8(z.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=z.canonicalizeEOL(z.encodeUTF8(this.text))),e?D(this.data):this.data}setFilename(e){this.filename=e}getFilename(){return this.filename}async read(e){await C(e,(async e=>{const t=await e.readByte(),r=await e.readByte();this.filename=z.decodeUTF8(await e.readBytes(r)),this.date=z.readDate(await e.readBytes(4));let n=e.remainder();y(n)&&(n=await Q(n)),this.setBytes(n,t)}))}writeHeader(){const e=z.encodeUTF8(this.filename),t=new Uint8Array([e.length]),r=new Uint8Array([this.format]),n=z.writeDate(this.date);return z.concatUint8Array([r,t,e,n])}write(){const e=this.writeHeader(),t=this.getBytes();return z.concat([e,t])}}class ga{constructor(){this.bytes=""}read(e){return this.bytes=z.uint8ArrayToString(e.subarray(0,8)),this.bytes.length}write(){return z.stringToUint8Array(this.bytes)}toHex(){return z.uint8ArrayToHex(z.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 ga;return t.read(z.hexToUint8Array(e)),t}static wildcard(){const e=new ga;return e.read(new Uint8Array(8)),e}}const pa=Symbol("verified"),da="salt@notations.openpgpjs.org",Aa=new Set([F.signatureSubpacket.issuerKeyID,F.signatureSubpacket.issuerFingerprint,F.signatureSubpacket.embeddedSignature]);class wa{static get tag(){return F.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 ga,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[pa]=null}read(e,t=O){let r=0;if(this.version=e[r++],5===this.version&&!t.enableParsingV5Entities)throw new Zn("Support for v5 entities is disabled; turn on `config.enableParsingV5Entities` if needed");if(4!==this.version&&5!==this.version&&6!==this.version)throw new Zn(`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}=ls.signature.parseSignatureParams(this.publicKeyAlgorithm,n);if(ils.serializeParams(this.publicKeyAlgorithm,await this.params))):ls.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()),z.concat(e)}async sign(e,t,r=new Date,n=!1,i){this.version=e.version,this.created=z.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=ba(this.hashAlgorithm);if(null===this.salt)this.salt=ls.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===da)).length)throw Error("Unexpected existing salt notation");{const e=ls.random.getRandomBytes(ba(this.hashAlgorithm));this.rawNotations.push({name:da,value:e,humanReadable:!1,critical:!1})}}s.push(this.writeHashedSubPackets()),this.unhashedSubpackets=[],this.signatureData=z.concat(s);const a=this.toHash(this.signatureType,t,n),o=await this.hash(this.signatureType,t,a,n);this.signedHashValue=x(P(o),0,2);const c=async()=>ls.signature.sign(this.publicKeyAlgorithm,this.hashAlgorithm,e.publicParams,e.privateParams,a,await Q(o));z.isStream(o)?this.params=c():(this.params=await c(),this[pa]=!0)}writeHashedSubPackets(){const e=F.signatureSubpacket,t=[];let r;if(null===this.created)throw Error("Missing signature creation time");t.push(ma(e.signatureCreationTime,!0,z.writeDate(this.created))),null!==this.signatureExpirationTime&&t.push(ma(e.signatureExpirationTime,!0,z.writeNumber(this.signatureExpirationTime,4))),null!==this.exportable&&t.push(ma(e.exportableCertification,!0,new Uint8Array([this.exportable?1:0]))),null!==this.trustLevel&&(r=new Uint8Array([this.trustLevel,this.trustAmount]),t.push(ma(e.trustSignature,!0,r))),null!==this.regularExpression&&t.push(ma(e.regularExpression,!0,this.regularExpression)),null!==this.revocable&&t.push(ma(e.revocable,!0,new Uint8Array([this.revocable?1:0]))),null!==this.keyExpirationTime&&t.push(ma(e.keyExpirationTime,!0,z.writeNumber(this.keyExpirationTime,4))),null!==this.preferredSymmetricAlgorithms&&(r=z.stringToUint8Array(z.uint8ArrayToString(this.preferredSymmetricAlgorithms)),t.push(ma(e.preferredSymmetricAlgorithms,!1,r))),null!==this.revocationKeyClass&&(r=new Uint8Array([this.revocationKeyClass,this.revocationKeyAlgorithm]),r=z.concat([r,this.revocationKeyFingerprint]),t.push(ma(e.revocationKey,!1,r))),!this.issuerKeyID.isNull()&&this.issuerKeyVersion<5&&t.push(ma(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=z.encodeUTF8(n);r.push(z.writeNumber(o.length,2)),r.push(z.writeNumber(i.length,2)),r.push(o),r.push(i),r=z.concat(r),t.push(ma(e.notationData,a,r))})),null!==this.preferredHashAlgorithms&&(r=z.stringToUint8Array(z.uint8ArrayToString(this.preferredHashAlgorithms)),t.push(ma(e.preferredHashAlgorithms,!1,r))),null!==this.preferredCompressionAlgorithms&&(r=z.stringToUint8Array(z.uint8ArrayToString(this.preferredCompressionAlgorithms)),t.push(ma(e.preferredCompressionAlgorithms,!1,r))),null!==this.keyServerPreferences&&(r=z.stringToUint8Array(z.uint8ArrayToString(this.keyServerPreferences)),t.push(ma(e.keyServerPreferences,!1,r))),null!==this.preferredKeyServer&&t.push(ma(e.preferredKeyServer,!1,z.encodeUTF8(this.preferredKeyServer))),null!==this.isPrimaryUserID&&t.push(ma(e.primaryUserID,!1,new Uint8Array([this.isPrimaryUserID?1:0]))),null!==this.policyURI&&t.push(ma(e.policyURI,!1,z.encodeUTF8(this.policyURI))),null!==this.keyFlags&&(r=z.stringToUint8Array(z.uint8ArrayToString(this.keyFlags)),t.push(ma(e.keyFlags,!0,r))),null!==this.signersUserID&&t.push(ma(e.signersUserID,!1,z.encodeUTF8(this.signersUserID))),null!==this.reasonForRevocationFlag&&(r=z.stringToUint8Array(String.fromCharCode(this.reasonForRevocationFlag)+this.reasonForRevocationString),t.push(ma(e.reasonForRevocation,!0,r))),null!==this.features&&(r=z.stringToUint8Array(z.uint8ArrayToString(this.features)),t.push(ma(e.features,!1,r))),null!==this.signatureTargetPublicKeyAlgorithm&&(r=[new Uint8Array([this.signatureTargetPublicKeyAlgorithm,this.signatureTargetHashAlgorithm])],r.push(z.stringToUint8Array(this.signatureTargetHash)),r=z.concat(r),t.push(ma(e.signatureTarget,!0,r))),null!==this.embeddedSignature&&t.push(ma(e.embeddedSignature,!0,this.embeddedSignature.write())),null!==this.issuerFingerprint&&(r=[new Uint8Array([this.issuerKeyVersion]),this.issuerFingerprint],r=z.concat(r),t.push(ma(e.issuerFingerprint,this.version>=5,r))),null!==this.preferredAEADAlgorithms&&(r=z.stringToUint8Array(z.uint8ArrayToString(this.preferredAEADAlgorithms)),t.push(ma(e.preferredAEADAlgorithms,!1,r))),null!==this.preferredCipherSuites&&(r=new Uint8Array([].concat(...this.preferredCipherSuites)),t.push(ma(e.preferredCipherSuites,!1,r)));const n=z.concat(t),i=z.writeNumber(n.length,6===this.version?4:2);return z.concat([i,n])}writeUnhashedSubPackets(){const e=this.unhashedSubpackets.map((({type:e,critical:t,body:r})=>ma(e,t,r))),t=z.concat(e),r=z.writeNumber(t.length,6===this.version?4:2);return z.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)}),Aa.has(i)))switch(i){case F.signatureSubpacket.signatureCreationTime:this.created=z.readDate(e.subarray(r,e.length));break;case F.signatureSubpacket.signatureExpirationTime:{const t=z.readNumber(e.subarray(r,e.length));this.signatureNeverExpires=0===t,this.signatureExpirationTime=t;break}case F.signatureSubpacket.exportableCertification:this.exportable=1===e[r++];break;case F.signatureSubpacket.trustSignature:this.trustLevel=e[r++],this.trustAmount=e[r++];break;case F.signatureSubpacket.regularExpression:this.regularExpression=e[r];break;case F.signatureSubpacket.revocable:this.revocable=1===e[r++];break;case F.signatureSubpacket.keyExpirationTime:{const t=z.readNumber(e.subarray(r,e.length));this.keyExpirationTime=t,this.keyNeverExpires=0===t;break}case F.signatureSubpacket.preferredSymmetricAlgorithms:this.preferredSymmetricAlgorithms=[...e.subarray(r,e.length)];break;case F.signatureSubpacket.revocationKey:this.revocationKeyClass=e[r++],this.revocationKeyAlgorithm=e[r++],this.revocationKeyFingerprint=e.subarray(r,r+20);break;case F.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 F.signatureSubpacket.notationData:{const t=!!(128&e[r]);r+=4;const i=z.readNumber(e.subarray(r,r+2));r+=2;const s=z.readNumber(e.subarray(r,r+2));r+=2;const a=z.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]=z.decodeUTF8(o));break}case F.signatureSubpacket.preferredHashAlgorithms:this.preferredHashAlgorithms=[...e.subarray(r,e.length)];break;case F.signatureSubpacket.preferredCompressionAlgorithms:this.preferredCompressionAlgorithms=[...e.subarray(r,e.length)];break;case F.signatureSubpacket.keyServerPreferences:this.keyServerPreferences=[...e.subarray(r,e.length)];break;case F.signatureSubpacket.preferredKeyServer:this.preferredKeyServer=z.decodeUTF8(e.subarray(r,e.length));break;case F.signatureSubpacket.primaryUserID:this.isPrimaryUserID=0!==e[r++];break;case F.signatureSubpacket.policyURI:this.policyURI=z.decodeUTF8(e.subarray(r,e.length));break;case F.signatureSubpacket.keyFlags:this.keyFlags=[...e.subarray(r,e.length)];break;case F.signatureSubpacket.signersUserID:this.signersUserID=z.decodeUTF8(e.subarray(r,e.length));break;case F.signatureSubpacket.reasonForRevocation:this.reasonForRevocationFlag=e[r++],this.reasonForRevocationString=z.decodeUTF8(e.subarray(r,e.length));break;case F.signatureSubpacket.features:this.features=[...e.subarray(r,e.length)];break;case F.signatureSubpacket.signatureTarget:{this.signatureTargetPublicKeyAlgorithm=e[r++],this.signatureTargetHashAlgorithm=e[r++];const t=ls.getHashByteLength(this.signatureTargetHashAlgorithm);this.signatureTargetHash=z.uint8ArrayToString(e.subarray(r,r+t));break}case F.signatureSubpacket.embeddedSignature:this.embeddedSignature=new wa,this.embeddedSignature.read(e.subarray(r,e.length));break;case F.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 F.signatureSubpacket.preferredAEADAlgorithms:this.preferredAEADAlgorithms=[...e.subarray(r,e.length)];break;case F.signatureSubpacket.preferredCipherSuites:this.preferredCipherSuites=[];for(let t=r;t{r+=e.length}),(()=>{const n=[];return 5!==this.version||this.signatureType!==F.signature.binary&&this.signatureType!==F.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(z.writeNumber(r,4)),z.concat(n)}))}toHash(e,t,r=!1){const n=this.toSign(e,t);return z.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!==ba(this.hashAlgorithm))throw Error("Signature salt does not have the expected length");return r||(r=this.toHash(e,t,n)),ls.hash.digest(this.hashAlgorithm,r)}async verify(e,t,r,n=new Date,i=!1,s=O){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===F.signature.binary||t===F.signature.text;if(!(this[pa]&&!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 Q(s),this.signedHashValue[0]!==s[0]||this.signedHashValue[1]!==s[1])throw Error("Signed digest did not match");if(this.params=await this.params,this[pa]=await ls.signature.verify(this.publicKeyAlgorithm,this.hashAlgorithm,this.params,e.publicParams,n,s),!this[pa])throw Error("Signature verification failed")}const o=z.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: "+F.read(F.hash,this.hashAlgorithm).toUpperCase());if(s.rejectMessageHashAlgorithms.has(this.hashAlgorithm)&&[F.signature.binary,F.signature.text].includes(this.signatureType))throw Error("Insecure message hash algorithm: "+F.read(F.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=z.normalizeDate(e);return null!==t&&!(this.created<=t&&twa.prototype.calculateTrailer.apply(await this.correspondingSig,e)))}async verify(){const e=await this.correspondingSig;if(!e||e.constructor.tag!==F.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&&!z.equalsUint8Array(e.issuerFingerprint,this.issuerFingerprint)||6===this.version&&!z.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 Ea(e,t){if(!t[e]){let t;try{t=F.read(F.packet,e)}catch(t){throw new $n("Unknown packet type with tag: "+e)}throw Error("Packet not allowed in this context: "+t)}return new t[e]}ka.prototype.hash=wa.prototype.hash,ka.prototype.toHash=wa.prototype.toHash,ka.prototype.toSign=wa.prototype.toSign;class va extends Array{static async fromBinary(e,t,r=O){const n=new va;return await n.read(e,t,r),n}async read(e,t,r=O){r.additionalAllowedPackets.length&&(t={...t,...z.constructAllowedPackets(r.additionalAllowedPackets)}),this.stream=K(e,(async(e,n)=>{const i=M(n);try{for(;;){await i.ready;if(await Wn(e,(async e=>{try{if(e.tag===F.packet.marker||e.tag===F.packet.trust||e.tag===F.packet.padding)return;const n=Ea(e.tag,t);n.packets=new va,n.fromStream=z.isStream(e.packet),await n.read(e.packet,r),await i.write(n)}catch(t){if(t instanceof $n){if(!(e.tag<=39))return;await i.abort(t)}const n=!r.ignoreUnsupportedPackets&&t instanceof Zn,s=!(r.ignoreMalformedPackets||t instanceof Zn);if(n||s||Yn(e.tag))await i.abort(t);else{const t=new Xn(e.tag,e.packet);await i.write(t)}z.printDebugError(t)}})))return await i.ready,void await i.close()}}catch(e){await i.abort(e)}}));const n=T(this.stream);for(;;){const{done:e,value:t}=await n.read();if(e?this.stream=null:this.push(t),e||Yn(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=z.concat([qn(e)].concat(t));return t=[n.subarray(1+r)],i=t[0].length,n.subarray(0,1+r)}}),(()=>z.concat([jn(i)].concat(t)))))}else{if(z.isStream(n)){let t=0;e.push(S(P(n),(e=>{t+=e.length}),(()=>Jn(r,t))))}else e.push(Jn(r,n.length));e.push(n)}}return z.concat(e)}filterByTag(...e){const t=new va,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(),z.concat([new Uint8Array([this.algorithm]),this.compressed])}async decompress(e=O){const t=F.read(F.compression,this.algorithm),r=Da[t];if(!r)throw Error(t+" decompression not supported");this.packets=await va.fromBinary(await r(this.compressed),Ba,e)}compress(){const e=F.read(F.compression,this.algorithm),t=Pa[e];if(!t)throw Error(e+" compression not supported");this.compressed=t(this.packets.write())}}function Sa(e,t){return r=>{if(!z.isStream(r)||y(r))return L((()=>Q(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 Ka(){return async function(e){const{decode:t}=await Promise.resolve().then((function(){return Ly}));return L((async()=>t(await Q(e))))}}const Ca=e=>({compressor:"undefined"!=typeof CompressionStream&&(()=>new CompressionStream(e)),decompressor:"undefined"!=typeof DecompressionStream&&(()=>new DecompressionStream(e))}),Pa={zip:/*#__PURE__*/Sa(Ca("deflate-raw").compressor,ca),zlib:/*#__PURE__*/Sa(Ca("deflate").compressor,ua)},Da={uncompressed:e=>e,zip:/*#__PURE__*/Sa(Ca("deflate-raw").decompressor,ha),zlib:/*#__PURE__*/Sa(Ca("deflate").decompressor,la),bzip2:/*#__PURE__*/Ka()},Ua=/*#__PURE__*/z.constructAllowedPackets([fa,Ia,ka,wa]);class xa{static get tag(){return F.packet.symEncryptedIntegrityProtectedData}static fromObject({version:e,aeadAlgorithm:t}){if(1!==e&&2!==e)throw Error("Unsupported SEIPD version");const r=new xa;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 C(e,(async e=>{if(this.version=await e.readByte(),1!==this.version&&2!==this.version)throw new Zn(`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?z.concat([new Uint8Array([this.version,this.cipherAlgorithm,this.aeadAlgorithm,this.chunkSizeByte]),this.salt,this.encrypted]):z.concat([new Uint8Array([this.version]),this.encrypted])}async encrypt(e,t,r=O){const{blockSize:n,keySize:i}=ls.getCipherParams(e);if(t.length!==i)throw Error("Unexpected session key size");let s=this.packets.write();if(y(s)&&(s=await Q(s)),2===this.version)this.cipherAlgorithm=e,this.salt=ls.random.getRandomBytes(32),this.chunkSizeByte=r.aeadChunkSizeByte,this.encrypted=await Qa(this,"encrypt",t,s);else{const i=await ls.getPrefixRandom(e),a=new Uint8Array([211,20]),o=z.concat([i,s,a]),c=await ls.hash.sha1(D(o)),h=z.concat([o,c]);this.encrypted=await ls.mode.cfb.encrypt(e,t,h,new Uint8Array(n),r)}return!0}async decrypt(e,t,r=O){if(t.length!==ls.getCipherParams(e).keySize)throw Error("Unexpected session key size");let n,i=P(this.encrypted);if(y(i)&&(i=await Q(i)),2===this.version){if(this.cipherAlgorithm!==e)throw Error("Unexpected session key algorithm");n=await Qa(this,"decrypt",t,i)}else{const{blockSize:s}=ls.getCipherParams(e),a=await ls.mode.cfb.decrypt(e,t,i,new Uint8Array(s)),o=x(D(a),-20),c=x(a,0,-20),h=Promise.all([Q(await ls.hash.sha1(D(c))),Q(o)]).then((([e,t])=>{if(!z.equalsUint8Array(e,t))throw Error("Modification detected.");return new Uint8Array})),u=x(c,s+2);n=x(u,0,-2),n=E([n,L((()=>h))]),z.isStream(i)&&r.allowUnauthenticatedStream||(n=await Q(n))}return this.packets=await va.fromBinary(n,Ua,r),!0}}async function Qa(e,t,r,n){const i=e instanceof xa&&2===e.version,s=!i&&e.constructor.tag===F.packet.aeadEncryptedData;if(!i&&!s)throw Error("Unexpected packet type");const a=ls.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}=ls.getCipherParams(e.cipherAlgorithm),{ivLength:n}=a,i=new Uint8Array(l,0,5),s=await fi(F.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 K(n,(async(r,n)=>{if("array"!==z.isStream(r)){const t=new TransformStream({},{highWaterMark:z.getHardwareConcurrency()*2**(e.chunkSizeByte+6),size:e=>e.length});v(t.readable,n),n=t.writable}const s=T(r),a=M(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 Ra=/*#__PURE__*/z.constructAllowedPackets([fa,Ia,ka,wa]);class La{static get tag(){return F.packet.aeadEncryptedData}constructor(){this.version=1,this.cipherAlgorithm=null,this.aeadAlgorithm=F.aead.eax,this.chunkSizeByte=null,this.iv=null,this.encrypted=null,this.packets=null}async read(e){await C(e,(async e=>{const t=await e.readByte();if(1!==t)throw new Zn(`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=ls.getAEADMode(this.aeadAlgorithm);this.iv=await e.readBytes(r.ivLength),this.encrypted=e.remainder()}))}write(){return z.concat([new Uint8Array([this.version,this.cipherAlgorithm,this.aeadAlgorithm,this.chunkSizeByte]),this.iv,this.encrypted])}async decrypt(e,t,r=O){this.packets=await va.fromBinary(await Qa(this,"decrypt",t,P(this.encrypted)),Ra,r)}async encrypt(e,t,r=O){this.cipherAlgorithm=e;const{ivLength:n}=ls.getAEADMode(this.aeadAlgorithm);this.iv=ls.random.getRandomBytes(n),this.chunkSizeByte=r.aeadChunkSizeByte;const i=this.packets.write();this.encrypted=await Qa(this,"encrypt",t,i)}}class Ta{static get tag(){return F.packet.publicKeyEncryptedSessionKey}constructor(){this.version=null,this.publicKeyID=new ga,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 Ta;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?ga.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 Zn(`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=ga.wildcard()}else t+=this.publicKeyID.read(e.subarray(t,t+8));if(this.publicKeyAlgorithm=e[t++],this.encrypted=ls.parseEncSessionKeyParams(this.publicKeyAlgorithm,e.subarray(t)),this.publicKeyAlgorithm===F.publicKey.x25519||this.publicKeyAlgorithm===F.publicKey.x448)if(3===this.version)this.sessionKeyAlgorithm=F.write(F.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]),ls.serializeParams(this.publicKeyAlgorithm,this.encrypted)),z.concatUint8Array(e)}async encrypt(e){const t=F.write(F.publicKey,this.publicKeyAlgorithm),r=3===this.version?this.sessionKeyAlgorithm:null,n=5===e.version?e.getFingerprintBytes().subarray(0,20):e.getFingerprintBytes(),i=Ma(this.version,t,r,this.sessionKey);this.encrypted=await ls.publicKeyEncrypt(t,r,e.publicParams,i,n)}async decrypt(e,t){if(this.publicKeyAlgorithm!==e.algorithm)throw Error("Decryption error");const r=t?Ma(this.version,this.publicKeyAlgorithm,t.sessionKeyAlgorithm,t.sessionKey):null,n=5===e.version?e.getFingerprintBytes().subarray(0,20):e.getFingerprintBytes(),i=await ls.publicKeyDecrypt(this.publicKeyAlgorithm,e.publicParams,e.privateParams,this.encrypted,n,r),{sessionKey:s,sessionKeyAlgorithm:a}=function(e,t,r,n){switch(t){case F.publicKey.rsaEncrypt:case F.publicKey.rsaEncryptSign:case F.publicKey.elgamal:case F.publicKey.ecdh:{const t=r.subarray(0,r.length-2),i=r.subarray(r.length-2),s=z.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:z.selectUint8Array(t,o.sessionKey,n.sessionKey),sessionKeyAlgorithm:6===e?null:z.selectUint8(t,o.sessionKeyAlgorithm,n.sessionKeyAlgorithm)}}if(a&&(6===e||F.read(F.symmetric,o.sessionKeyAlgorithm)))return o;throw Error("Decryption error")}case F.publicKey.x25519:case F.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!==F.publicKey.x25519&&this.publicKeyAlgorithm!==F.publicKey.x448;if(this.sessionKeyAlgorithm=e?a:this.sessionKeyAlgorithm,s.length!==ls.getCipherParams(this.sessionKeyAlgorithm).keySize)throw Error("Unexpected session key size")}this.sessionKey=s}}function Ma(e,t,r,n){switch(t){case F.publicKey.rsaEncrypt:case F.publicKey.rsaEncryptSign:case F.publicKey.elgamal:case F.publicKey.ecdh:return z.concatUint8Array([new Uint8Array(6===e?[]:[r]),n,z.writeChecksum(n.subarray(n.length%8))]);case F.publicKey.x25519:case F.publicKey.x448:return n;default:throw Error("Unsupported public key algorithm")}}class Na{static get tag(){return F.packet.symEncryptedSessionKey}constructor(e=O){this.version=e.aeadProtect?6:4,this.sessionKey=null,this.sessionKeyEncryptionAlgorithm=null,this.sessionKeyAlgorithm=null,this.aeadAlgorithm=F.write(F.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 Zn(`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=ws(n),t+=this.s2k.read(e.subarray(t,e.length)),this.version>=5){const r=ls.getAEADMode(this.aeadAlgorithm);this.iv=e.subarray(t,t+=r.ivLength)}this.version>=5||t=5){const e=ls.getAEADMode(this.aeadAlgorithm),r=new Uint8Array([192|Na.tag,this.version,this.sessionKeyEncryptionAlgorithm,this.aeadAlgorithm]),s=6===this.version?await fi(F.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 ls.mode.cfb.decrypt(t,i,this.encrypted,new Uint8Array(r));if(this.sessionKeyAlgorithm=F.write(F.symmetric,e[0]),this.sessionKey=e.subarray(1,e.length),this.sessionKey.length!==ls.getCipherParams(this.sessionKeyAlgorithm).keySize)throw Error("Unexpected session key size")}else this.sessionKey=i}async encrypt(e,t=O){const r=null!==this.sessionKeyEncryptionAlgorithm?this.sessionKeyEncryptionAlgorithm:this.sessionKeyAlgorithm;this.sessionKeyEncryptionAlgorithm=r,this.s2k=ms(t),this.s2k.generateSalt();const{blockSize:n,keySize:i}=ls.getCipherParams(r),s=await this.s2k.produceKey(e,i);if(null===this.sessionKey&&(this.sessionKey=ls.generateSessionKey(this.sessionKeyAlgorithm)),this.version>=5){const e=ls.getAEADMode(this.aeadAlgorithm);this.iv=ls.random.getRandomBytes(e.ivLength);const t=new Uint8Array([192|Na.tag,this.version,this.sessionKeyEncryptionAlgorithm,this.aeadAlgorithm]),n=6===this.version?await fi(F.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=z.concatUint8Array([new Uint8Array([this.sessionKeyAlgorithm]),this.sessionKey]);this.encrypted=await ls.mode.cfb.encrypt(r,s,e,new Uint8Array(n),t)}}}class Fa{static get tag(){return F.packet.publicKey}constructor(e=new Date,t=O){this.version=t.v6Keys?6:4,this.created=z.normalizeDate(e),this.algorithm=null,this.publicParams=null,this.expirationTimeV3=0,this.fingerprint=null,this.keyID=null}static fromSecretKeyPacket(e){const t=new Fa,{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=O){let r=0;if(this.version=e[r++],5===this.version&&!t.enableParsingV5Entities)throw new Zn("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=z.readDate(e.subarray(r,r+4)),r+=4,this.algorithm=e[r++],this.version>=5&&(r+=4);const{read:t,publicParams:n}=ls.parsePublicKeyParams(this.algorithm,e.subarray(r));if(6===this.version&&n.oid&&(n.oid.getName()===F.curve.curve25519Legacy||n.oid.getName()===F.curve.ed25519Legacy))throw Error("Legacy curve25519 cannot be used with v6 keys");return this.publicParams=n,r+=t,await this.computeFingerprintAndKeyID(),r}throw new Zn(`Version ${this.version} of the key packet is unsupported.`)}write(){const e=[];e.push(new Uint8Array([this.version])),e.push(z.writeDate(this.created)),e.push(new Uint8Array([this.algorithm]));const t=ls.serializeParams(this.algorithm,this.publicParams);return this.version>=5&&e.push(z.writeNumber(t.length,4)),e.push(t),z.concatUint8Array(e)}writeForHash(e){const t=this.writePublicKey(),r=149+e,n=e>=5?4:2;return z.concatUint8Array([new Uint8Array([r]),z.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 ga,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 ls.hash.sha256(e);else{if(4!==this.version)throw Error("Unsupported key version");this.fingerprint=await ls.hash.sha1(e)}}getFingerprintBytes(){return this.fingerprint}getFingerprint(){return z.uint8ArrayToHex(this.getFingerprintBytes())}hasSameFingerprintAs(e){return this.version===e.version&&z.equalsUint8Array(this.writePublicKey(),e.writePublicKey())}getAlgorithmInfo(){const e={};e.algorithm=F.read(F.publicKey,this.algorithm);const t=this.publicParams.n||this.publicParams.p;return t?e.bits=z.uint8ArrayBitLength(t):this.publicParams.oid&&(e.curve=this.publicParams.oid.getName()),e}}Fa.prototype.readPublicKey=Fa.prototype.read,Fa.prototype.writePublicKey=Fa.prototype.write;const Oa=/*#__PURE__*/z.constructAllowedPackets([fa,Ia,ka,wa]);class Ha{static get tag(){return F.packet.symmetricallyEncryptedData}constructor(){this.encrypted=null,this.packets=null}read(e){this.encrypted=e}write(){return this.encrypted}async decrypt(e,t,r=O){if(!r.allowUnauthenticatedMessages)throw Error("Message is not authenticated.");const{blockSize:n}=ls.getCipherParams(e),i=await Q(P(this.encrypted)),s=await ls.mode.cfb.decrypt(e,t,i.subarray(n+2),i.subarray(2,n+2));this.packets=await va.fromBinary(s,Oa,r)}async encrypt(e,t,r=O){const n=this.packets.write(),{blockSize:i}=ls.getCipherParams(e),s=await ls.getPrefixRandom(e),a=await ls.mode.cfb.encrypt(e,t,s,new Uint8Array(i),r),o=await ls.mode.cfb.encrypt(e,t,n,a.subarray(2),r);this.encrypted=z.concat([a,o])}}class za extends Fa{static get tag(){return F.packet.publicSubkey}constructor(e,t){super(e,t)}static fromSecretSubkeyPacket(e){const t=new za,{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 _a{static get tag(){return F.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 ja(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}=ls.getCipherParams(n),c=await t.produceKey(r,o);if(!i||5===e||a)return c;const h=z.concatUint8Array([s,new Uint8Array([e,n,i])]);return fi(F.hash.sha256,c,new Uint8Array,h,o)}class qa{static get tag(){return F.packet.userID}constructor(){this.userID="",this.name="",this.email="",this.comment=""}static fromObject(e){if(z.isString(e)||e.name&&!z.isString(e.name)||e.email&&!z.isEmailAddress(e.email)||e.comment&&!z.isString(e.comment))throw Error("Invalid user ID format");const t=new qa;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=O){const r=z.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 z.encodeUTF8(this.userID)}equals(e){return e&&e.userID===this.userID}}class Va extends Ga{static get tag(){return F.packet.secretSubkey}constructor(e=new Date,t=O){super(e,t)}}const Ja=/*#__PURE__*/z.constructAllowedPackets([wa]);class Ya{constructor(e){this.packets=e||new va}write(){return this.packets.write()}armor(e=O){const t=this.packets.some((e=>e.constructor.tag===wa.tag&&6!==e.version));return ie(F.armor.signature,this.write(),void 0,void 0,void 0,t,e)}getSigningKeyIDs(){return this.packets.map((e=>e.issuerKeyID))}}async function Wa(e,t){const r=new Va(e.date,t);return r.packets=null,r.algorithm=F.write(F.publicKey,e.algorithm),await r.generate(e.rsaBits,e.curve),await r.computeFingerprintAndKeyID(),r}async function Za(e,t){const r=new Ga(e.date,t);return r.packets=null,r.algorithm=F.write(F.publicKey,e.algorithm),await r.generate(e.rsaBits,e.curve,e.config),await r.computeFingerprintAndKeyID(),r}async function $a(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 z.wrapError(`Could not find valid ${F.read(F.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 Xa(e,t,r=new Date){const n=z.normalizeDate(r);if(null!==n){const r=io(e,t);return!(e.created<=n&&n0&&(s.keyExpirationTime=r.keyExpirationTime,s.keyNeverExpires=!1);return await to(i,[],t,s,r.date,void 0,void 0,void 0,n)}async function to(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 wa;return Object.assign(h,n),h.publicKeyAlgorithm=r.algorithm,h.hashAlgorithm=await async function(e,t,r=new Date,n=[],i){const s=F.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=F.write(F.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)=>ls.hash.getHashByteLength(e)-ls.hash.getHashByteLength(t)))[0];return ls.hash.getHashByteLength(e)>=ls.hash.getHashByteLength(s)?e:s};if(new Set([F.publicKey.ecdsa,F.publicKey.eddsaLegacy,F.publicKey.ed25519,F.publicKey.ed448]).has(t.algorithm)){const e=ls.getPreferredCurveHashAlgo(t.algorithm,t.publicParams.oid),r=h(a),n=ls.hash.getHashByteLength(a)>=ls.hash.getHashByteLength(e);if(r&&n)return a;{const t=u();return ls.hash.getHashByteLength(t)>=ls.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 ro(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 z.equalsUint8Array(t.writeParams(),e.writeParams())}))||t[r].push(e)}))):t[r]=e)}async function no(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=![F.reasonForRevocation.keyRetired,F.reasonForRevocation.keySuperseded,F.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 io(e,t){let r;return!1===t.keyNeverExpires&&(r=e.created.getTime()+1e3*t.keyExpirationTime),r?new Date(r):1/0}function so(e,t={}){switch(e.type=e.type||t.type,e.curve=e.curve||t.curve,e.rsaBits=e.rsaBits||t.rsaBits,e.keyExpirationTime=void 0!==e.keyExpirationTime?e.keyExpirationTime:t.keyExpirationTime,e.passphrase=z.isString(e.passphrase)?e.passphrase:t.passphrase,e.date=e.date||t.date,e.sign=e.sign||!1,e.type){case"ecc":try{e.curve=F.write(F.curve,e.curve)}catch(e){throw Error("Unknown curve")}e.curve!==F.curve.ed25519Legacy&&e.curve!==F.curve.curve25519Legacy&&"ed25519"!==e.curve&&"curve25519"!==e.curve||(e.curve=e.sign?F.curve.ed25519Legacy:F.curve.curve25519Legacy),e.sign?e.algorithm=e.curve===F.curve.ed25519Legacy?F.publicKey.eddsaLegacy:F.publicKey.ecdsa:e.algorithm=F.publicKey.ecdh;break;case"curve25519":e.algorithm=e.sign?F.publicKey.ed25519:F.publicKey.x25519;break;case"curve448":e.algorithm=e.sign?F.publicKey.ed448:F.publicKey.x448;break;case"rsa":e.algorithm=F.publicKey.rsaEncryptSign;break;default:throw Error("Unsupported key type "+e.type)}return e}function ao(e,t,r){switch(e.algorithm){case F.publicKey.rsaEncryptSign:case F.publicKey.rsaSign:case F.publicKey.dsa:case F.publicKey.ecdsa:case F.publicKey.eddsaLegacy:case F.publicKey.ed25519:case F.publicKey.ed448:if(!t.keyFlags&&!r.allowMissingKeyFlags)throw Error("None of the key flags is set: consider passing `config.allowMissingKeyFlags`");return!t.keyFlags||!!(t.keyFlags[0]&F.keyFlags.signData);default:return!1}}function oo(e,t,r){switch(e.algorithm){case F.publicKey.rsaEncryptSign:case F.publicKey.rsaEncrypt:case F.publicKey.elgamal:case F.publicKey.ecdh:case F.publicKey.x25519:case F.publicKey.x448:if(!t.keyFlags&&!r.allowMissingKeyFlags)throw Error("None of the key flags is set: consider passing `config.allowMissingKeyFlags`");return!t.keyFlags||!!(t.keyFlags[0]&F.keyFlags.encryptCommunication)||!!(t.keyFlags[0]&F.keyFlags.encryptStorage);default:return!1}}function co(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 F.publicKey.rsaEncryptSign:case F.publicKey.rsaEncrypt:case F.publicKey.elgamal:case F.publicKey.ecdh:case F.publicKey.x25519:case F.publicKey.x448:return!(!(!t.keyFlags||!!(t.keyFlags[0]&F.keyFlags.signData))||!r.allowInsecureDecryptionWithSigningKeys)||(!t.keyFlags||!!(t.keyFlags[0]&F.keyFlags.encryptCommunication)||!!(t.keyFlags[0]&F.keyFlags.encryptStorage));default:return!1}}function ho(e,t){const r=F.write(F.publicKey,e.algorithm),n=e.getAlgorithmInfo();if(t.rejectPublicKeyAlgorithms.has(r))throw Error(n.algorithm+" keys are considered too weak.");switch(r){case F.publicKey.rsaEncryptSign:case F.publicKey.rsaSign:case F.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,F.signature.certGeneric,a,r,void 0,n)}catch(e){throw z.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,F.signature.certGeneric,i,e,void 0,t)}catch(e){throw z.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 ro(e,this,"selfCertifications",t,(async function(e){try{return await e.verify(n,F.signature.certGeneric,i,t,!1,r),!0}catch(e){return!1}})),await ro(e,this,"otherCertifications",t),await ro(e,this,"revocationSignatures",t,(function(e){return no(n,F.signature.certRevocation,i,[e],void 0,void 0,t,r)}))}async revoke(e,{flag:t=F.reasonForRevocation.noReason,string:r=""}={},n=new Date,i=O){const s={userID:this.userID,userAttribute:this.userAttribute,key:e},a=new uo(s.userID||s.userAttribute,this.mainKey);return a.revocationSignatures.push(await to(s,[],e,{signatureType:F.signature.certRevocation,reasonForRevocationFlag:F.write(F.reasonForRevocation,t),reasonForRevocationString:r},n,void 0,void 0,!1,i)),await a.update(this),a}}class lo{constructor(e,t){this.keyPacket=e,this.bindingSignatures=[],this.revocationSignatures=[],this.mainKey=t}toPacketList(){const e=new va;return e.push(this.keyPacket),e.push(...this.revocationSignatures),e.push(...this.bindingSignatures),e}clone(){const e=new lo(this.keyPacket,this.mainKey);return e.bindingSignatures=[...this.bindingSignatures],e.revocationSignatures=[...this.revocationSignatures],e}async isRevoked(e,t,r=new Date,n=O){const i=this.mainKey.keyPacket;return no(i,F.signature.subkeyRevocation,{key:i,bind:this.keyPacket},this.revocationSignatures,e,t,r,n)}async verify(e=new Date,t=O){const r=this.mainKey.keyPacket,n={key:r,bind:this.keyPacket},i=await $a(this.bindingSignatures,r,F.signature.subkeyBinding,n,e,t);if(i.revoked||await this.isRevoked(i,null,e,t))throw Error("Subkey is revoked");if(Xa(this.keyPacket,i,e))throw Error("Subkey is expired");return i}async getExpirationTime(e=new Date,t=O){const r=this.mainKey.keyPacket,n={key:r,bind:this.keyPacket};let i;try{i=await $a(this.bindingSignatures,r,F.signature.subkeyBinding,n,e,t)}catch(e){return null}const s=io(this.keyPacket,i),a=i.getExpirationTime();return si.bindingSignatures[t].created&&(i.bindingSignatures[t]=e),!1;try{return await e.verify(n,F.signature.subkeyBinding,s,t,void 0,r),!0}catch(e){return!1}})),await ro(e,this,"revocationSignatures",t,(function(e){return no(n,F.signature.subkeyRevocation,s,[e],void 0,void 0,t,r)}))}async revoke(e,{flag:t=F.reasonForRevocation.noReason,string:r=""}={},n=new Date,i=O){const s={key:e,bind:this.keyPacket},a=new lo(this.keyPacket,this.mainKey);return a.revocationSignatures.push(await to(s,[],e,{signatureType:F.signature.subkeyRevocation,reasonForRevocationFlag:F.write(F.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=>{lo.prototype[e]=function(){return this.keyPacket[e]()}}));const yo=/*#__PURE__*/z.constructAllowedPackets([wa]),fo=new Set([F.packet.publicKey,F.packet.privateKey]),go=new Set([F.packet.publicKey,F.packet.privateKey,F.packet.publicSubkey,F.packet.privateSubkey]);class po{packetListToStructure(e,t=new Set){let r,n,i,s;for(const a of e){if(a instanceof Xn){go.has(a.tag)&&!s&&(s=fo.has(a.tag)?fo:go);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 F.packet.publicKey:case F.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 F.packet.userID:case F.packet.userAttribute:r=new uo(a,this),this.users.push(r);break;case F.packet.publicSubkey:case F.packet.secretSubkey:r=null,i=new lo(a,this),this.subkeys.push(i);break;case F.packet.signature:switch(a.signatureType){case F.signature.certGeneric:case F.signature.certPersona:case F.signature.certCasual:case F.signature.certPositive:if(!r){z.printDebug("Dropping certification signatures without preceding user packet");continue}a.issuerKeyID.equals(n)?r.selfCertifications.push(a):r.otherCertifications.push(a);break;case F.signature.certRevocation:r?r.revocationSignatures.push(a):this.directSignatures.push(a);break;case F.signature.key:this.directSignatures.push(a);break;case F.signature.subkeyBinding:if(!i){z.printDebug("Dropping subkey binding signature without preceding subkey packet");continue}i.bindingSignatures.push(a);break;case F.signature.keyRevocation:this.revocationSignatures.push(a);break;case F.signature.subkeyRevocation:if(!i){z.printDebug("Dropping subkey revocation signature without preceding subkey packet");continue}i.revocationSignatures.push(a)}}}}toPacketList(){const e=new va;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=O){await this.verifyPrimaryKey(t,r,n);const i=this.keyPacket;try{ho(i,n)}catch(e){throw z.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 $a(r.bindingSignatures,i,F.signature.subkeyBinding,e,t,n);if(!ao(r.keyPacket,s,n))continue;if(!s.embeddedSignature)throw Error("Missing embedded signature");return await $a([s.embeddedSignature],r.keyPacket,F.signature.keyBinding,e,t,n),ho(r.keyPacket,n),r}catch(e){a=e}try{const s=await this.getPrimarySelfSignature(t,r,n);if((!e||i.getKeyID().equals(e))&&ao(i,s,n))return ho(i,n),this}catch(e){a=e}throw z.wrapError("Could not find valid signing key packet in key "+this.getKeyID().toHex(),a)}async getEncryptionKey(e,t=new Date,r={},n=O){await this.verifyPrimaryKey(t,r,n);const i=this.keyPacket;try{ho(i,n)}catch(e){throw z.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 $a(r.bindingSignatures,i,F.signature.subkeyBinding,e,t,n);if(oo(r.keyPacket,s,n))return ho(r.keyPacket,n),r}catch(e){a=e}try{const s=await this.getPrimarySelfSignature(t,r,n);if((!e||i.getKeyID().equals(e))&&oo(i,s,n))return ho(i,n),this}catch(e){a=e}throw z.wrapError("Could not find valid encryption key packet in key "+this.getKeyID().toHex(),a)}async isRevoked(e,t,r=new Date,n=O){return no(this.keyPacket,F.signature.keyRevocation,{key:this.keyPacket},this.revocationSignatures,e,t,r,n)}async verifyPrimaryKey(e=new Date,t={},r=O){const n=this.keyPacket;if(await this.isRevoked(null,null,e,r))throw Error("Primary key is revoked");if(Xa(n,await this.getPrimarySelfSignature(e,t,r),e))throw Error("Primary key is expired");if(6!==n.version){const t=await $a(this.directSignatures,n,F.signature.key,{key:n},e,r).catch((()=>{}));if(t&&Xa(n,t,e))throw Error("Primary key is expired")}}async getExpirationTime(e,t=O){let r;try{const n=await this.getPrimarySelfSignature(null,e,t),i=io(this.keyPacket,n),s=n.getExpirationTime(),a=6!==this.keyPacket.version&&await $a(this.directSignatures,this.keyPacket,F.signature.key,{key:this.keyPacket},null,t).catch((()=>{}));if(a){const e=io(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 ro(e,n,"revocationSignatures",t,(i=>no(n.keyPacket,F.signature.keyRevocation,n,[i],null,e.keyPacket,t,r))),await ro(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=O){const r={key:this.keyPacket},n=await $a(this.revocationSignatures,this.keyPacket,F.signature.keyRevocation,r,e,t),i=new va;i.push(n);const s=6!==this.keyPacket.version;return ie(F.armor.publicKey,i.write(),null,null,"This is a revocation certificate",s,t)}async applyRevocationCertificate(e,t=new Date,r=O){const n=await ne(e),i=(await va.fromBinary(n.data,yo,r)).findPacket(F.packet.signature);if(!i||i.signatureType!==F.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,F.signature.keyRevocation,{key:this.keyPacket},t,void 0,r)}catch(e){throw z.wrapError("Could not verify revocation signature",e)}const s=this.clone();return s.revocationSignatures.push(i),s}async signPrimaryUser(e,t,r,n=O){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=O){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=O){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=O){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=>{po.prototype[e]=lo.prototype[e]}));class Ao extends po{constructor(e){if(super(),this.keyPacket=null,this.revocationSignatures=[],this.directSignatures=[],this.users=[],this.subkeys=[],e&&(this.packetListToStructure(e,new Set([F.packet.secretKey,F.packet.secretSubkey])),!this.keyPacket))throw Error("Invalid key: missing public-key packet")}isPrivate(){return!1}toPublic(){return this}armor(e=O){const t=6!==this.keyPacket.version;return ie(F.armor.publicKey,this.toPacketList().write(),void 0,void 0,void 0,t,e)}}class wo extends Ao{constructor(e){if(super(),this.packetListToStructure(e,new Set([F.packet.publicKey,F.packet.publicSubkey])),!this.keyPacket)throw Error("Invalid key: missing private-key packet")}isPrivate(){return!0}toPublic(){const e=new va,t=this.toPacketList();for(const r of t)switch(r.constructor.tag){case F.packet.secretKey:{const t=Fa.fromSecretKeyPacket(r);e.push(t);break}case F.packet.secretSubkey:{const t=za.fromSecretSubkeyPacket(r);e.push(t);break}default:e.push(r)}return new Ao(e)}armor(e=O){const t=6!==this.keyPacket.version;return ie(F.armor.privateKey,this.toPacketList().write(),void 0,void 0,void 0,t,e)}async getDecryptionKeys(e,t=new Date,r={},n=O){const i=this.keyPacket,s=[];let a=null;for(let r=0;re.isDecrypted()))}async validate(e=O){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=F.reasonForRevocation.noReason,string:t=""}={},r=new Date,n=O){if(!this.isPrivate())throw Error("Need private key for revoking");const i={key:this.keyPacket},s=this.clone();return s.revocationSignatures.push(await to(i,[],this.keyPacket,{signatureType:F.signature.keyRevocation,reasonForRevocationFlag:F.write(F.reasonForRevocation,e),reasonForRevocationString:t},r,void 0,void 0,void 0,n)),s}async addSubkey(e={}){const t={...O,...e.config};if(e.passphrase)throw Error("Subkey could not be encrypted here, please encrypt whole key");if(e.rsaBitse!==t))]}function a(){const e={};e.keyFlags=[F.keyFlags.certifyKeys|F.keyFlags.signData];const t=s([F.symmetric.aes256,F.symmetric.aes128],n.preferredSymmetricAlgorithm);if(e.preferredSymmetricAlgorithms=t,n.aeadProtect){const r=s([F.aead.gcm,F.aead.eax,F.aead.ocb],n.preferredAEADAlgorithm);e.preferredCipherSuites=r.flatMap((e=>t.map((t=>[t,e]))))}return e.preferredHashAlgorithms=s([F.hash.sha512,F.hash.sha256,F.hash.sha3_512,F.hash.sha3_256],n.preferredHashAlgorithm),e.preferredCompressionAlgorithms=s([F.compression.uncompressed,F.compression.zlib,F.compression.zip],n.preferredCompressionAlgorithm),e.features=[0],e.features[0]|=F.features.modificationDetection,n.aeadProtect&&(e.features[0]|=F.features.seipdv2),r.keyExpirationTime>0&&(e.keyExpirationTime=r.keyExpirationTime,e.keyNeverExpires=!1),e}if(i.push(e),6===e.version){const t={key:e},s=a();s.signatureType=F.signature.key;const o=await to(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=qa.fromObject(t),o={userID:s,key:e},c=6!==e.version?a():{};c.signatureType=F.signature.certPositive,0===i&&(c.isPrimaryUserID=!0);return{userIDPacket:s,signaturePacket:await to(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 eo(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 to(o,[],e,{signatureType:F.signature.keyRevocation,reasonForRevocationFlag:F.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 wo(i)}const Eo=/*#__PURE__*/z.constructAllowedPackets([fa,Ia,La,xa,Ha,Ta,Na,ka,wa]),vo=/*#__PURE__*/z.constructAllowedPackets([Na]),Bo=/*#__PURE__*/z.constructAllowedPackets([wa]);class Io{constructor(e){this.packets=e||new va}getEncryptionKeyIDs(){const e=[];return this.packets.filterByTag(F.packet.publicKeyEncryptedSessionKey).forEach((function(t){e.push(t.publicKeyID)})),e}getSigningKeyIDs(){const e=this.unwrapCompressed(),t=e.packets.filterByTag(F.packet.onePassSignature);if(t.length>0)return t.map((e=>e.issuerKeyID));return e.packets.filterByTag(F.packet.signature).map((e=>e.issuerKeyID))}async decrypt(e,t,r,n=new Date,i=O){const s=this.packets.filterByTag(F.packet.symmetricallyEncryptedData,F.packet.symEncryptedIntegrityProtectedData,F.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(!z.isUint8Array(t)||!a.cipherAlgorithm&&!z.isString(e))throw Error("Invalid session key for decryption.");try{const r=a.cipherAlgorithm||F.write(F.symmetric,e);await a.decrypt(r,t,i)}catch(e){z.printDebugError(e),h=e}})));if(R(a.encrypted),a.encrypted=null,await u,!a.packets||!a.packets.length)throw h||Error("Decryption failed.");const l=new Io(a.packets);return a.packets=new va,l}async decryptSessionKeys(e,t,r,n=new Date,i=O){let s,a=[];if(t){const e=this.packets.filterByTag(F.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 va.fromBinary(e.write(),vo,i):e,await Promise.all(n.map((async function(e){try{await e.decrypt(t),a.push(e)}catch(e){z.printDebugError(e),e instanceof ys&&(s=e)}})))})))}else{if(!e)throw Error("No key or password specified.");{const t=this.packets.filterByTag(F.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=[F.symmetric.aes256,F.symmetric.aes128,F.symmetric.tripledes,F.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===F.publicKey.rsaEncrypt||t.publicKeyAlgorithm===F.publicKey.rsaEncryptSign||t.publicKeyAlgorithm===F.publicKey.rsaSign||t.publicKeyAlgorithm===F.publicKey.elgamal)){const n=t.write();await Promise.all((r?[r]:Array.from(i.constantTimePKCS1DecryptionSupportedSymmetricAlgorithms)).map((async t=>{const r=new Ta;r.read(n);const i={sessionKeyAlgorithm:t,sessionKey:ls.generateSessionKey(t)};try{await r.decrypt(e,i),a.push(r)}catch(e){z.printDebugError(e),s=e}})))}else try{await t.decrypt(e);const n=r||t.sessionKeyAlgorithm;if(n&&!c.includes(F.write(F.symmetric,n)))throw Error("A non-preferred symmetric algorithm was used.");a.push(t)}catch(e){z.printDebugError(e),s=e}})))}))),R(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+z.uint8ArrayToString(t.sessionKey);return!e.has(r)&&(e.add(r),!0)}))}return a.map((e=>({data:e.sessionKey,algorithm:e.sessionKeyAlgorithm&&F.read(F.symmetric,e.sessionKeyAlgorithm)})))}throw s||Error("Session key decryption failed.")}getLiteralData(){const e=this.unwrapCompressed().packets.findPacket(F.packet.literalData);return e&&e.getBytes()||null}getFilename(){const e=this.unwrapCompressed().packets.findPacket(F.packet.literalData);return e&&e.getFilename()||null}getText(){const e=this.unwrapCompressed().packets.findPacket(F.packet.literalData);return e?e.getText():null}static async generateSessionKey(e=[],t=new Date,r=[],n=O){const{symmetricAlgo:i,aeadAlgo:s}=await async function(e=[],t=new Date,r=[],n=O){const i=await Promise.all(e.map(((e,i)=>e.getPrimarySelfSignature(t,r[i],n))));if(e.length?i.every((e=>e.features&&e.features[0]&F.features.seipdv2)):n.aeadProtect){const e={symmetricAlgo:F.symmetric.aes128,aeadAlgo:F.aead.ocb},t=[{symmetricAlgo:n.preferredSymmetricAlgorithm,aeadAlgo:n.preferredAEADAlgorithm},{symmetricAlgo:n.preferredSymmetricAlgorithm,aeadAlgo:F.aead.ocb},{symmetricAlgo:F.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=F.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=F.read(F.symmetric,i),o=s?F.read(F.aead,s):void 0;await Promise.all(e.map((e=>e.getEncryptionKey().catch((()=>null)).then((e=>{if(e&&(e.keyPacket.algorithm===F.publicKey.x25519||e.keyPacket.algorithm===F.publicKey.x448)&&!o&&!z.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:ls.generateSessionKey(i),algorithm:a,aeadAlgorithm:o}}async encrypt(e,t,r,n=!1,i=[],s=new Date,a=[],o=O){if(r){if(!z.isUint8Array(r.data)||!z.isString(r.algorithm))throw Error("Invalid session key for encryption.")}else if(e&&e.length)r=await Io.generateSessionKey(e,s,a,o);else{if(!t||!t.length)throw Error("No keys, passwords, or session key provided.");r=await Io.generateSessionKey(void 0,void 0,void 0,o)}const{data:c,algorithm:h,aeadAlgorithm:u}=r,l=await Io.encryptSessionKey(c,h,u,e,t,n,i,s,a,o),y=xa.fromObject({version:u?2:1,aeadAlgorithm:u?F.write(F.aead,u):null});y.packets=this.packets;const f=F.write(F.symmetric,h);return await y.encrypt(f,c,o),l.packets.push(y),y.packets=new va,l}static async encryptSessionKey(e,t,r,n,i,s=!1,a=[],o=new Date,c=[],h=O){const u=new va,l=F.write(F.symmetric,t),y=r&&F.write(F.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=Ta.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 Na(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 Io(u)}async sign(e=[],t=[],r=null,n=[],i=new Date,s=[],a=[],o=[],c=O){const h=new va,u=this.packets.findPacket(F.packet.literalData);if(!u)throw Error("No literal data packet to sign.");const l=await So(u,e,t,r,n,i,s,a,o,!1,c),y=l.map(((e,t)=>ka.fromSignaturePacket(e,0===t))).reverse();return h.push(...y),h.push(u),h.push(...l),new Io(h)}compress(e,t=O){if(e===F.compression.uncompressed)return this;const r=new Ia(t);r.algorithm=e,r.packets=this.packets;const n=new va;return n.push(r),new Io(n)}async signDetached(e=[],t=[],r=null,n=[],i=[],s=new Date,a=[],o=[],c=O){const h=this.packets.findPacket(F.packet.literalData);if(!h)throw Error("No literal data packet to sign.");return new Ya(await So(h,e,t,r,n,i,s,a,o,!0,c))}async verify(e,t=new Date,r=O){const n=this.unwrapCompressed(),i=n.packets.filterByTag(F.packet.literalData);if(1!==i.length)throw Error("Can only verify message with one literal data packet.");y(n.packets.stream)&&n.packets.push(...await Q(n.packets.stream,(e=>e||[])));const s=n.packets.filterByTag(F.packet.onePassSignature).reverse(),a=n.packets.filterByTag(F.packet.signature);return s.length&&!a.length&&z.isStream(n.packets.stream)&&!y(n.packets.stream)?(await Promise.all(s.map((async e=>{e.correspondingSig=new Promise(((t,r)=>{e.correspondingSigResolve=t,e.correspondingSigReject=r})),e.signatureData=L((async()=>(await e.correspondingSig).signatureData)),e.hashed=Q(await e.hash(e.signatureType,i[0],void 0,!1)),e.hashed.catch((()=>{}))}))),n.packets.stream=K(n.packets.stream,(async(e,t)=>{const r=T(e),n=M(t);try{for(let e=0;e{t.correspondingSigReject(e)})),await n.abort(e)}})),Ko(s,i,e,t,!1,r)):Ko(a,i,e,t,!1,r)}verifyDetached(e,t,r=new Date,n=O){const i=this.unwrapCompressed().packets.filterByTag(F.packet.literalData);if(1!==i.length)throw Error("Can only verify message with one literal data packet.");return Ko(e.packets.filterByTag(F.packet.signature),i,t,r,!0,n)}unwrapCompressed(){const e=this.packets.filterByTag(F.packet.compressedData);return e.length?new Io(e[0].packets):this}async appendSignature(e,t=O){await this.packets.read(z.isUint8Array(e)?e:(await ne(e)).data,Bo,t)}write(){return this.packets.write()}armor(e=O){const t=this.packets[this.packets.length-1],r=t.constructor.tag===xa.tag?2!==t.version:this.packets.some((e=>e.constructor.tag===wa.tag&&6!==e.version));return ie(F.armor.message,this.write(),null,null,null,r,e)}}async function So(e,t,r=[],n=null,i=[],s=new Date,a=[],o=[],c=[],h=!1,u=O){const l=new va,y=null===e.text?F.signature.binary:F.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 to(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(F.packet.signature);l.push(...e)}return l}async function Ko(e,t,r,n=new Date,i=!1,s=O){return Promise.all(e.filter((function(e){return["text","binary"].includes(F.read(F.signature,e.signatureType))})).map((async function(e){return async function(e,t,r,n=new Date,i=!1,s=O){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 ka?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 va;return e&&t.push(e),new Ya(t)})()};return h.signature.catch((()=>{})),h.verified.catch((()=>{})),h}(e,t,r,n,i,s)})))}const Co=/*#__PURE__*/z.constructAllowedPackets([wa]);class Po{constructor(e,t){if(this.text=z.removeTrailingSpaces(e).replace(/\r?\n/g,"\r\n"),t&&!(t instanceof Ya))throw Error("Invalid signature input");this.signature=t||new Ya(new va)}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=O){const h=new fa;h.setText(this.text);const u=new Ya(await So(h,e,t,r,n,i,s,a,o,!0,c));return new Po(this.text,u)}verify(e,t=new Date,r=O){const n=this.signature.packets.filterByTag(F.packet.signature),i=new fa;return i.setText(this.text),Ko(n,[i],e,t,!0,r)}getText(){return this.text.replace(/\r\n/g,"\n")}armor(e=O){const t=this.signature.packets.some((e=>6!==e.version)),r={hash:t?Array.from(new Set(this.signature.packets.map((e=>F.read(F.hash,e.hashAlgorithm).toUpperCase())))).join():null,text:this.text,data:this.signature.packets.write()};return ie(F.armor.signed,r,void 0,void 0,void 0,t,e)}}function Do(e){if(!(e instanceof Io))throw Error("Parameter [message] needs to be of type Message")}function Uo(e){if(!(e instanceof Po||e instanceof Io))throw Error("Parameter [message] needs to be of type Message or CleartextMessage")}function xo(e){if("armored"!==e&&"binary"!==e&&"object"!==e)throw Error("Unsupported format "+e)}const Qo=Object.keys(O).length;function Ro(e){const t=Object.keys(e);if(t.length!==Qo)for(const e of t)if(void 0===O[e])throw Error("Unknown config property: "+e)}function Lo(e){return e&&!z.isArray(e)&&(e=[e]),e}async function To(e){return"array"===z.isStream(e)?Q(e):e}function Mo(e,t){e.data=K(t.packets.stream,(async(t,r)=>{await v(e.data,r,{preventClose:!0});const n=M(r);try{await Q(t,(e=>e)),await n.close()}catch(e){await n.abort(e)}}))}function No(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 Fo(e){if(!Number.isSafeInteger(e)||e<0)throw Error("positive integer expected, not "+e)}function Oo(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 Ho(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 zo(e,t){Oo(e);const r=t.outputLen;if(e.lengthnew DataView(e.buffer,e.byteOffset,e.byteLength),jo=(e,t)=>e<<32-t|e>>>t,qo=(e,t)=>e<>>32-t>>>0,Vo=68===new Uint8Array(new Uint32Array([287454020]).buffer)[0]; /*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */function Jo(e){for(let r=0;r>>8&65280|t>>>24&255;var t}function Yo(e){if("string"!=typeof e)throw Error("utf8ToBytes expected string, got "+typeof e);return new Uint8Array((new TextEncoder).encode(e))}function Wo(e){return"string"==typeof e&&(e=Yo(e)),Oo(e),e}function Zo(...e){let t=0;for(let r=0;re().update(Wo(t)).digest(),r=e();return t.outputLen=r.outputLen,t.blockLen=r.blockLen,t.create=()=>e(),t}function ec(e=32){if(_o&&"function"==typeof _o.getRandomValues)return _o.getRandomValues(new Uint8Array(e));if(_o&&"function"==typeof _o.randomBytes)return _o.randomBytes(e);throw Error("crypto.getRandomValues must be defined")}const tc=(e,t,r)=>e&t^~e&r,rc=(e,t,r)=>e&t^e&r^t&r;class nc extends $o{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=Go(this.buffer)}update(e){Ho(this);const{view:t,buffer:r,blockLen:n}=this,i=(e=Wo(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=Go(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=jo(r,17)^jo(r,19)^r>>>10;ac[e]=i+ac[e-7]+n+ac[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+(jo(a,6)^jo(a,11)^jo(a,25))+tc(a,o,c)+ic[e]+ac[e]|0,u=(jo(r,2)^jo(r,13)^jo(r,22))+rc(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(){ac.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}}class cc extends oc{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 hc=/* @__PURE__ */Xo((()=>new oc)),uc=/* @__PURE__ */Xo((()=>new cc));class lc extends $o{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");Fo(e.outputLen),Fo(e.blockLen)}(e);const r=Wo(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 lc(e,t).update(r).digest();yc.create=(e,t)=>new lc(e,t) /*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */;const fc=/* @__PURE__ */BigInt(0),gc=/* @__PURE__ */BigInt(1),pc=/* @__PURE__ */BigInt(2);function dc(e){return e instanceof Uint8Array||null!=e&&"object"==typeof e&&"Uint8Array"===e.constructor.name}function Ac(e){if(!dc(e))throw Error("Uint8Array expected")}function wc(e,t){if("boolean"!=typeof t)throw Error(`${e} must be valid boolean, got "${t}".`)}const mc=/* @__PURE__ */Array.from({length:256},((e,t)=>t.toString(16).padStart(2,"0")));function bc(e){Ac(e);let t="";for(let r=0;r=vc._0&&e<=vc._9?e-vc._0:e>=vc._A&&e<=vc._F?e-(vc._A-10):e>=vc._a&&e<=vc._f?e-(vc._a-10):void 0}function Ic(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&&fc<=e;function Qc(e,t,r){return xc(e)&&xc(t)&&xc(r)&&t<=e&&efc;e>>=gc,t+=1);return t}const Tc=e=>(pc<new Uint8Array(e),Nc=e=>Uint8Array.from(e);function Fc(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=Mc(e),i=Mc(e),s=0;const a=()=>{n.fill(1),i.fill(0),s=0},o=(...e)=>r(i,n,...e),c=(e=Mc())=>{i=o(Nc([0]),e),n=o(),0!==e.length&&(i=o(Nc([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 Oc={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||dc(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 Hc(e,t,r={}){const n=(t,r,n)=>{const i=Oc[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 zc(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 _c=/*#__PURE__*/Object.freeze({__proto__:null,aInRange:Rc,abool:wc,abytes:Ac,bitGet:function(e,t){return e>>BigInt(t)&gc},bitLen:Lc,bitMask:Tc,bitSet:function(e,t,r){return e|(r?gc:fc)<{throw Error("not implemented")},numberToBytesBE:Cc,numberToBytesLE:Pc,numberToHexUnpadded:kc,numberToVarBytesBE:function(e){return Ic(kc(e))},utf8ToBytes:function(e){if("string"!=typeof e)throw Error("utf8ToBytes expected string, got "+typeof e);return new Uint8Array((new TextEncoder).encode(e))},validateObject:Hc}); /*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const Gc=BigInt(0),jc=BigInt(1),qc=BigInt(2),Vc=BigInt(3),Jc=BigInt(4),Yc=BigInt(5),Wc=BigInt(8);function Zc(e,t){const r=e%t;return r>=Gc?r:t+r}function $c(e,t,r){if(r<=Gc||t 0");if(r===jc)return Gc;let n=jc;for(;t>Gc;)t&jc&&(n=n*e%r),e=e*e%r,t>>=jc;return n}function Xc(e,t,r){let n=e;for(;t-- >Gc;)n*=n,n%=r;return n}function eh(e,t){if(e===Gc||t<=Gc)throw Error(`invert: expected positive integers, got n=${e} mod=${t}`);let r=Zc(e,t),n=t,i=Gc,s=jc;for(;r!==Gc;){const e=n%r,t=i-s*(n/r);n=r,r=e,i=s,s=t}if(n!==jc)throw Error("invert: does not exist");return Zc(i,t)}function th(e){if(e%Jc===Vc){const t=(e+jc)/Jc;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%Wc===Yc){const t=(e-Yc)/Wc;return function(e,r){const n=e.mul(r,qc),i=e.pow(n,t),s=e.mul(r,i),a=e.mul(e.mul(s,qc),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-jc)/qc;let r,n,i;for(r=e-jc,n=0;r%qc===Gc;r/=qc,n++);for(i=qc;i 0, got "+e);const{nBitLength:i,nByteLength:s}=nh(e,t);if(s>2048)throw Error("Field lengths over 2048 bytes are not supported");const a=th(e),o=Object.freeze({ORDER:e,BITS:i,BYTES:s,MASK:Tc(i),ZERO:Gc,ONE:jc,create:t=>Zc(t,e),isValid:t=>{if("bigint"!=typeof t)throw Error("Invalid field element: expected bigint, got "+typeof t);return Gc<=t&&te===Gc,isOdd:e=>(e&jc)===jc,neg:t=>Zc(-t,e),eql:(e,t)=>e===t,sqr:t=>Zc(t*t,e),add:(t,r)=>Zc(t+r,e),sub:(t,r)=>Zc(t-r,e),mul:(t,r)=>Zc(t*r,e),pow:(e,t)=>function(e,t,r){if(r 0");if(r===Gc)return e.ONE;if(r===jc)return t;let n=e.ONE,i=t;for(;r>Gc;)r&jc&&(n=e.mul(n,i)),i=e.sqr(i),r>>=jc;return n}(o,e,t),div:(t,r)=>Zc(t*eh(r,e),e),sqrN:e=>e*e,addN:(e,t)=>e+t,subN:(e,t)=>e-t,mulN:(e,t)=>e*t,inv:t=>eh(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?Pc(e,s):Cc(e,s),fromBytes:e=>{if(e.length!==s)throw Error(`Fp.fromBytes: expected ${s}, got ${e.length}`);return r?Kc(e):Sc(e)}});return Object.freeze(o)}function sh(e){if("bigint"!=typeof e)throw Error("field order must be bigint");const t=e.toString(2).length;return Math.ceil(t/8)}function ah(e){const t=sh(e);return t+Math.ceil(t/2)} /*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */ const oh=BigInt(0),ch=BigInt(1),hh=new WeakMap,uh=new WeakMap;function lh(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>oh;)r&ch&&(n=n.add(i)),i=i.double(),r>>=ch;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+=ch);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=uh.get(e)||1;let i=hh.get(e);return i||(i=this.precomputeWindow(e,n),1!==n&&hh.set(e,r(i))),this.wNAF(n,i,t)},setWindowSize(e,t){n(t),uh.set(e,t),hh.delete(e)}}}function yh(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=Lc(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"})),Hc(e,{n:"bigint",h:"bigint",Gx:"field",Gy:"field"},{nBitLength:"isSafeInteger",nByteLength:"isSafeInteger"}),Object.freeze({...nh(e.n,e.nBitLength),...e,p:e.Fp.ORDER})} /*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */function gh(e){void 0!==e.lowS&&wc("lowS",e.lowS),void 0!==e.prehash&&wc("prehash",e.prehash)}const{bytesToNumberBE:ph,hexToBytes:dh}=_c,Ah={Err:class extends Error{constructor(e=""){super(e)}},_tlv:{encode:(e,t)=>{const{Err:r}=Ah;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=kc(n);if(i.length/2&128)throw new r("tlv.encode: long form length too big");const s=n>127?kc(i.length/2|128):"";return`${kc(e)}${s}${i}${t}`},decode(e,t){const{Err:r}=Ah;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}=Ah;if(e{const i=t.toAffine();return Uc(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(dc(e)&&(e=bc(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:Sc(Dc("private key",e,n))}catch(t){throw Error(`private key must be ${n} bytes, hex or bigint, not ${typeof e}`)}return i&&(a=Zc(a,s)),Rc("private key",a,mh,s),a}function c(e){if(!(e instanceof l))throw Error("ProjectivePoint expected")}const h=zc(((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=zc((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(Dc("pointHex",e)));return t.assertValidity(),t}static fromPrivateKey(e){return l.BASE.multiply(o(e))}static msm(e,t){return yh(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,bh),{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,bh);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){Rc("scalar",e,wh,t.n);const n=l.ZERO;if(e===wh)return n;if(e===mh)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>wh||c>wh;)a&mh&&(h=h.add(y)),c&mh&&(u=u.add(y)),y=y.double(),a>>=mh,c>>=mh;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(Rc("scalar",e,mh,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!==wh&&t!==mh&&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===mh)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===mh?this:r?r(l,this):this.multiplyUnsafe(t.h)}toRawBytes(e=!0){return wc("isCompressed",e),this.assertValidity(),i(l,this,e)}toHex(e=!0){return wc("isCompressed",e),bc(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=lh(l,t.endo?Math.ceil(y/2):y);return{CURVE:t,ProjectivePoint:l,normPrivateKeyToScalar:o,weierstrassEquation:a,isWithinCurveOrder:function(e){return Qc(e,mh,t.n)}}}function Eh(e){const t=function(e){const t=fh(e);return Hc(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 Zc(e,n)}function o(e){return eh(e,n)}const{ProjectivePoint:c,normPrivateKeyToScalar:h,weierstrassEquation:u,isWithinCurveOrder:l}=kh({...t,toBytes(e,t,n){const i=t.toAffine(),s=r.toBytes(i.x),a=Uc;return wc("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=Sc(a);if(!Qc(e,mh,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&mh)===mh)&&(i=r.neg(i)),{x:e,y:i}}}}),y=e=>bc(Cc(e,t.nByteLength));function f(e){return e>n>>mh}const g=(e,t,r)=>Sc(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=Dc("compactSignature",e,2*r),new p(g(e,0,r),g(e,r,2*r))}static fromDER(e){const{r:t,s:r}=Ah.toSig(Dc("DER",e));return new p(t,r)}assertValidity(){Rc("r",this.r,mh,n),Rc("s",this.s,mh,n)}addRecoveryBit(e){return new p(this.r,this.s,e)}recoverPublicKey(e){const{r:n,s:i,recovery:s}=this,h=m(Dc("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 Ic(this.toDERHex())}toDERHex(){return Ah.hexFromSig({r:this.r,s:this.s})}toCompactRawBytes(){return Ic(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=ah(t.n);return function(e,t,r=!1){const n=e.length,i=sh(t),s=ah(t);if(n<16||n1024)throw Error(`expected ${s}-1024 bytes of input, got ${n}`);const a=Zc(r?Sc(e):Kc(e),t-jc)+jc;return r?Pc(a,i):Cc(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=dc(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=Sc(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=Tc(t.nBitLength);function k(e){return Rc("num < 2^"+t.nBitLength,e,wh,b),Cc(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=Dc("msgHash",e),gh(i),g&&(e=Dc("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(Dc("extraEntropy",e))}const B=Uc(...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===wh)return;const s=a(r*a(I+i*b));if(s===wh)return;let h=(n.x===i?0:2)|Number(n.y&mh),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 Fc(a.hash.outputLen,a.nByteLength,a.hmac)(i,s)},verify:function(e,r,n,i=B){const s=e;if(r=Dc("msgHash",r),n=Dc("publicKey",n),"strict"in i)throw Error("options.strict was renamed to lowS");gh(i);const{lowS:h,prehash:u}=i;let l,y;try{if("string"==typeof s||dc(s))try{l=p.fromDER(s)}catch(e){if(!(e instanceof Ah.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 vh(e){return{hash:e,hmac:(t,...r)=>yc(e,t,Zo(...r)),randomBytes:ec}}function Bh(e,t){const r=t=>Eh({...e,...vh(t)});return Object.freeze({...r(t),create:r})} /*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */BigInt(4);const Ih=ih(BigInt("0xffffffff00000001000000000000000000000000ffffffffffffffffffffffff")),Sh=Bh({a:Ih.create(BigInt("-3")),b:BigInt("0x5ac635d8aa3a93e7b3ebbd55769886bc651d06b0cc53b0f63bce3c3e27d2604b"),Fp:Ih,n:BigInt("0xffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc632551"),Gx:BigInt("0x6b17d1f2e12c4247f8bce6e563a440f277037d812deb33a0f4a13945d898c296"),Gy:BigInt("0x4fe342e2fe1a7f9b8ee7eb4a7c0f9e162bce33576b315ececbb6406837bf51f5"),h:BigInt(1),lowS:!1},hc),Kh=/* @__PURE__ */BigInt(2**32-1),Ch=/* @__PURE__ */BigInt(32);function Ph(e,t=!1){return t?{h:Number(e&Kh),l:Number(e>>Ch&Kh)}:{h:0|Number(e>>Ch&Kh),l:0|Number(e&Kh)}}function Dh(e,t=!1){let r=new Uint32Array(e.length),n=new Uint32Array(e.length);for(let i=0;ie<>>32-r,xh=(e,t,r)=>t<>>32-r,Qh=(e,t,r)=>t<>>64-r,Rh=(e,t,r)=>e<>>64-r;const Lh={fromBig:Ph,split:Dh,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:Uh,rotlSL:xh,rotlBH:Qh,rotlBL:Rh,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)},[Th,Mh]=/* @__PURE__ */(()=>Lh.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)))))(),Nh=/* @__PURE__ */new Uint32Array(80),Fh=/* @__PURE__ */new Uint32Array(80);class Oh extends nc{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)Nh[r]=e.getUint32(t),Fh[r]=e.getUint32(t+=4);for(let e=16;e<80;e++){const t=0|Nh[e-15],r=0|Fh[e-15],n=Lh.rotrSH(t,r,1)^Lh.rotrSH(t,r,8)^Lh.shrSH(t,r,7),i=Lh.rotrSL(t,r,1)^Lh.rotrSL(t,r,8)^Lh.shrSL(t,r,7),s=0|Nh[e-2],a=0|Fh[e-2],o=Lh.rotrSH(s,a,19)^Lh.rotrBH(s,a,61)^Lh.shrSH(s,a,6),c=Lh.rotrSL(s,a,19)^Lh.rotrBL(s,a,61)^Lh.shrSL(s,a,6),h=Lh.add4L(i,c,Fh[e-7],Fh[e-16]),u=Lh.add4H(h,n,o,Nh[e-7],Nh[e-16]);Nh[e]=0|u,Fh[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=Lh.rotrSH(u,l,14)^Lh.rotrSH(u,l,18)^Lh.rotrBH(u,l,41),w=Lh.rotrSL(u,l,14)^Lh.rotrSL(u,l,18)^Lh.rotrBL(u,l,41),m=u&y^~u&g,b=l&f^~l&p,k=Lh.add5L(A,w,b,Mh[e],Fh[e]),E=Lh.add5H(k,d,t,m,Th[e],Nh[e]),v=0|k,B=Lh.rotrSH(r,n,28)^Lh.rotrBH(r,n,34)^Lh.rotrBH(r,n,39),I=Lh.rotrSL(r,n,28)^Lh.rotrBL(r,n,34)^Lh.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}=Lh.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=Lh.add3L(v,I,K);r=Lh.add3H(C,E,B,S),n=0|C}({h:r,l:n}=Lh.add(0|this.Ah,0|this.Al,0|r,0|n)),({h:i,l:s}=Lh.add(0|this.Bh,0|this.Bl,0|i,0|s)),({h:a,l:o}=Lh.add(0|this.Ch,0|this.Cl,0|a,0|o)),({h:c,l:h}=Lh.add(0|this.Dh,0|this.Dl,0|c,0|h)),({h:u,l}=Lh.add(0|this.Eh,0|this.El,0|u,0|l)),({h:y,l:f}=Lh.add(0|this.Fh,0|this.Fl,0|y,0|f)),({h:g,l:p}=Lh.add(0|this.Gh,0|this.Gl,0|g,0|p)),({h:d,l:A}=Lh.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(){Nh.fill(0),Fh.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 Hh extends Oh{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 zh=/* @__PURE__ */Xo((()=>new Oh)),_h=/* @__PURE__ */Xo((()=>new Hh)),Gh=ih(BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffeffffffff0000000000000000ffffffff")),jh=Bh({a:Gh.create(BigInt("-3")),b:BigInt("0xb3312fa7e23ee7e4988e056be3f82d19181d9c6efe8141120314088f5013875ac656398d8a2ed19d2a85c8edd3ec2aef"),Fp:Gh,n:BigInt("0xffffffffffffffffffffffffffffffffffffffffffffffffc7634d81f4372ddf581a0db248b0a77aecec196accc52973"),Gx:BigInt("0xaa87ca22be8b05378eb1c71ef320ad746e1d3b628ba79b9859f741e082542a385502f25dbf55296c3a545e3872760ab7"),Gy:BigInt("0x3617de4a96262c6f5d9e98bf9292dc29f8f41dbd289a147ce9da3113b5f0b8c00a60b1ce1d7e819d7a431d7c90ea0e5f"),h:BigInt(1),lowS:!1},_h),qh=ih(BigInt("0x1ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff")),Vh={a:qh.create(BigInt("-3")),b:BigInt("0x0051953eb9618e1c9a1f929a21a0b68540eea2da725b99b315f3b8b489918ef109e156193951ec7e937b1652c0bd3bb1bf073573df883d2c34f1ef451fd46b503f00"),Fp:qh,n:BigInt("0x01fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffa51868783bf2f966b7fcc0148f709a5d03bb5c9b8899c47aebb6fb71e91386409"),Gx:BigInt("0x00c6858e06b70404e9cd9e3ecb662395b4429c648139053fb521f828af606b4d3dbaa14b5e77efe75928fe1dc127a2ffa8de3348b3c1856a429bf97e7e31c2e5bd66"),Gy:BigInt("0x011839296a789a3bc0045c8a5fb42c7d1bd998f54449579b446817afbd17273e662c97ee72995ef42640c550b9013fad0761353c7086a272c24088be94769fd16650"),h:BigInt(1)},Jh=Bh({a:Vh.a,b:Vh.b,Fp:qh,n:Vh.n,Gx:Vh.Gx,Gy:Vh.Gy,h:Vh.h,lowS:!1,allowedPrivateKeyLengths:[130,131,132]},zh),Yh=[],Wh=[],Zh=[],$h=/* @__PURE__ */BigInt(0),Xh=/* @__PURE__ */BigInt(1),eu=/* @__PURE__ */BigInt(2),tu=/* @__PURE__ */BigInt(7),ru=/* @__PURE__ */BigInt(256),nu=/* @__PURE__ */BigInt(113);for(let e=0,t=Xh,r=1,n=0;e<24;e++){[r,n]=[n,(2*r+3*n)%5],Yh.push(2*(5*n+r)),Wh.push((e+1)*(e+2)/2%64);let i=$h;for(let e=0;e<7;e++)t=(t<>tu)*nu)%ru,t&eu&&(i^=Xh<<(Xh<r>32?Qh(e,t,r):Uh(e,t,r),ou=(e,t,r)=>r>32?Rh(e,t,r):xh(e,t,r);class cu extends $o{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,Fo(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(){Vo||Jo(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=au(s,a,1)^r[n],c=ou(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=Wh[r],s=au(t,i,n),a=ou(t,i,n),o=Yh[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]^=iu[n],e[1]^=su[n]}r.fill(0)}(this.state32,this.rounds),Vo||Jo(this.state32),this.posOut=0,this.pos=0}update(e){Ho(this);const{blockLen:t,state:r}=this,n=(e=Wo(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 Fo(e),this.xofInto(new Uint8Array(e))}digestInto(e){if(zo(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 cu(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 hu=(e,t,r)=>Xo((()=>new cu(t,e,r))),uu=/* @__PURE__ */hu(6,136,32),lu=/* @__PURE__ */hu(6,72,64),yu=/* @__PURE__ */((e,t,r)=>function(e){const t=(t,r)=>e(r).update(Wo(t)).digest(),r=e({});return t.outputLen=r.outputLen,t.blockLen=r.blockLen,t.create=t=>e(t),t}(((n={})=>new cu(t,e,void 0===n.dkLen?r:n.dkLen,!0))))(31,136,32),fu=BigInt(0),gu=BigInt(1),pu=BigInt(2),du=BigInt(8),Au={zip215:!0};function wu(e){const t=function(e){const t=fh(e);return Hc(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=pu<{try{return{isValid:!0,value:r.sqrt(e*r.inv(t))}}catch(e){return{isValid:!1,value:fu}}}),f=t.adjustScalarBytes||(e=>e),g=t.domain||((e,t,r)=>{if(wc("phflag",r),t.length||r)throw Error("Contexts/pre-hash are not supported");return e});function p(e,t){Rc("coordinate "+e,t,fu,h)}function d(e){if(!(e instanceof m))throw Error("ExtendedPoint expected")}const A=zc(((e,t)=>{const{ex:n,ey:i,ez:s}=e,a=e.is0();null==t&&(t=a?du:r.inv(s));const o=u(n*t),c=u(i*t),h=u(s*t);if(a)return{x:fu,y:gu};if(h!==gu)throw Error("invZ was invalid");return{x:o,y:c}})),w=zc((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,gu,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 yh(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(pu*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===fu)return this.double();const n=u(a*pu*y),f=u(o*pu*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;Rc("scalar",t,gu,n);const{p:r,f:i}=this.wNAF(t);return m.normalizeZ([r,i])[0]}multiplyUnsafe(e){const t=e;return Rc("scalar",t,fu,n),t===fu?k:this.equals(k)||t===gu?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===gu?this:this.multiplyUnsafe(e)}static fromHex(e,n=!1){const{d:i,a:s}=t,a=r.BYTES;e=Dc("pointHex",e,a),wc("zip215",n);const o=e.slice(),c=e[a-1];o[a-1]=-129&c;const l=Kc(o),f=n?h:r.ORDER;Rc("pointHex.y",l,fu,f);const g=u(l*l),p=u(g-gu),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&gu)===gu,k=!!(128&c);if(!n&&w===fu&&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=Pc(t,r.BYTES);return n[n.length-1]|=e&gu?128:0,n}toHex(){return bc(this.toRawBytes())}}m.BASE=new m(t.Gx,t.Gy,gu,u(t.Gx*t.Gy)),m.ZERO=new m(fu,gu,gu,fu);const{BASE:b,ZERO:k}=m,E=lh(m,8*o);function v(e){return Zc(e,n)}function B(e){return v(Kc(e))}function I(e){const t=o;e=Dc("private key",e,t);const r=Dc("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=Uc(...t);return B(s(g(r,Dc("context",e),!!i)))}const K=Au;b._setWindowSize(8);return{CURVE:t,getPublicKey:function(e){return I(e).pointBytes},sign:function(e,t,s={}){e=Dc("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 Rc("signature.s",y,fu,n),Dc("result",Uc(l,Pc(y,r.BYTES)),2*o)},verify:function(e,t,n,s=K){const{context:a,zip215:o}=s,c=r.BYTES;e=Dc("signature",e,2*c),t=Dc("message",t),void 0!==o&&wc("zip215",o),i&&(t=i(t));const h=Kc(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 mu=BigInt(0),bu=BigInt(1);function ku(e){const t=(Hc(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=>Zc(e,n),s=t.montgomeryBits,a=Math.ceil(s/8),o=t.nByteLength,c=t.adjustScalarBytes||(e=>e),h=t.powPminus2||(e=>$c(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 Pc(i(e),a)}function f(e,t){const r=function(e){const t=Dc("u coordinate",e,a);return 32===o&&(t[31]&=127),Kc(t)}(t),f=function(e){const t=Dc("scalar",e),r=t.length;if(r!==a&&r!==o)throw Error(`Expected ${a} or ${o} bytes, got ${r}`);return Kc(c(t))}(e),g=function(e,t){Rc("u",e,mu,n),Rc("scalar",t,mu,n);const r=t,a=e;let o,c=bu,y=mu,f=e,g=bu,p=mu;for(let e=BigInt(s-1);e>=mu;e--){const t=r>>e&bu;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===mu)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 Eu=Xo((()=>yu.create({dkLen:114}))),vu=(Xo((()=>yu.create({dkLen:64}))),BigInt("726838724295606890549323807888004534353641360687318060281490199180612328166730772686396383698676545930088884461843637361053498018365439")),Bu=BigInt(1),Iu=BigInt(2),Su=BigInt(3);BigInt(4);const Ku=BigInt(11),Cu=BigInt(22),Pu=BigInt(44),Du=BigInt(88),Uu=BigInt(223);function xu(e){const t=vu,r=e*e*e%t,n=r*r*e%t,i=Xc(n,Su,t)*n%t,s=Xc(i,Su,t)*n%t,a=Xc(s,Iu,t)*r%t,o=Xc(a,Ku,t)*a%t,c=Xc(o,Cu,t)*o%t,h=Xc(c,Pu,t)*c%t,u=Xc(h,Du,t)*h%t,l=Xc(u,Pu,t)*c%t,y=Xc(l,Iu,t)*r%t,f=Xc(y,Bu,t)*e%t;return Xc(f,Uu,t)*y%t}function Qu(e){return e[0]&=252,e[55]|=128,e[56]=0,e}const Ru=ih(vu,456,!0),Lu={a:BigInt(1),d:BigInt("726838724295606890549323807888004534353641360687318060281490199180612328166730772686396383698676545930088884461843637361053498018326358"),Fp:Ru,n:BigInt("181709681073901722637330951972001133588410340171829515070372549795146003961539585716195755291692375963310293709091662304773755859649779"),nBitLength:456,h:BigInt(4),Gx:BigInt("224580040295924300187604334099896036246789641632564134246125461686950415467406032909029192869357953282578032075146446173674602635247710"),Gy:BigInt("298819210078481492676017930443930673437544040154080242095928241372331506189835876003536878655418784733982303233503462500531545062832660"),hash:Eu,randomBytes:ec,adjustScalarBytes:Qu,domain:(e,t,r)=>{if(t.length>255)throw Error("Context is too big: "+t.length);return Zo(Yo("SigEd448"),new Uint8Array([r?1:0,t.length]),t,e)},uvRatio:function(e,t){const r=vu,n=Zc(e*e*t,r),i=Zc(n*e,r),s=Zc(i*n*t,r),a=Zc(i*xu(s),r),o=Zc(a*a,r);return{isValid:Zc(o*t,r)===e,value:a}}},Tu=/* @__PURE__ */wu(Lu),Mu=/* @__PURE__ */(()=>ku({a:BigInt(156326),montgomeryBits:448,nByteLength:56,P:vu,Gu:BigInt(5),powPminus2:e=>{const t=vu;return Zc(Xc(xu(e),BigInt(2),t)*e,t)},adjustScalarBytes:Qu,randomBytes:ec}))();Ru.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 Nu=BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),Fu=BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),Ou=BigInt(1),Hu=BigInt(2),zu=(e,t)=>(e+t/Hu)/t;const _u=ih(Nu,void 0,void 0,{sqrt:function(e){const t=Nu,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=Xc(u,r,t)*u%t,y=Xc(l,r,t)*u%t,f=Xc(y,Hu,t)*h%t,g=Xc(f,i,t)*f%t,p=Xc(g,s,t)*g%t,d=Xc(p,o,t)*p%t,A=Xc(d,c,t)*d%t,w=Xc(A,o,t)*p%t,m=Xc(w,r,t)*u%t,b=Xc(m,a,t)*g%t,k=Xc(b,n,t)*h%t,E=Xc(k,Hu,t);if(!_u.eql(_u.sqr(E),e))throw Error("Cannot find square root");return E}}),Gu=Bh({a:BigInt(0),b:BigInt(7),Fp:_u,n:Fu,Gx:BigInt("55066263022277343669578718895168534326250603453777594175500187360389116729240"),Gy:BigInt("32670510020758816978083085130507043184471273380659243275938904335757337482424"),h:BigInt(1),lowS:!0,endo:{beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),splitScalar:e=>{const t=Fu,r=BigInt("0x3086d221a7d46bcde86c90e49284eb15"),n=-Ou*BigInt("0xe4437ed6010e88286f547fa90abfe4c3"),i=BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),s=r,a=BigInt("0x100000000000000000000000000000000"),o=zu(s*e,t),c=zu(-n*e,t);let h=Zc(e-o*r-c*i,t),u=Zc(-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}}}},hc);BigInt(0),Gu.ProjectivePoint;const ju=ih(BigInt("0xa9fb57dba1eea9bc3e660a909d838d726e3bf623d52620282013481d1f6e5377")),qu=Bh({a:ju.create(BigInt("0x7d5a0975fc2c3057eef67530417affe7fb8055c126dc5c6ce94a4b44f330b5d9")),b:BigInt("0x26dc5c6ce94a4b44f330b5d9bbd77cbf958416295cf7e1ce6bccdc18ff8c07b6"),Fp:ju,n:BigInt("0xa9fb57dba1eea9bc3e660a909d838d718c397aa3b561a6f7901e0e82974856a7"),Gx:BigInt("0x8bd2aeb9cb7e57cb2c4b482ffc81b7afb9de27e1e3bd23c23a4453bd9ace3262"),Gy:BigInt("0x547ef835c3dac4fd97f8461a14611dc9c27745132ded8e545c1d54c72f046997"),h:BigInt(1),lowS:!1},hc),Vu=ih(BigInt("0x8cb91e82a3386d280f5d6f7e50e641df152f7109ed5456b412b1da197fb71123acd3a729901d1a71874700133107ec53")),Ju=Bh({a:Vu.create(BigInt("0x7bc382c63d8c150c3c72080ace05afa0c2bea28e4fb22787139165efba91f90f8aa5814a503ad4eb04a8c7dd22ce2826")),b:BigInt("0x04a8c7dd22ce28268b39b55416f0447c2fb77de107dcd2a62e880ea53eeb62d57cb4390295dbc9943ab78696fa504c11"),Fp:Vu,n:BigInt("0x8cb91e82a3386d280f5d6f7e50e641df152f7109ed5456b31f166e6cac0425a7cf3ab6af6b7fc3103b883202e9046565"),Gx:BigInt("0x1d1c64f068cf45ffa2a63a81b7c13f6b8847a3e77ef14fe3db7fcafe0cbd10e8e826e03436d646aaef87b2e247d4af1e"),Gy:BigInt("0x8abe1d7520f9c2a45cb1eb8e95cfd55262b70b29feec5864e19c054ff99129280e4646217791811142820341263c5315"),h:BigInt(1),lowS:!1},_h),Yu=ih(BigInt("0xaadd9db8dbe9c48b3fd4e6ae33c9fc07cb308db3b3c9d20ed6639cca703308717d4d9b009bc66842aecda12ae6a380e62881ff2f2d82c68528aa6056583a48f3")),Wu=Bh({a:Yu.create(BigInt("0x7830a3318b603b89e2327145ac234cc594cbdd8d3df91610a83441caea9863bc2ded5d5aa8253aa10a2ef1c98b9ac8b57f1117a72bf2c7b9e7c1ac4d77fc94ca")),b:BigInt("0x3df91610a83441caea9863bc2ded5d5aa8253aa10a2ef1c98b9ac8b57f1117a72bf2c7b9e7c1ac4d77fc94cadc083e67984050b75ebae5dd2809bd638016f723"),Fp:Yu,n:BigInt("0xaadd9db8dbe9c48b3fd4e6ae33c9fc07cb308db3b3c9d20ed6639cca70330870553e5c414ca92619418661197fac10471db1d381085ddaddb58796829ca90069"),Gx:BigInt("0x81aee4bdd82ed9645a21322e9c4c6a9385ed9f70b5d916c1b43b62eef4d0098eff3b1f78e2d0d48d50d1687b93b97d5f7c6d5047406a5e688b352209bcb9f822"),Gy:BigInt("0x7dde385d566332ecc0eabfa9cf7822fdf209f70024a57b1aa000c55b881f8111b2dcde494a5f485e5bca4bd88a2763aed1ca2b2fa8f0540678cd1e0f3ad80892"),h:BigInt(1),lowS:!1},zh),Zu=new Map(Object.entries({nistP256:Sh,nistP384:jh,nistP521:Jh,brainpoolP256r1:qu,brainpoolP384r1:Ju,brainpoolP512r1:Wu,secp256k1:Gu,x448:Mu,ed448:Tu}));var $u=/*#__PURE__*/Object.freeze({__proto__:null,nobleCurves:Zu});function Xu(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 el(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 tl(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 Xu(el(this.key[2]),Xu(el(this.key[1]),Xu(el(this.key[0]),e,!0),!1),!0)}}function rl(){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 nl(e){this.cast5=new rl,this.cast5.setKey(e),this.encrypt=function(e){return this.cast5.encrypt(e)}}tl.keySize=tl.prototype.keySize=24,tl.blockSize=tl.prototype.blockSize=8,nl.blockSize=nl.prototype.blockSize=8,nl.keySize=nl.prototype.keySize=16;const il=4294967295;function sl(e,t){return(e<>>32-t)&il}function al(e,t){return e[t]|e[t+1]<<8|e[t+2]<<16|e[t+3]<<24}function ol(e,t,r){e.splice(t,4,255&r,r>>>8&255,r>>>16&255,r>>>24&255)}function cl(e,t){return e>>>8*t&255}function hl(e){this.tf=function(){let e=null,t=null,r=-1,n=[],i=[[],[],[],[]];function s(e){return i[0][cl(e,0)]^i[1][cl(e,1)]^i[2][cl(e,2)]^i[3][cl(e,3)]}function a(e){return i[0][cl(e,3)]^i[1][cl(e,0)]^i[2][cl(e,1)]^i[3][cl(e,2)]}function o(e,t){let r=s(t[0]),i=a(t[1]);t[2]=sl(t[2]^r+i+n[4*e+8]&il,31),t[3]=sl(t[3],1)^r+2*i+n[4*e+9]&il,r=s(t[2]),i=a(t[3]),t[0]=sl(t[0]^r+i+n[4*e+10]&il,31),t[1]=sl(t[1],1)^r+2*i+n[4*e+11]&il}function c(e,t){let r=s(t[0]),i=a(t[1]);t[2]=sl(t[2],1)^r+i+n[4*e+10]&il,t[3]=sl(t[3]^r+2*i+n[4*e+11]&il,31),r=s(t[2]),i=a(t[3]),t[0]=sl(t[0],1)^r+i+n[4*e+8]&il,t[1]=sl(t[1]^r+2*i+n[4*e+9]&il,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&il|e>>>24,e=e<<8&il,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=cl(e,0),n=cl(e,1),i=cl(e,2),s=cl(e,3);switch(y){case 4:r=v[1][r]^cl(t[3],0),n=v[0][n]^cl(t[3],1),i=v[0][i]^cl(t[3],2),s=v[1][s]^cl(t[3],3);case 3:r=v[1][r]^cl(t[2],0),n=v[1][n]^cl(t[2],1),i=v[0][i]^cl(t[2],2),s=v[0][s]^cl(t[2],3);case 2:r=v[0][v[0][r]^cl(t[1],0)]^cl(t[0],0),n=v[0][v[1][n]^cl(t[1],1)]^cl(t[0],1),i=v[1][v[0][i]^cl(t[1],2)]^cl(t[0],2),s=v[1][v[1][s]^cl(t[1],3)]^cl(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]=al(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);ol(t,r,s[2]^n[0]),ol(t,r+4,s[3]^n[1]),ol(t,r+8,s[0]^n[2]),ol(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 ul(){}function ll(e){this.bf=new ul,this.bf.init(e),this.encrypt=function(e){return this.bf.encryptBlock(e)}}hl.keySize=hl.prototype.keySize=32,hl.blockSize=hl.prototype.blockSize=16,ul.prototype.BLOCKSIZE=8,ul.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]],ul.prototype.PARRAY=[608135816,2242054355,320440878,57701188,2752067618,698298832,137296536,3964562569,1160258022,953160567,3193202383,887688300,3232508343,3380367581,1065670069,3041331479,2450970073,2306472731],ul.prototype.NN=16,ul.prototype._clean=function(e){if(e<0){e=(2147483647&e)+2147483648}return e},ul.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},ul.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},ul.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)},ul.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 dl)),wl=/* @__PURE__ */new Uint8Array([7,4,13,1,10,6,15,3,12,0,9,5,2,14,11,8]),ml=/* @__PURE__ */new Uint8Array(Array(16).fill(0).map(((e,t)=>t))),bl=/* @__PURE__ */ml.map((e=>(9*e+5)%16));let kl=[ml],El=[bl];for(let e=0;e<4;e++)for(let t of[kl,El])t.push(t[e].map((e=>wl[e])));const vl=/* @__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))),Bl=/* @__PURE__ */kl.map(((e,t)=>e.map((e=>vl[t][e])))),Il=/* @__PURE__ */El.map(((e,t)=>e.map((e=>vl[t][e])))),Sl=/* @__PURE__ */new Uint32Array([0,1518500249,1859775393,2400959708,2840853838]),Kl=/* @__PURE__ */new Uint32Array([1352829926,1548603684,1836072691,2053994217,0]);function Cl(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 Pl=/* @__PURE__ */new Uint32Array(16);class Dl extends nc{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)Pl[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=Sl[e],f=Kl[e],g=kl[e],p=El[e],d=Bl[e],A=Il[e];for(let t=0;t<16;t++){const n=qo(r+Cl(e,i,a,c)+Pl[g[t]]+y,d[t])+u|0;r=u,u=c,c=0|qo(a,10),a=i,i=n}for(let e=0;e<16;e++){const r=qo(n+Cl(t,s,o,h)+Pl[p[e]]+f,A[e])+l|0;n=l,l=h,h=0|qo(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(){Pl.fill(0)}destroy(){this.destroyed=!0,this.buffer.fill(0),this.set(0,0,0,0,0)}}const Ul=new Map(Object.entries({sha1:Al,sha224:uc,sha256:hc,sha384:_h,sha512:zh,sha3_256:uu,sha3_512:lu,ripemd160:/* @__PURE__ */Xo((()=>new Dl))}));var xl=/*#__PURE__*/Object.freeze({__proto__:null,nobleHashes:Ul});function Ql(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,Ql(e,r,e,n),Ql(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,Ql(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 Tl=new Uint32Array([4089235720,1779033703,2227873595,3144134277,4271175723,1013904242,1595750129,2773480762,2917565137,1359893119,725511199,2600822924,4215389547,528734635,327033209,1541459225]),Ml=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 Nl(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]=Tl[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;Ll(r,n,0,8,16,24,Ml[t+0],Ml[t+1]),Ll(r,n,2,10,18,26,Ml[t+2],Ml[t+3]),Ll(r,n,4,12,20,28,Ml[t+4],Ml[t+5]),Ll(r,n,6,14,22,30,Ml[t+6],Ml[t+7]),Ll(r,n,0,10,20,30,Ml[t+8],Ml[t+9]),Ll(r,n,2,12,22,24,Ml[t+10],Ml[t+11]),Ll(r,n,4,14,16,26,Ml[t+12],Ml[t+13]),Ll(r,n,6,8,18,28,Ml[t+14],Ml[t+15])}for(let t=0;t<16;t++)e.h[t]^=r[t]^r[t+16]}class Fl{constructor(e,t,r,n){const i=new Uint8Array(64);this.S={b:new Uint8Array(zl),h:new Uint32Array(Hl/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]=Tl[e]^s[e];if(t){const e=new Uint8Array(zl);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 Ol(e,t,r,n){if(e>Hl)throw Error(`outlen must be at most ${Hl} (given: ${e})`);return new Fl(e,t,r,n)}const Hl=64,zl=128,_l=2,Gl=19,jl=4294967295,ql=4,Vl=4294967295,Jl=8,Yl=4294967295,Wl=8,Zl=4294967295,$l=4294967295,Xl=32,ey=1024,ty=64,ry=205===new Uint8Array(new Uint16Array([43981]).buffer)[0];function ny(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 iy(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!==_l||t!==Gl)throw Error("Unsupported type or version");return u("password",n,Wl,Yl),u("salt",i,Jl,Vl),u("tag",r,ql,jl),u("memory",c,8*o,Zl),s&&u("associated data",s,0,$l),a&&u("secret",a,0,Xl),{type:e,version:t,tagLength:r,password:n,salt:i,ad:s,secret:a,lanes:o,memorySize:c,passes:h}}({type:_l,version:Gl,...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*ey+10*uy;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+ey),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),oy(g,h,b[l][y],e>0?p:b[i][c]),e>0&&ay(g,b[i][c],p,b[i][c])}}}const v=b[0][m-1];for(let e=1;eyy(e,{instance:n.instance,memory:r})}function py(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 dy=/*#__PURE__*/Object.freeze({__proto__:null,default:async()=>gy((e=>py(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=>py(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)))}),Ay=[0,1,3,7,15,31,63,127,255],wy=function(e){this.stream=e,this.bitOffset=0,this.curByte=0,this.hasByte=!1};wy.prototype._ensureByte=function(){this.hasByte||(this.curByte=this.stream.readByte(),this.hasByte=!0)},wy.prototype.read=function(e){for(var t=0;e>0;){this._ensureByte();var r=8-this.bitOffset;if(e>=r)t<<=r,t|=Ay[r]&this.curByte,this.hasByte=!1,this.bitOffset=0,e-=r;else{t<<=e;var n=r-e;t|=(this.curByte&Ay[e]<>n,this.bitOffset+=e,e=0}}return t},wy.prototype.seek=function(e){var t=e%8,r=(e-t)/8;this.bitOffset=t,this.stream.seek(r),this.hasByte=!1},wy.prototype.pi=function(){var e,t=new Uint8Array(6);for(e=0;e("00"+e.toString(16)).slice(-2))).join("")}(t)};var my=wy,by=function(){};by.prototype.readByte=function(){throw Error("abstract method readByte() not implemented")},by.prototype.read=function(e,t,r){for(var n=0;n>>0},this.updateCRC=function(t){e=e<<8^ky[255&(e>>>24^t)]},this.updateCRCRun=function(t,r){for(;r-- >0;)e=e<<8^ky[255&(e>>>24^t)]}}),By=my,Iy=Ey,Sy=vy,Ky=function(e,t){var r,n=e[t];for(r=t;r>0;r--)e[r]=e[r-1];return e[0]=n,n},Cy={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},Py={};Py[Cy.LAST_BLOCK]="Bad file checksum",Py[Cy.NOT_BZIP_DATA]="Not bzip data",Py[Cy.UNEXPECTED_INPUT_EOF]="Unexpected input EOF",Py[Cy.UNEXPECTED_OUTPUT_EOF]="Unexpected output EOF",Py[Cy.DATA_ERROR]="Data error",Py[Cy.OUT_OF_MEMORY]="Out of memory",Py[Cy.OBSOLETE_INPUT]="Obsolete (pre 0.9.5) bzip format not supported.";var Dy=function(e,t){var r=Py[e]||"unknown error";t&&(r+=": "+t);var n=new TypeError(r);throw n.errorCode=e,n},Uy=function(e,t){this.writePos=this.writeCurrent=this.writeCount=0,this._start_bunzip(e,t)};Uy.prototype._init_block=function(){return this._get_next_block()?(this.blockCRC=new Sy,!0):(this.writeCount=-1,!1)},Uy.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])||Dy(Cy.NOT_BZIP_DATA,"bad magic");var n=r[3]-48;(n<1||n>9)&&Dy(Cy.NOT_BZIP_DATA,"level out of range"),this.reader=new By(e),this.dbufSize=1e5*n,this.nextoutput=0,this.outputStream=t,this.streamCRC=0},Uy.prototype._get_next_block=function(){var e,t,r,n=this.reader,i=n.pi();if("177245385090"===i)return!1;"314159265359"!==i&&Dy(Cy.NOT_BZIP_DATA),this.targetBlockCRC=n.read(32)>>>0,this.streamCRC=(this.targetBlockCRC^(this.streamCRC<<1|this.streamCRC>>>31))>>>0,n.read(1)&&Dy(Cy.OBSOLETE_INPUT);var s=n.read(24);s>this.dbufSize&&Dy(Cy.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)&&Dy(Cy.DATA_ERROR);var l=n.read(15);0===l&&Dy(Cy.DATA_ERROR);var y=new Uint8Array(256);for(e=0;e=u&&Dy(Cy.DATA_ERROR);f[e]=Ky(y,t)}var g,p=c+2,d=[];for(t=0;t20)&&Dy(Cy.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&&Dy(Cy.DATA_ERROR),g=d[f[S++]]),e=g.minLen,t=n.read(e);e>g.maxLen&&Dy(Cy.DATA_ERROR),!(t<=g.limit[e]);e++)t=t<<1|n.read(1);((t-=g.base[e])<0||t>=258)&&Dy(Cy.DATA_ERROR);var C=g.permute[t];if(0!==C&&1!==C){if(B)for(B=0,I+a>this.dbufSize&&Dy(Cy.DATA_ERROR),E[v=o[y[0]]]+=a;a--;)K[I++]=v;if(C>c)break;I>=this.dbufSize&&Dy(Cy.DATA_ERROR),E[v=o[v=Ky(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)&&Dy(Cy.DATA_ERROR),t=0,e=0;e<256;e++)r=t+E[e],E[e]=t,t=r;for(e=0;e>=8,U=-1),this.writePos=P,this.writeCurrent=D,this.writeCount=I,this.writeRun=U,!0},Uy.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&&Dy(Cy.DATA_ERROR,"Bad block CRC (got "+this.blockCRC.getCRC().toString(16)+" expected "+this.targetBlockCRC.toString(16)+")"),this.nextoutput};var xy=function(e){if("readByte"in e)return e;var t=new Iy;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},Qy=function(e){var t=new Iy,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 Ry={Bunzip:Uy,Stream:Iy,Err:Cy,decode:function(e,t,r){for(var n=xy(e),i=Qy(t),s=new Uy(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&&Dy(Cy.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=xy(e),i=Qy(r),s=new Uy(n,i);if(s.reader.seek(t),s._get_next_block()&&(s.blockCRC=new Sy,s.writeCopies=0,s._read_bunzip()),"getBuffer"in i)return i.getBuffer()},table:function(e,t,r){var n=new Iy;n.delegate=xy(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 Iy;i.pos=0,i.writeByte=function(){this.pos++};for(var s=new Uy(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")}}}},Ly=/*#__PURE__*/s({__proto__:null},[Ry]);exports.AEADEncryptedDataPacket=La,exports.CleartextMessage=Po,exports.CompressedDataPacket=Ia,exports.LiteralDataPacket=fa,exports.MarkerPacket=class{static get tag(){return F.packet.marker}read(e){return 80===e[0]&&71===e[1]&&80===e[2]}write(){return new Uint8Array([80,71,80])}},exports.Message=Io,exports.OnePassSignaturePacket=ka,exports.PacketList=va,exports.PaddingPacket=class{static get tag(){return F.packet.padding}constructor(){this.padding=null}read(e){}write(){return this.padding}async createPadding(e){this.padding=await ls.random.getRandomBytes(e)}},exports.PrivateKey=wo,exports.PublicKey=Ao,exports.PublicKeyEncryptedSessionKeyPacket=Ta,exports.PublicKeyPacket=Fa,exports.PublicSubkeyPacket=za,exports.SecretKeyPacket=Ga,exports.SecretSubkeyPacket=Va,exports.Signature=Ya,exports.SignaturePacket=wa,exports.Subkey=lo,exports.SymEncryptedIntegrityProtectedDataPacket=xa,exports.SymEncryptedSessionKeyPacket=Na,exports.SymmetricallyEncryptedDataPacket=Ha,exports.TrustPacket=class{static get tag(){return F.packet.trust}read(){throw new Zn("Trust packets are not supported")}write(){throw new Zn("Trust packets are not supported")}},exports.UnparseablePacket=Xn,exports.UserAttributePacket=_a,exports.UserIDPacket=qa,exports.armor=ie,exports.config=O,exports.createCleartextMessage=async function({text:e,...t}){if(!e)throw Error("createCleartextMessage: must pass options object containing `text`");if(!z.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 Po(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&&!z.isString(e)&&!z.isStream(e))throw Error("createMessage: options.text must be a string or stream");if(t&&!z.isUint8Array(t)&&!z.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=z.isStream(a),h=new fa(n);void 0!==e?h.setText(a,F.write(F.literal,i)):h.setBytes(a,F.write(F.literal,i)),void 0!==r&&h.setFilename(r);const u=new va;u.push(h);const l=new Io(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(Ro(h={...O,...h}),Do(e),i=Lo(i),t=Lo(t),r=Lo(r),n=Lo(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(),Mo(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=E([l.data,L((async()=>(await z.anyPromise(l.signatures.map((e=>e.verified))),"binary"===a?new Uint8Array:"")))])}return l.data=await To(l.data),l}catch(e){throw z.wrapError("Error decrypting message",e)}},exports.decryptKey=async function({privateKey:e,passphrase:t,config:r,...n}){Ro(r={...O,...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=z.isArray(t)?t:[t];try{return await Promise.all(s.getKeys().map((e=>z.anyPromise(a.map((t=>e.keyPacket.decrypt(t))))))),await s.validate(r),s}catch(e){throw s.clearPrivateParams(),z.wrapError("Error decrypting private key",e)}},exports.decryptSessionKeys=async function({message:e,decryptionKeys:t,passwords:r,date:n=new Date,config:i,...s}){if(Ro(i={...O,...i}),Do(e),t=Lo(t),r=Lo(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 z.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(Ro(g={...O,...g}),Do(e),xo(s),t=Lo(t),r=Lo(r),n=Lo(n),c=Lo(c),h=Lo(h),l=Lo(l),y=Lo(y),f=Lo(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=O){const i=F.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 To(p)}catch(e){throw z.wrapError("Error encrypting message",e)}},exports.encryptKey=async function({privateKey:e,passphrase:t,config:r,...n}){Ro(r={...O,...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=z.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(),z.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(Ro(u={...O,...u}),function(e){if(!z.isUint8Array(e))throw Error("Parameter [data] must be of type Uint8Array")}(e),function(e,t){if(!z.isString(e))throw Error("Parameter ["+t+"] must be of type String")}(t,"algorithm"),xo(s),n=Lo(n),i=Lo(i),o=Lo(o),h=Lo(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 No(await Io.encryptSessionKey(e,t,r,n,i,a,o,c,h,u),s,u)}catch(e){throw z.wrapError("Error encrypting session key",e)}},exports.enums=F,exports.generateKey=async function({userIDs:e=[],passphrase:t,type:r,curve:n,rsaBits:i=4096,keyExpirationTime:s=0,date:a=new Date,subkeys:o=[{}],format:c="armored",config:h,...u}){Ro(h={...O,...h}),r||n?(r=r||"ecc",n=n||"curve25519Legacy"):(r=h.v6Keys?"curve25519":"ecc",n="curve25519Legacy"),e=Lo(e);const l=Object.keys(u);if(l.length>0)throw Error("Unknown option: "+l.join(", "));if(0===e.length&&!h.v6Keys)throw Error("UserIDs are required for V4 keys");if("rsa"===r&&iso(e.subkeys[r],e)));let r=[Za(e,t)];r=r.concat(e.subkeys.map((e=>Wa(e,t))));const n=await Promise.all(r),i=await ko(n[0],n.slice(1),e,t),s=await i.getRevocationCertificate(e.date,t);return i.revocationSignatures=[],{key:i,revocationCertificate:s}}(y,h);return e.getKeys().forEach((({keyPacket:e})=>ho(e,h))),{privateKey:No(e,c,h),publicKey:No(e.toPublic(),c,h),revocationCertificate:t}}catch(e){throw z.wrapError("Error generating keypair",e)}},exports.generateSessionKey=async function({encryptionKeys:e,date:t=new Date,encryptionUserIDs:r=[],config:n,...i}){if(Ro(n={...O,...n}),e=Lo(e),r=Lo(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 Io.generateSessionKey(e,t,r,n)}catch(e){throw z.wrapError("Error generating session key",e)}},exports.readCleartextMessage=async function({cleartextMessage:e,config:t,...r}){if(t={...O,...t},!e)throw Error("readCleartextMessage: must pass options object containing `cleartextMessage`");if(!z.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 ne(e);if(i.type!==F.armor.signed)throw Error("No cleartext signed message.");const s=await va.fromBinary(i.data,Co,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 F.write(F.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 Ya(s);return new Po(i.text,a)},exports.readKey=async function({armoredKey:e,binaryKey:t,config:r,...n}){if(r={...O,...r},!e&&!t)throw Error("readKey: must pass options object containing `armoredKey` or `binaryKey`");if(e&&!z.isString(e))throw Error("readKey: options.armoredKey must be a string");if(t&&!z.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 ne(e);if(t!==F.armor.publicKey&&t!==F.armor.privateKey)throw Error("Armored text not of type key");s=r}else s=t;const a=await va.fromBinary(s,mo,r),o=a.indexOfTag(F.packet.publicKey,F.packet.secretKey);if(0===o.length)throw Error("No key packet found");return bo(a.slice(o[0],o[1]))},exports.readKeys=async function({armoredKeys:e,binaryKeys:t,config:r,...n}){r={...O,...r};let i=e||t;if(!i)throw Error("readKeys: must pass options object containing `armoredKeys` or `binaryKeys`");if(e&&!z.isString(e))throw Error("readKeys: options.armoredKeys must be a string");if(t&&!z.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 ne(e);if(t!==F.armor.publicKey&&t!==F.armor.privateKey)throw Error("Armored text not of type key");i=r}const a=[],o=await va.fromBinary(i,mo,r),c=o.indexOfTag(F.packet.publicKey,F.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=z.isStream(i);if(e){const{type:e,data:t}=await ne(i);if(e!==F.armor.message)throw Error("Armored text not of type message");i=t}const o=await va.fromBinary(i,Eo,r),c=new Io(o);return c.fromStream=a,c},exports.readPrivateKey=async function({armoredKey:e,binaryKey:t,config:r,...n}){if(r={...O,...r},!e&&!t)throw Error("readPrivateKey: must pass options object containing `armoredKey` or `binaryKey`");if(e&&!z.isString(e))throw Error("readPrivateKey: options.armoredKey must be a string");if(t&&!z.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 ne(e);if(t!==F.armor.privateKey)throw Error("Armored text not of type private key");s=r}else s=t;const a=await va.fromBinary(s,mo,r),o=a.indexOfTag(F.packet.publicKey,F.packet.secretKey);for(let e=0;e0)throw Error("Unknown option: "+s.join(", "));if(e){const{type:e,data:t}=await ne(i);if(e!==F.armor.signature)throw Error("Armored text not of type signature");i=t}const a=await va.fromBinary(i,Ja,r);return new Ya(a)},exports.reformatKey=async function({privateKey:e,userIDs:t=[],passphrase:r,keyExpirationTime:n=0,date:i,format:s="armored",config:a,...o}){Ro(a={...O,...a}),t=Lo(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 $a(e.bindingSignatures,n,F.signature.subkeyBinding,i,null,t).catch((()=>({})));return{sign:s.keyFlags&&s.keyFlags[0]&F.keyFlags.signData}}))));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 ko(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=z.isString(e.passphrase)?e.passphrase:t.passphrase,e.date=e.date||t.date,e}}(h,a);return{privateKey:No(e,s,a),publicKey:No(e.toPublic(),s,a),revocationCertificate:t}}catch(e){throw z.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}){Ro(s={...O,...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:No(a,i,s),publicKey:No(a.toPublic(),i,s)}:{privateKey:null,publicKey:No(a,i,s)}}catch(e){throw z.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(Ro(u={...O,...u}),Uo(e),xo(n),t=Lo(t),s=Lo(s),o=Lo(o),r=Lo(r),c=Lo(c),h=Lo(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 Po&&"binary"===n)throw Error("Cannot return signed cleartext message in binary format");if(e instanceof Po&&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=K(e.packets.write(),(async(e,t)=>{await Promise.all([v(l,t),Q(e).catch((()=>{}))])}))),await To(l)}catch(e){throw z.wrapError("Error signing message",e)}},exports.unarmor=ne,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(Ro(a={...O,...a}),Uo(e),t=Lo(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 Po&&"binary"===n)throw Error("Can't return cleartext message data as binary");if(e instanceof Po&&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&&Mo(o,e),r){if(0===o.signatures.length)throw Error("Message is not signed");o.data=E([o.data,L((async()=>(await z.anyPromise(o.signatures.map((e=>e.verified))),"binary"===n?new Uint8Array:"")))])}return o.data=await To(o.data),o}catch(e){throw z.wrapError("Error verifying signed message",e)}}; //# sourceMappingURL=openpgp.min.cjs.map