@omnisat/lasereyes 0.0.94 → 0.0.96

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -10981,7 +10981,7 @@ async function m1(e, t, r, n, i, o, s = 7) {
10981
10981
  value: BigInt(n)
10982
10982
  }), v > g && h.addOutput({
10983
10983
  address: t,
10984
- value: BigInt(v - g - n)
10984
+ value: BigInt(v - g)
10985
10985
  }), {
10986
10986
  psbtBase64: h.toBase64(),
10987
10987
  psbtHex: h.toHex()
@@ -25508,7 +25508,7 @@ async function ob(e, t, r, n, i, o, s = 7) {
25508
25508
  value: BigInt(n)
25509
25509
  }), v > g && h.addOutput({
25510
25510
  address: t,
25511
- value: BigInt(v - g - n)
25511
+ value: BigInt(v - g)
25512
25512
  }), {
25513
25513
  psbtBase64: h.toBase64(),
25514
25514
  psbtHex: h.toHex()
@@ -13,7 +13,7 @@ PROCEED WITH CAUTION!
13
13
  *
14
14
  * @author Feross Aboukhadijeh <https://feross.org>
15
15
  * @license MIT
16
- */(function(e){const t=Gs,r=kh,n=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):null;e.Buffer=a,e.SlowBuffer=I,e.INSPECT_MAX_BYTES=50;const i=2147483647;e.kMaxLength=i,a.TYPED_ARRAY_SUPPORT=o(),!a.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 o(){try{const c=new Uint8Array(1),l={foo:function(){return 42}};return Object.setPrototypeOf(l,Uint8Array.prototype),Object.setPrototypeOf(c,l),c.foo()===42}catch{return!1}}Object.defineProperty(a.prototype,"parent",{enumerable:!0,get:function(){if(a.isBuffer(this))return this.buffer}}),Object.defineProperty(a.prototype,"offset",{enumerable:!0,get:function(){if(a.isBuffer(this))return this.byteOffset}});function s(c){if(c>i)throw new RangeError('The value "'+c+'" is invalid for option "size"');const l=new Uint8Array(c);return Object.setPrototypeOf(l,a.prototype),l}function a(c,l,p){if(typeof c=="number"){if(typeof l=="string")throw new TypeError('The "string" argument must be of type string. Received type number');return d(c)}return u(c,l,p)}a.poolSize=8192;function u(c,l,p){if(typeof c=="string")return g(c,l);if(ArrayBuffer.isView(c))return E(c);if(c==null)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof c);if(ze(c,ArrayBuffer)||c&&ze(c.buffer,ArrayBuffer)||typeof SharedArrayBuffer<"u"&&(ze(c,SharedArrayBuffer)||c&&ze(c.buffer,SharedArrayBuffer)))return T(c,l,p);if(typeof c=="number")throw new TypeError('The "value" argument must not be of type number. Received type number');const m=c.valueOf&&c.valueOf();if(m!=null&&m!==c)return a.from(m,l,p);const S=x(c);if(S)return S;if(typeof Symbol<"u"&&Symbol.toPrimitive!=null&&typeof c[Symbol.toPrimitive]=="function")return a.from(c[Symbol.toPrimitive]("string"),l,p);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof c)}a.from=function(c,l,p){return u(c,l,p)},Object.setPrototypeOf(a.prototype,Uint8Array.prototype),Object.setPrototypeOf(a,Uint8Array);function f(c){if(typeof c!="number")throw new TypeError('"size" argument must be of type number');if(c<0)throw new RangeError('The value "'+c+'" is invalid for option "size"')}function h(c,l,p){return f(c),c<=0?s(c):l!==void 0?typeof p=="string"?s(c).fill(l,p):s(c).fill(l):s(c)}a.alloc=function(c,l,p){return h(c,l,p)};function d(c){return f(c),s(c<0?0:N(c)|0)}a.allocUnsafe=function(c){return d(c)},a.allocUnsafeSlow=function(c){return d(c)};function g(c,l){if((typeof l!="string"||l==="")&&(l="utf8"),!a.isEncoding(l))throw new TypeError("Unknown encoding: "+l);const p=k(c,l)|0;let m=s(p);const S=m.write(c,l);return S!==p&&(m=m.slice(0,S)),m}function v(c){const l=c.length<0?0:N(c.length)|0,p=s(l);for(let m=0;m<l;m+=1)p[m]=c[m]&255;return p}function E(c){if(ze(c,Uint8Array)){const l=new Uint8Array(c);return T(l.buffer,l.byteOffset,l.byteLength)}return v(c)}function T(c,l,p){if(l<0||c.byteLength<l)throw new RangeError('"offset" is outside of buffer bounds');if(c.byteLength<l+(p||0))throw new RangeError('"length" is outside of buffer bounds');let m;return l===void 0&&p===void 0?m=new Uint8Array(c):p===void 0?m=new Uint8Array(c,l):m=new Uint8Array(c,l,p),Object.setPrototypeOf(m,a.prototype),m}function x(c){if(a.isBuffer(c)){const l=N(c.length)|0,p=s(l);return p.length===0||c.copy(p,0,0,l),p}if(c.length!==void 0)return typeof c.length!="number"||sr(c.length)?s(0):v(c);if(c.type==="Buffer"&&Array.isArray(c.data))return v(c.data)}function N(c){if(c>=i)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+i.toString(16)+" bytes");return c|0}function I(c){return+c!=c&&(c=0),a.alloc(+c)}a.isBuffer=function(c){return c!=null&&c._isBuffer===!0&&c!==a.prototype},a.compare=function(c,l){if(ze(c,Uint8Array)&&(c=a.from(c,c.offset,c.byteLength)),ze(l,Uint8Array)&&(l=a.from(l,l.offset,l.byteLength)),!a.isBuffer(c)||!a.isBuffer(l))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(c===l)return 0;let p=c.length,m=l.length;for(let S=0,O=Math.min(p,m);S<O;++S)if(c[S]!==l[S]){p=c[S],m=l[S];break}return p<m?-1:m<p?1:0},a.isEncoding=function(c){switch(String(c).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}},a.concat=function(c,l){if(!Array.isArray(c))throw new TypeError('"list" argument must be an Array of Buffers');if(c.length===0)return a.alloc(0);let p;if(l===void 0)for(l=0,p=0;p<c.length;++p)l+=c[p].length;const m=a.allocUnsafe(l);let S=0;for(p=0;p<c.length;++p){let O=c[p];if(ze(O,Uint8Array))S+O.length>m.length?(a.isBuffer(O)||(O=a.from(O)),O.copy(m,S)):Uint8Array.prototype.set.call(m,O,S);else if(a.isBuffer(O))O.copy(m,S);else throw new TypeError('"list" argument must be an Array of Buffers');S+=O.length}return m};function k(c,l){if(a.isBuffer(c))return c.length;if(ArrayBuffer.isView(c)||ze(c,ArrayBuffer))return c.byteLength;if(typeof c!="string")throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof c);const p=c.length,m=arguments.length>2&&arguments[2]===!0;if(!m&&p===0)return 0;let S=!1;for(;;)switch(l){case"ascii":case"latin1":case"binary":return p;case"utf8":case"utf-8":return Lt(c).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return p*2;case"hex":return p>>>1;case"base64":return On(c).length;default:if(S)return m?-1:Lt(c).length;l=(""+l).toLowerCase(),S=!0}}a.byteLength=k;function B(c,l,p){let m=!1;if((l===void 0||l<0)&&(l=0),l>this.length||((p===void 0||p>this.length)&&(p=this.length),p<=0)||(p>>>=0,l>>>=0,p<=l))return"";for(c||(c="utf8");;)switch(c){case"hex":return je(this,l,p);case"utf8":case"utf-8":return oe(this,l,p);case"ascii":return Ae(this,l,p);case"latin1":case"binary":return Et(this,l,p);case"base64":return F(this,l,p);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return Ce(this,l,p);default:if(m)throw new TypeError("Unknown encoding: "+c);c=(c+"").toLowerCase(),m=!0}}a.prototype._isBuffer=!0;function W(c,l,p){const m=c[l];c[l]=c[p],c[p]=m}a.prototype.swap16=function(){const c=this.length;if(c%2!==0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(let l=0;l<c;l+=2)W(this,l,l+1);return this},a.prototype.swap32=function(){const c=this.length;if(c%4!==0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(let l=0;l<c;l+=4)W(this,l,l+3),W(this,l+1,l+2);return this},a.prototype.swap64=function(){const c=this.length;if(c%8!==0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(let l=0;l<c;l+=8)W(this,l,l+7),W(this,l+1,l+6),W(this,l+2,l+5),W(this,l+3,l+4);return this},a.prototype.toString=function(){const c=this.length;return c===0?"":arguments.length===0?oe(this,0,c):B.apply(this,arguments)},a.prototype.toLocaleString=a.prototype.toString,a.prototype.equals=function(c){if(!a.isBuffer(c))throw new TypeError("Argument must be a Buffer");return this===c?!0:a.compare(this,c)===0},a.prototype.inspect=function(){let c="";const l=e.INSPECT_MAX_BYTES;return c=this.toString("hex",0,l).replace(/(.{2})/g,"$1 ").trim(),this.length>l&&(c+=" ... "),"<Buffer "+c+">"},n&&(a.prototype[n]=a.prototype.inspect),a.prototype.compare=function(c,l,p,m,S){if(ze(c,Uint8Array)&&(c=a.from(c,c.offset,c.byteLength)),!a.isBuffer(c))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof c);if(l===void 0&&(l=0),p===void 0&&(p=c?c.length:0),m===void 0&&(m=0),S===void 0&&(S=this.length),l<0||p>c.length||m<0||S>this.length)throw new RangeError("out of range index");if(m>=S&&l>=p)return 0;if(m>=S)return-1;if(l>=p)return 1;if(l>>>=0,p>>>=0,m>>>=0,S>>>=0,this===c)return 0;let O=S-m,U=p-l;const ce=Math.min(O,U),ke=this.slice(m,S),le=c.slice(l,p);for(let ae=0;ae<ce;++ae)if(ke[ae]!==le[ae]){O=ke[ae],U=le[ae];break}return O<U?-1:U<O?1:0};function V(c,l,p,m,S){if(c.length===0)return-1;if(typeof p=="string"?(m=p,p=0):p>2147483647?p=2147483647:p<-2147483648&&(p=-2147483648),p=+p,sr(p)&&(p=S?0:c.length-1),p<0&&(p=c.length+p),p>=c.length){if(S)return-1;p=c.length-1}else if(p<0)if(S)p=0;else return-1;if(typeof l=="string"&&(l=a.from(l,m)),a.isBuffer(l))return l.length===0?-1:Ue(c,l,p,m,S);if(typeof l=="number")return l=l&255,typeof Uint8Array.prototype.indexOf=="function"?S?Uint8Array.prototype.indexOf.call(c,l,p):Uint8Array.prototype.lastIndexOf.call(c,l,p):Ue(c,[l],p,m,S);throw new TypeError("val must be string, number or Buffer")}function Ue(c,l,p,m,S){let O=1,U=c.length,ce=l.length;if(m!==void 0&&(m=String(m).toLowerCase(),m==="ucs2"||m==="ucs-2"||m==="utf16le"||m==="utf-16le")){if(c.length<2||l.length<2)return-1;O=2,U/=2,ce/=2,p/=2}function ke(ae,me){return O===1?ae[me]:ae.readUInt16BE(me*O)}let le;if(S){let ae=-1;for(le=p;le<U;le++)if(ke(c,le)===ke(l,ae===-1?0:le-ae)){if(ae===-1&&(ae=le),le-ae+1===ce)return ae*O}else ae!==-1&&(le-=le-ae),ae=-1}else for(p+ce>U&&(p=U-ce),le=p;le>=0;le--){let ae=!0;for(let me=0;me<ce;me++)if(ke(c,le+me)!==ke(l,me)){ae=!1;break}if(ae)return le}return-1}a.prototype.includes=function(c,l,p){return this.indexOf(c,l,p)!==-1},a.prototype.indexOf=function(c,l,p){return V(this,c,l,p,!0)},a.prototype.lastIndexOf=function(c,l,p){return V(this,c,l,p,!1)};function Le(c,l,p,m){p=Number(p)||0;const S=c.length-p;m?(m=Number(m),m>S&&(m=S)):m=S;const O=l.length;m>O/2&&(m=O/2);let U;for(U=0;U<m;++U){const ce=parseInt(l.substr(U*2,2),16);if(sr(ce))return U;c[p+U]=ce}return U}function Je(c,l,p,m){return Mt(Lt(l,c.length-p),c,p,m)}function Fe(c,l,p,m){return Mt(Xr(l),c,p,m)}function Ye(c,l,p,m){return Mt(On(l),c,p,m)}function C(c,l,p,m){return Mt(Jr(l,c.length-p),c,p,m)}a.prototype.write=function(c,l,p,m){if(l===void 0)m="utf8",p=this.length,l=0;else if(p===void 0&&typeof l=="string")m=l,p=this.length,l=0;else if(isFinite(l))l=l>>>0,isFinite(p)?(p=p>>>0,m===void 0&&(m="utf8")):(m=p,p=void 0);else throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");const S=this.length-l;if((p===void 0||p>S)&&(p=S),c.length>0&&(p<0||l<0)||l>this.length)throw new RangeError("Attempt to write outside buffer bounds");m||(m="utf8");let O=!1;for(;;)switch(m){case"hex":return Le(this,c,l,p);case"utf8":case"utf-8":return Je(this,c,l,p);case"ascii":case"latin1":case"binary":return Fe(this,c,l,p);case"base64":return Ye(this,c,l,p);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return C(this,c,l,p);default:if(O)throw new TypeError("Unknown encoding: "+m);m=(""+m).toLowerCase(),O=!0}},a.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function F(c,l,p){return l===0&&p===c.length?t.fromByteArray(c):t.fromByteArray(c.slice(l,p))}function oe(c,l,p){p=Math.min(c.length,p);const m=[];let S=l;for(;S<p;){const O=c[S];let U=null,ce=O>239?4:O>223?3:O>191?2:1;if(S+ce<=p){let ke,le,ae,me;switch(ce){case 1:O<128&&(U=O);break;case 2:ke=c[S+1],(ke&192)===128&&(me=(O&31)<<6|ke&63,me>127&&(U=me));break;case 3:ke=c[S+1],le=c[S+2],(ke&192)===128&&(le&192)===128&&(me=(O&15)<<12|(ke&63)<<6|le&63,me>2047&&(me<55296||me>57343)&&(U=me));break;case 4:ke=c[S+1],le=c[S+2],ae=c[S+3],(ke&192)===128&&(le&192)===128&&(ae&192)===128&&(me=(O&15)<<18|(ke&63)<<12|(le&63)<<6|ae&63,me>65535&&me<1114112&&(U=me))}}U===null?(U=65533,ce=1):U>65535&&(U-=65536,m.push(U>>>10&1023|55296),U=56320|U&1023),m.push(U),S+=ce}return ue(m)}const J=4096;function ue(c){const l=c.length;if(l<=J)return String.fromCharCode.apply(String,c);let p="",m=0;for(;m<l;)p+=String.fromCharCode.apply(String,c.slice(m,m+=J));return p}function Ae(c,l,p){let m="";p=Math.min(c.length,p);for(let S=l;S<p;++S)m+=String.fromCharCode(c[S]&127);return m}function Et(c,l,p){let m="";p=Math.min(c.length,p);for(let S=l;S<p;++S)m+=String.fromCharCode(c[S]);return m}function je(c,l,p){const m=c.length;(!l||l<0)&&(l=0),(!p||p<0||p>m)&&(p=m);let S="";for(let O=l;O<p;++O)S+=wi[c[O]];return S}function Ce(c,l,p){const m=c.slice(l,p);let S="";for(let O=0;O<m.length-1;O+=2)S+=String.fromCharCode(m[O]+m[O+1]*256);return S}a.prototype.slice=function(c,l){const p=this.length;c=~~c,l=l===void 0?p:~~l,c<0?(c+=p,c<0&&(c=0)):c>p&&(c=p),l<0?(l+=p,l<0&&(l=0)):l>p&&(l=p),l<c&&(l=c);const m=this.subarray(c,l);return Object.setPrototypeOf(m,a.prototype),m};function re(c,l,p){if(c%1!==0||c<0)throw new RangeError("offset is not uint");if(c+l>p)throw new RangeError("Trying to access beyond buffer length")}a.prototype.readUintLE=a.prototype.readUIntLE=function(c,l,p){c=c>>>0,l=l>>>0,p||re(c,l,this.length);let m=this[c],S=1,O=0;for(;++O<l&&(S*=256);)m+=this[c+O]*S;return m},a.prototype.readUintBE=a.prototype.readUIntBE=function(c,l,p){c=c>>>0,l=l>>>0,p||re(c,l,this.length);let m=this[c+--l],S=1;for(;l>0&&(S*=256);)m+=this[c+--l]*S;return m},a.prototype.readUint8=a.prototype.readUInt8=function(c,l){return c=c>>>0,l||re(c,1,this.length),this[c]},a.prototype.readUint16LE=a.prototype.readUInt16LE=function(c,l){return c=c>>>0,l||re(c,2,this.length),this[c]|this[c+1]<<8},a.prototype.readUint16BE=a.prototype.readUInt16BE=function(c,l){return c=c>>>0,l||re(c,2,this.length),this[c]<<8|this[c+1]},a.prototype.readUint32LE=a.prototype.readUInt32LE=function(c,l){return c=c>>>0,l||re(c,4,this.length),(this[c]|this[c+1]<<8|this[c+2]<<16)+this[c+3]*16777216},a.prototype.readUint32BE=a.prototype.readUInt32BE=function(c,l){return c=c>>>0,l||re(c,4,this.length),this[c]*16777216+(this[c+1]<<16|this[c+2]<<8|this[c+3])},a.prototype.readBigUInt64LE=rt(function(c){c=c>>>0,Ve(c,"offset");const l=this[c],p=this[c+7];(l===void 0||p===void 0)&&wt(c,this.length-8);const m=l+this[++c]*2**8+this[++c]*2**16+this[++c]*2**24,S=this[++c]+this[++c]*2**8+this[++c]*2**16+p*2**24;return BigInt(m)+(BigInt(S)<<BigInt(32))}),a.prototype.readBigUInt64BE=rt(function(c){c=c>>>0,Ve(c,"offset");const l=this[c],p=this[c+7];(l===void 0||p===void 0)&&wt(c,this.length-8);const m=l*2**24+this[++c]*2**16+this[++c]*2**8+this[++c],S=this[++c]*2**24+this[++c]*2**16+this[++c]*2**8+p;return(BigInt(m)<<BigInt(32))+BigInt(S)}),a.prototype.readIntLE=function(c,l,p){c=c>>>0,l=l>>>0,p||re(c,l,this.length);let m=this[c],S=1,O=0;for(;++O<l&&(S*=256);)m+=this[c+O]*S;return S*=128,m>=S&&(m-=Math.pow(2,8*l)),m},a.prototype.readIntBE=function(c,l,p){c=c>>>0,l=l>>>0,p||re(c,l,this.length);let m=l,S=1,O=this[c+--m];for(;m>0&&(S*=256);)O+=this[c+--m]*S;return S*=128,O>=S&&(O-=Math.pow(2,8*l)),O},a.prototype.readInt8=function(c,l){return c=c>>>0,l||re(c,1,this.length),this[c]&128?(255-this[c]+1)*-1:this[c]},a.prototype.readInt16LE=function(c,l){c=c>>>0,l||re(c,2,this.length);const p=this[c]|this[c+1]<<8;return p&32768?p|4294901760:p},a.prototype.readInt16BE=function(c,l){c=c>>>0,l||re(c,2,this.length);const p=this[c+1]|this[c]<<8;return p&32768?p|4294901760:p},a.prototype.readInt32LE=function(c,l){return c=c>>>0,l||re(c,4,this.length),this[c]|this[c+1]<<8|this[c+2]<<16|this[c+3]<<24},a.prototype.readInt32BE=function(c,l){return c=c>>>0,l||re(c,4,this.length),this[c]<<24|this[c+1]<<16|this[c+2]<<8|this[c+3]},a.prototype.readBigInt64LE=rt(function(c){c=c>>>0,Ve(c,"offset");const l=this[c],p=this[c+7];(l===void 0||p===void 0)&&wt(c,this.length-8);const m=this[c+4]+this[c+5]*2**8+this[c+6]*2**16+(p<<24);return(BigInt(m)<<BigInt(32))+BigInt(l+this[++c]*2**8+this[++c]*2**16+this[++c]*2**24)}),a.prototype.readBigInt64BE=rt(function(c){c=c>>>0,Ve(c,"offset");const l=this[c],p=this[c+7];(l===void 0||p===void 0)&&wt(c,this.length-8);const m=(l<<24)+this[++c]*2**16+this[++c]*2**8+this[++c];return(BigInt(m)<<BigInt(32))+BigInt(this[++c]*2**24+this[++c]*2**16+this[++c]*2**8+p)}),a.prototype.readFloatLE=function(c,l){return c=c>>>0,l||re(c,4,this.length),r.read(this,c,!0,23,4)},a.prototype.readFloatBE=function(c,l){return c=c>>>0,l||re(c,4,this.length),r.read(this,c,!1,23,4)},a.prototype.readDoubleLE=function(c,l){return c=c>>>0,l||re(c,8,this.length),r.read(this,c,!0,52,8)},a.prototype.readDoubleBE=function(c,l){return c=c>>>0,l||re(c,8,this.length),r.read(this,c,!1,52,8)};function Ne(c,l,p,m,S,O){if(!a.isBuffer(c))throw new TypeError('"buffer" argument must be a Buffer instance');if(l>S||l<O)throw new RangeError('"value" argument is out of bounds');if(p+m>c.length)throw new RangeError("Index out of range")}a.prototype.writeUintLE=a.prototype.writeUIntLE=function(c,l,p,m){if(c=+c,l=l>>>0,p=p>>>0,!m){const U=Math.pow(2,8*p)-1;Ne(this,c,l,p,U,0)}let S=1,O=0;for(this[l]=c&255;++O<p&&(S*=256);)this[l+O]=c/S&255;return l+p},a.prototype.writeUintBE=a.prototype.writeUIntBE=function(c,l,p,m){if(c=+c,l=l>>>0,p=p>>>0,!m){const U=Math.pow(2,8*p)-1;Ne(this,c,l,p,U,0)}let S=p-1,O=1;for(this[l+S]=c&255;--S>=0&&(O*=256);)this[l+S]=c/O&255;return l+p},a.prototype.writeUint8=a.prototype.writeUInt8=function(c,l,p){return c=+c,l=l>>>0,p||Ne(this,c,l,1,255,0),this[l]=c&255,l+1},a.prototype.writeUint16LE=a.prototype.writeUInt16LE=function(c,l,p){return c=+c,l=l>>>0,p||Ne(this,c,l,2,65535,0),this[l]=c&255,this[l+1]=c>>>8,l+2},a.prototype.writeUint16BE=a.prototype.writeUInt16BE=function(c,l,p){return c=+c,l=l>>>0,p||Ne(this,c,l,2,65535,0),this[l]=c>>>8,this[l+1]=c&255,l+2},a.prototype.writeUint32LE=a.prototype.writeUInt32LE=function(c,l,p){return c=+c,l=l>>>0,p||Ne(this,c,l,4,4294967295,0),this[l+3]=c>>>24,this[l+2]=c>>>16,this[l+1]=c>>>8,this[l]=c&255,l+4},a.prototype.writeUint32BE=a.prototype.writeUInt32BE=function(c,l,p){return c=+c,l=l>>>0,p||Ne(this,c,l,4,4294967295,0),this[l]=c>>>24,this[l+1]=c>>>16,this[l+2]=c>>>8,this[l+3]=c&255,l+4};function L(c,l,p,m,S){Er(l,m,S,c,p,7);let O=Number(l&BigInt(4294967295));c[p++]=O,O=O>>8,c[p++]=O,O=O>>8,c[p++]=O,O=O>>8,c[p++]=O;let U=Number(l>>BigInt(32)&BigInt(4294967295));return c[p++]=U,U=U>>8,c[p++]=U,U=U>>8,c[p++]=U,U=U>>8,c[p++]=U,p}function He(c,l,p,m,S){Er(l,m,S,c,p,7);let O=Number(l&BigInt(4294967295));c[p+7]=O,O=O>>8,c[p+6]=O,O=O>>8,c[p+5]=O,O=O>>8,c[p+4]=O;let U=Number(l>>BigInt(32)&BigInt(4294967295));return c[p+3]=U,U=U>>8,c[p+2]=U,U=U>>8,c[p+1]=U,U=U>>8,c[p]=U,p+8}a.prototype.writeBigUInt64LE=rt(function(c,l=0){return L(this,c,l,BigInt(0),BigInt("0xffffffffffffffff"))}),a.prototype.writeBigUInt64BE=rt(function(c,l=0){return He(this,c,l,BigInt(0),BigInt("0xffffffffffffffff"))}),a.prototype.writeIntLE=function(c,l,p,m){if(c=+c,l=l>>>0,!m){const ce=Math.pow(2,8*p-1);Ne(this,c,l,p,ce-1,-ce)}let S=0,O=1,U=0;for(this[l]=c&255;++S<p&&(O*=256);)c<0&&U===0&&this[l+S-1]!==0&&(U=1),this[l+S]=(c/O>>0)-U&255;return l+p},a.prototype.writeIntBE=function(c,l,p,m){if(c=+c,l=l>>>0,!m){const ce=Math.pow(2,8*p-1);Ne(this,c,l,p,ce-1,-ce)}let S=p-1,O=1,U=0;for(this[l+S]=c&255;--S>=0&&(O*=256);)c<0&&U===0&&this[l+S+1]!==0&&(U=1),this[l+S]=(c/O>>0)-U&255;return l+p},a.prototype.writeInt8=function(c,l,p){return c=+c,l=l>>>0,p||Ne(this,c,l,1,127,-128),c<0&&(c=255+c+1),this[l]=c&255,l+1},a.prototype.writeInt16LE=function(c,l,p){return c=+c,l=l>>>0,p||Ne(this,c,l,2,32767,-32768),this[l]=c&255,this[l+1]=c>>>8,l+2},a.prototype.writeInt16BE=function(c,l,p){return c=+c,l=l>>>0,p||Ne(this,c,l,2,32767,-32768),this[l]=c>>>8,this[l+1]=c&255,l+2},a.prototype.writeInt32LE=function(c,l,p){return c=+c,l=l>>>0,p||Ne(this,c,l,4,2147483647,-2147483648),this[l]=c&255,this[l+1]=c>>>8,this[l+2]=c>>>16,this[l+3]=c>>>24,l+4},a.prototype.writeInt32BE=function(c,l,p){return c=+c,l=l>>>0,p||Ne(this,c,l,4,2147483647,-2147483648),c<0&&(c=4294967295+c+1),this[l]=c>>>24,this[l+1]=c>>>16,this[l+2]=c>>>8,this[l+3]=c&255,l+4},a.prototype.writeBigInt64LE=rt(function(c,l=0){return L(this,c,l,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))}),a.prototype.writeBigInt64BE=rt(function(c,l=0){return He(this,c,l,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});function Pn(c,l,p,m,S,O){if(p+m>c.length)throw new RangeError("Index out of range");if(p<0)throw new RangeError("Index out of range")}function gt(c,l,p,m,S){return l=+l,p=p>>>0,S||Pn(c,l,p,4),r.write(c,l,p,m,23,4),p+4}a.prototype.writeFloatLE=function(c,l,p){return gt(this,c,l,!0,p)},a.prototype.writeFloatBE=function(c,l,p){return gt(this,c,l,!1,p)};function Nr(c,l,p,m,S){return l=+l,p=p>>>0,S||Pn(c,l,p,8),r.write(c,l,p,m,52,8),p+8}a.prototype.writeDoubleLE=function(c,l,p){return Nr(this,c,l,!0,p)},a.prototype.writeDoubleBE=function(c,l,p){return Nr(this,c,l,!1,p)},a.prototype.copy=function(c,l,p,m){if(!a.isBuffer(c))throw new TypeError("argument should be a Buffer");if(p||(p=0),!m&&m!==0&&(m=this.length),l>=c.length&&(l=c.length),l||(l=0),m>0&&m<p&&(m=p),m===p||c.length===0||this.length===0)return 0;if(l<0)throw new RangeError("targetStart out of bounds");if(p<0||p>=this.length)throw new RangeError("Index out of range");if(m<0)throw new RangeError("sourceEnd out of bounds");m>this.length&&(m=this.length),c.length-l<m-p&&(m=c.length-l+p);const S=m-p;return this===c&&typeof Uint8Array.prototype.copyWithin=="function"?this.copyWithin(l,p,m):Uint8Array.prototype.set.call(c,this.subarray(p,m),l),S},a.prototype.fill=function(c,l,p,m){if(typeof c=="string"){if(typeof l=="string"?(m=l,l=0,p=this.length):typeof p=="string"&&(m=p,p=this.length),m!==void 0&&typeof m!="string")throw new TypeError("encoding must be a string");if(typeof m=="string"&&!a.isEncoding(m))throw new TypeError("Unknown encoding: "+m);if(c.length===1){const O=c.charCodeAt(0);(m==="utf8"&&O<128||m==="latin1")&&(c=O)}}else typeof c=="number"?c=c&255:typeof c=="boolean"&&(c=Number(c));if(l<0||this.length<l||this.length<p)throw new RangeError("Out of range index");if(p<=l)return this;l=l>>>0,p=p===void 0?this.length:p>>>0,c||(c=0);let S;if(typeof c=="number")for(S=l;S<p;++S)this[S]=c;else{const O=a.isBuffer(c)?c:a.from(c,m),U=O.length;if(U===0)throw new TypeError('The value "'+c+'" is invalid for argument "value"');for(S=0;S<p-l;++S)this[S+l]=O[S%U]}return this};const At={};function Ht(c,l,p){At[c]=class extends p{constructor(){super(),Object.defineProperty(this,"message",{value:l.apply(this,arguments),writable:!0,configurable:!0}),this.name=`${this.name} [${c}]`,this.stack,delete this.name}get code(){return c}set code(m){Object.defineProperty(this,"code",{configurable:!0,enumerable:!0,value:m,writable:!0})}toString(){return`${this.name} [${c}]: ${this.message}`}}}Ht("ERR_BUFFER_OUT_OF_BOUNDS",function(c){return c?`${c} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"},RangeError),Ht("ERR_INVALID_ARG_TYPE",function(c,l){return`The "${c}" argument must be of type number. Received type ${typeof l}`},TypeError),Ht("ERR_OUT_OF_RANGE",function(c,l,p){let m=`The value of "${c}" is out of range.`,S=p;return Number.isInteger(p)&&Math.abs(p)>2**32?S=st(String(p)):typeof p=="bigint"&&(S=String(p),(p>BigInt(2)**BigInt(32)||p<-(BigInt(2)**BigInt(32)))&&(S=st(S)),S+="n"),m+=` It must be ${l}. Received ${S}`,m},RangeError);function st(c){let l="",p=c.length;const m=c[0]==="-"?1:0;for(;p>=m+4;p-=3)l=`_${c.slice(p-3,p)}${l}`;return`${c.slice(0,p)}${l}`}function Dt(c,l,p){Ve(l,"offset"),(c[l]===void 0||c[l+p]===void 0)&&wt(l,c.length-(p+1))}function Er(c,l,p,m,S,O){if(c>p||c<l){const U=typeof l=="bigint"?"n":"";let ce;throw l===0||l===BigInt(0)?ce=`>= 0${U} and < 2${U} ** ${(O+1)*8}${U}`:ce=`>= -(2${U} ** ${(O+1)*8-1}${U}) and < 2 ** ${(O+1)*8-1}${U}`,new At.ERR_OUT_OF_RANGE("value",ce,c)}Dt(m,S,O)}function Ve(c,l){if(typeof c!="number")throw new At.ERR_INVALID_ARG_TYPE(l,"number",c)}function wt(c,l,p){throw Math.floor(c)!==c?(Ve(c,p),new At.ERR_OUT_OF_RANGE("offset","an integer",c)):l<0?new At.ERR_BUFFER_OUT_OF_BOUNDS:new At.ERR_OUT_OF_RANGE("offset",`>= 0 and <= ${l}`,c)}const Ar=/[^+/0-9A-Za-z-_]/g;function nt(c){if(c=c.split("=")[0],c=c.trim().replace(Ar,""),c.length<2)return"";for(;c.length%4!==0;)c=c+"=";return c}function Lt(c,l){l=l||1/0;let p;const m=c.length;let S=null;const O=[];for(let U=0;U<m;++U){if(p=c.charCodeAt(U),p>55295&&p<57344){if(!S){if(p>56319){(l-=3)>-1&&O.push(239,191,189);continue}else if(U+1===m){(l-=3)>-1&&O.push(239,191,189);continue}S=p;continue}if(p<56320){(l-=3)>-1&&O.push(239,191,189),S=p;continue}p=(S-55296<<10|p-56320)+65536}else S&&(l-=3)>-1&&O.push(239,191,189);if(S=null,p<128){if((l-=1)<0)break;O.push(p)}else if(p<2048){if((l-=2)<0)break;O.push(p>>6|192,p&63|128)}else if(p<65536){if((l-=3)<0)break;O.push(p>>12|224,p>>6&63|128,p&63|128)}else if(p<1114112){if((l-=4)<0)break;O.push(p>>18|240,p>>12&63|128,p>>6&63|128,p&63|128)}else throw new Error("Invalid code point")}return O}function Xr(c){const l=[];for(let p=0;p<c.length;++p)l.push(c.charCodeAt(p)&255);return l}function Jr(c,l){let p,m,S;const O=[];for(let U=0;U<c.length&&!((l-=2)<0);++U)p=c.charCodeAt(U),m=p>>8,S=p%256,O.push(S),O.push(m);return O}function On(c){return t.toByteArray(nt(c))}function Mt(c,l,p,m){let S;for(S=0;S<m&&!(S+p>=l.length||S>=c.length);++S)l[S+p]=c[S];return S}function ze(c,l){return c instanceof l||c!=null&&c.constructor!=null&&c.constructor.name!=null&&c.constructor.name===l.name}function sr(c){return c!==c}const wi=function(){const c="0123456789abcdef",l=new Array(256);for(let p=0;p<16;++p){const m=p*16;for(let S=0;S<16;++S)l[m+S]=c[p]+c[S]}return l}();function rt(c){return typeof BigInt>"u"?Yr:c}function Yr(){throw new Error("BigInt not supported")}})(my);const sS="https://mempool.space",oS="https://mempool.space/testnet",aS="https://mempool.space/testnet4",cS="https://mempool.space/signet",uS="https://mempool.fractalbitcoin.io",lS="https://mempool-testnet.fractalbitcoin.io",ti=e=>e===it?oS:e===Zt?aS:e===Yt?cS:e===ls?uS:e===Qt?lS:sS;var ut={},Ph={};const hS={},fS=Object.freeze(Object.defineProperty({__proto__:null,default:hS},Symbol.toStringTag,{value:"Module"})),Ey=lv(fS);(function(e){/*! noble-secp256k1 - MIT License (c) 2019 Paul Miller (paulmillr.com) */Object.defineProperty(e,"__esModule",{value:!0}),e.utils=e.schnorr=e.verify=e.signSync=e.sign=e.getSharedSecret=e.recoverPublicKey=e.getPublicKey=e.Signature=e.Point=e.CURVE=void 0;const t=Ey,r=BigInt(0),n=BigInt(1),i=BigInt(2),o=BigInt(3),s=BigInt(8),a=Object.freeze({a:r,b:BigInt(7),P:BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),n:BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),h:n,Gx:BigInt("55066263022277343669578718895168534326250603453777594175500187360389116729240"),Gy:BigInt("32670510020758816978083085130507043184471273380659243275938904335757337482424"),beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee")});e.CURVE=a;const u=(b,y)=>(b+y/i)/y,f={beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),splitScalar(b){const{n:y}=a,w=BigInt("0x3086d221a7d46bcde86c90e49284eb15"),A=-n*BigInt("0xe4437ed6010e88286f547fa90abfe4c3"),_=BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),$=w,H=BigInt("0x100000000000000000000000000000000"),K=u($*b,y),q=u(-A*b,y);let z=L(b-K*w-q*_,y),X=L(-K*A-q*$,y);const Z=z>H,te=X>H;if(Z&&(z=y-z),te&&(X=y-X),z>H||X>H)throw new Error("splitScalarEndo: Endomorphism failed, k="+b);return{k1neg:Z,k1:z,k2neg:te,k2:X}}},h=32,d=32,g=32,v=h+1,E=2*h+1;function T(b){const{a:y,b:w}=a,A=L(b*b),_=L(A*b);return L(_+y*b+w)}const x=a.a===r;class N extends Error{constructor(y){super(y)}}function I(b){if(!(b instanceof k))throw new TypeError("JacobianPoint expected")}class k{constructor(y,w,A){this.x=y,this.y=w,this.z=A}static fromAffine(y){if(!(y instanceof V))throw new TypeError("JacobianPoint#fromAffine: expected Point");return y.equals(V.ZERO)?k.ZERO:new k(y.x,y.y,n)}static toAffineBatch(y){const w=Nr(y.map(A=>A.z));return y.map((A,_)=>A.toAffine(w[_]))}static normalizeZ(y){return k.toAffineBatch(y).map(k.fromAffine)}equals(y){I(y);const{x:w,y:A,z:_}=this,{x:$,y:H,z:K}=y,q=L(_*_),z=L(K*K),X=L(w*z),Z=L($*q),te=L(L(A*K)*z),P=L(L(H*_)*q);return X===Z&&te===P}negate(){return new k(this.x,L(-this.y),this.z)}double(){const{x:y,y:w,z:A}=this,_=L(y*y),$=L(w*w),H=L($*$),K=y+$,q=L(i*(L(K*K)-_-H)),z=L(o*_),X=L(z*z),Z=L(X-i*q),te=L(z*(q-Z)-s*H),P=L(i*w*A);return new k(Z,te,P)}add(y){I(y);const{x:w,y:A,z:_}=this,{x:$,y:H,z:K}=y;if($===r||H===r)return this;if(w===r||A===r)return y;const q=L(_*_),z=L(K*K),X=L(w*z),Z=L($*q),te=L(L(A*K)*z),P=L(L(H*_)*q),j=L(Z-X),G=L(P-te);if(j===r)return G===r?this.double():k.ZERO;const ne=L(j*j),_e=L(j*ne),$e=L(X*ne),Pe=L(G*G-_e-i*$e),Oe=L(G*($e-Pe)-te*_e),Ze=L(_*K*j);return new k(Pe,Oe,Ze)}subtract(y){return this.add(y.negate())}multiplyUnsafe(y){const w=k.ZERO;if(typeof y=="bigint"&&y===r)return w;let A=Ne(y);if(A===n)return this;if(!x){let Z=w,te=this;for(;A>r;)A&n&&(Z=Z.add(te)),te=te.double(),A>>=n;return Z}let{k1neg:_,k1:$,k2neg:H,k2:K}=f.splitScalar(A),q=w,z=w,X=this;for(;$>r||K>r;)$&n&&(q=q.add(X)),K&n&&(z=z.add(X)),X=X.double(),$>>=n,K>>=n;return _&&(q=q.negate()),H&&(z=z.negate()),z=new k(L(z.x*f.beta),z.y,z.z),q.add(z)}precomputeWindow(y){const w=x?128/y+1:256/y+1,A=[];let _=this,$=_;for(let H=0;H<w;H++){$=_,A.push($);for(let K=1;K<2**(y-1);K++)$=$.add(_),A.push($);_=$.double()}return A}wNAF(y,w){!w&&this.equals(k.BASE)&&(w=V.BASE);const A=w&&w._WINDOW_SIZE||1;if(256%A)throw new Error("Point#wNAF: Invalid precomputation window, must be power of 2");let _=w&&W.get(w);_||(_=this.precomputeWindow(A),w&&A!==1&&(_=k.normalizeZ(_),W.set(w,_)));let $=k.ZERO,H=k.BASE;const K=1+(x?128/A:256/A),q=2**(A-1),z=BigInt(2**A-1),X=2**A,Z=BigInt(A);for(let te=0;te<K;te++){const P=te*q;let j=Number(y&z);y>>=Z,j>q&&(j-=X,y+=n);const G=P,ne=P+Math.abs(j)-1,_e=te%2!==0,$e=j<0;j===0?H=H.add(B(_e,_[G])):$=$.add(B($e,_[ne]))}return{p:$,f:H}}multiply(y,w){let A=Ne(y),_,$;if(x){const{k1neg:H,k1:K,k2neg:q,k2:z}=f.splitScalar(A);let{p:X,f:Z}=this.wNAF(K,w),{p:te,f:P}=this.wNAF(z,w);X=B(H,X),te=B(q,te),te=new k(L(te.x*f.beta),te.y,te.z),_=X.add(te),$=Z.add(P)}else{const{p:H,f:K}=this.wNAF(A,w);_=H,$=K}return k.normalizeZ([_,$])[0]}toAffine(y){const{x:w,y:A,z:_}=this,$=this.equals(k.ZERO);y==null&&(y=$?s:gt(_));const H=y,K=L(H*H),q=L(K*H),z=L(w*K),X=L(A*q),Z=L(_*H);if($)return V.ZERO;if(Z!==n)throw new Error("invZ was invalid");return new V(z,X)}}k.BASE=new k(a.Gx,a.Gy,n),k.ZERO=new k(r,n,r);function B(b,y){const w=y.negate();return b?w:y}const W=new WeakMap;class V{constructor(y,w){this.x=y,this.y=w}_setWindowSize(y){this._WINDOW_SIZE=y,W.delete(this)}hasEvenY(){return this.y%i===r}static fromCompressedHex(y){const w=y.length===32,A=Ce(w?y:y.subarray(1));if(!wt(A))throw new Error("Point is not on curve");const _=T(A);let $=Pn(_);const H=($&n)===n;w?H&&($=L(-$)):(y[0]&1)===1!==H&&($=L(-$));const K=new V(A,$);return K.assertValidity(),K}static fromUncompressedHex(y){const w=Ce(y.subarray(1,h+1)),A=Ce(y.subarray(h+1,h*2+1)),_=new V(w,A);return _.assertValidity(),_}static fromHex(y){const w=re(y),A=w.length,_=w[0];if(A===h)return this.fromCompressedHex(w);if(A===v&&(_===2||_===3))return this.fromCompressedHex(w);if(A===E&&_===4)return this.fromUncompressedHex(w);throw new Error(`Point.fromHex: received invalid point. Expected 32-${v} compressed bytes or ${E} uncompressed bytes, not ${A}`)}static fromPrivateKey(y){return V.BASE.multiply(nt(y))}static fromSignature(y,w,A){const{r:_,s:$}=Xr(w);if(![0,1,2,3].includes(A))throw new Error("Cannot recover: invalid recovery bit");const H=Ht(re(y)),{n:K}=a,q=A===2||A===3?_+K:_,z=gt(q,K),X=L(-H*z,K),Z=L($*z,K),te=A&1?"03":"02",P=V.fromHex(te+J(q)),j=V.BASE.multiplyAndAddUnsafe(P,X,Z);if(!j)throw new Error("Cannot recover signature: point at infinify");return j.assertValidity(),j}toRawBytes(y=!1){return je(this.toHex(y))}toHex(y=!1){const w=J(this.x);return y?`${this.hasEvenY()?"02":"03"}${w}`:`04${w}${J(this.y)}`}toHexX(){return this.toHex(!0).slice(2)}toRawX(){return this.toRawBytes(!0).slice(1)}assertValidity(){const y="Point is not on elliptic curve",{x:w,y:A}=this;if(!wt(w)||!wt(A))throw new Error(y);const _=L(A*A),$=T(w);if(L(_-$)!==r)throw new Error(y)}equals(y){return this.x===y.x&&this.y===y.y}negate(){return new V(this.x,L(-this.y))}double(){return k.fromAffine(this).double().toAffine()}add(y){return k.fromAffine(this).add(k.fromAffine(y)).toAffine()}subtract(y){return this.add(y.negate())}multiply(y){return k.fromAffine(this).multiply(y,this).toAffine()}multiplyAndAddUnsafe(y,w,A){const _=k.fromAffine(this),$=w===r||w===n||this!==V.BASE?_.multiplyUnsafe(w):_.multiply(w),H=k.fromAffine(y).multiplyUnsafe(A),K=$.add(H);return K.equals(k.ZERO)?void 0:K.toAffine()}}e.Point=V,V.BASE=new V(a.Gx,a.Gy),V.ZERO=new V(r,r);function Ue(b){return Number.parseInt(b[0],16)>=8?"00"+b:b}function Le(b){if(b.length<2||b[0]!==2)throw new Error(`Invalid signature integer tag: ${F(b)}`);const y=b[1],w=b.subarray(2,y+2);if(!y||w.length!==y)throw new Error("Invalid signature integer: wrong length");if(w[0]===0&&w[1]<=127)throw new Error("Invalid signature integer: trailing length");return{data:Ce(w),left:b.subarray(y+2)}}function Je(b){if(b.length<2||b[0]!=48)throw new Error(`Invalid signature tag: ${F(b)}`);if(b[1]!==b.length-2)throw new Error("Invalid signature: incorrect length");const{data:y,left:w}=Le(b.subarray(2)),{data:A,left:_}=Le(w);if(_.length)throw new Error(`Invalid signature: left bytes after parsing: ${F(_)}`);return{r:y,s:A}}class Fe{constructor(y,w){this.r=y,this.s=w,this.assertValidity()}static fromCompact(y){const w=y instanceof Uint8Array,A="Signature.fromCompact";if(typeof y!="string"&&!w)throw new TypeError(`${A}: Expected string or Uint8Array`);const _=w?F(y):y;if(_.length!==128)throw new Error(`${A}: Expected 64-byte hex`);return new Fe(Et(_.slice(0,64)),Et(_.slice(64,128)))}static fromDER(y){const w=y instanceof Uint8Array;if(typeof y!="string"&&!w)throw new TypeError("Signature.fromDER: Expected string or Uint8Array");const{r:A,s:_}=Je(w?y:je(y));return new Fe(A,_)}static fromHex(y){return this.fromDER(y)}assertValidity(){const{r:y,s:w}=this;if(!Ve(y))throw new Error("Invalid Signature: r must be 0 < r < n");if(!Ve(w))throw new Error("Invalid Signature: s must be 0 < s < n")}hasHighS(){const y=a.n>>n;return this.s>y}normalizeS(){return this.hasHighS()?new Fe(this.r,L(-this.s,a.n)):this}toDERRawBytes(){return je(this.toDERHex())}toDERHex(){const y=Ue(Ae(this.s)),w=Ue(Ae(this.r)),A=y.length/2,_=w.length/2,$=Ae(A),H=Ae(_);return`30${Ae(_+A+4)}02${H}${w}02${$}${y}`}toRawBytes(){return this.toDERRawBytes()}toHex(){return this.toDERHex()}toCompactRawBytes(){return je(this.toCompactHex())}toCompactHex(){return J(this.r)+J(this.s)}}e.Signature=Fe;function Ye(...b){if(!b.every(A=>A instanceof Uint8Array))throw new Error("Uint8Array list expected");if(b.length===1)return b[0];const y=b.reduce((A,_)=>A+_.length,0),w=new Uint8Array(y);for(let A=0,_=0;A<b.length;A++){const $=b[A];w.set($,_),_+=$.length}return w}const C=Array.from({length:256},(b,y)=>y.toString(16).padStart(2,"0"));function F(b){if(!(b instanceof Uint8Array))throw new Error("Expected Uint8Array");let y="";for(let w=0;w<b.length;w++)y+=C[b[w]];return y}const oe=BigInt("0x10000000000000000000000000000000000000000000000000000000000000000");function J(b){if(typeof b!="bigint")throw new Error("Expected bigint");if(!(r<=b&&b<oe))throw new Error("Expected number 0 <= n < 2^256");return b.toString(16).padStart(64,"0")}function ue(b){const y=je(J(b));if(y.length!==32)throw new Error("Error: expected 32 bytes");return y}function Ae(b){const y=b.toString(16);return y.length&1?`0${y}`:y}function Et(b){if(typeof b!="string")throw new TypeError("hexToNumber: expected string, got "+typeof b);return BigInt(`0x${b}`)}function je(b){if(typeof b!="string")throw new TypeError("hexToBytes: expected string, got "+typeof b);if(b.length%2)throw new Error("hexToBytes: received invalid unpadded hex"+b.length);const y=new Uint8Array(b.length/2);for(let w=0;w<y.length;w++){const A=w*2,_=b.slice(A,A+2),$=Number.parseInt(_,16);if(Number.isNaN($)||$<0)throw new Error("Invalid byte sequence");y[w]=$}return y}function Ce(b){return Et(F(b))}function re(b){return b instanceof Uint8Array?Uint8Array.from(b):je(b)}function Ne(b){if(typeof b=="number"&&Number.isSafeInteger(b)&&b>0)return BigInt(b);if(typeof b=="bigint"&&Ve(b))return b;throw new TypeError("Expected valid private scalar: 0 < scalar < curve.n")}function L(b,y=a.P){const w=b%y;return w>=r?w:y+w}function He(b,y){const{P:w}=a;let A=b;for(;y-- >r;)A*=A,A%=w;return A}function Pn(b){const{P:y}=a,w=BigInt(6),A=BigInt(11),_=BigInt(22),$=BigInt(23),H=BigInt(44),K=BigInt(88),q=b*b*b%y,z=q*q*b%y,X=He(z,o)*z%y,Z=He(X,o)*z%y,te=He(Z,i)*q%y,P=He(te,A)*te%y,j=He(P,_)*P%y,G=He(j,H)*j%y,ne=He(G,K)*G%y,_e=He(ne,H)*j%y,$e=He(_e,o)*z%y,Pe=He($e,$)*P%y,Oe=He(Pe,w)*q%y,Ze=He(Oe,i);if(Ze*Ze%y!==b)throw new Error("Cannot find square root");return Ze}function gt(b,y=a.P){if(b===r||y<=r)throw new Error(`invert: expected positive integers, got n=${b} mod=${y}`);let w=L(b,y),A=y,_=r,$=n;for(;w!==r;){const H=A/w,K=A%w,q=_-$*H;A=w,w=K,_=$,$=q}if(A!==n)throw new Error("invert: does not exist");return L(_,y)}function Nr(b,y=a.P){const w=new Array(b.length),A=b.reduce(($,H,K)=>H===r?$:(w[K]=$,L($*H,y)),n),_=gt(A,y);return b.reduceRight(($,H,K)=>H===r?$:(w[K]=L($*w[K],y),L($*H,y)),_),w}function At(b){const y=b.length*8-d*8,w=Ce(b);return y>0?w>>BigInt(y):w}function Ht(b,y=!1){const w=At(b);if(y)return w;const{n:A}=a;return w>=A?w-A:w}let st,Dt;class Er{constructor(y,w){if(this.hashLen=y,this.qByteLen=w,typeof y!="number"||y<2)throw new Error("hashLen must be a number");if(typeof w!="number"||w<2)throw new Error("qByteLen must be a number");this.v=new Uint8Array(y).fill(1),this.k=new Uint8Array(y).fill(0),this.counter=0}hmac(...y){return e.utils.hmacSha256(this.k,...y)}hmacSync(...y){return Dt(this.k,...y)}checkSync(){if(typeof Dt!="function")throw new N("hmacSha256Sync needs to be set")}incr(){if(this.counter>=1e3)throw new Error("Tried 1,000 k values for sign(), all were invalid");this.counter+=1}async reseed(y=new Uint8Array){this.k=await this.hmac(this.v,Uint8Array.from([0]),y),this.v=await this.hmac(this.v),y.length!==0&&(this.k=await this.hmac(this.v,Uint8Array.from([1]),y),this.v=await this.hmac(this.v))}reseedSync(y=new Uint8Array){this.checkSync(),this.k=this.hmacSync(this.v,Uint8Array.from([0]),y),this.v=this.hmacSync(this.v),y.length!==0&&(this.k=this.hmacSync(this.v,Uint8Array.from([1]),y),this.v=this.hmacSync(this.v))}async generate(){this.incr();let y=0;const w=[];for(;y<this.qByteLen;){this.v=await this.hmac(this.v);const A=this.v.slice();w.push(A),y+=this.v.length}return Ye(...w)}generateSync(){this.checkSync(),this.incr();let y=0;const w=[];for(;y<this.qByteLen;){this.v=this.hmacSync(this.v);const A=this.v.slice();w.push(A),y+=this.v.length}return Ye(...w)}}function Ve(b){return r<b&&b<a.n}function wt(b){return r<b&&b<a.P}function Ar(b,y,w,A=!0){const{n:_}=a,$=Ht(b,!0);if(!Ve($))return;const H=gt($,_),K=V.BASE.multiply($),q=L(K.x,_);if(q===r)return;const z=L(H*L(y+w*q,_),_);if(z===r)return;let X=new Fe(q,z),Z=(K.x===X.r?0:2)|Number(K.y&n);return A&&X.hasHighS()&&(X=X.normalizeS(),Z^=1),{sig:X,recovery:Z}}function nt(b){let y;if(typeof b=="bigint")y=b;else if(typeof b=="number"&&Number.isSafeInteger(b)&&b>0)y=BigInt(b);else if(typeof b=="string"){if(b.length!==2*d)throw new Error("Expected 32 bytes of private key");y=Et(b)}else if(b instanceof Uint8Array){if(b.length!==d)throw new Error("Expected 32 bytes of private key");y=Ce(b)}else throw new TypeError("Expected valid private key");if(!Ve(y))throw new Error("Expected private key: 0 < key < n");return y}function Lt(b){return b instanceof V?(b.assertValidity(),b):V.fromHex(b)}function Xr(b){if(b instanceof Fe)return b.assertValidity(),b;try{return Fe.fromDER(b)}catch{return Fe.fromCompact(b)}}function Jr(b,y=!1){return V.fromPrivateKey(b).toRawBytes(y)}e.getPublicKey=Jr;function On(b,y,w,A=!1){return V.fromSignature(b,y,w).toRawBytes(A)}e.recoverPublicKey=On;function Mt(b){const y=b instanceof Uint8Array,w=typeof b=="string",A=(y||w)&&b.length;return y?A===v||A===E:w?A===v*2||A===E*2:b instanceof V}function ze(b,y,w=!1){if(Mt(b))throw new TypeError("getSharedSecret: first arg must be private key");if(!Mt(y))throw new TypeError("getSharedSecret: second arg must be public key");const A=Lt(y);return A.assertValidity(),A.multiply(nt(b)).toRawBytes(w)}e.getSharedSecret=ze;function sr(b){const y=b.length>h?b.slice(0,h):b;return Ce(y)}function wi(b){const y=sr(b),w=L(y,a.n);return rt(w<r?y:w)}function rt(b){return ue(b)}function Yr(b,y,w){if(b==null)throw new Error(`sign: expected valid message hash, not "${b}"`);const A=re(b),_=nt(y),$=[rt(_),wi(A)];if(w!=null){w===!0&&(w=e.utils.randomBytes(h));const q=re(w);if(q.length!==h)throw new Error(`sign: Expected ${h} bytes of extra data`);$.push(q)}const H=Ye(...$),K=sr(A);return{seed:H,m:K,d:_}}function c(b,y){const{sig:w,recovery:A}=b,{der:_,recovered:$}=Object.assign({canonical:!0,der:!0},y),H=_?w.toDERRawBytes():w.toCompactRawBytes();return $?[H,A]:H}async function l(b,y,w={}){const{seed:A,m:_,d:$}=Yr(b,y,w.extraEntropy),H=new Er(g,d);await H.reseed(A);let K;for(;!(K=Ar(await H.generate(),_,$,w.canonical));)await H.reseed();return c(K,w)}e.sign=l;function p(b,y,w={}){const{seed:A,m:_,d:$}=Yr(b,y,w.extraEntropy),H=new Er(g,d);H.reseedSync(A);let K;for(;!(K=Ar(H.generateSync(),_,$,w.canonical));)H.reseedSync();return c(K,w)}e.signSync=p;const m={strict:!0};function S(b,y,w,A=m){let _;try{_=Xr(b),y=re(y)}catch{return!1}const{r:$,s:H}=_;if(A.strict&&_.hasHighS())return!1;const K=Ht(y);let q;try{q=Lt(w)}catch{return!1}const{n:z}=a,X=gt(H,z),Z=L(K*X,z),te=L($*X,z),P=V.BASE.multiplyAndAddUnsafe(q,Z,te);return P?L(P.x,z)===$:!1}e.verify=S;function O(b){return L(Ce(b),a.n)}class U{constructor(y,w){this.r=y,this.s=w,this.assertValidity()}static fromHex(y){const w=re(y);if(w.length!==64)throw new TypeError(`SchnorrSignature.fromHex: expected 64 bytes, not ${w.length}`);const A=Ce(w.subarray(0,32)),_=Ce(w.subarray(32,64));return new U(A,_)}assertValidity(){const{r:y,s:w}=this;if(!wt(y)||!Ve(w))throw new Error("Invalid signature")}toHex(){return J(this.r)+J(this.s)}toRawBytes(){return je(this.toHex())}}function ce(b){return V.fromPrivateKey(b).toRawX()}class ke{constructor(y,w,A=e.utils.randomBytes()){if(y==null)throw new TypeError(`sign: Expected valid message, not "${y}"`);this.m=re(y);const{x:_,scalar:$}=this.getScalar(nt(w));if(this.px=_,this.d=$,this.rand=re(A),this.rand.length!==32)throw new TypeError("sign: Expected 32 bytes of aux randomness")}getScalar(y){const w=V.fromPrivateKey(y),A=w.hasEvenY()?y:a.n-y;return{point:w,scalar:A,x:w.toRawX()}}initNonce(y,w){return ue(y^Ce(w))}finalizeNonce(y){const w=L(Ce(y),a.n);if(w===r)throw new Error("sign: Creation of signature failed. k is zero");const{point:A,x:_,scalar:$}=this.getScalar(w);return{R:A,rx:_,k:$}}finalizeSig(y,w,A,_){return new U(y.x,L(w+A*_,a.n)).toRawBytes()}error(){throw new Error("sign: Invalid signature produced")}async calc(){const{m:y,d:w,px:A,rand:_}=this,$=e.utils.taggedHash,H=this.initNonce(w,await $(Pt.aux,_)),{R:K,rx:q,k:z}=this.finalizeNonce(await $(Pt.nonce,H,A,y)),X=O(await $(Pt.challenge,q,A,y)),Z=this.finalizeSig(K,z,X,w);return await is(Z,y,A)||this.error(),Z}calcSync(){const{m:y,d:w,px:A,rand:_}=this,$=e.utils.taggedHashSync,H=this.initNonce(w,$(Pt.aux,_)),{R:K,rx:q,k:z}=this.finalizeNonce($(Pt.nonce,H,A,y)),X=O($(Pt.challenge,q,A,y)),Z=this.finalizeSig(K,z,X,w);return Zr(Z,y,A)||this.error(),Z}}async function le(b,y,w){return new ke(b,y,w).calc()}function ae(b,y,w){return new ke(b,y,w).calcSync()}function me(b,y,w){const A=b instanceof U,_=A?b:U.fromHex(b);return A&&_.assertValidity(),{..._,m:re(y),P:Lt(w)}}function bi(b,y,w,A){const _=V.BASE.multiplyAndAddUnsafe(y,nt(w),L(-A,a.n));return!(!_||!_.hasEvenY()||_.x!==b)}async function is(b,y,w){try{const{r:A,s:_,m:$,P:H}=me(b,y,w),K=O(await e.utils.taggedHash(Pt.challenge,ue(A),H.toRawX(),$));return bi(A,H,_,K)}catch{return!1}}function Zr(b,y,w){try{const{r:A,s:_,m:$,P:H}=me(b,y,w),K=O(e.utils.taggedHashSync(Pt.challenge,ue(A),H.toRawX(),$));return bi(A,H,_,K)}catch(A){if(A instanceof N)throw A;return!1}}e.schnorr={Signature:U,getPublicKey:ce,sign:le,verify:is,signSync:ae,verifySync:Zr},V.BASE._setWindowSize(8);const Ke={node:t,web:typeof self=="object"&&"crypto"in self?self.crypto:void 0},Pt={challenge:"BIP0340/challenge",aux:"BIP0340/aux",nonce:"BIP0340/nonce"},Qr={};e.utils={bytesToHex:F,hexToBytes:je,concatBytes:Ye,mod:L,invert:gt,isValidPrivateKey(b){try{return nt(b),!0}catch{return!1}},_bigintTo32Bytes:ue,_normalizePrivateKey:nt,hashToPrivateKey:b=>{b=re(b);const y=d+8;if(b.length<y||b.length>1024)throw new Error("Expected valid bytes of private key as per FIPS 186");const w=L(Ce(b),a.n-n)+n;return ue(w)},randomBytes:(b=32)=>{if(Ke.web)return Ke.web.getRandomValues(new Uint8Array(b));if(Ke.node){const{randomBytes:y}=Ke.node;return Uint8Array.from(y(b))}else throw new Error("The environment doesn't have randomBytes function")},randomPrivateKey:()=>e.utils.hashToPrivateKey(e.utils.randomBytes(d+8)),precompute(b=8,y=V.BASE){const w=y===V.BASE?y:new V(y.x,y.y);return w._setWindowSize(b),w.multiply(o),w},sha256:async(...b)=>{if(Ke.web){const y=await Ke.web.subtle.digest("SHA-256",Ye(...b));return new Uint8Array(y)}else if(Ke.node){const{createHash:y}=Ke.node,w=y("sha256");return b.forEach(A=>w.update(A)),Uint8Array.from(w.digest())}else throw new Error("The environment doesn't have sha256 function")},hmacSha256:async(b,...y)=>{if(Ke.web){const w=await Ke.web.subtle.importKey("raw",b,{name:"HMAC",hash:{name:"SHA-256"}},!1,["sign"]),A=Ye(...y),_=await Ke.web.subtle.sign("HMAC",w,A);return new Uint8Array(_)}else if(Ke.node){const{createHmac:w}=Ke.node,A=w("sha256",b);return y.forEach(_=>A.update(_)),Uint8Array.from(A.digest())}else throw new Error("The environment doesn't have hmac-sha256 function")},sha256Sync:void 0,hmacSha256Sync:void 0,taggedHash:async(b,...y)=>{let w=Qr[b];if(w===void 0){const A=await e.utils.sha256(Uint8Array.from(b,_=>_.charCodeAt(0)));w=Ye(A,A),Qr[b]=w}return e.utils.sha256(w,...y)},taggedHashSync:(b,...y)=>{if(typeof st!="function")throw new N("sha256Sync is undefined, you need to set it");let w=Qr[b];if(w===void 0){const A=st(Uint8Array.from(b,_=>_.charCodeAt(0)));w=Ye(A,A),Qr[b]=w}return st(w,...y)},_JacobianPoint:k},Object.defineProperties(e.utils,{sha256Sync:{configurable:!1,get(){return st},set(b){st||(st=b)}},hmacSha256Sync:{configurable:!1,get(){return Dt},set(b){Dt||(Dt=b)}}})})(Ph);var Oh={},Kr={};Object.defineProperty(Kr,"__esModule",{value:!0}),Kr.isBytes=Sy,Kr.number=Ic,Kr.bool=Ay,Kr.bytes=Ih,Kr.hash=Ty,Kr.exists=_y,Kr.output=ky;function Ic(e){if(!Number.isSafeInteger(e)||e<0)throw new Error(`positive integer expected, not ${e}`)}function Ay(e){if(typeof e!="boolean")throw new Error(`boolean expected, not ${e}`)}function Sy(e){return e instanceof Uint8Array||e!=null&&typeof e=="object"&&e.constructor.name==="Uint8Array"}function Ih(e,...t){if(!Sy(e))throw new Error("Uint8Array expected");if(t.length>0&&!t.includes(e.length))throw new Error(`Uint8Array expected of length ${t}, not of length=${e.length}`)}function Ty(e){if(typeof e!="function"||typeof e.create!="function")throw new Error("Hash should be wrapped by utils.wrapConstructor");Ic(e.outputLen),Ic(e.blockLen)}function _y(e,t=!0){if(e.destroyed)throw new Error("Hash instance has been destroyed");if(t&&e.finished)throw new Error("Hash#digest() has already been called")}function ky(e,t){Ih(e);const r=t.outputLen;if(e.length<r)throw new Error(`digestInto() expects output buffer of length at least ${r}`)}const dS={number:Ic,bool:Ay,bytes:Ih,hash:Ty,exists:_y,output:ky};Kr.default=dS;var Xo={},xc={};Object.defineProperty(xc,"__esModule",{value:!0}),xc.crypto=void 0,xc.crypto=typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0,function(e){/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */Object.defineProperty(e,"__esModule",{value:!0}),e.Hash=e.nextTick=e.byteSwapIfBE=e.byteSwap=e.isLE=e.rotl=e.rotr=e.createView=e.u32=e.u8=void 0,e.isBytes=n,e.byteSwap32=h,e.bytesToHex=g,e.hexToBytes=T,e.asyncLoop=N,e.utf8ToBytes=I,e.toBytes=k,e.concatBytes=B,e.checkOpts=Ue,e.wrapConstructor=Le,e.wrapConstructorWithOpts=Je,e.wrapXOFConstructorWithOpts=Fe,e.randomBytes=Ye;const t=xc,r=Kr;function n(C){return C instanceof Uint8Array||C!=null&&typeof C=="object"&&C.constructor.name==="Uint8Array"}const i=C=>new Uint8Array(C.buffer,C.byteOffset,C.byteLength);e.u8=i;const o=C=>new Uint32Array(C.buffer,C.byteOffset,Math.floor(C.byteLength/4));e.u32=o;const s=C=>new DataView(C.buffer,C.byteOffset,C.byteLength);e.createView=s;const a=(C,F)=>C<<32-F|C>>>F;e.rotr=a;const u=(C,F)=>C<<F|C>>>32-F>>>0;e.rotl=u,e.isLE=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;const f=C=>C<<24&4278190080|C<<8&16711680|C>>>8&65280|C>>>24&255;e.byteSwap=f,e.byteSwapIfBE=e.isLE?C=>C:C=>(0,e.byteSwap)(C);function h(C){for(let F=0;F<C.length;F++)C[F]=(0,e.byteSwap)(C[F])}const d=Array.from({length:256},(C,F)=>F.toString(16).padStart(2,"0"));function g(C){(0,r.bytes)(C);let F="";for(let oe=0;oe<C.length;oe++)F+=d[C[oe]];return F}const v={_0:48,_9:57,_A:65,_F:70,_a:97,_f:102};function E(C){if(C>=v._0&&C<=v._9)return C-v._0;if(C>=v._A&&C<=v._F)return C-(v._A-10);if(C>=v._a&&C<=v._f)return C-(v._a-10)}function T(C){if(typeof C!="string")throw new Error("hex string expected, got "+typeof C);const F=C.length,oe=F/2;if(F%2)throw new Error("padded hex string expected, got unpadded hex of length "+F);const J=new Uint8Array(oe);for(let ue=0,Ae=0;ue<oe;ue++,Ae+=2){const Et=E(C.charCodeAt(Ae)),je=E(C.charCodeAt(Ae+1));if(Et===void 0||je===void 0){const Ce=C[Ae]+C[Ae+1];throw new Error('hex string expected, got non-hex character "'+Ce+'" at index '+Ae)}J[ue]=Et*16+je}return J}const x=async()=>{};e.nextTick=x;async function N(C,F,oe){let J=Date.now();for(let ue=0;ue<C;ue++){oe(ue);const Ae=Date.now()-J;Ae>=0&&Ae<F||(await(0,e.nextTick)(),J+=Ae)}}function I(C){if(typeof C!="string")throw new Error(`utf8ToBytes expected string, got ${typeof C}`);return new Uint8Array(new TextEncoder().encode(C))}function k(C){return typeof C=="string"&&(C=I(C)),(0,r.bytes)(C),C}function B(...C){let F=0;for(let J=0;J<C.length;J++){const ue=C[J];(0,r.bytes)(ue),F+=ue.length}const oe=new Uint8Array(F);for(let J=0,ue=0;J<C.length;J++){const Ae=C[J];oe.set(Ae,ue),ue+=Ae.length}return oe}class W{clone(){return this._cloneInto()}}e.Hash=W;const V={}.toString;function Ue(C,F){if(F!==void 0&&V.call(F)!=="[object Object]")throw new Error("Options should be object or undefined");return Object.assign(C,F)}function Le(C){const F=J=>C().update(k(J)).digest(),oe=C();return F.outputLen=oe.outputLen,F.blockLen=oe.blockLen,F.create=()=>C(),F}function Je(C){const F=(J,ue)=>C(ue).update(k(J)).digest(),oe=C({});return F.outputLen=oe.outputLen,F.blockLen=oe.blockLen,F.create=J=>C(J),F}function Fe(C){const F=(J,ue)=>C(ue).update(k(J)).digest(),oe=C({});return F.outputLen=oe.outputLen,F.blockLen=oe.blockLen,F.create=J=>C(J),F}function Ye(C=32){if(t.crypto&&typeof t.crypto.getRandomValues=="function")return t.crypto.getRandomValues(new Uint8Array(C));if(t.crypto&&typeof t.crypto.randomBytes=="function")return t.crypto.randomBytes(C);throw new Error("crypto.getRandomValues must be defined")}}(Xo),function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.hmac=e.HMAC=void 0;const t=Kr,r=Xo;class n extends r.Hash{constructor(s,a){super(),this.finished=!1,this.destroyed=!1,(0,t.hash)(s);const u=(0,r.toBytes)(a);if(this.iHash=s.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 f=this.blockLen,h=new Uint8Array(f);h.set(u.length>f?s.create().update(u).digest():u);for(let d=0;d<h.length;d++)h[d]^=54;this.iHash.update(h),this.oHash=s.create();for(let d=0;d<h.length;d++)h[d]^=106;this.oHash.update(h),h.fill(0)}update(s){return(0,t.exists)(this),this.iHash.update(s),this}digestInto(s){(0,t.exists)(this),(0,t.bytes)(s,this.outputLen),this.finished=!0,this.iHash.digestInto(s),this.oHash.update(s),this.oHash.digestInto(s),this.destroy()}digest(){const s=new Uint8Array(this.oHash.outputLen);return this.digestInto(s),s}_cloneInto(s){s||(s=Object.create(Object.getPrototypeOf(this),{}));const{oHash:a,iHash:u,finished:f,destroyed:h,blockLen:d,outputLen:g}=this;return s=s,s.finished=f,s.destroyed=h,s.blockLen=d,s.outputLen=g,s.oHash=a._cloneInto(s.oHash),s.iHash=u._cloneInto(s.iHash),s}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}}e.HMAC=n;const i=(o,s,a)=>new n(o,s).update(a).digest();e.hmac=i,e.hmac.create=(o,s)=>new n(o,s)}(Oh);var Rn={},Ci={};Object.defineProperty(Ci,"__esModule",{value:!0}),Ci.HashMD=Ci.Maj=Ci.Chi=void 0;const xh=Kr,Jo=Xo;function pS(e,t,r,n){if(typeof e.setBigUint64=="function")return e.setBigUint64(t,r,n);const i=BigInt(32),o=BigInt(4294967295),s=Number(r>>i&o),a=Number(r&o),u=n?4:0,f=n?0:4;e.setUint32(t+u,s,n),e.setUint32(t+f,a,n)}const yS=(e,t,r)=>e&t^~e&r;Ci.Chi=yS;const gS=(e,t,r)=>e&t^e&r^t&r;Ci.Maj=gS;let wS=class extends Jo.Hash{constructor(t,r,n,i){super(),this.blockLen=t,this.outputLen=r,this.padOffset=n,this.isLE=i,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(t),this.view=(0,Jo.createView)(this.buffer)}update(t){(0,xh.exists)(this);const{view:r,buffer:n,blockLen:i}=this;t=(0,Jo.toBytes)(t);const o=t.length;for(let s=0;s<o;){const a=Math.min(i-this.pos,o-s);if(a===i){const u=(0,Jo.createView)(t);for(;i<=o-s;s+=i)this.process(u,s);continue}n.set(t.subarray(s,s+a),this.pos),this.pos+=a,s+=a,this.pos===i&&(this.process(r,0),this.pos=0)}return this.length+=t.length,this.roundClean(),this}digestInto(t){(0,xh.exists)(this),(0,xh.output)(t,this),this.finished=!0;const{buffer:r,view:n,blockLen:i,isLE:o}=this;let{pos:s}=this;r[s++]=128,this.buffer.subarray(s).fill(0),this.padOffset>i-s&&(this.process(n,0),s=0);for(let d=s;d<i;d++)r[d]=0;pS(n,i-8,BigInt(this.length*8),o),this.process(n,0);const a=(0,Jo.createView)(t),u=this.outputLen;if(u%4)throw new Error("_sha2: outputLen should be aligned to 32bit");const f=u/4,h=this.get();if(f>h.length)throw new Error("_sha2: outputLen bigger than state");for(let d=0;d<f;d++)a.setUint32(4*d,h[d],o)}digest(){const{buffer:t,outputLen:r}=this;this.digestInto(t);const n=t.slice(0,r);return this.destroy(),n}_cloneInto(t){t||(t=new this.constructor),t.set(...this.get());const{blockLen:r,buffer:n,length:i,finished:o,destroyed:s,pos:a}=this;return t.length=i,t.pos=a,t.finished=o,t.destroyed=s,i%r&&t.buffer.set(n),t}};Ci.HashMD=wS,Object.defineProperty(Rn,"__esModule",{value:!0}),Rn.sha224=Rn.sha256=Rn.SHA256=void 0;const $h=Ci,jr=Xo,bS=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]),Ni=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),Ui=new Uint32Array(64);let Ch=class extends $h.HashMD{constructor(){super(64,32,8,!1),this.A=Ni[0]|0,this.B=Ni[1]|0,this.C=Ni[2]|0,this.D=Ni[3]|0,this.E=Ni[4]|0,this.F=Ni[5]|0,this.G=Ni[6]|0,this.H=Ni[7]|0}get(){const{A:t,B:r,C:n,D:i,E:o,F:s,G:a,H:u}=this;return[t,r,n,i,o,s,a,u]}set(t,r,n,i,o,s,a,u){this.A=t|0,this.B=r|0,this.C=n|0,this.D=i|0,this.E=o|0,this.F=s|0,this.G=a|0,this.H=u|0}process(t,r){for(let d=0;d<16;d++,r+=4)Ui[d]=t.getUint32(r,!1);for(let d=16;d<64;d++){const g=Ui[d-15],v=Ui[d-2],E=(0,jr.rotr)(g,7)^(0,jr.rotr)(g,18)^g>>>3,T=(0,jr.rotr)(v,17)^(0,jr.rotr)(v,19)^v>>>10;Ui[d]=T+Ui[d-7]+E+Ui[d-16]|0}let{A:n,B:i,C:o,D:s,E:a,F:u,G:f,H:h}=this;for(let d=0;d<64;d++){const g=(0,jr.rotr)(a,6)^(0,jr.rotr)(a,11)^(0,jr.rotr)(a,25),v=h+g+(0,$h.Chi)(a,u,f)+bS[d]+Ui[d]|0,E=((0,jr.rotr)(n,2)^(0,jr.rotr)(n,13)^(0,jr.rotr)(n,22))+(0,$h.Maj)(n,i,o)|0;h=f,f=u,u=a,a=s+v|0,s=o,o=i,i=n,n=v+E|0}n=n+this.A|0,i=i+this.B|0,o=o+this.C|0,s=s+this.D|0,a=a+this.E|0,u=u+this.F|0,f=f+this.G|0,h=h+this.H|0,this.set(n,i,o,s,a,u,f,h)}roundClean(){Ui.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}};Rn.SHA256=Ch;let mS=class extends Ch{constructor(){super(),this.A=-1056596264,this.B=914150663,this.C=812702999,this.D=-150054599,this.E=-4191439,this.F=1750603025,this.G=1694076839,this.H=-1090891868,this.outputLen=28}};Rn.sha256=(0,jr.wrapConstructor)(()=>new Ch),Rn.sha224=(0,jr.wrapConstructor)(()=>new mS);var vS=Ph,ES=Oh,Py=Rn;function AS(e){var t=Object.create(null);return e&&Object.keys(e).forEach(function(r){if(r!=="default"){var n=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(t,r,n.get?n:{enumerable:!0,get:function(){return e[r]}})}}),t.default=e,Object.freeze(t)}var Re=AS(vS);const Ri="Expected Private",Bi="Expected Point",Yo="Expected Tweak",SS="Expected Hash",$c="Expected Signature",Nh="Expected Extra Data (32 bytes)",Zo="Expected Scalar",TS="Bad Recovery Id";Re.utils.hmacSha256Sync=(e,...t)=>ES.hmac(Py.sha256,e,Re.utils.concatBytes(...t)),Re.utils.sha256Sync=(...e)=>Py.sha256(Re.utils.concatBytes(...e));const Uh=Re.utils._normalizePrivateKey,_S=32,kS=32,Rh=new Uint8Array([255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,254,186,174,220,230,175,72,160,59,191,210,94,140,208,54,65,65]),PS=32,OS=new Uint8Array(32),IS=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,69,81,35,25,80,183,95,196,64,45,161,114,47,201,186,238]);function xS(e){return e instanceof Uint8Array}function Qo(e,t){for(let r=0;r<32;++r)if(e[r]!==t[r])return e[r]<t[r]?-1:1;return 0}function Oy(e){return Qo(e,OS)===0}function ea(e){return!(!(e instanceof Uint8Array)||e.length!==kS||Qo(e,Rh)>=0)}function Bh(e){return e instanceof Uint8Array&&e.length===64&&Qo(e.subarray(0,32),Rh)<0&&Qo(e.subarray(32,64),Rh)<0}function $S(e){return xS(e)&&e.length===64&&Qo(e.subarray(0,32),IS)<0}function CS(e){return!(Oy(e.subarray(0,32))||Oy(e.subarray(32,64)))}function Js(e){return e instanceof Uint8Array&&e.length===_S}function Hh(e){return e===void 0||e instanceof Uint8Array&&e.length===PS}function Iy(e){if(typeof e!="string")throw new TypeError("hexToNumber: expected string, got "+typeof e);return BigInt(`0x${e}`)}function NS(e){return Iy(Re.utils.bytesToHex(e))}function Lh(e){let t;if(typeof e=="bigint")t=e;else if(typeof e=="number"&&Number.isSafeInteger(e)&&e>=0)t=BigInt(e);else if(typeof e=="string"){if(e.length!==64)throw new Error("Expected 32 bytes of private scalar");t=Iy(e)}else if(e instanceof Uint8Array){if(e.length!==32)throw new Error("Expected 32 bytes of private scalar");t=NS(e)}else throw new TypeError("Expected valid private scalar");if(t<0)throw new Error("Expected private scalar >= 0");return t}const US=(e,t)=>{const r=Uh(e),n=Lh(t),i=Re.utils._bigintTo32Bytes(Re.utils.mod(r+n,Re.CURVE.n));return Re.utils.isValidPrivateKey(i)?i:null},RS=(e,t)=>{const r=Uh(e),n=Lh(t),i=Re.utils._bigintTo32Bytes(Re.utils.mod(r-n,Re.CURVE.n));return Re.utils.isValidPrivateKey(i)?i:null},BS=e=>{const t=Uh(e),r=Re.utils._bigintTo32Bytes(Re.CURVE.n-t);return Re.utils.isValidPrivateKey(r)?r:null},xy=(e,t,r)=>{const n=Re.Point.fromHex(e),i=Lh(t),o=Re.Point.BASE.multiplyAndAddUnsafe(n,i,BigInt(1));if(!o)throw new Error("Tweaked point at infinity");return o.toRawBytes(r)},HS=(e,t,r)=>{const n=Re.Point.fromHex(e),i=typeof t=="string"?t:Re.utils.bytesToHex(t),o=BigInt(`0x${i}`);return n.multiply(o).toRawBytes(r)};function Ys(e,t){return e===void 0?t!==void 0?$y(t):!0:!!e}function ps(e){try{return e()}catch{return null}}function Kh(e,t){if(e.length===32!==t)return!1;try{return!!Re.Point.fromHex(e)}catch{return!1}}function Hi(e){return Kh(e,!1)}function $y(e){return Kh(e,!1)&&e.length===33}function ri(e){return Re.utils.isValidPrivateKey(e)}function Cc(e){return Kh(e,!0)}function LS(e,t){if(!Cc(e))throw new Error(Bi);if(!ea(t))throw new Error(Yo);return ps(()=>{const r=xy(e,t,!0);return{parity:r[0]%2===1?1:0,xOnlyPubkey:r.slice(1)}})}function Cy(e){if(!Hi(e))throw new Error(Bi);return e.slice(1,33)}function Ny(e,t){if(!ri(e))throw new Error(Ri);return ps(()=>Re.getPublicKey(e,Ys(t)))}function KS(e){if(!ri(e))throw new Error(Ri);return Cy(Ny(e))}function jS(e,t){if(!Hi(e))throw new Error(Bi);return Re.Point.fromHex(e).toRawBytes(Ys(t,e))}function DS(e,t,r){if(!Hi(e))throw new Error(Bi);if(!ea(t))throw new Error(Yo);return ps(()=>HS(e,t,Ys(r,e)))}function MS(e,t,r){if(!Hi(e)||!Hi(t))throw new Error(Bi);return ps(()=>{const n=Re.Point.fromHex(e),i=Re.Point.fromHex(t);return n.equals(i.negate())?null:n.add(i).toRawBytes(Ys(r,e))})}function FS(e,t,r){if(!Hi(e))throw new Error(Bi);if(!ea(t))throw new Error(Yo);return ps(()=>xy(e,t,Ys(r,e)))}function VS(e,t){if(ri(e)===!1)throw new Error(Ri);if(ea(t)===!1)throw new Error(Yo);return ps(()=>US(e,t))}function zS(e,t){if(ri(e)===!1)throw new Error(Ri);if(ea(t)===!1)throw new Error(Yo);return ps(()=>RS(e,t))}function WS(e){if(ri(e)===!1)throw new Error(Ri);return BS(e)}function qS(e,t,r){if(!ri(t))throw new Error(Ri);if(!Js(e))throw new Error(Zo);if(!Hh(r))throw new Error(Nh);return Re.signSync(e,t,{der:!1,extraEntropy:r})}function GS(e,t,r){if(!ri(t))throw new Error(Ri);if(!Js(e))throw new Error(Zo);if(!Hh(r))throw new Error(Nh);const[n,i]=Re.signSync(e,t,{der:!1,extraEntropy:r,recovered:!0});return{signature:n,recoveryId:i}}function XS(e,t,r=Buffer.alloc(32,0)){if(!ri(t))throw new Error(Ri);if(!Js(e))throw new Error(Zo);if(!Hh(r))throw new Error(Nh);return Re.schnorr.signSync(e,t,r)}function JS(e,t,r,n){if(!Js(e))throw new Error(SS);if(!Bh(t)||!CS(t))throw new Error($c);if(r&2&&!$S(t))throw new Error(TS);if(!Cc(t.subarray(0,32)))throw new Error($c);return Re.recoverPublicKey(e,t,r,Ys(n))}function YS(e,t,r,n){if(!Hi(t))throw new Error(Bi);if(!Bh(r))throw new Error($c);if(!Js(e))throw new Error(Zo);return Re.verify(r,e,t,{strict:n})}function ZS(e,t,r){if(!Cc(t))throw new Error(Bi);if(!Bh(r))throw new Error($c);if(!Js(e))throw new Error(Zo);return Re.schnorr.verifySync(r,e,t)}var QS=ut.isPoint=Hi,e8=ut.isPointCompressed=$y,t8=ut.isPrivate=ri,r8=ut.isXOnlyPoint=Cc,n8=ut.pointAdd=MS,i8=ut.pointAddScalar=FS,s8=ut.pointCompress=jS,o8=ut.pointFromScalar=Ny,a8=ut.pointMultiply=DS,c8=ut.privateAdd=VS,u8=ut.privateNegate=WS,l8=ut.privateSub=zS,h8=ut.recover=JS,f8=ut.sign=qS,d8=ut.signRecoverable=GS,p8=ut.signSchnorr=XS,y8=ut.verify=YS,g8=ut.verifySchnorr=ZS,w8=ut.xOnlyPointAddTweak=LS,b8=ut.xOnlyPointFromPoint=Cy,m8=ut.xOnlyPointFromScalar=KS;yv(Qb({__proto__:null,default:ut,isPoint:QS,isPointCompressed:e8,isPrivate:t8,isXOnlyPoint:r8,pointAdd:n8,pointAddScalar:i8,pointCompress:s8,pointFromScalar:o8,pointMultiply:a8,privateAdd:c8,privateNegate:u8,privateSub:l8,recover:h8,sign:f8,signRecoverable:d8,signSchnorr:p8,verify:y8,verifySchnorr:g8,xOnlyPointAddTweak:w8,xOnlyPointFromPoint:b8,xOnlyPointFromScalar:m8},[ut]));const er=e=>e===it||e===Zt||e===Yt?um:sn,jh=e=>e.find(({purpose:t})=>t==="ordinals"),Dh=e=>e.find(({purpose:t})=>t==="payment"),zt=async(e,t)=>{try{const r=await Uy(e,t);return r?r.reduce((n,i)=>n+BigInt(i.value),0n):0n}catch(r){throw console.error("Error fetching BTC balance:",r),new Error("Failed to fetch BTC balance")}},v8=e=>/^(?:[A-Za-z0-9+\/]{4})*?(?:[A-Za-z0-9+\/]{2}==|[A-Za-z0-9+\/]{3}=)?$/.test(e),E8=e=>/^[a-fA-F0-9]+$/.test(e);function A8(e,t,r){const n=e*57+t*41,i=r*34;return 10+n+i}async function Uy(e,t){if(e.startsWith("t")){if(t===tt)return[];if(t===ls)return[];if(t===Qt)return[]}return await qe.get(`${ti(t)}/api/address/${e}/utxo`).then(r=>r.data)}async function Ry(e,t,r,n,i,o,s=7){const a=e===t,u=await Uy(t,o);if(!u)throw new Error("No UTXOs found");const f=u.sort((T,x)=>x.value-T.value),h=new ct({network:er(o)}),d=A8(1,0,2),g=Math.floor(d*s)+n;let v=0,E=0;for await(let T of f){const{txid:x,vout:N,value:I}=T,k=Lp(t,er(o));if(h.addInput({hash:x,index:N,witnessUtxo:{script:k,value:BigInt(I)}}),!a){const B=S8(i,o);h.updateInput(E,{redeemScript:B})}if(v+=I,v>=g)break}if(v<g)throw new Error("Insufficient funds");return h.addOutput({address:r,value:BigInt(n)}),v>g&&h.addOutput({address:t,value:BigInt(v-g-n)}),{psbtBase64:h.toBase64(),psbtHex:h.toHex()}}function S8(e,t){var r;const n=Ro({pubkey:my.Buffer.from(e,"hex"),network:er(t)}),i=Ks({redeem:n,network:er(t)});return(r=i==null?void 0:i.redeem)==null?void 0:r.output}let T8=class extends ln{constructor(){super(...arguments),de(this,"observer")}get library(){return window.unisat}get network(){return this.$network.get()}initialize(){typeof window<"u"&&typeof document<"u"&&(this.observer=new window.MutationObserver(()=>{var t;this.library&&(this.$store.setKey("hasProvider",{...this.$store.get().hasProvider,[zn]:!0}),(t=this.observer)==null||t.disconnect())}),this.observer.observe(document,{childList:!0,subtree:!0})),nn(this.$store,["provider"],t=>{if(t.provider!==zn){this.removeListeners();return}this.library.getAccounts().then(r=>{this.handleAccountsChanged(r)}),this.addListeners()})}addListeners(){this.library.on("accountsChanged",this.handleAccountsChanged.bind(this)),this.library.on("networkChanged",this.handleNetworkChanged.bind(this))}removeListeners(){this.library.removeListener("accountsChanged",this.handleAccountsChanged.bind(this)),this.library.removeListener("networkChanged",this.handleNetworkChanged.bind(this))}dispose(){var t;(t=this.observer)==null||t.disconnect(),this.removeListeners()}handleAccountsChanged(t){if(!t.length){this.parent.disconnect();return}this.$store.get().accounts[0]!==t[0]&&(this.$store.setKey("accounts",t),t.length>0?this.parent.connect(zn):this.parent.disconnect())}handleNetworkChanged(t){const r=zs(t);this.network!==r&&this.switchNetwork(r),this.parent.connect(zn)}async connect(t){if(!this.library)throw new Error("Unisat isn't installed");const r=await this.library.requestAccounts();if(!r)throw new Error("No accounts found");const n=await this.library.getPublicKey();if(!n)throw new Error("No public key found");this.$store.setKey("accounts",r),this.$store.setKey("address",r[0]),this.$store.setKey("paymentAddress",r[0]),this.$store.setKey("publicKey",n),this.$store.setKey("paymentPublicKey",n),this.$store.setKey("provider",zn),await this.getNetwork().then(i=>{var o;((o=this.config)==null?void 0:o.network)!==i&&this.switchNetwork(i)}),zt(r[0],this.network).then(i=>{this.$store.setKey("balance",i)}),this.$store.setKey("connected",!0)}async getNetwork(){var t;const r=await((t=this.library)==null?void 0:t.getChain());return r?zs(r.enum):this.network}async sendBTC(t,r){var n;const i=await((n=this.library)==null?void 0:n.sendBitcoin(t,r));if(!i)throw new Error("Transaction failed");return i}async signMessage(t,r){var n;return await((n=this.library)==null?void 0:n.signMessage(t))}async signPsbt(t,r,n,i,o){var s;const a=await((s=this.library)==null?void 0:s.signPsbt(r,{autoFinalized:i})),u=ct.fromHex(a);if(i&&o){const f=await this.pushPsbt(a);return{signedPsbtHex:u.toHex(),signedPsbtBase64:u.toBase64(),txId:f}}return{signedPsbtHex:u.toHex(),signedPsbtBase64:u.toBase64(),txId:void 0}}async pushPsbt(t){return await qe.post(`${ti(this.network)}/api/tx`,t).then(r=>r.data)}async getPublicKey(){var t;return await((t=this.library)==null?void 0:t.getPublicKey())}async getBalance(){return(await this.library.getBalance()).total}async getInscriptions(){return await this.library.getInscriptions(0,10)}async requestAccounts(){return await this.library.requestAccounts()}async switchNetwork(t){var r;const n=mc(t);await((r=this.library)==null?void 0:r.switchChain(n)),this.$network.set(t),await this.getBalance()}};function _8(){typeof window<"u"&&typeof localStorage<"u"&&setTimeout(()=>{const e=document.createTextNode(" ");document.body.appendChild(e),e.remove()},1500)}function k8(){return{$store:Rd({provider:void 0,address:"",paymentAddress:"",publicKey:"",paymentPublicKey:"",connected:!1,isConnecting:!1,isInitializing:!0,accounts:[],balance:void 0,hasProvider:{[zn]:!1,[In]:!1,[vi]:!1,[Wn]:!1,[Ti]:!1,[ss]:!1,[Ai]:!1,[Ei]:!1,[os]:!1,[Si]:!1}}),$network:yl(tt),$library:yl(void 0)}}function P8({network:e}){return{network:e}}function l9(e){}function h9(e){}function O8(e,t){var r;return(r=void 0)==null?void 0:r.get(t)}function Nc(e){var t,r;let n=typeof e;return n==="object"&&(n=(e&&((r=(t=Object.getPrototypeOf(e))==null?void 0:t.constructor)==null?void 0:r.name))??"null"),n==="string"?`"${e}"`:n==="number"||n==="bigint"||n==="boolean"?`${e}`:n}function fr(e,t,r,n,i){const o=i&&"input"in i?i.input:r.value,s=(i==null?void 0:i.expected)??e.expects??null,a=(i==null?void 0:i.received)??Nc(o),u={kind:e.kind,type:e.type,input:o,expected:s,received:a,message:`Invalid ${t}: ${s?`Expected ${s} but r`:"R"}eceived ${a}`,requirement:e.requirement,path:i==null?void 0:i.path,issues:i==null?void 0:i.issues,lang:n.lang,abortEarly:n.abortEarly,abortPipeEarly:n.abortPipeEarly},f=e.kind==="schema",h=(i==null?void 0:i.message)??e.message??O8(e.reference,u.lang)??(f?(u.lang,void 0):null)??n.message??(u.lang,void 0);h&&(u.message=typeof h=="function"?h(u):h),f&&(r.typed=!1),r.issues?r.issues.push(u):r.issues=[u]}function I8(e,t){return Object.hasOwn(e,t)&&t!=="__proto__"&&t!=="prototype"&&t!=="constructor"}function By(e,t,r){return typeof e.default=="function"?e.default(t,r):e.default}function Hy(e,t){return!e._run({typed:!1,value:t},{abortEarly:!0}).issues}function fn(e,t){return{kind:"schema",type:"array",reference:fn,expects:"Array",async:!1,item:e,message:t,_run(r,n){var i;const o=r.value;if(Array.isArray(o)){r.typed=!0,r.value=[];for(let s=0;s<o.length;s++){const a=o[s],u=this.item._run({typed:!1,value:a},n);if(u.issues){const f={type:"array",origin:"value",input:o,key:s,value:a};for(const h of u.issues)h.path?h.path.unshift(f):h.path=[f],(i=r.issues)==null||i.push(h);if(r.issues||(r.issues=u.issues),n.abortEarly){r.typed=!1;break}}u.typed||(r.typed=!1),r.value.push(u.value)}}else fr(this,"type",r,n);return r}}}function Ly(e){return{kind:"schema",type:"boolean",reference:Ly,expects:"boolean",async:!1,message:e,_run(t,r){return typeof t.value=="boolean"?t.typed=!0:fr(this,"type",t,r),t}}}function ys(e,t){const r=Object.entries(e).filter(([n])=>isNaN(+n)).map(([,n])=>n);return{kind:"schema",type:"enum",reference:ys,expects:r.map(Nc).join(" | ")||"never",async:!1,enum:e,options:r,message:t,_run(n,i){return this.options.includes(n.value)?n.typed=!0:fr(this,"type",n,i),n}}}function lt(e,t){return{kind:"schema",type:"literal",reference:lt,expects:Nc(e),async:!1,literal:e,message:t,_run(r,n){return r.value===this.literal?r.typed=!0:fr(this,"type",r,n),r}}}function Ky(e,t){return{kind:"schema",type:"loose_object",reference:Ky,expects:"Object",async:!1,entries:e,message:t,_run(r,n){var i;const o=r.value;if(o&&typeof o=="object"){r.typed=!0,r.value={};for(const s in this.entries){const a=o[s],u=this.entries[s]._run({typed:!1,value:a},n);if(u.issues){const f={type:"object",origin:"value",input:o,key:s,value:a};for(const h of u.issues)h.path?h.path.unshift(f):h.path=[f],(i=r.issues)==null||i.push(h);if(r.issues||(r.issues=u.issues),n.abortEarly){r.typed=!1;break}}u.typed||(r.typed=!1),(u.value!==void 0||s in o)&&(r.value[s]=u.value)}if(!r.issues||!n.abortEarly)for(const s in o)I8(o,s)&&!(s in this.entries)&&(r.value[s]=o[s])}else fr(this,"type",r,n);return r}}}function Mh(e,t){return{kind:"schema",type:"non_optional",reference:Mh,expects:"!undefined",async:!1,wrapped:e,message:t,_run(r,n){return r.value===void 0?(fr(this,"type",r,n),r):this.wrapped._run(r,n)}}}function gs(e){return{kind:"schema",type:"null",reference:gs,expects:"null",async:!1,message:e,_run(t,r){return t.value===null?t.typed=!0:fr(this,"type",t,r),t}}}function ws(e,...t){const r={kind:"schema",type:"nullish",reference:ws,expects:`${e.expects} | null | undefined`,async:!1,wrapped:e,_run(n,i){return(n.value===null||n.value===void 0)&&("default"in this&&(n.value=By(this,n,i)),n.value===null||n.value===void 0)?(n.typed=!0,n):this.wrapped._run(n,i)}};return 0 in t&&(r.default=t[0]),r}function Bn(e){return{kind:"schema",type:"number",reference:Bn,expects:"number",async:!1,message:e,_run(t,r){return typeof t.value=="number"&&!isNaN(t.value)?t.typed=!0:fr(this,"type",t,r),t}}}function he(e,t){return{kind:"schema",type:"object",reference:he,expects:"Object",async:!1,entries:e,message:t,_run(r,n){var i;const o=r.value;if(o&&typeof o=="object"){r.typed=!0,r.value={};for(const s in this.entries){const a=o[s],u=this.entries[s]._run({typed:!1,value:a},n);if(u.issues){const f={type:"object",origin:"value",input:o,key:s,value:a};for(const h of u.issues)h.path?h.path.unshift(f):h.path=[f],(i=r.issues)==null||i.push(h);if(r.issues||(r.issues=u.issues),n.abortEarly){r.typed=!1;break}}u.typed||(r.typed=!1),(u.value!==void 0||s in o)&&(r.value[s]=u.value)}}else fr(this,"type",r,n);return r}}}function dn(e,...t){const r={kind:"schema",type:"optional",reference:dn,expects:`${e.expects} | undefined`,async:!1,wrapped:e,_run(n,i){return n.value===void 0&&("default"in this&&(n.value=By(this,n,i)),n.value===void 0)?(n.typed=!0,n):this.wrapped._run(n,i)}};return 0 in t&&(r.default=t[0]),r}function jy(e,t){return{kind:"schema",type:"picklist",reference:jy,expects:e.map(Nc).join(" | ")||"never",async:!1,options:e,message:t,_run(r,n){return this.options.includes(r.value)?r.typed=!0:fr(this,"type",r,n),r}}}function ye(e){return{kind:"schema",type:"string",reference:ye,expects:"string",async:!1,message:e,_run(t,r){return typeof t.value=="string"?t.typed=!0:fr(this,"type",t,r),t}}}function Fh(e){return{kind:"schema",type:"undefined",reference:Fh,expects:"undefined",async:!1,message:e,_run(t,r){return t.value===void 0?t.typed=!0:fr(this,"type",t,r),t}}}function Dy(e){let t;if(e)for(const r of e)t?t.push(...r.issues):t=r.issues;return t}function Uc(e,t){return{kind:"schema",type:"union",reference:Uc,expects:[...new Set(e.map(r=>r.expects))].join(" | ")||"never",async:!1,options:e,message:t,_run(r,n){let i,o,s;for(const a of this.options){const u=a._run({typed:!1,value:r.value},n);if(u.typed)if(u.issues)o?o.push(u):o=[u];else{i=u;break}else s?s.push(u):s=[u]}if(i)return i;if(o){if(o.length===1)return o[0];fr(this,"type",r,n,{issues:Dy(o)}),r.typed=!0}else{if((s==null?void 0:s.length)===1)return s[0];fr(this,"type",r,n,{issues:Dy(s)})}return r}}}function Rc(){return{kind:"schema",type:"unknown",reference:Rc,expects:"unknown",async:!1,_run(e){return e.typed=!0,e}}}var Dr={},Zs={},tr={};Object.defineProperty(tr,"__esModule",{value:!0}),tr.decode=tr.encode=tr.unescape=tr.escape=tr.pad=void 0;const My=Gs;function Vh(e){return`${e}${"=".repeat(4-(e.length%4||4))}`}tr.pad=Vh;function Fy(e){return e.replace(/=/g,"").replace(/\+/g,"-").replace(/\//g,"_")}tr.escape=Fy;function Vy(e){return Vh(e).replace(/-/g,"+").replace(/_/g,"/")}tr.unescape=Vy;function x8(e){return Fy((0,My.fromByteArray)(new TextEncoder().encode(e)))}tr.encode=x8;function $8(e){return new TextDecoder().decode((0,My.toByteArray)(Vh(Vy(e))))}tr.decode=$8;var Bc={},Hc={},Qs={};Object.defineProperty(Qs,"__esModule",{value:!0}),Qs.joseToDer=Qs.derToJose=void 0;const zy=Gs,Wy=tr;function zh(e){return(e/8|0)+(e%8===0?0:1)}const C8={ES256:zh(256),ES384:zh(384),ES512:zh(521)};function qy(e){const t=C8[e];if(t)return t;throw new Error(`Unknown algorithm "${e}"`)}const Lc=128,Gy=0,N8=32,U8=16,R8=2,Xy=U8|N8|Gy<<6,Kc=R8|Gy<<6;function Jy(e){if(e instanceof Uint8Array)return e;if(typeof e=="string")return(0,zy.toByteArray)((0,Wy.pad)(e));throw new TypeError("ECDSA signature must be a Base64 string or a Uint8Array")}function B8(e,t){const r=Jy(e),n=qy(t),i=n+1,o=r.length;let s=0;if(r[s++]!==Xy)throw new Error('Could not find expected "seq"');let a=r[s++];if(a===(Lc|1)&&(a=r[s++]),o-s<a)throw new Error(`"seq" specified length of "${a}", only "${o-s}" remaining`);if(r[s++]!==Kc)throw new Error('Could not find expected "int" for "r"');const u=r[s++];if(o-s-2<u)throw new Error(`"r" specified length of "${u}", only "${o-s-2}" available`);if(i<u)throw new Error(`"r" specified length of "${u}", max of "${i}" is acceptable`);const f=s;if(s+=u,r[s++]!==Kc)throw new Error('Could not find expected "int" for "s"');const h=r[s++];if(o-s!==h)throw new Error(`"s" specified length of "${h}", expected "${o-s}"`);if(i<h)throw new Error(`"s" specified length of "${h}", max of "${i}" is acceptable`);const d=s;if(s+=h,s!==o)throw new Error(`Expected to consume entire array, but "${o-s}" bytes remain`);const g=n-u,v=n-h,E=new Uint8Array(g+u+v+h);for(s=0;s<g;++s)E[s]=0;E.set(r.subarray(f+Math.max(-g,0),f+u),s),s=n;for(const T=s;s<T+v;++s)E[s]=0;return E.set(r.subarray(d+Math.max(-v,0),d+h),s),(0,Wy.escape)((0,zy.fromByteArray)(E))}Qs.derToJose=B8;function Yy(e,t,r){let n=0;for(;t+n<r&&e[t+n]===0;)++n;return e[t+n]>=Lc&&--n,n}function H8(e,t){e=Jy(e);const r=qy(t),n=e.length;if(n!==r*2)throw new TypeError(`"${t}" signatures must be "${r*2}" bytes, saw "${n}"`);const i=Yy(e,0,r),o=Yy(e,r,e.length),s=r-i,a=r-o,u=2+s+1+1+a,f=u<Lc,h=new Uint8Array((f?2:3)+u);let d=0;return h[d++]=Xy,f?h[d++]=u:(h[d++]=Lc|1,h[d++]=u&255),h[d++]=Kc,h[d++]=s,i<0?(h[d++]=0,h.set(e.subarray(0,r),d),d+=r):(h.set(e.subarray(i,r),d),d+=r-i),h[d++]=Kc,h[d++]=a,o<0?(h[d++]=0,h.set(e.subarray(r),d)):h.set(e.subarray(r+o),d),h}Qs.joseToDer=H8;var ni={};Object.defineProperty(ni,"__esModule",{value:!0}),ni.InvalidTokenError=ni.MissingParametersError=void 0;class L8 extends Error{constructor(t){super(),this.name="MissingParametersError",this.message=t||""}}ni.MissingParametersError=L8;class K8 extends Error{constructor(t){super(),this.name="InvalidTokenError",this.message=t||""}}ni.InvalidTokenError=K8,Object.defineProperty(Hc,"__esModule",{value:!0}),Hc.SECP256K1Client=void 0;const j8=Oh,D8=Rn,jc=Ph,Zy=Qs,Qy=ni,eg=Xo;jc.utils.hmacSha256Sync=(e,...t)=>{const r=j8.hmac.create(D8.sha256,e);return t.forEach(n=>r.update(n)),r.digest()};let tg=class{static derivePublicKey(t,r=!0){return t.length===66&&(t=t.slice(0,64)),t.length<64&&(t=t.padStart(64,"0")),(0,eg.bytesToHex)(jc.getPublicKey(t,r))}static signHash(t,r,n="jose"){if(!t||!r)throw new Qy.MissingParametersError("a signing input hash and private key are all required");const i=jc.signSync(t,r.slice(0,64),{der:!0,canonical:!1});if(n==="der")return(0,eg.bytesToHex)(i);if(n==="jose")return(0,Zy.derToJose)(i,"ES256");throw Error("Invalid signature format")}static loadSignature(t){return(0,Zy.joseToDer)(t,"ES256")}static verifyHash(t,r,n){if(!t||!r||!n)throw new Qy.MissingParametersError("a signing input hash, der signature, and public key are all required");return jc.verify(r,t,n,{strict:!1})}};Hc.SECP256K1Client=tg,tg.algorithmName="ES256K",function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.cryptoClients=e.SECP256K1Client=void 0;const t=Hc;Object.defineProperty(e,"SECP256K1Client",{enumerable:!0,get:function(){return t.SECP256K1Client}});const r={ES256K:t.SECP256K1Client};e.cryptoClients=r}(Bc);var bs={},M8=Se&&Se.__awaiter||function(e,t,r,n){function i(o){return o instanceof r?o:new r(function(s){s(o)})}return new(r||(r=Promise))(function(o,s){function a(h){try{f(n.next(h))}catch(d){s(d)}}function u(h){try{f(n.throw(h))}catch(d){s(d)}}function f(h){h.done?o(h.value):i(h.value).then(a,u)}f((n=n.apply(e,t||[])).next())})};Object.defineProperty(bs,"__esModule",{value:!0}),bs.hashSha256Async=bs.hashSha256=void 0;const F8=Rn;function rg(e){return(0,F8.sha256)(e)}bs.hashSha256=rg;function V8(e){return M8(this,void 0,void 0,function*(){try{if(typeof crypto<"u"&&typeof crypto.subtle<"u"){const t=typeof e=="string"?new TextEncoder().encode(e):e,r=yield crypto.subtle.digest("SHA-256",t);return new Uint8Array(r)}else{const t=Ey;if(!t.createHash)throw new Error("`crypto` module does not contain `createHash`");return Promise.resolve(t.createHash("sha256").update(e).digest())}}catch(t){return console.log(t),console.log('Crypto lib not found. Neither the global `crypto.subtle` Web Crypto API, nor the or the Node.js `require("crypto").createHash` module is available. Falling back to JS implementation.'),Promise.resolve(rg(e))}})}bs.hashSha256Async=V8;var z8=Se&&Se.__awaiter||function(e,t,r,n){function i(o){return o instanceof r?o:new r(function(s){s(o)})}return new(r||(r=Promise))(function(o,s){function a(h){try{f(n.next(h))}catch(d){s(d)}}function u(h){try{f(n.throw(h))}catch(d){s(d)}}function f(h){h.done?o(h.value):i(h.value).then(a,u)}f((n=n.apply(e,t||[])).next())})};Object.defineProperty(Zs,"__esModule",{value:!0}),Zs.TokenSigner=Zs.createUnsecuredToken=void 0;const Wh=tr,ng=Bc,W8=ni,ig=bs;function qh(e,t){const r=[],n=Wh.encode(JSON.stringify(t));r.push(n);const i=Wh.encode(JSON.stringify(e));return r.push(i),r.join(".")}function q8(e){return qh(e,{typ:"JWT",alg:"none"})+"."}Zs.createUnsecuredToken=q8;class G8{constructor(t,r){if(!(t&&r))throw new W8.MissingParametersError("a signing algorithm and private key are required");if(typeof t!="string")throw new Error("signing algorithm parameter must be a string");if(t=t.toUpperCase(),!ng.cryptoClients.hasOwnProperty(t))throw new Error("invalid signing algorithm");this.tokenType="JWT",this.cryptoClient=ng.cryptoClients[t],this.rawPrivateKey=r}header(t={}){const r={typ:this.tokenType,alg:this.cryptoClient.algorithmName};return Object.assign({},r,t)}sign(t,r=!1,n={}){const i=this.header(n),o=qh(t,i),s=(0,ig.hashSha256)(o);return this.createWithSignedHash(t,r,i,o,s)}signAsync(t,r=!1,n={}){return z8(this,void 0,void 0,function*(){const i=this.header(n),o=qh(t,i),s=yield(0,ig.hashSha256Async)(o);return this.createWithSignedHash(t,r,i,o,s)})}createWithSignedHash(t,r,n,i,o){const s=this.cryptoClient.signHash(o,this.rawPrivateKey);return r?{header:[Wh.encode(JSON.stringify(n))],payload:JSON.stringify(t),signature:[s]}:[i,s].join(".")}}Zs.TokenSigner=G8;var Dc={};Object.defineProperty(Dc,"__esModule",{value:!0}),Dc.TokenVerifier=void 0;const X8=tr,sg=Bc,J8=ni,Mc=bs;class Y8{constructor(t,r){if(!(t&&r))throw new J8.MissingParametersError("a signing algorithm and public key are required");if(typeof t!="string")throw"signing algorithm parameter must be a string";if(t=t.toUpperCase(),!sg.cryptoClients.hasOwnProperty(t))throw"invalid signing algorithm";this.tokenType="JWT",this.cryptoClient=sg.cryptoClients[t],this.rawPublicKey=r}verify(t){return typeof t=="string"?this.verifyCompact(t,!1):typeof t=="object"?this.verifyExpanded(t,!1):!1}verifyAsync(t){return typeof t=="string"?this.verifyCompact(t,!0):typeof t=="object"?this.verifyExpanded(t,!0):Promise.resolve(!1)}verifyCompact(t,r){const n=t.split("."),i=n[0]+"."+n[1],o=s=>{const a=this.cryptoClient.loadSignature(n[2]);return this.cryptoClient.verifyHash(s,a,this.rawPublicKey)};if(r)return(0,Mc.hashSha256Async)(i).then(s=>o(s));{const s=(0,Mc.hashSha256)(i);return o(s)}}verifyExpanded(t,r){const n=[t.header.join("."),X8.encode(t.payload)].join(".");let i=!0;const o=s=>(t.signature.map(a=>{const u=this.cryptoClient.loadSignature(a);this.cryptoClient.verifyHash(s,u,this.rawPublicKey)||(i=!1)}),i);if(r)return(0,Mc.hashSha256Async)(n).then(s=>o(s));{const s=(0,Mc.hashSha256)(n);return o(s)}}}Dc.TokenVerifier=Y8;var Fc={};Object.defineProperty(Fc,"__esModule",{value:!0}),Fc.decodeToken=void 0;const Vc=tr;function Z8(e){if(typeof e=="string"){const t=e.split("."),r=JSON.parse(Vc.decode(t[0])),n=JSON.parse(Vc.decode(t[1])),i=t[2];return{header:r,payload:n,signature:i}}else if(typeof e=="object"){if(typeof e.payload!="string")throw new Error("Expected token payload to be a base64 or json string");let t=e.payload;e.payload[0]!=="{"&&(t=Vc.decode(t));const r=[];return e.header.map(n=>{const i=JSON.parse(Vc.decode(n));r.push(i)}),{header:r,payload:JSON.parse(t),signature:e.signature}}}Fc.decodeToken=Z8,function(e){var t=Se&&Se.__createBinding||(Object.create?function(n,i,o,s){s===void 0&&(s=o);var a=Object.getOwnPropertyDescriptor(i,o);(!a||("get"in a?!i.__esModule:a.writable||a.configurable))&&(a={enumerable:!0,get:function(){return i[o]}}),Object.defineProperty(n,s,a)}:function(n,i,o,s){s===void 0&&(s=o),n[s]=i[o]}),r=Se&&Se.__exportStar||function(n,i){for(var o in n)o!=="default"&&!Object.prototype.hasOwnProperty.call(i,o)&&t(i,n,o)};Object.defineProperty(e,"__esModule",{value:!0}),r(Zs,e),r(Dc,e),r(Fc,e),r(ni,e),r(Bc,e)}(Dr);/*! *****************************************************************************
16
+ */(function(e){const t=Gs,r=kh,n=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):null;e.Buffer=a,e.SlowBuffer=I,e.INSPECT_MAX_BYTES=50;const i=2147483647;e.kMaxLength=i,a.TYPED_ARRAY_SUPPORT=o(),!a.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 o(){try{const c=new Uint8Array(1),l={foo:function(){return 42}};return Object.setPrototypeOf(l,Uint8Array.prototype),Object.setPrototypeOf(c,l),c.foo()===42}catch{return!1}}Object.defineProperty(a.prototype,"parent",{enumerable:!0,get:function(){if(a.isBuffer(this))return this.buffer}}),Object.defineProperty(a.prototype,"offset",{enumerable:!0,get:function(){if(a.isBuffer(this))return this.byteOffset}});function s(c){if(c>i)throw new RangeError('The value "'+c+'" is invalid for option "size"');const l=new Uint8Array(c);return Object.setPrototypeOf(l,a.prototype),l}function a(c,l,p){if(typeof c=="number"){if(typeof l=="string")throw new TypeError('The "string" argument must be of type string. Received type number');return d(c)}return u(c,l,p)}a.poolSize=8192;function u(c,l,p){if(typeof c=="string")return g(c,l);if(ArrayBuffer.isView(c))return E(c);if(c==null)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof c);if(ze(c,ArrayBuffer)||c&&ze(c.buffer,ArrayBuffer)||typeof SharedArrayBuffer<"u"&&(ze(c,SharedArrayBuffer)||c&&ze(c.buffer,SharedArrayBuffer)))return T(c,l,p);if(typeof c=="number")throw new TypeError('The "value" argument must not be of type number. Received type number');const m=c.valueOf&&c.valueOf();if(m!=null&&m!==c)return a.from(m,l,p);const S=x(c);if(S)return S;if(typeof Symbol<"u"&&Symbol.toPrimitive!=null&&typeof c[Symbol.toPrimitive]=="function")return a.from(c[Symbol.toPrimitive]("string"),l,p);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof c)}a.from=function(c,l,p){return u(c,l,p)},Object.setPrototypeOf(a.prototype,Uint8Array.prototype),Object.setPrototypeOf(a,Uint8Array);function f(c){if(typeof c!="number")throw new TypeError('"size" argument must be of type number');if(c<0)throw new RangeError('The value "'+c+'" is invalid for option "size"')}function h(c,l,p){return f(c),c<=0?s(c):l!==void 0?typeof p=="string"?s(c).fill(l,p):s(c).fill(l):s(c)}a.alloc=function(c,l,p){return h(c,l,p)};function d(c){return f(c),s(c<0?0:N(c)|0)}a.allocUnsafe=function(c){return d(c)},a.allocUnsafeSlow=function(c){return d(c)};function g(c,l){if((typeof l!="string"||l==="")&&(l="utf8"),!a.isEncoding(l))throw new TypeError("Unknown encoding: "+l);const p=k(c,l)|0;let m=s(p);const S=m.write(c,l);return S!==p&&(m=m.slice(0,S)),m}function v(c){const l=c.length<0?0:N(c.length)|0,p=s(l);for(let m=0;m<l;m+=1)p[m]=c[m]&255;return p}function E(c){if(ze(c,Uint8Array)){const l=new Uint8Array(c);return T(l.buffer,l.byteOffset,l.byteLength)}return v(c)}function T(c,l,p){if(l<0||c.byteLength<l)throw new RangeError('"offset" is outside of buffer bounds');if(c.byteLength<l+(p||0))throw new RangeError('"length" is outside of buffer bounds');let m;return l===void 0&&p===void 0?m=new Uint8Array(c):p===void 0?m=new Uint8Array(c,l):m=new Uint8Array(c,l,p),Object.setPrototypeOf(m,a.prototype),m}function x(c){if(a.isBuffer(c)){const l=N(c.length)|0,p=s(l);return p.length===0||c.copy(p,0,0,l),p}if(c.length!==void 0)return typeof c.length!="number"||sr(c.length)?s(0):v(c);if(c.type==="Buffer"&&Array.isArray(c.data))return v(c.data)}function N(c){if(c>=i)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+i.toString(16)+" bytes");return c|0}function I(c){return+c!=c&&(c=0),a.alloc(+c)}a.isBuffer=function(c){return c!=null&&c._isBuffer===!0&&c!==a.prototype},a.compare=function(c,l){if(ze(c,Uint8Array)&&(c=a.from(c,c.offset,c.byteLength)),ze(l,Uint8Array)&&(l=a.from(l,l.offset,l.byteLength)),!a.isBuffer(c)||!a.isBuffer(l))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(c===l)return 0;let p=c.length,m=l.length;for(let S=0,O=Math.min(p,m);S<O;++S)if(c[S]!==l[S]){p=c[S],m=l[S];break}return p<m?-1:m<p?1:0},a.isEncoding=function(c){switch(String(c).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}},a.concat=function(c,l){if(!Array.isArray(c))throw new TypeError('"list" argument must be an Array of Buffers');if(c.length===0)return a.alloc(0);let p;if(l===void 0)for(l=0,p=0;p<c.length;++p)l+=c[p].length;const m=a.allocUnsafe(l);let S=0;for(p=0;p<c.length;++p){let O=c[p];if(ze(O,Uint8Array))S+O.length>m.length?(a.isBuffer(O)||(O=a.from(O)),O.copy(m,S)):Uint8Array.prototype.set.call(m,O,S);else if(a.isBuffer(O))O.copy(m,S);else throw new TypeError('"list" argument must be an Array of Buffers');S+=O.length}return m};function k(c,l){if(a.isBuffer(c))return c.length;if(ArrayBuffer.isView(c)||ze(c,ArrayBuffer))return c.byteLength;if(typeof c!="string")throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof c);const p=c.length,m=arguments.length>2&&arguments[2]===!0;if(!m&&p===0)return 0;let S=!1;for(;;)switch(l){case"ascii":case"latin1":case"binary":return p;case"utf8":case"utf-8":return Lt(c).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return p*2;case"hex":return p>>>1;case"base64":return On(c).length;default:if(S)return m?-1:Lt(c).length;l=(""+l).toLowerCase(),S=!0}}a.byteLength=k;function B(c,l,p){let m=!1;if((l===void 0||l<0)&&(l=0),l>this.length||((p===void 0||p>this.length)&&(p=this.length),p<=0)||(p>>>=0,l>>>=0,p<=l))return"";for(c||(c="utf8");;)switch(c){case"hex":return je(this,l,p);case"utf8":case"utf-8":return oe(this,l,p);case"ascii":return Ae(this,l,p);case"latin1":case"binary":return Et(this,l,p);case"base64":return F(this,l,p);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return Ce(this,l,p);default:if(m)throw new TypeError("Unknown encoding: "+c);c=(c+"").toLowerCase(),m=!0}}a.prototype._isBuffer=!0;function W(c,l,p){const m=c[l];c[l]=c[p],c[p]=m}a.prototype.swap16=function(){const c=this.length;if(c%2!==0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(let l=0;l<c;l+=2)W(this,l,l+1);return this},a.prototype.swap32=function(){const c=this.length;if(c%4!==0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(let l=0;l<c;l+=4)W(this,l,l+3),W(this,l+1,l+2);return this},a.prototype.swap64=function(){const c=this.length;if(c%8!==0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(let l=0;l<c;l+=8)W(this,l,l+7),W(this,l+1,l+6),W(this,l+2,l+5),W(this,l+3,l+4);return this},a.prototype.toString=function(){const c=this.length;return c===0?"":arguments.length===0?oe(this,0,c):B.apply(this,arguments)},a.prototype.toLocaleString=a.prototype.toString,a.prototype.equals=function(c){if(!a.isBuffer(c))throw new TypeError("Argument must be a Buffer");return this===c?!0:a.compare(this,c)===0},a.prototype.inspect=function(){let c="";const l=e.INSPECT_MAX_BYTES;return c=this.toString("hex",0,l).replace(/(.{2})/g,"$1 ").trim(),this.length>l&&(c+=" ... "),"<Buffer "+c+">"},n&&(a.prototype[n]=a.prototype.inspect),a.prototype.compare=function(c,l,p,m,S){if(ze(c,Uint8Array)&&(c=a.from(c,c.offset,c.byteLength)),!a.isBuffer(c))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof c);if(l===void 0&&(l=0),p===void 0&&(p=c?c.length:0),m===void 0&&(m=0),S===void 0&&(S=this.length),l<0||p>c.length||m<0||S>this.length)throw new RangeError("out of range index");if(m>=S&&l>=p)return 0;if(m>=S)return-1;if(l>=p)return 1;if(l>>>=0,p>>>=0,m>>>=0,S>>>=0,this===c)return 0;let O=S-m,U=p-l;const ce=Math.min(O,U),ke=this.slice(m,S),le=c.slice(l,p);for(let ae=0;ae<ce;++ae)if(ke[ae]!==le[ae]){O=ke[ae],U=le[ae];break}return O<U?-1:U<O?1:0};function V(c,l,p,m,S){if(c.length===0)return-1;if(typeof p=="string"?(m=p,p=0):p>2147483647?p=2147483647:p<-2147483648&&(p=-2147483648),p=+p,sr(p)&&(p=S?0:c.length-1),p<0&&(p=c.length+p),p>=c.length){if(S)return-1;p=c.length-1}else if(p<0)if(S)p=0;else return-1;if(typeof l=="string"&&(l=a.from(l,m)),a.isBuffer(l))return l.length===0?-1:Ue(c,l,p,m,S);if(typeof l=="number")return l=l&255,typeof Uint8Array.prototype.indexOf=="function"?S?Uint8Array.prototype.indexOf.call(c,l,p):Uint8Array.prototype.lastIndexOf.call(c,l,p):Ue(c,[l],p,m,S);throw new TypeError("val must be string, number or Buffer")}function Ue(c,l,p,m,S){let O=1,U=c.length,ce=l.length;if(m!==void 0&&(m=String(m).toLowerCase(),m==="ucs2"||m==="ucs-2"||m==="utf16le"||m==="utf-16le")){if(c.length<2||l.length<2)return-1;O=2,U/=2,ce/=2,p/=2}function ke(ae,me){return O===1?ae[me]:ae.readUInt16BE(me*O)}let le;if(S){let ae=-1;for(le=p;le<U;le++)if(ke(c,le)===ke(l,ae===-1?0:le-ae)){if(ae===-1&&(ae=le),le-ae+1===ce)return ae*O}else ae!==-1&&(le-=le-ae),ae=-1}else for(p+ce>U&&(p=U-ce),le=p;le>=0;le--){let ae=!0;for(let me=0;me<ce;me++)if(ke(c,le+me)!==ke(l,me)){ae=!1;break}if(ae)return le}return-1}a.prototype.includes=function(c,l,p){return this.indexOf(c,l,p)!==-1},a.prototype.indexOf=function(c,l,p){return V(this,c,l,p,!0)},a.prototype.lastIndexOf=function(c,l,p){return V(this,c,l,p,!1)};function Le(c,l,p,m){p=Number(p)||0;const S=c.length-p;m?(m=Number(m),m>S&&(m=S)):m=S;const O=l.length;m>O/2&&(m=O/2);let U;for(U=0;U<m;++U){const ce=parseInt(l.substr(U*2,2),16);if(sr(ce))return U;c[p+U]=ce}return U}function Je(c,l,p,m){return Mt(Lt(l,c.length-p),c,p,m)}function Fe(c,l,p,m){return Mt(Xr(l),c,p,m)}function Ye(c,l,p,m){return Mt(On(l),c,p,m)}function C(c,l,p,m){return Mt(Jr(l,c.length-p),c,p,m)}a.prototype.write=function(c,l,p,m){if(l===void 0)m="utf8",p=this.length,l=0;else if(p===void 0&&typeof l=="string")m=l,p=this.length,l=0;else if(isFinite(l))l=l>>>0,isFinite(p)?(p=p>>>0,m===void 0&&(m="utf8")):(m=p,p=void 0);else throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");const S=this.length-l;if((p===void 0||p>S)&&(p=S),c.length>0&&(p<0||l<0)||l>this.length)throw new RangeError("Attempt to write outside buffer bounds");m||(m="utf8");let O=!1;for(;;)switch(m){case"hex":return Le(this,c,l,p);case"utf8":case"utf-8":return Je(this,c,l,p);case"ascii":case"latin1":case"binary":return Fe(this,c,l,p);case"base64":return Ye(this,c,l,p);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return C(this,c,l,p);default:if(O)throw new TypeError("Unknown encoding: "+m);m=(""+m).toLowerCase(),O=!0}},a.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function F(c,l,p){return l===0&&p===c.length?t.fromByteArray(c):t.fromByteArray(c.slice(l,p))}function oe(c,l,p){p=Math.min(c.length,p);const m=[];let S=l;for(;S<p;){const O=c[S];let U=null,ce=O>239?4:O>223?3:O>191?2:1;if(S+ce<=p){let ke,le,ae,me;switch(ce){case 1:O<128&&(U=O);break;case 2:ke=c[S+1],(ke&192)===128&&(me=(O&31)<<6|ke&63,me>127&&(U=me));break;case 3:ke=c[S+1],le=c[S+2],(ke&192)===128&&(le&192)===128&&(me=(O&15)<<12|(ke&63)<<6|le&63,me>2047&&(me<55296||me>57343)&&(U=me));break;case 4:ke=c[S+1],le=c[S+2],ae=c[S+3],(ke&192)===128&&(le&192)===128&&(ae&192)===128&&(me=(O&15)<<18|(ke&63)<<12|(le&63)<<6|ae&63,me>65535&&me<1114112&&(U=me))}}U===null?(U=65533,ce=1):U>65535&&(U-=65536,m.push(U>>>10&1023|55296),U=56320|U&1023),m.push(U),S+=ce}return ue(m)}const J=4096;function ue(c){const l=c.length;if(l<=J)return String.fromCharCode.apply(String,c);let p="",m=0;for(;m<l;)p+=String.fromCharCode.apply(String,c.slice(m,m+=J));return p}function Ae(c,l,p){let m="";p=Math.min(c.length,p);for(let S=l;S<p;++S)m+=String.fromCharCode(c[S]&127);return m}function Et(c,l,p){let m="";p=Math.min(c.length,p);for(let S=l;S<p;++S)m+=String.fromCharCode(c[S]);return m}function je(c,l,p){const m=c.length;(!l||l<0)&&(l=0),(!p||p<0||p>m)&&(p=m);let S="";for(let O=l;O<p;++O)S+=wi[c[O]];return S}function Ce(c,l,p){const m=c.slice(l,p);let S="";for(let O=0;O<m.length-1;O+=2)S+=String.fromCharCode(m[O]+m[O+1]*256);return S}a.prototype.slice=function(c,l){const p=this.length;c=~~c,l=l===void 0?p:~~l,c<0?(c+=p,c<0&&(c=0)):c>p&&(c=p),l<0?(l+=p,l<0&&(l=0)):l>p&&(l=p),l<c&&(l=c);const m=this.subarray(c,l);return Object.setPrototypeOf(m,a.prototype),m};function re(c,l,p){if(c%1!==0||c<0)throw new RangeError("offset is not uint");if(c+l>p)throw new RangeError("Trying to access beyond buffer length")}a.prototype.readUintLE=a.prototype.readUIntLE=function(c,l,p){c=c>>>0,l=l>>>0,p||re(c,l,this.length);let m=this[c],S=1,O=0;for(;++O<l&&(S*=256);)m+=this[c+O]*S;return m},a.prototype.readUintBE=a.prototype.readUIntBE=function(c,l,p){c=c>>>0,l=l>>>0,p||re(c,l,this.length);let m=this[c+--l],S=1;for(;l>0&&(S*=256);)m+=this[c+--l]*S;return m},a.prototype.readUint8=a.prototype.readUInt8=function(c,l){return c=c>>>0,l||re(c,1,this.length),this[c]},a.prototype.readUint16LE=a.prototype.readUInt16LE=function(c,l){return c=c>>>0,l||re(c,2,this.length),this[c]|this[c+1]<<8},a.prototype.readUint16BE=a.prototype.readUInt16BE=function(c,l){return c=c>>>0,l||re(c,2,this.length),this[c]<<8|this[c+1]},a.prototype.readUint32LE=a.prototype.readUInt32LE=function(c,l){return c=c>>>0,l||re(c,4,this.length),(this[c]|this[c+1]<<8|this[c+2]<<16)+this[c+3]*16777216},a.prototype.readUint32BE=a.prototype.readUInt32BE=function(c,l){return c=c>>>0,l||re(c,4,this.length),this[c]*16777216+(this[c+1]<<16|this[c+2]<<8|this[c+3])},a.prototype.readBigUInt64LE=rt(function(c){c=c>>>0,Ve(c,"offset");const l=this[c],p=this[c+7];(l===void 0||p===void 0)&&wt(c,this.length-8);const m=l+this[++c]*2**8+this[++c]*2**16+this[++c]*2**24,S=this[++c]+this[++c]*2**8+this[++c]*2**16+p*2**24;return BigInt(m)+(BigInt(S)<<BigInt(32))}),a.prototype.readBigUInt64BE=rt(function(c){c=c>>>0,Ve(c,"offset");const l=this[c],p=this[c+7];(l===void 0||p===void 0)&&wt(c,this.length-8);const m=l*2**24+this[++c]*2**16+this[++c]*2**8+this[++c],S=this[++c]*2**24+this[++c]*2**16+this[++c]*2**8+p;return(BigInt(m)<<BigInt(32))+BigInt(S)}),a.prototype.readIntLE=function(c,l,p){c=c>>>0,l=l>>>0,p||re(c,l,this.length);let m=this[c],S=1,O=0;for(;++O<l&&(S*=256);)m+=this[c+O]*S;return S*=128,m>=S&&(m-=Math.pow(2,8*l)),m},a.prototype.readIntBE=function(c,l,p){c=c>>>0,l=l>>>0,p||re(c,l,this.length);let m=l,S=1,O=this[c+--m];for(;m>0&&(S*=256);)O+=this[c+--m]*S;return S*=128,O>=S&&(O-=Math.pow(2,8*l)),O},a.prototype.readInt8=function(c,l){return c=c>>>0,l||re(c,1,this.length),this[c]&128?(255-this[c]+1)*-1:this[c]},a.prototype.readInt16LE=function(c,l){c=c>>>0,l||re(c,2,this.length);const p=this[c]|this[c+1]<<8;return p&32768?p|4294901760:p},a.prototype.readInt16BE=function(c,l){c=c>>>0,l||re(c,2,this.length);const p=this[c+1]|this[c]<<8;return p&32768?p|4294901760:p},a.prototype.readInt32LE=function(c,l){return c=c>>>0,l||re(c,4,this.length),this[c]|this[c+1]<<8|this[c+2]<<16|this[c+3]<<24},a.prototype.readInt32BE=function(c,l){return c=c>>>0,l||re(c,4,this.length),this[c]<<24|this[c+1]<<16|this[c+2]<<8|this[c+3]},a.prototype.readBigInt64LE=rt(function(c){c=c>>>0,Ve(c,"offset");const l=this[c],p=this[c+7];(l===void 0||p===void 0)&&wt(c,this.length-8);const m=this[c+4]+this[c+5]*2**8+this[c+6]*2**16+(p<<24);return(BigInt(m)<<BigInt(32))+BigInt(l+this[++c]*2**8+this[++c]*2**16+this[++c]*2**24)}),a.prototype.readBigInt64BE=rt(function(c){c=c>>>0,Ve(c,"offset");const l=this[c],p=this[c+7];(l===void 0||p===void 0)&&wt(c,this.length-8);const m=(l<<24)+this[++c]*2**16+this[++c]*2**8+this[++c];return(BigInt(m)<<BigInt(32))+BigInt(this[++c]*2**24+this[++c]*2**16+this[++c]*2**8+p)}),a.prototype.readFloatLE=function(c,l){return c=c>>>0,l||re(c,4,this.length),r.read(this,c,!0,23,4)},a.prototype.readFloatBE=function(c,l){return c=c>>>0,l||re(c,4,this.length),r.read(this,c,!1,23,4)},a.prototype.readDoubleLE=function(c,l){return c=c>>>0,l||re(c,8,this.length),r.read(this,c,!0,52,8)},a.prototype.readDoubleBE=function(c,l){return c=c>>>0,l||re(c,8,this.length),r.read(this,c,!1,52,8)};function Ne(c,l,p,m,S,O){if(!a.isBuffer(c))throw new TypeError('"buffer" argument must be a Buffer instance');if(l>S||l<O)throw new RangeError('"value" argument is out of bounds');if(p+m>c.length)throw new RangeError("Index out of range")}a.prototype.writeUintLE=a.prototype.writeUIntLE=function(c,l,p,m){if(c=+c,l=l>>>0,p=p>>>0,!m){const U=Math.pow(2,8*p)-1;Ne(this,c,l,p,U,0)}let S=1,O=0;for(this[l]=c&255;++O<p&&(S*=256);)this[l+O]=c/S&255;return l+p},a.prototype.writeUintBE=a.prototype.writeUIntBE=function(c,l,p,m){if(c=+c,l=l>>>0,p=p>>>0,!m){const U=Math.pow(2,8*p)-1;Ne(this,c,l,p,U,0)}let S=p-1,O=1;for(this[l+S]=c&255;--S>=0&&(O*=256);)this[l+S]=c/O&255;return l+p},a.prototype.writeUint8=a.prototype.writeUInt8=function(c,l,p){return c=+c,l=l>>>0,p||Ne(this,c,l,1,255,0),this[l]=c&255,l+1},a.prototype.writeUint16LE=a.prototype.writeUInt16LE=function(c,l,p){return c=+c,l=l>>>0,p||Ne(this,c,l,2,65535,0),this[l]=c&255,this[l+1]=c>>>8,l+2},a.prototype.writeUint16BE=a.prototype.writeUInt16BE=function(c,l,p){return c=+c,l=l>>>0,p||Ne(this,c,l,2,65535,0),this[l]=c>>>8,this[l+1]=c&255,l+2},a.prototype.writeUint32LE=a.prototype.writeUInt32LE=function(c,l,p){return c=+c,l=l>>>0,p||Ne(this,c,l,4,4294967295,0),this[l+3]=c>>>24,this[l+2]=c>>>16,this[l+1]=c>>>8,this[l]=c&255,l+4},a.prototype.writeUint32BE=a.prototype.writeUInt32BE=function(c,l,p){return c=+c,l=l>>>0,p||Ne(this,c,l,4,4294967295,0),this[l]=c>>>24,this[l+1]=c>>>16,this[l+2]=c>>>8,this[l+3]=c&255,l+4};function L(c,l,p,m,S){Er(l,m,S,c,p,7);let O=Number(l&BigInt(4294967295));c[p++]=O,O=O>>8,c[p++]=O,O=O>>8,c[p++]=O,O=O>>8,c[p++]=O;let U=Number(l>>BigInt(32)&BigInt(4294967295));return c[p++]=U,U=U>>8,c[p++]=U,U=U>>8,c[p++]=U,U=U>>8,c[p++]=U,p}function He(c,l,p,m,S){Er(l,m,S,c,p,7);let O=Number(l&BigInt(4294967295));c[p+7]=O,O=O>>8,c[p+6]=O,O=O>>8,c[p+5]=O,O=O>>8,c[p+4]=O;let U=Number(l>>BigInt(32)&BigInt(4294967295));return c[p+3]=U,U=U>>8,c[p+2]=U,U=U>>8,c[p+1]=U,U=U>>8,c[p]=U,p+8}a.prototype.writeBigUInt64LE=rt(function(c,l=0){return L(this,c,l,BigInt(0),BigInt("0xffffffffffffffff"))}),a.prototype.writeBigUInt64BE=rt(function(c,l=0){return He(this,c,l,BigInt(0),BigInt("0xffffffffffffffff"))}),a.prototype.writeIntLE=function(c,l,p,m){if(c=+c,l=l>>>0,!m){const ce=Math.pow(2,8*p-1);Ne(this,c,l,p,ce-1,-ce)}let S=0,O=1,U=0;for(this[l]=c&255;++S<p&&(O*=256);)c<0&&U===0&&this[l+S-1]!==0&&(U=1),this[l+S]=(c/O>>0)-U&255;return l+p},a.prototype.writeIntBE=function(c,l,p,m){if(c=+c,l=l>>>0,!m){const ce=Math.pow(2,8*p-1);Ne(this,c,l,p,ce-1,-ce)}let S=p-1,O=1,U=0;for(this[l+S]=c&255;--S>=0&&(O*=256);)c<0&&U===0&&this[l+S+1]!==0&&(U=1),this[l+S]=(c/O>>0)-U&255;return l+p},a.prototype.writeInt8=function(c,l,p){return c=+c,l=l>>>0,p||Ne(this,c,l,1,127,-128),c<0&&(c=255+c+1),this[l]=c&255,l+1},a.prototype.writeInt16LE=function(c,l,p){return c=+c,l=l>>>0,p||Ne(this,c,l,2,32767,-32768),this[l]=c&255,this[l+1]=c>>>8,l+2},a.prototype.writeInt16BE=function(c,l,p){return c=+c,l=l>>>0,p||Ne(this,c,l,2,32767,-32768),this[l]=c>>>8,this[l+1]=c&255,l+2},a.prototype.writeInt32LE=function(c,l,p){return c=+c,l=l>>>0,p||Ne(this,c,l,4,2147483647,-2147483648),this[l]=c&255,this[l+1]=c>>>8,this[l+2]=c>>>16,this[l+3]=c>>>24,l+4},a.prototype.writeInt32BE=function(c,l,p){return c=+c,l=l>>>0,p||Ne(this,c,l,4,2147483647,-2147483648),c<0&&(c=4294967295+c+1),this[l]=c>>>24,this[l+1]=c>>>16,this[l+2]=c>>>8,this[l+3]=c&255,l+4},a.prototype.writeBigInt64LE=rt(function(c,l=0){return L(this,c,l,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))}),a.prototype.writeBigInt64BE=rt(function(c,l=0){return He(this,c,l,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});function Pn(c,l,p,m,S,O){if(p+m>c.length)throw new RangeError("Index out of range");if(p<0)throw new RangeError("Index out of range")}function gt(c,l,p,m,S){return l=+l,p=p>>>0,S||Pn(c,l,p,4),r.write(c,l,p,m,23,4),p+4}a.prototype.writeFloatLE=function(c,l,p){return gt(this,c,l,!0,p)},a.prototype.writeFloatBE=function(c,l,p){return gt(this,c,l,!1,p)};function Nr(c,l,p,m,S){return l=+l,p=p>>>0,S||Pn(c,l,p,8),r.write(c,l,p,m,52,8),p+8}a.prototype.writeDoubleLE=function(c,l,p){return Nr(this,c,l,!0,p)},a.prototype.writeDoubleBE=function(c,l,p){return Nr(this,c,l,!1,p)},a.prototype.copy=function(c,l,p,m){if(!a.isBuffer(c))throw new TypeError("argument should be a Buffer");if(p||(p=0),!m&&m!==0&&(m=this.length),l>=c.length&&(l=c.length),l||(l=0),m>0&&m<p&&(m=p),m===p||c.length===0||this.length===0)return 0;if(l<0)throw new RangeError("targetStart out of bounds");if(p<0||p>=this.length)throw new RangeError("Index out of range");if(m<0)throw new RangeError("sourceEnd out of bounds");m>this.length&&(m=this.length),c.length-l<m-p&&(m=c.length-l+p);const S=m-p;return this===c&&typeof Uint8Array.prototype.copyWithin=="function"?this.copyWithin(l,p,m):Uint8Array.prototype.set.call(c,this.subarray(p,m),l),S},a.prototype.fill=function(c,l,p,m){if(typeof c=="string"){if(typeof l=="string"?(m=l,l=0,p=this.length):typeof p=="string"&&(m=p,p=this.length),m!==void 0&&typeof m!="string")throw new TypeError("encoding must be a string");if(typeof m=="string"&&!a.isEncoding(m))throw new TypeError("Unknown encoding: "+m);if(c.length===1){const O=c.charCodeAt(0);(m==="utf8"&&O<128||m==="latin1")&&(c=O)}}else typeof c=="number"?c=c&255:typeof c=="boolean"&&(c=Number(c));if(l<0||this.length<l||this.length<p)throw new RangeError("Out of range index");if(p<=l)return this;l=l>>>0,p=p===void 0?this.length:p>>>0,c||(c=0);let S;if(typeof c=="number")for(S=l;S<p;++S)this[S]=c;else{const O=a.isBuffer(c)?c:a.from(c,m),U=O.length;if(U===0)throw new TypeError('The value "'+c+'" is invalid for argument "value"');for(S=0;S<p-l;++S)this[S+l]=O[S%U]}return this};const At={};function Ht(c,l,p){At[c]=class extends p{constructor(){super(),Object.defineProperty(this,"message",{value:l.apply(this,arguments),writable:!0,configurable:!0}),this.name=`${this.name} [${c}]`,this.stack,delete this.name}get code(){return c}set code(m){Object.defineProperty(this,"code",{configurable:!0,enumerable:!0,value:m,writable:!0})}toString(){return`${this.name} [${c}]: ${this.message}`}}}Ht("ERR_BUFFER_OUT_OF_BOUNDS",function(c){return c?`${c} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"},RangeError),Ht("ERR_INVALID_ARG_TYPE",function(c,l){return`The "${c}" argument must be of type number. Received type ${typeof l}`},TypeError),Ht("ERR_OUT_OF_RANGE",function(c,l,p){let m=`The value of "${c}" is out of range.`,S=p;return Number.isInteger(p)&&Math.abs(p)>2**32?S=st(String(p)):typeof p=="bigint"&&(S=String(p),(p>BigInt(2)**BigInt(32)||p<-(BigInt(2)**BigInt(32)))&&(S=st(S)),S+="n"),m+=` It must be ${l}. Received ${S}`,m},RangeError);function st(c){let l="",p=c.length;const m=c[0]==="-"?1:0;for(;p>=m+4;p-=3)l=`_${c.slice(p-3,p)}${l}`;return`${c.slice(0,p)}${l}`}function Dt(c,l,p){Ve(l,"offset"),(c[l]===void 0||c[l+p]===void 0)&&wt(l,c.length-(p+1))}function Er(c,l,p,m,S,O){if(c>p||c<l){const U=typeof l=="bigint"?"n":"";let ce;throw l===0||l===BigInt(0)?ce=`>= 0${U} and < 2${U} ** ${(O+1)*8}${U}`:ce=`>= -(2${U} ** ${(O+1)*8-1}${U}) and < 2 ** ${(O+1)*8-1}${U}`,new At.ERR_OUT_OF_RANGE("value",ce,c)}Dt(m,S,O)}function Ve(c,l){if(typeof c!="number")throw new At.ERR_INVALID_ARG_TYPE(l,"number",c)}function wt(c,l,p){throw Math.floor(c)!==c?(Ve(c,p),new At.ERR_OUT_OF_RANGE("offset","an integer",c)):l<0?new At.ERR_BUFFER_OUT_OF_BOUNDS:new At.ERR_OUT_OF_RANGE("offset",`>= 0 and <= ${l}`,c)}const Ar=/[^+/0-9A-Za-z-_]/g;function nt(c){if(c=c.split("=")[0],c=c.trim().replace(Ar,""),c.length<2)return"";for(;c.length%4!==0;)c=c+"=";return c}function Lt(c,l){l=l||1/0;let p;const m=c.length;let S=null;const O=[];for(let U=0;U<m;++U){if(p=c.charCodeAt(U),p>55295&&p<57344){if(!S){if(p>56319){(l-=3)>-1&&O.push(239,191,189);continue}else if(U+1===m){(l-=3)>-1&&O.push(239,191,189);continue}S=p;continue}if(p<56320){(l-=3)>-1&&O.push(239,191,189),S=p;continue}p=(S-55296<<10|p-56320)+65536}else S&&(l-=3)>-1&&O.push(239,191,189);if(S=null,p<128){if((l-=1)<0)break;O.push(p)}else if(p<2048){if((l-=2)<0)break;O.push(p>>6|192,p&63|128)}else if(p<65536){if((l-=3)<0)break;O.push(p>>12|224,p>>6&63|128,p&63|128)}else if(p<1114112){if((l-=4)<0)break;O.push(p>>18|240,p>>12&63|128,p>>6&63|128,p&63|128)}else throw new Error("Invalid code point")}return O}function Xr(c){const l=[];for(let p=0;p<c.length;++p)l.push(c.charCodeAt(p)&255);return l}function Jr(c,l){let p,m,S;const O=[];for(let U=0;U<c.length&&!((l-=2)<0);++U)p=c.charCodeAt(U),m=p>>8,S=p%256,O.push(S),O.push(m);return O}function On(c){return t.toByteArray(nt(c))}function Mt(c,l,p,m){let S;for(S=0;S<m&&!(S+p>=l.length||S>=c.length);++S)l[S+p]=c[S];return S}function ze(c,l){return c instanceof l||c!=null&&c.constructor!=null&&c.constructor.name!=null&&c.constructor.name===l.name}function sr(c){return c!==c}const wi=function(){const c="0123456789abcdef",l=new Array(256);for(let p=0;p<16;++p){const m=p*16;for(let S=0;S<16;++S)l[m+S]=c[p]+c[S]}return l}();function rt(c){return typeof BigInt>"u"?Yr:c}function Yr(){throw new Error("BigInt not supported")}})(my);const sS="https://mempool.space",oS="https://mempool.space/testnet",aS="https://mempool.space/testnet4",cS="https://mempool.space/signet",uS="https://mempool.fractalbitcoin.io",lS="https://mempool-testnet.fractalbitcoin.io",ti=e=>e===it?oS:e===Zt?aS:e===Yt?cS:e===ls?uS:e===Qt?lS:sS;var ut={},Ph={};const hS={},fS=Object.freeze(Object.defineProperty({__proto__:null,default:hS},Symbol.toStringTag,{value:"Module"})),Ey=lv(fS);(function(e){/*! noble-secp256k1 - MIT License (c) 2019 Paul Miller (paulmillr.com) */Object.defineProperty(e,"__esModule",{value:!0}),e.utils=e.schnorr=e.verify=e.signSync=e.sign=e.getSharedSecret=e.recoverPublicKey=e.getPublicKey=e.Signature=e.Point=e.CURVE=void 0;const t=Ey,r=BigInt(0),n=BigInt(1),i=BigInt(2),o=BigInt(3),s=BigInt(8),a=Object.freeze({a:r,b:BigInt(7),P:BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),n:BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),h:n,Gx:BigInt("55066263022277343669578718895168534326250603453777594175500187360389116729240"),Gy:BigInt("32670510020758816978083085130507043184471273380659243275938904335757337482424"),beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee")});e.CURVE=a;const u=(b,y)=>(b+y/i)/y,f={beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),splitScalar(b){const{n:y}=a,w=BigInt("0x3086d221a7d46bcde86c90e49284eb15"),A=-n*BigInt("0xe4437ed6010e88286f547fa90abfe4c3"),_=BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),$=w,H=BigInt("0x100000000000000000000000000000000"),K=u($*b,y),q=u(-A*b,y);let z=L(b-K*w-q*_,y),X=L(-K*A-q*$,y);const Z=z>H,te=X>H;if(Z&&(z=y-z),te&&(X=y-X),z>H||X>H)throw new Error("splitScalarEndo: Endomorphism failed, k="+b);return{k1neg:Z,k1:z,k2neg:te,k2:X}}},h=32,d=32,g=32,v=h+1,E=2*h+1;function T(b){const{a:y,b:w}=a,A=L(b*b),_=L(A*b);return L(_+y*b+w)}const x=a.a===r;class N extends Error{constructor(y){super(y)}}function I(b){if(!(b instanceof k))throw new TypeError("JacobianPoint expected")}class k{constructor(y,w,A){this.x=y,this.y=w,this.z=A}static fromAffine(y){if(!(y instanceof V))throw new TypeError("JacobianPoint#fromAffine: expected Point");return y.equals(V.ZERO)?k.ZERO:new k(y.x,y.y,n)}static toAffineBatch(y){const w=Nr(y.map(A=>A.z));return y.map((A,_)=>A.toAffine(w[_]))}static normalizeZ(y){return k.toAffineBatch(y).map(k.fromAffine)}equals(y){I(y);const{x:w,y:A,z:_}=this,{x:$,y:H,z:K}=y,q=L(_*_),z=L(K*K),X=L(w*z),Z=L($*q),te=L(L(A*K)*z),P=L(L(H*_)*q);return X===Z&&te===P}negate(){return new k(this.x,L(-this.y),this.z)}double(){const{x:y,y:w,z:A}=this,_=L(y*y),$=L(w*w),H=L($*$),K=y+$,q=L(i*(L(K*K)-_-H)),z=L(o*_),X=L(z*z),Z=L(X-i*q),te=L(z*(q-Z)-s*H),P=L(i*w*A);return new k(Z,te,P)}add(y){I(y);const{x:w,y:A,z:_}=this,{x:$,y:H,z:K}=y;if($===r||H===r)return this;if(w===r||A===r)return y;const q=L(_*_),z=L(K*K),X=L(w*z),Z=L($*q),te=L(L(A*K)*z),P=L(L(H*_)*q),j=L(Z-X),G=L(P-te);if(j===r)return G===r?this.double():k.ZERO;const ne=L(j*j),_e=L(j*ne),$e=L(X*ne),Pe=L(G*G-_e-i*$e),Oe=L(G*($e-Pe)-te*_e),Ze=L(_*K*j);return new k(Pe,Oe,Ze)}subtract(y){return this.add(y.negate())}multiplyUnsafe(y){const w=k.ZERO;if(typeof y=="bigint"&&y===r)return w;let A=Ne(y);if(A===n)return this;if(!x){let Z=w,te=this;for(;A>r;)A&n&&(Z=Z.add(te)),te=te.double(),A>>=n;return Z}let{k1neg:_,k1:$,k2neg:H,k2:K}=f.splitScalar(A),q=w,z=w,X=this;for(;$>r||K>r;)$&n&&(q=q.add(X)),K&n&&(z=z.add(X)),X=X.double(),$>>=n,K>>=n;return _&&(q=q.negate()),H&&(z=z.negate()),z=new k(L(z.x*f.beta),z.y,z.z),q.add(z)}precomputeWindow(y){const w=x?128/y+1:256/y+1,A=[];let _=this,$=_;for(let H=0;H<w;H++){$=_,A.push($);for(let K=1;K<2**(y-1);K++)$=$.add(_),A.push($);_=$.double()}return A}wNAF(y,w){!w&&this.equals(k.BASE)&&(w=V.BASE);const A=w&&w._WINDOW_SIZE||1;if(256%A)throw new Error("Point#wNAF: Invalid precomputation window, must be power of 2");let _=w&&W.get(w);_||(_=this.precomputeWindow(A),w&&A!==1&&(_=k.normalizeZ(_),W.set(w,_)));let $=k.ZERO,H=k.BASE;const K=1+(x?128/A:256/A),q=2**(A-1),z=BigInt(2**A-1),X=2**A,Z=BigInt(A);for(let te=0;te<K;te++){const P=te*q;let j=Number(y&z);y>>=Z,j>q&&(j-=X,y+=n);const G=P,ne=P+Math.abs(j)-1,_e=te%2!==0,$e=j<0;j===0?H=H.add(B(_e,_[G])):$=$.add(B($e,_[ne]))}return{p:$,f:H}}multiply(y,w){let A=Ne(y),_,$;if(x){const{k1neg:H,k1:K,k2neg:q,k2:z}=f.splitScalar(A);let{p:X,f:Z}=this.wNAF(K,w),{p:te,f:P}=this.wNAF(z,w);X=B(H,X),te=B(q,te),te=new k(L(te.x*f.beta),te.y,te.z),_=X.add(te),$=Z.add(P)}else{const{p:H,f:K}=this.wNAF(A,w);_=H,$=K}return k.normalizeZ([_,$])[0]}toAffine(y){const{x:w,y:A,z:_}=this,$=this.equals(k.ZERO);y==null&&(y=$?s:gt(_));const H=y,K=L(H*H),q=L(K*H),z=L(w*K),X=L(A*q),Z=L(_*H);if($)return V.ZERO;if(Z!==n)throw new Error("invZ was invalid");return new V(z,X)}}k.BASE=new k(a.Gx,a.Gy,n),k.ZERO=new k(r,n,r);function B(b,y){const w=y.negate();return b?w:y}const W=new WeakMap;class V{constructor(y,w){this.x=y,this.y=w}_setWindowSize(y){this._WINDOW_SIZE=y,W.delete(this)}hasEvenY(){return this.y%i===r}static fromCompressedHex(y){const w=y.length===32,A=Ce(w?y:y.subarray(1));if(!wt(A))throw new Error("Point is not on curve");const _=T(A);let $=Pn(_);const H=($&n)===n;w?H&&($=L(-$)):(y[0]&1)===1!==H&&($=L(-$));const K=new V(A,$);return K.assertValidity(),K}static fromUncompressedHex(y){const w=Ce(y.subarray(1,h+1)),A=Ce(y.subarray(h+1,h*2+1)),_=new V(w,A);return _.assertValidity(),_}static fromHex(y){const w=re(y),A=w.length,_=w[0];if(A===h)return this.fromCompressedHex(w);if(A===v&&(_===2||_===3))return this.fromCompressedHex(w);if(A===E&&_===4)return this.fromUncompressedHex(w);throw new Error(`Point.fromHex: received invalid point. Expected 32-${v} compressed bytes or ${E} uncompressed bytes, not ${A}`)}static fromPrivateKey(y){return V.BASE.multiply(nt(y))}static fromSignature(y,w,A){const{r:_,s:$}=Xr(w);if(![0,1,2,3].includes(A))throw new Error("Cannot recover: invalid recovery bit");const H=Ht(re(y)),{n:K}=a,q=A===2||A===3?_+K:_,z=gt(q,K),X=L(-H*z,K),Z=L($*z,K),te=A&1?"03":"02",P=V.fromHex(te+J(q)),j=V.BASE.multiplyAndAddUnsafe(P,X,Z);if(!j)throw new Error("Cannot recover signature: point at infinify");return j.assertValidity(),j}toRawBytes(y=!1){return je(this.toHex(y))}toHex(y=!1){const w=J(this.x);return y?`${this.hasEvenY()?"02":"03"}${w}`:`04${w}${J(this.y)}`}toHexX(){return this.toHex(!0).slice(2)}toRawX(){return this.toRawBytes(!0).slice(1)}assertValidity(){const y="Point is not on elliptic curve",{x:w,y:A}=this;if(!wt(w)||!wt(A))throw new Error(y);const _=L(A*A),$=T(w);if(L(_-$)!==r)throw new Error(y)}equals(y){return this.x===y.x&&this.y===y.y}negate(){return new V(this.x,L(-this.y))}double(){return k.fromAffine(this).double().toAffine()}add(y){return k.fromAffine(this).add(k.fromAffine(y)).toAffine()}subtract(y){return this.add(y.negate())}multiply(y){return k.fromAffine(this).multiply(y,this).toAffine()}multiplyAndAddUnsafe(y,w,A){const _=k.fromAffine(this),$=w===r||w===n||this!==V.BASE?_.multiplyUnsafe(w):_.multiply(w),H=k.fromAffine(y).multiplyUnsafe(A),K=$.add(H);return K.equals(k.ZERO)?void 0:K.toAffine()}}e.Point=V,V.BASE=new V(a.Gx,a.Gy),V.ZERO=new V(r,r);function Ue(b){return Number.parseInt(b[0],16)>=8?"00"+b:b}function Le(b){if(b.length<2||b[0]!==2)throw new Error(`Invalid signature integer tag: ${F(b)}`);const y=b[1],w=b.subarray(2,y+2);if(!y||w.length!==y)throw new Error("Invalid signature integer: wrong length");if(w[0]===0&&w[1]<=127)throw new Error("Invalid signature integer: trailing length");return{data:Ce(w),left:b.subarray(y+2)}}function Je(b){if(b.length<2||b[0]!=48)throw new Error(`Invalid signature tag: ${F(b)}`);if(b[1]!==b.length-2)throw new Error("Invalid signature: incorrect length");const{data:y,left:w}=Le(b.subarray(2)),{data:A,left:_}=Le(w);if(_.length)throw new Error(`Invalid signature: left bytes after parsing: ${F(_)}`);return{r:y,s:A}}class Fe{constructor(y,w){this.r=y,this.s=w,this.assertValidity()}static fromCompact(y){const w=y instanceof Uint8Array,A="Signature.fromCompact";if(typeof y!="string"&&!w)throw new TypeError(`${A}: Expected string or Uint8Array`);const _=w?F(y):y;if(_.length!==128)throw new Error(`${A}: Expected 64-byte hex`);return new Fe(Et(_.slice(0,64)),Et(_.slice(64,128)))}static fromDER(y){const w=y instanceof Uint8Array;if(typeof y!="string"&&!w)throw new TypeError("Signature.fromDER: Expected string or Uint8Array");const{r:A,s:_}=Je(w?y:je(y));return new Fe(A,_)}static fromHex(y){return this.fromDER(y)}assertValidity(){const{r:y,s:w}=this;if(!Ve(y))throw new Error("Invalid Signature: r must be 0 < r < n");if(!Ve(w))throw new Error("Invalid Signature: s must be 0 < s < n")}hasHighS(){const y=a.n>>n;return this.s>y}normalizeS(){return this.hasHighS()?new Fe(this.r,L(-this.s,a.n)):this}toDERRawBytes(){return je(this.toDERHex())}toDERHex(){const y=Ue(Ae(this.s)),w=Ue(Ae(this.r)),A=y.length/2,_=w.length/2,$=Ae(A),H=Ae(_);return`30${Ae(_+A+4)}02${H}${w}02${$}${y}`}toRawBytes(){return this.toDERRawBytes()}toHex(){return this.toDERHex()}toCompactRawBytes(){return je(this.toCompactHex())}toCompactHex(){return J(this.r)+J(this.s)}}e.Signature=Fe;function Ye(...b){if(!b.every(A=>A instanceof Uint8Array))throw new Error("Uint8Array list expected");if(b.length===1)return b[0];const y=b.reduce((A,_)=>A+_.length,0),w=new Uint8Array(y);for(let A=0,_=0;A<b.length;A++){const $=b[A];w.set($,_),_+=$.length}return w}const C=Array.from({length:256},(b,y)=>y.toString(16).padStart(2,"0"));function F(b){if(!(b instanceof Uint8Array))throw new Error("Expected Uint8Array");let y="";for(let w=0;w<b.length;w++)y+=C[b[w]];return y}const oe=BigInt("0x10000000000000000000000000000000000000000000000000000000000000000");function J(b){if(typeof b!="bigint")throw new Error("Expected bigint");if(!(r<=b&&b<oe))throw new Error("Expected number 0 <= n < 2^256");return b.toString(16).padStart(64,"0")}function ue(b){const y=je(J(b));if(y.length!==32)throw new Error("Error: expected 32 bytes");return y}function Ae(b){const y=b.toString(16);return y.length&1?`0${y}`:y}function Et(b){if(typeof b!="string")throw new TypeError("hexToNumber: expected string, got "+typeof b);return BigInt(`0x${b}`)}function je(b){if(typeof b!="string")throw new TypeError("hexToBytes: expected string, got "+typeof b);if(b.length%2)throw new Error("hexToBytes: received invalid unpadded hex"+b.length);const y=new Uint8Array(b.length/2);for(let w=0;w<y.length;w++){const A=w*2,_=b.slice(A,A+2),$=Number.parseInt(_,16);if(Number.isNaN($)||$<0)throw new Error("Invalid byte sequence");y[w]=$}return y}function Ce(b){return Et(F(b))}function re(b){return b instanceof Uint8Array?Uint8Array.from(b):je(b)}function Ne(b){if(typeof b=="number"&&Number.isSafeInteger(b)&&b>0)return BigInt(b);if(typeof b=="bigint"&&Ve(b))return b;throw new TypeError("Expected valid private scalar: 0 < scalar < curve.n")}function L(b,y=a.P){const w=b%y;return w>=r?w:y+w}function He(b,y){const{P:w}=a;let A=b;for(;y-- >r;)A*=A,A%=w;return A}function Pn(b){const{P:y}=a,w=BigInt(6),A=BigInt(11),_=BigInt(22),$=BigInt(23),H=BigInt(44),K=BigInt(88),q=b*b*b%y,z=q*q*b%y,X=He(z,o)*z%y,Z=He(X,o)*z%y,te=He(Z,i)*q%y,P=He(te,A)*te%y,j=He(P,_)*P%y,G=He(j,H)*j%y,ne=He(G,K)*G%y,_e=He(ne,H)*j%y,$e=He(_e,o)*z%y,Pe=He($e,$)*P%y,Oe=He(Pe,w)*q%y,Ze=He(Oe,i);if(Ze*Ze%y!==b)throw new Error("Cannot find square root");return Ze}function gt(b,y=a.P){if(b===r||y<=r)throw new Error(`invert: expected positive integers, got n=${b} mod=${y}`);let w=L(b,y),A=y,_=r,$=n;for(;w!==r;){const H=A/w,K=A%w,q=_-$*H;A=w,w=K,_=$,$=q}if(A!==n)throw new Error("invert: does not exist");return L(_,y)}function Nr(b,y=a.P){const w=new Array(b.length),A=b.reduce(($,H,K)=>H===r?$:(w[K]=$,L($*H,y)),n),_=gt(A,y);return b.reduceRight(($,H,K)=>H===r?$:(w[K]=L($*w[K],y),L($*H,y)),_),w}function At(b){const y=b.length*8-d*8,w=Ce(b);return y>0?w>>BigInt(y):w}function Ht(b,y=!1){const w=At(b);if(y)return w;const{n:A}=a;return w>=A?w-A:w}let st,Dt;class Er{constructor(y,w){if(this.hashLen=y,this.qByteLen=w,typeof y!="number"||y<2)throw new Error("hashLen must be a number");if(typeof w!="number"||w<2)throw new Error("qByteLen must be a number");this.v=new Uint8Array(y).fill(1),this.k=new Uint8Array(y).fill(0),this.counter=0}hmac(...y){return e.utils.hmacSha256(this.k,...y)}hmacSync(...y){return Dt(this.k,...y)}checkSync(){if(typeof Dt!="function")throw new N("hmacSha256Sync needs to be set")}incr(){if(this.counter>=1e3)throw new Error("Tried 1,000 k values for sign(), all were invalid");this.counter+=1}async reseed(y=new Uint8Array){this.k=await this.hmac(this.v,Uint8Array.from([0]),y),this.v=await this.hmac(this.v),y.length!==0&&(this.k=await this.hmac(this.v,Uint8Array.from([1]),y),this.v=await this.hmac(this.v))}reseedSync(y=new Uint8Array){this.checkSync(),this.k=this.hmacSync(this.v,Uint8Array.from([0]),y),this.v=this.hmacSync(this.v),y.length!==0&&(this.k=this.hmacSync(this.v,Uint8Array.from([1]),y),this.v=this.hmacSync(this.v))}async generate(){this.incr();let y=0;const w=[];for(;y<this.qByteLen;){this.v=await this.hmac(this.v);const A=this.v.slice();w.push(A),y+=this.v.length}return Ye(...w)}generateSync(){this.checkSync(),this.incr();let y=0;const w=[];for(;y<this.qByteLen;){this.v=this.hmacSync(this.v);const A=this.v.slice();w.push(A),y+=this.v.length}return Ye(...w)}}function Ve(b){return r<b&&b<a.n}function wt(b){return r<b&&b<a.P}function Ar(b,y,w,A=!0){const{n:_}=a,$=Ht(b,!0);if(!Ve($))return;const H=gt($,_),K=V.BASE.multiply($),q=L(K.x,_);if(q===r)return;const z=L(H*L(y+w*q,_),_);if(z===r)return;let X=new Fe(q,z),Z=(K.x===X.r?0:2)|Number(K.y&n);return A&&X.hasHighS()&&(X=X.normalizeS(),Z^=1),{sig:X,recovery:Z}}function nt(b){let y;if(typeof b=="bigint")y=b;else if(typeof b=="number"&&Number.isSafeInteger(b)&&b>0)y=BigInt(b);else if(typeof b=="string"){if(b.length!==2*d)throw new Error("Expected 32 bytes of private key");y=Et(b)}else if(b instanceof Uint8Array){if(b.length!==d)throw new Error("Expected 32 bytes of private key");y=Ce(b)}else throw new TypeError("Expected valid private key");if(!Ve(y))throw new Error("Expected private key: 0 < key < n");return y}function Lt(b){return b instanceof V?(b.assertValidity(),b):V.fromHex(b)}function Xr(b){if(b instanceof Fe)return b.assertValidity(),b;try{return Fe.fromDER(b)}catch{return Fe.fromCompact(b)}}function Jr(b,y=!1){return V.fromPrivateKey(b).toRawBytes(y)}e.getPublicKey=Jr;function On(b,y,w,A=!1){return V.fromSignature(b,y,w).toRawBytes(A)}e.recoverPublicKey=On;function Mt(b){const y=b instanceof Uint8Array,w=typeof b=="string",A=(y||w)&&b.length;return y?A===v||A===E:w?A===v*2||A===E*2:b instanceof V}function ze(b,y,w=!1){if(Mt(b))throw new TypeError("getSharedSecret: first arg must be private key");if(!Mt(y))throw new TypeError("getSharedSecret: second arg must be public key");const A=Lt(y);return A.assertValidity(),A.multiply(nt(b)).toRawBytes(w)}e.getSharedSecret=ze;function sr(b){const y=b.length>h?b.slice(0,h):b;return Ce(y)}function wi(b){const y=sr(b),w=L(y,a.n);return rt(w<r?y:w)}function rt(b){return ue(b)}function Yr(b,y,w){if(b==null)throw new Error(`sign: expected valid message hash, not "${b}"`);const A=re(b),_=nt(y),$=[rt(_),wi(A)];if(w!=null){w===!0&&(w=e.utils.randomBytes(h));const q=re(w);if(q.length!==h)throw new Error(`sign: Expected ${h} bytes of extra data`);$.push(q)}const H=Ye(...$),K=sr(A);return{seed:H,m:K,d:_}}function c(b,y){const{sig:w,recovery:A}=b,{der:_,recovered:$}=Object.assign({canonical:!0,der:!0},y),H=_?w.toDERRawBytes():w.toCompactRawBytes();return $?[H,A]:H}async function l(b,y,w={}){const{seed:A,m:_,d:$}=Yr(b,y,w.extraEntropy),H=new Er(g,d);await H.reseed(A);let K;for(;!(K=Ar(await H.generate(),_,$,w.canonical));)await H.reseed();return c(K,w)}e.sign=l;function p(b,y,w={}){const{seed:A,m:_,d:$}=Yr(b,y,w.extraEntropy),H=new Er(g,d);H.reseedSync(A);let K;for(;!(K=Ar(H.generateSync(),_,$,w.canonical));)H.reseedSync();return c(K,w)}e.signSync=p;const m={strict:!0};function S(b,y,w,A=m){let _;try{_=Xr(b),y=re(y)}catch{return!1}const{r:$,s:H}=_;if(A.strict&&_.hasHighS())return!1;const K=Ht(y);let q;try{q=Lt(w)}catch{return!1}const{n:z}=a,X=gt(H,z),Z=L(K*X,z),te=L($*X,z),P=V.BASE.multiplyAndAddUnsafe(q,Z,te);return P?L(P.x,z)===$:!1}e.verify=S;function O(b){return L(Ce(b),a.n)}class U{constructor(y,w){this.r=y,this.s=w,this.assertValidity()}static fromHex(y){const w=re(y);if(w.length!==64)throw new TypeError(`SchnorrSignature.fromHex: expected 64 bytes, not ${w.length}`);const A=Ce(w.subarray(0,32)),_=Ce(w.subarray(32,64));return new U(A,_)}assertValidity(){const{r:y,s:w}=this;if(!wt(y)||!Ve(w))throw new Error("Invalid signature")}toHex(){return J(this.r)+J(this.s)}toRawBytes(){return je(this.toHex())}}function ce(b){return V.fromPrivateKey(b).toRawX()}class ke{constructor(y,w,A=e.utils.randomBytes()){if(y==null)throw new TypeError(`sign: Expected valid message, not "${y}"`);this.m=re(y);const{x:_,scalar:$}=this.getScalar(nt(w));if(this.px=_,this.d=$,this.rand=re(A),this.rand.length!==32)throw new TypeError("sign: Expected 32 bytes of aux randomness")}getScalar(y){const w=V.fromPrivateKey(y),A=w.hasEvenY()?y:a.n-y;return{point:w,scalar:A,x:w.toRawX()}}initNonce(y,w){return ue(y^Ce(w))}finalizeNonce(y){const w=L(Ce(y),a.n);if(w===r)throw new Error("sign: Creation of signature failed. k is zero");const{point:A,x:_,scalar:$}=this.getScalar(w);return{R:A,rx:_,k:$}}finalizeSig(y,w,A,_){return new U(y.x,L(w+A*_,a.n)).toRawBytes()}error(){throw new Error("sign: Invalid signature produced")}async calc(){const{m:y,d:w,px:A,rand:_}=this,$=e.utils.taggedHash,H=this.initNonce(w,await $(Pt.aux,_)),{R:K,rx:q,k:z}=this.finalizeNonce(await $(Pt.nonce,H,A,y)),X=O(await $(Pt.challenge,q,A,y)),Z=this.finalizeSig(K,z,X,w);return await is(Z,y,A)||this.error(),Z}calcSync(){const{m:y,d:w,px:A,rand:_}=this,$=e.utils.taggedHashSync,H=this.initNonce(w,$(Pt.aux,_)),{R:K,rx:q,k:z}=this.finalizeNonce($(Pt.nonce,H,A,y)),X=O($(Pt.challenge,q,A,y)),Z=this.finalizeSig(K,z,X,w);return Zr(Z,y,A)||this.error(),Z}}async function le(b,y,w){return new ke(b,y,w).calc()}function ae(b,y,w){return new ke(b,y,w).calcSync()}function me(b,y,w){const A=b instanceof U,_=A?b:U.fromHex(b);return A&&_.assertValidity(),{..._,m:re(y),P:Lt(w)}}function bi(b,y,w,A){const _=V.BASE.multiplyAndAddUnsafe(y,nt(w),L(-A,a.n));return!(!_||!_.hasEvenY()||_.x!==b)}async function is(b,y,w){try{const{r:A,s:_,m:$,P:H}=me(b,y,w),K=O(await e.utils.taggedHash(Pt.challenge,ue(A),H.toRawX(),$));return bi(A,H,_,K)}catch{return!1}}function Zr(b,y,w){try{const{r:A,s:_,m:$,P:H}=me(b,y,w),K=O(e.utils.taggedHashSync(Pt.challenge,ue(A),H.toRawX(),$));return bi(A,H,_,K)}catch(A){if(A instanceof N)throw A;return!1}}e.schnorr={Signature:U,getPublicKey:ce,sign:le,verify:is,signSync:ae,verifySync:Zr},V.BASE._setWindowSize(8);const Ke={node:t,web:typeof self=="object"&&"crypto"in self?self.crypto:void 0},Pt={challenge:"BIP0340/challenge",aux:"BIP0340/aux",nonce:"BIP0340/nonce"},Qr={};e.utils={bytesToHex:F,hexToBytes:je,concatBytes:Ye,mod:L,invert:gt,isValidPrivateKey(b){try{return nt(b),!0}catch{return!1}},_bigintTo32Bytes:ue,_normalizePrivateKey:nt,hashToPrivateKey:b=>{b=re(b);const y=d+8;if(b.length<y||b.length>1024)throw new Error("Expected valid bytes of private key as per FIPS 186");const w=L(Ce(b),a.n-n)+n;return ue(w)},randomBytes:(b=32)=>{if(Ke.web)return Ke.web.getRandomValues(new Uint8Array(b));if(Ke.node){const{randomBytes:y}=Ke.node;return Uint8Array.from(y(b))}else throw new Error("The environment doesn't have randomBytes function")},randomPrivateKey:()=>e.utils.hashToPrivateKey(e.utils.randomBytes(d+8)),precompute(b=8,y=V.BASE){const w=y===V.BASE?y:new V(y.x,y.y);return w._setWindowSize(b),w.multiply(o),w},sha256:async(...b)=>{if(Ke.web){const y=await Ke.web.subtle.digest("SHA-256",Ye(...b));return new Uint8Array(y)}else if(Ke.node){const{createHash:y}=Ke.node,w=y("sha256");return b.forEach(A=>w.update(A)),Uint8Array.from(w.digest())}else throw new Error("The environment doesn't have sha256 function")},hmacSha256:async(b,...y)=>{if(Ke.web){const w=await Ke.web.subtle.importKey("raw",b,{name:"HMAC",hash:{name:"SHA-256"}},!1,["sign"]),A=Ye(...y),_=await Ke.web.subtle.sign("HMAC",w,A);return new Uint8Array(_)}else if(Ke.node){const{createHmac:w}=Ke.node,A=w("sha256",b);return y.forEach(_=>A.update(_)),Uint8Array.from(A.digest())}else throw new Error("The environment doesn't have hmac-sha256 function")},sha256Sync:void 0,hmacSha256Sync:void 0,taggedHash:async(b,...y)=>{let w=Qr[b];if(w===void 0){const A=await e.utils.sha256(Uint8Array.from(b,_=>_.charCodeAt(0)));w=Ye(A,A),Qr[b]=w}return e.utils.sha256(w,...y)},taggedHashSync:(b,...y)=>{if(typeof st!="function")throw new N("sha256Sync is undefined, you need to set it");let w=Qr[b];if(w===void 0){const A=st(Uint8Array.from(b,_=>_.charCodeAt(0)));w=Ye(A,A),Qr[b]=w}return st(w,...y)},_JacobianPoint:k},Object.defineProperties(e.utils,{sha256Sync:{configurable:!1,get(){return st},set(b){st||(st=b)}},hmacSha256Sync:{configurable:!1,get(){return Dt},set(b){Dt||(Dt=b)}}})})(Ph);var Oh={},Kr={};Object.defineProperty(Kr,"__esModule",{value:!0}),Kr.isBytes=Sy,Kr.number=Ic,Kr.bool=Ay,Kr.bytes=Ih,Kr.hash=Ty,Kr.exists=_y,Kr.output=ky;function Ic(e){if(!Number.isSafeInteger(e)||e<0)throw new Error(`positive integer expected, not ${e}`)}function Ay(e){if(typeof e!="boolean")throw new Error(`boolean expected, not ${e}`)}function Sy(e){return e instanceof Uint8Array||e!=null&&typeof e=="object"&&e.constructor.name==="Uint8Array"}function Ih(e,...t){if(!Sy(e))throw new Error("Uint8Array expected");if(t.length>0&&!t.includes(e.length))throw new Error(`Uint8Array expected of length ${t}, not of length=${e.length}`)}function Ty(e){if(typeof e!="function"||typeof e.create!="function")throw new Error("Hash should be wrapped by utils.wrapConstructor");Ic(e.outputLen),Ic(e.blockLen)}function _y(e,t=!0){if(e.destroyed)throw new Error("Hash instance has been destroyed");if(t&&e.finished)throw new Error("Hash#digest() has already been called")}function ky(e,t){Ih(e);const r=t.outputLen;if(e.length<r)throw new Error(`digestInto() expects output buffer of length at least ${r}`)}const dS={number:Ic,bool:Ay,bytes:Ih,hash:Ty,exists:_y,output:ky};Kr.default=dS;var Xo={},xc={};Object.defineProperty(xc,"__esModule",{value:!0}),xc.crypto=void 0,xc.crypto=typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0,function(e){/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */Object.defineProperty(e,"__esModule",{value:!0}),e.Hash=e.nextTick=e.byteSwapIfBE=e.byteSwap=e.isLE=e.rotl=e.rotr=e.createView=e.u32=e.u8=void 0,e.isBytes=n,e.byteSwap32=h,e.bytesToHex=g,e.hexToBytes=T,e.asyncLoop=N,e.utf8ToBytes=I,e.toBytes=k,e.concatBytes=B,e.checkOpts=Ue,e.wrapConstructor=Le,e.wrapConstructorWithOpts=Je,e.wrapXOFConstructorWithOpts=Fe,e.randomBytes=Ye;const t=xc,r=Kr;function n(C){return C instanceof Uint8Array||C!=null&&typeof C=="object"&&C.constructor.name==="Uint8Array"}const i=C=>new Uint8Array(C.buffer,C.byteOffset,C.byteLength);e.u8=i;const o=C=>new Uint32Array(C.buffer,C.byteOffset,Math.floor(C.byteLength/4));e.u32=o;const s=C=>new DataView(C.buffer,C.byteOffset,C.byteLength);e.createView=s;const a=(C,F)=>C<<32-F|C>>>F;e.rotr=a;const u=(C,F)=>C<<F|C>>>32-F>>>0;e.rotl=u,e.isLE=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;const f=C=>C<<24&4278190080|C<<8&16711680|C>>>8&65280|C>>>24&255;e.byteSwap=f,e.byteSwapIfBE=e.isLE?C=>C:C=>(0,e.byteSwap)(C);function h(C){for(let F=0;F<C.length;F++)C[F]=(0,e.byteSwap)(C[F])}const d=Array.from({length:256},(C,F)=>F.toString(16).padStart(2,"0"));function g(C){(0,r.bytes)(C);let F="";for(let oe=0;oe<C.length;oe++)F+=d[C[oe]];return F}const v={_0:48,_9:57,_A:65,_F:70,_a:97,_f:102};function E(C){if(C>=v._0&&C<=v._9)return C-v._0;if(C>=v._A&&C<=v._F)return C-(v._A-10);if(C>=v._a&&C<=v._f)return C-(v._a-10)}function T(C){if(typeof C!="string")throw new Error("hex string expected, got "+typeof C);const F=C.length,oe=F/2;if(F%2)throw new Error("padded hex string expected, got unpadded hex of length "+F);const J=new Uint8Array(oe);for(let ue=0,Ae=0;ue<oe;ue++,Ae+=2){const Et=E(C.charCodeAt(Ae)),je=E(C.charCodeAt(Ae+1));if(Et===void 0||je===void 0){const Ce=C[Ae]+C[Ae+1];throw new Error('hex string expected, got non-hex character "'+Ce+'" at index '+Ae)}J[ue]=Et*16+je}return J}const x=async()=>{};e.nextTick=x;async function N(C,F,oe){let J=Date.now();for(let ue=0;ue<C;ue++){oe(ue);const Ae=Date.now()-J;Ae>=0&&Ae<F||(await(0,e.nextTick)(),J+=Ae)}}function I(C){if(typeof C!="string")throw new Error(`utf8ToBytes expected string, got ${typeof C}`);return new Uint8Array(new TextEncoder().encode(C))}function k(C){return typeof C=="string"&&(C=I(C)),(0,r.bytes)(C),C}function B(...C){let F=0;for(let J=0;J<C.length;J++){const ue=C[J];(0,r.bytes)(ue),F+=ue.length}const oe=new Uint8Array(F);for(let J=0,ue=0;J<C.length;J++){const Ae=C[J];oe.set(Ae,ue),ue+=Ae.length}return oe}class W{clone(){return this._cloneInto()}}e.Hash=W;const V={}.toString;function Ue(C,F){if(F!==void 0&&V.call(F)!=="[object Object]")throw new Error("Options should be object or undefined");return Object.assign(C,F)}function Le(C){const F=J=>C().update(k(J)).digest(),oe=C();return F.outputLen=oe.outputLen,F.blockLen=oe.blockLen,F.create=()=>C(),F}function Je(C){const F=(J,ue)=>C(ue).update(k(J)).digest(),oe=C({});return F.outputLen=oe.outputLen,F.blockLen=oe.blockLen,F.create=J=>C(J),F}function Fe(C){const F=(J,ue)=>C(ue).update(k(J)).digest(),oe=C({});return F.outputLen=oe.outputLen,F.blockLen=oe.blockLen,F.create=J=>C(J),F}function Ye(C=32){if(t.crypto&&typeof t.crypto.getRandomValues=="function")return t.crypto.getRandomValues(new Uint8Array(C));if(t.crypto&&typeof t.crypto.randomBytes=="function")return t.crypto.randomBytes(C);throw new Error("crypto.getRandomValues must be defined")}}(Xo),function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.hmac=e.HMAC=void 0;const t=Kr,r=Xo;class n extends r.Hash{constructor(s,a){super(),this.finished=!1,this.destroyed=!1,(0,t.hash)(s);const u=(0,r.toBytes)(a);if(this.iHash=s.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 f=this.blockLen,h=new Uint8Array(f);h.set(u.length>f?s.create().update(u).digest():u);for(let d=0;d<h.length;d++)h[d]^=54;this.iHash.update(h),this.oHash=s.create();for(let d=0;d<h.length;d++)h[d]^=106;this.oHash.update(h),h.fill(0)}update(s){return(0,t.exists)(this),this.iHash.update(s),this}digestInto(s){(0,t.exists)(this),(0,t.bytes)(s,this.outputLen),this.finished=!0,this.iHash.digestInto(s),this.oHash.update(s),this.oHash.digestInto(s),this.destroy()}digest(){const s=new Uint8Array(this.oHash.outputLen);return this.digestInto(s),s}_cloneInto(s){s||(s=Object.create(Object.getPrototypeOf(this),{}));const{oHash:a,iHash:u,finished:f,destroyed:h,blockLen:d,outputLen:g}=this;return s=s,s.finished=f,s.destroyed=h,s.blockLen=d,s.outputLen=g,s.oHash=a._cloneInto(s.oHash),s.iHash=u._cloneInto(s.iHash),s}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}}e.HMAC=n;const i=(o,s,a)=>new n(o,s).update(a).digest();e.hmac=i,e.hmac.create=(o,s)=>new n(o,s)}(Oh);var Rn={},Ci={};Object.defineProperty(Ci,"__esModule",{value:!0}),Ci.HashMD=Ci.Maj=Ci.Chi=void 0;const xh=Kr,Jo=Xo;function pS(e,t,r,n){if(typeof e.setBigUint64=="function")return e.setBigUint64(t,r,n);const i=BigInt(32),o=BigInt(4294967295),s=Number(r>>i&o),a=Number(r&o),u=n?4:0,f=n?0:4;e.setUint32(t+u,s,n),e.setUint32(t+f,a,n)}const yS=(e,t,r)=>e&t^~e&r;Ci.Chi=yS;const gS=(e,t,r)=>e&t^e&r^t&r;Ci.Maj=gS;let wS=class extends Jo.Hash{constructor(t,r,n,i){super(),this.blockLen=t,this.outputLen=r,this.padOffset=n,this.isLE=i,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(t),this.view=(0,Jo.createView)(this.buffer)}update(t){(0,xh.exists)(this);const{view:r,buffer:n,blockLen:i}=this;t=(0,Jo.toBytes)(t);const o=t.length;for(let s=0;s<o;){const a=Math.min(i-this.pos,o-s);if(a===i){const u=(0,Jo.createView)(t);for(;i<=o-s;s+=i)this.process(u,s);continue}n.set(t.subarray(s,s+a),this.pos),this.pos+=a,s+=a,this.pos===i&&(this.process(r,0),this.pos=0)}return this.length+=t.length,this.roundClean(),this}digestInto(t){(0,xh.exists)(this),(0,xh.output)(t,this),this.finished=!0;const{buffer:r,view:n,blockLen:i,isLE:o}=this;let{pos:s}=this;r[s++]=128,this.buffer.subarray(s).fill(0),this.padOffset>i-s&&(this.process(n,0),s=0);for(let d=s;d<i;d++)r[d]=0;pS(n,i-8,BigInt(this.length*8),o),this.process(n,0);const a=(0,Jo.createView)(t),u=this.outputLen;if(u%4)throw new Error("_sha2: outputLen should be aligned to 32bit");const f=u/4,h=this.get();if(f>h.length)throw new Error("_sha2: outputLen bigger than state");for(let d=0;d<f;d++)a.setUint32(4*d,h[d],o)}digest(){const{buffer:t,outputLen:r}=this;this.digestInto(t);const n=t.slice(0,r);return this.destroy(),n}_cloneInto(t){t||(t=new this.constructor),t.set(...this.get());const{blockLen:r,buffer:n,length:i,finished:o,destroyed:s,pos:a}=this;return t.length=i,t.pos=a,t.finished=o,t.destroyed=s,i%r&&t.buffer.set(n),t}};Ci.HashMD=wS,Object.defineProperty(Rn,"__esModule",{value:!0}),Rn.sha224=Rn.sha256=Rn.SHA256=void 0;const $h=Ci,jr=Xo,bS=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]),Ni=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),Ui=new Uint32Array(64);let Ch=class extends $h.HashMD{constructor(){super(64,32,8,!1),this.A=Ni[0]|0,this.B=Ni[1]|0,this.C=Ni[2]|0,this.D=Ni[3]|0,this.E=Ni[4]|0,this.F=Ni[5]|0,this.G=Ni[6]|0,this.H=Ni[7]|0}get(){const{A:t,B:r,C:n,D:i,E:o,F:s,G:a,H:u}=this;return[t,r,n,i,o,s,a,u]}set(t,r,n,i,o,s,a,u){this.A=t|0,this.B=r|0,this.C=n|0,this.D=i|0,this.E=o|0,this.F=s|0,this.G=a|0,this.H=u|0}process(t,r){for(let d=0;d<16;d++,r+=4)Ui[d]=t.getUint32(r,!1);for(let d=16;d<64;d++){const g=Ui[d-15],v=Ui[d-2],E=(0,jr.rotr)(g,7)^(0,jr.rotr)(g,18)^g>>>3,T=(0,jr.rotr)(v,17)^(0,jr.rotr)(v,19)^v>>>10;Ui[d]=T+Ui[d-7]+E+Ui[d-16]|0}let{A:n,B:i,C:o,D:s,E:a,F:u,G:f,H:h}=this;for(let d=0;d<64;d++){const g=(0,jr.rotr)(a,6)^(0,jr.rotr)(a,11)^(0,jr.rotr)(a,25),v=h+g+(0,$h.Chi)(a,u,f)+bS[d]+Ui[d]|0,E=((0,jr.rotr)(n,2)^(0,jr.rotr)(n,13)^(0,jr.rotr)(n,22))+(0,$h.Maj)(n,i,o)|0;h=f,f=u,u=a,a=s+v|0,s=o,o=i,i=n,n=v+E|0}n=n+this.A|0,i=i+this.B|0,o=o+this.C|0,s=s+this.D|0,a=a+this.E|0,u=u+this.F|0,f=f+this.G|0,h=h+this.H|0,this.set(n,i,o,s,a,u,f,h)}roundClean(){Ui.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}};Rn.SHA256=Ch;let mS=class extends Ch{constructor(){super(),this.A=-1056596264,this.B=914150663,this.C=812702999,this.D=-150054599,this.E=-4191439,this.F=1750603025,this.G=1694076839,this.H=-1090891868,this.outputLen=28}};Rn.sha256=(0,jr.wrapConstructor)(()=>new Ch),Rn.sha224=(0,jr.wrapConstructor)(()=>new mS);var vS=Ph,ES=Oh,Py=Rn;function AS(e){var t=Object.create(null);return e&&Object.keys(e).forEach(function(r){if(r!=="default"){var n=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(t,r,n.get?n:{enumerable:!0,get:function(){return e[r]}})}}),t.default=e,Object.freeze(t)}var Re=AS(vS);const Ri="Expected Private",Bi="Expected Point",Yo="Expected Tweak",SS="Expected Hash",$c="Expected Signature",Nh="Expected Extra Data (32 bytes)",Zo="Expected Scalar",TS="Bad Recovery Id";Re.utils.hmacSha256Sync=(e,...t)=>ES.hmac(Py.sha256,e,Re.utils.concatBytes(...t)),Re.utils.sha256Sync=(...e)=>Py.sha256(Re.utils.concatBytes(...e));const Uh=Re.utils._normalizePrivateKey,_S=32,kS=32,Rh=new Uint8Array([255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,254,186,174,220,230,175,72,160,59,191,210,94,140,208,54,65,65]),PS=32,OS=new Uint8Array(32),IS=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,69,81,35,25,80,183,95,196,64,45,161,114,47,201,186,238]);function xS(e){return e instanceof Uint8Array}function Qo(e,t){for(let r=0;r<32;++r)if(e[r]!==t[r])return e[r]<t[r]?-1:1;return 0}function Oy(e){return Qo(e,OS)===0}function ea(e){return!(!(e instanceof Uint8Array)||e.length!==kS||Qo(e,Rh)>=0)}function Bh(e){return e instanceof Uint8Array&&e.length===64&&Qo(e.subarray(0,32),Rh)<0&&Qo(e.subarray(32,64),Rh)<0}function $S(e){return xS(e)&&e.length===64&&Qo(e.subarray(0,32),IS)<0}function CS(e){return!(Oy(e.subarray(0,32))||Oy(e.subarray(32,64)))}function Js(e){return e instanceof Uint8Array&&e.length===_S}function Hh(e){return e===void 0||e instanceof Uint8Array&&e.length===PS}function Iy(e){if(typeof e!="string")throw new TypeError("hexToNumber: expected string, got "+typeof e);return BigInt(`0x${e}`)}function NS(e){return Iy(Re.utils.bytesToHex(e))}function Lh(e){let t;if(typeof e=="bigint")t=e;else if(typeof e=="number"&&Number.isSafeInteger(e)&&e>=0)t=BigInt(e);else if(typeof e=="string"){if(e.length!==64)throw new Error("Expected 32 bytes of private scalar");t=Iy(e)}else if(e instanceof Uint8Array){if(e.length!==32)throw new Error("Expected 32 bytes of private scalar");t=NS(e)}else throw new TypeError("Expected valid private scalar");if(t<0)throw new Error("Expected private scalar >= 0");return t}const US=(e,t)=>{const r=Uh(e),n=Lh(t),i=Re.utils._bigintTo32Bytes(Re.utils.mod(r+n,Re.CURVE.n));return Re.utils.isValidPrivateKey(i)?i:null},RS=(e,t)=>{const r=Uh(e),n=Lh(t),i=Re.utils._bigintTo32Bytes(Re.utils.mod(r-n,Re.CURVE.n));return Re.utils.isValidPrivateKey(i)?i:null},BS=e=>{const t=Uh(e),r=Re.utils._bigintTo32Bytes(Re.CURVE.n-t);return Re.utils.isValidPrivateKey(r)?r:null},xy=(e,t,r)=>{const n=Re.Point.fromHex(e),i=Lh(t),o=Re.Point.BASE.multiplyAndAddUnsafe(n,i,BigInt(1));if(!o)throw new Error("Tweaked point at infinity");return o.toRawBytes(r)},HS=(e,t,r)=>{const n=Re.Point.fromHex(e),i=typeof t=="string"?t:Re.utils.bytesToHex(t),o=BigInt(`0x${i}`);return n.multiply(o).toRawBytes(r)};function Ys(e,t){return e===void 0?t!==void 0?$y(t):!0:!!e}function ps(e){try{return e()}catch{return null}}function Kh(e,t){if(e.length===32!==t)return!1;try{return!!Re.Point.fromHex(e)}catch{return!1}}function Hi(e){return Kh(e,!1)}function $y(e){return Kh(e,!1)&&e.length===33}function ri(e){return Re.utils.isValidPrivateKey(e)}function Cc(e){return Kh(e,!0)}function LS(e,t){if(!Cc(e))throw new Error(Bi);if(!ea(t))throw new Error(Yo);return ps(()=>{const r=xy(e,t,!0);return{parity:r[0]%2===1?1:0,xOnlyPubkey:r.slice(1)}})}function Cy(e){if(!Hi(e))throw new Error(Bi);return e.slice(1,33)}function Ny(e,t){if(!ri(e))throw new Error(Ri);return ps(()=>Re.getPublicKey(e,Ys(t)))}function KS(e){if(!ri(e))throw new Error(Ri);return Cy(Ny(e))}function jS(e,t){if(!Hi(e))throw new Error(Bi);return Re.Point.fromHex(e).toRawBytes(Ys(t,e))}function DS(e,t,r){if(!Hi(e))throw new Error(Bi);if(!ea(t))throw new Error(Yo);return ps(()=>HS(e,t,Ys(r,e)))}function MS(e,t,r){if(!Hi(e)||!Hi(t))throw new Error(Bi);return ps(()=>{const n=Re.Point.fromHex(e),i=Re.Point.fromHex(t);return n.equals(i.negate())?null:n.add(i).toRawBytes(Ys(r,e))})}function FS(e,t,r){if(!Hi(e))throw new Error(Bi);if(!ea(t))throw new Error(Yo);return ps(()=>xy(e,t,Ys(r,e)))}function VS(e,t){if(ri(e)===!1)throw new Error(Ri);if(ea(t)===!1)throw new Error(Yo);return ps(()=>US(e,t))}function zS(e,t){if(ri(e)===!1)throw new Error(Ri);if(ea(t)===!1)throw new Error(Yo);return ps(()=>RS(e,t))}function WS(e){if(ri(e)===!1)throw new Error(Ri);return BS(e)}function qS(e,t,r){if(!ri(t))throw new Error(Ri);if(!Js(e))throw new Error(Zo);if(!Hh(r))throw new Error(Nh);return Re.signSync(e,t,{der:!1,extraEntropy:r})}function GS(e,t,r){if(!ri(t))throw new Error(Ri);if(!Js(e))throw new Error(Zo);if(!Hh(r))throw new Error(Nh);const[n,i]=Re.signSync(e,t,{der:!1,extraEntropy:r,recovered:!0});return{signature:n,recoveryId:i}}function XS(e,t,r=Buffer.alloc(32,0)){if(!ri(t))throw new Error(Ri);if(!Js(e))throw new Error(Zo);if(!Hh(r))throw new Error(Nh);return Re.schnorr.signSync(e,t,r)}function JS(e,t,r,n){if(!Js(e))throw new Error(SS);if(!Bh(t)||!CS(t))throw new Error($c);if(r&2&&!$S(t))throw new Error(TS);if(!Cc(t.subarray(0,32)))throw new Error($c);return Re.recoverPublicKey(e,t,r,Ys(n))}function YS(e,t,r,n){if(!Hi(t))throw new Error(Bi);if(!Bh(r))throw new Error($c);if(!Js(e))throw new Error(Zo);return Re.verify(r,e,t,{strict:n})}function ZS(e,t,r){if(!Cc(t))throw new Error(Bi);if(!Bh(r))throw new Error($c);if(!Js(e))throw new Error(Zo);return Re.schnorr.verifySync(r,e,t)}var QS=ut.isPoint=Hi,e8=ut.isPointCompressed=$y,t8=ut.isPrivate=ri,r8=ut.isXOnlyPoint=Cc,n8=ut.pointAdd=MS,i8=ut.pointAddScalar=FS,s8=ut.pointCompress=jS,o8=ut.pointFromScalar=Ny,a8=ut.pointMultiply=DS,c8=ut.privateAdd=VS,u8=ut.privateNegate=WS,l8=ut.privateSub=zS,h8=ut.recover=JS,f8=ut.sign=qS,d8=ut.signRecoverable=GS,p8=ut.signSchnorr=XS,y8=ut.verify=YS,g8=ut.verifySchnorr=ZS,w8=ut.xOnlyPointAddTweak=LS,b8=ut.xOnlyPointFromPoint=Cy,m8=ut.xOnlyPointFromScalar=KS;yv(Qb({__proto__:null,default:ut,isPoint:QS,isPointCompressed:e8,isPrivate:t8,isXOnlyPoint:r8,pointAdd:n8,pointAddScalar:i8,pointCompress:s8,pointFromScalar:o8,pointMultiply:a8,privateAdd:c8,privateNegate:u8,privateSub:l8,recover:h8,sign:f8,signRecoverable:d8,signSchnorr:p8,verify:y8,verifySchnorr:g8,xOnlyPointAddTweak:w8,xOnlyPointFromPoint:b8,xOnlyPointFromScalar:m8},[ut]));const er=e=>e===it||e===Zt||e===Yt?um:sn,jh=e=>e.find(({purpose:t})=>t==="ordinals"),Dh=e=>e.find(({purpose:t})=>t==="payment"),zt=async(e,t)=>{try{const r=await Uy(e,t);return r?r.reduce((n,i)=>n+BigInt(i.value),0n):0n}catch(r){throw console.error("Error fetching BTC balance:",r),new Error("Failed to fetch BTC balance")}},v8=e=>/^(?:[A-Za-z0-9+\/]{4})*?(?:[A-Za-z0-9+\/]{2}==|[A-Za-z0-9+\/]{3}=)?$/.test(e),E8=e=>/^[a-fA-F0-9]+$/.test(e);function A8(e,t,r){const n=e*57+t*41,i=r*34;return 10+n+i}async function Uy(e,t){if(e.startsWith("t")){if(t===tt)return[];if(t===ls)return[];if(t===Qt)return[]}return await qe.get(`${ti(t)}/api/address/${e}/utxo`).then(r=>r.data)}async function Ry(e,t,r,n,i,o,s=7){const a=e===t,u=await Uy(t,o);if(!u)throw new Error("No UTXOs found");const f=u.sort((T,x)=>x.value-T.value),h=new ct({network:er(o)}),d=A8(1,0,2),g=Math.floor(d*s)+n;let v=0,E=0;for await(let T of f){const{txid:x,vout:N,value:I}=T,k=Lp(t,er(o));if(h.addInput({hash:x,index:N,witnessUtxo:{script:k,value:BigInt(I)}}),!a){const B=S8(i,o);h.updateInput(E,{redeemScript:B})}if(v+=I,v>=g)break}if(v<g)throw new Error("Insufficient funds");return h.addOutput({address:r,value:BigInt(n)}),v>g&&h.addOutput({address:t,value:BigInt(v-g)}),{psbtBase64:h.toBase64(),psbtHex:h.toHex()}}function S8(e,t){var r;const n=Ro({pubkey:my.Buffer.from(e,"hex"),network:er(t)}),i=Ks({redeem:n,network:er(t)});return(r=i==null?void 0:i.redeem)==null?void 0:r.output}let T8=class extends ln{constructor(){super(...arguments),de(this,"observer")}get library(){return window.unisat}get network(){return this.$network.get()}initialize(){typeof window<"u"&&typeof document<"u"&&(this.observer=new window.MutationObserver(()=>{var t;this.library&&(this.$store.setKey("hasProvider",{...this.$store.get().hasProvider,[zn]:!0}),(t=this.observer)==null||t.disconnect())}),this.observer.observe(document,{childList:!0,subtree:!0})),nn(this.$store,["provider"],t=>{if(t.provider!==zn){this.removeListeners();return}this.library.getAccounts().then(r=>{this.handleAccountsChanged(r)}),this.addListeners()})}addListeners(){this.library.on("accountsChanged",this.handleAccountsChanged.bind(this)),this.library.on("networkChanged",this.handleNetworkChanged.bind(this))}removeListeners(){this.library.removeListener("accountsChanged",this.handleAccountsChanged.bind(this)),this.library.removeListener("networkChanged",this.handleNetworkChanged.bind(this))}dispose(){var t;(t=this.observer)==null||t.disconnect(),this.removeListeners()}handleAccountsChanged(t){if(!t.length){this.parent.disconnect();return}this.$store.get().accounts[0]!==t[0]&&(this.$store.setKey("accounts",t),t.length>0?this.parent.connect(zn):this.parent.disconnect())}handleNetworkChanged(t){const r=zs(t);this.network!==r&&this.switchNetwork(r),this.parent.connect(zn)}async connect(t){if(!this.library)throw new Error("Unisat isn't installed");const r=await this.library.requestAccounts();if(!r)throw new Error("No accounts found");const n=await this.library.getPublicKey();if(!n)throw new Error("No public key found");this.$store.setKey("accounts",r),this.$store.setKey("address",r[0]),this.$store.setKey("paymentAddress",r[0]),this.$store.setKey("publicKey",n),this.$store.setKey("paymentPublicKey",n),this.$store.setKey("provider",zn),await this.getNetwork().then(i=>{var o;((o=this.config)==null?void 0:o.network)!==i&&this.switchNetwork(i)}),zt(r[0],this.network).then(i=>{this.$store.setKey("balance",i)}),this.$store.setKey("connected",!0)}async getNetwork(){var t;const r=await((t=this.library)==null?void 0:t.getChain());return r?zs(r.enum):this.network}async sendBTC(t,r){var n;const i=await((n=this.library)==null?void 0:n.sendBitcoin(t,r));if(!i)throw new Error("Transaction failed");return i}async signMessage(t,r){var n;return await((n=this.library)==null?void 0:n.signMessage(t))}async signPsbt(t,r,n,i,o){var s;const a=await((s=this.library)==null?void 0:s.signPsbt(r,{autoFinalized:i})),u=ct.fromHex(a);if(i&&o){const f=await this.pushPsbt(a);return{signedPsbtHex:u.toHex(),signedPsbtBase64:u.toBase64(),txId:f}}return{signedPsbtHex:u.toHex(),signedPsbtBase64:u.toBase64(),txId:void 0}}async pushPsbt(t){return await qe.post(`${ti(this.network)}/api/tx`,t).then(r=>r.data)}async getPublicKey(){var t;return await((t=this.library)==null?void 0:t.getPublicKey())}async getBalance(){return(await this.library.getBalance()).total}async getInscriptions(){return await this.library.getInscriptions(0,10)}async requestAccounts(){return await this.library.requestAccounts()}async switchNetwork(t){var r;const n=mc(t);await((r=this.library)==null?void 0:r.switchChain(n)),this.$network.set(t),await this.getBalance()}};function _8(){typeof window<"u"&&typeof localStorage<"u"&&setTimeout(()=>{const e=document.createTextNode(" ");document.body.appendChild(e),e.remove()},1500)}function k8(){return{$store:Rd({provider:void 0,address:"",paymentAddress:"",publicKey:"",paymentPublicKey:"",connected:!1,isConnecting:!1,isInitializing:!0,accounts:[],balance:void 0,hasProvider:{[zn]:!1,[In]:!1,[vi]:!1,[Wn]:!1,[Ti]:!1,[ss]:!1,[Ai]:!1,[Ei]:!1,[os]:!1,[Si]:!1}}),$network:yl(tt),$library:yl(void 0)}}function P8({network:e}){return{network:e}}function l9(e){}function h9(e){}function O8(e,t){var r;return(r=void 0)==null?void 0:r.get(t)}function Nc(e){var t,r;let n=typeof e;return n==="object"&&(n=(e&&((r=(t=Object.getPrototypeOf(e))==null?void 0:t.constructor)==null?void 0:r.name))??"null"),n==="string"?`"${e}"`:n==="number"||n==="bigint"||n==="boolean"?`${e}`:n}function fr(e,t,r,n,i){const o=i&&"input"in i?i.input:r.value,s=(i==null?void 0:i.expected)??e.expects??null,a=(i==null?void 0:i.received)??Nc(o),u={kind:e.kind,type:e.type,input:o,expected:s,received:a,message:`Invalid ${t}: ${s?`Expected ${s} but r`:"R"}eceived ${a}`,requirement:e.requirement,path:i==null?void 0:i.path,issues:i==null?void 0:i.issues,lang:n.lang,abortEarly:n.abortEarly,abortPipeEarly:n.abortPipeEarly},f=e.kind==="schema",h=(i==null?void 0:i.message)??e.message??O8(e.reference,u.lang)??(f?(u.lang,void 0):null)??n.message??(u.lang,void 0);h&&(u.message=typeof h=="function"?h(u):h),f&&(r.typed=!1),r.issues?r.issues.push(u):r.issues=[u]}function I8(e,t){return Object.hasOwn(e,t)&&t!=="__proto__"&&t!=="prototype"&&t!=="constructor"}function By(e,t,r){return typeof e.default=="function"?e.default(t,r):e.default}function Hy(e,t){return!e._run({typed:!1,value:t},{abortEarly:!0}).issues}function fn(e,t){return{kind:"schema",type:"array",reference:fn,expects:"Array",async:!1,item:e,message:t,_run(r,n){var i;const o=r.value;if(Array.isArray(o)){r.typed=!0,r.value=[];for(let s=0;s<o.length;s++){const a=o[s],u=this.item._run({typed:!1,value:a},n);if(u.issues){const f={type:"array",origin:"value",input:o,key:s,value:a};for(const h of u.issues)h.path?h.path.unshift(f):h.path=[f],(i=r.issues)==null||i.push(h);if(r.issues||(r.issues=u.issues),n.abortEarly){r.typed=!1;break}}u.typed||(r.typed=!1),r.value.push(u.value)}}else fr(this,"type",r,n);return r}}}function Ly(e){return{kind:"schema",type:"boolean",reference:Ly,expects:"boolean",async:!1,message:e,_run(t,r){return typeof t.value=="boolean"?t.typed=!0:fr(this,"type",t,r),t}}}function ys(e,t){const r=Object.entries(e).filter(([n])=>isNaN(+n)).map(([,n])=>n);return{kind:"schema",type:"enum",reference:ys,expects:r.map(Nc).join(" | ")||"never",async:!1,enum:e,options:r,message:t,_run(n,i){return this.options.includes(n.value)?n.typed=!0:fr(this,"type",n,i),n}}}function lt(e,t){return{kind:"schema",type:"literal",reference:lt,expects:Nc(e),async:!1,literal:e,message:t,_run(r,n){return r.value===this.literal?r.typed=!0:fr(this,"type",r,n),r}}}function Ky(e,t){return{kind:"schema",type:"loose_object",reference:Ky,expects:"Object",async:!1,entries:e,message:t,_run(r,n){var i;const o=r.value;if(o&&typeof o=="object"){r.typed=!0,r.value={};for(const s in this.entries){const a=o[s],u=this.entries[s]._run({typed:!1,value:a},n);if(u.issues){const f={type:"object",origin:"value",input:o,key:s,value:a};for(const h of u.issues)h.path?h.path.unshift(f):h.path=[f],(i=r.issues)==null||i.push(h);if(r.issues||(r.issues=u.issues),n.abortEarly){r.typed=!1;break}}u.typed||(r.typed=!1),(u.value!==void 0||s in o)&&(r.value[s]=u.value)}if(!r.issues||!n.abortEarly)for(const s in o)I8(o,s)&&!(s in this.entries)&&(r.value[s]=o[s])}else fr(this,"type",r,n);return r}}}function Mh(e,t){return{kind:"schema",type:"non_optional",reference:Mh,expects:"!undefined",async:!1,wrapped:e,message:t,_run(r,n){return r.value===void 0?(fr(this,"type",r,n),r):this.wrapped._run(r,n)}}}function gs(e){return{kind:"schema",type:"null",reference:gs,expects:"null",async:!1,message:e,_run(t,r){return t.value===null?t.typed=!0:fr(this,"type",t,r),t}}}function ws(e,...t){const r={kind:"schema",type:"nullish",reference:ws,expects:`${e.expects} | null | undefined`,async:!1,wrapped:e,_run(n,i){return(n.value===null||n.value===void 0)&&("default"in this&&(n.value=By(this,n,i)),n.value===null||n.value===void 0)?(n.typed=!0,n):this.wrapped._run(n,i)}};return 0 in t&&(r.default=t[0]),r}function Bn(e){return{kind:"schema",type:"number",reference:Bn,expects:"number",async:!1,message:e,_run(t,r){return typeof t.value=="number"&&!isNaN(t.value)?t.typed=!0:fr(this,"type",t,r),t}}}function he(e,t){return{kind:"schema",type:"object",reference:he,expects:"Object",async:!1,entries:e,message:t,_run(r,n){var i;const o=r.value;if(o&&typeof o=="object"){r.typed=!0,r.value={};for(const s in this.entries){const a=o[s],u=this.entries[s]._run({typed:!1,value:a},n);if(u.issues){const f={type:"object",origin:"value",input:o,key:s,value:a};for(const h of u.issues)h.path?h.path.unshift(f):h.path=[f],(i=r.issues)==null||i.push(h);if(r.issues||(r.issues=u.issues),n.abortEarly){r.typed=!1;break}}u.typed||(r.typed=!1),(u.value!==void 0||s in o)&&(r.value[s]=u.value)}}else fr(this,"type",r,n);return r}}}function dn(e,...t){const r={kind:"schema",type:"optional",reference:dn,expects:`${e.expects} | undefined`,async:!1,wrapped:e,_run(n,i){return n.value===void 0&&("default"in this&&(n.value=By(this,n,i)),n.value===void 0)?(n.typed=!0,n):this.wrapped._run(n,i)}};return 0 in t&&(r.default=t[0]),r}function jy(e,t){return{kind:"schema",type:"picklist",reference:jy,expects:e.map(Nc).join(" | ")||"never",async:!1,options:e,message:t,_run(r,n){return this.options.includes(r.value)?r.typed=!0:fr(this,"type",r,n),r}}}function ye(e){return{kind:"schema",type:"string",reference:ye,expects:"string",async:!1,message:e,_run(t,r){return typeof t.value=="string"?t.typed=!0:fr(this,"type",t,r),t}}}function Fh(e){return{kind:"schema",type:"undefined",reference:Fh,expects:"undefined",async:!1,message:e,_run(t,r){return t.value===void 0?t.typed=!0:fr(this,"type",t,r),t}}}function Dy(e){let t;if(e)for(const r of e)t?t.push(...r.issues):t=r.issues;return t}function Uc(e,t){return{kind:"schema",type:"union",reference:Uc,expects:[...new Set(e.map(r=>r.expects))].join(" | ")||"never",async:!1,options:e,message:t,_run(r,n){let i,o,s;for(const a of this.options){const u=a._run({typed:!1,value:r.value},n);if(u.typed)if(u.issues)o?o.push(u):o=[u];else{i=u;break}else s?s.push(u):s=[u]}if(i)return i;if(o){if(o.length===1)return o[0];fr(this,"type",r,n,{issues:Dy(o)}),r.typed=!0}else{if((s==null?void 0:s.length)===1)return s[0];fr(this,"type",r,n,{issues:Dy(s)})}return r}}}function Rc(){return{kind:"schema",type:"unknown",reference:Rc,expects:"unknown",async:!1,_run(e){return e.typed=!0,e}}}var Dr={},Zs={},tr={};Object.defineProperty(tr,"__esModule",{value:!0}),tr.decode=tr.encode=tr.unescape=tr.escape=tr.pad=void 0;const My=Gs;function Vh(e){return`${e}${"=".repeat(4-(e.length%4||4))}`}tr.pad=Vh;function Fy(e){return e.replace(/=/g,"").replace(/\+/g,"-").replace(/\//g,"_")}tr.escape=Fy;function Vy(e){return Vh(e).replace(/-/g,"+").replace(/_/g,"/")}tr.unescape=Vy;function x8(e){return Fy((0,My.fromByteArray)(new TextEncoder().encode(e)))}tr.encode=x8;function $8(e){return new TextDecoder().decode((0,My.toByteArray)(Vh(Vy(e))))}tr.decode=$8;var Bc={},Hc={},Qs={};Object.defineProperty(Qs,"__esModule",{value:!0}),Qs.joseToDer=Qs.derToJose=void 0;const zy=Gs,Wy=tr;function zh(e){return(e/8|0)+(e%8===0?0:1)}const C8={ES256:zh(256),ES384:zh(384),ES512:zh(521)};function qy(e){const t=C8[e];if(t)return t;throw new Error(`Unknown algorithm "${e}"`)}const Lc=128,Gy=0,N8=32,U8=16,R8=2,Xy=U8|N8|Gy<<6,Kc=R8|Gy<<6;function Jy(e){if(e instanceof Uint8Array)return e;if(typeof e=="string")return(0,zy.toByteArray)((0,Wy.pad)(e));throw new TypeError("ECDSA signature must be a Base64 string or a Uint8Array")}function B8(e,t){const r=Jy(e),n=qy(t),i=n+1,o=r.length;let s=0;if(r[s++]!==Xy)throw new Error('Could not find expected "seq"');let a=r[s++];if(a===(Lc|1)&&(a=r[s++]),o-s<a)throw new Error(`"seq" specified length of "${a}", only "${o-s}" remaining`);if(r[s++]!==Kc)throw new Error('Could not find expected "int" for "r"');const u=r[s++];if(o-s-2<u)throw new Error(`"r" specified length of "${u}", only "${o-s-2}" available`);if(i<u)throw new Error(`"r" specified length of "${u}", max of "${i}" is acceptable`);const f=s;if(s+=u,r[s++]!==Kc)throw new Error('Could not find expected "int" for "s"');const h=r[s++];if(o-s!==h)throw new Error(`"s" specified length of "${h}", expected "${o-s}"`);if(i<h)throw new Error(`"s" specified length of "${h}", max of "${i}" is acceptable`);const d=s;if(s+=h,s!==o)throw new Error(`Expected to consume entire array, but "${o-s}" bytes remain`);const g=n-u,v=n-h,E=new Uint8Array(g+u+v+h);for(s=0;s<g;++s)E[s]=0;E.set(r.subarray(f+Math.max(-g,0),f+u),s),s=n;for(const T=s;s<T+v;++s)E[s]=0;return E.set(r.subarray(d+Math.max(-v,0),d+h),s),(0,Wy.escape)((0,zy.fromByteArray)(E))}Qs.derToJose=B8;function Yy(e,t,r){let n=0;for(;t+n<r&&e[t+n]===0;)++n;return e[t+n]>=Lc&&--n,n}function H8(e,t){e=Jy(e);const r=qy(t),n=e.length;if(n!==r*2)throw new TypeError(`"${t}" signatures must be "${r*2}" bytes, saw "${n}"`);const i=Yy(e,0,r),o=Yy(e,r,e.length),s=r-i,a=r-o,u=2+s+1+1+a,f=u<Lc,h=new Uint8Array((f?2:3)+u);let d=0;return h[d++]=Xy,f?h[d++]=u:(h[d++]=Lc|1,h[d++]=u&255),h[d++]=Kc,h[d++]=s,i<0?(h[d++]=0,h.set(e.subarray(0,r),d),d+=r):(h.set(e.subarray(i,r),d),d+=r-i),h[d++]=Kc,h[d++]=a,o<0?(h[d++]=0,h.set(e.subarray(r),d)):h.set(e.subarray(r+o),d),h}Qs.joseToDer=H8;var ni={};Object.defineProperty(ni,"__esModule",{value:!0}),ni.InvalidTokenError=ni.MissingParametersError=void 0;class L8 extends Error{constructor(t){super(),this.name="MissingParametersError",this.message=t||""}}ni.MissingParametersError=L8;class K8 extends Error{constructor(t){super(),this.name="InvalidTokenError",this.message=t||""}}ni.InvalidTokenError=K8,Object.defineProperty(Hc,"__esModule",{value:!0}),Hc.SECP256K1Client=void 0;const j8=Oh,D8=Rn,jc=Ph,Zy=Qs,Qy=ni,eg=Xo;jc.utils.hmacSha256Sync=(e,...t)=>{const r=j8.hmac.create(D8.sha256,e);return t.forEach(n=>r.update(n)),r.digest()};let tg=class{static derivePublicKey(t,r=!0){return t.length===66&&(t=t.slice(0,64)),t.length<64&&(t=t.padStart(64,"0")),(0,eg.bytesToHex)(jc.getPublicKey(t,r))}static signHash(t,r,n="jose"){if(!t||!r)throw new Qy.MissingParametersError("a signing input hash and private key are all required");const i=jc.signSync(t,r.slice(0,64),{der:!0,canonical:!1});if(n==="der")return(0,eg.bytesToHex)(i);if(n==="jose")return(0,Zy.derToJose)(i,"ES256");throw Error("Invalid signature format")}static loadSignature(t){return(0,Zy.joseToDer)(t,"ES256")}static verifyHash(t,r,n){if(!t||!r||!n)throw new Qy.MissingParametersError("a signing input hash, der signature, and public key are all required");return jc.verify(r,t,n,{strict:!1})}};Hc.SECP256K1Client=tg,tg.algorithmName="ES256K",function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.cryptoClients=e.SECP256K1Client=void 0;const t=Hc;Object.defineProperty(e,"SECP256K1Client",{enumerable:!0,get:function(){return t.SECP256K1Client}});const r={ES256K:t.SECP256K1Client};e.cryptoClients=r}(Bc);var bs={},M8=Se&&Se.__awaiter||function(e,t,r,n){function i(o){return o instanceof r?o:new r(function(s){s(o)})}return new(r||(r=Promise))(function(o,s){function a(h){try{f(n.next(h))}catch(d){s(d)}}function u(h){try{f(n.throw(h))}catch(d){s(d)}}function f(h){h.done?o(h.value):i(h.value).then(a,u)}f((n=n.apply(e,t||[])).next())})};Object.defineProperty(bs,"__esModule",{value:!0}),bs.hashSha256Async=bs.hashSha256=void 0;const F8=Rn;function rg(e){return(0,F8.sha256)(e)}bs.hashSha256=rg;function V8(e){return M8(this,void 0,void 0,function*(){try{if(typeof crypto<"u"&&typeof crypto.subtle<"u"){const t=typeof e=="string"?new TextEncoder().encode(e):e,r=yield crypto.subtle.digest("SHA-256",t);return new Uint8Array(r)}else{const t=Ey;if(!t.createHash)throw new Error("`crypto` module does not contain `createHash`");return Promise.resolve(t.createHash("sha256").update(e).digest())}}catch(t){return console.log(t),console.log('Crypto lib not found. Neither the global `crypto.subtle` Web Crypto API, nor the or the Node.js `require("crypto").createHash` module is available. Falling back to JS implementation.'),Promise.resolve(rg(e))}})}bs.hashSha256Async=V8;var z8=Se&&Se.__awaiter||function(e,t,r,n){function i(o){return o instanceof r?o:new r(function(s){s(o)})}return new(r||(r=Promise))(function(o,s){function a(h){try{f(n.next(h))}catch(d){s(d)}}function u(h){try{f(n.throw(h))}catch(d){s(d)}}function f(h){h.done?o(h.value):i(h.value).then(a,u)}f((n=n.apply(e,t||[])).next())})};Object.defineProperty(Zs,"__esModule",{value:!0}),Zs.TokenSigner=Zs.createUnsecuredToken=void 0;const Wh=tr,ng=Bc,W8=ni,ig=bs;function qh(e,t){const r=[],n=Wh.encode(JSON.stringify(t));r.push(n);const i=Wh.encode(JSON.stringify(e));return r.push(i),r.join(".")}function q8(e){return qh(e,{typ:"JWT",alg:"none"})+"."}Zs.createUnsecuredToken=q8;class G8{constructor(t,r){if(!(t&&r))throw new W8.MissingParametersError("a signing algorithm and private key are required");if(typeof t!="string")throw new Error("signing algorithm parameter must be a string");if(t=t.toUpperCase(),!ng.cryptoClients.hasOwnProperty(t))throw new Error("invalid signing algorithm");this.tokenType="JWT",this.cryptoClient=ng.cryptoClients[t],this.rawPrivateKey=r}header(t={}){const r={typ:this.tokenType,alg:this.cryptoClient.algorithmName};return Object.assign({},r,t)}sign(t,r=!1,n={}){const i=this.header(n),o=qh(t,i),s=(0,ig.hashSha256)(o);return this.createWithSignedHash(t,r,i,o,s)}signAsync(t,r=!1,n={}){return z8(this,void 0,void 0,function*(){const i=this.header(n),o=qh(t,i),s=yield(0,ig.hashSha256Async)(o);return this.createWithSignedHash(t,r,i,o,s)})}createWithSignedHash(t,r,n,i,o){const s=this.cryptoClient.signHash(o,this.rawPrivateKey);return r?{header:[Wh.encode(JSON.stringify(n))],payload:JSON.stringify(t),signature:[s]}:[i,s].join(".")}}Zs.TokenSigner=G8;var Dc={};Object.defineProperty(Dc,"__esModule",{value:!0}),Dc.TokenVerifier=void 0;const X8=tr,sg=Bc,J8=ni,Mc=bs;class Y8{constructor(t,r){if(!(t&&r))throw new J8.MissingParametersError("a signing algorithm and public key are required");if(typeof t!="string")throw"signing algorithm parameter must be a string";if(t=t.toUpperCase(),!sg.cryptoClients.hasOwnProperty(t))throw"invalid signing algorithm";this.tokenType="JWT",this.cryptoClient=sg.cryptoClients[t],this.rawPublicKey=r}verify(t){return typeof t=="string"?this.verifyCompact(t,!1):typeof t=="object"?this.verifyExpanded(t,!1):!1}verifyAsync(t){return typeof t=="string"?this.verifyCompact(t,!0):typeof t=="object"?this.verifyExpanded(t,!0):Promise.resolve(!1)}verifyCompact(t,r){const n=t.split("."),i=n[0]+"."+n[1],o=s=>{const a=this.cryptoClient.loadSignature(n[2]);return this.cryptoClient.verifyHash(s,a,this.rawPublicKey)};if(r)return(0,Mc.hashSha256Async)(i).then(s=>o(s));{const s=(0,Mc.hashSha256)(i);return o(s)}}verifyExpanded(t,r){const n=[t.header.join("."),X8.encode(t.payload)].join(".");let i=!0;const o=s=>(t.signature.map(a=>{const u=this.cryptoClient.loadSignature(a);this.cryptoClient.verifyHash(s,u,this.rawPublicKey)||(i=!1)}),i);if(r)return(0,Mc.hashSha256Async)(n).then(s=>o(s));{const s=(0,Mc.hashSha256)(n);return o(s)}}}Dc.TokenVerifier=Y8;var Fc={};Object.defineProperty(Fc,"__esModule",{value:!0}),Fc.decodeToken=void 0;const Vc=tr;function Z8(e){if(typeof e=="string"){const t=e.split("."),r=JSON.parse(Vc.decode(t[0])),n=JSON.parse(Vc.decode(t[1])),i=t[2];return{header:r,payload:n,signature:i}}else if(typeof e=="object"){if(typeof e.payload!="string")throw new Error("Expected token payload to be a base64 or json string");let t=e.payload;e.payload[0]!=="{"&&(t=Vc.decode(t));const r=[];return e.header.map(n=>{const i=JSON.parse(Vc.decode(n));r.push(i)}),{header:r,payload:JSON.parse(t),signature:e.signature}}}Fc.decodeToken=Z8,function(e){var t=Se&&Se.__createBinding||(Object.create?function(n,i,o,s){s===void 0&&(s=o);var a=Object.getOwnPropertyDescriptor(i,o);(!a||("get"in a?!i.__esModule:a.writable||a.configurable))&&(a={enumerable:!0,get:function(){return i[o]}}),Object.defineProperty(n,s,a)}:function(n,i,o,s){s===void 0&&(s=o),n[s]=i[o]}),r=Se&&Se.__exportStar||function(n,i){for(var o in n)o!=="default"&&!Object.prototype.hasOwnProperty.call(i,o)&&t(i,n,o)};Object.defineProperty(e,"__esModule",{value:!0}),r(Zs,e),r(Dc,e),r(Fc,e),r(ni,e),r(Bc,e)}(Dr);/*! *****************************************************************************
17
17
  Copyright (c) Microsoft Corporation.
18
18
 
19
19
  Permission to use, copy, modify, and/or distribute this software for any
@@ -41,7 +41,7 @@ PROCEED WITH CAUTION!
41
41
  *
42
42
  * @author Feross Aboukhadijeh <https://feross.org>
43
43
  * @license MIT
44
- */(function(e){const t=go,r=sd,n=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):null;e.Buffer=a,e.SlowBuffer=I,e.INSPECT_MAX_BYTES=50;const i=2147483647;e.kMaxLength=i,a.TYPED_ARRAY_SUPPORT=o(),!a.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 o(){try{const c=new Uint8Array(1),l={foo:function(){return 42}};return Object.setPrototypeOf(l,Uint8Array.prototype),Object.setPrototypeOf(c,l),c.foo()===42}catch{return!1}}Object.defineProperty(a.prototype,"parent",{enumerable:!0,get:function(){if(a.isBuffer(this))return this.buffer}}),Object.defineProperty(a.prototype,"offset",{enumerable:!0,get:function(){if(a.isBuffer(this))return this.byteOffset}});function s(c){if(c>i)throw new RangeError('The value "'+c+'" is invalid for option "size"');const l=new Uint8Array(c);return Object.setPrototypeOf(l,a.prototype),l}function a(c,l,p){if(typeof c=="number"){if(typeof l=="string")throw new TypeError('The "string" argument must be of type string. Received type number');return d(c)}return u(c,l,p)}a.poolSize=8192;function u(c,l,p){if(typeof c=="string")return g(c,l);if(ArrayBuffer.isView(c))return E(c);if(c==null)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof c);if(ze(c,ArrayBuffer)||c&&ze(c.buffer,ArrayBuffer)||typeof SharedArrayBuffer<"u"&&(ze(c,SharedArrayBuffer)||c&&ze(c.buffer,SharedArrayBuffer)))return T(c,l,p);if(typeof c=="number")throw new TypeError('The "value" argument must not be of type number. Received type number');const m=c.valueOf&&c.valueOf();if(m!=null&&m!==c)return a.from(m,l,p);const S=x(c);if(S)return S;if(typeof Symbol<"u"&&Symbol.toPrimitive!=null&&typeof c[Symbol.toPrimitive]=="function")return a.from(c[Symbol.toPrimitive]("string"),l,p);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof c)}a.from=function(c,l,p){return u(c,l,p)},Object.setPrototypeOf(a.prototype,Uint8Array.prototype),Object.setPrototypeOf(a,Uint8Array);function f(c){if(typeof c!="number")throw new TypeError('"size" argument must be of type number');if(c<0)throw new RangeError('The value "'+c+'" is invalid for option "size"')}function h(c,l,p){return f(c),c<=0?s(c):l!==void 0?typeof p=="string"?s(c).fill(l,p):s(c).fill(l):s(c)}a.alloc=function(c,l,p){return h(c,l,p)};function d(c){return f(c),s(c<0?0:N(c)|0)}a.allocUnsafe=function(c){return d(c)},a.allocUnsafeSlow=function(c){return d(c)};function g(c,l){if((typeof l!="string"||l==="")&&(l="utf8"),!a.isEncoding(l))throw new TypeError("Unknown encoding: "+l);const p=k(c,l)|0;let m=s(p);const S=m.write(c,l);return S!==p&&(m=m.slice(0,S)),m}function v(c){const l=c.length<0?0:N(c.length)|0,p=s(l);for(let m=0;m<l;m+=1)p[m]=c[m]&255;return p}function E(c){if(ze(c,Uint8Array)){const l=new Uint8Array(c);return T(l.buffer,l.byteOffset,l.byteLength)}return v(c)}function T(c,l,p){if(l<0||c.byteLength<l)throw new RangeError('"offset" is outside of buffer bounds');if(c.byteLength<l+(p||0))throw new RangeError('"length" is outside of buffer bounds');let m;return l===void 0&&p===void 0?m=new Uint8Array(c):p===void 0?m=new Uint8Array(c,l):m=new Uint8Array(c,l,p),Object.setPrototypeOf(m,a.prototype),m}function x(c){if(a.isBuffer(c)){const l=N(c.length)|0,p=s(l);return p.length===0||c.copy(p,0,0,l),p}if(c.length!==void 0)return typeof c.length!="number"||sr(c.length)?s(0):v(c);if(c.type==="Buffer"&&Array.isArray(c.data))return v(c.data)}function N(c){if(c>=i)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+i.toString(16)+" bytes");return c|0}function I(c){return+c!=c&&(c=0),a.alloc(+c)}a.isBuffer=function(c){return c!=null&&c._isBuffer===!0&&c!==a.prototype},a.compare=function(c,l){if(ze(c,Uint8Array)&&(c=a.from(c,c.offset,c.byteLength)),ze(l,Uint8Array)&&(l=a.from(l,l.offset,l.byteLength)),!a.isBuffer(c)||!a.isBuffer(l))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(c===l)return 0;let p=c.length,m=l.length;for(let S=0,O=Math.min(p,m);S<O;++S)if(c[S]!==l[S]){p=c[S],m=l[S];break}return p<m?-1:m<p?1:0},a.isEncoding=function(c){switch(String(c).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}},a.concat=function(c,l){if(!Array.isArray(c))throw new TypeError('"list" argument must be an Array of Buffers');if(c.length===0)return a.alloc(0);let p;if(l===void 0)for(l=0,p=0;p<c.length;++p)l+=c[p].length;const m=a.allocUnsafe(l);let S=0;for(p=0;p<c.length;++p){let O=c[p];if(ze(O,Uint8Array))S+O.length>m.length?(a.isBuffer(O)||(O=a.from(O)),O.copy(m,S)):Uint8Array.prototype.set.call(m,O,S);else if(a.isBuffer(O))O.copy(m,S);else throw new TypeError('"list" argument must be an Array of Buffers');S+=O.length}return m};function k(c,l){if(a.isBuffer(c))return c.length;if(ArrayBuffer.isView(c)||ze(c,ArrayBuffer))return c.byteLength;if(typeof c!="string")throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof c);const p=c.length,m=arguments.length>2&&arguments[2]===!0;if(!m&&p===0)return 0;let S=!1;for(;;)switch(l){case"ascii":case"latin1":case"binary":return p;case"utf8":case"utf-8":return Lt(c).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return p*2;case"hex":return p>>>1;case"base64":return On(c).length;default:if(S)return m?-1:Lt(c).length;l=(""+l).toLowerCase(),S=!0}}a.byteLength=k;function B(c,l,p){let m=!1;if((l===void 0||l<0)&&(l=0),l>this.length||((p===void 0||p>this.length)&&(p=this.length),p<=0)||(p>>>=0,l>>>=0,p<=l))return"";for(c||(c="utf8");;)switch(c){case"hex":return je(this,l,p);case"utf8":case"utf-8":return oe(this,l,p);case"ascii":return Ae(this,l,p);case"latin1":case"binary":return Et(this,l,p);case"base64":return F(this,l,p);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return Ce(this,l,p);default:if(m)throw new TypeError("Unknown encoding: "+c);c=(c+"").toLowerCase(),m=!0}}a.prototype._isBuffer=!0;function W(c,l,p){const m=c[l];c[l]=c[p],c[p]=m}a.prototype.swap16=function(){const c=this.length;if(c%2!==0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(let l=0;l<c;l+=2)W(this,l,l+1);return this},a.prototype.swap32=function(){const c=this.length;if(c%4!==0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(let l=0;l<c;l+=4)W(this,l,l+3),W(this,l+1,l+2);return this},a.prototype.swap64=function(){const c=this.length;if(c%8!==0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(let l=0;l<c;l+=8)W(this,l,l+7),W(this,l+1,l+6),W(this,l+2,l+5),W(this,l+3,l+4);return this},a.prototype.toString=function(){const c=this.length;return c===0?"":arguments.length===0?oe(this,0,c):B.apply(this,arguments)},a.prototype.toLocaleString=a.prototype.toString,a.prototype.equals=function(c){if(!a.isBuffer(c))throw new TypeError("Argument must be a Buffer");return this===c?!0:a.compare(this,c)===0},a.prototype.inspect=function(){let c="";const l=e.INSPECT_MAX_BYTES;return c=this.toString("hex",0,l).replace(/(.{2})/g,"$1 ").trim(),this.length>l&&(c+=" ... "),"<Buffer "+c+">"},n&&(a.prototype[n]=a.prototype.inspect),a.prototype.compare=function(c,l,p,m,S){if(ze(c,Uint8Array)&&(c=a.from(c,c.offset,c.byteLength)),!a.isBuffer(c))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof c);if(l===void 0&&(l=0),p===void 0&&(p=c?c.length:0),m===void 0&&(m=0),S===void 0&&(S=this.length),l<0||p>c.length||m<0||S>this.length)throw new RangeError("out of range index");if(m>=S&&l>=p)return 0;if(m>=S)return-1;if(l>=p)return 1;if(l>>>=0,p>>>=0,m>>>=0,S>>>=0,this===c)return 0;let O=S-m,U=p-l;const ce=Math.min(O,U),ke=this.slice(m,S),le=c.slice(l,p);for(let ae=0;ae<ce;++ae)if(ke[ae]!==le[ae]){O=ke[ae],U=le[ae];break}return O<U?-1:U<O?1:0};function V(c,l,p,m,S){if(c.length===0)return-1;if(typeof p=="string"?(m=p,p=0):p>2147483647?p=2147483647:p<-2147483648&&(p=-2147483648),p=+p,sr(p)&&(p=S?0:c.length-1),p<0&&(p=c.length+p),p>=c.length){if(S)return-1;p=c.length-1}else if(p<0)if(S)p=0;else return-1;if(typeof l=="string"&&(l=a.from(l,m)),a.isBuffer(l))return l.length===0?-1:Ue(c,l,p,m,S);if(typeof l=="number")return l=l&255,typeof Uint8Array.prototype.indexOf=="function"?S?Uint8Array.prototype.indexOf.call(c,l,p):Uint8Array.prototype.lastIndexOf.call(c,l,p):Ue(c,[l],p,m,S);throw new TypeError("val must be string, number or Buffer")}function Ue(c,l,p,m,S){let O=1,U=c.length,ce=l.length;if(m!==void 0&&(m=String(m).toLowerCase(),m==="ucs2"||m==="ucs-2"||m==="utf16le"||m==="utf-16le")){if(c.length<2||l.length<2)return-1;O=2,U/=2,ce/=2,p/=2}function ke(ae,me){return O===1?ae[me]:ae.readUInt16BE(me*O)}let le;if(S){let ae=-1;for(le=p;le<U;le++)if(ke(c,le)===ke(l,ae===-1?0:le-ae)){if(ae===-1&&(ae=le),le-ae+1===ce)return ae*O}else ae!==-1&&(le-=le-ae),ae=-1}else for(p+ce>U&&(p=U-ce),le=p;le>=0;le--){let ae=!0;for(let me=0;me<ce;me++)if(ke(c,le+me)!==ke(l,me)){ae=!1;break}if(ae)return le}return-1}a.prototype.includes=function(c,l,p){return this.indexOf(c,l,p)!==-1},a.prototype.indexOf=function(c,l,p){return V(this,c,l,p,!0)},a.prototype.lastIndexOf=function(c,l,p){return V(this,c,l,p,!1)};function Le(c,l,p,m){p=Number(p)||0;const S=c.length-p;m?(m=Number(m),m>S&&(m=S)):m=S;const O=l.length;m>O/2&&(m=O/2);let U;for(U=0;U<m;++U){const ce=parseInt(l.substr(U*2,2),16);if(sr(ce))return U;c[p+U]=ce}return U}function Je(c,l,p,m){return Mt(Lt(l,c.length-p),c,p,m)}function Fe(c,l,p,m){return Mt(Xr(l),c,p,m)}function Ye(c,l,p,m){return Mt(On(l),c,p,m)}function C(c,l,p,m){return Mt(Jr(l,c.length-p),c,p,m)}a.prototype.write=function(c,l,p,m){if(l===void 0)m="utf8",p=this.length,l=0;else if(p===void 0&&typeof l=="string")m=l,p=this.length,l=0;else if(isFinite(l))l=l>>>0,isFinite(p)?(p=p>>>0,m===void 0&&(m="utf8")):(m=p,p=void 0);else throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");const S=this.length-l;if((p===void 0||p>S)&&(p=S),c.length>0&&(p<0||l<0)||l>this.length)throw new RangeError("Attempt to write outside buffer bounds");m||(m="utf8");let O=!1;for(;;)switch(m){case"hex":return Le(this,c,l,p);case"utf8":case"utf-8":return Je(this,c,l,p);case"ascii":case"latin1":case"binary":return Fe(this,c,l,p);case"base64":return Ye(this,c,l,p);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return C(this,c,l,p);default:if(O)throw new TypeError("Unknown encoding: "+m);m=(""+m).toLowerCase(),O=!0}},a.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function F(c,l,p){return l===0&&p===c.length?t.fromByteArray(c):t.fromByteArray(c.slice(l,p))}function oe(c,l,p){p=Math.min(c.length,p);const m=[];let S=l;for(;S<p;){const O=c[S];let U=null,ce=O>239?4:O>223?3:O>191?2:1;if(S+ce<=p){let ke,le,ae,me;switch(ce){case 1:O<128&&(U=O);break;case 2:ke=c[S+1],(ke&192)===128&&(me=(O&31)<<6|ke&63,me>127&&(U=me));break;case 3:ke=c[S+1],le=c[S+2],(ke&192)===128&&(le&192)===128&&(me=(O&15)<<12|(ke&63)<<6|le&63,me>2047&&(me<55296||me>57343)&&(U=me));break;case 4:ke=c[S+1],le=c[S+2],ae=c[S+3],(ke&192)===128&&(le&192)===128&&(ae&192)===128&&(me=(O&15)<<18|(ke&63)<<12|(le&63)<<6|ae&63,me>65535&&me<1114112&&(U=me))}}U===null?(U=65533,ce=1):U>65535&&(U-=65536,m.push(U>>>10&1023|55296),U=56320|U&1023),m.push(U),S+=ce}return ue(m)}const J=4096;function ue(c){const l=c.length;if(l<=J)return String.fromCharCode.apply(String,c);let p="",m=0;for(;m<l;)p+=String.fromCharCode.apply(String,c.slice(m,m+=J));return p}function Ae(c,l,p){let m="";p=Math.min(c.length,p);for(let S=l;S<p;++S)m+=String.fromCharCode(c[S]&127);return m}function Et(c,l,p){let m="";p=Math.min(c.length,p);for(let S=l;S<p;++S)m+=String.fromCharCode(c[S]);return m}function je(c,l,p){const m=c.length;(!l||l<0)&&(l=0),(!p||p<0||p>m)&&(p=m);let S="";for(let O=l;O<p;++O)S+=wi[c[O]];return S}function Ce(c,l,p){const m=c.slice(l,p);let S="";for(let O=0;O<m.length-1;O+=2)S+=String.fromCharCode(m[O]+m[O+1]*256);return S}a.prototype.slice=function(c,l){const p=this.length;c=~~c,l=l===void 0?p:~~l,c<0?(c+=p,c<0&&(c=0)):c>p&&(c=p),l<0?(l+=p,l<0&&(l=0)):l>p&&(l=p),l<c&&(l=c);const m=this.subarray(c,l);return Object.setPrototypeOf(m,a.prototype),m};function re(c,l,p){if(c%1!==0||c<0)throw new RangeError("offset is not uint");if(c+l>p)throw new RangeError("Trying to access beyond buffer length")}a.prototype.readUintLE=a.prototype.readUIntLE=function(c,l,p){c=c>>>0,l=l>>>0,p||re(c,l,this.length);let m=this[c],S=1,O=0;for(;++O<l&&(S*=256);)m+=this[c+O]*S;return m},a.prototype.readUintBE=a.prototype.readUIntBE=function(c,l,p){c=c>>>0,l=l>>>0,p||re(c,l,this.length);let m=this[c+--l],S=1;for(;l>0&&(S*=256);)m+=this[c+--l]*S;return m},a.prototype.readUint8=a.prototype.readUInt8=function(c,l){return c=c>>>0,l||re(c,1,this.length),this[c]},a.prototype.readUint16LE=a.prototype.readUInt16LE=function(c,l){return c=c>>>0,l||re(c,2,this.length),this[c]|this[c+1]<<8},a.prototype.readUint16BE=a.prototype.readUInt16BE=function(c,l){return c=c>>>0,l||re(c,2,this.length),this[c]<<8|this[c+1]},a.prototype.readUint32LE=a.prototype.readUInt32LE=function(c,l){return c=c>>>0,l||re(c,4,this.length),(this[c]|this[c+1]<<8|this[c+2]<<16)+this[c+3]*16777216},a.prototype.readUint32BE=a.prototype.readUInt32BE=function(c,l){return c=c>>>0,l||re(c,4,this.length),this[c]*16777216+(this[c+1]<<16|this[c+2]<<8|this[c+3])},a.prototype.readBigUInt64LE=rt(function(c){c=c>>>0,Ve(c,"offset");const l=this[c],p=this[c+7];(l===void 0||p===void 0)&&wt(c,this.length-8);const m=l+this[++c]*2**8+this[++c]*2**16+this[++c]*2**24,S=this[++c]+this[++c]*2**8+this[++c]*2**16+p*2**24;return BigInt(m)+(BigInt(S)<<BigInt(32))}),a.prototype.readBigUInt64BE=rt(function(c){c=c>>>0,Ve(c,"offset");const l=this[c],p=this[c+7];(l===void 0||p===void 0)&&wt(c,this.length-8);const m=l*2**24+this[++c]*2**16+this[++c]*2**8+this[++c],S=this[++c]*2**24+this[++c]*2**16+this[++c]*2**8+p;return(BigInt(m)<<BigInt(32))+BigInt(S)}),a.prototype.readIntLE=function(c,l,p){c=c>>>0,l=l>>>0,p||re(c,l,this.length);let m=this[c],S=1,O=0;for(;++O<l&&(S*=256);)m+=this[c+O]*S;return S*=128,m>=S&&(m-=Math.pow(2,8*l)),m},a.prototype.readIntBE=function(c,l,p){c=c>>>0,l=l>>>0,p||re(c,l,this.length);let m=l,S=1,O=this[c+--m];for(;m>0&&(S*=256);)O+=this[c+--m]*S;return S*=128,O>=S&&(O-=Math.pow(2,8*l)),O},a.prototype.readInt8=function(c,l){return c=c>>>0,l||re(c,1,this.length),this[c]&128?(255-this[c]+1)*-1:this[c]},a.prototype.readInt16LE=function(c,l){c=c>>>0,l||re(c,2,this.length);const p=this[c]|this[c+1]<<8;return p&32768?p|4294901760:p},a.prototype.readInt16BE=function(c,l){c=c>>>0,l||re(c,2,this.length);const p=this[c+1]|this[c]<<8;return p&32768?p|4294901760:p},a.prototype.readInt32LE=function(c,l){return c=c>>>0,l||re(c,4,this.length),this[c]|this[c+1]<<8|this[c+2]<<16|this[c+3]<<24},a.prototype.readInt32BE=function(c,l){return c=c>>>0,l||re(c,4,this.length),this[c]<<24|this[c+1]<<16|this[c+2]<<8|this[c+3]},a.prototype.readBigInt64LE=rt(function(c){c=c>>>0,Ve(c,"offset");const l=this[c],p=this[c+7];(l===void 0||p===void 0)&&wt(c,this.length-8);const m=this[c+4]+this[c+5]*2**8+this[c+6]*2**16+(p<<24);return(BigInt(m)<<BigInt(32))+BigInt(l+this[++c]*2**8+this[++c]*2**16+this[++c]*2**24)}),a.prototype.readBigInt64BE=rt(function(c){c=c>>>0,Ve(c,"offset");const l=this[c],p=this[c+7];(l===void 0||p===void 0)&&wt(c,this.length-8);const m=(l<<24)+this[++c]*2**16+this[++c]*2**8+this[++c];return(BigInt(m)<<BigInt(32))+BigInt(this[++c]*2**24+this[++c]*2**16+this[++c]*2**8+p)}),a.prototype.readFloatLE=function(c,l){return c=c>>>0,l||re(c,4,this.length),r.read(this,c,!0,23,4)},a.prototype.readFloatBE=function(c,l){return c=c>>>0,l||re(c,4,this.length),r.read(this,c,!1,23,4)},a.prototype.readDoubleLE=function(c,l){return c=c>>>0,l||re(c,8,this.length),r.read(this,c,!0,52,8)},a.prototype.readDoubleBE=function(c,l){return c=c>>>0,l||re(c,8,this.length),r.read(this,c,!1,52,8)};function Ne(c,l,p,m,S,O){if(!a.isBuffer(c))throw new TypeError('"buffer" argument must be a Buffer instance');if(l>S||l<O)throw new RangeError('"value" argument is out of bounds');if(p+m>c.length)throw new RangeError("Index out of range")}a.prototype.writeUintLE=a.prototype.writeUIntLE=function(c,l,p,m){if(c=+c,l=l>>>0,p=p>>>0,!m){const U=Math.pow(2,8*p)-1;Ne(this,c,l,p,U,0)}let S=1,O=0;for(this[l]=c&255;++O<p&&(S*=256);)this[l+O]=c/S&255;return l+p},a.prototype.writeUintBE=a.prototype.writeUIntBE=function(c,l,p,m){if(c=+c,l=l>>>0,p=p>>>0,!m){const U=Math.pow(2,8*p)-1;Ne(this,c,l,p,U,0)}let S=p-1,O=1;for(this[l+S]=c&255;--S>=0&&(O*=256);)this[l+S]=c/O&255;return l+p},a.prototype.writeUint8=a.prototype.writeUInt8=function(c,l,p){return c=+c,l=l>>>0,p||Ne(this,c,l,1,255,0),this[l]=c&255,l+1},a.prototype.writeUint16LE=a.prototype.writeUInt16LE=function(c,l,p){return c=+c,l=l>>>0,p||Ne(this,c,l,2,65535,0),this[l]=c&255,this[l+1]=c>>>8,l+2},a.prototype.writeUint16BE=a.prototype.writeUInt16BE=function(c,l,p){return c=+c,l=l>>>0,p||Ne(this,c,l,2,65535,0),this[l]=c>>>8,this[l+1]=c&255,l+2},a.prototype.writeUint32LE=a.prototype.writeUInt32LE=function(c,l,p){return c=+c,l=l>>>0,p||Ne(this,c,l,4,4294967295,0),this[l+3]=c>>>24,this[l+2]=c>>>16,this[l+1]=c>>>8,this[l]=c&255,l+4},a.prototype.writeUint32BE=a.prototype.writeUInt32BE=function(c,l,p){return c=+c,l=l>>>0,p||Ne(this,c,l,4,4294967295,0),this[l]=c>>>24,this[l+1]=c>>>16,this[l+2]=c>>>8,this[l+3]=c&255,l+4};function L(c,l,p,m,S){Er(l,m,S,c,p,7);let O=Number(l&BigInt(4294967295));c[p++]=O,O=O>>8,c[p++]=O,O=O>>8,c[p++]=O,O=O>>8,c[p++]=O;let U=Number(l>>BigInt(32)&BigInt(4294967295));return c[p++]=U,U=U>>8,c[p++]=U,U=U>>8,c[p++]=U,U=U>>8,c[p++]=U,p}function He(c,l,p,m,S){Er(l,m,S,c,p,7);let O=Number(l&BigInt(4294967295));c[p+7]=O,O=O>>8,c[p+6]=O,O=O>>8,c[p+5]=O,O=O>>8,c[p+4]=O;let U=Number(l>>BigInt(32)&BigInt(4294967295));return c[p+3]=U,U=U>>8,c[p+2]=U,U=U>>8,c[p+1]=U,U=U>>8,c[p]=U,p+8}a.prototype.writeBigUInt64LE=rt(function(c,l=0){return L(this,c,l,BigInt(0),BigInt("0xffffffffffffffff"))}),a.prototype.writeBigUInt64BE=rt(function(c,l=0){return He(this,c,l,BigInt(0),BigInt("0xffffffffffffffff"))}),a.prototype.writeIntLE=function(c,l,p,m){if(c=+c,l=l>>>0,!m){const ce=Math.pow(2,8*p-1);Ne(this,c,l,p,ce-1,-ce)}let S=0,O=1,U=0;for(this[l]=c&255;++S<p&&(O*=256);)c<0&&U===0&&this[l+S-1]!==0&&(U=1),this[l+S]=(c/O>>0)-U&255;return l+p},a.prototype.writeIntBE=function(c,l,p,m){if(c=+c,l=l>>>0,!m){const ce=Math.pow(2,8*p-1);Ne(this,c,l,p,ce-1,-ce)}let S=p-1,O=1,U=0;for(this[l+S]=c&255;--S>=0&&(O*=256);)c<0&&U===0&&this[l+S+1]!==0&&(U=1),this[l+S]=(c/O>>0)-U&255;return l+p},a.prototype.writeInt8=function(c,l,p){return c=+c,l=l>>>0,p||Ne(this,c,l,1,127,-128),c<0&&(c=255+c+1),this[l]=c&255,l+1},a.prototype.writeInt16LE=function(c,l,p){return c=+c,l=l>>>0,p||Ne(this,c,l,2,32767,-32768),this[l]=c&255,this[l+1]=c>>>8,l+2},a.prototype.writeInt16BE=function(c,l,p){return c=+c,l=l>>>0,p||Ne(this,c,l,2,32767,-32768),this[l]=c>>>8,this[l+1]=c&255,l+2},a.prototype.writeInt32LE=function(c,l,p){return c=+c,l=l>>>0,p||Ne(this,c,l,4,2147483647,-2147483648),this[l]=c&255,this[l+1]=c>>>8,this[l+2]=c>>>16,this[l+3]=c>>>24,l+4},a.prototype.writeInt32BE=function(c,l,p){return c=+c,l=l>>>0,p||Ne(this,c,l,4,2147483647,-2147483648),c<0&&(c=4294967295+c+1),this[l]=c>>>24,this[l+1]=c>>>16,this[l+2]=c>>>8,this[l+3]=c&255,l+4},a.prototype.writeBigInt64LE=rt(function(c,l=0){return L(this,c,l,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))}),a.prototype.writeBigInt64BE=rt(function(c,l=0){return He(this,c,l,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});function Pn(c,l,p,m,S,O){if(p+m>c.length)throw new RangeError("Index out of range");if(p<0)throw new RangeError("Index out of range")}function gt(c,l,p,m,S){return l=+l,p=p>>>0,S||Pn(c,l,p,4),r.write(c,l,p,m,23,4),p+4}a.prototype.writeFloatLE=function(c,l,p){return gt(this,c,l,!0,p)},a.prototype.writeFloatBE=function(c,l,p){return gt(this,c,l,!1,p)};function Nr(c,l,p,m,S){return l=+l,p=p>>>0,S||Pn(c,l,p,8),r.write(c,l,p,m,52,8),p+8}a.prototype.writeDoubleLE=function(c,l,p){return Nr(this,c,l,!0,p)},a.prototype.writeDoubleBE=function(c,l,p){return Nr(this,c,l,!1,p)},a.prototype.copy=function(c,l,p,m){if(!a.isBuffer(c))throw new TypeError("argument should be a Buffer");if(p||(p=0),!m&&m!==0&&(m=this.length),l>=c.length&&(l=c.length),l||(l=0),m>0&&m<p&&(m=p),m===p||c.length===0||this.length===0)return 0;if(l<0)throw new RangeError("targetStart out of bounds");if(p<0||p>=this.length)throw new RangeError("Index out of range");if(m<0)throw new RangeError("sourceEnd out of bounds");m>this.length&&(m=this.length),c.length-l<m-p&&(m=c.length-l+p);const S=m-p;return this===c&&typeof Uint8Array.prototype.copyWithin=="function"?this.copyWithin(l,p,m):Uint8Array.prototype.set.call(c,this.subarray(p,m),l),S},a.prototype.fill=function(c,l,p,m){if(typeof c=="string"){if(typeof l=="string"?(m=l,l=0,p=this.length):typeof p=="string"&&(m=p,p=this.length),m!==void 0&&typeof m!="string")throw new TypeError("encoding must be a string");if(typeof m=="string"&&!a.isEncoding(m))throw new TypeError("Unknown encoding: "+m);if(c.length===1){const O=c.charCodeAt(0);(m==="utf8"&&O<128||m==="latin1")&&(c=O)}}else typeof c=="number"?c=c&255:typeof c=="boolean"&&(c=Number(c));if(l<0||this.length<l||this.length<p)throw new RangeError("Out of range index");if(p<=l)return this;l=l>>>0,p=p===void 0?this.length:p>>>0,c||(c=0);let S;if(typeof c=="number")for(S=l;S<p;++S)this[S]=c;else{const O=a.isBuffer(c)?c:a.from(c,m),U=O.length;if(U===0)throw new TypeError('The value "'+c+'" is invalid for argument "value"');for(S=0;S<p-l;++S)this[S+l]=O[S%U]}return this};const At={};function Ht(c,l,p){At[c]=class extends p{constructor(){super(),Object.defineProperty(this,"message",{value:l.apply(this,arguments),writable:!0,configurable:!0}),this.name=`${this.name} [${c}]`,this.stack,delete this.name}get code(){return c}set code(m){Object.defineProperty(this,"code",{configurable:!0,enumerable:!0,value:m,writable:!0})}toString(){return`${this.name} [${c}]: ${this.message}`}}}Ht("ERR_BUFFER_OUT_OF_BOUNDS",function(c){return c?`${c} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"},RangeError),Ht("ERR_INVALID_ARG_TYPE",function(c,l){return`The "${c}" argument must be of type number. Received type ${typeof l}`},TypeError),Ht("ERR_OUT_OF_RANGE",function(c,l,p){let m=`The value of "${c}" is out of range.`,S=p;return Number.isInteger(p)&&Math.abs(p)>2**32?S=st(String(p)):typeof p=="bigint"&&(S=String(p),(p>BigInt(2)**BigInt(32)||p<-(BigInt(2)**BigInt(32)))&&(S=st(S)),S+="n"),m+=` It must be ${l}. Received ${S}`,m},RangeError);function st(c){let l="",p=c.length;const m=c[0]==="-"?1:0;for(;p>=m+4;p-=3)l=`_${c.slice(p-3,p)}${l}`;return`${c.slice(0,p)}${l}`}function Dt(c,l,p){Ve(l,"offset"),(c[l]===void 0||c[l+p]===void 0)&&wt(l,c.length-(p+1))}function Er(c,l,p,m,S,O){if(c>p||c<l){const U=typeof l=="bigint"?"n":"";let ce;throw l===0||l===BigInt(0)?ce=`>= 0${U} and < 2${U} ** ${(O+1)*8}${U}`:ce=`>= -(2${U} ** ${(O+1)*8-1}${U}) and < 2 ** ${(O+1)*8-1}${U}`,new At.ERR_OUT_OF_RANGE("value",ce,c)}Dt(m,S,O)}function Ve(c,l){if(typeof c!="number")throw new At.ERR_INVALID_ARG_TYPE(l,"number",c)}function wt(c,l,p){throw Math.floor(c)!==c?(Ve(c,p),new At.ERR_OUT_OF_RANGE("offset","an integer",c)):l<0?new At.ERR_BUFFER_OUT_OF_BOUNDS:new At.ERR_OUT_OF_RANGE("offset",`>= 0 and <= ${l}`,c)}const Ar=/[^+/0-9A-Za-z-_]/g;function nt(c){if(c=c.split("=")[0],c=c.trim().replace(Ar,""),c.length<2)return"";for(;c.length%4!==0;)c=c+"=";return c}function Lt(c,l){l=l||1/0;let p;const m=c.length;let S=null;const O=[];for(let U=0;U<m;++U){if(p=c.charCodeAt(U),p>55295&&p<57344){if(!S){if(p>56319){(l-=3)>-1&&O.push(239,191,189);continue}else if(U+1===m){(l-=3)>-1&&O.push(239,191,189);continue}S=p;continue}if(p<56320){(l-=3)>-1&&O.push(239,191,189),S=p;continue}p=(S-55296<<10|p-56320)+65536}else S&&(l-=3)>-1&&O.push(239,191,189);if(S=null,p<128){if((l-=1)<0)break;O.push(p)}else if(p<2048){if((l-=2)<0)break;O.push(p>>6|192,p&63|128)}else if(p<65536){if((l-=3)<0)break;O.push(p>>12|224,p>>6&63|128,p&63|128)}else if(p<1114112){if((l-=4)<0)break;O.push(p>>18|240,p>>12&63|128,p>>6&63|128,p&63|128)}else throw new Error("Invalid code point")}return O}function Xr(c){const l=[];for(let p=0;p<c.length;++p)l.push(c.charCodeAt(p)&255);return l}function Jr(c,l){let p,m,S;const O=[];for(let U=0;U<c.length&&!((l-=2)<0);++U)p=c.charCodeAt(U),m=p>>8,S=p%256,O.push(S),O.push(m);return O}function On(c){return t.toByteArray(nt(c))}function Mt(c,l,p,m){let S;for(S=0;S<m&&!(S+p>=l.length||S>=c.length);++S)l[S+p]=c[S];return S}function ze(c,l){return c instanceof l||c!=null&&c.constructor!=null&&c.constructor.name!=null&&c.constructor.name===l.name}function sr(c){return c!==c}const wi=function(){const c="0123456789abcdef",l=new Array(256);for(let p=0;p<16;++p){const m=p*16;for(let S=0;S<16;++S)l[m+S]=c[p]+c[S]}return l}();function rt(c){return typeof BigInt>"u"?Yr:c}function Yr(){throw new Error("BigInt not supported")}})(k2);const kI="https://mempool.space",PI="https://mempool.space/testnet",OI="https://mempool.space/testnet4",II="https://mempool.space/signet",xI="https://mempool.fractalbitcoin.io",$I="https://mempool-testnet.fractalbitcoin.io",pi=e=>e===Bt?PI:e===xr?OI:e===Ir?II:e===fo?xI:e===$r?$I:kI;var pt={},od={};const CI={},NI=Object.freeze(Object.defineProperty({__proto__:null,default:CI},Symbol.toStringTag,{value:"Module"})),O2=xT(NI);(function(e){/*! noble-secp256k1 - MIT License (c) 2019 Paul Miller (paulmillr.com) */Object.defineProperty(e,"__esModule",{value:!0}),e.utils=e.schnorr=e.verify=e.signSync=e.sign=e.getSharedSecret=e.recoverPublicKey=e.getPublicKey=e.Signature=e.Point=e.CURVE=void 0;const t=O2,r=BigInt(0),n=BigInt(1),i=BigInt(2),o=BigInt(3),s=BigInt(8),a=Object.freeze({a:r,b:BigInt(7),P:BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),n:BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),h:n,Gx:BigInt("55066263022277343669578718895168534326250603453777594175500187360389116729240"),Gy:BigInt("32670510020758816978083085130507043184471273380659243275938904335757337482424"),beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee")});e.CURVE=a;const u=(b,y)=>(b+y/i)/y,f={beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),splitScalar(b){const{n:y}=a,w=BigInt("0x3086d221a7d46bcde86c90e49284eb15"),A=-n*BigInt("0xe4437ed6010e88286f547fa90abfe4c3"),_=BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),$=w,H=BigInt("0x100000000000000000000000000000000"),K=u($*b,y),q=u(-A*b,y);let z=L(b-K*w-q*_,y),X=L(-K*A-q*$,y);const Z=z>H,te=X>H;if(Z&&(z=y-z),te&&(X=y-X),z>H||X>H)throw new Error("splitScalarEndo: Endomorphism failed, k="+b);return{k1neg:Z,k1:z,k2neg:te,k2:X}}},h=32,d=32,g=32,v=h+1,E=2*h+1;function T(b){const{a:y,b:w}=a,A=L(b*b),_=L(A*b);return L(_+y*b+w)}const x=a.a===r;class N extends Error{constructor(y){super(y)}}function I(b){if(!(b instanceof k))throw new TypeError("JacobianPoint expected")}class k{constructor(y,w,A){this.x=y,this.y=w,this.z=A}static fromAffine(y){if(!(y instanceof V))throw new TypeError("JacobianPoint#fromAffine: expected Point");return y.equals(V.ZERO)?k.ZERO:new k(y.x,y.y,n)}static toAffineBatch(y){const w=Nr(y.map(A=>A.z));return y.map((A,_)=>A.toAffine(w[_]))}static normalizeZ(y){return k.toAffineBatch(y).map(k.fromAffine)}equals(y){I(y);const{x:w,y:A,z:_}=this,{x:$,y:H,z:K}=y,q=L(_*_),z=L(K*K),X=L(w*z),Z=L($*q),te=L(L(A*K)*z),P=L(L(H*_)*q);return X===Z&&te===P}negate(){return new k(this.x,L(-this.y),this.z)}double(){const{x:y,y:w,z:A}=this,_=L(y*y),$=L(w*w),H=L($*$),K=y+$,q=L(i*(L(K*K)-_-H)),z=L(o*_),X=L(z*z),Z=L(X-i*q),te=L(z*(q-Z)-s*H),P=L(i*w*A);return new k(Z,te,P)}add(y){I(y);const{x:w,y:A,z:_}=this,{x:$,y:H,z:K}=y;if($===r||H===r)return this;if(w===r||A===r)return y;const q=L(_*_),z=L(K*K),X=L(w*z),Z=L($*q),te=L(L(A*K)*z),P=L(L(H*_)*q),j=L(Z-X),G=L(P-te);if(j===r)return G===r?this.double():k.ZERO;const ne=L(j*j),_e=L(j*ne),$e=L(X*ne),Pe=L(G*G-_e-i*$e),Oe=L(G*($e-Pe)-te*_e),Ze=L(_*K*j);return new k(Pe,Oe,Ze)}subtract(y){return this.add(y.negate())}multiplyUnsafe(y){const w=k.ZERO;if(typeof y=="bigint"&&y===r)return w;let A=Ne(y);if(A===n)return this;if(!x){let Z=w,te=this;for(;A>r;)A&n&&(Z=Z.add(te)),te=te.double(),A>>=n;return Z}let{k1neg:_,k1:$,k2neg:H,k2:K}=f.splitScalar(A),q=w,z=w,X=this;for(;$>r||K>r;)$&n&&(q=q.add(X)),K&n&&(z=z.add(X)),X=X.double(),$>>=n,K>>=n;return _&&(q=q.negate()),H&&(z=z.negate()),z=new k(L(z.x*f.beta),z.y,z.z),q.add(z)}precomputeWindow(y){const w=x?128/y+1:256/y+1,A=[];let _=this,$=_;for(let H=0;H<w;H++){$=_,A.push($);for(let K=1;K<2**(y-1);K++)$=$.add(_),A.push($);_=$.double()}return A}wNAF(y,w){!w&&this.equals(k.BASE)&&(w=V.BASE);const A=w&&w._WINDOW_SIZE||1;if(256%A)throw new Error("Point#wNAF: Invalid precomputation window, must be power of 2");let _=w&&W.get(w);_||(_=this.precomputeWindow(A),w&&A!==1&&(_=k.normalizeZ(_),W.set(w,_)));let $=k.ZERO,H=k.BASE;const K=1+(x?128/A:256/A),q=2**(A-1),z=BigInt(2**A-1),X=2**A,Z=BigInt(A);for(let te=0;te<K;te++){const P=te*q;let j=Number(y&z);y>>=Z,j>q&&(j-=X,y+=n);const G=P,ne=P+Math.abs(j)-1,_e=te%2!==0,$e=j<0;j===0?H=H.add(B(_e,_[G])):$=$.add(B($e,_[ne]))}return{p:$,f:H}}multiply(y,w){let A=Ne(y),_,$;if(x){const{k1neg:H,k1:K,k2neg:q,k2:z}=f.splitScalar(A);let{p:X,f:Z}=this.wNAF(K,w),{p:te,f:P}=this.wNAF(z,w);X=B(H,X),te=B(q,te),te=new k(L(te.x*f.beta),te.y,te.z),_=X.add(te),$=Z.add(P)}else{const{p:H,f:K}=this.wNAF(A,w);_=H,$=K}return k.normalizeZ([_,$])[0]}toAffine(y){const{x:w,y:A,z:_}=this,$=this.equals(k.ZERO);y==null&&(y=$?s:gt(_));const H=y,K=L(H*H),q=L(K*H),z=L(w*K),X=L(A*q),Z=L(_*H);if($)return V.ZERO;if(Z!==n)throw new Error("invZ was invalid");return new V(z,X)}}k.BASE=new k(a.Gx,a.Gy,n),k.ZERO=new k(r,n,r);function B(b,y){const w=y.negate();return b?w:y}const W=new WeakMap;class V{constructor(y,w){this.x=y,this.y=w}_setWindowSize(y){this._WINDOW_SIZE=y,W.delete(this)}hasEvenY(){return this.y%i===r}static fromCompressedHex(y){const w=y.length===32,A=Ce(w?y:y.subarray(1));if(!wt(A))throw new Error("Point is not on curve");const _=T(A);let $=Pn(_);const H=($&n)===n;w?H&&($=L(-$)):(y[0]&1)===1!==H&&($=L(-$));const K=new V(A,$);return K.assertValidity(),K}static fromUncompressedHex(y){const w=Ce(y.subarray(1,h+1)),A=Ce(y.subarray(h+1,h*2+1)),_=new V(w,A);return _.assertValidity(),_}static fromHex(y){const w=re(y),A=w.length,_=w[0];if(A===h)return this.fromCompressedHex(w);if(A===v&&(_===2||_===3))return this.fromCompressedHex(w);if(A===E&&_===4)return this.fromUncompressedHex(w);throw new Error(`Point.fromHex: received invalid point. Expected 32-${v} compressed bytes or ${E} uncompressed bytes, not ${A}`)}static fromPrivateKey(y){return V.BASE.multiply(nt(y))}static fromSignature(y,w,A){const{r:_,s:$}=Xr(w);if(![0,1,2,3].includes(A))throw new Error("Cannot recover: invalid recovery bit");const H=Ht(re(y)),{n:K}=a,q=A===2||A===3?_+K:_,z=gt(q,K),X=L(-H*z,K),Z=L($*z,K),te=A&1?"03":"02",P=V.fromHex(te+J(q)),j=V.BASE.multiplyAndAddUnsafe(P,X,Z);if(!j)throw new Error("Cannot recover signature: point at infinify");return j.assertValidity(),j}toRawBytes(y=!1){return je(this.toHex(y))}toHex(y=!1){const w=J(this.x);return y?`${this.hasEvenY()?"02":"03"}${w}`:`04${w}${J(this.y)}`}toHexX(){return this.toHex(!0).slice(2)}toRawX(){return this.toRawBytes(!0).slice(1)}assertValidity(){const y="Point is not on elliptic curve",{x:w,y:A}=this;if(!wt(w)||!wt(A))throw new Error(y);const _=L(A*A),$=T(w);if(L(_-$)!==r)throw new Error(y)}equals(y){return this.x===y.x&&this.y===y.y}negate(){return new V(this.x,L(-this.y))}double(){return k.fromAffine(this).double().toAffine()}add(y){return k.fromAffine(this).add(k.fromAffine(y)).toAffine()}subtract(y){return this.add(y.negate())}multiply(y){return k.fromAffine(this).multiply(y,this).toAffine()}multiplyAndAddUnsafe(y,w,A){const _=k.fromAffine(this),$=w===r||w===n||this!==V.BASE?_.multiplyUnsafe(w):_.multiply(w),H=k.fromAffine(y).multiplyUnsafe(A),K=$.add(H);return K.equals(k.ZERO)?void 0:K.toAffine()}}e.Point=V,V.BASE=new V(a.Gx,a.Gy),V.ZERO=new V(r,r);function Ue(b){return Number.parseInt(b[0],16)>=8?"00"+b:b}function Le(b){if(b.length<2||b[0]!==2)throw new Error(`Invalid signature integer tag: ${F(b)}`);const y=b[1],w=b.subarray(2,y+2);if(!y||w.length!==y)throw new Error("Invalid signature integer: wrong length");if(w[0]===0&&w[1]<=127)throw new Error("Invalid signature integer: trailing length");return{data:Ce(w),left:b.subarray(y+2)}}function Je(b){if(b.length<2||b[0]!=48)throw new Error(`Invalid signature tag: ${F(b)}`);if(b[1]!==b.length-2)throw new Error("Invalid signature: incorrect length");const{data:y,left:w}=Le(b.subarray(2)),{data:A,left:_}=Le(w);if(_.length)throw new Error(`Invalid signature: left bytes after parsing: ${F(_)}`);return{r:y,s:A}}class Fe{constructor(y,w){this.r=y,this.s=w,this.assertValidity()}static fromCompact(y){const w=y instanceof Uint8Array,A="Signature.fromCompact";if(typeof y!="string"&&!w)throw new TypeError(`${A}: Expected string or Uint8Array`);const _=w?F(y):y;if(_.length!==128)throw new Error(`${A}: Expected 64-byte hex`);return new Fe(Et(_.slice(0,64)),Et(_.slice(64,128)))}static fromDER(y){const w=y instanceof Uint8Array;if(typeof y!="string"&&!w)throw new TypeError("Signature.fromDER: Expected string or Uint8Array");const{r:A,s:_}=Je(w?y:je(y));return new Fe(A,_)}static fromHex(y){return this.fromDER(y)}assertValidity(){const{r:y,s:w}=this;if(!Ve(y))throw new Error("Invalid Signature: r must be 0 < r < n");if(!Ve(w))throw new Error("Invalid Signature: s must be 0 < s < n")}hasHighS(){const y=a.n>>n;return this.s>y}normalizeS(){return this.hasHighS()?new Fe(this.r,L(-this.s,a.n)):this}toDERRawBytes(){return je(this.toDERHex())}toDERHex(){const y=Ue(Ae(this.s)),w=Ue(Ae(this.r)),A=y.length/2,_=w.length/2,$=Ae(A),H=Ae(_);return`30${Ae(_+A+4)}02${H}${w}02${$}${y}`}toRawBytes(){return this.toDERRawBytes()}toHex(){return this.toDERHex()}toCompactRawBytes(){return je(this.toCompactHex())}toCompactHex(){return J(this.r)+J(this.s)}}e.Signature=Fe;function Ye(...b){if(!b.every(A=>A instanceof Uint8Array))throw new Error("Uint8Array list expected");if(b.length===1)return b[0];const y=b.reduce((A,_)=>A+_.length,0),w=new Uint8Array(y);for(let A=0,_=0;A<b.length;A++){const $=b[A];w.set($,_),_+=$.length}return w}const C=Array.from({length:256},(b,y)=>y.toString(16).padStart(2,"0"));function F(b){if(!(b instanceof Uint8Array))throw new Error("Expected Uint8Array");let y="";for(let w=0;w<b.length;w++)y+=C[b[w]];return y}const oe=BigInt("0x10000000000000000000000000000000000000000000000000000000000000000");function J(b){if(typeof b!="bigint")throw new Error("Expected bigint");if(!(r<=b&&b<oe))throw new Error("Expected number 0 <= n < 2^256");return b.toString(16).padStart(64,"0")}function ue(b){const y=je(J(b));if(y.length!==32)throw new Error("Error: expected 32 bytes");return y}function Ae(b){const y=b.toString(16);return y.length&1?`0${y}`:y}function Et(b){if(typeof b!="string")throw new TypeError("hexToNumber: expected string, got "+typeof b);return BigInt(`0x${b}`)}function je(b){if(typeof b!="string")throw new TypeError("hexToBytes: expected string, got "+typeof b);if(b.length%2)throw new Error("hexToBytes: received invalid unpadded hex"+b.length);const y=new Uint8Array(b.length/2);for(let w=0;w<y.length;w++){const A=w*2,_=b.slice(A,A+2),$=Number.parseInt(_,16);if(Number.isNaN($)||$<0)throw new Error("Invalid byte sequence");y[w]=$}return y}function Ce(b){return Et(F(b))}function re(b){return b instanceof Uint8Array?Uint8Array.from(b):je(b)}function Ne(b){if(typeof b=="number"&&Number.isSafeInteger(b)&&b>0)return BigInt(b);if(typeof b=="bigint"&&Ve(b))return b;throw new TypeError("Expected valid private scalar: 0 < scalar < curve.n")}function L(b,y=a.P){const w=b%y;return w>=r?w:y+w}function He(b,y){const{P:w}=a;let A=b;for(;y-- >r;)A*=A,A%=w;return A}function Pn(b){const{P:y}=a,w=BigInt(6),A=BigInt(11),_=BigInt(22),$=BigInt(23),H=BigInt(44),K=BigInt(88),q=b*b*b%y,z=q*q*b%y,X=He(z,o)*z%y,Z=He(X,o)*z%y,te=He(Z,i)*q%y,P=He(te,A)*te%y,j=He(P,_)*P%y,G=He(j,H)*j%y,ne=He(G,K)*G%y,_e=He(ne,H)*j%y,$e=He(_e,o)*z%y,Pe=He($e,$)*P%y,Oe=He(Pe,w)*q%y,Ze=He(Oe,i);if(Ze*Ze%y!==b)throw new Error("Cannot find square root");return Ze}function gt(b,y=a.P){if(b===r||y<=r)throw new Error(`invert: expected positive integers, got n=${b} mod=${y}`);let w=L(b,y),A=y,_=r,$=n;for(;w!==r;){const H=A/w,K=A%w,q=_-$*H;A=w,w=K,_=$,$=q}if(A!==n)throw new Error("invert: does not exist");return L(_,y)}function Nr(b,y=a.P){const w=new Array(b.length),A=b.reduce(($,H,K)=>H===r?$:(w[K]=$,L($*H,y)),n),_=gt(A,y);return b.reduceRight(($,H,K)=>H===r?$:(w[K]=L($*w[K],y),L($*H,y)),_),w}function At(b){const y=b.length*8-d*8,w=Ce(b);return y>0?w>>BigInt(y):w}function Ht(b,y=!1){const w=At(b);if(y)return w;const{n:A}=a;return w>=A?w-A:w}let st,Dt;class Er{constructor(y,w){if(this.hashLen=y,this.qByteLen=w,typeof y!="number"||y<2)throw new Error("hashLen must be a number");if(typeof w!="number"||w<2)throw new Error("qByteLen must be a number");this.v=new Uint8Array(y).fill(1),this.k=new Uint8Array(y).fill(0),this.counter=0}hmac(...y){return e.utils.hmacSha256(this.k,...y)}hmacSync(...y){return Dt(this.k,...y)}checkSync(){if(typeof Dt!="function")throw new N("hmacSha256Sync needs to be set")}incr(){if(this.counter>=1e3)throw new Error("Tried 1,000 k values for sign(), all were invalid");this.counter+=1}async reseed(y=new Uint8Array){this.k=await this.hmac(this.v,Uint8Array.from([0]),y),this.v=await this.hmac(this.v),y.length!==0&&(this.k=await this.hmac(this.v,Uint8Array.from([1]),y),this.v=await this.hmac(this.v))}reseedSync(y=new Uint8Array){this.checkSync(),this.k=this.hmacSync(this.v,Uint8Array.from([0]),y),this.v=this.hmacSync(this.v),y.length!==0&&(this.k=this.hmacSync(this.v,Uint8Array.from([1]),y),this.v=this.hmacSync(this.v))}async generate(){this.incr();let y=0;const w=[];for(;y<this.qByteLen;){this.v=await this.hmac(this.v);const A=this.v.slice();w.push(A),y+=this.v.length}return Ye(...w)}generateSync(){this.checkSync(),this.incr();let y=0;const w=[];for(;y<this.qByteLen;){this.v=this.hmacSync(this.v);const A=this.v.slice();w.push(A),y+=this.v.length}return Ye(...w)}}function Ve(b){return r<b&&b<a.n}function wt(b){return r<b&&b<a.P}function Ar(b,y,w,A=!0){const{n:_}=a,$=Ht(b,!0);if(!Ve($))return;const H=gt($,_),K=V.BASE.multiply($),q=L(K.x,_);if(q===r)return;const z=L(H*L(y+w*q,_),_);if(z===r)return;let X=new Fe(q,z),Z=(K.x===X.r?0:2)|Number(K.y&n);return A&&X.hasHighS()&&(X=X.normalizeS(),Z^=1),{sig:X,recovery:Z}}function nt(b){let y;if(typeof b=="bigint")y=b;else if(typeof b=="number"&&Number.isSafeInteger(b)&&b>0)y=BigInt(b);else if(typeof b=="string"){if(b.length!==2*d)throw new Error("Expected 32 bytes of private key");y=Et(b)}else if(b instanceof Uint8Array){if(b.length!==d)throw new Error("Expected 32 bytes of private key");y=Ce(b)}else throw new TypeError("Expected valid private key");if(!Ve(y))throw new Error("Expected private key: 0 < key < n");return y}function Lt(b){return b instanceof V?(b.assertValidity(),b):V.fromHex(b)}function Xr(b){if(b instanceof Fe)return b.assertValidity(),b;try{return Fe.fromDER(b)}catch{return Fe.fromCompact(b)}}function Jr(b,y=!1){return V.fromPrivateKey(b).toRawBytes(y)}e.getPublicKey=Jr;function On(b,y,w,A=!1){return V.fromSignature(b,y,w).toRawBytes(A)}e.recoverPublicKey=On;function Mt(b){const y=b instanceof Uint8Array,w=typeof b=="string",A=(y||w)&&b.length;return y?A===v||A===E:w?A===v*2||A===E*2:b instanceof V}function ze(b,y,w=!1){if(Mt(b))throw new TypeError("getSharedSecret: first arg must be private key");if(!Mt(y))throw new TypeError("getSharedSecret: second arg must be public key");const A=Lt(y);return A.assertValidity(),A.multiply(nt(b)).toRawBytes(w)}e.getSharedSecret=ze;function sr(b){const y=b.length>h?b.slice(0,h):b;return Ce(y)}function wi(b){const y=sr(b),w=L(y,a.n);return rt(w<r?y:w)}function rt(b){return ue(b)}function Yr(b,y,w){if(b==null)throw new Error(`sign: expected valid message hash, not "${b}"`);const A=re(b),_=nt(y),$=[rt(_),wi(A)];if(w!=null){w===!0&&(w=e.utils.randomBytes(h));const q=re(w);if(q.length!==h)throw new Error(`sign: Expected ${h} bytes of extra data`);$.push(q)}const H=Ye(...$),K=sr(A);return{seed:H,m:K,d:_}}function c(b,y){const{sig:w,recovery:A}=b,{der:_,recovered:$}=Object.assign({canonical:!0,der:!0},y),H=_?w.toDERRawBytes():w.toCompactRawBytes();return $?[H,A]:H}async function l(b,y,w={}){const{seed:A,m:_,d:$}=Yr(b,y,w.extraEntropy),H=new Er(g,d);await H.reseed(A);let K;for(;!(K=Ar(await H.generate(),_,$,w.canonical));)await H.reseed();return c(K,w)}e.sign=l;function p(b,y,w={}){const{seed:A,m:_,d:$}=Yr(b,y,w.extraEntropy),H=new Er(g,d);H.reseedSync(A);let K;for(;!(K=Ar(H.generateSync(),_,$,w.canonical));)H.reseedSync();return c(K,w)}e.signSync=p;const m={strict:!0};function S(b,y,w,A=m){let _;try{_=Xr(b),y=re(y)}catch{return!1}const{r:$,s:H}=_;if(A.strict&&_.hasHighS())return!1;const K=Ht(y);let q;try{q=Lt(w)}catch{return!1}const{n:z}=a,X=gt(H,z),Z=L(K*X,z),te=L($*X,z),P=V.BASE.multiplyAndAddUnsafe(q,Z,te);return P?L(P.x,z)===$:!1}e.verify=S;function O(b){return L(Ce(b),a.n)}class U{constructor(y,w){this.r=y,this.s=w,this.assertValidity()}static fromHex(y){const w=re(y);if(w.length!==64)throw new TypeError(`SchnorrSignature.fromHex: expected 64 bytes, not ${w.length}`);const A=Ce(w.subarray(0,32)),_=Ce(w.subarray(32,64));return new U(A,_)}assertValidity(){const{r:y,s:w}=this;if(!wt(y)||!Ve(w))throw new Error("Invalid signature")}toHex(){return J(this.r)+J(this.s)}toRawBytes(){return je(this.toHex())}}function ce(b){return V.fromPrivateKey(b).toRawX()}class ke{constructor(y,w,A=e.utils.randomBytes()){if(y==null)throw new TypeError(`sign: Expected valid message, not "${y}"`);this.m=re(y);const{x:_,scalar:$}=this.getScalar(nt(w));if(this.px=_,this.d=$,this.rand=re(A),this.rand.length!==32)throw new TypeError("sign: Expected 32 bytes of aux randomness")}getScalar(y){const w=V.fromPrivateKey(y),A=w.hasEvenY()?y:a.n-y;return{point:w,scalar:A,x:w.toRawX()}}initNonce(y,w){return ue(y^Ce(w))}finalizeNonce(y){const w=L(Ce(y),a.n);if(w===r)throw new Error("sign: Creation of signature failed. k is zero");const{point:A,x:_,scalar:$}=this.getScalar(w);return{R:A,rx:_,k:$}}finalizeSig(y,w,A,_){return new U(y.x,L(w+A*_,a.n)).toRawBytes()}error(){throw new Error("sign: Invalid signature produced")}async calc(){const{m:y,d:w,px:A,rand:_}=this,$=e.utils.taggedHash,H=this.initNonce(w,await $(Pt.aux,_)),{R:K,rx:q,k:z}=this.finalizeNonce(await $(Pt.nonce,H,A,y)),X=O(await $(Pt.challenge,q,A,y)),Z=this.finalizeSig(K,z,X,w);return await is(Z,y,A)||this.error(),Z}calcSync(){const{m:y,d:w,px:A,rand:_}=this,$=e.utils.taggedHashSync,H=this.initNonce(w,$(Pt.aux,_)),{R:K,rx:q,k:z}=this.finalizeNonce($(Pt.nonce,H,A,y)),X=O($(Pt.challenge,q,A,y)),Z=this.finalizeSig(K,z,X,w);return Zr(Z,y,A)||this.error(),Z}}async function le(b,y,w){return new ke(b,y,w).calc()}function ae(b,y,w){return new ke(b,y,w).calcSync()}function me(b,y,w){const A=b instanceof U,_=A?b:U.fromHex(b);return A&&_.assertValidity(),{..._,m:re(y),P:Lt(w)}}function bi(b,y,w,A){const _=V.BASE.multiplyAndAddUnsafe(y,nt(w),L(-A,a.n));return!(!_||!_.hasEvenY()||_.x!==b)}async function is(b,y,w){try{const{r:A,s:_,m:$,P:H}=me(b,y,w),K=O(await e.utils.taggedHash(Pt.challenge,ue(A),H.toRawX(),$));return bi(A,H,_,K)}catch{return!1}}function Zr(b,y,w){try{const{r:A,s:_,m:$,P:H}=me(b,y,w),K=O(e.utils.taggedHashSync(Pt.challenge,ue(A),H.toRawX(),$));return bi(A,H,_,K)}catch(A){if(A instanceof N)throw A;return!1}}e.schnorr={Signature:U,getPublicKey:ce,sign:le,verify:is,signSync:ae,verifySync:Zr},V.BASE._setWindowSize(8);const Ke={node:t,web:typeof self=="object"&&"crypto"in self?self.crypto:void 0},Pt={challenge:"BIP0340/challenge",aux:"BIP0340/aux",nonce:"BIP0340/nonce"},Qr={};e.utils={bytesToHex:F,hexToBytes:je,concatBytes:Ye,mod:L,invert:gt,isValidPrivateKey(b){try{return nt(b),!0}catch{return!1}},_bigintTo32Bytes:ue,_normalizePrivateKey:nt,hashToPrivateKey:b=>{b=re(b);const y=d+8;if(b.length<y||b.length>1024)throw new Error("Expected valid bytes of private key as per FIPS 186");const w=L(Ce(b),a.n-n)+n;return ue(w)},randomBytes:(b=32)=>{if(Ke.web)return Ke.web.getRandomValues(new Uint8Array(b));if(Ke.node){const{randomBytes:y}=Ke.node;return Uint8Array.from(y(b))}else throw new Error("The environment doesn't have randomBytes function")},randomPrivateKey:()=>e.utils.hashToPrivateKey(e.utils.randomBytes(d+8)),precompute(b=8,y=V.BASE){const w=y===V.BASE?y:new V(y.x,y.y);return w._setWindowSize(b),w.multiply(o),w},sha256:async(...b)=>{if(Ke.web){const y=await Ke.web.subtle.digest("SHA-256",Ye(...b));return new Uint8Array(y)}else if(Ke.node){const{createHash:y}=Ke.node,w=y("sha256");return b.forEach(A=>w.update(A)),Uint8Array.from(w.digest())}else throw new Error("The environment doesn't have sha256 function")},hmacSha256:async(b,...y)=>{if(Ke.web){const w=await Ke.web.subtle.importKey("raw",b,{name:"HMAC",hash:{name:"SHA-256"}},!1,["sign"]),A=Ye(...y),_=await Ke.web.subtle.sign("HMAC",w,A);return new Uint8Array(_)}else if(Ke.node){const{createHmac:w}=Ke.node,A=w("sha256",b);return y.forEach(_=>A.update(_)),Uint8Array.from(A.digest())}else throw new Error("The environment doesn't have hmac-sha256 function")},sha256Sync:void 0,hmacSha256Sync:void 0,taggedHash:async(b,...y)=>{let w=Qr[b];if(w===void 0){const A=await e.utils.sha256(Uint8Array.from(b,_=>_.charCodeAt(0)));w=Ye(A,A),Qr[b]=w}return e.utils.sha256(w,...y)},taggedHashSync:(b,...y)=>{if(typeof st!="function")throw new N("sha256Sync is undefined, you need to set it");let w=Qr[b];if(w===void 0){const A=st(Uint8Array.from(b,_=>_.charCodeAt(0)));w=Ye(A,A),Qr[b]=w}return st(w,...y)},_JacobianPoint:k},Object.defineProperties(e.utils,{sha256Sync:{configurable:!1,get(){return st},set(b){st||(st=b)}},hmacSha256Sync:{configurable:!1,get(){return Dt},set(b){Dt||(Dt=b)}}})})(od);var ad={},Wr={};Object.defineProperty(Wr,"__esModule",{value:!0}),Wr.isBytes=x2,Wr.number=Mu,Wr.bool=I2,Wr.bytes=cd,Wr.hash=$2,Wr.exists=C2,Wr.output=N2;function Mu(e){if(!Number.isSafeInteger(e)||e<0)throw new Error(`positive integer expected, not ${e}`)}function I2(e){if(typeof e!="boolean")throw new Error(`boolean expected, not ${e}`)}function x2(e){return e instanceof Uint8Array||e!=null&&typeof e=="object"&&e.constructor.name==="Uint8Array"}function cd(e,...t){if(!x2(e))throw new Error("Uint8Array expected");if(t.length>0&&!t.includes(e.length))throw new Error(`Uint8Array expected of length ${t}, not of length=${e.length}`)}function $2(e){if(typeof e!="function"||typeof e.create!="function")throw new Error("Hash should be wrapped by utils.wrapConstructor");Mu(e.outputLen),Mu(e.blockLen)}function C2(e,t=!0){if(e.destroyed)throw new Error("Hash instance has been destroyed");if(t&&e.finished)throw new Error("Hash#digest() has already been called")}function N2(e,t){cd(e);const r=t.outputLen;if(e.length<r)throw new Error(`digestInto() expects output buffer of length at least ${r}`)}const UI={number:Mu,bool:I2,bytes:cd,hash:$2,exists:C2,output:N2};Wr.default=UI;var ka={},Fu={};Object.defineProperty(Fu,"__esModule",{value:!0}),Fu.crypto=void 0,Fu.crypto=typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0,function(e){/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */Object.defineProperty(e,"__esModule",{value:!0}),e.Hash=e.nextTick=e.byteSwapIfBE=e.byteSwap=e.isLE=e.rotl=e.rotr=e.createView=e.u32=e.u8=void 0,e.isBytes=n,e.byteSwap32=h,e.bytesToHex=g,e.hexToBytes=T,e.asyncLoop=N,e.utf8ToBytes=I,e.toBytes=k,e.concatBytes=B,e.checkOpts=Ue,e.wrapConstructor=Le,e.wrapConstructorWithOpts=Je,e.wrapXOFConstructorWithOpts=Fe,e.randomBytes=Ye;const t=Fu,r=Wr;function n(C){return C instanceof Uint8Array||C!=null&&typeof C=="object"&&C.constructor.name==="Uint8Array"}const i=C=>new Uint8Array(C.buffer,C.byteOffset,C.byteLength);e.u8=i;const o=C=>new Uint32Array(C.buffer,C.byteOffset,Math.floor(C.byteLength/4));e.u32=o;const s=C=>new DataView(C.buffer,C.byteOffset,C.byteLength);e.createView=s;const a=(C,F)=>C<<32-F|C>>>F;e.rotr=a;const u=(C,F)=>C<<F|C>>>32-F>>>0;e.rotl=u,e.isLE=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;const f=C=>C<<24&4278190080|C<<8&16711680|C>>>8&65280|C>>>24&255;e.byteSwap=f,e.byteSwapIfBE=e.isLE?C=>C:C=>(0,e.byteSwap)(C);function h(C){for(let F=0;F<C.length;F++)C[F]=(0,e.byteSwap)(C[F])}const d=Array.from({length:256},(C,F)=>F.toString(16).padStart(2,"0"));function g(C){(0,r.bytes)(C);let F="";for(let oe=0;oe<C.length;oe++)F+=d[C[oe]];return F}const v={_0:48,_9:57,_A:65,_F:70,_a:97,_f:102};function E(C){if(C>=v._0&&C<=v._9)return C-v._0;if(C>=v._A&&C<=v._F)return C-(v._A-10);if(C>=v._a&&C<=v._f)return C-(v._a-10)}function T(C){if(typeof C!="string")throw new Error("hex string expected, got "+typeof C);const F=C.length,oe=F/2;if(F%2)throw new Error("padded hex string expected, got unpadded hex of length "+F);const J=new Uint8Array(oe);for(let ue=0,Ae=0;ue<oe;ue++,Ae+=2){const Et=E(C.charCodeAt(Ae)),je=E(C.charCodeAt(Ae+1));if(Et===void 0||je===void 0){const Ce=C[Ae]+C[Ae+1];throw new Error('hex string expected, got non-hex character "'+Ce+'" at index '+Ae)}J[ue]=Et*16+je}return J}const x=async()=>{};e.nextTick=x;async function N(C,F,oe){let J=Date.now();for(let ue=0;ue<C;ue++){oe(ue);const Ae=Date.now()-J;Ae>=0&&Ae<F||(await(0,e.nextTick)(),J+=Ae)}}function I(C){if(typeof C!="string")throw new Error(`utf8ToBytes expected string, got ${typeof C}`);return new Uint8Array(new TextEncoder().encode(C))}function k(C){return typeof C=="string"&&(C=I(C)),(0,r.bytes)(C),C}function B(...C){let F=0;for(let J=0;J<C.length;J++){const ue=C[J];(0,r.bytes)(ue),F+=ue.length}const oe=new Uint8Array(F);for(let J=0,ue=0;J<C.length;J++){const Ae=C[J];oe.set(Ae,ue),ue+=Ae.length}return oe}class W{clone(){return this._cloneInto()}}e.Hash=W;const V={}.toString;function Ue(C,F){if(F!==void 0&&V.call(F)!=="[object Object]")throw new Error("Options should be object or undefined");return Object.assign(C,F)}function Le(C){const F=J=>C().update(k(J)).digest(),oe=C();return F.outputLen=oe.outputLen,F.blockLen=oe.blockLen,F.create=()=>C(),F}function Je(C){const F=(J,ue)=>C(ue).update(k(J)).digest(),oe=C({});return F.outputLen=oe.outputLen,F.blockLen=oe.blockLen,F.create=J=>C(J),F}function Fe(C){const F=(J,ue)=>C(ue).update(k(J)).digest(),oe=C({});return F.outputLen=oe.outputLen,F.blockLen=oe.blockLen,F.create=J=>C(J),F}function Ye(C=32){if(t.crypto&&typeof t.crypto.getRandomValues=="function")return t.crypto.getRandomValues(new Uint8Array(C));if(t.crypto&&typeof t.crypto.randomBytes=="function")return t.crypto.randomBytes(C);throw new Error("crypto.getRandomValues must be defined")}}(ka),function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.hmac=e.HMAC=void 0;const t=Wr,r=ka;class n extends r.Hash{constructor(s,a){super(),this.finished=!1,this.destroyed=!1,(0,t.hash)(s);const u=(0,r.toBytes)(a);if(this.iHash=s.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 f=this.blockLen,h=new Uint8Array(f);h.set(u.length>f?s.create().update(u).digest():u);for(let d=0;d<h.length;d++)h[d]^=54;this.iHash.update(h),this.oHash=s.create();for(let d=0;d<h.length;d++)h[d]^=106;this.oHash.update(h),h.fill(0)}update(s){return(0,t.exists)(this),this.iHash.update(s),this}digestInto(s){(0,t.exists)(this),(0,t.bytes)(s,this.outputLen),this.finished=!0,this.iHash.digestInto(s),this.oHash.update(s),this.oHash.digestInto(s),this.destroy()}digest(){const s=new Uint8Array(this.oHash.outputLen);return this.digestInto(s),s}_cloneInto(s){s||(s=Object.create(Object.getPrototypeOf(this),{}));const{oHash:a,iHash:u,finished:f,destroyed:h,blockLen:d,outputLen:g}=this;return s=s,s.finished=f,s.destroyed=h,s.blockLen=d,s.outputLen=g,s.oHash=a._cloneInto(s.oHash),s.iHash=u._cloneInto(s.iHash),s}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}}e.HMAC=n;const i=(o,s,a)=>new n(o,s).update(a).digest();e.hmac=i,e.hmac.create=(o,s)=>new n(o,s)}(ad);var Fn={},Yi={};Object.defineProperty(Yi,"__esModule",{value:!0}),Yi.HashMD=Yi.Maj=Yi.Chi=void 0;const ud=Wr,Pa=ka;function RI(e,t,r,n){if(typeof e.setBigUint64=="function")return e.setBigUint64(t,r,n);const i=BigInt(32),o=BigInt(4294967295),s=Number(r>>i&o),a=Number(r&o),u=n?4:0,f=n?0:4;e.setUint32(t+u,s,n),e.setUint32(t+f,a,n)}const BI=(e,t,r)=>e&t^~e&r;Yi.Chi=BI;const HI=(e,t,r)=>e&t^e&r^t&r;Yi.Maj=HI;class LI extends Pa.Hash{constructor(t,r,n,i){super(),this.blockLen=t,this.outputLen=r,this.padOffset=n,this.isLE=i,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(t),this.view=(0,Pa.createView)(this.buffer)}update(t){(0,ud.exists)(this);const{view:r,buffer:n,blockLen:i}=this;t=(0,Pa.toBytes)(t);const o=t.length;for(let s=0;s<o;){const a=Math.min(i-this.pos,o-s);if(a===i){const u=(0,Pa.createView)(t);for(;i<=o-s;s+=i)this.process(u,s);continue}n.set(t.subarray(s,s+a),this.pos),this.pos+=a,s+=a,this.pos===i&&(this.process(r,0),this.pos=0)}return this.length+=t.length,this.roundClean(),this}digestInto(t){(0,ud.exists)(this),(0,ud.output)(t,this),this.finished=!0;const{buffer:r,view:n,blockLen:i,isLE:o}=this;let{pos:s}=this;r[s++]=128,this.buffer.subarray(s).fill(0),this.padOffset>i-s&&(this.process(n,0),s=0);for(let d=s;d<i;d++)r[d]=0;RI(n,i-8,BigInt(this.length*8),o),this.process(n,0);const a=(0,Pa.createView)(t),u=this.outputLen;if(u%4)throw new Error("_sha2: outputLen should be aligned to 32bit");const f=u/4,h=this.get();if(f>h.length)throw new Error("_sha2: outputLen bigger than state");for(let d=0;d<f;d++)a.setUint32(4*d,h[d],o)}digest(){const{buffer:t,outputLen:r}=this;this.digestInto(t);const n=t.slice(0,r);return this.destroy(),n}_cloneInto(t){t||(t=new this.constructor),t.set(...this.get());const{blockLen:r,buffer:n,length:i,finished:o,destroyed:s,pos:a}=this;return t.length=i,t.pos=a,t.finished=o,t.destroyed=s,i%r&&t.buffer.set(n),t}}Yi.HashMD=LI,Object.defineProperty(Fn,"__esModule",{value:!0}),Fn.sha224=Fn.sha256=Fn.SHA256=void 0;const ld=Yi,qr=ka,KI=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]),Zi=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),Qi=new Uint32Array(64);class hd extends ld.HashMD{constructor(){super(64,32,8,!1),this.A=Zi[0]|0,this.B=Zi[1]|0,this.C=Zi[2]|0,this.D=Zi[3]|0,this.E=Zi[4]|0,this.F=Zi[5]|0,this.G=Zi[6]|0,this.H=Zi[7]|0}get(){const{A:t,B:r,C:n,D:i,E:o,F:s,G:a,H:u}=this;return[t,r,n,i,o,s,a,u]}set(t,r,n,i,o,s,a,u){this.A=t|0,this.B=r|0,this.C=n|0,this.D=i|0,this.E=o|0,this.F=s|0,this.G=a|0,this.H=u|0}process(t,r){for(let d=0;d<16;d++,r+=4)Qi[d]=t.getUint32(r,!1);for(let d=16;d<64;d++){const g=Qi[d-15],v=Qi[d-2],E=(0,qr.rotr)(g,7)^(0,qr.rotr)(g,18)^g>>>3,T=(0,qr.rotr)(v,17)^(0,qr.rotr)(v,19)^v>>>10;Qi[d]=T+Qi[d-7]+E+Qi[d-16]|0}let{A:n,B:i,C:o,D:s,E:a,F:u,G:f,H:h}=this;for(let d=0;d<64;d++){const g=(0,qr.rotr)(a,6)^(0,qr.rotr)(a,11)^(0,qr.rotr)(a,25),v=h+g+(0,ld.Chi)(a,u,f)+KI[d]+Qi[d]|0,E=((0,qr.rotr)(n,2)^(0,qr.rotr)(n,13)^(0,qr.rotr)(n,22))+(0,ld.Maj)(n,i,o)|0;h=f,f=u,u=a,a=s+v|0,s=o,o=i,i=n,n=v+E|0}n=n+this.A|0,i=i+this.B|0,o=o+this.C|0,s=s+this.D|0,a=a+this.E|0,u=u+this.F|0,f=f+this.G|0,h=h+this.H|0,this.set(n,i,o,s,a,u,f,h)}roundClean(){Qi.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}}Fn.SHA256=hd;class jI extends hd{constructor(){super(),this.A=-1056596264,this.B=914150663,this.C=812702999,this.D=-150054599,this.E=-4191439,this.F=1750603025,this.G=1694076839,this.H=-1090891868,this.outputLen=28}}Fn.sha256=(0,qr.wrapConstructor)(()=>new hd),Fn.sha224=(0,qr.wrapConstructor)(()=>new jI);var DI=od,MI=ad,U2=Fn;function FI(e){var t=Object.create(null);return e&&Object.keys(e).forEach(function(r){if(r!=="default"){var n=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(t,r,n.get?n:{enumerable:!0,get:function(){return e[r]}})}}),t.default=e,Object.freeze(t)}var Be=FI(DI);const es="Expected Private",ts="Expected Point",Oa="Expected Tweak",VI="Expected Hash",Vu="Expected Signature",fd="Expected Extra Data (32 bytes)",Ia="Expected Scalar",zI="Bad Recovery Id";Be.utils.hmacSha256Sync=(e,...t)=>MI.hmac(U2.sha256,e,Be.utils.concatBytes(...t)),Be.utils.sha256Sync=(...e)=>U2.sha256(Be.utils.concatBytes(...e));const dd=Be.utils._normalizePrivateKey,WI=32,qI=32,pd=new Uint8Array([255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,254,186,174,220,230,175,72,160,59,191,210,94,140,208,54,65,65]),GI=32,XI=new Uint8Array(32),JI=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,69,81,35,25,80,183,95,196,64,45,161,114,47,201,186,238]);function YI(e){return e instanceof Uint8Array}function xa(e,t){for(let r=0;r<32;++r)if(e[r]!==t[r])return e[r]<t[r]?-1:1;return 0}function R2(e){return xa(e,XI)===0}function $a(e){return!(!(e instanceof Uint8Array)||e.length!==qI||xa(e,pd)>=0)}function yd(e){return e instanceof Uint8Array&&e.length===64&&xa(e.subarray(0,32),pd)<0&&xa(e.subarray(32,64),pd)<0}function ZI(e){return YI(e)&&e.length===64&&xa(e.subarray(0,32),JI)<0}function QI(e){return!(R2(e.subarray(0,32))||R2(e.subarray(32,64)))}function bo(e){return e instanceof Uint8Array&&e.length===WI}function gd(e){return e===void 0||e instanceof Uint8Array&&e.length===GI}function B2(e){if(typeof e!="string")throw new TypeError("hexToNumber: expected string, got "+typeof e);return BigInt(`0x${e}`)}function ex(e){return B2(Be.utils.bytesToHex(e))}function wd(e){let t;if(typeof e=="bigint")t=e;else if(typeof e=="number"&&Number.isSafeInteger(e)&&e>=0)t=BigInt(e);else if(typeof e=="string"){if(e.length!==64)throw new Error("Expected 32 bytes of private scalar");t=B2(e)}else if(e instanceof Uint8Array){if(e.length!==32)throw new Error("Expected 32 bytes of private scalar");t=ex(e)}else throw new TypeError("Expected valid private scalar");if(t<0)throw new Error("Expected private scalar >= 0");return t}const tx=(e,t)=>{const r=dd(e),n=wd(t),i=Be.utils._bigintTo32Bytes(Be.utils.mod(r+n,Be.CURVE.n));return Be.utils.isValidPrivateKey(i)?i:null},rx=(e,t)=>{const r=dd(e),n=wd(t),i=Be.utils._bigintTo32Bytes(Be.utils.mod(r-n,Be.CURVE.n));return Be.utils.isValidPrivateKey(i)?i:null},nx=e=>{const t=dd(e),r=Be.utils._bigintTo32Bytes(Be.CURVE.n-t);return Be.utils.isValidPrivateKey(r)?r:null},H2=(e,t,r)=>{const n=Be.Point.fromHex(e),i=wd(t),o=Be.Point.BASE.multiplyAndAddUnsafe(n,i,BigInt(1));if(!o)throw new Error("Tweaked point at infinity");return o.toRawBytes(r)},ix=(e,t,r)=>{const n=Be.Point.fromHex(e),i=typeof t=="string"?t:Be.utils.bytesToHex(t),o=BigInt(`0x${i}`);return n.multiply(o).toRawBytes(r)};function mo(e,t){return e===void 0?t!==void 0?L2(t):!0:!!e}function Is(e){try{return e()}catch{return null}}function bd(e,t){if(e.length===32!==t)return!1;try{return!!Be.Point.fromHex(e)}catch{return!1}}function rs(e){return bd(e,!1)}function L2(e){return bd(e,!1)&&e.length===33}function yi(e){return Be.utils.isValidPrivateKey(e)}function zu(e){return bd(e,!0)}function sx(e,t){if(!zu(e))throw new Error(ts);if(!$a(t))throw new Error(Oa);return Is(()=>{const r=H2(e,t,!0);return{parity:r[0]%2===1?1:0,xOnlyPubkey:r.slice(1)}})}function K2(e){if(!rs(e))throw new Error(ts);return e.slice(1,33)}function j2(e,t){if(!yi(e))throw new Error(es);return Is(()=>Be.getPublicKey(e,mo(t)))}function ox(e){if(!yi(e))throw new Error(es);return K2(j2(e))}function ax(e,t){if(!rs(e))throw new Error(ts);return Be.Point.fromHex(e).toRawBytes(mo(t,e))}function cx(e,t,r){if(!rs(e))throw new Error(ts);if(!$a(t))throw new Error(Oa);return Is(()=>ix(e,t,mo(r,e)))}function ux(e,t,r){if(!rs(e)||!rs(t))throw new Error(ts);return Is(()=>{const n=Be.Point.fromHex(e),i=Be.Point.fromHex(t);return n.equals(i.negate())?null:n.add(i).toRawBytes(mo(r,e))})}function lx(e,t,r){if(!rs(e))throw new Error(ts);if(!$a(t))throw new Error(Oa);return Is(()=>H2(e,t,mo(r,e)))}function hx(e,t){if(yi(e)===!1)throw new Error(es);if($a(t)===!1)throw new Error(Oa);return Is(()=>tx(e,t))}function fx(e,t){if(yi(e)===!1)throw new Error(es);if($a(t)===!1)throw new Error(Oa);return Is(()=>rx(e,t))}function dx(e){if(yi(e)===!1)throw new Error(es);return nx(e)}function px(e,t,r){if(!yi(t))throw new Error(es);if(!bo(e))throw new Error(Ia);if(!gd(r))throw new Error(fd);return Be.signSync(e,t,{der:!1,extraEntropy:r})}function yx(e,t,r){if(!yi(t))throw new Error(es);if(!bo(e))throw new Error(Ia);if(!gd(r))throw new Error(fd);const[n,i]=Be.signSync(e,t,{der:!1,extraEntropy:r,recovered:!0});return{signature:n,recoveryId:i}}function gx(e,t,r=Buffer.alloc(32,0)){if(!yi(t))throw new Error(es);if(!bo(e))throw new Error(Ia);if(!gd(r))throw new Error(fd);return Be.schnorr.signSync(e,t,r)}function wx(e,t,r,n){if(!bo(e))throw new Error(VI);if(!yd(t)||!QI(t))throw new Error(Vu);if(r&2&&!ZI(t))throw new Error(zI);if(!zu(t.subarray(0,32)))throw new Error(Vu);return Be.recoverPublicKey(e,t,r,mo(n))}function bx(e,t,r,n){if(!rs(t))throw new Error(ts);if(!yd(r))throw new Error(Vu);if(!bo(e))throw new Error(Ia);return Be.verify(r,e,t,{strict:n})}function mx(e,t,r){if(!zu(t))throw new Error(ts);if(!yd(r))throw new Error(Vu);if(!bo(e))throw new Error(Ia);return Be.schnorr.verifySync(r,e,t)}var vx=pt.isPoint=rs,Ex=pt.isPointCompressed=L2,Ax=pt.isPrivate=yi,Sx=pt.isXOnlyPoint=zu,Tx=pt.pointAdd=ux,_x=pt.pointAddScalar=lx,kx=pt.pointCompress=ax,Px=pt.pointFromScalar=j2,Ox=pt.pointMultiply=cx,Ix=pt.privateAdd=hx,xx=pt.privateNegate=dx,$x=pt.privateSub=fx,Cx=pt.recover=wx,Nx=pt.sign=px,Ux=pt.signRecoverable=yx,Rx=pt.signSchnorr=gx,Bx=pt.verify=bx,Hx=pt.verifySchnorr=mx,Lx=pt.xOnlyPointAddTweak=sx,Kx=pt.xOnlyPointFromPoint=K2,jx=pt.xOnlyPointFromScalar=ox;RT(T5({__proto__:null,default:pt,isPoint:vx,isPointCompressed:Ex,isPrivate:Ax,isXOnlyPoint:Sx,pointAdd:Tx,pointAddScalar:_x,pointCompress:kx,pointFromScalar:Px,pointMultiply:Ox,privateAdd:Ix,privateNegate:xx,privateSub:$x,recover:Cx,sign:Nx,signRecoverable:Ux,signSchnorr:Rx,verify:Bx,verifySchnorr:Hx,xOnlyPointAddTweak:Lx,xOnlyPointFromPoint:Kx,xOnlyPointFromScalar:jx},[pt]));const nr=e=>e===Bt||e===xr||e===Ir?I5:wn,md=e=>e.find(({purpose:t})=>t==="ordinals"),vd=e=>e.find(({purpose:t})=>t==="payment"),Xt=async(e,t)=>{try{const r=await D2(e,t);return r?r.reduce((n,i)=>n+BigInt(i.value),0n):0n}catch(r){throw console.error("Error fetching BTC balance:",r),new Error("Failed to fetch BTC balance")}},Dx=e=>/^(?:[A-Za-z0-9+\/]{4})*?(?:[A-Za-z0-9+\/]{2}==|[A-Za-z0-9+\/]{3}=)?$/.test(e),Mx=e=>/^[a-fA-F0-9]+$/.test(e);function Fx(e,t,r){const n=e*57+t*41,i=r*34;return 10+n+i}async function D2(e,t){if(e.startsWith("t")){if(t===vt)return[];if(t===fo)return[];if(t===$r)return[]}return await Xe.get(`${pi(t)}/api/address/${e}/utxo`).then(r=>r.data)}async function M2(e,t,r,n,i,o,s=7){const a=e===t,u=await D2(t,o);if(!u)throw new Error("No UTXOs found");const f=u.sort((T,x)=>x.value-T.value),h=new dt({network:nr(o)}),d=Fx(1,0,2),g=Math.floor(d*s)+n;let v=0,E=0;for await(let T of f){const{txid:x,vout:N,value:I}=T,k=M1(t,nr(o));if(h.addInput({hash:x,index:N,witnessUtxo:{script:k,value:BigInt(I)}}),!a){const B=Vx(i,o);h.updateInput(E,{redeemScript:B})}if(v+=I,v>=g)break}if(v<g)throw new Error("Insufficient funds");return h.addOutput({address:r,value:BigInt(n)}),v>g&&h.addOutput({address:t,value:BigInt(v-g-n)}),{psbtBase64:h.toBase64(),psbtHex:h.toHex()}}function Vx(e,t){var r;const n=fa({pubkey:k2.Buffer.from(e,"hex"),network:nr(t)}),i=ao({redeem:n,network:nr(t)});return(r=i==null?void 0:i.redeem)==null?void 0:r.output}class zx extends Dn{constructor(){super(...arguments),ge(this,"observer")}get library(){return window.unisat}get network(){return this.$network.get()}initialize(){typeof window<"u"&&typeof document<"u"&&(this.observer=new window.MutationObserver(()=>{var t;this.library&&(this.$store.setKey("hasProvider",{...this.$store.get().hasProvider,[ji]:!0}),(t=this.observer)==null||t.disconnect())}),this.observer.observe(document,{childList:!0,subtree:!0})),gn(this.$store,["provider"],t=>{if(t.provider!==ji){this.removeListeners();return}this.library.getAccounts().then(r=>{this.handleAccountsChanged(r)}),this.addListeners()})}addListeners(){this.library.on("accountsChanged",this.handleAccountsChanged.bind(this)),this.library.on("networkChanged",this.handleNetworkChanged.bind(this))}removeListeners(){this.library.removeListener("accountsChanged",this.handleAccountsChanged.bind(this)),this.library.removeListener("networkChanged",this.handleNetworkChanged.bind(this))}dispose(){var t;(t=this.observer)==null||t.disconnect(),this.removeListeners()}handleAccountsChanged(t){if(!t.length){this.parent.disconnect();return}this.$store.get().accounts[0]!==t[0]&&(this.$store.setKey("accounts",t),t.length>0?this.parent.connect(ji):this.parent.disconnect())}handleNetworkChanged(t){const r=Ea(t);this.network!==r&&this.switchNetwork(r),this.parent.connect(ji)}async connect(t){if(!this.library)throw new Error("Unisat isn't installed");const r=await this.library.requestAccounts();if(!r)throw new Error("No accounts found");const n=await this.library.getPublicKey();if(!n)throw new Error("No public key found");this.$store.setKey("accounts",r),this.$store.setKey("address",r[0]),this.$store.setKey("paymentAddress",r[0]),this.$store.setKey("publicKey",n),this.$store.setKey("paymentPublicKey",n),this.$store.setKey("provider",ji),await this.getNetwork().then(i=>{var o;((o=this.config)==null?void 0:o.network)!==i&&this.switchNetwork(i)}),Xt(r[0],this.network).then(i=>{this.$store.setKey("balance",i)}),this.$store.setKey("connected",!0)}async getNetwork(){var t;const r=await((t=this.library)==null?void 0:t.getChain());return r?Ea(r.enum):this.network}async sendBTC(t,r){var n;const i=await((n=this.library)==null?void 0:n.sendBitcoin(t,r));if(!i)throw new Error("Transaction failed");return i}async signMessage(t,r){var n;return await((n=this.library)==null?void 0:n.signMessage(t))}async signPsbt(t,r,n,i,o){var s;const a=await((s=this.library)==null?void 0:s.signPsbt(r,{autoFinalized:i})),u=dt.fromHex(a);if(i&&o){const f=await this.pushPsbt(a);return{signedPsbtHex:u.toHex(),signedPsbtBase64:u.toBase64(),txId:f}}return{signedPsbtHex:u.toHex(),signedPsbtBase64:u.toBase64(),txId:void 0}}async pushPsbt(t){return await Xe.post(`${pi(this.network)}/api/tx`,t).then(r=>r.data)}async getPublicKey(){var t;return await((t=this.library)==null?void 0:t.getPublicKey())}async getBalance(){return(await this.library.getBalance()).total}async getInscriptions(){return await this.library.getInscriptions(0,10)}async requestAccounts(){return await this.library.requestAccounts()}async switchNetwork(t){var r;const n=Df(t);await((r=this.library)==null?void 0:r.switchChain(n)),this.$network.set(t),await this.getBalance()}}function Wx(){typeof window<"u"&&typeof localStorage<"u"&&setTimeout(()=>{const e=document.createTextNode(" ");document.body.appendChild(e),e.remove()},1500)}function qx(){return{$store:Lg({provider:void 0,address:"",paymentAddress:"",publicKey:"",paymentPublicKey:"",connected:!1,isConnecting:!1,isInitializing:!0,accounts:[],balance:void 0,hasProvider:{[ji]:!1,[ii]:!1,[ms]:!1,[si]:!1,[Fi]:!1,[Es]:!1,[vs]:!1,[Di]:!1,[As]:!1,[Mi]:!1}}),$network:ef(vt),$library:ef(void 0)}}function Gx({network:e}){return{network:e}}function Xx(e,t){var r;return(r=void 0)==null?void 0:r.get(t)}function Wu(e){var t,r;let n=typeof e;return n==="object"&&(n=(e&&((r=(t=Object.getPrototypeOf(e))==null?void 0:t.constructor)==null?void 0:r.name))??"null"),n==="string"?`"${e}"`:n==="number"||n==="bigint"||n==="boolean"?`${e}`:n}function mr(e,t,r,n,i){const o=i&&"input"in i?i.input:r.value,s=(i==null?void 0:i.expected)??e.expects??null,a=(i==null?void 0:i.received)??Wu(o),u={kind:e.kind,type:e.type,input:o,expected:s,received:a,message:`Invalid ${t}: ${s?`Expected ${s} but r`:"R"}eceived ${a}`,requirement:e.requirement,path:i==null?void 0:i.path,issues:i==null?void 0:i.issues,lang:n.lang,abortEarly:n.abortEarly,abortPipeEarly:n.abortPipeEarly},f=e.kind==="schema",h=(i==null?void 0:i.message)??e.message??Xx(e.reference,u.lang)??(f?(u.lang,void 0):null)??n.message??(u.lang,void 0);h&&(u.message=typeof h=="function"?h(u):h),f&&(r.typed=!1),r.issues?r.issues.push(u):r.issues=[u]}function Jx(e,t){return Object.hasOwn(e,t)&&t!=="__proto__"&&t!=="prototype"&&t!=="constructor"}function F2(e,t,r){return typeof e.default=="function"?e.default(t,r):e.default}function V2(e,t){return!e._run({typed:!1,value:t},{abortEarly:!0}).issues}function Tn(e,t){return{kind:"schema",type:"array",reference:Tn,expects:"Array",async:!1,item:e,message:t,_run(r,n){var i;const o=r.value;if(Array.isArray(o)){r.typed=!0,r.value=[];for(let s=0;s<o.length;s++){const a=o[s],u=this.item._run({typed:!1,value:a},n);if(u.issues){const f={type:"array",origin:"value",input:o,key:s,value:a};for(const h of u.issues)h.path?h.path.unshift(f):h.path=[f],(i=r.issues)==null||i.push(h);if(r.issues||(r.issues=u.issues),n.abortEarly){r.typed=!1;break}}u.typed||(r.typed=!1),r.value.push(u.value)}}else mr(this,"type",r,n);return r}}}function z2(e){return{kind:"schema",type:"boolean",reference:z2,expects:"boolean",async:!1,message:e,_run(t,r){return typeof t.value=="boolean"?t.typed=!0:mr(this,"type",t,r),t}}}function xs(e,t){const r=Object.entries(e).filter(([n])=>isNaN(+n)).map(([,n])=>n);return{kind:"schema",type:"enum",reference:xs,expects:r.map(Wu).join(" | ")||"never",async:!1,enum:e,options:r,message:t,_run(n,i){return this.options.includes(n.value)?n.typed=!0:mr(this,"type",n,i),n}}}function yt(e,t){return{kind:"schema",type:"literal",reference:yt,expects:Wu(e),async:!1,literal:e,message:t,_run(r,n){return r.value===this.literal?r.typed=!0:mr(this,"type",r,n),r}}}function W2(e,t){return{kind:"schema",type:"loose_object",reference:W2,expects:"Object",async:!1,entries:e,message:t,_run(r,n){var i;const o=r.value;if(o&&typeof o=="object"){r.typed=!0,r.value={};for(const s in this.entries){const a=o[s],u=this.entries[s]._run({typed:!1,value:a},n);if(u.issues){const f={type:"object",origin:"value",input:o,key:s,value:a};for(const h of u.issues)h.path?h.path.unshift(f):h.path=[f],(i=r.issues)==null||i.push(h);if(r.issues||(r.issues=u.issues),n.abortEarly){r.typed=!1;break}}u.typed||(r.typed=!1),(u.value!==void 0||s in o)&&(r.value[s]=u.value)}if(!r.issues||!n.abortEarly)for(const s in o)Jx(o,s)&&!(s in this.entries)&&(r.value[s]=o[s])}else mr(this,"type",r,n);return r}}}function Ed(e,t){return{kind:"schema",type:"non_optional",reference:Ed,expects:"!undefined",async:!1,wrapped:e,message:t,_run(r,n){return r.value===void 0?(mr(this,"type",r,n),r):this.wrapped._run(r,n)}}}function $s(e){return{kind:"schema",type:"null",reference:$s,expects:"null",async:!1,message:e,_run(t,r){return t.value===null?t.typed=!0:mr(this,"type",t,r),t}}}function Cs(e,...t){const r={kind:"schema",type:"nullish",reference:Cs,expects:`${e.expects} | null | undefined`,async:!1,wrapped:e,_run(n,i){return(n.value===null||n.value===void 0)&&("default"in this&&(n.value=F2(this,n,i)),n.value===null||n.value===void 0)?(n.typed=!0,n):this.wrapped._run(n,i)}};return 0 in t&&(r.default=t[0]),r}function Vn(e){return{kind:"schema",type:"number",reference:Vn,expects:"number",async:!1,message:e,_run(t,r){return typeof t.value=="number"&&!isNaN(t.value)?t.typed=!0:mr(this,"type",t,r),t}}}function fe(e,t){return{kind:"schema",type:"object",reference:fe,expects:"Object",async:!1,entries:e,message:t,_run(r,n){var i;const o=r.value;if(o&&typeof o=="object"){r.typed=!0,r.value={};for(const s in this.entries){const a=o[s],u=this.entries[s]._run({typed:!1,value:a},n);if(u.issues){const f={type:"object",origin:"value",input:o,key:s,value:a};for(const h of u.issues)h.path?h.path.unshift(f):h.path=[f],(i=r.issues)==null||i.push(h);if(r.issues||(r.issues=u.issues),n.abortEarly){r.typed=!1;break}}u.typed||(r.typed=!1),(u.value!==void 0||s in o)&&(r.value[s]=u.value)}}else mr(this,"type",r,n);return r}}}function _n(e,...t){const r={kind:"schema",type:"optional",reference:_n,expects:`${e.expects} | undefined`,async:!1,wrapped:e,_run(n,i){return n.value===void 0&&("default"in this&&(n.value=F2(this,n,i)),n.value===void 0)?(n.typed=!0,n):this.wrapped._run(n,i)}};return 0 in t&&(r.default=t[0]),r}function q2(e,t){return{kind:"schema",type:"picklist",reference:q2,expects:e.map(Wu).join(" | ")||"never",async:!1,options:e,message:t,_run(r,n){return this.options.includes(r.value)?r.typed=!0:mr(this,"type",r,n),r}}}function be(e){return{kind:"schema",type:"string",reference:be,expects:"string",async:!1,message:e,_run(t,r){return typeof t.value=="string"?t.typed=!0:mr(this,"type",t,r),t}}}function Ad(e){return{kind:"schema",type:"undefined",reference:Ad,expects:"undefined",async:!1,message:e,_run(t,r){return t.value===void 0?t.typed=!0:mr(this,"type",t,r),t}}}function G2(e){let t;if(e)for(const r of e)t?t.push(...r.issues):t=r.issues;return t}function qu(e,t){return{kind:"schema",type:"union",reference:qu,expects:[...new Set(e.map(r=>r.expects))].join(" | ")||"never",async:!1,options:e,message:t,_run(r,n){let i,o,s;for(const a of this.options){const u=a._run({typed:!1,value:r.value},n);if(u.typed)if(u.issues)o?o.push(u):o=[u];else{i=u;break}else s?s.push(u):s=[u]}if(i)return i;if(o){if(o.length===1)return o[0];mr(this,"type",r,n,{issues:G2(o)}),r.typed=!0}else{if((s==null?void 0:s.length)===1)return s[0];mr(this,"type",r,n,{issues:G2(s)})}return r}}}function Gu(){return{kind:"schema",type:"unknown",reference:Gu,expects:"unknown",async:!1,_run(e){return e.typed=!0,e}}}var Gr={},vo={},ir={};Object.defineProperty(ir,"__esModule",{value:!0}),ir.decode=ir.encode=ir.unescape=ir.escape=ir.pad=void 0;const X2=go;function Sd(e){return`${e}${"=".repeat(4-(e.length%4||4))}`}ir.pad=Sd;function J2(e){return e.replace(/=/g,"").replace(/\+/g,"-").replace(/\//g,"_")}ir.escape=J2;function Y2(e){return Sd(e).replace(/-/g,"+").replace(/_/g,"/")}ir.unescape=Y2;function Yx(e){return J2((0,X2.fromByteArray)(new TextEncoder().encode(e)))}ir.encode=Yx;function Zx(e){return new TextDecoder().decode((0,X2.toByteArray)(Sd(Y2(e))))}ir.decode=Zx;var Xu={},Ju={},Eo={};Object.defineProperty(Eo,"__esModule",{value:!0}),Eo.joseToDer=Eo.derToJose=void 0;const Z2=go,Q2=ir;function Td(e){return(e/8|0)+(e%8===0?0:1)}const Qx={ES256:Td(256),ES384:Td(384),ES512:Td(521)};function eb(e){const t=Qx[e];if(t)return t;throw new Error(`Unknown algorithm "${e}"`)}const Yu=128,tb=0,e$=32,t$=16,r$=2,rb=t$|e$|tb<<6,Zu=r$|tb<<6;function nb(e){if(e instanceof Uint8Array)return e;if(typeof e=="string")return(0,Z2.toByteArray)((0,Q2.pad)(e));throw new TypeError("ECDSA signature must be a Base64 string or a Uint8Array")}function n$(e,t){const r=nb(e),n=eb(t),i=n+1,o=r.length;let s=0;if(r[s++]!==rb)throw new Error('Could not find expected "seq"');let a=r[s++];if(a===(Yu|1)&&(a=r[s++]),o-s<a)throw new Error(`"seq" specified length of "${a}", only "${o-s}" remaining`);if(r[s++]!==Zu)throw new Error('Could not find expected "int" for "r"');const u=r[s++];if(o-s-2<u)throw new Error(`"r" specified length of "${u}", only "${o-s-2}" available`);if(i<u)throw new Error(`"r" specified length of "${u}", max of "${i}" is acceptable`);const f=s;if(s+=u,r[s++]!==Zu)throw new Error('Could not find expected "int" for "s"');const h=r[s++];if(o-s!==h)throw new Error(`"s" specified length of "${h}", expected "${o-s}"`);if(i<h)throw new Error(`"s" specified length of "${h}", max of "${i}" is acceptable`);const d=s;if(s+=h,s!==o)throw new Error(`Expected to consume entire array, but "${o-s}" bytes remain`);const g=n-u,v=n-h,E=new Uint8Array(g+u+v+h);for(s=0;s<g;++s)E[s]=0;E.set(r.subarray(f+Math.max(-g,0),f+u),s),s=n;for(const T=s;s<T+v;++s)E[s]=0;return E.set(r.subarray(d+Math.max(-v,0),d+h),s),(0,Q2.escape)((0,Z2.fromByteArray)(E))}Eo.derToJose=n$;function ib(e,t,r){let n=0;for(;t+n<r&&e[t+n]===0;)++n;return e[t+n]>=Yu&&--n,n}function i$(e,t){e=nb(e);const r=eb(t),n=e.length;if(n!==r*2)throw new TypeError(`"${t}" signatures must be "${r*2}" bytes, saw "${n}"`);const i=ib(e,0,r),o=ib(e,r,e.length),s=r-i,a=r-o,u=2+s+1+1+a,f=u<Yu,h=new Uint8Array((f?2:3)+u);let d=0;return h[d++]=rb,f?h[d++]=u:(h[d++]=Yu|1,h[d++]=u&255),h[d++]=Zu,h[d++]=s,i<0?(h[d++]=0,h.set(e.subarray(0,r),d),d+=r):(h.set(e.subarray(i,r),d),d+=r-i),h[d++]=Zu,h[d++]=a,o<0?(h[d++]=0,h.set(e.subarray(r),d)):h.set(e.subarray(r+o),d),h}Eo.joseToDer=i$;var gi={};Object.defineProperty(gi,"__esModule",{value:!0}),gi.InvalidTokenError=gi.MissingParametersError=void 0;class s$ extends Error{constructor(t){super(),this.name="MissingParametersError",this.message=t||""}}gi.MissingParametersError=s$;class o$ extends Error{constructor(t){super(),this.name="InvalidTokenError",this.message=t||""}}gi.InvalidTokenError=o$,Object.defineProperty(Ju,"__esModule",{value:!0}),Ju.SECP256K1Client=void 0;const a$=ad,c$=Fn,Qu=od,sb=Eo,ob=gi,ab=ka;Qu.utils.hmacSha256Sync=(e,...t)=>{const r=a$.hmac.create(c$.sha256,e);return t.forEach(n=>r.update(n)),r.digest()};class cb{static derivePublicKey(t,r=!0){return t.length===66&&(t=t.slice(0,64)),t.length<64&&(t=t.padStart(64,"0")),(0,ab.bytesToHex)(Qu.getPublicKey(t,r))}static signHash(t,r,n="jose"){if(!t||!r)throw new ob.MissingParametersError("a signing input hash and private key are all required");const i=Qu.signSync(t,r.slice(0,64),{der:!0,canonical:!1});if(n==="der")return(0,ab.bytesToHex)(i);if(n==="jose")return(0,sb.derToJose)(i,"ES256");throw Error("Invalid signature format")}static loadSignature(t){return(0,sb.joseToDer)(t,"ES256")}static verifyHash(t,r,n){if(!t||!r||!n)throw new ob.MissingParametersError("a signing input hash, der signature, and public key are all required");return Qu.verify(r,t,n,{strict:!1})}}Ju.SECP256K1Client=cb,cb.algorithmName="ES256K",function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.cryptoClients=e.SECP256K1Client=void 0;const t=Ju;Object.defineProperty(e,"SECP256K1Client",{enumerable:!0,get:function(){return t.SECP256K1Client}});const r={ES256K:t.SECP256K1Client};e.cryptoClients=r}(Xu);var Ns={},u$=Te&&Te.__awaiter||function(e,t,r,n){function i(o){return o instanceof r?o:new r(function(s){s(o)})}return new(r||(r=Promise))(function(o,s){function a(h){try{f(n.next(h))}catch(d){s(d)}}function u(h){try{f(n.throw(h))}catch(d){s(d)}}function f(h){h.done?o(h.value):i(h.value).then(a,u)}f((n=n.apply(e,t||[])).next())})};Object.defineProperty(Ns,"__esModule",{value:!0}),Ns.hashSha256Async=Ns.hashSha256=void 0;const l$=Fn;function ub(e){return(0,l$.sha256)(e)}Ns.hashSha256=ub;function h$(e){return u$(this,void 0,void 0,function*(){try{if(typeof crypto<"u"&&typeof crypto.subtle<"u"){const t=typeof e=="string"?new TextEncoder().encode(e):e,r=yield crypto.subtle.digest("SHA-256",t);return new Uint8Array(r)}else{const t=O2;if(!t.createHash)throw new Error("`crypto` module does not contain `createHash`");return Promise.resolve(t.createHash("sha256").update(e).digest())}}catch(t){return console.log(t),console.log('Crypto lib not found. Neither the global `crypto.subtle` Web Crypto API, nor the or the Node.js `require("crypto").createHash` module is available. Falling back to JS implementation.'),Promise.resolve(ub(e))}})}Ns.hashSha256Async=h$;var f$=Te&&Te.__awaiter||function(e,t,r,n){function i(o){return o instanceof r?o:new r(function(s){s(o)})}return new(r||(r=Promise))(function(o,s){function a(h){try{f(n.next(h))}catch(d){s(d)}}function u(h){try{f(n.throw(h))}catch(d){s(d)}}function f(h){h.done?o(h.value):i(h.value).then(a,u)}f((n=n.apply(e,t||[])).next())})};Object.defineProperty(vo,"__esModule",{value:!0}),vo.TokenSigner=vo.createUnsecuredToken=void 0;const _d=ir,lb=Xu,d$=gi,hb=Ns;function kd(e,t){const r=[],n=_d.encode(JSON.stringify(t));r.push(n);const i=_d.encode(JSON.stringify(e));return r.push(i),r.join(".")}function p$(e){return kd(e,{typ:"JWT",alg:"none"})+"."}vo.createUnsecuredToken=p$;class y${constructor(t,r){if(!(t&&r))throw new d$.MissingParametersError("a signing algorithm and private key are required");if(typeof t!="string")throw new Error("signing algorithm parameter must be a string");if(t=t.toUpperCase(),!lb.cryptoClients.hasOwnProperty(t))throw new Error("invalid signing algorithm");this.tokenType="JWT",this.cryptoClient=lb.cryptoClients[t],this.rawPrivateKey=r}header(t={}){const r={typ:this.tokenType,alg:this.cryptoClient.algorithmName};return Object.assign({},r,t)}sign(t,r=!1,n={}){const i=this.header(n),o=kd(t,i),s=(0,hb.hashSha256)(o);return this.createWithSignedHash(t,r,i,o,s)}signAsync(t,r=!1,n={}){return f$(this,void 0,void 0,function*(){const i=this.header(n),o=kd(t,i),s=yield(0,hb.hashSha256Async)(o);return this.createWithSignedHash(t,r,i,o,s)})}createWithSignedHash(t,r,n,i,o){const s=this.cryptoClient.signHash(o,this.rawPrivateKey);return r?{header:[_d.encode(JSON.stringify(n))],payload:JSON.stringify(t),signature:[s]}:[i,s].join(".")}}vo.TokenSigner=y$;var el={};Object.defineProperty(el,"__esModule",{value:!0}),el.TokenVerifier=void 0;const g$=ir,fb=Xu,w$=gi,tl=Ns;class b${constructor(t,r){if(!(t&&r))throw new w$.MissingParametersError("a signing algorithm and public key are required");if(typeof t!="string")throw"signing algorithm parameter must be a string";if(t=t.toUpperCase(),!fb.cryptoClients.hasOwnProperty(t))throw"invalid signing algorithm";this.tokenType="JWT",this.cryptoClient=fb.cryptoClients[t],this.rawPublicKey=r}verify(t){return typeof t=="string"?this.verifyCompact(t,!1):typeof t=="object"?this.verifyExpanded(t,!1):!1}verifyAsync(t){return typeof t=="string"?this.verifyCompact(t,!0):typeof t=="object"?this.verifyExpanded(t,!0):Promise.resolve(!1)}verifyCompact(t,r){const n=t.split("."),i=n[0]+"."+n[1],o=s=>{const a=this.cryptoClient.loadSignature(n[2]);return this.cryptoClient.verifyHash(s,a,this.rawPublicKey)};if(r)return(0,tl.hashSha256Async)(i).then(s=>o(s));{const s=(0,tl.hashSha256)(i);return o(s)}}verifyExpanded(t,r){const n=[t.header.join("."),g$.encode(t.payload)].join(".");let i=!0;const o=s=>(t.signature.map(a=>{const u=this.cryptoClient.loadSignature(a);this.cryptoClient.verifyHash(s,u,this.rawPublicKey)||(i=!1)}),i);if(r)return(0,tl.hashSha256Async)(n).then(s=>o(s));{const s=(0,tl.hashSha256)(n);return o(s)}}}el.TokenVerifier=b$;var rl={};Object.defineProperty(rl,"__esModule",{value:!0}),rl.decodeToken=void 0;const nl=ir;function m$(e){if(typeof e=="string"){const t=e.split("."),r=JSON.parse(nl.decode(t[0])),n=JSON.parse(nl.decode(t[1])),i=t[2];return{header:r,payload:n,signature:i}}else if(typeof e=="object"){if(typeof e.payload!="string")throw new Error("Expected token payload to be a base64 or json string");let t=e.payload;e.payload[0]!=="{"&&(t=nl.decode(t));const r=[];return e.header.map(n=>{const i=JSON.parse(nl.decode(n));r.push(i)}),{header:r,payload:JSON.parse(t),signature:e.signature}}}rl.decodeToken=m$,function(e){var t=Te&&Te.__createBinding||(Object.create?function(n,i,o,s){s===void 0&&(s=o);var a=Object.getOwnPropertyDescriptor(i,o);(!a||("get"in a?!i.__esModule:a.writable||a.configurable))&&(a={enumerable:!0,get:function(){return i[o]}}),Object.defineProperty(n,s,a)}:function(n,i,o,s){s===void 0&&(s=o),n[s]=i[o]}),r=Te&&Te.__exportStar||function(n,i){for(var o in n)o!=="default"&&!Object.prototype.hasOwnProperty.call(i,o)&&t(i,n,o)};Object.defineProperty(e,"__esModule",{value:!0}),r(vo,e),r(el,e),r(rl,e),r(gi,e),r(Xu,e)}(Gr);/*! *****************************************************************************
44
+ */(function(e){const t=go,r=sd,n=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):null;e.Buffer=a,e.SlowBuffer=I,e.INSPECT_MAX_BYTES=50;const i=2147483647;e.kMaxLength=i,a.TYPED_ARRAY_SUPPORT=o(),!a.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 o(){try{const c=new Uint8Array(1),l={foo:function(){return 42}};return Object.setPrototypeOf(l,Uint8Array.prototype),Object.setPrototypeOf(c,l),c.foo()===42}catch{return!1}}Object.defineProperty(a.prototype,"parent",{enumerable:!0,get:function(){if(a.isBuffer(this))return this.buffer}}),Object.defineProperty(a.prototype,"offset",{enumerable:!0,get:function(){if(a.isBuffer(this))return this.byteOffset}});function s(c){if(c>i)throw new RangeError('The value "'+c+'" is invalid for option "size"');const l=new Uint8Array(c);return Object.setPrototypeOf(l,a.prototype),l}function a(c,l,p){if(typeof c=="number"){if(typeof l=="string")throw new TypeError('The "string" argument must be of type string. Received type number');return d(c)}return u(c,l,p)}a.poolSize=8192;function u(c,l,p){if(typeof c=="string")return g(c,l);if(ArrayBuffer.isView(c))return E(c);if(c==null)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof c);if(ze(c,ArrayBuffer)||c&&ze(c.buffer,ArrayBuffer)||typeof SharedArrayBuffer<"u"&&(ze(c,SharedArrayBuffer)||c&&ze(c.buffer,SharedArrayBuffer)))return T(c,l,p);if(typeof c=="number")throw new TypeError('The "value" argument must not be of type number. Received type number');const m=c.valueOf&&c.valueOf();if(m!=null&&m!==c)return a.from(m,l,p);const S=x(c);if(S)return S;if(typeof Symbol<"u"&&Symbol.toPrimitive!=null&&typeof c[Symbol.toPrimitive]=="function")return a.from(c[Symbol.toPrimitive]("string"),l,p);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof c)}a.from=function(c,l,p){return u(c,l,p)},Object.setPrototypeOf(a.prototype,Uint8Array.prototype),Object.setPrototypeOf(a,Uint8Array);function f(c){if(typeof c!="number")throw new TypeError('"size" argument must be of type number');if(c<0)throw new RangeError('The value "'+c+'" is invalid for option "size"')}function h(c,l,p){return f(c),c<=0?s(c):l!==void 0?typeof p=="string"?s(c).fill(l,p):s(c).fill(l):s(c)}a.alloc=function(c,l,p){return h(c,l,p)};function d(c){return f(c),s(c<0?0:N(c)|0)}a.allocUnsafe=function(c){return d(c)},a.allocUnsafeSlow=function(c){return d(c)};function g(c,l){if((typeof l!="string"||l==="")&&(l="utf8"),!a.isEncoding(l))throw new TypeError("Unknown encoding: "+l);const p=k(c,l)|0;let m=s(p);const S=m.write(c,l);return S!==p&&(m=m.slice(0,S)),m}function v(c){const l=c.length<0?0:N(c.length)|0,p=s(l);for(let m=0;m<l;m+=1)p[m]=c[m]&255;return p}function E(c){if(ze(c,Uint8Array)){const l=new Uint8Array(c);return T(l.buffer,l.byteOffset,l.byteLength)}return v(c)}function T(c,l,p){if(l<0||c.byteLength<l)throw new RangeError('"offset" is outside of buffer bounds');if(c.byteLength<l+(p||0))throw new RangeError('"length" is outside of buffer bounds');let m;return l===void 0&&p===void 0?m=new Uint8Array(c):p===void 0?m=new Uint8Array(c,l):m=new Uint8Array(c,l,p),Object.setPrototypeOf(m,a.prototype),m}function x(c){if(a.isBuffer(c)){const l=N(c.length)|0,p=s(l);return p.length===0||c.copy(p,0,0,l),p}if(c.length!==void 0)return typeof c.length!="number"||sr(c.length)?s(0):v(c);if(c.type==="Buffer"&&Array.isArray(c.data))return v(c.data)}function N(c){if(c>=i)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+i.toString(16)+" bytes");return c|0}function I(c){return+c!=c&&(c=0),a.alloc(+c)}a.isBuffer=function(c){return c!=null&&c._isBuffer===!0&&c!==a.prototype},a.compare=function(c,l){if(ze(c,Uint8Array)&&(c=a.from(c,c.offset,c.byteLength)),ze(l,Uint8Array)&&(l=a.from(l,l.offset,l.byteLength)),!a.isBuffer(c)||!a.isBuffer(l))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(c===l)return 0;let p=c.length,m=l.length;for(let S=0,O=Math.min(p,m);S<O;++S)if(c[S]!==l[S]){p=c[S],m=l[S];break}return p<m?-1:m<p?1:0},a.isEncoding=function(c){switch(String(c).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}},a.concat=function(c,l){if(!Array.isArray(c))throw new TypeError('"list" argument must be an Array of Buffers');if(c.length===0)return a.alloc(0);let p;if(l===void 0)for(l=0,p=0;p<c.length;++p)l+=c[p].length;const m=a.allocUnsafe(l);let S=0;for(p=0;p<c.length;++p){let O=c[p];if(ze(O,Uint8Array))S+O.length>m.length?(a.isBuffer(O)||(O=a.from(O)),O.copy(m,S)):Uint8Array.prototype.set.call(m,O,S);else if(a.isBuffer(O))O.copy(m,S);else throw new TypeError('"list" argument must be an Array of Buffers');S+=O.length}return m};function k(c,l){if(a.isBuffer(c))return c.length;if(ArrayBuffer.isView(c)||ze(c,ArrayBuffer))return c.byteLength;if(typeof c!="string")throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof c);const p=c.length,m=arguments.length>2&&arguments[2]===!0;if(!m&&p===0)return 0;let S=!1;for(;;)switch(l){case"ascii":case"latin1":case"binary":return p;case"utf8":case"utf-8":return Lt(c).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return p*2;case"hex":return p>>>1;case"base64":return On(c).length;default:if(S)return m?-1:Lt(c).length;l=(""+l).toLowerCase(),S=!0}}a.byteLength=k;function B(c,l,p){let m=!1;if((l===void 0||l<0)&&(l=0),l>this.length||((p===void 0||p>this.length)&&(p=this.length),p<=0)||(p>>>=0,l>>>=0,p<=l))return"";for(c||(c="utf8");;)switch(c){case"hex":return je(this,l,p);case"utf8":case"utf-8":return oe(this,l,p);case"ascii":return Ae(this,l,p);case"latin1":case"binary":return Et(this,l,p);case"base64":return F(this,l,p);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return Ce(this,l,p);default:if(m)throw new TypeError("Unknown encoding: "+c);c=(c+"").toLowerCase(),m=!0}}a.prototype._isBuffer=!0;function W(c,l,p){const m=c[l];c[l]=c[p],c[p]=m}a.prototype.swap16=function(){const c=this.length;if(c%2!==0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(let l=0;l<c;l+=2)W(this,l,l+1);return this},a.prototype.swap32=function(){const c=this.length;if(c%4!==0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(let l=0;l<c;l+=4)W(this,l,l+3),W(this,l+1,l+2);return this},a.prototype.swap64=function(){const c=this.length;if(c%8!==0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(let l=0;l<c;l+=8)W(this,l,l+7),W(this,l+1,l+6),W(this,l+2,l+5),W(this,l+3,l+4);return this},a.prototype.toString=function(){const c=this.length;return c===0?"":arguments.length===0?oe(this,0,c):B.apply(this,arguments)},a.prototype.toLocaleString=a.prototype.toString,a.prototype.equals=function(c){if(!a.isBuffer(c))throw new TypeError("Argument must be a Buffer");return this===c?!0:a.compare(this,c)===0},a.prototype.inspect=function(){let c="";const l=e.INSPECT_MAX_BYTES;return c=this.toString("hex",0,l).replace(/(.{2})/g,"$1 ").trim(),this.length>l&&(c+=" ... "),"<Buffer "+c+">"},n&&(a.prototype[n]=a.prototype.inspect),a.prototype.compare=function(c,l,p,m,S){if(ze(c,Uint8Array)&&(c=a.from(c,c.offset,c.byteLength)),!a.isBuffer(c))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof c);if(l===void 0&&(l=0),p===void 0&&(p=c?c.length:0),m===void 0&&(m=0),S===void 0&&(S=this.length),l<0||p>c.length||m<0||S>this.length)throw new RangeError("out of range index");if(m>=S&&l>=p)return 0;if(m>=S)return-1;if(l>=p)return 1;if(l>>>=0,p>>>=0,m>>>=0,S>>>=0,this===c)return 0;let O=S-m,U=p-l;const ce=Math.min(O,U),ke=this.slice(m,S),le=c.slice(l,p);for(let ae=0;ae<ce;++ae)if(ke[ae]!==le[ae]){O=ke[ae],U=le[ae];break}return O<U?-1:U<O?1:0};function V(c,l,p,m,S){if(c.length===0)return-1;if(typeof p=="string"?(m=p,p=0):p>2147483647?p=2147483647:p<-2147483648&&(p=-2147483648),p=+p,sr(p)&&(p=S?0:c.length-1),p<0&&(p=c.length+p),p>=c.length){if(S)return-1;p=c.length-1}else if(p<0)if(S)p=0;else return-1;if(typeof l=="string"&&(l=a.from(l,m)),a.isBuffer(l))return l.length===0?-1:Ue(c,l,p,m,S);if(typeof l=="number")return l=l&255,typeof Uint8Array.prototype.indexOf=="function"?S?Uint8Array.prototype.indexOf.call(c,l,p):Uint8Array.prototype.lastIndexOf.call(c,l,p):Ue(c,[l],p,m,S);throw new TypeError("val must be string, number or Buffer")}function Ue(c,l,p,m,S){let O=1,U=c.length,ce=l.length;if(m!==void 0&&(m=String(m).toLowerCase(),m==="ucs2"||m==="ucs-2"||m==="utf16le"||m==="utf-16le")){if(c.length<2||l.length<2)return-1;O=2,U/=2,ce/=2,p/=2}function ke(ae,me){return O===1?ae[me]:ae.readUInt16BE(me*O)}let le;if(S){let ae=-1;for(le=p;le<U;le++)if(ke(c,le)===ke(l,ae===-1?0:le-ae)){if(ae===-1&&(ae=le),le-ae+1===ce)return ae*O}else ae!==-1&&(le-=le-ae),ae=-1}else for(p+ce>U&&(p=U-ce),le=p;le>=0;le--){let ae=!0;for(let me=0;me<ce;me++)if(ke(c,le+me)!==ke(l,me)){ae=!1;break}if(ae)return le}return-1}a.prototype.includes=function(c,l,p){return this.indexOf(c,l,p)!==-1},a.prototype.indexOf=function(c,l,p){return V(this,c,l,p,!0)},a.prototype.lastIndexOf=function(c,l,p){return V(this,c,l,p,!1)};function Le(c,l,p,m){p=Number(p)||0;const S=c.length-p;m?(m=Number(m),m>S&&(m=S)):m=S;const O=l.length;m>O/2&&(m=O/2);let U;for(U=0;U<m;++U){const ce=parseInt(l.substr(U*2,2),16);if(sr(ce))return U;c[p+U]=ce}return U}function Je(c,l,p,m){return Mt(Lt(l,c.length-p),c,p,m)}function Fe(c,l,p,m){return Mt(Xr(l),c,p,m)}function Ye(c,l,p,m){return Mt(On(l),c,p,m)}function C(c,l,p,m){return Mt(Jr(l,c.length-p),c,p,m)}a.prototype.write=function(c,l,p,m){if(l===void 0)m="utf8",p=this.length,l=0;else if(p===void 0&&typeof l=="string")m=l,p=this.length,l=0;else if(isFinite(l))l=l>>>0,isFinite(p)?(p=p>>>0,m===void 0&&(m="utf8")):(m=p,p=void 0);else throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");const S=this.length-l;if((p===void 0||p>S)&&(p=S),c.length>0&&(p<0||l<0)||l>this.length)throw new RangeError("Attempt to write outside buffer bounds");m||(m="utf8");let O=!1;for(;;)switch(m){case"hex":return Le(this,c,l,p);case"utf8":case"utf-8":return Je(this,c,l,p);case"ascii":case"latin1":case"binary":return Fe(this,c,l,p);case"base64":return Ye(this,c,l,p);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return C(this,c,l,p);default:if(O)throw new TypeError("Unknown encoding: "+m);m=(""+m).toLowerCase(),O=!0}},a.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function F(c,l,p){return l===0&&p===c.length?t.fromByteArray(c):t.fromByteArray(c.slice(l,p))}function oe(c,l,p){p=Math.min(c.length,p);const m=[];let S=l;for(;S<p;){const O=c[S];let U=null,ce=O>239?4:O>223?3:O>191?2:1;if(S+ce<=p){let ke,le,ae,me;switch(ce){case 1:O<128&&(U=O);break;case 2:ke=c[S+1],(ke&192)===128&&(me=(O&31)<<6|ke&63,me>127&&(U=me));break;case 3:ke=c[S+1],le=c[S+2],(ke&192)===128&&(le&192)===128&&(me=(O&15)<<12|(ke&63)<<6|le&63,me>2047&&(me<55296||me>57343)&&(U=me));break;case 4:ke=c[S+1],le=c[S+2],ae=c[S+3],(ke&192)===128&&(le&192)===128&&(ae&192)===128&&(me=(O&15)<<18|(ke&63)<<12|(le&63)<<6|ae&63,me>65535&&me<1114112&&(U=me))}}U===null?(U=65533,ce=1):U>65535&&(U-=65536,m.push(U>>>10&1023|55296),U=56320|U&1023),m.push(U),S+=ce}return ue(m)}const J=4096;function ue(c){const l=c.length;if(l<=J)return String.fromCharCode.apply(String,c);let p="",m=0;for(;m<l;)p+=String.fromCharCode.apply(String,c.slice(m,m+=J));return p}function Ae(c,l,p){let m="";p=Math.min(c.length,p);for(let S=l;S<p;++S)m+=String.fromCharCode(c[S]&127);return m}function Et(c,l,p){let m="";p=Math.min(c.length,p);for(let S=l;S<p;++S)m+=String.fromCharCode(c[S]);return m}function je(c,l,p){const m=c.length;(!l||l<0)&&(l=0),(!p||p<0||p>m)&&(p=m);let S="";for(let O=l;O<p;++O)S+=wi[c[O]];return S}function Ce(c,l,p){const m=c.slice(l,p);let S="";for(let O=0;O<m.length-1;O+=2)S+=String.fromCharCode(m[O]+m[O+1]*256);return S}a.prototype.slice=function(c,l){const p=this.length;c=~~c,l=l===void 0?p:~~l,c<0?(c+=p,c<0&&(c=0)):c>p&&(c=p),l<0?(l+=p,l<0&&(l=0)):l>p&&(l=p),l<c&&(l=c);const m=this.subarray(c,l);return Object.setPrototypeOf(m,a.prototype),m};function re(c,l,p){if(c%1!==0||c<0)throw new RangeError("offset is not uint");if(c+l>p)throw new RangeError("Trying to access beyond buffer length")}a.prototype.readUintLE=a.prototype.readUIntLE=function(c,l,p){c=c>>>0,l=l>>>0,p||re(c,l,this.length);let m=this[c],S=1,O=0;for(;++O<l&&(S*=256);)m+=this[c+O]*S;return m},a.prototype.readUintBE=a.prototype.readUIntBE=function(c,l,p){c=c>>>0,l=l>>>0,p||re(c,l,this.length);let m=this[c+--l],S=1;for(;l>0&&(S*=256);)m+=this[c+--l]*S;return m},a.prototype.readUint8=a.prototype.readUInt8=function(c,l){return c=c>>>0,l||re(c,1,this.length),this[c]},a.prototype.readUint16LE=a.prototype.readUInt16LE=function(c,l){return c=c>>>0,l||re(c,2,this.length),this[c]|this[c+1]<<8},a.prototype.readUint16BE=a.prototype.readUInt16BE=function(c,l){return c=c>>>0,l||re(c,2,this.length),this[c]<<8|this[c+1]},a.prototype.readUint32LE=a.prototype.readUInt32LE=function(c,l){return c=c>>>0,l||re(c,4,this.length),(this[c]|this[c+1]<<8|this[c+2]<<16)+this[c+3]*16777216},a.prototype.readUint32BE=a.prototype.readUInt32BE=function(c,l){return c=c>>>0,l||re(c,4,this.length),this[c]*16777216+(this[c+1]<<16|this[c+2]<<8|this[c+3])},a.prototype.readBigUInt64LE=rt(function(c){c=c>>>0,Ve(c,"offset");const l=this[c],p=this[c+7];(l===void 0||p===void 0)&&wt(c,this.length-8);const m=l+this[++c]*2**8+this[++c]*2**16+this[++c]*2**24,S=this[++c]+this[++c]*2**8+this[++c]*2**16+p*2**24;return BigInt(m)+(BigInt(S)<<BigInt(32))}),a.prototype.readBigUInt64BE=rt(function(c){c=c>>>0,Ve(c,"offset");const l=this[c],p=this[c+7];(l===void 0||p===void 0)&&wt(c,this.length-8);const m=l*2**24+this[++c]*2**16+this[++c]*2**8+this[++c],S=this[++c]*2**24+this[++c]*2**16+this[++c]*2**8+p;return(BigInt(m)<<BigInt(32))+BigInt(S)}),a.prototype.readIntLE=function(c,l,p){c=c>>>0,l=l>>>0,p||re(c,l,this.length);let m=this[c],S=1,O=0;for(;++O<l&&(S*=256);)m+=this[c+O]*S;return S*=128,m>=S&&(m-=Math.pow(2,8*l)),m},a.prototype.readIntBE=function(c,l,p){c=c>>>0,l=l>>>0,p||re(c,l,this.length);let m=l,S=1,O=this[c+--m];for(;m>0&&(S*=256);)O+=this[c+--m]*S;return S*=128,O>=S&&(O-=Math.pow(2,8*l)),O},a.prototype.readInt8=function(c,l){return c=c>>>0,l||re(c,1,this.length),this[c]&128?(255-this[c]+1)*-1:this[c]},a.prototype.readInt16LE=function(c,l){c=c>>>0,l||re(c,2,this.length);const p=this[c]|this[c+1]<<8;return p&32768?p|4294901760:p},a.prototype.readInt16BE=function(c,l){c=c>>>0,l||re(c,2,this.length);const p=this[c+1]|this[c]<<8;return p&32768?p|4294901760:p},a.prototype.readInt32LE=function(c,l){return c=c>>>0,l||re(c,4,this.length),this[c]|this[c+1]<<8|this[c+2]<<16|this[c+3]<<24},a.prototype.readInt32BE=function(c,l){return c=c>>>0,l||re(c,4,this.length),this[c]<<24|this[c+1]<<16|this[c+2]<<8|this[c+3]},a.prototype.readBigInt64LE=rt(function(c){c=c>>>0,Ve(c,"offset");const l=this[c],p=this[c+7];(l===void 0||p===void 0)&&wt(c,this.length-8);const m=this[c+4]+this[c+5]*2**8+this[c+6]*2**16+(p<<24);return(BigInt(m)<<BigInt(32))+BigInt(l+this[++c]*2**8+this[++c]*2**16+this[++c]*2**24)}),a.prototype.readBigInt64BE=rt(function(c){c=c>>>0,Ve(c,"offset");const l=this[c],p=this[c+7];(l===void 0||p===void 0)&&wt(c,this.length-8);const m=(l<<24)+this[++c]*2**16+this[++c]*2**8+this[++c];return(BigInt(m)<<BigInt(32))+BigInt(this[++c]*2**24+this[++c]*2**16+this[++c]*2**8+p)}),a.prototype.readFloatLE=function(c,l){return c=c>>>0,l||re(c,4,this.length),r.read(this,c,!0,23,4)},a.prototype.readFloatBE=function(c,l){return c=c>>>0,l||re(c,4,this.length),r.read(this,c,!1,23,4)},a.prototype.readDoubleLE=function(c,l){return c=c>>>0,l||re(c,8,this.length),r.read(this,c,!0,52,8)},a.prototype.readDoubleBE=function(c,l){return c=c>>>0,l||re(c,8,this.length),r.read(this,c,!1,52,8)};function Ne(c,l,p,m,S,O){if(!a.isBuffer(c))throw new TypeError('"buffer" argument must be a Buffer instance');if(l>S||l<O)throw new RangeError('"value" argument is out of bounds');if(p+m>c.length)throw new RangeError("Index out of range")}a.prototype.writeUintLE=a.prototype.writeUIntLE=function(c,l,p,m){if(c=+c,l=l>>>0,p=p>>>0,!m){const U=Math.pow(2,8*p)-1;Ne(this,c,l,p,U,0)}let S=1,O=0;for(this[l]=c&255;++O<p&&(S*=256);)this[l+O]=c/S&255;return l+p},a.prototype.writeUintBE=a.prototype.writeUIntBE=function(c,l,p,m){if(c=+c,l=l>>>0,p=p>>>0,!m){const U=Math.pow(2,8*p)-1;Ne(this,c,l,p,U,0)}let S=p-1,O=1;for(this[l+S]=c&255;--S>=0&&(O*=256);)this[l+S]=c/O&255;return l+p},a.prototype.writeUint8=a.prototype.writeUInt8=function(c,l,p){return c=+c,l=l>>>0,p||Ne(this,c,l,1,255,0),this[l]=c&255,l+1},a.prototype.writeUint16LE=a.prototype.writeUInt16LE=function(c,l,p){return c=+c,l=l>>>0,p||Ne(this,c,l,2,65535,0),this[l]=c&255,this[l+1]=c>>>8,l+2},a.prototype.writeUint16BE=a.prototype.writeUInt16BE=function(c,l,p){return c=+c,l=l>>>0,p||Ne(this,c,l,2,65535,0),this[l]=c>>>8,this[l+1]=c&255,l+2},a.prototype.writeUint32LE=a.prototype.writeUInt32LE=function(c,l,p){return c=+c,l=l>>>0,p||Ne(this,c,l,4,4294967295,0),this[l+3]=c>>>24,this[l+2]=c>>>16,this[l+1]=c>>>8,this[l]=c&255,l+4},a.prototype.writeUint32BE=a.prototype.writeUInt32BE=function(c,l,p){return c=+c,l=l>>>0,p||Ne(this,c,l,4,4294967295,0),this[l]=c>>>24,this[l+1]=c>>>16,this[l+2]=c>>>8,this[l+3]=c&255,l+4};function L(c,l,p,m,S){Er(l,m,S,c,p,7);let O=Number(l&BigInt(4294967295));c[p++]=O,O=O>>8,c[p++]=O,O=O>>8,c[p++]=O,O=O>>8,c[p++]=O;let U=Number(l>>BigInt(32)&BigInt(4294967295));return c[p++]=U,U=U>>8,c[p++]=U,U=U>>8,c[p++]=U,U=U>>8,c[p++]=U,p}function He(c,l,p,m,S){Er(l,m,S,c,p,7);let O=Number(l&BigInt(4294967295));c[p+7]=O,O=O>>8,c[p+6]=O,O=O>>8,c[p+5]=O,O=O>>8,c[p+4]=O;let U=Number(l>>BigInt(32)&BigInt(4294967295));return c[p+3]=U,U=U>>8,c[p+2]=U,U=U>>8,c[p+1]=U,U=U>>8,c[p]=U,p+8}a.prototype.writeBigUInt64LE=rt(function(c,l=0){return L(this,c,l,BigInt(0),BigInt("0xffffffffffffffff"))}),a.prototype.writeBigUInt64BE=rt(function(c,l=0){return He(this,c,l,BigInt(0),BigInt("0xffffffffffffffff"))}),a.prototype.writeIntLE=function(c,l,p,m){if(c=+c,l=l>>>0,!m){const ce=Math.pow(2,8*p-1);Ne(this,c,l,p,ce-1,-ce)}let S=0,O=1,U=0;for(this[l]=c&255;++S<p&&(O*=256);)c<0&&U===0&&this[l+S-1]!==0&&(U=1),this[l+S]=(c/O>>0)-U&255;return l+p},a.prototype.writeIntBE=function(c,l,p,m){if(c=+c,l=l>>>0,!m){const ce=Math.pow(2,8*p-1);Ne(this,c,l,p,ce-1,-ce)}let S=p-1,O=1,U=0;for(this[l+S]=c&255;--S>=0&&(O*=256);)c<0&&U===0&&this[l+S+1]!==0&&(U=1),this[l+S]=(c/O>>0)-U&255;return l+p},a.prototype.writeInt8=function(c,l,p){return c=+c,l=l>>>0,p||Ne(this,c,l,1,127,-128),c<0&&(c=255+c+1),this[l]=c&255,l+1},a.prototype.writeInt16LE=function(c,l,p){return c=+c,l=l>>>0,p||Ne(this,c,l,2,32767,-32768),this[l]=c&255,this[l+1]=c>>>8,l+2},a.prototype.writeInt16BE=function(c,l,p){return c=+c,l=l>>>0,p||Ne(this,c,l,2,32767,-32768),this[l]=c>>>8,this[l+1]=c&255,l+2},a.prototype.writeInt32LE=function(c,l,p){return c=+c,l=l>>>0,p||Ne(this,c,l,4,2147483647,-2147483648),this[l]=c&255,this[l+1]=c>>>8,this[l+2]=c>>>16,this[l+3]=c>>>24,l+4},a.prototype.writeInt32BE=function(c,l,p){return c=+c,l=l>>>0,p||Ne(this,c,l,4,2147483647,-2147483648),c<0&&(c=4294967295+c+1),this[l]=c>>>24,this[l+1]=c>>>16,this[l+2]=c>>>8,this[l+3]=c&255,l+4},a.prototype.writeBigInt64LE=rt(function(c,l=0){return L(this,c,l,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))}),a.prototype.writeBigInt64BE=rt(function(c,l=0){return He(this,c,l,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});function Pn(c,l,p,m,S,O){if(p+m>c.length)throw new RangeError("Index out of range");if(p<0)throw new RangeError("Index out of range")}function gt(c,l,p,m,S){return l=+l,p=p>>>0,S||Pn(c,l,p,4),r.write(c,l,p,m,23,4),p+4}a.prototype.writeFloatLE=function(c,l,p){return gt(this,c,l,!0,p)},a.prototype.writeFloatBE=function(c,l,p){return gt(this,c,l,!1,p)};function Nr(c,l,p,m,S){return l=+l,p=p>>>0,S||Pn(c,l,p,8),r.write(c,l,p,m,52,8),p+8}a.prototype.writeDoubleLE=function(c,l,p){return Nr(this,c,l,!0,p)},a.prototype.writeDoubleBE=function(c,l,p){return Nr(this,c,l,!1,p)},a.prototype.copy=function(c,l,p,m){if(!a.isBuffer(c))throw new TypeError("argument should be a Buffer");if(p||(p=0),!m&&m!==0&&(m=this.length),l>=c.length&&(l=c.length),l||(l=0),m>0&&m<p&&(m=p),m===p||c.length===0||this.length===0)return 0;if(l<0)throw new RangeError("targetStart out of bounds");if(p<0||p>=this.length)throw new RangeError("Index out of range");if(m<0)throw new RangeError("sourceEnd out of bounds");m>this.length&&(m=this.length),c.length-l<m-p&&(m=c.length-l+p);const S=m-p;return this===c&&typeof Uint8Array.prototype.copyWithin=="function"?this.copyWithin(l,p,m):Uint8Array.prototype.set.call(c,this.subarray(p,m),l),S},a.prototype.fill=function(c,l,p,m){if(typeof c=="string"){if(typeof l=="string"?(m=l,l=0,p=this.length):typeof p=="string"&&(m=p,p=this.length),m!==void 0&&typeof m!="string")throw new TypeError("encoding must be a string");if(typeof m=="string"&&!a.isEncoding(m))throw new TypeError("Unknown encoding: "+m);if(c.length===1){const O=c.charCodeAt(0);(m==="utf8"&&O<128||m==="latin1")&&(c=O)}}else typeof c=="number"?c=c&255:typeof c=="boolean"&&(c=Number(c));if(l<0||this.length<l||this.length<p)throw new RangeError("Out of range index");if(p<=l)return this;l=l>>>0,p=p===void 0?this.length:p>>>0,c||(c=0);let S;if(typeof c=="number")for(S=l;S<p;++S)this[S]=c;else{const O=a.isBuffer(c)?c:a.from(c,m),U=O.length;if(U===0)throw new TypeError('The value "'+c+'" is invalid for argument "value"');for(S=0;S<p-l;++S)this[S+l]=O[S%U]}return this};const At={};function Ht(c,l,p){At[c]=class extends p{constructor(){super(),Object.defineProperty(this,"message",{value:l.apply(this,arguments),writable:!0,configurable:!0}),this.name=`${this.name} [${c}]`,this.stack,delete this.name}get code(){return c}set code(m){Object.defineProperty(this,"code",{configurable:!0,enumerable:!0,value:m,writable:!0})}toString(){return`${this.name} [${c}]: ${this.message}`}}}Ht("ERR_BUFFER_OUT_OF_BOUNDS",function(c){return c?`${c} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"},RangeError),Ht("ERR_INVALID_ARG_TYPE",function(c,l){return`The "${c}" argument must be of type number. Received type ${typeof l}`},TypeError),Ht("ERR_OUT_OF_RANGE",function(c,l,p){let m=`The value of "${c}" is out of range.`,S=p;return Number.isInteger(p)&&Math.abs(p)>2**32?S=st(String(p)):typeof p=="bigint"&&(S=String(p),(p>BigInt(2)**BigInt(32)||p<-(BigInt(2)**BigInt(32)))&&(S=st(S)),S+="n"),m+=` It must be ${l}. Received ${S}`,m},RangeError);function st(c){let l="",p=c.length;const m=c[0]==="-"?1:0;for(;p>=m+4;p-=3)l=`_${c.slice(p-3,p)}${l}`;return`${c.slice(0,p)}${l}`}function Dt(c,l,p){Ve(l,"offset"),(c[l]===void 0||c[l+p]===void 0)&&wt(l,c.length-(p+1))}function Er(c,l,p,m,S,O){if(c>p||c<l){const U=typeof l=="bigint"?"n":"";let ce;throw l===0||l===BigInt(0)?ce=`>= 0${U} and < 2${U} ** ${(O+1)*8}${U}`:ce=`>= -(2${U} ** ${(O+1)*8-1}${U}) and < 2 ** ${(O+1)*8-1}${U}`,new At.ERR_OUT_OF_RANGE("value",ce,c)}Dt(m,S,O)}function Ve(c,l){if(typeof c!="number")throw new At.ERR_INVALID_ARG_TYPE(l,"number",c)}function wt(c,l,p){throw Math.floor(c)!==c?(Ve(c,p),new At.ERR_OUT_OF_RANGE("offset","an integer",c)):l<0?new At.ERR_BUFFER_OUT_OF_BOUNDS:new At.ERR_OUT_OF_RANGE("offset",`>= 0 and <= ${l}`,c)}const Ar=/[^+/0-9A-Za-z-_]/g;function nt(c){if(c=c.split("=")[0],c=c.trim().replace(Ar,""),c.length<2)return"";for(;c.length%4!==0;)c=c+"=";return c}function Lt(c,l){l=l||1/0;let p;const m=c.length;let S=null;const O=[];for(let U=0;U<m;++U){if(p=c.charCodeAt(U),p>55295&&p<57344){if(!S){if(p>56319){(l-=3)>-1&&O.push(239,191,189);continue}else if(U+1===m){(l-=3)>-1&&O.push(239,191,189);continue}S=p;continue}if(p<56320){(l-=3)>-1&&O.push(239,191,189),S=p;continue}p=(S-55296<<10|p-56320)+65536}else S&&(l-=3)>-1&&O.push(239,191,189);if(S=null,p<128){if((l-=1)<0)break;O.push(p)}else if(p<2048){if((l-=2)<0)break;O.push(p>>6|192,p&63|128)}else if(p<65536){if((l-=3)<0)break;O.push(p>>12|224,p>>6&63|128,p&63|128)}else if(p<1114112){if((l-=4)<0)break;O.push(p>>18|240,p>>12&63|128,p>>6&63|128,p&63|128)}else throw new Error("Invalid code point")}return O}function Xr(c){const l=[];for(let p=0;p<c.length;++p)l.push(c.charCodeAt(p)&255);return l}function Jr(c,l){let p,m,S;const O=[];for(let U=0;U<c.length&&!((l-=2)<0);++U)p=c.charCodeAt(U),m=p>>8,S=p%256,O.push(S),O.push(m);return O}function On(c){return t.toByteArray(nt(c))}function Mt(c,l,p,m){let S;for(S=0;S<m&&!(S+p>=l.length||S>=c.length);++S)l[S+p]=c[S];return S}function ze(c,l){return c instanceof l||c!=null&&c.constructor!=null&&c.constructor.name!=null&&c.constructor.name===l.name}function sr(c){return c!==c}const wi=function(){const c="0123456789abcdef",l=new Array(256);for(let p=0;p<16;++p){const m=p*16;for(let S=0;S<16;++S)l[m+S]=c[p]+c[S]}return l}();function rt(c){return typeof BigInt>"u"?Yr:c}function Yr(){throw new Error("BigInt not supported")}})(k2);const kI="https://mempool.space",PI="https://mempool.space/testnet",OI="https://mempool.space/testnet4",II="https://mempool.space/signet",xI="https://mempool.fractalbitcoin.io",$I="https://mempool-testnet.fractalbitcoin.io",pi=e=>e===Bt?PI:e===xr?OI:e===Ir?II:e===fo?xI:e===$r?$I:kI;var pt={},od={};const CI={},NI=Object.freeze(Object.defineProperty({__proto__:null,default:CI},Symbol.toStringTag,{value:"Module"})),O2=xT(NI);(function(e){/*! noble-secp256k1 - MIT License (c) 2019 Paul Miller (paulmillr.com) */Object.defineProperty(e,"__esModule",{value:!0}),e.utils=e.schnorr=e.verify=e.signSync=e.sign=e.getSharedSecret=e.recoverPublicKey=e.getPublicKey=e.Signature=e.Point=e.CURVE=void 0;const t=O2,r=BigInt(0),n=BigInt(1),i=BigInt(2),o=BigInt(3),s=BigInt(8),a=Object.freeze({a:r,b:BigInt(7),P:BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),n:BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),h:n,Gx:BigInt("55066263022277343669578718895168534326250603453777594175500187360389116729240"),Gy:BigInt("32670510020758816978083085130507043184471273380659243275938904335757337482424"),beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee")});e.CURVE=a;const u=(b,y)=>(b+y/i)/y,f={beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),splitScalar(b){const{n:y}=a,w=BigInt("0x3086d221a7d46bcde86c90e49284eb15"),A=-n*BigInt("0xe4437ed6010e88286f547fa90abfe4c3"),_=BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),$=w,H=BigInt("0x100000000000000000000000000000000"),K=u($*b,y),q=u(-A*b,y);let z=L(b-K*w-q*_,y),X=L(-K*A-q*$,y);const Z=z>H,te=X>H;if(Z&&(z=y-z),te&&(X=y-X),z>H||X>H)throw new Error("splitScalarEndo: Endomorphism failed, k="+b);return{k1neg:Z,k1:z,k2neg:te,k2:X}}},h=32,d=32,g=32,v=h+1,E=2*h+1;function T(b){const{a:y,b:w}=a,A=L(b*b),_=L(A*b);return L(_+y*b+w)}const x=a.a===r;class N extends Error{constructor(y){super(y)}}function I(b){if(!(b instanceof k))throw new TypeError("JacobianPoint expected")}class k{constructor(y,w,A){this.x=y,this.y=w,this.z=A}static fromAffine(y){if(!(y instanceof V))throw new TypeError("JacobianPoint#fromAffine: expected Point");return y.equals(V.ZERO)?k.ZERO:new k(y.x,y.y,n)}static toAffineBatch(y){const w=Nr(y.map(A=>A.z));return y.map((A,_)=>A.toAffine(w[_]))}static normalizeZ(y){return k.toAffineBatch(y).map(k.fromAffine)}equals(y){I(y);const{x:w,y:A,z:_}=this,{x:$,y:H,z:K}=y,q=L(_*_),z=L(K*K),X=L(w*z),Z=L($*q),te=L(L(A*K)*z),P=L(L(H*_)*q);return X===Z&&te===P}negate(){return new k(this.x,L(-this.y),this.z)}double(){const{x:y,y:w,z:A}=this,_=L(y*y),$=L(w*w),H=L($*$),K=y+$,q=L(i*(L(K*K)-_-H)),z=L(o*_),X=L(z*z),Z=L(X-i*q),te=L(z*(q-Z)-s*H),P=L(i*w*A);return new k(Z,te,P)}add(y){I(y);const{x:w,y:A,z:_}=this,{x:$,y:H,z:K}=y;if($===r||H===r)return this;if(w===r||A===r)return y;const q=L(_*_),z=L(K*K),X=L(w*z),Z=L($*q),te=L(L(A*K)*z),P=L(L(H*_)*q),j=L(Z-X),G=L(P-te);if(j===r)return G===r?this.double():k.ZERO;const ne=L(j*j),_e=L(j*ne),$e=L(X*ne),Pe=L(G*G-_e-i*$e),Oe=L(G*($e-Pe)-te*_e),Ze=L(_*K*j);return new k(Pe,Oe,Ze)}subtract(y){return this.add(y.negate())}multiplyUnsafe(y){const w=k.ZERO;if(typeof y=="bigint"&&y===r)return w;let A=Ne(y);if(A===n)return this;if(!x){let Z=w,te=this;for(;A>r;)A&n&&(Z=Z.add(te)),te=te.double(),A>>=n;return Z}let{k1neg:_,k1:$,k2neg:H,k2:K}=f.splitScalar(A),q=w,z=w,X=this;for(;$>r||K>r;)$&n&&(q=q.add(X)),K&n&&(z=z.add(X)),X=X.double(),$>>=n,K>>=n;return _&&(q=q.negate()),H&&(z=z.negate()),z=new k(L(z.x*f.beta),z.y,z.z),q.add(z)}precomputeWindow(y){const w=x?128/y+1:256/y+1,A=[];let _=this,$=_;for(let H=0;H<w;H++){$=_,A.push($);for(let K=1;K<2**(y-1);K++)$=$.add(_),A.push($);_=$.double()}return A}wNAF(y,w){!w&&this.equals(k.BASE)&&(w=V.BASE);const A=w&&w._WINDOW_SIZE||1;if(256%A)throw new Error("Point#wNAF: Invalid precomputation window, must be power of 2");let _=w&&W.get(w);_||(_=this.precomputeWindow(A),w&&A!==1&&(_=k.normalizeZ(_),W.set(w,_)));let $=k.ZERO,H=k.BASE;const K=1+(x?128/A:256/A),q=2**(A-1),z=BigInt(2**A-1),X=2**A,Z=BigInt(A);for(let te=0;te<K;te++){const P=te*q;let j=Number(y&z);y>>=Z,j>q&&(j-=X,y+=n);const G=P,ne=P+Math.abs(j)-1,_e=te%2!==0,$e=j<0;j===0?H=H.add(B(_e,_[G])):$=$.add(B($e,_[ne]))}return{p:$,f:H}}multiply(y,w){let A=Ne(y),_,$;if(x){const{k1neg:H,k1:K,k2neg:q,k2:z}=f.splitScalar(A);let{p:X,f:Z}=this.wNAF(K,w),{p:te,f:P}=this.wNAF(z,w);X=B(H,X),te=B(q,te),te=new k(L(te.x*f.beta),te.y,te.z),_=X.add(te),$=Z.add(P)}else{const{p:H,f:K}=this.wNAF(A,w);_=H,$=K}return k.normalizeZ([_,$])[0]}toAffine(y){const{x:w,y:A,z:_}=this,$=this.equals(k.ZERO);y==null&&(y=$?s:gt(_));const H=y,K=L(H*H),q=L(K*H),z=L(w*K),X=L(A*q),Z=L(_*H);if($)return V.ZERO;if(Z!==n)throw new Error("invZ was invalid");return new V(z,X)}}k.BASE=new k(a.Gx,a.Gy,n),k.ZERO=new k(r,n,r);function B(b,y){const w=y.negate();return b?w:y}const W=new WeakMap;class V{constructor(y,w){this.x=y,this.y=w}_setWindowSize(y){this._WINDOW_SIZE=y,W.delete(this)}hasEvenY(){return this.y%i===r}static fromCompressedHex(y){const w=y.length===32,A=Ce(w?y:y.subarray(1));if(!wt(A))throw new Error("Point is not on curve");const _=T(A);let $=Pn(_);const H=($&n)===n;w?H&&($=L(-$)):(y[0]&1)===1!==H&&($=L(-$));const K=new V(A,$);return K.assertValidity(),K}static fromUncompressedHex(y){const w=Ce(y.subarray(1,h+1)),A=Ce(y.subarray(h+1,h*2+1)),_=new V(w,A);return _.assertValidity(),_}static fromHex(y){const w=re(y),A=w.length,_=w[0];if(A===h)return this.fromCompressedHex(w);if(A===v&&(_===2||_===3))return this.fromCompressedHex(w);if(A===E&&_===4)return this.fromUncompressedHex(w);throw new Error(`Point.fromHex: received invalid point. Expected 32-${v} compressed bytes or ${E} uncompressed bytes, not ${A}`)}static fromPrivateKey(y){return V.BASE.multiply(nt(y))}static fromSignature(y,w,A){const{r:_,s:$}=Xr(w);if(![0,1,2,3].includes(A))throw new Error("Cannot recover: invalid recovery bit");const H=Ht(re(y)),{n:K}=a,q=A===2||A===3?_+K:_,z=gt(q,K),X=L(-H*z,K),Z=L($*z,K),te=A&1?"03":"02",P=V.fromHex(te+J(q)),j=V.BASE.multiplyAndAddUnsafe(P,X,Z);if(!j)throw new Error("Cannot recover signature: point at infinify");return j.assertValidity(),j}toRawBytes(y=!1){return je(this.toHex(y))}toHex(y=!1){const w=J(this.x);return y?`${this.hasEvenY()?"02":"03"}${w}`:`04${w}${J(this.y)}`}toHexX(){return this.toHex(!0).slice(2)}toRawX(){return this.toRawBytes(!0).slice(1)}assertValidity(){const y="Point is not on elliptic curve",{x:w,y:A}=this;if(!wt(w)||!wt(A))throw new Error(y);const _=L(A*A),$=T(w);if(L(_-$)!==r)throw new Error(y)}equals(y){return this.x===y.x&&this.y===y.y}negate(){return new V(this.x,L(-this.y))}double(){return k.fromAffine(this).double().toAffine()}add(y){return k.fromAffine(this).add(k.fromAffine(y)).toAffine()}subtract(y){return this.add(y.negate())}multiply(y){return k.fromAffine(this).multiply(y,this).toAffine()}multiplyAndAddUnsafe(y,w,A){const _=k.fromAffine(this),$=w===r||w===n||this!==V.BASE?_.multiplyUnsafe(w):_.multiply(w),H=k.fromAffine(y).multiplyUnsafe(A),K=$.add(H);return K.equals(k.ZERO)?void 0:K.toAffine()}}e.Point=V,V.BASE=new V(a.Gx,a.Gy),V.ZERO=new V(r,r);function Ue(b){return Number.parseInt(b[0],16)>=8?"00"+b:b}function Le(b){if(b.length<2||b[0]!==2)throw new Error(`Invalid signature integer tag: ${F(b)}`);const y=b[1],w=b.subarray(2,y+2);if(!y||w.length!==y)throw new Error("Invalid signature integer: wrong length");if(w[0]===0&&w[1]<=127)throw new Error("Invalid signature integer: trailing length");return{data:Ce(w),left:b.subarray(y+2)}}function Je(b){if(b.length<2||b[0]!=48)throw new Error(`Invalid signature tag: ${F(b)}`);if(b[1]!==b.length-2)throw new Error("Invalid signature: incorrect length");const{data:y,left:w}=Le(b.subarray(2)),{data:A,left:_}=Le(w);if(_.length)throw new Error(`Invalid signature: left bytes after parsing: ${F(_)}`);return{r:y,s:A}}class Fe{constructor(y,w){this.r=y,this.s=w,this.assertValidity()}static fromCompact(y){const w=y instanceof Uint8Array,A="Signature.fromCompact";if(typeof y!="string"&&!w)throw new TypeError(`${A}: Expected string or Uint8Array`);const _=w?F(y):y;if(_.length!==128)throw new Error(`${A}: Expected 64-byte hex`);return new Fe(Et(_.slice(0,64)),Et(_.slice(64,128)))}static fromDER(y){const w=y instanceof Uint8Array;if(typeof y!="string"&&!w)throw new TypeError("Signature.fromDER: Expected string or Uint8Array");const{r:A,s:_}=Je(w?y:je(y));return new Fe(A,_)}static fromHex(y){return this.fromDER(y)}assertValidity(){const{r:y,s:w}=this;if(!Ve(y))throw new Error("Invalid Signature: r must be 0 < r < n");if(!Ve(w))throw new Error("Invalid Signature: s must be 0 < s < n")}hasHighS(){const y=a.n>>n;return this.s>y}normalizeS(){return this.hasHighS()?new Fe(this.r,L(-this.s,a.n)):this}toDERRawBytes(){return je(this.toDERHex())}toDERHex(){const y=Ue(Ae(this.s)),w=Ue(Ae(this.r)),A=y.length/2,_=w.length/2,$=Ae(A),H=Ae(_);return`30${Ae(_+A+4)}02${H}${w}02${$}${y}`}toRawBytes(){return this.toDERRawBytes()}toHex(){return this.toDERHex()}toCompactRawBytes(){return je(this.toCompactHex())}toCompactHex(){return J(this.r)+J(this.s)}}e.Signature=Fe;function Ye(...b){if(!b.every(A=>A instanceof Uint8Array))throw new Error("Uint8Array list expected");if(b.length===1)return b[0];const y=b.reduce((A,_)=>A+_.length,0),w=new Uint8Array(y);for(let A=0,_=0;A<b.length;A++){const $=b[A];w.set($,_),_+=$.length}return w}const C=Array.from({length:256},(b,y)=>y.toString(16).padStart(2,"0"));function F(b){if(!(b instanceof Uint8Array))throw new Error("Expected Uint8Array");let y="";for(let w=0;w<b.length;w++)y+=C[b[w]];return y}const oe=BigInt("0x10000000000000000000000000000000000000000000000000000000000000000");function J(b){if(typeof b!="bigint")throw new Error("Expected bigint");if(!(r<=b&&b<oe))throw new Error("Expected number 0 <= n < 2^256");return b.toString(16).padStart(64,"0")}function ue(b){const y=je(J(b));if(y.length!==32)throw new Error("Error: expected 32 bytes");return y}function Ae(b){const y=b.toString(16);return y.length&1?`0${y}`:y}function Et(b){if(typeof b!="string")throw new TypeError("hexToNumber: expected string, got "+typeof b);return BigInt(`0x${b}`)}function je(b){if(typeof b!="string")throw new TypeError("hexToBytes: expected string, got "+typeof b);if(b.length%2)throw new Error("hexToBytes: received invalid unpadded hex"+b.length);const y=new Uint8Array(b.length/2);for(let w=0;w<y.length;w++){const A=w*2,_=b.slice(A,A+2),$=Number.parseInt(_,16);if(Number.isNaN($)||$<0)throw new Error("Invalid byte sequence");y[w]=$}return y}function Ce(b){return Et(F(b))}function re(b){return b instanceof Uint8Array?Uint8Array.from(b):je(b)}function Ne(b){if(typeof b=="number"&&Number.isSafeInteger(b)&&b>0)return BigInt(b);if(typeof b=="bigint"&&Ve(b))return b;throw new TypeError("Expected valid private scalar: 0 < scalar < curve.n")}function L(b,y=a.P){const w=b%y;return w>=r?w:y+w}function He(b,y){const{P:w}=a;let A=b;for(;y-- >r;)A*=A,A%=w;return A}function Pn(b){const{P:y}=a,w=BigInt(6),A=BigInt(11),_=BigInt(22),$=BigInt(23),H=BigInt(44),K=BigInt(88),q=b*b*b%y,z=q*q*b%y,X=He(z,o)*z%y,Z=He(X,o)*z%y,te=He(Z,i)*q%y,P=He(te,A)*te%y,j=He(P,_)*P%y,G=He(j,H)*j%y,ne=He(G,K)*G%y,_e=He(ne,H)*j%y,$e=He(_e,o)*z%y,Pe=He($e,$)*P%y,Oe=He(Pe,w)*q%y,Ze=He(Oe,i);if(Ze*Ze%y!==b)throw new Error("Cannot find square root");return Ze}function gt(b,y=a.P){if(b===r||y<=r)throw new Error(`invert: expected positive integers, got n=${b} mod=${y}`);let w=L(b,y),A=y,_=r,$=n;for(;w!==r;){const H=A/w,K=A%w,q=_-$*H;A=w,w=K,_=$,$=q}if(A!==n)throw new Error("invert: does not exist");return L(_,y)}function Nr(b,y=a.P){const w=new Array(b.length),A=b.reduce(($,H,K)=>H===r?$:(w[K]=$,L($*H,y)),n),_=gt(A,y);return b.reduceRight(($,H,K)=>H===r?$:(w[K]=L($*w[K],y),L($*H,y)),_),w}function At(b){const y=b.length*8-d*8,w=Ce(b);return y>0?w>>BigInt(y):w}function Ht(b,y=!1){const w=At(b);if(y)return w;const{n:A}=a;return w>=A?w-A:w}let st,Dt;class Er{constructor(y,w){if(this.hashLen=y,this.qByteLen=w,typeof y!="number"||y<2)throw new Error("hashLen must be a number");if(typeof w!="number"||w<2)throw new Error("qByteLen must be a number");this.v=new Uint8Array(y).fill(1),this.k=new Uint8Array(y).fill(0),this.counter=0}hmac(...y){return e.utils.hmacSha256(this.k,...y)}hmacSync(...y){return Dt(this.k,...y)}checkSync(){if(typeof Dt!="function")throw new N("hmacSha256Sync needs to be set")}incr(){if(this.counter>=1e3)throw new Error("Tried 1,000 k values for sign(), all were invalid");this.counter+=1}async reseed(y=new Uint8Array){this.k=await this.hmac(this.v,Uint8Array.from([0]),y),this.v=await this.hmac(this.v),y.length!==0&&(this.k=await this.hmac(this.v,Uint8Array.from([1]),y),this.v=await this.hmac(this.v))}reseedSync(y=new Uint8Array){this.checkSync(),this.k=this.hmacSync(this.v,Uint8Array.from([0]),y),this.v=this.hmacSync(this.v),y.length!==0&&(this.k=this.hmacSync(this.v,Uint8Array.from([1]),y),this.v=this.hmacSync(this.v))}async generate(){this.incr();let y=0;const w=[];for(;y<this.qByteLen;){this.v=await this.hmac(this.v);const A=this.v.slice();w.push(A),y+=this.v.length}return Ye(...w)}generateSync(){this.checkSync(),this.incr();let y=0;const w=[];for(;y<this.qByteLen;){this.v=this.hmacSync(this.v);const A=this.v.slice();w.push(A),y+=this.v.length}return Ye(...w)}}function Ve(b){return r<b&&b<a.n}function wt(b){return r<b&&b<a.P}function Ar(b,y,w,A=!0){const{n:_}=a,$=Ht(b,!0);if(!Ve($))return;const H=gt($,_),K=V.BASE.multiply($),q=L(K.x,_);if(q===r)return;const z=L(H*L(y+w*q,_),_);if(z===r)return;let X=new Fe(q,z),Z=(K.x===X.r?0:2)|Number(K.y&n);return A&&X.hasHighS()&&(X=X.normalizeS(),Z^=1),{sig:X,recovery:Z}}function nt(b){let y;if(typeof b=="bigint")y=b;else if(typeof b=="number"&&Number.isSafeInteger(b)&&b>0)y=BigInt(b);else if(typeof b=="string"){if(b.length!==2*d)throw new Error("Expected 32 bytes of private key");y=Et(b)}else if(b instanceof Uint8Array){if(b.length!==d)throw new Error("Expected 32 bytes of private key");y=Ce(b)}else throw new TypeError("Expected valid private key");if(!Ve(y))throw new Error("Expected private key: 0 < key < n");return y}function Lt(b){return b instanceof V?(b.assertValidity(),b):V.fromHex(b)}function Xr(b){if(b instanceof Fe)return b.assertValidity(),b;try{return Fe.fromDER(b)}catch{return Fe.fromCompact(b)}}function Jr(b,y=!1){return V.fromPrivateKey(b).toRawBytes(y)}e.getPublicKey=Jr;function On(b,y,w,A=!1){return V.fromSignature(b,y,w).toRawBytes(A)}e.recoverPublicKey=On;function Mt(b){const y=b instanceof Uint8Array,w=typeof b=="string",A=(y||w)&&b.length;return y?A===v||A===E:w?A===v*2||A===E*2:b instanceof V}function ze(b,y,w=!1){if(Mt(b))throw new TypeError("getSharedSecret: first arg must be private key");if(!Mt(y))throw new TypeError("getSharedSecret: second arg must be public key");const A=Lt(y);return A.assertValidity(),A.multiply(nt(b)).toRawBytes(w)}e.getSharedSecret=ze;function sr(b){const y=b.length>h?b.slice(0,h):b;return Ce(y)}function wi(b){const y=sr(b),w=L(y,a.n);return rt(w<r?y:w)}function rt(b){return ue(b)}function Yr(b,y,w){if(b==null)throw new Error(`sign: expected valid message hash, not "${b}"`);const A=re(b),_=nt(y),$=[rt(_),wi(A)];if(w!=null){w===!0&&(w=e.utils.randomBytes(h));const q=re(w);if(q.length!==h)throw new Error(`sign: Expected ${h} bytes of extra data`);$.push(q)}const H=Ye(...$),K=sr(A);return{seed:H,m:K,d:_}}function c(b,y){const{sig:w,recovery:A}=b,{der:_,recovered:$}=Object.assign({canonical:!0,der:!0},y),H=_?w.toDERRawBytes():w.toCompactRawBytes();return $?[H,A]:H}async function l(b,y,w={}){const{seed:A,m:_,d:$}=Yr(b,y,w.extraEntropy),H=new Er(g,d);await H.reseed(A);let K;for(;!(K=Ar(await H.generate(),_,$,w.canonical));)await H.reseed();return c(K,w)}e.sign=l;function p(b,y,w={}){const{seed:A,m:_,d:$}=Yr(b,y,w.extraEntropy),H=new Er(g,d);H.reseedSync(A);let K;for(;!(K=Ar(H.generateSync(),_,$,w.canonical));)H.reseedSync();return c(K,w)}e.signSync=p;const m={strict:!0};function S(b,y,w,A=m){let _;try{_=Xr(b),y=re(y)}catch{return!1}const{r:$,s:H}=_;if(A.strict&&_.hasHighS())return!1;const K=Ht(y);let q;try{q=Lt(w)}catch{return!1}const{n:z}=a,X=gt(H,z),Z=L(K*X,z),te=L($*X,z),P=V.BASE.multiplyAndAddUnsafe(q,Z,te);return P?L(P.x,z)===$:!1}e.verify=S;function O(b){return L(Ce(b),a.n)}class U{constructor(y,w){this.r=y,this.s=w,this.assertValidity()}static fromHex(y){const w=re(y);if(w.length!==64)throw new TypeError(`SchnorrSignature.fromHex: expected 64 bytes, not ${w.length}`);const A=Ce(w.subarray(0,32)),_=Ce(w.subarray(32,64));return new U(A,_)}assertValidity(){const{r:y,s:w}=this;if(!wt(y)||!Ve(w))throw new Error("Invalid signature")}toHex(){return J(this.r)+J(this.s)}toRawBytes(){return je(this.toHex())}}function ce(b){return V.fromPrivateKey(b).toRawX()}class ke{constructor(y,w,A=e.utils.randomBytes()){if(y==null)throw new TypeError(`sign: Expected valid message, not "${y}"`);this.m=re(y);const{x:_,scalar:$}=this.getScalar(nt(w));if(this.px=_,this.d=$,this.rand=re(A),this.rand.length!==32)throw new TypeError("sign: Expected 32 bytes of aux randomness")}getScalar(y){const w=V.fromPrivateKey(y),A=w.hasEvenY()?y:a.n-y;return{point:w,scalar:A,x:w.toRawX()}}initNonce(y,w){return ue(y^Ce(w))}finalizeNonce(y){const w=L(Ce(y),a.n);if(w===r)throw new Error("sign: Creation of signature failed. k is zero");const{point:A,x:_,scalar:$}=this.getScalar(w);return{R:A,rx:_,k:$}}finalizeSig(y,w,A,_){return new U(y.x,L(w+A*_,a.n)).toRawBytes()}error(){throw new Error("sign: Invalid signature produced")}async calc(){const{m:y,d:w,px:A,rand:_}=this,$=e.utils.taggedHash,H=this.initNonce(w,await $(Pt.aux,_)),{R:K,rx:q,k:z}=this.finalizeNonce(await $(Pt.nonce,H,A,y)),X=O(await $(Pt.challenge,q,A,y)),Z=this.finalizeSig(K,z,X,w);return await is(Z,y,A)||this.error(),Z}calcSync(){const{m:y,d:w,px:A,rand:_}=this,$=e.utils.taggedHashSync,H=this.initNonce(w,$(Pt.aux,_)),{R:K,rx:q,k:z}=this.finalizeNonce($(Pt.nonce,H,A,y)),X=O($(Pt.challenge,q,A,y)),Z=this.finalizeSig(K,z,X,w);return Zr(Z,y,A)||this.error(),Z}}async function le(b,y,w){return new ke(b,y,w).calc()}function ae(b,y,w){return new ke(b,y,w).calcSync()}function me(b,y,w){const A=b instanceof U,_=A?b:U.fromHex(b);return A&&_.assertValidity(),{..._,m:re(y),P:Lt(w)}}function bi(b,y,w,A){const _=V.BASE.multiplyAndAddUnsafe(y,nt(w),L(-A,a.n));return!(!_||!_.hasEvenY()||_.x!==b)}async function is(b,y,w){try{const{r:A,s:_,m:$,P:H}=me(b,y,w),K=O(await e.utils.taggedHash(Pt.challenge,ue(A),H.toRawX(),$));return bi(A,H,_,K)}catch{return!1}}function Zr(b,y,w){try{const{r:A,s:_,m:$,P:H}=me(b,y,w),K=O(e.utils.taggedHashSync(Pt.challenge,ue(A),H.toRawX(),$));return bi(A,H,_,K)}catch(A){if(A instanceof N)throw A;return!1}}e.schnorr={Signature:U,getPublicKey:ce,sign:le,verify:is,signSync:ae,verifySync:Zr},V.BASE._setWindowSize(8);const Ke={node:t,web:typeof self=="object"&&"crypto"in self?self.crypto:void 0},Pt={challenge:"BIP0340/challenge",aux:"BIP0340/aux",nonce:"BIP0340/nonce"},Qr={};e.utils={bytesToHex:F,hexToBytes:je,concatBytes:Ye,mod:L,invert:gt,isValidPrivateKey(b){try{return nt(b),!0}catch{return!1}},_bigintTo32Bytes:ue,_normalizePrivateKey:nt,hashToPrivateKey:b=>{b=re(b);const y=d+8;if(b.length<y||b.length>1024)throw new Error("Expected valid bytes of private key as per FIPS 186");const w=L(Ce(b),a.n-n)+n;return ue(w)},randomBytes:(b=32)=>{if(Ke.web)return Ke.web.getRandomValues(new Uint8Array(b));if(Ke.node){const{randomBytes:y}=Ke.node;return Uint8Array.from(y(b))}else throw new Error("The environment doesn't have randomBytes function")},randomPrivateKey:()=>e.utils.hashToPrivateKey(e.utils.randomBytes(d+8)),precompute(b=8,y=V.BASE){const w=y===V.BASE?y:new V(y.x,y.y);return w._setWindowSize(b),w.multiply(o),w},sha256:async(...b)=>{if(Ke.web){const y=await Ke.web.subtle.digest("SHA-256",Ye(...b));return new Uint8Array(y)}else if(Ke.node){const{createHash:y}=Ke.node,w=y("sha256");return b.forEach(A=>w.update(A)),Uint8Array.from(w.digest())}else throw new Error("The environment doesn't have sha256 function")},hmacSha256:async(b,...y)=>{if(Ke.web){const w=await Ke.web.subtle.importKey("raw",b,{name:"HMAC",hash:{name:"SHA-256"}},!1,["sign"]),A=Ye(...y),_=await Ke.web.subtle.sign("HMAC",w,A);return new Uint8Array(_)}else if(Ke.node){const{createHmac:w}=Ke.node,A=w("sha256",b);return y.forEach(_=>A.update(_)),Uint8Array.from(A.digest())}else throw new Error("The environment doesn't have hmac-sha256 function")},sha256Sync:void 0,hmacSha256Sync:void 0,taggedHash:async(b,...y)=>{let w=Qr[b];if(w===void 0){const A=await e.utils.sha256(Uint8Array.from(b,_=>_.charCodeAt(0)));w=Ye(A,A),Qr[b]=w}return e.utils.sha256(w,...y)},taggedHashSync:(b,...y)=>{if(typeof st!="function")throw new N("sha256Sync is undefined, you need to set it");let w=Qr[b];if(w===void 0){const A=st(Uint8Array.from(b,_=>_.charCodeAt(0)));w=Ye(A,A),Qr[b]=w}return st(w,...y)},_JacobianPoint:k},Object.defineProperties(e.utils,{sha256Sync:{configurable:!1,get(){return st},set(b){st||(st=b)}},hmacSha256Sync:{configurable:!1,get(){return Dt},set(b){Dt||(Dt=b)}}})})(od);var ad={},Wr={};Object.defineProperty(Wr,"__esModule",{value:!0}),Wr.isBytes=x2,Wr.number=Mu,Wr.bool=I2,Wr.bytes=cd,Wr.hash=$2,Wr.exists=C2,Wr.output=N2;function Mu(e){if(!Number.isSafeInteger(e)||e<0)throw new Error(`positive integer expected, not ${e}`)}function I2(e){if(typeof e!="boolean")throw new Error(`boolean expected, not ${e}`)}function x2(e){return e instanceof Uint8Array||e!=null&&typeof e=="object"&&e.constructor.name==="Uint8Array"}function cd(e,...t){if(!x2(e))throw new Error("Uint8Array expected");if(t.length>0&&!t.includes(e.length))throw new Error(`Uint8Array expected of length ${t}, not of length=${e.length}`)}function $2(e){if(typeof e!="function"||typeof e.create!="function")throw new Error("Hash should be wrapped by utils.wrapConstructor");Mu(e.outputLen),Mu(e.blockLen)}function C2(e,t=!0){if(e.destroyed)throw new Error("Hash instance has been destroyed");if(t&&e.finished)throw new Error("Hash#digest() has already been called")}function N2(e,t){cd(e);const r=t.outputLen;if(e.length<r)throw new Error(`digestInto() expects output buffer of length at least ${r}`)}const UI={number:Mu,bool:I2,bytes:cd,hash:$2,exists:C2,output:N2};Wr.default=UI;var ka={},Fu={};Object.defineProperty(Fu,"__esModule",{value:!0}),Fu.crypto=void 0,Fu.crypto=typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0,function(e){/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */Object.defineProperty(e,"__esModule",{value:!0}),e.Hash=e.nextTick=e.byteSwapIfBE=e.byteSwap=e.isLE=e.rotl=e.rotr=e.createView=e.u32=e.u8=void 0,e.isBytes=n,e.byteSwap32=h,e.bytesToHex=g,e.hexToBytes=T,e.asyncLoop=N,e.utf8ToBytes=I,e.toBytes=k,e.concatBytes=B,e.checkOpts=Ue,e.wrapConstructor=Le,e.wrapConstructorWithOpts=Je,e.wrapXOFConstructorWithOpts=Fe,e.randomBytes=Ye;const t=Fu,r=Wr;function n(C){return C instanceof Uint8Array||C!=null&&typeof C=="object"&&C.constructor.name==="Uint8Array"}const i=C=>new Uint8Array(C.buffer,C.byteOffset,C.byteLength);e.u8=i;const o=C=>new Uint32Array(C.buffer,C.byteOffset,Math.floor(C.byteLength/4));e.u32=o;const s=C=>new DataView(C.buffer,C.byteOffset,C.byteLength);e.createView=s;const a=(C,F)=>C<<32-F|C>>>F;e.rotr=a;const u=(C,F)=>C<<F|C>>>32-F>>>0;e.rotl=u,e.isLE=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;const f=C=>C<<24&4278190080|C<<8&16711680|C>>>8&65280|C>>>24&255;e.byteSwap=f,e.byteSwapIfBE=e.isLE?C=>C:C=>(0,e.byteSwap)(C);function h(C){for(let F=0;F<C.length;F++)C[F]=(0,e.byteSwap)(C[F])}const d=Array.from({length:256},(C,F)=>F.toString(16).padStart(2,"0"));function g(C){(0,r.bytes)(C);let F="";for(let oe=0;oe<C.length;oe++)F+=d[C[oe]];return F}const v={_0:48,_9:57,_A:65,_F:70,_a:97,_f:102};function E(C){if(C>=v._0&&C<=v._9)return C-v._0;if(C>=v._A&&C<=v._F)return C-(v._A-10);if(C>=v._a&&C<=v._f)return C-(v._a-10)}function T(C){if(typeof C!="string")throw new Error("hex string expected, got "+typeof C);const F=C.length,oe=F/2;if(F%2)throw new Error("padded hex string expected, got unpadded hex of length "+F);const J=new Uint8Array(oe);for(let ue=0,Ae=0;ue<oe;ue++,Ae+=2){const Et=E(C.charCodeAt(Ae)),je=E(C.charCodeAt(Ae+1));if(Et===void 0||je===void 0){const Ce=C[Ae]+C[Ae+1];throw new Error('hex string expected, got non-hex character "'+Ce+'" at index '+Ae)}J[ue]=Et*16+je}return J}const x=async()=>{};e.nextTick=x;async function N(C,F,oe){let J=Date.now();for(let ue=0;ue<C;ue++){oe(ue);const Ae=Date.now()-J;Ae>=0&&Ae<F||(await(0,e.nextTick)(),J+=Ae)}}function I(C){if(typeof C!="string")throw new Error(`utf8ToBytes expected string, got ${typeof C}`);return new Uint8Array(new TextEncoder().encode(C))}function k(C){return typeof C=="string"&&(C=I(C)),(0,r.bytes)(C),C}function B(...C){let F=0;for(let J=0;J<C.length;J++){const ue=C[J];(0,r.bytes)(ue),F+=ue.length}const oe=new Uint8Array(F);for(let J=0,ue=0;J<C.length;J++){const Ae=C[J];oe.set(Ae,ue),ue+=Ae.length}return oe}class W{clone(){return this._cloneInto()}}e.Hash=W;const V={}.toString;function Ue(C,F){if(F!==void 0&&V.call(F)!=="[object Object]")throw new Error("Options should be object or undefined");return Object.assign(C,F)}function Le(C){const F=J=>C().update(k(J)).digest(),oe=C();return F.outputLen=oe.outputLen,F.blockLen=oe.blockLen,F.create=()=>C(),F}function Je(C){const F=(J,ue)=>C(ue).update(k(J)).digest(),oe=C({});return F.outputLen=oe.outputLen,F.blockLen=oe.blockLen,F.create=J=>C(J),F}function Fe(C){const F=(J,ue)=>C(ue).update(k(J)).digest(),oe=C({});return F.outputLen=oe.outputLen,F.blockLen=oe.blockLen,F.create=J=>C(J),F}function Ye(C=32){if(t.crypto&&typeof t.crypto.getRandomValues=="function")return t.crypto.getRandomValues(new Uint8Array(C));if(t.crypto&&typeof t.crypto.randomBytes=="function")return t.crypto.randomBytes(C);throw new Error("crypto.getRandomValues must be defined")}}(ka),function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.hmac=e.HMAC=void 0;const t=Wr,r=ka;class n extends r.Hash{constructor(s,a){super(),this.finished=!1,this.destroyed=!1,(0,t.hash)(s);const u=(0,r.toBytes)(a);if(this.iHash=s.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 f=this.blockLen,h=new Uint8Array(f);h.set(u.length>f?s.create().update(u).digest():u);for(let d=0;d<h.length;d++)h[d]^=54;this.iHash.update(h),this.oHash=s.create();for(let d=0;d<h.length;d++)h[d]^=106;this.oHash.update(h),h.fill(0)}update(s){return(0,t.exists)(this),this.iHash.update(s),this}digestInto(s){(0,t.exists)(this),(0,t.bytes)(s,this.outputLen),this.finished=!0,this.iHash.digestInto(s),this.oHash.update(s),this.oHash.digestInto(s),this.destroy()}digest(){const s=new Uint8Array(this.oHash.outputLen);return this.digestInto(s),s}_cloneInto(s){s||(s=Object.create(Object.getPrototypeOf(this),{}));const{oHash:a,iHash:u,finished:f,destroyed:h,blockLen:d,outputLen:g}=this;return s=s,s.finished=f,s.destroyed=h,s.blockLen=d,s.outputLen=g,s.oHash=a._cloneInto(s.oHash),s.iHash=u._cloneInto(s.iHash),s}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}}e.HMAC=n;const i=(o,s,a)=>new n(o,s).update(a).digest();e.hmac=i,e.hmac.create=(o,s)=>new n(o,s)}(ad);var Fn={},Yi={};Object.defineProperty(Yi,"__esModule",{value:!0}),Yi.HashMD=Yi.Maj=Yi.Chi=void 0;const ud=Wr,Pa=ka;function RI(e,t,r,n){if(typeof e.setBigUint64=="function")return e.setBigUint64(t,r,n);const i=BigInt(32),o=BigInt(4294967295),s=Number(r>>i&o),a=Number(r&o),u=n?4:0,f=n?0:4;e.setUint32(t+u,s,n),e.setUint32(t+f,a,n)}const BI=(e,t,r)=>e&t^~e&r;Yi.Chi=BI;const HI=(e,t,r)=>e&t^e&r^t&r;Yi.Maj=HI;class LI extends Pa.Hash{constructor(t,r,n,i){super(),this.blockLen=t,this.outputLen=r,this.padOffset=n,this.isLE=i,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(t),this.view=(0,Pa.createView)(this.buffer)}update(t){(0,ud.exists)(this);const{view:r,buffer:n,blockLen:i}=this;t=(0,Pa.toBytes)(t);const o=t.length;for(let s=0;s<o;){const a=Math.min(i-this.pos,o-s);if(a===i){const u=(0,Pa.createView)(t);for(;i<=o-s;s+=i)this.process(u,s);continue}n.set(t.subarray(s,s+a),this.pos),this.pos+=a,s+=a,this.pos===i&&(this.process(r,0),this.pos=0)}return this.length+=t.length,this.roundClean(),this}digestInto(t){(0,ud.exists)(this),(0,ud.output)(t,this),this.finished=!0;const{buffer:r,view:n,blockLen:i,isLE:o}=this;let{pos:s}=this;r[s++]=128,this.buffer.subarray(s).fill(0),this.padOffset>i-s&&(this.process(n,0),s=0);for(let d=s;d<i;d++)r[d]=0;RI(n,i-8,BigInt(this.length*8),o),this.process(n,0);const a=(0,Pa.createView)(t),u=this.outputLen;if(u%4)throw new Error("_sha2: outputLen should be aligned to 32bit");const f=u/4,h=this.get();if(f>h.length)throw new Error("_sha2: outputLen bigger than state");for(let d=0;d<f;d++)a.setUint32(4*d,h[d],o)}digest(){const{buffer:t,outputLen:r}=this;this.digestInto(t);const n=t.slice(0,r);return this.destroy(),n}_cloneInto(t){t||(t=new this.constructor),t.set(...this.get());const{blockLen:r,buffer:n,length:i,finished:o,destroyed:s,pos:a}=this;return t.length=i,t.pos=a,t.finished=o,t.destroyed=s,i%r&&t.buffer.set(n),t}}Yi.HashMD=LI,Object.defineProperty(Fn,"__esModule",{value:!0}),Fn.sha224=Fn.sha256=Fn.SHA256=void 0;const ld=Yi,qr=ka,KI=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]),Zi=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),Qi=new Uint32Array(64);class hd extends ld.HashMD{constructor(){super(64,32,8,!1),this.A=Zi[0]|0,this.B=Zi[1]|0,this.C=Zi[2]|0,this.D=Zi[3]|0,this.E=Zi[4]|0,this.F=Zi[5]|0,this.G=Zi[6]|0,this.H=Zi[7]|0}get(){const{A:t,B:r,C:n,D:i,E:o,F:s,G:a,H:u}=this;return[t,r,n,i,o,s,a,u]}set(t,r,n,i,o,s,a,u){this.A=t|0,this.B=r|0,this.C=n|0,this.D=i|0,this.E=o|0,this.F=s|0,this.G=a|0,this.H=u|0}process(t,r){for(let d=0;d<16;d++,r+=4)Qi[d]=t.getUint32(r,!1);for(let d=16;d<64;d++){const g=Qi[d-15],v=Qi[d-2],E=(0,qr.rotr)(g,7)^(0,qr.rotr)(g,18)^g>>>3,T=(0,qr.rotr)(v,17)^(0,qr.rotr)(v,19)^v>>>10;Qi[d]=T+Qi[d-7]+E+Qi[d-16]|0}let{A:n,B:i,C:o,D:s,E:a,F:u,G:f,H:h}=this;for(let d=0;d<64;d++){const g=(0,qr.rotr)(a,6)^(0,qr.rotr)(a,11)^(0,qr.rotr)(a,25),v=h+g+(0,ld.Chi)(a,u,f)+KI[d]+Qi[d]|0,E=((0,qr.rotr)(n,2)^(0,qr.rotr)(n,13)^(0,qr.rotr)(n,22))+(0,ld.Maj)(n,i,o)|0;h=f,f=u,u=a,a=s+v|0,s=o,o=i,i=n,n=v+E|0}n=n+this.A|0,i=i+this.B|0,o=o+this.C|0,s=s+this.D|0,a=a+this.E|0,u=u+this.F|0,f=f+this.G|0,h=h+this.H|0,this.set(n,i,o,s,a,u,f,h)}roundClean(){Qi.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}}Fn.SHA256=hd;class jI extends hd{constructor(){super(),this.A=-1056596264,this.B=914150663,this.C=812702999,this.D=-150054599,this.E=-4191439,this.F=1750603025,this.G=1694076839,this.H=-1090891868,this.outputLen=28}}Fn.sha256=(0,qr.wrapConstructor)(()=>new hd),Fn.sha224=(0,qr.wrapConstructor)(()=>new jI);var DI=od,MI=ad,U2=Fn;function FI(e){var t=Object.create(null);return e&&Object.keys(e).forEach(function(r){if(r!=="default"){var n=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(t,r,n.get?n:{enumerable:!0,get:function(){return e[r]}})}}),t.default=e,Object.freeze(t)}var Be=FI(DI);const es="Expected Private",ts="Expected Point",Oa="Expected Tweak",VI="Expected Hash",Vu="Expected Signature",fd="Expected Extra Data (32 bytes)",Ia="Expected Scalar",zI="Bad Recovery Id";Be.utils.hmacSha256Sync=(e,...t)=>MI.hmac(U2.sha256,e,Be.utils.concatBytes(...t)),Be.utils.sha256Sync=(...e)=>U2.sha256(Be.utils.concatBytes(...e));const dd=Be.utils._normalizePrivateKey,WI=32,qI=32,pd=new Uint8Array([255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,254,186,174,220,230,175,72,160,59,191,210,94,140,208,54,65,65]),GI=32,XI=new Uint8Array(32),JI=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,69,81,35,25,80,183,95,196,64,45,161,114,47,201,186,238]);function YI(e){return e instanceof Uint8Array}function xa(e,t){for(let r=0;r<32;++r)if(e[r]!==t[r])return e[r]<t[r]?-1:1;return 0}function R2(e){return xa(e,XI)===0}function $a(e){return!(!(e instanceof Uint8Array)||e.length!==qI||xa(e,pd)>=0)}function yd(e){return e instanceof Uint8Array&&e.length===64&&xa(e.subarray(0,32),pd)<0&&xa(e.subarray(32,64),pd)<0}function ZI(e){return YI(e)&&e.length===64&&xa(e.subarray(0,32),JI)<0}function QI(e){return!(R2(e.subarray(0,32))||R2(e.subarray(32,64)))}function bo(e){return e instanceof Uint8Array&&e.length===WI}function gd(e){return e===void 0||e instanceof Uint8Array&&e.length===GI}function B2(e){if(typeof e!="string")throw new TypeError("hexToNumber: expected string, got "+typeof e);return BigInt(`0x${e}`)}function ex(e){return B2(Be.utils.bytesToHex(e))}function wd(e){let t;if(typeof e=="bigint")t=e;else if(typeof e=="number"&&Number.isSafeInteger(e)&&e>=0)t=BigInt(e);else if(typeof e=="string"){if(e.length!==64)throw new Error("Expected 32 bytes of private scalar");t=B2(e)}else if(e instanceof Uint8Array){if(e.length!==32)throw new Error("Expected 32 bytes of private scalar");t=ex(e)}else throw new TypeError("Expected valid private scalar");if(t<0)throw new Error("Expected private scalar >= 0");return t}const tx=(e,t)=>{const r=dd(e),n=wd(t),i=Be.utils._bigintTo32Bytes(Be.utils.mod(r+n,Be.CURVE.n));return Be.utils.isValidPrivateKey(i)?i:null},rx=(e,t)=>{const r=dd(e),n=wd(t),i=Be.utils._bigintTo32Bytes(Be.utils.mod(r-n,Be.CURVE.n));return Be.utils.isValidPrivateKey(i)?i:null},nx=e=>{const t=dd(e),r=Be.utils._bigintTo32Bytes(Be.CURVE.n-t);return Be.utils.isValidPrivateKey(r)?r:null},H2=(e,t,r)=>{const n=Be.Point.fromHex(e),i=wd(t),o=Be.Point.BASE.multiplyAndAddUnsafe(n,i,BigInt(1));if(!o)throw new Error("Tweaked point at infinity");return o.toRawBytes(r)},ix=(e,t,r)=>{const n=Be.Point.fromHex(e),i=typeof t=="string"?t:Be.utils.bytesToHex(t),o=BigInt(`0x${i}`);return n.multiply(o).toRawBytes(r)};function mo(e,t){return e===void 0?t!==void 0?L2(t):!0:!!e}function Is(e){try{return e()}catch{return null}}function bd(e,t){if(e.length===32!==t)return!1;try{return!!Be.Point.fromHex(e)}catch{return!1}}function rs(e){return bd(e,!1)}function L2(e){return bd(e,!1)&&e.length===33}function yi(e){return Be.utils.isValidPrivateKey(e)}function zu(e){return bd(e,!0)}function sx(e,t){if(!zu(e))throw new Error(ts);if(!$a(t))throw new Error(Oa);return Is(()=>{const r=H2(e,t,!0);return{parity:r[0]%2===1?1:0,xOnlyPubkey:r.slice(1)}})}function K2(e){if(!rs(e))throw new Error(ts);return e.slice(1,33)}function j2(e,t){if(!yi(e))throw new Error(es);return Is(()=>Be.getPublicKey(e,mo(t)))}function ox(e){if(!yi(e))throw new Error(es);return K2(j2(e))}function ax(e,t){if(!rs(e))throw new Error(ts);return Be.Point.fromHex(e).toRawBytes(mo(t,e))}function cx(e,t,r){if(!rs(e))throw new Error(ts);if(!$a(t))throw new Error(Oa);return Is(()=>ix(e,t,mo(r,e)))}function ux(e,t,r){if(!rs(e)||!rs(t))throw new Error(ts);return Is(()=>{const n=Be.Point.fromHex(e),i=Be.Point.fromHex(t);return n.equals(i.negate())?null:n.add(i).toRawBytes(mo(r,e))})}function lx(e,t,r){if(!rs(e))throw new Error(ts);if(!$a(t))throw new Error(Oa);return Is(()=>H2(e,t,mo(r,e)))}function hx(e,t){if(yi(e)===!1)throw new Error(es);if($a(t)===!1)throw new Error(Oa);return Is(()=>tx(e,t))}function fx(e,t){if(yi(e)===!1)throw new Error(es);if($a(t)===!1)throw new Error(Oa);return Is(()=>rx(e,t))}function dx(e){if(yi(e)===!1)throw new Error(es);return nx(e)}function px(e,t,r){if(!yi(t))throw new Error(es);if(!bo(e))throw new Error(Ia);if(!gd(r))throw new Error(fd);return Be.signSync(e,t,{der:!1,extraEntropy:r})}function yx(e,t,r){if(!yi(t))throw new Error(es);if(!bo(e))throw new Error(Ia);if(!gd(r))throw new Error(fd);const[n,i]=Be.signSync(e,t,{der:!1,extraEntropy:r,recovered:!0});return{signature:n,recoveryId:i}}function gx(e,t,r=Buffer.alloc(32,0)){if(!yi(t))throw new Error(es);if(!bo(e))throw new Error(Ia);if(!gd(r))throw new Error(fd);return Be.schnorr.signSync(e,t,r)}function wx(e,t,r,n){if(!bo(e))throw new Error(VI);if(!yd(t)||!QI(t))throw new Error(Vu);if(r&2&&!ZI(t))throw new Error(zI);if(!zu(t.subarray(0,32)))throw new Error(Vu);return Be.recoverPublicKey(e,t,r,mo(n))}function bx(e,t,r,n){if(!rs(t))throw new Error(ts);if(!yd(r))throw new Error(Vu);if(!bo(e))throw new Error(Ia);return Be.verify(r,e,t,{strict:n})}function mx(e,t,r){if(!zu(t))throw new Error(ts);if(!yd(r))throw new Error(Vu);if(!bo(e))throw new Error(Ia);return Be.schnorr.verifySync(r,e,t)}var vx=pt.isPoint=rs,Ex=pt.isPointCompressed=L2,Ax=pt.isPrivate=yi,Sx=pt.isXOnlyPoint=zu,Tx=pt.pointAdd=ux,_x=pt.pointAddScalar=lx,kx=pt.pointCompress=ax,Px=pt.pointFromScalar=j2,Ox=pt.pointMultiply=cx,Ix=pt.privateAdd=hx,xx=pt.privateNegate=dx,$x=pt.privateSub=fx,Cx=pt.recover=wx,Nx=pt.sign=px,Ux=pt.signRecoverable=yx,Rx=pt.signSchnorr=gx,Bx=pt.verify=bx,Hx=pt.verifySchnorr=mx,Lx=pt.xOnlyPointAddTweak=sx,Kx=pt.xOnlyPointFromPoint=K2,jx=pt.xOnlyPointFromScalar=ox;RT(T5({__proto__:null,default:pt,isPoint:vx,isPointCompressed:Ex,isPrivate:Ax,isXOnlyPoint:Sx,pointAdd:Tx,pointAddScalar:_x,pointCompress:kx,pointFromScalar:Px,pointMultiply:Ox,privateAdd:Ix,privateNegate:xx,privateSub:$x,recover:Cx,sign:Nx,signRecoverable:Ux,signSchnorr:Rx,verify:Bx,verifySchnorr:Hx,xOnlyPointAddTweak:Lx,xOnlyPointFromPoint:Kx,xOnlyPointFromScalar:jx},[pt]));const nr=e=>e===Bt||e===xr||e===Ir?I5:wn,md=e=>e.find(({purpose:t})=>t==="ordinals"),vd=e=>e.find(({purpose:t})=>t==="payment"),Xt=async(e,t)=>{try{const r=await D2(e,t);return r?r.reduce((n,i)=>n+BigInt(i.value),0n):0n}catch(r){throw console.error("Error fetching BTC balance:",r),new Error("Failed to fetch BTC balance")}},Dx=e=>/^(?:[A-Za-z0-9+\/]{4})*?(?:[A-Za-z0-9+\/]{2}==|[A-Za-z0-9+\/]{3}=)?$/.test(e),Mx=e=>/^[a-fA-F0-9]+$/.test(e);function Fx(e,t,r){const n=e*57+t*41,i=r*34;return 10+n+i}async function D2(e,t){if(e.startsWith("t")){if(t===vt)return[];if(t===fo)return[];if(t===$r)return[]}return await Xe.get(`${pi(t)}/api/address/${e}/utxo`).then(r=>r.data)}async function M2(e,t,r,n,i,o,s=7){const a=e===t,u=await D2(t,o);if(!u)throw new Error("No UTXOs found");const f=u.sort((T,x)=>x.value-T.value),h=new dt({network:nr(o)}),d=Fx(1,0,2),g=Math.floor(d*s)+n;let v=0,E=0;for await(let T of f){const{txid:x,vout:N,value:I}=T,k=M1(t,nr(o));if(h.addInput({hash:x,index:N,witnessUtxo:{script:k,value:BigInt(I)}}),!a){const B=Vx(i,o);h.updateInput(E,{redeemScript:B})}if(v+=I,v>=g)break}if(v<g)throw new Error("Insufficient funds");return h.addOutput({address:r,value:BigInt(n)}),v>g&&h.addOutput({address:t,value:BigInt(v-g)}),{psbtBase64:h.toBase64(),psbtHex:h.toHex()}}function Vx(e,t){var r;const n=fa({pubkey:k2.Buffer.from(e,"hex"),network:nr(t)}),i=ao({redeem:n,network:nr(t)});return(r=i==null?void 0:i.redeem)==null?void 0:r.output}class zx extends Dn{constructor(){super(...arguments),ge(this,"observer")}get library(){return window.unisat}get network(){return this.$network.get()}initialize(){typeof window<"u"&&typeof document<"u"&&(this.observer=new window.MutationObserver(()=>{var t;this.library&&(this.$store.setKey("hasProvider",{...this.$store.get().hasProvider,[ji]:!0}),(t=this.observer)==null||t.disconnect())}),this.observer.observe(document,{childList:!0,subtree:!0})),gn(this.$store,["provider"],t=>{if(t.provider!==ji){this.removeListeners();return}this.library.getAccounts().then(r=>{this.handleAccountsChanged(r)}),this.addListeners()})}addListeners(){this.library.on("accountsChanged",this.handleAccountsChanged.bind(this)),this.library.on("networkChanged",this.handleNetworkChanged.bind(this))}removeListeners(){this.library.removeListener("accountsChanged",this.handleAccountsChanged.bind(this)),this.library.removeListener("networkChanged",this.handleNetworkChanged.bind(this))}dispose(){var t;(t=this.observer)==null||t.disconnect(),this.removeListeners()}handleAccountsChanged(t){if(!t.length){this.parent.disconnect();return}this.$store.get().accounts[0]!==t[0]&&(this.$store.setKey("accounts",t),t.length>0?this.parent.connect(ji):this.parent.disconnect())}handleNetworkChanged(t){const r=Ea(t);this.network!==r&&this.switchNetwork(r),this.parent.connect(ji)}async connect(t){if(!this.library)throw new Error("Unisat isn't installed");const r=await this.library.requestAccounts();if(!r)throw new Error("No accounts found");const n=await this.library.getPublicKey();if(!n)throw new Error("No public key found");this.$store.setKey("accounts",r),this.$store.setKey("address",r[0]),this.$store.setKey("paymentAddress",r[0]),this.$store.setKey("publicKey",n),this.$store.setKey("paymentPublicKey",n),this.$store.setKey("provider",ji),await this.getNetwork().then(i=>{var o;((o=this.config)==null?void 0:o.network)!==i&&this.switchNetwork(i)}),Xt(r[0],this.network).then(i=>{this.$store.setKey("balance",i)}),this.$store.setKey("connected",!0)}async getNetwork(){var t;const r=await((t=this.library)==null?void 0:t.getChain());return r?Ea(r.enum):this.network}async sendBTC(t,r){var n;const i=await((n=this.library)==null?void 0:n.sendBitcoin(t,r));if(!i)throw new Error("Transaction failed");return i}async signMessage(t,r){var n;return await((n=this.library)==null?void 0:n.signMessage(t))}async signPsbt(t,r,n,i,o){var s;const a=await((s=this.library)==null?void 0:s.signPsbt(r,{autoFinalized:i})),u=dt.fromHex(a);if(i&&o){const f=await this.pushPsbt(a);return{signedPsbtHex:u.toHex(),signedPsbtBase64:u.toBase64(),txId:f}}return{signedPsbtHex:u.toHex(),signedPsbtBase64:u.toBase64(),txId:void 0}}async pushPsbt(t){return await Xe.post(`${pi(this.network)}/api/tx`,t).then(r=>r.data)}async getPublicKey(){var t;return await((t=this.library)==null?void 0:t.getPublicKey())}async getBalance(){return(await this.library.getBalance()).total}async getInscriptions(){return await this.library.getInscriptions(0,10)}async requestAccounts(){return await this.library.requestAccounts()}async switchNetwork(t){var r;const n=Df(t);await((r=this.library)==null?void 0:r.switchChain(n)),this.$network.set(t),await this.getBalance()}}function Wx(){typeof window<"u"&&typeof localStorage<"u"&&setTimeout(()=>{const e=document.createTextNode(" ");document.body.appendChild(e),e.remove()},1500)}function qx(){return{$store:Lg({provider:void 0,address:"",paymentAddress:"",publicKey:"",paymentPublicKey:"",connected:!1,isConnecting:!1,isInitializing:!0,accounts:[],balance:void 0,hasProvider:{[ji]:!1,[ii]:!1,[ms]:!1,[si]:!1,[Fi]:!1,[Es]:!1,[vs]:!1,[Di]:!1,[As]:!1,[Mi]:!1}}),$network:ef(vt),$library:ef(void 0)}}function Gx({network:e}){return{network:e}}function Xx(e,t){var r;return(r=void 0)==null?void 0:r.get(t)}function Wu(e){var t,r;let n=typeof e;return n==="object"&&(n=(e&&((r=(t=Object.getPrototypeOf(e))==null?void 0:t.constructor)==null?void 0:r.name))??"null"),n==="string"?`"${e}"`:n==="number"||n==="bigint"||n==="boolean"?`${e}`:n}function mr(e,t,r,n,i){const o=i&&"input"in i?i.input:r.value,s=(i==null?void 0:i.expected)??e.expects??null,a=(i==null?void 0:i.received)??Wu(o),u={kind:e.kind,type:e.type,input:o,expected:s,received:a,message:`Invalid ${t}: ${s?`Expected ${s} but r`:"R"}eceived ${a}`,requirement:e.requirement,path:i==null?void 0:i.path,issues:i==null?void 0:i.issues,lang:n.lang,abortEarly:n.abortEarly,abortPipeEarly:n.abortPipeEarly},f=e.kind==="schema",h=(i==null?void 0:i.message)??e.message??Xx(e.reference,u.lang)??(f?(u.lang,void 0):null)??n.message??(u.lang,void 0);h&&(u.message=typeof h=="function"?h(u):h),f&&(r.typed=!1),r.issues?r.issues.push(u):r.issues=[u]}function Jx(e,t){return Object.hasOwn(e,t)&&t!=="__proto__"&&t!=="prototype"&&t!=="constructor"}function F2(e,t,r){return typeof e.default=="function"?e.default(t,r):e.default}function V2(e,t){return!e._run({typed:!1,value:t},{abortEarly:!0}).issues}function Tn(e,t){return{kind:"schema",type:"array",reference:Tn,expects:"Array",async:!1,item:e,message:t,_run(r,n){var i;const o=r.value;if(Array.isArray(o)){r.typed=!0,r.value=[];for(let s=0;s<o.length;s++){const a=o[s],u=this.item._run({typed:!1,value:a},n);if(u.issues){const f={type:"array",origin:"value",input:o,key:s,value:a};for(const h of u.issues)h.path?h.path.unshift(f):h.path=[f],(i=r.issues)==null||i.push(h);if(r.issues||(r.issues=u.issues),n.abortEarly){r.typed=!1;break}}u.typed||(r.typed=!1),r.value.push(u.value)}}else mr(this,"type",r,n);return r}}}function z2(e){return{kind:"schema",type:"boolean",reference:z2,expects:"boolean",async:!1,message:e,_run(t,r){return typeof t.value=="boolean"?t.typed=!0:mr(this,"type",t,r),t}}}function xs(e,t){const r=Object.entries(e).filter(([n])=>isNaN(+n)).map(([,n])=>n);return{kind:"schema",type:"enum",reference:xs,expects:r.map(Wu).join(" | ")||"never",async:!1,enum:e,options:r,message:t,_run(n,i){return this.options.includes(n.value)?n.typed=!0:mr(this,"type",n,i),n}}}function yt(e,t){return{kind:"schema",type:"literal",reference:yt,expects:Wu(e),async:!1,literal:e,message:t,_run(r,n){return r.value===this.literal?r.typed=!0:mr(this,"type",r,n),r}}}function W2(e,t){return{kind:"schema",type:"loose_object",reference:W2,expects:"Object",async:!1,entries:e,message:t,_run(r,n){var i;const o=r.value;if(o&&typeof o=="object"){r.typed=!0,r.value={};for(const s in this.entries){const a=o[s],u=this.entries[s]._run({typed:!1,value:a},n);if(u.issues){const f={type:"object",origin:"value",input:o,key:s,value:a};for(const h of u.issues)h.path?h.path.unshift(f):h.path=[f],(i=r.issues)==null||i.push(h);if(r.issues||(r.issues=u.issues),n.abortEarly){r.typed=!1;break}}u.typed||(r.typed=!1),(u.value!==void 0||s in o)&&(r.value[s]=u.value)}if(!r.issues||!n.abortEarly)for(const s in o)Jx(o,s)&&!(s in this.entries)&&(r.value[s]=o[s])}else mr(this,"type",r,n);return r}}}function Ed(e,t){return{kind:"schema",type:"non_optional",reference:Ed,expects:"!undefined",async:!1,wrapped:e,message:t,_run(r,n){return r.value===void 0?(mr(this,"type",r,n),r):this.wrapped._run(r,n)}}}function $s(e){return{kind:"schema",type:"null",reference:$s,expects:"null",async:!1,message:e,_run(t,r){return t.value===null?t.typed=!0:mr(this,"type",t,r),t}}}function Cs(e,...t){const r={kind:"schema",type:"nullish",reference:Cs,expects:`${e.expects} | null | undefined`,async:!1,wrapped:e,_run(n,i){return(n.value===null||n.value===void 0)&&("default"in this&&(n.value=F2(this,n,i)),n.value===null||n.value===void 0)?(n.typed=!0,n):this.wrapped._run(n,i)}};return 0 in t&&(r.default=t[0]),r}function Vn(e){return{kind:"schema",type:"number",reference:Vn,expects:"number",async:!1,message:e,_run(t,r){return typeof t.value=="number"&&!isNaN(t.value)?t.typed=!0:mr(this,"type",t,r),t}}}function fe(e,t){return{kind:"schema",type:"object",reference:fe,expects:"Object",async:!1,entries:e,message:t,_run(r,n){var i;const o=r.value;if(o&&typeof o=="object"){r.typed=!0,r.value={};for(const s in this.entries){const a=o[s],u=this.entries[s]._run({typed:!1,value:a},n);if(u.issues){const f={type:"object",origin:"value",input:o,key:s,value:a};for(const h of u.issues)h.path?h.path.unshift(f):h.path=[f],(i=r.issues)==null||i.push(h);if(r.issues||(r.issues=u.issues),n.abortEarly){r.typed=!1;break}}u.typed||(r.typed=!1),(u.value!==void 0||s in o)&&(r.value[s]=u.value)}}else mr(this,"type",r,n);return r}}}function _n(e,...t){const r={kind:"schema",type:"optional",reference:_n,expects:`${e.expects} | undefined`,async:!1,wrapped:e,_run(n,i){return n.value===void 0&&("default"in this&&(n.value=F2(this,n,i)),n.value===void 0)?(n.typed=!0,n):this.wrapped._run(n,i)}};return 0 in t&&(r.default=t[0]),r}function q2(e,t){return{kind:"schema",type:"picklist",reference:q2,expects:e.map(Wu).join(" | ")||"never",async:!1,options:e,message:t,_run(r,n){return this.options.includes(r.value)?r.typed=!0:mr(this,"type",r,n),r}}}function be(e){return{kind:"schema",type:"string",reference:be,expects:"string",async:!1,message:e,_run(t,r){return typeof t.value=="string"?t.typed=!0:mr(this,"type",t,r),t}}}function Ad(e){return{kind:"schema",type:"undefined",reference:Ad,expects:"undefined",async:!1,message:e,_run(t,r){return t.value===void 0?t.typed=!0:mr(this,"type",t,r),t}}}function G2(e){let t;if(e)for(const r of e)t?t.push(...r.issues):t=r.issues;return t}function qu(e,t){return{kind:"schema",type:"union",reference:qu,expects:[...new Set(e.map(r=>r.expects))].join(" | ")||"never",async:!1,options:e,message:t,_run(r,n){let i,o,s;for(const a of this.options){const u=a._run({typed:!1,value:r.value},n);if(u.typed)if(u.issues)o?o.push(u):o=[u];else{i=u;break}else s?s.push(u):s=[u]}if(i)return i;if(o){if(o.length===1)return o[0];mr(this,"type",r,n,{issues:G2(o)}),r.typed=!0}else{if((s==null?void 0:s.length)===1)return s[0];mr(this,"type",r,n,{issues:G2(s)})}return r}}}function Gu(){return{kind:"schema",type:"unknown",reference:Gu,expects:"unknown",async:!1,_run(e){return e.typed=!0,e}}}var Gr={},vo={},ir={};Object.defineProperty(ir,"__esModule",{value:!0}),ir.decode=ir.encode=ir.unescape=ir.escape=ir.pad=void 0;const X2=go;function Sd(e){return`${e}${"=".repeat(4-(e.length%4||4))}`}ir.pad=Sd;function J2(e){return e.replace(/=/g,"").replace(/\+/g,"-").replace(/\//g,"_")}ir.escape=J2;function Y2(e){return Sd(e).replace(/-/g,"+").replace(/_/g,"/")}ir.unescape=Y2;function Yx(e){return J2((0,X2.fromByteArray)(new TextEncoder().encode(e)))}ir.encode=Yx;function Zx(e){return new TextDecoder().decode((0,X2.toByteArray)(Sd(Y2(e))))}ir.decode=Zx;var Xu={},Ju={},Eo={};Object.defineProperty(Eo,"__esModule",{value:!0}),Eo.joseToDer=Eo.derToJose=void 0;const Z2=go,Q2=ir;function Td(e){return(e/8|0)+(e%8===0?0:1)}const Qx={ES256:Td(256),ES384:Td(384),ES512:Td(521)};function eb(e){const t=Qx[e];if(t)return t;throw new Error(`Unknown algorithm "${e}"`)}const Yu=128,tb=0,e$=32,t$=16,r$=2,rb=t$|e$|tb<<6,Zu=r$|tb<<6;function nb(e){if(e instanceof Uint8Array)return e;if(typeof e=="string")return(0,Z2.toByteArray)((0,Q2.pad)(e));throw new TypeError("ECDSA signature must be a Base64 string or a Uint8Array")}function n$(e,t){const r=nb(e),n=eb(t),i=n+1,o=r.length;let s=0;if(r[s++]!==rb)throw new Error('Could not find expected "seq"');let a=r[s++];if(a===(Yu|1)&&(a=r[s++]),o-s<a)throw new Error(`"seq" specified length of "${a}", only "${o-s}" remaining`);if(r[s++]!==Zu)throw new Error('Could not find expected "int" for "r"');const u=r[s++];if(o-s-2<u)throw new Error(`"r" specified length of "${u}", only "${o-s-2}" available`);if(i<u)throw new Error(`"r" specified length of "${u}", max of "${i}" is acceptable`);const f=s;if(s+=u,r[s++]!==Zu)throw new Error('Could not find expected "int" for "s"');const h=r[s++];if(o-s!==h)throw new Error(`"s" specified length of "${h}", expected "${o-s}"`);if(i<h)throw new Error(`"s" specified length of "${h}", max of "${i}" is acceptable`);const d=s;if(s+=h,s!==o)throw new Error(`Expected to consume entire array, but "${o-s}" bytes remain`);const g=n-u,v=n-h,E=new Uint8Array(g+u+v+h);for(s=0;s<g;++s)E[s]=0;E.set(r.subarray(f+Math.max(-g,0),f+u),s),s=n;for(const T=s;s<T+v;++s)E[s]=0;return E.set(r.subarray(d+Math.max(-v,0),d+h),s),(0,Q2.escape)((0,Z2.fromByteArray)(E))}Eo.derToJose=n$;function ib(e,t,r){let n=0;for(;t+n<r&&e[t+n]===0;)++n;return e[t+n]>=Yu&&--n,n}function i$(e,t){e=nb(e);const r=eb(t),n=e.length;if(n!==r*2)throw new TypeError(`"${t}" signatures must be "${r*2}" bytes, saw "${n}"`);const i=ib(e,0,r),o=ib(e,r,e.length),s=r-i,a=r-o,u=2+s+1+1+a,f=u<Yu,h=new Uint8Array((f?2:3)+u);let d=0;return h[d++]=rb,f?h[d++]=u:(h[d++]=Yu|1,h[d++]=u&255),h[d++]=Zu,h[d++]=s,i<0?(h[d++]=0,h.set(e.subarray(0,r),d),d+=r):(h.set(e.subarray(i,r),d),d+=r-i),h[d++]=Zu,h[d++]=a,o<0?(h[d++]=0,h.set(e.subarray(r),d)):h.set(e.subarray(r+o),d),h}Eo.joseToDer=i$;var gi={};Object.defineProperty(gi,"__esModule",{value:!0}),gi.InvalidTokenError=gi.MissingParametersError=void 0;class s$ extends Error{constructor(t){super(),this.name="MissingParametersError",this.message=t||""}}gi.MissingParametersError=s$;class o$ extends Error{constructor(t){super(),this.name="InvalidTokenError",this.message=t||""}}gi.InvalidTokenError=o$,Object.defineProperty(Ju,"__esModule",{value:!0}),Ju.SECP256K1Client=void 0;const a$=ad,c$=Fn,Qu=od,sb=Eo,ob=gi,ab=ka;Qu.utils.hmacSha256Sync=(e,...t)=>{const r=a$.hmac.create(c$.sha256,e);return t.forEach(n=>r.update(n)),r.digest()};class cb{static derivePublicKey(t,r=!0){return t.length===66&&(t=t.slice(0,64)),t.length<64&&(t=t.padStart(64,"0")),(0,ab.bytesToHex)(Qu.getPublicKey(t,r))}static signHash(t,r,n="jose"){if(!t||!r)throw new ob.MissingParametersError("a signing input hash and private key are all required");const i=Qu.signSync(t,r.slice(0,64),{der:!0,canonical:!1});if(n==="der")return(0,ab.bytesToHex)(i);if(n==="jose")return(0,sb.derToJose)(i,"ES256");throw Error("Invalid signature format")}static loadSignature(t){return(0,sb.joseToDer)(t,"ES256")}static verifyHash(t,r,n){if(!t||!r||!n)throw new ob.MissingParametersError("a signing input hash, der signature, and public key are all required");return Qu.verify(r,t,n,{strict:!1})}}Ju.SECP256K1Client=cb,cb.algorithmName="ES256K",function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.cryptoClients=e.SECP256K1Client=void 0;const t=Ju;Object.defineProperty(e,"SECP256K1Client",{enumerable:!0,get:function(){return t.SECP256K1Client}});const r={ES256K:t.SECP256K1Client};e.cryptoClients=r}(Xu);var Ns={},u$=Te&&Te.__awaiter||function(e,t,r,n){function i(o){return o instanceof r?o:new r(function(s){s(o)})}return new(r||(r=Promise))(function(o,s){function a(h){try{f(n.next(h))}catch(d){s(d)}}function u(h){try{f(n.throw(h))}catch(d){s(d)}}function f(h){h.done?o(h.value):i(h.value).then(a,u)}f((n=n.apply(e,t||[])).next())})};Object.defineProperty(Ns,"__esModule",{value:!0}),Ns.hashSha256Async=Ns.hashSha256=void 0;const l$=Fn;function ub(e){return(0,l$.sha256)(e)}Ns.hashSha256=ub;function h$(e){return u$(this,void 0,void 0,function*(){try{if(typeof crypto<"u"&&typeof crypto.subtle<"u"){const t=typeof e=="string"?new TextEncoder().encode(e):e,r=yield crypto.subtle.digest("SHA-256",t);return new Uint8Array(r)}else{const t=O2;if(!t.createHash)throw new Error("`crypto` module does not contain `createHash`");return Promise.resolve(t.createHash("sha256").update(e).digest())}}catch(t){return console.log(t),console.log('Crypto lib not found. Neither the global `crypto.subtle` Web Crypto API, nor the or the Node.js `require("crypto").createHash` module is available. Falling back to JS implementation.'),Promise.resolve(ub(e))}})}Ns.hashSha256Async=h$;var f$=Te&&Te.__awaiter||function(e,t,r,n){function i(o){return o instanceof r?o:new r(function(s){s(o)})}return new(r||(r=Promise))(function(o,s){function a(h){try{f(n.next(h))}catch(d){s(d)}}function u(h){try{f(n.throw(h))}catch(d){s(d)}}function f(h){h.done?o(h.value):i(h.value).then(a,u)}f((n=n.apply(e,t||[])).next())})};Object.defineProperty(vo,"__esModule",{value:!0}),vo.TokenSigner=vo.createUnsecuredToken=void 0;const _d=ir,lb=Xu,d$=gi,hb=Ns;function kd(e,t){const r=[],n=_d.encode(JSON.stringify(t));r.push(n);const i=_d.encode(JSON.stringify(e));return r.push(i),r.join(".")}function p$(e){return kd(e,{typ:"JWT",alg:"none"})+"."}vo.createUnsecuredToken=p$;class y${constructor(t,r){if(!(t&&r))throw new d$.MissingParametersError("a signing algorithm and private key are required");if(typeof t!="string")throw new Error("signing algorithm parameter must be a string");if(t=t.toUpperCase(),!lb.cryptoClients.hasOwnProperty(t))throw new Error("invalid signing algorithm");this.tokenType="JWT",this.cryptoClient=lb.cryptoClients[t],this.rawPrivateKey=r}header(t={}){const r={typ:this.tokenType,alg:this.cryptoClient.algorithmName};return Object.assign({},r,t)}sign(t,r=!1,n={}){const i=this.header(n),o=kd(t,i),s=(0,hb.hashSha256)(o);return this.createWithSignedHash(t,r,i,o,s)}signAsync(t,r=!1,n={}){return f$(this,void 0,void 0,function*(){const i=this.header(n),o=kd(t,i),s=yield(0,hb.hashSha256Async)(o);return this.createWithSignedHash(t,r,i,o,s)})}createWithSignedHash(t,r,n,i,o){const s=this.cryptoClient.signHash(o,this.rawPrivateKey);return r?{header:[_d.encode(JSON.stringify(n))],payload:JSON.stringify(t),signature:[s]}:[i,s].join(".")}}vo.TokenSigner=y$;var el={};Object.defineProperty(el,"__esModule",{value:!0}),el.TokenVerifier=void 0;const g$=ir,fb=Xu,w$=gi,tl=Ns;class b${constructor(t,r){if(!(t&&r))throw new w$.MissingParametersError("a signing algorithm and public key are required");if(typeof t!="string")throw"signing algorithm parameter must be a string";if(t=t.toUpperCase(),!fb.cryptoClients.hasOwnProperty(t))throw"invalid signing algorithm";this.tokenType="JWT",this.cryptoClient=fb.cryptoClients[t],this.rawPublicKey=r}verify(t){return typeof t=="string"?this.verifyCompact(t,!1):typeof t=="object"?this.verifyExpanded(t,!1):!1}verifyAsync(t){return typeof t=="string"?this.verifyCompact(t,!0):typeof t=="object"?this.verifyExpanded(t,!0):Promise.resolve(!1)}verifyCompact(t,r){const n=t.split("."),i=n[0]+"."+n[1],o=s=>{const a=this.cryptoClient.loadSignature(n[2]);return this.cryptoClient.verifyHash(s,a,this.rawPublicKey)};if(r)return(0,tl.hashSha256Async)(i).then(s=>o(s));{const s=(0,tl.hashSha256)(i);return o(s)}}verifyExpanded(t,r){const n=[t.header.join("."),g$.encode(t.payload)].join(".");let i=!0;const o=s=>(t.signature.map(a=>{const u=this.cryptoClient.loadSignature(a);this.cryptoClient.verifyHash(s,u,this.rawPublicKey)||(i=!1)}),i);if(r)return(0,tl.hashSha256Async)(n).then(s=>o(s));{const s=(0,tl.hashSha256)(n);return o(s)}}}el.TokenVerifier=b$;var rl={};Object.defineProperty(rl,"__esModule",{value:!0}),rl.decodeToken=void 0;const nl=ir;function m$(e){if(typeof e=="string"){const t=e.split("."),r=JSON.parse(nl.decode(t[0])),n=JSON.parse(nl.decode(t[1])),i=t[2];return{header:r,payload:n,signature:i}}else if(typeof e=="object"){if(typeof e.payload!="string")throw new Error("Expected token payload to be a base64 or json string");let t=e.payload;e.payload[0]!=="{"&&(t=nl.decode(t));const r=[];return e.header.map(n=>{const i=JSON.parse(nl.decode(n));r.push(i)}),{header:r,payload:JSON.parse(t),signature:e.signature}}}rl.decodeToken=m$,function(e){var t=Te&&Te.__createBinding||(Object.create?function(n,i,o,s){s===void 0&&(s=o);var a=Object.getOwnPropertyDescriptor(i,o);(!a||("get"in a?!i.__esModule:a.writable||a.configurable))&&(a={enumerable:!0,get:function(){return i[o]}}),Object.defineProperty(n,s,a)}:function(n,i,o,s){s===void 0&&(s=o),n[s]=i[o]}),r=Te&&Te.__exportStar||function(n,i){for(var o in n)o!=="default"&&!Object.prototype.hasOwnProperty.call(i,o)&&t(i,n,o)};Object.defineProperty(e,"__esModule",{value:!0}),r(vo,e),r(el,e),r(rl,e),r(gi,e),r(Xu,e)}(Gr);/*! *****************************************************************************
45
45
  Copyright (c) Microsoft Corporation.
46
46
 
47
47
  Permission to use, copy, modify, and/or distribute this software for any
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@omnisat/lasereyes",
3
3
  "private": false,
4
- "version": "0.0.94",
4
+ "version": "0.0.96",
5
5
  "type": "module",
6
6
  "main": "./dist/index.umd.cjs",
7
7
  "module": "./dist/index.js",
@@ -22,8 +22,8 @@
22
22
  "vite-plugin-dts": "^4.2.1"
23
23
  },
24
24
  "dependencies": {
25
- "@omnisat/lasereyes-core": "0.0.25-rc.3",
26
- "@omnisat/lasereyes-react": "0.0.17"
25
+ "@omnisat/lasereyes-core": "0.0.26",
26
+ "@omnisat/lasereyes-react": "0.0.19"
27
27
  },
28
28
  "publishConfig": {
29
29
  "access": "public"