@rizom/ops 0.2.0-alpha.663 → 0.2.0-alpha.665
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/brains-ops.js +1 -1
- package/dist/index.js +1 -1
- package/package.json +1 -1
package/dist/brains-ops.js
CHANGED
|
@@ -698,7 +698,7 @@ printf 'REMOTE_ARTIFACT_DIR=%s\\n' "$remote_dir"
|
|
|
698
698
|
`).replace(/\\n/g,`
|
|
699
699
|
`).trimEnd()}
|
|
700
700
|
`}var Y3,Xpe;var Q$=w(async()=>{he();V3();fn();Rf();await H3();Y3=l.object({HCLOUD_TOKEN:l.string().min(1),KAMAL_SSH_PRIVATE_KEY:l.string().min(1)}),Xpe=l.object({servers:l.array(l.object({status:l.string(),public_net:l.object({ipv4:l.object({ip:l.string().min(1)})})}))})});import{parseArgs as B5}from"util";function ot(e){return e}class Nf extends Error{constructor(e){super(e);this.name="CliUsageError"}}function Z5(e,t){let r={...t};for(let o of e)for(let[n,i]of Object.entries(o.flags??{})){let s=r[n];if(s===void 0){r[n]=i;continue}if(s.type!==i.type||s.short!==i.short||s.default!==i.default)throw Error(`Conflicting definitions for flag --${n}: commands must agree on type, short, and default`)}return r}function U5(e){let t={};for(let[r,o]of Object.entries(e))t[r]={type:o.type,...o.short!==void 0?{short:o.short}:{},...o.default!==void 0?{default:o.default}:{}};return t}function q5(e){if(!(e instanceof Error)||!("code"in e))return!1;return e.code==="ERR_PARSE_ARGS_UNKNOWN_OPTION"||e.code==="ERR_PARSE_ARGS_INVALID_OPTION_VALUE"}function eR(e,t){let r=Z5(t.commands,t.globalFlags??{}),o,n;try{({values:o,positionals:n}=B5({args:e,options:U5(r),allowPositionals:!0,strict:t.strict??!0}))}catch(s){if(q5(s))throw new Nf(s.message.split(". ")[0]??s.message);throw s}if("help"in r&&o.help===!0)return{command:"help",args:[],flags:{help:!0}};if("version"in r&&o.version===!0)return{command:"version",args:[],flags:{version:!0}};let i={};for(let[s,a]of Object.entries(r)){let c=o[s];if(typeof c==="string"&&a.type==="string")i[s]=c;else if(typeof c==="boolean"&&a.type==="boolean")i[s]=c}return{command:n[0]??"help",args:n.slice(1),flags:i}}function tR(e){let t=e.reduce((r,o)=>Math.max(r,o.label.length),0);return e.map((r)=>` ${r.label.padEnd(t)} ${r.description}`)}function M5(e){return tR(e.map((t)=>({label:t.usage?`${t.name} ${t.usage}`:t.name,description:t.description})))}function F5(e,t){let r=t.type==="string"?` ${t.placeholder??"<value>"}`:"",o=t.short!==void 0?`, -${t.short}`:"";return`--${e}${r}${o}`}function rR(e){return tR(Object.entries(e).map(([t,r])=>({label:F5(t,r),description:r.description})))}function nR(e,t){return`Usage: ${e} ${t.name}${t.usage?` ${t.usage}`:""}`}function J5(e){return JSON.stringify(Object.entries(e).map(([t,r])=>[t,r.type,r.short??"",r.description,r.placeholder??"",r.default??""]).sort((t,r)=>String(t[0]).localeCompare(String(r[0]))))}function K5(e){let t=[],r=new Map;for(let n of e){let i=n.flags??{};if(Object.keys(i).length===0)continue;let s=J5(i),a=r.get(s);if(a){a.names.push(n.name);continue}let c={names:[n.name],flags:i};r.set(s,c),t.push(c)}let o=[];for(let n of t)o.push("",`${n.names.join(" / ")} options:`),o.push(...rR(n.flags));return o}function oR(e){let t=[e.intro,"",`Usage: ${e.cliName} ${e.usage??"<command> [args]"}`,"","Commands:",...M5(e.commands)];if(e.globalFlags&&Object.keys(e.globalFlags).length>0)t.push("","Options:",...rR(e.globalFlags));return t.push(...K5(e.commands)),t.join(`
|
|
701
|
-
`)}function iR(e){let t=new Map;for(let r of e){if(t.has(r.name))throw Error(`Duplicate command name: ${r.name}`);t.set(r.name,r)}return t}function nt(e,t){let r=e[t];return typeof r==="string"?r:void 0}function ts(e,t){let r=e[t];return typeof r==="boolean"?r:void 0}var Df={name:"@rizom/ops",version:"0.2.0-alpha.663",description:"Operator CLI for managing private brain fleet registry repos",keywords:["brains","ops","cli","deploy","fleet","operator"],license:"AGPL-3.0-only",author:"Yeehaa <yeehaa@rizom.ai> (https://rizom.ai)",bin:{"brains-ops":"./dist/brains-ops.js"},bugs:"https://github.com/rizom-ai/brains/issues",dependencies:{"@libsql/client":"^0.17.4","age-encryption":"^0.3.0",yaml:"^2.9.0"},devDependencies:{"@brains/contracts":"workspace:*","@brains/deploy-support":"workspace:*","@brains/eslint-config":"workspace:*","@brains/job-queue":"workspace:*","@brains/profile":"workspace:*","@brains/site-composition":"workspace:*","@brains/test-utils":"workspace:*","@brains/typescript-config":"workspace:*","@brains/utils":"workspace:*","@types/bun":"^1.4.0",typescript:"^7.0.2"},engines:{bun:">=1.3.3"},exports:{".":{types:"./dist/index.d.ts",import:"./dist/index.js"},"./deploy":{types:"./dist/deploy.d.ts",import:"./dist/deploy.js",bun:"./dist/deploy.js"}},files:["dist","templates"],homepage:"https://github.com/rizom-ai/brains/tree/main/packages/brains-ops#readme",main:"./dist/index.js",publishConfig:{access:"public"},repository:{type:"git",url:"https://github.com/rizom-ai/brains.git",directory:"packages/brains-ops"},scripts:{build:"bun scripts/build.ts",lint:"eslint . --max-warnings 0","lint:fix":"eslint . --max-warnings 0 --fix",prepublishOnly:"bun scripts/build.ts",test:"bun test --timeout 20000","test:smoke":"bun run build && RUN_SMOKE_TESTS=1 bun test --timeout 60000",typecheck:"tsc --noEmit"},type:"module",types:"./dist/index.d.ts"};import{existsSync as wK,mkdirSync as xK,readFileSync as zS,writeFileSync as NS}from"fs";import{dirname as _K,join as mC}from"path";function Vy(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name==="Uint8Array"&&"BYTES_PER_ELEMENT"in e&&e.BYTES_PER_ELEMENT===1}function St(e,t=""){if(typeof e!=="number"){let r=t&&`"${t}" `;throw TypeError(`${r}expected number, got ${typeof e}`)}if(!Number.isSafeInteger(e)||e<0){let r=t&&`"${t}" `;throw RangeError(`${r}expected integer >= 0, got ${e}`)}}function Ut(e,t,r=""){let o=Vy(e),n=e?.length,i=t!==void 0;if(!o||i&&n!==t){let s=r&&`"${r}" `,a=i?` of length ${t}`:"",c=o?`length=${n}`:`type=${typeof e}`,u=s+"expected Uint8Array"+a+", got "+c;if(!o)throw TypeError(u);throw RangeError(u)}return e}function no(e){if(typeof e!=="function"||typeof e.create!=="function")throw TypeError("Hash must wrapped by utils.createHasher");if(St(e.outputLen),St(e.blockLen),e.outputLen<1)throw Error('"outputLen" must be >= 1');if(e.blockLen<1)throw Error('"blockLen" must be >= 1')}function pa(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 Lf(e,t){Ut(e,void 0,"digestInto() output");let r=t.outputLen;if(e.length<r)throw RangeError('"digestInto() output" expected to be of length >='+r)}function jf(e){return new Uint32Array(e.buffer,e.byteOffset,Math.floor(e.byteLength/4))}function cr(...e){for(let t=0;t<e.length;t++)e[t].fill(0)}function ma(e){return new DataView(e.buffer,e.byteOffset,e.byteLength)}function rn(e,t){return e<<32-t|e>>>t}function Fe(e,t){return e<<t|e>>>32-t>>>0}var V5=(()=>new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68)();function W5(e){return e<<24&4278190080|e<<8&16711680|e>>>8&65280|e>>>24&255}function G5(e){for(let t=0;t<e.length;t++)e[t]=W5(e[t]);return e}var Wy=V5?(e)=>e:G5,aR=(()=>typeof Uint8Array.from([]).toHex==="function"&&typeof Uint8Array.fromHex==="function")(),Q5=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,"0"));function Bf(e){if(Ut(e),aR)return e.toHex();let t="";for(let r=0;r<e.length;r++)t+=Q5[e[r]];return t}var ro={_0:48,_9:57,A:65,F:70,a:97,f:102};function sR(e){if(e>=ro._0&&e<=ro._9)return e-ro._0;if(e>=ro.A&&e<=ro.F)return e-(ro.A-10);if(e>=ro.a&&e<=ro.f)return e-(ro.a-10);return}function $l(e){if(typeof e!=="string")throw TypeError("hex string expected, got "+typeof e);if(aR)try{return Uint8Array.fromHex(e)}catch(n){if(n instanceof SyntaxError)throw RangeError(n.message);throw n}let t=e.length,r=t/2;if(t%2)throw RangeError("hex string expected, got unpadded hex of length "+t);let o=new Uint8Array(r);for(let n=0,i=0;n<r;n++,i+=2){let s=sR(e.charCodeAt(i)),a=sR(e.charCodeAt(i+1));if(s===void 0||a===void 0){let c=e[i]+e[i+1];throw RangeError('hex string expected, got non-hex character "'+c+'" at index '+i)}o[n]=s*16+a}return o}function Y5(e){if(typeof e!=="string")throw TypeError("string expected");return new Uint8Array(new TextEncoder().encode(e))}function Gy(e,t=""){if(typeof e==="string")return Y5(e);return Ut(e,void 0,t)}function Qy(...e){let t=0;for(let o=0;o<e.length;o++){let n=e[o];Ut(n),t+=n.length}let r=new Uint8Array(t);for(let o=0,n=0;o<e.length;o++){let i=e[o];r.set(i,n),n+=i.length}return r}function Zf(e,t){if(t!==void 0&&{}.toString.call(t)!=="[object Object]")throw TypeError("options must be object or undefined");return Object.assign(e,t)}function Yy(e,t={}){let r=(n,i)=>e(i).update(n).digest(),o=e(void 0);return r.outputLen=o.outputLen,r.blockLen=o.blockLen,r.canXOF=o.canXOF,r.create=(n)=>e(n),Object.assign(r,t),Object.freeze(r)}function oo(e=32){St(e,"bytesLength");let t=typeof globalThis==="object"?globalThis.crypto:null;if(typeof t?.getRandomValues!=="function")throw Error("crypto.getRandomValues must be defined");if(e>65536)throw RangeError(`"bytesLength" expected <= 65536, got ${e}`);return t.getRandomValues(new Uint8Array(e))}var Xy=(e)=>({oid:Uint8Array.from([6,9,96,134,72,1,101,3,4,2,e])});class eb{oHash;iHash;blockLen;outputLen;canXOF=!1;finished=!1;destroyed=!1;constructor(e,t){if(no(e),Ut(t,void 0,"key"),this.iHash=e.create(),typeof this.iHash.update!=="function")throw Error("Expected instance of class which extends utils.Hash");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;let r=this.blockLen,o=new Uint8Array(r);o.set(t.length>r?e.create().update(t).digest():t);for(let n=0;n<o.length;n++)o[n]^=54;this.iHash.update(o),this.oHash=e.create();for(let n=0;n<o.length;n++)o[n]^=106;this.oHash.update(o),cr(o)}update(e){return pa(this),this.iHash.update(e),this}digestInto(e){pa(this),Lf(e,this),this.finished=!0;let t=e.subarray(0,this.outputLen);this.iHash.digestInto(t),this.oHash.update(t),this.oHash.digestInto(t),this.destroy()}digest(){let e=new Uint8Array(this.oHash.outputLen);return this.digestInto(e),e}_cloneInto(e){e||=Object.create(Object.getPrototypeOf(this),{});let{oHash:t,iHash:r,finished:o,destroyed:n,blockLen:i,outputLen:s}=this;return e=e,e.finished=o,e.destroyed=n,e.blockLen=i,e.outputLen=s,e.oHash=t._cloneInto(e.oHash),e.iHash=r._cloneInto(e.iHash),e}clone(){return this._cloneInto()}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}}var Tn=(()=>{let e=(t,r,o)=>new eb(t,r).update(o).digest();return e.create=(t,r)=>new eb(t,r),e})();function Rl(e,t,r){if(no(e),r===void 0)r=new Uint8Array(e.outputLen);return Tn(e,r,t)}var tb=Uint8Array.of(0),cR=Uint8Array.of();function rb(e,t,r,o=32){no(e),St(o,"length"),Ut(t,void 0,"prk");let n=e.outputLen;if(t.length<n)throw Error('"prk" must be at least HashLen octets');if(o>255*n)throw Error("Length must be <= 255*HashLen");let i=Math.ceil(o/n);if(r===void 0)r=cR;else Ut(r,void 0,"info");let s=new Uint8Array(i*n),a=Tn.create(e,t),c=a._cloneInto(),u=new Uint8Array(a.outputLen);for(let d=0;d<i;d++)tb[0]=d+1,c.update(d===0?cR:u).update(r).update(tb).digestInto(u),s.set(u,n*d),a._cloneInto(c);return a.destroy(),c.destroy(),cr(u,tb),s.slice(0,o)}var Mo=(e,t,r,o,n)=>rb(e,Rl(e,t,r),o,n);function lR(e,t,r){return e&t^~e&r}function uR(e,t,r){return e&t^e&r^t&r}class Uf{blockLen;outputLen;canXOF=!1;padOffset;isLE;buffer;view;finished=!1;length=0;pos=0;destroyed=!1;constructor(e,t,r,o){this.blockLen=e,this.outputLen=t,this.padOffset=r,this.isLE=o,this.buffer=new Uint8Array(e),this.view=ma(this.buffer)}update(e){pa(this),Ut(e);let{view:t,buffer:r,blockLen:o}=this,n=e.length;for(let i=0;i<n;){let s=Math.min(o-this.pos,n-i);if(s===o){let a=ma(e);for(;o<=n-i;i+=o)this.process(a,i);continue}if(r.set(e.subarray(i,i+s),this.pos),this.pos+=s,i+=s,this.pos===o)this.process(t,0),this.pos=0}return this.length+=e.length,this.roundClean(),this}digestInto(e){pa(this),Lf(e,this),this.finished=!0;let{buffer:t,view:r,blockLen:o,isLE:n}=this,{pos:i}=this;if(t[i++]=128,cr(this.buffer.subarray(i)),this.padOffset>o-i)this.process(r,0),i=0;for(let d=i;d<o;d++)t[d]=0;r.setBigUint64(o-8,BigInt(this.length*8),n),this.process(r,0);let s=ma(e),a=this.outputLen;if(a%4)throw Error("_sha2: outputLen must be aligned to 32bit");let c=a/4,u=this.get();if(c>u.length)throw Error("_sha2: outputLen bigger than state");for(let d=0;d<c;d++)s.setUint32(4*d,u[d],n)}digest(){let{buffer:e,outputLen:t}=this;this.digestInto(e);let r=e.slice(0,t);return this.destroy(),r}_cloneInto(e){e||=new this.constructor,e.set(...this.get());let{blockLen:t,buffer:r,length:o,finished:n,destroyed:i,pos:s}=this;if(e.destroyed=i,e.finished=n,e.length=o,e.pos=s,o%t)e.buffer.set(r);return e}clone(){return this._cloneInto()}}var io=Uint32Array.from([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]);var qt=Uint32Array.from([1779033703,4089235720,3144134277,2227873595,1013904242,4271175723,2773480762,1595750129,1359893119,2917565137,2600822924,725511199,528734635,4215389547,1541459225,327033209]);var qf=BigInt(4294967295),dR=BigInt(32);function X5(e,t=!1){if(t)return{h:Number(e&qf),l:Number(e>>dR&qf)};return{h:Number(e>>dR&qf)|0,l:Number(e&qf)|0}}function fR(e,t=!1){let r=e.length,o=new Uint32Array(r),n=new Uint32Array(r);for(let i=0;i<r;i++){let{h:s,l:a}=X5(e[i],t);[o[i],n[i]]=[s,a]}return[o,n]}var nb=(e,t,r)=>e>>>r,ob=(e,t,r)=>e<<32-r|t>>>r,rs=(e,t,r)=>e>>>r|t<<32-r,ns=(e,t,r)=>e<<32-r|t>>>r,Ol=(e,t,r)=>e<<64-r|t>>>r-32,Cl=(e,t,r)=>e>>>r-32|t<<64-r;function $n(e,t,r,o){let n=(t>>>0)+(o>>>0);return{h:e+r+(n/4294967296|0)|0,l:n|0}}var pR=(e,t,r)=>(e>>>0)+(t>>>0)+(r>>>0),mR=(e,t,r,o)=>t+r+o+(e/4294967296|0)|0,hR=(e,t,r,o)=>(e>>>0)+(t>>>0)+(r>>>0)+(o>>>0),gR=(e,t,r,o,n)=>t+r+o+n+(e/4294967296|0)|0,yR=(e,t,r,o,n)=>(e>>>0)+(t>>>0)+(r>>>0)+(o>>>0)+(n>>>0),bR=(e,t,r,o,n,i)=>t+r+o+n+i+(e/4294967296|0)|0;var t8=Uint32Array.from([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),Fo=new Uint32Array(64);class SR extends Uf{constructor(e){super(64,e,8,!1)}get(){let{A:e,B:t,C:r,D:o,E:n,F:i,G:s,H:a}=this;return[e,t,r,o,n,i,s,a]}set(e,t,r,o,n,i,s,a){this.A=e|0,this.B=t|0,this.C=r|0,this.D=o|0,this.E=n|0,this.F=i|0,this.G=s|0,this.H=a|0}process(e,t){for(let d=0;d<16;d++,t+=4)Fo[d]=e.getUint32(t,!1);for(let d=16;d<64;d++){let f=Fo[d-15],m=Fo[d-2],h=rn(f,7)^rn(f,18)^f>>>3,b=rn(m,17)^rn(m,19)^m>>>10;Fo[d]=b+Fo[d-7]+h+Fo[d-16]|0}let{A:r,B:o,C:n,D:i,E:s,F:a,G:c,H:u}=this;for(let d=0;d<64;d++){let f=rn(s,6)^rn(s,11)^rn(s,25),m=u+f+lR(s,a,c)+t8[d]+Fo[d]|0,b=(rn(r,2)^rn(r,13)^rn(r,22))+uR(r,o,n)|0;u=c,c=a,a=s,s=i+m|0,i=n,n=o,o=r,r=m+b|0}r=r+this.A|0,o=o+this.B|0,n=n+this.C|0,i=i+this.D|0,s=s+this.E|0,a=a+this.F|0,c=c+this.G|0,u=u+this.H|0,this.set(r,o,n,i,s,a,c,u)}roundClean(){cr(Fo)}destroy(){this.destroyed=!0,this.set(0,0,0,0,0,0,0,0),cr(this.buffer)}}class vR extends SR{A=io[0]|0;B=io[1]|0;C=io[2]|0;D=io[3]|0;E=io[4]|0;F=io[5]|0;G=io[6]|0;H=io[7]|0;constructor(){super(32)}}var wR=(()=>fR(["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))))(),r8=(()=>wR[0])(),n8=(()=>wR[1])(),Jo=new Uint32Array(80),Ko=new Uint32Array(80);class xR extends Uf{constructor(e){super(128,e,16,!1)}get(){let{Ah:e,Al:t,Bh:r,Bl:o,Ch:n,Cl:i,Dh:s,Dl:a,Eh:c,El:u,Fh:d,Fl:f,Gh:m,Gl:h,Hh:b,Hl:y}=this;return[e,t,r,o,n,i,s,a,c,u,d,f,m,h,b,y]}set(e,t,r,o,n,i,s,a,c,u,d,f,m,h,b,y){this.Ah=e|0,this.Al=t|0,this.Bh=r|0,this.Bl=o|0,this.Ch=n|0,this.Cl=i|0,this.Dh=s|0,this.Dl=a|0,this.Eh=c|0,this.El=u|0,this.Fh=d|0,this.Fl=f|0,this.Gh=m|0,this.Gl=h|0,this.Hh=b|0,this.Hl=y|0}process(e,t){for(let _=0;_<16;_++,t+=4)Jo[_]=e.getUint32(t),Ko[_]=e.getUint32(t+=4);for(let _=16;_<80;_++){let A=Jo[_-15]|0,O=Ko[_-15]|0,L=rs(A,O,1)^rs(A,O,8)^nb(A,O,7),z=ns(A,O,1)^ns(A,O,8)^ob(A,O,7),K=Jo[_-2]|0,P=Ko[_-2]|0,W=rs(K,P,19)^Ol(K,P,61)^nb(K,P,6),ee=ns(K,P,19)^Cl(K,P,61)^ob(K,P,6),B=hR(z,ee,Ko[_-7],Ko[_-16]),R=gR(B,L,W,Jo[_-7],Jo[_-16]);Jo[_]=R|0,Ko[_]=B|0}let{Ah:r,Al:o,Bh:n,Bl:i,Ch:s,Cl:a,Dh:c,Dl:u,Eh:d,El:f,Fh:m,Fl:h,Gh:b,Gl:y,Hh:S,Hl:x}=this;for(let _=0;_<80;_++){let A=rs(d,f,14)^rs(d,f,18)^Ol(d,f,41),O=ns(d,f,14)^ns(d,f,18)^Cl(d,f,41),L=d&m^~d&b,z=f&h^~f&y,K=yR(x,O,z,n8[_],Ko[_]),P=bR(K,S,A,L,r8[_],Jo[_]),W=K|0,ee=rs(r,o,28)^Ol(r,o,34)^Ol(r,o,39),B=ns(r,o,28)^Cl(r,o,34)^Cl(r,o,39),R=r&n^r&s^n&s,j=o&i^o&a^i&a;S=b|0,x=y|0,b=m|0,y=h|0,m=d|0,h=f|0,{h:d,l:f}=$n(c|0,u|0,P|0,W|0),c=s|0,u=a|0,s=n|0,a=i|0,n=r|0,i=o|0;let I=pR(W,B,j);r=mR(I,P,ee,R),o=I|0}({h:r,l:o}=$n(this.Ah|0,this.Al|0,r|0,o|0)),{h:n,l:i}=$n(this.Bh|0,this.Bl|0,n|0,i|0),{h:s,l:a}=$n(this.Ch|0,this.Cl|0,s|0,a|0),{h:c,l:u}=$n(this.Dh|0,this.Dl|0,c|0,u|0),{h:d,l:f}=$n(this.Eh|0,this.El|0,d|0,f|0),{h:m,l:h}=$n(this.Fh|0,this.Fl|0,m|0,h|0),{h:b,l:y}=$n(this.Gh|0,this.Gl|0,b|0,y|0),{h:S,l:x}=$n(this.Hh|0,this.Hl|0,S|0,x|0),this.set(r,o,n,i,s,a,c,u,d,f,m,h,b,y,S,x)}roundClean(){cr(Jo,Ko)}destroy(){this.destroyed=!0,cr(this.buffer),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}}class _R extends xR{Ah=qt[0]|0;Al=qt[1]|0;Bh=qt[2]|0;Bl=qt[3]|0;Ch=qt[4]|0;Cl=qt[5]|0;Dh=qt[6]|0;Dl=qt[7]|0;Eh=qt[8]|0;El=qt[9]|0;Fh=qt[10]|0;Fl=qt[11]|0;Gh=qt[12]|0;Gl=qt[13]|0;Hh=qt[14]|0;Hl=qt[15]|0;constructor(){super(64)}}var vt=Yy(()=>new vR,Xy(1));var Mf=Yy(()=>new _R,Xy(3));/*! scure-base - MIT License (c) 2022 Paul Miller (paulmillr.com) */function Vf(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name==="Uint8Array"&&"BYTES_PER_ELEMENT"in e&&e.BYTES_PER_ELEMENT===1}function ab(e){if(!Vf(e))throw TypeError("Uint8Array expected")}function TR(e,t){if(!Array.isArray(t))return!1;if(t.length===0)return!0;if(e)return t.every((r)=>typeof r==="string");else return t.every((r)=>Number.isSafeInteger(r))}function $R(e){if(typeof e!=="function")throw TypeError("function expected");return!0}function Ho(e,t){if(typeof t!=="string")throw TypeError(`${e}: string expected`);return!0}function zl(e){if(typeof e!=="number")throw TypeError(`number expected, got ${typeof e}`);if(!Number.isSafeInteger(e))throw RangeError(`invalid integer: ${e}`)}function Jf(e){if(!Array.isArray(e))throw TypeError("array expected")}function Kf(e,t){if(!TR(!0,t))throw TypeError(`${e}: array of strings expected`)}function cb(e,t){if(!TR(!1,t))throw TypeError(`${e}: array of numbers expected`)}function Rr(...e){let t=(i)=>i,r=(i,s)=>(a)=>i(s(a)),o=e.map((i)=>i.encode).reduceRight(r,t),n=e.map((i)=>i.decode).reduce(r,t);return{encode:o,decode:n}}function Or(e){let t=typeof e==="string"?e.split(""):e,r=t.length;Kf("alphabet",t);let o=new Map(t.map((n,i)=>[n,i]));return{encode:(n)=>(Jf(n),n.map((i)=>{if(!Number.isSafeInteger(i)||i<0||i>=r)throw Error(`alphabet.encode: digit index outside alphabet "${i}". Allowed: ${e}`);return t[i]})),decode:(n)=>(Jf(n),n.map((i)=>{Ho("alphabet.decode",i);let s=o.get(i);if(s===void 0)throw Error(`Unknown letter: "${i}". Allowed: ${e}`);return s}))}}function Cr(e=""){return Ho("join",e),{encode:(t)=>(Kf("join.decode",t),t.join(e)),decode:(t)=>(Ho("join.decode",t),t.split(e))}}function Wf(e,t="="){return zl(e),Ho("padding",t),{encode(r){Kf("padding.encode",r);while(r.length*e%8)r.push(t);return r},decode(r){Kf("padding.decode",r);let o=r.length;if(o*e%8)throw Error("padding: invalid, string should have whole number of bytes");for(;o>0&&r[o-1]===t;o--)if((o-1)*e%8===0)throw Error("padding: invalid, string has too much padding");return r.slice(0,o)}}}function RR(e){return $R(e),{encode:(t)=>t,decode:(t)=>e(t)}}function ER(e,t,r){if(t<2)throw RangeError(`convertRadix: invalid from=${t}, base cannot be less than 2`);if(r<2)throw RangeError(`convertRadix: invalid to=${r}, base cannot be less than 2`);if(Jf(e),!e.length)return[];let o=0,n=[],i=Array.from(e,(a)=>{if(zl(a),a<0||a>=t)throw Error(`invalid integer: ${a}`);return a}),s=i.length;while(!0){let a=0,c=!0;for(let u=o;u<s;u++){let d=i[u],f=t*a,m=f+d;if(!Number.isSafeInteger(m)||f/t!==a||m-d!==f)throw Error("convertRadix: carry overflow");let h=m/r;a=m%r;let b=Math.floor(h);if(i[u]=b,!Number.isSafeInteger(b)||b*r+a!==m)throw Error("convertRadix: carry overflow");if(!c)continue;else if(!b)o=u;else c=!1}if(n.push(a),c)break}for(let a=0;a<e.length-1&&e[a]===0;a++)n.push(0);return n.reverse()}var OR=(e,t)=>t===0?e:OR(t,e%t),Hf=(e,t)=>e+(t-OR(e,t)),Ff=(()=>{let e=[];for(let t=0;t<40;t++)e.push(2**t);return e})();function ib(e,t,r,o){if(Jf(e),t<=0||t>32)throw RangeError(`convertRadix2: wrong from=${t}`);if(r<=0||r>32)throw RangeError(`convertRadix2: wrong to=${r}`);if(Hf(t,r)>32)throw Error(`convertRadix2: carry overflow from=${t} to=${r} carryBits=${Hf(t,r)}`);let n=0,i=0,s=Ff[t],a=Ff[r]-1,c=[];for(let u of e){if(zl(u),u>=s)throw Error(`convertRadix2: invalid data word=${u} from=${t}`);if(n=n<<t|u,i+t>32)throw Error(`convertRadix2: carry overflow pos=${i} from=${t}`);i+=t;for(;i>=r;i-=r)c.push((n>>i-r&a)>>>0);let d=Ff[i];if(d===void 0)throw Error("invalid carry");n&=d-1}if(n=n<<r-i&a,!o&&i>=t)throw Error("Excess padding");if(!o&&n>0)throw Error(`Non-zero padding: ${n}`);if(o&&i>0)c.push(n>>>0);return c}function o8(e){zl(e);let t=256;return{encode:(r)=>{if(!Vf(r))throw TypeError("radix.encode input should be Uint8Array");return ER(Array.from(r),t,e)},decode:(r)=>(cb("radix.decode",r),Uint8Array.from(ER(r,e,t)))}}function Ur(e,t=!1){if(zl(e),e<=0||e>32)throw RangeError("radix2: bits should be in (0..32]");if(Hf(8,e)>32||Hf(e,8)>32)throw RangeError("radix2: carry overflow");return{encode:(r)=>{if(!Vf(r))throw TypeError("radix2.encode input should be Uint8Array");return ib(Array.from(r),8,e,!t)},decode:(r)=>(cb("radix2.decode",r),Uint8Array.from(ib(r,e,8,t)))}}function IR(e){return $R(e),function(...t){try{return e.apply(null,t)}catch(r){}}}var kme=Object.freeze(Rr(Ur(4),Or("0123456789ABCDEF"),Cr(""))),Ame=Object.freeze(Rr(Ur(5),Or("ABCDEFGHIJKLMNOPQRSTUVWXYZ234567"),Wf(5),Cr(""))),Tme=Object.freeze(Rr(Ur(5),Or("ABCDEFGHIJKLMNOPQRSTUVWXYZ234567"),Cr(""))),$me=Object.freeze(Rr(Ur(5),Or("0123456789ABCDEFGHIJKLMNOPQRSTUV"),Wf(5),Cr(""))),Rme=Object.freeze(Rr(Ur(5),Or("0123456789ABCDEFGHIJKLMNOPQRSTUV"),Cr(""))),Ome=Object.freeze(Rr(Ur(5),Or("0123456789ABCDEFGHJKMNPQRSTVWXYZ"),Cr(""),RR((e)=>e.toUpperCase().replace(/O/g,"0").replace(/[IL]/g,"1")))),CR=(()=>typeof Uint8Array.from([]).toBase64==="function"&&typeof Uint8Array.fromBase64==="function")(),i8=/[\t\n\f\r ]/,PR=(e,t)=>{Ho("base64",e);let r=t?"base64url":"base64";if(e.length>0&&i8.test(e))throw Error("invalid base64");return Uint8Array.fromBase64(e,{alphabet:r,lastChunkHandling:"strict"})},lb=Object.freeze(CR?{encode(e){return ab(e),e.toBase64()},decode(e){return PR(e,!1)}}:Rr(Ur(6),Or("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"),Wf(6),Cr(""))),Yt=Object.freeze(Rr(Ur(6),Or("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"),Cr(""))),Cme=Object.freeze(CR?{encode(e){return ab(e),e.toBase64({alphabet:"base64url"})},decode(e){return PR(e,!0)}}:Rr(Ur(6),Or("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_"),Wf(6),Cr(""))),Pme=Object.freeze(Rr(Ur(6),Or("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_"),Cr(""))),ub=(e)=>Rr(o8(58),Or(e),Cr("")),zme=Object.freeze(ub("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz")),Nme=Object.freeze(ub("123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ")),Dme=Object.freeze(ub("rpshnaf39wBUDNEGHJKLM4PQRST7VWXYZ2bcdeCg65jkm8oFqi1tuvAxyz"));var sb=Rr(Or("qpzry9x8gf2tvdw0s3jn54khce6mua7l"),Cr("")),kR=[996825010,642813549,513874426,1027748829,705979059];function Pl(e){let t=e>>25,r=(e&33554431)<<5;for(let o=0;o<kR.length;o++)if((t>>o&1)===1)r^=kR[o];return r}function AR(e,t,r=1){let o=e.length,n=1;for(let i=0;i<o;i++){let s=e.charCodeAt(i);if(s<33||s>126)throw Error(`Invalid prefix (${e})`);n=Pl(n)^s>>5}n=Pl(n);for(let i=0;i<o;i++)n=Pl(n)^e.charCodeAt(i)&31;for(let i of t)n=Pl(n)^i;for(let i=0;i<6;i++)n=Pl(n);return n^=r,sb.encode(ib([n%Ff[30]],30,5,!1))}function zR(e){let t=e==="bech32"?1:734539939,r=Ur(5),o=r.decode,n=r.encode,i=IR(o);function s(f,m,h=90){if(Ho("bech32.encode prefix",f),Vf(m))m=Array.from(m);cb("bech32.encode",m);let b=f.length;if(b===0)throw TypeError(`Invalid prefix length ${b}`);let y=b+7+m.length;if(h!==!1&&y>h)throw TypeError(`Length ${y} exceeds limit ${h}`);let S=f.toLowerCase(),x=AR(S,m,t);return`${S}1${sb.encode(m)}${x}`}function a(f,m=90){Ho("bech32.decode input",f);let h=f.length;if(h<8||m!==!1&&h>m)throw TypeError(`invalid string length: ${h} (${f}). Expected (8..${m})`);let b=f.toLowerCase();if(f!==b&&f!==f.toUpperCase())throw Error("String must be lowercase or uppercase");let y=b.lastIndexOf("1");if(y===0||y===-1)throw Error('Letter "1" must be present between prefix and data only');let S=b.slice(0,y),x=b.slice(y+1);if(x.length<6)throw Error("Data must be at least 6 characters long");let _=sb.decode(x).slice(0,-6),A=AR(S,_,t);if(!x.endsWith(A))throw Error(`Invalid checksum in ${f}: expected "${A}"`);return{prefix:S,words:_}}let c=IR(a);function u(f){let{prefix:m,words:h}=a(f,!1);return{prefix:m,words:h,bytes:o(h)}}function d(f,m){return s(f,n(m))}return{encode:s,decode:a,encodeFromBytes:d,decodeToBytes:u,decodeUnsafe:c,fromWords:o,fromWordsUnsafe:i,toWords:n}}var Pr=Object.freeze(zR("bech32")),Lme=Object.freeze(zR("bech32m"));var s8=(()=>typeof Uint8Array.from([]).toHex==="function"&&typeof Uint8Array.fromHex==="function")(),a8={encode(e){return ab(e),e.toHex()},decode(e){return Ho("hex",e),Uint8Array.fromHex(e)}},jme=Object.freeze(s8?a8:Rr(Ur(4),Or("0123456789abcdef"),Cr(""),RR((e)=>{if(typeof e!=="string"||e.length%2!==0)throw TypeError(`hex.decode: expected string, got ${typeof e} with length ${e.length}`);return e.toLowerCase()})));function l8(e,t,r,o){no(e);let n=Zf({dkLen:32,asyncTick:10},o),{c:i,dkLen:s,asyncTick:a}=n;if(St(i,"c"),St(s,"dkLen"),St(a,"asyncTick"),i<1)throw Error("iterations (c) must be >= 1");if(s<1)throw Error('"dkLen" must be >= 1');if(s>4294967295*e.outputLen)throw Error("derived key too long");let c=Gy(t,"password"),u=Gy(r,"salt"),d=new Uint8Array(s),f=Tn.create(e,c),m=f._cloneInto().update(u);return{c:i,dkLen:s,asyncTick:a,DK:d,PRF:f,PRFSalt:m}}function u8(e,t,r,o,n){if(e.destroy(),t.destroy(),o)o.destroy();return cr(n),r}function db(e,t,r,o){let{c:n,dkLen:i,DK:s,PRF:a,PRFSalt:c}=l8(e,t,r,o),u,d=new Uint8Array(4),f=ma(d),m=new Uint8Array(a.outputLen);for(let h=1,b=0;b<i;h++,b+=a.outputLen){let y=s.subarray(b,b+a.outputLen);f.setInt32(0,h,!1),(u=c._cloneInto(u)).update(d).digestInto(m),y.set(m.subarray(0,y.length));for(let S=1;S<n;S++){a._cloneInto(u).update(m).digestInto(m);for(let x=0;x<y.length;x++)y[x]^=m[x]}}return u8(a,c,s,u,m)}function NR(e,t,r,o,n,i){let s=e[t++]^r[o++],a=e[t++]^r[o++],c=e[t++]^r[o++],u=e[t++]^r[o++],d=e[t++]^r[o++],f=e[t++]^r[o++],m=e[t++]^r[o++],h=e[t++]^r[o++],b=e[t++]^r[o++],y=e[t++]^r[o++],S=e[t++]^r[o++],x=e[t++]^r[o++],_=e[t++]^r[o++],A=e[t++]^r[o++],O=e[t++]^r[o++],L=e[t++]^r[o++],z=s,K=a,P=c,W=u,ee=d,B=f,R=m,j=h,I=b,T=y,k=S,M=x,N=_,H=A,G=O,re=L;for(let ae=0;ae<8;ae+=2)ee^=Fe(z+N|0,7),I^=Fe(ee+z|0,9),N^=Fe(I+ee|0,13),z^=Fe(N+I|0,18),T^=Fe(B+K|0,7),H^=Fe(T+B|0,9),K^=Fe(H+T|0,13),B^=Fe(K+H|0,18),G^=Fe(k+R|0,7),P^=Fe(G+k|0,9),R^=Fe(P+G|0,13),k^=Fe(R+P|0,18),W^=Fe(re+M|0,7),j^=Fe(W+re|0,9),M^=Fe(j+W|0,13),re^=Fe(M+j|0,18),K^=Fe(z+W|0,7),P^=Fe(K+z|0,9),W^=Fe(P+K|0,13),z^=Fe(W+P|0,18),R^=Fe(B+ee|0,7),j^=Fe(R+B|0,9),ee^=Fe(j+R|0,13),B^=Fe(ee+j|0,18),M^=Fe(k+T|0,7),I^=Fe(M+k|0,9),T^=Fe(I+M|0,13),k^=Fe(T+I|0,18),N^=Fe(re+G|0,7),H^=Fe(N+re|0,9),G^=Fe(H+N|0,13),re^=Fe(G+H|0,18);n[i++]=s+z|0,n[i++]=a+K|0,n[i++]=c+P|0,n[i++]=u+W|0,n[i++]=d+ee|0,n[i++]=f+B|0,n[i++]=m+R|0,n[i++]=h+j|0,n[i++]=b+I|0,n[i++]=y+T|0,n[i++]=S+k|0,n[i++]=x+M|0,n[i++]=_+N|0,n[i++]=A+H|0,n[i++]=O+G|0,n[i++]=L+re|0}function fb(e,t,r,o,n){let i=o+0,s=o+16*n;for(let a=0;a<16;a++)r[s+a]=e[t+(2*n-1)*16+a];for(let a=0;a<n;a++,i+=16,t+=16){if(NR(r,s,e,t,r,i),a>0)s+=16;NR(r,i,e,t+=16,r,s)}}function d8(e,t,r){let o=Zf({dkLen:32,asyncTick:10,maxmem:1073742848},r),{N:n,r:i,p:s,dkLen:a,asyncTick:c,maxmem:u,onProgress:d}=o;if(St(n,"N"),St(i,"r"),St(s,"p"),St(a,"dkLen"),St(c,"asyncTick"),St(u,"maxmem"),d!==void 0&&typeof d!=="function")throw Error("progressCb must be a function");let f=128*i,m=f/4,h=Math.pow(2,32);if(n<=1||(n&n-1)!==0||n>h)throw Error('"N" expected a power of 2, and 2^1 <= N <= 2^32');if(s<1||s>(h-1)*32/f)throw Error('"p" expected integer 1..((2^32 - 1) * 32) / (128 * r)');if(a<1||a>(h-1)*32)throw Error('"dkLen" expected integer 1..(2^32 - 1) * 32');let b=f*(n+s+1);if(b>u)throw Error('"maxmem" limit was hit: memUsed(128*r*(N+p+1))='+b+", maxmem="+u);let y=db(vt,e,t,{c:1,dkLen:f*s}),S=jf(y),x=jf(new Uint8Array(f*n)),_=jf(new Uint8Array(f)),A=()=>{};if(d){let O=2*n*s,L=Math.max(Math.floor(O/1e4),1),z=0;A=()=>{if(z++,d&&(!(z%L)||z===O))d(z/O)}}return{N:n,r:i,p:s,dkLen:a,blockSize32:m,V:x,B32:S,B:y,tmp:_,blockMixCb:A,asyncTick:c}}function f8(e,t,r,o,n){let i=db(vt,e,r,{c:1,dkLen:t});return cr(r,o,n),i}function pb(e,t,r){let{N:o,r:n,p:i,dkLen:s,blockSize32:a,V:c,B32:u,B:d,tmp:f,blockMixCb:m}=d8(e,t,r);Wy(u);for(let h=0;h<i;h++){let b=a*h;for(let y=0;y<a;y++)c[y]=u[b+y];for(let y=0,S=0;y<o-1;y++)fb(c,S,c,S+=a,n),m();fb(c,(o-1)*a,u,b,n),m();for(let y=0;y<o;y++){let S=(u[b+a-16]&o-1)>>>0;for(let x=0;x<a;x++)f[x]=u[b+x]^c[S*a+x];fb(f,0,u,b,n),m()}}return Wy(u),f8(e,s,d,c,f)}/*! noble-ciphers - MIT License (c) 2023 Paul Miller (paulmillr.com) */function p8(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name==="Uint8Array"&&"BYTES_PER_ELEMENT"in e&&e.BYTES_PER_ELEMENT===1}function Gf(e){if(typeof e!=="boolean")throw TypeError(`boolean expected, not ${e}`)}function ha(e){if(typeof e!=="number")throw TypeError("number expected, got "+typeof e);if(!Number.isSafeInteger(e)||e<0)throw RangeError("positive integer expected, got "+e)}function $t(e,t,r=""){let o=p8(e),n=e?.length,i=t!==void 0;if(!o||i&&n!==t){let s=r&&`"${r}" `,a=i?` of length ${t}`:"",c=o?`length=${n}`:`type=${typeof e}`,u=s+"expected Uint8Array"+a+", got "+c;if(!o)throw TypeError(u);throw RangeError(u)}return e}function mb(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 DR(e,t,r=!1){$t(e,void 0,"output");let o=t.outputLen;if(e.length<o)throw RangeError("digestInto() expects output buffer of length at least "+o);if(r&&!ga(e))throw Error("invalid output, must be aligned")}function Rn(e){return new Uint32Array(e.buffer,e.byteOffset,Math.floor(e.byteLength/4))}function nn(...e){for(let t=0;t<e.length;t++)e[t].fill(0)}function m8(e){return new DataView(e.buffer,e.byteOffset,e.byteLength)}var os=(()=>new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68)(),h8=(e)=>e<<24&4278190080|e<<8&16711680|e>>>8&65280|e>>>24&255;var g8=(e)=>{for(let t=0;t<e.length;t++)e[t]=h8(e[t]);return e},so=os?(e)=>e:g8;function LR(e,t){if(t==null||typeof t!=="object")throw Error("options must be defined");return Object.assign(e,t)}function jR(e,t){if(e.length!==t.length)return!1;let r=0;for(let o=0;o<e.length;o++)r|=e[o]^t[o];return r===0}function BR(e,t,r){let o=t,n=r||(()=>[]),i=(a,c)=>o(c,...n(a)).update(a).digest(),s=o(new Uint8Array(e),...n(new Uint8Array(0)));return i.outputLen=s.outputLen,i.blockLen=s.blockLen,i.create=(a,...c)=>o(a,...c),i}var ZR=(e,t)=>{function r(o,...n){if($t(o,void 0,"key"),e.nonceLength!==void 0){let d=n[0];$t(d,e.varSizeNonce?void 0:e.nonceLength,"nonce")}let i=e.tagLength;if(i&&n[1]!==void 0)$t(n[1],void 0,"AAD");let s=t(o,...n),a=(d,f)=>{if(f!==void 0){if(d!==2)throw Error("cipher output not supported");$t(f,void 0,"output")}},c=!1;return{encrypt(d,f){if(c)throw Error("cannot encrypt() twice with same key + nonce");return c=!0,$t(d),a(s.encrypt.length,f),s.encrypt(d,f)},decrypt(d,f){if($t(d),i&&d.length<i)throw Error('"ciphertext" expected length bigger than tagLength='+i);return a(s.decrypt.length,f),s.decrypt(d,f)}}}return Object.assign(r,e),r};function Nl(e,t,r=!0){if(t===void 0)return new Uint8Array(e);if($t(t,void 0,"output"),t.length!==e)throw Error('"output" expected Uint8Array of length '+e+", got: "+t.length);if(r&&!ga(t))throw Error("invalid output, must be aligned");return t}function UR(e,t,r){ha(e),ha(t),Gf(r);let o=new Uint8Array(16),n=m8(o);return n.setBigUint64(0,BigInt(t),r),n.setBigUint64(8,BigInt(e),r),o}function ga(e){return e.byteOffset%4===0}function ya(e){return Uint8Array.from($t(e))}var MR=(e)=>Uint8Array.from(e.split(""),(t)=>t.charCodeAt(0)),y8=(()=>so(Rn(MR("expand 16-byte k"))))(),b8=(()=>so(Rn(MR("expand 32-byte k"))))();function Je(e,t){return e<<t|e>>>32-t}var Dl=64,S8=16,hb=(()=>4294967295)(),qR=Uint32Array.of();function v8(e,t,r,o,n,i,s,a){let c=n.length,u=new Uint8Array(Dl),d=Rn(u),f=os&&ga(n)&&ga(i),m=f?Rn(n):qR,h=f?Rn(i):qR;if(!os){for(let b=0;b<c;s++){if(e(t,r,o,d,s,a),so(d),s>=hb)throw Error("arx: counter overflow");let y=Math.min(Dl,c-b);for(let S=0,x;S<y;S++)x=b+S,i[x]=n[x]^u[S];b+=y}return}for(let b=0;b<c;s++){if(e(t,r,o,d,s,a),s>=hb)throw Error("arx: counter overflow");let y=Math.min(Dl,c-b);if(f&&y===Dl){let S=b/4;if(b%4!==0)throw Error("arx: invalid block position");for(let x=0,_;x<S8;x++)_=S+x,h[_]=m[_]^d[x];b+=Dl;continue}for(let S=0,x;S<y;S++)x=b+S,i[x]=n[x]^u[S];b+=y}}function FR(e,t){let{allowShortKeys:r,extendNonceFn:o,counterLength:n,counterRight:i,rounds:s}=LR({allowShortKeys:!1,counterLength:8,counterRight:!1,rounds:20},t);if(typeof e!=="function")throw Error("core must be a function");return ha(n),ha(s),Gf(i),Gf(r),(a,c,u,d,f=0)=>{$t(a,void 0,"key"),$t(c,void 0,"nonce"),$t(u,void 0,"data");let m=u.length;if(d=Nl(m,d,!1),ha(f),f<0||f>=hb)throw Error("arx: counter overflow");let h=[],b=a.length,y,S;if(b===32)h.push(y=ya(a)),S=b8;else if(b===16&&r)y=new Uint8Array(32),y.set(a),y.set(a,16),S=y8,h.push(y);else throw $t(a,32,"arx key"),Error("invalid key size");if(!os||!ga(c))h.push(c=ya(c));let x=Rn(y);if(o){if(c.length!==24)throw Error("arx: extended nonce must be 24 bytes");let O=c.subarray(0,16);if(os)o(S,x,Rn(O),x);else{let L=so(Uint32Array.from(S));o(L,x,Rn(O),x),nn(L),so(x)}c=c.subarray(16)}else if(!os)so(x);let _=16-n;if(_!==c.length)throw Error(`arx: nonce must be ${_} or 16 bytes`);if(_!==12){let O=new Uint8Array(12);O.set(c,i?0:12-c.length),c=O,h.push(c)}let A=so(Rn(c));try{return v8(e,S,x,A,u,d,f,s),d}finally{nn(...h)}}}function Mt(e,t){return e[t++]&255|(e[t++]&255)<<8}class JR{blockLen=16;outputLen=16;buffer=new Uint8Array(16);r=new Uint16Array(10);h=new Uint16Array(10);pad=new Uint16Array(8);pos=0;finished=!1;destroyed=!1;constructor(e){e=ya($t(e,32,"key"));let t=Mt(e,0),r=Mt(e,2),o=Mt(e,4),n=Mt(e,6),i=Mt(e,8),s=Mt(e,10),a=Mt(e,12),c=Mt(e,14);this.r[0]=t&8191,this.r[1]=(t>>>13|r<<3)&8191,this.r[2]=(r>>>10|o<<6)&7939,this.r[3]=(o>>>7|n<<9)&8191,this.r[4]=(n>>>4|i<<12)&255,this.r[5]=i>>>1&8190,this.r[6]=(i>>>14|s<<2)&8191,this.r[7]=(s>>>11|a<<5)&8065,this.r[8]=(a>>>8|c<<8)&8191,this.r[9]=c>>>5&127;for(let u=0;u<8;u++)this.pad[u]=Mt(e,16+2*u)}process(e,t,r=!1){let o=r?0:2048,{h:n,r:i}=this,s=i[0],a=i[1],c=i[2],u=i[3],d=i[4],f=i[5],m=i[6],h=i[7],b=i[8],y=i[9],S=Mt(e,t+0),x=Mt(e,t+2),_=Mt(e,t+4),A=Mt(e,t+6),O=Mt(e,t+8),L=Mt(e,t+10),z=Mt(e,t+12),K=Mt(e,t+14),P=n[0]+(S&8191),W=n[1]+((S>>>13|x<<3)&8191),ee=n[2]+((x>>>10|_<<6)&8191),B=n[3]+((_>>>7|A<<9)&8191),R=n[4]+((A>>>4|O<<12)&8191),j=n[5]+(O>>>1&8191),I=n[6]+((O>>>14|L<<2)&8191),T=n[7]+((L>>>11|z<<5)&8191),k=n[8]+((z>>>8|K<<8)&8191),M=n[9]+(K>>>5|o),N=0,H=N+P*s+W*(5*y)+ee*(5*b)+B*(5*h)+R*(5*m);N=H>>>13,H&=8191,H+=j*(5*f)+I*(5*d)+T*(5*u)+k*(5*c)+M*(5*a),N+=H>>>13,H&=8191;let G=N+P*a+W*s+ee*(5*y)+B*(5*b)+R*(5*h);N=G>>>13,G&=8191,G+=j*(5*m)+I*(5*f)+T*(5*d)+k*(5*u)+M*(5*c),N+=G>>>13,G&=8191;let re=N+P*c+W*a+ee*s+B*(5*y)+R*(5*b);N=re>>>13,re&=8191,re+=j*(5*h)+I*(5*m)+T*(5*f)+k*(5*d)+M*(5*u),N+=re>>>13,re&=8191;let ae=N+P*u+W*c+ee*a+B*s+R*(5*y);N=ae>>>13,ae&=8191,ae+=j*(5*b)+I*(5*h)+T*(5*m)+k*(5*f)+M*(5*d),N+=ae>>>13,ae&=8191;let pe=N+P*d+W*u+ee*c+B*a+R*s;N=pe>>>13,pe&=8191,pe+=j*(5*y)+I*(5*b)+T*(5*h)+k*(5*m)+M*(5*f),N+=pe>>>13,pe&=8191;let be=N+P*f+W*d+ee*u+B*c+R*a;N=be>>>13,be&=8191,be+=j*s+I*(5*y)+T*(5*b)+k*(5*h)+M*(5*m),N+=be>>>13,be&=8191;let ve=N+P*m+W*f+ee*d+B*u+R*c;N=ve>>>13,ve&=8191,ve+=j*a+I*s+T*(5*y)+k*(5*b)+M*(5*h),N+=ve>>>13,ve&=8191;let ke=N+P*h+W*m+ee*f+B*d+R*u;N=ke>>>13,ke&=8191,ke+=j*c+I*a+T*s+k*(5*y)+M*(5*b),N+=ke>>>13,ke&=8191;let Ie=N+P*b+W*h+ee*m+B*f+R*d;N=Ie>>>13,Ie&=8191,Ie+=j*u+I*c+T*a+k*s+M*(5*y),N+=Ie>>>13,Ie&=8191;let we=N+P*y+W*b+ee*h+B*m+R*f;N=we>>>13,we&=8191,we+=j*d+I*u+T*c+k*a+M*s,N+=we>>>13,we&=8191,N=(N<<2)+N|0,N=N+H|0,H=N&8191,N=N>>>13,G+=N,n[0]=H,n[1]=G,n[2]=re,n[3]=ae,n[4]=pe,n[5]=be,n[6]=ve,n[7]=ke,n[8]=Ie,n[9]=we}finalize(){let{h:e,pad:t}=this,r=new Uint16Array(10),o=e[1]>>>13;e[1]&=8191;for(let s=2;s<10;s++)e[s]+=o,o=e[s]>>>13,e[s]&=8191;e[0]+=o*5,o=e[0]>>>13,e[0]&=8191,e[1]+=o,o=e[1]>>>13,e[1]&=8191,e[2]+=o,r[0]=e[0]+5,o=r[0]>>>13,r[0]&=8191;for(let s=1;s<10;s++)r[s]=e[s]+o,o=r[s]>>>13,r[s]&=8191;r[9]-=8192;let n=(o^1)-1;for(let s=0;s<10;s++)r[s]&=n;n=~n;for(let s=0;s<10;s++)e[s]=e[s]&n|r[s];e[0]=(e[0]|e[1]<<13)&65535,e[1]=(e[1]>>>3|e[2]<<10)&65535,e[2]=(e[2]>>>6|e[3]<<7)&65535,e[3]=(e[3]>>>9|e[4]<<4)&65535,e[4]=(e[4]>>>12|e[5]<<1|e[6]<<14)&65535,e[5]=(e[6]>>>2|e[7]<<11)&65535,e[6]=(e[7]>>>5|e[8]<<8)&65535,e[7]=(e[8]>>>8|e[9]<<5)&65535;let i=e[0]+t[0];e[0]=i&65535;for(let s=1;s<8;s++)i=(e[s]+t[s]|0)+(i>>>16)|0,e[s]=i&65535;nn(r)}update(e){mb(this),$t(e),e=ya(e);let{buffer:t,blockLen:r}=this,o=e.length;for(let n=0;n<o;){let i=Math.min(r-this.pos,o-n);if(i===r){for(;r<=o-n;n+=r)this.process(e,n);continue}if(t.set(e.subarray(n,n+i),this.pos),this.pos+=i,n+=i,this.pos===r)this.process(t,0,!1),this.pos=0}return this}destroy(){this.destroyed=!0,nn(this.h,this.r,this.buffer,this.pad)}digestInto(e){mb(this),DR(e,this),this.finished=!0;let{buffer:t,h:r}=this,{pos:o}=this;if(o){t[o++]=1;for(;o<16;o++)t[o]=0;this.process(t,0,!0)}this.finalize();let n=0;for(let i=0;i<8;i++)e[n++]=r[i]>>>0,e[n++]=r[i]>>>8}digest(){let{buffer:e,outputLen:t}=this;this.digestInto(e);let r=e.slice(0,t);return this.destroy(),r}}var KR=BR(32,(e)=>new JR(e));function w8(e,t,r,o,n,i=20){let s=e[0],a=e[1],c=e[2],u=e[3],d=t[0],f=t[1],m=t[2],h=t[3],b=t[4],y=t[5],S=t[6],x=t[7],_=n,A=r[0],O=r[1],L=r[2],z=s,K=a,P=c,W=u,ee=d,B=f,R=m,j=h,I=b,T=y,k=S,M=x,N=_,H=A,G=O,re=L;for(let pe=0;pe<i;pe+=2)z=z+ee|0,N=Je(N^z,16),I=I+N|0,ee=Je(ee^I,12),z=z+ee|0,N=Je(N^z,8),I=I+N|0,ee=Je(ee^I,7),K=K+B|0,H=Je(H^K,16),T=T+H|0,B=Je(B^T,12),K=K+B|0,H=Je(H^K,8),T=T+H|0,B=Je(B^T,7),P=P+R|0,G=Je(G^P,16),k=k+G|0,R=Je(R^k,12),P=P+R|0,G=Je(G^P,8),k=k+G|0,R=Je(R^k,7),W=W+j|0,re=Je(re^W,16),M=M+re|0,j=Je(j^M,12),W=W+j|0,re=Je(re^W,8),M=M+re|0,j=Je(j^M,7),z=z+B|0,re=Je(re^z,16),k=k+re|0,B=Je(B^k,12),z=z+B|0,re=Je(re^z,8),k=k+re|0,B=Je(B^k,7),K=K+R|0,N=Je(N^K,16),M=M+N|0,R=Je(R^M,12),K=K+R|0,N=Je(N^K,8),M=M+N|0,R=Je(R^M,7),P=P+j|0,H=Je(H^P,16),I=I+H|0,j=Je(j^I,12),P=P+j|0,H=Je(H^P,8),I=I+H|0,j=Je(j^I,7),W=W+ee|0,G=Je(G^W,16),T=T+G|0,ee=Je(ee^T,12),W=W+ee|0,G=Je(G^W,8),T=T+G|0,ee=Je(ee^T,7);let ae=0;o[ae++]=s+z|0,o[ae++]=a+K|0,o[ae++]=c+P|0,o[ae++]=u+W|0,o[ae++]=d+ee|0,o[ae++]=f+B|0,o[ae++]=m+R|0,o[ae++]=h+j|0,o[ae++]=b+I|0,o[ae++]=y+T|0,o[ae++]=S+k|0,o[ae++]=x+M|0,o[ae++]=_+N|0,o[ae++]=A+H|0,o[ae++]=O+G|0,o[ae++]=L+re|0}var x8=FR(w8,{counterRight:!1,counterLength:4,allowShortKeys:!1});var _8=new Uint8Array(16),HR=(e,t)=>{e.update(t);let r=t.length%16;if(r)e.update(_8.subarray(r))},E8=new Uint8Array(32);function VR(e,t,r,o,n){if(n!==void 0)$t(n,void 0,"AAD");let i=e(t,r,E8),s=UR(o.length,n?n.length:0,!0),a=KR.create(i);if(n)HR(a,n);HR(a,o),a.update(s);let c=a.digest();return nn(i,s),c}var I8=(e)=>(t,r,o)=>({encrypt(i,s){let a=i.length;s=Nl(a+16,s,!1),s.set(i);let c=s.subarray(0,-16);e(t,r,c,c,1);let u=VR(e,t,r,c,o);return s.set(u,a),nn(u),s},decrypt(i,s){s=Nl(i.length-16,s,!1);let a=i.subarray(0,-16),c=i.subarray(-16),u=VR(e,t,r,a,o);if(!jR(c,u))throw nn(u),Error("invalid tag");return s.set(i.subarray(0,-16)),e(t,r,s,s,1),nn(u),s}}),qr=ZR({blockSize:64,nonceLength:12,tagLength:16},I8(x8));/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */function ba(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name==="Uint8Array"}function Dt(e,t=""){if(!Number.isSafeInteger(e)||e<0){let r=t&&`"${t}" `;throw Error(`${r}expected integer >= 0, got ${e}`)}}function Te(e,t,r=""){let o=ba(e),n=e?.length,i=t!==void 0;if(!o||i&&n!==t){let s=r&&`"${r}" `,a=i?` of length ${t}`:"",c=o?`length=${n}`:`type=${typeof e}`;throw Error(s+"expected Uint8Array"+a+", got "+c)}return e}function Mr(e){if(typeof e!=="function"||typeof e.create!=="function")throw Error("Hash must wrapped by utils.createHasher");Dt(e.outputLen),Dt(e.blockLen)}function co(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 Qf(e,t){Te(e,void 0,"digestInto() output");let r=t.outputLen;if(e.length<r)throw Error('"digestInto() output" expected to be of length >='+r)}function Yf(e){return new Uint32Array(e.buffer,e.byteOffset,Math.floor(e.byteLength/4))}function vr(...e){for(let t=0;t<e.length;t++)e[t].fill(0)}function Xf(e){return new DataView(e.buffer,e.byteOffset,e.byteLength)}function on(e,t){return e<<32-t|e>>>t}var k8=(()=>new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68)();function A8(e){return e<<24&4278190080|e<<8&16711680|e>>>8&65280|e>>>24&255}function T8(e){for(let t=0;t<e.length;t++)e[t]=A8(e[t]);return e}var gb=k8?(e)=>e:T8,GR=(()=>typeof Uint8Array.from([]).toHex==="function"&&typeof Uint8Array.fromHex==="function")(),$8=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,"0"));function is(e){if(Te(e),GR)return e.toHex();let t="";for(let r=0;r<e.length;r++)t+=$8[e[r]];return t}var ao={_0:48,_9:57,A:65,F:70,a:97,f:102};function WR(e){if(e>=ao._0&&e<=ao._9)return e-ao._0;if(e>=ao.A&&e<=ao.F)return e-(ao.A-10);if(e>=ao.a&&e<=ao.f)return e-(ao.a-10);return}function ss(e){if(typeof e!=="string")throw Error("hex string expected, got "+typeof e);if(GR)return Uint8Array.fromHex(e);let t=e.length,r=t/2;if(t%2)throw Error("hex string expected, got unpadded hex of length "+t);let o=new Uint8Array(r);for(let n=0,i=0;n<r;n++,i+=2){let s=WR(e.charCodeAt(i)),a=WR(e.charCodeAt(i+1));if(s===void 0||a===void 0){let c=e[i]+e[i+1];throw Error('hex string expected, got non-hex character "'+c+'" at index '+i)}o[n]=s*16+a}return o}function Et(...e){let t=0;for(let o=0;o<e.length;o++){let n=e[o];Te(n),t+=n.length}let r=new Uint8Array(t);for(let o=0,n=0;o<e.length;o++){let i=e[o];r.set(i,n),n+=i.length}return r}function Sa(e,t={}){let r=(n,i)=>e(i).update(n).digest(),o=e(void 0);return r.outputLen=o.outputLen,r.blockLen=o.blockLen,r.create=(n)=>e(n),Object.assign(r,t),Object.freeze(r)}function Vo(e=32){let t=typeof globalThis==="object"?globalThis.crypto:null;if(typeof t?.getRandomValues!=="function")throw Error("crypto.getRandomValues must be defined");return t.getRandomValues(new Uint8Array(e))}var Wo=(e)=>({oid:Uint8Array.from([6,9,96,134,72,1,101,3,4,2,e])});/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */var bb=BigInt(0),yb=BigInt(1);function Ll(e,t=""){if(typeof e!=="boolean"){let r=t&&`"${t}" `;throw Error(r+"expected boolean, got type="+typeof e)}return e}function QR(e){if(typeof e==="bigint"){if(!ep(e))throw Error("positive bigint expected, got "+e)}else Dt(e);return e}function jl(e){let t=QR(e).toString(16);return t.length&1?"0"+t:t}function YR(e){if(typeof e!=="string")throw Error("hex string expected, got "+typeof e);return e===""?bb:BigInt("0x"+e)}function Go(e){return YR(is(e))}function Qo(e){return YR(is(tp(Te(e)).reverse()))}function va(e,t){Dt(t),e=QR(e);let r=ss(e.toString(16).padStart(t*2,"0"));if(r.length!==t)throw Error("number too large");return r}function Bl(e,t){return va(e,t).reverse()}function tp(e){return Uint8Array.from(e)}function Yo(e){return Uint8Array.from(e,(t,r)=>{let o=t.charCodeAt(0);if(t.length!==1||o>127)throw Error(`string contains non-ASCII character "${e[r]}" with code ${o} at position ${r}`);return o})}var ep=(e)=>typeof e==="bigint"&&bb<=e;function R8(e,t,r){return ep(e)&&ep(t)&&ep(r)&&t<=e&&e<r}function Zl(e,t,r,o){if(!R8(t,r,o))throw Error("expected valid "+e+": "+r+" <= n < "+o+", got "+t)}function Sb(e){let t;for(t=0;e>bb;e>>=yb,t+=1);return t}var Ul=(e)=>(yb<<BigInt(e))-yb;function XR(e,t,r){if(Dt(e,"hashLen"),Dt(t,"qByteLen"),typeof r!=="function")throw Error("hmacFn must be a function");let o=(S)=>new Uint8Array(S),n=Uint8Array.of(),i=Uint8Array.of(0),s=Uint8Array.of(1),a=1000,c=o(e),u=o(e),d=0,f=()=>{c.fill(1),u.fill(0),d=0},m=(...S)=>r(u,Et(c,...S)),h=(S=n)=>{if(u=m(i,S),c=m(),S.length===0)return;u=m(s,S),c=m()},b=()=>{if(d++>=a)throw Error("drbg: tried max amount of iterations");let S=0,x=[];while(S<t){c=m();let _=c.slice();x.push(_),S+=c.length}return Et(...x)};return(S,x)=>{f(),h(S);let _=void 0;while(!(_=x(b())))h();return f(),_}}function as(e,t={},r={}){if(!e||typeof e!=="object")throw Error("expected valid options object");function o(i,s,a){let c=e[i];if(a&&c===void 0)return;let u=typeof c;if(u!==s||c===null)throw Error(`param "${i}" is invalid: expected ${s}, got ${u}`)}let n=(i,s)=>Object.entries(i).forEach(([a,c])=>o(a,c,s));n(t,!1),n(r,!0)}function vb(e){let t=new WeakMap;return(r,...o)=>{let n=t.get(r);if(n!==void 0)return n;let i=e(r,...o);return t.set(r,i),i}}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */var ur=BigInt(0),Xt=BigInt(1),cs=BigInt(2),rO=BigInt(3),nO=BigInt(4),oO=BigInt(5),O8=BigInt(7),iO=BigInt(8),C8=BigInt(9),sO=BigInt(16);function lr(e,t){let r=e%t;return r>=ur?r:t+r}function Fr(e,t,r){let o=e;while(t-- >ur)o*=o,o%=r;return o}function eO(e,t){if(e===ur)throw Error("invert: expected non-zero number");if(t<=ur)throw Error("invert: expected positive modulus, got "+t);let r=lr(e,t),o=t,n=ur,i=Xt,s=Xt,a=ur;while(r!==ur){let u=o/r,d=o%r,f=n-s*u,m=i-a*u;o=r,r=d,n=s,i=a,s=f,a=m}if(o!==Xt)throw Error("invert: does not exist");return lr(n,t)}function wb(e,t,r){if(!e.eql(e.sqr(t),r))throw Error("Cannot find square root")}function aO(e,t){let r=(e.ORDER+Xt)/nO,o=e.pow(t,r);return wb(e,o,t),o}function P8(e,t){let r=(e.ORDER-oO)/iO,o=e.mul(t,cs),n=e.pow(o,r),i=e.mul(t,n),s=e.mul(e.mul(i,cs),n),a=e.mul(i,e.sub(s,e.ONE));return wb(e,a,t),a}function z8(e){let t=rp(e),r=cO(e),o=r(t,t.neg(t.ONE)),n=r(t,o),i=r(t,t.neg(o)),s=(e+O8)/sO;return(a,c)=>{let u=a.pow(c,s),d=a.mul(u,o),f=a.mul(u,n),m=a.mul(u,i),h=a.eql(a.sqr(d),c),b=a.eql(a.sqr(f),c);u=a.cmov(u,d,h),d=a.cmov(m,f,b);let y=a.eql(a.sqr(d),c),S=a.cmov(u,d,y);return wb(a,S,c),S}}function cO(e){if(e<rO)throw Error("sqrt is not defined for small field");let t=e-Xt,r=0;while(t%cs===ur)t/=cs,r++;let o=cs,n=rp(e);while(tO(n,o)===1)if(o++>1000)throw Error("Cannot find square root: probably non-prime P");if(r===1)return aO;let i=n.pow(o,t),s=(t+Xt)/cs;return function(c,u){if(c.is0(u))return u;if(tO(c,u)!==1)throw Error("Cannot find square root");let d=r,f=c.mul(c.ONE,i),m=c.pow(u,t),h=c.pow(u,s);while(!c.eql(m,c.ONE)){if(c.is0(m))return c.ZERO;let b=1,y=c.sqr(m);while(!c.eql(y,c.ONE))if(b++,y=c.sqr(y),b===d)throw Error("Cannot find square root");let S=Xt<<BigInt(d-b-1),x=c.pow(f,S);d=b,f=c.sqr(x),m=c.mul(m,f),h=c.mul(h,x)}return h}}function N8(e){if(e%nO===rO)return aO;if(e%iO===oO)return P8;if(e%sO===C8)return z8(e);return cO(e)}var D8=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function xb(e){let t={ORDER:"bigint",BYTES:"number",BITS:"number"},r=D8.reduce((o,n)=>(o[n]="function",o),t);return as(e,r),e}function L8(e,t,r){if(r<ur)throw Error("invalid exponent, negatives unsupported");if(r===ur)return e.ONE;if(r===Xt)return t;let o=e.ONE,n=t;while(r>ur){if(r&Xt)o=e.mul(o,n);n=e.sqr(n),r>>=Xt}return o}function ql(e,t,r=!1){let o=Array(t.length).fill(r?e.ZERO:void 0),n=t.reduce((s,a,c)=>{if(e.is0(a))return s;return o[c]=s,e.mul(s,a)},e.ONE),i=e.inv(n);return t.reduceRight((s,a,c)=>{if(e.is0(a))return s;return o[c]=e.mul(s,o[c]),e.mul(s,a)},i),o}function tO(e,t){let r=(e.ORDER-Xt)/cs,o=e.pow(t,r),n=e.eql(o,e.ONE),i=e.eql(o,e.ZERO),s=e.eql(o,e.neg(e.ONE));if(!n&&!i&&!s)throw Error("invalid Legendre symbol result");return n?1:i?0:-1}function j8(e,t){if(t!==void 0)Dt(t);let r=t!==void 0?t:e.toString(2).length,o=Math.ceil(r/8);return{nBitLength:r,nByteLength:o}}class lO{ORDER;BITS;BYTES;isLE;ZERO=ur;ONE=Xt;_lengths;_sqrt;_mod;constructor(e,t={}){if(e<=ur)throw Error("invalid field: expected ORDER > 0, got "+e);let r=void 0;if(this.isLE=!1,t!=null&&typeof t==="object"){if(typeof t.BITS==="number")r=t.BITS;if(typeof t.sqrt==="function")this.sqrt=t.sqrt;if(typeof t.isLE==="boolean")this.isLE=t.isLE;if(t.allowedLengths)this._lengths=t.allowedLengths?.slice();if(typeof t.modFromBytes==="boolean")this._mod=t.modFromBytes}let{nBitLength:o,nByteLength:n}=j8(e,r);if(n>2048)throw Error("invalid field: expected ORDER of <= 2048 bytes");this.ORDER=e,this.BITS=o,this.BYTES=n,this._sqrt=void 0,Object.preventExtensions(this)}create(e){return lr(e,this.ORDER)}isValid(e){if(typeof e!=="bigint")throw Error("invalid field element: expected bigint, got "+typeof e);return ur<=e&&e<this.ORDER}is0(e){return e===ur}isValidNot0(e){return!this.is0(e)&&this.isValid(e)}isOdd(e){return(e&Xt)===Xt}neg(e){return lr(-e,this.ORDER)}eql(e,t){return e===t}sqr(e){return lr(e*e,this.ORDER)}add(e,t){return lr(e+t,this.ORDER)}sub(e,t){return lr(e-t,this.ORDER)}mul(e,t){return lr(e*t,this.ORDER)}pow(e,t){return L8(this,e,t)}div(e,t){return lr(e*eO(t,this.ORDER),this.ORDER)}sqrN(e){return e*e}addN(e,t){return e+t}subN(e,t){return e-t}mulN(e,t){return e*t}inv(e){return eO(e,this.ORDER)}sqrt(e){if(!this._sqrt)this._sqrt=N8(this.ORDER);return this._sqrt(this,e)}toBytes(e){return this.isLE?Bl(e,this.BYTES):va(e,this.BYTES)}fromBytes(e,t=!1){Te(e);let{_lengths:r,BYTES:o,isLE:n,ORDER:i,_mod:s}=this;if(r){if(!r.includes(e.length)||e.length>o)throw Error("Field.fromBytes: expected "+r+" bytes, got "+e.length);let c=new Uint8Array(o);c.set(e,n?0:c.length-e.length),e=c}if(e.length!==o)throw Error("Field.fromBytes: expected "+o+" bytes, got "+e.length);let a=n?Qo(e):Go(e);if(s)a=lr(a,i);if(!t){if(!this.isValid(a))throw Error("invalid field element: outside of range 0..ORDER")}return a}invertBatch(e){return ql(this,e)}cmov(e,t,r){return r?t:e}}function rp(e,t={}){return new lO(e,t)}function uO(e){if(typeof e!=="bigint")throw Error("field order must be bigint");let t=e.toString(2).length;return Math.ceil(t/8)}function _b(e){let t=uO(e);return t+Math.ceil(t/2)}function dO(e,t,r=!1){Te(e);let o=e.length,n=uO(t),i=_b(t);if(o<16||o<i||o>1024)throw Error("expected "+i+"-1024 bytes of input, got "+o);let s=r?Qo(e):Go(e),a=lr(s,t-Xt)+Xt;return r?Bl(a,n):va(a,n)}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */var wa=BigInt(0),ls=BigInt(1);function Ml(e,t){let r=t.negate();return e?r:t}function Ab(e,t){let r=ql(e.Fp,t.map((o)=>o.Z));return t.map((o,n)=>e.fromAffine(o.toAffine(r[n])))}function hO(e,t){if(!Number.isSafeInteger(e)||e<=0||e>t)throw Error("invalid window size, expected [1.."+t+"], got W="+e)}function Eb(e,t){hO(e,t);let r=Math.ceil(t/e)+1,o=2**(e-1),n=2**e,i=Ul(e),s=BigInt(e);return{windows:r,windowSize:o,mask:i,maxNumber:n,shiftBy:s}}function fO(e,t,r){let{windowSize:o,mask:n,maxNumber:i,shiftBy:s}=r,a=Number(e&n),c=e>>s;if(a>o)a-=i,c+=ls;let u=t*o,d=u+Math.abs(a)-1,f=a===0,m=a<0,h=t%2!==0;return{nextN:c,offset:d,isZero:f,isNeg:m,isNegF:h,offsetF:u}}var Ib=new WeakMap,gO=new WeakMap;function kb(e){return gO.get(e)||1}function pO(e){if(e!==wa)throw Error("invalid wNAF")}class Tb{BASE;ZERO;Fn;bits;constructor(e,t){this.BASE=e.BASE,this.ZERO=e.ZERO,this.Fn=e.Fn,this.bits=t}_unsafeLadder(e,t,r=this.ZERO){let o=e;while(t>wa){if(t&ls)r=r.add(o);o=o.double(),t>>=ls}return r}precomputeWindow(e,t){let{windows:r,windowSize:o}=Eb(t,this.bits),n=[],i=e,s=i;for(let a=0;a<r;a++){s=i,n.push(s);for(let c=1;c<o;c++)s=s.add(i),n.push(s);i=s.double()}return n}wNAF(e,t,r){if(!this.Fn.isValid(r))throw Error("invalid scalar");let o=this.ZERO,n=this.BASE,i=Eb(e,this.bits);for(let s=0;s<i.windows;s++){let{nextN:a,offset:c,isZero:u,isNeg:d,isNegF:f,offsetF:m}=fO(r,s,i);if(r=a,u)n=n.add(Ml(f,t[m]));else o=o.add(Ml(d,t[c]))}return pO(r),{p:o,f:n}}wNAFUnsafe(e,t,r,o=this.ZERO){let n=Eb(e,this.bits);for(let i=0;i<n.windows;i++){if(r===wa)break;let{nextN:s,offset:a,isZero:c,isNeg:u}=fO(r,i,n);if(r=s,c)continue;else{let d=t[a];o=o.add(u?d.negate():d)}}return pO(r),o}getPrecomputes(e,t,r){let o=Ib.get(t);if(!o){if(o=this.precomputeWindow(t,e),e!==1){if(typeof r==="function")o=r(o);Ib.set(t,o)}}return o}cached(e,t,r){let o=kb(e);return this.wNAF(o,this.getPrecomputes(o,e,r),t)}unsafe(e,t,r,o){let n=kb(e);if(n===1)return this._unsafeLadder(e,t,o);return this.wNAFUnsafe(n,this.getPrecomputes(n,e,r),t,o)}createCache(e,t){hO(t,this.bits),gO.set(e,t),Ib.delete(e)}hasCache(e){return kb(e)!==1}}function yO(e,t,r,o){let n=t,i=e.ZERO,s=e.ZERO;while(r>wa||o>wa){if(r&ls)i=i.add(n);if(o&ls)s=s.add(n);n=n.double(),r>>=ls,o>>=ls}return{p1:i,p2:s}}function mO(e,t,r){if(t){if(t.ORDER!==e)throw Error("Field.ORDER must match order: Fp == p, Fn == n");return xb(t),t}else return rp(e,{isLE:r})}function bO(e,t,r={},o){if(o===void 0)o=e==="edwards";if(!t||typeof t!=="object")throw Error(`expected valid ${e} CURVE object`);for(let c of["p","n","h"]){let u=t[c];if(!(typeof u==="bigint"&&u>wa))throw Error(`CURVE.${c} must be positive bigint`)}let n=mO(t.p,r.Fp,o),i=mO(t.n,r.Fn,o),a=["Gx","Gy","a",e==="weierstrass"?"b":"d"];for(let c of a)if(!n.isValid(t[c]))throw Error(`CURVE.${c} must be valid field element of CURVE.Fp`);return t=Object.freeze(Object.assign({},t)),{CURVE:t,Fp:n,Fn:i}}function np(e,t){return function(o){let n=e(o);return{secretKey:n,publicKey:t(n)}}}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */var Fl=BigInt(0),xa=BigInt(1),op=BigInt(2);function B8(e){return as(e,{adjustScalarBytes:"function",powPminus2:"function"}),Object.freeze({...e})}function SO(e){let t=B8(e),{P:r,type:o,adjustScalarBytes:n,powPminus2:i,randomBytes:s}=t,a=o==="x25519";if(!a&&o!=="x448")throw Error("invalid type");let c=s||Vo,u=a?255:448,d=a?32:56,f=a?BigInt(9):BigInt(5),m=a?BigInt(121665):BigInt(39081),h=a?op**BigInt(254):op**BigInt(447),b=a?BigInt(8)*op**BigInt(251)-xa:BigInt(4)*op**BigInt(445)-xa,y=h+b+xa,S=(I)=>lr(I,r),x=_(f);function _(I){return Bl(S(I),d)}function A(I){let T=tp(Te(I,d,"uCoordinate"));if(a)T[31]&=127;return S(Qo(T))}function O(I){return Qo(n(tp(Te(I,d,"scalar"))))}function L(I,T){let k=ee(A(T),O(I));if(k===Fl)throw Error("invalid private or public key received");return _(k)}function z(I){return L(I,x)}let K=z,P=L;function W(I,T,k){let M=S(I*(T-k));return T=S(T-M),k=S(k+M),{x_2:T,x_3:k}}function ee(I,T){Zl("u",I,Fl,r),Zl("scalar",T,h,y);let k=T,M=I,N=xa,H=Fl,G=I,re=xa,ae=Fl;for(let be=BigInt(u-1);be>=Fl;be--){let ve=k>>be&xa;ae^=ve,{x_2:N,x_3:G}=W(ae,N,G),{x_2:H,x_3:re}=W(ae,H,re),ae=ve;let ke=N+H,Ie=S(ke*ke),we=N-H,Ue=S(we*we),De=Ie-Ue,Qe=G+re,bt=G-re,Tt=S(bt*ke),Nt=S(Qe*we),lt=Tt+Nt,$r=Tt-Nt;G=S(lt*lt),re=S(M*S($r*$r)),N=S(Ie*Ue),H=S(De*(Ie+S(m*De)))}({x_2:N,x_3:G}=W(ae,N,G)),{x_2:H,x_3:re}=W(ae,H,re);let pe=i(H);return S(N*pe)}let B={secretKey:d,publicKey:d,seed:d},R=(I=c(d))=>(Te(I,B.seed,"seed"),I),j={randomSecretKey:R};return Object.freeze({keygen:np(R,K),getSharedSecret:P,getPublicKey:K,scalarMult:L,scalarMultBase:z,utils:j,GuBytes:x.slice(),lengths:B})}class $b{oHash;iHash;blockLen;outputLen;finished=!1;destroyed=!1;constructor(e,t){if(Mr(e),Te(t,void 0,"key"),this.iHash=e.create(),typeof this.iHash.update!=="function")throw Error("Expected instance of class which extends utils.Hash");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;let r=this.blockLen,o=new Uint8Array(r);o.set(t.length>r?e.create().update(t).digest():t);for(let n=0;n<o.length;n++)o[n]^=54;this.iHash.update(o),this.oHash=e.create();for(let n=0;n<o.length;n++)o[n]^=106;this.oHash.update(o),vr(o)}update(e){return co(this),this.iHash.update(e),this}digestInto(e){co(this),Te(e,this.outputLen,"output"),this.finished=!0,this.iHash.digestInto(e),this.oHash.update(e),this.oHash.digestInto(e),this.destroy()}digest(){let e=new Uint8Array(this.oHash.outputLen);return this.digestInto(e),e}_cloneInto(e){e||=Object.create(Object.getPrototypeOf(this),{});let{oHash:t,iHash:r,finished:o,destroyed:n,blockLen:i,outputLen:s}=this;return e=e,e.finished=o,e.destroyed=n,e.blockLen=i,e.outputLen=s,e.oHash=t._cloneInto(e.oHash),e.iHash=r._cloneInto(e.iHash),e}clone(){return this._cloneInto()}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}}var _a=(e,t,r)=>new $b(e,t).update(r).digest();_a.create=(e,t)=>new $b(e,t);/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */var vO=(e,t)=>(e+(e>=0?t:-t)/xO)/t;function Z8(e,t,r){let[[o,n],[i,s]]=t,a=vO(s*e,r),c=vO(-n*e,r),u=e-a*o-c*i,d=-a*n-c*s,f=u<lo,m=d<lo;if(f)u=-u;if(m)d=-d;let h=Ul(Math.ceil(Sb(r)/2))+Ea;if(u<lo||u>=h||d<lo||d>=h)throw Error("splitScalar (endomorphism): failed, k="+e);return{k1neg:f,k1:u,k2neg:m,k2:d}}function Ob(e){if(!["compact","recovered","der"].includes(e))throw Error('Signature format must be "compact", "recovered", or "der"');return e}function Rb(e,t){let r={};for(let o of Object.keys(t))r[o]=e[o]===void 0?t[o]:e[o];if(Ll(r.lowS,"lowS"),Ll(r.prehash,"prehash"),r.format!==void 0)Ob(r.format);return r}class wO extends Error{constructor(e=""){super(e)}}var Xo={Err:wO,_tlv:{encode:(e,t)=>{let{Err:r}=Xo;if(e<0||e>256)throw new r("tlv.encode: wrong tag");if(t.length&1)throw new r("tlv.encode: unpadded data");let o=t.length/2,n=jl(o);if(n.length/2&128)throw new r("tlv.encode: long form length too big");let i=o>127?jl(n.length/2|128):"";return jl(e)+i+n+t},decode(e,t){let{Err:r}=Xo,o=0;if(e<0||e>256)throw new r("tlv.encode: wrong tag");if(t.length<2||t[o++]!==e)throw new r("tlv.decode: wrong tlv");let n=t[o++],i=!!(n&128),s=0;if(!i)s=n;else{let c=n&127;if(!c)throw new r("tlv.decode(long): indefinite length not supported");if(c>4)throw new r("tlv.decode(long): byte length is too big");let u=t.subarray(o,o+c);if(u.length!==c)throw new r("tlv.decode: length bytes not complete");if(u[0]===0)throw new r("tlv.decode(long): zero leftmost byte");for(let d of u)s=s<<8|d;if(o+=c,s<128)throw new r("tlv.decode(long): not minimal encoding")}let a=t.subarray(o,o+s);if(a.length!==s)throw new r("tlv.decode: wrong value length");return{v:a,l:t.subarray(o+s)}}},_int:{encode(e){let{Err:t}=Xo;if(e<lo)throw new t("integer: negative integers are not allowed");let r=jl(e);if(Number.parseInt(r[0],16)&8)r="00"+r;if(r.length&1)throw new t("unexpected DER parsing assertion: unpadded hex");return r},decode(e){let{Err:t}=Xo;if(e[0]&128)throw new t("invalid signature integer: negative");if(e[0]===0&&!(e[1]&128))throw new t("invalid signature integer: unnecessary leading zero");return Go(e)}},toSig(e){let{Err:t,_int:r,_tlv:o}=Xo,n=Te(e,void 0,"signature"),{v:i,l:s}=o.decode(48,n);if(s.length)throw new t("invalid signature: left bytes after parsing");let{v:a,l:c}=o.decode(2,i),{v:u,l:d}=o.decode(2,c);if(d.length)throw new t("invalid signature: left bytes after parsing");return{r:r.decode(a),s:r.decode(u)}},hexFromSig(e){let{_tlv:t,_int:r}=Xo,o=t.encode(2,r.encode(e.r)),n=t.encode(2,r.encode(e.s)),i=o+n;return t.encode(48,i)}},lo=BigInt(0),Ea=BigInt(1),xO=BigInt(2),ip=BigInt(3),U8=BigInt(4);function Cb(e,t={}){let r=bO("weierstrass",e,t),{Fp:o,Fn:n}=r,i=r.CURVE,{h:s,n:a}=i;as(t,{},{allowInfinityPoint:"boolean",clearCofactor:"function",isTorsionFree:"function",fromBytes:"function",toBytes:"function",endo:"object"});let{endo:c}=t;if(c){if(!o.is0(i.a)||typeof c.beta!=="bigint"||!Array.isArray(c.basises))throw Error('invalid endo: expected "beta": bigint and "basises": array')}let u=EO(o,n);function d(){if(!o.isOdd)throw Error("compression is not supported: Field does not have .isOdd()")}function f(R,j,I){let{x:T,y:k}=j.toAffine(),M=o.toBytes(T);if(Ll(I,"isCompressed"),I){d();let N=!o.isOdd(k);return Et(_O(N),M)}else return Et(Uint8Array.of(4),M,o.toBytes(k))}function m(R){Te(R,void 0,"Point");let{publicKey:j,publicKeyUncompressed:I}=u,T=R.length,k=R[0],M=R.subarray(1);if(T===j&&(k===2||k===3)){let N=o.fromBytes(M);if(!o.isValid(N))throw Error("bad point: is not on curve, wrong x");let H=y(N),G;try{G=o.sqrt(H)}catch(pe){let be=pe instanceof Error?": "+pe.message:"";throw Error("bad point: is not on curve, sqrt error"+be)}d();let re=o.isOdd(G);if((k&1)===1!==re)G=o.neg(G);return{x:N,y:G}}else if(T===I&&k===4){let N=o.BYTES,H=o.fromBytes(M.subarray(0,N)),G=o.fromBytes(M.subarray(N,N*2));if(!S(H,G))throw Error("bad point: is not on curve");return{x:H,y:G}}else throw Error(`bad point: got length ${T}, expected compressed=${j} or uncompressed=${I}`)}let h=t.toBytes||f,b=t.fromBytes||m;function y(R){let j=o.sqr(R),I=o.mul(j,R);return o.add(o.add(I,o.mul(R,i.a)),i.b)}function S(R,j){let I=o.sqr(j),T=y(R);return o.eql(I,T)}if(!S(i.Gx,i.Gy))throw Error("bad curve params: generator point");let x=o.mul(o.pow(i.a,ip),U8),_=o.mul(o.sqr(i.b),BigInt(27));if(o.is0(o.add(x,_)))throw Error("bad curve params: a or b");function A(R,j,I=!1){if(!o.isValid(j)||I&&o.is0(j))throw Error(`bad point coordinate ${R}`);return j}function O(R){if(!(R instanceof W))throw Error("Weierstrass Point expected")}function L(R){if(!c||!c.basises)throw Error("no endo");return Z8(R,c.basises,n.ORDER)}let z=vb((R,j)=>{let{X:I,Y:T,Z:k}=R;if(o.eql(k,o.ONE))return{x:I,y:T};let M=R.is0();if(j==null)j=M?o.ONE:o.inv(k);let N=o.mul(I,j),H=o.mul(T,j),G=o.mul(k,j);if(M)return{x:o.ZERO,y:o.ZERO};if(!o.eql(G,o.ONE))throw Error("invZ was invalid");return{x:N,y:H}}),K=vb((R)=>{if(R.is0()){if(t.allowInfinityPoint&&!o.is0(R.Y))return;throw Error("bad point: ZERO")}let{x:j,y:I}=R.toAffine();if(!o.isValid(j)||!o.isValid(I))throw Error("bad point: x or y not field elements");if(!S(j,I))throw Error("bad point: equation left != right");if(!R.isTorsionFree())throw Error("bad point: not in prime-order subgroup");return!0});function P(R,j,I,T,k){return I=new W(o.mul(I.X,R),I.Y,I.Z),j=Ml(T,j),I=Ml(k,I),j.add(I)}class W{static BASE=new W(i.Gx,i.Gy,o.ONE);static ZERO=new W(o.ZERO,o.ONE,o.ZERO);static Fp=o;static Fn=n;X;Y;Z;constructor(R,j,I){this.X=A("x",R),this.Y=A("y",j,!0),this.Z=A("z",I),Object.freeze(this)}static CURVE(){return i}static fromAffine(R){let{x:j,y:I}=R||{};if(!R||!o.isValid(j)||!o.isValid(I))throw Error("invalid affine point");if(R instanceof W)throw Error("projective point not allowed");if(o.is0(j)&&o.is0(I))return W.ZERO;return new W(j,I,o.ONE)}static fromBytes(R){let j=W.fromAffine(b(Te(R,void 0,"point")));return j.assertValidity(),j}static fromHex(R){return W.fromBytes(ss(R))}get x(){return this.toAffine().x}get y(){return this.toAffine().y}precompute(R=8,j=!0){if(B.createCache(this,R),!j)this.multiply(ip);return this}assertValidity(){K(this)}hasEvenY(){let{y:R}=this.toAffine();if(!o.isOdd)throw Error("Field doesn't support isOdd");return!o.isOdd(R)}equals(R){O(R);let{X:j,Y:I,Z:T}=this,{X:k,Y:M,Z:N}=R,H=o.eql(o.mul(j,N),o.mul(k,T)),G=o.eql(o.mul(I,N),o.mul(M,T));return H&&G}negate(){return new W(this.X,o.neg(this.Y),this.Z)}double(){let{a:R,b:j}=i,I=o.mul(j,ip),{X:T,Y:k,Z:M}=this,N=o.ZERO,H=o.ZERO,G=o.ZERO,re=o.mul(T,T),ae=o.mul(k,k),pe=o.mul(M,M),be=o.mul(T,k);return be=o.add(be,be),G=o.mul(T,M),G=o.add(G,G),N=o.mul(R,G),H=o.mul(I,pe),H=o.add(N,H),N=o.sub(ae,H),H=o.add(ae,H),H=o.mul(N,H),N=o.mul(be,N),G=o.mul(I,G),pe=o.mul(R,pe),be=o.sub(re,pe),be=o.mul(R,be),be=o.add(be,G),G=o.add(re,re),re=o.add(G,re),re=o.add(re,pe),re=o.mul(re,be),H=o.add(H,re),pe=o.mul(k,M),pe=o.add(pe,pe),re=o.mul(pe,be),N=o.sub(N,re),G=o.mul(pe,ae),G=o.add(G,G),G=o.add(G,G),new W(N,H,G)}add(R){O(R);let{X:j,Y:I,Z:T}=this,{X:k,Y:M,Z:N}=R,H=o.ZERO,G=o.ZERO,re=o.ZERO,ae=i.a,pe=o.mul(i.b,ip),be=o.mul(j,k),ve=o.mul(I,M),ke=o.mul(T,N),Ie=o.add(j,I),we=o.add(k,M);Ie=o.mul(Ie,we),we=o.add(be,ve),Ie=o.sub(Ie,we),we=o.add(j,T);let Ue=o.add(k,N);return we=o.mul(we,Ue),Ue=o.add(be,ke),we=o.sub(we,Ue),Ue=o.add(I,T),H=o.add(M,N),Ue=o.mul(Ue,H),H=o.add(ve,ke),Ue=o.sub(Ue,H),re=o.mul(ae,we),H=o.mul(pe,ke),re=o.add(H,re),H=o.sub(ve,re),re=o.add(ve,re),G=o.mul(H,re),ve=o.add(be,be),ve=o.add(ve,be),ke=o.mul(ae,ke),we=o.mul(pe,we),ve=o.add(ve,ke),ke=o.sub(be,ke),ke=o.mul(ae,ke),we=o.add(we,ke),be=o.mul(ve,we),G=o.add(G,be),be=o.mul(Ue,we),H=o.mul(Ie,H),H=o.sub(H,be),be=o.mul(Ie,ve),re=o.mul(Ue,re),re=o.add(re,be),new W(H,G,re)}subtract(R){return this.add(R.negate())}is0(){return this.equals(W.ZERO)}multiply(R){let{endo:j}=t;if(!n.isValidNot0(R))throw Error("invalid scalar: out of range");let I,T,k=(M)=>B.cached(this,M,(N)=>Ab(W,N));if(j){let{k1neg:M,k1:N,k2neg:H,k2:G}=L(R),{p:re,f:ae}=k(N),{p:pe,f:be}=k(G);T=ae.add(be),I=P(j.beta,re,pe,M,H)}else{let{p:M,f:N}=k(R);I=M,T=N}return Ab(W,[I,T])[0]}multiplyUnsafe(R){let{endo:j}=t,I=this;if(!n.isValid(R))throw Error("invalid scalar: out of range");if(R===lo||I.is0())return W.ZERO;if(R===Ea)return I;if(B.hasCache(this))return this.multiply(R);if(j){let{k1neg:T,k1:k,k2neg:M,k2:N}=L(R),{p1:H,p2:G}=yO(W,I,k,N);return P(j.beta,H,G,T,M)}else return B.unsafe(I,R)}toAffine(R){return z(this,R)}isTorsionFree(){let{isTorsionFree:R}=t;if(s===Ea)return!0;if(R)return R(W,this);return B.unsafe(this,a).is0()}clearCofactor(){let{clearCofactor:R}=t;if(s===Ea)return this;if(R)return R(W,this);return this.multiplyUnsafe(s)}isSmallOrder(){return this.multiplyUnsafe(s).is0()}toBytes(R=!0){return Ll(R,"isCompressed"),this.assertValidity(),h(W,this,R)}toHex(R=!0){return is(this.toBytes(R))}toString(){return`<Point ${this.is0()?"ZERO":this.toHex()}>`}}let ee=n.BITS,B=new Tb(W,t.endo?Math.ceil(ee/2):ee);return W.BASE.precompute(8),W}function _O(e){return Uint8Array.of(e?2:3)}function EO(e,t){return{secretKey:t.BYTES,publicKey:1+e.BYTES,publicKeyUncompressed:1+2*e.BYTES,publicKeyHasPrefix:!0,signature:2*t.BYTES}}function q8(e,t={}){let{Fn:r}=e,o=t.randomBytes||Vo,n=Object.assign(EO(e.Fp,r),{seed:_b(r.ORDER)});function i(h){try{let b=r.fromBytes(h);return r.isValidNot0(b)}catch(b){return!1}}function s(h,b){let{publicKey:y,publicKeyUncompressed:S}=n;try{let x=h.length;if(b===!0&&x!==y)return!1;if(b===!1&&x!==S)return!1;return!!e.fromBytes(h)}catch(x){return!1}}function a(h=o(n.seed)){return dO(Te(h,n.seed,"seed"),r.ORDER)}function c(h,b=!0){return e.BASE.multiply(r.fromBytes(h)).toBytes(b)}function u(h){let{secretKey:b,publicKey:y,publicKeyUncompressed:S}=n;if(!ba(h))return;if("_lengths"in r&&r._lengths||b===y)return;let x=Te(h,void 0,"key").length;return x===y||x===S}function d(h,b,y=!0){if(u(h)===!0)throw Error("first arg must be private key");if(u(b)===!1)throw Error("second arg must be public key");let S=r.fromBytes(h);return e.fromBytes(b).multiply(S).toBytes(y)}let f={isValidSecretKey:i,isValidPublicKey:s,randomSecretKey:a},m=np(a,c);return Object.freeze({getPublicKey:c,getSharedSecret:d,keygen:m,Point:e,utils:f,lengths:n})}function Pb(e,t,r={}){Mr(t),as(r,{},{hmac:"function",lowS:"boolean",randomBytes:"function",bits2int:"function",bits2int_modN:"function"}),r=Object.assign({},r);let o=r.randomBytes||Vo,n=r.hmac||((I,T)=>_a(t,I,T)),{Fp:i,Fn:s}=e,{ORDER:a,BITS:c}=s,{keygen:u,getPublicKey:d,getSharedSecret:f,utils:m,lengths:h}=q8(e,r),b={prehash:!0,lowS:typeof r.lowS==="boolean"?r.lowS:!0,format:"compact",extraEntropy:!1},y=a*xO<i.ORDER;function S(I){let T=a>>Ea;return I>T}function x(I,T){if(!s.isValidNot0(T))throw Error(`invalid signature ${I}: out of range 1..Point.Fn.ORDER`);return T}function _(){if(y)throw Error('"recovered" sig type is not supported for cofactor >2 curves')}function A(I,T){Ob(T);let k=h.signature,M=T==="compact"?k:T==="recovered"?k+1:void 0;return Te(I,M)}class O{r;s;recovery;constructor(I,T,k){if(this.r=x("r",I),this.s=x("s",T),k!=null){if(_(),![0,1,2,3].includes(k))throw Error("invalid recovery id");this.recovery=k}Object.freeze(this)}static fromBytes(I,T=b.format){A(I,T);let k;if(T==="der"){let{r:G,s:re}=Xo.toSig(Te(I));return new O(G,re)}if(T==="recovered")k=I[0],T="compact",I=I.subarray(1);let M=h.signature/2,N=I.subarray(0,M),H=I.subarray(M,M*2);return new O(s.fromBytes(N),s.fromBytes(H),k)}static fromHex(I,T){return this.fromBytes(ss(I),T)}assertRecovery(){let{recovery:I}=this;if(I==null)throw Error("invalid recovery id: must be present");return I}addRecoveryBit(I){return new O(this.r,this.s,I)}recoverPublicKey(I){let{r:T,s:k}=this,M=this.assertRecovery(),N=M===2||M===3?T+a:T;if(!i.isValid(N))throw Error("invalid recovery id: sig.r+curve.n != R.x");let H=i.toBytes(N),G=e.fromBytes(Et(_O((M&1)===0),H)),re=s.inv(N),ae=z(Te(I,void 0,"msgHash")),pe=s.create(-ae*re),be=s.create(k*re),ve=e.BASE.multiplyUnsafe(pe).add(G.multiplyUnsafe(be));if(ve.is0())throw Error("invalid recovery: point at infinify");return ve.assertValidity(),ve}hasHighS(){return S(this.s)}toBytes(I=b.format){if(Ob(I),I==="der")return ss(Xo.hexFromSig(this));let{r:T,s:k}=this,M=s.toBytes(T),N=s.toBytes(k);if(I==="recovered")return _(),Et(Uint8Array.of(this.assertRecovery()),M,N);return Et(M,N)}toHex(I){return is(this.toBytes(I))}}let L=r.bits2int||function(T){if(T.length>8192)throw Error("input is too large");let k=Go(T),M=T.length*8-c;return M>0?k>>BigInt(M):k},z=r.bits2int_modN||function(T){return s.create(L(T))},K=Ul(c);function P(I){return Zl("num < 2^"+c,I,lo,K),s.toBytes(I)}function W(I,T){return Te(I,void 0,"message"),T?Te(t(I),void 0,"prehashed message"):I}function ee(I,T,k){let{lowS:M,prehash:N,extraEntropy:H}=Rb(k,b);I=W(I,N);let G=z(I),re=s.fromBytes(T);if(!s.isValidNot0(re))throw Error("invalid private key");let ae=[P(re),P(G)];if(H!=null&&H!==!1){let ke=H===!0?o(h.secretKey):H;ae.push(Te(ke,void 0,"extraEntropy"))}let pe=Et(...ae),be=G;function ve(ke){let Ie=L(ke);if(!s.isValidNot0(Ie))return;let we=s.inv(Ie),Ue=e.BASE.multiply(Ie).toAffine(),De=s.create(Ue.x);if(De===lo)return;let Qe=s.create(we*s.create(be+De*re));if(Qe===lo)return;let bt=(Ue.x===De?0:2)|Number(Ue.y&Ea),Tt=Qe;if(M&&S(Qe))Tt=s.neg(Qe),bt^=1;return new O(De,Tt,y?void 0:bt)}return{seed:pe,k2sig:ve}}function B(I,T,k={}){let{seed:M,k2sig:N}=ee(I,T,k);return XR(t.outputLen,s.BYTES,n)(M,N).toBytes(k.format)}function R(I,T,k,M={}){let{lowS:N,prehash:H,format:G}=Rb(M,b);if(k=Te(k,void 0,"publicKey"),T=W(T,H),!ba(I)){let re=I instanceof O?", use sig.toBytes()":"";throw Error("verify expects Uint8Array signature"+re)}A(I,G);try{let re=O.fromBytes(I,G),ae=e.fromBytes(k);if(N&&re.hasHighS())return!1;let{r:pe,s:be}=re,ve=z(T),ke=s.inv(be),Ie=s.create(ve*ke),we=s.create(pe*ke),Ue=e.BASE.multiplyUnsafe(Ie).add(ae.multiplyUnsafe(we));if(Ue.is0())return!1;return s.create(Ue.x)===pe}catch(re){return!1}}function j(I,T,k={}){let{prehash:M}=Rb(k,b);return T=W(T,M),O.fromBytes(I,"recovered").recoverPublicKey(T).toBytes()}return Object.freeze({keygen:u,getPublicKey:d,getSharedSecret:f,utils:m,lengths:h,Point:e,sign:B,verify:R,recoverPublicKey:j,Signature:O,hash:t})}function IO(e,t,r){return e&t^~e&r}function kO(e,t,r){return e&t^e&r^t&r}class sp{blockLen;outputLen;padOffset;isLE;buffer;view;finished=!1;length=0;pos=0;destroyed=!1;constructor(e,t,r,o){this.blockLen=e,this.outputLen=t,this.padOffset=r,this.isLE=o,this.buffer=new Uint8Array(e),this.view=Xf(this.buffer)}update(e){co(this),Te(e);let{view:t,buffer:r,blockLen:o}=this,n=e.length;for(let i=0;i<n;){let s=Math.min(o-this.pos,n-i);if(s===o){let a=Xf(e);for(;o<=n-i;i+=o)this.process(a,i);continue}if(r.set(e.subarray(i,i+s),this.pos),this.pos+=s,i+=s,this.pos===o)this.process(t,0),this.pos=0}return this.length+=e.length,this.roundClean(),this}digestInto(e){co(this),Qf(e,this),this.finished=!0;let{buffer:t,view:r,blockLen:o,isLE:n}=this,{pos:i}=this;if(t[i++]=128,vr(this.buffer.subarray(i)),this.padOffset>o-i)this.process(r,0),i=0;for(let d=i;d<o;d++)t[d]=0;r.setBigUint64(o-8,BigInt(this.length*8),n),this.process(r,0);let s=Xf(e),a=this.outputLen;if(a%4)throw Error("_sha2: outputLen must be aligned to 32bit");let c=a/4,u=this.get();if(c>u.length)throw Error("_sha2: outputLen bigger than state");for(let d=0;d<c;d++)s.setUint32(4*d,u[d],n)}digest(){let{buffer:e,outputLen:t}=this;this.digestInto(e);let r=e.slice(0,t);return this.destroy(),r}_cloneInto(e){e||=new this.constructor,e.set(...this.get());let{blockLen:t,buffer:r,length:o,finished:n,destroyed:i,pos:s}=this;if(e.destroyed=i,e.finished=n,e.length=o,e.pos=s,o%t)e.buffer.set(r);return e}clone(){return this._cloneInto()}}var uo=Uint32Array.from([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]);var Ft=Uint32Array.from([3418070365,3238371032,1654270250,914150663,2438529370,812702999,355462360,4144912697,1731405415,4290775857,2394180231,1750603025,3675008525,1694076839,1203062813,3204075428]);var ap=BigInt(4294967295),AO=BigInt(32);function M8(e,t=!1){if(t)return{h:Number(e&ap),l:Number(e>>AO&ap)};return{h:Number(e>>AO&ap)|0,l:Number(e&ap)|0}}function cp(e,t=!1){let r=e.length,o=new Uint32Array(r),n=new Uint32Array(r);for(let i=0;i<r;i++){let{h:s,l:a}=M8(e[i],t);[o[i],n[i]]=[s,a]}return[o,n]}var zb=(e,t,r)=>e>>>r,Nb=(e,t,r)=>e<<32-r|t>>>r,us=(e,t,r)=>e>>>r|t<<32-r,ds=(e,t,r)=>e<<32-r|t>>>r,Jl=(e,t,r)=>e<<64-r|t>>>r-32,Kl=(e,t,r)=>e>>>r-32|t<<64-r;var TO=(e,t,r)=>e<<r|t>>>32-r,$O=(e,t,r)=>t<<r|e>>>32-r,RO=(e,t,r)=>t<<r-32|e>>>64-r,OO=(e,t,r)=>e<<r-32|t>>>64-r;function On(e,t,r,o){let n=(t>>>0)+(o>>>0);return{h:e+r+(n/4294967296|0)|0,l:n|0}}var CO=(e,t,r)=>(e>>>0)+(t>>>0)+(r>>>0),PO=(e,t,r,o)=>t+r+o+(e/4294967296|0)|0,zO=(e,t,r,o)=>(e>>>0)+(t>>>0)+(r>>>0)+(o>>>0),NO=(e,t,r,o,n)=>t+r+o+n+(e/4294967296|0)|0,DO=(e,t,r,o,n)=>(e>>>0)+(t>>>0)+(r>>>0)+(o>>>0)+(n>>>0),LO=(e,t,r,o,n,i)=>t+r+o+n+i+(e/4294967296|0)|0;var J8=Uint32Array.from([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),ei=new Uint32Array(64);class jO extends sp{constructor(e){super(64,e,8,!1)}get(){let{A:e,B:t,C:r,D:o,E:n,F:i,G:s,H:a}=this;return[e,t,r,o,n,i,s,a]}set(e,t,r,o,n,i,s,a){this.A=e|0,this.B=t|0,this.C=r|0,this.D=o|0,this.E=n|0,this.F=i|0,this.G=s|0,this.H=a|0}process(e,t){for(let d=0;d<16;d++,t+=4)ei[d]=e.getUint32(t,!1);for(let d=16;d<64;d++){let f=ei[d-15],m=ei[d-2],h=on(f,7)^on(f,18)^f>>>3,b=on(m,17)^on(m,19)^m>>>10;ei[d]=b+ei[d-7]+h+ei[d-16]|0}let{A:r,B:o,C:n,D:i,E:s,F:a,G:c,H:u}=this;for(let d=0;d<64;d++){let f=on(s,6)^on(s,11)^on(s,25),m=u+f+IO(s,a,c)+J8[d]+ei[d]|0,b=(on(r,2)^on(r,13)^on(r,22))+kO(r,o,n)|0;u=c,c=a,a=s,s=i+m|0,i=n,n=o,o=r,r=m+b|0}r=r+this.A|0,o=o+this.B|0,n=n+this.C|0,i=i+this.D|0,s=s+this.E|0,a=a+this.F|0,c=c+this.G|0,u=u+this.H|0,this.set(r,o,n,i,s,a,c,u)}roundClean(){vr(ei)}destroy(){this.set(0,0,0,0,0,0,0,0),vr(this.buffer)}}class BO extends jO{A=uo[0]|0;B=uo[1]|0;C=uo[2]|0;D=uo[3]|0;E=uo[4]|0;F=uo[5]|0;G=uo[6]|0;H=uo[7]|0;constructor(){super(32)}}var ZO=(()=>cp(["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))))(),K8=(()=>ZO[0])(),H8=(()=>ZO[1])(),ti=new Uint32Array(80),ri=new Uint32Array(80);class UO extends sp{constructor(e){super(128,e,16,!1)}get(){let{Ah:e,Al:t,Bh:r,Bl:o,Ch:n,Cl:i,Dh:s,Dl:a,Eh:c,El:u,Fh:d,Fl:f,Gh:m,Gl:h,Hh:b,Hl:y}=this;return[e,t,r,o,n,i,s,a,c,u,d,f,m,h,b,y]}set(e,t,r,o,n,i,s,a,c,u,d,f,m,h,b,y){this.Ah=e|0,this.Al=t|0,this.Bh=r|0,this.Bl=o|0,this.Ch=n|0,this.Cl=i|0,this.Dh=s|0,this.Dl=a|0,this.Eh=c|0,this.El=u|0,this.Fh=d|0,this.Fl=f|0,this.Gh=m|0,this.Gl=h|0,this.Hh=b|0,this.Hl=y|0}process(e,t){for(let _=0;_<16;_++,t+=4)ti[_]=e.getUint32(t),ri[_]=e.getUint32(t+=4);for(let _=16;_<80;_++){let A=ti[_-15]|0,O=ri[_-15]|0,L=us(A,O,1)^us(A,O,8)^zb(A,O,7),z=ds(A,O,1)^ds(A,O,8)^Nb(A,O,7),K=ti[_-2]|0,P=ri[_-2]|0,W=us(K,P,19)^Jl(K,P,61)^zb(K,P,6),ee=ds(K,P,19)^Kl(K,P,61)^Nb(K,P,6),B=zO(z,ee,ri[_-7],ri[_-16]),R=NO(B,L,W,ti[_-7],ti[_-16]);ti[_]=R|0,ri[_]=B|0}let{Ah:r,Al:o,Bh:n,Bl:i,Ch:s,Cl:a,Dh:c,Dl:u,Eh:d,El:f,Fh:m,Fl:h,Gh:b,Gl:y,Hh:S,Hl:x}=this;for(let _=0;_<80;_++){let A=us(d,f,14)^us(d,f,18)^Jl(d,f,41),O=ds(d,f,14)^ds(d,f,18)^Kl(d,f,41),L=d&m^~d&b,z=f&h^~f&y,K=DO(x,O,z,H8[_],ri[_]),P=LO(K,S,A,L,K8[_],ti[_]),W=K|0,ee=us(r,o,28)^Jl(r,o,34)^Jl(r,o,39),B=ds(r,o,28)^Kl(r,o,34)^Kl(r,o,39),R=r&n^r&s^n&s,j=o&i^o&a^i&a;S=b|0,x=y|0,b=m|0,y=h|0,m=d|0,h=f|0,{h:d,l:f}=On(c|0,u|0,P|0,W|0),c=s|0,u=a|0,s=n|0,a=i|0,n=r|0,i=o|0;let I=CO(W,B,j);r=PO(I,P,ee,R),o=I|0}({h:r,l:o}=On(this.Ah|0,this.Al|0,r|0,o|0)),{h:n,l:i}=On(this.Bh|0,this.Bl|0,n|0,i|0),{h:s,l:a}=On(this.Ch|0,this.Cl|0,s|0,a|0),{h:c,l:u}=On(this.Dh|0,this.Dl|0,c|0,u|0),{h:d,l:f}=On(this.Eh|0,this.El|0,d|0,f|0),{h:m,l:h}=On(this.Fh|0,this.Fl|0,m|0,h|0),{h:b,l:y}=On(this.Gh|0,this.Gl|0,b|0,y|0),{h:S,l:x}=On(this.Hh|0,this.Hl|0,S|0,x|0),this.set(r,o,n,i,s,a,c,u,d,f,m,h,b,y,S,x)}roundClean(){vr(ti,ri)}destroy(){vr(this.buffer),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}}class qO extends UO{Ah=Ft[0]|0;Al=Ft[1]|0;Bh=Ft[2]|0;Bl=Ft[3]|0;Ch=Ft[4]|0;Cl=Ft[5]|0;Dh=Ft[6]|0;Dl=Ft[7]|0;Eh=Ft[8]|0;El=Ft[9]|0;Fh=Ft[10]|0;Fl=Ft[11]|0;Gh=Ft[12]|0;Gl=Ft[13]|0;Hh=Ft[14]|0;Hl=Ft[15]|0;constructor(){super(48)}}var lp=Sa(()=>new BO,Wo(1));var MO=Sa(()=>new qO,Wo(2));/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */var V8=BigInt(1),FO=BigInt(2),W8=BigInt(3),G8=BigInt(5),Uhe=BigInt(8),JO=BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffed");function Q8(e){let t=BigInt(10),r=BigInt(20),o=BigInt(40),n=BigInt(80),i=JO,a=e*e%i*e%i,c=Fr(a,FO,i)*a%i,u=Fr(c,V8,i)*e%i,d=Fr(u,G8,i)*u%i,f=Fr(d,t,i)*d%i,m=Fr(f,r,i)*f%i,h=Fr(m,o,i)*m%i,b=Fr(h,n,i)*h%i,y=Fr(b,n,i)*h%i,S=Fr(y,t,i)*d%i;return{pow_p_5_8:Fr(S,FO,i)*e%i,b2:a}}function Y8(e){return e[0]&=248,e[31]&=127,e[31]|=64,e}var KO=(()=>{let e=JO;return SO({P:e,type:"x25519",powPminus2:(t)=>{let{pow_p_5_8:r,b2:o}=Q8(t);return lr(Fr(r,W8,e)*o,e)},adjustScalarBytes:Y8})})();/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */var X8=(()=>({p:BigInt("0xffffffff00000001000000000000000000000000ffffffffffffffffffffffff"),n:BigInt("0xffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc632551"),h:BigInt(1),a:BigInt("0xffffffff00000001000000000000000000000000fffffffffffffffffffffffc"),b:BigInt("0x5ac635d8aa3a93e7b3ebbd55769886bc651d06b0cc53b0f63bce3c3e27d2604b"),Gx:BigInt("0x6b17d1f2e12c4247f8bce6e563a440f277037d812deb33a0f4a13945d898c296"),Gy:BigInt("0x4fe342e2fe1a7f9b8ee7eb4a7c0f9e162bce33576b315ececbb6406837bf51f5")}))(),eJ=(()=>({p:BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffeffffffff0000000000000000ffffffff"),n:BigInt("0xffffffffffffffffffffffffffffffffffffffffffffffffc7634d81f4372ddf581a0db248b0a77aecec196accc52973"),h:BigInt(1),a:BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffeffffffff0000000000000000fffffffc"),b:BigInt("0xb3312fa7e23ee7e4988e056be3f82d19181d9c6efe8141120314088f5013875ac656398d8a2ed19d2a85c8edd3ec2aef"),Gx:BigInt("0xaa87ca22be8b05378eb1c71ef320ad746e1d3b628ba79b9859f741e082542a385502f25dbf55296c3a545e3872760ab7"),Gy:BigInt("0x3617de4a96262c6f5d9e98bf9292dc29f8f41dbd289a147ce9da3113b5f0b8c00a60b1ce1d7e819d7a431d7c90ea0e5f")}))();var tJ=Cb(X8),Db=Pb(tJ,lp);var rJ=Cb(eJ),HO=Pb(rJ,MO);function WO(e,t,r){if(Mr(e),r===void 0)r=new Uint8Array(e.outputLen);return _a(e,r,t)}var Lb=Uint8Array.of(0),VO=Uint8Array.of();function GO(e,t,r,o=32){Mr(e),Dt(o,"length");let n=e.outputLen;if(o>255*n)throw Error("Length must be <= 255*HashLen");let i=Math.ceil(o/n);if(r===void 0)r=VO;else Te(r,void 0,"info");let s=new Uint8Array(i*n),a=_a.create(e,t),c=a._cloneInto(),u=new Uint8Array(a.outputLen);for(let d=0;d<i;d++)Lb[0]=d+1,c.update(d===0?VO:u).update(r).update(Lb).digestInto(u),s.set(u,n*d),a._cloneInto(c);return a.destroy(),c.destroy(),vr(u,Lb),s.slice(0,o)}var nJ=BigInt(0),Hl=BigInt(1),oJ=BigInt(2),iJ=BigInt(7),sJ=BigInt(256),aJ=BigInt(113),XO=[],e1=[],t1=[];for(let e=0,t=Hl,r=1,o=0;e<24;e++){[r,o]=[o,(2*r+3*o)%5],XO.push(2*(5*o+r)),e1.push((e+1)*(e+2)/2%64);let n=nJ;for(let i=0;i<7;i++)if(t=(t<<Hl^(t>>iJ)*aJ)%sJ,t&oJ)n^=Hl<<(Hl<<BigInt(i))-Hl;t1.push(n)}var r1=cp(t1,!0),cJ=r1[0],lJ=r1[1],QO=(e,t,r)=>r>32?RO(e,t,r):TO(e,t,r),YO=(e,t,r)=>r>32?OO(e,t,r):$O(e,t,r);function uJ(e,t=24){let r=new Uint32Array(10);for(let o=24-t;o<24;o++){for(let s=0;s<10;s++)r[s]=e[s]^e[s+10]^e[s+20]^e[s+30]^e[s+40];for(let s=0;s<10;s+=2){let a=(s+8)%10,c=(s+2)%10,u=r[c],d=r[c+1],f=QO(u,d,1)^r[a],m=YO(u,d,1)^r[a+1];for(let h=0;h<50;h+=10)e[s+h]^=f,e[s+h+1]^=m}let n=e[2],i=e[3];for(let s=0;s<24;s++){let a=e1[s],c=QO(n,i,a),u=YO(n,i,a),d=XO[s];n=e[d],i=e[d+1],e[d]=c,e[d+1]=u}for(let s=0;s<50;s+=10){for(let a=0;a<10;a++)r[a]=e[s+a];for(let a=0;a<10;a++)e[s+a]^=~r[(a+2)%10]&r[(a+4)%10]}e[0]^=cJ[o],e[1]^=lJ[o]}vr(r)}class up{state;pos=0;posOut=0;finished=!1;state32;destroyed=!1;blockLen;suffix;outputLen;enableXOF=!1;rounds;constructor(e,t,r,o=!1,n=24){if(this.blockLen=e,this.suffix=t,this.outputLen=r,this.enableXOF=o,this.rounds=n,Dt(r,"outputLen"),!(0<e&&e<200))throw Error("only keccak-f1600 function is supported");this.state=new Uint8Array(200),this.state32=Yf(this.state)}clone(){return this._cloneInto()}keccak(){gb(this.state32),uJ(this.state32,this.rounds),gb(this.state32),this.posOut=0,this.pos=0}update(e){co(this),Te(e);let{blockLen:t,state:r}=this,o=e.length;for(let n=0;n<o;){let i=Math.min(t-this.pos,o-n);for(let s=0;s<i;s++)r[this.pos++]^=e[n++];if(this.pos===t)this.keccak()}return this}finish(){if(this.finished)return;this.finished=!0;let{state:e,suffix:t,pos:r,blockLen:o}=this;if(e[r]^=t,(t&128)!==0&&r===o-1)this.keccak();e[o-1]^=128,this.keccak()}writeInto(e){co(this,!1),Te(e),this.finish();let t=this.state,{blockLen:r}=this;for(let o=0,n=e.length;o<n;){if(this.posOut>=r)this.keccak();let i=Math.min(r-this.posOut,n-o);e.set(t.subarray(this.posOut,this.posOut+i),o),this.posOut+=i,o+=i}return e}xofInto(e){if(!this.enableXOF)throw Error("XOF is not possible for this instance");return this.writeInto(e)}xof(e){return Dt(e),this.xofInto(new Uint8Array(e))}digestInto(e){if(Qf(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,vr(this.state)}_cloneInto(e){let{blockLen:t,suffix:r,outputLen:o,rounds:n,enableXOF:i}=this;return e||=new up(t,r,o,i,n),e.state32.set(this.state32),e.pos=this.pos,e.posOut=this.posOut,e.finished=this.finished,e.rounds=n,e.suffix=r,e.outputLen=o,e.enableXOF=i,e.destroyed=this.destroyed,e}}var n1=(e,t,r,o={})=>Sa(()=>new up(t,e,r),o);var fs=n1(6,136,32,Wo(8));var o1=n1(6,72,64,Wo(10));var i1=(e,t,r,o={})=>Sa((n={})=>new up(t,e,n.dkLen===void 0?r:n.dkLen,!0),o),s1=i1(31,168,16,Wo(11)),Cn=i1(31,136,32,Wo(12));function jb(e){if(!Number.isSafeInteger(e)||e<0||e>4294967295)throw Error("wrong u32 integer:"+e);return e}function c1(e){return jb(e),(e&e-1)===0&&e!==0}function Bb(e,t){jb(e);let r=0;for(let o=0;o<t;o++,e>>>=1)r=r<<1|e&1;return r}function l1(e){return jb(e),31-Math.clz32(e)}function a1(e){let t=e.length;if(t<2||!c1(t))throw Error("n must be a power of 2 and greater than 1. Got "+t);let r=l1(t);for(let o=0;o<t;o++){let n=Bb(o,r);if(o<n){let i=e[o];e[o]=e[n],e[n]=i}}return e}var Zb=(e,t)=>{let{N:r,roots:o,dit:n,invertButterflies:i=!1,skipStages:s=0,brp:a=!0}=t,c=l1(r);if(!c1(r))throw Error("FFT: Polynomial size should be power of two");let u=n!==i;return(d)=>{if(d.length!==r)throw Error("FFT: wrong Polynomial length");if(n&&a)a1(d);for(let f=0,m=1;f<c-s;f++){let h=n?f+1+s:c-f,b=1<<h,y=b>>1,S=r>>h;for(let x=0;x<r;x+=b)for(let _=0,A=m++;_<y;_++){let O=i?n?r-A:A:_*S,L=x+_,z=x+_+y,K=o[O],P=d[z],W=d[L];if(u){let ee=e.mul(P,K);d[L]=e.add(W,ee),d[z]=e.sub(W,ee)}else if(i)d[L]=e.add(P,W),d[z]=e.mul(e.sub(P,W),K);else d[L]=e.add(W,P),d[z]=e.mul(e.sub(W,P),K)}}if(!n&&a)a1(d);return d}};/*! noble-post-quantum - MIT License (c) 2024 Paul Miller (paulmillr.com) */var Pn=Vo;function dp(e,t){if(e.length!==t.length)return!1;let r=0;for(let o=0;o<e.length;o++)r|=e[o]^t[o];return r===0}function u1(e){return Uint8Array.from(e)}function ps(e,...t){let r=(n)=>typeof n==="number"?n:n.bytesLen,o=t.reduce((n,i)=>n+r(i),0);return{bytesLen:o,encode:(n)=>{let i=new Uint8Array(o);for(let s=0,a=0;s<t.length;s++){let c=t[s],u=r(c),d=typeof c==="number"?n[s]:c.encode(n[s]);if(Te(d,u,e),i.set(d,a),typeof c!=="number")d.fill(0);a+=u}return i},decode:(n)=>{Te(n,o,e);let i=[];for(let s of t){let a=r(s),c=n.subarray(0,a);i.push(typeof s==="number"?c:s.decode(c)),n=n.subarray(a)}return i}}}function fp(e,t){let r=t*e.bytesLen;return{bytesLen:r,encode:(o)=>{if(o.length!==t)throw Error(`vecCoder.encode: wrong length=${o.length}. Expected: ${t}`);let n=new Uint8Array(r);for(let i=0,s=0;i<o.length;i++){let a=e.encode(o[i]);n.set(a,s),a.fill(0),s+=a.length}return n},decode:(o)=>{Te(o,r);let n=[];for(let i=0;i<o.length;i+=e.bytesLen)n.push(e.decode(o.subarray(i,i+e.bytesLen)));return n}}}function Rt(...e){for(let t of e)if(Array.isArray(t))for(let r of t)r.fill(0);else t.fill(0)}function Ub(e){return(1<<e)-1}var rge=Uint8Array.of();/*! noble-post-quantum - MIT License (c) 2024 Paul Miller (paulmillr.com) */var d1=(e)=>{let{newPoly:t,N:r,Q:o,F:n,ROOT_OF_UNITY:i,brvBits:s,isKyber:a}=e,c=(_,A=o)=>{let O=_%A|0;return(O>=0?O|0:A+O|0)|0},u=(_,A=o)=>{let O=c(_,A)|0;return(O>A>>1?O-A|0:O)|0};function d(){let _=t(r);for(let A=0;A<r;A++){let O=Bb(A,s),L=BigInt(i)**BigInt(O)%BigInt(o);_[A]=Number(L)|0}return _}let f=d(),m={add:(_,A)=>c((_|0)+(A|0))|0,sub:(_,A)=>c((_|0)-(A|0))|0,mul:(_,A)=>c((_|0)*(A|0))|0,inv:(_)=>{throw Error("not implemented")}},h={N:r,roots:f,invertButterflies:!0,skipStages:a?1:0,brp:!1},b=Zb(m,{dit:!1,...h}),y=Zb(m,{dit:!0,...h});return{mod:c,smod:u,nttZetas:f,NTT:{encode:(_)=>b(_),decode:(_)=>{y(_);for(let A=0;A<_.length;A++)_[A]=c(n*_[A]);return _}},bitsCoder:(_,A)=>{let O=Ub(_),L=_*(r/8);return{bytesLen:L,encode:(z)=>{let K=new Uint8Array(L);for(let P=0,W=0,ee=0,B=0;P<z.length;P++){W|=(A.encode(z[P])&O)<<ee,ee+=_;for(;ee>=8;ee-=8,W>>=8)K[B++]=W&Ub(ee)}return K},decode:(z)=>{let K=t(r);for(let P=0,W=0,ee=0,B=0;P<z.length;P++){W|=z[P]<<ee,ee+=8;for(;ee>=_;ee-=_,W>>=_)K[B++]=A.decode(W&O)}return K}}}}},dJ=(e)=>(t,r)=>{if(!r)r=e.blockLen;let o=new Uint8Array(t.length+2);o.set(t);let n=t.length,i=new Uint8Array(r),s=e.create({}),a=0,c=0;return{stats:()=>({calls:a,xofs:c}),get:(u,d)=>(o[n+0]=u,o[n+1]=d,s.destroy(),s=e.create({}).update(o),a++,()=>(c++,s.xofInto(i))),clean:()=>{s.destroy(),Rt(i,o)}}},f1=dJ(s1);/*! noble-post-quantum - MIT License (c) 2024 Paul Miller (paulmillr.com) */var er=256,fo=3329,fJ=3303,pJ=17,{mod:Gl,nttZetas:mJ,NTT:ms,bitsCoder:hJ}=d1({N:er,Q:fo,F:fJ,ROOT_OF_UNITY:pJ,newPoly:(e)=>new Uint16Array(e),brvBits:7,isKyber:!0}),qb={512:{N:er,Q:fo,K:2,ETA1:3,ETA2:2,du:10,dv:4,RBGstrength:128},768:{N:er,Q:fo,K:3,ETA1:2,ETA2:2,du:10,dv:4,RBGstrength:192},1024:{N:er,Q:fo,K:4,ETA1:2,ETA2:2,du:11,dv:5,RBGstrength:256}},gJ=(e)=>{if(e>=12)return{encode:(r)=>r,decode:(r)=>r};let t=2**(e-1);return{encode:(r)=>((r<<e)+fo/2)/fo,decode:(r)=>r*fo+t>>>e}},Vl=(e)=>hJ(e,gJ(e));function hs(e,t){for(let r=0;r<er;r++)e[r]=Gl(e[r]+t[r])}function yJ(e,t){for(let r=0;r<er;r++)e[r]=Gl(e[r]-t[r])}function bJ(e,t,r,o,n){let i=Gl(t*o*n+e*r),s=Gl(e*o+t*r);return{c0:i,c1:s}}function pp(e,t){for(let r=0;r<er/2;r++){let o=mJ[64+(r>>1)];if(r&1)o=-o;let{c0:n,c1:i}=bJ(e[2*r+0],e[2*r+1],t[2*r+0],t[2*r+1],o);e[2*r+0]=n,e[2*r+1]=i}return e}function p1(e){let t=new Uint16Array(er);for(let r=0;r<er;){let o=e();if(o.length%3)throw Error("SampleNTT: unaligned block");for(let n=0;r<er&&n+3<=o.length;n+=3){let i=(o[n+0]>>0|o[n+1]<<8)&4095,s=(o[n+1]>>4|o[n+2]<<4)&4095;if(i<fo)t[r++]=i;if(r<er&&s<fo)t[r++]=s}}return t}function Wl(e,t,r,o){let n=e(o*er/4,t,r),i=new Uint16Array(er),s=Yf(n),a=0;for(let c=0,u=0,d=0,f=0;c<s.length;c++){let m=s[c];for(let h=0;h<32;h++)if(d+=m&1,m>>=1,a+=1,a===o)f=d,d=0;else if(a===2*o)i[u++]=Gl(f-d),d=0,a=0}if(a)throw Error(`sampleCBD: leftover bits: ${a}`);return i}var SJ=(e)=>{let{K:t,PRF:r,XOF:o,HASH512:n,ETA1:i,ETA2:s,du:a,dv:c}=e,u=Vl(1),d=Vl(c),f=Vl(a),m=ps("publicKey",fp(Vl(12),t),32),h=fp(Vl(12),t),b=ps("ciphertext",fp(f,t),d),y=ps("seed",32,32);return{secretCoder:h,lengths:{secretKey:h.bytesLen,publicKey:m.bytesLen,cipherText:b.bytesLen},keygen:(S)=>{Te(S,32,"seed");let x=new Uint8Array(33);x.set(S),x[32]=t;let _=n(x),[A,O]=y.decode(_),L=[],z=[];for(let W=0;W<t;W++)L.push(ms.encode(Wl(r,O,W,i)));let K=o(A);for(let W=0;W<t;W++){let ee=ms.encode(Wl(r,O,t+W,i));for(let B=0;B<t;B++){let R=p1(K.get(B,W));hs(ee,pp(R,L[B]))}z.push(ee)}K.clean();let P={publicKey:m.encode([z,A]),secretKey:h.encode(L)};return Rt(A,O,L,z,x,_),P},encrypt:(S,x,_)=>{let[A,O]=m.decode(S),L=[];for(let B=0;B<t;B++)L.push(ms.encode(Wl(r,_,B,i)));let z=o(O),K=new Uint16Array(er),P=[];for(let B=0;B<t;B++){let R=Wl(r,_,t+B,s),j=new Uint16Array(er);for(let I=0;I<t;I++){let T=p1(z.get(B,I));hs(j,pp(T,L[I]))}hs(R,ms.decode(j)),P.push(R),hs(K,pp(A[B],L[B])),Rt(j)}z.clean();let W=Wl(r,_,2*t,s);hs(W,ms.decode(K));let ee=u.decode(x);return hs(ee,W),Rt(A,L,K,W),b.encode([P,ee])},decrypt:(S,x)=>{let[_,A]=b.decode(S),O=h.decode(x),L=new Uint16Array(er);for(let z=0;z<t;z++)hs(L,pp(O[z],ms.encode(_[z])));return yJ(A,ms.decode(L)),Rt(L,O,_),u.encode(A)}}};function Mb(e){let t=SJ(e),{HASH256:r,HASH512:o,KDF:n}=e,{secretCoder:i,lengths:s}=t,a=ps("secretKey",s.secretKey,s.publicKey,32,32),c=32,u=64;return{info:{type:"ml-kem"},lengths:{...s,seed:64,msg:32,msgRand:32,secretKey:a.bytesLen},keygen:(d=Pn(64))=>{Te(d,64,"seed");let{publicKey:f,secretKey:m}=t.keygen(d.subarray(0,32)),h=r(f),b=a.encode([m,f,h,d.subarray(32)]);return Rt(m,h),{publicKey:f,secretKey:b}},getPublicKey:(d)=>{let[f,m,h,b]=a.decode(d);return Uint8Array.from(m)},encapsulate:(d,f=Pn(32))=>{Te(d,s.publicKey,"publicKey"),Te(f,32,"message");let m=d.subarray(0,384*e.K),h=i.encode(i.decode(u1(m)));if(!dp(h,m))throw Rt(h),Error("ML-KEM.encapsulate: wrong publicKey modulus");Rt(h);let b=o.create().update(f).update(r(d)).digest(),y=t.encrypt(d,f,b.subarray(32,64));return Rt(b.subarray(32)),{cipherText:y,sharedSecret:b.subarray(0,32)}},decapsulate:(d,f)=>{Te(f,a.bytesLen,"secretKey"),Te(d,s.cipherText,"cipherText");let m=a.bytesLen-96,h=m+32,b=r(f.subarray(m/2,h));if(!dp(b,f.subarray(h,h+32)))throw Error("invalid secretKey: hash check failed");let[y,S,x,_]=a.decode(f),A=t.decrypt(d,y),O=o.create().update(A).update(x).digest(),L=O.subarray(0,32),z=t.encrypt(S,A,O.subarray(32,64)),K=dp(d,z),P=n.create({dkLen:32}).update(_).update(d).digest();return Rt(A,z,!K?L:P),K?L:P}}}function vJ(e,t,r){return Cn.create({dkLen:e}).update(t).update(new Uint8Array([r])).digest()}var Fb={HASH256:fs,HASH512:o1,KDF:Cn,XOF:f1,PRF:vJ},pge=Mb({...Fb,...qb[512]}),Ql=Mb({...Fb,...qb[768]}),m1=Mb({...Fb,...qb[1024]});/*! noble-post-quantum - MIT License (c) 2024 Paul Miller (paulmillr.com) */function wJ(e,t=!1){let{lengths:r,keygen:o}=e;if(t){let i=e.Point.Fn;if(!i)throw Error("No Point.Fn");o=(s=Pn(r.seed))=>{Te(s,r.seed,"seed");let a=i.isLE?Qo(s):Go(s),c=i.toBytes(i.create(a));return{secretKey:c,publicKey:e.getPublicKey(c)}}}return{lengths:{secretKey:r.secretKey,publicKey:r.publicKey,seed:r.seed},keygen:o,getPublicKey:(n)=>e.getPublicKey(n)}}function Jb(e,t=!1){let r=wJ(e,t);if(!e.getSharedSecret)throw Error("wrong curve");return{lengths:{...r.lengths,msg:r.lengths.seed,cipherText:r.lengths.publicKey},keygen:r.keygen,getPublicKey:r.getPublicKey,encapsulate(o,n=Pn(e.lengths.seed)){let i=this.keygen(n).secretKey,s=this.decapsulate(o,i),a=e.getPublicKey(i);return Rt(i),{sharedSecret:s,cipherText:a}},decapsulate(o,n){let i=e.getSharedSecret(n,o);return e.lengths.publicKeyHasPrefix?i.subarray(1):i}}}function Yl(e,t){return ps(t,...e.map((r)=>{if(typeof r.lengths[t]!=="number")throw Error("wrong length: "+t);return r.lengths[t]}))}function Kb(e){return(t,r)=>e(t,{dkLen:r})}function xJ(e,t,...r){let o=Yl(r,"seed"),n=Yl(r,"publicKey");if(e===void 0)e=o.bytesLen;Dt(e);function i(s){Te(s,e);let a=o.decode(t(s,o.bytesLen)),c=r.map((f,m)=>f.keygen(a[m])),u=c.map((f)=>f.secretKey),d=c.map((f)=>f.publicKey);return{secretKey:u,publicKey:d}}return{info:{lengths:{seed:e,publicKey:n.bytesLen,secretKey:e}},getPublicKey(s){return this.keygen(s).publicKey},keygen(s=Pn(e)){let{publicKey:a,secretKey:c}=i(s),u=n.encode(a);return Rt(a),Rt(c),{secretKey:s,publicKey:u}},expandDecapsulationKey:i,realSeedLen:e}}function mp(e,t,r,o,...n){let i=xJ(e,r,...n),s=Yl(n,"cipherText"),a=Yl(n,"publicKey"),c=Yl(n,"msg");if(t===void 0)t=c.bytesLen;return Dt(t),{lengths:{...i.info.lengths,msg:t,msgRand:c.bytesLen,cipherText:s.bytesLen},getPublicKey:i.getPublicKey,keygen:i.keygen,encapsulate(u,d=Pn(c.bytesLen)){let f=a.decode(u),m=c.decode(d),h=n.map((x,_)=>x.encapsulate(f[_],m[_])),b=h.map((x)=>x.sharedSecret),y=h.map((x)=>x.cipherText),S={sharedSecret:o(f,y,b),cipherText:s.encode(y)};return Rt(b,y),S},decapsulate(u,d){let f=s.decode(u),{publicKey:m,secretKey:h}=i.expandDecapsulationKey(d),b=n.map((y,S)=>y.decapsulate(f[S],h[S]));return o(m,f,b)}}}function h1(e,t,r,o,n){return Mr(o),Mr(n),mp(32,32,Kb(o),(i,s,a)=>n(Et(a[0],a[1],s[1],i[1],Yo(e))),t,r)}var Ege=h1("QSF-KEM(ML-KEM-768,P-256)-XOF(SHAKE256)-KDF(SHA3-256)",Ql,Jb(Db,!0),Cn,fs),Ige=h1("QSF-KEM(ML-KEM-1024,P-384)-XOF(SHAKE256)-KDF(SHA3-256)",m1,Jb(HO,!0),Cn,fs);function _J(e,t,r,o,n){return Mr(o),Mr(n),mp(32,32,Kb(o),(i,s,a)=>{let c=Et(a[0],a[1],s[0],i[0],s[1],i[1],Yo(e)),u=32,d=Et(Yo("hybrid_prk"),c),f=WO(n,d),m=Et(va(32,2),Yo("shared_secret"),Yo("")),h=GO(n,f,m,32);return Rt(f,m,d,c),h},t,r)}var g1=Jb(KO),kge=_J("KitchenSink-KEM(ML-KEM-768,X25519)-XOF(SHAKE256)-KDF(HKDF-SHA-256)",Ql,g1,Cn,lp),EJ=(()=>mp(32,32,Kb(Cn),(e,t,r)=>fs(Et(r[0],r[1],t[1],e[1],Yo("\\.//^\\"))),Ql,g1))();function IJ(e,t,r,o){let n=e.Point.Fn;if(!n)throw Error("no Point.Fn");function i(s){let a;for(let d=0,f=t;;d=f,f+=t){if(f>s.length)throw Error("rejection sampling failed");if(a=n.fromBytes(s.subarray(d,f),!0),n.isValidNot0(a))break}let c=n.toBytes(n.create(a)),u=e.getPublicKey(c,!1);return{secretKey:c,publicKey:u}}return{lengths:{secretKey:t,publicKey:r,seed:o,msg:o,cipherText:r},keygen(s=Pn(o)){return Te(s,o,"seed"),i(s)},getPublicKey(s){return e.getPublicKey(s,!1)},encapsulate(s,a=Pn(o)){Te(a,o,"rand");let{secretKey:c}=i(a),u=this.decapsulate(s,c),d=e.getPublicKey(c,!1);return Rt(c),{sharedSecret:u,cipherText:d}},decapsulate(s,a){return e.getSharedSecret(a,s).subarray(1)}}}function kJ(e,t,r,o){let{secretKey:n,publicKeyUncompressed:i}=r.lengths;if(!n||!i)throw Error("wrong curve");let s=IJ(r,n,i,o),a=64,c=a+o;return mp(32,32,(u)=>{Te(u,32);let d=Cn(u,{dkLen:c}),f=d.subarray(0,a),m=d.subarray(a,c);return Et(f,m)},(u,d,f)=>fs(Et(f[0],f[1],d[1],u[1],Yo(e))),t,s)}var AJ=(()=>kJ("MLKEM768-P256",Ql,Db,128))();var hp=EJ,y1=AJ;/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */var Ye=(e,t,r)=>Ut(e,t,r),Vb=St,Ia=Bf,Jt=(...e)=>Qy(...e),ka=(e)=>$l(e),Aa=Vy,Ta=(e)=>oo(e),yp=BigInt(0),Hb=BigInt(1);function po(e,t=""){if(typeof e!=="boolean"){let r=t&&`"${t}" `;throw TypeError(r+"expected boolean, got type="+typeof e)}return e}function bp(e){if(typeof e==="bigint"){if(!gp(e))throw RangeError("positive bigint expected, got "+e)}else Vb(e);return e}function zn(e,t=""){if(typeof e!=="number"){let r=t&&`"${t}" `;throw TypeError(r+"expected number, got type="+typeof e)}if(!Number.isSafeInteger(e)){let r=t&&`"${t}" `;throw RangeError(r+"expected safe integer, got "+e)}}function Xl(e){let t=bp(e).toString(16);return t.length&1?"0"+t:t}function b1(e){if(typeof e!=="string")throw TypeError("hex string expected, got "+typeof e);return e===""?yp:BigInt("0x"+e)}function gs(e){return b1(Bf(e))}function sn(e){return b1(Bf(ni(Ut(e)).reverse()))}function Sp(e,t){if(St(t),t===0)throw RangeError("zero length");e=bp(e);let r=e.toString(16);if(r.length>t*2)throw RangeError("number too large");return $l(r.padStart(t*2,"0"))}function eu(e,t){return Sp(e,t).reverse()}function S1(e,t){if(e=Ye(e),t=Ye(t),e.length!==t.length)return!1;let r=0;for(let o=0;o<e.length;o++)r|=e[o]^t[o];return r===0}function ni(e){return Uint8Array.from(Ye(e))}function vp(e){if(typeof e!=="string")throw TypeError("ascii string expected, got "+typeof e);return Uint8Array.from(e,(t,r)=>{let o=t.charCodeAt(0);if(t.length!==1||o>127)throw RangeError(`string contains non-ASCII character "${e[r]}" with code ${o} at position ${r}`);return o})}var gp=(e)=>typeof e==="bigint"&&yp<=e;function TJ(e,t,r){return gp(e)&&gp(t)&&gp(r)&&t<=e&&e<r}function mo(e,t,r,o){if(!TJ(t,r,o))throw RangeError("expected valid "+e+": "+r+" <= n < "+o+", got "+t)}function $a(e){if(e<yp)throw Error("expected non-negative bigint, got "+e);let t;for(t=0;e>yp;e>>=Hb,t+=1);return t}var tu=(e)=>(Hb<<BigInt(e))-Hb;function v1(e,t,r){if(St(e,"hashLen"),St(t,"qByteLen"),typeof r!=="function")throw TypeError("hmacFn must be a function");let o=(S)=>new Uint8Array(S),n=Uint8Array.of(),i=Uint8Array.of(0),s=Uint8Array.of(1),a=1000,c=o(e),u=o(e),d=0,f=()=>{c.fill(1),u.fill(0),d=0},m=(...S)=>r(u,Jt(c,...S)),h=(S=n)=>{if(u=m(i,S),c=m(),S.length===0)return;u=m(s,S),c=m()},b=()=>{if(d++>=a)throw Error("drbg: tried max amount of iterations");let S=0,x=[];while(S<t){c=m();let _=c.slice();x.push(_),S+=c.length}return Jt(...x)};return(S,x)=>{f(),h(S);let _=void 0;while((_=x(b()))===void 0)h();return f(),_}}function Jr(e,t={},r={}){if(Object.prototype.toString.call(e)!=="[object Object]")throw TypeError("expected valid options object");function o(i,s,a){if(!a&&s!=="function"&&!Object.hasOwn(e,i))throw TypeError(`param "${i}" is invalid: expected own property`);let c=e[i];if(a&&c===void 0)return;let u=typeof c;if(u!==s||c===null)throw TypeError(`param "${i}" is invalid: expected ${s}, got ${u}`)}let n=(i,s)=>Object.entries(i).forEach(([a,c])=>o(a,c,s));n(t,!1),n(r,!0)}var Wb=()=>{throw Error("not implemented")};/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */var Kt=BigInt(0),mt=BigInt(1),ys=BigInt(2),E1=BigInt(3),I1=BigInt(4),k1=BigInt(5),$J=BigInt(7),A1=BigInt(8),RJ=BigInt(9),T1=BigInt(16);function it(e,t){if(t<=Kt)throw Error("mod: expected positive modulus, got "+t);let r=e%t;return r>=Kt?r:t+r}function Kr(e,t,r){if(t<Kt)throw Error("pow2: expected non-negative exponent, got "+t);let o=e;while(t-- >Kt)o*=o,o%=r;return o}function w1(e,t){if(e===Kt)throw Error("invert: expected non-zero number");if(t<=Kt)throw Error("invert: expected positive modulus, got "+t);let r=it(e,t),o=t,n=Kt,i=mt,s=mt,a=Kt;while(r!==Kt){let u=o/r,d=o-r*u,f=n-s*u,m=i-a*u;o=r,r=d,n=s,i=a,s=f,a=m}if(o!==mt)throw Error("invert: does not exist");return it(n,t)}function Gb(e,t,r){let o=e;if(!o.eql(o.sqr(t),r))throw Error("Cannot find square root")}function $1(e,t){let r=e,o=(r.ORDER+mt)/I1,n=r.pow(t,o);return Gb(r,n,t),n}function OJ(e,t){let r=e,o=(r.ORDER-k1)/A1,n=r.mul(t,ys),i=r.pow(n,o),s=r.mul(t,i),a=r.mul(r.mul(s,ys),i),c=r.mul(s,r.sub(a,r.ONE));return Gb(r,c,t),c}function CJ(e){let t=wp(e),r=R1(e),o=r(t,t.neg(t.ONE)),n=r(t,o),i=r(t,t.neg(o)),s=(e+$J)/T1;return(a,c)=>{let u=a,d=u.pow(c,s),f=u.mul(d,o),m=u.mul(d,n),h=u.mul(d,i),b=u.eql(u.sqr(f),c),y=u.eql(u.sqr(m),c);d=u.cmov(d,f,b),f=u.cmov(h,m,y);let S=u.eql(u.sqr(f),c),x=u.cmov(d,f,S);return Gb(u,x,c),x}}function R1(e){if(e<E1)throw Error("sqrt is not defined for small field");let t=e-mt,r=0;while(t%ys===Kt)t/=ys,r++;let o=ys,n=wp(e);while(x1(n,o)===1)if(o++>1000)throw Error("Cannot find square root: probably non-prime P");if(r===1)return $1;let i=n.pow(o,t),s=(t+mt)/ys;return function(c,u){let d=c;if(d.is0(u))return u;if(x1(d,u)!==1)throw Error("Cannot find square root");let f=r,m=d.mul(d.ONE,i),h=d.pow(u,t),b=d.pow(u,s);while(!d.eql(h,d.ONE)){if(d.is0(h))return d.ZERO;let y=1,S=d.sqr(h);while(!d.eql(S,d.ONE))if(y++,S=d.sqr(S),y===f)throw Error("Cannot find square root");let x=mt<<BigInt(f-y-1),_=d.pow(m,x);f=y,m=d.sqr(_),h=d.mul(h,m),b=d.mul(b,_)}return b}}function PJ(e){if(e%I1===E1)return $1;if(e%A1===k1)return OJ;if(e%T1===RJ)return CJ(e);return R1(e)}var ho=(e,t)=>(it(e,t)&mt)===mt,zJ=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function Qb(e){let t={ORDER:"bigint",BYTES:"number",BITS:"number"},r=zJ.reduce((o,n)=>(o[n]="function",o),t);if(Jr(e,r),zn(e.BYTES,"BYTES"),zn(e.BITS,"BITS"),e.BYTES<1||e.BITS<1)throw Error("invalid field: expected BYTES/BITS > 0");if(e.ORDER<=mt)throw Error("invalid field: expected ORDER > 1, got "+e.ORDER);return e}function NJ(e,t,r){let o=e;if(r<Kt)throw Error("invalid exponent, negatives unsupported");if(r===Kt)return o.ONE;if(r===mt)return t;let n=o.ONE,i=t;while(r>Kt){if(r&mt)n=o.mul(n,i);i=o.sqr(i),r>>=mt}return n}function ru(e,t,r=!1){let o=e,n=Array(t.length).fill(r?o.ZERO:void 0),i=t.reduce((a,c,u)=>{if(o.is0(c))return a;return n[u]=a,o.mul(a,c)},o.ONE),s=o.inv(i);return t.reduceRight((a,c,u)=>{if(o.is0(c))return a;return n[u]=o.mul(a,n[u]),o.mul(a,c)},s),n}function x1(e,t){let r=e,o=(r.ORDER-mt)/ys,n=r.pow(t,o),i=r.eql(n,r.ONE),s=r.eql(n,r.ZERO),a=r.eql(n,r.neg(r.ONE));if(!i&&!s&&!a)throw Error("invalid Legendre symbol result");return i?1:s?0:-1}function DJ(e,t){if(t!==void 0)Vb(t);if(e<=Kt)throw Error("invalid n length: expected positive n, got "+e);if(t!==void 0&&t<1)throw Error("invalid n length: expected positive bit length, got "+t);let r=$a(e);if(t!==void 0&&t<r)throw Error(`invalid n length: expected bit length (${r}) >= n.length (${t})`);let o=t!==void 0?t:r,n=Math.ceil(o/8);return{nBitLength:o,nByteLength:n}}var _1=new WeakMap;class Yb{ORDER;BITS;BYTES;isLE;ZERO=Kt;ONE=mt;_lengths;_mod;constructor(e,t={}){if(e<=mt)throw Error("invalid field: expected ORDER > 1, got "+e);let r=void 0;if(this.isLE=!1,t!=null&&typeof t==="object"){if(typeof t.BITS==="number")r=t.BITS;if(typeof t.sqrt==="function")Object.defineProperty(this,"sqrt",{value:t.sqrt,enumerable:!0});if(typeof t.isLE==="boolean")this.isLE=t.isLE;if(t.allowedLengths)this._lengths=Object.freeze(t.allowedLengths.slice());if(typeof t.modFromBytes==="boolean")this._mod=t.modFromBytes}let{nBitLength:o,nByteLength:n}=DJ(e,r);if(n>2048)throw Error("invalid field: expected ORDER of <= 2048 bytes");this.ORDER=e,this.BITS=o,this.BYTES=n,Object.freeze(this)}create(e){return it(e,this.ORDER)}isValid(e){if(typeof e!=="bigint")throw TypeError("invalid field element: expected bigint, got "+typeof e);return Kt<=e&&e<this.ORDER}is0(e){return e===Kt}isValidNot0(e){return!this.is0(e)&&this.isValid(e)}isOdd(e){return(e&mt)===mt}neg(e){return it(-e,this.ORDER)}eql(e,t){return e===t}sqr(e){return it(e*e,this.ORDER)}add(e,t){return it(e+t,this.ORDER)}sub(e,t){return it(e-t,this.ORDER)}mul(e,t){return it(e*t,this.ORDER)}pow(e,t){return NJ(this,e,t)}div(e,t){return it(e*w1(t,this.ORDER),this.ORDER)}sqrN(e){return e*e}addN(e,t){return e+t}subN(e,t){return e-t}mulN(e,t){return e*t}inv(e){return w1(e,this.ORDER)}sqrt(e){let t=_1.get(this);if(!t)_1.set(this,t=PJ(this.ORDER));return t(this,e)}toBytes(e){return this.isLE?eu(e,this.BYTES):Sp(e,this.BYTES)}fromBytes(e,t=!1){Ye(e);let{_lengths:r,BYTES:o,isLE:n,ORDER:i,_mod:s}=this;if(r){if(e.length<1||!r.includes(e.length)||e.length>o)throw Error("Field.fromBytes: expected "+r+" bytes, got "+e.length);let c=new Uint8Array(o);c.set(e,n?0:c.length-e.length),e=c}if(e.length!==o)throw Error("Field.fromBytes: expected "+o+" bytes, got "+e.length);let a=n?sn(e):gs(e);if(s)a=it(a,i);if(!t){if(!this.isValid(a))throw Error("invalid field element: outside of range 0..ORDER")}return a}invertBatch(e){return ru(this,e)}cmov(e,t,r){return po(r,"condition"),r?t:e}}Object.freeze(Yb.prototype);function wp(e,t={}){return new Yb(e,t)}function O1(e){if(typeof e!=="bigint")throw Error("field order must be bigint");if(e<=mt)throw Error("field order must be greater than 1");let t=$a(e-mt);return Math.ceil(t/8)}function Xb(e){let t=O1(e);return t+Math.ceil(t/2)}function C1(e,t,r=!1){Ye(e);let o=e.length,n=O1(t),i=Math.max(Xb(t),16);if(o<i||o>1024)throw Error("expected "+i+"-1024 bytes of input, got "+o);let s=r?sn(e):gs(e),a=it(s,t-mt)+mt;return r?eu(a,n):Sp(a,n)}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */var Ra=BigInt(0),bs=BigInt(1);function nu(e,t){let r=t.negate();return e?r:t}function Ss(e,t){let r=ru(e.Fp,t.map((o)=>o.Z));return t.map((o,n)=>e.fromAffine(o.toAffine(r[n])))}function D1(e,t){if(!Number.isSafeInteger(e)||e<=0||e>t)throw Error("invalid window size, expected [1.."+t+"], got W="+e)}function eS(e,t){D1(e,t);let r=Math.ceil(t/e)+1,o=2**(e-1),n=2**e,i=tu(e),s=BigInt(e);return{windows:r,windowSize:o,mask:i,maxNumber:n,shiftBy:s}}function P1(e,t,r){let{windowSize:o,mask:n,maxNumber:i,shiftBy:s}=r,a=Number(e&n),c=e>>s;if(a>o)a-=i,c+=bs;let u=t*o,d=u+Math.abs(a)-1,f=a===0,m=a<0,h=t%2!==0;return{nextN:c,offset:d,isZero:f,isNeg:m,isNegF:h,offsetF:u}}var tS=new WeakMap,L1=new WeakMap;function rS(e){return L1.get(e)||1}function z1(e){if(e!==Ra)throw Error("invalid wNAF")}class ou{BASE;ZERO;Fn;bits;constructor(e,t){this.BASE=e.BASE,this.ZERO=e.ZERO,this.Fn=e.Fn,this.bits=t}_unsafeLadder(e,t,r=this.ZERO){let o=e;while(t>Ra){if(t&bs)r=r.add(o);o=o.double(),t>>=bs}return r}precomputeWindow(e,t){let{windows:r,windowSize:o}=eS(t,this.bits),n=[],i=e,s=i;for(let a=0;a<r;a++){s=i,n.push(s);for(let c=1;c<o;c++)s=s.add(i),n.push(s);i=s.double()}return n}wNAF(e,t,r){if(!this.Fn.isValid(r))throw Error("invalid scalar");let o=this.ZERO,n=this.BASE,i=eS(e,this.bits);for(let s=0;s<i.windows;s++){let{nextN:a,offset:c,isZero:u,isNeg:d,isNegF:f,offsetF:m}=P1(r,s,i);if(r=a,u)n=n.add(nu(f,t[m]));else o=o.add(nu(d,t[c]))}return z1(r),{p:o,f:n}}wNAFUnsafe(e,t,r,o=this.ZERO){let n=eS(e,this.bits);for(let i=0;i<n.windows;i++){if(r===Ra)break;let{nextN:s,offset:a,isZero:c,isNeg:u}=P1(r,i,n);if(r=s,c)continue;else{let d=t[a];o=o.add(u?d.negate():d)}}return z1(r),o}getPrecomputes(e,t,r){let o=tS.get(t);if(!o){if(o=this.precomputeWindow(t,e),e!==1){if(typeof r==="function")o=r(o);tS.set(t,o)}}return o}cached(e,t,r){let o=rS(e);return this.wNAF(o,this.getPrecomputes(o,e,r),t)}unsafe(e,t,r,o){let n=rS(e);if(n===1)return this._unsafeLadder(e,t,o);return this.wNAFUnsafe(n,this.getPrecomputes(n,e,r),t,o)}createCache(e,t){D1(t,this.bits),L1.set(e,t),tS.delete(e)}hasCache(e){return rS(e)!==1}}function j1(e,t,r,o){let n=t,i=e.ZERO,s=e.ZERO;while(r>Ra||o>Ra){if(r&bs)i=i.add(n);if(o&bs)s=s.add(n);n=n.double(),r>>=bs,o>>=bs}return{p1:i,p2:s}}function N1(e,t,r){if(t){if(t.ORDER!==e)throw Error("Field.ORDER must match order: Fp == p, Fn == n");return Qb(t),t}else return wp(e,{isLE:r})}function xp(e,t,r={},o){if(o===void 0)o=e==="edwards";if(!t||typeof t!=="object")throw Error(`expected valid ${e} CURVE object`);for(let c of["p","n","h"]){let u=t[c];if(!(typeof u==="bigint"&&u>Ra))throw Error(`CURVE.${c} must be positive bigint`)}let n=N1(t.p,r.Fp,o),i=N1(t.n,r.Fn,o),a=["Gx","Gy","a",e==="weierstrass"?"b":"d"];for(let c of a)if(!n.isValid(t[c]))throw Error(`CURVE.${c} must be valid field element of CURVE.Fp`);return t=Object.freeze(Object.assign({},t)),{CURVE:t,Fp:n,Fn:i}}function iu(e,t){return function(o){let n=e(o);return{secretKey:n,publicKey:t(n)}}}function su(e,t){if(zn(e),zn(t),t<0||t>4)throw Error("invalid I2OSP length: "+t);if(e<0||e>2**(8*t)-1)throw Error("invalid I2OSP input: "+e);let r=Array.from({length:t}).fill(0);for(let o=t-1;o>=0;o--)r[o]=e&255,e>>>=8;return new Uint8Array(r)}function LJ(e,t){let r=new Uint8Array(e.length);for(let o=0;o<e.length;o++)r[o]=e[o]^t[o];return r}function jJ(e){if(!Aa(e)&&typeof e!=="string")throw Error("DST must be Uint8Array or ascii string");let t=typeof e==="string"?vp(e):e;if(t.length===0)throw Error("DST must be non-empty");return t}function nS(e,t,r,o){if(Ye(e),zn(r),t=jJ(t),t.length>255)t=o(Jt(vp("H2C-OVERSIZE-DST-"),t));let{outputLen:n,blockLen:i}=o,s=Math.ceil(r/n);if(r>65535||s>255)throw Error("expand_message_xmd: invalid lenInBytes");let a=Jt(t,su(t.length,1)),c=new Uint8Array(i),u=su(r,2),d=Array(s),f=o(Jt(c,e,u,su(0,1),a));d[0]=o(Jt(f,su(1,1),a));for(let h=1;h<s;h++){let b=[LJ(f,d[h-1]),su(h+1,1),a];d[h]=o(Jt(...b))}return Jt(...d).slice(0,r)}var B1="HashToScalar-";/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */var Z1=(e,t)=>(e+(e>=0?t:-t)/q1)/t;function BJ(e,t,r){mo("scalar",e,Nn,r);let[[o,n],[i,s]]=t,a=Z1(s*e,r),c=Z1(-n*e,r),u=e-a*o-c*i,d=-a*n-c*s,f=u<Nn,m=d<Nn;if(f)u=-u;if(m)d=-d;let h=tu(Math.ceil($a(r)/2))+oi;if(u<Nn||u>=h||d<Nn||d>=h)throw Error("splitScalar (endomorphism): failed for k");return{k1neg:f,k1:u,k2neg:m,k2:d}}function iS(e){if(!["compact","recovered","der"].includes(e))throw Error('Signature format must be "compact", "recovered", or "der"');return e}function oS(e,t){Jr(e);let r={};for(let o of Object.keys(t))r[o]=e[o]===void 0?t[o]:e[o];if(po(r.lowS,"lowS"),po(r.prehash,"prehash"),r.format!==void 0)iS(r.format);return r}class U1 extends Error{constructor(e=""){super(e)}}var an={Err:U1,_tlv:{encode:(e,t)=>{let{Err:r}=an;if(zn(e,"tag"),e<0||e>255)throw new r("tlv.encode: wrong tag");if(typeof t!=="string")throw TypeError('"data" expected string, got type='+typeof t);if(t.length&1)throw new r("tlv.encode: unpadded data");let o=t.length/2,n=Xl(o);if(n.length/2&128)throw new r("tlv.encode: long form length too big");let i=o>127?Xl(n.length/2|128):"";return Xl(e)+i+n+t},decode(e,t){let{Err:r}=an;t=Ye(t,void 0,"DER data");let o=0;if(e<0||e>255)throw new r("tlv.encode: wrong tag");if(t.length<2||t[o++]!==e)throw new r("tlv.decode: wrong tlv");let n=t[o++],i=!!(n&128),s=0;if(!i)s=n;else{let c=n&127;if(!c)throw new r("tlv.decode(long): indefinite length not supported");if(c>4)throw new r("tlv.decode(long): byte length is too big");let u=t.subarray(o,o+c);if(u.length!==c)throw new r("tlv.decode: length bytes not complete");if(u[0]===0)throw new r("tlv.decode(long): zero leftmost byte");for(let d of u)s=s<<8|d;if(o+=c,s<128)throw new r("tlv.decode(long): not minimal encoding")}let a=t.subarray(o,o+s);if(a.length!==s)throw new r("tlv.decode: wrong value length");return{v:a,l:t.subarray(o+s)}}},_int:{encode(e){let{Err:t}=an;if(bp(e),e<Nn)throw new t("integer: negative integers are not allowed");let r=Xl(e);if(Number.parseInt(r[0],16)&8)r="00"+r;if(r.length&1)throw new t("unexpected DER parsing assertion: unpadded hex");return r},decode(e){let{Err:t}=an;if(e.length<1)throw new t("invalid signature integer: empty");if(e[0]&128)throw new t("invalid signature integer: negative");if(e.length>1&&e[0]===0&&!(e[1]&128))throw new t("invalid signature integer: unnecessary leading zero");return gs(e)}},toSig(e){let{Err:t,_int:r,_tlv:o}=an,n=Ye(e,void 0,"signature"),{v:i,l:s}=o.decode(48,n);if(s.length)throw new t("invalid signature: left bytes after parsing");let{v:a,l:c}=o.decode(2,i),{v:u,l:d}=o.decode(2,c);if(d.length)throw new t("invalid signature: left bytes after parsing");return{r:r.decode(a),s:r.decode(u)}},hexFromSig(e){let{_tlv:t,_int:r}=an,o=t.encode(2,r.encode(e.r)),n=t.encode(2,r.encode(e.s)),i=o+n;return t.encode(48,i)}};Object.freeze(an._tlv);Object.freeze(an._int);Object.freeze(an);var Nn=BigInt(0),oi=BigInt(1),q1=BigInt(2),_p=BigInt(3),ZJ=BigInt(4);function M1(e,t={}){let r=xp("weierstrass",e,t),o=r.Fp,n=r.Fn,i=r.CURVE,{h:s,n:a}=i;Jr(t,{},{allowInfinityPoint:"boolean",clearCofactor:"function",isTorsionFree:"function",fromBytes:"function",toBytes:"function",endo:"object"});let{endo:c,allowInfinityPoint:u}=t;if(c){if(!o.is0(i.a)||typeof c.beta!=="bigint"||!Array.isArray(c.basises))throw Error('invalid endo: expected "beta": bigint and "basises": array')}let d=J1(o,n);function f(){if(!o.isOdd)throw Error("compression is not supported: Field does not have .isOdd()")}function m(B,R,j){if(u&&R.is0())return Uint8Array.of(0);let{x:I,y:T}=R.toAffine(),k=o.toBytes(I);if(po(j,"isCompressed"),j){f();let M=!o.isOdd(T);return Jt(F1(M),k)}else return Jt(Uint8Array.of(4),k,o.toBytes(T))}function h(B){Ye(B,void 0,"Point");let{publicKey:R,publicKeyUncompressed:j}=d,I=B.length,T=B[0],k=B.subarray(1);if(u&&I===1&&T===0)return{x:o.ZERO,y:o.ZERO};if(I===R&&(T===2||T===3)){let M=o.fromBytes(k);if(!o.isValid(M))throw Error("bad point: is not on curve, wrong x");let N=S(M),H;try{H=o.sqrt(N)}catch(ae){let pe=ae instanceof Error?": "+ae.message:"";throw Error("bad point: is not on curve, sqrt error"+pe)}f();let G=o.isOdd(H);if((T&1)===1!==G)H=o.neg(H);return{x:M,y:H}}else if(I===j&&T===4){let M=o.BYTES,N=o.fromBytes(k.subarray(0,M)),H=o.fromBytes(k.subarray(M,M*2));if(!x(N,H))throw Error("bad point: is not on curve");return{x:N,y:H}}else throw Error(`bad point: got length ${I}, expected compressed=${R} or uncompressed=${j}`)}let b=t.toBytes===void 0?m:t.toBytes,y=t.fromBytes===void 0?h:t.fromBytes;function S(B){let R=o.sqr(B),j=o.mul(R,B);return o.add(o.add(j,o.mul(B,i.a)),i.b)}function x(B,R){let j=o.sqr(R),I=S(B);return o.eql(j,I)}if(!x(i.Gx,i.Gy))throw Error("bad curve params: generator point");let _=o.mul(o.pow(i.a,_p),ZJ),A=o.mul(o.sqr(i.b),BigInt(27));if(o.is0(o.add(_,A)))throw Error("bad curve params: a or b");function O(B,R,j=!1){if(!o.isValid(R)||j&&o.is0(R))throw Error(`bad point coordinate ${B}`);return R}function L(B){if(!(B instanceof P))throw Error("Weierstrass Point expected")}function z(B){if(!c||!c.basises)throw Error("no endo");return BJ(B,c.basises,n.ORDER)}function K(B,R,j,I,T){return j=new P(o.mul(j.X,B),j.Y,j.Z),R=nu(I,R),j=nu(T,j),R.add(j)}class P{static BASE=new P(i.Gx,i.Gy,o.ONE);static ZERO=new P(o.ZERO,o.ONE,o.ZERO);static Fp=o;static Fn=n;X;Y;Z;constructor(B,R,j){this.X=O("x",B),this.Y=O("y",R,!0),this.Z=O("z",j),Object.freeze(this)}static CURVE(){return i}static fromAffine(B){let{x:R,y:j}=B||{};if(!B||!o.isValid(R)||!o.isValid(j))throw Error("invalid affine point");if(B instanceof P)throw Error("projective point not allowed");if(o.is0(R)&&o.is0(j))return P.ZERO;return new P(R,j,o.ONE)}static fromBytes(B){let R=P.fromAffine(y(Ye(B,void 0,"point")));return R.assertValidity(),R}static fromHex(B){return P.fromBytes(ka(B))}get x(){return this.toAffine().x}get y(){return this.toAffine().y}precompute(B=8,R=!0){if(ee.createCache(this,B),!R)this.multiply(_p);return this}assertValidity(){let B=this;if(B.is0()){if(t.allowInfinityPoint&&o.is0(B.X)&&o.eql(B.Y,o.ONE)&&o.is0(B.Z))return;throw Error("bad point: ZERO")}let{x:R,y:j}=B.toAffine();if(!o.isValid(R)||!o.isValid(j))throw Error("bad point: x or y not field elements");if(!x(R,j))throw Error("bad point: equation left != right");if(!B.isTorsionFree())throw Error("bad point: not in prime-order subgroup")}hasEvenY(){let{y:B}=this.toAffine();if(!o.isOdd)throw Error("Field doesn't support isOdd");return!o.isOdd(B)}equals(B){L(B);let{X:R,Y:j,Z:I}=this,{X:T,Y:k,Z:M}=B,N=o.eql(o.mul(R,M),o.mul(T,I)),H=o.eql(o.mul(j,M),o.mul(k,I));return N&&H}negate(){return new P(this.X,o.neg(this.Y),this.Z)}double(){let{a:B,b:R}=i,j=o.mul(R,_p),{X:I,Y:T,Z:k}=this,M=o.ZERO,N=o.ZERO,H=o.ZERO,G=o.mul(I,I),re=o.mul(T,T),ae=o.mul(k,k),pe=o.mul(I,T);return pe=o.add(pe,pe),H=o.mul(I,k),H=o.add(H,H),M=o.mul(B,H),N=o.mul(j,ae),N=o.add(M,N),M=o.sub(re,N),N=o.add(re,N),N=o.mul(M,N),M=o.mul(pe,M),H=o.mul(j,H),ae=o.mul(B,ae),pe=o.sub(G,ae),pe=o.mul(B,pe),pe=o.add(pe,H),H=o.add(G,G),G=o.add(H,G),G=o.add(G,ae),G=o.mul(G,pe),N=o.add(N,G),ae=o.mul(T,k),ae=o.add(ae,ae),G=o.mul(ae,pe),M=o.sub(M,G),H=o.mul(ae,re),H=o.add(H,H),H=o.add(H,H),new P(M,N,H)}add(B){L(B);let{X:R,Y:j,Z:I}=this,{X:T,Y:k,Z:M}=B,N=o.ZERO,H=o.ZERO,G=o.ZERO,re=i.a,ae=o.mul(i.b,_p),pe=o.mul(R,T),be=o.mul(j,k),ve=o.mul(I,M),ke=o.add(R,j),Ie=o.add(T,k);ke=o.mul(ke,Ie),Ie=o.add(pe,be),ke=o.sub(ke,Ie),Ie=o.add(R,I);let we=o.add(T,M);return Ie=o.mul(Ie,we),we=o.add(pe,ve),Ie=o.sub(Ie,we),we=o.add(j,I),N=o.add(k,M),we=o.mul(we,N),N=o.add(be,ve),we=o.sub(we,N),G=o.mul(re,Ie),N=o.mul(ae,ve),G=o.add(N,G),N=o.sub(be,G),G=o.add(be,G),H=o.mul(N,G),be=o.add(pe,pe),be=o.add(be,pe),ve=o.mul(re,ve),Ie=o.mul(ae,Ie),be=o.add(be,ve),ve=o.sub(pe,ve),ve=o.mul(re,ve),Ie=o.add(Ie,ve),pe=o.mul(be,Ie),H=o.add(H,pe),pe=o.mul(we,Ie),N=o.mul(ke,N),N=o.sub(N,pe),pe=o.mul(ke,be),G=o.mul(we,G),G=o.add(G,pe),new P(N,H,G)}subtract(B){return L(B),this.add(B.negate())}is0(){return this.equals(P.ZERO)}multiply(B){let{endo:R}=t;if(!n.isValidNot0(B))throw RangeError("invalid scalar: out of range");let j,I,T=(k)=>ee.cached(this,k,(M)=>Ss(P,M));if(R){let{k1neg:k,k1:M,k2neg:N,k2:H}=z(B),{p:G,f:re}=T(M),{p:ae,f:pe}=T(H);I=re.add(pe),j=K(R.beta,G,ae,k,N)}else{let{p:k,f:M}=T(B);j=k,I=M}return Ss(P,[j,I])[0]}multiplyUnsafe(B){let{endo:R}=t,j=this,I=B;if(!n.isValid(I))throw RangeError("invalid scalar: out of range");if(I===Nn||j.is0())return P.ZERO;if(I===oi)return j;if(ee.hasCache(this))return this.multiply(I);if(R){let{k1neg:T,k1:k,k2neg:M,k2:N}=z(I),{p1:H,p2:G}=j1(P,j,k,N);return K(R.beta,H,G,T,M)}else return ee.unsafe(j,I)}toAffine(B){let R=this,j=B,{X:I,Y:T,Z:k}=R;if(o.eql(k,o.ONE))return{x:I,y:T};let M=R.is0();if(j==null)j=M?o.ONE:o.inv(k);let N=o.mul(I,j),H=o.mul(T,j),G=o.mul(k,j);if(M)return{x:o.ZERO,y:o.ZERO};if(!o.eql(G,o.ONE))throw Error("invZ was invalid");return{x:N,y:H}}isTorsionFree(){let{isTorsionFree:B}=t;if(s===oi)return!0;if(B)return B(P,this);return ee.unsafe(this,a).is0()}clearCofactor(){let{clearCofactor:B}=t;if(s===oi)return this;if(B)return B(P,this);return this.multiplyUnsafe(s)}isSmallOrder(){if(s===oi)return this.is0();return this.clearCofactor().is0()}toBytes(B=!0){return po(B,"isCompressed"),this.assertValidity(),b(P,this,B)}toHex(B=!0){return Ia(this.toBytes(B))}toString(){return`<Point ${this.is0()?"ZERO":this.toHex()}>`}}let W=n.BITS,ee=new ou(P,t.endo?Math.ceil(W/2):W);if(W>=8)P.BASE.precompute(8);return Object.freeze(P.prototype),Object.freeze(P),P}function F1(e){return Uint8Array.of(e?2:3)}function J1(e,t){return{secretKey:t.BYTES,publicKey:1+e.BYTES,publicKeyUncompressed:1+2*e.BYTES,publicKeyHasPrefix:!0,signature:2*t.BYTES}}function UJ(e,t={}){let{Fn:r}=e,o=t.randomBytes===void 0?Ta:t.randomBytes,n=Object.assign(J1(e.Fp,r),{seed:Math.max(Xb(r.ORDER),16)});function i(h){try{let b=r.fromBytes(h);return r.isValidNot0(b)}catch(b){return!1}}function s(h,b){let{publicKey:y,publicKeyUncompressed:S}=n;try{let x=h.length;if(b===!0&&x!==y)return!1;if(b===!1&&x!==S)return!1;return!!e.fromBytes(h)}catch(x){return!1}}function a(h){return h=h===void 0?o(n.seed):h,C1(Ye(h,n.seed,"seed"),r.ORDER)}function c(h,b=!0){return e.BASE.multiply(r.fromBytes(h)).toBytes(b)}function u(h){let{secretKey:b,publicKey:y,publicKeyUncompressed:S}=n,x=r._lengths;if(!Aa(h))return;let _=Ye(h,void 0,"key").length,A=_===y||_===S,O=_===b||!!x?.includes(_);if(A&&O)return;return A}function d(h,b,y=!0){if(u(h)===!0)throw Error("first arg must be private key");if(u(b)===!1)throw Error("second arg must be public key");let S=r.fromBytes(h);return e.fromBytes(b).multiply(S).toBytes(y)}let f={isValidSecretKey:i,isValidPublicKey:s,randomSecretKey:a},m=iu(a,c);return Object.freeze(f),Object.freeze(n),Object.freeze({getPublicKey:c,getSharedSecret:d,keygen:m,Point:e,utils:f,lengths:n})}function K1(e,t,r={}){let o=t;no(o),Jr(r,{},{hmac:"function",lowS:"boolean",randomBytes:"function",bits2int:"function",bits2int_modN:"function"}),r=Object.assign({},r);let n=r.randomBytes===void 0?Ta:r.randomBytes,i=r.hmac===void 0?(T,k)=>Tn(o,T,k):r.hmac,{Fp:s,Fn:a}=e,{ORDER:c,BITS:u}=a,{keygen:d,getPublicKey:f,getSharedSecret:m,utils:h,lengths:b}=UJ(e,r),y={prehash:!0,lowS:typeof r.lowS==="boolean"?r.lowS:!0,format:"compact",extraEntropy:!1},S=c*q1+oi<s.ORDER;function x(T){let k=c>>oi;return T>k}function _(T,k){if(!a.isValidNot0(k))throw Error(`invalid signature ${T}: out of range 1..Point.Fn.ORDER`);return k}function A(){if(S)throw Error('"recovered" sig type is not supported for cofactor >2 curves')}function O(T,k){iS(k);let M=b.signature,N=k==="compact"?M:k==="recovered"?M+1:void 0;return Ye(T,N)}class L{r;s;recovery;constructor(T,k,M){if(this.r=_("r",T),this.s=_("s",k),M!=null){if(A(),![0,1,2,3].includes(M))throw Error("invalid recovery id");this.recovery=M}Object.freeze(this)}static fromBytes(T,k=y.format){O(T,k);let M;if(k==="der"){let{r:re,s:ae}=an.toSig(Ye(T));return new L(re,ae)}if(k==="recovered")M=T[0],k="compact",T=T.subarray(1);let N=b.signature/2,H=T.subarray(0,N),G=T.subarray(N,N*2);return new L(a.fromBytes(H),a.fromBytes(G),M)}static fromHex(T,k){return this.fromBytes(ka(T),k)}assertRecovery(){let{recovery:T}=this;if(T==null)throw Error("invalid recovery id: must be present");return T}addRecoveryBit(T){return new L(this.r,this.s,T)}recoverPublicKey(T){let{r:k,s:M}=this,N=this.assertRecovery(),H=N===2||N===3?k+c:k;if(!s.isValid(H))throw Error("invalid recovery id: sig.r+curve.n != R.x");let G=s.toBytes(H),re=e.fromBytes(Jt(F1((N&1)===0),G)),ae=a.inv(H),pe=K(Ye(T,void 0,"msgHash")),be=a.create(-pe*ae),ve=a.create(M*ae),ke=e.BASE.multiplyUnsafe(be).add(re.multiplyUnsafe(ve));if(ke.is0())throw Error("invalid recovery: point at infinify");return ke.assertValidity(),ke}hasHighS(){return x(this.s)}toBytes(T=y.format){if(iS(T),T==="der")return ka(an.hexFromSig(this));let{r:k,s:M}=this,N=a.toBytes(k),H=a.toBytes(M);if(T==="recovered")return A(),Jt(Uint8Array.of(this.assertRecovery()),N,H);return Jt(N,H)}toHex(T){return Ia(this.toBytes(T))}}Object.freeze(L.prototype),Object.freeze(L);let z=r.bits2int===void 0?function(k){if(k.length>8192)throw Error("input is too large");let M=gs(k),N=k.length*8-u;return N>0?M>>BigInt(N):M}:r.bits2int,K=r.bits2int_modN===void 0?function(k){return a.create(z(k))}:r.bits2int_modN,P=tu(u);function W(T){return mo("num < 2^"+u,T,Nn,P),a.toBytes(T)}function ee(T,k){return Ye(T,void 0,"message"),k?Ye(o(T),void 0,"prehashed message"):T}function B(T,k,M){let{lowS:N,prehash:H,extraEntropy:G}=oS(M,y);T=ee(T,H);let re=K(T),ae=a.fromBytes(k);if(!a.isValidNot0(ae))throw Error("invalid private key");let pe=[W(ae),W(re)];if(G!=null&&G!==!1){let Ie=G===!0?n(b.secretKey):G;pe.push(Ye(Ie,void 0,"extraEntropy"))}let be=Jt(...pe),ve=re;function ke(Ie){let we=z(Ie);if(!a.isValidNot0(we))return;let Ue=a.inv(we),De=e.BASE.multiply(we).toAffine(),Qe=a.create(De.x);if(Qe===Nn)return;let bt=a.create(Ue*a.create(ve+Qe*ae));if(bt===Nn)return;let Tt=(De.x===Qe?0:2)|Number(De.y&oi),Nt=bt;if(N&&x(bt))Nt=a.neg(bt),Tt^=1;return new L(Qe,Nt,S?void 0:Tt)}return{seed:be,k2sig:ke}}function R(T,k,M={}){let{seed:N,k2sig:H}=B(T,k,M);return v1(o.outputLen,a.BYTES,i)(N,H).toBytes(M.format)}function j(T,k,M,N={}){let{lowS:H,prehash:G,format:re}=oS(N,y);if(M=Ye(M,void 0,"publicKey"),k=ee(k,G),!Aa(T)){let ae=T instanceof L?", use sig.toBytes()":"";throw Error("verify expects Uint8Array signature"+ae)}O(T,re);try{let ae=L.fromBytes(T,re),pe=e.fromBytes(M);if(H&&ae.hasHighS())return!1;let{r:be,s:ve}=ae,ke=K(k),Ie=a.inv(ve),we=a.create(ke*Ie),Ue=a.create(be*Ie),De=e.BASE.multiplyUnsafe(we).add(pe.multiplyUnsafe(Ue));if(De.is0())return!1;return a.create(De.x)===be}catch(ae){return!1}}function I(T,k,M={}){let{prehash:N}=oS(M,y);return k=ee(k,N),L.fromBytes(T,"recovered").recoverPublicKey(k).toBytes()}return Object.freeze({keygen:d,getPublicKey:f,getSharedSecret:m,utils:h,lengths:b,Point:e,sign:R,verify:j,recoverPublicKey:I,Signature:L,hash:o})}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */var qJ=(()=>({p:BigInt("0xffffffff00000001000000000000000000000000ffffffffffffffffffffffff"),n:BigInt("0xffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc632551"),h:BigInt(1),a:BigInt("0xffffffff00000001000000000000000000000000fffffffffffffffffffffffc"),b:BigInt("0x5ac635d8aa3a93e7b3ebbd55769886bc651d06b0cc53b0f63bce3c3e27d2604b"),Gx:BigInt("0x6b17d1f2e12c4247f8bce6e563a440f277037d812deb33a0f4a13945d898c296"),Gy:BigInt("0x4fe342e2fe1a7f9b8ee7eb4a7c0f9e162bce33576b315ececbb6406837bf51f5")}))();var MJ=M1(qJ),Oa=K1(MJ,vt);/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */var ii=BigInt(0),wr=BigInt(1),sS=BigInt(2),FJ=BigInt(8);function JJ(e,t,r,o){let n=e.sqr(r),i=e.sqr(o),s=e.add(e.mul(t.a,n),i),a=e.add(e.ONE,e.mul(t.d,e.mul(n,i)));return e.eql(s,a)}function H1(e,t={}){let r=t,o=xp("edwards",e,r,r.FpFnLE),{Fp:n,Fn:i}=o,s=o.CURVE,{h:a}=s;Jr(r,{},{uvRatio:"function"});let c=sS<<BigInt(i.BYTES*8)-wr,u=(y)=>n.create(y),d=r.uvRatio===void 0?(y,S)=>{try{return{isValid:!0,value:n.sqrt(n.div(y,S))}}catch(x){return{isValid:!1,value:ii}}}:r.uvRatio;if(!JJ(n,s,s.Gx,s.Gy))throw Error("bad curve params: generator point");function f(y,S,x=!1){let _=x?wr:ii;return mo("coordinate "+y,S,_,c),S}function m(y){if(!(y instanceof h))throw Error("EdwardsPoint expected")}class h{static BASE=new h(s.Gx,s.Gy,wr,u(s.Gx*s.Gy));static ZERO=new h(ii,wr,wr,ii);static Fp=n;static Fn=i;X;Y;Z;T;constructor(y,S,x,_){this.X=f("x",y),this.Y=f("y",S),this.Z=f("z",x,!0),this.T=f("t",_),Object.freeze(this)}static CURVE(){return s}static fromAffine(y){if(y instanceof h)throw Error("extended point not allowed");let{x:S,y:x}=y||{};return f("x",S),f("y",x),new h(S,x,wr,u(S*x))}static fromBytes(y,S=!1){let x=n.BYTES,{a:_,d:A}=s;y=ni(Ye(y,x,"point")),po(S,"zip215");let O=ni(y),L=y[x-1];O[x-1]=L&-129;let z=sn(O),K=S?c:n.ORDER;mo("point.y",z,ii,K);let P=u(z*z),W=u(P-wr),ee=u(A*P-_),{isValid:B,value:R}=d(W,ee);if(!B)throw Error("bad point: invalid y coordinate");let j=(R&wr)===wr,I=(L&128)!==0;if(!S&&R===ii&&I)throw Error("bad point: x=0 and x_0=1");if(I!==j)R=u(-R);return h.fromAffine({x:R,y:z})}static fromHex(y,S=!1){return h.fromBytes(ka(y),S)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}precompute(y=8,S=!0){if(b.createCache(this,y),!S)this.multiply(sS);return this}assertValidity(){let y=this,{a:S,d:x}=s;if(y.is0())throw Error("bad point: ZERO");let{X:_,Y:A,Z:O,T:L}=y,z=u(_*_),K=u(A*A),P=u(O*O),W=u(P*P),ee=u(z*S),B=u(P*u(ee+K)),R=u(W+u(x*u(z*K)));if(B!==R)throw Error("bad point: equation left != right (1)");let j=u(_*A),I=u(O*L);if(j!==I)throw Error("bad point: equation left != right (2)")}equals(y){m(y);let{X:S,Y:x,Z:_}=this,{X:A,Y:O,Z:L}=y,z=u(S*L),K=u(A*_),P=u(x*L),W=u(O*_);return z===K&&P===W}is0(){return this.equals(h.ZERO)}negate(){return new h(u(-this.X),this.Y,this.Z,u(-this.T))}double(){let{a:y}=s,{X:S,Y:x,Z:_}=this,A=u(S*S),O=u(x*x),L=u(sS*u(_*_)),z=u(y*A),K=S+x,P=u(u(K*K)-A-O),W=z+O,ee=W-L,B=z-O,R=u(P*ee),j=u(W*B),I=u(P*B),T=u(ee*W);return new h(R,j,T,I)}add(y){m(y);let{a:S,d:x}=s,{X:_,Y:A,Z:O,T:L}=this,{X:z,Y:K,Z:P,T:W}=y,ee=u(_*z),B=u(A*K),R=u(L*x*W),j=u(O*P),I=u((_+A)*(z+K)-ee-B),T=j-R,k=j+R,M=u(B-S*ee),N=u(I*T),H=u(k*M),G=u(I*M),re=u(T*k);return new h(N,H,re,G)}subtract(y){return m(y),this.add(y.negate())}multiply(y){if(!i.isValidNot0(y))throw RangeError("invalid scalar: expected 1 <= sc < curve.n");let{p:S,f:x}=b.cached(this,y,(_)=>Ss(h,_));return Ss(h,[S,x])[0]}multiplyUnsafe(y){if(!i.isValid(y))throw RangeError("invalid scalar: expected 0 <= sc < curve.n");if(y===ii)return h.ZERO;if(this.is0()||y===wr)return this;return b.unsafe(this,y,(S)=>Ss(h,S))}isSmallOrder(){return this.clearCofactor().is0()}isTorsionFree(){return b.unsafe(this,s.n).is0()}toAffine(y){let S=this,x=y,{X:_,Y:A,Z:O}=S,L=S.is0();if(x==null)x=L?FJ:n.inv(O);let z=u(_*x),K=u(A*x),P=n.mul(O,x);if(L)return{x:ii,y:wr};if(P!==wr)throw Error("invZ was invalid");return{x:z,y:K}}clearCofactor(){if(a===wr)return this;return this.multiplyUnsafe(a)}toBytes(){let{x:y,y:S}=this.toAffine(),x=n.toBytes(S);return x[x.length-1]|=y&wr?128:0,x}toHex(){return Ia(this.toBytes())}toString(){return`<Point ${this.is0()?"ZERO":this.toHex()}>`}}let b=new ou(h,i.BITS);if(i.BITS>=8)h.BASE.precompute(8);return Object.freeze(h.prototype),Object.freeze(h),h}class aS{static BASE;static ZERO;static Fp;static Fn;ep;constructor(e){this.ep=e}static fromBytes(e){Wb()}static fromHex(e){Wb()}get x(){return this.toAffine().x}get y(){return this.toAffine().y}clearCofactor(){return this}assertValidity(){this.ep.assertValidity()}toAffine(e){return this.ep.toAffine(e)}toHex(){return Ia(this.toBytes())}toString(){return this.toHex()}isTorsionFree(){return!0}isSmallOrder(){return!1}add(e){return this.assertSame(e),this.init(this.ep.add(e.ep))}subtract(e){return this.assertSame(e),this.init(this.ep.subtract(e.ep))}multiply(e){return this.init(this.ep.multiply(e))}multiplyUnsafe(e){return this.init(this.ep.multiplyUnsafe(e))}double(){return this.init(this.ep.double())}negate(){return this.init(this.ep.negate())}precompute(e,t){return this.ep.precompute(e,t),this}}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */var au=BigInt(0),Ca=BigInt(1),Ep=BigInt(2);function KJ(e){return Jr(e,{P:"bigint",type:"string",adjustScalarBytes:"function",powPminus2:"function"},{randomBytes:"function"}),Object.freeze({...e})}function V1(e){let t=KJ(e),{P:r,type:o,adjustScalarBytes:n,powPminus2:i,randomBytes:s}=t,a=o==="x25519";if(!a&&o!=="x448")throw Error("invalid type");let c=s===void 0?Ta:s,u=a?255:448,d=a?32:56,f=a?BigInt(9):BigInt(5),m=a?BigInt(121665):BigInt(39081),h=a?Ep**BigInt(254):Ep**BigInt(447),b=a?BigInt(8)*Ep**BigInt(251)-Ca:BigInt(4)*Ep**BigInt(445)-Ca,y=h+b+Ca,S=(I)=>it(I,r),x=_(f);function _(I){return eu(S(I),d)}function A(I){let T=ni(Ye(I,d,"uCoordinate"));if(a)T[31]&=127;return S(sn(T))}function O(I){return sn(n(ni(Ye(I,d,"scalar"))))}function L(I,T){let k=ee(A(T),O(I));if(k===au)throw Error("invalid private or public key received");return _(k)}function z(I){return L(I,x)}let K=z,P=L;function W(I,T,k){let M=S(I*(T-k));return T=S(T-M),k=S(k+M),{x_2:T,x_3:k}}function ee(I,T){mo("u",I,au,r),mo("scalar",T,h,y);let k=T,M=I,N=Ca,H=au,G=I,re=Ca,ae=au;for(let be=BigInt(u-1);be>=au;be--){let ve=k>>be&Ca;ae^=ve,{x_2:N,x_3:G}=W(ae,N,G),{x_2:H,x_3:re}=W(ae,H,re),ae=ve;let ke=N+H,Ie=S(ke*ke),we=N-H,Ue=S(we*we),De=Ie-Ue,Qe=G+re,bt=G-re,Tt=S(bt*ke),Nt=S(Qe*we),lt=Tt+Nt,$r=Tt-Nt;G=S(lt*lt),re=S(M*S($r*$r)),N=S(Ie*Ue),H=S(De*(Ie+S(m*De)))}({x_2:N,x_3:G}=W(ae,N,G)),{x_2:H,x_3:re}=W(ae,H,re);let pe=i(H);return S(N*pe)}let B={secretKey:d,publicKey:d,seed:d},R=(I)=>(I=I===void 0?c(d):I,Ye(I,B.seed,"seed"),I),j={randomSecretKey:R};return Object.freeze(B),Object.freeze(j),Object.freeze({keygen:iu(R,K),getSharedSecret:P,getPublicKey:K,scalarMult:L,scalarMultBase:z,utils:j,GuBytes:x.slice(),lengths:B})}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */var HJ=BigInt(0),go=BigInt(1),W1=BigInt(2),VJ=BigInt(3),WJ=BigInt(5),GJ=BigInt(8),ws=BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffed"),dS=(()=>({p:ws,n:BigInt("0x1000000000000000000000000000000014def9dea2f79cd65812631a5cf5d3ed"),h:GJ,a:BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffec"),d:BigInt("0x52036cee2b6ffe738cc740797779e89800700a4d4141d8ab75eb4dca135978a3"),Gx:BigInt("0x216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51a"),Gy:BigInt("0x6666666666666666666666666666666666666666666666666666666666666658")}))();function Y1(e){let t=BigInt(10),r=BigInt(20),o=BigInt(40),n=BigInt(80),i=ws,a=e*e%i*e%i,c=Kr(a,W1,i)*a%i,u=Kr(c,go,i)*e%i,d=Kr(u,WJ,i)*u%i,f=Kr(d,t,i)*d%i,m=Kr(f,r,i)*f%i,h=Kr(m,o,i)*m%i,b=Kr(h,n,i)*h%i,y=Kr(b,n,i)*h%i,S=Kr(y,t,i)*d%i;return{pow_p_5_8:Kr(S,W1,i)*e%i,b2:a}}function QJ(e){return e[0]&=248,e[31]&=127,e[31]|=64,e}var cS=BigInt("19681161376707505956807079304988542015446066515923890162744021073123829784752");function fS(e,t){let r=ws,o=it(t*t*t,r),n=it(o*o*t,r),i=Y1(e*n).pow_p_5_8,s=it(e*o*i,r),a=it(t*s*s,r),c=s,u=it(s*cS,r),d=a===e,f=a===it(-e,r),m=a===it(-e*cS,r);if(d)s=c;if(f||m)s=u;if(ho(s,r))s=it(-s,r);return{isValid:d||f,value:s}}var vs=H1(dS,{uvRatio:fS}),si=(()=>vs.Fp)(),X1=(()=>vs.Fn)();var Ip=(()=>{let e=ws;return V1({P:e,type:"x25519",powPminus2:(t)=>{let{pow_p_5_8:r,b2:o}=Y1(t);return it(Kr(r,VJ,e)*o,e)},adjustScalarBytes:QJ})})();var lS=cS,YJ=BigInt("25063068953384623474111414158702152701244531502492656460079210482610430750235"),XJ=BigInt("54469307008909316920995813868745141605393597292927456921205312896311721017578"),eK=BigInt("1159843021668779879193775521855586647937357759715417654439879720876111806838"),tK=BigInt("40440834346308536858101042469323190826248399146238708352240133220865137265952"),G1=(e)=>fS(go,e),rK=BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"),uS=(e)=>si.create(sn(e)&rK);function Q1(e){let{d:t}=dS,r=ws,o=(x)=>si.create(x),n=o(lS*e*e),i=o((n+go)*eK),s=BigInt(-1),a=o((s-t*n)*o(n+t)),{isValid:c,value:u}=fS(i,a),d=o(u*e);if(!ho(d,r))d=o(-d);if(!c)u=d;if(!c)s=n;let f=o(s*(n-go)*tK-a),m=u*u,h=o((u+u)*a),b=o(f*YJ),y=o(go-m),S=o(go+m);return new vs(o(h*S),o(y*b),o(b*S),o(h*y))}class dr extends aS{static BASE=(()=>new dr(vs.BASE))();static ZERO=(()=>new dr(vs.ZERO))();static Fp=(()=>si)();static Fn=(()=>X1)();constructor(e){super(e)}static fromAffine(e){return new dr(vs.fromAffine(e))}assertSame(e){if(!(e instanceof dr))throw Error("RistrettoPoint expected")}init(e){return new dr(e)}static fromBytes(e){Ut(e,32);let{a:t,d:r}=dS,o=ws,n=(A)=>si.create(A),i=uS(e);if(!S1(si.toBytes(i),e)||ho(i,o))throw Error("invalid ristretto255 encoding 1");let s=n(i*i),a=n(go+t*s),c=n(go-t*s),u=n(a*a),d=n(c*c),f=n(t*r*u-d),{isValid:m,value:h}=G1(n(f*d)),b=n(h*c),y=n(h*b*f),S=n((i+i)*b);if(ho(S,o))S=n(-S);let x=n(a*y),_=n(S*x);if(!m||ho(_,o)||x===HJ)throw Error("invalid ristretto255 encoding 2");return new dr(new vs(S,x,go,_))}static fromHex(e){return dr.fromBytes($l(e))}toBytes(){let{X:e,Y:t,Z:r,T:o}=this.ep,n=ws,i=(y)=>si.create(y),s=i(i(r+t)*i(r-t)),a=i(e*t),c=i(a*a),{value:u}=G1(i(s*c)),d=i(u*s),f=i(u*a),m=i(d*f*o),h;if(ho(o*m,n)){let y=i(t*lS),S=i(e*lS);e=y,t=S,h=i(d*XJ)}else h=f;if(ho(e*m,n))t=i(-t);let b=i((r-t)*h);if(ho(b,n))b=i(-b);return si.toBytes(b)}equals(e){this.assertSame(e);let{X:t,Y:r}=this.ep,{X:o,Y:n}=e.ep,i=(c)=>si.create(c),s=i(t*n)===i(r*o),a=i(r*n)===i(t*o);return s||a}is0(){return this.equals(dr.ZERO)}}Object.freeze(dr.BASE);Object.freeze(dr.ZERO);Object.freeze(dr.prototype);Object.freeze(dr);var nK=Object.freeze({Point:dr,hashToCurve(e,t){let r=t?.DST===void 0?"ristretto255_XMD:SHA-512_R255MAP_RO_":t.DST,o=nS(e,r,64,Mf);return nK.deriveToCurve(o)},hashToScalar(e,t={DST:B1}){let r=nS(e,t.DST,64,Mf);return X1.create(sn(r))},deriveToCurve(e){Ut(e,64);let t=uS(e.subarray(0,32)),r=Q1(t),o=uS(e.subarray(32,64)),n=Q1(o);return new dr(r.add(n))}});var eC=!1,oK=!1;async function tC(e,t){if(oK)return await t();try{return await e()}catch(r){if(r instanceof ReferenceError||r instanceof DOMException&&r.name==="NotSupportedError")return await t();else throw r}}async function kp(e,t){return await tC(async()=>{let r=pS(e)?e:await sK(e),o=await crypto.subtle.importKey("raw",aK(t),{name:"X25519"},eC,[]);return new Uint8Array(await crypto.subtle.deriveBits({name:"X25519",public:o},r,256))},()=>{if(pS(e))throw Error("CryptoKey provided but X25519 WebCrypto is not supported");return Ip.scalarMult(e,t)})}async function cu(e){return await tC(async()=>kp(e,Ip.GuBytes),()=>{if(pS(e))throw Error("CryptoKey provided but X25519 WebCrypto is not supported");return Ip.scalarMultBase(e)})}var iK=new Uint8Array([48,46,2,1,0,48,5,6,3,43,101,110,4,34,4,32]);async function sK(e){if(e.length!==32)throw Error("X25519 private key must be 32 bytes");let t=new Uint8Array([...iK,...e]);return crypto.subtle.importKey("pkcs8",t,{name:"X25519"},eC,["deriveBits"])}function pS(e){return typeof CryptoKey<"u"&&e instanceof CryptoKey}function aK(e){return e}class mS{s;transcript=[];buf=new Uint8Array(0);constructor(e){this.s=e.getReader()}async readLine(){let e=[];while(!0){let t=this.buf.indexOf(10);if(t>=0)return e.push(this.buf.subarray(0,t)),this.transcript.push(this.buf.subarray(0,t+1)),this.buf=this.buf.subarray(t+1),lK(xs(e));if(this.buf.length>0)e.push(this.buf),this.transcript.push(this.buf);let r=await this.s.read();if(r.done)return this.buf=xs(e),null;this.buf=r.value}}close(){return this.s.releaseLock(),{rest:this.buf,transcript:xs(this.transcript)}}}function lK(e){return e.forEach((t)=>{if(t<32||t>126)throw Error("invalid non-ASCII byte in header")}),new TextDecoder().decode(e)}function xs(e){let t=e.reduce((n,i)=>n+i.length,0),r=new Uint8Array(t),o=0;for(let n of e)r.set(n,o),o+=n.length;return r}function Pa(e,...t){return e.pipeThrough(new TransformStream({start(r){for(let o of t)r.enqueue(o)}}))}function Ap(e){return new ReadableStream({start(t){t.enqueue(e),t.close()}})}async function hS(e){if(!(e instanceof ReadableStream))throw Error("readAll expects a ReadableStream<Uint8Array>");return new Uint8Array(await new Response(e).arrayBuffer())}async function rC(e){if(!(e instanceof ReadableStream))throw Error("readAllString expects a ReadableStream<Uint8Array>");return await new Response(e).text()}async function nC(e,t){let r=e.getReader(),o=[],n=0;while(n<t){let{done:c,value:u}=await r.read();if(c)throw Error("stream ended before reading "+t.toString()+" bytes");o.push(u),n+=u.length}r.releaseLock();let i=xs(o),s=i.subarray(0,t),a=Pa(e,i.subarray(t));return{data:s,rest:a}}class Dn{args;body;constructor(e,t){this.args=e,this.body=t}}async function uK(e){let t=await e.readLine();if(t===null)throw Error("invalid stanza");let r=t.split(" ");if(r.length<2||r.shift()!=="->")return{next:t};for(let i of r)if(i.length===0)throw Error("invalid stanza");let o=[];for(;;){let i=await e.readLine();if(i===null)throw Error("invalid stanza");let s=Yt.decode(i);if(s.length>48)throw Error("invalid stanza");if(o.push(s),s.length<48)break}let n=xs(o);return{s:new Dn(r,n)}}async function oC(e){let t=new mS(e),r=await t.readLine();if(r!=="age-encryption.org/v1")throw Error("invalid version "+(r??"line"));let o=[];for(;;){let{s:n,next:i}=await uK(t);if(n!==void 0){o.push(n);continue}if(!i.startsWith("--- "))throw Error("invalid header");let s=Yt.decode(i.slice(4)),{rest:a,transcript:c}=t.close(),u=c.slice(0,c.length-1-i.length+3);return{stanzas:o,headerNoMAC:u,MAC:s,headerSize:c.length,rest:Pa(e,a)}}}function gS(e){let t=[];t.push(`age-encryption.org/v1
|
|
701
|
+
`)}function iR(e){let t=new Map;for(let r of e){if(t.has(r.name))throw Error(`Duplicate command name: ${r.name}`);t.set(r.name,r)}return t}function nt(e,t){let r=e[t];return typeof r==="string"?r:void 0}function ts(e,t){let r=e[t];return typeof r==="boolean"?r:void 0}var Df={name:"@rizom/ops",version:"0.2.0-alpha.665",description:"Operator CLI for managing private brain fleet registry repos",keywords:["brains","ops","cli","deploy","fleet","operator"],license:"AGPL-3.0-only",author:"Yeehaa <yeehaa@rizom.ai> (https://rizom.ai)",bin:{"brains-ops":"./dist/brains-ops.js"},bugs:"https://github.com/rizom-ai/brains/issues",dependencies:{"@libsql/client":"^0.17.4","age-encryption":"^0.3.0",yaml:"^2.9.0"},devDependencies:{"@brains/contracts":"workspace:*","@brains/deploy-support":"workspace:*","@brains/eslint-config":"workspace:*","@brains/job-queue":"workspace:*","@brains/profile":"workspace:*","@brains/site-composition":"workspace:*","@brains/test-utils":"workspace:*","@brains/typescript-config":"workspace:*","@brains/utils":"workspace:*","@types/bun":"^1.4.0",typescript:"^7.0.2"},engines:{bun:">=1.3.3"},exports:{".":{types:"./dist/index.d.ts",import:"./dist/index.js"},"./deploy":{types:"./dist/deploy.d.ts",import:"./dist/deploy.js",bun:"./dist/deploy.js"}},files:["dist","templates"],homepage:"https://github.com/rizom-ai/brains/tree/main/packages/brains-ops#readme",main:"./dist/index.js",publishConfig:{access:"public"},repository:{type:"git",url:"https://github.com/rizom-ai/brains.git",directory:"packages/brains-ops"},scripts:{build:"bun scripts/build.ts",lint:"eslint . --max-warnings 0","lint:fix":"eslint . --max-warnings 0 --fix",prepublishOnly:"bun scripts/build.ts",test:"bun test --timeout 20000","test:smoke":"bun run build && RUN_SMOKE_TESTS=1 bun test --timeout 60000",typecheck:"tsc --noEmit"},type:"module",types:"./dist/index.d.ts"};import{existsSync as wK,mkdirSync as xK,readFileSync as zS,writeFileSync as NS}from"fs";import{dirname as _K,join as mC}from"path";function Vy(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name==="Uint8Array"&&"BYTES_PER_ELEMENT"in e&&e.BYTES_PER_ELEMENT===1}function St(e,t=""){if(typeof e!=="number"){let r=t&&`"${t}" `;throw TypeError(`${r}expected number, got ${typeof e}`)}if(!Number.isSafeInteger(e)||e<0){let r=t&&`"${t}" `;throw RangeError(`${r}expected integer >= 0, got ${e}`)}}function Ut(e,t,r=""){let o=Vy(e),n=e?.length,i=t!==void 0;if(!o||i&&n!==t){let s=r&&`"${r}" `,a=i?` of length ${t}`:"",c=o?`length=${n}`:`type=${typeof e}`,u=s+"expected Uint8Array"+a+", got "+c;if(!o)throw TypeError(u);throw RangeError(u)}return e}function no(e){if(typeof e!=="function"||typeof e.create!=="function")throw TypeError("Hash must wrapped by utils.createHasher");if(St(e.outputLen),St(e.blockLen),e.outputLen<1)throw Error('"outputLen" must be >= 1');if(e.blockLen<1)throw Error('"blockLen" must be >= 1')}function pa(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 Lf(e,t){Ut(e,void 0,"digestInto() output");let r=t.outputLen;if(e.length<r)throw RangeError('"digestInto() output" expected to be of length >='+r)}function jf(e){return new Uint32Array(e.buffer,e.byteOffset,Math.floor(e.byteLength/4))}function cr(...e){for(let t=0;t<e.length;t++)e[t].fill(0)}function ma(e){return new DataView(e.buffer,e.byteOffset,e.byteLength)}function rn(e,t){return e<<32-t|e>>>t}function Fe(e,t){return e<<t|e>>>32-t>>>0}var V5=(()=>new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68)();function W5(e){return e<<24&4278190080|e<<8&16711680|e>>>8&65280|e>>>24&255}function G5(e){for(let t=0;t<e.length;t++)e[t]=W5(e[t]);return e}var Wy=V5?(e)=>e:G5,aR=(()=>typeof Uint8Array.from([]).toHex==="function"&&typeof Uint8Array.fromHex==="function")(),Q5=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,"0"));function Bf(e){if(Ut(e),aR)return e.toHex();let t="";for(let r=0;r<e.length;r++)t+=Q5[e[r]];return t}var ro={_0:48,_9:57,A:65,F:70,a:97,f:102};function sR(e){if(e>=ro._0&&e<=ro._9)return e-ro._0;if(e>=ro.A&&e<=ro.F)return e-(ro.A-10);if(e>=ro.a&&e<=ro.f)return e-(ro.a-10);return}function $l(e){if(typeof e!=="string")throw TypeError("hex string expected, got "+typeof e);if(aR)try{return Uint8Array.fromHex(e)}catch(n){if(n instanceof SyntaxError)throw RangeError(n.message);throw n}let t=e.length,r=t/2;if(t%2)throw RangeError("hex string expected, got unpadded hex of length "+t);let o=new Uint8Array(r);for(let n=0,i=0;n<r;n++,i+=2){let s=sR(e.charCodeAt(i)),a=sR(e.charCodeAt(i+1));if(s===void 0||a===void 0){let c=e[i]+e[i+1];throw RangeError('hex string expected, got non-hex character "'+c+'" at index '+i)}o[n]=s*16+a}return o}function Y5(e){if(typeof e!=="string")throw TypeError("string expected");return new Uint8Array(new TextEncoder().encode(e))}function Gy(e,t=""){if(typeof e==="string")return Y5(e);return Ut(e,void 0,t)}function Qy(...e){let t=0;for(let o=0;o<e.length;o++){let n=e[o];Ut(n),t+=n.length}let r=new Uint8Array(t);for(let o=0,n=0;o<e.length;o++){let i=e[o];r.set(i,n),n+=i.length}return r}function Zf(e,t){if(t!==void 0&&{}.toString.call(t)!=="[object Object]")throw TypeError("options must be object or undefined");return Object.assign(e,t)}function Yy(e,t={}){let r=(n,i)=>e(i).update(n).digest(),o=e(void 0);return r.outputLen=o.outputLen,r.blockLen=o.blockLen,r.canXOF=o.canXOF,r.create=(n)=>e(n),Object.assign(r,t),Object.freeze(r)}function oo(e=32){St(e,"bytesLength");let t=typeof globalThis==="object"?globalThis.crypto:null;if(typeof t?.getRandomValues!=="function")throw Error("crypto.getRandomValues must be defined");if(e>65536)throw RangeError(`"bytesLength" expected <= 65536, got ${e}`);return t.getRandomValues(new Uint8Array(e))}var Xy=(e)=>({oid:Uint8Array.from([6,9,96,134,72,1,101,3,4,2,e])});class eb{oHash;iHash;blockLen;outputLen;canXOF=!1;finished=!1;destroyed=!1;constructor(e,t){if(no(e),Ut(t,void 0,"key"),this.iHash=e.create(),typeof this.iHash.update!=="function")throw Error("Expected instance of class which extends utils.Hash");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;let r=this.blockLen,o=new Uint8Array(r);o.set(t.length>r?e.create().update(t).digest():t);for(let n=0;n<o.length;n++)o[n]^=54;this.iHash.update(o),this.oHash=e.create();for(let n=0;n<o.length;n++)o[n]^=106;this.oHash.update(o),cr(o)}update(e){return pa(this),this.iHash.update(e),this}digestInto(e){pa(this),Lf(e,this),this.finished=!0;let t=e.subarray(0,this.outputLen);this.iHash.digestInto(t),this.oHash.update(t),this.oHash.digestInto(t),this.destroy()}digest(){let e=new Uint8Array(this.oHash.outputLen);return this.digestInto(e),e}_cloneInto(e){e||=Object.create(Object.getPrototypeOf(this),{});let{oHash:t,iHash:r,finished:o,destroyed:n,blockLen:i,outputLen:s}=this;return e=e,e.finished=o,e.destroyed=n,e.blockLen=i,e.outputLen=s,e.oHash=t._cloneInto(e.oHash),e.iHash=r._cloneInto(e.iHash),e}clone(){return this._cloneInto()}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}}var Tn=(()=>{let e=(t,r,o)=>new eb(t,r).update(o).digest();return e.create=(t,r)=>new eb(t,r),e})();function Rl(e,t,r){if(no(e),r===void 0)r=new Uint8Array(e.outputLen);return Tn(e,r,t)}var tb=Uint8Array.of(0),cR=Uint8Array.of();function rb(e,t,r,o=32){no(e),St(o,"length"),Ut(t,void 0,"prk");let n=e.outputLen;if(t.length<n)throw Error('"prk" must be at least HashLen octets');if(o>255*n)throw Error("Length must be <= 255*HashLen");let i=Math.ceil(o/n);if(r===void 0)r=cR;else Ut(r,void 0,"info");let s=new Uint8Array(i*n),a=Tn.create(e,t),c=a._cloneInto(),u=new Uint8Array(a.outputLen);for(let d=0;d<i;d++)tb[0]=d+1,c.update(d===0?cR:u).update(r).update(tb).digestInto(u),s.set(u,n*d),a._cloneInto(c);return a.destroy(),c.destroy(),cr(u,tb),s.slice(0,o)}var Mo=(e,t,r,o,n)=>rb(e,Rl(e,t,r),o,n);function lR(e,t,r){return e&t^~e&r}function uR(e,t,r){return e&t^e&r^t&r}class Uf{blockLen;outputLen;canXOF=!1;padOffset;isLE;buffer;view;finished=!1;length=0;pos=0;destroyed=!1;constructor(e,t,r,o){this.blockLen=e,this.outputLen=t,this.padOffset=r,this.isLE=o,this.buffer=new Uint8Array(e),this.view=ma(this.buffer)}update(e){pa(this),Ut(e);let{view:t,buffer:r,blockLen:o}=this,n=e.length;for(let i=0;i<n;){let s=Math.min(o-this.pos,n-i);if(s===o){let a=ma(e);for(;o<=n-i;i+=o)this.process(a,i);continue}if(r.set(e.subarray(i,i+s),this.pos),this.pos+=s,i+=s,this.pos===o)this.process(t,0),this.pos=0}return this.length+=e.length,this.roundClean(),this}digestInto(e){pa(this),Lf(e,this),this.finished=!0;let{buffer:t,view:r,blockLen:o,isLE:n}=this,{pos:i}=this;if(t[i++]=128,cr(this.buffer.subarray(i)),this.padOffset>o-i)this.process(r,0),i=0;for(let d=i;d<o;d++)t[d]=0;r.setBigUint64(o-8,BigInt(this.length*8),n),this.process(r,0);let s=ma(e),a=this.outputLen;if(a%4)throw Error("_sha2: outputLen must be aligned to 32bit");let c=a/4,u=this.get();if(c>u.length)throw Error("_sha2: outputLen bigger than state");for(let d=0;d<c;d++)s.setUint32(4*d,u[d],n)}digest(){let{buffer:e,outputLen:t}=this;this.digestInto(e);let r=e.slice(0,t);return this.destroy(),r}_cloneInto(e){e||=new this.constructor,e.set(...this.get());let{blockLen:t,buffer:r,length:o,finished:n,destroyed:i,pos:s}=this;if(e.destroyed=i,e.finished=n,e.length=o,e.pos=s,o%t)e.buffer.set(r);return e}clone(){return this._cloneInto()}}var io=Uint32Array.from([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]);var qt=Uint32Array.from([1779033703,4089235720,3144134277,2227873595,1013904242,4271175723,2773480762,1595750129,1359893119,2917565137,2600822924,725511199,528734635,4215389547,1541459225,327033209]);var qf=BigInt(4294967295),dR=BigInt(32);function X5(e,t=!1){if(t)return{h:Number(e&qf),l:Number(e>>dR&qf)};return{h:Number(e>>dR&qf)|0,l:Number(e&qf)|0}}function fR(e,t=!1){let r=e.length,o=new Uint32Array(r),n=new Uint32Array(r);for(let i=0;i<r;i++){let{h:s,l:a}=X5(e[i],t);[o[i],n[i]]=[s,a]}return[o,n]}var nb=(e,t,r)=>e>>>r,ob=(e,t,r)=>e<<32-r|t>>>r,rs=(e,t,r)=>e>>>r|t<<32-r,ns=(e,t,r)=>e<<32-r|t>>>r,Ol=(e,t,r)=>e<<64-r|t>>>r-32,Cl=(e,t,r)=>e>>>r-32|t<<64-r;function $n(e,t,r,o){let n=(t>>>0)+(o>>>0);return{h:e+r+(n/4294967296|0)|0,l:n|0}}var pR=(e,t,r)=>(e>>>0)+(t>>>0)+(r>>>0),mR=(e,t,r,o)=>t+r+o+(e/4294967296|0)|0,hR=(e,t,r,o)=>(e>>>0)+(t>>>0)+(r>>>0)+(o>>>0),gR=(e,t,r,o,n)=>t+r+o+n+(e/4294967296|0)|0,yR=(e,t,r,o,n)=>(e>>>0)+(t>>>0)+(r>>>0)+(o>>>0)+(n>>>0),bR=(e,t,r,o,n,i)=>t+r+o+n+i+(e/4294967296|0)|0;var t8=Uint32Array.from([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),Fo=new Uint32Array(64);class SR extends Uf{constructor(e){super(64,e,8,!1)}get(){let{A:e,B:t,C:r,D:o,E:n,F:i,G:s,H:a}=this;return[e,t,r,o,n,i,s,a]}set(e,t,r,o,n,i,s,a){this.A=e|0,this.B=t|0,this.C=r|0,this.D=o|0,this.E=n|0,this.F=i|0,this.G=s|0,this.H=a|0}process(e,t){for(let d=0;d<16;d++,t+=4)Fo[d]=e.getUint32(t,!1);for(let d=16;d<64;d++){let f=Fo[d-15],m=Fo[d-2],h=rn(f,7)^rn(f,18)^f>>>3,b=rn(m,17)^rn(m,19)^m>>>10;Fo[d]=b+Fo[d-7]+h+Fo[d-16]|0}let{A:r,B:o,C:n,D:i,E:s,F:a,G:c,H:u}=this;for(let d=0;d<64;d++){let f=rn(s,6)^rn(s,11)^rn(s,25),m=u+f+lR(s,a,c)+t8[d]+Fo[d]|0,b=(rn(r,2)^rn(r,13)^rn(r,22))+uR(r,o,n)|0;u=c,c=a,a=s,s=i+m|0,i=n,n=o,o=r,r=m+b|0}r=r+this.A|0,o=o+this.B|0,n=n+this.C|0,i=i+this.D|0,s=s+this.E|0,a=a+this.F|0,c=c+this.G|0,u=u+this.H|0,this.set(r,o,n,i,s,a,c,u)}roundClean(){cr(Fo)}destroy(){this.destroyed=!0,this.set(0,0,0,0,0,0,0,0),cr(this.buffer)}}class vR extends SR{A=io[0]|0;B=io[1]|0;C=io[2]|0;D=io[3]|0;E=io[4]|0;F=io[5]|0;G=io[6]|0;H=io[7]|0;constructor(){super(32)}}var wR=(()=>fR(["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))))(),r8=(()=>wR[0])(),n8=(()=>wR[1])(),Jo=new Uint32Array(80),Ko=new Uint32Array(80);class xR extends Uf{constructor(e){super(128,e,16,!1)}get(){let{Ah:e,Al:t,Bh:r,Bl:o,Ch:n,Cl:i,Dh:s,Dl:a,Eh:c,El:u,Fh:d,Fl:f,Gh:m,Gl:h,Hh:b,Hl:y}=this;return[e,t,r,o,n,i,s,a,c,u,d,f,m,h,b,y]}set(e,t,r,o,n,i,s,a,c,u,d,f,m,h,b,y){this.Ah=e|0,this.Al=t|0,this.Bh=r|0,this.Bl=o|0,this.Ch=n|0,this.Cl=i|0,this.Dh=s|0,this.Dl=a|0,this.Eh=c|0,this.El=u|0,this.Fh=d|0,this.Fl=f|0,this.Gh=m|0,this.Gl=h|0,this.Hh=b|0,this.Hl=y|0}process(e,t){for(let _=0;_<16;_++,t+=4)Jo[_]=e.getUint32(t),Ko[_]=e.getUint32(t+=4);for(let _=16;_<80;_++){let A=Jo[_-15]|0,O=Ko[_-15]|0,L=rs(A,O,1)^rs(A,O,8)^nb(A,O,7),z=ns(A,O,1)^ns(A,O,8)^ob(A,O,7),K=Jo[_-2]|0,P=Ko[_-2]|0,W=rs(K,P,19)^Ol(K,P,61)^nb(K,P,6),ee=ns(K,P,19)^Cl(K,P,61)^ob(K,P,6),B=hR(z,ee,Ko[_-7],Ko[_-16]),R=gR(B,L,W,Jo[_-7],Jo[_-16]);Jo[_]=R|0,Ko[_]=B|0}let{Ah:r,Al:o,Bh:n,Bl:i,Ch:s,Cl:a,Dh:c,Dl:u,Eh:d,El:f,Fh:m,Fl:h,Gh:b,Gl:y,Hh:S,Hl:x}=this;for(let _=0;_<80;_++){let A=rs(d,f,14)^rs(d,f,18)^Ol(d,f,41),O=ns(d,f,14)^ns(d,f,18)^Cl(d,f,41),L=d&m^~d&b,z=f&h^~f&y,K=yR(x,O,z,n8[_],Ko[_]),P=bR(K,S,A,L,r8[_],Jo[_]),W=K|0,ee=rs(r,o,28)^Ol(r,o,34)^Ol(r,o,39),B=ns(r,o,28)^Cl(r,o,34)^Cl(r,o,39),R=r&n^r&s^n&s,j=o&i^o&a^i&a;S=b|0,x=y|0,b=m|0,y=h|0,m=d|0,h=f|0,{h:d,l:f}=$n(c|0,u|0,P|0,W|0),c=s|0,u=a|0,s=n|0,a=i|0,n=r|0,i=o|0;let I=pR(W,B,j);r=mR(I,P,ee,R),o=I|0}({h:r,l:o}=$n(this.Ah|0,this.Al|0,r|0,o|0)),{h:n,l:i}=$n(this.Bh|0,this.Bl|0,n|0,i|0),{h:s,l:a}=$n(this.Ch|0,this.Cl|0,s|0,a|0),{h:c,l:u}=$n(this.Dh|0,this.Dl|0,c|0,u|0),{h:d,l:f}=$n(this.Eh|0,this.El|0,d|0,f|0),{h:m,l:h}=$n(this.Fh|0,this.Fl|0,m|0,h|0),{h:b,l:y}=$n(this.Gh|0,this.Gl|0,b|0,y|0),{h:S,l:x}=$n(this.Hh|0,this.Hl|0,S|0,x|0),this.set(r,o,n,i,s,a,c,u,d,f,m,h,b,y,S,x)}roundClean(){cr(Jo,Ko)}destroy(){this.destroyed=!0,cr(this.buffer),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}}class _R extends xR{Ah=qt[0]|0;Al=qt[1]|0;Bh=qt[2]|0;Bl=qt[3]|0;Ch=qt[4]|0;Cl=qt[5]|0;Dh=qt[6]|0;Dl=qt[7]|0;Eh=qt[8]|0;El=qt[9]|0;Fh=qt[10]|0;Fl=qt[11]|0;Gh=qt[12]|0;Gl=qt[13]|0;Hh=qt[14]|0;Hl=qt[15]|0;constructor(){super(64)}}var vt=Yy(()=>new vR,Xy(1));var Mf=Yy(()=>new _R,Xy(3));/*! scure-base - MIT License (c) 2022 Paul Miller (paulmillr.com) */function Vf(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name==="Uint8Array"&&"BYTES_PER_ELEMENT"in e&&e.BYTES_PER_ELEMENT===1}function ab(e){if(!Vf(e))throw TypeError("Uint8Array expected")}function TR(e,t){if(!Array.isArray(t))return!1;if(t.length===0)return!0;if(e)return t.every((r)=>typeof r==="string");else return t.every((r)=>Number.isSafeInteger(r))}function $R(e){if(typeof e!=="function")throw TypeError("function expected");return!0}function Ho(e,t){if(typeof t!=="string")throw TypeError(`${e}: string expected`);return!0}function zl(e){if(typeof e!=="number")throw TypeError(`number expected, got ${typeof e}`);if(!Number.isSafeInteger(e))throw RangeError(`invalid integer: ${e}`)}function Jf(e){if(!Array.isArray(e))throw TypeError("array expected")}function Kf(e,t){if(!TR(!0,t))throw TypeError(`${e}: array of strings expected`)}function cb(e,t){if(!TR(!1,t))throw TypeError(`${e}: array of numbers expected`)}function Rr(...e){let t=(i)=>i,r=(i,s)=>(a)=>i(s(a)),o=e.map((i)=>i.encode).reduceRight(r,t),n=e.map((i)=>i.decode).reduce(r,t);return{encode:o,decode:n}}function Or(e){let t=typeof e==="string"?e.split(""):e,r=t.length;Kf("alphabet",t);let o=new Map(t.map((n,i)=>[n,i]));return{encode:(n)=>(Jf(n),n.map((i)=>{if(!Number.isSafeInteger(i)||i<0||i>=r)throw Error(`alphabet.encode: digit index outside alphabet "${i}". Allowed: ${e}`);return t[i]})),decode:(n)=>(Jf(n),n.map((i)=>{Ho("alphabet.decode",i);let s=o.get(i);if(s===void 0)throw Error(`Unknown letter: "${i}". Allowed: ${e}`);return s}))}}function Cr(e=""){return Ho("join",e),{encode:(t)=>(Kf("join.decode",t),t.join(e)),decode:(t)=>(Ho("join.decode",t),t.split(e))}}function Wf(e,t="="){return zl(e),Ho("padding",t),{encode(r){Kf("padding.encode",r);while(r.length*e%8)r.push(t);return r},decode(r){Kf("padding.decode",r);let o=r.length;if(o*e%8)throw Error("padding: invalid, string should have whole number of bytes");for(;o>0&&r[o-1]===t;o--)if((o-1)*e%8===0)throw Error("padding: invalid, string has too much padding");return r.slice(0,o)}}}function RR(e){return $R(e),{encode:(t)=>t,decode:(t)=>e(t)}}function ER(e,t,r){if(t<2)throw RangeError(`convertRadix: invalid from=${t}, base cannot be less than 2`);if(r<2)throw RangeError(`convertRadix: invalid to=${r}, base cannot be less than 2`);if(Jf(e),!e.length)return[];let o=0,n=[],i=Array.from(e,(a)=>{if(zl(a),a<0||a>=t)throw Error(`invalid integer: ${a}`);return a}),s=i.length;while(!0){let a=0,c=!0;for(let u=o;u<s;u++){let d=i[u],f=t*a,m=f+d;if(!Number.isSafeInteger(m)||f/t!==a||m-d!==f)throw Error("convertRadix: carry overflow");let h=m/r;a=m%r;let b=Math.floor(h);if(i[u]=b,!Number.isSafeInteger(b)||b*r+a!==m)throw Error("convertRadix: carry overflow");if(!c)continue;else if(!b)o=u;else c=!1}if(n.push(a),c)break}for(let a=0;a<e.length-1&&e[a]===0;a++)n.push(0);return n.reverse()}var OR=(e,t)=>t===0?e:OR(t,e%t),Hf=(e,t)=>e+(t-OR(e,t)),Ff=(()=>{let e=[];for(let t=0;t<40;t++)e.push(2**t);return e})();function ib(e,t,r,o){if(Jf(e),t<=0||t>32)throw RangeError(`convertRadix2: wrong from=${t}`);if(r<=0||r>32)throw RangeError(`convertRadix2: wrong to=${r}`);if(Hf(t,r)>32)throw Error(`convertRadix2: carry overflow from=${t} to=${r} carryBits=${Hf(t,r)}`);let n=0,i=0,s=Ff[t],a=Ff[r]-1,c=[];for(let u of e){if(zl(u),u>=s)throw Error(`convertRadix2: invalid data word=${u} from=${t}`);if(n=n<<t|u,i+t>32)throw Error(`convertRadix2: carry overflow pos=${i} from=${t}`);i+=t;for(;i>=r;i-=r)c.push((n>>i-r&a)>>>0);let d=Ff[i];if(d===void 0)throw Error("invalid carry");n&=d-1}if(n=n<<r-i&a,!o&&i>=t)throw Error("Excess padding");if(!o&&n>0)throw Error(`Non-zero padding: ${n}`);if(o&&i>0)c.push(n>>>0);return c}function o8(e){zl(e);let t=256;return{encode:(r)=>{if(!Vf(r))throw TypeError("radix.encode input should be Uint8Array");return ER(Array.from(r),t,e)},decode:(r)=>(cb("radix.decode",r),Uint8Array.from(ER(r,e,t)))}}function Ur(e,t=!1){if(zl(e),e<=0||e>32)throw RangeError("radix2: bits should be in (0..32]");if(Hf(8,e)>32||Hf(e,8)>32)throw RangeError("radix2: carry overflow");return{encode:(r)=>{if(!Vf(r))throw TypeError("radix2.encode input should be Uint8Array");return ib(Array.from(r),8,e,!t)},decode:(r)=>(cb("radix2.decode",r),Uint8Array.from(ib(r,e,8,t)))}}function IR(e){return $R(e),function(...t){try{return e.apply(null,t)}catch(r){}}}var kme=Object.freeze(Rr(Ur(4),Or("0123456789ABCDEF"),Cr(""))),Ame=Object.freeze(Rr(Ur(5),Or("ABCDEFGHIJKLMNOPQRSTUVWXYZ234567"),Wf(5),Cr(""))),Tme=Object.freeze(Rr(Ur(5),Or("ABCDEFGHIJKLMNOPQRSTUVWXYZ234567"),Cr(""))),$me=Object.freeze(Rr(Ur(5),Or("0123456789ABCDEFGHIJKLMNOPQRSTUV"),Wf(5),Cr(""))),Rme=Object.freeze(Rr(Ur(5),Or("0123456789ABCDEFGHIJKLMNOPQRSTUV"),Cr(""))),Ome=Object.freeze(Rr(Ur(5),Or("0123456789ABCDEFGHJKMNPQRSTVWXYZ"),Cr(""),RR((e)=>e.toUpperCase().replace(/O/g,"0").replace(/[IL]/g,"1")))),CR=(()=>typeof Uint8Array.from([]).toBase64==="function"&&typeof Uint8Array.fromBase64==="function")(),i8=/[\t\n\f\r ]/,PR=(e,t)=>{Ho("base64",e);let r=t?"base64url":"base64";if(e.length>0&&i8.test(e))throw Error("invalid base64");return Uint8Array.fromBase64(e,{alphabet:r,lastChunkHandling:"strict"})},lb=Object.freeze(CR?{encode(e){return ab(e),e.toBase64()},decode(e){return PR(e,!1)}}:Rr(Ur(6),Or("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"),Wf(6),Cr(""))),Yt=Object.freeze(Rr(Ur(6),Or("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"),Cr(""))),Cme=Object.freeze(CR?{encode(e){return ab(e),e.toBase64({alphabet:"base64url"})},decode(e){return PR(e,!0)}}:Rr(Ur(6),Or("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_"),Wf(6),Cr(""))),Pme=Object.freeze(Rr(Ur(6),Or("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_"),Cr(""))),ub=(e)=>Rr(o8(58),Or(e),Cr("")),zme=Object.freeze(ub("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz")),Nme=Object.freeze(ub("123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ")),Dme=Object.freeze(ub("rpshnaf39wBUDNEGHJKLM4PQRST7VWXYZ2bcdeCg65jkm8oFqi1tuvAxyz"));var sb=Rr(Or("qpzry9x8gf2tvdw0s3jn54khce6mua7l"),Cr("")),kR=[996825010,642813549,513874426,1027748829,705979059];function Pl(e){let t=e>>25,r=(e&33554431)<<5;for(let o=0;o<kR.length;o++)if((t>>o&1)===1)r^=kR[o];return r}function AR(e,t,r=1){let o=e.length,n=1;for(let i=0;i<o;i++){let s=e.charCodeAt(i);if(s<33||s>126)throw Error(`Invalid prefix (${e})`);n=Pl(n)^s>>5}n=Pl(n);for(let i=0;i<o;i++)n=Pl(n)^e.charCodeAt(i)&31;for(let i of t)n=Pl(n)^i;for(let i=0;i<6;i++)n=Pl(n);return n^=r,sb.encode(ib([n%Ff[30]],30,5,!1))}function zR(e){let t=e==="bech32"?1:734539939,r=Ur(5),o=r.decode,n=r.encode,i=IR(o);function s(f,m,h=90){if(Ho("bech32.encode prefix",f),Vf(m))m=Array.from(m);cb("bech32.encode",m);let b=f.length;if(b===0)throw TypeError(`Invalid prefix length ${b}`);let y=b+7+m.length;if(h!==!1&&y>h)throw TypeError(`Length ${y} exceeds limit ${h}`);let S=f.toLowerCase(),x=AR(S,m,t);return`${S}1${sb.encode(m)}${x}`}function a(f,m=90){Ho("bech32.decode input",f);let h=f.length;if(h<8||m!==!1&&h>m)throw TypeError(`invalid string length: ${h} (${f}). Expected (8..${m})`);let b=f.toLowerCase();if(f!==b&&f!==f.toUpperCase())throw Error("String must be lowercase or uppercase");let y=b.lastIndexOf("1");if(y===0||y===-1)throw Error('Letter "1" must be present between prefix and data only');let S=b.slice(0,y),x=b.slice(y+1);if(x.length<6)throw Error("Data must be at least 6 characters long");let _=sb.decode(x).slice(0,-6),A=AR(S,_,t);if(!x.endsWith(A))throw Error(`Invalid checksum in ${f}: expected "${A}"`);return{prefix:S,words:_}}let c=IR(a);function u(f){let{prefix:m,words:h}=a(f,!1);return{prefix:m,words:h,bytes:o(h)}}function d(f,m){return s(f,n(m))}return{encode:s,decode:a,encodeFromBytes:d,decodeToBytes:u,decodeUnsafe:c,fromWords:o,fromWordsUnsafe:i,toWords:n}}var Pr=Object.freeze(zR("bech32")),Lme=Object.freeze(zR("bech32m"));var s8=(()=>typeof Uint8Array.from([]).toHex==="function"&&typeof Uint8Array.fromHex==="function")(),a8={encode(e){return ab(e),e.toHex()},decode(e){return Ho("hex",e),Uint8Array.fromHex(e)}},jme=Object.freeze(s8?a8:Rr(Ur(4),Or("0123456789abcdef"),Cr(""),RR((e)=>{if(typeof e!=="string"||e.length%2!==0)throw TypeError(`hex.decode: expected string, got ${typeof e} with length ${e.length}`);return e.toLowerCase()})));function l8(e,t,r,o){no(e);let n=Zf({dkLen:32,asyncTick:10},o),{c:i,dkLen:s,asyncTick:a}=n;if(St(i,"c"),St(s,"dkLen"),St(a,"asyncTick"),i<1)throw Error("iterations (c) must be >= 1");if(s<1)throw Error('"dkLen" must be >= 1');if(s>4294967295*e.outputLen)throw Error("derived key too long");let c=Gy(t,"password"),u=Gy(r,"salt"),d=new Uint8Array(s),f=Tn.create(e,c),m=f._cloneInto().update(u);return{c:i,dkLen:s,asyncTick:a,DK:d,PRF:f,PRFSalt:m}}function u8(e,t,r,o,n){if(e.destroy(),t.destroy(),o)o.destroy();return cr(n),r}function db(e,t,r,o){let{c:n,dkLen:i,DK:s,PRF:a,PRFSalt:c}=l8(e,t,r,o),u,d=new Uint8Array(4),f=ma(d),m=new Uint8Array(a.outputLen);for(let h=1,b=0;b<i;h++,b+=a.outputLen){let y=s.subarray(b,b+a.outputLen);f.setInt32(0,h,!1),(u=c._cloneInto(u)).update(d).digestInto(m),y.set(m.subarray(0,y.length));for(let S=1;S<n;S++){a._cloneInto(u).update(m).digestInto(m);for(let x=0;x<y.length;x++)y[x]^=m[x]}}return u8(a,c,s,u,m)}function NR(e,t,r,o,n,i){let s=e[t++]^r[o++],a=e[t++]^r[o++],c=e[t++]^r[o++],u=e[t++]^r[o++],d=e[t++]^r[o++],f=e[t++]^r[o++],m=e[t++]^r[o++],h=e[t++]^r[o++],b=e[t++]^r[o++],y=e[t++]^r[o++],S=e[t++]^r[o++],x=e[t++]^r[o++],_=e[t++]^r[o++],A=e[t++]^r[o++],O=e[t++]^r[o++],L=e[t++]^r[o++],z=s,K=a,P=c,W=u,ee=d,B=f,R=m,j=h,I=b,T=y,k=S,M=x,N=_,H=A,G=O,re=L;for(let ae=0;ae<8;ae+=2)ee^=Fe(z+N|0,7),I^=Fe(ee+z|0,9),N^=Fe(I+ee|0,13),z^=Fe(N+I|0,18),T^=Fe(B+K|0,7),H^=Fe(T+B|0,9),K^=Fe(H+T|0,13),B^=Fe(K+H|0,18),G^=Fe(k+R|0,7),P^=Fe(G+k|0,9),R^=Fe(P+G|0,13),k^=Fe(R+P|0,18),W^=Fe(re+M|0,7),j^=Fe(W+re|0,9),M^=Fe(j+W|0,13),re^=Fe(M+j|0,18),K^=Fe(z+W|0,7),P^=Fe(K+z|0,9),W^=Fe(P+K|0,13),z^=Fe(W+P|0,18),R^=Fe(B+ee|0,7),j^=Fe(R+B|0,9),ee^=Fe(j+R|0,13),B^=Fe(ee+j|0,18),M^=Fe(k+T|0,7),I^=Fe(M+k|0,9),T^=Fe(I+M|0,13),k^=Fe(T+I|0,18),N^=Fe(re+G|0,7),H^=Fe(N+re|0,9),G^=Fe(H+N|0,13),re^=Fe(G+H|0,18);n[i++]=s+z|0,n[i++]=a+K|0,n[i++]=c+P|0,n[i++]=u+W|0,n[i++]=d+ee|0,n[i++]=f+B|0,n[i++]=m+R|0,n[i++]=h+j|0,n[i++]=b+I|0,n[i++]=y+T|0,n[i++]=S+k|0,n[i++]=x+M|0,n[i++]=_+N|0,n[i++]=A+H|0,n[i++]=O+G|0,n[i++]=L+re|0}function fb(e,t,r,o,n){let i=o+0,s=o+16*n;for(let a=0;a<16;a++)r[s+a]=e[t+(2*n-1)*16+a];for(let a=0;a<n;a++,i+=16,t+=16){if(NR(r,s,e,t,r,i),a>0)s+=16;NR(r,i,e,t+=16,r,s)}}function d8(e,t,r){let o=Zf({dkLen:32,asyncTick:10,maxmem:1073742848},r),{N:n,r:i,p:s,dkLen:a,asyncTick:c,maxmem:u,onProgress:d}=o;if(St(n,"N"),St(i,"r"),St(s,"p"),St(a,"dkLen"),St(c,"asyncTick"),St(u,"maxmem"),d!==void 0&&typeof d!=="function")throw Error("progressCb must be a function");let f=128*i,m=f/4,h=Math.pow(2,32);if(n<=1||(n&n-1)!==0||n>h)throw Error('"N" expected a power of 2, and 2^1 <= N <= 2^32');if(s<1||s>(h-1)*32/f)throw Error('"p" expected integer 1..((2^32 - 1) * 32) / (128 * r)');if(a<1||a>(h-1)*32)throw Error('"dkLen" expected integer 1..(2^32 - 1) * 32');let b=f*(n+s+1);if(b>u)throw Error('"maxmem" limit was hit: memUsed(128*r*(N+p+1))='+b+", maxmem="+u);let y=db(vt,e,t,{c:1,dkLen:f*s}),S=jf(y),x=jf(new Uint8Array(f*n)),_=jf(new Uint8Array(f)),A=()=>{};if(d){let O=2*n*s,L=Math.max(Math.floor(O/1e4),1),z=0;A=()=>{if(z++,d&&(!(z%L)||z===O))d(z/O)}}return{N:n,r:i,p:s,dkLen:a,blockSize32:m,V:x,B32:S,B:y,tmp:_,blockMixCb:A,asyncTick:c}}function f8(e,t,r,o,n){let i=db(vt,e,r,{c:1,dkLen:t});return cr(r,o,n),i}function pb(e,t,r){let{N:o,r:n,p:i,dkLen:s,blockSize32:a,V:c,B32:u,B:d,tmp:f,blockMixCb:m}=d8(e,t,r);Wy(u);for(let h=0;h<i;h++){let b=a*h;for(let y=0;y<a;y++)c[y]=u[b+y];for(let y=0,S=0;y<o-1;y++)fb(c,S,c,S+=a,n),m();fb(c,(o-1)*a,u,b,n),m();for(let y=0;y<o;y++){let S=(u[b+a-16]&o-1)>>>0;for(let x=0;x<a;x++)f[x]=u[b+x]^c[S*a+x];fb(f,0,u,b,n),m()}}return Wy(u),f8(e,s,d,c,f)}/*! noble-ciphers - MIT License (c) 2023 Paul Miller (paulmillr.com) */function p8(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name==="Uint8Array"&&"BYTES_PER_ELEMENT"in e&&e.BYTES_PER_ELEMENT===1}function Gf(e){if(typeof e!=="boolean")throw TypeError(`boolean expected, not ${e}`)}function ha(e){if(typeof e!=="number")throw TypeError("number expected, got "+typeof e);if(!Number.isSafeInteger(e)||e<0)throw RangeError("positive integer expected, got "+e)}function $t(e,t,r=""){let o=p8(e),n=e?.length,i=t!==void 0;if(!o||i&&n!==t){let s=r&&`"${r}" `,a=i?` of length ${t}`:"",c=o?`length=${n}`:`type=${typeof e}`,u=s+"expected Uint8Array"+a+", got "+c;if(!o)throw TypeError(u);throw RangeError(u)}return e}function mb(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 DR(e,t,r=!1){$t(e,void 0,"output");let o=t.outputLen;if(e.length<o)throw RangeError("digestInto() expects output buffer of length at least "+o);if(r&&!ga(e))throw Error("invalid output, must be aligned")}function Rn(e){return new Uint32Array(e.buffer,e.byteOffset,Math.floor(e.byteLength/4))}function nn(...e){for(let t=0;t<e.length;t++)e[t].fill(0)}function m8(e){return new DataView(e.buffer,e.byteOffset,e.byteLength)}var os=(()=>new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68)(),h8=(e)=>e<<24&4278190080|e<<8&16711680|e>>>8&65280|e>>>24&255;var g8=(e)=>{for(let t=0;t<e.length;t++)e[t]=h8(e[t]);return e},so=os?(e)=>e:g8;function LR(e,t){if(t==null||typeof t!=="object")throw Error("options must be defined");return Object.assign(e,t)}function jR(e,t){if(e.length!==t.length)return!1;let r=0;for(let o=0;o<e.length;o++)r|=e[o]^t[o];return r===0}function BR(e,t,r){let o=t,n=r||(()=>[]),i=(a,c)=>o(c,...n(a)).update(a).digest(),s=o(new Uint8Array(e),...n(new Uint8Array(0)));return i.outputLen=s.outputLen,i.blockLen=s.blockLen,i.create=(a,...c)=>o(a,...c),i}var ZR=(e,t)=>{function r(o,...n){if($t(o,void 0,"key"),e.nonceLength!==void 0){let d=n[0];$t(d,e.varSizeNonce?void 0:e.nonceLength,"nonce")}let i=e.tagLength;if(i&&n[1]!==void 0)$t(n[1],void 0,"AAD");let s=t(o,...n),a=(d,f)=>{if(f!==void 0){if(d!==2)throw Error("cipher output not supported");$t(f,void 0,"output")}},c=!1;return{encrypt(d,f){if(c)throw Error("cannot encrypt() twice with same key + nonce");return c=!0,$t(d),a(s.encrypt.length,f),s.encrypt(d,f)},decrypt(d,f){if($t(d),i&&d.length<i)throw Error('"ciphertext" expected length bigger than tagLength='+i);return a(s.decrypt.length,f),s.decrypt(d,f)}}}return Object.assign(r,e),r};function Nl(e,t,r=!0){if(t===void 0)return new Uint8Array(e);if($t(t,void 0,"output"),t.length!==e)throw Error('"output" expected Uint8Array of length '+e+", got: "+t.length);if(r&&!ga(t))throw Error("invalid output, must be aligned");return t}function UR(e,t,r){ha(e),ha(t),Gf(r);let o=new Uint8Array(16),n=m8(o);return n.setBigUint64(0,BigInt(t),r),n.setBigUint64(8,BigInt(e),r),o}function ga(e){return e.byteOffset%4===0}function ya(e){return Uint8Array.from($t(e))}var MR=(e)=>Uint8Array.from(e.split(""),(t)=>t.charCodeAt(0)),y8=(()=>so(Rn(MR("expand 16-byte k"))))(),b8=(()=>so(Rn(MR("expand 32-byte k"))))();function Je(e,t){return e<<t|e>>>32-t}var Dl=64,S8=16,hb=(()=>4294967295)(),qR=Uint32Array.of();function v8(e,t,r,o,n,i,s,a){let c=n.length,u=new Uint8Array(Dl),d=Rn(u),f=os&&ga(n)&&ga(i),m=f?Rn(n):qR,h=f?Rn(i):qR;if(!os){for(let b=0;b<c;s++){if(e(t,r,o,d,s,a),so(d),s>=hb)throw Error("arx: counter overflow");let y=Math.min(Dl,c-b);for(let S=0,x;S<y;S++)x=b+S,i[x]=n[x]^u[S];b+=y}return}for(let b=0;b<c;s++){if(e(t,r,o,d,s,a),s>=hb)throw Error("arx: counter overflow");let y=Math.min(Dl,c-b);if(f&&y===Dl){let S=b/4;if(b%4!==0)throw Error("arx: invalid block position");for(let x=0,_;x<S8;x++)_=S+x,h[_]=m[_]^d[x];b+=Dl;continue}for(let S=0,x;S<y;S++)x=b+S,i[x]=n[x]^u[S];b+=y}}function FR(e,t){let{allowShortKeys:r,extendNonceFn:o,counterLength:n,counterRight:i,rounds:s}=LR({allowShortKeys:!1,counterLength:8,counterRight:!1,rounds:20},t);if(typeof e!=="function")throw Error("core must be a function");return ha(n),ha(s),Gf(i),Gf(r),(a,c,u,d,f=0)=>{$t(a,void 0,"key"),$t(c,void 0,"nonce"),$t(u,void 0,"data");let m=u.length;if(d=Nl(m,d,!1),ha(f),f<0||f>=hb)throw Error("arx: counter overflow");let h=[],b=a.length,y,S;if(b===32)h.push(y=ya(a)),S=b8;else if(b===16&&r)y=new Uint8Array(32),y.set(a),y.set(a,16),S=y8,h.push(y);else throw $t(a,32,"arx key"),Error("invalid key size");if(!os||!ga(c))h.push(c=ya(c));let x=Rn(y);if(o){if(c.length!==24)throw Error("arx: extended nonce must be 24 bytes");let O=c.subarray(0,16);if(os)o(S,x,Rn(O),x);else{let L=so(Uint32Array.from(S));o(L,x,Rn(O),x),nn(L),so(x)}c=c.subarray(16)}else if(!os)so(x);let _=16-n;if(_!==c.length)throw Error(`arx: nonce must be ${_} or 16 bytes`);if(_!==12){let O=new Uint8Array(12);O.set(c,i?0:12-c.length),c=O,h.push(c)}let A=so(Rn(c));try{return v8(e,S,x,A,u,d,f,s),d}finally{nn(...h)}}}function Mt(e,t){return e[t++]&255|(e[t++]&255)<<8}class JR{blockLen=16;outputLen=16;buffer=new Uint8Array(16);r=new Uint16Array(10);h=new Uint16Array(10);pad=new Uint16Array(8);pos=0;finished=!1;destroyed=!1;constructor(e){e=ya($t(e,32,"key"));let t=Mt(e,0),r=Mt(e,2),o=Mt(e,4),n=Mt(e,6),i=Mt(e,8),s=Mt(e,10),a=Mt(e,12),c=Mt(e,14);this.r[0]=t&8191,this.r[1]=(t>>>13|r<<3)&8191,this.r[2]=(r>>>10|o<<6)&7939,this.r[3]=(o>>>7|n<<9)&8191,this.r[4]=(n>>>4|i<<12)&255,this.r[5]=i>>>1&8190,this.r[6]=(i>>>14|s<<2)&8191,this.r[7]=(s>>>11|a<<5)&8065,this.r[8]=(a>>>8|c<<8)&8191,this.r[9]=c>>>5&127;for(let u=0;u<8;u++)this.pad[u]=Mt(e,16+2*u)}process(e,t,r=!1){let o=r?0:2048,{h:n,r:i}=this,s=i[0],a=i[1],c=i[2],u=i[3],d=i[4],f=i[5],m=i[6],h=i[7],b=i[8],y=i[9],S=Mt(e,t+0),x=Mt(e,t+2),_=Mt(e,t+4),A=Mt(e,t+6),O=Mt(e,t+8),L=Mt(e,t+10),z=Mt(e,t+12),K=Mt(e,t+14),P=n[0]+(S&8191),W=n[1]+((S>>>13|x<<3)&8191),ee=n[2]+((x>>>10|_<<6)&8191),B=n[3]+((_>>>7|A<<9)&8191),R=n[4]+((A>>>4|O<<12)&8191),j=n[5]+(O>>>1&8191),I=n[6]+((O>>>14|L<<2)&8191),T=n[7]+((L>>>11|z<<5)&8191),k=n[8]+((z>>>8|K<<8)&8191),M=n[9]+(K>>>5|o),N=0,H=N+P*s+W*(5*y)+ee*(5*b)+B*(5*h)+R*(5*m);N=H>>>13,H&=8191,H+=j*(5*f)+I*(5*d)+T*(5*u)+k*(5*c)+M*(5*a),N+=H>>>13,H&=8191;let G=N+P*a+W*s+ee*(5*y)+B*(5*b)+R*(5*h);N=G>>>13,G&=8191,G+=j*(5*m)+I*(5*f)+T*(5*d)+k*(5*u)+M*(5*c),N+=G>>>13,G&=8191;let re=N+P*c+W*a+ee*s+B*(5*y)+R*(5*b);N=re>>>13,re&=8191,re+=j*(5*h)+I*(5*m)+T*(5*f)+k*(5*d)+M*(5*u),N+=re>>>13,re&=8191;let ae=N+P*u+W*c+ee*a+B*s+R*(5*y);N=ae>>>13,ae&=8191,ae+=j*(5*b)+I*(5*h)+T*(5*m)+k*(5*f)+M*(5*d),N+=ae>>>13,ae&=8191;let pe=N+P*d+W*u+ee*c+B*a+R*s;N=pe>>>13,pe&=8191,pe+=j*(5*y)+I*(5*b)+T*(5*h)+k*(5*m)+M*(5*f),N+=pe>>>13,pe&=8191;let be=N+P*f+W*d+ee*u+B*c+R*a;N=be>>>13,be&=8191,be+=j*s+I*(5*y)+T*(5*b)+k*(5*h)+M*(5*m),N+=be>>>13,be&=8191;let ve=N+P*m+W*f+ee*d+B*u+R*c;N=ve>>>13,ve&=8191,ve+=j*a+I*s+T*(5*y)+k*(5*b)+M*(5*h),N+=ve>>>13,ve&=8191;let ke=N+P*h+W*m+ee*f+B*d+R*u;N=ke>>>13,ke&=8191,ke+=j*c+I*a+T*s+k*(5*y)+M*(5*b),N+=ke>>>13,ke&=8191;let Ie=N+P*b+W*h+ee*m+B*f+R*d;N=Ie>>>13,Ie&=8191,Ie+=j*u+I*c+T*a+k*s+M*(5*y),N+=Ie>>>13,Ie&=8191;let we=N+P*y+W*b+ee*h+B*m+R*f;N=we>>>13,we&=8191,we+=j*d+I*u+T*c+k*a+M*s,N+=we>>>13,we&=8191,N=(N<<2)+N|0,N=N+H|0,H=N&8191,N=N>>>13,G+=N,n[0]=H,n[1]=G,n[2]=re,n[3]=ae,n[4]=pe,n[5]=be,n[6]=ve,n[7]=ke,n[8]=Ie,n[9]=we}finalize(){let{h:e,pad:t}=this,r=new Uint16Array(10),o=e[1]>>>13;e[1]&=8191;for(let s=2;s<10;s++)e[s]+=o,o=e[s]>>>13,e[s]&=8191;e[0]+=o*5,o=e[0]>>>13,e[0]&=8191,e[1]+=o,o=e[1]>>>13,e[1]&=8191,e[2]+=o,r[0]=e[0]+5,o=r[0]>>>13,r[0]&=8191;for(let s=1;s<10;s++)r[s]=e[s]+o,o=r[s]>>>13,r[s]&=8191;r[9]-=8192;let n=(o^1)-1;for(let s=0;s<10;s++)r[s]&=n;n=~n;for(let s=0;s<10;s++)e[s]=e[s]&n|r[s];e[0]=(e[0]|e[1]<<13)&65535,e[1]=(e[1]>>>3|e[2]<<10)&65535,e[2]=(e[2]>>>6|e[3]<<7)&65535,e[3]=(e[3]>>>9|e[4]<<4)&65535,e[4]=(e[4]>>>12|e[5]<<1|e[6]<<14)&65535,e[5]=(e[6]>>>2|e[7]<<11)&65535,e[6]=(e[7]>>>5|e[8]<<8)&65535,e[7]=(e[8]>>>8|e[9]<<5)&65535;let i=e[0]+t[0];e[0]=i&65535;for(let s=1;s<8;s++)i=(e[s]+t[s]|0)+(i>>>16)|0,e[s]=i&65535;nn(r)}update(e){mb(this),$t(e),e=ya(e);let{buffer:t,blockLen:r}=this,o=e.length;for(let n=0;n<o;){let i=Math.min(r-this.pos,o-n);if(i===r){for(;r<=o-n;n+=r)this.process(e,n);continue}if(t.set(e.subarray(n,n+i),this.pos),this.pos+=i,n+=i,this.pos===r)this.process(t,0,!1),this.pos=0}return this}destroy(){this.destroyed=!0,nn(this.h,this.r,this.buffer,this.pad)}digestInto(e){mb(this),DR(e,this),this.finished=!0;let{buffer:t,h:r}=this,{pos:o}=this;if(o){t[o++]=1;for(;o<16;o++)t[o]=0;this.process(t,0,!0)}this.finalize();let n=0;for(let i=0;i<8;i++)e[n++]=r[i]>>>0,e[n++]=r[i]>>>8}digest(){let{buffer:e,outputLen:t}=this;this.digestInto(e);let r=e.slice(0,t);return this.destroy(),r}}var KR=BR(32,(e)=>new JR(e));function w8(e,t,r,o,n,i=20){let s=e[0],a=e[1],c=e[2],u=e[3],d=t[0],f=t[1],m=t[2],h=t[3],b=t[4],y=t[5],S=t[6],x=t[7],_=n,A=r[0],O=r[1],L=r[2],z=s,K=a,P=c,W=u,ee=d,B=f,R=m,j=h,I=b,T=y,k=S,M=x,N=_,H=A,G=O,re=L;for(let pe=0;pe<i;pe+=2)z=z+ee|0,N=Je(N^z,16),I=I+N|0,ee=Je(ee^I,12),z=z+ee|0,N=Je(N^z,8),I=I+N|0,ee=Je(ee^I,7),K=K+B|0,H=Je(H^K,16),T=T+H|0,B=Je(B^T,12),K=K+B|0,H=Je(H^K,8),T=T+H|0,B=Je(B^T,7),P=P+R|0,G=Je(G^P,16),k=k+G|0,R=Je(R^k,12),P=P+R|0,G=Je(G^P,8),k=k+G|0,R=Je(R^k,7),W=W+j|0,re=Je(re^W,16),M=M+re|0,j=Je(j^M,12),W=W+j|0,re=Je(re^W,8),M=M+re|0,j=Je(j^M,7),z=z+B|0,re=Je(re^z,16),k=k+re|0,B=Je(B^k,12),z=z+B|0,re=Je(re^z,8),k=k+re|0,B=Je(B^k,7),K=K+R|0,N=Je(N^K,16),M=M+N|0,R=Je(R^M,12),K=K+R|0,N=Je(N^K,8),M=M+N|0,R=Je(R^M,7),P=P+j|0,H=Je(H^P,16),I=I+H|0,j=Je(j^I,12),P=P+j|0,H=Je(H^P,8),I=I+H|0,j=Je(j^I,7),W=W+ee|0,G=Je(G^W,16),T=T+G|0,ee=Je(ee^T,12),W=W+ee|0,G=Je(G^W,8),T=T+G|0,ee=Je(ee^T,7);let ae=0;o[ae++]=s+z|0,o[ae++]=a+K|0,o[ae++]=c+P|0,o[ae++]=u+W|0,o[ae++]=d+ee|0,o[ae++]=f+B|0,o[ae++]=m+R|0,o[ae++]=h+j|0,o[ae++]=b+I|0,o[ae++]=y+T|0,o[ae++]=S+k|0,o[ae++]=x+M|0,o[ae++]=_+N|0,o[ae++]=A+H|0,o[ae++]=O+G|0,o[ae++]=L+re|0}var x8=FR(w8,{counterRight:!1,counterLength:4,allowShortKeys:!1});var _8=new Uint8Array(16),HR=(e,t)=>{e.update(t);let r=t.length%16;if(r)e.update(_8.subarray(r))},E8=new Uint8Array(32);function VR(e,t,r,o,n){if(n!==void 0)$t(n,void 0,"AAD");let i=e(t,r,E8),s=UR(o.length,n?n.length:0,!0),a=KR.create(i);if(n)HR(a,n);HR(a,o),a.update(s);let c=a.digest();return nn(i,s),c}var I8=(e)=>(t,r,o)=>({encrypt(i,s){let a=i.length;s=Nl(a+16,s,!1),s.set(i);let c=s.subarray(0,-16);e(t,r,c,c,1);let u=VR(e,t,r,c,o);return s.set(u,a),nn(u),s},decrypt(i,s){s=Nl(i.length-16,s,!1);let a=i.subarray(0,-16),c=i.subarray(-16),u=VR(e,t,r,a,o);if(!jR(c,u))throw nn(u),Error("invalid tag");return s.set(i.subarray(0,-16)),e(t,r,s,s,1),nn(u),s}}),qr=ZR({blockSize:64,nonceLength:12,tagLength:16},I8(x8));/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */function ba(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name==="Uint8Array"}function Dt(e,t=""){if(!Number.isSafeInteger(e)||e<0){let r=t&&`"${t}" `;throw Error(`${r}expected integer >= 0, got ${e}`)}}function Te(e,t,r=""){let o=ba(e),n=e?.length,i=t!==void 0;if(!o||i&&n!==t){let s=r&&`"${r}" `,a=i?` of length ${t}`:"",c=o?`length=${n}`:`type=${typeof e}`;throw Error(s+"expected Uint8Array"+a+", got "+c)}return e}function Mr(e){if(typeof e!=="function"||typeof e.create!=="function")throw Error("Hash must wrapped by utils.createHasher");Dt(e.outputLen),Dt(e.blockLen)}function co(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 Qf(e,t){Te(e,void 0,"digestInto() output");let r=t.outputLen;if(e.length<r)throw Error('"digestInto() output" expected to be of length >='+r)}function Yf(e){return new Uint32Array(e.buffer,e.byteOffset,Math.floor(e.byteLength/4))}function vr(...e){for(let t=0;t<e.length;t++)e[t].fill(0)}function Xf(e){return new DataView(e.buffer,e.byteOffset,e.byteLength)}function on(e,t){return e<<32-t|e>>>t}var k8=(()=>new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68)();function A8(e){return e<<24&4278190080|e<<8&16711680|e>>>8&65280|e>>>24&255}function T8(e){for(let t=0;t<e.length;t++)e[t]=A8(e[t]);return e}var gb=k8?(e)=>e:T8,GR=(()=>typeof Uint8Array.from([]).toHex==="function"&&typeof Uint8Array.fromHex==="function")(),$8=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,"0"));function is(e){if(Te(e),GR)return e.toHex();let t="";for(let r=0;r<e.length;r++)t+=$8[e[r]];return t}var ao={_0:48,_9:57,A:65,F:70,a:97,f:102};function WR(e){if(e>=ao._0&&e<=ao._9)return e-ao._0;if(e>=ao.A&&e<=ao.F)return e-(ao.A-10);if(e>=ao.a&&e<=ao.f)return e-(ao.a-10);return}function ss(e){if(typeof e!=="string")throw Error("hex string expected, got "+typeof e);if(GR)return Uint8Array.fromHex(e);let t=e.length,r=t/2;if(t%2)throw Error("hex string expected, got unpadded hex of length "+t);let o=new Uint8Array(r);for(let n=0,i=0;n<r;n++,i+=2){let s=WR(e.charCodeAt(i)),a=WR(e.charCodeAt(i+1));if(s===void 0||a===void 0){let c=e[i]+e[i+1];throw Error('hex string expected, got non-hex character "'+c+'" at index '+i)}o[n]=s*16+a}return o}function Et(...e){let t=0;for(let o=0;o<e.length;o++){let n=e[o];Te(n),t+=n.length}let r=new Uint8Array(t);for(let o=0,n=0;o<e.length;o++){let i=e[o];r.set(i,n),n+=i.length}return r}function Sa(e,t={}){let r=(n,i)=>e(i).update(n).digest(),o=e(void 0);return r.outputLen=o.outputLen,r.blockLen=o.blockLen,r.create=(n)=>e(n),Object.assign(r,t),Object.freeze(r)}function Vo(e=32){let t=typeof globalThis==="object"?globalThis.crypto:null;if(typeof t?.getRandomValues!=="function")throw Error("crypto.getRandomValues must be defined");return t.getRandomValues(new Uint8Array(e))}var Wo=(e)=>({oid:Uint8Array.from([6,9,96,134,72,1,101,3,4,2,e])});/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */var bb=BigInt(0),yb=BigInt(1);function Ll(e,t=""){if(typeof e!=="boolean"){let r=t&&`"${t}" `;throw Error(r+"expected boolean, got type="+typeof e)}return e}function QR(e){if(typeof e==="bigint"){if(!ep(e))throw Error("positive bigint expected, got "+e)}else Dt(e);return e}function jl(e){let t=QR(e).toString(16);return t.length&1?"0"+t:t}function YR(e){if(typeof e!=="string")throw Error("hex string expected, got "+typeof e);return e===""?bb:BigInt("0x"+e)}function Go(e){return YR(is(e))}function Qo(e){return YR(is(tp(Te(e)).reverse()))}function va(e,t){Dt(t),e=QR(e);let r=ss(e.toString(16).padStart(t*2,"0"));if(r.length!==t)throw Error("number too large");return r}function Bl(e,t){return va(e,t).reverse()}function tp(e){return Uint8Array.from(e)}function Yo(e){return Uint8Array.from(e,(t,r)=>{let o=t.charCodeAt(0);if(t.length!==1||o>127)throw Error(`string contains non-ASCII character "${e[r]}" with code ${o} at position ${r}`);return o})}var ep=(e)=>typeof e==="bigint"&&bb<=e;function R8(e,t,r){return ep(e)&&ep(t)&&ep(r)&&t<=e&&e<r}function Zl(e,t,r,o){if(!R8(t,r,o))throw Error("expected valid "+e+": "+r+" <= n < "+o+", got "+t)}function Sb(e){let t;for(t=0;e>bb;e>>=yb,t+=1);return t}var Ul=(e)=>(yb<<BigInt(e))-yb;function XR(e,t,r){if(Dt(e,"hashLen"),Dt(t,"qByteLen"),typeof r!=="function")throw Error("hmacFn must be a function");let o=(S)=>new Uint8Array(S),n=Uint8Array.of(),i=Uint8Array.of(0),s=Uint8Array.of(1),a=1000,c=o(e),u=o(e),d=0,f=()=>{c.fill(1),u.fill(0),d=0},m=(...S)=>r(u,Et(c,...S)),h=(S=n)=>{if(u=m(i,S),c=m(),S.length===0)return;u=m(s,S),c=m()},b=()=>{if(d++>=a)throw Error("drbg: tried max amount of iterations");let S=0,x=[];while(S<t){c=m();let _=c.slice();x.push(_),S+=c.length}return Et(...x)};return(S,x)=>{f(),h(S);let _=void 0;while(!(_=x(b())))h();return f(),_}}function as(e,t={},r={}){if(!e||typeof e!=="object")throw Error("expected valid options object");function o(i,s,a){let c=e[i];if(a&&c===void 0)return;let u=typeof c;if(u!==s||c===null)throw Error(`param "${i}" is invalid: expected ${s}, got ${u}`)}let n=(i,s)=>Object.entries(i).forEach(([a,c])=>o(a,c,s));n(t,!1),n(r,!0)}function vb(e){let t=new WeakMap;return(r,...o)=>{let n=t.get(r);if(n!==void 0)return n;let i=e(r,...o);return t.set(r,i),i}}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */var ur=BigInt(0),Xt=BigInt(1),cs=BigInt(2),rO=BigInt(3),nO=BigInt(4),oO=BigInt(5),O8=BigInt(7),iO=BigInt(8),C8=BigInt(9),sO=BigInt(16);function lr(e,t){let r=e%t;return r>=ur?r:t+r}function Fr(e,t,r){let o=e;while(t-- >ur)o*=o,o%=r;return o}function eO(e,t){if(e===ur)throw Error("invert: expected non-zero number");if(t<=ur)throw Error("invert: expected positive modulus, got "+t);let r=lr(e,t),o=t,n=ur,i=Xt,s=Xt,a=ur;while(r!==ur){let u=o/r,d=o%r,f=n-s*u,m=i-a*u;o=r,r=d,n=s,i=a,s=f,a=m}if(o!==Xt)throw Error("invert: does not exist");return lr(n,t)}function wb(e,t,r){if(!e.eql(e.sqr(t),r))throw Error("Cannot find square root")}function aO(e,t){let r=(e.ORDER+Xt)/nO,o=e.pow(t,r);return wb(e,o,t),o}function P8(e,t){let r=(e.ORDER-oO)/iO,o=e.mul(t,cs),n=e.pow(o,r),i=e.mul(t,n),s=e.mul(e.mul(i,cs),n),a=e.mul(i,e.sub(s,e.ONE));return wb(e,a,t),a}function z8(e){let t=rp(e),r=cO(e),o=r(t,t.neg(t.ONE)),n=r(t,o),i=r(t,t.neg(o)),s=(e+O8)/sO;return(a,c)=>{let u=a.pow(c,s),d=a.mul(u,o),f=a.mul(u,n),m=a.mul(u,i),h=a.eql(a.sqr(d),c),b=a.eql(a.sqr(f),c);u=a.cmov(u,d,h),d=a.cmov(m,f,b);let y=a.eql(a.sqr(d),c),S=a.cmov(u,d,y);return wb(a,S,c),S}}function cO(e){if(e<rO)throw Error("sqrt is not defined for small field");let t=e-Xt,r=0;while(t%cs===ur)t/=cs,r++;let o=cs,n=rp(e);while(tO(n,o)===1)if(o++>1000)throw Error("Cannot find square root: probably non-prime P");if(r===1)return aO;let i=n.pow(o,t),s=(t+Xt)/cs;return function(c,u){if(c.is0(u))return u;if(tO(c,u)!==1)throw Error("Cannot find square root");let d=r,f=c.mul(c.ONE,i),m=c.pow(u,t),h=c.pow(u,s);while(!c.eql(m,c.ONE)){if(c.is0(m))return c.ZERO;let b=1,y=c.sqr(m);while(!c.eql(y,c.ONE))if(b++,y=c.sqr(y),b===d)throw Error("Cannot find square root");let S=Xt<<BigInt(d-b-1),x=c.pow(f,S);d=b,f=c.sqr(x),m=c.mul(m,f),h=c.mul(h,x)}return h}}function N8(e){if(e%nO===rO)return aO;if(e%iO===oO)return P8;if(e%sO===C8)return z8(e);return cO(e)}var D8=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function xb(e){let t={ORDER:"bigint",BYTES:"number",BITS:"number"},r=D8.reduce((o,n)=>(o[n]="function",o),t);return as(e,r),e}function L8(e,t,r){if(r<ur)throw Error("invalid exponent, negatives unsupported");if(r===ur)return e.ONE;if(r===Xt)return t;let o=e.ONE,n=t;while(r>ur){if(r&Xt)o=e.mul(o,n);n=e.sqr(n),r>>=Xt}return o}function ql(e,t,r=!1){let o=Array(t.length).fill(r?e.ZERO:void 0),n=t.reduce((s,a,c)=>{if(e.is0(a))return s;return o[c]=s,e.mul(s,a)},e.ONE),i=e.inv(n);return t.reduceRight((s,a,c)=>{if(e.is0(a))return s;return o[c]=e.mul(s,o[c]),e.mul(s,a)},i),o}function tO(e,t){let r=(e.ORDER-Xt)/cs,o=e.pow(t,r),n=e.eql(o,e.ONE),i=e.eql(o,e.ZERO),s=e.eql(o,e.neg(e.ONE));if(!n&&!i&&!s)throw Error("invalid Legendre symbol result");return n?1:i?0:-1}function j8(e,t){if(t!==void 0)Dt(t);let r=t!==void 0?t:e.toString(2).length,o=Math.ceil(r/8);return{nBitLength:r,nByteLength:o}}class lO{ORDER;BITS;BYTES;isLE;ZERO=ur;ONE=Xt;_lengths;_sqrt;_mod;constructor(e,t={}){if(e<=ur)throw Error("invalid field: expected ORDER > 0, got "+e);let r=void 0;if(this.isLE=!1,t!=null&&typeof t==="object"){if(typeof t.BITS==="number")r=t.BITS;if(typeof t.sqrt==="function")this.sqrt=t.sqrt;if(typeof t.isLE==="boolean")this.isLE=t.isLE;if(t.allowedLengths)this._lengths=t.allowedLengths?.slice();if(typeof t.modFromBytes==="boolean")this._mod=t.modFromBytes}let{nBitLength:o,nByteLength:n}=j8(e,r);if(n>2048)throw Error("invalid field: expected ORDER of <= 2048 bytes");this.ORDER=e,this.BITS=o,this.BYTES=n,this._sqrt=void 0,Object.preventExtensions(this)}create(e){return lr(e,this.ORDER)}isValid(e){if(typeof e!=="bigint")throw Error("invalid field element: expected bigint, got "+typeof e);return ur<=e&&e<this.ORDER}is0(e){return e===ur}isValidNot0(e){return!this.is0(e)&&this.isValid(e)}isOdd(e){return(e&Xt)===Xt}neg(e){return lr(-e,this.ORDER)}eql(e,t){return e===t}sqr(e){return lr(e*e,this.ORDER)}add(e,t){return lr(e+t,this.ORDER)}sub(e,t){return lr(e-t,this.ORDER)}mul(e,t){return lr(e*t,this.ORDER)}pow(e,t){return L8(this,e,t)}div(e,t){return lr(e*eO(t,this.ORDER),this.ORDER)}sqrN(e){return e*e}addN(e,t){return e+t}subN(e,t){return e-t}mulN(e,t){return e*t}inv(e){return eO(e,this.ORDER)}sqrt(e){if(!this._sqrt)this._sqrt=N8(this.ORDER);return this._sqrt(this,e)}toBytes(e){return this.isLE?Bl(e,this.BYTES):va(e,this.BYTES)}fromBytes(e,t=!1){Te(e);let{_lengths:r,BYTES:o,isLE:n,ORDER:i,_mod:s}=this;if(r){if(!r.includes(e.length)||e.length>o)throw Error("Field.fromBytes: expected "+r+" bytes, got "+e.length);let c=new Uint8Array(o);c.set(e,n?0:c.length-e.length),e=c}if(e.length!==o)throw Error("Field.fromBytes: expected "+o+" bytes, got "+e.length);let a=n?Qo(e):Go(e);if(s)a=lr(a,i);if(!t){if(!this.isValid(a))throw Error("invalid field element: outside of range 0..ORDER")}return a}invertBatch(e){return ql(this,e)}cmov(e,t,r){return r?t:e}}function rp(e,t={}){return new lO(e,t)}function uO(e){if(typeof e!=="bigint")throw Error("field order must be bigint");let t=e.toString(2).length;return Math.ceil(t/8)}function _b(e){let t=uO(e);return t+Math.ceil(t/2)}function dO(e,t,r=!1){Te(e);let o=e.length,n=uO(t),i=_b(t);if(o<16||o<i||o>1024)throw Error("expected "+i+"-1024 bytes of input, got "+o);let s=r?Qo(e):Go(e),a=lr(s,t-Xt)+Xt;return r?Bl(a,n):va(a,n)}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */var wa=BigInt(0),ls=BigInt(1);function Ml(e,t){let r=t.negate();return e?r:t}function Ab(e,t){let r=ql(e.Fp,t.map((o)=>o.Z));return t.map((o,n)=>e.fromAffine(o.toAffine(r[n])))}function hO(e,t){if(!Number.isSafeInteger(e)||e<=0||e>t)throw Error("invalid window size, expected [1.."+t+"], got W="+e)}function Eb(e,t){hO(e,t);let r=Math.ceil(t/e)+1,o=2**(e-1),n=2**e,i=Ul(e),s=BigInt(e);return{windows:r,windowSize:o,mask:i,maxNumber:n,shiftBy:s}}function fO(e,t,r){let{windowSize:o,mask:n,maxNumber:i,shiftBy:s}=r,a=Number(e&n),c=e>>s;if(a>o)a-=i,c+=ls;let u=t*o,d=u+Math.abs(a)-1,f=a===0,m=a<0,h=t%2!==0;return{nextN:c,offset:d,isZero:f,isNeg:m,isNegF:h,offsetF:u}}var Ib=new WeakMap,gO=new WeakMap;function kb(e){return gO.get(e)||1}function pO(e){if(e!==wa)throw Error("invalid wNAF")}class Tb{BASE;ZERO;Fn;bits;constructor(e,t){this.BASE=e.BASE,this.ZERO=e.ZERO,this.Fn=e.Fn,this.bits=t}_unsafeLadder(e,t,r=this.ZERO){let o=e;while(t>wa){if(t&ls)r=r.add(o);o=o.double(),t>>=ls}return r}precomputeWindow(e,t){let{windows:r,windowSize:o}=Eb(t,this.bits),n=[],i=e,s=i;for(let a=0;a<r;a++){s=i,n.push(s);for(let c=1;c<o;c++)s=s.add(i),n.push(s);i=s.double()}return n}wNAF(e,t,r){if(!this.Fn.isValid(r))throw Error("invalid scalar");let o=this.ZERO,n=this.BASE,i=Eb(e,this.bits);for(let s=0;s<i.windows;s++){let{nextN:a,offset:c,isZero:u,isNeg:d,isNegF:f,offsetF:m}=fO(r,s,i);if(r=a,u)n=n.add(Ml(f,t[m]));else o=o.add(Ml(d,t[c]))}return pO(r),{p:o,f:n}}wNAFUnsafe(e,t,r,o=this.ZERO){let n=Eb(e,this.bits);for(let i=0;i<n.windows;i++){if(r===wa)break;let{nextN:s,offset:a,isZero:c,isNeg:u}=fO(r,i,n);if(r=s,c)continue;else{let d=t[a];o=o.add(u?d.negate():d)}}return pO(r),o}getPrecomputes(e,t,r){let o=Ib.get(t);if(!o){if(o=this.precomputeWindow(t,e),e!==1){if(typeof r==="function")o=r(o);Ib.set(t,o)}}return o}cached(e,t,r){let o=kb(e);return this.wNAF(o,this.getPrecomputes(o,e,r),t)}unsafe(e,t,r,o){let n=kb(e);if(n===1)return this._unsafeLadder(e,t,o);return this.wNAFUnsafe(n,this.getPrecomputes(n,e,r),t,o)}createCache(e,t){hO(t,this.bits),gO.set(e,t),Ib.delete(e)}hasCache(e){return kb(e)!==1}}function yO(e,t,r,o){let n=t,i=e.ZERO,s=e.ZERO;while(r>wa||o>wa){if(r&ls)i=i.add(n);if(o&ls)s=s.add(n);n=n.double(),r>>=ls,o>>=ls}return{p1:i,p2:s}}function mO(e,t,r){if(t){if(t.ORDER!==e)throw Error("Field.ORDER must match order: Fp == p, Fn == n");return xb(t),t}else return rp(e,{isLE:r})}function bO(e,t,r={},o){if(o===void 0)o=e==="edwards";if(!t||typeof t!=="object")throw Error(`expected valid ${e} CURVE object`);for(let c of["p","n","h"]){let u=t[c];if(!(typeof u==="bigint"&&u>wa))throw Error(`CURVE.${c} must be positive bigint`)}let n=mO(t.p,r.Fp,o),i=mO(t.n,r.Fn,o),a=["Gx","Gy","a",e==="weierstrass"?"b":"d"];for(let c of a)if(!n.isValid(t[c]))throw Error(`CURVE.${c} must be valid field element of CURVE.Fp`);return t=Object.freeze(Object.assign({},t)),{CURVE:t,Fp:n,Fn:i}}function np(e,t){return function(o){let n=e(o);return{secretKey:n,publicKey:t(n)}}}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */var Fl=BigInt(0),xa=BigInt(1),op=BigInt(2);function B8(e){return as(e,{adjustScalarBytes:"function",powPminus2:"function"}),Object.freeze({...e})}function SO(e){let t=B8(e),{P:r,type:o,adjustScalarBytes:n,powPminus2:i,randomBytes:s}=t,a=o==="x25519";if(!a&&o!=="x448")throw Error("invalid type");let c=s||Vo,u=a?255:448,d=a?32:56,f=a?BigInt(9):BigInt(5),m=a?BigInt(121665):BigInt(39081),h=a?op**BigInt(254):op**BigInt(447),b=a?BigInt(8)*op**BigInt(251)-xa:BigInt(4)*op**BigInt(445)-xa,y=h+b+xa,S=(I)=>lr(I,r),x=_(f);function _(I){return Bl(S(I),d)}function A(I){let T=tp(Te(I,d,"uCoordinate"));if(a)T[31]&=127;return S(Qo(T))}function O(I){return Qo(n(tp(Te(I,d,"scalar"))))}function L(I,T){let k=ee(A(T),O(I));if(k===Fl)throw Error("invalid private or public key received");return _(k)}function z(I){return L(I,x)}let K=z,P=L;function W(I,T,k){let M=S(I*(T-k));return T=S(T-M),k=S(k+M),{x_2:T,x_3:k}}function ee(I,T){Zl("u",I,Fl,r),Zl("scalar",T,h,y);let k=T,M=I,N=xa,H=Fl,G=I,re=xa,ae=Fl;for(let be=BigInt(u-1);be>=Fl;be--){let ve=k>>be&xa;ae^=ve,{x_2:N,x_3:G}=W(ae,N,G),{x_2:H,x_3:re}=W(ae,H,re),ae=ve;let ke=N+H,Ie=S(ke*ke),we=N-H,Ue=S(we*we),De=Ie-Ue,Qe=G+re,bt=G-re,Tt=S(bt*ke),Nt=S(Qe*we),lt=Tt+Nt,$r=Tt-Nt;G=S(lt*lt),re=S(M*S($r*$r)),N=S(Ie*Ue),H=S(De*(Ie+S(m*De)))}({x_2:N,x_3:G}=W(ae,N,G)),{x_2:H,x_3:re}=W(ae,H,re);let pe=i(H);return S(N*pe)}let B={secretKey:d,publicKey:d,seed:d},R=(I=c(d))=>(Te(I,B.seed,"seed"),I),j={randomSecretKey:R};return Object.freeze({keygen:np(R,K),getSharedSecret:P,getPublicKey:K,scalarMult:L,scalarMultBase:z,utils:j,GuBytes:x.slice(),lengths:B})}class $b{oHash;iHash;blockLen;outputLen;finished=!1;destroyed=!1;constructor(e,t){if(Mr(e),Te(t,void 0,"key"),this.iHash=e.create(),typeof this.iHash.update!=="function")throw Error("Expected instance of class which extends utils.Hash");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;let r=this.blockLen,o=new Uint8Array(r);o.set(t.length>r?e.create().update(t).digest():t);for(let n=0;n<o.length;n++)o[n]^=54;this.iHash.update(o),this.oHash=e.create();for(let n=0;n<o.length;n++)o[n]^=106;this.oHash.update(o),vr(o)}update(e){return co(this),this.iHash.update(e),this}digestInto(e){co(this),Te(e,this.outputLen,"output"),this.finished=!0,this.iHash.digestInto(e),this.oHash.update(e),this.oHash.digestInto(e),this.destroy()}digest(){let e=new Uint8Array(this.oHash.outputLen);return this.digestInto(e),e}_cloneInto(e){e||=Object.create(Object.getPrototypeOf(this),{});let{oHash:t,iHash:r,finished:o,destroyed:n,blockLen:i,outputLen:s}=this;return e=e,e.finished=o,e.destroyed=n,e.blockLen=i,e.outputLen=s,e.oHash=t._cloneInto(e.oHash),e.iHash=r._cloneInto(e.iHash),e}clone(){return this._cloneInto()}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}}var _a=(e,t,r)=>new $b(e,t).update(r).digest();_a.create=(e,t)=>new $b(e,t);/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */var vO=(e,t)=>(e+(e>=0?t:-t)/xO)/t;function Z8(e,t,r){let[[o,n],[i,s]]=t,a=vO(s*e,r),c=vO(-n*e,r),u=e-a*o-c*i,d=-a*n-c*s,f=u<lo,m=d<lo;if(f)u=-u;if(m)d=-d;let h=Ul(Math.ceil(Sb(r)/2))+Ea;if(u<lo||u>=h||d<lo||d>=h)throw Error("splitScalar (endomorphism): failed, k="+e);return{k1neg:f,k1:u,k2neg:m,k2:d}}function Ob(e){if(!["compact","recovered","der"].includes(e))throw Error('Signature format must be "compact", "recovered", or "der"');return e}function Rb(e,t){let r={};for(let o of Object.keys(t))r[o]=e[o]===void 0?t[o]:e[o];if(Ll(r.lowS,"lowS"),Ll(r.prehash,"prehash"),r.format!==void 0)Ob(r.format);return r}class wO extends Error{constructor(e=""){super(e)}}var Xo={Err:wO,_tlv:{encode:(e,t)=>{let{Err:r}=Xo;if(e<0||e>256)throw new r("tlv.encode: wrong tag");if(t.length&1)throw new r("tlv.encode: unpadded data");let o=t.length/2,n=jl(o);if(n.length/2&128)throw new r("tlv.encode: long form length too big");let i=o>127?jl(n.length/2|128):"";return jl(e)+i+n+t},decode(e,t){let{Err:r}=Xo,o=0;if(e<0||e>256)throw new r("tlv.encode: wrong tag");if(t.length<2||t[o++]!==e)throw new r("tlv.decode: wrong tlv");let n=t[o++],i=!!(n&128),s=0;if(!i)s=n;else{let c=n&127;if(!c)throw new r("tlv.decode(long): indefinite length not supported");if(c>4)throw new r("tlv.decode(long): byte length is too big");let u=t.subarray(o,o+c);if(u.length!==c)throw new r("tlv.decode: length bytes not complete");if(u[0]===0)throw new r("tlv.decode(long): zero leftmost byte");for(let d of u)s=s<<8|d;if(o+=c,s<128)throw new r("tlv.decode(long): not minimal encoding")}let a=t.subarray(o,o+s);if(a.length!==s)throw new r("tlv.decode: wrong value length");return{v:a,l:t.subarray(o+s)}}},_int:{encode(e){let{Err:t}=Xo;if(e<lo)throw new t("integer: negative integers are not allowed");let r=jl(e);if(Number.parseInt(r[0],16)&8)r="00"+r;if(r.length&1)throw new t("unexpected DER parsing assertion: unpadded hex");return r},decode(e){let{Err:t}=Xo;if(e[0]&128)throw new t("invalid signature integer: negative");if(e[0]===0&&!(e[1]&128))throw new t("invalid signature integer: unnecessary leading zero");return Go(e)}},toSig(e){let{Err:t,_int:r,_tlv:o}=Xo,n=Te(e,void 0,"signature"),{v:i,l:s}=o.decode(48,n);if(s.length)throw new t("invalid signature: left bytes after parsing");let{v:a,l:c}=o.decode(2,i),{v:u,l:d}=o.decode(2,c);if(d.length)throw new t("invalid signature: left bytes after parsing");return{r:r.decode(a),s:r.decode(u)}},hexFromSig(e){let{_tlv:t,_int:r}=Xo,o=t.encode(2,r.encode(e.r)),n=t.encode(2,r.encode(e.s)),i=o+n;return t.encode(48,i)}},lo=BigInt(0),Ea=BigInt(1),xO=BigInt(2),ip=BigInt(3),U8=BigInt(4);function Cb(e,t={}){let r=bO("weierstrass",e,t),{Fp:o,Fn:n}=r,i=r.CURVE,{h:s,n:a}=i;as(t,{},{allowInfinityPoint:"boolean",clearCofactor:"function",isTorsionFree:"function",fromBytes:"function",toBytes:"function",endo:"object"});let{endo:c}=t;if(c){if(!o.is0(i.a)||typeof c.beta!=="bigint"||!Array.isArray(c.basises))throw Error('invalid endo: expected "beta": bigint and "basises": array')}let u=EO(o,n);function d(){if(!o.isOdd)throw Error("compression is not supported: Field does not have .isOdd()")}function f(R,j,I){let{x:T,y:k}=j.toAffine(),M=o.toBytes(T);if(Ll(I,"isCompressed"),I){d();let N=!o.isOdd(k);return Et(_O(N),M)}else return Et(Uint8Array.of(4),M,o.toBytes(k))}function m(R){Te(R,void 0,"Point");let{publicKey:j,publicKeyUncompressed:I}=u,T=R.length,k=R[0],M=R.subarray(1);if(T===j&&(k===2||k===3)){let N=o.fromBytes(M);if(!o.isValid(N))throw Error("bad point: is not on curve, wrong x");let H=y(N),G;try{G=o.sqrt(H)}catch(pe){let be=pe instanceof Error?": "+pe.message:"";throw Error("bad point: is not on curve, sqrt error"+be)}d();let re=o.isOdd(G);if((k&1)===1!==re)G=o.neg(G);return{x:N,y:G}}else if(T===I&&k===4){let N=o.BYTES,H=o.fromBytes(M.subarray(0,N)),G=o.fromBytes(M.subarray(N,N*2));if(!S(H,G))throw Error("bad point: is not on curve");return{x:H,y:G}}else throw Error(`bad point: got length ${T}, expected compressed=${j} or uncompressed=${I}`)}let h=t.toBytes||f,b=t.fromBytes||m;function y(R){let j=o.sqr(R),I=o.mul(j,R);return o.add(o.add(I,o.mul(R,i.a)),i.b)}function S(R,j){let I=o.sqr(j),T=y(R);return o.eql(I,T)}if(!S(i.Gx,i.Gy))throw Error("bad curve params: generator point");let x=o.mul(o.pow(i.a,ip),U8),_=o.mul(o.sqr(i.b),BigInt(27));if(o.is0(o.add(x,_)))throw Error("bad curve params: a or b");function A(R,j,I=!1){if(!o.isValid(j)||I&&o.is0(j))throw Error(`bad point coordinate ${R}`);return j}function O(R){if(!(R instanceof W))throw Error("Weierstrass Point expected")}function L(R){if(!c||!c.basises)throw Error("no endo");return Z8(R,c.basises,n.ORDER)}let z=vb((R,j)=>{let{X:I,Y:T,Z:k}=R;if(o.eql(k,o.ONE))return{x:I,y:T};let M=R.is0();if(j==null)j=M?o.ONE:o.inv(k);let N=o.mul(I,j),H=o.mul(T,j),G=o.mul(k,j);if(M)return{x:o.ZERO,y:o.ZERO};if(!o.eql(G,o.ONE))throw Error("invZ was invalid");return{x:N,y:H}}),K=vb((R)=>{if(R.is0()){if(t.allowInfinityPoint&&!o.is0(R.Y))return;throw Error("bad point: ZERO")}let{x:j,y:I}=R.toAffine();if(!o.isValid(j)||!o.isValid(I))throw Error("bad point: x or y not field elements");if(!S(j,I))throw Error("bad point: equation left != right");if(!R.isTorsionFree())throw Error("bad point: not in prime-order subgroup");return!0});function P(R,j,I,T,k){return I=new W(o.mul(I.X,R),I.Y,I.Z),j=Ml(T,j),I=Ml(k,I),j.add(I)}class W{static BASE=new W(i.Gx,i.Gy,o.ONE);static ZERO=new W(o.ZERO,o.ONE,o.ZERO);static Fp=o;static Fn=n;X;Y;Z;constructor(R,j,I){this.X=A("x",R),this.Y=A("y",j,!0),this.Z=A("z",I),Object.freeze(this)}static CURVE(){return i}static fromAffine(R){let{x:j,y:I}=R||{};if(!R||!o.isValid(j)||!o.isValid(I))throw Error("invalid affine point");if(R instanceof W)throw Error("projective point not allowed");if(o.is0(j)&&o.is0(I))return W.ZERO;return new W(j,I,o.ONE)}static fromBytes(R){let j=W.fromAffine(b(Te(R,void 0,"point")));return j.assertValidity(),j}static fromHex(R){return W.fromBytes(ss(R))}get x(){return this.toAffine().x}get y(){return this.toAffine().y}precompute(R=8,j=!0){if(B.createCache(this,R),!j)this.multiply(ip);return this}assertValidity(){K(this)}hasEvenY(){let{y:R}=this.toAffine();if(!o.isOdd)throw Error("Field doesn't support isOdd");return!o.isOdd(R)}equals(R){O(R);let{X:j,Y:I,Z:T}=this,{X:k,Y:M,Z:N}=R,H=o.eql(o.mul(j,N),o.mul(k,T)),G=o.eql(o.mul(I,N),o.mul(M,T));return H&&G}negate(){return new W(this.X,o.neg(this.Y),this.Z)}double(){let{a:R,b:j}=i,I=o.mul(j,ip),{X:T,Y:k,Z:M}=this,N=o.ZERO,H=o.ZERO,G=o.ZERO,re=o.mul(T,T),ae=o.mul(k,k),pe=o.mul(M,M),be=o.mul(T,k);return be=o.add(be,be),G=o.mul(T,M),G=o.add(G,G),N=o.mul(R,G),H=o.mul(I,pe),H=o.add(N,H),N=o.sub(ae,H),H=o.add(ae,H),H=o.mul(N,H),N=o.mul(be,N),G=o.mul(I,G),pe=o.mul(R,pe),be=o.sub(re,pe),be=o.mul(R,be),be=o.add(be,G),G=o.add(re,re),re=o.add(G,re),re=o.add(re,pe),re=o.mul(re,be),H=o.add(H,re),pe=o.mul(k,M),pe=o.add(pe,pe),re=o.mul(pe,be),N=o.sub(N,re),G=o.mul(pe,ae),G=o.add(G,G),G=o.add(G,G),new W(N,H,G)}add(R){O(R);let{X:j,Y:I,Z:T}=this,{X:k,Y:M,Z:N}=R,H=o.ZERO,G=o.ZERO,re=o.ZERO,ae=i.a,pe=o.mul(i.b,ip),be=o.mul(j,k),ve=o.mul(I,M),ke=o.mul(T,N),Ie=o.add(j,I),we=o.add(k,M);Ie=o.mul(Ie,we),we=o.add(be,ve),Ie=o.sub(Ie,we),we=o.add(j,T);let Ue=o.add(k,N);return we=o.mul(we,Ue),Ue=o.add(be,ke),we=o.sub(we,Ue),Ue=o.add(I,T),H=o.add(M,N),Ue=o.mul(Ue,H),H=o.add(ve,ke),Ue=o.sub(Ue,H),re=o.mul(ae,we),H=o.mul(pe,ke),re=o.add(H,re),H=o.sub(ve,re),re=o.add(ve,re),G=o.mul(H,re),ve=o.add(be,be),ve=o.add(ve,be),ke=o.mul(ae,ke),we=o.mul(pe,we),ve=o.add(ve,ke),ke=o.sub(be,ke),ke=o.mul(ae,ke),we=o.add(we,ke),be=o.mul(ve,we),G=o.add(G,be),be=o.mul(Ue,we),H=o.mul(Ie,H),H=o.sub(H,be),be=o.mul(Ie,ve),re=o.mul(Ue,re),re=o.add(re,be),new W(H,G,re)}subtract(R){return this.add(R.negate())}is0(){return this.equals(W.ZERO)}multiply(R){let{endo:j}=t;if(!n.isValidNot0(R))throw Error("invalid scalar: out of range");let I,T,k=(M)=>B.cached(this,M,(N)=>Ab(W,N));if(j){let{k1neg:M,k1:N,k2neg:H,k2:G}=L(R),{p:re,f:ae}=k(N),{p:pe,f:be}=k(G);T=ae.add(be),I=P(j.beta,re,pe,M,H)}else{let{p:M,f:N}=k(R);I=M,T=N}return Ab(W,[I,T])[0]}multiplyUnsafe(R){let{endo:j}=t,I=this;if(!n.isValid(R))throw Error("invalid scalar: out of range");if(R===lo||I.is0())return W.ZERO;if(R===Ea)return I;if(B.hasCache(this))return this.multiply(R);if(j){let{k1neg:T,k1:k,k2neg:M,k2:N}=L(R),{p1:H,p2:G}=yO(W,I,k,N);return P(j.beta,H,G,T,M)}else return B.unsafe(I,R)}toAffine(R){return z(this,R)}isTorsionFree(){let{isTorsionFree:R}=t;if(s===Ea)return!0;if(R)return R(W,this);return B.unsafe(this,a).is0()}clearCofactor(){let{clearCofactor:R}=t;if(s===Ea)return this;if(R)return R(W,this);return this.multiplyUnsafe(s)}isSmallOrder(){return this.multiplyUnsafe(s).is0()}toBytes(R=!0){return Ll(R,"isCompressed"),this.assertValidity(),h(W,this,R)}toHex(R=!0){return is(this.toBytes(R))}toString(){return`<Point ${this.is0()?"ZERO":this.toHex()}>`}}let ee=n.BITS,B=new Tb(W,t.endo?Math.ceil(ee/2):ee);return W.BASE.precompute(8),W}function _O(e){return Uint8Array.of(e?2:3)}function EO(e,t){return{secretKey:t.BYTES,publicKey:1+e.BYTES,publicKeyUncompressed:1+2*e.BYTES,publicKeyHasPrefix:!0,signature:2*t.BYTES}}function q8(e,t={}){let{Fn:r}=e,o=t.randomBytes||Vo,n=Object.assign(EO(e.Fp,r),{seed:_b(r.ORDER)});function i(h){try{let b=r.fromBytes(h);return r.isValidNot0(b)}catch(b){return!1}}function s(h,b){let{publicKey:y,publicKeyUncompressed:S}=n;try{let x=h.length;if(b===!0&&x!==y)return!1;if(b===!1&&x!==S)return!1;return!!e.fromBytes(h)}catch(x){return!1}}function a(h=o(n.seed)){return dO(Te(h,n.seed,"seed"),r.ORDER)}function c(h,b=!0){return e.BASE.multiply(r.fromBytes(h)).toBytes(b)}function u(h){let{secretKey:b,publicKey:y,publicKeyUncompressed:S}=n;if(!ba(h))return;if("_lengths"in r&&r._lengths||b===y)return;let x=Te(h,void 0,"key").length;return x===y||x===S}function d(h,b,y=!0){if(u(h)===!0)throw Error("first arg must be private key");if(u(b)===!1)throw Error("second arg must be public key");let S=r.fromBytes(h);return e.fromBytes(b).multiply(S).toBytes(y)}let f={isValidSecretKey:i,isValidPublicKey:s,randomSecretKey:a},m=np(a,c);return Object.freeze({getPublicKey:c,getSharedSecret:d,keygen:m,Point:e,utils:f,lengths:n})}function Pb(e,t,r={}){Mr(t),as(r,{},{hmac:"function",lowS:"boolean",randomBytes:"function",bits2int:"function",bits2int_modN:"function"}),r=Object.assign({},r);let o=r.randomBytes||Vo,n=r.hmac||((I,T)=>_a(t,I,T)),{Fp:i,Fn:s}=e,{ORDER:a,BITS:c}=s,{keygen:u,getPublicKey:d,getSharedSecret:f,utils:m,lengths:h}=q8(e,r),b={prehash:!0,lowS:typeof r.lowS==="boolean"?r.lowS:!0,format:"compact",extraEntropy:!1},y=a*xO<i.ORDER;function S(I){let T=a>>Ea;return I>T}function x(I,T){if(!s.isValidNot0(T))throw Error(`invalid signature ${I}: out of range 1..Point.Fn.ORDER`);return T}function _(){if(y)throw Error('"recovered" sig type is not supported for cofactor >2 curves')}function A(I,T){Ob(T);let k=h.signature,M=T==="compact"?k:T==="recovered"?k+1:void 0;return Te(I,M)}class O{r;s;recovery;constructor(I,T,k){if(this.r=x("r",I),this.s=x("s",T),k!=null){if(_(),![0,1,2,3].includes(k))throw Error("invalid recovery id");this.recovery=k}Object.freeze(this)}static fromBytes(I,T=b.format){A(I,T);let k;if(T==="der"){let{r:G,s:re}=Xo.toSig(Te(I));return new O(G,re)}if(T==="recovered")k=I[0],T="compact",I=I.subarray(1);let M=h.signature/2,N=I.subarray(0,M),H=I.subarray(M,M*2);return new O(s.fromBytes(N),s.fromBytes(H),k)}static fromHex(I,T){return this.fromBytes(ss(I),T)}assertRecovery(){let{recovery:I}=this;if(I==null)throw Error("invalid recovery id: must be present");return I}addRecoveryBit(I){return new O(this.r,this.s,I)}recoverPublicKey(I){let{r:T,s:k}=this,M=this.assertRecovery(),N=M===2||M===3?T+a:T;if(!i.isValid(N))throw Error("invalid recovery id: sig.r+curve.n != R.x");let H=i.toBytes(N),G=e.fromBytes(Et(_O((M&1)===0),H)),re=s.inv(N),ae=z(Te(I,void 0,"msgHash")),pe=s.create(-ae*re),be=s.create(k*re),ve=e.BASE.multiplyUnsafe(pe).add(G.multiplyUnsafe(be));if(ve.is0())throw Error("invalid recovery: point at infinify");return ve.assertValidity(),ve}hasHighS(){return S(this.s)}toBytes(I=b.format){if(Ob(I),I==="der")return ss(Xo.hexFromSig(this));let{r:T,s:k}=this,M=s.toBytes(T),N=s.toBytes(k);if(I==="recovered")return _(),Et(Uint8Array.of(this.assertRecovery()),M,N);return Et(M,N)}toHex(I){return is(this.toBytes(I))}}let L=r.bits2int||function(T){if(T.length>8192)throw Error("input is too large");let k=Go(T),M=T.length*8-c;return M>0?k>>BigInt(M):k},z=r.bits2int_modN||function(T){return s.create(L(T))},K=Ul(c);function P(I){return Zl("num < 2^"+c,I,lo,K),s.toBytes(I)}function W(I,T){return Te(I,void 0,"message"),T?Te(t(I),void 0,"prehashed message"):I}function ee(I,T,k){let{lowS:M,prehash:N,extraEntropy:H}=Rb(k,b);I=W(I,N);let G=z(I),re=s.fromBytes(T);if(!s.isValidNot0(re))throw Error("invalid private key");let ae=[P(re),P(G)];if(H!=null&&H!==!1){let ke=H===!0?o(h.secretKey):H;ae.push(Te(ke,void 0,"extraEntropy"))}let pe=Et(...ae),be=G;function ve(ke){let Ie=L(ke);if(!s.isValidNot0(Ie))return;let we=s.inv(Ie),Ue=e.BASE.multiply(Ie).toAffine(),De=s.create(Ue.x);if(De===lo)return;let Qe=s.create(we*s.create(be+De*re));if(Qe===lo)return;let bt=(Ue.x===De?0:2)|Number(Ue.y&Ea),Tt=Qe;if(M&&S(Qe))Tt=s.neg(Qe),bt^=1;return new O(De,Tt,y?void 0:bt)}return{seed:pe,k2sig:ve}}function B(I,T,k={}){let{seed:M,k2sig:N}=ee(I,T,k);return XR(t.outputLen,s.BYTES,n)(M,N).toBytes(k.format)}function R(I,T,k,M={}){let{lowS:N,prehash:H,format:G}=Rb(M,b);if(k=Te(k,void 0,"publicKey"),T=W(T,H),!ba(I)){let re=I instanceof O?", use sig.toBytes()":"";throw Error("verify expects Uint8Array signature"+re)}A(I,G);try{let re=O.fromBytes(I,G),ae=e.fromBytes(k);if(N&&re.hasHighS())return!1;let{r:pe,s:be}=re,ve=z(T),ke=s.inv(be),Ie=s.create(ve*ke),we=s.create(pe*ke),Ue=e.BASE.multiplyUnsafe(Ie).add(ae.multiplyUnsafe(we));if(Ue.is0())return!1;return s.create(Ue.x)===pe}catch(re){return!1}}function j(I,T,k={}){let{prehash:M}=Rb(k,b);return T=W(T,M),O.fromBytes(I,"recovered").recoverPublicKey(T).toBytes()}return Object.freeze({keygen:u,getPublicKey:d,getSharedSecret:f,utils:m,lengths:h,Point:e,sign:B,verify:R,recoverPublicKey:j,Signature:O,hash:t})}function IO(e,t,r){return e&t^~e&r}function kO(e,t,r){return e&t^e&r^t&r}class sp{blockLen;outputLen;padOffset;isLE;buffer;view;finished=!1;length=0;pos=0;destroyed=!1;constructor(e,t,r,o){this.blockLen=e,this.outputLen=t,this.padOffset=r,this.isLE=o,this.buffer=new Uint8Array(e),this.view=Xf(this.buffer)}update(e){co(this),Te(e);let{view:t,buffer:r,blockLen:o}=this,n=e.length;for(let i=0;i<n;){let s=Math.min(o-this.pos,n-i);if(s===o){let a=Xf(e);for(;o<=n-i;i+=o)this.process(a,i);continue}if(r.set(e.subarray(i,i+s),this.pos),this.pos+=s,i+=s,this.pos===o)this.process(t,0),this.pos=0}return this.length+=e.length,this.roundClean(),this}digestInto(e){co(this),Qf(e,this),this.finished=!0;let{buffer:t,view:r,blockLen:o,isLE:n}=this,{pos:i}=this;if(t[i++]=128,vr(this.buffer.subarray(i)),this.padOffset>o-i)this.process(r,0),i=0;for(let d=i;d<o;d++)t[d]=0;r.setBigUint64(o-8,BigInt(this.length*8),n),this.process(r,0);let s=Xf(e),a=this.outputLen;if(a%4)throw Error("_sha2: outputLen must be aligned to 32bit");let c=a/4,u=this.get();if(c>u.length)throw Error("_sha2: outputLen bigger than state");for(let d=0;d<c;d++)s.setUint32(4*d,u[d],n)}digest(){let{buffer:e,outputLen:t}=this;this.digestInto(e);let r=e.slice(0,t);return this.destroy(),r}_cloneInto(e){e||=new this.constructor,e.set(...this.get());let{blockLen:t,buffer:r,length:o,finished:n,destroyed:i,pos:s}=this;if(e.destroyed=i,e.finished=n,e.length=o,e.pos=s,o%t)e.buffer.set(r);return e}clone(){return this._cloneInto()}}var uo=Uint32Array.from([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]);var Ft=Uint32Array.from([3418070365,3238371032,1654270250,914150663,2438529370,812702999,355462360,4144912697,1731405415,4290775857,2394180231,1750603025,3675008525,1694076839,1203062813,3204075428]);var ap=BigInt(4294967295),AO=BigInt(32);function M8(e,t=!1){if(t)return{h:Number(e&ap),l:Number(e>>AO&ap)};return{h:Number(e>>AO&ap)|0,l:Number(e&ap)|0}}function cp(e,t=!1){let r=e.length,o=new Uint32Array(r),n=new Uint32Array(r);for(let i=0;i<r;i++){let{h:s,l:a}=M8(e[i],t);[o[i],n[i]]=[s,a]}return[o,n]}var zb=(e,t,r)=>e>>>r,Nb=(e,t,r)=>e<<32-r|t>>>r,us=(e,t,r)=>e>>>r|t<<32-r,ds=(e,t,r)=>e<<32-r|t>>>r,Jl=(e,t,r)=>e<<64-r|t>>>r-32,Kl=(e,t,r)=>e>>>r-32|t<<64-r;var TO=(e,t,r)=>e<<r|t>>>32-r,$O=(e,t,r)=>t<<r|e>>>32-r,RO=(e,t,r)=>t<<r-32|e>>>64-r,OO=(e,t,r)=>e<<r-32|t>>>64-r;function On(e,t,r,o){let n=(t>>>0)+(o>>>0);return{h:e+r+(n/4294967296|0)|0,l:n|0}}var CO=(e,t,r)=>(e>>>0)+(t>>>0)+(r>>>0),PO=(e,t,r,o)=>t+r+o+(e/4294967296|0)|0,zO=(e,t,r,o)=>(e>>>0)+(t>>>0)+(r>>>0)+(o>>>0),NO=(e,t,r,o,n)=>t+r+o+n+(e/4294967296|0)|0,DO=(e,t,r,o,n)=>(e>>>0)+(t>>>0)+(r>>>0)+(o>>>0)+(n>>>0),LO=(e,t,r,o,n,i)=>t+r+o+n+i+(e/4294967296|0)|0;var J8=Uint32Array.from([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),ei=new Uint32Array(64);class jO extends sp{constructor(e){super(64,e,8,!1)}get(){let{A:e,B:t,C:r,D:o,E:n,F:i,G:s,H:a}=this;return[e,t,r,o,n,i,s,a]}set(e,t,r,o,n,i,s,a){this.A=e|0,this.B=t|0,this.C=r|0,this.D=o|0,this.E=n|0,this.F=i|0,this.G=s|0,this.H=a|0}process(e,t){for(let d=0;d<16;d++,t+=4)ei[d]=e.getUint32(t,!1);for(let d=16;d<64;d++){let f=ei[d-15],m=ei[d-2],h=on(f,7)^on(f,18)^f>>>3,b=on(m,17)^on(m,19)^m>>>10;ei[d]=b+ei[d-7]+h+ei[d-16]|0}let{A:r,B:o,C:n,D:i,E:s,F:a,G:c,H:u}=this;for(let d=0;d<64;d++){let f=on(s,6)^on(s,11)^on(s,25),m=u+f+IO(s,a,c)+J8[d]+ei[d]|0,b=(on(r,2)^on(r,13)^on(r,22))+kO(r,o,n)|0;u=c,c=a,a=s,s=i+m|0,i=n,n=o,o=r,r=m+b|0}r=r+this.A|0,o=o+this.B|0,n=n+this.C|0,i=i+this.D|0,s=s+this.E|0,a=a+this.F|0,c=c+this.G|0,u=u+this.H|0,this.set(r,o,n,i,s,a,c,u)}roundClean(){vr(ei)}destroy(){this.set(0,0,0,0,0,0,0,0),vr(this.buffer)}}class BO extends jO{A=uo[0]|0;B=uo[1]|0;C=uo[2]|0;D=uo[3]|0;E=uo[4]|0;F=uo[5]|0;G=uo[6]|0;H=uo[7]|0;constructor(){super(32)}}var ZO=(()=>cp(["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))))(),K8=(()=>ZO[0])(),H8=(()=>ZO[1])(),ti=new Uint32Array(80),ri=new Uint32Array(80);class UO extends sp{constructor(e){super(128,e,16,!1)}get(){let{Ah:e,Al:t,Bh:r,Bl:o,Ch:n,Cl:i,Dh:s,Dl:a,Eh:c,El:u,Fh:d,Fl:f,Gh:m,Gl:h,Hh:b,Hl:y}=this;return[e,t,r,o,n,i,s,a,c,u,d,f,m,h,b,y]}set(e,t,r,o,n,i,s,a,c,u,d,f,m,h,b,y){this.Ah=e|0,this.Al=t|0,this.Bh=r|0,this.Bl=o|0,this.Ch=n|0,this.Cl=i|0,this.Dh=s|0,this.Dl=a|0,this.Eh=c|0,this.El=u|0,this.Fh=d|0,this.Fl=f|0,this.Gh=m|0,this.Gl=h|0,this.Hh=b|0,this.Hl=y|0}process(e,t){for(let _=0;_<16;_++,t+=4)ti[_]=e.getUint32(t),ri[_]=e.getUint32(t+=4);for(let _=16;_<80;_++){let A=ti[_-15]|0,O=ri[_-15]|0,L=us(A,O,1)^us(A,O,8)^zb(A,O,7),z=ds(A,O,1)^ds(A,O,8)^Nb(A,O,7),K=ti[_-2]|0,P=ri[_-2]|0,W=us(K,P,19)^Jl(K,P,61)^zb(K,P,6),ee=ds(K,P,19)^Kl(K,P,61)^Nb(K,P,6),B=zO(z,ee,ri[_-7],ri[_-16]),R=NO(B,L,W,ti[_-7],ti[_-16]);ti[_]=R|0,ri[_]=B|0}let{Ah:r,Al:o,Bh:n,Bl:i,Ch:s,Cl:a,Dh:c,Dl:u,Eh:d,El:f,Fh:m,Fl:h,Gh:b,Gl:y,Hh:S,Hl:x}=this;for(let _=0;_<80;_++){let A=us(d,f,14)^us(d,f,18)^Jl(d,f,41),O=ds(d,f,14)^ds(d,f,18)^Kl(d,f,41),L=d&m^~d&b,z=f&h^~f&y,K=DO(x,O,z,H8[_],ri[_]),P=LO(K,S,A,L,K8[_],ti[_]),W=K|0,ee=us(r,o,28)^Jl(r,o,34)^Jl(r,o,39),B=ds(r,o,28)^Kl(r,o,34)^Kl(r,o,39),R=r&n^r&s^n&s,j=o&i^o&a^i&a;S=b|0,x=y|0,b=m|0,y=h|0,m=d|0,h=f|0,{h:d,l:f}=On(c|0,u|0,P|0,W|0),c=s|0,u=a|0,s=n|0,a=i|0,n=r|0,i=o|0;let I=CO(W,B,j);r=PO(I,P,ee,R),o=I|0}({h:r,l:o}=On(this.Ah|0,this.Al|0,r|0,o|0)),{h:n,l:i}=On(this.Bh|0,this.Bl|0,n|0,i|0),{h:s,l:a}=On(this.Ch|0,this.Cl|0,s|0,a|0),{h:c,l:u}=On(this.Dh|0,this.Dl|0,c|0,u|0),{h:d,l:f}=On(this.Eh|0,this.El|0,d|0,f|0),{h:m,l:h}=On(this.Fh|0,this.Fl|0,m|0,h|0),{h:b,l:y}=On(this.Gh|0,this.Gl|0,b|0,y|0),{h:S,l:x}=On(this.Hh|0,this.Hl|0,S|0,x|0),this.set(r,o,n,i,s,a,c,u,d,f,m,h,b,y,S,x)}roundClean(){vr(ti,ri)}destroy(){vr(this.buffer),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}}class qO extends UO{Ah=Ft[0]|0;Al=Ft[1]|0;Bh=Ft[2]|0;Bl=Ft[3]|0;Ch=Ft[4]|0;Cl=Ft[5]|0;Dh=Ft[6]|0;Dl=Ft[7]|0;Eh=Ft[8]|0;El=Ft[9]|0;Fh=Ft[10]|0;Fl=Ft[11]|0;Gh=Ft[12]|0;Gl=Ft[13]|0;Hh=Ft[14]|0;Hl=Ft[15]|0;constructor(){super(48)}}var lp=Sa(()=>new BO,Wo(1));var MO=Sa(()=>new qO,Wo(2));/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */var V8=BigInt(1),FO=BigInt(2),W8=BigInt(3),G8=BigInt(5),Uhe=BigInt(8),JO=BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffed");function Q8(e){let t=BigInt(10),r=BigInt(20),o=BigInt(40),n=BigInt(80),i=JO,a=e*e%i*e%i,c=Fr(a,FO,i)*a%i,u=Fr(c,V8,i)*e%i,d=Fr(u,G8,i)*u%i,f=Fr(d,t,i)*d%i,m=Fr(f,r,i)*f%i,h=Fr(m,o,i)*m%i,b=Fr(h,n,i)*h%i,y=Fr(b,n,i)*h%i,S=Fr(y,t,i)*d%i;return{pow_p_5_8:Fr(S,FO,i)*e%i,b2:a}}function Y8(e){return e[0]&=248,e[31]&=127,e[31]|=64,e}var KO=(()=>{let e=JO;return SO({P:e,type:"x25519",powPminus2:(t)=>{let{pow_p_5_8:r,b2:o}=Q8(t);return lr(Fr(r,W8,e)*o,e)},adjustScalarBytes:Y8})})();/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */var X8=(()=>({p:BigInt("0xffffffff00000001000000000000000000000000ffffffffffffffffffffffff"),n:BigInt("0xffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc632551"),h:BigInt(1),a:BigInt("0xffffffff00000001000000000000000000000000fffffffffffffffffffffffc"),b:BigInt("0x5ac635d8aa3a93e7b3ebbd55769886bc651d06b0cc53b0f63bce3c3e27d2604b"),Gx:BigInt("0x6b17d1f2e12c4247f8bce6e563a440f277037d812deb33a0f4a13945d898c296"),Gy:BigInt("0x4fe342e2fe1a7f9b8ee7eb4a7c0f9e162bce33576b315ececbb6406837bf51f5")}))(),eJ=(()=>({p:BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffeffffffff0000000000000000ffffffff"),n:BigInt("0xffffffffffffffffffffffffffffffffffffffffffffffffc7634d81f4372ddf581a0db248b0a77aecec196accc52973"),h:BigInt(1),a:BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffeffffffff0000000000000000fffffffc"),b:BigInt("0xb3312fa7e23ee7e4988e056be3f82d19181d9c6efe8141120314088f5013875ac656398d8a2ed19d2a85c8edd3ec2aef"),Gx:BigInt("0xaa87ca22be8b05378eb1c71ef320ad746e1d3b628ba79b9859f741e082542a385502f25dbf55296c3a545e3872760ab7"),Gy:BigInt("0x3617de4a96262c6f5d9e98bf9292dc29f8f41dbd289a147ce9da3113b5f0b8c00a60b1ce1d7e819d7a431d7c90ea0e5f")}))();var tJ=Cb(X8),Db=Pb(tJ,lp);var rJ=Cb(eJ),HO=Pb(rJ,MO);function WO(e,t,r){if(Mr(e),r===void 0)r=new Uint8Array(e.outputLen);return _a(e,r,t)}var Lb=Uint8Array.of(0),VO=Uint8Array.of();function GO(e,t,r,o=32){Mr(e),Dt(o,"length");let n=e.outputLen;if(o>255*n)throw Error("Length must be <= 255*HashLen");let i=Math.ceil(o/n);if(r===void 0)r=VO;else Te(r,void 0,"info");let s=new Uint8Array(i*n),a=_a.create(e,t),c=a._cloneInto(),u=new Uint8Array(a.outputLen);for(let d=0;d<i;d++)Lb[0]=d+1,c.update(d===0?VO:u).update(r).update(Lb).digestInto(u),s.set(u,n*d),a._cloneInto(c);return a.destroy(),c.destroy(),vr(u,Lb),s.slice(0,o)}var nJ=BigInt(0),Hl=BigInt(1),oJ=BigInt(2),iJ=BigInt(7),sJ=BigInt(256),aJ=BigInt(113),XO=[],e1=[],t1=[];for(let e=0,t=Hl,r=1,o=0;e<24;e++){[r,o]=[o,(2*r+3*o)%5],XO.push(2*(5*o+r)),e1.push((e+1)*(e+2)/2%64);let n=nJ;for(let i=0;i<7;i++)if(t=(t<<Hl^(t>>iJ)*aJ)%sJ,t&oJ)n^=Hl<<(Hl<<BigInt(i))-Hl;t1.push(n)}var r1=cp(t1,!0),cJ=r1[0],lJ=r1[1],QO=(e,t,r)=>r>32?RO(e,t,r):TO(e,t,r),YO=(e,t,r)=>r>32?OO(e,t,r):$O(e,t,r);function uJ(e,t=24){let r=new Uint32Array(10);for(let o=24-t;o<24;o++){for(let s=0;s<10;s++)r[s]=e[s]^e[s+10]^e[s+20]^e[s+30]^e[s+40];for(let s=0;s<10;s+=2){let a=(s+8)%10,c=(s+2)%10,u=r[c],d=r[c+1],f=QO(u,d,1)^r[a],m=YO(u,d,1)^r[a+1];for(let h=0;h<50;h+=10)e[s+h]^=f,e[s+h+1]^=m}let n=e[2],i=e[3];for(let s=0;s<24;s++){let a=e1[s],c=QO(n,i,a),u=YO(n,i,a),d=XO[s];n=e[d],i=e[d+1],e[d]=c,e[d+1]=u}for(let s=0;s<50;s+=10){for(let a=0;a<10;a++)r[a]=e[s+a];for(let a=0;a<10;a++)e[s+a]^=~r[(a+2)%10]&r[(a+4)%10]}e[0]^=cJ[o],e[1]^=lJ[o]}vr(r)}class up{state;pos=0;posOut=0;finished=!1;state32;destroyed=!1;blockLen;suffix;outputLen;enableXOF=!1;rounds;constructor(e,t,r,o=!1,n=24){if(this.blockLen=e,this.suffix=t,this.outputLen=r,this.enableXOF=o,this.rounds=n,Dt(r,"outputLen"),!(0<e&&e<200))throw Error("only keccak-f1600 function is supported");this.state=new Uint8Array(200),this.state32=Yf(this.state)}clone(){return this._cloneInto()}keccak(){gb(this.state32),uJ(this.state32,this.rounds),gb(this.state32),this.posOut=0,this.pos=0}update(e){co(this),Te(e);let{blockLen:t,state:r}=this,o=e.length;for(let n=0;n<o;){let i=Math.min(t-this.pos,o-n);for(let s=0;s<i;s++)r[this.pos++]^=e[n++];if(this.pos===t)this.keccak()}return this}finish(){if(this.finished)return;this.finished=!0;let{state:e,suffix:t,pos:r,blockLen:o}=this;if(e[r]^=t,(t&128)!==0&&r===o-1)this.keccak();e[o-1]^=128,this.keccak()}writeInto(e){co(this,!1),Te(e),this.finish();let t=this.state,{blockLen:r}=this;for(let o=0,n=e.length;o<n;){if(this.posOut>=r)this.keccak();let i=Math.min(r-this.posOut,n-o);e.set(t.subarray(this.posOut,this.posOut+i),o),this.posOut+=i,o+=i}return e}xofInto(e){if(!this.enableXOF)throw Error("XOF is not possible for this instance");return this.writeInto(e)}xof(e){return Dt(e),this.xofInto(new Uint8Array(e))}digestInto(e){if(Qf(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,vr(this.state)}_cloneInto(e){let{blockLen:t,suffix:r,outputLen:o,rounds:n,enableXOF:i}=this;return e||=new up(t,r,o,i,n),e.state32.set(this.state32),e.pos=this.pos,e.posOut=this.posOut,e.finished=this.finished,e.rounds=n,e.suffix=r,e.outputLen=o,e.enableXOF=i,e.destroyed=this.destroyed,e}}var n1=(e,t,r,o={})=>Sa(()=>new up(t,e,r),o);var fs=n1(6,136,32,Wo(8));var o1=n1(6,72,64,Wo(10));var i1=(e,t,r,o={})=>Sa((n={})=>new up(t,e,n.dkLen===void 0?r:n.dkLen,!0),o),s1=i1(31,168,16,Wo(11)),Cn=i1(31,136,32,Wo(12));function jb(e){if(!Number.isSafeInteger(e)||e<0||e>4294967295)throw Error("wrong u32 integer:"+e);return e}function c1(e){return jb(e),(e&e-1)===0&&e!==0}function Bb(e,t){jb(e);let r=0;for(let o=0;o<t;o++,e>>>=1)r=r<<1|e&1;return r}function l1(e){return jb(e),31-Math.clz32(e)}function a1(e){let t=e.length;if(t<2||!c1(t))throw Error("n must be a power of 2 and greater than 1. Got "+t);let r=l1(t);for(let o=0;o<t;o++){let n=Bb(o,r);if(o<n){let i=e[o];e[o]=e[n],e[n]=i}}return e}var Zb=(e,t)=>{let{N:r,roots:o,dit:n,invertButterflies:i=!1,skipStages:s=0,brp:a=!0}=t,c=l1(r);if(!c1(r))throw Error("FFT: Polynomial size should be power of two");let u=n!==i;return(d)=>{if(d.length!==r)throw Error("FFT: wrong Polynomial length");if(n&&a)a1(d);for(let f=0,m=1;f<c-s;f++){let h=n?f+1+s:c-f,b=1<<h,y=b>>1,S=r>>h;for(let x=0;x<r;x+=b)for(let _=0,A=m++;_<y;_++){let O=i?n?r-A:A:_*S,L=x+_,z=x+_+y,K=o[O],P=d[z],W=d[L];if(u){let ee=e.mul(P,K);d[L]=e.add(W,ee),d[z]=e.sub(W,ee)}else if(i)d[L]=e.add(P,W),d[z]=e.mul(e.sub(P,W),K);else d[L]=e.add(W,P),d[z]=e.mul(e.sub(W,P),K)}}if(!n&&a)a1(d);return d}};/*! noble-post-quantum - MIT License (c) 2024 Paul Miller (paulmillr.com) */var Pn=Vo;function dp(e,t){if(e.length!==t.length)return!1;let r=0;for(let o=0;o<e.length;o++)r|=e[o]^t[o];return r===0}function u1(e){return Uint8Array.from(e)}function ps(e,...t){let r=(n)=>typeof n==="number"?n:n.bytesLen,o=t.reduce((n,i)=>n+r(i),0);return{bytesLen:o,encode:(n)=>{let i=new Uint8Array(o);for(let s=0,a=0;s<t.length;s++){let c=t[s],u=r(c),d=typeof c==="number"?n[s]:c.encode(n[s]);if(Te(d,u,e),i.set(d,a),typeof c!=="number")d.fill(0);a+=u}return i},decode:(n)=>{Te(n,o,e);let i=[];for(let s of t){let a=r(s),c=n.subarray(0,a);i.push(typeof s==="number"?c:s.decode(c)),n=n.subarray(a)}return i}}}function fp(e,t){let r=t*e.bytesLen;return{bytesLen:r,encode:(o)=>{if(o.length!==t)throw Error(`vecCoder.encode: wrong length=${o.length}. Expected: ${t}`);let n=new Uint8Array(r);for(let i=0,s=0;i<o.length;i++){let a=e.encode(o[i]);n.set(a,s),a.fill(0),s+=a.length}return n},decode:(o)=>{Te(o,r);let n=[];for(let i=0;i<o.length;i+=e.bytesLen)n.push(e.decode(o.subarray(i,i+e.bytesLen)));return n}}}function Rt(...e){for(let t of e)if(Array.isArray(t))for(let r of t)r.fill(0);else t.fill(0)}function Ub(e){return(1<<e)-1}var rge=Uint8Array.of();/*! noble-post-quantum - MIT License (c) 2024 Paul Miller (paulmillr.com) */var d1=(e)=>{let{newPoly:t,N:r,Q:o,F:n,ROOT_OF_UNITY:i,brvBits:s,isKyber:a}=e,c=(_,A=o)=>{let O=_%A|0;return(O>=0?O|0:A+O|0)|0},u=(_,A=o)=>{let O=c(_,A)|0;return(O>A>>1?O-A|0:O)|0};function d(){let _=t(r);for(let A=0;A<r;A++){let O=Bb(A,s),L=BigInt(i)**BigInt(O)%BigInt(o);_[A]=Number(L)|0}return _}let f=d(),m={add:(_,A)=>c((_|0)+(A|0))|0,sub:(_,A)=>c((_|0)-(A|0))|0,mul:(_,A)=>c((_|0)*(A|0))|0,inv:(_)=>{throw Error("not implemented")}},h={N:r,roots:f,invertButterflies:!0,skipStages:a?1:0,brp:!1},b=Zb(m,{dit:!1,...h}),y=Zb(m,{dit:!0,...h});return{mod:c,smod:u,nttZetas:f,NTT:{encode:(_)=>b(_),decode:(_)=>{y(_);for(let A=0;A<_.length;A++)_[A]=c(n*_[A]);return _}},bitsCoder:(_,A)=>{let O=Ub(_),L=_*(r/8);return{bytesLen:L,encode:(z)=>{let K=new Uint8Array(L);for(let P=0,W=0,ee=0,B=0;P<z.length;P++){W|=(A.encode(z[P])&O)<<ee,ee+=_;for(;ee>=8;ee-=8,W>>=8)K[B++]=W&Ub(ee)}return K},decode:(z)=>{let K=t(r);for(let P=0,W=0,ee=0,B=0;P<z.length;P++){W|=z[P]<<ee,ee+=8;for(;ee>=_;ee-=_,W>>=_)K[B++]=A.decode(W&O)}return K}}}}},dJ=(e)=>(t,r)=>{if(!r)r=e.blockLen;let o=new Uint8Array(t.length+2);o.set(t);let n=t.length,i=new Uint8Array(r),s=e.create({}),a=0,c=0;return{stats:()=>({calls:a,xofs:c}),get:(u,d)=>(o[n+0]=u,o[n+1]=d,s.destroy(),s=e.create({}).update(o),a++,()=>(c++,s.xofInto(i))),clean:()=>{s.destroy(),Rt(i,o)}}},f1=dJ(s1);/*! noble-post-quantum - MIT License (c) 2024 Paul Miller (paulmillr.com) */var er=256,fo=3329,fJ=3303,pJ=17,{mod:Gl,nttZetas:mJ,NTT:ms,bitsCoder:hJ}=d1({N:er,Q:fo,F:fJ,ROOT_OF_UNITY:pJ,newPoly:(e)=>new Uint16Array(e),brvBits:7,isKyber:!0}),qb={512:{N:er,Q:fo,K:2,ETA1:3,ETA2:2,du:10,dv:4,RBGstrength:128},768:{N:er,Q:fo,K:3,ETA1:2,ETA2:2,du:10,dv:4,RBGstrength:192},1024:{N:er,Q:fo,K:4,ETA1:2,ETA2:2,du:11,dv:5,RBGstrength:256}},gJ=(e)=>{if(e>=12)return{encode:(r)=>r,decode:(r)=>r};let t=2**(e-1);return{encode:(r)=>((r<<e)+fo/2)/fo,decode:(r)=>r*fo+t>>>e}},Vl=(e)=>hJ(e,gJ(e));function hs(e,t){for(let r=0;r<er;r++)e[r]=Gl(e[r]+t[r])}function yJ(e,t){for(let r=0;r<er;r++)e[r]=Gl(e[r]-t[r])}function bJ(e,t,r,o,n){let i=Gl(t*o*n+e*r),s=Gl(e*o+t*r);return{c0:i,c1:s}}function pp(e,t){for(let r=0;r<er/2;r++){let o=mJ[64+(r>>1)];if(r&1)o=-o;let{c0:n,c1:i}=bJ(e[2*r+0],e[2*r+1],t[2*r+0],t[2*r+1],o);e[2*r+0]=n,e[2*r+1]=i}return e}function p1(e){let t=new Uint16Array(er);for(let r=0;r<er;){let o=e();if(o.length%3)throw Error("SampleNTT: unaligned block");for(let n=0;r<er&&n+3<=o.length;n+=3){let i=(o[n+0]>>0|o[n+1]<<8)&4095,s=(o[n+1]>>4|o[n+2]<<4)&4095;if(i<fo)t[r++]=i;if(r<er&&s<fo)t[r++]=s}}return t}function Wl(e,t,r,o){let n=e(o*er/4,t,r),i=new Uint16Array(er),s=Yf(n),a=0;for(let c=0,u=0,d=0,f=0;c<s.length;c++){let m=s[c];for(let h=0;h<32;h++)if(d+=m&1,m>>=1,a+=1,a===o)f=d,d=0;else if(a===2*o)i[u++]=Gl(f-d),d=0,a=0}if(a)throw Error(`sampleCBD: leftover bits: ${a}`);return i}var SJ=(e)=>{let{K:t,PRF:r,XOF:o,HASH512:n,ETA1:i,ETA2:s,du:a,dv:c}=e,u=Vl(1),d=Vl(c),f=Vl(a),m=ps("publicKey",fp(Vl(12),t),32),h=fp(Vl(12),t),b=ps("ciphertext",fp(f,t),d),y=ps("seed",32,32);return{secretCoder:h,lengths:{secretKey:h.bytesLen,publicKey:m.bytesLen,cipherText:b.bytesLen},keygen:(S)=>{Te(S,32,"seed");let x=new Uint8Array(33);x.set(S),x[32]=t;let _=n(x),[A,O]=y.decode(_),L=[],z=[];for(let W=0;W<t;W++)L.push(ms.encode(Wl(r,O,W,i)));let K=o(A);for(let W=0;W<t;W++){let ee=ms.encode(Wl(r,O,t+W,i));for(let B=0;B<t;B++){let R=p1(K.get(B,W));hs(ee,pp(R,L[B]))}z.push(ee)}K.clean();let P={publicKey:m.encode([z,A]),secretKey:h.encode(L)};return Rt(A,O,L,z,x,_),P},encrypt:(S,x,_)=>{let[A,O]=m.decode(S),L=[];for(let B=0;B<t;B++)L.push(ms.encode(Wl(r,_,B,i)));let z=o(O),K=new Uint16Array(er),P=[];for(let B=0;B<t;B++){let R=Wl(r,_,t+B,s),j=new Uint16Array(er);for(let I=0;I<t;I++){let T=p1(z.get(B,I));hs(j,pp(T,L[I]))}hs(R,ms.decode(j)),P.push(R),hs(K,pp(A[B],L[B])),Rt(j)}z.clean();let W=Wl(r,_,2*t,s);hs(W,ms.decode(K));let ee=u.decode(x);return hs(ee,W),Rt(A,L,K,W),b.encode([P,ee])},decrypt:(S,x)=>{let[_,A]=b.decode(S),O=h.decode(x),L=new Uint16Array(er);for(let z=0;z<t;z++)hs(L,pp(O[z],ms.encode(_[z])));return yJ(A,ms.decode(L)),Rt(L,O,_),u.encode(A)}}};function Mb(e){let t=SJ(e),{HASH256:r,HASH512:o,KDF:n}=e,{secretCoder:i,lengths:s}=t,a=ps("secretKey",s.secretKey,s.publicKey,32,32),c=32,u=64;return{info:{type:"ml-kem"},lengths:{...s,seed:64,msg:32,msgRand:32,secretKey:a.bytesLen},keygen:(d=Pn(64))=>{Te(d,64,"seed");let{publicKey:f,secretKey:m}=t.keygen(d.subarray(0,32)),h=r(f),b=a.encode([m,f,h,d.subarray(32)]);return Rt(m,h),{publicKey:f,secretKey:b}},getPublicKey:(d)=>{let[f,m,h,b]=a.decode(d);return Uint8Array.from(m)},encapsulate:(d,f=Pn(32))=>{Te(d,s.publicKey,"publicKey"),Te(f,32,"message");let m=d.subarray(0,384*e.K),h=i.encode(i.decode(u1(m)));if(!dp(h,m))throw Rt(h),Error("ML-KEM.encapsulate: wrong publicKey modulus");Rt(h);let b=o.create().update(f).update(r(d)).digest(),y=t.encrypt(d,f,b.subarray(32,64));return Rt(b.subarray(32)),{cipherText:y,sharedSecret:b.subarray(0,32)}},decapsulate:(d,f)=>{Te(f,a.bytesLen,"secretKey"),Te(d,s.cipherText,"cipherText");let m=a.bytesLen-96,h=m+32,b=r(f.subarray(m/2,h));if(!dp(b,f.subarray(h,h+32)))throw Error("invalid secretKey: hash check failed");let[y,S,x,_]=a.decode(f),A=t.decrypt(d,y),O=o.create().update(A).update(x).digest(),L=O.subarray(0,32),z=t.encrypt(S,A,O.subarray(32,64)),K=dp(d,z),P=n.create({dkLen:32}).update(_).update(d).digest();return Rt(A,z,!K?L:P),K?L:P}}}function vJ(e,t,r){return Cn.create({dkLen:e}).update(t).update(new Uint8Array([r])).digest()}var Fb={HASH256:fs,HASH512:o1,KDF:Cn,XOF:f1,PRF:vJ},pge=Mb({...Fb,...qb[512]}),Ql=Mb({...Fb,...qb[768]}),m1=Mb({...Fb,...qb[1024]});/*! noble-post-quantum - MIT License (c) 2024 Paul Miller (paulmillr.com) */function wJ(e,t=!1){let{lengths:r,keygen:o}=e;if(t){let i=e.Point.Fn;if(!i)throw Error("No Point.Fn");o=(s=Pn(r.seed))=>{Te(s,r.seed,"seed");let a=i.isLE?Qo(s):Go(s),c=i.toBytes(i.create(a));return{secretKey:c,publicKey:e.getPublicKey(c)}}}return{lengths:{secretKey:r.secretKey,publicKey:r.publicKey,seed:r.seed},keygen:o,getPublicKey:(n)=>e.getPublicKey(n)}}function Jb(e,t=!1){let r=wJ(e,t);if(!e.getSharedSecret)throw Error("wrong curve");return{lengths:{...r.lengths,msg:r.lengths.seed,cipherText:r.lengths.publicKey},keygen:r.keygen,getPublicKey:r.getPublicKey,encapsulate(o,n=Pn(e.lengths.seed)){let i=this.keygen(n).secretKey,s=this.decapsulate(o,i),a=e.getPublicKey(i);return Rt(i),{sharedSecret:s,cipherText:a}},decapsulate(o,n){let i=e.getSharedSecret(n,o);return e.lengths.publicKeyHasPrefix?i.subarray(1):i}}}function Yl(e,t){return ps(t,...e.map((r)=>{if(typeof r.lengths[t]!=="number")throw Error("wrong length: "+t);return r.lengths[t]}))}function Kb(e){return(t,r)=>e(t,{dkLen:r})}function xJ(e,t,...r){let o=Yl(r,"seed"),n=Yl(r,"publicKey");if(e===void 0)e=o.bytesLen;Dt(e);function i(s){Te(s,e);let a=o.decode(t(s,o.bytesLen)),c=r.map((f,m)=>f.keygen(a[m])),u=c.map((f)=>f.secretKey),d=c.map((f)=>f.publicKey);return{secretKey:u,publicKey:d}}return{info:{lengths:{seed:e,publicKey:n.bytesLen,secretKey:e}},getPublicKey(s){return this.keygen(s).publicKey},keygen(s=Pn(e)){let{publicKey:a,secretKey:c}=i(s),u=n.encode(a);return Rt(a),Rt(c),{secretKey:s,publicKey:u}},expandDecapsulationKey:i,realSeedLen:e}}function mp(e,t,r,o,...n){let i=xJ(e,r,...n),s=Yl(n,"cipherText"),a=Yl(n,"publicKey"),c=Yl(n,"msg");if(t===void 0)t=c.bytesLen;return Dt(t),{lengths:{...i.info.lengths,msg:t,msgRand:c.bytesLen,cipherText:s.bytesLen},getPublicKey:i.getPublicKey,keygen:i.keygen,encapsulate(u,d=Pn(c.bytesLen)){let f=a.decode(u),m=c.decode(d),h=n.map((x,_)=>x.encapsulate(f[_],m[_])),b=h.map((x)=>x.sharedSecret),y=h.map((x)=>x.cipherText),S={sharedSecret:o(f,y,b),cipherText:s.encode(y)};return Rt(b,y),S},decapsulate(u,d){let f=s.decode(u),{publicKey:m,secretKey:h}=i.expandDecapsulationKey(d),b=n.map((y,S)=>y.decapsulate(f[S],h[S]));return o(m,f,b)}}}function h1(e,t,r,o,n){return Mr(o),Mr(n),mp(32,32,Kb(o),(i,s,a)=>n(Et(a[0],a[1],s[1],i[1],Yo(e))),t,r)}var Ege=h1("QSF-KEM(ML-KEM-768,P-256)-XOF(SHAKE256)-KDF(SHA3-256)",Ql,Jb(Db,!0),Cn,fs),Ige=h1("QSF-KEM(ML-KEM-1024,P-384)-XOF(SHAKE256)-KDF(SHA3-256)",m1,Jb(HO,!0),Cn,fs);function _J(e,t,r,o,n){return Mr(o),Mr(n),mp(32,32,Kb(o),(i,s,a)=>{let c=Et(a[0],a[1],s[0],i[0],s[1],i[1],Yo(e)),u=32,d=Et(Yo("hybrid_prk"),c),f=WO(n,d),m=Et(va(32,2),Yo("shared_secret"),Yo("")),h=GO(n,f,m,32);return Rt(f,m,d,c),h},t,r)}var g1=Jb(KO),kge=_J("KitchenSink-KEM(ML-KEM-768,X25519)-XOF(SHAKE256)-KDF(HKDF-SHA-256)",Ql,g1,Cn,lp),EJ=(()=>mp(32,32,Kb(Cn),(e,t,r)=>fs(Et(r[0],r[1],t[1],e[1],Yo("\\.//^\\"))),Ql,g1))();function IJ(e,t,r,o){let n=e.Point.Fn;if(!n)throw Error("no Point.Fn");function i(s){let a;for(let d=0,f=t;;d=f,f+=t){if(f>s.length)throw Error("rejection sampling failed");if(a=n.fromBytes(s.subarray(d,f),!0),n.isValidNot0(a))break}let c=n.toBytes(n.create(a)),u=e.getPublicKey(c,!1);return{secretKey:c,publicKey:u}}return{lengths:{secretKey:t,publicKey:r,seed:o,msg:o,cipherText:r},keygen(s=Pn(o)){return Te(s,o,"seed"),i(s)},getPublicKey(s){return e.getPublicKey(s,!1)},encapsulate(s,a=Pn(o)){Te(a,o,"rand");let{secretKey:c}=i(a),u=this.decapsulate(s,c),d=e.getPublicKey(c,!1);return Rt(c),{sharedSecret:u,cipherText:d}},decapsulate(s,a){return e.getSharedSecret(a,s).subarray(1)}}}function kJ(e,t,r,o){let{secretKey:n,publicKeyUncompressed:i}=r.lengths;if(!n||!i)throw Error("wrong curve");let s=IJ(r,n,i,o),a=64,c=a+o;return mp(32,32,(u)=>{Te(u,32);let d=Cn(u,{dkLen:c}),f=d.subarray(0,a),m=d.subarray(a,c);return Et(f,m)},(u,d,f)=>fs(Et(f[0],f[1],d[1],u[1],Yo(e))),t,s)}var AJ=(()=>kJ("MLKEM768-P256",Ql,Db,128))();var hp=EJ,y1=AJ;/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */var Ye=(e,t,r)=>Ut(e,t,r),Vb=St,Ia=Bf,Jt=(...e)=>Qy(...e),ka=(e)=>$l(e),Aa=Vy,Ta=(e)=>oo(e),yp=BigInt(0),Hb=BigInt(1);function po(e,t=""){if(typeof e!=="boolean"){let r=t&&`"${t}" `;throw TypeError(r+"expected boolean, got type="+typeof e)}return e}function bp(e){if(typeof e==="bigint"){if(!gp(e))throw RangeError("positive bigint expected, got "+e)}else Vb(e);return e}function zn(e,t=""){if(typeof e!=="number"){let r=t&&`"${t}" `;throw TypeError(r+"expected number, got type="+typeof e)}if(!Number.isSafeInteger(e)){let r=t&&`"${t}" `;throw RangeError(r+"expected safe integer, got "+e)}}function Xl(e){let t=bp(e).toString(16);return t.length&1?"0"+t:t}function b1(e){if(typeof e!=="string")throw TypeError("hex string expected, got "+typeof e);return e===""?yp:BigInt("0x"+e)}function gs(e){return b1(Bf(e))}function sn(e){return b1(Bf(ni(Ut(e)).reverse()))}function Sp(e,t){if(St(t),t===0)throw RangeError("zero length");e=bp(e);let r=e.toString(16);if(r.length>t*2)throw RangeError("number too large");return $l(r.padStart(t*2,"0"))}function eu(e,t){return Sp(e,t).reverse()}function S1(e,t){if(e=Ye(e),t=Ye(t),e.length!==t.length)return!1;let r=0;for(let o=0;o<e.length;o++)r|=e[o]^t[o];return r===0}function ni(e){return Uint8Array.from(Ye(e))}function vp(e){if(typeof e!=="string")throw TypeError("ascii string expected, got "+typeof e);return Uint8Array.from(e,(t,r)=>{let o=t.charCodeAt(0);if(t.length!==1||o>127)throw RangeError(`string contains non-ASCII character "${e[r]}" with code ${o} at position ${r}`);return o})}var gp=(e)=>typeof e==="bigint"&&yp<=e;function TJ(e,t,r){return gp(e)&&gp(t)&&gp(r)&&t<=e&&e<r}function mo(e,t,r,o){if(!TJ(t,r,o))throw RangeError("expected valid "+e+": "+r+" <= n < "+o+", got "+t)}function $a(e){if(e<yp)throw Error("expected non-negative bigint, got "+e);let t;for(t=0;e>yp;e>>=Hb,t+=1);return t}var tu=(e)=>(Hb<<BigInt(e))-Hb;function v1(e,t,r){if(St(e,"hashLen"),St(t,"qByteLen"),typeof r!=="function")throw TypeError("hmacFn must be a function");let o=(S)=>new Uint8Array(S),n=Uint8Array.of(),i=Uint8Array.of(0),s=Uint8Array.of(1),a=1000,c=o(e),u=o(e),d=0,f=()=>{c.fill(1),u.fill(0),d=0},m=(...S)=>r(u,Jt(c,...S)),h=(S=n)=>{if(u=m(i,S),c=m(),S.length===0)return;u=m(s,S),c=m()},b=()=>{if(d++>=a)throw Error("drbg: tried max amount of iterations");let S=0,x=[];while(S<t){c=m();let _=c.slice();x.push(_),S+=c.length}return Jt(...x)};return(S,x)=>{f(),h(S);let _=void 0;while((_=x(b()))===void 0)h();return f(),_}}function Jr(e,t={},r={}){if(Object.prototype.toString.call(e)!=="[object Object]")throw TypeError("expected valid options object");function o(i,s,a){if(!a&&s!=="function"&&!Object.hasOwn(e,i))throw TypeError(`param "${i}" is invalid: expected own property`);let c=e[i];if(a&&c===void 0)return;let u=typeof c;if(u!==s||c===null)throw TypeError(`param "${i}" is invalid: expected ${s}, got ${u}`)}let n=(i,s)=>Object.entries(i).forEach(([a,c])=>o(a,c,s));n(t,!1),n(r,!0)}var Wb=()=>{throw Error("not implemented")};/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */var Kt=BigInt(0),mt=BigInt(1),ys=BigInt(2),E1=BigInt(3),I1=BigInt(4),k1=BigInt(5),$J=BigInt(7),A1=BigInt(8),RJ=BigInt(9),T1=BigInt(16);function it(e,t){if(t<=Kt)throw Error("mod: expected positive modulus, got "+t);let r=e%t;return r>=Kt?r:t+r}function Kr(e,t,r){if(t<Kt)throw Error("pow2: expected non-negative exponent, got "+t);let o=e;while(t-- >Kt)o*=o,o%=r;return o}function w1(e,t){if(e===Kt)throw Error("invert: expected non-zero number");if(t<=Kt)throw Error("invert: expected positive modulus, got "+t);let r=it(e,t),o=t,n=Kt,i=mt,s=mt,a=Kt;while(r!==Kt){let u=o/r,d=o-r*u,f=n-s*u,m=i-a*u;o=r,r=d,n=s,i=a,s=f,a=m}if(o!==mt)throw Error("invert: does not exist");return it(n,t)}function Gb(e,t,r){let o=e;if(!o.eql(o.sqr(t),r))throw Error("Cannot find square root")}function $1(e,t){let r=e,o=(r.ORDER+mt)/I1,n=r.pow(t,o);return Gb(r,n,t),n}function OJ(e,t){let r=e,o=(r.ORDER-k1)/A1,n=r.mul(t,ys),i=r.pow(n,o),s=r.mul(t,i),a=r.mul(r.mul(s,ys),i),c=r.mul(s,r.sub(a,r.ONE));return Gb(r,c,t),c}function CJ(e){let t=wp(e),r=R1(e),o=r(t,t.neg(t.ONE)),n=r(t,o),i=r(t,t.neg(o)),s=(e+$J)/T1;return(a,c)=>{let u=a,d=u.pow(c,s),f=u.mul(d,o),m=u.mul(d,n),h=u.mul(d,i),b=u.eql(u.sqr(f),c),y=u.eql(u.sqr(m),c);d=u.cmov(d,f,b),f=u.cmov(h,m,y);let S=u.eql(u.sqr(f),c),x=u.cmov(d,f,S);return Gb(u,x,c),x}}function R1(e){if(e<E1)throw Error("sqrt is not defined for small field");let t=e-mt,r=0;while(t%ys===Kt)t/=ys,r++;let o=ys,n=wp(e);while(x1(n,o)===1)if(o++>1000)throw Error("Cannot find square root: probably non-prime P");if(r===1)return $1;let i=n.pow(o,t),s=(t+mt)/ys;return function(c,u){let d=c;if(d.is0(u))return u;if(x1(d,u)!==1)throw Error("Cannot find square root");let f=r,m=d.mul(d.ONE,i),h=d.pow(u,t),b=d.pow(u,s);while(!d.eql(h,d.ONE)){if(d.is0(h))return d.ZERO;let y=1,S=d.sqr(h);while(!d.eql(S,d.ONE))if(y++,S=d.sqr(S),y===f)throw Error("Cannot find square root");let x=mt<<BigInt(f-y-1),_=d.pow(m,x);f=y,m=d.sqr(_),h=d.mul(h,m),b=d.mul(b,_)}return b}}function PJ(e){if(e%I1===E1)return $1;if(e%A1===k1)return OJ;if(e%T1===RJ)return CJ(e);return R1(e)}var ho=(e,t)=>(it(e,t)&mt)===mt,zJ=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function Qb(e){let t={ORDER:"bigint",BYTES:"number",BITS:"number"},r=zJ.reduce((o,n)=>(o[n]="function",o),t);if(Jr(e,r),zn(e.BYTES,"BYTES"),zn(e.BITS,"BITS"),e.BYTES<1||e.BITS<1)throw Error("invalid field: expected BYTES/BITS > 0");if(e.ORDER<=mt)throw Error("invalid field: expected ORDER > 1, got "+e.ORDER);return e}function NJ(e,t,r){let o=e;if(r<Kt)throw Error("invalid exponent, negatives unsupported");if(r===Kt)return o.ONE;if(r===mt)return t;let n=o.ONE,i=t;while(r>Kt){if(r&mt)n=o.mul(n,i);i=o.sqr(i),r>>=mt}return n}function ru(e,t,r=!1){let o=e,n=Array(t.length).fill(r?o.ZERO:void 0),i=t.reduce((a,c,u)=>{if(o.is0(c))return a;return n[u]=a,o.mul(a,c)},o.ONE),s=o.inv(i);return t.reduceRight((a,c,u)=>{if(o.is0(c))return a;return n[u]=o.mul(a,n[u]),o.mul(a,c)},s),n}function x1(e,t){let r=e,o=(r.ORDER-mt)/ys,n=r.pow(t,o),i=r.eql(n,r.ONE),s=r.eql(n,r.ZERO),a=r.eql(n,r.neg(r.ONE));if(!i&&!s&&!a)throw Error("invalid Legendre symbol result");return i?1:s?0:-1}function DJ(e,t){if(t!==void 0)Vb(t);if(e<=Kt)throw Error("invalid n length: expected positive n, got "+e);if(t!==void 0&&t<1)throw Error("invalid n length: expected positive bit length, got "+t);let r=$a(e);if(t!==void 0&&t<r)throw Error(`invalid n length: expected bit length (${r}) >= n.length (${t})`);let o=t!==void 0?t:r,n=Math.ceil(o/8);return{nBitLength:o,nByteLength:n}}var _1=new WeakMap;class Yb{ORDER;BITS;BYTES;isLE;ZERO=Kt;ONE=mt;_lengths;_mod;constructor(e,t={}){if(e<=mt)throw Error("invalid field: expected ORDER > 1, got "+e);let r=void 0;if(this.isLE=!1,t!=null&&typeof t==="object"){if(typeof t.BITS==="number")r=t.BITS;if(typeof t.sqrt==="function")Object.defineProperty(this,"sqrt",{value:t.sqrt,enumerable:!0});if(typeof t.isLE==="boolean")this.isLE=t.isLE;if(t.allowedLengths)this._lengths=Object.freeze(t.allowedLengths.slice());if(typeof t.modFromBytes==="boolean")this._mod=t.modFromBytes}let{nBitLength:o,nByteLength:n}=DJ(e,r);if(n>2048)throw Error("invalid field: expected ORDER of <= 2048 bytes");this.ORDER=e,this.BITS=o,this.BYTES=n,Object.freeze(this)}create(e){return it(e,this.ORDER)}isValid(e){if(typeof e!=="bigint")throw TypeError("invalid field element: expected bigint, got "+typeof e);return Kt<=e&&e<this.ORDER}is0(e){return e===Kt}isValidNot0(e){return!this.is0(e)&&this.isValid(e)}isOdd(e){return(e&mt)===mt}neg(e){return it(-e,this.ORDER)}eql(e,t){return e===t}sqr(e){return it(e*e,this.ORDER)}add(e,t){return it(e+t,this.ORDER)}sub(e,t){return it(e-t,this.ORDER)}mul(e,t){return it(e*t,this.ORDER)}pow(e,t){return NJ(this,e,t)}div(e,t){return it(e*w1(t,this.ORDER),this.ORDER)}sqrN(e){return e*e}addN(e,t){return e+t}subN(e,t){return e-t}mulN(e,t){return e*t}inv(e){return w1(e,this.ORDER)}sqrt(e){let t=_1.get(this);if(!t)_1.set(this,t=PJ(this.ORDER));return t(this,e)}toBytes(e){return this.isLE?eu(e,this.BYTES):Sp(e,this.BYTES)}fromBytes(e,t=!1){Ye(e);let{_lengths:r,BYTES:o,isLE:n,ORDER:i,_mod:s}=this;if(r){if(e.length<1||!r.includes(e.length)||e.length>o)throw Error("Field.fromBytes: expected "+r+" bytes, got "+e.length);let c=new Uint8Array(o);c.set(e,n?0:c.length-e.length),e=c}if(e.length!==o)throw Error("Field.fromBytes: expected "+o+" bytes, got "+e.length);let a=n?sn(e):gs(e);if(s)a=it(a,i);if(!t){if(!this.isValid(a))throw Error("invalid field element: outside of range 0..ORDER")}return a}invertBatch(e){return ru(this,e)}cmov(e,t,r){return po(r,"condition"),r?t:e}}Object.freeze(Yb.prototype);function wp(e,t={}){return new Yb(e,t)}function O1(e){if(typeof e!=="bigint")throw Error("field order must be bigint");if(e<=mt)throw Error("field order must be greater than 1");let t=$a(e-mt);return Math.ceil(t/8)}function Xb(e){let t=O1(e);return t+Math.ceil(t/2)}function C1(e,t,r=!1){Ye(e);let o=e.length,n=O1(t),i=Math.max(Xb(t),16);if(o<i||o>1024)throw Error("expected "+i+"-1024 bytes of input, got "+o);let s=r?sn(e):gs(e),a=it(s,t-mt)+mt;return r?eu(a,n):Sp(a,n)}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */var Ra=BigInt(0),bs=BigInt(1);function nu(e,t){let r=t.negate();return e?r:t}function Ss(e,t){let r=ru(e.Fp,t.map((o)=>o.Z));return t.map((o,n)=>e.fromAffine(o.toAffine(r[n])))}function D1(e,t){if(!Number.isSafeInteger(e)||e<=0||e>t)throw Error("invalid window size, expected [1.."+t+"], got W="+e)}function eS(e,t){D1(e,t);let r=Math.ceil(t/e)+1,o=2**(e-1),n=2**e,i=tu(e),s=BigInt(e);return{windows:r,windowSize:o,mask:i,maxNumber:n,shiftBy:s}}function P1(e,t,r){let{windowSize:o,mask:n,maxNumber:i,shiftBy:s}=r,a=Number(e&n),c=e>>s;if(a>o)a-=i,c+=bs;let u=t*o,d=u+Math.abs(a)-1,f=a===0,m=a<0,h=t%2!==0;return{nextN:c,offset:d,isZero:f,isNeg:m,isNegF:h,offsetF:u}}var tS=new WeakMap,L1=new WeakMap;function rS(e){return L1.get(e)||1}function z1(e){if(e!==Ra)throw Error("invalid wNAF")}class ou{BASE;ZERO;Fn;bits;constructor(e,t){this.BASE=e.BASE,this.ZERO=e.ZERO,this.Fn=e.Fn,this.bits=t}_unsafeLadder(e,t,r=this.ZERO){let o=e;while(t>Ra){if(t&bs)r=r.add(o);o=o.double(),t>>=bs}return r}precomputeWindow(e,t){let{windows:r,windowSize:o}=eS(t,this.bits),n=[],i=e,s=i;for(let a=0;a<r;a++){s=i,n.push(s);for(let c=1;c<o;c++)s=s.add(i),n.push(s);i=s.double()}return n}wNAF(e,t,r){if(!this.Fn.isValid(r))throw Error("invalid scalar");let o=this.ZERO,n=this.BASE,i=eS(e,this.bits);for(let s=0;s<i.windows;s++){let{nextN:a,offset:c,isZero:u,isNeg:d,isNegF:f,offsetF:m}=P1(r,s,i);if(r=a,u)n=n.add(nu(f,t[m]));else o=o.add(nu(d,t[c]))}return z1(r),{p:o,f:n}}wNAFUnsafe(e,t,r,o=this.ZERO){let n=eS(e,this.bits);for(let i=0;i<n.windows;i++){if(r===Ra)break;let{nextN:s,offset:a,isZero:c,isNeg:u}=P1(r,i,n);if(r=s,c)continue;else{let d=t[a];o=o.add(u?d.negate():d)}}return z1(r),o}getPrecomputes(e,t,r){let o=tS.get(t);if(!o){if(o=this.precomputeWindow(t,e),e!==1){if(typeof r==="function")o=r(o);tS.set(t,o)}}return o}cached(e,t,r){let o=rS(e);return this.wNAF(o,this.getPrecomputes(o,e,r),t)}unsafe(e,t,r,o){let n=rS(e);if(n===1)return this._unsafeLadder(e,t,o);return this.wNAFUnsafe(n,this.getPrecomputes(n,e,r),t,o)}createCache(e,t){D1(t,this.bits),L1.set(e,t),tS.delete(e)}hasCache(e){return rS(e)!==1}}function j1(e,t,r,o){let n=t,i=e.ZERO,s=e.ZERO;while(r>Ra||o>Ra){if(r&bs)i=i.add(n);if(o&bs)s=s.add(n);n=n.double(),r>>=bs,o>>=bs}return{p1:i,p2:s}}function N1(e,t,r){if(t){if(t.ORDER!==e)throw Error("Field.ORDER must match order: Fp == p, Fn == n");return Qb(t),t}else return wp(e,{isLE:r})}function xp(e,t,r={},o){if(o===void 0)o=e==="edwards";if(!t||typeof t!=="object")throw Error(`expected valid ${e} CURVE object`);for(let c of["p","n","h"]){let u=t[c];if(!(typeof u==="bigint"&&u>Ra))throw Error(`CURVE.${c} must be positive bigint`)}let n=N1(t.p,r.Fp,o),i=N1(t.n,r.Fn,o),a=["Gx","Gy","a",e==="weierstrass"?"b":"d"];for(let c of a)if(!n.isValid(t[c]))throw Error(`CURVE.${c} must be valid field element of CURVE.Fp`);return t=Object.freeze(Object.assign({},t)),{CURVE:t,Fp:n,Fn:i}}function iu(e,t){return function(o){let n=e(o);return{secretKey:n,publicKey:t(n)}}}function su(e,t){if(zn(e),zn(t),t<0||t>4)throw Error("invalid I2OSP length: "+t);if(e<0||e>2**(8*t)-1)throw Error("invalid I2OSP input: "+e);let r=Array.from({length:t}).fill(0);for(let o=t-1;o>=0;o--)r[o]=e&255,e>>>=8;return new Uint8Array(r)}function LJ(e,t){let r=new Uint8Array(e.length);for(let o=0;o<e.length;o++)r[o]=e[o]^t[o];return r}function jJ(e){if(!Aa(e)&&typeof e!=="string")throw Error("DST must be Uint8Array or ascii string");let t=typeof e==="string"?vp(e):e;if(t.length===0)throw Error("DST must be non-empty");return t}function nS(e,t,r,o){if(Ye(e),zn(r),t=jJ(t),t.length>255)t=o(Jt(vp("H2C-OVERSIZE-DST-"),t));let{outputLen:n,blockLen:i}=o,s=Math.ceil(r/n);if(r>65535||s>255)throw Error("expand_message_xmd: invalid lenInBytes");let a=Jt(t,su(t.length,1)),c=new Uint8Array(i),u=su(r,2),d=Array(s),f=o(Jt(c,e,u,su(0,1),a));d[0]=o(Jt(f,su(1,1),a));for(let h=1;h<s;h++){let b=[LJ(f,d[h-1]),su(h+1,1),a];d[h]=o(Jt(...b))}return Jt(...d).slice(0,r)}var B1="HashToScalar-";/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */var Z1=(e,t)=>(e+(e>=0?t:-t)/q1)/t;function BJ(e,t,r){mo("scalar",e,Nn,r);let[[o,n],[i,s]]=t,a=Z1(s*e,r),c=Z1(-n*e,r),u=e-a*o-c*i,d=-a*n-c*s,f=u<Nn,m=d<Nn;if(f)u=-u;if(m)d=-d;let h=tu(Math.ceil($a(r)/2))+oi;if(u<Nn||u>=h||d<Nn||d>=h)throw Error("splitScalar (endomorphism): failed for k");return{k1neg:f,k1:u,k2neg:m,k2:d}}function iS(e){if(!["compact","recovered","der"].includes(e))throw Error('Signature format must be "compact", "recovered", or "der"');return e}function oS(e,t){Jr(e);let r={};for(let o of Object.keys(t))r[o]=e[o]===void 0?t[o]:e[o];if(po(r.lowS,"lowS"),po(r.prehash,"prehash"),r.format!==void 0)iS(r.format);return r}class U1 extends Error{constructor(e=""){super(e)}}var an={Err:U1,_tlv:{encode:(e,t)=>{let{Err:r}=an;if(zn(e,"tag"),e<0||e>255)throw new r("tlv.encode: wrong tag");if(typeof t!=="string")throw TypeError('"data" expected string, got type='+typeof t);if(t.length&1)throw new r("tlv.encode: unpadded data");let o=t.length/2,n=Xl(o);if(n.length/2&128)throw new r("tlv.encode: long form length too big");let i=o>127?Xl(n.length/2|128):"";return Xl(e)+i+n+t},decode(e,t){let{Err:r}=an;t=Ye(t,void 0,"DER data");let o=0;if(e<0||e>255)throw new r("tlv.encode: wrong tag");if(t.length<2||t[o++]!==e)throw new r("tlv.decode: wrong tlv");let n=t[o++],i=!!(n&128),s=0;if(!i)s=n;else{let c=n&127;if(!c)throw new r("tlv.decode(long): indefinite length not supported");if(c>4)throw new r("tlv.decode(long): byte length is too big");let u=t.subarray(o,o+c);if(u.length!==c)throw new r("tlv.decode: length bytes not complete");if(u[0]===0)throw new r("tlv.decode(long): zero leftmost byte");for(let d of u)s=s<<8|d;if(o+=c,s<128)throw new r("tlv.decode(long): not minimal encoding")}let a=t.subarray(o,o+s);if(a.length!==s)throw new r("tlv.decode: wrong value length");return{v:a,l:t.subarray(o+s)}}},_int:{encode(e){let{Err:t}=an;if(bp(e),e<Nn)throw new t("integer: negative integers are not allowed");let r=Xl(e);if(Number.parseInt(r[0],16)&8)r="00"+r;if(r.length&1)throw new t("unexpected DER parsing assertion: unpadded hex");return r},decode(e){let{Err:t}=an;if(e.length<1)throw new t("invalid signature integer: empty");if(e[0]&128)throw new t("invalid signature integer: negative");if(e.length>1&&e[0]===0&&!(e[1]&128))throw new t("invalid signature integer: unnecessary leading zero");return gs(e)}},toSig(e){let{Err:t,_int:r,_tlv:o}=an,n=Ye(e,void 0,"signature"),{v:i,l:s}=o.decode(48,n);if(s.length)throw new t("invalid signature: left bytes after parsing");let{v:a,l:c}=o.decode(2,i),{v:u,l:d}=o.decode(2,c);if(d.length)throw new t("invalid signature: left bytes after parsing");return{r:r.decode(a),s:r.decode(u)}},hexFromSig(e){let{_tlv:t,_int:r}=an,o=t.encode(2,r.encode(e.r)),n=t.encode(2,r.encode(e.s)),i=o+n;return t.encode(48,i)}};Object.freeze(an._tlv);Object.freeze(an._int);Object.freeze(an);var Nn=BigInt(0),oi=BigInt(1),q1=BigInt(2),_p=BigInt(3),ZJ=BigInt(4);function M1(e,t={}){let r=xp("weierstrass",e,t),o=r.Fp,n=r.Fn,i=r.CURVE,{h:s,n:a}=i;Jr(t,{},{allowInfinityPoint:"boolean",clearCofactor:"function",isTorsionFree:"function",fromBytes:"function",toBytes:"function",endo:"object"});let{endo:c,allowInfinityPoint:u}=t;if(c){if(!o.is0(i.a)||typeof c.beta!=="bigint"||!Array.isArray(c.basises))throw Error('invalid endo: expected "beta": bigint and "basises": array')}let d=J1(o,n);function f(){if(!o.isOdd)throw Error("compression is not supported: Field does not have .isOdd()")}function m(B,R,j){if(u&&R.is0())return Uint8Array.of(0);let{x:I,y:T}=R.toAffine(),k=o.toBytes(I);if(po(j,"isCompressed"),j){f();let M=!o.isOdd(T);return Jt(F1(M),k)}else return Jt(Uint8Array.of(4),k,o.toBytes(T))}function h(B){Ye(B,void 0,"Point");let{publicKey:R,publicKeyUncompressed:j}=d,I=B.length,T=B[0],k=B.subarray(1);if(u&&I===1&&T===0)return{x:o.ZERO,y:o.ZERO};if(I===R&&(T===2||T===3)){let M=o.fromBytes(k);if(!o.isValid(M))throw Error("bad point: is not on curve, wrong x");let N=S(M),H;try{H=o.sqrt(N)}catch(ae){let pe=ae instanceof Error?": "+ae.message:"";throw Error("bad point: is not on curve, sqrt error"+pe)}f();let G=o.isOdd(H);if((T&1)===1!==G)H=o.neg(H);return{x:M,y:H}}else if(I===j&&T===4){let M=o.BYTES,N=o.fromBytes(k.subarray(0,M)),H=o.fromBytes(k.subarray(M,M*2));if(!x(N,H))throw Error("bad point: is not on curve");return{x:N,y:H}}else throw Error(`bad point: got length ${I}, expected compressed=${R} or uncompressed=${j}`)}let b=t.toBytes===void 0?m:t.toBytes,y=t.fromBytes===void 0?h:t.fromBytes;function S(B){let R=o.sqr(B),j=o.mul(R,B);return o.add(o.add(j,o.mul(B,i.a)),i.b)}function x(B,R){let j=o.sqr(R),I=S(B);return o.eql(j,I)}if(!x(i.Gx,i.Gy))throw Error("bad curve params: generator point");let _=o.mul(o.pow(i.a,_p),ZJ),A=o.mul(o.sqr(i.b),BigInt(27));if(o.is0(o.add(_,A)))throw Error("bad curve params: a or b");function O(B,R,j=!1){if(!o.isValid(R)||j&&o.is0(R))throw Error(`bad point coordinate ${B}`);return R}function L(B){if(!(B instanceof P))throw Error("Weierstrass Point expected")}function z(B){if(!c||!c.basises)throw Error("no endo");return BJ(B,c.basises,n.ORDER)}function K(B,R,j,I,T){return j=new P(o.mul(j.X,B),j.Y,j.Z),R=nu(I,R),j=nu(T,j),R.add(j)}class P{static BASE=new P(i.Gx,i.Gy,o.ONE);static ZERO=new P(o.ZERO,o.ONE,o.ZERO);static Fp=o;static Fn=n;X;Y;Z;constructor(B,R,j){this.X=O("x",B),this.Y=O("y",R,!0),this.Z=O("z",j),Object.freeze(this)}static CURVE(){return i}static fromAffine(B){let{x:R,y:j}=B||{};if(!B||!o.isValid(R)||!o.isValid(j))throw Error("invalid affine point");if(B instanceof P)throw Error("projective point not allowed");if(o.is0(R)&&o.is0(j))return P.ZERO;return new P(R,j,o.ONE)}static fromBytes(B){let R=P.fromAffine(y(Ye(B,void 0,"point")));return R.assertValidity(),R}static fromHex(B){return P.fromBytes(ka(B))}get x(){return this.toAffine().x}get y(){return this.toAffine().y}precompute(B=8,R=!0){if(ee.createCache(this,B),!R)this.multiply(_p);return this}assertValidity(){let B=this;if(B.is0()){if(t.allowInfinityPoint&&o.is0(B.X)&&o.eql(B.Y,o.ONE)&&o.is0(B.Z))return;throw Error("bad point: ZERO")}let{x:R,y:j}=B.toAffine();if(!o.isValid(R)||!o.isValid(j))throw Error("bad point: x or y not field elements");if(!x(R,j))throw Error("bad point: equation left != right");if(!B.isTorsionFree())throw Error("bad point: not in prime-order subgroup")}hasEvenY(){let{y:B}=this.toAffine();if(!o.isOdd)throw Error("Field doesn't support isOdd");return!o.isOdd(B)}equals(B){L(B);let{X:R,Y:j,Z:I}=this,{X:T,Y:k,Z:M}=B,N=o.eql(o.mul(R,M),o.mul(T,I)),H=o.eql(o.mul(j,M),o.mul(k,I));return N&&H}negate(){return new P(this.X,o.neg(this.Y),this.Z)}double(){let{a:B,b:R}=i,j=o.mul(R,_p),{X:I,Y:T,Z:k}=this,M=o.ZERO,N=o.ZERO,H=o.ZERO,G=o.mul(I,I),re=o.mul(T,T),ae=o.mul(k,k),pe=o.mul(I,T);return pe=o.add(pe,pe),H=o.mul(I,k),H=o.add(H,H),M=o.mul(B,H),N=o.mul(j,ae),N=o.add(M,N),M=o.sub(re,N),N=o.add(re,N),N=o.mul(M,N),M=o.mul(pe,M),H=o.mul(j,H),ae=o.mul(B,ae),pe=o.sub(G,ae),pe=o.mul(B,pe),pe=o.add(pe,H),H=o.add(G,G),G=o.add(H,G),G=o.add(G,ae),G=o.mul(G,pe),N=o.add(N,G),ae=o.mul(T,k),ae=o.add(ae,ae),G=o.mul(ae,pe),M=o.sub(M,G),H=o.mul(ae,re),H=o.add(H,H),H=o.add(H,H),new P(M,N,H)}add(B){L(B);let{X:R,Y:j,Z:I}=this,{X:T,Y:k,Z:M}=B,N=o.ZERO,H=o.ZERO,G=o.ZERO,re=i.a,ae=o.mul(i.b,_p),pe=o.mul(R,T),be=o.mul(j,k),ve=o.mul(I,M),ke=o.add(R,j),Ie=o.add(T,k);ke=o.mul(ke,Ie),Ie=o.add(pe,be),ke=o.sub(ke,Ie),Ie=o.add(R,I);let we=o.add(T,M);return Ie=o.mul(Ie,we),we=o.add(pe,ve),Ie=o.sub(Ie,we),we=o.add(j,I),N=o.add(k,M),we=o.mul(we,N),N=o.add(be,ve),we=o.sub(we,N),G=o.mul(re,Ie),N=o.mul(ae,ve),G=o.add(N,G),N=o.sub(be,G),G=o.add(be,G),H=o.mul(N,G),be=o.add(pe,pe),be=o.add(be,pe),ve=o.mul(re,ve),Ie=o.mul(ae,Ie),be=o.add(be,ve),ve=o.sub(pe,ve),ve=o.mul(re,ve),Ie=o.add(Ie,ve),pe=o.mul(be,Ie),H=o.add(H,pe),pe=o.mul(we,Ie),N=o.mul(ke,N),N=o.sub(N,pe),pe=o.mul(ke,be),G=o.mul(we,G),G=o.add(G,pe),new P(N,H,G)}subtract(B){return L(B),this.add(B.negate())}is0(){return this.equals(P.ZERO)}multiply(B){let{endo:R}=t;if(!n.isValidNot0(B))throw RangeError("invalid scalar: out of range");let j,I,T=(k)=>ee.cached(this,k,(M)=>Ss(P,M));if(R){let{k1neg:k,k1:M,k2neg:N,k2:H}=z(B),{p:G,f:re}=T(M),{p:ae,f:pe}=T(H);I=re.add(pe),j=K(R.beta,G,ae,k,N)}else{let{p:k,f:M}=T(B);j=k,I=M}return Ss(P,[j,I])[0]}multiplyUnsafe(B){let{endo:R}=t,j=this,I=B;if(!n.isValid(I))throw RangeError("invalid scalar: out of range");if(I===Nn||j.is0())return P.ZERO;if(I===oi)return j;if(ee.hasCache(this))return this.multiply(I);if(R){let{k1neg:T,k1:k,k2neg:M,k2:N}=z(I),{p1:H,p2:G}=j1(P,j,k,N);return K(R.beta,H,G,T,M)}else return ee.unsafe(j,I)}toAffine(B){let R=this,j=B,{X:I,Y:T,Z:k}=R;if(o.eql(k,o.ONE))return{x:I,y:T};let M=R.is0();if(j==null)j=M?o.ONE:o.inv(k);let N=o.mul(I,j),H=o.mul(T,j),G=o.mul(k,j);if(M)return{x:o.ZERO,y:o.ZERO};if(!o.eql(G,o.ONE))throw Error("invZ was invalid");return{x:N,y:H}}isTorsionFree(){let{isTorsionFree:B}=t;if(s===oi)return!0;if(B)return B(P,this);return ee.unsafe(this,a).is0()}clearCofactor(){let{clearCofactor:B}=t;if(s===oi)return this;if(B)return B(P,this);return this.multiplyUnsafe(s)}isSmallOrder(){if(s===oi)return this.is0();return this.clearCofactor().is0()}toBytes(B=!0){return po(B,"isCompressed"),this.assertValidity(),b(P,this,B)}toHex(B=!0){return Ia(this.toBytes(B))}toString(){return`<Point ${this.is0()?"ZERO":this.toHex()}>`}}let W=n.BITS,ee=new ou(P,t.endo?Math.ceil(W/2):W);if(W>=8)P.BASE.precompute(8);return Object.freeze(P.prototype),Object.freeze(P),P}function F1(e){return Uint8Array.of(e?2:3)}function J1(e,t){return{secretKey:t.BYTES,publicKey:1+e.BYTES,publicKeyUncompressed:1+2*e.BYTES,publicKeyHasPrefix:!0,signature:2*t.BYTES}}function UJ(e,t={}){let{Fn:r}=e,o=t.randomBytes===void 0?Ta:t.randomBytes,n=Object.assign(J1(e.Fp,r),{seed:Math.max(Xb(r.ORDER),16)});function i(h){try{let b=r.fromBytes(h);return r.isValidNot0(b)}catch(b){return!1}}function s(h,b){let{publicKey:y,publicKeyUncompressed:S}=n;try{let x=h.length;if(b===!0&&x!==y)return!1;if(b===!1&&x!==S)return!1;return!!e.fromBytes(h)}catch(x){return!1}}function a(h){return h=h===void 0?o(n.seed):h,C1(Ye(h,n.seed,"seed"),r.ORDER)}function c(h,b=!0){return e.BASE.multiply(r.fromBytes(h)).toBytes(b)}function u(h){let{secretKey:b,publicKey:y,publicKeyUncompressed:S}=n,x=r._lengths;if(!Aa(h))return;let _=Ye(h,void 0,"key").length,A=_===y||_===S,O=_===b||!!x?.includes(_);if(A&&O)return;return A}function d(h,b,y=!0){if(u(h)===!0)throw Error("first arg must be private key");if(u(b)===!1)throw Error("second arg must be public key");let S=r.fromBytes(h);return e.fromBytes(b).multiply(S).toBytes(y)}let f={isValidSecretKey:i,isValidPublicKey:s,randomSecretKey:a},m=iu(a,c);return Object.freeze(f),Object.freeze(n),Object.freeze({getPublicKey:c,getSharedSecret:d,keygen:m,Point:e,utils:f,lengths:n})}function K1(e,t,r={}){let o=t;no(o),Jr(r,{},{hmac:"function",lowS:"boolean",randomBytes:"function",bits2int:"function",bits2int_modN:"function"}),r=Object.assign({},r);let n=r.randomBytes===void 0?Ta:r.randomBytes,i=r.hmac===void 0?(T,k)=>Tn(o,T,k):r.hmac,{Fp:s,Fn:a}=e,{ORDER:c,BITS:u}=a,{keygen:d,getPublicKey:f,getSharedSecret:m,utils:h,lengths:b}=UJ(e,r),y={prehash:!0,lowS:typeof r.lowS==="boolean"?r.lowS:!0,format:"compact",extraEntropy:!1},S=c*q1+oi<s.ORDER;function x(T){let k=c>>oi;return T>k}function _(T,k){if(!a.isValidNot0(k))throw Error(`invalid signature ${T}: out of range 1..Point.Fn.ORDER`);return k}function A(){if(S)throw Error('"recovered" sig type is not supported for cofactor >2 curves')}function O(T,k){iS(k);let M=b.signature,N=k==="compact"?M:k==="recovered"?M+1:void 0;return Ye(T,N)}class L{r;s;recovery;constructor(T,k,M){if(this.r=_("r",T),this.s=_("s",k),M!=null){if(A(),![0,1,2,3].includes(M))throw Error("invalid recovery id");this.recovery=M}Object.freeze(this)}static fromBytes(T,k=y.format){O(T,k);let M;if(k==="der"){let{r:re,s:ae}=an.toSig(Ye(T));return new L(re,ae)}if(k==="recovered")M=T[0],k="compact",T=T.subarray(1);let N=b.signature/2,H=T.subarray(0,N),G=T.subarray(N,N*2);return new L(a.fromBytes(H),a.fromBytes(G),M)}static fromHex(T,k){return this.fromBytes(ka(T),k)}assertRecovery(){let{recovery:T}=this;if(T==null)throw Error("invalid recovery id: must be present");return T}addRecoveryBit(T){return new L(this.r,this.s,T)}recoverPublicKey(T){let{r:k,s:M}=this,N=this.assertRecovery(),H=N===2||N===3?k+c:k;if(!s.isValid(H))throw Error("invalid recovery id: sig.r+curve.n != R.x");let G=s.toBytes(H),re=e.fromBytes(Jt(F1((N&1)===0),G)),ae=a.inv(H),pe=K(Ye(T,void 0,"msgHash")),be=a.create(-pe*ae),ve=a.create(M*ae),ke=e.BASE.multiplyUnsafe(be).add(re.multiplyUnsafe(ve));if(ke.is0())throw Error("invalid recovery: point at infinify");return ke.assertValidity(),ke}hasHighS(){return x(this.s)}toBytes(T=y.format){if(iS(T),T==="der")return ka(an.hexFromSig(this));let{r:k,s:M}=this,N=a.toBytes(k),H=a.toBytes(M);if(T==="recovered")return A(),Jt(Uint8Array.of(this.assertRecovery()),N,H);return Jt(N,H)}toHex(T){return Ia(this.toBytes(T))}}Object.freeze(L.prototype),Object.freeze(L);let z=r.bits2int===void 0?function(k){if(k.length>8192)throw Error("input is too large");let M=gs(k),N=k.length*8-u;return N>0?M>>BigInt(N):M}:r.bits2int,K=r.bits2int_modN===void 0?function(k){return a.create(z(k))}:r.bits2int_modN,P=tu(u);function W(T){return mo("num < 2^"+u,T,Nn,P),a.toBytes(T)}function ee(T,k){return Ye(T,void 0,"message"),k?Ye(o(T),void 0,"prehashed message"):T}function B(T,k,M){let{lowS:N,prehash:H,extraEntropy:G}=oS(M,y);T=ee(T,H);let re=K(T),ae=a.fromBytes(k);if(!a.isValidNot0(ae))throw Error("invalid private key");let pe=[W(ae),W(re)];if(G!=null&&G!==!1){let Ie=G===!0?n(b.secretKey):G;pe.push(Ye(Ie,void 0,"extraEntropy"))}let be=Jt(...pe),ve=re;function ke(Ie){let we=z(Ie);if(!a.isValidNot0(we))return;let Ue=a.inv(we),De=e.BASE.multiply(we).toAffine(),Qe=a.create(De.x);if(Qe===Nn)return;let bt=a.create(Ue*a.create(ve+Qe*ae));if(bt===Nn)return;let Tt=(De.x===Qe?0:2)|Number(De.y&oi),Nt=bt;if(N&&x(bt))Nt=a.neg(bt),Tt^=1;return new L(Qe,Nt,S?void 0:Tt)}return{seed:be,k2sig:ke}}function R(T,k,M={}){let{seed:N,k2sig:H}=B(T,k,M);return v1(o.outputLen,a.BYTES,i)(N,H).toBytes(M.format)}function j(T,k,M,N={}){let{lowS:H,prehash:G,format:re}=oS(N,y);if(M=Ye(M,void 0,"publicKey"),k=ee(k,G),!Aa(T)){let ae=T instanceof L?", use sig.toBytes()":"";throw Error("verify expects Uint8Array signature"+ae)}O(T,re);try{let ae=L.fromBytes(T,re),pe=e.fromBytes(M);if(H&&ae.hasHighS())return!1;let{r:be,s:ve}=ae,ke=K(k),Ie=a.inv(ve),we=a.create(ke*Ie),Ue=a.create(be*Ie),De=e.BASE.multiplyUnsafe(we).add(pe.multiplyUnsafe(Ue));if(De.is0())return!1;return a.create(De.x)===be}catch(ae){return!1}}function I(T,k,M={}){let{prehash:N}=oS(M,y);return k=ee(k,N),L.fromBytes(T,"recovered").recoverPublicKey(k).toBytes()}return Object.freeze({keygen:d,getPublicKey:f,getSharedSecret:m,utils:h,lengths:b,Point:e,sign:R,verify:j,recoverPublicKey:I,Signature:L,hash:o})}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */var qJ=(()=>({p:BigInt("0xffffffff00000001000000000000000000000000ffffffffffffffffffffffff"),n:BigInt("0xffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc632551"),h:BigInt(1),a:BigInt("0xffffffff00000001000000000000000000000000fffffffffffffffffffffffc"),b:BigInt("0x5ac635d8aa3a93e7b3ebbd55769886bc651d06b0cc53b0f63bce3c3e27d2604b"),Gx:BigInt("0x6b17d1f2e12c4247f8bce6e563a440f277037d812deb33a0f4a13945d898c296"),Gy:BigInt("0x4fe342e2fe1a7f9b8ee7eb4a7c0f9e162bce33576b315ececbb6406837bf51f5")}))();var MJ=M1(qJ),Oa=K1(MJ,vt);/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */var ii=BigInt(0),wr=BigInt(1),sS=BigInt(2),FJ=BigInt(8);function JJ(e,t,r,o){let n=e.sqr(r),i=e.sqr(o),s=e.add(e.mul(t.a,n),i),a=e.add(e.ONE,e.mul(t.d,e.mul(n,i)));return e.eql(s,a)}function H1(e,t={}){let r=t,o=xp("edwards",e,r,r.FpFnLE),{Fp:n,Fn:i}=o,s=o.CURVE,{h:a}=s;Jr(r,{},{uvRatio:"function"});let c=sS<<BigInt(i.BYTES*8)-wr,u=(y)=>n.create(y),d=r.uvRatio===void 0?(y,S)=>{try{return{isValid:!0,value:n.sqrt(n.div(y,S))}}catch(x){return{isValid:!1,value:ii}}}:r.uvRatio;if(!JJ(n,s,s.Gx,s.Gy))throw Error("bad curve params: generator point");function f(y,S,x=!1){let _=x?wr:ii;return mo("coordinate "+y,S,_,c),S}function m(y){if(!(y instanceof h))throw Error("EdwardsPoint expected")}class h{static BASE=new h(s.Gx,s.Gy,wr,u(s.Gx*s.Gy));static ZERO=new h(ii,wr,wr,ii);static Fp=n;static Fn=i;X;Y;Z;T;constructor(y,S,x,_){this.X=f("x",y),this.Y=f("y",S),this.Z=f("z",x,!0),this.T=f("t",_),Object.freeze(this)}static CURVE(){return s}static fromAffine(y){if(y instanceof h)throw Error("extended point not allowed");let{x:S,y:x}=y||{};return f("x",S),f("y",x),new h(S,x,wr,u(S*x))}static fromBytes(y,S=!1){let x=n.BYTES,{a:_,d:A}=s;y=ni(Ye(y,x,"point")),po(S,"zip215");let O=ni(y),L=y[x-1];O[x-1]=L&-129;let z=sn(O),K=S?c:n.ORDER;mo("point.y",z,ii,K);let P=u(z*z),W=u(P-wr),ee=u(A*P-_),{isValid:B,value:R}=d(W,ee);if(!B)throw Error("bad point: invalid y coordinate");let j=(R&wr)===wr,I=(L&128)!==0;if(!S&&R===ii&&I)throw Error("bad point: x=0 and x_0=1");if(I!==j)R=u(-R);return h.fromAffine({x:R,y:z})}static fromHex(y,S=!1){return h.fromBytes(ka(y),S)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}precompute(y=8,S=!0){if(b.createCache(this,y),!S)this.multiply(sS);return this}assertValidity(){let y=this,{a:S,d:x}=s;if(y.is0())throw Error("bad point: ZERO");let{X:_,Y:A,Z:O,T:L}=y,z=u(_*_),K=u(A*A),P=u(O*O),W=u(P*P),ee=u(z*S),B=u(P*u(ee+K)),R=u(W+u(x*u(z*K)));if(B!==R)throw Error("bad point: equation left != right (1)");let j=u(_*A),I=u(O*L);if(j!==I)throw Error("bad point: equation left != right (2)")}equals(y){m(y);let{X:S,Y:x,Z:_}=this,{X:A,Y:O,Z:L}=y,z=u(S*L),K=u(A*_),P=u(x*L),W=u(O*_);return z===K&&P===W}is0(){return this.equals(h.ZERO)}negate(){return new h(u(-this.X),this.Y,this.Z,u(-this.T))}double(){let{a:y}=s,{X:S,Y:x,Z:_}=this,A=u(S*S),O=u(x*x),L=u(sS*u(_*_)),z=u(y*A),K=S+x,P=u(u(K*K)-A-O),W=z+O,ee=W-L,B=z-O,R=u(P*ee),j=u(W*B),I=u(P*B),T=u(ee*W);return new h(R,j,T,I)}add(y){m(y);let{a:S,d:x}=s,{X:_,Y:A,Z:O,T:L}=this,{X:z,Y:K,Z:P,T:W}=y,ee=u(_*z),B=u(A*K),R=u(L*x*W),j=u(O*P),I=u((_+A)*(z+K)-ee-B),T=j-R,k=j+R,M=u(B-S*ee),N=u(I*T),H=u(k*M),G=u(I*M),re=u(T*k);return new h(N,H,re,G)}subtract(y){return m(y),this.add(y.negate())}multiply(y){if(!i.isValidNot0(y))throw RangeError("invalid scalar: expected 1 <= sc < curve.n");let{p:S,f:x}=b.cached(this,y,(_)=>Ss(h,_));return Ss(h,[S,x])[0]}multiplyUnsafe(y){if(!i.isValid(y))throw RangeError("invalid scalar: expected 0 <= sc < curve.n");if(y===ii)return h.ZERO;if(this.is0()||y===wr)return this;return b.unsafe(this,y,(S)=>Ss(h,S))}isSmallOrder(){return this.clearCofactor().is0()}isTorsionFree(){return b.unsafe(this,s.n).is0()}toAffine(y){let S=this,x=y,{X:_,Y:A,Z:O}=S,L=S.is0();if(x==null)x=L?FJ:n.inv(O);let z=u(_*x),K=u(A*x),P=n.mul(O,x);if(L)return{x:ii,y:wr};if(P!==wr)throw Error("invZ was invalid");return{x:z,y:K}}clearCofactor(){if(a===wr)return this;return this.multiplyUnsafe(a)}toBytes(){let{x:y,y:S}=this.toAffine(),x=n.toBytes(S);return x[x.length-1]|=y&wr?128:0,x}toHex(){return Ia(this.toBytes())}toString(){return`<Point ${this.is0()?"ZERO":this.toHex()}>`}}let b=new ou(h,i.BITS);if(i.BITS>=8)h.BASE.precompute(8);return Object.freeze(h.prototype),Object.freeze(h),h}class aS{static BASE;static ZERO;static Fp;static Fn;ep;constructor(e){this.ep=e}static fromBytes(e){Wb()}static fromHex(e){Wb()}get x(){return this.toAffine().x}get y(){return this.toAffine().y}clearCofactor(){return this}assertValidity(){this.ep.assertValidity()}toAffine(e){return this.ep.toAffine(e)}toHex(){return Ia(this.toBytes())}toString(){return this.toHex()}isTorsionFree(){return!0}isSmallOrder(){return!1}add(e){return this.assertSame(e),this.init(this.ep.add(e.ep))}subtract(e){return this.assertSame(e),this.init(this.ep.subtract(e.ep))}multiply(e){return this.init(this.ep.multiply(e))}multiplyUnsafe(e){return this.init(this.ep.multiplyUnsafe(e))}double(){return this.init(this.ep.double())}negate(){return this.init(this.ep.negate())}precompute(e,t){return this.ep.precompute(e,t),this}}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */var au=BigInt(0),Ca=BigInt(1),Ep=BigInt(2);function KJ(e){return Jr(e,{P:"bigint",type:"string",adjustScalarBytes:"function",powPminus2:"function"},{randomBytes:"function"}),Object.freeze({...e})}function V1(e){let t=KJ(e),{P:r,type:o,adjustScalarBytes:n,powPminus2:i,randomBytes:s}=t,a=o==="x25519";if(!a&&o!=="x448")throw Error("invalid type");let c=s===void 0?Ta:s,u=a?255:448,d=a?32:56,f=a?BigInt(9):BigInt(5),m=a?BigInt(121665):BigInt(39081),h=a?Ep**BigInt(254):Ep**BigInt(447),b=a?BigInt(8)*Ep**BigInt(251)-Ca:BigInt(4)*Ep**BigInt(445)-Ca,y=h+b+Ca,S=(I)=>it(I,r),x=_(f);function _(I){return eu(S(I),d)}function A(I){let T=ni(Ye(I,d,"uCoordinate"));if(a)T[31]&=127;return S(sn(T))}function O(I){return sn(n(ni(Ye(I,d,"scalar"))))}function L(I,T){let k=ee(A(T),O(I));if(k===au)throw Error("invalid private or public key received");return _(k)}function z(I){return L(I,x)}let K=z,P=L;function W(I,T,k){let M=S(I*(T-k));return T=S(T-M),k=S(k+M),{x_2:T,x_3:k}}function ee(I,T){mo("u",I,au,r),mo("scalar",T,h,y);let k=T,M=I,N=Ca,H=au,G=I,re=Ca,ae=au;for(let be=BigInt(u-1);be>=au;be--){let ve=k>>be&Ca;ae^=ve,{x_2:N,x_3:G}=W(ae,N,G),{x_2:H,x_3:re}=W(ae,H,re),ae=ve;let ke=N+H,Ie=S(ke*ke),we=N-H,Ue=S(we*we),De=Ie-Ue,Qe=G+re,bt=G-re,Tt=S(bt*ke),Nt=S(Qe*we),lt=Tt+Nt,$r=Tt-Nt;G=S(lt*lt),re=S(M*S($r*$r)),N=S(Ie*Ue),H=S(De*(Ie+S(m*De)))}({x_2:N,x_3:G}=W(ae,N,G)),{x_2:H,x_3:re}=W(ae,H,re);let pe=i(H);return S(N*pe)}let B={secretKey:d,publicKey:d,seed:d},R=(I)=>(I=I===void 0?c(d):I,Ye(I,B.seed,"seed"),I),j={randomSecretKey:R};return Object.freeze(B),Object.freeze(j),Object.freeze({keygen:iu(R,K),getSharedSecret:P,getPublicKey:K,scalarMult:L,scalarMultBase:z,utils:j,GuBytes:x.slice(),lengths:B})}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */var HJ=BigInt(0),go=BigInt(1),W1=BigInt(2),VJ=BigInt(3),WJ=BigInt(5),GJ=BigInt(8),ws=BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffed"),dS=(()=>({p:ws,n:BigInt("0x1000000000000000000000000000000014def9dea2f79cd65812631a5cf5d3ed"),h:GJ,a:BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffec"),d:BigInt("0x52036cee2b6ffe738cc740797779e89800700a4d4141d8ab75eb4dca135978a3"),Gx:BigInt("0x216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51a"),Gy:BigInt("0x6666666666666666666666666666666666666666666666666666666666666658")}))();function Y1(e){let t=BigInt(10),r=BigInt(20),o=BigInt(40),n=BigInt(80),i=ws,a=e*e%i*e%i,c=Kr(a,W1,i)*a%i,u=Kr(c,go,i)*e%i,d=Kr(u,WJ,i)*u%i,f=Kr(d,t,i)*d%i,m=Kr(f,r,i)*f%i,h=Kr(m,o,i)*m%i,b=Kr(h,n,i)*h%i,y=Kr(b,n,i)*h%i,S=Kr(y,t,i)*d%i;return{pow_p_5_8:Kr(S,W1,i)*e%i,b2:a}}function QJ(e){return e[0]&=248,e[31]&=127,e[31]|=64,e}var cS=BigInt("19681161376707505956807079304988542015446066515923890162744021073123829784752");function fS(e,t){let r=ws,o=it(t*t*t,r),n=it(o*o*t,r),i=Y1(e*n).pow_p_5_8,s=it(e*o*i,r),a=it(t*s*s,r),c=s,u=it(s*cS,r),d=a===e,f=a===it(-e,r),m=a===it(-e*cS,r);if(d)s=c;if(f||m)s=u;if(ho(s,r))s=it(-s,r);return{isValid:d||f,value:s}}var vs=H1(dS,{uvRatio:fS}),si=(()=>vs.Fp)(),X1=(()=>vs.Fn)();var Ip=(()=>{let e=ws;return V1({P:e,type:"x25519",powPminus2:(t)=>{let{pow_p_5_8:r,b2:o}=Y1(t);return it(Kr(r,VJ,e)*o,e)},adjustScalarBytes:QJ})})();var lS=cS,YJ=BigInt("25063068953384623474111414158702152701244531502492656460079210482610430750235"),XJ=BigInt("54469307008909316920995813868745141605393597292927456921205312896311721017578"),eK=BigInt("1159843021668779879193775521855586647937357759715417654439879720876111806838"),tK=BigInt("40440834346308536858101042469323190826248399146238708352240133220865137265952"),G1=(e)=>fS(go,e),rK=BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"),uS=(e)=>si.create(sn(e)&rK);function Q1(e){let{d:t}=dS,r=ws,o=(x)=>si.create(x),n=o(lS*e*e),i=o((n+go)*eK),s=BigInt(-1),a=o((s-t*n)*o(n+t)),{isValid:c,value:u}=fS(i,a),d=o(u*e);if(!ho(d,r))d=o(-d);if(!c)u=d;if(!c)s=n;let f=o(s*(n-go)*tK-a),m=u*u,h=o((u+u)*a),b=o(f*YJ),y=o(go-m),S=o(go+m);return new vs(o(h*S),o(y*b),o(b*S),o(h*y))}class dr extends aS{static BASE=(()=>new dr(vs.BASE))();static ZERO=(()=>new dr(vs.ZERO))();static Fp=(()=>si)();static Fn=(()=>X1)();constructor(e){super(e)}static fromAffine(e){return new dr(vs.fromAffine(e))}assertSame(e){if(!(e instanceof dr))throw Error("RistrettoPoint expected")}init(e){return new dr(e)}static fromBytes(e){Ut(e,32);let{a:t,d:r}=dS,o=ws,n=(A)=>si.create(A),i=uS(e);if(!S1(si.toBytes(i),e)||ho(i,o))throw Error("invalid ristretto255 encoding 1");let s=n(i*i),a=n(go+t*s),c=n(go-t*s),u=n(a*a),d=n(c*c),f=n(t*r*u-d),{isValid:m,value:h}=G1(n(f*d)),b=n(h*c),y=n(h*b*f),S=n((i+i)*b);if(ho(S,o))S=n(-S);let x=n(a*y),_=n(S*x);if(!m||ho(_,o)||x===HJ)throw Error("invalid ristretto255 encoding 2");return new dr(new vs(S,x,go,_))}static fromHex(e){return dr.fromBytes($l(e))}toBytes(){let{X:e,Y:t,Z:r,T:o}=this.ep,n=ws,i=(y)=>si.create(y),s=i(i(r+t)*i(r-t)),a=i(e*t),c=i(a*a),{value:u}=G1(i(s*c)),d=i(u*s),f=i(u*a),m=i(d*f*o),h;if(ho(o*m,n)){let y=i(t*lS),S=i(e*lS);e=y,t=S,h=i(d*XJ)}else h=f;if(ho(e*m,n))t=i(-t);let b=i((r-t)*h);if(ho(b,n))b=i(-b);return si.toBytes(b)}equals(e){this.assertSame(e);let{X:t,Y:r}=this.ep,{X:o,Y:n}=e.ep,i=(c)=>si.create(c),s=i(t*n)===i(r*o),a=i(r*n)===i(t*o);return s||a}is0(){return this.equals(dr.ZERO)}}Object.freeze(dr.BASE);Object.freeze(dr.ZERO);Object.freeze(dr.prototype);Object.freeze(dr);var nK=Object.freeze({Point:dr,hashToCurve(e,t){let r=t?.DST===void 0?"ristretto255_XMD:SHA-512_R255MAP_RO_":t.DST,o=nS(e,r,64,Mf);return nK.deriveToCurve(o)},hashToScalar(e,t={DST:B1}){let r=nS(e,t.DST,64,Mf);return X1.create(sn(r))},deriveToCurve(e){Ut(e,64);let t=uS(e.subarray(0,32)),r=Q1(t),o=uS(e.subarray(32,64)),n=Q1(o);return new dr(r.add(n))}});var eC=!1,oK=!1;async function tC(e,t){if(oK)return await t();try{return await e()}catch(r){if(r instanceof ReferenceError||r instanceof DOMException&&r.name==="NotSupportedError")return await t();else throw r}}async function kp(e,t){return await tC(async()=>{let r=pS(e)?e:await sK(e),o=await crypto.subtle.importKey("raw",aK(t),{name:"X25519"},eC,[]);return new Uint8Array(await crypto.subtle.deriveBits({name:"X25519",public:o},r,256))},()=>{if(pS(e))throw Error("CryptoKey provided but X25519 WebCrypto is not supported");return Ip.scalarMult(e,t)})}async function cu(e){return await tC(async()=>kp(e,Ip.GuBytes),()=>{if(pS(e))throw Error("CryptoKey provided but X25519 WebCrypto is not supported");return Ip.scalarMultBase(e)})}var iK=new Uint8Array([48,46,2,1,0,48,5,6,3,43,101,110,4,34,4,32]);async function sK(e){if(e.length!==32)throw Error("X25519 private key must be 32 bytes");let t=new Uint8Array([...iK,...e]);return crypto.subtle.importKey("pkcs8",t,{name:"X25519"},eC,["deriveBits"])}function pS(e){return typeof CryptoKey<"u"&&e instanceof CryptoKey}function aK(e){return e}class mS{s;transcript=[];buf=new Uint8Array(0);constructor(e){this.s=e.getReader()}async readLine(){let e=[];while(!0){let t=this.buf.indexOf(10);if(t>=0)return e.push(this.buf.subarray(0,t)),this.transcript.push(this.buf.subarray(0,t+1)),this.buf=this.buf.subarray(t+1),lK(xs(e));if(this.buf.length>0)e.push(this.buf),this.transcript.push(this.buf);let r=await this.s.read();if(r.done)return this.buf=xs(e),null;this.buf=r.value}}close(){return this.s.releaseLock(),{rest:this.buf,transcript:xs(this.transcript)}}}function lK(e){return e.forEach((t)=>{if(t<32||t>126)throw Error("invalid non-ASCII byte in header")}),new TextDecoder().decode(e)}function xs(e){let t=e.reduce((n,i)=>n+i.length,0),r=new Uint8Array(t),o=0;for(let n of e)r.set(n,o),o+=n.length;return r}function Pa(e,...t){return e.pipeThrough(new TransformStream({start(r){for(let o of t)r.enqueue(o)}}))}function Ap(e){return new ReadableStream({start(t){t.enqueue(e),t.close()}})}async function hS(e){if(!(e instanceof ReadableStream))throw Error("readAll expects a ReadableStream<Uint8Array>");return new Uint8Array(await new Response(e).arrayBuffer())}async function rC(e){if(!(e instanceof ReadableStream))throw Error("readAllString expects a ReadableStream<Uint8Array>");return await new Response(e).text()}async function nC(e,t){let r=e.getReader(),o=[],n=0;while(n<t){let{done:c,value:u}=await r.read();if(c)throw Error("stream ended before reading "+t.toString()+" bytes");o.push(u),n+=u.length}r.releaseLock();let i=xs(o),s=i.subarray(0,t),a=Pa(e,i.subarray(t));return{data:s,rest:a}}class Dn{args;body;constructor(e,t){this.args=e,this.body=t}}async function uK(e){let t=await e.readLine();if(t===null)throw Error("invalid stanza");let r=t.split(" ");if(r.length<2||r.shift()!=="->")return{next:t};for(let i of r)if(i.length===0)throw Error("invalid stanza");let o=[];for(;;){let i=await e.readLine();if(i===null)throw Error("invalid stanza");let s=Yt.decode(i);if(s.length>48)throw Error("invalid stanza");if(o.push(s),s.length<48)break}let n=xs(o);return{s:new Dn(r,n)}}async function oC(e){let t=new mS(e),r=await t.readLine();if(r!=="age-encryption.org/v1")throw Error("invalid version "+(r??"line"));let o=[];for(;;){let{s:n,next:i}=await uK(t);if(n!==void 0){o.push(n);continue}if(!i.startsWith("--- "))throw Error("invalid header");let s=Yt.decode(i.slice(4)),{rest:a,transcript:c}=t.close(),u=c.slice(0,c.length-1-i.length+3);return{stanzas:o,headerNoMAC:u,MAC:s,headerSize:c.length,rest:Pa(e,a)}}}function gS(e){let t=[];t.push(`age-encryption.org/v1
|
|
702
702
|
`);for(let r of e){t.push("-> "+r.args.join(" ")+`
|
|
703
703
|
`);for(let o=0;o<r.body.length;o+=48){let n=o+48;if(n>r.body.length)n=r.body.length;t.push(Yt.encode(r.body.subarray(o,n))+`
|
|
704
704
|
`)}if(r.body.length%48===0)t.push(`
|
package/dist/index.js
CHANGED
|
@@ -708,7 +708,7 @@ printf 'REMOTE_ARTIFACT_DIR=%s\\n' "$remote_dir"
|
|
|
708
708
|
`),i}async function d5(e,t){let r=await ut(e),o=r.users.find((n)=>n.handle===t);if(!o)throw Error(`Unknown pilot user: ${t}`);return{pilot:r.pilot,user:o}}async function f5(e){let t=await eme(to(tme(),"brains-ops-watchdog-smoke-")),r=to(t,"id_ed25519"),o=to(t,"known_hosts");try{let n=encodeURIComponent(`brain=${e.target.pilot.contentRepoPrefix}${e.target.user.handle}`),i=await e.fetchImpl(`https://api.hetzner.cloud/v1/servers?label_selector=${n}`,{headers:{Authorization:`Bearer ${e.environment.HCLOUD_TOKEN}`}});if(!i.ok)throw Error(`Hetzner server lookup failed with ${i.status}`);let s=rme.parse(await i.json());if(s.servers.length!==1)throw Error(`Expected one smoke server, found ${s.servers.length}`);let a=s.servers[0];if(a?.status!=="running")throw Error("Smoke server is not running");await Al(r,ime(e.environment.KAMAL_SSH_PRIVATE_KEY),{mode:384}),await Xpe(r,384);let c=await e.commandRunner("ssh-keyscan",["-T","10","-t","ed25519",a.public_net.ipv4.ip]);if(c.exitCode!==0||!c.stdout.trim())throw Error("Unable to resolve watchdog smoke SSH host key");return await Al(o,c.stdout,{mode:384}),{temporaryRoot:t,sshKeyPath:r,knownHostsPath:o,serverIp:a.public_net.ipv4.ip,commandRunner:e.commandRunner}}catch(n){throw await pR(t,{recursive:!0,force:!0}),n}}async function fR(e,t,r){return e.commandRunner("ssh",[...p5(e),`root@${e.serverIp}`,"bash","-s","--",t,r],{stdin:mR()})}async function nme(e,t,r){return e.commandRunner("scp",[...p5(e),"-r",`root@${e.serverIp}:${t}/.`,r])}function p5(e){return["-i",e.sshKeyPath,"-o","BatchMode=yes","-o","IdentitiesOnly=yes","-o","ConnectTimeout=10","-o","StrictHostKeyChecking=yes","-o",`UserKnownHostsFile=${e.knownHostsPath}`]}async function ome(e){try{return await Ype(e),!0}catch{return!1}}async function Wy(e,t,r){await Promise.all([Al(to(e,`${t}.stdout.log`),r.stdout),Al(to(e,`${t}.stderr.log`),r.stderr)])}function ime(e){return`${e.replace(/\r\n/g,`
|
|
709
709
|
`).replace(/\\n/g,`
|
|
710
710
|
`).trimEnd()}
|
|
711
|
-
`}var c5,rme;var Qy=w(async()=>{he();o5();Mr();Nf();await n5();c5=l.object({HCLOUD_TOKEN:l.string().min(1),KAMAL_SSH_PRIVATE_KEY:l.string().min(1)}),rme=l.object({servers:l.array(l.object({status:l.string(),public_net:l.object({ipv4:l.object({ip:l.string().min(1)})})}))})});import{access as TN,chmod as lE,mkdir as Bm,readFile as RN,writeFile as $N}from"fs/promises";import{dirname as e7,join as tc}from"path";import{fileURLToPath as t7}from"url";var Zf={name:"@rizom/ops",version:"0.2.0-alpha.
|
|
711
|
+
`}var c5,rme;var Qy=w(async()=>{he();o5();Mr();Nf();await n5();c5=l.object({HCLOUD_TOKEN:l.string().min(1),KAMAL_SSH_PRIVATE_KEY:l.string().min(1)}),rme=l.object({servers:l.array(l.object({status:l.string(),public_net:l.object({ipv4:l.object({ip:l.string().min(1)})})}))})});import{access as TN,chmod as lE,mkdir as Bm,readFile as RN,writeFile as $N}from"fs/promises";import{dirname as e7,join as tc}from"path";import{fileURLToPath as t7}from"url";var Zf={name:"@rizom/ops",version:"0.2.0-alpha.665",description:"Operator CLI for managing private brain fleet registry repos",keywords:["brains","ops","cli","deploy","fleet","operator"],license:"AGPL-3.0-only",author:"Yeehaa <yeehaa@rizom.ai> (https://rizom.ai)",bin:{"brains-ops":"./dist/brains-ops.js"},bugs:"https://github.com/rizom-ai/brains/issues",dependencies:{"@libsql/client":"^0.17.4","age-encryption":"^0.3.0",yaml:"^2.9.0"},devDependencies:{"@brains/contracts":"workspace:*","@brains/deploy-support":"workspace:*","@brains/eslint-config":"workspace:*","@brains/job-queue":"workspace:*","@brains/profile":"workspace:*","@brains/site-composition":"workspace:*","@brains/test-utils":"workspace:*","@brains/typescript-config":"workspace:*","@brains/utils":"workspace:*","@types/bun":"^1.4.0",typescript:"^7.0.2"},engines:{bun:">=1.3.3"},exports:{".":{types:"./dist/index.d.ts",import:"./dist/index.js"},"./deploy":{types:"./dist/deploy.d.ts",import:"./dist/deploy.js",bun:"./dist/deploy.js"}},files:["dist","templates"],homepage:"https://github.com/rizom-ai/brains/tree/main/packages/brains-ops#readme",main:"./dist/index.js",publishConfig:{access:"public"},repository:{type:"git",url:"https://github.com/rizom-ai/brains.git",directory:"packages/brains-ops"},scripts:{build:"bun scripts/build.ts",lint:"eslint . --max-warnings 0","lint:fix":"eslint . --max-warnings 0 --fix",prepublishOnly:"bun scripts/build.ts",test:"bun test --timeout 20000","test:smoke":"bun run build && RUN_SMOKE_TESTS=1 bun test --timeout 60000",typecheck:"tsc --noEmit"},type:"module",types:"./dist/index.d.ts"};ns();ec();var r7=["pilot.yaml","package.json",".env.schema",".gitignore","cohorts/cohort-1.yaml","users/alice.yaml",".github/actions/varlock-env/action.yml",".github/workflows/build.yml",".github/workflows/deploy.yml",".github/workflows/directory-sync-stress.yml",".github/workflows/health-watchdog-smoke.yml",".github/workflows/offboard.yml",".github/workflows/reconcile.yml",".github/workflows/upgrade.yml","deploy/Dockerfile","deploy/kamal/deploy.yml","deploy/scripts/helpers.ts","deploy/scripts/create-predeploy-backup.ts","deploy/scripts/install-health-watchdog.ts","deploy/scripts/provision-server.ts","deploy/scripts/update-dns.ts","deploy/scripts/write-ssh-key.ts","deploy/scripts/decrypt-user-secrets.ts","deploy/scripts/validate-secrets.ts","deploy/scripts/write-kamal-secrets.ts","deploy/scripts/resolve-user-config.ts","deploy/scripts/resolve-missing-images.ts","deploy/scripts/verify-runtime-image.ts","deploy/scripts/resolve-deploy-handles.ts","deploy/scripts/sync-content-repo.ts",".kamal/hooks/pre-deploy","docs/onboarding-checklist.md","docs/canonical-crossover-record.md","docs/operator-playbook.md","docs/user-onboarding.md","README.md"],uE=new Set([".kamal/hooks/pre-deploy"]),n7=new Set(["cohorts/cohort-1.yaml","users/alice.yaml","docs/canonical-crossover-record.md"]),o7=t7(new URL("../templates/rover-pilot/",import.meta.url));function co(e){return(t)=>t.includes(e)}function i7(e){return ER.find((t)=>e===`deploy/scripts/${t}`)}function dE(e){return e.replace(/\n {2}secret:\n(?: {4}- .*\n)+\nvolumes:\n/,`
|
|
712
712
|
secret:
|
|
713
713
|
- __DYNAMIC_SECRETS__
|
|
714
714
|
|