You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

2247 lines
564 KiB

var I1=Object.defineProperty;var Wh=r=>{throw TypeError(r)};var _1=(r,t,n)=>t in r?I1(r,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):r[t]=n;var We=(r,t,n)=>_1(r,typeof t!="symbol"?t+"":t,n),cf=(r,t,n)=>t.has(r)||Wh("Cannot "+n);var P=(r,t,n)=>(cf(r,t,"read from private field"),n?n.call(r):t.get(r)),Ve=(r,t,n)=>t.has(r)?Wh("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(r):t.set(r,n),we=(r,t,n,i)=>(cf(r,t,"write to private field"),i?i.call(r,n):t.set(r,n),n),de=(r,t,n)=>(cf(r,t,"access private method"),n);var Ks=(r,t,n,i)=>({set _(o){we(r,t,o,n)},get _(){return P(r,t,i)}});import{ab as Jh,J as Qi,K as mo,N as va,O as Ep,ac as M1,B as tc,ad as qo,A as Yh,a as Sp,a9 as pi,a2 as Bp,u as Dp,f as Cp,d as k1,D as T1,y as N1,b as R1}from"./index-BLqts8WY.js";import{u as U1}from"./index-CsfPLOYu.js";function Ip(r,t){switch(r){case 0:return function(){return t.apply(this,arguments)};case 1:return function(n){return t.apply(this,arguments)};case 2:return function(n,i){return t.apply(this,arguments)};case 3:return function(n,i,o){return t.apply(this,arguments)};case 4:return function(n,i,o,s){return t.apply(this,arguments)};case 5:return function(n,i,o,s,a){return t.apply(this,arguments)};case 6:return function(n,i,o,s,a,c){return t.apply(this,arguments)};case 7:return function(n,i,o,s,a,c,f){return t.apply(this,arguments)};case 8:return function(n,i,o,s,a,c,f,h){return t.apply(this,arguments)};case 9:return function(n,i,o,s,a,c,f,h,d){return t.apply(this,arguments)};case 10:return function(n,i,o,s,a,c,f,h,d,g){return t.apply(this,arguments)};default:throw new Error("First argument to _arity must be a non-negative integer no greater than ten")}}function _p(r,t,n){return function(){for(var i=[],o=0,s=r,a=0,c=!1;a<t.length||o<arguments.length;){var f;a<t.length&&(!Jh(t[a])||o>=arguments.length)?f=t[a]:(f=arguments[o],o+=1),i[a]=f,Jh(f)?c=!0:s-=1,a+=1}return!c&&s<=0?n.apply(this,i):Ip(Math.max(0,s),_p(r,i,n))}}var O1=Qi(function(t,n){return t===1?mo(n):Ip(t,_p(t,[],n))});const Mp=Array.isArray||function(t){return t!=null&&t.length>=0&&Object.prototype.toString.call(t)==="[object Array]"};function P1(r){return r!=null&&typeof r["@@transducer/step"]=="function"}function Dl(r,t,n){return function(){if(arguments.length===0)return n();var i=arguments[arguments.length-1];if(!Mp(i)){for(var o=0;o<r.length;){if(typeof i[r[o]]=="function")return i[r[o]].apply(i,Array.prototype.slice.call(arguments,0,-1));o+=1}if(P1(i)){var s=t.apply(null,Array.prototype.slice.call(arguments,0,-1));return s(i)}}return n.apply(this,arguments)}}function F1(r){return r&&r["@@transducer/reduced"]?r:{"@@transducer/value":r,"@@transducer/reduced":!0}}const is={init:function(){return this.xf["@@transducer/init"]()},result:function(r){return this.xf["@@transducer/result"](r)}};function Zh(r){for(var t=[],n;!(n=r.next()).done;)t.push(n.value);return t}function Xh(r,t,n){for(var i=0,o=n.length;i<o;){if(r(t,n[i]))return!0;i+=1}return!1}function L1(r){var t=String(r).match(/^function (\w*)/);return t==null?"":t[1]}function H1(r,t){return r===t?r!==0||1/r===1/t:r!==r&&t!==t}const ff=typeof Object.is=="function"?Object.is:H1;var Qh=Object.prototype.toString,kp=function(){return Qh.call(arguments)==="[object Arguments]"?function(t){return Qh.call(t)==="[object Arguments]"}:function(t){return va("callee",t)}}(),$1=!{toString:null}.propertyIsEnumerable("toString"),ed=["constructor","valueOf","isPrototypeOf","toString","propertyIsEnumerable","hasOwnProperty","toLocaleString"],td=function(){return arguments.propertyIsEnumerable("length")}(),V1=function(t,n){for(var i=0;i<t.length;){if(t[i]===n)return!0;i+=1}return!1},xa=typeof Object.keys=="function"&&!td?mo(function(t){return Object(t)!==t?[]:Object.keys(t)}):mo(function(t){if(Object(t)!==t)return[];var n,i,o=[],s=td&&kp(t);for(n in t)va(n,t)&&(!s||n!=="length")&&(o[o.length]=n);if($1)for(i=ed.length-1;i>=0;)n=ed[i],va(n,t)&&!V1(o,n)&&(o[o.length]=n),i-=1;return o}),eu=mo(function(t){return t===null?"Null":t===void 0?"Undefined":Object.prototype.toString.call(t).slice(8,-1)});function rd(r,t,n,i){var o=Zh(r),s=Zh(t);function a(c,f){return Cl(c,f,n.slice(),i.slice())}return!Xh(function(c,f){return!Xh(a,f,c)},s,o)}function Cl(r,t,n,i){if(ff(r,t))return!0;var o=eu(r);if(o!==eu(t))return!1;if(typeof r["fantasy-land/equals"]=="function"||typeof t["fantasy-land/equals"]=="function")return typeof r["fantasy-land/equals"]=="function"&&r["fantasy-land/equals"](t)&&typeof t["fantasy-land/equals"]=="function"&&t["fantasy-land/equals"](r);if(typeof r.equals=="function"||typeof t.equals=="function")return typeof r.equals=="function"&&r.equals(t)&&typeof t.equals=="function"&&t.equals(r);switch(o){case"Arguments":case"Array":case"Object":if(typeof r.constructor=="function"&&L1(r.constructor)==="Promise")return r===t;break;case"Boolean":case"Number":case"String":if(!(typeof r==typeof t&&ff(r.valueOf(),t.valueOf())))return!1;break;case"Date":if(!ff(r.valueOf(),t.valueOf()))return!1;break;case"Error":return r.name===t.name&&r.message===t.message;case"RegExp":if(!(r.source===t.source&&r.global===t.global&&r.ignoreCase===t.ignoreCase&&r.multiline===t.multiline&&r.sticky===t.sticky&&r.unicode===t.unicode))return!1;break}for(var s=n.length-1;s>=0;){if(n[s]===r)return i[s]===t;s-=1}switch(o){case"Map":return r.size!==t.size?!1:rd(r.entries(),t.entries(),n.concat([r]),i.concat([t]));case"Set":return r.size!==t.size?!1:rd(r.values(),t.values(),n.concat([r]),i.concat([t]));case"Arguments":case"Array":case"Object":case"Boolean":case"Number":case"String":case"Date":case"Error":case"RegExp":case"Int8Array":case"Uint8Array":case"Uint8ClampedArray":case"Int16Array":case"Uint16Array":case"Int32Array":case"Uint32Array":case"Float32Array":case"Float64Array":case"ArrayBuffer":break;default:return!1}var a=xa(r);if(a.length!==xa(t).length)return!1;var c=n.concat([r]),f=i.concat([t]);for(s=a.length-1;s>=0;){var h=a[s];if(!(va(h,t)&&Cl(t[h],r[h],c,f)))return!1;s-=1}return!0}var Tp=Qi(function(t,n){return Cl(t,n,[],[])});function j1(r,t){for(var n=0,i=t.length,o=Array(i);n<i;)o[n]=r(t[n]),n+=1;return o}function K1(r){return function(){return!r.apply(this,arguments)}}function Np(r,t,n){for(var i=0,o=n.length;i<o;)t=r(t,n[i]),i+=1;return t}function z1(r,t){for(var n=0,i=t.length,o=[];n<i;)r(t[n])&&(o[o.length]=t[n]),n+=1;return o}var q1=function(){function r(t,n){this.xf=n,this.f=t}return r.prototype["@@transducer/init"]=is.init,r.prototype["@@transducer/result"]=is.result,r.prototype["@@transducer/step"]=function(t,n){return this.f(n)?this.xf["@@transducer/step"](t,n):t},r}();function G1(r){return function(t){return new q1(r,t)}}var W1=Qi(Dl(["fantasy-land/filter","filter"],G1,function(r,t){return Ep(t)?Np(function(n,i){return r(t[i])&&(n[i]=t[i]),n},{},xa(t)):z1(r,t)})),nd=Qi(function(t,n){return W1(K1(t),n)}),J1=function(){function r(t,n){this.xf=n,this.f=t}return r.prototype["@@transducer/init"]=is.init,r.prototype["@@transducer/result"]=is.result,r.prototype["@@transducer/step"]=function(t,n){return this.xf["@@transducer/step"](t,this.f(n))},r}(),Y1=function(t){return function(n){return new J1(t,n)}},Z1=Qi(Dl(["fantasy-land/map","map"],Y1,function(t,n){switch(Object.prototype.toString.call(n)){case"[object Function]":return O1(n.length,function(){return t.call(this,n.apply(this,arguments))});case"[object Object]":return Np(function(i,o){return i[o]=t(n[o]),i},{},xa(n));default:return j1(t,n)}}));function X1(r){return Object.prototype.toString.call(r)==="[object String]"}function Q1(r){return new RegExp(r.source,r.flags?r.flags:(r.global?"g":"")+(r.ignoreCase?"i":"")+(r.multiline?"m":"")+(r.sticky?"y":"")+(r.unicode?"u":"")+(r.dotAll?"s":""))}function Rp(r,t,n){if(n||(n=new tm),em(r))return r;var i=function(s){var a=n.get(r);if(a)return a;n.set(r,s);for(var c in r)Object.prototype.hasOwnProperty.call(r,c)&&(s[c]=t?Rp(r[c],!0,n):r[c]);return s};switch(eu(r)){case"Object":return i(Object.create(Object.getPrototypeOf(r)));case"Array":return i([]);case"Date":return new Date(r.valueOf());case"RegExp":return Q1(r);case"Int8Array":case"Uint8Array":case"Uint8ClampedArray":case"Int16Array":case"Uint16Array":case"Int32Array":case"Uint32Array":case"Float32Array":case"Float64Array":case"BigInt64Array":case"BigUint64Array":return r.slice();default:return r}}function em(r){var t=typeof r;return r==null||t!="object"&&t!="function"}var tm=function(){function r(){this.map={},this.length=0}return r.prototype.set=function(t,n){const i=this.hash(t);let o=this.map[i];o||(this.map[i]=o=[]),o.push([t,n]),this.length+=1},r.prototype.hash=function(t){let n=[];for(var i in t)n.push(Object.prototype.toString.call(t[i]));return n.join()},r.prototype.get=function(t){if(this.length<=180){for(const o in this.map){const s=this.map[o];for(let a=0;a<s.length;a+=1){const c=s[a];if(c[0]===t)return c[1]}}return}const n=this.hash(t),i=this.map[n];if(i)for(let o=0;o<i.length;o+=1){const s=i[o];if(s[0]===t)return s[1]}},r}(),os=mo(function(t){return t!=null&&typeof t.clone=="function"?t.clone():Rp(t,!0)});function rm(r){var t=Object.prototype.toString.call(r);return t==="[object Uint8ClampedArray]"||t==="[object Int8Array]"||t==="[object Uint8Array]"||t==="[object Int16Array]"||t==="[object Uint16Array]"||t==="[object Int32Array]"||t==="[object Uint32Array]"||t==="[object Float32Array]"||t==="[object Float64Array]"||t==="[object BigInt64Array]"||t==="[object BigUint64Array]"}var nm=mo(function(t){return t!=null&&typeof t["fantasy-land/empty"]=="function"?t["fantasy-land/empty"]():t!=null&&t.constructor!=null&&typeof t.constructor["fantasy-land/empty"]=="function"?t.constructor["fantasy-land/empty"]():t!=null&&typeof t.empty=="function"?t.empty():t!=null&&t.constructor!=null&&typeof t.constructor.empty=="function"?t.constructor.empty():Mp(t)?[]:X1(t)?"":Ep(t)?{}:kp(t)?function(){return arguments}():rm(t)?t.constructor.from(""):void 0}),im=function(){function r(t,n){this.xf=n,this.f=t,this.found=!1}return r.prototype["@@transducer/init"]=is.init,r.prototype["@@transducer/result"]=function(t){return this.found||(t=this.xf["@@transducer/step"](t,void 0)),this.xf["@@transducer/result"](t)},r.prototype["@@transducer/step"]=function(t,n){return this.f(n)&&(this.found=!0,t=F1(this.xf["@@transducer/step"](t,n))),t},r}();function om(r){return function(t){return new im(r,t)}}var Il=Qi(Dl(["find"],om,function(t,n){for(var i=0,o=n.length;i<o;){if(t(n[i]))return n[i];i+=1}})),Up=Qi(function(t,n){for(var i={},o={},s=0,a=t.length;s<a;)o[t[s]]=1,s+=1;for(var c in n)o.hasOwnProperty(c)||(i[c]=n[c]);return i}),uf={},$o={},id;function sm(){if(id)return $o;id=1,$o.byteLength=c,$o.toByteArray=h,$o.fromByteArray=x;for(var r=[],t=[],n=typeof Uint8Array<"u"?Uint8Array:Array,i="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",o=0,s=i.length;o<s;++o)r[o]=i[o],t[i.charCodeAt(o)]=o;t[45]=62,t[95]=63;function a(S){var D=S.length;if(D%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var E=S.indexOf("=");E===-1&&(E=D);var _=E===D?0:4-E%4;return[E,_]}function c(S){var D=a(S),E=D[0],_=D[1];return(E+_)*3/4-_}function f(S,D,E){return(D+E)*3/4-E}function h(S){var D,E=a(S),_=E[0],T=E[1],F=new n(f(S,_,T)),U=0,z=T>0?_-4:_,V;for(V=0;V<z;V+=4)D=t[S.charCodeAt(V)]<<18|t[S.charCodeAt(V+1)]<<12|t[S.charCodeAt(V+2)]<<6|t[S.charCodeAt(V+3)],F[U++]=D>>16&255,F[U++]=D>>8&255,F[U++]=D&255;return T===2&&(D=t[S.charCodeAt(V)]<<2|t[S.charCodeAt(V+1)]>>4,F[U++]=D&255),T===1&&(D=t[S.charCodeAt(V)]<<10|t[S.charCodeAt(V+1)]<<4|t[S.charCodeAt(V+2)]>>2,F[U++]=D>>8&255,F[U++]=D&255),F}function d(S){return r[S>>18&63]+r[S>>12&63]+r[S>>6&63]+r[S&63]}function g(S,D,E){for(var _,T=[],F=D;F<E;F+=3)_=(S[F]<<16&16711680)+(S[F+1]<<8&65280)+(S[F+2]&255),T.push(d(_));return T.join("")}function x(S){for(var D,E=S.length,_=E%3,T=[],F=16383,U=0,z=E-_;U<z;U+=F)T.push(g(S,U,U+F>z?z:U+F));return _===1?(D=S[E-1],T.push(r[D>>2]+r[D<<4&63]+"==")):_===2&&(D=(S[E-2]<<8)+S[E-1],T.push(r[D>>10]+r[D>>4&63]+r[D<<2&63]+"=")),T.join("")}return $o}var zs={};/*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> */var od;function am(){return od||(od=1,zs.read=function(r,t,n,i,o){var s,a,c=o*8-i-1,f=(1<<c)-1,h=f>>1,d=-7,g=n?o-1:0,x=n?-1:1,S=r[t+g];for(g+=x,s=S&(1<<-d)-1,S>>=-d,d+=c;d>0;s=s*256+r[t+g],g+=x,d-=8);for(a=s&(1<<-d)-1,s>>=-d,d+=i;d>0;a=a*256+r[t+g],g+=x,d-=8);if(s===0)s=1-h;else{if(s===f)return a?NaN:(S?-1:1)*(1/0);a=a+Math.pow(2,i),s=s-h}return(S?-1:1)*a*Math.pow(2,s-i)},zs.write=function(r,t,n,i,o,s){var a,c,f,h=s*8-o-1,d=(1<<h)-1,g=d>>1,x=o===23?Math.pow(2,-24)-Math.pow(2,-77):0,S=i?0:s-1,D=i?1:-1,E=t<0||t===0&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(c=isNaN(t)?1:0,a=d):(a=Math.floor(Math.log(t)/Math.LN2),t*(f=Math.pow(2,-a))<1&&(a--,f*=2),a+g>=1?t+=x/f:t+=x*Math.pow(2,1-g),t*f>=2&&(a++,f/=2),a+g>=d?(c=0,a=d):a+g>=1?(c=(t*f-1)*Math.pow(2,o),a=a+g):(c=t*Math.pow(2,g-1)*Math.pow(2,o),a=0));o>=8;r[n+S]=c&255,S+=D,c/=256,o-=8);for(a=a<<o|c,h+=o;h>0;r[n+S]=a&255,S+=D,a/=256,h-=8);r[n+S-D]|=E*128}),zs}/*!
* The buffer module from node.js, for the browser.
*
* @author Feross Aboukhadijeh <https://feross.org>
* @license MIT
*/var sd;function cm(){return sd||(sd=1,function(r){const t=sm(),n=am(),i=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):null;r.Buffer=c,r.SlowBuffer=F,r.INSPECT_MAX_BYTES=50;const o=2147483647;r.kMaxLength=o,c.TYPED_ARRAY_SUPPORT=s(),!c.TYPED_ARRAY_SUPPORT&&typeof console<"u"&&typeof console.error=="function"&&console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support.");function s(){try{const M=new Uint8Array(1),m={foo:function(){return 42}};return Object.setPrototypeOf(m,Uint8Array.prototype),Object.setPrototypeOf(M,m),M.foo()===42}catch{return!1}}Object.defineProperty(c.prototype,"parent",{enumerable:!0,get:function(){if(c.isBuffer(this))return this.buffer}}),Object.defineProperty(c.prototype,"offset",{enumerable:!0,get:function(){if(c.isBuffer(this))return this.byteOffset}});function a(M){if(M>o)throw new RangeError('The value "'+M+'" is invalid for option "size"');const m=new Uint8Array(M);return Object.setPrototypeOf(m,c.prototype),m}function c(M,m,b){if(typeof M=="number"){if(typeof m=="string")throw new TypeError('The "string" argument must be of type string. Received type number');return g(M)}return f(M,m,b)}c.poolSize=8192;function f(M,m,b){if(typeof M=="string")return x(M,m);if(ArrayBuffer.isView(M))return D(M);if(M==null)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof M);if(Qe(M,ArrayBuffer)||M&&Qe(M.buffer,ArrayBuffer)||typeof SharedArrayBuffer<"u"&&(Qe(M,SharedArrayBuffer)||M&&Qe(M.buffer,SharedArrayBuffer)))return E(M,m,b);if(typeof M=="number")throw new TypeError('The "value" argument must not be of type number. Received type number');const R=M.valueOf&&M.valueOf();if(R!=null&&R!==M)return c.from(R,m,b);const K=_(M);if(K)return K;if(typeof Symbol<"u"&&Symbol.toPrimitive!=null&&typeof M[Symbol.toPrimitive]=="function")return c.from(M[Symbol.toPrimitive]("string"),m,b);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof M)}c.from=function(M,m,b){return f(M,m,b)},Object.setPrototypeOf(c.prototype,Uint8Array.prototype),Object.setPrototypeOf(c,Uint8Array);function h(M){if(typeof M!="number")throw new TypeError('"size" argument must be of type number');if(M<0)throw new RangeError('The value "'+M+'" is invalid for option "size"')}function d(M,m,b){return h(M),M<=0?a(M):m!==void 0?typeof b=="string"?a(M).fill(m,b):a(M).fill(m):a(M)}c.alloc=function(M,m,b){return d(M,m,b)};function g(M){return h(M),a(M<0?0:T(M)|0)}c.allocUnsafe=function(M){return g(M)},c.allocUnsafeSlow=function(M){return g(M)};function x(M,m){if((typeof m!="string"||m==="")&&(m="utf8"),!c.isEncoding(m))throw new TypeError("Unknown encoding: "+m);const b=U(M,m)|0;let R=a(b);const K=R.write(M,m);return K!==b&&(R=R.slice(0,K)),R}function S(M){const m=M.length<0?0:T(M.length)|0,b=a(m);for(let R=0;R<m;R+=1)b[R]=M[R]&255;return b}function D(M){if(Qe(M,Uint8Array)){const m=new Uint8Array(M);return E(m.buffer,m.byteOffset,m.byteLength)}return S(M)}function E(M,m,b){if(m<0||M.byteLength<m)throw new RangeError('"offset" is outside of buffer bounds');if(M.byteLength<m+(b||0))throw new RangeError('"length" is outside of buffer bounds');let R;return m===void 0&&b===void 0?R=new Uint8Array(M):b===void 0?R=new Uint8Array(M,m):R=new Uint8Array(M,m,b),Object.setPrototypeOf(R,c.prototype),R}function _(M){if(c.isBuffer(M)){const m=T(M.length)|0,b=a(m);return b.length===0||M.copy(b,0,0,m),b}if(M.length!==void 0)return typeof M.length!="number"||Oe(M.length)?a(0):S(M);if(M.type==="Buffer"&&Array.isArray(M.data))return S(M.data)}function T(M){if(M>=o)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+o.toString(16)+" bytes");return M|0}function F(M){return+M!=M&&(M=0),c.alloc(+M)}c.isBuffer=function(m){return m!=null&&m._isBuffer===!0&&m!==c.prototype},c.compare=function(m,b){if(Qe(m,Uint8Array)&&(m=c.from(m,m.offset,m.byteLength)),Qe(b,Uint8Array)&&(b=c.from(b,b.offset,b.byteLength)),!c.isBuffer(m)||!c.isBuffer(b))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(m===b)return 0;let R=m.length,K=b.length;for(let q=0,te=Math.min(R,K);q<te;++q)if(m[q]!==b[q]){R=m[q],K=b[q];break}return R<K?-1:K<R?1:0},c.isEncoding=function(m){switch(String(m).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},c.concat=function(m,b){if(!Array.isArray(m))throw new TypeError('"list" argument must be an Array of Buffers');if(m.length===0)return c.alloc(0);let R;if(b===void 0)for(b=0,R=0;R<m.length;++R)b+=m[R].length;const K=c.allocUnsafe(b);let q=0;for(R=0;R<m.length;++R){let te=m[R];if(Qe(te,Uint8Array))q+te.length>K.length?(c.isBuffer(te)||(te=c.from(te)),te.copy(K,q)):Uint8Array.prototype.set.call(K,te,q);else if(c.isBuffer(te))te.copy(K,q);else throw new TypeError('"list" argument must be an Array of Buffers');q+=te.length}return K};function U(M,m){if(c.isBuffer(M))return M.length;if(ArrayBuffer.isView(M)||Qe(M,ArrayBuffer))return M.byteLength;if(typeof M!="string")throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof M);const b=M.length,R=arguments.length>2&&arguments[2]===!0;if(!R&&b===0)return 0;let K=!1;for(;;)switch(m){case"ascii":case"latin1":case"binary":return b;case"utf8":case"utf-8":return _e(M).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return b*2;case"hex":return b>>>1;case"base64":return He(M).length;default:if(K)return R?-1:_e(M).length;m=(""+m).toLowerCase(),K=!0}}c.byteLength=U;function z(M,m,b){let R=!1;if((m===void 0||m<0)&&(m=0),m>this.length||((b===void 0||b>this.length)&&(b=this.length),b<=0)||(b>>>=0,m>>>=0,b<=m))return"";for(M||(M="utf8");;)switch(M){case"hex":return C(this,m,b);case"utf8":case"utf-8":return u(this,m,b);case"ascii":return w(this,m,b);case"latin1":case"binary":return A(this,m,b);case"base64":return v(this,m,b);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return k(this,m,b);default:if(R)throw new TypeError("Unknown encoding: "+M);M=(M+"").toLowerCase(),R=!0}}c.prototype._isBuffer=!0;function V(M,m,b){const R=M[m];M[m]=M[b],M[b]=R}c.prototype.swap16=function(){const m=this.length;if(m%2!==0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(let b=0;b<m;b+=2)V(this,b,b+1);return this},c.prototype.swap32=function(){const m=this.length;if(m%4!==0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(let b=0;b<m;b+=4)V(this,b,b+3),V(this,b+1,b+2);return this},c.prototype.swap64=function(){const m=this.length;if(m%8!==0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(let b=0;b<m;b+=8)V(this,b,b+7),V(this,b+1,b+6),V(this,b+2,b+5),V(this,b+3,b+4);return this},c.prototype.toString=function(){const m=this.length;return m===0?"":arguments.length===0?u(this,0,m):z.apply(this,arguments)},c.prototype.toLocaleString=c.prototype.toString,c.prototype.equals=function(m){if(!c.isBuffer(m))throw new TypeError("Argument must be a Buffer");return this===m?!0:c.compare(this,m)===0},c.prototype.inspect=function(){let m="";const b=r.INSPECT_MAX_BYTES;return m=this.toString("hex",0,b).replace(/(.{2})/g,"$1 ").trim(),this.length>b&&(m+=" ... "),"<Buffer "+m+">"},i&&(c.prototype[i]=c.prototype.inspect),c.prototype.compare=function(m,b,R,K,q){if(Qe(m,Uint8Array)&&(m=c.from(m,m.offset,m.byteLength)),!c.isBuffer(m))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof m);if(b===void 0&&(b=0),R===void 0&&(R=m?m.length:0),K===void 0&&(K=0),q===void 0&&(q=this.length),b<0||R>m.length||K<0||q>this.length)throw new RangeError("out of range index");if(K>=q&&b>=R)return 0;if(K>=q)return-1;if(b>=R)return 1;if(b>>>=0,R>>>=0,K>>>=0,q>>>=0,this===m)return 0;let te=q-K,Ee=R-b;const ve=Math.min(te,Ee),me=this.slice(K,q),ze=m.slice(b,R);for(let ye=0;ye<ve;++ye)if(me[ye]!==ze[ye]){te=me[ye],Ee=ze[ye];break}return te<Ee?-1:Ee<te?1:0};function G(M,m,b,R,K){if(M.length===0)return-1;if(typeof b=="string"?(R=b,b=0):b>2147483647?b=2147483647:b<-2147483648&&(b=-2147483648),b=+b,Oe(b)&&(b=K?0:M.length-1),b<0&&(b=M.length+b),b>=M.length){if(K)return-1;b=M.length-1}else if(b<0)if(K)b=0;else return-1;if(typeof m=="string"&&(m=c.from(m,R)),c.isBuffer(m))return m.length===0?-1:ee(M,m,b,R,K);if(typeof m=="number")return m=m&255,typeof Uint8Array.prototype.indexOf=="function"?K?Uint8Array.prototype.indexOf.call(M,m,b):Uint8Array.prototype.lastIndexOf.call(M,m,b):ee(M,[m],b,R,K);throw new TypeError("val must be string, number or Buffer")}function ee(M,m,b,R,K){let q=1,te=M.length,Ee=m.length;if(R!==void 0&&(R=String(R).toLowerCase(),R==="ucs2"||R==="ucs-2"||R==="utf16le"||R==="utf-16le")){if(M.length<2||m.length<2)return-1;q=2,te/=2,Ee/=2,b/=2}function ve(ze,ye){return q===1?ze[ye]:ze.readUInt16BE(ye*q)}let me;if(K){let ze=-1;for(me=b;me<te;me++)if(ve(M,me)===ve(m,ze===-1?0:me-ze)){if(ze===-1&&(ze=me),me-ze+1===Ee)return ze*q}else ze!==-1&&(me-=me-ze),ze=-1}else for(b+Ee>te&&(b=te-Ee),me=b;me>=0;me--){let ze=!0;for(let ye=0;ye<Ee;ye++)if(ve(M,me+ye)!==ve(m,ye)){ze=!1;break}if(ze)return me}return-1}c.prototype.includes=function(m,b,R){return this.indexOf(m,b,R)!==-1},c.prototype.indexOf=function(m,b,R){return G(this,m,b,R,!0)},c.prototype.lastIndexOf=function(m,b,R){return G(this,m,b,R,!1)};function Q(M,m,b,R){b=Number(b)||0;const K=M.length-b;R?(R=Number(R),R>K&&(R=K)):R=K;const q=m.length;R>q/2&&(R=q/2);let te;for(te=0;te<R;++te){const Ee=parseInt(m.substr(te*2,2),16);if(Oe(Ee))return te;M[b+te]=Ee}return te}function X(M,m,b,R){return Te(_e(m,M.length-b),M,b,R)}function se(M,m,b,R){return Te(je(m),M,b,R)}function oe(M,m,b,R){return Te(He(m),M,b,R)}function H(M,m,b,R){return Te(cr(m,M.length-b),M,b,R)}c.prototype.write=function(m,b,R,K){if(b===void 0)K="utf8",R=this.length,b=0;else if(R===void 0&&typeof b=="string")K=b,R=this.length,b=0;else if(isFinite(b))b=b>>>0,isFinite(R)?(R=R>>>0,K===void 0&&(K="utf8")):(K=R,R=void 0);else throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");const q=this.length-b;if((R===void 0||R>q)&&(R=q),m.length>0&&(R<0||b<0)||b>this.length)throw new RangeError("Attempt to write outside buffer bounds");K||(K="utf8");let te=!1;for(;;)switch(K){case"hex":return Q(this,m,b,R);case"utf8":case"utf-8":return X(this,m,b,R);case"ascii":case"latin1":case"binary":return se(this,m,b,R);case"base64":return oe(this,m,b,R);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return H(this,m,b,R);default:if(te)throw new TypeError("Unknown encoding: "+K);K=(""+K).toLowerCase(),te=!0}},c.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function v(M,m,b){return m===0&&b===M.length?t.fromByteArray(M):t.fromByteArray(M.slice(m,b))}function u(M,m,b){b=Math.min(M.length,b);const R=[];let K=m;for(;K<b;){const q=M[K];let te=null,Ee=q>239?4:q>223?3:q>191?2:1;if(K+Ee<=b){let ve,me,ze,ye;switch(Ee){case 1:q<128&&(te=q);break;case 2:ve=M[K+1],(ve&192)===128&&(ye=(q&31)<<6|ve&63,ye>127&&(te=ye));break;case 3:ve=M[K+1],me=M[K+2],(ve&192)===128&&(me&192)===128&&(ye=(q&15)<<12|(ve&63)<<6|me&63,ye>2047&&(ye<55296||ye>57343)&&(te=ye));break;case 4:ve=M[K+1],me=M[K+2],ze=M[K+3],(ve&192)===128&&(me&192)===128&&(ze&192)===128&&(ye=(q&15)<<18|(ve&63)<<12|(me&63)<<6|ze&63,ye>65535&&ye<1114112&&(te=ye))}}te===null?(te=65533,Ee=1):te>65535&&(te-=65536,R.push(te>>>10&1023|55296),te=56320|te&1023),R.push(te),K+=Ee}return p(R)}const l=4096;function p(M){const m=M.length;if(m<=l)return String.fromCharCode.apply(String,M);let b="",R=0;for(;R<m;)b+=String.fromCharCode.apply(String,M.slice(R,R+=l));return b}function w(M,m,b){let R="";b=Math.min(M.length,b);for(let K=m;K<b;++K)R+=String.fromCharCode(M[K]&127);return R}function A(M,m,b){let R="";b=Math.min(M.length,b);for(let K=m;K<b;++K)R+=String.fromCharCode(M[K]);return R}function C(M,m,b){const R=M.length;(!m||m<0)&&(m=0),(!b||b<0||b>R)&&(b=R);let K="";for(let q=m;q<b;++q)K+=Pe[M[q]];return K}function k(M,m,b){const R=M.slice(m,b);let K="";for(let q=0;q<R.length-1;q+=2)K+=String.fromCharCode(R[q]+R[q+1]*256);return K}c.prototype.slice=function(m,b){const R=this.length;m=~~m,b=b===void 0?R:~~b,m<0?(m+=R,m<0&&(m=0)):m>R&&(m=R),b<0?(b+=R,b<0&&(b=0)):b>R&&(b=R),b<m&&(b=m);const K=this.subarray(m,b);return Object.setPrototypeOf(K,c.prototype),K};function I(M,m,b){if(M%1!==0||M<0)throw new RangeError("offset is not uint");if(M+m>b)throw new RangeError("Trying to access beyond buffer length")}c.prototype.readUintLE=c.prototype.readUIntLE=function(m,b,R){m=m>>>0,b=b>>>0,R||I(m,b,this.length);let K=this[m],q=1,te=0;for(;++te<b&&(q*=256);)K+=this[m+te]*q;return K},c.prototype.readUintBE=c.prototype.readUIntBE=function(m,b,R){m=m>>>0,b=b>>>0,R||I(m,b,this.length);let K=this[m+--b],q=1;for(;b>0&&(q*=256);)K+=this[m+--b]*q;return K},c.prototype.readUint8=c.prototype.readUInt8=function(m,b){return m=m>>>0,b||I(m,1,this.length),this[m]},c.prototype.readUint16LE=c.prototype.readUInt16LE=function(m,b){return m=m>>>0,b||I(m,2,this.length),this[m]|this[m+1]<<8},c.prototype.readUint16BE=c.prototype.readUInt16BE=function(m,b){return m=m>>>0,b||I(m,2,this.length),this[m]<<8|this[m+1]},c.prototype.readUint32LE=c.prototype.readUInt32LE=function(m,b){return m=m>>>0,b||I(m,4,this.length),(this[m]|this[m+1]<<8|this[m+2]<<16)+this[m+3]*16777216},c.prototype.readUint32BE=c.prototype.readUInt32BE=function(m,b){return m=m>>>0,b||I(m,4,this.length),this[m]*16777216+(this[m+1]<<16|this[m+2]<<8|this[m+3])},c.prototype.readBigUInt64LE=vt(function(m){m=m>>>0,be(m,"offset");const b=this[m],R=this[m+7];(b===void 0||R===void 0)&&fe(m,this.length-8);const K=b+this[++m]*2**8+this[++m]*2**16+this[++m]*2**24,q=this[++m]+this[++m]*2**8+this[++m]*2**16+R*2**24;return BigInt(K)+(BigInt(q)<<BigInt(32))}),c.prototype.readBigUInt64BE=vt(function(m){m=m>>>0,be(m,"offset");const b=this[m],R=this[m+7];(b===void 0||R===void 0)&&fe(m,this.length-8);const K=b*2**24+this[++m]*2**16+this[++m]*2**8+this[++m],q=this[++m]*2**24+this[++m]*2**16+this[++m]*2**8+R;return(BigInt(K)<<BigInt(32))+BigInt(q)}),c.prototype.readIntLE=function(m,b,R){m=m>>>0,b=b>>>0,R||I(m,b,this.length);let K=this[m],q=1,te=0;for(;++te<b&&(q*=256);)K+=this[m+te]*q;return q*=128,K>=q&&(K-=Math.pow(2,8*b)),K},c.prototype.readIntBE=function(m,b,R){m=m>>>0,b=b>>>0,R||I(m,b,this.length);let K=b,q=1,te=this[m+--K];for(;K>0&&(q*=256);)te+=this[m+--K]*q;return q*=128,te>=q&&(te-=Math.pow(2,8*b)),te},c.prototype.readInt8=function(m,b){return m=m>>>0,b||I(m,1,this.length),this[m]&128?(255-this[m]+1)*-1:this[m]},c.prototype.readInt16LE=function(m,b){m=m>>>0,b||I(m,2,this.length);const R=this[m]|this[m+1]<<8;return R&32768?R|4294901760:R},c.prototype.readInt16BE=function(m,b){m=m>>>0,b||I(m,2,this.length);const R=this[m+1]|this[m]<<8;return R&32768?R|4294901760:R},c.prototype.readInt32LE=function(m,b){return m=m>>>0,b||I(m,4,this.length),this[m]|this[m+1]<<8|this[m+2]<<16|this[m+3]<<24},c.prototype.readInt32BE=function(m,b){return m=m>>>0,b||I(m,4,this.length),this[m]<<24|this[m+1]<<16|this[m+2]<<8|this[m+3]},c.prototype.readBigInt64LE=vt(function(m){m=m>>>0,be(m,"offset");const b=this[m],R=this[m+7];(b===void 0||R===void 0)&&fe(m,this.length-8);const K=this[m+4]+this[m+5]*2**8+this[m+6]*2**16+(R<<24);return(BigInt(K)<<BigInt(32))+BigInt(b+this[++m]*2**8+this[++m]*2**16+this[++m]*2**24)}),c.prototype.readBigInt64BE=vt(function(m){m=m>>>0,be(m,"offset");const b=this[m],R=this[m+7];(b===void 0||R===void 0)&&fe(m,this.length-8);const K=(b<<24)+this[++m]*2**16+this[++m]*2**8+this[++m];return(BigInt(K)<<BigInt(32))+BigInt(this[++m]*2**24+this[++m]*2**16+this[++m]*2**8+R)}),c.prototype.readFloatLE=function(m,b){return m=m>>>0,b||I(m,4,this.length),n.read(this,m,!0,23,4)},c.prototype.readFloatBE=function(m,b){return m=m>>>0,b||I(m,4,this.length),n.read(this,m,!1,23,4)},c.prototype.readDoubleLE=function(m,b){return m=m>>>0,b||I(m,8,this.length),n.read(this,m,!0,52,8)},c.prototype.readDoubleBE=function(m,b){return m=m>>>0,b||I(m,8,this.length),n.read(this,m,!1,52,8)};function y(M,m,b,R,K,q){if(!c.isBuffer(M))throw new TypeError('"buffer" argument must be a Buffer instance');if(m>K||m<q)throw new RangeError('"value" argument is out of bounds');if(b+R>M.length)throw new RangeError("Index out of range")}c.prototype.writeUintLE=c.prototype.writeUIntLE=function(m,b,R,K){if(m=+m,b=b>>>0,R=R>>>0,!K){const Ee=Math.pow(2,8*R)-1;y(this,m,b,R,Ee,0)}let q=1,te=0;for(this[b]=m&255;++te<R&&(q*=256);)this[b+te]=m/q&255;return b+R},c.prototype.writeUintBE=c.prototype.writeUIntBE=function(m,b,R,K){if(m=+m,b=b>>>0,R=R>>>0,!K){const Ee=Math.pow(2,8*R)-1;y(this,m,b,R,Ee,0)}let q=R-1,te=1;for(this[b+q]=m&255;--q>=0&&(te*=256);)this[b+q]=m/te&255;return b+R},c.prototype.writeUint8=c.prototype.writeUInt8=function(m,b,R){return m=+m,b=b>>>0,R||y(this,m,b,1,255,0),this[b]=m&255,b+1},c.prototype.writeUint16LE=c.prototype.writeUInt16LE=function(m,b,R){return m=+m,b=b>>>0,R||y(this,m,b,2,65535,0),this[b]=m&255,this[b+1]=m>>>8,b+2},c.prototype.writeUint16BE=c.prototype.writeUInt16BE=function(m,b,R){return m=+m,b=b>>>0,R||y(this,m,b,2,65535,0),this[b]=m>>>8,this[b+1]=m&255,b+2},c.prototype.writeUint32LE=c.prototype.writeUInt32LE=function(m,b,R){return m=+m,b=b>>>0,R||y(this,m,b,4,4294967295,0),this[b+3]=m>>>24,this[b+2]=m>>>16,this[b+1]=m>>>8,this[b]=m&255,b+4},c.prototype.writeUint32BE=c.prototype.writeUInt32BE=function(m,b,R){return m=+m,b=b>>>0,R||y(this,m,b,4,4294967295,0),this[b]=m>>>24,this[b+1]=m>>>16,this[b+2]=m>>>8,this[b+3]=m&255,b+4};function N(M,m,b,R,K){ae(m,R,K,M,b,7);let q=Number(m&BigInt(4294967295));M[b++]=q,q=q>>8,M[b++]=q,q=q>>8,M[b++]=q,q=q>>8,M[b++]=q;let te=Number(m>>BigInt(32)&BigInt(4294967295));return M[b++]=te,te=te>>8,M[b++]=te,te=te>>8,M[b++]=te,te=te>>8,M[b++]=te,b}function re(M,m,b,R,K){ae(m,R,K,M,b,7);let q=Number(m&BigInt(4294967295));M[b+7]=q,q=q>>8,M[b+6]=q,q=q>>8,M[b+5]=q,q=q>>8,M[b+4]=q;let te=Number(m>>BigInt(32)&BigInt(4294967295));return M[b+3]=te,te=te>>8,M[b+2]=te,te=te>>8,M[b+1]=te,te=te>>8,M[b]=te,b+8}c.prototype.writeBigUInt64LE=vt(function(m,b=0){return N(this,m,b,BigInt(0),BigInt("0xffffffffffffffff"))}),c.prototype.writeBigUInt64BE=vt(function(m,b=0){return re(this,m,b,BigInt(0),BigInt("0xffffffffffffffff"))}),c.prototype.writeIntLE=function(m,b,R,K){if(m=+m,b=b>>>0,!K){const ve=Math.pow(2,8*R-1);y(this,m,b,R,ve-1,-ve)}let q=0,te=1,Ee=0;for(this[b]=m&255;++q<R&&(te*=256);)m<0&&Ee===0&&this[b+q-1]!==0&&(Ee=1),this[b+q]=(m/te>>0)-Ee&255;return b+R},c.prototype.writeIntBE=function(m,b,R,K){if(m=+m,b=b>>>0,!K){const ve=Math.pow(2,8*R-1);y(this,m,b,R,ve-1,-ve)}let q=R-1,te=1,Ee=0;for(this[b+q]=m&255;--q>=0&&(te*=256);)m<0&&Ee===0&&this[b+q+1]!==0&&(Ee=1),this[b+q]=(m/te>>0)-Ee&255;return b+R},c.prototype.writeInt8=function(m,b,R){return m=+m,b=b>>>0,R||y(this,m,b,1,127,-128),m<0&&(m=255+m+1),this[b]=m&255,b+1},c.prototype.writeInt16LE=function(m,b,R){return m=+m,b=b>>>0,R||y(this,m,b,2,32767,-32768),this[b]=m&255,this[b+1]=m>>>8,b+2},c.prototype.writeInt16BE=function(m,b,R){return m=+m,b=b>>>0,R||y(this,m,b,2,32767,-32768),this[b]=m>>>8,this[b+1]=m&255,b+2},c.prototype.writeInt32LE=function(m,b,R){return m=+m,b=b>>>0,R||y(this,m,b,4,2147483647,-2147483648),this[b]=m&255,this[b+1]=m>>>8,this[b+2]=m>>>16,this[b+3]=m>>>24,b+4},c.prototype.writeInt32BE=function(m,b,R){return m=+m,b=b>>>0,R||y(this,m,b,4,2147483647,-2147483648),m<0&&(m=4294967295+m+1),this[b]=m>>>24,this[b+1]=m>>>16,this[b+2]=m>>>8,this[b+3]=m&255,b+4},c.prototype.writeBigInt64LE=vt(function(m,b=0){return N(this,m,b,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))}),c.prototype.writeBigInt64BE=vt(function(m,b=0){return re(this,m,b,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});function B(M,m,b,R,K,q){if(b+R>M.length)throw new RangeError("Index out of range");if(b<0)throw new RangeError("Index out of range")}function j(M,m,b,R,K){return m=+m,b=b>>>0,K||B(M,m,b,4),n.write(M,m,b,R,23,4),b+4}c.prototype.writeFloatLE=function(m,b,R){return j(this,m,b,!0,R)},c.prototype.writeFloatBE=function(m,b,R){return j(this,m,b,!1,R)};function Z(M,m,b,R,K){return m=+m,b=b>>>0,K||B(M,m,b,8),n.write(M,m,b,R,52,8),b+8}c.prototype.writeDoubleLE=function(m,b,R){return Z(this,m,b,!0,R)},c.prototype.writeDoubleBE=function(m,b,R){return Z(this,m,b,!1,R)},c.prototype.copy=function(m,b,R,K){if(!c.isBuffer(m))throw new TypeError("argument should be a Buffer");if(R||(R=0),!K&&K!==0&&(K=this.length),b>=m.length&&(b=m.length),b||(b=0),K>0&&K<R&&(K=R),K===R||m.length===0||this.length===0)return 0;if(b<0)throw new RangeError("targetStart out of bounds");if(R<0||R>=this.length)throw new RangeError("Index out of range");if(K<0)throw new RangeError("sourceEnd out of bounds");K>this.length&&(K=this.length),m.length-b<K-R&&(K=m.length-b+R);const q=K-R;return this===m&&typeof Uint8Array.prototype.copyWithin=="function"?this.copyWithin(b,R,K):Uint8Array.prototype.set.call(m,this.subarray(R,K),b),q},c.prototype.fill=function(m,b,R,K){if(typeof m=="string"){if(typeof b=="string"?(K=b,b=0,R=this.length):typeof R=="string"&&(K=R,R=this.length),K!==void 0&&typeof K!="string")throw new TypeError("encoding must be a string");if(typeof K=="string"&&!c.isEncoding(K))throw new TypeError("Unknown encoding: "+K);if(m.length===1){const te=m.charCodeAt(0);(K==="utf8"&&te<128||K==="latin1")&&(m=te)}}else typeof m=="number"?m=m&255:typeof m=="boolean"&&(m=Number(m));if(b<0||this.length<b||this.length<R)throw new RangeError("Out of range index");if(R<=b)return this;b=b>>>0,R=R===void 0?this.length:R>>>0,m||(m=0);let q;if(typeof m=="number")for(q=b;q<R;++q)this[q]=m;else{const te=c.isBuffer(m)?m:c.from(m,K),Ee=te.length;if(Ee===0)throw new TypeError('The value "'+m+'" is invalid for argument "value"');for(q=0;q<R-b;++q)this[q+b]=te[q%Ee]}return this};const Y={};function ne(M,m,b){Y[M]=class extends b{constructor(){super(),Object.defineProperty(this,"message",{value:m.apply(this,arguments),writable:!0,configurable:!0}),this.name=`${this.name} [${M}]`,this.stack,delete this.name}get code(){return M}set code(K){Object.defineProperty(this,"code",{configurable:!0,enumerable:!0,value:K,writable:!0})}toString(){return`${this.name} [${M}]: ${this.message}`}}}ne("ERR_BUFFER_OUT_OF_BOUNDS",function(M){return M?`${M} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"},RangeError),ne("ERR_INVALID_ARG_TYPE",function(M,m){return`The "${M}" argument must be of type number. Received type ${typeof m}`},TypeError),ne("ERR_OUT_OF_RANGE",function(M,m,b){let R=`The value of "${M}" is out of range.`,K=b;return Number.isInteger(b)&&Math.abs(b)>2**32?K=ue(String(b)):typeof b=="bigint"&&(K=String(b),(b>BigInt(2)**BigInt(32)||b<-(BigInt(2)**BigInt(32)))&&(K=ue(K)),K+="n"),R+=` It must be ${m}. Received ${K}`,R},RangeError);function ue(M){let m="",b=M.length;const R=M[0]==="-"?1:0;for(;b>=R+4;b-=3)m=`_${M.slice(b-3,b)}${m}`;return`${M.slice(0,b)}${m}`}function ce(M,m,b){be(m,"offset"),(M[m]===void 0||M[m+b]===void 0)&&fe(m,M.length-(b+1))}function ae(M,m,b,R,K,q){if(M>b||M<m){const te=typeof m=="bigint"?"n":"";let Ee;throw m===0||m===BigInt(0)?Ee=`>= 0${te} and < 2${te} ** ${(q+1)*8}${te}`:Ee=`>= -(2${te} ** ${(q+1)*8-1}${te}) and < 2 ** ${(q+1)*8-1}${te}`,new Y.ERR_OUT_OF_RANGE("value",Ee,M)}ce(R,K,q)}function be(M,m){if(typeof M!="number")throw new Y.ERR_INVALID_ARG_TYPE(m,"number",M)}function fe(M,m,b){throw Math.floor(M)!==M?(be(M,b),new Y.ERR_OUT_OF_RANGE("offset","an integer",M)):m<0?new Y.ERR_BUFFER_OUT_OF_BOUNDS:new Y.ERR_OUT_OF_RANGE("offset",`>= 0 and <= ${m}`,M)}const ge=/[^+/0-9A-Za-z-_]/g;function jt(M){if(M=M.split("=")[0],M=M.trim().replace(ge,""),M.length<2)return"";for(;M.length%4!==0;)M=M+"=";return M}function _e(M,m){m=m||1/0;let b;const R=M.length;let K=null;const q=[];for(let te=0;te<R;++te){if(b=M.charCodeAt(te),b>55295&&b<57344){if(!K){if(b>56319){(m-=3)>-1&&q.push(239,191,189);continue}else if(te+1===R){(m-=3)>-1&&q.push(239,191,189);continue}K=b;continue}if(b<56320){(m-=3)>-1&&q.push(239,191,189),K=b;continue}b=(K-55296<<10|b-56320)+65536}else K&&(m-=3)>-1&&q.push(239,191,189);if(K=null,b<128){if((m-=1)<0)break;q.push(b)}else if(b<2048){if((m-=2)<0)break;q.push(b>>6|192,b&63|128)}else if(b<65536){if((m-=3)<0)break;q.push(b>>12|224,b>>6&63|128,b&63|128)}else if(b<1114112){if((m-=4)<0)break;q.push(b>>18|240,b>>12&63|128,b>>6&63|128,b&63|128)}else throw new Error("Invalid code point")}return q}function je(M){const m=[];for(let b=0;b<M.length;++b)m.push(M.charCodeAt(b)&255);return m}function cr(M,m){let b,R,K;const q=[];for(let te=0;te<M.length&&!((m-=2)<0);++te)b=M.charCodeAt(te),R=b>>8,K=b%256,q.push(K),q.push(R);return q}function He(M){return t.toByteArray(jt(M))}function Te(M,m,b,R){let K;for(K=0;K<R&&!(K+b>=m.length||K>=M.length);++K)m[K+b]=M[K];return K}function Qe(M,m){return M instanceof m||M!=null&&M.constructor!=null&&M.constructor.name!=null&&M.constructor.name===m.name}function Oe(M){return M!==M}const Pe=function(){const M="0123456789abcdef",m=new Array(256);for(let b=0;b<16;++b){const R=b*16;for(let K=0;K<16;++K)m[R+K]=M[b]+M[K]}return m}();function vt(M){return typeof BigInt>"u"?$e:M}function $e(){throw new Error("BigInt not supported")}}(uf)),uf}var qe=cm();const lf=typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0;function tu(r){if(!Number.isSafeInteger(r)||r<0)throw new Error(`positive integer expected, not ${r}`)}function fm(r){if(typeof r!="boolean")throw new Error(`boolean expected, not ${r}`)}function um(r){return r instanceof Uint8Array||r!=null&&typeof r=="object"&&r.constructor.name==="Uint8Array"}function _l(r,...t){if(!um(r))throw new Error("Uint8Array expected");if(t.length>0&&!t.includes(r.length))throw new Error(`Uint8Array expected of length ${t}, not of length=${r.length}`)}function lm(r){if(typeof r!="function"||typeof r.create!="function")throw new Error("Hash should be wrapped by utils.wrapConstructor");tu(r.outputLen),tu(r.blockLen)}function ru(r,t=!0){if(r.destroyed)throw new Error("Hash instance has been destroyed");if(t&&r.finished)throw new Error("Hash#digest() has already been called")}function Op(r,t){_l(r);const n=t.outputLen;if(r.length<n)throw new Error(`digestInto() expects output buffer of length at least ${n}`)}const hm={number:tu,bool:fm,bytes:_l,hash:lm,exists:ru,output:Op};/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */const hf=r=>new DataView(r.buffer,r.byteOffset,r.byteLength),nn=(r,t)=>r<<32-t|r>>>t;new Uint8Array(new Uint32Array([287454020]).buffer)[0];function dm(r){if(typeof r!="string")throw new Error(`utf8ToBytes expected string, got ${typeof r}`);return new Uint8Array(new TextEncoder().encode(r))}function Pp(r){return typeof r=="string"&&(r=dm(r)),_l(r),r}let pm=class{clone(){return this._cloneInto()}};function gm(r){const t=i=>r().update(Pp(i)).digest(),n=r();return t.outputLen=n.outputLen,t.blockLen=n.blockLen,t.create=()=>r(),t}function ym(r=32){if(lf&&typeof lf.getRandomValues=="function")return lf.getRandomValues(new Uint8Array(r));throw new Error("crypto.getRandomValues must be defined")}function wm(r){return ym(r)}function mm(r){return r instanceof Uint8Array||r!=null&&typeof r=="object"&&r.constructor.name==="Uint8Array"}function Ml(r,...t){if(!mm(r))throw new Error("Uint8Array expected");if(t.length>0&&!t.includes(r.length))throw new Error(`Uint8Array expected of length ${t}, not of length=${r.length}`)}function ad(r,t=!0){if(r.destroyed)throw new Error("Hash instance has been destroyed");if(t&&r.finished)throw new Error("Hash#digest() has already been called")}function bm(r,t){Ml(r);const n=t.outputLen;if(r.length<n)throw new Error(`digestInto() expects output buffer of length at least ${n}`)}/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */const df=r=>new DataView(r.buffer,r.byteOffset,r.byteLength),on=(r,t)=>r<<32-t|r>>>t;new Uint8Array(new Uint32Array([287454020]).buffer)[0];function vm(r){if(typeof r!="string")throw new Error(`utf8ToBytes expected string, got ${typeof r}`);return new Uint8Array(new TextEncoder().encode(r))}function Fp(r){return typeof r=="string"&&(r=vm(r)),Ml(r),r}let xm=class{clone(){return this._cloneInto()}};function Am(r){const t=i=>r().update(Fp(i)).digest(),n=r();return t.outputLen=n.outputLen,t.blockLen=n.blockLen,t.create=()=>r(),t}function Em(r,t,n,i){if(typeof r.setBigUint64=="function")return r.setBigUint64(t,n,i);const o=BigInt(32),s=BigInt(4294967295),a=Number(n>>o&s),c=Number(n&s),f=i?4:0,h=i?0:4;r.setUint32(t+f,a,i),r.setUint32(t+h,c,i)}const Sm=(r,t,n)=>r&t^~r&n,Bm=(r,t,n)=>r&t^r&n^t&n;let Dm=class extends xm{constructor(t,n,i,o){super(),this.blockLen=t,this.outputLen=n,this.padOffset=i,this.isLE=o,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(t),this.view=df(this.buffer)}update(t){ad(this);const{view:n,buffer:i,blockLen:o}=this;t=Fp(t);const s=t.length;for(let a=0;a<s;){const c=Math.min(o-this.pos,s-a);if(c===o){const f=df(t);for(;o<=s-a;a+=o)this.process(f,a);continue}i.set(t.subarray(a,a+c),this.pos),this.pos+=c,a+=c,this.pos===o&&(this.process(n,0),this.pos=0)}return this.length+=t.length,this.roundClean(),this}digestInto(t){ad(this),bm(t,this),this.finished=!0;const{buffer:n,view:i,blockLen:o,isLE:s}=this;let{pos:a}=this;n[a++]=128,this.buffer.subarray(a).fill(0),this.padOffset>o-a&&(this.process(i,0),a=0);for(let g=a;g<o;g++)n[g]=0;Em(i,o-8,BigInt(this.length*8),s),this.process(i,0);const c=df(t),f=this.outputLen;if(f%4)throw new Error("_sha2: outputLen should be aligned to 32bit");const h=f/4,d=this.get();if(h>d.length)throw new Error("_sha2: outputLen bigger than state");for(let g=0;g<h;g++)c.setUint32(4*g,d[g],s)}digest(){const{buffer:t,outputLen:n}=this;this.digestInto(t);const i=t.slice(0,n);return this.destroy(),i}_cloneInto(t){t||(t=new this.constructor),t.set(...this.get());const{blockLen:n,buffer:i,length:o,finished:s,destroyed:a,pos:c}=this;return t.length=o,t.pos=c,t.finished=s,t.destroyed=a,o%n&&t.buffer.set(i),t}};const Cm=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),Gn=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),Wn=new Uint32Array(64);let Im=class extends Dm{constructor(){super(64,32,8,!1),this.A=Gn[0]|0,this.B=Gn[1]|0,this.C=Gn[2]|0,this.D=Gn[3]|0,this.E=Gn[4]|0,this.F=Gn[5]|0,this.G=Gn[6]|0,this.H=Gn[7]|0}get(){const{A:t,B:n,C:i,D:o,E:s,F:a,G:c,H:f}=this;return[t,n,i,o,s,a,c,f]}set(t,n,i,o,s,a,c,f){this.A=t|0,this.B=n|0,this.C=i|0,this.D=o|0,this.E=s|0,this.F=a|0,this.G=c|0,this.H=f|0}process(t,n){for(let g=0;g<16;g++,n+=4)Wn[g]=t.getUint32(n,!1);for(let g=16;g<64;g++){const x=Wn[g-15],S=Wn[g-2],D=on(x,7)^on(x,18)^x>>>3,E=on(S,17)^on(S,19)^S>>>10;Wn[g]=E+Wn[g-7]+D+Wn[g-16]|0}let{A:i,B:o,C:s,D:a,E:c,F:f,G:h,H:d}=this;for(let g=0;g<64;g++){const x=on(c,6)^on(c,11)^on(c,25),S=d+x+Sm(c,f,h)+Cm[g]+Wn[g]|0,E=(on(i,2)^on(i,13)^on(i,22))+Bm(i,o,s)|0;d=h,h=f,f=c,c=a+S|0,a=s,s=o,o=i,i=S+E|0}i=i+this.A|0,o=o+this.B|0,s=s+this.C|0,a=a+this.D|0,c=c+this.E|0,f=f+this.F|0,h=h+this.G|0,d=d+this.H|0,this.set(i,o,s,a,c,f,h,d)}roundClean(){Wn.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}};const _m=Am(()=>new Im);/*! scure-base - MIT License (c) 2022 Paul Miller (paulmillr.com) */function Aa(r){return r instanceof Uint8Array||r!=null&&typeof r=="object"&&r.constructor.name==="Uint8Array"}function Mm(...r){const t=s=>s,n=(s,a)=>c=>s(a(c)),i=r.map(s=>s.encode).reduceRight(n,t),o=r.map(s=>s.decode).reduce(n,t);return{encode:i,decode:o}}function km(r){return{encode:t=>{if(!Array.isArray(t)||t.length&&typeof t[0]!="number")throw new Error("alphabet.encode input should be an array of numbers");return t.map(n=>{if(n<0||n>=r.length)throw new Error(`Digit index outside alphabet: ${n} (alphabet: ${r.length})`);return r[n]})},decode:t=>{if(!Array.isArray(t)||t.length&&typeof t[0]!="string")throw new Error("alphabet.decode input should be array of strings");return t.map(n=>{if(typeof n!="string")throw new Error(`alphabet.decode: not string element=${n}`);const i=r.indexOf(n);if(i===-1)throw new Error(`Unknown letter: "${n}". Allowed: ${r}`);return i})}}}function Tm(r=""){if(typeof r!="string")throw new Error("join separator should be string");return{encode:t=>{if(!Array.isArray(t)||t.length&&typeof t[0]!="string")throw new Error("join.encode input should be array of strings");for(let n of t)if(typeof n!="string")throw new Error(`join.encode: non-string input=${n}`);return t.join(r)},decode:t=>{if(typeof t!="string")throw new Error("join.decode input should be string");return t.split(r)}}}function Nm(r,t="="){if(typeof t!="string")throw new Error("padding chr should be string");return{encode(n){if(!Array.isArray(n)||n.length&&typeof n[0]!="string")throw new Error("padding.encode input should be array of strings");for(let i of n)if(typeof i!="string")throw new Error(`padding.encode: non-string input=${i}`);for(;n.length*r%8;)n.push(t);return n},decode(n){if(!Array.isArray(n)||n.length&&typeof n[0]!="string")throw new Error("padding.encode input should be array of strings");for(let o of n)if(typeof o!="string")throw new Error(`padding.decode: non-string input=${o}`);let i=n.length;if(i*r%8)throw new Error("Invalid padding: string should have whole number of bytes");for(;i>0&&n[i-1]===t;i--)if(!((i-1)*r%8))throw new Error("Invalid padding: string has too much padding");return n.slice(0,i)}}}function nu(r,t,n){if(t<2)throw new Error(`convertRadix: wrong from=${t}, base cannot be less than 2`);if(n<2)throw new Error(`convertRadix: wrong to=${n}, base cannot be less than 2`);if(!Array.isArray(r))throw new Error("convertRadix: data should be array");if(!r.length)return[];let i=0;const o=[],s=Array.from(r);for(s.forEach(a=>{if(a<0||a>=t)throw new Error(`Wrong integer: ${a}`)});;){let a=0,c=!0;for(let f=i;f<s.length;f++){const h=s[f],d=t*a+h;if(!Number.isSafeInteger(d)||t*a/t!==a||d-h!==t*a)throw new Error("convertRadix: carry overflow");a=d%n;const g=Math.floor(d/n);if(s[f]=g,!Number.isSafeInteger(g)||g*n+a!==d)throw new Error("convertRadix: carry overflow");if(c)g?c=!1:i=f;else continue}if(o.push(a),c)break}for(let a=0;a<r.length-1&&r[a]===0;a++)o.push(0);return o.reverse()}const Lp=(r,t)=>t?Lp(t,r%t):r,Ea=(r,t)=>r+(t-Lp(r,t));function iu(r,t,n,i){if(!Array.isArray(r))throw new Error("convertRadix2: data should be array");if(t<=0||t>32)throw new Error(`convertRadix2: wrong from=${t}`);if(n<=0||n>32)throw new Error(`convertRadix2: wrong to=${n}`);if(Ea(t,n)>32)throw new Error(`convertRadix2: carry overflow from=${t} to=${n} carryBits=${Ea(t,n)}`);let o=0,s=0;const a=2**n-1,c=[];for(const f of r){if(f>=2**t)throw new Error(`convertRadix2: invalid data word=${f} from=${t}`);if(o=o<<t|f,s+t>32)throw new Error(`convertRadix2: carry overflow pos=${s} from=${t}`);for(s+=t;s>=n;s-=n)c.push((o>>s-n&a)>>>0);o&=2**s-1}if(o=o<<n-s&a,!i&&s>=t)throw new Error("Excess padding");if(!i&&o)throw new Error(`Non-zero padding: ${o}`);return i&&s>0&&c.push(o>>>0),c}function Rm(r){return{encode:t=>{if(!Aa(t))throw new Error("radix.encode input should be Uint8Array");return nu(Array.from(t),2**8,r)},decode:t=>{if(!Array.isArray(t)||t.length&&typeof t[0]!="number")throw new Error("radix.decode input should be array of numbers");return Uint8Array.from(nu(t,r,2**8))}}}function Um(r,t=!1){if(r<=0||r>32)throw new Error("radix2: bits should be in (0..32]");if(Ea(8,r)>32||Ea(r,8)>32)throw new Error("radix2: carry overflow");return{encode:n=>{if(!Aa(n))throw new Error("radix2.encode input should be Uint8Array");return iu(Array.from(n),8,r,!t)},decode:n=>{if(!Array.isArray(n)||n.length&&typeof n[0]!="number")throw new Error("radix2.decode input should be array of numbers");return Uint8Array.from(iu(n,r,8,t))}}}function Om(r,t){if(typeof t!="function")throw new Error("checksum fn should be function");return{encode(n){if(!Aa(n))throw new Error("checksum.encode: input should be Uint8Array");const i=t(n).slice(0,r),o=new Uint8Array(n.length+r);return o.set(n),o.set(i,n.length),o},decode(n){if(!Aa(n))throw new Error("checksum.decode: input should be Uint8Array");const i=n.slice(0,-r),o=t(i).slice(0,r),s=n.slice(-r);for(let a=0;a<r;a++)if(o[a]!==s[a])throw new Error("Invalid checksum");return i}}}const qs={alphabet:km,chain:Mm,checksum:Om,convertRadix:nu,convertRadix2:iu,radix:Rm,radix2:Um,join:Tm,padding:Nm};/*! scure-bip39 - MIT License (c) 2022 Patricio Palladino, Paul Miller (paulmillr.com) */const Pm=r=>r[0]==="あいこくしん";function Fm(r){Ml(r,16,20,24,28,32)}const Lm=r=>{const t=8-r.length/4;return new Uint8Array([_m(r)[0]>>t<<t])};function Hm(r){if(!Array.isArray(r)||r.length!==2048||typeof r[0]!="string")throw new Error("Wordlist: expected array of 2048 strings");return r.forEach(t=>{if(typeof t!="string")throw new Error(`Wordlist: non-string element: ${t}`)}),qs.chain(qs.checksum(1,Lm),qs.radix2(11,!0),qs.alphabet(r))}function $m(r,t){return Fm(r),Hm(t).encode(r).join(Pm(t)?" ":" ")}const Vm=`abandon
ability
able
about
above
absent
absorb
abstract
absurd
abuse
access
accident
account
accuse
achieve
acid
acoustic
acquire
across
act
action
actor
actress
actual
adapt
add
addict
address
adjust
admit
adult
advance
advice
aerobic
affair
afford
afraid
again
age
agent
agree
ahead
aim
air
airport
aisle
alarm
album
alcohol
alert
alien
all
alley
allow
almost
alone
alpha
already
also
alter
always
amateur
amazing
among
amount
amused
analyst
anchor
ancient
anger
angle
angry
animal
ankle
announce
annual
another
answer
antenna
antique
anxiety
any
apart
apology
appear
apple
approve
april
arch
arctic
area
arena
argue
arm
armed
armor
army
around
arrange
arrest
arrive
arrow
art
artefact
artist
artwork
ask
aspect
assault
asset
assist
assume
asthma
athlete
atom
attack
attend
attitude
attract
auction
audit
august
aunt
author
auto
autumn
average
avocado
avoid
awake
aware
away
awesome
awful
awkward
axis
baby
bachelor
bacon
badge
bag
balance
balcony
ball
bamboo
banana
banner
bar
barely
bargain
barrel
base
basic
basket
battle
beach
bean
beauty
because
become
beef
before
begin
behave
behind
believe
below
belt
bench
benefit
best
betray
better
between
beyond
bicycle
bid
bike
bind
biology
bird
birth
bitter
black
blade
blame
blanket
blast
bleak
bless
blind
blood
blossom
blouse
blue
blur
blush
board
boat
body
boil
bomb
bone
bonus
book
boost
border
boring
borrow
boss
bottom
bounce
box
boy
bracket
brain
brand
brass
brave
bread
breeze
brick
bridge
brief
bright
bring
brisk
broccoli
broken
bronze
broom
brother
brown
brush
bubble
buddy
budget
buffalo
build
bulb
bulk
bullet
bundle
bunker
burden
burger
burst
bus
business
busy
butter
buyer
buzz
cabbage
cabin
cable
cactus
cage
cake
call
calm
camera
camp
can
canal
cancel
candy
cannon
canoe
canvas
canyon
capable
capital
captain
car
carbon
card
cargo
carpet
carry
cart
case
cash
casino
castle
casual
cat
catalog
catch
category
cattle
caught
cause
caution
cave
ceiling
celery
cement
census
century
cereal
certain
chair
chalk
champion
change
chaos
chapter
charge
chase
chat
cheap
check
cheese
chef
cherry
chest
chicken
chief
child
chimney
choice
choose
chronic
chuckle
chunk
churn
cigar
cinnamon
circle
citizen
city
civil
claim
clap
clarify
claw
clay
clean
clerk
clever
click
client
cliff
climb
clinic
clip
clock
clog
close
cloth
cloud
clown
club
clump
cluster
clutch
coach
coast
coconut
code
coffee
coil
coin
collect
color
column
combine
come
comfort
comic
common
company
concert
conduct
confirm
congress
connect
consider
control
convince
cook
cool
copper
copy
coral
core
corn
correct
cost
cotton
couch
country
couple
course
cousin
cover
coyote
crack
cradle
craft
cram
crane
crash
crater
crawl
crazy
cream
credit
creek
crew
cricket
crime
crisp
critic
crop
cross
crouch
crowd
crucial
cruel
cruise
crumble
crunch
crush
cry
crystal
cube
culture
cup
cupboard
curious
current
curtain
curve
cushion
custom
cute
cycle
dad
damage
damp
dance
danger
daring
dash
daughter
dawn
day
deal
debate
debris
decade
december
decide
decline
decorate
decrease
deer
defense
define
defy
degree
delay
deliver
demand
demise
denial
dentist
deny
depart
depend
deposit
depth
deputy
derive
describe
desert
design
desk
despair
destroy
detail
detect
develop
device
devote
diagram
dial
diamond
diary
dice
diesel
diet
differ
digital
dignity
dilemma
dinner
dinosaur
direct
dirt
disagree
discover
disease
dish
dismiss
disorder
display
distance
divert
divide
divorce
dizzy
doctor
document
dog
doll
dolphin
domain
donate
donkey
donor
door
dose
double
dove
draft
dragon
drama
drastic
draw
dream
dress
drift
drill
drink
drip
drive
drop
drum
dry
duck
dumb
dune
during
dust
dutch
duty
dwarf
dynamic
eager
eagle
early
earn
earth
easily
east
easy
echo
ecology
economy
edge
edit
educate
effort
egg
eight
either
elbow
elder
electric
elegant
element
elephant
elevator
elite
else
embark
embody
embrace
emerge
emotion
employ
empower
empty
enable
enact
end
endless
endorse
enemy
energy
enforce
engage
engine
enhance
enjoy
enlist
enough
enrich
enroll
ensure
enter
entire
entry
envelope
episode
equal
equip
era
erase
erode
erosion
error
erupt
escape
essay
essence
estate
eternal
ethics
evidence
evil
evoke
evolve
exact
example
excess
exchange
excite
exclude
excuse
execute
exercise
exhaust
exhibit
exile
exist
exit
exotic
expand
expect
expire
explain
expose
express
extend
extra
eye
eyebrow
fabric
face
faculty
fade
faint
faith
fall
false
fame
family
famous
fan
fancy
fantasy
farm
fashion
fat
fatal
father
fatigue
fault
favorite
feature
february
federal
fee
feed
feel
female
fence
festival
fetch
fever
few
fiber
fiction
field
figure
file
film
filter
final
find
fine
finger
finish
fire
firm
first
fiscal
fish
fit
fitness
fix
flag
flame
flash
flat
flavor
flee
flight
flip
float
flock
floor
flower
fluid
flush
fly
foam
focus
fog
foil
fold
follow
food
foot
force
forest
forget
fork
fortune
forum
forward
fossil
foster
found
fox
fragile
frame
frequent
fresh
friend
fringe
frog
front
frost
frown
frozen
fruit
fuel
fun
funny
furnace
fury
future
gadget
gain
galaxy
gallery
game
gap
garage
garbage
garden
garlic
garment
gas
gasp
gate
gather
gauge
gaze
general
genius
genre
gentle
genuine
gesture
ghost
giant
gift
giggle
ginger
giraffe
girl
give
glad
glance
glare
glass
glide
glimpse
globe
gloom
glory
glove
glow
glue
goat
goddess
gold
good
goose
gorilla
gospel
gossip
govern
gown
grab
grace
grain
grant
grape
grass
gravity
great
green
grid
grief
grit
grocery
group
grow
grunt
guard
guess
guide
guilt
guitar
gun
gym
habit
hair
half
hammer
hamster
hand
happy
harbor
hard
harsh
harvest
hat
have
hawk
hazard
head
health
heart
heavy
hedgehog
height
hello
helmet
help
hen
hero
hidden
high
hill
hint
hip
hire
history
hobby
hockey
hold
hole
holiday
hollow
home
honey
hood
hope
horn
horror
horse
hospital
host
hotel
hour
hover
hub
huge
human
humble
humor
hundred
hungry
hunt
hurdle
hurry
hurt
husband
hybrid
ice
icon
idea
identify
idle
ignore
ill
illegal
illness
image
imitate
immense
immune
impact
impose
improve
impulse
inch
include
income
increase
index
indicate
indoor
industry
infant
inflict
inform
inhale
inherit
initial
inject
injury
inmate
inner
innocent
input
inquiry
insane
insect
inside
inspire
install
intact
interest
into
invest
invite
involve
iron
island
isolate
issue
item
ivory
jacket
jaguar
jar
jazz
jealous
jeans
jelly
jewel
job
join
joke
journey
joy
judge
juice
jump
jungle
junior
junk
just
kangaroo
keen
keep
ketchup
key
kick
kid
kidney
kind
kingdom
kiss
kit
kitchen
kite
kitten
kiwi
knee
knife
knock
know
lab
label
labor
ladder
lady
lake
lamp
language
laptop
large
later
latin
laugh
laundry
lava
law
lawn
lawsuit
layer
lazy
leader
leaf
learn
leave
lecture
left
leg
legal
legend
leisure
lemon
lend
length
lens
leopard
lesson
letter
level
liar
liberty
library
license
life
lift
light
like
limb
limit
link
lion
liquid
list
little
live
lizard
load
loan
lobster
local
lock
logic
lonely
long
loop
lottery
loud
lounge
love
loyal
lucky
luggage
lumber
lunar
lunch
luxury
lyrics
machine
mad
magic
magnet
maid
mail
main
major
make
mammal
man
manage
mandate
mango
mansion
manual
maple
marble
march
margin
marine
market
marriage
mask
mass
master
match
material
math
matrix
matter
maximum
maze
meadow
mean
measure
meat
mechanic
medal
media
melody
melt
member
memory
mention
menu
mercy
merge
merit
merry
mesh
message
metal
method
middle
midnight
milk
million
mimic
mind
minimum
minor
minute
miracle
mirror
misery
miss
mistake
mix
mixed
mixture
mobile
model
modify
mom
moment
monitor
monkey
monster
month
moon
moral
more
morning
mosquito
mother
motion
motor
mountain
mouse
move
movie
much
muffin
mule
multiply
muscle
museum
mushroom
music
must
mutual
myself
mystery
myth
naive
name
napkin
narrow
nasty
nation
nature
near
neck
need
negative
neglect
neither
nephew
nerve
nest
net
network
neutral
never
news
next
nice
night
noble
noise
nominee
noodle
normal
north
nose
notable
note
nothing
notice
novel
now
nuclear
number
nurse
nut
oak
obey
object
oblige
obscure
observe
obtain
obvious
occur
ocean
october
odor
off
offer
office
often
oil
okay
old
olive
olympic
omit
once
one
onion
online
only
open
opera
opinion
oppose
option
orange
orbit
orchard
order
ordinary
organ
orient
original
orphan
ostrich
other
outdoor
outer
output
outside
oval
oven
over
own
owner
oxygen
oyster
ozone
pact
paddle
page
pair
palace
palm
panda
panel
panic
panther
paper
parade
parent
park
parrot
party
pass
patch
path
patient
patrol
pattern
pause
pave
payment
peace
peanut
pear
peasant
pelican
pen
penalty
pencil
people
pepper
perfect
permit
person
pet
phone
photo
phrase
physical
piano
picnic
picture
piece
pig
pigeon
pill
pilot
pink
pioneer
pipe
pistol
pitch
pizza
place
planet
plastic
plate
play
please
pledge
pluck
plug
plunge
poem
poet
point
polar
pole
police
pond
pony
pool
popular
portion
position
possible
post
potato
pottery
poverty
powder
power
practice
praise
predict
prefer
prepare
present
pretty
prevent
price
pride
primary
print
priority
prison
private
prize
problem
process
produce
profit
program
project
promote
proof
property
prosper
protect
proud
provide
public
pudding
pull
pulp
pulse
pumpkin
punch
pupil
puppy
purchase
purity
purpose
purse
push
put
puzzle
pyramid
quality
quantum
quarter
question
quick
quit
quiz
quote
rabbit
raccoon
race
rack
radar
radio
rail
rain
raise
rally
ramp
ranch
random
range
rapid
rare
rate
rather
raven
raw
razor
ready
real
reason
rebel
rebuild
recall
receive
recipe
record
recycle
reduce
reflect
reform
refuse
region
regret
regular
reject
relax
release
relief
rely
remain
remember
remind
remove
render
renew
rent
reopen
repair
repeat
replace
report
require
rescue
resemble
resist
resource
response
result
retire
retreat
return
reunion
reveal
review
reward
rhythm
rib
ribbon
rice
rich
ride
ridge
rifle
right
rigid
ring
riot
ripple
risk
ritual
rival
river
road
roast
robot
robust
rocket
romance
roof
rookie
room
rose
rotate
rough
round
route
royal
rubber
rude
rug
rule
run
runway
rural
sad
saddle
sadness
safe
sail
salad
salmon
salon
salt
salute
same
sample
sand
satisfy
satoshi
sauce
sausage
save
say
scale
scan
scare
scatter
scene
scheme
school
science
scissors
scorpion
scout
scrap
screen
script
scrub
sea
search
season
seat
second
secret
section
security
seed
seek
segment
select
sell
seminar
senior
sense
sentence
series
service
session
settle
setup
seven
shadow
shaft
shallow
share
shed
shell
sheriff
shield
shift
shine
ship
shiver
shock
shoe
shoot
shop
short
shoulder
shove
shrimp
shrug
shuffle
shy
sibling
sick
side
siege
sight
sign
silent
silk
silly
silver
similar
simple
since
sing
siren
sister
situate
six
size
skate
sketch
ski
skill
skin
skirt
skull
slab
slam
sleep
slender
slice
slide
slight
slim
slogan
slot
slow
slush
small
smart
smile
smoke
smooth
snack
snake
snap
sniff
snow
soap
soccer
social
sock
soda
soft
solar
soldier
solid
solution
solve
someone
song
soon
sorry
sort
soul
sound
soup
source
south
space
spare
spatial
spawn
speak
special
speed
spell
spend
sphere
spice
spider
spike
spin
spirit
split
spoil
sponsor
spoon
sport
spot
spray
spread
spring
spy
square
squeeze
squirrel
stable
stadium
staff
stage
stairs
stamp
stand
start
state
stay
steak
steel
stem
step
stereo
stick
still
sting
stock
stomach
stone
stool
story
stove
strategy
street
strike
strong
struggle
student
stuff
stumble
style
subject
submit
subway
success
such
sudden
suffer
sugar
suggest
suit
summer
sun
sunny
sunset
super
supply
supreme
sure
surface
surge
surprise
surround
survey
suspect
sustain
swallow
swamp
swap
swarm
swear
sweet
swift
swim
swing
switch
sword
symbol
symptom
syrup
system
table
tackle
tag
tail
talent
talk
tank
tape
target
task
taste
tattoo
taxi
teach
team
tell
ten
tenant
tennis
tent
term
test
text
thank
that
theme
then
theory
there
they
thing
this
thought
three
thrive
throw
thumb
thunder
ticket
tide
tiger
tilt
timber
time
tiny
tip
tired
tissue
title
toast
tobacco
today
toddler
toe
together
toilet
token
tomato
tomorrow
tone
tongue
tonight
tool
tooth
top
topic
topple
torch
tornado
tortoise
toss
total
tourist
toward
tower
town
toy
track
trade
traffic
tragic
train
transfer
trap
trash
travel
tray
treat
tree
trend
trial
tribe
trick
trigger
trim
trip
trophy
trouble
truck
true
truly
trumpet
trust
truth
try
tube
tuition
tumble
tuna
tunnel
turkey
turn
turtle
twelve
twenty
twice
twin
twist
two
type
typical
ugly
umbrella
unable
unaware
uncle
uncover
under
undo
unfair
unfold
unhappy
uniform
unique
unit
universe
unknown
unlock
until
unusual
unveil
update
upgrade
uphold
upon
upper
upset
urban
urge
usage
use
used
useful
useless
usual
utility
vacant
vacuum
vague
valid
valley
valve
van
vanish
vapor
various
vast
vault
vehicle
velvet
vendor
venture
venue
verb
verify
version
very
vessel
veteran
viable
vibrant
vicious
victory
video
view
village
vintage
violin
virtual
virus
visa
visit
visual
vital
vivid
vocal
voice
void
volcano
volume
vote
voyage
wage
wagon
wait
walk
wall
walnut
want
warfare
warm
warrior
wash
wasp
waste
water
wave
way
wealth
weapon
wear
weasel
weather
web
wedding
weekend
weird
welcome
west
wet
whale
what
wheat
wheel
when
where
whip
whisper
wide
width
wife
wild
will
win
window
wine
wing
wink
winner
winter
wire
wisdom
wise
wish
witness
wolf
woman
wonder
wood
wool
word
work
world
worry
worth
wrap
wreck
wrestle
wrist
write
wrong
yard
year
yellow
you
young
youth
zebra
zero
zone
zoo`.split(`
`),jm="logger/5.7.0";let cd=!1,fd=!1;const ca={debug:1,default:2,info:2,warning:3,error:4,off:5};let ud=ca.default,pf=null;function Km(){try{const r=[];if(["NFD","NFC","NFKD","NFKC"].forEach(t=>{try{if("test".normalize(t)!=="test")throw new Error("bad normalize")}catch{r.push(t)}}),r.length)throw new Error("missing "+r.join(", "));if("é".normalize("NFD")!=="é")throw new Error("broken implementation")}catch(r){return r.message}return null}const ld=Km();var ou;(function(r){r.DEBUG="DEBUG",r.INFO="INFO",r.WARNING="WARNING",r.ERROR="ERROR",r.OFF="OFF"})(ou||(ou={}));var jr;(function(r){r.UNKNOWN_ERROR="UNKNOWN_ERROR",r.NOT_IMPLEMENTED="NOT_IMPLEMENTED",r.UNSUPPORTED_OPERATION="UNSUPPORTED_OPERATION",r.NETWORK_ERROR="NETWORK_ERROR",r.SERVER_ERROR="SERVER_ERROR",r.TIMEOUT="TIMEOUT",r.BUFFER_OVERRUN="BUFFER_OVERRUN",r.NUMERIC_FAULT="NUMERIC_FAULT",r.MISSING_NEW="MISSING_NEW",r.INVALID_ARGUMENT="INVALID_ARGUMENT",r.MISSING_ARGUMENT="MISSING_ARGUMENT",r.UNEXPECTED_ARGUMENT="UNEXPECTED_ARGUMENT",r.CALL_EXCEPTION="CALL_EXCEPTION",r.INSUFFICIENT_FUNDS="INSUFFICIENT_FUNDS",r.NONCE_EXPIRED="NONCE_EXPIRED",r.REPLACEMENT_UNDERPRICED="REPLACEMENT_UNDERPRICED",r.UNPREDICTABLE_GAS_LIMIT="UNPREDICTABLE_GAS_LIMIT",r.TRANSACTION_REPLACED="TRANSACTION_REPLACED",r.ACTION_REJECTED="ACTION_REJECTED"})(jr||(jr={}));const hd="0123456789abcdef";class Le{constructor(t){Object.defineProperty(this,"version",{enumerable:!0,value:t,writable:!1})}_log(t,n){const i=t.toLowerCase();ca[i]==null&&this.throwArgumentError("invalid log level name","logLevel",t),!(ud>ca[i])&&console.log.apply(console,n)}debug(...t){this._log(Le.levels.DEBUG,t)}info(...t){this._log(Le.levels.INFO,t)}warn(...t){this._log(Le.levels.WARNING,t)}makeError(t,n,i){if(fd)return this.makeError("censored error",n,{});n||(n=Le.errors.UNKNOWN_ERROR),i||(i={});const o=[];Object.keys(i).forEach(f=>{const h=i[f];try{if(h instanceof Uint8Array){let d="";for(let g=0;g<h.length;g++)d+=hd[h[g]>>4],d+=hd[h[g]&15];o.push(f+"=Uint8Array(0x"+d+")")}else o.push(f+"="+JSON.stringify(h))}catch{o.push(f+"="+JSON.stringify(i[f].toString()))}}),o.push(`code=${n}`),o.push(`version=${this.version}`);const s=t;let a="";switch(n){case jr.NUMERIC_FAULT:{a="NUMERIC_FAULT";const f=t;switch(f){case"overflow":case"underflow":case"division-by-zero":a+="-"+f;break;case"negative-power":case"negative-width":a+="-unsupported";break;case"unbound-bitwise-result":a+="-unbound-result";break}break}case jr.CALL_EXCEPTION:case jr.INSUFFICIENT_FUNDS:case jr.MISSING_NEW:case jr.NONCE_EXPIRED:case jr.REPLACEMENT_UNDERPRICED:case jr.TRANSACTION_REPLACED:case jr.UNPREDICTABLE_GAS_LIMIT:a=n;break}a&&(t+=" [ See: https://links.ethers.org/v5-errors-"+a+" ]"),o.length&&(t+=" ("+o.join(", ")+")");const c=new Error(t);return c.reason=s,c.code=n,Object.keys(i).forEach(function(f){c[f]=i[f]}),c}throwError(t,n,i){throw this.makeError(t,n,i)}throwArgumentError(t,n,i){return this.throwError(t,Le.errors.INVALID_ARGUMENT,{argument:n,value:i})}assert(t,n,i,o){t||this.throwError(n,i,o)}assertArgument(t,n,i,o){t||this.throwArgumentError(n,i,o)}checkNormalize(t){ld&&this.throwError("platform missing String.prototype.normalize",Le.errors.UNSUPPORTED_OPERATION,{operation:"String.prototype.normalize",form:ld})}checkSafeUint53(t,n){typeof t=="number"&&(n==null&&(n="value not safe"),(t<0||t>=9007199254740991)&&this.throwError(n,Le.errors.NUMERIC_FAULT,{operation:"checkSafeInteger",fault:"out-of-safe-range",value:t}),t%1&&this.throwError(n,Le.errors.NUMERIC_FAULT,{operation:"checkSafeInteger",fault:"non-integer",value:t}))}checkArgumentCount(t,n,i){i?i=": "+i:i="",t<n&&this.throwError("missing argument"+i,Le.errors.MISSING_ARGUMENT,{count:t,expectedCount:n}),t>n&&this.throwError("too many arguments"+i,Le.errors.UNEXPECTED_ARGUMENT,{count:t,expectedCount:n})}checkNew(t,n){(t===Object||t==null)&&this.throwError("missing new",Le.errors.MISSING_NEW,{name:n.name})}checkAbstract(t,n){t===n?this.throwError("cannot instantiate abstract class "+JSON.stringify(n.name)+" directly; use a sub-class",Le.errors.UNSUPPORTED_OPERATION,{name:t.name,operation:"new"}):(t===Object||t==null)&&this.throwError("missing new",Le.errors.MISSING_NEW,{name:n.name})}static globalLogger(){return pf||(pf=new Le(jm)),pf}static setCensorship(t,n){if(!t&&n&&this.globalLogger().throwError("cannot permanently disable censorship",Le.errors.UNSUPPORTED_OPERATION,{operation:"setCensorship"}),cd){if(!t)return;this.globalLogger().throwError("error censorship permanent",Le.errors.UNSUPPORTED_OPERATION,{operation:"setCensorship"})}fd=!!t,cd=!!n}static setLogLevel(t){const n=ca[t.toLowerCase()];if(n==null){Le.globalLogger().warn("invalid log level - "+t);return}ud=n}static from(t){return new Le(t)}}Le.errors=jr;Le.levels=ou;const zm="bytes/5.7.0",Ct=new Le(zm);function Hp(r){return!!r.toHexString}function uo(r){return r.slice||(r.slice=function(){const t=Array.prototype.slice.call(arguments);return uo(new Uint8Array(Array.prototype.slice.apply(r,t)))}),r}function qm(r){return Nr(r)&&!(r.length%2)||rc(r)}function dd(r){return typeof r=="number"&&r==r&&r%1===0}function rc(r){if(r==null)return!1;if(r.constructor===Uint8Array)return!0;if(typeof r=="string"||!dd(r.length)||r.length<0)return!1;for(let t=0;t<r.length;t++){const n=r[t];if(!dd(n)||n<0||n>=256)return!1}return!0}function Ue(r,t){if(t||(t={}),typeof r=="number"){Ct.checkSafeUint53(r,"invalid arrayify value");const n=[];for(;r;)n.unshift(r&255),r=parseInt(String(r/256));return n.length===0&&n.push(0),uo(new Uint8Array(n))}if(t.allowMissingPrefix&&typeof r=="string"&&r.substring(0,2)!=="0x"&&(r="0x"+r),Hp(r)&&(r=r.toHexString()),Nr(r)){let n=r.substring(2);n.length%2&&(t.hexPad==="left"?n="0"+n:t.hexPad==="right"?n+="0":Ct.throwArgumentError("hex data is odd-length","value",r));const i=[];for(let o=0;o<n.length;o+=2)i.push(parseInt(n.substring(o,o+2),16));return uo(new Uint8Array(i))}return rc(r)?uo(new Uint8Array(r)):Ct.throwArgumentError("invalid arrayify value","value",r)}function su(r){const t=r.map(o=>Ue(o)),n=t.reduce((o,s)=>o+s.length,0),i=new Uint8Array(n);return t.reduce((o,s)=>(i.set(s,o),o+s.length),0),uo(i)}function Gm(r,t){r=Ue(r),r.length>t&&Ct.throwArgumentError("value out of range","value",arguments[0]);const n=new Uint8Array(t);return n.set(r,t-r.length),uo(n)}function Nr(r,t){return!(typeof r!="string"||!r.match(/^0x[0-9A-Fa-f]*$/)||t&&r.length!==2+2*t)}const gf="0123456789abcdef";function Ze(r,t){if(t||(t={}),typeof r=="number"){Ct.checkSafeUint53(r,"invalid hexlify value");let n="";for(;r;)n=gf[r&15]+n,r=Math.floor(r/16);return n.length?(n.length%2&&(n="0"+n),"0x"+n):"0x00"}if(typeof r=="bigint")return r=r.toString(16),r.length%2?"0x0"+r:"0x"+r;if(t.allowMissingPrefix&&typeof r=="string"&&r.substring(0,2)!=="0x"&&(r="0x"+r),Hp(r))return r.toHexString();if(Nr(r))return r.length%2&&(t.hexPad==="left"?r="0x0"+r.substring(2):t.hexPad==="right"?r+="0":Ct.throwArgumentError("hex data is odd-length","value",r)),r.toLowerCase();if(rc(r)){let n="0x";for(let i=0;i<r.length;i++){let o=r[i];n+=gf[(o&240)>>4]+gf[o&15]}return n}return Ct.throwArgumentError("invalid hexlify value","value",r)}function Wm(r){if(typeof r!="string")r=Ze(r);else if(!Nr(r)||r.length%2)return null;return(r.length-2)/2}function Sa(r,t,n){return typeof r!="string"?r=Ze(r):(!Nr(r)||r.length%2)&&Ct.throwArgumentError("invalid hexData","value",r),t=2+2*t,n!=null?"0x"+r.substring(t,2+2*n):"0x"+r.substring(t)}function ci(r,t){for(typeof r!="string"?r=Ze(r):Nr(r)||Ct.throwArgumentError("invalid hex string","value",r),r.length>2*t+2&&Ct.throwArgumentError("value out of range","value",arguments[1]);r.length<2*t+2;)r="0x0"+r.substring(2);return r}function Jm(r){const t={r:"0x",s:"0x",_vs:"0x",recoveryParam:0,v:0,yParityAndS:"0x",compact:"0x"};if(qm(r)){let n=Ue(r);n.length===64?(t.v=27+(n[32]>>7),n[32]&=127,t.r=Ze(n.slice(0,32)),t.s=Ze(n.slice(32,64))):n.length===65?(t.r=Ze(n.slice(0,32)),t.s=Ze(n.slice(32,64)),t.v=n[64]):Ct.throwArgumentError("invalid signature string","signature",r),t.v<27&&(t.v===0||t.v===1?t.v+=27:Ct.throwArgumentError("signature invalid v byte","signature",r)),t.recoveryParam=1-t.v%2,t.recoveryParam&&(n[32]|=128),t._vs=Ze(n.slice(32,64))}else{if(t.r=r.r,t.s=r.s,t.v=r.v,t.recoveryParam=r.recoveryParam,t._vs=r._vs,t._vs!=null){const o=Gm(Ue(t._vs),32);t._vs=Ze(o);const s=o[0]>=128?1:0;t.recoveryParam==null?t.recoveryParam=s:t.recoveryParam!==s&&Ct.throwArgumentError("signature recoveryParam mismatch _vs","signature",r),o[0]&=127;const a=Ze(o);t.s==null?t.s=a:t.s!==a&&Ct.throwArgumentError("signature v mismatch _vs","signature",r)}if(t.recoveryParam==null)t.v==null?Ct.throwArgumentError("signature missing v and recoveryParam","signature",r):t.v===0||t.v===1?t.recoveryParam=t.v:t.recoveryParam=1-t.v%2;else if(t.v==null)t.v=27+t.recoveryParam;else{const o=t.v===0||t.v===1?t.v:1-t.v%2;t.recoveryParam!==o&&Ct.throwArgumentError("signature recoveryParam mismatch v","signature",r)}t.r==null||!Nr(t.r)?Ct.throwArgumentError("signature missing or invalid r","signature",r):t.r=ci(t.r,32),t.s==null||!Nr(t.s)?Ct.throwArgumentError("signature missing or invalid s","signature",r):t.s=ci(t.s,32);const n=Ue(t.s);n[0]>=128&&Ct.throwArgumentError("signature s out of range","signature",r),t.recoveryParam&&(n[0]|=128);const i=Ze(n);t._vs&&(Nr(t._vs)||Ct.throwArgumentError("signature invalid _vs","signature",r),t._vs=ci(t._vs,32)),t._vs==null?t._vs=i:t._vs!==i&&Ct.throwArgumentError("signature _vs mismatch v and s","signature",r)}return t.yParityAndS=t._vs,t.compact=t.r+t.yParityAndS.substring(2),t}function Xe(r,t,n){Object.defineProperty(r,t,{enumerable:!0,value:n,writable:!1})}class $p{constructor(t){Xe(this,"alphabet",t),Xe(this,"base",t.length),Xe(this,"_alphabetMap",{}),Xe(this,"_leader",t.charAt(0));for(let n=0;n<t.length;n++)this._alphabetMap[t.charAt(n)]=n}encode(t){let n=Ue(t);if(n.length===0)return"";let i=[0];for(let s=0;s<n.length;++s){let a=n[s];for(let c=0;c<i.length;++c)a+=i[c]<<8,i[c]=a%this.base,a=a/this.base|0;for(;a>0;)i.push(a%this.base),a=a/this.base|0}let o="";for(let s=0;n[s]===0&&s<n.length-1;++s)o+=this._leader;for(let s=i.length-1;s>=0;--s)o+=this.alphabet[i[s]];return o}decode(t){if(typeof t!="string")throw new TypeError("Expected String");let n=[];if(t.length===0)return new Uint8Array(n);n.push(0);for(let i=0;i<t.length;i++){let o=this._alphabetMap[t[i]];if(o===void 0)throw new Error("Non-base"+this.base+" character");let s=o;for(let a=0;a<n.length;++a)s+=n[a]*this.base,n[a]=s&255,s>>=8;for(;s>0;)n.push(s&255),s>>=8}for(let i=0;t[i]===this._leader&&i<t.length-1;++i)n.push(0);return Ue(new Uint8Array(n.reverse()))}}new $p("abcdefghijklmnopqrstuvwxyz234567");const Vp=new $p("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz");var fa={exports:{}},Ym=fa.exports,pd;function Zm(){return pd||(pd=1,function(r){(function(t,n){function i(v,u){if(!v)throw new Error(u||"Assertion failed")}function o(v,u){v.super_=u;var l=function(){};l.prototype=u.prototype,v.prototype=new l,v.prototype.constructor=v}function s(v,u,l){if(s.isBN(v))return v;this.negative=0,this.words=null,this.length=0,this.red=null,v!==null&&((u==="le"||u==="be")&&(l=u,u=10),this._init(v||0,u||10,l||"be"))}typeof t=="object"?t.exports=s:n.BN=s,s.BN=s,s.wordSize=26;var a;try{typeof window<"u"&&typeof window.Buffer<"u"?a=window.Buffer:a=M1.Buffer}catch{}s.isBN=function(u){return u instanceof s?!0:u!==null&&typeof u=="object"&&u.constructor.wordSize===s.wordSize&&Array.isArray(u.words)},s.max=function(u,l){return u.cmp(l)>0?u:l},s.min=function(u,l){return u.cmp(l)<0?u:l},s.prototype._init=function(u,l,p){if(typeof u=="number")return this._initNumber(u,l,p);if(typeof u=="object")return this._initArray(u,l,p);l==="hex"&&(l=16),i(l===(l|0)&&l>=2&&l<=36),u=u.toString().replace(/\s+/g,"");var w=0;u[0]==="-"&&(w++,this.negative=1),w<u.length&&(l===16?this._parseHex(u,w,p):(this._parseBase(u,l,w),p==="le"&&this._initArray(this.toArray(),l,p)))},s.prototype._initNumber=function(u,l,p){u<0&&(this.negative=1,u=-u),u<67108864?(this.words=[u&67108863],this.length=1):u<4503599627370496?(this.words=[u&67108863,u/67108864&67108863],this.length=2):(i(u<9007199254740992),this.words=[u&67108863,u/67108864&67108863,1],this.length=3),p==="le"&&this._initArray(this.toArray(),l,p)},s.prototype._initArray=function(u,l,p){if(i(typeof u.length=="number"),u.length<=0)return this.words=[0],this.length=1,this;this.length=Math.ceil(u.length/3),this.words=new Array(this.length);for(var w=0;w<this.length;w++)this.words[w]=0;var A,C,k=0;if(p==="be")for(w=u.length-1,A=0;w>=0;w-=3)C=u[w]|u[w-1]<<8|u[w-2]<<16,this.words[A]|=C<<k&67108863,this.words[A+1]=C>>>26-k&67108863,k+=24,k>=26&&(k-=26,A++);else if(p==="le")for(w=0,A=0;w<u.length;w+=3)C=u[w]|u[w+1]<<8|u[w+2]<<16,this.words[A]|=C<<k&67108863,this.words[A+1]=C>>>26-k&67108863,k+=24,k>=26&&(k-=26,A++);return this._strip()};function c(v,u){var l=v.charCodeAt(u);if(l>=48&&l<=57)return l-48;if(l>=65&&l<=70)return l-55;if(l>=97&&l<=102)return l-87;i(!1,"Invalid character in "+v)}function f(v,u,l){var p=c(v,l);return l-1>=u&&(p|=c(v,l-1)<<4),p}s.prototype._parseHex=function(u,l,p){this.length=Math.ceil((u.length-l)/6),this.words=new Array(this.length);for(var w=0;w<this.length;w++)this.words[w]=0;var A=0,C=0,k;if(p==="be")for(w=u.length-1;w>=l;w-=2)k=f(u,l,w)<<A,this.words[C]|=k&67108863,A>=18?(A-=18,C+=1,this.words[C]|=k>>>26):A+=8;else{var I=u.length-l;for(w=I%2===0?l+1:l;w<u.length;w+=2)k=f(u,l,w)<<A,this.words[C]|=k&67108863,A>=18?(A-=18,C+=1,this.words[C]|=k>>>26):A+=8}this._strip()};function h(v,u,l,p){for(var w=0,A=0,C=Math.min(v.length,l),k=u;k<C;k++){var I=v.charCodeAt(k)-48;w*=p,I>=49?A=I-49+10:I>=17?A=I-17+10:A=I,i(I>=0&&A<p,"Invalid character"),w+=A}return w}s.prototype._parseBase=function(u,l,p){this.words=[0],this.length=1;for(var w=0,A=1;A<=67108863;A*=l)w++;w--,A=A/l|0;for(var C=u.length-p,k=C%w,I=Math.min(C,C-k)+p,y=0,N=p;N<I;N+=w)y=h(u,N,N+w,l),this.imuln(A),this.words[0]+y<67108864?this.words[0]+=y:this._iaddn(y);if(k!==0){var re=1;for(y=h(u,N,u.length,l),N=0;N<k;N++)re*=l;this.imuln(re),this.words[0]+y<67108864?this.words[0]+=y:this._iaddn(y)}this._strip()},s.prototype.copy=function(u){u.words=new Array(this.length);for(var l=0;l<this.length;l++)u.words[l]=this.words[l];u.length=this.length,u.negative=this.negative,u.red=this.red};function d(v,u){v.words=u.words,v.length=u.length,v.negative=u.negative,v.red=u.red}if(s.prototype._move=function(u){d(u,this)},s.prototype.clone=function(){var u=new s(null);return this.copy(u),u},s.prototype._expand=function(u){for(;this.length<u;)this.words[this.length++]=0;return this},s.prototype._strip=function(){for(;this.length>1&&this.words[this.length-1]===0;)this.length--;return this._normSign()},s.prototype._normSign=function(){return this.length===1&&this.words[0]===0&&(this.negative=0),this},typeof Symbol<"u"&&typeof Symbol.for=="function")try{s.prototype[Symbol.for("nodejs.util.inspect.custom")]=g}catch{s.prototype.inspect=g}else s.prototype.inspect=g;function g(){return(this.red?"<BN-R: ":"<BN: ")+this.toString(16)+">"}var x=["","0","00","000","0000","00000","000000","0000000","00000000","000000000","0000000000","00000000000","000000000000","0000000000000","00000000000000","000000000000000","0000000000000000","00000000000000000","000000000000000000","0000000000000000000","00000000000000000000","000000000000000000000","0000000000000000000000","00000000000000000000000","000000000000000000000000","0000000000000000000000000"],S=[0,0,25,16,12,11,10,9,8,8,7,7,7,7,6,6,6,6,6,6,6,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5],D=[0,0,33554432,43046721,16777216,48828125,60466176,40353607,16777216,43046721,1e7,19487171,35831808,62748517,7529536,11390625,16777216,24137569,34012224,47045881,64e6,4084101,5153632,6436343,7962624,9765625,11881376,14348907,17210368,20511149,243e5,28629151,33554432,39135393,45435424,52521875,60466176];s.prototype.toString=function(u,l){u=u||10,l=l|0||1;var p;if(u===16||u==="hex"){p="";for(var w=0,A=0,C=0;C<this.length;C++){var k=this.words[C],I=((k<<w|A)&16777215).toString(16);A=k>>>24-w&16777215,w+=2,w>=26&&(w-=26,C--),A!==0||C!==this.length-1?p=x[6-I.length]+I+p:p=I+p}for(A!==0&&(p=A.toString(16)+p);p.length%l!==0;)p="0"+p;return this.negative!==0&&(p="-"+p),p}if(u===(u|0)&&u>=2&&u<=36){var y=S[u],N=D[u];p="";var re=this.clone();for(re.negative=0;!re.isZero();){var B=re.modrn(N).toString(u);re=re.idivn(N),re.isZero()?p=B+p:p=x[y-B.length]+B+p}for(this.isZero()&&(p="0"+p);p.length%l!==0;)p="0"+p;return this.negative!==0&&(p="-"+p),p}i(!1,"Base should be between 2 and 36")},s.prototype.toNumber=function(){var u=this.words[0];return this.length===2?u+=this.words[1]*67108864:this.length===3&&this.words[2]===1?u+=4503599627370496+this.words[1]*67108864:this.length>2&&i(!1,"Number can only safely store up to 53 bits"),this.negative!==0?-u:u},s.prototype.toJSON=function(){return this.toString(16,2)},a&&(s.prototype.toBuffer=function(u,l){return this.toArrayLike(a,u,l)}),s.prototype.toArray=function(u,l){return this.toArrayLike(Array,u,l)};var E=function(u,l){return u.allocUnsafe?u.allocUnsafe(l):new u(l)};s.prototype.toArrayLike=function(u,l,p){this._strip();var w=this.byteLength(),A=p||Math.max(1,w);i(w<=A,"byte array longer than desired length"),i(A>0,"Requested array length <= 0");var C=E(u,A),k=l==="le"?"LE":"BE";return this["_toArrayLike"+k](C,w),C},s.prototype._toArrayLikeLE=function(u,l){for(var p=0,w=0,A=0,C=0;A<this.length;A++){var k=this.words[A]<<C|w;u[p++]=k&255,p<u.length&&(u[p++]=k>>8&255),p<u.length&&(u[p++]=k>>16&255),C===6?(p<u.length&&(u[p++]=k>>24&255),w=0,C=0):(w=k>>>24,C+=2)}if(p<u.length)for(u[p++]=w;p<u.length;)u[p++]=0},s.prototype._toArrayLikeBE=function(u,l){for(var p=u.length-1,w=0,A=0,C=0;A<this.length;A++){var k=this.words[A]<<C|w;u[p--]=k&255,p>=0&&(u[p--]=k>>8&255),p>=0&&(u[p--]=k>>16&255),C===6?(p>=0&&(u[p--]=k>>24&255),w=0,C=0):(w=k>>>24,C+=2)}if(p>=0)for(u[p--]=w;p>=0;)u[p--]=0},Math.clz32?s.prototype._countBits=function(u){return 32-Math.clz32(u)}:s.prototype._countBits=function(u){var l=u,p=0;return l>=4096&&(p+=13,l>>>=13),l>=64&&(p+=7,l>>>=7),l>=8&&(p+=4,l>>>=4),l>=2&&(p+=2,l>>>=2),p+l},s.prototype._zeroBits=function(u){if(u===0)return 26;var l=u,p=0;return l&8191||(p+=13,l>>>=13),l&127||(p+=7,l>>>=7),l&15||(p+=4,l>>>=4),l&3||(p+=2,l>>>=2),l&1||p++,p},s.prototype.bitLength=function(){var u=this.words[this.length-1],l=this._countBits(u);return(this.length-1)*26+l};function _(v){for(var u=new Array(v.bitLength()),l=0;l<u.length;l++){var p=l/26|0,w=l%26;u[l]=v.words[p]>>>w&1}return u}s.prototype.zeroBits=function(){if(this.isZero())return 0;for(var u=0,l=0;l<this.length;l++){var p=this._zeroBits(this.words[l]);if(u+=p,p!==26)break}return u},s.prototype.byteLength=function(){return Math.ceil(this.bitLength()/8)},s.prototype.toTwos=function(u){return this.negative!==0?this.abs().inotn(u).iaddn(1):this.clone()},s.prototype.fromTwos=function(u){return this.testn(u-1)?this.notn(u).iaddn(1).ineg():this.clone()},s.prototype.isNeg=function(){return this.negative!==0},s.prototype.neg=function(){return this.clone().ineg()},s.prototype.ineg=function(){return this.isZero()||(this.negative^=1),this},s.prototype.iuor=function(u){for(;this.length<u.length;)this.words[this.length++]=0;for(var l=0;l<u.length;l++)this.words[l]=this.words[l]|u.words[l];return this._strip()},s.prototype.ior=function(u){return i((this.negative|u.negative)===0),this.iuor(u)},s.prototype.or=function(u){return this.length>u.length?this.clone().ior(u):u.clone().ior(this)},s.prototype.uor=function(u){return this.length>u.length?this.clone().iuor(u):u.clone().iuor(this)},s.prototype.iuand=function(u){var l;this.length>u.length?l=u:l=this;for(var p=0;p<l.length;p++)this.words[p]=this.words[p]&u.words[p];return this.length=l.length,this._strip()},s.prototype.iand=function(u){return i((this.negative|u.negative)===0),this.iuand(u)},s.prototype.and=function(u){return this.length>u.length?this.clone().iand(u):u.clone().iand(this)},s.prototype.uand=function(u){return this.length>u.length?this.clone().iuand(u):u.clone().iuand(this)},s.prototype.iuxor=function(u){var l,p;this.length>u.length?(l=this,p=u):(l=u,p=this);for(var w=0;w<p.length;w++)this.words[w]=l.words[w]^p.words[w];if(this!==l)for(;w<l.length;w++)this.words[w]=l.words[w];return this.length=l.length,this._strip()},s.prototype.ixor=function(u){return i((this.negative|u.negative)===0),this.iuxor(u)},s.prototype.xor=function(u){return this.length>u.length?this.clone().ixor(u):u.clone().ixor(this)},s.prototype.uxor=function(u){return this.length>u.length?this.clone().iuxor(u):u.clone().iuxor(this)},s.prototype.inotn=function(u){i(typeof u=="number"&&u>=0);var l=Math.ceil(u/26)|0,p=u%26;this._expand(l),p>0&&l--;for(var w=0;w<l;w++)this.words[w]=~this.words[w]&67108863;return p>0&&(this.words[w]=~this.words[w]&67108863>>26-p),this._strip()},s.prototype.notn=function(u){return this.clone().inotn(u)},s.prototype.setn=function(u,l){i(typeof u=="number"&&u>=0);var p=u/26|0,w=u%26;return this._expand(p+1),l?this.words[p]=this.words[p]|1<<w:this.words[p]=this.words[p]&~(1<<w),this._strip()},s.prototype.iadd=function(u){var l;if(this.negative!==0&&u.negative===0)return this.negative=0,l=this.isub(u),this.negative^=1,this._normSign();if(this.negative===0&&u.negative!==0)return u.negative=0,l=this.isub(u),u.negative=1,l._normSign();var p,w;this.length>u.length?(p=this,w=u):(p=u,w=this);for(var A=0,C=0;C<w.length;C++)l=(p.words[C]|0)+(w.words[C]|0)+A,this.words[C]=l&67108863,A=l>>>26;for(;A!==0&&C<p.length;C++)l=(p.words[C]|0)+A,this.words[C]=l&67108863,A=l>>>26;if(this.length=p.length,A!==0)this.words[this.length]=A,this.length++;else if(p!==this)for(;C<p.length;C++)this.words[C]=p.words[C];return this},s.prototype.add=function(u){var l;return u.negative!==0&&this.negative===0?(u.negative=0,l=this.sub(u),u.negative^=1,l):u.negative===0&&this.negative!==0?(this.negative=0,l=u.sub(this),this.negative=1,l):this.length>u.length?this.clone().iadd(u):u.clone().iadd(this)},s.prototype.isub=function(u){if(u.negative!==0){u.negative=0;var l=this.iadd(u);return u.negative=1,l._normSign()}else if(this.negative!==0)return this.negative=0,this.iadd(u),this.negative=1,this._normSign();var p=this.cmp(u);if(p===0)return this.negative=0,this.length=1,this.words[0]=0,this;var w,A;p>0?(w=this,A=u):(w=u,A=this);for(var C=0,k=0;k<A.length;k++)l=(w.words[k]|0)-(A.words[k]|0)+C,C=l>>26,this.words[k]=l&67108863;for(;C!==0&&k<w.length;k++)l=(w.words[k]|0)+C,C=l>>26,this.words[k]=l&67108863;if(C===0&&k<w.length&&w!==this)for(;k<w.length;k++)this.words[k]=w.words[k];return this.length=Math.max(this.length,k),w!==this&&(this.negative=1),this._strip()},s.prototype.sub=function(u){return this.clone().isub(u)};function T(v,u,l){l.negative=u.negative^v.negative;var p=v.length+u.length|0;l.length=p,p=p-1|0;var w=v.words[0]|0,A=u.words[0]|0,C=w*A,k=C&67108863,I=C/67108864|0;l.words[0]=k;for(var y=1;y<p;y++){for(var N=I>>>26,re=I&67108863,B=Math.min(y,u.length-1),j=Math.max(0,y-v.length+1);j<=B;j++){var Z=y-j|0;w=v.words[Z]|0,A=u.words[j]|0,C=w*A+re,N+=C/67108864|0,re=C&67108863}l.words[y]=re|0,I=N|0}return I!==0?l.words[y]=I|0:l.length--,l._strip()}var F=function(u,l,p){var w=u.words,A=l.words,C=p.words,k=0,I,y,N,re=w[0]|0,B=re&8191,j=re>>>13,Z=w[1]|0,Y=Z&8191,ne=Z>>>13,ue=w[2]|0,ce=ue&8191,ae=ue>>>13,be=w[3]|0,fe=be&8191,ge=be>>>13,jt=w[4]|0,_e=jt&8191,je=jt>>>13,cr=w[5]|0,He=cr&8191,Te=cr>>>13,Qe=w[6]|0,Oe=Qe&8191,Pe=Qe>>>13,vt=w[7]|0,$e=vt&8191,M=vt>>>13,m=w[8]|0,b=m&8191,R=m>>>13,K=w[9]|0,q=K&8191,te=K>>>13,Ee=A[0]|0,ve=Ee&8191,me=Ee>>>13,ze=A[1]|0,ye=ze&8191,et=ze>>>13,xi=A[2]|0,tt=xi&8191,rt=xi>>>13,Ai=A[3]|0,nt=Ai&8191,it=Ai>>>13,Ei=A[4]|0,ot=Ei&8191,st=Ei>>>13,Si=A[5]|0,at=Si&8191,ct=Si>>>13,Bi=A[6]|0,ft=Bi&8191,ut=Bi>>>13,Di=A[7]|0,lt=Di&8191,ht=Di>>>13,Ci=A[8]|0,dt=Ci&8191,pt=Ci>>>13,Ii=A[9]|0,gt=Ii&8191,yt=Ii>>>13;p.negative=u.negative^l.negative,p.length=19,I=Math.imul(B,ve),y=Math.imul(B,me),y=y+Math.imul(j,ve)|0,N=Math.imul(j,me);var Vn=(k+I|0)+((y&8191)<<13)|0;k=(N+(y>>>13)|0)+(Vn>>>26)|0,Vn&=67108863,I=Math.imul(Y,ve),y=Math.imul(Y,me),y=y+Math.imul(ne,ve)|0,N=Math.imul(ne,me),I=I+Math.imul(B,ye)|0,y=y+Math.imul(B,et)|0,y=y+Math.imul(j,ye)|0,N=N+Math.imul(j,et)|0;var jn=(k+I|0)+((y&8191)<<13)|0;k=(N+(y>>>13)|0)+(jn>>>26)|0,jn&=67108863,I=Math.imul(ce,ve),y=Math.imul(ce,me),y=y+Math.imul(ae,ve)|0,N=Math.imul(ae,me),I=I+Math.imul(Y,ye)|0,y=y+Math.imul(Y,et)|0,y=y+Math.imul(ne,ye)|0,N=N+Math.imul(ne,et)|0,I=I+Math.imul(B,tt)|0,y=y+Math.imul(B,rt)|0,y=y+Math.imul(j,tt)|0,N=N+Math.imul(j,rt)|0;var Kn=(k+I|0)+((y&8191)<<13)|0;k=(N+(y>>>13)|0)+(Kn>>>26)|0,Kn&=67108863,I=Math.imul(fe,ve),y=Math.imul(fe,me),y=y+Math.imul(ge,ve)|0,N=Math.imul(ge,me),I=I+Math.imul(ce,ye)|0,y=y+Math.imul(ce,et)|0,y=y+Math.imul(ae,ye)|0,N=N+Math.imul(ae,et)|0,I=I+Math.imul(Y,tt)|0,y=y+Math.imul(Y,rt)|0,y=y+Math.imul(ne,tt)|0,N=N+Math.imul(ne,rt)|0,I=I+Math.imul(B,nt)|0,y=y+Math.imul(B,it)|0,y=y+Math.imul(j,nt)|0,N=N+Math.imul(j,it)|0;var zn=(k+I|0)+((y&8191)<<13)|0;k=(N+(y>>>13)|0)+(zn>>>26)|0,zn&=67108863,I=Math.imul(_e,ve),y=Math.imul(_e,me),y=y+Math.imul(je,ve)|0,N=Math.imul(je,me),I=I+Math.imul(fe,ye)|0,y=y+Math.imul(fe,et)|0,y=y+Math.imul(ge,ye)|0,N=N+Math.imul(ge,et)|0,I=I+Math.imul(ce,tt)|0,y=y+Math.imul(ce,rt)|0,y=y+Math.imul(ae,tt)|0,N=N+Math.imul(ae,rt)|0,I=I+Math.imul(Y,nt)|0,y=y+Math.imul(Y,it)|0,y=y+Math.imul(ne,nt)|0,N=N+Math.imul(ne,it)|0,I=I+Math.imul(B,ot)|0,y=y+Math.imul(B,st)|0,y=y+Math.imul(j,ot)|0,N=N+Math.imul(j,st)|0;var qn=(k+I|0)+((y&8191)<<13)|0;k=(N+(y>>>13)|0)+(qn>>>26)|0,qn&=67108863,I=Math.imul(He,ve),y=Math.imul(He,me),y=y+Math.imul(Te,ve)|0,N=Math.imul(Te,me),I=I+Math.imul(_e,ye)|0,y=y+Math.imul(_e,et)|0,y=y+Math.imul(je,ye)|0,N=N+Math.imul(je,et)|0,I=I+Math.imul(fe,tt)|0,y=y+Math.imul(fe,rt)|0,y=y+Math.imul(ge,tt)|0,N=N+Math.imul(ge,rt)|0,I=I+Math.imul(ce,nt)|0,y=y+Math.imul(ce,it)|0,y=y+Math.imul(ae,nt)|0,N=N+Math.imul(ae,it)|0,I=I+Math.imul(Y,ot)|0,y=y+Math.imul(Y,st)|0,y=y+Math.imul(ne,ot)|0,N=N+Math.imul(ne,st)|0,I=I+Math.imul(B,at)|0,y=y+Math.imul(B,ct)|0,y=y+Math.imul(j,at)|0,N=N+Math.imul(j,ct)|0;var Gc=(k+I|0)+((y&8191)<<13)|0;k=(N+(y>>>13)|0)+(Gc>>>26)|0,Gc&=67108863,I=Math.imul(Oe,ve),y=Math.imul(Oe,me),y=y+Math.imul(Pe,ve)|0,N=Math.imul(Pe,me),I=I+Math.imul(He,ye)|0,y=y+Math.imul(He,et)|0,y=y+Math.imul(Te,ye)|0,N=N+Math.imul(Te,et)|0,I=I+Math.imul(_e,tt)|0,y=y+Math.imul(_e,rt)|0,y=y+Math.imul(je,tt)|0,N=N+Math.imul(je,rt)|0,I=I+Math.imul(fe,nt)|0,y=y+Math.imul(fe,it)|0,y=y+Math.imul(ge,nt)|0,N=N+Math.imul(ge,it)|0,I=I+Math.imul(ce,ot)|0,y=y+Math.imul(ce,st)|0,y=y+Math.imul(ae,ot)|0,N=N+Math.imul(ae,st)|0,I=I+Math.imul(Y,at)|0,y=y+Math.imul(Y,ct)|0,y=y+Math.imul(ne,at)|0,N=N+Math.imul(ne,ct)|0,I=I+Math.imul(B,ft)|0,y=y+Math.imul(B,ut)|0,y=y+Math.imul(j,ft)|0,N=N+Math.imul(j,ut)|0;var Wc=(k+I|0)+((y&8191)<<13)|0;k=(N+(y>>>13)|0)+(Wc>>>26)|0,Wc&=67108863,I=Math.imul($e,ve),y=Math.imul($e,me),y=y+Math.imul(M,ve)|0,N=Math.imul(M,me),I=I+Math.imul(Oe,ye)|0,y=y+Math.imul(Oe,et)|0,y=y+Math.imul(Pe,ye)|0,N=N+Math.imul(Pe,et)|0,I=I+Math.imul(He,tt)|0,y=y+Math.imul(He,rt)|0,y=y+Math.imul(Te,tt)|0,N=N+Math.imul(Te,rt)|0,I=I+Math.imul(_e,nt)|0,y=y+Math.imul(_e,it)|0,y=y+Math.imul(je,nt)|0,N=N+Math.imul(je,it)|0,I=I+Math.imul(fe,ot)|0,y=y+Math.imul(fe,st)|0,y=y+Math.imul(ge,ot)|0,N=N+Math.imul(ge,st)|0,I=I+Math.imul(ce,at)|0,y=y+Math.imul(ce,ct)|0,y=y+Math.imul(ae,at)|0,N=N+Math.imul(ae,ct)|0,I=I+Math.imul(Y,ft)|0,y=y+Math.imul(Y,ut)|0,y=y+Math.imul(ne,ft)|0,N=N+Math.imul(ne,ut)|0,I=I+Math.imul(B,lt)|0,y=y+Math.imul(B,ht)|0,y=y+Math.imul(j,lt)|0,N=N+Math.imul(j,ht)|0;var Jc=(k+I|0)+((y&8191)<<13)|0;k=(N+(y>>>13)|0)+(Jc>>>26)|0,Jc&=67108863,I=Math.imul(b,ve),y=Math.imul(b,me),y=y+Math.imul(R,ve)|0,N=Math.imul(R,me),I=I+Math.imul($e,ye)|0,y=y+Math.imul($e,et)|0,y=y+Math.imul(M,ye)|0,N=N+Math.imul(M,et)|0,I=I+Math.imul(Oe,tt)|0,y=y+Math.imul(Oe,rt)|0,y=y+Math.imul(Pe,tt)|0,N=N+Math.imul(Pe,rt)|0,I=I+Math.imul(He,nt)|0,y=y+Math.imul(He,it)|0,y=y+Math.imul(Te,nt)|0,N=N+Math.imul(Te,it)|0,I=I+Math.imul(_e,ot)|0,y=y+Math.imul(_e,st)|0,y=y+Math.imul(je,ot)|0,N=N+Math.imul(je,st)|0,I=I+Math.imul(fe,at)|0,y=y+Math.imul(fe,ct)|0,y=y+Math.imul(ge,at)|0,N=N+Math.imul(ge,ct)|0,I=I+Math.imul(ce,ft)|0,y=y+Math.imul(ce,ut)|0,y=y+Math.imul(ae,ft)|0,N=N+Math.imul(ae,ut)|0,I=I+Math.imul(Y,lt)|0,y=y+Math.imul(Y,ht)|0,y=y+Math.imul(ne,lt)|0,N=N+Math.imul(ne,ht)|0,I=I+Math.imul(B,dt)|0,y=y+Math.imul(B,pt)|0,y=y+Math.imul(j,dt)|0,N=N+Math.imul(j,pt)|0;var Yc=(k+I|0)+((y&8191)<<13)|0;k=(N+(y>>>13)|0)+(Yc>>>26)|0,Yc&=67108863,I=Math.imul(q,ve),y=Math.imul(q,me),y=y+Math.imul(te,ve)|0,N=Math.imul(te,me),I=I+Math.imul(b,ye)|0,y=y+Math.imul(b,et)|0,y=y+Math.imul(R,ye)|0,N=N+Math.imul(R,et)|0,I=I+Math.imul($e,tt)|0,y=y+Math.imul($e,rt)|0,y=y+Math.imul(M,tt)|0,N=N+Math.imul(M,rt)|0,I=I+Math.imul(Oe,nt)|0,y=y+Math.imul(Oe,it)|0,y=y+Math.imul(Pe,nt)|0,N=N+Math.imul(Pe,it)|0,I=I+Math.imul(He,ot)|0,y=y+Math.imul(He,st)|0,y=y+Math.imul(Te,ot)|0,N=N+Math.imul(Te,st)|0,I=I+Math.imul(_e,at)|0,y=y+Math.imul(_e,ct)|0,y=y+Math.imul(je,at)|0,N=N+Math.imul(je,ct)|0,I=I+Math.imul(fe,ft)|0,y=y+Math.imul(fe,ut)|0,y=y+Math.imul(ge,ft)|0,N=N+Math.imul(ge,ut)|0,I=I+Math.imul(ce,lt)|0,y=y+Math.imul(ce,ht)|0,y=y+Math.imul(ae,lt)|0,N=N+Math.imul(ae,ht)|0,I=I+Math.imul(Y,dt)|0,y=y+Math.imul(Y,pt)|0,y=y+Math.imul(ne,dt)|0,N=N+Math.imul(ne,pt)|0,I=I+Math.imul(B,gt)|0,y=y+Math.imul(B,yt)|0,y=y+Math.imul(j,gt)|0,N=N+Math.imul(j,yt)|0;var Zc=(k+I|0)+((y&8191)<<13)|0;k=(N+(y>>>13)|0)+(Zc>>>26)|0,Zc&=67108863,I=Math.imul(q,ye),y=Math.imul(q,et),y=y+Math.imul(te,ye)|0,N=Math.imul(te,et),I=I+Math.imul(b,tt)|0,y=y+Math.imul(b,rt)|0,y=y+Math.imul(R,tt)|0,N=N+Math.imul(R,rt)|0,I=I+Math.imul($e,nt)|0,y=y+Math.imul($e,it)|0,y=y+Math.imul(M,nt)|0,N=N+Math.imul(M,it)|0,I=I+Math.imul(Oe,ot)|0,y=y+Math.imul(Oe,st)|0,y=y+Math.imul(Pe,ot)|0,N=N+Math.imul(Pe,st)|0,I=I+Math.imul(He,at)|0,y=y+Math.imul(He,ct)|0,y=y+Math.imul(Te,at)|0,N=N+Math.imul(Te,ct)|0,I=I+Math.imul(_e,ft)|0,y=y+Math.imul(_e,ut)|0,y=y+Math.imul(je,ft)|0,N=N+Math.imul(je,ut)|0,I=I+Math.imul(fe,lt)|0,y=y+Math.imul(fe,ht)|0,y=y+Math.imul(ge,lt)|0,N=N+Math.imul(ge,ht)|0,I=I+Math.imul(ce,dt)|0,y=y+Math.imul(ce,pt)|0,y=y+Math.imul(ae,dt)|0,N=N+Math.imul(ae,pt)|0,I=I+Math.imul(Y,gt)|0,y=y+Math.imul(Y,yt)|0,y=y+Math.imul(ne,gt)|0,N=N+Math.imul(ne,yt)|0;var Xc=(k+I|0)+((y&8191)<<13)|0;k=(N+(y>>>13)|0)+(Xc>>>26)|0,Xc&=67108863,I=Math.imul(q,tt),y=Math.imul(q,rt),y=y+Math.imul(te,tt)|0,N=Math.imul(te,rt),I=I+Math.imul(b,nt)|0,y=y+Math.imul(b,it)|0,y=y+Math.imul(R,nt)|0,N=N+Math.imul(R,it)|0,I=I+Math.imul($e,ot)|0,y=y+Math.imul($e,st)|0,y=y+Math.imul(M,ot)|0,N=N+Math.imul(M,st)|0,I=I+Math.imul(Oe,at)|0,y=y+Math.imul(Oe,ct)|0,y=y+Math.imul(Pe,at)|0,N=N+Math.imul(Pe,ct)|0,I=I+Math.imul(He,ft)|0,y=y+Math.imul(He,ut)|0,y=y+Math.imul(Te,ft)|0,N=N+Math.imul(Te,ut)|0,I=I+Math.imul(_e,lt)|0,y=y+Math.imul(_e,ht)|0,y=y+Math.imul(je,lt)|0,N=N+Math.imul(je,ht)|0,I=I+Math.imul(fe,dt)|0,y=y+Math.imul(fe,pt)|0,y=y+Math.imul(ge,dt)|0,N=N+Math.imul(ge,pt)|0,I=I+Math.imul(ce,gt)|0,y=y+Math.imul(ce,yt)|0,y=y+Math.imul(ae,gt)|0,N=N+Math.imul(ae,yt)|0;var Qc=(k+I|0)+((y&8191)<<13)|0;k=(N+(y>>>13)|0)+(Qc>>>26)|0,Qc&=67108863,I=Math.imul(q,nt),y=Math.imul(q,it),y=y+Math.imul(te,nt)|0,N=Math.imul(te,it),I=I+Math.imul(b,ot)|0,y=y+Math.imul(b,st)|0,y=y+Math.imul(R,ot)|0,N=N+Math.imul(R,st)|0,I=I+Math.imul($e,at)|0,y=y+Math.imul($e,ct)|0,y=y+Math.imul(M,at)|0,N=N+Math.imul(M,ct)|0,I=I+Math.imul(Oe,ft)|0,y=y+Math.imul(Oe,ut)|0,y=y+Math.imul(Pe,ft)|0,N=N+Math.imul(Pe,ut)|0,I=I+Math.imul(He,lt)|0,y=y+Math.imul(He,ht)|0,y=y+Math.imul(Te,lt)|0,N=N+Math.imul(Te,ht)|0,I=I+Math.imul(_e,dt)|0,y=y+Math.imul(_e,pt)|0,y=y+Math.imul(je,dt)|0,N=N+Math.imul(je,pt)|0,I=I+Math.imul(fe,gt)|0,y=y+Math.imul(fe,yt)|0,y=y+Math.imul(ge,gt)|0,N=N+Math.imul(ge,yt)|0;var ef=(k+I|0)+((y&8191)<<13)|0;k=(N+(y>>>13)|0)+(ef>>>26)|0,ef&=67108863,I=Math.imul(q,ot),y=Math.imul(q,st),y=y+Math.imul(te,ot)|0,N=Math.imul(te,st),I=I+Math.imul(b,at)|0,y=y+Math.imul(b,ct)|0,y=y+Math.imul(R,at)|0,N=N+Math.imul(R,ct)|0,I=I+Math.imul($e,ft)|0,y=y+Math.imul($e,ut)|0,y=y+Math.imul(M,ft)|0,N=N+Math.imul(M,ut)|0,I=I+Math.imul(Oe,lt)|0,y=y+Math.imul(Oe,ht)|0,y=y+Math.imul(Pe,lt)|0,N=N+Math.imul(Pe,ht)|0,I=I+Math.imul(He,dt)|0,y=y+Math.imul(He,pt)|0,y=y+Math.imul(Te,dt)|0,N=N+Math.imul(Te,pt)|0,I=I+Math.imul(_e,gt)|0,y=y+Math.imul(_e,yt)|0,y=y+Math.imul(je,gt)|0,N=N+Math.imul(je,yt)|0;var tf=(k+I|0)+((y&8191)<<13)|0;k=(N+(y>>>13)|0)+(tf>>>26)|0,tf&=67108863,I=Math.imul(q,at),y=Math.imul(q,ct),y=y+Math.imul(te,at)|0,N=Math.imul(te,ct),I=I+Math.imul(b,ft)|0,y=y+Math.imul(b,ut)|0,y=y+Math.imul(R,ft)|0,N=N+Math.imul(R,ut)|0,I=I+Math.imul($e,lt)|0,y=y+Math.imul($e,ht)|0,y=y+Math.imul(M,lt)|0,N=N+Math.imul(M,ht)|0,I=I+Math.imul(Oe,dt)|0,y=y+Math.imul(Oe,pt)|0,y=y+Math.imul(Pe,dt)|0,N=N+Math.imul(Pe,pt)|0,I=I+Math.imul(He,gt)|0,y=y+Math.imul(He,yt)|0,y=y+Math.imul(Te,gt)|0,N=N+Math.imul(Te,yt)|0;var rf=(k+I|0)+((y&8191)<<13)|0;k=(N+(y>>>13)|0)+(rf>>>26)|0,rf&=67108863,I=Math.imul(q,ft),y=Math.imul(q,ut),y=y+Math.imul(te,ft)|0,N=Math.imul(te,ut),I=I+Math.imul(b,lt)|0,y=y+Math.imul(b,ht)|0,y=y+Math.imul(R,lt)|0,N=N+Math.imul(R,ht)|0,I=I+Math.imul($e,dt)|0,y=y+Math.imul($e,pt)|0,y=y+Math.imul(M,dt)|0,N=N+Math.imul(M,pt)|0,I=I+Math.imul(Oe,gt)|0,y=y+Math.imul(Oe,yt)|0,y=y+Math.imul(Pe,gt)|0,N=N+Math.imul(Pe,yt)|0;var nf=(k+I|0)+((y&8191)<<13)|0;k=(N+(y>>>13)|0)+(nf>>>26)|0,nf&=67108863,I=Math.imul(q,lt),y=Math.imul(q,ht),y=y+Math.imul(te,lt)|0,N=Math.imul(te,ht),I=I+Math.imul(b,dt)|0,y=y+Math.imul(b,pt)|0,y=y+Math.imul(R,dt)|0,N=N+Math.imul(R,pt)|0,I=I+Math.imul($e,gt)|0,y=y+Math.imul($e,yt)|0,y=y+Math.imul(M,gt)|0,N=N+Math.imul(M,yt)|0;var of=(k+I|0)+((y&8191)<<13)|0;k=(N+(y>>>13)|0)+(of>>>26)|0,of&=67108863,I=Math.imul(q,dt),y=Math.imul(q,pt),y=y+Math.imul(te,dt)|0,N=Math.imul(te,pt),I=I+Math.imul(b,gt)|0,y=y+Math.imul(b,yt)|0,y=y+Math.imul(R,gt)|0,N=N+Math.imul(R,yt)|0;var sf=(k+I|0)+((y&8191)<<13)|0;k=(N+(y>>>13)|0)+(sf>>>26)|0,sf&=67108863,I=Math.imul(q,gt),y=Math.imul(q,yt),y=y+Math.imul(te,gt)|0,N=Math.imul(te,yt);var af=(k+I|0)+((y&8191)<<13)|0;return k=(N+(y>>>13)|0)+(af>>>26)|0,af&=67108863,C[0]=Vn,C[1]=jn,C[2]=Kn,C[3]=zn,C[4]=qn,C[5]=Gc,C[6]=Wc,C[7]=Jc,C[8]=Yc,C[9]=Zc,C[10]=Xc,C[11]=Qc,C[12]=ef,C[13]=tf,C[14]=rf,C[15]=nf,C[16]=of,C[17]=sf,C[18]=af,k!==0&&(C[19]=k,p.length++),p};Math.imul||(F=T);function U(v,u,l){l.negative=u.negative^v.negative,l.length=v.length+u.length;for(var p=0,w=0,A=0;A<l.length-1;A++){var C=w;w=0;for(var k=p&67108863,I=Math.min(A,u.length-1),y=Math.max(0,A-v.length+1);y<=I;y++){var N=A-y,re=v.words[N]|0,B=u.words[y]|0,j=re*B,Z=j&67108863;C=C+(j/67108864|0)|0,Z=Z+k|0,k=Z&67108863,C=C+(Z>>>26)|0,w+=C>>>26,C&=67108863}l.words[A]=k,p=C,C=w}return p!==0?l.words[A]=p:l.length--,l._strip()}function z(v,u,l){return U(v,u,l)}s.prototype.mulTo=function(u,l){var p,w=this.length+u.length;return this.length===10&&u.length===10?p=F(this,u,l):w<63?p=T(this,u,l):w<1024?p=U(this,u,l):p=z(this,u,l),p},s.prototype.mul=function(u){var l=new s(null);return l.words=new Array(this.length+u.length),this.mulTo(u,l)},s.prototype.mulf=function(u){var l=new s(null);return l.words=new Array(this.length+u.length),z(this,u,l)},s.prototype.imul=function(u){return this.clone().mulTo(u,this)},s.prototype.imuln=function(u){var l=u<0;l&&(u=-u),i(typeof u=="number"),i(u<67108864);for(var p=0,w=0;w<this.length;w++){var A=(this.words[w]|0)*u,C=(A&67108863)+(p&67108863);p>>=26,p+=A/67108864|0,p+=C>>>26,this.words[w]=C&67108863}return p!==0&&(this.words[w]=p,this.length++),l?this.ineg():this},s.prototype.muln=function(u){return this.clone().imuln(u)},s.prototype.sqr=function(){return this.mul(this)},s.prototype.isqr=function(){return this.imul(this.clone())},s.prototype.pow=function(u){var l=_(u);if(l.length===0)return new s(1);for(var p=this,w=0;w<l.length&&l[w]===0;w++,p=p.sqr());if(++w<l.length)for(var A=p.sqr();w<l.length;w++,A=A.sqr())l[w]!==0&&(p=p.mul(A));return p},s.prototype.iushln=function(u){i(typeof u=="number"&&u>=0);var l=u%26,p=(u-l)/26,w=67108863>>>26-l<<26-l,A;if(l!==0){var C=0;for(A=0;A<this.length;A++){var k=this.words[A]&w,I=(this.words[A]|0)-k<<l;this.words[A]=I|C,C=k>>>26-l}C&&(this.words[A]=C,this.length++)}if(p!==0){for(A=this.length-1;A>=0;A--)this.words[A+p]=this.words[A];for(A=0;A<p;A++)this.words[A]=0;this.length+=p}return this._strip()},s.prototype.ishln=function(u){return i(this.negative===0),this.iushln(u)},s.prototype.iushrn=function(u,l,p){i(typeof u=="number"&&u>=0);var w;l?w=(l-l%26)/26:w=0;var A=u%26,C=Math.min((u-A)/26,this.length),k=67108863^67108863>>>A<<A,I=p;if(w-=C,w=Math.max(0,w),I){for(var y=0;y<C;y++)I.words[y]=this.words[y];I.length=C}if(C!==0)if(this.length>C)for(this.length-=C,y=0;y<this.length;y++)this.words[y]=this.words[y+C];else this.words[0]=0,this.length=1;var N=0;for(y=this.length-1;y>=0&&(N!==0||y>=w);y--){var re=this.words[y]|0;this.words[y]=N<<26-A|re>>>A,N=re&k}return I&&N!==0&&(I.words[I.length++]=N),this.length===0&&(this.words[0]=0,this.length=1),this._strip()},s.prototype.ishrn=function(u,l,p){return i(this.negative===0),this.iushrn(u,l,p)},s.prototype.shln=function(u){return this.clone().ishln(u)},s.prototype.ushln=function(u){return this.clone().iushln(u)},s.prototype.shrn=function(u){return this.clone().ishrn(u)},s.prototype.ushrn=function(u){return this.clone().iushrn(u)},s.prototype.testn=function(u){i(typeof u=="number"&&u>=0);var l=u%26,p=(u-l)/26,w=1<<l;if(this.length<=p)return!1;var A=this.words[p];return!!(A&w)},s.prototype.imaskn=function(u){i(typeof u=="number"&&u>=0);var l=u%26,p=(u-l)/26;if(i(this.negative===0,"imaskn works only with positive numbers"),this.length<=p)return this;if(l!==0&&p++,this.length=Math.min(p,this.length),l!==0){var w=67108863^67108863>>>l<<l;this.words[this.length-1]&=w}return this._strip()},s.prototype.maskn=function(u){return this.clone().imaskn(u)},s.prototype.iaddn=function(u){return i(typeof u=="number"),i(u<67108864),u<0?this.isubn(-u):this.negative!==0?this.length===1&&(this.words[0]|0)<=u?(this.words[0]=u-(this.words[0]|0),this.negative=0,this):(this.negative=0,this.isubn(u),this.negative=1,this):this._iaddn(u)},s.prototype._iaddn=function(u){this.words[0]+=u;for(var l=0;l<this.length&&this.words[l]>=67108864;l++)this.words[l]-=67108864,l===this.length-1?this.words[l+1]=1:this.words[l+1]++;return this.length=Math.max(this.length,l+1),this},s.prototype.isubn=function(u){if(i(typeof u=="number"),i(u<67108864),u<0)return this.iaddn(-u);if(this.negative!==0)return this.negative=0,this.iaddn(u),this.negative=1,this;if(this.words[0]-=u,this.length===1&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var l=0;l<this.length&&this.words[l]<0;l++)this.words[l]+=67108864,this.words[l+1]-=1;return this._strip()},s.prototype.addn=function(u){return this.clone().iaddn(u)},s.prototype.subn=function(u){return this.clone().isubn(u)},s.prototype.iabs=function(){return this.negative=0,this},s.prototype.abs=function(){return this.clone().iabs()},s.prototype._ishlnsubmul=function(u,l,p){var w=u.length+p,A;this._expand(w);var C,k=0;for(A=0;A<u.length;A++){C=(this.words[A+p]|0)+k;var I=(u.words[A]|0)*l;C-=I&67108863,k=(C>>26)-(I/67108864|0),this.words[A+p]=C&67108863}for(;A<this.length-p;A++)C=(this.words[A+p]|0)+k,k=C>>26,this.words[A+p]=C&67108863;if(k===0)return this._strip();for(i(k===-1),k=0,A=0;A<this.length;A++)C=-(this.words[A]|0)+k,k=C>>26,this.words[A]=C&67108863;return this.negative=1,this._strip()},s.prototype._wordDiv=function(u,l){var p=this.length-u.length,w=this.clone(),A=u,C=A.words[A.length-1]|0,k=this._countBits(C);p=26-k,p!==0&&(A=A.ushln(p),w.iushln(p),C=A.words[A.length-1]|0);var I=w.length-A.length,y;if(l!=="mod"){y=new s(null),y.length=I+1,y.words=new Array(y.length);for(var N=0;N<y.length;N++)y.words[N]=0}var re=w.clone()._ishlnsubmul(A,1,I);re.negative===0&&(w=re,y&&(y.words[I]=1));for(var B=I-1;B>=0;B--){var j=(w.words[A.length+B]|0)*67108864+(w.words[A.length+B-1]|0);for(j=Math.min(j/C|0,67108863),w._ishlnsubmul(A,j,B);w.negative!==0;)j--,w.negative=0,w._ishlnsubmul(A,1,B),w.isZero()||(w.negative^=1);y&&(y.words[B]=j)}return y&&y._strip(),w._strip(),l!=="div"&&p!==0&&w.iushrn(p),{div:y||null,mod:w}},s.prototype.divmod=function(u,l,p){if(i(!u.isZero()),this.isZero())return{div:new s(0),mod:new s(0)};var w,A,C;return this.negative!==0&&u.negative===0?(C=this.neg().divmod(u,l),l!=="mod"&&(w=C.div.neg()),l!=="div"&&(A=C.mod.neg(),p&&A.negative!==0&&A.iadd(u)),{div:w,mod:A}):this.negative===0&&u.negative!==0?(C=this.divmod(u.neg(),l),l!=="mod"&&(w=C.div.neg()),{div:w,mod:C.mod}):this.negative&u.negative?(C=this.neg().divmod(u.neg(),l),l!=="div"&&(A=C.mod.neg(),p&&A.negative!==0&&A.isub(u)),{div:C.div,mod:A}):u.length>this.length||this.cmp(u)<0?{div:new s(0),mod:this}:u.length===1?l==="div"?{div:this.divn(u.words[0]),mod:null}:l==="mod"?{div:null,mod:new s(this.modrn(u.words[0]))}:{div:this.divn(u.words[0]),mod:new s(this.modrn(u.words[0]))}:this._wordDiv(u,l)},s.prototype.div=function(u){return this.divmod(u,"div",!1).div},s.prototype.mod=function(u){return this.divmod(u,"mod",!1).mod},s.prototype.umod=function(u){return this.divmod(u,"mod",!0).mod},s.prototype.divRound=function(u){var l=this.divmod(u);if(l.mod.isZero())return l.div;var p=l.div.negative!==0?l.mod.isub(u):l.mod,w=u.ushrn(1),A=u.andln(1),C=p.cmp(w);return C<0||A===1&&C===0?l.div:l.div.negative!==0?l.div.isubn(1):l.div.iaddn(1)},s.prototype.modrn=function(u){var l=u<0;l&&(u=-u),i(u<=67108863);for(var p=(1<<26)%u,w=0,A=this.length-1;A>=0;A--)w=(p*w+(this.words[A]|0))%u;return l?-w:w},s.prototype.modn=function(u){return this.modrn(u)},s.prototype.idivn=function(u){var l=u<0;l&&(u=-u),i(u<=67108863);for(var p=0,w=this.length-1;w>=0;w--){var A=(this.words[w]|0)+p*67108864;this.words[w]=A/u|0,p=A%u}return this._strip(),l?this.ineg():this},s.prototype.divn=function(u){return this.clone().idivn(u)},s.prototype.egcd=function(u){i(u.negative===0),i(!u.isZero());var l=this,p=u.clone();l.negative!==0?l=l.umod(u):l=l.clone();for(var w=new s(1),A=new s(0),C=new s(0),k=new s(1),I=0;l.isEven()&&p.isEven();)l.iushrn(1),p.iushrn(1),++I;for(var y=p.clone(),N=l.clone();!l.isZero();){for(var re=0,B=1;!(l.words[0]&B)&&re<26;++re,B<<=1);if(re>0)for(l.iushrn(re);re-- >0;)(w.isOdd()||A.isOdd())&&(w.iadd(y),A.isub(N)),w.iushrn(1),A.iushrn(1);for(var j=0,Z=1;!(p.words[0]&Z)&&j<26;++j,Z<<=1);if(j>0)for(p.iushrn(j);j-- >0;)(C.isOdd()||k.isOdd())&&(C.iadd(y),k.isub(N)),C.iushrn(1),k.iushrn(1);l.cmp(p)>=0?(l.isub(p),w.isub(C),A.isub(k)):(p.isub(l),C.isub(w),k.isub(A))}return{a:C,b:k,gcd:p.iushln(I)}},s.prototype._invmp=function(u){i(u.negative===0),i(!u.isZero());var l=this,p=u.clone();l.negative!==0?l=l.umod(u):l=l.clone();for(var w=new s(1),A=new s(0),C=p.clone();l.cmpn(1)>0&&p.cmpn(1)>0;){for(var k=0,I=1;!(l.words[0]&I)&&k<26;++k,I<<=1);if(k>0)for(l.iushrn(k);k-- >0;)w.isOdd()&&w.iadd(C),w.iushrn(1);for(var y=0,N=1;!(p.words[0]&N)&&y<26;++y,N<<=1);if(y>0)for(p.iushrn(y);y-- >0;)A.isOdd()&&A.iadd(C),A.iushrn(1);l.cmp(p)>=0?(l.isub(p),w.isub(A)):(p.isub(l),A.isub(w))}var re;return l.cmpn(1)===0?re=w:re=A,re.cmpn(0)<0&&re.iadd(u),re},s.prototype.gcd=function(u){if(this.isZero())return u.abs();if(u.isZero())return this.abs();var l=this.clone(),p=u.clone();l.negative=0,p.negative=0;for(var w=0;l.isEven()&&p.isEven();w++)l.iushrn(1),p.iushrn(1);do{for(;l.isEven();)l.iushrn(1);for(;p.isEven();)p.iushrn(1);var A=l.cmp(p);if(A<0){var C=l;l=p,p=C}else if(A===0||p.cmpn(1)===0)break;l.isub(p)}while(!0);return p.iushln(w)},s.prototype.invm=function(u){return this.egcd(u).a.umod(u)},s.prototype.isEven=function(){return(this.words[0]&1)===0},s.prototype.isOdd=function(){return(this.words[0]&1)===1},s.prototype.andln=function(u){return this.words[0]&u},s.prototype.bincn=function(u){i(typeof u=="number");var l=u%26,p=(u-l)/26,w=1<<l;if(this.length<=p)return this._expand(p+1),this.words[p]|=w,this;for(var A=w,C=p;A!==0&&C<this.length;C++){var k=this.words[C]|0;k+=A,A=k>>>26,k&=67108863,this.words[C]=k}return A!==0&&(this.words[C]=A,this.length++),this},s.prototype.isZero=function(){return this.length===1&&this.words[0]===0},s.prototype.cmpn=function(u){var l=u<0;if(this.negative!==0&&!l)return-1;if(this.negative===0&&l)return 1;this._strip();var p;if(this.length>1)p=1;else{l&&(u=-u),i(u<=67108863,"Number is too big");var w=this.words[0]|0;p=w===u?0:w<u?-1:1}return this.negative!==0?-p|0:p},s.prototype.cmp=function(u){if(this.negative!==0&&u.negative===0)return-1;if(this.negative===0&&u.negative!==0)return 1;var l=this.ucmp(u);return this.negative!==0?-l|0:l},s.prototype.ucmp=function(u){if(this.length>u.length)return 1;if(this.length<u.length)return-1;for(var l=0,p=this.length-1;p>=0;p--){var w=this.words[p]|0,A=u.words[p]|0;if(w!==A){w<A?l=-1:w>A&&(l=1);break}}return l},s.prototype.gtn=function(u){return this.cmpn(u)===1},s.prototype.gt=function(u){return this.cmp(u)===1},s.prototype.gten=function(u){return this.cmpn(u)>=0},s.prototype.gte=function(u){return this.cmp(u)>=0},s.prototype.ltn=function(u){return this.cmpn(u)===-1},s.prototype.lt=function(u){return this.cmp(u)===-1},s.prototype.lten=function(u){return this.cmpn(u)<=0},s.prototype.lte=function(u){return this.cmp(u)<=0},s.prototype.eqn=function(u){return this.cmpn(u)===0},s.prototype.eq=function(u){return this.cmp(u)===0},s.red=function(u){return new oe(u)},s.prototype.toRed=function(u){return i(!this.red,"Already a number in reduction context"),i(this.negative===0,"red works only with positives"),u.convertTo(this)._forceRed(u)},s.prototype.fromRed=function(){return i(this.red,"fromRed works only with numbers in reduction context"),this.red.convertFrom(this)},s.prototype._forceRed=function(u){return this.red=u,this},s.prototype.forceRed=function(u){return i(!this.red,"Already a number in reduction context"),this._forceRed(u)},s.prototype.redAdd=function(u){return i(this.red,"redAdd works only with red numbers"),this.red.add(this,u)},s.prototype.redIAdd=function(u){return i(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,u)},s.prototype.redSub=function(u){return i(this.red,"redSub works only with red numbers"),this.red.sub(this,u)},s.prototype.redISub=function(u){return i(this.red,"redISub works only with red numbers"),this.red.isub(this,u)},s.prototype.redShl=function(u){return i(this.red,"redShl works only with red numbers"),this.red.shl(this,u)},s.prototype.redMul=function(u){return i(this.red,"redMul works only with red numbers"),this.red._verify2(this,u),this.red.mul(this,u)},s.prototype.redIMul=function(u){return i(this.red,"redMul works only with red numbers"),this.red._verify2(this,u),this.red.imul(this,u)},s.prototype.redSqr=function(){return i(this.red,"redSqr works only with red numbers"),this.red._verify1(this),this.red.sqr(this)},s.prototype.redISqr=function(){return i(this.red,"redISqr works only with red numbers"),this.red._verify1(this),this.red.isqr(this)},s.prototype.redSqrt=function(){return i(this.red,"redSqrt works only with red numbers"),this.red._verify1(this),this.red.sqrt(this)},s.prototype.redInvm=function(){return i(this.red,"redInvm works only with red numbers"),this.red._verify1(this),this.red.invm(this)},s.prototype.redNeg=function(){return i(this.red,"redNeg works only with red numbers"),this.red._verify1(this),this.red.neg(this)},s.prototype.redPow=function(u){return i(this.red&&!u.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,u)};var V={k256:null,p224:null,p192:null,p25519:null};function G(v,u){this.name=v,this.p=new s(u,16),this.n=this.p.bitLength(),this.k=new s(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}G.prototype._tmp=function(){var u=new s(null);return u.words=new Array(Math.ceil(this.n/13)),u},G.prototype.ireduce=function(u){var l=u,p;do this.split(l,this.tmp),l=this.imulK(l),l=l.iadd(this.tmp),p=l.bitLength();while(p>this.n);var w=p<this.n?-1:l.ucmp(this.p);return w===0?(l.words[0]=0,l.length=1):w>0?l.isub(this.p):l.strip!==void 0?l.strip():l._strip(),l},G.prototype.split=function(u,l){u.iushrn(this.n,0,l)},G.prototype.imulK=function(u){return u.imul(this.k)};function ee(){G.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}o(ee,G),ee.prototype.split=function(u,l){for(var p=4194303,w=Math.min(u.length,9),A=0;A<w;A++)l.words[A]=u.words[A];if(l.length=w,u.length<=9){u.words[0]=0,u.length=1;return}var C=u.words[9];for(l.words[l.length++]=C&p,A=10;A<u.length;A++){var k=u.words[A]|0;u.words[A-10]=(k&p)<<4|C>>>22,C=k}C>>>=22,u.words[A-10]=C,C===0&&u.length>10?u.length-=10:u.length-=9},ee.prototype.imulK=function(u){u.words[u.length]=0,u.words[u.length+1]=0,u.length+=2;for(var l=0,p=0;p<u.length;p++){var w=u.words[p]|0;l+=w*977,u.words[p]=l&67108863,l=w*64+(l/67108864|0)}return u.words[u.length-1]===0&&(u.length--,u.words[u.length-1]===0&&u.length--),u};function Q(){G.call(this,"p224","ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001")}o(Q,G);function X(){G.call(this,"p192","ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff")}o(X,G);function se(){G.call(this,"25519","7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed")}o(se,G),se.prototype.imulK=function(u){for(var l=0,p=0;p<u.length;p++){var w=(u.words[p]|0)*19+l,A=w&67108863;w>>>=26,u.words[p]=A,l=w}return l!==0&&(u.words[u.length++]=l),u},s._prime=function(u){if(V[u])return V[u];var l;if(u==="k256")l=new ee;else if(u==="p224")l=new Q;else if(u==="p192")l=new X;else if(u==="p25519")l=new se;else throw new Error("Unknown prime "+u);return V[u]=l,l};function oe(v){if(typeof v=="string"){var u=s._prime(v);this.m=u.p,this.prime=u}else i(v.gtn(1),"modulus must be greater than 1"),this.m=v,this.prime=null}oe.prototype._verify1=function(u){i(u.negative===0,"red works only with positives"),i(u.red,"red works only with red numbers")},oe.prototype._verify2=function(u,l){i((u.negative|l.negative)===0,"red works only with positives"),i(u.red&&u.red===l.red,"red works only with red numbers")},oe.prototype.imod=function(u){return this.prime?this.prime.ireduce(u)._forceRed(this):(d(u,u.umod(this.m)._forceRed(this)),u)},oe.prototype.neg=function(u){return u.isZero()?u.clone():this.m.sub(u)._forceRed(this)},oe.prototype.add=function(u,l){this._verify2(u,l);var p=u.add(l);return p.cmp(this.m)>=0&&p.isub(this.m),p._forceRed(this)},oe.prototype.iadd=function(u,l){this._verify2(u,l);var p=u.iadd(l);return p.cmp(this.m)>=0&&p.isub(this.m),p},oe.prototype.sub=function(u,l){this._verify2(u,l);var p=u.sub(l);return p.cmpn(0)<0&&p.iadd(this.m),p._forceRed(this)},oe.prototype.isub=function(u,l){this._verify2(u,l);var p=u.isub(l);return p.cmpn(0)<0&&p.iadd(this.m),p},oe.prototype.shl=function(u,l){return this._verify1(u),this.imod(u.ushln(l))},oe.prototype.imul=function(u,l){return this._verify2(u,l),this.imod(u.imul(l))},oe.prototype.mul=function(u,l){return this._verify2(u,l),this.imod(u.mul(l))},oe.prototype.isqr=function(u){return this.imul(u,u.clone())},oe.prototype.sqr=function(u){return this.mul(u,u)},oe.prototype.sqrt=function(u){if(u.isZero())return u.clone();var l=this.m.andln(3);if(i(l%2===1),l===3){var p=this.m.add(new s(1)).iushrn(2);return this.pow(u,p)}for(var w=this.m.subn(1),A=0;!w.isZero()&&w.andln(1)===0;)A++,w.iushrn(1);i(!w.isZero());var C=new s(1).toRed(this),k=C.redNeg(),I=this.m.subn(1).iushrn(1),y=this.m.bitLength();for(y=new s(2*y*y).toRed(this);this.pow(y,I).cmp(k)!==0;)y.redIAdd(k);for(var N=this.pow(y,w),re=this.pow(u,w.addn(1).iushrn(1)),B=this.pow(u,w),j=A;B.cmp(C)!==0;){for(var Z=B,Y=0;Z.cmp(C)!==0;Y++)Z=Z.redSqr();i(Y<j);var ne=this.pow(N,new s(1).iushln(j-Y-1));re=re.redMul(ne),N=ne.redSqr(),B=B.redMul(N),j=Y}return re},oe.prototype.invm=function(u){var l=u._invmp(this.m);return l.negative!==0?(l.negative=0,this.imod(l).redNeg()):this.imod(l)},oe.prototype.pow=function(u,l){if(l.isZero())return new s(1).toRed(this);if(l.cmpn(1)===0)return u.clone();var p=4,w=new Array(1<<p);w[0]=new s(1).toRed(this),w[1]=u;for(var A=2;A<w.length;A++)w[A]=this.mul(w[A-1],u);var C=w[0],k=0,I=0,y=l.bitLength()%26;for(y===0&&(y=26),A=l.length-1;A>=0;A--){for(var N=l.words[A],re=y-1;re>=0;re--){var B=N>>re&1;if(C!==w[0]&&(C=this.sqr(C)),B===0&&k===0){I=0;continue}k<<=1,k|=B,I++,!(I!==p&&(A!==0||re!==0))&&(C=this.mul(C,w[k]),I=0,k=0)}y=26}return C},oe.prototype.convertTo=function(u){var l=u.umod(this.m);return l===u?l.clone():l},oe.prototype.convertFrom=function(u){var l=u.clone();return l.red=null,l},s.mont=function(u){return new H(u)};function H(v){oe.call(this,v),this.shift=this.m.bitLength(),this.shift%26!==0&&(this.shift+=26-this.shift%26),this.r=new s(1).iushln(this.shift),this.r2=this.imod(this.r.sqr()),this.rinv=this.r._invmp(this.m),this.minv=this.rinv.mul(this.r).isubn(1).div(this.m),this.minv=this.minv.umod(this.r),this.minv=this.r.sub(this.minv)}o(H,oe),H.prototype.convertTo=function(u){return this.imod(u.ushln(this.shift))},H.prototype.convertFrom=function(u){var l=this.imod(u.mul(this.rinv));return l.red=null,l},H.prototype.imul=function(u,l){if(u.isZero()||l.isZero())return u.words[0]=0,u.length=1,u;var p=u.imul(l),w=p.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),A=p.isub(w).iushrn(this.shift),C=A;return A.cmp(this.m)>=0?C=A.isub(this.m):A.cmpn(0)<0&&(C=A.iadd(this.m)),C._forceRed(this)},H.prototype.mul=function(u,l){if(u.isZero()||l.isZero())return new s(0)._forceRed(this);var p=u.mul(l),w=p.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),A=p.isub(w).iushrn(this.shift),C=A;return A.cmp(this.m)>=0?C=A.isub(this.m):A.cmpn(0)<0&&(C=A.iadd(this.m)),C._forceRed(this)},H.prototype.invm=function(u){var l=this.imod(u._invmp(this.m).mul(this.r2));return l._forceRed(this)}})(r,Ym)}(fa)),fa.exports}var Xm=Zm();const Be=tc(Xm),Qm="bignumber/5.7.0";var Ba=Be.BN;const En=new Le(Qm),yf={},eb=9007199254740991;let gd=!1;class rr{constructor(t,n){t!==yf&&En.throwError("cannot call constructor directly; use BigNumber.from",Le.errors.UNSUPPORTED_OPERATION,{operation:"new (BigNumber)"}),this._hex=n,this._isBigNumber=!0,Object.freeze(this)}fromTwos(t){return fr(Ne(this).fromTwos(t))}toTwos(t){return fr(Ne(this).toTwos(t))}abs(){return this._hex[0]==="-"?rr.from(this._hex.substring(1)):this}add(t){return fr(Ne(this).add(Ne(t)))}sub(t){return fr(Ne(this).sub(Ne(t)))}div(t){return rr.from(t).isZero()&&Ir("division-by-zero","div"),fr(Ne(this).div(Ne(t)))}mul(t){return fr(Ne(this).mul(Ne(t)))}mod(t){const n=Ne(t);return n.isNeg()&&Ir("division-by-zero","mod"),fr(Ne(this).umod(n))}pow(t){const n=Ne(t);return n.isNeg()&&Ir("negative-power","pow"),fr(Ne(this).pow(n))}and(t){const n=Ne(t);return(this.isNegative()||n.isNeg())&&Ir("unbound-bitwise-result","and"),fr(Ne(this).and(n))}or(t){const n=Ne(t);return(this.isNegative()||n.isNeg())&&Ir("unbound-bitwise-result","or"),fr(Ne(this).or(n))}xor(t){const n=Ne(t);return(this.isNegative()||n.isNeg())&&Ir("unbound-bitwise-result","xor"),fr(Ne(this).xor(n))}mask(t){return(this.isNegative()||t<0)&&Ir("negative-width","mask"),fr(Ne(this).maskn(t))}shl(t){return(this.isNegative()||t<0)&&Ir("negative-width","shl"),fr(Ne(this).shln(t))}shr(t){return(this.isNegative()||t<0)&&Ir("negative-width","shr"),fr(Ne(this).shrn(t))}eq(t){return Ne(this).eq(Ne(t))}lt(t){return Ne(this).lt(Ne(t))}lte(t){return Ne(this).lte(Ne(t))}gt(t){return Ne(this).gt(Ne(t))}gte(t){return Ne(this).gte(Ne(t))}isNegative(){return this._hex[0]==="-"}isZero(){return Ne(this).isZero()}toNumber(){try{return Ne(this).toNumber()}catch{Ir("overflow","toNumber",this.toString())}return null}toBigInt(){try{return BigInt(this.toString())}catch{}return En.throwError("this platform does not support BigInt",Le.errors.UNSUPPORTED_OPERATION,{value:this.toString()})}toString(){return arguments.length>0&&(arguments[0]===10?gd||(gd=!0,En.warn("BigNumber.toString does not accept any parameters; base-10 is assumed")):arguments[0]===16?En.throwError("BigNumber.toString does not accept any parameters; use bigNumber.toHexString()",Le.errors.UNEXPECTED_ARGUMENT,{}):En.throwError("BigNumber.toString does not accept parameters",Le.errors.UNEXPECTED_ARGUMENT,{})),Ne(this).toString(10)}toHexString(){return this._hex}toJSON(t){return{type:"BigNumber",hex:this.toHexString()}}static from(t){if(t instanceof rr)return t;if(typeof t=="string")return t.match(/^-?0x[0-9a-f]+$/i)?new rr(yf,ss(t)):t.match(/^-?[0-9]+$/)?new rr(yf,ss(new Ba(t))):En.throwArgumentError("invalid BigNumber string","value",t);if(typeof t=="number")return t%1&&Ir("underflow","BigNumber.from",t),(t>=eb||t<=-9007199254740991)&&Ir("overflow","BigNumber.from",t),rr.from(String(t));const n=t;if(typeof n=="bigint")return rr.from(n.toString());if(rc(n))return rr.from(Ze(n));if(n)if(n.toHexString){const i=n.toHexString();if(typeof i=="string")return rr.from(i)}else{let i=n._hex;if(i==null&&n.type==="BigNumber"&&(i=n.hex),typeof i=="string"&&(Nr(i)||i[0]==="-"&&Nr(i.substring(1))))return rr.from(i)}return En.throwArgumentError("invalid BigNumber value","value",t)}static isBigNumber(t){return!!(t&&t._isBigNumber)}}function ss(r){if(typeof r!="string")return ss(r.toString(16));if(r[0]==="-")return r=r.substring(1),r[0]==="-"&&En.throwArgumentError("invalid hex","value",r),r=ss(r),r==="0x00"?r:"-"+r;if(r.substring(0,2)!=="0x"&&(r="0x"+r),r==="0x")return"0x00";for(r.length%2&&(r="0x0"+r.substring(2));r.length>4&&r.substring(0,4)==="0x00";)r="0x"+r.substring(4);return r}function fr(r){return rr.from(ss(r))}function Ne(r){const t=rr.from(r).toHexString();return t[0]==="-"?new Ba("-"+t.substring(3),16):new Ba(t.substring(2),16)}function Ir(r,t,n){const i={fault:r,operation:t};return n!=null&&(i.value=n),En.throwError(r,Le.errors.NUMERIC_FAULT,i)}function tb(r){return new Ba(r,36).toString(16)}const rb="strings/5.7.0",nb=new Le(rb);var bo;(function(r){r.current="",r.NFC="NFC",r.NFD="NFD",r.NFKC="NFKC",r.NFKD="NFKD"})(bo||(bo={}));var yd;(function(r){r.UNEXPECTED_CONTINUE="unexpected continuation byte",r.BAD_PREFIX="bad codepoint prefix",r.OVERRUN="string overrun",r.MISSING_CONTINUE="missing continuation byte",r.OUT_OF_RANGE="out of UTF-8 range",r.UTF16_SURROGATE="UTF-16 surrogate",r.OVERLONG="overlong representation"})(yd||(yd={}));function Da(r,t=bo.current){t!=bo.current&&(nb.checkNormalize(),r=r.normalize(t));let n=[];for(let i=0;i<r.length;i++){const o=r.charCodeAt(i);if(o<128)n.push(o);else if(o<2048)n.push(o>>6|192),n.push(o&63|128);else if((o&64512)==55296){i++;const s=r.charCodeAt(i);if(i>=r.length||(s&64512)!==56320)throw new Error("invalid utf-8 string");const a=65536+((o&1023)<<10)+(s&1023);n.push(a>>18|240),n.push(a>>12&63|128),n.push(a>>6&63|128),n.push(a&63|128)}else n.push(o>>12|224),n.push(o>>6&63|128),n.push(o&63|128)}return Ue(n)}var wf={},Je={},mf,wd;function Bs(){if(wd)return mf;wd=1,mf=r;function r(t,n){if(!t)throw new Error(n||"Assertion failed")}return r.equal=function(n,i,o){if(n!=i)throw new Error(o||"Assertion failed: "+n+" != "+i)},mf}var Gs={exports:{}},md;function ib(){return md||(md=1,typeof Object.create=="function"?Gs.exports=function(t,n){n&&(t.super_=n,t.prototype=Object.create(n.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}))}:Gs.exports=function(t,n){if(n){t.super_=n;var i=function(){};i.prototype=n.prototype,t.prototype=new i,t.prototype.constructor=t}}),Gs.exports}var bd;function yn(){if(bd)return Je;bd=1;var r=Bs(),t=ib();Je.inherits=t;function n(H,v){return(H.charCodeAt(v)&64512)!==55296||v<0||v+1>=H.length?!1:(H.charCodeAt(v+1)&64512)===56320}function i(H,v){if(Array.isArray(H))return H.slice();if(!H)return[];var u=[];if(typeof H=="string")if(v){if(v==="hex")for(H=H.replace(/[^a-z0-9]+/ig,""),H.length%2!==0&&(H="0"+H),p=0;p<H.length;p+=2)u.push(parseInt(H[p]+H[p+1],16))}else for(var l=0,p=0;p<H.length;p++){var w=H.charCodeAt(p);w<128?u[l++]=w:w<2048?(u[l++]=w>>6|192,u[l++]=w&63|128):n(H,p)?(w=65536+((w&1023)<<10)+(H.charCodeAt(++p)&1023),u[l++]=w>>18|240,u[l++]=w>>12&63|128,u[l++]=w>>6&63|128,u[l++]=w&63|128):(u[l++]=w>>12|224,u[l++]=w>>6&63|128,u[l++]=w&63|128)}else for(p=0;p<H.length;p++)u[p]=H[p]|0;return u}Je.toArray=i;function o(H){for(var v="",u=0;u<H.length;u++)v+=c(H[u].toString(16));return v}Je.toHex=o;function s(H){var v=H>>>24|H>>>8&65280|H<<8&16711680|(H&255)<<24;return v>>>0}Je.htonl=s;function a(H,v){for(var u="",l=0;l<H.length;l++){var p=H[l];v==="little"&&(p=s(p)),u+=f(p.toString(16))}return u}Je.toHex32=a;function c(H){return H.length===1?"0"+H:H}Je.zero2=c;function f(H){return H.length===7?"0"+H:H.length===6?"00"+H:H.length===5?"000"+H:H.length===4?"0000"+H:H.length===3?"00000"+H:H.length===2?"000000"+H:H.length===1?"0000000"+H:H}Je.zero8=f;function h(H,v,u,l){var p=u-v;r(p%4===0);for(var w=new Array(p/4),A=0,C=v;A<w.length;A++,C+=4){var k;l==="big"?k=H[C]<<24|H[C+1]<<16|H[C+2]<<8|H[C+3]:k=H[C+3]<<24|H[C+2]<<16|H[C+1]<<8|H[C],w[A]=k>>>0}return w}Je.join32=h;function d(H,v){for(var u=new Array(H.length*4),l=0,p=0;l<H.length;l++,p+=4){var w=H[l];v==="big"?(u[p]=w>>>24,u[p+1]=w>>>16&255,u[p+2]=w>>>8&255,u[p+3]=w&255):(u[p+3]=w>>>24,u[p+2]=w>>>16&255,u[p+1]=w>>>8&255,u[p]=w&255)}return u}Je.split32=d;function g(H,v){return H>>>v|H<<32-v}Je.rotr32=g;function x(H,v){return H<<v|H>>>32-v}Je.rotl32=x;function S(H,v){return H+v>>>0}Je.sum32=S;function D(H,v,u){return H+v+u>>>0}Je.sum32_3=D;function E(H,v,u,l){return H+v+u+l>>>0}Je.sum32_4=E;function _(H,v,u,l,p){return H+v+u+l+p>>>0}Je.sum32_5=_;function T(H,v,u,l){var p=H[v],w=H[v+1],A=l+w>>>0,C=(A<l?1:0)+u+p;H[v]=C>>>0,H[v+1]=A}Je.sum64=T;function F(H,v,u,l){var p=v+l>>>0,w=(p<v?1:0)+H+u;return w>>>0}Je.sum64_hi=F;function U(H,v,u,l){var p=v+l;return p>>>0}Je.sum64_lo=U;function z(H,v,u,l,p,w,A,C){var k=0,I=v;I=I+l>>>0,k+=I<v?1:0,I=I+w>>>0,k+=I<w?1:0,I=I+C>>>0,k+=I<C?1:0;var y=H+u+p+A+k;return y>>>0}Je.sum64_4_hi=z;function V(H,v,u,l,p,w,A,C){var k=v+l+w+C;return k>>>0}Je.sum64_4_lo=V;function G(H,v,u,l,p,w,A,C,k,I){var y=0,N=v;N=N+l>>>0,y+=N<v?1:0,N=N+w>>>0,y+=N<w?1:0,N=N+C>>>0,y+=N<C?1:0,N=N+I>>>0,y+=N<I?1:0;var re=H+u+p+A+k+y;return re>>>0}Je.sum64_5_hi=G;function ee(H,v,u,l,p,w,A,C,k,I){var y=v+l+w+C+I;return y>>>0}Je.sum64_5_lo=ee;function Q(H,v,u){var l=v<<32-u|H>>>u;return l>>>0}Je.rotr64_hi=Q;function X(H,v,u){var l=H<<32-u|v>>>u;return l>>>0}Je.rotr64_lo=X;function se(H,v,u){return H>>>u}Je.shr64_hi=se;function oe(H,v,u){var l=H<<32-u|v>>>u;return l>>>0}return Je.shr64_lo=oe,Je}var bf={},vd;function Ds(){if(vd)return bf;vd=1;var r=yn(),t=Bs();function n(){this.pending=null,this.pendingTotal=0,this.blockSize=this.constructor.blockSize,this.outSize=this.constructor.outSize,this.hmacStrength=this.constructor.hmacStrength,this.padLength=this.constructor.padLength/8,this.endian="big",this._delta8=this.blockSize/8,this._delta32=this.blockSize/32}return bf.BlockHash=n,n.prototype.update=function(o,s){if(o=r.toArray(o,s),this.pending?this.pending=this.pending.concat(o):this.pending=o,this.pendingTotal+=o.length,this.pending.length>=this._delta8){o=this.pending;var a=o.length%this._delta8;this.pending=o.slice(o.length-a,o.length),this.pending.length===0&&(this.pending=null),o=r.join32(o,0,o.length-a,this.endian);for(var c=0;c<o.length;c+=this._delta32)this._update(o,c,c+this._delta32)}return this},n.prototype.digest=function(o){return this.update(this._pad()),t(this.pending===null),this._digest(o)},n.prototype._pad=function(){var o=this.pendingTotal,s=this._delta8,a=s-(o+this.padLength)%s,c=new Array(a+this.padLength);c[0]=128;for(var f=1;f<a;f++)c[f]=0;if(o<<=3,this.endian==="big"){for(var h=8;h<this.padLength;h++)c[f++]=0;c[f++]=0,c[f++]=0,c[f++]=0,c[f++]=0,c[f++]=o>>>24&255,c[f++]=o>>>16&255,c[f++]=o>>>8&255,c[f++]=o&255}else for(c[f++]=o&255,c[f++]=o>>>8&255,c[f++]=o>>>16&255,c[f++]=o>>>24&255,c[f++]=0,c[f++]=0,c[f++]=0,c[f++]=0,h=8;h<this.padLength;h++)c[f++]=0;return c},bf}var _i={},sn={},xd;function jp(){if(xd)return sn;xd=1;var r=yn(),t=r.rotr32;function n(d,g,x,S){if(d===0)return i(g,x,S);if(d===1||d===3)return s(g,x,S);if(d===2)return o(g,x,S)}sn.ft_1=n;function i(d,g,x){return d&g^~d&x}sn.ch32=i;function o(d,g,x){return d&g^d&x^g&x}sn.maj32=o;function s(d,g,x){return d^g^x}sn.p32=s;function a(d){return t(d,2)^t(d,13)^t(d,22)}sn.s0_256=a;function c(d){return t(d,6)^t(d,11)^t(d,25)}sn.s1_256=c;function f(d){return t(d,7)^t(d,18)^d>>>3}sn.g0_256=f;function h(d){return t(d,17)^t(d,19)^d>>>10}return sn.g1_256=h,sn}var vf,Ad;function ob(){if(Ad)return vf;Ad=1;var r=yn(),t=Ds(),n=jp(),i=r.rotl32,o=r.sum32,s=r.sum32_5,a=n.ft_1,c=t.BlockHash,f=[1518500249,1859775393,2400959708,3395469782];function h(){if(!(this instanceof h))return new h;c.call(this),this.h=[1732584193,4023233417,2562383102,271733878,3285377520],this.W=new Array(80)}return r.inherits(h,c),vf=h,h.blockSize=512,h.outSize=160,h.hmacStrength=80,h.padLength=64,h.prototype._update=function(g,x){for(var S=this.W,D=0;D<16;D++)S[D]=g[x+D];for(;D<S.length;D++)S[D]=i(S[D-3]^S[D-8]^S[D-14]^S[D-16],1);var E=this.h[0],_=this.h[1],T=this.h[2],F=this.h[3],U=this.h[4];for(D=0;D<S.length;D++){var z=~~(D/20),V=s(i(E,5),a(z,_,T,F),U,S[D],f[z]);U=F,F=T,T=i(_,30),_=E,E=V}this.h[0]=o(this.h[0],E),this.h[1]=o(this.h[1],_),this.h[2]=o(this.h[2],T),this.h[3]=o(this.h[3],F),this.h[4]=o(this.h[4],U)},h.prototype._digest=function(g){return g==="hex"?r.toHex32(this.h,"big"):r.split32(this.h,"big")},vf}var xf,Ed;function Kp(){if(Ed)return xf;Ed=1;var r=yn(),t=Ds(),n=jp(),i=Bs(),o=r.sum32,s=r.sum32_4,a=r.sum32_5,c=n.ch32,f=n.maj32,h=n.s0_256,d=n.s1_256,g=n.g0_256,x=n.g1_256,S=t.BlockHash,D=[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];function E(){if(!(this instanceof E))return new E;S.call(this),this.h=[1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225],this.k=D,this.W=new Array(64)}return r.inherits(E,S),xf=E,E.blockSize=512,E.outSize=256,E.hmacStrength=192,E.padLength=64,E.prototype._update=function(T,F){for(var U=this.W,z=0;z<16;z++)U[z]=T[F+z];for(;z<U.length;z++)U[z]=s(x(U[z-2]),U[z-7],g(U[z-15]),U[z-16]);var V=this.h[0],G=this.h[1],ee=this.h[2],Q=this.h[3],X=this.h[4],se=this.h[5],oe=this.h[6],H=this.h[7];for(i(this.k.length===U.length),z=0;z<U.length;z++){var v=a(H,d(X),c(X,se,oe),this.k[z],U[z]),u=o(h(V),f(V,G,ee));H=oe,oe=se,se=X,X=o(Q,v),Q=ee,ee=G,G=V,V=o(v,u)}this.h[0]=o(this.h[0],V),this.h[1]=o(this.h[1],G),this.h[2]=o(this.h[2],ee),this.h[3]=o(this.h[3],Q),this.h[4]=o(this.h[4],X),this.h[5]=o(this.h[5],se),this.h[6]=o(this.h[6],oe),this.h[7]=o(this.h[7],H)},E.prototype._digest=function(T){return T==="hex"?r.toHex32(this.h,"big"):r.split32(this.h,"big")},xf}var Af,Sd;function sb(){if(Sd)return Af;Sd=1;var r=yn(),t=Kp();function n(){if(!(this instanceof n))return new n;t.call(this),this.h=[3238371032,914150663,812702999,4144912697,4290775857,1750603025,1694076839,3204075428]}return r.inherits(n,t),Af=n,n.blockSize=512,n.outSize=224,n.hmacStrength=192,n.padLength=64,n.prototype._digest=function(o){return o==="hex"?r.toHex32(this.h.slice(0,7),"big"):r.split32(this.h.slice(0,7),"big")},Af}var Ef,Bd;function zp(){if(Bd)return Ef;Bd=1;var r=yn(),t=Ds(),n=Bs(),i=r.rotr64_hi,o=r.rotr64_lo,s=r.shr64_hi,a=r.shr64_lo,c=r.sum64,f=r.sum64_hi,h=r.sum64_lo,d=r.sum64_4_hi,g=r.sum64_4_lo,x=r.sum64_5_hi,S=r.sum64_5_lo,D=t.BlockHash,E=[1116352408,3609767458,1899447441,602891725,3049323471,3964484399,3921009573,2173295548,961987163,4081628472,1508970993,3053834265,2453635748,2937671579,2870763221,3664609560,3624381080,2734883394,310598401,1164996542,607225278,1323610764,1426881987,3590304994,1925078388,4068182383,2162078206,991336113,2614888103,633803317,3248222580,3479774868,3835390401,2666613458,4022224774,944711139,264347078,2341262773,604807628,2007800933,770255983,1495990901,1249150122,1856431235,1555081692,3175218132,1996064986,2198950837,2554220882,3999719339,2821834349,766784016,2952996808,2566594879,3210313671,3203337956,3336571891,1034457026,3584528711,2466948901,113926993,3758326383,338241895,168717936,666307205,1188179964,773529912,1546045734,1294757372,1522805485,1396182291,2643833823,1695183700,2343527390,1986661051,1014477480,2177026350,1206759142,2456956037,344077627,2730485921,1290863460,2820302411,3158454273,3259730800,3505952657,3345764771,106217008,3516065817,3606008344,3600352804,1432725776,4094571909,1467031594,275423344,851169720,430227734,3100823752,506948616,1363258195,659060556,3750685593,883997877,3785050280,958139571,3318307427,1322822218,3812723403,1537002063,2003034995,1747873779,3602036899,1955562222,1575990012,2024104815,1125592928,2227730452,2716904306,2361852424,442776044,2428436474,593698344,2756734187,3733110249,3204031479,2999351573,3329325298,3815920427,3391569614,3928383900,3515267271,566280711,3940187606,3454069534,4118630271,4000239992,116418474,1914138554,174292421,2731055270,289380356,3203993006,460393269,320620315,685471733,587496836,852142971,1086792851,1017036298,365543100,1126000580,2618297676,1288033470,3409855158,1501505948,4234509866,1607167915,987167468,1816402316,1246189591];function _(){if(!(this instanceof _))return new _;D.call(this),this.h=[1779033703,4089235720,3144134277,2227873595,1013904242,4271175723,2773480762,1595750129,1359893119,2917565137,2600822924,725511199,528734635,4215389547,1541459225,327033209],this.k=E,this.W=new Array(160)}r.inherits(_,D),Ef=_,_.blockSize=1024,_.outSize=512,_.hmacStrength=192,_.padLength=128,_.prototype._prepareBlock=function(u,l){for(var p=this.W,w=0;w<32;w++)p[w]=u[l+w];for(;w<p.length;w+=2){var A=oe(p[w-4],p[w-3]),C=H(p[w-4],p[w-3]),k=p[w-14],I=p[w-13],y=X(p[w-30],p[w-29]),N=se(p[w-30],p[w-29]),re=p[w-32],B=p[w-31];p[w]=d(A,C,k,I,y,N,re,B),p[w+1]=g(A,C,k,I,y,N,re,B)}},_.prototype._update=function(u,l){this._prepareBlock(u,l);var p=this.W,w=this.h[0],A=this.h[1],C=this.h[2],k=this.h[3],I=this.h[4],y=this.h[5],N=this.h[6],re=this.h[7],B=this.h[8],j=this.h[9],Z=this.h[10],Y=this.h[11],ne=this.h[12],ue=this.h[13],ce=this.h[14],ae=this.h[15];n(this.k.length===p.length);for(var be=0;be<p.length;be+=2){var fe=ce,ge=ae,jt=ee(B,j),_e=Q(B,j),je=T(B,j,Z,Y,ne),cr=F(B,j,Z,Y,ne,ue),He=this.k[be],Te=this.k[be+1],Qe=p[be],Oe=p[be+1],Pe=x(fe,ge,jt,_e,je,cr,He,Te,Qe,Oe),vt=S(fe,ge,jt,_e,je,cr,He,Te,Qe,Oe);fe=V(w,A),ge=G(w,A),jt=U(w,A,C,k,I),_e=z(w,A,C,k,I,y);var $e=f(fe,ge,jt,_e),M=h(fe,ge,jt,_e);ce=ne,ae=ue,ne=Z,ue=Y,Z=B,Y=j,B=f(N,re,Pe,vt),j=h(re,re,Pe,vt),N=I,re=y,I=C,y=k,C=w,k=A,w=f(Pe,vt,$e,M),A=h(Pe,vt,$e,M)}c(this.h,0,w,A),c(this.h,2,C,k),c(this.h,4,I,y),c(this.h,6,N,re),c(this.h,8,B,j),c(this.h,10,Z,Y),c(this.h,12,ne,ue),c(this.h,14,ce,ae)},_.prototype._digest=function(u){return u==="hex"?r.toHex32(this.h,"big"):r.split32(this.h,"big")};function T(v,u,l,p,w){var A=v&l^~v&w;return A<0&&(A+=4294967296),A}function F(v,u,l,p,w,A){var C=u&p^~u&A;return C<0&&(C+=4294967296),C}function U(v,u,l,p,w){var A=v&l^v&w^l&w;return A<0&&(A+=4294967296),A}function z(v,u,l,p,w,A){var C=u&p^u&A^p&A;return C<0&&(C+=4294967296),C}function V(v,u){var l=i(v,u,28),p=i(u,v,2),w=i(u,v,7),A=l^p^w;return A<0&&(A+=4294967296),A}function G(v,u){var l=o(v,u,28),p=o(u,v,2),w=o(u,v,7),A=l^p^w;return A<0&&(A+=4294967296),A}function ee(v,u){var l=i(v,u,14),p=i(v,u,18),w=i(u,v,9),A=l^p^w;return A<0&&(A+=4294967296),A}function Q(v,u){var l=o(v,u,14),p=o(v,u,18),w=o(u,v,9),A=l^p^w;return A<0&&(A+=4294967296),A}function X(v,u){var l=i(v,u,1),p=i(v,u,8),w=s(v,u,7),A=l^p^w;return A<0&&(A+=4294967296),A}function se(v,u){var l=o(v,u,1),p=o(v,u,8),w=a(v,u,7),A=l^p^w;return A<0&&(A+=4294967296),A}function oe(v,u){var l=i(v,u,19),p=i(u,v,29),w=s(v,u,6),A=l^p^w;return A<0&&(A+=4294967296),A}function H(v,u){var l=o(v,u,19),p=o(u,v,29),w=a(v,u,6),A=l^p^w;return A<0&&(A+=4294967296),A}return Ef}var Sf,Dd;function ab(){if(Dd)return Sf;Dd=1;var r=yn(),t=zp();function n(){if(!(this instanceof n))return new n;t.call(this),this.h=[3418070365,3238371032,1654270250,914150663,2438529370,812702999,355462360,4144912697,1731405415,4290775857,2394180231,1750603025,3675008525,1694076839,1203062813,3204075428]}return r.inherits(n,t),Sf=n,n.blockSize=1024,n.outSize=384,n.hmacStrength=192,n.padLength=128,n.prototype._digest=function(o){return o==="hex"?r.toHex32(this.h.slice(0,12),"big"):r.split32(this.h.slice(0,12),"big")},Sf}var Cd;function cb(){return Cd||(Cd=1,_i.sha1=ob(),_i.sha224=sb(),_i.sha256=Kp(),_i.sha384=ab(),_i.sha512=zp()),_i}var Bf={},Id;function fb(){if(Id)return Bf;Id=1;var r=yn(),t=Ds(),n=r.rotl32,i=r.sum32,o=r.sum32_3,s=r.sum32_4,a=t.BlockHash;function c(){if(!(this instanceof c))return new c;a.call(this),this.h=[1732584193,4023233417,2562383102,271733878,3285377520],this.endian="little"}r.inherits(c,a),Bf.ripemd160=c,c.blockSize=512,c.outSize=160,c.hmacStrength=192,c.padLength=64,c.prototype._update=function(_,T){for(var F=this.h[0],U=this.h[1],z=this.h[2],V=this.h[3],G=this.h[4],ee=F,Q=U,X=z,se=V,oe=G,H=0;H<80;H++){var v=i(n(s(F,f(H,U,z,V),_[g[H]+T],h(H)),S[H]),G);F=G,G=V,V=n(z,10),z=U,U=v,v=i(n(s(ee,f(79-H,Q,X,se),_[x[H]+T],d(H)),D[H]),oe),ee=oe,oe=se,se=n(X,10),X=Q,Q=v}v=o(this.h[1],z,se),this.h[1]=o(this.h[2],V,oe),this.h[2]=o(this.h[3],G,ee),this.h[3]=o(this.h[4],F,Q),this.h[4]=o(this.h[0],U,X),this.h[0]=v},c.prototype._digest=function(_){return _==="hex"?r.toHex32(this.h,"little"):r.split32(this.h,"little")};function f(E,_,T,F){return E<=15?_^T^F:E<=31?_&T|~_&F:E<=47?(_|~T)^F:E<=63?_&F|T&~F:_^(T|~F)}function h(E){return E<=15?0:E<=31?1518500249:E<=47?1859775393:E<=63?2400959708:2840853838}function d(E){return E<=15?1352829926:E<=31?1548603684:E<=47?1836072691:E<=63?2053994217:0}var g=[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,7,4,13,1,10,6,15,3,12,0,9,5,2,14,11,8,3,10,14,4,9,15,8,1,2,7,0,6,13,11,5,12,1,9,11,10,0,8,12,4,13,3,7,15,14,5,6,2,4,0,5,9,7,12,2,10,14,1,3,8,11,6,15,13],x=[5,14,7,0,9,2,11,4,13,6,15,8,1,10,3,12,6,11,3,7,0,13,5,10,14,15,8,12,4,9,1,2,15,5,1,3,7,14,6,9,11,8,12,2,10,0,4,13,8,6,4,1,3,11,15,0,5,12,2,13,9,7,10,14,12,15,10,4,1,5,8,7,6,2,13,14,0,3,9,11],S=[11,14,15,12,5,8,7,9,11,13,14,15,6,7,9,8,7,6,8,13,11,9,7,15,7,12,15,9,11,7,13,12,11,13,6,7,14,9,13,15,14,8,13,6,5,12,7,5,11,12,14,15,14,15,9,8,9,14,5,6,8,6,5,12,9,15,5,11,6,8,13,12,5,12,13,14,11,8,5,6],D=[8,9,9,11,13,15,15,5,7,7,8,11,14,14,12,6,9,13,15,7,12,8,9,11,7,7,12,7,6,15,13,11,9,7,15,11,8,6,6,14,12,13,5,14,13,13,7,5,15,5,8,11,14,14,6,14,6,9,12,9,12,5,15,8,8,5,12,9,12,5,14,6,8,13,6,5,15,13,11,11];return Bf}var Df,_d;function ub(){if(_d)return Df;_d=1;var r=yn(),t=Bs();function n(i,o,s){if(!(this instanceof n))return new n(i,o,s);this.Hash=i,this.blockSize=i.blockSize/8,this.outSize=i.outSize/8,this.inner=null,this.outer=null,this._init(r.toArray(o,s))}return Df=n,n.prototype._init=function(o){o.length>this.blockSize&&(o=new this.Hash().update(o).digest()),t(o.length<=this.blockSize);for(var s=o.length;s<this.blockSize;s++)o.push(0);for(s=0;s<o.length;s++)o[s]^=54;for(this.inner=new this.Hash().update(o),s=0;s<o.length;s++)o[s]^=106;this.outer=new this.Hash().update(o)},n.prototype.update=function(o,s){return this.inner.update(o,s),this},n.prototype.digest=function(o){return this.outer.update(this.inner.digest()),this.outer.digest(o)},Df}var Md;function lb(){return Md||(Md=1,function(r){var t=r;t.utils=yn(),t.common=Ds(),t.sha=cb(),t.ripemd=fb(),t.hmac=ub(),t.sha1=t.sha.sha1,t.sha256=t.sha.sha256,t.sha224=t.sha.sha224,t.sha384=t.sha.sha384,t.sha512=t.sha.sha512,t.ripemd160=t.ripemd.ripemd160}(wf)),wf}var hb=lb();const vr=tc(hb);var as;(function(r){r.sha256="sha256",r.sha512="sha512"})(as||(as={}));const db="sha2/5.7.0",pb=new Le(db);function gb(r){return"0x"+vr.ripemd160().update(Ue(r)).digest("hex")}function cs(r){return"0x"+vr.sha256().update(Ue(r)).digest("hex")}function Ca(r,t,n){return as[r]||pb.throwError("unsupported algorithm "+r,Le.errors.UNSUPPORTED_OPERATION,{operation:"hmac",algorithm:r}),"0x"+vr.hmac(vr[r],Ue(t)).update(Ue(n)).digest("hex")}function yb(r,t,n,i,o){r=Ue(r),t=Ue(t);let s,a=1;const c=new Uint8Array(i),f=new Uint8Array(t.length+4);f.set(t);let h,d;for(let g=1;g<=a;g++){f[t.length]=g>>24&255,f[t.length+1]=g>>16&255,f[t.length+2]=g>>8&255,f[t.length+3]=g&255;let x=Ue(Ca(o,r,f));s||(s=x.length,d=new Uint8Array(s),a=Math.ceil(i/s),h=i-(a-1)*s),d.set(x);for(let E=1;E<n;E++){x=Ue(Ca(o,r,x));for(let _=0;_<s;_++)d[_]^=x[_]}const S=(g-1)*s,D=g===a?h:s;c.set(Ue(d).slice(0,D),S)}return Ze(c)}function To(r,t,n){return n={path:t,exports:{},require:function(i,o){return wb(i,o??n.path)}},r(n,n.exports),n.exports}function wb(){throw new Error("Dynamic requires are not currently supported by @rollup/plugin-commonjs")}var kl=qp;function qp(r,t){if(!r)throw new Error(t||"Assertion failed")}qp.equal=function(t,n,i){if(t!=n)throw new Error(i||"Assertion failed: "+t+" != "+n)};var Xr=To(function(r,t){var n=t;function i(a,c){if(Array.isArray(a))return a.slice();if(!a)return[];var f=[];if(typeof a!="string"){for(var h=0;h<a.length;h++)f[h]=a[h]|0;return f}if(c==="hex"){a=a.replace(/[^a-z0-9]+/ig,""),a.length%2!==0&&(a="0"+a);for(var h=0;h<a.length;h+=2)f.push(parseInt(a[h]+a[h+1],16))}else for(var h=0;h<a.length;h++){var d=a.charCodeAt(h),g=d>>8,x=d&255;g?f.push(g,x):f.push(x)}return f}n.toArray=i;function o(a){return a.length===1?"0"+a:a}n.zero2=o;function s(a){for(var c="",f=0;f<a.length;f++)c+=o(a[f].toString(16));return c}n.toHex=s,n.encode=function(c,f){return f==="hex"?s(c):c}}),Dr=To(function(r,t){var n=t;n.assert=kl,n.toArray=Xr.toArray,n.zero2=Xr.zero2,n.toHex=Xr.toHex,n.encode=Xr.encode;function i(f,h,d){var g=new Array(Math.max(f.bitLength(),d)+1);g.fill(0);for(var x=1<<h+1,S=f.clone(),D=0;D<g.length;D++){var E,_=S.andln(x-1);S.isOdd()?(_>(x>>1)-1?E=(x>>1)-_:E=_,S.isubn(E)):E=0,g[D]=E,S.iushrn(1)}return g}n.getNAF=i;function o(f,h){var d=[[],[]];f=f.clone(),h=h.clone();for(var g=0,x=0,S;f.cmpn(-g)>0||h.cmpn(-x)>0;){var D=f.andln(3)+g&3,E=h.andln(3)+x&3;D===3&&(D=-1),E===3&&(E=-1);var _;D&1?(S=f.andln(7)+g&7,(S===3||S===5)&&E===2?_=-D:_=D):_=0,d[0].push(_);var T;E&1?(S=h.andln(7)+x&7,(S===3||S===5)&&D===2?T=-E:T=E):T=0,d[1].push(T),2*g===_+1&&(g=1-g),2*x===T+1&&(x=1-x),f.iushrn(1),h.iushrn(1)}return d}n.getJSF=o;function s(f,h,d){var g="_"+h;f.prototype[h]=function(){return this[g]!==void 0?this[g]:this[g]=d.call(this)}}n.cachedProperty=s;function a(f){return typeof f=="string"?n.toArray(f,"hex"):f}n.parseBytes=a;function c(f){return new Be(f,"hex","le")}n.intFromLE=c}),Ia=Dr.getNAF,mb=Dr.getJSF,_a=Dr.assert;function gi(r,t){this.type=r,this.p=new Be(t.p,16),this.red=t.prime?Be.red(t.prime):Be.mont(this.p),this.zero=new Be(0).toRed(this.red),this.one=new Be(1).toRed(this.red),this.two=new Be(2).toRed(this.red),this.n=t.n&&new Be(t.n,16),this.g=t.g&&this.pointFromJSON(t.g,t.gRed),this._wnafT1=new Array(4),this._wnafT2=new Array(4),this._wnafT3=new Array(4),this._wnafT4=new Array(4),this._bitLength=this.n?this.n.bitLength():0;var n=this.n&&this.p.div(this.n);!n||n.cmpn(100)>0?this.redN=null:(this._maxwellTrick=!0,this.redN=this.n.toRed(this.red))}var eo=gi;gi.prototype.point=function(){throw new Error("Not implemented")};gi.prototype.validate=function(){throw new Error("Not implemented")};gi.prototype._fixedNafMul=function(t,n){_a(t.precomputed);var i=t._getDoubles(),o=Ia(n,1,this._bitLength),s=(1<<i.step+1)-(i.step%2===0?2:1);s/=3;var a=[],c,f;for(c=0;c<o.length;c+=i.step){f=0;for(var h=c+i.step-1;h>=c;h--)f=(f<<1)+o[h];a.push(f)}for(var d=this.jpoint(null,null,null),g=this.jpoint(null,null,null),x=s;x>0;x--){for(c=0;c<a.length;c++)f=a[c],f===x?g=g.mixedAdd(i.points[c]):f===-x&&(g=g.mixedAdd(i.points[c].neg()));d=d.add(g)}return d.toP()};gi.prototype._wnafMul=function(t,n){var i=4,o=t._getNAFPoints(i);i=o.wnd;for(var s=o.points,a=Ia(n,i,this._bitLength),c=this.jpoint(null,null,null),f=a.length-1;f>=0;f--){for(var h=0;f>=0&&a[f]===0;f--)h++;if(f>=0&&h++,c=c.dblp(h),f<0)break;var d=a[f];_a(d!==0),t.type==="affine"?d>0?c=c.mixedAdd(s[d-1>>1]):c=c.mixedAdd(s[-d-1>>1].neg()):d>0?c=c.add(s[d-1>>1]):c=c.add(s[-d-1>>1].neg())}return t.type==="affine"?c.toP():c};gi.prototype._wnafMulAdd=function(t,n,i,o,s){var a=this._wnafT1,c=this._wnafT2,f=this._wnafT3,h=0,d,g,x;for(d=0;d<o;d++){x=n[d];var S=x._getNAFPoints(t);a[d]=S.wnd,c[d]=S.points}for(d=o-1;d>=1;d-=2){var D=d-1,E=d;if(a[D]!==1||a[E]!==1){f[D]=Ia(i[D],a[D],this._bitLength),f[E]=Ia(i[E],a[E],this._bitLength),h=Math.max(f[D].length,h),h=Math.max(f[E].length,h);continue}var _=[n[D],null,null,n[E]];n[D].y.cmp(n[E].y)===0?(_[1]=n[D].add(n[E]),_[2]=n[D].toJ().mixedAdd(n[E].neg())):n[D].y.cmp(n[E].y.redNeg())===0?(_[1]=n[D].toJ().mixedAdd(n[E]),_[2]=n[D].add(n[E].neg())):(_[1]=n[D].toJ().mixedAdd(n[E]),_[2]=n[D].toJ().mixedAdd(n[E].neg()));var T=[-3,-1,-5,-7,0,7,5,1,3],F=mb(i[D],i[E]);for(h=Math.max(F[0].length,h),f[D]=new Array(h),f[E]=new Array(h),g=0;g<h;g++){var U=F[0][g]|0,z=F[1][g]|0;f[D][g]=T[(U+1)*3+(z+1)],f[E][g]=0,c[D]=_}}var V=this.jpoint(null,null,null),G=this._wnafT4;for(d=h;d>=0;d--){for(var ee=0;d>=0;){var Q=!0;for(g=0;g<o;g++)G[g]=f[g][d]|0,G[g]!==0&&(Q=!1);if(!Q)break;ee++,d--}if(d>=0&&ee++,V=V.dblp(ee),d<0)break;for(g=0;g<o;g++){var X=G[g];X!==0&&(X>0?x=c[g][X-1>>1]:X<0&&(x=c[g][-X-1>>1].neg()),x.type==="affine"?V=V.mixedAdd(x):V=V.add(x))}}for(d=0;d<o;d++)c[d]=null;return s?V:V.toP()};function Or(r,t){this.curve=r,this.type=t,this.precomputed=null}gi.BasePoint=Or;Or.prototype.eq=function(){throw new Error("Not implemented")};Or.prototype.validate=function(){return this.curve.validate(this)};gi.prototype.decodePoint=function(t,n){t=Dr.toArray(t,n);var i=this.p.byteLength();if((t[0]===4||t[0]===6||t[0]===7)&&t.length-1===2*i){t[0]===6?_a(t[t.length-1]%2===0):t[0]===7&&_a(t[t.length-1]%2===1);var o=this.point(t.slice(1,1+i),t.slice(1+i,1+2*i));return o}else if((t[0]===2||t[0]===3)&&t.length-1===i)return this.pointFromX(t.slice(1,1+i),t[0]===3);throw new Error("Unknown point format")};Or.prototype.encodeCompressed=function(t){return this.encode(t,!0)};Or.prototype._encode=function(t){var n=this.curve.p.byteLength(),i=this.getX().toArray("be",n);return t?[this.getY().isEven()?2:3].concat(i):[4].concat(i,this.getY().toArray("be",n))};Or.prototype.encode=function(t,n){return Dr.encode(this._encode(n),t)};Or.prototype.precompute=function(t){if(this.precomputed)return this;var n={doubles:null,naf:null,beta:null};return n.naf=this._getNAFPoints(8),n.doubles=this._getDoubles(4,t),n.beta=this._getBeta(),this.precomputed=n,this};Or.prototype._hasDoubles=function(t){if(!this.precomputed)return!1;var n=this.precomputed.doubles;return n?n.points.length>=Math.ceil((t.bitLength()+1)/n.step):!1};Or.prototype._getDoubles=function(t,n){if(this.precomputed&&this.precomputed.doubles)return this.precomputed.doubles;for(var i=[this],o=this,s=0;s<n;s+=t){for(var a=0;a<t;a++)o=o.dbl();i.push(o)}return{step:t,points:i}};Or.prototype._getNAFPoints=function(t){if(this.precomputed&&this.precomputed.naf)return this.precomputed.naf;for(var n=[this],i=(1<<t)-1,o=i===1?null:this.dbl(),s=1;s<i;s++)n[s]=n[s-1].add(o);return{wnd:t,points:n}};Or.prototype._getBeta=function(){return null};Or.prototype.dblp=function(t){for(var n=this,i=0;i<t;i++)n=n.dbl();return n};var Tl=To(function(r){typeof Object.create=="function"?r.exports=function(n,i){i&&(n.super_=i,n.prototype=Object.create(i.prototype,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}}))}:r.exports=function(n,i){if(i){n.super_=i;var o=function(){};o.prototype=i.prototype,n.prototype=new o,n.prototype.constructor=n}}}),bb=Dr.assert;function Pr(r){eo.call(this,"short",r),this.a=new Be(r.a,16).toRed(this.red),this.b=new Be(r.b,16).toRed(this.red),this.tinv=this.two.redInvm(),this.zeroA=this.a.fromRed().cmpn(0)===0,this.threeA=this.a.fromRed().sub(this.p).cmpn(-3)===0,this.endo=this._getEndomorphism(r),this._endoWnafT1=new Array(4),this._endoWnafT2=new Array(4)}Tl(Pr,eo);var vb=Pr;Pr.prototype._getEndomorphism=function(t){if(!(!this.zeroA||!this.g||!this.n||this.p.modn(3)!==1)){var n,i;if(t.beta)n=new Be(t.beta,16).toRed(this.red);else{var o=this._getEndoRoots(this.p);n=o[0].cmp(o[1])<0?o[0]:o[1],n=n.toRed(this.red)}if(t.lambda)i=new Be(t.lambda,16);else{var s=this._getEndoRoots(this.n);this.g.mul(s[0]).x.cmp(this.g.x.redMul(n))===0?i=s[0]:(i=s[1],bb(this.g.mul(i).x.cmp(this.g.x.redMul(n))===0))}var a;return t.basis?a=t.basis.map(function(c){return{a:new Be(c.a,16),b:new Be(c.b,16)}}):a=this._getEndoBasis(i),{beta:n,lambda:i,basis:a}}};Pr.prototype._getEndoRoots=function(t){var n=t===this.p?this.red:Be.mont(t),i=new Be(2).toRed(n).redInvm(),o=i.redNeg(),s=new Be(3).toRed(n).redNeg().redSqrt().redMul(i),a=o.redAdd(s).fromRed(),c=o.redSub(s).fromRed();return[a,c]};Pr.prototype._getEndoBasis=function(t){for(var n=this.n.ushrn(Math.floor(this.n.bitLength()/2)),i=t,o=this.n.clone(),s=new Be(1),a=new Be(0),c=new Be(0),f=new Be(1),h,d,g,x,S,D,E,_=0,T,F;i.cmpn(0)!==0;){var U=o.div(i);T=o.sub(U.mul(i)),F=c.sub(U.mul(s));var z=f.sub(U.mul(a));if(!g&&T.cmp(n)<0)h=E.neg(),d=s,g=T.neg(),x=F;else if(g&&++_===2)break;E=T,o=i,i=T,c=s,s=F,f=a,a=z}S=T.neg(),D=F;var V=g.sqr().add(x.sqr()),G=S.sqr().add(D.sqr());return G.cmp(V)>=0&&(S=h,D=d),g.negative&&(g=g.neg(),x=x.neg()),S.negative&&(S=S.neg(),D=D.neg()),[{a:g,b:x},{a:S,b:D}]};Pr.prototype._endoSplit=function(t){var n=this.endo.basis,i=n[0],o=n[1],s=o.b.mul(t).divRound(this.n),a=i.b.neg().mul(t).divRound(this.n),c=s.mul(i.a),f=a.mul(o.a),h=s.mul(i.b),d=a.mul(o.b),g=t.sub(c).sub(f),x=h.add(d).neg();return{k1:g,k2:x}};Pr.prototype.pointFromX=function(t,n){t=new Be(t,16),t.red||(t=t.toRed(this.red));var i=t.redSqr().redMul(t).redIAdd(t.redMul(this.a)).redIAdd(this.b),o=i.redSqrt();if(o.redSqr().redSub(i).cmp(this.zero)!==0)throw new Error("invalid point");var s=o.fromRed().isOdd();return(n&&!s||!n&&s)&&(o=o.redNeg()),this.point(t,o)};Pr.prototype.validate=function(t){if(t.inf)return!0;var n=t.x,i=t.y,o=this.a.redMul(n),s=n.redSqr().redMul(n).redIAdd(o).redIAdd(this.b);return i.redSqr().redISub(s).cmpn(0)===0};Pr.prototype._endoWnafMulAdd=function(t,n,i){for(var o=this._endoWnafT1,s=this._endoWnafT2,a=0;a<t.length;a++){var c=this._endoSplit(n[a]),f=t[a],h=f._getBeta();c.k1.negative&&(c.k1.ineg(),f=f.neg(!0)),c.k2.negative&&(c.k2.ineg(),h=h.neg(!0)),o[a*2]=f,o[a*2+1]=h,s[a*2]=c.k1,s[a*2+1]=c.k2}for(var d=this._wnafMulAdd(1,o,s,a*2,i),g=0;g<a*2;g++)o[g]=null,s[g]=null;return d};function Vt(r,t,n,i){eo.BasePoint.call(this,r,"affine"),t===null&&n===null?(this.x=null,this.y=null,this.inf=!0):(this.x=new Be(t,16),this.y=new Be(n,16),i&&(this.x.forceRed(this.curve.red),this.y.forceRed(this.curve.red)),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.y.red||(this.y=this.y.toRed(this.curve.red)),this.inf=!1)}Tl(Vt,eo.BasePoint);Pr.prototype.point=function(t,n,i){return new Vt(this,t,n,i)};Pr.prototype.pointFromJSON=function(t,n){return Vt.fromJSON(this,t,n)};Vt.prototype._getBeta=function(){if(this.curve.endo){var t=this.precomputed;if(t&&t.beta)return t.beta;var n=this.curve.point(this.x.redMul(this.curve.endo.beta),this.y);if(t){var i=this.curve,o=function(s){return i.point(s.x.redMul(i.endo.beta),s.y)};t.beta=n,n.precomputed={beta:null,naf:t.naf&&{wnd:t.naf.wnd,points:t.naf.points.map(o)},doubles:t.doubles&&{step:t.doubles.step,points:t.doubles.points.map(o)}}}return n}};Vt.prototype.toJSON=function(){return this.precomputed?[this.x,this.y,this.precomputed&&{doubles:this.precomputed.doubles&&{step:this.precomputed.doubles.step,points:this.precomputed.doubles.points.slice(1)},naf:this.precomputed.naf&&{wnd:this.precomputed.naf.wnd,points:this.precomputed.naf.points.slice(1)}}]:[this.x,this.y]};Vt.fromJSON=function(t,n,i){typeof n=="string"&&(n=JSON.parse(n));var o=t.point(n[0],n[1],i);if(!n[2])return o;function s(c){return t.point(c[0],c[1],i)}var a=n[2];return o.precomputed={beta:null,doubles:a.doubles&&{step:a.doubles.step,points:[o].concat(a.doubles.points.map(s))},naf:a.naf&&{wnd:a.naf.wnd,points:[o].concat(a.naf.points.map(s))}},o};Vt.prototype.inspect=function(){return this.isInfinity()?"<EC Point Infinity>":"<EC Point x: "+this.x.fromRed().toString(16,2)+" y: "+this.y.fromRed().toString(16,2)+">"};Vt.prototype.isInfinity=function(){return this.inf};Vt.prototype.add=function(t){if(this.inf)return t;if(t.inf)return this;if(this.eq(t))return this.dbl();if(this.neg().eq(t))return this.curve.point(null,null);if(this.x.cmp(t.x)===0)return this.curve.point(null,null);var n=this.y.redSub(t.y);n.cmpn(0)!==0&&(n=n.redMul(this.x.redSub(t.x).redInvm()));var i=n.redSqr().redISub(this.x).redISub(t.x),o=n.redMul(this.x.redSub(i)).redISub(this.y);return this.curve.point(i,o)};Vt.prototype.dbl=function(){if(this.inf)return this;var t=this.y.redAdd(this.y);if(t.cmpn(0)===0)return this.curve.point(null,null);var n=this.curve.a,i=this.x.redSqr(),o=t.redInvm(),s=i.redAdd(i).redIAdd(i).redIAdd(n).redMul(o),a=s.redSqr().redISub(this.x.redAdd(this.x)),c=s.redMul(this.x.redSub(a)).redISub(this.y);return this.curve.point(a,c)};Vt.prototype.getX=function(){return this.x.fromRed()};Vt.prototype.getY=function(){return this.y.fromRed()};Vt.prototype.mul=function(t){return t=new Be(t,16),this.isInfinity()?this:this._hasDoubles(t)?this.curve._fixedNafMul(this,t):this.curve.endo?this.curve._endoWnafMulAdd([this],[t]):this.curve._wnafMul(this,t)};Vt.prototype.mulAdd=function(t,n,i){var o=[this,n],s=[t,i];return this.curve.endo?this.curve._endoWnafMulAdd(o,s):this.curve._wnafMulAdd(1,o,s,2)};Vt.prototype.jmulAdd=function(t,n,i){var o=[this,n],s=[t,i];return this.curve.endo?this.curve._endoWnafMulAdd(o,s,!0):this.curve._wnafMulAdd(1,o,s,2,!0)};Vt.prototype.eq=function(t){return this===t||this.inf===t.inf&&(this.inf||this.x.cmp(t.x)===0&&this.y.cmp(t.y)===0)};Vt.prototype.neg=function(t){if(this.inf)return this;var n=this.curve.point(this.x,this.y.redNeg());if(t&&this.precomputed){var i=this.precomputed,o=function(s){return s.neg()};n.precomputed={naf:i.naf&&{wnd:i.naf.wnd,points:i.naf.points.map(o)},doubles:i.doubles&&{step:i.doubles.step,points:i.doubles.points.map(o)}}}return n};Vt.prototype.toJ=function(){if(this.inf)return this.curve.jpoint(null,null,null);var t=this.curve.jpoint(this.x,this.y,this.curve.one);return t};function qt(r,t,n,i){eo.BasePoint.call(this,r,"jacobian"),t===null&&n===null&&i===null?(this.x=this.curve.one,this.y=this.curve.one,this.z=new Be(0)):(this.x=new Be(t,16),this.y=new Be(n,16),this.z=new Be(i,16)),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.y.red||(this.y=this.y.toRed(this.curve.red)),this.z.red||(this.z=this.z.toRed(this.curve.red)),this.zOne=this.z===this.curve.one}Tl(qt,eo.BasePoint);Pr.prototype.jpoint=function(t,n,i){return new qt(this,t,n,i)};qt.prototype.toP=function(){if(this.isInfinity())return this.curve.point(null,null);var t=this.z.redInvm(),n=t.redSqr(),i=this.x.redMul(n),o=this.y.redMul(n).redMul(t);return this.curve.point(i,o)};qt.prototype.neg=function(){return this.curve.jpoint(this.x,this.y.redNeg(),this.z)};qt.prototype.add=function(t){if(this.isInfinity())return t;if(t.isInfinity())return this;var n=t.z.redSqr(),i=this.z.redSqr(),o=this.x.redMul(n),s=t.x.redMul(i),a=this.y.redMul(n.redMul(t.z)),c=t.y.redMul(i.redMul(this.z)),f=o.redSub(s),h=a.redSub(c);if(f.cmpn(0)===0)return h.cmpn(0)!==0?this.curve.jpoint(null,null,null):this.dbl();var d=f.redSqr(),g=d.redMul(f),x=o.redMul(d),S=h.redSqr().redIAdd(g).redISub(x).redISub(x),D=h.redMul(x.redISub(S)).redISub(a.redMul(g)),E=this.z.redMul(t.z).redMul(f);return this.curve.jpoint(S,D,E)};qt.prototype.mixedAdd=function(t){if(this.isInfinity())return t.toJ();if(t.isInfinity())return this;var n=this.z.redSqr(),i=this.x,o=t.x.redMul(n),s=this.y,a=t.y.redMul(n).redMul(this.z),c=i.redSub(o),f=s.redSub(a);if(c.cmpn(0)===0)return f.cmpn(0)!==0?this.curve.jpoint(null,null,null):this.dbl();var h=c.redSqr(),d=h.redMul(c),g=i.redMul(h),x=f.redSqr().redIAdd(d).redISub(g).redISub(g),S=f.redMul(g.redISub(x)).redISub(s.redMul(d)),D=this.z.redMul(c);return this.curve.jpoint(x,S,D)};qt.prototype.dblp=function(t){if(t===0)return this;if(this.isInfinity())return this;if(!t)return this.dbl();var n;if(this.curve.zeroA||this.curve.threeA){var i=this;for(n=0;n<t;n++)i=i.dbl();return i}var o=this.curve.a,s=this.curve.tinv,a=this.x,c=this.y,f=this.z,h=f.redSqr().redSqr(),d=c.redAdd(c);for(n=0;n<t;n++){var g=a.redSqr(),x=d.redSqr(),S=x.redSqr(),D=g.redAdd(g).redIAdd(g).redIAdd(o.redMul(h)),E=a.redMul(x),_=D.redSqr().redISub(E.redAdd(E)),T=E.redISub(_),F=D.redMul(T);F=F.redIAdd(F).redISub(S);var U=d.redMul(f);n+1<t&&(h=h.redMul(S)),a=_,f=U,d=F}return this.curve.jpoint(a,d.redMul(s),f)};qt.prototype.dbl=function(){return this.isInfinity()?this:this.curve.zeroA?this._zeroDbl():this.curve.threeA?this._threeDbl():this._dbl()};qt.prototype._zeroDbl=function(){var t,n,i;if(this.zOne){var o=this.x.redSqr(),s=this.y.redSqr(),a=s.redSqr(),c=this.x.redAdd(s).redSqr().redISub(o).redISub(a);c=c.redIAdd(c);var f=o.redAdd(o).redIAdd(o),h=f.redSqr().redISub(c).redISub(c),d=a.redIAdd(a);d=d.redIAdd(d),d=d.redIAdd(d),t=h,n=f.redMul(c.redISub(h)).redISub(d),i=this.y.redAdd(this.y)}else{var g=this.x.redSqr(),x=this.y.redSqr(),S=x.redSqr(),D=this.x.redAdd(x).redSqr().redISub(g).redISub(S);D=D.redIAdd(D);var E=g.redAdd(g).redIAdd(g),_=E.redSqr(),T=S.redIAdd(S);T=T.redIAdd(T),T=T.redIAdd(T),t=_.redISub(D).redISub(D),n=E.redMul(D.redISub(t)).redISub(T),i=this.y.redMul(this.z),i=i.redIAdd(i)}return this.curve.jpoint(t,n,i)};qt.prototype._threeDbl=function(){var t,n,i;if(this.zOne){var o=this.x.redSqr(),s=this.y.redSqr(),a=s.redSqr(),c=this.x.redAdd(s).redSqr().redISub(o).redISub(a);c=c.redIAdd(c);var f=o.redAdd(o).redIAdd(o).redIAdd(this.curve.a),h=f.redSqr().redISub(c).redISub(c);t=h;var d=a.redIAdd(a);d=d.redIAdd(d),d=d.redIAdd(d),n=f.redMul(c.redISub(h)).redISub(d),i=this.y.redAdd(this.y)}else{var g=this.z.redSqr(),x=this.y.redSqr(),S=this.x.redMul(x),D=this.x.redSub(g).redMul(this.x.redAdd(g));D=D.redAdd(D).redIAdd(D);var E=S.redIAdd(S);E=E.redIAdd(E);var _=E.redAdd(E);t=D.redSqr().redISub(_),i=this.y.redAdd(this.z).redSqr().redISub(x).redISub(g);var T=x.redSqr();T=T.redIAdd(T),T=T.redIAdd(T),T=T.redIAdd(T),n=D.redMul(E.redISub(t)).redISub(T)}return this.curve.jpoint(t,n,i)};qt.prototype._dbl=function(){var t=this.curve.a,n=this.x,i=this.y,o=this.z,s=o.redSqr().redSqr(),a=n.redSqr(),c=i.redSqr(),f=a.redAdd(a).redIAdd(a).redIAdd(t.redMul(s)),h=n.redAdd(n);h=h.redIAdd(h);var d=h.redMul(c),g=f.redSqr().redISub(d.redAdd(d)),x=d.redISub(g),S=c.redSqr();S=S.redIAdd(S),S=S.redIAdd(S),S=S.redIAdd(S);var D=f.redMul(x).redISub(S),E=i.redAdd(i).redMul(o);return this.curve.jpoint(g,D,E)};qt.prototype.trpl=function(){if(!this.curve.zeroA)return this.dbl().add(this);var t=this.x.redSqr(),n=this.y.redSqr(),i=this.z.redSqr(),o=n.redSqr(),s=t.redAdd(t).redIAdd(t),a=s.redSqr(),c=this.x.redAdd(n).redSqr().redISub(t).redISub(o);c=c.redIAdd(c),c=c.redAdd(c).redIAdd(c),c=c.redISub(a);var f=c.redSqr(),h=o.redIAdd(o);h=h.redIAdd(h),h=h.redIAdd(h),h=h.redIAdd(h);var d=s.redIAdd(c).redSqr().redISub(a).redISub(f).redISub(h),g=n.redMul(d);g=g.redIAdd(g),g=g.redIAdd(g);var x=this.x.redMul(f).redISub(g);x=x.redIAdd(x),x=x.redIAdd(x);var S=this.y.redMul(d.redMul(h.redISub(d)).redISub(c.redMul(f)));S=S.redIAdd(S),S=S.redIAdd(S),S=S.redIAdd(S);var D=this.z.redAdd(c).redSqr().redISub(i).redISub(f);return this.curve.jpoint(x,S,D)};qt.prototype.mul=function(t,n){return t=new Be(t,n),this.curve._wnafMul(this,t)};qt.prototype.eq=function(t){if(t.type==="affine")return this.eq(t.toJ());if(this===t)return!0;var n=this.z.redSqr(),i=t.z.redSqr();if(this.x.redMul(i).redISub(t.x.redMul(n)).cmpn(0)!==0)return!1;var o=n.redMul(this.z),s=i.redMul(t.z);return this.y.redMul(s).redISub(t.y.redMul(o)).cmpn(0)===0};qt.prototype.eqXToP=function(t){var n=this.z.redSqr(),i=t.toRed(this.curve.red).redMul(n);if(this.x.cmp(i)===0)return!0;for(var o=t.clone(),s=this.curve.redN.redMul(n);;){if(o.iadd(this.curve.n),o.cmp(this.curve.p)>=0)return!1;if(i.redIAdd(s),this.x.cmp(i)===0)return!0}};qt.prototype.inspect=function(){return this.isInfinity()?"<EC JPoint Infinity>":"<EC JPoint x: "+this.x.toString(16,2)+" y: "+this.y.toString(16,2)+" z: "+this.z.toString(16,2)+">"};qt.prototype.isInfinity=function(){return this.z.cmpn(0)===0};var ua=To(function(r,t){var n=t;n.base=eo,n.short=vb,n.mont=null,n.edwards=null}),la=To(function(r,t){var n=t,i=Dr.assert;function o(c){c.type==="short"?this.curve=new ua.short(c):c.type==="edwards"?this.curve=new ua.edwards(c):this.curve=new ua.mont(c),this.g=this.curve.g,this.n=this.curve.n,this.hash=c.hash,i(this.g.validate(),"Invalid curve"),i(this.g.mul(this.n).isInfinity(),"Invalid curve, G*N != O")}n.PresetCurve=o;function s(c,f){Object.defineProperty(n,c,{configurable:!0,enumerable:!0,get:function(){var h=new o(f);return Object.defineProperty(n,c,{configurable:!0,enumerable:!0,value:h}),h}})}s("p192",{type:"short",prime:"p192",p:"ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff",a:"ffffffff ffffffff ffffffff fffffffe ffffffff fffffffc",b:"64210519 e59c80e7 0fa7e9ab 72243049 feb8deec c146b9b1",n:"ffffffff ffffffff ffffffff 99def836 146bc9b1 b4d22831",hash:vr.sha256,gRed:!1,g:["188da80e b03090f6 7cbf20eb 43a18800 f4ff0afd 82ff1012","07192b95 ffc8da78 631011ed 6b24cdd5 73f977a1 1e794811"]}),s("p224",{type:"short",prime:"p224",p:"ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001",a:"ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff fffffffe",b:"b4050a85 0c04b3ab f5413256 5044b0b7 d7bfd8ba 270b3943 2355ffb4",n:"ffffffff ffffffff ffffffff ffff16a2 e0b8f03e 13dd2945 5c5c2a3d",hash:vr.sha256,gRed:!1,g:["b70e0cbd 6bb4bf7f 321390b9 4a03c1d3 56c21122 343280d6 115c1d21","bd376388 b5f723fb 4c22dfe6 cd4375a0 5a074764 44d58199 85007e34"]}),s("p256",{type:"short",prime:null,p:"ffffffff 00000001 00000000 00000000 00000000 ffffffff ffffffff ffffffff",a:"ffffffff 00000001 00000000 00000000 00000000 ffffffff ffffffff fffffffc",b:"5ac635d8 aa3a93e7 b3ebbd55 769886bc 651d06b0 cc53b0f6 3bce3c3e 27d2604b",n:"ffffffff 00000000 ffffffff ffffffff bce6faad a7179e84 f3b9cac2 fc632551",hash:vr.sha256,gRed:!1,g:["6b17d1f2 e12c4247 f8bce6e5 63a440f2 77037d81 2deb33a0 f4a13945 d898c296","4fe342e2 fe1a7f9b 8ee7eb4a 7c0f9e16 2bce3357 6b315ece cbb64068 37bf51f5"]}),s("p384",{type:"short",prime:null,p:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe ffffffff 00000000 00000000 ffffffff",a:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe ffffffff 00000000 00000000 fffffffc",b:"b3312fa7 e23ee7e4 988e056b e3f82d19 181d9c6e fe814112 0314088f 5013875a c656398d 8a2ed19d 2a85c8ed d3ec2aef",n:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff c7634d81 f4372ddf 581a0db2 48b0a77a ecec196a ccc52973",hash:vr.sha384,gRed:!1,g:["aa87ca22 be8b0537 8eb1c71e f320ad74 6e1d3b62 8ba79b98 59f741e0 82542a38 5502f25d bf55296c 3a545e38 72760ab7","3617de4a 96262c6f 5d9e98bf 9292dc29 f8f41dbd 289a147c e9da3113 b5f0b8c0 0a60b1ce 1d7e819d 7a431d7c 90ea0e5f"]}),s("p521",{type:"short",prime:null,p:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff",a:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffc",b:"00000051 953eb961 8e1c9a1f 929a21a0 b68540ee a2da725b 99b315f3 b8b48991 8ef109e1 56193951 ec7e937b 1652c0bd 3bb1bf07 3573df88 3d2c34f1 ef451fd4 6b503f00",n:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffa 51868783 bf2f966b 7fcc0148 f709a5d0 3bb5c9b8 899c47ae bb6fb71e 91386409",hash:vr.sha512,gRed:!1,g:["000000c6 858e06b7 0404e9cd 9e3ecb66 2395b442 9c648139 053fb521 f828af60 6b4d3dba a14b5e77 efe75928 fe1dc127 a2ffa8de 3348b3c1 856a429b f97e7e31 c2e5bd66","00000118 39296a78 9a3bc004 5c8a5fb4 2c7d1bd9 98f54449 579b4468 17afbd17 273e662c 97ee7299 5ef42640 c550b901 3fad0761 353c7086 a272c240 88be9476 9fd16650"]}),s("curve25519",{type:"mont",prime:"p25519",p:"7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed",a:"76d06",b:"1",n:"1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed",hash:vr.sha256,gRed:!1,g:["9"]}),s("ed25519",{type:"edwards",prime:"p25519",p:"7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed",a:"-1",c:"1",d:"52036cee2b6ffe73 8cc740797779e898 00700a4d4141d8ab 75eb4dca135978a3",n:"1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed",hash:vr.sha256,gRed:!1,g:["216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51a","6666666666666666666666666666666666666666666666666666666666666658"]});var a;try{a=null.crash()}catch{a=void 0}s("secp256k1",{type:"short",prime:"k256",p:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f",a:"0",b:"7",n:"ffffffff ffffffff ffffffff fffffffe baaedce6 af48a03b bfd25e8c d0364141",h:"1",hash:vr.sha256,beta:"7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee",lambda:"5363ad4cc05c30e0a5261c028812645a122e22ea20816678df02967c1b23bd72",basis:[{a:"3086d221a7d46bcde86c90e49284eb15",b:"-e4437ed6010e88286f547fa90abfe4c3"},{a:"114ca50f7a8e2f3f657c1108d9d44cfd8",b:"3086d221a7d46bcde86c90e49284eb15"}],gRed:!1,g:["79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798","483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8",a]})});function hi(r){if(!(this instanceof hi))return new hi(r);this.hash=r.hash,this.predResist=!!r.predResist,this.outLen=this.hash.outSize,this.minEntropy=r.minEntropy||this.hash.hmacStrength,this._reseed=null,this.reseedInterval=null,this.K=null,this.V=null;var t=Xr.toArray(r.entropy,r.entropyEnc||"hex"),n=Xr.toArray(r.nonce,r.nonceEnc||"hex"),i=Xr.toArray(r.pers,r.persEnc||"hex");kl(t.length>=this.minEntropy/8,"Not enough entropy. Minimum is: "+this.minEntropy+" bits"),this._init(t,n,i)}var Gp=hi;hi.prototype._init=function(t,n,i){var o=t.concat(n).concat(i);this.K=new Array(this.outLen/8),this.V=new Array(this.outLen/8);for(var s=0;s<this.V.length;s++)this.K[s]=0,this.V[s]=1;this._update(o),this._reseed=1,this.reseedInterval=281474976710656};hi.prototype._hmac=function(){return new vr.hmac(this.hash,this.K)};hi.prototype._update=function(t){var n=this._hmac().update(this.V).update([0]);t&&(n=n.update(t)),this.K=n.digest(),this.V=this._hmac().update(this.V).digest(),t&&(this.K=this._hmac().update(this.V).update([1]).update(t).digest(),this.V=this._hmac().update(this.V).digest())};hi.prototype.reseed=function(t,n,i,o){typeof n!="string"&&(o=i,i=n,n=null),t=Xr.toArray(t,n),i=Xr.toArray(i,o),kl(t.length>=this.minEntropy/8,"Not enough entropy. Minimum is: "+this.minEntropy+" bits"),this._update(t.concat(i||[])),this._reseed=1};hi.prototype.generate=function(t,n,i,o){if(this._reseed>this.reseedInterval)throw new Error("Reseed is required");typeof n!="string"&&(o=i,i=n,n=null),i&&(i=Xr.toArray(i,o||"hex"),this._update(i));for(var s=[];s.length<t;)this.V=this._hmac().update(this.V).digest(),s=s.concat(this.V);var a=s.slice(0,t);return this._update(i),this._reseed++,Xr.encode(a,n)};var au=Dr.assert;function Xt(r,t){this.ec=r,this.priv=null,this.pub=null,t.priv&&this._importPrivate(t.priv,t.privEnc),t.pub&&this._importPublic(t.pub,t.pubEnc)}var Nl=Xt;Xt.fromPublic=function(t,n,i){return n instanceof Xt?n:new Xt(t,{pub:n,pubEnc:i})};Xt.fromPrivate=function(t,n,i){return n instanceof Xt?n:new Xt(t,{priv:n,privEnc:i})};Xt.prototype.validate=function(){var t=this.getPublic();return t.isInfinity()?{result:!1,reason:"Invalid public key"}:t.validate()?t.mul(this.ec.curve.n).isInfinity()?{result:!0,reason:null}:{result:!1,reason:"Public key * N != O"}:{result:!1,reason:"Public key is not a point"}};Xt.prototype.getPublic=function(t,n){return typeof t=="string"&&(n=t,t=null),this.pub||(this.pub=this.ec.g.mul(this.priv)),n?this.pub.encode(n,t):this.pub};Xt.prototype.getPrivate=function(t){return t==="hex"?this.priv.toString(16,2):this.priv};Xt.prototype._importPrivate=function(t,n){this.priv=new Be(t,n||16),this.priv=this.priv.umod(this.ec.curve.n)};Xt.prototype._importPublic=function(t,n){if(t.x||t.y){this.ec.curve.type==="mont"?au(t.x,"Need x coordinate"):(this.ec.curve.type==="short"||this.ec.curve.type==="edwards")&&au(t.x&&t.y,"Need both x and y coordinate"),this.pub=this.ec.curve.point(t.x,t.y);return}this.pub=this.ec.curve.decodePoint(t,n)};Xt.prototype.derive=function(t){return t.validate()||au(t.validate(),"public point not validated"),t.mul(this.priv).getX()};Xt.prototype.sign=function(t,n,i){return this.ec.sign(t,this,n,i)};Xt.prototype.verify=function(t,n){return this.ec.verify(t,n,this)};Xt.prototype.inspect=function(){return"<Key priv: "+(this.priv&&this.priv.toString(16,2))+" pub: "+(this.pub&&this.pub.inspect())+" >"};var xb=Dr.assert;function nc(r,t){if(r instanceof nc)return r;this._importDER(r,t)||(xb(r.r&&r.s,"Signature without r or s"),this.r=new Be(r.r,16),this.s=new Be(r.s,16),r.recoveryParam===void 0?this.recoveryParam=null:this.recoveryParam=r.recoveryParam)}var ic=nc;function Ab(){this.place=0}function Cf(r,t){var n=r[t.place++];if(!(n&128))return n;var i=n&15;if(i===0||i>4)return!1;for(var o=0,s=0,a=t.place;s<i;s++,a++)o<<=8,o|=r[a],o>>>=0;return o<=127?!1:(t.place=a,o)}function kd(r){for(var t=0,n=r.length-1;!r[t]&&!(r[t+1]&128)&&t<n;)t++;return t===0?r:r.slice(t)}nc.prototype._importDER=function(t,n){t=Dr.toArray(t,n);var i=new Ab;if(t[i.place++]!==48)return!1;var o=Cf(t,i);if(o===!1||o+i.place!==t.length||t[i.place++]!==2)return!1;var s=Cf(t,i);if(s===!1)return!1;var a=t.slice(i.place,s+i.place);if(i.place+=s,t[i.place++]!==2)return!1;var c=Cf(t,i);if(c===!1||t.length!==c+i.place)return!1;var f=t.slice(i.place,c+i.place);if(a[0]===0)if(a[1]&128)a=a.slice(1);else return!1;if(f[0]===0)if(f[1]&128)f=f.slice(1);else return!1;return this.r=new Be(a),this.s=new Be(f),this.recoveryParam=null,!0};function If(r,t){if(t<128){r.push(t);return}var n=1+(Math.log(t)/Math.LN2>>>3);for(r.push(n|128);--n;)r.push(t>>>(n<<3)&255);r.push(t)}nc.prototype.toDER=function(t){var n=this.r.toArray(),i=this.s.toArray();for(n[0]&128&&(n=[0].concat(n)),i[0]&128&&(i=[0].concat(i)),n=kd(n),i=kd(i);!i[0]&&!(i[1]&128);)i=i.slice(1);var o=[2];If(o,n.length),o=o.concat(n),o.push(2),If(o,i.length);var s=o.concat(i),a=[48];return If(a,s.length),a=a.concat(s),Dr.encode(a,t)};var Eb=function(){throw new Error("unsupported")},Wp=Dr.assert;function Ur(r){if(!(this instanceof Ur))return new Ur(r);typeof r=="string"&&(Wp(Object.prototype.hasOwnProperty.call(la,r),"Unknown curve "+r),r=la[r]),r instanceof la.PresetCurve&&(r={curve:r}),this.curve=r.curve.curve,this.n=this.curve.n,this.nh=this.n.ushrn(1),this.g=this.curve.g,this.g=r.curve.g,this.g.precompute(r.curve.n.bitLength()+1),this.hash=r.hash||r.curve.hash}var Sb=Ur;Ur.prototype.keyPair=function(t){return new Nl(this,t)};Ur.prototype.keyFromPrivate=function(t,n){return Nl.fromPrivate(this,t,n)};Ur.prototype.keyFromPublic=function(t,n){return Nl.fromPublic(this,t,n)};Ur.prototype.genKeyPair=function(t){t||(t={});for(var n=new Gp({hash:this.hash,pers:t.pers,persEnc:t.persEnc||"utf8",entropy:t.entropy||Eb(this.hash.hmacStrength),entropyEnc:t.entropy&&t.entropyEnc||"utf8",nonce:this.n.toArray()}),i=this.n.byteLength(),o=this.n.sub(new Be(2));;){var s=new Be(n.generate(i));if(!(s.cmp(o)>0))return s.iaddn(1),this.keyFromPrivate(s)}};Ur.prototype._truncateToN=function(t,n){var i=t.byteLength()*8-this.n.bitLength();return i>0&&(t=t.ushrn(i)),!n&&t.cmp(this.n)>=0?t.sub(this.n):t};Ur.prototype.sign=function(t,n,i,o){typeof i=="object"&&(o=i,i=null),o||(o={}),n=this.keyFromPrivate(n,i),t=this._truncateToN(new Be(t,16));for(var s=this.n.byteLength(),a=n.getPrivate().toArray("be",s),c=t.toArray("be",s),f=new Gp({hash:this.hash,entropy:a,nonce:c,pers:o.pers,persEnc:o.persEnc||"utf8"}),h=this.n.sub(new Be(1)),d=0;;d++){var g=o.k?o.k(d):new Be(f.generate(this.n.byteLength()));if(g=this._truncateToN(g,!0),!(g.cmpn(1)<=0||g.cmp(h)>=0)){var x=this.g.mul(g);if(!x.isInfinity()){var S=x.getX(),D=S.umod(this.n);if(D.cmpn(0)!==0){var E=g.invm(this.n).mul(D.mul(n.getPrivate()).iadd(t));if(E=E.umod(this.n),E.cmpn(0)!==0){var _=(x.getY().isOdd()?1:0)|(S.cmp(D)!==0?2:0);return o.canonical&&E.cmp(this.nh)>0&&(E=this.n.sub(E),_^=1),new ic({r:D,s:E,recoveryParam:_})}}}}}};Ur.prototype.verify=function(t,n,i,o){t=this._truncateToN(new Be(t,16)),i=this.keyFromPublic(i,o),n=new ic(n,"hex");var s=n.r,a=n.s;if(s.cmpn(1)<0||s.cmp(this.n)>=0||a.cmpn(1)<0||a.cmp(this.n)>=0)return!1;var c=a.invm(this.n),f=c.mul(t).umod(this.n),h=c.mul(s).umod(this.n),d;return this.curve._maxwellTrick?(d=this.g.jmulAdd(f,i.getPublic(),h),d.isInfinity()?!1:d.eqXToP(s)):(d=this.g.mulAdd(f,i.getPublic(),h),d.isInfinity()?!1:d.getX().umod(this.n).cmp(s)===0)};Ur.prototype.recoverPubKey=function(r,t,n,i){Wp((3&n)===n,"The recovery param is more than two bits"),t=new ic(t,i);var o=this.n,s=new Be(r),a=t.r,c=t.s,f=n&1,h=n>>1;if(a.cmp(this.curve.p.umod(this.curve.n))>=0&&h)throw new Error("Unable to find sencond key candinate");h?a=this.curve.pointFromX(a.add(this.curve.n),f):a=this.curve.pointFromX(a,f);var d=t.r.invm(o),g=o.sub(s).mul(d).umod(o),x=c.mul(d).umod(o);return this.g.mulAdd(g,a,x)};Ur.prototype.getKeyRecoveryParam=function(r,t,n,i){if(t=new ic(t,i),t.recoveryParam!==null)return t.recoveryParam;for(var o=0;o<4;o++){var s;try{s=this.recoverPubKey(r,t,o)}catch{continue}if(s.eq(n))return o}throw new Error("Unable to find valid recovery factor")};var Bb=To(function(r,t){var n=t;n.version="6.5.4",n.utils=Dr,n.rand=function(){throw new Error("unsupported")},n.curve=ua,n.curves=la,n.ec=Sb,n.eddsa=null}),Db=Bb.ec;const Cb="signing-key/5.7.0",cu=new Le(Cb);let _f=null;function Mi(){return _f||(_f=new Db("secp256k1")),_f}class fu{constructor(t){Xe(this,"curve","secp256k1"),Xe(this,"privateKey",Ze(t)),Wm(this.privateKey)!==32&&cu.throwArgumentError("invalid private key","privateKey","[[ REDACTED ]]");const n=Mi().keyFromPrivate(Ue(this.privateKey));Xe(this,"publicKey","0x"+n.getPublic(!1,"hex")),Xe(this,"compressedPublicKey","0x"+n.getPublic(!0,"hex")),Xe(this,"_isSigningKey",!0)}_addPoint(t){const n=Mi().keyFromPublic(Ue(this.publicKey)),i=Mi().keyFromPublic(Ue(t));return"0x"+n.pub.add(i.pub).encodeCompressed("hex")}signDigest(t){const n=Mi().keyFromPrivate(Ue(this.privateKey)),i=Ue(t);i.length!==32&&cu.throwArgumentError("bad digest length","digest",t);const o=n.sign(i,{canonical:!0});return Jm({recoveryParam:o.recoveryParam,r:ci("0x"+o.r.toString(16),32),s:ci("0x"+o.s.toString(16),32)})}computeSharedSecret(t){const n=Mi().keyFromPrivate(Ue(this.privateKey)),i=Mi().keyFromPublic(Ue(Jp(t)));return ci("0x"+n.derive(i.getPublic()).toString(16),32)}static isSigningKey(t){return!!(t&&t._isSigningKey)}}function Jp(r,t){const n=Ue(r);return n.length===32?new fu(n).publicKey:n.length===33?"0x"+Mi().keyFromPublic(n).getPublic(!1,"hex"):n.length===65?Ze(n):cu.throwArgumentError("invalid public or private key","key","[REDACTED]")}var Mf={exports:{}};/**
* [js-sha3]{@link https://github.com/emn178/js-sha3}
*
* @version 0.8.0
* @author Chen, Yi-Cyuan [emn178@gmail.com]
* @copyright Chen, Yi-Cyuan 2015-2018
* @license MIT
*/var Td;function Ib(){return Td||(Td=1,function(r){(function(){var t="input is invalid type",n="finalize already called",i=typeof window=="object",o=i?window:{};o.JS_SHA3_NO_WINDOW&&(i=!1);var s=!i&&typeof self=="object",a=!o.JS_SHA3_NO_NODE_JS&&typeof process=="object"&&process.versions&&process.versions.node;a?o=qo:s&&(o=self);var c=!o.JS_SHA3_NO_COMMON_JS&&!0&&r.exports,f=!o.JS_SHA3_NO_ARRAY_BUFFER&&typeof ArrayBuffer<"u",h="0123456789abcdef".split(""),d=[31,7936,2031616,520093696],g=[4,1024,262144,67108864],x=[1,256,65536,16777216],S=[6,1536,393216,100663296],D=[0,8,16,24],E=[1,0,32898,0,32906,2147483648,2147516416,2147483648,32907,0,2147483649,0,2147516545,2147483648,32777,2147483648,138,0,136,0,2147516425,0,2147483658,0,2147516555,0,139,2147483648,32905,2147483648,32771,2147483648,32770,2147483648,128,2147483648,32778,0,2147483658,2147483648,2147516545,2147483648,32896,2147483648,2147483649,0,2147516424,2147483648],_=[224,256,384,512],T=[128,256],F=["hex","buffer","arrayBuffer","array","digest"],U={128:168,256:136};(o.JS_SHA3_NO_NODE_JS||!Array.isArray)&&(Array.isArray=function(B){return Object.prototype.toString.call(B)==="[object Array]"}),f&&(o.JS_SHA3_NO_ARRAY_BUFFER_IS_VIEW||!ArrayBuffer.isView)&&(ArrayBuffer.isView=function(B){return typeof B=="object"&&B.buffer&&B.buffer.constructor===ArrayBuffer});for(var z=function(B,j,Z){return function(Y){return new y(B,j,B).update(Y)[Z]()}},V=function(B,j,Z){return function(Y,ne){return new y(B,j,ne).update(Y)[Z]()}},G=function(B,j,Z){return function(Y,ne,ue,ce){return u["cshake"+B].update(Y,ne,ue,ce)[Z]()}},ee=function(B,j,Z){return function(Y,ne,ue,ce){return u["kmac"+B].update(Y,ne,ue,ce)[Z]()}},Q=function(B,j,Z,Y){for(var ne=0;ne<F.length;++ne){var ue=F[ne];B[ue]=j(Z,Y,ue)}return B},X=function(B,j){var Z=z(B,j,"hex");return Z.create=function(){return new y(B,j,B)},Z.update=function(Y){return Z.create().update(Y)},Q(Z,z,B,j)},se=function(B,j){var Z=V(B,j,"hex");return Z.create=function(Y){return new y(B,j,Y)},Z.update=function(Y,ne){return Z.create(ne).update(Y)},Q(Z,V,B,j)},oe=function(B,j){var Z=U[B],Y=G(B,j,"hex");return Y.create=function(ne,ue,ce){return!ue&&!ce?u["shake"+B].create(ne):new y(B,j,ne).bytepad([ue,ce],Z)},Y.update=function(ne,ue,ce,ae){return Y.create(ue,ce,ae).update(ne)},Q(Y,G,B,j)},H=function(B,j){var Z=U[B],Y=ee(B,j,"hex");return Y.create=function(ne,ue,ce){return new N(B,j,ue).bytepad(["KMAC",ce],Z).bytepad([ne],Z)},Y.update=function(ne,ue,ce,ae){return Y.create(ne,ce,ae).update(ue)},Q(Y,ee,B,j)},v=[{name:"keccak",padding:x,bits:_,createMethod:X},{name:"sha3",padding:S,bits:_,createMethod:X},{name:"shake",padding:d,bits:T,createMethod:se},{name:"cshake",padding:g,bits:T,createMethod:oe},{name:"kmac",padding:g,bits:T,createMethod:H}],u={},l=[],p=0;p<v.length;++p)for(var w=v[p],A=w.bits,C=0;C<A.length;++C){var k=w.name+"_"+A[C];if(l.push(k),u[k]=w.createMethod(A[C],w.padding),w.name!=="sha3"){var I=w.name+A[C];l.push(I),u[I]=u[k]}}function y(B,j,Z){this.blocks=[],this.s=[],this.padding=j,this.outputBits=Z,this.reset=!0,this.finalized=!1,this.block=0,this.start=0,this.blockCount=1600-(B<<1)>>5,this.byteCount=this.blockCount<<2,this.outputBlocks=Z>>5,this.extraBytes=(Z&31)>>3;for(var Y=0;Y<50;++Y)this.s[Y]=0}y.prototype.update=function(B){if(this.finalized)throw new Error(n);var j,Z=typeof B;if(Z!=="string"){if(Z==="object"){if(B===null)throw new Error(t);if(f&&B.constructor===ArrayBuffer)B=new Uint8Array(B);else if(!Array.isArray(B)&&(!f||!ArrayBuffer.isView(B)))throw new Error(t)}else throw new Error(t);j=!0}for(var Y=this.blocks,ne=this.byteCount,ue=B.length,ce=this.blockCount,ae=0,be=this.s,fe,ge;ae<ue;){if(this.reset)for(this.reset=!1,Y[0]=this.block,fe=1;fe<ce+1;++fe)Y[fe]=0;if(j)for(fe=this.start;ae<ue&&fe<ne;++ae)Y[fe>>2]|=B[ae]<<D[fe++&3];else for(fe=this.start;ae<ue&&fe<ne;++ae)ge=B.charCodeAt(ae),ge<128?Y[fe>>2]|=ge<<D[fe++&3]:ge<2048?(Y[fe>>2]|=(192|ge>>6)<<D[fe++&3],Y[fe>>2]|=(128|ge&63)<<D[fe++&3]):ge<55296||ge>=57344?(Y[fe>>2]|=(224|ge>>12)<<D[fe++&3],Y[fe>>2]|=(128|ge>>6&63)<<D[fe++&3],Y[fe>>2]|=(128|ge&63)<<D[fe++&3]):(ge=65536+((ge&1023)<<10|B.charCodeAt(++ae)&1023),Y[fe>>2]|=(240|ge>>18)<<D[fe++&3],Y[fe>>2]|=(128|ge>>12&63)<<D[fe++&3],Y[fe>>2]|=(128|ge>>6&63)<<D[fe++&3],Y[fe>>2]|=(128|ge&63)<<D[fe++&3]);if(this.lastByteIndex=fe,fe>=ne){for(this.start=fe-ne,this.block=Y[ce],fe=0;fe<ce;++fe)be[fe]^=Y[fe];re(be),this.reset=!0}else this.start=fe}return this},y.prototype.encode=function(B,j){var Z=B&255,Y=1,ne=[Z];for(B=B>>8,Z=B&255;Z>0;)ne.unshift(Z),B=B>>8,Z=B&255,++Y;return j?ne.push(Y):ne.unshift(Y),this.update(ne),ne.length},y.prototype.encodeString=function(B){var j,Z=typeof B;if(Z!=="string"){if(Z==="object"){if(B===null)throw new Error(t);if(f&&B.constructor===ArrayBuffer)B=new Uint8Array(B);else if(!Array.isArray(B)&&(!f||!ArrayBuffer.isView(B)))throw new Error(t)}else throw new Error(t);j=!0}var Y=0,ne=B.length;if(j)Y=ne;else for(var ue=0;ue<B.length;++ue){var ce=B.charCodeAt(ue);ce<128?Y+=1:ce<2048?Y+=2:ce<55296||ce>=57344?Y+=3:(ce=65536+((ce&1023)<<10|B.charCodeAt(++ue)&1023),Y+=4)}return Y+=this.encode(Y*8),this.update(B),Y},y.prototype.bytepad=function(B,j){for(var Z=this.encode(j),Y=0;Y<B.length;++Y)Z+=this.encodeString(B[Y]);var ne=j-Z%j,ue=[];return ue.length=ne,this.update(ue),this},y.prototype.finalize=function(){if(!this.finalized){this.finalized=!0;var B=this.blocks,j=this.lastByteIndex,Z=this.blockCount,Y=this.s;if(B[j>>2]|=this.padding[j&3],this.lastByteIndex===this.byteCount)for(B[0]=B[Z],j=1;j<Z+1;++j)B[j]=0;for(B[Z-1]|=2147483648,j=0;j<Z;++j)Y[j]^=B[j];re(Y)}},y.prototype.toString=y.prototype.hex=function(){this.finalize();for(var B=this.blockCount,j=this.s,Z=this.outputBlocks,Y=this.extraBytes,ne=0,ue=0,ce="",ae;ue<Z;){for(ne=0;ne<B&&ue<Z;++ne,++ue)ae=j[ne],ce+=h[ae>>4&15]+h[ae&15]+h[ae>>12&15]+h[ae>>8&15]+h[ae>>20&15]+h[ae>>16&15]+h[ae>>28&15]+h[ae>>24&15];ue%B===0&&(re(j),ne=0)}return Y&&(ae=j[ne],ce+=h[ae>>4&15]+h[ae&15],Y>1&&(ce+=h[ae>>12&15]+h[ae>>8&15]),Y>2&&(ce+=h[ae>>20&15]+h[ae>>16&15])),ce},y.prototype.arrayBuffer=function(){this.finalize();var B=this.blockCount,j=this.s,Z=this.outputBlocks,Y=this.extraBytes,ne=0,ue=0,ce=this.outputBits>>3,ae;Y?ae=new ArrayBuffer(Z+1<<2):ae=new ArrayBuffer(ce);for(var be=new Uint32Array(ae);ue<Z;){for(ne=0;ne<B&&ue<Z;++ne,++ue)be[ue]=j[ne];ue%B===0&&re(j)}return Y&&(be[ne]=j[ne],ae=ae.slice(0,ce)),ae},y.prototype.buffer=y.prototype.arrayBuffer,y.prototype.digest=y.prototype.array=function(){this.finalize();for(var B=this.blockCount,j=this.s,Z=this.outputBlocks,Y=this.extraBytes,ne=0,ue=0,ce=[],ae,be;ue<Z;){for(ne=0;ne<B&&ue<Z;++ne,++ue)ae=ue<<2,be=j[ne],ce[ae]=be&255,ce[ae+1]=be>>8&255,ce[ae+2]=be>>16&255,ce[ae+3]=be>>24&255;ue%B===0&&re(j)}return Y&&(ae=ue<<2,be=j[ne],ce[ae]=be&255,Y>1&&(ce[ae+1]=be>>8&255),Y>2&&(ce[ae+2]=be>>16&255)),ce};function N(B,j,Z){y.call(this,B,j,Z)}N.prototype=new y,N.prototype.finalize=function(){return this.encode(this.outputBits,!0),y.prototype.finalize.call(this)};var re=function(B){var j,Z,Y,ne,ue,ce,ae,be,fe,ge,jt,_e,je,cr,He,Te,Qe,Oe,Pe,vt,$e,M,m,b,R,K,q,te,Ee,ve,me,ze,ye,et,xi,tt,rt,Ai,nt,it,Ei,ot,st,Si,at,ct,Bi,ft,ut,Di,lt,ht,Ci,dt,pt,Ii,gt,yt,Vn,jn,Kn,zn,qn;for(Y=0;Y<48;Y+=2)ne=B[0]^B[10]^B[20]^B[30]^B[40],ue=B[1]^B[11]^B[21]^B[31]^B[41],ce=B[2]^B[12]^B[22]^B[32]^B[42],ae=B[3]^B[13]^B[23]^B[33]^B[43],be=B[4]^B[14]^B[24]^B[34]^B[44],fe=B[5]^B[15]^B[25]^B[35]^B[45],ge=B[6]^B[16]^B[26]^B[36]^B[46],jt=B[7]^B[17]^B[27]^B[37]^B[47],_e=B[8]^B[18]^B[28]^B[38]^B[48],je=B[9]^B[19]^B[29]^B[39]^B[49],j=_e^(ce<<1|ae>>>31),Z=je^(ae<<1|ce>>>31),B[0]^=j,B[1]^=Z,B[10]^=j,B[11]^=Z,B[20]^=j,B[21]^=Z,B[30]^=j,B[31]^=Z,B[40]^=j,B[41]^=Z,j=ne^(be<<1|fe>>>31),Z=ue^(fe<<1|be>>>31),B[2]^=j,B[3]^=Z,B[12]^=j,B[13]^=Z,B[22]^=j,B[23]^=Z,B[32]^=j,B[33]^=Z,B[42]^=j,B[43]^=Z,j=ce^(ge<<1|jt>>>31),Z=ae^(jt<<1|ge>>>31),B[4]^=j,B[5]^=Z,B[14]^=j,B[15]^=Z,B[24]^=j,B[25]^=Z,B[34]^=j,B[35]^=Z,B[44]^=j,B[45]^=Z,j=be^(_e<<1|je>>>31),Z=fe^(je<<1|_e>>>31),B[6]^=j,B[7]^=Z,B[16]^=j,B[17]^=Z,B[26]^=j,B[27]^=Z,B[36]^=j,B[37]^=Z,B[46]^=j,B[47]^=Z,j=ge^(ne<<1|ue>>>31),Z=jt^(ue<<1|ne>>>31),B[8]^=j,B[9]^=Z,B[18]^=j,B[19]^=Z,B[28]^=j,B[29]^=Z,B[38]^=j,B[39]^=Z,B[48]^=j,B[49]^=Z,cr=B[0],He=B[1],ct=B[11]<<4|B[10]>>>28,Bi=B[10]<<4|B[11]>>>28,te=B[20]<<3|B[21]>>>29,Ee=B[21]<<3|B[20]>>>29,jn=B[31]<<9|B[30]>>>23,Kn=B[30]<<9|B[31]>>>23,ot=B[40]<<18|B[41]>>>14,st=B[41]<<18|B[40]>>>14,et=B[2]<<1|B[3]>>>31,xi=B[3]<<1|B[2]>>>31,Te=B[13]<<12|B[12]>>>20,Qe=B[12]<<12|B[13]>>>20,ft=B[22]<<10|B[23]>>>22,ut=B[23]<<10|B[22]>>>22,ve=B[33]<<13|B[32]>>>19,me=B[32]<<13|B[33]>>>19,zn=B[42]<<2|B[43]>>>30,qn=B[43]<<2|B[42]>>>30,dt=B[5]<<30|B[4]>>>2,pt=B[4]<<30|B[5]>>>2,tt=B[14]<<6|B[15]>>>26,rt=B[15]<<6|B[14]>>>26,Oe=B[25]<<11|B[24]>>>21,Pe=B[24]<<11|B[25]>>>21,Di=B[34]<<15|B[35]>>>17,lt=B[35]<<15|B[34]>>>17,ze=B[45]<<29|B[44]>>>3,ye=B[44]<<29|B[45]>>>3,b=B[6]<<28|B[7]>>>4,R=B[7]<<28|B[6]>>>4,Ii=B[17]<<23|B[16]>>>9,gt=B[16]<<23|B[17]>>>9,Ai=B[26]<<25|B[27]>>>7,nt=B[27]<<25|B[26]>>>7,vt=B[36]<<21|B[37]>>>11,$e=B[37]<<21|B[36]>>>11,ht=B[47]<<24|B[46]>>>8,Ci=B[46]<<24|B[47]>>>8,Si=B[8]<<27|B[9]>>>5,at=B[9]<<27|B[8]>>>5,K=B[18]<<20|B[19]>>>12,q=B[19]<<20|B[18]>>>12,yt=B[29]<<7|B[28]>>>25,Vn=B[28]<<7|B[29]>>>25,it=B[38]<<8|B[39]>>>24,Ei=B[39]<<8|B[38]>>>24,M=B[48]<<14|B[49]>>>18,m=B[49]<<14|B[48]>>>18,B[0]=cr^~Te&Oe,B[1]=He^~Qe&Pe,B[10]=b^~K&te,B[11]=R^~q&Ee,B[20]=et^~tt&Ai,B[21]=xi^~rt&nt,B[30]=Si^~ct&ft,B[31]=at^~Bi&ut,B[40]=dt^~Ii&yt,B[41]=pt^~gt&Vn,B[2]=Te^~Oe&vt,B[3]=Qe^~Pe&$e,B[12]=K^~te&ve,B[13]=q^~Ee&me,B[22]=tt^~Ai&it,B[23]=rt^~nt&Ei,B[32]=ct^~ft&Di,B[33]=Bi^~ut&lt,B[42]=Ii^~yt&jn,B[43]=gt^~Vn&Kn,B[4]=Oe^~vt&M,B[5]=Pe^~$e&m,B[14]=te^~ve&ze,B[15]=Ee^~me&ye,B[24]=Ai^~it&ot,B[25]=nt^~Ei&st,B[34]=ft^~Di&ht,B[35]=ut^~lt&Ci,B[44]=yt^~jn&zn,B[45]=Vn^~Kn&qn,B[6]=vt^~M&cr,B[7]=$e^~m&He,B[16]=ve^~ze&b,B[17]=me^~ye&R,B[26]=it^~ot&et,B[27]=Ei^~st&xi,B[36]=Di^~ht&Si,B[37]=lt^~Ci&at,B[46]=jn^~zn&dt,B[47]=Kn^~qn&pt,B[8]=M^~cr&Te,B[9]=m^~He&Qe,B[18]=ze^~b&K,B[19]=ye^~R&q,B[28]=ot^~et&tt,B[29]=st^~xi&rt,B[38]=ht^~Si&ct,B[39]=Ci^~at&Bi,B[48]=zn^~dt&Ii,B[49]=qn^~pt&gt,B[0]^=E[Y],B[1]^=E[Y+1]};if(c)r.exports=u;else for(p=0;p<l.length;++p)o[l[p]]=u[l[p]]})()}(Mf)),Mf.exports}var _b=Ib();const Mb=tc(_b);function Rl(r){return"0x"+Mb.keccak_256(Ue(r))}const kb="address/5.7.0",Go=new Le(kb);function Nd(r){Nr(r,20)||Go.throwArgumentError("invalid address","address",r),r=r.toLowerCase();const t=r.substring(2).split(""),n=new Uint8Array(40);for(let o=0;o<40;o++)n[o]=t[o].charCodeAt(0);const i=Ue(Rl(n));for(let o=0;o<40;o+=2)i[o>>1]>>4>=8&&(t[o]=t[o].toUpperCase()),(i[o>>1]&15)>=8&&(t[o+1]=t[o+1].toUpperCase());return"0x"+t.join("")}const Tb=9007199254740991;function Nb(r){return Math.log10?Math.log10(r):Math.log(r)/Math.LN10}const Ul={};for(let r=0;r<10;r++)Ul[String(r)]=String(r);for(let r=0;r<26;r++)Ul[String.fromCharCode(65+r)]=String(10+r);const Rd=Math.floor(Nb(Tb));function Rb(r){r=r.toUpperCase(),r=r.substring(4)+r.substring(0,2)+"00";let t=r.split("").map(i=>Ul[i]).join("");for(;t.length>=Rd;){let i=t.substring(0,Rd);t=parseInt(i,10)%97+t.substring(i.length)}let n=String(98-parseInt(t,10)%97);for(;n.length<2;)n="0"+n;return n}function Ub(r){let t=null;if(typeof r!="string"&&Go.throwArgumentError("invalid address","address",r),r.match(/^(0x)?[0-9a-fA-F]{40}$/))r.substring(0,2)!=="0x"&&(r="0x"+r),t=Nd(r),r.match(/([A-F].*[a-f])|([a-f].*[A-F])/)&&t!==r&&Go.throwArgumentError("bad address checksum","address",r);else if(r.match(/^XE[0-9]{2}[0-9A-Za-z]{30,31}$/)){for(r.substring(2,4)!==Rb(r)&&Go.throwArgumentError("bad icap checksum","address",r),t=tb(r.substring(4));t.length<40;)t="0"+t;t=Nd("0x"+t)}else Go.throwArgumentError("invalid address","address",r);return t}var Ud;(function(r){r[r.legacy=0]="legacy",r[r.eip2930=1]="eip2930",r[r.eip1559=2]="eip1559"})(Ud||(Ud={}));function Ob(r){const t=Jp(r);return Ub(Sa(Rl(Sa(t,1)),12))}function Pb(r){return Rl(Da(r))}const Fb="wordlists/5.7.0",Lb=new Le(Fb);class Cs{constructor(t){Lb.checkAbstract(new.target,Cs),Xe(this,"locale",t)}split(t){return t.toLowerCase().split(/ +/g)}join(t){return t.join(" ")}static check(t){const n=[];for(let i=0;i<2048;i++){const o=t.getWord(i);if(i!==t.getWordIndex(o))return"0x";n.push(o)}return Pb(n.join(`
`)+`
`)}static register(t,n){n||(n=t.locale)}}const Hb="AbandonAbilityAbleAboutAboveAbsentAbsorbAbstractAbsurdAbuseAccessAccidentAccountAccuseAchieveAcidAcousticAcquireAcrossActActionActorActressActualAdaptAddAddictAddressAdjustAdmitAdultAdvanceAdviceAerobicAffairAffordAfraidAgainAgeAgentAgreeAheadAimAirAirportAisleAlarmAlbumAlcoholAlertAlienAllAlleyAllowAlmostAloneAlphaAlreadyAlsoAlterAlwaysAmateurAmazingAmongAmountAmusedAnalystAnchorAncientAngerAngleAngryAnimalAnkleAnnounceAnnualAnotherAnswerAntennaAntiqueAnxietyAnyApartApologyAppearAppleApproveAprilArchArcticAreaArenaArgueArmArmedArmorArmyAroundArrangeArrestArriveArrowArtArtefactArtistArtworkAskAspectAssaultAssetAssistAssumeAsthmaAthleteAtomAttackAttendAttitudeAttractAuctionAuditAugustAuntAuthorAutoAutumnAverageAvocadoAvoidAwakeAwareAwayAwesomeAwfulAwkwardAxisBabyBachelorBaconBadgeBagBalanceBalconyBallBambooBananaBannerBarBarelyBargainBarrelBaseBasicBasketBattleBeachBeanBeautyBecauseBecomeBeefBeforeBeginBehaveBehindBelieveBelowBeltBenchBenefitBestBetrayBetterBetweenBeyondBicycleBidBikeBindBiologyBirdBirthBitterBlackBladeBlameBlanketBlastBleakBlessBlindBloodBlossomBlouseBlueBlurBlushBoardBoatBodyBoilBombBoneBonusBookBoostBorderBoringBorrowBossBottomBounceBoxBoyBracketBrainBrandBrassBraveBreadBreezeBrickBridgeBriefBrightBringBriskBroccoliBrokenBronzeBroomBrotherBrownBrushBubbleBuddyBudgetBuffaloBuildBulbBulkBulletBundleBunkerBurdenBurgerBurstBusBusinessBusyButterBuyerBuzzCabbageCabinCableCactusCageCakeCallCalmCameraCampCanCanalCancelCandyCannonCanoeCanvasCanyonCapableCapitalCaptainCarCarbonCardCargoCarpetCarryCartCaseCashCasinoCastleCasualCatCatalogCatchCategoryCattleCaughtCauseCautionCaveCeilingCeleryCementCensusCenturyCerealCertainChairChalkChampionChangeChaosChapterChargeChaseChatCheapCheckCheeseChefCherryChestChickenChiefChildChimneyChoiceChooseChronicChuckleChunkChurnCigarCinnamonCircleCitizenCityCivilClaimClapClarifyClawClayCleanClerkCleverClickClientCliffClimbClinicClipClockClogCloseClothCloudClownClubClumpClusterClutchCoachCoastCoconutCodeCoffeeCoilCoinCollectColorColumnCombineComeComfortComicCommonCompanyConcertConductConfirmCongressConnectConsiderControlConvinceCookCoolCopperCopyCoralCoreCornCorrectCostCottonCouchCountryCoupleCourseCousinCoverCoyoteCrackCradleCraftCramCraneCrashCraterCrawlCrazyCreamCreditCreekCrewCricketCrimeCrispCriticCropCrossCrouchCrowdCrucialCruelCruiseCrumbleCrunchCrushCryCrystalCubeCultureCupCupboardCuriousCurrentCurtainCurveCushionCustomCuteCycleDadDamageDampDanceDangerDaringDashDaughterDawnDayDealDebateDebrisDecadeDecemberDecideDeclineDecorateDecreaseDeerDefenseDefineDefyDegreeDelayDeliverDemandDemiseDenialDentistDenyDepartDependDepositDepthDeputyDeriveDescribeDesertDesignDeskDespairDestroyDetailDetectDevelopDeviceDevoteDiagramDialDiamondDiaryDiceDieselDietDifferDigitalDignityDilemmaDinnerDinosaurDirectDirtDisagreeDiscoverDiseaseDishDismissDisorderDisplayDistanceDivertDivideDivorceDizzyDoctorDocumentDogDollDolphinDomainDonateDonkeyDonorDoorDoseDoubleDoveDraftDragonDramaDrasticDrawDreamDressDriftDrillDrinkDripDriveDropDrumDryDuckDumbDuneDuringDustDutchDutyDwarfDynamicEagerEagleEarlyEarnEarthEasilyEastEasyEchoEcologyEconomyEdgeEditEducateEffortEggEightEitherElbowElderElectricElegantElementElephantElevatorEliteElseEmbarkEmbodyEmbraceEmergeEmotionEmployEmpowerEmptyEnableEnactEndEndlessEndorseEnemyEnergyEnforceEngageEngineEnhanceEnjoyEnlistEnoughEnrichEnrollEnsureEnterEntireEntryEnvelopeEpisodeEqualEquipEraEraseErodeErosionErrorEruptEscapeEssayEssenceEstateEternalEthicsEvidenceEvilEvokeEvolveExactExampleExcessExchangeExciteExcludeExcuseExecuteExerciseExhaustExhibitExileExistExitExoticExpandExpectExpireExplainExposeExpressExtendExtraEyeEyebrowFabricFaceFacultyFadeFaintFaithFallFalseFameFamilyFamousFanFancyFantasyFarmFashionFatFatalFatherFatigueFaultFavoriteFeatureFebruaryFederalFeeFeedFeelFemaleFenceFestivalFetchFeverFewFiberFictionFieldFigureFileFilmFilterFinalFindFineFingerFinishFireFirmFirstFiscalFishFitFitnessFixFlagFlameFlashFlatFlavorFleeFlightFlipFloatFlockFloorFlowerFluidFlushFlyFoamFocusFogFoilFoldFollowFoodFootForceForestForgetForkFortuneForumForwardFossilFosterFoundFoxFragileFrameFrequentFreshFriendFringeFrogFrontFrostFrownFrozenFruitFuelFunFunnyFurnaceFuryFutureGadgetGainGalaxyGalleryGameGapGarageGarbageGardenGarlicGarmentGasGaspGateGatherGaugeGazeGeneralGeniusGenreGentleGenuineGestureGhostGiantGiftGiggleGingerGiraffeGirlGiveGladGlanceGlareGlassGlideGlimpseGlobeGloomGloryGloveGlowGlueGoatGoddessGoldGoodGooseGorillaGospelGossipGovernGownGrabGraceGrainGrantGrapeGrassGravityGreatGreenGridGriefGritGroceryGroupGrowGruntGuardGuessGuideGuiltGuitarGunGymHabitHairHalfHammerHamsterHandHappyHarborHardHarshHarvestHatHaveHawkHazardHeadHealthHeartHeavyHedgehogHeightHelloHelmetHelpHenHeroHiddenHighHillHintHipHireHistoryHobbyHockeyHoldHoleHolidayHollowHomeHoneyHoodHopeHornHorrorHorseHospitalHostHotelHourHoverHubHugeHumanHumbleHumorHundredHungryHuntHurdleHurryHurtHusbandHybridIceIconIdeaIdentifyIdleIgnoreIllIllegalIllnessImageImitateImmenseImmuneImpactImposeImproveImpulseInchIncludeIncomeIncreaseIndexIndicateIndoorIndustryInfantInflictInformInhaleInheritInitialInjectInjuryInmateInnerInnocentInputInquiryInsaneInsectInsideInspireInstallIntactInterestIntoInvestInviteInvolveIronIslandIsolateIssueItemIvoryJacketJaguarJarJazzJealousJeansJellyJewelJobJoinJokeJourneyJoyJudgeJuiceJumpJungleJuniorJunkJustKangarooKeenKeepKetchupKeyKickKidKidneyKindKingdomKissKitKitchenKiteKittenKiwiKneeKnifeKnockKnowLabLabelLaborLadderLadyLakeLampLanguageLaptopLargeLaterLatinLaughLaundryLavaLawLawnLawsuitLayerLazyLeaderLeafLearnLeaveLectureLeftLegLegalLegendLeisureLemonLendLengthLensLeopardLessonLetterLevelLiarLibertyLibraryLicenseLifeLiftLightLikeLimbLimitLinkLionLiquidListLittleLiveLizardLoadLoanLobsterLocalLockLogicLonelyLongLoopLotteryLoudLoungeLoveLoyalLuckyLuggageLumberLunarLunchLuxuryLyricsMachineMadMagicMagnetMaidMailMainMajorMakeMammalManManageMandateMangoMansionManualMapleMarbleMarchMarginMarineMarketMarriageMaskMassMasterMatchMaterialMathMatrixMatterMaximumMazeMeadowMeanMeasureMeatMechanicMedalMediaMelodyMeltMemberMemoryMentionMenuMercyMergeMeritMerryMeshMessageMetalMethodMiddleMidnightMilkMillionMimicMindMinimumMinorMinuteMiracleMirrorMiseryMissMistakeMixMixedMixtureMobileModelModifyMomMomentMonitorMonkeyMonsterMonthMoonMoralMoreMorningMosquitoMotherMotionMotorMountainMouseMoveMovieMuchMuffinMuleMultiplyMuscleMuseumMushroomMusicMustMutualMyselfMysteryMythNaiveNameNapkinNarrowNastyNationNatureNearNeckNeedNegativeNeglectNeitherNephewNerveNestNetNetworkNeutralNeverNewsNextNiceNightNobleNoiseNomineeNoodleNormalNorthNoseNotableNoteNothingNoticeNovelNowNuclearNumberNurseNutOakObeyObjectObligeObscureObserveObtainObviousOccurOceanOctoberOdorOffOfferOfficeOftenOilOkayOldOliveOlympicOmitOnceOneOnionOnlineOnlyOpenOperaOpinionOpposeOptionOrangeOrbitOrchardOrderOrdinaryOrganOrientOriginalOrphanOstrichOtherOutdoorOuterOutputOutsideOvalOvenOverOwnOwnerOxygenOysterOzonePactPaddlePagePairPalacePalmPandaPanelPanicPantherPaperParadeParentParkParrotPartyPassPatchPathPatientPatrolPatternPausePavePaymentPeacePeanutPearPeasantPelicanPenPenaltyPencilPeoplePepperPerfectPermitPersonPetPhonePhotoPhrasePhysicalPianoPicnicPicturePiecePigPigeonPillPilotPinkPioneerPipePistolPitchPizzaPlacePlanetPlasticPlatePlayPleasePledgePluckPlugPlungePoemPoetPointPolarPolePolicePondPonyPoolPopularPortionPositionPossiblePostPotatoPotteryPovertyPowderPowerPracticePraisePredictPreferPreparePresentPrettyPreventPricePridePrimaryPrintPriorityPrisonPrivatePrizeProblemProcessProduceProfitProgramProjectPromoteProofPropertyProsperProtectProudProvidePublicPuddingPullPulpPulsePumpkinPunchPupilPuppyPurchasePurityPurposePursePushPutPuzzlePyramidQualityQuantumQuarterQuestionQuickQuitQuizQuoteRabbitRaccoonRaceRackRadarRadioRailRainRaiseRallyRampRanchRandomRangeRapidRareRateRatherRavenRawRazorReadyRealReasonRebelRebuildRecallReceiveRecipeRecordRecycleReduceReflectReformRefuseRegionRegretRegularRejectRelaxReleaseReliefRelyRemainRememberRemindRemoveRenderRenewRentReopenRepairRepeatReplaceReportRequireRescueResembleResistResourceResponseResultRetireRetreatReturnReunionRevealReviewRewardRhythmRibRibbonRiceRichRideRidgeRifleRightRigidRingRiotRippleRiskRitualRivalRiverRoadRoastRobotRobustRocketRomanceRoofRookieRoomRoseRotateRoughRoundRouteRoyalRubberRudeRugRuleRunRunwayRuralSadSaddleSadnessSafeSailSaladSalmonSalonSaltSaluteSameSampleSandSatisfySatoshiSauceSausageSaveSayScaleScanScareScatterSceneSchemeSchoolScienceScissorsScorpionScoutScrapScreenScriptScrubSeaSearchSeasonSeatSecondSecretSectionSecuritySeedSeekSegmentSelectSellSeminarSeniorSenseSentenceSeriesServiceSessionSettleSetupSevenShadowShaftShallowShareShedShellSheriffShieldShiftShineShipShiverShockShoeShootShopShortShoulderShoveShrimpShrugShuffleShySiblingSickSideSiegeSightSignSilentSilkSillySilverSimilarSimpleSinceSingSirenSisterSituateSixSizeSkateSketchSkiSkillSkinSkirtSkullSlabSlamSleepSlenderSliceSlideSlightSlimSloganSlotSlowSlushSmallSmartSmileSmokeSmoothSnackSnakeSnapSniffSnowSoapSoccerSocialSockSodaSoftSolarSoldierSolidSolutionSolveSomeoneSongSoonSorrySortSoulSoundSoupSourceSouthSpaceSpareSpatialSpawnSpeakSpecialSpeedSpellSpendSphereSpiceSpiderSpikeSpinSpiritSplitSpoilSponsorSpoonSportSpotSpraySpreadSpringSpySquareSqueezeSquirrelStableStadiumStaffStageStairsStampStandStartStateStaySteakSteelStemStepStereoStickStillStingStockStomachStoneStoolStoryStoveStrategyStreetStrikeStrongStruggleStudentStuffStumbleStyleSubjectSubmitSubwaySuccessSuchSuddenSufferSugarSuggestSuitSummerSunSunnySunsetSuperSupplySupremeSureSurfaceSurgeSurpriseSurroundSurveySuspectSustainSwallowSwampSwapSwarmSwearSweetSwiftSwimSwingSwitchSwordSymbolSymptomSyrupSystemTableTackleTagTailTalentTalkTankTapeTargetTaskTasteTattooTaxiTeachTeamTellTenTenantTennisTentTermTestTextThankThatThemeThenTheoryThereTheyThingThisThoughtThreeThriveThrowThumbThunderTicketTideTigerTiltTimberTimeTinyTipTiredTissueTitleToastTobaccoTodayToddlerToeTogetherToiletTokenTomatoTomorrowToneTongueTonightToolToothTopTopicToppleTorchTornadoTortoiseTossTotalTouristTowardTowerTownToyTrackTradeTrafficTragicTrainTransferTrapTrashTravelTrayTreatTreeTrendTrialTribeTrickTriggerTrimTripTrophyTroubleTruckTrueTrulyTrumpetTrustTruthTryTubeTuitionTumbleTunaTunnelTurkeyTurnTurtleTwelveTwentyTwiceTwinTwistTwoTypeTypicalUglyUmbrellaUnableUnawareUncleUncoverUnderUndoUnfairUnfoldUnhappyUniformUniqueUnitUniverseUnknownUnlockUntilUnusualUnveilUpdateUpgradeUpholdUponUpperUpsetUrbanUrgeUsageUseUsedUsefulUselessUsualUtilityVacantVacuumVagueValidValleyValveVanVanishVaporVariousVastVaultVehicleVelvetVendorVentureVenueVerbVerifyVersionVeryVesselVeteranViableVibrantViciousVictoryVideoViewVillageVintageViolinVirtualVirusVisaVisitVisualVitalVividVocalVoiceVoidVolcanoVolumeVoteVoyageWageWagonWaitWalkWallWalnutWantWarfareWarmWarriorWashWaspWasteWaterWaveWayWealthWeaponWearWeaselWeatherWebWeddingWeekendWeirdWelcomeWestWetWhaleWhatWheatWheelWhenWhereWhipWhisperWideWidthWifeWildWillWinWindowWineWingWinkWinnerWinterWireWisdomWiseWishWitnessWolfWomanWonderWoodWoolWordWorkWorldWorryWorthWrapWreckWrestleWristWriteWrongYardYearYellowYouYoungYouthZebraZeroZoneZoo";let Xo=null;function Od(r){if(Xo==null&&(Xo=Hb.replace(/([A-Z])/g," $1").toLowerCase().substring(1).split(" "),Cs.check(r)!=="0x3c8acc1e7b08d8e76f9fda015ef48dc8c710a73cb7e0f77b2c18a9b5a7adde60"))throw Xo=null,new Error("BIP39 Wordlist for en (English) FAILED")}class $b extends Cs{constructor(){super("en")}getWord(t){return Od(this),Xo[t]}getWordIndex(t){return Od(this),Xo.indexOf(t)}}const Yp=new $b;Cs.register(Yp);const Pd={en:Yp},Vb="hdnode/5.7.0",Ma=new Le(Vb),jb=rr.from("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),Kb=Da("Bitcoin seed"),Ws=2147483648;function Zp(r){return(1<<r)-1<<8-r}function zb(r){return(1<<r)-1}function Js(r){return ci(Ze(r),32)}function Fd(r){return Vp.encode(su([r,Sa(cs(cs(r)),0,4)]))}function Ol(r){if(r==null)return Pd.en;if(typeof r=="string"){const t=Pd[r];return t==null&&Ma.throwArgumentError("unknown locale","wordlist",r),t}return r}const ro={};class Sn{constructor(t,n,i,o,s,a,c,f){if(t!==ro)throw new Error("HDNode constructor cannot be called directly");if(n){const h=new fu(n);Xe(this,"privateKey",h.privateKey),Xe(this,"publicKey",h.compressedPublicKey)}else Xe(this,"privateKey",null),Xe(this,"publicKey",Ze(i));Xe(this,"parentFingerprint",o),Xe(this,"fingerprint",Sa(gb(cs(this.publicKey)),0,4)),Xe(this,"address",Ob(this.publicKey)),Xe(this,"chainCode",s),Xe(this,"index",a),Xe(this,"depth",c),f==null?(Xe(this,"mnemonic",null),Xe(this,"path",null)):typeof f=="string"?(Xe(this,"mnemonic",null),Xe(this,"path",f)):(Xe(this,"mnemonic",f),Xe(this,"path",f.path))}get extendedKey(){if(this.depth>=256)throw new Error("Depth too large!");return Fd(su([this.privateKey!=null?"0x0488ADE4":"0x0488B21E",Ze(this.depth),this.parentFingerprint,ci(Ze(this.index),4),this.chainCode,this.privateKey!=null?su(["0x00",this.privateKey]):this.publicKey]))}neuter(){return new Sn(ro,null,this.publicKey,this.parentFingerprint,this.chainCode,this.index,this.depth,this.path)}_derive(t){if(t>4294967295)throw new Error("invalid index - "+String(t));let n=this.path;n&&(n+="/"+(t&2147483647));const i=new Uint8Array(37);if(t&Ws){if(!this.privateKey)throw new Error("cannot derive child of neutered node");i.set(Ue(this.privateKey),1),n&&(n+="'")}else i.set(Ue(this.publicKey));for(let g=24;g>=0;g-=8)i[33+(g>>3)]=t>>24-g&255;const o=Ue(Ca(as.sha512,this.chainCode,i)),s=o.slice(0,32),a=o.slice(32);let c=null,f=null;this.privateKey?c=Js(rr.from(s).add(this.privateKey).mod(jb)):f=new fu(Ze(s))._addPoint(this.publicKey);let h=n;const d=this.mnemonic;return d&&(h=Object.freeze({phrase:d.phrase,path:n,locale:d.locale||"en"})),new Sn(ro,c,f,this.fingerprint,Js(a),t,this.depth+1,h)}derivePath(t){const n=t.split("/");if(n.length===0||n[0]==="m"&&this.depth!==0)throw new Error("invalid path - "+t);n[0]==="m"&&n.shift();let i=this;for(let o=0;o<n.length;o++){const s=n[o];if(s.match(/^[0-9]+'$/)){const a=parseInt(s.substring(0,s.length-1));if(a>=Ws)throw new Error("invalid path index - "+s);i=i._derive(Ws+a)}else if(s.match(/^[0-9]+$/)){const a=parseInt(s);if(a>=Ws)throw new Error("invalid path index - "+s);i=i._derive(a)}else throw new Error("invalid path component - "+s)}return i}static _fromSeed(t,n){const i=Ue(t);if(i.length<16||i.length>64)throw new Error("invalid seed");const o=Ue(Ca(as.sha512,Kb,i));return new Sn(ro,Js(o.slice(0,32)),null,"0x00000000",Js(o.slice(32)),0,0,n)}static fromMnemonic(t,n,i){return i=Ol(i),t=Wb(Gb(t,i),i),Sn._fromSeed(qb(t,n),{phrase:t,path:"m",locale:i.locale})}static fromSeed(t){return Sn._fromSeed(t,null)}static fromExtendedKey(t){const n=Vp.decode(t);(n.length!==82||Fd(n.slice(0,78))!==t)&&Ma.throwArgumentError("invalid extended key","extendedKey","[REDACTED]");const i=n[4],o=Ze(n.slice(5,9)),s=parseInt(Ze(n.slice(9,13)).substring(2),16),a=Ze(n.slice(13,45)),c=n.slice(45,78);switch(Ze(n.slice(0,4))){case"0x0488b21e":case"0x043587cf":return new Sn(ro,null,Ze(c),o,a,s,i,null);case"0x0488ade4":case"0x04358394 ":if(c[0]!==0)break;return new Sn(ro,Ze(c.slice(1)),null,o,a,s,i,null)}return Ma.throwArgumentError("invalid extended key","extendedKey","[REDACTED]")}}function qb(r,t){t||(t="");const n=Da("mnemonic"+t,bo.NFKD);return yb(Da(r,bo.NFKD),n,2048,64,"sha512")}function Gb(r,t){t=Ol(t),Ma.checkNormalize();const n=t.split(r);if(n.length%3!==0)throw new Error("invalid mnemonic");const i=Ue(new Uint8Array(Math.ceil(11*n.length/8)));let o=0;for(let h=0;h<n.length;h++){let d=t.getWordIndex(n[h].normalize("NFKD"));if(d===-1)throw new Error("invalid mnemonic");for(let g=0;g<11;g++)d&1<<10-g&&(i[o>>3]|=1<<7-o%8),o++}const s=32*n.length/3,a=n.length/3,c=Zp(a);if((Ue(cs(i.slice(0,s/8)))[0]&c)!==(i[i.length-1]&c))throw new Error("invalid checksum");return Ze(i.slice(0,s/8))}function Wb(r,t){if(t=Ol(t),r=Ue(r),r.length%4!==0||r.length<16||r.length>32)throw new Error("invalid entropy");const n=[0];let i=11;for(let a=0;a<r.length;a++)i>8?(n[n.length-1]<<=8,n[n.length-1]|=r[a],i-=8):(n[n.length-1]<<=i,n[n.length-1]|=r[a]>>8-i,n.push(r[a]&zb(8-i)),i+=3);const o=r.length/4,s=Ue(cs(r))[0]&Zp(o);return n[n.length-1]<<=o,n[n.length-1]|=s>>8-o,t.join(n.map(a=>t.getWord(a)))}function Jb(r,t,n,i){if(typeof r.setBigUint64=="function")return r.setBigUint64(t,n,i);const o=BigInt(32),s=BigInt(4294967295),a=Number(n>>o&s),c=Number(n&s),f=i?4:0,h=i?0:4;r.setUint32(t+f,a,i),r.setUint32(t+h,c,i)}const Yb=(r,t,n)=>r&t^~r&n,Zb=(r,t,n)=>r&t^r&n^t&n;let Xb=class extends pm{constructor(t,n,i,o){super(),this.blockLen=t,this.outputLen=n,this.padOffset=i,this.isLE=o,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(t),this.view=hf(this.buffer)}update(t){ru(this);const{view:n,buffer:i,blockLen:o}=this;t=Pp(t);const s=t.length;for(let a=0;a<s;){const c=Math.min(o-this.pos,s-a);if(c===o){const f=hf(t);for(;o<=s-a;a+=o)this.process(f,a);continue}i.set(t.subarray(a,a+c),this.pos),this.pos+=c,a+=c,this.pos===o&&(this.process(n,0),this.pos=0)}return this.length+=t.length,this.roundClean(),this}digestInto(t){ru(this),Op(t,this),this.finished=!0;const{buffer:n,view:i,blockLen:o,isLE:s}=this;let{pos:a}=this;n[a++]=128,this.buffer.subarray(a).fill(0),this.padOffset>o-a&&(this.process(i,0),a=0);for(let g=a;g<o;g++)n[g]=0;Jb(i,o-8,BigInt(this.length*8),s),this.process(i,0);const c=hf(t),f=this.outputLen;if(f%4)throw new Error("_sha2: outputLen should be aligned to 32bit");const h=f/4,d=this.get();if(h>d.length)throw new Error("_sha2: outputLen bigger than state");for(let g=0;g<h;g++)c.setUint32(4*g,d[g],s)}digest(){const{buffer:t,outputLen:n}=this;this.digestInto(t);const i=t.slice(0,n);return this.destroy(),i}_cloneInto(t){t||(t=new this.constructor),t.set(...this.get());const{blockLen:n,buffer:i,length:o,finished:s,destroyed:a,pos:c}=this;return t.length=o,t.pos=c,t.finished=s,t.destroyed=a,o%n&&t.buffer.set(i),t}};const Qb=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),Jn=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),Yn=new Uint32Array(64);let ev=class extends Xb{constructor(){super(64,32,8,!1),this.A=Jn[0]|0,this.B=Jn[1]|0,this.C=Jn[2]|0,this.D=Jn[3]|0,this.E=Jn[4]|0,this.F=Jn[5]|0,this.G=Jn[6]|0,this.H=Jn[7]|0}get(){const{A:t,B:n,C:i,D:o,E:s,F:a,G:c,H:f}=this;return[t,n,i,o,s,a,c,f]}set(t,n,i,o,s,a,c,f){this.A=t|0,this.B=n|0,this.C=i|0,this.D=o|0,this.E=s|0,this.F=a|0,this.G=c|0,this.H=f|0}process(t,n){for(let g=0;g<16;g++,n+=4)Yn[g]=t.getUint32(n,!1);for(let g=16;g<64;g++){const x=Yn[g-15],S=Yn[g-2],D=nn(x,7)^nn(x,18)^x>>>3,E=nn(S,17)^nn(S,19)^S>>>10;Yn[g]=E+Yn[g-7]+D+Yn[g-16]|0}let{A:i,B:o,C:s,D:a,E:c,F:f,G:h,H:d}=this;for(let g=0;g<64;g++){const x=nn(c,6)^nn(c,11)^nn(c,25),S=d+x+Yb(c,f,h)+Qb[g]+Yn[g]|0,E=(nn(i,2)^nn(i,13)^nn(i,22))+Zb(i,o,s)|0;d=h,h=f,f=c,c=a+S|0,a=s,s=o,o=i,i=S+E|0}i=i+this.A|0,o=o+this.B|0,s=s+this.C|0,a=a+this.D|0,c=c+this.E|0,f=f+this.F|0,h=h+this.G|0,d=d+this.H|0,this.set(i,o,s,a,c,f,h,d)}roundClean(){Yn.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}};const tv=gm(()=>new ev);function rv(r){return t=>(hm.bytes(t),r(t))}(()=>{const r=typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0,t=typeof module<"u"&&typeof module.require=="function"&&module.require.bind(module);return{node:t&&!r?t("crypto"):void 0,web:r}})();const Pl=rv(tv),no=typeof performance=="object"&&performance&&typeof performance.now=="function"?performance:Date,Xp=new Set,uu=typeof process=="object"&&process?process:{},Qp=(r,t,n,i)=>{typeof uu.emitWarning=="function"?uu.emitWarning(r,t,n,i):console.error(`[${n}] ${t}: ${r}`)};let ka=globalThis.AbortController,Ld=globalThis.AbortSignal;var vp;if(typeof ka>"u"){Ld=class{constructor(){We(this,"onabort");We(this,"_onabort",[]);We(this,"reason");We(this,"aborted",!1)}addEventListener(i,o){this._onabort.push(o)}},ka=class{constructor(){We(this,"signal",new Ld);t()}abort(i){var o,s;if(!this.signal.aborted){this.signal.reason=i,this.signal.aborted=!0;for(const a of this.signal._onabort)a(i);(s=(o=this.signal).onabort)==null||s.call(o,i)}}};let r=((vp=uu.env)==null?void 0:vp.LRU_CACHE_IGNORE_AC_WARNING)!=="1";const t=()=>{r&&(r=!1,Qp("AbortController is not defined. If using lru-cache in node 14, load an AbortController polyfill from the `node-abort-controller` package. A minimal polyfill is provided for use by LRUCache.fetch(), but it should not be relied upon in other contexts (eg, passing it to other APIs that use AbortController/AbortSignal might have undesirable effects). You may disable this with LRU_CACHE_IGNORE_AC_WARNING=1 in the env.","NO_ABORT_CONTROLLER","ENOTSUP",t))}}const nv=r=>!Xp.has(r),ri=r=>r&&r===Math.floor(r)&&r>0&&isFinite(r),eg=r=>ri(r)?r<=Math.pow(2,8)?Uint8Array:r<=Math.pow(2,16)?Uint16Array:r<=Math.pow(2,32)?Uint32Array:r<=Number.MAX_SAFE_INTEGER?ha:null:null;class ha extends Array{constructor(t){super(t),this.fill(0)}}var po;const Ni=class Ni{constructor(t,n){We(this,"heap");We(this,"length");if(!P(Ni,po))throw new TypeError("instantiate Stack using Stack.create(n)");this.heap=new n(t),this.length=0}static create(t){const n=eg(t);if(!n)return[];we(Ni,po,!0);const i=new Ni(t,n);return we(Ni,po,!1),i}push(t){this.heap[this.length++]=t}pop(){return this.heap[--this.length]}};po=new WeakMap,Ve(Ni,po,!1);let lu=Ni;var xp,Ap,Kr,yr,zr,qr,go,yo,kt,Gr,It,mt,Se,er,wr,Jt,Pt,Wr,Ft,Jr,Yr,mr,Zr,ai,tr,le,du,Ui,Dn,Es,br,tg,Oi,wo,Ss,ni,ii,pu,da,pa,wt,gu,Wo,oi,yu;const Gh=class Gh{constructor(t){Ve(this,le);Ve(this,Kr);Ve(this,yr);Ve(this,zr);Ve(this,qr);Ve(this,go);Ve(this,yo);We(this,"ttl");We(this,"ttlResolution");We(this,"ttlAutopurge");We(this,"updateAgeOnGet");We(this,"updateAgeOnHas");We(this,"allowStale");We(this,"noDisposeOnSet");We(this,"noUpdateTTL");We(this,"maxEntrySize");We(this,"sizeCalculation");We(this,"noDeleteOnFetchRejection");We(this,"noDeleteOnStaleGet");We(this,"allowStaleOnFetchAbort");We(this,"allowStaleOnFetchRejection");We(this,"ignoreFetchAbort");Ve(this,kt);Ve(this,Gr);Ve(this,It);Ve(this,mt);Ve(this,Se);Ve(this,er);Ve(this,wr);Ve(this,Jt);Ve(this,Pt);Ve(this,Wr);Ve(this,Ft);Ve(this,Jr);Ve(this,Yr);Ve(this,mr);Ve(this,Zr);Ve(this,ai);Ve(this,tr);Ve(this,Ui,()=>{});Ve(this,Dn,()=>{});Ve(this,Es,()=>{});Ve(this,br,()=>!1);Ve(this,Oi,t=>{});Ve(this,wo,(t,n,i)=>{});Ve(this,Ss,(t,n,i,o)=>{if(i||o)throw new TypeError("cannot set size without setting maxSize or maxEntrySize on cache");return 0});We(this,xp,"LRUCache");const{max:n=0,ttl:i,ttlResolution:o=1,ttlAutopurge:s,updateAgeOnGet:a,updateAgeOnHas:c,allowStale:f,dispose:h,disposeAfter:d,noDisposeOnSet:g,noUpdateTTL:x,maxSize:S=0,maxEntrySize:D=0,sizeCalculation:E,fetchMethod:_,memoMethod:T,noDeleteOnFetchRejection:F,noDeleteOnStaleGet:U,allowStaleOnFetchRejection:z,allowStaleOnFetchAbort:V,ignoreFetchAbort:G}=t;if(n!==0&&!ri(n))throw new TypeError("max option must be a nonnegative integer");const ee=n?eg(n):Array;if(!ee)throw new Error("invalid max value: "+n);if(we(this,Kr,n),we(this,yr,S),this.maxEntrySize=D||P(this,yr),this.sizeCalculation=E,this.sizeCalculation){if(!P(this,yr)&&!this.maxEntrySize)throw new TypeError("cannot set sizeCalculation without setting maxSize or maxEntrySize");if(typeof this.sizeCalculation!="function")throw new TypeError("sizeCalculation set to non-function")}if(T!==void 0&&typeof T!="function")throw new TypeError("memoMethod must be a function if defined");if(we(this,yo,T),_!==void 0&&typeof _!="function")throw new TypeError("fetchMethod must be a function if specified");if(we(this,go,_),we(this,ai,!!_),we(this,It,new Map),we(this,mt,new Array(n).fill(void 0)),we(this,Se,new Array(n).fill(void 0)),we(this,er,new ee(n)),we(this,wr,new ee(n)),we(this,Jt,0),we(this,Pt,0),we(this,Wr,lu.create(n)),we(this,kt,0),we(this,Gr,0),typeof h=="function"&&we(this,zr,h),typeof d=="function"?(we(this,qr,d),we(this,Ft,[])):(we(this,qr,void 0),we(this,Ft,void 0)),we(this,Zr,!!P(this,zr)),we(this,tr,!!P(this,qr)),this.noDisposeOnSet=!!g,this.noUpdateTTL=!!x,this.noDeleteOnFetchRejection=!!F,this.allowStaleOnFetchRejection=!!z,this.allowStaleOnFetchAbort=!!V,this.ignoreFetchAbort=!!G,this.maxEntrySize!==0){if(P(this,yr)!==0&&!ri(P(this,yr)))throw new TypeError("maxSize must be a positive integer if specified");if(!ri(this.maxEntrySize))throw new TypeError("maxEntrySize must be a positive integer if specified");de(this,le,tg).call(this)}if(this.allowStale=!!f,this.noDeleteOnStaleGet=!!U,this.updateAgeOnGet=!!a,this.updateAgeOnHas=!!c,this.ttlResolution=ri(o)||o===0?o:1,this.ttlAutopurge=!!s,this.ttl=i||0,this.ttl){if(!ri(this.ttl))throw new TypeError("ttl must be a positive integer if specified");de(this,le,du).call(this)}if(P(this,Kr)===0&&this.ttl===0&&P(this,yr)===0)throw new TypeError("At least one of max, maxSize, or ttl is required");if(!this.ttlAutopurge&&!P(this,Kr)&&!P(this,yr)){const Q="LRU_CACHE_UNBOUNDED";nv(Q)&&(Xp.add(Q),Qp("TTL caching without ttlAutopurge, max, or maxSize can result in unbounded memory consumption.","UnboundedCacheWarning",Q,Gh))}}static unsafeExposeInternals(t){return{starts:P(t,Yr),ttls:P(t,mr),sizes:P(t,Jr),keyMap:P(t,It),keyList:P(t,mt),valList:P(t,Se),next:P(t,er),prev:P(t,wr),get head(){return P(t,Jt)},get tail(){return P(t,Pt)},free:P(t,Wr),isBackgroundFetch:n=>{var i;return de(i=t,le,wt).call(i,n)},backgroundFetch:(n,i,o,s)=>{var a;return de(a=t,le,pa).call(a,n,i,o,s)},moveToTail:n=>{var i;return de(i=t,le,Wo).call(i,n)},indexes:n=>{var i;return de(i=t,le,ni).call(i,n)},rindexes:n=>{var i;return de(i=t,le,ii).call(i,n)},isStale:n=>{var i;return P(i=t,br).call(i,n)}}}get max(){return P(this,Kr)}get maxSize(){return P(this,yr)}get calculatedSize(){return P(this,Gr)}get size(){return P(this,kt)}get fetchMethod(){return P(this,go)}get memoMethod(){return P(this,yo)}get dispose(){return P(this,zr)}get disposeAfter(){return P(this,qr)}getRemainingTTL(t){return P(this,It).has(t)?1/0:0}*entries(){for(const t of de(this,le,ni).call(this))P(this,Se)[t]!==void 0&&P(this,mt)[t]!==void 0&&!de(this,le,wt).call(this,P(this,Se)[t])&&(yield[P(this,mt)[t],P(this,Se)[t]])}*rentries(){for(const t of de(this,le,ii).call(this))P(this,Se)[t]!==void 0&&P(this,mt)[t]!==void 0&&!de(this,le,wt).call(this,P(this,Se)[t])&&(yield[P(this,mt)[t],P(this,Se)[t]])}*keys(){for(const t of de(this,le,ni).call(this)){const n=P(this,mt)[t];n!==void 0&&!de(this,le,wt).call(this,P(this,Se)[t])&&(yield n)}}*rkeys(){for(const t of de(this,le,ii).call(this)){const n=P(this,mt)[t];n!==void 0&&!de(this,le,wt).call(this,P(this,Se)[t])&&(yield n)}}*values(){for(const t of de(this,le,ni).call(this))P(this,Se)[t]!==void 0&&!de(this,le,wt).call(this,P(this,Se)[t])&&(yield P(this,Se)[t])}*rvalues(){for(const t of de(this,le,ii).call(this))P(this,Se)[t]!==void 0&&!de(this,le,wt).call(this,P(this,Se)[t])&&(yield P(this,Se)[t])}[(Ap=Symbol.iterator,xp=Symbol.toStringTag,Ap)](){return this.entries()}find(t,n={}){for(const i of de(this,le,ni).call(this)){const o=P(this,Se)[i],s=de(this,le,wt).call(this,o)?o.__staleWhileFetching:o;if(s!==void 0&&t(s,P(this,mt)[i],this))return this.get(P(this,mt)[i],n)}}forEach(t,n=this){for(const i of de(this,le,ni).call(this)){const o=P(this,Se)[i],s=de(this,le,wt).call(this,o)?o.__staleWhileFetching:o;s!==void 0&&t.call(n,s,P(this,mt)[i],this)}}rforEach(t,n=this){for(const i of de(this,le,ii).call(this)){const o=P(this,Se)[i],s=de(this,le,wt).call(this,o)?o.__staleWhileFetching:o;s!==void 0&&t.call(n,s,P(this,mt)[i],this)}}purgeStale(){let t=!1;for(const n of de(this,le,ii).call(this,{allowStale:!0}))P(this,br).call(this,n)&&(de(this,le,oi).call(this,P(this,mt)[n],"expire"),t=!0);return t}info(t){const n=P(this,It).get(t);if(n===void 0)return;const i=P(this,Se)[n],o=de(this,le,wt).call(this,i)?i.__staleWhileFetching:i;if(o===void 0)return;const s={value:o};if(P(this,mr)&&P(this,Yr)){const a=P(this,mr)[n],c=P(this,Yr)[n];if(a&&c){const f=a-(no.now()-c);s.ttl=f,s.start=Date.now()}}return P(this,Jr)&&(s.size=P(this,Jr)[n]),s}dump(){const t=[];for(const n of de(this,le,ni).call(this,{allowStale:!0})){const i=P(this,mt)[n],o=P(this,Se)[n],s=de(this,le,wt).call(this,o)?o.__staleWhileFetching:o;if(s===void 0||i===void 0)continue;const a={value:s};if(P(this,mr)&&P(this,Yr)){a.ttl=P(this,mr)[n];const c=no.now()-P(this,Yr)[n];a.start=Math.floor(Date.now()-c)}P(this,Jr)&&(a.size=P(this,Jr)[n]),t.unshift([i,a])}return t}load(t){this.clear();for(const[n,i]of t){if(i.start){const o=Date.now()-i.start;i.start=no.now()-o}this.set(n,i.value,i)}}set(t,n,i={}){var x,S,D,E,_;if(n===void 0)return this.delete(t),this;const{ttl:o=this.ttl,start:s,noDisposeOnSet:a=this.noDisposeOnSet,sizeCalculation:c=this.sizeCalculation,status:f}=i;let{noUpdateTTL:h=this.noUpdateTTL}=i;const d=P(this,Ss).call(this,t,n,i.size||0,c);if(this.maxEntrySize&&d>this.maxEntrySize)return f&&(f.set="miss",f.maxEntrySizeExceeded=!0),de(this,le,oi).call(this,t,"set"),this;let g=P(this,kt)===0?void 0:P(this,It).get(t);if(g===void 0)g=P(this,kt)===0?P(this,Pt):P(this,Wr).length!==0?P(this,Wr).pop():P(this,kt)===P(this,Kr)?de(this,le,da).call(this,!1):P(this,kt),P(this,mt)[g]=t,P(this,Se)[g]=n,P(this,It).set(t,g),P(this,er)[P(this,Pt)]=g,P(this,wr)[g]=P(this,Pt),we(this,Pt,g),Ks(this,kt)._++,P(this,wo).call(this,g,d,f),f&&(f.set="add"),h=!1;else{de(this,le,Wo).call(this,g);const T=P(this,Se)[g];if(n!==T){if(P(this,ai)&&de(this,le,wt).call(this,T)){T.__abortController.abort(new Error("replaced"));const{__staleWhileFetching:F}=T;F!==void 0&&!a&&(P(this,Zr)&&((x=P(this,zr))==null||x.call(this,F,t,"set")),P(this,tr)&&((S=P(this,Ft))==null||S.push([F,t,"set"])))}else a||(P(this,Zr)&&((D=P(this,zr))==null||D.call(this,T,t,"set")),P(this,tr)&&((E=P(this,Ft))==null||E.push([T,t,"set"])));if(P(this,Oi).call(this,g),P(this,wo).call(this,g,d,f),P(this,Se)[g]=n,f){f.set="replace";const F=T&&de(this,le,wt).call(this,T)?T.__staleWhileFetching:T;F!==void 0&&(f.oldValue=F)}}else f&&(f.set="update")}if(o!==0&&!P(this,mr)&&de(this,le,du).call(this),P(this,mr)&&(h||P(this,Es).call(this,g,o,s),f&&P(this,Dn).call(this,f,g)),!a&&P(this,tr)&&P(this,Ft)){const T=P(this,Ft);let F;for(;F=T==null?void 0:T.shift();)(_=P(this,qr))==null||_.call(this,...F)}return this}pop(){var t;try{for(;P(this,kt);){const n=P(this,Se)[P(this,Jt)];if(de(this,le,da).call(this,!0),de(this,le,wt).call(this,n)){if(n.__staleWhileFetching)return n.__staleWhileFetching}else if(n!==void 0)return n}}finally{if(P(this,tr)&&P(this,Ft)){const n=P(this,Ft);let i;for(;i=n==null?void 0:n.shift();)(t=P(this,qr))==null||t.call(this,...i)}}}has(t,n={}){const{updateAgeOnHas:i=this.updateAgeOnHas,status:o}=n,s=P(this,It).get(t);if(s!==void 0){const a=P(this,Se)[s];if(de(this,le,wt).call(this,a)&&a.__staleWhileFetching===void 0)return!1;if(P(this,br).call(this,s))o&&(o.has="stale",P(this,Dn).call(this,o,s));else return i&&P(this,Ui).call(this,s),o&&(o.has="hit",P(this,Dn).call(this,o,s)),!0}else o&&(o.has="miss");return!1}peek(t,n={}){const{allowStale:i=this.allowStale}=n,o=P(this,It).get(t);if(o===void 0||!i&&P(this,br).call(this,o))return;const s=P(this,Se)[o];return de(this,le,wt).call(this,s)?s.__staleWhileFetching:s}async fetch(t,n={}){const{allowStale:i=this.allowStale,updateAgeOnGet:o=this.updateAgeOnGet,noDeleteOnStaleGet:s=this.noDeleteOnStaleGet,ttl:a=this.ttl,noDisposeOnSet:c=this.noDisposeOnSet,size:f=0,sizeCalculation:h=this.sizeCalculation,noUpdateTTL:d=this.noUpdateTTL,noDeleteOnFetchRejection:g=this.noDeleteOnFetchRejection,allowStaleOnFetchRejection:x=this.allowStaleOnFetchRejection,ignoreFetchAbort:S=this.ignoreFetchAbort,allowStaleOnFetchAbort:D=this.allowStaleOnFetchAbort,context:E,forceRefresh:_=!1,status:T,signal:F}=n;if(!P(this,ai))return T&&(T.fetch="get"),this.get(t,{allowStale:i,updateAgeOnGet:o,noDeleteOnStaleGet:s,status:T});const U={allowStale:i,updateAgeOnGet:o,noDeleteOnStaleGet:s,ttl:a,noDisposeOnSet:c,size:f,sizeCalculation:h,noUpdateTTL:d,noDeleteOnFetchRejection:g,allowStaleOnFetchRejection:x,allowStaleOnFetchAbort:D,ignoreFetchAbort:S,status:T,signal:F};let z=P(this,It).get(t);if(z===void 0){T&&(T.fetch="miss");const V=de(this,le,pa).call(this,t,z,U,E);return V.__returned=V}else{const V=P(this,Se)[z];if(de(this,le,wt).call(this,V)){const se=i&&V.__staleWhileFetching!==void 0;return T&&(T.fetch="inflight",se&&(T.returnedStale=!0)),se?V.__staleWhileFetching:V.__returned=V}const G=P(this,br).call(this,z);if(!_&&!G)return T&&(T.fetch="hit"),de(this,le,Wo).call(this,z),o&&P(this,Ui).call(this,z),T&&P(this,Dn).call(this,T,z),V;const ee=de(this,le,pa).call(this,t,z,U,E),X=ee.__staleWhileFetching!==void 0&&i;return T&&(T.fetch=G?"stale":"refresh",X&&G&&(T.returnedStale=!0)),X?ee.__staleWhileFetching:ee.__returned=ee}}async forceFetch(t,n={}){const i=await this.fetch(t,n);if(i===void 0)throw new Error("fetch() returned undefined");return i}memo(t,n={}){const i=P(this,yo);if(!i)throw new Error("no memoMethod provided to constructor");const{context:o,forceRefresh:s,...a}=n,c=this.get(t,a);if(!s&&c!==void 0)return c;const f=i(t,c,{options:a,context:o});return this.set(t,f,a),f}get(t,n={}){const{allowStale:i=this.allowStale,updateAgeOnGet:o=this.updateAgeOnGet,noDeleteOnStaleGet:s=this.noDeleteOnStaleGet,status:a}=n,c=P(this,It).get(t);if(c!==void 0){const f=P(this,Se)[c],h=de(this,le,wt).call(this,f);return a&&P(this,Dn).call(this,a,c),P(this,br).call(this,c)?(a&&(a.get="stale"),h?(a&&i&&f.__staleWhileFetching!==void 0&&(a.returnedStale=!0),i?f.__staleWhileFetching:void 0):(s||de(this,le,oi).call(this,t,"expire"),a&&i&&(a.returnedStale=!0),i?f:void 0)):(a&&(a.get="hit"),h?f.__staleWhileFetching:(de(this,le,Wo).call(this,c),o&&P(this,Ui).call(this,c),f))}else a&&(a.get="miss")}delete(t){return de(this,le,oi).call(this,t,"delete")}clear(){return de(this,le,yu).call(this,"delete")}};Kr=new WeakMap,yr=new WeakMap,zr=new WeakMap,qr=new WeakMap,go=new WeakMap,yo=new WeakMap,kt=new WeakMap,Gr=new WeakMap,It=new WeakMap,mt=new WeakMap,Se=new WeakMap,er=new WeakMap,wr=new WeakMap,Jt=new WeakMap,Pt=new WeakMap,Wr=new WeakMap,Ft=new WeakMap,Jr=new WeakMap,Yr=new WeakMap,mr=new WeakMap,Zr=new WeakMap,ai=new WeakMap,tr=new WeakMap,le=new WeakSet,du=function(){const t=new ha(P(this,Kr)),n=new ha(P(this,Kr));we(this,mr,t),we(this,Yr,n),we(this,Es,(s,a,c=no.now())=>{if(n[s]=a!==0?c:0,t[s]=a,a!==0&&this.ttlAutopurge){const f=setTimeout(()=>{P(this,br).call(this,s)&&de(this,le,oi).call(this,P(this,mt)[s],"expire")},a+1);f.unref&&f.unref()}}),we(this,Ui,s=>{n[s]=t[s]!==0?no.now():0}),we(this,Dn,(s,a)=>{if(t[a]){const c=t[a],f=n[a];if(!c||!f)return;s.ttl=c,s.start=f,s.now=i||o();const h=s.now-f;s.remainingTTL=c-h}});let i=0;const o=()=>{const s=no.now();if(this.ttlResolution>0){i=s;const a=setTimeout(()=>i=0,this.ttlResolution);a.unref&&a.unref()}return s};this.getRemainingTTL=s=>{const a=P(this,It).get(s);if(a===void 0)return 0;const c=t[a],f=n[a];if(!c||!f)return 1/0;const h=(i||o())-f;return c-h},we(this,br,s=>{const a=n[s],c=t[s];return!!c&&!!a&&(i||o())-a>c})},Ui=new WeakMap,Dn=new WeakMap,Es=new WeakMap,br=new WeakMap,tg=function(){const t=new ha(P(this,Kr));we(this,Gr,0),we(this,Jr,t),we(this,Oi,n=>{we(this,Gr,P(this,Gr)-t[n]),t[n]=0}),we(this,Ss,(n,i,o,s)=>{if(de(this,le,wt).call(this,i))return 0;if(!ri(o))if(s){if(typeof s!="function")throw new TypeError("sizeCalculation must be a function");if(o=s(i,n),!ri(o))throw new TypeError("sizeCalculation return invalid (expect positive integer)")}else throw new TypeError("invalid size value (must be positive integer). When maxSize or maxEntrySize is used, sizeCalculation or size must be set.");return o}),we(this,wo,(n,i,o)=>{if(t[n]=i,P(this,yr)){const s=P(this,yr)-t[n];for(;P(this,Gr)>s;)de(this,le,da).call(this,!0)}we(this,Gr,P(this,Gr)+t[n]),o&&(o.entrySize=i,o.totalCalculatedSize=P(this,Gr))})},Oi=new WeakMap,wo=new WeakMap,Ss=new WeakMap,ni=function*({allowStale:t=this.allowStale}={}){if(P(this,kt))for(let n=P(this,Pt);!(!de(this,le,pu).call(this,n)||((t||!P(this,br).call(this,n))&&(yield n),n===P(this,Jt)));)n=P(this,wr)[n]},ii=function*({allowStale:t=this.allowStale}={}){if(P(this,kt))for(let n=P(this,Jt);!(!de(this,le,pu).call(this,n)||((t||!P(this,br).call(this,n))&&(yield n),n===P(this,Pt)));)n=P(this,er)[n]},pu=function(t){return t!==void 0&&P(this,It).get(P(this,mt)[t])===t},da=function(t){var s,a;const n=P(this,Jt),i=P(this,mt)[n],o=P(this,Se)[n];return P(this,ai)&&de(this,le,wt).call(this,o)?o.__abortController.abort(new Error("evicted")):(P(this,Zr)||P(this,tr))&&(P(this,Zr)&&((s=P(this,zr))==null||s.call(this,o,i,"evict")),P(this,tr)&&((a=P(this,Ft))==null||a.push([o,i,"evict"]))),P(this,Oi).call(this,n),t&&(P(this,mt)[n]=void 0,P(this,Se)[n]=void 0,P(this,Wr).push(n)),P(this,kt)===1?(we(this,Jt,we(this,Pt,0)),P(this,Wr).length=0):we(this,Jt,P(this,er)[n]),P(this,It).delete(i),Ks(this,kt)._--,n},pa=function(t,n,i,o){const s=n===void 0?void 0:P(this,Se)[n];if(de(this,le,wt).call(this,s))return s;const a=new ka,{signal:c}=i;c==null||c.addEventListener("abort",()=>a.abort(c.reason),{signal:a.signal});const f={signal:a.signal,options:i,context:o},h=(E,_=!1)=>{const{aborted:T}=a.signal,F=i.ignoreFetchAbort&&E!==void 0;if(i.status&&(T&&!_?(i.status.fetchAborted=!0,i.status.fetchError=a.signal.reason,F&&(i.status.fetchAbortIgnored=!0)):i.status.fetchResolved=!0),T&&!F&&!_)return g(a.signal.reason);const U=S;return P(this,Se)[n]===S&&(E===void 0?U.__staleWhileFetching?P(this,Se)[n]=U.__staleWhileFetching:de(this,le,oi).call(this,t,"fetch"):(i.status&&(i.status.fetchUpdated=!0),this.set(t,E,f.options))),E},d=E=>(i.status&&(i.status.fetchRejected=!0,i.status.fetchError=E),g(E)),g=E=>{const{aborted:_}=a.signal,T=_&&i.allowStaleOnFetchAbort,F=T||i.allowStaleOnFetchRejection,U=F||i.noDeleteOnFetchRejection,z=S;if(P(this,Se)[n]===S&&(!U||z.__staleWhileFetching===void 0?de(this,le,oi).call(this,t,"fetch"):T||(P(this,Se)[n]=z.__staleWhileFetching)),F)return i.status&&z.__staleWhileFetching!==void 0&&(i.status.returnedStale=!0),z.__staleWhileFetching;if(z.__returned===z)throw E},x=(E,_)=>{var F;const T=(F=P(this,go))==null?void 0:F.call(this,t,s,f);T&&T instanceof Promise&&T.then(U=>E(U===void 0?void 0:U),_),a.signal.addEventListener("abort",()=>{(!i.ignoreFetchAbort||i.allowStaleOnFetchAbort)&&(E(void 0),i.allowStaleOnFetchAbort&&(E=U=>h(U,!0)))})};i.status&&(i.status.fetchDispatched=!0);const S=new Promise(x).then(h,d),D=Object.assign(S,{__abortController:a,__staleWhileFetching:s,__returned:void 0});return n===void 0?(this.set(t,D,{...f.options,status:void 0}),n=P(this,It).get(t)):P(this,Se)[n]=D,D},wt=function(t){if(!P(this,ai))return!1;const n=t;return!!n&&n instanceof Promise&&n.hasOwnProperty("__staleWhileFetching")&&n.__abortController instanceof ka},gu=function(t,n){P(this,wr)[n]=t,P(this,er)[t]=n},Wo=function(t){t!==P(this,Pt)&&(t===P(this,Jt)?we(this,Jt,P(this,er)[t]):de(this,le,gu).call(this,P(this,wr)[t],P(this,er)[t]),de(this,le,gu).call(this,P(this,Pt),t),we(this,Pt,t))},oi=function(t,n){var o,s,a,c;let i=!1;if(P(this,kt)!==0){const f=P(this,It).get(t);if(f!==void 0)if(i=!0,P(this,kt)===1)de(this,le,yu).call(this,n);else{P(this,Oi).call(this,f);const h=P(this,Se)[f];if(de(this,le,wt).call(this,h)?h.__abortController.abort(new Error("deleted")):(P(this,Zr)||P(this,tr))&&(P(this,Zr)&&((o=P(this,zr))==null||o.call(this,h,t,n)),P(this,tr)&&((s=P(this,Ft))==null||s.push([h,t,n]))),P(this,It).delete(t),P(this,mt)[f]=void 0,P(this,Se)[f]=void 0,f===P(this,Pt))we(this,Pt,P(this,wr)[f]);else if(f===P(this,Jt))we(this,Jt,P(this,er)[f]);else{const d=P(this,wr)[f];P(this,er)[d]=P(this,er)[f];const g=P(this,er)[f];P(this,wr)[g]=P(this,wr)[f]}Ks(this,kt)._--,P(this,Wr).push(f)}}if(P(this,tr)&&((a=P(this,Ft))!=null&&a.length)){const f=P(this,Ft);let h;for(;h=f==null?void 0:f.shift();)(c=P(this,qr))==null||c.call(this,...h)}return i},yu=function(t){var n,i,o;for(const s of de(this,le,ii).call(this,{allowStale:!0})){const a=P(this,Se)[s];if(de(this,le,wt).call(this,a))a.__abortController.abort(new Error("deleted"));else{const c=P(this,mt)[s];P(this,Zr)&&((n=P(this,zr))==null||n.call(this,a,c,t)),P(this,tr)&&((i=P(this,Ft))==null||i.push([a,c,t]))}}if(P(this,It).clear(),P(this,Se).fill(void 0),P(this,mt).fill(void 0),P(this,mr)&&P(this,Yr)&&(P(this,mr).fill(0),P(this,Yr).fill(0)),P(this,Jr)&&P(this,Jr).fill(0),we(this,Jt,0),we(this,Pt,0),P(this,Wr).length=0,we(this,Gr,0),we(this,kt,0),P(this,tr)&&P(this,Ft)){const s=P(this,Ft);let a;for(;a=s==null?void 0:s.shift();)(o=P(this,qr))==null||o.call(this,...a)}};let hu=Gh,wu;try{wu=new TextDecoder}catch{}let pe,Pi,ie=0;const iv=105,ov=57342,sv=57343,Hd=57337,$d=6,io={};let Vo=11281e4,bn=1681e4,Re={},Bt,Ta,Na=0,fs=0,Nt,_r,Mt=[],mu=[],hr,nr,Jo,Vd={useRecords:!1,mapsAsObjects:!0},us=!1,rg=2;try{new Function("")}catch{rg=1/0}let ng=class bu{constructor(t){if(t&&((t.keyMap||t._keyMap)&&!t.useRecords&&(t.useRecords=!1,t.mapsAsObjects=!0),t.useRecords===!1&&t.mapsAsObjects===void 0&&(t.mapsAsObjects=!0),t.getStructures&&(t.getShared=t.getStructures),t.getShared&&!t.structures&&((t.structures=[]).uninitialized=!0),t.keyMap)){this.mapKey=new Map;for(let[n,i]of Object.entries(t.keyMap))this.mapKey.set(i,n)}Object.assign(this,t)}decodeKey(t){return this.keyMap&&this.mapKey.get(t)||t}encodeKey(t){return this.keyMap&&this.keyMap.hasOwnProperty(t)?this.keyMap[t]:t}encodeKeys(t){if(!this._keyMap)return t;let n=new Map;for(let[i,o]of Object.entries(t))n.set(this._keyMap.hasOwnProperty(i)?this._keyMap[i]:i,o);return n}decodeKeys(t){if(!this._keyMap||t.constructor.name!="Map")return t;if(!this._mapKey){this._mapKey=new Map;for(let[i,o]of Object.entries(this._keyMap))this._mapKey.set(o,i)}let n={};return t.forEach((i,o)=>n[Mr(this._mapKey.has(o)?this._mapKey.get(o):o)]=i),n}mapDecode(t,n){let i=this.decode(t);if(this._keyMap)switch(i.constructor.name){case"Array":return i.map(o=>this.decodeKeys(o))}return i}decode(t,n){if(pe)return ag(()=>(Eu(),this?this.decode(t,n):bu.prototype.decode.call(Vd,t,n)));Pi=n>-1?n:t.length,ie=0,fs=0,Ta=null,Nt=null,pe=t;try{nr=t.dataView||(t.dataView=new DataView(t.buffer,t.byteOffset,t.byteLength))}catch(i){throw pe=null,t instanceof Uint8Array?i:new Error("Source must be a Uint8Array or Buffer but was a "+(t&&typeof t=="object"?t.constructor.name:typeof t))}if(this instanceof bu){if(Re=this,hr=this.sharedValues&&(this.pack?new Array(this.maxPrivatePackedValues||16).concat(this.sharedValues):this.sharedValues),this.structures)return Bt=this.structures,Ys();(!Bt||Bt.length>0)&&(Bt=[])}else Re=Vd,(!Bt||Bt.length>0)&&(Bt=[]),hr=null;return Ys()}decodeMultiple(t,n){let i,o=0;try{let s=t.length;us=!0;let a=this?this.decode(t,s):Hl.decode(t,s);if(n){if(n(a)===!1)return;for(;ie<s;)if(o=ie,n(Ys())===!1)return}else{for(i=[a];ie<s;)o=ie,i.push(Ys());return i}}catch(s){throw s.lastPosition=o,s.values=i,s}finally{us=!1,Eu()}}};function Ys(){try{let r=Fe();if(Nt){if(ie>=Nt.postBundlePosition){let t=new Error("Unexpected bundle position");throw t.incomplete=!0,t}ie=Nt.postBundlePosition,Nt=null}if(ie==Pi)Bt=null,pe=null,_r&&(_r=null);else if(ie>Pi){let t=new Error("Unexpected end of CBOR data");throw t.incomplete=!0,t}else if(!us)throw new Error("Data read, but end of buffer not reached");return r}catch(r){throw Eu(),(r instanceof RangeError||r.message.startsWith("Unexpected end of buffer"))&&(r.incomplete=!0),r}}function Fe(){let r=pe[ie++],t=r>>5;if(r=r&31,r>23)switch(r){case 24:r=pe[ie++];break;case 25:if(t==7)return uv();r=nr.getUint16(ie),ie+=2;break;case 26:if(t==7){let n=nr.getFloat32(ie);if(Re.useFloat32>2){let i=Ll[(pe[ie]&127)<<1|pe[ie+1]>>7];return ie+=4,(i*n+(n>0?.5:-.5)>>0)/i}return ie+=4,n}r=nr.getUint32(ie),ie+=4;break;case 27:if(t==7){let n=nr.getFloat64(ie);return ie+=8,n}if(t>1){if(nr.getUint32(ie)>0)throw new Error("JavaScript does not support arrays, maps, or strings with length over 4294967295");r=nr.getUint32(ie+4)}else Re.int64AsNumber?(r=nr.getUint32(ie)*4294967296,r+=nr.getUint32(ie+4)):r=nr.getBigUint64(ie);ie+=8;break;case 31:switch(t){case 2:case 3:throw new Error("Indefinite length not supported for byte or text strings");case 4:let n=[],i,o=0;for(;(i=Fe())!=io;){if(o>=Vo)throw new Error(`Array length exceeds ${Vo}`);n[o++]=i}return t==4?n:t==3?n.join(""):Buffer.concat(n);case 5:let s;if(Re.mapsAsObjects){let a={},c=0;if(Re.keyMap)for(;(s=Fe())!=io;){if(c++>=bn)throw new Error(`Property count exceeds ${bn}`);a[Mr(Re.decodeKey(s))]=Fe()}else for(;(s=Fe())!=io;){if(c++>=bn)throw new Error(`Property count exceeds ${bn}`);a[Mr(s)]=Fe()}return a}else{Jo&&(Re.mapsAsObjects=!0,Jo=!1);let a=new Map;if(Re.keyMap){let c=0;for(;(s=Fe())!=io;){if(c++>=bn)throw new Error(`Map size exceeds ${bn}`);a.set(Re.decodeKey(s),Fe())}}else{let c=0;for(;(s=Fe())!=io;){if(c++>=bn)throw new Error(`Map size exceeds ${bn}`);a.set(s,Fe())}}return a}case 7:return io;default:throw new Error("Invalid major type for indefinite length "+t)}default:throw new Error("Unknown token "+r)}switch(t){case 0:return r;case 1:return~r;case 2:return fv(r);case 3:if(fs>=ie)return Ta.slice(ie-Na,(ie+=r)-Na);if(fs==0&&Pi<140&&r<32){let o=r<16?ig(r):cv(r);if(o!=null)return o}return av(r);case 4:if(r>=Vo)throw new Error(`Array length exceeds ${Vo}`);let n=new Array(r);for(let o=0;o<r;o++)n[o]=Fe();return n;case 5:if(r>=bn)throw new Error(`Map size exceeds ${Vo}`);if(Re.mapsAsObjects){let o={};if(Re.keyMap)for(let s=0;s<r;s++)o[Mr(Re.decodeKey(Fe()))]=Fe();else for(let s=0;s<r;s++)o[Mr(Fe())]=Fe();return o}else{Jo&&(Re.mapsAsObjects=!0,Jo=!1);let o=new Map;if(Re.keyMap)for(let s=0;s<r;s++)o.set(Re.decodeKey(Fe()),Fe());else for(let s=0;s<r;s++)o.set(Fe(),Fe());return o}case 6:if(r>=Hd){let o=Bt[r&8191];if(o)return o.read||(o.read=vu(o)),o.read();if(r<65536){if(r==sv){let s=ao(),a=Fe(),c=Fe();Au(a,c);let f={};if(Re.keyMap)for(let h=2;h<s;h++){let d=Re.decodeKey(c[h-2]);f[Mr(d)]=Fe()}else for(let h=2;h<s;h++){let d=c[h-2];f[Mr(d)]=Fe()}return f}else if(r==ov){let s=ao(),a=Fe();for(let c=2;c<s;c++)Au(a++,Fe());return Fe()}else if(r==Hd)return yv();if(Re.getShared&&(Fl(),o=Bt[r&8191],o))return o.read||(o.read=vu(o)),o.read()}}let i=Mt[r];if(i)return i.handlesRead?i(Fe):i(Fe());{let o=Fe();for(let s=0;s<mu.length;s++){let a=mu[s](r,o);if(a!==void 0)return a}return new No(o,r)}case 7:switch(r){case 20:return!1;case 21:return!0;case 22:return null;case 23:return;case 31:default:let o=(hr||ki())[r];if(o!==void 0)return o;throw new Error("Unknown token "+r)}default:if(isNaN(r)){let o=new Error("Unexpected end of CBOR data");throw o.incomplete=!0,o}throw new Error("Unknown CBOR token "+r)}}const jd=/^[a-zA-Z_$][a-zA-Z\d_$]*$/;function vu(r){if(!r)throw new Error("Structure is required in record definition");function t(){let n=pe[ie++];if(n=n&31,n>23)switch(n){case 24:n=pe[ie++];break;case 25:n=nr.getUint16(ie),ie+=2;break;case 26:n=nr.getUint32(ie),ie+=4;break;default:throw new Error("Expected array header, but got "+pe[ie-1])}let i=this.compiledReader;for(;i;){if(i.propertyCount===n)return i(Fe);i=i.next}if(this.slowReads++>=rg){let s=this.length==n?this:this.slice(0,n);return i=Re.keyMap?new Function("r","return {"+s.map(a=>Re.decodeKey(a)).map(a=>jd.test(a)?Mr(a)+":r()":"["+JSON.stringify(a)+"]:r()").join(",")+"}"):new Function("r","return {"+s.map(a=>jd.test(a)?Mr(a)+":r()":"["+JSON.stringify(a)+"]:r()").join(",")+"}"),this.compiledReader&&(i.next=this.compiledReader),i.propertyCount=n,this.compiledReader=i,i(Fe)}let o={};if(Re.keyMap)for(let s=0;s<n;s++)o[Mr(Re.decodeKey(this[s]))]=Fe();else for(let s=0;s<n;s++)o[Mr(this[s])]=Fe();return o}return r.slowReads=0,t}function Mr(r){if(typeof r=="string")return r==="__proto__"?"__proto_":r;if(typeof r=="number"||typeof r=="boolean"||typeof r=="bigint")return r.toString();if(r==null)return r+"";throw new Error("Invalid property name type "+typeof r)}let av=xu;function xu(r){let t;if(r<16&&(t=ig(r)))return t;if(r>64&&wu)return wu.decode(pe.subarray(ie,ie+=r));const n=ie+r,i=[];for(t="";ie<n;){const o=pe[ie++];if(!(o&128))i.push(o);else if((o&224)===192){const s=pe[ie++]&63;i.push((o&31)<<6|s)}else if((o&240)===224){const s=pe[ie++]&63,a=pe[ie++]&63;i.push((o&31)<<12|s<<6|a)}else if((o&248)===240){const s=pe[ie++]&63,a=pe[ie++]&63,c=pe[ie++]&63;let f=(o&7)<<18|s<<12|a<<6|c;f>65535&&(f-=65536,i.push(f>>>10&1023|55296),f=56320|f&1023),i.push(f)}else i.push(o);i.length>=4096&&(t+=Ot.apply(String,i),i.length=0)}return i.length>0&&(t+=Ot.apply(String,i)),t}let Ot=String.fromCharCode;function cv(r){let t=ie,n=new Array(r);for(let i=0;i<r;i++){const o=pe[ie++];if((o&128)>0){ie=t;return}n[i]=o}return Ot.apply(String,n)}function ig(r){if(r<4)if(r<2){if(r===0)return"";{let t=pe[ie++];if((t&128)>1){ie-=1;return}return Ot(t)}}else{let t=pe[ie++],n=pe[ie++];if((t&128)>0||(n&128)>0){ie-=2;return}if(r<3)return Ot(t,n);let i=pe[ie++];if((i&128)>0){ie-=3;return}return Ot(t,n,i)}else{let t=pe[ie++],n=pe[ie++],i=pe[ie++],o=pe[ie++];if((t&128)>0||(n&128)>0||(i&128)>0||(o&128)>0){ie-=4;return}if(r<6){if(r===4)return Ot(t,n,i,o);{let s=pe[ie++];if((s&128)>0){ie-=5;return}return Ot(t,n,i,o,s)}}else if(r<8){let s=pe[ie++],a=pe[ie++];if((s&128)>0||(a&128)>0){ie-=6;return}if(r<7)return Ot(t,n,i,o,s,a);let c=pe[ie++];if((c&128)>0){ie-=7;return}return Ot(t,n,i,o,s,a,c)}else{let s=pe[ie++],a=pe[ie++],c=pe[ie++],f=pe[ie++];if((s&128)>0||(a&128)>0||(c&128)>0||(f&128)>0){ie-=8;return}if(r<10){if(r===8)return Ot(t,n,i,o,s,a,c,f);{let h=pe[ie++];if((h&128)>0){ie-=9;return}return Ot(t,n,i,o,s,a,c,f,h)}}else if(r<12){let h=pe[ie++],d=pe[ie++];if((h&128)>0||(d&128)>0){ie-=10;return}if(r<11)return Ot(t,n,i,o,s,a,c,f,h,d);let g=pe[ie++];if((g&128)>0){ie-=11;return}return Ot(t,n,i,o,s,a,c,f,h,d,g)}else{let h=pe[ie++],d=pe[ie++],g=pe[ie++],x=pe[ie++];if((h&128)>0||(d&128)>0||(g&128)>0||(x&128)>0){ie-=12;return}if(r<14){if(r===12)return Ot(t,n,i,o,s,a,c,f,h,d,g,x);{let S=pe[ie++];if((S&128)>0){ie-=13;return}return Ot(t,n,i,o,s,a,c,f,h,d,g,x,S)}}else{let S=pe[ie++],D=pe[ie++];if((S&128)>0||(D&128)>0){ie-=14;return}if(r<15)return Ot(t,n,i,o,s,a,c,f,h,d,g,x,S,D);let E=pe[ie++];if((E&128)>0){ie-=15;return}return Ot(t,n,i,o,s,a,c,f,h,d,g,x,S,D,E)}}}}}function fv(r){return Re.copyBuffers?Uint8Array.prototype.slice.call(pe,ie,ie+=r):pe.subarray(ie,ie+=r)}let og=new Float32Array(1),Zs=new Uint8Array(og.buffer,0,4);function uv(){let r=pe[ie++],t=pe[ie++],n=(r&127)>>2;if(n===31)return t||r&3?NaN:r&128?-1/0:1/0;if(n===0){let i=((r&3)<<8|t)/16777216;return r&128?-i:i}return Zs[3]=r&128|(n>>1)+56,Zs[2]=(r&7)<<5|t>>3,Zs[1]=t<<5,Zs[0]=0,og[0]}new Array(4096);class No{constructor(t,n){this.value=t,this.tag=n}}Mt[0]=r=>new Date(r);Mt[1]=r=>new Date(Math.round(r*1e3));Mt[2]=r=>{let t=BigInt(0);for(let n=0,i=r.byteLength;n<i;n++)t=BigInt(r[n])+(t<<BigInt(8));return t};Mt[3]=r=>BigInt(-1)-Mt[2](r);Mt[4]=r=>+(r[1]+"e"+r[0]);Mt[5]=r=>r[1]*Math.exp(r[0]*Math.log(2));const Au=(r,t)=>{r=r-57344;let n=Bt[r];n&&n.isShared&&((Bt.restoreStructures||(Bt.restoreStructures=[]))[r]=n),Bt[r]=t,t.read=vu(t)};Mt[iv]=r=>{let t=r.length,n=r[1];Au(r[0],n);let i={};for(let o=2;o<t;o++){let s=n[o-2];i[Mr(s)]=r[o]}return i};Mt[14]=r=>Nt?Nt[0].slice(Nt.position0,Nt.position0+=r):new No(r,14);Mt[15]=r=>Nt?Nt[1].slice(Nt.position1,Nt.position1+=r):new No(r,15);let lv={Error,RegExp};Mt[27]=r=>(lv[r[0]]||Error)(r[1],r[2]);const sg=r=>{if(pe[ie++]!=132){let n=new Error("Packed values structure must be followed by a 4 element array");throw pe.length<ie&&(n.incomplete=!0),n}let t=r();if(!t||!t.length){let n=new Error("Packed values structure must be followed by a 4 element array");throw n.incomplete=!0,n}return hr=hr?t.concat(hr.slice(t.length)):t,hr.prefixes=r(),hr.suffixes=r(),r()};sg.handlesRead=!0;Mt[51]=sg;Mt[$d]=r=>{if(!hr)if(Re.getShared)Fl();else return new No(r,$d);if(typeof r=="number")return hr[16+(r>=0?2*r:-2*r-1)];let t=new Error("No support for non-integer packed references yet");throw r===void 0&&(t.incomplete=!0),t};Mt[28]=r=>{_r||(_r=new Map,_r.id=0);let t=_r.id++,n=ie,i=pe[ie],o;i>>5==4?o=[]:o={};let s={target:o};_r.set(t,s);let a=r();return s.used?(Object.getPrototypeOf(o)!==Object.getPrototypeOf(a)&&(ie=n,o=a,_r.set(t,{target:o}),a=r()),Object.assign(o,a)):(s.target=a,a)};Mt[28].handlesRead=!0;Mt[29]=r=>{let t=_r.get(r);return t.used=!0,t.target};Mt[258]=r=>new Set(r);(Mt[259]=r=>(Re.mapsAsObjects&&(Re.mapsAsObjects=!1,Jo=!0),r())).handlesRead=!0;function oo(r,t){return typeof r=="string"?r+t:r instanceof Array?r.concat(t):Object.assign({},r,t)}function ki(){if(!hr)if(Re.getShared)Fl();else throw new Error("No packed values available");return hr}const hv=1399353956;mu.push((r,t)=>{if(r>=225&&r<=255)return oo(ki().prefixes[r-224],t);if(r>=28704&&r<=32767)return oo(ki().prefixes[r-28672],t);if(r>=1879052288&&r<=2147483647)return oo(ki().prefixes[r-1879048192],t);if(r>=216&&r<=223)return oo(t,ki().suffixes[r-216]);if(r>=27647&&r<=28671)return oo(t,ki().suffixes[r-27639]);if(r>=1811940352&&r<=1879048191)return oo(t,ki().suffixes[r-1811939328]);if(r==hv)return{packedValues:hr,structures:Bt.slice(0),version:t};if(r==55799)return t});const dv=new Uint8Array(new Uint16Array([1]).buffer)[0]==1,Kd=[Uint8Array,Uint8ClampedArray,Uint16Array,Uint32Array,typeof BigUint64Array>"u"?{name:"BigUint64Array"}:BigUint64Array,Int8Array,Int16Array,Int32Array,typeof BigInt64Array>"u"?{name:"BigInt64Array"}:BigInt64Array,Float32Array,Float64Array],pv=[64,68,69,70,71,72,77,78,79,85,86];for(let r=0;r<Kd.length;r++)gv(Kd[r],pv[r]);function gv(r,t){let n="get"+r.name.slice(0,-5),i;typeof r=="function"?i=r.BYTES_PER_ELEMENT:r=null;for(let o=0;o<2;o++){if(!o&&i==1)continue;let s=i==2?1:i==4?2:i==8?3:0;Mt[o?t:t-4]=i==1||o==dv?a=>{if(!r)throw new Error("Could not find typed array for code "+t);return!Re.copyBuffers&&(i===1||i===2&&!(a.byteOffset&1)||i===4&&!(a.byteOffset&3)||i===8&&!(a.byteOffset&7))?new r(a.buffer,a.byteOffset,a.byteLength>>s):new r(Uint8Array.prototype.slice.call(a,0).buffer)}:a=>{if(!r)throw new Error("Could not find typed array for code "+t);let c=new DataView(a.buffer,a.byteOffset,a.byteLength),f=a.length>>s,h=new r(f),d=c[n];for(let g=0;g<f;g++)h[g]=d.call(c,g<<s,o);return h}}}function yv(){let r=ao(),t=ie+Fe();for(let i=2;i<r;i++){let o=ao();ie+=o}let n=ie;return ie=t,Nt=[xu(ao()),xu(ao())],Nt.position0=0,Nt.position1=0,Nt.postBundlePosition=ie,ie=n,Fe()}function ao(){let r=pe[ie++]&31;if(r>23)switch(r){case 24:r=pe[ie++];break;case 25:r=nr.getUint16(ie),ie+=2;break;case 26:r=nr.getUint32(ie),ie+=4;break}return r}function Fl(){if(Re.getShared){let r=ag(()=>(pe=null,Re.getShared()))||{},t=r.structures||[];Re.sharedVersion=r.version,hr=Re.sharedValues=r.packedValues,Bt===!0?Re.structures=Bt=t:Bt.splice.apply(Bt,[0,t.length].concat(t))}}function ag(r){let t=Pi,n=ie,i=Na,o=fs,s=Ta,a=_r,c=Nt,f=new Uint8Array(pe.slice(0,Pi)),h=Bt,d=Re,g=us,x=r();return Pi=t,ie=n,Na=i,fs=o,Ta=s,_r=a,Nt=c,pe=f,us=g,Bt=h,Re=d,nr=new DataView(pe.buffer,pe.byteOffset,pe.byteLength),x}function Eu(){pe=null,_r=null,Bt=null}const Ll=new Array(147);for(let r=0;r<256;r++)Ll[r]=+("1e"+Math.floor(45.15-r*.30103));let Hl=new ng({useRecords:!1});const wv=Hl.decode;Hl.decodeMultiple;let ga;try{ga=new TextEncoder}catch{}let Su,cg;const oc=typeof globalThis=="object"&&globalThis.Buffer,Is=typeof oc<"u",kf=Is?oc.allocUnsafeSlow:Uint8Array,zd=Is?oc:Uint8Array,qd=256,Gd=Is?4294967296:2144337920;let Tf,J,bt,$=0,Zn,Tt=null;const mv=61440,bv=/[\u0080-\uFFFF]/,pr=Symbol("record-id");let vv=class extends ng{constructor(t){super(t),this.offset=0;let n,i,o,s,a;t=t||{};let c=zd.prototype.utf8Write?function(v,u,l){return J.utf8Write(v,u,l)}:ga&&ga.encodeInto?function(v,u){return ga.encodeInto(v,J.subarray(u)).written}:!1,f=this,h=t.structures||t.saveStructures,d=t.maxSharedStructures;if(d==null&&(d=h?128:0),d>8190)throw new Error("Maximum maxSharedStructure is 8190");let g=t.sequential;g&&(d=0),this.structures||(this.structures=[]),this.saveStructures&&(this.saveShared=this.saveStructures);let x,S,D=t.sharedValues,E;if(D){E=Object.create(null);for(let v=0,u=D.length;v<u;v++)E[D[v]]=v}let _=[],T=0,F=0;this.mapEncode=function(v,u){if(this._keyMap&&!this._mapped)switch(v.constructor.name){case"Array":v=v.map(l=>this.encodeKeys(l));break}return this.encode(v,u)},this.encode=function(v,u){if(J||(J=new kf(8192),bt=new DataView(J.buffer,0,8192),$=0),Zn=J.length-10,Zn-$<2048?(J=new kf(J.length),bt=new DataView(J.buffer,0,J.length),Zn=J.length-10,$=0):u===Yd&&($=$+7&2147483640),n=$,f.useSelfDescribedHeader&&(bt.setUint32($,3654940416),$+=3),a=f.structuredClone?new Map:null,f.bundleStrings&&typeof v!="string"?(Tt=[],Tt.size=1/0):Tt=null,i=f.structures,i){if(i.uninitialized){let p=f.getShared()||{};f.structures=i=p.structures||[],f.sharedVersion=p.version;let w=f.sharedValues=p.packedValues;if(w){E={};for(let A=0,C=w.length;A<C;A++)E[w[A]]=A}}let l=i.length;if(l>d&&!g&&(l=d),!i.transitions){i.transitions=Object.create(null);for(let p=0;p<l;p++){let w=i[p];if(!w)continue;let A,C=i.transitions;for(let k=0,I=w.length;k<I;k++){C[pr]===void 0&&(C[pr]=p);let y=w[k];A=C[y],A||(A=C[y]=Object.create(null)),C=A}C[pr]=p|1048576}}g||(i.nextId=l)}if(o&&(o=!1),s=i||[],S=E,t.pack){let l=new Map;if(l.values=[],l.encoder=f,l.maxValues=t.maxPrivatePackedValues||(E?16:1/0),l.objectMap=E||!1,l.samplingPackedValues=x,ya(v,l),l.values.length>0){J[$++]=216,J[$++]=51,un(4);let p=l.values;U(p),un(0),un(0),S=Object.create(E||null);for(let w=0,A=p.length;w<A;w++)S[p[w]]=w}}Tf=u&Rf;try{if(Tf)return;if(U(v),Tt&&Jd(n,U),f.offset=$,a&&a.idsToInsert){$+=a.idsToInsert.length*2,$>Zn&&V($),f.offset=$;let l=Ev(J.subarray(n,$),a.idsToInsert);return a=null,l}return u&Yd?(J.start=n,J.end=$,J):J.subarray(n,$)}finally{if(i){if(F<10&&F++,i.length>d&&(i.length=d),T>1e4)i.transitions=null,F=0,T=0,_.length>0&&(_=[]);else if(_.length>0&&!g){for(let l=0,p=_.length;l<p;l++)_[l][pr]=void 0;_=[]}}if(o&&f.saveShared){f.structures.length>d&&(f.structures=f.structures.slice(0,d));let l=J.subarray(n,$);return f.updateSharedData()===!1?f.encode(v):l}u&Sv&&($=n)}},this.findCommonStringsToPack=()=>(x=new Map,E||(E=Object.create(null)),v=>{let u=v&&v.threshold||4,l=this.pack?v.maxPrivatePackedValues||16:0;D||(D=this.sharedValues=[]);for(let[p,w]of x)w.count>u&&(E[p]=l++,D.push(p),o=!0);for(;this.saveShared&&this.updateSharedData()===!1;);x=null});const U=v=>{$>Zn&&(J=V($));var u=typeof v,l;if(u==="string"){if(S){let C=S[v];if(C>=0){C<16?J[$++]=C+224:(J[$++]=198,C&1?U(15-C>>1):U(C-16>>1));return}else if(x&&!t.pack){let k=x.get(v);k?k.count++:x.set(v,{count:1})}}let p=v.length;if(Tt&&p>=4&&p<1024){if((Tt.size+=p)>mv){let k,I=(Tt[0]?Tt[0].length*3+Tt[1].length:0)+10;$+I>Zn&&(J=V($+I)),J[$++]=217,J[$++]=223,J[$++]=249,J[$++]=Tt.position?132:130,J[$++]=26,k=$-n,$+=4,Tt.position&&Jd(n,U),Tt=["",""],Tt.size=0,Tt.position=k}let C=bv.test(v);Tt[C?0:1]+=v,J[$++]=C?206:207,U(p);return}let w;p<32?w=1:p<256?w=2:p<65536?w=3:w=5;let A=p*3;if($+A>Zn&&(J=V($+A)),p<64||!c){let C,k,I,y=$+w;for(C=0;C<p;C++)k=v.charCodeAt(C),k<128?J[y++]=k:k<2048?(J[y++]=k>>6|192,J[y++]=k&63|128):(k&64512)===55296&&((I=v.charCodeAt(C+1))&64512)===56320?(k=65536+((k&1023)<<10)+(I&1023),C++,J[y++]=k>>18|240,J[y++]=k>>12&63|128,J[y++]=k>>6&63|128,J[y++]=k&63|128):(J[y++]=k>>12|224,J[y++]=k>>6&63|128,J[y++]=k&63|128);l=y-$-w}else l=c(v,$+w,A);l<24?J[$++]=96|l:l<256?(w<2&&J.copyWithin($+2,$+1,$+1+l),J[$++]=120,J[$++]=l):l<65536?(w<3&&J.copyWithin($+3,$+2,$+2+l),J[$++]=121,J[$++]=l>>8,J[$++]=l&255):(w<5&&J.copyWithin($+5,$+3,$+3+l),J[$++]=122,bt.setUint32($,l),$+=4),$+=l}else if(u==="number")if(!this.alwaysUseFloat&&v>>>0===v)v<24?J[$++]=v:v<256?(J[$++]=24,J[$++]=v):v<65536?(J[$++]=25,J[$++]=v>>8,J[$++]=v&255):(J[$++]=26,bt.setUint32($,v),$+=4);else if(!this.alwaysUseFloat&&v>>0===v)v>=-24?J[$++]=31-v:v>=-256?(J[$++]=56,J[$++]=~v):v>=-65536?(J[$++]=57,bt.setUint16($,~v),$+=2):(J[$++]=58,bt.setUint32($,~v),$+=4);else{let p;if((p=this.useFloat32)>0&&v<4294967296&&v>=-2147483648){J[$++]=250,bt.setFloat32($,v);let w;if(p<4||(w=v*Ll[(J[$]&127)<<1|J[$+1]>>7])>>0===w){$+=4;return}else $--}J[$++]=251,bt.setFloat64($,v),$+=8}else if(u==="object")if(!v)J[$++]=246;else{if(a){let w=a.get(v);if(w){if(J[$++]=216,J[$++]=29,J[$++]=25,!w.references){let A=a.idsToInsert||(a.idsToInsert=[]);w.references=[],A.push(w)}w.references.push($-n),$+=2;return}else a.set(v,{offset:$-n})}let p=v.constructor;if(p===Object)z(v);else if(p===Array){l=v.length,l<24?J[$++]=128|l:un(l);for(let w=0;w<l;w++)U(v[w])}else if(p===Map)if((this.mapsAsObjects?this.useTag259ForMaps!==!1:this.useTag259ForMaps)&&(J[$++]=217,J[$++]=1,J[$++]=3),l=v.size,l<24?J[$++]=160|l:l<256?(J[$++]=184,J[$++]=l):l<65536?(J[$++]=185,J[$++]=l>>8,J[$++]=l&255):(J[$++]=186,bt.setUint32($,l),$+=4),f.keyMap)for(let[w,A]of v)U(f.encodeKey(w)),U(A);else for(let[w,A]of v)U(w),U(A);else{for(let w=0,A=Su.length;w<A;w++){let C=cg[w];if(v instanceof C){let k=Su[w],I=k.tag;I==null&&(I=k.getTag&&k.getTag.call(this,v)),I<24?J[$++]=192|I:I<256?(J[$++]=216,J[$++]=I):I<65536?(J[$++]=217,J[$++]=I>>8,J[$++]=I&255):I>-1&&(J[$++]=218,bt.setUint32($,I),$+=4),k.encode.call(this,v,U,V);return}}if(v[Symbol.iterator]){if(Tf){let w=new Error("Iterable should be serialized as iterator");throw w.iteratorNotHandled=!0,w}J[$++]=159;for(let w of v)U(w);J[$++]=255;return}if(v[Symbol.asyncIterator]||Nf(v)){let w=new Error("Iterable/blob should be serialized as iterator");throw w.iteratorNotHandled=!0,w}if(this.useToJSON&&v.toJSON){const w=v.toJSON();if(w!==v)return U(w)}z(v)}}else if(u==="boolean")J[$++]=v?245:244;else if(u==="bigint"){if(v<BigInt(1)<<BigInt(64)&&v>=0)J[$++]=27,bt.setBigUint64($,v);else if(v>-(BigInt(1)<<BigInt(64))&&v<0)J[$++]=59,bt.setBigUint64($,-v-BigInt(1));else if(this.largeBigIntToFloat)J[$++]=251,bt.setFloat64($,Number(v));else{v>=BigInt(0)?J[$++]=194:(J[$++]=195,v=BigInt(-1)-v);let p=[];for(;v;)p.push(Number(v&BigInt(255))),v>>=BigInt(8);Bu(new Uint8Array(p.reverse()),V);return}$+=8}else if(u==="undefined")J[$++]=247;else throw new Error("Unknown type: "+u)},z=this.useRecords===!1?this.variableMapSize?v=>{let u=Object.keys(v),l=Object.values(v),p=u.length;if(p<24?J[$++]=160|p:p<256?(J[$++]=184,J[$++]=p):p<65536?(J[$++]=185,J[$++]=p>>8,J[$++]=p&255):(J[$++]=186,bt.setUint32($,p),$+=4),f.keyMap)for(let w=0;w<p;w++)U(f.encodeKey(u[w])),U(l[w]);else for(let w=0;w<p;w++)U(u[w]),U(l[w])}:v=>{J[$++]=185;let u=$-n;$+=2;let l=0;if(f.keyMap)for(let p in v)(typeof v.hasOwnProperty!="function"||v.hasOwnProperty(p))&&(U(f.encodeKey(p)),U(v[p]),l++);else for(let p in v)(typeof v.hasOwnProperty!="function"||v.hasOwnProperty(p))&&(U(p),U(v[p]),l++);J[u+++n]=l>>8,J[u+n]=l&255}:(v,u)=>{let l,p=s.transitions||(s.transitions=Object.create(null)),w=0,A=0,C,k;if(this.keyMap){k=Object.keys(v).map(y=>this.encodeKey(y)),A=k.length;for(let y=0;y<A;y++){let N=k[y];l=p[N],l||(l=p[N]=Object.create(null),w++),p=l}}else for(let y in v)(typeof v.hasOwnProperty!="function"||v.hasOwnProperty(y))&&(l=p[y],l||(p[pr]&1048576&&(C=p[pr]&65535),l=p[y]=Object.create(null),w++),p=l,A++);let I=p[pr];if(I!==void 0)I&=65535,J[$++]=217,J[$++]=I>>8|224,J[$++]=I&255;else if(k||(k=p.__keys__||(p.__keys__=Object.keys(v))),C===void 0?(I=s.nextId++,I||(I=0,s.nextId=1),I>=qd&&(s.nextId=(I=d)+1)):I=C,s[I]=k,I<d){J[$++]=217,J[$++]=I>>8|224,J[$++]=I&255,p=s.transitions;for(let y=0;y<A;y++)(p[pr]===void 0||p[pr]&1048576)&&(p[pr]=I),p=p[k[y]];p[pr]=I|1048576,o=!0}else{if(p[pr]=I,bt.setUint32($,3655335680),$+=3,w&&(T+=F*w),_.length>=qd-d&&(_.shift()[pr]=void 0),_.push(p),un(A+2),U(57344+I),U(k),u)return;for(let y in v)(typeof v.hasOwnProperty!="function"||v.hasOwnProperty(y))&&U(v[y]);return}if(A<24?J[$++]=128|A:un(A),!u)for(let y in v)(typeof v.hasOwnProperty!="function"||v.hasOwnProperty(y))&&U(v[y])},V=v=>{let u;if(v>16777216){if(v-n>Gd)throw new Error("Encoded buffer would be larger than maximum buffer size");u=Math.min(Gd,Math.round(Math.max((v-n)*(v>67108864?1.25:2),4194304)/4096)*4096)}else u=(Math.max(v-n<<2,J.length-1)>>12)+1<<12;let l=new kf(u);return bt=new DataView(l.buffer,0,u),J.copy?J.copy(l,0,n,v):l.set(J.slice(n,v)),$-=n,n=0,Zn=l.length-10,J=l};let G=100,ee=1e3;this.encodeAsIterable=function(v,u){return oe(v,u,Q)},this.encodeAsAsyncIterable=function(v,u){return oe(v,u,H)};function*Q(v,u,l){let p=v.constructor;if(p===Object){let w=f.useRecords!==!1;w?z(v,!0):Wd(Object.keys(v).length,160);for(let A in v){let C=v[A];w||U(A),C&&typeof C=="object"?u[A]?yield*Q(C,u[A]):yield*X(C,u,A):U(C)}}else if(p===Array){let w=v.length;un(w);for(let A=0;A<w;A++){let C=v[A];C&&(typeof C=="object"||$-n>G)?u.element?yield*Q(C,u.element):yield*X(C,u,"element"):U(C)}}else if(v[Symbol.iterator]&&!v.buffer){J[$++]=159;for(let w of v)w&&(typeof w=="object"||$-n>G)?u.element?yield*Q(w,u.element):yield*X(w,u,"element"):U(w);J[$++]=255}else Nf(v)?(Wd(v.size,64),yield J.subarray(n,$),yield v,se()):v[Symbol.asyncIterator]?(J[$++]=159,yield J.subarray(n,$),yield v,se(),J[$++]=255):U(v);l&&$>n?yield J.subarray(n,$):$-n>G&&(yield J.subarray(n,$),se())}function*X(v,u,l){let p=$-n;try{U(v),$-n>G&&(yield J.subarray(n,$),se())}catch(w){if(w.iteratorNotHandled)u[l]={},$=n+p,yield*Q.call(this,v,u[l]);else throw w}}function se(){G=ee,f.encode(null,Rf)}function oe(v,u,l){return u&&u.chunkThreshold?G=ee=u.chunkThreshold:G=100,v&&typeof v=="object"?(f.encode(null,Rf),l(v,f.iterateProperties||(f.iterateProperties={}),!0)):[f.encode(v)]}async function*H(v,u){for(let l of Q(v,u,!0)){let p=l.constructor;if(p===zd||p===Uint8Array)yield l;else if(Nf(l)){let w=l.stream().getReader(),A;for(;!(A=await w.read()).done;)yield A.value}else if(l[Symbol.asyncIterator])for await(let w of l)se(),w?yield*H(w,u.async||(u.async={})):yield f.encode(w);else yield l}}}useBuffer(t){J=t,bt=new DataView(J.buffer,J.byteOffset,J.byteLength),$=0}clearSharedData(){this.structures&&(this.structures=[]),this.sharedValues&&(this.sharedValues=void 0)}updateSharedData(){let t=this.sharedVersion||0;this.sharedVersion=t+1;let n=this.structures.slice(0),i=new fg(n,this.sharedValues,this.sharedVersion),o=this.saveShared(i,s=>(s&&s.version||0)==t);return o===!1?(i=this.getShared()||{},this.structures=i.structures||[],this.sharedValues=i.packedValues,this.sharedVersion=i.version,this.structures.nextId=this.structures.length):n.forEach((s,a)=>this.structures[a]=s),o}};function Wd(r,t){r<24?J[$++]=t|r:r<256?(J[$++]=t|24,J[$++]=r):r<65536?(J[$++]=t|25,J[$++]=r>>8,J[$++]=r&255):(J[$++]=t|26,bt.setUint32($,r),$+=4)}class fg{constructor(t,n,i){this.structures=t,this.packedValues=n,this.version=i}}function un(r){r<24?J[$++]=128|r:r<256?(J[$++]=152,J[$++]=r):r<65536?(J[$++]=153,J[$++]=r>>8,J[$++]=r&255):(J[$++]=154,bt.setUint32($,r),$+=4)}const xv=typeof Blob>"u"?function(){}:Blob;function Nf(r){if(r instanceof xv)return!0;let t=r[Symbol.toStringTag];return t==="Blob"||t==="File"}function ya(r,t){switch(typeof r){case"string":if(r.length>3){if(t.objectMap[r]>-1||t.values.length>=t.maxValues)return;let i=t.get(r);if(i)++i.count==2&&t.values.push(r);else if(t.set(r,{count:1}),t.samplingPackedValues){let o=t.samplingPackedValues.get(r);o?o.count++:t.samplingPackedValues.set(r,{count:1})}}break;case"object":if(r)if(r instanceof Array)for(let i=0,o=r.length;i<o;i++)ya(r[i],t);else{let i=!t.encoder.useRecords;for(var n in r)r.hasOwnProperty(n)&&(i&&ya(n,t),ya(r[n],t))}break;case"function":console.log(r)}}const Av=new Uint8Array(new Uint16Array([1]).buffer)[0]==1;cg=[Date,Set,Error,RegExp,No,ArrayBuffer,Uint8Array,Uint8ClampedArray,Uint16Array,Uint32Array,typeof BigUint64Array>"u"?function(){}:BigUint64Array,Int8Array,Int16Array,Int32Array,typeof BigInt64Array>"u"?function(){}:BigInt64Array,Float32Array,Float64Array,fg];Su=[{tag:1,encode(r,t){let n=r.getTime()/1e3;(this.useTimestamp32||r.getMilliseconds()===0)&&n>=0&&n<4294967296?(J[$++]=26,bt.setUint32($,n),$+=4):(J[$++]=251,bt.setFloat64($,n),$+=8)}},{tag:258,encode(r,t){let n=Array.from(r);t(n)}},{tag:27,encode(r,t){t([r.name,r.message])}},{tag:27,encode(r,t){t(["RegExp",r.source,r.flags])}},{getTag(r){return r.tag},encode(r,t){t(r.value)}},{encode(r,t,n){Bu(r,n)}},{getTag(r){if(r.constructor===Uint8Array&&(this.tagUint8Array||Is&&this.tagUint8Array!==!1))return 64},encode(r,t,n){Bu(r,n)}},an(68,1),an(69,2),an(70,4),an(71,8),an(72,1),an(77,2),an(78,4),an(79,8),an(85,4),an(86,8),{encode(r,t){let n=r.packedValues||[],i=r.structures||[];if(n.values.length>0){J[$++]=216,J[$++]=51,un(4);let o=n.values;t(o),un(0),un(0),packedObjectMap=Object.create(sharedPackedObjectMap||null);for(let s=0,a=o.length;s<a;s++)packedObjectMap[o[s]]=s}{bt.setUint32($,3655335424),$+=3;let o=i.slice(0);o.unshift(57344),o.push(new No(r.version,1399353956)),t(o)}}}];function an(r,t){return!Av&&t>1&&(r-=4),{tag:r,encode:function(i,o){let s=i.byteLength,a=i.byteOffset||0,c=i.buffer||i;o(Is?oc.from(c,a,s):new Uint8Array(c,a,s))}}}function Bu(r,t){let n=r.byteLength;n<24?J[$++]=64+n:n<256?(J[$++]=88,J[$++]=n):n<65536?(J[$++]=89,J[$++]=n>>8,J[$++]=n&255):(J[$++]=90,bt.setUint32($,n),$+=4),$+n>=J.length&&t($+n),J.set(r.buffer?r:new Uint8Array(r),$),$+=n}function Ev(r,t){let n,i=t.length*2,o=r.length-i;t.sort((s,a)=>s.offset>a.offset?1:-1);for(let s=0;s<t.length;s++){let a=t[s];a.id=s;for(let c of a.references)r[c++]=s>>8,r[c]=s&255}for(;n=t.pop();){let s=n.offset;r.copyWithin(s+i,s,o),i-=2;let a=s+i;r[a++]=216,r[a++]=28,o=s}return r}function Jd(r,t){bt.setUint32(Tt.position+r,$-Tt.position-r+1);let n=Tt;Tt=null,t(n[0]),t(n[1])}let $l=new vv({useRecords:!1});$l.encode;$l.encodeAsIterable;$l.encodeAsAsyncIterable;const Yd=512,Sv=1024,Rf=2048;function Vl(r){return globalThis.Buffer!=null?new Uint8Array(r.buffer,r.byteOffset,r.byteLength):r}function ug(r=0){return globalThis.Buffer!=null&&globalThis.Buffer.allocUnsafe!=null?Vl(globalThis.Buffer.allocUnsafe(r)):new Uint8Array(r)}function Bv(r,t){t||(t=r.reduce((o,s)=>o+s.length,0));const n=ug(t);let i=0;for(const o of r)n.set(o,i),i+=o.length;return Vl(n)}function Dv(r,t){if(r.length>=255)throw new TypeError("Alphabet too long");for(var n=new Uint8Array(256),i=0;i<n.length;i++)n[i]=255;for(var o=0;o<r.length;o++){var s=r.charAt(o),a=s.charCodeAt(0);if(n[a]!==255)throw new TypeError(s+" is ambiguous");n[a]=o}var c=r.length,f=r.charAt(0),h=Math.log(c)/Math.log(256),d=Math.log(256)/Math.log(c);function g(D){if(D instanceof Uint8Array||(ArrayBuffer.isView(D)?D=new Uint8Array(D.buffer,D.byteOffset,D.byteLength):Array.isArray(D)&&(D=Uint8Array.from(D))),!(D instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(D.length===0)return"";for(var E=0,_=0,T=0,F=D.length;T!==F&&D[T]===0;)T++,E++;for(var U=(F-T)*d+1>>>0,z=new Uint8Array(U);T!==F;){for(var V=D[T],G=0,ee=U-1;(V!==0||G<_)&&ee!==-1;ee--,G++)V+=256*z[ee]>>>0,z[ee]=V%c>>>0,V=V/c>>>0;if(V!==0)throw new Error("Non-zero carry");_=G,T++}for(var Q=U-_;Q!==U&&z[Q]===0;)Q++;for(var X=f.repeat(E);Q<U;++Q)X+=r.charAt(z[Q]);return X}function x(D){if(typeof D!="string")throw new TypeError("Expected String");if(D.length===0)return new Uint8Array;var E=0;if(D[E]!==" "){for(var _=0,T=0;D[E]===f;)_++,E++;for(var F=(D.length-E)*h+1>>>0,U=new Uint8Array(F);D[E];){var z=n[D.charCodeAt(E)];if(z===255)return;for(var V=0,G=F-1;(z!==0||V<T)&&G!==-1;G--,V++)z+=c*U[G]>>>0,U[G]=z%256>>>0,z=z/256>>>0;if(z!==0)throw new Error("Non-zero carry");T=V,E++}if(D[E]!==" "){for(var ee=F-T;ee!==F&&U[ee]===0;)ee++;for(var Q=new Uint8Array(_+(F-ee)),X=_;ee!==F;)Q[X++]=U[ee++];return Q}}}function S(D){var E=x(D);if(E)return E;throw new Error(`Non-${t} character`)}return{encode:g,decodeUnsafe:x,decode:S}}var Cv=Dv,Iv=Cv;const _v=r=>{if(r instanceof Uint8Array&&r.constructor.name==="Uint8Array")return r;if(r instanceof ArrayBuffer)return new Uint8Array(r);if(ArrayBuffer.isView(r))return new Uint8Array(r.buffer,r.byteOffset,r.byteLength);throw new Error("Unknown type, must be binary type")},Mv=r=>new TextEncoder().encode(r),kv=r=>new TextDecoder().decode(r);let Tv=class{constructor(t,n,i){this.name=t,this.prefix=n,this.baseEncode=i}encode(t){if(t instanceof Uint8Array)return`${this.prefix}${this.baseEncode(t)}`;throw Error("Unknown type, must be binary type")}},Nv=class{constructor(t,n,i){if(this.name=t,this.prefix=n,n.codePointAt(0)===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=n.codePointAt(0),this.baseDecode=i}decode(t){if(typeof t=="string"){if(t.codePointAt(0)!==this.prefixCodePoint)throw Error(`Unable to decode multibase string ${JSON.stringify(t)}, ${this.name} decoder only supports inputs prefixed with ${this.prefix}`);return this.baseDecode(t.slice(this.prefix.length))}else throw Error("Can only multibase decode strings")}or(t){return lg(this,t)}},Rv=class{constructor(t){this.decoders=t}or(t){return lg(this,t)}decode(t){const n=t[0],i=this.decoders[n];if(i)return i.decode(t);throw RangeError(`Unable to decode multibase string ${JSON.stringify(t)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}};const lg=(r,t)=>new Rv({...r.decoders||{[r.prefix]:r},...t.decoders||{[t.prefix]:t}});let Uv=class{constructor(t,n,i,o){this.name=t,this.prefix=n,this.baseEncode=i,this.baseDecode=o,this.encoder=new Tv(t,n,i),this.decoder=new Nv(t,n,o)}encode(t){return this.encoder.encode(t)}decode(t){return this.decoder.decode(t)}};const sc=({name:r,prefix:t,encode:n,decode:i})=>new Uv(r,t,n,i),_s=({prefix:r,name:t,alphabet:n})=>{const{encode:i,decode:o}=Iv(n,t);return sc({prefix:r,name:t,encode:i,decode:s=>_v(o(s))})},Ov=(r,t,n,i)=>{const o={};for(let d=0;d<t.length;++d)o[t[d]]=d;let s=r.length;for(;r[s-1]==="=";)--s;const a=new Uint8Array(s*n/8|0);let c=0,f=0,h=0;for(let d=0;d<s;++d){const g=o[r[d]];if(g===void 0)throw new SyntaxError(`Non-${i} character`);f=f<<n|g,c+=n,c>=8&&(c-=8,a[h++]=255&f>>c)}if(c>=n||255&f<<8-c)throw new SyntaxError("Unexpected end of data");return a},Pv=(r,t,n)=>{const i=t[t.length-1]==="=",o=(1<<n)-1;let s="",a=0,c=0;for(let f=0;f<r.length;++f)for(c=c<<8|r[f],a+=8;a>n;)a-=n,s+=t[o&c>>a];if(a&&(s+=t[o&c<<n-a]),i)for(;s.length*n&7;)s+="=";return s},Gt=({name:r,prefix:t,bitsPerChar:n,alphabet:i})=>sc({prefix:t,name:r,encode(o){return Pv(o,i,n)},decode(o){return Ov(o,i,n,r)}}),Fv=sc({prefix:"\0",name:"identity",encode:r=>kv(r),decode:r=>Mv(r)}),Lv=Object.freeze(Object.defineProperty({__proto__:null,identity:Fv},Symbol.toStringTag,{value:"Module"})),Hv=Gt({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1}),$v=Object.freeze(Object.defineProperty({__proto__:null,base2:Hv},Symbol.toStringTag,{value:"Module"})),Vv=Gt({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3}),jv=Object.freeze(Object.defineProperty({__proto__:null,base8:Vv},Symbol.toStringTag,{value:"Module"})),Kv=_s({prefix:"9",name:"base10",alphabet:"0123456789"}),zv=Object.freeze(Object.defineProperty({__proto__:null,base10:Kv},Symbol.toStringTag,{value:"Module"})),qv=Gt({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),Gv=Gt({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4}),Wv=Object.freeze(Object.defineProperty({__proto__:null,base16:qv,base16upper:Gv},Symbol.toStringTag,{value:"Module"})),Jv=Gt({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),Yv=Gt({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),Zv=Gt({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),Xv=Gt({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),Qv=Gt({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),ex=Gt({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),tx=Gt({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),rx=Gt({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),nx=Gt({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5}),ix=Object.freeze(Object.defineProperty({__proto__:null,base32:Jv,base32hex:Qv,base32hexpad:tx,base32hexpadupper:rx,base32hexupper:ex,base32pad:Zv,base32padupper:Xv,base32upper:Yv,base32z:nx},Symbol.toStringTag,{value:"Module"})),ox=_s({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),sx=_s({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"}),ax=Object.freeze(Object.defineProperty({__proto__:null,base36:ox,base36upper:sx},Symbol.toStringTag,{value:"Module"})),cx=_s({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),fx=_s({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"}),ux=Object.freeze(Object.defineProperty({__proto__:null,base58btc:cx,base58flickr:fx},Symbol.toStringTag,{value:"Module"})),lx=Gt({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),hx=Gt({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),dx=Gt({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),px=Gt({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6}),gx=Object.freeze(Object.defineProperty({__proto__:null,base64:lx,base64pad:hx,base64url:dx,base64urlpad:px},Symbol.toStringTag,{value:"Module"})),hg=Array.from("🚀🪐☄🛰🌌🌑🌒🌓🌔🌕🌖🌗🌘🌍🌏🌎🐉☀💻🖥💾💿😂❤😍🤣😊🙏💕😭😘👍😅👏😁🔥🥰💔💖💙😢🤔😆🙄💪😉☺👌🤗💜😔😎😇🌹🤦🎉💞✌✨🤷😱😌🌸🙌😋💗💚😏💛🙂💓🤩😄😀🖤😃💯🙈👇🎶😒🤭❣😜💋👀😪😑💥🙋😞😩😡🤪👊🥳😥🤤👉💃😳✋😚😝😴🌟😬🙃🍀🌷😻😓⭐✅🥺🌈😈🤘💦✔😣🏃💐☹🎊💘😠☝😕🌺🎂🌻😐🖕💝🙊😹🗣💫💀👑🎵🤞😛🔴😤🌼😫⚽🤙☕🏆🤫👈😮🙆🍻🍃🐶💁😲🌿🧡🎁⚡🌞🎈❌✊👋😰🤨😶🤝🚶💰🍓💢🤟🙁🚨💨🤬✈🎀🍺🤓😙💟🌱😖👶🥴▶➡❓💎💸⬇😨🌚🦋😷🕺⚠🙅😟😵👎🤲🤠🤧📌🔵💅🧐🐾🍒😗🤑🌊🤯🐷☎💧😯💆👆🎤🙇🍑❄🌴💣🐸💌📍🥀🤢👅💡💩👐📸👻🤐🤮🎼🥵🚩🍎🍊👼💍📣🥂"),yx=hg.reduce((r,t,n)=>(r[n]=t,r),[]),wx=hg.reduce((r,t,n)=>(r[t.codePointAt(0)]=n,r),[]);function mx(r){return r.reduce((t,n)=>(t+=yx[n],t),"")}function bx(r){const t=[];for(const n of r){const i=wx[n.codePointAt(0)];if(i===void 0)throw new Error(`Non-base256emoji character: ${n}`);t.push(i)}return new Uint8Array(t)}const vx=sc({prefix:"🚀",name:"base256emoji",encode:mx,decode:bx}),xx=Object.freeze(Object.defineProperty({__proto__:null,base256emoji:vx},Symbol.toStringTag,{value:"Module"}));var Ax=dg,Zd=128,Ex=-128,Sx=Math.pow(2,31);function dg(r,t,n){t=t||[],n=n||0;for(var i=n;r>=Sx;)t[n++]=r&255|Zd,r/=128;for(;r&Ex;)t[n++]=r&255|Zd,r>>>=7;return t[n]=r|0,dg.bytes=n-i+1,t}var Bx=Du,Dx=128,Xd=127;function Du(r,i){var n=0,i=i||0,o=0,s=i,a,c=r.length;do{if(s>=c)throw Du.bytes=0,new RangeError("Could not decode varint");a=r[s++],n+=o<28?(a&Xd)<<o:(a&Xd)*Math.pow(2,o),o+=7}while(a>=Dx);return Du.bytes=s-i,n}var Cx=Math.pow(2,7),Ix=Math.pow(2,14),_x=Math.pow(2,21),Mx=Math.pow(2,28),kx=Math.pow(2,35),Tx=Math.pow(2,42),Nx=Math.pow(2,49),Rx=Math.pow(2,56),Ux=Math.pow(2,63),Ox=function(r){return r<Cx?1:r<Ix?2:r<_x?3:r<Mx?4:r<kx?5:r<Tx?6:r<Nx?7:r<Rx?8:r<Ux?9:10},Px={encode:Ax,decode:Bx,encodingLength:Ox},Ra=Px;const Fx=(r,t=0)=>[Ra.decode(r,t),Ra.decode.bytes],Lx=(r,t,n=0)=>(Ra.encode(r,t,n),t),Hx=r=>Ra.encodingLength(r);new TextEncoder;new TextDecoder;const Qd={...Lv,...$v,...jv,...zv,...Wv,...ix,...ax,...ux,...gx,...xx};function pg(r,t,n,i){return{name:r,prefix:t,encoder:{name:r,prefix:t,encode:n},decoder:{decode:i}}}const e0=pg("utf8","u",r=>"u"+new TextDecoder("utf8").decode(r),r=>new TextEncoder().encode(r.substring(1))),Uf=pg("ascii","a",r=>{let t="a";for(let n=0;n<r.length;n++)t+=String.fromCharCode(r[n]);return t},r=>{r=r.substring(1);const t=ug(r.length);for(let n=0;n<r.length;n++)t[n]=r.charCodeAt(n);return t}),gg={utf8:e0,"utf-8":e0,hex:Qd.base16,latin1:Uf,ascii:Uf,binary:Uf,...Qd};function jl(r,t="utf8"){const n=gg[t];if(!n)throw new Error(`Unsupported encoding "${t}"`);return(t==="utf8"||t==="utf-8")&&globalThis.Buffer!=null&&globalThis.Buffer.from!=null?Vl(globalThis.Buffer.from(r,"utf-8")):n.decoder.decode(`${n.prefix}${r}`)}function yg(r,t="utf8"){const n=gg[t];if(!n)throw new Error(`Unsupported encoding "${t}"`);return(t==="utf8"||t==="utf-8")&&globalThis.Buffer!=null&&globalThis.Buffer.from!=null?globalThis.Buffer.from(r.buffer,r.byteOffset,r.byteLength).toString("utf8"):n.encoder.encode(r).substring(1)}function Ua(r){if(!Number.isSafeInteger(r)||r<0)throw new Error("positive integer expected, got "+r)}function $x(r){return r instanceof Uint8Array||ArrayBuffer.isView(r)&&r.constructor.name==="Uint8Array"}function Ms(r,...t){if(!$x(r))throw new Error("Uint8Array expected");if(t.length>0&&!t.includes(r.length))throw new Error("Uint8Array expected of length "+t+", got length="+r.length)}function Vx(r){if(typeof r!="function"||typeof r.create!="function")throw new Error("Hash should be wrapped by utils.wrapConstructor");Ua(r.outputLen),Ua(r.blockLen)}function vo(r,t=!0){if(r.destroyed)throw new Error("Hash instance has been destroyed");if(t&&r.finished)throw new Error("Hash#digest() has already been called")}function wg(r,t){Ms(r);const n=t.outputLen;if(r.length<n)throw new Error("digestInto() expects output buffer of length at least "+n)}const so=typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0;/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */const jx=r=>new Uint32Array(r.buffer,r.byteOffset,Math.floor(r.byteLength/4)),Of=r=>new DataView(r.buffer,r.byteOffset,r.byteLength),cn=(r,t)=>r<<32-t|r>>>t,Xs=(r,t)=>r<<t|r>>>32-t>>>0,t0=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68,Kx=r=>r<<24&4278190080|r<<8&16711680|r>>>8&65280|r>>>24&255;function r0(r){for(let t=0;t<r.length;t++)r[t]=Kx(r[t])}const vn={_0:48,_9:57,A:65,F:70,a:97,f:102};function n0(r){if(r>=vn._0&&r<=vn._9)return r-vn._0;if(r>=vn.A&&r<=vn.F)return r-(vn.A-10);if(r>=vn.a&&r<=vn.f)return r-(vn.a-10)}function L4(r){if(typeof r!="string")throw new Error("hex string expected, got "+typeof r);const t=r.length,n=t/2;if(t%2)throw new Error("hex string expected, got unpadded hex of length "+t);const i=new Uint8Array(n);for(let o=0,s=0;o<n;o++,s+=2){const a=n0(r.charCodeAt(s)),c=n0(r.charCodeAt(s+1));if(a===void 0||c===void 0){const f=r[s]+r[s+1];throw new Error('hex string expected, got non-hex character "'+f+'" at index '+s)}i[o]=a*16+c}return i}function zx(r){if(typeof r!="string")throw new Error("utf8ToBytes expected string, got "+typeof r);return new Uint8Array(new TextEncoder().encode(r))}function ac(r){return typeof r=="string"&&(r=zx(r)),Ms(r),r}function qx(...r){let t=0;for(let i=0;i<r.length;i++){const o=r[i];Ms(o),t+=o.length}const n=new Uint8Array(t);for(let i=0,o=0;i<r.length;i++){const s=r[i];n.set(s,o),o+=s.length}return n}class Kl{clone(){return this._cloneInto()}}function cc(r){const t=i=>r().update(ac(i)).digest(),n=r();return t.outputLen=n.outputLen,t.blockLen=n.blockLen,t.create=()=>r(),t}function mg(r=32){if(so&&typeof so.getRandomValues=="function")return so.getRandomValues(new Uint8Array(r));if(so&&typeof so.randomBytes=="function")return so.randomBytes(r);throw new Error("crypto.getRandomValues must be defined")}function Gx(r,t,n,i){if(typeof r.setBigUint64=="function")return r.setBigUint64(t,n,i);const o=BigInt(32),s=BigInt(4294967295),a=Number(n>>o&s),c=Number(n&s),f=i?4:0,h=i?0:4;r.setUint32(t+f,a,i),r.setUint32(t+h,c,i)}const Wx=(r,t,n)=>r&t^~r&n,Jx=(r,t,n)=>r&t^r&n^t&n;class zl extends Kl{constructor(t,n,i,o){super(),this.blockLen=t,this.outputLen=n,this.padOffset=i,this.isLE=o,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(t),this.view=Of(this.buffer)}update(t){vo(this);const{view:n,buffer:i,blockLen:o}=this;t=ac(t);const s=t.length;for(let a=0;a<s;){const c=Math.min(o-this.pos,s-a);if(c===o){const f=Of(t);for(;o<=s-a;a+=o)this.process(f,a);continue}i.set(t.subarray(a,a+c),this.pos),this.pos+=c,a+=c,this.pos===o&&(this.process(n,0),this.pos=0)}return this.length+=t.length,this.roundClean(),this}digestInto(t){vo(this),wg(t,this),this.finished=!0;const{buffer:n,view:i,blockLen:o,isLE:s}=this;let{pos:a}=this;n[a++]=128,this.buffer.subarray(a).fill(0),this.padOffset>o-a&&(this.process(i,0),a=0);for(let g=a;g<o;g++)n[g]=0;Gx(i,o-8,BigInt(this.length*8),s),this.process(i,0);const c=Of(t),f=this.outputLen;if(f%4)throw new Error("_sha2: outputLen should be aligned to 32bit");const h=f/4,d=this.get();if(h>d.length)throw new Error("_sha2: outputLen bigger than state");for(let g=0;g<h;g++)c.setUint32(4*g,d[g],s)}digest(){const{buffer:t,outputLen:n}=this;this.digestInto(t);const i=t.slice(0,n);return this.destroy(),i}_cloneInto(t){t||(t=new this.constructor),t.set(...this.get());const{blockLen:n,buffer:i,length:o,finished:s,destroyed:a,pos:c}=this;return t.length=o,t.pos=c,t.finished=s,t.destroyed=a,o%n&&t.buffer.set(i),t}}const Qs=BigInt(2**32-1),Cu=BigInt(32);function bg(r,t=!1){return t?{h:Number(r&Qs),l:Number(r>>Cu&Qs)}:{h:Number(r>>Cu&Qs)|0,l:Number(r&Qs)|0}}function vg(r,t=!1){let n=new Uint32Array(r.length),i=new Uint32Array(r.length);for(let o=0;o<r.length;o++){const{h:s,l:a}=bg(r[o],t);[n[o],i[o]]=[s,a]}return[n,i]}const Yx=(r,t)=>BigInt(r>>>0)<<Cu|BigInt(t>>>0),Zx=(r,t,n)=>r>>>n,Xx=(r,t,n)=>r<<32-n|t>>>n,Qx=(r,t,n)=>r>>>n|t<<32-n,e2=(r,t,n)=>r<<32-n|t>>>n,t2=(r,t,n)=>r<<64-n|t>>>n-32,r2=(r,t,n)=>r>>>n-32|t<<64-n,n2=(r,t)=>t,i2=(r,t)=>r,xg=(r,t,n)=>r<<n|t>>>32-n,Ag=(r,t,n)=>t<<n|r>>>32-n,Eg=(r,t,n)=>t<<n-32|r>>>64-n,Sg=(r,t,n)=>r<<n-32|t>>>64-n;function o2(r,t,n,i){const o=(t>>>0)+(i>>>0);return{h:r+n+(o/2**32|0)|0,l:o|0}}const s2=(r,t,n)=>(r>>>0)+(t>>>0)+(n>>>0),a2=(r,t,n,i)=>t+n+i+(r/2**32|0)|0,c2=(r,t,n,i)=>(r>>>0)+(t>>>0)+(n>>>0)+(i>>>0),f2=(r,t,n,i,o)=>t+n+i+o+(r/2**32|0)|0,u2=(r,t,n,i,o)=>(r>>>0)+(t>>>0)+(n>>>0)+(i>>>0)+(o>>>0),l2=(r,t,n,i,o,s)=>t+n+i+o+s+(r/2**32|0)|0,De={fromBig:bg,split:vg,toBig:Yx,shrSH:Zx,shrSL:Xx,rotrSH:Qx,rotrSL:e2,rotrBH:t2,rotrBL:r2,rotr32H:n2,rotr32L:i2,rotlSH:xg,rotlSL:Ag,rotlBH:Eg,rotlBL:Sg,add:o2,add3L:s2,add3H:a2,add4L:c2,add4H:f2,add5H:l2,add5L:u2},[h2,d2]=De.split(["0x428a2f98d728ae22","0x7137449123ef65cd","0xb5c0fbcfec4d3b2f","0xe9b5dba58189dbbc","0x3956c25bf348b538","0x59f111f1b605d019","0x923f82a4af194f9b","0xab1c5ed5da6d8118","0xd807aa98a3030242","0x12835b0145706fbe","0x243185be4ee4b28c","0x550c7dc3d5ffb4e2","0x72be5d74f27b896f","0x80deb1fe3b1696b1","0x9bdc06a725c71235","0xc19bf174cf692694","0xe49b69c19ef14ad2","0xefbe4786384f25e3","0x0fc19dc68b8cd5b5","0x240ca1cc77ac9c65","0x2de92c6f592b0275","0x4a7484aa6ea6e483","0x5cb0a9dcbd41fbd4","0x76f988da831153b5","0x983e5152ee66dfab","0xa831c66d2db43210","0xb00327c898fb213f","0xbf597fc7beef0ee4","0xc6e00bf33da88fc2","0xd5a79147930aa725","0x06ca6351e003826f","0x142929670a0e6e70","0x27b70a8546d22ffc","0x2e1b21385c26c926","0x4d2c6dfc5ac42aed","0x53380d139d95b3df","0x650a73548baf63de","0x766a0abb3c77b2a8","0x81c2c92e47edaee6","0x92722c851482353b","0xa2bfe8a14cf10364","0xa81a664bbc423001","0xc24b8b70d0f89791","0xc76c51a30654be30","0xd192e819d6ef5218","0xd69906245565a910","0xf40e35855771202a","0x106aa07032bbd1b8","0x19a4c116b8d2d0c8","0x1e376c085141ab53","0x2748774cdf8eeb99","0x34b0bcb5e19b48a8","0x391c0cb3c5c95a63","0x4ed8aa4ae3418acb","0x5b9cca4f7763e373","0x682e6ff3d6b2b8a3","0x748f82ee5defb2fc","0x78a5636f43172f60","0x84c87814a1f0ab72","0x8cc702081a6439ec","0x90befffa23631e28","0xa4506cebde82bde9","0xbef9a3f7b2c67915","0xc67178f2e372532b","0xca273eceea26619c","0xd186b8c721c0c207","0xeada7dd6cde0eb1e","0xf57d4f7fee6ed178","0x06f067aa72176fba","0x0a637dc5a2c898a6","0x113f9804bef90dae","0x1b710b35131c471b","0x28db77f523047d84","0x32caab7b40c72493","0x3c9ebe0a15c9bebc","0x431d67c49c100d4c","0x4cc5d4becb3e42b6","0x597f299cfc657e2a","0x5fcb6fab3ad6faec","0x6c44198c4a475817"].map(r=>BigInt(r))),Xn=new Uint32Array(80),Qn=new Uint32Array(80);class p2 extends zl{constructor(){super(128,64,16,!1),this.Ah=1779033703,this.Al=-205731576,this.Bh=-1150833019,this.Bl=-2067093701,this.Ch=1013904242,this.Cl=-23791573,this.Dh=-1521486534,this.Dl=1595750129,this.Eh=1359893119,this.El=-1377402159,this.Fh=-1694144372,this.Fl=725511199,this.Gh=528734635,this.Gl=-79577749,this.Hh=1541459225,this.Hl=327033209}get(){const{Ah:t,Al:n,Bh:i,Bl:o,Ch:s,Cl:a,Dh:c,Dl:f,Eh:h,El:d,Fh:g,Fl:x,Gh:S,Gl:D,Hh:E,Hl:_}=this;return[t,n,i,o,s,a,c,f,h,d,g,x,S,D,E,_]}set(t,n,i,o,s,a,c,f,h,d,g,x,S,D,E,_){this.Ah=t|0,this.Al=n|0,this.Bh=i|0,this.Bl=o|0,this.Ch=s|0,this.Cl=a|0,this.Dh=c|0,this.Dl=f|0,this.Eh=h|0,this.El=d|0,this.Fh=g|0,this.Fl=x|0,this.Gh=S|0,this.Gl=D|0,this.Hh=E|0,this.Hl=_|0}process(t,n){for(let U=0;U<16;U++,n+=4)Xn[U]=t.getUint32(n),Qn[U]=t.getUint32(n+=4);for(let U=16;U<80;U++){const z=Xn[U-15]|0,V=Qn[U-15]|0,G=De.rotrSH(z,V,1)^De.rotrSH(z,V,8)^De.shrSH(z,V,7),ee=De.rotrSL(z,V,1)^De.rotrSL(z,V,8)^De.shrSL(z,V,7),Q=Xn[U-2]|0,X=Qn[U-2]|0,se=De.rotrSH(Q,X,19)^De.rotrBH(Q,X,61)^De.shrSH(Q,X,6),oe=De.rotrSL(Q,X,19)^De.rotrBL(Q,X,61)^De.shrSL(Q,X,6),H=De.add4L(ee,oe,Qn[U-7],Qn[U-16]),v=De.add4H(H,G,se,Xn[U-7],Xn[U-16]);Xn[U]=v|0,Qn[U]=H|0}let{Ah:i,Al:o,Bh:s,Bl:a,Ch:c,Cl:f,Dh:h,Dl:d,Eh:g,El:x,Fh:S,Fl:D,Gh:E,Gl:_,Hh:T,Hl:F}=this;for(let U=0;U<80;U++){const z=De.rotrSH(g,x,14)^De.rotrSH(g,x,18)^De.rotrBH(g,x,41),V=De.rotrSL(g,x,14)^De.rotrSL(g,x,18)^De.rotrBL(g,x,41),G=g&S^~g&E,ee=x&D^~x&_,Q=De.add5L(F,V,ee,d2[U],Qn[U]),X=De.add5H(Q,T,z,G,h2[U],Xn[U]),se=Q|0,oe=De.rotrSH(i,o,28)^De.rotrBH(i,o,34)^De.rotrBH(i,o,39),H=De.rotrSL(i,o,28)^De.rotrBL(i,o,34)^De.rotrBL(i,o,39),v=i&s^i&c^s&c,u=o&a^o&f^a&f;T=E|0,F=_|0,E=S|0,_=D|0,S=g|0,D=x|0,{h:g,l:x}=De.add(h|0,d|0,X|0,se|0),h=c|0,d=f|0,c=s|0,f=a|0,s=i|0,a=o|0;const l=De.add3L(se,H,u);i=De.add3H(l,X,oe,v),o=l|0}({h:i,l:o}=De.add(this.Ah|0,this.Al|0,i|0,o|0)),{h:s,l:a}=De.add(this.Bh|0,this.Bl|0,s|0,a|0),{h:c,l:f}=De.add(this.Ch|0,this.Cl|0,c|0,f|0),{h,l:d}=De.add(this.Dh|0,this.Dl|0,h|0,d|0),{h:g,l:x}=De.add(this.Eh|0,this.El|0,g|0,x|0),{h:S,l:D}=De.add(this.Fh|0,this.Fl|0,S|0,D|0),{h:E,l:_}=De.add(this.Gh|0,this.Gl|0,E|0,_|0),{h:T,l:F}=De.add(this.Hh|0,this.Hl|0,T|0,F|0),this.set(i,o,s,a,c,f,h,d,g,x,S,D,E,_,T,F)}roundClean(){Xn.fill(0),Qn.fill(0)}destroy(){this.buffer.fill(0),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}}const g2=cc(()=>new p2);/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const fc=BigInt(0),uc=BigInt(1),y2=BigInt(2);function Vi(r){return r instanceof Uint8Array||ArrayBuffer.isView(r)&&r.constructor.name==="Uint8Array"}function ks(r){if(!Vi(r))throw new Error("Uint8Array expected")}function Mn(r,t){if(typeof t!="boolean")throw new Error(r+" boolean expected, got "+t)}const w2=Array.from({length:256},(r,t)=>t.toString(16).padStart(2,"0"));function ji(r){ks(r);let t="";for(let n=0;n<r.length;n++)t+=w2[r[n]];return t}function co(r){const t=r.toString(16);return t.length&1?"0"+t:t}function ql(r){if(typeof r!="string")throw new Error("hex string expected, got "+typeof r);return r===""?fc:BigInt("0x"+r)}const xn={_0:48,_9:57,A:65,F:70,a:97,f:102};function i0(r){if(r>=xn._0&&r<=xn._9)return r-xn._0;if(r>=xn.A&&r<=xn.F)return r-(xn.A-10);if(r>=xn.a&&r<=xn.f)return r-(xn.a-10)}function xo(r){if(typeof r!="string")throw new Error("hex string expected, got "+typeof r);const t=r.length,n=t/2;if(t%2)throw new Error("hex string expected, got unpadded hex of length "+t);const i=new Uint8Array(n);for(let o=0,s=0;o<n;o++,s+=2){const a=i0(r.charCodeAt(s)),c=i0(r.charCodeAt(s+1));if(a===void 0||c===void 0){const f=r[s]+r[s+1];throw new Error('hex string expected, got non-hex character "'+f+'" at index '+s)}i[o]=a*16+c}return i}function Fi(r){return ql(ji(r))}function lo(r){return ks(r),ql(ji(Uint8Array.from(r).reverse()))}function Ao(r,t){return xo(r.toString(16).padStart(t*2,"0"))}function ls(r,t){return Ao(r,t).reverse()}function m2(r){return xo(co(r))}function _t(r,t,n){let i;if(typeof t=="string")try{i=xo(t)}catch(s){throw new Error(r+" must be hex string or Uint8Array, cause: "+s)}else if(Vi(t))i=Uint8Array.from(t);else throw new Error(r+" must be hex string or Uint8Array");const o=i.length;if(typeof n=="number"&&o!==n)throw new Error(r+" of length "+n+" expected, got "+o);return i}function Ki(...r){let t=0;for(let i=0;i<r.length;i++){const o=r[i];ks(o),t+=o.length}const n=new Uint8Array(t);for(let i=0,o=0;i<r.length;i++){const s=r[i];n.set(s,o),o+=s.length}return n}function b2(r,t){if(r.length!==t.length)return!1;let n=0;for(let i=0;i<r.length;i++)n|=r[i]^t[i];return n===0}function v2(r){if(typeof r!="string")throw new Error("string expected");return new Uint8Array(new TextEncoder().encode(r))}const Pf=r=>typeof r=="bigint"&&fc<=r;function lc(r,t,n){return Pf(r)&&Pf(t)&&Pf(n)&&t<=r&&r<n}function kr(r,t,n,i){if(!lc(t,n,i))throw new Error("expected valid "+r+": "+n+" <= n < "+i+", got "+t)}function Bg(r){let t;for(t=0;r>fc;r>>=uc,t+=1);return t}function x2(r,t){return r>>BigInt(t)&uc}function A2(r,t,n){return r|(n?uc:fc)<<BigInt(t)}const Gl=r=>(y2<<BigInt(r-1))-uc,Ff=r=>new Uint8Array(r),o0=r=>Uint8Array.from(r);function Dg(r,t,n){if(typeof r!="number"||r<2)throw new Error("hashLen must be a number");if(typeof t!="number"||t<2)throw new Error("qByteLen must be a number");if(typeof n!="function")throw new Error("hmacFn must be a function");let i=Ff(r),o=Ff(r),s=0;const a=()=>{i.fill(1),o.fill(0),s=0},c=(...g)=>n(o,i,...g),f=(g=Ff())=>{o=c(o0([0]),g),i=c(),g.length!==0&&(o=c(o0([1]),g),i=c())},h=()=>{if(s++>=1e3)throw new Error("drbg: tried 1000 values");let g=0;const x=[];for(;g<t;){i=c();const S=i.slice();x.push(S),g+=i.length}return Ki(...x)};return(g,x)=>{a(),f(g);let S;for(;!(S=x(h()));)f();return a(),S}}const E2={bigint:r=>typeof r=="bigint",function:r=>typeof r=="function",boolean:r=>typeof r=="boolean",string:r=>typeof r=="string",stringOrUint8Array:r=>typeof r=="string"||Vi(r),isSafeInteger:r=>Number.isSafeInteger(r),array:r=>Array.isArray(r),field:(r,t)=>t.Fp.isValid(r),hash:r=>typeof r=="function"&&Number.isSafeInteger(r.outputLen)};function Ro(r,t,n={}){const i=(o,s,a)=>{const c=E2[s];if(typeof c!="function")throw new Error("invalid validator function");const f=r[o];if(!(a&&f===void 0)&&!c(f,r))throw new Error("param "+String(o)+" is invalid. Expected "+s+", got "+f)};for(const[o,s]of Object.entries(t))i(o,s,!1);for(const[o,s]of Object.entries(n))i(o,s,!0);return r}const S2=()=>{throw new Error("not implemented")};function hs(r){const t=new WeakMap;return(n,...i)=>{const o=t.get(n);if(o!==void 0)return o;const s=r(n,...i);return t.set(n,s),s}}const B2=Object.freeze(Object.defineProperty({__proto__:null,aInRange:kr,abool:Mn,abytes:ks,bitGet:x2,bitLen:Bg,bitMask:Gl,bitSet:A2,bytesToHex:ji,bytesToNumberBE:Fi,bytesToNumberLE:lo,concatBytes:Ki,createHmacDrbg:Dg,ensureBytes:_t,equalBytes:b2,hexToBytes:xo,hexToNumber:ql,inRange:lc,isBytes:Vi,memoized:hs,notImplemented:S2,numberToBytesBE:Ao,numberToBytesLE:ls,numberToHexUnpadded:co,numberToVarBytesBE:m2,utf8ToBytes:v2,validateObject:Ro},Symbol.toStringTag,{value:"Module"}));/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const Ht=BigInt(0),Et=BigInt(1),Ti=BigInt(2),D2=BigInt(3),Iu=BigInt(4),s0=BigInt(5),a0=BigInt(8);function xt(r,t){const n=r%t;return n>=Ht?n:t+n}function C2(r,t,n){if(t<Ht)throw new Error("invalid exponent, negatives unsupported");if(n<=Ht)throw new Error("invalid modulus");if(n===Et)return Ht;let i=Et;for(;t>Ht;)t&Et&&(i=i*r%n),r=r*r%n,t>>=Et;return i}function St(r,t,n){let i=r;for(;t-- >Ht;)i*=i,i%=n;return i}function _u(r,t){if(r===Ht)throw new Error("invert: expected non-zero number");if(t<=Ht)throw new Error("invert: expected positive modulus, got "+t);let n=xt(r,t),i=t,o=Ht,s=Et;for(;n!==Ht;){const c=i/n,f=i%n,h=o-s*c;i=n,n=f,o=s,s=h}if(i!==Et)throw new Error("invert: does not exist");return xt(o,t)}function I2(r){const t=(r-Et)/Ti;let n,i,o;for(n=r-Et,i=0;n%Ti===Ht;n/=Ti,i++);for(o=Ti;o<r&&C2(o,t,r)!==r-Et;o++)if(o>1e3)throw new Error("Cannot find square root: likely non-prime P");if(i===1){const a=(r+Et)/Iu;return function(f,h){const d=f.pow(h,a);if(!f.eql(f.sqr(d),h))throw new Error("Cannot find square root");return d}}const s=(n+Et)/Ti;return function(c,f){if(c.pow(f,t)===c.neg(c.ONE))throw new Error("Cannot find square root");let h=i,d=c.pow(c.mul(c.ONE,o),n),g=c.pow(f,s),x=c.pow(f,n);for(;!c.eql(x,c.ONE);){if(c.eql(x,c.ZERO))return c.ZERO;let S=1;for(let E=c.sqr(x);S<h&&!c.eql(E,c.ONE);S++)E=c.sqr(E);const D=c.pow(d,Et<<BigInt(h-S-1));d=c.sqr(D),g=c.mul(g,D),x=c.mul(x,d),h=S}return g}}function _2(r){if(r%Iu===D2){const t=(r+Et)/Iu;return function(i,o){const s=i.pow(o,t);if(!i.eql(i.sqr(s),o))throw new Error("Cannot find square root");return s}}if(r%a0===s0){const t=(r-s0)/a0;return function(i,o){const s=i.mul(o,Ti),a=i.pow(s,t),c=i.mul(o,a),f=i.mul(i.mul(c,Ti),a),h=i.mul(c,i.sub(f,i.ONE));if(!i.eql(i.sqr(h),o))throw new Error("Cannot find square root");return h}}return I2(r)}const M2=(r,t)=>(xt(r,t)&Et)===Et,k2=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function T2(r){const t={ORDER:"bigint",MASK:"bigint",BYTES:"isSafeInteger",BITS:"isSafeInteger"},n=k2.reduce((i,o)=>(i[o]="function",i),t);return Ro(r,n)}function N2(r,t,n){if(n<Ht)throw new Error("invalid exponent, negatives unsupported");if(n===Ht)return r.ONE;if(n===Et)return t;let i=r.ONE,o=t;for(;n>Ht;)n&Et&&(i=r.mul(i,o)),o=r.sqr(o),n>>=Et;return i}function R2(r,t){const n=new Array(t.length),i=t.reduce((s,a,c)=>r.is0(a)?s:(n[c]=s,r.mul(s,a)),r.ONE),o=r.inv(i);return t.reduceRight((s,a,c)=>r.is0(a)?s:(n[c]=r.mul(s,n[c]),r.mul(s,a)),o),n}function Cg(r,t){const n=t!==void 0?t:r.toString(2).length,i=Math.ceil(n/8);return{nBitLength:n,nByteLength:i}}function Ts(r,t,n=!1,i={}){if(r<=Ht)throw new Error("invalid field: expected ORDER > 0, got "+r);const{nBitLength:o,nByteLength:s}=Cg(r,t);if(s>2048)throw new Error("invalid field: expected ORDER of <= 2048 bytes");let a;const c=Object.freeze({ORDER:r,isLE:n,BITS:o,BYTES:s,MASK:Gl(o),ZERO:Ht,ONE:Et,create:f=>xt(f,r),isValid:f=>{if(typeof f!="bigint")throw new Error("invalid field element: expected bigint, got "+typeof f);return Ht<=f&&f<r},is0:f=>f===Ht,isOdd:f=>(f&Et)===Et,neg:f=>xt(-f,r),eql:(f,h)=>f===h,sqr:f=>xt(f*f,r),add:(f,h)=>xt(f+h,r),sub:(f,h)=>xt(f-h,r),mul:(f,h)=>xt(f*h,r),pow:(f,h)=>N2(c,f,h),div:(f,h)=>xt(f*_u(h,r),r),sqrN:f=>f*f,addN:(f,h)=>f+h,subN:(f,h)=>f-h,mulN:(f,h)=>f*h,inv:f=>_u(f,r),sqrt:i.sqrt||(f=>(a||(a=_2(r)),a(c,f))),invertBatch:f=>R2(c,f),cmov:(f,h,d)=>d?h:f,toBytes:f=>n?ls(f,s):Ao(f,s),fromBytes:f=>{if(f.length!==s)throw new Error("Field.fromBytes: expected "+s+" bytes, got "+f.length);return n?lo(f):Fi(f)}});return Object.freeze(c)}function Ig(r){if(typeof r!="bigint")throw new Error("field order must be bigint");const t=r.toString(2).length;return Math.ceil(t/8)}function _g(r){const t=Ig(r);return t+Math.ceil(t/2)}function U2(r,t,n=!1){const i=r.length,o=Ig(t),s=_g(t);if(i<16||i<s||i>1024)throw new Error("expected "+s+"-1024 bytes of input, got "+i);const a=n?lo(r):Fi(r),c=xt(a,t-Et)+Et;return n?ls(c,o):Ao(c,o)}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const c0=BigInt(0),ea=BigInt(1);function Lf(r,t){const n=t.negate();return r?n:t}function Mg(r,t){if(!Number.isSafeInteger(r)||r<=0||r>t)throw new Error("invalid window size, expected [1.."+t+"], got W="+r)}function Hf(r,t){Mg(r,t);const n=Math.ceil(t/r)+1,i=2**(r-1);return{windows:n,windowSize:i}}function O2(r,t){if(!Array.isArray(r))throw new Error("array expected");r.forEach((n,i)=>{if(!(n instanceof t))throw new Error("invalid point at index "+i)})}function P2(r,t){if(!Array.isArray(r))throw new Error("array of scalars expected");r.forEach((n,i)=>{if(!t.isValid(n))throw new Error("invalid scalar at index "+i)})}const $f=new WeakMap,kg=new WeakMap;function Vf(r){return kg.get(r)||1}function Tg(r,t){return{constTimeNegate:Lf,hasPrecomputes(n){return Vf(n)!==1},unsafeLadder(n,i,o=r.ZERO){let s=n;for(;i>c0;)i&ea&&(o=o.add(s)),s=s.double(),i>>=ea;return o},precomputeWindow(n,i){const{windows:o,windowSize:s}=Hf(i,t),a=[];let c=n,f=c;for(let h=0;h<o;h++){f=c,a.push(f);for(let d=1;d<s;d++)f=f.add(c),a.push(f);c=f.double()}return a},wNAF(n,i,o){const{windows:s,windowSize:a}=Hf(n,t);let c=r.ZERO,f=r.BASE;const h=BigInt(2**n-1),d=2**n,g=BigInt(n);for(let x=0;x<s;x++){const S=x*a;let D=Number(o&h);o>>=g,D>a&&(D-=d,o+=ea);const E=S,_=S+Math.abs(D)-1,T=x%2!==0,F=D<0;D===0?f=f.add(Lf(T,i[E])):c=c.add(Lf(F,i[_]))}return{p:c,f}},wNAFUnsafe(n,i,o,s=r.ZERO){const{windows:a,windowSize:c}=Hf(n,t),f=BigInt(2**n-1),h=2**n,d=BigInt(n);for(let g=0;g<a;g++){const x=g*c;if(o===c0)break;let S=Number(o&f);if(o>>=d,S>c&&(S-=h,o+=ea),S===0)continue;let D=i[x+Math.abs(S)-1];S<0&&(D=D.negate()),s=s.add(D)}return s},getPrecomputes(n,i,o){let s=$f.get(i);return s||(s=this.precomputeWindow(i,n),n!==1&&$f.set(i,o(s))),s},wNAFCached(n,i,o){const s=Vf(n);return this.wNAF(s,this.getPrecomputes(s,n,o),i)},wNAFCachedUnsafe(n,i,o,s){const a=Vf(n);return a===1?this.unsafeLadder(n,i,s):this.wNAFUnsafe(a,this.getPrecomputes(a,n,o),i,s)},setWindowSize(n,i){Mg(i,t),kg.set(n,i),$f.delete(n)}}}function Ng(r,t,n,i){if(O2(n,r),P2(i,t),n.length!==i.length)throw new Error("arrays of points and scalars must have equal length");const o=r.ZERO,s=Bg(BigInt(n.length)),a=s>12?s-3:s>4?s-2:s?2:1,c=(1<<a)-1,f=new Array(c+1).fill(o),h=Math.floor((t.BITS-1)/a)*a;let d=o;for(let g=h;g>=0;g-=a){f.fill(o);for(let S=0;S<i.length;S++){const D=i[S],E=Number(D>>BigInt(g)&BigInt(c));f[E]=f[E].add(n[S])}let x=o;for(let S=f.length-1,D=o;S>0;S--)D=D.add(f[S]),x=x.add(D);if(d=d.add(x),g!==0)for(let S=0;S<a;S++)d=d.double()}return d}function Wl(r){return T2(r.Fp),Ro(r,{n:"bigint",h:"bigint",Gx:"field",Gy:"field"},{nBitLength:"isSafeInteger",nByteLength:"isSafeInteger"}),Object.freeze({...Cg(r.n,r.nBitLength),...r,p:r.Fp.ORDER})}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const $r=BigInt(0),ur=BigInt(1),ta=BigInt(2),F2=BigInt(8),L2={zip215:!0};function H2(r){const t=Wl(r);return Ro(r,{hash:"function",a:"bigint",d:"bigint",randomBytes:"function"},{adjustScalarBytes:"function",domain:"function",uvRatio:"function",mapToCurve:"function"}),Object.freeze({...t})}function $2(r){const t=H2(r),{Fp:n,n:i,prehash:o,hash:s,randomBytes:a,nByteLength:c,h:f}=t,h=ta<<BigInt(c*8)-ur,d=n.create,g=Ts(t.n,t.nBitLength),x=t.uvRatio||((p,w)=>{try{return{isValid:!0,value:n.sqrt(p*n.inv(w))}}catch{return{isValid:!1,value:$r}}}),S=t.adjustScalarBytes||(p=>p),D=t.domain||((p,w,A)=>{if(Mn("phflag",A),w.length||A)throw new Error("Contexts/pre-hash are not supported");return p});function E(p,w){kr("coordinate "+p,w,$r,h)}function _(p){if(!(p instanceof U))throw new Error("ExtendedPoint expected")}const T=hs((p,w)=>{const{ex:A,ey:C,ez:k}=p,I=p.is0();w==null&&(w=I?F2:n.inv(k));const y=d(A*w),N=d(C*w),re=d(k*w);if(I)return{x:$r,y:ur};if(re!==ur)throw new Error("invZ was invalid");return{x:y,y:N}}),F=hs(p=>{const{a:w,d:A}=t;if(p.is0())throw new Error("bad point: ZERO");const{ex:C,ey:k,ez:I,et:y}=p,N=d(C*C),re=d(k*k),B=d(I*I),j=d(B*B),Z=d(N*w),Y=d(B*d(Z+re)),ne=d(j+d(A*d(N*re)));if(Y!==ne)throw new Error("bad point: equation left != right (1)");const ue=d(C*k),ce=d(I*y);if(ue!==ce)throw new Error("bad point: equation left != right (2)");return!0});class U{constructor(w,A,C,k){this.ex=w,this.ey=A,this.ez=C,this.et=k,E("x",w),E("y",A),E("z",C),E("t",k),Object.freeze(this)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static fromAffine(w){if(w instanceof U)throw new Error("extended point not allowed");const{x:A,y:C}=w||{};return E("x",A),E("y",C),new U(A,C,ur,d(A*C))}static normalizeZ(w){const A=n.invertBatch(w.map(C=>C.ez));return w.map((C,k)=>C.toAffine(A[k])).map(U.fromAffine)}static msm(w,A){return Ng(U,g,w,A)}_setWindowSize(w){G.setWindowSize(this,w)}assertValidity(){F(this)}equals(w){_(w);const{ex:A,ey:C,ez:k}=this,{ex:I,ey:y,ez:N}=w,re=d(A*N),B=d(I*k),j=d(C*N),Z=d(y*k);return re===B&&j===Z}is0(){return this.equals(U.ZERO)}negate(){return new U(d(-this.ex),this.ey,this.ez,d(-this.et))}double(){const{a:w}=t,{ex:A,ey:C,ez:k}=this,I=d(A*A),y=d(C*C),N=d(ta*d(k*k)),re=d(w*I),B=A+C,j=d(d(B*B)-I-y),Z=re+y,Y=Z-N,ne=re-y,ue=d(j*Y),ce=d(Z*ne),ae=d(j*ne),be=d(Y*Z);return new U(ue,ce,be,ae)}add(w){_(w);const{a:A,d:C}=t,{ex:k,ey:I,ez:y,et:N}=this,{ex:re,ey:B,ez:j,et:Z}=w;if(A===BigInt(-1)){const He=d((I-k)*(B+re)),Te=d((I+k)*(B-re)),Qe=d(Te-He);if(Qe===$r)return this.double();const Oe=d(y*ta*Z),Pe=d(N*ta*j),vt=Pe+Oe,$e=Te+He,M=Pe-Oe,m=d(vt*Qe),b=d($e*M),R=d(vt*M),K=d(Qe*$e);return new U(m,b,K,R)}const Y=d(k*re),ne=d(I*B),ue=d(N*C*Z),ce=d(y*j),ae=d((k+I)*(re+B)-Y-ne),be=ce-ue,fe=ce+ue,ge=d(ne-A*Y),jt=d(ae*be),_e=d(fe*ge),je=d(ae*ge),cr=d(be*fe);return new U(jt,_e,cr,je)}subtract(w){return this.add(w.negate())}wNAF(w){return G.wNAFCached(this,w,U.normalizeZ)}multiply(w){const A=w;kr("scalar",A,ur,i);const{p:C,f:k}=this.wNAF(A);return U.normalizeZ([C,k])[0]}multiplyUnsafe(w,A=U.ZERO){const C=w;return kr("scalar",C,$r,i),C===$r?V:this.is0()||C===ur?this:G.wNAFCachedUnsafe(this,C,U.normalizeZ,A)}isSmallOrder(){return this.multiplyUnsafe(f).is0()}isTorsionFree(){return G.unsafeLadder(this,i).is0()}toAffine(w){return T(this,w)}clearCofactor(){const{h:w}=t;return w===ur?this:this.multiplyUnsafe(w)}static fromHex(w,A=!1){const{d:C,a:k}=t,I=n.BYTES;w=_t("pointHex",w,I),Mn("zip215",A);const y=w.slice(),N=w[I-1];y[I-1]=N&-129;const re=lo(y),B=A?h:n.ORDER;kr("pointHex.y",re,$r,B);const j=d(re*re),Z=d(j-ur),Y=d(C*j-k);let{isValid:ne,value:ue}=x(Z,Y);if(!ne)throw new Error("Point.fromHex: invalid y coordinate");const ce=(ue&ur)===ur,ae=(N&128)!==0;if(!A&&ue===$r&&ae)throw new Error("Point.fromHex: x=0 and x_0=1");return ae!==ce&&(ue=d(-ue)),U.fromAffine({x:ue,y:re})}static fromPrivateKey(w){return X(w).point}toRawBytes(){const{x:w,y:A}=this.toAffine(),C=ls(A,n.BYTES);return C[C.length-1]|=w&ur?128:0,C}toHex(){return ji(this.toRawBytes())}}U.BASE=new U(t.Gx,t.Gy,ur,d(t.Gx*t.Gy)),U.ZERO=new U($r,ur,ur,$r);const{BASE:z,ZERO:V}=U,G=Tg(U,c*8);function ee(p){return xt(p,i)}function Q(p){return ee(lo(p))}function X(p){const w=n.BYTES;p=_t("private key",p,w);const A=_t("hashed private key",s(p),2*w),C=S(A.slice(0,w)),k=A.slice(w,2*w),I=Q(C),y=z.multiply(I),N=y.toRawBytes();return{head:C,prefix:k,scalar:I,point:y,pointBytes:N}}function se(p){return X(p).pointBytes}function oe(p=new Uint8Array,...w){const A=Ki(...w);return Q(s(D(A,_t("context",p),!!o)))}function H(p,w,A={}){p=_t("message",p),o&&(p=o(p));const{prefix:C,scalar:k,pointBytes:I}=X(w),y=oe(A.context,C,p),N=z.multiply(y).toRawBytes(),re=oe(A.context,N,I,p),B=ee(y+re*k);kr("signature.s",B,$r,i);const j=Ki(N,ls(B,n.BYTES));return _t("result",j,n.BYTES*2)}const v=L2;function u(p,w,A,C=v){const{context:k,zip215:I}=C,y=n.BYTES;p=_t("signature",p,2*y),w=_t("message",w),A=_t("publicKey",A,y),I!==void 0&&Mn("zip215",I),o&&(w=o(w));const N=lo(p.slice(y,2*y));let re,B,j;try{re=U.fromHex(A,I),B=U.fromHex(p.slice(0,y),I),j=z.multiplyUnsafe(N)}catch{return!1}if(!I&&re.isSmallOrder())return!1;const Z=oe(k,B.toRawBytes(),re.toRawBytes(),w);return B.add(re.multiplyUnsafe(Z)).subtract(j).clearCofactor().equals(U.ZERO)}return z._setWindowSize(8),{CURVE:t,getPublicKey:se,sign:H,verify:u,ExtendedPoint:U,utils:{getExtendedPublicKey:X,randomPrivateKey:()=>a(n.BYTES),precompute(p=8,w=U.BASE){return w._setWindowSize(p),w.multiply(BigInt(3)),w}}}}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const Jl=BigInt("57896044618658097711785492504343953926634992332820282019728792003956564819949"),f0=BigInt("19681161376707505956807079304988542015446066515923890162744021073123829784752");BigInt(0);const V2=BigInt(1),u0=BigInt(2);BigInt(3);const j2=BigInt(5),K2=BigInt(8);function z2(r){const t=BigInt(10),n=BigInt(20),i=BigInt(40),o=BigInt(80),s=Jl,c=r*r%s*r%s,f=St(c,u0,s)*c%s,h=St(f,V2,s)*r%s,d=St(h,j2,s)*h%s,g=St(d,t,s)*d%s,x=St(g,n,s)*g%s,S=St(x,i,s)*x%s,D=St(S,o,s)*S%s,E=St(D,o,s)*S%s,_=St(E,t,s)*d%s;return{pow_p_5_8:St(_,u0,s)*r%s,b2:c}}function q2(r){return r[0]&=248,r[31]&=127,r[31]|=64,r}function G2(r,t){const n=Jl,i=xt(t*t*t,n),o=xt(i*i*t,n),s=z2(r*o).pow_p_5_8;let a=xt(r*i*s,n);const c=xt(t*a*a,n),f=a,h=xt(a*f0,n),d=c===r,g=c===xt(-r,n),x=c===xt(-r*f0,n);return d&&(a=f),(g||x)&&(a=h),M2(a,n)&&(a=xt(-a,n)),{isValid:d||g,value:a}}const W2=Ts(Jl,void 0,!0),J2={a:BigInt(-1),d:BigInt("37095705934669439343138083508754565189542113879843219016388785533085940283555"),Fp:W2,n:BigInt("7237005577332262213973186563042994240857116359379907606001950938285454250989"),h:K2,Gx:BigInt("15112221349535400772501151409588531511454012693041857206046113283949847762202"),Gy:BigInt("46316835694926478169428394003475163141307993866256225615783033603165251855960"),hash:g2,randomBytes:mg,adjustScalarBytes:q2,uvRatio:G2},Y2=$2(J2);var ra={exports:{}},jf,l0;function Z2(){if(l0)return jf;l0=1;function r(t){if(t.length>=255)throw new TypeError("Alphabet too long");for(var n=new Uint8Array(256),i=0;i<n.length;i++)n[i]=255;for(var o=0;o<t.length;o++){var s=t.charAt(o),a=s.charCodeAt(0);if(n[a]!==255)throw new TypeError(s+" is ambiguous");n[a]=o}var c=t.length,f=t.charAt(0),h=Math.log(c)/Math.log(256),d=Math.log(256)/Math.log(c);function g(D){if(D instanceof Uint8Array||(ArrayBuffer.isView(D)?D=new Uint8Array(D.buffer,D.byteOffset,D.byteLength):Array.isArray(D)&&(D=Uint8Array.from(D))),!(D instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(D.length===0)return"";for(var E=0,_=0,T=0,F=D.length;T!==F&&D[T]===0;)T++,E++;for(var U=(F-T)*d+1>>>0,z=new Uint8Array(U);T!==F;){for(var V=D[T],G=0,ee=U-1;(V!==0||G<_)&&ee!==-1;ee--,G++)V+=256*z[ee]>>>0,z[ee]=V%c>>>0,V=V/c>>>0;if(V!==0)throw new Error("Non-zero carry");_=G,T++}for(var Q=U-_;Q!==U&&z[Q]===0;)Q++;for(var X=f.repeat(E);Q<U;++Q)X+=t.charAt(z[Q]);return X}function x(D){if(typeof D!="string")throw new TypeError("Expected String");if(D.length===0)return new Uint8Array;var E=0;if(D[E]!==" "){for(var _=0,T=0;D[E]===f;)_++,E++;for(var F=(D.length-E)*h+1>>>0,U=new Uint8Array(F);D[E];){var z=n[D.charCodeAt(E)];if(z===255)return;for(var V=0,G=F-1;(z!==0||V<T)&&G!==-1;G--,V++)z+=c*U[G]>>>0,U[G]=z%256>>>0,z=z/256>>>0;if(z!==0)throw new Error("Non-zero carry");T=V,E++}if(D[E]!==" "){for(var ee=F-T;ee!==F&&U[ee]===0;)ee++;for(var Q=new Uint8Array(_+(F-ee)),X=_;ee!==F;)Q[X++]=U[ee++];return Q}}}function S(D){var E=x(D);if(E)return E;throw new Error("Non-base"+c+" character")}return{encode:g,decodeUnsafe:x,decode:S}}return jf=r,jf}var Kf,h0;function Yl(){if(h0)return Kf;h0=1;const r=new TextDecoder,t=s=>r.decode(s),n=new TextEncoder,i=s=>n.encode(s);function o(s,a){const c=new Uint8Array(a);let f=0;for(const h of s)c.set(h,f),f+=h.length;return c}return Kf={decodeText:t,encodeText:i,concat:o},Kf}var zf,d0;function X2(){if(d0)return zf;d0=1;const{encodeText:r}=Yl();class t{constructor(i,o,s,a){this.name=i,this.code=o,this.codeBuf=r(this.code),this.alphabet=a,this.codec=s(a)}encode(i){return this.codec.encode(i)}decode(i){for(const o of i)if(this.alphabet&&this.alphabet.indexOf(o)<0)throw new Error(`invalid character '${o}' in '${i}'`);return this.codec.decode(i)}}return zf=t,zf}var qf,p0;function Q2(){if(p0)return qf;p0=1;const r=(i,o,s)=>{const a={};for(let x=0;x<o.length;++x)a[o[x]]=x;let c=i.length;for(;i[c-1]==="=";)--c;const f=new Uint8Array(c*s/8|0);let h=0,d=0,g=0;for(let x=0;x<c;++x){const S=a[i[x]];if(S===void 0)throw new SyntaxError("Invalid character "+i[x]);d=d<<s|S,h+=s,h>=8&&(h-=8,f[g++]=255&d>>h)}if(h>=s||255&d<<8-h)throw new SyntaxError("Unexpected end of data");return f},t=(i,o,s)=>{const a=o[o.length-1]==="=",c=(1<<s)-1;let f="",h=0,d=0;for(let g=0;g<i.length;++g)for(d=d<<8|i[g],h+=8;h>s;)h-=s,f+=o[c&d>>h];if(h&&(f+=o[c&d<<s-h]),a)for(;f.length*s&7;)f+="=";return f};return qf={rfc4648:i=>o=>({encode(s){return t(s,o,i)},decode(s){return r(s,o,i)}})},qf}var Gf,g0;function eA(){if(g0)return Gf;g0=1;const r=Z2(),t=X2(),{rfc4648:n}=Q2(),{decodeText:i,encodeText:o}=Yl(),a=[["identity","\0",()=>({encode:i,decode:o}),""],["base2","0",n(1),"01"],["base8","7",n(3),"01234567"],["base10","9",r,"0123456789"],["base16","f",n(4),"0123456789abcdef"],["base16upper","F",n(4),"0123456789ABCDEF"],["base32hex","v",n(5),"0123456789abcdefghijklmnopqrstuv"],["base32hexupper","V",n(5),"0123456789ABCDEFGHIJKLMNOPQRSTUV"],["base32hexpad","t",n(5),"0123456789abcdefghijklmnopqrstuv="],["base32hexpadupper","T",n(5),"0123456789ABCDEFGHIJKLMNOPQRSTUV="],["base32","b",n(5),"abcdefghijklmnopqrstuvwxyz234567"],["base32upper","B",n(5),"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567"],["base32pad","c",n(5),"abcdefghijklmnopqrstuvwxyz234567="],["base32padupper","C",n(5),"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567="],["base32z","h",n(5),"ybndrfg8ejkmcpqxot1uwisza345h769"],["base36","k",r,"0123456789abcdefghijklmnopqrstuvwxyz"],["base36upper","K",r,"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"],["base58btc","z",r,"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"],["base58flickr","Z",r,"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"],["base64","m",n(6),"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"],["base64pad","M",n(6),"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="],["base64url","u",n(6),"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_"],["base64urlpad","U",n(6),"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_="]],c=a.reduce((h,d)=>(h[d[0]]=new t(d[0],d[1],d[2],d[3]),h),{}),f=a.reduce((h,d)=>(h[d[1]]=c[d[0]],h),{});return Gf={names:c,codes:f},Gf}var y0;function tA(){return y0||(y0=1,function(r,t){const n=eA(),{encodeText:i,decodeText:o,concat:s}=Yl();function a(E,_){if(!_)throw new Error("requires an encoded Uint8Array");const{name:T,codeBuf:F}=g(E);return d(T,_),s([F,_],F.length+_.length)}function c(E,_){const T=g(E),F=i(T.encode(_));return s([T.codeBuf,F],T.codeBuf.length+F.length)}function f(E){E instanceof Uint8Array&&(E=o(E));const _=E[0];return["f","F","v","V","t","T","b","B","c","C","h","k","K"].includes(_)&&(E=E.toLowerCase()),g(E[0]).decode(E.substring(1))}function h(E){if(E instanceof Uint8Array&&(E=o(E)),Object.prototype.toString.call(E)!=="[object String]")return!1;try{return g(E[0]).name}catch{return!1}}function d(E,_){g(E).decode(o(_))}function g(E){if(Object.prototype.hasOwnProperty.call(n.names,E))return n.names[E];if(Object.prototype.hasOwnProperty.call(n.codes,E))return n.codes[E];throw new Error(`Unsupported encoding: ${E}`)}function x(E){return E instanceof Uint8Array&&(E=o(E)),g(E[0])}t=r.exports=a,t.encode=c,t.decode=f,t.isEncoded=h,t.encoding=g,t.encodingFromData=x;const S=Object.freeze(n.names),D=Object.freeze(n.codes);t.names=S,t.codes=D}(ra,ra.exports)),ra.exports}var Rg=tA();const rA=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),ei=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),ti=new Uint32Array(64);class nA extends zl{constructor(){super(64,32,8,!1),this.A=ei[0]|0,this.B=ei[1]|0,this.C=ei[2]|0,this.D=ei[3]|0,this.E=ei[4]|0,this.F=ei[5]|0,this.G=ei[6]|0,this.H=ei[7]|0}get(){const{A:t,B:n,C:i,D:o,E:s,F:a,G:c,H:f}=this;return[t,n,i,o,s,a,c,f]}set(t,n,i,o,s,a,c,f){this.A=t|0,this.B=n|0,this.C=i|0,this.D=o|0,this.E=s|0,this.F=a|0,this.G=c|0,this.H=f|0}process(t,n){for(let g=0;g<16;g++,n+=4)ti[g]=t.getUint32(n,!1);for(let g=16;g<64;g++){const x=ti[g-15],S=ti[g-2],D=cn(x,7)^cn(x,18)^x>>>3,E=cn(S,17)^cn(S,19)^S>>>10;ti[g]=E+ti[g-7]+D+ti[g-16]|0}let{A:i,B:o,C:s,D:a,E:c,F:f,G:h,H:d}=this;for(let g=0;g<64;g++){const x=cn(c,6)^cn(c,11)^cn(c,25),S=d+x+Wx(c,f,h)+rA[g]+ti[g]|0,E=(cn(i,2)^cn(i,13)^cn(i,22))+Jx(i,o,s)|0;d=h,h=f,f=c,c=a+S|0,a=s,s=o,o=i,i=S+E|0}i=i+this.A|0,o=o+this.B|0,s=s+this.C|0,a=a+this.D|0,c=c+this.E|0,f=f+this.F|0,h=h+this.G|0,d=d+this.H|0,this.set(i,o,s,a,c,f,h,d)}roundClean(){ti.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}}const Zl=cc(()=>new nA),iA=new Uint8Array([7,4,13,1,10,6,15,3,12,0,9,5,2,14,11,8]),Ug=new Uint8Array(new Array(16).fill(0).map((r,t)=>t)),oA=Ug.map(r=>(9*r+5)%16);let Xl=[Ug],Ql=[oA];for(let r=0;r<4;r++)for(let t of[Xl,Ql])t.push(t[r].map(n=>iA[n]));const Og=[[11,14,15,12,5,8,7,9,11,13,14,15,6,7,9,8],[12,13,11,15,6,9,9,7,12,15,11,13,7,8,7,7],[13,15,14,11,7,7,6,8,13,14,13,12,5,5,6,9],[14,11,12,14,8,6,5,5,15,12,15,14,9,9,8,6],[15,12,13,13,9,5,8,6,14,11,12,11,8,6,5,5]].map(r=>new Uint8Array(r)),sA=Xl.map((r,t)=>r.map(n=>Og[t][n])),aA=Ql.map((r,t)=>r.map(n=>Og[t][n])),cA=new Uint32Array([0,1518500249,1859775393,2400959708,2840853838]),fA=new Uint32Array([1352829926,1548603684,1836072691,2053994217,0]);function w0(r,t,n,i){return r===0?t^n^i:r===1?t&n|~t&i:r===2?(t|~n)^i:r===3?t&i|n&~i:t^(n|~i)}const na=new Uint32Array(16);class uA extends zl{constructor(){super(64,20,8,!0),this.h0=1732584193,this.h1=-271733879,this.h2=-1732584194,this.h3=271733878,this.h4=-1009589776}get(){const{h0:t,h1:n,h2:i,h3:o,h4:s}=this;return[t,n,i,o,s]}set(t,n,i,o,s){this.h0=t|0,this.h1=n|0,this.h2=i|0,this.h3=o|0,this.h4=s|0}process(t,n){for(let S=0;S<16;S++,n+=4)na[S]=t.getUint32(n,!0);let i=this.h0|0,o=i,s=this.h1|0,a=s,c=this.h2|0,f=c,h=this.h3|0,d=h,g=this.h4|0,x=g;for(let S=0;S<5;S++){const D=4-S,E=cA[S],_=fA[S],T=Xl[S],F=Ql[S],U=sA[S],z=aA[S];for(let V=0;V<16;V++){const G=Xs(i+w0(S,s,c,h)+na[T[V]]+E,U[V])+g|0;i=g,g=h,h=Xs(c,10)|0,c=s,s=G}for(let V=0;V<16;V++){const G=Xs(o+w0(D,a,f,d)+na[F[V]]+_,z[V])+x|0;o=x,x=d,d=Xs(f,10)|0,f=a,a=G}}this.set(this.h1+c+d|0,this.h2+h+x|0,this.h3+g+o|0,this.h4+i+a|0,this.h0+s+f|0)}roundClean(){na.fill(0)}destroy(){this.destroyed=!0,this.buffer.fill(0),this.set(0,0,0,0,0)}}const Pg=cc(()=>new uA),Fg=[],Lg=[],Hg=[],lA=BigInt(0),jo=BigInt(1),hA=BigInt(2),dA=BigInt(7),pA=BigInt(256),gA=BigInt(113);for(let r=0,t=jo,n=1,i=0;r<24;r++){[n,i]=[i,(2*n+3*i)%5],Fg.push(2*(5*i+n)),Lg.push((r+1)*(r+2)/2%64);let o=lA;for(let s=0;s<7;s++)t=(t<<jo^(t>>dA)*gA)%pA,t&hA&&(o^=jo<<(jo<<BigInt(s))-jo);Hg.push(o)}const[yA,wA]=vg(Hg,!0),m0=(r,t,n)=>n>32?Eg(r,t,n):xg(r,t,n),b0=(r,t,n)=>n>32?Sg(r,t,n):Ag(r,t,n);function mA(r,t=24){const n=new Uint32Array(10);for(let i=24-t;i<24;i++){for(let a=0;a<10;a++)n[a]=r[a]^r[a+10]^r[a+20]^r[a+30]^r[a+40];for(let a=0;a<10;a+=2){const c=(a+8)%10,f=(a+2)%10,h=n[f],d=n[f+1],g=m0(h,d,1)^n[c],x=b0(h,d,1)^n[c+1];for(let S=0;S<50;S+=10)r[a+S]^=g,r[a+S+1]^=x}let o=r[2],s=r[3];for(let a=0;a<24;a++){const c=Lg[a],f=m0(o,s,c),h=b0(o,s,c),d=Fg[a];o=r[d],s=r[d+1],r[d]=f,r[d+1]=h}for(let a=0;a<50;a+=10){for(let c=0;c<10;c++)n[c]=r[a+c];for(let c=0;c<10;c++)r[a+c]^=~n[(c+2)%10]&n[(c+4)%10]}r[0]^=yA[i],r[1]^=wA[i]}n.fill(0)}class eh extends Kl{constructor(t,n,i,o=!1,s=24){if(super(),this.blockLen=t,this.suffix=n,this.outputLen=i,this.enableXOF=o,this.rounds=s,this.pos=0,this.posOut=0,this.finished=!1,this.destroyed=!1,Ua(i),0>=this.blockLen||this.blockLen>=200)throw new Error("Sha3 supports only keccak-f1600 function");this.state=new Uint8Array(200),this.state32=jx(this.state)}keccak(){t0||r0(this.state32),mA(this.state32,this.rounds),t0||r0(this.state32),this.posOut=0,this.pos=0}update(t){vo(this);const{blockLen:n,state:i}=this;t=ac(t);const o=t.length;for(let s=0;s<o;){const a=Math.min(n-this.pos,o-s);for(let c=0;c<a;c++)i[this.pos++]^=t[s++];this.pos===n&&this.keccak()}return this}finish(){if(this.finished)return;this.finished=!0;const{state:t,suffix:n,pos:i,blockLen:o}=this;t[i]^=n,n&128&&i===o-1&&this.keccak(),t[o-1]^=128,this.keccak()}writeInto(t){vo(this,!1),Ms(t),this.finish();const n=this.state,{blockLen:i}=this;for(let o=0,s=t.length;o<s;){this.posOut>=i&&this.keccak();const a=Math.min(i-this.posOut,s-o);t.set(n.subarray(this.posOut,this.posOut+a),o),this.posOut+=a,o+=a}return t}xofInto(t){if(!this.enableXOF)throw new Error("XOF is not possible for this instance");return this.writeInto(t)}xof(t){return Ua(t),this.xofInto(new Uint8Array(t))}digestInto(t){if(wg(t,this),this.finished)throw new Error("digest() was already called");return this.writeInto(t),this.destroy(),t}digest(){return this.digestInto(new Uint8Array(this.outputLen))}destroy(){this.destroyed=!0,this.state.fill(0)}_cloneInto(t){const{blockLen:n,suffix:i,outputLen:o,rounds:s,enableXOF:a}=this;return t||(t=new eh(n,i,o,a,s)),t.state32.set(this.state32),t.pos=this.pos,t.posOut=this.posOut,t.finished=this.finished,t.rounds=s,t.suffix=i,t.outputLen=o,t.enableXOF=a,t.destroyed=this.destroyed,t}}const bA=(r,t,n)=>cc(()=>new eh(t,r,n)),vA=bA(1,136,256/8);class $g extends Kl{constructor(t,n){super(),this.finished=!1,this.destroyed=!1,Vx(t);const i=ac(n);if(this.iHash=t.create(),typeof this.iHash.update!="function")throw new Error("Expected instance of class which extends utils.Hash");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;const o=this.blockLen,s=new Uint8Array(o);s.set(i.length>o?t.create().update(i).digest():i);for(let a=0;a<s.length;a++)s[a]^=54;this.iHash.update(s),this.oHash=t.create();for(let a=0;a<s.length;a++)s[a]^=106;this.oHash.update(s),s.fill(0)}update(t){return vo(this),this.iHash.update(t),this}digestInto(t){vo(this),Ms(t,this.outputLen),this.finished=!0,this.iHash.digestInto(t),this.oHash.update(t),this.oHash.digestInto(t),this.destroy()}digest(){const t=new Uint8Array(this.oHash.outputLen);return this.digestInto(t),t}_cloneInto(t){t||(t=Object.create(Object.getPrototypeOf(this),{}));const{oHash:n,iHash:i,finished:o,destroyed:s,blockLen:a,outputLen:c}=this;return t=t,t.finished=o,t.destroyed=s,t.blockLen=a,t.outputLen=c,t.oHash=n._cloneInto(t.oHash),t.iHash=i._cloneInto(t.iHash),t}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}}const Vg=(r,t,n)=>new $g(r,t).update(n).digest();Vg.create=(r,t)=>new $g(r,t);/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */function v0(r){r.lowS!==void 0&&Mn("lowS",r.lowS),r.prehash!==void 0&&Mn("prehash",r.prehash)}function xA(r){const t=Wl(r);Ro(t,{a:"field",b:"field"},{allowedPrivateKeyLengths:"array",wrapPrivateKey:"boolean",isTorsionFree:"function",clearCofactor:"function",allowInfinityPoint:"boolean",fromBytes:"function",toBytes:"function"});const{endo:n,Fp:i,a:o}=t;if(n){if(!i.eql(o,i.ZERO))throw new Error("invalid endomorphism, can only be defined for Koblitz curves that have a=0");if(typeof n!="object"||typeof n.beta!="bigint"||typeof n.splitScalar!="function")throw new Error("invalid endomorphism, expected beta: bigint and splitScalar: function")}return Object.freeze({...t})}const{bytesToNumberBE:AA,hexToBytes:EA}=B2;class SA extends Error{constructor(t=""){super(t)}}const Bn={Err:SA,_tlv:{encode:(r,t)=>{const{Err:n}=Bn;if(r<0||r>256)throw new n("tlv.encode: wrong tag");if(t.length&1)throw new n("tlv.encode: unpadded data");const i=t.length/2,o=co(i);if(o.length/2&128)throw new n("tlv.encode: long form length too big");const s=i>127?co(o.length/2|128):"";return co(r)+s+o+t},decode(r,t){const{Err:n}=Bn;let i=0;if(r<0||r>256)throw new n("tlv.encode: wrong tag");if(t.length<2||t[i++]!==r)throw new n("tlv.decode: wrong tlv");const o=t[i++],s=!!(o&128);let a=0;if(!s)a=o;else{const f=o&127;if(!f)throw new n("tlv.decode(long): indefinite length not supported");if(f>4)throw new n("tlv.decode(long): byte length is too big");const h=t.subarray(i,i+f);if(h.length!==f)throw new n("tlv.decode: length bytes not complete");if(h[0]===0)throw new n("tlv.decode(long): zero leftmost byte");for(const d of h)a=a<<8|d;if(i+=f,a<128)throw new n("tlv.decode(long): not minimal encoding")}const c=t.subarray(i,i+a);if(c.length!==a)throw new n("tlv.decode: wrong value length");return{v:c,l:t.subarray(i+a)}}},_int:{encode(r){const{Err:t}=Bn;if(r<Cn)throw new t("integer: negative integers are not allowed");let n=co(r);if(Number.parseInt(n[0],16)&8&&(n="00"+n),n.length&1)throw new t("unexpected DER parsing assertion: unpadded hex");return n},decode(r){const{Err:t}=Bn;if(r[0]&128)throw new t("invalid signature integer: negative");if(r[0]===0&&!(r[1]&128))throw new t("invalid signature integer: unnecessary leading zero");return AA(r)}},toSig(r){const{Err:t,_int:n,_tlv:i}=Bn,o=typeof r=="string"?EA(r):r;ks(o);const{v:s,l:a}=i.decode(48,o);if(a.length)throw new t("invalid signature: left bytes after parsing");const{v:c,l:f}=i.decode(2,s),{v:h,l:d}=i.decode(2,f);if(d.length)throw new t("invalid signature: left bytes after parsing");return{r:n.decode(c),s:n.decode(h)}},hexFromSig(r){const{_tlv:t,_int:n}=Bn,i=t.encode(2,n.encode(r.r)),o=t.encode(2,n.encode(r.s)),s=i+o;return t.encode(48,s)}},Cn=BigInt(0),Lt=BigInt(1);BigInt(2);const x0=BigInt(3);BigInt(4);function BA(r){const t=xA(r),{Fp:n}=t,i=Ts(t.n,t.nBitLength),o=t.toBytes||((E,_,T)=>{const F=_.toAffine();return Ki(Uint8Array.from([4]),n.toBytes(F.x),n.toBytes(F.y))}),s=t.fromBytes||(E=>{const _=E.subarray(1),T=n.fromBytes(_.subarray(0,n.BYTES)),F=n.fromBytes(_.subarray(n.BYTES,2*n.BYTES));return{x:T,y:F}});function a(E){const{a:_,b:T}=t,F=n.sqr(E),U=n.mul(F,E);return n.add(n.add(U,n.mul(E,_)),T)}if(!n.eql(n.sqr(t.Gy),a(t.Gx)))throw new Error("bad generator point: equation left != right");function c(E){return lc(E,Lt,t.n)}function f(E){const{allowedPrivateKeyLengths:_,nByteLength:T,wrapPrivateKey:F,n:U}=t;if(_&&typeof E!="bigint"){if(Vi(E)&&(E=ji(E)),typeof E!="string"||!_.includes(E.length))throw new Error("invalid private key");E=E.padStart(T*2,"0")}let z;try{z=typeof E=="bigint"?E:Fi(_t("private key",E,T))}catch{throw new Error("invalid private key, expected hex or "+T+" bytes, got "+typeof E)}return F&&(z=xt(z,U)),kr("private key",z,Lt,U),z}function h(E){if(!(E instanceof x))throw new Error("ProjectivePoint expected")}const d=hs((E,_)=>{const{px:T,py:F,pz:U}=E;if(n.eql(U,n.ONE))return{x:T,y:F};const z=E.is0();_==null&&(_=z?n.ONE:n.inv(U));const V=n.mul(T,_),G=n.mul(F,_),ee=n.mul(U,_);if(z)return{x:n.ZERO,y:n.ZERO};if(!n.eql(ee,n.ONE))throw new Error("invZ was invalid");return{x:V,y:G}}),g=hs(E=>{if(E.is0()){if(t.allowInfinityPoint&&!n.is0(E.py))return;throw new Error("bad point: ZERO")}const{x:_,y:T}=E.toAffine();if(!n.isValid(_)||!n.isValid(T))throw new Error("bad point: x or y not FE");const F=n.sqr(T),U=a(_);if(!n.eql(F,U))throw new Error("bad point: equation left != right");if(!E.isTorsionFree())throw new Error("bad point: not in prime-order subgroup");return!0});class x{constructor(_,T,F){if(this.px=_,this.py=T,this.pz=F,_==null||!n.isValid(_))throw new Error("x required");if(T==null||!n.isValid(T))throw new Error("y required");if(F==null||!n.isValid(F))throw new Error("z required");Object.freeze(this)}static fromAffine(_){const{x:T,y:F}=_||{};if(!_||!n.isValid(T)||!n.isValid(F))throw new Error("invalid affine point");if(_ instanceof x)throw new Error("projective point not allowed");const U=z=>n.eql(z,n.ZERO);return U(T)&&U(F)?x.ZERO:new x(T,F,n.ONE)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static normalizeZ(_){const T=n.invertBatch(_.map(F=>F.pz));return _.map((F,U)=>F.toAffine(T[U])).map(x.fromAffine)}static fromHex(_){const T=x.fromAffine(s(_t("pointHex",_)));return T.assertValidity(),T}static fromPrivateKey(_){return x.BASE.multiply(f(_))}static msm(_,T){return Ng(x,i,_,T)}_setWindowSize(_){D.setWindowSize(this,_)}assertValidity(){g(this)}hasEvenY(){const{y:_}=this.toAffine();if(n.isOdd)return!n.isOdd(_);throw new Error("Field doesn't support isOdd")}equals(_){h(_);const{px:T,py:F,pz:U}=this,{px:z,py:V,pz:G}=_,ee=n.eql(n.mul(T,G),n.mul(z,U)),Q=n.eql(n.mul(F,G),n.mul(V,U));return ee&&Q}negate(){return new x(this.px,n.neg(this.py),this.pz)}double(){const{a:_,b:T}=t,F=n.mul(T,x0),{px:U,py:z,pz:V}=this;let G=n.ZERO,ee=n.ZERO,Q=n.ZERO,X=n.mul(U,U),se=n.mul(z,z),oe=n.mul(V,V),H=n.mul(U,z);return H=n.add(H,H),Q=n.mul(U,V),Q=n.add(Q,Q),G=n.mul(_,Q),ee=n.mul(F,oe),ee=n.add(G,ee),G=n.sub(se,ee),ee=n.add(se,ee),ee=n.mul(G,ee),G=n.mul(H,G),Q=n.mul(F,Q),oe=n.mul(_,oe),H=n.sub(X,oe),H=n.mul(_,H),H=n.add(H,Q),Q=n.add(X,X),X=n.add(Q,X),X=n.add(X,oe),X=n.mul(X,H),ee=n.add(ee,X),oe=n.mul(z,V),oe=n.add(oe,oe),X=n.mul(oe,H),G=n.sub(G,X),Q=n.mul(oe,se),Q=n.add(Q,Q),Q=n.add(Q,Q),new x(G,ee,Q)}add(_){h(_);const{px:T,py:F,pz:U}=this,{px:z,py:V,pz:G}=_;let ee=n.ZERO,Q=n.ZERO,X=n.ZERO;const se=t.a,oe=n.mul(t.b,x0);let H=n.mul(T,z),v=n.mul(F,V),u=n.mul(U,G),l=n.add(T,F),p=n.add(z,V);l=n.mul(l,p),p=n.add(H,v),l=n.sub(l,p),p=n.add(T,U);let w=n.add(z,G);return p=n.mul(p,w),w=n.add(H,u),p=n.sub(p,w),w=n.add(F,U),ee=n.add(V,G),w=n.mul(w,ee),ee=n.add(v,u),w=n.sub(w,ee),X=n.mul(se,p),ee=n.mul(oe,u),X=n.add(ee,X),ee=n.sub(v,X),X=n.add(v,X),Q=n.mul(ee,X),v=n.add(H,H),v=n.add(v,H),u=n.mul(se,u),p=n.mul(oe,p),v=n.add(v,u),u=n.sub(H,u),u=n.mul(se,u),p=n.add(p,u),H=n.mul(v,p),Q=n.add(Q,H),H=n.mul(w,p),ee=n.mul(l,ee),ee=n.sub(ee,H),H=n.mul(l,v),X=n.mul(w,X),X=n.add(X,H),new x(ee,Q,X)}subtract(_){return this.add(_.negate())}is0(){return this.equals(x.ZERO)}wNAF(_){return D.wNAFCached(this,_,x.normalizeZ)}multiplyUnsafe(_){const{endo:T,n:F}=t;kr("scalar",_,Cn,F);const U=x.ZERO;if(_===Cn)return U;if(this.is0()||_===Lt)return this;if(!T||D.hasPrecomputes(this))return D.wNAFCachedUnsafe(this,_,x.normalizeZ);let{k1neg:z,k1:V,k2neg:G,k2:ee}=T.splitScalar(_),Q=U,X=U,se=this;for(;V>Cn||ee>Cn;)V&Lt&&(Q=Q.add(se)),ee&Lt&&(X=X.add(se)),se=se.double(),V>>=Lt,ee>>=Lt;return z&&(Q=Q.negate()),G&&(X=X.negate()),X=new x(n.mul(X.px,T.beta),X.py,X.pz),Q.add(X)}multiply(_){const{endo:T,n:F}=t;kr("scalar",_,Lt,F);let U,z;if(T){const{k1neg:V,k1:G,k2neg:ee,k2:Q}=T.splitScalar(_);let{p:X,f:se}=this.wNAF(G),{p:oe,f:H}=this.wNAF(Q);X=D.constTimeNegate(V,X),oe=D.constTimeNegate(ee,oe),oe=new x(n.mul(oe.px,T.beta),oe.py,oe.pz),U=X.add(oe),z=se.add(H)}else{const{p:V,f:G}=this.wNAF(_);U=V,z=G}return x.normalizeZ([U,z])[0]}multiplyAndAddUnsafe(_,T,F){const U=x.BASE,z=(G,ee)=>ee===Cn||ee===Lt||!G.equals(U)?G.multiplyUnsafe(ee):G.multiply(ee),V=z(this,T).add(z(_,F));return V.is0()?void 0:V}toAffine(_){return d(this,_)}isTorsionFree(){const{h:_,isTorsionFree:T}=t;if(_===Lt)return!0;if(T)return T(x,this);throw new Error("isTorsionFree() has not been declared for the elliptic curve")}clearCofactor(){const{h:_,clearCofactor:T}=t;return _===Lt?this:T?T(x,this):this.multiplyUnsafe(t.h)}toRawBytes(_=!0){return Mn("isCompressed",_),this.assertValidity(),o(x,this,_)}toHex(_=!0){return Mn("isCompressed",_),ji(this.toRawBytes(_))}}x.BASE=new x(t.Gx,t.Gy,n.ONE),x.ZERO=new x(n.ZERO,n.ONE,n.ZERO);const S=t.nBitLength,D=Tg(x,t.endo?Math.ceil(S/2):S);return{CURVE:t,ProjectivePoint:x,normPrivateKeyToScalar:f,weierstrassEquation:a,isWithinCurveOrder:c}}function DA(r){const t=Wl(r);return Ro(t,{hash:"hash",hmac:"function",randomBytes:"function"},{bits2int:"function",bits2int_modN:"function",lowS:"boolean"}),Object.freeze({lowS:!0,...t})}function CA(r){const t=DA(r),{Fp:n,n:i}=t,o=n.BYTES+1,s=2*n.BYTES+1;function a(u){return xt(u,i)}function c(u){return _u(u,i)}const{ProjectivePoint:f,normPrivateKeyToScalar:h,weierstrassEquation:d,isWithinCurveOrder:g}=BA({...t,toBytes(u,l,p){const w=l.toAffine(),A=n.toBytes(w.x),C=Ki;return Mn("isCompressed",p),p?C(Uint8Array.from([l.hasEvenY()?2:3]),A):C(Uint8Array.from([4]),A,n.toBytes(w.y))},fromBytes(u){const l=u.length,p=u[0],w=u.subarray(1);if(l===o&&(p===2||p===3)){const A=Fi(w);if(!lc(A,Lt,n.ORDER))throw new Error("Point is not on curve");const C=d(A);let k;try{k=n.sqrt(C)}catch(N){const re=N instanceof Error?": "+N.message:"";throw new Error("Point is not on curve"+re)}const I=(k&Lt)===Lt;return(p&1)===1!==I&&(k=n.neg(k)),{x:A,y:k}}else if(l===s&&p===4){const A=n.fromBytes(w.subarray(0,n.BYTES)),C=n.fromBytes(w.subarray(n.BYTES,2*n.BYTES));return{x:A,y:C}}else{const A=o,C=s;throw new Error("invalid Point, expected length of "+A+", or uncompressed "+C+", got "+l)}}}),x=u=>ji(Ao(u,t.nByteLength));function S(u){const l=i>>Lt;return u>l}function D(u){return S(u)?a(-u):u}const E=(u,l,p)=>Fi(u.slice(l,p));class _{constructor(l,p,w){this.r=l,this.s=p,this.recovery=w,this.assertValidity()}static fromCompact(l){const p=t.nByteLength;return l=_t("compactSignature",l,p*2),new _(E(l,0,p),E(l,p,2*p))}static fromDER(l){const{r:p,s:w}=Bn.toSig(_t("DER",l));return new _(p,w)}assertValidity(){kr("r",this.r,Lt,i),kr("s",this.s,Lt,i)}addRecoveryBit(l){return new _(this.r,this.s,l)}recoverPublicKey(l){const{r:p,s:w,recovery:A}=this,C=G(_t("msgHash",l));if(A==null||![0,1,2,3].includes(A))throw new Error("recovery id invalid");const k=A===2||A===3?p+t.n:p;if(k>=n.ORDER)throw new Error("recovery id 2 or 3 invalid");const I=A&1?"03":"02",y=f.fromHex(I+x(k)),N=c(k),re=a(-C*N),B=a(w*N),j=f.BASE.multiplyAndAddUnsafe(y,re,B);if(!j)throw new Error("point at infinify");return j.assertValidity(),j}hasHighS(){return S(this.s)}normalizeS(){return this.hasHighS()?new _(this.r,a(-this.s),this.recovery):this}toDERRawBytes(){return xo(this.toDERHex())}toDERHex(){return Bn.hexFromSig({r:this.r,s:this.s})}toCompactRawBytes(){return xo(this.toCompactHex())}toCompactHex(){return x(this.r)+x(this.s)}}const T={isValidPrivateKey(u){try{return h(u),!0}catch{return!1}},normPrivateKeyToScalar:h,randomPrivateKey:()=>{const u=_g(t.n);return U2(t.randomBytes(u),t.n)},precompute(u=8,l=f.BASE){return l._setWindowSize(u),l.multiply(BigInt(3)),l}};function F(u,l=!0){return f.fromPrivateKey(u).toRawBytes(l)}function U(u){const l=Vi(u),p=typeof u=="string",w=(l||p)&&u.length;return l?w===o||w===s:p?w===2*o||w===2*s:u instanceof f}function z(u,l,p=!0){if(U(u))throw new Error("first arg must be private key");if(!U(l))throw new Error("second arg must be public key");return f.fromHex(l).multiply(h(u)).toRawBytes(p)}const V=t.bits2int||function(u){if(u.length>8192)throw new Error("input is too large");const l=Fi(u),p=u.length*8-t.nBitLength;return p>0?l>>BigInt(p):l},G=t.bits2int_modN||function(u){return a(V(u))},ee=Gl(t.nBitLength);function Q(u){return kr("num < 2^"+t.nBitLength,u,Cn,ee),Ao(u,t.nByteLength)}function X(u,l,p=se){if(["recovered","canonical"].some(Y=>Y in p))throw new Error("sign() legacy options not supported");const{hash:w,randomBytes:A}=t;let{lowS:C,prehash:k,extraEntropy:I}=p;C==null&&(C=!0),u=_t("msgHash",u),v0(p),k&&(u=_t("prehashed msgHash",w(u)));const y=G(u),N=h(l),re=[Q(N),Q(y)];if(I!=null&&I!==!1){const Y=I===!0?A(n.BYTES):I;re.push(_t("extraEntropy",Y))}const B=Ki(...re),j=y;function Z(Y){const ne=V(Y);if(!g(ne))return;const ue=c(ne),ce=f.BASE.multiply(ne).toAffine(),ae=a(ce.x);if(ae===Cn)return;const be=a(ue*a(j+ae*N));if(be===Cn)return;let fe=(ce.x===ae?0:2)|Number(ce.y&Lt),ge=be;return C&&S(be)&&(ge=D(be),fe^=1),new _(ae,ge,fe)}return{seed:B,k2sig:Z}}const se={lowS:t.lowS,prehash:!1},oe={lowS:t.lowS,prehash:!1};function H(u,l,p=se){const{seed:w,k2sig:A}=X(u,l,p),C=t;return Dg(C.hash.outputLen,C.nByteLength,C.hmac)(w,A)}f.BASE._setWindowSize(8);function v(u,l,p,w=oe){var fe;const A=u;l=_t("msgHash",l),p=_t("publicKey",p);const{lowS:C,prehash:k,format:I}=w;if(v0(w),"strict"in w)throw new Error("options.strict was renamed to lowS");if(I!==void 0&&I!=="compact"&&I!=="der")throw new Error("format must be compact or der");const y=typeof A=="string"||Vi(A),N=!y&&!I&&typeof A=="object"&&A!==null&&typeof A.r=="bigint"&&typeof A.s=="bigint";if(!y&&!N)throw new Error("invalid signature, expected Uint8Array, hex string or Signature instance");let re,B;try{if(N&&(re=new _(A.r,A.s)),y){try{I!=="compact"&&(re=_.fromDER(A))}catch(ge){if(!(ge instanceof Bn.Err))throw ge}!re&&I!=="der"&&(re=_.fromCompact(A))}B=f.fromHex(p)}catch{return!1}if(!re||C&&re.hasHighS())return!1;k&&(l=t.hash(l));const{r:j,s:Z}=re,Y=G(l),ne=c(Z),ue=a(Y*ne),ce=a(j*ne),ae=(fe=f.BASE.multiplyAndAddUnsafe(B,ue,ce))==null?void 0:fe.toAffine();return ae?a(ae.x)===j:!1}return{CURVE:t,getPublicKey:F,getSharedSecret:z,sign:H,verify:v,ProjectivePoint:f,Signature:_,utils:T}}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */function IA(r){return{hash:r,hmac:(t,...n)=>Vg(r,t,qx(...n)),randomBytes:mg}}function jg(r,t){const n=i=>CA({...r,...IA(i)});return{...n(t),create:n}}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const Kg=BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),A0=BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),_A=BigInt(1),Mu=BigInt(2),E0=(r,t)=>(r+t/Mu)/t;function MA(r){const t=Kg,n=BigInt(3),i=BigInt(6),o=BigInt(11),s=BigInt(22),a=BigInt(23),c=BigInt(44),f=BigInt(88),h=r*r*r%t,d=h*h*r%t,g=St(d,n,t)*d%t,x=St(g,n,t)*d%t,S=St(x,Mu,t)*h%t,D=St(S,o,t)*S%t,E=St(D,s,t)*D%t,_=St(E,c,t)*E%t,T=St(_,f,t)*_%t,F=St(T,c,t)*E%t,U=St(F,n,t)*d%t,z=St(U,a,t)*D%t,V=St(z,i,t)*h%t,G=St(V,Mu,t);if(!ku.eql(ku.sqr(G),r))throw new Error("Cannot find square root");return G}const ku=Ts(Kg,void 0,void 0,{sqrt:MA}),zi=jg({a:BigInt(0),b:BigInt(7),Fp:ku,n:A0,Gx:BigInt("55066263022277343669578718895168534326250603453777594175500187360389116729240"),Gy:BigInt("32670510020758816978083085130507043184471273380659243275938904335757337482424"),h:BigInt(1),lowS:!0,endo:{beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),splitScalar:r=>{const t=A0,n=BigInt("0x3086d221a7d46bcde86c90e49284eb15"),i=-_A*BigInt("0xe4437ed6010e88286f547fa90abfe4c3"),o=BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),s=n,a=BigInt("0x100000000000000000000000000000000"),c=E0(s*r,t),f=E0(-i*r,t);let h=xt(r-c*n-f*o,t),d=xt(-c*i-f*s,t);const g=h>a,x=d>a;if(g&&(h=t-h),x&&(d=t-d),h>a||d>a)throw new Error("splitScalar: Endomorphism failed, k="+r);return{k1neg:g,k1:h,k2neg:x,k2:d}}}},Zl);BigInt(0);zi.ProjectivePoint;/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const zg=Ts(BigInt("0xffffffff00000001000000000000000000000000ffffffffffffffffffffffff")),kA=zg.create(BigInt("-3")),TA=BigInt("0x5ac635d8aa3a93e7b3ebbd55769886bc651d06b0cc53b0f63bce3c3e27d2604b"),Tu=jg({a:kA,b:TA,Fp:zg,n:BigInt("0xffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc632551"),Gx:BigInt("0x6b17d1f2e12c4247f8bce6e563a440f277037d812deb33a0f4a13945d898c296"),Gy:BigInt("0x4fe342e2fe1a7f9b8ee7eb4a7c0f9e162bce33576b315ececbb6406837bf51f5"),h:BigInt(1),lowS:!1},Zl);var Wf,S0;function NA(){return S0||(S0=1,Wf=function r(t){if(typeof t=="number"&&isNaN(t))throw new Error("NaN is not allowed");if(typeof t=="number"&&!isFinite(t))throw new Error("Infinity is not allowed");return t===null||typeof t!="object"?JSON.stringify(t):t.toJSON instanceof Function?r(t.toJSON()):Array.isArray(t)?`[${t.reduce((o,s,a)=>`${o}${a===0?"":","}${r(s===void 0||typeof s=="symbol"?null:s)}`,"")}]`:`{${Object.keys(t).sort().reduce((i,o)=>{if(t[o]===void 0||typeof t[o]=="symbol")return i;const s=i.length===0?"":",";return`${i}${s}${r(o)}:${r(t[o])}`},"")}}`}),Wf}var RA=NA();const UA=tc(RA);function OA(r,t){try{var n=r()}catch(i){return t(i)}return n&&n.then?n.then(void 0,t):n}function PA(){const r=new Map;return function(t,n){try{let o=function(a){if(i)return a;const c=r.get(t.didUrl);return c!==void 0?c:Promise.resolve(n()).then(function(f){var h;return((h=f.didResolutionMetadata)==null?void 0:h.error)!=="notFound"&&r.set(t.didUrl,f),f})},i;const s=function(){if(t.params&&t.params["no-cache"]==="true")return Promise.resolve(n()).then(function(a){return i=1,a})}();return Promise.resolve(s&&s.then?s.then(o):o(s))}catch(i){return Promise.reject(i)}}}function FA(r,t){return t()}const LA="(?:%[0-9a-fA-F]{2})",B0=`(?:[a-zA-Z0-9._-]|${LA})`,HA="([a-z0-9]+)",$A=`((?:${B0}*:)*(${B0}+))`,D0="[a-zA-Z0-9_.:%-]",VA=`;${D0}+=${D0}*`,jA=`((${VA})*)`,KA="(/[^#?]*)?",zA="([?][^#]*)?",qA="(#.*)?",GA=new RegExp(`^did:${HA}:${$A}${jA}${KA}${zA}${qA}$`);function qg(r){if(r===""||!r)return null;const t=r.match(GA);if(t){const n={did:`did:${t[1]}:${t[2]}`,method:t[1],id:t[2],didUrl:r};if(t[4]){const i=t[4].slice(1).split(";");n.params={};for(const o of i){const s=o.split("=");n.params[s[0]]=s[1]}}return t[6]&&(n.path=t[6]),t[7]&&(n.query=t[7].slice(1)),t[8]&&(n.fragment=t[8].slice(1)),n}return null}const Oa={didResolutionMetadata:{},didDocument:null,didDocumentMetadata:{}};function WA(r){return function(t,n,i){try{return Promise.resolve(OA(function(){return Promise.resolve(r(t,n,i)).then(function(o){return{...Oa,didResolutionMetadata:{contentType:"application/did+ld+json"},didDocument:o}})},function(o){return{...Oa,didResolutionMetadata:{error:"notFound",message:o.toString()}}}))}catch(o){return Promise.reject(o)}}}class JA{constructor(t={},n={}){this.registry=void 0,this.cache=void 0,this.registry=t,this.cache=n.cache===!0?PA():n.cache||FA,n.legacyResolvers&&Object.keys(n.legacyResolvers).map(i=>{this.registry[i]||(this.registry[i]=WA(n.legacyResolvers[i]))})}resolve(t,n={}){try{const i=this,o=qg(t);if(o===null)return Promise.resolve({...Oa,didResolutionMetadata:{error:"invalidDid"}});const s=i.registry[o.method];return s?Promise.resolve(i.cache(o,()=>s(o.did,o,i,n))):Promise.resolve({...Oa,didResolutionMetadata:{error:"unsupportedDidMethod"}})}catch(i){return Promise.reject(i)}}}/*! scure-base - MIT License (c) 2022 Paul Miller (paulmillr.com) */function Gg(r){return r instanceof Uint8Array||ArrayBuffer.isView(r)&&r.constructor.name==="Uint8Array"}function Wg(r,t){return Array.isArray(t)?t.length===0?!0:r?t.every(n=>typeof n=="string"):t.every(n=>Number.isSafeInteger(n)):!1}function YA(r){if(typeof r!="function")throw new Error("function expected");return!0}function ds(r,t){if(typeof t!="string")throw new Error(`${r}: string expected`);return!0}function Jg(r){if(!Number.isSafeInteger(r))throw new Error(`invalid integer: ${r}`)}function Nu(r){if(!Array.isArray(r))throw new Error("array expected")}function Yg(r,t){if(!Wg(!0,t))throw new Error(`${r}: array of strings expected`)}function Zg(r,t){if(!Wg(!1,t))throw new Error(`${r}: array of numbers expected`)}function ZA(...r){const t=s=>s,n=(s,a)=>c=>s(a(c)),i=r.map(s=>s.encode).reduceRight(n,t),o=r.map(s=>s.decode).reduce(n,t);return{encode:i,decode:o}}function XA(r){const t=typeof r=="string"?r.split(""):r,n=t.length;Yg("alphabet",t);const i=new Map(t.map((o,s)=>[o,s]));return{encode:o=>(Nu(o),o.map(s=>{if(!Number.isSafeInteger(s)||s<0||s>=n)throw new Error(`alphabet.encode: digit index outside alphabet "${s}". Allowed: ${r}`);return t[s]})),decode:o=>(Nu(o),o.map(s=>{ds("alphabet.decode",s);const a=i.get(s);if(a===void 0)throw new Error(`Unknown letter: "${s}". Allowed: ${r}`);return a}))}}function QA(r=""){return ds("join",r),{encode:t=>(Yg("join.decode",t),t.join(r)),decode:t=>(ds("join.decode",t),t.split(r))}}const Xg=(r,t)=>t===0?r:Xg(t,r%t),Pa=(r,t)=>r+(t-Xg(r,t)),wa=(()=>{let r=[];for(let t=0;t<40;t++)r.push(2**t);return r})();function Ru(r,t,n,i){if(Nu(r),t<=0||t>32)throw new Error(`convertRadix2: wrong from=${t}`);if(n<=0||n>32)throw new Error(`convertRadix2: wrong to=${n}`);if(Pa(t,n)>32)throw new Error(`convertRadix2: carry overflow from=${t} to=${n} carryBits=${Pa(t,n)}`);let o=0,s=0;const a=wa[t],c=wa[n]-1,f=[];for(const h of r){if(Jg(h),h>=a)throw new Error(`convertRadix2: invalid data word=${h} from=${t}`);if(o=o<<t|h,s+t>32)throw new Error(`convertRadix2: carry overflow pos=${s} from=${t}`);for(s+=t;s>=n;s-=n)f.push((o>>s-n&c)>>>0);const d=wa[s];if(d===void 0)throw new Error("invalid carry");o&=d-1}if(o=o<<n-s&c,!i&&s>=t)throw new Error("Excess padding");if(!i&&o>0)throw new Error(`Non-zero padding: ${o}`);return i&&s>0&&f.push(o>>>0),f}function eE(r,t=!1){if(Jg(r),r<=0||r>32)throw new Error("radix2: bits should be in (0..32]");if(Pa(8,r)>32||Pa(r,8)>32)throw new Error("radix2: carry overflow");return{encode:n=>{if(!Gg(n))throw new Error("radix2.encode input should be Uint8Array");return Ru(Array.from(n),8,r,!t)},decode:n=>(Zg("radix2.decode",n),Uint8Array.from(Ru(n,r,8,t)))}}function C0(r){return YA(r),function(...t){try{return r.apply(null,t)}catch{}}}const Uu=ZA(XA("qpzry9x8gf2tvdw0s3jn54khce6mua7l"),QA("")),I0=[996825010,642813549,513874426,1027748829,705979059];function Ko(r){const t=r>>25;let n=(r&33554431)<<5;for(let i=0;i<I0.length;i++)(t>>i&1)===1&&(n^=I0[i]);return n}function _0(r,t,n=1){const i=r.length;let o=1;for(let s=0;s<i;s++){const a=r.charCodeAt(s);if(a<33||a>126)throw new Error(`Invalid prefix (${r})`);o=Ko(o)^a>>5}o=Ko(o);for(let s=0;s<i;s++)o=Ko(o)^r.charCodeAt(s)&31;for(let s of t)o=Ko(o)^s;for(let s=0;s<6;s++)o=Ko(o);return o^=n,Uu.encode(Ru([o%wa[30]],30,5,!1))}function tE(r){const t=r==="bech32"?1:734539939,n=eE(5),i=n.decode,o=n.encode,s=C0(i);function a(g,x,S=90){ds("bech32.encode prefix",g),Gg(x)&&(x=Array.from(x)),Zg("bech32.encode",x);const D=g.length;if(D===0)throw new TypeError(`Invalid prefix length ${D}`);const E=D+7+x.length;if(S!==!1&&E>S)throw new TypeError(`Length ${E} exceeds limit ${S}`);const _=g.toLowerCase(),T=_0(_,x,t);return`${_}1${Uu.encode(x)}${T}`}function c(g,x=90){ds("bech32.decode input",g);const S=g.length;if(S<8||x!==!1&&S>x)throw new TypeError(`invalid string length: ${S} (${g}). Expected (8..${x})`);const D=g.toLowerCase();if(g!==D&&g!==g.toUpperCase())throw new Error("String must be lowercase or uppercase");const E=D.lastIndexOf("1");if(E===0||E===-1)throw new Error('Letter "1" must be present between prefix and data only');const _=D.slice(0,E),T=D.slice(E+1);if(T.length<6)throw new Error("Data must be at least 6 characters long");const F=Uu.decode(T).slice(0,-6),U=_0(_,F,t);if(!T.endsWith(U))throw new Error(`Invalid checksum in ${g}: expected "${U}"`);return{prefix:_,words:F}}const f=C0(c);function h(g){const{prefix:x,words:S}=c(g,!1);return{prefix:x,words:S,bytes:i(S)}}function d(g,x){return a(g,o(x))}return{encode:a,decode:c,encodeFromBytes:d,decodeToBytes:h,decodeUnsafe:f,fromWords:i,fromWordsUnsafe:s,toWords:o}}const M0=tE("bech32");/*! noble-ciphers - MIT License (c) 2023 Paul Miller (paulmillr.com) */const Qg=r=>new Uint32Array(r.buffer,r.byteOffset,Math.floor(r.byteLength/4));function ey(r){return r instanceof Uint8Array||r!=null&&typeof r=="object"&&r.constructor.name==="Uint8Array"}const rE=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;if(!rE)throw new Error("Non little-endian hardware is not supported");function th(r){if(typeof r!="string")throw new Error(`utf8ToBytes expected string, got ${typeof r}`);return new Uint8Array(new TextEncoder().encode(r))}function Ou(r){if(typeof r=="string")r=th(r);else if(ey(r))r=r.slice();else throw new Error(`expected Uint8Array, got ${typeof r}`);return r}function nE(r,t){if(!ey(r))throw new Error("Uint8Array expected");if(r.length!==t)throw new Error(`Uint8Array length ${t} expected`)}function iE(r){return r!=null&&typeof r=="object"&&(r instanceof Uint8Array||r.constructor.name==="Uint8Array")}function oE(r,...t){if(!iE(r))throw new Error("Uint8Array expected");if(t.length>0&&!t.includes(r.length))throw new Error(`Uint8Array expected of length ${t}, not of length=${r.length}`)}function k0(r,t=!0){if(r.destroyed)throw new Error("Hash instance has been destroyed");if(t&&r.finished)throw new Error("Hash#digest() has already been called")}function sE(r,t){oE(r);const n=t.outputLen;if(r.length<n)throw new Error(`digestInto() expects output buffer of length at least ${n}`)}const Kt=(r,t)=>r[t++]&255|(r[t++]&255)<<8;class aE{constructor(t){this.blockLen=16,this.outputLen=16,this.buffer=new Uint8Array(16),this.r=new Uint16Array(10),this.h=new Uint16Array(10),this.pad=new Uint16Array(8),this.pos=0,this.finished=!1,t=Ou(t),nE(t,32);const n=Kt(t,0),i=Kt(t,2),o=Kt(t,4),s=Kt(t,6),a=Kt(t,8),c=Kt(t,10),f=Kt(t,12),h=Kt(t,14);this.r[0]=n&8191,this.r[1]=(n>>>13|i<<3)&8191,this.r[2]=(i>>>10|o<<6)&7939,this.r[3]=(o>>>7|s<<9)&8191,this.r[4]=(s>>>4|a<<12)&255,this.r[5]=a>>>1&8190,this.r[6]=(a>>>14|c<<2)&8191,this.r[7]=(c>>>11|f<<5)&8065,this.r[8]=(f>>>8|h<<8)&8191,this.r[9]=h>>>5&127;for(let d=0;d<8;d++)this.pad[d]=Kt(t,16+2*d)}process(t,n,i=!1){const o=i?0:2048,{h:s,r:a}=this,c=a[0],f=a[1],h=a[2],d=a[3],g=a[4],x=a[5],S=a[6],D=a[7],E=a[8],_=a[9],T=Kt(t,n+0),F=Kt(t,n+2),U=Kt(t,n+4),z=Kt(t,n+6),V=Kt(t,n+8),G=Kt(t,n+10),ee=Kt(t,n+12),Q=Kt(t,n+14);let X=s[0]+(T&8191),se=s[1]+((T>>>13|F<<3)&8191),oe=s[2]+((F>>>10|U<<6)&8191),H=s[3]+((U>>>7|z<<9)&8191),v=s[4]+((z>>>4|V<<12)&8191),u=s[5]+(V>>>1&8191),l=s[6]+((V>>>14|G<<2)&8191),p=s[7]+((G>>>11|ee<<5)&8191),w=s[8]+((ee>>>8|Q<<8)&8191),A=s[9]+(Q>>>5|o),C=0,k=C+X*c+se*(5*_)+oe*(5*E)+H*(5*D)+v*(5*S);C=k>>>13,k&=8191,k+=u*(5*x)+l*(5*g)+p*(5*d)+w*(5*h)+A*(5*f),C+=k>>>13,k&=8191;let I=C+X*f+se*c+oe*(5*_)+H*(5*E)+v*(5*D);C=I>>>13,I&=8191,I+=u*(5*S)+l*(5*x)+p*(5*g)+w*(5*d)+A*(5*h),C+=I>>>13,I&=8191;let y=C+X*h+se*f+oe*c+H*(5*_)+v*(5*E);C=y>>>13,y&=8191,y+=u*(5*D)+l*(5*S)+p*(5*x)+w*(5*g)+A*(5*d),C+=y>>>13,y&=8191;let N=C+X*d+se*h+oe*f+H*c+v*(5*_);C=N>>>13,N&=8191,N+=u*(5*E)+l*(5*D)+p*(5*S)+w*(5*x)+A*(5*g),C+=N>>>13,N&=8191;let re=C+X*g+se*d+oe*h+H*f+v*c;C=re>>>13,re&=8191,re+=u*(5*_)+l*(5*E)+p*(5*D)+w*(5*S)+A*(5*x),C+=re>>>13,re&=8191;let B=C+X*x+se*g+oe*d+H*h+v*f;C=B>>>13,B&=8191,B+=u*c+l*(5*_)+p*(5*E)+w*(5*D)+A*(5*S),C+=B>>>13,B&=8191;let j=C+X*S+se*x+oe*g+H*d+v*h;C=j>>>13,j&=8191,j+=u*f+l*c+p*(5*_)+w*(5*E)+A*(5*D),C+=j>>>13,j&=8191;let Z=C+X*D+se*S+oe*x+H*g+v*d;C=Z>>>13,Z&=8191,Z+=u*h+l*f+p*c+w*(5*_)+A*(5*E),C+=Z>>>13,Z&=8191;let Y=C+X*E+se*D+oe*S+H*x+v*g;C=Y>>>13,Y&=8191,Y+=u*d+l*h+p*f+w*c+A*(5*_),C+=Y>>>13,Y&=8191;let ne=C+X*_+se*E+oe*D+H*S+v*x;C=ne>>>13,ne&=8191,ne+=u*g+l*d+p*h+w*f+A*c,C+=ne>>>13,ne&=8191,C=(C<<2)+C|0,C=C+k|0,k=C&8191,C=C>>>13,I+=C,s[0]=k,s[1]=I,s[2]=y,s[3]=N,s[4]=re,s[5]=B,s[6]=j,s[7]=Z,s[8]=Y,s[9]=ne}finalize(){const{h:t,pad:n}=this,i=new Uint16Array(10);let o=t[1]>>>13;t[1]&=8191;for(let c=2;c<10;c++)t[c]+=o,o=t[c]>>>13,t[c]&=8191;t[0]+=o*5,o=t[0]>>>13,t[0]&=8191,t[1]+=o,o=t[1]>>>13,t[1]&=8191,t[2]+=o,i[0]=t[0]+5,o=i[0]>>>13,i[0]&=8191;for(let c=1;c<10;c++)i[c]=t[c]+o,o=i[c]>>>13,i[c]&=8191;i[9]-=8192;let s=(o^1)-1;for(let c=0;c<10;c++)i[c]&=s;s=~s;for(let c=0;c<10;c++)t[c]=t[c]&s|i[c];t[0]=(t[0]|t[1]<<13)&65535,t[1]=(t[1]>>>3|t[2]<<10)&65535,t[2]=(t[2]>>>6|t[3]<<7)&65535,t[3]=(t[3]>>>9|t[4]<<4)&65535,t[4]=(t[4]>>>12|t[5]<<1|t[6]<<14)&65535,t[5]=(t[6]>>>2|t[7]<<11)&65535,t[6]=(t[7]>>>5|t[8]<<8)&65535,t[7]=(t[8]>>>8|t[9]<<5)&65535;let a=t[0]+n[0];t[0]=a&65535;for(let c=1;c<8;c++)a=(t[c]+n[c]|0)+(a>>>16)|0,t[c]=a&65535}update(t){k0(this);const{buffer:n,blockLen:i}=this;t=Ou(t);const o=t.length;for(let s=0;s<o;){const a=Math.min(i-this.pos,o-s);if(a===i){for(;i<=o-s;s+=i)this.process(t,s);continue}n.set(t.subarray(s,s+a),this.pos),this.pos+=a,s+=a,this.pos===i&&(this.process(n,0,!1),this.pos=0)}return this}destroy(){this.h.fill(0),this.r.fill(0),this.buffer.fill(0),this.pad.fill(0)}digestInto(t){k0(this),sE(t,this),this.finished=!0;const{buffer:n,h:i}=this;let{pos:o}=this;if(o){for(n[o++]=1;o<16;o++)n[o]=0;this.process(n,0,!0)}this.finalize();let s=0;for(let a=0;a<8;a++)t[s++]=i[a]>>>0,t[s++]=i[a]>>>8;return t}digest(){const{buffer:t,outputLen:n}=this;this.digestInto(t);const i=t.slice(0,n);return this.destroy(),i}}function cE(r){const t=(i,o)=>r(o).update(Ou(i)).digest(),n=r(new Uint8Array(32));return t.outputLen=n.outputLen,t.blockLen=n.blockLen,t.create=i=>r(i),t}cE(r=>new aE(r));const fE=th("expand 16-byte k"),uE=th("expand 32-byte k");Qg(fE);Qg(uE);const Br={toString:yg,fromString:jl,concat:Bv};function ty(r){return Br.toString(r,"base64url")}function Ar(r){const t=r.replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"");return Br.fromString(t,"base64url")}function ry(r){return Br.fromString(r,"base58btc")}function lE(r){return Br.toString(r,"base58btc")}const hE={"ed25519-pub":237,"x25519-pub":236,"secp256k1-pub":231,"bls12_381-g1-pub":234,"bls12_381-g2-pub":235,"p256-pub":4608};function dE(r,t="base58btc",n){{const i=hE[n],o=Hx(i),s=new Uint8Array(o+r.length);return Lx(i,s),s.set(r,o),Br.toString(Rg.encode(t,s),"utf-8")}}function ny(r){const t=Rg.decode(r);if([32,33,48,64,65,96].includes(t.length))return t;try{const[n,i]=Fx(t);return t.slice(i)}catch{return t}}function Qo(r,t){let n=r.startsWith("0x")?r.substring(2):r;return n.length%2!==0&&(n=`0${n}`),Br.fromString(n.toLowerCase(),"base16")}function T0(r){return ty(Br.fromString(r))}function iy(r){return Br.toString(Ar(r))}function fi(r){return Br.toString(r,"base16")}function ia(r){return BigInt("0x"+Br.toString(r,"base16"))}function pE(r){return Br.fromString(r,"utf-8")}function rh({r,s:t,recoveryParam:n},i){const o=new Uint8Array(i?65:64);if(o.set(Br.fromString(r,"base16"),0),o.set(Br.fromString(t,"base16"),32),i){if(typeof n>"u")throw new Error("Signer did not return a recoveryParam");o[64]=n}return ty(o)}function gE(r){const t=Ar(r);if(t.length<64||t.length>65)throw new TypeError(`Wrong size for signature. Expected 64 or 65 bytes, but got ${t.length}`);const n=fi(t.slice(0,32)),i=fi(t.slice(32,64)),o=t.length===65?t[64]:void 0;return{r:n,s:i,recoveryParam:o}}function N0(r,t=64){return r.length===t?r:"0".repeat(t-r.length)+r}function ui(r){const t=typeof r=="string"?jl(r):r;return Zl(t)}const yE=vA;function oy(r){const t=jl(r.slice(2),"base16");return`0x${yg(yE(t).slice(-20),"base16")}`}function wE(r,t=!1){const n=r;if(n.length!==32)throw new Error(`bad_key: Invalid private key format. Expecting 32 bytes, but got ${n.length}`);return function(i){try{const o=zi.sign(ui(i),n);return Promise.resolve(rh({r:N0(o.r.toString(16)),s:N0(o.s.toString(16)),recoveryParam:o.recovery},t))}catch(o){return Promise.reject(o)}}}function nh(r){return typeof r=="object"&&"r"in r&&"s"in r}function mE(){return function(t,n){try{return Promise.resolve(n(t)).then(function(i){return nh(i)?rh(i):i})}catch(i){return Promise.reject(i)}}}function R0(r){return function(n,i){try{return Promise.resolve(i(n)).then(function(o){if(nh(o))return rh(o,r);if(r&&typeof gE(o).recoveryParam>"u")throw new Error("not_supported: ES256K-R not supported when signer doesn't provide a recovery param");return o})}catch(o){return Promise.reject(o)}}}function U0(){return function(t,n){try{return Promise.resolve(n(t)).then(function(i){if(nh(i))throw new Error("invalid_config: expected a signer function that returns a string instead of signature object");return i})}catch(i){return Promise.reject(i)}}}const bE={ES256:mE(),ES256K:R0(),"ES256K-R":R0(!0),Ed25519:U0(),EdDSA:U0()};function vE(r){const t=bE[r];if(!t)throw new Error(`not_supported: Unsupported algorithm ${r}`);return t}function xE(r,t){const n=fi(ry(t).slice(0,1)),i=Qo(r),o=Pg(ui(i)),s=n+fi(o),a=ui(Qo(s)),c=ui(a),f=fi(c).substring(0,8),h=s+f;return lE(Qo(h))}function AE(r,t){const n=zi.ProjectivePoint.fromHex(r).toRawBytes(),i=Pg(ui(n)),o=M0.toWords(i);return M0.encode(t,o).replace(t,"")}function EE(r,t){if(t){const n=t.split(":");switch(n[0]){case"bip122":n[n.length-1]=xE(r,n[n.length-1]);break;case"cosmos":n[n.length-1]=AE(r,n[1]);break;case"eip155":n[n.length-1]=oy(r);break;default:return!1}return n.join(":").toLowerCase()===t.toLowerCase()}return!1}function SE(r,t=!1){const n=Ar(r);if(n.length!==(t?65:64))throw new Error("wrong signature length");const i=fi(n.slice(0,32)),o=fi(n.slice(32,64)),s={r:i,s:o};return t&&(s.recoveryParam=n[64]),s}function Pu(r,t=!1){const n=Ar(r);if(n.length!==(t?65:64))throw new Error("wrong signature length");return{compact:n.slice(0,64),recovery:n[64]}}function hc(r){return r.publicKeyBase58?ry(r.publicKeyBase58):r.publicKeyBase64?Ar(r.publicKeyBase64):r.publicKeyHex?Qo(r.publicKeyHex):r.publicKeyJwk&&r.publicKeyJwk.crv==="secp256k1"&&r.publicKeyJwk.x&&r.publicKeyJwk.y?zi.ProjectivePoint.fromAffine({x:ia(Ar(r.publicKeyJwk.x)),y:ia(Ar(r.publicKeyJwk.y))}).toRawBytes(!1):r.publicKeyJwk&&r.publicKeyJwk.crv==="P-256"&&r.publicKeyJwk.x&&r.publicKeyJwk.y?Tu.ProjectivePoint.fromAffine({x:ia(Ar(r.publicKeyJwk.x)),y:ia(Ar(r.publicKeyJwk.y))}).toRawBytes(!1):r.publicKeyJwk&&r.publicKeyJwk.kty==="OKP"&&["Ed25519","X25519"].includes(r.publicKeyJwk.crv??"")&&r.publicKeyJwk.x?Ar(r.publicKeyJwk.x):r.publicKeyMultibase?ny(r.publicKeyMultibase):new Uint8Array}function BE(r,t,n){const i=ui(r),o=Tu.Signature.fromCompact(Pu(t).compact),a=n.filter(c=>!c.ethereumAddress&&!c.blockchainAccountId).find(c=>{try{const f=hc(c);return Tu.verify(o,i,f)}catch{return!1}});if(!a)throw new Error("invalid_signature: Signature invalid for JWT");return a}function DE(r,t,n){const i=ui(r),o=zi.Signature.fromCompact(Ar(t)).normalizeS(),s=n.filter(f=>!f.ethereumAddress&&!f.blockchainAccountId),a=n.filter(f=>f.ethereumAddress||f.blockchainAccountId);let c=s.find(f=>{try{const h=hc(f);return zi.verify(o,i,h)}catch{return!1}});if(!c&&a.length>0&&(c=sy(r,t,a)),!c)throw new Error("invalid_signature: Signature invalid for JWT");return c}function sy(r,t,n){const i=[];if(t.length>86)i.push(Pu(t,!0));else{const a=Pu(t,!1);i.push({...a,recovery:0}),i.push({...a,recovery:1})}const o=ui(r),s=a=>{const f=zi.Signature.fromCompact(a.compact).addRecoveryBit(a.recovery||0).recoverPublicKey(o),h=oy(f.toHex(!1)).toLowerCase(),d=f.toHex(!1),g=f.toHex(!0);return n.find(x=>{var D,E,_;const S=fi(hc(x));return S===d||S===g||((D=x.ethereumAddress)==null?void 0:D.toLowerCase())===h||((_=(E=x.blockchainAccountId)==null?void 0:E.split("@eip155"))==null?void 0:_[0].toLowerCase())===h||EE(d,x.blockchainAccountId)})};for(const a of i){const c=s(a);if(c)return c}throw new Error("invalid_signature: Signature invalid for JWT")}function O0(r,t,n){const i=pE(r),o=Ar(t),s=n.find(a=>Y2.verify(o,i,hc(a)));if(!s)throw new Error("invalid_signature: Signature invalid for JWT");return s}const CE={ES256:BE,ES256K:DE,"ES256K-R":sy,Ed25519:O0,EdDSA:O0};function ay(r){const t=CE[r];if(!t)throw new Error(`not_supported: Unsupported algorithm ${r}`);return t}ay.toSignatureObject=SE;const Ye={INVALID_JWT:"invalid_jwt",INVALID_AUDIENCE:"invalid_config",INVALID_SIGNATURE:"invalid_signature",NO_SUITABLE_KEYS:"no_suitable_keys",NOT_SUPPORTED:"not_supported",RESOLVER_ERROR:"resolver_error"};function cy(r,t){try{var n=r()}catch(i){return t(i)}return n&&n.then?n.then(void 0,t):n}const IE=function(r,{header:t,payload:n,data:i,signature:o},s,a){try{if(!s.conditionDelegated)throw new Error("Expected conditionDelegated");if(!a.resolver)throw new Error("Expected resolver");let c;const f=s.conditionDelegated;return Promise.resolve(uy(a.resolver,t.alg,f,a.proofPurpose)).then(function(h){let d;function g(E){if(c)return s;throw new Error(`${Ye.INVALID_SIGNATURE}: condition for authenticator ${s.id} is not met.`)}const x=h.didResolutionResult;if(!(x!=null&&x.didDocument))throw new Error(`${Ye.RESOLVER_ERROR}: Could not resolve delegated DID ${f}.`);const S=h.authenticators.find(E=>E.id===f);if(!S)throw new Error(`${Ye.NO_SUITABLE_KEYS}: Could not find delegated authenticator ${f} in it's DID Document`);const D=function(){return S.type===ih?Promise.resolve(sh(r,{...a,didAuthenticator:{didResolutionResult:x,authenticators:[S],issuer:S.id}})).then(function({verified:E}){E&&(c=S)}):cy(function(){return Promise.resolve(ah({header:t,payload:n,data:i,signature:o},S)).then(function(E){c=E})},function(E){if(!E.message.startsWith("invalid_signature:"))throw E})}();return D&&D.then?D.then(g):g(D)})}catch(c){return Promise.reject(c)}},P0=typeof Symbol<"u"?Symbol.iterator||(Symbol.iterator=Symbol("Symbol.iterator")):"@@iterator";function ir(r,t,n){if(!r.s){if(n instanceof Eo)if(n.s)t&1&&(t=n.s),n=n.v;else{n.o=ir.bind(null,r,t);return}if(n&&n.then){n.then(ir.bind(null,r,t),ir.bind(null,r,2));return}r.s=t,r.v=n;const i=r.o;i&&i(r)}}const Eo=function(){function r(){}return r.prototype.then=function(t,n){const i=new r,o=this.s;if(o){const s=o&1?t:n;if(s){try{ir(i,1,s(this.v))}catch(a){ir(i,2,a)}return i}else return this}return this.o=function(s){try{const a=s.v;s.s&1?ir(i,1,t?t(a):a):n?ir(i,1,n(a)):ir(i,2,a)}catch(a){ir(i,2,a)}},i},r}();function fy(r){return r instanceof Eo&&r.s&1}function _E(r,t,n){var i=-1,o,s;function a(c){try{for(;++i<r.length&&(!n||!n());)if(c=t(i),c&&c.then)if(fy(c))c=c.v;else{c.then(a,s||(s=ir.bind(null,o=new Eo,2)));return}o?ir(o,1,c):o=c}catch(f){ir(o||(o=new Eo),2,f)}}return a(),o}const ME=function(r,{header:t,payload:n,data:i,signature:o},s,a){try{let c=function(S){if(f)return S;throw new Error(`${Ye.INVALID_SIGNATURE}: condition for authenticator ${s.id} is not met.`)},f;if(!s.conditionWeightedThreshold||!s.threshold)throw new Error("Expected conditionWeightedThreshold and threshold");const h=[],d=s.threshold;let g=0;const x=kE(s.conditionWeightedThreshold,function(S){function D(F){if(f)return F;if(_&&!h.includes(_.id)&&(h.push(_.id),g+=S.weight,g>=d))return f=1,s}const E=S.condition;let _;const T=cy(function(){var F;if(E.type===ih){if(!a.didAuthenticator)throw new Error("Expected didAuthenticator");const U={...a,didAuthenticator:{didResolutionResult:(F=a.didAuthenticator)==null?void 0:F.didResolutionResult,authenticators:[E],issuer:E.id}};return Promise.resolve(sh(r,U)).then(function({verified:z}){z&&(_=E)})}else return Promise.resolve(ah({header:t,payload:n,data:i,signature:o},E)).then(function(U){_=U})},function(F){if(!F.message.startsWith(Ye.INVALID_SIGNATURE))throw F});return T&&T.then?T.then(D):D(T)},function(){return f});return Promise.resolve(x&&x.then?x.then(c):c(x))}catch(c){return Promise.reject(c)}};function kE(r,t,n){if(typeof r[P0]=="function"){let d=function(g){try{for(;!(o=i.next()).done&&(!n||!n());)if(g=t(o.value),g&&g.then)if(fy(g))g=g.v;else{g.then(d,a||(a=ir.bind(null,s=new Eo,2)));return}s?ir(s,1,g):s=g}catch(x){ir(s||(s=new Eo),2,x)}};var i=r[P0](),o,s,a;if(d(),i.return){var c=function(g){try{o.done||i.return()}catch{}return g};if(s&&s.then)return s.then(c,function(g){throw c(g)});c()}return s}if(!("length"in r))throw new TypeError("Object is not iterable");for(var f=[],h=0;h<r.length;h++)f.push(r[h]);return _E(f,function(d){return t(f[d])},n)}const TE=function(r,{header:t,payload:n,signature:i,data:o},s,a){try{if(s.conditionWeightedThreshold)return ME(r,{header:t,payload:n,data:o,signature:i},s,a);if(s.conditionDelegated)return IE(r,{header:t,payload:n,data:o,signature:i},s,a);throw new Error(`${Ye.INVALID_JWT}: conditional proof type did not find condition for authenticator ${s.id}.`)}catch(c){return Promise.reject(c)}},F0=function(r,{header:t,payload:n,signature:i,data:o},s,a){try{return s.type===ih?TE(r,{payload:n,header:t,signature:i,data:o},s,a):Promise.resolve(ah({header:t,payload:n,data:o,signature:i},[s]))}catch(c){return Promise.reject(c)}},ih="ConditionalProof2022";function Er(r,t,n){if(!r.s){if(n instanceof oh)if(n.s)t&1&&(t=n.s),n=n.v;else{n.o=Er.bind(null,r,t);return}if(n&&n.then){n.then(Er.bind(null,r,t),Er.bind(null,r,2));return}r.s=t,r.v=n;const i=r.o;i&&i(r)}}const oh=function(){function r(){}return r.prototype.then=function(t,n){const i=new r,o=this.s;if(o){const s=o&1?t:n;if(s){try{Er(i,1,s(this.v))}catch(a){Er(i,2,a)}return i}else return this}return this.o=function(s){try{const a=s.v;s.s&1?Er(i,1,t?t(a):a):n?Er(i,1,n(a)):Er(i,2,a)}catch(a){Er(i,2,a)}},i},r}();function oa(r){return r instanceof oh&&r.s&1}function NE(r,t){try{var n=r()}catch(i){return t(i)}return n&&n.then?n.then(void 0,t):n}function RE(r,t,n){for(var i;;){var o=r();if(oa(o)&&(o=o.v),!o)return s;if(o.then){i=0;break}var s=n();if(s&&s.then)if(oa(s))s=s.s;else{i=1;break}var a}var c=new oh,f=Er.bind(null,c,2);return(i===0?o.then(d):i===1?s.then(h):a.then(g)).then(void 0,f),c;function h(x){s=x;do{if(o=r(),!o||oa(o)&&!o.v){Er(c,1,s);return}if(o.then){o.then(d).then(void 0,f);return}s=n(),oa(s)&&(s=s.v)}while(!s||!s.then);s.then(h).then(void 0,f)}function d(x){x?(s=n(),s&&s.then?s.then(h).then(void 0,f):h(s)):Er(c,1,s)}function g(){(o=r())?o.then?o.then(d).then(void 0,f):d(o):Er(c,1,s)}}const uy=function(r,t,n,i){try{const o=PE[t];if(!o||o.length===0)throw new Error(`${Ye.NOT_SUPPORTED}: No supported signature types for algorithm ${t}`);let s;return Promise.resolve(r.resolve(n,{accept:L0})).then(function(a){var d,g,x;if(Object.getOwnPropertyNames(a).indexOf("didDocument")===-1?s={didDocument:a,didDocumentMetadata:{},didResolutionMetadata:{contentType:L0}}:s=a,(d=s.didResolutionMetadata)!=null&&d.error||s.didDocument==null){const{error:S,message:D}=s.didResolutionMetadata;throw new Error(`${Ye.RESOLVER_ERROR}: Unable to resolve DID document for ${n}: ${S}, ${D||""}`)}const c=(S,D)=>{const E=S.filter(({id:_})=>D===_);return E.length>0?E[0]:null};let f=[...((g=s==null?void 0:s.didDocument)==null?void 0:g.verificationMethod)||[],...((x=s==null?void 0:s.didDocument)==null?void 0:x.publicKey)||[]];typeof i=="string"&&(i.startsWith("assertion")&&!Object.getOwnPropertyNames(s==null?void 0:s.didDocument).includes("assertionMethod")&&(s.didDocument={...s.didDocument},s.didDocument.assertionMethod=[...f.map(S=>S.id)]),f=(s.didDocument[i]||[]).map(S=>typeof S=="string"?c(f,S):typeof S.publicKey=="string"?c(f,S.publicKey):S).filter(S=>S!=null));const h=f.filter(({type:S})=>o.find(D=>D===S));if(typeof i=="string"&&(!h||h.length===0))throw new Error(`${Ye.NO_SUITABLE_KEYS}: DID document for ${n} does not have public keys suitable for ${t} with ${i} purpose`);if(!h||h.length===0)throw new Error(`${Ye.NO_SUITABLE_KEYS}: DID document for ${n} does not have public keys for ${t}`);return{authenticators:h,issuer:n,didResolutionResult:s}})}catch(o){return Promise.reject(o)}},sh=function(r,t={resolver:void 0,auth:void 0,audience:void 0,callbackUrl:void 0,skewTime:void 0,proofPurpose:void 0,policies:{},didAuthenticator:void 0}){try{let n=function(){let S;function D(F){var U,z,V,G,ee;if(_){const Q=typeof((U=t.policies)==null?void 0:U.now)=="number"?t.policies.now:Math.floor(Date.now()/1e3),X=typeof t.skewTime<"u"&&t.skewTime>=0?t.skewTime:VE,se=Q+X;if(((z=t.policies)==null?void 0:z.nbf)!==!1&&i.nbf){if(i.nbf>se)throw new Error(`${Ye.INVALID_JWT}: JWT not valid before nbf: ${i.nbf}`)}else if(((V=t.policies)==null?void 0:V.iat)!==!1&&i.iat&&i.iat>se)throw new Error(`${Ye.INVALID_JWT}: JWT not valid yet (issued in the future) iat: ${i.iat}`);if(((G=t.policies)==null?void 0:G.exp)!==!1&&i.exp&&i.exp<=Q-X)throw new Error(`${Ye.INVALID_JWT}: JWT has expired: exp: ${i.exp} < now: ${Q}`);if(((ee=t.policies)==null?void 0:ee.aud)!==!1&&i.aud){if(!t.audience&&!t.callbackUrl)throw new Error(`${Ye.INVALID_AUDIENCE}: JWT audience is required but your app address has not been configured`);if(typeof(Array.isArray(i.aud)?i.aud:[i.aud]).find(v=>t.audience===v||t.callbackUrl===v)>"u")throw new Error(`${Ye.INVALID_AUDIENCE}: JWT audience does not match your DID or callback url`)}return{verified:!0,payload:i,didResolutionResult:g,issuer:d,signer:_,jwt:r,policies:t.policies}}throw new Error(`${Ye.INVALID_SIGNATURE}: JWT not valid. issuer DID document does not contain a verificationMethod that matches the signature.`)}const{did:E}=qg(f);let _=null;const T=function(){if(E!==f){const F=h.find(U=>U.id===f);if(!F)throw new Error(`${Ye.INVALID_JWT}: No authenticator found for did URL ${f}`);return Promise.resolve(F0(r,{payload:i,header:o,signature:s,data:a},F,t)).then(function(U){_=U})}else{let F=0;return RE(function(){return!S&&!_&&F<h.length},void 0,function(){function U(G){F++}const z=h[F],V=NE(function(){return Promise.resolve(F0(r,{payload:i,header:o,signature:s,data:a},z,t)).then(function(G){_=G})},function(G){if(!G.message.includes(Ye.INVALID_SIGNATURE)||F===h.length-1)throw G});return V&&V.then?V.then(U):U(V)})}}();return T&&T.then?T.then(D):D(T)};if(!t.resolver)throw new Error("missing_resolver: No DID resolver has been configured");const{payload:i,header:o,signature:s,data:a}=dc(r,!1),c=Object.prototype.hasOwnProperty.call(t,"auth")?t.auth?"authentication":void 0:t.proofPurpose;let f;if(!i.iss&&!i.client_id)throw new Error(`${Ye.INVALID_JWT}: JWT iss or client_id are required`);if(t.didAuthenticator)f=t.didAuthenticator.issuer;else if(i.iss===FE||i.iss===LE){if(!i.sub)throw new Error(`${Ye.INVALID_JWT}: JWT sub is required`);typeof i.sub_jwk>"u"?f=i.sub:f=(o.kid||"").split("#")[0]}else if(i.iss===HE){if(!i.did)throw new Error(`${Ye.INVALID_JWT}: JWT did is required`);f=i.did}else if(!i.iss&&i.scope==="openid"&&i.redirect_uri){if(!i.client_id)throw new Error(`${Ye.INVALID_JWT}: JWT client_id is required`);f=i.client_id}else f=i.iss;if(!f)throw new Error(`${Ye.INVALID_JWT}: No DID has been found in the JWT`);let h,d,g;const x=function(){if(t.didAuthenticator)({didResolutionResult:g,authenticators:h,issuer:d}=t.didAuthenticator);else return Promise.resolve(uy(t.resolver,o.alg,f,c)).then(function(S){({didResolutionResult:g,authenticators:h,issuer:d}=S),t.didAuthenticator={didResolutionResult:g,authenticators:h,issuer:d}})}();return Promise.resolve(x&&x.then?x.then(n):n(x))}catch(n){return Promise.reject(n)}},UE=function(r,{issuer:t,signer:n,alg:i,expiresIn:o,canonicalize:s},a={}){try{if(!n)throw new Error("missing_signer: No Signer functionality has been configured");if(!t)throw new Error("missing_issuer: No issuing DID has been configured");a.typ||(a.typ="JWT"),a.alg||(a.alg=i);const c={iat:Math.floor(Date.now()/1e3),exp:void 0};if(o)if(typeof o=="number")c.exp=(r.nbf||c.iat)+Math.floor(o);else throw new Error("invalid_argument: JWT expiresIn is not a number");const f={...c,...r,iss:t};return OE(f,n,a,{canonicalize:s})}catch(c){return Promise.reject(c)}},OE=function(r,t,n={},i={}){try{n.alg||(n.alg=$E);const o=typeof r=="string"?r:H0(r,i.canonicalize),s=[H0(n,i.canonicalize),o].join("."),a=vE(n.alg);return Promise.resolve(a(s,t)).then(function(c){return[s,c].join(".")})}catch(o){return Promise.reject(o)}},PE={ES256:["JsonWebKey2020"],ES256K:["EcdsaSecp256k1VerificationKey2019","EcdsaSecp256k1RecoveryMethod2020","Secp256k1VerificationKey2018","Secp256k1SignatureVerificationKey2018","EcdsaPublicKeySecp256k1","JsonWebKey2020"],"ES256K-R":["EcdsaSecp256k1VerificationKey2019","EcdsaSecp256k1RecoveryMethod2020","Secp256k1VerificationKey2018","Secp256k1SignatureVerificationKey2018","EcdsaPublicKeySecp256k1","ConditionalProof2022","JsonWebKey2020"],Ed25519:["ED25519SignatureVerification","Ed25519VerificationKey2018","Ed25519VerificationKey2020","JsonWebKey2020"],EdDSA:["ED25519SignatureVerification","Ed25519VerificationKey2018","Ed25519VerificationKey2020","JsonWebKey2020"]},FE="https://self-issued.me/v2",LE="https://self-issued.me/v2/openid-vc",HE="https://self-issued.me",$E="ES256K",L0="application/did+json";function H0(r,t=!1){return T0(t?UA(r):JSON.stringify(r))}const VE=300;function jE(r){const t=r.match(/^([a-zA-Z0-9_-]+)\.([a-zA-Z0-9_-]+)\.([a-zA-Z0-9_-]+)$/);if(t)return{header:JSON.parse(iy(t[1])),payload:t[2],signature:t[3],data:`${t[1]}.${t[2]}`};throw new Error("invalid_argument: Incorrect format JWS")}function dc(r,t=!0){if(!r)throw new Error("invalid_argument: no JWT passed into decodeJWT");try{const n=jE(r),i=Object.assign(n,{payload:JSON.parse(iy(n.payload))}),o=i.payload.iss;if(i.header.cty==="JWT"&&t){const s=dc(i.payload.jwt);if(s.payload.iss!==o)throw new Error(`${Ye.INVALID_JWT}: multiple issuers`);return s}return i}catch{throw new Error("invalid_argument: Incorrect format JWT")}}function ah({header:r,payload:t,data:n,signature:i},o){Array.isArray(o)||(o=[o]);const s=t.iss;let a=!0;do{if(s!==t.iss)throw new Error(`${Ye.INVALID_JWT}: multiple issuers`);try{return ay(r.alg)(n,i,o)}catch(c){if(!c.message.startsWith(Ye.INVALID_SIGNATURE))throw c}r.cty!=="JWT"?a=!1:{payload:t,header:r,signature:i,data:n}=dc(t.jwt,!1)}while(a);throw new Error(`${Ye.INVALID_SIGNATURE}: no matching public key found`)}typeof Symbol<"u"&&(Symbol.iterator||(Symbol.iterator=Symbol("Symbol.iterator")));/*!
* MIT License
*
* Copyright (c) 2017-2024 Peculiar Ventures, LLC
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*
*/const KE="[object ArrayBuffer]";class Me{static isArrayBuffer(t){return Object.prototype.toString.call(t)===KE}static toArrayBuffer(t){return this.isArrayBuffer(t)?t:t.byteLength===t.buffer.byteLength||t.byteOffset===0&&t.byteLength===t.buffer.byteLength?t.buffer:this.toUint8Array(t.buffer).slice(t.byteOffset,t.byteOffset+t.byteLength).buffer}static toUint8Array(t){return this.toView(t,Uint8Array)}static toView(t,n){if(t.constructor===n)return t;if(this.isArrayBuffer(t))return new n(t);if(this.isArrayBufferView(t))return new n(t.buffer,t.byteOffset,t.byteLength);throw new TypeError("The provided value is not of type '(ArrayBuffer or ArrayBufferView)'")}static isBufferSource(t){return this.isArrayBufferView(t)||this.isArrayBuffer(t)}static isArrayBufferView(t){return ArrayBuffer.isView(t)||t&&this.isArrayBuffer(t.buffer)}static isEqual(t,n){const i=Me.toUint8Array(t),o=Me.toUint8Array(n);if(i.length!==o.byteLength)return!1;for(let s=0;s<i.length;s++)if(i[s]!==o[s])return!1;return!0}static concat(...t){let n;Array.isArray(t[0])&&!(t[1]instanceof Function)||Array.isArray(t[0])&&t[1]instanceof Function?n=t[0]:t[t.length-1]instanceof Function?n=t.slice(0,t.length-1):n=t;let i=0;for(const a of n)i+=a.byteLength;const o=new Uint8Array(i);let s=0;for(const a of n){const c=this.toUint8Array(a);o.set(c,s),s+=c.length}return t[t.length-1]instanceof Function?this.toView(o,t[t.length-1]):o.buffer}}const Jf="string",zE=/^[0-9a-f\s]+$/i,qE=/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/,GE=/^[a-zA-Z0-9-_]+$/;class $0{static fromString(t){const n=unescape(encodeURIComponent(t)),i=new Uint8Array(n.length);for(let o=0;o<n.length;o++)i[o]=n.charCodeAt(o);return i.buffer}static toString(t){const n=Me.toUint8Array(t);let i="";for(let s=0;s<n.length;s++)i+=String.fromCharCode(n[s]);return decodeURIComponent(escape(i))}}class fn{static toString(t,n=!1){const i=Me.toArrayBuffer(t),o=new DataView(i);let s="";for(let a=0;a<i.byteLength;a+=2){const c=o.getUint16(a,n);s+=String.fromCharCode(c)}return s}static fromString(t,n=!1){const i=new ArrayBuffer(t.length*2),o=new DataView(i);for(let s=0;s<t.length;s++)o.setUint16(s*2,t.charCodeAt(s),n);return i}}class At{static isHex(t){return typeof t===Jf&&zE.test(t)}static isBase64(t){return typeof t===Jf&&qE.test(t)}static isBase64Url(t){return typeof t===Jf&&GE.test(t)}static ToString(t,n="utf8"){const i=Me.toUint8Array(t);switch(n.toLowerCase()){case"utf8":return this.ToUtf8String(i);case"binary":return this.ToBinary(i);case"hex":return this.ToHex(i);case"base64":return this.ToBase64(i);case"base64url":return this.ToBase64Url(i);case"utf16le":return fn.toString(i,!0);case"utf16":case"utf16be":return fn.toString(i);default:throw new Error(`Unknown type of encoding '${n}'`)}}static FromString(t,n="utf8"){if(!t)return new ArrayBuffer(0);switch(n.toLowerCase()){case"utf8":return this.FromUtf8String(t);case"binary":return this.FromBinary(t);case"hex":return this.FromHex(t);case"base64":return this.FromBase64(t);case"base64url":return this.FromBase64Url(t);case"utf16le":return fn.fromString(t,!0);case"utf16":case"utf16be":return fn.fromString(t);default:throw new Error(`Unknown type of encoding '${n}'`)}}static ToBase64(t){const n=Me.toUint8Array(t);if(typeof btoa<"u"){const i=this.ToString(n,"binary");return btoa(i)}else return Buffer.from(n).toString("base64")}static FromBase64(t){const n=this.formatString(t);if(!n)return new ArrayBuffer(0);if(!At.isBase64(n))throw new TypeError("Argument 'base64Text' is not Base64 encoded");return typeof atob<"u"?this.FromBinary(atob(n)):new Uint8Array(Buffer.from(n,"base64")).buffer}static FromBase64Url(t){const n=this.formatString(t);if(!n)return new ArrayBuffer(0);if(!At.isBase64Url(n))throw new TypeError("Argument 'base64url' is not Base64Url encoded");return this.FromBase64(this.Base64Padding(n.replace(/\-/g,"+").replace(/\_/g,"/")))}static ToBase64Url(t){return this.ToBase64(t).replace(/\+/g,"-").replace(/\//g,"_").replace(/\=/g,"")}static FromUtf8String(t,n=At.DEFAULT_UTF8_ENCODING){switch(n){case"ascii":return this.FromBinary(t);case"utf8":return $0.fromString(t);case"utf16":case"utf16be":return fn.fromString(t);case"utf16le":case"usc2":return fn.fromString(t,!0);default:throw new Error(`Unknown type of encoding '${n}'`)}}static ToUtf8String(t,n=At.DEFAULT_UTF8_ENCODING){switch(n){case"ascii":return this.ToBinary(t);case"utf8":return $0.toString(t);case"utf16":case"utf16be":return fn.toString(t);case"utf16le":case"usc2":return fn.toString(t,!0);default:throw new Error(`Unknown type of encoding '${n}'`)}}static FromBinary(t){const n=t.length,i=new Uint8Array(n);for(let o=0;o<n;o++)i[o]=t.charCodeAt(o);return i.buffer}static ToBinary(t){const n=Me.toUint8Array(t);let i="";for(let o=0;o<n.length;o++)i+=String.fromCharCode(n[o]);return i}static ToHex(t){const n=Me.toUint8Array(t);let i="";const o=n.length;for(let s=0;s<o;s++){const a=n[s];a<16&&(i+="0"),i+=a.toString(16)}return i}static FromHex(t){let n=this.formatString(t);if(!n)return new ArrayBuffer(0);if(!At.isHex(n))throw new TypeError("Argument 'hexString' is not HEX encoded");n.length%2&&(n=`0${n}`);const i=new Uint8Array(n.length/2);for(let o=0;o<n.length;o=o+2){const s=n.slice(o,o+2);i[o/2]=parseInt(s,16)}return i.buffer}static ToUtf16String(t,n=!1){return fn.toString(t,n)}static FromUtf16String(t,n=!1){return fn.fromString(t,n)}static Base64Padding(t){const n=4-t.length%4;if(n<4)for(let i=0;i<n;i++)t+="=";return t}static formatString(t){return(t==null?void 0:t.replace(/[\n\r\t ]/g,""))||""}}At.DEFAULT_UTF8_ENCODING="utf8";function WE(r,t){if(!(r&&t)||r.byteLength!==t.byteLength)return!1;const n=new Uint8Array(r),i=new Uint8Array(t);for(let o=0;o<r.byteLength;o++)if(n[o]!==i[o])return!1;return!0}/*!
Copyright (c) Peculiar Ventures, LLC
*/function So(r,t){let n=0;if(r.length===1)return r[0];for(let i=r.length-1;i>=0;i--)n+=r[r.length-1-i]*Math.pow(2,t*i);return n}function qi(r,t,n=-1){const i=n;let o=r,s=0,a=Math.pow(2,t);for(let c=1;c<8;c++){if(r<a){let f;if(i<0)f=new ArrayBuffer(c),s=c;else{if(i<c)return new ArrayBuffer(0);f=new ArrayBuffer(i),s=i}const h=new Uint8Array(f);for(let d=c-1;d>=0;d--){const g=Math.pow(2,d*t);h[s-d-1]=Math.floor(o/g),o-=h[s-d-1]*g}return f}a*=Math.pow(2,t)}return new ArrayBuffer(0)}function Fu(...r){let t=0,n=0;for(const s of r)t+=s.length;const i=new ArrayBuffer(t),o=new Uint8Array(i);for(const s of r)o.set(s,n),n+=s.length;return o}function ly(){const r=new Uint8Array(this.valueHex);if(this.valueHex.byteLength>=2){const c=r[0]===255&&r[1]&128,f=r[0]===0&&(r[1]&128)===0;(c||f)&&this.warnings.push("Needlessly long format")}const t=new ArrayBuffer(this.valueHex.byteLength),n=new Uint8Array(t);for(let c=0;c<this.valueHex.byteLength;c++)n[c]=0;n[0]=r[0]&128;const i=So(n,8),o=new ArrayBuffer(this.valueHex.byteLength),s=new Uint8Array(o);for(let c=0;c<this.valueHex.byteLength;c++)s[c]=r[c];return s[0]&=127,So(s,8)-i}function JE(r){const t=r<0?r*-1:r;let n=128;for(let i=1;i<8;i++){if(t<=n){if(r<0){const a=n-t,c=qi(a,8,i),f=new Uint8Array(c);return f[0]|=128,c}let o=qi(t,8,i),s=new Uint8Array(o);if(s[0]&128){const a=o.slice(0),c=new Uint8Array(a);o=new ArrayBuffer(o.byteLength+1),s=new Uint8Array(o);for(let f=0;f<a.byteLength;f++)s[f+1]=c[f];s[0]=0}return o}n*=Math.pow(2,8)}return new ArrayBuffer(0)}function YE(r,t){if(r.byteLength!==t.byteLength)return!1;const n=new Uint8Array(r),i=new Uint8Array(t);for(let o=0;o<n.length;o++)if(n[o]!==i[o])return!1;return!0}function xr(r,t){const n=r.toString(10);if(t<n.length)return"";const i=t-n.length,o=new Array(i);for(let a=0;a<i;a++)o[a]="0";return o.join("").concat(n)}/*!
* Copyright (c) 2014, GMO GlobalSign
* Copyright (c) 2015-2022, Peculiar Ventures
* All rights reserved.
*
* Author 2014-2019, Yury Strozhevsky
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright notice, this
* list of conditions and the following disclaimer in the documentation and/or
* other materials provided with the distribution.
*
* * Neither the name of the copyright holder nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/function Fa(){if(typeof BigInt>"u")throw new Error("BigInt is not defined. Your environment doesn't implement BigInt.")}function ch(r){let t=0,n=0;for(let o=0;o<r.length;o++){const s=r[o];t+=s.byteLength}const i=new Uint8Array(t);for(let o=0;o<r.length;o++){const s=r[o];i.set(new Uint8Array(s),n),n+=s.byteLength}return i.buffer}function Pn(r,t,n,i){return t instanceof Uint8Array?t.byteLength?n<0?(r.error="Wrong parameter: inputOffset less than zero",!1):i<0?(r.error="Wrong parameter: inputLength less than zero",!1):t.byteLength-n-i<0?(r.error="End of input reached before message was fully decoded (inconsistent offset and length values)",!1):!0:(r.error="Wrong parameter: inputBuffer has zero length",!1):(r.error="Wrong parameter: inputBuffer must be 'Uint8Array'",!1)}class pc{constructor(){this.items=[]}write(t){this.items.push(t)}final(){return ch(this.items)}}const zo=[new Uint8Array([1])],V0="0123456789",Yf="name",j0="valueHexView",ZE="isHexOnly",XE="idBlock",QE="tagClass",eS="tagNumber",tS="isConstructed",rS="fromBER",nS="toBER",iS="local",lr="",rn=new ArrayBuffer(0),gc=new Uint8Array(0),ps="EndOfContent",hy="OCTET STRING",dy="BIT STRING";function wn(r){var t;return t=class extends r{constructor(...i){var o;super(...i);const s=i[0]||{};this.isHexOnly=(o=s.isHexOnly)!==null&&o!==void 0?o:!1,this.valueHexView=s.valueHex?Me.toUint8Array(s.valueHex):gc}get valueHex(){return this.valueHexView.slice().buffer}set valueHex(i){this.valueHexView=new Uint8Array(i)}fromBER(i,o,s){const a=i instanceof ArrayBuffer?new Uint8Array(i):i;if(!Pn(this,a,o,s))return-1;const c=o+s;return this.valueHexView=a.subarray(o,c),this.valueHexView.length?(this.blockLength=s,c):(this.warnings.push("Zero buffer length"),o)}toBER(i=!1){return this.isHexOnly?i?new ArrayBuffer(this.valueHexView.byteLength):this.valueHexView.byteLength===this.valueHexView.buffer.byteLength?this.valueHexView.buffer:this.valueHexView.slice().buffer:(this.error="Flag 'isHexOnly' is not set, abort",rn)}toJSON(){return{...super.toJSON(),isHexOnly:this.isHexOnly,valueHex:At.ToHex(this.valueHexView)}}},t.NAME="hexBlock",t}class to{constructor({blockLength:t=0,error:n=lr,warnings:i=[],valueBeforeDecode:o=gc}={}){this.blockLength=t,this.error=n,this.warnings=i,this.valueBeforeDecodeView=Me.toUint8Array(o)}static blockName(){return this.NAME}get valueBeforeDecode(){return this.valueBeforeDecodeView.slice().buffer}set valueBeforeDecode(t){this.valueBeforeDecodeView=new Uint8Array(t)}toJSON(){return{blockName:this.constructor.NAME,blockLength:this.blockLength,error:this.error,warnings:this.warnings,valueBeforeDecode:At.ToHex(this.valueBeforeDecodeView)}}}to.NAME="baseBlock";class sr extends to{fromBER(t,n,i){throw TypeError("User need to make a specific function in a class which extends 'ValueBlock'")}toBER(t,n){throw TypeError("User need to make a specific function in a class which extends 'ValueBlock'")}}sr.NAME="valueBlock";class py extends wn(to){constructor({idBlock:t={}}={}){var n,i,o,s;super(),t?(this.isHexOnly=(n=t.isHexOnly)!==null&&n!==void 0?n:!1,this.valueHexView=t.valueHex?Me.toUint8Array(t.valueHex):gc,this.tagClass=(i=t.tagClass)!==null&&i!==void 0?i:-1,this.tagNumber=(o=t.tagNumber)!==null&&o!==void 0?o:-1,this.isConstructed=(s=t.isConstructed)!==null&&s!==void 0?s:!1):(this.tagClass=-1,this.tagNumber=-1,this.isConstructed=!1)}toBER(t=!1){let n=0;switch(this.tagClass){case 1:n|=0;break;case 2:n|=64;break;case 3:n|=128;break;case 4:n|=192;break;default:return this.error="Unknown tag class",rn}if(this.isConstructed&&(n|=32),this.tagNumber<31&&!this.isHexOnly){const o=new Uint8Array(1);if(!t){let s=this.tagNumber;s&=31,n|=s,o[0]=n}return o.buffer}if(!this.isHexOnly){const o=qi(this.tagNumber,7),s=new Uint8Array(o),a=o.byteLength,c=new Uint8Array(a+1);if(c[0]=n|31,!t){for(let f=0;f<a-1;f++)c[f+1]=s[f]|128;c[a]=s[a-1]}return c.buffer}const i=new Uint8Array(this.valueHexView.byteLength+1);if(i[0]=n|31,!t){const o=this.valueHexView;for(let s=0;s<o.length-1;s++)i[s+1]=o[s]|128;i[this.valueHexView.byteLength]=o[o.length-1]}return i.buffer}fromBER(t,n,i){const o=Me.toUint8Array(t);if(!Pn(this,o,n,i))return-1;const s=o.subarray(n,n+i);if(s.length===0)return this.error="Zero buffer length",-1;switch(s[0]&192){case 0:this.tagClass=1;break;case 64:this.tagClass=2;break;case 128:this.tagClass=3;break;case 192:this.tagClass=4;break;default:return this.error="Unknown tag class",-1}this.isConstructed=(s[0]&32)===32,this.isHexOnly=!1;const c=s[0]&31;if(c!==31)this.tagNumber=c,this.blockLength=1;else{let f=1,h=this.valueHexView=new Uint8Array(255),d=255;for(;s[f]&128;){if(h[f-1]=s[f]&127,f++,f>=s.length)return this.error="End of input reached before message was fully decoded",-1;if(f===d){d+=255;const x=new Uint8Array(d);for(let S=0;S<h.length;S++)x[S]=h[S];h=this.valueHexView=new Uint8Array(d)}}this.blockLength=f+1,h[f-1]=s[f]&127;const g=new Uint8Array(f);for(let x=0;x<f;x++)g[x]=h[x];h=this.valueHexView=new Uint8Array(f),h.set(g),this.blockLength<=9?this.tagNumber=So(h,7):(this.isHexOnly=!0,this.warnings.push("Tag too long, represented as hex-coded"))}if(this.tagClass===1&&this.isConstructed)switch(this.tagNumber){case 1:case 2:case 5:case 6:case 9:case 13:case 14:case 23:case 24:case 31:case 32:case 33:case 34:return this.error="Constructed encoding used for primitive type",-1}return n+this.blockLength}toJSON(){return{...super.toJSON(),tagClass:this.tagClass,tagNumber:this.tagNumber,isConstructed:this.isConstructed}}}py.NAME="identificationBlock";class gy extends to{constructor({lenBlock:t={}}={}){var n,i,o;super(),this.isIndefiniteForm=(n=t.isIndefiniteForm)!==null&&n!==void 0?n:!1,this.longFormUsed=(i=t.longFormUsed)!==null&&i!==void 0?i:!1,this.length=(o=t.length)!==null&&o!==void 0?o:0}fromBER(t,n,i){const o=Me.toUint8Array(t);if(!Pn(this,o,n,i))return-1;const s=o.subarray(n,n+i);if(s.length===0)return this.error="Zero buffer length",-1;if(s[0]===255)return this.error="Length block 0xFF is reserved by standard",-1;if(this.isIndefiniteForm=s[0]===128,this.isIndefiniteForm)return this.blockLength=1,n+this.blockLength;if(this.longFormUsed=!!(s[0]&128),this.longFormUsed===!1)return this.length=s[0],this.blockLength=1,n+this.blockLength;const a=s[0]&127;if(a>8)return this.error="Too big integer",-1;if(a+1>s.length)return this.error="End of input reached before message was fully decoded",-1;const c=n+1,f=o.subarray(c,c+a);return f[a-1]===0&&this.warnings.push("Needlessly long encoded length"),this.length=So(f,8),this.longFormUsed&&this.length<=127&&this.warnings.push("Unnecessary usage of long length form"),this.blockLength=a+1,n+this.blockLength}toBER(t=!1){let n,i;if(this.length>127&&(this.longFormUsed=!0),this.isIndefiniteForm)return n=new ArrayBuffer(1),t===!1&&(i=new Uint8Array(n),i[0]=128),n;if(this.longFormUsed){const o=qi(this.length,8);if(o.byteLength>127)return this.error="Too big length",rn;if(n=new ArrayBuffer(o.byteLength+1),t)return n;const s=new Uint8Array(o);i=new Uint8Array(n),i[0]=o.byteLength|128;for(let a=0;a<o.byteLength;a++)i[a+1]=s[a];return n}return n=new ArrayBuffer(1),t===!1&&(i=new Uint8Array(n),i[0]=this.length),n}toJSON(){return{...super.toJSON(),isIndefiniteForm:this.isIndefiniteForm,longFormUsed:this.longFormUsed,length:this.length}}}gy.NAME="lengthBlock";const he={};class zt extends to{constructor({name:t=lr,optional:n=!1,primitiveSchema:i,...o}={},s){super(o),this.name=t,this.optional=n,i&&(this.primitiveSchema=i),this.idBlock=new py(o),this.lenBlock=new gy(o),this.valueBlock=s?new s(o):new sr(o)}fromBER(t,n,i){const o=this.valueBlock.fromBER(t,n,this.lenBlock.isIndefiniteForm?i:this.lenBlock.length);return o===-1?(this.error=this.valueBlock.error,o):(this.idBlock.error.length||(this.blockLength+=this.idBlock.blockLength),this.lenBlock.error.length||(this.blockLength+=this.lenBlock.blockLength),this.valueBlock.error.length||(this.blockLength+=this.valueBlock.blockLength),o)}toBER(t,n){const i=n||new pc;n||yy(this);const o=this.idBlock.toBER(t);if(i.write(o),this.lenBlock.isIndefiniteForm)i.write(new Uint8Array([128]).buffer),this.valueBlock.toBER(t,i),i.write(new ArrayBuffer(2));else{const s=this.valueBlock.toBER(t);this.lenBlock.length=s.byteLength;const a=this.lenBlock.toBER(t);i.write(a),i.write(s)}return n?rn:i.final()}toJSON(){const t={...super.toJSON(),idBlock:this.idBlock.toJSON(),lenBlock:this.lenBlock.toJSON(),valueBlock:this.valueBlock.toJSON(),name:this.name,optional:this.optional};return this.primitiveSchema&&(t.primitiveSchema=this.primitiveSchema.toJSON()),t}toString(t="ascii"){return t==="ascii"?this.onAsciiEncoding():At.ToHex(this.toBER())}onAsciiEncoding(){return`${this.constructor.NAME} : ${At.ToHex(this.valueBlock.valueBeforeDecodeView)}`}isEqual(t){if(this===t)return!0;if(!(t instanceof this.constructor))return!1;const n=this.toBER(),i=t.toBER();return YE(n,i)}}zt.NAME="BaseBlock";function yy(r){if(r instanceof he.Constructed)for(const t of r.valueBlock.value)yy(t)&&(r.lenBlock.isIndefiniteForm=!0);return!!r.lenBlock.isIndefiniteForm}class fh extends zt{constructor({value:t=lr,...n}={},i){super(n,i),t&&this.fromString(t)}getValue(){return this.valueBlock.value}setValue(t){this.valueBlock.value=t}fromBER(t,n,i){const o=this.valueBlock.fromBER(t,n,this.lenBlock.isIndefiniteForm?i:this.lenBlock.length);return o===-1?(this.error=this.valueBlock.error,o):(this.fromBuffer(this.valueBlock.valueHexView),this.idBlock.error.length||(this.blockLength+=this.idBlock.blockLength),this.lenBlock.error.length||(this.blockLength+=this.lenBlock.blockLength),this.valueBlock.error.length||(this.blockLength+=this.valueBlock.blockLength),o)}onAsciiEncoding(){return`${this.constructor.NAME} : '${this.valueBlock.value}'`}}fh.NAME="BaseStringBlock";class wy extends wn(sr){constructor({isHexOnly:t=!0,...n}={}){super(n),this.isHexOnly=t}}wy.NAME="PrimitiveValueBlock";var my;class Ns extends zt{constructor(t={}){super(t,wy),this.idBlock.isConstructed=!1}}my=Ns;he.Primitive=my;Ns.NAME="PRIMITIVE";function oS(r,t){if(r instanceof t)return r;const n=new t;return n.idBlock=r.idBlock,n.lenBlock=r.lenBlock,n.warnings=r.warnings,n.valueBeforeDecodeView=r.valueBeforeDecodeView,n}function Uo(r,t=0,n=r.length){const i=t;let o=new zt({},sr);const s=new to;if(!Pn(s,r,t,n))return o.error=s.error,{offset:-1,result:o};if(!r.subarray(t,t+n).length)return o.error="Zero buffer length",{offset:-1,result:o};let c=o.idBlock.fromBER(r,t,n);if(o.idBlock.warnings.length&&o.warnings.concat(o.idBlock.warnings),c===-1)return o.error=o.idBlock.error,{offset:-1,result:o};if(t=c,n-=o.idBlock.blockLength,c=o.lenBlock.fromBER(r,t,n),o.lenBlock.warnings.length&&o.warnings.concat(o.lenBlock.warnings),c===-1)return o.error=o.lenBlock.error,{offset:-1,result:o};if(t=c,n-=o.lenBlock.blockLength,!o.idBlock.isConstructed&&o.lenBlock.isIndefiniteForm)return o.error="Indefinite length form used for primitive encoding form",{offset:-1,result:o};let f=zt;switch(o.idBlock.tagClass){case 1:if(o.idBlock.tagNumber>=37&&o.idBlock.isHexOnly===!1)return o.error="UNIVERSAL 37 and upper tags are reserved by ASN.1 standard",{offset:-1,result:o};switch(o.idBlock.tagNumber){case 0:if(o.idBlock.isConstructed&&o.lenBlock.length>0)return o.error="Type [UNIVERSAL 0] is reserved",{offset:-1,result:o};f=he.EndOfContent;break;case 1:f=he.Boolean;break;case 2:f=he.Integer;break;case 3:f=he.BitString;break;case 4:f=he.OctetString;break;case 5:f=he.Null;break;case 6:f=he.ObjectIdentifier;break;case 10:f=he.Enumerated;break;case 12:f=he.Utf8String;break;case 13:f=he.RelativeObjectIdentifier;break;case 14:f=he.TIME;break;case 15:return o.error="[UNIVERSAL 15] is reserved by ASN.1 standard",{offset:-1,result:o};case 16:f=he.Sequence;break;case 17:f=he.Set;break;case 18:f=he.NumericString;break;case 19:f=he.PrintableString;break;case 20:f=he.TeletexString;break;case 21:f=he.VideotexString;break;case 22:f=he.IA5String;break;case 23:f=he.UTCTime;break;case 24:f=he.GeneralizedTime;break;case 25:f=he.GraphicString;break;case 26:f=he.VisibleString;break;case 27:f=he.GeneralString;break;case 28:f=he.UniversalString;break;case 29:f=he.CharacterString;break;case 30:f=he.BmpString;break;case 31:f=he.DATE;break;case 32:f=he.TimeOfDay;break;case 33:f=he.DateTime;break;case 34:f=he.Duration;break;default:{const h=o.idBlock.isConstructed?new he.Constructed:new he.Primitive;h.idBlock=o.idBlock,h.lenBlock=o.lenBlock,h.warnings=o.warnings,o=h}}break;case 2:case 3:case 4:default:f=o.idBlock.isConstructed?he.Constructed:he.Primitive}return o=oS(o,f),c=o.fromBER(r,t,o.lenBlock.isIndefiniteForm?n:o.lenBlock.length),o.valueBeforeDecodeView=r.subarray(i,i+o.blockLength),{offset:c,result:o}}function ho(r){if(!r.byteLength){const t=new zt({},sr);return t.error="Input buffer has zero length",{offset:-1,result:t}}return Uo(Me.toUint8Array(r).slice(),0,r.byteLength)}function sS(r,t){return r?1:t}class li extends sr{constructor({value:t=[],isIndefiniteForm:n=!1,...i}={}){super(i),this.value=t,this.isIndefiniteForm=n}fromBER(t,n,i){const o=Me.toUint8Array(t);if(!Pn(this,o,n,i))return-1;if(this.valueBeforeDecodeView=o.subarray(n,n+i),this.valueBeforeDecodeView.length===0)return this.warnings.push("Zero buffer length"),n;let s=n;for(;sS(this.isIndefiniteForm,i)>0;){const a=Uo(o,s,i);if(a.offset===-1)return this.error=a.result.error,this.warnings.concat(a.result.warnings),-1;if(s=a.offset,this.blockLength+=a.result.blockLength,i-=a.result.blockLength,this.value.push(a.result),this.isIndefiniteForm&&a.result.constructor.NAME===ps)break}return this.isIndefiniteForm&&(this.value[this.value.length-1].constructor.NAME===ps?this.value.pop():this.warnings.push("No EndOfContent block encoded")),s}toBER(t,n){const i=n||new pc;for(let o=0;o<this.value.length;o++)this.value[o].toBER(t,i);return n?rn:i.final()}toJSON(){const t={...super.toJSON(),isIndefiniteForm:this.isIndefiniteForm,value:[]};for(const n of this.value)t.value.push(n.toJSON());return t}}li.NAME="ConstructedValueBlock";var by;class dr extends zt{constructor(t={}){super(t,li),this.idBlock.isConstructed=!0}fromBER(t,n,i){this.valueBlock.isIndefiniteForm=this.lenBlock.isIndefiniteForm;const o=this.valueBlock.fromBER(t,n,this.lenBlock.isIndefiniteForm?i:this.lenBlock.length);return o===-1?(this.error=this.valueBlock.error,o):(this.idBlock.error.length||(this.blockLength+=this.idBlock.blockLength),this.lenBlock.error.length||(this.blockLength+=this.lenBlock.blockLength),this.valueBlock.error.length||(this.blockLength+=this.valueBlock.blockLength),o)}onAsciiEncoding(){const t=[];for(const i of this.valueBlock.value)t.push(i.toString("ascii").split(`
`).map(o=>` ${o}`).join(`
`));const n=this.idBlock.tagClass===3?`[${this.idBlock.tagNumber}]`:this.constructor.NAME;return t.length?`${n} :
${t.join(`
`)}`:`${n} :`}}by=dr;he.Constructed=by;dr.NAME="CONSTRUCTED";class vy extends sr{fromBER(t,n,i){return n}toBER(t){return rn}}vy.override="EndOfContentValueBlock";var xy;class uh extends zt{constructor(t={}){super(t,vy),this.idBlock.tagClass=1,this.idBlock.tagNumber=0}}xy=uh;he.EndOfContent=xy;uh.NAME=ps;var Ay;class Gi extends zt{constructor(t={}){super(t,sr),this.idBlock.tagClass=1,this.idBlock.tagNumber=5}fromBER(t,n,i){return this.lenBlock.length>0&&this.warnings.push("Non-zero length of value block for Null type"),this.idBlock.error.length||(this.blockLength+=this.idBlock.blockLength),this.lenBlock.error.length||(this.blockLength+=this.lenBlock.blockLength),this.blockLength+=i,n+i>t.byteLength?(this.error="End of input reached before message was fully decoded (inconsistent offset and length values)",-1):n+i}toBER(t,n){const i=new ArrayBuffer(2);if(!t){const o=new Uint8Array(i);o[0]=5,o[1]=0}return n&&n.write(i),i}onAsciiEncoding(){return`${this.constructor.NAME}`}}Ay=Gi;he.Null=Ay;Gi.NAME="NULL";class Ey extends wn(sr){constructor({value:t,...n}={}){super(n),n.valueHex?this.valueHexView=Me.toUint8Array(n.valueHex):this.valueHexView=new Uint8Array(1),t&&(this.value=t)}get value(){for(const t of this.valueHexView)if(t>0)return!0;return!1}set value(t){this.valueHexView[0]=t?255:0}fromBER(t,n,i){const o=Me.toUint8Array(t);return Pn(this,o,n,i)?(this.valueHexView=o.subarray(n,n+i),i>1&&this.warnings.push("Boolean value encoded in more then 1 octet"),this.isHexOnly=!0,ly.call(this),this.blockLength=i,n+i):-1}toBER(){return this.valueHexView.slice()}toJSON(){return{...super.toJSON(),value:this.value}}}Ey.NAME="BooleanValueBlock";var Sy;class yc extends zt{constructor(t={}){super(t,Ey),this.idBlock.tagClass=1,this.idBlock.tagNumber=1}getValue(){return this.valueBlock.value}setValue(t){this.valueBlock.value=t}onAsciiEncoding(){return`${this.constructor.NAME} : ${this.getValue}`}}Sy=yc;he.Boolean=Sy;yc.NAME="BOOLEAN";class By extends wn(li){constructor({isConstructed:t=!1,...n}={}){super(n),this.isConstructed=t}fromBER(t,n,i){let o=0;if(this.isConstructed){if(this.isHexOnly=!1,o=li.prototype.fromBER.call(this,t,n,i),o===-1)return o;for(let s=0;s<this.value.length;s++){const a=this.value[s].constructor.NAME;if(a===ps){if(this.isIndefiniteForm)break;return this.error="EndOfContent is unexpected, OCTET STRING may consists of OCTET STRINGs only",-1}if(a!==hy)return this.error="OCTET STRING may consists of OCTET STRINGs only",-1}}else this.isHexOnly=!0,o=super.fromBER(t,n,i),this.blockLength=i;return o}toBER(t,n){return this.isConstructed?li.prototype.toBER.call(this,t,n):t?new ArrayBuffer(this.valueHexView.byteLength):this.valueHexView.slice().buffer}toJSON(){return{...super.toJSON(),isConstructed:this.isConstructed}}}By.NAME="OctetStringValueBlock";var Dy;let Li=class Cy extends zt{constructor({idBlock:t={},lenBlock:n={},...i}={}){var o,s;(o=i.isConstructed)!==null&&o!==void 0||(i.isConstructed=!!(!((s=i.value)===null||s===void 0)&&s.length)),super({idBlock:{isConstructed:i.isConstructed,...t},lenBlock:{...n,isIndefiniteForm:!!i.isIndefiniteForm},...i},By),this.idBlock.tagClass=1,this.idBlock.tagNumber=4}fromBER(t,n,i){if(this.valueBlock.isConstructed=this.idBlock.isConstructed,this.valueBlock.isIndefiniteForm=this.lenBlock.isIndefiniteForm,i===0)return this.idBlock.error.length===0&&(this.blockLength+=this.idBlock.blockLength),this.lenBlock.error.length===0&&(this.blockLength+=this.lenBlock.blockLength),n;if(!this.valueBlock.isConstructed){const s=(t instanceof ArrayBuffer?new Uint8Array(t):t).subarray(n,n+i);try{if(s.byteLength){const a=Uo(s,0,s.byteLength);a.offset!==-1&&a.offset===i&&(this.valueBlock.value=[a.result])}}catch{}}return super.fromBER(t,n,i)}onAsciiEncoding(){return this.valueBlock.isConstructed||this.valueBlock.value&&this.valueBlock.value.length?dr.prototype.onAsciiEncoding.call(this):`${this.constructor.NAME} : ${At.ToHex(this.valueBlock.valueHexView)}`}getValue(){if(!this.idBlock.isConstructed)return this.valueBlock.valueHexView.slice().buffer;const t=[];for(const n of this.valueBlock.value)n instanceof Cy&&t.push(n.valueBlock.valueHexView);return Me.concat(t)}};Dy=Li;he.OctetString=Dy;Li.NAME=hy;class Iy extends wn(li){constructor({unusedBits:t=0,isConstructed:n=!1,...i}={}){super(i),this.unusedBits=t,this.isConstructed=n,this.blockLength=this.valueHexView.byteLength}fromBER(t,n,i){if(!i)return n;let o=-1;if(this.isConstructed){if(o=li.prototype.fromBER.call(this,t,n,i),o===-1)return o;for(const c of this.value){const f=c.constructor.NAME;if(f===ps){if(this.isIndefiniteForm)break;return this.error="EndOfContent is unexpected, BIT STRING may consists of BIT STRINGs only",-1}if(f!==dy)return this.error="BIT STRING may consists of BIT STRINGs only",-1;const h=c.valueBlock;if(this.unusedBits>0&&h.unusedBits>0)return this.error='Using of "unused bits" inside constructive BIT STRING allowed for least one only',-1;this.unusedBits=h.unusedBits}return o}const s=Me.toUint8Array(t);if(!Pn(this,s,n,i))return-1;const a=s.subarray(n,n+i);if(this.unusedBits=a[0],this.unusedBits>7)return this.error="Unused bits for BitString must be in range 0-7",-1;if(!this.unusedBits){const c=a.subarray(1);try{if(c.byteLength){const f=Uo(c,0,c.byteLength);f.offset!==-1&&f.offset===i-1&&(this.value=[f.result])}}catch{}}return this.valueHexView=a.subarray(1),this.blockLength=a.length,n+i}toBER(t,n){if(this.isConstructed)return li.prototype.toBER.call(this,t,n);if(t)return new ArrayBuffer(this.valueHexView.byteLength+1);if(!this.valueHexView.byteLength)return rn;const i=new Uint8Array(this.valueHexView.length+1);return i[0]=this.unusedBits,i.set(this.valueHexView,1),i.buffer}toJSON(){return{...super.toJSON(),unusedBits:this.unusedBits,isConstructed:this.isConstructed}}}Iy.NAME="BitStringValueBlock";var _y;let Hi=class extends zt{constructor({idBlock:t={},lenBlock:n={},...i}={}){var o,s;(o=i.isConstructed)!==null&&o!==void 0||(i.isConstructed=!!(!((s=i.value)===null||s===void 0)&&s.length)),super({idBlock:{isConstructed:i.isConstructed,...t},lenBlock:{...n,isIndefiniteForm:!!i.isIndefiniteForm},...i},Iy),this.idBlock.tagClass=1,this.idBlock.tagNumber=3}fromBER(t,n,i){return this.valueBlock.isConstructed=this.idBlock.isConstructed,this.valueBlock.isIndefiniteForm=this.lenBlock.isIndefiniteForm,super.fromBER(t,n,i)}onAsciiEncoding(){if(this.valueBlock.isConstructed||this.valueBlock.value&&this.valueBlock.value.length)return dr.prototype.onAsciiEncoding.call(this);{const t=[],n=this.valueBlock.valueHexView;for(const o of n)t.push(o.toString(2).padStart(8,"0"));const i=t.join("");return`${this.constructor.NAME} : ${i.substring(0,i.length-this.valueBlock.unusedBits)}`}}};_y=Hi;he.BitString=_y;Hi.NAME=dy;var My;function aS(r,t){const n=new Uint8Array([0]),i=new Uint8Array(r),o=new Uint8Array(t);let s=i.slice(0);const a=s.length-1,c=o.slice(0),f=c.length-1;let h=0;const d=f<a?a:f;let g=0;for(let x=d;x>=0;x--,g++){switch(!0){case g<c.length:h=s[a-g]+c[f-g]+n[0];break;default:h=s[a-g]+n[0]}switch(n[0]=h/10,!0){case g>=s.length:s=Fu(new Uint8Array([h%10]),s);break;default:s[a-g]=h%10}}return n[0]>0&&(s=Fu(n,s)),s}function K0(r){if(r>=zo.length)for(let t=zo.length;t<=r;t++){const n=new Uint8Array([0]);let i=zo[t-1].slice(0);for(let o=i.length-1;o>=0;o--){const s=new Uint8Array([(i[o]<<1)+n[0]]);n[0]=s[0]/10,i[o]=s[0]%10}n[0]>0&&(i=Fu(n,i)),zo.push(i)}return zo[r]}function cS(r,t){let n=0;const i=new Uint8Array(r),o=new Uint8Array(t),s=i.slice(0),a=s.length-1,c=o.slice(0),f=c.length-1;let h,d=0;for(let g=f;g>=0;g--,d++)switch(h=s[a-d]-c[f-d]-n,!0){case h<0:n=1,s[a-d]=h+10;break;default:n=0,s[a-d]=h}if(n>0)for(let g=a-f+1;g>=0;g--,d++)if(h=s[a-d]-n,h<0)n=1,s[a-d]=h+10;else{n=0,s[a-d]=h;break}return s.slice()}class lh extends wn(sr){constructor({value:t,...n}={}){super(n),this._valueDec=0,n.valueHex&&this.setValueHex(),t!==void 0&&(this.valueDec=t)}setValueHex(){this.valueHexView.length>=4?(this.warnings.push("Too big Integer for decoding, hex only"),this.isHexOnly=!0,this._valueDec=0):(this.isHexOnly=!1,this.valueHexView.length>0&&(this._valueDec=ly.call(this)))}set valueDec(t){this._valueDec=t,this.isHexOnly=!1,this.valueHexView=new Uint8Array(JE(t))}get valueDec(){return this._valueDec}fromDER(t,n,i,o=0){const s=this.fromBER(t,n,i);if(s===-1)return s;const a=this.valueHexView;return a[0]===0&&a[1]&128?this.valueHexView=a.subarray(1):o!==0&&a.length<o&&(o-a.length>1&&(o=a.length+1),this.valueHexView=a.subarray(o-a.length)),s}toDER(t=!1){const n=this.valueHexView;switch(!0){case(n[0]&128)!==0:{const i=new Uint8Array(this.valueHexView.length+1);i[0]=0,i.set(n,1),this.valueHexView=i}break;case(n[0]===0&&(n[1]&128)===0):this.valueHexView=this.valueHexView.subarray(1);break}return this.toBER(t)}fromBER(t,n,i){const o=super.fromBER(t,n,i);return o===-1||this.setValueHex(),o}toBER(t){return t?new ArrayBuffer(this.valueHexView.length):this.valueHexView.slice().buffer}toJSON(){return{...super.toJSON(),valueDec:this.valueDec}}toString(){const t=this.valueHexView.length*8-1;let n=new Uint8Array(this.valueHexView.length*8/3),i=0,o;const s=this.valueHexView;let a="",c=!1;for(let f=s.byteLength-1;f>=0;f--){o=s[f];for(let h=0;h<8;h++){if((o&1)===1)switch(i){case t:n=cS(K0(i),n),a="-";break;default:n=aS(n,K0(i))}i++,o>>=1}}for(let f=0;f<n.length;f++)n[f]&&(c=!0),c&&(a+=V0.charAt(n[f]));return c===!1&&(a+=V0.charAt(0)),a}}My=lh;lh.NAME="IntegerValueBlock";Object.defineProperty(My.prototype,"valueHex",{set:function(r){this.valueHexView=new Uint8Array(r),this.setValueHex()},get:function(){return this.valueHexView.slice().buffer}});var ky;class dn extends zt{constructor(t={}){super(t,lh),this.idBlock.tagClass=1,this.idBlock.tagNumber=2}toBigInt(){return Fa(),BigInt(this.valueBlock.toString())}static fromBigInt(t){Fa();const n=BigInt(t),i=new pc,o=n.toString(16).replace(/^-/,""),s=new Uint8Array(At.FromHex(o));if(n<0){const c=new Uint8Array(s.length+(s[0]&128?1:0));c[0]|=128;const h=BigInt(`0x${At.ToHex(c)}`)+n,d=Me.toUint8Array(At.FromHex(h.toString(16)));d[0]|=128,i.write(d)}else s[0]&128&&i.write(new Uint8Array([0])),i.write(s);return new dn({valueHex:i.final()})}convertToDER(){const t=new dn({valueHex:this.valueBlock.valueHexView});return t.valueBlock.toDER(),t}convertFromDER(){return new dn({valueHex:this.valueBlock.valueHexView[0]===0?this.valueBlock.valueHexView.subarray(1):this.valueBlock.valueHexView})}onAsciiEncoding(){return`${this.constructor.NAME} : ${this.valueBlock.toString()}`}}ky=dn;he.Integer=ky;dn.NAME="INTEGER";var Ty;class wc extends dn{constructor(t={}){super(t),this.idBlock.tagClass=1,this.idBlock.tagNumber=10}}Ty=wc;he.Enumerated=Ty;wc.NAME="ENUMERATED";class Lu extends wn(sr){constructor({valueDec:t=-1,isFirstSid:n=!1,...i}={}){super(i),this.valueDec=t,this.isFirstSid=n}fromBER(t,n,i){if(!i)return n;const o=Me.toUint8Array(t);if(!Pn(this,o,n,i))return-1;const s=o.subarray(n,n+i);this.valueHexView=new Uint8Array(i);for(let c=0;c<i&&(this.valueHexView[c]=s[c]&127,this.blockLength++,!!(s[c]&128));c++);const a=new Uint8Array(this.blockLength);for(let c=0;c<this.blockLength;c++)a[c]=this.valueHexView[c];return this.valueHexView=a,s[this.blockLength-1]&128?(this.error="End of input reached before message was fully decoded",-1):(this.valueHexView[0]===0&&this.warnings.push("Needlessly long format of SID encoding"),this.blockLength<=8?this.valueDec=So(this.valueHexView,7):(this.isHexOnly=!0,this.warnings.push("Too big SID for decoding, hex only")),n+this.blockLength)}set valueBigInt(t){Fa();let n=BigInt(t).toString(2);for(;n.length%7;)n="0"+n;const i=new Uint8Array(n.length/7);for(let o=0;o<i.length;o++)i[o]=parseInt(n.slice(o*7,o*7+7),2)+(o+1<i.length?128:0);this.fromBER(i.buffer,0,i.length)}toBER(t){if(this.isHexOnly){if(t)return new ArrayBuffer(this.valueHexView.byteLength);const o=this.valueHexView,s=new Uint8Array(this.blockLength);for(let a=0;a<this.blockLength-1;a++)s[a]=o[a]|128;return s[this.blockLength-1]=o[this.blockLength-1],s.buffer}const n=qi(this.valueDec,7);if(n.byteLength===0)return this.error="Error during encoding SID value",rn;const i=new Uint8Array(n.byteLength);if(!t){const o=new Uint8Array(n),s=n.byteLength-1;for(let a=0;a<s;a++)i[a]=o[a]|128;i[s]=o[s]}return i}toString(){let t="";if(this.isHexOnly)t=At.ToHex(this.valueHexView);else if(this.isFirstSid){let n=this.valueDec;this.valueDec<=39?t="0.":this.valueDec<=79?(t="1.",n-=40):(t="2.",n-=80),t+=n.toString()}else t=this.valueDec.toString();return t}toJSON(){return{...super.toJSON(),valueDec:this.valueDec,isFirstSid:this.isFirstSid}}}Lu.NAME="sidBlock";class Ny extends sr{constructor({value:t=lr,...n}={}){super(n),this.value=[],t&&this.fromString(t)}fromBER(t,n,i){let o=n;for(;i>0;){const s=new Lu;if(o=s.fromBER(t,o,i),o===-1)return this.blockLength=0,this.error=s.error,o;this.value.length===0&&(s.isFirstSid=!0),this.blockLength+=s.blockLength,i-=s.blockLength,this.value.push(s)}return o}toBER(t){const n=[];for(let i=0;i<this.value.length;i++){const o=this.value[i].toBER(t);if(o.byteLength===0)return this.error=this.value[i].error,rn;n.push(o)}return ch(n)}fromString(t){this.value=[];let n=0,i=0,o="",s=!1;do if(i=t.indexOf(".",n),i===-1?o=t.substring(n):o=t.substring(n,i),n=i+1,s){const a=this.value[0];let c=0;switch(a.valueDec){case 0:break;case 1:c=40;break;case 2:c=80;break;default:this.value=[];return}const f=parseInt(o,10);if(isNaN(f))return;a.valueDec=f+c,s=!1}else{const a=new Lu;if(o>Number.MAX_SAFE_INTEGER){Fa();const c=BigInt(o);a.valueBigInt=c}else if(a.valueDec=parseInt(o,10),isNaN(a.valueDec))return;this.value.length||(a.isFirstSid=!0,s=!0),this.value.push(a)}while(i!==-1)}toString(){let t="",n=!1;for(let i=0;i<this.value.length;i++){n=this.value[i].isHexOnly;let o=this.value[i].toString();i!==0&&(t=`${t}.`),n?(o=`{${o}}`,this.value[i].isFirstSid?t=`2.{${o} - 80}`:t+=o):t+=o}return t}toJSON(){const t={...super.toJSON(),value:this.toString(),sidArray:[]};for(let n=0;n<this.value.length;n++)t.sidArray.push(this.value[n].toJSON());return t}}Ny.NAME="ObjectIdentifierValueBlock";var Ry;class mc extends zt{constructor(t={}){super(t,Ny),this.idBlock.tagClass=1,this.idBlock.tagNumber=6}getValue(){return this.valueBlock.toString()}setValue(t){this.valueBlock.fromString(t)}onAsciiEncoding(){return`${this.constructor.NAME} : ${this.valueBlock.toString()||"empty"}`}toJSON(){return{...super.toJSON(),value:this.getValue()}}}Ry=mc;he.ObjectIdentifier=Ry;mc.NAME="OBJECT IDENTIFIER";class Hu extends wn(to){constructor({valueDec:t=0,...n}={}){super(n),this.valueDec=t}fromBER(t,n,i){if(i===0)return n;const o=Me.toUint8Array(t);if(!Pn(this,o,n,i))return-1;const s=o.subarray(n,n+i);this.valueHexView=new Uint8Array(i);for(let c=0;c<i&&(this.valueHexView[c]=s[c]&127,this.blockLength++,!!(s[c]&128));c++);const a=new Uint8Array(this.blockLength);for(let c=0;c<this.blockLength;c++)a[c]=this.valueHexView[c];return this.valueHexView=a,s[this.blockLength-1]&128?(this.error="End of input reached before message was fully decoded",-1):(this.valueHexView[0]===0&&this.warnings.push("Needlessly long format of SID encoding"),this.blockLength<=8?this.valueDec=So(this.valueHexView,7):(this.isHexOnly=!0,this.warnings.push("Too big SID for decoding, hex only")),n+this.blockLength)}toBER(t){if(this.isHexOnly){if(t)return new ArrayBuffer(this.valueHexView.byteLength);const o=this.valueHexView,s=new Uint8Array(this.blockLength);for(let a=0;a<this.blockLength-1;a++)s[a]=o[a]|128;return s[this.blockLength-1]=o[this.blockLength-1],s.buffer}const n=qi(this.valueDec,7);if(n.byteLength===0)return this.error="Error during encoding SID value",rn;const i=new Uint8Array(n.byteLength);if(!t){const o=new Uint8Array(n),s=n.byteLength-1;for(let a=0;a<s;a++)i[a]=o[a]|128;i[s]=o[s]}return i.buffer}toString(){let t="";return this.isHexOnly?t=At.ToHex(this.valueHexView):t=this.valueDec.toString(),t}toJSON(){return{...super.toJSON(),valueDec:this.valueDec}}}Hu.NAME="relativeSidBlock";class Uy extends sr{constructor({value:t=lr,...n}={}){super(n),this.value=[],t&&this.fromString(t)}fromBER(t,n,i){let o=n;for(;i>0;){const s=new Hu;if(o=s.fromBER(t,o,i),o===-1)return this.blockLength=0,this.error=s.error,o;this.blockLength+=s.blockLength,i-=s.blockLength,this.value.push(s)}return o}toBER(t,n){const i=[];for(let o=0;o<this.value.length;o++){const s=this.value[o].toBER(t);if(s.byteLength===0)return this.error=this.value[o].error,rn;i.push(s)}return ch(i)}fromString(t){this.value=[];let n=0,i=0,o="";do{i=t.indexOf(".",n),i===-1?o=t.substring(n):o=t.substring(n,i),n=i+1;const s=new Hu;if(s.valueDec=parseInt(o,10),isNaN(s.valueDec))return!0;this.value.push(s)}while(i!==-1);return!0}toString(){let t="",n=!1;for(let i=0;i<this.value.length;i++){n=this.value[i].isHexOnly;let o=this.value[i].toString();i!==0&&(t=`${t}.`),n&&(o=`{${o}}`),t+=o}return t}toJSON(){const t={...super.toJSON(),value:this.toString(),sidArray:[]};for(let n=0;n<this.value.length;n++)t.sidArray.push(this.value[n].toJSON());return t}}Uy.NAME="RelativeObjectIdentifierValueBlock";var Oy;class hh extends zt{constructor(t={}){super(t,Uy),this.idBlock.tagClass=1,this.idBlock.tagNumber=13}getValue(){return this.valueBlock.toString()}setValue(t){this.valueBlock.fromString(t)}onAsciiEncoding(){return`${this.constructor.NAME} : ${this.valueBlock.toString()||"empty"}`}toJSON(){return{...super.toJSON(),value:this.getValue()}}}Oy=hh;he.RelativeObjectIdentifier=Oy;hh.NAME="RelativeObjectIdentifier";var Py;class kn extends dr{constructor(t={}){super(t),this.idBlock.tagClass=1,this.idBlock.tagNumber=16}}Py=kn;he.Sequence=Py;kn.NAME="SEQUENCE";var Fy;let Tn=class extends dr{constructor(t={}){super(t),this.idBlock.tagClass=1,this.idBlock.tagNumber=17}};Fy=Tn;he.Set=Fy;Tn.NAME="SET";class Ly extends wn(sr){constructor({...t}={}){super(t),this.isHexOnly=!0,this.value=lr}toJSON(){return{...super.toJSON(),value:this.value}}}Ly.NAME="StringValueBlock";class Hy extends Ly{}Hy.NAME="SimpleStringValueBlock";class Cr extends fh{constructor({...t}={}){super(t,Hy)}fromBuffer(t){this.valueBlock.value=String.fromCharCode.apply(null,Me.toUint8Array(t))}fromString(t){const n=t.length,i=this.valueBlock.valueHexView=new Uint8Array(n);for(let o=0;o<n;o++)i[o]=t.charCodeAt(o);this.valueBlock.value=t}}Cr.NAME="SIMPLE STRING";class $y extends Cr{fromBuffer(t){this.valueBlock.valueHexView=Me.toUint8Array(t);try{this.valueBlock.value=At.ToUtf8String(t)}catch(n){this.warnings.push(`Error during "decodeURIComponent": ${n}, using raw string`),this.valueBlock.value=At.ToBinary(t)}}fromString(t){this.valueBlock.valueHexView=new Uint8Array(At.FromUtf8String(t)),this.valueBlock.value=t}}$y.NAME="Utf8StringValueBlock";var Vy;class Fn extends $y{constructor(t={}){super(t),this.idBlock.tagClass=1,this.idBlock.tagNumber=12}}Vy=Fn;he.Utf8String=Vy;Fn.NAME="UTF8String";class jy extends Cr{fromBuffer(t){this.valueBlock.value=At.ToUtf16String(t),this.valueBlock.valueHexView=Me.toUint8Array(t)}fromString(t){this.valueBlock.value=t,this.valueBlock.valueHexView=new Uint8Array(At.FromUtf16String(t))}}jy.NAME="BmpStringValueBlock";var Ky;class bc extends jy{constructor({...t}={}){super(t),this.idBlock.tagClass=1,this.idBlock.tagNumber=30}}Ky=bc;he.BmpString=Ky;bc.NAME="BMPString";class zy extends Cr{fromBuffer(t){const n=ArrayBuffer.isView(t)?t.slice().buffer:t.slice(0),i=new Uint8Array(n);for(let o=0;o<i.length;o+=4)i[o]=i[o+3],i[o+1]=i[o+2],i[o+2]=0,i[o+3]=0;this.valueBlock.value=String.fromCharCode.apply(null,new Uint32Array(n))}fromString(t){const n=t.length,i=this.valueBlock.valueHexView=new Uint8Array(n*4);for(let o=0;o<n;o++){const s=qi(t.charCodeAt(o),8),a=new Uint8Array(s);if(a.length>4)continue;const c=4-a.length;for(let f=a.length-1;f>=0;f--)i[o*4+f+c]=a[f]}this.valueBlock.value=t}}zy.NAME="UniversalStringValueBlock";var qy;class vc extends zy{constructor({...t}={}){super(t),this.idBlock.tagClass=1,this.idBlock.tagNumber=28}}qy=vc;he.UniversalString=qy;vc.NAME="UniversalString";var Gy;class xc extends Cr{constructor(t={}){super(t),this.idBlock.tagClass=1,this.idBlock.tagNumber=18}}Gy=xc;he.NumericString=Gy;xc.NAME="NumericString";var Wy;class Ac extends Cr{constructor(t={}){super(t),this.idBlock.tagClass=1,this.idBlock.tagNumber=19}}Wy=Ac;he.PrintableString=Wy;Ac.NAME="PrintableString";var Jy;class Ec extends Cr{constructor(t={}){super(t),this.idBlock.tagClass=1,this.idBlock.tagNumber=20}}Jy=Ec;he.TeletexString=Jy;Ec.NAME="TeletexString";var Yy;class Sc extends Cr{constructor(t={}){super(t),this.idBlock.tagClass=1,this.idBlock.tagNumber=21}}Yy=Sc;he.VideotexString=Yy;Sc.NAME="VideotexString";var Zy;class Bc extends Cr{constructor(t={}){super(t),this.idBlock.tagClass=1,this.idBlock.tagNumber=22}}Zy=Bc;he.IA5String=Zy;Bc.NAME="IA5String";var Xy;class Dc extends Cr{constructor(t={}){super(t),this.idBlock.tagClass=1,this.idBlock.tagNumber=25}}Xy=Dc;he.GraphicString=Xy;Dc.NAME="GraphicString";var Qy;class Rs extends Cr{constructor(t={}){super(t),this.idBlock.tagClass=1,this.idBlock.tagNumber=26}}Qy=Rs;he.VisibleString=Qy;Rs.NAME="VisibleString";var ew;class Cc extends Cr{constructor(t={}){super(t),this.idBlock.tagClass=1,this.idBlock.tagNumber=27}}ew=Cc;he.GeneralString=ew;Cc.NAME="GeneralString";var tw;class Ic extends Cr{constructor(t={}){super(t),this.idBlock.tagClass=1,this.idBlock.tagNumber=29}}tw=Ic;he.CharacterString=tw;Ic.NAME="CharacterString";var rw;class Us extends Rs{constructor({value:t,valueDate:n,...i}={}){if(super(i),this.year=0,this.month=0,this.day=0,this.hour=0,this.minute=0,this.second=0,t){this.fromString(t),this.valueBlock.valueHexView=new Uint8Array(t.length);for(let o=0;o<t.length;o++)this.valueBlock.valueHexView[o]=t.charCodeAt(o)}n&&(this.fromDate(n),this.valueBlock.valueHexView=new Uint8Array(this.toBuffer())),this.idBlock.tagClass=1,this.idBlock.tagNumber=23}fromBuffer(t){this.fromString(String.fromCharCode.apply(null,Me.toUint8Array(t)))}toBuffer(){const t=this.toString(),n=new ArrayBuffer(t.length),i=new Uint8Array(n);for(let o=0;o<t.length;o++)i[o]=t.charCodeAt(o);return n}fromDate(t){this.year=t.getUTCFullYear(),this.month=t.getUTCMonth()+1,this.day=t.getUTCDate(),this.hour=t.getUTCHours(),this.minute=t.getUTCMinutes(),this.second=t.getUTCSeconds()}toDate(){return new Date(Date.UTC(this.year,this.month-1,this.day,this.hour,this.minute,this.second))}fromString(t){const i=/(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})Z/ig.exec(t);if(i===null){this.error="Wrong input string for conversion";return}const o=parseInt(i[1],10);o>=50?this.year=1900+o:this.year=2e3+o,this.month=parseInt(i[2],10),this.day=parseInt(i[3],10),this.hour=parseInt(i[4],10),this.minute=parseInt(i[5],10),this.second=parseInt(i[6],10)}toString(t="iso"){if(t==="iso"){const n=new Array(7);return n[0]=xr(this.year<2e3?this.year-1900:this.year-2e3,2),n[1]=xr(this.month,2),n[2]=xr(this.day,2),n[3]=xr(this.hour,2),n[4]=xr(this.minute,2),n[5]=xr(this.second,2),n[6]="Z",n.join("")}return super.toString(t)}onAsciiEncoding(){return`${this.constructor.NAME} : ${this.toDate().toISOString()}`}toJSON(){return{...super.toJSON(),year:this.year,month:this.month,day:this.day,hour:this.hour,minute:this.minute,second:this.second}}}rw=Us;he.UTCTime=rw;Us.NAME="UTCTime";var nw;class _c extends Us{constructor(t={}){var n;super(t),(n=this.millisecond)!==null&&n!==void 0||(this.millisecond=0),this.idBlock.tagClass=1,this.idBlock.tagNumber=24}fromDate(t){super.fromDate(t),this.millisecond=t.getUTCMilliseconds()}toDate(){return new Date(Date.UTC(this.year,this.month-1,this.day,this.hour,this.minute,this.second,this.millisecond))}fromString(t){let n=!1,i="",o="",s=0,a,c=0,f=0;if(t[t.length-1]==="Z")i=t.substring(0,t.length-1),n=!0;else{const g=new Number(t[t.length-1]);if(isNaN(g.valueOf()))throw new Error("Wrong input string for conversion");i=t}if(n){if(i.indexOf("+")!==-1)throw new Error("Wrong input string for conversion");if(i.indexOf("-")!==-1)throw new Error("Wrong input string for conversion")}else{let g=1,x=i.indexOf("+"),S="";if(x===-1&&(x=i.indexOf("-"),g=-1),x!==-1){if(S=i.substring(x+1),i=i.substring(0,x),S.length!==2&&S.length!==4)throw new Error("Wrong input string for conversion");let D=parseInt(S.substring(0,2),10);if(isNaN(D.valueOf()))throw new Error("Wrong input string for conversion");if(c=g*D,S.length===4){if(D=parseInt(S.substring(2,4),10),isNaN(D.valueOf()))throw new Error("Wrong input string for conversion");f=g*D}}}let h=i.indexOf(".");if(h===-1&&(h=i.indexOf(",")),h!==-1){const g=new Number(`0${i.substring(h)}`);if(isNaN(g.valueOf()))throw new Error("Wrong input string for conversion");s=g.valueOf(),o=i.substring(0,h)}else o=i;switch(!0){case o.length===8:if(a=/(\d{4})(\d{2})(\d{2})/ig,h!==-1)throw new Error("Wrong input string for conversion");break;case o.length===10:if(a=/(\d{4})(\d{2})(\d{2})(\d{2})/ig,h!==-1){let g=60*s;this.minute=Math.floor(g),g=60*(g-this.minute),this.second=Math.floor(g),g=1e3*(g-this.second),this.millisecond=Math.floor(g)}break;case o.length===12:if(a=/(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})/ig,h!==-1){let g=60*s;this.second=Math.floor(g),g=1e3*(g-this.second),this.millisecond=Math.floor(g)}break;case o.length===14:if(a=/(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})/ig,h!==-1){const g=1e3*s;this.millisecond=Math.floor(g)}break;default:throw new Error("Wrong input string for conversion")}const d=a.exec(o);if(d===null)throw new Error("Wrong input string for conversion");for(let g=1;g<d.length;g++)switch(g){case 1:this.year=parseInt(d[g],10);break;case 2:this.month=parseInt(d[g],10);break;case 3:this.day=parseInt(d[g],10);break;case 4:this.hour=parseInt(d[g],10)+c;break;case 5:this.minute=parseInt(d[g],10)+f;break;case 6:this.second=parseInt(d[g],10);break;default:throw new Error("Wrong input string for conversion")}if(n===!1){const g=new Date(this.year,this.month,this.day,this.hour,this.minute,this.second,this.millisecond);this.year=g.getUTCFullYear(),this.month=g.getUTCMonth(),this.day=g.getUTCDay(),this.hour=g.getUTCHours(),this.minute=g.getUTCMinutes(),this.second=g.getUTCSeconds(),this.millisecond=g.getUTCMilliseconds()}}toString(t="iso"){if(t==="iso"){const n=[];return n.push(xr(this.year,4)),n.push(xr(this.month,2)),n.push(xr(this.day,2)),n.push(xr(this.hour,2)),n.push(xr(this.minute,2)),n.push(xr(this.second,2)),this.millisecond!==0&&(n.push("."),n.push(xr(this.millisecond,3))),n.push("Z"),n.join("")}return super.toString(t)}toJSON(){return{...super.toJSON(),millisecond:this.millisecond}}}nw=_c;he.GeneralizedTime=nw;_c.NAME="GeneralizedTime";var iw;class dh extends Fn{constructor(t={}){super(t),this.idBlock.tagClass=1,this.idBlock.tagNumber=31}}iw=dh;he.DATE=iw;dh.NAME="DATE";var ow;class ph extends Fn{constructor(t={}){super(t),this.idBlock.tagClass=1,this.idBlock.tagNumber=32}}ow=ph;he.TimeOfDay=ow;ph.NAME="TimeOfDay";var sw;class gh extends Fn{constructor(t={}){super(t),this.idBlock.tagClass=1,this.idBlock.tagNumber=33}}sw=gh;he.DateTime=sw;gh.NAME="DateTime";var aw;class yh extends Fn{constructor(t={}){super(t),this.idBlock.tagClass=1,this.idBlock.tagNumber=34}}aw=yh;he.Duration=aw;yh.NAME="Duration";var cw;class wh extends Fn{constructor(t={}){super(t),this.idBlock.tagClass=1,this.idBlock.tagNumber=14}}cw=wh;he.TIME=cw;wh.NAME="TIME";class Wi{constructor({name:t=lr,optional:n=!1}={}){this.name=t,this.optional=n}}class mh extends Wi{constructor({value:t=[],...n}={}){super(n),this.value=t}}class La extends Wi{constructor({value:t=new Wi,local:n=!1,...i}={}){super(i),this.value=t,this.local=n}}class fS{constructor({data:t=gc}={}){this.dataView=Me.toUint8Array(t)}get data(){return this.dataView.slice().buffer}set data(t){this.dataView=Me.toUint8Array(t)}fromBER(t,n,i){const o=n+i;return this.dataView=Me.toUint8Array(t).subarray(n,o),o}toBER(t){return this.dataView.slice().buffer}}function Ri(r,t,n){if(n instanceof mh){for(let s=0;s<n.value.length;s++)if(Ri(r,t,n.value[s]).verified)return{verified:!0,result:r};{const s={verified:!1,result:{error:"Wrong values for Choice type"}};return n.hasOwnProperty(Yf)&&(s.name=n.name),s}}if(n instanceof Wi)return n.hasOwnProperty(Yf)&&(r[n.name]=t),{verified:!0,result:r};if(!(r instanceof Object))return{verified:!1,result:{error:"Wrong root object"}};if(!(t instanceof Object))return{verified:!1,result:{error:"Wrong ASN.1 data"}};if(!(n instanceof Object))return{verified:!1,result:{error:"Wrong ASN.1 schema"}};if(!(XE in n))return{verified:!1,result:{error:"Wrong ASN.1 schema"}};if(!(rS in n.idBlock))return{verified:!1,result:{error:"Wrong ASN.1 schema"}};if(!(nS in n.idBlock))return{verified:!1,result:{error:"Wrong ASN.1 schema"}};const i=n.idBlock.toBER(!1);if(i.byteLength===0)return{verified:!1,result:{error:"Error encoding idBlock for ASN.1 schema"}};if(n.idBlock.fromBER(i,0,i.byteLength)===-1)return{verified:!1,result:{error:"Error decoding idBlock for ASN.1 schema"}};if(n.idBlock.hasOwnProperty(QE)===!1)return{verified:!1,result:{error:"Wrong ASN.1 schema"}};if(n.idBlock.tagClass!==t.idBlock.tagClass)return{verified:!1,result:r};if(n.idBlock.hasOwnProperty(eS)===!1)return{verified:!1,result:{error:"Wrong ASN.1 schema"}};if(n.idBlock.tagNumber!==t.idBlock.tagNumber)return{verified:!1,result:r};if(n.idBlock.hasOwnProperty(tS)===!1)return{verified:!1,result:{error:"Wrong ASN.1 schema"}};if(n.idBlock.isConstructed!==t.idBlock.isConstructed)return{verified:!1,result:r};if(!(ZE in n.idBlock))return{verified:!1,result:{error:"Wrong ASN.1 schema"}};if(n.idBlock.isHexOnly!==t.idBlock.isHexOnly)return{verified:!1,result:r};if(n.idBlock.isHexOnly){if(!(j0 in n.idBlock))return{verified:!1,result:{error:"Wrong ASN.1 schema"}};const s=n.idBlock.valueHexView,a=t.idBlock.valueHexView;if(s.length!==a.length)return{verified:!1,result:r};for(let c=0;c<s.length;c++)if(s[c]!==a[1])return{verified:!1,result:r}}if(n.name&&(n.name=n.name.replace(/^\s+|\s+$/g,lr),n.name&&(r[n.name]=t)),n instanceof he.Constructed){let s=0,a={verified:!1,result:{error:"Unknown error"}},c=n.valueBlock.value.length;if(c>0&&n.valueBlock.value[0]instanceof La&&(c=t.valueBlock.value.length),c===0)return{verified:!0,result:r};if(t.valueBlock.value.length===0&&n.valueBlock.value.length!==0){let f=!0;for(let h=0;h<n.valueBlock.value.length;h++)f=f&&(n.valueBlock.value[h].optional||!1);return f?{verified:!0,result:r}:(n.name&&(n.name=n.name.replace(/^\s+|\s+$/g,lr),n.name&&delete r[n.name]),r.error="Inconsistent object length",{verified:!1,result:r})}for(let f=0;f<c;f++)if(f-s>=t.valueBlock.value.length){if(n.valueBlock.value[f].optional===!1){const h={verified:!1,result:r};return r.error="Inconsistent length between ASN.1 data and schema",n.name&&(n.name=n.name.replace(/^\s+|\s+$/g,lr),n.name&&(delete r[n.name],h.name=n.name)),h}}else if(n.valueBlock.value[0]instanceof La){if(a=Ri(r,t.valueBlock.value[f],n.valueBlock.value[0].value),a.verified===!1)if(n.valueBlock.value[0].optional)s++;else return n.name&&(n.name=n.name.replace(/^\s+|\s+$/g,lr),n.name&&delete r[n.name]),a;if(Yf in n.valueBlock.value[0]&&n.valueBlock.value[0].name.length>0){let h={};iS in n.valueBlock.value[0]&&n.valueBlock.value[0].local?h=t:h=r,typeof h[n.valueBlock.value[0].name]>"u"&&(h[n.valueBlock.value[0].name]=[]),h[n.valueBlock.value[0].name].push(t.valueBlock.value[f])}}else if(a=Ri(r,t.valueBlock.value[f-s],n.valueBlock.value[f]),a.verified===!1)if(n.valueBlock.value[f].optional)s++;else return n.name&&(n.name=n.name.replace(/^\s+|\s+$/g,lr),n.name&&delete r[n.name]),a;if(a.verified===!1){const f={verified:!1,result:r};return n.name&&(n.name=n.name.replace(/^\s+|\s+$/g,lr),n.name&&(delete r[n.name],f.name=n.name)),f}return{verified:!0,result:r}}if(n.primitiveSchema&&j0 in t.valueBlock){const s=Uo(t.valueBlock.valueHexView);if(s.offset===-1){const a={verified:!1,result:s.result};return n.name&&(n.name=n.name.replace(/^\s+|\s+$/g,lr),n.name&&(delete r[n.name],a.name=n.name)),a}return Ri(r,s.result,n.primitiveSchema)}return{verified:!0,result:r}}function uS(r,t){if(!(t instanceof Object))return{verified:!1,result:{error:"Wrong ASN.1 schema type"}};const n=Uo(Me.toUint8Array(r));return n.offset===-1?{verified:!1,result:n.result}:Ri(n.result,n.result,t)}const fw=Object.freeze(Object.defineProperty({__proto__:null,Any:Wi,BaseBlock:zt,BaseStringBlock:fh,BitString:Hi,BmpString:bc,Boolean:yc,CharacterString:Ic,Choice:mh,Constructed:dr,DATE:dh,DateTime:gh,Duration:yh,EndOfContent:uh,Enumerated:wc,GeneralString:Cc,GeneralizedTime:_c,GraphicString:Dc,HexBlock:wn,IA5String:Bc,Integer:dn,Null:Gi,NumericString:xc,ObjectIdentifier:mc,OctetString:Li,Primitive:Ns,PrintableString:Ac,RawData:fS,RelativeObjectIdentifier:hh,Repeated:La,Sequence:kn,Set:Tn,TIME:wh,TeletexString:Ec,TimeOfDay:ph,UTCTime:Us,UniversalString:vc,Utf8String:Fn,ValueBlock:sr,VideotexString:Sc,ViewWriter:pc,VisibleString:Rs,compareSchema:Ri,fromBER:ho,verifySchema:uS},Symbol.toStringTag,{value:"Module"}));var xe;(function(r){r[r.Sequence=0]="Sequence",r[r.Set=1]="Set",r[r.Choice=2]="Choice"})(xe||(xe={}));var W;(function(r){r[r.Any=1]="Any",r[r.Boolean=2]="Boolean",r[r.OctetString=3]="OctetString",r[r.BitString=4]="BitString",r[r.Integer=5]="Integer",r[r.Enumerated=6]="Enumerated",r[r.ObjectIdentifier=7]="ObjectIdentifier",r[r.Utf8String=8]="Utf8String",r[r.BmpString=9]="BmpString",r[r.UniversalString=10]="UniversalString",r[r.NumericString=11]="NumericString",r[r.PrintableString=12]="PrintableString",r[r.TeletexString=13]="TeletexString",r[r.VideotexString=14]="VideotexString",r[r.IA5String=15]="IA5String",r[r.GraphicString=16]="GraphicString",r[r.VisibleString=17]="VisibleString",r[r.GeneralString=18]="GeneralString",r[r.CharacterString=19]="CharacterString",r[r.UTCTime=20]="UTCTime",r[r.GeneralizedTime=21]="GeneralizedTime",r[r.DATE=22]="DATE",r[r.TimeOfDay=23]="TimeOfDay",r[r.DateTime=24]="DateTime",r[r.Duration=25]="Duration",r[r.TIME=26]="TIME",r[r.Null=27]="Null"})(W||(W={}));class uw{constructor(t,n=0){if(this.unusedBits=0,this.value=new ArrayBuffer(0),t)if(typeof t=="number")this.fromNumber(t);else if(Me.isBufferSource(t))this.unusedBits=n,this.value=Me.toArrayBuffer(t);else throw TypeError("Unsupported type of 'params' argument for BitString")}fromASN(t){if(!(t instanceof Hi))throw new TypeError("Argument 'asn' is not instance of ASN.1 BitString");return this.unusedBits=t.valueBlock.unusedBits,this.value=t.valueBlock.valueHex,this}toASN(){return new Hi({unusedBits:this.unusedBits,valueHex:this.value})}toSchema(t){return new Hi({name:t})}toNumber(){let t="";const n=new Uint8Array(this.value);for(const i of n)t+=i.toString(2).padStart(8,"0");return t=t.split("").reverse().join(""),this.unusedBits&&(t=t.slice(this.unusedBits).padStart(this.unusedBits,"0")),parseInt(t,2)}fromNumber(t){let n=t.toString(2);const i=n.length+7>>3;this.unusedBits=(i<<3)-n.length;const o=new Uint8Array(i);n=n.padStart(i<<3,"0").split("").reverse().join("");let s=0;for(;s<i;)o[s]=parseInt(n.slice(s<<3,(s<<3)+8),2),s++;this.value=o.buffer}}class Ge{get byteLength(){return this.buffer.byteLength}get byteOffset(){return 0}constructor(t){typeof t=="number"?this.buffer=new ArrayBuffer(t):Me.isBufferSource(t)?this.buffer=Me.toArrayBuffer(t):Array.isArray(t)?this.buffer=new Uint8Array(t):this.buffer=new ArrayBuffer(0)}fromASN(t){if(!(t instanceof Li))throw new TypeError("Argument 'asn' is not instance of ASN.1 OctetString");return this.buffer=t.valueBlock.valueHex,this}toASN(){return new Li({valueHex:this.buffer})}toSchema(t){return new Li({name:t})}}const lS={fromASN:r=>r instanceof Gi?null:r.valueBeforeDecodeView,toASN:r=>{if(r===null)return new Gi;const t=ho(r);if(t.result.error)throw new Error(t.result.error);return t.result}},hS={fromASN:r=>r.valueBlock.valueHexView.byteLength>=4?r.valueBlock.toString():r.valueBlock.valueDec,toASN:r=>new dn({value:+r})},dS={fromASN:r=>r.valueBlock.valueDec,toASN:r=>new wc({value:r})},Dt={fromASN:r=>r.valueBlock.valueHexView,toASN:r=>new dn({valueHex:r})},pS={fromASN:r=>r.valueBlock.valueHexView,toASN:r=>new Hi({valueHex:r})},gS={fromASN:r=>r.valueBlock.toString(),toASN:r=>new mc({value:r})},yS={fromASN:r=>r.valueBlock.value,toASN:r=>new yc({value:r})},Ha={fromASN:r=>r.valueBlock.valueHexView,toASN:r=>new Li({valueHex:r})};function Fr(r){return{fromASN:t=>t.valueBlock.value,toASN:t=>new r({value:t})}}const wS=Fr(Fn),mS=Fr(bc),bS=Fr(vc),vS=Fr(xc),xS=Fr(Ac),AS=Fr(Ec),ES=Fr(Sc),SS=Fr(Bc),BS=Fr(Dc),DS=Fr(Rs),CS=Fr(Cc),IS=Fr(Ic),_S={fromASN:r=>r.toDate(),toASN:r=>new Us({valueDate:r})},MS={fromASN:r=>r.toDate(),toASN:r=>new _c({valueDate:r})},kS={fromASN:()=>null,toASN:()=>new Gi};function bh(r){switch(r){case W.Any:return lS;case W.BitString:return pS;case W.BmpString:return mS;case W.Boolean:return yS;case W.CharacterString:return IS;case W.Enumerated:return dS;case W.GeneralString:return CS;case W.GeneralizedTime:return MS;case W.GraphicString:return BS;case W.IA5String:return SS;case W.Integer:return hS;case W.Null:return kS;case W.NumericString:return vS;case W.ObjectIdentifier:return gS;case W.OctetString:return Ha;case W.PrintableString:return xS;case W.TeletexString:return AS;case W.UTCTime:return _S;case W.UniversalString:return bS;case W.Utf8String:return wS;case W.VideotexString:return ES;case W.VisibleString:return DS;default:return null}}function In(r){return typeof r=="function"&&r.prototype?r.prototype.toASN&&r.prototype.fromASN?!0:In(r.prototype):!!(r&&typeof r=="object"&&"toASN"in r&&"fromASN"in r)}function lw(r){var t;if(r){const n=Object.getPrototypeOf(r);return((t=n==null?void 0:n.prototype)===null||t===void 0?void 0:t.constructor)===Array?!0:lw(n)}return!1}function TS(r,t){if(!(r&&t)||r.byteLength!==t.byteLength)return!1;const n=new Uint8Array(r),i=new Uint8Array(t);for(let o=0;o<r.byteLength;o++)if(n[o]!==i[o])return!1;return!0}class NS{constructor(){this.items=new WeakMap}has(t){return this.items.has(t)}get(t,n=!1){const i=this.items.get(t);if(!i)throw new Error(`Cannot get schema for '${t.prototype.constructor.name}' target`);if(n&&!i.schema)throw new Error(`Schema '${t.prototype.constructor.name}' doesn't contain ASN.1 schema. Call 'AsnSchemaStorage.cache'.`);return i}cache(t){const n=this.get(t);n.schema||(n.schema=this.create(t,!0))}createDefault(t){const n={type:xe.Sequence,items:{}},i=this.findParentSchema(t);return i&&(Object.assign(n,i),n.items=Object.assign({},n.items,i.items)),n}create(t,n){const i=this.items.get(t)||this.createDefault(t),o=[];for(const s in i.items){const a=i.items[s],c=n?s:"";let f;if(typeof a.type=="number"){const d=W[a.type],g=fw[d];if(!g)throw new Error(`Cannot get ASN1 class by name '${d}'`);f=new g({name:c})}else In(a.type)?f=new a.type().toSchema(c):a.optional?this.get(a.type).type===xe.Choice?f=new Wi({name:c}):(f=this.create(a.type,!1),f.name=c):f=new Wi({name:c});const h=!!a.optional||a.defaultValue!==void 0;if(a.repeated){f.name="";const d=a.repeated==="set"?Tn:kn;f=new d({name:"",value:[new La({name:c,value:f})]})}if(a.context!==null&&a.context!==void 0)if(a.implicit)if(typeof a.type=="number"||In(a.type)){const d=a.repeated?dr:Ns;o.push(new d({name:c,optional:h,idBlock:{tagClass:3,tagNumber:a.context}}))}else{this.cache(a.type);const d=!!a.repeated;let g=d?f:this.get(a.type,!0).schema;g="valueBlock"in g?g.valueBlock.value:g.value,o.push(new dr({name:d?"":c,optional:h,idBlock:{tagClass:3,tagNumber:a.context},value:g}))}else o.push(new dr({optional:h,idBlock:{tagClass:3,tagNumber:a.context},value:[f]}));else f.optional=h,o.push(f)}switch(i.type){case xe.Sequence:return new kn({value:o,name:""});case xe.Set:return new Tn({value:o,name:""});case xe.Choice:return new mh({value:o,name:""});default:throw new Error("Unsupported ASN1 type in use")}}set(t,n){return this.items.set(t,n),this}findParentSchema(t){const n=Object.getPrototypeOf(t);return n?this.items.get(n)||this.findParentSchema(n):null}}const Tr=new NS,ke=r=>t=>{let n;Tr.has(t)?n=Tr.get(t):(n=Tr.createDefault(t),Tr.set(t,n)),Object.assign(n,r)},L=r=>(t,n)=>{let i;Tr.has(t.constructor)?i=Tr.get(t.constructor):(i=Tr.createDefault(t.constructor),Tr.set(t.constructor,i));const o=Object.assign({},r);if(typeof o.type=="number"&&!o.converter){const s=bh(r.type);if(!s)throw new Error(`Cannot get default converter for property '${n}' of ${t.constructor.name}`);o.converter=s}i.items[n]=o};class z0 extends Error{constructor(){super(...arguments),this.schemas=[]}}class $t{static parse(t,n){const i=ho(t);if(i.result.error)throw new Error(i.result.error);return this.fromASN(i.result,n)}static fromASN(t,n){var i;try{if(In(n))return new n().fromASN(t);const o=Tr.get(n);Tr.cache(n);let s=o.schema;if(t.constructor===dr&&o.type!==xe.Choice){s=new dr({idBlock:{tagClass:3,tagNumber:t.idBlock.tagNumber},value:o.schema.valueBlock.value});for(const f in o.items)delete t[f]}const a=Ri({},t,s);if(!a.verified)throw new z0(`Data does not match to ${n.name} ASN1 schema. ${a.result.error}`);const c=new n;if(lw(n)){if(!("value"in t.valueBlock&&Array.isArray(t.valueBlock.value)))throw new Error("Cannot get items from the ASN.1 parsed value. ASN.1 object is not constructed.");const f=o.itemType;if(typeof f=="number"){const h=bh(f);if(!h)throw new Error(`Cannot get default converter for array item of ${n.name} ASN1 schema`);return n.from(t.valueBlock.value,d=>h.fromASN(d))}else return n.from(t.valueBlock.value,h=>this.fromASN(h,f))}for(const f in o.items){const h=a.result[f];if(!h)continue;const d=o.items[f],g=d.type;if(typeof g=="number"||In(g)){const x=(i=d.converter)!==null&&i!==void 0?i:In(g)?new g:null;if(!x)throw new Error("Converter is empty");if(d.repeated)if(d.implicit){const S=d.repeated==="sequence"?kn:Tn,D=new S;D.valueBlock=h.valueBlock;const E=ho(D.toBER(!1));if(E.offset===-1)throw new Error(`Cannot parse the child item. ${E.result.error}`);if(!("value"in E.result.valueBlock&&Array.isArray(E.result.valueBlock.value)))throw new Error("Cannot get items from the ASN.1 parsed value. ASN.1 object is not constructed.");const _=E.result.valueBlock.value;c[f]=Array.from(_,T=>x.fromASN(T))}else c[f]=Array.from(h,S=>x.fromASN(S));else{let S=h;if(d.implicit){let D;if(In(g))D=new g().toSchema("");else{const E=W[g],_=fw[E];if(!_)throw new Error(`Cannot get '${E}' class from asn1js module`);D=new _}D.valueBlock=S.valueBlock,S=ho(D.toBER(!1)).result}c[f]=x.fromASN(S)}}else if(d.repeated){if(!Array.isArray(h))throw new Error("Cannot get list of items from the ASN.1 parsed value. ASN.1 value should be iterable.");c[f]=Array.from(h,x=>this.fromASN(x,g))}else c[f]=this.fromASN(h,g)}return c}catch(o){throw o instanceof z0&&o.schemas.push(n.name),o}}}class Mc{static serialize(t){return t instanceof zt?t.toBER(!1):this.toASN(t).toBER(!1)}static toASN(t){if(t&&typeof t=="object"&&In(t))return t.toASN();if(!(t&&typeof t=="object"))throw new TypeError("Parameter 1 should be type of Object.");const n=t.constructor,i=Tr.get(n);Tr.cache(n);let o=[];if(i.itemType){if(!Array.isArray(t))throw new TypeError("Parameter 1 should be type of Array.");if(typeof i.itemType=="number"){const a=bh(i.itemType);if(!a)throw new Error(`Cannot get default converter for array item of ${n.name} ASN1 schema`);o=t.map(c=>a.toASN(c))}else o=t.map(a=>this.toAsnItem({type:i.itemType},"[]",n,a))}else for(const a in i.items){const c=i.items[a],f=t[a];if(f===void 0||c.defaultValue===f||typeof c.defaultValue=="object"&&typeof f=="object"&&TS(this.serialize(c.defaultValue),this.serialize(f)))continue;const h=Mc.toAsnItem(c,a,n,f);if(typeof c.context=="number")if(c.implicit)if(!c.repeated&&(typeof c.type=="number"||In(c.type))){const d={};d.valueHex=h instanceof Gi?h.valueBeforeDecodeView:h.valueBlock.toBER(),o.push(new Ns({optional:c.optional,idBlock:{tagClass:3,tagNumber:c.context},...d}))}else o.push(new dr({optional:c.optional,idBlock:{tagClass:3,tagNumber:c.context},value:h.valueBlock.value}));else o.push(new dr({optional:c.optional,idBlock:{tagClass:3,tagNumber:c.context},value:[h]}));else c.repeated?o=o.concat(h):o.push(h)}let s;switch(i.type){case xe.Sequence:s=new kn({value:o});break;case xe.Set:s=new Tn({value:o});break;case xe.Choice:if(!o[0])throw new Error(`Schema '${n.name}' has wrong data. Choice cannot be empty.`);s=o[0];break}return s}static toAsnItem(t,n,i,o){let s;if(typeof t.type=="number"){const a=t.converter;if(!a)throw new Error(`Property '${n}' doesn't have converter for type ${W[t.type]} in schema '${i.name}'`);if(t.repeated){if(!Array.isArray(o))throw new TypeError("Parameter 'objProp' should be type of Array.");const c=Array.from(o,h=>a.toASN(h)),f=t.repeated==="sequence"?kn:Tn;s=new f({value:c})}else s=a.toASN(o)}else if(t.repeated){if(!Array.isArray(o))throw new TypeError("Parameter 'objProp' should be type of Array.");const a=Array.from(o,f=>this.toASN(f)),c=t.repeated==="sequence"?kn:Tn;s=new c({value:a})}else s=this.toASN(o);return s}}class ar extends Array{constructor(t=[]){if(typeof t=="number")super(t);else{super();for(const n of t)this.push(n)}}}class yi{static serialize(t){return Mc.serialize(t)}static parse(t,n){return $t.parse(t,n)}static toString(t){const n=Me.isBufferSource(t)?Me.toArrayBuffer(t):yi.serialize(t),i=ho(n);if(i.offset===-1)throw new Error(`Cannot decode ASN.1 data. ${i.result.error}`);return i.result.toString()}}function O(r,t,n,i){var o=arguments.length,s=o<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,n):i,a;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(r,t,n,i);else for(var c=r.length-1;c>=0;c--)(a=r[c])&&(s=(o<3?a(s):o>3?a(t,n,s):a(t,n))||s);return o>3&&s&&Object.defineProperty(t,n,s),s}class q0{static isIPv4(t){return/^(\d{1,3}\.){3}\d{1,3}$/.test(t)}static parseIPv4(t){const n=t.split(".");if(n.length!==4)throw new Error("Invalid IPv4 address");return n.map(i=>{const o=parseInt(i,10);if(isNaN(o)||o<0||o>255)throw new Error("Invalid IPv4 address part");return o})}static parseIPv6(t){const i=this.expandIPv6(t).split(":");if(i.length!==8)throw new Error("Invalid IPv6 address");return i.reduce((o,s)=>{const a=parseInt(s,16);if(isNaN(a)||a<0||a>65535)throw new Error("Invalid IPv6 address part");return o.push(a>>8&255),o.push(a&255),o},[])}static expandIPv6(t){if(!t.includes("::"))return t;const n=t.split("::");if(n.length>2)throw new Error("Invalid IPv6 address");const i=n[0]?n[0].split(":"):[],o=n[1]?n[1].split(":"):[],s=8-(i.length+o.length);if(s<0)throw new Error("Invalid IPv6 address");return[...i,...Array(s).fill("0"),...o].join(":")}static formatIPv6(t){const n=[];for(let i=0;i<16;i+=2)n.push((t[i]<<8|t[i+1]).toString(16));return this.compressIPv6(n.join(":"))}static compressIPv6(t){const n=t.split(":");let i=-1,o=0,s=-1,a=0;for(let c=0;c<n.length;c++)n[c]==="0"?(s===-1&&(s=c),a++):(a>o&&(i=s,o=a),s=-1,a=0);if(a>o&&(i=s,o=a),o>1){const c=n.slice(0,i).join(":"),f=n.slice(i+o).join(":");return`${c}::${f}`}return t}static parseCIDR(t){const[n,i]=t.split("/"),o=parseInt(i,10);if(this.isIPv4(n)){if(o<0||o>32)throw new Error("Invalid IPv4 prefix length");return[this.parseIPv4(n),o]}else{if(o<0||o>128)throw new Error("Invalid IPv6 prefix length");return[this.parseIPv6(n),o]}}static decodeIP(t){if(t.length===64&&parseInt(t,16)===0)return"::/0";if(t.length!==16)return t;const n=parseInt(t.slice(8),16).toString(2).split("").reduce((o,s)=>o+ +s,0);let i=t.slice(0,8).replace(/(.{2})/g,o=>`${parseInt(o,16)}.`);return i=i.slice(0,-1),`${i}/${n}`}static toString(t){const n=new Uint8Array(t);if(n.length===4)return Array.from(n).join(".");if(n.length===16)return this.formatIPv6(n);if(n.length===8||n.length===32){const i=n.length/2,o=n.slice(0,i),s=n.slice(i);if(n.every(f=>f===0))return n.length===8?"0.0.0.0/0":"::/0";const c=s.reduce((f,h)=>f+(h.toString(2).match(/1/g)||[]).length,0);return n.length===8?`${Array.from(o).join(".")}/${c}`:`${this.formatIPv6(o)}/${c}`}return this.decodeIP(At.ToHex(t))}static fromString(t){if(t.includes("/")){const[i,o]=this.parseCIDR(t),s=new Uint8Array(i.length);let a=o;for(let f=0;f<s.length;f++)a>=8?(s[f]=255,a-=8):a>0&&(s[f]=255<<8-a,a=0);const c=new Uint8Array(i.length*2);return c.set(i,0),c.set(s,i.length),c.buffer}const n=this.isIPv4(t)?this.parseIPv4(t):this.parseIPv6(t);return new Uint8Array(n).buffer}}var $u,Vu,ju;let Qr=class{constructor(t={}){Object.assign(this,t)}toString(){return this.bmpString||this.printableString||this.teletexString||this.universalString||this.utf8String||""}};O([L({type:W.TeletexString})],Qr.prototype,"teletexString",void 0);O([L({type:W.PrintableString})],Qr.prototype,"printableString",void 0);O([L({type:W.UniversalString})],Qr.prototype,"universalString",void 0);O([L({type:W.Utf8String})],Qr.prototype,"utf8String",void 0);O([L({type:W.BmpString})],Qr.prototype,"bmpString",void 0);Qr=O([ke({type:xe.Choice})],Qr);let Bo=class extends Qr{constructor(t={}){super(t),Object.assign(this,t)}toString(){return this.ia5String||(this.anyValue?At.ToHex(this.anyValue):super.toString())}};O([L({type:W.IA5String})],Bo.prototype,"ia5String",void 0);O([L({type:W.Any})],Bo.prototype,"anyValue",void 0);Bo=O([ke({type:xe.Choice})],Bo);class vh{constructor(t={}){this.type="",this.value=new Bo,Object.assign(this,t)}}O([L({type:W.ObjectIdentifier})],vh.prototype,"type",void 0);O([L({type:Bo})],vh.prototype,"value",void 0);let $a=$u=class extends ar{constructor(t){super(t),Object.setPrototypeOf(this,$u.prototype)}};$a=$u=O([ke({type:xe.Set,itemType:vh})],$a);let Ku=Vu=class extends ar{constructor(t){super(t),Object.setPrototypeOf(this,Vu.prototype)}};Ku=Vu=O([ke({type:xe.Sequence,itemType:$a})],Ku);let Rn=ju=class extends Ku{constructor(t){super(t),Object.setPrototypeOf(this,ju.prototype)}};Rn=ju=O([ke({type:xe.Sequence})],Rn);const RS={fromASN:r=>q0.toString(Ha.fromASN(r)),toASN:r=>Ha.toASN(q0.fromString(r))};class xh{constructor(t={}){this.typeId="",this.value=new ArrayBuffer(0),Object.assign(this,t)}}O([L({type:W.ObjectIdentifier})],xh.prototype,"typeId",void 0);O([L({type:W.Any,context:0})],xh.prototype,"value",void 0);class Ah{constructor(t={}){this.partyName=new Qr,Object.assign(this,t)}}O([L({type:Qr,optional:!0,context:0,implicit:!0})],Ah.prototype,"nameAssigner",void 0);O([L({type:Qr,context:1,implicit:!0})],Ah.prototype,"partyName",void 0);let Rt=class{constructor(t={}){Object.assign(this,t)}};O([L({type:xh,context:0,implicit:!0})],Rt.prototype,"otherName",void 0);O([L({type:W.IA5String,context:1,implicit:!0})],Rt.prototype,"rfc822Name",void 0);O([L({type:W.IA5String,context:2,implicit:!0})],Rt.prototype,"dNSName",void 0);O([L({type:W.Any,context:3,implicit:!0})],Rt.prototype,"x400Address",void 0);O([L({type:Rn,context:4,implicit:!1})],Rt.prototype,"directoryName",void 0);O([L({type:Ah,context:5})],Rt.prototype,"ediPartyName",void 0);O([L({type:W.IA5String,context:6,implicit:!0})],Rt.prototype,"uniformResourceIdentifier",void 0);O([L({type:W.OctetString,context:7,implicit:!0,converter:RS})],Rt.prototype,"iPAddress",void 0);O([L({type:W.ObjectIdentifier,context:8,implicit:!0})],Rt.prototype,"registeredID",void 0);Rt=O([ke({type:xe.Choice})],Rt);const Oo="2.5.29";var zu;class kc{constructor(t={}){this.accessMethod="",this.accessLocation=new Rt,Object.assign(this,t)}}O([L({type:W.ObjectIdentifier})],kc.prototype,"accessMethod",void 0);O([L({type:Rt})],kc.prototype,"accessLocation",void 0);let G0=zu=class extends ar{constructor(t){super(t),Object.setPrototypeOf(this,zu.prototype)}};G0=zu=O([ke({type:xe.Sequence,itemType:kc})],G0);const US=`${Oo}.35`;class hw extends Ge{}class Tc{constructor(t={}){t&&Object.assign(this,t)}}O([L({type:hw,context:0,optional:!0,implicit:!0})],Tc.prototype,"keyIdentifier",void 0);O([L({type:Rt,context:1,optional:!0,implicit:!0,repeated:"sequence"})],Tc.prototype,"authorityCertIssuer",void 0);O([L({type:W.Integer,context:2,optional:!0,implicit:!0,converter:Dt})],Tc.prototype,"authorityCertSerialNumber",void 0);const OS=`${Oo}.19`;class Eh{constructor(t={}){this.cA=!1,Object.assign(this,t)}}O([L({type:W.Boolean,defaultValue:!1})],Eh.prototype,"cA",void 0);O([L({type:W.Integer,optional:!0})],Eh.prototype,"pathLenConstraint",void 0);var qu;let gs=qu=class extends ar{constructor(t){super(t),Object.setPrototypeOf(this,qu.prototype)}};gs=qu=O([ke({type:xe.Sequence,itemType:Rt})],gs);var Gu;let W0=Gu=class extends gs{constructor(t){super(t),Object.setPrototypeOf(this,Gu.prototype)}};W0=Gu=O([ke({type:xe.Sequence})],W0);var Wu;let Un=class{constructor(t={}){Object.assign(this,t)}toString(){return this.ia5String||this.visibleString||this.bmpString||this.utf8String||""}};O([L({type:W.IA5String})],Un.prototype,"ia5String",void 0);O([L({type:W.VisibleString})],Un.prototype,"visibleString",void 0);O([L({type:W.BmpString})],Un.prototype,"bmpString",void 0);O([L({type:W.Utf8String})],Un.prototype,"utf8String",void 0);Un=O([ke({type:xe.Choice})],Un);class Sh{constructor(t={}){this.organization=new Un,this.noticeNumbers=[],Object.assign(this,t)}}O([L({type:Un})],Sh.prototype,"organization",void 0);O([L({type:W.Integer,repeated:"sequence"})],Sh.prototype,"noticeNumbers",void 0);class Bh{constructor(t={}){Object.assign(this,t)}}O([L({type:Sh,optional:!0})],Bh.prototype,"noticeRef",void 0);O([L({type:Un,optional:!0})],Bh.prototype,"explicitText",void 0);let Va=class{constructor(t={}){Object.assign(this,t)}};O([L({type:W.IA5String})],Va.prototype,"cPSuri",void 0);O([L({type:Bh})],Va.prototype,"userNotice",void 0);Va=O([ke({type:xe.Choice})],Va);class Dh{constructor(t={}){this.policyQualifierId="",this.qualifier=new ArrayBuffer(0),Object.assign(this,t)}}O([L({type:W.ObjectIdentifier})],Dh.prototype,"policyQualifierId",void 0);O([L({type:W.Any})],Dh.prototype,"qualifier",void 0);class Ch{constructor(t={}){this.policyIdentifier="",Object.assign(this,t)}}O([L({type:W.ObjectIdentifier})],Ch.prototype,"policyIdentifier",void 0);O([L({type:Dh,repeated:"sequence",optional:!0})],Ch.prototype,"policyQualifiers",void 0);let J0=Wu=class extends ar{constructor(t){super(t),Object.setPrototypeOf(this,Wu.prototype)}};J0=Wu=O([ke({type:xe.Sequence,itemType:Ch})],J0);let ja=class{constructor(t=0){this.value=t}};O([L({type:W.Integer})],ja.prototype,"value",void 0);ja=O([ke({type:xe.Choice})],ja);let Y0=class extends ja{};Y0=O([ke({type:xe.Choice})],Y0);var Ju;const PS=`${Oo}.31`;var Vr;(function(r){r[r.unused=1]="unused",r[r.keyCompromise=2]="keyCompromise",r[r.cACompromise=4]="cACompromise",r[r.affiliationChanged=8]="affiliationChanged",r[r.superseded=16]="superseded",r[r.cessationOfOperation=32]="cessationOfOperation",r[r.certificateHold=64]="certificateHold",r[r.privilegeWithdrawn=128]="privilegeWithdrawn",r[r.aACompromise=256]="aACompromise"})(Vr||(Vr={}));class dw extends uw{toJSON(){const t=[],n=this.toNumber();return n&Vr.aACompromise&&t.push("aACompromise"),n&Vr.affiliationChanged&&t.push("affiliationChanged"),n&Vr.cACompromise&&t.push("cACompromise"),n&Vr.certificateHold&&t.push("certificateHold"),n&Vr.cessationOfOperation&&t.push("cessationOfOperation"),n&Vr.keyCompromise&&t.push("keyCompromise"),n&Vr.privilegeWithdrawn&&t.push("privilegeWithdrawn"),n&Vr.superseded&&t.push("superseded"),n&Vr.unused&&t.push("unused"),t}toString(){return`[${this.toJSON().join(", ")}]`}}let Do=class{constructor(t={}){Object.assign(this,t)}};O([L({type:Rt,context:0,repeated:"sequence",implicit:!0})],Do.prototype,"fullName",void 0);O([L({type:$a,context:1,implicit:!0})],Do.prototype,"nameRelativeToCRLIssuer",void 0);Do=O([ke({type:xe.Choice})],Do);class Os{constructor(t={}){Object.assign(this,t)}}O([L({type:Do,context:0,optional:!0})],Os.prototype,"distributionPoint",void 0);O([L({type:dw,context:1,optional:!0,implicit:!0})],Os.prototype,"reasons",void 0);O([L({type:Rt,context:2,optional:!0,repeated:"sequence",implicit:!0})],Os.prototype,"cRLIssuer",void 0);let Ka=Ju=class extends ar{constructor(t){super(t),Object.setPrototypeOf(this,Ju.prototype)}};Ka=Ju=O([ke({type:xe.Sequence,itemType:Os})],Ka);var Yu;let Z0=Yu=class extends Ka{constructor(t){super(t),Object.setPrototypeOf(this,Yu.prototype)}};Z0=Yu=O([ke({type:xe.Sequence,itemType:Os})],Z0);class Zt{constructor(t={}){this.onlyContainsUserCerts=Zt.ONLY,this.onlyContainsCACerts=Zt.ONLY,this.indirectCRL=Zt.ONLY,this.onlyContainsAttributeCerts=Zt.ONLY,Object.assign(this,t)}}Zt.ONLY=!1;O([L({type:Do,context:0,optional:!0})],Zt.prototype,"distributionPoint",void 0);O([L({type:W.Boolean,context:1,defaultValue:Zt.ONLY,implicit:!0})],Zt.prototype,"onlyContainsUserCerts",void 0);O([L({type:W.Boolean,context:2,defaultValue:Zt.ONLY,implicit:!0})],Zt.prototype,"onlyContainsCACerts",void 0);O([L({type:dw,context:3,optional:!0,implicit:!0})],Zt.prototype,"onlySomeReasons",void 0);O([L({type:W.Boolean,context:4,defaultValue:Zt.ONLY,implicit:!0})],Zt.prototype,"indirectCRL",void 0);O([L({type:W.Boolean,context:5,defaultValue:Zt.ONLY,implicit:!0})],Zt.prototype,"onlyContainsAttributeCerts",void 0);var es;(function(r){r[r.unspecified=0]="unspecified",r[r.keyCompromise=1]="keyCompromise",r[r.cACompromise=2]="cACompromise",r[r.affiliationChanged=3]="affiliationChanged",r[r.superseded=4]="superseded",r[r.cessationOfOperation=5]="cessationOfOperation",r[r.certificateHold=6]="certificateHold",r[r.removeFromCRL=8]="removeFromCRL",r[r.privilegeWithdrawn=9]="privilegeWithdrawn",r[r.aACompromise=10]="aACompromise"})(es||(es={}));let Zu=class{constructor(t=es.unspecified){this.reason=es.unspecified,this.reason=t}toJSON(){return es[this.reason]}toString(){return this.toJSON()}};O([L({type:W.Enumerated})],Zu.prototype,"reason",void 0);Zu=O([ke({type:xe.Choice})],Zu);var Xu;const FS=`${Oo}.37`;let Qu=Xu=class extends ar{constructor(t){super(t),Object.setPrototypeOf(this,Xu.prototype)}};Qu=Xu=O([ke({type:xe.Sequence,itemType:W.ObjectIdentifier})],Qu);let el=class{constructor(t=new ArrayBuffer(0)){this.value=t}};O([L({type:W.Integer,converter:Dt})],el.prototype,"value",void 0);el=O([ke({type:xe.Choice})],el);let tl=class{constructor(t){this.value=new Date,t&&(this.value=t)}};O([L({type:W.GeneralizedTime})],tl.prototype,"value",void 0);tl=O([ke({type:xe.Choice})],tl);var rl;let X0=rl=class extends gs{constructor(t){super(t),Object.setPrototypeOf(this,rl.prototype)}};X0=rl=O([ke({type:xe.Sequence})],X0);var Q0;(function(r){r[r.digitalSignature=1]="digitalSignature",r[r.nonRepudiation=2]="nonRepudiation",r[r.keyEncipherment=4]="keyEncipherment",r[r.dataEncipherment=8]="dataEncipherment",r[r.keyAgreement=16]="keyAgreement",r[r.keyCertSign=32]="keyCertSign",r[r.cRLSign=64]="cRLSign",r[r.encipherOnly=128]="encipherOnly",r[r.decipherOnly=256]="decipherOnly"})(Q0||(Q0={}));var nl;class Nc{constructor(t={}){this.base=new Rt,this.minimum=0,Object.assign(this,t)}}O([L({type:Rt})],Nc.prototype,"base",void 0);O([L({type:W.Integer,context:0,defaultValue:0,implicit:!0})],Nc.prototype,"minimum",void 0);O([L({type:W.Integer,context:1,optional:!0,implicit:!0})],Nc.prototype,"maximum",void 0);let za=nl=class extends ar{constructor(t){super(t),Object.setPrototypeOf(this,nl.prototype)}};za=nl=O([ke({type:xe.Sequence,itemType:Nc})],za);class pw{constructor(t={}){Object.assign(this,t)}}O([L({type:za,context:0,optional:!0,implicit:!0})],pw.prototype,"permittedSubtrees",void 0);O([L({type:za,context:1,optional:!0,implicit:!0})],pw.prototype,"excludedSubtrees",void 0);class gw{constructor(t={}){Object.assign(this,t)}}O([L({type:W.Integer,context:0,implicit:!0,optional:!0,converter:Dt})],gw.prototype,"requireExplicitPolicy",void 0);O([L({type:W.Integer,context:1,implicit:!0,optional:!0,converter:Dt})],gw.prototype,"inhibitPolicyMapping",void 0);var il;class Ih{constructor(t={}){this.issuerDomainPolicy="",this.subjectDomainPolicy="",Object.assign(this,t)}}O([L({type:W.ObjectIdentifier})],Ih.prototype,"issuerDomainPolicy",void 0);O([L({type:W.ObjectIdentifier})],Ih.prototype,"subjectDomainPolicy",void 0);let ep=il=class extends ar{constructor(t){super(t),Object.setPrototypeOf(this,il.prototype)}};ep=il=O([ke({type:xe.Sequence,itemType:Ih})],ep);var ol;const LS=`${Oo}.17`;let sl=ol=class extends gs{constructor(t){super(t),Object.setPrototypeOf(this,ol.prototype)}};sl=ol=O([ke({type:xe.Sequence})],sl);class _h{constructor(t={}){this.type="",this.values=[],Object.assign(this,t)}}O([L({type:W.ObjectIdentifier})],_h.prototype,"type",void 0);O([L({type:W.Any,repeated:"set"})],_h.prototype,"values",void 0);var al;let tp=al=class extends ar{constructor(t){super(t),Object.setPrototypeOf(this,al.prototype)}};tp=al=O([ke({type:xe.Sequence,itemType:_h})],tp);const HS=`${Oo}.14`;class $S extends hw{}class yw{constructor(t={}){Object.assign(this,t)}}O([L({type:W.GeneralizedTime,context:0,implicit:!0,optional:!0})],yw.prototype,"notBefore",void 0);O([L({type:W.GeneralizedTime,context:1,implicit:!0,optional:!0})],yw.prototype,"notAfter",void 0);var ts;(function(r){r[r.keyUpdateAllowed=1]="keyUpdateAllowed",r[r.newExtensions=2]="newExtensions",r[r.pKIXCertificate=4]="pKIXCertificate"})(ts||(ts={}));class ww extends uw{toJSON(){const t=[],n=this.toNumber();return n&ts.pKIXCertificate&&t.push("pKIXCertificate"),n&ts.newExtensions&&t.push("newExtensions"),n&ts.keyUpdateAllowed&&t.push("keyUpdateAllowed"),t}toString(){return`[${this.toJSON().join(", ")}]`}}class mw{constructor(t={}){this.entrustVers="",this.entrustInfoFlags=new ww,Object.assign(this,t)}}O([L({type:W.GeneralString})],mw.prototype,"entrustVers",void 0);O([L({type:ww})],mw.prototype,"entrustInfoFlags",void 0);var cl;let rp=cl=class extends ar{constructor(t){super(t),Object.setPrototypeOf(this,cl.prototype)}};rp=cl=O([ke({type:xe.Sequence,itemType:kc})],rp);class Ke{constructor(t={}){this.algorithm="",Object.assign(this,t)}isEqual(t){return t instanceof Ke&&t.algorithm==this.algorithm&&(t.parameters&&this.parameters&&WE(t.parameters,this.parameters)||t.parameters===this.parameters)}}O([L({type:W.ObjectIdentifier})],Ke.prototype,"algorithm",void 0);O([L({type:W.Any,optional:!0})],Ke.prototype,"parameters",void 0);class Rc{constructor(t={}){this.algorithm=new Ke,this.subjectPublicKey=new ArrayBuffer(0),Object.assign(this,t)}}O([L({type:Ke})],Rc.prototype,"algorithm",void 0);O([L({type:W.BitString})],Rc.prototype,"subjectPublicKey",void 0);let or=class{constructor(t){if(t)if(typeof t=="string"||typeof t=="number"||t instanceof Date){const n=new Date(t);n.getUTCFullYear()>2049?this.generalTime=n:this.utcTime=n}else Object.assign(this,t)}getTime(){const t=this.utcTime||this.generalTime;if(!t)throw new Error("Cannot get time from CHOICE object");return t}};O([L({type:W.UTCTime})],or.prototype,"utcTime",void 0);O([L({type:W.GeneralizedTime})],or.prototype,"generalTime",void 0);or=O([ke({type:xe.Choice})],or);class Uc{constructor(t){this.notBefore=new or(new Date),this.notAfter=new or(new Date),t&&(this.notBefore=new or(t.notBefore),this.notAfter=new or(t.notAfter))}}O([L({type:or})],Uc.prototype,"notBefore",void 0);O([L({type:or})],Uc.prototype,"notAfter",void 0);var fl;class pn{constructor(t={}){this.extnID="",this.critical=pn.CRITICAL,this.extnValue=new Ge,Object.assign(this,t)}}pn.CRITICAL=!1;O([L({type:W.ObjectIdentifier})],pn.prototype,"extnID",void 0);O([L({type:W.Boolean,defaultValue:pn.CRITICAL})],pn.prototype,"critical",void 0);O([L({type:Ge})],pn.prototype,"extnValue",void 0);let ul=fl=class extends ar{constructor(t){super(t),Object.setPrototypeOf(this,fl.prototype)}};ul=fl=O([ke({type:xe.Sequence,itemType:pn})],ul);var qa;(function(r){r[r.v1=0]="v1",r[r.v2=1]="v2",r[r.v3=2]="v3"})(qa||(qa={}));class Lr{constructor(t={}){this.version=qa.v1,this.serialNumber=new ArrayBuffer(0),this.signature=new Ke,this.issuer=new Rn,this.validity=new Uc,this.subject=new Rn,this.subjectPublicKeyInfo=new Rc,Object.assign(this,t)}}O([L({type:W.Integer,context:0,defaultValue:qa.v1})],Lr.prototype,"version",void 0);O([L({type:W.Integer,converter:Dt})],Lr.prototype,"serialNumber",void 0);O([L({type:Ke})],Lr.prototype,"signature",void 0);O([L({type:Rn})],Lr.prototype,"issuer",void 0);O([L({type:Uc})],Lr.prototype,"validity",void 0);O([L({type:Rn})],Lr.prototype,"subject",void 0);O([L({type:Rc})],Lr.prototype,"subjectPublicKeyInfo",void 0);O([L({type:W.BitString,context:1,implicit:!0,optional:!0})],Lr.prototype,"issuerUniqueID",void 0);O([L({type:W.BitString,context:2,implicit:!0,optional:!0})],Lr.prototype,"subjectUniqueID",void 0);O([L({type:ul,context:3,optional:!0})],Lr.prototype,"extensions",void 0);class wi{constructor(t={}){this.tbsCertificate=new Lr,this.signatureAlgorithm=new Ke,this.signatureValue=new ArrayBuffer(0),Object.assign(this,t)}}O([L({type:Lr})],wi.prototype,"tbsCertificate",void 0);O([L({type:Ke})],wi.prototype,"signatureAlgorithm",void 0);O([L({type:W.BitString})],wi.prototype,"signatureValue",void 0);class Oc{constructor(t={}){this.userCertificate=new ArrayBuffer(0),this.revocationDate=new or,Object.assign(this,t)}}O([L({type:W.Integer,converter:Dt})],Oc.prototype,"userCertificate",void 0);O([L({type:or})],Oc.prototype,"revocationDate",void 0);O([L({type:pn,optional:!0,repeated:"sequence"})],Oc.prototype,"crlEntryExtensions",void 0);class Ln{constructor(t={}){this.signature=new Ke,this.issuer=new Rn,this.thisUpdate=new or,Object.assign(this,t)}}O([L({type:W.Integer,optional:!0})],Ln.prototype,"version",void 0);O([L({type:Ke})],Ln.prototype,"signature",void 0);O([L({type:Rn})],Ln.prototype,"issuer",void 0);O([L({type:or})],Ln.prototype,"thisUpdate",void 0);O([L({type:or,optional:!0})],Ln.prototype,"nextUpdate",void 0);O([L({type:Oc,repeated:"sequence",optional:!0})],Ln.prototype,"revokedCertificates",void 0);O([L({type:pn,optional:!0,context:0,repeated:"sequence"})],Ln.prototype,"crlExtensions",void 0);class Pc{constructor(t={}){this.tbsCertList=new Ln,this.signatureAlgorithm=new Ke,this.signature=new ArrayBuffer(0),Object.assign(this,t)}}O([L({type:Ln})],Pc.prototype,"tbsCertList",void 0);O([L({type:Ke})],Pc.prototype,"signatureAlgorithm",void 0);O([L({type:W.BitString})],Pc.prototype,"signature",void 0);const VS="1.2.840.10045.2.1",jS="1.2.840.10045.4.1",KS="1.2.840.10045.4.3.1",zS="1.2.840.10045.4.3.2",qS="1.2.840.10045.4.3.3",GS="1.2.840.10045.4.3.4",WS="1.2.840.10045.3.1.7",JS="1.3.132.0.34";function Ps(r){return new Ke({algorithm:r})}Ps(jS);Ps(KS);Ps(zS);Ps(qS);Ps(GS);let ys=class{constructor(t={}){Object.assign(this,t)}};O([L({type:W.ObjectIdentifier})],ys.prototype,"fieldType",void 0);O([L({type:W.Any})],ys.prototype,"parameters",void 0);ys=O([ke({type:xe.Sequence})],ys);class YS extends Ge{}let Co=class{constructor(t={}){Object.assign(this,t)}};O([L({type:W.OctetString})],Co.prototype,"a",void 0);O([L({type:W.OctetString})],Co.prototype,"b",void 0);O([L({type:W.BitString,optional:!0})],Co.prototype,"seed",void 0);Co=O([ke({type:xe.Sequence})],Co);var ll;(function(r){r[r.ecpVer1=1]="ecpVer1"})(ll||(ll={}));let On=class{constructor(t={}){this.version=ll.ecpVer1,Object.assign(this,t)}};O([L({type:W.Integer})],On.prototype,"version",void 0);O([L({type:ys})],On.prototype,"fieldID",void 0);O([L({type:Co})],On.prototype,"curve",void 0);O([L({type:YS})],On.prototype,"base",void 0);O([L({type:W.Integer,converter:Dt})],On.prototype,"order",void 0);O([L({type:W.Integer,optional:!0})],On.prototype,"cofactor",void 0);On=O([ke({type:xe.Sequence})],On);let Ji=class{constructor(t={}){Object.assign(this,t)}};O([L({type:W.ObjectIdentifier})],Ji.prototype,"namedCurve",void 0);O([L({type:W.Null})],Ji.prototype,"implicitCurve",void 0);O([L({type:On})],Ji.prototype,"specifiedCurve",void 0);Ji=O([ke({type:xe.Choice})],Ji);class Fc{constructor(t={}){this.version=1,this.privateKey=new Ge,Object.assign(this,t)}}O([L({type:W.Integer})],Fc.prototype,"version",void 0);O([L({type:Ge})],Fc.prototype,"privateKey",void 0);O([L({type:Ji,context:0,optional:!0})],Fc.prototype,"parameters",void 0);O([L({type:W.BitString,context:1,optional:!0})],Fc.prototype,"publicKey",void 0);class Lc{constructor(t={}){this.r=new ArrayBuffer(0),this.s=new ArrayBuffer(0),Object.assign(this,t)}}O([L({type:W.Integer,converter:Dt})],Lc.prototype,"r",void 0);O([L({type:W.Integer,converter:Dt})],Lc.prototype,"s",void 0);function bw(r){const t=$t.parse(r,Lc);let n=new Uint8Array(t.r),i=new Uint8Array(t.s);return np(n)&&(n=n.slice(1)),np(i)&&(i=i.slice(1)),ZS([n,i])}function np(r){return r[0]===0&&(r[1]&128)!==0}function ZS(r){let t=0;const n=r.reduce((o,s)=>o+s.length,0),i=new Uint8Array(n);return r.forEach(o=>{i.set(o,t),t+=o.length}),i}let Yo;function XS(){return new Promise((t,n)=>{if(Yo)return t(Yo);const i=e3.stubThisGlobalThisCrypto();return i?(Yo=i,t(Yo)):n(new QS)})}let QS=class extends Error{constructor(){super("An instance of the Crypto API could not be located"),this.name="MissingWebCrypto"}};const e3={stubThisGlobalThisCrypto:()=>globalThis.crypto,setCachedCrypto:r=>{Yo=r}},hl="did:peer:",vw=hl+"0";async function xw(r,t,n){const i=Mh(t),o=await XS(),s={name:"ECDSA",hash:{name:"SHA-256"}},a=Aw(i).publicKeyJwk,c={name:"ECDSA",namedCurve:a.crv},f=await o.subtle.importKey("jwk",a,c,!1,["verify"]);return await o.subtle.verify(s,f,n,r)}function Aw(r){const t=wv(r);if(t[1]!=2||t[3]!=-7||t[-1]!=1||t[-2].length!=32||t[-3].length!=32)throw new Error("Unable to extract key.");const n={alg:"ES256",crv:"P-256",kty:"EC",x:Ga(t[-2]),y:Ga(t[-3])},i=qe.Buffer.concat([qe.Buffer.from(t[-2]),qe.Buffer.from(t[-3])]);return{publicKeyJwk:n,publicKeyBuffer:i}}function t3(r){return r.replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")}function Ga(r){return t3(qe.Buffer.from(r).toString("base64"))}function Mh(r){return ny(r.substring(vw.length))}function r3(r){const t=dE(r,"base58btc","p256-pub");return vw+t}function ln(r){const t=new Uint8Array(r);let n="";for(const o of t)n+=String.fromCharCode(o);return btoa(n).replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"")}function Wa(r){const t=r.replace(/-/g,"+").replace(/_/g,"/"),n=(4-t.length%4)%4,i=t.padEnd(t.length+n,"="),o=atob(i),s=new ArrayBuffer(o.length),a=new Uint8Array(s);for(let c=0;c<o.length;c++)a[c]=o.charCodeAt(c);return s}function kh(){return(window==null?void 0:window.PublicKeyCredential)!==void 0&&typeof window.PublicKeyCredential=="function"}function Ew(r){const{id:t}=r;return{...r,id:Wa(t),transports:r.transports}}function Sw(r){return r==="localhost"||/^([a-z0-9]+(-[a-z0-9]+)*\.)+[a-z]{2,}$/i.test(r)}class Yt extends Error{constructor({message:t,code:n,cause:i,name:o}){super(t,{cause:i}),this.name=o??i.name,this.code=n}}function n3({error:r,options:t}){var i,o;const{publicKey:n}=t;if(!n)throw Error("options was missing required publicKey property");if(r.name==="AbortError"){if(t.signal instanceof AbortSignal)return new Yt({message:"Registration ceremony was sent an abort signal",code:"ERROR_CEREMONY_ABORTED",cause:r})}else if(r.name==="ConstraintError"){if(((i=n.authenticatorSelection)==null?void 0:i.requireResidentKey)===!0)return new Yt({message:"Discoverable credentials were required but no available authenticator supported it",code:"ERROR_AUTHENTICATOR_MISSING_DISCOVERABLE_CREDENTIAL_SUPPORT",cause:r});if(((o=n.authenticatorSelection)==null?void 0:o.userVerification)==="required")return new Yt({message:"User verification was required but no available authenticator supported it",code:"ERROR_AUTHENTICATOR_MISSING_USER_VERIFICATION_SUPPORT",cause:r})}else{if(r.name==="InvalidStateError")return new Yt({message:"The authenticator was previously registered",code:"ERROR_AUTHENTICATOR_PREVIOUSLY_REGISTERED",cause:r});if(r.name==="NotAllowedError")return new Yt({message:r.message,code:"ERROR_PASSTHROUGH_SEE_CAUSE_PROPERTY",cause:r});if(r.name==="NotSupportedError")return n.pubKeyCredParams.filter(a=>a.type==="public-key").length===0?new Yt({message:'No entry in pubKeyCredParams was of type "public-key"',code:"ERROR_MALFORMED_PUBKEYCREDPARAMS",cause:r}):new Yt({message:"No available authenticator supported any of the specified pubKeyCredParams algorithms",code:"ERROR_AUTHENTICATOR_NO_SUPPORTED_PUBKEYCREDPARAMS_ALG",cause:r});if(r.name==="SecurityError"){const s=window.location.hostname;if(Sw(s)){if(n.rp.id!==s)return new Yt({message:`The RP ID "${n.rp.id}" is invalid for this domain`,code:"ERROR_INVALID_RP_ID",cause:r})}else return new Yt({message:`${window.location.hostname} is an invalid domain`,code:"ERROR_INVALID_DOMAIN",cause:r})}else if(r.name==="TypeError"){if(n.user.id.byteLength<1||n.user.id.byteLength>64)return new Yt({message:"User ID was not between 1 and 64 characters",code:"ERROR_INVALID_USER_ID_LENGTH",cause:r})}else if(r.name==="UnknownError")return new Yt({message:"The authenticator was unable to process the specified options, or could not create a new credential",code:"ERROR_AUTHENTICATOR_GENERAL_ERROR",cause:r})}return r}class i3{createNewAbortSignal(){if(this.controller){const n=new Error("Cancelling existing WebAuthn API call for new one");n.name="AbortError",this.controller.abort(n)}const t=new AbortController;return this.controller=t,t.signal}cancelCeremony(){if(this.controller){const t=new Error("Manually cancelling existing WebAuthn API call");t.name="AbortError",this.controller.abort(t),this.controller=void 0}}}const Bw=new i3,o3=["cross-platform","platform"];function Dw(r){if(r&&!(o3.indexOf(r)<0))return r}async function s3(r){var x;if(!kh())throw new Error("WebAuthn is not supported in this browser");const n={publicKey:{...r,challenge:Wa(r.challenge),user:{...r.user,id:Wa(r.user.id)},excludeCredentials:(x=r.excludeCredentials)==null?void 0:x.map(Ew)}};n.signal=Bw.createNewAbortSignal();let i;try{i=await navigator.credentials.create(n)}catch(S){throw n3({error:S,options:n})}if(!i)throw new Error("Registration was not completed");const{id:o,rawId:s,response:a,type:c}=i;let f;typeof a.getTransports=="function"&&(f=a.getTransports());let h;if(typeof a.getPublicKeyAlgorithm=="function")try{h=a.getPublicKeyAlgorithm()}catch(S){Zf("getPublicKeyAlgorithm()",S)}let d;if(typeof a.getPublicKey=="function")try{const S=a.getPublicKey();S!==null&&(d=ln(S))}catch(S){Zf("getPublicKey()",S)}let g;if(typeof a.getAuthenticatorData=="function")try{g=ln(a.getAuthenticatorData())}catch(S){Zf("getAuthenticatorData()",S)}return{id:o,rawId:ln(s),response:{attestationObject:ln(a.attestationObject),clientDataJSON:ln(a.clientDataJSON),transports:f,publicKeyAlgorithm:h,publicKey:d,authenticatorData:g},type:c,clientExtensionResults:i.getClientExtensionResults(),authenticatorAttachment:Dw(i.authenticatorAttachment)}}function Zf(r,t){console.warn(`The browser extension that intercepted this WebAuthn API call incorrectly implemented ${r}. You should report this error to them.
`,t)}function a3(){if(!kh())return new Promise(t=>t(!1));const r=window.PublicKeyCredential;return r.isConditionalMediationAvailable===void 0?new Promise(t=>t(!1)):r.isConditionalMediationAvailable()}function c3({error:r,options:t}){const{publicKey:n}=t;if(!n)throw Error("options was missing required publicKey property");if(r.name==="AbortError"){if(t.signal instanceof AbortSignal)return new Yt({message:"Authentication ceremony was sent an abort signal",code:"ERROR_CEREMONY_ABORTED",cause:r})}else{if(r.name==="NotAllowedError")return new Yt({message:r.message,code:"ERROR_PASSTHROUGH_SEE_CAUSE_PROPERTY",cause:r});if(r.name==="SecurityError"){const i=window.location.hostname;if(Sw(i)){if(n.rpId!==i)return new Yt({message:`The RP ID "${n.rpId}" is invalid for this domain`,code:"ERROR_INVALID_RP_ID",cause:r})}else return new Yt({message:`${window.location.hostname} is an invalid domain`,code:"ERROR_INVALID_DOMAIN",cause:r})}else if(r.name==="UnknownError")return new Yt({message:"The authenticator was unable to process the specified options, or could not create a new assertion signature",code:"ERROR_AUTHENTICATOR_GENERAL_ERROR",cause:r})}return r}async function f3(r,t=!1){var g,x;if(!kh())throw new Error("WebAuthn is not supported in this browser");let n;((g=r.allowCredentials)==null?void 0:g.length)!==0&&(n=(x=r.allowCredentials)==null?void 0:x.map(Ew));const i={...r,challenge:Wa(r.challenge),allowCredentials:n},o={};if(t){if(!await a3())throw Error("Browser does not support WebAuthn autofill");if(document.querySelectorAll("input[autocomplete$='webauthn']").length<1)throw Error('No <input> with "webauthn" as the only or last value in its `autocomplete` attribute was detected');o.mediation="conditional",i.allowCredentials=[]}o.publicKey=i,o.signal=Bw.createNewAbortSignal();let s;try{s=await navigator.credentials.get(o)}catch(S){throw c3({error:S,options:o})}if(!s)throw new Error("Authentication was not completed");const{id:a,rawId:c,response:f,type:h}=s;let d;return f.userHandle&&(d=ln(f.userHandle)),{id:a,rawId:ln(c),response:{authenticatorData:ln(f.authenticatorData),clientDataJSON:ln(f.clientDataJSON),signature:ln(f.signature),userHandle:d},type:h,clientExtensionResults:s.getClientExtensionResults(),authenticatorAttachment:Dw(s.authenticatorAttachment)}}function Fs(r,t,n){if(t<24)return[t,1];const i=r.byteLength-n-1,o=new DataView(r.buffer,n+1);let s,a=0;switch(t){case 24:{i>0&&(s=o.getUint8(0),a=2);break}case 25:{i>1&&(s=o.getUint16(0,!1),a=3);break}case 26:{i>3&&(s=o.getUint32(0,!1),a=5);break}case 27:{if(i>7){const c=o.getBigUint64(0,!1);if(c>=24n&&c<=Number.MAX_SAFE_INTEGER)return[Number(c),9]}break}}if(s&&s>=24)return[s,a];throw new Error("Length not supported or not well formed")}const dl=0,Ja=1,Cw=2,Iw=3,_w=4,Mw=5,kw=6,u3=7;function _n(r,t){const n=r<<5;if(t<0)throw new Error("CBOR Data Item argument must not be negative");let i;if(typeof t=="number"){if(!Number.isInteger(t))throw new Error("CBOR Data Item argument must be an integer");i=BigInt(t)}else i=t;if(r==Ja){if(i==0n)throw new Error("CBOR Data Item argument cannot be zero when negative");i=i-1n}if(i>18446744073709551615n)throw new Error("CBOR number out of range");const o=new Uint8Array(8);return new DataView(o.buffer).setBigUint64(0,i,!1),i<=23?[n|o[7]]:i<=255?[n|24,o[7]]:i<=65535?[n|25,...o.slice(6)]:i<=4294967295?[n|26,...o.slice(4)]:[n|27,...o]}class Tw{constructor(t,n){Object.defineProperty(this,"tagId",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"tagValue",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.tagId=t,this.tagValue=n}get tag(){return this.tagId}get value(){return this.tagValue}}function Nw(r,t,n){return Fs(r,t,n)}function l3(r,t,n){const[i,o]=Nw(r,t,n);return[-i-1,o]}function Rw(r,t,n){const[i,o]=Fs(r,t,n),s=n+o;return[new Uint8Array(r.buffer.slice(s,s+i)),o+i]}const h3=new TextDecoder;function d3(r,t,n){const[i,o]=Rw(r,t,n);return[h3.decode(i),o]}function p3(r,t,n){if(t===0)return[[],1];const[i,o]=Fs(r,t,n);let s=o;const a=[];for(let c=0;c<i;c++){if(r.byteLength-n-s<=0)throw new Error("array is not supported or well formed");const[h,d]=$i(r,n+s);a.push(h),s+=d}return[a,s]}const sa="Map is not supported or well formed";function g3(r,t,n){if(t===0)return[new Map,1];const[i,o]=Fs(r,t,n);let s=o;const a=new Map;for(let c=0;c<i;c++){let f=r.byteLength-n-s;if(f<=0)throw new Error(sa);const[h,d]=$i(r,n+s);if(s+=d,f-=d,f<=0)throw new Error(sa);if(typeof h!="string"&&typeof h!="number")throw new Error(sa);if(a.has(h))throw new Error(sa);const[g,x]=$i(r,n+s);s+=x,a.set(h,g)}return[a,s]}function y3(r,t){if(t+3>r.byteLength)throw new Error("CBOR stream ended before end of Float 16");const n=r.getUint16(t+1,!1);if(n==31744)return[1/0,3];if(n==32256)return[NaN,3];if(n==64512)return[-1/0,3];throw new Error("Float16 data is unsupported")}function w3(r,t){if(t+5>r.byteLength)throw new Error("CBOR stream ended before end of Float 32");return[r.getFloat32(t+1,!1),5]}function m3(r,t){if(t+9>r.byteLength)throw new Error("CBOR stream ended before end of Float 64");return[r.getFloat64(t+1,!1),9]}function b3(r,t,n){const[i,o]=Fs(r,t,n),[s,a]=$i(r,n+o);return[new Tw(i,s),o+a]}function $i(r,t){if(t>=r.byteLength)throw new Error("CBOR stream ended before tag value");const n=r.getUint8(t),i=n>>5,o=n&31;switch(i){case dl:return Nw(r,o,t);case Ja:return l3(r,o,t);case Cw:return Rw(r,o,t);case Iw:return d3(r,o,t);case _w:return p3(r,o,t);case Mw:return g3(r,o,t);case kw:return b3(r,o,t);case u3:switch(o){case 20:return[!1,1];case 21:return[!0,1];case 22:return[null,1];case 23:return[void 0,1];case 25:return y3(r,t);case 26:return w3(r,t);case 27:return m3(r,t)}}throw new Error(`Unsupported or not well formed at ${t}`)}function v3(r){return r===!0?245:r===!1?244:r===null?246:247}function x3(r){if(Math.fround(r)==r||!Number.isFinite(r)||Number.isNaN(r)){const t=new Uint8Array(5);return t[0]=250,new DataView(t.buffer).setFloat32(1,r,!1),t}else{const t=new Uint8Array(9);return t[0]=251,new DataView(t.buffer).setFloat64(1,r,!1),t}}function A3(r){return typeof r=="number"?Number.isSafeInteger(r)?r<0?_n(Ja,Math.abs(r)):_n(dl,r):[x3(r)]:r<0n?_n(Ja,r*-1n):_n(dl,r)}const E3=new TextEncoder;function S3(r,t){t.push(..._n(Iw,r.length)),t.push(E3.encode(r))}function B3(r,t){t.push(..._n(Cw,r.length)),t.push(r)}function D3(r,t){t.push(..._n(_w,r.length));for(const n of r)ws(n,t)}function C3(r,t){t.push(new Uint8Array(_n(Mw,r.size)));for(const[n,i]of r.entries())ws(n,t),ws(i,t)}function I3(r,t){t.push(..._n(kw,r.tag)),ws(r.value,t)}function ws(r,t){if(typeof r=="boolean"||r===null||r==null){t.push(v3(r));return}if(typeof r=="number"||typeof r=="bigint"){t.push(...A3(r));return}if(typeof r=="string"){S3(r,t);return}if(r instanceof Uint8Array){B3(r,t);return}if(Array.isArray(r)){D3(r,t);return}if(r instanceof Map){C3(r,t);return}if(r instanceof Tw){I3(r,t);return}throw new Error("Not implemented")}function _3(r,t){if(r.byteLength===0||r.byteLength<=t||t<0)throw new Error("No data");return r instanceof Uint8Array?$i(new DataView(r.buffer),t):r instanceof ArrayBuffer?$i(new DataView(r),t):$i(r,t)}function M3(r){const t=[];ws(r,t);let n=0;for(const s of t)typeof s=="number"?n+=1:n+=s.length;const i=new Uint8Array(n);let o=0;for(const s of t)typeof s=="number"?(i[o]=s,o+=1):(i.set(s,o),o+=s.length);return i}const Th="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",Uw="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",Ow=r=>{const t=typeof Uint8Array>"u"?[]:new Uint8Array(256),n=Th.length;for(let i=0;i<n;i++)t[r.charCodeAt(i)]=i;return t},k3=Ow(Th),T3=Ow(Uw),N3=/^[-A-Za-z0-9\-_]*$/,R3=/^[-A-Za-z0-9+/]*={0,3}$/,Qt={};Qt.toArrayBuffer=(r,t)=>{const n=r.length;let i=r.length*.75,o,s=0,a,c,f,h;r[r.length-1]==="="&&(i--,r[r.length-2]==="="&&i--);const d=new ArrayBuffer(i),g=new Uint8Array(d),x=t?T3:k3;for(o=0;o<n;o+=4)a=x[r.charCodeAt(o)],c=x[r.charCodeAt(o+1)],f=x[r.charCodeAt(o+2)],h=x[r.charCodeAt(o+3)],g[s++]=a<<2|c>>4,g[s++]=(c&15)<<4|f>>2,g[s++]=(f&3)<<6|h&63;return d};Qt.fromArrayBuffer=(r,t)=>{const n=new Uint8Array(r);let i,o="";const s=n.length,a=t?Uw:Th;for(i=0;i<s;i+=3)o+=a[n[i]>>2],o+=a[(n[i]&3)<<4|n[i+1]>>4],o+=a[(n[i+1]&15)<<2|n[i+2]>>6],o+=a[n[i+2]&63];const c=s%3;return c===2?o=o.substring(0,o.length-1)+(t?"":"="):c===1&&(o=o.substring(0,o.length-2)+(t?"":"==")),o};Qt.toString=(r,t)=>new TextDecoder().decode(Qt.toArrayBuffer(r,t));Qt.fromString=(r,t)=>Qt.fromArrayBuffer(new TextEncoder().encode(r),t);Qt.validate=(r,t)=>{if(!(typeof r=="string"||r instanceof String))return!1;try{return t?N3.test(r):R3.test(r)}catch{return!1}};Qt.base64=Qt;var aa={exports:{}},ip;function U3(){return ip||(ip=1,function(r,t){var n=typeof globalThis<"u"&&globalThis||typeof self<"u"&&self||typeof qo<"u"&&qo,i=function(){function s(){this.fetch=!1,this.DOMException=n.DOMException}return s.prototype=n,new s}();(function(s){(function(a){var c=typeof s<"u"&&s||typeof self<"u"&&self||typeof qo<"u"&&qo||{},f={searchParams:"URLSearchParams"in c,iterable:"Symbol"in c&&"iterator"in Symbol,blob:"FileReader"in c&&"Blob"in c&&function(){try{return new Blob,!0}catch{return!1}}(),formData:"FormData"in c,arrayBuffer:"ArrayBuffer"in c};function h(l){return l&&DataView.prototype.isPrototypeOf(l)}if(f.arrayBuffer)var d=["[object Int8Array]","[object Uint8Array]","[object Uint8ClampedArray]","[object Int16Array]","[object Uint16Array]","[object Int32Array]","[object Uint32Array]","[object Float32Array]","[object Float64Array]"],g=ArrayBuffer.isView||function(l){return l&&d.indexOf(Object.prototype.toString.call(l))>-1};function x(l){if(typeof l!="string"&&(l=String(l)),/[^a-z0-9\-#$%&'*+.^_`|~!]/i.test(l)||l==="")throw new TypeError('Invalid character in header field name: "'+l+'"');return l.toLowerCase()}function S(l){return typeof l!="string"&&(l=String(l)),l}function D(l){var p={next:function(){var w=l.shift();return{done:w===void 0,value:w}}};return f.iterable&&(p[Symbol.iterator]=function(){return p}),p}function E(l){this.map={},l instanceof E?l.forEach(function(p,w){this.append(w,p)},this):Array.isArray(l)?l.forEach(function(p){if(p.length!=2)throw new TypeError("Headers constructor: expected name/value pair to be length 2, found"+p.length);this.append(p[0],p[1])},this):l&&Object.getOwnPropertyNames(l).forEach(function(p){this.append(p,l[p])},this)}E.prototype.append=function(l,p){l=x(l),p=S(p);var w=this.map[l];this.map[l]=w?w+", "+p:p},E.prototype.delete=function(l){delete this.map[x(l)]},E.prototype.get=function(l){return l=x(l),this.has(l)?this.map[l]:null},E.prototype.has=function(l){return this.map.hasOwnProperty(x(l))},E.prototype.set=function(l,p){this.map[x(l)]=S(p)},E.prototype.forEach=function(l,p){for(var w in this.map)this.map.hasOwnProperty(w)&&l.call(p,this.map[w],w,this)},E.prototype.keys=function(){var l=[];return this.forEach(function(p,w){l.push(w)}),D(l)},E.prototype.values=function(){var l=[];return this.forEach(function(p){l.push(p)}),D(l)},E.prototype.entries=function(){var l=[];return this.forEach(function(p,w){l.push([w,p])}),D(l)},f.iterable&&(E.prototype[Symbol.iterator]=E.prototype.entries);function _(l){if(!l._noBody){if(l.bodyUsed)return Promise.reject(new TypeError("Already read"));l.bodyUsed=!0}}function T(l){return new Promise(function(p,w){l.onload=function(){p(l.result)},l.onerror=function(){w(l.error)}})}function F(l){var p=new FileReader,w=T(p);return p.readAsArrayBuffer(l),w}function U(l){var p=new FileReader,w=T(p),A=/charset=([A-Za-z0-9_-]+)/.exec(l.type),C=A?A[1]:"utf-8";return p.readAsText(l,C),w}function z(l){for(var p=new Uint8Array(l),w=new Array(p.length),A=0;A<p.length;A++)w[A]=String.fromCharCode(p[A]);return w.join("")}function V(l){if(l.slice)return l.slice(0);var p=new Uint8Array(l.byteLength);return p.set(new Uint8Array(l)),p.buffer}function G(){return this.bodyUsed=!1,this._initBody=function(l){this.bodyUsed=this.bodyUsed,this._bodyInit=l,l?typeof l=="string"?this._bodyText=l:f.blob&&Blob.prototype.isPrototypeOf(l)?this._bodyBlob=l:f.formData&&FormData.prototype.isPrototypeOf(l)?this._bodyFormData=l:f.searchParams&&URLSearchParams.prototype.isPrototypeOf(l)?this._bodyText=l.toString():f.arrayBuffer&&f.blob&&h(l)?(this._bodyArrayBuffer=V(l.buffer),this._bodyInit=new Blob([this._bodyArrayBuffer])):f.arrayBuffer&&(ArrayBuffer.prototype.isPrototypeOf(l)||g(l))?this._bodyArrayBuffer=V(l):this._bodyText=l=Object.prototype.toString.call(l):(this._noBody=!0,this._bodyText=""),this.headers.get("content-type")||(typeof l=="string"?this.headers.set("content-type","text/plain;charset=UTF-8"):this._bodyBlob&&this._bodyBlob.type?this.headers.set("content-type",this._bodyBlob.type):f.searchParams&&URLSearchParams.prototype.isPrototypeOf(l)&&this.headers.set("content-type","application/x-www-form-urlencoded;charset=UTF-8"))},f.blob&&(this.blob=function(){var l=_(this);if(l)return l;if(this._bodyBlob)return Promise.resolve(this._bodyBlob);if(this._bodyArrayBuffer)return Promise.resolve(new Blob([this._bodyArrayBuffer]));if(this._bodyFormData)throw new Error("could not read FormData body as blob");return Promise.resolve(new Blob([this._bodyText]))}),this.arrayBuffer=function(){if(this._bodyArrayBuffer){var l=_(this);return l||(ArrayBuffer.isView(this._bodyArrayBuffer)?Promise.resolve(this._bodyArrayBuffer.buffer.slice(this._bodyArrayBuffer.byteOffset,this._bodyArrayBuffer.byteOffset+this._bodyArrayBuffer.byteLength)):Promise.resolve(this._bodyArrayBuffer))}else{if(f.blob)return this.blob().then(F);throw new Error("could not read as ArrayBuffer")}},this.text=function(){var l=_(this);if(l)return l;if(this._bodyBlob)return U(this._bodyBlob);if(this._bodyArrayBuffer)return Promise.resolve(z(this._bodyArrayBuffer));if(this._bodyFormData)throw new Error("could not read FormData body as text");return Promise.resolve(this._bodyText)},f.formData&&(this.formData=function(){return this.text().then(se)}),this.json=function(){return this.text().then(JSON.parse)},this}var ee=["CONNECT","DELETE","GET","HEAD","OPTIONS","PATCH","POST","PUT","TRACE"];function Q(l){var p=l.toUpperCase();return ee.indexOf(p)>-1?p:l}function X(l,p){if(!(this instanceof X))throw new TypeError('Please use the "new" operator, this DOM object constructor cannot be called as a function.');p=p||{};var w=p.body;if(l instanceof X){if(l.bodyUsed)throw new TypeError("Already read");this.url=l.url,this.credentials=l.credentials,p.headers||(this.headers=new E(l.headers)),this.method=l.method,this.mode=l.mode,this.signal=l.signal,!w&&l._bodyInit!=null&&(w=l._bodyInit,l.bodyUsed=!0)}else this.url=String(l);if(this.credentials=p.credentials||this.credentials||"same-origin",(p.headers||!this.headers)&&(this.headers=new E(p.headers)),this.method=Q(p.method||this.method||"GET"),this.mode=p.mode||this.mode||null,this.signal=p.signal||this.signal||function(){if("AbortController"in c){var k=new AbortController;return k.signal}}(),this.referrer=null,(this.method==="GET"||this.method==="HEAD")&&w)throw new TypeError("Body not allowed for GET or HEAD requests");if(this._initBody(w),(this.method==="GET"||this.method==="HEAD")&&(p.cache==="no-store"||p.cache==="no-cache")){var A=/([?&])_=[^&]*/;if(A.test(this.url))this.url=this.url.replace(A,"$1_="+new Date().getTime());else{var C=/\?/;this.url+=(C.test(this.url)?"&":"?")+"_="+new Date().getTime()}}}X.prototype.clone=function(){return new X(this,{body:this._bodyInit})};function se(l){var p=new FormData;return l.trim().split("&").forEach(function(w){if(w){var A=w.split("="),C=A.shift().replace(/\+/g," "),k=A.join("=").replace(/\+/g," ");p.append(decodeURIComponent(C),decodeURIComponent(k))}}),p}function oe(l){var p=new E,w=l.replace(/\r?\n[\t ]+/g," ");return w.split("\r").map(function(A){return A.indexOf(`
`)===0?A.substr(1,A.length):A}).forEach(function(A){var C=A.split(":"),k=C.shift().trim();if(k){var I=C.join(":").trim();try{p.append(k,I)}catch(y){console.warn("Response "+y.message)}}}),p}G.call(X.prototype);function H(l,p){if(!(this instanceof H))throw new TypeError('Please use the "new" operator, this DOM object constructor cannot be called as a function.');if(p||(p={}),this.type="default",this.status=p.status===void 0?200:p.status,this.status<200||this.status>599)throw new RangeError("Failed to construct 'Response': The status provided (0) is outside the range [200, 599].");this.ok=this.status>=200&&this.status<300,this.statusText=p.statusText===void 0?"":""+p.statusText,this.headers=new E(p.headers),this.url=p.url||"",this._initBody(l)}G.call(H.prototype),H.prototype.clone=function(){return new H(this._bodyInit,{status:this.status,statusText:this.statusText,headers:new E(this.headers),url:this.url})},H.error=function(){var l=new H(null,{status:200,statusText:""});return l.ok=!1,l.status=0,l.type="error",l};var v=[301,302,303,307,308];H.redirect=function(l,p){if(v.indexOf(p)===-1)throw new RangeError("Invalid status code");return new H(null,{status:p,headers:{location:l}})},a.DOMException=c.DOMException;try{new a.DOMException}catch{a.DOMException=function(p,w){this.message=p,this.name=w;var A=Error(p);this.stack=A.stack},a.DOMException.prototype=Object.create(Error.prototype),a.DOMException.prototype.constructor=a.DOMException}function u(l,p){return new Promise(function(w,A){var C=new X(l,p);if(C.signal&&C.signal.aborted)return A(new a.DOMException("Aborted","AbortError"));var k=new XMLHttpRequest;function I(){k.abort()}k.onload=function(){var re={statusText:k.statusText,headers:oe(k.getAllResponseHeaders()||"")};C.url.indexOf("file://")===0&&(k.status<200||k.status>599)?re.status=200:re.status=k.status,re.url="responseURL"in k?k.responseURL:re.headers.get("X-Request-URL");var B="response"in k?k.response:k.responseText;setTimeout(function(){w(new H(B,re))},0)},k.onerror=function(){setTimeout(function(){A(new TypeError("Network request failed"))},0)},k.ontimeout=function(){setTimeout(function(){A(new TypeError("Network request timed out"))},0)},k.onabort=function(){setTimeout(function(){A(new a.DOMException("Aborted","AbortError"))},0)};function y(re){try{return re===""&&c.location.href?c.location.href:re}catch{return re}}if(k.open(C.method,y(C.url),!0),C.credentials==="include"?k.withCredentials=!0:C.credentials==="omit"&&(k.withCredentials=!1),"responseType"in k&&(f.blob?k.responseType="blob":f.arrayBuffer&&(k.responseType="arraybuffer")),p&&typeof p.headers=="object"&&!(p.headers instanceof E||c.Headers&&p.headers instanceof c.Headers)){var N=[];Object.getOwnPropertyNames(p.headers).forEach(function(re){N.push(x(re)),k.setRequestHeader(re,S(p.headers[re]))}),C.headers.forEach(function(re,B){N.indexOf(B)===-1&&k.setRequestHeader(B,re)})}else C.headers.forEach(function(re,B){k.setRequestHeader(B,re)});C.signal&&(C.signal.addEventListener("abort",I),k.onreadystatechange=function(){k.readyState===4&&C.signal.removeEventListener("abort",I)}),k.send(typeof C._bodyInit>"u"?null:C._bodyInit)})}return u.polyfill=!0,c.fetch||(c.fetch=u,c.Headers=E,c.Request=X,c.Response=H),a.Headers=E,a.Request=X,a.Response=H,a.fetch=u,a})({})})(i),i.fetch.ponyfill=!0,delete i.fetch.polyfill;var o=n.fetch?n:i;t=o.fetch,t.default=o.fetch,t.fetch=o.fetch,t.Headers=o.Headers,t.Request=o.Request,t.Response=o.Response,r.exports=t}(aa,aa.exports)),aa.exports}var O3=U3();const Hr="1.2.840.113549.1.1",P3=`${Hr}.1`,F3=`${Hr}.7`,L3=`${Hr}.9`,H3=`${Hr}.10`,$3=`${Hr}.2`,V3=`${Hr}.4`,j3=`${Hr}.5`,K3=`${Hr}.12`,z3=`${Hr}.13`,Pw=`${Hr}.15`,Fw=`${Hr}.16`,q3="1.3.14.3.2.26",G3="2.16.840.1.101.3.4.2.4",W3="2.16.840.1.101.3.4.2.1",J3="2.16.840.1.101.3.4.2.2",Y3="2.16.840.1.101.3.4.2.3",Z3="2.16.840.1.101.3.4.2.5",X3="2.16.840.1.101.3.4.2.6",Q3="1.2.840.113549.2.2",e8="1.2.840.113549.2.5",Nh=`${Hr}.8`;function Ut(r){return new Ke({algorithm:r,parameters:null})}Ut(Q3);Ut(e8);const Yi=Ut(q3);Ut(G3);Ut(W3);Ut(J3);Ut(Y3);Ut(Z3);Ut(X3);const Lw=new Ke({algorithm:Nh,parameters:yi.serialize(Yi)}),Hw=new Ke({algorithm:L3,parameters:yi.serialize(Ha.toASN(new Uint8Array([218,57,163,238,94,107,75,13,50,85,191,239,149,96,24,144,175,216,7,9]).buffer))});Ut(P3);Ut($3);Ut(V3);Ut(j3);Ut(Pw);Ut(Fw);Ut(K3);Ut(z3);Ut(Pw);Ut(Fw);class Hc{constructor(t={}){this.hashAlgorithm=new Ke(Yi),this.maskGenAlgorithm=new Ke({algorithm:Nh,parameters:yi.serialize(Yi)}),this.pSourceAlgorithm=new Ke(Hw),Object.assign(this,t)}}O([L({type:Ke,context:0,defaultValue:Yi})],Hc.prototype,"hashAlgorithm",void 0);O([L({type:Ke,context:1,defaultValue:Lw})],Hc.prototype,"maskGenAlgorithm",void 0);O([L({type:Ke,context:2,defaultValue:Hw})],Hc.prototype,"pSourceAlgorithm",void 0);new Ke({algorithm:F3,parameters:yi.serialize(new Hc)});class Ls{constructor(t={}){this.hashAlgorithm=new Ke(Yi),this.maskGenAlgorithm=new Ke({algorithm:Nh,parameters:yi.serialize(Yi)}),this.saltLength=20,this.trailerField=1,Object.assign(this,t)}}O([L({type:Ke,context:0,defaultValue:Yi})],Ls.prototype,"hashAlgorithm",void 0);O([L({type:Ke,context:1,defaultValue:Lw})],Ls.prototype,"maskGenAlgorithm",void 0);O([L({type:W.Integer,context:2,defaultValue:20})],Ls.prototype,"saltLength",void 0);O([L({type:W.Integer,context:3,defaultValue:1})],Ls.prototype,"trailerField",void 0);new Ke({algorithm:H3,parameters:yi.serialize(new Ls)});class $w{constructor(t={}){this.digestAlgorithm=new Ke,this.digest=new Ge,Object.assign(this,t)}}O([L({type:Ke})],$w.prototype,"digestAlgorithm",void 0);O([L({type:Ge})],$w.prototype,"digest",void 0);var pl;class $c{constructor(t={}){this.prime=new ArrayBuffer(0),this.exponent=new ArrayBuffer(0),this.coefficient=new ArrayBuffer(0),Object.assign(this,t)}}O([L({type:W.Integer,converter:Dt})],$c.prototype,"prime",void 0);O([L({type:W.Integer,converter:Dt})],$c.prototype,"exponent",void 0);O([L({type:W.Integer,converter:Dt})],$c.prototype,"coefficient",void 0);let gl=pl=class extends ar{constructor(t){super(t),Object.setPrototypeOf(this,pl.prototype)}};gl=pl=O([ke({type:xe.Sequence,itemType:$c})],gl);class mn{constructor(t={}){this.version=0,this.modulus=new ArrayBuffer(0),this.publicExponent=new ArrayBuffer(0),this.privateExponent=new ArrayBuffer(0),this.prime1=new ArrayBuffer(0),this.prime2=new ArrayBuffer(0),this.exponent1=new ArrayBuffer(0),this.exponent2=new ArrayBuffer(0),this.coefficient=new ArrayBuffer(0),Object.assign(this,t)}}O([L({type:W.Integer})],mn.prototype,"version",void 0);O([L({type:W.Integer,converter:Dt})],mn.prototype,"modulus",void 0);O([L({type:W.Integer,converter:Dt})],mn.prototype,"publicExponent",void 0);O([L({type:W.Integer,converter:Dt})],mn.prototype,"privateExponent",void 0);O([L({type:W.Integer,converter:Dt})],mn.prototype,"prime1",void 0);O([L({type:W.Integer,converter:Dt})],mn.prototype,"prime2",void 0);O([L({type:W.Integer,converter:Dt})],mn.prototype,"exponent1",void 0);O([L({type:W.Integer,converter:Dt})],mn.prototype,"exponent2",void 0);O([L({type:W.Integer,converter:Dt})],mn.prototype,"coefficient",void 0);O([L({type:gl,optional:!0})],mn.prototype,"otherPrimeInfos",void 0);class Rh{constructor(t={}){this.modulus=new ArrayBuffer(0),this.publicExponent=new ArrayBuffer(0),Object.assign(this,t)}}O([L({type:W.Integer,converter:Dt})],Rh.prototype,"modulus",void 0);O([L({type:W.Integer,converter:Dt})],Rh.prototype,"publicExponent",void 0);var yl;const t8="1.3.6.1.4.1.11129.2.1.17";var wl;(function(r){r[r.verified=0]="verified",r[r.selfSigned=1]="selfSigned",r[r.unverified=2]="unverified",r[r.failed=3]="failed"})(wl||(wl={}));class Hs{constructor(t={}){this.verifiedBootKey=new Ge,this.deviceLocked=!1,this.verifiedBootState=wl.verified,Object.assign(this,t)}}O([L({type:Ge})],Hs.prototype,"verifiedBootKey",void 0);O([L({type:W.Boolean})],Hs.prototype,"deviceLocked",void 0);O([L({type:W.Enumerated})],Hs.prototype,"verifiedBootState",void 0);O([L({type:Ge,optional:!0})],Hs.prototype,"verifiedBootHash",void 0);let Io=yl=class extends ar{constructor(t){super(t),Object.setPrototypeOf(this,yl.prototype)}};Io=yl=O([ke({type:xe.Set,itemType:W.Integer})],Io);class Ae{constructor(t={}){Object.assign(this,t)}}O([L({context:1,type:Io,optional:!0})],Ae.prototype,"purpose",void 0);O([L({context:2,type:W.Integer,optional:!0})],Ae.prototype,"algorithm",void 0);O([L({context:3,type:W.Integer,optional:!0})],Ae.prototype,"keySize",void 0);O([L({context:5,type:Io,optional:!0})],Ae.prototype,"digest",void 0);O([L({context:6,type:Io,optional:!0})],Ae.prototype,"padding",void 0);O([L({context:10,type:W.Integer,optional:!0})],Ae.prototype,"ecCurve",void 0);O([L({context:200,type:W.Integer,optional:!0})],Ae.prototype,"rsaPublicExponent",void 0);O([L({context:203,type:Io,optional:!0})],Ae.prototype,"mgfDigest",void 0);O([L({context:303,type:W.Null,optional:!0})],Ae.prototype,"rollbackResistance",void 0);O([L({context:305,type:W.Null,optional:!0})],Ae.prototype,"earlyBootOnly",void 0);O([L({context:400,type:W.Integer,optional:!0})],Ae.prototype,"activeDateTime",void 0);O([L({context:401,type:W.Integer,optional:!0})],Ae.prototype,"originationExpireDateTime",void 0);O([L({context:402,type:W.Integer,optional:!0})],Ae.prototype,"usageExpireDateTime",void 0);O([L({context:405,type:W.Integer,optional:!0})],Ae.prototype,"usageCountLimit",void 0);O([L({context:503,type:W.Null,optional:!0})],Ae.prototype,"noAuthRequired",void 0);O([L({context:504,type:W.Integer,optional:!0})],Ae.prototype,"userAuthType",void 0);O([L({context:505,type:W.Integer,optional:!0})],Ae.prototype,"authTimeout",void 0);O([L({context:506,type:W.Null,optional:!0})],Ae.prototype,"allowWhileOnBody",void 0);O([L({context:507,type:W.Null,optional:!0})],Ae.prototype,"trustedUserPresenceRequired",void 0);O([L({context:508,type:W.Null,optional:!0})],Ae.prototype,"trustedConfirmationRequired",void 0);O([L({context:509,type:W.Null,optional:!0})],Ae.prototype,"unlockedDeviceRequired",void 0);O([L({context:600,type:W.Null,optional:!0})],Ae.prototype,"allApplications",void 0);O([L({context:601,type:Ge,optional:!0})],Ae.prototype,"applicationId",void 0);O([L({context:701,type:W.Integer,optional:!0})],Ae.prototype,"creationDateTime",void 0);O([L({context:702,type:W.Integer,optional:!0})],Ae.prototype,"origin",void 0);O([L({context:703,type:W.Null,optional:!0})],Ae.prototype,"rollbackResistant",void 0);O([L({context:704,type:Hs,optional:!0})],Ae.prototype,"rootOfTrust",void 0);O([L({context:705,type:W.Integer,optional:!0})],Ae.prototype,"osVersion",void 0);O([L({context:706,type:W.Integer,optional:!0})],Ae.prototype,"osPatchLevel",void 0);O([L({context:709,type:Ge,optional:!0})],Ae.prototype,"attestationApplicationId",void 0);O([L({context:710,type:Ge,optional:!0})],Ae.prototype,"attestationIdBrand",void 0);O([L({context:711,type:Ge,optional:!0})],Ae.prototype,"attestationIdDevice",void 0);O([L({context:712,type:Ge,optional:!0})],Ae.prototype,"attestationIdProduct",void 0);O([L({context:713,type:Ge,optional:!0})],Ae.prototype,"attestationIdSerial",void 0);O([L({context:714,type:Ge,optional:!0})],Ae.prototype,"attestationIdImei",void 0);O([L({context:715,type:Ge,optional:!0})],Ae.prototype,"attestationIdMeid",void 0);O([L({context:716,type:Ge,optional:!0})],Ae.prototype,"attestationIdManufacturer",void 0);O([L({context:717,type:Ge,optional:!0})],Ae.prototype,"attestationIdModel",void 0);O([L({context:718,type:W.Integer,optional:!0})],Ae.prototype,"vendorPatchLevel",void 0);O([L({context:719,type:W.Integer,optional:!0})],Ae.prototype,"bootPatchLevel",void 0);O([L({context:720,type:W.Null,optional:!0})],Ae.prototype,"deviceUniqueAttestation",void 0);var _o;(function(r){r[r.software=0]="software",r[r.trustedEnvironment=1]="trustedEnvironment",r[r.strongBox=2]="strongBox"})(_o||(_o={}));var Ya;(function(r){r[r.KM2=1]="KM2",r[r.KM3=2]="KM3",r[r.KM4=3]="KM4",r[r.KM4_1=4]="KM4_1",r[r.keyMint1=100]="keyMint1",r[r.keyMint2=200]="keyMint2"})(Ya||(Ya={}));class Hn{constructor(t={}){this.attestationVersion=Ya.KM4,this.attestationSecurityLevel=_o.software,this.keymasterVersion=0,this.keymasterSecurityLevel=_o.software,this.attestationChallenge=new Ge,this.uniqueId=new Ge,this.softwareEnforced=new Ae,this.teeEnforced=new Ae,Object.assign(this,t)}}O([L({type:W.Integer})],Hn.prototype,"attestationVersion",void 0);O([L({type:W.Enumerated})],Hn.prototype,"attestationSecurityLevel",void 0);O([L({type:W.Integer})],Hn.prototype,"keymasterVersion",void 0);O([L({type:W.Enumerated})],Hn.prototype,"keymasterSecurityLevel",void 0);O([L({type:Ge})],Hn.prototype,"attestationChallenge",void 0);O([L({type:Ge})],Hn.prototype,"uniqueId",void 0);O([L({type:Ae})],Hn.prototype,"softwareEnforced",void 0);O([L({type:Ae})],Hn.prototype,"teeEnforced",void 0);var ml;let bl=class extends Ae{};bl=O([ke({type:xe.Choice})],bl);let Mo=ml=class extends ar{constructor(t){super(t),Object.setPrototypeOf(this,ml.prototype)}findProperty(t){const n=this.find(i=>t in i);if(n)return n[t]}};Mo=ml=O([ke({type:xe.Sequence,itemType:bl})],Mo);class mi{constructor(t={}){this.attestationVersion=Ya.KM4,this.attestationSecurityLevel=_o.software,this.keymasterVersion=0,this.keymasterSecurityLevel=_o.software,this.attestationChallenge=new Ge,this.uniqueId=new Ge,this.softwareEnforced=new Mo,this.teeEnforced=new Mo,Object.assign(this,t)}}O([L({type:W.Integer})],mi.prototype,"attestationVersion",void 0);O([L({type:W.Enumerated})],mi.prototype,"attestationSecurityLevel",void 0);O([L({type:W.Integer})],mi.prototype,"keymasterVersion",void 0);O([L({type:W.Enumerated})],mi.prototype,"keymasterSecurityLevel",void 0);O([L({type:Ge})],mi.prototype,"attestationChallenge",void 0);O([L({type:Ge})],mi.prototype,"uniqueId",void 0);O([L({type:Mo})],mi.prototype,"softwareEnforced",void 0);O([L({type:Mo})],mi.prototype,"teeEnforced",void 0);class Uh{constructor(t={}){Object.assign(this,t)}}O([L({type:W.OctetString})],Uh.prototype,"packageName",void 0);O([L({type:W.Integer})],Uh.prototype,"version",void 0);class Vw{constructor(t={}){Object.assign(this,t)}}O([L({type:Uh,repeated:"set"})],Vw.prototype,"packageInfos",void 0);O([L({type:W.OctetString,repeated:"set"})],Vw.prototype,"signatureDigests",void 0);function Nn(r,t="base64url"){const n=Qt.toArrayBuffer(r,t==="base64url");return new Uint8Array(n)}function en(r,t="base64url"){return Qt.fromArrayBuffer(r,t==="base64url")}function r8(r){const t=Qt.toArrayBuffer(r,!0);return Qt.fromArrayBuffer(t)}function ms(r){return Qt.toString(r,!0)}function n8(r){return Qt.validate(r,!1)}function bs(r){return r=Oh(r),Qt.validate(r,!0)}function Oh(r){return r.replace(/=/g,"")}function ko(r){const t=new Uint8Array(r),n=_3(t,0),[i]=n;return i}function op(r){return M3(r)}function i8(r){const t=r.get(Ce.kty);return Fh(t)&&t===tn.OKP}function Vc(r){const t=r.get(Ce.kty);return Fh(t)&&t===tn.EC2}function Ph(r){const t=r.get(Ce.kty);return Fh(t)&&t===tn.RSA}var Ce;(function(r){r[r.kty=1]="kty",r[r.alg=3]="alg",r[r.crv=-1]="crv",r[r.x=-2]="x",r[r.y=-3]="y",r[r.n=-1]="n",r[r.e=-2]="e"})(Ce||(Ce={}));var tn;(function(r){r[r.OKP=1]="OKP",r[r.EC2=2]="EC2",r[r.RSA=3]="RSA"})(tn||(tn={}));function Fh(r){return Object.values(tn).indexOf(r)>=0}var Rr;(function(r){r[r.P256=1]="P256",r[r.P384=2]="P384",r[r.P521=3]="P521",r[r.ED25519=6]="ED25519",r[r.SECP256K1=8]="SECP256K1"})(Rr||(Rr={}));function o8(r){return Object.values(Rr).indexOf(r)>=0}var Ie;(function(r){r[r.ES256=-7]="ES256",r[r.EdDSA=-8]="EdDSA",r[r.ES384=-35]="ES384",r[r.ES512=-36]="ES512",r[r.PS256=-37]="PS256",r[r.PS384=-38]="PS384",r[r.PS512=-39]="PS512",r[r.ES256K=-47]="ES256K",r[r.RS256=-257]="RS256",r[r.RS384=-258]="RS384",r[r.RS512=-259]="RS512",r[r.RS1=-65535]="RS1"})(Ie||(Ie={}));function $s(r){return Object.values(Ie).indexOf(r)>=0}function vs(r){if([Ie.RS1].indexOf(r)>=0)return"SHA-1";if([Ie.ES256,Ie.PS256,Ie.RS256].indexOf(r)>=0)return"SHA-256";if([Ie.ES384,Ie.PS384,Ie.RS384].indexOf(r)>=0)return"SHA-384";if([Ie.ES512,Ie.PS512,Ie.RS512,Ie.EdDSA].indexOf(r)>=0)return"SHA-512";throw new Error(`Could not map COSE alg value of ${r} to a WebCrypto alg`)}let Zo;function Po(){return new Promise((t,n)=>{if(Zo)return t(Zo);const i=a8.stubThisGlobalThisCrypto();return i?(Zo=i,t(Zo)):n(new s8)})}class s8 extends Error{constructor(){super("An instance of the Crypto API could not be located"),this.name="MissingWebCrypto"}}const a8={stubThisGlobalThisCrypto:()=>globalThis.crypto,setCachedCrypto:r=>{Zo=r}};async function c8(r,t){const n=await Po(),i=vs(t),o=await n.subtle.digest(i,r);return new Uint8Array(o)}async function jw(r){return(await Po()).getRandomValues(r),r}async function Lh(r){const t=await Po(),{keyData:n,algorithm:i}=r;return t.subtle.importKey("jwk",n,i,!1,["verify"])}async function Kw(r){const{cosePublicKey:t,signature:n,data:i,shaHashOverride:o}=r,s=await Po(),a=t.get(Ce.alg),c=t.get(Ce.crv),f=t.get(Ce.x),h=t.get(Ce.y);if(!a)throw new Error("Public key was missing alg (EC2)");if(!c)throw new Error("Public key was missing crv (EC2)");if(!f)throw new Error("Public key was missing x (EC2)");if(!h)throw new Error("Public key was missing y (EC2)");let d;if(c===Rr.P256)d="P-256";else if(c===Rr.P384)d="P-384";else if(c===Rr.P521)d="P-521";else throw new Error(`Unexpected COSE crv value of ${c} (EC2)`);const g={kty:"EC",crv:d,x:en(f),y:en(h),ext:!1},S=await Lh({keyData:g,algorithm:{name:"ECDSA",namedCurve:d}});let D=vs(a);o&&(D=vs(o));const E={name:"ECDSA",hash:{name:D}};return s.subtle.verify(E,S,n,i)}function sp(r){if([Ie.EdDSA].indexOf(r)>=0)return"Ed25519";if([Ie.ES256,Ie.ES384,Ie.ES512,Ie.ES256K].indexOf(r)>=0)return"ECDSA";if([Ie.RS256,Ie.RS384,Ie.RS512,Ie.RS1].indexOf(r)>=0)return"RSASSA-PKCS1-v1_5";if([Ie.PS256,Ie.PS384,Ie.PS512].indexOf(r)>=0)return"RSA-PSS";throw new Error(`Could not map COSE alg value of ${r} to a WebCrypto key alg name`)}async function zw(r){const{cosePublicKey:t,signature:n,data:i,shaHashOverride:o}=r,s=await Po(),a=t.get(Ce.alg),c=t.get(Ce.n),f=t.get(Ce.e);if(!a)throw new Error("Public key was missing alg (RSA)");if(!$s(a))throw new Error(`Public key had invalid alg ${a} (RSA)`);if(!c)throw new Error("Public key was missing n (RSA)");if(!f)throw new Error("Public key was missing e (RSA)");const h={kty:"RSA",alg:"",n:en(c),e:en(f),ext:!1},d={name:sp(a),hash:{name:vs(a)}},g={name:sp(a)};if(o&&(d.hash.name=vs(o)),d.name==="RSASSA-PKCS1-v1_5")d.hash.name==="SHA-256"?h.alg="RS256":d.hash.name==="SHA-384"?h.alg="RS384":d.hash.name==="SHA-512"?h.alg="RS512":d.hash.name==="SHA-1"&&(h.alg="RS1");else if(d.name==="RSA-PSS"){let S=0;d.hash.name==="SHA-256"?(h.alg="PS256",S=32):d.hash.name==="SHA-384"?(h.alg="PS384",S=48):d.hash.name==="SHA-512"&&(h.alg="PS512",S=64),g.saltLength=S}else throw new Error(`Unexpected RSA key algorithm ${a} (${d.name})`);const x=await Lh({keyData:h,algorithm:d});return s.subtle.verify(g,x,n,i)}function qw(r){const t=fo(r);return[t.slice(0,8),t.slice(8,12),t.slice(12,16),t.slice(16,20),t.slice(20,32)].join("-")}function gn(r){let t;if(typeof r=="string")if(bs(r))t=r8(r);else if(n8(r))t=r;else throw new Error("Certificate is not a valid base64 or base64url string");else t=en(r,"base64");let n="";for(let i=0;i<Math.ceil(t.length/64);i+=1){const o=64*i;n+=`${t.substr(o,64)}
`}return n=`-----BEGIN CERTIFICATE-----
${n}-----END CERTIFICATE-----
`,n}function Hh(r){const t=ko(r),n=Uint8Array.from([4]),i=t.get(Ce.x),o=t.get(Ce.y);if(!i)throw new Error("COSE public key was missing x");return Sr(o?[n,i,o]:[n,i])}function f8(r){return u8.stubThis(ko(r))}const u8={stubThis:r=>r};function Gw(r){const t=ms(r),n=JSON.parse(t);return l8.stubThis(n)}const l8={stubThis:r=>r};function jc(r){return h8.stubThis(ko(r))}const h8={stubThis:r=>r};async function d8(){const r=new Uint8Array(32);return await jw(r),p8.stubThis(r)}const p8={stubThis:r=>r},ap={"2.5.4.6":"C","2.5.4.10":"O","2.5.4.11":"OU","2.5.4.3":"CN"};function xs(r){const t=$t.parse(r,wi),n=t.tbsCertificate,i={combined:""};n.issuer.forEach(([a])=>{const c=ap[a.type];c&&(i[c]=a.value.toString())}),i.combined=cp(i);const o={combined:""};n.subject.forEach(([a])=>{const c=ap[a.type];c&&(o[c]=a.value.toString())}),o.combined=cp(o);let s=!1;if(n.extensions)for(const a of n.extensions)a.extnID===OS&&(s=$t.parse(a.extnValue,Eh).cA);return{issuer:i,subject:o,version:n.version,basicConstraintsCA:s,notBefore:n.validity.notBefore.getTime(),notAfter:n.validity.notAfter.getTime(),parsedCertificate:t}}function cp(r){const t=[];return r.C&&t.push(r.C),r.O&&t.push(r.O),r.OU&&t.push(r.OU),r.CN&&t.push(r.CN),t.join(" : ")}function Ww(r){return g8.stubThis(r)}const g8={stubThis:r=>O3.fetch(r)},fp={};async function y8(r){var x,S;const{extensions:t}=r.tbsCertificate;if(!t)return!1;let n,i,o;t.forEach(D=>{D.extnID===US?n=$t.parse(D.extnValue,Tc):D.extnID===HS?i=$t.parse(D.extnValue,$S):D.extnID===PS&&(o=$t.parse(D.extnValue,Ka))});let s;n&&n.keyIdentifier?s=fo(new Uint8Array(n.keyIdentifier.buffer)):i&&(s=fo(new Uint8Array(i.buffer)));const a=fo(new Uint8Array(r.tbsCertificate.serialNumber));if(s){const D=fp[s];if(D){const E=new Date;if(!D.nextUpdate||D.nextUpdate>E)return D.revokedCerts.indexOf(a)>=0}}const c=(S=(x=o==null?void 0:o[0].distributionPoint)==null?void 0:x.fullName)==null?void 0:S[0].uniformResourceIdentifier;if(!c)return!1;let f;try{f=await(await Ww(c)).arrayBuffer()}catch{return!1}let h;try{h=$t.parse(f,Pc)}catch{return!1}const d={revokedCerts:[],nextUpdate:void 0};h.tbsCertList.nextUpdate&&(d.nextUpdate=h.tbsCertList.nextUpdate.getTime());const g=h.tbsCertList.revokedCertificates;if(g){for(const D of g){const E=fo(new Uint8Array(D.userCertificate));d.revokedCerts.push(E)}return s&&(fp[s]=d),d.revokedCerts.indexOf(a)>=0}return!1}function w8(r){let t;try{t=ko(r)}catch(n){const i=n;throw new Error(`Error decoding authenticator extensions: ${i.message}`)}return Jw(t)}function Jw(r){const t={};for(const[n,i]of r)i instanceof Map?t[n]=Jw(i):t[n]=i;return t}function Yw(r){if(r.byteLength<37)throw new Error(`Authenticator data was ${r.byteLength} bytes, expected at least 37 bytes`);let t=0;const n=Za(r),i=r.slice(t,t+=32),o=r.slice(t,t+=1),s=o[0],a={up:!!(s&1),uv:!!(s&4),be:!!(s&8),bs:!!(s&16),at:!!(s&64),ed:!!(s&128),flagsInt:s},c=r.slice(t,t+4),f=n.getUint32(t,!1);t+=4;let h,d,g;if(a.at){h=r.slice(t,t+=16);const D=n.getUint16(t);t+=2,d=r.slice(t,t+=D);const E=B8("a301634f4b500327206745643235353139"),_=r.slice(t,t+E.byteLength);let T=!1;hn(E,_)&&(T=!0,r[t]=164);const F=ko(r.slice(t)),U=Uint8Array.from(op(F));T&&(r[t]=163),g=U,t+=U.byteLength}let x,S;if(a.ed){const D=ko(r.slice(t));S=Uint8Array.from(op(D)),x=w8(S),t+=S.byteLength}if(r.byteLength>t)throw new Error("Leftover bytes detected while parsing authenticator data");return m8.stubThis({rpIdHash:i,flagsBuf:o,flags:a,counter:f,counterBuf:c,aaguid:h,credentialID:d,credentialPublicKey:g,extensionsData:x,extensionsDataBuffer:S})}const m8={stubThis:r=>r};function Zi(r,t=-7){return typeof r=="string"&&(r=Vs(r)),c8(r,t)}function vl(r){let t;if(r==="1.2.840.10045.4.3.2")t=Ie.ES256;else if(r==="1.2.840.10045.4.3.3")t=Ie.ES384;else if(r==="1.2.840.10045.4.3.4")t=Ie.ES512;else if(r==="1.2.840.113549.1.1.11")t=Ie.RS256;else if(r==="1.2.840.113549.1.1.12")t=Ie.RS384;else if(r==="1.2.840.113549.1.1.13")t=Ie.RS512;else if(r==="1.2.840.113549.1.1.5")t=Ie.RS1;else throw new Error(`Unable to map X.509 signature algorithm ${r} to a COSE algorithm`);return t}function Zw(r){let t=new Map;const n=$t.parse(r,wi),{tbsCertificate:i}=n,{subjectPublicKeyInfo:o,signature:s}=i,a=s.algorithm,c=o.algorithm.algorithm;if(c===VS){if(!o.algorithm.parameters)throw new Error("Certificate public key was missing parameters (EC2)");const f=$t.parse(new Uint8Array(o.algorithm.parameters),Ji);let h=-999;const{namedCurve:d}=f;if(d===WS)h=Rr.P256;else if(d===JS)h=Rr.P384;else throw new Error(`Certificate public key contained unexpected namedCurve ${d} (EC2)`);const g=new Uint8Array(o.subjectPublicKey);let x,S;if(g[0]===4){let E=1;const _=(g.length-1)/2;x=g.slice(E,E+=_),S=g.slice(E)}else throw new Error('TODO: Figure out how to handle public keys in "compressed form"');const D=new Map;D.set(Ce.kty,tn.EC2),D.set(Ce.alg,vl(a)),D.set(Ce.crv,h),D.set(Ce.x,x),D.set(Ce.y,S),t=D}else if(c==="1.2.840.113549.1.1.1"){const f=$t.parse(o.subjectPublicKey,Rh),h=new Map;h.set(Ce.kty,tn.RSA),h.set(Ce.alg,vl(a)),h.set(Ce.n,new Uint8Array(f.modulus)),h.set(Ce.e,new Uint8Array(f.publicExponent)),t=h}else throw new Error(`Certificate public key contained unexpected algorithm ID ${c}`);return t}function di(r){const{signature:t,data:n,credentialPublicKey:i,x509Certificate:o,hashAlgorithm:s}=r;if(!o&&!i)throw new Error('Must declare either "leafCert" or "credentialPublicKey"');if(o&&i)throw new Error('Must not declare both "leafCert" and "credentialPublicKey"');let a=new Map;return i?a=jc(i):o&&(a=Zw(o)),b8.stubThis(S8({cosePublicKey:a,signature:t,data:n,shaHashOverride:s}))}const b8={stubThis:r=>r};function ma(r){const t=r.replace("-----BEGIN CERTIFICATE-----","").replace("-----END CERTIFICATE-----","").replace(/[\n ]/g,"");return Nn(t,"base64")}async function bi(r,t=[]){if(t.length===0)return!0;let n=!1,i;for(const o of t)try{const s=r.concat([o]);await v8(s),n=!1,i=void 0;break}catch(s){if(s instanceof xl)n=!0;else if(s instanceof rs)i=s.message;else throw s}if(n)throw new xl;if(i)throw new rs(i);return!0}async function v8(r){if(new Set(r).size!==r.length)throw new Error("Invalid certificate path: found duplicate certificates");for(let t=0;t<r.length;t+=1){const n=r[t],i=t===0,o=t+1>=r.length;let s="";o?s=n:s=r[t+1];const a=xs(ma(n)),c=xs(ma(s)),f=a.parsedCertificate;if(await y8(f))throw new Error("Found revoked certificate in certificate path");const{notBefore:d,notAfter:g}=c,x=new Date(Date.now());if(d>x||g<x)throw i?new rs(`Leaf certificate is not yet valid or expired: ${s}`):o?new rs(`Root certificate is not yet valid or expired: ${s}`):new rs(`Intermediate certificate is not yet valid or expired: ${s}`);if(a.issuer.combined!==c.subject.combined)throw new xl;const S=Mc.serialize(f.tbsCertificate),D=f.signatureValue,E=vl(f.signatureAlgorithm.algorithm),_=ma(s);if(!await di({data:new Uint8Array(S),signature:new Uint8Array(D),x509Certificate:_,hashAlgorithm:E}))throw new Error("Invalid certificate path: invalid signature")}return!0}class xl extends Error{constructor(){super("Subject issuer did not match issuer subject"),this.name="InvalidSubjectAndIssuer"}}class rs extends Error{constructor(t){super(t),this.name="CertificateNotYetValidOrExpired"}}async function x8(r){const{cosePublicKey:t,signature:n,data:i}=r,o=await Po(),s=t.get(Ce.alg),a=t.get(Ce.crv),c=t.get(Ce.x);if(!s)throw new Error("Public key was missing alg (OKP)");if(!$s(s))throw new Error(`Public key had invalid alg ${s} (OKP)`);if(!a)throw new Error("Public key was missing crv (OKP)");if(!c)throw new Error("Public key was missing x (OKP)");let f;if(a===Rr.ED25519)f="Ed25519";else throw new Error(`Unexpected COSE crv value of ${a} (OKP)`);const h={kty:"OKP",crv:f,alg:"EdDSA",x:en(c),ext:!1},g=await Lh({keyData:h,algorithm:{name:f,namedCurve:f}}),x={name:f};return o.subtle.verify(x,g,n,i)}function A8(r,t){const n=$t.parse(r,Lc),i=new Uint8Array(n.r),o=new Uint8Array(n.s),s=E8(t),a=up(i,s),c=up(o,s);return Sr([a,c])}function E8(r){switch(r){case Rr.P256:return 32;case Rr.P384:return 48;case Rr.P521:return 66;default:throw new Error(`Unexpected COSE crv value of ${r} (EC2)`)}}function up(r,t){let n;if(r.length<t)n=new Uint8Array(t),n.set(r,t-r.length);else if(r.length===t)n=r;else if(r.length===t+1&&r[0]===0&&(r[1]&128)===128)n=r.subarray(1);else throw new Error(`Invalid signature component length ${r.length}, expected ${t}`);return n}function S8(r){const{cosePublicKey:t,signature:n,data:i,shaHashOverride:o}=r;if(Vc(t)){const a=t.get(Ce.crv);if(!o8(a))throw new Error(`unknown COSE curve ${a}`);const c=A8(n,a);return Kw({cosePublicKey:t,signature:c,data:i,shaHashOverride:o})}else{if(Ph(t))return zw({cosePublicKey:t,signature:n,data:i,shaHashOverride:o});if(i8(t))return x8({cosePublicKey:t,signature:n,data:i})}const s=t.get(Ce.kty);throw new Error(`Signature verification with public key of kty ${s} is not supported by this method`)}function hn(r,t){return r.length!=t.length?!1:r.every((n,i)=>n===t[i])}function fo(r){return Array.from(r,n=>n.toString(16).padStart(2,"0")).join("")}function B8(r){if(!(r.length!==0&&r.length%2===0&&!/[^a-fA-F0-9]/u.test(r)))throw new Error("Invalid hex string");const n=r.match(/.{1,2}/g)??[];return Uint8Array.from(n.map(i=>parseInt(i,16)))}function Sr(r){let t=0;const n=r.reduce((o,s)=>o+s.length,0),i=new Uint8Array(n);return r.forEach(o=>{i.set(o,t),t+=o.length}),i}function D8(r){return new globalThis.TextDecoder("utf-8").decode(r)}function Vs(r){return new globalThis.TextEncoder().encode(r)}function C8(r){return Uint8Array.from(r.split("").map(t=>t.charCodeAt(0)))}function Za(r){return new DataView(r.buffer,r.byteOffset,r.length)}async function Xw(){const r=new Uint8Array(32);return await jw(r),I8.stubThis(r)}const I8={stubThis:r=>r},_8=[-8,-7,-36,-37,-38,-39,-257,-258,-259,-65535],M8={residentKey:"preferred",userVerification:"preferred"},k8=[-8,-7,-257];async function T8(r){const{rpName:t,rpID:n,userName:i,userID:o,challenge:s=await Xw(),userDisplayName:a="",timeout:c=6e4,attestationType:f="none",excludeCredentials:h=[],authenticatorSelection:d=M8,extensions:g,supportedAlgorithmIDs:x=k8}=r,S=x.map(_=>({alg:_,type:"public-key"}));d.residentKey===void 0?d.requireResidentKey&&(d.residentKey="required"):d.requireResidentKey=d.residentKey==="required";let D=s;if(typeof D=="string"&&(D=Vs(D)),typeof o=="string")throw new Error("String values for `userID` are no longer supported. See https://simplewebauthn.dev/docs/advanced/server/custom-user-ids");let E=o;return E||(E=await d8()),{challenge:en(D),rp:{name:t,id:n},user:{id:en(E),name:i,displayName:a},pubKeyCredParams:S,timeout:c,attestation:f,excludeCredentials:h.map(_=>{if(!bs(_.id))throw new Error(`excludeCredential id "${_.id}" is not a valid base64url string`);return{..._,id:Oh(_.id),type:"public-key"}}),authenticatorSelection:d,extensions:{...g,credProps:!0}}}function Qw({be:r,bs:t}){const n=t;let i="singleDevice";if(r&&(i="multiDevice"),i==="singleDevice"&&n)throw new N8("Single-device credential indicated that it was backed up, which should be impossible.");return{credentialDeviceType:i,credentialBackedUp:n}}class N8 extends Error{constructor(t){super(t),this.name="InvalidBackupFlags"}}async function e1(r,t){try{return await Promise.any(t.map(i=>new Promise((o,s)=>{Zi(C8(i)).then(a=>{hn(r,a)?o(i):s()})})))}catch(n){throw n.name==="AggregateError"?new R8:n}}class R8 extends Error{constructor(){super("Unexpected RP ID hash"),this.name="UnexpectedRPIDHash"}}const U8=`-----BEGIN CERTIFICATE-----
MIIDdTCCAl2gAwIBAgILBAAAAAABFUtaw5QwDQYJKoZIhvcNAQEFBQAwVzELMAkG
A1UEBhMCQkUxGTAXBgNVBAoTEEdsb2JhbFNpZ24gbnYtc2ExEDAOBgNVBAsTB1Jv
b3QgQ0ExGzAZBgNVBAMTEkdsb2JhbFNpZ24gUm9vdCBDQTAeFw05ODA5MDExMjAw
MDBaFw0yODAxMjgxMjAwMDBaMFcxCzAJBgNVBAYTAkJFMRkwFwYDVQQKExBHbG9i
YWxTaWduIG52LXNhMRAwDgYDVQQLEwdSb290IENBMRswGQYDVQQDExJHbG9iYWxT
aWduIFJvb3QgQ0EwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQDaDuaZ
jc6j40+Kfvvxi4Mla+pIH/EqsLmVEQS98GPR4mdmzxzdzxtIK+6NiY6arymAZavp
xy0Sy6scTHAHoT0KMM0VjU/43dSMUBUc71DuxC73/OlS8pF94G3VNTCOXkNz8kHp
1Wrjsok6Vjk4bwY8iGlbKk3Fp1S4bInMm/k8yuX9ifUSPJJ4ltbcdG6TRGHRjcdG
snUOhugZitVtbNV4FpWi6cgKOOvyJBNPc1STE4U6G7weNLWLBYy5d4ux2x8gkasJ
U26Qzns3dLlwR5EiUWMWea6xrkEmCMgZK9FGqkjWZCrXgzT/LCrBbBlDSgeF59N8
9iFo7+ryUp9/k5DPAgMBAAGjQjBAMA4GA1UdDwEB/wQEAwIBBjAPBgNVHRMBAf8E
BTADAQH/MB0GA1UdDgQWBBRge2YaRQ2XyolQL30EzTSo//z9SzANBgkqhkiG9w0B
AQUFAAOCAQEA1nPnfE920I2/7LqivjTFKDK1fPxsnCwrvQmeU79rXqoRSLblCKOz
yj1hTdNGCbM+w6DjY1Ub8rrvrTnhQ7k4o+YviiY776BQVvnGCv04zcQLcFGUl5gE
38NflNUVyRRBnMRddWQVDf9VMOyGj/8N7yy5Y0b2qvzfvGn9LhJIZJrglfCm7ymP
AbEVtQwdpf5pLGkkeB6zpxxxYu7KyJesF12KwvhHhm4qxFYxldBniYUr+WymXUad
DKqC5JlR3XC321Y9YeRq4VzW9v493kHMB65jUr9TU/Qr6cf9tveCX4XSQRjbgbME
HMUfpIBvFSDJ3gyICh3WZlXi/EjJKSZp4A==
-----END CERTIFICATE-----
`,O8=`-----BEGIN CERTIFICATE-----
MIIFYDCCA0igAwIBAgIJAOj6GWMU0voYMA0GCSqGSIb3DQEBCwUAMBsxGTAXBgNV
BAUTEGY5MjAwOWU4NTNiNmIwNDUwHhcNMTYwNTI2MTYyODUyWhcNMjYwNTI0MTYy
ODUyWjAbMRkwFwYDVQQFExBmOTIwMDllODUzYjZiMDQ1MIICIjANBgkqhkiG9w0B
AQEFAAOCAg8AMIICCgKCAgEAr7bHgiuxpwHsK7Qui8xUFmOr75gvMsd/dTEDDJdS
Sxtf6An7xyqpRR90PL2abxM1dEqlXnf2tqw1Ne4Xwl5jlRfdnJLmN0pTy/4lj4/7
tv0Sk3iiKkypnEUtR6WfMgH0QZfKHM1+di+y9TFRtv6y//0rb+T+W8a9nsNL/ggj
nar86461qO0rOs2cXjp3kOG1FEJ5MVmFmBGtnrKpa73XpXyTqRxB/M0n1n/W9nGq
C4FSYa04T6N5RIZGBN2z2MT5IKGbFlbC8UrW0DxW7AYImQQcHtGl/m00QLVWutHQ
oVJYnFPlXTcHYvASLu+RhhsbDmxMgJJ0mcDpvsC4PjvB+TxywElgS70vE0XmLD+O
JtvsBslHZvPBKCOdT0MS+tgSOIfga+z1Z1g7+DVagf7quvmag8jfPioyKvxnK/Eg
sTUVi2ghzq8wm27ud/mIM7AY2qEORR8Go3TVB4HzWQgpZrt3i5MIlCaY504LzSRi
igHCzAPlHws+W0rB5N+er5/2pJKnfBSDiCiFAVtCLOZ7gLiMm0jhO2B6tUXHI/+M
RPjy02i59lINMRRev56GKtcd9qO/0kUJWdZTdA2XoS82ixPvZtXQpUpuL12ab+9E
aDK8Z4RHJYYfCT3Q5vNAXaiWQ+8PTWm2QgBR/bkwSWc+NpUFgNPN9PvQi8WEg5Um
AGMCAwEAAaOBpjCBozAdBgNVHQ4EFgQUNmHhAHyIBQlRi0RsR/8aTMnqTxIwHwYD
VR0jBBgwFoAUNmHhAHyIBQlRi0RsR/8aTMnqTxIwDwYDVR0TAQH/BAUwAwEB/zAO
BgNVHQ8BAf8EBAMCAYYwQAYDVR0fBDkwNzA1oDOgMYYvaHR0cHM6Ly9hbmRyb2lk
Lmdvb2dsZWFwaXMuY29tL2F0dGVzdGF0aW9uL2NybC8wDQYJKoZIhvcNAQELBQAD
ggIBACDIw41L3KlXG0aMiS//cqrG+EShHUGo8HNsw30W1kJtjn6UBwRM6jnmiwfB
Pb8VA91chb2vssAtX2zbTvqBJ9+LBPGCdw/E53Rbf86qhxKaiAHOjpvAy5Y3m00m
qC0w/Zwvju1twb4vhLaJ5NkUJYsUS7rmJKHHBnETLi8GFqiEsqTWpG/6ibYCv7rY
DBJDcR9W62BW9jfIoBQcxUCUJouMPH25lLNcDc1ssqvC2v7iUgI9LeoM1sNovqPm
QUiG9rHli1vXxzCyaMTjwftkJLkf6724DFhuKug2jITV0QkXvaJWF4nUaHOTNA4u
JU9WDvZLI1j83A+/xnAJUucIv/zGJ1AMH2boHqF8CY16LpsYgBt6tKxxWH00XcyD
CdW2KlBCeqbQPcsFmWyWugxdcekhYsAWyoSf818NUsZdBWBaR/OukXrNLfkQ79Iy
ZohZbvabO/X+MVT3rriAoKc8oE2Uws6DF+60PV7/WIPjNvXySdqspImSN78mflxD
qwLqRBYkA3I75qppLGG9rp7UCdRjxMl8ZDBld+7yvHVgt1cVzJx9xnyGCC23Uaic
MDSXYrB4I4WHXPGjxhZuCuPBLTdOLU8YRvMYdEvYebWHMpvwGCF6bAx3JBpIeOQ1
wDB5y0USicV3YgYGmi+NZfhA4URSh77Yd6uuJOJENRaNVTzk
-----END CERTIFICATE-----
`,P8=`-----BEGIN CERTIFICATE-----
MIIFHDCCAwSgAwIBAgIJANUP8luj8tazMA0GCSqGSIb3DQEBCwUAMBsxGTAXBgNV
BAUTEGY5MjAwOWU4NTNiNmIwNDUwHhcNMTkxMTIyMjAzNzU4WhcNMzQxMTE4MjAz
NzU4WjAbMRkwFwYDVQQFExBmOTIwMDllODUzYjZiMDQ1MIICIjANBgkqhkiG9w0B
AQEFAAOCAg8AMIICCgKCAgEAr7bHgiuxpwHsK7Qui8xUFmOr75gvMsd/dTEDDJdS
Sxtf6An7xyqpRR90PL2abxM1dEqlXnf2tqw1Ne4Xwl5jlRfdnJLmN0pTy/4lj4/7
tv0Sk3iiKkypnEUtR6WfMgH0QZfKHM1+di+y9TFRtv6y//0rb+T+W8a9nsNL/ggj
nar86461qO0rOs2cXjp3kOG1FEJ5MVmFmBGtnrKpa73XpXyTqRxB/M0n1n/W9nGq
C4FSYa04T6N5RIZGBN2z2MT5IKGbFlbC8UrW0DxW7AYImQQcHtGl/m00QLVWutHQ
oVJYnFPlXTcHYvASLu+RhhsbDmxMgJJ0mcDpvsC4PjvB+TxywElgS70vE0XmLD+O
JtvsBslHZvPBKCOdT0MS+tgSOIfga+z1Z1g7+DVagf7quvmag8jfPioyKvxnK/Eg
sTUVi2ghzq8wm27ud/mIM7AY2qEORR8Go3TVB4HzWQgpZrt3i5MIlCaY504LzSRi
igHCzAPlHws+W0rB5N+er5/2pJKnfBSDiCiFAVtCLOZ7gLiMm0jhO2B6tUXHI/+M
RPjy02i59lINMRRev56GKtcd9qO/0kUJWdZTdA2XoS82ixPvZtXQpUpuL12ab+9E
aDK8Z4RHJYYfCT3Q5vNAXaiWQ+8PTWm2QgBR/bkwSWc+NpUFgNPN9PvQi8WEg5Um
AGMCAwEAAaNjMGEwHQYDVR0OBBYEFDZh4QB8iAUJUYtEbEf/GkzJ6k8SMB8GA1Ud
IwQYMBaAFDZh4QB8iAUJUYtEbEf/GkzJ6k8SMA8GA1UdEwEB/wQFMAMBAf8wDgYD
VR0PAQH/BAQDAgIEMA0GCSqGSIb3DQEBCwUAA4ICAQBOMaBc8oumXb2voc7XCWnu
XKhBBK3e2KMGz39t7lA3XXRe2ZLLAkLM5y3J7tURkf5a1SutfdOyXAmeE6SRo83U
h6WszodmMkxK5GM4JGrnt4pBisu5igXEydaW7qq2CdC6DOGjG+mEkN8/TA6p3cno
L/sPyz6evdjLlSeJ8rFBH6xWyIZCbrcpYEJzXaUOEaxxXxgYz5/cTiVKN2M1G2ok
QBUIYSY6bjEL4aUN5cfo7ogP3UvliEo3Eo0YgwuzR2v0KR6C1cZqZJSTnghIC/vA
D32KdNQ+c3N+vl2OTsUVMC1GiWkngNx1OO1+kXW+YTnnTUOtOIswUP/Vqd5SYgAI
mMAfY8U9/iIgkQj6T2W6FsScy94IN9fFhE1UtzmLoBIuUFsVXJMTz+Jucth+IqoW
Fua9v1R93/k98p41pjtFX+H8DslVgfP097vju4KDlqN64xV1grw3ZLl4CiOe/A91
oeLm2UHOq6wn3esB4r2EIQKb6jTVGu5sYCcdWpXr0AUVqcABPdgL+H7qJguBw09o
jm6xNIrw2OocrDKsudk/okr/AwqEyPKw9WnMlQgLIKw1rODG2NvU9oR3GVGdMkUB
ZutL8VuFkERQGt6vQ2OCw0sV47VMkuYbacK/xyZFiRcrPJPb41zgbQj9XAEyLKCH
ex0SdDrx+tWUDqG8At2JHA==
-----END CERTIFICATE-----
`,F8=`-----BEGIN CERTIFICATE-----
MIICEjCCAZmgAwIBAgIQaB0BbHo84wIlpQGUKEdXcTAKBggqhkjOPQQDAzBLMR8w
HQYDVQQDDBZBcHBsZSBXZWJBdXRobiBSb290IENBMRMwEQYDVQQKDApBcHBsZSBJ
bmMuMRMwEQYDVQQIDApDYWxpZm9ybmlhMB4XDTIwMDMxODE4MjEzMloXDTQ1MDMx
NTAwMDAwMFowSzEfMB0GA1UEAwwWQXBwbGUgV2ViQXV0aG4gUm9vdCBDQTETMBEG
A1UECgwKQXBwbGUgSW5jLjETMBEGA1UECAwKQ2FsaWZvcm5pYTB2MBAGByqGSM49
AgEGBSuBBAAiA2IABCJCQ2pTVhzjl4Wo6IhHtMSAzO2cv+H9DQKev3//fG59G11k
xu9eI0/7o6V5uShBpe1u6l6mS19S1FEh6yGljnZAJ+2GNP1mi/YK2kSXIuTHjxA/
pcoRf7XkOtO4o1qlcaNCMEAwDwYDVR0TAQH/BAUwAwEB/zAdBgNVHQ4EFgQUJtdk
2cV4wlpn0afeaxLQG2PxxtcwDgYDVR0PAQH/BAQDAgEGMAoGCCqGSM49BAMDA2cA
MGQCMFrZ+9DsJ1PW9hfNdBywZDsWDbWFp28it1d/5w2RPkRX3Bbn/UbDTNLx7Jr3
jAGGiQIwHFj+dJZYUJR786osByBelJYsVZd2GbHQu209b5RCmGQ21gpSAk9QZW4B
1bWeT0vT
-----END CERTIFICATE-----
`,L8=`-----BEGIN CERTIFICATE-----
MIIDXzCCAkegAwIBAgILBAAAAAABIVhTCKIwDQYJKoZIhvcNAQELBQAwTDEgMB4G
A1UECxMXR2xvYmFsU2lnbiBSb290IENBIC0gUjMxEzARBgNVBAoTCkdsb2JhbFNp
Z24xEzARBgNVBAMTCkdsb2JhbFNpZ24wHhcNMDkwMzE4MTAwMDAwWhcNMjkwMzE4
MTAwMDAwWjBMMSAwHgYDVQQLExdHbG9iYWxTaWduIFJvb3QgQ0EgLSBSMzETMBEG
A1UEChMKR2xvYmFsU2lnbjETMBEGA1UEAxMKR2xvYmFsU2lnbjCCASIwDQYJKoZI
hvcNAQEBBQADggEPADCCAQoCggEBAMwldpB5BngiFvXAg7aEyiie/QV2EcWtiHL8
RgJDx7KKnQRfJMsuS+FggkbhUqsMgUdwbN1k0ev1LKMPgj0MK66X17YUhhB5uzsT
gHeMCOFJ0mpiLx9e+pZo34knlTifBtc+ycsmWQ1z3rDI6SYOgxXG71uL0gRgykmm
KPZpO/bLyCiR5Z2KYVc3rHQU3HTgOu5yLy6c+9C7v/U9AOEGM+iCK65TpjoWc4zd
QQ4gOsC0p6Hpsk+QLjJg6VfLuQSSaGjlOCZgdbKfd/+RFO+uIEn8rUAVSNECMWEZ
XriX7613t2Saer9fwRPvm2L7DWzgVGkWqQPabumDk3F2xmmFghcCAwEAAaNCMEAw
DgYDVR0PAQH/BAQDAgEGMA8GA1UdEwEB/wQFMAMBAf8wHQYDVR0OBBYEFI/wS3+o
LkUkrk1Q+mOai97i3Ru8MA0GCSqGSIb3DQEBCwUAA4IBAQBLQNvAUKr+yAzv95ZU
RUm7lgAJQayzE4aGKAczymvmdLm6AC2upArT9fHxD4q/c2dKg8dEe3jgr25sbwMp
jjM5RcOO5LlXbKr8EpbsU8Yt5CRsuZRj+9xTaGdWPoO4zzUhw8lo/s7awlOqzJCK
6fBdRoyV3XpYKBovHd7NADdBj+1EbddTKJd+82cEHhXXipa0095MJ6RMG3NzdvQX
mcIfeg7jLQitChws/zyrVQ4PkX4268NXSb7hLi18YIvDQVETI53O9zJrlAGomecs
Mx86OyXShkDOOyyGeMlhLxS67ttVb9+E7gUJTb0o2HLO02JQZR7rkpeDMdmztcpH
WD9f
-----END CERTIFICATE-----
`;class H8{constructor(){Object.defineProperty(this,"pemCertificates",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.pemCertificates=new Map}setRootCertificates(t){const{identifier:n,certificates:i}=t,o=[];for(const s of i)s instanceof Uint8Array?o.push(gn(s)):o.push(s);this.pemCertificates.set(n,o)}getRootCertificates(t){const{identifier:n}=t;return this.pemCertificates.get(n)??[]}}const Fo=new H8;Fo.setRootCertificates({identifier:"android-key",certificates:[O8,P8]});Fo.setRootCertificates({identifier:"android-safetynet",certificates:[U8]});Fo.setRootCertificates({identifier:"apple",certificates:[F8]});Fo.setRootCertificates({identifier:"mds",certificates:[L8]});async function $8(r){const{attStmt:t,clientDataHash:n,rpIdHash:i,credentialID:o,credentialPublicKey:s,aaguid:a,rootCertificates:c}=r,f=Uint8Array.from([0]),h=Hh(s),d=Sr([f,i,n,o,h]),g=t.get("sig"),x=t.get("x5c");if(!x)throw new Error("No attestation certificate provided in attestation statement (FIDOU2F)");if(!g)throw new Error("No attestation signature provided in attestation statement (FIDOU2F)");const S=Number.parseInt(fo(a),16);if(S!==0)throw new Error(`AAGUID "${S}" was not expected value`);try{await bi(x.map(gn),c)}catch(D){const E=D;throw new Error(`${E.message} (FIDOU2F)`)}return di({signature:g,data:d,x509Certificate:x[0],hashAlgorithm:Ie.ES256})}function V8(r){const t=r.split(".");return[JSON.parse(ms(t[0])),JSON.parse(ms(t[1])),t[2]]}function j8(r,t){const[n,i,o]=r.split("."),s=Zw(t),a=Vs(`${n}.${i}`),c=Nn(o);if(Vc(s))return Kw({data:a,signature:c,cosePublicKey:s,shaHashOverride:Ie.ES256});if(Ph(s))return zw({data:a,signature:c,cosePublicKey:s});const f=s.get(Ce.kty);throw new Error(`JWT verification with public key of kty ${f} is not supported by this method`)}const K8="https://mds.fidoalliance.org/";var gr;(function(r){r[r.DISABLED=0]="DISABLED",r[r.REFRESHING=1]="REFRESHING",r[r.READY=2]="READY"})(gr||(gr={}));class z8{constructor(){Object.defineProperty(this,"mdsCache",{enumerable:!0,configurable:!0,writable:!0,value:{}}),Object.defineProperty(this,"statementCache",{enumerable:!0,configurable:!0,writable:!0,value:{}}),Object.defineProperty(this,"state",{enumerable:!0,configurable:!0,writable:!0,value:gr.DISABLED}),Object.defineProperty(this,"verificationMode",{enumerable:!0,configurable:!0,writable:!0,value:"strict"})}async initialize(t={}){const{mdsServers:n=[K8],statements:i,verificationMode:o}=t;if(this.setState(gr.REFRESHING),i!=null&&i.length&&i.forEach(s=>{s.aaguid&&(this.statementCache[s.aaguid]={entry:{metadataStatement:s,statusReports:[],timeOfLastStatusChange:"1970-01-01"},url:""})}),n!=null&&n.length){Object.keys(this.statementCache).length,n.length;for(const s of n)try{await this.downloadBlob({url:s,no:0,nextUpdate:new Date(0)})}catch{}Object.keys(this.statementCache).length}o&&(this.verificationMode=o),this.setState(gr.READY)}async getStatement(t){if(this.state===gr.DISABLED||!t)return;t instanceof Uint8Array&&(t=qw(t)),await this.pauseUntilReady();const n=this.statementCache[t];if(!n){if(this.verificationMode==="strict")throw new Error(`No metadata statement found for aaguid "${t}"`);return}if(n.url){const o=this.mdsCache[n.url];if(new Date>o.nextUpdate)try{this.setState(gr.REFRESHING),await this.downloadBlob(o)}finally{this.setState(gr.READY)}}const{entry:i}=n;for(const o of i.statusReports){const{status:s}=o;if(s==="USER_VERIFICATION_BYPASS"||s==="ATTESTATION_KEY_COMPROMISE"||s==="USER_KEY_REMOTE_COMPROMISE"||s==="USER_KEY_PHYSICAL_COMPROMISE")throw new Error(`Detected compromised aaguid "${t}"`)}return i.metadataStatement}async downloadBlob(t){const{url:n,no:i}=t,s=await(await Ww(n)).text(),a=V8(s),c=a[0],f=a[1];if(f.no<=i)throw new Error(`Latest BLOB no. "${f.no}" is not greater than previous ${i}`);const h=c.x5c.map(gn);try{const E=Fo.getRootCertificates({identifier:"mds"});await bi(h,E)}catch(E){const _=E;throw new Error(`BLOB certificate path could not be validated: ${_.message}`)}const d=h[0];if(!await j8(s,ma(d)))throw new Error("BLOB signature could not be verified");for(const E of f.entries)E.aaguid&&(this.statementCache[E.aaguid]={entry:E,url:n});const[x,S,D]=f.nextUpdate.split("-");this.mdsCache[n]={...t,no:f.no,nextUpdate:new Date(parseInt(x,10),parseInt(S,10)-1,parseInt(D,10))}}pauseUntilReady(){return this.state===gr.READY?new Promise(n=>{n()}):new Promise((n,i)=>{let a=700;const c=globalThis.setInterval(()=>{a<1?(clearInterval(c),i(`State did not become ready in ${7e4/1e3} seconds`)):this.state===gr.READY&&(clearInterval(c),n()),a-=1},100)})}setState(t){this.state=t,t===gr.DISABLED||t===gr.REFRESHING||gr.READY}}const Kc=new z8;async function zc({statement:r,credentialPublicKey:t,x5c:n,attestationStatementAlg:i}){const{authenticationAlgorithms:o,authenticatorGetInfo:s,attestationRootCertificates:a}=r,c=new Set;o.forEach(_=>{const T=lp[_];T&&c.add(T)});const f=jc(t),h=f.get(Ce.kty),d=f.get(Ce.alg);if(!h)throw new Error("Credential public key was missing kty");if(!d)throw new Error("Credential public key was missing alg");if(!h)throw new Error("Credential public key was missing kty");const g={kty:h,alg:d};if(Vc(f)){const _=f.get(Ce.crv);g.crv=_}let x=!1;for(const _ of c)if(_.alg===g.alg&&_.kty===g.kty&&((_.kty===tn.EC2||_.kty===tn.OKP)&&(_.crv,g.crv),x=!0),x)break;if(!x){const _=o.map(U=>`'${U}' (COSE info: ${hp(lp[U])})`),T=JSON.stringify(_,null,2).replace(/"/g,""),F=hp(g);throw new Error(`Public key parameters ${F} did not match any of the following metadata algorithms:
${T}`)}if(i!==void 0&&(s==null?void 0:s.algorithms)!==void 0){const _=s.algorithms.map(T=>T.alg);if(_.indexOf(i)<0)throw new Error(`Attestation statement alg ${i} did not match one of ${_}`)}const S=n.map(gn),D=a.map(gn);let E=!1;if(S.length===1&&D.indexOf(S[0])>=0&&(E=!0),!E)try{await bi(S,D)}catch(_){const T=_;throw new Error(`Could not validate certificate path with any metadata root certificates: ${T.message}`)}return!0}const lp={secp256r1_ecdsa_sha256_raw:{kty:2,alg:-7,crv:1},secp256r1_ecdsa_sha256_der:{kty:2,alg:-7,crv:1},rsassa_pss_sha256_raw:{kty:3,alg:-37},rsassa_pss_sha256_der:{kty:3,alg:-37},secp256k1_ecdsa_sha256_raw:{kty:2,alg:-47,crv:8},secp256k1_ecdsa_sha256_der:{kty:2,alg:-47,crv:8},rsassa_pss_sha384_raw:{kty:3,alg:-38},rsassa_pkcsv15_sha256_raw:{kty:3,alg:-257},rsassa_pkcsv15_sha384_raw:{kty:3,alg:-258},rsassa_pkcsv15_sha512_raw:{kty:3,alg:-259},rsassa_pkcsv15_sha1_raw:{kty:3,alg:-65535},secp384r1_ecdsa_sha384_raw:{kty:2,alg:-35,crv:2},secp512r1_ecdsa_sha256_raw:{kty:2,alg:-36,crv:3},ed25519_eddsa_sha512_raw:{kty:1,alg:-8,crv:6}};function hp(r){const{kty:t,alg:n,crv:i}=r;let o="";return t!==tn.RSA?o=`{ kty: ${t}, alg: ${n}, crv: ${i} }`:o=`{ kty: ${t}, alg: ${n} }`,o}async function q8(r){const{attStmt:t,clientDataHash:n,authData:i,credentialPublicKey:o,aaguid:s,rootCertificates:a}=r,c=t.get("sig"),f=t.get("x5c"),h=t.get("alg");if(!c)throw new Error("No attestation signature provided in attestation statement (Packed)");if(!h)throw new Error("Attestation statement did not contain alg (Packed)");if(!$s(h))throw new Error(`Attestation statement contained invalid alg ${h} (Packed)`);const d=Sr([i,n]);let g=!1;if(f){const{subject:x,basicConstraintsCA:S,version:D,notBefore:E,notAfter:_}=xs(f[0]),{OU:T,CN:F,O:U,C:z}=x;if(T!=="Authenticator Attestation")throw new Error('Certificate OU was not "Authenticator Attestation" (Packed|Full)');if(!F)throw new Error("Certificate CN was empty (Packed|Full)");if(!U)throw new Error("Certificate O was empty (Packed|Full)");if(!z||z.length!==2)throw new Error("Certificate C was not two-character ISO 3166 code (Packed|Full)");if(S)throw new Error("Certificate basic constraints CA was not `false` (Packed|Full)");if(D!==2)throw new Error("Certificate version was not `3` (ASN.1 value of 2) (Packed|Full)");let V=new Date;if(E>V)throw new Error(`Certificate not good before "${E.toString()}" (Packed|Full)`);if(V=new Date,_<V)throw new Error(`Certificate not good after "${_.toString()}" (Packed|Full)`);const G=await Kc.getStatement(s);if(G){if(G.attestationTypes.indexOf("basic_full")<0)throw new Error("Metadata does not indicate support for full attestations (Packed|Full)");try{await zc({statement:G,credentialPublicKey:o,x5c:f,attestationStatementAlg:h})}catch(ee){const Q=ee;throw new Error(`${Q.message} (Packed|Full)`)}}else try{await bi(f.map(gn),a)}catch(ee){const Q=ee;throw new Error(`${Q.message} (Packed|Full)`)}g=await di({signature:c,data:d,x509Certificate:f[0]})}else g=await di({signature:c,data:d,credentialPublicKey:o,hashAlgorithm:h});return g}async function G8(r){const{attStmt:t,clientDataHash:n,authData:i,aaguid:o,rootCertificates:s,verifyTimestampMS:a=!0,credentialPublicKey:c}=r,f=t.get("alg"),h=t.get("response");if(!t.get("ver"))throw new Error("No ver value in attestation (SafetyNet)");if(!h)throw new Error("No response was included in attStmt by authenticator (SafetyNet)");const x=D8(h).split("."),S=JSON.parse(ms(x[0])),D=JSON.parse(ms(x[1])),E=x[2],{nonce:_,ctsProfileMatch:T,timestampMs:F}=D;if(a){let v=Date.now();if(F>Date.now())throw new Error(`Payload timestamp "${F}" was later than "${v}" (SafetyNet)`);const u=F+60*1e3;if(v=Date.now(),u<v)throw new Error(`Payload timestamp "${u}" has expired (SafetyNet)`)}const U=Sr([i,n]),z=await Zi(U),V=en(z,"base64");if(_!==V)throw new Error("Could not verify payload nonce (SafetyNet)");if(!T)throw new Error("Could not verify device integrity (SafetyNet)");const G=Nn(S.x5c[0],"base64"),ee=xs(G),{subject:Q}=ee;if(Q.CN!=="attest.android.com")throw new Error('Certificate common name was not "attest.android.com" (SafetyNet)');const X=await Kc.getStatement(o);if(X)try{await zc({statement:X,credentialPublicKey:c,x5c:S.x5c,attestationStatementAlg:f})}catch(v){const u=v;throw new Error(`${u.message} (SafetyNet)`)}else try{await bi(S.x5c.map(gn),s)}catch(v){const u=v;throw new Error(`${u.message} (SafetyNet)`)}const se=Vs(`${x[0]}.${x[1]}`),oe=Nn(E);return await di({signature:oe,data:se,x509Certificate:G})}const W8={196:"TPM_ST_RSP_COMMAND",32768:"TPM_ST_NULL",32769:"TPM_ST_NO_SESSIONS",32770:"TPM_ST_SESSIONS",32788:"TPM_ST_ATTEST_NV",32789:"TPM_ST_ATTEST_COMMAND_AUDIT",32790:"TPM_ST_ATTEST_SESSION_AUDIT",32791:"TPM_ST_ATTEST_CERTIFY",32792:"TPM_ST_ATTEST_QUOTE",32793:"TPM_ST_ATTEST_TIME",32794:"TPM_ST_ATTEST_CREATION",32801:"TPM_ST_CREATION",32802:"TPM_ST_VERIFIED",32803:"TPM_ST_AUTH_SECRET",32804:"TPM_ST_HASHCHECK",32805:"TPM_ST_AUTH_SIGNED",32809:"TPM_ST_FU_MANIFEST"},si={0:"TPM_ALG_ERROR",1:"TPM_ALG_RSA",4:"TPM_ALG_SHA",4:"TPM_ALG_SHA1",5:"TPM_ALG_HMAC",6:"TPM_ALG_AES",7:"TPM_ALG_MGF1",8:"TPM_ALG_KEYEDHASH",10:"TPM_ALG_XOR",11:"TPM_ALG_SHA256",12:"TPM_ALG_SHA384",13:"TPM_ALG_SHA512",16:"TPM_ALG_NULL",18:"TPM_ALG_SM3_256",19:"TPM_ALG_SM4",20:"TPM_ALG_RSASSA",21:"TPM_ALG_RSAES",22:"TPM_ALG_RSAPSS",23:"TPM_ALG_OAEP",24:"TPM_ALG_ECDSA",25:"TPM_ALG_ECDH",26:"TPM_ALG_ECDAA",27:"TPM_ALG_SM2",28:"TPM_ALG_ECSCHNORR",29:"TPM_ALG_ECMQV",32:"TPM_ALG_KDF1_SP800_56A",33:"TPM_ALG_KDF2",34:"TPM_ALG_KDF1_SP800_108",35:"TPM_ALG_ECC",37:"TPM_ALG_SYMCIPHER",38:"TPM_ALG_CAMELLIA",64:"TPM_ALG_CTR",65:"TPM_ALG_OFB",66:"TPM_ALG_CBC",67:"TPM_ALG_CFB",68:"TPM_ALG_ECB"},J8={0:"TPM_ECC_NONE",1:"TPM_ECC_NIST_P192",2:"TPM_ECC_NIST_P224",3:"TPM_ECC_NIST_P256",4:"TPM_ECC_NIST_P384",5:"TPM_ECC_NIST_P521",16:"TPM_ECC_BN_P256",17:"TPM_ECC_BN_P638",32:"TPM_ECC_SM2_P256"},Y8={"id:414D4400":{name:"AMD",id:"AMD"},"id:41544D4C":{name:"Atmel",id:"ATML"},"id:4252434D":{name:"Broadcom",id:"BRCM"},"id:49424d00":{name:"IBM",id:"IBM"},"id:49465800":{name:"Infineon",id:"IFX"},"id:494E5443":{name:"Intel",id:"INTC"},"id:4C454E00":{name:"Lenovo",id:"LEN"},"id:4E534D20":{name:"National Semiconductor",id:"NSM"},"id:4E545A00":{name:"Nationz",id:"NTZ"},"id:4E544300":{name:"Nuvoton Technology",id:"NTC"},"id:51434F4D":{name:"Qualcomm",id:"QCOM"},"id:534D5343":{name:"SMSC",id:"SMSC"},"id:53544D20":{name:"ST Microelectronics",id:"STM"},"id:534D534E":{name:"Samsung",id:"SMSN"},"id:534E5300":{name:"Sinosun",id:"SNS"},"id:54584E00":{name:"Texas Instruments",id:"TXN"},"id:57454300":{name:"Winbond",id:"WEC"},"id:524F4343":{name:"Fuzhouk Rockchip",id:"ROCC"},"id:FFFFF1D0":{name:"FIDO Alliance",id:"FIDO"}},Z8={TPM_ECC_NIST_P256:1,TPM_ECC_NIST_P384:2,TPM_ECC_NIST_P521:3,TPM_ECC_BN_P256:1,TPM_ECC_SM2_P256:1};function X8(r){let t=0;const n=Za(r),i=n.getUint32(t);t+=4;const o=n.getUint16(t);t+=2;const s=W8[o],a=n.getUint16(t);t+=2;const c=r.slice(t,t+=a),f=n.getUint16(t);t+=2;const h=r.slice(t,t+=f),d=r.slice(t,t+=8),g=n.getUint32(t);t+=4;const x=n.getUint32(t);t+=4;const S=!!r.slice(t,t+=1),D={clock:d,resetCount:g,restartCount:x,safe:S},E=r.slice(t,t+=8),_=n.getUint16(t);t+=2;const T=r.slice(t,t+=_),F=Za(T),U=n.getUint16(t);t+=2;const z=r.slice(t,t+=U),V={nameAlg:si[F.getUint16(0)],nameAlgBuffer:T.slice(0,2),name:T,qualifiedName:z};return{magic:i,type:s,qualifiedSigner:c,extraData:h,clockInfo:D,firmwareVersion:E,attested:V}}function Q8(r){let t=0;const n=Za(r),i=si[n.getUint16(t)];t+=2;const o=si[n.getUint16(t)];t+=2;const s=n.getUint32(t);t+=4;const a={fixedTPM:!!(s&1),stClear:!!(s&2),fixedParent:!!(s&8),sensitiveDataOrigin:!!(s&16),userWithAuth:!!(s&32),adminWithPolicy:!!(s&64),noDA:!!(s&512),encryptedDuplication:!!(s&1024),restricted:!!(s&32768),decrypt:!!(s&65536),signOrEncrypt:!!(s&131072)},c=n.getUint16(t);t+=2;const f=r.slice(t,t+=c),h={};let d=Uint8Array.from([]);if(i==="TPM_ALG_RSA"){const g=si[n.getUint16(t)];t+=2;const x=si[n.getUint16(t)];t+=2;const S=n.getUint16(t);t+=2;const D=n.getUint32(t);t+=4,h.rsa={symmetric:g,scheme:x,keyBits:S,exponent:D};const E=n.getUint16(t);t+=2,d=r.slice(t,t+=E)}else if(i==="TPM_ALG_ECC"){const g=si[n.getUint16(t)];t+=2;const x=si[n.getUint16(t)];t+=2;const S=J8[n.getUint16(t)];t+=2;const D=si[n.getUint16(t)];t+=2,h.ecc={symmetric:g,scheme:x,curveID:S,kdf:D};const E=n.getUint16(t);t+=2;const _=r.slice(t,t+=E),T=n.getUint16(t);t+=2;const F=r.slice(t,t+=T);d=Sr([_,F])}else throw new Error(`Unexpected type "${i}" (TPM)`);return{type:i,nameAlg:o,objectAttributes:a,authPolicy:f,parameters:h,unique:d}}async function e6(r){var B;const{aaguid:t,attStmt:n,authData:i,credentialPublicKey:o,clientDataHash:s,rootCertificates:a}=r,c=n.get("ver"),f=n.get("sig"),h=n.get("alg"),d=n.get("x5c"),g=n.get("pubArea"),x=n.get("certInfo");if(c!=="2.0")throw new Error(`Unexpected ver "${c}", expected "2.0" (TPM)`);if(!f)throw new Error("No attestation signature provided in attestation statement (TPM)");if(!h)throw new Error("Attestation statement did not contain alg (TPM)");if(!$s(h))throw new Error(`Attestation statement contained invalid alg ${h} (TPM)`);if(!d)throw new Error("No attestation certificate provided in attestation statement (TPM)");if(!g)throw new Error("Attestation statement did not contain pubArea (TPM)");if(!x)throw new Error("Attestation statement did not contain certInfo (TPM)");const S=Q8(g),{unique:D,type:E,parameters:_}=S,T=jc(o);if(E==="TPM_ALG_RSA"){if(!Ph(T))throw new Error(`Credential public key with kty ${T.get(Ce.kty)} did not match ${E}`);const j=T.get(Ce.n),Z=T.get(Ce.e);if(!j)throw new Error("COSE public key missing n (TPM|RSA)");if(!Z)throw new Error("COSE public key missing e (TPM|RSA)");if(!hn(D,j))throw new Error("PubArea unique is not same as credentialPublicKey (TPM|RSA)");if(!_.rsa)throw new Error("Parsed pubArea type is RSA, but missing parameters.rsa (TPM|RSA)");const Y=Z,ne=_.rsa.exponent||65537,ue=Y[0]+(Y[1]<<8)+(Y[2]<<16);if(ne!==ue)throw new Error(`Unexpected public key exp ${ue}, expected ${ne} (TPM|RSA)`)}else if(E==="TPM_ALG_ECC"){if(!Vc(T))throw new Error(`Credential public key with kty ${T.get(Ce.kty)} did not match ${E}`);const j=T.get(Ce.crv),Z=T.get(Ce.x),Y=T.get(Ce.y);if(!j)throw new Error("COSE public key missing crv (TPM|ECC)");if(!Z)throw new Error("COSE public key missing x (TPM|ECC)");if(!Y)throw new Error("COSE public key missing y (TPM|ECC)");if(!hn(D,Sr([Z,Y])))throw new Error("PubArea unique is not same as public key x and y (TPM|ECC)");if(!_.ecc)throw new Error("Parsed pubArea type is ECC, but missing parameters.ecc (TPM|ECC)");const ne=_.ecc.curveID,ue=Z8[ne];if(ue!==j)throw new Error(`Public area key curve ID "${ne}" mapped to "${ue}" which did not match public key crv of "${j}" (TPM|ECC)`)}else throw new Error(`Unsupported pubArea.type "${E}"`);const F=X8(x),{magic:U,type:z,attested:V,extraData:G}=F;if(U!==4283712327)throw new Error(`Unexpected magic value "${U}", expected "0xff544347" (TPM)`);if(z!=="TPM_ST_ATTEST_CERTIFY")throw new Error(`Unexpected type "${z}", expected "TPM_ST_ATTEST_CERTIFY" (TPM)`);const ee=await Zi(g,r6(V.nameAlg)),Q=Sr([V.nameAlgBuffer,ee]);if(!hn(V.name,Q))throw new Error("Attested name comparison failed (TPM)");const X=Sr([i,s]),se=await Zi(X,h);if(!hn(G,se))throw new Error("CertInfo extra data did not equal hashed attestation (TPM)");if(d.length<1)throw new Error("No certificates present in x5c array (TPM)");const oe=xs(d[0]),{basicConstraintsCA:H,version:v,subject:u,notAfter:l,notBefore:p}=oe;if(H)throw new Error("Certificate basic constraints CA was not `false` (TPM)");if(v!==2)throw new Error("Certificate version was not `3` (ASN.1 value of 2) (TPM)");if(u.combined.length>0)throw new Error("Certificate subject was not empty (TPM)");let w=new Date;if(p>w)throw new Error(`Certificate not good before "${p.toString()}" (TPM)`);if(w=new Date,l<w)throw new Error(`Certificate not good after "${l.toString()}" (TPM)`);const A=$t.parse(d[0],wi);if(!A.tbsCertificate.extensions)throw new Error("Certificate was missing extensions (TPM)");let C,k;if(A.tbsCertificate.extensions.forEach(j=>{j.extnID===LS?C=$t.parse(j.extnValue,sl):j.extnID===FS&&(k=$t.parse(j.extnValue,Qu))}),!C)throw new Error("Certificate did not contain subjectAltName extension (TPM)");if(!((B=C[0].directoryName)!=null&&B[0].length))throw new Error("Certificate subjectAltName extension directoryName was empty (TPM)");const{tcgAtTpmManufacturer:I,tcgAtTpmModel:y,tcgAtTpmVersion:N}=t6(C[0].directoryName);if(!I||!y||!N)throw new Error("Certificate contained incomplete subjectAltName data (TPM)");if(!k)throw new Error("Certificate did not contain ExtendedKeyUsage extension (TPM)");if(!Y8[I])throw new Error(`Could not match TPM manufacturer "${I}" (TPM)`);if(k[0]!=="2.23.133.8.3")throw new Error(`Unexpected extKeyUsage "${k[0]}", expected "2.23.133.8.3" (TPM)`);const re=await Kc.getStatement(t);if(re)try{await zc({statement:re,credentialPublicKey:o,x5c:d,attestationStatementAlg:h})}catch(j){const Z=j;throw new Error(`${Z.message} (TPM)`)}else try{await bi(d.map(gn),a)}catch(j){const Z=j;throw new Error(`${Z.message} (TPM)`)}return di({signature:f,data:x,x509Certificate:d[0],hashAlgorithm:h})}function t6(r){const t="2.23.133.2.1",n="2.23.133.2.2",i="2.23.133.2.3";let o,s,a;return r.forEach(c=>{c.forEach(f=>{f.type===t?o=f.value.toString():f.type===n?s=f.value.toString():f.type===i&&(a=f.value.toString())})}),{tcgAtTpmManufacturer:o,tcgAtTpmModel:s,tcgAtTpmVersion:a}}function r6(r){if(r==="TPM_ALG_SHA256")return Ie.ES256;if(r==="TPM_ALG_SHA384")return Ie.ES384;if(r==="TPM_ALG_SHA512")return Ie.ES512;throw new Error(`Unexpected TPM attested name alg ${r}`)}async function n6(r){var z;const{authData:t,clientDataHash:n,attStmt:i,credentialPublicKey:o,aaguid:s,rootCertificates:a}=r,c=i.get("x5c"),f=i.get("sig"),h=i.get("alg");if(!c)throw new Error("No attestation certificate provided in attestation statement (AndroidKey)");if(!f)throw new Error("No attestation signature provided in attestation statement (AndroidKey)");if(!h)throw new Error("Attestation statement did not contain alg (AndroidKey)");if(!$s(h))throw new Error(`Attestation statement contained invalid alg ${h} (AndroidKey)`);const d=$t.parse(c[0],wi),g=new Uint8Array(d.tbsCertificate.subjectPublicKeyInfo.subjectPublicKey),x=Hh(o);if(!hn(x,g))throw new Error("Credential public key does not equal leaf cert public key (AndroidKey)");const S=(z=d.tbsCertificate.extensions)==null?void 0:z.find(V=>V.extnID===t8);if(!S)throw new Error("Certificate did not contain extKeyStore (AndroidKey)");const D=$t.parse(S.extnValue,Hn),{attestationChallenge:E,teeEnforced:_,softwareEnforced:T}=D;if(!hn(new Uint8Array(E.buffer),n))throw new Error("Attestation challenge was not equal to client data hash (AndroidKey)");if(_.allApplications!==void 0)throw new Error('teeEnforced contained "allApplications [600]" tag (AndroidKey)');if(T.allApplications!==void 0)throw new Error('teeEnforced contained "allApplications [600]" tag (AndroidKey)');const F=await Kc.getStatement(s);if(F)try{await zc({statement:F,credentialPublicKey:o,x5c:c,attestationStatementAlg:h})}catch(V){const G=V;throw new Error(`${G.message} (AndroidKey)`)}else try{await bi(c.map(gn),a)}catch(V){const G=V;throw new Error(`${G.message} (AndroidKey)`)}const U=Sr([t,n]);return di({signature:f,data:U,x509Certificate:c[0],hashAlgorithm:h})}async function i6(r){const{attStmt:t,authData:n,clientDataHash:i,credentialPublicKey:o,rootCertificates:s}=r,a=t.get("x5c");if(!a)throw new Error("No attestation certificate provided in attestation statement (Apple)");try{await bi(a.map(gn),s)}catch(_){const T=_;throw new Error(`${T.message} (Apple)`)}const c=$t.parse(a[0],wi),{extensions:f,subjectPublicKeyInfo:h}=c.tbsCertificate;if(!f)throw new Error("credCert missing extensions (Apple)");const d=f.find(_=>_.extnID==="1.2.840.113635.100.8.2");if(!d)throw new Error('credCert missing "1.2.840.113635.100.8.2" extension (Apple)');const g=Sr([n,i]),x=await Zi(g),S=new Uint8Array(d.extnValue.buffer).slice(6);if(!hn(x,S))throw new Error("credCert nonce was not expected value (Apple)");const D=Hh(o),E=new Uint8Array(h.subjectPublicKey);if(!hn(D,E))throw new Error("Credential public key does not equal credCert public key (Apple)");return!0}async function o6(r){const{response:t,expectedChallenge:n,expectedOrigin:i,expectedRPID:o,expectedType:s,requireUserVerification:a=!0,supportedAlgorithmIDs:c=_8}=r,{id:f,rawId:h,type:d,response:g}=t;if(!f)throw new Error("Missing credential ID");if(f!==h)throw new Error("Credential ID was not base64url-encoded");if(d!=="public-key")throw new Error(`Unexpected credential type ${d}, expected "public-key"`);const x=Gw(g.clientDataJSON),{type:S,origin:D,challenge:E,tokenBinding:_}=x;if(Array.isArray(s)){if(!s.includes(S)){const y=s.join(", ");throw new Error(`Unexpected registration response type "${S}", expected one of: ${y}`)}}else if(s){if(S!==s)throw new Error(`Unexpected registration response type "${S}", expected "${s}"`)}else if(S!=="webauthn.create")throw new Error(`Unexpected registration response type: ${S}`);if(typeof n=="function"){if(!await n(E))throw new Error(`Custom challenge verifier returned false for registration response challenge "${E}"`)}else if(E!==n)throw new Error(`Unexpected registration response challenge "${E}", expected "${n}"`);if(Array.isArray(i)){if(!i.includes(D))throw new Error(`Unexpected registration response origin "${D}", expected one of: ${i.join(", ")}`)}else if(D!==i)throw new Error(`Unexpected registration response origin "${D}", expected "${i}"`);if(_){if(typeof _!="object")throw new Error(`Unexpected value for TokenBinding "${_}"`);if(["present","supported","not-supported"].indexOf(_.status)<0)throw new Error(`Unexpected tokenBinding.status value of "${_.status}"`)}const T=Nn(g.attestationObject),F=f8(T),U=F.get("fmt"),z=F.get("authData"),V=F.get("attStmt"),G=Yw(z),{aaguid:ee,rpIdHash:Q,flags:X,credentialID:se,counter:oe,credentialPublicKey:H,extensionsData:v}=G;let u;if(o){let y=[];typeof o=="string"?y=[o]:y=o,u=await e1(Q,y)}if(!X.up)throw new Error("User not present during registration");if(a&&!X.uv)throw new Error("User verification required, but user could not be verified");if(!se)throw new Error("No credential ID was provided by authenticator");if(!H)throw new Error("No public key was provided by authenticator");if(!ee)throw new Error("No AAGUID was present during registration");const p=jc(H).get(Ce.alg);if(typeof p!="number")throw new Error("Credential public key was missing numeric alg");if(!c.includes(p)){const y=c.join(", ");throw new Error(`Unexpected public key alg "${p}", expected one of "${y}"`)}const w=await Zi(Nn(g.clientDataJSON)),A=Fo.getRootCertificates({identifier:U}),C={aaguid:ee,attStmt:V,authData:z,clientDataHash:w,credentialID:se,credentialPublicKey:H,rootCertificates:A,rpIdHash:Q};let k=!1;if(U==="fido-u2f")k=await $8(C);else if(U==="packed")k=await q8(C);else if(U==="android-safetynet")k=await G8(C);else if(U==="android-key")k=await n6(C);else if(U==="tpm")k=await e6(C);else if(U==="apple")k=await i6(C);else if(U==="none"){if(V.size>0)throw new Error("None attestation had unexpected attestation statement");k=!0}else throw new Error(`Unsupported Attestation Format: ${U}`);const I={verified:k};if(I.verified){const{credentialDeviceType:y,credentialBackedUp:N}=Qw(X);I.registrationInfo={fmt:U,counter:oe,aaguid:qw(ee),credentialID:en(se),credentialPublicKey:H,credentialType:d,attestationObject:T,userVerified:X.uv,credentialDeviceType:y,credentialBackedUp:N,origin:x.origin,rpID:u,authenticatorExtensionResults:v}}return I}async function s6(r){const{allowCredentials:t,challenge:n=await Xw(),timeout:i=6e4,userVerification:o="preferred",extensions:s,rpID:a}=r;let c=n;return typeof c=="string"&&(c=Vs(c)),{rpId:a,challenge:en(c),allowCredentials:t==null?void 0:t.map(f=>{if(!bs(f.id))throw new Error(`excludeCredential id "${f.id}" is not a valid base64url string`);return{...f,id:Oh(f.id),type:"public-key"}}),timeout:i,userVerification:o,extensions:s}}async function a6(r){const{response:t,expectedChallenge:n,expectedOrigin:i,expectedRPID:o,expectedType:s,authenticator:a,requireUserVerification:c=!0,advancedFIDOConfig:f}=r,{id:h,rawId:d,type:g,response:x}=t;if(!h)throw new Error("Missing credential ID");if(h!==d)throw new Error("Credential ID was not base64url-encoded");if(g!=="public-key")throw new Error(`Unexpected credential type ${g}, expected "public-key"`);if(!t)throw new Error("Credential missing response");if(typeof(x==null?void 0:x.clientDataJSON)!="string")throw new Error("Credential response clientDataJSON was not a string");const S=Gw(x.clientDataJSON),{type:D,origin:E,challenge:_,tokenBinding:T}=S;if(Array.isArray(s)){if(!s.includes(D)){const p=s.join(", ");throw new Error(`Unexpected authentication response type "${D}", expected one of: ${p}`)}}else if(s){if(D!==s)throw new Error(`Unexpected authentication response type "${D}", expected "${s}"`)}else if(D!=="webauthn.get")throw new Error(`Unexpected authentication response type: ${D}`);if(typeof n=="function"){if(!await n(_))throw new Error(`Custom challenge verifier returned false for registration response challenge "${_}"`)}else if(_!==n)throw new Error(`Unexpected authentication response challenge "${_}", expected "${n}"`);if(Array.isArray(i)){if(!i.includes(E)){const p=i.join(", ");throw new Error(`Unexpected authentication response origin "${E}", expected one of: ${p}`)}}else if(E!==i)throw new Error(`Unexpected authentication response origin "${E}", expected "${i}"`);if(!bs(x.authenticatorData))throw new Error("Credential response authenticatorData was not a base64url string");if(!bs(x.signature))throw new Error("Credential response signature was not a base64url string");if(x.userHandle&&typeof x.userHandle!="string")throw new Error("Credential response userHandle was not a string");if(T){if(typeof T!="object")throw new Error("ClientDataJSON tokenBinding was not an object");if(["present","supported","notSupported"].indexOf(T.status)<0)throw new Error(`Unexpected tokenBinding status ${T.status}`)}const F=Nn(x.authenticatorData),U=Yw(F),{rpIdHash:z,flags:V,counter:G,extensionsData:ee}=U;let Q=[];typeof o=="string"?Q=[o]:Q=o;const X=await e1(z,Q);if(f!==void 0){const{userVerification:p}=f;if(p==="required"&&!V.uv)throw new Error("User verification required, but user could not be verified")}else{if(!V.up)throw new Error("User not present during authentication");if(c&&!V.uv)throw new Error("User verification required, but user could not be verified")}const se=await Zi(Nn(x.clientDataJSON)),oe=Sr([F,se]),H=Nn(x.signature);if((G>0||a.counter>0)&&G<=a.counter)throw new Error(`Response counter value ${G} was lower than expected ${a.counter}`);const{credentialDeviceType:v,credentialBackedUp:u}=Qw(V);return{verified:await di({signature:H,data:oe,credentialPublicKey:a.credentialPublicKey}),authenticationInfo:{newCounter:G,credentialID:a.credentialID,userVerified:V.uv,credentialDeviceType:v,credentialBackedUp:u,authenticatorExtensionResults:ee,origin:S.origin,rpID:X}}}async function c6(r){var c,f,h,d;const t=await T8({rpName:Yh.APP_NAME,rpID:window.location.hostname,userName:r||Yh.APP_NAME+" User",attestationType:"none",authenticatorSelection:{residentKey:"preferred",userVerification:"preferred",authenticatorAttachment:"platform"}}),n=await s3(t),i=await o6({response:n,expectedChallenge:t.challenge,expectedOrigin:window.location.origin,expectedRPID:window.location.hostname}),o=(c=i.registrationInfo)==null?void 0:c.credentialID;n.rawId!==o&&console.log("Warning! The raw ID does not match the credential ID.");const s=qe.Buffer.from(l6(o)).toString("hex"),{publicKeyJwk:a}=Aw((f=i.registrationInfo)==null?void 0:f.credentialPublicKey);return{authData:(h=i.registrationInfo)==null?void 0:h.attestationObject,credIdHex:s,publicKeyJwk:a,publicKeyBytes:(d=i.registrationInfo)==null?void 0:d.credentialPublicKey}}class f6{constructor(){We(this,"authenticatorData");We(this,"challenge");We(this,"clientDataJsonBase64Url");We(this,"signature")}async createJwtSimplewebauthn(t,n,i,o=1){const s=ba(qe.Buffer.from(i,"hex").buffer),a=Math.floor(Date.now()/1e3),c=Math.floor(Date.now()/1e3)+o*60,f={...n,exp:c,iat:a,iss:t};this.challenge=new Uint8Array(qe.Buffer.from(JSON.stringify(f)));const h=await s6({challenge:this.challenge,rpID:window.location.hostname,allowCredentials:[{id:s}]}),d=await f3(h),g=d.response.authenticatorData;this.authenticatorData=qe.Buffer.from(d.response.authenticatorData,"base64").buffer,this.clientDataJsonBase64Url=d.response.clientDataJSON,this.signature=d.response.signature;const x={typ:"JWANT",alg:"ES256"},S=qe.Buffer.from(JSON.stringify(x)).toString("base64").replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,""),D={AuthenticationDataB64URL:g,ClientDataJSONB64URL:this.clientDataJsonBase64Url,exp:c,iat:a,iss:t},E=JSON.stringify(D),_=qe.Buffer.from(E).toString("base64").replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,""),T=d.response.signature;return S+"."+_+"."+T}async createJwtNavigator(t,n,i,o=1){const s=Math.floor(Date.now()/1e3),a=Math.floor(Date.now()/1e3)+o*60,c={...n,exp:a,iat:s,iss:t},f=JSON.stringify(c),h=qe.Buffer.from(f),d=qe.Buffer.from(i,"hex");this.challenge=new Uint8Array(h);const g={publicKey:{allowCredentials:[{id:d,type:"public-key"}],challenge:this.challenge.buffer,rpID:window.location.hostname,userVerification:"preferred"}},x=await navigator.credentials.get(g);this.authenticatorData=x==null?void 0:x.response.authenticatorData;const S=ba(this.authenticatorData);this.clientDataJsonBase64Url=ba(x==null?void 0:x.response.clientDataJSON);const D={typ:"JWANT",alg:"ES256"},E=qe.Buffer.from(JSON.stringify(D)).toString("base64").replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,""),_={AuthenticationDataB64URL:S,ClientDataJSONB64URL:this.clientDataJsonBase64Url,exp:a,iat:s,iss:t},T=JSON.stringify(_),F=qe.Buffer.from(T).toString("base64").replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,""),U=qe.Buffer.from(x==null?void 0:x.response.signature).toString("base64");return this.signature=U.replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,""),E+"."+F+"."+this.signature}}async function u6(r,t,n){return await new f6().createJwtNavigator(r,n,t)}async function CD(r,t,n,i,o,s){const a=qe.Buffer.from(n),c=qe.Buffer.from(o,"base64"),f=qe.Buffer.from(s,"base64"),h=bw(f),d=Mh(t),g=Pl(c),x=qe.Buffer.concat([a,g]);return p256.verify(h,new Uint8Array(x),d)}async function ID(r,t,n,i,o,s){const a=Ga(qe.Buffer.from(n)),c=Mh(t),f=ba(qe.Buffer.from(r,"hex").buffer),h={authenticator:{credentialID:f,credentialPublicKey:c,counter:0},expectedChallenge:Ga(i),expectedOrigin:window.location.origin,expectedRPID:window.location.hostname,response:{authenticatorAttachment:"platform",clientExtensionResults:{},id:f,rawId:f,response:{authenticatorData:a,clientDataJSON:o,signature:s},type:"public-key"}};return(await a6(h)).verified}async function _D(r,t,n,i,o,s){const a=qe.Buffer.from(n),c=qe.Buffer.from(o,"base64"),f=qe.Buffer.from(s,"base64"),h=bw(f),d=Pl(c),g=qe.Buffer.concat([a,d]);return xw(g,t,h)}function dp(r){return atob(r.replace(/-/g,"+").replace(/_/g,"/"))}function ba(r){const t=new Uint8Array(r);let n="";for(const o of t)n+=String.fromCharCode(o);return btoa(n).replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"")}function l6(r){const t=r.replace(/-/g,"+").replace(/_/g,"/"),n=(4-t.length%4)%4,i=t.padEnd(t.length+n,"="),o=atob(i),s=new ArrayBuffer(o.length),a=new Uint8Array(s);for(let c=0;c<o.length;c++)a[c]=o.charCodeAt(c);return s}var t1=(r=>(r.Home="HOME",r.Discover="DISCOVER",r.Create="CREATE",r.Contact="CONTACT",r.Account="ACCOUNT",r))(t1||{});const h6="The data you send will be visible to the world -- except: your IDs and the IDs of anyone you tag will stay private, only visible to them and others you explicitly allow.",d6="shared-photo-base64",p6={BTC:"BTC",BX:"BX",ETH:"ETH",HUR:"Hours",USD:"US $"},g6={BTC:"Bitcoin",BX:"Buxbe",ETH:"Ethereum",HUR:"hours",USD:"dollars"},y6={BTC:{name:"Bitcoin",faIcon:"bitcoin-sign"},HUR:{name:"hours",faIcon:"clock"},USD:{name:"US Dollars",faIcon:"dollar"}};function w6(r){var t;return((t=y6[r])==null?void 0:t.faIcon)||"question"}function r1(r){return!isNaN(r)&&!isNaN(parseFloat(r))}function m6(r){return r1(r)?+r:0}const b6=r=>r&&r.match(new RegExp(/^[A-Za-z][A-Za-z0-9+.-]+:/)),$h=r=>r==="GiveAction",n1=r=>$h(r.claimType),v6=(r,t,n)=>{if(n===r)return"you";const i=Il(o=>o.did==n,t);return i1(i)},i1=(r,t)=>(r==null?void 0:r.name)||(t?"This":"this")+" unnamed user",x6=(r,t)=>{t(),U1().copy(r).then(()=>setTimeout(t,2e3))};async function A6(r,t,n,i){const o=r+"/api/report/issuersWhoClaimedOrConfirmed?claimId="+encodeURIComponent(b1(t)),s=await vi(i),a=await Sp.get(o,{headers:s});if(a.status===200){const c=a.data.result||[];delete c.publicUrls;const f=nd(Xi,c),h=nd(D=>D===n,f),d=h;let g=c.length-f.length;h.length===f.length&&(g=g-1);const x=a.data.result.resultVisibleToDids||[];return{confirmerIdList:d,confsVisibleToIdList:x,numConfsNotVisible:g}}else{console.error("Bad response status of",a.status,"for confirmers:",a);return}}function E6(r,t,n,i=[]){return r&&n1(t)&&!i.includes(n)&&t.issuer!==n&&!Vh(t.claim)}function S6(r,t,n,i,o,s=[]){t?$h(n)?s.includes(o)?r({group:"alert",type:"info",title:"Already Confirmed",text:"You already confirmed this claim."},3e3):(i==null?void 0:i.issuerDid)==o?r({group:"alert",type:"info",title:"Cannot Confirm",text:"You cannot confirm this because you issued this claim."},3e3):Vh(i==null?void 0:i.fullClaim)?r({group:"alert",type:"info",title:"Cannot Confirm",text:"You cannot confirm this because some people are hidden."},3e3):r({group:"alert",type:"info",title:"Cannot Confirm",text:"You cannot confirm this claim. There are no other details -- we can help more if you contact us and send us screenshots."},3e3):r({group:"alert",type:"info",title:"Not A Give",text:"This is not a giving action to confirm."},3e3):r({group:"alert",type:"info",title:"Not Registered",text:"Someone needs to register you before you can confirm."},3e3)}async function B6(r){return new Promise((t,n)=>{const i=new FileReader;i.onloadend=()=>t(i.result),i.onerror=n,i.readAsDataURL(r)})}function D6(r,t=512){const[n,i]=r.split(","),o=n.match(/data:(.*?);base64/),s=o?o[1]:"",a=atob(i),c=[];for(let f=0;f<a.length;f+=t){const h=a.slice(f,f+t),d=new Array(h.length);for(let x=0;x<h.length;x++)d[x]=h.charCodeAt(x);const g=new Uint8Array(d);c.push(g)}return new Blob(c,{type:s})}function o1(r){var n;let t;return(n=r.claim.offeredBy)!=null&&n.identifier&&!Xi(r.claim.offeredBy.identifier)?t=r.claim.offeredBy.identifier:r.issuer&&!Xi(r.issuer)&&(t=r.issuer),t}const C6=r=>r.claimType==="Offer"&&!!o1(r);function Al(r,t=!1){if(Array.isArray(r)){const n={};for(let i=0;i<r.length;i++){const o=Al(r[i],t);for(const s in o){const a=t?"#"+(i+1)+" "+s:"["+i+"]"+s;n[a]=o[s]}}return n}else if(r instanceof Object){const n={};for(const i in r)if(i.endsWith("VisibleToDids")){const o=i.slice(0,-13),s=t?o:"."+o;n[s]=r[i]}else{const o=Al(r[i],t);for(const s in o){const a=t?i+"'s "+s:"."+i+s;n[a]=o[s]}}return n}else return{}}const I6=async()=>await(await pi).accounts.count(),_6=async()=>(await(await pi).accounts.toArray()).map(i=>i.did),s1=async r=>{const n=await(await pi).accounts.where("did").equals(r).first();if(n){const{identity:i,mnemonic:o,...s}=n;return s}else return},M6=async()=>(await(await pi).accounts.toArray()).map(n=>{const{identity:i,mnemonic:o,...s}=n;return s}),a1=async r=>await(await pi).accounts.where("did").equals(r).first(),k6=async()=>await(await pi).accounts.toArray(),T6=async()=>{const r=v4(),[t,n,i,o]=C1(r),s=b4(t,i,n,o),a=JSON.stringify(s);return await(await pi).accounts.add({dateCreated:new Date().toISOString(),derivationPath:o,did:s.did,identity:a,mnemonic:r,publicKeyHex:s.keys[0].publicKeyHex}),await Bp({activeDid:s.did}),await Dp(s.did,{isRegistered:!1}),s.did},c1=async r=>{const t=await c6(r),n=t.publicKeyBytes,i=r3(n),o=t.credIdHex,s={dateCreated:new Date().toISOString(),did:i,passkeyCredIdHex:o,publicKeyHex:qe.Buffer.from(n).toString("hex")};return await(await pi).accounts.add(s),s},N6=async r=>{const t=await c1(r);return await Bp({activeDid:t.did}),await Dp(t.did,{isRegistered:!1}),t},f1=async()=>{const r=await Cp();return((r==null?void 0:r.passkeyExpirationMinutes)??k1)*60},R6="DAILY_CHECK",u1="DIRECT_NOTIFICATION",U6=async(r,t)=>{const n=await Cp();let i=T1;n!=null&&n.webPushServer&&(i=n.webPushServer);const o={...r,message:`Test, where you will see this message ${t?"un":""}filtered.`,title:t?u1:"Your Web Push"};console.log("Sending a test web push message:",o);const s=JSON.stringify(o),a=await Sp.post(i+"/web-push/send-test",s,{headers:{"Content-Type":"application/json"}});return console.log("Got response from web push server:",a),a},MD=Object.freeze(Object.defineProperty({__proto__:null,DAILY_CHECK_TITLE:R6,DIRECT_PUSH_TITLE:u1,OnboardPage:t1,PRIVACY_MESSAGE:h6,SHARED_PHOTO_BASE64_KEY:d6,UNIT_LONG:g6,UNIT_SHORT:p6,base64ToBlob:D6,blobToBase64:B6,canFulfillOffer:C6,doCopyTwoSecRedo:x6,findAllVisibleToDids:Al,generateSaveAndActivateIdentity:T6,getPasskeyExpirationSeconds:f1,iconForUnitCode:w6,isGiveAction:n1,isGiveClaimType:$h,isGiveRecordTheUserCanConfirm:E6,isGlobalUri:b6,isNumeric:r1,nameForContact:i1,nameForDid:v6,notifyWhyCannotConfirm:S6,numberOrZero:m6,offerGiverDid:o1,registerAndSavePasskey:c1,registerSaveAndActivatePasskey:N6,retrieveAccountCount:I6,retrieveAccountDids:_6,retrieveAccountMetadata:s1,retrieveAllAccountsMetadata:M6,retrieveAllFullyDecryptedAccounts:k6,retrieveConfirmerIdList:A6,retrieveFullyDecryptedAccount:a1,sendTestThroughPushServer:U6},Symbol.toStringTag,{value:"Module"}));function O6(r){return globalThis.Buffer!=null?new Uint8Array(r.buffer,r.byteOffset,r.byteLength):r}function P6(r=0){var t;return((t=globalThis.Buffer)==null?void 0:t.allocUnsafe)!=null?O6(globalThis.Buffer.allocUnsafe(r)):new Uint8Array(r)}function F6(r,t){if(r.length>=255)throw new TypeError("Alphabet too long");for(var n=new Uint8Array(256),i=0;i<n.length;i++)n[i]=255;for(var o=0;o<r.length;o++){var s=r.charAt(o),a=s.charCodeAt(0);if(n[a]!==255)throw new TypeError(s+" is ambiguous");n[a]=o}var c=r.length,f=r.charAt(0),h=Math.log(c)/Math.log(256),d=Math.log(256)/Math.log(c);function g(D){if(D instanceof Uint8Array||(ArrayBuffer.isView(D)?D=new Uint8Array(D.buffer,D.byteOffset,D.byteLength):Array.isArray(D)&&(D=Uint8Array.from(D))),!(D instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(D.length===0)return"";for(var E=0,_=0,T=0,F=D.length;T!==F&&D[T]===0;)T++,E++;for(var U=(F-T)*d+1>>>0,z=new Uint8Array(U);T!==F;){for(var V=D[T],G=0,ee=U-1;(V!==0||G<_)&&ee!==-1;ee--,G++)V+=256*z[ee]>>>0,z[ee]=V%c>>>0,V=V/c>>>0;if(V!==0)throw new Error("Non-zero carry");_=G,T++}for(var Q=U-_;Q!==U&&z[Q]===0;)Q++;for(var X=f.repeat(E);Q<U;++Q)X+=r.charAt(z[Q]);return X}function x(D){if(typeof D!="string")throw new TypeError("Expected String");if(D.length===0)return new Uint8Array;var E=0;if(D[E]!==" "){for(var _=0,T=0;D[E]===f;)_++,E++;for(var F=(D.length-E)*h+1>>>0,U=new Uint8Array(F);D[E];){var z=n[D.charCodeAt(E)];if(z===255)return;for(var V=0,G=F-1;(z!==0||V<T)&&G!==-1;G--,V++)z+=c*U[G]>>>0,U[G]=z%256>>>0,z=z/256>>>0;if(z!==0)throw new Error("Non-zero carry");T=V,E++}if(D[E]!==" "){for(var ee=F-T;ee!==F&&U[ee]===0;)ee++;for(var Q=new Uint8Array(_+(F-ee)),X=_;ee!==F;)Q[X++]=U[ee++];return Q}}}function S(D){var E=x(D);if(E)return E;throw new Error(`Non-${t} character`)}return{encode:g,decodeUnsafe:x,decode:S}}var L6=F6,H6=L6;const $6=r=>{if(r instanceof Uint8Array&&r.constructor.name==="Uint8Array")return r;if(r instanceof ArrayBuffer)return new Uint8Array(r);if(ArrayBuffer.isView(r))return new Uint8Array(r.buffer,r.byteOffset,r.byteLength);throw new Error("Unknown type, must be binary type")},V6=r=>new TextEncoder().encode(r),j6=r=>new TextDecoder().decode(r);class K6{constructor(t,n,i){this.name=t,this.prefix=n,this.baseEncode=i}encode(t){if(t instanceof Uint8Array)return`${this.prefix}${this.baseEncode(t)}`;throw Error("Unknown type, must be binary type")}}class z6{constructor(t,n,i){if(this.name=t,this.prefix=n,n.codePointAt(0)===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=n.codePointAt(0),this.baseDecode=i}decode(t){if(typeof t=="string"){if(t.codePointAt(0)!==this.prefixCodePoint)throw Error(`Unable to decode multibase string ${JSON.stringify(t)}, ${this.name} decoder only supports inputs prefixed with ${this.prefix}`);return this.baseDecode(t.slice(this.prefix.length))}else throw Error("Can only multibase decode strings")}or(t){return l1(this,t)}}class q6{constructor(t){this.decoders=t}or(t){return l1(this,t)}decode(t){const n=t[0],i=this.decoders[n];if(i)return i.decode(t);throw RangeError(`Unable to decode multibase string ${JSON.stringify(t)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}}const l1=(r,t)=>new q6({...r.decoders||{[r.prefix]:r},...t.decoders||{[t.prefix]:t}});class G6{constructor(t,n,i,o){this.name=t,this.prefix=n,this.baseEncode=i,this.baseDecode=o,this.encoder=new K6(t,n,i),this.decoder=new z6(t,n,o)}encode(t){return this.encoder.encode(t)}decode(t){return this.decoder.decode(t)}}const qc=({name:r,prefix:t,encode:n,decode:i})=>new G6(r,t,n,i),js=({prefix:r,name:t,alphabet:n})=>{const{encode:i,decode:o}=H6(n,t);return qc({prefix:r,name:t,encode:i,decode:s=>$6(o(s))})},W6=(r,t,n,i)=>{const o={};for(let d=0;d<t.length;++d)o[t[d]]=d;let s=r.length;for(;r[s-1]==="=";)--s;const a=new Uint8Array(s*n/8|0);let c=0,f=0,h=0;for(let d=0;d<s;++d){const g=o[r[d]];if(g===void 0)throw new SyntaxError(`Non-${i} character`);f=f<<n|g,c+=n,c>=8&&(c-=8,a[h++]=255&f>>c)}if(c>=n||255&f<<8-c)throw new SyntaxError("Unexpected end of data");return a},J6=(r,t,n)=>{const i=t[t.length-1]==="=",o=(1<<n)-1;let s="",a=0,c=0;for(let f=0;f<r.length;++f)for(c=c<<8|r[f],a+=8;a>n;)a-=n,s+=t[o&c>>a];if(a&&(s+=t[o&c<<n-a]),i)for(;s.length*n&7;)s+="=";return s},Wt=({name:r,prefix:t,bitsPerChar:n,alphabet:i})=>qc({prefix:t,name:r,encode(o){return J6(o,i,n)},decode(o){return W6(o,i,n,r)}}),Y6=js({prefix:"9",name:"base10",alphabet:"0123456789"}),Z6=Object.freeze(Object.defineProperty({__proto__:null,base10:Y6},Symbol.toStringTag,{value:"Module"})),X6=Wt({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),Q6=Wt({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4}),eB=Object.freeze(Object.defineProperty({__proto__:null,base16:X6,base16upper:Q6},Symbol.toStringTag,{value:"Module"})),tB=Wt({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1}),rB=Object.freeze(Object.defineProperty({__proto__:null,base2:tB},Symbol.toStringTag,{value:"Module"})),h1=Array.from("🚀🪐☄🛰🌌🌑🌒🌓🌔🌕🌖🌗🌘🌍🌏🌎🐉☀💻🖥💾💿😂❤😍🤣😊🙏💕😭😘👍😅👏😁🔥🥰💔💖💙😢🤔😆🙄💪😉☺👌🤗💜😔😎😇🌹🤦🎉💞✌✨🤷😱😌🌸🙌😋💗💚😏💛🙂💓🤩😄😀🖤😃💯🙈👇🎶😒🤭❣😜💋👀😪😑💥🙋😞😩😡🤪👊🥳😥🤤👉💃😳✋😚😝😴🌟😬🙃🍀🌷😻😓⭐✅🥺🌈😈🤘💦✔😣🏃💐☹🎊💘😠☝😕🌺🎂🌻😐🖕💝🙊😹🗣💫💀👑🎵🤞😛🔴😤🌼😫⚽🤙☕🏆🤫👈😮🙆🍻🍃🐶💁😲🌿🧡🎁⚡🌞🎈❌✊👋😰🤨😶🤝🚶💰🍓💢🤟🙁🚨💨🤬✈🎀🍺🤓😙💟🌱😖👶🥴▶➡❓💎💸⬇😨🌚🦋😷🕺⚠🙅😟😵👎🤲🤠🤧📌🔵💅🧐🐾🍒😗🤑🌊🤯🐷☎💧😯💆👆🎤🙇🍑❄🌴💣🐸💌📍🥀🤢👅💡💩👐📸👻🤐🤮🎼🥵🚩🍎🍊👼💍📣🥂"),nB=h1.reduce((r,t,n)=>(r[n]=t,r),[]),iB=h1.reduce((r,t,n)=>(r[t.codePointAt(0)]=n,r),[]);function oB(r){return r.reduce((t,n)=>(t+=nB[n],t),"")}function sB(r){const t=[];for(const n of r){const i=iB[n.codePointAt(0)];if(i===void 0)throw new Error(`Non-base256emoji character: ${n}`);t.push(i)}return new Uint8Array(t)}const aB=qc({prefix:"🚀",name:"base256emoji",encode:oB,decode:sB}),cB=Object.freeze(Object.defineProperty({__proto__:null,base256emoji:aB},Symbol.toStringTag,{value:"Module"})),fB=Wt({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),uB=Wt({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),lB=Wt({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),hB=Wt({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),dB=Wt({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),pB=Wt({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),gB=Wt({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),yB=Wt({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),wB=Wt({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5}),mB=Object.freeze(Object.defineProperty({__proto__:null,base32:fB,base32hex:dB,base32hexpad:gB,base32hexpadupper:yB,base32hexupper:pB,base32pad:lB,base32padupper:hB,base32upper:uB,base32z:wB},Symbol.toStringTag,{value:"Module"})),bB=js({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),vB=js({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"}),xB=Object.freeze(Object.defineProperty({__proto__:null,base36:bB,base36upper:vB},Symbol.toStringTag,{value:"Module"})),AB=js({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),EB=js({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"}),SB=Object.freeze(Object.defineProperty({__proto__:null,base58btc:AB,base58flickr:EB},Symbol.toStringTag,{value:"Module"})),BB=Wt({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),DB=Wt({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),CB=Wt({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),IB=Wt({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6}),_B=Object.freeze(Object.defineProperty({__proto__:null,base64:BB,base64pad:DB,base64url:CB,base64urlpad:IB},Symbol.toStringTag,{value:"Module"})),MB=Wt({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3}),kB=Object.freeze(Object.defineProperty({__proto__:null,base8:MB},Symbol.toStringTag,{value:"Module"})),TB=qc({prefix:"\0",name:"identity",encode:r=>j6(r),decode:r=>V6(r)}),NB=Object.freeze(Object.defineProperty({__proto__:null,identity:TB},Symbol.toStringTag,{value:"Module"}));new TextEncoder;new TextDecoder;const pp={...NB,...rB,...kB,...Z6,...eB,...mB,...xB,...SB,..._B,...cB};function d1(r,t,n,i){return{name:r,prefix:t,encoder:{name:r,prefix:t,encode:n},decoder:{decode:i}}}const gp=d1("utf8","u",r=>"u"+new TextDecoder("utf8").decode(r),r=>new TextEncoder().encode(r.substring(1))),Xf=d1("ascii","a",r=>{let t="a";for(let n=0;n<r.length;n++)t+=String.fromCharCode(r[n]);return t},r=>{r=r.substring(1);const t=P6(r.length);for(let n=0;n<r.length;n++)t[n]=r.charCodeAt(n);return t}),RB={utf8:gp,"utf-8":gp,hex:pp.base16,latin1:Xf,ascii:Xf,binary:Xf,...pp};function UB(r,t="utf8"){const n=RB[t];if(n==null)throw new Error(`Unsupported encoding "${t}"`);return(t==="utf8"||t==="utf-8")&&globalThis.Buffer!=null&&globalThis.Buffer.from!=null?globalThis.Buffer.from(r.buffer,r.byteOffset,r.byteLength).toString("utf8"):n.encoder.encode(r).substring(1)}const OB=async r=>{const t=/^did:ethr:(0x[0-9a-fA-F]{40})$/,n=r.match(t);if(n){const o=n[1];return{didDocumentMetadata:{},didResolutionMetadata:{contentType:"application/did+ld+json"},didDocument:{"@context":["https://www.w3.org/ns/did/v1","https://w3id.org/security/suites/secp256k1recovery-2020/v2"],id:r,verificationMethod:[{id:`${r}#controller`,type:"EcdsaSecp256k1RecoveryMethod2020",controller:r,blockchainAccountId:"eip155:1:"+o}],authentication:[`${r}#controller`],assertionMethod:[`${r}#controller`]}}}throw new Error(`Unsupported DID format: ${r}`)};function PB(r){const t="=".repeat((4-r.length%4)%4),n=(r+t).replace(/-/g,"+").replace(/_/g,"/"),i=window.atob(n),o=new Uint8Array(i.length);for(let s=0;s<i.length;++s)o[s]=i.charCodeAt(s);return o}const FB="did:ethr:",yp="JWT_VERIFY_FAILED",LB="UNSUPPORTED_DID_METHOD",HB=new JA({ethr:OB});function kD(r){return!!(r!=null&&r.passkeyCredIdHex)}async function $B(r,t,n){if(r!=null&&r.identity){const o=JSON.parse(r.identity).keys[0].privateKeyHex,s=await VB(o),a={issuer:r.did,signer:s,expiresIn:void 0};return n&&(a.expiresIn=n),UE(t,a)}else{if(r!=null&&r.passkeyCredIdHex)return u6(r.did,r.passkeyCredIdHex,t);throw new Error("No identity data found to sign for DID "+r.did)}}function VB(r){const t=wE(Qo(r),!0);return async n=>{const i=await t(n);return jB(i)}}function jB(r){const t=Ar(r);if(t.length<64||t.length>65)throw new TypeError(`Wrong size for signature. Expected 64 or 65 bytes, but got ${t.length}`);const n=wp(t.slice(0,32)),i=wp(t.slice(32,64)),o=t.length===65?t[64]:void 0;return{r:n,s:i,recoveryParam:o}}function wp(r){return UB(r,"base16")}function KB(r){return dc(r)}async function TD(r){const t=r.split("."),n=JSON.parse(dp(t[0])),i=JSON.parse(dp(t[1])),o=i.iss;if(!o)return Promise.reject({clientError:{message:'Missing "iss" field in JWT.'}});if(o.startsWith(FB))try{return await sh(r,{resolver:HB})}catch(s){return Promise.reject({clientError:{message:"JWT failed verification: "+s.toString(),code:yp}})}return o.startsWith(hl)&&n.typ==="JWANT"?await xw(qe.Buffer.from(i),o,PB(t[2]))?{issuer:o,payload:i,verified:!0}:Promise.reject({clientError:{message:"JWT failed verification: "+e.toString(),code:yp}}):o.startsWith(hl)?Promise.reject({clientError:{message:"JWT with a PEER DID currently only supported with typ == JWANT. Contact us us for JWT suport since it should be straightforward."}}):Promise.reject({clientError:{message:`Unsupported DID method ${o}`,code:LB}})}const $n="https://schema.org",p1="endorser.ch",zB="name,did,pubKeyBase64,seesMe,registered",g1="https://endorser.ch",Xa="/contact?jwt=",El="https://endorser.ch/entity/",qB={claim:{"@type":""},handleId:"",id:"",issuedAt:"",issuer:""},y1="did:none:HIDDEN";function w1(r){return r.startsWith("did:")}function Xi(r){return r===y1}function m1(r){return!r||r===y1}function Qa(r,t){if(Object.prototype.toString.call(t)==="[object String]")return r(t);if(t instanceof Object){if(Array.isArray(t)){for(const n of t)if(Qa(r,n))return!0}else for(const n in t)if(Qa(r,t[n]))return!0;return!1}else return!1}function Vh(r){return Qa(Xi,r)}const GB=r=>Qa(t=>w1(t)&&!Xi(t),r);function b1(r){return r&&r.startsWith(El)?r.substring(El.length):r}function v1(r){return r["@context"]===$n?Up(["@context"],r):r}function x1(r,t,n){if(!r.identifier&&t){const i=os(r);return i.lastClaimId=t,i}else if(!r.identifier&&n){const i=os(r);return i.identifier=n,i}else return r}function ec(r){if(r instanceof Object){if(Array.isArray(r))return Z1(ec,r);{const t={};for(const n in r)n.endsWith("VisibleToDids")||(t[n]=ec(os(r[n])));return t}}else return r}function jh(r,t){return m1(r)?void 0:Il(n=>n.did===r,t)}function Kh(r,t,n,i=[],o=!1){return r?r===t?{displayName:"You",known:!0}:n?{displayName:n.name||"Contact With No Name",known:!!n,profileImageUrl:n.profileImageUrl}:Il(Tp(r),i)?{displayName:"You (Alt ID)",known:!0}:Xi(r)?{displayName:"Someone Outside Your View",known:!1}:{displayName:o?r:"Someone Visible But Not In Your Contact List",known:!1}:{displayName:"Someone Unnamed/Unknown",known:!1}}function An(r,t,n,i){const o=jh(r,i);return Kh(r,t,o,n).displayName}function WB(r,t){return Kh(r,void 0,jh(r,t),[],!0).displayName}let ns="",As=0;function JB(){ns="",As=0}function YB(){return!ns||As<new Date().getTime()/1e3?"Token has expired":"Token expires at "+new Date(As*1e3).toLocaleString()}async function vi(r,t,n){const i={"Content-Type":"application/json"};if(r)try{let o;const s=await s1(r);if(s!=null&&s.passkeyCredIdHex)if(ns&&As>Date.now()/1e3)o=ns;else{o=await bp(r),ns=o;const a=await f1();As=Date.now()/1e3+a}else o=await bp(r);i.Authorization="Bearer "+o}catch(o){N1("Something failed in getHeaders call (will proceed anonymously"+(t?" and notify user":"")+"): "+o,!0),t&&t({group:"alert",type:"danger",title:"Personal Data Error",text:n||"Showing anonymous data. See the Help page for help with personal data."},3e3)}return i}const Sl=new hu({max:500});function ZB(r){var i;let t=""+r+" - JSON: "+JSON.stringify(r);const n=JSON.stringify(r.response);if(!nm(n)&&!t.includes(n))if(Tp(r==null?void 0:r.config,(i=r==null?void 0:r.response)==null?void 0:i.config)){const o=JSON.stringify(Up(["config"],r.response));t+=" - .response w/o same config JSON: "+o}else t+=" - .response JSON: "+n;return t}async function XB(r,t,n,i){var s,a;if(!r)return;let o=Sl.get(r);if(!o){const c=n+"/api/v2/report/plans?handleId="+encodeURIComponent(r),f=await vi(i);try{const h=await t.get(c,{headers:f});h.status===200&&((a=(s=h.data)==null?void 0:s.data)==null?void 0:a.length)>0?(o=h.data.data[0],Sl.set(r,o)):console.error("Failed to load plan with handle",r," Got data:",h.data)}catch(h){console.error("Failed to load plan with handle",r," Got error:",h)}}return o}async function QB(r,t){Sl.set(r,t)}async function e4(r,t,n,i,o){let s=`${t}/api/v2/report/offers?recipientDid=${n}`;i&&(s+="&afterId="+i),o&&(s+="&beforeId="+o);const a=await vi(n);return console.log("Using headers: ",a),(await r.get(s,{headers:a})).data}async function t4(r,t,n,i,o){let s=`${t}/api/v2/report/offersToPlansOwnedByMe`;i&&(s+="?afterId="+i),o&&(s+=i?"&":"?",s+="beforeId="+o);const a=await vi(n);return(await r.get(s,{headers:a})).data}function zh(r,t,n,i,o,s,a,c,f=!1,h,d,g){const x=r?os(r):{"@context":$n,"@type":"GiveAction"};return g&&(x.lastClaimId=g,delete x.identifier),x.agent=t?{identifier:t}:void 0,x.recipient=n?{identifier:n}:void 0,x.description=i||void 0,x.object=o&&!isNaN(o)?{amountOfThisGood:o,unitCode:s||"HUR"}:void 0,Array.isArray(x.fulfills)||(x.fulfills=x.fulfills?[x.fulfills]:[]),x.fulfills=x.fulfills.filter(S=>S["@type"]!=="PlanAction"),a&&x.fulfills.push({"@type":"PlanAction",identifier:a}),x.fulfills=x.fulfills.filter(S=>S["@type"]!=="Offer"),c&&x.fulfills.push({"@type":"Offer",identifier:c}),x.fulfills=x.fulfills.filter(S=>S["@type"]!=="DonateAction"&&S["@type"]!=="TradeAction"),x.fulfills.push({"@type":f?"TradeAction":"DonateAction"}),x.image=h||void 0,x.provider=d?{"@type":"PlanAction",identifier:d}:void 0,x}async function r4(r,t,n,i,o,s,a,c,f,h,d=!1,g,x){const S=zh(void 0,i,o,s,a,c,f,h,d,g,x,void 0);return Lo(S,n,t,r)}async function n4(r,t,n,i,o,s,a,c,f,h,d,g=!1,x,S){const D=zh(n.claim,o,s,a,c,f,h,d,g,x,S,n.id);return Lo(D,i,t,r)}function qh(r,t,n,i,o,s,a,c,f,h){const d=r?os(r):{"@context":$n,"@type":"Offer"};return h&&(d.lastClaimId=h,delete d.identifier),d.offeredBy=t?{identifier:t}:void 0,d.recipient=n?{identifier:n}:void 0,d.description=a||void 0,d.includesObject=o&&!isNaN(o)?{amountOfThisGood:o,unitCode:s||"HUR"}:void 0,(i||c)&&(d.itemOffered=d.itemOffered||{},d.itemOffered.description=i||void 0,c&&(d.itemOffered.isPartOf={"@type":"PlanAction",identifier:c})),d.validThrough=f||void 0,d}async function i4(r,t,n,i,o,s,a,c,f,h){const d=qh(void 0,n,f,i,o,s,a,h,c,void 0);return Lo(d,n,t,r)}async function o4(r,t,n,i,o,s,a,c,f,h,d){const g=qh(n.claim,i,h,o,s,a,c,d,f,n.id);return Lo(g,i,t,r)}const s4=async(r,t,n,i,o,s)=>{const a=v1(ec(x1(t,n,i)));return Lo({"@context":$n,"@type":"AgreeAction",object:a},r,o,s)};async function Lo(r,t,n,i){var o,s,a;try{const f=await Ho(t,{vc:{"@context":["https://www.w3.org/2018/credentials/v1"],type:["VerifiableCredential"],credentialSubject:r}}),h=JSON.stringify({jwtEncoded:f}),d=`${n}/api/v2/claim`;return{type:"success",response:await i.post(d,h,{headers:{"Content-Type":"application/json"}})}}catch(c){return console.error("Error submitting claim:",c),{type:"error",error:{error:((a=(s=(o=c.response)==null?void 0:o.data)==null?void 0:s.error)==null?void 0:a.message)||c.message||"Got some error submitting the claim. Check your permissions, network, and error logs."}}}}async function a4(r,t,n,i,o){const s=r.publicKeyHex,a=qe.Buffer.from(s,"hex").toString("base64"),c={iat:Date.now(),iss:r.did,own:{name:n??"",publicEncKey:a,registered:!!t}};if(i&&(c.own.profileImageUrl=i),o&&(r!=null&&r.mnemonic)&&(r!=null&&r.derivationPath)){const d=x4(r.derivationPath),g=C1(r.mnemonic,d)[2],x=qe.Buffer.from(g,"hex"),S=Pl(x),D=qe.Buffer.from(S).toString("base64");c.own.nextPublicEncKeyHash=D}const f=await Ho(r.did,c);return g1+Xa+f}async function Ho(r,t,n){const i=await a1(r);return $B(i,t,n)}const A1=r=>r&&r["@context"]===$n&&r["@type"]==="AcceptAction",E1=r=>r&&r["@context"]===$n&&r["@type"]==="Offer";function S1(r,t){return r==="HUR"?t?"hour":"hours":r}function Bl(r,t){return""+t+" "+S1(r,t===1)}const B1=r=>r?r[0].toUpperCase()+r.substr(1).replace(/([A-Z])/g," $1"):"",Qf=r=>{if(!r)return"something";let t=r;if(r.claim&&(t=r.claim),Array.isArray(t))if(t.length===1)t=t[0];else return"multiple claims";const n=t["@type"];if(n){let i=B1(n);return i==="Person"&&(i+=" claim"),"a "+i}else return"a claim"},c4=(r,t,n,i)=>{var c,f,h,d,g,x,S,D,E,_,T,F,U,z,V,G,ee;let o=r.claim;o.claim&&(o=o.claim);const s=An(r.issuer,t,n,i),a=o["@type"]||"UnknownType";if(a==="AgreeAction")return s+" agreed with "+Qf(o.object);if(A1(o))return s+" accepted "+Qf(o.object);if(a==="GiveAction"){const Q=((c=o.agent)==null?void 0:c.identifier)||((f=o.agent)==null?void 0:f.did),X=An(Q,t,n,i);let se=(h=o.object)!=null&&h.amountOfThisGood?Bl(o.object.unitCode,o.object.amountOfThisGood):"";o.description&&(se&&(se=se+", and also: "),se=se+o.description),se||(se="something not described");const oe=((d=o.recipient)==null?void 0:d.identifier)||((g=o.recipient)==null?void 0:g.did),H=oe?" to "+An(oe,t,n,i):"";return X+" gave"+H+": "+se}else if(a==="JoinAction"){const Q=((x=o.agent)==null?void 0:x.identifier)||((S=o.agent)==null?void 0:S.did),X=An(Q,t,n,i);let se=o.event&&o.event.organizer&&o.event.organizer.name;se=se||"";let oe=o.event&&o.event.name;oe=oe?" "+oe:"";let H=se+oe;H=H?" attended the "+H:"";let v=o.event&&o.event.startTime;return v=v?" at "+v:"",X+H+v}else if(E1(o)){const Q=(D=o.offeredBy)==null?void 0:D.identifier,X=An(Q,t,n,i);let se="";o.includesObject&&(se+=" "+Bl(o.includesObject.unitCode,o.includesObject.amountOfThisGood)),(E=o.itemOffered)!=null&&E.description&&(se+=", saying: "+((_=o.itemOffered)==null?void 0:_.description));const oe=((T=o.recipient)==null?void 0:T.identifier)||((F=o.recipient)==null?void 0:F.did),H=oe?" to "+An(oe,t,n,i):"";return X+" offered"+se+H}else if(a==="PlanAction"){const Q=((U=o.agent)==null?void 0:U.identifier)||r.issuer;return An(Q,t,n,i)+" announced a project: "+o.name}else if(a==="Tenure"){const Q=((z=o.party)==null?void 0:z.identifier)||((V=o.party)==null?void 0:V.did),X=An(Q,t,n,i),se=((ee=(G=o.spatialUnit)==null?void 0:G.geo)==null?void 0:ee.polygon)||"";return X+" possesses ["+se.substring(0,se.indexOf(" "))+"...]"}else return s+" declared "+Qf(o)},f4="https://endorser.ch/entity/01GXYPFF7FA03NXKPYY142PY4H",u4=(r,t)=>({"@context":$n,"@type":"JoinAction",agent:{identifier:r},event:{organizer:{name:"Bountiful Voluntaryist Community"},name:"Saturday Morning Meeting",startTime:t}});async function l4(r,t){return Ho(r,{vc:{"@context":["https://www.w3.org/2018/credentials/v1"],type:["VerifiableCredential"],credentialSubject:t}})}async function D1(r,t,n,i){const o={"@context":$n,"@type":"RegisterAction",agent:{identifier:r},object:p1};return t&&(o.participant={identifier:t.did}),n&&(o.identifier=n),await Ho(r,{vc:{"@context":["https://www.w3.org/2018/credentials/v1"],type:["VerifiableCredential"],credentialSubject:o}},i)}async function h4(r,t,n,i){var c,f,h,d;const o=await D1(r,i),s=t+"/api/v2/claim",a=await n.post(s,{jwtEncoded:o});if((f=(c=a.data)==null?void 0:c.success)!=null&&f.handleId)return{success:!0};if((d=(h=a.data)==null?void 0:h.success)!=null&&d.embeddedRecordError){let g="There was some problem with the registration and so it may not be complete.";return typeof a.data.success.embeddedRecordError=="string"&&(g+=" "+a.data.success.embeddedRecordError),{error:g}}else return console.error(a),{error:"Got a server error when registering."}}async function d4(r,t,n,i,o,s){var h;if(!r)return{error:"Cannot set visibility without an identifier."};const a=t+"/api/report/"+(s?"canSeeMe":"cannotSeeMe"),c=await vi(r),f=JSON.stringify({did:o.did});try{const d=await n.post(a,f,{headers:c});if(d.status===200){const g=d.data.success;return g&&i.contacts.update(o.did,{seesMe:s}),{success:g}}else return console.error("Got some bad server response when setting visibility: ",d.status,d),{error:((h=d.data.error)==null?void 0:h.message)||"Got some error setting visibility."}}catch(d){return console.error("Got some error when setting visibility:",d),{error:"Check connectivity and try again."}}}async function p4(r,t,n){const i=`${r}/api/report/rateLimits`,o=await vi(n);return await t.get(i,{headers:o})}async function g4(r,t){const n=R1+"/image-limits",i=await vi(t);return await r.get(n,{headers:i})}const ND=Object.freeze(Object.defineProperty({__proto__:null,BLANK_GENERIC_SERVER_RECORD:qB,BVC_MEETUPS_PROJECT_CLAIM_ID:f4,CONTACT_CSV_HEADER:zB,CONTACT_URL_PREFIX:g1,ENDORSER_CH_HANDLE_PREFIX:El,ENDORSER_JWT_URL_LOCATION:Xa,SCHEMA_ORG_CONTEXT:$n,SERVICE_ID:p1,addLastClaimOrHandleAsIdIfMissing:x1,bvcMeetingJoinClaim:u4,capitalizeAndInsertSpacesBeforeCaps:B1,claimSpecialDescription:c4,clearPasskeyToken:JB,contactForDid:jh,containsHiddenDid:Vh,containsNonHiddenDid:GB,createAndSubmitClaim:Lo,createAndSubmitConfirmation:s4,createAndSubmitGive:r4,createAndSubmitOffer:i4,createEndorserJwtForDid:Ho,createEndorserJwtVcFromClaim:l4,createInviteJwt:D1,currencyShortWordForCode:S1,didInfo:An,didInfoForCertificate:WB,didInfoForContact:Kh,displayAmount:Bl,editAndSubmitGive:n4,editAndSubmitOffer:o4,errorStringForLog:ZB,fetchEndorserRateLimits:p4,fetchImageRateLimits:g4,generateEndorserJwtForAccount:a4,getHeaders:vi,getNewOffersToUser:e4,getNewOffersToUserProjects:t4,getPlanFromCache:XB,hydrateGive:zh,hydrateOffer:qh,isAccept:A1,isDid:w1,isEmptyOrHiddenDid:m1,isHiddenDid:Xi,isOffer:E1,register:h4,removeSchemaContext:v1,removeVisibleToDids:ec,setPlanInCache:QB,setVisibilityUtil:d4,stripEndorserPrefix:b1,tokenExpiryTimeDescription:YB},Symbol.toStringTag,{value:"Module"}));function y4(r){return"did:ethr"}const mp=y4(),w4="m/84737769'/0'/0'/0'",m4="local",b4=(r,t,n,i)=>({did:mp+":"+r,keys:[{kid:t,kms:m4,meta:{derivationPath:i},privateKeyHex:n,publicKeyHex:t,type:"Secp256k1"}],provider:mp,services:[]}),C1=(r,t=w4)=>{r=r.trim().toLowerCase();const i=Sn.fromMnemonic(r).derivePath(t),o=i.privateKey.substring(2),s=i.publicKey.substring(2);return[i.address,o,s,t]},v4=()=>{const r=wm(32);return $m(r,Vm)},bp=async r=>{if(r){const t=Math.floor(Date.now()/1e3),i={exp:t+60,iat:t,iss:r};return Ho(r,i)}else return""},RD=r=>{let t=r;const n=t.indexOf(Xa);return n>-1&&(t=t.substring(n+Xa.length)),KB(t).payload},x4=r=>{let t=r.split("/").slice(-1)[0];t.endsWith("'")&&(t=t.slice(0,-1));const o=(parseInt(t,10)+1).toString()+(t.endsWith("'")?"'":"");return r.split("/").slice(0,-1).concat([o]).join("/")};export{Tp as $,Bl as A,qB as B,S6 as C,R6 as D,n1 as E,Vh as F,I6 as G,os as H,l4 as I,TD as J,d4 as K,O1 as L,F1 as M,Dl as N,X1 as O,Z1 as P,Mp as Q,Ip as R,$n as S,Np as T,xa as U,Y1 as V,j1 as W,Rp as X,_p as Y,Xh as Z,is as _,u1 as a,ID as a$,ff as a0,z1 as a1,P1 as a2,nm as a3,K1 as a4,W1 as a5,nd as a6,Q1 as a7,Il as a8,eu as a9,GB as aA,M6 as aB,w4 as aC,C1 as aD,b4 as aE,k6 as aF,x4 as aG,D1 as aH,a1 as aI,L4 as aJ,o4 as aK,i4 as aL,qh as aM,C6 as aN,E6 as aO,bp as aP,f4 as aQ,u4 as aR,s4 as aS,c4 as aT,d6 as aU,D6 as aV,B6 as aW,c1 as aX,kD as aY,f6 as aZ,CD as a_,FB as aa,a4 as ab,RD as ac,w1 as ad,h4 as ae,KB as af,T6 as ag,g1 as ah,zB as ai,v6 as aj,Ho as ak,B1 as al,Kh as am,i1 as an,t1 as ao,XB as ap,n4 as aq,r4 as ar,zh as as,h6 as at,U6 as au,m6 as av,PB as aw,e4 as ax,t4 as ay,N6 as az,qe as b,_D as b0,g4 as c,JB as d,_6 as e,p4 as f,vi as g,An as h,b6 as i,Al as j,A6 as k,MD as l,jh as m,v1 as n,Up as o,ec as p,x1 as q,s1 as r,ND as s,YB as t,Lo as u,o1 as v,b1 as w,ZB as x,WB as y,Xi as z};