@smartledger/bsv 7.12.0 → 7.13.0
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/CHANGELOG.md +72 -0
- package/README.md +38 -38
- package/bsv-didweb.min.js +6 -6
- package/bsv-gdaf.min.js +58 -58
- package/bsv-ltp.min.js +41 -41
- package/bsv-mnemonic.min.js +8 -8
- package/bsv-smartcontract.min.js +1 -1
- package/bsv.bundle.js +58 -58
- package/bsv.min.js +58 -58
- package/docs/AUDIT_SCOPE.md +18 -19
- package/docs/MODULE_REFERENCE_COMPLETE.md +27 -27
- package/docs/advanced/UTXO_MANAGER_GUIDE.md +1 -1
- package/docs/getting-started/INSTALLATION.md +23 -23
- package/docs/getting-started/QUICK_START.md +7 -7
- package/docs/migration/FROM_BSV_1_5_6.md +5 -5
- package/index.js +10 -2
- package/lib/crypto/hash.browser.js +13 -5
- package/lib/crypto/hash.js +58 -2
- package/lib/crypto/random.js +72 -15
- package/lib/didweb/index.js +88 -9
- package/lib/encoding/base58.js +67 -3
- package/lib/mnemonic/mnemonic.js +19 -5
- package/lib/mnemonic/pbkdf2.js +35 -2
- package/lib/script/interpreter.js +21 -2
- package/lib/transaction/input/multisig.js +1 -1
- package/lib/transaction/input/multisigscripthash.js +1 -1
- package/lib/transaction/input/publickey.js +1 -1
- package/lib/transaction/input/publickeyhash.js +1 -1
- package/lib/transaction/signature.js +1 -1
- package/lib/util/inherits.js +37 -0
- package/package.json +4 -8
- package/test/crypto/backend_selection.js +126 -0
- package/test/crypto/random.js +73 -0
- package/test/didweb/relationships.js +144 -0
- package/test/transaction/unspentoutput.js +6 -1
- package/version.js +1 -1
package/bsv-ltp.min.js
CHANGED
|
@@ -1,70 +1,70 @@
|
|
|
1
|
-
var bsvLTP=(()=>{var mI=Object.create;var bs=Object.defineProperty;var vI=Object.getOwnPropertyDescriptor;var bI=Object.getOwnPropertyNames;var _I=Object.getPrototypeOf,wI=Object.prototype.hasOwnProperty;var SI=(e,t,r)=>t in e?bs(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r;var fr=(e,t,r)=>()=>{if(r)throw r[0];try{return e&&(t=e(e=0)),t}catch(n){throw r=[n],n}};var P=(e,t)=>()=>{try{return t||e((t={exports:{}}).exports,t),t.exports}catch(r){throw t=0,r}},EI=(e,t)=>{for(var r in t)bs(e,r,{get:t[r],enumerable:!0})},Qp=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of bI(t))!wI.call(e,i)&&i!==r&&bs(e,i,{get:()=>t[i],enumerable:!(n=vI(t,i))||n.enumerable});return e};var e0=(e,t,r)=>(r=e!=null?mI(_I(e)):{},Qp(t||!e||!e.__esModule?bs(r,"default",{value:e,enumerable:!0}):r,e)),xI=e=>Qp(bs({},"__esModule",{value:!0}),e);var fe=(e,t,r)=>SI(e,typeof t!="symbol"?t+"":t,r);var o0=P((z4,i0)=>{p();var et=i0.exports={},$r,Zr;function eh(){throw new Error("setTimeout has not been defined")}function th(){throw new Error("clearTimeout has not been defined")}(function(){try{typeof setTimeout=="function"?$r=setTimeout:$r=eh}catch{$r=eh}try{typeof clearTimeout=="function"?Zr=clearTimeout:Zr=th}catch{Zr=th}})();function t0(e){if($r===setTimeout)return setTimeout(e,0);if(($r===eh||!$r)&&setTimeout)return $r=setTimeout,setTimeout(e,0);try{return $r(e,0)}catch{try{return $r.call(null,e,0)}catch{return $r.call(this,e,0)}}}function II(e){if(Zr===clearTimeout)return clearTimeout(e);if((Zr===th||!Zr)&&clearTimeout)return Zr=clearTimeout,clearTimeout(e);try{return Zr(e)}catch{try{return Zr.call(null,e)}catch{return Zr.call(this,e)}}}var _n=[],co=!1,bi,Ja=-1;function AI(){!co||!bi||(co=!1,bi.length?_n=bi.concat(_n):Ja=-1,_n.length&&r0())}function r0(){if(!co){var e=t0(AI);co=!0;for(var t=_n.length;t;){for(bi=_n,_n=[];++Ja<t;)bi&&bi[Ja].run();Ja=-1,t=_n.length}bi=null,co=!1,II(e)}}et.nextTick=function(e){var t=new Array(arguments.length-1);if(arguments.length>1)for(var r=1;r<arguments.length;r++)t[r-1]=arguments[r];_n.push(new n0(e,t)),_n.length===1&&!co&&t0(r0)};function n0(e,t){this.fun=e,this.array=t}n0.prototype.run=function(){this.fun.apply(null,this.array)};et.title="browser";et.browser=!0;et.env={};et.argv=[];et.version="";et.versions={};function wn(){}et.on=wn;et.addListener=wn;et.once=wn;et.off=wn;et.removeListener=wn;et.removeAllListeners=wn;et.emit=wn;et.prependListener=wn;et.prependOnceListener=wn;et.listeners=function(e){return[]};et.binding=function(e){throw new Error("process.binding is not supported")};et.cwd=function(){return"/"};et.chdir=function(e){throw new Error("process.chdir is not supported")};et.umask=function(){return 0}});var u0=P(Qa=>{"use strict";p();Qa.byteLength=RI;Qa.toByteArray=PI;Qa.fromByteArray=MI;var Xr=[],mr=[],OI=typeof Uint8Array<"u"?Uint8Array:Array,rh="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";for(_i=0,s0=rh.length;_i<s0;++_i)Xr[_i]=rh[_i],mr[rh.charCodeAt(_i)]=_i;var _i,s0;mr[45]=62;mr[95]=63;function a0(e){var t=e.length;if(t%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var r=e.indexOf("=");r===-1&&(r=t);var n=r===t?0:4-r%4;return[r,n]}function RI(e){var t=a0(e),r=t[0],n=t[1];return(r+n)*3/4-n}function TI(e,t,r){return(t+r)*3/4-r}function PI(e){var t,r=a0(e),n=r[0],i=r[1],o=new OI(TI(e,n,i)),s=0,a=i>0?n-4:n,c;for(c=0;c<a;c+=4)t=mr[e.charCodeAt(c)]<<18|mr[e.charCodeAt(c+1)]<<12|mr[e.charCodeAt(c+2)]<<6|mr[e.charCodeAt(c+3)],o[s++]=t>>16&255,o[s++]=t>>8&255,o[s++]=t&255;return i===2&&(t=mr[e.charCodeAt(c)]<<2|mr[e.charCodeAt(c+1)]>>4,o[s++]=t&255),i===1&&(t=mr[e.charCodeAt(c)]<<10|mr[e.charCodeAt(c+1)]<<4|mr[e.charCodeAt(c+2)]>>2,o[s++]=t>>8&255,o[s++]=t&255),o}function BI(e){return Xr[e>>18&63]+Xr[e>>12&63]+Xr[e>>6&63]+Xr[e&63]}function NI(e,t,r){for(var n,i=[],o=t;o<r;o+=3)n=(e[o]<<16&16711680)+(e[o+1]<<8&65280)+(e[o+2]&255),i.push(BI(n));return i.join("")}function MI(e){for(var t,r=e.length,n=r%3,i=[],o=16383,s=0,a=r-n;s<a;s+=o)i.push(NI(e,s,s+o>a?a:s+o));return n===1?(t=e[r-1],i.push(Xr[t>>2]+Xr[t<<4&63]+"==")):n===2&&(t=(e[r-2]<<8)+e[r-1],i.push(Xr[t>>10]+Xr[t>>4&63]+Xr[t<<2&63]+"=")),i.join("")}});var f0=P(nh=>{p();nh.read=function(e,t,r,n,i){var o,s,a=i*8-n-1,c=(1<<a)-1,l=c>>1,g=-7,m=r?i-1:0,_=r?-1:1,x=e[t+m];for(m+=_,o=x&(1<<-g)-1,x>>=-g,g+=a;g>0;o=o*256+e[t+m],m+=_,g-=8);for(s=o&(1<<-g)-1,o>>=-g,g+=n;g>0;s=s*256+e[t+m],m+=_,g-=8);if(o===0)o=1-l;else{if(o===c)return s?NaN:(x?-1:1)*(1/0);s=s+Math.pow(2,n),o=o-l}return(x?-1:1)*s*Math.pow(2,o-n)};nh.write=function(e,t,r,n,i,o){var s,a,c,l=o*8-i-1,g=(1<<l)-1,m=g>>1,_=i===23?Math.pow(2,-24)-Math.pow(2,-77):0,x=n?0:o-1,R=n?1:-1,B=t<0||t===0&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(a=isNaN(t)?1:0,s=g):(s=Math.floor(Math.log(t)/Math.LN2),t*(c=Math.pow(2,-s))<1&&(s--,c*=2),s+m>=1?t+=_/c:t+=_*Math.pow(2,1-m),t*c>=2&&(s++,c/=2),s+m>=g?(a=0,s=g):s+m>=1?(a=(t*c-1)*Math.pow(2,i),s=s+m):(a=t*Math.pow(2,m-1)*Math.pow(2,i),s=0));i>=8;e[r+x]=a&255,x+=R,a/=256,i-=8);for(s=s<<i|a,l+=i;l>0;e[r+x]=s&255,x+=R,s/=256,l-=8);e[r+x-R]|=B*128}});var Pt=P(go=>{"use strict";p();var ih=u0(),lo=f0(),c0=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):null;go.Buffer=D;go.SlowBuffer=qI;go.INSPECT_MAX_BYTES=50;var eu=2147483647;go.kMaxLength=eu;D.TYPED_ARRAY_SUPPORT=kI();!D.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 kI(){try{let e=new Uint8Array(1),t={foo:function(){return 42}};return Object.setPrototypeOf(t,Uint8Array.prototype),Object.setPrototypeOf(e,t),e.foo()===42}catch{return!1}}Object.defineProperty(D.prototype,"parent",{enumerable:!0,get:function(){if(D.isBuffer(this))return this.buffer}});Object.defineProperty(D.prototype,"offset",{enumerable:!0,get:function(){if(D.isBuffer(this))return this.byteOffset}});function Sn(e){if(e>eu)throw new RangeError('The value "'+e+'" is invalid for option "size"');let t=new Uint8Array(e);return Object.setPrototypeOf(t,D.prototype),t}function D(e,t,r){if(typeof e=="number"){if(typeof t=="string")throw new TypeError('The "string" argument must be of type string. Received type number');return uh(e)}return p0(e,t,r)}D.poolSize=8192;function p0(e,t,r){if(typeof e=="string")return LI(e,t);if(ArrayBuffer.isView(e))return DI(e);if(e==null)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof e);if(Jr(e,ArrayBuffer)||e&&Jr(e.buffer,ArrayBuffer)||typeof SharedArrayBuffer<"u"&&(Jr(e,SharedArrayBuffer)||e&&Jr(e.buffer,SharedArrayBuffer)))return sh(e,t,r);if(typeof e=="number")throw new TypeError('The "value" argument must not be of type number. Received type number');let n=e.valueOf&&e.valueOf();if(n!=null&&n!==e)return D.from(n,t,r);let i=UI(e);if(i)return i;if(typeof Symbol<"u"&&Symbol.toPrimitive!=null&&typeof e[Symbol.toPrimitive]=="function")return D.from(e[Symbol.toPrimitive]("string"),t,r);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof e)}D.from=function(e,t,r){return p0(e,t,r)};Object.setPrototypeOf(D.prototype,Uint8Array.prototype);Object.setPrototypeOf(D,Uint8Array);function g0(e){if(typeof e!="number")throw new TypeError('"size" argument must be of type number');if(e<0)throw new RangeError('The value "'+e+'" is invalid for option "size"')}function CI(e,t,r){return g0(e),e<=0?Sn(e):t!==void 0?typeof r=="string"?Sn(e).fill(t,r):Sn(e).fill(t):Sn(e)}D.alloc=function(e,t,r){return CI(e,t,r)};function uh(e){return g0(e),Sn(e<0?0:fh(e)|0)}D.allocUnsafe=function(e){return uh(e)};D.allocUnsafeSlow=function(e){return uh(e)};function LI(e,t){if((typeof t!="string"||t==="")&&(t="utf8"),!D.isEncoding(t))throw new TypeError("Unknown encoding: "+t);let r=y0(e,t)|0,n=Sn(r),i=n.write(e,t);return i!==r&&(n=n.slice(0,i)),n}function oh(e){let t=e.length<0?0:fh(e.length)|0,r=Sn(t);for(let n=0;n<t;n+=1)r[n]=e[n]&255;return r}function DI(e){if(Jr(e,Uint8Array)){let t=new Uint8Array(e);return sh(t.buffer,t.byteOffset,t.byteLength)}return oh(e)}function sh(e,t,r){if(t<0||e.byteLength<t)throw new RangeError('"offset" is outside of buffer bounds');if(e.byteLength<t+(r||0))throw new RangeError('"length" is outside of buffer bounds');let n;return t===void 0&&r===void 0?n=new Uint8Array(e):r===void 0?n=new Uint8Array(e,t):n=new Uint8Array(e,t,r),Object.setPrototypeOf(n,D.prototype),n}function UI(e){if(D.isBuffer(e)){let t=fh(e.length)|0,r=Sn(t);return r.length===0||e.copy(r,0,0,t),r}if(e.length!==void 0)return typeof e.length!="number"||hh(e.length)?Sn(0):oh(e);if(e.type==="Buffer"&&Array.isArray(e.data))return oh(e.data)}function fh(e){if(e>=eu)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+eu.toString(16)+" bytes");return e|0}function qI(e){return+e!=e&&(e=0),D.alloc(+e)}D.isBuffer=function(t){return t!=null&&t._isBuffer===!0&&t!==D.prototype};D.compare=function(t,r){if(Jr(t,Uint8Array)&&(t=D.from(t,t.offset,t.byteLength)),Jr(r,Uint8Array)&&(r=D.from(r,r.offset,r.byteLength)),!D.isBuffer(t)||!D.isBuffer(r))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(t===r)return 0;let n=t.length,i=r.length;for(let o=0,s=Math.min(n,i);o<s;++o)if(t[o]!==r[o]){n=t[o],i=r[o];break}return n<i?-1:i<n?1:0};D.isEncoding=function(t){switch(String(t).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}};D.concat=function(t,r){if(!Array.isArray(t))throw new TypeError('"list" argument must be an Array of Buffers');if(t.length===0)return D.alloc(0);let n;if(r===void 0)for(r=0,n=0;n<t.length;++n)r+=t[n].length;let i=D.allocUnsafe(r),o=0;for(n=0;n<t.length;++n){let s=t[n];if(Jr(s,Uint8Array))o+s.length>i.length?(D.isBuffer(s)||(s=D.from(s)),s.copy(i,o)):Uint8Array.prototype.set.call(i,s,o);else if(D.isBuffer(s))s.copy(i,o);else throw new TypeError('"list" argument must be an Array of Buffers');o+=s.length}return i};function y0(e,t){if(D.isBuffer(e))return e.length;if(ArrayBuffer.isView(e)||Jr(e,ArrayBuffer))return e.byteLength;if(typeof e!="string")throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof e);let r=e.length,n=arguments.length>2&&arguments[2]===!0;if(!n&&r===0)return 0;let i=!1;for(;;)switch(t){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":return ah(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return r*2;case"hex":return r>>>1;case"base64":return I0(e).length;default:if(i)return n?-1:ah(e).length;t=(""+t).toLowerCase(),i=!0}}D.byteLength=y0;function FI(e,t,r){let n=!1;if((t===void 0||t<0)&&(t=0),t>this.length||((r===void 0||r>this.length)&&(r=this.length),r<=0)||(r>>>=0,t>>>=0,r<=t))return"";for(e||(e="utf8");;)switch(e){case"hex":return ZI(this,t,r);case"utf8":case"utf-8":return v0(this,t,r);case"ascii":return YI(this,t,r);case"latin1":case"binary":return $I(this,t,r);case"base64":return zI(this,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return XI(this,t,r);default:if(n)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),n=!0}}D.prototype._isBuffer=!0;function wi(e,t,r){let n=e[t];e[t]=e[r],e[r]=n}D.prototype.swap16=function(){let t=this.length;if(t%2!==0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(let r=0;r<t;r+=2)wi(this,r,r+1);return this};D.prototype.swap32=function(){let t=this.length;if(t%4!==0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(let r=0;r<t;r+=4)wi(this,r,r+3),wi(this,r+1,r+2);return this};D.prototype.swap64=function(){let t=this.length;if(t%8!==0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(let r=0;r<t;r+=8)wi(this,r,r+7),wi(this,r+1,r+6),wi(this,r+2,r+5),wi(this,r+3,r+4);return this};D.prototype.toString=function(){let t=this.length;return t===0?"":arguments.length===0?v0(this,0,t):FI.apply(this,arguments)};D.prototype.toLocaleString=D.prototype.toString;D.prototype.equals=function(t){if(!D.isBuffer(t))throw new TypeError("Argument must be a Buffer");return this===t?!0:D.compare(this,t)===0};D.prototype.inspect=function(){let t="",r=go.INSPECT_MAX_BYTES;return t=this.toString("hex",0,r).replace(/(.{2})/g,"$1 ").trim(),this.length>r&&(t+=" ... "),"<Buffer "+t+">"};c0&&(D.prototype[c0]=D.prototype.inspect);D.prototype.compare=function(t,r,n,i,o){if(Jr(t,Uint8Array)&&(t=D.from(t,t.offset,t.byteLength)),!D.isBuffer(t))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof t);if(r===void 0&&(r=0),n===void 0&&(n=t?t.length:0),i===void 0&&(i=0),o===void 0&&(o=this.length),r<0||n>t.length||i<0||o>this.length)throw new RangeError("out of range index");if(i>=o&&r>=n)return 0;if(i>=o)return-1;if(r>=n)return 1;if(r>>>=0,n>>>=0,i>>>=0,o>>>=0,this===t)return 0;let s=o-i,a=n-r,c=Math.min(s,a),l=this.slice(i,o),g=t.slice(r,n);for(let m=0;m<c;++m)if(l[m]!==g[m]){s=l[m],a=g[m];break}return s<a?-1:a<s?1:0};function m0(e,t,r,n,i){if(e.length===0)return-1;if(typeof r=="string"?(n=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),r=+r,hh(r)&&(r=i?0:e.length-1),r<0&&(r=e.length+r),r>=e.length){if(i)return-1;r=e.length-1}else if(r<0)if(i)r=0;else return-1;if(typeof t=="string"&&(t=D.from(t,n)),D.isBuffer(t))return t.length===0?-1:h0(e,t,r,n,i);if(typeof t=="number")return t=t&255,typeof Uint8Array.prototype.indexOf=="function"?i?Uint8Array.prototype.indexOf.call(e,t,r):Uint8Array.prototype.lastIndexOf.call(e,t,r):h0(e,[t],r,n,i);throw new TypeError("val must be string, number or Buffer")}function h0(e,t,r,n,i){let o=1,s=e.length,a=t.length;if(n!==void 0&&(n=String(n).toLowerCase(),n==="ucs2"||n==="ucs-2"||n==="utf16le"||n==="utf-16le")){if(e.length<2||t.length<2)return-1;o=2,s/=2,a/=2,r/=2}function c(g,m){return o===1?g[m]:g.readUInt16BE(m*o)}let l;if(i){let g=-1;for(l=r;l<s;l++)if(c(e,l)===c(t,g===-1?0:l-g)){if(g===-1&&(g=l),l-g+1===a)return g*o}else g!==-1&&(l-=l-g),g=-1}else for(r+a>s&&(r=s-a),l=r;l>=0;l--){let g=!0;for(let m=0;m<a;m++)if(c(e,l+m)!==c(t,m)){g=!1;break}if(g)return l}return-1}D.prototype.includes=function(t,r,n){return this.indexOf(t,r,n)!==-1};D.prototype.indexOf=function(t,r,n){return m0(this,t,r,n,!0)};D.prototype.lastIndexOf=function(t,r,n){return m0(this,t,r,n,!1)};function HI(e,t,r,n){r=Number(r)||0;let i=e.length-r;n?(n=Number(n),n>i&&(n=i)):n=i;let o=t.length;n>o/2&&(n=o/2);let s;for(s=0;s<n;++s){let a=parseInt(t.substr(s*2,2),16);if(hh(a))return s;e[r+s]=a}return s}function jI(e,t,r,n){return tu(ah(t,e.length-r),e,r,n)}function KI(e,t,r,n){return tu(tA(t),e,r,n)}function VI(e,t,r,n){return tu(I0(t),e,r,n)}function GI(e,t,r,n){return tu(rA(t,e.length-r),e,r,n)}D.prototype.write=function(t,r,n,i){if(r===void 0)i="utf8",n=this.length,r=0;else if(n===void 0&&typeof r=="string")i=r,n=this.length,r=0;else if(isFinite(r))r=r>>>0,isFinite(n)?(n=n>>>0,i===void 0&&(i="utf8")):(i=n,n=void 0);else throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");let o=this.length-r;if((n===void 0||n>o)&&(n=o),t.length>0&&(n<0||r<0)||r>this.length)throw new RangeError("Attempt to write outside buffer bounds");i||(i="utf8");let s=!1;for(;;)switch(i){case"hex":return HI(this,t,r,n);case"utf8":case"utf-8":return jI(this,t,r,n);case"ascii":case"latin1":case"binary":return KI(this,t,r,n);case"base64":return VI(this,t,r,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return GI(this,t,r,n);default:if(s)throw new TypeError("Unknown encoding: "+i);i=(""+i).toLowerCase(),s=!0}};D.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function zI(e,t,r){return t===0&&r===e.length?ih.fromByteArray(e):ih.fromByteArray(e.slice(t,r))}function v0(e,t,r){r=Math.min(e.length,r);let n=[],i=t;for(;i<r;){let o=e[i],s=null,a=o>239?4:o>223?3:o>191?2:1;if(i+a<=r){let c,l,g,m;switch(a){case 1:o<128&&(s=o);break;case 2:c=e[i+1],(c&192)===128&&(m=(o&31)<<6|c&63,m>127&&(s=m));break;case 3:c=e[i+1],l=e[i+2],(c&192)===128&&(l&192)===128&&(m=(o&15)<<12|(c&63)<<6|l&63,m>2047&&(m<55296||m>57343)&&(s=m));break;case 4:c=e[i+1],l=e[i+2],g=e[i+3],(c&192)===128&&(l&192)===128&&(g&192)===128&&(m=(o&15)<<18|(c&63)<<12|(l&63)<<6|g&63,m>65535&&m<1114112&&(s=m))}}s===null?(s=65533,a=1):s>65535&&(s-=65536,n.push(s>>>10&1023|55296),s=56320|s&1023),n.push(s),i+=a}return WI(n)}var l0=4096;function WI(e){let t=e.length;if(t<=l0)return String.fromCharCode.apply(String,e);let r="",n=0;for(;n<t;)r+=String.fromCharCode.apply(String,e.slice(n,n+=l0));return r}function YI(e,t,r){let n="";r=Math.min(e.length,r);for(let i=t;i<r;++i)n+=String.fromCharCode(e[i]&127);return n}function $I(e,t,r){let n="";r=Math.min(e.length,r);for(let i=t;i<r;++i)n+=String.fromCharCode(e[i]);return n}function ZI(e,t,r){let n=e.length;(!t||t<0)&&(t=0),(!r||r<0||r>n)&&(r=n);let i="";for(let o=t;o<r;++o)i+=nA[e[o]];return i}function XI(e,t,r){let n=e.slice(t,r),i="";for(let o=0;o<n.length-1;o+=2)i+=String.fromCharCode(n[o]+n[o+1]*256);return i}D.prototype.slice=function(t,r){let n=this.length;t=~~t,r=r===void 0?n:~~r,t<0?(t+=n,t<0&&(t=0)):t>n&&(t=n),r<0?(r+=n,r<0&&(r=0)):r>n&&(r=n),r<t&&(r=t);let i=this.subarray(t,r);return Object.setPrototypeOf(i,D.prototype),i};function kt(e,t,r){if(e%1!==0||e<0)throw new RangeError("offset is not uint");if(e+t>r)throw new RangeError("Trying to access beyond buffer length")}D.prototype.readUintLE=D.prototype.readUIntLE=function(t,r,n){t=t>>>0,r=r>>>0,n||kt(t,r,this.length);let i=this[t],o=1,s=0;for(;++s<r&&(o*=256);)i+=this[t+s]*o;return i};D.prototype.readUintBE=D.prototype.readUIntBE=function(t,r,n){t=t>>>0,r=r>>>0,n||kt(t,r,this.length);let i=this[t+--r],o=1;for(;r>0&&(o*=256);)i+=this[t+--r]*o;return i};D.prototype.readUint8=D.prototype.readUInt8=function(t,r){return t=t>>>0,r||kt(t,1,this.length),this[t]};D.prototype.readUint16LE=D.prototype.readUInt16LE=function(t,r){return t=t>>>0,r||kt(t,2,this.length),this[t]|this[t+1]<<8};D.prototype.readUint16BE=D.prototype.readUInt16BE=function(t,r){return t=t>>>0,r||kt(t,2,this.length),this[t]<<8|this[t+1]};D.prototype.readUint32LE=D.prototype.readUInt32LE=function(t,r){return t=t>>>0,r||kt(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+this[t+3]*16777216};D.prototype.readUint32BE=D.prototype.readUInt32BE=function(t,r){return t=t>>>0,r||kt(t,4,this.length),this[t]*16777216+(this[t+1]<<16|this[t+2]<<8|this[t+3])};D.prototype.readBigUInt64LE=Wn(function(t){t=t>>>0,po(t,"offset");let r=this[t],n=this[t+7];(r===void 0||n===void 0)&&_s(t,this.length-8);let i=r+this[++t]*2**8+this[++t]*2**16+this[++t]*2**24,o=this[++t]+this[++t]*2**8+this[++t]*2**16+n*2**24;return BigInt(i)+(BigInt(o)<<BigInt(32))});D.prototype.readBigUInt64BE=Wn(function(t){t=t>>>0,po(t,"offset");let r=this[t],n=this[t+7];(r===void 0||n===void 0)&&_s(t,this.length-8);let i=r*2**24+this[++t]*2**16+this[++t]*2**8+this[++t],o=this[++t]*2**24+this[++t]*2**16+this[++t]*2**8+n;return(BigInt(i)<<BigInt(32))+BigInt(o)});D.prototype.readIntLE=function(t,r,n){t=t>>>0,r=r>>>0,n||kt(t,r,this.length);let i=this[t],o=1,s=0;for(;++s<r&&(o*=256);)i+=this[t+s]*o;return o*=128,i>=o&&(i-=Math.pow(2,8*r)),i};D.prototype.readIntBE=function(t,r,n){t=t>>>0,r=r>>>0,n||kt(t,r,this.length);let i=r,o=1,s=this[t+--i];for(;i>0&&(o*=256);)s+=this[t+--i]*o;return o*=128,s>=o&&(s-=Math.pow(2,8*r)),s};D.prototype.readInt8=function(t,r){return t=t>>>0,r||kt(t,1,this.length),this[t]&128?(255-this[t]+1)*-1:this[t]};D.prototype.readInt16LE=function(t,r){t=t>>>0,r||kt(t,2,this.length);let n=this[t]|this[t+1]<<8;return n&32768?n|4294901760:n};D.prototype.readInt16BE=function(t,r){t=t>>>0,r||kt(t,2,this.length);let n=this[t+1]|this[t]<<8;return n&32768?n|4294901760:n};D.prototype.readInt32LE=function(t,r){return t=t>>>0,r||kt(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24};D.prototype.readInt32BE=function(t,r){return t=t>>>0,r||kt(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]};D.prototype.readBigInt64LE=Wn(function(t){t=t>>>0,po(t,"offset");let r=this[t],n=this[t+7];(r===void 0||n===void 0)&&_s(t,this.length-8);let i=this[t+4]+this[t+5]*2**8+this[t+6]*2**16+(n<<24);return(BigInt(i)<<BigInt(32))+BigInt(r+this[++t]*2**8+this[++t]*2**16+this[++t]*2**24)});D.prototype.readBigInt64BE=Wn(function(t){t=t>>>0,po(t,"offset");let r=this[t],n=this[t+7];(r===void 0||n===void 0)&&_s(t,this.length-8);let i=(r<<24)+this[++t]*2**16+this[++t]*2**8+this[++t];return(BigInt(i)<<BigInt(32))+BigInt(this[++t]*2**24+this[++t]*2**16+this[++t]*2**8+n)});D.prototype.readFloatLE=function(t,r){return t=t>>>0,r||kt(t,4,this.length),lo.read(this,t,!0,23,4)};D.prototype.readFloatBE=function(t,r){return t=t>>>0,r||kt(t,4,this.length),lo.read(this,t,!1,23,4)};D.prototype.readDoubleLE=function(t,r){return t=t>>>0,r||kt(t,8,this.length),lo.read(this,t,!0,52,8)};D.prototype.readDoubleBE=function(t,r){return t=t>>>0,r||kt(t,8,this.length),lo.read(this,t,!1,52,8)};function rr(e,t,r,n,i,o){if(!D.isBuffer(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>i||t<o)throw new RangeError('"value" argument is out of bounds');if(r+n>e.length)throw new RangeError("Index out of range")}D.prototype.writeUintLE=D.prototype.writeUIntLE=function(t,r,n,i){if(t=+t,r=r>>>0,n=n>>>0,!i){let a=Math.pow(2,8*n)-1;rr(this,t,r,n,a,0)}let o=1,s=0;for(this[r]=t&255;++s<n&&(o*=256);)this[r+s]=t/o&255;return r+n};D.prototype.writeUintBE=D.prototype.writeUIntBE=function(t,r,n,i){if(t=+t,r=r>>>0,n=n>>>0,!i){let a=Math.pow(2,8*n)-1;rr(this,t,r,n,a,0)}let o=n-1,s=1;for(this[r+o]=t&255;--o>=0&&(s*=256);)this[r+o]=t/s&255;return r+n};D.prototype.writeUint8=D.prototype.writeUInt8=function(t,r,n){return t=+t,r=r>>>0,n||rr(this,t,r,1,255,0),this[r]=t&255,r+1};D.prototype.writeUint16LE=D.prototype.writeUInt16LE=function(t,r,n){return t=+t,r=r>>>0,n||rr(this,t,r,2,65535,0),this[r]=t&255,this[r+1]=t>>>8,r+2};D.prototype.writeUint16BE=D.prototype.writeUInt16BE=function(t,r,n){return t=+t,r=r>>>0,n||rr(this,t,r,2,65535,0),this[r]=t>>>8,this[r+1]=t&255,r+2};D.prototype.writeUint32LE=D.prototype.writeUInt32LE=function(t,r,n){return t=+t,r=r>>>0,n||rr(this,t,r,4,4294967295,0),this[r+3]=t>>>24,this[r+2]=t>>>16,this[r+1]=t>>>8,this[r]=t&255,r+4};D.prototype.writeUint32BE=D.prototype.writeUInt32BE=function(t,r,n){return t=+t,r=r>>>0,n||rr(this,t,r,4,4294967295,0),this[r]=t>>>24,this[r+1]=t>>>16,this[r+2]=t>>>8,this[r+3]=t&255,r+4};function b0(e,t,r,n,i){x0(t,n,i,e,r,7);let o=Number(t&BigInt(4294967295));e[r++]=o,o=o>>8,e[r++]=o,o=o>>8,e[r++]=o,o=o>>8,e[r++]=o;let s=Number(t>>BigInt(32)&BigInt(4294967295));return e[r++]=s,s=s>>8,e[r++]=s,s=s>>8,e[r++]=s,s=s>>8,e[r++]=s,r}function _0(e,t,r,n,i){x0(t,n,i,e,r,7);let o=Number(t&BigInt(4294967295));e[r+7]=o,o=o>>8,e[r+6]=o,o=o>>8,e[r+5]=o,o=o>>8,e[r+4]=o;let s=Number(t>>BigInt(32)&BigInt(4294967295));return e[r+3]=s,s=s>>8,e[r+2]=s,s=s>>8,e[r+1]=s,s=s>>8,e[r]=s,r+8}D.prototype.writeBigUInt64LE=Wn(function(t,r=0){return b0(this,t,r,BigInt(0),BigInt("0xffffffffffffffff"))});D.prototype.writeBigUInt64BE=Wn(function(t,r=0){return _0(this,t,r,BigInt(0),BigInt("0xffffffffffffffff"))});D.prototype.writeIntLE=function(t,r,n,i){if(t=+t,r=r>>>0,!i){let c=Math.pow(2,8*n-1);rr(this,t,r,n,c-1,-c)}let o=0,s=1,a=0;for(this[r]=t&255;++o<n&&(s*=256);)t<0&&a===0&&this[r+o-1]!==0&&(a=1),this[r+o]=(t/s>>0)-a&255;return r+n};D.prototype.writeIntBE=function(t,r,n,i){if(t=+t,r=r>>>0,!i){let c=Math.pow(2,8*n-1);rr(this,t,r,n,c-1,-c)}let o=n-1,s=1,a=0;for(this[r+o]=t&255;--o>=0&&(s*=256);)t<0&&a===0&&this[r+o+1]!==0&&(a=1),this[r+o]=(t/s>>0)-a&255;return r+n};D.prototype.writeInt8=function(t,r,n){return t=+t,r=r>>>0,n||rr(this,t,r,1,127,-128),t<0&&(t=255+t+1),this[r]=t&255,r+1};D.prototype.writeInt16LE=function(t,r,n){return t=+t,r=r>>>0,n||rr(this,t,r,2,32767,-32768),this[r]=t&255,this[r+1]=t>>>8,r+2};D.prototype.writeInt16BE=function(t,r,n){return t=+t,r=r>>>0,n||rr(this,t,r,2,32767,-32768),this[r]=t>>>8,this[r+1]=t&255,r+2};D.prototype.writeInt32LE=function(t,r,n){return t=+t,r=r>>>0,n||rr(this,t,r,4,2147483647,-2147483648),this[r]=t&255,this[r+1]=t>>>8,this[r+2]=t>>>16,this[r+3]=t>>>24,r+4};D.prototype.writeInt32BE=function(t,r,n){return t=+t,r=r>>>0,n||rr(this,t,r,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),this[r]=t>>>24,this[r+1]=t>>>16,this[r+2]=t>>>8,this[r+3]=t&255,r+4};D.prototype.writeBigInt64LE=Wn(function(t,r=0){return b0(this,t,r,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});D.prototype.writeBigInt64BE=Wn(function(t,r=0){return _0(this,t,r,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});function w0(e,t,r,n,i,o){if(r+n>e.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function S0(e,t,r,n,i){return t=+t,r=r>>>0,i||w0(e,t,r,4,34028234663852886e22,-34028234663852886e22),lo.write(e,t,r,n,23,4),r+4}D.prototype.writeFloatLE=function(t,r,n){return S0(this,t,r,!0,n)};D.prototype.writeFloatBE=function(t,r,n){return S0(this,t,r,!1,n)};function E0(e,t,r,n,i){return t=+t,r=r>>>0,i||w0(e,t,r,8,17976931348623157e292,-17976931348623157e292),lo.write(e,t,r,n,52,8),r+8}D.prototype.writeDoubleLE=function(t,r,n){return E0(this,t,r,!0,n)};D.prototype.writeDoubleBE=function(t,r,n){return E0(this,t,r,!1,n)};D.prototype.copy=function(t,r,n,i){if(!D.isBuffer(t))throw new TypeError("argument should be a Buffer");if(n||(n=0),!i&&i!==0&&(i=this.length),r>=t.length&&(r=t.length),r||(r=0),i>0&&i<n&&(i=n),i===n||t.length===0||this.length===0)return 0;if(r<0)throw new RangeError("targetStart out of bounds");if(n<0||n>=this.length)throw new RangeError("Index out of range");if(i<0)throw new RangeError("sourceEnd out of bounds");i>this.length&&(i=this.length),t.length-r<i-n&&(i=t.length-r+n);let o=i-n;return this===t&&typeof Uint8Array.prototype.copyWithin=="function"?this.copyWithin(r,n,i):Uint8Array.prototype.set.call(t,this.subarray(n,i),r),o};D.prototype.fill=function(t,r,n,i){if(typeof t=="string"){if(typeof r=="string"?(i=r,r=0,n=this.length):typeof n=="string"&&(i=n,n=this.length),i!==void 0&&typeof i!="string")throw new TypeError("encoding must be a string");if(typeof i=="string"&&!D.isEncoding(i))throw new TypeError("Unknown encoding: "+i);if(t.length===1){let s=t.charCodeAt(0);(i==="utf8"&&s<128||i==="latin1")&&(t=s)}}else typeof t=="number"?t=t&255:typeof t=="boolean"&&(t=Number(t));if(r<0||this.length<r||this.length<n)throw new RangeError("Out of range index");if(n<=r)return this;r=r>>>0,n=n===void 0?this.length:n>>>0,t||(t=0);let o;if(typeof t=="number")for(o=r;o<n;++o)this[o]=t;else{let s=D.isBuffer(t)?t:D.from(t,i),a=s.length;if(a===0)throw new TypeError('The value "'+t+'" is invalid for argument "value"');for(o=0;o<n-r;++o)this[o+r]=s[o%a]}return this};var ho={};function ch(e,t,r){ho[e]=class extends r{constructor(){super(),Object.defineProperty(this,"message",{value:t.apply(this,arguments),writable:!0,configurable:!0}),this.name=`${this.name} [${e}]`,this.stack,delete this.name}get code(){return e}set code(i){Object.defineProperty(this,"code",{configurable:!0,enumerable:!0,value:i,writable:!0})}toString(){return`${this.name} [${e}]: ${this.message}`}}}ch("ERR_BUFFER_OUT_OF_BOUNDS",function(e){return e?`${e} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"},RangeError);ch("ERR_INVALID_ARG_TYPE",function(e,t){return`The "${e}" argument must be of type number. Received type ${typeof t}`},TypeError);ch("ERR_OUT_OF_RANGE",function(e,t,r){let n=`The value of "${e}" is out of range.`,i=r;return Number.isInteger(r)&&Math.abs(r)>2**32?i=d0(String(r)):typeof r=="bigint"&&(i=String(r),(r>BigInt(2)**BigInt(32)||r<-(BigInt(2)**BigInt(32)))&&(i=d0(i)),i+="n"),n+=` It must be ${t}. Received ${i}`,n},RangeError);function d0(e){let t="",r=e.length,n=e[0]==="-"?1:0;for(;r>=n+4;r-=3)t=`_${e.slice(r-3,r)}${t}`;return`${e.slice(0,r)}${t}`}function JI(e,t,r){po(t,"offset"),(e[t]===void 0||e[t+r]===void 0)&&_s(t,e.length-(r+1))}function x0(e,t,r,n,i,o){if(e>r||e<t){let s=typeof t=="bigint"?"n":"",a;throw o>3?t===0||t===BigInt(0)?a=`>= 0${s} and < 2${s} ** ${(o+1)*8}${s}`:a=`>= -(2${s} ** ${(o+1)*8-1}${s}) and < 2 ** ${(o+1)*8-1}${s}`:a=`>= ${t}${s} and <= ${r}${s}`,new ho.ERR_OUT_OF_RANGE("value",a,e)}JI(n,i,o)}function po(e,t){if(typeof e!="number")throw new ho.ERR_INVALID_ARG_TYPE(t,"number",e)}function _s(e,t,r){throw Math.floor(e)!==e?(po(e,r),new ho.ERR_OUT_OF_RANGE(r||"offset","an integer",e)):t<0?new ho.ERR_BUFFER_OUT_OF_BOUNDS:new ho.ERR_OUT_OF_RANGE(r||"offset",`>= ${r?1:0} and <= ${t}`,e)}var QI=/[^+/0-9A-Za-z-_]/g;function eA(e){if(e=e.split("=")[0],e=e.trim().replace(QI,""),e.length<2)return"";for(;e.length%4!==0;)e=e+"=";return e}function ah(e,t){t=t||1/0;let r,n=e.length,i=null,o=[];for(let s=0;s<n;++s){if(r=e.charCodeAt(s),r>55295&&r<57344){if(!i){if(r>56319){(t-=3)>-1&&o.push(239,191,189);continue}else if(s+1===n){(t-=3)>-1&&o.push(239,191,189);continue}i=r;continue}if(r<56320){(t-=3)>-1&&o.push(239,191,189),i=r;continue}r=(i-55296<<10|r-56320)+65536}else i&&(t-=3)>-1&&o.push(239,191,189);if(i=null,r<128){if((t-=1)<0)break;o.push(r)}else if(r<2048){if((t-=2)<0)break;o.push(r>>6|192,r&63|128)}else if(r<65536){if((t-=3)<0)break;o.push(r>>12|224,r>>6&63|128,r&63|128)}else if(r<1114112){if((t-=4)<0)break;o.push(r>>18|240,r>>12&63|128,r>>6&63|128,r&63|128)}else throw new Error("Invalid code point")}return o}function tA(e){let t=[];for(let r=0;r<e.length;++r)t.push(e.charCodeAt(r)&255);return t}function rA(e,t){let r,n,i,o=[];for(let s=0;s<e.length&&!((t-=2)<0);++s)r=e.charCodeAt(s),n=r>>8,i=r%256,o.push(i),o.push(n);return o}function I0(e){return ih.toByteArray(eA(e))}function tu(e,t,r,n){let i;for(i=0;i<n&&!(i+r>=t.length||i>=e.length);++i)t[i+r]=e[i];return i}function Jr(e,t){return e instanceof t||e!=null&&e.constructor!=null&&e.constructor.name!=null&&e.constructor.name===t.name}function hh(e){return e!==e}var nA=(function(){let e="0123456789abcdef",t=new Array(256);for(let r=0;r<16;++r){let n=r*16;for(let i=0;i<16;++i)t[n+i]=e[r]+e[i]}return t})();function Wn(e){return typeof BigInt>"u"?iA:e}function iA(){throw new Error("BigInt not supported")}});var I,d,p=fr(()=>{I=e0(o0()),d=e0(Pt())});var O0=P((A0,lh)=>{p();(function(e,t){"use strict";function r(A,u){if(!A)throw new Error(u||"Assertion failed")}function n(A,u){A.super_=u;var h=function(){};h.prototype=u.prototype,A.prototype=new h,A.prototype.constructor=A}function i(A,u,h){if(i.isBN(A))return A;this.negative=0,this.words=null,this.length=0,this.red=null,A!==null&&((u==="le"||u==="be")&&(h=u,u=10),this._init(A||0,u||10,h||"be"))}typeof e=="object"?e.exports=i:t.BN=i,i.BN=i,i.wordSize=26;var o;try{typeof window<"u"&&typeof window.Buffer<"u"?o=window.Buffer:o=Pt().Buffer}catch{}i.isBN=function(u){return u instanceof i?!0:u!==null&&typeof u=="object"&&u.constructor.wordSize===i.wordSize&&Array.isArray(u.words)},i.max=function(u,h){return u.cmp(h)>0?u:h},i.min=function(u,h){return u.cmp(h)<0?u:h},i.prototype._init=function(u,h,y){if(typeof u=="number")return this._initNumber(u,h,y);if(typeof u=="object")return this._initArray(u,h,y);h==="hex"&&(h=16),r(h===(h|0)&&h>=2&&h<=36),u=u.toString().replace(/\s+/g,"");var v=0;u[0]==="-"&&(v++,this.negative=1),v<u.length&&(h===16?this._parseHex(u,v,y):(this._parseBase(u,h,v),y==="le"&&this._initArray(this.toArray(),h,y)))},i.prototype._initNumber=function(u,h,y){u<0&&(this.negative=1,u=-u),u<67108864?(this.words=[u&67108863],this.length=1):u<4503599627370496?(this.words=[u&67108863,u/67108864&67108863],this.length=2):(r(u<9007199254740992),this.words=[u&67108863,u/67108864&67108863,1],this.length=3),y==="le"&&this._initArray(this.toArray(),h,y)},i.prototype._initArray=function(u,h,y){if(r(typeof u.length=="number"),u.length<=0)return this.words=[0],this.length=1,this;this.length=Math.ceil(u.length/3),this.words=new Array(this.length);for(var v=0;v<this.length;v++)this.words[v]=0;var b,E,O=0;if(y==="be")for(v=u.length-1,b=0;v>=0;v-=3)E=u[v]|u[v-1]<<8|u[v-2]<<16,this.words[b]|=E<<O&67108863,this.words[b+1]=E>>>26-O&67108863,O+=24,O>=26&&(O-=26,b++);else if(y==="le")for(v=0,b=0;v<u.length;v+=3)E=u[v]|u[v+1]<<8|u[v+2]<<16,this.words[b]|=E<<O&67108863,this.words[b+1]=E>>>26-O&67108863,O+=24,O>=26&&(O-=26,b++);return this.strip()};function s(A,u){var h=A.charCodeAt(u);return h>=65&&h<=70?h-55:h>=97&&h<=102?h-87:h-48&15}function a(A,u,h){var y=s(A,h);return h-1>=u&&(y|=s(A,h-1)<<4),y}i.prototype._parseHex=function(u,h,y){this.length=Math.ceil((u.length-h)/6),this.words=new Array(this.length);for(var v=0;v<this.length;v++)this.words[v]=0;var b=0,E=0,O;if(y==="be")for(v=u.length-1;v>=h;v-=2)O=a(u,h,v)<<b,this.words[E]|=O&67108863,b>=18?(b-=18,E+=1,this.words[E]|=O>>>26):b+=8;else{var w=u.length-h;for(v=w%2===0?h+1:h;v<u.length;v+=2)O=a(u,h,v)<<b,this.words[E]|=O&67108863,b>=18?(b-=18,E+=1,this.words[E]|=O>>>26):b+=8}this.strip()};function c(A,u,h,y){for(var v=0,b=Math.min(A.length,h),E=u;E<b;E++){var O=A.charCodeAt(E)-48;v*=y,O>=49?v+=O-49+10:O>=17?v+=O-17+10:v+=O}return v}i.prototype._parseBase=function(u,h,y){this.words=[0],this.length=1;for(var v=0,b=1;b<=67108863;b*=h)v++;v--,b=b/h|0;for(var E=u.length-y,O=E%v,w=Math.min(E,E-O)+y,f=0,S=y;S<w;S+=v)f=c(u,S,S+v,h),this.imuln(b),this.words[0]+f<67108864?this.words[0]+=f:this._iaddn(f);if(O!==0){var H=1;for(f=c(u,S,u.length,h),S=0;S<O;S++)H*=h;this.imuln(H),this.words[0]+f<67108864?this.words[0]+=f:this._iaddn(f)}this.strip()},i.prototype.copy=function(u){u.words=new Array(this.length);for(var h=0;h<this.length;h++)u.words[h]=this.words[h];u.length=this.length,u.negative=this.negative,u.red=this.red},i.prototype.clone=function(){var u=new i(null);return this.copy(u),u},i.prototype._expand=function(u){for(;this.length<u;)this.words[this.length++]=0;return this},i.prototype.strip=function(){for(;this.length>1&&this.words[this.length-1]===0;)this.length--;return this._normSign()},i.prototype._normSign=function(){return this.length===1&&this.words[0]===0&&(this.negative=0),this},i.prototype.inspect=function(){return(this.red?"<BN-R: ":"<BN: ")+this.toString(16)+">"};var l=["","0","00","000","0000","00000","000000","0000000","00000000","000000000","0000000000","00000000000","000000000000","0000000000000","00000000000000","000000000000000","0000000000000000","00000000000000000","000000000000000000","0000000000000000000","00000000000000000000","000000000000000000000","0000000000000000000000","00000000000000000000000","000000000000000000000000","0000000000000000000000000"],g=[0,0,25,16,12,11,10,9,8,8,7,7,7,7,6,6,6,6,6,6,6,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5],m=[0,0,33554432,43046721,16777216,48828125,60466176,40353607,16777216,43046721,1e7,19487171,35831808,62748517,7529536,11390625,16777216,24137569,34012224,47045881,64e6,4084101,5153632,6436343,7962624,9765625,11881376,14348907,17210368,20511149,243e5,28629151,33554432,39135393,45435424,52521875,60466176];i.prototype.toString=function(u,h){u=u||10,h=h|0||1;var y;if(u===16||u==="hex"){y="";for(var v=0,b=0,E=0;E<this.length;E++){var O=this.words[E],w=((O<<v|b)&16777215).toString(16);b=O>>>24-v&16777215,v+=2,v>=26&&(v-=26,E--),b!==0||E!==this.length-1?y=l[6-w.length]+w+y:y=w+y}for(b!==0&&(y=b.toString(16)+y);y.length%h!==0;)y="0"+y;return this.negative!==0&&(y="-"+y),y}if(u===(u|0)&&u>=2&&u<=36){var f=g[u],S=m[u];y="";var H=this.clone();for(H.negative=0;!H.isZero();){var q=H.modn(S).toString(u);H=H.idivn(S),H.isZero()?y=q+y:y=l[f-q.length]+q+y}for(this.isZero()&&(y="0"+y);y.length%h!==0;)y="0"+y;return this.negative!==0&&(y="-"+y),y}r(!1,"Base should be between 2 and 36")},i.prototype.toNumber=function(){var u=this.words[0];return this.length===2?u+=this.words[1]*67108864:this.length===3&&this.words[2]===1?u+=4503599627370496+this.words[1]*67108864:this.length>2&&r(!1,"Number can only safely store up to 53 bits"),this.negative!==0?-u:u},i.prototype.toJSON=function(){return this.toString(16)},i.prototype.toBuffer=function(u,h){return r(typeof o<"u"),this.toArrayLike(o,u,h)},i.prototype.toArray=function(u,h){return this.toArrayLike(Array,u,h)},i.prototype.toArrayLike=function(u,h,y){var v=this.byteLength(),b=y||Math.max(1,v);r(v<=b,"byte array longer than desired length"),r(b>0,"Requested array length <= 0"),this.strip();var E=h==="le",O=new u(b),w,f,S=this.clone();if(E){for(f=0;!S.isZero();f++)w=S.andln(255),S.iushrn(8),O[f]=w;for(;f<b;f++)O[f]=0}else{for(f=0;f<b-v;f++)O[f]=0;for(f=0;!S.isZero();f++)w=S.andln(255),S.iushrn(8),O[b-f-1]=w}return O},Math.clz32?i.prototype._countBits=function(u){return 32-Math.clz32(u)}:i.prototype._countBits=function(u){var h=u,y=0;return h>=4096&&(y+=13,h>>>=13),h>=64&&(y+=7,h>>>=7),h>=8&&(y+=4,h>>>=4),h>=2&&(y+=2,h>>>=2),y+h},i.prototype._zeroBits=function(u){if(u===0)return 26;var h=u,y=0;return(h&8191)===0&&(y+=13,h>>>=13),(h&127)===0&&(y+=7,h>>>=7),(h&15)===0&&(y+=4,h>>>=4),(h&3)===0&&(y+=2,h>>>=2),(h&1)===0&&y++,y},i.prototype.bitLength=function(){var u=this.words[this.length-1],h=this._countBits(u);return(this.length-1)*26+h};function _(A){for(var u=new Array(A.bitLength()),h=0;h<u.length;h++){var y=h/26|0,v=h%26;u[h]=(A.words[y]&1<<v)>>>v}return u}i.prototype.zeroBits=function(){if(this.isZero())return 0;for(var u=0,h=0;h<this.length;h++){var y=this._zeroBits(this.words[h]);if(u+=y,y!==26)break}return u},i.prototype.byteLength=function(){return Math.ceil(this.bitLength()/8)},i.prototype.toTwos=function(u){return this.negative!==0?this.abs().inotn(u).iaddn(1):this.clone()},i.prototype.fromTwos=function(u){return this.testn(u-1)?this.notn(u).iaddn(1).ineg():this.clone()},i.prototype.isNeg=function(){return this.negative!==0},i.prototype.neg=function(){return this.clone().ineg()},i.prototype.ineg=function(){return this.isZero()||(this.negative^=1),this},i.prototype.iuor=function(u){for(;this.length<u.length;)this.words[this.length++]=0;for(var h=0;h<u.length;h++)this.words[h]=this.words[h]|u.words[h];return this.strip()},i.prototype.ior=function(u){return r((this.negative|u.negative)===0),this.iuor(u)},i.prototype.or=function(u){return this.length>u.length?this.clone().ior(u):u.clone().ior(this)},i.prototype.uor=function(u){return this.length>u.length?this.clone().iuor(u):u.clone().iuor(this)},i.prototype.iuand=function(u){var h;this.length>u.length?h=u:h=this;for(var y=0;y<h.length;y++)this.words[y]=this.words[y]&u.words[y];return this.length=h.length,this.strip()},i.prototype.iand=function(u){return r((this.negative|u.negative)===0),this.iuand(u)},i.prototype.and=function(u){return this.length>u.length?this.clone().iand(u):u.clone().iand(this)},i.prototype.uand=function(u){return this.length>u.length?this.clone().iuand(u):u.clone().iuand(this)},i.prototype.iuxor=function(u){var h,y;this.length>u.length?(h=this,y=u):(h=u,y=this);for(var v=0;v<y.length;v++)this.words[v]=h.words[v]^y.words[v];if(this!==h)for(;v<h.length;v++)this.words[v]=h.words[v];return this.length=h.length,this.strip()},i.prototype.ixor=function(u){return r((this.negative|u.negative)===0),this.iuxor(u)},i.prototype.xor=function(u){return this.length>u.length?this.clone().ixor(u):u.clone().ixor(this)},i.prototype.uxor=function(u){return this.length>u.length?this.clone().iuxor(u):u.clone().iuxor(this)},i.prototype.inotn=function(u){r(typeof u=="number"&&u>=0);var h=Math.ceil(u/26)|0,y=u%26;this._expand(h),y>0&&h--;for(var v=0;v<h;v++)this.words[v]=~this.words[v]&67108863;for(y>0&&(this.words[v]=~this.words[v]&67108863>>26-y,v++);v<this.length;v++)this.words[v]=0;return this.strip()},i.prototype.notn=function(u){return this.clone().inotn(u)},i.prototype.setn=function(u,h){r(typeof u=="number"&&u>=0);var y=u/26|0,v=u%26;return this._expand(y+1),h?this.words[y]=this.words[y]|1<<v:this.words[y]=this.words[y]&~(1<<v),this.strip()},i.prototype.iadd=function(u){var h;if(this.negative!==0&&u.negative===0)return this.negative=0,h=this.isub(u),this.negative^=1,this._normSign();if(this.negative===0&&u.negative!==0)return u.negative=0,h=this.isub(u),u.negative=1,h._normSign();var y,v;this.length>u.length?(y=this,v=u):(y=u,v=this);for(var b=0,E=0;E<v.length;E++)h=(y.words[E]|0)+(v.words[E]|0)+b,this.words[E]=h&67108863,b=h>>>26;for(;b!==0&&E<y.length;E++)h=(y.words[E]|0)+b,this.words[E]=h&67108863,b=h>>>26;if(this.length=y.length,b!==0)this.words[this.length]=b,this.length++;else if(y!==this)for(;E<y.length;E++)this.words[E]=y.words[E];return this},i.prototype.add=function(u){var h;return u.negative!==0&&this.negative===0?(u.negative=0,h=this.sub(u),u.negative^=1,h):u.negative===0&&this.negative!==0?(this.negative=0,h=u.sub(this),this.negative=1,h):this.length>u.length?this.clone().iadd(u):u.clone().iadd(this)},i.prototype.isub=function(u){if(u.negative!==0){u.negative=0;var h=this.iadd(u);return u.negative=1,h._normSign()}else if(this.negative!==0)return this.negative=0,this.iadd(u),this.negative=1,this._normSign();var y=this.cmp(u);if(y===0)return this.negative=0,this.length=1,this.words[0]=0,this;var v,b;y>0?(v=this,b=u):(v=u,b=this);for(var E=0,O=0;O<b.length;O++)h=(v.words[O]|0)-(b.words[O]|0)+E,E=h>>26,this.words[O]=h&67108863;for(;E!==0&&O<v.length;O++)h=(v.words[O]|0)+E,E=h>>26,this.words[O]=h&67108863;if(E===0&&O<v.length&&v!==this)for(;O<v.length;O++)this.words[O]=v.words[O];return this.length=Math.max(this.length,O),v!==this&&(this.negative=1),this.strip()},i.prototype.sub=function(u){return this.clone().isub(u)};function x(A,u,h){h.negative=u.negative^A.negative;var y=A.length+u.length|0;h.length=y,y=y-1|0;var v=A.words[0]|0,b=u.words[0]|0,E=v*b,O=E&67108863,w=E/67108864|0;h.words[0]=O;for(var f=1;f<y;f++){for(var S=w>>>26,H=w&67108863,q=Math.min(f,u.length-1),W=Math.max(0,f-A.length+1);W<=q;W++){var $=f-W|0;v=A.words[$]|0,b=u.words[W]|0,E=v*b+H,S+=E/67108864|0,H=E&67108863}h.words[f]=H|0,w=S|0}return w!==0?h.words[f]=w|0:h.length--,h.strip()}var R=function(u,h,y){var v=u.words,b=h.words,E=y.words,O=0,w,f,S,H=v[0]|0,q=H&8191,W=H>>>13,$=v[1]|0,X=$&8191,ae=$>>>13,ge=v[2]|0,le=ge&8191,T=ge>>>13,k=v[3]|0,F=k&8191,K=k>>>13,ne=v[4]|0,J=ne&8191,ee=ne>>>13,de=v[5]|0,ie=de&8191,ue=de>>>13,Ye=v[6]|0,Oe=Ye&8191,te=Ye>>>13,ve=v[7]|0,be=ve&8191,we=ve>>>13,bn=v[8]|0,$e=bn&8191,Ke=bn>>>13,Xa=v[9]|0,Xe=Xa&8191,nt=Xa>>>13,Kp=b[0]|0,it=Kp&8191,ot=Kp>>>13,Vp=b[1]|0,st=Vp&8191,at=Vp>>>13,Gp=b[2]|0,ut=Gp&8191,ft=Gp>>>13,zp=b[3]|0,ct=zp&8191,ht=zp>>>13,Wp=b[4]|0,lt=Wp&8191,dt=Wp>>>13,Yp=b[5]|0,pt=Yp&8191,gt=Yp>>>13,$p=b[6]|0,yt=$p&8191,mt=$p>>>13,Zp=b[7]|0,vt=Zp&8191,bt=Zp>>>13,Xp=b[8]|0,_t=Xp&8191,wt=Xp>>>13,Jp=b[9]|0,St=Jp&8191,Et=Jp>>>13;y.negative=u.negative^h.negative,y.length=19,w=Math.imul(q,it),f=Math.imul(q,ot),f=f+Math.imul(W,it)|0,S=Math.imul(W,ot);var Cc=(O+w|0)+((f&8191)<<13)|0;O=(S+(f>>>13)|0)+(Cc>>>26)|0,Cc&=67108863,w=Math.imul(X,it),f=Math.imul(X,ot),f=f+Math.imul(ae,it)|0,S=Math.imul(ae,ot),w=w+Math.imul(q,st)|0,f=f+Math.imul(q,at)|0,f=f+Math.imul(W,st)|0,S=S+Math.imul(W,at)|0;var Lc=(O+w|0)+((f&8191)<<13)|0;O=(S+(f>>>13)|0)+(Lc>>>26)|0,Lc&=67108863,w=Math.imul(le,it),f=Math.imul(le,ot),f=f+Math.imul(T,it)|0,S=Math.imul(T,ot),w=w+Math.imul(X,st)|0,f=f+Math.imul(X,at)|0,f=f+Math.imul(ae,st)|0,S=S+Math.imul(ae,at)|0,w=w+Math.imul(q,ut)|0,f=f+Math.imul(q,ft)|0,f=f+Math.imul(W,ut)|0,S=S+Math.imul(W,ft)|0;var Dc=(O+w|0)+((f&8191)<<13)|0;O=(S+(f>>>13)|0)+(Dc>>>26)|0,Dc&=67108863,w=Math.imul(F,it),f=Math.imul(F,ot),f=f+Math.imul(K,it)|0,S=Math.imul(K,ot),w=w+Math.imul(le,st)|0,f=f+Math.imul(le,at)|0,f=f+Math.imul(T,st)|0,S=S+Math.imul(T,at)|0,w=w+Math.imul(X,ut)|0,f=f+Math.imul(X,ft)|0,f=f+Math.imul(ae,ut)|0,S=S+Math.imul(ae,ft)|0,w=w+Math.imul(q,ct)|0,f=f+Math.imul(q,ht)|0,f=f+Math.imul(W,ct)|0,S=S+Math.imul(W,ht)|0;var Uc=(O+w|0)+((f&8191)<<13)|0;O=(S+(f>>>13)|0)+(Uc>>>26)|0,Uc&=67108863,w=Math.imul(J,it),f=Math.imul(J,ot),f=f+Math.imul(ee,it)|0,S=Math.imul(ee,ot),w=w+Math.imul(F,st)|0,f=f+Math.imul(F,at)|0,f=f+Math.imul(K,st)|0,S=S+Math.imul(K,at)|0,w=w+Math.imul(le,ut)|0,f=f+Math.imul(le,ft)|0,f=f+Math.imul(T,ut)|0,S=S+Math.imul(T,ft)|0,w=w+Math.imul(X,ct)|0,f=f+Math.imul(X,ht)|0,f=f+Math.imul(ae,ct)|0,S=S+Math.imul(ae,ht)|0,w=w+Math.imul(q,lt)|0,f=f+Math.imul(q,dt)|0,f=f+Math.imul(W,lt)|0,S=S+Math.imul(W,dt)|0;var qc=(O+w|0)+((f&8191)<<13)|0;O=(S+(f>>>13)|0)+(qc>>>26)|0,qc&=67108863,w=Math.imul(ie,it),f=Math.imul(ie,ot),f=f+Math.imul(ue,it)|0,S=Math.imul(ue,ot),w=w+Math.imul(J,st)|0,f=f+Math.imul(J,at)|0,f=f+Math.imul(ee,st)|0,S=S+Math.imul(ee,at)|0,w=w+Math.imul(F,ut)|0,f=f+Math.imul(F,ft)|0,f=f+Math.imul(K,ut)|0,S=S+Math.imul(K,ft)|0,w=w+Math.imul(le,ct)|0,f=f+Math.imul(le,ht)|0,f=f+Math.imul(T,ct)|0,S=S+Math.imul(T,ht)|0,w=w+Math.imul(X,lt)|0,f=f+Math.imul(X,dt)|0,f=f+Math.imul(ae,lt)|0,S=S+Math.imul(ae,dt)|0,w=w+Math.imul(q,pt)|0,f=f+Math.imul(q,gt)|0,f=f+Math.imul(W,pt)|0,S=S+Math.imul(W,gt)|0;var Fc=(O+w|0)+((f&8191)<<13)|0;O=(S+(f>>>13)|0)+(Fc>>>26)|0,Fc&=67108863,w=Math.imul(Oe,it),f=Math.imul(Oe,ot),f=f+Math.imul(te,it)|0,S=Math.imul(te,ot),w=w+Math.imul(ie,st)|0,f=f+Math.imul(ie,at)|0,f=f+Math.imul(ue,st)|0,S=S+Math.imul(ue,at)|0,w=w+Math.imul(J,ut)|0,f=f+Math.imul(J,ft)|0,f=f+Math.imul(ee,ut)|0,S=S+Math.imul(ee,ft)|0,w=w+Math.imul(F,ct)|0,f=f+Math.imul(F,ht)|0,f=f+Math.imul(K,ct)|0,S=S+Math.imul(K,ht)|0,w=w+Math.imul(le,lt)|0,f=f+Math.imul(le,dt)|0,f=f+Math.imul(T,lt)|0,S=S+Math.imul(T,dt)|0,w=w+Math.imul(X,pt)|0,f=f+Math.imul(X,gt)|0,f=f+Math.imul(ae,pt)|0,S=S+Math.imul(ae,gt)|0,w=w+Math.imul(q,yt)|0,f=f+Math.imul(q,mt)|0,f=f+Math.imul(W,yt)|0,S=S+Math.imul(W,mt)|0;var Hc=(O+w|0)+((f&8191)<<13)|0;O=(S+(f>>>13)|0)+(Hc>>>26)|0,Hc&=67108863,w=Math.imul(be,it),f=Math.imul(be,ot),f=f+Math.imul(we,it)|0,S=Math.imul(we,ot),w=w+Math.imul(Oe,st)|0,f=f+Math.imul(Oe,at)|0,f=f+Math.imul(te,st)|0,S=S+Math.imul(te,at)|0,w=w+Math.imul(ie,ut)|0,f=f+Math.imul(ie,ft)|0,f=f+Math.imul(ue,ut)|0,S=S+Math.imul(ue,ft)|0,w=w+Math.imul(J,ct)|0,f=f+Math.imul(J,ht)|0,f=f+Math.imul(ee,ct)|0,S=S+Math.imul(ee,ht)|0,w=w+Math.imul(F,lt)|0,f=f+Math.imul(F,dt)|0,f=f+Math.imul(K,lt)|0,S=S+Math.imul(K,dt)|0,w=w+Math.imul(le,pt)|0,f=f+Math.imul(le,gt)|0,f=f+Math.imul(T,pt)|0,S=S+Math.imul(T,gt)|0,w=w+Math.imul(X,yt)|0,f=f+Math.imul(X,mt)|0,f=f+Math.imul(ae,yt)|0,S=S+Math.imul(ae,mt)|0,w=w+Math.imul(q,vt)|0,f=f+Math.imul(q,bt)|0,f=f+Math.imul(W,vt)|0,S=S+Math.imul(W,bt)|0;var jc=(O+w|0)+((f&8191)<<13)|0;O=(S+(f>>>13)|0)+(jc>>>26)|0,jc&=67108863,w=Math.imul($e,it),f=Math.imul($e,ot),f=f+Math.imul(Ke,it)|0,S=Math.imul(Ke,ot),w=w+Math.imul(be,st)|0,f=f+Math.imul(be,at)|0,f=f+Math.imul(we,st)|0,S=S+Math.imul(we,at)|0,w=w+Math.imul(Oe,ut)|0,f=f+Math.imul(Oe,ft)|0,f=f+Math.imul(te,ut)|0,S=S+Math.imul(te,ft)|0,w=w+Math.imul(ie,ct)|0,f=f+Math.imul(ie,ht)|0,f=f+Math.imul(ue,ct)|0,S=S+Math.imul(ue,ht)|0,w=w+Math.imul(J,lt)|0,f=f+Math.imul(J,dt)|0,f=f+Math.imul(ee,lt)|0,S=S+Math.imul(ee,dt)|0,w=w+Math.imul(F,pt)|0,f=f+Math.imul(F,gt)|0,f=f+Math.imul(K,pt)|0,S=S+Math.imul(K,gt)|0,w=w+Math.imul(le,yt)|0,f=f+Math.imul(le,mt)|0,f=f+Math.imul(T,yt)|0,S=S+Math.imul(T,mt)|0,w=w+Math.imul(X,vt)|0,f=f+Math.imul(X,bt)|0,f=f+Math.imul(ae,vt)|0,S=S+Math.imul(ae,bt)|0,w=w+Math.imul(q,_t)|0,f=f+Math.imul(q,wt)|0,f=f+Math.imul(W,_t)|0,S=S+Math.imul(W,wt)|0;var Kc=(O+w|0)+((f&8191)<<13)|0;O=(S+(f>>>13)|0)+(Kc>>>26)|0,Kc&=67108863,w=Math.imul(Xe,it),f=Math.imul(Xe,ot),f=f+Math.imul(nt,it)|0,S=Math.imul(nt,ot),w=w+Math.imul($e,st)|0,f=f+Math.imul($e,at)|0,f=f+Math.imul(Ke,st)|0,S=S+Math.imul(Ke,at)|0,w=w+Math.imul(be,ut)|0,f=f+Math.imul(be,ft)|0,f=f+Math.imul(we,ut)|0,S=S+Math.imul(we,ft)|0,w=w+Math.imul(Oe,ct)|0,f=f+Math.imul(Oe,ht)|0,f=f+Math.imul(te,ct)|0,S=S+Math.imul(te,ht)|0,w=w+Math.imul(ie,lt)|0,f=f+Math.imul(ie,dt)|0,f=f+Math.imul(ue,lt)|0,S=S+Math.imul(ue,dt)|0,w=w+Math.imul(J,pt)|0,f=f+Math.imul(J,gt)|0,f=f+Math.imul(ee,pt)|0,S=S+Math.imul(ee,gt)|0,w=w+Math.imul(F,yt)|0,f=f+Math.imul(F,mt)|0,f=f+Math.imul(K,yt)|0,S=S+Math.imul(K,mt)|0,w=w+Math.imul(le,vt)|0,f=f+Math.imul(le,bt)|0,f=f+Math.imul(T,vt)|0,S=S+Math.imul(T,bt)|0,w=w+Math.imul(X,_t)|0,f=f+Math.imul(X,wt)|0,f=f+Math.imul(ae,_t)|0,S=S+Math.imul(ae,wt)|0,w=w+Math.imul(q,St)|0,f=f+Math.imul(q,Et)|0,f=f+Math.imul(W,St)|0,S=S+Math.imul(W,Et)|0;var Vc=(O+w|0)+((f&8191)<<13)|0;O=(S+(f>>>13)|0)+(Vc>>>26)|0,Vc&=67108863,w=Math.imul(Xe,st),f=Math.imul(Xe,at),f=f+Math.imul(nt,st)|0,S=Math.imul(nt,at),w=w+Math.imul($e,ut)|0,f=f+Math.imul($e,ft)|0,f=f+Math.imul(Ke,ut)|0,S=S+Math.imul(Ke,ft)|0,w=w+Math.imul(be,ct)|0,f=f+Math.imul(be,ht)|0,f=f+Math.imul(we,ct)|0,S=S+Math.imul(we,ht)|0,w=w+Math.imul(Oe,lt)|0,f=f+Math.imul(Oe,dt)|0,f=f+Math.imul(te,lt)|0,S=S+Math.imul(te,dt)|0,w=w+Math.imul(ie,pt)|0,f=f+Math.imul(ie,gt)|0,f=f+Math.imul(ue,pt)|0,S=S+Math.imul(ue,gt)|0,w=w+Math.imul(J,yt)|0,f=f+Math.imul(J,mt)|0,f=f+Math.imul(ee,yt)|0,S=S+Math.imul(ee,mt)|0,w=w+Math.imul(F,vt)|0,f=f+Math.imul(F,bt)|0,f=f+Math.imul(K,vt)|0,S=S+Math.imul(K,bt)|0,w=w+Math.imul(le,_t)|0,f=f+Math.imul(le,wt)|0,f=f+Math.imul(T,_t)|0,S=S+Math.imul(T,wt)|0,w=w+Math.imul(X,St)|0,f=f+Math.imul(X,Et)|0,f=f+Math.imul(ae,St)|0,S=S+Math.imul(ae,Et)|0;var Gc=(O+w|0)+((f&8191)<<13)|0;O=(S+(f>>>13)|0)+(Gc>>>26)|0,Gc&=67108863,w=Math.imul(Xe,ut),f=Math.imul(Xe,ft),f=f+Math.imul(nt,ut)|0,S=Math.imul(nt,ft),w=w+Math.imul($e,ct)|0,f=f+Math.imul($e,ht)|0,f=f+Math.imul(Ke,ct)|0,S=S+Math.imul(Ke,ht)|0,w=w+Math.imul(be,lt)|0,f=f+Math.imul(be,dt)|0,f=f+Math.imul(we,lt)|0,S=S+Math.imul(we,dt)|0,w=w+Math.imul(Oe,pt)|0,f=f+Math.imul(Oe,gt)|0,f=f+Math.imul(te,pt)|0,S=S+Math.imul(te,gt)|0,w=w+Math.imul(ie,yt)|0,f=f+Math.imul(ie,mt)|0,f=f+Math.imul(ue,yt)|0,S=S+Math.imul(ue,mt)|0,w=w+Math.imul(J,vt)|0,f=f+Math.imul(J,bt)|0,f=f+Math.imul(ee,vt)|0,S=S+Math.imul(ee,bt)|0,w=w+Math.imul(F,_t)|0,f=f+Math.imul(F,wt)|0,f=f+Math.imul(K,_t)|0,S=S+Math.imul(K,wt)|0,w=w+Math.imul(le,St)|0,f=f+Math.imul(le,Et)|0,f=f+Math.imul(T,St)|0,S=S+Math.imul(T,Et)|0;var zc=(O+w|0)+((f&8191)<<13)|0;O=(S+(f>>>13)|0)+(zc>>>26)|0,zc&=67108863,w=Math.imul(Xe,ct),f=Math.imul(Xe,ht),f=f+Math.imul(nt,ct)|0,S=Math.imul(nt,ht),w=w+Math.imul($e,lt)|0,f=f+Math.imul($e,dt)|0,f=f+Math.imul(Ke,lt)|0,S=S+Math.imul(Ke,dt)|0,w=w+Math.imul(be,pt)|0,f=f+Math.imul(be,gt)|0,f=f+Math.imul(we,pt)|0,S=S+Math.imul(we,gt)|0,w=w+Math.imul(Oe,yt)|0,f=f+Math.imul(Oe,mt)|0,f=f+Math.imul(te,yt)|0,S=S+Math.imul(te,mt)|0,w=w+Math.imul(ie,vt)|0,f=f+Math.imul(ie,bt)|0,f=f+Math.imul(ue,vt)|0,S=S+Math.imul(ue,bt)|0,w=w+Math.imul(J,_t)|0,f=f+Math.imul(J,wt)|0,f=f+Math.imul(ee,_t)|0,S=S+Math.imul(ee,wt)|0,w=w+Math.imul(F,St)|0,f=f+Math.imul(F,Et)|0,f=f+Math.imul(K,St)|0,S=S+Math.imul(K,Et)|0;var Wc=(O+w|0)+((f&8191)<<13)|0;O=(S+(f>>>13)|0)+(Wc>>>26)|0,Wc&=67108863,w=Math.imul(Xe,lt),f=Math.imul(Xe,dt),f=f+Math.imul(nt,lt)|0,S=Math.imul(nt,dt),w=w+Math.imul($e,pt)|0,f=f+Math.imul($e,gt)|0,f=f+Math.imul(Ke,pt)|0,S=S+Math.imul(Ke,gt)|0,w=w+Math.imul(be,yt)|0,f=f+Math.imul(be,mt)|0,f=f+Math.imul(we,yt)|0,S=S+Math.imul(we,mt)|0,w=w+Math.imul(Oe,vt)|0,f=f+Math.imul(Oe,bt)|0,f=f+Math.imul(te,vt)|0,S=S+Math.imul(te,bt)|0,w=w+Math.imul(ie,_t)|0,f=f+Math.imul(ie,wt)|0,f=f+Math.imul(ue,_t)|0,S=S+Math.imul(ue,wt)|0,w=w+Math.imul(J,St)|0,f=f+Math.imul(J,Et)|0,f=f+Math.imul(ee,St)|0,S=S+Math.imul(ee,Et)|0;var Yc=(O+w|0)+((f&8191)<<13)|0;O=(S+(f>>>13)|0)+(Yc>>>26)|0,Yc&=67108863,w=Math.imul(Xe,pt),f=Math.imul(Xe,gt),f=f+Math.imul(nt,pt)|0,S=Math.imul(nt,gt),w=w+Math.imul($e,yt)|0,f=f+Math.imul($e,mt)|0,f=f+Math.imul(Ke,yt)|0,S=S+Math.imul(Ke,mt)|0,w=w+Math.imul(be,vt)|0,f=f+Math.imul(be,bt)|0,f=f+Math.imul(we,vt)|0,S=S+Math.imul(we,bt)|0,w=w+Math.imul(Oe,_t)|0,f=f+Math.imul(Oe,wt)|0,f=f+Math.imul(te,_t)|0,S=S+Math.imul(te,wt)|0,w=w+Math.imul(ie,St)|0,f=f+Math.imul(ie,Et)|0,f=f+Math.imul(ue,St)|0,S=S+Math.imul(ue,Et)|0;var $c=(O+w|0)+((f&8191)<<13)|0;O=(S+(f>>>13)|0)+($c>>>26)|0,$c&=67108863,w=Math.imul(Xe,yt),f=Math.imul(Xe,mt),f=f+Math.imul(nt,yt)|0,S=Math.imul(nt,mt),w=w+Math.imul($e,vt)|0,f=f+Math.imul($e,bt)|0,f=f+Math.imul(Ke,vt)|0,S=S+Math.imul(Ke,bt)|0,w=w+Math.imul(be,_t)|0,f=f+Math.imul(be,wt)|0,f=f+Math.imul(we,_t)|0,S=S+Math.imul(we,wt)|0,w=w+Math.imul(Oe,St)|0,f=f+Math.imul(Oe,Et)|0,f=f+Math.imul(te,St)|0,S=S+Math.imul(te,Et)|0;var Zc=(O+w|0)+((f&8191)<<13)|0;O=(S+(f>>>13)|0)+(Zc>>>26)|0,Zc&=67108863,w=Math.imul(Xe,vt),f=Math.imul(Xe,bt),f=f+Math.imul(nt,vt)|0,S=Math.imul(nt,bt),w=w+Math.imul($e,_t)|0,f=f+Math.imul($e,wt)|0,f=f+Math.imul(Ke,_t)|0,S=S+Math.imul(Ke,wt)|0,w=w+Math.imul(be,St)|0,f=f+Math.imul(be,Et)|0,f=f+Math.imul(we,St)|0,S=S+Math.imul(we,Et)|0;var Xc=(O+w|0)+((f&8191)<<13)|0;O=(S+(f>>>13)|0)+(Xc>>>26)|0,Xc&=67108863,w=Math.imul(Xe,_t),f=Math.imul(Xe,wt),f=f+Math.imul(nt,_t)|0,S=Math.imul(nt,wt),w=w+Math.imul($e,St)|0,f=f+Math.imul($e,Et)|0,f=f+Math.imul(Ke,St)|0,S=S+Math.imul(Ke,Et)|0;var Jc=(O+w|0)+((f&8191)<<13)|0;O=(S+(f>>>13)|0)+(Jc>>>26)|0,Jc&=67108863,w=Math.imul(Xe,St),f=Math.imul(Xe,Et),f=f+Math.imul(nt,St)|0,S=Math.imul(nt,Et);var Qc=(O+w|0)+((f&8191)<<13)|0;return O=(S+(f>>>13)|0)+(Qc>>>26)|0,Qc&=67108863,E[0]=Cc,E[1]=Lc,E[2]=Dc,E[3]=Uc,E[4]=qc,E[5]=Fc,E[6]=Hc,E[7]=jc,E[8]=Kc,E[9]=Vc,E[10]=Gc,E[11]=zc,E[12]=Wc,E[13]=Yc,E[14]=$c,E[15]=Zc,E[16]=Xc,E[17]=Jc,E[18]=Qc,O!==0&&(E[19]=O,y.length++),y};Math.imul||(R=x);function B(A,u,h){h.negative=u.negative^A.negative,h.length=A.length+u.length;for(var y=0,v=0,b=0;b<h.length-1;b++){var E=v;v=0;for(var O=y&67108863,w=Math.min(b,u.length-1),f=Math.max(0,b-A.length+1);f<=w;f++){var S=b-f,H=A.words[S]|0,q=u.words[f]|0,W=H*q,$=W&67108863;E=E+(W/67108864|0)|0,$=$+O|0,O=$&67108863,E=E+($>>>26)|0,v+=E>>>26,E&=67108863}h.words[b]=O,y=E,E=v}return y!==0?h.words[b]=y:h.length--,h.strip()}function C(A,u,h){var y=new U;return y.mulp(A,u,h)}i.prototype.mulTo=function(u,h){var y,v=this.length+u.length;return this.length===10&&u.length===10?y=R(this,u,h):v<63?y=x(this,u,h):v<1024?y=B(this,u,h):y=C(this,u,h),y};function U(A,u){this.x=A,this.y=u}U.prototype.makeRBT=function(u){for(var h=new Array(u),y=i.prototype._countBits(u)-1,v=0;v<u;v++)h[v]=this.revBin(v,y,u);return h},U.prototype.revBin=function(u,h,y){if(u===0||u===y-1)return u;for(var v=0,b=0;b<h;b++)v|=(u&1)<<h-b-1,u>>=1;return v},U.prototype.permute=function(u,h,y,v,b,E){for(var O=0;O<E;O++)v[O]=h[u[O]],b[O]=y[u[O]]},U.prototype.transform=function(u,h,y,v,b,E){this.permute(E,u,h,y,v,b);for(var O=1;O<b;O<<=1)for(var w=O<<1,f=Math.cos(2*Math.PI/w),S=Math.sin(2*Math.PI/w),H=0;H<b;H+=w)for(var q=f,W=S,$=0;$<O;$++){var X=y[H+$],ae=v[H+$],ge=y[H+$+O],le=v[H+$+O],T=q*ge-W*le;le=q*le+W*ge,ge=T,y[H+$]=X+ge,v[H+$]=ae+le,y[H+$+O]=X-ge,v[H+$+O]=ae-le,$!==w&&(T=f*q-S*W,W=f*W+S*q,q=T)}},U.prototype.guessLen13b=function(u,h){var y=Math.max(h,u)|1,v=y&1,b=0;for(y=y/2|0;y;y=y>>>1)b++;return 1<<b+1+v},U.prototype.conjugate=function(u,h,y){if(!(y<=1))for(var v=0;v<y/2;v++){var b=u[v];u[v]=u[y-v-1],u[y-v-1]=b,b=h[v],h[v]=-h[y-v-1],h[y-v-1]=-b}},U.prototype.normalize13b=function(u,h){for(var y=0,v=0;v<h/2;v++){var b=Math.round(u[2*v+1]/h)*8192+Math.round(u[2*v]/h)+y;u[v]=b&67108863,b<67108864?y=0:y=b/67108864|0}return u},U.prototype.convert13b=function(u,h,y,v){for(var b=0,E=0;E<h;E++)b=b+(u[E]|0),y[2*E]=b&8191,b=b>>>13,y[2*E+1]=b&8191,b=b>>>13;for(E=2*h;E<v;++E)y[E]=0;r(b===0),r((b&-8192)===0)},U.prototype.stub=function(u){for(var h=new Array(u),y=0;y<u;y++)h[y]=0;return h},U.prototype.mulp=function(u,h,y){var v=2*this.guessLen13b(u.length,h.length),b=this.makeRBT(v),E=this.stub(v),O=new Array(v),w=new Array(v),f=new Array(v),S=new Array(v),H=new Array(v),q=new Array(v),W=y.words;W.length=v,this.convert13b(u.words,u.length,O,v),this.convert13b(h.words,h.length,S,v),this.transform(O,E,w,f,v,b),this.transform(S,E,H,q,v,b);for(var $=0;$<v;$++){var X=w[$]*H[$]-f[$]*q[$];f[$]=w[$]*q[$]+f[$]*H[$],w[$]=X}return this.conjugate(w,f,v),this.transform(w,f,W,E,v,b),this.conjugate(W,E,v),this.normalize13b(W,v),y.negative=u.negative^h.negative,y.length=u.length+h.length,y.strip()},i.prototype.mul=function(u){var h=new i(null);return h.words=new Array(this.length+u.length),this.mulTo(u,h)},i.prototype.mulf=function(u){var h=new i(null);return h.words=new Array(this.length+u.length),C(this,u,h)},i.prototype.imul=function(u){return this.clone().mulTo(u,this)},i.prototype.imuln=function(u){r(typeof u=="number"),r(u<67108864);for(var h=0,y=0;y<this.length;y++){var v=(this.words[y]|0)*u,b=(v&67108863)+(h&67108863);h>>=26,h+=v/67108864|0,h+=b>>>26,this.words[y]=b&67108863}return h!==0&&(this.words[y]=h,this.length++),u===0&&(this.length=1,this._normSign()),this},i.prototype.muln=function(u){return this.clone().imuln(u)},i.prototype.sqr=function(){return this.mul(this)},i.prototype.isqr=function(){return this.imul(this.clone())},i.prototype.pow=function(u){var h=_(u);if(h.length===0)return new i(1);for(var y=this,v=0;v<h.length&&h[v]===0;v++,y=y.sqr());if(++v<h.length)for(var b=y.sqr();v<h.length;v++,b=b.sqr())h[v]!==0&&(y=y.mul(b));return y},i.prototype.iushln=function(u){r(typeof u=="number"&&u>=0);var h=u%26,y=(u-h)/26,v=67108863>>>26-h<<26-h,b;if(h!==0){var E=0;for(b=0;b<this.length;b++){var O=this.words[b]&v,w=(this.words[b]|0)-O<<h;this.words[b]=w|E,E=O>>>26-h}E&&(this.words[b]=E,this.length++)}if(y!==0){for(b=this.length-1;b>=0;b--)this.words[b+y]=this.words[b];for(b=0;b<y;b++)this.words[b]=0;this.length+=y}return this.strip()},i.prototype.ishln=function(u){return r(this.negative===0),this.iushln(u)},i.prototype.iushrn=function(u,h,y){r(typeof u=="number"&&u>=0);var v;h?v=(h-h%26)/26:v=0;var b=u%26,E=Math.min((u-b)/26,this.length),O=67108863^67108863>>>b<<b,w=y;if(v-=E,v=Math.max(0,v),w){for(var f=0;f<E;f++)w.words[f]=this.words[f];w.length=E}if(E!==0)if(this.length>E)for(this.length-=E,f=0;f<this.length;f++)this.words[f]=this.words[f+E];else this.words[0]=0,this.length=1;var S=0;for(f=this.length-1;f>=0&&(S!==0||f>=v);f--){var H=this.words[f]|0;this.words[f]=S<<26-b|H>>>b,S=H&O}return w&&S!==0&&(w.words[w.length++]=S),this.length===0&&(this.words[0]=0,this.length=1),this.strip()},i.prototype.ishrn=function(u,h,y){return r(this.negative===0),this.iushrn(u,h,y)},i.prototype.shln=function(u){return this.clone().ishln(u)},i.prototype.ushln=function(u){return this.clone().iushln(u)},i.prototype.shrn=function(u){return this.clone().ishrn(u)},i.prototype.ushrn=function(u){return this.clone().iushrn(u)},i.prototype.testn=function(u){r(typeof u=="number"&&u>=0);var h=u%26,y=(u-h)/26,v=1<<h;if(this.length<=y)return!1;var b=this.words[y];return!!(b&v)},i.prototype.imaskn=function(u){r(typeof u=="number"&&u>=0);var h=u%26,y=(u-h)/26;if(r(this.negative===0,"imaskn works only with positive numbers"),this.length<=y)return this;if(h!==0&&y++,this.length=Math.min(y,this.length),h!==0){var v=67108863^67108863>>>h<<h;this.words[this.length-1]&=v}return this.length===0&&(this.words[0]=0,this.length=1),this.strip()},i.prototype.maskn=function(u){return this.clone().imaskn(u)},i.prototype.iaddn=function(u){return r(typeof u=="number"),r(u<67108864),u<0?this.isubn(-u):this.negative!==0?this.length===1&&(this.words[0]|0)<u?(this.words[0]=u-(this.words[0]|0),this.negative=0,this):(this.negative=0,this.isubn(u),this.negative=1,this):this._iaddn(u)},i.prototype._iaddn=function(u){this.words[0]+=u;for(var h=0;h<this.length&&this.words[h]>=67108864;h++)this.words[h]-=67108864,h===this.length-1?this.words[h+1]=1:this.words[h+1]++;return this.length=Math.max(this.length,h+1),this},i.prototype.isubn=function(u){if(r(typeof u=="number"),r(u<67108864),u<0)return this.iaddn(-u);if(this.negative!==0)return this.negative=0,this.iaddn(u),this.negative=1,this;if(this.words[0]-=u,this.length===1&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var h=0;h<this.length&&this.words[h]<0;h++)this.words[h]+=67108864,this.words[h+1]-=1;return this.strip()},i.prototype.addn=function(u){return this.clone().iaddn(u)},i.prototype.subn=function(u){return this.clone().isubn(u)},i.prototype.iabs=function(){return this.negative=0,this},i.prototype.abs=function(){return this.clone().iabs()},i.prototype._ishlnsubmul=function(u,h,y){var v=u.length+y,b;this._expand(v);var E,O=0;for(b=0;b<u.length;b++){E=(this.words[b+y]|0)+O;var w=(u.words[b]|0)*h;E-=w&67108863,O=(E>>26)-(w/67108864|0),this.words[b+y]=E&67108863}for(;b<this.length-y;b++)E=(this.words[b+y]|0)+O,O=E>>26,this.words[b+y]=E&67108863;if(O===0)return this.strip();for(r(O===-1),O=0,b=0;b<this.length;b++)E=-(this.words[b]|0)+O,O=E>>26,this.words[b]=E&67108863;return this.negative=1,this.strip()},i.prototype._wordDiv=function(u,h){var y=this.length-u.length,v=this.clone(),b=u,E=b.words[b.length-1]|0,O=this._countBits(E);y=26-O,y!==0&&(b=b.ushln(y),v.iushln(y),E=b.words[b.length-1]|0);var w=v.length-b.length,f;if(h!=="mod"){f=new i(null),f.length=w+1,f.words=new Array(f.length);for(var S=0;S<f.length;S++)f.words[S]=0}var H=v.clone()._ishlnsubmul(b,1,w);H.negative===0&&(v=H,f&&(f.words[w]=1));for(var q=w-1;q>=0;q--){var W=(v.words[b.length+q]|0)*67108864+(v.words[b.length+q-1]|0);for(W=Math.min(W/E|0,67108863),v._ishlnsubmul(b,W,q);v.negative!==0;)W--,v.negative=0,v._ishlnsubmul(b,1,q),v.isZero()||(v.negative^=1);f&&(f.words[q]=W)}return f&&f.strip(),v.strip(),h!=="div"&&y!==0&&v.iushrn(y),{div:f||null,mod:v}},i.prototype.divmod=function(u,h,y){if(r(!u.isZero()),this.isZero())return{div:new i(0),mod:new i(0)};var v,b,E;return this.negative!==0&&u.negative===0?(E=this.neg().divmod(u,h),h!=="mod"&&(v=E.div.neg()),h!=="div"&&(b=E.mod.neg(),y&&b.negative!==0&&b.iadd(u)),{div:v,mod:b}):this.negative===0&&u.negative!==0?(E=this.divmod(u.neg(),h),h!=="mod"&&(v=E.div.neg()),{div:v,mod:E.mod}):(this.negative&u.negative)!==0?(E=this.neg().divmod(u.neg(),h),h!=="div"&&(b=E.mod.neg(),y&&b.negative!==0&&b.isub(u)),{div:E.div,mod:b}):u.length>this.length||this.cmp(u)<0?{div:new i(0),mod:this}:u.length===1?h==="div"?{div:this.divn(u.words[0]),mod:null}:h==="mod"?{div:null,mod:new i(this.modn(u.words[0]))}:{div:this.divn(u.words[0]),mod:new i(this.modn(u.words[0]))}:this._wordDiv(u,h)},i.prototype.div=function(u){return this.divmod(u,"div",!1).div},i.prototype.mod=function(u){return this.divmod(u,"mod",!1).mod},i.prototype.umod=function(u){return this.divmod(u,"mod",!0).mod},i.prototype.divRound=function(u){var h=this.divmod(u);if(h.mod.isZero())return h.div;var y=h.mod.abs(),v=u.abs().iushrn(1),b=u.words[0]&1,E=y.cmp(v);if(E<0||b===1&&E===0)return h.div;var O=new i(1);return O.negative=this.negative^u.negative,h.div.iadd(O)},i.prototype.modn=function(u){r(u<=67108863);for(var h=(1<<26)%u,y=0,v=this.length-1;v>=0;v--)y=(h*y+(this.words[v]|0))%u;return y},i.prototype.idivn=function(u){r(u<=67108863);for(var h=0,y=this.length-1;y>=0;y--){var v=(this.words[y]|0)+h*67108864;this.words[y]=v/u|0,h=v%u}return this.strip()},i.prototype.divn=function(u){return this.clone().idivn(u)},i.prototype.egcd=function(u){r(u.negative===0),r(!u.isZero());var h=this,y=u.clone();h.negative!==0?h=h.umod(u):h=h.clone();for(var v=new i(1),b=new i(0),E=new i(0),O=new i(1),w=0;h.isEven()&&y.isEven();)h.iushrn(1),y.iushrn(1),++w;for(var f=y.clone(),S=h.clone();!h.isZero();){for(var H=0,q=1;(h.words[0]&q)===0&&H<26;++H,q<<=1);if(H>0)for(h.iushrn(H);H-- >0;)(v.isOdd()||b.isOdd())&&(v.iadd(f),b.isub(S)),v.iushrn(1),b.iushrn(1);for(var W=0,$=1;(y.words[0]&$)===0&&W<26;++W,$<<=1);if(W>0)for(y.iushrn(W);W-- >0;)(E.isOdd()||O.isOdd())&&(E.iadd(f),O.isub(S)),E.iushrn(1),O.iushrn(1);h.cmp(y)>=0?(h.isub(y),v.isub(E),b.isub(O)):(y.isub(h),E.isub(v),O.isub(b))}return{a:E,b:O,gcd:y.iushln(w)}},i.prototype._invmp=function(u){r(u.negative===0),r(!u.isZero());var h=this,y=u.clone();h.negative!==0?h=h.umod(u):h=h.clone();for(var v=new i(1),b=new i(0),E=y.clone();h.cmpn(1)>0&&y.cmpn(1)>0;){for(var O=0,w=1;(h.words[0]&w)===0&&O<26;++O,w<<=1);if(O>0)for(h.iushrn(O);O-- >0;)v.isOdd()&&v.iadd(E),v.iushrn(1);for(var f=0,S=1;(y.words[0]&S)===0&&f<26;++f,S<<=1);if(f>0)for(y.iushrn(f);f-- >0;)b.isOdd()&&b.iadd(E),b.iushrn(1);h.cmp(y)>=0?(h.isub(y),v.isub(b)):(y.isub(h),b.isub(v))}var H;return h.cmpn(1)===0?H=v:H=b,H.cmpn(0)<0&&H.iadd(u),H},i.prototype.gcd=function(u){if(this.isZero())return u.abs();if(u.isZero())return this.abs();var h=this.clone(),y=u.clone();h.negative=0,y.negative=0;for(var v=0;h.isEven()&&y.isEven();v++)h.iushrn(1),y.iushrn(1);do{for(;h.isEven();)h.iushrn(1);for(;y.isEven();)y.iushrn(1);var b=h.cmp(y);if(b<0){var E=h;h=y,y=E}else if(b===0||y.cmpn(1)===0)break;h.isub(y)}while(!0);return y.iushln(v)},i.prototype.invm=function(u){return this.egcd(u).a.umod(u)},i.prototype.isEven=function(){return(this.words[0]&1)===0},i.prototype.isOdd=function(){return(this.words[0]&1)===1},i.prototype.andln=function(u){return this.words[0]&u},i.prototype.bincn=function(u){r(typeof u=="number");var h=u%26,y=(u-h)/26,v=1<<h;if(this.length<=y)return this._expand(y+1),this.words[y]|=v,this;for(var b=v,E=y;b!==0&&E<this.length;E++){var O=this.words[E]|0;O+=b,b=O>>>26,O&=67108863,this.words[E]=O}return b!==0&&(this.words[E]=b,this.length++),this},i.prototype.isZero=function(){return this.length===1&&this.words[0]===0},i.prototype.cmpn=function(u){var h=u<0;if(this.negative!==0&&!h)return-1;if(this.negative===0&&h)return 1;this.strip();var y;if(this.length>1)y=1;else{h&&(u=-u),r(u<=67108863,"Number is too big");var v=this.words[0]|0;y=v===u?0:v<u?-1:1}return this.negative!==0?-y|0:y},i.prototype.cmp=function(u){if(this.negative!==0&&u.negative===0)return-1;if(this.negative===0&&u.negative!==0)return 1;var h=this.ucmp(u);return this.negative!==0?-h|0:h},i.prototype.ucmp=function(u){if(this.length>u.length)return 1;if(this.length<u.length)return-1;for(var h=0,y=this.length-1;y>=0;y--){var v=this.words[y]|0,b=u.words[y]|0;if(v!==b){v<b?h=-1:v>b&&(h=1);break}}return h},i.prototype.gtn=function(u){return this.cmpn(u)===1},i.prototype.gt=function(u){return this.cmp(u)===1},i.prototype.gten=function(u){return this.cmpn(u)>=0},i.prototype.gte=function(u){return this.cmp(u)>=0},i.prototype.ltn=function(u){return this.cmpn(u)===-1},i.prototype.lt=function(u){return this.cmp(u)===-1},i.prototype.lten=function(u){return this.cmpn(u)<=0},i.prototype.lte=function(u){return this.cmp(u)<=0},i.prototype.eqn=function(u){return this.cmpn(u)===0},i.prototype.eq=function(u){return this.cmp(u)===0},i.red=function(u){return new se(u)},i.prototype.toRed=function(u){return r(!this.red,"Already a number in reduction context"),r(this.negative===0,"red works only with positives"),u.convertTo(this)._forceRed(u)},i.prototype.fromRed=function(){return r(this.red,"fromRed works only with numbers in reduction context"),this.red.convertFrom(this)},i.prototype._forceRed=function(u){return this.red=u,this},i.prototype.forceRed=function(u){return r(!this.red,"Already a number in reduction context"),this._forceRed(u)},i.prototype.redAdd=function(u){return r(this.red,"redAdd works only with red numbers"),this.red.add(this,u)},i.prototype.redIAdd=function(u){return r(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,u)},i.prototype.redSub=function(u){return r(this.red,"redSub works only with red numbers"),this.red.sub(this,u)},i.prototype.redISub=function(u){return r(this.red,"redISub works only with red numbers"),this.red.isub(this,u)},i.prototype.redShl=function(u){return r(this.red,"redShl works only with red numbers"),this.red.shl(this,u)},i.prototype.redMul=function(u){return r(this.red,"redMul works only with red numbers"),this.red._verify2(this,u),this.red.mul(this,u)},i.prototype.redIMul=function(u){return r(this.red,"redMul works only with red numbers"),this.red._verify2(this,u),this.red.imul(this,u)},i.prototype.redSqr=function(){return r(this.red,"redSqr works only with red numbers"),this.red._verify1(this),this.red.sqr(this)},i.prototype.redISqr=function(){return r(this.red,"redISqr works only with red numbers"),this.red._verify1(this),this.red.isqr(this)},i.prototype.redSqrt=function(){return r(this.red,"redSqrt works only with red numbers"),this.red._verify1(this),this.red.sqrt(this)},i.prototype.redInvm=function(){return r(this.red,"redInvm works only with red numbers"),this.red._verify1(this),this.red.invm(this)},i.prototype.redNeg=function(){return r(this.red,"redNeg works only with red numbers"),this.red._verify1(this),this.red.neg(this)},i.prototype.redPow=function(u){return r(this.red&&!u.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,u)};var V={k256:null,p224:null,p192:null,p25519:null};function z(A,u){this.name=A,this.p=new i(u,16),this.n=this.p.bitLength(),this.k=new i(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}z.prototype._tmp=function(){var u=new i(null);return u.words=new Array(Math.ceil(this.n/13)),u},z.prototype.ireduce=function(u){var h=u,y;do this.split(h,this.tmp),h=this.imulK(h),h=h.iadd(this.tmp),y=h.bitLength();while(y>this.n);var v=y<this.n?-1:h.ucmp(this.p);return v===0?(h.words[0]=0,h.length=1):v>0?h.isub(this.p):h.strip!==void 0?h.strip():h._strip(),h},z.prototype.split=function(u,h){u.iushrn(this.n,0,h)},z.prototype.imulK=function(u){return u.imul(this.k)};function j(){z.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}n(j,z),j.prototype.split=function(u,h){for(var y=4194303,v=Math.min(u.length,9),b=0;b<v;b++)h.words[b]=u.words[b];if(h.length=v,u.length<=9){u.words[0]=0,u.length=1;return}var E=u.words[9];for(h.words[h.length++]=E&y,b=10;b<u.length;b++){var O=u.words[b]|0;u.words[b-10]=(O&y)<<4|E>>>22,E=O}E>>>=22,u.words[b-10]=E,E===0&&u.length>10?u.length-=10:u.length-=9},j.prototype.imulK=function(u){u.words[u.length]=0,u.words[u.length+1]=0,u.length+=2;for(var h=0,y=0;y<u.length;y++){var v=u.words[y]|0;h+=v*977,u.words[y]=h&67108863,h=v*64+(h/67108864|0)}return u.words[u.length-1]===0&&(u.length--,u.words[u.length-1]===0&&u.length--),u};function Y(){z.call(this,"p224","ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001")}n(Y,z);function oe(){z.call(this,"p192","ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff")}n(oe,z);function Q(){z.call(this,"25519","7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed")}n(Q,z),Q.prototype.imulK=function(u){for(var h=0,y=0;y<u.length;y++){var v=(u.words[y]|0)*19+h,b=v&67108863;v>>>=26,u.words[y]=b,h=v}return h!==0&&(u.words[u.length++]=h),u},i._prime=function(u){if(V[u])return V[u];var h;if(u==="k256")h=new j;else if(u==="p224")h=new Y;else if(u==="p192")h=new oe;else if(u==="p25519")h=new Q;else throw new Error("Unknown prime "+u);return V[u]=h,h};function se(A){if(typeof A=="string"){var u=i._prime(A);this.m=u.p,this.prime=u}else r(A.gtn(1),"modulus must be greater than 1"),this.m=A,this.prime=null}se.prototype._verify1=function(u){r(u.negative===0,"red works only with positives"),r(u.red,"red works only with red numbers")},se.prototype._verify2=function(u,h){r((u.negative|h.negative)===0,"red works only with positives"),r(u.red&&u.red===h.red,"red works only with red numbers")},se.prototype.imod=function(u){return this.prime?this.prime.ireduce(u)._forceRed(this):u.umod(this.m)._forceRed(this)},se.prototype.neg=function(u){return u.isZero()?u.clone():this.m.sub(u)._forceRed(this)},se.prototype.add=function(u,h){this._verify2(u,h);var y=u.add(h);return y.cmp(this.m)>=0&&y.isub(this.m),y._forceRed(this)},se.prototype.iadd=function(u,h){this._verify2(u,h);var y=u.iadd(h);return y.cmp(this.m)>=0&&y.isub(this.m),y},se.prototype.sub=function(u,h){this._verify2(u,h);var y=u.sub(h);return y.cmpn(0)<0&&y.iadd(this.m),y._forceRed(this)},se.prototype.isub=function(u,h){this._verify2(u,h);var y=u.isub(h);return y.cmpn(0)<0&&y.iadd(this.m),y},se.prototype.shl=function(u,h){return this._verify1(u),this.imod(u.ushln(h))},se.prototype.imul=function(u,h){return this._verify2(u,h),this.imod(u.imul(h))},se.prototype.mul=function(u,h){return this._verify2(u,h),this.imod(u.mul(h))},se.prototype.isqr=function(u){return this.imul(u,u.clone())},se.prototype.sqr=function(u){return this.mul(u,u)},se.prototype.sqrt=function(u){if(u.isZero())return u.clone();var h=this.m.andln(3);if(r(h%2===1),h===3){var y=this.m.add(new i(1)).iushrn(2);return this.pow(u,y)}for(var v=this.m.subn(1),b=0;!v.isZero()&&v.andln(1)===0;)b++,v.iushrn(1);r(!v.isZero());var E=new i(1).toRed(this),O=E.redNeg(),w=this.m.subn(1).iushrn(1),f=this.m.bitLength();for(f=new i(2*f*f).toRed(this);this.pow(f,w).cmp(O)!==0;)f.redIAdd(O);for(var S=this.pow(f,v),H=this.pow(u,v.addn(1).iushrn(1)),q=this.pow(u,v),W=b;q.cmp(E)!==0;){for(var $=q,X=0;$.cmp(E)!==0;X++)$=$.redSqr();r(X<W);var ae=this.pow(S,new i(1).iushln(W-X-1));H=H.redMul(ae),S=ae.redSqr(),q=q.redMul(S),W=X}return H},se.prototype.invm=function(u){var h=u._invmp(this.m);return h.negative!==0?(h.negative=0,this.imod(h).redNeg()):this.imod(h)},se.prototype.pow=function(u,h){if(h.isZero())return new i(1).toRed(this);if(h.cmpn(1)===0)return u.clone();var y=4,v=new Array(1<<y);v[0]=new i(1).toRed(this),v[1]=u;for(var b=2;b<v.length;b++)v[b]=this.mul(v[b-1],u);var E=v[0],O=0,w=0,f=h.bitLength()%26;for(f===0&&(f=26),b=h.length-1;b>=0;b--){for(var S=h.words[b],H=f-1;H>=0;H--){var q=S>>H&1;if(E!==v[0]&&(E=this.sqr(E)),q===0&&O===0){w=0;continue}O<<=1,O|=q,w++,!(w!==y&&(b!==0||H!==0))&&(E=this.mul(E,v[O]),w=0,O=0)}f=26}return E},se.prototype.convertTo=function(u){var h=u.umod(this.m);return h===u?h.clone():h},se.prototype.convertFrom=function(u){var h=u.clone();return h.red=null,h},i.mont=function(u){return new ye(u)};function ye(A){se.call(this,A),this.shift=this.m.bitLength(),this.shift%26!==0&&(this.shift+=26-this.shift%26),this.r=new i(1).iushln(this.shift),this.r2=this.imod(this.r.sqr()),this.rinv=this.r._invmp(this.m),this.minv=this.rinv.mul(this.r).isubn(1).div(this.m),this.minv=this.minv.umod(this.r),this.minv=this.r.sub(this.minv)}n(ye,se),ye.prototype.convertTo=function(u){return this.imod(u.ushln(this.shift))},ye.prototype.convertFrom=function(u){var h=this.imod(u.mul(this.rinv));return h.red=null,h},ye.prototype.imul=function(u,h){if(u.isZero()||h.isZero())return u.words[0]=0,u.length=1,u;var y=u.imul(h),v=y.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),b=y.isub(v).iushrn(this.shift),E=b;return b.cmp(this.m)>=0?E=b.isub(this.m):b.cmpn(0)<0&&(E=b.iadd(this.m)),E._forceRed(this)},ye.prototype.mul=function(u,h){if(u.isZero()||h.isZero())return new i(0)._forceRed(this);var y=u.mul(h),v=y.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),b=y.isub(v).iushrn(this.shift),E=b;return b.cmp(this.m)>=0?E=b.isub(this.m):b.cmpn(0)<0&&(E=b.iadd(this.m)),E._forceRed(this)},ye.prototype.invm=function(u){var h=this.imod(u._invmp(this.m).mul(this.r2));return h._forceRed(this)}})(typeof lh>"u"||lh,A0)});var Te=P((n5,dh)=>{p();typeof Object.create=="function"?dh.exports=function(t,r){r&&(t.super_=r,t.prototype=Object.create(r.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}))}:dh.exports=function(t,r){if(r){t.super_=r;var n=function(){};n.prototype=r.prototype,t.prototype=new n,t.prototype.constructor=t}}});var Ct=P((ph,T0)=>{p();var ru=Pt(),Qr=ru.Buffer;function R0(e,t){for(var r in e)t[r]=e[r]}Qr.from&&Qr.alloc&&Qr.allocUnsafe&&Qr.allocUnsafeSlow?T0.exports=ru:(R0(ru,ph),ph.Buffer=Si);function Si(e,t,r){return Qr(e,t,r)}Si.prototype=Object.create(Qr.prototype);R0(Qr,Si);Si.from=function(e,t,r){if(typeof e=="number")throw new TypeError("Argument must not be a number");return Qr(e,t,r)};Si.alloc=function(e,t,r){if(typeof e!="number")throw new TypeError("Argument must be a number");var n=Qr(e);return t!==void 0?typeof r=="string"?n.fill(t,r):n.fill(t):n.fill(0),n};Si.allocUnsafe=function(e){if(typeof e!="number")throw new TypeError("Argument must be a number");return Qr(e)};Si.allocUnsafeSlow=function(e){if(typeof e!="number")throw new TypeError("Argument must be a number");return ru.SlowBuffer(e)}});var mo=P((s5,gh)=>{"use strict";p();var yo=typeof Reflect=="object"?Reflect:null,P0=yo&&typeof yo.apply=="function"?yo.apply:function(t,r,n){return Function.prototype.apply.call(t,r,n)},nu;yo&&typeof yo.ownKeys=="function"?nu=yo.ownKeys:Object.getOwnPropertySymbols?nu=function(t){return Object.getOwnPropertyNames(t).concat(Object.getOwnPropertySymbols(t))}:nu=function(t){return Object.getOwnPropertyNames(t)};function oA(e){console&&console.warn&&console.warn(e)}var N0=Number.isNaN||function(t){return t!==t};function Le(){Le.init.call(this)}gh.exports=Le;gh.exports.once=fA;Le.EventEmitter=Le;Le.prototype._events=void 0;Le.prototype._eventsCount=0;Le.prototype._maxListeners=void 0;var B0=10;function iu(e){if(typeof e!="function")throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof e)}Object.defineProperty(Le,"defaultMaxListeners",{enumerable:!0,get:function(){return B0},set:function(e){if(typeof e!="number"||e<0||N0(e))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+e+".");B0=e}});Le.init=function(){(this._events===void 0||this._events===Object.getPrototypeOf(this)._events)&&(this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0};Le.prototype.setMaxListeners=function(t){if(typeof t!="number"||t<0||N0(t))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+t+".");return this._maxListeners=t,this};function M0(e){return e._maxListeners===void 0?Le.defaultMaxListeners:e._maxListeners}Le.prototype.getMaxListeners=function(){return M0(this)};Le.prototype.emit=function(t){for(var r=[],n=1;n<arguments.length;n++)r.push(arguments[n]);var i=t==="error",o=this._events;if(o!==void 0)i=i&&o.error===void 0;else if(!i)return!1;if(i){var s;if(r.length>0&&(s=r[0]),s instanceof Error)throw s;var a=new Error("Unhandled error."+(s?" ("+s.message+")":""));throw a.context=s,a}var c=o[t];if(c===void 0)return!1;if(typeof c=="function")P0(c,this,r);else for(var l=c.length,g=U0(c,l),n=0;n<l;++n)P0(g[n],this,r);return!0};function k0(e,t,r,n){var i,o,s;if(iu(r),o=e._events,o===void 0?(o=e._events=Object.create(null),e._eventsCount=0):(o.newListener!==void 0&&(e.emit("newListener",t,r.listener?r.listener:r),o=e._events),s=o[t]),s===void 0)s=o[t]=r,++e._eventsCount;else if(typeof s=="function"?s=o[t]=n?[r,s]:[s,r]:n?s.unshift(r):s.push(r),i=M0(e),i>0&&s.length>i&&!s.warned){s.warned=!0;var a=new Error("Possible EventEmitter memory leak detected. "+s.length+" "+String(t)+" listeners added. Use emitter.setMaxListeners() to increase limit");a.name="MaxListenersExceededWarning",a.emitter=e,a.type=t,a.count=s.length,oA(a)}return e}Le.prototype.addListener=function(t,r){return k0(this,t,r,!1)};Le.prototype.on=Le.prototype.addListener;Le.prototype.prependListener=function(t,r){return k0(this,t,r,!0)};function sA(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,arguments.length===0?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function C0(e,t,r){var n={fired:!1,wrapFn:void 0,target:e,type:t,listener:r},i=sA.bind(n);return i.listener=r,n.wrapFn=i,i}Le.prototype.once=function(t,r){return iu(r),this.on(t,C0(this,t,r)),this};Le.prototype.prependOnceListener=function(t,r){return iu(r),this.prependListener(t,C0(this,t,r)),this};Le.prototype.removeListener=function(t,r){var n,i,o,s,a;if(iu(r),i=this._events,i===void 0)return this;if(n=i[t],n===void 0)return this;if(n===r||n.listener===r)--this._eventsCount===0?this._events=Object.create(null):(delete i[t],i.removeListener&&this.emit("removeListener",t,n.listener||r));else if(typeof n!="function"){for(o=-1,s=n.length-1;s>=0;s--)if(n[s]===r||n[s].listener===r){a=n[s].listener,o=s;break}if(o<0)return this;o===0?n.shift():aA(n,o),n.length===1&&(i[t]=n[0]),i.removeListener!==void 0&&this.emit("removeListener",t,a||r)}return this};Le.prototype.off=Le.prototype.removeListener;Le.prototype.removeAllListeners=function(t){var r,n,i;if(n=this._events,n===void 0)return this;if(n.removeListener===void 0)return arguments.length===0?(this._events=Object.create(null),this._eventsCount=0):n[t]!==void 0&&(--this._eventsCount===0?this._events=Object.create(null):delete n[t]),this;if(arguments.length===0){var o=Object.keys(n),s;for(i=0;i<o.length;++i)s=o[i],s!=="removeListener"&&this.removeAllListeners(s);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if(r=n[t],typeof r=="function")this.removeListener(t,r);else if(r!==void 0)for(i=r.length-1;i>=0;i--)this.removeListener(t,r[i]);return this};function L0(e,t,r){var n=e._events;if(n===void 0)return[];var i=n[t];return i===void 0?[]:typeof i=="function"?r?[i.listener||i]:[i]:r?uA(i):U0(i,i.length)}Le.prototype.listeners=function(t){return L0(this,t,!0)};Le.prototype.rawListeners=function(t){return L0(this,t,!1)};Le.listenerCount=function(e,t){return typeof e.listenerCount=="function"?e.listenerCount(t):D0.call(e,t)};Le.prototype.listenerCount=D0;function D0(e){var t=this._events;if(t!==void 0){var r=t[e];if(typeof r=="function")return 1;if(r!==void 0)return r.length}return 0}Le.prototype.eventNames=function(){return this._eventsCount>0?nu(this._events):[]};function U0(e,t){for(var r=new Array(t),n=0;n<t;++n)r[n]=e[n];return r}function aA(e,t){for(;t+1<e.length;t++)e[t]=e[t+1];e.pop()}function uA(e){for(var t=new Array(e.length),r=0;r<t.length;++r)t[r]=e[r].listener||e[r];return t}function fA(e,t){return new Promise(function(r,n){function i(s){e.removeListener(t,o),n(s)}function o(){typeof e.removeListener=="function"&&e.removeListener("error",i),r([].slice.call(arguments))}q0(e,t,o,{once:!0}),t!=="error"&&cA(e,i,{once:!0})})}function cA(e,t,r){typeof e.on=="function"&&q0(e,"error",t,r)}function q0(e,t,r,n){if(typeof e.on=="function")n.once?e.once(t,r):e.on(t,r);else if(typeof e.addEventListener=="function")e.addEventListener(t,function i(o){n.once&&e.removeEventListener(t,i),r(o)});else throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof e)}});var yh=P((u5,F0)=>{p();F0.exports=mo().EventEmitter});var ou=P((c5,H0)=>{"use strict";p();H0.exports=function(){if(typeof Symbol!="function"||typeof Object.getOwnPropertySymbols!="function")return!1;if(typeof Symbol.iterator=="symbol")return!0;var t={},r=Symbol("test"),n=Object(r);if(typeof r=="string"||Object.prototype.toString.call(r)!=="[object Symbol]"||Object.prototype.toString.call(n)!=="[object Symbol]")return!1;var i=42;t[r]=i;for(var o in t)return!1;if(typeof Object.keys=="function"&&Object.keys(t).length!==0||typeof Object.getOwnPropertyNames=="function"&&Object.getOwnPropertyNames(t).length!==0)return!1;var s=Object.getOwnPropertySymbols(t);if(s.length!==1||s[0]!==r||!Object.prototype.propertyIsEnumerable.call(t,r))return!1;if(typeof Object.getOwnPropertyDescriptor=="function"){var a=Object.getOwnPropertyDescriptor(t,r);if(a.value!==i||a.enumerable!==!0)return!1}return!0}});var ws=P((l5,j0)=>{"use strict";p();var hA=ou();j0.exports=function(){return hA()&&!!Symbol.toStringTag}});var su=P((p5,K0)=>{"use strict";p();K0.exports=Object});var G0=P((y5,V0)=>{"use strict";p();V0.exports=Error});var W0=P((v5,z0)=>{"use strict";p();z0.exports=EvalError});var $0=P((_5,Y0)=>{"use strict";p();Y0.exports=RangeError});var X0=P((S5,Z0)=>{"use strict";p();Z0.exports=ReferenceError});var mh=P((x5,J0)=>{"use strict";p();J0.exports=SyntaxError});var Ei=P((A5,Q0)=>{"use strict";p();Q0.exports=TypeError});var tg=P((R5,eg)=>{"use strict";p();eg.exports=URIError});var ng=P((P5,rg)=>{"use strict";p();rg.exports=Math.abs});var og=P((N5,ig)=>{"use strict";p();ig.exports=Math.floor});var ag=P((k5,sg)=>{"use strict";p();sg.exports=Math.max});var fg=P((L5,ug)=>{"use strict";p();ug.exports=Math.min});var hg=P((U5,cg)=>{"use strict";p();cg.exports=Math.pow});var dg=P((F5,lg)=>{"use strict";p();lg.exports=Math.round});var gg=P((j5,pg)=>{"use strict";p();pg.exports=Number.isNaN||function(t){return t!==t}});var mg=P((V5,yg)=>{"use strict";p();var lA=gg();yg.exports=function(t){return lA(t)||t===0?t:t<0?-1:1}});var bg=P((z5,vg)=>{"use strict";p();vg.exports=Object.getOwnPropertyDescriptor});var xi=P((Y5,_g)=>{"use strict";p();var au=bg();if(au)try{au([],"length")}catch{au=null}_g.exports=au});var Ss=P((Z5,wg)=>{"use strict";p();var uu=Object.defineProperty||!1;if(uu)try{uu({},"a",{value:1})}catch{uu=!1}wg.exports=uu});var xg=P((J5,Eg)=>{"use strict";p();var Sg=typeof Symbol<"u"&&Symbol,dA=ou();Eg.exports=function(){return typeof Sg!="function"||typeof Symbol!="function"||typeof Sg("foo")!="symbol"||typeof Symbol("bar")!="symbol"?!1:dA()}});var vh=P((eC,Ig)=>{"use strict";p();Ig.exports=typeof Reflect<"u"&&Reflect.getPrototypeOf||null});var bh=P((rC,Ag)=>{"use strict";p();var pA=su();Ag.exports=pA.getPrototypeOf||null});var Tg=P((iC,Rg)=>{"use strict";p();var gA="Function.prototype.bind called on incompatible ",yA=Object.prototype.toString,mA=Math.max,vA="[object Function]",Og=function(t,r){for(var n=[],i=0;i<t.length;i+=1)n[i]=t[i];for(var o=0;o<r.length;o+=1)n[o+t.length]=r[o];return n},bA=function(t,r){for(var n=[],i=r||0,o=0;i<t.length;i+=1,o+=1)n[o]=t[i];return n},_A=function(e,t){for(var r="",n=0;n<e.length;n+=1)r+=e[n],n+1<e.length&&(r+=t);return r};Rg.exports=function(t){var r=this;if(typeof r!="function"||yA.apply(r)!==vA)throw new TypeError(gA+r);for(var n=bA(arguments,1),i,o=function(){if(this instanceof i){var g=r.apply(this,Og(n,arguments));return Object(g)===g?g:this}return r.apply(t,Og(n,arguments))},s=mA(0,r.length-n.length),a=[],c=0;c<s;c++)a[c]="$"+c;if(i=Function("binder","return function ("+_A(a,",")+"){ return binder.apply(this,arguments); }")(o),r.prototype){var l=function(){};l.prototype=r.prototype,i.prototype=new l,l.prototype=null}return i}});var vo=P((sC,Pg)=>{"use strict";p();var wA=Tg();Pg.exports=Function.prototype.bind||wA});var fu=P((uC,Bg)=>{"use strict";p();Bg.exports=Function.prototype.call});var cu=P((cC,Ng)=>{"use strict";p();Ng.exports=Function.prototype.apply});var kg=P((lC,Mg)=>{"use strict";p();Mg.exports=typeof Reflect<"u"&&Reflect&&Reflect.apply});var _h=P((pC,Cg)=>{"use strict";p();var SA=vo(),EA=cu(),xA=fu(),IA=kg();Cg.exports=IA||SA.call(xA,EA)});var hu=P((yC,Lg)=>{"use strict";p();var AA=vo(),OA=Ei(),RA=fu(),TA=_h();Lg.exports=function(t){if(t.length<1||typeof t[0]!="function")throw new OA("a function is required");return TA(AA,RA,t)}});var jg=P((vC,Hg)=>{"use strict";p();var PA=hu(),Dg=xi(),qg;try{qg=[].__proto__===Array.prototype}catch(e){if(!e||typeof e!="object"||!("code"in e)||e.code!=="ERR_PROTO_ACCESS")throw e}var wh=!!qg&&Dg&&Dg(Object.prototype,"__proto__"),Fg=Object,Ug=Fg.getPrototypeOf;Hg.exports=wh&&typeof wh.get=="function"?PA([wh.get]):typeof Ug=="function"?function(t){return Ug(t==null?t:Fg(t))}:!1});var lu=P((_C,zg)=>{"use strict";p();var Kg=vh(),Vg=bh(),Gg=jg();zg.exports=Kg?function(t){return Kg(t)}:Vg?function(t){if(!t||typeof t!="object"&&typeof t!="function")throw new TypeError("getProto: not an object");return Vg(t)}:Gg?function(t){return Gg(t)}:null});var Sh=P((SC,Wg)=>{"use strict";p();var BA=Function.prototype.call,NA=Object.prototype.hasOwnProperty,MA=vo();Wg.exports=MA.call(BA,NA)});var gu=P((xC,Qg)=>{"use strict";p();var Se,kA=su(),CA=G0(),LA=W0(),DA=$0(),UA=X0(),So=mh(),wo=Ei(),qA=tg(),FA=ng(),HA=og(),jA=ag(),KA=fg(),VA=hg(),GA=dg(),zA=mg(),Xg=Function,Eh=function(e){try{return Xg('"use strict"; return ('+e+").constructor;")()}catch{}},Es=xi(),WA=Ss(),xh=function(){throw new wo},YA=Es?(function(){try{return arguments.callee,xh}catch{try{return Es(arguments,"callee").get}catch{return xh}}})():xh,bo=xg()(),Lt=lu(),$A=bh(),ZA=vh(),Jg=cu(),xs=fu(),_o={},XA=typeof Uint8Array>"u"||!Lt?Se:Lt(Uint8Array),Ii={__proto__:null,"%AggregateError%":typeof AggregateError>"u"?Se:AggregateError,"%Array%":Array,"%ArrayBuffer%":typeof ArrayBuffer>"u"?Se:ArrayBuffer,"%ArrayIteratorPrototype%":bo&&Lt?Lt([][Symbol.iterator]()):Se,"%AsyncFromSyncIteratorPrototype%":Se,"%AsyncFunction%":_o,"%AsyncGenerator%":_o,"%AsyncGeneratorFunction%":_o,"%AsyncIteratorPrototype%":_o,"%Atomics%":typeof Atomics>"u"?Se:Atomics,"%BigInt%":typeof BigInt>"u"?Se:BigInt,"%BigInt64Array%":typeof BigInt64Array>"u"?Se:BigInt64Array,"%BigUint64Array%":typeof BigUint64Array>"u"?Se:BigUint64Array,"%Boolean%":Boolean,"%DataView%":typeof DataView>"u"?Se:DataView,"%Date%":Date,"%decodeURI%":decodeURI,"%decodeURIComponent%":decodeURIComponent,"%encodeURI%":encodeURI,"%encodeURIComponent%":encodeURIComponent,"%Error%":CA,"%eval%":eval,"%EvalError%":LA,"%Float16Array%":typeof Float16Array>"u"?Se:Float16Array,"%Float32Array%":typeof Float32Array>"u"?Se:Float32Array,"%Float64Array%":typeof Float64Array>"u"?Se:Float64Array,"%FinalizationRegistry%":typeof FinalizationRegistry>"u"?Se:FinalizationRegistry,"%Function%":Xg,"%GeneratorFunction%":_o,"%Int8Array%":typeof Int8Array>"u"?Se:Int8Array,"%Int16Array%":typeof Int16Array>"u"?Se:Int16Array,"%Int32Array%":typeof Int32Array>"u"?Se:Int32Array,"%isFinite%":isFinite,"%isNaN%":isNaN,"%IteratorPrototype%":bo&&Lt?Lt(Lt([][Symbol.iterator]())):Se,"%JSON%":typeof JSON=="object"?JSON:Se,"%Map%":typeof Map>"u"?Se:Map,"%MapIteratorPrototype%":typeof Map>"u"||!bo||!Lt?Se:Lt(new Map()[Symbol.iterator]()),"%Math%":Math,"%Number%":Number,"%Object%":kA,"%Object.getOwnPropertyDescriptor%":Es,"%parseFloat%":parseFloat,"%parseInt%":parseInt,"%Promise%":typeof Promise>"u"?Se:Promise,"%Proxy%":typeof Proxy>"u"?Se:Proxy,"%RangeError%":DA,"%ReferenceError%":UA,"%Reflect%":typeof Reflect>"u"?Se:Reflect,"%RegExp%":RegExp,"%Set%":typeof Set>"u"?Se:Set,"%SetIteratorPrototype%":typeof Set>"u"||!bo||!Lt?Se:Lt(new Set()[Symbol.iterator]()),"%SharedArrayBuffer%":typeof SharedArrayBuffer>"u"?Se:SharedArrayBuffer,"%String%":String,"%StringIteratorPrototype%":bo&&Lt?Lt(""[Symbol.iterator]()):Se,"%Symbol%":bo?Symbol:Se,"%SyntaxError%":So,"%ThrowTypeError%":YA,"%TypedArray%":XA,"%TypeError%":wo,"%Uint8Array%":typeof Uint8Array>"u"?Se:Uint8Array,"%Uint8ClampedArray%":typeof Uint8ClampedArray>"u"?Se:Uint8ClampedArray,"%Uint16Array%":typeof Uint16Array>"u"?Se:Uint16Array,"%Uint32Array%":typeof Uint32Array>"u"?Se:Uint32Array,"%URIError%":qA,"%WeakMap%":typeof WeakMap>"u"?Se:WeakMap,"%WeakRef%":typeof WeakRef>"u"?Se:WeakRef,"%WeakSet%":typeof WeakSet>"u"?Se:WeakSet,"%Function.prototype.call%":xs,"%Function.prototype.apply%":Jg,"%Object.defineProperty%":WA,"%Object.getPrototypeOf%":$A,"%Math.abs%":FA,"%Math.floor%":HA,"%Math.max%":jA,"%Math.min%":KA,"%Math.pow%":VA,"%Math.round%":GA,"%Math.sign%":zA,"%Reflect.getPrototypeOf%":ZA};if(Lt)try{null.error}catch(e){Yg=Lt(Lt(e)),Ii["%Error.prototype%"]=Yg}var Yg,JA=function e(t){var r;if(t==="%AsyncFunction%")r=Eh("async function () {}");else if(t==="%GeneratorFunction%")r=Eh("function* () {}");else if(t==="%AsyncGeneratorFunction%")r=Eh("async function* () {}");else if(t==="%AsyncGenerator%"){var n=e("%AsyncGeneratorFunction%");n&&(r=n.prototype)}else if(t==="%AsyncIteratorPrototype%"){var i=e("%AsyncGenerator%");i&&Lt&&(r=Lt(i.prototype))}return Ii[t]=r,r},$g={__proto__:null,"%ArrayBufferPrototype%":["ArrayBuffer","prototype"],"%ArrayPrototype%":["Array","prototype"],"%ArrayProto_entries%":["Array","prototype","entries"],"%ArrayProto_forEach%":["Array","prototype","forEach"],"%ArrayProto_keys%":["Array","prototype","keys"],"%ArrayProto_values%":["Array","prototype","values"],"%AsyncFunctionPrototype%":["AsyncFunction","prototype"],"%AsyncGenerator%":["AsyncGeneratorFunction","prototype"],"%AsyncGeneratorPrototype%":["AsyncGeneratorFunction","prototype","prototype"],"%BooleanPrototype%":["Boolean","prototype"],"%DataViewPrototype%":["DataView","prototype"],"%DatePrototype%":["Date","prototype"],"%ErrorPrototype%":["Error","prototype"],"%EvalErrorPrototype%":["EvalError","prototype"],"%Float32ArrayPrototype%":["Float32Array","prototype"],"%Float64ArrayPrototype%":["Float64Array","prototype"],"%FunctionPrototype%":["Function","prototype"],"%Generator%":["GeneratorFunction","prototype"],"%GeneratorPrototype%":["GeneratorFunction","prototype","prototype"],"%Int8ArrayPrototype%":["Int8Array","prototype"],"%Int16ArrayPrototype%":["Int16Array","prototype"],"%Int32ArrayPrototype%":["Int32Array","prototype"],"%JSONParse%":["JSON","parse"],"%JSONStringify%":["JSON","stringify"],"%MapPrototype%":["Map","prototype"],"%NumberPrototype%":["Number","prototype"],"%ObjectPrototype%":["Object","prototype"],"%ObjProto_toString%":["Object","prototype","toString"],"%ObjProto_valueOf%":["Object","prototype","valueOf"],"%PromisePrototype%":["Promise","prototype"],"%PromiseProto_then%":["Promise","prototype","then"],"%Promise_all%":["Promise","all"],"%Promise_reject%":["Promise","reject"],"%Promise_resolve%":["Promise","resolve"],"%RangeErrorPrototype%":["RangeError","prototype"],"%ReferenceErrorPrototype%":["ReferenceError","prototype"],"%RegExpPrototype%":["RegExp","prototype"],"%SetPrototype%":["Set","prototype"],"%SharedArrayBufferPrototype%":["SharedArrayBuffer","prototype"],"%StringPrototype%":["String","prototype"],"%SymbolPrototype%":["Symbol","prototype"],"%SyntaxErrorPrototype%":["SyntaxError","prototype"],"%TypedArrayPrototype%":["TypedArray","prototype"],"%TypeErrorPrototype%":["TypeError","prototype"],"%Uint8ArrayPrototype%":["Uint8Array","prototype"],"%Uint8ClampedArrayPrototype%":["Uint8ClampedArray","prototype"],"%Uint16ArrayPrototype%":["Uint16Array","prototype"],"%Uint32ArrayPrototype%":["Uint32Array","prototype"],"%URIErrorPrototype%":["URIError","prototype"],"%WeakMapPrototype%":["WeakMap","prototype"],"%WeakSetPrototype%":["WeakSet","prototype"]},Is=vo(),du=Sh(),QA=Is.call(xs,Array.prototype.concat),e2=Is.call(Jg,Array.prototype.splice),Zg=Is.call(xs,String.prototype.replace),pu=Is.call(xs,String.prototype.slice),t2=Is.call(xs,RegExp.prototype.exec),r2=/[^%.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|%$))/g,n2=/\\(\\)?/g,i2=function(t){var r=pu(t,0,1),n=pu(t,-1);if(r==="%"&&n!=="%")throw new So("invalid intrinsic syntax, expected closing `%`");if(n==="%"&&r!=="%")throw new So("invalid intrinsic syntax, expected opening `%`");var i=[];return Zg(t,r2,function(o,s,a,c){i[i.length]=a?Zg(c,n2,"$1"):s||o}),i},o2=function(t,r){var n=t,i;if(du($g,n)&&(i=$g[n],n="%"+i[0]+"%"),du(Ii,n)){var o=Ii[n];if(o===_o&&(o=JA(n)),typeof o>"u"&&!r)throw new wo("intrinsic "+t+" exists, but is not available. Please file an issue!");return{alias:i,name:n,value:o}}throw new So("intrinsic "+t+" does not exist!")};Qg.exports=function(t,r){if(typeof t!="string"||t.length===0)throw new wo("intrinsic name must be a non-empty string");if(arguments.length>1&&typeof r!="boolean")throw new wo('"allowMissing" argument must be a boolean');if(t2(/^%?[^%]*%?$/,t)===null)throw new So("`%` may not be present anywhere but at the beginning and end of the intrinsic name");var n=i2(t),i=n.length>0?n[0]:"",o=o2("%"+i+"%",r),s=o.name,a=o.value,c=!1,l=o.alias;l&&(i=l[0],e2(n,QA([0,1],l)));for(var g=1,m=!0;g<n.length;g+=1){var _=n[g],x=pu(_,0,1),R=pu(_,-1);if((x==='"'||x==="'"||x==="`"||R==='"'||R==="'"||R==="`")&&x!==R)throw new So("property names with quotes must have matching quotes");if((_==="constructor"||!m)&&(c=!0),i+="."+_,s="%"+i+"%",du(Ii,s))a=Ii[s];else if(a!=null){if(!(_ in a)){if(!r)throw new wo("base intrinsic for "+t+" exists, but the property is not available.");return}if(Es&&g+1>=n.length){var B=Es(a,_);m=!!B,m&&"get"in B&&!("originalValue"in B.get)?a=B.get:a=a[_]}else m=du(a,_),a=a[_];m&&!c&&(Ii[s]=a)}}return a}});var Yn=P((AC,ry)=>{"use strict";p();var ey=gu(),ty=hu(),s2=ty([ey("%String.prototype.indexOf%")]);ry.exports=function(t,r){var n=ey(t,!!r);return typeof n=="function"&&s2(t,".prototype.")>-1?ty([n]):n}});var oy=P((RC,iy)=>{"use strict";p();var a2=ws()(),u2=Yn(),Ih=u2("Object.prototype.toString"),yu=function(t){return a2&&t&&typeof t=="object"&&Symbol.toStringTag in t?!1:Ih(t)==="[object Arguments]"},ny=function(t){return yu(t)?!0:t!==null&&typeof t=="object"&&"length"in t&&typeof t.length=="number"&&t.length>=0&&Ih(t)!=="[object Array]"&&"callee"in t&&Ih(t.callee)==="[object Function]"},f2=(function(){return yu(arguments)})();yu.isLegacyArguments=ny;iy.exports=f2?yu:ny});var hy=P((PC,cy)=>{"use strict";p();var sy=Yn(),c2=ws()(),h2=Sh(),l2=xi(),Rh;c2?(ay=sy("RegExp.prototype.exec"),Ah={},mu=function(){throw Ah},Oh={toString:mu,valueOf:mu},typeof Symbol.toPrimitive=="symbol"&&(Oh[Symbol.toPrimitive]=mu),Rh=function(t){if(!t||typeof t!="object")return!1;var r=l2(t,"lastIndex"),n=r&&h2(r,"value");if(!n)return!1;try{ay(t,Oh)}catch(i){return i===Ah}}):(uy=sy("Object.prototype.toString"),fy="[object RegExp]",Rh=function(t){return!t||typeof t!="object"&&typeof t!="function"?!1:uy(t)===fy});var ay,Ah,mu,Oh,uy,fy;cy.exports=Rh});var dy=P((NC,ly)=>{"use strict";p();var d2=Yn(),p2=hy(),g2=d2("RegExp.prototype.exec"),y2=Ei();ly.exports=function(t){if(!p2(t))throw new y2("`regex` must be a RegExp");return function(n){return g2(t,n)!==null}}});var gy=P((kC,py)=>{"use strict";p();var m2=function*(){}.constructor;py.exports=()=>m2});var by=P((LC,vy)=>{"use strict";p();var my=Yn(),v2=dy(),b2=v2(/^\s*(?:function)?\*/),_2=ws()(),yy=lu(),w2=my("Object.prototype.toString"),S2=my("Function.prototype.toString"),E2=gy();vy.exports=function(t){if(typeof t!="function")return!1;if(b2(S2(t)))return!0;if(!_2){var r=w2(t);return r==="[object GeneratorFunction]"}if(!yy)return!1;var n=E2();return n&&yy(t)===n.prototype}});var Ey=P((UC,Sy)=>{"use strict";p();var wy=Function.prototype.toString,Eo=typeof Reflect=="object"&&Reflect!==null&&Reflect.apply,Ph,vu;if(typeof Eo=="function"&&typeof Object.defineProperty=="function")try{Ph=Object.defineProperty({},"length",{get:function(){throw vu}}),vu={},Eo(function(){throw 42},null,Ph)}catch(e){e!==vu&&(Eo=null)}else Eo=null;var x2=/^\s*class\b/,Bh=function(t){try{var r=wy.call(t);return x2.test(r)}catch{return!1}},Th=function(t){try{return Bh(t)?!1:(wy.call(t),!0)}catch{return!1}},bu=Object.prototype.toString,I2="[object Object]",A2="[object Function]",O2="[object GeneratorFunction]",R2="[object HTMLAllCollection]",T2="[object HTML document.all class]",P2="[object HTMLCollection]",B2=typeof Symbol=="function"&&!!Symbol.toStringTag,N2=!(0 in[,]),Nh=function(){return!1};typeof document=="object"&&(_y=document.all,bu.call(_y)===bu.call(document.all)&&(Nh=function(t){if((N2||!t)&&(typeof t>"u"||typeof t=="object"))try{var r=bu.call(t);return(r===R2||r===T2||r===P2||r===I2)&&t("")==null}catch{}return!1}));var _y;Sy.exports=Eo?function(t){if(Nh(t))return!0;if(!t||typeof t!="function"&&typeof t!="object")return!1;try{Eo(t,null,Ph)}catch(r){if(r!==vu)return!1}return!Bh(t)&&Th(t)}:function(t){if(Nh(t))return!0;if(!t||typeof t!="function"&&typeof t!="object")return!1;if(B2)return Th(t);if(Bh(t))return!1;var r=bu.call(t);return r!==A2&&r!==O2&&!/^\[object HTML/.test(r)?!1:Th(t)}});var Ay=P((FC,Iy)=>{"use strict";p();var M2=Ey(),k2=Object.prototype.toString,xy=Object.prototype.hasOwnProperty,C2=function(t,r,n){for(var i=0,o=t.length;i<o;i++)xy.call(t,i)&&(n==null?r(t[i],i,t):r.call(n,t[i],i,t))},L2=function(t,r,n){for(var i=0,o=t.length;i<o;i++)n==null?r(t.charAt(i),i,t):r.call(n,t.charAt(i),i,t)},D2=function(t,r,n){for(var i in t)xy.call(t,i)&&(n==null?r(t[i],i,t):r.call(n,t[i],i,t))};function U2(e){return k2.call(e)==="[object Array]"}Iy.exports=function(t,r,n){if(!M2(r))throw new TypeError("iterator must be a function");var i;arguments.length>=3&&(i=n),U2(t)?C2(t,r,i):typeof t=="string"?L2(t,r,i):D2(t,r,i)}});var Ry=P((jC,Oy)=>{"use strict";p();Oy.exports=["Float16Array","Float32Array","Float64Array","Int8Array","Int16Array","Int32Array","Uint8Array","Uint8ClampedArray","Uint16Array","Uint32Array","BigInt64Array","BigUint64Array"]});var Py=P((VC,Ty)=>{"use strict";p();var Mh=Ry(),q2=globalThis;Ty.exports=function(){for(var t=[],r=0;r<Mh.length;r++)typeof q2[Mh[r]]=="function"&&(t[t.length]=Mh[r]);return t}});var kh=P((zC,My)=>{"use strict";p();var By=Ss(),F2=mh(),xo=Ei(),Ny=xi();My.exports=function(t,r,n){if(!t||typeof t!="object"&&typeof t!="function")throw new xo("`obj` must be an object or a function`");if(typeof r!="string"&&typeof r!="symbol")throw new xo("`property` must be a string or a symbol`");if(arguments.length>3&&typeof arguments[3]!="boolean"&&arguments[3]!==null)throw new xo("`nonEnumerable`, if provided, must be a boolean or null");if(arguments.length>4&&typeof arguments[4]!="boolean"&&arguments[4]!==null)throw new xo("`nonWritable`, if provided, must be a boolean or null");if(arguments.length>5&&typeof arguments[5]!="boolean"&&arguments[5]!==null)throw new xo("`nonConfigurable`, if provided, must be a boolean or null");if(arguments.length>6&&typeof arguments[6]!="boolean")throw new xo("`loose`, if provided, must be a boolean");var i=arguments.length>3?arguments[3]:null,o=arguments.length>4?arguments[4]:null,s=arguments.length>5?arguments[5]:null,a=arguments.length>6?arguments[6]:!1,c=!!Ny&&Ny(t,r);if(By)By(t,r,{configurable:s===null&&c?c.configurable:!s,enumerable:i===null&&c?c.enumerable:!i,value:n,writable:o===null&&c?c.writable:!o});else if(a||!i&&!o&&!s)t[r]=n;else throw new F2("This environment does not support defining a property as non-configurable, non-writable, or non-enumerable.")}});var Lh=P((YC,Cy)=>{"use strict";p();var Ch=Ss(),ky=function(){return!!Ch};ky.hasArrayLengthDefineBug=function(){if(!Ch)return null;try{return Ch([],"length",{value:1}).length!==1}catch{return!0}};Cy.exports=ky});var Fy=P((ZC,qy)=>{"use strict";p();var H2=gu(),Ly=kh(),j2=Lh()(),Dy=xi(),Uy=Ei(),K2=H2("%Math.floor%");qy.exports=function(t,r){if(typeof t!="function")throw new Uy("`fn` is not a function");if(typeof r!="number"||r<0||r>4294967295||K2(r)!==r)throw new Uy("`length` must be a positive 32-bit integer");var n=arguments.length>2&&!!arguments[2],i=!0,o=!0;if("length"in t&&Dy){var s=Dy(t,"length");s&&!s.configurable&&(i=!1),s&&!s.writable&&(o=!1)}return(i||o||!n)&&(j2?Ly(t,"length",r,!0,!0):Ly(t,"length",r)),t}});var jy=P((JC,Hy)=>{"use strict";p();var V2=vo(),G2=cu(),z2=_h();Hy.exports=function(){return z2(V2,G2,arguments)}});var As=P((eL,_u)=>{"use strict";p();var W2=Fy(),Ky=Ss(),Y2=hu(),Vy=jy();_u.exports=function(t){var r=Y2(arguments),n=1+t.length-(arguments.length-1);return W2(r,n>0?n:0,!0)};Ky?Ky(_u.exports,"apply",{value:Vy}):_u.exports.apply=Vy});var Fh=P((rL,Yy)=>{"use strict";p();var Eu=Ay(),$2=Py(),Gy=As(),Uh=Yn(),Su=xi(),wu=lu(),Z2=Uh("Object.prototype.toString"),Wy=ws()(),zy=globalThis,Dh=$2(),qh=Uh("String.prototype.slice"),X2=Uh("Array.prototype.indexOf",!0)||function(t,r){for(var n=0;n<t.length;n+=1)if(t[n]===r)return n;return-1},xu={__proto__:null};Wy&&Su&&wu?Eu(Dh,function(e){var t=new zy[e];if(Symbol.toStringTag in t&&wu){var r=wu(t),n=Su(r,Symbol.toStringTag);if(!n&&r){var i=wu(r);n=Su(i,Symbol.toStringTag)}if(n&&n.get){var o=Gy(n.get);xu["$"+e]=o}}}):Eu(Dh,function(e){var t=new zy[e],r=t.slice||t.set;if(r){var n=Gy(r);xu["$"+e]=n}});var J2=function(t){var r=!1;return Eu(xu,function(n,i){if(!r)try{"$"+n(t)===i&&(r=qh(i,1))}catch{}}),r},Q2=function(t){var r=!1;return Eu(xu,function(n,i){if(!r)try{n(t),r=qh(i,1)}catch{}}),r};Yy.exports=function(t){if(!t||typeof t!="object")return!1;if(!Wy){var r=qh(Z2(t),8,-1);return X2(Dh,r)>-1?r:r!=="Object"?!1:Q2(t)}return Su?J2(t):null}});var Hh=P((iL,$y)=>{"use strict";p();var eO=Fh();$y.exports=function(t){return!!eO(t)}});var fm=P(Ee=>{"use strict";p();var tO=oy(),rO=by(),Pr=Fh(),Zy=Hh();function Io(e){return e.call.bind(e)}var Xy=typeof BigInt<"u",Jy=typeof Symbol<"u",vr=Io(Object.prototype.toString),nO=Io(Number.prototype.valueOf),iO=Io(String.prototype.valueOf),oO=Io(Boolean.prototype.valueOf);Xy&&(Qy=Io(BigInt.prototype.valueOf));var Qy;Jy&&(em=Io(Symbol.prototype.valueOf));var em;function Rs(e,t){if(typeof e!="object")return!1;try{return t(e),!0}catch{return!1}}Ee.isArgumentsObject=tO;Ee.isGeneratorFunction=rO;Ee.isTypedArray=Zy;function sO(e){return typeof Promise<"u"&&e instanceof Promise||e!==null&&typeof e=="object"&&typeof e.then=="function"&&typeof e.catch=="function"}Ee.isPromise=sO;function aO(e){return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?ArrayBuffer.isView(e):Zy(e)||rm(e)}Ee.isArrayBufferView=aO;function uO(e){return Pr(e)==="Uint8Array"}Ee.isUint8Array=uO;function fO(e){return Pr(e)==="Uint8ClampedArray"}Ee.isUint8ClampedArray=fO;function cO(e){return Pr(e)==="Uint16Array"}Ee.isUint16Array=cO;function hO(e){return Pr(e)==="Uint32Array"}Ee.isUint32Array=hO;function lO(e){return Pr(e)==="Int8Array"}Ee.isInt8Array=lO;function dO(e){return Pr(e)==="Int16Array"}Ee.isInt16Array=dO;function pO(e){return Pr(e)==="Int32Array"}Ee.isInt32Array=pO;function gO(e){return Pr(e)==="Float32Array"}Ee.isFloat32Array=gO;function yO(e){return Pr(e)==="Float64Array"}Ee.isFloat64Array=yO;function mO(e){return Pr(e)==="BigInt64Array"}Ee.isBigInt64Array=mO;function vO(e){return Pr(e)==="BigUint64Array"}Ee.isBigUint64Array=vO;function Iu(e){return vr(e)==="[object Map]"}Iu.working=typeof Map<"u"&&Iu(new Map);function bO(e){return typeof Map>"u"?!1:Iu.working?Iu(e):e instanceof Map}Ee.isMap=bO;function Au(e){return vr(e)==="[object Set]"}Au.working=typeof Set<"u"&&Au(new Set);function _O(e){return typeof Set>"u"?!1:Au.working?Au(e):e instanceof Set}Ee.isSet=_O;function Ou(e){return vr(e)==="[object WeakMap]"}Ou.working=typeof WeakMap<"u"&&Ou(new WeakMap);function wO(e){return typeof WeakMap>"u"?!1:Ou.working?Ou(e):e instanceof WeakMap}Ee.isWeakMap=wO;function Kh(e){return vr(e)==="[object WeakSet]"}Kh.working=typeof WeakSet<"u"&&Kh(new WeakSet);function SO(e){return Kh(e)}Ee.isWeakSet=SO;function Ru(e){return vr(e)==="[object ArrayBuffer]"}Ru.working=typeof ArrayBuffer<"u"&&Ru(new ArrayBuffer);function tm(e){return typeof ArrayBuffer>"u"?!1:Ru.working?Ru(e):e instanceof ArrayBuffer}Ee.isArrayBuffer=tm;function Tu(e){return vr(e)==="[object DataView]"}Tu.working=typeof ArrayBuffer<"u"&&typeof DataView<"u"&&Tu(new DataView(new ArrayBuffer(1),0,1));function rm(e){return typeof DataView>"u"?!1:Tu.working?Tu(e):e instanceof DataView}Ee.isDataView=rm;var jh=typeof SharedArrayBuffer<"u"?SharedArrayBuffer:void 0;function Os(e){return vr(e)==="[object SharedArrayBuffer]"}function nm(e){return typeof jh>"u"?!1:(typeof Os.working>"u"&&(Os.working=Os(new jh)),Os.working?Os(e):e instanceof jh)}Ee.isSharedArrayBuffer=nm;function EO(e){return vr(e)==="[object AsyncFunction]"}Ee.isAsyncFunction=EO;function xO(e){return vr(e)==="[object Map Iterator]"}Ee.isMapIterator=xO;function IO(e){return vr(e)==="[object Set Iterator]"}Ee.isSetIterator=IO;function AO(e){return vr(e)==="[object Generator]"}Ee.isGeneratorObject=AO;function OO(e){return vr(e)==="[object WebAssembly.Module]"}Ee.isWebAssemblyCompiledModule=OO;function im(e){return Rs(e,nO)}Ee.isNumberObject=im;function om(e){return Rs(e,iO)}Ee.isStringObject=om;function sm(e){return Rs(e,oO)}Ee.isBooleanObject=sm;function am(e){return Xy&&Rs(e,Qy)}Ee.isBigIntObject=am;function um(e){return Jy&&Rs(e,em)}Ee.isSymbolObject=um;function RO(e){return im(e)||om(e)||sm(e)||am(e)||um(e)}Ee.isBoxedPrimitive=RO;function TO(e){return typeof Uint8Array<"u"&&(tm(e)||nm(e))}Ee.isAnyArrayBuffer=TO;["isProxy","isExternal","isModuleNamespaceObject"].forEach(function(e){Object.defineProperty(Ee,e,{enumerable:!1,value:function(){throw new Error(e+" is not supported in userland")}})})});var hm=P((uL,cm)=>{p();cm.exports=function(t){return t&&typeof t=="object"&&typeof t.copy=="function"&&typeof t.fill=="function"&&typeof t.readUInt8=="function"}});var en=P(xe=>{p();var lm=Object.getOwnPropertyDescriptors||function(t){for(var r=Object.keys(t),n={},i=0;i<r.length;i++)n[r[i]]=Object.getOwnPropertyDescriptor(t,r[i]);return n},PO=/%[sdj%]/g;xe.format=function(e){if(!Lu(e)){for(var t=[],r=0;r<arguments.length;r++)t.push($n(arguments[r]));return t.join(" ")}for(var r=1,n=arguments,i=n.length,o=String(e).replace(PO,function(a){if(a==="%%")return"%";if(r>=i)return a;switch(a){case"%s":return String(n[r++]);case"%d":return Number(n[r++]);case"%j":try{return JSON.stringify(n[r++])}catch{return"[Circular]"}default:return a}}),s=n[r];r<i;s=n[++r])Cu(s)||!Ao(s)?o+=" "+s:o+=" "+$n(s);return o};xe.deprecate=function(e,t){if(typeof I.default<"u"&&I.default.noDeprecation===!0)return e;if(typeof I.default>"u")return function(){return xe.deprecate(e,t).apply(this,arguments)};var r=!1;function n(){if(!r){if(I.default.throwDeprecation)throw new Error(t);I.default.traceDeprecation?console.trace(t):console.error(t),r=!0}return e.apply(this,arguments)}return n};var Pu={},dm=/^$/;I.default.env.NODE_DEBUG&&(Bu=I.default.env.NODE_DEBUG,Bu=Bu.replace(/[|\\{}()[\]^$+?.]/g,"\\$&").replace(/\*/g,".*").replace(/,/g,"$|^").toUpperCase(),dm=new RegExp("^"+Bu+"$","i"));var Bu;xe.debuglog=function(e){if(e=e.toUpperCase(),!Pu[e])if(dm.test(e)){var t=I.default.pid;Pu[e]=function(){var r=xe.format.apply(xe,arguments);console.error("%s %d: %s",e,t,r)}}else Pu[e]=function(){};return Pu[e]};function $n(e,t){var r={seen:[],stylize:NO};return arguments.length>=3&&(r.depth=arguments[2]),arguments.length>=4&&(r.colors=arguments[3]),Wh(t)?r.showHidden=t:t&&xe._extend(r,t),Oi(r.showHidden)&&(r.showHidden=!1),Oi(r.depth)&&(r.depth=2),Oi(r.colors)&&(r.colors=!1),Oi(r.customInspect)&&(r.customInspect=!0),r.colors&&(r.stylize=BO),Mu(r,e,r.depth)}xe.inspect=$n;$n.colors={bold:[1,22],italic:[3,23],underline:[4,24],inverse:[7,27],white:[37,39],grey:[90,39],black:[30,39],blue:[34,39],cyan:[36,39],green:[32,39],magenta:[35,39],red:[31,39],yellow:[33,39]};$n.styles={special:"cyan",number:"yellow",boolean:"yellow",undefined:"grey",null:"bold",string:"green",date:"magenta",regexp:"red"};function BO(e,t){var r=$n.styles[t];return r?"\x1B["+$n.colors[r][0]+"m"+e+"\x1B["+$n.colors[r][1]+"m":e}function NO(e,t){return e}function MO(e){var t={};return e.forEach(function(r,n){t[r]=!0}),t}function Mu(e,t,r){if(e.customInspect&&t&&Nu(t.inspect)&&t.inspect!==xe.inspect&&!(t.constructor&&t.constructor.prototype===t)){var n=t.inspect(r,e);return Lu(n)||(n=Mu(e,n,r)),n}var i=kO(e,t);if(i)return i;var o=Object.keys(t),s=MO(o);if(e.showHidden&&(o=Object.getOwnPropertyNames(t)),Ps(t)&&(o.indexOf("message")>=0||o.indexOf("description")>=0))return Vh(t);if(o.length===0){if(Nu(t)){var a=t.name?": "+t.name:"";return e.stylize("[Function"+a+"]","special")}if(Ts(t))return e.stylize(RegExp.prototype.toString.call(t),"regexp");if(ku(t))return e.stylize(Date.prototype.toString.call(t),"date");if(Ps(t))return Vh(t)}var c="",l=!1,g=["{","}"];if(pm(t)&&(l=!0,g=["[","]"]),Nu(t)){var m=t.name?": "+t.name:"";c=" [Function"+m+"]"}if(Ts(t)&&(c=" "+RegExp.prototype.toString.call(t)),ku(t)&&(c=" "+Date.prototype.toUTCString.call(t)),Ps(t)&&(c=" "+Vh(t)),o.length===0&&(!l||t.length==0))return g[0]+c+g[1];if(r<0)return Ts(t)?e.stylize(RegExp.prototype.toString.call(t),"regexp"):e.stylize("[Object]","special");e.seen.push(t);var _;return l?_=CO(e,t,r,s,o):_=o.map(function(x){return zh(e,t,r,s,x,l)}),e.seen.pop(),LO(_,c,g)}function kO(e,t){if(Oi(t))return e.stylize("undefined","undefined");if(Lu(t)){var r="'"+JSON.stringify(t).replace(/^"|"$/g,"").replace(/'/g,"\\'").replace(/\\"/g,'"')+"'";return e.stylize(r,"string")}if(gm(t))return e.stylize(""+t,"number");if(Wh(t))return e.stylize(""+t,"boolean");if(Cu(t))return e.stylize("null","null")}function Vh(e){return"["+Error.prototype.toString.call(e)+"]"}function CO(e,t,r,n,i){for(var o=[],s=0,a=t.length;s<a;++s)ym(t,String(s))?o.push(zh(e,t,r,n,String(s),!0)):o.push("");return i.forEach(function(c){c.match(/^\d+$/)||o.push(zh(e,t,r,n,c,!0))}),o}function zh(e,t,r,n,i,o){var s,a,c;if(c=Object.getOwnPropertyDescriptor(t,i)||{value:t[i]},c.get?c.set?a=e.stylize("[Getter/Setter]","special"):a=e.stylize("[Getter]","special"):c.set&&(a=e.stylize("[Setter]","special")),ym(n,i)||(s="["+i+"]"),a||(e.seen.indexOf(c.value)<0?(Cu(r)?a=Mu(e,c.value,null):a=Mu(e,c.value,r-1),a.indexOf(`
|
|
1
|
+
var bsvLTP=(()=>{var Lx=Object.create;var gs=Object.defineProperty;var Dx=Object.getOwnPropertyDescriptor;var Ux=Object.getOwnPropertyNames;var Fx=Object.getPrototypeOf,qx=Object.prototype.hasOwnProperty;var Hx=(e,t,r)=>t in e?gs(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r;var er=(e,t,r)=>()=>{if(r)throw r[0];try{return e&&(t=e(e=0)),t}catch(n){throw r=[n],n}};var P=(e,t)=>()=>{try{return t||e((t={exports:{}}).exports,t),t.exports}catch(r){throw t=0,r}},al=(e,t)=>{for(var r in t)gs(e,r,{get:t[r],enumerable:!0})},Qp=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of Ux(t))!qx.call(e,i)&&i!==r&&gs(e,i,{get:()=>t[i],enumerable:!(n=Dx(t,i))||n.enumerable});return e};var e0=(e,t,r)=>(r=e!=null?Lx(Fx(e)):{},Qp(t||!e||!e.__esModule?gs(r,"default",{value:e,enumerable:!0}):r,e)),ul=e=>Qp(gs({},"__esModule",{value:!0}),e);var C=(e,t,r)=>Hx(e,typeof t!="symbol"?t+"":t,r);var o0=P((jk,i0)=>{y();var Qe=i0.exports={},$r,Zr;function fl(){throw new Error("setTimeout has not been defined")}function cl(){throw new Error("clearTimeout has not been defined")}(function(){try{typeof setTimeout=="function"?$r=setTimeout:$r=fl}catch{$r=fl}try{typeof clearTimeout=="function"?Zr=clearTimeout:Zr=cl}catch{Zr=cl}})();function t0(e){if($r===setTimeout)return setTimeout(e,0);if(($r===fl||!$r)&&setTimeout)return $r=setTimeout,setTimeout(e,0);try{return $r(e,0)}catch{try{return $r.call(null,e,0)}catch{return $r.call(this,e,0)}}}function jx(e){if(Zr===clearTimeout)return clearTimeout(e);if((Zr===cl||!Zr)&&clearTimeout)return Zr=clearTimeout,clearTimeout(e);try{return Zr(e)}catch{try{return Zr.call(null,e)}catch{return Zr.call(this,e)}}}var gn=[],fo=!1,mi,Za=-1;function Kx(){!fo||!mi||(fo=!1,mi.length?gn=mi.concat(gn):Za=-1,gn.length&&r0())}function r0(){if(!fo){var e=t0(Kx);fo=!0;for(var t=gn.length;t;){for(mi=gn,gn=[];++Za<t;)mi&&mi[Za].run();Za=-1,t=gn.length}mi=null,fo=!1,jx(e)}}Qe.nextTick=function(e){var t=new Array(arguments.length-1);if(arguments.length>1)for(var r=1;r<arguments.length;r++)t[r-1]=arguments[r];gn.push(new n0(e,t)),gn.length===1&&!fo&&t0(r0)};function n0(e,t){this.fun=e,this.array=t}n0.prototype.run=function(){this.fun.apply(null,this.array)};Qe.title="browser";Qe.browser=!0;Qe.env={};Qe.argv=[];Qe.version="";Qe.versions={};function yn(){}Qe.on=yn;Qe.addListener=yn;Qe.once=yn;Qe.off=yn;Qe.removeListener=yn;Qe.removeAllListeners=yn;Qe.emit=yn;Qe.prependListener=yn;Qe.prependOnceListener=yn;Qe.listeners=function(e){return[]};Qe.binding=function(e){throw new Error("process.binding is not supported")};Qe.cwd=function(){return"/"};Qe.chdir=function(e){throw new Error("process.chdir is not supported")};Qe.umask=function(){return 0}});var u0=P(Xa=>{"use strict";y();Xa.byteLength=Gx;Xa.toByteArray=zx;Xa.fromByteArray=Zx;var Xr=[],br=[],Vx=typeof Uint8Array<"u"?Uint8Array:Array,ll="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";for(vi=0,s0=ll.length;vi<s0;++vi)Xr[vi]=ll[vi],br[ll.charCodeAt(vi)]=vi;var vi,s0;br[45]=62;br[95]=63;function a0(e){var t=e.length;if(t%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var r=e.indexOf("=");r===-1&&(r=t);var n=r===t?0:4-r%4;return[r,n]}function Gx(e){var t=a0(e),r=t[0],n=t[1];return(r+n)*3/4-n}function Wx(e,t,r){return(t+r)*3/4-r}function zx(e){var t,r=a0(e),n=r[0],i=r[1],o=new Vx(Wx(e,n,i)),s=0,a=i>0?n-4:n,c;for(c=0;c<a;c+=4)t=br[e.charCodeAt(c)]<<18|br[e.charCodeAt(c+1)]<<12|br[e.charCodeAt(c+2)]<<6|br[e.charCodeAt(c+3)],o[s++]=t>>16&255,o[s++]=t>>8&255,o[s++]=t&255;return i===2&&(t=br[e.charCodeAt(c)]<<2|br[e.charCodeAt(c+1)]>>4,o[s++]=t&255),i===1&&(t=br[e.charCodeAt(c)]<<10|br[e.charCodeAt(c+1)]<<4|br[e.charCodeAt(c+2)]>>2,o[s++]=t>>8&255,o[s++]=t&255),o}function Yx(e){return Xr[e>>18&63]+Xr[e>>12&63]+Xr[e>>6&63]+Xr[e&63]}function $x(e,t,r){for(var n,i=[],o=t;o<r;o+=3)n=(e[o]<<16&16711680)+(e[o+1]<<8&65280)+(e[o+2]&255),i.push(Yx(n));return i.join("")}function Zx(e){for(var t,r=e.length,n=r%3,i=[],o=16383,s=0,a=r-n;s<a;s+=o)i.push($x(e,s,s+o>a?a:s+o));return n===1?(t=e[r-1],i.push(Xr[t>>2]+Xr[t<<4&63]+"==")):n===2&&(t=(e[r-2]<<8)+e[r-1],i.push(Xr[t>>10]+Xr[t>>4&63]+Xr[t<<2&63]+"=")),i.join("")}});var f0=P(hl=>{y();hl.read=function(e,t,r,n,i){var o,s,a=i*8-n-1,c=(1<<a)-1,h=c>>1,g=-7,m=r?i-1:0,_=r?-1:1,I=e[t+m];for(m+=_,o=I&(1<<-g)-1,I>>=-g,g+=a;g>0;o=o*256+e[t+m],m+=_,g-=8);for(s=o&(1<<-g)-1,o>>=-g,g+=n;g>0;s=s*256+e[t+m],m+=_,g-=8);if(o===0)o=1-h;else{if(o===c)return s?NaN:(I?-1:1)*(1/0);s=s+Math.pow(2,n),o=o-h}return(I?-1:1)*s*Math.pow(2,o-n)};hl.write=function(e,t,r,n,i,o){var s,a,c,h=o*8-i-1,g=(1<<h)-1,m=g>>1,_=i===23?Math.pow(2,-24)-Math.pow(2,-77):0,I=n?0:o-1,R=n?1:-1,N=t<0||t===0&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(a=isNaN(t)?1:0,s=g):(s=Math.floor(Math.log(t)/Math.LN2),t*(c=Math.pow(2,-s))<1&&(s--,c*=2),s+m>=1?t+=_/c:t+=_*Math.pow(2,1-m),t*c>=2&&(s++,c/=2),s+m>=g?(a=0,s=g):s+m>=1?(a=(t*c-1)*Math.pow(2,i),s=s+m):(a=t*Math.pow(2,m-1)*Math.pow(2,i),s=0));i>=8;e[r+I]=a&255,I+=R,a/=256,i-=8);for(s=s<<i|a,h+=i;h>0;e[r+I]=s&255,I+=R,s/=256,h-=8);e[r+I-R]|=N*128}});var Tt=P(po=>{"use strict";y();var dl=u0(),lo=f0(),c0=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):null;po.Buffer=U;po.SlowBuffer=rI;po.INSPECT_MAX_BYTES=50;var Ja=2147483647;po.kMaxLength=Ja;U.TYPED_ARRAY_SUPPORT=Xx();!U.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 Xx(){try{let e=new Uint8Array(1),t={foo:function(){return 42}};return Object.setPrototypeOf(t,Uint8Array.prototype),Object.setPrototypeOf(e,t),e.foo()===42}catch{return!1}}Object.defineProperty(U.prototype,"parent",{enumerable:!0,get:function(){if(U.isBuffer(this))return this.buffer}});Object.defineProperty(U.prototype,"offset",{enumerable:!0,get:function(){if(U.isBuffer(this))return this.byteOffset}});function mn(e){if(e>Ja)throw new RangeError('The value "'+e+'" is invalid for option "size"');let t=new Uint8Array(e);return Object.setPrototypeOf(t,U.prototype),t}function U(e,t,r){if(typeof e=="number"){if(typeof t=="string")throw new TypeError('The "string" argument must be of type string. Received type number');return ml(e)}return p0(e,t,r)}U.poolSize=8192;function p0(e,t,r){if(typeof e=="string")return Qx(e,t);if(ArrayBuffer.isView(e))return eI(e);if(e==null)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof e);if(Jr(e,ArrayBuffer)||e&&Jr(e.buffer,ArrayBuffer)||typeof SharedArrayBuffer<"u"&&(Jr(e,SharedArrayBuffer)||e&&Jr(e.buffer,SharedArrayBuffer)))return gl(e,t,r);if(typeof e=="number")throw new TypeError('The "value" argument must not be of type number. Received type number');let n=e.valueOf&&e.valueOf();if(n!=null&&n!==e)return U.from(n,t,r);let i=tI(e);if(i)return i;if(typeof Symbol<"u"&&Symbol.toPrimitive!=null&&typeof e[Symbol.toPrimitive]=="function")return U.from(e[Symbol.toPrimitive]("string"),t,r);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof e)}U.from=function(e,t,r){return p0(e,t,r)};Object.setPrototypeOf(U.prototype,Uint8Array.prototype);Object.setPrototypeOf(U,Uint8Array);function g0(e){if(typeof e!="number")throw new TypeError('"size" argument must be of type number');if(e<0)throw new RangeError('The value "'+e+'" is invalid for option "size"')}function Jx(e,t,r){return g0(e),e<=0?mn(e):t!==void 0?typeof r=="string"?mn(e).fill(t,r):mn(e).fill(t):mn(e)}U.alloc=function(e,t,r){return Jx(e,t,r)};function ml(e){return g0(e),mn(e<0?0:vl(e)|0)}U.allocUnsafe=function(e){return ml(e)};U.allocUnsafeSlow=function(e){return ml(e)};function Qx(e,t){if((typeof t!="string"||t==="")&&(t="utf8"),!U.isEncoding(t))throw new TypeError("Unknown encoding: "+t);let r=y0(e,t)|0,n=mn(r),i=n.write(e,t);return i!==r&&(n=n.slice(0,i)),n}function pl(e){let t=e.length<0?0:vl(e.length)|0,r=mn(t);for(let n=0;n<t;n+=1)r[n]=e[n]&255;return r}function eI(e){if(Jr(e,Uint8Array)){let t=new Uint8Array(e);return gl(t.buffer,t.byteOffset,t.byteLength)}return pl(e)}function gl(e,t,r){if(t<0||e.byteLength<t)throw new RangeError('"offset" is outside of buffer bounds');if(e.byteLength<t+(r||0))throw new RangeError('"length" is outside of buffer bounds');let n;return t===void 0&&r===void 0?n=new Uint8Array(e):r===void 0?n=new Uint8Array(e,t):n=new Uint8Array(e,t,r),Object.setPrototypeOf(n,U.prototype),n}function tI(e){if(U.isBuffer(e)){let t=vl(e.length)|0,r=mn(t);return r.length===0||e.copy(r,0,0,t),r}if(e.length!==void 0)return typeof e.length!="number"||_l(e.length)?mn(0):pl(e);if(e.type==="Buffer"&&Array.isArray(e.data))return pl(e.data)}function vl(e){if(e>=Ja)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+Ja.toString(16)+" bytes");return e|0}function rI(e){return+e!=e&&(e=0),U.alloc(+e)}U.isBuffer=function(t){return t!=null&&t._isBuffer===!0&&t!==U.prototype};U.compare=function(t,r){if(Jr(t,Uint8Array)&&(t=U.from(t,t.offset,t.byteLength)),Jr(r,Uint8Array)&&(r=U.from(r,r.offset,r.byteLength)),!U.isBuffer(t)||!U.isBuffer(r))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(t===r)return 0;let n=t.length,i=r.length;for(let o=0,s=Math.min(n,i);o<s;++o)if(t[o]!==r[o]){n=t[o],i=r[o];break}return n<i?-1:i<n?1:0};U.isEncoding=function(t){switch(String(t).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}};U.concat=function(t,r){if(!Array.isArray(t))throw new TypeError('"list" argument must be an Array of Buffers');if(t.length===0)return U.alloc(0);let n;if(r===void 0)for(r=0,n=0;n<t.length;++n)r+=t[n].length;let i=U.allocUnsafe(r),o=0;for(n=0;n<t.length;++n){let s=t[n];if(Jr(s,Uint8Array))o+s.length>i.length?(U.isBuffer(s)||(s=U.from(s)),s.copy(i,o)):Uint8Array.prototype.set.call(i,s,o);else if(U.isBuffer(s))s.copy(i,o);else throw new TypeError('"list" argument must be an Array of Buffers');o+=s.length}return i};function y0(e,t){if(U.isBuffer(e))return e.length;if(ArrayBuffer.isView(e)||Jr(e,ArrayBuffer))return e.byteLength;if(typeof e!="string")throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof e);let r=e.length,n=arguments.length>2&&arguments[2]===!0;if(!n&&r===0)return 0;let i=!1;for(;;)switch(t){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":return yl(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return r*2;case"hex":return r>>>1;case"base64":return I0(e).length;default:if(i)return n?-1:yl(e).length;t=(""+t).toLowerCase(),i=!0}}U.byteLength=y0;function nI(e,t,r){let n=!1;if((t===void 0||t<0)&&(t=0),t>this.length||((r===void 0||r>this.length)&&(r=this.length),r<=0)||(r>>>=0,t>>>=0,r<=t))return"";for(e||(e="utf8");;)switch(e){case"hex":return dI(this,t,r);case"utf8":case"utf-8":return v0(this,t,r);case"ascii":return lI(this,t,r);case"latin1":case"binary":return hI(this,t,r);case"base64":return fI(this,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return pI(this,t,r);default:if(n)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),n=!0}}U.prototype._isBuffer=!0;function bi(e,t,r){let n=e[t];e[t]=e[r],e[r]=n}U.prototype.swap16=function(){let t=this.length;if(t%2!==0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(let r=0;r<t;r+=2)bi(this,r,r+1);return this};U.prototype.swap32=function(){let t=this.length;if(t%4!==0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(let r=0;r<t;r+=4)bi(this,r,r+3),bi(this,r+1,r+2);return this};U.prototype.swap64=function(){let t=this.length;if(t%8!==0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(let r=0;r<t;r+=8)bi(this,r,r+7),bi(this,r+1,r+6),bi(this,r+2,r+5),bi(this,r+3,r+4);return this};U.prototype.toString=function(){let t=this.length;return t===0?"":arguments.length===0?v0(this,0,t):nI.apply(this,arguments)};U.prototype.toLocaleString=U.prototype.toString;U.prototype.equals=function(t){if(!U.isBuffer(t))throw new TypeError("Argument must be a Buffer");return this===t?!0:U.compare(this,t)===0};U.prototype.inspect=function(){let t="",r=po.INSPECT_MAX_BYTES;return t=this.toString("hex",0,r).replace(/(.{2})/g,"$1 ").trim(),this.length>r&&(t+=" ... "),"<Buffer "+t+">"};c0&&(U.prototype[c0]=U.prototype.inspect);U.prototype.compare=function(t,r,n,i,o){if(Jr(t,Uint8Array)&&(t=U.from(t,t.offset,t.byteLength)),!U.isBuffer(t))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof t);if(r===void 0&&(r=0),n===void 0&&(n=t?t.length:0),i===void 0&&(i=0),o===void 0&&(o=this.length),r<0||n>t.length||i<0||o>this.length)throw new RangeError("out of range index");if(i>=o&&r>=n)return 0;if(i>=o)return-1;if(r>=n)return 1;if(r>>>=0,n>>>=0,i>>>=0,o>>>=0,this===t)return 0;let s=o-i,a=n-r,c=Math.min(s,a),h=this.slice(i,o),g=t.slice(r,n);for(let m=0;m<c;++m)if(h[m]!==g[m]){s=h[m],a=g[m];break}return s<a?-1:a<s?1:0};function m0(e,t,r,n,i){if(e.length===0)return-1;if(typeof r=="string"?(n=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),r=+r,_l(r)&&(r=i?0:e.length-1),r<0&&(r=e.length+r),r>=e.length){if(i)return-1;r=e.length-1}else if(r<0)if(i)r=0;else return-1;if(typeof t=="string"&&(t=U.from(t,n)),U.isBuffer(t))return t.length===0?-1:l0(e,t,r,n,i);if(typeof t=="number")return t=t&255,typeof Uint8Array.prototype.indexOf=="function"?i?Uint8Array.prototype.indexOf.call(e,t,r):Uint8Array.prototype.lastIndexOf.call(e,t,r):l0(e,[t],r,n,i);throw new TypeError("val must be string, number or Buffer")}function l0(e,t,r,n,i){let o=1,s=e.length,a=t.length;if(n!==void 0&&(n=String(n).toLowerCase(),n==="ucs2"||n==="ucs-2"||n==="utf16le"||n==="utf-16le")){if(e.length<2||t.length<2)return-1;o=2,s/=2,a/=2,r/=2}function c(g,m){return o===1?g[m]:g.readUInt16BE(m*o)}let h;if(i){let g=-1;for(h=r;h<s;h++)if(c(e,h)===c(t,g===-1?0:h-g)){if(g===-1&&(g=h),h-g+1===a)return g*o}else g!==-1&&(h-=h-g),g=-1}else for(r+a>s&&(r=s-a),h=r;h>=0;h--){let g=!0;for(let m=0;m<a;m++)if(c(e,h+m)!==c(t,m)){g=!1;break}if(g)return h}return-1}U.prototype.includes=function(t,r,n){return this.indexOf(t,r,n)!==-1};U.prototype.indexOf=function(t,r,n){return m0(this,t,r,n,!0)};U.prototype.lastIndexOf=function(t,r,n){return m0(this,t,r,n,!1)};function iI(e,t,r,n){r=Number(r)||0;let i=e.length-r;n?(n=Number(n),n>i&&(n=i)):n=i;let o=t.length;n>o/2&&(n=o/2);let s;for(s=0;s<n;++s){let a=parseInt(t.substr(s*2,2),16);if(_l(a))return s;e[r+s]=a}return s}function oI(e,t,r,n){return Qa(yl(t,e.length-r),e,r,n)}function sI(e,t,r,n){return Qa(vI(t),e,r,n)}function aI(e,t,r,n){return Qa(I0(t),e,r,n)}function uI(e,t,r,n){return Qa(bI(t,e.length-r),e,r,n)}U.prototype.write=function(t,r,n,i){if(r===void 0)i="utf8",n=this.length,r=0;else if(n===void 0&&typeof r=="string")i=r,n=this.length,r=0;else if(isFinite(r))r=r>>>0,isFinite(n)?(n=n>>>0,i===void 0&&(i="utf8")):(i=n,n=void 0);else throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");let o=this.length-r;if((n===void 0||n>o)&&(n=o),t.length>0&&(n<0||r<0)||r>this.length)throw new RangeError("Attempt to write outside buffer bounds");i||(i="utf8");let s=!1;for(;;)switch(i){case"hex":return iI(this,t,r,n);case"utf8":case"utf-8":return oI(this,t,r,n);case"ascii":case"latin1":case"binary":return sI(this,t,r,n);case"base64":return aI(this,t,r,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return uI(this,t,r,n);default:if(s)throw new TypeError("Unknown encoding: "+i);i=(""+i).toLowerCase(),s=!0}};U.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function fI(e,t,r){return t===0&&r===e.length?dl.fromByteArray(e):dl.fromByteArray(e.slice(t,r))}function v0(e,t,r){r=Math.min(e.length,r);let n=[],i=t;for(;i<r;){let o=e[i],s=null,a=o>239?4:o>223?3:o>191?2:1;if(i+a<=r){let c,h,g,m;switch(a){case 1:o<128&&(s=o);break;case 2:c=e[i+1],(c&192)===128&&(m=(o&31)<<6|c&63,m>127&&(s=m));break;case 3:c=e[i+1],h=e[i+2],(c&192)===128&&(h&192)===128&&(m=(o&15)<<12|(c&63)<<6|h&63,m>2047&&(m<55296||m>57343)&&(s=m));break;case 4:c=e[i+1],h=e[i+2],g=e[i+3],(c&192)===128&&(h&192)===128&&(g&192)===128&&(m=(o&15)<<18|(c&63)<<12|(h&63)<<6|g&63,m>65535&&m<1114112&&(s=m))}}s===null?(s=65533,a=1):s>65535&&(s-=65536,n.push(s>>>10&1023|55296),s=56320|s&1023),n.push(s),i+=a}return cI(n)}var h0=4096;function cI(e){let t=e.length;if(t<=h0)return String.fromCharCode.apply(String,e);let r="",n=0;for(;n<t;)r+=String.fromCharCode.apply(String,e.slice(n,n+=h0));return r}function lI(e,t,r){let n="";r=Math.min(e.length,r);for(let i=t;i<r;++i)n+=String.fromCharCode(e[i]&127);return n}function hI(e,t,r){let n="";r=Math.min(e.length,r);for(let i=t;i<r;++i)n+=String.fromCharCode(e[i]);return n}function dI(e,t,r){let n=e.length;(!t||t<0)&&(t=0),(!r||r<0||r>n)&&(r=n);let i="";for(let o=t;o<r;++o)i+=_I[e[o]];return i}function pI(e,t,r){let n=e.slice(t,r),i="";for(let o=0;o<n.length-1;o+=2)i+=String.fromCharCode(n[o]+n[o+1]*256);return i}U.prototype.slice=function(t,r){let n=this.length;t=~~t,r=r===void 0?n:~~r,t<0?(t+=n,t<0&&(t=0)):t>n&&(t=n),r<0?(r+=n,r<0&&(r=0)):r>n&&(r=n),r<t&&(r=t);let i=this.subarray(t,r);return Object.setPrototypeOf(i,U.prototype),i};function Mt(e,t,r){if(e%1!==0||e<0)throw new RangeError("offset is not uint");if(e+t>r)throw new RangeError("Trying to access beyond buffer length")}U.prototype.readUintLE=U.prototype.readUIntLE=function(t,r,n){t=t>>>0,r=r>>>0,n||Mt(t,r,this.length);let i=this[t],o=1,s=0;for(;++s<r&&(o*=256);)i+=this[t+s]*o;return i};U.prototype.readUintBE=U.prototype.readUIntBE=function(t,r,n){t=t>>>0,r=r>>>0,n||Mt(t,r,this.length);let i=this[t+--r],o=1;for(;r>0&&(o*=256);)i+=this[t+--r]*o;return i};U.prototype.readUint8=U.prototype.readUInt8=function(t,r){return t=t>>>0,r||Mt(t,1,this.length),this[t]};U.prototype.readUint16LE=U.prototype.readUInt16LE=function(t,r){return t=t>>>0,r||Mt(t,2,this.length),this[t]|this[t+1]<<8};U.prototype.readUint16BE=U.prototype.readUInt16BE=function(t,r){return t=t>>>0,r||Mt(t,2,this.length),this[t]<<8|this[t+1]};U.prototype.readUint32LE=U.prototype.readUInt32LE=function(t,r){return t=t>>>0,r||Mt(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+this[t+3]*16777216};U.prototype.readUint32BE=U.prototype.readUInt32BE=function(t,r){return t=t>>>0,r||Mt(t,4,this.length),this[t]*16777216+(this[t+1]<<16|this[t+2]<<8|this[t+3])};U.prototype.readBigUInt64LE=Kn(function(t){t=t>>>0,ho(t,"offset");let r=this[t],n=this[t+7];(r===void 0||n===void 0)&&ys(t,this.length-8);let i=r+this[++t]*2**8+this[++t]*2**16+this[++t]*2**24,o=this[++t]+this[++t]*2**8+this[++t]*2**16+n*2**24;return BigInt(i)+(BigInt(o)<<BigInt(32))});U.prototype.readBigUInt64BE=Kn(function(t){t=t>>>0,ho(t,"offset");let r=this[t],n=this[t+7];(r===void 0||n===void 0)&&ys(t,this.length-8);let i=r*2**24+this[++t]*2**16+this[++t]*2**8+this[++t],o=this[++t]*2**24+this[++t]*2**16+this[++t]*2**8+n;return(BigInt(i)<<BigInt(32))+BigInt(o)});U.prototype.readIntLE=function(t,r,n){t=t>>>0,r=r>>>0,n||Mt(t,r,this.length);let i=this[t],o=1,s=0;for(;++s<r&&(o*=256);)i+=this[t+s]*o;return o*=128,i>=o&&(i-=Math.pow(2,8*r)),i};U.prototype.readIntBE=function(t,r,n){t=t>>>0,r=r>>>0,n||Mt(t,r,this.length);let i=r,o=1,s=this[t+--i];for(;i>0&&(o*=256);)s+=this[t+--i]*o;return o*=128,s>=o&&(s-=Math.pow(2,8*r)),s};U.prototype.readInt8=function(t,r){return t=t>>>0,r||Mt(t,1,this.length),this[t]&128?(255-this[t]+1)*-1:this[t]};U.prototype.readInt16LE=function(t,r){t=t>>>0,r||Mt(t,2,this.length);let n=this[t]|this[t+1]<<8;return n&32768?n|4294901760:n};U.prototype.readInt16BE=function(t,r){t=t>>>0,r||Mt(t,2,this.length);let n=this[t+1]|this[t]<<8;return n&32768?n|4294901760:n};U.prototype.readInt32LE=function(t,r){return t=t>>>0,r||Mt(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24};U.prototype.readInt32BE=function(t,r){return t=t>>>0,r||Mt(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]};U.prototype.readBigInt64LE=Kn(function(t){t=t>>>0,ho(t,"offset");let r=this[t],n=this[t+7];(r===void 0||n===void 0)&&ys(t,this.length-8);let i=this[t+4]+this[t+5]*2**8+this[t+6]*2**16+(n<<24);return(BigInt(i)<<BigInt(32))+BigInt(r+this[++t]*2**8+this[++t]*2**16+this[++t]*2**24)});U.prototype.readBigInt64BE=Kn(function(t){t=t>>>0,ho(t,"offset");let r=this[t],n=this[t+7];(r===void 0||n===void 0)&&ys(t,this.length-8);let i=(r<<24)+this[++t]*2**16+this[++t]*2**8+this[++t];return(BigInt(i)<<BigInt(32))+BigInt(this[++t]*2**24+this[++t]*2**16+this[++t]*2**8+n)});U.prototype.readFloatLE=function(t,r){return t=t>>>0,r||Mt(t,4,this.length),lo.read(this,t,!0,23,4)};U.prototype.readFloatBE=function(t,r){return t=t>>>0,r||Mt(t,4,this.length),lo.read(this,t,!1,23,4)};U.prototype.readDoubleLE=function(t,r){return t=t>>>0,r||Mt(t,8,this.length),lo.read(this,t,!0,52,8)};U.prototype.readDoubleBE=function(t,r){return t=t>>>0,r||Mt(t,8,this.length),lo.read(this,t,!1,52,8)};function sr(e,t,r,n,i,o){if(!U.isBuffer(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>i||t<o)throw new RangeError('"value" argument is out of bounds');if(r+n>e.length)throw new RangeError("Index out of range")}U.prototype.writeUintLE=U.prototype.writeUIntLE=function(t,r,n,i){if(t=+t,r=r>>>0,n=n>>>0,!i){let a=Math.pow(2,8*n)-1;sr(this,t,r,n,a,0)}let o=1,s=0;for(this[r]=t&255;++s<n&&(o*=256);)this[r+s]=t/o&255;return r+n};U.prototype.writeUintBE=U.prototype.writeUIntBE=function(t,r,n,i){if(t=+t,r=r>>>0,n=n>>>0,!i){let a=Math.pow(2,8*n)-1;sr(this,t,r,n,a,0)}let o=n-1,s=1;for(this[r+o]=t&255;--o>=0&&(s*=256);)this[r+o]=t/s&255;return r+n};U.prototype.writeUint8=U.prototype.writeUInt8=function(t,r,n){return t=+t,r=r>>>0,n||sr(this,t,r,1,255,0),this[r]=t&255,r+1};U.prototype.writeUint16LE=U.prototype.writeUInt16LE=function(t,r,n){return t=+t,r=r>>>0,n||sr(this,t,r,2,65535,0),this[r]=t&255,this[r+1]=t>>>8,r+2};U.prototype.writeUint16BE=U.prototype.writeUInt16BE=function(t,r,n){return t=+t,r=r>>>0,n||sr(this,t,r,2,65535,0),this[r]=t>>>8,this[r+1]=t&255,r+2};U.prototype.writeUint32LE=U.prototype.writeUInt32LE=function(t,r,n){return t=+t,r=r>>>0,n||sr(this,t,r,4,4294967295,0),this[r+3]=t>>>24,this[r+2]=t>>>16,this[r+1]=t>>>8,this[r]=t&255,r+4};U.prototype.writeUint32BE=U.prototype.writeUInt32BE=function(t,r,n){return t=+t,r=r>>>0,n||sr(this,t,r,4,4294967295,0),this[r]=t>>>24,this[r+1]=t>>>16,this[r+2]=t>>>8,this[r+3]=t&255,r+4};function b0(e,t,r,n,i){x0(t,n,i,e,r,7);let o=Number(t&BigInt(4294967295));e[r++]=o,o=o>>8,e[r++]=o,o=o>>8,e[r++]=o,o=o>>8,e[r++]=o;let s=Number(t>>BigInt(32)&BigInt(4294967295));return e[r++]=s,s=s>>8,e[r++]=s,s=s>>8,e[r++]=s,s=s>>8,e[r++]=s,r}function _0(e,t,r,n,i){x0(t,n,i,e,r,7);let o=Number(t&BigInt(4294967295));e[r+7]=o,o=o>>8,e[r+6]=o,o=o>>8,e[r+5]=o,o=o>>8,e[r+4]=o;let s=Number(t>>BigInt(32)&BigInt(4294967295));return e[r+3]=s,s=s>>8,e[r+2]=s,s=s>>8,e[r+1]=s,s=s>>8,e[r]=s,r+8}U.prototype.writeBigUInt64LE=Kn(function(t,r=0){return b0(this,t,r,BigInt(0),BigInt("0xffffffffffffffff"))});U.prototype.writeBigUInt64BE=Kn(function(t,r=0){return _0(this,t,r,BigInt(0),BigInt("0xffffffffffffffff"))});U.prototype.writeIntLE=function(t,r,n,i){if(t=+t,r=r>>>0,!i){let c=Math.pow(2,8*n-1);sr(this,t,r,n,c-1,-c)}let o=0,s=1,a=0;for(this[r]=t&255;++o<n&&(s*=256);)t<0&&a===0&&this[r+o-1]!==0&&(a=1),this[r+o]=(t/s>>0)-a&255;return r+n};U.prototype.writeIntBE=function(t,r,n,i){if(t=+t,r=r>>>0,!i){let c=Math.pow(2,8*n-1);sr(this,t,r,n,c-1,-c)}let o=n-1,s=1,a=0;for(this[r+o]=t&255;--o>=0&&(s*=256);)t<0&&a===0&&this[r+o+1]!==0&&(a=1),this[r+o]=(t/s>>0)-a&255;return r+n};U.prototype.writeInt8=function(t,r,n){return t=+t,r=r>>>0,n||sr(this,t,r,1,127,-128),t<0&&(t=255+t+1),this[r]=t&255,r+1};U.prototype.writeInt16LE=function(t,r,n){return t=+t,r=r>>>0,n||sr(this,t,r,2,32767,-32768),this[r]=t&255,this[r+1]=t>>>8,r+2};U.prototype.writeInt16BE=function(t,r,n){return t=+t,r=r>>>0,n||sr(this,t,r,2,32767,-32768),this[r]=t>>>8,this[r+1]=t&255,r+2};U.prototype.writeInt32LE=function(t,r,n){return t=+t,r=r>>>0,n||sr(this,t,r,4,2147483647,-2147483648),this[r]=t&255,this[r+1]=t>>>8,this[r+2]=t>>>16,this[r+3]=t>>>24,r+4};U.prototype.writeInt32BE=function(t,r,n){return t=+t,r=r>>>0,n||sr(this,t,r,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),this[r]=t>>>24,this[r+1]=t>>>16,this[r+2]=t>>>8,this[r+3]=t&255,r+4};U.prototype.writeBigInt64LE=Kn(function(t,r=0){return b0(this,t,r,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});U.prototype.writeBigInt64BE=Kn(function(t,r=0){return _0(this,t,r,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});function w0(e,t,r,n,i,o){if(r+n>e.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function S0(e,t,r,n,i){return t=+t,r=r>>>0,i||w0(e,t,r,4,34028234663852886e22,-34028234663852886e22),lo.write(e,t,r,n,23,4),r+4}U.prototype.writeFloatLE=function(t,r,n){return S0(this,t,r,!0,n)};U.prototype.writeFloatBE=function(t,r,n){return S0(this,t,r,!1,n)};function E0(e,t,r,n,i){return t=+t,r=r>>>0,i||w0(e,t,r,8,17976931348623157e292,-17976931348623157e292),lo.write(e,t,r,n,52,8),r+8}U.prototype.writeDoubleLE=function(t,r,n){return E0(this,t,r,!0,n)};U.prototype.writeDoubleBE=function(t,r,n){return E0(this,t,r,!1,n)};U.prototype.copy=function(t,r,n,i){if(!U.isBuffer(t))throw new TypeError("argument should be a Buffer");if(n||(n=0),!i&&i!==0&&(i=this.length),r>=t.length&&(r=t.length),r||(r=0),i>0&&i<n&&(i=n),i===n||t.length===0||this.length===0)return 0;if(r<0)throw new RangeError("targetStart out of bounds");if(n<0||n>=this.length)throw new RangeError("Index out of range");if(i<0)throw new RangeError("sourceEnd out of bounds");i>this.length&&(i=this.length),t.length-r<i-n&&(i=t.length-r+n);let o=i-n;return this===t&&typeof Uint8Array.prototype.copyWithin=="function"?this.copyWithin(r,n,i):Uint8Array.prototype.set.call(t,this.subarray(n,i),r),o};U.prototype.fill=function(t,r,n,i){if(typeof t=="string"){if(typeof r=="string"?(i=r,r=0,n=this.length):typeof n=="string"&&(i=n,n=this.length),i!==void 0&&typeof i!="string")throw new TypeError("encoding must be a string");if(typeof i=="string"&&!U.isEncoding(i))throw new TypeError("Unknown encoding: "+i);if(t.length===1){let s=t.charCodeAt(0);(i==="utf8"&&s<128||i==="latin1")&&(t=s)}}else typeof t=="number"?t=t&255:typeof t=="boolean"&&(t=Number(t));if(r<0||this.length<r||this.length<n)throw new RangeError("Out of range index");if(n<=r)return this;r=r>>>0,n=n===void 0?this.length:n>>>0,t||(t=0);let o;if(typeof t=="number")for(o=r;o<n;++o)this[o]=t;else{let s=U.isBuffer(t)?t:U.from(t,i),a=s.length;if(a===0)throw new TypeError('The value "'+t+'" is invalid for argument "value"');for(o=0;o<n-r;++o)this[o+r]=s[o%a]}return this};var co={};function bl(e,t,r){co[e]=class extends r{constructor(){super(),Object.defineProperty(this,"message",{value:t.apply(this,arguments),writable:!0,configurable:!0}),this.name=`${this.name} [${e}]`,this.stack,delete this.name}get code(){return e}set code(i){Object.defineProperty(this,"code",{configurable:!0,enumerable:!0,value:i,writable:!0})}toString(){return`${this.name} [${e}]: ${this.message}`}}}bl("ERR_BUFFER_OUT_OF_BOUNDS",function(e){return e?`${e} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"},RangeError);bl("ERR_INVALID_ARG_TYPE",function(e,t){return`The "${e}" argument must be of type number. Received type ${typeof t}`},TypeError);bl("ERR_OUT_OF_RANGE",function(e,t,r){let n=`The value of "${e}" is out of range.`,i=r;return Number.isInteger(r)&&Math.abs(r)>2**32?i=d0(String(r)):typeof r=="bigint"&&(i=String(r),(r>BigInt(2)**BigInt(32)||r<-(BigInt(2)**BigInt(32)))&&(i=d0(i)),i+="n"),n+=` It must be ${t}. Received ${i}`,n},RangeError);function d0(e){let t="",r=e.length,n=e[0]==="-"?1:0;for(;r>=n+4;r-=3)t=`_${e.slice(r-3,r)}${t}`;return`${e.slice(0,r)}${t}`}function gI(e,t,r){ho(t,"offset"),(e[t]===void 0||e[t+r]===void 0)&&ys(t,e.length-(r+1))}function x0(e,t,r,n,i,o){if(e>r||e<t){let s=typeof t=="bigint"?"n":"",a;throw o>3?t===0||t===BigInt(0)?a=`>= 0${s} and < 2${s} ** ${(o+1)*8}${s}`:a=`>= -(2${s} ** ${(o+1)*8-1}${s}) and < 2 ** ${(o+1)*8-1}${s}`:a=`>= ${t}${s} and <= ${r}${s}`,new co.ERR_OUT_OF_RANGE("value",a,e)}gI(n,i,o)}function ho(e,t){if(typeof e!="number")throw new co.ERR_INVALID_ARG_TYPE(t,"number",e)}function ys(e,t,r){throw Math.floor(e)!==e?(ho(e,r),new co.ERR_OUT_OF_RANGE(r||"offset","an integer",e)):t<0?new co.ERR_BUFFER_OUT_OF_BOUNDS:new co.ERR_OUT_OF_RANGE(r||"offset",`>= ${r?1:0} and <= ${t}`,e)}var yI=/[^+/0-9A-Za-z-_]/g;function mI(e){if(e=e.split("=")[0],e=e.trim().replace(yI,""),e.length<2)return"";for(;e.length%4!==0;)e=e+"=";return e}function yl(e,t){t=t||1/0;let r,n=e.length,i=null,o=[];for(let s=0;s<n;++s){if(r=e.charCodeAt(s),r>55295&&r<57344){if(!i){if(r>56319){(t-=3)>-1&&o.push(239,191,189);continue}else if(s+1===n){(t-=3)>-1&&o.push(239,191,189);continue}i=r;continue}if(r<56320){(t-=3)>-1&&o.push(239,191,189),i=r;continue}r=(i-55296<<10|r-56320)+65536}else i&&(t-=3)>-1&&o.push(239,191,189);if(i=null,r<128){if((t-=1)<0)break;o.push(r)}else if(r<2048){if((t-=2)<0)break;o.push(r>>6|192,r&63|128)}else if(r<65536){if((t-=3)<0)break;o.push(r>>12|224,r>>6&63|128,r&63|128)}else if(r<1114112){if((t-=4)<0)break;o.push(r>>18|240,r>>12&63|128,r>>6&63|128,r&63|128)}else throw new Error("Invalid code point")}return o}function vI(e){let t=[];for(let r=0;r<e.length;++r)t.push(e.charCodeAt(r)&255);return t}function bI(e,t){let r,n,i,o=[];for(let s=0;s<e.length&&!((t-=2)<0);++s)r=e.charCodeAt(s),n=r>>8,i=r%256,o.push(i),o.push(n);return o}function I0(e){return dl.toByteArray(mI(e))}function Qa(e,t,r,n){let i;for(i=0;i<n&&!(i+r>=t.length||i>=e.length);++i)t[i+r]=e[i];return i}function Jr(e,t){return e instanceof t||e!=null&&e.constructor!=null&&e.constructor.name!=null&&e.constructor.name===t.name}function _l(e){return e!==e}var _I=(function(){let e="0123456789abcdef",t=new Array(256);for(let r=0;r<16;++r){let n=r*16;for(let i=0;i<16;++i)t[n+i]=e[r]+e[i]}return t})();function Kn(e){return typeof BigInt>"u"?wI:e}function wI(){throw new Error("BigInt not supported")}});var x,d,y=er(()=>{x=e0(o0()),d=e0(Tt())});var O0=P((A0,wl)=>{y();(function(e,t){"use strict";function r(A,u){if(!A)throw new Error(u||"Assertion failed")}function n(A,u){A.super_=u;var l=function(){};l.prototype=u.prototype,A.prototype=new l,A.prototype.constructor=A}function i(A,u,l){if(i.isBN(A))return A;this.negative=0,this.words=null,this.length=0,this.red=null,A!==null&&((u==="le"||u==="be")&&(l=u,u=10),this._init(A||0,u||10,l||"be"))}typeof e=="object"?e.exports=i:t.BN=i,i.BN=i,i.wordSize=26;var o;try{typeof window<"u"&&typeof window.Buffer<"u"?o=window.Buffer:o=Tt().Buffer}catch{}i.isBN=function(u){return u instanceof i?!0:u!==null&&typeof u=="object"&&u.constructor.wordSize===i.wordSize&&Array.isArray(u.words)},i.max=function(u,l){return u.cmp(l)>0?u:l},i.min=function(u,l){return u.cmp(l)<0?u:l},i.prototype._init=function(u,l,p){if(typeof u=="number")return this._initNumber(u,l,p);if(typeof u=="object")return this._initArray(u,l,p);l==="hex"&&(l=16),r(l===(l|0)&&l>=2&&l<=36),u=u.toString().replace(/\s+/g,"");var v=0;u[0]==="-"&&(v++,this.negative=1),v<u.length&&(l===16?this._parseHex(u,v,p):(this._parseBase(u,l,v),p==="le"&&this._initArray(this.toArray(),l,p)))},i.prototype._initNumber=function(u,l,p){u<0&&(this.negative=1,u=-u),u<67108864?(this.words=[u&67108863],this.length=1):u<4503599627370496?(this.words=[u&67108863,u/67108864&67108863],this.length=2):(r(u<9007199254740992),this.words=[u&67108863,u/67108864&67108863,1],this.length=3),p==="le"&&this._initArray(this.toArray(),l,p)},i.prototype._initArray=function(u,l,p){if(r(typeof u.length=="number"),u.length<=0)return this.words=[0],this.length=1,this;this.length=Math.ceil(u.length/3),this.words=new Array(this.length);for(var v=0;v<this.length;v++)this.words[v]=0;var b,E,O=0;if(p==="be")for(v=u.length-1,b=0;v>=0;v-=3)E=u[v]|u[v-1]<<8|u[v-2]<<16,this.words[b]|=E<<O&67108863,this.words[b+1]=E>>>26-O&67108863,O+=24,O>=26&&(O-=26,b++);else if(p==="le")for(v=0,b=0;v<u.length;v+=3)E=u[v]|u[v+1]<<8|u[v+2]<<16,this.words[b]|=E<<O&67108863,this.words[b+1]=E>>>26-O&67108863,O+=24,O>=26&&(O-=26,b++);return this.strip()};function s(A,u){var l=A.charCodeAt(u);return l>=65&&l<=70?l-55:l>=97&&l<=102?l-87:l-48&15}function a(A,u,l){var p=s(A,l);return l-1>=u&&(p|=s(A,l-1)<<4),p}i.prototype._parseHex=function(u,l,p){this.length=Math.ceil((u.length-l)/6),this.words=new Array(this.length);for(var v=0;v<this.length;v++)this.words[v]=0;var b=0,E=0,O;if(p==="be")for(v=u.length-1;v>=l;v-=2)O=a(u,l,v)<<b,this.words[E]|=O&67108863,b>=18?(b-=18,E+=1,this.words[E]|=O>>>26):b+=8;else{var w=u.length-l;for(v=w%2===0?l+1:l;v<u.length;v+=2)O=a(u,l,v)<<b,this.words[E]|=O&67108863,b>=18?(b-=18,E+=1,this.words[E]|=O>>>26):b+=8}this.strip()};function c(A,u,l,p){for(var v=0,b=Math.min(A.length,l),E=u;E<b;E++){var O=A.charCodeAt(E)-48;v*=p,O>=49?v+=O-49+10:O>=17?v+=O-17+10:v+=O}return v}i.prototype._parseBase=function(u,l,p){this.words=[0],this.length=1;for(var v=0,b=1;b<=67108863;b*=l)v++;v--,b=b/l|0;for(var E=u.length-p,O=E%v,w=Math.min(E,E-O)+p,f=0,S=p;S<w;S+=v)f=c(u,S,S+v,l),this.imuln(b),this.words[0]+f<67108864?this.words[0]+=f:this._iaddn(f);if(O!==0){var j=1;for(f=c(u,S,u.length,l),S=0;S<O;S++)j*=l;this.imuln(j),this.words[0]+f<67108864?this.words[0]+=f:this._iaddn(f)}this.strip()},i.prototype.copy=function(u){u.words=new Array(this.length);for(var l=0;l<this.length;l++)u.words[l]=this.words[l];u.length=this.length,u.negative=this.negative,u.red=this.red},i.prototype.clone=function(){var u=new i(null);return this.copy(u),u},i.prototype._expand=function(u){for(;this.length<u;)this.words[this.length++]=0;return this},i.prototype.strip=function(){for(;this.length>1&&this.words[this.length-1]===0;)this.length--;return this._normSign()},i.prototype._normSign=function(){return this.length===1&&this.words[0]===0&&(this.negative=0),this},i.prototype.inspect=function(){return(this.red?"<BN-R: ":"<BN: ")+this.toString(16)+">"};var h=["","0","00","000","0000","00000","000000","0000000","00000000","000000000","0000000000","00000000000","000000000000","0000000000000","00000000000000","000000000000000","0000000000000000","00000000000000000","000000000000000000","0000000000000000000","00000000000000000000","000000000000000000000","0000000000000000000000","00000000000000000000000","000000000000000000000000","0000000000000000000000000"],g=[0,0,25,16,12,11,10,9,8,8,7,7,7,7,6,6,6,6,6,6,6,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5],m=[0,0,33554432,43046721,16777216,48828125,60466176,40353607,16777216,43046721,1e7,19487171,35831808,62748517,7529536,11390625,16777216,24137569,34012224,47045881,64e6,4084101,5153632,6436343,7962624,9765625,11881376,14348907,17210368,20511149,243e5,28629151,33554432,39135393,45435424,52521875,60466176];i.prototype.toString=function(u,l){u=u||10,l=l|0||1;var p;if(u===16||u==="hex"){p="";for(var v=0,b=0,E=0;E<this.length;E++){var O=this.words[E],w=((O<<v|b)&16777215).toString(16);b=O>>>24-v&16777215,v+=2,v>=26&&(v-=26,E--),b!==0||E!==this.length-1?p=h[6-w.length]+w+p:p=w+p}for(b!==0&&(p=b.toString(16)+p);p.length%l!==0;)p="0"+p;return this.negative!==0&&(p="-"+p),p}if(u===(u|0)&&u>=2&&u<=36){var f=g[u],S=m[u];p="";var j=this.clone();for(j.negative=0;!j.isZero();){var F=j.modn(S).toString(u);j=j.idivn(S),j.isZero()?p=F+p:p=h[f-F.length]+F+p}for(this.isZero()&&(p="0"+p);p.length%l!==0;)p="0"+p;return this.negative!==0&&(p="-"+p),p}r(!1,"Base should be between 2 and 36")},i.prototype.toNumber=function(){var u=this.words[0];return this.length===2?u+=this.words[1]*67108864:this.length===3&&this.words[2]===1?u+=4503599627370496+this.words[1]*67108864:this.length>2&&r(!1,"Number can only safely store up to 53 bits"),this.negative!==0?-u:u},i.prototype.toJSON=function(){return this.toString(16)},i.prototype.toBuffer=function(u,l){return r(typeof o<"u"),this.toArrayLike(o,u,l)},i.prototype.toArray=function(u,l){return this.toArrayLike(Array,u,l)},i.prototype.toArrayLike=function(u,l,p){var v=this.byteLength(),b=p||Math.max(1,v);r(v<=b,"byte array longer than desired length"),r(b>0,"Requested array length <= 0"),this.strip();var E=l==="le",O=new u(b),w,f,S=this.clone();if(E){for(f=0;!S.isZero();f++)w=S.andln(255),S.iushrn(8),O[f]=w;for(;f<b;f++)O[f]=0}else{for(f=0;f<b-v;f++)O[f]=0;for(f=0;!S.isZero();f++)w=S.andln(255),S.iushrn(8),O[b-f-1]=w}return O},Math.clz32?i.prototype._countBits=function(u){return 32-Math.clz32(u)}:i.prototype._countBits=function(u){var l=u,p=0;return l>=4096&&(p+=13,l>>>=13),l>=64&&(p+=7,l>>>=7),l>=8&&(p+=4,l>>>=4),l>=2&&(p+=2,l>>>=2),p+l},i.prototype._zeroBits=function(u){if(u===0)return 26;var l=u,p=0;return(l&8191)===0&&(p+=13,l>>>=13),(l&127)===0&&(p+=7,l>>>=7),(l&15)===0&&(p+=4,l>>>=4),(l&3)===0&&(p+=2,l>>>=2),(l&1)===0&&p++,p},i.prototype.bitLength=function(){var u=this.words[this.length-1],l=this._countBits(u);return(this.length-1)*26+l};function _(A){for(var u=new Array(A.bitLength()),l=0;l<u.length;l++){var p=l/26|0,v=l%26;u[l]=(A.words[p]&1<<v)>>>v}return u}i.prototype.zeroBits=function(){if(this.isZero())return 0;for(var u=0,l=0;l<this.length;l++){var p=this._zeroBits(this.words[l]);if(u+=p,p!==26)break}return u},i.prototype.byteLength=function(){return Math.ceil(this.bitLength()/8)},i.prototype.toTwos=function(u){return this.negative!==0?this.abs().inotn(u).iaddn(1):this.clone()},i.prototype.fromTwos=function(u){return this.testn(u-1)?this.notn(u).iaddn(1).ineg():this.clone()},i.prototype.isNeg=function(){return this.negative!==0},i.prototype.neg=function(){return this.clone().ineg()},i.prototype.ineg=function(){return this.isZero()||(this.negative^=1),this},i.prototype.iuor=function(u){for(;this.length<u.length;)this.words[this.length++]=0;for(var l=0;l<u.length;l++)this.words[l]=this.words[l]|u.words[l];return this.strip()},i.prototype.ior=function(u){return r((this.negative|u.negative)===0),this.iuor(u)},i.prototype.or=function(u){return this.length>u.length?this.clone().ior(u):u.clone().ior(this)},i.prototype.uor=function(u){return this.length>u.length?this.clone().iuor(u):u.clone().iuor(this)},i.prototype.iuand=function(u){var l;this.length>u.length?l=u:l=this;for(var p=0;p<l.length;p++)this.words[p]=this.words[p]&u.words[p];return this.length=l.length,this.strip()},i.prototype.iand=function(u){return r((this.negative|u.negative)===0),this.iuand(u)},i.prototype.and=function(u){return this.length>u.length?this.clone().iand(u):u.clone().iand(this)},i.prototype.uand=function(u){return this.length>u.length?this.clone().iuand(u):u.clone().iuand(this)},i.prototype.iuxor=function(u){var l,p;this.length>u.length?(l=this,p=u):(l=u,p=this);for(var v=0;v<p.length;v++)this.words[v]=l.words[v]^p.words[v];if(this!==l)for(;v<l.length;v++)this.words[v]=l.words[v];return this.length=l.length,this.strip()},i.prototype.ixor=function(u){return r((this.negative|u.negative)===0),this.iuxor(u)},i.prototype.xor=function(u){return this.length>u.length?this.clone().ixor(u):u.clone().ixor(this)},i.prototype.uxor=function(u){return this.length>u.length?this.clone().iuxor(u):u.clone().iuxor(this)},i.prototype.inotn=function(u){r(typeof u=="number"&&u>=0);var l=Math.ceil(u/26)|0,p=u%26;this._expand(l),p>0&&l--;for(var v=0;v<l;v++)this.words[v]=~this.words[v]&67108863;for(p>0&&(this.words[v]=~this.words[v]&67108863>>26-p,v++);v<this.length;v++)this.words[v]=0;return this.strip()},i.prototype.notn=function(u){return this.clone().inotn(u)},i.prototype.setn=function(u,l){r(typeof u=="number"&&u>=0);var p=u/26|0,v=u%26;return this._expand(p+1),l?this.words[p]=this.words[p]|1<<v:this.words[p]=this.words[p]&~(1<<v),this.strip()},i.prototype.iadd=function(u){var l;if(this.negative!==0&&u.negative===0)return this.negative=0,l=this.isub(u),this.negative^=1,this._normSign();if(this.negative===0&&u.negative!==0)return u.negative=0,l=this.isub(u),u.negative=1,l._normSign();var p,v;this.length>u.length?(p=this,v=u):(p=u,v=this);for(var b=0,E=0;E<v.length;E++)l=(p.words[E]|0)+(v.words[E]|0)+b,this.words[E]=l&67108863,b=l>>>26;for(;b!==0&&E<p.length;E++)l=(p.words[E]|0)+b,this.words[E]=l&67108863,b=l>>>26;if(this.length=p.length,b!==0)this.words[this.length]=b,this.length++;else if(p!==this)for(;E<p.length;E++)this.words[E]=p.words[E];return this},i.prototype.add=function(u){var l;return u.negative!==0&&this.negative===0?(u.negative=0,l=this.sub(u),u.negative^=1,l):u.negative===0&&this.negative!==0?(this.negative=0,l=u.sub(this),this.negative=1,l):this.length>u.length?this.clone().iadd(u):u.clone().iadd(this)},i.prototype.isub=function(u){if(u.negative!==0){u.negative=0;var l=this.iadd(u);return u.negative=1,l._normSign()}else if(this.negative!==0)return this.negative=0,this.iadd(u),this.negative=1,this._normSign();var p=this.cmp(u);if(p===0)return this.negative=0,this.length=1,this.words[0]=0,this;var v,b;p>0?(v=this,b=u):(v=u,b=this);for(var E=0,O=0;O<b.length;O++)l=(v.words[O]|0)-(b.words[O]|0)+E,E=l>>26,this.words[O]=l&67108863;for(;E!==0&&O<v.length;O++)l=(v.words[O]|0)+E,E=l>>26,this.words[O]=l&67108863;if(E===0&&O<v.length&&v!==this)for(;O<v.length;O++)this.words[O]=v.words[O];return this.length=Math.max(this.length,O),v!==this&&(this.negative=1),this.strip()},i.prototype.sub=function(u){return this.clone().isub(u)};function I(A,u,l){l.negative=u.negative^A.negative;var p=A.length+u.length|0;l.length=p,p=p-1|0;var v=A.words[0]|0,b=u.words[0]|0,E=v*b,O=E&67108863,w=E/67108864|0;l.words[0]=O;for(var f=1;f<p;f++){for(var S=w>>>26,j=w&67108863,F=Math.min(f,u.length-1),Y=Math.max(0,f-A.length+1);Y<=F;Y++){var $=f-Y|0;v=A.words[$]|0,b=u.words[Y]|0,E=v*b+j,S+=E/67108864|0,j=E&67108863}l.words[f]=j|0,w=S|0}return w!==0?l.words[f]=w|0:l.length--,l.strip()}var R=function(u,l,p){var v=u.words,b=l.words,E=p.words,O=0,w,f,S,j=v[0]|0,F=j&8191,Y=j>>>13,$=v[1]|0,J=$&8191,ae=$>>>13,ye=v[2]|0,he=ye&8191,T=ye>>>13,k=v[3]|0,H=k&8191,V=k>>>13,ne=v[4]|0,Q=ne&8191,ee=ne>>>13,pe=v[5]|0,ie=pe&8191,fe=pe>>>13,ze=v[6]|0,Oe=ze&8191,te=ze>>>13,ve=v[7]|0,be=ve&8191,we=ve>>>13,pn=v[8]|0,Ye=pn&8191,je=pn>>>13,$a=v[9]|0,Ze=$a&8191,rt=$a>>>13,Kp=b[0]|0,nt=Kp&8191,it=Kp>>>13,Vp=b[1]|0,ot=Vp&8191,st=Vp>>>13,Gp=b[2]|0,at=Gp&8191,ut=Gp>>>13,Wp=b[3]|0,ft=Wp&8191,ct=Wp>>>13,zp=b[4]|0,lt=zp&8191,ht=zp>>>13,Yp=b[5]|0,dt=Yp&8191,pt=Yp>>>13,$p=b[6]|0,gt=$p&8191,yt=$p>>>13,Zp=b[7]|0,mt=Zp&8191,vt=Zp>>>13,Xp=b[8]|0,bt=Xp&8191,_t=Xp>>>13,Jp=b[9]|0,wt=Jp&8191,St=Jp>>>13;p.negative=u.negative^l.negative,p.length=19,w=Math.imul(F,nt),f=Math.imul(F,it),f=f+Math.imul(Y,nt)|0,S=Math.imul(Y,it);var jc=(O+w|0)+((f&8191)<<13)|0;O=(S+(f>>>13)|0)+(jc>>>26)|0,jc&=67108863,w=Math.imul(J,nt),f=Math.imul(J,it),f=f+Math.imul(ae,nt)|0,S=Math.imul(ae,it),w=w+Math.imul(F,ot)|0,f=f+Math.imul(F,st)|0,f=f+Math.imul(Y,ot)|0,S=S+Math.imul(Y,st)|0;var Kc=(O+w|0)+((f&8191)<<13)|0;O=(S+(f>>>13)|0)+(Kc>>>26)|0,Kc&=67108863,w=Math.imul(he,nt),f=Math.imul(he,it),f=f+Math.imul(T,nt)|0,S=Math.imul(T,it),w=w+Math.imul(J,ot)|0,f=f+Math.imul(J,st)|0,f=f+Math.imul(ae,ot)|0,S=S+Math.imul(ae,st)|0,w=w+Math.imul(F,at)|0,f=f+Math.imul(F,ut)|0,f=f+Math.imul(Y,at)|0,S=S+Math.imul(Y,ut)|0;var Vc=(O+w|0)+((f&8191)<<13)|0;O=(S+(f>>>13)|0)+(Vc>>>26)|0,Vc&=67108863,w=Math.imul(H,nt),f=Math.imul(H,it),f=f+Math.imul(V,nt)|0,S=Math.imul(V,it),w=w+Math.imul(he,ot)|0,f=f+Math.imul(he,st)|0,f=f+Math.imul(T,ot)|0,S=S+Math.imul(T,st)|0,w=w+Math.imul(J,at)|0,f=f+Math.imul(J,ut)|0,f=f+Math.imul(ae,at)|0,S=S+Math.imul(ae,ut)|0,w=w+Math.imul(F,ft)|0,f=f+Math.imul(F,ct)|0,f=f+Math.imul(Y,ft)|0,S=S+Math.imul(Y,ct)|0;var Gc=(O+w|0)+((f&8191)<<13)|0;O=(S+(f>>>13)|0)+(Gc>>>26)|0,Gc&=67108863,w=Math.imul(Q,nt),f=Math.imul(Q,it),f=f+Math.imul(ee,nt)|0,S=Math.imul(ee,it),w=w+Math.imul(H,ot)|0,f=f+Math.imul(H,st)|0,f=f+Math.imul(V,ot)|0,S=S+Math.imul(V,st)|0,w=w+Math.imul(he,at)|0,f=f+Math.imul(he,ut)|0,f=f+Math.imul(T,at)|0,S=S+Math.imul(T,ut)|0,w=w+Math.imul(J,ft)|0,f=f+Math.imul(J,ct)|0,f=f+Math.imul(ae,ft)|0,S=S+Math.imul(ae,ct)|0,w=w+Math.imul(F,lt)|0,f=f+Math.imul(F,ht)|0,f=f+Math.imul(Y,lt)|0,S=S+Math.imul(Y,ht)|0;var Wc=(O+w|0)+((f&8191)<<13)|0;O=(S+(f>>>13)|0)+(Wc>>>26)|0,Wc&=67108863,w=Math.imul(ie,nt),f=Math.imul(ie,it),f=f+Math.imul(fe,nt)|0,S=Math.imul(fe,it),w=w+Math.imul(Q,ot)|0,f=f+Math.imul(Q,st)|0,f=f+Math.imul(ee,ot)|0,S=S+Math.imul(ee,st)|0,w=w+Math.imul(H,at)|0,f=f+Math.imul(H,ut)|0,f=f+Math.imul(V,at)|0,S=S+Math.imul(V,ut)|0,w=w+Math.imul(he,ft)|0,f=f+Math.imul(he,ct)|0,f=f+Math.imul(T,ft)|0,S=S+Math.imul(T,ct)|0,w=w+Math.imul(J,lt)|0,f=f+Math.imul(J,ht)|0,f=f+Math.imul(ae,lt)|0,S=S+Math.imul(ae,ht)|0,w=w+Math.imul(F,dt)|0,f=f+Math.imul(F,pt)|0,f=f+Math.imul(Y,dt)|0,S=S+Math.imul(Y,pt)|0;var zc=(O+w|0)+((f&8191)<<13)|0;O=(S+(f>>>13)|0)+(zc>>>26)|0,zc&=67108863,w=Math.imul(Oe,nt),f=Math.imul(Oe,it),f=f+Math.imul(te,nt)|0,S=Math.imul(te,it),w=w+Math.imul(ie,ot)|0,f=f+Math.imul(ie,st)|0,f=f+Math.imul(fe,ot)|0,S=S+Math.imul(fe,st)|0,w=w+Math.imul(Q,at)|0,f=f+Math.imul(Q,ut)|0,f=f+Math.imul(ee,at)|0,S=S+Math.imul(ee,ut)|0,w=w+Math.imul(H,ft)|0,f=f+Math.imul(H,ct)|0,f=f+Math.imul(V,ft)|0,S=S+Math.imul(V,ct)|0,w=w+Math.imul(he,lt)|0,f=f+Math.imul(he,ht)|0,f=f+Math.imul(T,lt)|0,S=S+Math.imul(T,ht)|0,w=w+Math.imul(J,dt)|0,f=f+Math.imul(J,pt)|0,f=f+Math.imul(ae,dt)|0,S=S+Math.imul(ae,pt)|0,w=w+Math.imul(F,gt)|0,f=f+Math.imul(F,yt)|0,f=f+Math.imul(Y,gt)|0,S=S+Math.imul(Y,yt)|0;var Yc=(O+w|0)+((f&8191)<<13)|0;O=(S+(f>>>13)|0)+(Yc>>>26)|0,Yc&=67108863,w=Math.imul(be,nt),f=Math.imul(be,it),f=f+Math.imul(we,nt)|0,S=Math.imul(we,it),w=w+Math.imul(Oe,ot)|0,f=f+Math.imul(Oe,st)|0,f=f+Math.imul(te,ot)|0,S=S+Math.imul(te,st)|0,w=w+Math.imul(ie,at)|0,f=f+Math.imul(ie,ut)|0,f=f+Math.imul(fe,at)|0,S=S+Math.imul(fe,ut)|0,w=w+Math.imul(Q,ft)|0,f=f+Math.imul(Q,ct)|0,f=f+Math.imul(ee,ft)|0,S=S+Math.imul(ee,ct)|0,w=w+Math.imul(H,lt)|0,f=f+Math.imul(H,ht)|0,f=f+Math.imul(V,lt)|0,S=S+Math.imul(V,ht)|0,w=w+Math.imul(he,dt)|0,f=f+Math.imul(he,pt)|0,f=f+Math.imul(T,dt)|0,S=S+Math.imul(T,pt)|0,w=w+Math.imul(J,gt)|0,f=f+Math.imul(J,yt)|0,f=f+Math.imul(ae,gt)|0,S=S+Math.imul(ae,yt)|0,w=w+Math.imul(F,mt)|0,f=f+Math.imul(F,vt)|0,f=f+Math.imul(Y,mt)|0,S=S+Math.imul(Y,vt)|0;var $c=(O+w|0)+((f&8191)<<13)|0;O=(S+(f>>>13)|0)+($c>>>26)|0,$c&=67108863,w=Math.imul(Ye,nt),f=Math.imul(Ye,it),f=f+Math.imul(je,nt)|0,S=Math.imul(je,it),w=w+Math.imul(be,ot)|0,f=f+Math.imul(be,st)|0,f=f+Math.imul(we,ot)|0,S=S+Math.imul(we,st)|0,w=w+Math.imul(Oe,at)|0,f=f+Math.imul(Oe,ut)|0,f=f+Math.imul(te,at)|0,S=S+Math.imul(te,ut)|0,w=w+Math.imul(ie,ft)|0,f=f+Math.imul(ie,ct)|0,f=f+Math.imul(fe,ft)|0,S=S+Math.imul(fe,ct)|0,w=w+Math.imul(Q,lt)|0,f=f+Math.imul(Q,ht)|0,f=f+Math.imul(ee,lt)|0,S=S+Math.imul(ee,ht)|0,w=w+Math.imul(H,dt)|0,f=f+Math.imul(H,pt)|0,f=f+Math.imul(V,dt)|0,S=S+Math.imul(V,pt)|0,w=w+Math.imul(he,gt)|0,f=f+Math.imul(he,yt)|0,f=f+Math.imul(T,gt)|0,S=S+Math.imul(T,yt)|0,w=w+Math.imul(J,mt)|0,f=f+Math.imul(J,vt)|0,f=f+Math.imul(ae,mt)|0,S=S+Math.imul(ae,vt)|0,w=w+Math.imul(F,bt)|0,f=f+Math.imul(F,_t)|0,f=f+Math.imul(Y,bt)|0,S=S+Math.imul(Y,_t)|0;var Zc=(O+w|0)+((f&8191)<<13)|0;O=(S+(f>>>13)|0)+(Zc>>>26)|0,Zc&=67108863,w=Math.imul(Ze,nt),f=Math.imul(Ze,it),f=f+Math.imul(rt,nt)|0,S=Math.imul(rt,it),w=w+Math.imul(Ye,ot)|0,f=f+Math.imul(Ye,st)|0,f=f+Math.imul(je,ot)|0,S=S+Math.imul(je,st)|0,w=w+Math.imul(be,at)|0,f=f+Math.imul(be,ut)|0,f=f+Math.imul(we,at)|0,S=S+Math.imul(we,ut)|0,w=w+Math.imul(Oe,ft)|0,f=f+Math.imul(Oe,ct)|0,f=f+Math.imul(te,ft)|0,S=S+Math.imul(te,ct)|0,w=w+Math.imul(ie,lt)|0,f=f+Math.imul(ie,ht)|0,f=f+Math.imul(fe,lt)|0,S=S+Math.imul(fe,ht)|0,w=w+Math.imul(Q,dt)|0,f=f+Math.imul(Q,pt)|0,f=f+Math.imul(ee,dt)|0,S=S+Math.imul(ee,pt)|0,w=w+Math.imul(H,gt)|0,f=f+Math.imul(H,yt)|0,f=f+Math.imul(V,gt)|0,S=S+Math.imul(V,yt)|0,w=w+Math.imul(he,mt)|0,f=f+Math.imul(he,vt)|0,f=f+Math.imul(T,mt)|0,S=S+Math.imul(T,vt)|0,w=w+Math.imul(J,bt)|0,f=f+Math.imul(J,_t)|0,f=f+Math.imul(ae,bt)|0,S=S+Math.imul(ae,_t)|0,w=w+Math.imul(F,wt)|0,f=f+Math.imul(F,St)|0,f=f+Math.imul(Y,wt)|0,S=S+Math.imul(Y,St)|0;var Xc=(O+w|0)+((f&8191)<<13)|0;O=(S+(f>>>13)|0)+(Xc>>>26)|0,Xc&=67108863,w=Math.imul(Ze,ot),f=Math.imul(Ze,st),f=f+Math.imul(rt,ot)|0,S=Math.imul(rt,st),w=w+Math.imul(Ye,at)|0,f=f+Math.imul(Ye,ut)|0,f=f+Math.imul(je,at)|0,S=S+Math.imul(je,ut)|0,w=w+Math.imul(be,ft)|0,f=f+Math.imul(be,ct)|0,f=f+Math.imul(we,ft)|0,S=S+Math.imul(we,ct)|0,w=w+Math.imul(Oe,lt)|0,f=f+Math.imul(Oe,ht)|0,f=f+Math.imul(te,lt)|0,S=S+Math.imul(te,ht)|0,w=w+Math.imul(ie,dt)|0,f=f+Math.imul(ie,pt)|0,f=f+Math.imul(fe,dt)|0,S=S+Math.imul(fe,pt)|0,w=w+Math.imul(Q,gt)|0,f=f+Math.imul(Q,yt)|0,f=f+Math.imul(ee,gt)|0,S=S+Math.imul(ee,yt)|0,w=w+Math.imul(H,mt)|0,f=f+Math.imul(H,vt)|0,f=f+Math.imul(V,mt)|0,S=S+Math.imul(V,vt)|0,w=w+Math.imul(he,bt)|0,f=f+Math.imul(he,_t)|0,f=f+Math.imul(T,bt)|0,S=S+Math.imul(T,_t)|0,w=w+Math.imul(J,wt)|0,f=f+Math.imul(J,St)|0,f=f+Math.imul(ae,wt)|0,S=S+Math.imul(ae,St)|0;var Jc=(O+w|0)+((f&8191)<<13)|0;O=(S+(f>>>13)|0)+(Jc>>>26)|0,Jc&=67108863,w=Math.imul(Ze,at),f=Math.imul(Ze,ut),f=f+Math.imul(rt,at)|0,S=Math.imul(rt,ut),w=w+Math.imul(Ye,ft)|0,f=f+Math.imul(Ye,ct)|0,f=f+Math.imul(je,ft)|0,S=S+Math.imul(je,ct)|0,w=w+Math.imul(be,lt)|0,f=f+Math.imul(be,ht)|0,f=f+Math.imul(we,lt)|0,S=S+Math.imul(we,ht)|0,w=w+Math.imul(Oe,dt)|0,f=f+Math.imul(Oe,pt)|0,f=f+Math.imul(te,dt)|0,S=S+Math.imul(te,pt)|0,w=w+Math.imul(ie,gt)|0,f=f+Math.imul(ie,yt)|0,f=f+Math.imul(fe,gt)|0,S=S+Math.imul(fe,yt)|0,w=w+Math.imul(Q,mt)|0,f=f+Math.imul(Q,vt)|0,f=f+Math.imul(ee,mt)|0,S=S+Math.imul(ee,vt)|0,w=w+Math.imul(H,bt)|0,f=f+Math.imul(H,_t)|0,f=f+Math.imul(V,bt)|0,S=S+Math.imul(V,_t)|0,w=w+Math.imul(he,wt)|0,f=f+Math.imul(he,St)|0,f=f+Math.imul(T,wt)|0,S=S+Math.imul(T,St)|0;var Qc=(O+w|0)+((f&8191)<<13)|0;O=(S+(f>>>13)|0)+(Qc>>>26)|0,Qc&=67108863,w=Math.imul(Ze,ft),f=Math.imul(Ze,ct),f=f+Math.imul(rt,ft)|0,S=Math.imul(rt,ct),w=w+Math.imul(Ye,lt)|0,f=f+Math.imul(Ye,ht)|0,f=f+Math.imul(je,lt)|0,S=S+Math.imul(je,ht)|0,w=w+Math.imul(be,dt)|0,f=f+Math.imul(be,pt)|0,f=f+Math.imul(we,dt)|0,S=S+Math.imul(we,pt)|0,w=w+Math.imul(Oe,gt)|0,f=f+Math.imul(Oe,yt)|0,f=f+Math.imul(te,gt)|0,S=S+Math.imul(te,yt)|0,w=w+Math.imul(ie,mt)|0,f=f+Math.imul(ie,vt)|0,f=f+Math.imul(fe,mt)|0,S=S+Math.imul(fe,vt)|0,w=w+Math.imul(Q,bt)|0,f=f+Math.imul(Q,_t)|0,f=f+Math.imul(ee,bt)|0,S=S+Math.imul(ee,_t)|0,w=w+Math.imul(H,wt)|0,f=f+Math.imul(H,St)|0,f=f+Math.imul(V,wt)|0,S=S+Math.imul(V,St)|0;var el=(O+w|0)+((f&8191)<<13)|0;O=(S+(f>>>13)|0)+(el>>>26)|0,el&=67108863,w=Math.imul(Ze,lt),f=Math.imul(Ze,ht),f=f+Math.imul(rt,lt)|0,S=Math.imul(rt,ht),w=w+Math.imul(Ye,dt)|0,f=f+Math.imul(Ye,pt)|0,f=f+Math.imul(je,dt)|0,S=S+Math.imul(je,pt)|0,w=w+Math.imul(be,gt)|0,f=f+Math.imul(be,yt)|0,f=f+Math.imul(we,gt)|0,S=S+Math.imul(we,yt)|0,w=w+Math.imul(Oe,mt)|0,f=f+Math.imul(Oe,vt)|0,f=f+Math.imul(te,mt)|0,S=S+Math.imul(te,vt)|0,w=w+Math.imul(ie,bt)|0,f=f+Math.imul(ie,_t)|0,f=f+Math.imul(fe,bt)|0,S=S+Math.imul(fe,_t)|0,w=w+Math.imul(Q,wt)|0,f=f+Math.imul(Q,St)|0,f=f+Math.imul(ee,wt)|0,S=S+Math.imul(ee,St)|0;var tl=(O+w|0)+((f&8191)<<13)|0;O=(S+(f>>>13)|0)+(tl>>>26)|0,tl&=67108863,w=Math.imul(Ze,dt),f=Math.imul(Ze,pt),f=f+Math.imul(rt,dt)|0,S=Math.imul(rt,pt),w=w+Math.imul(Ye,gt)|0,f=f+Math.imul(Ye,yt)|0,f=f+Math.imul(je,gt)|0,S=S+Math.imul(je,yt)|0,w=w+Math.imul(be,mt)|0,f=f+Math.imul(be,vt)|0,f=f+Math.imul(we,mt)|0,S=S+Math.imul(we,vt)|0,w=w+Math.imul(Oe,bt)|0,f=f+Math.imul(Oe,_t)|0,f=f+Math.imul(te,bt)|0,S=S+Math.imul(te,_t)|0,w=w+Math.imul(ie,wt)|0,f=f+Math.imul(ie,St)|0,f=f+Math.imul(fe,wt)|0,S=S+Math.imul(fe,St)|0;var rl=(O+w|0)+((f&8191)<<13)|0;O=(S+(f>>>13)|0)+(rl>>>26)|0,rl&=67108863,w=Math.imul(Ze,gt),f=Math.imul(Ze,yt),f=f+Math.imul(rt,gt)|0,S=Math.imul(rt,yt),w=w+Math.imul(Ye,mt)|0,f=f+Math.imul(Ye,vt)|0,f=f+Math.imul(je,mt)|0,S=S+Math.imul(je,vt)|0,w=w+Math.imul(be,bt)|0,f=f+Math.imul(be,_t)|0,f=f+Math.imul(we,bt)|0,S=S+Math.imul(we,_t)|0,w=w+Math.imul(Oe,wt)|0,f=f+Math.imul(Oe,St)|0,f=f+Math.imul(te,wt)|0,S=S+Math.imul(te,St)|0;var nl=(O+w|0)+((f&8191)<<13)|0;O=(S+(f>>>13)|0)+(nl>>>26)|0,nl&=67108863,w=Math.imul(Ze,mt),f=Math.imul(Ze,vt),f=f+Math.imul(rt,mt)|0,S=Math.imul(rt,vt),w=w+Math.imul(Ye,bt)|0,f=f+Math.imul(Ye,_t)|0,f=f+Math.imul(je,bt)|0,S=S+Math.imul(je,_t)|0,w=w+Math.imul(be,wt)|0,f=f+Math.imul(be,St)|0,f=f+Math.imul(we,wt)|0,S=S+Math.imul(we,St)|0;var il=(O+w|0)+((f&8191)<<13)|0;O=(S+(f>>>13)|0)+(il>>>26)|0,il&=67108863,w=Math.imul(Ze,bt),f=Math.imul(Ze,_t),f=f+Math.imul(rt,bt)|0,S=Math.imul(rt,_t),w=w+Math.imul(Ye,wt)|0,f=f+Math.imul(Ye,St)|0,f=f+Math.imul(je,wt)|0,S=S+Math.imul(je,St)|0;var ol=(O+w|0)+((f&8191)<<13)|0;O=(S+(f>>>13)|0)+(ol>>>26)|0,ol&=67108863,w=Math.imul(Ze,wt),f=Math.imul(Ze,St),f=f+Math.imul(rt,wt)|0,S=Math.imul(rt,St);var sl=(O+w|0)+((f&8191)<<13)|0;return O=(S+(f>>>13)|0)+(sl>>>26)|0,sl&=67108863,E[0]=jc,E[1]=Kc,E[2]=Vc,E[3]=Gc,E[4]=Wc,E[5]=zc,E[6]=Yc,E[7]=$c,E[8]=Zc,E[9]=Xc,E[10]=Jc,E[11]=Qc,E[12]=el,E[13]=tl,E[14]=rl,E[15]=nl,E[16]=il,E[17]=ol,E[18]=sl,O!==0&&(E[19]=O,p.length++),p};Math.imul||(R=I);function N(A,u,l){l.negative=u.negative^A.negative,l.length=A.length+u.length;for(var p=0,v=0,b=0;b<l.length-1;b++){var E=v;v=0;for(var O=p&67108863,w=Math.min(b,u.length-1),f=Math.max(0,b-A.length+1);f<=w;f++){var S=b-f,j=A.words[S]|0,F=u.words[f]|0,Y=j*F,$=Y&67108863;E=E+(Y/67108864|0)|0,$=$+O|0,O=$&67108863,E=E+($>>>26)|0,v+=E>>>26,E&=67108863}l.words[b]=O,p=E,E=v}return p!==0?l.words[b]=p:l.length--,l.strip()}function L(A,u,l){var p=new q;return p.mulp(A,u,l)}i.prototype.mulTo=function(u,l){var p,v=this.length+u.length;return this.length===10&&u.length===10?p=R(this,u,l):v<63?p=I(this,u,l):v<1024?p=N(this,u,l):p=L(this,u,l),p};function q(A,u){this.x=A,this.y=u}q.prototype.makeRBT=function(u){for(var l=new Array(u),p=i.prototype._countBits(u)-1,v=0;v<u;v++)l[v]=this.revBin(v,p,u);return l},q.prototype.revBin=function(u,l,p){if(u===0||u===p-1)return u;for(var v=0,b=0;b<l;b++)v|=(u&1)<<l-b-1,u>>=1;return v},q.prototype.permute=function(u,l,p,v,b,E){for(var O=0;O<E;O++)v[O]=l[u[O]],b[O]=p[u[O]]},q.prototype.transform=function(u,l,p,v,b,E){this.permute(E,u,l,p,v,b);for(var O=1;O<b;O<<=1)for(var w=O<<1,f=Math.cos(2*Math.PI/w),S=Math.sin(2*Math.PI/w),j=0;j<b;j+=w)for(var F=f,Y=S,$=0;$<O;$++){var J=p[j+$],ae=v[j+$],ye=p[j+$+O],he=v[j+$+O],T=F*ye-Y*he;he=F*he+Y*ye,ye=T,p[j+$]=J+ye,v[j+$]=ae+he,p[j+$+O]=J-ye,v[j+$+O]=ae-he,$!==w&&(T=f*F-S*Y,Y=f*Y+S*F,F=T)}},q.prototype.guessLen13b=function(u,l){var p=Math.max(l,u)|1,v=p&1,b=0;for(p=p/2|0;p;p=p>>>1)b++;return 1<<b+1+v},q.prototype.conjugate=function(u,l,p){if(!(p<=1))for(var v=0;v<p/2;v++){var b=u[v];u[v]=u[p-v-1],u[p-v-1]=b,b=l[v],l[v]=-l[p-v-1],l[p-v-1]=-b}},q.prototype.normalize13b=function(u,l){for(var p=0,v=0;v<l/2;v++){var b=Math.round(u[2*v+1]/l)*8192+Math.round(u[2*v]/l)+p;u[v]=b&67108863,b<67108864?p=0:p=b/67108864|0}return u},q.prototype.convert13b=function(u,l,p,v){for(var b=0,E=0;E<l;E++)b=b+(u[E]|0),p[2*E]=b&8191,b=b>>>13,p[2*E+1]=b&8191,b=b>>>13;for(E=2*l;E<v;++E)p[E]=0;r(b===0),r((b&-8192)===0)},q.prototype.stub=function(u){for(var l=new Array(u),p=0;p<u;p++)l[p]=0;return l},q.prototype.mulp=function(u,l,p){var v=2*this.guessLen13b(u.length,l.length),b=this.makeRBT(v),E=this.stub(v),O=new Array(v),w=new Array(v),f=new Array(v),S=new Array(v),j=new Array(v),F=new Array(v),Y=p.words;Y.length=v,this.convert13b(u.words,u.length,O,v),this.convert13b(l.words,l.length,S,v),this.transform(O,E,w,f,v,b),this.transform(S,E,j,F,v,b);for(var $=0;$<v;$++){var J=w[$]*j[$]-f[$]*F[$];f[$]=w[$]*F[$]+f[$]*j[$],w[$]=J}return this.conjugate(w,f,v),this.transform(w,f,Y,E,v,b),this.conjugate(Y,E,v),this.normalize13b(Y,v),p.negative=u.negative^l.negative,p.length=u.length+l.length,p.strip()},i.prototype.mul=function(u){var l=new i(null);return l.words=new Array(this.length+u.length),this.mulTo(u,l)},i.prototype.mulf=function(u){var l=new i(null);return l.words=new Array(this.length+u.length),L(this,u,l)},i.prototype.imul=function(u){return this.clone().mulTo(u,this)},i.prototype.imuln=function(u){r(typeof u=="number"),r(u<67108864);for(var l=0,p=0;p<this.length;p++){var v=(this.words[p]|0)*u,b=(v&67108863)+(l&67108863);l>>=26,l+=v/67108864|0,l+=b>>>26,this.words[p]=b&67108863}return l!==0&&(this.words[p]=l,this.length++),u===0&&(this.length=1,this._normSign()),this},i.prototype.muln=function(u){return this.clone().imuln(u)},i.prototype.sqr=function(){return this.mul(this)},i.prototype.isqr=function(){return this.imul(this.clone())},i.prototype.pow=function(u){var l=_(u);if(l.length===0)return new i(1);for(var p=this,v=0;v<l.length&&l[v]===0;v++,p=p.sqr());if(++v<l.length)for(var b=p.sqr();v<l.length;v++,b=b.sqr())l[v]!==0&&(p=p.mul(b));return p},i.prototype.iushln=function(u){r(typeof u=="number"&&u>=0);var l=u%26,p=(u-l)/26,v=67108863>>>26-l<<26-l,b;if(l!==0){var E=0;for(b=0;b<this.length;b++){var O=this.words[b]&v,w=(this.words[b]|0)-O<<l;this.words[b]=w|E,E=O>>>26-l}E&&(this.words[b]=E,this.length++)}if(p!==0){for(b=this.length-1;b>=0;b--)this.words[b+p]=this.words[b];for(b=0;b<p;b++)this.words[b]=0;this.length+=p}return this.strip()},i.prototype.ishln=function(u){return r(this.negative===0),this.iushln(u)},i.prototype.iushrn=function(u,l,p){r(typeof u=="number"&&u>=0);var v;l?v=(l-l%26)/26:v=0;var b=u%26,E=Math.min((u-b)/26,this.length),O=67108863^67108863>>>b<<b,w=p;if(v-=E,v=Math.max(0,v),w){for(var f=0;f<E;f++)w.words[f]=this.words[f];w.length=E}if(E!==0)if(this.length>E)for(this.length-=E,f=0;f<this.length;f++)this.words[f]=this.words[f+E];else this.words[0]=0,this.length=1;var S=0;for(f=this.length-1;f>=0&&(S!==0||f>=v);f--){var j=this.words[f]|0;this.words[f]=S<<26-b|j>>>b,S=j&O}return w&&S!==0&&(w.words[w.length++]=S),this.length===0&&(this.words[0]=0,this.length=1),this.strip()},i.prototype.ishrn=function(u,l,p){return r(this.negative===0),this.iushrn(u,l,p)},i.prototype.shln=function(u){return this.clone().ishln(u)},i.prototype.ushln=function(u){return this.clone().iushln(u)},i.prototype.shrn=function(u){return this.clone().ishrn(u)},i.prototype.ushrn=function(u){return this.clone().iushrn(u)},i.prototype.testn=function(u){r(typeof u=="number"&&u>=0);var l=u%26,p=(u-l)/26,v=1<<l;if(this.length<=p)return!1;var b=this.words[p];return!!(b&v)},i.prototype.imaskn=function(u){r(typeof u=="number"&&u>=0);var l=u%26,p=(u-l)/26;if(r(this.negative===0,"imaskn works only with positive numbers"),this.length<=p)return this;if(l!==0&&p++,this.length=Math.min(p,this.length),l!==0){var v=67108863^67108863>>>l<<l;this.words[this.length-1]&=v}return this.length===0&&(this.words[0]=0,this.length=1),this.strip()},i.prototype.maskn=function(u){return this.clone().imaskn(u)},i.prototype.iaddn=function(u){return r(typeof u=="number"),r(u<67108864),u<0?this.isubn(-u):this.negative!==0?this.length===1&&(this.words[0]|0)<u?(this.words[0]=u-(this.words[0]|0),this.negative=0,this):(this.negative=0,this.isubn(u),this.negative=1,this):this._iaddn(u)},i.prototype._iaddn=function(u){this.words[0]+=u;for(var l=0;l<this.length&&this.words[l]>=67108864;l++)this.words[l]-=67108864,l===this.length-1?this.words[l+1]=1:this.words[l+1]++;return this.length=Math.max(this.length,l+1),this},i.prototype.isubn=function(u){if(r(typeof u=="number"),r(u<67108864),u<0)return this.iaddn(-u);if(this.negative!==0)return this.negative=0,this.iaddn(u),this.negative=1,this;if(this.words[0]-=u,this.length===1&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var l=0;l<this.length&&this.words[l]<0;l++)this.words[l]+=67108864,this.words[l+1]-=1;return this.strip()},i.prototype.addn=function(u){return this.clone().iaddn(u)},i.prototype.subn=function(u){return this.clone().isubn(u)},i.prototype.iabs=function(){return this.negative=0,this},i.prototype.abs=function(){return this.clone().iabs()},i.prototype._ishlnsubmul=function(u,l,p){var v=u.length+p,b;this._expand(v);var E,O=0;for(b=0;b<u.length;b++){E=(this.words[b+p]|0)+O;var w=(u.words[b]|0)*l;E-=w&67108863,O=(E>>26)-(w/67108864|0),this.words[b+p]=E&67108863}for(;b<this.length-p;b++)E=(this.words[b+p]|0)+O,O=E>>26,this.words[b+p]=E&67108863;if(O===0)return this.strip();for(r(O===-1),O=0,b=0;b<this.length;b++)E=-(this.words[b]|0)+O,O=E>>26,this.words[b]=E&67108863;return this.negative=1,this.strip()},i.prototype._wordDiv=function(u,l){var p=this.length-u.length,v=this.clone(),b=u,E=b.words[b.length-1]|0,O=this._countBits(E);p=26-O,p!==0&&(b=b.ushln(p),v.iushln(p),E=b.words[b.length-1]|0);var w=v.length-b.length,f;if(l!=="mod"){f=new i(null),f.length=w+1,f.words=new Array(f.length);for(var S=0;S<f.length;S++)f.words[S]=0}var j=v.clone()._ishlnsubmul(b,1,w);j.negative===0&&(v=j,f&&(f.words[w]=1));for(var F=w-1;F>=0;F--){var Y=(v.words[b.length+F]|0)*67108864+(v.words[b.length+F-1]|0);for(Y=Math.min(Y/E|0,67108863),v._ishlnsubmul(b,Y,F);v.negative!==0;)Y--,v.negative=0,v._ishlnsubmul(b,1,F),v.isZero()||(v.negative^=1);f&&(f.words[F]=Y)}return f&&f.strip(),v.strip(),l!=="div"&&p!==0&&v.iushrn(p),{div:f||null,mod:v}},i.prototype.divmod=function(u,l,p){if(r(!u.isZero()),this.isZero())return{div:new i(0),mod:new i(0)};var v,b,E;return this.negative!==0&&u.negative===0?(E=this.neg().divmod(u,l),l!=="mod"&&(v=E.div.neg()),l!=="div"&&(b=E.mod.neg(),p&&b.negative!==0&&b.iadd(u)),{div:v,mod:b}):this.negative===0&&u.negative!==0?(E=this.divmod(u.neg(),l),l!=="mod"&&(v=E.div.neg()),{div:v,mod:E.mod}):(this.negative&u.negative)!==0?(E=this.neg().divmod(u.neg(),l),l!=="div"&&(b=E.mod.neg(),p&&b.negative!==0&&b.isub(u)),{div:E.div,mod:b}):u.length>this.length||this.cmp(u)<0?{div:new i(0),mod:this}:u.length===1?l==="div"?{div:this.divn(u.words[0]),mod:null}:l==="mod"?{div:null,mod:new i(this.modn(u.words[0]))}:{div:this.divn(u.words[0]),mod:new i(this.modn(u.words[0]))}:this._wordDiv(u,l)},i.prototype.div=function(u){return this.divmod(u,"div",!1).div},i.prototype.mod=function(u){return this.divmod(u,"mod",!1).mod},i.prototype.umod=function(u){return this.divmod(u,"mod",!0).mod},i.prototype.divRound=function(u){var l=this.divmod(u);if(l.mod.isZero())return l.div;var p=l.mod.abs(),v=u.abs().iushrn(1),b=u.words[0]&1,E=p.cmp(v);if(E<0||b===1&&E===0)return l.div;var O=new i(1);return O.negative=this.negative^u.negative,l.div.iadd(O)},i.prototype.modn=function(u){r(u<=67108863);for(var l=(1<<26)%u,p=0,v=this.length-1;v>=0;v--)p=(l*p+(this.words[v]|0))%u;return p},i.prototype.idivn=function(u){r(u<=67108863);for(var l=0,p=this.length-1;p>=0;p--){var v=(this.words[p]|0)+l*67108864;this.words[p]=v/u|0,l=v%u}return this.strip()},i.prototype.divn=function(u){return this.clone().idivn(u)},i.prototype.egcd=function(u){r(u.negative===0),r(!u.isZero());var l=this,p=u.clone();l.negative!==0?l=l.umod(u):l=l.clone();for(var v=new i(1),b=new i(0),E=new i(0),O=new i(1),w=0;l.isEven()&&p.isEven();)l.iushrn(1),p.iushrn(1),++w;for(var f=p.clone(),S=l.clone();!l.isZero();){for(var j=0,F=1;(l.words[0]&F)===0&&j<26;++j,F<<=1);if(j>0)for(l.iushrn(j);j-- >0;)(v.isOdd()||b.isOdd())&&(v.iadd(f),b.isub(S)),v.iushrn(1),b.iushrn(1);for(var Y=0,$=1;(p.words[0]&$)===0&&Y<26;++Y,$<<=1);if(Y>0)for(p.iushrn(Y);Y-- >0;)(E.isOdd()||O.isOdd())&&(E.iadd(f),O.isub(S)),E.iushrn(1),O.iushrn(1);l.cmp(p)>=0?(l.isub(p),v.isub(E),b.isub(O)):(p.isub(l),E.isub(v),O.isub(b))}return{a:E,b:O,gcd:p.iushln(w)}},i.prototype._invmp=function(u){r(u.negative===0),r(!u.isZero());var l=this,p=u.clone();l.negative!==0?l=l.umod(u):l=l.clone();for(var v=new i(1),b=new i(0),E=p.clone();l.cmpn(1)>0&&p.cmpn(1)>0;){for(var O=0,w=1;(l.words[0]&w)===0&&O<26;++O,w<<=1);if(O>0)for(l.iushrn(O);O-- >0;)v.isOdd()&&v.iadd(E),v.iushrn(1);for(var f=0,S=1;(p.words[0]&S)===0&&f<26;++f,S<<=1);if(f>0)for(p.iushrn(f);f-- >0;)b.isOdd()&&b.iadd(E),b.iushrn(1);l.cmp(p)>=0?(l.isub(p),v.isub(b)):(p.isub(l),b.isub(v))}var j;return l.cmpn(1)===0?j=v:j=b,j.cmpn(0)<0&&j.iadd(u),j},i.prototype.gcd=function(u){if(this.isZero())return u.abs();if(u.isZero())return this.abs();var l=this.clone(),p=u.clone();l.negative=0,p.negative=0;for(var v=0;l.isEven()&&p.isEven();v++)l.iushrn(1),p.iushrn(1);do{for(;l.isEven();)l.iushrn(1);for(;p.isEven();)p.iushrn(1);var b=l.cmp(p);if(b<0){var E=l;l=p,p=E}else if(b===0||p.cmpn(1)===0)break;l.isub(p)}while(!0);return p.iushln(v)},i.prototype.invm=function(u){return this.egcd(u).a.umod(u)},i.prototype.isEven=function(){return(this.words[0]&1)===0},i.prototype.isOdd=function(){return(this.words[0]&1)===1},i.prototype.andln=function(u){return this.words[0]&u},i.prototype.bincn=function(u){r(typeof u=="number");var l=u%26,p=(u-l)/26,v=1<<l;if(this.length<=p)return this._expand(p+1),this.words[p]|=v,this;for(var b=v,E=p;b!==0&&E<this.length;E++){var O=this.words[E]|0;O+=b,b=O>>>26,O&=67108863,this.words[E]=O}return b!==0&&(this.words[E]=b,this.length++),this},i.prototype.isZero=function(){return this.length===1&&this.words[0]===0},i.prototype.cmpn=function(u){var l=u<0;if(this.negative!==0&&!l)return-1;if(this.negative===0&&l)return 1;this.strip();var p;if(this.length>1)p=1;else{l&&(u=-u),r(u<=67108863,"Number is too big");var v=this.words[0]|0;p=v===u?0:v<u?-1:1}return this.negative!==0?-p|0:p},i.prototype.cmp=function(u){if(this.negative!==0&&u.negative===0)return-1;if(this.negative===0&&u.negative!==0)return 1;var l=this.ucmp(u);return this.negative!==0?-l|0:l},i.prototype.ucmp=function(u){if(this.length>u.length)return 1;if(this.length<u.length)return-1;for(var l=0,p=this.length-1;p>=0;p--){var v=this.words[p]|0,b=u.words[p]|0;if(v!==b){v<b?l=-1:v>b&&(l=1);break}}return l},i.prototype.gtn=function(u){return this.cmpn(u)===1},i.prototype.gt=function(u){return this.cmp(u)===1},i.prototype.gten=function(u){return this.cmpn(u)>=0},i.prototype.gte=function(u){return this.cmp(u)>=0},i.prototype.ltn=function(u){return this.cmpn(u)===-1},i.prototype.lt=function(u){return this.cmp(u)===-1},i.prototype.lten=function(u){return this.cmpn(u)<=0},i.prototype.lte=function(u){return this.cmp(u)<=0},i.prototype.eqn=function(u){return this.cmpn(u)===0},i.prototype.eq=function(u){return this.cmp(u)===0},i.red=function(u){return new se(u)},i.prototype.toRed=function(u){return r(!this.red,"Already a number in reduction context"),r(this.negative===0,"red works only with positives"),u.convertTo(this)._forceRed(u)},i.prototype.fromRed=function(){return r(this.red,"fromRed works only with numbers in reduction context"),this.red.convertFrom(this)},i.prototype._forceRed=function(u){return this.red=u,this},i.prototype.forceRed=function(u){return r(!this.red,"Already a number in reduction context"),this._forceRed(u)},i.prototype.redAdd=function(u){return r(this.red,"redAdd works only with red numbers"),this.red.add(this,u)},i.prototype.redIAdd=function(u){return r(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,u)},i.prototype.redSub=function(u){return r(this.red,"redSub works only with red numbers"),this.red.sub(this,u)},i.prototype.redISub=function(u){return r(this.red,"redISub works only with red numbers"),this.red.isub(this,u)},i.prototype.redShl=function(u){return r(this.red,"redShl works only with red numbers"),this.red.shl(this,u)},i.prototype.redMul=function(u){return r(this.red,"redMul works only with red numbers"),this.red._verify2(this,u),this.red.mul(this,u)},i.prototype.redIMul=function(u){return r(this.red,"redMul works only with red numbers"),this.red._verify2(this,u),this.red.imul(this,u)},i.prototype.redSqr=function(){return r(this.red,"redSqr works only with red numbers"),this.red._verify1(this),this.red.sqr(this)},i.prototype.redISqr=function(){return r(this.red,"redISqr works only with red numbers"),this.red._verify1(this),this.red.isqr(this)},i.prototype.redSqrt=function(){return r(this.red,"redSqrt works only with red numbers"),this.red._verify1(this),this.red.sqrt(this)},i.prototype.redInvm=function(){return r(this.red,"redInvm works only with red numbers"),this.red._verify1(this),this.red.invm(this)},i.prototype.redNeg=function(){return r(this.red,"redNeg works only with red numbers"),this.red._verify1(this),this.red.neg(this)},i.prototype.redPow=function(u){return r(this.red&&!u.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,u)};var G={k256:null,p224:null,p192:null,p25519:null};function K(A,u){this.name=A,this.p=new i(u,16),this.n=this.p.bitLength(),this.k=new i(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}K.prototype._tmp=function(){var u=new i(null);return u.words=new Array(Math.ceil(this.n/13)),u},K.prototype.ireduce=function(u){var l=u,p;do this.split(l,this.tmp),l=this.imulK(l),l=l.iadd(this.tmp),p=l.bitLength();while(p>this.n);var v=p<this.n?-1:l.ucmp(this.p);return v===0?(l.words[0]=0,l.length=1):v>0?l.isub(this.p):l.strip!==void 0?l.strip():l._strip(),l},K.prototype.split=function(u,l){u.iushrn(this.n,0,l)},K.prototype.imulK=function(u){return u.imul(this.k)};function z(){K.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}n(z,K),z.prototype.split=function(u,l){for(var p=4194303,v=Math.min(u.length,9),b=0;b<v;b++)l.words[b]=u.words[b];if(l.length=v,u.length<=9){u.words[0]=0,u.length=1;return}var E=u.words[9];for(l.words[l.length++]=E&p,b=10;b<u.length;b++){var O=u.words[b]|0;u.words[b-10]=(O&p)<<4|E>>>22,E=O}E>>>=22,u.words[b-10]=E,E===0&&u.length>10?u.length-=10:u.length-=9},z.prototype.imulK=function(u){u.words[u.length]=0,u.words[u.length+1]=0,u.length+=2;for(var l=0,p=0;p<u.length;p++){var v=u.words[p]|0;l+=v*977,u.words[p]=l&67108863,l=v*64+(l/67108864|0)}return u.words[u.length-1]===0&&(u.length--,u.words[u.length-1]===0&&u.length--),u};function X(){K.call(this,"p224","ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001")}n(X,K);function oe(){K.call(this,"p192","ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff")}n(oe,K);function ue(){K.call(this,"25519","7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed")}n(ue,K),ue.prototype.imulK=function(u){for(var l=0,p=0;p<u.length;p++){var v=(u.words[p]|0)*19+l,b=v&67108863;v>>>=26,u.words[p]=b,l=v}return l!==0&&(u.words[u.length++]=l),u},i._prime=function(u){if(G[u])return G[u];var l;if(u==="k256")l=new z;else if(u==="p224")l=new X;else if(u==="p192")l=new oe;else if(u==="p25519")l=new ue;else throw new Error("Unknown prime "+u);return G[u]=l,l};function se(A){if(typeof A=="string"){var u=i._prime(A);this.m=u.p,this.prime=u}else r(A.gtn(1),"modulus must be greater than 1"),this.m=A,this.prime=null}se.prototype._verify1=function(u){r(u.negative===0,"red works only with positives"),r(u.red,"red works only with red numbers")},se.prototype._verify2=function(u,l){r((u.negative|l.negative)===0,"red works only with positives"),r(u.red&&u.red===l.red,"red works only with red numbers")},se.prototype.imod=function(u){return this.prime?this.prime.ireduce(u)._forceRed(this):u.umod(this.m)._forceRed(this)},se.prototype.neg=function(u){return u.isZero()?u.clone():this.m.sub(u)._forceRed(this)},se.prototype.add=function(u,l){this._verify2(u,l);var p=u.add(l);return p.cmp(this.m)>=0&&p.isub(this.m),p._forceRed(this)},se.prototype.iadd=function(u,l){this._verify2(u,l);var p=u.iadd(l);return p.cmp(this.m)>=0&&p.isub(this.m),p},se.prototype.sub=function(u,l){this._verify2(u,l);var p=u.sub(l);return p.cmpn(0)<0&&p.iadd(this.m),p._forceRed(this)},se.prototype.isub=function(u,l){this._verify2(u,l);var p=u.isub(l);return p.cmpn(0)<0&&p.iadd(this.m),p},se.prototype.shl=function(u,l){return this._verify1(u),this.imod(u.ushln(l))},se.prototype.imul=function(u,l){return this._verify2(u,l),this.imod(u.imul(l))},se.prototype.mul=function(u,l){return this._verify2(u,l),this.imod(u.mul(l))},se.prototype.isqr=function(u){return this.imul(u,u.clone())},se.prototype.sqr=function(u){return this.mul(u,u)},se.prototype.sqrt=function(u){if(u.isZero())return u.clone();var l=this.m.andln(3);if(r(l%2===1),l===3){var p=this.m.add(new i(1)).iushrn(2);return this.pow(u,p)}for(var v=this.m.subn(1),b=0;!v.isZero()&&v.andln(1)===0;)b++,v.iushrn(1);r(!v.isZero());var E=new i(1).toRed(this),O=E.redNeg(),w=this.m.subn(1).iushrn(1),f=this.m.bitLength();for(f=new i(2*f*f).toRed(this);this.pow(f,w).cmp(O)!==0;)f.redIAdd(O);for(var S=this.pow(f,v),j=this.pow(u,v.addn(1).iushrn(1)),F=this.pow(u,v),Y=b;F.cmp(E)!==0;){for(var $=F,J=0;$.cmp(E)!==0;J++)$=$.redSqr();r(J<Y);var ae=this.pow(S,new i(1).iushln(Y-J-1));j=j.redMul(ae),S=ae.redSqr(),F=F.redMul(S),Y=J}return j},se.prototype.invm=function(u){var l=u._invmp(this.m);return l.negative!==0?(l.negative=0,this.imod(l).redNeg()):this.imod(l)},se.prototype.pow=function(u,l){if(l.isZero())return new i(1).toRed(this);if(l.cmpn(1)===0)return u.clone();var p=4,v=new Array(1<<p);v[0]=new i(1).toRed(this),v[1]=u;for(var b=2;b<v.length;b++)v[b]=this.mul(v[b-1],u);var E=v[0],O=0,w=0,f=l.bitLength()%26;for(f===0&&(f=26),b=l.length-1;b>=0;b--){for(var S=l.words[b],j=f-1;j>=0;j--){var F=S>>j&1;if(E!==v[0]&&(E=this.sqr(E)),F===0&&O===0){w=0;continue}O<<=1,O|=F,w++,!(w!==p&&(b!==0||j!==0))&&(E=this.mul(E,v[O]),w=0,O=0)}f=26}return E},se.prototype.convertTo=function(u){var l=u.umod(this.m);return l===u?l.clone():l},se.prototype.convertFrom=function(u){var l=u.clone();return l.red=null,l},i.mont=function(u){return new de(u)};function de(A){se.call(this,A),this.shift=this.m.bitLength(),this.shift%26!==0&&(this.shift+=26-this.shift%26),this.r=new i(1).iushln(this.shift),this.r2=this.imod(this.r.sqr()),this.rinv=this.r._invmp(this.m),this.minv=this.rinv.mul(this.r).isubn(1).div(this.m),this.minv=this.minv.umod(this.r),this.minv=this.r.sub(this.minv)}n(de,se),de.prototype.convertTo=function(u){return this.imod(u.ushln(this.shift))},de.prototype.convertFrom=function(u){var l=this.imod(u.mul(this.rinv));return l.red=null,l},de.prototype.imul=function(u,l){if(u.isZero()||l.isZero())return u.words[0]=0,u.length=1,u;var p=u.imul(l),v=p.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),b=p.isub(v).iushrn(this.shift),E=b;return b.cmp(this.m)>=0?E=b.isub(this.m):b.cmpn(0)<0&&(E=b.iadd(this.m)),E._forceRed(this)},de.prototype.mul=function(u,l){if(u.isZero()||l.isZero())return new i(0)._forceRed(this);var p=u.mul(l),v=p.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),b=p.isub(v).iushrn(this.shift),E=b;return b.cmp(this.m)>=0?E=b.isub(this.m):b.cmpn(0)<0&&(E=b.iadd(this.m)),E._forceRed(this)},de.prototype.invm=function(u){var l=this.imod(u._invmp(this.m).mul(this.r2));return l._forceRed(this)}})(typeof wl>"u"||wl,A0)});var De=P((Qk,Sl)=>{y();typeof Object.create=="function"?Sl.exports=function(t,r){r&&(t.super_=r,t.prototype=Object.create(r.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}))}:Sl.exports=function(t,r){if(r){t.super_=r;var n=function(){};n.prototype=r.prototype,t.prototype=new n,t.prototype.constructor=t}}});var qt=P((El,T0)=>{y();var eu=Tt(),Qr=eu.Buffer;function R0(e,t){for(var r in e)t[r]=e[r]}Qr.from&&Qr.alloc&&Qr.allocUnsafe&&Qr.allocUnsafeSlow?T0.exports=eu:(R0(eu,El),El.Buffer=_i);function _i(e,t,r){return Qr(e,t,r)}_i.prototype=Object.create(Qr.prototype);R0(Qr,_i);_i.from=function(e,t,r){if(typeof e=="number")throw new TypeError("Argument must not be a number");return Qr(e,t,r)};_i.alloc=function(e,t,r){if(typeof e!="number")throw new TypeError("Argument must be a number");var n=Qr(e);return t!==void 0?typeof r=="string"?n.fill(t,r):n.fill(t):n.fill(0),n};_i.allocUnsafe=function(e){if(typeof e!="number")throw new TypeError("Argument must be a number");return Qr(e)};_i.allocUnsafeSlow=function(e){if(typeof e!="number")throw new TypeError("Argument must be a number");return eu.SlowBuffer(e)}});var yo=P((r8,xl)=>{"use strict";y();var go=typeof Reflect=="object"?Reflect:null,P0=go&&typeof go.apply=="function"?go.apply:function(t,r,n){return Function.prototype.apply.call(t,r,n)},tu;go&&typeof go.ownKeys=="function"?tu=go.ownKeys:Object.getOwnPropertySymbols?tu=function(t){return Object.getOwnPropertyNames(t).concat(Object.getOwnPropertySymbols(t))}:tu=function(t){return Object.getOwnPropertyNames(t)};function SI(e){console&&console.warn&&console.warn(e)}var N0=Number.isNaN||function(t){return t!==t};function Ce(){Ce.init.call(this)}xl.exports=Ce;xl.exports.once=AI;Ce.EventEmitter=Ce;Ce.prototype._events=void 0;Ce.prototype._eventsCount=0;Ce.prototype._maxListeners=void 0;var B0=10;function ru(e){if(typeof e!="function")throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof e)}Object.defineProperty(Ce,"defaultMaxListeners",{enumerable:!0,get:function(){return B0},set:function(e){if(typeof e!="number"||e<0||N0(e))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+e+".");B0=e}});Ce.init=function(){(this._events===void 0||this._events===Object.getPrototypeOf(this)._events)&&(this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0};Ce.prototype.setMaxListeners=function(t){if(typeof t!="number"||t<0||N0(t))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+t+".");return this._maxListeners=t,this};function M0(e){return e._maxListeners===void 0?Ce.defaultMaxListeners:e._maxListeners}Ce.prototype.getMaxListeners=function(){return M0(this)};Ce.prototype.emit=function(t){for(var r=[],n=1;n<arguments.length;n++)r.push(arguments[n]);var i=t==="error",o=this._events;if(o!==void 0)i=i&&o.error===void 0;else if(!i)return!1;if(i){var s;if(r.length>0&&(s=r[0]),s instanceof Error)throw s;var a=new Error("Unhandled error."+(s?" ("+s.message+")":""));throw a.context=s,a}var c=o[t];if(c===void 0)return!1;if(typeof c=="function")P0(c,this,r);else for(var h=c.length,g=U0(c,h),n=0;n<h;++n)P0(g[n],this,r);return!0};function k0(e,t,r,n){var i,o,s;if(ru(r),o=e._events,o===void 0?(o=e._events=Object.create(null),e._eventsCount=0):(o.newListener!==void 0&&(e.emit("newListener",t,r.listener?r.listener:r),o=e._events),s=o[t]),s===void 0)s=o[t]=r,++e._eventsCount;else if(typeof s=="function"?s=o[t]=n?[r,s]:[s,r]:n?s.unshift(r):s.push(r),i=M0(e),i>0&&s.length>i&&!s.warned){s.warned=!0;var a=new Error("Possible EventEmitter memory leak detected. "+s.length+" "+String(t)+" listeners added. Use emitter.setMaxListeners() to increase limit");a.name="MaxListenersExceededWarning",a.emitter=e,a.type=t,a.count=s.length,SI(a)}return e}Ce.prototype.addListener=function(t,r){return k0(this,t,r,!1)};Ce.prototype.on=Ce.prototype.addListener;Ce.prototype.prependListener=function(t,r){return k0(this,t,r,!0)};function EI(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,arguments.length===0?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function C0(e,t,r){var n={fired:!1,wrapFn:void 0,target:e,type:t,listener:r},i=EI.bind(n);return i.listener=r,n.wrapFn=i,i}Ce.prototype.once=function(t,r){return ru(r),this.on(t,C0(this,t,r)),this};Ce.prototype.prependOnceListener=function(t,r){return ru(r),this.prependListener(t,C0(this,t,r)),this};Ce.prototype.removeListener=function(t,r){var n,i,o,s,a;if(ru(r),i=this._events,i===void 0)return this;if(n=i[t],n===void 0)return this;if(n===r||n.listener===r)--this._eventsCount===0?this._events=Object.create(null):(delete i[t],i.removeListener&&this.emit("removeListener",t,n.listener||r));else if(typeof n!="function"){for(o=-1,s=n.length-1;s>=0;s--)if(n[s]===r||n[s].listener===r){a=n[s].listener,o=s;break}if(o<0)return this;o===0?n.shift():xI(n,o),n.length===1&&(i[t]=n[0]),i.removeListener!==void 0&&this.emit("removeListener",t,a||r)}return this};Ce.prototype.off=Ce.prototype.removeListener;Ce.prototype.removeAllListeners=function(t){var r,n,i;if(n=this._events,n===void 0)return this;if(n.removeListener===void 0)return arguments.length===0?(this._events=Object.create(null),this._eventsCount=0):n[t]!==void 0&&(--this._eventsCount===0?this._events=Object.create(null):delete n[t]),this;if(arguments.length===0){var o=Object.keys(n),s;for(i=0;i<o.length;++i)s=o[i],s!=="removeListener"&&this.removeAllListeners(s);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if(r=n[t],typeof r=="function")this.removeListener(t,r);else if(r!==void 0)for(i=r.length-1;i>=0;i--)this.removeListener(t,r[i]);return this};function L0(e,t,r){var n=e._events;if(n===void 0)return[];var i=n[t];return i===void 0?[]:typeof i=="function"?r?[i.listener||i]:[i]:r?II(i):U0(i,i.length)}Ce.prototype.listeners=function(t){return L0(this,t,!0)};Ce.prototype.rawListeners=function(t){return L0(this,t,!1)};Ce.listenerCount=function(e,t){return typeof e.listenerCount=="function"?e.listenerCount(t):D0.call(e,t)};Ce.prototype.listenerCount=D0;function D0(e){var t=this._events;if(t!==void 0){var r=t[e];if(typeof r=="function")return 1;if(r!==void 0)return r.length}return 0}Ce.prototype.eventNames=function(){return this._eventsCount>0?tu(this._events):[]};function U0(e,t){for(var r=new Array(t),n=0;n<t;++n)r[n]=e[n];return r}function xI(e,t){for(;t+1<e.length;t++)e[t]=e[t+1];e.pop()}function II(e){for(var t=new Array(e.length),r=0;r<t.length;++r)t[r]=e[r].listener||e[r];return t}function AI(e,t){return new Promise(function(r,n){function i(s){e.removeListener(t,o),n(s)}function o(){typeof e.removeListener=="function"&&e.removeListener("error",i),r([].slice.call(arguments))}F0(e,t,o,{once:!0}),t!=="error"&&OI(e,i,{once:!0})})}function OI(e,t,r){typeof e.on=="function"&&F0(e,"error",t,r)}function F0(e,t,r,n){if(typeof e.on=="function")n.once?e.once(t,r):e.on(t,r);else if(typeof e.addEventListener=="function")e.addEventListener(t,function i(o){n.once&&e.removeEventListener(t,i),r(o)});else throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof e)}});var Il=P((i8,q0)=>{y();q0.exports=yo().EventEmitter});var nu=P((s8,H0)=>{"use strict";y();H0.exports=function(){if(typeof Symbol!="function"||typeof Object.getOwnPropertySymbols!="function")return!1;if(typeof Symbol.iterator=="symbol")return!0;var t={},r=Symbol("test"),n=Object(r);if(typeof r=="string"||Object.prototype.toString.call(r)!=="[object Symbol]"||Object.prototype.toString.call(n)!=="[object Symbol]")return!1;var i=42;t[r]=i;for(var o in t)return!1;if(typeof Object.keys=="function"&&Object.keys(t).length!==0||typeof Object.getOwnPropertyNames=="function"&&Object.getOwnPropertyNames(t).length!==0)return!1;var s=Object.getOwnPropertySymbols(t);if(s.length!==1||s[0]!==r||!Object.prototype.propertyIsEnumerable.call(t,r))return!1;if(typeof Object.getOwnPropertyDescriptor=="function"){var a=Object.getOwnPropertyDescriptor(t,r);if(a.value!==i||a.enumerable!==!0)return!1}return!0}});var ms=P((u8,j0)=>{"use strict";y();var RI=nu();j0.exports=function(){return RI()&&!!Symbol.toStringTag}});var iu=P((c8,K0)=>{"use strict";y();K0.exports=Object});var G0=P((h8,V0)=>{"use strict";y();V0.exports=Error});var z0=P((p8,W0)=>{"use strict";y();W0.exports=EvalError});var $0=P((y8,Y0)=>{"use strict";y();Y0.exports=RangeError});var X0=P((v8,Z0)=>{"use strict";y();Z0.exports=ReferenceError});var Al=P((_8,J0)=>{"use strict";y();J0.exports=SyntaxError});var wi=P((S8,Q0)=>{"use strict";y();Q0.exports=TypeError});var tg=P((x8,eg)=>{"use strict";y();eg.exports=URIError});var ng=P((A8,rg)=>{"use strict";y();rg.exports=Math.abs});var og=P((R8,ig)=>{"use strict";y();ig.exports=Math.floor});var ag=P((P8,sg)=>{"use strict";y();sg.exports=Math.max});var fg=P((N8,ug)=>{"use strict";y();ug.exports=Math.min});var lg=P((k8,cg)=>{"use strict";y();cg.exports=Math.pow});var dg=P((L8,hg)=>{"use strict";y();hg.exports=Math.round});var gg=P((U8,pg)=>{"use strict";y();pg.exports=Number.isNaN||function(t){return t!==t}});var mg=P((q8,yg)=>{"use strict";y();var TI=gg();yg.exports=function(t){return TI(t)||t===0?t:t<0?-1:1}});var bg=P((j8,vg)=>{"use strict";y();vg.exports=Object.getOwnPropertyDescriptor});var Si=P((V8,_g)=>{"use strict";y();var ou=bg();if(ou)try{ou([],"length")}catch{ou=null}_g.exports=ou});var vs=P((W8,wg)=>{"use strict";y();var su=Object.defineProperty||!1;if(su)try{su({},"a",{value:1})}catch{su=!1}wg.exports=su});var xg=P((Y8,Eg)=>{"use strict";y();var Sg=typeof Symbol<"u"&&Symbol,PI=nu();Eg.exports=function(){return typeof Sg!="function"||typeof Symbol!="function"||typeof Sg("foo")!="symbol"||typeof Symbol("bar")!="symbol"?!1:PI()}});var Ol=P((Z8,Ig)=>{"use strict";y();Ig.exports=typeof Reflect<"u"&&Reflect.getPrototypeOf||null});var Rl=P((J8,Ag)=>{"use strict";y();var BI=iu();Ag.exports=BI.getPrototypeOf||null});var Tg=P((e4,Rg)=>{"use strict";y();var NI="Function.prototype.bind called on incompatible ",MI=Object.prototype.toString,kI=Math.max,CI="[object Function]",Og=function(t,r){for(var n=[],i=0;i<t.length;i+=1)n[i]=t[i];for(var o=0;o<r.length;o+=1)n[o+t.length]=r[o];return n},LI=function(t,r){for(var n=[],i=r||0,o=0;i<t.length;i+=1,o+=1)n[o]=t[i];return n},DI=function(e,t){for(var r="",n=0;n<e.length;n+=1)r+=e[n],n+1<e.length&&(r+=t);return r};Rg.exports=function(t){var r=this;if(typeof r!="function"||MI.apply(r)!==CI)throw new TypeError(NI+r);for(var n=LI(arguments,1),i,o=function(){if(this instanceof i){var g=r.apply(this,Og(n,arguments));return Object(g)===g?g:this}return r.apply(t,Og(n,arguments))},s=kI(0,r.length-n.length),a=[],c=0;c<s;c++)a[c]="$"+c;if(i=Function("binder","return function ("+DI(a,",")+"){ return binder.apply(this,arguments); }")(o),r.prototype){var h=function(){};h.prototype=r.prototype,i.prototype=new h,h.prototype=null}return i}});var mo=P((r4,Pg)=>{"use strict";y();var UI=Tg();Pg.exports=Function.prototype.bind||UI});var au=P((i4,Bg)=>{"use strict";y();Bg.exports=Function.prototype.call});var uu=P((s4,Ng)=>{"use strict";y();Ng.exports=Function.prototype.apply});var kg=P((u4,Mg)=>{"use strict";y();Mg.exports=typeof Reflect<"u"&&Reflect&&Reflect.apply});var Tl=P((c4,Cg)=>{"use strict";y();var FI=mo(),qI=uu(),HI=au(),jI=kg();Cg.exports=jI||FI.call(HI,qI)});var fu=P((h4,Lg)=>{"use strict";y();var KI=mo(),VI=wi(),GI=au(),WI=Tl();Lg.exports=function(t){if(t.length<1||typeof t[0]!="function")throw new VI("a function is required");return WI(KI,GI,t)}});var jg=P((p4,Hg)=>{"use strict";y();var zI=fu(),Dg=Si(),Fg;try{Fg=[].__proto__===Array.prototype}catch(e){if(!e||typeof e!="object"||!("code"in e)||e.code!=="ERR_PROTO_ACCESS")throw e}var Pl=!!Fg&&Dg&&Dg(Object.prototype,"__proto__"),qg=Object,Ug=qg.getPrototypeOf;Hg.exports=Pl&&typeof Pl.get=="function"?zI([Pl.get]):typeof Ug=="function"?function(t){return Ug(t==null?t:qg(t))}:!1});var cu=P((y4,Wg)=>{"use strict";y();var Kg=Ol(),Vg=Rl(),Gg=jg();Wg.exports=Kg?function(t){return Kg(t)}:Vg?function(t){if(!t||typeof t!="object"&&typeof t!="function")throw new TypeError("getProto: not an object");return Vg(t)}:Gg?function(t){return Gg(t)}:null});var Bl=P((v4,zg)=>{"use strict";y();var YI=Function.prototype.call,$I=Object.prototype.hasOwnProperty,ZI=mo();zg.exports=ZI.call(YI,$I)});var du=P((_4,Qg)=>{"use strict";y();var Se,XI=iu(),JI=G0(),QI=z0(),eA=$0(),tA=X0(),wo=Al(),_o=wi(),rA=tg(),nA=ng(),iA=og(),oA=ag(),sA=fg(),aA=lg(),uA=dg(),fA=mg(),Xg=Function,Nl=function(e){try{return Xg('"use strict"; return ('+e+").constructor;")()}catch{}},bs=Si(),cA=vs(),Ml=function(){throw new _o},lA=bs?(function(){try{return arguments.callee,Ml}catch{try{return bs(arguments,"callee").get}catch{return Ml}}})():Ml,vo=xg()(),kt=cu(),hA=Rl(),dA=Ol(),Jg=uu(),_s=au(),bo={},pA=typeof Uint8Array>"u"||!kt?Se:kt(Uint8Array),Ei={__proto__:null,"%AggregateError%":typeof AggregateError>"u"?Se:AggregateError,"%Array%":Array,"%ArrayBuffer%":typeof ArrayBuffer>"u"?Se:ArrayBuffer,"%ArrayIteratorPrototype%":vo&&kt?kt([][Symbol.iterator]()):Se,"%AsyncFromSyncIteratorPrototype%":Se,"%AsyncFunction%":bo,"%AsyncGenerator%":bo,"%AsyncGeneratorFunction%":bo,"%AsyncIteratorPrototype%":bo,"%Atomics%":typeof Atomics>"u"?Se:Atomics,"%BigInt%":typeof BigInt>"u"?Se:BigInt,"%BigInt64Array%":typeof BigInt64Array>"u"?Se:BigInt64Array,"%BigUint64Array%":typeof BigUint64Array>"u"?Se:BigUint64Array,"%Boolean%":Boolean,"%DataView%":typeof DataView>"u"?Se:DataView,"%Date%":Date,"%decodeURI%":decodeURI,"%decodeURIComponent%":decodeURIComponent,"%encodeURI%":encodeURI,"%encodeURIComponent%":encodeURIComponent,"%Error%":JI,"%eval%":eval,"%EvalError%":QI,"%Float16Array%":typeof Float16Array>"u"?Se:Float16Array,"%Float32Array%":typeof Float32Array>"u"?Se:Float32Array,"%Float64Array%":typeof Float64Array>"u"?Se:Float64Array,"%FinalizationRegistry%":typeof FinalizationRegistry>"u"?Se:FinalizationRegistry,"%Function%":Xg,"%GeneratorFunction%":bo,"%Int8Array%":typeof Int8Array>"u"?Se:Int8Array,"%Int16Array%":typeof Int16Array>"u"?Se:Int16Array,"%Int32Array%":typeof Int32Array>"u"?Se:Int32Array,"%isFinite%":isFinite,"%isNaN%":isNaN,"%IteratorPrototype%":vo&&kt?kt(kt([][Symbol.iterator]())):Se,"%JSON%":typeof JSON=="object"?JSON:Se,"%Map%":typeof Map>"u"?Se:Map,"%MapIteratorPrototype%":typeof Map>"u"||!vo||!kt?Se:kt(new Map()[Symbol.iterator]()),"%Math%":Math,"%Number%":Number,"%Object%":XI,"%Object.getOwnPropertyDescriptor%":bs,"%parseFloat%":parseFloat,"%parseInt%":parseInt,"%Promise%":typeof Promise>"u"?Se:Promise,"%Proxy%":typeof Proxy>"u"?Se:Proxy,"%RangeError%":eA,"%ReferenceError%":tA,"%Reflect%":typeof Reflect>"u"?Se:Reflect,"%RegExp%":RegExp,"%Set%":typeof Set>"u"?Se:Set,"%SetIteratorPrototype%":typeof Set>"u"||!vo||!kt?Se:kt(new Set()[Symbol.iterator]()),"%SharedArrayBuffer%":typeof SharedArrayBuffer>"u"?Se:SharedArrayBuffer,"%String%":String,"%StringIteratorPrototype%":vo&&kt?kt(""[Symbol.iterator]()):Se,"%Symbol%":vo?Symbol:Se,"%SyntaxError%":wo,"%ThrowTypeError%":lA,"%TypedArray%":pA,"%TypeError%":_o,"%Uint8Array%":typeof Uint8Array>"u"?Se:Uint8Array,"%Uint8ClampedArray%":typeof Uint8ClampedArray>"u"?Se:Uint8ClampedArray,"%Uint16Array%":typeof Uint16Array>"u"?Se:Uint16Array,"%Uint32Array%":typeof Uint32Array>"u"?Se:Uint32Array,"%URIError%":rA,"%WeakMap%":typeof WeakMap>"u"?Se:WeakMap,"%WeakRef%":typeof WeakRef>"u"?Se:WeakRef,"%WeakSet%":typeof WeakSet>"u"?Se:WeakSet,"%Function.prototype.call%":_s,"%Function.prototype.apply%":Jg,"%Object.defineProperty%":cA,"%Object.getPrototypeOf%":hA,"%Math.abs%":nA,"%Math.floor%":iA,"%Math.max%":oA,"%Math.min%":sA,"%Math.pow%":aA,"%Math.round%":uA,"%Math.sign%":fA,"%Reflect.getPrototypeOf%":dA};if(kt)try{null.error}catch(e){Yg=kt(kt(e)),Ei["%Error.prototype%"]=Yg}var Yg,gA=function e(t){var r;if(t==="%AsyncFunction%")r=Nl("async function () {}");else if(t==="%GeneratorFunction%")r=Nl("function* () {}");else if(t==="%AsyncGeneratorFunction%")r=Nl("async function* () {}");else if(t==="%AsyncGenerator%"){var n=e("%AsyncGeneratorFunction%");n&&(r=n.prototype)}else if(t==="%AsyncIteratorPrototype%"){var i=e("%AsyncGenerator%");i&&kt&&(r=kt(i.prototype))}return Ei[t]=r,r},$g={__proto__:null,"%ArrayBufferPrototype%":["ArrayBuffer","prototype"],"%ArrayPrototype%":["Array","prototype"],"%ArrayProto_entries%":["Array","prototype","entries"],"%ArrayProto_forEach%":["Array","prototype","forEach"],"%ArrayProto_keys%":["Array","prototype","keys"],"%ArrayProto_values%":["Array","prototype","values"],"%AsyncFunctionPrototype%":["AsyncFunction","prototype"],"%AsyncGenerator%":["AsyncGeneratorFunction","prototype"],"%AsyncGeneratorPrototype%":["AsyncGeneratorFunction","prototype","prototype"],"%BooleanPrototype%":["Boolean","prototype"],"%DataViewPrototype%":["DataView","prototype"],"%DatePrototype%":["Date","prototype"],"%ErrorPrototype%":["Error","prototype"],"%EvalErrorPrototype%":["EvalError","prototype"],"%Float32ArrayPrototype%":["Float32Array","prototype"],"%Float64ArrayPrototype%":["Float64Array","prototype"],"%FunctionPrototype%":["Function","prototype"],"%Generator%":["GeneratorFunction","prototype"],"%GeneratorPrototype%":["GeneratorFunction","prototype","prototype"],"%Int8ArrayPrototype%":["Int8Array","prototype"],"%Int16ArrayPrototype%":["Int16Array","prototype"],"%Int32ArrayPrototype%":["Int32Array","prototype"],"%JSONParse%":["JSON","parse"],"%JSONStringify%":["JSON","stringify"],"%MapPrototype%":["Map","prototype"],"%NumberPrototype%":["Number","prototype"],"%ObjectPrototype%":["Object","prototype"],"%ObjProto_toString%":["Object","prototype","toString"],"%ObjProto_valueOf%":["Object","prototype","valueOf"],"%PromisePrototype%":["Promise","prototype"],"%PromiseProto_then%":["Promise","prototype","then"],"%Promise_all%":["Promise","all"],"%Promise_reject%":["Promise","reject"],"%Promise_resolve%":["Promise","resolve"],"%RangeErrorPrototype%":["RangeError","prototype"],"%ReferenceErrorPrototype%":["ReferenceError","prototype"],"%RegExpPrototype%":["RegExp","prototype"],"%SetPrototype%":["Set","prototype"],"%SharedArrayBufferPrototype%":["SharedArrayBuffer","prototype"],"%StringPrototype%":["String","prototype"],"%SymbolPrototype%":["Symbol","prototype"],"%SyntaxErrorPrototype%":["SyntaxError","prototype"],"%TypedArrayPrototype%":["TypedArray","prototype"],"%TypeErrorPrototype%":["TypeError","prototype"],"%Uint8ArrayPrototype%":["Uint8Array","prototype"],"%Uint8ClampedArrayPrototype%":["Uint8ClampedArray","prototype"],"%Uint16ArrayPrototype%":["Uint16Array","prototype"],"%Uint32ArrayPrototype%":["Uint32Array","prototype"],"%URIErrorPrototype%":["URIError","prototype"],"%WeakMapPrototype%":["WeakMap","prototype"],"%WeakSetPrototype%":["WeakSet","prototype"]},ws=mo(),lu=Bl(),yA=ws.call(_s,Array.prototype.concat),mA=ws.call(Jg,Array.prototype.splice),Zg=ws.call(_s,String.prototype.replace),hu=ws.call(_s,String.prototype.slice),vA=ws.call(_s,RegExp.prototype.exec),bA=/[^%.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|%$))/g,_A=/\\(\\)?/g,wA=function(t){var r=hu(t,0,1),n=hu(t,-1);if(r==="%"&&n!=="%")throw new wo("invalid intrinsic syntax, expected closing `%`");if(n==="%"&&r!=="%")throw new wo("invalid intrinsic syntax, expected opening `%`");var i=[];return Zg(t,bA,function(o,s,a,c){i[i.length]=a?Zg(c,_A,"$1"):s||o}),i},SA=function(t,r){var n=t,i;if(lu($g,n)&&(i=$g[n],n="%"+i[0]+"%"),lu(Ei,n)){var o=Ei[n];if(o===bo&&(o=gA(n)),typeof o>"u"&&!r)throw new _o("intrinsic "+t+" exists, but is not available. Please file an issue!");return{alias:i,name:n,value:o}}throw new wo("intrinsic "+t+" does not exist!")};Qg.exports=function(t,r){if(typeof t!="string"||t.length===0)throw new _o("intrinsic name must be a non-empty string");if(arguments.length>1&&typeof r!="boolean")throw new _o('"allowMissing" argument must be a boolean');if(vA(/^%?[^%]*%?$/,t)===null)throw new wo("`%` may not be present anywhere but at the beginning and end of the intrinsic name");var n=wA(t),i=n.length>0?n[0]:"",o=SA("%"+i+"%",r),s=o.name,a=o.value,c=!1,h=o.alias;h&&(i=h[0],mA(n,yA([0,1],h)));for(var g=1,m=!0;g<n.length;g+=1){var _=n[g],I=hu(_,0,1),R=hu(_,-1);if((I==='"'||I==="'"||I==="`"||R==='"'||R==="'"||R==="`")&&I!==R)throw new wo("property names with quotes must have matching quotes");if((_==="constructor"||!m)&&(c=!0),i+="."+_,s="%"+i+"%",lu(Ei,s))a=Ei[s];else if(a!=null){if(!(_ in a)){if(!r)throw new _o("base intrinsic for "+t+" exists, but the property is not available.");return}if(bs&&g+1>=n.length){var N=bs(a,_);m=!!N,m&&"get"in N&&!("originalValue"in N.get)?a=N.get:a=a[_]}else m=lu(a,_),a=a[_];m&&!c&&(Ei[s]=a)}}return a}});var Vn=P((S4,ry)=>{"use strict";y();var ey=du(),ty=fu(),EA=ty([ey("%String.prototype.indexOf%")]);ry.exports=function(t,r){var n=ey(t,!!r);return typeof n=="function"&&EA(t,".prototype.")>-1?ty([n]):n}});var oy=P((x4,iy)=>{"use strict";y();var xA=ms()(),IA=Vn(),kl=IA("Object.prototype.toString"),pu=function(t){return xA&&t&&typeof t=="object"&&Symbol.toStringTag in t?!1:kl(t)==="[object Arguments]"},ny=function(t){return pu(t)?!0:t!==null&&typeof t=="object"&&"length"in t&&typeof t.length=="number"&&t.length>=0&&kl(t)!=="[object Array]"&&"callee"in t&&kl(t.callee)==="[object Function]"},AA=(function(){return pu(arguments)})();pu.isLegacyArguments=ny;iy.exports=AA?pu:ny});var ly=P((A4,cy)=>{"use strict";y();var sy=Vn(),OA=ms()(),RA=Bl(),TA=Si(),Dl;OA?(ay=sy("RegExp.prototype.exec"),Cl={},gu=function(){throw Cl},Ll={toString:gu,valueOf:gu},typeof Symbol.toPrimitive=="symbol"&&(Ll[Symbol.toPrimitive]=gu),Dl=function(t){if(!t||typeof t!="object")return!1;var r=TA(t,"lastIndex"),n=r&&RA(r,"value");if(!n)return!1;try{ay(t,Ll)}catch(i){return i===Cl}}):(uy=sy("Object.prototype.toString"),fy="[object RegExp]",Dl=function(t){return!t||typeof t!="object"&&typeof t!="function"?!1:uy(t)===fy});var ay,Cl,gu,Ll,uy,fy;cy.exports=Dl});var dy=P((R4,hy)=>{"use strict";y();var PA=Vn(),BA=ly(),NA=PA("RegExp.prototype.exec"),MA=wi();hy.exports=function(t){if(!BA(t))throw new MA("`regex` must be a RegExp");return function(n){return NA(t,n)!==null}}});var gy=P((P4,py)=>{"use strict";y();var kA=function*(){}.constructor;py.exports=()=>kA});var by=P((N4,vy)=>{"use strict";y();var my=Vn(),CA=dy(),LA=CA(/^\s*(?:function)?\*/),DA=ms()(),yy=cu(),UA=my("Object.prototype.toString"),FA=my("Function.prototype.toString"),qA=gy();vy.exports=function(t){if(typeof t!="function")return!1;if(LA(FA(t)))return!0;if(!DA){var r=UA(t);return r==="[object GeneratorFunction]"}if(!yy)return!1;var n=qA();return n&&yy(t)===n.prototype}});var Ey=P((k4,Sy)=>{"use strict";y();var wy=Function.prototype.toString,So=typeof Reflect=="object"&&Reflect!==null&&Reflect.apply,Fl,yu;if(typeof So=="function"&&typeof Object.defineProperty=="function")try{Fl=Object.defineProperty({},"length",{get:function(){throw yu}}),yu={},So(function(){throw 42},null,Fl)}catch(e){e!==yu&&(So=null)}else So=null;var HA=/^\s*class\b/,ql=function(t){try{var r=wy.call(t);return HA.test(r)}catch{return!1}},Ul=function(t){try{return ql(t)?!1:(wy.call(t),!0)}catch{return!1}},mu=Object.prototype.toString,jA="[object Object]",KA="[object Function]",VA="[object GeneratorFunction]",GA="[object HTMLAllCollection]",WA="[object HTML document.all class]",zA="[object HTMLCollection]",YA=typeof Symbol=="function"&&!!Symbol.toStringTag,$A=!(0 in[,]),Hl=function(){return!1};typeof document=="object"&&(_y=document.all,mu.call(_y)===mu.call(document.all)&&(Hl=function(t){if(($A||!t)&&(typeof t>"u"||typeof t=="object"))try{var r=mu.call(t);return(r===GA||r===WA||r===zA||r===jA)&&t("")==null}catch{}return!1}));var _y;Sy.exports=So?function(t){if(Hl(t))return!0;if(!t||typeof t!="function"&&typeof t!="object")return!1;try{So(t,null,Fl)}catch(r){if(r!==yu)return!1}return!ql(t)&&Ul(t)}:function(t){if(Hl(t))return!0;if(!t||typeof t!="function"&&typeof t!="object")return!1;if(YA)return Ul(t);if(ql(t))return!1;var r=mu.call(t);return r!==KA&&r!==VA&&!/^\[object HTML/.test(r)?!1:Ul(t)}});var Ay=P((L4,Iy)=>{"use strict";y();var ZA=Ey(),XA=Object.prototype.toString,xy=Object.prototype.hasOwnProperty,JA=function(t,r,n){for(var i=0,o=t.length;i<o;i++)xy.call(t,i)&&(n==null?r(t[i],i,t):r.call(n,t[i],i,t))},QA=function(t,r,n){for(var i=0,o=t.length;i<o;i++)n==null?r(t.charAt(i),i,t):r.call(n,t.charAt(i),i,t)},eO=function(t,r,n){for(var i in t)xy.call(t,i)&&(n==null?r(t[i],i,t):r.call(n,t[i],i,t))};function tO(e){return XA.call(e)==="[object Array]"}Iy.exports=function(t,r,n){if(!ZA(r))throw new TypeError("iterator must be a function");var i;arguments.length>=3&&(i=n),tO(t)?JA(t,r,i):typeof t=="string"?QA(t,r,i):eO(t,r,i)}});var Ry=P((U4,Oy)=>{"use strict";y();Oy.exports=["Float16Array","Float32Array","Float64Array","Int8Array","Int16Array","Int32Array","Uint8Array","Uint8ClampedArray","Uint16Array","Uint32Array","BigInt64Array","BigUint64Array"]});var Py=P((q4,Ty)=>{"use strict";y();var jl=Ry(),rO=globalThis;Ty.exports=function(){for(var t=[],r=0;r<jl.length;r++)typeof rO[jl[r]]=="function"&&(t[t.length]=jl[r]);return t}});var Kl=P((j4,My)=>{"use strict";y();var By=vs(),nO=Al(),Eo=wi(),Ny=Si();My.exports=function(t,r,n){if(!t||typeof t!="object"&&typeof t!="function")throw new Eo("`obj` must be an object or a function`");if(typeof r!="string"&&typeof r!="symbol")throw new Eo("`property` must be a string or a symbol`");if(arguments.length>3&&typeof arguments[3]!="boolean"&&arguments[3]!==null)throw new Eo("`nonEnumerable`, if provided, must be a boolean or null");if(arguments.length>4&&typeof arguments[4]!="boolean"&&arguments[4]!==null)throw new Eo("`nonWritable`, if provided, must be a boolean or null");if(arguments.length>5&&typeof arguments[5]!="boolean"&&arguments[5]!==null)throw new Eo("`nonConfigurable`, if provided, must be a boolean or null");if(arguments.length>6&&typeof arguments[6]!="boolean")throw new Eo("`loose`, if provided, must be a boolean");var i=arguments.length>3?arguments[3]:null,o=arguments.length>4?arguments[4]:null,s=arguments.length>5?arguments[5]:null,a=arguments.length>6?arguments[6]:!1,c=!!Ny&&Ny(t,r);if(By)By(t,r,{configurable:s===null&&c?c.configurable:!s,enumerable:i===null&&c?c.enumerable:!i,value:n,writable:o===null&&c?c.writable:!o});else if(a||!i&&!o&&!s)t[r]=n;else throw new nO("This environment does not support defining a property as non-configurable, non-writable, or non-enumerable.")}});var Gl=P((V4,Cy)=>{"use strict";y();var Vl=vs(),ky=function(){return!!Vl};ky.hasArrayLengthDefineBug=function(){if(!Vl)return null;try{return Vl([],"length",{value:1}).length!==1}catch{return!0}};Cy.exports=ky});var qy=P((W4,Fy)=>{"use strict";y();var iO=du(),Ly=Kl(),oO=Gl()(),Dy=Si(),Uy=wi(),sO=iO("%Math.floor%");Fy.exports=function(t,r){if(typeof t!="function")throw new Uy("`fn` is not a function");if(typeof r!="number"||r<0||r>4294967295||sO(r)!==r)throw new Uy("`length` must be a positive 32-bit integer");var n=arguments.length>2&&!!arguments[2],i=!0,o=!0;if("length"in t&&Dy){var s=Dy(t,"length");s&&!s.configurable&&(i=!1),s&&!s.writable&&(o=!1)}return(i||o||!n)&&(oO?Ly(t,"length",r,!0,!0):Ly(t,"length",r)),t}});var jy=P((Y4,Hy)=>{"use strict";y();var aO=mo(),uO=uu(),fO=Tl();Hy.exports=function(){return fO(aO,uO,arguments)}});var Ss=P((Z4,vu)=>{"use strict";y();var cO=qy(),Ky=vs(),lO=fu(),Vy=jy();vu.exports=function(t){var r=lO(arguments),n=1+t.length-(arguments.length-1);return cO(r,n>0?n:0,!0)};Ky?Ky(vu.exports,"apply",{value:Vy}):vu.exports.apply=Vy});var $l=P((J4,Yy)=>{"use strict";y();var wu=Ay(),hO=Py(),Gy=Ss(),zl=Vn(),_u=Si(),bu=cu(),dO=zl("Object.prototype.toString"),zy=ms()(),Wy=globalThis,Wl=hO(),Yl=zl("String.prototype.slice"),pO=zl("Array.prototype.indexOf",!0)||function(t,r){for(var n=0;n<t.length;n+=1)if(t[n]===r)return n;return-1},Su={__proto__:null};zy&&_u&&bu?wu(Wl,function(e){var t=new Wy[e];if(Symbol.toStringTag in t&&bu){var r=bu(t),n=_u(r,Symbol.toStringTag);if(!n&&r){var i=bu(r);n=_u(i,Symbol.toStringTag)}if(n&&n.get){var o=Gy(n.get);Su["$"+e]=o}}}):wu(Wl,function(e){var t=new Wy[e],r=t.slice||t.set;if(r){var n=Gy(r);Su["$"+e]=n}});var gO=function(t){var r=!1;return wu(Su,function(n,i){if(!r)try{"$"+n(t)===i&&(r=Yl(i,1))}catch{}}),r},yO=function(t){var r=!1;return wu(Su,function(n,i){if(!r)try{n(t),r=Yl(i,1)}catch{}}),r};Yy.exports=function(t){if(!t||typeof t!="object")return!1;if(!zy){var r=Yl(dO(t),8,-1);return pO(Wl,r)>-1?r:r!=="Object"?!1:yO(t)}return _u?gO(t):null}});var Zl=P((eC,$y)=>{"use strict";y();var mO=$l();$y.exports=function(t){return!!mO(t)}});var fm=P(Ee=>{"use strict";y();var vO=oy(),bO=by(),Nr=$l(),Zy=Zl();function xo(e){return e.call.bind(e)}var Xy=typeof BigInt<"u",Jy=typeof Symbol<"u",_r=xo(Object.prototype.toString),_O=xo(Number.prototype.valueOf),wO=xo(String.prototype.valueOf),SO=xo(Boolean.prototype.valueOf);Xy&&(Qy=xo(BigInt.prototype.valueOf));var Qy;Jy&&(em=xo(Symbol.prototype.valueOf));var em;function xs(e,t){if(typeof e!="object")return!1;try{return t(e),!0}catch{return!1}}Ee.isArgumentsObject=vO;Ee.isGeneratorFunction=bO;Ee.isTypedArray=Zy;function EO(e){return typeof Promise<"u"&&e instanceof Promise||e!==null&&typeof e=="object"&&typeof e.then=="function"&&typeof e.catch=="function"}Ee.isPromise=EO;function xO(e){return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?ArrayBuffer.isView(e):Zy(e)||rm(e)}Ee.isArrayBufferView=xO;function IO(e){return Nr(e)==="Uint8Array"}Ee.isUint8Array=IO;function AO(e){return Nr(e)==="Uint8ClampedArray"}Ee.isUint8ClampedArray=AO;function OO(e){return Nr(e)==="Uint16Array"}Ee.isUint16Array=OO;function RO(e){return Nr(e)==="Uint32Array"}Ee.isUint32Array=RO;function TO(e){return Nr(e)==="Int8Array"}Ee.isInt8Array=TO;function PO(e){return Nr(e)==="Int16Array"}Ee.isInt16Array=PO;function BO(e){return Nr(e)==="Int32Array"}Ee.isInt32Array=BO;function NO(e){return Nr(e)==="Float32Array"}Ee.isFloat32Array=NO;function MO(e){return Nr(e)==="Float64Array"}Ee.isFloat64Array=MO;function kO(e){return Nr(e)==="BigInt64Array"}Ee.isBigInt64Array=kO;function CO(e){return Nr(e)==="BigUint64Array"}Ee.isBigUint64Array=CO;function Eu(e){return _r(e)==="[object Map]"}Eu.working=typeof Map<"u"&&Eu(new Map);function LO(e){return typeof Map>"u"?!1:Eu.working?Eu(e):e instanceof Map}Ee.isMap=LO;function xu(e){return _r(e)==="[object Set]"}xu.working=typeof Set<"u"&&xu(new Set);function DO(e){return typeof Set>"u"?!1:xu.working?xu(e):e instanceof Set}Ee.isSet=DO;function Iu(e){return _r(e)==="[object WeakMap]"}Iu.working=typeof WeakMap<"u"&&Iu(new WeakMap);function UO(e){return typeof WeakMap>"u"?!1:Iu.working?Iu(e):e instanceof WeakMap}Ee.isWeakMap=UO;function Jl(e){return _r(e)==="[object WeakSet]"}Jl.working=typeof WeakSet<"u"&&Jl(new WeakSet);function FO(e){return Jl(e)}Ee.isWeakSet=FO;function Au(e){return _r(e)==="[object ArrayBuffer]"}Au.working=typeof ArrayBuffer<"u"&&Au(new ArrayBuffer);function tm(e){return typeof ArrayBuffer>"u"?!1:Au.working?Au(e):e instanceof ArrayBuffer}Ee.isArrayBuffer=tm;function Ou(e){return _r(e)==="[object DataView]"}Ou.working=typeof ArrayBuffer<"u"&&typeof DataView<"u"&&Ou(new DataView(new ArrayBuffer(1),0,1));function rm(e){return typeof DataView>"u"?!1:Ou.working?Ou(e):e instanceof DataView}Ee.isDataView=rm;var Xl=typeof SharedArrayBuffer<"u"?SharedArrayBuffer:void 0;function Es(e){return _r(e)==="[object SharedArrayBuffer]"}function nm(e){return typeof Xl>"u"?!1:(typeof Es.working>"u"&&(Es.working=Es(new Xl)),Es.working?Es(e):e instanceof Xl)}Ee.isSharedArrayBuffer=nm;function qO(e){return _r(e)==="[object AsyncFunction]"}Ee.isAsyncFunction=qO;function HO(e){return _r(e)==="[object Map Iterator]"}Ee.isMapIterator=HO;function jO(e){return _r(e)==="[object Set Iterator]"}Ee.isSetIterator=jO;function KO(e){return _r(e)==="[object Generator]"}Ee.isGeneratorObject=KO;function VO(e){return _r(e)==="[object WebAssembly.Module]"}Ee.isWebAssemblyCompiledModule=VO;function im(e){return xs(e,_O)}Ee.isNumberObject=im;function om(e){return xs(e,wO)}Ee.isStringObject=om;function sm(e){return xs(e,SO)}Ee.isBooleanObject=sm;function am(e){return Xy&&xs(e,Qy)}Ee.isBigIntObject=am;function um(e){return Jy&&xs(e,em)}Ee.isSymbolObject=um;function GO(e){return im(e)||om(e)||sm(e)||am(e)||um(e)}Ee.isBoxedPrimitive=GO;function WO(e){return typeof Uint8Array<"u"&&(tm(e)||nm(e))}Ee.isAnyArrayBuffer=WO;["isProxy","isExternal","isModuleNamespaceObject"].forEach(function(e){Object.defineProperty(Ee,e,{enumerable:!1,value:function(){throw new Error(e+" is not supported in userland")}})})});var lm=P((iC,cm)=>{y();cm.exports=function(t){return t&&typeof t=="object"&&typeof t.copy=="function"&&typeof t.fill=="function"&&typeof t.readUInt8=="function"}});var en=P(xe=>{y();var hm=Object.getOwnPropertyDescriptors||function(t){for(var r=Object.keys(t),n={},i=0;i<r.length;i++)n[r[i]]=Object.getOwnPropertyDescriptor(t,r[i]);return n},zO=/%[sdj%]/g;xe.format=function(e){if(!ku(e)){for(var t=[],r=0;r<arguments.length;r++)t.push(Gn(arguments[r]));return t.join(" ")}for(var r=1,n=arguments,i=n.length,o=String(e).replace(zO,function(a){if(a==="%%")return"%";if(r>=i)return a;switch(a){case"%s":return String(n[r++]);case"%d":return Number(n[r++]);case"%j":try{return JSON.stringify(n[r++])}catch{return"[Circular]"}default:return a}}),s=n[r];r<i;s=n[++r])Mu(s)||!Io(s)?o+=" "+s:o+=" "+Gn(s);return o};xe.deprecate=function(e,t){if(typeof x.default<"u"&&x.default.noDeprecation===!0)return e;if(typeof x.default>"u")return function(){return xe.deprecate(e,t).apply(this,arguments)};var r=!1;function n(){if(!r){if(x.default.throwDeprecation)throw new Error(t);x.default.traceDeprecation?console.trace(t):console.error(t),r=!0}return e.apply(this,arguments)}return n};var Ru={},dm=/^$/;x.default.env.NODE_DEBUG&&(Tu=x.default.env.NODE_DEBUG,Tu=Tu.replace(/[|\\{}()[\]^$+?.]/g,"\\$&").replace(/\*/g,".*").replace(/,/g,"$|^").toUpperCase(),dm=new RegExp("^"+Tu+"$","i"));var Tu;xe.debuglog=function(e){if(e=e.toUpperCase(),!Ru[e])if(dm.test(e)){var t=x.default.pid;Ru[e]=function(){var r=xe.format.apply(xe,arguments);console.error("%s %d: %s",e,t,r)}}else Ru[e]=function(){};return Ru[e]};function Gn(e,t){var r={seen:[],stylize:$O};return arguments.length>=3&&(r.depth=arguments[2]),arguments.length>=4&&(r.colors=arguments[3]),rh(t)?r.showHidden=t:t&&xe._extend(r,t),Ii(r.showHidden)&&(r.showHidden=!1),Ii(r.depth)&&(r.depth=2),Ii(r.colors)&&(r.colors=!1),Ii(r.customInspect)&&(r.customInspect=!0),r.colors&&(r.stylize=YO),Bu(r,e,r.depth)}xe.inspect=Gn;Gn.colors={bold:[1,22],italic:[3,23],underline:[4,24],inverse:[7,27],white:[37,39],grey:[90,39],black:[30,39],blue:[34,39],cyan:[36,39],green:[32,39],magenta:[35,39],red:[31,39],yellow:[33,39]};Gn.styles={special:"cyan",number:"yellow",boolean:"yellow",undefined:"grey",null:"bold",string:"green",date:"magenta",regexp:"red"};function YO(e,t){var r=Gn.styles[t];return r?"\x1B["+Gn.colors[r][0]+"m"+e+"\x1B["+Gn.colors[r][1]+"m":e}function $O(e,t){return e}function ZO(e){var t={};return e.forEach(function(r,n){t[r]=!0}),t}function Bu(e,t,r){if(e.customInspect&&t&&Pu(t.inspect)&&t.inspect!==xe.inspect&&!(t.constructor&&t.constructor.prototype===t)){var n=t.inspect(r,e);return ku(n)||(n=Bu(e,n,r)),n}var i=XO(e,t);if(i)return i;var o=Object.keys(t),s=ZO(o);if(e.showHidden&&(o=Object.getOwnPropertyNames(t)),As(t)&&(o.indexOf("message")>=0||o.indexOf("description")>=0))return Ql(t);if(o.length===0){if(Pu(t)){var a=t.name?": "+t.name:"";return e.stylize("[Function"+a+"]","special")}if(Is(t))return e.stylize(RegExp.prototype.toString.call(t),"regexp");if(Nu(t))return e.stylize(Date.prototype.toString.call(t),"date");if(As(t))return Ql(t)}var c="",h=!1,g=["{","}"];if(pm(t)&&(h=!0,g=["[","]"]),Pu(t)){var m=t.name?": "+t.name:"";c=" [Function"+m+"]"}if(Is(t)&&(c=" "+RegExp.prototype.toString.call(t)),Nu(t)&&(c=" "+Date.prototype.toUTCString.call(t)),As(t)&&(c=" "+Ql(t)),o.length===0&&(!h||t.length==0))return g[0]+c+g[1];if(r<0)return Is(t)?e.stylize(RegExp.prototype.toString.call(t),"regexp"):e.stylize("[Object]","special");e.seen.push(t);var _;return h?_=JO(e,t,r,s,o):_=o.map(function(I){return th(e,t,r,s,I,h)}),e.seen.pop(),QO(_,c,g)}function XO(e,t){if(Ii(t))return e.stylize("undefined","undefined");if(ku(t)){var r="'"+JSON.stringify(t).replace(/^"|"$/g,"").replace(/'/g,"\\'").replace(/\\"/g,'"')+"'";return e.stylize(r,"string")}if(gm(t))return e.stylize(""+t,"number");if(rh(t))return e.stylize(""+t,"boolean");if(Mu(t))return e.stylize("null","null")}function Ql(e){return"["+Error.prototype.toString.call(e)+"]"}function JO(e,t,r,n,i){for(var o=[],s=0,a=t.length;s<a;++s)ym(t,String(s))?o.push(th(e,t,r,n,String(s),!0)):o.push("");return i.forEach(function(c){c.match(/^\d+$/)||o.push(th(e,t,r,n,c,!0))}),o}function th(e,t,r,n,i,o){var s,a,c;if(c=Object.getOwnPropertyDescriptor(t,i)||{value:t[i]},c.get?c.set?a=e.stylize("[Getter/Setter]","special"):a=e.stylize("[Getter]","special"):c.set&&(a=e.stylize("[Setter]","special")),ym(n,i)||(s="["+i+"]"),a||(e.seen.indexOf(c.value)<0?(Mu(r)?a=Bu(e,c.value,null):a=Bu(e,c.value,r-1),a.indexOf(`
|
|
2
2
|
`)>-1&&(o?a=a.split(`
|
|
3
|
-
`).map(function(
|
|
3
|
+
`).map(function(h){return" "+h}).join(`
|
|
4
4
|
`).slice(2):a=`
|
|
5
5
|
`+a.split(`
|
|
6
|
-
`).map(function(
|
|
7
|
-
`))):a=e.stylize("[Circular]","special")),
|
|
6
|
+
`).map(function(h){return" "+h}).join(`
|
|
7
|
+
`))):a=e.stylize("[Circular]","special")),Ii(s)){if(o&&i.match(/^\d+$/))return a;s=JSON.stringify(""+i),s.match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)?(s=s.slice(1,-1),s=e.stylize(s,"name")):(s=s.replace(/'/g,"\\'").replace(/\\"/g,'"').replace(/(^"|"$)/g,"'"),s=e.stylize(s,"string"))}return s+": "+a}function QO(e,t,r){var n=0,i=e.reduce(function(o,s){return n++,s.indexOf(`
|
|
8
8
|
`)>=0&&n++,o+s.replace(/\u001b\[\d\d?m/g,"").length+1},0);return i>60?r[0]+(t===""?"":t+`
|
|
9
9
|
`)+" "+e.join(`,
|
|
10
|
-
`)+" "+r[1]:r[0]+t+" "+e.join(", ")+" "+r[1]}xe.types=fm();function pm(e){return Array.isArray(e)}xe.isArray=pm;function Wh(e){return typeof e=="boolean"}xe.isBoolean=Wh;function Cu(e){return e===null}xe.isNull=Cu;function DO(e){return e==null}xe.isNullOrUndefined=DO;function gm(e){return typeof e=="number"}xe.isNumber=gm;function Lu(e){return typeof e=="string"}xe.isString=Lu;function UO(e){return typeof e=="symbol"}xe.isSymbol=UO;function Oi(e){return e===void 0}xe.isUndefined=Oi;function Ts(e){return Ao(e)&&Yh(e)==="[object RegExp]"}xe.isRegExp=Ts;xe.types.isRegExp=Ts;function Ao(e){return typeof e=="object"&&e!==null}xe.isObject=Ao;function ku(e){return Ao(e)&&Yh(e)==="[object Date]"}xe.isDate=ku;xe.types.isDate=ku;function Ps(e){return Ao(e)&&(Yh(e)==="[object Error]"||e instanceof Error)}xe.isError=Ps;xe.types.isNativeError=Ps;function Nu(e){return typeof e=="function"}xe.isFunction=Nu;function qO(e){return e===null||typeof e=="boolean"||typeof e=="number"||typeof e=="string"||typeof e=="symbol"||typeof e>"u"}xe.isPrimitive=qO;xe.isBuffer=hm();function Yh(e){return Object.prototype.toString.call(e)}function Gh(e){return e<10?"0"+e.toString(10):e.toString(10)}var FO=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function HO(){var e=new Date,t=[Gh(e.getHours()),Gh(e.getMinutes()),Gh(e.getSeconds())].join(":");return[e.getDate(),FO[e.getMonth()],t].join(" ")}xe.log=function(){console.log("%s - %s",HO(),xe.format.apply(xe,arguments))};xe.inherits=Te();xe._extend=function(e,t){if(!t||!Ao(t))return e;for(var r=Object.keys(t),n=r.length;n--;)e[r[n]]=t[r[n]];return e};function ym(e,t){return Object.prototype.hasOwnProperty.call(e,t)}var Ai=typeof Symbol<"u"?Symbol("util.promisify.custom"):void 0;xe.promisify=function(t){if(typeof t!="function")throw new TypeError('The "original" argument must be of type Function');if(Ai&&t[Ai]){var r=t[Ai];if(typeof r!="function")throw new TypeError('The "util.promisify.custom" argument must be of type Function');return Object.defineProperty(r,Ai,{value:r,enumerable:!1,writable:!1,configurable:!0}),r}function r(){for(var n,i,o=new Promise(function(c,l){n=c,i=l}),s=[],a=0;a<arguments.length;a++)s.push(arguments[a]);s.push(function(c,l){c?i(c):n(l)});try{t.apply(this,s)}catch(c){i(c)}return o}return Object.setPrototypeOf(r,Object.getPrototypeOf(t)),Ai&&Object.defineProperty(r,Ai,{value:r,enumerable:!1,writable:!1,configurable:!0}),Object.defineProperties(r,lm(t))};xe.promisify.custom=Ai;function jO(e,t){if(!e){var r=new Error("Promise was rejected with a falsy value");r.reason=e,e=r}return t(e)}function KO(e){if(typeof e!="function")throw new TypeError('The "original" argument must be of type Function');function t(){for(var r=[],n=0;n<arguments.length;n++)r.push(arguments[n]);var i=r.pop();if(typeof i!="function")throw new TypeError("The last argument must be of type Function");var o=this,s=function(){return i.apply(o,arguments)};e.apply(this,r).then(function(a){I.default.nextTick(s.bind(null,null,a))},function(a){I.default.nextTick(jO.bind(null,a,s))})}return Object.setPrototypeOf(t,Object.getPrototypeOf(e)),Object.defineProperties(t,lm(e)),t}xe.callbackify=KO});var Sm=P((lL,wm)=>{"use strict";p();function mm(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(i){return Object.getOwnPropertyDescriptor(e,i).enumerable})),r.push.apply(r,n)}return r}function vm(e){for(var t=1;t<arguments.length;t++){var r=arguments[t]!=null?arguments[t]:{};t%2?mm(Object(r),!0).forEach(function(n){VO(e,n,r[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):mm(Object(r)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(r,n))})}return e}function VO(e,t,r){return t=_m(t),t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function GO(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function bm(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,_m(n.key),n)}}function zO(e,t,r){return t&&bm(e.prototype,t),r&&bm(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e}function _m(e){var t=WO(e,"string");return typeof t=="symbol"?t:String(t)}function WO(e,t){if(typeof e!="object"||e===null)return e;var r=e[Symbol.toPrimitive];if(r!==void 0){var n=r.call(e,t||"default");if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}var YO=Pt(),Du=YO.Buffer,$O=en(),$h=$O.inspect,ZO=$h&&$h.custom||"inspect";function XO(e,t,r){Du.prototype.copy.call(e,t,r)}wm.exports=(function(){function e(){GO(this,e),this.head=null,this.tail=null,this.length=0}return zO(e,[{key:"push",value:function(r){var n={data:r,next:null};this.length>0?this.tail.next=n:this.head=n,this.tail=n,++this.length}},{key:"unshift",value:function(r){var n={data:r,next:this.head};this.length===0&&(this.tail=n),this.head=n,++this.length}},{key:"shift",value:function(){if(this.length!==0){var r=this.head.data;return this.length===1?this.head=this.tail=null:this.head=this.head.next,--this.length,r}}},{key:"clear",value:function(){this.head=this.tail=null,this.length=0}},{key:"join",value:function(r){if(this.length===0)return"";for(var n=this.head,i=""+n.data;n=n.next;)i+=r+n.data;return i}},{key:"concat",value:function(r){if(this.length===0)return Du.alloc(0);for(var n=Du.allocUnsafe(r>>>0),i=this.head,o=0;i;)XO(i.data,n,o),o+=i.data.length,i=i.next;return n}},{key:"consume",value:function(r,n){var i;return r<this.head.data.length?(i=this.head.data.slice(0,r),this.head.data=this.head.data.slice(r)):r===this.head.data.length?i=this.shift():i=n?this._getString(r):this._getBuffer(r),i}},{key:"first",value:function(){return this.head.data}},{key:"_getString",value:function(r){var n=this.head,i=1,o=n.data;for(r-=o.length;n=n.next;){var s=n.data,a=r>s.length?s.length:r;if(a===s.length?o+=s:o+=s.slice(0,r),r-=a,r===0){a===s.length?(++i,n.next?this.head=n.next:this.head=this.tail=null):(this.head=n,n.data=s.slice(a));break}++i}return this.length-=i,o}},{key:"_getBuffer",value:function(r){var n=Du.allocUnsafe(r),i=this.head,o=1;for(i.data.copy(n),r-=i.data.length;i=i.next;){var s=i.data,a=r>s.length?s.length:r;if(s.copy(n,n.length-r,0,a),r-=a,r===0){a===s.length?(++o,i.next?this.head=i.next:this.head=this.tail=null):(this.head=i,i.data=s.slice(a));break}++o}return this.length-=o,n}},{key:ZO,value:function(r,n){return $h(this,vm(vm({},n),{},{depth:0,customInspect:!1}))}}]),e})()});var Xh=P((pL,xm)=>{"use strict";p();function JO(e,t){var r=this,n=this._readableState&&this._readableState.destroyed,i=this._writableState&&this._writableState.destroyed;return n||i?(t?t(e):e&&(this._writableState?this._writableState.errorEmitted||(this._writableState.errorEmitted=!0,I.default.nextTick(Zh,this,e)):I.default.nextTick(Zh,this,e)),this):(this._readableState&&(this._readableState.destroyed=!0),this._writableState&&(this._writableState.destroyed=!0),this._destroy(e||null,function(o){!t&&o?r._writableState?r._writableState.errorEmitted?I.default.nextTick(Uu,r):(r._writableState.errorEmitted=!0,I.default.nextTick(Em,r,o)):I.default.nextTick(Em,r,o):t?(I.default.nextTick(Uu,r),t(o)):I.default.nextTick(Uu,r)}),this)}function Em(e,t){Zh(e,t),Uu(e)}function Uu(e){e._writableState&&!e._writableState.emitClose||e._readableState&&!e._readableState.emitClose||e.emit("close")}function QO(){this._readableState&&(this._readableState.destroyed=!1,this._readableState.reading=!1,this._readableState.ended=!1,this._readableState.endEmitted=!1),this._writableState&&(this._writableState.destroyed=!1,this._writableState.ended=!1,this._writableState.ending=!1,this._writableState.finalCalled=!1,this._writableState.prefinished=!1,this._writableState.finished=!1,this._writableState.errorEmitted=!1)}function Zh(e,t){e.emit("error",t)}function eR(e,t){var r=e._readableState,n=e._writableState;r&&r.autoDestroy||n&&n.autoDestroy?e.destroy(t):e.emit("error",t)}xm.exports={destroy:JO,undestroy:QO,errorOrDestroy:eR}});var Ri=P((yL,Om)=>{"use strict";p();function tR(e,t){e.prototype=Object.create(t.prototype),e.prototype.constructor=e,e.__proto__=t}var Am={};function br(e,t,r){r||(r=Error);function n(o,s,a){return typeof t=="string"?t:t(o,s,a)}var i=(function(o){tR(s,o);function s(a,c,l){return o.call(this,n(a,c,l))||this}return s})(r);i.prototype.name=r.name,i.prototype.code=e,Am[e]=i}function Im(e,t){if(Array.isArray(e)){var r=e.length;return e=e.map(function(n){return String(n)}),r>2?"one of ".concat(t," ").concat(e.slice(0,r-1).join(", "),", or ")+e[r-1]:r===2?"one of ".concat(t," ").concat(e[0]," or ").concat(e[1]):"of ".concat(t," ").concat(e[0])}else return"of ".concat(t," ").concat(String(e))}function rR(e,t,r){return e.substr(!r||r<0?0:+r,t.length)===t}function nR(e,t,r){return(r===void 0||r>e.length)&&(r=e.length),e.substring(r-t.length,r)===t}function iR(e,t,r){return typeof r!="number"&&(r=0),r+t.length>e.length?!1:e.indexOf(t,r)!==-1}br("ERR_INVALID_OPT_VALUE",function(e,t){return'The value "'+t+'" is invalid for option "'+e+'"'},TypeError);br("ERR_INVALID_ARG_TYPE",function(e,t,r){var n;typeof t=="string"&&rR(t,"not ")?(n="must not be",t=t.replace(/^not /,"")):n="must be";var i;if(nR(e," argument"))i="The ".concat(e," ").concat(n," ").concat(Im(t,"type"));else{var o=iR(e,".")?"property":"argument";i='The "'.concat(e,'" ').concat(o," ").concat(n," ").concat(Im(t,"type"))}return i+=". Received type ".concat(typeof r),i},TypeError);br("ERR_STREAM_PUSH_AFTER_EOF","stream.push() after EOF");br("ERR_METHOD_NOT_IMPLEMENTED",function(e){return"The "+e+" method is not implemented"});br("ERR_STREAM_PREMATURE_CLOSE","Premature close");br("ERR_STREAM_DESTROYED",function(e){return"Cannot call "+e+" after a stream was destroyed"});br("ERR_MULTIPLE_CALLBACK","Callback called multiple times");br("ERR_STREAM_CANNOT_PIPE","Cannot pipe, not readable");br("ERR_STREAM_WRITE_AFTER_END","write after end");br("ERR_STREAM_NULL_VALUES","May not write null values to stream",TypeError);br("ERR_UNKNOWN_ENCODING",function(e){return"Unknown encoding: "+e},TypeError);br("ERR_STREAM_UNSHIFT_AFTER_END_EVENT","stream.unshift() after end event");Om.exports.codes=Am});var Jh=P((vL,Rm)=>{"use strict";p();var oR=Ri().codes.ERR_INVALID_OPT_VALUE;function sR(e,t,r){return e.highWaterMark!=null?e.highWaterMark:t?e[r]:null}function aR(e,t,r,n){var i=sR(t,n,r);if(i!=null){if(!(isFinite(i)&&Math.floor(i)===i)||i<0){var o=n?r:"highWaterMark";throw new oR(o,i)}return Math.floor(i)}return e.objectMode?16:16*1024}Rm.exports={getHighWaterMark:aR}});var el=P((_L,Tm)=>{p();Tm.exports=uR;function uR(e,t){if(Qh("noDeprecation"))return e;var r=!1;function n(){if(!r){if(Qh("throwDeprecation"))throw new Error(t);Qh("traceDeprecation")?console.trace(t):console.warn(t),r=!0}return e.apply(this,arguments)}return n}function Qh(e){try{if(!globalThis.localStorage)return!1}catch{return!1}var t=globalThis.localStorage[e];return t==null?!1:String(t).toLowerCase()==="true"}});var nl=P((SL,Cm)=>{"use strict";p();Cm.exports=Je;function Bm(e){var t=this;this.next=null,this.entry=null,this.finish=function(){CR(t,e)}}var Oo;Je.WritableState=Ns;var fR={deprecate:el()},Nm=yh(),Fu=Pt().Buffer,cR=(typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof self<"u"?self:{}).Uint8Array||function(){};function hR(e){return Fu.from(e)}function lR(e){return Fu.isBuffer(e)||e instanceof cR}var rl=Xh(),dR=Jh(),pR=dR.getHighWaterMark,Zn=Ri().codes,gR=Zn.ERR_INVALID_ARG_TYPE,yR=Zn.ERR_METHOD_NOT_IMPLEMENTED,mR=Zn.ERR_MULTIPLE_CALLBACK,vR=Zn.ERR_STREAM_CANNOT_PIPE,bR=Zn.ERR_STREAM_DESTROYED,_R=Zn.ERR_STREAM_NULL_VALUES,wR=Zn.ERR_STREAM_WRITE_AFTER_END,SR=Zn.ERR_UNKNOWN_ENCODING,Ro=rl.errorOrDestroy;Te()(Je,Nm);function ER(){}function Ns(e,t,r){Oo=Oo||Ti(),e=e||{},typeof r!="boolean"&&(r=t instanceof Oo),this.objectMode=!!e.objectMode,r&&(this.objectMode=this.objectMode||!!e.writableObjectMode),this.highWaterMark=pR(this,e,"writableHighWaterMark",r),this.finalCalled=!1,this.needDrain=!1,this.ending=!1,this.ended=!1,this.finished=!1,this.destroyed=!1;var n=e.decodeStrings===!1;this.decodeStrings=!n,this.defaultEncoding=e.defaultEncoding||"utf8",this.length=0,this.writing=!1,this.corked=0,this.sync=!0,this.bufferProcessing=!1,this.onwrite=function(i){PR(t,i)},this.writecb=null,this.writelen=0,this.bufferedRequest=null,this.lastBufferedRequest=null,this.pendingcb=0,this.prefinished=!1,this.errorEmitted=!1,this.emitClose=e.emitClose!==!1,this.autoDestroy=!!e.autoDestroy,this.bufferedRequestCount=0,this.corkedRequestsFree=new Bm(this)}Ns.prototype.getBuffer=function(){for(var t=this.bufferedRequest,r=[];t;)r.push(t),t=t.next;return r};(function(){try{Object.defineProperty(Ns.prototype,"buffer",{get:fR.deprecate(function(){return this.getBuffer()},"_writableState.buffer is deprecated. Use _writableState.getBuffer instead.","DEP0003")})}catch{}})();var qu;typeof Symbol=="function"&&Symbol.hasInstance&&typeof Function.prototype[Symbol.hasInstance]=="function"?(qu=Function.prototype[Symbol.hasInstance],Object.defineProperty(Je,Symbol.hasInstance,{value:function(t){return qu.call(this,t)?!0:this!==Je?!1:t&&t._writableState instanceof Ns}})):qu=function(t){return t instanceof this};function Je(e){Oo=Oo||Ti();var t=this instanceof Oo;if(!t&&!qu.call(Je,this))return new Je(e);this._writableState=new Ns(e,this,t),this.writable=!0,e&&(typeof e.write=="function"&&(this._write=e.write),typeof e.writev=="function"&&(this._writev=e.writev),typeof e.destroy=="function"&&(this._destroy=e.destroy),typeof e.final=="function"&&(this._final=e.final)),Nm.call(this)}Je.prototype.pipe=function(){Ro(this,new vR)};function xR(e,t){var r=new wR;Ro(e,r),I.default.nextTick(t,r)}function IR(e,t,r,n){var i;return r===null?i=new _R:typeof r!="string"&&!t.objectMode&&(i=new gR("chunk",["string","Buffer"],r)),i?(Ro(e,i),I.default.nextTick(n,i),!1):!0}Je.prototype.write=function(e,t,r){var n=this._writableState,i=!1,o=!n.objectMode&&lR(e);return o&&!Fu.isBuffer(e)&&(e=hR(e)),typeof t=="function"&&(r=t,t=null),o?t="buffer":t||(t=n.defaultEncoding),typeof r!="function"&&(r=ER),n.ending?xR(this,r):(o||IR(this,n,e,r))&&(n.pendingcb++,i=OR(this,n,o,e,t,r)),i};Je.prototype.cork=function(){this._writableState.corked++};Je.prototype.uncork=function(){var e=this._writableState;e.corked&&(e.corked--,!e.writing&&!e.corked&&!e.bufferProcessing&&e.bufferedRequest&&Mm(this,e))};Je.prototype.setDefaultEncoding=function(t){if(typeof t=="string"&&(t=t.toLowerCase()),!(["hex","utf8","utf-8","ascii","binary","base64","ucs2","ucs-2","utf16le","utf-16le","raw"].indexOf((t+"").toLowerCase())>-1))throw new SR(t);return this._writableState.defaultEncoding=t,this};Object.defineProperty(Je.prototype,"writableBuffer",{enumerable:!1,get:function(){return this._writableState&&this._writableState.getBuffer()}});function AR(e,t,r){return!e.objectMode&&e.decodeStrings!==!1&&typeof t=="string"&&(t=Fu.from(t,r)),t}Object.defineProperty(Je.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}});function OR(e,t,r,n,i,o){if(!r){var s=AR(t,n,i);n!==s&&(r=!0,i="buffer",n=s)}var a=t.objectMode?1:n.length;t.length+=a;var c=t.length<t.highWaterMark;if(c||(t.needDrain=!0),t.writing||t.corked){var l=t.lastBufferedRequest;t.lastBufferedRequest={chunk:n,encoding:i,isBuf:r,callback:o,next:null},l?l.next=t.lastBufferedRequest:t.bufferedRequest=t.lastBufferedRequest,t.bufferedRequestCount+=1}else tl(e,t,!1,a,n,i,o);return c}function tl(e,t,r,n,i,o,s){t.writelen=n,t.writecb=s,t.writing=!0,t.sync=!0,t.destroyed?t.onwrite(new bR("write")):r?e._writev(i,t.onwrite):e._write(i,o,t.onwrite),t.sync=!1}function RR(e,t,r,n,i){--t.pendingcb,r?(I.default.nextTick(i,n),I.default.nextTick(Bs,e,t),e._writableState.errorEmitted=!0,Ro(e,n)):(i(n),e._writableState.errorEmitted=!0,Ro(e,n),Bs(e,t))}function TR(e){e.writing=!1,e.writecb=null,e.length-=e.writelen,e.writelen=0}function PR(e,t){var r=e._writableState,n=r.sync,i=r.writecb;if(typeof i!="function")throw new mR;if(TR(r),t)RR(e,r,n,t,i);else{var o=km(r)||e.destroyed;!o&&!r.corked&&!r.bufferProcessing&&r.bufferedRequest&&Mm(e,r),n?I.default.nextTick(Pm,e,r,o,i):Pm(e,r,o,i)}}function Pm(e,t,r,n){r||BR(e,t),t.pendingcb--,n(),Bs(e,t)}function BR(e,t){t.length===0&&t.needDrain&&(t.needDrain=!1,e.emit("drain"))}function Mm(e,t){t.bufferProcessing=!0;var r=t.bufferedRequest;if(e._writev&&r&&r.next){var n=t.bufferedRequestCount,i=new Array(n),o=t.corkedRequestsFree;o.entry=r;for(var s=0,a=!0;r;)i[s]=r,r.isBuf||(a=!1),r=r.next,s+=1;i.allBuffers=a,tl(e,t,!0,t.length,i,"",o.finish),t.pendingcb++,t.lastBufferedRequest=null,o.next?(t.corkedRequestsFree=o.next,o.next=null):t.corkedRequestsFree=new Bm(t),t.bufferedRequestCount=0}else{for(;r;){var c=r.chunk,l=r.encoding,g=r.callback,m=t.objectMode?1:c.length;if(tl(e,t,!1,m,c,l,g),r=r.next,t.bufferedRequestCount--,t.writing)break}r===null&&(t.lastBufferedRequest=null)}t.bufferedRequest=r,t.bufferProcessing=!1}Je.prototype._write=function(e,t,r){r(new yR("_write()"))};Je.prototype._writev=null;Je.prototype.end=function(e,t,r){var n=this._writableState;return typeof e=="function"?(r=e,e=null,t=null):typeof t=="function"&&(r=t,t=null),e!=null&&this.write(e,t),n.corked&&(n.corked=1,this.uncork()),n.ending||kR(this,n,r),this};Object.defineProperty(Je.prototype,"writableLength",{enumerable:!1,get:function(){return this._writableState.length}});function km(e){return e.ending&&e.length===0&&e.bufferedRequest===null&&!e.finished&&!e.writing}function NR(e,t){e._final(function(r){t.pendingcb--,r&&Ro(e,r),t.prefinished=!0,e.emit("prefinish"),Bs(e,t)})}function MR(e,t){!t.prefinished&&!t.finalCalled&&(typeof e._final=="function"&&!t.destroyed?(t.pendingcb++,t.finalCalled=!0,I.default.nextTick(NR,e,t)):(t.prefinished=!0,e.emit("prefinish")))}function Bs(e,t){var r=km(t);if(r&&(MR(e,t),t.pendingcb===0&&(t.finished=!0,e.emit("finish"),t.autoDestroy))){var n=e._readableState;(!n||n.autoDestroy&&n.endEmitted)&&e.destroy()}return r}function kR(e,t,r){t.ending=!0,Bs(e,t),r&&(t.finished?I.default.nextTick(r):e.once("finish",r)),t.ended=!0,e.writable=!1}function CR(e,t,r){var n=e.entry;for(e.entry=null;n;){var i=n.callback;t.pendingcb--,i(r),n=n.next}t.corkedRequestsFree.next=e}Object.defineProperty(Je.prototype,"destroyed",{enumerable:!1,get:function(){return this._writableState===void 0?!1:this._writableState.destroyed},set:function(t){this._writableState&&(this._writableState.destroyed=t)}});Je.prototype.destroy=rl.destroy;Je.prototype._undestroy=rl.undestroy;Je.prototype._destroy=function(e,t){t(e)}});var Ti=P((xL,Dm)=>{"use strict";p();var LR=Object.keys||function(e){var t=[];for(var r in e)t.push(r);return t};Dm.exports=tn;var Lm=sl(),ol=nl();Te()(tn,Lm);for(il=LR(ol.prototype),Hu=0;Hu<il.length;Hu++)ju=il[Hu],tn.prototype[ju]||(tn.prototype[ju]=ol.prototype[ju]);var il,ju,Hu;function tn(e){if(!(this instanceof tn))return new tn(e);Lm.call(this,e),ol.call(this,e),this.allowHalfOpen=!0,e&&(e.readable===!1&&(this.readable=!1),e.writable===!1&&(this.writable=!1),e.allowHalfOpen===!1&&(this.allowHalfOpen=!1,this.once("end",DR)))}Object.defineProperty(tn.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}});Object.defineProperty(tn.prototype,"writableBuffer",{enumerable:!1,get:function(){return this._writableState&&this._writableState.getBuffer()}});Object.defineProperty(tn.prototype,"writableLength",{enumerable:!1,get:function(){return this._writableState.length}});function DR(){this._writableState.ended||I.default.nextTick(UR,this)}function UR(e){e.end()}Object.defineProperty(tn.prototype,"destroyed",{enumerable:!1,get:function(){return this._readableState===void 0||this._writableState===void 0?!1:this._readableState.destroyed&&this._writableState.destroyed},set:function(t){this._readableState===void 0||this._writableState===void 0||(this._readableState.destroyed=t,this._writableState.destroyed=t)}})});var Fm=P((al,qm)=>{p();var Ku=Pt(),En=Ku.Buffer;function Um(e,t){for(var r in e)t[r]=e[r]}En.from&&En.alloc&&En.allocUnsafe&&En.allocUnsafeSlow?qm.exports=Ku:(Um(Ku,al),al.Buffer=To);function To(e,t,r){return En(e,t,r)}Um(En,To);To.from=function(e,t,r){if(typeof e=="number")throw new TypeError("Argument must not be a number");return En(e,t,r)};To.alloc=function(e,t,r){if(typeof e!="number")throw new TypeError("Argument must be a number");var n=En(e);return t!==void 0?typeof r=="string"?n.fill(t,r):n.fill(t):n.fill(0),n};To.allocUnsafe=function(e){if(typeof e!="number")throw new TypeError("Argument must be a number");return En(e)};To.allocUnsafeSlow=function(e){if(typeof e!="number")throw new TypeError("Argument must be a number");return Ku.SlowBuffer(e)}});var Po=P(jm=>{"use strict";p();var fl=Fm().Buffer,Hm=fl.isEncoding||function(e){switch(e=""+e,e&&e.toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":case"raw":return!0;default:return!1}};function qR(e){if(!e)return"utf8";for(var t;;)switch(e){case"utf8":case"utf-8":return"utf8";case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return"utf16le";case"latin1":case"binary":return"latin1";case"base64":case"ascii":case"hex":return e;default:if(t)return;e=(""+e).toLowerCase(),t=!0}}function FR(e){var t=qR(e);if(typeof t!="string"&&(fl.isEncoding===Hm||!Hm(e)))throw new Error("Unknown encoding: "+e);return t||e}jm.StringDecoder=Ms;function Ms(e){this.encoding=FR(e);var t;switch(this.encoding){case"utf16le":this.text=zR,this.end=WR,t=4;break;case"utf8":this.fillLast=KR,t=4;break;case"base64":this.text=YR,this.end=$R,t=3;break;default:this.write=ZR,this.end=XR;return}this.lastNeed=0,this.lastTotal=0,this.lastChar=fl.allocUnsafe(t)}Ms.prototype.write=function(e){if(e.length===0)return"";var t,r;if(this.lastNeed){if(t=this.fillLast(e),t===void 0)return"";r=this.lastNeed,this.lastNeed=0}else r=0;return r<e.length?t?t+this.text(e,r):this.text(e,r):t||""};Ms.prototype.end=GR;Ms.prototype.text=VR;Ms.prototype.fillLast=function(e){if(this.lastNeed<=e.length)return e.copy(this.lastChar,this.lastTotal-this.lastNeed,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal);e.copy(this.lastChar,this.lastTotal-this.lastNeed,0,e.length),this.lastNeed-=e.length};function ul(e){return e<=127?0:e>>5===6?2:e>>4===14?3:e>>3===30?4:e>>6===2?-1:-2}function HR(e,t,r){var n=t.length-1;if(n<r)return 0;var i=ul(t[n]);return i>=0?(i>0&&(e.lastNeed=i-1),i):--n<r||i===-2?0:(i=ul(t[n]),i>=0?(i>0&&(e.lastNeed=i-2),i):--n<r||i===-2?0:(i=ul(t[n]),i>=0?(i>0&&(i===2?i=0:e.lastNeed=i-3),i):0))}function jR(e,t,r){if((t[0]&192)!==128)return e.lastNeed=0,"\uFFFD";if(e.lastNeed>1&&t.length>1){if((t[1]&192)!==128)return e.lastNeed=1,"\uFFFD";if(e.lastNeed>2&&t.length>2&&(t[2]&192)!==128)return e.lastNeed=2,"\uFFFD"}}function KR(e){var t=this.lastTotal-this.lastNeed,r=jR(this,e,t);if(r!==void 0)return r;if(this.lastNeed<=e.length)return e.copy(this.lastChar,t,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal);e.copy(this.lastChar,t,0,e.length),this.lastNeed-=e.length}function VR(e,t){var r=HR(this,e,t);if(!this.lastNeed)return e.toString("utf8",t);this.lastTotal=r;var n=e.length-(r-this.lastNeed);return e.copy(this.lastChar,0,n),e.toString("utf8",t,n)}function GR(e){var t=e&&e.length?this.write(e):"";return this.lastNeed?t+"\uFFFD":t}function zR(e,t){if((e.length-t)%2===0){var r=e.toString("utf16le",t);if(r){var n=r.charCodeAt(r.length-1);if(n>=55296&&n<=56319)return this.lastNeed=2,this.lastTotal=4,this.lastChar[0]=e[e.length-2],this.lastChar[1]=e[e.length-1],r.slice(0,-1)}return r}return this.lastNeed=1,this.lastTotal=2,this.lastChar[0]=e[e.length-1],e.toString("utf16le",t,e.length-1)}function WR(e){var t=e&&e.length?this.write(e):"";if(this.lastNeed){var r=this.lastTotal-this.lastNeed;return t+this.lastChar.toString("utf16le",0,r)}return t}function YR(e,t){var r=(e.length-t)%3;return r===0?e.toString("base64",t):(this.lastNeed=3-r,this.lastTotal=3,r===1?this.lastChar[0]=e[e.length-1]:(this.lastChar[0]=e[e.length-2],this.lastChar[1]=e[e.length-1]),e.toString("base64",t,e.length-r))}function $R(e){var t=e&&e.length?this.write(e):"";return this.lastNeed?t+this.lastChar.toString("base64",0,3-this.lastNeed):t}function ZR(e){return e.toString(this.encoding)}function XR(e){return e&&e.length?this.write(e):""}});var Vu=P((TL,Gm)=>{"use strict";p();var Km=Ri().codes.ERR_STREAM_PREMATURE_CLOSE;function JR(e){var t=!1;return function(){if(!t){t=!0;for(var r=arguments.length,n=new Array(r),i=0;i<r;i++)n[i]=arguments[i];e.apply(this,n)}}}function QR(){}function eT(e){return e.setHeader&&typeof e.abort=="function"}function Vm(e,t,r){if(typeof t=="function")return Vm(e,null,t);t||(t={}),r=JR(r||QR);var n=t.readable||t.readable!==!1&&e.readable,i=t.writable||t.writable!==!1&&e.writable,o=function(){e.writable||a()},s=e._writableState&&e._writableState.finished,a=function(){i=!1,s=!0,n||r.call(e)},c=e._readableState&&e._readableState.endEmitted,l=function(){n=!1,c=!0,i||r.call(e)},g=function(R){r.call(e,R)},m=function(){var R;if(n&&!c)return(!e._readableState||!e._readableState.ended)&&(R=new Km),r.call(e,R);if(i&&!s)return(!e._writableState||!e._writableState.ended)&&(R=new Km),r.call(e,R)},_=function(){e.req.on("finish",a)};return eT(e)?(e.on("complete",a),e.on("abort",m),e.req?_():e.on("request",_)):i&&!e._writableState&&(e.on("end",o),e.on("close",o)),e.on("end",l),e.on("finish",a),t.error!==!1&&e.on("error",g),e.on("close",m),function(){e.removeListener("complete",a),e.removeListener("abort",m),e.removeListener("request",_),e.req&&e.req.removeListener("finish",a),e.removeListener("end",o),e.removeListener("close",o),e.removeListener("finish",a),e.removeListener("end",l),e.removeListener("error",g),e.removeListener("close",m)}}Gm.exports=Vm});var Wm=P((BL,zm)=>{"use strict";p();var Gu;function Xn(e,t,r){return t=tT(t),t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function tT(e){var t=rT(e,"string");return typeof t=="symbol"?t:String(t)}function rT(e,t){if(typeof e!="object"||e===null)return e;var r=e[Symbol.toPrimitive];if(r!==void 0){var n=r.call(e,t||"default");if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}var nT=Vu(),Jn=Symbol("lastResolve"),Pi=Symbol("lastReject"),ks=Symbol("error"),zu=Symbol("ended"),Bi=Symbol("lastPromise"),cl=Symbol("handlePromise"),Ni=Symbol("stream");function Qn(e,t){return{value:e,done:t}}function iT(e){var t=e[Jn];if(t!==null){var r=e[Ni].read();r!==null&&(e[Bi]=null,e[Jn]=null,e[Pi]=null,t(Qn(r,!1)))}}function oT(e){I.default.nextTick(iT,e)}function sT(e,t){return function(r,n){e.then(function(){if(t[zu]){r(Qn(void 0,!0));return}t[cl](r,n)},n)}}var aT=Object.getPrototypeOf(function(){}),uT=Object.setPrototypeOf((Gu={get stream(){return this[Ni]},next:function(){var t=this,r=this[ks];if(r!==null)return Promise.reject(r);if(this[zu])return Promise.resolve(Qn(void 0,!0));if(this[Ni].destroyed)return new Promise(function(s,a){I.default.nextTick(function(){t[ks]?a(t[ks]):s(Qn(void 0,!0))})});var n=this[Bi],i;if(n)i=new Promise(sT(n,this));else{var o=this[Ni].read();if(o!==null)return Promise.resolve(Qn(o,!1));i=new Promise(this[cl])}return this[Bi]=i,i}},Xn(Gu,Symbol.asyncIterator,function(){return this}),Xn(Gu,"return",function(){var t=this;return new Promise(function(r,n){t[Ni].destroy(null,function(i){if(i){n(i);return}r(Qn(void 0,!0))})})}),Gu),aT),fT=function(t){var r,n=Object.create(uT,(r={},Xn(r,Ni,{value:t,writable:!0}),Xn(r,Jn,{value:null,writable:!0}),Xn(r,Pi,{value:null,writable:!0}),Xn(r,ks,{value:null,writable:!0}),Xn(r,zu,{value:t._readableState.endEmitted,writable:!0}),Xn(r,cl,{value:function(o,s){var a=n[Ni].read();a?(n[Bi]=null,n[Jn]=null,n[Pi]=null,o(Qn(a,!1))):(n[Jn]=o,n[Pi]=s)},writable:!0}),r));return n[Bi]=null,nT(t,function(i){if(i&&i.code!=="ERR_STREAM_PREMATURE_CLOSE"){var o=n[Pi];o!==null&&(n[Bi]=null,n[Jn]=null,n[Pi]=null,o(i)),n[ks]=i;return}var s=n[Jn];s!==null&&(n[Bi]=null,n[Jn]=null,n[Pi]=null,s(Qn(void 0,!0))),n[zu]=!0}),t.on("readable",oT.bind(null,n)),n};zm.exports=fT});var $m=P((ML,Ym)=>{p();Ym.exports=function(){throw new Error("Readable.from is not available in the browser")}});var sl=P((LL,ov)=>{"use strict";p();ov.exports=Pe;var Bo;Pe.ReadableState=Qm;var CL=mo().EventEmitter,Jm=function(t,r){return t.listeners(r).length},Ls=yh(),Wu=Pt().Buffer,cT=(typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof self<"u"?self:{}).Uint8Array||function(){};function hT(e){return Wu.from(e)}function lT(e){return Wu.isBuffer(e)||e instanceof cT}var hl=en(),_e;hl&&hl.debuglog?_e=hl.debuglog("stream"):_e=function(){};var dT=Sm(),vl=Xh(),pT=Jh(),gT=pT.getHighWaterMark,Yu=Ri().codes,yT=Yu.ERR_INVALID_ARG_TYPE,mT=Yu.ERR_STREAM_PUSH_AFTER_EOF,vT=Yu.ERR_METHOD_NOT_IMPLEMENTED,bT=Yu.ERR_STREAM_UNSHIFT_AFTER_END_EVENT,No,ll,dl;Te()(Pe,Ls);var Cs=vl.errorOrDestroy,pl=["error","close","destroy","pause","resume"];function _T(e,t,r){if(typeof e.prependListener=="function")return e.prependListener(t,r);!e._events||!e._events[t]?e.on(t,r):Array.isArray(e._events[t])?e._events[t].unshift(r):e._events[t]=[r,e._events[t]]}function Qm(e,t,r){Bo=Bo||Ti(),e=e||{},typeof r!="boolean"&&(r=t instanceof Bo),this.objectMode=!!e.objectMode,r&&(this.objectMode=this.objectMode||!!e.readableObjectMode),this.highWaterMark=gT(this,e,"readableHighWaterMark",r),this.buffer=new dT,this.length=0,this.pipes=null,this.pipesCount=0,this.flowing=null,this.ended=!1,this.endEmitted=!1,this.reading=!1,this.sync=!0,this.needReadable=!1,this.emittedReadable=!1,this.readableListening=!1,this.resumeScheduled=!1,this.paused=!0,this.emitClose=e.emitClose!==!1,this.autoDestroy=!!e.autoDestroy,this.destroyed=!1,this.defaultEncoding=e.defaultEncoding||"utf8",this.awaitDrain=0,this.readingMore=!1,this.decoder=null,this.encoding=null,e.encoding&&(No||(No=Po().StringDecoder),this.decoder=new No(e.encoding),this.encoding=e.encoding)}function Pe(e){if(Bo=Bo||Ti(),!(this instanceof Pe))return new Pe(e);var t=this instanceof Bo;this._readableState=new Qm(e,this,t),this.readable=!0,e&&(typeof e.read=="function"&&(this._read=e.read),typeof e.destroy=="function"&&(this._destroy=e.destroy)),Ls.call(this)}Object.defineProperty(Pe.prototype,"destroyed",{enumerable:!1,get:function(){return this._readableState===void 0?!1:this._readableState.destroyed},set:function(t){this._readableState&&(this._readableState.destroyed=t)}});Pe.prototype.destroy=vl.destroy;Pe.prototype._undestroy=vl.undestroy;Pe.prototype._destroy=function(e,t){t(e)};Pe.prototype.push=function(e,t){var r=this._readableState,n;return r.objectMode?n=!0:typeof e=="string"&&(t=t||r.defaultEncoding,t!==r.encoding&&(e=Wu.from(e,t),t=""),n=!0),ev(this,e,t,!1,n)};Pe.prototype.unshift=function(e){return ev(this,e,null,!0,!1)};function ev(e,t,r,n,i){_e("readableAddChunk",t);var o=e._readableState;if(t===null)o.reading=!1,ET(e,o);else{var s;if(i||(s=wT(o,t)),s)Cs(e,s);else if(o.objectMode||t&&t.length>0)if(typeof t!="string"&&!o.objectMode&&Object.getPrototypeOf(t)!==Wu.prototype&&(t=hT(t)),n)o.endEmitted?Cs(e,new bT):gl(e,o,t,!0);else if(o.ended)Cs(e,new mT);else{if(o.destroyed)return!1;o.reading=!1,o.decoder&&!r?(t=o.decoder.write(t),o.objectMode||t.length!==0?gl(e,o,t,!1):ml(e,o)):gl(e,o,t,!1)}else n||(o.reading=!1,ml(e,o))}return!o.ended&&(o.length<o.highWaterMark||o.length===0)}function gl(e,t,r,n){t.flowing&&t.length===0&&!t.sync?(t.awaitDrain=0,e.emit("data",r)):(t.length+=t.objectMode?1:r.length,n?t.buffer.unshift(r):t.buffer.push(r),t.needReadable&&$u(e)),ml(e,t)}function wT(e,t){var r;return!lT(t)&&typeof t!="string"&&t!==void 0&&!e.objectMode&&(r=new yT("chunk",["string","Buffer","Uint8Array"],t)),r}Pe.prototype.isPaused=function(){return this._readableState.flowing===!1};Pe.prototype.setEncoding=function(e){No||(No=Po().StringDecoder);var t=new No(e);this._readableState.decoder=t,this._readableState.encoding=this._readableState.decoder.encoding;for(var r=this._readableState.buffer.head,n="";r!==null;)n+=t.write(r.data),r=r.next;return this._readableState.buffer.clear(),n!==""&&this._readableState.buffer.push(n),this._readableState.length=n.length,this};var Zm=1073741824;function ST(e){return e>=Zm?e=Zm:(e--,e|=e>>>1,e|=e>>>2,e|=e>>>4,e|=e>>>8,e|=e>>>16,e++),e}function Xm(e,t){return e<=0||t.length===0&&t.ended?0:t.objectMode?1:e!==e?t.flowing&&t.length?t.buffer.head.data.length:t.length:(e>t.highWaterMark&&(t.highWaterMark=ST(e)),e<=t.length?e:t.ended?t.length:(t.needReadable=!0,0))}Pe.prototype.read=function(e){_e("read",e),e=parseInt(e,10);var t=this._readableState,r=e;if(e!==0&&(t.emittedReadable=!1),e===0&&t.needReadable&&((t.highWaterMark!==0?t.length>=t.highWaterMark:t.length>0)||t.ended))return _e("read: emitReadable",t.length,t.ended),t.length===0&&t.ended?yl(this):$u(this),null;if(e=Xm(e,t),e===0&&t.ended)return t.length===0&&yl(this),null;var n=t.needReadable;_e("need readable",n),(t.length===0||t.length-e<t.highWaterMark)&&(n=!0,_e("length less than watermark",n)),t.ended||t.reading?(n=!1,_e("reading or ended",n)):n&&(_e("do read"),t.reading=!0,t.sync=!0,t.length===0&&(t.needReadable=!0),this._read(t.highWaterMark),t.sync=!1,t.reading||(e=Xm(r,t)));var i;return e>0?i=nv(e,t):i=null,i===null?(t.needReadable=t.length<=t.highWaterMark,e=0):(t.length-=e,t.awaitDrain=0),t.length===0&&(t.ended||(t.needReadable=!0),r!==e&&t.ended&&yl(this)),i!==null&&this.emit("data",i),i};function ET(e,t){if(_e("onEofChunk"),!t.ended){if(t.decoder){var r=t.decoder.end();r&&r.length&&(t.buffer.push(r),t.length+=t.objectMode?1:r.length)}t.ended=!0,t.sync?$u(e):(t.needReadable=!1,t.emittedReadable||(t.emittedReadable=!0,tv(e)))}}function $u(e){var t=e._readableState;_e("emitReadable",t.needReadable,t.emittedReadable),t.needReadable=!1,t.emittedReadable||(_e("emitReadable",t.flowing),t.emittedReadable=!0,I.default.nextTick(tv,e))}function tv(e){var t=e._readableState;_e("emitReadable_",t.destroyed,t.length,t.ended),!t.destroyed&&(t.length||t.ended)&&(e.emit("readable"),t.emittedReadable=!1),t.needReadable=!t.flowing&&!t.ended&&t.length<=t.highWaterMark,bl(e)}function ml(e,t){t.readingMore||(t.readingMore=!0,I.default.nextTick(xT,e,t))}function xT(e,t){for(;!t.reading&&!t.ended&&(t.length<t.highWaterMark||t.flowing&&t.length===0);){var r=t.length;if(_e("maybeReadMore read 0"),e.read(0),r===t.length)break}t.readingMore=!1}Pe.prototype._read=function(e){Cs(this,new vT("_read()"))};Pe.prototype.pipe=function(e,t){var r=this,n=this._readableState;switch(n.pipesCount){case 0:n.pipes=e;break;case 1:n.pipes=[n.pipes,e];break;default:n.pipes.push(e);break}n.pipesCount+=1,_e("pipe count=%d opts=%j",n.pipesCount,t);var i=(!t||t.end!==!1)&&e!==I.default.stdout&&e!==I.default.stderr,o=i?a:B;n.endEmitted?I.default.nextTick(o):r.once("end",o),e.on("unpipe",s);function s(C,U){_e("onunpipe"),C===r&&U&&U.hasUnpiped===!1&&(U.hasUnpiped=!0,g())}function a(){_e("onend"),e.end()}var c=IT(r);e.on("drain",c);var l=!1;function g(){_e("cleanup"),e.removeListener("close",x),e.removeListener("finish",R),e.removeListener("drain",c),e.removeListener("error",_),e.removeListener("unpipe",s),r.removeListener("end",a),r.removeListener("end",B),r.removeListener("data",m),l=!0,n.awaitDrain&&(!e._writableState||e._writableState.needDrain)&&c()}r.on("data",m);function m(C){_e("ondata");var U=e.write(C);_e("dest.write",U),U===!1&&((n.pipesCount===1&&n.pipes===e||n.pipesCount>1&&iv(n.pipes,e)!==-1)&&!l&&(_e("false write response, pause",n.awaitDrain),n.awaitDrain++),r.pause())}function _(C){_e("onerror",C),B(),e.removeListener("error",_),Jm(e,"error")===0&&Cs(e,C)}_T(e,"error",_);function x(){e.removeListener("finish",R),B()}e.once("close",x);function R(){_e("onfinish"),e.removeListener("close",x),B()}e.once("finish",R);function B(){_e("unpipe"),r.unpipe(e)}return e.emit("pipe",r),n.flowing||(_e("pipe resume"),r.resume()),e};function IT(e){return function(){var r=e._readableState;_e("pipeOnDrain",r.awaitDrain),r.awaitDrain&&r.awaitDrain--,r.awaitDrain===0&&Jm(e,"data")&&(r.flowing=!0,bl(e))}}Pe.prototype.unpipe=function(e){var t=this._readableState,r={hasUnpiped:!1};if(t.pipesCount===0)return this;if(t.pipesCount===1)return e&&e!==t.pipes?this:(e||(e=t.pipes),t.pipes=null,t.pipesCount=0,t.flowing=!1,e&&e.emit("unpipe",this,r),this);if(!e){var n=t.pipes,i=t.pipesCount;t.pipes=null,t.pipesCount=0,t.flowing=!1;for(var o=0;o<i;o++)n[o].emit("unpipe",this,{hasUnpiped:!1});return this}var s=iv(t.pipes,e);return s===-1?this:(t.pipes.splice(s,1),t.pipesCount-=1,t.pipesCount===1&&(t.pipes=t.pipes[0]),e.emit("unpipe",this,r),this)};Pe.prototype.on=function(e,t){var r=Ls.prototype.on.call(this,e,t),n=this._readableState;return e==="data"?(n.readableListening=this.listenerCount("readable")>0,n.flowing!==!1&&this.resume()):e==="readable"&&!n.endEmitted&&!n.readableListening&&(n.readableListening=n.needReadable=!0,n.flowing=!1,n.emittedReadable=!1,_e("on readable",n.length,n.reading),n.length?$u(this):n.reading||I.default.nextTick(AT,this)),r};Pe.prototype.addListener=Pe.prototype.on;Pe.prototype.removeListener=function(e,t){var r=Ls.prototype.removeListener.call(this,e,t);return e==="readable"&&I.default.nextTick(rv,this),r};Pe.prototype.removeAllListeners=function(e){var t=Ls.prototype.removeAllListeners.apply(this,arguments);return(e==="readable"||e===void 0)&&I.default.nextTick(rv,this),t};function rv(e){var t=e._readableState;t.readableListening=e.listenerCount("readable")>0,t.resumeScheduled&&!t.paused?t.flowing=!0:e.listenerCount("data")>0&&e.resume()}function AT(e){_e("readable nexttick read 0"),e.read(0)}Pe.prototype.resume=function(){var e=this._readableState;return e.flowing||(_e("resume"),e.flowing=!e.readableListening,OT(this,e)),e.paused=!1,this};function OT(e,t){t.resumeScheduled||(t.resumeScheduled=!0,I.default.nextTick(RT,e,t))}function RT(e,t){_e("resume",t.reading),t.reading||e.read(0),t.resumeScheduled=!1,e.emit("resume"),bl(e),t.flowing&&!t.reading&&e.read(0)}Pe.prototype.pause=function(){return _e("call pause flowing=%j",this._readableState.flowing),this._readableState.flowing!==!1&&(_e("pause"),this._readableState.flowing=!1,this.emit("pause")),this._readableState.paused=!0,this};function bl(e){var t=e._readableState;for(_e("flow",t.flowing);t.flowing&&e.read()!==null;);}Pe.prototype.wrap=function(e){var t=this,r=this._readableState,n=!1;e.on("end",function(){if(_e("wrapped end"),r.decoder&&!r.ended){var s=r.decoder.end();s&&s.length&&t.push(s)}t.push(null)}),e.on("data",function(s){if(_e("wrapped data"),r.decoder&&(s=r.decoder.write(s)),!(r.objectMode&&s==null)&&!(!r.objectMode&&(!s||!s.length))){var a=t.push(s);a||(n=!0,e.pause())}});for(var i in e)this[i]===void 0&&typeof e[i]=="function"&&(this[i]=(function(a){return function(){return e[a].apply(e,arguments)}})(i));for(var o=0;o<pl.length;o++)e.on(pl[o],this.emit.bind(this,pl[o]));return this._read=function(s){_e("wrapped _read",s),n&&(n=!1,e.resume())},this};typeof Symbol=="function"&&(Pe.prototype[Symbol.asyncIterator]=function(){return ll===void 0&&(ll=Wm()),ll(this)});Object.defineProperty(Pe.prototype,"readableHighWaterMark",{enumerable:!1,get:function(){return this._readableState.highWaterMark}});Object.defineProperty(Pe.prototype,"readableBuffer",{enumerable:!1,get:function(){return this._readableState&&this._readableState.buffer}});Object.defineProperty(Pe.prototype,"readableFlowing",{enumerable:!1,get:function(){return this._readableState.flowing},set:function(t){this._readableState&&(this._readableState.flowing=t)}});Pe._fromList=nv;Object.defineProperty(Pe.prototype,"readableLength",{enumerable:!1,get:function(){return this._readableState.length}});function nv(e,t){if(t.length===0)return null;var r;return t.objectMode?r=t.buffer.shift():!e||e>=t.length?(t.decoder?r=t.buffer.join(""):t.buffer.length===1?r=t.buffer.first():r=t.buffer.concat(t.length),t.buffer.clear()):r=t.buffer.consume(e,t.decoder),r}function yl(e){var t=e._readableState;_e("endReadable",t.endEmitted),t.endEmitted||(t.ended=!0,I.default.nextTick(TT,t,e))}function TT(e,t){if(_e("endReadableNT",e.endEmitted,e.length),!e.endEmitted&&e.length===0&&(e.endEmitted=!0,t.readable=!1,t.emit("end"),e.autoDestroy)){var r=t._writableState;(!r||r.autoDestroy&&r.finished)&&t.destroy()}}typeof Symbol=="function"&&(Pe.from=function(e,t){return dl===void 0&&(dl=$m()),dl(Pe,e,t)});function iv(e,t){for(var r=0,n=e.length;r<n;r++)if(e[r]===t)return r;return-1}});var _l=P((UL,av)=>{"use strict";p();av.exports=xn;var Zu=Ri().codes,PT=Zu.ERR_METHOD_NOT_IMPLEMENTED,BT=Zu.ERR_MULTIPLE_CALLBACK,NT=Zu.ERR_TRANSFORM_ALREADY_TRANSFORMING,MT=Zu.ERR_TRANSFORM_WITH_LENGTH_0,Xu=Ti();Te()(xn,Xu);function kT(e,t){var r=this._transformState;r.transforming=!1;var n=r.writecb;if(n===null)return this.emit("error",new BT);r.writechunk=null,r.writecb=null,t!=null&&this.push(t),n(e);var i=this._readableState;i.reading=!1,(i.needReadable||i.length<i.highWaterMark)&&this._read(i.highWaterMark)}function xn(e){if(!(this instanceof xn))return new xn(e);Xu.call(this,e),this._transformState={afterTransform:kT.bind(this),needTransform:!1,transforming:!1,writecb:null,writechunk:null,writeencoding:null},this._readableState.needReadable=!0,this._readableState.sync=!1,e&&(typeof e.transform=="function"&&(this._transform=e.transform),typeof e.flush=="function"&&(this._flush=e.flush)),this.on("prefinish",CT)}function CT(){var e=this;typeof this._flush=="function"&&!this._readableState.destroyed?this._flush(function(t,r){sv(e,t,r)}):sv(this,null,null)}xn.prototype.push=function(e,t){return this._transformState.needTransform=!1,Xu.prototype.push.call(this,e,t)};xn.prototype._transform=function(e,t,r){r(new PT("_transform()"))};xn.prototype._write=function(e,t,r){var n=this._transformState;if(n.writecb=r,n.writechunk=e,n.writeencoding=t,!n.transforming){var i=this._readableState;(n.needTransform||i.needReadable||i.length<i.highWaterMark)&&this._read(i.highWaterMark)}};xn.prototype._read=function(e){var t=this._transformState;t.writechunk!==null&&!t.transforming?(t.transforming=!0,this._transform(t.writechunk,t.writeencoding,t.afterTransform)):t.needTransform=!0};xn.prototype._destroy=function(e,t){Xu.prototype._destroy.call(this,e,function(r){t(r)})};function sv(e,t,r){if(t)return e.emit("error",t);if(r!=null&&e.push(r),e._writableState.length)throw new MT;if(e._transformState.transforming)throw new NT;return e.push(null)}});var cv=P((FL,fv)=>{"use strict";p();fv.exports=Ds;var uv=_l();Te()(Ds,uv);function Ds(e){if(!(this instanceof Ds))return new Ds(e);uv.call(this,e)}Ds.prototype._transform=function(e,t,r){r(null,e)}});var gv=P((jL,pv)=>{"use strict";p();var wl;function LT(e){var t=!1;return function(){t||(t=!0,e.apply(void 0,arguments))}}var dv=Ri().codes,DT=dv.ERR_MISSING_ARGS,UT=dv.ERR_STREAM_DESTROYED;function hv(e){if(e)throw e}function qT(e){return e.setHeader&&typeof e.abort=="function"}function FT(e,t,r,n){n=LT(n);var i=!1;e.on("close",function(){i=!0}),wl===void 0&&(wl=Vu()),wl(e,{readable:t,writable:r},function(s){if(s)return n(s);i=!0,n()});var o=!1;return function(s){if(!i&&!o){if(o=!0,qT(e))return e.abort();if(typeof e.destroy=="function")return e.destroy();n(s||new UT("pipe"))}}}function lv(e){e()}function HT(e,t){return e.pipe(t)}function jT(e){return!e.length||typeof e[e.length-1]!="function"?hv:e.pop()}function KT(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];var n=jT(t);if(Array.isArray(t[0])&&(t=t[0]),t.length<2)throw new DT("streams");var i,o=t.map(function(s,a){var c=a<t.length-1,l=a>0;return FT(s,c,l,function(g){i||(i=g),g&&o.forEach(lv),!c&&(o.forEach(lv),n(i))})});return t.reduce(HT)}pv.exports=KT});var El=P((VL,yv)=>{p();yv.exports=_r;var Sl=mo().EventEmitter,VT=Te();VT(_r,Sl);_r.Readable=sl();_r.Writable=nl();_r.Duplex=Ti();_r.Transform=_l();_r.PassThrough=cv();_r.finished=Vu();_r.pipeline=gv();_r.Stream=_r;function _r(){Sl.call(this)}_r.prototype.pipe=function(e,t){var r=this;function n(g){e.writable&&e.write(g)===!1&&r.pause&&r.pause()}r.on("data",n);function i(){r.readable&&r.resume&&r.resume()}e.on("drain",i),!e._isStdio&&(!t||t.end!==!1)&&(r.on("end",s),r.on("close",a));var o=!1;function s(){o||(o=!0,e.end())}function a(){o||(o=!0,typeof e.destroy=="function"&&e.destroy())}function c(g){if(l(),Sl.listenerCount(this,"error")===0)throw g}r.on("error",c),e.on("error",c);function l(){r.removeListener("data",n),e.removeListener("drain",i),r.removeListener("end",s),r.removeListener("close",a),r.removeListener("error",c),e.removeListener("error",c),r.removeListener("end",l),r.removeListener("close",l),e.removeListener("close",l)}return r.on("end",l),r.on("close",l),e.on("close",l),e.emit("pipe",r),e}});var bv=P((zL,vv)=>{"use strict";p();var rn=Ct().Buffer,mv=El().Transform,GT=Te();function ei(e){mv.call(this),this._block=rn.allocUnsafe(e),this._blockSize=e,this._blockOffset=0,this._length=[0,0,0,0],this._finalized=!1}GT(ei,mv);ei.prototype._transform=function(e,t,r){var n=null;try{this.update(e,t)}catch(i){n=i}r(n)};ei.prototype._flush=function(e){var t=null;try{this.push(this.digest())}catch(r){t=r}e(t)};var zT=typeof Uint8Array<"u",WT=typeof ArrayBuffer<"u"&&typeof Uint8Array<"u"&&ArrayBuffer.isView&&(rn.prototype instanceof Uint8Array||rn.TYPED_ARRAY_SUPPORT);function YT(e,t){if(e instanceof rn)return e;if(typeof e=="string")return rn.from(e,t);if(WT&&ArrayBuffer.isView(e)){if(e.byteLength===0)return rn.alloc(0);var r=rn.from(e.buffer,e.byteOffset,e.byteLength);if(r.byteLength===e.byteLength)return r}if(zT&&e instanceof Uint8Array||rn.isBuffer(e)&&e.constructor&&typeof e.constructor.isBuffer=="function"&&e.constructor.isBuffer(e))return rn.from(e);throw new TypeError('The "data" argument must be of type string or an instance of Buffer, TypedArray, or DataView.')}ei.prototype.update=function(e,t){if(this._finalized)throw new Error("Digest already called");e=YT(e,t);for(var r=this._block,n=0;this._blockOffset+e.length-n>=this._blockSize;){for(var i=this._blockOffset;i<this._blockSize;)r[i++]=e[n++];this._update(),this._blockOffset=0}for(;n<e.length;)r[this._blockOffset++]=e[n++];for(var o=0,s=e.length*8;s>0;++o)this._length[o]+=s,s=this._length[o]/4294967296|0,s>0&&(this._length[o]-=4294967296*s);return this};ei.prototype._update=function(){throw new Error("_update is not implemented")};ei.prototype.digest=function(e){if(this._finalized)throw new Error("Digest already called");this._finalized=!0;var t=this._digest();e!==void 0&&(t=t.toString(e)),this._block.fill(0),this._blockOffset=0;for(var r=0;r<4;++r)this._length[r]=0;return t};ei.prototype._digest=function(){throw new Error("_digest is not implemented")};vv.exports=ei});var xl=P((YL,wv)=>{"use strict";p();var $T=Te(),_v=bv(),ZT=Ct().Buffer,XT=new Array(16);function Ju(){_v.call(this,64),this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878}$T(Ju,_v);Ju.prototype._update=function(){for(var e=XT,t=0;t<16;++t)e[t]=this._block.readInt32LE(t*4);var r=this._a,n=this._b,i=this._c,o=this._d;r=Gt(r,n,i,o,e[0],3614090360,7),o=Gt(o,r,n,i,e[1],3905402710,12),i=Gt(i,o,r,n,e[2],606105819,17),n=Gt(n,i,o,r,e[3],3250441966,22),r=Gt(r,n,i,o,e[4],4118548399,7),o=Gt(o,r,n,i,e[5],1200080426,12),i=Gt(i,o,r,n,e[6],2821735955,17),n=Gt(n,i,o,r,e[7],4249261313,22),r=Gt(r,n,i,o,e[8],1770035416,7),o=Gt(o,r,n,i,e[9],2336552879,12),i=Gt(i,o,r,n,e[10],4294925233,17),n=Gt(n,i,o,r,e[11],2304563134,22),r=Gt(r,n,i,o,e[12],1804603682,7),o=Gt(o,r,n,i,e[13],4254626195,12),i=Gt(i,o,r,n,e[14],2792965006,17),n=Gt(n,i,o,r,e[15],1236535329,22),r=zt(r,n,i,o,e[1],4129170786,5),o=zt(o,r,n,i,e[6],3225465664,9),i=zt(i,o,r,n,e[11],643717713,14),n=zt(n,i,o,r,e[0],3921069994,20),r=zt(r,n,i,o,e[5],3593408605,5),o=zt(o,r,n,i,e[10],38016083,9),i=zt(i,o,r,n,e[15],3634488961,14),n=zt(n,i,o,r,e[4],3889429448,20),r=zt(r,n,i,o,e[9],568446438,5),o=zt(o,r,n,i,e[14],3275163606,9),i=zt(i,o,r,n,e[3],4107603335,14),n=zt(n,i,o,r,e[8],1163531501,20),r=zt(r,n,i,o,e[13],2850285829,5),o=zt(o,r,n,i,e[2],4243563512,9),i=zt(i,o,r,n,e[7],1735328473,14),n=zt(n,i,o,r,e[12],2368359562,20),r=Wt(r,n,i,o,e[5],4294588738,4),o=Wt(o,r,n,i,e[8],2272392833,11),i=Wt(i,o,r,n,e[11],1839030562,16),n=Wt(n,i,o,r,e[14],4259657740,23),r=Wt(r,n,i,o,e[1],2763975236,4),o=Wt(o,r,n,i,e[4],1272893353,11),i=Wt(i,o,r,n,e[7],4139469664,16),n=Wt(n,i,o,r,e[10],3200236656,23),r=Wt(r,n,i,o,e[13],681279174,4),o=Wt(o,r,n,i,e[0],3936430074,11),i=Wt(i,o,r,n,e[3],3572445317,16),n=Wt(n,i,o,r,e[6],76029189,23),r=Wt(r,n,i,o,e[9],3654602809,4),o=Wt(o,r,n,i,e[12],3873151461,11),i=Wt(i,o,r,n,e[15],530742520,16),n=Wt(n,i,o,r,e[2],3299628645,23),r=Yt(r,n,i,o,e[0],4096336452,6),o=Yt(o,r,n,i,e[7],1126891415,10),i=Yt(i,o,r,n,e[14],2878612391,15),n=Yt(n,i,o,r,e[5],4237533241,21),r=Yt(r,n,i,o,e[12],1700485571,6),o=Yt(o,r,n,i,e[3],2399980690,10),i=Yt(i,o,r,n,e[10],4293915773,15),n=Yt(n,i,o,r,e[1],2240044497,21),r=Yt(r,n,i,o,e[8],1873313359,6),o=Yt(o,r,n,i,e[15],4264355552,10),i=Yt(i,o,r,n,e[6],2734768916,15),n=Yt(n,i,o,r,e[13],1309151649,21),r=Yt(r,n,i,o,e[4],4149444226,6),o=Yt(o,r,n,i,e[11],3174756917,10),i=Yt(i,o,r,n,e[2],718787259,15),n=Yt(n,i,o,r,e[9],3951481745,21),this._a=this._a+r|0,this._b=this._b+n|0,this._c=this._c+i|0,this._d=this._d+o|0};Ju.prototype._digest=function(){this._block[this._blockOffset++]=128,this._blockOffset>56&&(this._block.fill(0,this._blockOffset,64),this._update(),this._blockOffset=0),this._block.fill(0,this._blockOffset,56),this._block.writeUInt32LE(this._length[0],56),this._block.writeUInt32LE(this._length[1],60),this._update();var e=ZT.allocUnsafe(16);return e.writeInt32LE(this._a,0),e.writeInt32LE(this._b,4),e.writeInt32LE(this._c,8),e.writeInt32LE(this._d,12),e};function Qu(e,t){return e<<t|e>>>32-t}function Gt(e,t,r,n,i,o,s){return Qu(e+(t&r|~t&n)+i+o|0,s)+t|0}function zt(e,t,r,n,i,o,s){return Qu(e+(t&n|r&~n)+i+o|0,s)+t|0}function Wt(e,t,r,n,i,o,s){return Qu(e+(t^r^n)+i+o|0,s)+t|0}function Yt(e,t,r,n,i,o,s){return Qu(e+(r^(t|~n))+i+o|0,s)+t|0}wv.exports=Ju});var Ev=P((ZL,Sv)=>{p();var JT={}.toString;Sv.exports=Array.isArray||function(e){return JT.call(e)=="[object Array]"}});var Iv=P((JL,xv)=>{"use strict";p();var QT=Ei(),eP=Yn(),tP=eP("TypedArray.prototype.buffer",!0),rP=Hh();xv.exports=tP||function(t){if(!rP(t))throw new QT("Not a Typed Array");return t.buffer}});var ef=P((eD,Ov)=>{"use strict";p();var Br=Ct().Buffer,nP=Ev(),iP=Iv(),oP=ArrayBuffer.isView||function(t){try{return iP(t),!0}catch{return!1}},sP=typeof Uint8Array<"u",Av=typeof ArrayBuffer<"u"&&typeof Uint8Array<"u",aP=Av&&(Br.prototype instanceof Uint8Array||Br.TYPED_ARRAY_SUPPORT);Ov.exports=function(t,r){if(Br.isBuffer(t))return t.constructor&&!("isBuffer"in t)?Br.from(t):t;if(typeof t=="string")return Br.from(t,r);if(Av&&oP(t)){if(t.byteLength===0)return Br.alloc(0);if(aP){var n=Br.from(t.buffer,t.byteOffset,t.byteLength);if(n.byteLength===t.byteLength)return n}var i=t instanceof Uint8Array?t:new Uint8Array(t.buffer,t.byteOffset,t.byteLength),o=Br.from(i);if(o.length===t.byteLength)return o}if(sP&&t instanceof Uint8Array)return Br.from(t);var s=nP(t);if(s)for(var a=0;a<t.length;a+=1){var c=t[a];if(typeof c!="number"||c<0||c>255||~~c!==c)throw new RangeError("Array items must be numbers in the range 0-255.")}if(s||Br.isBuffer(t)&&t.constructor&&typeof t.constructor.isBuffer=="function"&&t.constructor.isBuffer(t))return Br.from(t);throw new TypeError('The "data" argument must be a string, an Array, a Buffer, a Uint8Array, or a DataView.')}});var Bv=P((rD,Pv)=>{"use strict";p();var uP=Ct().Buffer,fP=ef(),Tv=typeof Uint8Array<"u",cP=Tv&&typeof ArrayBuffer<"u",Rv=cP&&ArrayBuffer.isView;Pv.exports=function(e,t){if(typeof e=="string"||uP.isBuffer(e)||Tv&&e instanceof Uint8Array||Rv&&Rv(e))return fP(e,t);throw new TypeError('The "data" argument must be a string, a Buffer, a Uint8Array, or a DataView')}});var Us=P((iD,Il)=>{"use strict";p();typeof I.default>"u"||!I.default.version||I.default.version.indexOf("v0.")===0||I.default.version.indexOf("v1.")===0&&I.default.version.indexOf("v1.8.")!==0?Il.exports={nextTick:hP}:Il.exports=I.default;function hP(e,t,r,n){if(typeof e!="function")throw new TypeError('"callback" argument must be a function');var i=arguments.length,o,s;switch(i){case 0:case 1:return I.default.nextTick(e);case 2:return I.default.nextTick(function(){e.call(null,t)});case 3:return I.default.nextTick(function(){e.call(null,t,r)});case 4:return I.default.nextTick(function(){e.call(null,t,r,n)});default:for(o=new Array(i-1),s=0;s<o.length;)o[s++]=arguments[s];return I.default.nextTick(function(){e.apply(null,o)})}}});var Mv=P((sD,Nv)=>{p();var lP={}.toString;Nv.exports=Array.isArray||function(e){return lP.call(e)=="[object Array]"}});var Al=P((uD,kv)=>{p();kv.exports=mo().EventEmitter});var rf=P((Ol,Lv)=>{p();var tf=Pt(),In=tf.Buffer;function Cv(e,t){for(var r in e)t[r]=e[r]}In.from&&In.alloc&&In.allocUnsafe&&In.allocUnsafeSlow?Lv.exports=tf:(Cv(tf,Ol),Ol.Buffer=Mo);function Mo(e,t,r){return In(e,t,r)}Cv(In,Mo);Mo.from=function(e,t,r){if(typeof e=="number")throw new TypeError("Argument must not be a number");return In(e,t,r)};Mo.alloc=function(e,t,r){if(typeof e!="number")throw new TypeError("Argument must be a number");var n=In(e);return t!==void 0?typeof r=="string"?n.fill(t,r):n.fill(t):n.fill(0),n};Mo.allocUnsafe=function(e){if(typeof e!="number")throw new TypeError("Argument must be a number");return In(e)};Mo.allocUnsafeSlow=function(e){if(typeof e!="number")throw new TypeError("Argument must be a number");return tf.SlowBuffer(e)}});var ko=P($t=>{p();function dP(e){return Array.isArray?Array.isArray(e):nf(e)==="[object Array]"}$t.isArray=dP;function pP(e){return typeof e=="boolean"}$t.isBoolean=pP;function gP(e){return e===null}$t.isNull=gP;function yP(e){return e==null}$t.isNullOrUndefined=yP;function mP(e){return typeof e=="number"}$t.isNumber=mP;function vP(e){return typeof e=="string"}$t.isString=vP;function bP(e){return typeof e=="symbol"}$t.isSymbol=bP;function _P(e){return e===void 0}$t.isUndefined=_P;function wP(e){return nf(e)==="[object RegExp]"}$t.isRegExp=wP;function SP(e){return typeof e=="object"&&e!==null}$t.isObject=SP;function EP(e){return nf(e)==="[object Date]"}$t.isDate=EP;function xP(e){return nf(e)==="[object Error]"||e instanceof Error}$t.isError=xP;function IP(e){return typeof e=="function"}$t.isFunction=IP;function AP(e){return e===null||typeof e=="boolean"||typeof e=="number"||typeof e=="string"||typeof e=="symbol"||typeof e>"u"}$t.isPrimitive=AP;$t.isBuffer=Pt().Buffer.isBuffer;function nf(e){return Object.prototype.toString.call(e)}});var Uv=P((dD,Rl)=>{"use strict";p();function OP(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}var Dv=rf().Buffer,qs=en();function RP(e,t,r){e.copy(t,r)}Rl.exports=(function(){function e(){OP(this,e),this.head=null,this.tail=null,this.length=0}return e.prototype.push=function(r){var n={data:r,next:null};this.length>0?this.tail.next=n:this.head=n,this.tail=n,++this.length},e.prototype.unshift=function(r){var n={data:r,next:this.head};this.length===0&&(this.tail=n),this.head=n,++this.length},e.prototype.shift=function(){if(this.length!==0){var r=this.head.data;return this.length===1?this.head=this.tail=null:this.head=this.head.next,--this.length,r}},e.prototype.clear=function(){this.head=this.tail=null,this.length=0},e.prototype.join=function(r){if(this.length===0)return"";for(var n=this.head,i=""+n.data;n=n.next;)i+=r+n.data;return i},e.prototype.concat=function(r){if(this.length===0)return Dv.alloc(0);for(var n=Dv.allocUnsafe(r>>>0),i=this.head,o=0;i;)RP(i.data,n,o),o+=i.data.length,i=i.next;return n},e})();qs&&qs.inspect&&qs.inspect.custom&&(Rl.exports.prototype[qs.inspect.custom]=function(){var e=qs.inspect({length:this.length});return this.constructor.name+" "+e})});var Tl=P((gD,qv)=>{"use strict";p();var of=Us();function TP(e,t){var r=this,n=this._readableState&&this._readableState.destroyed,i=this._writableState&&this._writableState.destroyed;return n||i?(t?t(e):e&&(this._writableState?this._writableState.errorEmitted||(this._writableState.errorEmitted=!0,of.nextTick(sf,this,e)):of.nextTick(sf,this,e)),this):(this._readableState&&(this._readableState.destroyed=!0),this._writableState&&(this._writableState.destroyed=!0),this._destroy(e||null,function(o){!t&&o?r._writableState?r._writableState.errorEmitted||(r._writableState.errorEmitted=!0,of.nextTick(sf,r,o)):of.nextTick(sf,r,o):t&&t(o)}),this)}function PP(){this._readableState&&(this._readableState.destroyed=!1,this._readableState.reading=!1,this._readableState.ended=!1,this._readableState.endEmitted=!1),this._writableState&&(this._writableState.destroyed=!1,this._writableState.ended=!1,this._writableState.ending=!1,this._writableState.finalCalled=!1,this._writableState.prefinished=!1,this._writableState.finished=!1,this._writableState.errorEmitted=!1)}function sf(e,t){e.emit("error",t)}qv.exports={destroy:TP,undestroy:PP}});var Bl=P((mD,Wv)=>{"use strict";p();var Mi=Us();Wv.exports=xt;function Hv(e){var t=this;this.next=null,this.entry=null,this.finish=function(){YP(t,e)}}var BP=!I.default.browser&&["v0.10","v0.9."].indexOf(I.default.version.slice(0,5))>-1?setImmediate:Mi.nextTick,Co;xt.WritableState=Hs;var jv=Object.create(ko());jv.inherits=Te();var NP={deprecate:el()},Kv=Al(),uf=rf().Buffer,MP=(typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof self<"u"?self:{}).Uint8Array||function(){};function kP(e){return uf.from(e)}function CP(e){return uf.isBuffer(e)||e instanceof MP}var Vv=Tl();jv.inherits(xt,Kv);function LP(){}function Hs(e,t){Co=Co||ki(),e=e||{};var r=t instanceof Co;this.objectMode=!!e.objectMode,r&&(this.objectMode=this.objectMode||!!e.writableObjectMode);var n=e.highWaterMark,i=e.writableHighWaterMark,o=this.objectMode?16:16*1024;n||n===0?this.highWaterMark=n:r&&(i||i===0)?this.highWaterMark=i:this.highWaterMark=o,this.highWaterMark=Math.floor(this.highWaterMark),this.finalCalled=!1,this.needDrain=!1,this.ending=!1,this.ended=!1,this.finished=!1,this.destroyed=!1;var s=e.decodeStrings===!1;this.decodeStrings=!s,this.defaultEncoding=e.defaultEncoding||"utf8",this.length=0,this.writing=!1,this.corked=0,this.sync=!0,this.bufferProcessing=!1,this.onwrite=function(a){KP(t,a)},this.writecb=null,this.writelen=0,this.bufferedRequest=null,this.lastBufferedRequest=null,this.pendingcb=0,this.prefinished=!1,this.errorEmitted=!1,this.bufferedRequestCount=0,this.corkedRequestsFree=new Hv(this)}Hs.prototype.getBuffer=function(){for(var t=this.bufferedRequest,r=[];t;)r.push(t),t=t.next;return r};(function(){try{Object.defineProperty(Hs.prototype,"buffer",{get:NP.deprecate(function(){return this.getBuffer()},"_writableState.buffer is deprecated. Use _writableState.getBuffer instead.","DEP0003")})}catch{}})();var af;typeof Symbol=="function"&&Symbol.hasInstance&&typeof Function.prototype[Symbol.hasInstance]=="function"?(af=Function.prototype[Symbol.hasInstance],Object.defineProperty(xt,Symbol.hasInstance,{value:function(e){return af.call(this,e)?!0:this!==xt?!1:e&&e._writableState instanceof Hs}})):af=function(e){return e instanceof this};function xt(e){if(Co=Co||ki(),!af.call(xt,this)&&!(this instanceof Co))return new xt(e);this._writableState=new Hs(e,this),this.writable=!0,e&&(typeof e.write=="function"&&(this._write=e.write),typeof e.writev=="function"&&(this._writev=e.writev),typeof e.destroy=="function"&&(this._destroy=e.destroy),typeof e.final=="function"&&(this._final=e.final)),Kv.call(this)}xt.prototype.pipe=function(){this.emit("error",new Error("Cannot pipe, not readable"))};function DP(e,t){var r=new Error("write after end");e.emit("error",r),Mi.nextTick(t,r)}function UP(e,t,r,n){var i=!0,o=!1;return r===null?o=new TypeError("May not write null values to stream"):typeof r!="string"&&r!==void 0&&!t.objectMode&&(o=new TypeError("Invalid non-string/buffer chunk")),o&&(e.emit("error",o),Mi.nextTick(n,o),i=!1),i}xt.prototype.write=function(e,t,r){var n=this._writableState,i=!1,o=!n.objectMode&&CP(e);return o&&!uf.isBuffer(e)&&(e=kP(e)),typeof t=="function"&&(r=t,t=null),o?t="buffer":t||(t=n.defaultEncoding),typeof r!="function"&&(r=LP),n.ended?DP(this,r):(o||UP(this,n,e,r))&&(n.pendingcb++,i=FP(this,n,o,e,t,r)),i};xt.prototype.cork=function(){var e=this._writableState;e.corked++};xt.prototype.uncork=function(){var e=this._writableState;e.corked&&(e.corked--,!e.writing&&!e.corked&&!e.bufferProcessing&&e.bufferedRequest&&Gv(this,e))};xt.prototype.setDefaultEncoding=function(t){if(typeof t=="string"&&(t=t.toLowerCase()),!(["hex","utf8","utf-8","ascii","binary","base64","ucs2","ucs-2","utf16le","utf-16le","raw"].indexOf((t+"").toLowerCase())>-1))throw new TypeError("Unknown encoding: "+t);return this._writableState.defaultEncoding=t,this};function qP(e,t,r){return!e.objectMode&&e.decodeStrings!==!1&&typeof t=="string"&&(t=uf.from(t,r)),t}Object.defineProperty(xt.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}});function FP(e,t,r,n,i,o){if(!r){var s=qP(t,n,i);n!==s&&(r=!0,i="buffer",n=s)}var a=t.objectMode?1:n.length;t.length+=a;var c=t.length<t.highWaterMark;if(c||(t.needDrain=!0),t.writing||t.corked){var l=t.lastBufferedRequest;t.lastBufferedRequest={chunk:n,encoding:i,isBuf:r,callback:o,next:null},l?l.next=t.lastBufferedRequest:t.bufferedRequest=t.lastBufferedRequest,t.bufferedRequestCount+=1}else Pl(e,t,!1,a,n,i,o);return c}function Pl(e,t,r,n,i,o,s){t.writelen=n,t.writecb=s,t.writing=!0,t.sync=!0,r?e._writev(i,t.onwrite):e._write(i,o,t.onwrite),t.sync=!1}function HP(e,t,r,n,i){--t.pendingcb,r?(Mi.nextTick(i,n),Mi.nextTick(Fs,e,t),e._writableState.errorEmitted=!0,e.emit("error",n)):(i(n),e._writableState.errorEmitted=!0,e.emit("error",n),Fs(e,t))}function jP(e){e.writing=!1,e.writecb=null,e.length-=e.writelen,e.writelen=0}function KP(e,t){var r=e._writableState,n=r.sync,i=r.writecb;if(jP(r),t)HP(e,r,n,t,i);else{var o=zv(r);!o&&!r.corked&&!r.bufferProcessing&&r.bufferedRequest&&Gv(e,r),n?BP(Fv,e,r,o,i):Fv(e,r,o,i)}}function Fv(e,t,r,n){r||VP(e,t),t.pendingcb--,n(),Fs(e,t)}function VP(e,t){t.length===0&&t.needDrain&&(t.needDrain=!1,e.emit("drain"))}function Gv(e,t){t.bufferProcessing=!0;var r=t.bufferedRequest;if(e._writev&&r&&r.next){var n=t.bufferedRequestCount,i=new Array(n),o=t.corkedRequestsFree;o.entry=r;for(var s=0,a=!0;r;)i[s]=r,r.isBuf||(a=!1),r=r.next,s+=1;i.allBuffers=a,Pl(e,t,!0,t.length,i,"",o.finish),t.pendingcb++,t.lastBufferedRequest=null,o.next?(t.corkedRequestsFree=o.next,o.next=null):t.corkedRequestsFree=new Hv(t),t.bufferedRequestCount=0}else{for(;r;){var c=r.chunk,l=r.encoding,g=r.callback,m=t.objectMode?1:c.length;if(Pl(e,t,!1,m,c,l,g),r=r.next,t.bufferedRequestCount--,t.writing)break}r===null&&(t.lastBufferedRequest=null)}t.bufferedRequest=r,t.bufferProcessing=!1}xt.prototype._write=function(e,t,r){r(new Error("_write() is not implemented"))};xt.prototype._writev=null;xt.prototype.end=function(e,t,r){var n=this._writableState;typeof e=="function"?(r=e,e=null,t=null):typeof t=="function"&&(r=t,t=null),e!=null&&this.write(e,t),n.corked&&(n.corked=1,this.uncork()),n.ending||WP(this,n,r)};function zv(e){return e.ending&&e.length===0&&e.bufferedRequest===null&&!e.finished&&!e.writing}function GP(e,t){e._final(function(r){t.pendingcb--,r&&e.emit("error",r),t.prefinished=!0,e.emit("prefinish"),Fs(e,t)})}function zP(e,t){!t.prefinished&&!t.finalCalled&&(typeof e._final=="function"?(t.pendingcb++,t.finalCalled=!0,Mi.nextTick(GP,e,t)):(t.prefinished=!0,e.emit("prefinish")))}function Fs(e,t){var r=zv(t);return r&&(zP(e,t),t.pendingcb===0&&(t.finished=!0,e.emit("finish"))),r}function WP(e,t,r){t.ending=!0,Fs(e,t),r&&(t.finished?Mi.nextTick(r):e.once("finish",r)),t.ended=!0,e.writable=!1}function YP(e,t,r){var n=e.entry;for(e.entry=null;n;){var i=n.callback;t.pendingcb--,i(r),n=n.next}t.corkedRequestsFree.next=e}Object.defineProperty(xt.prototype,"destroyed",{get:function(){return this._writableState===void 0?!1:this._writableState.destroyed},set:function(e){this._writableState&&(this._writableState.destroyed=e)}});xt.prototype.destroy=Vv.destroy;xt.prototype._undestroy=Vv.undestroy;xt.prototype._destroy=function(e,t){this.end(),t(e)}});var ki=P((bD,Xv)=>{"use strict";p();var Yv=Us(),$P=Object.keys||function(e){var t=[];for(var r in e)t.push(r);return t};Xv.exports=An;var $v=Object.create(ko());$v.inherits=Te();var Zv=kl(),Ml=Bl();$v.inherits(An,Zv);for(Nl=$P(Ml.prototype),ff=0;ff<Nl.length;ff++)cf=Nl[ff],An.prototype[cf]||(An.prototype[cf]=Ml.prototype[cf]);var Nl,cf,ff;function An(e){if(!(this instanceof An))return new An(e);Zv.call(this,e),Ml.call(this,e),e&&e.readable===!1&&(this.readable=!1),e&&e.writable===!1&&(this.writable=!1),this.allowHalfOpen=!0,e&&e.allowHalfOpen===!1&&(this.allowHalfOpen=!1),this.once("end",ZP)}Object.defineProperty(An.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}});function ZP(){this.allowHalfOpen||this._writableState.ended||Yv.nextTick(XP,this)}function XP(e){e.end()}Object.defineProperty(An.prototype,"destroyed",{get:function(){return this._readableState===void 0||this._writableState===void 0?!1:this._readableState.destroyed&&this._writableState.destroyed},set:function(e){this._readableState===void 0||this._writableState===void 0||(this._readableState.destroyed=e,this._writableState.destroyed=e)}});An.prototype._destroy=function(e,t){this.push(null),this.end(),Yv.nextTick(t,e)}});var kl=P((SD,fb)=>{"use strict";p();var Do=Us();fb.exports=We;var JP=Mv(),js;We.ReadableState=ib;var wD=mo().EventEmitter,tb=function(e,t){return e.listeners(t).length},ql=Al(),Ks=rf().Buffer,QP=(typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof self<"u"?self:{}).Uint8Array||function(){};function eB(e){return Ks.from(e)}function tB(e){return Ks.isBuffer(e)||e instanceof QP}var rb=Object.create(ko());rb.inherits=Te();var Cl=en(),Me=void 0;Cl&&Cl.debuglog?Me=Cl.debuglog("stream"):Me=function(){};var rB=Uv(),nb=Tl(),Lo;rb.inherits(We,ql);var Ll=["error","close","destroy","pause","resume"];function nB(e,t,r){if(typeof e.prependListener=="function")return e.prependListener(t,r);!e._events||!e._events[t]?e.on(t,r):JP(e._events[t])?e._events[t].unshift(r):e._events[t]=[r,e._events[t]]}function ib(e,t){js=js||ki(),e=e||{};var r=t instanceof js;this.objectMode=!!e.objectMode,r&&(this.objectMode=this.objectMode||!!e.readableObjectMode);var n=e.highWaterMark,i=e.readableHighWaterMark,o=this.objectMode?16:16*1024;n||n===0?this.highWaterMark=n:r&&(i||i===0)?this.highWaterMark=i:this.highWaterMark=o,this.highWaterMark=Math.floor(this.highWaterMark),this.buffer=new rB,this.length=0,this.pipes=null,this.pipesCount=0,this.flowing=null,this.ended=!1,this.endEmitted=!1,this.reading=!1,this.sync=!0,this.needReadable=!1,this.emittedReadable=!1,this.readableListening=!1,this.resumeScheduled=!1,this.destroyed=!1,this.defaultEncoding=e.defaultEncoding||"utf8",this.awaitDrain=0,this.readingMore=!1,this.decoder=null,this.encoding=null,e.encoding&&(Lo||(Lo=Po().StringDecoder),this.decoder=new Lo(e.encoding),this.encoding=e.encoding)}function We(e){if(js=js||ki(),!(this instanceof We))return new We(e);this._readableState=new ib(e,this),this.readable=!0,e&&(typeof e.read=="function"&&(this._read=e.read),typeof e.destroy=="function"&&(this._destroy=e.destroy)),ql.call(this)}Object.defineProperty(We.prototype,"destroyed",{get:function(){return this._readableState===void 0?!1:this._readableState.destroyed},set:function(e){this._readableState&&(this._readableState.destroyed=e)}});We.prototype.destroy=nb.destroy;We.prototype._undestroy=nb.undestroy;We.prototype._destroy=function(e,t){this.push(null),t(e)};We.prototype.push=function(e,t){var r=this._readableState,n;return r.objectMode?n=!0:typeof e=="string"&&(t=t||r.defaultEncoding,t!==r.encoding&&(e=Ks.from(e,t),t=""),n=!0),ob(this,e,t,!1,n)};We.prototype.unshift=function(e){return ob(this,e,null,!0,!1)};function ob(e,t,r,n,i){var o=e._readableState;if(t===null)o.reading=!1,aB(e,o);else{var s;i||(s=iB(o,t)),s?e.emit("error",s):o.objectMode||t&&t.length>0?(typeof t!="string"&&!o.objectMode&&Object.getPrototypeOf(t)!==Ks.prototype&&(t=eB(t)),n?o.endEmitted?e.emit("error",new Error("stream.unshift() after end event")):Dl(e,o,t,!0):o.ended?e.emit("error",new Error("stream.push() after EOF")):(o.reading=!1,o.decoder&&!r?(t=o.decoder.write(t),o.objectMode||t.length!==0?Dl(e,o,t,!1):sb(e,o)):Dl(e,o,t,!1))):n||(o.reading=!1)}return oB(o)}function Dl(e,t,r,n){t.flowing&&t.length===0&&!t.sync?(e.emit("data",r),e.read(0)):(t.length+=t.objectMode?1:r.length,n?t.buffer.unshift(r):t.buffer.push(r),t.needReadable&&hf(e)),sb(e,t)}function iB(e,t){var r;return!tB(t)&&typeof t!="string"&&t!==void 0&&!e.objectMode&&(r=new TypeError("Invalid non-string/buffer chunk")),r}function oB(e){return!e.ended&&(e.needReadable||e.length<e.highWaterMark||e.length===0)}We.prototype.isPaused=function(){return this._readableState.flowing===!1};We.prototype.setEncoding=function(e){return Lo||(Lo=Po().StringDecoder),this._readableState.decoder=new Lo(e),this._readableState.encoding=e,this};var Jv=8388608;function sB(e){return e>=Jv?e=Jv:(e--,e|=e>>>1,e|=e>>>2,e|=e>>>4,e|=e>>>8,e|=e>>>16,e++),e}function Qv(e,t){return e<=0||t.length===0&&t.ended?0:t.objectMode?1:e!==e?t.flowing&&t.length?t.buffer.head.data.length:t.length:(e>t.highWaterMark&&(t.highWaterMark=sB(e)),e<=t.length?e:t.ended?t.length:(t.needReadable=!0,0))}We.prototype.read=function(e){Me("read",e),e=parseInt(e,10);var t=this._readableState,r=e;if(e!==0&&(t.emittedReadable=!1),e===0&&t.needReadable&&(t.length>=t.highWaterMark||t.ended))return Me("read: emitReadable",t.length,t.ended),t.length===0&&t.ended?Ul(this):hf(this),null;if(e=Qv(e,t),e===0&&t.ended)return t.length===0&&Ul(this),null;var n=t.needReadable;Me("need readable",n),(t.length===0||t.length-e<t.highWaterMark)&&(n=!0,Me("length less than watermark",n)),t.ended||t.reading?(n=!1,Me("reading or ended",n)):n&&(Me("do read"),t.reading=!0,t.sync=!0,t.length===0&&(t.needReadable=!0),this._read(t.highWaterMark),t.sync=!1,t.reading||(e=Qv(r,t)));var i;return e>0?i=ab(e,t):i=null,i===null?(t.needReadable=!0,e=0):t.length-=e,t.length===0&&(t.ended||(t.needReadable=!0),r!==e&&t.ended&&Ul(this)),i!==null&&this.emit("data",i),i};function aB(e,t){if(!t.ended){if(t.decoder){var r=t.decoder.end();r&&r.length&&(t.buffer.push(r),t.length+=t.objectMode?1:r.length)}t.ended=!0,hf(e)}}function hf(e){var t=e._readableState;t.needReadable=!1,t.emittedReadable||(Me("emitReadable",t.flowing),t.emittedReadable=!0,t.sync?Do.nextTick(eb,e):eb(e))}function eb(e){Me("emit readable"),e.emit("readable"),Fl(e)}function sb(e,t){t.readingMore||(t.readingMore=!0,Do.nextTick(uB,e,t))}function uB(e,t){for(var r=t.length;!t.reading&&!t.flowing&&!t.ended&&t.length<t.highWaterMark&&(Me("maybeReadMore read 0"),e.read(0),r!==t.length);)r=t.length;t.readingMore=!1}We.prototype._read=function(e){this.emit("error",new Error("_read() is not implemented"))};We.prototype.pipe=function(e,t){var r=this,n=this._readableState;switch(n.pipesCount){case 0:n.pipes=e;break;case 1:n.pipes=[n.pipes,e];break;default:n.pipes.push(e);break}n.pipesCount+=1,Me("pipe count=%d opts=%j",n.pipesCount,t);var i=(!t||t.end!==!1)&&e!==I.default.stdout&&e!==I.default.stderr,o=i?a:C;n.endEmitted?Do.nextTick(o):r.once("end",o),e.on("unpipe",s);function s(U,V){Me("onunpipe"),U===r&&V&&V.hasUnpiped===!1&&(V.hasUnpiped=!0,g())}function a(){Me("onend"),e.end()}var c=fB(r);e.on("drain",c);var l=!1;function g(){Me("cleanup"),e.removeListener("close",R),e.removeListener("finish",B),e.removeListener("drain",c),e.removeListener("error",x),e.removeListener("unpipe",s),r.removeListener("end",a),r.removeListener("end",C),r.removeListener("data",_),l=!0,n.awaitDrain&&(!e._writableState||e._writableState.needDrain)&&c()}var m=!1;r.on("data",_);function _(U){Me("ondata"),m=!1;var V=e.write(U);V===!1&&!m&&((n.pipesCount===1&&n.pipes===e||n.pipesCount>1&&ub(n.pipes,e)!==-1)&&!l&&(Me("false write response, pause",n.awaitDrain),n.awaitDrain++,m=!0),r.pause())}function x(U){Me("onerror",U),C(),e.removeListener("error",x),tb(e,"error")===0&&e.emit("error",U)}nB(e,"error",x);function R(){e.removeListener("finish",B),C()}e.once("close",R);function B(){Me("onfinish"),e.removeListener("close",R),C()}e.once("finish",B);function C(){Me("unpipe"),r.unpipe(e)}return e.emit("pipe",r),n.flowing||(Me("pipe resume"),r.resume()),e};function fB(e){return function(){var t=e._readableState;Me("pipeOnDrain",t.awaitDrain),t.awaitDrain&&t.awaitDrain--,t.awaitDrain===0&&tb(e,"data")&&(t.flowing=!0,Fl(e))}}We.prototype.unpipe=function(e){var t=this._readableState,r={hasUnpiped:!1};if(t.pipesCount===0)return this;if(t.pipesCount===1)return e&&e!==t.pipes?this:(e||(e=t.pipes),t.pipes=null,t.pipesCount=0,t.flowing=!1,e&&e.emit("unpipe",this,r),this);if(!e){var n=t.pipes,i=t.pipesCount;t.pipes=null,t.pipesCount=0,t.flowing=!1;for(var o=0;o<i;o++)n[o].emit("unpipe",this,{hasUnpiped:!1});return this}var s=ub(t.pipes,e);return s===-1?this:(t.pipes.splice(s,1),t.pipesCount-=1,t.pipesCount===1&&(t.pipes=t.pipes[0]),e.emit("unpipe",this,r),this)};We.prototype.on=function(e,t){var r=ql.prototype.on.call(this,e,t);if(e==="data")this._readableState.flowing!==!1&&this.resume();else if(e==="readable"){var n=this._readableState;!n.endEmitted&&!n.readableListening&&(n.readableListening=n.needReadable=!0,n.emittedReadable=!1,n.reading?n.length&&hf(this):Do.nextTick(cB,this))}return r};We.prototype.addListener=We.prototype.on;function cB(e){Me("readable nexttick read 0"),e.read(0)}We.prototype.resume=function(){var e=this._readableState;return e.flowing||(Me("resume"),e.flowing=!0,hB(this,e)),this};function hB(e,t){t.resumeScheduled||(t.resumeScheduled=!0,Do.nextTick(lB,e,t))}function lB(e,t){t.reading||(Me("resume read 0"),e.read(0)),t.resumeScheduled=!1,t.awaitDrain=0,e.emit("resume"),Fl(e),t.flowing&&!t.reading&&e.read(0)}We.prototype.pause=function(){return Me("call pause flowing=%j",this._readableState.flowing),this._readableState.flowing!==!1&&(Me("pause"),this._readableState.flowing=!1,this.emit("pause")),this};function Fl(e){var t=e._readableState;for(Me("flow",t.flowing);t.flowing&&e.read()!==null;);}We.prototype.wrap=function(e){var t=this,r=this._readableState,n=!1;e.on("end",function(){if(Me("wrapped end"),r.decoder&&!r.ended){var s=r.decoder.end();s&&s.length&&t.push(s)}t.push(null)}),e.on("data",function(s){if(Me("wrapped data"),r.decoder&&(s=r.decoder.write(s)),!(r.objectMode&&s==null)&&!(!r.objectMode&&(!s||!s.length))){var a=t.push(s);a||(n=!0,e.pause())}});for(var i in e)this[i]===void 0&&typeof e[i]=="function"&&(this[i]=(function(s){return function(){return e[s].apply(e,arguments)}})(i));for(var o=0;o<Ll.length;o++)e.on(Ll[o],this.emit.bind(this,Ll[o]));return this._read=function(s){Me("wrapped _read",s),n&&(n=!1,e.resume())},this};Object.defineProperty(We.prototype,"readableHighWaterMark",{enumerable:!1,get:function(){return this._readableState.highWaterMark}});We._fromList=ab;function ab(e,t){if(t.length===0)return null;var r;return t.objectMode?r=t.buffer.shift():!e||e>=t.length?(t.decoder?r=t.buffer.join(""):t.buffer.length===1?r=t.buffer.head.data:r=t.buffer.concat(t.length),t.buffer.clear()):r=dB(e,t.buffer,t.decoder),r}function dB(e,t,r){var n;return e<t.head.data.length?(n=t.head.data.slice(0,e),t.head.data=t.head.data.slice(e)):e===t.head.data.length?n=t.shift():n=r?pB(e,t):gB(e,t),n}function pB(e,t){var r=t.head,n=1,i=r.data;for(e-=i.length;r=r.next;){var o=r.data,s=e>o.length?o.length:e;if(s===o.length?i+=o:i+=o.slice(0,e),e-=s,e===0){s===o.length?(++n,r.next?t.head=r.next:t.head=t.tail=null):(t.head=r,r.data=o.slice(s));break}++n}return t.length-=n,i}function gB(e,t){var r=Ks.allocUnsafe(e),n=t.head,i=1;for(n.data.copy(r),e-=n.data.length;n=n.next;){var o=n.data,s=e>o.length?o.length:e;if(o.copy(r,r.length-e,0,s),e-=s,e===0){s===o.length?(++i,n.next?t.head=n.next:t.head=t.tail=null):(t.head=n,n.data=o.slice(s));break}++i}return t.length-=i,r}function Ul(e){var t=e._readableState;if(t.length>0)throw new Error('"endReadable()" called on non-empty stream');t.endEmitted||(t.ended=!0,Do.nextTick(yB,t,e))}function yB(e,t){!e.endEmitted&&e.length===0&&(e.endEmitted=!0,t.readable=!1,t.emit("end"))}function ub(e,t){for(var r=0,n=e.length;r<n;r++)if(e[r]===t)return r;return-1}});var Hl=P((xD,lb)=>{"use strict";p();lb.exports=On;var lf=ki(),hb=Object.create(ko());hb.inherits=Te();hb.inherits(On,lf);function mB(e,t){var r=this._transformState;r.transforming=!1;var n=r.writecb;if(!n)return this.emit("error",new Error("write callback called multiple times"));r.writechunk=null,r.writecb=null,t!=null&&this.push(t),n(e);var i=this._readableState;i.reading=!1,(i.needReadable||i.length<i.highWaterMark)&&this._read(i.highWaterMark)}function On(e){if(!(this instanceof On))return new On(e);lf.call(this,e),this._transformState={afterTransform:mB.bind(this),needTransform:!1,transforming:!1,writecb:null,writechunk:null,writeencoding:null},this._readableState.needReadable=!0,this._readableState.sync=!1,e&&(typeof e.transform=="function"&&(this._transform=e.transform),typeof e.flush=="function"&&(this._flush=e.flush)),this.on("prefinish",vB)}function vB(){var e=this;typeof this._flush=="function"?this._flush(function(t,r){cb(e,t,r)}):cb(this,null,null)}On.prototype.push=function(e,t){return this._transformState.needTransform=!1,lf.prototype.push.call(this,e,t)};On.prototype._transform=function(e,t,r){throw new Error("_transform() is not implemented")};On.prototype._write=function(e,t,r){var n=this._transformState;if(n.writecb=r,n.writechunk=e,n.writeencoding=t,!n.transforming){var i=this._readableState;(n.needTransform||i.needReadable||i.length<i.highWaterMark)&&this._read(i.highWaterMark)}};On.prototype._read=function(e){var t=this._transformState;t.writechunk!==null&&t.writecb&&!t.transforming?(t.transforming=!0,this._transform(t.writechunk,t.writeencoding,t.afterTransform)):t.needTransform=!0};On.prototype._destroy=function(e,t){var r=this;lf.prototype._destroy.call(this,e,function(n){t(n),r.emit("close")})};function cb(e,t,r){if(t)return e.emit("error",t);if(r!=null&&e.push(r),e._writableState.length)throw new Error("Calling transform done when ws.length != 0");if(e._transformState.transforming)throw new Error("Calling transform done when still transforming");return e.push(null)}});var yb=P((AD,gb)=>{"use strict";p();gb.exports=Vs;var db=Hl(),pb=Object.create(ko());pb.inherits=Te();pb.inherits(Vs,db);function Vs(e){if(!(this instanceof Vs))return new Vs(e);db.call(this,e)}Vs.prototype._transform=function(e,t,r){r(null,e)}});var vb=P((nn,mb)=>{p();nn=mb.exports=kl();nn.Stream=nn;nn.Readable=nn;nn.Writable=Bl();nn.Duplex=ki();nn.Transform=Hl();nn.PassThrough=yb()});var wb=P((TD,_b)=>{"use strict";p();var bB=Ct().Buffer,_B=Bv(),bb=vb().Transform,wB=Te();function ti(e){bb.call(this),this._block=bB.allocUnsafe(e),this._blockSize=e,this._blockOffset=0,this._length=[0,0,0,0],this._finalized=!1}wB(ti,bb);ti.prototype._transform=function(e,t,r){var n=null;try{this.update(e,t)}catch(i){n=i}r(n)};ti.prototype._flush=function(e){var t=null;try{this.push(this.digest())}catch(r){t=r}e(t)};ti.prototype.update=function(e,t){if(this._finalized)throw new Error("Digest already called");for(var r=_B(e,t),n=this._block,i=0;this._blockOffset+r.length-i>=this._blockSize;){for(var o=this._blockOffset;o<this._blockSize;)n[o]=r[i],o+=1,i+=1;this._update(),this._blockOffset=0}for(;i<r.length;)n[this._blockOffset]=r[i],this._blockOffset+=1,i+=1;for(var s=0,a=r.length*8;a>0;++s)this._length[s]+=a,a=this._length[s]/4294967296|0,a>0&&(this._length[s]-=4294967296*a);return this};ti.prototype._update=function(){throw new Error("_update is not implemented")};ti.prototype.digest=function(e){if(this._finalized)throw new Error("Digest already called");this._finalized=!0;var t=this._digest();e!==void 0&&(t=t.toString(e)),this._block.fill(0),this._blockOffset=0;for(var r=0;r<4;++r)this._length[r]=0;return t};ti.prototype._digest=function(){throw new Error("_digest is not implemented")};_b.exports=ti});var Kl=P((BD,Rb)=>{"use strict";p();var jl=Pt().Buffer,SB=Te(),Ob=wb(),EB=new Array(16),Gs=[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,7,4,13,1,10,6,15,3,12,0,9,5,2,14,11,8,3,10,14,4,9,15,8,1,2,7,0,6,13,11,5,12,1,9,11,10,0,8,12,4,13,3,7,15,14,5,6,2,4,0,5,9,7,12,2,10,14,1,3,8,11,6,15,13],zs=[5,14,7,0,9,2,11,4,13,6,15,8,1,10,3,12,6,11,3,7,0,13,5,10,14,15,8,12,4,9,1,2,15,5,1,3,7,14,6,9,11,8,12,2,10,0,4,13,8,6,4,1,3,11,15,0,5,12,2,13,9,7,10,14,12,15,10,4,1,5,8,7,6,2,13,14,0,3,9,11],Ws=[11,14,15,12,5,8,7,9,11,13,14,15,6,7,9,8,7,6,8,13,11,9,7,15,7,12,15,9,11,7,13,12,11,13,6,7,14,9,13,15,14,8,13,6,5,12,7,5,11,12,14,15,14,15,9,8,9,14,5,6,8,6,5,12,9,15,5,11,6,8,13,12,5,12,13,14,11,8,5,6],Ys=[8,9,9,11,13,15,15,5,7,7,8,11,14,14,12,6,9,13,15,7,12,8,9,11,7,7,12,7,6,15,13,11,9,7,15,11,8,6,6,14,12,13,5,14,13,13,7,5,15,5,8,11,14,14,6,14,6,9,12,9,12,5,15,8,8,5,12,9,12,5,14,6,8,13,6,5,15,13,11,11],$s=[0,1518500249,1859775393,2400959708,2840853838],Zs=[1352829926,1548603684,1836072691,2053994217,0];function Ci(e,t){return e<<t|e>>>32-t}function Sb(e,t,r,n,i,o,s,a){return Ci(e+(t^r^n)+o+s|0,a)+i|0}function Eb(e,t,r,n,i,o,s,a){return Ci(e+(t&r|~t&n)+o+s|0,a)+i|0}function xb(e,t,r,n,i,o,s,a){return Ci(e+((t|~r)^n)+o+s|0,a)+i|0}function Ib(e,t,r,n,i,o,s,a){return Ci(e+(t&n|r&~n)+o+s|0,a)+i|0}function Ab(e,t,r,n,i,o,s,a){return Ci(e+(t^(r|~n))+o+s|0,a)+i|0}function df(){Ob.call(this,64),this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878,this._e=3285377520}SB(df,Ob);df.prototype._update=function(){for(var e=EB,t=0;t<16;++t)e[t]=this._block.readInt32LE(t*4);for(var r=this._a|0,n=this._b|0,i=this._c|0,o=this._d|0,s=this._e|0,a=this._a|0,c=this._b|0,l=this._c|0,g=this._d|0,m=this._e|0,_=0;_<80;_+=1){var x,R;_<16?(x=Sb(r,n,i,o,s,e[Gs[_]],$s[0],Ws[_]),R=Ab(a,c,l,g,m,e[zs[_]],Zs[0],Ys[_])):_<32?(x=Eb(r,n,i,o,s,e[Gs[_]],$s[1],Ws[_]),R=Ib(a,c,l,g,m,e[zs[_]],Zs[1],Ys[_])):_<48?(x=xb(r,n,i,o,s,e[Gs[_]],$s[2],Ws[_]),R=xb(a,c,l,g,m,e[zs[_]],Zs[2],Ys[_])):_<64?(x=Ib(r,n,i,o,s,e[Gs[_]],$s[3],Ws[_]),R=Eb(a,c,l,g,m,e[zs[_]],Zs[3],Ys[_])):(x=Ab(r,n,i,o,s,e[Gs[_]],$s[4],Ws[_]),R=Sb(a,c,l,g,m,e[zs[_]],Zs[4],Ys[_])),r=s,s=o,o=Ci(i,10),i=n,n=x,a=m,m=g,g=Ci(l,10),l=c,c=R}var B=this._b+i+g|0;this._b=this._c+o+m|0,this._c=this._d+s+a|0,this._d=this._e+r+c|0,this._e=this._a+n+l|0,this._a=B};df.prototype._digest=function(){this._block[this._blockOffset]=128,this._blockOffset+=1,this._blockOffset>56&&(this._block.fill(0,this._blockOffset,64),this._update(),this._blockOffset=0),this._block.fill(0,this._blockOffset,56),this._block.writeUInt32LE(this._length[0],56),this._block.writeUInt32LE(this._length[1],60),this._update();var e=jl.alloc?jl.alloc(20):new jl(20);return e.writeInt32LE(this._a,0),e.writeInt32LE(this._b,4),e.writeInt32LE(this._c,8),e.writeInt32LE(this._d,12),e.writeInt32LE(this._e,16),e};Rb.exports=df});var Li=P((MD,Tb)=>{"use strict";p();var xB=Ct().Buffer,IB=ef();function pf(e,t){this._block=xB.alloc(e),this._finalSize=t,this._blockSize=e,this._len=0}pf.prototype.update=function(e,t){e=IB(e,t||"utf8");for(var r=this._block,n=this._blockSize,i=e.length,o=this._len,s=0;s<i;){for(var a=o%n,c=Math.min(i-s,n-a),l=0;l<c;l++)r[a+l]=e[s+l];o+=c,s+=c,o%n===0&&this._update(r)}return this._len+=i,this};pf.prototype.digest=function(e){var t=this._len%this._blockSize;this._block[t]=128,this._block.fill(0,t+1),t>=this._finalSize&&(this._update(this._block),this._block.fill(0));var r=this._len*8;if(r<=4294967295)this._block.writeUInt32BE(r,this._blockSize-4);else{var n=(r&4294967295)>>>0,i=(r-n)/4294967296;this._block.writeUInt32BE(i,this._blockSize-8),this._block.writeUInt32BE(n,this._blockSize-4)}this._update(this._block);var o=this._hash();return e?o.toString(e):o};pf.prototype._update=function(){throw new Error("_update must be implemented by subclass")};Tb.exports=pf});var Nb=P((CD,Bb)=>{"use strict";p();var AB=Te(),Pb=Li(),OB=Ct().Buffer,RB=[1518500249,1859775393,-1894007588,-899497514],TB=new Array(80);function Xs(){this.init(),this._w=TB,Pb.call(this,64,56)}AB(Xs,Pb);Xs.prototype.init=function(){return this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878,this._e=3285377520,this};function PB(e){return e<<5|e>>>27}function BB(e){return e<<30|e>>>2}function NB(e,t,r,n){return e===0?t&r|~t&n:e===2?t&r|t&n|r&n:t^r^n}Xs.prototype._update=function(e){for(var t=this._w,r=this._a|0,n=this._b|0,i=this._c|0,o=this._d|0,s=this._e|0,a=0;a<16;++a)t[a]=e.readInt32BE(a*4);for(;a<80;++a)t[a]=t[a-3]^t[a-8]^t[a-14]^t[a-16];for(var c=0;c<80;++c){var l=~~(c/20),g=PB(r)+NB(l,n,i,o)+s+t[c]+RB[l]|0;s=o,o=i,i=BB(n),n=r,r=g}this._a=r+this._a|0,this._b=n+this._b|0,this._c=i+this._c|0,this._d=o+this._d|0,this._e=s+this._e|0};Xs.prototype._hash=function(){var e=OB.allocUnsafe(20);return e.writeInt32BE(this._a|0,0),e.writeInt32BE(this._b|0,4),e.writeInt32BE(this._c|0,8),e.writeInt32BE(this._d|0,12),e.writeInt32BE(this._e|0,16),e};Bb.exports=Xs});var Cb=P((DD,kb)=>{"use strict";p();var MB=Te(),Mb=Li(),kB=Ct().Buffer,CB=[1518500249,1859775393,-1894007588,-899497514],LB=new Array(80);function Js(){this.init(),this._w=LB,Mb.call(this,64,56)}MB(Js,Mb);Js.prototype.init=function(){return this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878,this._e=3285377520,this};function DB(e){return e<<1|e>>>31}function UB(e){return e<<5|e>>>27}function qB(e){return e<<30|e>>>2}function FB(e,t,r,n){return e===0?t&r|~t&n:e===2?t&r|t&n|r&n:t^r^n}Js.prototype._update=function(e){for(var t=this._w,r=this._a|0,n=this._b|0,i=this._c|0,o=this._d|0,s=this._e|0,a=0;a<16;++a)t[a]=e.readInt32BE(a*4);for(;a<80;++a)t[a]=DB(t[a-3]^t[a-8]^t[a-14]^t[a-16]);for(var c=0;c<80;++c){var l=~~(c/20),g=UB(r)+FB(l,n,i,o)+s+t[c]+CB[l]|0;s=o,o=i,i=qB(n),n=r,r=g}this._a=r+this._a|0,this._b=n+this._b|0,this._c=i+this._c|0,this._d=o+this._d|0,this._e=s+this._e|0};Js.prototype._hash=function(){var e=kB.allocUnsafe(20);return e.writeInt32BE(this._a|0,0),e.writeInt32BE(this._b|0,4),e.writeInt32BE(this._c|0,8),e.writeInt32BE(this._d|0,12),e.writeInt32BE(this._e|0,16),e};kb.exports=Js});var Vl=P((qD,Db)=>{"use strict";p();var HB=Te(),Lb=Li(),jB=Ct().Buffer,KB=[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],VB=new Array(64);function Qs(){this.init(),this._w=VB,Lb.call(this,64,56)}HB(Qs,Lb);Qs.prototype.init=function(){return this._a=1779033703,this._b=3144134277,this._c=1013904242,this._d=2773480762,this._e=1359893119,this._f=2600822924,this._g=528734635,this._h=1541459225,this};function GB(e,t,r){return r^e&(t^r)}function zB(e,t,r){return e&t|r&(e|t)}function WB(e){return(e>>>2|e<<30)^(e>>>13|e<<19)^(e>>>22|e<<10)}function YB(e){return(e>>>6|e<<26)^(e>>>11|e<<21)^(e>>>25|e<<7)}function $B(e){return(e>>>7|e<<25)^(e>>>18|e<<14)^e>>>3}function ZB(e){return(e>>>17|e<<15)^(e>>>19|e<<13)^e>>>10}Qs.prototype._update=function(e){for(var t=this._w,r=this._a|0,n=this._b|0,i=this._c|0,o=this._d|0,s=this._e|0,a=this._f|0,c=this._g|0,l=this._h|0,g=0;g<16;++g)t[g]=e.readInt32BE(g*4);for(;g<64;++g)t[g]=ZB(t[g-2])+t[g-7]+$B(t[g-15])+t[g-16]|0;for(var m=0;m<64;++m){var _=l+YB(s)+GB(s,a,c)+KB[m]+t[m]|0,x=WB(r)+zB(r,n,i)|0;l=c,c=a,a=s,s=o+_|0,o=i,i=n,n=r,r=_+x|0}this._a=r+this._a|0,this._b=n+this._b|0,this._c=i+this._c|0,this._d=o+this._d|0,this._e=s+this._e|0,this._f=a+this._f|0,this._g=c+this._g|0,this._h=l+this._h|0};Qs.prototype._hash=function(){var e=jB.allocUnsafe(32);return e.writeInt32BE(this._a,0),e.writeInt32BE(this._b,4),e.writeInt32BE(this._c,8),e.writeInt32BE(this._d,12),e.writeInt32BE(this._e,16),e.writeInt32BE(this._f,20),e.writeInt32BE(this._g,24),e.writeInt32BE(this._h,28),e};Db.exports=Qs});var qb=P((HD,Ub)=>{"use strict";p();var XB=Te(),JB=Vl(),QB=Li(),e6=Ct().Buffer,t6=new Array(64);function gf(){this.init(),this._w=t6,QB.call(this,64,56)}XB(gf,JB);gf.prototype.init=function(){return this._a=3238371032,this._b=914150663,this._c=812702999,this._d=4144912697,this._e=4290775857,this._f=1750603025,this._g=1694076839,this._h=3204075428,this};gf.prototype._hash=function(){var e=e6.allocUnsafe(28);return e.writeInt32BE(this._a,0),e.writeInt32BE(this._b,4),e.writeInt32BE(this._c,8),e.writeInt32BE(this._d,12),e.writeInt32BE(this._e,16),e.writeInt32BE(this._f,20),e.writeInt32BE(this._g,24),e};Ub.exports=gf});var Gl=P((KD,zb)=>{"use strict";p();var r6=Te(),Gb=Li(),n6=Ct().Buffer,Fb=[1116352408,3609767458,1899447441,602891725,3049323471,3964484399,3921009573,2173295548,961987163,4081628472,1508970993,3053834265,2453635748,2937671579,2870763221,3664609560,3624381080,2734883394,310598401,1164996542,607225278,1323610764,1426881987,3590304994,1925078388,4068182383,2162078206,991336113,2614888103,633803317,3248222580,3479774868,3835390401,2666613458,4022224774,944711139,264347078,2341262773,604807628,2007800933,770255983,1495990901,1249150122,1856431235,1555081692,3175218132,1996064986,2198950837,2554220882,3999719339,2821834349,766784016,2952996808,2566594879,3210313671,3203337956,3336571891,1034457026,3584528711,2466948901,113926993,3758326383,338241895,168717936,666307205,1188179964,773529912,1546045734,1294757372,1522805485,1396182291,2643833823,1695183700,2343527390,1986661051,1014477480,2177026350,1206759142,2456956037,344077627,2730485921,1290863460,2820302411,3158454273,3259730800,3505952657,3345764771,106217008,3516065817,3606008344,3600352804,1432725776,4094571909,1467031594,275423344,851169720,430227734,3100823752,506948616,1363258195,659060556,3750685593,883997877,3785050280,958139571,3318307427,1322822218,3812723403,1537002063,2003034995,1747873779,3602036899,1955562222,1575990012,2024104815,1125592928,2227730452,2716904306,2361852424,442776044,2428436474,593698344,2756734187,3733110249,3204031479,2999351573,3329325298,3815920427,3391569614,3928383900,3515267271,566280711,3940187606,3454069534,4118630271,4000239992,116418474,1914138554,174292421,2731055270,289380356,3203993006,460393269,320620315,685471733,587496836,852142971,1086792851,1017036298,365543100,1126000580,2618297676,1288033470,3409855158,1501505948,4234509866,1607167915,987167468,1816402316,1246189591],i6=new Array(160);function ea(){this.init(),this._w=i6,Gb.call(this,128,112)}r6(ea,Gb);ea.prototype.init=function(){return this._ah=1779033703,this._bh=3144134277,this._ch=1013904242,this._dh=2773480762,this._eh=1359893119,this._fh=2600822924,this._gh=528734635,this._hh=1541459225,this._al=4089235720,this._bl=2227873595,this._cl=4271175723,this._dl=1595750129,this._el=2917565137,this._fl=725511199,this._gl=4215389547,this._hl=327033209,this};function Hb(e,t,r){return r^e&(t^r)}function jb(e,t,r){return e&t|r&(e|t)}function Kb(e,t){return(e>>>28|t<<4)^(t>>>2|e<<30)^(t>>>7|e<<25)}function Vb(e,t){return(e>>>14|t<<18)^(e>>>18|t<<14)^(t>>>9|e<<23)}function o6(e,t){return(e>>>1|t<<31)^(e>>>8|t<<24)^e>>>7}function s6(e,t){return(e>>>1|t<<31)^(e>>>8|t<<24)^(e>>>7|t<<25)}function a6(e,t){return(e>>>19|t<<13)^(t>>>29|e<<3)^e>>>6}function u6(e,t){return(e>>>19|t<<13)^(t>>>29|e<<3)^(e>>>6|t<<26)}function Dt(e,t){return e>>>0<t>>>0?1:0}ea.prototype._update=function(e){for(var t=this._w,r=this._ah|0,n=this._bh|0,i=this._ch|0,o=this._dh|0,s=this._eh|0,a=this._fh|0,c=this._gh|0,l=this._hh|0,g=this._al|0,m=this._bl|0,_=this._cl|0,x=this._dl|0,R=this._el|0,B=this._fl|0,C=this._gl|0,U=this._hl|0,V=0;V<32;V+=2)t[V]=e.readInt32BE(V*4),t[V+1]=e.readInt32BE(V*4+4);for(;V<160;V+=2){var z=t[V-30],j=t[V-30+1],Y=o6(z,j),oe=s6(j,z);z=t[V-4],j=t[V-4+1];var Q=a6(z,j),se=u6(j,z),ye=t[V-14],A=t[V-14+1],u=t[V-32],h=t[V-32+1],y=oe+A|0,v=Y+ye+Dt(y,oe)|0;y=y+se|0,v=v+Q+Dt(y,se)|0,y=y+h|0,v=v+u+Dt(y,h)|0,t[V]=v,t[V+1]=y}for(var b=0;b<160;b+=2){v=t[b],y=t[b+1];var E=jb(r,n,i),O=jb(g,m,_),w=Kb(r,g),f=Kb(g,r),S=Vb(s,R),H=Vb(R,s),q=Fb[b],W=Fb[b+1],$=Hb(s,a,c),X=Hb(R,B,C),ae=U+H|0,ge=l+S+Dt(ae,U)|0;ae=ae+X|0,ge=ge+$+Dt(ae,X)|0,ae=ae+W|0,ge=ge+q+Dt(ae,W)|0,ae=ae+y|0,ge=ge+v+Dt(ae,y)|0;var le=f+O|0,T=w+E+Dt(le,f)|0;l=c,U=C,c=a,C=B,a=s,B=R,R=x+ae|0,s=o+ge+Dt(R,x)|0,o=i,x=_,i=n,_=m,n=r,m=g,g=ae+le|0,r=ge+T+Dt(g,ae)|0}this._al=this._al+g|0,this._bl=this._bl+m|0,this._cl=this._cl+_|0,this._dl=this._dl+x|0,this._el=this._el+R|0,this._fl=this._fl+B|0,this._gl=this._gl+C|0,this._hl=this._hl+U|0,this._ah=this._ah+r+Dt(this._al,g)|0,this._bh=this._bh+n+Dt(this._bl,m)|0,this._ch=this._ch+i+Dt(this._cl,_)|0,this._dh=this._dh+o+Dt(this._dl,x)|0,this._eh=this._eh+s+Dt(this._el,R)|0,this._fh=this._fh+a+Dt(this._fl,B)|0,this._gh=this._gh+c+Dt(this._gl,C)|0,this._hh=this._hh+l+Dt(this._hl,U)|0};ea.prototype._hash=function(){var e=n6.allocUnsafe(64);function t(r,n,i){e.writeInt32BE(r,i),e.writeInt32BE(n,i+4)}return t(this._ah,this._al,0),t(this._bh,this._bl,8),t(this._ch,this._cl,16),t(this._dh,this._dl,24),t(this._eh,this._el,32),t(this._fh,this._fl,40),t(this._gh,this._gl,48),t(this._hh,this._hl,56),e};zb.exports=ea});var Yb=P((GD,Wb)=>{"use strict";p();var f6=Te(),c6=Gl(),h6=Li(),l6=Ct().Buffer,d6=new Array(160);function yf(){this.init(),this._w=d6,h6.call(this,128,112)}f6(yf,c6);yf.prototype.init=function(){return this._ah=3418070365,this._bh=1654270250,this._ch=2438529370,this._dh=355462360,this._eh=1731405415,this._fh=2394180231,this._gh=3675008525,this._hh=1203062813,this._al=3238371032,this._bl=914150663,this._cl=812702999,this._dl=4144912697,this._el=4290775857,this._fl=1750603025,this._gl=1694076839,this._hl=3204075428,this};yf.prototype._hash=function(){var e=l6.allocUnsafe(48);function t(r,n,i){e.writeInt32BE(r,i),e.writeInt32BE(n,i+4)}return t(this._ah,this._al,0),t(this._bh,this._bl,8),t(this._ch,this._cl,16),t(this._dh,this._dl,24),t(this._eh,this._el,32),t(this._fh,this._fl,40),e};Wb.exports=yf});var zl=P((WD,Rn)=>{"use strict";p();Rn.exports=function(t){var r=t.toLowerCase(),n=Rn.exports[r];if(!n)throw new Error(r+" is not supported (we accept pull requests)");return new n};Rn.exports.sha=Nb();Rn.exports.sha1=Cb();Rn.exports.sha224=qb();Rn.exports.sha256=Vl();Rn.exports.sha384=Yb();Rn.exports.sha512=Gl()});var mf=P(($D,Zb)=>{"use strict";p();var p6=Ct().Buffer,$b=El().Transform,g6=Po().StringDecoder,y6=Te(),m6=ef();function Nr(e){$b.call(this),this.hashMode=typeof e=="string",this.hashMode?this[e]=this._finalOrDigest:this.final=this._finalOrDigest,this._final&&(this.__final=this._final,this._final=null),this._decoder=null,this._encoding=null}y6(Nr,$b);Nr.prototype.update=function(e,t,r){var n=m6(e,t),i=this._update(n);return this.hashMode?this:(r&&(i=this._toString(i,r)),i)};Nr.prototype.setAutoPadding=function(){};Nr.prototype.getAuthTag=function(){throw new Error("trying to get auth tag in unsupported state")};Nr.prototype.setAuthTag=function(){throw new Error("trying to set auth tag in unsupported state")};Nr.prototype.setAAD=function(){throw new Error("trying to set aad in unsupported state")};Nr.prototype._transform=function(e,t,r){var n;try{this.hashMode?this._update(e):this.push(this._update(e))}catch(i){n=i}finally{r(n)}};Nr.prototype._flush=function(e){var t;try{this.push(this.__final())}catch(r){t=r}e(t)};Nr.prototype._finalOrDigest=function(e){var t=this.__final()||p6.alloc(0);return e&&(t=this._toString(t,e,!0)),t};Nr.prototype._toString=function(e,t,r){if(this._decoder||(this._decoder=new g6(t),this._encoding=t),this._encoding!==t)throw new Error("can\u2019t switch encodings");var n=this._decoder.write(e);return r&&(n+=this._decoder.end()),n};Zb.exports=Nr});var Qb=P((XD,Jb)=>{"use strict";p();var v6=Te(),b6=xl(),_6=Kl(),w6=zl(),Xb=mf();function vf(e){Xb.call(this,"digest"),this._hash=e}v6(vf,Xb);vf.prototype._update=function(e){this._hash.update(e)};vf.prototype._final=function(){return this._hash.digest()};Jb.exports=function(t){return t=t.toLowerCase(),t==="md5"?new b6:t==="rmd160"||t==="ripemd160"?new _6:new vf(w6(t))}});var r_=P((QD,t_)=>{"use strict";p();var S6=Te(),Di=Ct().Buffer,e_=mf(),E6=Di.alloc(128),Uo=64;function bf(e,t){e_.call(this,"digest"),typeof t=="string"&&(t=Di.from(t)),this._alg=e,this._key=t,t.length>Uo?t=e(t):t.length<Uo&&(t=Di.concat([t,E6],Uo));for(var r=this._ipad=Di.allocUnsafe(Uo),n=this._opad=Di.allocUnsafe(Uo),i=0;i<Uo;i++)r[i]=t[i]^54,n[i]=t[i]^92;this._hash=[r]}S6(bf,e_);bf.prototype._update=function(e){this._hash.push(e)};bf.prototype._final=function(){var e=this._alg(Di.concat(this._hash));return this._alg(Di.concat([this._opad,e]))};t_.exports=bf});var i_=P((tU,n_)=>{p();var x6=xl();n_.exports=function(e){return new x6().update(e).digest()}});var a_=P((nU,s_)=>{"use strict";p();var I6=Te(),A6=r_(),o_=mf(),ta=Ct().Buffer,O6=i_(),Wl=Kl(),Yl=zl(),R6=ta.alloc(128);function ra(e,t){o_.call(this,"digest"),typeof t=="string"&&(t=ta.from(t));var r=e==="sha512"||e==="sha384"?128:64;if(this._alg=e,this._key=t,t.length>r){var n=e==="rmd160"?new Wl:Yl(e);t=n.update(t).digest()}else t.length<r&&(t=ta.concat([t,R6],r));for(var i=this._ipad=ta.allocUnsafe(r),o=this._opad=ta.allocUnsafe(r),s=0;s<r;s++)i[s]=t[s]^54,o[s]=t[s]^92;this._hash=e==="rmd160"?new Wl:Yl(e),this._hash.update(i)}I6(ra,o_);ra.prototype._update=function(e){this._hash.update(e)};ra.prototype._final=function(){var e=this._hash.digest(),t=this._alg==="rmd160"?new Wl:Yl(this._alg);return t.update(this._opad).update(e).digest()};s_.exports=function(t,r){return t=t.toLowerCase(),t==="rmd160"||t==="ripemd160"?new ra("rmd160",r):t==="md5"?new A6(O6,r):new ra(t,r)}});var u_=P((oU,Zl)=>{"use strict";p();var $l=65536,T6=4294967295;function P6(){throw new Error(`Secure random number generation is not supported by this browser.
|
|
11
|
-
Use Chrome, Firefox or Internet Explorer 11`)}var
|
|
12
|
-
`+new Error().stack};return r.prototype=Object.create(e.prototype),r.prototype.name=e.prototype.name+t.name,e[t.name]=r,t.errors&&
|
|
13
|
-
`+new Error().stack};Fo.Error.prototype=Object.create(Error.prototype);Fo.Error.prototype.name="bsv.Error";var D6=l_();L6(Fo.Error,D6);Ql.exports=Fo.Error;Ql.exports.extend=function(e){return d_(Fo.Error,e)}});var Ce=P((mU,g_)=>{"use strict";p();var ia=ri(),U6=Ge();g_.exports={checkState:function(e,t){if(!e)throw new ia.InvalidState(t)},checkArgument:function(e,t,r,n){if(!e)throw new ia.InvalidArgument(t,r,n)},checkArgumentType:function(e,t,r){if(r=r||"(unknown name)",U6.isString(t)){if(t==="Buffer"){var n=Pt();if(!n.Buffer.isBuffer(e))throw new ia.InvalidArgumentType(e,t,r)}else if(typeof e!==t)throw new ia.InvalidArgumentType(e,t,r)}else if(!(e instanceof t))throw new ia.InvalidArgumentType(e,t.name,r)}}});var wr=P((bU,m_)=>{"use strict";p();var Ne=O0(),ed=Ce(),y_=Ge(),Sf=function(e){for(var t=d.Buffer.alloc(e.length),r=0;r<e.length;r++)t[r]=e[e.length-1-r];return t};Ne.Zero=new Ne(0);Ne.One=new Ne(1);Ne.Minus1=new Ne(-1);Ne.fromNumber=function(e){return ed.checkArgument(y_.isNumber(e)),new Ne(e)};Ne.fromString=function(e,t){return ed.checkArgument(y_.isString(e)),new Ne(e,t)};Ne.fromBuffer=function(e,t){typeof t<"u"&&t.endian==="little"&&(e=Sf(e));var r=e.toString("hex"),n=new Ne(r,16);return n};Ne.fromSM=function(e,t){var r;if(e.length===0)return Ne.fromBuffer(d.Buffer.from([0]));var n="big";return t&&(n=t.endian),n==="little"&&(e=Sf(e)),e[0]&128?(e[0]=e[0]&127,r=Ne.fromBuffer(e),r.neg().copy(r)):r=Ne.fromBuffer(e),r};Ne.prototype.toNumber=function(){return parseInt(this.toString(10),10)};Ne.prototype.toBuffer=function(e){var t,r;if(e&&e.size){r=this.toString(16,2);var n=r.length/2;t=d.Buffer.from(r,"hex"),n===e.size||(n>e.size?t=Ne.trim(t,n):n<e.size&&(t=Ne.pad(t,n,e.size)))}else r=this.toString(16,2),t=d.Buffer.from(r,"hex");return typeof e<"u"&&e.endian==="little"&&(t=Sf(t)),t};Ne.prototype.toSMBigEndian=function(){var e;return this.cmp(Ne.Zero)===-1?(e=this.neg().toBuffer(),e[0]&128?e=d.Buffer.concat([d.Buffer.from([128]),e]):e[0]=e[0]|128):(e=this.toBuffer(),e[0]&128&&(e=d.Buffer.concat([d.Buffer.from([0]),e]))),e.length===1&&e[0]===0&&(e=d.Buffer.from([])),e};Ne.prototype.toSM=function(e){var t=e?e.endian:"big",r=this.toSMBigEndian();return t==="little"&&(r=Sf(r)),r};Ne.fromScriptNumBuffer=function(e,t,r){var n=r||4;if(ed.checkArgument(e.length<=n,new Error("script number overflow")),t&&e.length>0&&(e[e.length-1]&127)===0&&(e.length<=1||(e[e.length-2]&128)===0))throw new Error("non-minimally encoded script number");return Ne.fromSM(e,{endian:"little"})};Ne.prototype.toScriptNumBuffer=function(){return this.toSM({endian:"little"})};Ne.trim=function(e,t){return e.slice(t-e.length,e.length)};Ne.pad=function(e,t,r){for(var n=d.Buffer.alloc(r),i=0;i<e.length;i++)n[n.length-1-i]=e[e.length-1-i];for(i=0;i<r-t;i++)n[i]=0;return n};Ne.prototype.toHex=function(...e){return this.toBuffer(...e).toString("hex")};Ne.fromHex=function(e,...t){return Ne.fromBuffer(d.Buffer.from(e,"hex"),...t)};m_.exports=Ne});function td(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name==="Uint8Array"&&"BYTES_PER_ELEMENT"in e&&e.BYTES_PER_ELEMENT===1}function ni(e,t=""){if(typeof e!="number"){let r=t&&`"${t}" `;throw new TypeError(`${r}expected number, got ${typeof e}`)}if(!Number.isSafeInteger(e)||e<0){let r=t&&`"${t}" `;throw new RangeError(`${r}expected integer >= 0, got ${e}`)}}function on(e,t,r=""){let n=td(e),i=e?.length,o=t!==void 0;if(!n||o&&i!==t){let s=r&&`"${r}" `,a=o?` of length ${t}`:"",c=n?`length=${i}`:`type=${typeof e}`,l=s+"expected Uint8Array"+a+", got "+c;throw n?new RangeError(l):new TypeError(l)}return e}function Ef(e){if(typeof e!="function"||typeof e.create!="function")throw new TypeError("Hash must wrapped by utils.createHasher");if(ni(e.outputLen),ni(e.blockLen),e.outputLen<1)throw new Error('"outputLen" must be >= 1');if(e.blockLen<1)throw new Error('"blockLen" must be >= 1')}function Ho(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 xf(e,t){on(e,void 0,"digestInto() output");let r=t.outputLen;if(e.length<r)throw new RangeError('"digestInto() output" expected to be of length >='+r)}function Ui(...e){for(let t=0;t<e.length;t++)e[t].fill(0)}function If(e){return new DataView(e.buffer,e.byteOffset,e.byteLength)}function Mr(e,t){return e<<32-t|e>>>t}function Af(e){if(on(e),b_)return e.toHex();let t="";for(let r=0;r<e.length;r++)t+=q6[e[r]];return t}function v_(e){if(e>=Tn._0&&e<=Tn._9)return e-Tn._0;if(e>=Tn.A&&e<=Tn.F)return e-(Tn.A-10);if(e>=Tn.a&&e<=Tn.f)return e-(Tn.a-10)}function rd(e){if(typeof e!="string")throw new TypeError("hex string expected, got "+typeof e);if(b_)try{return Uint8Array.fromHex(e)}catch(i){throw i instanceof SyntaxError?new RangeError(i.message):i}let t=e.length,r=t/2;if(t%2)throw new RangeError("hex string expected, got unpadded hex of length "+t);let n=new Uint8Array(r);for(let i=0,o=0;i<r;i++,o+=2){let s=v_(e.charCodeAt(o)),a=v_(e.charCodeAt(o+1));if(s===void 0||a===void 0){let c=e[o]+e[o+1];throw new RangeError('hex string expected, got non-hex character "'+c+'" at index '+o)}n[i]=s*16+a}return n}function Pn(e){if(typeof e!="string")throw new TypeError("string expected");return new Uint8Array(new TextEncoder().encode(e))}function __(...e){let t=0;for(let n=0;n<e.length;n++){let i=e[n];on(i),t+=i.length}let r=new Uint8Array(t);for(let n=0,i=0;n<e.length;n++){let o=e[n];r.set(o,i),i+=o.length}return r}function w_(e,t={}){let r=(i,o)=>e(o).update(i).digest(),n=e(void 0);return r.outputLen=n.outputLen,r.blockLen=n.blockLen,r.canXOF=n.canXOF,r.create=i=>e(i),Object.assign(r,t),Object.freeze(r)}function oa(e=32){ni(e,"bytesLength");let t=typeof globalThis=="object"?globalThis.crypto:null;if(typeof t?.getRandomValues!="function")throw new Error("crypto.getRandomValues must be defined");if(e>65536)throw new RangeError(`"bytesLength" expected <= 65536, got ${e}`);return t.getRandomValues(new Uint8Array(e))}var b_,q6,Tn,S_,ii=fr(()=>{p();b_=typeof Uint8Array.from([]).toHex=="function"&&typeof Uint8Array.fromHex=="function",q6=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,"0"));Tn={_0:48,_9:57,A:65,F:70,a:97,f:102};S_=e=>({oid:Uint8Array.from([6,9,96,134,72,1,101,3,4,2,e])})});function E_(e,t,r){return e&t^~e&r}function x_(e,t,r){return e&t^e&r^t&r}var Of,Bn,I_=fr(()=>{p();ii();Of=class{constructor(t,r,n,i){fe(this,"blockLen");fe(this,"outputLen");fe(this,"canXOF",!1);fe(this,"padOffset");fe(this,"isLE");fe(this,"buffer");fe(this,"view");fe(this,"finished",!1);fe(this,"length",0);fe(this,"pos",0);fe(this,"destroyed",!1);this.blockLen=t,this.outputLen=r,this.padOffset=n,this.isLE=i,this.buffer=new Uint8Array(t),this.view=If(this.buffer)}update(t){Ho(this),on(t);let{view:r,buffer:n,blockLen:i}=this,o=t.length;for(let s=0;s<o;){let a=Math.min(i-this.pos,o-s);if(a===i){let c=If(t);for(;i<=o-s;s+=i)this.process(c,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){Ho(this),xf(t,this),this.finished=!0;let{buffer:r,view:n,blockLen:i,isLE:o}=this,{pos:s}=this;r[s++]=128,Ui(this.buffer.subarray(s)),this.padOffset>i-s&&(this.process(n,0),s=0);for(let m=s;m<i;m++)r[m]=0;n.setBigUint64(i-8,BigInt(this.length*8),o),this.process(n,0);let a=If(t),c=this.outputLen;if(c%4)throw new Error("_sha2: outputLen must be aligned to 32bit");let l=c/4,g=this.get();if(l>g.length)throw new Error("_sha2: outputLen bigger than state");for(let m=0;m<l;m++)a.setUint32(4*m,g[m],o)}digest(){let{buffer:t,outputLen:r}=this;this.digestInto(t);let n=t.slice(0,r);return this.destroy(),n}_cloneInto(t){t||(t=new this.constructor),t.set(...this.get());let{blockLen:r,buffer:n,length:i,finished:o,destroyed:s,pos:a}=this;return t.destroyed=s,t.finished=o,t.length=i,t.pos=a,i%r&&t.buffer.set(n),t}clone(){return this._cloneInto()}},Bn=Uint32Array.from([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225])});var F6,oi,nd,id,qi,A_=fr(()=>{p();I_();ii();F6=Uint32Array.from([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),oi=new Uint32Array(64),nd=class extends Of{constructor(t){super(64,t,8,!1)}get(){let{A:t,B:r,C:n,D:i,E:o,F:s,G:a,H:c}=this;return[t,r,n,i,o,s,a,c]}set(t,r,n,i,o,s,a,c){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=c|0}process(t,r){for(let m=0;m<16;m++,r+=4)oi[m]=t.getUint32(r,!1);for(let m=16;m<64;m++){let _=oi[m-15],x=oi[m-2],R=Mr(_,7)^Mr(_,18)^_>>>3,B=Mr(x,17)^Mr(x,19)^x>>>10;oi[m]=B+oi[m-7]+R+oi[m-16]|0}let{A:n,B:i,C:o,D:s,E:a,F:c,G:l,H:g}=this;for(let m=0;m<64;m++){let _=Mr(a,6)^Mr(a,11)^Mr(a,25),x=g+_+E_(a,c,l)+F6[m]+oi[m]|0,B=(Mr(n,2)^Mr(n,13)^Mr(n,22))+x_(n,i,o)|0;g=l,l=c,c=a,a=s+x|0,s=o,o=i,i=n,n=x+B|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,c=c+this.F|0,l=l+this.G|0,g=g+this.H|0,this.set(n,i,o,s,a,c,l,g)}roundClean(){Ui(oi)}destroy(){this.destroyed=!0,this.set(0,0,0,0,0,0,0,0),Ui(this.buffer)}},id=class extends nd{constructor(){super(32);fe(this,"A",Bn[0]|0);fe(this,"B",Bn[1]|0);fe(this,"C",Bn[2]|0);fe(this,"D",Bn[3]|0);fe(this,"E",Bn[4]|0);fe(this,"F",Bn[5]|0);fe(this,"G",Bn[6]|0);fe(this,"H",Bn[7]|0)}},qi=w_(()=>new id,S_(1))});function Hi(e,t=""){if(typeof e!="boolean"){let r=t&&`"${t}" `;throw new TypeError(r+"expected boolean, got type="+typeof e)}return e}function Pf(e){if(typeof e=="bigint"){if(!Rf(e))throw new RangeError("positive bigint expected, got "+e)}else sd(e);return e}function Sr(e,t=""){if(typeof e!="number"){let r=t&&`"${t}" `;throw new TypeError(r+"expected number, got type="+typeof e)}if(!Number.isSafeInteger(e)){let r=t&&`"${t}" `;throw new RangeError(r+"expected safe integer, got "+e)}}function sa(e){let t=Pf(e).toString(16);return t.length&1?"0"+t:t}function O_(e){if(typeof e!="string")throw new TypeError("hex string expected, got "+typeof e);return e===""?Tf:BigInt("0x"+e)}function Xt(e){return O_(Af(e))}function Ko(e){return O_(Af(Nf(on(e)).reverse()))}function Bf(e,t){if(ni(t),t===0)throw new RangeError("zero length");e=Pf(e);let r=e.toString(16);if(r.length>t*2)throw new RangeError("number too large");return rd(r.padStart(t*2,"0"))}function ad(e,t){return Bf(e,t).reverse()}function Nf(e){return Uint8Array.from(De(e))}function Vo(e){if(typeof e!="string")throw new TypeError("ascii string expected, got "+typeof e);return Uint8Array.from(e,(t,r)=>{let n=t.charCodeAt(0);if(t.length!==1||n>127)throw new RangeError(`string contains non-ASCII character "${e[r]}" with code ${n} at position ${r}`);return n})}function H6(e,t,r){return Rf(e)&&Rf(t)&&Rf(r)&&t<=e&&e<r}function ud(e,t,r,n){if(!H6(t,r,n))throw new RangeError("expected valid "+e+": "+r+" <= n < "+n+", got "+t)}function ji(e){if(e<Tf)throw new Error("expected non-negative bigint, got "+e);let t;for(t=0;e>Tf;e>>=od,t+=1);return t}function R_(e,t,r){if(ni(e,"hashLen"),ni(t,"qByteLen"),typeof r!="function")throw new TypeError("hmacFn must be a function");let n=C=>new Uint8Array(C),i=Uint8Array.of(),o=Uint8Array.of(0),s=Uint8Array.of(1),a=1e3,c=n(e),l=n(e),g=0,m=()=>{c.fill(1),l.fill(0),g=0},_=(...C)=>r(l,ke(c,...C)),x=(C=i)=>{l=_(o,C),c=_(),C.length!==0&&(l=_(s,C),c=_())},R=()=>{if(g++>=a)throw new Error("drbg: tried max amount of iterations");let C=0,U=[];for(;C<t;){c=_();let V=c.slice();U.push(V),C+=c.length}return ke(...U)};return(C,U)=>{m(),x(C);let V;for(;(V=U(R()))===void 0;)x();return m(),V}}function Er(e,t={},r={}){if(Object.prototype.toString.call(e)!=="[object Object]")throw new TypeError("expected valid options object");function n(o,s,a){if(!a&&s!=="function"&&!Object.hasOwn(e,o))throw new TypeError(`param "${o}" is invalid: expected own property`);let c=e[o];if(a&&c===void 0)return;let l=typeof c;if(l!==s||c===null)throw new TypeError(`param "${o}" is invalid: expected ${s}, got ${l}`)}let i=(o,s)=>Object.entries(o).forEach(([a,c])=>n(a,c,s));i(t,!1),i(r,!0)}var De,sd,Nn,ke,jo,Fi,nr,Tf,od,Rf,Go,Ki=fr(()=>{p();ii();De=(e,t,r)=>on(e,t,r),sd=ni,Nn=Af,ke=(...e)=>__(...e),jo=e=>rd(e),Fi=td,nr=e=>oa(e),Tf=BigInt(0),od=BigInt(1);Rf=e=>typeof e=="bigint"&&Tf<=e;Go=e=>(od<<BigInt(e))-od});function cr(e,t){if(t<=jt)throw new Error("mod: expected positive modulus, got "+t);let r=e%t;return r>=jt?r:t+r}function hr(e,t,r){if(t<jt)throw new Error("pow2: expected non-negative exponent, got "+t);let n=e;for(;t-- >jt;)n*=n,n%=r;return n}function T_(e,t){if(e===jt)throw new Error("invert: expected non-zero number");if(t<=jt)throw new Error("invert: expected positive modulus, got "+t);let r=cr(e,t),n=t,i=jt,o=It,s=It,a=jt;for(;r!==jt;){let l=n/r,g=n-r*l,m=i-s*l,_=o-a*l;n=r,r=g,i=s,o=a,s=m,a=_}if(n!==It)throw new Error("invert: does not exist");return cr(i,t)}function cd(e,t,r){let n=e;if(!n.eql(n.sqr(t),r))throw new Error("Cannot find square root")}function L_(e,t){let r=e,n=(r.ORDER+It)/N_,i=r.pow(t,n);return cd(r,i,t),i}function V6(e,t){let r=e,n=(r.ORDER-M_)/k_,i=r.mul(t,Vi),o=r.pow(i,n),s=r.mul(t,o),a=r.mul(r.mul(s,Vi),o),c=r.mul(s,r.sub(a,r.ONE));return cd(r,c,t),c}function G6(e){let t=zo(e),r=D_(e),n=r(t,t.neg(t.ONE)),i=r(t,n),o=r(t,t.neg(n)),s=(e+j6)/C_;return((a,c)=>{let l=a,g=l.pow(c,s),m=l.mul(g,n),_=l.mul(g,i),x=l.mul(g,o),R=l.eql(l.sqr(m),c),B=l.eql(l.sqr(_),c);g=l.cmov(g,m,R),m=l.cmov(x,_,B);let C=l.eql(l.sqr(m),c),U=l.cmov(g,m,C);return cd(l,U,c),U})}function D_(e){if(e<B_)throw new Error("sqrt is not defined for small field");let t=e-It,r=0;for(;t%Vi===jt;)t/=Vi,r++;let n=Vi,i=zo(e);for(;fd(i,n)===1;)if(n++>1e3)throw new Error("Cannot find square root: probably non-prime P");if(r===1)return L_;let o=i.pow(n,t),s=(t+It)/Vi;return function(c,l){let g=c;if(g.is0(l))return l;if(fd(g,l)!==1)throw new Error("Cannot find square root");let m=r,_=g.mul(g.ONE,o),x=g.pow(l,t),R=g.pow(l,s);for(;!g.eql(x,g.ONE);){if(g.is0(x))return g.ZERO;let B=1,C=g.sqr(x);for(;!g.eql(C,g.ONE);)if(B++,C=g.sqr(C),B===m)throw new Error("Cannot find square root");let U=It<<BigInt(m-B-1),V=g.pow(_,U);m=B,_=g.sqr(V),x=g.mul(x,_),R=g.mul(R,V)}return R}}function z6(e){return e%N_===B_?L_:e%k_===M_?V6:e%C_===K6?G6(e):D_(e)}function Gi(e){let t={ORDER:"bigint",BYTES:"number",BITS:"number"},r=W6.reduce((n,i)=>(n[i]="function",n),t);if(Er(e,r),Sr(e.BYTES,"BYTES"),Sr(e.BITS,"BITS"),e.BYTES<1||e.BITS<1)throw new Error("invalid field: expected BYTES/BITS > 0");if(e.ORDER<=It)throw new Error("invalid field: expected ORDER > 1, got "+e.ORDER);return e}function Y6(e,t,r){let n=e;if(r<jt)throw new Error("invalid exponent, negatives unsupported");if(r===jt)return n.ONE;if(r===It)return t;let i=n.ONE,o=t;for(;r>jt;)r&It&&(i=n.mul(i,o)),o=n.sqr(o),r>>=It;return i}function zi(e,t,r=!1){let n=e,i=new Array(t.length).fill(r?n.ZERO:void 0),o=t.reduce((a,c,l)=>n.is0(c)?a:(i[l]=a,n.mul(a,c)),n.ONE),s=n.inv(o);return t.reduceRight((a,c,l)=>n.is0(c)?a:(i[l]=n.mul(a,i[l]),n.mul(a,c)),s),i}function fd(e,t){let r=e,n=(r.ORDER-It)/Vi,i=r.pow(t,n),o=r.eql(i,r.ONE),s=r.eql(i,r.ZERO),a=r.eql(i,r.neg(r.ONE));if(!o&&!s&&!a)throw new Error("invalid Legendre symbol result");return o?1:s?0:-1}function hd(e,t){return fd(e,t)!==-1}function $6(e,t){if(t!==void 0&&sd(t),e<=jt)throw new Error("invalid n length: expected positive n, got "+e);if(t!==void 0&&t<1)throw new Error("invalid n length: expected positive bit length, got "+t);let r=ji(e);if(t!==void 0&&t<r)throw new Error(`invalid n length: expected bit length (${r}) >= n.length (${t})`);let n=t!==void 0?t:r,i=Math.ceil(n/8);return{nBitLength:n,nByteLength:i}}function zo(e,t={}){return new Mf(e,t)}function U_(e){if(typeof e!="bigint")throw new Error("field order must be bigint");if(e<=It)throw new Error("field order must be greater than 1");let t=ji(e-It);return Math.ceil(t/8)}function aa(e){let t=U_(e);return t+Math.ceil(t/2)}function Wo(e,t,r=!1){De(e);let n=e.length,i=U_(t),o=Math.max(aa(t),16);if(n<o||n>1024)throw new Error("expected "+o+"-1024 bytes of input, got "+n);let s=r?Ko(e):Xt(e),a=cr(s,t-It)+It;return r?ad(a,i):Bf(a,i)}var jt,It,Vi,B_,N_,M_,j6,k_,K6,C_,W6,P_,Mf,Yo=fr(()=>{p();Ki();jt=BigInt(0),It=BigInt(1),Vi=BigInt(2),B_=BigInt(3),N_=BigInt(4),M_=BigInt(5),j6=BigInt(7),k_=BigInt(8),K6=BigInt(9),C_=BigInt(16);W6=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];P_=new WeakMap,Mf=class{constructor(t,r={}){fe(this,"ORDER");fe(this,"BITS");fe(this,"BYTES");fe(this,"isLE");fe(this,"ZERO",jt);fe(this,"ONE",It);fe(this,"_lengths");fe(this,"_mod");if(t<=It)throw new Error("invalid field: expected ORDER > 1, got "+t);let n;this.isLE=!1,r!=null&&typeof r=="object"&&(typeof r.BITS=="number"&&(n=r.BITS),typeof r.sqrt=="function"&&Object.defineProperty(this,"sqrt",{value:r.sqrt,enumerable:!0}),typeof r.isLE=="boolean"&&(this.isLE=r.isLE),r.allowedLengths&&(this._lengths=Object.freeze(r.allowedLengths.slice())),typeof r.modFromBytes=="boolean"&&(this._mod=r.modFromBytes));let{nBitLength:i,nByteLength:o}=$6(t,n);if(o>2048)throw new Error("invalid field: expected ORDER of <= 2048 bytes");this.ORDER=t,this.BITS=i,this.BYTES=o,Object.freeze(this)}create(t){return cr(t,this.ORDER)}isValid(t){if(typeof t!="bigint")throw new TypeError("invalid field element: expected bigint, got "+typeof t);return jt<=t&&t<this.ORDER}is0(t){return t===jt}isValidNot0(t){return!this.is0(t)&&this.isValid(t)}isOdd(t){return(t&It)===It}neg(t){return cr(-t,this.ORDER)}eql(t,r){return t===r}sqr(t){return cr(t*t,this.ORDER)}add(t,r){return cr(t+r,this.ORDER)}sub(t,r){return cr(t-r,this.ORDER)}mul(t,r){return cr(t*r,this.ORDER)}pow(t,r){return Y6(this,t,r)}div(t,r){return cr(t*T_(r,this.ORDER),this.ORDER)}sqrN(t){return t*t}addN(t,r){return t+r}subN(t,r){return t-r}mulN(t,r){return t*r}inv(t){return T_(t,this.ORDER)}sqrt(t){let r=P_.get(this);return r||P_.set(this,r=z6(this.ORDER)),r(this,t)}toBytes(t){return this.isLE?ad(t,this.BYTES):Bf(t,this.BYTES)}fromBytes(t,r=!1){De(t);let{_lengths:n,BYTES:i,isLE:o,ORDER:s,_mod:a}=this;if(n){if(t.length<1||!n.includes(t.length)||t.length>i)throw new Error("Field.fromBytes: expected "+n+" bytes, got "+t.length);let l=new Uint8Array(i);l.set(t,o?0:l.length-t.length),t=l}if(t.length!==i)throw new Error("Field.fromBytes: expected "+i+" bytes, got "+t.length);let c=o?Ko(t):Xt(t);if(a&&(c=cr(c,s)),!r&&!this.isValid(c))throw new Error("invalid field element: outside of range 0..ORDER");return c}invertBatch(t){return zi(this,t)}cmov(t,r,n){return Hi(n,"condition"),n?r:t}};Object.freeze(Mf.prototype)});function j_(e){let t=e;if(typeof t!="function")throw new TypeError("Point must be a constructor");Er({Fp:t.Fp,Fn:t.Fn,fromAffine:t.fromAffine,fromBytes:t.fromBytes,fromHex:t.fromHex},{Fp:"object",Fn:"object",fromAffine:"function",fromBytes:"function",fromHex:"function"}),Gi(t.Fp),Gi(t.Fn)}function ua(e,t){let r=t.negate();return e?r:t}function gd(e,t){let r=zi(e.Fp,t.map(n=>n.Z));return t.map((n,i)=>e.fromAffine(n.toAffine(r[i])))}function K_(e,t){if(!Number.isSafeInteger(e)||e<=0||e>t)throw new Error("invalid window size, expected [1.."+t+"], got W="+e)}function ld(e,t){K_(e,t);let r=Math.ceil(t/e)+1,n=2**(e-1),i=2**e,o=Go(e),s=BigInt(e);return{windows:r,windowSize:n,mask:o,maxNumber:i,shiftBy:s}}function q_(e,t,r){let{windowSize:n,mask:i,maxNumber:o,shiftBy:s}=r,a=Number(e&i),c=e>>s;a>n&&(a-=o,c+=Wi);let l=t*n,g=l+Math.abs(a)-1,m=a===0,_=a<0,x=t%2!==0;return{nextN:c,offset:g,isZero:m,isNeg:_,isNegF:x,offsetF:l}}function Z6(e,t){if(!Array.isArray(e))throw new Error("array expected");e.forEach((r,n)=>{if(!(r instanceof t))throw new Error("invalid point at index "+n)})}function X6(e,t){if(!Array.isArray(e))throw new Error("array of scalars expected");e.forEach((r,n)=>{if(!t.isValid(r))throw new Error("invalid scalar at index "+n)})}function pd(e){return V_.get(e)||1}function F_(e){if(e!==$o)throw new Error("invalid wNAF")}function G_(e,t,r,n){let i=t,o=e.ZERO,s=e.ZERO;for(;r>$o||n>$o;)r&Wi&&(o=o.add(i)),n&Wi&&(s=s.add(i)),i=i.double(),r>>=Wi,n>>=Wi;return{p1:o,p2:s}}function z_(e,t,r){let n=e.Fn;Z6(t,e),X6(r,n);let i=t.length,o=r.length;if(i!==o)throw new Error("arrays of points and scalars must have equal length");let s=e.ZERO,a=ji(BigInt(i)),c=1;a>12?c=a-3:a>4?c=a-2:a>0&&(c=2);let l=Go(c),g=new Array(Number(l)+1).fill(s),m=Math.floor((n.BITS-1)/c)*c,_=s;for(let x=m;x>=0;x-=c){g.fill(s);for(let B=0;B<o;B++){let C=r[B],U=Number(C>>BigInt(x)&l);g[U]=g[U].add(t[B])}let R=s;for(let B=g.length-1,C=s;B>0;B--)C=C.add(g[B]),R=R.add(C);if(_=_.add(R),x!==0)for(let B=0;B<c;B++)_=_.double()}return _}function H_(e,t,r){if(t){if(t.ORDER!==e)throw new Error("Field.ORDER must match order: Fp == p, Fn == n");return Gi(t),t}else return zo(e,{isLE:r})}function W_(e,t,r={},n){if(n===void 0&&(n=e==="edwards"),!t||typeof t!="object")throw new Error(`expected valid ${e} CURVE object`);for(let c of["p","n","h"]){let l=t[c];if(!(typeof l=="bigint"&&l>$o))throw new Error(`CURVE.${c} must be positive bigint`)}let i=H_(t.p,r.Fp,n),o=H_(t.n,r.Fn,n),a=["Gx","Gy","a",e==="weierstrass"?"b":"d"];for(let c of a)if(!i.isValid(t[c]))throw new Error(`CURVE.${c} must be valid field element of CURVE.Fp`);return t=Object.freeze(Object.assign({},t)),{CURVE:t,Fp:i,Fn:o}}function Cf(e,t){return function(n){let i=e(n);return{secretKey:i,publicKey:t(i)}}}var $o,Wi,dd,V_,kf,Lf=fr(()=>{p();Ki();Yo();$o=BigInt(0),Wi=BigInt(1);dd=new WeakMap,V_=new WeakMap;kf=class{constructor(t,r){fe(this,"BASE");fe(this,"ZERO");fe(this,"Fn");fe(this,"bits");this.BASE=t.BASE,this.ZERO=t.ZERO,this.Fn=t.Fn,this.bits=r}_unsafeLadder(t,r,n=this.ZERO){let i=t;for(;r>$o;)r&Wi&&(n=n.add(i)),i=i.double(),r>>=Wi;return n}precomputeWindow(t,r){let{windows:n,windowSize:i}=ld(r,this.bits),o=[],s=t,a=s;for(let c=0;c<n;c++){a=s,o.push(a);for(let l=1;l<i;l++)a=a.add(s),o.push(a);s=a.double()}return o}wNAF(t,r,n){if(!this.Fn.isValid(n))throw new Error("invalid scalar");let i=this.ZERO,o=this.BASE,s=ld(t,this.bits);for(let a=0;a<s.windows;a++){let{nextN:c,offset:l,isZero:g,isNeg:m,isNegF:_,offsetF:x}=q_(n,a,s);n=c,g?o=o.add(ua(_,r[x])):i=i.add(ua(m,r[l]))}return F_(n),{p:i,f:o}}wNAFUnsafe(t,r,n,i=this.ZERO){let o=ld(t,this.bits);for(let s=0;s<o.windows&&n!==$o;s++){let{nextN:a,offset:c,isZero:l,isNeg:g}=q_(n,s,o);if(n=a,!l){let m=r[c];i=i.add(g?m.negate():m)}}return F_(n),i}getPrecomputes(t,r,n){let i=dd.get(r);return i||(i=this.precomputeWindow(r,t),t!==1&&(typeof n=="function"&&(i=n(i)),dd.set(r,i))),i}cached(t,r,n){let i=pd(t);return this.wNAF(i,this.getPrecomputes(i,t,n),r)}unsafe(t,r,n,i){let o=pd(t);return o===1?this._unsafeLadder(t,r,i):this.wNAFUnsafe(o,this.getPrecomputes(o,t,n),r,i)}createCache(t,r){K_(r,this.bits),V_.set(t,r),dd.delete(t)}hasCache(t){return pd(t)!==1}}});function Y_(e){if(!Number.isSafeInteger(e)||e<0||e>4294967295)throw new Error("wrong u32 integer:"+e);return e}function J6(e){if(Y_(e),e<=1)return 1;if(e>2147483648)throw new Error("nextPowerOfTwo overflow: result does not fit u32");return 1<<yd(e-1)+1>>>0}function yd(e){return Y_(e),31-Math.clz32(e)}function $_(e,t,r,n,i){let o=e,s=r||((g,m)=>new Array(g).fill(m??o.ZERO)),a=g=>{if(Array.isArray(g))return!0;if(!ArrayBuffer.isView(g))return!1;let m=g;return typeof m.length=="number"&&typeof m.slice=="function"&&typeof m[Symbol.iterator]=="function"},c=(...g)=>{if(!g.length)return 0;for(let _ of g)if(!a(_))throw new Error("poly: not polynomial: "+_);let m=g[0].length;for(let _=1;_<g.length;_++)if(g[_].length!==m)throw new Error(`poly: mismatched lengths ${m} vs ${g[_].length}`);if(i!==void 0&&m!==i)throw new Error(`poly: expected fixed length ${i}, got ${m}`);return m};function l(g,m,_=!1){let x=yd(m),R=_?t.brp(x):t.roots(x);for(let B=0;B<m;B++)if(o.eql(g,R[B]))return B;return-1}return{roots:t,create:s,length:i,extend:(g,m)=>{c(g);let _=s(m,o.ZERO);for(let x=0;x<Math.min(g.length,m);x++)_[x]=g[x];return _},degree:g=>{c(g);for(let m=g.length-1;m>=0;m--)if(!o.is0(g[m]))return m;return-1},add:(g,m)=>{let _=c(g,m),x=s(_);for(let R=0;R<_;R++)x[R]=o.add(g[R],m[R]);return x},sub:(g,m)=>{let _=c(g,m),x=s(_);for(let R=0;R<_;R++)x[R]=o.sub(g[R],m[R]);return x},dot:(g,m)=>{let _=c(g,m),x=s(_);for(let R=0;R<_;R++)x[R]=o.mul(g[R],m[R]);return x},mul:(g,m)=>{if(a(m)){let _=c(g,m);if(n){let x=n.direct(g,!1,!0),R=n.direct(m,!1,!0);for(let B=0;B<x.length;B++)x[B]=o.mul(x[B],R[B]);return n.inverse(x,!0,!1)}else{let x=s(_);for(let R=0;R<_;R++)for(let B=0;B<_;B++){let C=(R+B)%_;x[C]=o.add(x[C],o.mul(g[R],m[B]))}return x}}else{let _=s(c(g));for(let x=0;x<_.length;x++)_[x]=o.mul(g[x],m);return _}},convolve(g,m){let _=J6(g.length+m.length-1);return this.mul(this.extend(g,_),this.extend(m,_))},shift(g,m){let _=s(c(g));_[0]=g[0];for(let x=1,R=o.ONE;x<g.length;x++)R=o.mul(R,m),_[x]=o.mul(g[x],R);return _},clone:g=>{c(g);let m=s(g.length);for(let _=0;_<g.length;_++)m[_]=g[_];return m},eval:(g,m)=>{c(g,m);let _=o.ZERO;for(let x=0;x<g.length;x++)_=o.add(_,o.mul(g[x],m[x]));return _},monomial:{basis:(g,m)=>{let _=s(m),x=o.ONE;for(let R=0;R<m;R++)_[R]=x,x=o.mul(x,g);return _},eval:(g,m)=>{c(g);let _=o.ZERO;for(let x=g.length-1;x>=0;x--)_=o.add(o.mul(_,m),g[x]);return _}},lagrange:{basis:(g,m,_=!1,x)=>{let R=yd(m),B=x||(_?t.brp(R):t.roots(R)),C=s(m),U=l(g,m,_);if(U!==-1)return C[U]=o.ONE,C;let V=o.pow(g,BigInt(m)),z=o.mul(o.sub(V,o.ONE),o.inv(BigInt(m))),j=s(m);for(let oe=0;oe<m;oe++)j[oe]=o.sub(g,B[oe]);let Y=o.invertBatch(j);for(let oe=0;oe<m;oe++)C[oe]=o.mul(z,o.mul(B[oe],Y[oe]));return C},eval(g,m,_=!1){c(g);let x=l(m,g.length,_);if(x!==-1)return g[x];let R=this.basis(m,g.length,_),B=o.ZERO;for(let C=0;C<g.length;C++)o.is0(g[C])||(B=o.add(B,o.mul(g[C],R[C])));return B}},vanishing(g){c(g);let m=s(g.length+1,o.ZERO);m[0]=o.ONE;for(let _ of g){let x=o.neg(_);for(let R=m.length-1;R>0;R--)m[R]=o.add(o.mul(m[R],x),m[R-1]);m[0]=o.mul(m[0],x)}return m}}}var Z_=fr(()=>{p()});function Yi(e,t){if(Sr(e),Sr(t),t<0||t>4)throw new Error("invalid I2OSP length: "+t);if(e<0||e>2**(8*t)-1)throw new Error("invalid I2OSP input: "+e);let r=Array.from({length:t}).fill(0);for(let n=t-1;n>=0;n--)r[n]=e&255,e>>>=8;return new Uint8Array(r)}function e3(e,t){let r=new Uint8Array(e.length);for(let n=0;n<e.length;n++)r[n]=e[n]^t[n];return r}function X_(e){if(!Fi(e)&&typeof e!="string")throw new Error("DST must be Uint8Array or ascii string");let t=typeof e=="string"?Vo(e):e;if(t.length===0)throw new Error("DST must be non-empty");return t}function t3(e,t,r,n){De(e),Sr(r),t=X_(t),t.length>255&&(t=n(ke(Vo("H2C-OVERSIZE-DST-"),t)));let{outputLen:i,blockLen:o}=n,s=Math.ceil(r/i);if(r>65535||s>255)throw new Error("expand_message_xmd: invalid lenInBytes");let a=ke(t,Yi(t.length,1)),c=new Uint8Array(o),l=Yi(r,2),g=new Array(s),m=n(ke(c,e,l,Yi(0,1),a));g[0]=n(ke(m,Yi(1,1),a));for(let x=1;x<s;x++){let R=[e3(m,g[x-1]),Yi(x+1,1),a];g[x]=n(ke(...R))}return ke(...g).slice(0,r)}function r3(e,t,r,n,i){if(De(e),Sr(r),t=X_(t),t.length>255){let o=Math.ceil(2*n/8);t=i.create({dkLen:o}).update(Vo("H2C-OVERSIZE-DST-")).update(t).digest()}if(r>65535||t.length>255)throw new Error("expand_message_xof: invalid lenInBytes");return i.create({dkLen:r}).update(e).update(Yi(r,2)).update(t).update(Yi(t.length,1)).digest()}function md(e,t,r){Er(r,{p:"bigint",m:"number",k:"number",hash:"function"});let{p:n,k:i,m:o,hash:s,expand:a,DST:c}=r;if(Sr(s.outputLen,"valid hash"),De(e),Sr(t),t<1)throw new Error("hash_to_field: expected count >= 1");if(o<1)throw new Error("hash_to_field: expected m >= 1");let l=n.toString(2).length,g=Math.ceil((l+i)/8),m=t*o*g,_;if(a==="xmd")_=t3(e,c,m,s);else if(a==="xof")_=r3(e,c,m,i,s);else if(a==="_internal_pass")_=e;else throw new Error('expand must be "xmd" or "xof"');let x=new Array(t);for(let R=0;R<t;R++){let B=new Array(o);for(let C=0;C<o;C++){let U=g*(C+R*o),V=_.subarray(U,U+g);B[C]=cr(Q6(V),n)}x[R]=B}return x}function J_(e,t){let r=t.map(n=>Array.from(n).reverse());return(n,i)=>{let[o,s,a,c]=r.map(m=>m.reduce((_,x)=>e.add(e.mul(_,n),x))),[l,g]=zi(e,[s,c],!0);return n=e.mul(o,l),i=e.mul(i,e.mul(a,g)),{x:n,y:i}}}function Q_(e,t,r){if(typeof t!="function")throw new Error("mapToCurve() must be defined");let n=a=>Object.freeze({...a,DST:Fi(a.DST)?Nf(a.DST):a.DST,...a.encodeDST===void 0?{}:{encodeDST:Fi(a.encodeDST)?Nf(a.encodeDST):a.encodeDST}}),i=n(r);function o(a){return e.fromAffine(t(a))}function s(a){let c=a.clearCofactor();return c.equals(e.ZERO)?e.ZERO:(c.assertValidity(),c)}return Object.freeze({get defaults(){return n(i)},Point:e,hashToCurve(a,c){let l=Object.assign({},i,c),g=md(a,2,l),m=o(g[0]),_=o(g[1]);return s(m.add(_))},encodeToCurve(a,c){let l=i.encodeDST?{DST:i.encodeDST}:{},g=Object.assign({},i,l,c),m=md(a,1,g),_=o(m[0]);return s(_)},mapToCurve(a){if(i.m===1){if(typeof a!="bigint")throw new Error("expected bigint (m=1)");return s(o([a]))}if(!Array.isArray(a))throw new Error("expected array of bigints");for(let c of a)if(typeof c!="bigint")throw new Error("expected array of bigints");return s(o(a))},hashToScalar(a,c){let l=e.Fn.ORDER,g=Object.assign({},i,{p:l,m:1,DST:n3},c);return md(a,1,g)[0][0]}})}var Q6,n3,e1=fr(()=>{p();Ki();Yo();Q6=Xt;n3="HashToScalar-"});function vd(e){Er(e,{name:"string",hash:"function"},{hashToScalar:"function",validatePoint:"function",parsePublicKey:"function",adjustScalar:"function",adjustPoint:"function",challenge:"function",adjustNonces:"function",adjustSecret:"function",adjustPublic:"function",adjustGroupCommitmentShare:"function",adjustDKG:"function"}),j_(e.Point);let{Point:t}=e,r=e.Fn===void 0?t.Fn:e.Fn,n=e.hash,i=e.hashToScalar===void 0?(T,k={DST:new Uint8Array})=>{let F=n(ke(k.DST,T));return r.create(r.isLE?Ko(F):Xt(F))}:e.hashToScalar,o=Pn(e.H1!==void 0?e.H1:e.name+"rho"),s=Pn(e.H2!==void 0?e.H2:e.name+"chal"),a=Pn(e.H3!==void 0?e.H3:e.name+"nonce"),c=Pn(e.H4!==void 0?e.H4:e.name+"msg"),l=Pn(e.H5!==void 0?e.H5:e.name+"com"),g=Pn(e.HDKG!==void 0?e.HDKG:e.name+"dkg"),m=Pn(e.HID!==void 0?e.HID:e.name+"id"),_=T=>i(T,{DST:o}),x=T=>i(T,{DST:s}),R=T=>i(T,{DST:a}),B=T=>n(ke(c,T)),C=T=>n(ke(l,T)),U=T=>i(T,{DST:g}),V=T=>i(T,{DST:m}),z=(T=nr)=>{let k=Wo(T(aa(r.ORDER)),r.ORDER,r.isLE);return r.isLE?Ko(k):Xt(k)},j=T=>T.toBytes(),Y=T=>{let k=t.fromBytes(T);return e.validatePoint&&e.validatePoint(k),k},oe=(T,k)=>({identifier:T,hiding:j(t.BASE.multiply(r.fromBytes(k.hiding))),binding:j(t.BASE.multiply(r.fromBytes(k.binding)))}),Q=e.adjustPoint===void 0?T=>T:e.adjustPoint,se=T=>{if(!r.isValid(T)||r.is0(T))throw new Error("Invalid identifier "+T);return T},ye=T=>Nn(r.toBytes(se(T))),A=T=>{let k=se(r.fromBytes(jo(T)));if(ye(k)!==T)throw new Error("expected canonical identifier hex");return k},u={encode:(T,k)=>{let F=ke(j(T),r.toBytes(k));return e.adjustTx&&(F=e.adjustTx.encode(F)),F},decode:T=>{e.adjustTx&&(T=e.adjustTx.decode(T));let k=Y(T.subarray(0,-r.BYTES)),F=r.fromBytes(T.subarray(-r.BYTES));return{R:k,z:F}}},h=(T=nr)=>{let k=z(T);e.adjustScalar&&(k=e.adjustScalar(k));let F=t.BASE.multiply(k);return{scalar:k,point:F}},y="roots are unavailable in FROST polynomial mode",v={info:{G:r.ZERO,oddFactor:r.ZERO,powerOfTwo:0},roots(){throw new Error(y)},brp(){throw new Error(y)},inverse(){throw new Error(y)},omega(){throw new Error(y)},clear(){}},b=$_(r,v),E=(T,k)=>z_(t,T,k),O=(T,k)=>{if(!k.length)throw new Error("empty coefficients");return b.monomial.eval(k,T)},w=(T,k)=>{let F="invalid parameters";if(!T.some(ee=>r.eql(ee,k)))throw new Error(F);let K=new Set(T);if(K.size!==T.length)throw new Error(F);if(!K.has(k))throw new Error(F);let ne=r.ONE,J=r.ONE;for(let ee of T)r.eql(ee,k)||(ne=r.mul(ne,ee),J=r.mul(J,r.sub(ee,k)));return r.div(ne,J)},f=(T,k)=>{let F=b.monomial.basis(T,k.length);return E(k,F)},S=(T,k,F,K=nr)=>{Df(T);let ne=k===void 0?z(K):r.fromBytes(k);if(!F){F=[];for(let de=0;de<T.min-1;de++)F.push(z(K))}if(F.length!==T.min-1)throw new Error("wrong coefficients length");let J=[ne,...F],ee=J.map(de=>t.BASE.multiply(de));return{coefficients:J,commitment:ee,secret:ne}},H={challenge:(T,k,F)=>U(ke(r.toBytes(T),j(k),j(F))),compute(T,k,F,K=nr){if(k.length<1)throw new Error("coefficients should have at least one element");let{point:ne,scalar:J}=h(K),ee=F[0],de=this.challenge(T,ee,ne),ie=r.add(J,r.mul(k[0],de));return u.encode(ne,ie)},validate(T,k,F){if(k.length<1)throw new Error("commitment should have at least one element");let{R:K,z:ne}=u.decode(F),J=Y(k[0]),ee=this.challenge(T,J,K);if(!K.equals(t.BASE.multiply(ne).subtract(J.multiply(ee))))throw new Error("invalid proof of knowledge")}},q={challenge:(T,k,F)=>e.challenge?e.challenge(T,k,F):x(ke(j(T),j(k),F)),sign(T,k,F=nr){let{point:K,scalar:ne}=h(F),J=t.BASE.multiply(k),ee=this.challenge(K,J,T),de=r.add(ne,r.mul(ee,k));return[K,de]},verify(T,k,F,K){e.adjustPoint&&(K=e.adjustPoint(K)),e.adjustPoint&&(k=e.adjustPoint(k));let ne=this.challenge(k,K,T),J=t.BASE.multiply(F),ee=K.multiply(ne),de=J.subtract(ee).subtract(k);return de.clearCofactor&&(de=de.clearCofactor()),t.ZERO.equals(de)}},W=(T,k,F)=>{if(!t.BASE.multiply(F).equals(f(T,k)))throw new Error("invalid secret share")},$={fromNumber(T){if(!Number.isSafeInteger(T))throw new Error("expected safe interger");return ye(BigInt(T))},derive(T){if(typeof T!="string")throw new Error("wrong identifier string: "+T);return ye(V(Pn(T)))}},X=(T,k=nr)=>R(ke(k(32),r.toBytes(T))),ae=(T,k,F)=>{let K=k.map(te=>[te.identifier,A(te.identifier),Y(te.hiding),Y(te.binding)]);K.sort((te,ve)=>te[1]<ve[1]?-1:te[1]>ve[1]?1:0);let ne=[];for(let[te,ve,be,we]of K)ne.push(r.toBytes(ve),j(be),j(we));let J=C(ke(...ne)),ee=ke(j(T),B(F),J),de={};for(let[te,ve]of K)de[te]=_(ke(ee,r.toBytes(ve)));let ie=[],ue=[];for(let[te,ve,be,we]of K){if(t.ZERO.equals(be)||t.ZERO.equals(we))throw new Error("infinity commitment");ie.push(be,we),ue.push(r.ONE,de[te])}let Ye=E(ie,ue);return{identifiers:K.map(te=>te[1]),groupCommitment:Ye,bindingFactors:de}},ge=(T,k,F,K)=>{let ne=Q(Y(T)),J=A(K),{identifiers:ee,groupCommitment:de,bindingFactors:ie}=ae(ne,k,F),ue=ie[K],Ye=w(ee,J),Oe=q.challenge(de,ne,F);return{lambda:Ye,challenge:Oe,bindingFactor:ue,groupCommitment:de}};Object.freeze($);let le={Identifier:$,DKG:Object.freeze({round1:(T,k,F,K=nr)=>{Df(k);let ne=A(T),{coefficients:J,commitment:ee}=S(k,F,void 0,K),de=H.compute(ne,J,ee,K),ie=ee.map(j),ue={identifier:ye(ne),commitment:ie,proofOfKnowledge:de},Ye={identifier:ne,coefficients:J,commitment:ee.map(j),signers:{min:k.min,max:k.max},step:1};return{public:ue,secret:Ye}},round2:(T,k)=>{if(k.length!==T.signers.max-1)throw new Error("wrong number of round1 packages");if(!T.coefficients||T.step===3)throw new Error("round3 package used in round2");let F={};for(let K of k){if(K.commitment.length!==T.signers.min)throw new Error("wrong number of commitments");let ne=A(K.identifier);if(ne===T.identifier)throw new Error("duplicate id="+ye(ne));H.validate(ne,K.commitment,K.proofOfKnowledge);for(let ee of K.commitment)Y(ee);if(F[K.identifier])throw new Error("Duplicate id="+ne);let J=r.toBytes(O(ne,T.coefficients));F[K.identifier]={identifier:ye(T.identifier),signingShare:J}}return T.step=2,F},round3:(T,k,F)=>{if(k.length!==T.signers.max-1)throw new Error("wrong length of round1 packages");if(!T.coefficients||T.step!==2)throw new Error("round2 package used in round3");if(F.length!==k.length)throw new Error("wrong length of round2 packages");let K={};for(let ve of k){if(!ve.identifier||!ve.commitment)throw new Error("wrong round1 share");K[ve.identifier]={...ve}}for(let ve of F){if(!ve.identifier||!ve.signingShare)throw new Error("wrong round2 share");if(!K[ve.identifier])throw new Error("round1 share for "+ve.identifier+" is missing");K[ve.identifier].signingShare=ve.signingShare}if(Object.keys(K).length!==k.length)throw new Error("mismatch identifiers between rounds");let ne=r.ZERO;if(T.commitment.length!==T.signers.min)throw new Error("wrong commitments length");let J=T.commitment.map(Y),ee=O(T.identifier,T.coefficients);W(T.identifier,J,ee);let de=J.map(j),ie={[ye(T.identifier)]:de};for(let ve in K){let be=K[ve];if(!be.signingShare||!be.commitment)throw new Error("mismatch identifiers");let we=A(ve),bn=r.fromBytes(be.signingShare),$e=be.commitment.map(Y);W(T.identifier,$e,bn),ne=r.add(ne,bn);let Ke=ye(we);if(ie[Ke])throw new Error("duplicated id="+Ke);ie[Ke]=be.commitment}ne=r.add(ne,ee);let ue=new Array(T.signers.min).fill(t.ZERO);for(let ve in ie){let be=ie[ve];if(be.length!==T.signers.min)throw new Error("wrong commitments length");for(let we=0;we<be.length;we++)ue[we]=ue[we].add(Y(be[we]))}let Ye=ue.map(j),Oe={};for(let ve in ie)Oe[ve]=j(f(A(ve),ue));let te={public:{signers:{min:T.signers.min,max:T.signers.max},commitments:Ye,verifyingShares:Object.fromEntries(Object.entries(Oe).map(([ve,be])=>[ve,be.slice()]))},secret:{identifier:ye(T.identifier),signingShare:r.toBytes(ne)}};e.adjustDKG&&(te=e.adjustDKG(te));for(let ve=0;ve<T.coefficients.length;ve++)T.coefficients[ve]-=T.coefficients[ve];return delete T.coefficients,T.step=3,te},clean(T){if(T.identifier-=T.identifier,T.coefficients)for(let k=0;k<T.coefficients.length;k++)T.coefficients[k]-=T.coefficients[k];T.step=3}}),trustedDealer(T,k,F,K=nr){if(Df(T),k===void 0){k=[];for(let ue=1;ue<=T.max;ue++)k.push($.fromNumber(ue))}else if(!Array.isArray(k)||k.length!==T.max)throw new Error("identifiers should be array of "+T.max);let ne={};for(let ue of k){let Ye=A(ue);if(ue in ne)throw new Error("duplicated id="+ue);ne[ue]=Ye}let J=S(T,F,void 0,K),ee=J.commitment.map(j),de={},ie={};for(let ue of k){let Ye=O(ne[ue],J.coefficients);ie[ue]=j(t.BASE.multiply(Ye)),de[ue]={identifier:ue,signingShare:r.toBytes(Ye)}}return{public:{signers:{min:T.min,max:T.max},commitments:ee,verifyingShares:ie},secretShares:de}},validateSecret(T,k){let F=A(T.identifier),K=k.commitments.map(Y),ne=r.fromBytes(T.signingShare);W(F,K,ne)},commit(T,k=nr){let F=r.fromBytes(T.signingShare),K=X(F,k),ne=X(F,k),J={hiding:r.toBytes(K),binding:r.toBytes(ne)};return{nonces:J,commitments:oe(T.identifier,J)}},signShare(T,k,F,K,ne){t1(k.signers,K.length);let J=r.fromBytes(F.hiding),ee=r.fromBytes(F.binding);if(r.is0(J)||r.is0(ee))throw new Error("signing nonces already used");let de={identifier:T.identifier,hiding:j(t.BASE.multiply(J)),binding:j(t.BASE.multiply(ee))},ie=K.find(Xe=>Xe.identifier===T.identifier);if(!ie)throw new Error("missing signer commitment");if(Nn(ie.hiding)!==Nn(de.hiding)||Nn(ie.binding)!==Nn(de.binding))throw new Error("incorrect signer commitment");e.adjustSecret&&(T=e.adjustSecret(T,k)),e.adjustPublic&&(k=e.adjustPublic(k));let ue=r.fromBytes(T.signingShare),{lambda:Ye,challenge:Oe,bindingFactor:te,groupCommitment:ve}=ge(k.commitments[0],K,ne,T.identifier),be=e.adjustNonces?e.adjustNonces(ve,F):F,we=e.adjustNonces?r.fromBytes(be.hiding):J,bn=e.adjustNonces?r.fromBytes(be.binding):ee,$e=r.mul(r.mul(Ye,ue),Oe),Ke=r.mul(bn,te),Xa=r.toBytes(r.add(r.add(we,Ke),$e));return F.hiding.fill(0),F.binding.fill(0),Xa},verifyShare(T,k,F,K,ne){e.adjustPublic&&(T=e.adjustPublic(T));let J=k.find(bn=>bn.identifier===K);if(!J)throw new Error("cannot find identifier commitment");let ee=Y(T.verifyingShares[K]),de=Y(J.hiding),ie=Y(J.binding),{lambda:ue,challenge:Ye,bindingFactor:Oe,groupCommitment:te}=ge(T.commitments[0],k,F,K),ve=de.add(ie.multiply(Oe));e.adjustGroupCommitmentShare&&(ve=e.adjustGroupCommitmentShare(te,ve));let be=t.BASE.multiply(r.fromBytes(ne)),we=ve.add(ee.multiply(r.mul(Ye,ue)));return be.equals(we)},aggregate(T,k,F,K){e.adjustPublic&&(T=e.adjustPublic(T));try{t1(T.signers,k.length)}catch{throw new Zo("aggregation failed",[])}let ne=k.map(ie=>ie.identifier);if(ne.length!==Object.keys(K).length)throw new Zo("aggregation failed",[]);for(let ie of ne)if(!(ie in K)||!(ie in T.verifyingShares))throw new Zo("aggregation failed",[]);let J=Y(T.commitments[0]),{groupCommitment:ee}=ae(J,k,F),de=r.ZERO;for(let ie of ne)de=r.add(de,r.fromBytes(K[ie]));if(!q.verify(F,ee,de,J)){let ie=[];for(let ue of ne)this.verifyShare(T,k,F,ue,K[ue])||ie.push(ue);throw new Zo("aggregation failed",ie)}return u.encode(ee,de)},sign(T,k){let F=r.fromBytes(k);e.adjustScalar&&(F=e.adjustScalar(F));let[K,ne]=q.sign(T,F);return u.encode(K,ne)},verify(T,k,F){let K=e.parsePublicKey?e.parsePublicKey(F):Y(F),{R:ne,z:J}=u.decode(T);return q.verify(k,ne,J,K)},combineSecret(T,k){if(Df(k),!Array.isArray(T)||T.length<k.min)throw new Error("wrong secret shares array");let F=[],K={};for(let ee of T){let de=A(ee.identifier),ie=ye(de);if(K[ie])throw new Error("duplicated id="+ie);K[ie]=!0,F.push([de,r.fromBytes(ee.signingShare)])}let ne=F.map(([ee])=>ee),J=r.ZERO;for(let[ee,de]of F)J=r.add(J,r.mul(de,w(ne,ee)));return r.toBytes(J)},utils:Object.freeze({Fn:r,randomScalar:(T=nr)=>r.toBytes(h(T).scalar),generateSecretPolynomial:(T,k,F,K)=>{let ne=S(T,k,F,K);return{...ne,commitment:ne.commitment.map(j)}}})};return Object.freeze(le)}var Df,t1,Zo,r1=fr(()=>{p();ii();Ki();Lf();Z_();Yo();Df=e=>{if(!Number.isSafeInteger(e.min)||!Number.isSafeInteger(e.max))throw new Error("Wrong signers info: min="+e.min+" max="+e.max);if(e.min<2||e.max<2||e.min>e.max)throw new Error("Wrong signers info: min="+e.min+" max="+e.max)},t1=(e,t)=>{if(t<e.min||t>e.max)throw new Error("Wrong number of commitments="+t)},Zo=class extends Error{constructor(r,n){super(r);fe(this,"cheaters");this.cheaters=n}}});var Uf,n1,i1=fr(()=>{p();ii();Uf=class{constructor(t,r){fe(this,"oHash");fe(this,"iHash");fe(this,"blockLen");fe(this,"outputLen");fe(this,"canXOF",!1);fe(this,"finished",!1);fe(this,"destroyed",!1);if(Ef(t),on(r,void 0,"key"),this.iHash=t.create(),typeof this.iHash.update!="function")throw new Error("Expected instance of class which extends utils.Hash");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;let n=this.blockLen,i=new Uint8Array(n);i.set(r.length>n?t.create().update(r).digest():r);for(let o=0;o<i.length;o++)i[o]^=54;this.iHash.update(i),this.oHash=t.create();for(let o=0;o<i.length;o++)i[o]^=106;this.oHash.update(i),Ui(i)}update(t){return Ho(this),this.iHash.update(t),this}digestInto(t){Ho(this),xf(t,this),this.finished=!0;let r=t.subarray(0,this.outputLen);this.iHash.digestInto(r),this.oHash.update(r),this.oHash.digestInto(r),this.destroy()}digest(){let t=new Uint8Array(this.oHash.outputLen);return this.digestInto(t),t}_cloneInto(t){t||(t=Object.create(Object.getPrototypeOf(this),{}));let{oHash:r,iHash:n,finished:i,destroyed:o,blockLen:s,outputLen:a}=this;return t=t,t.finished=i,t.destroyed=o,t.blockLen=s,t.outputLen=a,t.oHash=r._cloneInto(t.oHash),t.iHash=n._cloneInto(t.iHash),t}clone(){return this._cloneInto()}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}},n1=(()=>{let e=((t,r,n)=>new Uf(t,r).update(n).digest());return e.create=(t,r)=>new Uf(t,r),e})()});function i3(e,t,r){ud("scalar",e,xr,r);let[[n,i],[o,s]]=t,a=o1(s*e,r),c=o1(-i*e,r),l=e-a*n-c*o,g=-a*i-c*s,m=l<xr,_=g<xr;m&&(l=-l),_&&(g=-g);let x=Go(Math.ceil(ji(r)/2))+Ut;if(l<xr||l>=x||g<xr||g>=x)throw new Error("splitScalar (endomorphism): failed for k");return{k1neg:m,k1:l,k2neg:_,k2:g}}function _d(e){if(!["compact","recovered","der"].includes(e))throw new Error('Signature format must be "compact", "recovered", or "der"');return e}function bd(e,t){Er(e);let r={};for(let n of Object.keys(t))r[n]=e[n]===void 0?t[n]:e[n];return Hi(r.lowS,"lowS"),Hi(r.prehash,"prehash"),r.format!==void 0&&_d(r.format),r}function s1(e,t={}){let r=W_("weierstrass",e,t),n=r.Fp,i=r.Fn,o=r.CURVE,{h:s,n:a}=o;Er(t,{},{allowInfinityPoint:"boolean",clearCofactor:"function",isTorsionFree:"function",fromBytes:"function",toBytes:"function",endo:"object"});let{endo:c,allowInfinityPoint:l}=t;if(c&&(!n.is0(o.a)||typeof c.beta!="bigint"||!Array.isArray(c.basises)))throw new Error('invalid endo: expected "beta": bigint and "basises": array');let g=f1(n,i);function m(){if(!n.isOdd)throw new Error("compression is not supported: Field does not have .isOdd()")}function _(h,y,v){if(l&&y.is0())return Uint8Array.of(0);let{x:b,y:E}=y.toAffine(),O=n.toBytes(b);if(Hi(v,"isCompressed"),v){m();let w=!n.isOdd(E);return ke(a1(w),O)}else return ke(Uint8Array.of(4),O,n.toBytes(E))}function x(h){De(h,void 0,"Point");let{publicKey:y,publicKeyUncompressed:v}=g,b=h.length,E=h[0],O=h.subarray(1);if(l&&b===1&&E===0)return{x:n.ZERO,y:n.ZERO};if(b===y&&(E===2||E===3)){let w=n.fromBytes(O);if(!n.isValid(w))throw new Error("bad point: is not on curve, wrong x");let f=C(w),S;try{S=n.sqrt(f)}catch(W){let $=W instanceof Error?": "+W.message:"";throw new Error("bad point: is not on curve, sqrt error"+$)}m();let H=n.isOdd(S);return(E&1)===1!==H&&(S=n.neg(S)),{x:w,y:S}}else if(b===v&&E===4){let w=n.BYTES,f=n.fromBytes(O.subarray(0,w)),S=n.fromBytes(O.subarray(w,w*2));if(!U(f,S))throw new Error("bad point: is not on curve");return{x:f,y:S}}else throw new Error(`bad point: got length ${b}, expected compressed=${y} or uncompressed=${v}`)}let R=t.toBytes===void 0?_:t.toBytes,B=t.fromBytes===void 0?x:t.fromBytes;function C(h){let y=n.sqr(h),v=n.mul(y,h);return n.add(n.add(v,n.mul(h,o.a)),o.b)}function U(h,y){let v=n.sqr(y),b=C(h);return n.eql(v,b)}if(!U(o.Gx,o.Gy))throw new Error("bad curve params: generator point");let V=n.mul(n.pow(o.a,Xo),Sd),z=n.mul(n.sqr(o.b),BigInt(27));if(n.is0(n.add(V,z)))throw new Error("bad curve params: a or b");function j(h,y,v=!1){if(!n.isValid(y)||v&&n.is0(y))throw new Error(`bad point coordinate ${h}`);return y}function Y(h){if(!(h instanceof se))throw new Error("Weierstrass Point expected")}function oe(h){if(!c||!c.basises)throw new Error("no endo");return i3(h,c.basises,i.ORDER)}function Q(h,y,v,b,E){return v=new se(n.mul(v.X,h),v.Y,v.Z),y=ua(b,y),v=ua(E,v),y.add(v)}let u=class u{constructor(y,v,b){fe(this,"X");fe(this,"Y");fe(this,"Z");this.X=j("x",y),this.Y=j("y",v,!0),this.Z=j("z",b),Object.freeze(this)}static CURVE(){return o}static fromAffine(y){let{x:v,y:b}=y||{};if(!y||!n.isValid(v)||!n.isValid(b))throw new Error("invalid affine point");if(y instanceof u)throw new Error("projective point not allowed");return n.is0(v)&&n.is0(b)?u.ZERO:new u(v,b,n.ONE)}static fromBytes(y){let v=u.fromAffine(B(De(y,void 0,"point")));return v.assertValidity(),v}static fromHex(y){return u.fromBytes(jo(y))}get x(){return this.toAffine().x}get y(){return this.toAffine().y}precompute(y=8,v=!0){return A.createCache(this,y),v||this.multiply(Xo),this}assertValidity(){let y=this;if(y.is0()){if(t.allowInfinityPoint&&n.is0(y.X)&&n.eql(y.Y,n.ONE)&&n.is0(y.Z))return;throw new Error("bad point: ZERO")}let{x:v,y:b}=y.toAffine();if(!n.isValid(v)||!n.isValid(b))throw new Error("bad point: x or y not field elements");if(!U(v,b))throw new Error("bad point: equation left != right");if(!y.isTorsionFree())throw new Error("bad point: not in prime-order subgroup")}hasEvenY(){let{y}=this.toAffine();if(!n.isOdd)throw new Error("Field doesn't support isOdd");return!n.isOdd(y)}equals(y){Y(y);let{X:v,Y:b,Z:E}=this,{X:O,Y:w,Z:f}=y,S=n.eql(n.mul(v,f),n.mul(O,E)),H=n.eql(n.mul(b,f),n.mul(w,E));return S&&H}negate(){return new u(this.X,n.neg(this.Y),this.Z)}double(){let{a:y,b:v}=o,b=n.mul(v,Xo),{X:E,Y:O,Z:w}=this,f=n.ZERO,S=n.ZERO,H=n.ZERO,q=n.mul(E,E),W=n.mul(O,O),$=n.mul(w,w),X=n.mul(E,O);return X=n.add(X,X),H=n.mul(E,w),H=n.add(H,H),f=n.mul(y,H),S=n.mul(b,$),S=n.add(f,S),f=n.sub(W,S),S=n.add(W,S),S=n.mul(f,S),f=n.mul(X,f),H=n.mul(b,H),$=n.mul(y,$),X=n.sub(q,$),X=n.mul(y,X),X=n.add(X,H),H=n.add(q,q),q=n.add(H,q),q=n.add(q,$),q=n.mul(q,X),S=n.add(S,q),$=n.mul(O,w),$=n.add($,$),q=n.mul($,X),f=n.sub(f,q),H=n.mul($,W),H=n.add(H,H),H=n.add(H,H),new u(f,S,H)}add(y){Y(y);let{X:v,Y:b,Z:E}=this,{X:O,Y:w,Z:f}=y,S=n.ZERO,H=n.ZERO,q=n.ZERO,W=o.a,$=n.mul(o.b,Xo),X=n.mul(v,O),ae=n.mul(b,w),ge=n.mul(E,f),le=n.add(v,b),T=n.add(O,w);le=n.mul(le,T),T=n.add(X,ae),le=n.sub(le,T),T=n.add(v,E);let k=n.add(O,f);return T=n.mul(T,k),k=n.add(X,ge),T=n.sub(T,k),k=n.add(b,E),S=n.add(w,f),k=n.mul(k,S),S=n.add(ae,ge),k=n.sub(k,S),q=n.mul(W,T),S=n.mul($,ge),q=n.add(S,q),S=n.sub(ae,q),q=n.add(ae,q),H=n.mul(S,q),ae=n.add(X,X),ae=n.add(ae,X),ge=n.mul(W,ge),T=n.mul($,T),ae=n.add(ae,ge),ge=n.sub(X,ge),ge=n.mul(W,ge),T=n.add(T,ge),X=n.mul(ae,T),H=n.add(H,X),X=n.mul(k,T),S=n.mul(le,S),S=n.sub(S,X),X=n.mul(le,ae),q=n.mul(k,q),q=n.add(q,X),new u(S,H,q)}subtract(y){return Y(y),this.add(y.negate())}is0(){return this.equals(u.ZERO)}multiply(y){let{endo:v}=t;if(!i.isValidNot0(y))throw new RangeError("invalid scalar: out of range");let b,E,O=w=>A.cached(this,w,f=>gd(u,f));if(v){let{k1neg:w,k1:f,k2neg:S,k2:H}=oe(y),{p:q,f:W}=O(f),{p:$,f:X}=O(H);E=W.add(X),b=Q(v.beta,q,$,w,S)}else{let{p:w,f}=O(y);b=w,E=f}return gd(u,[b,E])[0]}multiplyUnsafe(y){let{endo:v}=t,b=this,E=y;if(!i.isValid(E))throw new RangeError("invalid scalar: out of range");if(E===xr||b.is0())return u.ZERO;if(E===Ut)return b;if(A.hasCache(this))return this.multiply(E);if(v){let{k1neg:O,k1:w,k2neg:f,k2:S}=oe(E),{p1:H,p2:q}=G_(u,b,w,S);return Q(v.beta,H,q,O,f)}else return A.unsafe(b,E)}toAffine(y){let v=this,b=y,{X:E,Y:O,Z:w}=v;if(n.eql(w,n.ONE))return{x:E,y:O};let f=v.is0();b==null&&(b=f?n.ONE:n.inv(w));let S=n.mul(E,b),H=n.mul(O,b),q=n.mul(w,b);if(f)return{x:n.ZERO,y:n.ZERO};if(!n.eql(q,n.ONE))throw new Error("invZ was invalid");return{x:S,y:H}}isTorsionFree(){let{isTorsionFree:y}=t;return s===Ut?!0:y?y(u,this):A.unsafe(this,a).is0()}clearCofactor(){let{clearCofactor:y}=t;return s===Ut?this:y?y(u,this):this.multiplyUnsafe(s)}isSmallOrder(){return s===Ut?this.is0():this.clearCofactor().is0()}toBytes(y=!0){return Hi(y,"isCompressed"),this.assertValidity(),R(u,this,y)}toHex(y=!0){return Nn(this.toBytes(y))}toString(){return`<Point ${this.is0()?"ZERO":this.toHex()}>`}};fe(u,"BASE",new u(o.Gx,o.Gy,n.ONE)),fe(u,"ZERO",new u(n.ZERO,n.ONE,n.ZERO)),fe(u,"Fp",n),fe(u,"Fn",i);let se=u,ye=i.BITS,A=new kf(se,t.endo?Math.ceil(ye/2):ye);return ye>=8&&se.BASE.precompute(8),Object.freeze(se.prototype),Object.freeze(se),se}function a1(e){return Uint8Array.of(e?2:3)}function o3(e,t){let r=Gi(e),n=r.ORDER,i=xr;for(let B=n-Ut;B%sn===xr;B/=sn)i+=Ut;let o=i,s=sn<<o-Ut-Ut,a=s*sn,c=(n-Ut)/a,l=(c-Ut)/sn,g=a-Ut,m=s,_=r.pow(t,c),x=r.pow(t,(c+Ut)/sn),R=(B,C)=>{let U=_,V=r.pow(C,g),z=r.sqr(V);z=r.mul(z,C);let j=r.mul(B,z);j=r.pow(j,l),j=r.mul(j,V),V=r.mul(j,C),z=r.mul(j,B);let Y=r.mul(z,V);j=r.pow(Y,m);let oe=r.eql(j,r.ONE);V=r.mul(z,x),j=r.mul(Y,U),z=r.cmov(V,z,oe),Y=r.cmov(j,Y,oe);for(let Q=o;Q>Ut;Q--){let se=Q-sn;se=sn<<se-Ut;let ye=r.pow(Y,se),A=r.eql(ye,r.ONE);V=r.mul(z,U),U=r.mul(U,U),ye=r.mul(Y,U),z=r.cmov(V,z,A),Y=r.cmov(ye,Y,A)}return{isValid:!r.is0(C)&&(oe||r.is0(B)),value:z}};if(r.ORDER%Sd===Xo){let B=(r.ORDER-Xo)/Sd,C=r.sqrt(r.neg(t));R=(U,V)=>{let z=r.sqr(V),j=r.mul(U,V);z=r.mul(z,j);let Y=r.pow(z,B);Y=r.mul(Y,j);let oe=r.mul(Y,C),Q=r.mul(r.sqr(Y),V),se=r.eql(Q,U),ye=r.cmov(oe,Y,se);return{isValid:!r.is0(V)&&se,value:ye}}}return R}function u1(e,t){let r=Gi(e),{A:n,B:i,Z:o}=t;if(!r.isValidNot0(n)||!r.isValidNot0(i)||!r.isValid(o))throw new Error("mapToCurveSimpleSWU: invalid opts");if(r.eql(o,r.neg(r.ONE))||hd(r,o))throw new Error("mapToCurveSimpleSWU: invalid opts");let s=r.mul(i,r.inv(r.mul(o,n))),a=r.add(r.add(r.mul(r.sqr(s),s),r.mul(n,s)),i);if(!hd(r,a))throw new Error("mapToCurveSimpleSWU: invalid opts");let c=o3(r,o);if(!r.isOdd)throw new Error("Field does not have .isOdd()");return l=>{let g,m,_,x,R,B,C,U;g=r.sqr(l),g=r.mul(g,o),m=r.sqr(g),m=r.add(m,g),_=r.add(m,r.ONE),_=r.mul(_,i),x=r.cmov(o,r.neg(m),!r.eql(m,r.ZERO)),x=r.mul(x,n),m=r.sqr(_),B=r.sqr(x),R=r.mul(B,n),m=r.add(m,R),m=r.mul(m,_),B=r.mul(B,x),R=r.mul(B,i),m=r.add(m,R),C=r.mul(g,_);let{isValid:V,value:z}=c(m,B);U=r.mul(g,l),U=r.mul(U,z),C=r.cmov(C,_,V),U=r.cmov(U,z,V);let j=r.isOdd(l)===r.isOdd(U);U=r.cmov(r.neg(U),U,j);let Y=zi(r,[x],!0)[0];return C=r.mul(C,Y),{x:C,y:U}}}function f1(e,t){return{secretKey:t.BYTES,publicKey:1+e.BYTES,publicKeyUncompressed:1+2*e.BYTES,publicKeyHasPrefix:!0,signature:2*t.BYTES}}function s3(e,t={}){let{Fn:r}=e,n=t.randomBytes===void 0?nr:t.randomBytes,i=Object.assign(f1(e.Fp,r),{seed:Math.max(aa(r.ORDER),16)});function o(x){try{let R=r.fromBytes(x);return r.isValidNot0(R)}catch{return!1}}function s(x,R){let{publicKey:B,publicKeyUncompressed:C}=i;try{let U=x.length;return R===!0&&U!==B||R===!1&&U!==C?!1:!!e.fromBytes(x)}catch{return!1}}function a(x){return x=x===void 0?n(i.seed):x,Wo(De(x,i.seed,"seed"),r.ORDER)}function c(x,R=!0){return e.BASE.multiply(r.fromBytes(x)).toBytes(R)}function l(x){let{secretKey:R,publicKey:B,publicKeyUncompressed:C}=i,U=r._lengths;if(!Fi(x))return;let V=De(x,void 0,"key").length,z=V===B||V===C,j=V===R||!!U?.includes(V);if(!(z&&j))return z}function g(x,R,B=!0){if(l(x)===!0)throw new Error("first arg must be private key");if(l(R)===!1)throw new Error("second arg must be public key");let C=r.fromBytes(x);return e.fromBytes(R).multiply(C).toBytes(B)}let m={isValidSecretKey:o,isValidPublicKey:s,randomSecretKey:a},_=Cf(a,c);return Object.freeze(m),Object.freeze(i),Object.freeze({getPublicKey:c,getSharedSecret:g,keygen:_,Point:e,utils:m,lengths:i})}function c1(e,t,r={}){let n=t;Ef(n),Er(r,{},{hmac:"function",lowS:"boolean",randomBytes:"function",bits2int:"function",bits2int_modN:"function"}),r=Object.assign({},r);let i=r.randomBytes===void 0?nr:r.randomBytes,o=r.hmac===void 0?(b,E)=>n1(n,b,E):r.hmac,{Fp:s,Fn:a}=e,{ORDER:c,BITS:l}=a,{keygen:g,getPublicKey:m,getSharedSecret:_,utils:x,lengths:R}=s3(e,r),B={prehash:!0,lowS:typeof r.lowS=="boolean"?r.lowS:!0,format:"compact",extraEntropy:!1},C=c*sn+Ut<s.ORDER;function U(b){let E=c>>Ut;return b>E}function V(b,E){if(!a.isValidNot0(E))throw new Error(`invalid signature ${b}: out of range 1..Point.Fn.ORDER`);return E}function z(){if(C)throw new Error('"recovered" sig type is not supported for cofactor >2 curves')}function j(b,E){_d(E);let O=R.signature,w=E==="compact"?O:E==="recovered"?O+1:void 0;return De(b,w)}class Y{constructor(E,O,w){fe(this,"r");fe(this,"s");fe(this,"recovery");if(this.r=V("r",E),this.s=V("s",O),w!=null){if(z(),![0,1,2,3].includes(w))throw new Error("invalid recovery id");this.recovery=w}Object.freeze(this)}static fromBytes(E,O=B.format){j(E,O);let w;if(O==="der"){let{r:q,s:W}=kr.toSig(De(E));return new Y(q,W)}O==="recovered"&&(w=E[0],O="compact",E=E.subarray(1));let f=R.signature/2,S=E.subarray(0,f),H=E.subarray(f,f*2);return new Y(a.fromBytes(S),a.fromBytes(H),w)}static fromHex(E,O){return this.fromBytes(jo(E),O)}assertRecovery(){let{recovery:E}=this;if(E==null)throw new Error("invalid recovery id: must be present");return E}addRecoveryBit(E){return new Y(this.r,this.s,E)}recoverPublicKey(E){let{r:O,s:w}=this,f=this.assertRecovery(),S=f===2||f===3?O+c:O;if(!s.isValid(S))throw new Error("invalid recovery id: sig.r+curve.n != R.x");let H=s.toBytes(S),q=e.fromBytes(ke(a1((f&1)===0),H)),W=a.inv(S),$=Q(De(E,void 0,"msgHash")),X=a.create(-$*W),ae=a.create(w*W),ge=e.BASE.multiplyUnsafe(X).add(q.multiplyUnsafe(ae));if(ge.is0())throw new Error("invalid recovery: point at infinify");return ge.assertValidity(),ge}hasHighS(){return U(this.s)}toBytes(E=B.format){if(_d(E),E==="der")return jo(kr.hexFromSig(this));let{r:O,s:w}=this,f=a.toBytes(O),S=a.toBytes(w);return E==="recovered"?(z(),ke(Uint8Array.of(this.assertRecovery()),f,S)):ke(f,S)}toHex(E){return Nn(this.toBytes(E))}}Object.freeze(Y.prototype),Object.freeze(Y);let oe=r.bits2int===void 0?function(E){if(E.length>8192)throw new Error("input is too large");let O=Xt(E),w=E.length*8-l;return w>0?O>>BigInt(w):O}:r.bits2int,Q=r.bits2int_modN===void 0?function(E){return a.create(oe(E))}:r.bits2int_modN,se=Go(l);function ye(b){return ud("num < 2^"+l,b,xr,se),a.toBytes(b)}function A(b,E){return De(b,void 0,"message"),E?De(n(b),void 0,"prehashed message"):b}function u(b,E,O){let{lowS:w,prehash:f,extraEntropy:S}=bd(O,B);b=A(b,f);let H=Q(b),q=a.fromBytes(E);if(!a.isValidNot0(q))throw new Error("invalid private key");let W=[ye(q),ye(H)];if(S!=null&&S!==!1){let ge=S===!0?i(R.secretKey):S;W.push(De(ge,void 0,"extraEntropy"))}let $=ke(...W),X=H;function ae(ge){let le=oe(ge);if(!a.isValidNot0(le))return;let T=a.inv(le),k=e.BASE.multiply(le).toAffine(),F=a.create(k.x);if(F===xr)return;let K=a.create(T*a.create(X+F*q));if(K===xr)return;let ne=(k.x===F?0:2)|Number(k.y&Ut),J=K;return w&&U(K)&&(J=a.neg(K),ne^=1),new Y(F,J,C?void 0:ne)}return{seed:$,k2sig:ae}}function h(b,E,O={}){let{seed:w,k2sig:f}=u(b,E,O);return R_(n.outputLen,a.BYTES,o)(w,f).toBytes(O.format)}function y(b,E,O,w={}){let{lowS:f,prehash:S,format:H}=bd(w,B);if(O=De(O,void 0,"publicKey"),E=A(E,S),!Fi(b)){let q=b instanceof Y?", use sig.toBytes()":"";throw new Error("verify expects Uint8Array signature"+q)}j(b,H);try{let q=Y.fromBytes(b,H),W=e.fromBytes(O);if(f&&q.hasHighS())return!1;let{r:$,s:X}=q,ae=Q(E),ge=a.inv(X),le=a.create(ae*ge),T=a.create($*ge),k=e.BASE.multiplyUnsafe(le).add(W.multiplyUnsafe(T));return k.is0()?!1:a.create(k.x)===$}catch{return!1}}function v(b,E,O={}){let{prehash:w}=bd(O,B);return E=A(E,w),Y.fromBytes(b,"recovered").recoverPublicKey(E).toBytes()}return Object.freeze({keygen:g,getPublicKey:m,getSharedSecret:_,utils:x,lengths:R,Point:e,sign:h,verify:y,recoverPublicKey:v,Signature:Y,hash:n})}var o1,wd,kr,xr,Ut,sn,Xo,Sd,h1=fr(()=>{p();i1();ii();Ki();Lf();Yo();o1=(e,t)=>(e+(e>=0?t:-t)/sn)/t;wd=class extends Error{constructor(t=""){super(t)}},kr={Err:wd,_tlv:{encode:(e,t)=>{let{Err:r}=kr;if(Sr(e,"tag"),e<0||e>255)throw new r("tlv.encode: wrong tag");if(typeof t!="string")throw new TypeError('"data" expected string, got type='+typeof t);if(t.length&1)throw new r("tlv.encode: unpadded data");let n=t.length/2,i=sa(n);if(i.length/2&128)throw new r("tlv.encode: long form length too big");let o=n>127?sa(i.length/2|128):"";return sa(e)+o+i+t},decode(e,t){let{Err:r}=kr;t=De(t,void 0,"DER data");let n=0;if(e<0||e>255)throw new r("tlv.encode: wrong tag");if(t.length<2||t[n++]!==e)throw new r("tlv.decode: wrong tlv");let i=t[n++],o=!!(i&128),s=0;if(!o)s=i;else{let c=i&127;if(!c)throw new r("tlv.decode(long): indefinite length not supported");if(c>4)throw new r("tlv.decode(long): byte length is too big");let l=t.subarray(n,n+c);if(l.length!==c)throw new r("tlv.decode: length bytes not complete");if(l[0]===0)throw new r("tlv.decode(long): zero leftmost byte");for(let g of l)s=s<<8|g;if(n+=c,s<128)throw new r("tlv.decode(long): not minimal encoding")}let a=t.subarray(n,n+s);if(a.length!==s)throw new r("tlv.decode: wrong value length");return{v:a,l:t.subarray(n+s)}}},_int:{encode(e){let{Err:t}=kr;if(Pf(e),e<xr)throw new t("integer: negative integers are not allowed");let r=sa(e);if(Number.parseInt(r[0],16)&8&&(r="00"+r),r.length&1)throw new t("unexpected DER parsing assertion: unpadded hex");return r},decode(e){let{Err:t}=kr;if(e.length<1)throw new t("invalid signature integer: empty");if(e[0]&128)throw new t("invalid signature integer: negative");if(e.length>1&&e[0]===0&&!(e[1]&128))throw new t("invalid signature integer: unnecessary leading zero");return Xt(e)}},toSig(e){let{Err:t,_int:r,_tlv:n}=kr,i=De(e,void 0,"signature"),{v:o,l:s}=n.decode(48,i);if(s.length)throw new t("invalid signature: left bytes after parsing");let{v:a,l:c}=n.decode(2,o),{v:l,l:g}=n.decode(2,c);if(g.length)throw new t("invalid signature: left bytes after parsing");return{r:r.decode(a),s:r.decode(l)}},hexFromSig(e){let{_tlv:t,_int:r}=kr,n=t.encode(2,r.encode(e.r)),i=t.encode(2,r.encode(e.s)),o=n+i;return t.encode(48,o)}};Object.freeze(kr._tlv);Object.freeze(kr._int);Object.freeze(kr);xr=BigInt(0),Ut=BigInt(1),sn=BigInt(2),Xo=BigInt(3),Sd=BigInt(4)});var _1={};EI(_1,{__TEST:()=>h3,schnorr:()=>l3,schnorr_FROST:()=>b3,secp256k1:()=>f3,secp256k1_FROST:()=>g3,secp256k1_hasher:()=>Id});function u3(e){let t=qf.p,r=BigInt(3),n=BigInt(6),i=BigInt(11),o=BigInt(22),s=BigInt(23),a=BigInt(44),c=BigInt(88),l=e*e*e%t,g=l*l*e%t,m=hr(g,r,t)*g%t,_=hr(m,r,t)*g%t,x=hr(_,Ed,t)*l%t,R=hr(x,i,t)*x%t,B=hr(R,o,t)*R%t,C=hr(B,a,t)*B%t,U=hr(C,c,t)*C%t,V=hr(U,a,t)*B%t,z=hr(V,r,t)*g%t,j=hr(z,s,t)*R%t,Y=hr(j,n,t)*l%t,oe=hr(Y,Ed,t);if(!Mn.eql(Mn.sqr(oe),e))throw new Error("Cannot find square root");return oe}function fa(e,...t){let r=l1[e];if(r===void 0){let n=qi(Vo(e));r=ke(n,n),l1[e]=r}return qi(ke(r,...t))}function y1(e){let{Fn:t,BASE:r}=Ue,n=t.fromBytes(e),i=r.multiply(n);return{scalar:an(i.y)?n:t.neg(n),bytes:$i(i)}}function Ff(e){let t=Mn;if(!t.isValidNot0(e))throw new Error("invalid x: Fail if x \u2265 p");let r=t.create(e*e),n=t.create(r*e+BigInt(7)),i=t.sqrt(n);an(i)||(i=t.neg(i));let o=Ue.fromAffine({x:e,y:i});return o.assertValidity(),o}function xd(...e){return Ue.Fn.create(Jo(fa("BIP0340/challenge",...e)))}function d1(e){return y1(e).bytes}function c3(e,t,r=oa(32)){let{Fn:n,BASE:i}=Ue,o=De(e,void 0,"message"),{bytes:s,scalar:a}=y1(t),c=De(r,32,"auxRand"),l=n.toBytes(a^Jo(fa("BIP0340/aux",c))),g=fa("BIP0340/nonce",l,s,o),m=n.create(Jo(g));if(m===0n)throw new Error("sign failed: k is zero");let _=i.multiply(m),x=an(_.y)?m:n.neg(m),R=$i(_),B=xd(R,s,o),C=new Uint8Array(64);if(C.set(R,0),C.set(n.toBytes(n.create(x+B*a)),32),!m1(C,o,s))throw new Error("sign: Invalid signature produced");return C}function m1(e,t,r){let{Fp:n,Fn:i,BASE:o}=Ue,s=De(e,64,"signature"),a=De(t,void 0,"message"),c=De(r,32,"publicKey");try{let l=Ff(Jo(c)),g=Jo(s.subarray(0,32));if(!n.isValidNot0(g))return!1;let m=Jo(s.subarray(32,64));if(!i.isValidNot0(m))return!1;let _=xd(i.toBytes(g),$i(l),a),x=o.multiplyUnsafe(m).add(l.multiplyUnsafe(i.neg(_))),{x:R,y:B}=x.toAffine();return!(x.is0()||!an(B)||R!==g)}catch{return!1}}function v1(e,t){if(t===void 0)return g1;let r=$i(e),n=Xt(fa("TapTweak",r,t));if(!Ue.Fn.isValid(n))throw new Error("invalid TapTweak hash");return n}function Ad(e){let t=Ue.fromBytes(e.commitments[0]);return an(t.y)?e:{signers:{min:e.signers.min,max:e.signers.max},commitments:e.commitments.map(r=>Ue.fromBytes(r).negate().toBytes()),verifyingShares:Object.fromEntries(Object.entries(e.verifyingShares).map(([r,n])=>[r,Ue.fromBytes(n).negate().toBytes()]))}}function b1(e,t){let r=Ue.fromBytes(t.commitments[0]);if(an(r.y))return e;let n=Ue.Fn;return{...e,signingShare:n.toBytes(n.neg(n.fromBytes(e.signingShare)))}}function y3(e,t){if(an(e.y))return t;let r=Ue.Fn;return{binding:r.toBytes(r.neg(r.fromBytes(t.binding))),hiding:r.toBytes(r.neg(r.fromBytes(t.hiding)))}}function m3(e,t,r){let n=Ue.Fn,i=b1(e,t),o=Ad(t),s=v1(Ue.fromBytes(o.commitments[0]),r),a=n.toBytes(n.add(n.fromBytes(i.signingShare),s));return{identifier:i.identifier,signingShare:a}}function v3(e,t){let r=Ad(e),n=v1(Ue.fromBytes(r.commitments[0]),t),i=Ue.BASE.multiply(n),o=r.commitments.map((a,c)=>(c===0?Ue.fromBytes(a).add(i):Ue.fromBytes(a)).toBytes()),s={};for(let a in r.verifyingShares)s[a]=Ue.fromBytes(r.verifyingShares[a]).add(i).toBytes();return{signers:{min:r.signers.min,max:r.signers.max},commitments:o,verifyingShares:s}}var qf,a3,g1,Ed,Mn,Ue,f3,l1,$i,an,Jo,h3,l3,d3,p1,p3,Id,g3,b3,w1=fr(()=>{p();A_();ii();Lf();r1();e1();Yo();h1();Ki();qf={p:BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),n:BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),h:BigInt(1),a:BigInt(0),b:BigInt(7),Gx:BigInt("0x79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"),Gy:BigInt("0x483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8")},a3={beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),basises:[[BigInt("0x3086d221a7d46bcde86c90e49284eb15"),-BigInt("0xe4437ed6010e88286f547fa90abfe4c3")],[BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),BigInt("0x3086d221a7d46bcde86c90e49284eb15")]]},g1=BigInt(0),Ed=BigInt(2);Mn=zo(qf.p,{sqrt:u3}),Ue=s1(qf,{Fp:Mn,endo:a3}),f3=c1(Ue,qi),l1={};$i=e=>e.toBytes(!0).slice(1),an=e=>e%Ed===g1;Jo=Xt;h3=Object.freeze({lift_x:Ff}),l3=(()=>{let r=n=>(n=n===void 0?oa(48):n,Wo(n,qf.n));return Object.freeze({keygen:Cf(r,d1),getPublicKey:d1,sign:c3,verify:m1,Point:Ue,utils:Object.freeze({randomSecretKey:r,taggedHash:fa,lift_x:Ff,pointToBytes:$i}),lengths:Object.freeze({secretKey:32,publicKey:32,publicKeyHasPrefix:!1,signature:64,seed:48})})})(),d3=J_(Mn,[["0x8e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38daaaaa8c7","0x7d3d4c80bc321d5b9f315cea7fd44c5d595d2fc0bf63b92dfff1044f17c6581","0x534c328d23f234e6e2a413deca25caece4506144037c40314ecbd0b53d9dd262","0x8e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38daaaaa88c"],["0xd35771193d94918a9ca34ccbb7b640dd86cd409542f8487d9fe6b745781eb49b","0xedadc6f64383dc1df7c4b2d51b54225406d36b641f5e41bbc52a56612a8c6d14","0x0000000000000000000000000000000000000000000000000000000000000001"],["0x4bda12f684bda12f684bda12f684bda12f684bda12f684bda12f684b8e38e23c","0xc75e0c32d5cb7c0fa9d0a54b12a0a6d5647ab046d686da6fdffc90fc201d71a3","0x29a6194691f91a73715209ef6512e576722830a201be2018a765e85a9ecee931","0x2f684bda12f684bda12f684bda12f684bda12f684bda12f684bda12f38e38d84"],["0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffff93b","0x7a06534bb8bdb49fd5e9e6632722c2989467c1bfc8e8d978dfb425d2685c2573","0x6484aa716545ca2cf3a70c3fa8fe337e0a3d21162f0d6299a7bf8192bfd2a76f","0x0000000000000000000000000000000000000000000000000000000000000001"]].map(e=>e.map(t=>BigInt(t)))),p3=()=>p1||(p1=u1(Mn,{A:BigInt("0x3f8731abdd661adca08a5558f0f5d272e953d363cb6f0e5d405447c01a444533"),B:BigInt("1771"),Z:Mn.create(BigInt("-11"))})),Id=Q_(Ue,e=>{let{x:t,y:r}=p3()(Mn.create(e[0]));return d3(t,r)},{DST:"secp256k1_XMD:SHA-256_SSWU_RO_",encodeDST:"secp256k1_XMD:SHA-256_SSWU_NU_",p:Mn.ORDER,m:1,k:128,expand:"xmd",hash:qi}),g3=vd({name:"FROST-secp256k1-SHA256-v1",Point:Ue,hashToScalar:Id.hashToScalar,hash:qi});b3=vd({name:"FROST-secp256k1-SHA256-TR-v1",Point:Ue,hashToScalar:Id.hashToScalar,hash:qi,parsePublicKey(e){if(e.length===32)return Ff(Xt(e));if(e.length===33)return Ue.fromBytes(e);throw new Error(`expected x-only or compressed public key, got length=${e.length}`)},adjustScalar(e){let t=Ue.BASE.multiply(e);return an(t.y)?e:Ue.Fn.neg(e)},adjustPoint:e=>an(e.y)?e:e.negate(),challenge(e,t,r){return xd($i(e),$i(t),r)},adjustNonces:y3,adjustGroupCommitmentShare:(e,t)=>an(e.y)?t:t.negate(),adjustPublic:Ad,adjustSecret:b1,adjustTx:{encode:e=>e.subarray(1),decode:e=>ke(Uint8Array.of(2),e)},adjustDKG:e=>{let t=new Uint8Array(0);return{public:v3(e.public,t),secret:m3(e.secret,e.public,t)}}})});var si=P((Rq,I1)=>{"use strict";p();var S1=wr(),{secp256k1:_3}=(w1(),xI(_1)),ha=_3.Point,Hf=ha.Fn.ORDER;function w3(e){return BigInt("0x"+(e.toString(16)||"0"))}function Od(e){var t=e.toString(16);return t.length%2&&(t="0"+t),new S1(t,16)}function jf(e){if(e==null)throw new Error("Invalid Point");if(typeof e=="bigint")return e;if(typeof e=="number")return BigInt(e);if(typeof e=="string")return BigInt(e.indexOf("0x")===0?e:"0x"+e);if(typeof e.toString=="function")return w3(e);throw new Error("Invalid Point")}function ca(e){var t=Object.create(qe.prototype);return t._p=e,t}function E1(e,t){var r=jf(t).toString(16).padStart(64,"0");return ha.fromHex((e?"03":"02")+r)}function x1(e,t){var r;try{r=E1((t&1n)===1n,e)}catch{throw new Error("Point does not lie on the curve")}if(r.toAffine().y!==t)throw new Error("Invalid y value for curve.")}function qe(e,t,r){if(!(this instanceof qe))return new qe(e,t,r);var n,i;try{n=jf(e),i=jf(t)}catch{throw new Error("Invalid Point")}x1(n,i);try{this._p=ha.fromAffine({x:n,y:i})}catch{throw new Error("Invalid Point")}return this}qe.fromX=function(t,r){try{var n=ca(E1(t,r))}catch{throw new Error("Invalid X")}return n.validate(),n};qe.getG=function(){return ca(ha.BASE)};qe.getN=function(){return Od(Hf)};qe.prototype.getX=function(){return Od(this._p.toAffine().x)};qe.prototype.getY=function(){return Od(this._p.toAffine().y)};Object.defineProperty(qe.prototype,"x",{configurable:!0,enumerable:!0,get:function(){return this.getX()}});Object.defineProperty(qe.prototype,"y",{configurable:!0,enumerable:!0,get:function(){return this.getY()}});qe.prototype.mul=function(t){var r=(jf(t)%Hf+Hf)%Hf;return r===0n||this._p.is0()?ca(ha.ZERO):ca(this._p.multiply(r))};qe.prototype.add=function(t){return ca(this._p.add(t._p))};qe.prototype.mulAdd=function(t,r,n){return this.mul(t).add(r.mul(n))};qe.prototype.eq=function(t){return this._p.equals(t._p)};qe.prototype.isInfinity=function(){return this._p.is0()};qe.prototype.validate=function(){if(this.isInfinity())throw new Error("Point cannot be equal to Infinity");var t=this._p.toAffine();return x1(t.x,t.y),this};qe.pointToCompressed=function(t){var r=t.getX().toBuffer({size:32}),n=t.getY().toBuffer({size:32}),i,o=n[n.length-1]%2;return o?i=d.Buffer.from([3]):i=d.Buffer.from([2]),d.Buffer.concat([i,r])};qe.pointFromCompressed=function(e){if(e.length!==33)throw new Error("invalid buffer length");var t=e[0],r;if(t===3)r=!0;else if(t===2)r=!1;else throw new Error("invalid value of compressed prefix");var n=S1.fromBuffer(e.slice(1,33));return qe.fromX(r,n)};qe.prototype.toBuffer=function(){return qe.pointToCompressed(this)};qe.prototype.toHex=function(){return this.toBuffer().toString("hex")};qe.fromBuffer=function(e){return qe.pointFromCompressed(e)};qe.fromHex=function(e){return qe.fromBuffer(d.Buffer.from(e,"hex"))};I1.exports=qe});var Qo=P((Pq,O1)=>{p();O1.exports=A1;function A1(e,t){if(!e)throw new Error(t||"Assertion failed")}A1.equal=function(t,r,n){if(t!=r)throw new Error(n||"Assertion failed: "+t+" != "+r)}});var Cr=P(Fe=>{"use strict";p();var S3=Qo(),E3=Te();Fe.inherits=E3;function x3(e,t){return(e.charCodeAt(t)&64512)!==55296||t<0||t+1>=e.length?!1:(e.charCodeAt(t+1)&64512)===56320}function I3(e,t){if(Array.isArray(e))return e.slice();if(!e)return[];var r=[];if(typeof e=="string")if(t){if(t==="hex")for(e=e.replace(/[^a-z0-9]+/ig,""),e.length%2!==0&&(e="0"+e),i=0;i<e.length;i+=2)r.push(parseInt(e[i]+e[i+1],16))}else for(var n=0,i=0;i<e.length;i++){var o=e.charCodeAt(i);o<128?r[n++]=o:o<2048?(r[n++]=o>>6|192,r[n++]=o&63|128):x3(e,i)?(o=65536+((o&1023)<<10)+(e.charCodeAt(++i)&1023),r[n++]=o>>18|240,r[n++]=o>>12&63|128,r[n++]=o>>6&63|128,r[n++]=o&63|128):(r[n++]=o>>12|224,r[n++]=o>>6&63|128,r[n++]=o&63|128)}else for(i=0;i<e.length;i++)r[i]=e[i]|0;return r}Fe.toArray=I3;function A3(e){for(var t="",r=0;r<e.length;r++)t+=T1(e[r].toString(16));return t}Fe.toHex=A3;function R1(e){var t=e>>>24|e>>>8&65280|e<<8&16711680|(e&255)<<24;return t>>>0}Fe.htonl=R1;function O3(e,t){for(var r="",n=0;n<e.length;n++){var i=e[n];t==="little"&&(i=R1(i)),r+=P1(i.toString(16))}return r}Fe.toHex32=O3;function T1(e){return e.length===1?"0"+e:e}Fe.zero2=T1;function P1(e){return e.length===7?"0"+e:e.length===6?"00"+e:e.length===5?"000"+e:e.length===4?"0000"+e:e.length===3?"00000"+e:e.length===2?"000000"+e:e.length===1?"0000000"+e:e}Fe.zero8=P1;function R3(e,t,r,n){var i=r-t;S3(i%4===0);for(var o=new Array(i/4),s=0,a=t;s<o.length;s++,a+=4){var c;n==="big"?c=e[a]<<24|e[a+1]<<16|e[a+2]<<8|e[a+3]:c=e[a+3]<<24|e[a+2]<<16|e[a+1]<<8|e[a],o[s]=c>>>0}return o}Fe.join32=R3;function T3(e,t){for(var r=new Array(e.length*4),n=0,i=0;n<e.length;n++,i+=4){var o=e[n];t==="big"?(r[i]=o>>>24,r[i+1]=o>>>16&255,r[i+2]=o>>>8&255,r[i+3]=o&255):(r[i+3]=o>>>24,r[i+2]=o>>>16&255,r[i+1]=o>>>8&255,r[i]=o&255)}return r}Fe.split32=T3;function P3(e,t){return e>>>t|e<<32-t}Fe.rotr32=P3;function B3(e,t){return e<<t|e>>>32-t}Fe.rotl32=B3;function N3(e,t){return e+t>>>0}Fe.sum32=N3;function M3(e,t,r){return e+t+r>>>0}Fe.sum32_3=M3;function k3(e,t,r,n){return e+t+r+n>>>0}Fe.sum32_4=k3;function C3(e,t,r,n,i){return e+t+r+n+i>>>0}Fe.sum32_5=C3;function L3(e,t,r,n){var i=e[t],o=e[t+1],s=n+o>>>0,a=(s<n?1:0)+r+i;e[t]=a>>>0,e[t+1]=s}Fe.sum64=L3;function D3(e,t,r,n){var i=t+n>>>0,o=(i<t?1:0)+e+r;return o>>>0}Fe.sum64_hi=D3;function U3(e,t,r,n){var i=t+n;return i>>>0}Fe.sum64_lo=U3;function q3(e,t,r,n,i,o,s,a){var c=0,l=t;l=l+n>>>0,c+=l<t?1:0,l=l+o>>>0,c+=l<o?1:0,l=l+a>>>0,c+=l<a?1:0;var g=e+r+i+s+c;return g>>>0}Fe.sum64_4_hi=q3;function F3(e,t,r,n,i,o,s,a){var c=t+n+o+a;return c>>>0}Fe.sum64_4_lo=F3;function H3(e,t,r,n,i,o,s,a,c,l){var g=0,m=t;m=m+n>>>0,g+=m<t?1:0,m=m+o>>>0,g+=m<o?1:0,m=m+a>>>0,g+=m<a?1:0,m=m+l>>>0,g+=m<l?1:0;var _=e+r+i+s+c+g;return _>>>0}Fe.sum64_5_hi=H3;function j3(e,t,r,n,i,o,s,a,c,l){var g=t+n+o+a+l;return g>>>0}Fe.sum64_5_lo=j3;function K3(e,t,r){var n=t<<32-r|e>>>r;return n>>>0}Fe.rotr64_hi=K3;function V3(e,t,r){var n=e<<32-r|t>>>r;return n>>>0}Fe.rotr64_lo=V3;function G3(e,t,r){return e>>>r}Fe.shr64_hi=G3;function z3(e,t,r){var n=e<<32-r|t>>>r;return n>>>0}Fe.shr64_lo=z3});var es=P(N1=>{"use strict";p();var B1=Cr(),W3=Qo();function Kf(){this.pending=null,this.pendingTotal=0,this.blockSize=this.constructor.blockSize,this.outSize=this.constructor.outSize,this.hmacStrength=this.constructor.hmacStrength,this.padLength=this.constructor.padLength/8,this.endian="big",this._delta8=this.blockSize/8,this._delta32=this.blockSize/32}N1.BlockHash=Kf;Kf.prototype.update=function(t,r){if(t=B1.toArray(t,r),this.pending?this.pending=this.pending.concat(t):this.pending=t,this.pendingTotal+=t.length,this.pending.length>=this._delta8){t=this.pending;var n=t.length%this._delta8;this.pending=t.slice(t.length-n,t.length),this.pending.length===0&&(this.pending=null),t=B1.join32(t,0,t.length-n,this.endian);for(var i=0;i<t.length;i+=this._delta32)this._update(t,i,i+this._delta32)}return this};Kf.prototype.digest=function(t){return this.update(this._pad()),W3(this.pending===null),this._digest(t)};Kf.prototype._pad=function(){var t=this.pendingTotal,r=this._delta8,n=r-(t+this.padLength)%r,i=new Array(n+this.padLength);i[0]=128;for(var o=1;o<n;o++)i[o]=0;if(t<<=3,this.endian==="big"){for(var s=8;s<this.padLength;s++)i[o++]=0;i[o++]=0,i[o++]=0,i[o++]=0,i[o++]=0,i[o++]=t>>>24&255,i[o++]=t>>>16&255,i[o++]=t>>>8&255,i[o++]=t&255}else for(i[o++]=t&255,i[o++]=t>>>8&255,i[o++]=t>>>16&255,i[o++]=t>>>24&255,i[o++]=0,i[o++]=0,i[o++]=0,i[o++]=0,s=8;s<this.padLength;s++)i[o++]=0;return i}});var Rd=P(kn=>{"use strict";p();var Y3=Cr(),un=Y3.rotr32;function $3(e,t,r,n){if(e===0)return M1(t,r,n);if(e===1||e===3)return C1(t,r,n);if(e===2)return k1(t,r,n)}kn.ft_1=$3;function M1(e,t,r){return e&t^~e&r}kn.ch32=M1;function k1(e,t,r){return e&t^e&r^t&r}kn.maj32=k1;function C1(e,t,r){return e^t^r}kn.p32=C1;function Z3(e){return un(e,2)^un(e,13)^un(e,22)}kn.s0_256=Z3;function X3(e){return un(e,6)^un(e,11)^un(e,25)}kn.s1_256=X3;function J3(e){return un(e,7)^un(e,18)^e>>>3}kn.g0_256=J3;function Q3(e){return un(e,17)^un(e,19)^e>>>10}kn.g1_256=Q3});var U1=P((Uq,D1)=>{"use strict";p();var ts=Cr(),eN=es(),tN=Rd(),Td=ts.rotl32,la=ts.sum32,rN=ts.sum32_5,nN=tN.ft_1,L1=eN.BlockHash,iN=[1518500249,1859775393,2400959708,3395469782];function fn(){if(!(this instanceof fn))return new fn;L1.call(this),this.h=[1732584193,4023233417,2562383102,271733878,3285377520],this.W=new Array(80)}ts.inherits(fn,L1);D1.exports=fn;fn.blockSize=512;fn.outSize=160;fn.hmacStrength=80;fn.padLength=64;fn.prototype._update=function(t,r){for(var n=this.W,i=0;i<16;i++)n[i]=t[r+i];for(;i<n.length;i++)n[i]=Td(n[i-3]^n[i-8]^n[i-14]^n[i-16],1);var o=this.h[0],s=this.h[1],a=this.h[2],c=this.h[3],l=this.h[4];for(i=0;i<n.length;i++){var g=~~(i/20),m=rN(Td(o,5),nN(g,s,a,c),l,n[i],iN[g]);l=c,c=a,a=Td(s,30),s=o,o=m}this.h[0]=la(this.h[0],o),this.h[1]=la(this.h[1],s),this.h[2]=la(this.h[2],a),this.h[3]=la(this.h[3],c),this.h[4]=la(this.h[4],l)};fn.prototype._digest=function(t){return t==="hex"?ts.toHex32(this.h,"big"):ts.split32(this.h,"big")}});var Pd=P((Fq,F1)=>{"use strict";p();var rs=Cr(),oN=es(),ns=Rd(),sN=Qo(),Lr=rs.sum32,aN=rs.sum32_4,uN=rs.sum32_5,fN=ns.ch32,cN=ns.maj32,hN=ns.s0_256,lN=ns.s1_256,dN=ns.g0_256,pN=ns.g1_256,q1=oN.BlockHash,gN=[1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298];function cn(){if(!(this instanceof cn))return new cn;q1.call(this),this.h=[1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225],this.k=gN,this.W=new Array(64)}rs.inherits(cn,q1);F1.exports=cn;cn.blockSize=512;cn.outSize=256;cn.hmacStrength=192;cn.padLength=64;cn.prototype._update=function(t,r){for(var n=this.W,i=0;i<16;i++)n[i]=t[r+i];for(;i<n.length;i++)n[i]=aN(pN(n[i-2]),n[i-7],dN(n[i-15]),n[i-16]);var o=this.h[0],s=this.h[1],a=this.h[2],c=this.h[3],l=this.h[4],g=this.h[5],m=this.h[6],_=this.h[7];for(sN(this.k.length===n.length),i=0;i<n.length;i++){var x=uN(_,lN(l),fN(l,g,m),this.k[i],n[i]),R=Lr(hN(o),cN(o,s,a));_=m,m=g,g=l,l=Lr(c,x),c=a,a=s,s=o,o=Lr(x,R)}this.h[0]=Lr(this.h[0],o),this.h[1]=Lr(this.h[1],s),this.h[2]=Lr(this.h[2],a),this.h[3]=Lr(this.h[3],c),this.h[4]=Lr(this.h[4],l),this.h[5]=Lr(this.h[5],g),this.h[6]=Lr(this.h[6],m),this.h[7]=Lr(this.h[7],_)};cn.prototype._digest=function(t){return t==="hex"?rs.toHex32(this.h,"big"):rs.split32(this.h,"big")}});var K1=P((jq,j1)=>{"use strict";p();var Bd=Cr(),H1=Pd();function Cn(){if(!(this instanceof Cn))return new Cn;H1.call(this),this.h=[3238371032,914150663,812702999,4144912697,4290775857,1750603025,1694076839,3204075428]}Bd.inherits(Cn,H1);j1.exports=Cn;Cn.blockSize=512;Cn.outSize=224;Cn.hmacStrength=192;Cn.padLength=64;Cn.prototype._digest=function(t){return t==="hex"?Bd.toHex32(this.h.slice(0,7),"big"):Bd.split32(this.h.slice(0,7),"big")}});var kd=P((Vq,W1)=>{"use strict";p();var ir=Cr(),yN=es(),mN=Qo(),hn=ir.rotr64_hi,ln=ir.rotr64_lo,V1=ir.shr64_hi,G1=ir.shr64_lo,ai=ir.sum64,Nd=ir.sum64_hi,Md=ir.sum64_lo,vN=ir.sum64_4_hi,bN=ir.sum64_4_lo,_N=ir.sum64_5_hi,wN=ir.sum64_5_lo,z1=yN.BlockHash,SN=[1116352408,3609767458,1899447441,602891725,3049323471,3964484399,3921009573,2173295548,961987163,4081628472,1508970993,3053834265,2453635748,2937671579,2870763221,3664609560,3624381080,2734883394,310598401,1164996542,607225278,1323610764,1426881987,3590304994,1925078388,4068182383,2162078206,991336113,2614888103,633803317,3248222580,3479774868,3835390401,2666613458,4022224774,944711139,264347078,2341262773,604807628,2007800933,770255983,1495990901,1249150122,1856431235,1555081692,3175218132,1996064986,2198950837,2554220882,3999719339,2821834349,766784016,2952996808,2566594879,3210313671,3203337956,3336571891,1034457026,3584528711,2466948901,113926993,3758326383,338241895,168717936,666307205,1188179964,773529912,1546045734,1294757372,1522805485,1396182291,2643833823,1695183700,2343527390,1986661051,1014477480,2177026350,1206759142,2456956037,344077627,2730485921,1290863460,2820302411,3158454273,3259730800,3505952657,3345764771,106217008,3516065817,3606008344,3600352804,1432725776,4094571909,1467031594,275423344,851169720,430227734,3100823752,506948616,1363258195,659060556,3750685593,883997877,3785050280,958139571,3318307427,1322822218,3812723403,1537002063,2003034995,1747873779,3602036899,1955562222,1575990012,2024104815,1125592928,2227730452,2716904306,2361852424,442776044,2428436474,593698344,2756734187,3733110249,3204031479,2999351573,3329325298,3815920427,3391569614,3928383900,3515267271,566280711,3940187606,3454069534,4118630271,4000239992,116418474,1914138554,174292421,2731055270,289380356,3203993006,460393269,320620315,685471733,587496836,852142971,1086792851,1017036298,365543100,1126000580,2618297676,1288033470,3409855158,1501505948,4234509866,1607167915,987167468,1816402316,1246189591];function Dr(){if(!(this instanceof Dr))return new Dr;z1.call(this),this.h=[1779033703,4089235720,3144134277,2227873595,1013904242,4271175723,2773480762,1595750129,1359893119,2917565137,2600822924,725511199,528734635,4215389547,1541459225,327033209],this.k=SN,this.W=new Array(160)}ir.inherits(Dr,z1);W1.exports=Dr;Dr.blockSize=1024;Dr.outSize=512;Dr.hmacStrength=192;Dr.padLength=128;Dr.prototype._prepareBlock=function(t,r){for(var n=this.W,i=0;i<32;i++)n[i]=t[r+i];for(;i<n.length;i+=2){var o=MN(n[i-4],n[i-3]),s=kN(n[i-4],n[i-3]),a=n[i-14],c=n[i-13],l=BN(n[i-30],n[i-29]),g=NN(n[i-30],n[i-29]),m=n[i-32],_=n[i-31];n[i]=vN(o,s,a,c,l,g,m,_),n[i+1]=bN(o,s,a,c,l,g,m,_)}};Dr.prototype._update=function(t,r){this._prepareBlock(t,r);var n=this.W,i=this.h[0],o=this.h[1],s=this.h[2],a=this.h[3],c=this.h[4],l=this.h[5],g=this.h[6],m=this.h[7],_=this.h[8],x=this.h[9],R=this.h[10],B=this.h[11],C=this.h[12],U=this.h[13],V=this.h[14],z=this.h[15];mN(this.k.length===n.length);for(var j=0;j<n.length;j+=2){var Y=V,oe=z,Q=TN(_,x),se=PN(_,x),ye=EN(_,x,R,B,C,U),A=xN(_,x,R,B,C,U),u=this.k[j],h=this.k[j+1],y=n[j],v=n[j+1],b=_N(Y,oe,Q,se,ye,A,u,h,y,v),E=wN(Y,oe,Q,se,ye,A,u,h,y,v);Y=ON(i,o),oe=RN(i,o),Q=IN(i,o,s,a,c,l),se=AN(i,o,s,a,c,l);var O=Nd(Y,oe,Q,se),w=Md(Y,oe,Q,se);V=C,z=U,C=R,U=B,R=_,B=x,_=Nd(g,m,b,E),x=Md(m,m,b,E),g=c,m=l,c=s,l=a,s=i,a=o,i=Nd(b,E,O,w),o=Md(b,E,O,w)}ai(this.h,0,i,o),ai(this.h,2,s,a),ai(this.h,4,c,l),ai(this.h,6,g,m),ai(this.h,8,_,x),ai(this.h,10,R,B),ai(this.h,12,C,U),ai(this.h,14,V,z)};Dr.prototype._digest=function(t){return t==="hex"?ir.toHex32(this.h,"big"):ir.split32(this.h,"big")};function EN(e,t,r,n,i){var o=e&r^~e&i;return o<0&&(o+=4294967296),o}function xN(e,t,r,n,i,o){var s=t&n^~t&o;return s<0&&(s+=4294967296),s}function IN(e,t,r,n,i){var o=e&r^e&i^r&i;return o<0&&(o+=4294967296),o}function AN(e,t,r,n,i,o){var s=t&n^t&o^n&o;return s<0&&(s+=4294967296),s}function ON(e,t){var r=hn(e,t,28),n=hn(t,e,2),i=hn(t,e,7),o=r^n^i;return o<0&&(o+=4294967296),o}function RN(e,t){var r=ln(e,t,28),n=ln(t,e,2),i=ln(t,e,7),o=r^n^i;return o<0&&(o+=4294967296),o}function TN(e,t){var r=hn(e,t,14),n=hn(e,t,18),i=hn(t,e,9),o=r^n^i;return o<0&&(o+=4294967296),o}function PN(e,t){var r=ln(e,t,14),n=ln(e,t,18),i=ln(t,e,9),o=r^n^i;return o<0&&(o+=4294967296),o}function BN(e,t){var r=hn(e,t,1),n=hn(e,t,8),i=V1(e,t,7),o=r^n^i;return o<0&&(o+=4294967296),o}function NN(e,t){var r=ln(e,t,1),n=ln(e,t,8),i=G1(e,t,7),o=r^n^i;return o<0&&(o+=4294967296),o}function MN(e,t){var r=hn(e,t,19),n=hn(t,e,29),i=V1(e,t,6),o=r^n^i;return o<0&&(o+=4294967296),o}function kN(e,t){var r=ln(e,t,19),n=ln(t,e,29),i=G1(e,t,6),o=r^n^i;return o<0&&(o+=4294967296),o}});var Z1=P((zq,$1)=>{"use strict";p();var Cd=Cr(),Y1=kd();function Ln(){if(!(this instanceof Ln))return new Ln;Y1.call(this),this.h=[3418070365,3238371032,1654270250,914150663,2438529370,812702999,355462360,4144912697,1731405415,4290775857,2394180231,1750603025,3675008525,1694076839,1203062813,3204075428]}Cd.inherits(Ln,Y1);$1.exports=Ln;Ln.blockSize=1024;Ln.outSize=384;Ln.hmacStrength=192;Ln.padLength=128;Ln.prototype._digest=function(t){return t==="hex"?Cd.toHex32(this.h.slice(0,12),"big"):Cd.split32(this.h.slice(0,12),"big")}});var X1=P(is=>{"use strict";p();is.sha1=U1();is.sha224=K1();is.sha256=Pd();is.sha384=Z1();is.sha512=kd()});var nw=P(rw=>{"use strict";p();var Zi=Cr(),CN=es(),Vf=Zi.rotl32,J1=Zi.sum32,da=Zi.sum32_3,Q1=Zi.sum32_4,tw=CN.BlockHash;function dn(){if(!(this instanceof dn))return new dn;tw.call(this),this.h=[1732584193,4023233417,2562383102,271733878,3285377520],this.endian="little"}Zi.inherits(dn,tw);rw.ripemd160=dn;dn.blockSize=512;dn.outSize=160;dn.hmacStrength=192;dn.padLength=64;dn.prototype._update=function(t,r){for(var n=this.h[0],i=this.h[1],o=this.h[2],s=this.h[3],a=this.h[4],c=n,l=i,g=o,m=s,_=a,x=0;x<80;x++){var R=J1(Vf(Q1(n,ew(x,i,o,s),t[UN[x]+r],LN(x)),FN[x]),a);n=a,a=s,s=Vf(o,10),o=i,i=R,R=J1(Vf(Q1(c,ew(79-x,l,g,m),t[qN[x]+r],DN(x)),HN[x]),_),c=_,_=m,m=Vf(g,10),g=l,l=R}R=da(this.h[1],o,m),this.h[1]=da(this.h[2],s,_),this.h[2]=da(this.h[3],a,c),this.h[3]=da(this.h[4],n,l),this.h[4]=da(this.h[0],i,g),this.h[0]=R};dn.prototype._digest=function(t){return t==="hex"?Zi.toHex32(this.h,"little"):Zi.split32(this.h,"little")};function ew(e,t,r,n){return e<=15?t^r^n:e<=31?t&r|~t&n:e<=47?(t|~r)^n:e<=63?t&n|r&~n:t^(r|~n)}function LN(e){return e<=15?0:e<=31?1518500249:e<=47?1859775393:e<=63?2400959708:2840853838}function DN(e){return e<=15?1352829926:e<=31?1548603684:e<=47?1836072691:e<=63?2053994217:0}var UN=[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,7,4,13,1,10,6,15,3,12,0,9,5,2,14,11,8,3,10,14,4,9,15,8,1,2,7,0,6,13,11,5,12,1,9,11,10,0,8,12,4,13,3,7,15,14,5,6,2,4,0,5,9,7,12,2,10,14,1,3,8,11,6,15,13],qN=[5,14,7,0,9,2,11,4,13,6,15,8,1,10,3,12,6,11,3,7,0,13,5,10,14,15,8,12,4,9,1,2,15,5,1,3,7,14,6,9,11,8,12,2,10,0,4,13,8,6,4,1,3,11,15,0,5,12,2,13,9,7,10,14,12,15,10,4,1,5,8,7,6,2,13,14,0,3,9,11],FN=[11,14,15,12,5,8,7,9,11,13,14,15,6,7,9,8,7,6,8,13,11,9,7,15,7,12,15,9,11,7,13,12,11,13,6,7,14,9,13,15,14,8,13,6,5,12,7,5,11,12,14,15,14,15,9,8,9,14,5,6,8,6,5,12,9,15,5,11,6,8,13,12,5,12,13,14,11,8,5,6],HN=[8,9,9,11,13,15,15,5,7,7,8,11,14,14,12,6,9,13,15,7,12,8,9,11,7,7,12,7,6,15,13,11,9,7,15,11,8,6,6,14,12,13,5,14,13,13,7,5,15,5,8,11,14,14,6,14,6,9,12,9,12,5,15,8,8,5,12,9,12,5,14,6,8,13,6,5,15,13,11,11]});var ow=P((Jq,iw)=>{"use strict";p();var jN=Cr(),KN=Qo();function os(e,t,r){if(!(this instanceof os))return new os(e,t,r);this.Hash=e,this.blockSize=e.blockSize/8,this.outSize=e.outSize/8,this.inner=null,this.outer=null,this._init(jN.toArray(t,r))}iw.exports=os;os.prototype._init=function(t){t.length>this.blockSize&&(t=new this.Hash().update(t).digest()),KN(t.length<=this.blockSize);for(var r=t.length;r<this.blockSize;r++)t.push(0);for(r=0;r<t.length;r++)t[r]^=54;for(this.inner=new this.Hash().update(t),r=0;r<t.length;r++)t[r]^=106;this.outer=new this.Hash().update(t)};os.prototype.update=function(t,r){return this.inner.update(t,r),this};os.prototype.digest=function(t){return this.outer.update(this.inner.digest()),this.outer.digest(t)}});var aw=P(sw=>{p();var Kt=sw;Kt.utils=Cr();Kt.common=es();Kt.sha=X1();Kt.ripemd=nw();Kt.hmac=ow();Kt.sha1=Kt.sha.sha1;Kt.sha256=Kt.sha.sha256;Kt.sha224=Kt.sha.sha224;Kt.sha384=Kt.sha.sha384;Kt.sha512=Kt.sha.sha512;Kt.ripemd160=Kt.ripemd.ripemd160});var fw=P((rF,uw)=>{"use strict";p();var Gf=aw(),Dn=Ce(),At=uw.exports;At.sha1=function(e){return Dn.checkArgument(d.Buffer.isBuffer(e)),d.Buffer.from(Gf.sha1().update(e).digest("hex"),"hex")};At.sha1.blocksize=512;At.sha256=function(e){return Dn.checkArgument(d.Buffer.isBuffer(e)),d.Buffer.from(Gf.sha256().update(e).digest("hex"),"hex")};At.sha256.blocksize=512;At.sha256sha256=function(e){return Dn.checkArgument(d.Buffer.isBuffer(e)),At.sha256(At.sha256(e))};At.ripemd160=function(e){return Dn.checkArgument(d.Buffer.isBuffer(e)),d.Buffer.from(Gf.ripemd160().update(e).digest("hex"),"hex")};At.sha256ripemd160=function(e){return Dn.checkArgument(d.Buffer.isBuffer(e)),At.ripemd160(At.sha256(e))};At.sha512=function(e){return Dn.checkArgument(d.Buffer.isBuffer(e)),d.Buffer.from(Gf.sha512().update(e).digest("hex"),"hex")};At.sha512.blocksize=1024;At.hmac=function(e,t,r){Dn.checkArgument(d.Buffer.isBuffer(t)),Dn.checkArgument(d.Buffer.isBuffer(r)),Dn.checkArgument(e.blocksize);var n=e.blocksize/8;if(r.length>n)r=e(r);else if(r.length<n){var i=d.Buffer.alloc(n);i.fill(0),r.copy(i),r=i}var o=d.Buffer.alloc(n);o.fill(92);var s=d.Buffer.alloc(n);s.fill(54);for(var a=d.Buffer.alloc(n),c=d.Buffer.alloc(n),l=0;l<n;l++)a[l]=o[l]^r[l],c[l]=s[l]^r[l];return e(d.Buffer.concat([a,e(d.Buffer.concat([c,t]))]))};At.sha256hmac=function(e,t){return At.hmac(At.sha256,e,t)};At.sha512hmac=function(e,t){return At.hmac(At.sha512,e,t)}});var hw=P((iF,cw)=>{"use strict";p();var zf=Xl(),Un=Ce(),Ot=cw.exports;Ot.sha1=function(e){return Un.checkArgument(d.Buffer.isBuffer(e)),zf.createHash("sha1").update(e).digest()};Ot.sha1.blocksize=512;Ot.sha256=function(e){return Un.checkArgument(d.Buffer.isBuffer(e)),zf.createHash("sha256").update(e).digest()};Ot.sha256.blocksize=512;Ot.sha256sha256=function(e){return Un.checkArgument(d.Buffer.isBuffer(e)),Ot.sha256(Ot.sha256(e))};Ot.ripemd160=function(e){return Un.checkArgument(d.Buffer.isBuffer(e)),zf.createHash("ripemd160").update(e).digest()};Ot.sha256ripemd160=function(e){return Un.checkArgument(d.Buffer.isBuffer(e)),Ot.ripemd160(Ot.sha256(e))};Ot.sha512=function(e){return Un.checkArgument(d.Buffer.isBuffer(e)),zf.createHash("sha512").update(e).digest()};Ot.sha512.blocksize=1024;Ot.hmac=function(e,t,r){Un.checkArgument(d.Buffer.isBuffer(t)),Un.checkArgument(d.Buffer.isBuffer(r)),Un.checkArgument(e.blocksize);var n=e.blocksize/8;if(r.length>n)r=e(r);else if(r.length<n){var i=d.Buffer.alloc(n);i.fill(0),r.copy(i),r=i}var o=d.Buffer.alloc(n);o.fill(92);var s=d.Buffer.alloc(n);s.fill(54);for(var a=d.Buffer.alloc(n),c=d.Buffer.alloc(n),l=0;l<n;l++)a[l]=o[l]^r[l],c[l]=s[l]^r[l];return e(d.Buffer.concat([a,e(d.Buffer.concat([c,t]))]))};Ot.sha256hmac=function(e,t){return Ot.hmac(Ot.sha256,e,t)};Ot.sha512hmac=function(e,t){return Ot.hmac(Ot.sha512,e,t)}});var Zt=P((sF,Ld)=>{p();I.default.browser?Ld.exports=fw():Ld.exports=hw()});var lr=P((uF,pw)=>{"use strict";p();var dw=Ge(),VN=Ce(),lw=function(t){return dw.isString(t)?/^[0-9a-fA-F]+$/.test(t):!1};pw.exports={isValidJSON:function(t){var r;if(!dw.isString(t))return!1;try{r=JSON.parse(t)}catch{return!1}return typeof r=="object"},isHexa:lw,isHexaString:lw,defineImmutable:function(t,r){return Object.keys(r).forEach(function(n){Object.defineProperty(t,n,{configurable:!1,enumerable:!0,value:r[n]})}),t},isNaturalNumber:function(t){return typeof t=="number"&&isFinite(t)&&Math.floor(t)===t&&t>=0},integerAsBuffer:function(t){VN.checkArgumentType(t,"number","integer");let r=d.Buffer.allocUnsafe(4);return r.writeUInt32BE(t,0),r}}});var va=P((cF,mw)=>{"use strict";p();var qn=Ge(),pa=lr(),Xi=[],ga={};function gw(){}gw.prototype.toString=function(){return this.name};function ya(e,t){if(~Xi.indexOf(e))return e;if(t){qn.isArray(t)||(t=[t]);for(var r=0;r<Xi.length;r++){var n=Xi[r],i=qn.pick(n,t),o=qn.values(i);if(~o.indexOf(e))return n}return}return ga[e]}function Wf(e){for(var t=[],r=0;r<e.length;r++)t.push(e.charCodeAt(r)&31);return t}function ma(e){var t=new gw;pa.defineImmutable(t,{name:e.name,alias:e.alias,pubkeyhash:e.pubkeyhash,privatekey:e.privatekey,scripthash:e.scripthash,xpubkey:e.xpubkey,xprivkey:e.xprivkey});var r=e.indexBy||Object.keys(e);return e.cashAddrPrefix&&qn.extend(t,{cashAddrPrefix:e.cashAddrPrefix,cashAddrPrefixArray:Wf(e.cashAddrPrefix)}),e.networkMagic&&qn.extend(t,{networkMagic:pa.integerAsBuffer(e.networkMagic)}),e.port&&qn.extend(t,{port:e.port}),e.dnsSeeds&&qn.extend(t,{dnsSeeds:e.dnsSeeds}),Xi.push(t),GN(t,r),t}function GN(e,t){for(var r=0;r<t.length;r++){var n=t[r],i=e[n];!qn.isUndefined(i)&&!qn.isObject(i)&&(ga[i]=e)}}function zN(e,t){for(var r=0;r<t.length;r++){var n=t[r];ga[n]===e&&delete ga[n]}}function WN(e){for(var t=0;t<Xi.length;t++)Xi[t]===e&&Xi.splice(t,1);zN(e,Object.keys(ga))}var Yf={livenet:3823236072,testnet:4108710900,regtest:3669344250,stn:4224632057},yw=["seed.bitcoinsv.org","seed.bitcoinunlimited.info"],ui={PORT:18333,NETWORK_MAGIC:Yf.testnet,DNS_SEEDS:yw,PREFIX:"testnet",CASHADDRPREFIX:"bchtest"},Fn={PORT:18444,NETWORK_MAGIC:Yf.regtest,DNS_SEEDS:[],PREFIX:"regtest",CASHADDRPREFIX:"bchreg"},fi={PORT:9333,NETWORK_MAGIC:Yf.stn,DNS_SEEDS:["stn-seed.bitcoinsv.io"],PREFIX:"stn",CASHADDRPREFIX:"bsvstn"},YN={name:"livenet",alias:"mainnet",prefix:"bitcoin",cashAddrPrefix:"bitcoincash",pubkeyhash:0,privatekey:128,scripthash:5,xpubkey:76067358,xprivkey:76066276,networkMagic:Yf.livenet,port:8333,dnsSeeds:yw},$N={name:"testnet",prefix:ui.PREFIX,cashAddrPrefix:ui.CASHADDRPREFIX,pubkeyhash:111,privatekey:239,scripthash:196,xpubkey:70617039,xprivkey:70615956,networkMagic:ui.NETWORK_MAGIC},ZN={name:"regtest",prefix:Fn.PREFIX,cashAddrPrefix:Fn.CASHADDRPREFIX,pubkeyhash:111,privatekey:239,scripthash:196,xpubkey:70617039,xprivkey:70615956,networkMagic:Fn.NETWORK_MAGIC,port:Fn.PORT,dnsSeeds:[],indexBy:["port","name","cashAddrPrefix","networkMagic"]},XN={name:"stn",prefix:fi.PREFIX,cashAddrPrefix:fi.CASHADDRPREFIX,pubkeyhash:111,privatekey:239,scripthash:196,xpubkey:70617039,xprivkey:70615956,networkMagic:fi.NETWORK_MAGIC,indexBy:["port","name","cashAddrPrefix","networkMagic"]};ma($N);ma(XN);ma(ZN);ma(YN);var Dd=ya("livenet"),JN=ya("regtest"),pn=ya("testnet"),QN=ya("stn");Object.defineProperty(pn,"port",{enumerable:!0,configurable:!1,get:function(){return this.regtestEnabled?Fn.PORT:this.stnEnabled?fi.PORT:ui.PORT}});Object.defineProperty(pn,"networkMagic",{enumerable:!0,configurable:!1,get:function(){return this.regtestEnabled?pa.integerAsBuffer(Fn.NETWORK_MAGIC):this.stnEnabled?pa.integerAsBuffer(fi.NETWORK_MAGIC):pa.integerAsBuffer(ui.NETWORK_MAGIC)}});Object.defineProperty(pn,"dnsSeeds",{enumerable:!0,configurable:!1,get:function(){return this.regtestEnabled?Fn.DNS_SEEDS:this.stnEnabled?fi.DNS_SEEDS:ui.DNS_SEEDS}});Object.defineProperty(pn,"cashAddrPrefix",{enumerable:!0,configurable:!1,get:function(){return this.regtestEnabled?Fn.CASHADDRPREFIX:this.stnEnabled?fi.CASHADDRPREFIX:ui.CASHADDRPREFIX}});Object.defineProperty(pn,"cashAddrPrefixArray",{enumerable:!0,configurable:!1,get:function(){return this.regtestEnabled?Wf(Fn.CASHADDRPREFIX):this.stnEnabled?Wf(fi.CASHADDRPREFIX):Wf(ui.CASHADDRPREFIX)}});function eM(){pn.regtestEnabled=!0}function tM(){pn.regtestEnabled=!1}function rM(){pn.stnEnabled=!0}function nM(){pn.stnEnabled=!1}mw.exports={add:ma,remove:WN,defaultNetwork:Dd,livenet:Dd,mainnet:Dd,testnet:pn,regtest:JN,stn:QN,get:ya,enableRegtest:eM,disableRegtest:tM,enableStn:rM,disableStn:nM}});var bw=P((lF,vw)=>{"use strict";p();var $f=Ct().Buffer;function iM(e){if(e.length>=255)throw new TypeError("Alphabet too long");for(var t=new Uint8Array(256),r=0;r<t.length;r++)t[r]=255;for(var n=0;n<e.length;n++){var i=e.charAt(n),o=i.charCodeAt(0);if(t[o]!==255)throw new TypeError(i+" is ambiguous");t[o]=n}var s=e.length,a=e.charAt(0),c=Math.log(s)/Math.log(256),l=Math.log(256)/Math.log(s);function g(x){if((Array.isArray(x)||x instanceof Uint8Array)&&(x=$f.from(x)),!$f.isBuffer(x))throw new TypeError("Expected Buffer");if(x.length===0)return"";for(var R=0,B=0,C=0,U=x.length;C!==U&&x[C]===0;)C++,R++;for(var V=(U-C)*l+1>>>0,z=new Uint8Array(V);C!==U;){for(var j=x[C],Y=0,oe=V-1;(j!==0||Y<B)&&oe!==-1;oe--,Y++)j+=256*z[oe]>>>0,z[oe]=j%s>>>0,j=j/s>>>0;if(j!==0)throw new Error("Non-zero carry");B=Y,C++}for(var Q=V-B;Q!==V&&z[Q]===0;)Q++;for(var se=a.repeat(R);Q<V;++Q)se+=e.charAt(z[Q]);return se}function m(x){if(typeof x!="string")throw new TypeError("Expected String");if(x.length===0)return $f.alloc(0);for(var R=0,B=0,C=0;x[R]===a;)B++,R++;for(var U=(x.length-R)*c+1>>>0,V=new Uint8Array(U);R<x.length;){var z=x.charCodeAt(R);if(z>255)return;var j=t[z];if(j===255)return;for(var Y=0,oe=U-1;(j!==0||Y<C)&&oe!==-1;oe--,Y++)j+=s*V[oe]>>>0,V[oe]=j%256>>>0,j=j/256>>>0;if(j!==0)throw new Error("Non-zero carry");C=Y,R++}for(var Q=U-C;Q!==U&&V[Q]===0;)Q++;var se=$f.allocUnsafe(B+(U-Q));se.fill(0,0,B);for(var ye=B;Q!==U;)se[ye++]=V[Q++];return se}function _(x){var R=m(x);if(R)return R;throw new Error("Non-base"+s+" character")}return{encode:g,decodeUnsafe:m,decode:_}}vw.exports=iM});var ww=P((pF,_w)=>{p();var oM=bw(),sM="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";_w.exports=oM(sM)});var Iw=P((yF,xw)=>{"use strict";p();var Ud=Ge(),Sw=ww(),Ew=Pt(),aM="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz".split(""),qt=function e(t){if(!(this instanceof e))return new e(t);if(d.Buffer.isBuffer(t)){var r=t;this.fromBuffer(r)}else if(typeof t=="string"){var n=t;this.fromString(n)}};qt.validCharacters=function(t){return Ew.Buffer.isBuffer(t)&&(t=t.toString()),Ud.every(Ud.map(t,function(r){return Ud.includes(aM,r)}))};qt.prototype.set=function(e){return this.buf=e.buf||this.buf||void 0,this};qt.encode=function(e){if(!Ew.Buffer.isBuffer(e))throw new Error("Input should be a buffer");return Sw.encode(e)};qt.decode=function(e){if(typeof e!="string")throw new Error("Input should be a string");return d.Buffer.from(Sw.decode(e))};qt.prototype.fromBuffer=function(e){return this.buf=e,this};qt.fromBuffer=function(e){return new qt().fromBuffer(e)};qt.fromHex=function(e){return qt.fromBuffer(d.Buffer.from(e,"hex"))};qt.prototype.fromString=function(e){var t=qt.decode(e);return this.buf=t,this};qt.fromString=function(e){return new qt().fromString(e)};qt.prototype.toBuffer=function(){return this.buf};qt.prototype.toHex=function(){return this.toBuffer().toString("hex")};qt.prototype.toString=function(){return qt.encode(this.buf)};xw.exports=qt});var qd=P((vF,Tw)=>{"use strict";p();var Aw=Ge(),Zf=Iw(),Ow=Pt(),Rw=Zt().sha256sha256,Qe=function e(t){if(!(this instanceof e))return new e(t);if(d.Buffer.isBuffer(t)){var r=t;this.fromBuffer(r)}else if(typeof t=="string"){var n=t;this.fromString(n)}};Qe.prototype.set=function(e){return this.buf=e.buf||this.buf||void 0,this};Qe.validChecksum=function(t,r){return Aw.isString(t)&&(t=Ow.Buffer.from(Zf.decode(t))),Aw.isString(r)&&(r=Ow.Buffer.from(Zf.decode(r))),r||(r=t.slice(-4),t=t.slice(0,-4)),Qe.checksum(t).toString("hex")===r.toString("hex")};Qe.decode=function(e){if(typeof e!="string")throw new Error("Input must be a string");var t=d.Buffer.from(Zf.decode(e));if(t.length<4)throw new Error("Input string too short");var r=t.slice(0,-4),n=t.slice(-4),i=Rw(r),o=i.slice(0,4);if(n.toString("hex")!==o.toString("hex"))throw new Error("Checksum mismatch");return r};Qe.checksum=function(e){return Rw(e).slice(0,4)};Qe.encode=function(e){if(!d.Buffer.isBuffer(e))throw new Error("Input must be a buffer");var t=d.Buffer.alloc(e.length+4),r=Qe.checksum(e);return e.copy(t),r.copy(t,e.length),Zf.encode(t)};Qe.prototype.fromBuffer=function(e){return this.buf=e,this};Qe.fromBuffer=function(e){return new Qe().fromBuffer(e)};Qe.fromHex=function(e){return Qe.fromBuffer(d.Buffer.from(e,"hex"))};Qe.prototype.fromString=function(e){var t=Qe.decode(e);return this.buf=t,this};Qe.fromString=function(e){var t=Qe.decode(e);return new Qe(t)};Qe.prototype.toBuffer=function(){return this.buf};Qe.prototype.toHex=function(){return this.toBuffer().toString("hex")};Qe.prototype.toString=function(){return Qe.encode(this.buf)};Tw.exports=Qe});var _a=P((_F,Bw)=>{"use strict";p();var ba=Ge(),Pw=Ce(),ss=wr(),tt=function e(t){if(!(this instanceof e))return new e(t);if(!ba.isUndefined(t))if(d.Buffer.isBuffer(t))this.set({buf:t});else if(ba.isString(t)){var r=d.Buffer.from(t,"hex");if(r.length*2!==t.length)throw new TypeError("Invalid hex string");this.set({buf:r})}else if(ba.isObject(t)){var n=t;this.set(n)}else throw new TypeError("Unrecognized argument for BufferReader")};tt.prototype.set=function(e){return this.buf=e.buf||this.buf||void 0,this.pos=e.pos||this.pos||0,this};tt.prototype.eof=function(){return this.pos>=this.buf.length};tt.prototype.finished=tt.prototype.eof;tt.prototype.read=function(e){Pw.checkArgument(!ba.isUndefined(e),"Must specify a length");var t=this.buf.slice(this.pos,this.pos+e);return this.pos=this.pos+e,t};tt.prototype.readAll=function(){var e=this.buf.slice(this.pos,this.buf.length);return this.pos=this.buf.length,e};tt.prototype.readUInt8=function(){var e=this.buf.readUInt8(this.pos);return this.pos=this.pos+1,e};tt.prototype.readUInt16BE=function(){var e=this.buf.readUInt16BE(this.pos);return this.pos=this.pos+2,e};tt.prototype.readUInt16LE=function(){var e=this.buf.readUInt16LE(this.pos);return this.pos=this.pos+2,e};tt.prototype.readUInt32BE=function(){var e=this.buf.readUInt32BE(this.pos);return this.pos=this.pos+4,e};tt.prototype.readUInt32LE=function(){var e=this.buf.readUInt32LE(this.pos);return this.pos=this.pos+4,e};tt.prototype.readInt32LE=function(){var e=this.buf.readInt32LE(this.pos);return this.pos=this.pos+4,e};tt.prototype.readUInt64BEBN=function(){var e=this.buf.slice(this.pos,this.pos+8),t=ss.fromBuffer(e);return this.pos=this.pos+8,t};tt.prototype.readUInt64LEBN=function(){var e=this.buf.readUInt32LE(this.pos),t=this.buf.readUInt32LE(this.pos+4),r=t*4294967296+e,n;if(r<=9007199254740991)n=new ss(r);else{var i=Array.prototype.slice.call(this.buf,this.pos,this.pos+8);n=new ss(i,10,"le")}return this.pos=this.pos+8,n};tt.prototype.readVarintNum=function(){var e=this.readUInt8();switch(e){case 253:return this.readUInt16LE();case 254:return this.readUInt32LE();case 255:var t=this.readUInt64LEBN(),r=t.toNumber();if(r<=Math.pow(2,53))return r;throw new Error("number too large to retain precision - use readVarintBN");default:return e}};tt.prototype.readVarLengthBuffer=function(){var e=this.readVarintNum(),t=this.read(e);return Pw.checkState(t.length===e,"Invalid length while reading varlength buffer. Expected to read: "+e+" and read "+t.length),t};tt.prototype.readVarintBuf=function(){var e=this.buf.readUInt8(this.pos);switch(e){case 253:return this.read(3);case 254:return this.read(5);case 255:return this.read(9);default:return this.read(1)}};tt.prototype.readVarintBN=function(){var e=this.readUInt8();switch(e){case 253:return new ss(this.readUInt16LE());case 254:return new ss(this.readUInt32LE());case 255:return this.readUInt64LEBN();default:return new ss(e)}};tt.prototype.reverse=function(){for(var e=d.Buffer.alloc(this.buf.length),t=0;t<e.length;t++)e[t]=this.buf[this.buf.length-1-t];return this.buf=e,this};tt.prototype.readReverse=function(e){ba.isUndefined(e)&&(e=this.buf.length);var t=this.buf.slice(this.pos,this.pos+e);return this.pos=this.pos+e,d.Buffer.from(t).reverse()};Bw.exports=tt});var jd=P((SF,Cw)=>{"use strict";p();function ci(e){"@babel/helpers - typeof";return ci=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},ci(e)}function Nw(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,fM(n.key),n)}}function uM(e,t,r){return t&&Nw(e.prototype,t),r&&Nw(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e}function fM(e){var t=cM(e,"string");return ci(t)==="symbol"?t:String(t)}function cM(e,t){if(ci(e)!=="object"||e===null)return e;var r=e[Symbol.toPrimitive];if(r!==void 0){var n=r.call(e,t||"default");if(ci(n)!=="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}function hM(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function lM(e,t){if(typeof t!="function"&&t!==null)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&Hd(e,t)}function Hd(e,t){return Hd=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(n,i){return n.__proto__=i,n},Hd(e,t)}function dM(e){var t=yM();return function(){var n=Xf(e),i;if(t){var o=Xf(this).constructor;i=Reflect.construct(n,arguments,o)}else i=n.apply(this,arguments);return pM(this,i)}}function pM(e,t){if(t&&(ci(t)==="object"||typeof t=="function"))return t;if(t!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return gM(e)}function gM(e){if(e===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function yM(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}function Xf(e){return Xf=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(r){return r.__proto__||Object.getPrototypeOf(r)},Xf(e)}var kw={},as,Fd;function wa(e,t,r){r||(r=Error);function n(o,s,a){return typeof t=="string"?t:t(o,s,a)}var i=(function(o){lM(a,o);var s=dM(a);function a(c,l,g){var m;return hM(this,a),m=s.call(this,n(c,l,g)),m.code=e,m}return uM(a)})(r);kw[e]=i}function Mw(e,t){if(Array.isArray(e)){var r=e.length;return e=e.map(function(n){return String(n)}),r>2?"one of ".concat(t," ").concat(e.slice(0,r-1).join(", "),", or ")+e[r-1]:r===2?"one of ".concat(t," ").concat(e[0]," or ").concat(e[1]):"of ".concat(t," ").concat(e[0])}else return"of ".concat(t," ").concat(String(e))}function mM(e,t,r){return e.substr(!r||r<0?0:+r,t.length)===t}function vM(e,t,r){return(r===void 0||r>e.length)&&(r=e.length),e.substring(r-t.length,r)===t}function bM(e,t,r){return typeof r!="number"&&(r=0),r+t.length>e.length?!1:e.indexOf(t,r)!==-1}wa("ERR_AMBIGUOUS_ARGUMENT",'The "%s" argument is ambiguous. %s',TypeError);wa("ERR_INVALID_ARG_TYPE",function(e,t,r){as===void 0&&(as=Jf()),as(typeof e=="string","'name' must be a string");var n;typeof t=="string"&&mM(t,"not ")?(n="must not be",t=t.replace(/^not /,"")):n="must be";var i;if(vM(e," argument"))i="The ".concat(e," ").concat(n," ").concat(Mw(t,"type"));else{var o=bM(e,".")?"property":"argument";i='The "'.concat(e,'" ').concat(o," ").concat(n," ").concat(Mw(t,"type"))}return i+=". Received type ".concat(ci(r)),i},TypeError);wa("ERR_INVALID_ARG_VALUE",function(e,t){var r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:"is invalid";Fd===void 0&&(Fd=en());var n=Fd.inspect(t);return n.length>128&&(n="".concat(n.slice(0,128),"...")),"The argument '".concat(e,"' ").concat(r,". Received ").concat(n)},TypeError,RangeError);wa("ERR_INVALID_RETURN_VALUE",function(e,t,r){var n;return r&&r.constructor&&r.constructor.name?n="instance of ".concat(r.constructor.name):n="type ".concat(ci(r)),"Expected ".concat(e,' to be returned from the "').concat(t,'"')+" function but got ".concat(n,".")},TypeError);wa("ERR_MISSING_ARGS",function(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];as===void 0&&(as=Jf()),as(t.length>0,"At least one arg needs to be specified");var n="The ",i=t.length;switch(t=t.map(function(o){return'"'.concat(o,'"')}),i){case 1:n+="".concat(t[0]," argument");break;case 2:n+="".concat(t[0]," and ").concat(t[1]," arguments");break;default:n+=t.slice(0,i-1).join(", "),n+=", and ".concat(t[i-1]," arguments");break}return"".concat(n," must be specified")},TypeError);Cw.exports.codes=kw});var Gw=P((xF,Vw)=>{"use strict";p();function Lw(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(i){return Object.getOwnPropertyDescriptor(e,i).enumerable})),r.push.apply(r,n)}return r}function Dw(e){for(var t=1;t<arguments.length;t++){var r=arguments[t]!=null?arguments[t]:{};t%2?Lw(Object(r),!0).forEach(function(n){_M(e,n,r[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):Lw(Object(r)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(r,n))})}return e}function _M(e,t,r){return t=Hw(t),t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function wM(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function Uw(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,Hw(n.key),n)}}function SM(e,t,r){return t&&Uw(e.prototype,t),r&&Uw(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e}function Hw(e){var t=EM(e,"string");return or(t)==="symbol"?t:String(t)}function EM(e,t){if(or(e)!=="object"||e===null)return e;var r=e[Symbol.toPrimitive];if(r!==void 0){var n=r.call(e,t||"default");if(or(n)!=="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}function xM(e,t){if(typeof t!="function"&&t!==null)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&Ia(e,t)}function IM(e){var t=Kw();return function(){var n=Aa(e),i;if(t){var o=Aa(this).constructor;i=Reflect.construct(n,arguments,o)}else i=n.apply(this,arguments);return jw(this,i)}}function jw(e,t){if(t&&(or(t)==="object"||typeof t=="function"))return t;if(t!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return Kd(e)}function Kd(e){if(e===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function Vd(e){var t=typeof Map=="function"?new Map:void 0;return Vd=function(n){if(n===null||!AM(n))return n;if(typeof n!="function")throw new TypeError("Super expression must either be null or a function");if(typeof t<"u"){if(t.has(n))return t.get(n);t.set(n,i)}function i(){return Qf(n,arguments,Aa(this).constructor)}return i.prototype=Object.create(n.prototype,{constructor:{value:i,enumerable:!1,writable:!0,configurable:!0}}),Ia(i,n)},Vd(e)}function Qf(e,t,r){return Kw()?Qf=Reflect.construct.bind():Qf=function(i,o,s){var a=[null];a.push.apply(a,o);var c=Function.bind.apply(i,a),l=new c;return s&&Ia(l,s.prototype),l},Qf.apply(null,arguments)}function Kw(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}function AM(e){return Function.toString.call(e).indexOf("[native code]")!==-1}function Ia(e,t){return Ia=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(n,i){return n.__proto__=i,n},Ia(e,t)}function Aa(e){return Aa=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(r){return r.__proto__||Object.getPrototypeOf(r)},Aa(e)}function or(e){"@babel/helpers - typeof";return or=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},or(e)}var OM=en(),Gd=OM.inspect,RM=jd(),TM=RM.codes.ERR_INVALID_ARG_TYPE;function qw(e,t,r){return(r===void 0||r>e.length)&&(r=e.length),e.substring(r-t.length,r)===t}function PM(e,t){if(t=Math.floor(t),e.length==0||t==0)return"";var r=e.length*t;for(t=Math.floor(Math.log(t)/Math.log(2));t;)e+=e,t--;return e+=e.substring(0,r-e.length),e}var Ur="",Sa="",Ea="",Vt="",Ji={deepStrictEqual:"Expected values to be strictly deep-equal:",strictEqual:"Expected values to be strictly equal:",strictEqualObject:'Expected "actual" to be reference-equal to "expected":',deepEqual:"Expected values to be loosely deep-equal:",equal:"Expected values to be loosely equal:",notDeepStrictEqual:'Expected "actual" not to be strictly deep-equal to:',notStrictEqual:'Expected "actual" to be strictly unequal to:',notStrictEqualObject:'Expected "actual" not to be reference-equal to "expected":',notDeepEqual:'Expected "actual" not to be loosely deep-equal to:',notEqual:'Expected "actual" to be loosely unequal to:',notIdentical:"Values identical but not reference-equal:"},BM=10;function Fw(e){var t=Object.keys(e),r=Object.create(Object.getPrototypeOf(e));return t.forEach(function(n){r[n]=e[n]}),Object.defineProperty(r,"message",{value:e.message}),r}function xa(e){return Gd(e,{compact:!1,customInspect:!1,depth:1e3,maxArrayLength:1/0,showHidden:!1,breakLength:1/0,showProxy:!1,sorted:!0,getters:!0})}function NM(e,t,r){var n="",i="",o=0,s="",a=!1,c=xa(e),l=c.split(`
|
|
14
|
-
`),g=
|
|
15
|
-
`),m=0,_="";if(r==="strictEqual"&&
|
|
10
|
+
`)+" "+r[1]:r[0]+t+" "+e.join(", ")+" "+r[1]}xe.types=fm();function pm(e){return Array.isArray(e)}xe.isArray=pm;function rh(e){return typeof e=="boolean"}xe.isBoolean=rh;function Mu(e){return e===null}xe.isNull=Mu;function eR(e){return e==null}xe.isNullOrUndefined=eR;function gm(e){return typeof e=="number"}xe.isNumber=gm;function ku(e){return typeof e=="string"}xe.isString=ku;function tR(e){return typeof e=="symbol"}xe.isSymbol=tR;function Ii(e){return e===void 0}xe.isUndefined=Ii;function Is(e){return Io(e)&&nh(e)==="[object RegExp]"}xe.isRegExp=Is;xe.types.isRegExp=Is;function Io(e){return typeof e=="object"&&e!==null}xe.isObject=Io;function Nu(e){return Io(e)&&nh(e)==="[object Date]"}xe.isDate=Nu;xe.types.isDate=Nu;function As(e){return Io(e)&&(nh(e)==="[object Error]"||e instanceof Error)}xe.isError=As;xe.types.isNativeError=As;function Pu(e){return typeof e=="function"}xe.isFunction=Pu;function rR(e){return e===null||typeof e=="boolean"||typeof e=="number"||typeof e=="string"||typeof e=="symbol"||typeof e>"u"}xe.isPrimitive=rR;xe.isBuffer=lm();function nh(e){return Object.prototype.toString.call(e)}function eh(e){return e<10?"0"+e.toString(10):e.toString(10)}var nR=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function iR(){var e=new Date,t=[eh(e.getHours()),eh(e.getMinutes()),eh(e.getSeconds())].join(":");return[e.getDate(),nR[e.getMonth()],t].join(" ")}xe.log=function(){console.log("%s - %s",iR(),xe.format.apply(xe,arguments))};xe.inherits=De();xe._extend=function(e,t){if(!t||!Io(t))return e;for(var r=Object.keys(t),n=r.length;n--;)e[r[n]]=t[r[n]];return e};function ym(e,t){return Object.prototype.hasOwnProperty.call(e,t)}var xi=typeof Symbol<"u"?Symbol("util.promisify.custom"):void 0;xe.promisify=function(t){if(typeof t!="function")throw new TypeError('The "original" argument must be of type Function');if(xi&&t[xi]){var r=t[xi];if(typeof r!="function")throw new TypeError('The "util.promisify.custom" argument must be of type Function');return Object.defineProperty(r,xi,{value:r,enumerable:!1,writable:!1,configurable:!0}),r}function r(){for(var n,i,o=new Promise(function(c,h){n=c,i=h}),s=[],a=0;a<arguments.length;a++)s.push(arguments[a]);s.push(function(c,h){c?i(c):n(h)});try{t.apply(this,s)}catch(c){i(c)}return o}return Object.setPrototypeOf(r,Object.getPrototypeOf(t)),xi&&Object.defineProperty(r,xi,{value:r,enumerable:!1,writable:!1,configurable:!0}),Object.defineProperties(r,hm(t))};xe.promisify.custom=xi;function oR(e,t){if(!e){var r=new Error("Promise was rejected with a falsy value");r.reason=e,e=r}return t(e)}function sR(e){if(typeof e!="function")throw new TypeError('The "original" argument must be of type Function');function t(){for(var r=[],n=0;n<arguments.length;n++)r.push(arguments[n]);var i=r.pop();if(typeof i!="function")throw new TypeError("The last argument must be of type Function");var o=this,s=function(){return i.apply(o,arguments)};e.apply(this,r).then(function(a){x.default.nextTick(s.bind(null,null,a))},function(a){x.default.nextTick(oR.bind(null,a,s))})}return Object.setPrototypeOf(t,Object.getPrototypeOf(e)),Object.defineProperties(t,hm(e)),t}xe.callbackify=sR});var Sm=P((uC,wm)=>{"use strict";y();function mm(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(i){return Object.getOwnPropertyDescriptor(e,i).enumerable})),r.push.apply(r,n)}return r}function vm(e){for(var t=1;t<arguments.length;t++){var r=arguments[t]!=null?arguments[t]:{};t%2?mm(Object(r),!0).forEach(function(n){aR(e,n,r[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):mm(Object(r)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(r,n))})}return e}function aR(e,t,r){return t=_m(t),t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function uR(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function bm(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,_m(n.key),n)}}function fR(e,t,r){return t&&bm(e.prototype,t),r&&bm(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e}function _m(e){var t=cR(e,"string");return typeof t=="symbol"?t:String(t)}function cR(e,t){if(typeof e!="object"||e===null)return e;var r=e[Symbol.toPrimitive];if(r!==void 0){var n=r.call(e,t||"default");if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}var lR=Tt(),Cu=lR.Buffer,hR=en(),ih=hR.inspect,dR=ih&&ih.custom||"inspect";function pR(e,t,r){Cu.prototype.copy.call(e,t,r)}wm.exports=(function(){function e(){uR(this,e),this.head=null,this.tail=null,this.length=0}return fR(e,[{key:"push",value:function(r){var n={data:r,next:null};this.length>0?this.tail.next=n:this.head=n,this.tail=n,++this.length}},{key:"unshift",value:function(r){var n={data:r,next:this.head};this.length===0&&(this.tail=n),this.head=n,++this.length}},{key:"shift",value:function(){if(this.length!==0){var r=this.head.data;return this.length===1?this.head=this.tail=null:this.head=this.head.next,--this.length,r}}},{key:"clear",value:function(){this.head=this.tail=null,this.length=0}},{key:"join",value:function(r){if(this.length===0)return"";for(var n=this.head,i=""+n.data;n=n.next;)i+=r+n.data;return i}},{key:"concat",value:function(r){if(this.length===0)return Cu.alloc(0);for(var n=Cu.allocUnsafe(r>>>0),i=this.head,o=0;i;)pR(i.data,n,o),o+=i.data.length,i=i.next;return n}},{key:"consume",value:function(r,n){var i;return r<this.head.data.length?(i=this.head.data.slice(0,r),this.head.data=this.head.data.slice(r)):r===this.head.data.length?i=this.shift():i=n?this._getString(r):this._getBuffer(r),i}},{key:"first",value:function(){return this.head.data}},{key:"_getString",value:function(r){var n=this.head,i=1,o=n.data;for(r-=o.length;n=n.next;){var s=n.data,a=r>s.length?s.length:r;if(a===s.length?o+=s:o+=s.slice(0,r),r-=a,r===0){a===s.length?(++i,n.next?this.head=n.next:this.head=this.tail=null):(this.head=n,n.data=s.slice(a));break}++i}return this.length-=i,o}},{key:"_getBuffer",value:function(r){var n=Cu.allocUnsafe(r),i=this.head,o=1;for(i.data.copy(n),r-=i.data.length;i=i.next;){var s=i.data,a=r>s.length?s.length:r;if(s.copy(n,n.length-r,0,a),r-=a,r===0){a===s.length?(++o,i.next?this.head=i.next:this.head=this.tail=null):(this.head=i,i.data=s.slice(a));break}++o}return this.length-=o,n}},{key:dR,value:function(r,n){return ih(this,vm(vm({},n),{},{depth:0,customInspect:!1}))}}]),e})()});var sh=P((cC,xm)=>{"use strict";y();function gR(e,t){var r=this,n=this._readableState&&this._readableState.destroyed,i=this._writableState&&this._writableState.destroyed;return n||i?(t?t(e):e&&(this._writableState?this._writableState.errorEmitted||(this._writableState.errorEmitted=!0,x.default.nextTick(oh,this,e)):x.default.nextTick(oh,this,e)),this):(this._readableState&&(this._readableState.destroyed=!0),this._writableState&&(this._writableState.destroyed=!0),this._destroy(e||null,function(o){!t&&o?r._writableState?r._writableState.errorEmitted?x.default.nextTick(Lu,r):(r._writableState.errorEmitted=!0,x.default.nextTick(Em,r,o)):x.default.nextTick(Em,r,o):t?(x.default.nextTick(Lu,r),t(o)):x.default.nextTick(Lu,r)}),this)}function Em(e,t){oh(e,t),Lu(e)}function Lu(e){e._writableState&&!e._writableState.emitClose||e._readableState&&!e._readableState.emitClose||e.emit("close")}function yR(){this._readableState&&(this._readableState.destroyed=!1,this._readableState.reading=!1,this._readableState.ended=!1,this._readableState.endEmitted=!1),this._writableState&&(this._writableState.destroyed=!1,this._writableState.ended=!1,this._writableState.ending=!1,this._writableState.finalCalled=!1,this._writableState.prefinished=!1,this._writableState.finished=!1,this._writableState.errorEmitted=!1)}function oh(e,t){e.emit("error",t)}function mR(e,t){var r=e._readableState,n=e._writableState;r&&r.autoDestroy||n&&n.autoDestroy?e.destroy(t):e.emit("error",t)}xm.exports={destroy:gR,undestroy:yR,errorOrDestroy:mR}});var Ai=P((hC,Om)=>{"use strict";y();function vR(e,t){e.prototype=Object.create(t.prototype),e.prototype.constructor=e,e.__proto__=t}var Am={};function wr(e,t,r){r||(r=Error);function n(o,s,a){return typeof t=="string"?t:t(o,s,a)}var i=(function(o){vR(s,o);function s(a,c,h){return o.call(this,n(a,c,h))||this}return s})(r);i.prototype.name=r.name,i.prototype.code=e,Am[e]=i}function Im(e,t){if(Array.isArray(e)){var r=e.length;return e=e.map(function(n){return String(n)}),r>2?"one of ".concat(t," ").concat(e.slice(0,r-1).join(", "),", or ")+e[r-1]:r===2?"one of ".concat(t," ").concat(e[0]," or ").concat(e[1]):"of ".concat(t," ").concat(e[0])}else return"of ".concat(t," ").concat(String(e))}function bR(e,t,r){return e.substr(!r||r<0?0:+r,t.length)===t}function _R(e,t,r){return(r===void 0||r>e.length)&&(r=e.length),e.substring(r-t.length,r)===t}function wR(e,t,r){return typeof r!="number"&&(r=0),r+t.length>e.length?!1:e.indexOf(t,r)!==-1}wr("ERR_INVALID_OPT_VALUE",function(e,t){return'The value "'+t+'" is invalid for option "'+e+'"'},TypeError);wr("ERR_INVALID_ARG_TYPE",function(e,t,r){var n;typeof t=="string"&&bR(t,"not ")?(n="must not be",t=t.replace(/^not /,"")):n="must be";var i;if(_R(e," argument"))i="The ".concat(e," ").concat(n," ").concat(Im(t,"type"));else{var o=wR(e,".")?"property":"argument";i='The "'.concat(e,'" ').concat(o," ").concat(n," ").concat(Im(t,"type"))}return i+=". Received type ".concat(typeof r),i},TypeError);wr("ERR_STREAM_PUSH_AFTER_EOF","stream.push() after EOF");wr("ERR_METHOD_NOT_IMPLEMENTED",function(e){return"The "+e+" method is not implemented"});wr("ERR_STREAM_PREMATURE_CLOSE","Premature close");wr("ERR_STREAM_DESTROYED",function(e){return"Cannot call "+e+" after a stream was destroyed"});wr("ERR_MULTIPLE_CALLBACK","Callback called multiple times");wr("ERR_STREAM_CANNOT_PIPE","Cannot pipe, not readable");wr("ERR_STREAM_WRITE_AFTER_END","write after end");wr("ERR_STREAM_NULL_VALUES","May not write null values to stream",TypeError);wr("ERR_UNKNOWN_ENCODING",function(e){return"Unknown encoding: "+e},TypeError);wr("ERR_STREAM_UNSHIFT_AFTER_END_EVENT","stream.unshift() after end event");Om.exports.codes=Am});var ah=P((pC,Rm)=>{"use strict";y();var SR=Ai().codes.ERR_INVALID_OPT_VALUE;function ER(e,t,r){return e.highWaterMark!=null?e.highWaterMark:t?e[r]:null}function xR(e,t,r,n){var i=ER(t,n,r);if(i!=null){if(!(isFinite(i)&&Math.floor(i)===i)||i<0){var o=n?r:"highWaterMark";throw new SR(o,i)}return Math.floor(i)}return e.objectMode?16:16*1024}Rm.exports={getHighWaterMark:xR}});var fh=P((yC,Tm)=>{y();Tm.exports=IR;function IR(e,t){if(uh("noDeprecation"))return e;var r=!1;function n(){if(!r){if(uh("throwDeprecation"))throw new Error(t);uh("traceDeprecation")?console.trace(t):console.warn(t),r=!0}return e.apply(this,arguments)}return n}function uh(e){try{if(!globalThis.localStorage)return!1}catch{return!1}var t=globalThis.localStorage[e];return t==null?!1:String(t).toLowerCase()==="true"}});var hh=P((vC,Cm)=>{"use strict";y();Cm.exports=Xe;function Bm(e){var t=this;this.next=null,this.entry=null,this.finish=function(){JR(t,e)}}var Ao;Xe.WritableState=Rs;var AR={deprecate:fh()},Nm=Il(),Uu=Tt().Buffer,OR=(typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof self<"u"?self:{}).Uint8Array||function(){};function RR(e){return Uu.from(e)}function TR(e){return Uu.isBuffer(e)||e instanceof OR}var lh=sh(),PR=ah(),BR=PR.getHighWaterMark,Wn=Ai().codes,NR=Wn.ERR_INVALID_ARG_TYPE,MR=Wn.ERR_METHOD_NOT_IMPLEMENTED,kR=Wn.ERR_MULTIPLE_CALLBACK,CR=Wn.ERR_STREAM_CANNOT_PIPE,LR=Wn.ERR_STREAM_DESTROYED,DR=Wn.ERR_STREAM_NULL_VALUES,UR=Wn.ERR_STREAM_WRITE_AFTER_END,FR=Wn.ERR_UNKNOWN_ENCODING,Oo=lh.errorOrDestroy;De()(Xe,Nm);function qR(){}function Rs(e,t,r){Ao=Ao||Oi(),e=e||{},typeof r!="boolean"&&(r=t instanceof Ao),this.objectMode=!!e.objectMode,r&&(this.objectMode=this.objectMode||!!e.writableObjectMode),this.highWaterMark=BR(this,e,"writableHighWaterMark",r),this.finalCalled=!1,this.needDrain=!1,this.ending=!1,this.ended=!1,this.finished=!1,this.destroyed=!1;var n=e.decodeStrings===!1;this.decodeStrings=!n,this.defaultEncoding=e.defaultEncoding||"utf8",this.length=0,this.writing=!1,this.corked=0,this.sync=!0,this.bufferProcessing=!1,this.onwrite=function(i){zR(t,i)},this.writecb=null,this.writelen=0,this.bufferedRequest=null,this.lastBufferedRequest=null,this.pendingcb=0,this.prefinished=!1,this.errorEmitted=!1,this.emitClose=e.emitClose!==!1,this.autoDestroy=!!e.autoDestroy,this.bufferedRequestCount=0,this.corkedRequestsFree=new Bm(this)}Rs.prototype.getBuffer=function(){for(var t=this.bufferedRequest,r=[];t;)r.push(t),t=t.next;return r};(function(){try{Object.defineProperty(Rs.prototype,"buffer",{get:AR.deprecate(function(){return this.getBuffer()},"_writableState.buffer is deprecated. Use _writableState.getBuffer instead.","DEP0003")})}catch{}})();var Du;typeof Symbol=="function"&&Symbol.hasInstance&&typeof Function.prototype[Symbol.hasInstance]=="function"?(Du=Function.prototype[Symbol.hasInstance],Object.defineProperty(Xe,Symbol.hasInstance,{value:function(t){return Du.call(this,t)?!0:this!==Xe?!1:t&&t._writableState instanceof Rs}})):Du=function(t){return t instanceof this};function Xe(e){Ao=Ao||Oi();var t=this instanceof Ao;if(!t&&!Du.call(Xe,this))return new Xe(e);this._writableState=new Rs(e,this,t),this.writable=!0,e&&(typeof e.write=="function"&&(this._write=e.write),typeof e.writev=="function"&&(this._writev=e.writev),typeof e.destroy=="function"&&(this._destroy=e.destroy),typeof e.final=="function"&&(this._final=e.final)),Nm.call(this)}Xe.prototype.pipe=function(){Oo(this,new CR)};function HR(e,t){var r=new UR;Oo(e,r),x.default.nextTick(t,r)}function jR(e,t,r,n){var i;return r===null?i=new DR:typeof r!="string"&&!t.objectMode&&(i=new NR("chunk",["string","Buffer"],r)),i?(Oo(e,i),x.default.nextTick(n,i),!1):!0}Xe.prototype.write=function(e,t,r){var n=this._writableState,i=!1,o=!n.objectMode&&TR(e);return o&&!Uu.isBuffer(e)&&(e=RR(e)),typeof t=="function"&&(r=t,t=null),o?t="buffer":t||(t=n.defaultEncoding),typeof r!="function"&&(r=qR),n.ending?HR(this,r):(o||jR(this,n,e,r))&&(n.pendingcb++,i=VR(this,n,o,e,t,r)),i};Xe.prototype.cork=function(){this._writableState.corked++};Xe.prototype.uncork=function(){var e=this._writableState;e.corked&&(e.corked--,!e.writing&&!e.corked&&!e.bufferProcessing&&e.bufferedRequest&&Mm(this,e))};Xe.prototype.setDefaultEncoding=function(t){if(typeof t=="string"&&(t=t.toLowerCase()),!(["hex","utf8","utf-8","ascii","binary","base64","ucs2","ucs-2","utf16le","utf-16le","raw"].indexOf((t+"").toLowerCase())>-1))throw new FR(t);return this._writableState.defaultEncoding=t,this};Object.defineProperty(Xe.prototype,"writableBuffer",{enumerable:!1,get:function(){return this._writableState&&this._writableState.getBuffer()}});function KR(e,t,r){return!e.objectMode&&e.decodeStrings!==!1&&typeof t=="string"&&(t=Uu.from(t,r)),t}Object.defineProperty(Xe.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}});function VR(e,t,r,n,i,o){if(!r){var s=KR(t,n,i);n!==s&&(r=!0,i="buffer",n=s)}var a=t.objectMode?1:n.length;t.length+=a;var c=t.length<t.highWaterMark;if(c||(t.needDrain=!0),t.writing||t.corked){var h=t.lastBufferedRequest;t.lastBufferedRequest={chunk:n,encoding:i,isBuf:r,callback:o,next:null},h?h.next=t.lastBufferedRequest:t.bufferedRequest=t.lastBufferedRequest,t.bufferedRequestCount+=1}else ch(e,t,!1,a,n,i,o);return c}function ch(e,t,r,n,i,o,s){t.writelen=n,t.writecb=s,t.writing=!0,t.sync=!0,t.destroyed?t.onwrite(new LR("write")):r?e._writev(i,t.onwrite):e._write(i,o,t.onwrite),t.sync=!1}function GR(e,t,r,n,i){--t.pendingcb,r?(x.default.nextTick(i,n),x.default.nextTick(Os,e,t),e._writableState.errorEmitted=!0,Oo(e,n)):(i(n),e._writableState.errorEmitted=!0,Oo(e,n),Os(e,t))}function WR(e){e.writing=!1,e.writecb=null,e.length-=e.writelen,e.writelen=0}function zR(e,t){var r=e._writableState,n=r.sync,i=r.writecb;if(typeof i!="function")throw new kR;if(WR(r),t)GR(e,r,n,t,i);else{var o=km(r)||e.destroyed;!o&&!r.corked&&!r.bufferProcessing&&r.bufferedRequest&&Mm(e,r),n?x.default.nextTick(Pm,e,r,o,i):Pm(e,r,o,i)}}function Pm(e,t,r,n){r||YR(e,t),t.pendingcb--,n(),Os(e,t)}function YR(e,t){t.length===0&&t.needDrain&&(t.needDrain=!1,e.emit("drain"))}function Mm(e,t){t.bufferProcessing=!0;var r=t.bufferedRequest;if(e._writev&&r&&r.next){var n=t.bufferedRequestCount,i=new Array(n),o=t.corkedRequestsFree;o.entry=r;for(var s=0,a=!0;r;)i[s]=r,r.isBuf||(a=!1),r=r.next,s+=1;i.allBuffers=a,ch(e,t,!0,t.length,i,"",o.finish),t.pendingcb++,t.lastBufferedRequest=null,o.next?(t.corkedRequestsFree=o.next,o.next=null):t.corkedRequestsFree=new Bm(t),t.bufferedRequestCount=0}else{for(;r;){var c=r.chunk,h=r.encoding,g=r.callback,m=t.objectMode?1:c.length;if(ch(e,t,!1,m,c,h,g),r=r.next,t.bufferedRequestCount--,t.writing)break}r===null&&(t.lastBufferedRequest=null)}t.bufferedRequest=r,t.bufferProcessing=!1}Xe.prototype._write=function(e,t,r){r(new MR("_write()"))};Xe.prototype._writev=null;Xe.prototype.end=function(e,t,r){var n=this._writableState;return typeof e=="function"?(r=e,e=null,t=null):typeof t=="function"&&(r=t,t=null),e!=null&&this.write(e,t),n.corked&&(n.corked=1,this.uncork()),n.ending||XR(this,n,r),this};Object.defineProperty(Xe.prototype,"writableLength",{enumerable:!1,get:function(){return this._writableState.length}});function km(e){return e.ending&&e.length===0&&e.bufferedRequest===null&&!e.finished&&!e.writing}function $R(e,t){e._final(function(r){t.pendingcb--,r&&Oo(e,r),t.prefinished=!0,e.emit("prefinish"),Os(e,t)})}function ZR(e,t){!t.prefinished&&!t.finalCalled&&(typeof e._final=="function"&&!t.destroyed?(t.pendingcb++,t.finalCalled=!0,x.default.nextTick($R,e,t)):(t.prefinished=!0,e.emit("prefinish")))}function Os(e,t){var r=km(t);if(r&&(ZR(e,t),t.pendingcb===0&&(t.finished=!0,e.emit("finish"),t.autoDestroy))){var n=e._readableState;(!n||n.autoDestroy&&n.endEmitted)&&e.destroy()}return r}function XR(e,t,r){t.ending=!0,Os(e,t),r&&(t.finished?x.default.nextTick(r):e.once("finish",r)),t.ended=!0,e.writable=!1}function JR(e,t,r){var n=e.entry;for(e.entry=null;n;){var i=n.callback;t.pendingcb--,i(r),n=n.next}t.corkedRequestsFree.next=e}Object.defineProperty(Xe.prototype,"destroyed",{enumerable:!1,get:function(){return this._writableState===void 0?!1:this._writableState.destroyed},set:function(t){this._writableState&&(this._writableState.destroyed=t)}});Xe.prototype.destroy=lh.destroy;Xe.prototype._undestroy=lh.undestroy;Xe.prototype._destroy=function(e,t){t(e)}});var Oi=P((_C,Dm)=>{"use strict";y();var QR=Object.keys||function(e){var t=[];for(var r in e)t.push(r);return t};Dm.exports=tn;var Lm=gh(),ph=hh();De()(tn,Lm);for(dh=QR(ph.prototype),Fu=0;Fu<dh.length;Fu++)qu=dh[Fu],tn.prototype[qu]||(tn.prototype[qu]=ph.prototype[qu]);var dh,qu,Fu;function tn(e){if(!(this instanceof tn))return new tn(e);Lm.call(this,e),ph.call(this,e),this.allowHalfOpen=!0,e&&(e.readable===!1&&(this.readable=!1),e.writable===!1&&(this.writable=!1),e.allowHalfOpen===!1&&(this.allowHalfOpen=!1,this.once("end",eT)))}Object.defineProperty(tn.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}});Object.defineProperty(tn.prototype,"writableBuffer",{enumerable:!1,get:function(){return this._writableState&&this._writableState.getBuffer()}});Object.defineProperty(tn.prototype,"writableLength",{enumerable:!1,get:function(){return this._writableState.length}});function eT(){this._writableState.ended||x.default.nextTick(tT,this)}function tT(e){e.end()}Object.defineProperty(tn.prototype,"destroyed",{enumerable:!1,get:function(){return this._readableState===void 0||this._writableState===void 0?!1:this._readableState.destroyed&&this._writableState.destroyed},set:function(t){this._readableState===void 0||this._writableState===void 0||(this._readableState.destroyed=t,this._writableState.destroyed=t)}})});var qm=P((yh,Fm)=>{y();var Hu=Tt(),vn=Hu.Buffer;function Um(e,t){for(var r in e)t[r]=e[r]}vn.from&&vn.alloc&&vn.allocUnsafe&&vn.allocUnsafeSlow?Fm.exports=Hu:(Um(Hu,yh),yh.Buffer=Ro);function Ro(e,t,r){return vn(e,t,r)}Um(vn,Ro);Ro.from=function(e,t,r){if(typeof e=="number")throw new TypeError("Argument must not be a number");return vn(e,t,r)};Ro.alloc=function(e,t,r){if(typeof e!="number")throw new TypeError("Argument must be a number");var n=vn(e);return t!==void 0?typeof r=="string"?n.fill(t,r):n.fill(t):n.fill(0),n};Ro.allocUnsafe=function(e){if(typeof e!="number")throw new TypeError("Argument must be a number");return vn(e)};Ro.allocUnsafeSlow=function(e){if(typeof e!="number")throw new TypeError("Argument must be a number");return Hu.SlowBuffer(e)}});var To=P(jm=>{"use strict";y();var vh=qm().Buffer,Hm=vh.isEncoding||function(e){switch(e=""+e,e&&e.toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":case"raw":return!0;default:return!1}};function rT(e){if(!e)return"utf8";for(var t;;)switch(e){case"utf8":case"utf-8":return"utf8";case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return"utf16le";case"latin1":case"binary":return"latin1";case"base64":case"ascii":case"hex":return e;default:if(t)return;e=(""+e).toLowerCase(),t=!0}}function nT(e){var t=rT(e);if(typeof t!="string"&&(vh.isEncoding===Hm||!Hm(e)))throw new Error("Unknown encoding: "+e);return t||e}jm.StringDecoder=Ts;function Ts(e){this.encoding=nT(e);var t;switch(this.encoding){case"utf16le":this.text=fT,this.end=cT,t=4;break;case"utf8":this.fillLast=sT,t=4;break;case"base64":this.text=lT,this.end=hT,t=3;break;default:this.write=dT,this.end=pT;return}this.lastNeed=0,this.lastTotal=0,this.lastChar=vh.allocUnsafe(t)}Ts.prototype.write=function(e){if(e.length===0)return"";var t,r;if(this.lastNeed){if(t=this.fillLast(e),t===void 0)return"";r=this.lastNeed,this.lastNeed=0}else r=0;return r<e.length?t?t+this.text(e,r):this.text(e,r):t||""};Ts.prototype.end=uT;Ts.prototype.text=aT;Ts.prototype.fillLast=function(e){if(this.lastNeed<=e.length)return e.copy(this.lastChar,this.lastTotal-this.lastNeed,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal);e.copy(this.lastChar,this.lastTotal-this.lastNeed,0,e.length),this.lastNeed-=e.length};function mh(e){return e<=127?0:e>>5===6?2:e>>4===14?3:e>>3===30?4:e>>6===2?-1:-2}function iT(e,t,r){var n=t.length-1;if(n<r)return 0;var i=mh(t[n]);return i>=0?(i>0&&(e.lastNeed=i-1),i):--n<r||i===-2?0:(i=mh(t[n]),i>=0?(i>0&&(e.lastNeed=i-2),i):--n<r||i===-2?0:(i=mh(t[n]),i>=0?(i>0&&(i===2?i=0:e.lastNeed=i-3),i):0))}function oT(e,t,r){if((t[0]&192)!==128)return e.lastNeed=0,"\uFFFD";if(e.lastNeed>1&&t.length>1){if((t[1]&192)!==128)return e.lastNeed=1,"\uFFFD";if(e.lastNeed>2&&t.length>2&&(t[2]&192)!==128)return e.lastNeed=2,"\uFFFD"}}function sT(e){var t=this.lastTotal-this.lastNeed,r=oT(this,e,t);if(r!==void 0)return r;if(this.lastNeed<=e.length)return e.copy(this.lastChar,t,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal);e.copy(this.lastChar,t,0,e.length),this.lastNeed-=e.length}function aT(e,t){var r=iT(this,e,t);if(!this.lastNeed)return e.toString("utf8",t);this.lastTotal=r;var n=e.length-(r-this.lastNeed);return e.copy(this.lastChar,0,n),e.toString("utf8",t,n)}function uT(e){var t=e&&e.length?this.write(e):"";return this.lastNeed?t+"\uFFFD":t}function fT(e,t){if((e.length-t)%2===0){var r=e.toString("utf16le",t);if(r){var n=r.charCodeAt(r.length-1);if(n>=55296&&n<=56319)return this.lastNeed=2,this.lastTotal=4,this.lastChar[0]=e[e.length-2],this.lastChar[1]=e[e.length-1],r.slice(0,-1)}return r}return this.lastNeed=1,this.lastTotal=2,this.lastChar[0]=e[e.length-1],e.toString("utf16le",t,e.length-1)}function cT(e){var t=e&&e.length?this.write(e):"";if(this.lastNeed){var r=this.lastTotal-this.lastNeed;return t+this.lastChar.toString("utf16le",0,r)}return t}function lT(e,t){var r=(e.length-t)%3;return r===0?e.toString("base64",t):(this.lastNeed=3-r,this.lastTotal=3,r===1?this.lastChar[0]=e[e.length-1]:(this.lastChar[0]=e[e.length-2],this.lastChar[1]=e[e.length-1]),e.toString("base64",t,e.length-r))}function hT(e){var t=e&&e.length?this.write(e):"";return this.lastNeed?t+this.lastChar.toString("base64",0,3-this.lastNeed):t}function dT(e){return e.toString(this.encoding)}function pT(e){return e&&e.length?this.write(e):""}});var ju=P((IC,Gm)=>{"use strict";y();var Km=Ai().codes.ERR_STREAM_PREMATURE_CLOSE;function gT(e){var t=!1;return function(){if(!t){t=!0;for(var r=arguments.length,n=new Array(r),i=0;i<r;i++)n[i]=arguments[i];e.apply(this,n)}}}function yT(){}function mT(e){return e.setHeader&&typeof e.abort=="function"}function Vm(e,t,r){if(typeof t=="function")return Vm(e,null,t);t||(t={}),r=gT(r||yT);var n=t.readable||t.readable!==!1&&e.readable,i=t.writable||t.writable!==!1&&e.writable,o=function(){e.writable||a()},s=e._writableState&&e._writableState.finished,a=function(){i=!1,s=!0,n||r.call(e)},c=e._readableState&&e._readableState.endEmitted,h=function(){n=!1,c=!0,i||r.call(e)},g=function(R){r.call(e,R)},m=function(){var R;if(n&&!c)return(!e._readableState||!e._readableState.ended)&&(R=new Km),r.call(e,R);if(i&&!s)return(!e._writableState||!e._writableState.ended)&&(R=new Km),r.call(e,R)},_=function(){e.req.on("finish",a)};return mT(e)?(e.on("complete",a),e.on("abort",m),e.req?_():e.on("request",_)):i&&!e._writableState&&(e.on("end",o),e.on("close",o)),e.on("end",h),e.on("finish",a),t.error!==!1&&e.on("error",g),e.on("close",m),function(){e.removeListener("complete",a),e.removeListener("abort",m),e.removeListener("request",_),e.req&&e.req.removeListener("finish",a),e.removeListener("end",o),e.removeListener("close",o),e.removeListener("finish",a),e.removeListener("end",h),e.removeListener("error",g),e.removeListener("close",m)}}Gm.exports=Vm});var zm=P((OC,Wm)=>{"use strict";y();var Ku;function zn(e,t,r){return t=vT(t),t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function vT(e){var t=bT(e,"string");return typeof t=="symbol"?t:String(t)}function bT(e,t){if(typeof e!="object"||e===null)return e;var r=e[Symbol.toPrimitive];if(r!==void 0){var n=r.call(e,t||"default");if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}var _T=ju(),Yn=Symbol("lastResolve"),Ri=Symbol("lastReject"),Ps=Symbol("error"),Vu=Symbol("ended"),Ti=Symbol("lastPromise"),bh=Symbol("handlePromise"),Pi=Symbol("stream");function $n(e,t){return{value:e,done:t}}function wT(e){var t=e[Yn];if(t!==null){var r=e[Pi].read();r!==null&&(e[Ti]=null,e[Yn]=null,e[Ri]=null,t($n(r,!1)))}}function ST(e){x.default.nextTick(wT,e)}function ET(e,t){return function(r,n){e.then(function(){if(t[Vu]){r($n(void 0,!0));return}t[bh](r,n)},n)}}var xT=Object.getPrototypeOf(function(){}),IT=Object.setPrototypeOf((Ku={get stream(){return this[Pi]},next:function(){var t=this,r=this[Ps];if(r!==null)return Promise.reject(r);if(this[Vu])return Promise.resolve($n(void 0,!0));if(this[Pi].destroyed)return new Promise(function(s,a){x.default.nextTick(function(){t[Ps]?a(t[Ps]):s($n(void 0,!0))})});var n=this[Ti],i;if(n)i=new Promise(ET(n,this));else{var o=this[Pi].read();if(o!==null)return Promise.resolve($n(o,!1));i=new Promise(this[bh])}return this[Ti]=i,i}},zn(Ku,Symbol.asyncIterator,function(){return this}),zn(Ku,"return",function(){var t=this;return new Promise(function(r,n){t[Pi].destroy(null,function(i){if(i){n(i);return}r($n(void 0,!0))})})}),Ku),xT),AT=function(t){var r,n=Object.create(IT,(r={},zn(r,Pi,{value:t,writable:!0}),zn(r,Yn,{value:null,writable:!0}),zn(r,Ri,{value:null,writable:!0}),zn(r,Ps,{value:null,writable:!0}),zn(r,Vu,{value:t._readableState.endEmitted,writable:!0}),zn(r,bh,{value:function(o,s){var a=n[Pi].read();a?(n[Ti]=null,n[Yn]=null,n[Ri]=null,o($n(a,!1))):(n[Yn]=o,n[Ri]=s)},writable:!0}),r));return n[Ti]=null,_T(t,function(i){if(i&&i.code!=="ERR_STREAM_PREMATURE_CLOSE"){var o=n[Ri];o!==null&&(n[Ti]=null,n[Yn]=null,n[Ri]=null,o(i)),n[Ps]=i;return}var s=n[Yn];s!==null&&(n[Ti]=null,n[Yn]=null,n[Ri]=null,s($n(void 0,!0))),n[Vu]=!0}),t.on("readable",ST.bind(null,n)),n};Wm.exports=AT});var $m=P((TC,Ym)=>{y();Ym.exports=function(){throw new Error("Readable.from is not available in the browser")}});var gh=P((NC,ov)=>{"use strict";y();ov.exports=Te;var Po;Te.ReadableState=Qm;var BC=yo().EventEmitter,Jm=function(t,r){return t.listeners(r).length},Ns=Il(),Gu=Tt().Buffer,OT=(typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof self<"u"?self:{}).Uint8Array||function(){};function RT(e){return Gu.from(e)}function TT(e){return Gu.isBuffer(e)||e instanceof OT}var _h=en(),_e;_h&&_h.debuglog?_e=_h.debuglog("stream"):_e=function(){};var PT=Sm(),Oh=sh(),BT=ah(),NT=BT.getHighWaterMark,Wu=Ai().codes,MT=Wu.ERR_INVALID_ARG_TYPE,kT=Wu.ERR_STREAM_PUSH_AFTER_EOF,CT=Wu.ERR_METHOD_NOT_IMPLEMENTED,LT=Wu.ERR_STREAM_UNSHIFT_AFTER_END_EVENT,Bo,wh,Sh;De()(Te,Ns);var Bs=Oh.errorOrDestroy,Eh=["error","close","destroy","pause","resume"];function DT(e,t,r){if(typeof e.prependListener=="function")return e.prependListener(t,r);!e._events||!e._events[t]?e.on(t,r):Array.isArray(e._events[t])?e._events[t].unshift(r):e._events[t]=[r,e._events[t]]}function Qm(e,t,r){Po=Po||Oi(),e=e||{},typeof r!="boolean"&&(r=t instanceof Po),this.objectMode=!!e.objectMode,r&&(this.objectMode=this.objectMode||!!e.readableObjectMode),this.highWaterMark=NT(this,e,"readableHighWaterMark",r),this.buffer=new PT,this.length=0,this.pipes=null,this.pipesCount=0,this.flowing=null,this.ended=!1,this.endEmitted=!1,this.reading=!1,this.sync=!0,this.needReadable=!1,this.emittedReadable=!1,this.readableListening=!1,this.resumeScheduled=!1,this.paused=!0,this.emitClose=e.emitClose!==!1,this.autoDestroy=!!e.autoDestroy,this.destroyed=!1,this.defaultEncoding=e.defaultEncoding||"utf8",this.awaitDrain=0,this.readingMore=!1,this.decoder=null,this.encoding=null,e.encoding&&(Bo||(Bo=To().StringDecoder),this.decoder=new Bo(e.encoding),this.encoding=e.encoding)}function Te(e){if(Po=Po||Oi(),!(this instanceof Te))return new Te(e);var t=this instanceof Po;this._readableState=new Qm(e,this,t),this.readable=!0,e&&(typeof e.read=="function"&&(this._read=e.read),typeof e.destroy=="function"&&(this._destroy=e.destroy)),Ns.call(this)}Object.defineProperty(Te.prototype,"destroyed",{enumerable:!1,get:function(){return this._readableState===void 0?!1:this._readableState.destroyed},set:function(t){this._readableState&&(this._readableState.destroyed=t)}});Te.prototype.destroy=Oh.destroy;Te.prototype._undestroy=Oh.undestroy;Te.prototype._destroy=function(e,t){t(e)};Te.prototype.push=function(e,t){var r=this._readableState,n;return r.objectMode?n=!0:typeof e=="string"&&(t=t||r.defaultEncoding,t!==r.encoding&&(e=Gu.from(e,t),t=""),n=!0),ev(this,e,t,!1,n)};Te.prototype.unshift=function(e){return ev(this,e,null,!0,!1)};function ev(e,t,r,n,i){_e("readableAddChunk",t);var o=e._readableState;if(t===null)o.reading=!1,qT(e,o);else{var s;if(i||(s=UT(o,t)),s)Bs(e,s);else if(o.objectMode||t&&t.length>0)if(typeof t!="string"&&!o.objectMode&&Object.getPrototypeOf(t)!==Gu.prototype&&(t=RT(t)),n)o.endEmitted?Bs(e,new LT):xh(e,o,t,!0);else if(o.ended)Bs(e,new kT);else{if(o.destroyed)return!1;o.reading=!1,o.decoder&&!r?(t=o.decoder.write(t),o.objectMode||t.length!==0?xh(e,o,t,!1):Ah(e,o)):xh(e,o,t,!1)}else n||(o.reading=!1,Ah(e,o))}return!o.ended&&(o.length<o.highWaterMark||o.length===0)}function xh(e,t,r,n){t.flowing&&t.length===0&&!t.sync?(t.awaitDrain=0,e.emit("data",r)):(t.length+=t.objectMode?1:r.length,n?t.buffer.unshift(r):t.buffer.push(r),t.needReadable&&zu(e)),Ah(e,t)}function UT(e,t){var r;return!TT(t)&&typeof t!="string"&&t!==void 0&&!e.objectMode&&(r=new MT("chunk",["string","Buffer","Uint8Array"],t)),r}Te.prototype.isPaused=function(){return this._readableState.flowing===!1};Te.prototype.setEncoding=function(e){Bo||(Bo=To().StringDecoder);var t=new Bo(e);this._readableState.decoder=t,this._readableState.encoding=this._readableState.decoder.encoding;for(var r=this._readableState.buffer.head,n="";r!==null;)n+=t.write(r.data),r=r.next;return this._readableState.buffer.clear(),n!==""&&this._readableState.buffer.push(n),this._readableState.length=n.length,this};var Zm=1073741824;function FT(e){return e>=Zm?e=Zm:(e--,e|=e>>>1,e|=e>>>2,e|=e>>>4,e|=e>>>8,e|=e>>>16,e++),e}function Xm(e,t){return e<=0||t.length===0&&t.ended?0:t.objectMode?1:e!==e?t.flowing&&t.length?t.buffer.head.data.length:t.length:(e>t.highWaterMark&&(t.highWaterMark=FT(e)),e<=t.length?e:t.ended?t.length:(t.needReadable=!0,0))}Te.prototype.read=function(e){_e("read",e),e=parseInt(e,10);var t=this._readableState,r=e;if(e!==0&&(t.emittedReadable=!1),e===0&&t.needReadable&&((t.highWaterMark!==0?t.length>=t.highWaterMark:t.length>0)||t.ended))return _e("read: emitReadable",t.length,t.ended),t.length===0&&t.ended?Ih(this):zu(this),null;if(e=Xm(e,t),e===0&&t.ended)return t.length===0&&Ih(this),null;var n=t.needReadable;_e("need readable",n),(t.length===0||t.length-e<t.highWaterMark)&&(n=!0,_e("length less than watermark",n)),t.ended||t.reading?(n=!1,_e("reading or ended",n)):n&&(_e("do read"),t.reading=!0,t.sync=!0,t.length===0&&(t.needReadable=!0),this._read(t.highWaterMark),t.sync=!1,t.reading||(e=Xm(r,t)));var i;return e>0?i=nv(e,t):i=null,i===null?(t.needReadable=t.length<=t.highWaterMark,e=0):(t.length-=e,t.awaitDrain=0),t.length===0&&(t.ended||(t.needReadable=!0),r!==e&&t.ended&&Ih(this)),i!==null&&this.emit("data",i),i};function qT(e,t){if(_e("onEofChunk"),!t.ended){if(t.decoder){var r=t.decoder.end();r&&r.length&&(t.buffer.push(r),t.length+=t.objectMode?1:r.length)}t.ended=!0,t.sync?zu(e):(t.needReadable=!1,t.emittedReadable||(t.emittedReadable=!0,tv(e)))}}function zu(e){var t=e._readableState;_e("emitReadable",t.needReadable,t.emittedReadable),t.needReadable=!1,t.emittedReadable||(_e("emitReadable",t.flowing),t.emittedReadable=!0,x.default.nextTick(tv,e))}function tv(e){var t=e._readableState;_e("emitReadable_",t.destroyed,t.length,t.ended),!t.destroyed&&(t.length||t.ended)&&(e.emit("readable"),t.emittedReadable=!1),t.needReadable=!t.flowing&&!t.ended&&t.length<=t.highWaterMark,Rh(e)}function Ah(e,t){t.readingMore||(t.readingMore=!0,x.default.nextTick(HT,e,t))}function HT(e,t){for(;!t.reading&&!t.ended&&(t.length<t.highWaterMark||t.flowing&&t.length===0);){var r=t.length;if(_e("maybeReadMore read 0"),e.read(0),r===t.length)break}t.readingMore=!1}Te.prototype._read=function(e){Bs(this,new CT("_read()"))};Te.prototype.pipe=function(e,t){var r=this,n=this._readableState;switch(n.pipesCount){case 0:n.pipes=e;break;case 1:n.pipes=[n.pipes,e];break;default:n.pipes.push(e);break}n.pipesCount+=1,_e("pipe count=%d opts=%j",n.pipesCount,t);var i=(!t||t.end!==!1)&&e!==x.default.stdout&&e!==x.default.stderr,o=i?a:N;n.endEmitted?x.default.nextTick(o):r.once("end",o),e.on("unpipe",s);function s(L,q){_e("onunpipe"),L===r&&q&&q.hasUnpiped===!1&&(q.hasUnpiped=!0,g())}function a(){_e("onend"),e.end()}var c=jT(r);e.on("drain",c);var h=!1;function g(){_e("cleanup"),e.removeListener("close",I),e.removeListener("finish",R),e.removeListener("drain",c),e.removeListener("error",_),e.removeListener("unpipe",s),r.removeListener("end",a),r.removeListener("end",N),r.removeListener("data",m),h=!0,n.awaitDrain&&(!e._writableState||e._writableState.needDrain)&&c()}r.on("data",m);function m(L){_e("ondata");var q=e.write(L);_e("dest.write",q),q===!1&&((n.pipesCount===1&&n.pipes===e||n.pipesCount>1&&iv(n.pipes,e)!==-1)&&!h&&(_e("false write response, pause",n.awaitDrain),n.awaitDrain++),r.pause())}function _(L){_e("onerror",L),N(),e.removeListener("error",_),Jm(e,"error")===0&&Bs(e,L)}DT(e,"error",_);function I(){e.removeListener("finish",R),N()}e.once("close",I);function R(){_e("onfinish"),e.removeListener("close",I),N()}e.once("finish",R);function N(){_e("unpipe"),r.unpipe(e)}return e.emit("pipe",r),n.flowing||(_e("pipe resume"),r.resume()),e};function jT(e){return function(){var r=e._readableState;_e("pipeOnDrain",r.awaitDrain),r.awaitDrain&&r.awaitDrain--,r.awaitDrain===0&&Jm(e,"data")&&(r.flowing=!0,Rh(e))}}Te.prototype.unpipe=function(e){var t=this._readableState,r={hasUnpiped:!1};if(t.pipesCount===0)return this;if(t.pipesCount===1)return e&&e!==t.pipes?this:(e||(e=t.pipes),t.pipes=null,t.pipesCount=0,t.flowing=!1,e&&e.emit("unpipe",this,r),this);if(!e){var n=t.pipes,i=t.pipesCount;t.pipes=null,t.pipesCount=0,t.flowing=!1;for(var o=0;o<i;o++)n[o].emit("unpipe",this,{hasUnpiped:!1});return this}var s=iv(t.pipes,e);return s===-1?this:(t.pipes.splice(s,1),t.pipesCount-=1,t.pipesCount===1&&(t.pipes=t.pipes[0]),e.emit("unpipe",this,r),this)};Te.prototype.on=function(e,t){var r=Ns.prototype.on.call(this,e,t),n=this._readableState;return e==="data"?(n.readableListening=this.listenerCount("readable")>0,n.flowing!==!1&&this.resume()):e==="readable"&&!n.endEmitted&&!n.readableListening&&(n.readableListening=n.needReadable=!0,n.flowing=!1,n.emittedReadable=!1,_e("on readable",n.length,n.reading),n.length?zu(this):n.reading||x.default.nextTick(KT,this)),r};Te.prototype.addListener=Te.prototype.on;Te.prototype.removeListener=function(e,t){var r=Ns.prototype.removeListener.call(this,e,t);return e==="readable"&&x.default.nextTick(rv,this),r};Te.prototype.removeAllListeners=function(e){var t=Ns.prototype.removeAllListeners.apply(this,arguments);return(e==="readable"||e===void 0)&&x.default.nextTick(rv,this),t};function rv(e){var t=e._readableState;t.readableListening=e.listenerCount("readable")>0,t.resumeScheduled&&!t.paused?t.flowing=!0:e.listenerCount("data")>0&&e.resume()}function KT(e){_e("readable nexttick read 0"),e.read(0)}Te.prototype.resume=function(){var e=this._readableState;return e.flowing||(_e("resume"),e.flowing=!e.readableListening,VT(this,e)),e.paused=!1,this};function VT(e,t){t.resumeScheduled||(t.resumeScheduled=!0,x.default.nextTick(GT,e,t))}function GT(e,t){_e("resume",t.reading),t.reading||e.read(0),t.resumeScheduled=!1,e.emit("resume"),Rh(e),t.flowing&&!t.reading&&e.read(0)}Te.prototype.pause=function(){return _e("call pause flowing=%j",this._readableState.flowing),this._readableState.flowing!==!1&&(_e("pause"),this._readableState.flowing=!1,this.emit("pause")),this._readableState.paused=!0,this};function Rh(e){var t=e._readableState;for(_e("flow",t.flowing);t.flowing&&e.read()!==null;);}Te.prototype.wrap=function(e){var t=this,r=this._readableState,n=!1;e.on("end",function(){if(_e("wrapped end"),r.decoder&&!r.ended){var s=r.decoder.end();s&&s.length&&t.push(s)}t.push(null)}),e.on("data",function(s){if(_e("wrapped data"),r.decoder&&(s=r.decoder.write(s)),!(r.objectMode&&s==null)&&!(!r.objectMode&&(!s||!s.length))){var a=t.push(s);a||(n=!0,e.pause())}});for(var i in e)this[i]===void 0&&typeof e[i]=="function"&&(this[i]=(function(a){return function(){return e[a].apply(e,arguments)}})(i));for(var o=0;o<Eh.length;o++)e.on(Eh[o],this.emit.bind(this,Eh[o]));return this._read=function(s){_e("wrapped _read",s),n&&(n=!1,e.resume())},this};typeof Symbol=="function"&&(Te.prototype[Symbol.asyncIterator]=function(){return wh===void 0&&(wh=zm()),wh(this)});Object.defineProperty(Te.prototype,"readableHighWaterMark",{enumerable:!1,get:function(){return this._readableState.highWaterMark}});Object.defineProperty(Te.prototype,"readableBuffer",{enumerable:!1,get:function(){return this._readableState&&this._readableState.buffer}});Object.defineProperty(Te.prototype,"readableFlowing",{enumerable:!1,get:function(){return this._readableState.flowing},set:function(t){this._readableState&&(this._readableState.flowing=t)}});Te._fromList=nv;Object.defineProperty(Te.prototype,"readableLength",{enumerable:!1,get:function(){return this._readableState.length}});function nv(e,t){if(t.length===0)return null;var r;return t.objectMode?r=t.buffer.shift():!e||e>=t.length?(t.decoder?r=t.buffer.join(""):t.buffer.length===1?r=t.buffer.first():r=t.buffer.concat(t.length),t.buffer.clear()):r=t.buffer.consume(e,t.decoder),r}function Ih(e){var t=e._readableState;_e("endReadable",t.endEmitted),t.endEmitted||(t.ended=!0,x.default.nextTick(WT,t,e))}function WT(e,t){if(_e("endReadableNT",e.endEmitted,e.length),!e.endEmitted&&e.length===0&&(e.endEmitted=!0,t.readable=!1,t.emit("end"),e.autoDestroy)){var r=t._writableState;(!r||r.autoDestroy&&r.finished)&&t.destroy()}}typeof Symbol=="function"&&(Te.from=function(e,t){return Sh===void 0&&(Sh=$m()),Sh(Te,e,t)});function iv(e,t){for(var r=0,n=e.length;r<n;r++)if(e[r]===t)return r;return-1}});var Th=P((kC,av)=>{"use strict";y();av.exports=bn;var Yu=Ai().codes,zT=Yu.ERR_METHOD_NOT_IMPLEMENTED,YT=Yu.ERR_MULTIPLE_CALLBACK,$T=Yu.ERR_TRANSFORM_ALREADY_TRANSFORMING,ZT=Yu.ERR_TRANSFORM_WITH_LENGTH_0,$u=Oi();De()(bn,$u);function XT(e,t){var r=this._transformState;r.transforming=!1;var n=r.writecb;if(n===null)return this.emit("error",new YT);r.writechunk=null,r.writecb=null,t!=null&&this.push(t),n(e);var i=this._readableState;i.reading=!1,(i.needReadable||i.length<i.highWaterMark)&&this._read(i.highWaterMark)}function bn(e){if(!(this instanceof bn))return new bn(e);$u.call(this,e),this._transformState={afterTransform:XT.bind(this),needTransform:!1,transforming:!1,writecb:null,writechunk:null,writeencoding:null},this._readableState.needReadable=!0,this._readableState.sync=!1,e&&(typeof e.transform=="function"&&(this._transform=e.transform),typeof e.flush=="function"&&(this._flush=e.flush)),this.on("prefinish",JT)}function JT(){var e=this;typeof this._flush=="function"&&!this._readableState.destroyed?this._flush(function(t,r){sv(e,t,r)}):sv(this,null,null)}bn.prototype.push=function(e,t){return this._transformState.needTransform=!1,$u.prototype.push.call(this,e,t)};bn.prototype._transform=function(e,t,r){r(new zT("_transform()"))};bn.prototype._write=function(e,t,r){var n=this._transformState;if(n.writecb=r,n.writechunk=e,n.writeencoding=t,!n.transforming){var i=this._readableState;(n.needTransform||i.needReadable||i.length<i.highWaterMark)&&this._read(i.highWaterMark)}};bn.prototype._read=function(e){var t=this._transformState;t.writechunk!==null&&!t.transforming?(t.transforming=!0,this._transform(t.writechunk,t.writeencoding,t.afterTransform)):t.needTransform=!0};bn.prototype._destroy=function(e,t){$u.prototype._destroy.call(this,e,function(r){t(r)})};function sv(e,t,r){if(t)return e.emit("error",t);if(r!=null&&e.push(r),e._writableState.length)throw new ZT;if(e._transformState.transforming)throw new $T;return e.push(null)}});var cv=P((LC,fv)=>{"use strict";y();fv.exports=Ms;var uv=Th();De()(Ms,uv);function Ms(e){if(!(this instanceof Ms))return new Ms(e);uv.call(this,e)}Ms.prototype._transform=function(e,t,r){r(null,e)}});var gv=P((UC,pv)=>{"use strict";y();var Ph;function QT(e){var t=!1;return function(){t||(t=!0,e.apply(void 0,arguments))}}var dv=Ai().codes,e2=dv.ERR_MISSING_ARGS,t2=dv.ERR_STREAM_DESTROYED;function lv(e){if(e)throw e}function r2(e){return e.setHeader&&typeof e.abort=="function"}function n2(e,t,r,n){n=QT(n);var i=!1;e.on("close",function(){i=!0}),Ph===void 0&&(Ph=ju()),Ph(e,{readable:t,writable:r},function(s){if(s)return n(s);i=!0,n()});var o=!1;return function(s){if(!i&&!o){if(o=!0,r2(e))return e.abort();if(typeof e.destroy=="function")return e.destroy();n(s||new t2("pipe"))}}}function hv(e){e()}function i2(e,t){return e.pipe(t)}function o2(e){return!e.length||typeof e[e.length-1]!="function"?lv:e.pop()}function s2(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];var n=o2(t);if(Array.isArray(t[0])&&(t=t[0]),t.length<2)throw new e2("streams");var i,o=t.map(function(s,a){var c=a<t.length-1,h=a>0;return n2(s,c,h,function(g){i||(i=g),g&&o.forEach(hv),!c&&(o.forEach(hv),n(i))})});return t.reduce(i2)}pv.exports=s2});var Nh=P((qC,yv)=>{y();yv.exports=Sr;var Bh=yo().EventEmitter,a2=De();a2(Sr,Bh);Sr.Readable=gh();Sr.Writable=hh();Sr.Duplex=Oi();Sr.Transform=Th();Sr.PassThrough=cv();Sr.finished=ju();Sr.pipeline=gv();Sr.Stream=Sr;function Sr(){Bh.call(this)}Sr.prototype.pipe=function(e,t){var r=this;function n(g){e.writable&&e.write(g)===!1&&r.pause&&r.pause()}r.on("data",n);function i(){r.readable&&r.resume&&r.resume()}e.on("drain",i),!e._isStdio&&(!t||t.end!==!1)&&(r.on("end",s),r.on("close",a));var o=!1;function s(){o||(o=!0,e.end())}function a(){o||(o=!0,typeof e.destroy=="function"&&e.destroy())}function c(g){if(h(),Bh.listenerCount(this,"error")===0)throw g}r.on("error",c),e.on("error",c);function h(){r.removeListener("data",n),e.removeListener("drain",i),r.removeListener("end",s),r.removeListener("close",a),r.removeListener("error",c),e.removeListener("error",c),r.removeListener("end",h),r.removeListener("close",h),e.removeListener("close",h)}return r.on("end",h),r.on("close",h),e.on("close",h),e.emit("pipe",r),e}});var bv=P((jC,vv)=>{"use strict";y();var rn=qt().Buffer,mv=Nh().Transform,u2=De();function Zn(e){mv.call(this),this._block=rn.allocUnsafe(e),this._blockSize=e,this._blockOffset=0,this._length=[0,0,0,0],this._finalized=!1}u2(Zn,mv);Zn.prototype._transform=function(e,t,r){var n=null;try{this.update(e,t)}catch(i){n=i}r(n)};Zn.prototype._flush=function(e){var t=null;try{this.push(this.digest())}catch(r){t=r}e(t)};var f2=typeof Uint8Array<"u",c2=typeof ArrayBuffer<"u"&&typeof Uint8Array<"u"&&ArrayBuffer.isView&&(rn.prototype instanceof Uint8Array||rn.TYPED_ARRAY_SUPPORT);function l2(e,t){if(e instanceof rn)return e;if(typeof e=="string")return rn.from(e,t);if(c2&&ArrayBuffer.isView(e)){if(e.byteLength===0)return rn.alloc(0);var r=rn.from(e.buffer,e.byteOffset,e.byteLength);if(r.byteLength===e.byteLength)return r}if(f2&&e instanceof Uint8Array||rn.isBuffer(e)&&e.constructor&&typeof e.constructor.isBuffer=="function"&&e.constructor.isBuffer(e))return rn.from(e);throw new TypeError('The "data" argument must be of type string or an instance of Buffer, TypedArray, or DataView.')}Zn.prototype.update=function(e,t){if(this._finalized)throw new Error("Digest already called");e=l2(e,t);for(var r=this._block,n=0;this._blockOffset+e.length-n>=this._blockSize;){for(var i=this._blockOffset;i<this._blockSize;)r[i++]=e[n++];this._update(),this._blockOffset=0}for(;n<e.length;)r[this._blockOffset++]=e[n++];for(var o=0,s=e.length*8;s>0;++o)this._length[o]+=s,s=this._length[o]/4294967296|0,s>0&&(this._length[o]-=4294967296*s);return this};Zn.prototype._update=function(){throw new Error("_update is not implemented")};Zn.prototype.digest=function(e){if(this._finalized)throw new Error("Digest already called");this._finalized=!0;var t=this._digest();e!==void 0&&(t=t.toString(e)),this._block.fill(0),this._blockOffset=0;for(var r=0;r<4;++r)this._length[r]=0;return t};Zn.prototype._digest=function(){throw new Error("_digest is not implemented")};vv.exports=Zn});var Mh=P((VC,wv)=>{"use strict";y();var h2=De(),_v=bv(),d2=qt().Buffer,p2=new Array(16);function Zu(){_v.call(this,64),this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878}h2(Zu,_v);Zu.prototype._update=function(){for(var e=p2,t=0;t<16;++t)e[t]=this._block.readInt32LE(t*4);var r=this._a,n=this._b,i=this._c,o=this._d;r=Gt(r,n,i,o,e[0],3614090360,7),o=Gt(o,r,n,i,e[1],3905402710,12),i=Gt(i,o,r,n,e[2],606105819,17),n=Gt(n,i,o,r,e[3],3250441966,22),r=Gt(r,n,i,o,e[4],4118548399,7),o=Gt(o,r,n,i,e[5],1200080426,12),i=Gt(i,o,r,n,e[6],2821735955,17),n=Gt(n,i,o,r,e[7],4249261313,22),r=Gt(r,n,i,o,e[8],1770035416,7),o=Gt(o,r,n,i,e[9],2336552879,12),i=Gt(i,o,r,n,e[10],4294925233,17),n=Gt(n,i,o,r,e[11],2304563134,22),r=Gt(r,n,i,o,e[12],1804603682,7),o=Gt(o,r,n,i,e[13],4254626195,12),i=Gt(i,o,r,n,e[14],2792965006,17),n=Gt(n,i,o,r,e[15],1236535329,22),r=Wt(r,n,i,o,e[1],4129170786,5),o=Wt(o,r,n,i,e[6],3225465664,9),i=Wt(i,o,r,n,e[11],643717713,14),n=Wt(n,i,o,r,e[0],3921069994,20),r=Wt(r,n,i,o,e[5],3593408605,5),o=Wt(o,r,n,i,e[10],38016083,9),i=Wt(i,o,r,n,e[15],3634488961,14),n=Wt(n,i,o,r,e[4],3889429448,20),r=Wt(r,n,i,o,e[9],568446438,5),o=Wt(o,r,n,i,e[14],3275163606,9),i=Wt(i,o,r,n,e[3],4107603335,14),n=Wt(n,i,o,r,e[8],1163531501,20),r=Wt(r,n,i,o,e[13],2850285829,5),o=Wt(o,r,n,i,e[2],4243563512,9),i=Wt(i,o,r,n,e[7],1735328473,14),n=Wt(n,i,o,r,e[12],2368359562,20),r=zt(r,n,i,o,e[5],4294588738,4),o=zt(o,r,n,i,e[8],2272392833,11),i=zt(i,o,r,n,e[11],1839030562,16),n=zt(n,i,o,r,e[14],4259657740,23),r=zt(r,n,i,o,e[1],2763975236,4),o=zt(o,r,n,i,e[4],1272893353,11),i=zt(i,o,r,n,e[7],4139469664,16),n=zt(n,i,o,r,e[10],3200236656,23),r=zt(r,n,i,o,e[13],681279174,4),o=zt(o,r,n,i,e[0],3936430074,11),i=zt(i,o,r,n,e[3],3572445317,16),n=zt(n,i,o,r,e[6],76029189,23),r=zt(r,n,i,o,e[9],3654602809,4),o=zt(o,r,n,i,e[12],3873151461,11),i=zt(i,o,r,n,e[15],530742520,16),n=zt(n,i,o,r,e[2],3299628645,23),r=Yt(r,n,i,o,e[0],4096336452,6),o=Yt(o,r,n,i,e[7],1126891415,10),i=Yt(i,o,r,n,e[14],2878612391,15),n=Yt(n,i,o,r,e[5],4237533241,21),r=Yt(r,n,i,o,e[12],1700485571,6),o=Yt(o,r,n,i,e[3],2399980690,10),i=Yt(i,o,r,n,e[10],4293915773,15),n=Yt(n,i,o,r,e[1],2240044497,21),r=Yt(r,n,i,o,e[8],1873313359,6),o=Yt(o,r,n,i,e[15],4264355552,10),i=Yt(i,o,r,n,e[6],2734768916,15),n=Yt(n,i,o,r,e[13],1309151649,21),r=Yt(r,n,i,o,e[4],4149444226,6),o=Yt(o,r,n,i,e[11],3174756917,10),i=Yt(i,o,r,n,e[2],718787259,15),n=Yt(n,i,o,r,e[9],3951481745,21),this._a=this._a+r|0,this._b=this._b+n|0,this._c=this._c+i|0,this._d=this._d+o|0};Zu.prototype._digest=function(){this._block[this._blockOffset++]=128,this._blockOffset>56&&(this._block.fill(0,this._blockOffset,64),this._update(),this._blockOffset=0),this._block.fill(0,this._blockOffset,56),this._block.writeUInt32LE(this._length[0],56),this._block.writeUInt32LE(this._length[1],60),this._update();var e=d2.allocUnsafe(16);return e.writeInt32LE(this._a,0),e.writeInt32LE(this._b,4),e.writeInt32LE(this._c,8),e.writeInt32LE(this._d,12),e};function Xu(e,t){return e<<t|e>>>32-t}function Gt(e,t,r,n,i,o,s){return Xu(e+(t&r|~t&n)+i+o|0,s)+t|0}function Wt(e,t,r,n,i,o,s){return Xu(e+(t&n|r&~n)+i+o|0,s)+t|0}function zt(e,t,r,n,i,o,s){return Xu(e+(t^r^n)+i+o|0,s)+t|0}function Yt(e,t,r,n,i,o,s){return Xu(e+(r^(t|~n))+i+o|0,s)+t|0}wv.exports=Zu});var Ev=P((WC,Sv)=>{y();var g2={}.toString;Sv.exports=Array.isArray||function(e){return g2.call(e)=="[object Array]"}});var Iv=P((YC,xv)=>{"use strict";y();var y2=wi(),m2=Vn(),v2=m2("TypedArray.prototype.buffer",!0),b2=Zl();xv.exports=v2||function(t){if(!b2(t))throw new y2("Not a Typed Array");return t.buffer}});var Ju=P((ZC,Ov)=>{"use strict";y();var Mr=qt().Buffer,_2=Ev(),w2=Iv(),S2=ArrayBuffer.isView||function(t){try{return w2(t),!0}catch{return!1}},E2=typeof Uint8Array<"u",Av=typeof ArrayBuffer<"u"&&typeof Uint8Array<"u",x2=Av&&(Mr.prototype instanceof Uint8Array||Mr.TYPED_ARRAY_SUPPORT);Ov.exports=function(t,r){if(Mr.isBuffer(t))return t.constructor&&!("isBuffer"in t)?Mr.from(t):t;if(typeof t=="string")return Mr.from(t,r);if(Av&&S2(t)){if(t.byteLength===0)return Mr.alloc(0);if(x2){var n=Mr.from(t.buffer,t.byteOffset,t.byteLength);if(n.byteLength===t.byteLength)return n}var i=t instanceof Uint8Array?t:new Uint8Array(t.buffer,t.byteOffset,t.byteLength),o=Mr.from(i);if(o.length===t.byteLength)return o}if(E2&&t instanceof Uint8Array)return Mr.from(t);var s=_2(t);if(s)for(var a=0;a<t.length;a+=1){var c=t[a];if(typeof c!="number"||c<0||c>255||~~c!==c)throw new RangeError("Array items must be numbers in the range 0-255.")}if(s||Mr.isBuffer(t)&&t.constructor&&typeof t.constructor.isBuffer=="function"&&t.constructor.isBuffer(t))return Mr.from(t);throw new TypeError('The "data" argument must be a string, an Array, a Buffer, a Uint8Array, or a DataView.')}});var Bv=P((JC,Pv)=>{"use strict";y();var I2=qt().Buffer,A2=Ju(),Tv=typeof Uint8Array<"u",O2=Tv&&typeof ArrayBuffer<"u",Rv=O2&&ArrayBuffer.isView;Pv.exports=function(e,t){if(typeof e=="string"||I2.isBuffer(e)||Tv&&e instanceof Uint8Array||Rv&&Rv(e))return A2(e,t);throw new TypeError('The "data" argument must be a string, a Buffer, a Uint8Array, or a DataView')}});var ks=P((eL,kh)=>{"use strict";y();typeof x.default>"u"||!x.default.version||x.default.version.indexOf("v0.")===0||x.default.version.indexOf("v1.")===0&&x.default.version.indexOf("v1.8.")!==0?kh.exports={nextTick:R2}:kh.exports=x.default;function R2(e,t,r,n){if(typeof e!="function")throw new TypeError('"callback" argument must be a function');var i=arguments.length,o,s;switch(i){case 0:case 1:return x.default.nextTick(e);case 2:return x.default.nextTick(function(){e.call(null,t)});case 3:return x.default.nextTick(function(){e.call(null,t,r)});case 4:return x.default.nextTick(function(){e.call(null,t,r,n)});default:for(o=new Array(i-1),s=0;s<o.length;)o[s++]=arguments[s];return x.default.nextTick(function(){e.apply(null,o)})}}});var Mv=P((rL,Nv)=>{y();var T2={}.toString;Nv.exports=Array.isArray||function(e){return T2.call(e)=="[object Array]"}});var Ch=P((iL,kv)=>{y();kv.exports=yo().EventEmitter});var ef=P((Lh,Lv)=>{y();var Qu=Tt(),_n=Qu.Buffer;function Cv(e,t){for(var r in e)t[r]=e[r]}_n.from&&_n.alloc&&_n.allocUnsafe&&_n.allocUnsafeSlow?Lv.exports=Qu:(Cv(Qu,Lh),Lh.Buffer=No);function No(e,t,r){return _n(e,t,r)}Cv(_n,No);No.from=function(e,t,r){if(typeof e=="number")throw new TypeError("Argument must not be a number");return _n(e,t,r)};No.alloc=function(e,t,r){if(typeof e!="number")throw new TypeError("Argument must be a number");var n=_n(e);return t!==void 0?typeof r=="string"?n.fill(t,r):n.fill(t):n.fill(0),n};No.allocUnsafe=function(e){if(typeof e!="number")throw new TypeError("Argument must be a number");return _n(e)};No.allocUnsafeSlow=function(e){if(typeof e!="number")throw new TypeError("Argument must be a number");return Qu.SlowBuffer(e)}});var Mo=P($t=>{y();function P2(e){return Array.isArray?Array.isArray(e):tf(e)==="[object Array]"}$t.isArray=P2;function B2(e){return typeof e=="boolean"}$t.isBoolean=B2;function N2(e){return e===null}$t.isNull=N2;function M2(e){return e==null}$t.isNullOrUndefined=M2;function k2(e){return typeof e=="number"}$t.isNumber=k2;function C2(e){return typeof e=="string"}$t.isString=C2;function L2(e){return typeof e=="symbol"}$t.isSymbol=L2;function D2(e){return e===void 0}$t.isUndefined=D2;function U2(e){return tf(e)==="[object RegExp]"}$t.isRegExp=U2;function F2(e){return typeof e=="object"&&e!==null}$t.isObject=F2;function q2(e){return tf(e)==="[object Date]"}$t.isDate=q2;function H2(e){return tf(e)==="[object Error]"||e instanceof Error}$t.isError=H2;function j2(e){return typeof e=="function"}$t.isFunction=j2;function K2(e){return e===null||typeof e=="boolean"||typeof e=="number"||typeof e=="string"||typeof e=="symbol"||typeof e>"u"}$t.isPrimitive=K2;$t.isBuffer=Tt().Buffer.isBuffer;function tf(e){return Object.prototype.toString.call(e)}});var Uv=P((fL,Dh)=>{"use strict";y();function V2(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}var Dv=ef().Buffer,Cs=en();function G2(e,t,r){e.copy(t,r)}Dh.exports=(function(){function e(){V2(this,e),this.head=null,this.tail=null,this.length=0}return e.prototype.push=function(r){var n={data:r,next:null};this.length>0?this.tail.next=n:this.head=n,this.tail=n,++this.length},e.prototype.unshift=function(r){var n={data:r,next:this.head};this.length===0&&(this.tail=n),this.head=n,++this.length},e.prototype.shift=function(){if(this.length!==0){var r=this.head.data;return this.length===1?this.head=this.tail=null:this.head=this.head.next,--this.length,r}},e.prototype.clear=function(){this.head=this.tail=null,this.length=0},e.prototype.join=function(r){if(this.length===0)return"";for(var n=this.head,i=""+n.data;n=n.next;)i+=r+n.data;return i},e.prototype.concat=function(r){if(this.length===0)return Dv.alloc(0);for(var n=Dv.allocUnsafe(r>>>0),i=this.head,o=0;i;)G2(i.data,n,o),o+=i.data.length,i=i.next;return n},e})();Cs&&Cs.inspect&&Cs.inspect.custom&&(Dh.exports.prototype[Cs.inspect.custom]=function(){var e=Cs.inspect({length:this.length});return this.constructor.name+" "+e})});var Uh=P((lL,Fv)=>{"use strict";y();var rf=ks();function W2(e,t){var r=this,n=this._readableState&&this._readableState.destroyed,i=this._writableState&&this._writableState.destroyed;return n||i?(t?t(e):e&&(this._writableState?this._writableState.errorEmitted||(this._writableState.errorEmitted=!0,rf.nextTick(nf,this,e)):rf.nextTick(nf,this,e)),this):(this._readableState&&(this._readableState.destroyed=!0),this._writableState&&(this._writableState.destroyed=!0),this._destroy(e||null,function(o){!t&&o?r._writableState?r._writableState.errorEmitted||(r._writableState.errorEmitted=!0,rf.nextTick(nf,r,o)):rf.nextTick(nf,r,o):t&&t(o)}),this)}function z2(){this._readableState&&(this._readableState.destroyed=!1,this._readableState.reading=!1,this._readableState.ended=!1,this._readableState.endEmitted=!1),this._writableState&&(this._writableState.destroyed=!1,this._writableState.ended=!1,this._writableState.ending=!1,this._writableState.finalCalled=!1,this._writableState.prefinished=!1,this._writableState.finished=!1,this._writableState.errorEmitted=!1)}function nf(e,t){e.emit("error",t)}Fv.exports={destroy:W2,undestroy:z2}});var qh=P((dL,zv)=>{"use strict";y();var Bi=ks();zv.exports=Et;function Hv(e){var t=this;this.next=null,this.entry=null,this.finish=function(){lP(t,e)}}var Y2=!x.default.browser&&["v0.10","v0.9."].indexOf(x.default.version.slice(0,5))>-1?setImmediate:Bi.nextTick,ko;Et.WritableState=Ds;var jv=Object.create(Mo());jv.inherits=De();var $2={deprecate:fh()},Kv=Ch(),sf=ef().Buffer,Z2=(typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof self<"u"?self:{}).Uint8Array||function(){};function X2(e){return sf.from(e)}function J2(e){return sf.isBuffer(e)||e instanceof Z2}var Vv=Uh();jv.inherits(Et,Kv);function Q2(){}function Ds(e,t){ko=ko||Ni(),e=e||{};var r=t instanceof ko;this.objectMode=!!e.objectMode,r&&(this.objectMode=this.objectMode||!!e.writableObjectMode);var n=e.highWaterMark,i=e.writableHighWaterMark,o=this.objectMode?16:16*1024;n||n===0?this.highWaterMark=n:r&&(i||i===0)?this.highWaterMark=i:this.highWaterMark=o,this.highWaterMark=Math.floor(this.highWaterMark),this.finalCalled=!1,this.needDrain=!1,this.ending=!1,this.ended=!1,this.finished=!1,this.destroyed=!1;var s=e.decodeStrings===!1;this.decodeStrings=!s,this.defaultEncoding=e.defaultEncoding||"utf8",this.length=0,this.writing=!1,this.corked=0,this.sync=!0,this.bufferProcessing=!1,this.onwrite=function(a){sP(t,a)},this.writecb=null,this.writelen=0,this.bufferedRequest=null,this.lastBufferedRequest=null,this.pendingcb=0,this.prefinished=!1,this.errorEmitted=!1,this.bufferedRequestCount=0,this.corkedRequestsFree=new Hv(this)}Ds.prototype.getBuffer=function(){for(var t=this.bufferedRequest,r=[];t;)r.push(t),t=t.next;return r};(function(){try{Object.defineProperty(Ds.prototype,"buffer",{get:$2.deprecate(function(){return this.getBuffer()},"_writableState.buffer is deprecated. Use _writableState.getBuffer instead.","DEP0003")})}catch{}})();var of;typeof Symbol=="function"&&Symbol.hasInstance&&typeof Function.prototype[Symbol.hasInstance]=="function"?(of=Function.prototype[Symbol.hasInstance],Object.defineProperty(Et,Symbol.hasInstance,{value:function(e){return of.call(this,e)?!0:this!==Et?!1:e&&e._writableState instanceof Ds}})):of=function(e){return e instanceof this};function Et(e){if(ko=ko||Ni(),!of.call(Et,this)&&!(this instanceof ko))return new Et(e);this._writableState=new Ds(e,this),this.writable=!0,e&&(typeof e.write=="function"&&(this._write=e.write),typeof e.writev=="function"&&(this._writev=e.writev),typeof e.destroy=="function"&&(this._destroy=e.destroy),typeof e.final=="function"&&(this._final=e.final)),Kv.call(this)}Et.prototype.pipe=function(){this.emit("error",new Error("Cannot pipe, not readable"))};function eP(e,t){var r=new Error("write after end");e.emit("error",r),Bi.nextTick(t,r)}function tP(e,t,r,n){var i=!0,o=!1;return r===null?o=new TypeError("May not write null values to stream"):typeof r!="string"&&r!==void 0&&!t.objectMode&&(o=new TypeError("Invalid non-string/buffer chunk")),o&&(e.emit("error",o),Bi.nextTick(n,o),i=!1),i}Et.prototype.write=function(e,t,r){var n=this._writableState,i=!1,o=!n.objectMode&&J2(e);return o&&!sf.isBuffer(e)&&(e=X2(e)),typeof t=="function"&&(r=t,t=null),o?t="buffer":t||(t=n.defaultEncoding),typeof r!="function"&&(r=Q2),n.ended?eP(this,r):(o||tP(this,n,e,r))&&(n.pendingcb++,i=nP(this,n,o,e,t,r)),i};Et.prototype.cork=function(){var e=this._writableState;e.corked++};Et.prototype.uncork=function(){var e=this._writableState;e.corked&&(e.corked--,!e.writing&&!e.corked&&!e.bufferProcessing&&e.bufferedRequest&&Gv(this,e))};Et.prototype.setDefaultEncoding=function(t){if(typeof t=="string"&&(t=t.toLowerCase()),!(["hex","utf8","utf-8","ascii","binary","base64","ucs2","ucs-2","utf16le","utf-16le","raw"].indexOf((t+"").toLowerCase())>-1))throw new TypeError("Unknown encoding: "+t);return this._writableState.defaultEncoding=t,this};function rP(e,t,r){return!e.objectMode&&e.decodeStrings!==!1&&typeof t=="string"&&(t=sf.from(t,r)),t}Object.defineProperty(Et.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}});function nP(e,t,r,n,i,o){if(!r){var s=rP(t,n,i);n!==s&&(r=!0,i="buffer",n=s)}var a=t.objectMode?1:n.length;t.length+=a;var c=t.length<t.highWaterMark;if(c||(t.needDrain=!0),t.writing||t.corked){var h=t.lastBufferedRequest;t.lastBufferedRequest={chunk:n,encoding:i,isBuf:r,callback:o,next:null},h?h.next=t.lastBufferedRequest:t.bufferedRequest=t.lastBufferedRequest,t.bufferedRequestCount+=1}else Fh(e,t,!1,a,n,i,o);return c}function Fh(e,t,r,n,i,o,s){t.writelen=n,t.writecb=s,t.writing=!0,t.sync=!0,r?e._writev(i,t.onwrite):e._write(i,o,t.onwrite),t.sync=!1}function iP(e,t,r,n,i){--t.pendingcb,r?(Bi.nextTick(i,n),Bi.nextTick(Ls,e,t),e._writableState.errorEmitted=!0,e.emit("error",n)):(i(n),e._writableState.errorEmitted=!0,e.emit("error",n),Ls(e,t))}function oP(e){e.writing=!1,e.writecb=null,e.length-=e.writelen,e.writelen=0}function sP(e,t){var r=e._writableState,n=r.sync,i=r.writecb;if(oP(r),t)iP(e,r,n,t,i);else{var o=Wv(r);!o&&!r.corked&&!r.bufferProcessing&&r.bufferedRequest&&Gv(e,r),n?Y2(qv,e,r,o,i):qv(e,r,o,i)}}function qv(e,t,r,n){r||aP(e,t),t.pendingcb--,n(),Ls(e,t)}function aP(e,t){t.length===0&&t.needDrain&&(t.needDrain=!1,e.emit("drain"))}function Gv(e,t){t.bufferProcessing=!0;var r=t.bufferedRequest;if(e._writev&&r&&r.next){var n=t.bufferedRequestCount,i=new Array(n),o=t.corkedRequestsFree;o.entry=r;for(var s=0,a=!0;r;)i[s]=r,r.isBuf||(a=!1),r=r.next,s+=1;i.allBuffers=a,Fh(e,t,!0,t.length,i,"",o.finish),t.pendingcb++,t.lastBufferedRequest=null,o.next?(t.corkedRequestsFree=o.next,o.next=null):t.corkedRequestsFree=new Hv(t),t.bufferedRequestCount=0}else{for(;r;){var c=r.chunk,h=r.encoding,g=r.callback,m=t.objectMode?1:c.length;if(Fh(e,t,!1,m,c,h,g),r=r.next,t.bufferedRequestCount--,t.writing)break}r===null&&(t.lastBufferedRequest=null)}t.bufferedRequest=r,t.bufferProcessing=!1}Et.prototype._write=function(e,t,r){r(new Error("_write() is not implemented"))};Et.prototype._writev=null;Et.prototype.end=function(e,t,r){var n=this._writableState;typeof e=="function"?(r=e,e=null,t=null):typeof t=="function"&&(r=t,t=null),e!=null&&this.write(e,t),n.corked&&(n.corked=1,this.uncork()),n.ending||cP(this,n,r)};function Wv(e){return e.ending&&e.length===0&&e.bufferedRequest===null&&!e.finished&&!e.writing}function uP(e,t){e._final(function(r){t.pendingcb--,r&&e.emit("error",r),t.prefinished=!0,e.emit("prefinish"),Ls(e,t)})}function fP(e,t){!t.prefinished&&!t.finalCalled&&(typeof e._final=="function"?(t.pendingcb++,t.finalCalled=!0,Bi.nextTick(uP,e,t)):(t.prefinished=!0,e.emit("prefinish")))}function Ls(e,t){var r=Wv(t);return r&&(fP(e,t),t.pendingcb===0&&(t.finished=!0,e.emit("finish"))),r}function cP(e,t,r){t.ending=!0,Ls(e,t),r&&(t.finished?Bi.nextTick(r):e.once("finish",r)),t.ended=!0,e.writable=!1}function lP(e,t,r){var n=e.entry;for(e.entry=null;n;){var i=n.callback;t.pendingcb--,i(r),n=n.next}t.corkedRequestsFree.next=e}Object.defineProperty(Et.prototype,"destroyed",{get:function(){return this._writableState===void 0?!1:this._writableState.destroyed},set:function(e){this._writableState&&(this._writableState.destroyed=e)}});Et.prototype.destroy=Vv.destroy;Et.prototype._undestroy=Vv.undestroy;Et.prototype._destroy=function(e,t){this.end(),t(e)}});var Ni=P((gL,Xv)=>{"use strict";y();var Yv=ks(),hP=Object.keys||function(e){var t=[];for(var r in e)t.push(r);return t};Xv.exports=wn;var $v=Object.create(Mo());$v.inherits=De();var Zv=Kh(),jh=qh();$v.inherits(wn,Zv);for(Hh=hP(jh.prototype),af=0;af<Hh.length;af++)uf=Hh[af],wn.prototype[uf]||(wn.prototype[uf]=jh.prototype[uf]);var Hh,uf,af;function wn(e){if(!(this instanceof wn))return new wn(e);Zv.call(this,e),jh.call(this,e),e&&e.readable===!1&&(this.readable=!1),e&&e.writable===!1&&(this.writable=!1),this.allowHalfOpen=!0,e&&e.allowHalfOpen===!1&&(this.allowHalfOpen=!1),this.once("end",dP)}Object.defineProperty(wn.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}});function dP(){this.allowHalfOpen||this._writableState.ended||Yv.nextTick(pP,this)}function pP(e){e.end()}Object.defineProperty(wn.prototype,"destroyed",{get:function(){return this._readableState===void 0||this._writableState===void 0?!1:this._readableState.destroyed&&this._writableState.destroyed},set:function(e){this._readableState===void 0||this._writableState===void 0||(this._readableState.destroyed=e,this._writableState.destroyed=e)}});wn.prototype._destroy=function(e,t){this.push(null),this.end(),Yv.nextTick(t,e)}});var Kh=P((vL,fb)=>{"use strict";y();var Lo=ks();fb.exports=We;var gP=Mv(),Us;We.ReadableState=ib;var mL=yo().EventEmitter,tb=function(e,t){return e.listeners(t).length},Yh=Ch(),Fs=ef().Buffer,yP=(typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof self<"u"?self:{}).Uint8Array||function(){};function mP(e){return Fs.from(e)}function vP(e){return Fs.isBuffer(e)||e instanceof yP}var rb=Object.create(Mo());rb.inherits=De();var Vh=en(),Ne=void 0;Vh&&Vh.debuglog?Ne=Vh.debuglog("stream"):Ne=function(){};var bP=Uv(),nb=Uh(),Co;rb.inherits(We,Yh);var Gh=["error","close","destroy","pause","resume"];function _P(e,t,r){if(typeof e.prependListener=="function")return e.prependListener(t,r);!e._events||!e._events[t]?e.on(t,r):gP(e._events[t])?e._events[t].unshift(r):e._events[t]=[r,e._events[t]]}function ib(e,t){Us=Us||Ni(),e=e||{};var r=t instanceof Us;this.objectMode=!!e.objectMode,r&&(this.objectMode=this.objectMode||!!e.readableObjectMode);var n=e.highWaterMark,i=e.readableHighWaterMark,o=this.objectMode?16:16*1024;n||n===0?this.highWaterMark=n:r&&(i||i===0)?this.highWaterMark=i:this.highWaterMark=o,this.highWaterMark=Math.floor(this.highWaterMark),this.buffer=new bP,this.length=0,this.pipes=null,this.pipesCount=0,this.flowing=null,this.ended=!1,this.endEmitted=!1,this.reading=!1,this.sync=!0,this.needReadable=!1,this.emittedReadable=!1,this.readableListening=!1,this.resumeScheduled=!1,this.destroyed=!1,this.defaultEncoding=e.defaultEncoding||"utf8",this.awaitDrain=0,this.readingMore=!1,this.decoder=null,this.encoding=null,e.encoding&&(Co||(Co=To().StringDecoder),this.decoder=new Co(e.encoding),this.encoding=e.encoding)}function We(e){if(Us=Us||Ni(),!(this instanceof We))return new We(e);this._readableState=new ib(e,this),this.readable=!0,e&&(typeof e.read=="function"&&(this._read=e.read),typeof e.destroy=="function"&&(this._destroy=e.destroy)),Yh.call(this)}Object.defineProperty(We.prototype,"destroyed",{get:function(){return this._readableState===void 0?!1:this._readableState.destroyed},set:function(e){this._readableState&&(this._readableState.destroyed=e)}});We.prototype.destroy=nb.destroy;We.prototype._undestroy=nb.undestroy;We.prototype._destroy=function(e,t){this.push(null),t(e)};We.prototype.push=function(e,t){var r=this._readableState,n;return r.objectMode?n=!0:typeof e=="string"&&(t=t||r.defaultEncoding,t!==r.encoding&&(e=Fs.from(e,t),t=""),n=!0),ob(this,e,t,!1,n)};We.prototype.unshift=function(e){return ob(this,e,null,!0,!1)};function ob(e,t,r,n,i){var o=e._readableState;if(t===null)o.reading=!1,xP(e,o);else{var s;i||(s=wP(o,t)),s?e.emit("error",s):o.objectMode||t&&t.length>0?(typeof t!="string"&&!o.objectMode&&Object.getPrototypeOf(t)!==Fs.prototype&&(t=mP(t)),n?o.endEmitted?e.emit("error",new Error("stream.unshift() after end event")):Wh(e,o,t,!0):o.ended?e.emit("error",new Error("stream.push() after EOF")):(o.reading=!1,o.decoder&&!r?(t=o.decoder.write(t),o.objectMode||t.length!==0?Wh(e,o,t,!1):sb(e,o)):Wh(e,o,t,!1))):n||(o.reading=!1)}return SP(o)}function Wh(e,t,r,n){t.flowing&&t.length===0&&!t.sync?(e.emit("data",r),e.read(0)):(t.length+=t.objectMode?1:r.length,n?t.buffer.unshift(r):t.buffer.push(r),t.needReadable&&ff(e)),sb(e,t)}function wP(e,t){var r;return!vP(t)&&typeof t!="string"&&t!==void 0&&!e.objectMode&&(r=new TypeError("Invalid non-string/buffer chunk")),r}function SP(e){return!e.ended&&(e.needReadable||e.length<e.highWaterMark||e.length===0)}We.prototype.isPaused=function(){return this._readableState.flowing===!1};We.prototype.setEncoding=function(e){return Co||(Co=To().StringDecoder),this._readableState.decoder=new Co(e),this._readableState.encoding=e,this};var Jv=8388608;function EP(e){return e>=Jv?e=Jv:(e--,e|=e>>>1,e|=e>>>2,e|=e>>>4,e|=e>>>8,e|=e>>>16,e++),e}function Qv(e,t){return e<=0||t.length===0&&t.ended?0:t.objectMode?1:e!==e?t.flowing&&t.length?t.buffer.head.data.length:t.length:(e>t.highWaterMark&&(t.highWaterMark=EP(e)),e<=t.length?e:t.ended?t.length:(t.needReadable=!0,0))}We.prototype.read=function(e){Ne("read",e),e=parseInt(e,10);var t=this._readableState,r=e;if(e!==0&&(t.emittedReadable=!1),e===0&&t.needReadable&&(t.length>=t.highWaterMark||t.ended))return Ne("read: emitReadable",t.length,t.ended),t.length===0&&t.ended?zh(this):ff(this),null;if(e=Qv(e,t),e===0&&t.ended)return t.length===0&&zh(this),null;var n=t.needReadable;Ne("need readable",n),(t.length===0||t.length-e<t.highWaterMark)&&(n=!0,Ne("length less than watermark",n)),t.ended||t.reading?(n=!1,Ne("reading or ended",n)):n&&(Ne("do read"),t.reading=!0,t.sync=!0,t.length===0&&(t.needReadable=!0),this._read(t.highWaterMark),t.sync=!1,t.reading||(e=Qv(r,t)));var i;return e>0?i=ab(e,t):i=null,i===null?(t.needReadable=!0,e=0):t.length-=e,t.length===0&&(t.ended||(t.needReadable=!0),r!==e&&t.ended&&zh(this)),i!==null&&this.emit("data",i),i};function xP(e,t){if(!t.ended){if(t.decoder){var r=t.decoder.end();r&&r.length&&(t.buffer.push(r),t.length+=t.objectMode?1:r.length)}t.ended=!0,ff(e)}}function ff(e){var t=e._readableState;t.needReadable=!1,t.emittedReadable||(Ne("emitReadable",t.flowing),t.emittedReadable=!0,t.sync?Lo.nextTick(eb,e):eb(e))}function eb(e){Ne("emit readable"),e.emit("readable"),$h(e)}function sb(e,t){t.readingMore||(t.readingMore=!0,Lo.nextTick(IP,e,t))}function IP(e,t){for(var r=t.length;!t.reading&&!t.flowing&&!t.ended&&t.length<t.highWaterMark&&(Ne("maybeReadMore read 0"),e.read(0),r!==t.length);)r=t.length;t.readingMore=!1}We.prototype._read=function(e){this.emit("error",new Error("_read() is not implemented"))};We.prototype.pipe=function(e,t){var r=this,n=this._readableState;switch(n.pipesCount){case 0:n.pipes=e;break;case 1:n.pipes=[n.pipes,e];break;default:n.pipes.push(e);break}n.pipesCount+=1,Ne("pipe count=%d opts=%j",n.pipesCount,t);var i=(!t||t.end!==!1)&&e!==x.default.stdout&&e!==x.default.stderr,o=i?a:L;n.endEmitted?Lo.nextTick(o):r.once("end",o),e.on("unpipe",s);function s(q,G){Ne("onunpipe"),q===r&&G&&G.hasUnpiped===!1&&(G.hasUnpiped=!0,g())}function a(){Ne("onend"),e.end()}var c=AP(r);e.on("drain",c);var h=!1;function g(){Ne("cleanup"),e.removeListener("close",R),e.removeListener("finish",N),e.removeListener("drain",c),e.removeListener("error",I),e.removeListener("unpipe",s),r.removeListener("end",a),r.removeListener("end",L),r.removeListener("data",_),h=!0,n.awaitDrain&&(!e._writableState||e._writableState.needDrain)&&c()}var m=!1;r.on("data",_);function _(q){Ne("ondata"),m=!1;var G=e.write(q);G===!1&&!m&&((n.pipesCount===1&&n.pipes===e||n.pipesCount>1&&ub(n.pipes,e)!==-1)&&!h&&(Ne("false write response, pause",n.awaitDrain),n.awaitDrain++,m=!0),r.pause())}function I(q){Ne("onerror",q),L(),e.removeListener("error",I),tb(e,"error")===0&&e.emit("error",q)}_P(e,"error",I);function R(){e.removeListener("finish",N),L()}e.once("close",R);function N(){Ne("onfinish"),e.removeListener("close",R),L()}e.once("finish",N);function L(){Ne("unpipe"),r.unpipe(e)}return e.emit("pipe",r),n.flowing||(Ne("pipe resume"),r.resume()),e};function AP(e){return function(){var t=e._readableState;Ne("pipeOnDrain",t.awaitDrain),t.awaitDrain&&t.awaitDrain--,t.awaitDrain===0&&tb(e,"data")&&(t.flowing=!0,$h(e))}}We.prototype.unpipe=function(e){var t=this._readableState,r={hasUnpiped:!1};if(t.pipesCount===0)return this;if(t.pipesCount===1)return e&&e!==t.pipes?this:(e||(e=t.pipes),t.pipes=null,t.pipesCount=0,t.flowing=!1,e&&e.emit("unpipe",this,r),this);if(!e){var n=t.pipes,i=t.pipesCount;t.pipes=null,t.pipesCount=0,t.flowing=!1;for(var o=0;o<i;o++)n[o].emit("unpipe",this,{hasUnpiped:!1});return this}var s=ub(t.pipes,e);return s===-1?this:(t.pipes.splice(s,1),t.pipesCount-=1,t.pipesCount===1&&(t.pipes=t.pipes[0]),e.emit("unpipe",this,r),this)};We.prototype.on=function(e,t){var r=Yh.prototype.on.call(this,e,t);if(e==="data")this._readableState.flowing!==!1&&this.resume();else if(e==="readable"){var n=this._readableState;!n.endEmitted&&!n.readableListening&&(n.readableListening=n.needReadable=!0,n.emittedReadable=!1,n.reading?n.length&&ff(this):Lo.nextTick(OP,this))}return r};We.prototype.addListener=We.prototype.on;function OP(e){Ne("readable nexttick read 0"),e.read(0)}We.prototype.resume=function(){var e=this._readableState;return e.flowing||(Ne("resume"),e.flowing=!0,RP(this,e)),this};function RP(e,t){t.resumeScheduled||(t.resumeScheduled=!0,Lo.nextTick(TP,e,t))}function TP(e,t){t.reading||(Ne("resume read 0"),e.read(0)),t.resumeScheduled=!1,t.awaitDrain=0,e.emit("resume"),$h(e),t.flowing&&!t.reading&&e.read(0)}We.prototype.pause=function(){return Ne("call pause flowing=%j",this._readableState.flowing),this._readableState.flowing!==!1&&(Ne("pause"),this._readableState.flowing=!1,this.emit("pause")),this};function $h(e){var t=e._readableState;for(Ne("flow",t.flowing);t.flowing&&e.read()!==null;);}We.prototype.wrap=function(e){var t=this,r=this._readableState,n=!1;e.on("end",function(){if(Ne("wrapped end"),r.decoder&&!r.ended){var s=r.decoder.end();s&&s.length&&t.push(s)}t.push(null)}),e.on("data",function(s){if(Ne("wrapped data"),r.decoder&&(s=r.decoder.write(s)),!(r.objectMode&&s==null)&&!(!r.objectMode&&(!s||!s.length))){var a=t.push(s);a||(n=!0,e.pause())}});for(var i in e)this[i]===void 0&&typeof e[i]=="function"&&(this[i]=(function(s){return function(){return e[s].apply(e,arguments)}})(i));for(var o=0;o<Gh.length;o++)e.on(Gh[o],this.emit.bind(this,Gh[o]));return this._read=function(s){Ne("wrapped _read",s),n&&(n=!1,e.resume())},this};Object.defineProperty(We.prototype,"readableHighWaterMark",{enumerable:!1,get:function(){return this._readableState.highWaterMark}});We._fromList=ab;function ab(e,t){if(t.length===0)return null;var r;return t.objectMode?r=t.buffer.shift():!e||e>=t.length?(t.decoder?r=t.buffer.join(""):t.buffer.length===1?r=t.buffer.head.data:r=t.buffer.concat(t.length),t.buffer.clear()):r=PP(e,t.buffer,t.decoder),r}function PP(e,t,r){var n;return e<t.head.data.length?(n=t.head.data.slice(0,e),t.head.data=t.head.data.slice(e)):e===t.head.data.length?n=t.shift():n=r?BP(e,t):NP(e,t),n}function BP(e,t){var r=t.head,n=1,i=r.data;for(e-=i.length;r=r.next;){var o=r.data,s=e>o.length?o.length:e;if(s===o.length?i+=o:i+=o.slice(0,e),e-=s,e===0){s===o.length?(++n,r.next?t.head=r.next:t.head=t.tail=null):(t.head=r,r.data=o.slice(s));break}++n}return t.length-=n,i}function NP(e,t){var r=Fs.allocUnsafe(e),n=t.head,i=1;for(n.data.copy(r),e-=n.data.length;n=n.next;){var o=n.data,s=e>o.length?o.length:e;if(o.copy(r,r.length-e,0,s),e-=s,e===0){s===o.length?(++i,n.next?t.head=n.next:t.head=t.tail=null):(t.head=n,n.data=o.slice(s));break}++i}return t.length-=i,r}function zh(e){var t=e._readableState;if(t.length>0)throw new Error('"endReadable()" called on non-empty stream');t.endEmitted||(t.ended=!0,Lo.nextTick(MP,t,e))}function MP(e,t){!e.endEmitted&&e.length===0&&(e.endEmitted=!0,t.readable=!1,t.emit("end"))}function ub(e,t){for(var r=0,n=e.length;r<n;r++)if(e[r]===t)return r;return-1}});var Zh=P((_L,hb)=>{"use strict";y();hb.exports=Sn;var cf=Ni(),lb=Object.create(Mo());lb.inherits=De();lb.inherits(Sn,cf);function kP(e,t){var r=this._transformState;r.transforming=!1;var n=r.writecb;if(!n)return this.emit("error",new Error("write callback called multiple times"));r.writechunk=null,r.writecb=null,t!=null&&this.push(t),n(e);var i=this._readableState;i.reading=!1,(i.needReadable||i.length<i.highWaterMark)&&this._read(i.highWaterMark)}function Sn(e){if(!(this instanceof Sn))return new Sn(e);cf.call(this,e),this._transformState={afterTransform:kP.bind(this),needTransform:!1,transforming:!1,writecb:null,writechunk:null,writeencoding:null},this._readableState.needReadable=!0,this._readableState.sync=!1,e&&(typeof e.transform=="function"&&(this._transform=e.transform),typeof e.flush=="function"&&(this._flush=e.flush)),this.on("prefinish",CP)}function CP(){var e=this;typeof this._flush=="function"?this._flush(function(t,r){cb(e,t,r)}):cb(this,null,null)}Sn.prototype.push=function(e,t){return this._transformState.needTransform=!1,cf.prototype.push.call(this,e,t)};Sn.prototype._transform=function(e,t,r){throw new Error("_transform() is not implemented")};Sn.prototype._write=function(e,t,r){var n=this._transformState;if(n.writecb=r,n.writechunk=e,n.writeencoding=t,!n.transforming){var i=this._readableState;(n.needTransform||i.needReadable||i.length<i.highWaterMark)&&this._read(i.highWaterMark)}};Sn.prototype._read=function(e){var t=this._transformState;t.writechunk!==null&&t.writecb&&!t.transforming?(t.transforming=!0,this._transform(t.writechunk,t.writeencoding,t.afterTransform)):t.needTransform=!0};Sn.prototype._destroy=function(e,t){var r=this;cf.prototype._destroy.call(this,e,function(n){t(n),r.emit("close")})};function cb(e,t,r){if(t)return e.emit("error",t);if(r!=null&&e.push(r),e._writableState.length)throw new Error("Calling transform done when ws.length != 0");if(e._transformState.transforming)throw new Error("Calling transform done when still transforming");return e.push(null)}});var yb=P((SL,gb)=>{"use strict";y();gb.exports=qs;var db=Zh(),pb=Object.create(Mo());pb.inherits=De();pb.inherits(qs,db);function qs(e){if(!(this instanceof qs))return new qs(e);db.call(this,e)}qs.prototype._transform=function(e,t,r){r(null,e)}});var vb=P((nn,mb)=>{y();nn=mb.exports=Kh();nn.Stream=nn;nn.Readable=nn;nn.Writable=qh();nn.Duplex=Ni();nn.Transform=Zh();nn.PassThrough=yb()});var wb=P((IL,_b)=>{"use strict";y();var LP=qt().Buffer,DP=Bv(),bb=vb().Transform,UP=De();function Xn(e){bb.call(this),this._block=LP.allocUnsafe(e),this._blockSize=e,this._blockOffset=0,this._length=[0,0,0,0],this._finalized=!1}UP(Xn,bb);Xn.prototype._transform=function(e,t,r){var n=null;try{this.update(e,t)}catch(i){n=i}r(n)};Xn.prototype._flush=function(e){var t=null;try{this.push(this.digest())}catch(r){t=r}e(t)};Xn.prototype.update=function(e,t){if(this._finalized)throw new Error("Digest already called");for(var r=DP(e,t),n=this._block,i=0;this._blockOffset+r.length-i>=this._blockSize;){for(var o=this._blockOffset;o<this._blockSize;)n[o]=r[i],o+=1,i+=1;this._update(),this._blockOffset=0}for(;i<r.length;)n[this._blockOffset]=r[i],this._blockOffset+=1,i+=1;for(var s=0,a=r.length*8;a>0;++s)this._length[s]+=a,a=this._length[s]/4294967296|0,a>0&&(this._length[s]-=4294967296*a);return this};Xn.prototype._update=function(){throw new Error("_update is not implemented")};Xn.prototype.digest=function(e){if(this._finalized)throw new Error("Digest already called");this._finalized=!0;var t=this._digest();e!==void 0&&(t=t.toString(e)),this._block.fill(0),this._blockOffset=0;for(var r=0;r<4;++r)this._length[r]=0;return t};Xn.prototype._digest=function(){throw new Error("_digest is not implemented")};_b.exports=Xn});var Jh=P((OL,Rb)=>{"use strict";y();var Xh=Tt().Buffer,FP=De(),Ob=wb(),qP=new Array(16),Hs=[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,7,4,13,1,10,6,15,3,12,0,9,5,2,14,11,8,3,10,14,4,9,15,8,1,2,7,0,6,13,11,5,12,1,9,11,10,0,8,12,4,13,3,7,15,14,5,6,2,4,0,5,9,7,12,2,10,14,1,3,8,11,6,15,13],js=[5,14,7,0,9,2,11,4,13,6,15,8,1,10,3,12,6,11,3,7,0,13,5,10,14,15,8,12,4,9,1,2,15,5,1,3,7,14,6,9,11,8,12,2,10,0,4,13,8,6,4,1,3,11,15,0,5,12,2,13,9,7,10,14,12,15,10,4,1,5,8,7,6,2,13,14,0,3,9,11],Ks=[11,14,15,12,5,8,7,9,11,13,14,15,6,7,9,8,7,6,8,13,11,9,7,15,7,12,15,9,11,7,13,12,11,13,6,7,14,9,13,15,14,8,13,6,5,12,7,5,11,12,14,15,14,15,9,8,9,14,5,6,8,6,5,12,9,15,5,11,6,8,13,12,5,12,13,14,11,8,5,6],Vs=[8,9,9,11,13,15,15,5,7,7,8,11,14,14,12,6,9,13,15,7,12,8,9,11,7,7,12,7,6,15,13,11,9,7,15,11,8,6,6,14,12,13,5,14,13,13,7,5,15,5,8,11,14,14,6,14,6,9,12,9,12,5,15,8,8,5,12,9,12,5,14,6,8,13,6,5,15,13,11,11],Gs=[0,1518500249,1859775393,2400959708,2840853838],Ws=[1352829926,1548603684,1836072691,2053994217,0];function Mi(e,t){return e<<t|e>>>32-t}function Sb(e,t,r,n,i,o,s,a){return Mi(e+(t^r^n)+o+s|0,a)+i|0}function Eb(e,t,r,n,i,o,s,a){return Mi(e+(t&r|~t&n)+o+s|0,a)+i|0}function xb(e,t,r,n,i,o,s,a){return Mi(e+((t|~r)^n)+o+s|0,a)+i|0}function Ib(e,t,r,n,i,o,s,a){return Mi(e+(t&n|r&~n)+o+s|0,a)+i|0}function Ab(e,t,r,n,i,o,s,a){return Mi(e+(t^(r|~n))+o+s|0,a)+i|0}function lf(){Ob.call(this,64),this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878,this._e=3285377520}FP(lf,Ob);lf.prototype._update=function(){for(var e=qP,t=0;t<16;++t)e[t]=this._block.readInt32LE(t*4);for(var r=this._a|0,n=this._b|0,i=this._c|0,o=this._d|0,s=this._e|0,a=this._a|0,c=this._b|0,h=this._c|0,g=this._d|0,m=this._e|0,_=0;_<80;_+=1){var I,R;_<16?(I=Sb(r,n,i,o,s,e[Hs[_]],Gs[0],Ks[_]),R=Ab(a,c,h,g,m,e[js[_]],Ws[0],Vs[_])):_<32?(I=Eb(r,n,i,o,s,e[Hs[_]],Gs[1],Ks[_]),R=Ib(a,c,h,g,m,e[js[_]],Ws[1],Vs[_])):_<48?(I=xb(r,n,i,o,s,e[Hs[_]],Gs[2],Ks[_]),R=xb(a,c,h,g,m,e[js[_]],Ws[2],Vs[_])):_<64?(I=Ib(r,n,i,o,s,e[Hs[_]],Gs[3],Ks[_]),R=Eb(a,c,h,g,m,e[js[_]],Ws[3],Vs[_])):(I=Ab(r,n,i,o,s,e[Hs[_]],Gs[4],Ks[_]),R=Sb(a,c,h,g,m,e[js[_]],Ws[4],Vs[_])),r=s,s=o,o=Mi(i,10),i=n,n=I,a=m,m=g,g=Mi(h,10),h=c,c=R}var N=this._b+i+g|0;this._b=this._c+o+m|0,this._c=this._d+s+a|0,this._d=this._e+r+c|0,this._e=this._a+n+h|0,this._a=N};lf.prototype._digest=function(){this._block[this._blockOffset]=128,this._blockOffset+=1,this._blockOffset>56&&(this._block.fill(0,this._blockOffset,64),this._update(),this._blockOffset=0),this._block.fill(0,this._blockOffset,56),this._block.writeUInt32LE(this._length[0],56),this._block.writeUInt32LE(this._length[1],60),this._update();var e=Xh.alloc?Xh.alloc(20):new Xh(20);return e.writeInt32LE(this._a,0),e.writeInt32LE(this._b,4),e.writeInt32LE(this._c,8),e.writeInt32LE(this._d,12),e.writeInt32LE(this._e,16),e};Rb.exports=lf});var ki=P((TL,Tb)=>{"use strict";y();var HP=qt().Buffer,jP=Ju();function hf(e,t){this._block=HP.alloc(e),this._finalSize=t,this._blockSize=e,this._len=0}hf.prototype.update=function(e,t){e=jP(e,t||"utf8");for(var r=this._block,n=this._blockSize,i=e.length,o=this._len,s=0;s<i;){for(var a=o%n,c=Math.min(i-s,n-a),h=0;h<c;h++)r[a+h]=e[s+h];o+=c,s+=c,o%n===0&&this._update(r)}return this._len+=i,this};hf.prototype.digest=function(e){var t=this._len%this._blockSize;this._block[t]=128,this._block.fill(0,t+1),t>=this._finalSize&&(this._update(this._block),this._block.fill(0));var r=this._len*8;if(r<=4294967295)this._block.writeUInt32BE(r,this._blockSize-4);else{var n=(r&4294967295)>>>0,i=(r-n)/4294967296;this._block.writeUInt32BE(i,this._blockSize-8),this._block.writeUInt32BE(n,this._blockSize-4)}this._update(this._block);var o=this._hash();return e?o.toString(e):o};hf.prototype._update=function(){throw new Error("_update must be implemented by subclass")};Tb.exports=hf});var Nb=P((BL,Bb)=>{"use strict";y();var KP=De(),Pb=ki(),VP=qt().Buffer,GP=[1518500249,1859775393,-1894007588,-899497514],WP=new Array(80);function zs(){this.init(),this._w=WP,Pb.call(this,64,56)}KP(zs,Pb);zs.prototype.init=function(){return this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878,this._e=3285377520,this};function zP(e){return e<<5|e>>>27}function YP(e){return e<<30|e>>>2}function $P(e,t,r,n){return e===0?t&r|~t&n:e===2?t&r|t&n|r&n:t^r^n}zs.prototype._update=function(e){for(var t=this._w,r=this._a|0,n=this._b|0,i=this._c|0,o=this._d|0,s=this._e|0,a=0;a<16;++a)t[a]=e.readInt32BE(a*4);for(;a<80;++a)t[a]=t[a-3]^t[a-8]^t[a-14]^t[a-16];for(var c=0;c<80;++c){var h=~~(c/20),g=zP(r)+$P(h,n,i,o)+s+t[c]+GP[h]|0;s=o,o=i,i=YP(n),n=r,r=g}this._a=r+this._a|0,this._b=n+this._b|0,this._c=i+this._c|0,this._d=o+this._d|0,this._e=s+this._e|0};zs.prototype._hash=function(){var e=VP.allocUnsafe(20);return e.writeInt32BE(this._a|0,0),e.writeInt32BE(this._b|0,4),e.writeInt32BE(this._c|0,8),e.writeInt32BE(this._d|0,12),e.writeInt32BE(this._e|0,16),e};Bb.exports=zs});var Cb=P((ML,kb)=>{"use strict";y();var ZP=De(),Mb=ki(),XP=qt().Buffer,JP=[1518500249,1859775393,-1894007588,-899497514],QP=new Array(80);function Ys(){this.init(),this._w=QP,Mb.call(this,64,56)}ZP(Ys,Mb);Ys.prototype.init=function(){return this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878,this._e=3285377520,this};function eB(e){return e<<1|e>>>31}function tB(e){return e<<5|e>>>27}function rB(e){return e<<30|e>>>2}function nB(e,t,r,n){return e===0?t&r|~t&n:e===2?t&r|t&n|r&n:t^r^n}Ys.prototype._update=function(e){for(var t=this._w,r=this._a|0,n=this._b|0,i=this._c|0,o=this._d|0,s=this._e|0,a=0;a<16;++a)t[a]=e.readInt32BE(a*4);for(;a<80;++a)t[a]=eB(t[a-3]^t[a-8]^t[a-14]^t[a-16]);for(var c=0;c<80;++c){var h=~~(c/20),g=tB(r)+nB(h,n,i,o)+s+t[c]+JP[h]|0;s=o,o=i,i=rB(n),n=r,r=g}this._a=r+this._a|0,this._b=n+this._b|0,this._c=i+this._c|0,this._d=o+this._d|0,this._e=s+this._e|0};Ys.prototype._hash=function(){var e=XP.allocUnsafe(20);return e.writeInt32BE(this._a|0,0),e.writeInt32BE(this._b|0,4),e.writeInt32BE(this._c|0,8),e.writeInt32BE(this._d|0,12),e.writeInt32BE(this._e|0,16),e};kb.exports=Ys});var Qh=P((CL,Db)=>{"use strict";y();var iB=De(),Lb=ki(),oB=qt().Buffer,sB=[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],aB=new Array(64);function $s(){this.init(),this._w=aB,Lb.call(this,64,56)}iB($s,Lb);$s.prototype.init=function(){return this._a=1779033703,this._b=3144134277,this._c=1013904242,this._d=2773480762,this._e=1359893119,this._f=2600822924,this._g=528734635,this._h=1541459225,this};function uB(e,t,r){return r^e&(t^r)}function fB(e,t,r){return e&t|r&(e|t)}function cB(e){return(e>>>2|e<<30)^(e>>>13|e<<19)^(e>>>22|e<<10)}function lB(e){return(e>>>6|e<<26)^(e>>>11|e<<21)^(e>>>25|e<<7)}function hB(e){return(e>>>7|e<<25)^(e>>>18|e<<14)^e>>>3}function dB(e){return(e>>>17|e<<15)^(e>>>19|e<<13)^e>>>10}$s.prototype._update=function(e){for(var t=this._w,r=this._a|0,n=this._b|0,i=this._c|0,o=this._d|0,s=this._e|0,a=this._f|0,c=this._g|0,h=this._h|0,g=0;g<16;++g)t[g]=e.readInt32BE(g*4);for(;g<64;++g)t[g]=dB(t[g-2])+t[g-7]+hB(t[g-15])+t[g-16]|0;for(var m=0;m<64;++m){var _=h+lB(s)+uB(s,a,c)+sB[m]+t[m]|0,I=cB(r)+fB(r,n,i)|0;h=c,c=a,a=s,s=o+_|0,o=i,i=n,n=r,r=_+I|0}this._a=r+this._a|0,this._b=n+this._b|0,this._c=i+this._c|0,this._d=o+this._d|0,this._e=s+this._e|0,this._f=a+this._f|0,this._g=c+this._g|0,this._h=h+this._h|0};$s.prototype._hash=function(){var e=oB.allocUnsafe(32);return e.writeInt32BE(this._a,0),e.writeInt32BE(this._b,4),e.writeInt32BE(this._c,8),e.writeInt32BE(this._d,12),e.writeInt32BE(this._e,16),e.writeInt32BE(this._f,20),e.writeInt32BE(this._g,24),e.writeInt32BE(this._h,28),e};Db.exports=$s});var Fb=P((DL,Ub)=>{"use strict";y();var pB=De(),gB=Qh(),yB=ki(),mB=qt().Buffer,vB=new Array(64);function df(){this.init(),this._w=vB,yB.call(this,64,56)}pB(df,gB);df.prototype.init=function(){return this._a=3238371032,this._b=914150663,this._c=812702999,this._d=4144912697,this._e=4290775857,this._f=1750603025,this._g=1694076839,this._h=3204075428,this};df.prototype._hash=function(){var e=mB.allocUnsafe(28);return e.writeInt32BE(this._a,0),e.writeInt32BE(this._b,4),e.writeInt32BE(this._c,8),e.writeInt32BE(this._d,12),e.writeInt32BE(this._e,16),e.writeInt32BE(this._f,20),e.writeInt32BE(this._g,24),e};Ub.exports=df});var ed=P((FL,Wb)=>{"use strict";y();var bB=De(),Gb=ki(),_B=qt().Buffer,qb=[1116352408,3609767458,1899447441,602891725,3049323471,3964484399,3921009573,2173295548,961987163,4081628472,1508970993,3053834265,2453635748,2937671579,2870763221,3664609560,3624381080,2734883394,310598401,1164996542,607225278,1323610764,1426881987,3590304994,1925078388,4068182383,2162078206,991336113,2614888103,633803317,3248222580,3479774868,3835390401,2666613458,4022224774,944711139,264347078,2341262773,604807628,2007800933,770255983,1495990901,1249150122,1856431235,1555081692,3175218132,1996064986,2198950837,2554220882,3999719339,2821834349,766784016,2952996808,2566594879,3210313671,3203337956,3336571891,1034457026,3584528711,2466948901,113926993,3758326383,338241895,168717936,666307205,1188179964,773529912,1546045734,1294757372,1522805485,1396182291,2643833823,1695183700,2343527390,1986661051,1014477480,2177026350,1206759142,2456956037,344077627,2730485921,1290863460,2820302411,3158454273,3259730800,3505952657,3345764771,106217008,3516065817,3606008344,3600352804,1432725776,4094571909,1467031594,275423344,851169720,430227734,3100823752,506948616,1363258195,659060556,3750685593,883997877,3785050280,958139571,3318307427,1322822218,3812723403,1537002063,2003034995,1747873779,3602036899,1955562222,1575990012,2024104815,1125592928,2227730452,2716904306,2361852424,442776044,2428436474,593698344,2756734187,3733110249,3204031479,2999351573,3329325298,3815920427,3391569614,3928383900,3515267271,566280711,3940187606,3454069534,4118630271,4000239992,116418474,1914138554,174292421,2731055270,289380356,3203993006,460393269,320620315,685471733,587496836,852142971,1086792851,1017036298,365543100,1126000580,2618297676,1288033470,3409855158,1501505948,4234509866,1607167915,987167468,1816402316,1246189591],wB=new Array(160);function Zs(){this.init(),this._w=wB,Gb.call(this,128,112)}bB(Zs,Gb);Zs.prototype.init=function(){return this._ah=1779033703,this._bh=3144134277,this._ch=1013904242,this._dh=2773480762,this._eh=1359893119,this._fh=2600822924,this._gh=528734635,this._hh=1541459225,this._al=4089235720,this._bl=2227873595,this._cl=4271175723,this._dl=1595750129,this._el=2917565137,this._fl=725511199,this._gl=4215389547,this._hl=327033209,this};function Hb(e,t,r){return r^e&(t^r)}function jb(e,t,r){return e&t|r&(e|t)}function Kb(e,t){return(e>>>28|t<<4)^(t>>>2|e<<30)^(t>>>7|e<<25)}function Vb(e,t){return(e>>>14|t<<18)^(e>>>18|t<<14)^(t>>>9|e<<23)}function SB(e,t){return(e>>>1|t<<31)^(e>>>8|t<<24)^e>>>7}function EB(e,t){return(e>>>1|t<<31)^(e>>>8|t<<24)^(e>>>7|t<<25)}function xB(e,t){return(e>>>19|t<<13)^(t>>>29|e<<3)^e>>>6}function IB(e,t){return(e>>>19|t<<13)^(t>>>29|e<<3)^(e>>>6|t<<26)}function Ct(e,t){return e>>>0<t>>>0?1:0}Zs.prototype._update=function(e){for(var t=this._w,r=this._ah|0,n=this._bh|0,i=this._ch|0,o=this._dh|0,s=this._eh|0,a=this._fh|0,c=this._gh|0,h=this._hh|0,g=this._al|0,m=this._bl|0,_=this._cl|0,I=this._dl|0,R=this._el|0,N=this._fl|0,L=this._gl|0,q=this._hl|0,G=0;G<32;G+=2)t[G]=e.readInt32BE(G*4),t[G+1]=e.readInt32BE(G*4+4);for(;G<160;G+=2){var K=t[G-30],z=t[G-30+1],X=SB(K,z),oe=EB(z,K);K=t[G-4],z=t[G-4+1];var ue=xB(K,z),se=IB(z,K),de=t[G-14],A=t[G-14+1],u=t[G-32],l=t[G-32+1],p=oe+A|0,v=X+de+Ct(p,oe)|0;p=p+se|0,v=v+ue+Ct(p,se)|0,p=p+l|0,v=v+u+Ct(p,l)|0,t[G]=v,t[G+1]=p}for(var b=0;b<160;b+=2){v=t[b],p=t[b+1];var E=jb(r,n,i),O=jb(g,m,_),w=Kb(r,g),f=Kb(g,r),S=Vb(s,R),j=Vb(R,s),F=qb[b],Y=qb[b+1],$=Hb(s,a,c),J=Hb(R,N,L),ae=q+j|0,ye=h+S+Ct(ae,q)|0;ae=ae+J|0,ye=ye+$+Ct(ae,J)|0,ae=ae+Y|0,ye=ye+F+Ct(ae,Y)|0,ae=ae+p|0,ye=ye+v+Ct(ae,p)|0;var he=f+O|0,T=w+E+Ct(he,f)|0;h=c,q=L,c=a,L=N,a=s,N=R,R=I+ae|0,s=o+ye+Ct(R,I)|0,o=i,I=_,i=n,_=m,n=r,m=g,g=ae+he|0,r=ye+T+Ct(g,ae)|0}this._al=this._al+g|0,this._bl=this._bl+m|0,this._cl=this._cl+_|0,this._dl=this._dl+I|0,this._el=this._el+R|0,this._fl=this._fl+N|0,this._gl=this._gl+L|0,this._hl=this._hl+q|0,this._ah=this._ah+r+Ct(this._al,g)|0,this._bh=this._bh+n+Ct(this._bl,m)|0,this._ch=this._ch+i+Ct(this._cl,_)|0,this._dh=this._dh+o+Ct(this._dl,I)|0,this._eh=this._eh+s+Ct(this._el,R)|0,this._fh=this._fh+a+Ct(this._fl,N)|0,this._gh=this._gh+c+Ct(this._gl,L)|0,this._hh=this._hh+h+Ct(this._hl,q)|0};Zs.prototype._hash=function(){var e=_B.allocUnsafe(64);function t(r,n,i){e.writeInt32BE(r,i),e.writeInt32BE(n,i+4)}return t(this._ah,this._al,0),t(this._bh,this._bl,8),t(this._ch,this._cl,16),t(this._dh,this._dl,24),t(this._eh,this._el,32),t(this._fh,this._fl,40),t(this._gh,this._gl,48),t(this._hh,this._hl,56),e};Wb.exports=Zs});var Yb=P((HL,zb)=>{"use strict";y();var AB=De(),OB=ed(),RB=ki(),TB=qt().Buffer,PB=new Array(160);function pf(){this.init(),this._w=PB,RB.call(this,128,112)}AB(pf,OB);pf.prototype.init=function(){return this._ah=3418070365,this._bh=1654270250,this._ch=2438529370,this._dh=355462360,this._eh=1731405415,this._fh=2394180231,this._gh=3675008525,this._hh=1203062813,this._al=3238371032,this._bl=914150663,this._cl=812702999,this._dl=4144912697,this._el=4290775857,this._fl=1750603025,this._gl=1694076839,this._hl=3204075428,this};pf.prototype._hash=function(){var e=TB.allocUnsafe(48);function t(r,n,i){e.writeInt32BE(r,i),e.writeInt32BE(n,i+4)}return t(this._ah,this._al,0),t(this._bh,this._bl,8),t(this._ch,this._cl,16),t(this._dh,this._dl,24),t(this._eh,this._el,32),t(this._fh,this._fl,40),e};zb.exports=pf});var td=P((KL,En)=>{"use strict";y();En.exports=function(t){var r=t.toLowerCase(),n=En.exports[r];if(!n)throw new Error(r+" is not supported (we accept pull requests)");return new n};En.exports.sha=Nb();En.exports.sha1=Cb();En.exports.sha224=Fb();En.exports.sha256=Qh();En.exports.sha384=Yb();En.exports.sha512=ed()});var gf=P((GL,Zb)=>{"use strict";y();var BB=qt().Buffer,$b=Nh().Transform,NB=To().StringDecoder,MB=De(),kB=Ju();function kr(e){$b.call(this),this.hashMode=typeof e=="string",this.hashMode?this[e]=this._finalOrDigest:this.final=this._finalOrDigest,this._final&&(this.__final=this._final,this._final=null),this._decoder=null,this._encoding=null}MB(kr,$b);kr.prototype.update=function(e,t,r){var n=kB(e,t),i=this._update(n);return this.hashMode?this:(r&&(i=this._toString(i,r)),i)};kr.prototype.setAutoPadding=function(){};kr.prototype.getAuthTag=function(){throw new Error("trying to get auth tag in unsupported state")};kr.prototype.setAuthTag=function(){throw new Error("trying to set auth tag in unsupported state")};kr.prototype.setAAD=function(){throw new Error("trying to set aad in unsupported state")};kr.prototype._transform=function(e,t,r){var n;try{this.hashMode?this._update(e):this.push(this._update(e))}catch(i){n=i}finally{r(n)}};kr.prototype._flush=function(e){var t;try{this.push(this.__final())}catch(r){t=r}e(t)};kr.prototype._finalOrDigest=function(e){var t=this.__final()||BB.alloc(0);return e&&(t=this._toString(t,e,!0)),t};kr.prototype._toString=function(e,t,r){if(this._decoder||(this._decoder=new NB(t),this._encoding=t),this._encoding!==t)throw new Error("can\u2019t switch encodings");var n=this._decoder.write(e);return r&&(n+=this._decoder.end()),n};Zb.exports=kr});var Qb=P((zL,Jb)=>{"use strict";y();var CB=De(),LB=Mh(),DB=Jh(),UB=td(),Xb=gf();function yf(e){Xb.call(this,"digest"),this._hash=e}CB(yf,Xb);yf.prototype._update=function(e){this._hash.update(e)};yf.prototype._final=function(){return this._hash.digest()};Jb.exports=function(t){return t=t.toLowerCase(),t==="md5"?new LB:t==="rmd160"||t==="ripemd160"?new DB:new yf(UB(t))}});var r_=P(($L,t_)=>{"use strict";y();var FB=De(),Ci=qt().Buffer,e_=gf(),qB=Ci.alloc(128),Do=64;function mf(e,t){e_.call(this,"digest"),typeof t=="string"&&(t=Ci.from(t)),this._alg=e,this._key=t,t.length>Do?t=e(t):t.length<Do&&(t=Ci.concat([t,qB],Do));for(var r=this._ipad=Ci.allocUnsafe(Do),n=this._opad=Ci.allocUnsafe(Do),i=0;i<Do;i++)r[i]=t[i]^54,n[i]=t[i]^92;this._hash=[r]}FB(mf,e_);mf.prototype._update=function(e){this._hash.push(e)};mf.prototype._final=function(){var e=this._alg(Ci.concat(this._hash));return this._alg(Ci.concat([this._opad,e]))};t_.exports=mf});var i_=P((XL,n_)=>{y();var HB=Mh();n_.exports=function(e){return new HB().update(e).digest()}});var a_=P((QL,s_)=>{"use strict";y();var jB=De(),KB=r_(),o_=gf(),Xs=qt().Buffer,VB=i_(),rd=Jh(),nd=td(),GB=Xs.alloc(128);function Js(e,t){o_.call(this,"digest"),typeof t=="string"&&(t=Xs.from(t));var r=e==="sha512"||e==="sha384"?128:64;if(this._alg=e,this._key=t,t.length>r){var n=e==="rmd160"?new rd:nd(e);t=n.update(t).digest()}else t.length<r&&(t=Xs.concat([t,GB],r));for(var i=this._ipad=Xs.allocUnsafe(r),o=this._opad=Xs.allocUnsafe(r),s=0;s<r;s++)i[s]=t[s]^54,o[s]=t[s]^92;this._hash=e==="rmd160"?new rd:nd(e),this._hash.update(i)}jB(Js,o_);Js.prototype._update=function(e){this._hash.update(e)};Js.prototype._final=function(){var e=this._hash.digest(),t=this._alg==="rmd160"?new rd:nd(this._alg);return t.update(this._opad).update(e).digest()};s_.exports=function(t,r){return t=t.toLowerCase(),t==="rmd160"||t==="ripemd160"?new Js("rmd160",r):t==="md5"?new KB(VB,r):new Js(t,r)}});var u_=P((tD,od)=>{"use strict";y();var id=65536,WB=4294967295;function zB(){throw new Error(`Secure random number generation is not supported by this browser.
|
|
11
|
+
Use Chrome, Firefox or Internet Explorer 11`)}var YB=qt().Buffer,vf=globalThis.crypto||globalThis.msCrypto;vf&&vf.getRandomValues?od.exports=$B:od.exports=zB;function $B(e,t){if(e>WB)throw new RangeError("requested too many random bytes");var r=YB.allocUnsafe(e);if(e>0)if(e>id)for(var n=0;n<e;n+=id)vf.getRandomValues(r.slice(n,n+id));else vf.getRandomValues(r);return typeof t=="function"?x.default.nextTick(function(){t(null,r)}):r}});var Qs=P(bf=>{"use strict";y();bf.createHash=Qb();bf.createHmac=a_();bf.randomBytes=u_()});var ea=P((oD,c_)=>{"use strict";y();var f_=65536;function Li(){}Li.getRandomBuffer=function(e){var t=typeof globalThis<"u"?globalThis.crypto:void 0;if(t&&typeof t.getRandomValues=="function")return Li._fromGetRandomValues(t,e);try{var r=Qs();if(r&&typeof r.randomBytes=="function")return r.randomBytes(e)}catch{}throw new Error("bsv: no CSPRNG available in this environment (needs globalThis.crypto.getRandomValues or node crypto)")};Li._fromGetRandomValues=function(e,t){for(var r=d.Buffer.alloc(t),n=0;n<t;n+=f_){var i=new Uint8Array(Math.min(f_,t-n));e.getRandomValues(i),d.Buffer.from(i).copy(r,n)}return r};Li.getRandomBufferNode=function(e){var t=Qs();return t.randomBytes(e)};Li.getRandomBufferBrowser=function(e){var t=typeof globalThis<"u"?globalThis:{},r=null;if(t.crypto&&typeof t.crypto.getRandomValues=="function"?r=t.crypto:t.msCrypto&&typeof t.msCrypto.getRandomValues=="function"&&(r=t.msCrypto),!r)throw new Error("window.crypto.getRandomValues not available");return Li._fromGetRandomValues(r,e)};c_.exports=Li});var Ve=P((aD,l_)=>{"use strict";y();var ZB=ea(),Ke={};Ke.isArray=e=>Array.isArray(e);Ke.isNumber=e=>typeof e=="number";Ke.isObject=e=>e&&typeof e=="object";Ke.isString=e=>typeof e=="string";Ke.isUndefined=e=>typeof e>"u";Ke.isFunction=e=>typeof e=="function";Ke.isNull=e=>e===null;Ke.isDate=e=>e instanceof Date;Ke.extend=(e,t)=>Object.assign(e,t);Ke.noop=()=>{};Ke.every=(e,t)=>e.every(t||(r=>r));Ke.map=(e,t)=>Array.from(e).map(t||(r=>r));Ke.includes=(e,t)=>e.includes(t);Ke.each=(e,t)=>e.forEach(t);Ke.clone=e=>Object.assign({},e);Ke.pick=(e,t)=>{let r={};return t.forEach(n=>{typeof e[n]<"u"&&(r[n]=e[n])}),r};Ke.values=e=>Object.values(e);Ke.filter=(e,t)=>e.filter(t);Ke.reduce=(e,t,r)=>e.reduce(t,r);Ke.without=(e,t)=>e.filter(r=>r!==t);Ke.shuffle=e=>{let t=e.slice(0);for(let r=t.length-1;r>0;r--){let i=ZB.getRandomBuffer(4).readUInt32BE(0)/4294967296,o=Math.floor(i*(r+1));[t[r],t[o]]=[t[o],t[r]]}return t};Ke.difference=(e,t)=>e.filter(r=>!t.includes(r));Ke.findIndex=(e,t)=>e.findIndex(t);Ke.some=(e,t)=>e.some(t);Ke.range=e=>[...Array(e).keys()];l_.exports=Ke});var d_=P((fD,h_)=>{"use strict";y();var XB="https://docs.moneybutton.com/";h_.exports=[{name:"InvalidB58Char",message:"Invalid Base58 character: {0} in {1}"},{name:"InvalidB58Checksum",message:"Invalid Base58 checksum for {0}"},{name:"InvalidNetwork",message:"Invalid version for network: got {0}"},{name:"InvalidState",message:"Invalid state: {0}"},{name:"NotImplemented",message:"Function {0} was not implemented yet"},{name:"InvalidNetworkArgument",message:'Invalid network: must be "livenet" or "testnet", got {0}'},{name:"InvalidArgument",message:function(){return"Invalid Argument"+(arguments[0]?": "+arguments[0]:"")+(arguments[1]?" Documentation: "+XB+arguments[1]:"")}},{name:"AbstractMethodInvoked",message:"Abstract Method Invocation: {0}"},{name:"InvalidArgumentType",message:function(){return"Invalid Argument for "+arguments[2]+", expected "+arguments[1]+" but got "+typeof arguments[0]}},{name:"Unit",message:"Internal Error on Unit {0}",errors:[{name:"UnknownCode",message:"Unrecognized unit code: {0}"},{name:"InvalidRate",message:"Invalid exchange rate: {0}"}]},{name:"MerkleBlock",message:"Internal Error on MerkleBlock {0}",errors:[{name:"InvalidMerkleTree",message:"This MerkleBlock contain an invalid Merkle Tree"}]},{name:"Transaction",message:"Internal Error on Transaction {0}",errors:[{name:"Input",message:"Internal Error on Input {0}",errors:[{name:"MissingScript",message:"Need a script to create an input"},{name:"UnsupportedScript",message:"Unsupported input script type: {0}"},{name:"MissingPreviousOutput",message:"No previous output information."}]},{name:"NeedMoreInfo",message:"{0}"},{name:"InvalidSorting",message:"The sorting function provided did not return the change output as one of the array elements"},{name:"InvalidOutputAmountSum",message:"{0}"},{name:"MissingSignatures",message:"Some inputs have not been fully signed"},{name:"InvalidIndex",message:"Invalid index: {0} is not between 0, {1}"},{name:"UnableToVerifySignature",message:"Unable to verify signature: {0}"},{name:"DustOutputs",message:"Dust amount detected in one output"},{name:"InvalidSatoshis",message:"Output satoshis are invalid"},{name:"FeeError",message:"Internal Error on Fee {0}",errors:[{name:"TooSmall",message:"Fee is too small: {0}"},{name:"TooLarge",message:"Fee is too large: {0}"},{name:"Different",message:"Unspent value is different from specified fee: {0}"}]},{name:"ChangeAddressMissing",message:"Change address is missing"},{name:"BlockHeightTooHigh",message:"Block Height can be at most 2^32 -1"},{name:"NLockTimeOutOfRange",message:"Block Height can only be between 0 and 499 999 999"},{name:"LockTimeTooEarly",message:"Lock Time can't be earlier than UNIX date 500 000 000"}]},{name:"Script",message:"Internal Error on Script {0}",errors:[{name:"UnrecognizedAddress",message:"Expected argument {0} to be an address"},{name:"CantDeriveAddress",message:"Can't derive address associated with script {0}, needs to be p2pkh in, p2pkh out, p2sh in, or p2sh out."},{name:"InvalidBuffer",message:"Invalid script buffer: can't parse valid script from given buffer {0}"}]},{name:"HDPrivateKey",message:"Internal Error on HDPrivateKey {0}",errors:[{name:"InvalidDerivationArgument",message:"Invalid derivation argument {0}, expected string, or number and boolean"},{name:"InvalidEntropyArgument",message:"Invalid entropy: must be an hexa string or binary buffer, got {0}",errors:[{name:"TooMuchEntropy",message:'Invalid entropy: more than 512 bits is non standard, got "{0}"'},{name:"NotEnoughEntropy",message:'Invalid entropy: at least 128 bits needed, got "{0}"'}]},{name:"InvalidLength",message:"Invalid length for xprivkey string in {0}"},{name:"InvalidPath",message:"Invalid derivation path: {0}"},{name:"UnrecognizedArgument",message:'Invalid argument: creating a HDPrivateKey requires a string, buffer, json or object, got "{0}"'}]},{name:"HDPublicKey",message:"Internal Error on HDPublicKey {0}",errors:[{name:"ArgumentIsPrivateExtended",message:"Argument is an extended private key: {0}"},{name:"InvalidDerivationArgument",message:"Invalid derivation argument: got {0}"},{name:"InvalidLength",message:'Invalid length for xpubkey: got "{0}"'},{name:"InvalidPath",message:'Invalid derivation path, it should look like: "m/1/100", got "{0}"'},{name:"InvalidIndexCantDeriveHardened",message:"Invalid argument: creating a hardened path requires an HDPrivateKey"},{name:"MustSupplyArgument",message:"Must supply an argument to create a HDPublicKey"},{name:"UnrecognizedArgument",message:"Invalid argument for creation, must be string, json, buffer, or object"}]}]});var Jn=P((lD,ad)=>{"use strict";y();var sd=Ve();function JB(e,t){return e.replace("{0}",t[0]).replace("{1}",t[1]).replace("{2}",t[2])}var p_=function(e,t){var r=function(){if(sd.isString(t.message))this.message=JB(t.message,arguments);else if(sd.isFunction(t.message))this.message=t.message.apply(null,arguments);else throw new Error("Invalid error definition for "+t.name);this.stack=this.message+`
|
|
12
|
+
`+new Error().stack};return r.prototype=Object.create(e.prototype),r.prototype.name=e.prototype.name+t.name,e[t.name]=r,t.errors&&g_(r,t.errors),r},g_=function(e,t){sd.each(t,function(r){p_(e,r)})},QB=function(e,t){return g_(e,t),e},Uo={};Uo.Error=function(){this.message="Internal error",this.stack=this.message+`
|
|
13
|
+
`+new Error().stack};Uo.Error.prototype=Object.create(Error.prototype);Uo.Error.prototype.name="bsv.Error";var eN=d_();QB(Uo.Error,eN);ad.exports=Uo.Error;ad.exports.extend=function(e){return p_(Uo.Error,e)}});var ke=P((dD,y_)=>{"use strict";y();var ta=Jn(),tN=Ve();y_.exports={checkState:function(e,t){if(!e)throw new ta.InvalidState(t)},checkArgument:function(e,t,r,n){if(!e)throw new ta.InvalidArgument(t,r,n)},checkArgumentType:function(e,t,r){if(r=r||"(unknown name)",tN.isString(t)){if(t==="Buffer"){var n=Tt();if(!n.Buffer.isBuffer(e))throw new ta.InvalidArgumentType(e,t,r)}else if(typeof e!==t)throw new ta.InvalidArgumentType(e,t,r)}else if(!(e instanceof t))throw new ta.InvalidArgumentType(e,t.name,r)}}});var Er=P((gD,v_)=>{"use strict";y();var Be=O0(),ud=ke(),m_=Ve(),_f=function(e){for(var t=d.Buffer.alloc(e.length),r=0;r<e.length;r++)t[r]=e[e.length-1-r];return t};Be.Zero=new Be(0);Be.One=new Be(1);Be.Minus1=new Be(-1);Be.fromNumber=function(e){return ud.checkArgument(m_.isNumber(e)),new Be(e)};Be.fromString=function(e,t){return ud.checkArgument(m_.isString(e)),new Be(e,t)};Be.fromBuffer=function(e,t){typeof t<"u"&&t.endian==="little"&&(e=_f(e));var r=e.toString("hex"),n=new Be(r,16);return n};Be.fromSM=function(e,t){var r;if(e.length===0)return Be.fromBuffer(d.Buffer.from([0]));var n="big";return t&&(n=t.endian),n==="little"&&(e=_f(e)),e[0]&128?(e[0]=e[0]&127,r=Be.fromBuffer(e),r.neg().copy(r)):r=Be.fromBuffer(e),r};Be.prototype.toNumber=function(){return parseInt(this.toString(10),10)};Be.prototype.toBuffer=function(e){var t,r;if(e&&e.size){r=this.toString(16,2);var n=r.length/2;t=d.Buffer.from(r,"hex"),n===e.size||(n>e.size?t=Be.trim(t,n):n<e.size&&(t=Be.pad(t,n,e.size)))}else r=this.toString(16,2),t=d.Buffer.from(r,"hex");return typeof e<"u"&&e.endian==="little"&&(t=_f(t)),t};Be.prototype.toSMBigEndian=function(){var e;return this.cmp(Be.Zero)===-1?(e=this.neg().toBuffer(),e[0]&128?e=d.Buffer.concat([d.Buffer.from([128]),e]):e[0]=e[0]|128):(e=this.toBuffer(),e[0]&128&&(e=d.Buffer.concat([d.Buffer.from([0]),e]))),e.length===1&&e[0]===0&&(e=d.Buffer.from([])),e};Be.prototype.toSM=function(e){var t=e?e.endian:"big",r=this.toSMBigEndian();return t==="little"&&(r=_f(r)),r};Be.fromScriptNumBuffer=function(e,t,r){var n=r||4;if(ud.checkArgument(e.length<=n,new Error("script number overflow")),t&&e.length>0&&(e[e.length-1]&127)===0&&(e.length<=1||(e[e.length-2]&128)===0))throw new Error("non-minimally encoded script number");return Be.fromSM(e,{endian:"little"})};Be.prototype.toScriptNumBuffer=function(){return this.toSM({endian:"little"})};Be.trim=function(e,t){return e.slice(t-e.length,e.length)};Be.pad=function(e,t,r){for(var n=d.Buffer.alloc(r),i=0;i<e.length;i++)n[n.length-1-i]=e[e.length-1-i];for(i=0;i<r-t;i++)n[i]=0;return n};Be.prototype.toHex=function(...e){return this.toBuffer(...e).toString("hex")};Be.fromHex=function(e,...t){return Be.fromBuffer(d.Buffer.from(e,"hex"),...t)};v_.exports=Be});function fd(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name==="Uint8Array"&&"BYTES_PER_ELEMENT"in e&&e.BYTES_PER_ELEMENT===1}function Qn(e,t=""){if(typeof e!="number"){let r=t&&`"${t}" `;throw new TypeError(`${r}expected number, got ${typeof e}`)}if(!Number.isSafeInteger(e)||e<0){let r=t&&`"${t}" `;throw new RangeError(`${r}expected integer >= 0, got ${e}`)}}function on(e,t,r=""){let n=fd(e),i=e?.length,o=t!==void 0;if(!n||o&&i!==t){let s=r&&`"${r}" `,a=o?` of length ${t}`:"",c=n?`length=${i}`:`type=${typeof e}`,h=s+"expected Uint8Array"+a+", got "+c;throw n?new RangeError(h):new TypeError(h)}return e}function wf(e){if(typeof e!="function"||typeof e.create!="function")throw new TypeError("Hash must wrapped by utils.createHasher");if(Qn(e.outputLen),Qn(e.blockLen),e.outputLen<1)throw new Error('"outputLen" must be >= 1');if(e.blockLen<1)throw new Error('"blockLen" must be >= 1')}function Fo(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 Sf(e,t){on(e,void 0,"digestInto() output");let r=t.outputLen;if(e.length<r)throw new RangeError('"digestInto() output" expected to be of length >='+r)}function Zt(...e){for(let t=0;t<e.length;t++)e[t].fill(0)}function Ef(e){return new DataView(e.buffer,e.byteOffset,e.byteLength)}function Cr(e,t){return e<<32-t|e>>>t}function In(e,t){return e<<t|e>>>32-t>>>0}function xf(e){if(on(e),__)return e.toHex();let t="";for(let r=0;r<e.length;r++)t+=rN[e[r]];return t}function b_(e){if(e>=xn._0&&e<=xn._9)return e-xn._0;if(e>=xn.A&&e<=xn.F)return e-(xn.A-10);if(e>=xn.a&&e<=xn.f)return e-(xn.a-10)}function cd(e){if(typeof e!="string")throw new TypeError("hex string expected, got "+typeof e);if(__)try{return Uint8Array.fromHex(e)}catch(i){throw i instanceof SyntaxError?new RangeError(i.message):i}let t=e.length,r=t/2;if(t%2)throw new RangeError("hex string expected, got unpadded hex of length "+t);let n=new Uint8Array(r);for(let i=0,o=0;i<r;i++,o+=2){let s=b_(e.charCodeAt(o)),a=b_(e.charCodeAt(o+1));if(s===void 0||a===void 0){let c=e[o]+e[o+1];throw new RangeError('hex string expected, got non-hex character "'+c+'" at index '+o)}n[i]=s*16+a}return n}function An(e){if(typeof e!="string")throw new TypeError("string expected");return new Uint8Array(new TextEncoder().encode(e))}function w_(...e){let t=0;for(let n=0;n<e.length;n++){let i=e[n];on(i),t+=i.length}let r=new Uint8Array(t);for(let n=0,i=0;n<e.length;n++){let o=e[n];r.set(o,i),i+=o.length}return r}function Lr(e,t={}){let r=(i,o)=>e(o).update(i).digest(),n=e(void 0);return r.outputLen=n.outputLen,r.blockLen=n.blockLen,r.canXOF=n.canXOF,r.create=i=>e(i),Object.assign(r,t),Object.freeze(r)}function ra(e=32){Qn(e,"bytesLength");let t=typeof globalThis=="object"?globalThis.crypto:null;if(typeof t?.getRandomValues!="function")throw new Error("crypto.getRandomValues must be defined");if(e>65536)throw new RangeError(`"bytesLength" expected <= 65536, got ${e}`);return t.getRandomValues(new Uint8Array(e))}var __,rN,xn,Di,On=er(()=>{y();__=typeof Uint8Array.from([]).toHex=="function"&&typeof Uint8Array.fromHex=="function",rN=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,"0"));xn={_0:48,_9:57,A:65,F:70,a:97,f:102};Di=e=>({oid:Uint8Array.from([6,9,96,134,72,1,101,3,4,2,e])})});function qo(e,t,r){return e&t^~e&r}function If(e,t,r){return e&t^e&r^t&r}var Rn,Tn,Pn,Ht,jt,ld=er(()=>{y();On();Rn=class{constructor(t,r,n,i){C(this,"blockLen");C(this,"outputLen");C(this,"canXOF",!1);C(this,"padOffset");C(this,"isLE");C(this,"buffer");C(this,"view");C(this,"finished",!1);C(this,"length",0);C(this,"pos",0);C(this,"destroyed",!1);this.blockLen=t,this.outputLen=r,this.padOffset=n,this.isLE=i,this.buffer=new Uint8Array(t),this.view=Ef(this.buffer)}update(t){Fo(this),on(t);let{view:r,buffer:n,blockLen:i}=this,o=t.length;for(let s=0;s<o;){let a=Math.min(i-this.pos,o-s);if(a===i){let c=Ef(t);for(;i<=o-s;s+=i)this.process(c,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){Fo(this),Sf(t,this),this.finished=!0;let{buffer:r,view:n,blockLen:i,isLE:o}=this,{pos:s}=this;r[s++]=128,Zt(this.buffer.subarray(s)),this.padOffset>i-s&&(this.process(n,0),s=0);for(let m=s;m<i;m++)r[m]=0;n.setBigUint64(i-8,BigInt(this.length*8),o),this.process(n,0);let a=Ef(t),c=this.outputLen;if(c%4)throw new Error("_sha2: outputLen must be aligned to 32bit");let h=c/4,g=this.get();if(h>g.length)throw new Error("_sha2: outputLen bigger than state");for(let m=0;m<h;m++)a.setUint32(4*m,g[m],o)}digest(){let{buffer:t,outputLen:r}=this;this.digestInto(t);let n=t.slice(0,r);return this.destroy(),n}_cloneInto(t){t||(t=new this.constructor),t.set(...this.get());let{blockLen:r,buffer:n,length:i,finished:o,destroyed:s,pos:a}=this;return t.destroyed=s,t.finished=o,t.length=i,t.pos=a,i%r&&t.buffer.set(n),t}clone(){return this._cloneInto()}},Tn=Uint32Array.from([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),Pn=Uint32Array.from([3238371032,914150663,812702999,4144912697,4290775857,1750603025,1694076839,3204075428]),Ht=Uint32Array.from([3418070365,3238371032,1654270250,914150663,2438529370,812702999,355462360,4144912697,1731405415,4290775857,2394180231,1750603025,3675008525,1694076839,1203062813,3204075428]),jt=Uint32Array.from([1779033703,4089235720,3144134277,2227873595,1013904242,4271175723,2773480762,1595750129,1359893119,2917565137,2600822924,725511199,528734635,4215389547,1541459225,327033209])});function nN(e,t=!1){return t?{h:Number(e&Af),l:Number(e>>S_&Af)}:{h:Number(e>>S_&Af)|0,l:Number(e&Af)|0}}function E_(e,t=!1){let r=e.length,n=new Uint32Array(r),i=new Uint32Array(r);for(let o=0;o<r;o++){let{h:s,l:a}=nN(e[o],t);[n[o],i[o]]=[s,a]}return[n,i]}function sn(e,t,r,n){let i=(t>>>0)+(n>>>0);return{h:e+r+(i/2**32|0)|0,l:i|0}}var Af,S_,hd,dd,Ui,Fi,na,ia,x_,I_,A_,O_,R_,T_,P_=er(()=>{y();Af=BigInt(4294967295),S_=BigInt(32);hd=(e,t,r)=>e>>>r,dd=(e,t,r)=>e<<32-r|t>>>r,Ui=(e,t,r)=>e>>>r|t<<32-r,Fi=(e,t,r)=>e<<32-r|t>>>r,na=(e,t,r)=>e<<64-r|t>>>r-32,ia=(e,t,r)=>e>>>r-32|t<<64-r;x_=(e,t,r)=>(e>>>0)+(t>>>0)+(r>>>0),I_=(e,t,r,n)=>t+r+n+(e/2**32|0)|0,A_=(e,t,r,n)=>(e>>>0)+(t>>>0)+(r>>>0)+(n>>>0),O_=(e,t,r,n,i)=>t+r+n+i+(e/2**32|0)|0,R_=(e,t,r,n,i)=>(e>>>0)+(t>>>0)+(r>>>0)+(n>>>0)+(i>>>0),T_=(e,t,r,n,i,o)=>t+r+n+i+o+(e/2**32|0)|0});var N_={};al(N_,{_SHA224:()=>Tf,_SHA256:()=>Rf,_SHA384:()=>Bf,_SHA512:()=>Pf,_SHA512_224:()=>Nf,_SHA512_256:()=>Mf,sha224:()=>uN,sha256:()=>ni,sha384:()=>cN,sha512:()=>fN,sha512_224:()=>hN,sha512_256:()=>lN});var oN,ei,Of,Rf,Tf,B_,sN,aN,ti,ri,Ho,Pf,Bf,Xt,Jt,Nf,Mf,ni,uN,fN,cN,lN,hN,pd=er(()=>{y();ld();P_();On();oN=Uint32Array.from([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),ei=new Uint32Array(64),Of=class extends Rn{constructor(t){super(64,t,8,!1)}get(){let{A:t,B:r,C:n,D:i,E:o,F:s,G:a,H:c}=this;return[t,r,n,i,o,s,a,c]}set(t,r,n,i,o,s,a,c){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=c|0}process(t,r){for(let m=0;m<16;m++,r+=4)ei[m]=t.getUint32(r,!1);for(let m=16;m<64;m++){let _=ei[m-15],I=ei[m-2],R=Cr(_,7)^Cr(_,18)^_>>>3,N=Cr(I,17)^Cr(I,19)^I>>>10;ei[m]=N+ei[m-7]+R+ei[m-16]|0}let{A:n,B:i,C:o,D:s,E:a,F:c,G:h,H:g}=this;for(let m=0;m<64;m++){let _=Cr(a,6)^Cr(a,11)^Cr(a,25),I=g+_+qo(a,c,h)+oN[m]+ei[m]|0,N=(Cr(n,2)^Cr(n,13)^Cr(n,22))+If(n,i,o)|0;g=h,h=c,c=a,a=s+I|0,s=o,o=i,i=n,n=I+N|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,c=c+this.F|0,h=h+this.G|0,g=g+this.H|0,this.set(n,i,o,s,a,c,h,g)}roundClean(){Zt(ei)}destroy(){this.destroyed=!0,this.set(0,0,0,0,0,0,0,0),Zt(this.buffer)}},Rf=class extends Of{constructor(){super(32);C(this,"A",Tn[0]|0);C(this,"B",Tn[1]|0);C(this,"C",Tn[2]|0);C(this,"D",Tn[3]|0);C(this,"E",Tn[4]|0);C(this,"F",Tn[5]|0);C(this,"G",Tn[6]|0);C(this,"H",Tn[7]|0)}},Tf=class extends Of{constructor(){super(28);C(this,"A",Pn[0]|0);C(this,"B",Pn[1]|0);C(this,"C",Pn[2]|0);C(this,"D",Pn[3]|0);C(this,"E",Pn[4]|0);C(this,"F",Pn[5]|0);C(this,"G",Pn[6]|0);C(this,"H",Pn[7]|0)}},B_=E_(["0x428a2f98d728ae22","0x7137449123ef65cd","0xb5c0fbcfec4d3b2f","0xe9b5dba58189dbbc","0x3956c25bf348b538","0x59f111f1b605d019","0x923f82a4af194f9b","0xab1c5ed5da6d8118","0xd807aa98a3030242","0x12835b0145706fbe","0x243185be4ee4b28c","0x550c7dc3d5ffb4e2","0x72be5d74f27b896f","0x80deb1fe3b1696b1","0x9bdc06a725c71235","0xc19bf174cf692694","0xe49b69c19ef14ad2","0xefbe4786384f25e3","0x0fc19dc68b8cd5b5","0x240ca1cc77ac9c65","0x2de92c6f592b0275","0x4a7484aa6ea6e483","0x5cb0a9dcbd41fbd4","0x76f988da831153b5","0x983e5152ee66dfab","0xa831c66d2db43210","0xb00327c898fb213f","0xbf597fc7beef0ee4","0xc6e00bf33da88fc2","0xd5a79147930aa725","0x06ca6351e003826f","0x142929670a0e6e70","0x27b70a8546d22ffc","0x2e1b21385c26c926","0x4d2c6dfc5ac42aed","0x53380d139d95b3df","0x650a73548baf63de","0x766a0abb3c77b2a8","0x81c2c92e47edaee6","0x92722c851482353b","0xa2bfe8a14cf10364","0xa81a664bbc423001","0xc24b8b70d0f89791","0xc76c51a30654be30","0xd192e819d6ef5218","0xd69906245565a910","0xf40e35855771202a","0x106aa07032bbd1b8","0x19a4c116b8d2d0c8","0x1e376c085141ab53","0x2748774cdf8eeb99","0x34b0bcb5e19b48a8","0x391c0cb3c5c95a63","0x4ed8aa4ae3418acb","0x5b9cca4f7763e373","0x682e6ff3d6b2b8a3","0x748f82ee5defb2fc","0x78a5636f43172f60","0x84c87814a1f0ab72","0x8cc702081a6439ec","0x90befffa23631e28","0xa4506cebde82bde9","0xbef9a3f7b2c67915","0xc67178f2e372532b","0xca273eceea26619c","0xd186b8c721c0c207","0xeada7dd6cde0eb1e","0xf57d4f7fee6ed178","0x06f067aa72176fba","0x0a637dc5a2c898a6","0x113f9804bef90dae","0x1b710b35131c471b","0x28db77f523047d84","0x32caab7b40c72493","0x3c9ebe0a15c9bebc","0x431d67c49c100d4c","0x4cc5d4becb3e42b6","0x597f299cfc657e2a","0x5fcb6fab3ad6faec","0x6c44198c4a475817"].map(e=>BigInt(e))),sN=B_[0],aN=B_[1],ti=new Uint32Array(80),ri=new Uint32Array(80),Ho=class extends Rn{constructor(t){super(128,t,16,!1)}get(){let{Ah:t,Al:r,Bh:n,Bl:i,Ch:o,Cl:s,Dh:a,Dl:c,Eh:h,El:g,Fh:m,Fl:_,Gh:I,Gl:R,Hh:N,Hl:L}=this;return[t,r,n,i,o,s,a,c,h,g,m,_,I,R,N,L]}set(t,r,n,i,o,s,a,c,h,g,m,_,I,R,N,L){this.Ah=t|0,this.Al=r|0,this.Bh=n|0,this.Bl=i|0,this.Ch=o|0,this.Cl=s|0,this.Dh=a|0,this.Dl=c|0,this.Eh=h|0,this.El=g|0,this.Fh=m|0,this.Fl=_|0,this.Gh=I|0,this.Gl=R|0,this.Hh=N|0,this.Hl=L|0}process(t,r){for(let K=0;K<16;K++,r+=4)ti[K]=t.getUint32(r),ri[K]=t.getUint32(r+=4);for(let K=16;K<80;K++){let z=ti[K-15]|0,X=ri[K-15]|0,oe=Ui(z,X,1)^Ui(z,X,8)^hd(z,X,7),ue=Fi(z,X,1)^Fi(z,X,8)^dd(z,X,7),se=ti[K-2]|0,de=ri[K-2]|0,A=Ui(se,de,19)^na(se,de,61)^hd(se,de,6),u=Fi(se,de,19)^ia(se,de,61)^dd(se,de,6),l=A_(ue,u,ri[K-7],ri[K-16]),p=O_(l,oe,A,ti[K-7],ti[K-16]);ti[K]=p|0,ri[K]=l|0}let{Ah:n,Al:i,Bh:o,Bl:s,Ch:a,Cl:c,Dh:h,Dl:g,Eh:m,El:_,Fh:I,Fl:R,Gh:N,Gl:L,Hh:q,Hl:G}=this;for(let K=0;K<80;K++){let z=Ui(m,_,14)^Ui(m,_,18)^na(m,_,41),X=Fi(m,_,14)^Fi(m,_,18)^ia(m,_,41),oe=m&I^~m&N,ue=_&R^~_&L,se=R_(G,X,ue,aN[K],ri[K]),de=T_(se,q,z,oe,sN[K],ti[K]),A=se|0,u=Ui(n,i,28)^na(n,i,34)^na(n,i,39),l=Fi(n,i,28)^ia(n,i,34)^ia(n,i,39),p=n&o^n&a^o&a,v=i&s^i&c^s&c;q=N|0,G=L|0,N=I|0,L=R|0,I=m|0,R=_|0,{h:m,l:_}=sn(h|0,g|0,de|0,A|0),h=a|0,g=c|0,a=o|0,c=s|0,o=n|0,s=i|0;let b=x_(A,l,v);n=I_(b,de,u,p),i=b|0}({h:n,l:i}=sn(this.Ah|0,this.Al|0,n|0,i|0)),{h:o,l:s}=sn(this.Bh|0,this.Bl|0,o|0,s|0),{h:a,l:c}=sn(this.Ch|0,this.Cl|0,a|0,c|0),{h,l:g}=sn(this.Dh|0,this.Dl|0,h|0,g|0),{h:m,l:_}=sn(this.Eh|0,this.El|0,m|0,_|0),{h:I,l:R}=sn(this.Fh|0,this.Fl|0,I|0,R|0),{h:N,l:L}=sn(this.Gh|0,this.Gl|0,N|0,L|0),{h:q,l:G}=sn(this.Hh|0,this.Hl|0,q|0,G|0),this.set(n,i,o,s,a,c,h,g,m,_,I,R,N,L,q,G)}roundClean(){Zt(ti,ri)}destroy(){this.destroyed=!0,Zt(this.buffer),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}},Pf=class extends Ho{constructor(){super(64);C(this,"Ah",jt[0]|0);C(this,"Al",jt[1]|0);C(this,"Bh",jt[2]|0);C(this,"Bl",jt[3]|0);C(this,"Ch",jt[4]|0);C(this,"Cl",jt[5]|0);C(this,"Dh",jt[6]|0);C(this,"Dl",jt[7]|0);C(this,"Eh",jt[8]|0);C(this,"El",jt[9]|0);C(this,"Fh",jt[10]|0);C(this,"Fl",jt[11]|0);C(this,"Gh",jt[12]|0);C(this,"Gl",jt[13]|0);C(this,"Hh",jt[14]|0);C(this,"Hl",jt[15]|0)}},Bf=class extends Ho{constructor(){super(48);C(this,"Ah",Ht[0]|0);C(this,"Al",Ht[1]|0);C(this,"Bh",Ht[2]|0);C(this,"Bl",Ht[3]|0);C(this,"Ch",Ht[4]|0);C(this,"Cl",Ht[5]|0);C(this,"Dh",Ht[6]|0);C(this,"Dl",Ht[7]|0);C(this,"Eh",Ht[8]|0);C(this,"El",Ht[9]|0);C(this,"Fh",Ht[10]|0);C(this,"Fl",Ht[11]|0);C(this,"Gh",Ht[12]|0);C(this,"Gl",Ht[13]|0);C(this,"Hh",Ht[14]|0);C(this,"Hl",Ht[15]|0)}},Xt=Uint32Array.from([2352822216,424955298,1944164710,2312950998,502970286,855612546,1738396948,1479516111,258812777,2077511080,2011393907,79989058,1067287976,1780299464,286451373,2446758561]),Jt=Uint32Array.from([573645204,4230739756,2673172387,3360449730,596883563,1867755857,2520282905,1497426621,2519219938,2827943907,3193839141,1401305490,721525244,746961066,246885852,2177182882]),Nf=class extends Ho{constructor(){super(28);C(this,"Ah",Xt[0]|0);C(this,"Al",Xt[1]|0);C(this,"Bh",Xt[2]|0);C(this,"Bl",Xt[3]|0);C(this,"Ch",Xt[4]|0);C(this,"Cl",Xt[5]|0);C(this,"Dh",Xt[6]|0);C(this,"Dl",Xt[7]|0);C(this,"Eh",Xt[8]|0);C(this,"El",Xt[9]|0);C(this,"Fh",Xt[10]|0);C(this,"Fl",Xt[11]|0);C(this,"Gh",Xt[12]|0);C(this,"Gl",Xt[13]|0);C(this,"Hh",Xt[14]|0);C(this,"Hl",Xt[15]|0)}},Mf=class extends Ho{constructor(){super(32);C(this,"Ah",Jt[0]|0);C(this,"Al",Jt[1]|0);C(this,"Bh",Jt[2]|0);C(this,"Bl",Jt[3]|0);C(this,"Ch",Jt[4]|0);C(this,"Cl",Jt[5]|0);C(this,"Dh",Jt[6]|0);C(this,"Dl",Jt[7]|0);C(this,"Eh",Jt[8]|0);C(this,"El",Jt[9]|0);C(this,"Fh",Jt[10]|0);C(this,"Fl",Jt[11]|0);C(this,"Gh",Jt[12]|0);C(this,"Gl",Jt[13]|0);C(this,"Hh",Jt[14]|0);C(this,"Hl",Jt[15]|0)}},ni=Lr(()=>new Rf,Di(1)),uN=Lr(()=>new Tf,Di(4)),fN=Lr(()=>new Pf,Di(3)),cN=Lr(()=>new Bf,Di(2)),lN=Lr(()=>new Mf,Di(6)),hN=Lr(()=>new Nf,Di(5))});function Hi(e,t=""){if(typeof e!="boolean"){let r=t&&`"${t}" `;throw new TypeError(r+"expected boolean, got type="+typeof e)}return e}function Lf(e){if(typeof e=="bigint"){if(!kf(e))throw new RangeError("positive bigint expected, got "+e)}else yd(e);return e}function xr(e,t=""){if(typeof e!="number"){let r=t&&`"${t}" `;throw new TypeError(r+"expected number, got type="+typeof e)}if(!Number.isSafeInteger(e)){let r=t&&`"${t}" `;throw new RangeError(r+"expected safe integer, got "+e)}}function oa(e){let t=Lf(e).toString(16);return t.length&1?"0"+t:t}function M_(e){if(typeof e!="string")throw new TypeError("hex string expected, got "+typeof e);return e===""?Cf:BigInt("0x"+e)}function tr(e){return M_(xf(e))}function Ko(e){return M_(xf(Uf(on(e)).reverse()))}function Df(e,t){if(Qn(t),t===0)throw new RangeError("zero length");e=Lf(e);let r=e.toString(16);if(r.length>t*2)throw new RangeError("number too large");return cd(r.padStart(t*2,"0"))}function md(e,t){return Df(e,t).reverse()}function Uf(e){return Uint8Array.from(Le(e))}function Vo(e){if(typeof e!="string")throw new TypeError("ascii string expected, got "+typeof e);return Uint8Array.from(e,(t,r)=>{let n=t.charCodeAt(0);if(t.length!==1||n>127)throw new RangeError(`string contains non-ASCII character "${e[r]}" with code ${n} at position ${r}`);return n})}function dN(e,t,r){return kf(e)&&kf(t)&&kf(r)&&t<=e&&e<r}function vd(e,t,r,n){if(!dN(t,r,n))throw new RangeError("expected valid "+e+": "+r+" <= n < "+n+", got "+t)}function ji(e){if(e<Cf)throw new Error("expected non-negative bigint, got "+e);let t;for(t=0;e>Cf;e>>=gd,t+=1);return t}function k_(e,t,r){if(Qn(e,"hashLen"),Qn(t,"qByteLen"),typeof r!="function")throw new TypeError("hmacFn must be a function");let n=L=>new Uint8Array(L),i=Uint8Array.of(),o=Uint8Array.of(0),s=Uint8Array.of(1),a=1e3,c=n(e),h=n(e),g=0,m=()=>{c.fill(1),h.fill(0),g=0},_=(...L)=>r(h,Me(c,...L)),I=(L=i)=>{h=_(o,L),c=_(),L.length!==0&&(h=_(s,L),c=_())},R=()=>{if(g++>=a)throw new Error("drbg: tried max amount of iterations");let L=0,q=[];for(;L<t;){c=_();let G=c.slice();q.push(G),L+=c.length}return Me(...q)};return(L,q)=>{m(),I(L);let G;for(;(G=q(R()))===void 0;)I();return m(),G}}function Ir(e,t={},r={}){if(Object.prototype.toString.call(e)!=="[object Object]")throw new TypeError("expected valid options object");function n(o,s,a){if(!a&&s!=="function"&&!Object.hasOwn(e,o))throw new TypeError(`param "${o}" is invalid: expected own property`);let c=e[o];if(a&&c===void 0)return;let h=typeof c;if(h!==s||c===null)throw new TypeError(`param "${o}" is invalid: expected ${s}, got ${h}`)}let i=(o,s)=>Object.entries(o).forEach(([a,c])=>n(a,c,s));i(t,!1),i(r,!0)}var Le,yd,Bn,Me,jo,qi,ar,Cf,gd,kf,Go,Ki=er(()=>{y();On();Le=(e,t,r)=>on(e,t,r),yd=Qn,Bn=xf,Me=(...e)=>w_(...e),jo=e=>cd(e),qi=fd,ar=e=>ra(e),Cf=BigInt(0),gd=BigInt(1);kf=e=>typeof e=="bigint"&&Cf<=e;Go=e=>(gd<<BigInt(e))-gd});function hr(e,t){if(t<=Kt)throw new Error("mod: expected positive modulus, got "+t);let r=e%t;return r>=Kt?r:t+r}function dr(e,t,r){if(t<Kt)throw new Error("pow2: expected non-negative exponent, got "+t);let n=e;for(;t-- >Kt;)n*=n,n%=r;return n}function C_(e,t){if(e===Kt)throw new Error("invert: expected non-zero number");if(t<=Kt)throw new Error("invert: expected positive modulus, got "+t);let r=hr(e,t),n=t,i=Kt,o=xt,s=xt,a=Kt;for(;r!==Kt;){let h=n/r,g=n-r*h,m=i-s*h,_=o-a*h;n=r,r=g,i=s,o=a,s=m,a=_}if(n!==xt)throw new Error("invert: does not exist");return hr(i,t)}function _d(e,t,r){let n=e;if(!n.eql(n.sqr(t),r))throw new Error("Cannot find square root")}function j_(e,t){let r=e,n=(r.ORDER+xt)/U_,i=r.pow(t,n);return _d(r,i,t),i}function yN(e,t){let r=e,n=(r.ORDER-F_)/q_,i=r.mul(t,Vi),o=r.pow(i,n),s=r.mul(t,o),a=r.mul(r.mul(s,Vi),o),c=r.mul(s,r.sub(a,r.ONE));return _d(r,c,t),c}function mN(e){let t=Wo(e),r=K_(e),n=r(t,t.neg(t.ONE)),i=r(t,n),o=r(t,t.neg(n)),s=(e+pN)/H_;return((a,c)=>{let h=a,g=h.pow(c,s),m=h.mul(g,n),_=h.mul(g,i),I=h.mul(g,o),R=h.eql(h.sqr(m),c),N=h.eql(h.sqr(_),c);g=h.cmov(g,m,R),m=h.cmov(I,_,N);let L=h.eql(h.sqr(m),c),q=h.cmov(g,m,L);return _d(h,q,c),q})}function K_(e){if(e<D_)throw new Error("sqrt is not defined for small field");let t=e-xt,r=0;for(;t%Vi===Kt;)t/=Vi,r++;let n=Vi,i=Wo(e);for(;bd(i,n)===1;)if(n++>1e3)throw new Error("Cannot find square root: probably non-prime P");if(r===1)return j_;let o=i.pow(n,t),s=(t+xt)/Vi;return function(c,h){let g=c;if(g.is0(h))return h;if(bd(g,h)!==1)throw new Error("Cannot find square root");let m=r,_=g.mul(g.ONE,o),I=g.pow(h,t),R=g.pow(h,s);for(;!g.eql(I,g.ONE);){if(g.is0(I))return g.ZERO;let N=1,L=g.sqr(I);for(;!g.eql(L,g.ONE);)if(N++,L=g.sqr(L),N===m)throw new Error("Cannot find square root");let q=xt<<BigInt(m-N-1),G=g.pow(_,q);m=N,_=g.sqr(G),I=g.mul(I,_),R=g.mul(R,G)}return R}}function vN(e){return e%U_===D_?j_:e%q_===F_?yN:e%H_===gN?mN(e):K_(e)}function Gi(e){let t={ORDER:"bigint",BYTES:"number",BITS:"number"},r=bN.reduce((n,i)=>(n[i]="function",n),t);if(Ir(e,r),xr(e.BYTES,"BYTES"),xr(e.BITS,"BITS"),e.BYTES<1||e.BITS<1)throw new Error("invalid field: expected BYTES/BITS > 0");if(e.ORDER<=xt)throw new Error("invalid field: expected ORDER > 1, got "+e.ORDER);return e}function _N(e,t,r){let n=e;if(r<Kt)throw new Error("invalid exponent, negatives unsupported");if(r===Kt)return n.ONE;if(r===xt)return t;let i=n.ONE,o=t;for(;r>Kt;)r&xt&&(i=n.mul(i,o)),o=n.sqr(o),r>>=xt;return i}function Wi(e,t,r=!1){let n=e,i=new Array(t.length).fill(r?n.ZERO:void 0),o=t.reduce((a,c,h)=>n.is0(c)?a:(i[h]=a,n.mul(a,c)),n.ONE),s=n.inv(o);return t.reduceRight((a,c,h)=>n.is0(c)?a:(i[h]=n.mul(a,i[h]),n.mul(a,c)),s),i}function bd(e,t){let r=e,n=(r.ORDER-xt)/Vi,i=r.pow(t,n),o=r.eql(i,r.ONE),s=r.eql(i,r.ZERO),a=r.eql(i,r.neg(r.ONE));if(!o&&!s&&!a)throw new Error("invalid Legendre symbol result");return o?1:s?0:-1}function wd(e,t){return bd(e,t)!==-1}function wN(e,t){if(t!==void 0&&yd(t),e<=Kt)throw new Error("invalid n length: expected positive n, got "+e);if(t!==void 0&&t<1)throw new Error("invalid n length: expected positive bit length, got "+t);let r=ji(e);if(t!==void 0&&t<r)throw new Error(`invalid n length: expected bit length (${r}) >= n.length (${t})`);let n=t!==void 0?t:r,i=Math.ceil(n/8);return{nBitLength:n,nByteLength:i}}function Wo(e,t={}){return new Ff(e,t)}function V_(e){if(typeof e!="bigint")throw new Error("field order must be bigint");if(e<=xt)throw new Error("field order must be greater than 1");let t=ji(e-xt);return Math.ceil(t/8)}function sa(e){let t=V_(e);return t+Math.ceil(t/2)}function zo(e,t,r=!1){Le(e);let n=e.length,i=V_(t),o=Math.max(sa(t),16);if(n<o||n>1024)throw new Error("expected "+o+"-1024 bytes of input, got "+n);let s=r?Ko(e):tr(e),a=hr(s,t-xt)+xt;return r?md(a,i):Df(a,i)}var Kt,xt,Vi,D_,U_,F_,pN,q_,gN,H_,bN,L_,Ff,Yo=er(()=>{y();Ki();Kt=BigInt(0),xt=BigInt(1),Vi=BigInt(2),D_=BigInt(3),U_=BigInt(4),F_=BigInt(5),pN=BigInt(7),q_=BigInt(8),gN=BigInt(9),H_=BigInt(16);bN=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];L_=new WeakMap,Ff=class{constructor(t,r={}){C(this,"ORDER");C(this,"BITS");C(this,"BYTES");C(this,"isLE");C(this,"ZERO",Kt);C(this,"ONE",xt);C(this,"_lengths");C(this,"_mod");if(t<=xt)throw new Error("invalid field: expected ORDER > 1, got "+t);let n;this.isLE=!1,r!=null&&typeof r=="object"&&(typeof r.BITS=="number"&&(n=r.BITS),typeof r.sqrt=="function"&&Object.defineProperty(this,"sqrt",{value:r.sqrt,enumerable:!0}),typeof r.isLE=="boolean"&&(this.isLE=r.isLE),r.allowedLengths&&(this._lengths=Object.freeze(r.allowedLengths.slice())),typeof r.modFromBytes=="boolean"&&(this._mod=r.modFromBytes));let{nBitLength:i,nByteLength:o}=wN(t,n);if(o>2048)throw new Error("invalid field: expected ORDER of <= 2048 bytes");this.ORDER=t,this.BITS=i,this.BYTES=o,Object.freeze(this)}create(t){return hr(t,this.ORDER)}isValid(t){if(typeof t!="bigint")throw new TypeError("invalid field element: expected bigint, got "+typeof t);return Kt<=t&&t<this.ORDER}is0(t){return t===Kt}isValidNot0(t){return!this.is0(t)&&this.isValid(t)}isOdd(t){return(t&xt)===xt}neg(t){return hr(-t,this.ORDER)}eql(t,r){return t===r}sqr(t){return hr(t*t,this.ORDER)}add(t,r){return hr(t+r,this.ORDER)}sub(t,r){return hr(t-r,this.ORDER)}mul(t,r){return hr(t*r,this.ORDER)}pow(t,r){return _N(this,t,r)}div(t,r){return hr(t*C_(r,this.ORDER),this.ORDER)}sqrN(t){return t*t}addN(t,r){return t+r}subN(t,r){return t-r}mulN(t,r){return t*r}inv(t){return C_(t,this.ORDER)}sqrt(t){let r=L_.get(this);return r||L_.set(this,r=vN(this.ORDER)),r(this,t)}toBytes(t){return this.isLE?md(t,this.BYTES):Df(t,this.BYTES)}fromBytes(t,r=!1){Le(t);let{_lengths:n,BYTES:i,isLE:o,ORDER:s,_mod:a}=this;if(n){if(t.length<1||!n.includes(t.length)||t.length>i)throw new Error("Field.fromBytes: expected "+n+" bytes, got "+t.length);let h=new Uint8Array(i);h.set(t,o?0:h.length-t.length),t=h}if(t.length!==i)throw new Error("Field.fromBytes: expected "+i+" bytes, got "+t.length);let c=o?Ko(t):tr(t);if(a&&(c=hr(c,s)),!r&&!this.isValid(c))throw new Error("invalid field element: outside of range 0..ORDER");return c}invertBatch(t){return Wi(this,t)}cmov(t,r,n){return Hi(n,"condition"),n?r:t}};Object.freeze(Ff.prototype)});function Y_(e){let t=e;if(typeof t!="function")throw new TypeError("Point must be a constructor");Ir({Fp:t.Fp,Fn:t.Fn,fromAffine:t.fromAffine,fromBytes:t.fromBytes,fromHex:t.fromHex},{Fp:"object",Fn:"object",fromAffine:"function",fromBytes:"function",fromHex:"function"}),Gi(t.Fp),Gi(t.Fn)}function aa(e,t){let r=t.negate();return e?r:t}function Id(e,t){let r=Wi(e.Fp,t.map(n=>n.Z));return t.map((n,i)=>e.fromAffine(n.toAffine(r[i])))}function $_(e,t){if(!Number.isSafeInteger(e)||e<=0||e>t)throw new Error("invalid window size, expected [1.."+t+"], got W="+e)}function Sd(e,t){$_(e,t);let r=Math.ceil(t/e)+1,n=2**(e-1),i=2**e,o=Go(e),s=BigInt(e);return{windows:r,windowSize:n,mask:o,maxNumber:i,shiftBy:s}}function G_(e,t,r){let{windowSize:n,mask:i,maxNumber:o,shiftBy:s}=r,a=Number(e&i),c=e>>s;a>n&&(a-=o,c+=zi);let h=t*n,g=h+Math.abs(a)-1,m=a===0,_=a<0,I=t%2!==0;return{nextN:c,offset:g,isZero:m,isNeg:_,isNegF:I,offsetF:h}}function SN(e,t){if(!Array.isArray(e))throw new Error("array expected");e.forEach((r,n)=>{if(!(r instanceof t))throw new Error("invalid point at index "+n)})}function EN(e,t){if(!Array.isArray(e))throw new Error("array of scalars expected");e.forEach((r,n)=>{if(!t.isValid(r))throw new Error("invalid scalar at index "+n)})}function xd(e){return Z_.get(e)||1}function W_(e){if(e!==$o)throw new Error("invalid wNAF")}function X_(e,t,r,n){let i=t,o=e.ZERO,s=e.ZERO;for(;r>$o||n>$o;)r&zi&&(o=o.add(i)),n&zi&&(s=s.add(i)),i=i.double(),r>>=zi,n>>=zi;return{p1:o,p2:s}}function J_(e,t,r){let n=e.Fn;SN(t,e),EN(r,n);let i=t.length,o=r.length;if(i!==o)throw new Error("arrays of points and scalars must have equal length");let s=e.ZERO,a=ji(BigInt(i)),c=1;a>12?c=a-3:a>4?c=a-2:a>0&&(c=2);let h=Go(c),g=new Array(Number(h)+1).fill(s),m=Math.floor((n.BITS-1)/c)*c,_=s;for(let I=m;I>=0;I-=c){g.fill(s);for(let N=0;N<o;N++){let L=r[N],q=Number(L>>BigInt(I)&h);g[q]=g[q].add(t[N])}let R=s;for(let N=g.length-1,L=s;N>0;N--)L=L.add(g[N]),R=R.add(L);if(_=_.add(R),I!==0)for(let N=0;N<c;N++)_=_.double()}return _}function z_(e,t,r){if(t){if(t.ORDER!==e)throw new Error("Field.ORDER must match order: Fp == p, Fn == n");return Gi(t),t}else return Wo(e,{isLE:r})}function Q_(e,t,r={},n){if(n===void 0&&(n=e==="edwards"),!t||typeof t!="object")throw new Error(`expected valid ${e} CURVE object`);for(let c of["p","n","h"]){let h=t[c];if(!(typeof h=="bigint"&&h>$o))throw new Error(`CURVE.${c} must be positive bigint`)}let i=z_(t.p,r.Fp,n),o=z_(t.n,r.Fn,n),a=["Gx","Gy","a",e==="weierstrass"?"b":"d"];for(let c of a)if(!i.isValid(t[c]))throw new Error(`CURVE.${c} must be valid field element of CURVE.Fp`);return t=Object.freeze(Object.assign({},t)),{CURVE:t,Fp:i,Fn:o}}function Hf(e,t){return function(n){let i=e(n);return{secretKey:i,publicKey:t(i)}}}var $o,zi,Ed,Z_,qf,jf=er(()=>{y();Ki();Yo();$o=BigInt(0),zi=BigInt(1);Ed=new WeakMap,Z_=new WeakMap;qf=class{constructor(t,r){C(this,"BASE");C(this,"ZERO");C(this,"Fn");C(this,"bits");this.BASE=t.BASE,this.ZERO=t.ZERO,this.Fn=t.Fn,this.bits=r}_unsafeLadder(t,r,n=this.ZERO){let i=t;for(;r>$o;)r&zi&&(n=n.add(i)),i=i.double(),r>>=zi;return n}precomputeWindow(t,r){let{windows:n,windowSize:i}=Sd(r,this.bits),o=[],s=t,a=s;for(let c=0;c<n;c++){a=s,o.push(a);for(let h=1;h<i;h++)a=a.add(s),o.push(a);s=a.double()}return o}wNAF(t,r,n){if(!this.Fn.isValid(n))throw new Error("invalid scalar");let i=this.ZERO,o=this.BASE,s=Sd(t,this.bits);for(let a=0;a<s.windows;a++){let{nextN:c,offset:h,isZero:g,isNeg:m,isNegF:_,offsetF:I}=G_(n,a,s);n=c,g?o=o.add(aa(_,r[I])):i=i.add(aa(m,r[h]))}return W_(n),{p:i,f:o}}wNAFUnsafe(t,r,n,i=this.ZERO){let o=Sd(t,this.bits);for(let s=0;s<o.windows&&n!==$o;s++){let{nextN:a,offset:c,isZero:h,isNeg:g}=G_(n,s,o);if(n=a,!h){let m=r[c];i=i.add(g?m.negate():m)}}return W_(n),i}getPrecomputes(t,r,n){let i=Ed.get(r);return i||(i=this.precomputeWindow(r,t),t!==1&&(typeof n=="function"&&(i=n(i)),Ed.set(r,i))),i}cached(t,r,n){let i=xd(t);return this.wNAF(i,this.getPrecomputes(i,t,n),r)}unsafe(t,r,n,i){let o=xd(t);return o===1?this._unsafeLadder(t,r,i):this.wNAFUnsafe(o,this.getPrecomputes(o,t,n),r,i)}createCache(t,r){$_(r,this.bits),Z_.set(t,r),Ed.delete(t)}hasCache(t){return xd(t)!==1}}});function ew(e){if(!Number.isSafeInteger(e)||e<0||e>4294967295)throw new Error("wrong u32 integer:"+e);return e}function xN(e){if(ew(e),e<=1)return 1;if(e>2147483648)throw new Error("nextPowerOfTwo overflow: result does not fit u32");return 1<<Ad(e-1)+1>>>0}function Ad(e){return ew(e),31-Math.clz32(e)}function tw(e,t,r,n,i){let o=e,s=r||((g,m)=>new Array(g).fill(m??o.ZERO)),a=g=>{if(Array.isArray(g))return!0;if(!ArrayBuffer.isView(g))return!1;let m=g;return typeof m.length=="number"&&typeof m.slice=="function"&&typeof m[Symbol.iterator]=="function"},c=(...g)=>{if(!g.length)return 0;for(let _ of g)if(!a(_))throw new Error("poly: not polynomial: "+_);let m=g[0].length;for(let _=1;_<g.length;_++)if(g[_].length!==m)throw new Error(`poly: mismatched lengths ${m} vs ${g[_].length}`);if(i!==void 0&&m!==i)throw new Error(`poly: expected fixed length ${i}, got ${m}`);return m};function h(g,m,_=!1){let I=Ad(m),R=_?t.brp(I):t.roots(I);for(let N=0;N<m;N++)if(o.eql(g,R[N]))return N;return-1}return{roots:t,create:s,length:i,extend:(g,m)=>{c(g);let _=s(m,o.ZERO);for(let I=0;I<Math.min(g.length,m);I++)_[I]=g[I];return _},degree:g=>{c(g);for(let m=g.length-1;m>=0;m--)if(!o.is0(g[m]))return m;return-1},add:(g,m)=>{let _=c(g,m),I=s(_);for(let R=0;R<_;R++)I[R]=o.add(g[R],m[R]);return I},sub:(g,m)=>{let _=c(g,m),I=s(_);for(let R=0;R<_;R++)I[R]=o.sub(g[R],m[R]);return I},dot:(g,m)=>{let _=c(g,m),I=s(_);for(let R=0;R<_;R++)I[R]=o.mul(g[R],m[R]);return I},mul:(g,m)=>{if(a(m)){let _=c(g,m);if(n){let I=n.direct(g,!1,!0),R=n.direct(m,!1,!0);for(let N=0;N<I.length;N++)I[N]=o.mul(I[N],R[N]);return n.inverse(I,!0,!1)}else{let I=s(_);for(let R=0;R<_;R++)for(let N=0;N<_;N++){let L=(R+N)%_;I[L]=o.add(I[L],o.mul(g[R],m[N]))}return I}}else{let _=s(c(g));for(let I=0;I<_.length;I++)_[I]=o.mul(g[I],m);return _}},convolve(g,m){let _=xN(g.length+m.length-1);return this.mul(this.extend(g,_),this.extend(m,_))},shift(g,m){let _=s(c(g));_[0]=g[0];for(let I=1,R=o.ONE;I<g.length;I++)R=o.mul(R,m),_[I]=o.mul(g[I],R);return _},clone:g=>{c(g);let m=s(g.length);for(let _=0;_<g.length;_++)m[_]=g[_];return m},eval:(g,m)=>{c(g,m);let _=o.ZERO;for(let I=0;I<g.length;I++)_=o.add(_,o.mul(g[I],m[I]));return _},monomial:{basis:(g,m)=>{let _=s(m),I=o.ONE;for(let R=0;R<m;R++)_[R]=I,I=o.mul(I,g);return _},eval:(g,m)=>{c(g);let _=o.ZERO;for(let I=g.length-1;I>=0;I--)_=o.add(o.mul(_,m),g[I]);return _}},lagrange:{basis:(g,m,_=!1,I)=>{let R=Ad(m),N=I||(_?t.brp(R):t.roots(R)),L=s(m),q=h(g,m,_);if(q!==-1)return L[q]=o.ONE,L;let G=o.pow(g,BigInt(m)),K=o.mul(o.sub(G,o.ONE),o.inv(BigInt(m))),z=s(m);for(let oe=0;oe<m;oe++)z[oe]=o.sub(g,N[oe]);let X=o.invertBatch(z);for(let oe=0;oe<m;oe++)L[oe]=o.mul(K,o.mul(N[oe],X[oe]));return L},eval(g,m,_=!1){c(g);let I=h(m,g.length,_);if(I!==-1)return g[I];let R=this.basis(m,g.length,_),N=o.ZERO;for(let L=0;L<g.length;L++)o.is0(g[L])||(N=o.add(N,o.mul(g[L],R[L])));return N}},vanishing(g){c(g);let m=s(g.length+1,o.ZERO);m[0]=o.ONE;for(let _ of g){let I=o.neg(_);for(let R=m.length-1;R>0;R--)m[R]=o.add(o.mul(m[R],I),m[R-1]);m[0]=o.mul(m[0],I)}return m}}}var rw=er(()=>{y()});function Yi(e,t){if(xr(e),xr(t),t<0||t>4)throw new Error("invalid I2OSP length: "+t);if(e<0||e>2**(8*t)-1)throw new Error("invalid I2OSP input: "+e);let r=Array.from({length:t}).fill(0);for(let n=t-1;n>=0;n--)r[n]=e&255,e>>>=8;return new Uint8Array(r)}function AN(e,t){let r=new Uint8Array(e.length);for(let n=0;n<e.length;n++)r[n]=e[n]^t[n];return r}function nw(e){if(!qi(e)&&typeof e!="string")throw new Error("DST must be Uint8Array or ascii string");let t=typeof e=="string"?Vo(e):e;if(t.length===0)throw new Error("DST must be non-empty");return t}function ON(e,t,r,n){Le(e),xr(r),t=nw(t),t.length>255&&(t=n(Me(Vo("H2C-OVERSIZE-DST-"),t)));let{outputLen:i,blockLen:o}=n,s=Math.ceil(r/i);if(r>65535||s>255)throw new Error("expand_message_xmd: invalid lenInBytes");let a=Me(t,Yi(t.length,1)),c=new Uint8Array(o),h=Yi(r,2),g=new Array(s),m=n(Me(c,e,h,Yi(0,1),a));g[0]=n(Me(m,Yi(1,1),a));for(let I=1;I<s;I++){let R=[AN(m,g[I-1]),Yi(I+1,1),a];g[I]=n(Me(...R))}return Me(...g).slice(0,r)}function RN(e,t,r,n,i){if(Le(e),xr(r),t=nw(t),t.length>255){let o=Math.ceil(2*n/8);t=i.create({dkLen:o}).update(Vo("H2C-OVERSIZE-DST-")).update(t).digest()}if(r>65535||t.length>255)throw new Error("expand_message_xof: invalid lenInBytes");return i.create({dkLen:r}).update(e).update(Yi(r,2)).update(t).update(Yi(t.length,1)).digest()}function Od(e,t,r){Ir(r,{p:"bigint",m:"number",k:"number",hash:"function"});let{p:n,k:i,m:o,hash:s,expand:a,DST:c}=r;if(xr(s.outputLen,"valid hash"),Le(e),xr(t),t<1)throw new Error("hash_to_field: expected count >= 1");if(o<1)throw new Error("hash_to_field: expected m >= 1");let h=n.toString(2).length,g=Math.ceil((h+i)/8),m=t*o*g,_;if(a==="xmd")_=ON(e,c,m,s);else if(a==="xof")_=RN(e,c,m,i,s);else if(a==="_internal_pass")_=e;else throw new Error('expand must be "xmd" or "xof"');let I=new Array(t);for(let R=0;R<t;R++){let N=new Array(o);for(let L=0;L<o;L++){let q=g*(L+R*o),G=_.subarray(q,q+g);N[L]=hr(IN(G),n)}I[R]=N}return I}function iw(e,t){let r=t.map(n=>Array.from(n).reverse());return(n,i)=>{let[o,s,a,c]=r.map(m=>m.reduce((_,I)=>e.add(e.mul(_,n),I))),[h,g]=Wi(e,[s,c],!0);return n=e.mul(o,h),i=e.mul(i,e.mul(a,g)),{x:n,y:i}}}function ow(e,t,r){if(typeof t!="function")throw new Error("mapToCurve() must be defined");let n=a=>Object.freeze({...a,DST:qi(a.DST)?Uf(a.DST):a.DST,...a.encodeDST===void 0?{}:{encodeDST:qi(a.encodeDST)?Uf(a.encodeDST):a.encodeDST}}),i=n(r);function o(a){return e.fromAffine(t(a))}function s(a){let c=a.clearCofactor();return c.equals(e.ZERO)?e.ZERO:(c.assertValidity(),c)}return Object.freeze({get defaults(){return n(i)},Point:e,hashToCurve(a,c){let h=Object.assign({},i,c),g=Od(a,2,h),m=o(g[0]),_=o(g[1]);return s(m.add(_))},encodeToCurve(a,c){let h=i.encodeDST?{DST:i.encodeDST}:{},g=Object.assign({},i,h,c),m=Od(a,1,g),_=o(m[0]);return s(_)},mapToCurve(a){if(i.m===1){if(typeof a!="bigint")throw new Error("expected bigint (m=1)");return s(o([a]))}if(!Array.isArray(a))throw new Error("expected array of bigints");for(let c of a)if(typeof c!="bigint")throw new Error("expected array of bigints");return s(o(a))},hashToScalar(a,c){let h=e.Fn.ORDER,g=Object.assign({},i,{p:h,m:1,DST:TN},c);return Od(a,1,g)[0][0]}})}var IN,TN,sw=er(()=>{y();Ki();Yo();IN=tr;TN="HashToScalar-"});function Rd(e){Ir(e,{name:"string",hash:"function"},{hashToScalar:"function",validatePoint:"function",parsePublicKey:"function",adjustScalar:"function",adjustPoint:"function",challenge:"function",adjustNonces:"function",adjustSecret:"function",adjustPublic:"function",adjustGroupCommitmentShare:"function",adjustDKG:"function"}),Y_(e.Point);let{Point:t}=e,r=e.Fn===void 0?t.Fn:e.Fn,n=e.hash,i=e.hashToScalar===void 0?(T,k={DST:new Uint8Array})=>{let H=n(Me(k.DST,T));return r.create(r.isLE?Ko(H):tr(H))}:e.hashToScalar,o=An(e.H1!==void 0?e.H1:e.name+"rho"),s=An(e.H2!==void 0?e.H2:e.name+"chal"),a=An(e.H3!==void 0?e.H3:e.name+"nonce"),c=An(e.H4!==void 0?e.H4:e.name+"msg"),h=An(e.H5!==void 0?e.H5:e.name+"com"),g=An(e.HDKG!==void 0?e.HDKG:e.name+"dkg"),m=An(e.HID!==void 0?e.HID:e.name+"id"),_=T=>i(T,{DST:o}),I=T=>i(T,{DST:s}),R=T=>i(T,{DST:a}),N=T=>n(Me(c,T)),L=T=>n(Me(h,T)),q=T=>i(T,{DST:g}),G=T=>i(T,{DST:m}),K=(T=ar)=>{let k=zo(T(sa(r.ORDER)),r.ORDER,r.isLE);return r.isLE?Ko(k):tr(k)},z=T=>T.toBytes(),X=T=>{let k=t.fromBytes(T);return e.validatePoint&&e.validatePoint(k),k},oe=(T,k)=>({identifier:T,hiding:z(t.BASE.multiply(r.fromBytes(k.hiding))),binding:z(t.BASE.multiply(r.fromBytes(k.binding)))}),ue=e.adjustPoint===void 0?T=>T:e.adjustPoint,se=T=>{if(!r.isValid(T)||r.is0(T))throw new Error("Invalid identifier "+T);return T},de=T=>Bn(r.toBytes(se(T))),A=T=>{let k=se(r.fromBytes(jo(T)));if(de(k)!==T)throw new Error("expected canonical identifier hex");return k},u={encode:(T,k)=>{let H=Me(z(T),r.toBytes(k));return e.adjustTx&&(H=e.adjustTx.encode(H)),H},decode:T=>{e.adjustTx&&(T=e.adjustTx.decode(T));let k=X(T.subarray(0,-r.BYTES)),H=r.fromBytes(T.subarray(-r.BYTES));return{R:k,z:H}}},l=(T=ar)=>{let k=K(T);e.adjustScalar&&(k=e.adjustScalar(k));let H=t.BASE.multiply(k);return{scalar:k,point:H}},p="roots are unavailable in FROST polynomial mode",v={info:{G:r.ZERO,oddFactor:r.ZERO,powerOfTwo:0},roots(){throw new Error(p)},brp(){throw new Error(p)},inverse(){throw new Error(p)},omega(){throw new Error(p)},clear(){}},b=tw(r,v),E=(T,k)=>J_(t,T,k),O=(T,k)=>{if(!k.length)throw new Error("empty coefficients");return b.monomial.eval(k,T)},w=(T,k)=>{let H="invalid parameters";if(!T.some(ee=>r.eql(ee,k)))throw new Error(H);let V=new Set(T);if(V.size!==T.length)throw new Error(H);if(!V.has(k))throw new Error(H);let ne=r.ONE,Q=r.ONE;for(let ee of T)r.eql(ee,k)||(ne=r.mul(ne,ee),Q=r.mul(Q,r.sub(ee,k)));return r.div(ne,Q)},f=(T,k)=>{let H=b.monomial.basis(T,k.length);return E(k,H)},S=(T,k,H,V=ar)=>{Kf(T);let ne=k===void 0?K(V):r.fromBytes(k);if(!H){H=[];for(let pe=0;pe<T.min-1;pe++)H.push(K(V))}if(H.length!==T.min-1)throw new Error("wrong coefficients length");let Q=[ne,...H],ee=Q.map(pe=>t.BASE.multiply(pe));return{coefficients:Q,commitment:ee,secret:ne}},j={challenge:(T,k,H)=>q(Me(r.toBytes(T),z(k),z(H))),compute(T,k,H,V=ar){if(k.length<1)throw new Error("coefficients should have at least one element");let{point:ne,scalar:Q}=l(V),ee=H[0],pe=this.challenge(T,ee,ne),ie=r.add(Q,r.mul(k[0],pe));return u.encode(ne,ie)},validate(T,k,H){if(k.length<1)throw new Error("commitment should have at least one element");let{R:V,z:ne}=u.decode(H),Q=X(k[0]),ee=this.challenge(T,Q,V);if(!V.equals(t.BASE.multiply(ne).subtract(Q.multiply(ee))))throw new Error("invalid proof of knowledge")}},F={challenge:(T,k,H)=>e.challenge?e.challenge(T,k,H):I(Me(z(T),z(k),H)),sign(T,k,H=ar){let{point:V,scalar:ne}=l(H),Q=t.BASE.multiply(k),ee=this.challenge(V,Q,T),pe=r.add(ne,r.mul(ee,k));return[V,pe]},verify(T,k,H,V){e.adjustPoint&&(V=e.adjustPoint(V)),e.adjustPoint&&(k=e.adjustPoint(k));let ne=this.challenge(k,V,T),Q=t.BASE.multiply(H),ee=V.multiply(ne),pe=Q.subtract(ee).subtract(k);return pe.clearCofactor&&(pe=pe.clearCofactor()),t.ZERO.equals(pe)}},Y=(T,k,H)=>{if(!t.BASE.multiply(H).equals(f(T,k)))throw new Error("invalid secret share")},$={fromNumber(T){if(!Number.isSafeInteger(T))throw new Error("expected safe interger");return de(BigInt(T))},derive(T){if(typeof T!="string")throw new Error("wrong identifier string: "+T);return de(G(An(T)))}},J=(T,k=ar)=>R(Me(k(32),r.toBytes(T))),ae=(T,k,H)=>{let V=k.map(te=>[te.identifier,A(te.identifier),X(te.hiding),X(te.binding)]);V.sort((te,ve)=>te[1]<ve[1]?-1:te[1]>ve[1]?1:0);let ne=[];for(let[te,ve,be,we]of V)ne.push(r.toBytes(ve),z(be),z(we));let Q=L(Me(...ne)),ee=Me(z(T),N(H),Q),pe={};for(let[te,ve]of V)pe[te]=_(Me(ee,r.toBytes(ve)));let ie=[],fe=[];for(let[te,ve,be,we]of V){if(t.ZERO.equals(be)||t.ZERO.equals(we))throw new Error("infinity commitment");ie.push(be,we),fe.push(r.ONE,pe[te])}let ze=E(ie,fe);return{identifiers:V.map(te=>te[1]),groupCommitment:ze,bindingFactors:pe}},ye=(T,k,H,V)=>{let ne=ue(X(T)),Q=A(V),{identifiers:ee,groupCommitment:pe,bindingFactors:ie}=ae(ne,k,H),fe=ie[V],ze=w(ee,Q),Oe=F.challenge(pe,ne,H);return{lambda:ze,challenge:Oe,bindingFactor:fe,groupCommitment:pe}};Object.freeze($);let he={Identifier:$,DKG:Object.freeze({round1:(T,k,H,V=ar)=>{Kf(k);let ne=A(T),{coefficients:Q,commitment:ee}=S(k,H,void 0,V),pe=j.compute(ne,Q,ee,V),ie=ee.map(z),fe={identifier:de(ne),commitment:ie,proofOfKnowledge:pe},ze={identifier:ne,coefficients:Q,commitment:ee.map(z),signers:{min:k.min,max:k.max},step:1};return{public:fe,secret:ze}},round2:(T,k)=>{if(k.length!==T.signers.max-1)throw new Error("wrong number of round1 packages");if(!T.coefficients||T.step===3)throw new Error("round3 package used in round2");let H={};for(let V of k){if(V.commitment.length!==T.signers.min)throw new Error("wrong number of commitments");let ne=A(V.identifier);if(ne===T.identifier)throw new Error("duplicate id="+de(ne));j.validate(ne,V.commitment,V.proofOfKnowledge);for(let ee of V.commitment)X(ee);if(H[V.identifier])throw new Error("Duplicate id="+ne);let Q=r.toBytes(O(ne,T.coefficients));H[V.identifier]={identifier:de(T.identifier),signingShare:Q}}return T.step=2,H},round3:(T,k,H)=>{if(k.length!==T.signers.max-1)throw new Error("wrong length of round1 packages");if(!T.coefficients||T.step!==2)throw new Error("round2 package used in round3");if(H.length!==k.length)throw new Error("wrong length of round2 packages");let V={};for(let ve of k){if(!ve.identifier||!ve.commitment)throw new Error("wrong round1 share");V[ve.identifier]={...ve}}for(let ve of H){if(!ve.identifier||!ve.signingShare)throw new Error("wrong round2 share");if(!V[ve.identifier])throw new Error("round1 share for "+ve.identifier+" is missing");V[ve.identifier].signingShare=ve.signingShare}if(Object.keys(V).length!==k.length)throw new Error("mismatch identifiers between rounds");let ne=r.ZERO;if(T.commitment.length!==T.signers.min)throw new Error("wrong commitments length");let Q=T.commitment.map(X),ee=O(T.identifier,T.coefficients);Y(T.identifier,Q,ee);let pe=Q.map(z),ie={[de(T.identifier)]:pe};for(let ve in V){let be=V[ve];if(!be.signingShare||!be.commitment)throw new Error("mismatch identifiers");let we=A(ve),pn=r.fromBytes(be.signingShare),Ye=be.commitment.map(X);Y(T.identifier,Ye,pn),ne=r.add(ne,pn);let je=de(we);if(ie[je])throw new Error("duplicated id="+je);ie[je]=be.commitment}ne=r.add(ne,ee);let fe=new Array(T.signers.min).fill(t.ZERO);for(let ve in ie){let be=ie[ve];if(be.length!==T.signers.min)throw new Error("wrong commitments length");for(let we=0;we<be.length;we++)fe[we]=fe[we].add(X(be[we]))}let ze=fe.map(z),Oe={};for(let ve in ie)Oe[ve]=z(f(A(ve),fe));let te={public:{signers:{min:T.signers.min,max:T.signers.max},commitments:ze,verifyingShares:Object.fromEntries(Object.entries(Oe).map(([ve,be])=>[ve,be.slice()]))},secret:{identifier:de(T.identifier),signingShare:r.toBytes(ne)}};e.adjustDKG&&(te=e.adjustDKG(te));for(let ve=0;ve<T.coefficients.length;ve++)T.coefficients[ve]-=T.coefficients[ve];return delete T.coefficients,T.step=3,te},clean(T){if(T.identifier-=T.identifier,T.coefficients)for(let k=0;k<T.coefficients.length;k++)T.coefficients[k]-=T.coefficients[k];T.step=3}}),trustedDealer(T,k,H,V=ar){if(Kf(T),k===void 0){k=[];for(let fe=1;fe<=T.max;fe++)k.push($.fromNumber(fe))}else if(!Array.isArray(k)||k.length!==T.max)throw new Error("identifiers should be array of "+T.max);let ne={};for(let fe of k){let ze=A(fe);if(fe in ne)throw new Error("duplicated id="+fe);ne[fe]=ze}let Q=S(T,H,void 0,V),ee=Q.commitment.map(z),pe={},ie={};for(let fe of k){let ze=O(ne[fe],Q.coefficients);ie[fe]=z(t.BASE.multiply(ze)),pe[fe]={identifier:fe,signingShare:r.toBytes(ze)}}return{public:{signers:{min:T.min,max:T.max},commitments:ee,verifyingShares:ie},secretShares:pe}},validateSecret(T,k){let H=A(T.identifier),V=k.commitments.map(X),ne=r.fromBytes(T.signingShare);Y(H,V,ne)},commit(T,k=ar){let H=r.fromBytes(T.signingShare),V=J(H,k),ne=J(H,k),Q={hiding:r.toBytes(V),binding:r.toBytes(ne)};return{nonces:Q,commitments:oe(T.identifier,Q)}},signShare(T,k,H,V,ne){aw(k.signers,V.length);let Q=r.fromBytes(H.hiding),ee=r.fromBytes(H.binding);if(r.is0(Q)||r.is0(ee))throw new Error("signing nonces already used");let pe={identifier:T.identifier,hiding:z(t.BASE.multiply(Q)),binding:z(t.BASE.multiply(ee))},ie=V.find(Ze=>Ze.identifier===T.identifier);if(!ie)throw new Error("missing signer commitment");if(Bn(ie.hiding)!==Bn(pe.hiding)||Bn(ie.binding)!==Bn(pe.binding))throw new Error("incorrect signer commitment");e.adjustSecret&&(T=e.adjustSecret(T,k)),e.adjustPublic&&(k=e.adjustPublic(k));let fe=r.fromBytes(T.signingShare),{lambda:ze,challenge:Oe,bindingFactor:te,groupCommitment:ve}=ye(k.commitments[0],V,ne,T.identifier),be=e.adjustNonces?e.adjustNonces(ve,H):H,we=e.adjustNonces?r.fromBytes(be.hiding):Q,pn=e.adjustNonces?r.fromBytes(be.binding):ee,Ye=r.mul(r.mul(ze,fe),Oe),je=r.mul(pn,te),$a=r.toBytes(r.add(r.add(we,je),Ye));return H.hiding.fill(0),H.binding.fill(0),$a},verifyShare(T,k,H,V,ne){e.adjustPublic&&(T=e.adjustPublic(T));let Q=k.find(pn=>pn.identifier===V);if(!Q)throw new Error("cannot find identifier commitment");let ee=X(T.verifyingShares[V]),pe=X(Q.hiding),ie=X(Q.binding),{lambda:fe,challenge:ze,bindingFactor:Oe,groupCommitment:te}=ye(T.commitments[0],k,H,V),ve=pe.add(ie.multiply(Oe));e.adjustGroupCommitmentShare&&(ve=e.adjustGroupCommitmentShare(te,ve));let be=t.BASE.multiply(r.fromBytes(ne)),we=ve.add(ee.multiply(r.mul(ze,fe)));return be.equals(we)},aggregate(T,k,H,V){e.adjustPublic&&(T=e.adjustPublic(T));try{aw(T.signers,k.length)}catch{throw new Zo("aggregation failed",[])}let ne=k.map(ie=>ie.identifier);if(ne.length!==Object.keys(V).length)throw new Zo("aggregation failed",[]);for(let ie of ne)if(!(ie in V)||!(ie in T.verifyingShares))throw new Zo("aggregation failed",[]);let Q=X(T.commitments[0]),{groupCommitment:ee}=ae(Q,k,H),pe=r.ZERO;for(let ie of ne)pe=r.add(pe,r.fromBytes(V[ie]));if(!F.verify(H,ee,pe,Q)){let ie=[];for(let fe of ne)this.verifyShare(T,k,H,fe,V[fe])||ie.push(fe);throw new Zo("aggregation failed",ie)}return u.encode(ee,pe)},sign(T,k){let H=r.fromBytes(k);e.adjustScalar&&(H=e.adjustScalar(H));let[V,ne]=F.sign(T,H);return u.encode(V,ne)},verify(T,k,H){let V=e.parsePublicKey?e.parsePublicKey(H):X(H),{R:ne,z:Q}=u.decode(T);return F.verify(k,ne,Q,V)},combineSecret(T,k){if(Kf(k),!Array.isArray(T)||T.length<k.min)throw new Error("wrong secret shares array");let H=[],V={};for(let ee of T){let pe=A(ee.identifier),ie=de(pe);if(V[ie])throw new Error("duplicated id="+ie);V[ie]=!0,H.push([pe,r.fromBytes(ee.signingShare)])}let ne=H.map(([ee])=>ee),Q=r.ZERO;for(let[ee,pe]of H)Q=r.add(Q,r.mul(pe,w(ne,ee)));return r.toBytes(Q)},utils:Object.freeze({Fn:r,randomScalar:(T=ar)=>r.toBytes(l(T).scalar),generateSecretPolynomial:(T,k,H,V)=>{let ne=S(T,k,H,V);return{...ne,commitment:ne.commitment.map(z)}}})};return Object.freeze(he)}var Kf,aw,Zo,uw=er(()=>{y();On();Ki();jf();rw();Yo();Kf=e=>{if(!Number.isSafeInteger(e.min)||!Number.isSafeInteger(e.max))throw new Error("Wrong signers info: min="+e.min+" max="+e.max);if(e.min<2||e.max<2||e.min>e.max)throw new Error("Wrong signers info: min="+e.min+" max="+e.max)},aw=(e,t)=>{if(t<e.min||t>e.max)throw new Error("Wrong number of commitments="+t)},Zo=class extends Error{constructor(r,n){super(r);C(this,"cheaters");this.cheaters=n}}});var Vf,fw,cw=er(()=>{y();On();Vf=class{constructor(t,r){C(this,"oHash");C(this,"iHash");C(this,"blockLen");C(this,"outputLen");C(this,"canXOF",!1);C(this,"finished",!1);C(this,"destroyed",!1);if(wf(t),on(r,void 0,"key"),this.iHash=t.create(),typeof this.iHash.update!="function")throw new Error("Expected instance of class which extends utils.Hash");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;let n=this.blockLen,i=new Uint8Array(n);i.set(r.length>n?t.create().update(r).digest():r);for(let o=0;o<i.length;o++)i[o]^=54;this.iHash.update(i),this.oHash=t.create();for(let o=0;o<i.length;o++)i[o]^=106;this.oHash.update(i),Zt(i)}update(t){return Fo(this),this.iHash.update(t),this}digestInto(t){Fo(this),Sf(t,this),this.finished=!0;let r=t.subarray(0,this.outputLen);this.iHash.digestInto(r),this.oHash.update(r),this.oHash.digestInto(r),this.destroy()}digest(){let t=new Uint8Array(this.oHash.outputLen);return this.digestInto(t),t}_cloneInto(t){t||(t=Object.create(Object.getPrototypeOf(this),{}));let{oHash:r,iHash:n,finished:i,destroyed:o,blockLen:s,outputLen:a}=this;return t=t,t.finished=i,t.destroyed=o,t.blockLen=s,t.outputLen=a,t.oHash=r._cloneInto(t.oHash),t.iHash=n._cloneInto(t.iHash),t}clone(){return this._cloneInto()}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}},fw=(()=>{let e=((t,r,n)=>new Vf(t,r).update(n).digest());return e.create=(t,r)=>new Vf(t,r),e})()});function PN(e,t,r){vd("scalar",e,Ar,r);let[[n,i],[o,s]]=t,a=lw(s*e,r),c=lw(-i*e,r),h=e-a*n-c*o,g=-a*i-c*s,m=h<Ar,_=g<Ar;m&&(h=-h),_&&(g=-g);let I=Go(Math.ceil(ji(r)/2))+Lt;if(h<Ar||h>=I||g<Ar||g>=I)throw new Error("splitScalar (endomorphism): failed for k");return{k1neg:m,k1:h,k2neg:_,k2:g}}function Pd(e){if(!["compact","recovered","der"].includes(e))throw new Error('Signature format must be "compact", "recovered", or "der"');return e}function Td(e,t){Ir(e);let r={};for(let n of Object.keys(t))r[n]=e[n]===void 0?t[n]:e[n];return Hi(r.lowS,"lowS"),Hi(r.prehash,"prehash"),r.format!==void 0&&Pd(r.format),r}function hw(e,t={}){let r=Q_("weierstrass",e,t),n=r.Fp,i=r.Fn,o=r.CURVE,{h:s,n:a}=o;Ir(t,{},{allowInfinityPoint:"boolean",clearCofactor:"function",isTorsionFree:"function",fromBytes:"function",toBytes:"function",endo:"object"});let{endo:c,allowInfinityPoint:h}=t;if(c&&(!n.is0(o.a)||typeof c.beta!="bigint"||!Array.isArray(c.basises)))throw new Error('invalid endo: expected "beta": bigint and "basises": array');let g=gw(n,i);function m(){if(!n.isOdd)throw new Error("compression is not supported: Field does not have .isOdd()")}function _(l,p,v){if(h&&p.is0())return Uint8Array.of(0);let{x:b,y:E}=p.toAffine(),O=n.toBytes(b);if(Hi(v,"isCompressed"),v){m();let w=!n.isOdd(E);return Me(dw(w),O)}else return Me(Uint8Array.of(4),O,n.toBytes(E))}function I(l){Le(l,void 0,"Point");let{publicKey:p,publicKeyUncompressed:v}=g,b=l.length,E=l[0],O=l.subarray(1);if(h&&b===1&&E===0)return{x:n.ZERO,y:n.ZERO};if(b===p&&(E===2||E===3)){let w=n.fromBytes(O);if(!n.isValid(w))throw new Error("bad point: is not on curve, wrong x");let f=L(w),S;try{S=n.sqrt(f)}catch(Y){let $=Y instanceof Error?": "+Y.message:"";throw new Error("bad point: is not on curve, sqrt error"+$)}m();let j=n.isOdd(S);return(E&1)===1!==j&&(S=n.neg(S)),{x:w,y:S}}else if(b===v&&E===4){let w=n.BYTES,f=n.fromBytes(O.subarray(0,w)),S=n.fromBytes(O.subarray(w,w*2));if(!q(f,S))throw new Error("bad point: is not on curve");return{x:f,y:S}}else throw new Error(`bad point: got length ${b}, expected compressed=${p} or uncompressed=${v}`)}let R=t.toBytes===void 0?_:t.toBytes,N=t.fromBytes===void 0?I:t.fromBytes;function L(l){let p=n.sqr(l),v=n.mul(p,l);return n.add(n.add(v,n.mul(l,o.a)),o.b)}function q(l,p){let v=n.sqr(p),b=L(l);return n.eql(v,b)}if(!q(o.Gx,o.Gy))throw new Error("bad curve params: generator point");let G=n.mul(n.pow(o.a,Xo),Nd),K=n.mul(n.sqr(o.b),BigInt(27));if(n.is0(n.add(G,K)))throw new Error("bad curve params: a or b");function z(l,p,v=!1){if(!n.isValid(p)||v&&n.is0(p))throw new Error(`bad point coordinate ${l}`);return p}function X(l){if(!(l instanceof se))throw new Error("Weierstrass Point expected")}function oe(l){if(!c||!c.basises)throw new Error("no endo");return PN(l,c.basises,i.ORDER)}function ue(l,p,v,b,E){return v=new se(n.mul(v.X,l),v.Y,v.Z),p=aa(b,p),v=aa(E,v),p.add(v)}let u=class u{constructor(p,v,b){C(this,"X");C(this,"Y");C(this,"Z");this.X=z("x",p),this.Y=z("y",v,!0),this.Z=z("z",b),Object.freeze(this)}static CURVE(){return o}static fromAffine(p){let{x:v,y:b}=p||{};if(!p||!n.isValid(v)||!n.isValid(b))throw new Error("invalid affine point");if(p instanceof u)throw new Error("projective point not allowed");return n.is0(v)&&n.is0(b)?u.ZERO:new u(v,b,n.ONE)}static fromBytes(p){let v=u.fromAffine(N(Le(p,void 0,"point")));return v.assertValidity(),v}static fromHex(p){return u.fromBytes(jo(p))}get x(){return this.toAffine().x}get y(){return this.toAffine().y}precompute(p=8,v=!0){return A.createCache(this,p),v||this.multiply(Xo),this}assertValidity(){let p=this;if(p.is0()){if(t.allowInfinityPoint&&n.is0(p.X)&&n.eql(p.Y,n.ONE)&&n.is0(p.Z))return;throw new Error("bad point: ZERO")}let{x:v,y:b}=p.toAffine();if(!n.isValid(v)||!n.isValid(b))throw new Error("bad point: x or y not field elements");if(!q(v,b))throw new Error("bad point: equation left != right");if(!p.isTorsionFree())throw new Error("bad point: not in prime-order subgroup")}hasEvenY(){let{y:p}=this.toAffine();if(!n.isOdd)throw new Error("Field doesn't support isOdd");return!n.isOdd(p)}equals(p){X(p);let{X:v,Y:b,Z:E}=this,{X:O,Y:w,Z:f}=p,S=n.eql(n.mul(v,f),n.mul(O,E)),j=n.eql(n.mul(b,f),n.mul(w,E));return S&&j}negate(){return new u(this.X,n.neg(this.Y),this.Z)}double(){let{a:p,b:v}=o,b=n.mul(v,Xo),{X:E,Y:O,Z:w}=this,f=n.ZERO,S=n.ZERO,j=n.ZERO,F=n.mul(E,E),Y=n.mul(O,O),$=n.mul(w,w),J=n.mul(E,O);return J=n.add(J,J),j=n.mul(E,w),j=n.add(j,j),f=n.mul(p,j),S=n.mul(b,$),S=n.add(f,S),f=n.sub(Y,S),S=n.add(Y,S),S=n.mul(f,S),f=n.mul(J,f),j=n.mul(b,j),$=n.mul(p,$),J=n.sub(F,$),J=n.mul(p,J),J=n.add(J,j),j=n.add(F,F),F=n.add(j,F),F=n.add(F,$),F=n.mul(F,J),S=n.add(S,F),$=n.mul(O,w),$=n.add($,$),F=n.mul($,J),f=n.sub(f,F),j=n.mul($,Y),j=n.add(j,j),j=n.add(j,j),new u(f,S,j)}add(p){X(p);let{X:v,Y:b,Z:E}=this,{X:O,Y:w,Z:f}=p,S=n.ZERO,j=n.ZERO,F=n.ZERO,Y=o.a,$=n.mul(o.b,Xo),J=n.mul(v,O),ae=n.mul(b,w),ye=n.mul(E,f),he=n.add(v,b),T=n.add(O,w);he=n.mul(he,T),T=n.add(J,ae),he=n.sub(he,T),T=n.add(v,E);let k=n.add(O,f);return T=n.mul(T,k),k=n.add(J,ye),T=n.sub(T,k),k=n.add(b,E),S=n.add(w,f),k=n.mul(k,S),S=n.add(ae,ye),k=n.sub(k,S),F=n.mul(Y,T),S=n.mul($,ye),F=n.add(S,F),S=n.sub(ae,F),F=n.add(ae,F),j=n.mul(S,F),ae=n.add(J,J),ae=n.add(ae,J),ye=n.mul(Y,ye),T=n.mul($,T),ae=n.add(ae,ye),ye=n.sub(J,ye),ye=n.mul(Y,ye),T=n.add(T,ye),J=n.mul(ae,T),j=n.add(j,J),J=n.mul(k,T),S=n.mul(he,S),S=n.sub(S,J),J=n.mul(he,ae),F=n.mul(k,F),F=n.add(F,J),new u(S,j,F)}subtract(p){return X(p),this.add(p.negate())}is0(){return this.equals(u.ZERO)}multiply(p){let{endo:v}=t;if(!i.isValidNot0(p))throw new RangeError("invalid scalar: out of range");let b,E,O=w=>A.cached(this,w,f=>Id(u,f));if(v){let{k1neg:w,k1:f,k2neg:S,k2:j}=oe(p),{p:F,f:Y}=O(f),{p:$,f:J}=O(j);E=Y.add(J),b=ue(v.beta,F,$,w,S)}else{let{p:w,f}=O(p);b=w,E=f}return Id(u,[b,E])[0]}multiplyUnsafe(p){let{endo:v}=t,b=this,E=p;if(!i.isValid(E))throw new RangeError("invalid scalar: out of range");if(E===Ar||b.is0())return u.ZERO;if(E===Lt)return b;if(A.hasCache(this))return this.multiply(E);if(v){let{k1neg:O,k1:w,k2neg:f,k2:S}=oe(E),{p1:j,p2:F}=X_(u,b,w,S);return ue(v.beta,j,F,O,f)}else return A.unsafe(b,E)}toAffine(p){let v=this,b=p,{X:E,Y:O,Z:w}=v;if(n.eql(w,n.ONE))return{x:E,y:O};let f=v.is0();b==null&&(b=f?n.ONE:n.inv(w));let S=n.mul(E,b),j=n.mul(O,b),F=n.mul(w,b);if(f)return{x:n.ZERO,y:n.ZERO};if(!n.eql(F,n.ONE))throw new Error("invZ was invalid");return{x:S,y:j}}isTorsionFree(){let{isTorsionFree:p}=t;return s===Lt?!0:p?p(u,this):A.unsafe(this,a).is0()}clearCofactor(){let{clearCofactor:p}=t;return s===Lt?this:p?p(u,this):this.multiplyUnsafe(s)}isSmallOrder(){return s===Lt?this.is0():this.clearCofactor().is0()}toBytes(p=!0){return Hi(p,"isCompressed"),this.assertValidity(),R(u,this,p)}toHex(p=!0){return Bn(this.toBytes(p))}toString(){return`<Point ${this.is0()?"ZERO":this.toHex()}>`}};C(u,"BASE",new u(o.Gx,o.Gy,n.ONE)),C(u,"ZERO",new u(n.ZERO,n.ONE,n.ZERO)),C(u,"Fp",n),C(u,"Fn",i);let se=u,de=i.BITS,A=new qf(se,t.endo?Math.ceil(de/2):de);return de>=8&&se.BASE.precompute(8),Object.freeze(se.prototype),Object.freeze(se),se}function dw(e){return Uint8Array.of(e?2:3)}function BN(e,t){let r=Gi(e),n=r.ORDER,i=Ar;for(let N=n-Lt;N%an===Ar;N/=an)i+=Lt;let o=i,s=an<<o-Lt-Lt,a=s*an,c=(n-Lt)/a,h=(c-Lt)/an,g=a-Lt,m=s,_=r.pow(t,c),I=r.pow(t,(c+Lt)/an),R=(N,L)=>{let q=_,G=r.pow(L,g),K=r.sqr(G);K=r.mul(K,L);let z=r.mul(N,K);z=r.pow(z,h),z=r.mul(z,G),G=r.mul(z,L),K=r.mul(z,N);let X=r.mul(K,G);z=r.pow(X,m);let oe=r.eql(z,r.ONE);G=r.mul(K,I),z=r.mul(X,q),K=r.cmov(G,K,oe),X=r.cmov(z,X,oe);for(let ue=o;ue>Lt;ue--){let se=ue-an;se=an<<se-Lt;let de=r.pow(X,se),A=r.eql(de,r.ONE);G=r.mul(K,q),q=r.mul(q,q),de=r.mul(X,q),K=r.cmov(G,K,A),X=r.cmov(de,X,A)}return{isValid:!r.is0(L)&&(oe||r.is0(N)),value:K}};if(r.ORDER%Nd===Xo){let N=(r.ORDER-Xo)/Nd,L=r.sqrt(r.neg(t));R=(q,G)=>{let K=r.sqr(G),z=r.mul(q,G);K=r.mul(K,z);let X=r.pow(K,N);X=r.mul(X,z);let oe=r.mul(X,L),ue=r.mul(r.sqr(X),G),se=r.eql(ue,q),de=r.cmov(oe,X,se);return{isValid:!r.is0(G)&&se,value:de}}}return R}function pw(e,t){let r=Gi(e),{A:n,B:i,Z:o}=t;if(!r.isValidNot0(n)||!r.isValidNot0(i)||!r.isValid(o))throw new Error("mapToCurveSimpleSWU: invalid opts");if(r.eql(o,r.neg(r.ONE))||wd(r,o))throw new Error("mapToCurveSimpleSWU: invalid opts");let s=r.mul(i,r.inv(r.mul(o,n))),a=r.add(r.add(r.mul(r.sqr(s),s),r.mul(n,s)),i);if(!wd(r,a))throw new Error("mapToCurveSimpleSWU: invalid opts");let c=BN(r,o);if(!r.isOdd)throw new Error("Field does not have .isOdd()");return h=>{let g,m,_,I,R,N,L,q;g=r.sqr(h),g=r.mul(g,o),m=r.sqr(g),m=r.add(m,g),_=r.add(m,r.ONE),_=r.mul(_,i),I=r.cmov(o,r.neg(m),!r.eql(m,r.ZERO)),I=r.mul(I,n),m=r.sqr(_),N=r.sqr(I),R=r.mul(N,n),m=r.add(m,R),m=r.mul(m,_),N=r.mul(N,I),R=r.mul(N,i),m=r.add(m,R),L=r.mul(g,_);let{isValid:G,value:K}=c(m,N);q=r.mul(g,h),q=r.mul(q,K),L=r.cmov(L,_,G),q=r.cmov(q,K,G);let z=r.isOdd(h)===r.isOdd(q);q=r.cmov(r.neg(q),q,z);let X=Wi(r,[I],!0)[0];return L=r.mul(L,X),{x:L,y:q}}}function gw(e,t){return{secretKey:t.BYTES,publicKey:1+e.BYTES,publicKeyUncompressed:1+2*e.BYTES,publicKeyHasPrefix:!0,signature:2*t.BYTES}}function NN(e,t={}){let{Fn:r}=e,n=t.randomBytes===void 0?ar:t.randomBytes,i=Object.assign(gw(e.Fp,r),{seed:Math.max(sa(r.ORDER),16)});function o(I){try{let R=r.fromBytes(I);return r.isValidNot0(R)}catch{return!1}}function s(I,R){let{publicKey:N,publicKeyUncompressed:L}=i;try{let q=I.length;return R===!0&&q!==N||R===!1&&q!==L?!1:!!e.fromBytes(I)}catch{return!1}}function a(I){return I=I===void 0?n(i.seed):I,zo(Le(I,i.seed,"seed"),r.ORDER)}function c(I,R=!0){return e.BASE.multiply(r.fromBytes(I)).toBytes(R)}function h(I){let{secretKey:R,publicKey:N,publicKeyUncompressed:L}=i,q=r._lengths;if(!qi(I))return;let G=Le(I,void 0,"key").length,K=G===N||G===L,z=G===R||!!q?.includes(G);if(!(K&&z))return K}function g(I,R,N=!0){if(h(I)===!0)throw new Error("first arg must be private key");if(h(R)===!1)throw new Error("second arg must be public key");let L=r.fromBytes(I);return e.fromBytes(R).multiply(L).toBytes(N)}let m={isValidSecretKey:o,isValidPublicKey:s,randomSecretKey:a},_=Hf(a,c);return Object.freeze(m),Object.freeze(i),Object.freeze({getPublicKey:c,getSharedSecret:g,keygen:_,Point:e,utils:m,lengths:i})}function yw(e,t,r={}){let n=t;wf(n),Ir(r,{},{hmac:"function",lowS:"boolean",randomBytes:"function",bits2int:"function",bits2int_modN:"function"}),r=Object.assign({},r);let i=r.randomBytes===void 0?ar:r.randomBytes,o=r.hmac===void 0?(b,E)=>fw(n,b,E):r.hmac,{Fp:s,Fn:a}=e,{ORDER:c,BITS:h}=a,{keygen:g,getPublicKey:m,getSharedSecret:_,utils:I,lengths:R}=NN(e,r),N={prehash:!0,lowS:typeof r.lowS=="boolean"?r.lowS:!0,format:"compact",extraEntropy:!1},L=c*an+Lt<s.ORDER;function q(b){let E=c>>Lt;return b>E}function G(b,E){if(!a.isValidNot0(E))throw new Error(`invalid signature ${b}: out of range 1..Point.Fn.ORDER`);return E}function K(){if(L)throw new Error('"recovered" sig type is not supported for cofactor >2 curves')}function z(b,E){Pd(E);let O=R.signature,w=E==="compact"?O:E==="recovered"?O+1:void 0;return Le(b,w)}class X{constructor(E,O,w){C(this,"r");C(this,"s");C(this,"recovery");if(this.r=G("r",E),this.s=G("s",O),w!=null){if(K(),![0,1,2,3].includes(w))throw new Error("invalid recovery id");this.recovery=w}Object.freeze(this)}static fromBytes(E,O=N.format){z(E,O);let w;if(O==="der"){let{r:F,s:Y}=Dr.toSig(Le(E));return new X(F,Y)}O==="recovered"&&(w=E[0],O="compact",E=E.subarray(1));let f=R.signature/2,S=E.subarray(0,f),j=E.subarray(f,f*2);return new X(a.fromBytes(S),a.fromBytes(j),w)}static fromHex(E,O){return this.fromBytes(jo(E),O)}assertRecovery(){let{recovery:E}=this;if(E==null)throw new Error("invalid recovery id: must be present");return E}addRecoveryBit(E){return new X(this.r,this.s,E)}recoverPublicKey(E){let{r:O,s:w}=this,f=this.assertRecovery(),S=f===2||f===3?O+c:O;if(!s.isValid(S))throw new Error("invalid recovery id: sig.r+curve.n != R.x");let j=s.toBytes(S),F=e.fromBytes(Me(dw((f&1)===0),j)),Y=a.inv(S),$=ue(Le(E,void 0,"msgHash")),J=a.create(-$*Y),ae=a.create(w*Y),ye=e.BASE.multiplyUnsafe(J).add(F.multiplyUnsafe(ae));if(ye.is0())throw new Error("invalid recovery: point at infinify");return ye.assertValidity(),ye}hasHighS(){return q(this.s)}toBytes(E=N.format){if(Pd(E),E==="der")return jo(Dr.hexFromSig(this));let{r:O,s:w}=this,f=a.toBytes(O),S=a.toBytes(w);return E==="recovered"?(K(),Me(Uint8Array.of(this.assertRecovery()),f,S)):Me(f,S)}toHex(E){return Bn(this.toBytes(E))}}Object.freeze(X.prototype),Object.freeze(X);let oe=r.bits2int===void 0?function(E){if(E.length>8192)throw new Error("input is too large");let O=tr(E),w=E.length*8-h;return w>0?O>>BigInt(w):O}:r.bits2int,ue=r.bits2int_modN===void 0?function(E){return a.create(oe(E))}:r.bits2int_modN,se=Go(h);function de(b){return vd("num < 2^"+h,b,Ar,se),a.toBytes(b)}function A(b,E){return Le(b,void 0,"message"),E?Le(n(b),void 0,"prehashed message"):b}function u(b,E,O){let{lowS:w,prehash:f,extraEntropy:S}=Td(O,N);b=A(b,f);let j=ue(b),F=a.fromBytes(E);if(!a.isValidNot0(F))throw new Error("invalid private key");let Y=[de(F),de(j)];if(S!=null&&S!==!1){let ye=S===!0?i(R.secretKey):S;Y.push(Le(ye,void 0,"extraEntropy"))}let $=Me(...Y),J=j;function ae(ye){let he=oe(ye);if(!a.isValidNot0(he))return;let T=a.inv(he),k=e.BASE.multiply(he).toAffine(),H=a.create(k.x);if(H===Ar)return;let V=a.create(T*a.create(J+H*F));if(V===Ar)return;let ne=(k.x===H?0:2)|Number(k.y&Lt),Q=V;return w&&q(V)&&(Q=a.neg(V),ne^=1),new X(H,Q,L?void 0:ne)}return{seed:$,k2sig:ae}}function l(b,E,O={}){let{seed:w,k2sig:f}=u(b,E,O);return k_(n.outputLen,a.BYTES,o)(w,f).toBytes(O.format)}function p(b,E,O,w={}){let{lowS:f,prehash:S,format:j}=Td(w,N);if(O=Le(O,void 0,"publicKey"),E=A(E,S),!qi(b)){let F=b instanceof X?", use sig.toBytes()":"";throw new Error("verify expects Uint8Array signature"+F)}z(b,j);try{let F=X.fromBytes(b,j),Y=e.fromBytes(O);if(f&&F.hasHighS())return!1;let{r:$,s:J}=F,ae=ue(E),ye=a.inv(J),he=a.create(ae*ye),T=a.create($*ye),k=e.BASE.multiplyUnsafe(he).add(Y.multiplyUnsafe(T));return k.is0()?!1:a.create(k.x)===$}catch{return!1}}function v(b,E,O={}){let{prehash:w}=Td(O,N);return E=A(E,w),X.fromBytes(b,"recovered").recoverPublicKey(E).toBytes()}return Object.freeze({keygen:g,getPublicKey:m,getSharedSecret:_,utils:I,lengths:R,Point:e,sign:l,verify:p,recoverPublicKey:v,Signature:X,hash:n})}var lw,Bd,Dr,Ar,Lt,an,Xo,Nd,mw=er(()=>{y();cw();On();Ki();jf();Yo();lw=(e,t)=>(e+(e>=0?t:-t)/an)/t;Bd=class extends Error{constructor(t=""){super(t)}},Dr={Err:Bd,_tlv:{encode:(e,t)=>{let{Err:r}=Dr;if(xr(e,"tag"),e<0||e>255)throw new r("tlv.encode: wrong tag");if(typeof t!="string")throw new TypeError('"data" expected string, got type='+typeof t);if(t.length&1)throw new r("tlv.encode: unpadded data");let n=t.length/2,i=oa(n);if(i.length/2&128)throw new r("tlv.encode: long form length too big");let o=n>127?oa(i.length/2|128):"";return oa(e)+o+i+t},decode(e,t){let{Err:r}=Dr;t=Le(t,void 0,"DER data");let n=0;if(e<0||e>255)throw new r("tlv.encode: wrong tag");if(t.length<2||t[n++]!==e)throw new r("tlv.decode: wrong tlv");let i=t[n++],o=!!(i&128),s=0;if(!o)s=i;else{let c=i&127;if(!c)throw new r("tlv.decode(long): indefinite length not supported");if(c>4)throw new r("tlv.decode(long): byte length is too big");let h=t.subarray(n,n+c);if(h.length!==c)throw new r("tlv.decode: length bytes not complete");if(h[0]===0)throw new r("tlv.decode(long): zero leftmost byte");for(let g of h)s=s<<8|g;if(n+=c,s<128)throw new r("tlv.decode(long): not minimal encoding")}let a=t.subarray(n,n+s);if(a.length!==s)throw new r("tlv.decode: wrong value length");return{v:a,l:t.subarray(n+s)}}},_int:{encode(e){let{Err:t}=Dr;if(Lf(e),e<Ar)throw new t("integer: negative integers are not allowed");let r=oa(e);if(Number.parseInt(r[0],16)&8&&(r="00"+r),r.length&1)throw new t("unexpected DER parsing assertion: unpadded hex");return r},decode(e){let{Err:t}=Dr;if(e.length<1)throw new t("invalid signature integer: empty");if(e[0]&128)throw new t("invalid signature integer: negative");if(e.length>1&&e[0]===0&&!(e[1]&128))throw new t("invalid signature integer: unnecessary leading zero");return tr(e)}},toSig(e){let{Err:t,_int:r,_tlv:n}=Dr,i=Le(e,void 0,"signature"),{v:o,l:s}=n.decode(48,i);if(s.length)throw new t("invalid signature: left bytes after parsing");let{v:a,l:c}=n.decode(2,o),{v:h,l:g}=n.decode(2,c);if(g.length)throw new t("invalid signature: left bytes after parsing");return{r:r.decode(a),s:r.decode(h)}},hexFromSig(e){let{_tlv:t,_int:r}=Dr,n=t.encode(2,r.encode(e.r)),i=t.encode(2,r.encode(e.s)),o=n+i;return t.encode(48,o)}};Object.freeze(Dr._tlv);Object.freeze(Dr._int);Object.freeze(Dr);Ar=BigInt(0),Lt=BigInt(1),an=BigInt(2),Xo=BigInt(3),Nd=BigInt(4)});var Aw={};al(Aw,{__TEST:()=>DN,schnorr:()=>UN,schnorr_FROST:()=>GN,secp256k1:()=>CN,secp256k1_FROST:()=>HN,secp256k1_hasher:()=>Cd});function kN(e){let t=Gf.p,r=BigInt(3),n=BigInt(6),i=BigInt(11),o=BigInt(22),s=BigInt(23),a=BigInt(44),c=BigInt(88),h=e*e*e%t,g=h*h*e%t,m=dr(g,r,t)*g%t,_=dr(m,r,t)*g%t,I=dr(_,Md,t)*h%t,R=dr(I,i,t)*I%t,N=dr(R,o,t)*R%t,L=dr(N,a,t)*N%t,q=dr(L,c,t)*L%t,G=dr(q,a,t)*N%t,K=dr(G,r,t)*g%t,z=dr(K,s,t)*R%t,X=dr(z,n,t)*h%t,oe=dr(X,Md,t);if(!Nn.eql(Nn.sqr(oe),e))throw new Error("Cannot find square root");return oe}function ua(e,...t){let r=vw[e];if(r===void 0){let n=ni(Vo(e));r=Me(n,n),vw[e]=r}return ni(Me(r,...t))}function Sw(e){let{Fn:t,BASE:r}=Ue,n=t.fromBytes(e),i=r.multiply(n);return{scalar:un(i.y)?n:t.neg(n),bytes:$i(i)}}function Wf(e){let t=Nn;if(!t.isValidNot0(e))throw new Error("invalid x: Fail if x \u2265 p");let r=t.create(e*e),n=t.create(r*e+BigInt(7)),i=t.sqrt(n);un(i)||(i=t.neg(i));let o=Ue.fromAffine({x:e,y:i});return o.assertValidity(),o}function kd(...e){return Ue.Fn.create(Jo(ua("BIP0340/challenge",...e)))}function bw(e){return Sw(e).bytes}function LN(e,t,r=ra(32)){let{Fn:n,BASE:i}=Ue,o=Le(e,void 0,"message"),{bytes:s,scalar:a}=Sw(t),c=Le(r,32,"auxRand"),h=n.toBytes(a^Jo(ua("BIP0340/aux",c))),g=ua("BIP0340/nonce",h,s,o),m=n.create(Jo(g));if(m===0n)throw new Error("sign failed: k is zero");let _=i.multiply(m),I=un(_.y)?m:n.neg(m),R=$i(_),N=kd(R,s,o),L=new Uint8Array(64);if(L.set(R,0),L.set(n.toBytes(n.create(I+N*a)),32),!Ew(L,o,s))throw new Error("sign: Invalid signature produced");return L}function Ew(e,t,r){let{Fp:n,Fn:i,BASE:o}=Ue,s=Le(e,64,"signature"),a=Le(t,void 0,"message"),c=Le(r,32,"publicKey");try{let h=Wf(Jo(c)),g=Jo(s.subarray(0,32));if(!n.isValidNot0(g))return!1;let m=Jo(s.subarray(32,64));if(!i.isValidNot0(m))return!1;let _=kd(i.toBytes(g),$i(h),a),I=o.multiplyUnsafe(m).add(h.multiplyUnsafe(i.neg(_))),{x:R,y:N}=I.toAffine();return!(I.is0()||!un(N)||R!==g)}catch{return!1}}function xw(e,t){if(t===void 0)return ww;let r=$i(e),n=tr(ua("TapTweak",r,t));if(!Ue.Fn.isValid(n))throw new Error("invalid TapTweak hash");return n}function Ld(e){let t=Ue.fromBytes(e.commitments[0]);return un(t.y)?e:{signers:{min:e.signers.min,max:e.signers.max},commitments:e.commitments.map(r=>Ue.fromBytes(r).negate().toBytes()),verifyingShares:Object.fromEntries(Object.entries(e.verifyingShares).map(([r,n])=>[r,Ue.fromBytes(n).negate().toBytes()]))}}function Iw(e,t){let r=Ue.fromBytes(t.commitments[0]);if(un(r.y))return e;let n=Ue.Fn;return{...e,signingShare:n.toBytes(n.neg(n.fromBytes(e.signingShare)))}}function jN(e,t){if(un(e.y))return t;let r=Ue.Fn;return{binding:r.toBytes(r.neg(r.fromBytes(t.binding))),hiding:r.toBytes(r.neg(r.fromBytes(t.hiding)))}}function KN(e,t,r){let n=Ue.Fn,i=Iw(e,t),o=Ld(t),s=xw(Ue.fromBytes(o.commitments[0]),r),a=n.toBytes(n.add(n.fromBytes(i.signingShare),s));return{identifier:i.identifier,signingShare:a}}function VN(e,t){let r=Ld(e),n=xw(Ue.fromBytes(r.commitments[0]),t),i=Ue.BASE.multiply(n),o=r.commitments.map((a,c)=>(c===0?Ue.fromBytes(a).add(i):Ue.fromBytes(a)).toBytes()),s={};for(let a in r.verifyingShares)s[a]=Ue.fromBytes(r.verifyingShares[a]).add(i).toBytes();return{signers:{min:r.signers.min,max:r.signers.max},commitments:o,verifyingShares:s}}var Gf,MN,ww,Md,Nn,Ue,CN,vw,$i,un,Jo,DN,UN,FN,_w,qN,Cd,HN,GN,Ow=er(()=>{y();pd();On();jf();uw();sw();Yo();mw();Ki();Gf={p:BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),n:BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),h:BigInt(1),a:BigInt(0),b:BigInt(7),Gx:BigInt("0x79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"),Gy:BigInt("0x483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8")},MN={beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),basises:[[BigInt("0x3086d221a7d46bcde86c90e49284eb15"),-BigInt("0xe4437ed6010e88286f547fa90abfe4c3")],[BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),BigInt("0x3086d221a7d46bcde86c90e49284eb15")]]},ww=BigInt(0),Md=BigInt(2);Nn=Wo(Gf.p,{sqrt:kN}),Ue=hw(Gf,{Fp:Nn,endo:MN}),CN=yw(Ue,ni),vw={};$i=e=>e.toBytes(!0).slice(1),un=e=>e%Md===ww;Jo=tr;DN=Object.freeze({lift_x:Wf}),UN=(()=>{let r=n=>(n=n===void 0?ra(48):n,zo(n,Gf.n));return Object.freeze({keygen:Hf(r,bw),getPublicKey:bw,sign:LN,verify:Ew,Point:Ue,utils:Object.freeze({randomSecretKey:r,taggedHash:ua,lift_x:Wf,pointToBytes:$i}),lengths:Object.freeze({secretKey:32,publicKey:32,publicKeyHasPrefix:!1,signature:64,seed:48})})})(),FN=iw(Nn,[["0x8e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38daaaaa8c7","0x7d3d4c80bc321d5b9f315cea7fd44c5d595d2fc0bf63b92dfff1044f17c6581","0x534c328d23f234e6e2a413deca25caece4506144037c40314ecbd0b53d9dd262","0x8e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38daaaaa88c"],["0xd35771193d94918a9ca34ccbb7b640dd86cd409542f8487d9fe6b745781eb49b","0xedadc6f64383dc1df7c4b2d51b54225406d36b641f5e41bbc52a56612a8c6d14","0x0000000000000000000000000000000000000000000000000000000000000001"],["0x4bda12f684bda12f684bda12f684bda12f684bda12f684bda12f684b8e38e23c","0xc75e0c32d5cb7c0fa9d0a54b12a0a6d5647ab046d686da6fdffc90fc201d71a3","0x29a6194691f91a73715209ef6512e576722830a201be2018a765e85a9ecee931","0x2f684bda12f684bda12f684bda12f684bda12f684bda12f684bda12f38e38d84"],["0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffff93b","0x7a06534bb8bdb49fd5e9e6632722c2989467c1bfc8e8d978dfb425d2685c2573","0x6484aa716545ca2cf3a70c3fa8fe337e0a3d21162f0d6299a7bf8192bfd2a76f","0x0000000000000000000000000000000000000000000000000000000000000001"]].map(e=>e.map(t=>BigInt(t)))),qN=()=>_w||(_w=pw(Nn,{A:BigInt("0x3f8731abdd661adca08a5558f0f5d272e953d363cb6f0e5d405447c01a444533"),B:BigInt("1771"),Z:Nn.create(BigInt("-11"))})),Cd=ow(Ue,e=>{let{x:t,y:r}=qN()(Nn.create(e[0]));return FN(t,r)},{DST:"secp256k1_XMD:SHA-256_SSWU_RO_",encodeDST:"secp256k1_XMD:SHA-256_SSWU_NU_",p:Nn.ORDER,m:1,k:128,expand:"xmd",hash:ni}),HN=Rd({name:"FROST-secp256k1-SHA256-v1",Point:Ue,hashToScalar:Cd.hashToScalar,hash:ni});GN=Rd({name:"FROST-secp256k1-SHA256-TR-v1",Point:Ue,hashToScalar:Cd.hashToScalar,hash:ni,parsePublicKey(e){if(e.length===32)return Wf(tr(e));if(e.length===33)return Ue.fromBytes(e);throw new Error(`expected x-only or compressed public key, got length=${e.length}`)},adjustScalar(e){let t=Ue.BASE.multiply(e);return un(t.y)?e:Ue.Fn.neg(e)},adjustPoint:e=>un(e.y)?e:e.negate(),challenge(e,t,r){return kd($i(e),$i(t),r)},adjustNonces:jN,adjustGroupCommitmentShare:(e,t)=>un(e.y)?t:t.negate(),adjustPublic:Ld,adjustSecret:Iw,adjustTx:{encode:e=>e.subarray(1),decode:e=>Me(Uint8Array.of(2),e)},adjustDKG:e=>{let t=new Uint8Array(0);return{public:VN(e.public,t),secret:KN(e.secret,e.public,t)}}})});var ii=P((wU,Bw)=>{"use strict";y();var Rw=Er(),{secp256k1:WN}=(Ow(),ul(Aw)),ca=WN.Point,zf=ca.Fn.ORDER;function zN(e){return BigInt("0x"+(e.toString(16)||"0"))}function Dd(e){var t=e.toString(16);return t.length%2&&(t="0"+t),new Rw(t,16)}function Yf(e){if(e==null)throw new Error("Invalid Point");if(typeof e=="bigint")return e;if(typeof e=="number")return BigInt(e);if(typeof e=="string")return BigInt(e.indexOf("0x")===0?e:"0x"+e);if(typeof e.toString=="function")return zN(e);throw new Error("Invalid Point")}function fa(e){var t=Object.create(Fe.prototype);return t._p=e,t}function Tw(e,t){var r=Yf(t).toString(16).padStart(64,"0");return ca.fromHex((e?"03":"02")+r)}function Pw(e,t){var r;try{r=Tw((t&1n)===1n,e)}catch{throw new Error("Point does not lie on the curve")}if(r.toAffine().y!==t)throw new Error("Invalid y value for curve.")}function Fe(e,t,r){if(!(this instanceof Fe))return new Fe(e,t,r);var n,i;try{n=Yf(e),i=Yf(t)}catch{throw new Error("Invalid Point")}Pw(n,i);try{this._p=ca.fromAffine({x:n,y:i})}catch{throw new Error("Invalid Point")}return this}Fe.fromX=function(t,r){try{var n=fa(Tw(t,r))}catch{throw new Error("Invalid X")}return n.validate(),n};Fe.getG=function(){return fa(ca.BASE)};Fe.getN=function(){return Dd(zf)};Fe.prototype.getX=function(){return Dd(this._p.toAffine().x)};Fe.prototype.getY=function(){return Dd(this._p.toAffine().y)};Object.defineProperty(Fe.prototype,"x",{configurable:!0,enumerable:!0,get:function(){return this.getX()}});Object.defineProperty(Fe.prototype,"y",{configurable:!0,enumerable:!0,get:function(){return this.getY()}});Fe.prototype.mul=function(t){var r=(Yf(t)%zf+zf)%zf;return r===0n||this._p.is0()?fa(ca.ZERO):fa(this._p.multiply(r))};Fe.prototype.add=function(t){return fa(this._p.add(t._p))};Fe.prototype.mulAdd=function(t,r,n){return this.mul(t).add(r.mul(n))};Fe.prototype.eq=function(t){return this._p.equals(t._p)};Fe.prototype.isInfinity=function(){return this._p.is0()};Fe.prototype.validate=function(){if(this.isInfinity())throw new Error("Point cannot be equal to Infinity");var t=this._p.toAffine();return Pw(t.x,t.y),this};Fe.pointToCompressed=function(t){var r=t.getX().toBuffer({size:32}),n=t.getY().toBuffer({size:32}),i,o=n[n.length-1]%2;return o?i=d.Buffer.from([3]):i=d.Buffer.from([2]),d.Buffer.concat([i,r])};Fe.pointFromCompressed=function(e){if(e.length!==33)throw new Error("invalid buffer length");var t=e[0],r;if(t===3)r=!0;else if(t===2)r=!1;else throw new Error("invalid value of compressed prefix");var n=Rw.fromBuffer(e.slice(1,33));return Fe.fromX(r,n)};Fe.prototype.toBuffer=function(){return Fe.pointToCompressed(this)};Fe.prototype.toHex=function(){return this.toBuffer().toString("hex")};Fe.fromBuffer=function(e){return Fe.pointFromCompressed(e)};Fe.fromHex=function(e){return Fe.fromBuffer(d.Buffer.from(e,"hex"))};Bw.exports=Fe});var Mw=P((EU,Nw)=>{"use strict";y();var $f=Qs(),Mn=ke(),It=Nw.exports;It.sha1=function(e){return Mn.checkArgument(d.Buffer.isBuffer(e)),$f.createHash("sha1").update(e).digest()};It.sha1.blocksize=512;It.sha256=function(e){return Mn.checkArgument(d.Buffer.isBuffer(e)),$f.createHash("sha256").update(e).digest()};It.sha256.blocksize=512;It.sha256sha256=function(e){return Mn.checkArgument(d.Buffer.isBuffer(e)),It.sha256(It.sha256(e))};It.ripemd160=function(e){return Mn.checkArgument(d.Buffer.isBuffer(e)),$f.createHash("ripemd160").update(e).digest()};It.sha256ripemd160=function(e){return Mn.checkArgument(d.Buffer.isBuffer(e)),It.ripemd160(It.sha256(e))};It.sha512=function(e){return Mn.checkArgument(d.Buffer.isBuffer(e)),$f.createHash("sha512").update(e).digest()};It.sha512.blocksize=1024;It.hmac=function(e,t,r){Mn.checkArgument(d.Buffer.isBuffer(t)),Mn.checkArgument(d.Buffer.isBuffer(r)),Mn.checkArgument(e.blocksize);var n=e.blocksize/8;if(r.length>n)r=e(r);else if(r.length<n){var i=d.Buffer.alloc(n);i.fill(0),r.copy(i),r=i}var o=d.Buffer.alloc(n);o.fill(92);var s=d.Buffer.alloc(n);s.fill(54);for(var a=d.Buffer.alloc(n),c=d.Buffer.alloc(n),h=0;h<n;h++)a[h]=o[h]^r[h],c[h]=s[h]^r[h];return e(d.Buffer.concat([a,e(d.Buffer.concat([c,t]))]))};It.sha256hmac=function(e,t){return It.hmac(It.sha256,e,t)};It.sha512hmac=function(e,t){return It.hmac(It.sha512,e,t)}});var qw={};al(qw,{_MD5:()=>Qf,_RIPEMD160:()=>ec,_SHA1:()=>Jf,md5:()=>XN,ripemd160:()=>iM,sha1:()=>YN});function kw(e,t,r,n){return e===0?t^r^n:e===1?t&r|~t&n:e===2?(t|~r)^n:e===3?t&n|r&~n:t^(r|~n)}var Qo,oi,Jf,YN,$N,ZN,Zf,Ud,Qf,XN,JN,Cw,QN,Lw,Dw,Uw,Fw,eM,tM,rM,nM,Xf,ec,iM,Hw=er(()=>{y();ld();On();Qo=Uint32Array.from([1732584193,4023233417,2562383102,271733878,3285377520]),oi=new Uint32Array(80),Jf=class extends Rn{constructor(){super(64,20,8,!1);C(this,"A",Qo[0]|0);C(this,"B",Qo[1]|0);C(this,"C",Qo[2]|0);C(this,"D",Qo[3]|0);C(this,"E",Qo[4]|0)}get(){let{A:r,B:n,C:i,D:o,E:s}=this;return[r,n,i,o,s]}set(r,n,i,o,s){this.A=r|0,this.B=n|0,this.C=i|0,this.D=o|0,this.E=s|0}process(r,n){for(let h=0;h<16;h++,n+=4)oi[h]=r.getUint32(n,!1);for(let h=16;h<80;h++)oi[h]=In(oi[h-3]^oi[h-8]^oi[h-14]^oi[h-16],1);let{A:i,B:o,C:s,D:a,E:c}=this;for(let h=0;h<80;h++){let g,m;h<20?(g=qo(o,s,a),m=1518500249):h<40?(g=o^s^a,m=1859775393):h<60?(g=If(o,s,a),m=2400959708):(g=o^s^a,m=3395469782);let _=In(i,5)+g+c+m+oi[h]|0;c=a,a=s,s=In(o,30),o=i,i=_}i=i+this.A|0,o=o+this.B|0,s=s+this.C|0,a=a+this.D|0,c=c+this.E|0,this.set(i,o,s,a,c)}roundClean(){Zt(oi)}destroy(){this.destroyed=!0,this.set(0,0,0,0,0),Zt(this.buffer)}},YN=Lr(()=>new Jf),$N=Math.pow(2,32),ZN=Array.from({length:64},(e,t)=>Math.floor($N*Math.abs(Math.sin(t+1)))),Zf=Qo.slice(0,4),Ud=new Uint32Array(16),Qf=class extends Rn{constructor(){super(64,16,8,!0);C(this,"A",Zf[0]|0);C(this,"B",Zf[1]|0);C(this,"C",Zf[2]|0);C(this,"D",Zf[3]|0)}get(){let{A:r,B:n,C:i,D:o}=this;return[r,n,i,o]}set(r,n,i,o){this.A=r|0,this.B=n|0,this.C=i|0,this.D=o|0}process(r,n){for(let c=0;c<16;c++,n+=4)Ud[c]=r.getUint32(n,!0);let{A:i,B:o,C:s,D:a}=this;for(let c=0;c<64;c++){let h,g,m;c<16?(h=qo(o,s,a),g=c,m=[7,12,17,22]):c<32?(h=qo(a,o,s),g=(5*c+1)%16,m=[5,9,14,20]):c<48?(h=o^s^a,g=(3*c+5)%16,m=[4,11,16,23]):(h=s^(o|~a),g=7*c%16,m=[6,10,15,21]),h=h+i+ZN[c]+Ud[g],i=a,a=s,s=o,o=o+In(h,m[c%4])}i=i+this.A|0,o=o+this.B|0,s=s+this.C|0,a=a+this.D|0,this.set(i,o,s,a)}roundClean(){Zt(Ud)}destroy(){this.destroyed=!0,this.set(0,0,0,0),Zt(this.buffer)}},XN=Lr(()=>new Qf),JN=Uint8Array.from([7,4,13,1,10,6,15,3,12,0,9,5,2,14,11,8]),Cw=Uint8Array.from(new Array(16).fill(0).map((e,t)=>t)),QN=Cw.map(e=>(9*e+5)%16),Lw=(()=>{let r=[[Cw],[QN]];for(let n=0;n<4;n++)for(let i of r)i.push(i[n].map(o=>JN[o]));return r})(),Dw=Lw[0],Uw=Lw[1],Fw=[[11,14,15,12,5,8,7,9,11,13,14,15,6,7,9,8],[12,13,11,15,6,9,9,7,12,15,11,13,7,8,7,7],[13,15,14,11,7,7,6,8,13,14,13,12,5,5,6,9],[14,11,12,14,8,6,5,5,15,12,15,14,9,9,8,6],[15,12,13,13,9,5,8,6,14,11,12,11,8,6,5,5]].map(e=>Uint8Array.from(e)),eM=Dw.map((e,t)=>e.map(r=>Fw[t][r])),tM=Uw.map((e,t)=>e.map(r=>Fw[t][r])),rM=Uint32Array.from([0,1518500249,1859775393,2400959708,2840853838]),nM=Uint32Array.from([1352829926,1548603684,1836072691,2053994217,0]);Xf=new Uint32Array(16),ec=class extends Rn{constructor(){super(64,20,8,!0);C(this,"h0",1732584193);C(this,"h1",-271733879);C(this,"h2",-1732584194);C(this,"h3",271733878);C(this,"h4",-1009589776)}get(){let{h0:r,h1:n,h2:i,h3:o,h4:s}=this;return[r,n,i,o,s]}set(r,n,i,o,s){this.h0=r|0,this.h1=n|0,this.h2=i|0,this.h3=o|0,this.h4=s|0}process(r,n){for(let R=0;R<16;R++,n+=4)Xf[R]=r.getUint32(n,!0);let i=this.h0|0,o=i,s=this.h1|0,a=s,c=this.h2|0,h=c,g=this.h3|0,m=g,_=this.h4|0,I=_;for(let R=0;R<5;R++){let N=4-R,L=rM[R],q=nM[R],G=Dw[R],K=Uw[R],z=eM[R],X=tM[R];for(let oe=0;oe<16;oe++){let ue=In(i+kw(R,s,c,g)+Xf[G[oe]]+L,z[oe])+_|0;i=_,_=g,g=In(c,10)|0,c=s,s=ue}for(let oe=0;oe<16;oe++){let ue=In(o+kw(N,a,h,m)+Xf[K[oe]]+q,X[oe])+I|0;o=I,I=m,m=In(h,10)|0,h=a,a=ue}}this.set(this.h1+c+m|0,this.h2+g+I|0,this.h3+_+o|0,this.h4+i+a|0,this.h0+s+h|0)}roundClean(){Zt(Xf)}destroy(){this.destroyed=!0,Zt(this.buffer),this.set(0,0,0,0,0)}},iM=Lr(()=>new ec)});var Kw=P((TU,jw)=>{"use strict";y();var{sha256:oM,sha512:sM}=(pd(),ul(N_)),{sha1:aM,ripemd160:uM}=(Hw(),ul(qw)),kn=ke(),At=jw.exports;At.sha1=function(e){return kn.checkArgument(d.Buffer.isBuffer(e)),d.Buffer.from(aM(e))};At.sha1.blocksize=512;At.sha256=function(e){return kn.checkArgument(d.Buffer.isBuffer(e)),d.Buffer.from(oM(e))};At.sha256.blocksize=512;At.sha256sha256=function(e){return kn.checkArgument(d.Buffer.isBuffer(e)),At.sha256(At.sha256(e))};At.ripemd160=function(e){return kn.checkArgument(d.Buffer.isBuffer(e)),d.Buffer.from(uM(e))};At.sha256ripemd160=function(e){return kn.checkArgument(d.Buffer.isBuffer(e)),At.ripemd160(At.sha256(e))};At.sha512=function(e){return kn.checkArgument(d.Buffer.isBuffer(e)),d.Buffer.from(sM(e))};At.sha512.blocksize=1024;At.hmac=function(e,t,r){kn.checkArgument(d.Buffer.isBuffer(t)),kn.checkArgument(d.Buffer.isBuffer(r)),kn.checkArgument(e.blocksize);var n=e.blocksize/8;if(r.length>n)r=e(r);else if(r.length<n){var i=d.Buffer.alloc(n);i.fill(0),r.copy(i),r=i}var o=d.Buffer.alloc(n);o.fill(92);var s=d.Buffer.alloc(n);s.fill(54);for(var a=d.Buffer.alloc(n),c=d.Buffer.alloc(n),h=0;h<n;h++)a[h]=o[h]^r[h],c[h]=s[h]^r[h];return e(d.Buffer.concat([a,e(d.Buffer.concat([c,t]))]))};At.sha256hmac=function(e,t){return At.hmac(At.sha256,e,t)};At.sha512hmac=function(e,t){return At.hmac(At.sha512,e,t)}});var Qt=P((BU,Gw)=>{"use strict";y();var Vw={sha1:"a9993e364706816aba3e25717850c26c9cd0d89d",sha256:"ba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad",sha512:"ddaf35a193617abacc417349ae20413112e6fa4e89a97ea20a9eeee64b55d39a2192992a274fc1a836ba3c23a3feebbd454d4423643ce80e2a9ac94fa54ca49f",ripemd160:"8eb208f7e05d987a9b044a8e98c6b087f15a0bfc"};function fM(){var e;try{e=Qs()}catch{return!1}if(!e||typeof e.createHash!="function")return!1;for(var t=Object.keys(Vw),r=0;r<t.length;r++){var n=t[r];try{if(e.createHash(n).update("abc").digest("hex")!==Vw[n])return!1}catch{return!1}}return!0}Gw.exports=fM()?Mw():Kw()});var pr=P((MU,Yw)=>{"use strict";y();var zw=Ve(),cM=ke(),Ww=function(t){return zw.isString(t)?/^[0-9a-fA-F]+$/.test(t):!1};Yw.exports={isValidJSON:function(t){var r;if(!zw.isString(t))return!1;try{r=JSON.parse(t)}catch{return!1}return typeof r=="object"},isHexa:Ww,isHexaString:Ww,defineImmutable:function(t,r){return Object.keys(r).forEach(function(n){Object.defineProperty(t,n,{configurable:!1,enumerable:!0,value:r[n]})}),t},isNaturalNumber:function(t){return typeof t=="number"&&isFinite(t)&&Math.floor(t)===t&&t>=0},integerAsBuffer:function(t){cM.checkArgumentType(t,"number","integer");let r=d.Buffer.allocUnsafe(4);return r.writeUInt32BE(t,0),r}}});var ga=P((CU,Xw)=>{"use strict";y();var Cn=Ve(),la=pr(),Zi=[],ha={};function $w(){}$w.prototype.toString=function(){return this.name};function da(e,t){if(~Zi.indexOf(e))return e;if(t){Cn.isArray(t)||(t=[t]);for(var r=0;r<Zi.length;r++){var n=Zi[r],i=Cn.pick(n,t),o=Cn.values(i);if(~o.indexOf(e))return n}return}return ha[e]}function tc(e){for(var t=[],r=0;r<e.length;r++)t.push(e.charCodeAt(r)&31);return t}function pa(e){var t=new $w;la.defineImmutable(t,{name:e.name,alias:e.alias,pubkeyhash:e.pubkeyhash,privatekey:e.privatekey,scripthash:e.scripthash,xpubkey:e.xpubkey,xprivkey:e.xprivkey});var r=e.indexBy||Object.keys(e);return e.cashAddrPrefix&&Cn.extend(t,{cashAddrPrefix:e.cashAddrPrefix,cashAddrPrefixArray:tc(e.cashAddrPrefix)}),e.networkMagic&&Cn.extend(t,{networkMagic:la.integerAsBuffer(e.networkMagic)}),e.port&&Cn.extend(t,{port:e.port}),e.dnsSeeds&&Cn.extend(t,{dnsSeeds:e.dnsSeeds}),Zi.push(t),lM(t,r),t}function lM(e,t){for(var r=0;r<t.length;r++){var n=t[r],i=e[n];!Cn.isUndefined(i)&&!Cn.isObject(i)&&(ha[i]=e)}}function hM(e,t){for(var r=0;r<t.length;r++){var n=t[r];ha[n]===e&&delete ha[n]}}function dM(e){for(var t=0;t<Zi.length;t++)Zi[t]===e&&Zi.splice(t,1);hM(e,Object.keys(ha))}var rc={livenet:3823236072,testnet:4108710900,regtest:3669344250,stn:4224632057},Zw=["seed.bitcoinsv.org","seed.bitcoinunlimited.info"],si={PORT:18333,NETWORK_MAGIC:rc.testnet,DNS_SEEDS:Zw,PREFIX:"testnet",CASHADDRPREFIX:"bchtest"},Ln={PORT:18444,NETWORK_MAGIC:rc.regtest,DNS_SEEDS:[],PREFIX:"regtest",CASHADDRPREFIX:"bchreg"},ai={PORT:9333,NETWORK_MAGIC:rc.stn,DNS_SEEDS:["stn-seed.bitcoinsv.io"],PREFIX:"stn",CASHADDRPREFIX:"bsvstn"},pM={name:"livenet",alias:"mainnet",prefix:"bitcoin",cashAddrPrefix:"bitcoincash",pubkeyhash:0,privatekey:128,scripthash:5,xpubkey:76067358,xprivkey:76066276,networkMagic:rc.livenet,port:8333,dnsSeeds:Zw},gM={name:"testnet",prefix:si.PREFIX,cashAddrPrefix:si.CASHADDRPREFIX,pubkeyhash:111,privatekey:239,scripthash:196,xpubkey:70617039,xprivkey:70615956,networkMagic:si.NETWORK_MAGIC},yM={name:"regtest",prefix:Ln.PREFIX,cashAddrPrefix:Ln.CASHADDRPREFIX,pubkeyhash:111,privatekey:239,scripthash:196,xpubkey:70617039,xprivkey:70615956,networkMagic:Ln.NETWORK_MAGIC,port:Ln.PORT,dnsSeeds:[],indexBy:["port","name","cashAddrPrefix","networkMagic"]},mM={name:"stn",prefix:ai.PREFIX,cashAddrPrefix:ai.CASHADDRPREFIX,pubkeyhash:111,privatekey:239,scripthash:196,xpubkey:70617039,xprivkey:70615956,networkMagic:ai.NETWORK_MAGIC,indexBy:["port","name","cashAddrPrefix","networkMagic"]};pa(gM);pa(mM);pa(yM);pa(pM);var Fd=da("livenet"),vM=da("regtest"),fn=da("testnet"),bM=da("stn");Object.defineProperty(fn,"port",{enumerable:!0,configurable:!1,get:function(){return this.regtestEnabled?Ln.PORT:this.stnEnabled?ai.PORT:si.PORT}});Object.defineProperty(fn,"networkMagic",{enumerable:!0,configurable:!1,get:function(){return this.regtestEnabled?la.integerAsBuffer(Ln.NETWORK_MAGIC):this.stnEnabled?la.integerAsBuffer(ai.NETWORK_MAGIC):la.integerAsBuffer(si.NETWORK_MAGIC)}});Object.defineProperty(fn,"dnsSeeds",{enumerable:!0,configurable:!1,get:function(){return this.regtestEnabled?Ln.DNS_SEEDS:this.stnEnabled?ai.DNS_SEEDS:si.DNS_SEEDS}});Object.defineProperty(fn,"cashAddrPrefix",{enumerable:!0,configurable:!1,get:function(){return this.regtestEnabled?Ln.CASHADDRPREFIX:this.stnEnabled?ai.CASHADDRPREFIX:si.CASHADDRPREFIX}});Object.defineProperty(fn,"cashAddrPrefixArray",{enumerable:!0,configurable:!1,get:function(){return this.regtestEnabled?tc(Ln.CASHADDRPREFIX):this.stnEnabled?tc(ai.CASHADDRPREFIX):tc(si.CASHADDRPREFIX)}});function _M(){fn.regtestEnabled=!0}function wM(){fn.regtestEnabled=!1}function SM(){fn.stnEnabled=!0}function EM(){fn.stnEnabled=!1}Xw.exports={add:pa,remove:dM,defaultNetwork:Fd,livenet:Fd,mainnet:Fd,testnet:fn,regtest:vM,stn:bM,get:da,enableRegtest:_M,disableRegtest:wM,enableStn:SM,disableStn:EM}});var tS=P((DU,eS)=>{"use strict";y();var qd=Ve(),Jw=Tt(),es="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz".split(""),Qw={};for(ya=0;ya<es.length;ya++)Qw[es[ya]]=ya;var ya;function xM(e){if(e.length===0)return"";var t=[0],r,n,i;for(r=0;r<e.length;r++){for(n=0,i=e[r];n<t.length;n++)i+=t[n]<<8,t[n]=i%58,i=i/58|0;for(;i>0;)t.push(i%58),i=i/58|0}var o="";for(r=0;e[r]===0&&r<e.length-1;r++)o+=es[0];for(r=t.length-1;r>=0;r--)o+=es[t[r]];return o}function IM(e){if(e.length===0)return d.Buffer.alloc(0);var t=[0],r,n,i;for(r=0;r<e.length;r++){var o=Qw[e[r]];if(o===void 0)throw new Error("Non-base58 character");for(n=0,i=o;n<t.length;n++)i+=t[n]*58,t[n]=i&255,i>>=8;for(;i>0;)t.push(i&255),i>>=8}for(r=0;e[r]===es[0]&&r<e.length-1;r++)t.push(0);return d.Buffer.from(t.reverse())}var Dt=function e(t){if(!(this instanceof e))return new e(t);if(d.Buffer.isBuffer(t)){var r=t;this.fromBuffer(r)}else if(typeof t=="string"){var n=t;this.fromString(n)}};Dt.validCharacters=function(t){return Jw.Buffer.isBuffer(t)&&(t=t.toString()),qd.every(qd.map(t,function(r){return qd.includes(es,r)}))};Dt.prototype.set=function(e){return this.buf=e.buf||this.buf||void 0,this};Dt.encode=function(e){if(!Jw.Buffer.isBuffer(e))throw new Error("Input should be a buffer");return xM(e)};Dt.decode=function(e){if(typeof e!="string")throw new Error("Input should be a string");return IM(e)};Dt.prototype.fromBuffer=function(e){return this.buf=e,this};Dt.fromBuffer=function(e){return new Dt().fromBuffer(e)};Dt.fromHex=function(e){return Dt.fromBuffer(d.Buffer.from(e,"hex"))};Dt.prototype.fromString=function(e){var t=Dt.decode(e);return this.buf=t,this};Dt.fromString=function(e){return new Dt().fromString(e)};Dt.prototype.toBuffer=function(){return this.buf};Dt.prototype.toHex=function(){return this.toBuffer().toString("hex")};Dt.prototype.toString=function(){return Dt.encode(this.buf)};eS.exports=Dt});var Hd=P((FU,oS)=>{"use strict";y();var rS=Ve(),nc=tS(),nS=Tt(),iS=Qt().sha256sha256,Je=function e(t){if(!(this instanceof e))return new e(t);if(d.Buffer.isBuffer(t)){var r=t;this.fromBuffer(r)}else if(typeof t=="string"){var n=t;this.fromString(n)}};Je.prototype.set=function(e){return this.buf=e.buf||this.buf||void 0,this};Je.validChecksum=function(t,r){return rS.isString(t)&&(t=nS.Buffer.from(nc.decode(t))),rS.isString(r)&&(r=nS.Buffer.from(nc.decode(r))),r||(r=t.slice(-4),t=t.slice(0,-4)),Je.checksum(t).toString("hex")===r.toString("hex")};Je.decode=function(e){if(typeof e!="string")throw new Error("Input must be a string");var t=d.Buffer.from(nc.decode(e));if(t.length<4)throw new Error("Input string too short");var r=t.slice(0,-4),n=t.slice(-4),i=iS(r),o=i.slice(0,4);if(n.toString("hex")!==o.toString("hex"))throw new Error("Checksum mismatch");return r};Je.checksum=function(e){return iS(e).slice(0,4)};Je.encode=function(e){if(!d.Buffer.isBuffer(e))throw new Error("Input must be a buffer");var t=d.Buffer.alloc(e.length+4),r=Je.checksum(e);return e.copy(t),r.copy(t,e.length),nc.encode(t)};Je.prototype.fromBuffer=function(e){return this.buf=e,this};Je.fromBuffer=function(e){return new Je().fromBuffer(e)};Je.fromHex=function(e){return Je.fromBuffer(d.Buffer.from(e,"hex"))};Je.prototype.fromString=function(e){var t=Je.decode(e);return this.buf=t,this};Je.fromString=function(e){var t=Je.decode(e);return new Je(t)};Je.prototype.toBuffer=function(){return this.buf};Je.prototype.toHex=function(){return this.toBuffer().toString("hex")};Je.prototype.toString=function(){return Je.encode(this.buf)};oS.exports=Je});var va=P((HU,aS)=>{"use strict";y();var ma=Ve(),sS=ke(),ts=Er(),et=function e(t){if(!(this instanceof e))return new e(t);if(!ma.isUndefined(t))if(d.Buffer.isBuffer(t))this.set({buf:t});else if(ma.isString(t)){var r=d.Buffer.from(t,"hex");if(r.length*2!==t.length)throw new TypeError("Invalid hex string");this.set({buf:r})}else if(ma.isObject(t)){var n=t;this.set(n)}else throw new TypeError("Unrecognized argument for BufferReader")};et.prototype.set=function(e){return this.buf=e.buf||this.buf||void 0,this.pos=e.pos||this.pos||0,this};et.prototype.eof=function(){return this.pos>=this.buf.length};et.prototype.finished=et.prototype.eof;et.prototype.read=function(e){sS.checkArgument(!ma.isUndefined(e),"Must specify a length");var t=this.buf.slice(this.pos,this.pos+e);return this.pos=this.pos+e,t};et.prototype.readAll=function(){var e=this.buf.slice(this.pos,this.buf.length);return this.pos=this.buf.length,e};et.prototype.readUInt8=function(){var e=this.buf.readUInt8(this.pos);return this.pos=this.pos+1,e};et.prototype.readUInt16BE=function(){var e=this.buf.readUInt16BE(this.pos);return this.pos=this.pos+2,e};et.prototype.readUInt16LE=function(){var e=this.buf.readUInt16LE(this.pos);return this.pos=this.pos+2,e};et.prototype.readUInt32BE=function(){var e=this.buf.readUInt32BE(this.pos);return this.pos=this.pos+4,e};et.prototype.readUInt32LE=function(){var e=this.buf.readUInt32LE(this.pos);return this.pos=this.pos+4,e};et.prototype.readInt32LE=function(){var e=this.buf.readInt32LE(this.pos);return this.pos=this.pos+4,e};et.prototype.readUInt64BEBN=function(){var e=this.buf.slice(this.pos,this.pos+8),t=ts.fromBuffer(e);return this.pos=this.pos+8,t};et.prototype.readUInt64LEBN=function(){var e=this.buf.readUInt32LE(this.pos),t=this.buf.readUInt32LE(this.pos+4),r=t*4294967296+e,n;if(r<=9007199254740991)n=new ts(r);else{var i=Array.prototype.slice.call(this.buf,this.pos,this.pos+8);n=new ts(i,10,"le")}return this.pos=this.pos+8,n};et.prototype.readVarintNum=function(){var e=this.readUInt8();switch(e){case 253:return this.readUInt16LE();case 254:return this.readUInt32LE();case 255:var t=this.readUInt64LEBN(),r=t.toNumber();if(r<=Math.pow(2,53))return r;throw new Error("number too large to retain precision - use readVarintBN");default:return e}};et.prototype.readVarLengthBuffer=function(){var e=this.readVarintNum(),t=this.read(e);return sS.checkState(t.length===e,"Invalid length while reading varlength buffer. Expected to read: "+e+" and read "+t.length),t};et.prototype.readVarintBuf=function(){var e=this.buf.readUInt8(this.pos);switch(e){case 253:return this.read(3);case 254:return this.read(5);case 255:return this.read(9);default:return this.read(1)}};et.prototype.readVarintBN=function(){var e=this.readUInt8();switch(e){case 253:return new ts(this.readUInt16LE());case 254:return new ts(this.readUInt32LE());case 255:return this.readUInt64LEBN();default:return new ts(e)}};et.prototype.reverse=function(){for(var e=d.Buffer.alloc(this.buf.length),t=0;t<e.length;t++)e[t]=this.buf[this.buf.length-1-t];return this.buf=e,this};et.prototype.readReverse=function(e){ma.isUndefined(e)&&(e=this.buf.length);var t=this.buf.slice(this.pos,this.pos+e);return this.pos=this.pos+e,d.Buffer.from(t).reverse()};aS.exports=et});var Vd=P((KU,lS)=>{"use strict";y();function ui(e){"@babel/helpers - typeof";return ui=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},ui(e)}function uS(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,OM(n.key),n)}}function AM(e,t,r){return t&&uS(e.prototype,t),r&&uS(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e}function OM(e){var t=RM(e,"string");return ui(t)==="symbol"?t:String(t)}function RM(e,t){if(ui(e)!=="object"||e===null)return e;var r=e[Symbol.toPrimitive];if(r!==void 0){var n=r.call(e,t||"default");if(ui(n)!=="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}function TM(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function PM(e,t){if(typeof t!="function"&&t!==null)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&Kd(e,t)}function Kd(e,t){return Kd=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(n,i){return n.__proto__=i,n},Kd(e,t)}function BM(e){var t=kM();return function(){var n=ic(e),i;if(t){var o=ic(this).constructor;i=Reflect.construct(n,arguments,o)}else i=n.apply(this,arguments);return NM(this,i)}}function NM(e,t){if(t&&(ui(t)==="object"||typeof t=="function"))return t;if(t!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return MM(e)}function MM(e){if(e===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function kM(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}function ic(e){return ic=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(r){return r.__proto__||Object.getPrototypeOf(r)},ic(e)}var cS={},rs,jd;function ba(e,t,r){r||(r=Error);function n(o,s,a){return typeof t=="string"?t:t(o,s,a)}var i=(function(o){PM(a,o);var s=BM(a);function a(c,h,g){var m;return TM(this,a),m=s.call(this,n(c,h,g)),m.code=e,m}return AM(a)})(r);cS[e]=i}function fS(e,t){if(Array.isArray(e)){var r=e.length;return e=e.map(function(n){return String(n)}),r>2?"one of ".concat(t," ").concat(e.slice(0,r-1).join(", "),", or ")+e[r-1]:r===2?"one of ".concat(t," ").concat(e[0]," or ").concat(e[1]):"of ".concat(t," ").concat(e[0])}else return"of ".concat(t," ").concat(String(e))}function CM(e,t,r){return e.substr(!r||r<0?0:+r,t.length)===t}function LM(e,t,r){return(r===void 0||r>e.length)&&(r=e.length),e.substring(r-t.length,r)===t}function DM(e,t,r){return typeof r!="number"&&(r=0),r+t.length>e.length?!1:e.indexOf(t,r)!==-1}ba("ERR_AMBIGUOUS_ARGUMENT",'The "%s" argument is ambiguous. %s',TypeError);ba("ERR_INVALID_ARG_TYPE",function(e,t,r){rs===void 0&&(rs=oc()),rs(typeof e=="string","'name' must be a string");var n;typeof t=="string"&&CM(t,"not ")?(n="must not be",t=t.replace(/^not /,"")):n="must be";var i;if(LM(e," argument"))i="The ".concat(e," ").concat(n," ").concat(fS(t,"type"));else{var o=DM(e,".")?"property":"argument";i='The "'.concat(e,'" ').concat(o," ").concat(n," ").concat(fS(t,"type"))}return i+=". Received type ".concat(ui(r)),i},TypeError);ba("ERR_INVALID_ARG_VALUE",function(e,t){var r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:"is invalid";jd===void 0&&(jd=en());var n=jd.inspect(t);return n.length>128&&(n="".concat(n.slice(0,128),"...")),"The argument '".concat(e,"' ").concat(r,". Received ").concat(n)},TypeError,RangeError);ba("ERR_INVALID_RETURN_VALUE",function(e,t,r){var n;return r&&r.constructor&&r.constructor.name?n="instance of ".concat(r.constructor.name):n="type ".concat(ui(r)),"Expected ".concat(e,' to be returned from the "').concat(t,'"')+" function but got ".concat(n,".")},TypeError);ba("ERR_MISSING_ARGS",function(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];rs===void 0&&(rs=oc()),rs(t.length>0,"At least one arg needs to be specified");var n="The ",i=t.length;switch(t=t.map(function(o){return'"'.concat(o,'"')}),i){case 1:n+="".concat(t[0]," argument");break;case 2:n+="".concat(t[0]," and ").concat(t[1]," arguments");break;default:n+=t.slice(0,i-1).join(", "),n+=", and ".concat(t[i-1]," arguments");break}return"".concat(n," must be specified")},TypeError);lS.exports.codes=cS});var wS=P((GU,_S)=>{"use strict";y();function hS(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(i){return Object.getOwnPropertyDescriptor(e,i).enumerable})),r.push.apply(r,n)}return r}function dS(e){for(var t=1;t<arguments.length;t++){var r=arguments[t]!=null?arguments[t]:{};t%2?hS(Object(r),!0).forEach(function(n){UM(e,n,r[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):hS(Object(r)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(r,n))})}return e}function UM(e,t,r){return t=mS(t),t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function FM(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function pS(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,mS(n.key),n)}}function qM(e,t,r){return t&&pS(e.prototype,t),r&&pS(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e}function mS(e){var t=HM(e,"string");return ur(t)==="symbol"?t:String(t)}function HM(e,t){if(ur(e)!=="object"||e===null)return e;var r=e[Symbol.toPrimitive];if(r!==void 0){var n=r.call(e,t||"default");if(ur(n)!=="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}function jM(e,t){if(typeof t!="function"&&t!==null)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&Ea(e,t)}function KM(e){var t=bS();return function(){var n=xa(e),i;if(t){var o=xa(this).constructor;i=Reflect.construct(n,arguments,o)}else i=n.apply(this,arguments);return vS(this,i)}}function vS(e,t){if(t&&(ur(t)==="object"||typeof t=="function"))return t;if(t!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return Gd(e)}function Gd(e){if(e===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function Wd(e){var t=typeof Map=="function"?new Map:void 0;return Wd=function(n){if(n===null||!VM(n))return n;if(typeof n!="function")throw new TypeError("Super expression must either be null or a function");if(typeof t<"u"){if(t.has(n))return t.get(n);t.set(n,i)}function i(){return sc(n,arguments,xa(this).constructor)}return i.prototype=Object.create(n.prototype,{constructor:{value:i,enumerable:!1,writable:!0,configurable:!0}}),Ea(i,n)},Wd(e)}function sc(e,t,r){return bS()?sc=Reflect.construct.bind():sc=function(i,o,s){var a=[null];a.push.apply(a,o);var c=Function.bind.apply(i,a),h=new c;return s&&Ea(h,s.prototype),h},sc.apply(null,arguments)}function bS(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}function VM(e){return Function.toString.call(e).indexOf("[native code]")!==-1}function Ea(e,t){return Ea=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(n,i){return n.__proto__=i,n},Ea(e,t)}function xa(e){return xa=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(r){return r.__proto__||Object.getPrototypeOf(r)},xa(e)}function ur(e){"@babel/helpers - typeof";return ur=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},ur(e)}var GM=en(),zd=GM.inspect,WM=Vd(),zM=WM.codes.ERR_INVALID_ARG_TYPE;function gS(e,t,r){return(r===void 0||r>e.length)&&(r=e.length),e.substring(r-t.length,r)===t}function YM(e,t){if(t=Math.floor(t),e.length==0||t==0)return"";var r=e.length*t;for(t=Math.floor(Math.log(t)/Math.log(2));t;)e+=e,t--;return e+=e.substring(0,r-e.length),e}var Ur="",_a="",wa="",Vt="",Xi={deepStrictEqual:"Expected values to be strictly deep-equal:",strictEqual:"Expected values to be strictly equal:",strictEqualObject:'Expected "actual" to be reference-equal to "expected":',deepEqual:"Expected values to be loosely deep-equal:",equal:"Expected values to be loosely equal:",notDeepStrictEqual:'Expected "actual" not to be strictly deep-equal to:',notStrictEqual:'Expected "actual" to be strictly unequal to:',notStrictEqualObject:'Expected "actual" not to be reference-equal to "expected":',notDeepEqual:'Expected "actual" not to be loosely deep-equal to:',notEqual:'Expected "actual" to be loosely unequal to:',notIdentical:"Values identical but not reference-equal:"},$M=10;function yS(e){var t=Object.keys(e),r=Object.create(Object.getPrototypeOf(e));return t.forEach(function(n){r[n]=e[n]}),Object.defineProperty(r,"message",{value:e.message}),r}function Sa(e){return zd(e,{compact:!1,customInspect:!1,depth:1e3,maxArrayLength:1/0,showHidden:!1,breakLength:1/0,showProxy:!1,sorted:!0,getters:!0})}function ZM(e,t,r){var n="",i="",o=0,s="",a=!1,c=Sa(e),h=c.split(`
|
|
14
|
+
`),g=Sa(t).split(`
|
|
15
|
+
`),m=0,_="";if(r==="strictEqual"&&ur(e)==="object"&&ur(t)==="object"&&e!==null&&t!==null&&(r="strictEqualObject"),h.length===1&&g.length===1&&h[0]!==g[0]){var I=h[0].length+g[0].length;if(I<=$M){if((ur(e)!=="object"||e===null)&&(ur(t)!=="object"||t===null)&&(e!==0||t!==0))return"".concat(Xi[r],`
|
|
16
16
|
|
|
17
|
-
`)+"".concat(
|
|
18
|
-
`)}else if(r!=="strictEqualObject"){var R=
|
|
19
|
-
`.concat(
|
|
20
|
-
`.concat(
|
|
21
|
-
`);if(
|
|
17
|
+
`)+"".concat(h[0]," !== ").concat(g[0],`
|
|
18
|
+
`)}else if(r!=="strictEqualObject"){var R=x.default.stderr&&x.default.stderr.isTTY?x.default.stderr.columns:80;if(I<R){for(;h[0][m]===g[0][m];)m++;m>2&&(_=`
|
|
19
|
+
`.concat(YM(" ",m),"^"),m=0)}}}for(var N=h[h.length-1],L=g[g.length-1];N===L&&(m++<2?s=`
|
|
20
|
+
`.concat(N).concat(s):n=N,h.pop(),g.pop(),!(h.length===0||g.length===0));)N=h[h.length-1],L=g[g.length-1];var q=Math.max(h.length,g.length);if(q===0){var G=c.split(`
|
|
21
|
+
`);if(G.length>30)for(G[26]="".concat(Ur,"...").concat(Vt);G.length>27;)G.pop();return"".concat(Xi.notIdentical,`
|
|
22
22
|
|
|
23
|
-
`).concat(
|
|
23
|
+
`).concat(G.join(`
|
|
24
24
|
`),`
|
|
25
25
|
`)}m>3&&(s=`
|
|
26
26
|
`.concat(Ur,"...").concat(Vt).concat(s),a=!0),n!==""&&(s=`
|
|
27
|
-
`.concat(n).concat(s),n="");var
|
|
28
|
-
`.concat(
|
|
27
|
+
`.concat(n).concat(s),n="");var K=0,z=Xi[r]+`
|
|
28
|
+
`.concat(_a,"+ actual").concat(Vt," ").concat(wa,"- expected").concat(Vt),X=" ".concat(Ur,"...").concat(Vt," Lines skipped");for(m=0;m<q;m++){var oe=m-o;if(h.length<m+1)oe>1&&m>2&&(oe>4?(i+=`
|
|
29
29
|
`.concat(Ur,"...").concat(Vt),a=!0):oe>3&&(i+=`
|
|
30
|
-
`.concat(g[m-2]),
|
|
31
|
-
`.concat(g[m-1]),
|
|
32
|
-
`.concat(
|
|
30
|
+
`.concat(g[m-2]),K++),i+=`
|
|
31
|
+
`.concat(g[m-1]),K++),o=m,n+=`
|
|
32
|
+
`.concat(wa,"-").concat(Vt," ").concat(g[m]),K++;else if(g.length<m+1)oe>1&&m>2&&(oe>4?(i+=`
|
|
33
33
|
`.concat(Ur,"...").concat(Vt),a=!0):oe>3&&(i+=`
|
|
34
|
-
`.concat(
|
|
35
|
-
`.concat(
|
|
36
|
-
`.concat(
|
|
34
|
+
`.concat(h[m-2]),K++),i+=`
|
|
35
|
+
`.concat(h[m-1]),K++),o=m,i+=`
|
|
36
|
+
`.concat(_a,"+").concat(Vt," ").concat(h[m]),K++;else{var ue=g[m],se=h[m],de=se!==ue&&(!gS(se,",")||se.slice(0,-1)!==ue);de&&gS(ue,",")&&ue.slice(0,-1)===se&&(de=!1,se+=","),de?(oe>1&&m>2&&(oe>4?(i+=`
|
|
37
37
|
`.concat(Ur,"...").concat(Vt),a=!0):oe>3&&(i+=`
|
|
38
|
-
`.concat(
|
|
39
|
-
`.concat(
|
|
40
|
-
`.concat(
|
|
41
|
-
`.concat(
|
|
42
|
-
`.concat(se),
|
|
38
|
+
`.concat(h[m-2]),K++),i+=`
|
|
39
|
+
`.concat(h[m-1]),K++),o=m,i+=`
|
|
40
|
+
`.concat(_a,"+").concat(Vt," ").concat(se),n+=`
|
|
41
|
+
`.concat(wa,"-").concat(Vt," ").concat(ue),K+=2):(i+=n,n="",(oe===1||m===0)&&(i+=`
|
|
42
|
+
`.concat(se),K++))}if(K>20&&m<q-2)return"".concat(z).concat(X,`
|
|
43
43
|
`).concat(i,`
|
|
44
44
|
`).concat(Ur,"...").concat(Vt).concat(n,`
|
|
45
|
-
`)+"".concat(Ur,"...").concat(Vt)}return"".concat(
|
|
46
|
-
`).concat(i).concat(n).concat(s).concat(_)}var
|
|
47
|
-
`);if(a==="notStrictEqual"&&
|
|
45
|
+
`)+"".concat(Ur,"...").concat(Vt)}return"".concat(z).concat(a?X:"",`
|
|
46
|
+
`).concat(i).concat(n).concat(s).concat(_)}var XM=(function(e,t){jM(n,e);var r=KM(n);function n(i){var o;if(FM(this,n),ur(i)!=="object"||i===null)throw new zM("options","Object",i);var s=i.message,a=i.operator,c=i.stackStartFn,h=i.actual,g=i.expected,m=Error.stackTraceLimit;if(Error.stackTraceLimit=0,s!=null)o=r.call(this,String(s));else if(x.default.stderr&&x.default.stderr.isTTY&&(x.default.stderr&&x.default.stderr.getColorDepth&&x.default.stderr.getColorDepth()!==1?(Ur="\x1B[34m",_a="\x1B[32m",Vt="\x1B[39m",wa="\x1B[31m"):(Ur="",_a="",Vt="",wa="")),ur(h)==="object"&&h!==null&&ur(g)==="object"&&g!==null&&"stack"in h&&h instanceof Error&&"stack"in g&&g instanceof Error&&(h=yS(h),g=yS(g)),a==="deepStrictEqual"||a==="strictEqual")o=r.call(this,ZM(h,g,a));else if(a==="notDeepStrictEqual"||a==="notStrictEqual"){var _=Xi[a],I=Sa(h).split(`
|
|
47
|
+
`);if(a==="notStrictEqual"&&ur(h)==="object"&&h!==null&&(_=Xi.notStrictEqualObject),I.length>30)for(I[26]="".concat(Ur,"...").concat(Vt);I.length>27;)I.pop();I.length===1?o=r.call(this,"".concat(_," ").concat(I[0])):o=r.call(this,"".concat(_,`
|
|
48
48
|
|
|
49
|
-
`).concat(
|
|
49
|
+
`).concat(I.join(`
|
|
50
50
|
`),`
|
|
51
|
-
`))}else{var R=
|
|
51
|
+
`))}else{var R=Sa(h),N="",L=Xi[a];a==="notDeepEqual"||a==="notEqual"?(R="".concat(Xi[a],`
|
|
52
52
|
|
|
53
|
-
`).concat(R),R.length>1024&&(R="".concat(R.slice(0,1021),"..."))):(
|
|
53
|
+
`).concat(R),R.length>1024&&(R="".concat(R.slice(0,1021),"..."))):(N="".concat(Sa(g)),R.length>512&&(R="".concat(R.slice(0,509),"...")),N.length>512&&(N="".concat(N.slice(0,509),"...")),a==="deepEqual"||a==="equal"?R="".concat(L,`
|
|
54
54
|
|
|
55
55
|
`).concat(R,`
|
|
56
56
|
|
|
57
57
|
should equal
|
|
58
58
|
|
|
59
|
-
`):
|
|
60
|
-
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function f8(e,t){if(e){if(typeof e=="string")return qS(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);if(r==="Object"&&e.constructor&&(r=e.constructor.name),r==="Map"||r==="Set")return Array.from(e);if(r==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return qS(e,t)}}function qS(e,t){(t==null||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}function c8(e,t){var r=e==null?null:typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(r!=null){var n,i,o,s,a=[],c=!0,l=!1;try{if(o=(r=r.call(e)).next,t===0){if(Object(r)!==r)return;c=!1}else for(;!(c=(n=o.call(r)).done)&&(a.push(n.value),a.length!==t);c=!0);}catch(g){l=!0,i=g}finally{try{if(!c&&r.return!=null&&(s=r.return(),Object(s)!==s))return}finally{if(l)throw i}}return a}}function h8(e){if(Array.isArray(e))return e}function Ir(e){"@babel/helpers - typeof";return Ir=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Ir(e)}var l8=/a/g.flags!==void 0,cc=function(t){var r=[];return t.forEach(function(n){return r.push(n)}),r},FS=function(t){var r=[];return t.forEach(function(n,i){return r.push([i,n])}),r},XS=Object.is?Object.is:TS(),uc=Object.getOwnPropertySymbols?Object.getOwnPropertySymbols:function(){return[]},ep=Number.isNaN?Number.isNaN:DS();function rp(e){return e.call.bind(e)}var Ba=rp(Object.prototype.hasOwnProperty),fc=rp(Object.prototype.propertyIsEnumerable),HS=rp(Object.prototype.toString),Jt=en().types,d8=Jt.isAnyArrayBuffer,p8=Jt.isArrayBufferView,jS=Jt.isDate,ic=Jt.isMap,KS=Jt.isRegExp,oc=Jt.isSet,g8=Jt.isNativeError,y8=Jt.isBoxedPrimitive,VS=Jt.isNumberObject,GS=Jt.isStringObject,zS=Jt.isBooleanObject,WS=Jt.isBigIntObject,m8=Jt.isSymbolObject,v8=Jt.isFloat32Array,b8=Jt.isFloat64Array;function _8(e){if(e.length===0||e.length>10)return!0;for(var t=0;t<e.length;t++){var r=e.charCodeAt(t);if(r<48||r>57)return!0}return e.length===10&&e>=Math.pow(2,32)}function sc(e){return Object.keys(e).filter(_8).concat(uc(e).filter(Object.prototype.propertyIsEnumerable.bind(e)))}function JS(e,t){if(e===t)return 0;for(var r=e.length,n=t.length,i=0,o=Math.min(r,n);i<o;++i)if(e[i]!==t[i]){r=e[i],n=t[i];break}return r<n?-1:n<r?1:0}var ac=void 0,w8=!0,S8=!1,tp=0,np=1,QS=2,eE=3;function E8(e,t){return l8?e.source===t.source&&e.flags===t.flags:RegExp.prototype.toString.call(e)===RegExp.prototype.toString.call(t)}function x8(e,t){if(e.byteLength!==t.byteLength)return!1;for(var r=0;r<e.byteLength;r++)if(e[r]!==t[r])return!1;return!0}function I8(e,t){return e.byteLength!==t.byteLength?!1:JS(new Uint8Array(e.buffer,e.byteOffset,e.byteLength),new Uint8Array(t.buffer,t.byteOffset,t.byteLength))===0}function A8(e,t){return e.byteLength===t.byteLength&&JS(new Uint8Array(e),new Uint8Array(t))===0}function O8(e,t){return VS(e)?VS(t)&&XS(Number.prototype.valueOf.call(e),Number.prototype.valueOf.call(t)):GS(e)?GS(t)&&String.prototype.valueOf.call(e)===String.prototype.valueOf.call(t):zS(e)?zS(t)&&Boolean.prototype.valueOf.call(e)===Boolean.prototype.valueOf.call(t):WS(e)?WS(t)&&BigInt.prototype.valueOf.call(e)===BigInt.prototype.valueOf.call(t):m8(t)&&Symbol.prototype.valueOf.call(e)===Symbol.prototype.valueOf.call(t)}function Ar(e,t,r,n){if(e===t)return e!==0?!0:r?XS(e,t):!0;if(r){if(Ir(e)!=="object")return typeof e=="number"&&ep(e)&&ep(t);if(Ir(t)!=="object"||e===null||t===null||Object.getPrototypeOf(e)!==Object.getPrototypeOf(t))return!1}else{if(e===null||Ir(e)!=="object")return t===null||Ir(t)!=="object"?e==t:!1;if(t===null||Ir(t)!=="object")return!1}var i=HS(e),o=HS(t);if(i!==o)return!1;if(Array.isArray(e)){if(e.length!==t.length)return!1;var s=sc(e,ac),a=sc(t,ac);return s.length!==a.length?!1:Pa(e,t,r,n,np,s)}if(i==="[object Object]"&&(!ic(e)&&ic(t)||!oc(e)&&oc(t)))return!1;if(jS(e)){if(!jS(t)||Date.prototype.getTime.call(e)!==Date.prototype.getTime.call(t))return!1}else if(KS(e)){if(!KS(t)||!E8(e,t))return!1}else if(g8(e)||e instanceof Error){if(e.message!==t.message||e.name!==t.name)return!1}else if(p8(e)){if(!r&&(v8(e)||b8(e))){if(!x8(e,t))return!1}else if(!I8(e,t))return!1;var c=sc(e,ac),l=sc(t,ac);return c.length!==l.length?!1:Pa(e,t,r,n,tp,c)}else{if(oc(e))return!oc(t)||e.size!==t.size?!1:Pa(e,t,r,n,QS);if(ic(e))return!ic(t)||e.size!==t.size?!1:Pa(e,t,r,n,eE);if(d8(e)){if(!A8(e,t))return!1}else if(y8(e)&&!O8(e,t))return!1}return Pa(e,t,r,n,tp)}function YS(e,t){return t.filter(function(r){return fc(e,r)})}function Pa(e,t,r,n,i,o){if(arguments.length===5){o=Object.keys(e);var s=Object.keys(t);if(o.length!==s.length)return!1}for(var a=0;a<o.length;a++)if(!Ba(t,o[a]))return!1;if(r&&arguments.length===5){var c=uc(e);if(c.length!==0){var l=0;for(a=0;a<c.length;a++){var g=c[a];if(fc(e,g)){if(!fc(t,g))return!1;o.push(g),l++}else if(fc(t,g))return!1}var m=uc(t);if(c.length!==m.length&&YS(t,m).length!==l)return!1}else{var _=uc(t);if(_.length!==0&&YS(t,_).length!==0)return!1}}if(o.length===0&&(i===tp||i===np&&e.length===0||e.size===0))return!0;if(n===void 0)n={val1:new Map,val2:new Map,position:0};else{var x=n.val1.get(e);if(x!==void 0){var R=n.val2.get(t);if(R!==void 0)return x===R}n.position++}n.val1.set(e,n.position),n.val2.set(t,n.position);var B=N8(e,t,r,o,n,i);return n.val1.delete(e),n.val2.delete(t),B}function $S(e,t,r,n){for(var i=cc(e),o=0;o<i.length;o++){var s=i[o];if(Ar(t,s,r,n))return e.delete(s),!0}return!1}function tE(e){switch(Ir(e)){case"undefined":return null;case"object":return;case"symbol":return!1;case"string":e=+e;case"number":if(ep(e))return!1}return!0}function R8(e,t,r){var n=tE(r);return n??(t.has(n)&&!e.has(n))}function T8(e,t,r,n,i){var o=tE(r);if(o!=null)return o;var s=t.get(o);return s===void 0&&!t.has(o)||!Ar(n,s,!1,i)?!1:!e.has(o)&&Ar(n,s,!1,i)}function P8(e,t,r,n){for(var i=null,o=cc(e),s=0;s<o.length;s++){var a=o[s];if(Ir(a)==="object"&&a!==null)i===null&&(i=new Set),i.add(a);else if(!t.has(a)){if(r||!R8(e,t,a))return!1;i===null&&(i=new Set),i.add(a)}}if(i!==null){for(var c=cc(t),l=0;l<c.length;l++){var g=c[l];if(Ir(g)==="object"&&g!==null){if(!$S(i,g,r,n))return!1}else if(!r&&!e.has(g)&&!$S(i,g,r,n))return!1}return i.size===0}return!0}function ZS(e,t,r,n,i,o){for(var s=cc(e),a=0;a<s.length;a++){var c=s[a];if(Ar(r,c,i,o)&&Ar(n,t.get(c),i,o))return e.delete(c),!0}return!1}function B8(e,t,r,n){for(var i=null,o=FS(e),s=0;s<o.length;s++){var a=US(o[s],2),c=a[0],l=a[1];if(Ir(c)==="object"&&c!==null)i===null&&(i=new Set),i.add(c);else{var g=t.get(c);if(g===void 0&&!t.has(c)||!Ar(l,g,r,n)){if(r||!T8(e,t,c,l,n))return!1;i===null&&(i=new Set),i.add(c)}}}if(i!==null){for(var m=FS(t),_=0;_<m.length;_++){var x=US(m[_],2),R=x[0],B=x[1];if(Ir(R)==="object"&&R!==null){if(!ZS(i,e,R,B,r,n))return!1}else if(!r&&(!e.has(R)||!Ar(e.get(R),B,!1,n))&&!ZS(i,e,R,B,!1,n))return!1}return i.size===0}return!0}function N8(e,t,r,n,i,o){var s=0;if(o===QS){if(!P8(e,t,r,i))return!1}else if(o===eE){if(!B8(e,t,r,i))return!1}else if(o===np)for(;s<e.length;s++)if(Ba(e,s)){if(!Ba(t,s)||!Ar(e[s],t[s],r,i))return!1}else{if(Ba(t,s))return!1;for(var a=Object.keys(e);s<a.length;s++){var c=a[s];if(!Ba(t,c)||!Ar(e[c],t[c],r,i))return!1}return a.length===Object.keys(t).length}for(s=0;s<n.length;s++){var l=n[s];if(!Ar(e[l],t[l],r,i))return!1}return!0}function M8(e,t){return Ar(e,t,S8)}function k8(e,t){return Ar(e,t,w8)}rE.exports={isDeepEqual:M8,isDeepStrictEqual:k8}});var Jf=P((iH,wE)=>{"use strict";p();function qr(e){"@babel/helpers - typeof";return qr=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},qr(e)}function iE(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,L8(n.key),n)}}function C8(e,t,r){return t&&iE(e.prototype,t),r&&iE(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e}function L8(e){var t=D8(e,"string");return qr(t)==="symbol"?t:String(t)}function D8(e,t){if(qr(e)!=="object"||e===null)return e;var r=e[Symbol.toPrimitive];if(r!==void 0){var n=r.call(e,t||"default");if(qr(n)!=="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}function U8(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}var q8=jd(),Na=q8.codes,oE=Na.ERR_AMBIGUOUS_ARGUMENT,us=Na.ERR_INVALID_ARG_TYPE,F8=Na.ERR_INVALID_ARG_VALUE,H8=Na.ERR_INVALID_RETURN_VALUE,li=Na.ERR_MISSING_ARGS,di=Gw(),j8=en(),hc=j8.inspect,fE=en().types,K8=fE.isPromise,lc=fE.isRegExp,V8=lS()(),cE=nc()(),dc=bS()("RegExp.prototype.test"),hi,pc;function Ma(){var e=nE();hi=e.isDeepEqual,pc=e.isDeepStrictEqual}var sE=!1,ze=wE.exports=ip,gc={};function Fr(e){throw e.message instanceof Error?e.message:new di(e)}function hE(e,t,r,n,i){var o=arguments.length,s;if(o===0)s="Failed";else if(o===1)r=e,e=void 0;else{if(sE===!1){sE=!0;var a=I.default.emitWarning?I.default.emitWarning:console.warn.bind(console);a("assert.fail() with more than one argument is deprecated. Please use assert.strictEqual() instead or only pass a message.","DeprecationWarning","DEP0094")}o===2&&(n="!=")}if(r instanceof Error)throw r;var c={actual:e,expected:t,operator:n===void 0?"fail":n,stackStartFn:i||hE};r!==void 0&&(c.message=r);var l=new di(c);throw s&&(l.message=s,l.generatedMessage=!0),l}ze.fail=hE;ze.AssertionError=di;function lE(e,t,r,n){if(!r){var i=!1;if(t===0)i=!0,n="No value argument passed to `assert.ok()`";else if(n instanceof Error)throw n;var o=new di({actual:r,expected:!0,message:n,operator:"==",stackStartFn:e});throw o.generatedMessage=i,o}}function ip(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];lE.apply(void 0,[ip,t.length].concat(t))}ze.ok=ip;ze.equal=function e(t,r,n){if(arguments.length<2)throw new li("actual","expected");t!=r&&Fr({actual:t,expected:r,message:n,operator:"==",stackStartFn:e})};ze.notEqual=function e(t,r,n){if(arguments.length<2)throw new li("actual","expected");t==r&&Fr({actual:t,expected:r,message:n,operator:"!=",stackStartFn:e})};ze.deepEqual=function e(t,r,n){if(arguments.length<2)throw new li("actual","expected");hi===void 0&&Ma(),hi(t,r)||Fr({actual:t,expected:r,message:n,operator:"deepEqual",stackStartFn:e})};ze.notDeepEqual=function e(t,r,n){if(arguments.length<2)throw new li("actual","expected");hi===void 0&&Ma(),hi(t,r)&&Fr({actual:t,expected:r,message:n,operator:"notDeepEqual",stackStartFn:e})};ze.deepStrictEqual=function e(t,r,n){if(arguments.length<2)throw new li("actual","expected");hi===void 0&&Ma(),pc(t,r)||Fr({actual:t,expected:r,message:n,operator:"deepStrictEqual",stackStartFn:e})};ze.notDeepStrictEqual=dE;function dE(e,t,r){if(arguments.length<2)throw new li("actual","expected");hi===void 0&&Ma(),pc(e,t)&&Fr({actual:e,expected:t,message:r,operator:"notDeepStrictEqual",stackStartFn:dE})}ze.strictEqual=function e(t,r,n){if(arguments.length<2)throw new li("actual","expected");cE(t,r)||Fr({actual:t,expected:r,message:n,operator:"strictEqual",stackStartFn:e})};ze.notStrictEqual=function e(t,r,n){if(arguments.length<2)throw new li("actual","expected");cE(t,r)&&Fr({actual:t,expected:r,message:n,operator:"notStrictEqual",stackStartFn:e})};var aE=C8(function e(t,r,n){var i=this;U8(this,e),r.forEach(function(o){o in t&&(n!==void 0&&typeof n[o]=="string"&&lc(t[o])&&dc(t[o],n[o])?i[o]=n[o]:i[o]=t[o])})});function G8(e,t,r,n,i,o){if(!(r in e)||!pc(e[r],t[r])){if(!n){var s=new aE(e,i),a=new aE(t,i,e),c=new di({actual:s,expected:a,operator:"deepStrictEqual",stackStartFn:o});throw c.actual=e,c.expected=t,c.operator=o.name,c}Fr({actual:e,expected:t,message:n,operator:o.name,stackStartFn:o})}}function pE(e,t,r,n){if(typeof t!="function"){if(lc(t))return dc(t,e);if(arguments.length===2)throw new us("expected",["Function","RegExp"],t);if(qr(e)!=="object"||e===null){var i=new di({actual:e,expected:t,message:r,operator:"deepStrictEqual",stackStartFn:n});throw i.operator=n.name,i}var o=Object.keys(t);if(t instanceof Error)o.push("name","message");else if(o.length===0)throw new F8("error",t,"may not be an empty object");return hi===void 0&&Ma(),o.forEach(function(s){typeof e[s]=="string"&&lc(t[s])&&dc(t[s],e[s])||G8(e,t,s,r,o,n)}),!0}return t.prototype!==void 0&&e instanceof t?!0:Error.isPrototypeOf(t)?!1:t.call({},e)===!0}function gE(e){if(typeof e!="function")throw new us("fn","Function",e);try{e()}catch(t){return t}return gc}function uE(e){return K8(e)||e!==null&&qr(e)==="object"&&typeof e.then=="function"&&typeof e.catch=="function"}function yE(e){return Promise.resolve().then(function(){var t;if(typeof e=="function"){if(t=e(),!uE(t))throw new H8("instance of Promise","promiseFn",t)}else if(uE(e))t=e;else throw new us("promiseFn",["Function","Promise"],e);return Promise.resolve().then(function(){return t}).then(function(){return gc}).catch(function(r){return r})})}function mE(e,t,r,n){if(typeof r=="string"){if(arguments.length===4)throw new us("error",["Object","Error","Function","RegExp"],r);if(qr(t)==="object"&&t!==null){if(t.message===r)throw new oE("error/message",'The error message "'.concat(t.message,'" is identical to the message.'))}else if(t===r)throw new oE("error/message",'The error "'.concat(t,'" is identical to the message.'));n=r,r=void 0}else if(r!=null&&qr(r)!=="object"&&typeof r!="function")throw new us("error",["Object","Error","Function","RegExp"],r);if(t===gc){var i="";r&&r.name&&(i+=" (".concat(r.name,")")),i+=n?": ".concat(n):".";var o=e.name==="rejects"?"rejection":"exception";Fr({actual:void 0,expected:r,operator:e.name,message:"Missing expected ".concat(o).concat(i),stackStartFn:e})}if(r&&!pE(t,r,n,e))throw t}function vE(e,t,r,n){if(t!==gc){if(typeof r=="string"&&(n=r,r=void 0),!r||pE(t,r)){var i=n?": ".concat(n):".",o=e.name==="doesNotReject"?"rejection":"exception";Fr({actual:t,expected:r,operator:e.name,message:"Got unwanted ".concat(o).concat(i,`
|
|
61
|
-
`)+'Actual message: "'.concat(t&&t.message,'"'),stackStartFn:e})}throw t}}
|
|
59
|
+
`):N=" ".concat(a," ").concat(N)),o=r.call(this,"".concat(R).concat(N))}return Error.stackTraceLimit=m,o.generatedMessage=!s,Object.defineProperty(Gd(o),"name",{value:"AssertionError [ERR_ASSERTION]",enumerable:!1,writable:!0,configurable:!0}),o.code="ERR_ASSERTION",o.actual=h,o.expected=g,o.operator=a,Error.captureStackTrace&&Error.captureStackTrace(Gd(o),c),o.stack,o.name="AssertionError",vS(o)}return qM(n,[{key:"toString",value:function(){return"".concat(this.name," [").concat(this.code,"]: ").concat(this.message)}},{key:t,value:function(o,s){return zd(this,dS(dS({},s),{},{customInspect:!1,depth:0}))}}]),n})(Wd(Error),zd.custom);_S.exports=XM});var Yd=P((zU,ES)=>{"use strict";y();var SS=Object.prototype.toString;ES.exports=function(t){var r=SS.call(t),n=r==="[object Arguments]";return n||(n=r!=="[object Array]"&&t!==null&&typeof t=="object"&&typeof t.length=="number"&&t.length>=0&&SS.call(t.callee)==="[object Function]"),n}});var NS=P(($U,BS)=>{"use strict";y();var PS;Object.keys||(Ia=Object.prototype.hasOwnProperty,$d=Object.prototype.toString,xS=Yd(),Zd=Object.prototype.propertyIsEnumerable,IS=!Zd.call({toString:null},"toString"),AS=Zd.call(function(){},"prototype"),Aa=["toString","toLocaleString","valueOf","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","constructor"],ac=function(e){var t=e.constructor;return t&&t.prototype===e},OS={$applicationCache:!0,$console:!0,$external:!0,$frame:!0,$frameElement:!0,$frames:!0,$innerHeight:!0,$innerWidth:!0,$onmozfullscreenchange:!0,$onmozfullscreenerror:!0,$outerHeight:!0,$outerWidth:!0,$pageXOffset:!0,$pageYOffset:!0,$parent:!0,$scrollLeft:!0,$scrollTop:!0,$scrollX:!0,$scrollY:!0,$self:!0,$webkitIndexedDB:!0,$webkitStorageInfo:!0,$window:!0},RS=(function(){if(typeof window>"u")return!1;for(var e in window)try{if(!OS["$"+e]&&Ia.call(window,e)&&window[e]!==null&&typeof window[e]=="object")try{ac(window[e])}catch{return!0}}catch{return!0}return!1})(),TS=function(e){if(typeof window>"u"||!RS)return ac(e);try{return ac(e)}catch{return!1}},PS=function(t){var r=t!==null&&typeof t=="object",n=$d.call(t)==="[object Function]",i=xS(t),o=r&&$d.call(t)==="[object String]",s=[];if(!r&&!n&&!i)throw new TypeError("Object.keys called on a non-object");var a=AS&&n;if(o&&t.length>0&&!Ia.call(t,0))for(var c=0;c<t.length;++c)s.push(String(c));if(i&&t.length>0)for(var h=0;h<t.length;++h)s.push(String(h));else for(var g in t)!(a&&g==="prototype")&&Ia.call(t,g)&&s.push(String(g));if(IS)for(var m=TS(t),_=0;_<Aa.length;++_)!(m&&Aa[_]==="constructor")&&Ia.call(t,Aa[_])&&s.push(Aa[_]);return s});var Ia,$d,xS,Zd,IS,AS,Aa,ac,OS,RS,TS;BS.exports=PS});var Xd=P((XU,CS)=>{"use strict";y();var JM=Array.prototype.slice,QM=Yd(),MS=Object.keys,uc=MS?function(t){return MS(t)}:NS(),kS=Object.keys;uc.shim=function(){if(Object.keys){var t=(function(){var r=Object.keys(arguments);return r&&r.length===arguments.length})(1,2);t||(Object.keys=function(n){return QM(n)?kS(JM.call(n)):kS(n)})}else Object.keys=uc;return Object.keys||uc};CS.exports=uc});var qS=P((QU,FS)=>{"use strict";y();var e3=Xd(),DS=nu()(),US=Vn(),fc=iu(),t3=US("Array.prototype.push"),LS=US("Object.prototype.propertyIsEnumerable"),r3=DS?fc.getOwnPropertySymbols:null;FS.exports=function(t,r){if(t==null)throw new TypeError("target must be an object");var n=fc(t);if(arguments.length===1)return n;for(var i=1;i<arguments.length;++i){var o=fc(arguments[i]),s=e3(o),a=DS&&(fc.getOwnPropertySymbols||r3);if(a)for(var c=a(o),h=0;h<c.length;++h){var g=c[h];LS(o,g)&&t3(s,g)}for(var m=0;m<s.length;++m){var _=s[m];if(LS(o,_)){var I=o[_];n[_]=I}}}return n}});var jS=P((tF,HS)=>{"use strict";y();var Jd=qS(),n3=function(){if(!Object.assign)return!1;for(var e="abcdefghijklmnopqrst",t=e.split(""),r={},n=0;n<t.length;++n)r[t[n]]=t[n];var i=Object.assign({},r),o="";for(var s in i)o+=s;return e!==o},i3=function(){if(!Object.assign||!Object.preventExtensions)return!1;var e=Object.preventExtensions({1:2});try{Object.assign(e,"xy")}catch{return e[1]==="y"}return!1};HS.exports=function(){return!Object.assign||n3()||i3()?Jd:Object.assign}});var Qd=P((nF,VS)=>{"use strict";y();var KS=function(e){return e!==e};VS.exports=function(t,r){return t===0&&r===0?1/t===1/r:!!(t===r||KS(t)&&KS(r))}});var cc=P((oF,GS)=>{"use strict";y();var o3=Qd();GS.exports=function(){return typeof Object.is=="function"?Object.is:o3}});var $S=P((aF,YS)=>{"use strict";y();var WS=du(),zS=Ss(),s3=zS(WS("String.prototype.indexOf"));YS.exports=function(t,r){var n=WS(t,!!r);return typeof n=="function"&&s3(t,".prototype.")>-1?zS(n):n}});var Oa=P((fF,QS)=>{"use strict";y();var a3=Xd(),u3=typeof Symbol=="function"&&typeof Symbol("foo")=="symbol",f3=Object.prototype.toString,c3=Array.prototype.concat,ZS=Kl(),l3=function(e){return typeof e=="function"&&f3.call(e)==="[object Function]"},XS=Gl()(),h3=function(e,t,r,n){if(t in e){if(n===!0){if(e[t]===r)return}else if(!l3(n)||!n())return}XS?ZS(e,t,r,!0):ZS(e,t,r)},JS=function(e,t){var r=arguments.length>2?arguments[2]:{},n=a3(t);u3&&(n=c3.call(n,Object.getOwnPropertySymbols(t)));for(var i=0;i<n.length;i+=1)h3(e,n[i],t[n[i]],r[n[i]])};JS.supportsDescriptors=!!XS;QS.exports=JS});var tE=P((lF,eE)=>{"use strict";y();var d3=cc(),p3=Oa();eE.exports=function(){var t=d3();return p3(Object,{is:t},{is:function(){return Object.is!==t}}),t}});var oE=P((dF,iE)=>{"use strict";y();var g3=Oa(),y3=Ss(),m3=Qd(),rE=cc(),v3=tE(),nE=y3(rE(),Object);g3(nE,{getPolyfill:rE,implementation:m3,shim:v3});iE.exports=nE});var ep=P((gF,sE)=>{"use strict";y();sE.exports=function(t){return t!==t}});var tp=P((mF,aE)=>{"use strict";y();var b3=ep();aE.exports=function(){return Number.isNaN&&Number.isNaN(NaN)&&!Number.isNaN("a")?Number.isNaN:b3}});var fE=P((bF,uE)=>{"use strict";y();var _3=Oa(),w3=tp();uE.exports=function(){var t=w3();return _3(Number,{isNaN:t},{isNaN:function(){return Number.isNaN!==t}}),t}});var dE=P((wF,hE)=>{"use strict";y();var S3=Ss(),E3=Oa(),x3=ep(),cE=tp(),I3=fE(),lE=S3(cE(),Number);E3(lE,{getPolyfill:cE,implementation:x3,shim:I3});hE.exports=lE});var ME=P((EF,NE)=>{"use strict";y();function pE(e,t){return T3(e)||R3(e,t)||O3(e,t)||A3()}function A3(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
|
|
60
|
+
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function O3(e,t){if(e){if(typeof e=="string")return gE(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);if(r==="Object"&&e.constructor&&(r=e.constructor.name),r==="Map"||r==="Set")return Array.from(e);if(r==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return gE(e,t)}}function gE(e,t){(t==null||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}function R3(e,t){var r=e==null?null:typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(r!=null){var n,i,o,s,a=[],c=!0,h=!1;try{if(o=(r=r.call(e)).next,t===0){if(Object(r)!==r)return;c=!1}else for(;!(c=(n=o.call(r)).done)&&(a.push(n.value),a.length!==t);c=!0);}catch(g){h=!0,i=g}finally{try{if(!c&&r.return!=null&&(s=r.return(),Object(s)!==s))return}finally{if(h)throw i}}return a}}function T3(e){if(Array.isArray(e))return e}function Or(e){"@babel/helpers - typeof";return Or=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Or(e)}var P3=/a/g.flags!==void 0,mc=function(t){var r=[];return t.forEach(function(n){return r.push(n)}),r},yE=function(t){var r=[];return t.forEach(function(n,i){return r.push([i,n])}),r},OE=Object.is?Object.is:oE(),gc=Object.getOwnPropertySymbols?Object.getOwnPropertySymbols:function(){return[]},rp=Number.isNaN?Number.isNaN:dE();function ip(e){return e.call.bind(e)}var Ta=ip(Object.prototype.hasOwnProperty),yc=ip(Object.prototype.propertyIsEnumerable),mE=ip(Object.prototype.toString),rr=en().types,B3=rr.isAnyArrayBuffer,N3=rr.isArrayBufferView,vE=rr.isDate,lc=rr.isMap,bE=rr.isRegExp,hc=rr.isSet,M3=rr.isNativeError,k3=rr.isBoxedPrimitive,_E=rr.isNumberObject,wE=rr.isStringObject,SE=rr.isBooleanObject,EE=rr.isBigIntObject,C3=rr.isSymbolObject,L3=rr.isFloat32Array,D3=rr.isFloat64Array;function U3(e){if(e.length===0||e.length>10)return!0;for(var t=0;t<e.length;t++){var r=e.charCodeAt(t);if(r<48||r>57)return!0}return e.length===10&&e>=Math.pow(2,32)}function dc(e){return Object.keys(e).filter(U3).concat(gc(e).filter(Object.prototype.propertyIsEnumerable.bind(e)))}function RE(e,t){if(e===t)return 0;for(var r=e.length,n=t.length,i=0,o=Math.min(r,n);i<o;++i)if(e[i]!==t[i]){r=e[i],n=t[i];break}return r<n?-1:n<r?1:0}var pc=void 0,F3=!0,q3=!1,np=0,op=1,TE=2,PE=3;function H3(e,t){return P3?e.source===t.source&&e.flags===t.flags:RegExp.prototype.toString.call(e)===RegExp.prototype.toString.call(t)}function j3(e,t){if(e.byteLength!==t.byteLength)return!1;for(var r=0;r<e.byteLength;r++)if(e[r]!==t[r])return!1;return!0}function K3(e,t){return e.byteLength!==t.byteLength?!1:RE(new Uint8Array(e.buffer,e.byteOffset,e.byteLength),new Uint8Array(t.buffer,t.byteOffset,t.byteLength))===0}function V3(e,t){return e.byteLength===t.byteLength&&RE(new Uint8Array(e),new Uint8Array(t))===0}function G3(e,t){return _E(e)?_E(t)&&OE(Number.prototype.valueOf.call(e),Number.prototype.valueOf.call(t)):wE(e)?wE(t)&&String.prototype.valueOf.call(e)===String.prototype.valueOf.call(t):SE(e)?SE(t)&&Boolean.prototype.valueOf.call(e)===Boolean.prototype.valueOf.call(t):EE(e)?EE(t)&&BigInt.prototype.valueOf.call(e)===BigInt.prototype.valueOf.call(t):C3(t)&&Symbol.prototype.valueOf.call(e)===Symbol.prototype.valueOf.call(t)}function Rr(e,t,r,n){if(e===t)return e!==0?!0:r?OE(e,t):!0;if(r){if(Or(e)!=="object")return typeof e=="number"&&rp(e)&&rp(t);if(Or(t)!=="object"||e===null||t===null||Object.getPrototypeOf(e)!==Object.getPrototypeOf(t))return!1}else{if(e===null||Or(e)!=="object")return t===null||Or(t)!=="object"?e==t:!1;if(t===null||Or(t)!=="object")return!1}var i=mE(e),o=mE(t);if(i!==o)return!1;if(Array.isArray(e)){if(e.length!==t.length)return!1;var s=dc(e,pc),a=dc(t,pc);return s.length!==a.length?!1:Ra(e,t,r,n,op,s)}if(i==="[object Object]"&&(!lc(e)&&lc(t)||!hc(e)&&hc(t)))return!1;if(vE(e)){if(!vE(t)||Date.prototype.getTime.call(e)!==Date.prototype.getTime.call(t))return!1}else if(bE(e)){if(!bE(t)||!H3(e,t))return!1}else if(M3(e)||e instanceof Error){if(e.message!==t.message||e.name!==t.name)return!1}else if(N3(e)){if(!r&&(L3(e)||D3(e))){if(!j3(e,t))return!1}else if(!K3(e,t))return!1;var c=dc(e,pc),h=dc(t,pc);return c.length!==h.length?!1:Ra(e,t,r,n,np,c)}else{if(hc(e))return!hc(t)||e.size!==t.size?!1:Ra(e,t,r,n,TE);if(lc(e))return!lc(t)||e.size!==t.size?!1:Ra(e,t,r,n,PE);if(B3(e)){if(!V3(e,t))return!1}else if(k3(e)&&!G3(e,t))return!1}return Ra(e,t,r,n,np)}function xE(e,t){return t.filter(function(r){return yc(e,r)})}function Ra(e,t,r,n,i,o){if(arguments.length===5){o=Object.keys(e);var s=Object.keys(t);if(o.length!==s.length)return!1}for(var a=0;a<o.length;a++)if(!Ta(t,o[a]))return!1;if(r&&arguments.length===5){var c=gc(e);if(c.length!==0){var h=0;for(a=0;a<c.length;a++){var g=c[a];if(yc(e,g)){if(!yc(t,g))return!1;o.push(g),h++}else if(yc(t,g))return!1}var m=gc(t);if(c.length!==m.length&&xE(t,m).length!==h)return!1}else{var _=gc(t);if(_.length!==0&&xE(t,_).length!==0)return!1}}if(o.length===0&&(i===np||i===op&&e.length===0||e.size===0))return!0;if(n===void 0)n={val1:new Map,val2:new Map,position:0};else{var I=n.val1.get(e);if(I!==void 0){var R=n.val2.get(t);if(R!==void 0)return I===R}n.position++}n.val1.set(e,n.position),n.val2.set(t,n.position);var N=Z3(e,t,r,o,n,i);return n.val1.delete(e),n.val2.delete(t),N}function IE(e,t,r,n){for(var i=mc(e),o=0;o<i.length;o++){var s=i[o];if(Rr(t,s,r,n))return e.delete(s),!0}return!1}function BE(e){switch(Or(e)){case"undefined":return null;case"object":return;case"symbol":return!1;case"string":e=+e;case"number":if(rp(e))return!1}return!0}function W3(e,t,r){var n=BE(r);return n??(t.has(n)&&!e.has(n))}function z3(e,t,r,n,i){var o=BE(r);if(o!=null)return o;var s=t.get(o);return s===void 0&&!t.has(o)||!Rr(n,s,!1,i)?!1:!e.has(o)&&Rr(n,s,!1,i)}function Y3(e,t,r,n){for(var i=null,o=mc(e),s=0;s<o.length;s++){var a=o[s];if(Or(a)==="object"&&a!==null)i===null&&(i=new Set),i.add(a);else if(!t.has(a)){if(r||!W3(e,t,a))return!1;i===null&&(i=new Set),i.add(a)}}if(i!==null){for(var c=mc(t),h=0;h<c.length;h++){var g=c[h];if(Or(g)==="object"&&g!==null){if(!IE(i,g,r,n))return!1}else if(!r&&!e.has(g)&&!IE(i,g,r,n))return!1}return i.size===0}return!0}function AE(e,t,r,n,i,o){for(var s=mc(e),a=0;a<s.length;a++){var c=s[a];if(Rr(r,c,i,o)&&Rr(n,t.get(c),i,o))return e.delete(c),!0}return!1}function $3(e,t,r,n){for(var i=null,o=yE(e),s=0;s<o.length;s++){var a=pE(o[s],2),c=a[0],h=a[1];if(Or(c)==="object"&&c!==null)i===null&&(i=new Set),i.add(c);else{var g=t.get(c);if(g===void 0&&!t.has(c)||!Rr(h,g,r,n)){if(r||!z3(e,t,c,h,n))return!1;i===null&&(i=new Set),i.add(c)}}}if(i!==null){for(var m=yE(t),_=0;_<m.length;_++){var I=pE(m[_],2),R=I[0],N=I[1];if(Or(R)==="object"&&R!==null){if(!AE(i,e,R,N,r,n))return!1}else if(!r&&(!e.has(R)||!Rr(e.get(R),N,!1,n))&&!AE(i,e,R,N,!1,n))return!1}return i.size===0}return!0}function Z3(e,t,r,n,i,o){var s=0;if(o===TE){if(!Y3(e,t,r,i))return!1}else if(o===PE){if(!$3(e,t,r,i))return!1}else if(o===op)for(;s<e.length;s++)if(Ta(e,s)){if(!Ta(t,s)||!Rr(e[s],t[s],r,i))return!1}else{if(Ta(t,s))return!1;for(var a=Object.keys(e);s<a.length;s++){var c=a[s];if(!Ta(t,c)||!Rr(e[c],t[c],r,i))return!1}return a.length===Object.keys(t).length}for(s=0;s<n.length;s++){var h=n[s];if(!Rr(e[h],t[h],r,i))return!1}return!0}function X3(e,t){return Rr(e,t,q3)}function J3(e,t){return Rr(e,t,F3)}NE.exports={isDeepEqual:X3,isDeepStrictEqual:J3}});var oc=P((IF,XE)=>{"use strict";y();function Fr(e){"@babel/helpers - typeof";return Fr=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Fr(e)}function kE(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,e6(n.key),n)}}function Q3(e,t,r){return t&&kE(e.prototype,t),r&&kE(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e}function e6(e){var t=t6(e,"string");return Fr(t)==="symbol"?t:String(t)}function t6(e,t){if(Fr(e)!=="object"||e===null)return e;var r=e[Symbol.toPrimitive];if(r!==void 0){var n=r.call(e,t||"default");if(Fr(n)!=="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}function r6(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}var n6=Vd(),Pa=n6.codes,CE=Pa.ERR_AMBIGUOUS_ARGUMENT,ns=Pa.ERR_INVALID_ARG_TYPE,i6=Pa.ERR_INVALID_ARG_VALUE,o6=Pa.ERR_INVALID_RETURN_VALUE,ci=Pa.ERR_MISSING_ARGS,li=wS(),s6=en(),vc=s6.inspect,FE=en().types,a6=FE.isPromise,bc=FE.isRegExp,u6=jS()(),qE=cc()(),_c=$S()("RegExp.prototype.test"),fi,wc;function Ba(){var e=ME();fi=e.isDeepEqual,wc=e.isDeepStrictEqual}var LE=!1,Ge=XE.exports=sp,Sc={};function qr(e){throw e.message instanceof Error?e.message:new li(e)}function HE(e,t,r,n,i){var o=arguments.length,s;if(o===0)s="Failed";else if(o===1)r=e,e=void 0;else{if(LE===!1){LE=!0;var a=x.default.emitWarning?x.default.emitWarning:console.warn.bind(console);a("assert.fail() with more than one argument is deprecated. Please use assert.strictEqual() instead or only pass a message.","DeprecationWarning","DEP0094")}o===2&&(n="!=")}if(r instanceof Error)throw r;var c={actual:e,expected:t,operator:n===void 0?"fail":n,stackStartFn:i||HE};r!==void 0&&(c.message=r);var h=new li(c);throw s&&(h.message=s,h.generatedMessage=!0),h}Ge.fail=HE;Ge.AssertionError=li;function jE(e,t,r,n){if(!r){var i=!1;if(t===0)i=!0,n="No value argument passed to `assert.ok()`";else if(n instanceof Error)throw n;var o=new li({actual:r,expected:!0,message:n,operator:"==",stackStartFn:e});throw o.generatedMessage=i,o}}function sp(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];jE.apply(void 0,[sp,t.length].concat(t))}Ge.ok=sp;Ge.equal=function e(t,r,n){if(arguments.length<2)throw new ci("actual","expected");t!=r&&qr({actual:t,expected:r,message:n,operator:"==",stackStartFn:e})};Ge.notEqual=function e(t,r,n){if(arguments.length<2)throw new ci("actual","expected");t==r&&qr({actual:t,expected:r,message:n,operator:"!=",stackStartFn:e})};Ge.deepEqual=function e(t,r,n){if(arguments.length<2)throw new ci("actual","expected");fi===void 0&&Ba(),fi(t,r)||qr({actual:t,expected:r,message:n,operator:"deepEqual",stackStartFn:e})};Ge.notDeepEqual=function e(t,r,n){if(arguments.length<2)throw new ci("actual","expected");fi===void 0&&Ba(),fi(t,r)&&qr({actual:t,expected:r,message:n,operator:"notDeepEqual",stackStartFn:e})};Ge.deepStrictEqual=function e(t,r,n){if(arguments.length<2)throw new ci("actual","expected");fi===void 0&&Ba(),wc(t,r)||qr({actual:t,expected:r,message:n,operator:"deepStrictEqual",stackStartFn:e})};Ge.notDeepStrictEqual=KE;function KE(e,t,r){if(arguments.length<2)throw new ci("actual","expected");fi===void 0&&Ba(),wc(e,t)&&qr({actual:e,expected:t,message:r,operator:"notDeepStrictEqual",stackStartFn:KE})}Ge.strictEqual=function e(t,r,n){if(arguments.length<2)throw new ci("actual","expected");qE(t,r)||qr({actual:t,expected:r,message:n,operator:"strictEqual",stackStartFn:e})};Ge.notStrictEqual=function e(t,r,n){if(arguments.length<2)throw new ci("actual","expected");qE(t,r)&&qr({actual:t,expected:r,message:n,operator:"notStrictEqual",stackStartFn:e})};var DE=Q3(function e(t,r,n){var i=this;r6(this,e),r.forEach(function(o){o in t&&(n!==void 0&&typeof n[o]=="string"&&bc(t[o])&&_c(t[o],n[o])?i[o]=n[o]:i[o]=t[o])})});function f6(e,t,r,n,i,o){if(!(r in e)||!wc(e[r],t[r])){if(!n){var s=new DE(e,i),a=new DE(t,i,e),c=new li({actual:s,expected:a,operator:"deepStrictEqual",stackStartFn:o});throw c.actual=e,c.expected=t,c.operator=o.name,c}qr({actual:e,expected:t,message:n,operator:o.name,stackStartFn:o})}}function VE(e,t,r,n){if(typeof t!="function"){if(bc(t))return _c(t,e);if(arguments.length===2)throw new ns("expected",["Function","RegExp"],t);if(Fr(e)!=="object"||e===null){var i=new li({actual:e,expected:t,message:r,operator:"deepStrictEqual",stackStartFn:n});throw i.operator=n.name,i}var o=Object.keys(t);if(t instanceof Error)o.push("name","message");else if(o.length===0)throw new i6("error",t,"may not be an empty object");return fi===void 0&&Ba(),o.forEach(function(s){typeof e[s]=="string"&&bc(t[s])&&_c(t[s],e[s])||f6(e,t,s,r,o,n)}),!0}return t.prototype!==void 0&&e instanceof t?!0:Error.isPrototypeOf(t)?!1:t.call({},e)===!0}function GE(e){if(typeof e!="function")throw new ns("fn","Function",e);try{e()}catch(t){return t}return Sc}function UE(e){return a6(e)||e!==null&&Fr(e)==="object"&&typeof e.then=="function"&&typeof e.catch=="function"}function WE(e){return Promise.resolve().then(function(){var t;if(typeof e=="function"){if(t=e(),!UE(t))throw new o6("instance of Promise","promiseFn",t)}else if(UE(e))t=e;else throw new ns("promiseFn",["Function","Promise"],e);return Promise.resolve().then(function(){return t}).then(function(){return Sc}).catch(function(r){return r})})}function zE(e,t,r,n){if(typeof r=="string"){if(arguments.length===4)throw new ns("error",["Object","Error","Function","RegExp"],r);if(Fr(t)==="object"&&t!==null){if(t.message===r)throw new CE("error/message",'The error message "'.concat(t.message,'" is identical to the message.'))}else if(t===r)throw new CE("error/message",'The error "'.concat(t,'" is identical to the message.'));n=r,r=void 0}else if(r!=null&&Fr(r)!=="object"&&typeof r!="function")throw new ns("error",["Object","Error","Function","RegExp"],r);if(t===Sc){var i="";r&&r.name&&(i+=" (".concat(r.name,")")),i+=n?": ".concat(n):".";var o=e.name==="rejects"?"rejection":"exception";qr({actual:void 0,expected:r,operator:e.name,message:"Missing expected ".concat(o).concat(i),stackStartFn:e})}if(r&&!VE(t,r,n,e))throw t}function YE(e,t,r,n){if(t!==Sc){if(typeof r=="string"&&(n=r,r=void 0),!r||VE(t,r)){var i=n?": ".concat(n):".",o=e.name==="doesNotReject"?"rejection":"exception";qr({actual:t,expected:r,operator:e.name,message:"Got unwanted ".concat(o).concat(i,`
|
|
61
|
+
`)+'Actual message: "'.concat(t&&t.message,'"'),stackStartFn:e})}throw t}}Ge.throws=function e(t){for(var r=arguments.length,n=new Array(r>1?r-1:0),i=1;i<r;i++)n[i-1]=arguments[i];zE.apply(void 0,[e,GE(t)].concat(n))};Ge.rejects=function e(t){for(var r=arguments.length,n=new Array(r>1?r-1:0),i=1;i<r;i++)n[i-1]=arguments[i];return WE(t).then(function(o){return zE.apply(void 0,[e,o].concat(n))})};Ge.doesNotThrow=function e(t){for(var r=arguments.length,n=new Array(r>1?r-1:0),i=1;i<r;i++)n[i-1]=arguments[i];YE.apply(void 0,[e,GE(t)].concat(n))};Ge.doesNotReject=function e(t){for(var r=arguments.length,n=new Array(r>1?r-1:0),i=1;i<r;i++)n[i-1]=arguments[i];return WE(t).then(function(o){return YE.apply(void 0,[e,o].concat(n))})};Ge.ifError=function e(t){if(t!=null){var r="ifError got unwanted exception: ";Fr(t)==="object"&&typeof t.message=="string"?t.message.length===0&&t.constructor?r+=t.constructor.name:r+=t.message:r+=vc(t);var n=new li({actual:t,expected:null,operator:"ifError",message:r,stackStartFn:e}),i=t.stack;if(typeof i=="string"){var o=i.split(`
|
|
62
62
|
`);o.shift();for(var s=n.stack.split(`
|
|
63
63
|
`),a=0;a<o.length;a++){var c=s.indexOf(o[a]);if(c!==-1){s=s.slice(0,c);break}}n.stack="".concat(s.join(`
|
|
64
64
|
`),`
|
|
65
65
|
`).concat(o.join(`
|
|
66
|
-
`))}throw n}};function
|
|
66
|
+
`))}throw n}};function $E(e,t,r,n,i){if(!bc(t))throw new ns("regexp","RegExp",t);var o=i==="match";if(typeof e!="string"||_c(t,e)!==o){if(r instanceof Error)throw r;var s=!r;r=r||(typeof e!="string"?'The "string" argument must be of type string. Received type '+"".concat(Fr(e)," (").concat(vc(e),")"):(o?"The input did not match the regular expression ":"The input was expected to not match the regular expression ")+"".concat(vc(t),`. Input:
|
|
67
67
|
|
|
68
|
-
`).concat(
|
|
69
|
-
`));var a=new di({actual:e,expected:t,message:r,operator:i,stackStartFn:n});throw a.generatedMessage=s,a}}ze.match=function e(t,r,n){bE(t,r,n,e,"match")};ze.doesNotMatch=function e(t,r,n){bE(t,r,n,e,"doesNotMatch")};function _E(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];lE.apply(void 0,[_E,t.length].concat(t))}ze.strict=V8(_E,ze,{equal:ze.strictEqual,deepEqual:ze.deepStrictEqual,notEqual:ze.notStrictEqual,notDeepEqual:ze.notDeepStrictEqual});ze.strict.strict=ze.strict});var Qi=P((sH,EE)=>{"use strict";p();var SE=Jf(),rt=function e(t){if(!(this instanceof e))return new e(t);this.bufLen=0,t?this.set(t):this.bufs=[]};rt.prototype.set=function(e){return this.bufs=e.bufs||this.bufs||[],this.bufLen=this.bufs.reduce(function(t,r){return t+r.length},0),this};rt.prototype.toBuffer=function(){return this.concat()};rt.prototype.concat=function(){return d.Buffer.concat(this.bufs,this.bufLen)};rt.prototype.write=function(e){return SE(d.Buffer.isBuffer(e)),this.bufs.push(e),this.bufLen+=e.length,this};rt.prototype.writeReverse=function(e){return SE(d.Buffer.isBuffer(e)),this.bufs.push(d.Buffer.from(e).reverse()),this.bufLen+=e.length,this};rt.prototype.writeUInt8=function(e){var t=d.Buffer.alloc(1);return t.writeUInt8(e,0),this.write(t),this};rt.prototype.writeUInt16BE=function(e){var t=d.Buffer.alloc(2);return t.writeUInt16BE(e,0),this.write(t),this};rt.prototype.writeUInt16LE=function(e){var t=d.Buffer.alloc(2);return t.writeUInt16LE(e,0),this.write(t),this};rt.prototype.writeUInt32BE=function(e){var t=d.Buffer.alloc(4);return t.writeUInt32BE(e,0),this.write(t),this};rt.prototype.writeInt32LE=function(e){var t=d.Buffer.alloc(4);return t.writeInt32LE(e,0),this.write(t),this};rt.prototype.writeUInt32LE=function(e){var t=d.Buffer.alloc(4);return t.writeUInt32LE(e,0),this.write(t),this};rt.prototype.writeUInt64BEBN=function(e){var t=e.toBuffer({size:8});return this.write(t),this};rt.prototype.writeUInt64LEBN=function(e){var t=e.toBuffer({size:8});return this.writeReverse(t),this};rt.prototype.writeVarintNum=function(e){var t=rt.varintBufNum(e);return this.write(t),this};rt.prototype.writeVarintBN=function(e){var t=rt.varintBufBN(e);return this.write(t),this};rt.varintBufNum=function(e){var t;return e<253?(t=d.Buffer.alloc(1),t.writeUInt8(e,0)):e<65536?(t=d.Buffer.alloc(3),t.writeUInt8(253,0),t.writeUInt16LE(e,1)):e<4294967296?(t=d.Buffer.alloc(5),t.writeUInt8(254,0),t.writeUInt32LE(e,1)):(t=d.Buffer.alloc(9),t.writeUInt8(255,0),t.writeInt32LE(e&-1,1),t.writeUInt32LE(Math.floor(e/4294967296),5)),t};rt.varintBufBN=function(e){var t,r=e.toNumber();if(r<253)t=d.Buffer.alloc(1),t.writeUInt8(r,0);else if(r<65536)t=d.Buffer.alloc(3),t.writeUInt8(253,0),t.writeUInt16LE(r,1);else if(r<4294967296)t=d.Buffer.alloc(5),t.writeUInt8(254,0),t.writeUInt32LE(r,1);else{var n=new rt;n.writeUInt8(255),n.writeUInt64LEBN(e),t=n.concat()}return t};EE.exports=rt});var sp=P((uH,xE)=>{"use strict";p();var fs=Ge(),ka=Ce(),z8=lr();function Be(e){if(!(this instanceof Be))return new Be(e);var t;if(fs.isNumber(e))t=e;else if(fs.isString(e))t=Be.map[e];else throw new TypeError('Unrecognized num type: "'+typeof e+'" for Opcode');return z8.defineImmutable(this,{num:t}),this}Be.fromBuffer=function(e){return ka.checkArgument(d.Buffer.isBuffer(e)),new Be(+("0x"+e.toString("hex")))};Be.fromNumber=function(e){return ka.checkArgument(fs.isNumber(e)),new Be(e)};Be.fromString=function(e){ka.checkArgument(fs.isString(e));var t=Be.map[e];if(typeof t>"u")throw new TypeError("Invalid opcodestr");return new Be(t)};Be.prototype.toHex=function(){return this.num.toString(16)};Be.prototype.toBuffer=function(){return d.Buffer.from(this.toHex(),"hex")};Be.prototype.toNumber=function(){return this.num};Be.prototype.toString=function(){var e=Be.reverseMap[this.num];if(typeof e>"u")throw new Error("Opcode does not have a string representation");return e};Be.smallInt=function(e){return ka.checkArgument(fs.isNumber(e),"Invalid Argument: n should be number"),ka.checkArgument(e>=0&&e<=16,"Invalid Argument: n must be between 0 and 16"),e===0?Be("OP_0"):new Be(Be.map.OP_1+e-1)};Be.map={OP_FALSE:0,OP_0:0,OP_PUSHDATA1:76,OP_PUSHDATA2:77,OP_PUSHDATA4:78,OP_1NEGATE:79,OP_RESERVED:80,OP_TRUE:81,OP_1:81,OP_2:82,OP_3:83,OP_4:84,OP_5:85,OP_6:86,OP_7:87,OP_8:88,OP_9:89,OP_10:90,OP_11:91,OP_12:92,OP_13:93,OP_14:94,OP_15:95,OP_16:96,OP_NOP:97,OP_VER:98,OP_IF:99,OP_NOTIF:100,OP_VERIF:101,OP_VERNOTIF:102,OP_ELSE:103,OP_ENDIF:104,OP_VERIFY:105,OP_RETURN:106,OP_TOALTSTACK:107,OP_FROMALTSTACK:108,OP_2DROP:109,OP_2DUP:110,OP_3DUP:111,OP_2OVER:112,OP_2ROT:113,OP_2SWAP:114,OP_IFDUP:115,OP_DEPTH:116,OP_DROP:117,OP_DUP:118,OP_NIP:119,OP_OVER:120,OP_PICK:121,OP_ROLL:122,OP_ROT:123,OP_SWAP:124,OP_TUCK:125,OP_CAT:126,OP_SPLIT:127,OP_NUM2BIN:128,OP_BIN2NUM:129,OP_SIZE:130,OP_INVERT:131,OP_AND:132,OP_OR:133,OP_XOR:134,OP_EQUAL:135,OP_EQUALVERIFY:136,OP_RESERVED1:137,OP_RESERVED2:138,OP_1ADD:139,OP_1SUB:140,OP_2MUL:141,OP_2DIV:142,OP_NEGATE:143,OP_ABS:144,OP_NOT:145,OP_0NOTEQUAL:146,OP_ADD:147,OP_SUB:148,OP_MUL:149,OP_DIV:150,OP_MOD:151,OP_LSHIFT:152,OP_RSHIFT:153,OP_BOOLAND:154,OP_BOOLOR:155,OP_NUMEQUAL:156,OP_NUMEQUALVERIFY:157,OP_NUMNOTEQUAL:158,OP_LESSTHAN:159,OP_GREATERTHAN:160,OP_LESSTHANOREQUAL:161,OP_GREATERTHANOREQUAL:162,OP_MIN:163,OP_MAX:164,OP_WITHIN:165,OP_RIPEMD160:166,OP_SHA1:167,OP_SHA256:168,OP_HASH160:169,OP_HASH256:170,OP_CODESEPARATOR:171,OP_CHECKSIG:172,OP_CHECKSIGVERIFY:173,OP_CHECKMULTISIG:174,OP_CHECKMULTISIGVERIFY:175,OP_CHECKLOCKTIMEVERIFY:177,OP_CHECKSEQUENCEVERIFY:178,OP_NOP1:176,OP_NOP2:177,OP_NOP3:178,OP_SUBSTR:179,OP_LEFT:180,OP_RIGHT:181,OP_LSHIFTNUM:182,OP_RSHIFTNUM:183,OP_NOP9:184,OP_NOP10:185,OP_PUBKEYHASH:253,OP_PUBKEY:254,OP_INVALIDOPCODE:255};Be.reverseMap=[];for(op in Be.map)Be.reverseMap[Be.map[op]]=op;var op;fs.extend(Be,Be.map);Be.isSmallIntOp=function(e){return e instanceof Be&&(e=e.toNumber()),e===Be.map.OP_0||e>=Be.map.OP_1&&e<=Be.map.OP_16};Be.prototype.inspect=function(){return"<Opcode: "+this.toString()+", hex: "+this.toHex()+", decimal: "+this.num+">"};xE.exports=Be});var er=P((cH,AE)=>{"use strict";p();var eo=wr(),W8=Ge(),Qt=Ce(),Y8=lr(),Ie=function e(t,r){if(!(this instanceof e))return new e(t,r);if(t instanceof eo)this.set({r:t,s:r});else if(t){var n=t;this.set(n)}};Ie.prototype.set=function(e){return this.r=e.r||this.r||void 0,this.s=e.s||this.s||void 0,this.i=typeof e.i<"u"?e.i:this.i,this.compressed=typeof e.compressed<"u"?e.compressed:this.compressed,this.nhashtype=e.nhashtype||this.nhashtype||void 0,this};Ie.fromCompact=function(e){Qt.checkArgument(d.Buffer.isBuffer(e),"Argument is expected to be a Buffer");var t=new Ie,r=!0,n=e.slice(0,1)[0]-27-4;n<0&&(r=!1,n=n+4);var i=e.slice(1,33),o=e.slice(33,65);return Qt.checkArgument(n===0||n===1||n===2||n===3,new Error("i must be 0, 1, 2, or 3")),Qt.checkArgument(i.length===32,new Error("r must be 32 bytes")),Qt.checkArgument(o.length===32,new Error("s must be 32 bytes")),t.compressed=r,t.i=n,t.r=eo.fromBuffer(i),t.s=eo.fromBuffer(o),t};Ie.fromDER=Ie.fromBuffer=function(e,t){var r=Ie.parseDER(e,t),n=new Ie;return n.r=r.r,n.s=r.s,n};Ie.fromTxFormat=function(e){var t=e.readUInt8(e.length-1),r=e.slice(0,e.length-1),n=Ie.fromDER(r,!1);return n.nhashtype=t,n};Ie.fromString=function(e){var t=d.Buffer.from(e,"hex");return Ie.fromDER(t)};function IE(e,t){Qt.checkArgument(t.length>0,new Error("Length of "+e+" is zero")),Qt.checkArgument(!(t[0]&128),new Error("Value of "+e+" is negative")),Qt.checkArgument(!(t.length>1&&t[0]===0&&!(t[1]&128)),new Error("Value of "+e+" is excessively padded"))}Ie.parseDER=function(e,t){Qt.checkArgument(d.Buffer.isBuffer(e),new Error("DER formatted signature should be a buffer")),W8.isUndefined(t)&&(t=!0);var r=e[0];Qt.checkArgument(r===48,new Error("Header byte should be 0x30"));var n=e[1],i=e.slice(2).length;Qt.checkArgument(!t||n===i,new Error("Length byte should length of what follows")),n=n<i?n:i;var o=e[2];Qt.checkArgument(o===2,new Error("Integer byte for r should be 0x02"));var s=e[3],a=e.slice(4,4+s),c=eo.fromBuffer(a),l=e[4]===0;Qt.checkArgument(s===a.length,new Error("Length of r incorrect"));var g=e[4+s+0];Qt.checkArgument(g===2,new Error("Integer byte for s should be 0x02"));var m=e[4+s+1],_=e.slice(4+s+2,4+s+2+m),x=eo.fromBuffer(_),R=e[4+s+2]===0;Qt.checkArgument(m===_.length,new Error("Length of s incorrect"));var B=4+s+2+m;Qt.checkArgument(n===B-2,new Error("Length of signature incorrect")),t&&(IE("r",a),IE("s",_));var C={header:r,length:n,rheader:o,rlength:s,rneg:l,rbuf:a,r:c,sheader:g,slength:m,sneg:R,sbuf:_,s:x};return C};Ie.prototype.toCompact=function(e,t){if(e=typeof e=="number"?e:this.i,t=typeof t=="boolean"?t:this.compressed,!(e===0||e===1||e===2||e===3))throw new Error("i must be equal to 0, 1, 2, or 3");var r=e+27+4;t===!1&&(r=r-4);var n=d.Buffer.from([r]),i=this.r.toBuffer({size:32}),o=this.s.toBuffer({size:32});return d.Buffer.concat([n,i,o])};Ie.prototype.toBuffer=Ie.prototype.toDER=function(){var e=this.r.toBuffer(),t=this.s.toBuffer(),r=!!(e[0]&128),n=!!(t[0]&128),i=r?d.Buffer.concat([d.Buffer.from([0]),e]):e,o=n?d.Buffer.concat([d.Buffer.from([0]),t]):t,s=i.length,a=o.length,c=2+s+2+a,l=2,g=2,m=48,_=d.Buffer.concat([d.Buffer.from([m,c,l,s]),i,d.Buffer.from([g,a]),o]);return _};Ie.prototype.toString=function(){var e=this.toDER();return e.toString("hex")};Ie.isTxDER=function(e){if(e.length<9||e.length>73||e[0]!==48||e[1]!==e.length-3)return!1;var t=e[3];if(5+t>=e.length)return!1;var r=e[5+t];if(t+r+7!==e.length)return!1;var n=e.slice(4);if(e[2]!==2||t===0||n[0]&128||t>1&&n[0]===0&&!(n[1]&128))return!1;var i=e.slice(6+t);return!(e[6+t-2]!==2||r===0||i[0]&128||r>1&&i[0]===0&&!(i[1]&128))};Ie.prototype.hasLowS=function(){return!(this.s.lt(new eo(1))||this.s.gt(new eo("7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0","hex")))};Ie.prototype.hasDefinedHashtype=function(){if(!Y8.isNaturalNumber(this.nhashtype))return!1;var e=this.nhashtype&31;return!(e<Ie.SIGHASH_ALL||e>Ie.SIGHASH_SINGLE)};Ie.prototype.toTxFormat=function(){var e=this.toDER(),t=d.Buffer.alloc(1);return t.writeUInt8(this.nhashtype,0),d.Buffer.concat([e,t])};Ie.SIGHASH_ALL=1;Ie.SIGHASH_NONE=2;Ie.SIGHASH_SINGLE=3;Ie.SIGHASH_CHRONICLE=32;Ie.SIGHASH_FORKID=64;Ie.SIGHASH_ANYONECANPAY=128;Ie.prototype.isCanonical=function(){var e=si(),t=e.getN().shrn(1);return this.s.lte(t)};Ie.prototype.toCanonical=function(){if(this.isCanonical())return new Ie({r:this.r,s:this.s,i:this.i,compressed:this.compressed,nhashtype:this.nhashtype});var e=si(),t=e.getN(),r=t.sub(this.s);return new Ie({r:this.r,s:r,i:this.i,compressed:this.compressed,nhashtype:this.nhashtype})};Ie.prototype.validate=function(){if(!this.r||!this.s)throw new Error("Signature missing r or s component");if(this.r.isZero())throw new Error("Signature r component is zero");if(this.s.isZero())throw new Error("Signature s component is zero");var e=si(),t=e.getN();if(this.r.gte(t))throw new Error("Signature r component >= curve order");if(this.s.gte(t))throw new Error("Signature s component >= curve order");if(this.r.isNeg())throw new Error("Signature r component is negative");if(this.s.isNeg())throw new Error("Signature s component is negative");return!0};Ie.prototype.isValid=function(){try{return this.validate(),!0}catch{return!1}};Ie.prototype.applySecurityPatches=function(){var e=si(),t=e.getN(),r=t.shrn(1);if(this.r.isZero()||this.s.isZero())throw new Error("Invalid signature: zero r or s");if(this.r.gte(t)||this.s.gte(t))throw new Error("Invalid signature: out of range");if(this.s.gt(r))throw new Error("Invalid signature: non-canonical (high) s");return this};AE.exports=Ie});var fp=P((lH,TE)=>{"use strict";p();var Hr=no(),$8=_a(),Z8=Qi(),ap=Zt(),Z=sp(),ro=Or(),to=er(),OE=va(),Ze=Ce(),Ae=Ge(),up=ri(),RE=Pt(),X8=lr(),L=function e(t){if(!(this instanceof e))return new e(t);if(this.chunks=[],d.Buffer.isBuffer(t))return e.fromBuffer(t);if(t instanceof Hr)return e.fromAddress(t);if(t instanceof e)return e.fromBuffer(t.toBuffer());if(Ae.isString(t))return e.fromString(t);Ae.isObject(t)&&Ae.isArray(t.chunks)&&this.set(t)};L.prototype.set=function(e){return Ze.checkArgument(Ae.isObject(e)),Ze.checkArgument(Ae.isArray(e.chunks)),this.chunks=e.chunks,this};L.fromBuffer=function(e){var t=new L;t.chunks=[];for(var r=new $8(e);!r.finished();)try{var n=r.readUInt8(),i,o;n>0&&n<Z.OP_PUSHDATA1?(i=n,t.chunks.push({buf:r.read(i),len:i,opcodenum:n})):n===Z.OP_PUSHDATA1?(i=r.readUInt8(),o=r.read(i),t.chunks.push({buf:o,len:i,opcodenum:n})):n===Z.OP_PUSHDATA2?(i=r.readUInt16LE(),o=r.read(i),t.chunks.push({buf:o,len:i,opcodenum:n})):n===Z.OP_PUSHDATA4?(i=r.readUInt32LE(),o=r.read(i),t.chunks.push({buf:o,len:i,opcodenum:n})):t.chunks.push({opcodenum:n})}catch(s){throw s instanceof RangeError?new up.Script.InvalidBuffer(e.toString("hex")):s}return t};L.prototype.toBuffer=function(){for(var e=new Z8,t=0;t<this.chunks.length;t++){var r=this.chunks[t],n=r.opcodenum;e.writeUInt8(r.opcodenum),r.buf&&(n<Z.OP_PUSHDATA1?e.write(r.buf):n===Z.OP_PUSHDATA1?(e.writeUInt8(r.len),e.write(r.buf)):n===Z.OP_PUSHDATA2?(e.writeUInt16LE(r.len),e.write(r.buf)):n===Z.OP_PUSHDATA4&&(e.writeUInt32LE(r.len),e.write(r.buf)))}return e.concat()};L.fromASM=function(e){var t=new L;t.chunks=[];for(var r=e.split(" "),n=0;n<r.length;){var i=r[n],o=Z(i),s=o.toNumber();if(i==="0")s=0,t.chunks.push({opcodenum:s}),n=n+1;else if(i==="-1")s=Z.OP_1NEGATE,t.chunks.push({opcodenum:s}),n=n+1;else if(Ae.isUndefined(s)){var a=d.Buffer.from(r[n],"hex");if(a.toString("hex")!==r[n])throw new Error("invalid hex string in script");var c=a.length;c>=0&&c<Z.OP_PUSHDATA1?s=c:c<Math.pow(2,8)?s=Z.OP_PUSHDATA1:c<Math.pow(2,16)?s=Z.OP_PUSHDATA2:c<Math.pow(2,32)&&(s=Z.OP_PUSHDATA4),t.chunks.push({buf:a,len:a.length,opcodenum:s}),n=n+1}else t.chunks.push({opcodenum:s}),n=n+1}return t};L.fromHex=function(e){return new L(RE.Buffer.from(e,"hex"))};L.fromString=function(e){if(X8.isHexa(e)||e.length===0)return new L(RE.Buffer.from(e,"hex"));var t=new L;t.chunks=[];for(var r=e.split(" "),n=0;n<r.length;){var i=r[n],o=Z(i),s=o.toNumber();if(Ae.isUndefined(s))if(s=parseInt(i),s>0&&s<Z.OP_PUSHDATA1)t.chunks.push({buf:d.Buffer.from(r[n+1].slice(2),"hex"),len:s,opcodenum:s}),n=n+2;else throw new Error("Invalid script: "+JSON.stringify(e));else if(s===Z.OP_PUSHDATA1||s===Z.OP_PUSHDATA2||s===Z.OP_PUSHDATA4){if(r[n+2].slice(0,2)!=="0x")throw new Error("Pushdata data must start with 0x");t.chunks.push({buf:d.Buffer.from(r[n+2].slice(2),"hex"),len:parseInt(r[n+1]),opcodenum:s}),n=n+3}else t.chunks.push({opcodenum:s}),n=n+1}return t};L.prototype._chunkToString=function(e,t){var r=e.opcodenum,n=t==="asm",i="";if(e.buf)!n&&(r===Z.OP_PUSHDATA1||r===Z.OP_PUSHDATA2||r===Z.OP_PUSHDATA4)&&(i=i+" "+Z(r).toString()),e.len>0&&(n?i=i+" "+e.buf.toString("hex"):i=i+" "+e.len+" 0x"+e.buf.toString("hex"));else if(typeof Z.reverseMap[r]<"u")n?r===0?i=i+" 0":r===79?i=i+" -1":i=i+" "+Z(r).toString():i=i+" "+Z(r).toString();else{var o=r.toString(16);o.length%2!==0&&(o="0"+o),n?i=i+" "+o:i=i+" 0x"+o}return i};L.prototype.toASM=function(){for(var e="",t=0;t<this.chunks.length;t++){var r=this.chunks[t];e+=this._chunkToString(r,"asm")}return e.substr(1)};L.prototype.toString=function(){for(var e="",t=0;t<this.chunks.length;t++){var r=this.chunks[t];e+=this._chunkToString(r)}return e.substr(1)};L.prototype.toHex=function(){return this.toBuffer().toString("hex")};L.prototype.inspect=function(){return"<Script: "+this.toString()+">"};L.prototype.isPublicKeyHashOut=function(){return!!(this.chunks.length===5&&this.chunks[0].opcodenum===Z.OP_DUP&&this.chunks[1].opcodenum===Z.OP_HASH160&&this.chunks[2].buf&&this.chunks[2].buf.length===20&&this.chunks[3].opcodenum===Z.OP_EQUALVERIFY&&this.chunks[4].opcodenum===Z.OP_CHECKSIG)};L.prototype.isPublicKeyHashOutPrefix=function(){return!!(this.chunks.length>=5&&this.chunks[0].opcodenum===Z.OP_DUP&&this.chunks[1].opcodenum===Z.OP_HASH160&&this.chunks[2].buf&&this.chunks[2].buf.length===20&&this.chunks[3].opcodenum===Z.OP_EQUALVERIFY&&this.chunks[4].opcodenum===Z.OP_CHECKSIG)};L.prototype.isPublicKeyHashIn=function(){if(this.chunks.length===2){var e=this.chunks[0].buf,t=this.chunks[1].buf;if(e&&e.length&&e[0]===48&&t&&t.length){var r=t[0];if((r===4||r===6||r===7)&&t.length===65)return!0;if((r===3||r===2)&&t.length===33)return!0}}return!1};L.prototype.getPublicKey=function(){return Ze.checkState(this.isPublicKeyOut(),"Can't retrieve PublicKey from a non-PK output"),this.chunks[0].buf};L.prototype.getPublicKeyHash=function(){return Ze.checkState(this.isPublicKeyHashOut(),"Can't retrieve PublicKeyHash from a non-PKH output"),this.chunks[2].buf};L.prototype.isPublicKeyOut=function(){if(this.chunks.length===2&&this.chunks[0].buf&&this.chunks[0].buf.length&&this.chunks[1].opcodenum===Z.OP_CHECKSIG){var e=this.chunks[0].buf,t=e[0],r=!1;if(((t===4||t===6||t===7)&&e.length===65||(t===3||t===2)&&e.length===33)&&(r=!0),r)return ro.isValid(e)}return!1};L.prototype.isPublicKeyIn=function(){if(this.chunks.length===1){var e=this.chunks[0].buf;if(e&&e.length&&e[0]===48)return!0}return!1};L.prototype.isScriptHashOut=function(){var e=this.toBuffer();return e.length===23&&e[0]===Z.OP_HASH160&&e[1]===20&&e[e.length-1]===Z.OP_EQUAL};L.prototype.isScriptHashIn=function(){if(this.chunks.length<=1)return!1;var e=this.chunks[this.chunks.length-1],t=e.buf;if(!t)return!1;var r;try{r=L.fromBuffer(t)}catch(i){if(i instanceof up.Script.InvalidBuffer)return!1;throw i}var n=r.classify();return n!==L.types.UNKNOWN};L.prototype.isMultisigOut=function(){return this.chunks.length>3&&Z.isSmallIntOp(this.chunks[0].opcodenum)&&this.chunks.slice(1,this.chunks.length-2).every(function(e){return e.buf&&d.Buffer.isBuffer(e.buf)})&&Z.isSmallIntOp(this.chunks[this.chunks.length-2].opcodenum)&&this.chunks[this.chunks.length-1].opcodenum===Z.OP_CHECKMULTISIG};L.prototype.isMultisigIn=function(){return this.chunks.length>=2&&this.chunks[0].opcodenum===0&&this.chunks.slice(1,this.chunks.length).every(function(e){return e.buf&&d.Buffer.isBuffer(e.buf)&&to.isTxDER(e.buf)})};L.prototype.isDataOut=function(){var e=this.chunks.length>=1&&this.chunks[0].opcodenum===Z.OP_RETURN;if(!e)return!1;var t=this.chunks.slice(1),r=new L({chunks:t});return r.isPushOnly()};L.prototype.isSafeDataOut=function(){if(this.chunks.length<2||this.chunks[0].opcodenum!==Z.OP_FALSE)return!1;var e=this.chunks.slice(1),t=new L({chunks:e});return t.isDataOut()};L.prototype.getData=function(){if(this.isSafeDataOut()){var e=this.chunks.slice(2),t=e.map(r=>r.buf);return t}if(this.isDataOut()||this.isScriptHashOut())return Ae.isUndefined(this.chunks[1])?d.Buffer.alloc(0):d.Buffer.from(this.chunks[1].buf);if(this.isPublicKeyHashOut())return d.Buffer.from(this.chunks[2].buf);throw new Error("Unrecognized script type to get data from")};L.prototype.isPushOnly=function(){return Ae.every(this.chunks,function(e){return e.opcodenum<=Z.OP_16||e.opcodenum===Z.OP_PUSHDATA1||e.opcodenum===Z.OP_PUSHDATA2||e.opcodenum===Z.OP_PUSHDATA4})};L.types={};L.types.UNKNOWN="Unknown";L.types.PUBKEY_OUT="Pay to public key";L.types.PUBKEY_IN="Spend from public key";L.types.PUBKEYHASH_OUT="Pay to public key hash";L.types.PUBKEYHASH_IN="Spend from public key hash";L.types.SCRIPTHASH_OUT="Pay to script hash";L.types.SCRIPTHASH_IN="Spend from script hash";L.types.MULTISIG_OUT="Pay to multisig";L.types.MULTISIG_IN="Spend from multisig";L.types.DATA_OUT="Data push";L.types.SAFE_DATA_OUT="Safe data push";L.OP_RETURN_STANDARD_SIZE=220;L.prototype.classify=function(){if(this._isInput)return this.classifyInput();if(this._isOutput)return this.classifyOutput();var e=this.classifyOutput();return e!==L.types.UNKNOWN?e:this.classifyInput()};L.outputIdentifiers={};L.outputIdentifiers.PUBKEY_OUT=L.prototype.isPublicKeyOut;L.outputIdentifiers.PUBKEYHASH_OUT=L.prototype.isPublicKeyHashOut;L.outputIdentifiers.MULTISIG_OUT=L.prototype.isMultisigOut;L.outputIdentifiers.SCRIPTHASH_OUT=L.prototype.isScriptHashOut;L.outputIdentifiers.DATA_OUT=L.prototype.isDataOut;L.outputIdentifiers.SAFE_DATA_OUT=L.prototype.isSafeDataOut;L.prototype.classifyOutput=function(){for(var e in L.outputIdentifiers)if(L.outputIdentifiers[e].bind(this)())return L.types[e];return L.types.UNKNOWN};L.inputIdentifiers={};L.inputIdentifiers.PUBKEY_IN=L.prototype.isPublicKeyIn;L.inputIdentifiers.PUBKEYHASH_IN=L.prototype.isPublicKeyHashIn;L.inputIdentifiers.MULTISIG_IN=L.prototype.isMultisigIn;L.inputIdentifiers.SCRIPTHASH_IN=L.prototype.isScriptHashIn;L.prototype.classifyInput=function(){for(var e in L.inputIdentifiers)if(L.inputIdentifiers[e].bind(this)())return L.types[e];return L.types.UNKNOWN};L.prototype.isStandard=function(){return this.classify()!==L.types.UNKNOWN};L.prototype.prepend=function(e){return this._addByType(e,!0),this};L.prototype.equals=function(e){if(Ze.checkState(e instanceof L,"Must provide another script"),this.chunks.length!==e.chunks.length)return!1;var t;for(t=0;t<this.chunks.length;t++){if(d.Buffer.isBuffer(this.chunks[t].buf)&&!d.Buffer.isBuffer(e.chunks[t].buf)||d.Buffer.isBuffer(this.chunks[t].buf)&&!this.chunks[t].buf.equals(e.chunks[t].buf))return!1;if(this.chunks[t].opcodenum!==e.chunks[t].opcodenum)return!1}return!0};L.prototype.add=function(e){return this._addByType(e,!1),this};L.prototype._addByType=function(e,t){if(typeof e=="string")this._addOpcode(e,t);else if(typeof e=="number")this._addOpcode(e,t);else if(e instanceof Z)this._addOpcode(e,t);else if(d.Buffer.isBuffer(e))this._addBuffer(e,t);else if(e instanceof L)this.chunks=this.chunks.concat(e.chunks);else if(typeof e=="object")this._insertAtPosition(e,t);else throw new Error("Invalid script chunk")};L.prototype._insertAtPosition=function(e,t){t?this.chunks.unshift(e):this.chunks.push(e)};L.prototype._addOpcode=function(e,t){var r;return typeof e=="number"?r=e:e instanceof Z?r=e.toNumber():r=Z(e).toNumber(),this._insertAtPosition({opcodenum:r},t),this};L.prototype._addBuffer=function(e,t){var r,n=e.length;if(n>=0&&n<Z.OP_PUSHDATA1)r=n;else if(n<Math.pow(2,8))r=Z.OP_PUSHDATA1;else if(n<Math.pow(2,16))r=Z.OP_PUSHDATA2;else if(n<Math.pow(2,32))r=Z.OP_PUSHDATA4;else throw new Error("You can't push that much data");return this._insertAtPosition({buf:e,len:n,opcodenum:r},t),this};L.prototype.removeCodeseparators=function(){for(var e=[],t=0;t<this.chunks.length;t++)this.chunks[t].opcodenum!==Z.OP_CODESEPARATOR&&e.push(this.chunks[t]);return this.chunks=e,this};L.buildMultisigOut=function(e,t,r){Ze.checkArgument(t<=e.length,"Number of required signatures must be less than or equal to the number of public keys"),r=r||{};var n=new L;n.add(Z.smallInt(t)),e=Ae.map(e,ro);var i=e;r.noSorting||(i=e.map(a=>a.toString("hex")).sort().map(a=>new ro(a)));for(var o=0;o<i.length;o++){var s=i[o];n.add(s.toBuffer())}return n.add(Z.smallInt(e.length)),n.add(Z.OP_CHECKMULTISIG),n};L.buildMultisigIn=function(e,t,r,n){Ze.checkArgument(Ae.isArray(e)),Ze.checkArgument(Ae.isNumber(t)),Ze.checkArgument(Ae.isArray(r)),n=n||{};var i=new L;return i.add(Z.OP_0),Ae.each(r,function(o){Ze.checkArgument(d.Buffer.isBuffer(o),"Signatures must be an array of Buffers"),i.add(o)}),i};L.buildP2SHMultisigIn=function(e,t,r,n){Ze.checkArgument(Ae.isArray(e)),Ze.checkArgument(Ae.isNumber(t)),Ze.checkArgument(Ae.isArray(r)),n=n||{};var i=new L;return i.add(Z.OP_0),Ae.each(r,function(o){Ze.checkArgument(d.Buffer.isBuffer(o),"Signatures must be an array of Buffers"),i.add(o)}),i.add((n.cachedMultisig||L.buildMultisigOut(e,t,n)).toBuffer()),i};L.buildPublicKeyHashOut=function(e){Ze.checkArgument(!Ae.isUndefined(e)),Ze.checkArgument(e instanceof ro||e instanceof Hr||Ae.isString(e)),e instanceof ro?e=e.toAddress():Ae.isString(e)&&(e=new Hr(e));var t=new L;return t.add(Z.OP_DUP).add(Z.OP_HASH160).add(e.hashBuffer).add(Z.OP_EQUALVERIFY).add(Z.OP_CHECKSIG),t._network=e.network,t};L.buildPublicKeyOut=function(e){Ze.checkArgument(e instanceof ro);var t=new L;return t.add(e.toBuffer()).add(Z.OP_CHECKSIG),t};L.buildDataOut=function(e,t){Ze.checkArgument(Ae.isUndefined(e)||Ae.isString(e)||Ae.isArray(e)||d.Buffer.isBuffer(e));var r=e;Ae.isArray(r)||(r=[e]);var n=new L;n.add(Z.OP_RETURN);for(let i of r)Ze.checkArgument(Ae.isUndefined(i)||Ae.isString(i)||d.Buffer.isBuffer(i)),Ae.isString(i)&&(i=d.Buffer.from(i,t)),Ae.isUndefined(i)||n.add(i);return n};L.buildSafeDataOut=function(e,t){var r=L.buildDataOut(e,t),n=new L;return n.add(Z.OP_FALSE),n.add(r),n};L.buildScriptHashOut=function(e){Ze.checkArgument(e instanceof L||e instanceof Hr&&e.isPayToScriptHash());var t=new L;return t.add(Z.OP_HASH160).add(e instanceof Hr?e.hashBuffer:ap.sha256ripemd160(e.toBuffer())).add(Z.OP_EQUAL),t._network=e._network||e.network,t};L.buildPublicKeyIn=function(e,t){Ze.checkArgument(e instanceof to||d.Buffer.isBuffer(e)),Ze.checkArgument(Ae.isUndefined(t)||Ae.isNumber(t)),e instanceof to&&(e=e.toBuffer());var r=new L;return r.add(d.Buffer.concat([e,d.Buffer.from([(t||to.SIGHASH_ALL)&255])])),r};L.buildPublicKeyHashIn=function(e,t,r){Ze.checkArgument(t instanceof to||d.Buffer.isBuffer(t)),Ze.checkArgument(Ae.isUndefined(r)||Ae.isNumber(r)),t instanceof to&&(t=t.toBuffer());var n=new L().add(d.Buffer.concat([t,d.Buffer.from([(r||to.SIGHASH_ALL)&255])])).add(new ro(e).toBuffer());return n};L.empty=function(){return new L};L.prototype.toScriptHashOut=function(){return L.buildScriptHashOut(this)};L.fromAddress=function(e){if(e=Hr(e),e.isPayToScriptHash())return L.buildScriptHashOut(e);if(e.isPayToPublicKeyHash())return L.buildPublicKeyHashOut(e);throw new up.Script.UnrecognizedAddress(e)};L.prototype.getAddressInfo=function(e){if(this._isInput)return this._getInputAddressInfo();if(this._isOutput)return this._getOutputAddressInfo();var t=this._getOutputAddressInfo();return t||this._getInputAddressInfo()};L.prototype._getOutputAddressInfo=function(){var e={};if(this.isScriptHashOut())e.hashBuffer=this.getData(),e.type=Hr.PayToScriptHash;else if(this.isPublicKeyHashOut())e.hashBuffer=this.getData(),e.type=Hr.PayToPublicKeyHash;else return!1;return e};L.prototype._getInputAddressInfo=function(){var e={};if(this.isPublicKeyHashIn())e.hashBuffer=ap.sha256ripemd160(this.chunks[1].buf),e.type=Hr.PayToPublicKeyHash;else if(this.isScriptHashIn())e.hashBuffer=ap.sha256ripemd160(this.chunks[this.chunks.length-1].buf),e.type=Hr.PayToScriptHash;else return!1;return e};L.prototype.toAddress=function(e){var t=this.getAddressInfo();return t?(t.network=OE.get(e)||this._network||OE.defaultNetwork,new Hr(t)):!1};L.prototype.findAndDelete=function(e){for(var t=e.toBuffer(),r=t.toString("hex"),n=0;n<this.chunks.length;n++){var i=L({chunks:[this.chunks[n]]}),o=i.toBuffer(),s=o.toString("hex");r===s&&this.chunks.splice(n,1)}return this};L.prototype.checkMinimalPush=function(e){var t=this.chunks[e],r=t.buf,n=t.opcodenum;return r?r.length===0?n===Z.OP_0:r.length===1&&r[0]>=1&&r[0]<=16?n===Z.OP_1+(r[0]-1):r.length===1&&r[0]===129?n===Z.OP_1NEGATE:r.length<=75?n===r.length:r.length<=255?n===Z.OP_PUSHDATA1:r.length<=65535?n===Z.OP_PUSHDATA2:!0:!0};L.prototype._decodeOP_N=function(e){if(e===Z.OP_0)return 0;if(e>=Z.OP_1&&e<=Z.OP_16)return e-(Z.OP_1-1);throw new Error("Invalid opcode: "+JSON.stringify(e))};L.prototype.getSignatureOperationsCount=function(e){e=Ae.isUndefined(e)?!0:e;var t=this,r=0,n=Z.OP_INVALIDOPCODE;return Ae.each(t.chunks,function(o){var s=o.opcodenum;s===Z.OP_CHECKSIG||s===Z.OP_CHECKSIGVERIFY?r++:(s===Z.OP_CHECKMULTISIG||s===Z.OP_CHECKMULTISIGVERIFY)&&(e&&n>=Z.OP_1&&n<=Z.OP_16?r+=t._decodeOP_N(n):r+=20),n=s}),r};TE.exports=L});var cp=P((pH,BE)=>{p();var J8=Object.prototype.toString;BE.exports=function(t){if(t===void 0)return"undefined";if(t===null)return"null";var r=typeof t;if(r==="boolean")return"boolean";if(r==="string")return"string";if(r==="number")return"number";if(r==="symbol")return"symbol";if(r==="function")return nk(t)?"generatorfunction":"function";if(Q8(t))return"array";if(sk(t))return"buffer";if(ok(t))return"arguments";if(tk(t))return"date";if(ek(t))return"error";if(rk(t))return"regexp";switch(PE(t)){case"Symbol":return"symbol";case"Promise":return"promise";case"WeakMap":return"weakmap";case"WeakSet":return"weakset";case"Map":return"map";case"Set":return"set";case"Int8Array":return"int8array";case"Uint8Array":return"uint8array";case"Uint8ClampedArray":return"uint8clampedarray";case"Int16Array":return"int16array";case"Uint16Array":return"uint16array";case"Int32Array":return"int32array";case"Uint32Array":return"uint32array";case"Float32Array":return"float32array";case"Float64Array":return"float64array"}if(ik(t))return"generator";switch(r=J8.call(t),r){case"[object Object]":return"object";case"[object Map Iterator]":return"mapiterator";case"[object Set Iterator]":return"setiterator";case"[object String Iterator]":return"stringiterator";case"[object Array Iterator]":return"arrayiterator"}return r.slice(8,-1).toLowerCase().replace(/\s/g,"")};function PE(e){return typeof e.constructor=="function"?e.constructor.name:null}function Q8(e){return Array.isArray?Array.isArray(e):e instanceof Array}function ek(e){return e instanceof Error||typeof e.message=="string"&&e.constructor&&typeof e.constructor.stackTraceLimit=="number"}function tk(e){return e instanceof Date?!0:typeof e.toDateString=="function"&&typeof e.getDate=="function"&&typeof e.setDate=="function"}function rk(e){return e instanceof RegExp?!0:typeof e.flags=="string"&&typeof e.ignoreCase=="boolean"&&typeof e.multiline=="boolean"&&typeof e.global=="boolean"}function nk(e,t){return PE(e)==="GeneratorFunction"}function ik(e){return typeof e.throw=="function"&&typeof e.return=="function"&&typeof e.next=="function"}function ok(e){try{if(typeof e.length=="number"&&typeof e.callee=="function")return!0}catch(t){if(t.message.indexOf("callee")!==-1)return!0}return!1}function sk(e){return e.constructor&&typeof e.constructor.isBuffer=="function"?e.constructor.isBuffer(e):!1}});var kE=P((yH,ME)=>{"use strict";p();var NE=Symbol.prototype.valueOf,ak=cp();function uk(e,t){switch(ak(e)){case"array":return e.slice();case"object":return Object.assign({},e);case"date":return new e.constructor(Number(e));case"map":return new Map(e);case"set":return new Set(e);case"buffer":return lk(e);case"symbol":return dk(e);case"arraybuffer":return ck(e);case"float32array":case"float64array":case"int16array":case"int32array":case"int8array":case"uint16array":case"uint32array":case"uint8clampedarray":case"uint8array":return hk(e);case"regexp":return fk(e);case"error":return Object.create(e);default:return e}}function fk(e){let t=e.flags!==void 0?e.flags:/\w+$/.exec(e)||void 0,r=new e.constructor(e.source,t);return r.lastIndex=e.lastIndex,r}function ck(e){let t=new e.constructor(e.byteLength);return new Uint8Array(t).set(new Uint8Array(e)),t}function hk(e,t){return new e.constructor(e.buffer,e.byteOffset,e.length)}function lk(e){let t=e.length,r=d.Buffer.allocUnsafe?d.Buffer.allocUnsafe(t):d.Buffer.from(t);return e.copy(r),r}function dk(e){return NE?Object(NE.call(e)):{}}ME.exports=uk});var LE=P((vH,CE)=>{"use strict";p();CE.exports=function(t){return t!=null&&typeof t=="object"&&Array.isArray(t)===!1}});var qE=P((_H,UE)=>{"use strict";p();var pk=LE();function DE(e){return pk(e)===!0&&Object.prototype.toString.call(e)==="[object Object]"}UE.exports=function(t){var r,n;return!(DE(t)===!1||(r=t.constructor,typeof r!="function")||(n=r.prototype,DE(n)===!1)||n.hasOwnProperty("isPrototypeOf")===!1)}});var HE=P((SH,FE)=>{"use strict";p();var gk=kE(),yk=cp(),mk=qE();function hp(e,t){switch(yk(e)){case"object":return vk(e,t);case"array":return bk(e,t);default:return gk(e)}}function vk(e,t){if(typeof t=="function")return t(e);if(t||mk(e)){let r=new e.constructor;for(let n in e)r[n]=hp(e[n],t);return r}return e}function bk(e,t){let r=new e.constructor(e.length);for(let n=0;n<e.length;n++)r[n]=hp(e[n],t);return r}FE.exports=hp});var Ca=P((xH,VE)=>{"use strict";p();var jE=Qi(),KE=_a(),_k=wr(),jr=function e(t){if(!(this instanceof e))return new e(t);if(d.Buffer.isBuffer(t))this.buf=t;else if(typeof t=="number"){var r=t;this.fromNumber(r)}else if(t instanceof _k){var n=t;this.fromBN(n)}else if(t){var i=t;this.set(i)}};jr.prototype.set=function(e){return this.buf=e.buf||this.buf,this};jr.prototype.fromString=function(e){return this.set({buf:d.Buffer.from(e,"hex")}),this};jr.prototype.toString=function(){return this.buf.toString("hex")};jr.prototype.fromBuffer=function(e){return this.buf=e,this};jr.prototype.fromBufferReader=function(e){return this.buf=e.readVarintBuf(),this};jr.prototype.fromBN=function(e){return this.buf=jE().writeVarintBN(e).concat(),this};jr.prototype.fromNumber=function(e){return this.buf=jE().writeVarintNum(e).concat(),this};jr.prototype.toBuffer=function(){return this.buf};jr.prototype.toBN=function(){return KE(this.buf).readVarintBN()};jr.prototype.toNumber=function(){return KE(this.buf).readVarintNum()};VE.exports=jr});var Hn=P((AH,zE)=>{"use strict";p();var yc=Ge(),lp=wr(),GE=Pt(),mc=lr(),wk=Qi(),Sk=Ca(),dp=Kr(),pp=Ce(),Ek=ri(),xk=9007199254740991;function Ft(e){if(!(this instanceof Ft))return new Ft(e);if(yc.isObject(e))if(this.satoshis=e.satoshis,d.Buffer.isBuffer(e.script))this._scriptBuffer=e.script;else{var t;yc.isString(e.script)&&mc.isHexa(e.script)?t=GE.Buffer.from(e.script,"hex"):t=e.script,this.setScript(t)}else throw new TypeError("Unrecognized argument for Output")}Object.defineProperty(Ft.prototype,"script",{configurable:!1,enumerable:!0,get:function(){return this._script?this._script:(this.setScriptFromBuffer(this._scriptBuffer),this._script)}});Object.defineProperty(Ft.prototype,"satoshis",{configurable:!1,enumerable:!0,get:function(){return this._satoshis},set:function(e){e instanceof lp?(this._satoshisBN=e,this._satoshis=e.toNumber()):yc.isString(e)?(this._satoshis=parseInt(e),this._satoshisBN=lp.fromNumber(this._satoshis)):(pp.checkArgument(mc.isNaturalNumber(e),"Output satoshis is not a natural number"),this._satoshisBN=lp.fromNumber(e),this._satoshis=e),pp.checkState(mc.isNaturalNumber(this._satoshis),"Output satoshis is not a natural number")}});Ft.prototype.invalidSatoshis=function(){return this._satoshis>xk?"transaction txout satoshis greater than max safe integer":this._satoshis!==this._satoshisBN.toNumber()?"transaction txout satoshis has corrupted value":this._satoshis<0?"transaction txout negative":!1};Object.defineProperty(Ft.prototype,"satoshisBN",{configurable:!1,enumerable:!0,get:function(){return this._satoshisBN},set:function(e){this._satoshisBN=e,this._satoshis=e.toNumber(),pp.checkState(mc.isNaturalNumber(this._satoshis),"Output satoshis is not a natural number")}});Ft.prototype.toObject=Ft.prototype.toJSON=function(){var t={satoshis:this.satoshis};return t.script=this._scriptBuffer.toString("hex"),t};Ft.fromObject=function(e){return new Ft(e)};Ft.prototype.setScriptFromBuffer=function(e){this._scriptBuffer=e;try{this._script=dp.fromBuffer(this._scriptBuffer),this._script._isOutput=!0}catch(t){if(t instanceof Ek.Script.InvalidBuffer)this._script=null;else throw t}};Ft.prototype.setScript=function(e){if(e instanceof dp)this._scriptBuffer=e.toBuffer(),this._script=e,this._script._isOutput=!0;else if(yc.isString(e))this._script=dp.fromString(e),this._scriptBuffer=this._script.toBuffer(),this._script._isOutput=!0;else if(d.Buffer.isBuffer(e))this.setScriptFromBuffer(e);else throw new TypeError("Invalid argument type: script");return this};Ft.prototype.inspect=function(){var e;return this.script?e=this.script.inspect():e=this._scriptBuffer.toString("hex"),"<Output ("+this.satoshis+" sats) "+e+">"};Ft.fromBufferReader=function(e){var t={};t.satoshis=e.readUInt64LEBN();var r=e.readVarintNum();return r!==0?t.script=e.read(r):t.script=GE.Buffer.from([]),new Ft(t)};Ft.prototype.toBufferWriter=function(e){e||(e=new wk),e.writeUInt64LEBN(this._satoshisBN);var t=this._scriptBuffer;return e.writeVarintNum(t.length),e.write(t),e};Ft.prototype.getSize=function(){var e=this.script.toBuffer().length,t=Sk(e).toBuffer().length;return 8+t+e};zE.exports=Ft});var La=P((RH,WE)=>{"use strict";p();var dr=wr(),gn=si(),Ik=er(),Ak=Or(),Ok=na(),pi=Zt(),Rk=Ge(),gp=Ce(),He=function e(t){if(!(this instanceof e))return new e(t);t&&this.set(t)};Object.defineProperty(He.prototype,"k",{get:function(){return this._k},set:function(e){this._k=e,this._kFresh=!0},enumerable:!0,configurable:!0});He.prototype.set=function(e){if(this.hashbuf=e.hashbuf||this.hashbuf,this.endian=e.endian||this.endian,this.privkey=e.privkey||this.privkey,this.pubkey=e.pubkey||(this.privkey?this.privkey.publicKey:this.pubkey),e.sig)if(d.Buffer.isBuffer(e.sig)){var t=er();this.sig=t.fromDER(e.sig)}else this.sig=e.sig;else this.sig=this.sig;return e.k&&(this.k=e.k),this.verified=e.verified||this.verified,this};He.prototype.privkey2pubkey=function(){this.pubkey=this.privkey.toPublicKey()};He.prototype.calci=function(){for(var e=0;e<4;e++){this.sig.i=e;var t;try{t=this.toPublicKey()}catch(r){console.error(r);continue}if(t.point.eq(this.pubkey.point))return this.sig.compressed=this.pubkey.compressed,this}throw this.sig.i=void 0,new Error("Unable to find valid recovery factor")};He.fromString=function(e){var t=JSON.parse(e);return new He(t)};He.prototype.randomK=function(){var e=gn.getN(),t;do t=dr.fromBuffer(Ok.getRandomBuffer(32));while(!(t.lt(e)&&t.gt(dr.Zero)));return this.k=t,this};He.prototype.deterministicK=function(e){Rk.isUndefined(e)&&(e=0);var t=d.Buffer.alloc(32);t.fill(1);var r=d.Buffer.alloc(32);r.fill(0);var n=this.privkey.bn.toBuffer({size:32}),i=this.endian==="little"?d.Buffer.from(this.hashbuf).reverse():this.hashbuf;r=pi.sha256hmac(d.Buffer.concat([t,d.Buffer.from([0]),n,i]),r),t=pi.sha256hmac(t,r),r=pi.sha256hmac(d.Buffer.concat([t,d.Buffer.from([1]),n,i]),r),t=pi.sha256hmac(t,r),t=pi.sha256hmac(t,r);for(var o=dr.fromBuffer(t),s=gn.getN(),a=0;a<e||!(o.lt(s)&&o.gt(dr.Zero));a++)r=pi.sha256hmac(d.Buffer.concat([t,d.Buffer.from([0])]),r),t=pi.sha256hmac(t,r),t=pi.sha256hmac(t,r),o=dr.fromBuffer(t);return this.k=o,this};He.prototype.toPublicKey=function(){var e=this.sig.i;gp.checkArgument(e===0||e===1||e===2||e===3,new Error("i must be equal to 0, 1, 2, or 3"));var t=dr.fromBuffer(this.hashbuf),r=this.sig.r,n=this.sig.s,i=e&1,o=e>>1,s=gn.getN(),a=gn.getG(),c=o?r.add(s):r,l=gn.fromX(i,c),g=l.mul(s);if(!g.isInfinity())throw new Error("nR is not a valid curve point");var m=t.neg().umod(s),_=r.invm(s),x=l.mul(n).add(a.mul(m)).mul(_),R=Ak.fromPoint(x,this.sig.compressed);return R};He.prototype.sigError=function(){if(!d.Buffer.isBuffer(this.hashbuf)||this.hashbuf.length!==32)return"hashbuf must be a 32 byte buffer";var e=this.sig.r,t=this.sig.s,r=gn.getN();try{if(e.lte(dr.Zero)||t.lte(dr.Zero)||e.gte(r)||t.gte(r))return"r and s not in range";var n=dr.fromBuffer(this.hashbuf,this.endian?{endian:this.endian}:void 0),i=t.invm(r),o=i.mul(n).umod(r),s=i.mul(e).umod(r),a=gn.getG().mulAdd(o,this.pubkey.point,s);return a.isInfinity()?"p is infinity":a.getX().umod(r).cmp(e)!==0?"Invalid signature":!1}catch(c){return"Signature security validation failed: "+c.message}};He.toLowS=function(e){return e.gt(dr.fromBuffer(d.Buffer.from("7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0","hex")))&&(e=gn.getN().sub(e)),e};He.prototype._findSignature=function(e,t){var r=gn.getN(),n=gn.getG(),i=0,o,s,a,c;do(!this.k||!this._kFresh||i>0)&&this.deterministicK(i),i++,o=this.k,s=n.mul(o),a=s.x.umod(r),c=o.invm(r).mul(t.add(e.mul(a))).umod(r);while(a.cmp(dr.Zero)<=0||c.cmp(dr.Zero)<=0);return this._kFresh=!1,c=He.toLowS(c),{s:c,r:a}};He.prototype.sign=function(){var e=this.hashbuf,t=this.privkey,r=t.bn;gp.checkState(e&&t&&r,new Error("invalid parameters")),gp.checkState(d.Buffer.isBuffer(e)&&e.length===32,new Error("hashbuf must be a 32 byte buffer"));var n=dr.fromBuffer(e,this.endian?{endian:this.endian}:void 0),i=this._findSignature(r,n);return i.compressed=this.pubkey.compressed,this.sig=new Ik(i),this};He.prototype.signRandomK=function(){return this.randomK(),this.sign()};He.prototype.toString=function(){var e={};return this.hashbuf&&(e.hashbuf=this.hashbuf.toString("hex")),this.privkey&&(e.privkey=this.privkey.toString()),this.pubkey&&(e.pubkey=this.pubkey.toString()),this.sig&&(e.sig=this.sig.toString()),this.k&&(e.k=this.k.toString()),JSON.stringify(e)};He.prototype.verify=function(){return this.verified=!this.sigError(),this.verified};He.prototype.verifyBool=function(){return this.verify()===!0};He.sign=function(e,t,r){return He().set({hashbuf:e,endian:r,privkey:t}).sign().sig};He.signWithCalcI=function(e,t,r){return He().set({hashbuf:e,endian:r,privkey:t}).sign().calci().sig};He.signRandomK=function(e,t,r){return He().set({hashbuf:e,endian:r,privkey:t}).signRandomK().sig};He.verify=function(e,t,r,n){return He().set({hashbuf:e,endian:n,sig:t,pubkey:r}).verify()};WE.exports=He});var cs=P((PH,XE)=>{"use strict";p();var gi=Ge(),Tk=Ce(),Da=ri(),Pk=Qi(),yp=Pt(),$E=lr(),vc=Kr(),Bk=yi(),YE=Hn(),bc=4294967295,Nk=bc-2,ZE=bc,Mk=bc-1;function je(e){if(!(this instanceof je))return new je(e);if(e)return this._fromObject(e)}je.MAXINT=bc;je.DEFAULT_SEQNUMBER=ZE;je.DEFAULT_LOCKTIME_SEQNUMBER=Mk;je.DEFAULT_RBF_SEQNUMBER=Nk;je.BASE_SIZE=40;Object.defineProperty(je.prototype,"script",{configurable:!1,enumerable:!0,get:function(){return this.isNull()?null:(this._script||(this._script=new vc(this._scriptBuffer),this._script._isInput=!0),this._script)}});je.fromObject=function(e){Tk.checkArgument(gi.isObject(e));var t=new je;return t._fromObject(e)};je.prototype._fromObject=function(e){var t;if(gi.isString(e.prevTxId)&&$E.isHexa(e.prevTxId)?t=yp.Buffer.from(e.prevTxId,"hex"):t=e.prevTxId,this.output=e.output?e.output instanceof YE?e.output:new YE(e.output):void 0,this.prevTxId=t||e.txidbuf,this.outputIndex=gi.isUndefined(e.outputIndex)?e.txoutnum:e.outputIndex,this.sequenceNumber=gi.isUndefined(e.sequenceNumber)?gi.isUndefined(e.seqnum)?ZE:e.seqnum:e.sequenceNumber,gi.isUndefined(e.script)&&gi.isUndefined(e.scriptBuffer))throw new Da.Transaction.Input.MissingScript;return this.setScript(e.scriptBuffer||e.script),this};je.prototype.toObject=je.prototype.toJSON=function(){var t={prevTxId:this.prevTxId.toString("hex"),outputIndex:this.outputIndex,sequenceNumber:this.sequenceNumber,script:this._scriptBuffer.toString("hex")};return this.script&&(t.scriptString=this.script.toString()),this.output&&(t.output=this.output.toObject()),t};je.fromBufferReader=function(e){var t=new je;return t.prevTxId=e.readReverse(32),t.outputIndex=e.readUInt32LE(),t._scriptBuffer=e.readVarLengthBuffer(),t.sequenceNumber=e.readUInt32LE(),t};je.prototype.toBufferWriter=function(e){e||(e=new Pk),e.writeReverse(this.prevTxId),e.writeUInt32LE(this.outputIndex);var t=this._scriptBuffer;return e.writeVarintNum(t.length),e.write(t),e.writeUInt32LE(this.sequenceNumber),e};je.prototype.setScript=function(e){if(this._script=null,e instanceof vc)this._script=e,this._script._isInput=!0,this._scriptBuffer=e.toBuffer();else if(e===null)this._script=vc.empty(),this._script._isInput=!0,this._scriptBuffer=this._script.toBuffer();else if($E.isHexa(e))this._scriptBuffer=yp.Buffer.from(e,"hex");else if(gi.isString(e))this._script=new vc(e),this._script._isInput=!0,this._scriptBuffer=this._script.toBuffer();else if(d.Buffer.isBuffer(e))this._scriptBuffer=yp.Buffer.from(e);else throw new TypeError("Invalid argument type: script");return this};je.prototype.getSignatures=function(){throw new Da.AbstractMethodInvoked("Trying to sign unsupported output type (only P2PKH and P2SH multisig inputs are supported) for input: "+JSON.stringify(this))};je.prototype.isFullySigned=function(){throw new Da.AbstractMethodInvoked("Input#isFullySigned")};je.prototype.isFinal=function(){return this.sequenceNumber===je.MAXINT};je.prototype.addSignature=function(){throw new Da.AbstractMethodInvoked("Input#addSignature")};je.prototype.clearSignatures=function(){throw new Da.AbstractMethodInvoked("Input#clearSignatures")};je.prototype.isValidSignature=function(e,t){return t.signature.nhashtype=t.sigtype,Bk.verify(e,t.signature,t.publicKey,t.inputIndex,this.output.script,this.output.satoshisBN)};je.prototype.isNull=function(){return this.prevTxId.toString("hex")==="0000000000000000000000000000000000000000000000000000000000000000"&&this.outputIndex===4294967295};je.prototype._estimateSize=function(){return this.toBufferWriter().toBuffer().length};XE.exports=je});var ls=P((NH,ex)=>{"use strict";p();var hs=Ge(),Rr=Ce(),kk=Te(),JE=lr(),QE=Or(),Ck=ri(),Ua=er();function Vr(e){if(!(this instanceof Vr))return new Vr(e);if(e instanceof Vr)return e;if(hs.isObject(e))return this._fromObject(e);throw new Ck.InvalidArgument("TransactionSignatures must be instantiated from an object")}kk(Vr,Ua);Vr.prototype._fromObject=function(e){return this._checkObjectArgs(e),this.publicKey=new QE(e.publicKey),this.prevTxId=d.Buffer.isBuffer(e.prevTxId)?e.prevTxId:d.Buffer.from(e.prevTxId,"hex"),this.outputIndex=e.outputIndex,this.inputIndex=e.inputIndex,this.signature=e.signature instanceof Ua?e.signature:d.Buffer.isBuffer(e.signature)?Ua.fromBuffer(e.signature):Ua.fromString(e.signature),this.sigtype=e.sigtype,this};Vr.prototype._checkObjectArgs=function(e){Rr.checkArgument(QE(e.publicKey),"publicKey"),Rr.checkArgument(!hs.isUndefined(e.inputIndex),"inputIndex"),Rr.checkArgument(!hs.isUndefined(e.outputIndex),"outputIndex"),Rr.checkState(hs.isNumber(e.inputIndex),"inputIndex must be a number"),Rr.checkState(hs.isNumber(e.outputIndex),"outputIndex must be a number"),Rr.checkArgument(e.signature,"signature"),Rr.checkArgument(e.prevTxId,"prevTxId"),Rr.checkState(e.signature instanceof Ua||d.Buffer.isBuffer(e.signature)||JE.isHexa(e.signature),"signature must be a buffer or hexa value"),Rr.checkState(d.Buffer.isBuffer(e.prevTxId)||JE.isHexa(e.prevTxId),"prevTxId must be a buffer or hexa value"),Rr.checkArgument(e.sigtype,"sigtype"),Rr.checkState(hs.isNumber(e.sigtype),"sigtype must be a number")};Vr.prototype.toObject=Vr.prototype.toJSON=function(){return{publicKey:this.publicKey.toString(),prevTxId:this.prevTxId.toString("hex"),outputIndex:this.outputIndex,inputIndex:this.inputIndex,signature:this.signature.toString(),sigtype:this.sigtype}};Vr.fromObject=function(e){return Rr.checkArgument(e),new Vr(e)};ex.exports=Vr});var ox=P((kH,ix)=>{"use strict";p();var Lk=Te(),rx=Ce(),mp=cs(),Dk=Hn(),Uk=yi(),nx=Kr(),tx=er(),qk=ls();function jn(){mp.apply(this,arguments)}Lk(jn,mp);jn.prototype.getSignatures=function(e,t,r,n){rx.checkState(this.output instanceof Dk),n=n||tx.SIGHASH_ALL|tx.SIGHASH_FORKID;var i=t.toPublicKey();return i.toString()===this.output.script.getPublicKey().toString("hex")?[new qk({publicKey:i,prevTxId:this.prevTxId,outputIndex:this.outputIndex,inputIndex:r,signature:Uk.sign(e,t,n,r,this.output.script,this.output.satoshisBN),sigtype:n})]:[]};jn.prototype.addSignature=function(e,t){return rx.checkState(this.isValidSignature(e,t),"Signature is invalid"),this.setScript(nx.buildPublicKeyIn(t.signature.toDER(),t.sigtype)),this};jn.prototype.clearSignatures=function(){return this.setScript(nx.empty()),this};jn.prototype.isFullySigned=function(){return this.script.isPublicKeyIn()};jn.SCRIPT_MAX_SIZE=74;jn.prototype._estimateSize=function(){return mp.BASE_SIZE+jn.SCRIPT_MAX_SIZE};ix.exports=jn});var cx=P((LH,fx)=>{"use strict";p();var Fk=Te(),ax=Ce(),Hk=Zt(),vp=cs(),jk=Hn(),Kk=yi(),ux=Kr(),sx=er(),Vk=ls();function Kn(){vp.apply(this,arguments)}Fk(Kn,vp);Kn.prototype.getSignatures=function(e,t,r,n,i){ax.checkState(this.output instanceof jk),i=i||Hk.sha256ripemd160(t.publicKey.toBuffer()),n=n||sx.SIGHASH_ALL|sx.SIGHASH_FORKID;var o=this.output.script.chunks[2]&&this.output.script.chunks[2].buf;return o&&i.equals(o)?[new Vk({publicKey:t.publicKey,prevTxId:this.prevTxId,outputIndex:this.outputIndex,inputIndex:r,signature:Kk.sign(e,t,n,r,this.output.script,this.output.satoshisBN),sigtype:n})]:[]};Kn.prototype.addSignature=function(e,t){return ax.checkState(this.isValidSignature(e,t),"Signature is invalid"),this.setScript(ux.buildPublicKeyHashIn(t.publicKey,t.signature.toDER(),t.sigtype)),this};Kn.prototype.clearSignatures=function(){return this.setScript(ux.empty()),this};Kn.prototype.isFullySigned=function(){return this.script.isPublicKeyHashIn()};Kn.SCRIPT_MAX_SIZE=108;Kn.prototype._estimateSize=function(){return vp.BASE_SIZE+Kn.SCRIPT_MAX_SIZE};fx.exports=Kn});var dx=P((UH,lx)=>{"use strict";p();var Gr=Ge(),Gk=Te(),wc=cs(),zk=Hn(),qa=Ce(),hx=Kr(),_c=er(),bp=yi(),_p=ls(),Wk=Or(),Yk=Ca();function Bt(e,t,r,n){wc.apply(this,arguments);var i=this;t=t||e.publicKeys,r=r||e.threshold,n=n||e.signatures,this.publicKeys=t.map(o=>o.toString("hex")).sort().map(o=>new Wk(o)),qa.checkState(hx.buildMultisigOut(this.publicKeys,r).equals(this.output.script),"Provided public keys don't match to the provided output script"),this.publicKeyIndex={},Gr.each(this.publicKeys,function(o,s){i.publicKeyIndex[o.toString()]=s}),this.threshold=r,this.signatures=n?this._deserializeSignatures(n):new Array(this.publicKeys.length)}Gk(Bt,wc);Bt.prototype.toObject=function(){var e=wc.prototype.toObject.apply(this,arguments);return e.threshold=this.threshold,e.publicKeys=Gr.map(this.publicKeys,function(t){return t.toString()}),e.signatures=this._serializeSignatures(),e};Bt.prototype._deserializeSignatures=function(e){return Gr.map(e,function(t){if(t)return new _p(t)})};Bt.prototype._serializeSignatures=function(){return Gr.map(this.signatures,function(e){if(e)return e.toObject()})};Bt.prototype.getSignatures=function(e,t,r,n){qa.checkState(this.output instanceof zk),n=n||_c.SIGHASH_ALL|_c.SIGHASH_FORKID;var i=this,o=[];return Gr.each(this.publicKeys,function(s){s.toString()===t.publicKey.toString()&&o.push(new _p({publicKey:t.publicKey,prevTxId:i.prevTxId,outputIndex:i.outputIndex,inputIndex:r,signature:bp.sign(e,t,n,r,i.output.script,i.output.satoshisBN),sigtype:n}))}),o};Bt.prototype.addSignature=function(e,t){return qa.checkState(!this.isFullySigned(),"All needed signatures have already been added"),qa.checkArgument(!Gr.isUndefined(this.publicKeyIndex[t.publicKey.toString()]),"Signature has no matching public key"),qa.checkState(this.isValidSignature(e,t)),this.signatures[this.publicKeyIndex[t.publicKey.toString()]]=t,this._updateScript(),this};Bt.prototype._updateScript=function(){return this.setScript(hx.buildMultisigIn(this.publicKeys,this.threshold,this._createSignatures())),this};Bt.prototype._createSignatures=function(){return Gr.map(Gr.filter(this.signatures,function(e){return!Gr.isUndefined(e)}),function(e){return d.Buffer.concat([e.signature.toDER(),d.Buffer.from([e.sigtype&255])])})};Bt.prototype.clearSignatures=function(){this.signatures=new Array(this.publicKeys.length),this._updateScript()};Bt.prototype.isFullySigned=function(){return this.countSignatures()===this.threshold};Bt.prototype.countMissingSignatures=function(){return this.threshold-this.countSignatures()};Bt.prototype.countSignatures=function(){return Gr.reduce(this.signatures,function(e,t){return e+!!t},0)};Bt.prototype.publicKeysWithoutSignature=function(){var e=this;return Gr.filter(this.publicKeys,function(t){return!e.signatures[e.publicKeyIndex[t.toString()]]})};Bt.prototype.isValidSignature=function(e,t){return t.signature.nhashtype=t.sigtype,bp.verify(e,t.signature,t.publicKey,t.inputIndex,this.output.script,this.output.satoshisBN)};Bt.normalizeSignatures=function(e,t,r,n,i){return i.map(function(o){var s=null;return n=n.filter(function(a){if(s)return!0;var c=new _p({signature:_c.fromTxFormat(a),publicKey:o,prevTxId:t.prevTxId,outputIndex:t.outputIndex,inputIndex:r,sigtype:_c.SIGHASH_ALL});c.signature.nhashtype=c.sigtype;var l=bp.verify(e,c.signature,c.publicKey,c.inputIndex,t.output.script);return l?(s=c,!1):!0}),s||null})};Bt.SIGNATURE_SIZE=73;Bt.prototype._estimateSize=function(){var e=1+this.threshold*Bt.SIGNATURE_SIZE;return wc.BASE_SIZE+Yk(e).toBuffer().length+e};lx.exports=Bt});var vx=P((FH,mx)=>{"use strict";p();var zr=Ge(),$k=Te(),Sc=cs(),Zk=Hn(),Fa=Ce(),wp=Kr(),px=er(),gx=yi(),yx=ls(),Xk=Or(),Jk=Ca();function Rt(e,t,r,n){Sc.apply(this,arguments);var i=this;t=t||e.publicKeys,r=r||e.threshold,n=n||e.signatures,this.publicKeys=t.map(o=>o.toString("hex")).sort().map(o=>new Xk(o)),this.redeemScript=wp.buildMultisigOut(this.publicKeys,r),Fa.checkState(wp.buildScriptHashOut(this.redeemScript).equals(this.output.script),"Provided public keys don't hash to the provided output"),this.publicKeyIndex={},zr.each(this.publicKeys,function(o,s){i.publicKeyIndex[o.toString()]=s}),this.threshold=r,this.signatures=n?this._deserializeSignatures(n):new Array(this.publicKeys.length)}$k(Rt,Sc);Rt.prototype.toObject=function(){var e=Sc.prototype.toObject.apply(this,arguments);return e.threshold=this.threshold,e.publicKeys=zr.map(this.publicKeys,function(t){return t.toString()}),e.signatures=this._serializeSignatures(),e};Rt.prototype._deserializeSignatures=function(e){return zr.map(e,function(t){if(t)return new yx(t)})};Rt.prototype._serializeSignatures=function(){return zr.map(this.signatures,function(e){if(e)return e.toObject()})};Rt.prototype.getSignatures=function(e,t,r,n){Fa.checkState(this.output instanceof Zk),n=n||px.SIGHASH_ALL|px.SIGHASH_FORKID;var i=this,o=[];return zr.each(this.publicKeys,function(s){s.toString()===t.publicKey.toString()&&o.push(new yx({publicKey:t.publicKey,prevTxId:i.prevTxId,outputIndex:i.outputIndex,inputIndex:r,signature:gx.sign(e,t,n,r,i.redeemScript,i.output.satoshisBN),sigtype:n}))}),o};Rt.prototype.addSignature=function(e,t){return Fa.checkState(!this.isFullySigned(),"All needed signatures have already been added"),Fa.checkArgument(!zr.isUndefined(this.publicKeyIndex[t.publicKey.toString()]),"Signature has no matching public key"),Fa.checkState(this.isValidSignature(e,t)),this.signatures[this.publicKeyIndex[t.publicKey.toString()]]=t,this._updateScript(),this};Rt.prototype._updateScript=function(){return this.setScript(wp.buildP2SHMultisigIn(this.publicKeys,this.threshold,this._createSignatures(),{cachedMultisig:this.redeemScript})),this};Rt.prototype._createSignatures=function(){return zr.map(zr.filter(this.signatures,function(e){return!zr.isUndefined(e)}),function(e){return d.Buffer.concat([e.signature.toDER(),d.Buffer.from([e.sigtype&255])])})};Rt.prototype.clearSignatures=function(){this.signatures=new Array(this.publicKeys.length),this._updateScript()};Rt.prototype.isFullySigned=function(){return this.countSignatures()===this.threshold};Rt.prototype.countMissingSignatures=function(){return this.threshold-this.countSignatures()};Rt.prototype.countSignatures=function(){return zr.reduce(this.signatures,function(e,t){return e+!!t},0)};Rt.prototype.publicKeysWithoutSignature=function(){var e=this;return zr.filter(this.publicKeys,function(t){return!e.signatures[e.publicKeyIndex[t.toString()]]})};Rt.prototype.isValidSignature=function(e,t){return t.signature.nhashtype=t.sigtype,gx.verify(e,t.signature,t.publicKey,t.inputIndex,this.redeemScript,this.output.satoshisBN)};Rt.SIGNATURE_SIZE=73;Rt.PUBKEY_SIZE=34;Rt.prototype._estimateSize=function(){var e=this.publicKeys.length*Rt.PUBKEY_SIZE,t=this.threshold*Rt.SIGNATURE_SIZE,r=3+e,n=r<=75?1:r<=255?2:3,i=t+1+n+r;return Sc.BASE_SIZE+Jk(i).toBuffer().length+i};mx.exports=Rt});var Ec=P((jH,ds)=>{p();ds.exports=cs();ds.exports.PublicKey=ox();ds.exports.PublicKeyHash=cx();ds.exports.MultiSig=dx();ds.exports.MultiSigScriptHash=vx()});var yi=P((VH,Ex)=>{"use strict";p();var Qk=Pt(),sr=er(),Sp=Kr(),e4=Hn(),t4=_a(),Ha=Qi(),bx=wr(),xc=Zt(),_x=La(),Ep=Ce(),Ic=Ac(),mi=Ge(),wx=d.Buffer.from("0000000000000000000000000000000000000000000000000000000000000001","hex"),r4="ffffffffffffffff",n4=Ic.SCRIPT_ENABLE_SIGHASH_FORKID,i4=function(e,t,r,n,i){var o=e.inputs[r];Ep.checkArgument(i instanceof bx,"For ForkId=0 signatures, satoshis or complete input must be provided");function s(B){var C=new Ha;mi.each(B.inputs,function(z){C.writeReverse(z.prevTxId),C.writeUInt32LE(z.outputIndex)});var U=C.toBuffer(),V=xc.sha256sha256(U);return V}function a(B){var C=new Ha;mi.each(B.inputs,function(z){C.writeUInt32LE(z.sequenceNumber)});var U=C.toBuffer(),V=xc.sha256sha256(U);return V}function c(B,C){var U=new Ha;mi.isUndefined(C)?mi.each(B.outputs,function(j){j.toBufferWriter(U)}):B.outputs[C].toBufferWriter(U);var V=U.toBuffer(),z=xc.sha256sha256(V);return z}var l=d.Buffer.alloc(32),g=d.Buffer.alloc(32),m=d.Buffer.alloc(32);t&sr.SIGHASH_ANYONECANPAY||(l=s(e)),!(t&sr.SIGHASH_ANYONECANPAY)&&(t&31)!==sr.SIGHASH_SINGLE&&(t&31)!==sr.SIGHASH_NONE&&(g=a(e)),(t&31)!==sr.SIGHASH_SINGLE&&(t&31)!==sr.SIGHASH_NONE?m=c(e):(t&31)===sr.SIGHASH_SINGLE&&r<e.outputs.length&&(m=c(e,r));var _=new Ha;_.writeInt32LE(e.version),_.write(l),_.write(g),_.writeReverse(o.prevTxId),_.writeUInt32LE(o.outputIndex),_.writeVarintNum(n.toBuffer().length),_.write(n.toBuffer()),_.writeUInt64LEBN(i);var x=o.sequenceNumber;_.writeUInt32LE(x),_.write(m),_.writeUInt32LE(e.nLockTime),_.writeUInt32LE(t>>>0);var R=_.toBuffer();return R},Sx=function(t,r,n,i,o,s){var a=Ip(),c=Ec();mi.isUndefined(s)&&(s=n4);var l=a.shallowCopy(t);if(i=new Sp(i),s&Ic.SCRIPT_ENABLE_REPLAY_PROTECTION){var g=r>>8,m=16711680|g^57005;r=m<<8|r&255}if(!(r&sr.SIGHASH_CHRONICLE&&s&Ic.SCRIPT_ENABLE_CHRONICLE)){if(r&sr.SIGHASH_FORKID&&s&Ic.SCRIPT_ENABLE_SIGHASH_FORKID)return i4(l,r,n,i,o)}i.removeCodeseparators();var _;for(_=0;_<l.inputs.length;_++)l.inputs[_]=new c(l.inputs[_]).setScript(Sp.empty());if(l.inputs[n]=new c(l.inputs[n]).setScript(i),(r&31)===sr.SIGHASH_NONE||(r&31)===sr.SIGHASH_SINGLE)for(_=0;_<l.inputs.length;_++)_!==n&&(l.inputs[_].sequenceNumber=0);if((r&31)===sr.SIGHASH_NONE)l.outputs=[];else if((r&31)===sr.SIGHASH_SINGLE){if(n>=l.outputs.length)return wx;for(l.outputs.length=n+1,_=0;_<n;_++)l.outputs[_]=new e4({satoshis:bx.fromBuffer(Qk.Buffer.from(r4,"hex")),script:Sp.empty()})}r&sr.SIGHASH_ANYONECANPAY&&(l.inputs=[l.inputs[n]]);var x=new Ha().write(l.toBuffer()).writeInt32LE(r).toBuffer();return x},xp=function(t,r,n,i,o,s){var a=Sx(t,r,n,i,o,s);if(a.compare(wx)===0)return a;var c=xc.sha256sha256(a);return c=new t4(c).readReverse(),c};function o4(e,t,r,n,i,o,s){var a=xp(e,r,n,i,o,s),c=_x.sign(a,t,"little").set({nhashtype:r});return c}function s4(e,t,r,n,i,o,s){Ep.checkArgument(!mi.isUndefined(e)),Ep.checkArgument(!mi.isUndefined(t)&&!mi.isUndefined(t.nhashtype));var a=xp(e,t.nhashtype,n,i,o,s);return _x.verify(a,t,r,"little")}Ex.exports={sighashPreimage:Sx,sighash:xp,sign:o4,verify:s4}});var Ap=P((zH,Ix)=>{"use strict";p();var Vn=Ge(),Oc=Ce(),xx=lr(),a4=Kr(),u4=no();function Gn(e){if(!(this instanceof Gn))return new Gn(e);Oc.checkArgument(Vn.isObject(e),"Must provide an object from where to extract data");var t=e.address?new u4(e.address):void 0,r=e.txid?e.txid:e.txId;if(!r||!xx.isHexaString(r)||r.length>64)throw new Error("Invalid TXID in object",e);var n=Vn.isUndefined(e.vout)?e.outputIndex:e.vout;if(!Vn.isNumber(n))throw new Error("Invalid outputIndex, received "+n);Oc.checkArgument(!Vn.isUndefined(e.scriptPubKey)||!Vn.isUndefined(e.script),"Must provide the scriptPubKey for that output!");var i=new a4(e.scriptPubKey||e.script);Oc.checkArgument(!Vn.isUndefined(e.amount)||!Vn.isUndefined(e.satoshis),"Must provide an amount for the output");var o=Vn.isUndefined(e.amount)?e.satoshis:Math.round(e.amount*1e8);Oc.checkArgument(Vn.isNumber(o),"Amount must be a number"),xx.defineImmutable(this,{address:t,txId:r,outputIndex:n,script:i,satoshis:o})}Gn.prototype.inspect=function(){return"<UnspentOutput: "+this.txId+":"+this.outputIndex+", satoshis: "+this.satoshis+", address: "+this.address+">"};Gn.prototype.toString=function(){return this.txId+":"+this.outputIndex};Gn.fromObject=function(e){return new Gn(e)};Gn.prototype.toObject=Gn.prototype.toJSON=function(){return{address:this.address?this.address.toString():void 0,txid:this.txId,vout:this.outputIndex,scriptPubKey:this.script.toBuffer().toString("hex"),amount:Number.parseFloat((this.satoshis/1e8).toFixed(8))}};Ix.exports=Gn});var Ip=P((YH,Mx)=>{"use strict";p();var pe=Ge(),Ht=Ce(),f4=Pt(),Mt=ri(),Ox=lr(),Rx=_a(),c4=Qi(),Ax=Ca(),Tx=Zt(),Tc=er(),Px=yi(),h4=no(),Bx=Ap(),Nt=Ec(),l4=Nt.PublicKeyHash,d4=Nt.PublicKey,p4=Nt.MultiSigScriptHash,g4=Nt.MultiSig,Wr=Hn(),yn=Kr(),y4=io(),Rc=wr(),m4=Ac(),v4=m4.SCRIPT_ENABLE_SIGHASH_FORKID;function G(e){if(!(this instanceof G))return new G(e);if(this.inputs=[],this.outputs=[],this._inputAmount=void 0,this._outputAmount=void 0,e){if(e instanceof G)return G.shallowCopy(e);if(Ox.isHexa(e))this.fromString(e);else if(d.Buffer.isBuffer(e))this.fromBuffer(e);else if(pe.isObject(e))this.fromObject(e);else throw new Mt.InvalidArgument("Must provide an object or string to deserialize a transaction")}else this._newTransaction()}var b4=1,_4=0,w4=1e6;G.DUST_AMOUNT=546;G.FEE_SECURITY_MARGIN=150;G.MAX_MONEY=21e6*1e8;G.NLOCKTIME_BLOCKHEIGHT_LIMIT=5e8;G.NLOCKTIME_MAX_VALUE=4294967295;G.FEE_PER_KB=500;G.CHANGE_OUTPUT_MAX_SIZE=62;G.shallowCopy=function(e){var t=new G(e.toBuffer());return t};var Nx={configurable:!1,enumerable:!0,get:function(){return this._hash=new Rx(this._getHash()).readReverse().toString("hex"),this._hash}};Object.defineProperty(G.prototype,"hash",Nx);Object.defineProperty(G.prototype,"id",Nx);var Op={configurable:!1,enumerable:!0,get:function(){return this._getInputAmount()}};Object.defineProperty(G.prototype,"inputAmount",Op);Op.get=function(){return this._getOutputAmount()};Object.defineProperty(G.prototype,"outputAmount",Op);G.prototype._getHash=function(){return Tx.sha256sha256(this.toBuffer())};G.prototype.serialize=function(e){return e===!0||e&&e.disableAll?this.uncheckedSerialize():this.checkedSerialize(e)};G.prototype.uncheckedSerialize=G.prototype.toString=function(){return this.toBuffer().toString("hex")};G.prototype.checkedSerialize=function(e){var t=this.getSerializationError(e);if(t)throw t.message+=" - For more information please see: https://bsv.io/api/lib/transaction#serialization-checks",t;return this.uncheckedSerialize()};G.prototype.invalidSatoshis=function(){for(var e=!1,t=0;t<this.outputs.length;t++)this.outputs[t].invalidSatoshis()&&(e=!0);return e};G.prototype.getSerializationError=function(e){if(e=e||{},this.invalidSatoshis())return new Mt.Transaction.InvalidSatoshis;var t=this._getUnspentValue(),r;return t<0?e.disableMoreOutputThanInput||(r=new Mt.Transaction.InvalidOutputAmountSum):r=this._hasFeeError(e,t),r||this._hasDustOutputs(e)||this._isMissingSignatures(e)};G.prototype._hasFeeError=function(e,t){if(!pe.isUndefined(this._fee)&&this._fee!==t)return new Mt.Transaction.FeeError.Different("Unspent value is "+t+" but specified fee is "+this._fee);if(!e.disableLargeFees){var r=Math.floor(G.FEE_SECURITY_MARGIN*this._estimateFee());if(t>r)return this._missingChange()?new Mt.Transaction.ChangeAddressMissing("Fee is too large and no change address was provided"):new Mt.Transaction.FeeError.TooLarge("expected less than "+r+" but got "+t)}};G.prototype._missingChange=function(){return!this._changeScript};G.prototype._hasDustOutputs=function(e){if(!e.disableDustOutputs){var t,r;for(t in this.outputs)if(r=this.outputs[t],r.satoshis<G.DUST_AMOUNT&&!r.script.isDataOut()&&!r.script.isSafeDataOut())return new Mt.Transaction.DustOutputs}};G.prototype._isMissingSignatures=function(e){if(!e.disableIsFullySigned&&!this.isFullySigned())return new Mt.Transaction.MissingSignatures};G.prototype.inspect=function(){return"<Transaction: "+this.uncheckedSerialize()+">"};G.prototype.toBuffer=function(){var e=new c4;return this.toBufferWriter(e).toBuffer()};G.prototype.toBufferWriter=function(e){return e.writeInt32LE(this.version),e.writeVarintNum(this.inputs.length),pe.each(this.inputs,function(t){t.toBufferWriter(e)}),e.writeVarintNum(this.outputs.length),pe.each(this.outputs,function(t){t.toBufferWriter(e)}),e.writeUInt32LE(this.nLockTime),e};G.prototype.fromBuffer=function(e){var t=new Rx(e);return this.fromBufferReader(t)};G.prototype.fromBufferReader=function(e){Ht.checkArgument(!e.finished(),"No transaction data received");var t,r,n;for(this.version=e.readInt32LE(),r=e.readVarintNum(),t=0;t<r;t++){var i=Nt.fromBufferReader(e);this.inputs.push(i)}for(n=e.readVarintNum(),t=0;t<n;t++)this.outputs.push(Wr.fromBufferReader(e));return this.nLockTime=e.readUInt32LE(),this};G.prototype.toObject=G.prototype.toJSON=function(){var t=[];this.inputs.forEach(function(i){t.push(i.toObject())});var r=[];this.outputs.forEach(function(i){r.push(i.toObject())});var n={hash:this.hash,version:this.version,inputs:t,outputs:r,nLockTime:this.nLockTime};return this._changeScript&&(n.changeScript=this._changeScript.toString()),pe.isUndefined(this._changeIndex)||(n.changeIndex=this._changeIndex),pe.isUndefined(this._fee)||(n.fee=this._fee),n};G.prototype.fromObject=function(t){Ht.checkArgument(pe.isObject(t)||t instanceof G);var r=this,n;return t instanceof G?n=t.toObject():n=t,pe.each(n.inputs,function(i){if(!i.output||!i.output.script){r.uncheckedAddInput(new Nt(i));return}var o=new yn(i.output.script),s;if(o.isPublicKeyHashOut())s=new Nt.PublicKeyHash(i);else if(o.isScriptHashOut()&&i.publicKeys&&i.threshold)s=new Nt.MultiSigScriptHash(i,i.publicKeys,i.threshold,i.signatures);else if(o.isPublicKeyOut())s=new Nt.PublicKey(i);else throw new Mt.Transaction.Input.UnsupportedScript(i.output.script);r.addInput(s)}),pe.each(n.outputs,function(i){r.addOutput(new Wr(i))}),n.changeIndex&&(this._changeIndex=n.changeIndex),n.changeScript&&(this._changeScript=new yn(n.changeScript)),n.fee&&(this._fee=n.fee),this.nLockTime=n.nLockTime,this.version=n.version,this._checkConsistency(t),this};G.prototype._checkConsistency=function(e){pe.isUndefined(this._changeIndex)||(Ht.checkState(this._changeScript,"Change script is expected."),Ht.checkState(this.outputs[this._changeIndex],"Change index points to undefined output."),Ht.checkState(this.outputs[this._changeIndex].script.toString()===this._changeScript.toString(),"Change output has an unexpected script.")),e&&e.hash&&Ht.checkState(e.hash===this.hash,"Hash in object does not match transaction hash.")};G.prototype.lockUntilDate=function(e){if(Ht.checkArgument(e),pe.isNumber(e)&&e<G.NLOCKTIME_BLOCKHEIGHT_LIMIT)throw new Mt.Transaction.LockTimeTooEarly;pe.isDate(e)&&(e=e.getTime()/1e3);for(var t=0;t<this.inputs.length;t++)this.inputs[t].sequenceNumber===Nt.DEFAULT_SEQNUMBER&&(this.inputs[t].sequenceNumber=Nt.DEFAULT_LOCKTIME_SEQNUMBER);return this.nLockTime=e,this};G.prototype.lockUntilBlockHeight=function(e){if(Ht.checkArgument(pe.isNumber(e)),e>=G.NLOCKTIME_BLOCKHEIGHT_LIMIT)throw new Mt.Transaction.BlockHeightTooHigh;if(e<0)throw new Mt.Transaction.NLockTimeOutOfRange;for(var t=0;t<this.inputs.length;t++)this.inputs[t].sequenceNumber===Nt.DEFAULT_SEQNUMBER&&(this.inputs[t].sequenceNumber=Nt.DEFAULT_LOCKTIME_SEQNUMBER);return this.nLockTime=e,this};G.prototype.getLockTime=function(){return this.nLockTime?this.nLockTime<G.NLOCKTIME_BLOCKHEIGHT_LIMIT?this.nLockTime:new Date(1e3*this.nLockTime):null};G.prototype.fromString=function(e){this.fromBuffer(f4.Buffer.from(e,"hex"))};G.prototype._newTransaction=function(){this.version=b4,this.nLockTime=_4};G.prototype.from=function(e,t,r){if(pe.isArray(e)){var n=this;return pe.each(e,function(o){n.from(o,t,r)}),this}var i=pe.some(this.inputs,function(o){return o.prevTxId.toString("hex")===e.txId&&o.outputIndex===e.outputIndex});return i?this:(t&&r?this._fromMultisigUtxo(e,t,r):this._fromNonP2SH(e),this)};G.prototype._fromNonP2SH=function(e){var t;e=new Bx(e),e.script.isPublicKeyHashOutPrefix()?t=l4:e.script.isPublicKeyOut()?t=d4:t=Nt,this.addInput(new t({output:new Wr({script:e.script,satoshis:e.satoshis}),prevTxId:e.txId,outputIndex:e.outputIndex,script:yn.empty()}))};G.prototype._fromMultisigUtxo=function(e,t,r){Ht.checkArgument(r<=t.length,"Number of required signatures must be greater than the number of public keys");var n;if(e=new Bx(e),e.script.isMultisigOut())n=g4;else if(e.script.isScriptHashOut())n=p4;else throw new Mt.Transaction.Input.UnsupportedScript(e.script.toString());this.addInput(new n({output:new Wr({script:e.script,satoshis:e.satoshis}),prevTxId:e.txId,outputIndex:e.outputIndex,script:yn.empty()},t,r))};G.prototype.addInput=function(e,t,r){if(Ht.checkArgumentType(e,Nt,"input"),!e.output&&(pe.isUndefined(t)||pe.isUndefined(r)))throw new Mt.Transaction.NeedMoreInfo("Need information about the UTXO script and satoshis");return!e.output&&t&&!pe.isUndefined(r)&&(t=t instanceof yn?t:new yn(t),Ht.checkArgumentType(r,"number","satoshis"),e.output=new Wr({script:t,satoshis:r})),this.uncheckedAddInput(e)};G.prototype.uncheckedAddInput=function(e){return Ht.checkArgumentType(e,Nt,"input"),this.inputs.push(e),this._inputAmount=void 0,this._updateChangeOutput(),this};G.prototype.hasAllUtxoInfo=function(){return pe.every(this.inputs.map(function(e){return!!e.output}))};G.prototype.fee=function(e){return Ht.checkArgument(pe.isNumber(e),"amount must be a number"),this._fee=e,this._updateChangeOutput(),this};G.prototype.feePerKb=function(e){return Ht.checkArgument(pe.isNumber(e),"amount must be a number"),this._feePerKb=e,this._updateChangeOutput(),this};G.prototype.change=function(e){return Ht.checkArgument(e,"address is required"),this._changeScript=yn.fromAddress(e),this._updateChangeOutput(),this};G.prototype.getChangeOutput=function(){return pe.isUndefined(this._changeIndex)?null:this.outputs[this._changeIndex]};G.prototype.to=function(e,t){if(pe.isArray(e)){var r=this;return pe.each(e,function(n){r.to(n.address,n.satoshis)}),this}return Ht.checkArgument(Ox.isNaturalNumber(t),"Amount is expected to be a positive integer"),this.addOutput(new Wr({script:yn(new h4(e)),satoshis:t})),this};G.prototype.addData=function(e){return this.addOutput(new Wr({script:yn.buildDataOut(e),satoshis:0})),this};G.prototype.addSafeData=function(e){return this.addOutput(new Wr({script:yn.buildSafeDataOut(e),satoshis:0})),this};G.prototype.addOutput=function(e){return Ht.checkArgumentType(e,Wr,"output"),this._addOutput(e),this._updateChangeOutput(),this};G.prototype.clearOutputs=function(){return this.outputs=[],this._clearSignatures(),this._outputAmount=void 0,this._changeIndex=void 0,this._updateChangeOutput(),this};G.prototype._addOutput=function(e){this.outputs.push(e),this._outputAmount=void 0};G.prototype._getOutputAmount=function(){if(pe.isUndefined(this._outputAmount)){var e=this;this._outputAmount=0,pe.each(this.outputs,function(t){e._outputAmount+=t.satoshis})}return this._outputAmount};G.prototype._getInputAmount=function(){if(pe.isUndefined(this._inputAmount)){var e=this;this._inputAmount=0,pe.each(this.inputs,function(t){if(pe.isUndefined(t.output))throw new Mt.Transaction.Input.MissingPreviousOutput;e._inputAmount+=t.output.satoshis})}return this._inputAmount};G.prototype._updateChangeOutput=function(){if(this._changeScript){this._clearSignatures(),pe.isUndefined(this._changeIndex)||this._removeOutput(this._changeIndex),this._changeIndex=this.outputs.length,this._addOutput(new Wr({script:this._changeScript,satoshis:0}));var e=this._getUnspentValue(),t=this.getFee(),r=e-t;this._removeOutput(this._changeIndex),this._changeIndex=void 0,r>=G.DUST_AMOUNT&&(this._changeIndex=this.outputs.length,this._addOutput(new Wr({script:this._changeScript,satoshis:r})))}};G.prototype.getFee=function(){return this.isCoinbase()?0:pe.isUndefined(this._fee)?this._changeScript?this._estimateFee():this._getUnspentValue():this._fee};G.prototype._estimateFee=function(){var e=this._estimateSize();return Math.ceil(e/1e3*(this._feePerKb||G.FEE_PER_KB))};G.prototype._getUnspentValue=function(){return this._getInputAmount()-this._getOutputAmount()};G.prototype._clearSignatures=function(){pe.each(this.inputs,function(e){e.clearSignatures!==Nt.prototype.clearSignatures&&e.clearSignatures()})};G.prototype._estimateSize=function(){var e=8;return e+=Ax(this.inputs.length).toBuffer().length,e+=Ax(this.outputs.length).toBuffer().length,pe.each(this.inputs,function(t){e+=t._estimateSize()}),pe.each(this.outputs,function(t){e+=t.getSize()}),e};G.prototype._removeOutput=function(e){var t=this.outputs[e];this.outputs=pe.without(this.outputs,t),this._outputAmount=void 0};G.prototype.removeOutput=function(e){this._removeOutput(e),this._updateChangeOutput()};G.prototype.sort=function(){return this.sortInputs(function(e){var t=Array.prototype.concat.apply([],e);return t.sort(function(r,n){return r.prevTxId.compare(n.prevTxId)||r.outputIndex-n.outputIndex}),t}),this.sortOutputs(function(e){var t=Array.prototype.concat.apply([],e);return t.sort(function(r,n){return r.satoshis-n.satoshis||r.script.toBuffer().compare(n.script.toBuffer())}),t}),this};G.prototype.shuffleOutputs=function(){return this.sortOutputs(pe.shuffle)};G.prototype.sortOutputs=function(e){var t=e(this.outputs);return this._newOutputOrder(t)};G.prototype.sortInputs=function(e){return this.inputs=e(this.inputs),this._clearSignatures(),this};G.prototype._newOutputOrder=function(e){var t=this.outputs.length!==e.length||pe.difference(this.outputs,e).length!==0;if(t)throw new Mt.Transaction.InvalidSorting;if(!pe.isUndefined(this._changeIndex)){var r=this.outputs[this._changeIndex];this._changeIndex=e.indexOf(r)}return this.outputs=e,this};G.prototype.removeInput=function(e,t){var r;if(!t&&pe.isNumber(e)?r=e:r=pe.findIndex(this.inputs,function(i){return i.prevTxId.toString("hex")===e&&i.outputIndex===t}),r<0||r>=this.inputs.length)throw new Mt.Transaction.InvalidIndex(r,this.inputs.length);var n=this.inputs[r];this.inputs=pe.without(this.inputs,n),this._inputAmount=void 0,this._updateChangeOutput()};G.prototype.sign=function(e,t){Ht.checkState(this.hasAllUtxoInfo(),"Not all utxo information is available to sign the transaction.");var r=this;return pe.isArray(e)?(pe.each(e,function(n){r.sign(n,t)}),this):(pe.each(this.getSignatures(e,t),function(n){r.applySignature(n)}),this)};G.prototype.getSignatures=function(e,t){e=new y4(e),t=t||Tc.SIGHASH_ALL|Tc.SIGHASH_FORKID;var r=this,n=[],i=Tx.sha256ripemd160(e.publicKey.toBuffer());return pe.each(this.inputs,function(s,a){pe.each(s.getSignatures(r,e,a,t,i),function(c){n.push(c)})}),n};G.prototype.applySignature=function(e){return this.inputs[e.inputIndex].addSignature(this,e),this};G.prototype.isFullySigned=function(){return pe.each(this.inputs,function(e){if(e.isFullySigned===Nt.prototype.isFullySigned)throw new Mt.Transaction.UnableToVerifySignature("Unrecognized script kind, or not enough information to execute script.This usually happens when creating a transaction from a serialized transaction")}),pe.every(pe.map(this.inputs,function(e){return e.isFullySigned()}))};G.prototype.isValidSignature=function(e){var t=this;if(this.inputs[e.inputIndex].isValidSignature===Nt.prototype.isValidSignature)throw new Mt.Transaction.UnableToVerifySignature("Unrecognized script kind, or not enough information to execute script.This usually happens when creating a transaction from a serialized transaction");return this.inputs[e.inputIndex].isValidSignature(t,e)};G.prototype.verifySignature=function(e,t,r,n,i,o){return Px.verify(this,e,t,r,n,i,o)};G.prototype.verify=function(){if(this.inputs.length===0)return"transaction txins empty";if(this.outputs.length===0)return"transaction txouts empty";for(var e=new Rc(0),t=0;t<this.outputs.length;t++){var r=this.outputs[t];if(r.invalidSatoshis())return"transaction txout "+t+" satoshis is invalid";if(r._satoshisBN.gt(new Rc(G.MAX_MONEY,10)))return"transaction txout "+t+" greater than MAX_MONEY";if(e=e.add(r._satoshisBN),e.gt(new Rc(G.MAX_MONEY)))return"transaction txout "+t+" total output greater than MAX_MONEY"}if(this.toBuffer().length>w4)return"transaction over the maximum block size";var n={};for(t=0;t<this.inputs.length;t++){var i=this.inputs[t],o=i.prevTxId+":"+i.outputIndex;if(!pe.isUndefined(n[o]))return"transaction input "+t+" duplicate input";n[o]=!0}var s=this.isCoinbase();if(s){var a=this.inputs[0]._scriptBuffer;if(a.length<2||a.length>100)return"coinbase transaction script size invalid"}else for(t=0;t<this.inputs.length;t++)if(this.inputs[t].isNull())return"transaction input "+t+" has null input";return!0};G.prototype.isCoinbase=function(){return this.inputs.length===1&&this.inputs[0].isNull()};G.prototype.sighash=function(e,t,r,n,i){t=t||Tc.SIGHASH_ALL|Tc.SIGHASH_FORKID;var o=this.inputs[e];if(!o)throw new Error("Input index "+e+" does not exist");return!r&&o.output&&(r=o.output.script),!n&&o.output&&(n=new Rc(o.output.satoshis)),i=i||v4,Px.sighash(this,t,e,r,n,i)};Mx.exports=G});var Rp=P((ZH,oo)=>{p();oo.exports=Ip();oo.exports.Input=Ec();oo.exports.Output=Hn();oo.exports.UnspentOutput=Ap();oo.exports.Signature=ls();oo.exports.Sighash=yi()});var Ac=P((JH,Lx)=>{"use strict";p();var Pc=Ge(),Ka=fp(),N=sp(),ce=wr(),ja=Zt(),so=er(),Tp=Or(),kx=HE(),M=function e(t){if(!(this instanceof e))return new e(t);t?(this.initialize(),this.set(t)):this.initialize()};M.prototype.verify=function(e,t,r,n,i,o){var s=Rp();if(Pc.isUndefined(r)&&(r=new s),Pc.isUndefined(n)&&(n=0),Pc.isUndefined(i)&&(i=0),i&M.SCRIPT_ENABLE_SIGHASH_FORKID&&(i|=M.SCRIPT_VERIFY_STRICTENC,!o))throw new Error("internal error - need satoshisBN to verify FORKID transactions");this.set({script:e,tx:r,nin:n,flags:i,satoshisBN:o});var a;if((i&M.SCRIPT_VERIFY_SIGPUSHONLY)!==0&&!e.isPushOnly())return this.errstr="SCRIPT_ERR_SIG_PUSHONLY",!1;if(!this.evaluate())return!1;i&M.SCRIPT_VERIFY_P2SH&&(a=this.stack.slice());var c=this.stack;if(this.initialize(),this.set({script:t,stack:c,tx:r,nin:n,flags:i,satoshisBN:o}),!this.evaluate())return!1;if(this.stack.length===0)return this.errstr="SCRIPT_ERR_EVAL_FALSE_NO_RESULT",!1;var l=this.stack[this.stack.length-1];if(!M.castToBool(l))return this.errstr="SCRIPT_ERR_EVAL_FALSE_IN_STACK",!1;if(i&M.SCRIPT_VERIFY_P2SH&&t.isScriptHashOut()){if(!e.isPushOnly())return this.errstr="SCRIPT_ERR_SIG_PUSHONLY",!1;if(a.length===0)throw new Error("internal error - stack copy empty");var g=a[a.length-1],m=Ka.fromBuffer(g);if(a.pop(),this.initialize(),this.set({script:m,stack:a,tx:r,nin:n,flags:i,satoshisBN:o}),!this.evaluate())return!1;if(a.length===0)return this.errstr="SCRIPT_ERR_EVAL_FALSE_NO_P2SH_STACK",!1;if(!M.castToBool(a[a.length-1]))return this.errstr="SCRIPT_ERR_EVAL_FALSE_IN_P2SH_STACK",!1}if((i&M.SCRIPT_VERIFY_CLEANSTACK)!==0){if((i&M.SCRIPT_VERIFY_P2SH)===0)throw new Error("internal error - CLEANSTACK without P2SH");if(a.length!==1)return this.errstr="SCRIPT_ERR_CLEANSTACK",!1}return!0};Lx.exports=M;M.prototype.initialize=function(e){this.stack=[],this.altstack=[],this.pc=0,this.pbegincodehash=0,this.nOpCount=0,this.vfExec=[],this.errstr="",this.flags=0};M.prototype.set=function(e){this.script=e.script||this.script,this.tx=e.tx||this.tx,this.nin=typeof e.nin<"u"?e.nin:this.nin,this.satoshisBN=e.satoshisBN||this.satoshisBN,this.stack=e.stack||this.stack,this.altstack=e.altstack||this.altstack,this.pc=typeof e.pc<"u"?e.pc:this.pc,this.pbegincodehash=typeof e.pbegincodehash<"u"?e.pbegincodehash:this.pbegincodehash,this.nOpCount=typeof e.nOpCount<"u"?e.nOpCount:this.nOpCount,this.vfExec=e.vfExec||this.vfExec,this.errstr=e.errstr||this.errstr,this.flags=typeof e.flags<"u"?e.flags:this.flags};M.true=d.Buffer.from([1]);M.false=d.Buffer.from([]);M.MAX_SCRIPT_ELEMENT_SIZE=520;M.MAXIMUM_ELEMENT_SIZE=4;M.MAX_OPS_PER_SCRIPT=201;M.MAX_SCRIPT_SIZE=1e4;M.LOCKTIME_THRESHOLD=5e8;M.LOCKTIME_THRESHOLD_BN=new ce(M.LOCKTIME_THRESHOLD);M.useGenesisLimits=function(e){return e=e||2147483647,M.MAX_SCRIPT_ELEMENT_SIZE=e,M.MAXIMUM_ELEMENT_SIZE=e,M.MAX_OPS_PER_SCRIPT=e,M.MAX_SCRIPT_SIZE=e,M};M.getLimits=function(){return{maxScriptElementSize:M.MAX_SCRIPT_ELEMENT_SIZE,maximumElementSize:M.MAXIMUM_ELEMENT_SIZE,maxOpsPerScript:M.MAX_OPS_PER_SCRIPT,maxScriptSize:M.MAX_SCRIPT_SIZE}};M.setLimits=function(e){return e=e||{},e.maxScriptElementSize!=null&&(M.MAX_SCRIPT_ELEMENT_SIZE=e.maxScriptElementSize),e.maximumElementSize!=null&&(M.MAXIMUM_ELEMENT_SIZE=e.maximumElementSize),e.maxOpsPerScript!=null&&(M.MAX_OPS_PER_SCRIPT=e.maxOpsPerScript),e.maxScriptSize!=null&&(M.MAX_SCRIPT_SIZE=e.maxScriptSize),M};M.SCRIPT_VERIFY_NONE=0;M.SCRIPT_VERIFY_P2SH=1;M.SCRIPT_VERIFY_STRICTENC=2;M.SCRIPT_VERIFY_DERSIG=4;M.SCRIPT_VERIFY_LOW_S=8;M.SCRIPT_VERIFY_NULLDUMMY=16;M.SCRIPT_VERIFY_SIGPUSHONLY=32;M.SCRIPT_VERIFY_MINIMALDATA=64;M.SCRIPT_VERIFY_DISCOURAGE_UPGRADABLE_NOPS=128;M.SCRIPT_VERIFY_CLEANSTACK=256;M.SCRIPT_VERIFY_CHECKLOCKTIMEVERIFY=512;M.SCRIPT_VERIFY_CHECKSEQUENCEVERIFY=1024;M.SCRIPT_VERIFY_MINIMALIF=8192;M.SCRIPT_VERIFY_NULLFAIL=16384;M.SCRIPT_VERIFY_COMPRESSED_PUBKEYTYPE=32768;M.SCRIPT_ENABLE_SIGHASH_FORKID=65536;M.SCRIPT_ENABLE_REPLAY_PROTECTION=1<<17;M.SCRIPT_ENABLE_MONOLITH_OPCODES=1<<18;M.SCRIPT_ENABLE_MAGNETIC_OPCODES=1<<19;M.SCRIPT_ENABLE_CHRONICLE=1<<20;M.CHRONICLE_ACTIVATION_HEIGHT=943816;M.mainnetFlags=function(e){e=e||{};var t=M.SCRIPT_VERIFY_P2SH|M.SCRIPT_VERIFY_STRICTENC|M.SCRIPT_VERIFY_DERSIG|M.SCRIPT_VERIFY_LOW_S|M.SCRIPT_VERIFY_NULLFAIL|M.SCRIPT_VERIFY_MINIMALDATA|M.SCRIPT_VERIFY_CHECKLOCKTIMEVERIFY|M.SCRIPT_VERIFY_CHECKSEQUENCEVERIFY|M.SCRIPT_ENABLE_SIGHASH_FORKID|M.SCRIPT_ENABLE_MAGNETIC_OPCODES|M.SCRIPT_ENABLE_MONOLITH_OPCODES;return e.afterChronicle!==!1&&(t|=M.SCRIPT_ENABLE_CHRONICLE),t};M.SEQUENCE_LOCKTIME_DISABLE_FLAG=1<<31;M.SEQUENCE_LOCKTIME_TYPE_FLAG=1<<22;M.SEQUENCE_LOCKTIME_MASK=65535;M.castToBool=function(e){for(var t=0;t<e.length;t++)if(e[t]!==0)return!(t===e.length-1&&e[t]===128);return!1};M.prototype.checkSignatureEncoding=function(e){var t;if(e.length===0)return!0;if((this.flags&(M.SCRIPT_VERIFY_DERSIG|M.SCRIPT_VERIFY_LOW_S|M.SCRIPT_VERIFY_STRICTENC))!==0&&!so.isTxDER(e))return this.errstr="SCRIPT_ERR_SIG_DER_INVALID_FORMAT",!1;if((this.flags&M.SCRIPT_VERIFY_LOW_S)!==0){if(t=so.fromTxFormat(e),!t.hasLowS())return this.errstr="SCRIPT_ERR_SIG_DER_HIGH_S",!1}else if((this.flags&M.SCRIPT_VERIFY_STRICTENC)!==0){if(t=so.fromTxFormat(e),!t.hasDefinedHashtype())return this.errstr="SCRIPT_ERR_SIG_HASHTYPE",!1;if(!(this.flags&M.SCRIPT_ENABLE_SIGHASH_FORKID)&&t.nhashtype&so.SIGHASH_FORKID)return this.errstr="SCRIPT_ERR_ILLEGAL_FORKID",!1;if(this.flags&M.SCRIPT_ENABLE_SIGHASH_FORKID&&!(t.nhashtype&so.SIGHASH_FORKID))return this.errstr="SCRIPT_ERR_MUST_USE_FORKID",!1}return!0};M.prototype.checkPubkeyEncoding=function(e){return(this.flags&M.SCRIPT_VERIFY_STRICTENC)!==0&&!Tp.isValid(e)?(this.errstr="SCRIPT_ERR_PUBKEYTYPE",!1):!0};M._isMinimallyEncoded=function(e,t){return t=t||M.MAXIMUM_ELEMENT_SIZE,!(e.length>t||e.length>0&&(e[e.length-1]&127)===0&&(e.length<=1||(e[e.length-2]&128)===0))};M._minimallyEncode=function(e){if(e.length===0)return e;var t=e[e.length-1];if(t&127)return e;if(e.length===1)return d.Buffer.from("");if(e[e.length-2]&128)return e;for(var r=e.length-1;r>0;r--)if(e[r-1]!==0)return e[r-1]&128?e[r++]=t:e[r-1]|=t,e.slice(0,r);return d.Buffer.from("")};M.prototype.evaluate=function(){if(this.script.toBuffer().length>M.MAX_SCRIPT_SIZE)return this.errstr="SCRIPT_ERR_SCRIPT_SIZE",!1;try{for(;this.pc<this.script.chunks.length;){let t={pc:this.pc,opcode:N.fromNumber(this.script.chunks[this.pc].opcodenum)};var e=this.step();if(!e)return!1;this._callbackStep(t)}if(this.stack.length+this.altstack.length>1e3)return this.errstr="SCRIPT_ERR_STACK_SIZE",!1}catch(t){return this.errstr="SCRIPT_ERR_UNKNOWN_ERROR: "+t,!1}return this.vfExec.length>0?(this.errstr="SCRIPT_ERR_UNBALANCED_CONDITIONAL",!1):!0};M.prototype._callbackStep=function(e){if(typeof this.stepListener=="function")try{this.stepListener(e,kx(this.stack,!0),kx(this.altstack,!0))}catch(t){console.log(`Error in Step callback:${t}`)}};M.prototype.checkLockTime=function(e){return!(!(this.tx.nLockTime<M.LOCKTIME_THRESHOLD&&e.lt(M.LOCKTIME_THRESHOLD_BN)||this.tx.nLockTime>=M.LOCKTIME_THRESHOLD&&e.gte(M.LOCKTIME_THRESHOLD_BN))||e.gt(new ce(this.tx.nLockTime))||this.tx.inputs[this.nin].isFinal())};M.prototype.checkSequence=function(e){var t=this.tx.inputs[this.nin].sequenceNumber;if(this.tx.version<2||t&M.SEQUENCE_LOCKTIME_DISABLE_FLAG)return!1;var r=M.SEQUENCE_LOCKTIME_TYPE_FLAG|M.SEQUENCE_LOCKTIME_MASK,n=new ce(t&r),i=e.and(new ce(r)),o=new ce(M.SEQUENCE_LOCKTIME_TYPE_FLAG);return!(!(n.lt(o)&&i.lt(o)||n.gte(o)&&i.gte(o))||i.gt(n))};function S4(e,t){let r=e;for(;r.length<t;)r=d.Buffer.concat([d.Buffer.from([0]),r]);return r}function Cx(e){var t=d.Buffer.alloc(4);return t.writeInt32LE(e|0,0),t}M.prototype.step=function(){var e=this;function t(te){return e.stack[e.stack.length+te]}function r(te){switch(te){case N.OP_2MUL:case N.OP_2DIV:if((e.flags&M.SCRIPT_ENABLE_CHRONICLE)===0)return!0;break;case N.OP_INVERT:case N.OP_MUL:case N.OP_LSHIFT:case N.OP_RSHIFT:if((e.flags&M.SCRIPT_ENABLE_MAGNETIC_OPCODES)===0)return!0;break;case N.OP_DIV:case N.OP_MOD:case N.OP_SPLIT:case N.OP_CAT:case N.OP_AND:case N.OP_OR:case N.OP_XOR:case N.OP_BIN2NUM:case N.OP_NUM2BIN:return!1;default:break}return!1}var n=(this.flags&M.SCRIPT_VERIFY_MINIMALDATA)!==0,i=this.vfExec.indexOf(!1)===-1,o,s,a,c,l,g,m,_,x,R,B,C,U,V,z,j,Y,oe=this.script.chunks[this.pc];this.pc++;var Q=oe.opcodenum;if(Pc.isUndefined(Q))return this.errstr="SCRIPT_ERR_UNDEFINED_OPCODE",!1;if(oe.buf&&oe.buf.length>M.MAX_SCRIPT_ELEMENT_SIZE)return this.errstr="SCRIPT_ERR_PUSH_SIZE",!1;if(Q>N.OP_16&&++this.nOpCount>M.MAX_OPS_PER_SCRIPT)return this.errstr="SCRIPT_ERR_OP_COUNT",!1;if(r(Q))return this.errstr="SCRIPT_ERR_DISABLED_OPCODE",!1;if(i&&Q>=0&&Q<=N.OP_PUSHDATA4){if(n&&!this.script.checkMinimalPush(this.pc-1))return this.errstr="SCRIPT_ERR_MINIMALDATA",!1;if(!oe.buf)this.stack.push(M.false);else{if(oe.len!==oe.buf.length)throw new Error(`Length of push value not equal to length of data (${oe.len},${oe.buf.length})`);this.stack.push(oe.buf)}}else if(i||N.OP_IF<=Q&&Q<=N.OP_ENDIF)switch(Q){case N.OP_1NEGATE:case N.OP_1:case N.OP_2:case N.OP_3:case N.OP_4:case N.OP_5:case N.OP_6:case N.OP_7:case N.OP_8:case N.OP_9:case N.OP_10:case N.OP_11:case N.OP_12:case N.OP_13:case N.OP_14:case N.OP_15:case N.OP_16:l=Q-(N.OP_1-1),o=new ce(l).toScriptNumBuffer(),this.stack.push(o);break;case N.OP_NOP:break;case N.OP_NOP2:case N.OP_CHECKLOCKTIMEVERIFY:if(!(this.flags&M.SCRIPT_VERIFY_CHECKLOCKTIMEVERIFY)){if(this.flags&M.SCRIPT_VERIFY_DISCOURAGE_UPGRADABLE_NOPS)return this.errstr="SCRIPT_ERR_DISCOURAGE_UPGRADABLE_NOPS",!1;break}if(this.stack.length<1)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;var se=ce.fromScriptNumBuffer(this.stack[this.stack.length-1],n,5);if(se.lt(new ce(0)))return this.errstr="SCRIPT_ERR_NEGATIVE_LOCKTIME",!1;if(!this.checkLockTime(se))return this.errstr="SCRIPT_ERR_UNSATISFIED_LOCKTIME",!1;break;case N.OP_NOP3:case N.OP_CHECKSEQUENCEVERIFY:if(!(this.flags&M.SCRIPT_VERIFY_CHECKSEQUENCEVERIFY)){if(this.flags&M.SCRIPT_VERIFY_DISCOURAGE_UPGRADABLE_NOPS)return this.errstr="SCRIPT_ERR_DISCOURAGE_UPGRADABLE_NOPS",!1;break}if(this.stack.length<1)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;var ye=ce.fromScriptNumBuffer(t(-1),n,5);if(ye.lt(new ce(0)))return this.errstr="SCRIPT_ERR_NEGATIVE_LOCKTIME",!1;if((ye&M.SEQUENCE_LOCKTIME_DISABLE_FLAG)!==0)break;if(!this.checkSequence(ye))return this.errstr="SCRIPT_ERR_UNSATISFIED_LOCKTIME",!1;break;case N.OP_NOP1:case N.OP_NOP9:case N.OP_NOP10:if(this.flags&M.SCRIPT_VERIFY_DISCOURAGE_UPGRADABLE_NOPS)return this.errstr="SCRIPT_ERR_DISCOURAGE_UPGRADABLE_NOPS",!1;break;case N.OP_LSHIFTNUM:case N.OP_RSHIFTNUM:if((this.flags&M.SCRIPT_ENABLE_CHRONICLE)===0){if(this.flags&M.SCRIPT_VERIFY_DISCOURAGE_UPGRADABLE_NOPS)return this.errstr="SCRIPT_ERR_DISCOURAGE_UPGRADABLE_NOPS",!1;break}if(this.stack.length<2)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;var A=M.MAXIMUM_ELEMENT_SIZE,u=ce.fromScriptNumBuffer(t(-1),n,A);if(u.isNeg())return this.errstr="SCRIPT_ERR_INVALID_NUMBER_RANGE",!1;this.stack.pop();var h=ce.fromScriptNumBuffer(t(-1),n,A);this.stack.pop();var y=u.toNumber(),v=h.isNeg(),b=h.abs(),E;if(Q===N.OP_LSHIFTNUM){var O=h.toScriptNumBuffer().length;if(O+Math.floor(y/8)>A)return this.errstr="SCRIPT_ERR_SCRIPTNUM_OVERFLOW",!1;E=b.shln(y)}else E=y>=b.bitLength()?new ce(0):b.shrn(y);if(v&&!E.isZero()&&(E=E.neg()),E.toScriptNumBuffer().length>A)return this.errstr="SCRIPT_ERR_SCRIPTNUM_OVERFLOW",!1;this.stack.push(E.toScriptNumBuffer());break;case N.OP_VER:if((this.flags&M.SCRIPT_ENABLE_CHRONICLE)===0)return this.errstr="SCRIPT_ERR_BAD_OPCODE",!1;if(this.tx==null)return this.errstr="SCRIPT_ERR_UNKNOWN_ERROR",!1;this.stack.push(Cx(this.tx.version));break;case N.OP_VERIF:case N.OP_VERNOTIF:if((this.flags&M.SCRIPT_ENABLE_CHRONICLE)===0){if(!i)break;return this.errstr="SCRIPT_ERR_BAD_OPCODE",!1}if(j=!1,i){if(this.stack.length<1)return this.errstr="SCRIPT_ERR_UNBALANCED_CONDITIONAL",!1;if(this.tx==null)return this.errstr="SCRIPT_ERR_UNKNOWN_ERROR",!1;o=t(-1),j=o.length===4&&o.equals(Cx(this.tx.version)),Q===N.OP_VERNOTIF&&(j=!j),this.stack.pop()}this.vfExec.push(j);break;case N.OP_IF:case N.OP_NOTIF:if(j=!1,i){if(this.stack.length<1)return this.errstr="SCRIPT_ERR_UNBALANCED_CONDITIONAL",!1;if(o=t(-1),this.flags&M.SCRIPT_VERIFY_MINIMALIF){if(o.length>1)return this.errstr="SCRIPT_ERR_MINIMALIF",!1;if(o.length===1&&o[0]!==1)return this.errstr="SCRIPT_ERR_MINIMALIF",!1}j=M.castToBool(o),Q===N.OP_NOTIF&&(j=!j),this.stack.pop()}this.vfExec.push(j);break;case N.OP_ELSE:if(this.vfExec.length===0)return this.errstr="SCRIPT_ERR_UNBALANCED_CONDITIONAL",!1;this.vfExec[this.vfExec.length-1]=!this.vfExec[this.vfExec.length-1];break;case N.OP_ENDIF:if(this.vfExec.length===0)return this.errstr="SCRIPT_ERR_UNBALANCED_CONDITIONAL",!1;this.vfExec.pop();break;case N.OP_VERIFY:if(this.stack.length<1)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;if(o=t(-1),j=M.castToBool(o),j)this.stack.pop();else return this.errstr="SCRIPT_ERR_VERIFY",!1;break;case N.OP_RETURN:return this.errstr="SCRIPT_ERR_OP_RETURN",!1;case N.OP_TOALTSTACK:if(this.stack.length<1)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;this.altstack.push(this.stack.pop());break;case N.OP_FROMALTSTACK:if(this.altstack.length<1)return this.errstr="SCRIPT_ERR_INVALID_ALTSTACK_OPERATION",!1;this.stack.push(this.altstack.pop());break;case N.OP_2DROP:if(this.stack.length<2)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;this.stack.pop(),this.stack.pop();break;case N.OP_2DUP:if(this.stack.length<2)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;s=t(-2),a=t(-1),this.stack.push(d.Buffer.from(s)),this.stack.push(d.Buffer.from(a));break;case N.OP_3DUP:if(this.stack.length<3)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;s=t(-3),a=t(-2);var w=t(-1);this.stack.push(d.Buffer.from(s)),this.stack.push(d.Buffer.from(a)),this.stack.push(d.Buffer.from(w));break;case N.OP_2OVER:if(this.stack.length<4)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;s=t(-4),a=t(-3),this.stack.push(d.Buffer.from(s)),this.stack.push(d.Buffer.from(a));break;case N.OP_2ROT:if(this.stack.length<6)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;c=this.stack.splice(this.stack.length-6,2),this.stack.push(c[0]),this.stack.push(c[1]);break;case N.OP_2SWAP:if(this.stack.length<4)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;c=this.stack.splice(this.stack.length-4,2),this.stack.push(c[0]),this.stack.push(c[1]);break;case N.OP_IFDUP:if(this.stack.length<1)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;o=t(-1),j=M.castToBool(o),j&&this.stack.push(d.Buffer.from(o));break;case N.OP_DEPTH:o=new ce(this.stack.length).toScriptNumBuffer(),this.stack.push(o);break;case N.OP_DROP:if(this.stack.length<1)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;this.stack.pop();break;case N.OP_DUP:if(this.stack.length<1)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;this.stack.push(d.Buffer.from(t(-1)));break;case N.OP_NIP:if(this.stack.length<2)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;this.stack.splice(this.stack.length-2,1);break;case N.OP_OVER:if(this.stack.length<2)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;this.stack.push(d.Buffer.from(t(-2)));break;case N.OP_PICK:case N.OP_ROLL:if(this.stack.length<2)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;if(o=t(-1),_=ce.fromScriptNumBuffer(o,n),l=_.toNumber(),this.stack.pop(),l<0||l>=this.stack.length)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;o=t(-l-1),Q===N.OP_ROLL&&this.stack.splice(this.stack.length-l-1,1),this.stack.push(d.Buffer.from(o));break;case N.OP_ROT:if(this.stack.length<3)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;g=t(-3),m=t(-2);var f=t(-1);this.stack[this.stack.length-3]=m,this.stack[this.stack.length-2]=f,this.stack[this.stack.length-1]=g;break;case N.OP_SWAP:if(this.stack.length<2)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;g=t(-2),m=t(-1),this.stack[this.stack.length-2]=m,this.stack[this.stack.length-1]=g;break;case N.OP_TUCK:if(this.stack.length<2)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;this.stack.splice(this.stack.length-2,0,d.Buffer.from(t(-1)));break;case N.OP_SIZE:if(this.stack.length<1)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;_=new ce(t(-1).length),this.stack.push(_.toScriptNumBuffer());break;case N.OP_AND:case N.OP_OR:case N.OP_XOR:if(this.stack.length<2)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;if(s=t(-2),a=t(-1),s.length!==a.length)return this.errstr="SCRIPT_ERR_INVALID_OPERAND_SIZE",!1;switch(Q){case N.OP_AND:for(let te=0;te<s.length;te++)s[te]&=a[te];break;case N.OP_OR:for(let te=0;te<s.length;te++)s[te]|=a[te];break;case N.OP_XOR:for(let te=0;te<s.length;te++)s[te]^=a[te];break;default:break}this.stack.pop();break;case N.OP_INVERT:this.stack.length<1&&(this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION"),o=t(-1);for(let te=0;te<o.length;te++)o[te]=~o[te];break;case N.OP_LSHIFT:case N.OP_RSHIFT:if(this.stack.length<2)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;if(s=t(-2),s.length===0)this.stack.pop();else{if(x=new ce(s),R=ce.fromScriptNumBuffer(t(-1),n),l=R.toNumber(),l<0)return this.errstr="SCRIPT_ERR_INVALID_NUMBER_RANGE",!1;this.stack.pop(),this.stack.pop();let te;Q===N.OP_LSHIFT&&(te=x.ushln(l)),Q===N.OP_RSHIFT&&(te=x.ushrn(l));let ve=S4(d.Buffer.from(te.toArray().slice(s.length*-1)),s.length);this.stack.push(ve)}break;case N.OP_EQUAL:case N.OP_EQUALVERIFY:if(this.stack.length<2)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;s=t(-2),a=t(-1);var S=s.toString("hex")===a.toString("hex");if(this.stack.pop(),this.stack.pop(),this.stack.push(S?M.true:M.false),Q===N.OP_EQUALVERIFY)if(S)this.stack.pop();else return this.errstr="SCRIPT_ERR_EQUALVERIFY",!1;break;case N.OP_2MUL:case N.OP_2DIV:case N.OP_1ADD:case N.OP_1SUB:case N.OP_NEGATE:case N.OP_ABS:case N.OP_NOT:case N.OP_0NOTEQUAL:if(this.stack.length<1)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;switch(o=t(-1),_=ce.fromScriptNumBuffer(o,n),Q){case N.OP_2MUL:_=_.mul(new ce(2));break;case N.OP_2DIV:_=_.div(new ce(2));break;case N.OP_1ADD:_=_.add(ce.One);break;case N.OP_1SUB:_=_.sub(ce.One);break;case N.OP_NEGATE:_=_.neg();break;case N.OP_ABS:_.cmp(ce.Zero)<0&&(_=_.neg());break;case N.OP_NOT:_=new ce((_.cmp(ce.Zero)===0)+0);break;case N.OP_0NOTEQUAL:_=new ce((_.cmp(ce.Zero)!==0)+0);break}this.stack.pop(),this.stack.push(_.toScriptNumBuffer());break;case N.OP_ADD:case N.OP_SUB:case N.OP_MUL:case N.OP_MOD:case N.OP_DIV:case N.OP_BOOLAND:case N.OP_BOOLOR:case N.OP_NUMEQUAL:case N.OP_NUMEQUALVERIFY:case N.OP_NUMNOTEQUAL:case N.OP_LESSTHAN:case N.OP_GREATERTHAN:case N.OP_LESSTHANOREQUAL:case N.OP_GREATERTHANOREQUAL:case N.OP_MIN:case N.OP_MAX:if(this.stack.length<2)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;switch(x=ce.fromScriptNumBuffer(t(-2),n,M.MAXIMUM_ELEMENT_SIZE),R=ce.fromScriptNumBuffer(t(-1),n,M.MAXIMUM_ELEMENT_SIZE),_=new ce(0),Q){case N.OP_ADD:_=x.add(R);break;case N.OP_SUB:_=x.sub(R);break;case N.OP_MUL:_=x.mul(R);break;case N.OP_DIV:if(R===0)return this.errstr="SCRIPT_ERR_DIV_BY_ZERO",!1;_=x.div(R);break;case N.OP_MOD:if(R===0)return this.errstr="SCRIPT_ERR_DIV_BY_ZERO",!1;_=x.mod(R);break;case N.OP_BOOLAND:_=new ce((x.cmp(ce.Zero)!==0&&R.cmp(ce.Zero)!==0)+0);break;case N.OP_BOOLOR:_=new ce((x.cmp(ce.Zero)!==0||R.cmp(ce.Zero)!==0)+0);break;case N.OP_NUMEQUAL:_=new ce((x.cmp(R)===0)+0);break;case N.OP_NUMEQUALVERIFY:_=new ce((x.cmp(R)===0)+0);break;case N.OP_NUMNOTEQUAL:_=new ce((x.cmp(R)!==0)+0);break;case N.OP_LESSTHAN:_=new ce((x.cmp(R)<0)+0);break;case N.OP_GREATERTHAN:_=new ce((x.cmp(R)>0)+0);break;case N.OP_LESSTHANOREQUAL:_=new ce((x.cmp(R)<=0)+0);break;case N.OP_GREATERTHANOREQUAL:_=new ce((x.cmp(R)>=0)+0);break;case N.OP_MIN:_=x.cmp(R)<0?x:R;break;case N.OP_MAX:_=x.cmp(R)>0?x:R;break}if(this.stack.pop(),this.stack.pop(),this.stack.push(_.toScriptNumBuffer()),Q===N.OP_NUMEQUALVERIFY)if(M.castToBool(t(-1)))this.stack.pop();else return this.errstr="SCRIPT_ERR_NUMEQUALVERIFY",!1;break;case N.OP_WITHIN:if(this.stack.length<3)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;x=ce.fromScriptNumBuffer(t(-3),n,M.MAXIMUM_ELEMENT_SIZE),R=ce.fromScriptNumBuffer(t(-2),n,M.MAXIMUM_ELEMENT_SIZE);var H=ce.fromScriptNumBuffer(t(-1),n,M.MAXIMUM_ELEMENT_SIZE);j=R.cmp(x)<=0&&x.cmp(H)<0,this.stack.pop(),this.stack.pop(),this.stack.pop(),this.stack.push(j?M.true:M.false);break;case N.OP_RIPEMD160:case N.OP_SHA1:case N.OP_SHA256:case N.OP_HASH160:case N.OP_HASH256:if(this.stack.length<1)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;o=t(-1);var q;Q===N.OP_RIPEMD160?q=ja.ripemd160(o):Q===N.OP_SHA1?q=ja.sha1(o):Q===N.OP_SHA256?q=ja.sha256(o):Q===N.OP_HASH160?q=ja.sha256ripemd160(o):Q===N.OP_HASH256&&(q=ja.sha256sha256(o)),this.stack.pop(),this.stack.push(q);break;case N.OP_CODESEPARATOR:this.pbegincodehash=this.pc;break;case N.OP_CHECKSIG:case N.OP_CHECKSIGVERIFY:if(this.stack.length<2)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;if(B=t(-2),C=t(-1),!this.checkSignatureEncoding(B)||!this.checkPubkeyEncoding(C))return!1;U=new Ka().set({chunks:this.script.chunks.slice(this.pbegincodehash)});var W=new Ka().add(B);U.findAndDelete(W);try{V=so.fromTxFormat(B),z=Tp.fromBuffer(C,!1),Y=this.tx.verifySignature(V,z,this.nin,U,this.satoshisBN,this.flags)}catch{Y=!1}if(!Y&&this.flags&M.SCRIPT_VERIFY_NULLFAIL&&B.length)return this.errstr="SCRIPT_ERR_NULLFAIL",!1;if(this.stack.pop(),this.stack.pop(),this.stack.push(Y?M.true:M.false),Q===N.OP_CHECKSIGVERIFY)if(Y)this.stack.pop();else return this.errstr="SCRIPT_ERR_CHECKSIGVERIFY",!1;break;case N.OP_CHECKMULTISIG:case N.OP_CHECKMULTISIGVERIFY:var $=1;if(this.stack.length<$)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;var X=ce.fromScriptNumBuffer(t(-$),n).toNumber();if(X<0||X>20)return this.errstr="SCRIPT_ERR_PUBKEY_COUNT",!1;if(this.nOpCount+=X,this.nOpCount>M.MAX_OPS_PER_SCRIPT)return this.errstr="SCRIPT_ERR_OP_COUNT",!1;var ae=++$;$+=X;var ge=X+2;if(this.stack.length<$)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;var le=ce.fromScriptNumBuffer(t(-$),n).toNumber();if(le<0||le>X)return this.errstr="SCRIPT_ERR_SIG_COUNT",!1;var T=++$;if($+=le,this.stack.length<$)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;U=new Ka().set({chunks:this.script.chunks.slice(this.pbegincodehash)});for(var k=0;k<le;k++)B=t(-T-k),U.findAndDelete(new Ka().add(B));for(Y=!0;Y&&le>0;){if(B=t(-T),C=t(-ae),!this.checkSignatureEncoding(B)||!this.checkPubkeyEncoding(C))return!1;var F;try{V=so.fromTxFormat(B),z=Tp.fromBuffer(C,!1),F=this.tx.verifySignature(V,z,this.nin,U,this.satoshisBN,this.flags)}catch{F=!1}F&&(T++,le--),ae++,X--,le>X&&(Y=!1)}for(;$-- >1;){if(!Y&&this.flags&M.SCRIPT_VERIFY_NULLFAIL&&!ge&&t(-1).length)return this.errstr="SCRIPT_ERR_NULLFAIL",!1;ge>0&&ge--,this.stack.pop()}if(this.stack.length<1)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;if(this.flags&M.SCRIPT_VERIFY_NULLDUMMY&&t(-1).length)return this.errstr="SCRIPT_ERR_SIG_NULLDUMMY",!1;if(this.stack.pop(),this.stack.push(Y?M.true:M.false),Q===N.OP_CHECKMULTISIGVERIFY)if(Y)this.stack.pop();else return this.errstr="SCRIPT_ERR_CHECKMULTISIGVERIFY",!1;break;case N.OP_CAT:if(this.stack.length<2)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;if(s=t(-2),a=t(-1),s.length+a.length>M.MAX_SCRIPT_ELEMENT_SIZE)return this.errstr="SCRIPT_ERR_PUSH_SIZE",!1;this.stack[this.stack.length-2]=d.Buffer.concat([s,a]),this.stack.pop();break;case N.OP_SPLIT:if(this.stack.length<2)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;s=t(-2);var K=ce.fromScriptNumBuffer(t(-1),n).toNumber();if(K<0||K>s.length)return this.errstr="SCRIPT_ERR_INVALID_SPLIT_RANGE",!1;var ne=d.Buffer.from(s);this.stack[this.stack.length-2]=ne.slice(0,K),this.stack[this.stack.length-1]=ne.slice(K);break;case N.OP_LEFT:case N.OP_RIGHT:if((this.flags&M.SCRIPT_ENABLE_CHRONICLE)===0){if(this.flags&M.SCRIPT_VERIFY_DISCOURAGE_UPGRADABLE_NOPS)return this.errstr="SCRIPT_ERR_DISCOURAGE_UPGRADABLE_NOPS",!1;break}if(this.stack.length<2)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;if(s=t(-2),l=ce.fromScriptNumBuffer(t(-1),n,M.MAXIMUM_ELEMENT_SIZE).toNumber(),l<0||l>s.length)return this.errstr="SCRIPT_ERR_INVALID_NUMBER_RANGE",!1;this.stack.pop(),Q===N.OP_LEFT?this.stack[this.stack.length-1]=d.Buffer.from(s).slice(0,l):this.stack[this.stack.length-1]=d.Buffer.from(s).slice(s.length-l);break;case N.OP_SUBSTR:if((this.flags&M.SCRIPT_ENABLE_CHRONICLE)===0){if(this.flags&M.SCRIPT_VERIFY_DISCOURAGE_UPGRADABLE_NOPS)return this.errstr="SCRIPT_ERR_DISCOURAGE_UPGRADABLE_NOPS",!1;break}if(this.stack.length<3)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;s=t(-3);var J=ce.fromScriptNumBuffer(t(-1),n,M.MAXIMUM_ELEMENT_SIZE).toNumber(),ee=ce.fromScriptNumBuffer(t(-2),n,M.MAXIMUM_ELEMENT_SIZE).toNumber();if(ee<0||ee>=s.length||J<0||J>s.length-ee)return this.errstr="SCRIPT_ERR_INVALID_NUMBER_RANGE",!1;this.stack.pop(),this.stack.pop(),this.stack[this.stack.length-1]=d.Buffer.from(s).slice(ee,ee+J);break;case N.OP_NUM2BIN:if(this.stack.length<2)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;var de=ce.fromScriptNumBuffer(t(-1),n).toNumber();if(de>M.MAX_SCRIPT_ELEMENT_SIZE)return this.errstr="SCRIPT_ERR_PUSH_SIZE",!1;this.stack.pop();var ie=t(-1);if(ie=M._minimallyEncode(ie),ie.length>de)return this.errstr="SCRIPT_ERR_IMPOSSIBLE_ENCODING",!1;if(ie.length===de){this.stack[this.stack.length-1]=ie;break}var ue=0;ie.length>0&&(ue=ie[ie.length-1]&128,ie[ie.length-1]&=127);var Ye=d.Buffer.alloc(de);ie.copy(Ye,0);for(var Oe=ie.length-1;Oe++<de-2;)Ye[Oe]=0;Ye[Oe]=ue,this.stack[this.stack.length-1]=Ye;break;case N.OP_BIN2NUM:if(this.stack.length<1)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;if(s=t(-1),a=M._minimallyEncode(s),this.stack[this.stack.length-1]=a,!M._isMinimallyEncoded(a))return this.errstr="SCRIPT_ERR_INVALID_NUMBER_RANGE",!1;break;default:return this.errstr="SCRIPT_ERR_BAD_OPCODE",!1}return!0}});var Kr=P((e7,Pp)=>{p();Pp.exports=fp();Pp.exports.Interpreter=Ac()});var no=P((r7,Fx)=>{"use strict";p();var Bp=Ge(),zn=Ce(),E4=ri(),Dx=qd(),Tr=va(),Ux=Zt(),qx=lr(),Np=Or();function re(e,t,r){if(!(this instanceof re))return new re(e,t,r);if(Bp.isArray(e)&&Bp.isNumber(t))return re.createMultisig(e,t,r);if(e instanceof re)return e;if(zn.checkArgument(e,"First argument is required, please include address data.","guide/address.html"),t&&!Tr.get(t))throw new TypeError('Second argument must be "livenet", "testnet", or "regtest".');if(r&&r!==re.PayToPublicKeyHash&&r!==re.PayToScriptHash)throw new TypeError('Third argument must be "pubkeyhash" or "scripthash".');var n=this._classifyArguments(e,t,r);return n.network=n.network||Tr.get(t)||Tr.defaultNetwork,n.type=n.type||r||re.PayToPublicKeyHash,qx.defineImmutable(this,{hashBuffer:n.hashBuffer,network:n.network,type:n.type}),this}re.prototype._classifyArguments=function(e,t,r){if((e instanceof d.Buffer||e instanceof Uint8Array)&&e.length===20)return re._transformHash(e);if((e instanceof d.Buffer||e instanceof Uint8Array)&&e.length===21)return re._transformBuffer(e,t,r);if(e instanceof Np)return re._transformPublicKey(e);if(e instanceof Va())return re._transformScript(e,t);if(typeof e=="string")return re._transformString(e,t,r);if(Bp.isObject(e))return re._transformObject(e);throw new TypeError("First argument is an unrecognized data format.")};re.PayToPublicKeyHash="pubkeyhash";re.PayToScriptHash="scripthash";re._transformHash=function(e){var t={};if(!(e instanceof d.Buffer)&&!(e instanceof Uint8Array))throw new TypeError("Address supplied is not a buffer.");if(e.length!==20)throw new TypeError("Address hashbuffers must be exactly 20 bytes.");return t.hashBuffer=e,t};re._transformObject=function(e){return zn.checkArgument(e.hash||e.hashBuffer,"Must provide a `hash` or `hashBuffer` property"),zn.checkArgument(e.type,"Must provide a `type` property"),{hashBuffer:e.hash?d.Buffer.from(e.hash,"hex"):e.hashBuffer,network:Tr.get(e.network)||Tr.defaultNetwork,type:e.type}};re._classifyFromVersion=function(e){var t={},r=Tr.get(e[0],"pubkeyhash"),n=Tr.get(e[0],"scripthash");return r?(t.network=r,t.type=re.PayToPublicKeyHash):n&&(t.network=n,t.type=re.PayToScriptHash),t};re._transformBuffer=function(e,t,r){var n={};if(!(e instanceof d.Buffer)&&!(e instanceof Uint8Array))throw new TypeError("Address supplied is not a buffer.");if(e.length!==21)throw new TypeError("Address buffers must be exactly 21 bytes.");var i=Tr.get(t),o=re._classifyFromVersion(e);if(t&&!i)throw new TypeError("Unknown network");if(!o.network||i&&i!==o.network)throw new TypeError("Address has mismatched network type.");if(!o.type||r&&r!==o.type)throw new TypeError("Address has mismatched type.");return n.hashBuffer=e.slice(1),n.network=o.network,n.type=o.type,n};re._transformPublicKey=function(e){var t={};if(!(e instanceof Np))throw new TypeError("Address must be an instance of PublicKey.");return t.hashBuffer=Ux.sha256ripemd160(e.toBuffer()),t.type=re.PayToPublicKeyHash,t};re._transformScript=function(e,t){zn.checkArgument(e instanceof Va(),"script must be a Script instance");var r=e.getAddressInfo(t);if(!r)throw new E4.Script.CantDeriveAddress(e);return r};re.createMultisig=function(e,t,r){return r=r||e[0].network||Tr.defaultNetwork,re.payingTo(Va().buildMultisigOut(e,t),r)};re._transformString=function(e,t,r){if(typeof e!="string")throw new TypeError("data parameter supplied is not a string.");if(e.length<27)throw new Error("Invalid Address string provided");e=e.trim();var n=Tr.get(t);if(t&&!n)throw new TypeError("Unknown network");var i=Dx.decode(e);return re._transformBuffer(i,t,r)};re.fromPublicKey=function(e,t){var r=re._transformPublicKey(e);return t=t||Tr.defaultNetwork,new re(r.hashBuffer,t,r.type)};re.fromPrivateKey=function(e,t){let r=Np.fromPrivateKey(e);return t=t||e.network||Tr.defaultNetwork,re.fromPublicKey(r,t)};re.fromPublicKeyHash=function(e,t){var r=re._transformHash(e);return new re(r.hashBuffer,t,re.PayToPublicKeyHash)};re.fromScriptHash=function(e,t){zn.checkArgument(e,"hash parameter is required");var r=re._transformHash(e);return new re(r.hashBuffer,t,re.PayToScriptHash)};re.payingTo=function(e,t){return zn.checkArgument(e,"script is required"),zn.checkArgument(e instanceof Va(),"script must be instance of Script"),re.fromScriptHash(Ux.sha256ripemd160(e.toBuffer()),t)};re.fromScript=function(e,t){zn.checkArgument(e instanceof Va(),"script must be a Script instance");var r=re._transformScript(e,t);return new re(r.hashBuffer,t,r.type)};re.fromBuffer=function(e,t,r){var n=re._transformBuffer(e,t,r);return new re(n.hashBuffer,n.network,n.type)};re.fromHex=function(e,t,r){return re.fromBuffer(d.Buffer.from(e,"hex"),t,r)};re.fromString=function(e,t,r){var n=re._transformString(e,t,r);return new re(n.hashBuffer,n.network,n.type)};re.fromObject=function(t){zn.checkState(qx.isHexa(t.hash),'Unexpected hash property, "'+t.hash+'", expected to be hex.');var r=d.Buffer.from(t.hash,"hex");return new re(r,t.network,t.type)};re.getValidationError=function(e,t,r){var n;try{new re(e,t,r)}catch(i){n=i}return n};re.isValid=function(e,t,r){return!re.getValidationError(e,t,r)};re.prototype.isPayToPublicKeyHash=function(){return this.type===re.PayToPublicKeyHash};re.prototype.isPayToScriptHash=function(){return this.type===re.PayToScriptHash};re.prototype.toBuffer=function(){var e=d.Buffer.from([this.network[this.type]]),t=d.Buffer.concat([e,this.hashBuffer]);return t};re.prototype.toHex=function(){return this.toBuffer().toString("hex")};re.prototype.toObject=re.prototype.toJSON=function(){return{hash:this.hashBuffer.toString("hex"),type:this.type,network:this.network.toString()}};re.prototype.inspect=function(){return"<Address: "+this.toString()+", type: "+this.type+", network: "+this.network+">"};re.prototype.toString=function(){return Dx.encode(this.toBuffer())};Fx.exports=re;function Va(){return Kr()}});var io=P((i7,Vx)=>{"use strict";p();var Bc=Ge(),x4=no(),Hx=qd(),vi=wr(),jx=lr(),mn=va(),kp=si(),I4=Or(),A4=na(),Kx=Ce(),Mp="[REDACTED]";function me(e,t){if(!(this instanceof me))return new me(e,t);if(e instanceof me)return e;var r=this._classifyArguments(e,t);if(!r.bn||r.bn.cmp(new vi(0))===0)throw new TypeError("Number can not be equal to zero, undefined, null or false");if(!r.bn.lt(kp.getN()))throw new TypeError("Number must be less than N");if(typeof r.network>"u")throw new TypeError('Must specify the network ("livenet" or "testnet")');return jx.defineImmutable(this,{bn:r.bn,compressed:r.compressed,network:r.network}),Object.defineProperty(this,"publicKey",{configurable:!1,enumerable:!0,get:this.toPublicKey.bind(this)}),this}me.prototype._classifyArguments=function(e,t){var r={compressed:!0,network:t?mn.get(t):mn.defaultNetwork};if(Bc.isUndefined(e)||Bc.isNull(e))r.bn=me._getRandomBN();else if(e instanceof vi)r.bn=e;else if(e instanceof d.Buffer||e instanceof Uint8Array)r=me._transformBuffer(e,t);else if(e.bn&&e.network)r=me._transformObject(e);else if(!t&&mn.get(e))r.bn=me._getRandomBN(),r.network=mn.get(e);else if(typeof e=="string")jx.isHexa(e)?r.bn=new vi(d.Buffer.from(e,"hex")):r=me._transformWIF(e,t);else throw new TypeError("First argument is an unrecognized data type.");return r};me._getRandomBN=function(){var e,t;do{var r=A4.getRandomBuffer(32);t=vi.fromBuffer(r),e=t.lt(kp.getN())}while(!e);return t};me._transformBuffer=function(e,t){var r={};if(e.length===32)return me._transformBNBuffer(e,t);if(r.network=mn.get(e[0],"privatekey"),!r.network)throw new Error("Invalid network");if(t&&r.network!==mn.get(t))throw new TypeError("Private key network mismatch");if(e.length===34&&e[33]===1)r.compressed=!0;else if(e.length===33)r.compressed=!1;else throw new Error("Length of buffer must be 33 (uncompressed) or 34 (compressed)");return r.bn=vi.fromBuffer(e.slice(1,33)),r};me._transformBNBuffer=function(e,t,r){var n={};return n.network=mn.get(t)||mn.defaultNetwork,n.bn=vi.fromBuffer(e),n.compressed=r===void 0?!0:!!r,n};me._transformWIF=function(e,t){return me._transformBuffer(Hx.decode(e),t)};me.fromBuffer=function(e,t,r){return r!==void 0&&e&&e.length===32?new me(me._transformBNBuffer(e,t,r)):new me(e,t)};me.fromHex=function(e,t,r){return me.fromBuffer(d.Buffer.from(e,"hex"),t,r)};me._transformObject=function(e){if(e.bn instanceof vi)return{bn:e.bn,network:mn.get(e.network),compressed:e.compressed};if(typeof e.bn!="string"||!e.bn.length)throw new TypeError("Invalid private key: `bn` must be a hex string");if(e.bn===Mp)throw new TypeError('Invalid private key: `bn` is "'+Mp+'". JSON.stringify() redacts the secret on purpose \u2014 use toObject() for a round-trippable export, or toWIF().');if(!/^[0-9a-fA-F]+$/.test(e.bn))throw new TypeError("Invalid private key: `bn` is not hexadecimal");var t=new vi(e.bn,"hex");if(t.isZero()||t.gte(kp.getN()))throw new TypeError("Invalid private key: outside the range of valid keys");var r=mn.get(e.network);return{bn:t,network:r,compressed:e.compressed}};me.fromString=me.fromWIF=function(e,t){return Kx.checkArgument(Bc.isString(e),"First argument is expected to be a string."),new me(e,t)};me.fromObject=me.fromJSON=function(e){return Kx.checkArgument(Bc.isObject(e),"First argument is expected to be an object."),new me(e)};me.fromRandom=function(e){var t=me._getRandomBN();return new me(t,e)};me.getValidationError=function(e,t){var r;try{new me(e,t)}catch(n){r=n}return r};me.isValid=function(e,t){return e?!me.getValidationError(e,t):!1};me.prototype.toString=function(){return this.toWIF()};me.prototype.toWIF=function(){var e=this.network,t=this.compressed,r;return t?r=d.Buffer.concat([d.Buffer.from([e.privatekey]),this.bn.toBuffer({size:32}),d.Buffer.from([1])]):r=d.Buffer.concat([d.Buffer.from([e.privatekey]),this.bn.toBuffer({size:32})]),Hx.encode(r)};me.prototype.toBigNumber=function(){return this.bn};me.prototype.toBuffer=function(){return this.bn.toBuffer({size:32})};me.prototype.toHex=function(){return this.toBuffer().toString("hex")};me.prototype.toPublicKey=function(){return this._pubkey||(this._pubkey=I4.fromPrivateKey(this)),this._pubkey};me.prototype.toAddress=function(e){var t=this.toPublicKey();return x4.fromPublicKey(t,e||this.network)};me.prototype.toObject=function(){return{bn:this.bn.toString("hex"),compressed:this.compressed,network:this.network.toString()}};me.prototype.toJSON=function(){return{bn:Mp,compressed:this.compressed,network:this.network.toString()}};me.prototype.inspect=function(){var e=this.compressed?"":", uncompressed";return"<PrivateKey: "+this.toHex()+", network: "+this.network+e+">"};Vx.exports=me});var Or=P((s7,zx)=>{"use strict";p();var ps=wr(),gs=si(),O4=Zt(),R4=lr(),Gx=va(),Cp=Ge(),ao=Ce();function he(e,t){if(!(this instanceof he))return new he(e,t);if(ao.checkArgument(e,"First argument is required, please include public key data."),e instanceof he)return e;t=t||{};var r=this._classifyArgs(e,t);return r.point.validate(),R4.defineImmutable(this,{point:r.point,compressed:r.compressed,network:r.network||Gx.defaultNetwork}),this}he.prototype._classifyArgs=function(e,t){var r={compressed:Cp.isUndefined(t.compressed)||t.compressed};if(e instanceof gs)r.point=e;else if(e.x&&e.y)r=he._transformObject(e);else if(typeof e=="string")r=he._transformDER(d.Buffer.from(e,"hex"));else if(he._isBuffer(e))r=he._transformDER(e);else if(he._isPrivateKey(e))r=he._transformPrivateKey(e);else throw new TypeError("First argument is an unrecognized data format.");return r.network||(r.network=Cp.isUndefined(t.network)?void 0:Gx.get(t.network)),r};he._isPrivateKey=function(e){var t=io();return e instanceof t};he._isBuffer=function(e){return e instanceof d.Buffer||e instanceof Uint8Array};he._transformPrivateKey=function(e){ao.checkArgument(he._isPrivateKey(e),"Must be an instance of PrivateKey");var t={};return t.point=gs.getG().mul(e.bn),t.compressed=e.compressed,t.network=e.network,t};he._transformDER=function(e,t){ao.checkArgument(he._isBuffer(e),"Must be a buffer of DER encoded public key");var r={};t=Cp.isUndefined(t)?!0:t;var n,i,o,s;if(e[0]===4||!t&&(e[0]===6||e[0]===7)){if(o=e.slice(1,33),s=e.slice(33,65),o.length!==32||s.length!==32||e.length!==65)throw new TypeError("Length of x and y must be 32 bytes");n=new ps(o),i=new ps(s),r.point=new gs(n,i),r.compressed=!1}else if(e[0]===3)o=e.slice(1),n=new ps(o),r=he._transformX(!0,n),r.compressed=!0;else if(e[0]===2)o=e.slice(1),n=new ps(o),r=he._transformX(!1,n),r.compressed=!0;else throw new TypeError("Invalid DER format public key");return r};he._transformX=function(e,t){ao.checkArgument(typeof e=="boolean","Must specify whether y is odd or not (true or false)");var r={};return r.point=gs.fromX(e,t),r};he._transformObject=function(e){var t=new ps(e.x,"hex"),r=new ps(e.y,"hex"),n=new gs(t,r);return new he(n,{compressed:e.compressed})};he.fromPrivateKey=function(e){ao.checkArgument(he._isPrivateKey(e),"Must be an instance of PrivateKey");var t=he._transformPrivateKey(e);return new he(t.point,{compressed:t.compressed,network:t.network})};he.fromDER=he.fromBuffer=function(e,t){ao.checkArgument(he._isBuffer(e),"Must be a buffer of DER encoded public key");var r=he._transformDER(e,t);return new he(r.point,{compressed:r.compressed})};he.fromPoint=function(e,t){return ao.checkArgument(e instanceof gs,"First argument must be an instance of Point."),new he(e,{compressed:t})};he.fromHex=he.fromString=function(e,t){var r=d.Buffer.from(e,t||"hex"),n=he._transformDER(r);return new he(n.point,{compressed:n.compressed})};he.fromX=function(e,t){var r=he._transformX(e,t);return new he(r.point,{compressed:r.compressed})};he.getValidationError=function(e){var t;try{new he(e)}catch(r){t=r}return t};he.isValid=function(e){return!he.getValidationError(e)};he.prototype.toObject=he.prototype.toJSON=function(){return{x:this.point.getX().toString("hex",2),y:this.point.getY().toString("hex",2),compressed:this.compressed}};he.prototype.toBuffer=he.prototype.toDER=function(){var e=this.point.getX(),t=this.point.getY(),r=e.toBuffer({size:32}),n=t.toBuffer({size:32}),i;if(this.compressed){var o=n[n.length-1]%2;return o?i=d.Buffer.from([3]):i=d.Buffer.from([2]),d.Buffer.concat([i,r])}else return i=d.Buffer.from([4]),d.Buffer.concat([i,r,n])};he.prototype._getID=function(){return O4.sha256ripemd160(this.toBuffer())};he.prototype.toAddress=function(e){var t=no();return t.fromPublicKey(this,e||this.network)};he.prototype.toString=he.prototype.toHex=function(){return this.toDER().toString("hex")};he.prototype.inspect=function(){return"<PublicKey: "+this.toHex()+(this.compressed?"":", uncompressed")+">"};zx.exports=he});var Ga=P((u7,Yx)=>{"use strict";p();var Wx=na();function T4(){var e=Wx.getRandomBuffer(16);e[6]=e[6]&15|64,e[8]=e[8]&63|128;var t=e.toString("hex");return[t.substring(0,8),t.substring(8,12),t.substring(12,16),t.substring(16,20),t.substring(20,32)].join("-")}function P4(e){return Wx.getRandomBuffer(Math.ceil(e/2)).toString("hex").substring(0,e)}Yx.exports={uuid4:T4,randomHex:P4}});var Qx=P((h7,Jx)=>{"use strict";p();var za=Or(),Lp=Zt(),Dp=La(),$x=er(),Up=io(),Tt=Ce(),c7=Ge(),B4=Ga();function Zx(e,t){if(t=t||{},t.issuerPublicKey)return t.issuerPublicKey instanceof za?t.issuerPublicKey:za.fromString(t.issuerPublicKey);var r=e&&e.issuer;if(typeof r!="string")return null;try{var n=r.split("#")[0].split(":")[2];return n?za.fromString(n):null}catch{return null}}var ys={PROPERTY_TITLE:"PropertyTitle",VEHICLE_TITLE:"VehicleTitle",INTELLECTUAL_PROPERTY:"IntellectualProperty",MUSIC_LICENSE:"MusicLicense",SOFTWARE_LICENSE:"SoftwareLicense",FINANCIAL_INSTRUMENT:"FinancialInstrument",PROMISSORY_NOTE:"PromissoryNote",BOND:"Bond",EQUITY_SHARE:"EquityShare",PROFESSIONAL_LICENSE:"ProfessionalLicense",REGULATORY_PERMIT:"RegulatoryPermit",ACCESS_RIGHT:"AccessRight",VOTING_RIGHT:"VotingRight",ROYALTY_RIGHT:"RoyaltyRight",USAGE_RIGHT:"UsageRight"},Xx={create:function(e,t,r,n,i,o){o=o||{},Tt.checkArgument(typeof e=="string","Right type must be string"),Tt.checkArgument(typeof t=="string","Issuer DID must be string"),Tt.checkArgument(typeof r=="string","Subject DID must be string"),Tt.checkArgument(n&&typeof n=="object","Claim must be object");var s=Object.values(ys);Tt.checkArgument(s.includes(e),"Invalid right type: "+e);var a={"@context":["https://www.w3.org/2018/credentials/v1","https://smartledger.technology/contexts/ltp/v1"],id:"urn:uuid:"+this._generateUUID(),type:["VerifiableCredential","LegalRightToken",e],issuer:t,issuanceDate:new Date().toISOString(),credentialSubject:{id:r,rightType:e,claim:n,jurisdiction:o.jurisdiction||"US",purpose:o.purpose||"legal_right",validFrom:o.validFrom||new Date().toISOString(),validUntil:o.validUntil||null,transferable:o.transferable!==!1,revocable:o.revocable!==!1}};return o.metadata&&(a.credentialSubject.metadata=o.metadata),a},prepareRightToken:function(e,t,r,n,i,o){o=o||{},Tt.checkArgument(typeof e=="string","Right type must be string"),Tt.checkArgument(typeof t=="string","Issuer DID must be string"),Tt.checkArgument(typeof r=="string","Subject DID must be string"),Tt.checkArgument(n&&typeof n=="object","Claim must be object"),Tt.checkArgument(i instanceof Up,"Invalid issuer private key");var s=Object.values(ys);Tt.checkArgument(s.includes(e),"Invalid right type: "+e);try{var a=this.create(e,t,r,n,i,o),c=this._signToken(a,i);return{success:!0,rightToken:c,tokenHash:c.tokenHash,metadata:{type:e,issuer:t,subject:r,transferable:a.credentialSubject.transferable,revocable:a.credentialSubject.revocable,jurisdiction:a.credentialSubject.jurisdiction},externalOperations:{storeToken:{endpoint:"POST /rights/tokens",data:{token:c,metadata:{type:e,issuer:t,subject:r,transferable:a.credentialSubject.transferable,revocable:a.credentialSubject.revocable,jurisdiction:a.credentialSubject.jurisdiction}}},indexToken:{endpoint:"POST /rights/index",data:{tokenId:c.id,tokenHash:c.tokenHash,type:e,issuer:t,subject:r,issuedAt:c.issuanceDate}},notifyParties:{endpoint:"POST /notifications/right-issued",data:{tokenId:c.id,issuer:t,subject:r,rightType:e}}}}}catch(l){return{success:!1,error:l.message}}},prepareRightTokenVerification:function(e,t){t=t||{};try{var r=[],n=[];this._validateTokenStructure(e,r),this._verifyTokenSignature(e,r,t),this._validateTokenTemporal(e,r,n),this._validateRightType(e,r),t.requireJurisdiction&&this._validateJurisdiction(e,t.allowedJurisdictions,r);var i={valid:r.length===0,errors:r,warnings:n,issuerDID:e.issuer,subjectDID:e.credentialSubject?e.credentialSubject.id:null,rightType:e.credentialSubject?e.credentialSubject.rightType:null,transferable:e.credentialSubject?e.credentialSubject.transferable:null,revocable:e.credentialSubject?e.credentialSubject.revocable:null,verifiedAt:new Date().toISOString()};return{success:!0,verification:i,externalOperations:{recordVerification:{endpoint:"POST /rights/verification-record",data:{tokenId:e.id,result:i.valid,errors:r,warnings:n,verifiedAt:i.verifiedAt}},auditVerification:{endpoint:"POST /audit/right-verification",data:{tokenId:e.id,rightType:i.rightType,issuer:i.issuerDID,subject:i.subjectDID,result:i.valid,verifiedAt:i.verifiedAt}},updateTokenStatus:i.valid?{endpoint:"PUT /rights/tokens/"+e.id+"/status",data:{status:"VERIFIED",verifiedAt:i.verifiedAt}}:null}}}catch(o){return{success:!1,error:"Verification preparation failed: "+o.message}}},prepareRightTokenTransfer:function(e,t,r,n){n=n||{},Tt.checkArgument(e&&typeof e=="object","Invalid token"),Tt.checkArgument(typeof t=="string","New owner DID must be string"),Tt.checkArgument(r instanceof Up,"Invalid current owner key");try{var i=this.prepareRightTokenVerification(e,{});if(!i.success||!i.verification.valid)return{success:!1,error:"Cannot transfer invalid token: "+i.verification.errors.join(", ")};if(!e.credentialSubject.transferable)return{success:!1,error:"Token is not transferable"};var o=e.credentialSubject&&e.credentialSubject.id,s=Zx({issuer:o},{issuerPublicKey:n.currentOwnerPublicKey});if(!s)return{success:!1,error:"Cannot resolve current owner public key from token.credentialSubject.id; pass options.currentOwnerPublicKey"};if(r.toPublicKey().toString()!==s.toString())return{success:!1,error:"Unauthorized transfer: signing key does not match the current owner"};var a={"@context":["https://www.w3.org/2018/credentials/v1","https://smartledger.technology/contexts/ltp/v1"],id:"urn:uuid:"+this._generateUUID(),type:["VerifiableCredential","LegalRightTransfer"],issuer:e.credentialSubject.id,issuanceDate:new Date().toISOString(),credentialSubject:{id:t,originalToken:e.id,transferFrom:e.credentialSubject.id,transferTo:t,transferDate:new Date().toISOString(),transferReason:n.reason||"ownership_transfer",consideration:n.consideration||null}},c=this._signToken(a,r),l=JSON.parse(JSON.stringify(e));l.id="urn:uuid:"+this._generateUUID(),l.issuanceDate=new Date().toISOString(),l.credentialSubject.id=t,l.credentialSubject.transferHistory=l.credentialSubject.transferHistory||[],l.credentialSubject.transferHistory.push({transferId:c.id,transferDate:c.issuanceDate,from:e.credentialSubject.id,to:t}),delete l.proof;var g=this._signToken(l,r);return{success:!0,newToken:g,transferProof:c,transferId:c.id,externalOperations:{recordTransfer:{endpoint:"POST /rights/transfers",data:{originalTokenId:e.id,newTokenId:g.id,transferProof:c,fromOwner:e.credentialSubject.id,toOwner:t,transferDate:c.issuanceDate}},updateOwnership:{endpoint:"PUT /rights/tokens/"+e.id+"/ownership",data:{newOwner:t,transferId:c.id,transferDate:c.issuanceDate,previousOwner:e.credentialSubject.id}},notifyParties:{endpoint:"POST /notifications/right-transferred",data:{originalTokenId:e.id,newTokenId:g.id,fromOwner:e.credentialSubject.id,toOwner:t,rightType:e.credentialSubject.rightType}},auditTransfer:{endpoint:"POST /audit/right-transfer",data:{originalTokenId:e.id,newTokenId:g.id,transferId:c.id,fromOwner:e.credentialSubject.id,toOwner:t,transferredAt:c.issuanceDate}}}}}catch(m){return{success:!1,error:m.message}}},prepareObligationToken:function(e,t,r,n){Tt.checkArgument(e&&typeof e=="object","Invalid right token"),Tt.checkArgument(typeof t=="string","Obligor DID must be string"),Tt.checkArgument(r&&typeof r=="object","Obligation must be object"),Tt.checkArgument(n instanceof Up,"Invalid issuer key");try{var i={"@context":["https://www.w3.org/2018/credentials/v1","https://smartledger.technology/contexts/ltp/v1"],id:"urn:uuid:"+this._generateUUID(),type:["VerifiableCredential","LegalObligationToken"],issuer:e.issuer,issuanceDate:new Date().toISOString(),credentialSubject:{id:t,obligationType:"correlative_obligation",correlativeRight:e.id,rightHolder:e.credentialSubject.id,obligation:r,jurisdiction:e.credentialSubject.jurisdiction,purpose:e.credentialSubject.purpose}},o=this._signToken(i,n);return{success:!0,obligationToken:o,correlativeRight:e.id,externalOperations:{storeObligation:{endpoint:"POST /obligations/tokens",data:{obligationToken:o,correlativeRightId:e.id,obligor:t,rightHolder:e.credentialSubject.id}},linkToRight:{endpoint:"POST /rights/tokens/"+e.id+"/obligations",data:{obligationId:o.id,obligor:t,obligationType:"correlative_obligation"}},notifyObligor:{endpoint:"POST /notifications/obligation-created",data:{obligationId:o.id,obligor:t,rightHolder:e.credentialSubject.id,correlativeRight:e.id}}}}}catch(s){return{success:!1,error:s.message}}},prepareRightTypeValidation:function(e){Tt.checkArgument(typeof e=="string","Right type must be string");var t=Object.values(ys),r=t.includes(e);return{success:!0,validation:{type:e,valid:r,availableTypes:t,category:this._categorizeRightType(e),description:this._getRightTypeDescription(e)},externalOperations:{validateType:{endpoint:"POST /rights/validate-type",data:{type:e,valid:r}}}}},_categorizeRightType:function(e){var t={PropertyTitle:"PROPERTY_RIGHT",VehicleTitle:"PROPERTY_RIGHT",IntellectualProperty:"IP_RIGHT",MusicLicense:"IP_RIGHT",SoftwareLicense:"IP_RIGHT",FinancialInstrument:"FINANCIAL_RIGHT",PromissoryNote:"FINANCIAL_RIGHT",Bond:"FINANCIAL_RIGHT",EquityShare:"FINANCIAL_RIGHT",ProfessionalLicense:"LICENSE_RIGHT",RegulatoryPermit:"LICENSE_RIGHT",AccessRight:"ACCESS_RIGHT",VotingRight:"GOVERNANCE_RIGHT",RoyaltyRight:"IP_RIGHT",UsageRight:"ACCESS_RIGHT"};return t[e]||"UNKNOWN"},_getRightTypeDescription:function(e){var t={PropertyTitle:"Legal ownership of real estate property",VehicleTitle:"Legal ownership of motor vehicle",IntellectualProperty:"Rights to intellectual property assets",MusicLicense:"License for music performance and usage",SoftwareLicense:"License for software usage and distribution",FinancialInstrument:"Rights related to financial instruments",PromissoryNote:"Promise to pay a specified amount",Bond:"Debt security representing loan",EquityShare:"Ownership stake in company",ProfessionalLicense:"License for professional practice",RegulatoryPermit:"Permit for regulated activities",AccessRight:"Right to access resources or locations",VotingRight:"Right to participate in governance",RoyaltyRight:"Right to receive royalty payments",UsageRight:"Right to use specific assets or services"};return t[e]||"Unknown right type"},getRightTypes:function(){return ys},verifyToken:function(e,t){var r=[];try{if(Tt.checkArgument(e&&typeof e=="object","Invalid token"),!e.proof||!e.proof.jws)return r.push("Missing signature proof"),{valid:!1,errors:r};var n=t instanceof za?t:za.fromString(t),i=this._canonicalizeToken(e),o=Lp.sha256(d.Buffer.from(i));if(e.tokenHash&&e.tokenHash!==o.toString("hex"))return r.push("Token hash mismatch"),{valid:!1,errors:r};var s=e.proof.jws.split(".");if(s.length!==3||!s[2])return r.push("Malformed JWS"),{valid:!1,errors:r};var a=$x.fromDER(d.Buffer.from(s[2],"base64url")),c=new Dp;return c.hashbuf=o,c.sig=a,c.pubkey=n,c.verify()||r.push("Signature verification failed"),{valid:r.length===0,errors:r,tokenHash:o.toString("hex"),verifiedAt:new Date().toISOString()}}catch(l){return r.push(l.message),{valid:!1,errors:r}}},_signToken:function(e,t){var r=this._canonicalizeToken(e),n=Lp.sha256(d.Buffer.from(r)),i=new Dp;i.hashbuf=n,i.privkey=t,i.pubkey=t.toPublicKey(),i.sign();var o=i.sig,s={type:"EcdsaSecp256k1Signature2019",created:new Date().toISOString(),verificationMethod:"did:smartledger:"+t.toPublicKey().toString()+"#keys-1",proofPurpose:"assertionMethod",jws:this._createJWS(n,o)},a=JSON.parse(JSON.stringify(e));return a.proof=s,a.tokenHash=n.toString("hex"),a},_createJWS:function(e,t){var r={alg:"ES256K",typ:"JWT"},n=d.Buffer.from(JSON.stringify(r)).toString("base64url"),i=t.toDER().toString("base64url");return n+".."+i},_canonicalizeToken:function(e){var t=JSON.parse(JSON.stringify(e));return delete t.proof,delete t.tokenHash,JSON.stringify(this._sortObjectKeys(t))},_sortObjectKeys:function(e){if(Array.isArray(e))return e.map(this._sortObjectKeys.bind(this));if(e!==null&&typeof e=="object"){var t={};return Object.keys(e).sort().forEach(function(r){t[r]=this._sortObjectKeys(e[r])}.bind(this)),t}return e},_validateTokenStructure:function(e,t){e["@context"]||t.push("Missing @context"),e.id||t.push("Missing id"),(!e.type||!Array.isArray(e.type))&&t.push("Missing or invalid type"),e.issuer||t.push("Missing issuer"),e.issuanceDate||t.push("Missing issuanceDate"),e.credentialSubject||t.push("Missing credentialSubject"),e.proof||t.push("Missing proof")},_verifyTokenSignature:function(e,t,r){try{if(!e.proof||!e.proof.jws){t.push("Missing signature proof");return}var n=this._canonicalizeToken(e),i=Lp.sha256(d.Buffer.from(n));if(e.tokenHash&&e.tokenHash!==i.toString("hex")){t.push("Token hash mismatch");return}var o=Zx(e,r);if(!o){t.push("Signature not verified: issuer public key could not be resolved from token.issuer; pass options.issuerPublicKey");return}var s=e.proof.jws.split(".");if(s.length!==3||!s[2]){t.push("Malformed JWS");return}var a=$x.fromDER(d.Buffer.from(s[2],"base64url")),c=new Dp;c.hashbuf=i,c.sig=a,c.pubkey=o,c.verify()!==!0&&t.push("Signature verification failed")}catch(l){t.push("Signature verification failed: "+l.message)}},_validateTokenTemporal:function(e,t,r){var n=new Date,i=new Date(e.issuanceDate);if(i>n&&t.push("Token issued in the future"),e.credentialSubject.validFrom){var o=new Date(e.credentialSubject.validFrom);n<o&&r.push("Token not yet valid")}if(e.credentialSubject.validUntil){var s=new Date(e.credentialSubject.validUntil);n>s&&t.push("Token expired")}},_validateRightType:function(e,t){if(!e.credentialSubject.rightType){t.push("Missing rightType");return}var r=Object.values(ys);r.includes(e.credentialSubject.rightType)||t.push("Invalid right type: "+e.credentialSubject.rightType)},_validateJurisdiction:function(e,t,r){if(!e.credentialSubject.jurisdiction){r.push("Missing jurisdiction");return}t&&Array.isArray(t)&&(t.includes(e.credentialSubject.jurisdiction)||r.push("Jurisdiction not allowed: "+e.credentialSubject.jurisdiction))},_generateUUID:function(){return B4.uuid4()}};Xx.RightTypes=ys;Jx.exports=Xx});var tI=P((d7,eI)=>{"use strict";p();var Wa=Zt(),pr=Ce(),N4=Ga(),uo={PropertyTitle:{title:"Property Title",description:"Real estate property ownership title",type:"object",required:["propertyId","address","ownershipType"],properties:{propertyId:{type:"string",description:"Unique property identifier"},address:{type:"object",required:["street","city","state","country"],properties:{street:{type:"string"},city:{type:"string"},state:{type:"string"},country:{type:"string"},postalCode:{type:"string"}}},ownershipType:{type:"string",enum:["fee_simple","leasehold","joint_tenancy","tenancy_in_common"]},titleNumber:{type:"string"},registeredDate:{type:"string",format:"date-time"},legalDescription:{type:"string"},encumbrances:{type:"array",items:{type:"object",properties:{type:{type:"string"},amount:{type:"number"},description:{type:"string"}}}}}},VehicleTitle:{title:"Vehicle Title",description:"Motor vehicle ownership title",type:"object",required:["vin","make","model","year"],properties:{vin:{type:"string",pattern:"^[A-HJ-NPR-Z0-9]{17}$",description:"Vehicle Identification Number"},make:{type:"string"},model:{type:"string"},year:{type:"integer",minimum:1900,maximum:2030},titleNumber:{type:"string"},registeredState:{type:"string"},mileage:{type:"integer",minimum:0},color:{type:"string"},fuelType:{type:"string",enum:["gasoline","diesel","electric","hybrid","other"]},liens:{type:"array",items:{type:"object",properties:{lienholderName:{type:"string"},lienAmount:{type:"number"},lienDate:{type:"string",format:"date"}}}}}},PromissoryNote:{title:"Promissory Note",description:"Legal promise to pay a specified amount",type:"object",required:["principal","interestRate","maturityDate","borrower","lender"],properties:{principalAmount:{type:"number",minimum:0,description:"Principal amount in base currency units"},currency:{type:"string",default:"USD"},interestRate:{type:"number",minimum:0,maximum:100,description:"Annual interest rate percentage"},maturityDate:{type:"string",format:"date",description:"Date when principal and interest are due"},payee:{type:"string",description:"DID of the payee (creditor)"},payor:{type:"string",description:"DID of the payor (debtor)"},paymentSchedule:{type:"string",enum:["lump_sum","monthly","quarterly","annually"]},collateral:{type:"array",items:{type:"object",properties:{description:{type:"string"},value:{type:"number"},type:{type:"string"}}}},defaultProvisions:{type:"string"},governingLaw:{type:"string"}}},IntellectualProperty:{title:"Intellectual Property",description:"Intellectual property rights and licensing",type:"object",required:["ipType","title","registrationNumber"],properties:{ipType:{type:"string",enum:["patent","trademark","copyright","trade_secret"]},title:{type:"string"},creator:{type:"string",description:"Creator DID"},registrationNumber:{type:"string"},registrationDate:{type:"string",format:"date"},expirationDate:{type:"string",format:"date"},jurisdiction:{type:"string"},description:{type:"string"},claims:{type:"array",items:{type:"string"}},priorArt:{type:"array",items:{type:"object",properties:{reference:{type:"string"},date:{type:"string",format:"date"},relevance:{type:"string"}}}}}},ProfessionalLicense:{title:"Professional License",description:"Professional practice license or certification",type:"object",required:["licenseType","licenseNumber","issuingAuthority","expirationDate"],properties:{licenseType:{type:"string"},licenseNumber:{type:"string"},issuingAuthority:{type:"string"},licensee:{type:"string",description:"Licensee DID"},issueDate:{type:"string",format:"date"},expirationDate:{type:"string",format:"date"},renewalDate:{type:"string",format:"date"},jurisdiction:{type:"string"},scope:{type:"string"},restrictions:{type:"array",items:{type:"string"}},continuing_education:{type:"object",properties:{hours_required:{type:"integer"},deadline:{type:"string",format:"date"},completed_hours:{type:"integer"}}}}},MusicLicense:{title:"Music License",description:"Music performance and usage licensing",type:"object",required:["songTitle","artist","licenseType","royaltyRate"],properties:{workTitle:{type:"string"},composer:{type:"string",description:"Composer DID"},performer:{type:"string",description:"Performer DID"},licenseType:{type:"string",enum:["mechanical","performance","synchronization","master_use"]},territory:{type:"string"},duration:{type:"string"},royaltyRate:{type:"number",minimum:0,maximum:100},advancePayment:{type:"number",minimum:0},exclusivity:{type:"boolean"},mediaTypes:{type:"array",items:{type:"string",enum:["cd","vinyl","digital","streaming","broadcast","film","tv"]}},usage_restrictions:{type:"string"},copyrightNotice:{type:"string"}}}},M4={prepareClaimValidation:function(e,t){try{pr.checkArgument(e&&typeof e=="object","Invalid claim"),pr.checkArgument(typeof t=="string","Schema name must be string");var r=uo[t];if(!r)return{success:!1,error:"Unknown schema: "+t};var n=[],i=[];this._validateObject(e,r,"",n,i);var o={valid:n.length===0,errors:n,warnings:i,schema:t,claimHash:this.hash(e),canonical:this.canonicalize(e)};return{success:!0,validation:o,claim:e,schema:r,externalOperations:{store:{endpoint:"POST /claims/validate",data:{claim:e,validation:o,schema:t}},index:{endpoint:"POST /claims/index",data:{claimHash:o.claimHash,schemaName:t,valid:o.valid}}}}}catch(s){return{success:!1,error:"Validation preparation failed: "+s.message}}},prepareClaimAttestation:function(e,t,r){try{pr.checkArgument(e&&typeof e=="object","Invalid claim"),pr.checkArgument(typeof t=="string","Schema name must be string"),pr.checkArgument(r&&typeof r=="object","Invalid attestor");var n=this.prepareClaimValidation(e,t);if(!n.success||!n.validation.valid)return{success:!1,error:"Cannot attest invalid claim",validation:n};var i={type:"LTP_CLAIM_ATTESTATION",claimHash:n.validation.claimHash,schemaName:t,attestor:{did:r.did||r.id,name:r.name||"Unknown",authority:r.authority||null,jurisdiction:r.jurisdiction||null},attestedAt:new Date().toISOString(),confidence:r.confidence||100,evidence:r.evidence||null,notes:r.notes||null},o=Wa.sha256(d.Buffer.from(this.canonicalize(i))).toString("hex");return i.attestationHash=o,{success:!0,attestation:i,claim:e,validation:n.validation,externalOperations:{storeAttestation:{endpoint:"POST /claims/"+n.validation.claimHash+"/attestations",data:i},notifyStakeholders:{endpoint:"POST /notifications/claim-attested",data:{claimHash:n.validation.claimHash,attestorDid:i.attestor.did,attestationHash:o}}}}}catch(s){return{success:!1,error:"Attestation preparation failed: "+s.message}}},prepareClaimDispute:function(e,t,r){try{pr.checkArgument(typeof e=="string","Claim hash must be string"),pr.checkArgument(t&&typeof t=="object","Invalid disputant"),pr.checkArgument(r&&typeof r=="object","Invalid dispute");var n={type:"LTP_CLAIM_DISPUTE",claimHash:e,disputant:{did:t.did||t.id,name:t.name||"Unknown",jurisdiction:t.jurisdiction||null},dispute:{reason:r.reason||"UNSPECIFIED",category:r.category||"ACCURACY",description:r.description||"",evidence:r.evidence||null,requestedAction:r.requestedAction||"REVIEW"},disputedAt:new Date().toISOString(),status:"FILED",priority:r.priority||"NORMAL"},i=Wa.sha256(d.Buffer.from(this.canonicalize(n))).toString("hex");return n.disputeHash=i,{success:!0,dispute:n,disputeId:this._generateDisputeId(e),externalOperations:{fileDispute:{endpoint:"POST /claims/"+e+"/disputes",data:n},notifyStakeholders:{endpoint:"POST /notifications/claim-disputed",data:{claimHash:e,disputantDid:n.disputant.did,disputeHash:i}},escalate:{endpoint:"POST /disputes/escalate",data:{disputeHash:i,priority:n.priority}}}}}catch(o){return{success:!1,error:"Dispute preparation failed: "+o.message}}},prepareBulkClaimValidation:function(e,t){try{pr.checkArgument(Array.isArray(e),"Claims must be array"),pr.checkArgument(typeof t=="string","Schema name must be string");var r=[],n=[],i=0;e.forEach(function(a,c){try{var l=this.prepareClaimValidation(a,t);l.success&&l.validation.valid&&i++,r.push({index:c,result:l})}catch(g){n.push({index:c,error:g.message})}}.bind(this));var o=this._generateBatchId(),s=Wa.sha256(d.Buffer.from(JSON.stringify(r.map(a=>a.result.validation.claimHash)))).toString("hex");return{success:!0,batchId:o,batchHash:s,totalClaims:e.length,validClaims:i,invalidClaims:e.length-i,validations:r,errors:n,externalOperations:{storeBatch:{endpoint:"POST /claims/batch-validate",data:{batchId:o,batchHash:s,schemaName:t,validations:r}},generateReport:{endpoint:"POST /reports/bulk-validation",data:{batchId:o,summary:{total:e.length,valid:i,invalid:e.length-i}}}}}}catch(a){return{success:!1,error:"Bulk validation preparation failed: "+a.message}}},canonicalize:function(e){pr.checkArgument(e&&typeof e=="object","Invalid claim");var t=this._sortObjectKeys(e);return JSON.stringify(t)},hash:function(e){var t=this.canonicalize(e);return Wa.sha256(d.Buffer.from(t)).toString("hex")},prepareClaimTemplate:function(e,t){t=t||{};try{var r=uo[e];if(!r)return{success:!1,error:"Unknown schema: "+e};var n=this._createTemplateFromSchema(r),i=this._generateFormStructure(r);return{success:!0,schemaName:e,template:n,schema:r,formStructure:i,validation:{required:r.required||[],patterns:this._extractPatterns(r),enums:this._extractEnums(r)},externalOperations:{generateForm:{endpoint:"POST /forms/generate",data:{schemaName:e,formStructure:i,template:n}},saveTemplate:{endpoint:"POST /templates/claim",data:{schemaName:e,template:n,customizations:t.customizations||{}}}}}}catch(o){return{success:!1,error:"Template preparation failed: "+o.message}}},getSchemas:function(){return uo},getSchemaNames:function(){return Object.keys(uo)},getSchema:function(e){return uo[e]||null},addSchema:function(e,t){pr.checkArgument(typeof e=="string","Schema name must be string"),pr.checkArgument(t&&typeof t=="object","Invalid schema"),uo[e]=t},createTemplate:function(e){var t=uo[e];if(!t)throw new Error("Unknown schema: "+e);return this._createTemplateFromSchema(t)},_generateDisputeId:function(e){var t="dispute_"+e+"_"+Date.now();return Wa.sha256(d.Buffer.from(t)).toString("hex").substring(0,16)},_generateBatchId:function(){return N4.randomHex(16)},_generateFormStructure:function(e){var t={type:"form",title:e.title||"Legal Claim Form",description:e.description||"",fields:[]};return e.properties&&Object.keys(e.properties).forEach(function(r){var n=e.properties[r],i={name:r,label:this._humanizeFieldName(r),type:this._mapSchemaTypeToFormType(n),required:e.required&&e.required.includes(r),validation:this._extractFieldValidation(n)};n.enum&&(i.options=n.enum.map(function(o){return{value:o,label:this._humanizeValue(o)}}.bind(this))),t.fields.push(i)}.bind(this)),t},_extractPatterns:function(e){var t={};return e.properties&&Object.keys(e.properties).forEach(function(r){var n=e.properties[r];n.pattern&&(t[r]=n.pattern)}),t},_extractEnums:function(e){var t={};return e.properties&&Object.keys(e.properties).forEach(function(r){var n=e.properties[r];n.enum&&(t[r]=n.enum)}),t},_mapSchemaTypeToFormType:function(e){switch(e.type){case"string":return e.enum?"select":e.format==="date"?"date":e.format==="date-time"?"datetime":"text";case"number":case"integer":return"number";case"boolean":return"checkbox";case"array":return"list";case"object":return"fieldset";default:return"text"}},_extractFieldValidation:function(e){var t={};return e.pattern&&(t.pattern=e.pattern),e.minimum!==void 0&&(t.min=e.minimum),e.maximum!==void 0&&(t.max=e.maximum),e.format&&(t.format=e.format),t},_humanizeFieldName:function(e){return e.replace(/([A-Z])/g," $1").replace(/^./,function(t){return t.toUpperCase()}).replace(/_/g," ")},_humanizeValue:function(e){return e.replace(/_/g," ").replace(/\b\w/g,function(t){return t.toUpperCase()})},_validateObject:function(e,t,r,n,i){t.type==="object"?(t.required&&Array.isArray(t.required)&&t.required.forEach(function(o){e.hasOwnProperty(o)||n.push("Missing required field: "+this._getFieldPath(r,o))}.bind(this)),t.properties&&Object.keys(e).forEach(function(o){var s=this._getFieldPath(r,o),a=t.properties[o];a?this._validateValue(e[o],a,s,n,i):i.push("Unknown field: "+s)}.bind(this))):this._validateValue(e,t,r,n,i)},_validateValue:function(e,t,r,n,i){if(t.type){var o=Array.isArray(e)?"array":typeof e;if(o!==t.type){n.push("Invalid type for "+r+": expected "+t.type+", got "+o);return}}if(t.type==="string"&&(t.pattern&&!new RegExp(t.pattern).test(e)&&n.push("Value does not match pattern for "+r),t.enum&&!t.enum.includes(e)&&n.push("Invalid enum value for "+r+": "+e),t.format==="date"&&!this._isValidDate(e)&&n.push("Invalid date format for "+r),t.format==="date-time"&&!this._isValidDateTime(e)&&n.push("Invalid date-time format for "+r)),(t.type==="number"||t.type==="integer")&&(t.minimum!==void 0&&e<t.minimum&&n.push("Value below minimum for "+r+": "+e+" < "+t.minimum),t.maximum!==void 0&&e>t.maximum&&n.push("Value above maximum for "+r+": "+e+" > "+t.maximum),t.type==="integer"&&!Number.isInteger(e)&&n.push("Value must be integer for "+r)),t.type==="array"&&t.items)for(var s=0;s<e.length;s++)this._validateValue(e[s],t.items,r+"["+s+"]",n,i);t.type==="object"&&this._validateObject(e,t,r,n,i)},_sortObjectKeys:function(e){if(Array.isArray(e))return e.map(this._sortObjectKeys.bind(this));if(e!==null&&typeof e=="object"){var t={};return Object.keys(e).sort().forEach(function(r){t[r]=this._sortObjectKeys(e[r])}.bind(this)),t}return e},_createTemplateFromSchema:function(e){if(e.type==="object"){var t={};return e.properties&&Object.keys(e.properties).forEach(function(r){var n=e.properties[r];t[r]=this._getDefaultValue(n)}.bind(this)),t}return this._getDefaultValue(e)},_getDefaultValue:function(e){if(e.default!==void 0)return e.default;switch(e.type){case"string":return e.enum?e.enum[0]:e.format==="date"?"2023-01-01":e.format==="date-time"?new Date().toISOString():"PLACEHOLDER_STRING";case"number":case"integer":return e.minimum||0;case"boolean":return!1;case"array":return[];case"object":return this._createTemplateFromSchema(e);default:return null}},_getFieldPath:function(e,t){return e?e+"."+t:t},_isValidDate:function(e){var t=new Date(e);return!isNaN(t.getTime())&&e.match(/^\d{4}-\d{2}-\d{2}$/)},_isValidDateTime:function(e){var t=new Date(e);return!isNaN(t.getTime())}};eI.exports=M4});var nI=P((g7,rI)=>{"use strict";p();var Ya=Zt(),ms=Ce(),k4={prepareTokenCommitment:function(e,t){t=t||{},ms.checkArgument(e&&typeof e=="object","Invalid token");try{var r=this._createCommitment(e,t),n=this._formatOpReturn(r,t),i=this._createTxTemplate(n,t);return{success:!0,commitment:r,opReturnData:n,txTemplate:i,preparedAt:new Date().toISOString(),metadata:{tokenId:e.id,purpose:t.purpose||"legal_token_anchor",version:"LTP.v1"}}}catch(o){return{success:!1,error:o.message}}},prepareBatchCommitment:function(e,t){t=t||{},ms.checkArgument(Array.isArray(e),"Tokens must be array");try{var r=this._createBatchCommitment(e,t),n=this._formatOpReturn(r,t),i=this._createTxTemplate(n,t);return{success:!0,batchCommitment:r,opReturnData:n,txTemplate:i,tokenCount:e.length,preparedAt:new Date().toISOString(),metadata:{purpose:t.purpose||"legal_token_batch_anchor",version:"LTP.v1"}}}catch(o){return{success:!1,error:o.message}}},verifyTokenAnchor:function(e,t,r){ms.checkArgument(e&&typeof e=="object","Invalid token"),ms.checkArgument(typeof t=="string","Transaction ID must be string");try{var n=this._createCommitment(e,{}),i=this._extractOpReturn(r);if(!i)return{valid:!1,error:"No OP_RETURN data found in transaction"};var o=this._verifyCommitment(n,i);return{valid:o,chainVerified:!1,txid:t,commitment:n,anchorData:i,verifiedAt:new Date().toISOString()}}catch(s){return{valid:!1,error:s.message}}},formatRevocation:function(e,t){ms.checkArgument(typeof e=="string","Token ID must be string"),ms.checkArgument(t&&typeof t=="object","Invalid revocation data");try{var r={type:"LTP_REVOCATION",tokenId:e,reason:t.reason||"UNSPECIFIED",revokedBy:t.revokedBy||"UNKNOWN",revokedAt:new Date().toISOString(),effectiveDate:t.effectiveDate||new Date().toISOString(),legalBasis:t.legalBasis||null,evidence:t.evidence||null},n=Ya.sha256(d.Buffer.from(JSON.stringify(r))).toString("hex");return{success:!0,revocation:r,revocationHash:n,opReturnData:this._formatOpReturn({hash:n,type:"REVOCATION"},{})}}catch(i){return{success:!1,error:i.message}}},_createCommitment:function(e,t){var r=this._canonicalizeToken(e),n={type:"LTP_TOKEN",tokenHash:Ya.sha256(d.Buffer.from(r)).toString("hex"),tokenId:e.id,timestamp:new Date().toISOString(),purpose:t.purpose||"legal_token"},i=Ya.sha256(d.Buffer.from(JSON.stringify(n))).toString("hex");return{hash:i,data:n,canonical:r}},_createBatchCommitment:function(e,t){var r=[],n=[];e.forEach(function(a){var c=this._createCommitment(a,t);r.push(c.hash),n.push(a.id)}.bind(this));var i=this._createMerkleRoot(r),o={type:"LTP_BATCH",merkleRoot:i,tokenCount:e.length,tokenIds:n,timestamp:new Date().toISOString(),purpose:t.purpose||"batch_anchor"},s=Ya.sha256(d.Buffer.from(JSON.stringify(o))).toString("hex");return{hash:s,data:o,merkleRoot:i,tokenHashes:r}},_formatOpReturn:function(e,t){var r=t.prefix||"LTP.v1",n=e.hash;return{prefix:r,data:n,full:r+"."+n,bytes:d.Buffer.from(r+"."+n,"utf8"),size:d.Buffer.from(r+"."+n,"utf8").length}},_createTxTemplate:function(e,t){try{var r={version:1,inputs:[],outputs:[{satoshis:0,script:"OP_RETURN "+e.data}],locktime:0};return t.feeOutput&&r.outputs.push(t.feeOutput),{template:r,opReturn:e,estimatedSize:this._estimateSize(r),instructions:{step1:"Add input UTXOs to cover fees",step2:"Add change output if needed",step3:"Sign transaction with appropriate keys",step4:"Broadcast to BSV network"}}}catch(n){throw new Error("Failed to create transaction template: "+n.message)}},_extractOpReturn:function(e){try{if(!e||!e.outputs)return null;for(var t=0;t<e.outputs.length;t++){var r=e.outputs[t];if(r.script&&r.script.startsWith("OP_RETURN")){var n=r.script.replace("OP_RETURN ","");return{raw:n,decoded:d.Buffer.from(n,"hex").toString("utf8")}}}return null}catch{return null}},_verifyCommitment:function(e,t){try{return!t||!t.decoded?!1:t.decoded.includes(e.hash)}catch{return!1}},_canonicalizeToken:function(e){var t=JSON.parse(JSON.stringify(e));return delete t.proof,delete t.tokenHash,delete t.anchorTx,delete t.anchorBlock,JSON.stringify(this._sortObjectKeys(t))},_createMerkleRoot:function(e){if(e.length===0)return null;if(e.length===1)return e[0];for(var t=e.slice();t.length>1;){for(var r=[],n=0;n<t.length;n+=2){var i=t[n],o=t[n+1]||i,s=d.Buffer.concat([d.Buffer.from(i,"hex"),d.Buffer.from(o,"hex")]),a=Ya.sha256(s).toString("hex");r.push(a)}t=r}return t[0]},_estimateSize:function(e){var t=10,r=e.outputs.length*34,n=148;return{base:t+r,withOneInput:t+r+n,bytesPerInput:n}},_sortObjectKeys:function(e){if(Array.isArray(e))return e.map(this._sortObjectKeys.bind(this));if(e!==null&&typeof e=="object"){var t={};return Object.keys(e).sort().forEach(function(r){t[r]=this._sortObjectKeys(e[r])}.bind(this)),t}return e}};rI.exports=k4});var sI=P((m7,oI)=>{"use strict";p();var C4=Or(),Yr=Zt(),iI=La(),L4=er(),D4=io(),tr=Ce(),U4={prepareSignatureProof:function(e,t,r){r=r||{},tr.checkArgument(e&&typeof e=="object","Invalid token"),tr.checkArgument(t instanceof D4,"Invalid private key");try{var n=this._canonicalizeForSigning(e),i=Yr.sha256(d.Buffer.from(n)),o=new iI;o.hashbuf=i,o.privkey=t,o.pubkey=t.toPublicKey(),o.sign();var s=o.sig,a={type:"EcdsaSecp256k1Signature2019",created:new Date().toISOString(),verificationMethod:"did:smartledger:"+t.toPublicKey().toString()+"#keys-1",proofPurpose:r.purpose||"assertionMethod",jws:this._createJWS(i,s),proofValue:s.toDER().toString("hex")};return{success:!0,proof:a,tokenHash:i.toString("hex"),canonical:n,signingKey:{publicKey:t.toPublicKey().toString(),keyId:"did:smartledger:"+t.toPublicKey().toString()+"#keys-1"},externalOperations:{storeProof:{endpoint:"POST /proofs/signature",data:{tokenHash:i.toString("hex"),proof:a,signingKey:t.toPublicKey().toString()}},verifyProof:{endpoint:"POST /proofs/verify-signature",data:{tokenHash:i.toString("hex"),signature:s.toDER().toString("hex"),publicKey:t.toPublicKey().toString()}}}}}catch(c){return{success:!1,error:c.message}}},prepareSignatureVerification:function(e,t){try{if(tr.checkArgument(e&&typeof e=="object","Invalid token"),tr.checkArgument(typeof t=="string","Public key must be string"),!e.proof)return{success:!1,error:"No proof found in token"};var r=this._canonicalizeForSigning(e),n=Yr.sha256(d.Buffer.from(r)),i=L4.fromDER(d.Buffer.from(e.proof.proofValue,"hex")),o={tokenHash:n.toString("hex"),signature:i.toDER().toString("hex"),publicKey:t,proof:e.proof,canonical:r},s=new iI;s.hashbuf=n,s.sig=i,s.pubkey=C4.fromString(t);var a=s.verify()===!0;return{success:!0,verification:{valid:a,tokenHash:n.toString("hex"),signatureValid:a,publicKey:t,verifiedAt:new Date().toISOString()},verificationData:o,externalOperations:{recordVerification:{endpoint:"POST /proofs/verification-record",data:{tokenHash:n.toString("hex"),result:a,publicKey:t,verifiedAt:new Date().toISOString()}},auditVerification:{endpoint:"POST /audit/proof-verification",data:{tokenId:e.id,proofType:e.proof.type,result:a,verifier:t}}}}}catch(c){return{success:!1,error:c.message}}},prepareSelectiveDisclosure:function(e,t,r){tr.checkArgument(e&&typeof e=="object","Invalid token"),tr.checkArgument(Array.isArray(t),"Revealed fields must be array"),tr.checkArgument(typeof r=="string","Nonce must be string");try{var n=this._createFieldCommitments(e,r),i=this._createMerkleTree(n),o=[],s=[];t.forEach(function(c){var l=this._getNestedValue(e,c),g=this._findFieldCommitment(n,c);if(g){o.push({path:c,value:l,commitment:g.hash,salt:g.salt});var m=this._generateMerkleProof(i,g.index);s.push({path:c,leafIndex:g.index,proof:m})}}.bind(this));var a={type:"LegalTokenSelectiveDisclosure",created:new Date().toISOString(),proofPurpose:"selectiveDisclosure",verificationMethod:e.proof?e.proof.verificationMethod:null,nonce:r,merkleRoot:i.root,disclosures:o,merkleProofs:s,totalFields:n.length};return{success:!0,proof:a,hiddenFieldCount:n.length-o.length,revealedFieldCount:o.length,externalOperations:{storeDisclosure:{endpoint:"POST /proofs/selective-disclosure",data:{tokenId:e.id,proof:a,merkleRoot:i.root}},verifyDisclosure:{endpoint:"POST /proofs/verify-disclosure",data:{proof:a,expectedNonce:r}},auditDisclosure:{endpoint:"POST /audit/selective-disclosure",data:{tokenId:e.id,revealedFields:t,totalFields:n.length,disclosedAt:new Date().toISOString()}}}}}catch(c){return{success:!1,error:c.message}}},prepareSelectiveDisclosureVerification:function(e,t){try{if(tr.checkArgument(e&&typeof e=="object","Invalid proof"),tr.checkArgument(typeof t=="string","Expected nonce must be string"),e.nonce!==t)return{success:!1,error:"Nonce mismatch"};var r=[],n=[];e.disclosures.forEach(function(o,s){var a=e.merkleProofs[s],c=this._hashField(o.path,o.value,o.salt);if(c!==o.commitment){n.push("Invalid commitment for field: "+o.path);return}var l=this._verifyMerkleProof(o.commitment,a.leafIndex,a.proof,e.merkleRoot);l?r.push({path:o.path,value:o.value,verified:!0}):n.push("Invalid Merkle proof for field: "+o.path)}.bind(this));var i={valid:n.length===0,errors:n,disclosures:r,merkleRoot:e.merkleRoot,totalFields:e.totalFields,verifiedAt:new Date().toISOString()};return{success:!0,verification:i,externalOperations:{recordVerification:{endpoint:"POST /proofs/disclosure-verification",data:{proofId:e.id||"unknown",result:i.valid,verifiedFields:r.length,totalFields:e.totalFields,verifiedAt:i.verifiedAt}},auditVerification:{endpoint:"POST /audit/disclosure-verification",data:{merkleRoot:e.merkleRoot,disclosuresVerified:r.length,errors:n.length,result:i.valid}}}}}catch(o){return{success:!1,error:o.message}}},prepareLegalValidityProof:function(e,t,r){tr.checkArgument(e&&typeof e=="object","Invalid token"),tr.checkArgument(t&&typeof t=="object","Invalid jurisdiction"),tr.checkArgument(typeof r=="string","Nonce must be string");try{var n=t.requirements||[],i=[],o=!0;n.forEach(function(a){var c=this._checkLegalRequirement(e,a);i.push(c),c.satisfied||(o=!1)}.bind(this));var s={type:"LegalValidityProof",created:new Date().toISOString(),proofPurpose:"legalValidity",jurisdiction:t.code,nonce:r,valid:o,checks:i,complianceHash:this._hashCompliance(e,t,r)};return{success:!0,proof:s,valid:o,complianceReport:{jurisdiction:t.code,totalRequirements:n.length,satisfiedRequirements:i.filter(a=>a.satisfied).length,failedRequirements:i.filter(a=>!a.satisfied).length,overallCompliance:o},externalOperations:{submitCompliance:{endpoint:"POST /compliance/legal-validity",data:{tokenId:e.id,jurisdiction:t.code,proof:s,complianceReport:{jurisdiction:t.code,totalRequirements:n.length,satisfiedRequirements:i.filter(a=>a.satisfied).length,failedRequirements:i.filter(a=>!a.satisfied).length,overallCompliance:o}}},auditCompliance:{endpoint:"POST /audit/compliance-check",data:{tokenId:e.id,jurisdiction:t.code,result:o,checkedAt:new Date().toISOString(),requirements:i}},notifyRegulator:o?null:{endpoint:"POST /notifications/compliance-failure",data:{tokenId:e.id,jurisdiction:t.code,failedRequirements:i.filter(a=>!a.satisfied)}}}}}catch(a){return{success:!1,error:a.message}}},prepareZeroKnowledgeProof:function(e,t,r){tr.checkArgument(e&&typeof e=="object","Invalid token"),tr.checkArgument(t&&typeof t=="object","Invalid statement"),tr.checkArgument(typeof r=="string","Nonce must be string");try{var n=Yr.sha256(d.Buffer.from(this._canonicalizeForSigning(e)+r)).toString("hex"),i={type:"LegalTokenZKProof",created:new Date().toISOString(),proofPurpose:"zeroKnowledge",statement:{claim:t.claim||"UNSPECIFIED",predicate:t.predicate||"SATISFIES",threshold:t.threshold||null},commitment:n,nonce:r,proofData:this._generateZKProofData(e,t,r)};return{success:!0,proof:i,commitment:n,externalOperations:{storeZKProof:{endpoint:"POST /proofs/zero-knowledge",data:{tokenId:e.id,proof:i,statement:t}},verifyZKProof:{endpoint:"POST /proofs/verify-zk",data:{proof:i,expectedNonce:r}},auditZKProof:{endpoint:"POST /audit/zk-proof",data:{tokenId:e.id,statement:t.claim,proofGenerated:new Date().toISOString()}}}}}catch(o){return{success:!1,error:o.message}}},_generateZKProofData:function(e,t,r){var n={challenge:Yr.sha256(d.Buffer.from(t.claim+r)).toString("hex"),response:Yr.sha256(d.Buffer.from(this._canonicalizeForSigning(e)+t.claim)).toString("hex"),witness:Yr.sha256(d.Buffer.from(r+e.id+t.predicate)).toString("hex")};return n},_createJWS:function(e,t){var r={alg:"ES256K",typ:"JWT"},n=d.Buffer.from(JSON.stringify(r)).toString("base64url"),i=e.toString("base64url"),o=t.toDER().toString("base64url");return n+".."+o},_canonicalizeForSigning:function(e){var t=JSON.parse(JSON.stringify(e));delete t.proof,delete t.tokenHash;var r=this._sortObjectKeys(t);return JSON.stringify(r)},_createFieldCommitments:function(e,t){var r=[],n=0;return this._traverseObject(e,"",function(i,o){if(i!=="proof"&&i!=="tokenHash"){var s=Yr.sha256(d.Buffer.from(t+i+n)).toString("hex"),a=this._hashField(i,o,s);r.push({path:i,value:o,salt:s,hash:a,index:n}),n++}}.bind(this)),r},_hashField:function(e,t,r){var n=e+":"+JSON.stringify(t)+":"+r;return Yr.sha256(d.Buffer.from(n)).toString("hex")},_createMerkleTree:function(e){var t=e.map(function(g){return g.hash});if(t.length===0)return{root:null,levels:[]};for(var r=[t],n=t;n.length>1;){for(var i=[],o=0;o<n.length;o+=2){var s=n[o],a=n[o+1]||s,c=d.Buffer.concat([d.Buffer.from(s,"hex"),d.Buffer.from(a,"hex")]),l=Yr.sha256(c).toString("hex");i.push(l)}r.push(i),n=i}return{root:n[0],levels:r}},_generateMerkleProof:function(e,t){for(var r=[],n=t,i=0;i<e.levels.length-1;i++){var o=e.levels[i],s=n%2===0,a=s?n+1:n-1;a<o.length&&r.push({hash:o[a],isLeft:!s}),n=Math.floor(n/2)}return r},_verifyMerkleProof:function(e,t,r,n){for(var i=e,o=t,s=0;s<r.length;s++){var a=r[s],c=o%2===0,l;a.isLeft?l=d.Buffer.concat([d.Buffer.from(a.hash,"hex"),d.Buffer.from(i,"hex")]):l=d.Buffer.concat([d.Buffer.from(i,"hex"),d.Buffer.from(a.hash,"hex")]),i=Yr.sha256(l).toString("hex"),o=Math.floor(o/2)}return i===n},_traverseObject:function(e,t,r){Array.isArray(e)?e.forEach(function(n,i){var o=t+"["+i+"]";this._traverseObject(n,o,r)}.bind(this)):e!==null&&typeof e=="object"?Object.keys(e).forEach(function(n){var i=t?t+"."+n:n;this._traverseObject(e[n],i,r)}.bind(this)):r(t,e)},_getNestedValue:function(e,t){return t.split(".").reduce(function(r,n){return r&&r[n]},e)},_findFieldCommitment:function(e,t){return e.find(function(r){return r.path===t})},_checkLegalRequirement:function(e,t){switch(t.type){case"field_present":var r=this._getNestedValue(e,t.field);return{requirement:t.type,field:t.field,satisfied:r!=null};case"field_value":var r=this._getNestedValue(e,t.field);return{requirement:t.type,field:t.field,satisfied:r===t.expectedValue};case"temporal_validity":var n=new Date,i=new Date(e.issuanceDate);return{requirement:t.type,satisfied:i<=n};default:return{requirement:t.type,satisfied:!1,error:"Unknown requirement type"}}},_hashCompliance:function(e,t,r){var n={tokenId:e.id,jurisdiction:t.code,nonce:r,timestamp:new Date().toISOString()};return Yr.sha256(d.Buffer.from(JSON.stringify(n))).toString("hex")},_sortObjectKeys:function(e){if(Array.isArray(e))return e.map(this._sortObjectKeys.bind(this));if(e!==null&&typeof e=="object"){var t={};return Object.keys(e).sort().forEach(function(r){t[r]=this._sortObjectKeys(e[r])}.bind(this)),t}return e}};oI.exports=U4});var fI=P((w7,uI)=>{"use strict";p();var $a=Zt(),b7=no(),_7=Rp(),ar=Ce(),aI=Ga(),q4={prepareRegistry:function(e){e=e||{},ar.checkArgument(typeof e=="object","Config must be object");var t={id:e.id||this._generateRegistryId(),name:e.name||"Legal Token Registry",jurisdiction:e.jurisdiction||"GLOBAL",authority:e.authority||null,created:new Date().toISOString(),version:"1.0.0",config:{allowPublicRegistration:e.allowPublicRegistration||!1,requireApproval:e.requireApproval||!0,enableRevocation:e.enableRevocation!==!1,enableAuditTrail:e.enableAuditTrail!==!1,retentionPeriod:e.retentionPeriod||"7Y",complianceLevel:e.complianceLevel||"STANDARD"},dataStructure:{tokens:"Map<tokenId, registrationRecord>",revocations:"Map<tokenId, revocationRecord>",auditLog:"Array<auditEntry>",statistics:{totalTokens:0,activeTokens:0,revokedTokens:0,registrations:0}},externalStorage:{required:!0,type:"database_or_blockchain",endpoints:{store:"POST /registry/{id}/tokens",retrieve:"GET /registry/{id}/tokens/{tokenId}",search:"GET /registry/{id}/search",revoke:"POST /registry/{id}/revocations"}}},r=this._prepareAuditEntry({action:"REGISTRY_CREATED",actor:e.authority,timestamp:t.created,metadata:{jurisdiction:t.jurisdiction,config:t.config}});return{success:!0,registry:t,initialAudit:r,instructions:{step1:"Store registry configuration in external system",step2:"Initialize token storage with provided data structure",step3:"Set up audit logging with provided templates",step4:"Configure external endpoints for registry operations"}}},prepareTokenRegistration:function(e,t,r){r=r||{},ar.checkArgument(e&&typeof e=="object","Invalid token"),ar.checkArgument(t&&typeof t=="object","Invalid registry config");try{var n=this._validateTokenForRegistration(e,t);if(!n.valid)return{success:!1,error:"Token validation failed: "+n.error};var i={tokenId:e.id,tokenHash:this._hashToken(e),token:e,status:t.requireApproval?"PENDING":"ACTIVE",registeredBy:r.registeredBy||"UNKNOWN",registeredAt:new Date().toISOString(),approvedBy:null,approvedAt:null,metadata:r.metadata||{},compliance:{jurisdiction:e.jurisdiction||t.jurisdiction,level:this._calculateComplianceLevel(e),checks:n.checks||[]}},o=this._prepareAuditEntry({action:"TOKEN_REGISTERED",actor:r.registeredBy,tokenId:e.id,timestamp:i.registeredAt,metadata:{status:i.status,tokenType:e.type,compliance:i.compliance}});return{success:!0,registrationRecord:i,auditEntry:o,registrationId:this._generateRegistrationId(e.id),validation:n,externalOperations:{store:{endpoint:"POST /registry/"+t.id+"/tokens",data:i},audit:{endpoint:"POST /registry/"+t.id+"/audit",data:o}}}}catch(s){return{success:!1,error:s.message}}},prepareTokenApproval:function(e,t,r){try{ar.checkArgument(typeof e=="string","Token ID must be string"),ar.checkArgument(typeof t=="string","Approver must be string"),ar.checkArgument(r&&typeof r=="object","Invalid registry config");var n={tokenId:e,status:"ACTIVE",approvedBy:t,approvedAt:new Date().toISOString()},i=this._prepareAuditEntry({action:"TOKEN_APPROVED",actor:t,tokenId:e,timestamp:n.approvedAt});return{success:!0,approvalData:n,auditEntry:i,externalOperations:{update:{endpoint:"PUT /registry/"+r.id+"/tokens/"+e+"/status",data:n},audit:{endpoint:"POST /registry/"+r.id+"/audit",data:i}}}}catch(o){return{success:!1,error:o.message}}},prepareTokenRevocation:function(e,t,r){try{if(ar.checkArgument(typeof e=="string","Token ID must be string"),ar.checkArgument(t&&typeof t=="object","Invalid revocation"),ar.checkArgument(r&&typeof r=="object","Invalid registry config"),!r.enableRevocation)return{success:!1,error:"Revocation is disabled for this registry"};var n={tokenId:e,reason:t.reason||"UNSPECIFIED",revokedBy:t.revokedBy||"UNKNOWN",revokedAt:new Date().toISOString(),effectiveDate:t.effectiveDate||new Date().toISOString(),legalBasis:t.legalBasis||null,evidence:t.evidence||null,revocationHash:this._generateRevocationHash(e,t)},i={tokenId:e,status:"REVOKED",revokedAt:n.revokedAt,revocationReason:n.reason},o=this._prepareAuditEntry({action:"TOKEN_REVOKED",actor:t.revokedBy,tokenId:e,timestamp:n.revokedAt,metadata:{reason:n.reason,legalBasis:n.legalBasis}});return{success:!0,revocationRecord:n,statusUpdate:i,auditEntry:o,revocationId:this._generateRevocationId(e),externalOperations:{storeRevocation:{endpoint:"POST /registry/"+r.id+"/revocations",data:n},updateStatus:{endpoint:"PUT /registry/"+r.id+"/tokens/"+e+"/status",data:i},audit:{endpoint:"POST /registry/"+r.id+"/audit",data:o}}}}catch(s){return{success:!1,error:s.message}}},prepareTokenStatusQuery:function(e,t){try{return ar.checkArgument(typeof e=="string","Token ID must be string"),ar.checkArgument(t&&typeof t=="object","Invalid registry config"),{success:!0,query:{tokenId:e,registryId:t.id},externalOperations:{retrieve:{endpoint:"GET /registry/"+t.id+"/tokens/"+e,method:"GET"},checkRevocation:{endpoint:"GET /registry/"+t.id+"/revocations/"+e,method:"GET"}},expectedResponse:{found:"boolean",status:"string (PENDING|ACTIVE|REVOKED)",registeredAt:"ISO datetime",registeredBy:"string",approvedAt:"ISO datetime or null",approvedBy:"string or null",revokedAt:"ISO datetime or null",revocationReason:"string or null",compliance:"object",revocation:"object or null"}}}catch(r){return{success:!1,error:r.message}}},prepareTokenSearch:function(e,t){e=e||{};try{ar.checkArgument(t&&typeof t=="object","Invalid registry config");var r=[];e.status&&r.push("status="+encodeURIComponent(e.status)),e.type&&r.push("type="+encodeURIComponent(e.type)),e.registeredBy&&r.push("registeredBy="+encodeURIComponent(e.registeredBy)),e.jurisdiction&&r.push("jurisdiction="+encodeURIComponent(e.jurisdiction)),e.dateFrom&&r.push("dateFrom="+encodeURIComponent(e.dateFrom)),e.dateTo&&r.push("dateTo="+encodeURIComponent(e.dateTo)),e.includeTokens&&r.push("includeTokens=true"),e.sortBy&&r.push("sortBy="+encodeURIComponent(e.sortBy)),e.sortOrder&&r.push("sortOrder="+encodeURIComponent(e.sortOrder));var n=e.offset||0,i=e.limit||100;r.push("offset="+n),r.push("limit="+i);var o=r.length>0?"?"+r.join("&"):"";return{success:!0,searchCriteria:e,externalOperations:{search:{endpoint:"GET /registry/"+t.id+"/search"+o,method:"GET"}},expectedResponse:{success:"boolean",results:"Array<tokenRecord>",totalCount:"number",totalRegistrations:"number",offset:"number",limit:"number",hasMore:"boolean"}}}catch(s){return{success:!1,error:s.message}}},prepareStatisticsQuery:function(e){return ar.checkArgument(e&&typeof e=="object","Invalid registry config"),{success:!0,query:{registryId:e.id},externalOperations:{getStatistics:{endpoint:"GET /registry/"+e.id+"/statistics",method:"GET"}},expectedResponse:{id:"string",name:"string",jurisdiction:"string",created:"ISO datetime",statistics:{totalTokens:"number",activeTokens:"number",revokedTokens:"number",registrations:"number"},auditEntries:"number",lastActivity:"ISO datetime"}}},prepareAuditLogQuery:function(e,t){if(t=t||{},ar.checkArgument(e&&typeof e=="object","Invalid registry config"),!e.enableAuditTrail)return{success:!1,error:"Audit trail is disabled"};var r=[];t.action&&r.push("action="+encodeURIComponent(t.action)),t.actor&&r.push("actor="+encodeURIComponent(t.actor)),t.tokenId&&r.push("tokenId="+encodeURIComponent(t.tokenId)),t.dateFrom&&r.push("dateFrom="+encodeURIComponent(t.dateFrom)),t.dateTo&&r.push("dateTo="+encodeURIComponent(t.dateTo));var n=t.offset||0,i=t.limit||100;r.push("offset="+n),r.push("limit="+i);var o=r.length>0?"?"+r.join("&"):"";return{success:!0,auditOptions:t,externalOperations:{getAuditLog:{endpoint:"GET /registry/"+e.id+"/audit"+o,method:"GET"}},expectedResponse:{success:"boolean",entries:"Array<auditEntry>",totalEntries:"number",offset:"number",limit:"number",hasMore:"boolean"}}},_generateRegistryId:function(){return"reg_"+aI.randomHex(16)},_generateRegistrationId:function(e){var t="reg_"+e+"_"+Date.now();return $a.sha256(d.Buffer.from(t)).toString("hex").substring(0,16)},_generateRevocationId:function(e){var t="rev_"+e+"_"+Date.now();return $a.sha256(d.Buffer.from(t)).toString("hex").substring(0,16)},_hashToken:function(e){var t=JSON.parse(JSON.stringify(e));return delete t.proof,delete t.tokenHash,$a.sha256(d.Buffer.from(JSON.stringify(t))).toString("hex")},_generateRevocationHash:function(e,t){var r=e+(t.reason||"")+(t.revokedBy||"")+Date.now();return $a.sha256(d.Buffer.from(r)).toString("hex")},_validateTokenForRegistration:function(e,t){var r=[],n=!0;return e.id?r.push({field:"id",valid:!0}):(r.push({field:"id",valid:!1,error:"Missing token ID"}),n=!1),e.type?r.push({field:"type",valid:!0}):(r.push({field:"type",valid:!1,error:"Missing token type"}),n=!1),e.issuanceDate?r.push({field:"issuanceDate",valid:!0}):(r.push({field:"issuanceDate",valid:!1,error:"Missing issuance date"}),n=!1),e.proof?r.push({field:"proof",valid:!0}):(r.push({field:"proof",valid:!1,error:"Missing cryptographic proof"}),n=!1),{valid:n,checks:r}},_calculateComplianceLevel:function(e){var t="BASIC";return e.proof&&e.proof.type&&(t="STANDARD"),e.jurisdiction&&e.legalBasis&&(t="ENHANCED"),e.attestations&&e.attestations.length>0&&(t="PREMIUM"),t},_prepareAuditEntry:function(e){var t={id:this._generateAuditId(),action:e.action,actor:e.actor||"SYSTEM",tokenId:e.tokenId||null,timestamp:e.timestamp||new Date().toISOString(),metadata:e.metadata||{},hash:this._generateAuditHash(e)};return t},_generateAuditId:function(){return"audit_"+aI.randomHex(32)},_generateAuditHash:function(e){var t=(e.action||"")+(e.actor||"")+(e.tokenId||"")+(e.timestamp||"");return $a.sha256(d.Buffer.from(t)).toString("hex").substring(0,16)}};uI.exports=q4});var dI=P((E7,lI)=>{"use strict";p();var qp=Or(),Fp=Zt(),cI=La(),F4=er(),hI=io(),gr=Ce(),H4=Ga();function j4(e,t){if(t=t||{},t.issuerPublicKey)return t.issuerPublicKey instanceof qp?t.issuerPublicKey:qp.fromString(t.issuerPublicKey);var r=e&&e.issuer;if(typeof r!="string")return null;try{var n=r.split("#")[0].split(":")[2];return n?qp.fromString(n):null}catch{return null}}var Nc={CORRELATIVE_OBLIGATION:"CorrelativeObligation",CONTRACTUAL_OBLIGATION:"ContractualObligation",PAYMENT_OBLIGATION:"PaymentObligation",DELIVERY_OBLIGATION:"DeliveryObligation",PERFORMANCE_OBLIGATION:"PerformanceObligation",MAINTENANCE_OBLIGATION:"MaintenanceObligation",COMPLIANCE_OBLIGATION:"ComplianceObligation",REPORTING_OBLIGATION:"ReportingObligation",CONFIDENTIALITY_OBLIGATION:"ConfidentialityObligation",NON_COMPETE_OBLIGATION:"NonCompeteObligation",INDEMNIFICATION_OBLIGATION:"IndemnificationObligation",WARRANTY_OBLIGATION:"WarrantyObligation",SUPPORT_OBLIGATION:"SupportObligation",REGULATORY_OBLIGATION:"RegulatoryObligation",FIDUCIARY_OBLIGATION:"FiduciaryObligation"},vs={CRITICAL:"CRITICAL",HIGH:"HIGH",MEDIUM:"MEDIUM",LOW:"LOW",DEFERRED:"DEFERRED"},ur={PENDING:"PENDING",ACTIVE:"ACTIVE",IN_PROGRESS:"IN_PROGRESS",COMPLETED:"COMPLETED",OVERDUE:"OVERDUE",BREACHED:"BREACHED",WAIVED:"WAIVED",TERMINATED:"TERMINATED"},Mc={prepareObligationToken:function(e,t,r,n,i,o){o=o||{},gr.checkArgument(typeof e=="string","Obligation type must be string"),gr.checkArgument(typeof t=="string","Issuer DID must be string"),gr.checkArgument(typeof r=="string","Obligor DID must be string"),gr.checkArgument(n&&typeof n=="object","Obligation must be object"),gr.checkArgument(i instanceof hI,"Invalid issuer private key");var s=Object.values(Nc);gr.checkArgument(s.includes(e),"Invalid obligation type: "+e);try{var a={"@context":["https://www.w3.org/2018/credentials/v1","https://smartledger.technology/contexts/ltp/v1"],id:"urn:uuid:"+this._generateUUID(),type:["VerifiableCredential","LegalObligationToken",e],issuer:t,issuanceDate:new Date().toISOString(),credentialSubject:{id:r,obligationType:e,obligation:n,jurisdiction:o.jurisdiction||"US",priority:o.priority||vs.MEDIUM,status:ur.PENDING,dueDate:o.dueDate||null,effectiveDate:o.effectiveDate||new Date().toISOString(),expirationDate:o.expirationDate||null,correlativeRight:o.correlativeRight||null,rightHolder:o.rightHolder||null,enforceable:o.enforceable!==!1,penalties:o.penalties||null,remedies:o.remedies||null}};o.metadata&&(a.credentialSubject.metadata=o.metadata);var c=this._signToken(a,i);return{success:!0,obligationToken:c,tokenHash:c.tokenHash,metadata:{type:e,issuer:t,obligor:r,priority:a.credentialSubject.priority,status:a.credentialSubject.status,jurisdiction:a.credentialSubject.jurisdiction,dueDate:a.credentialSubject.dueDate,correlativeRight:a.credentialSubject.correlativeRight},externalOperations:{storeToken:{endpoint:"POST /obligations/tokens",data:{token:c,metadata:{type:e,issuer:t,obligor:r,priority:a.credentialSubject.priority,status:a.credentialSubject.status,jurisdiction:a.credentialSubject.jurisdiction,dueDate:a.credentialSubject.dueDate,correlativeRight:a.credentialSubject.correlativeRight}}},indexToken:{endpoint:"POST /obligations/index",data:{tokenId:c.id,tokenHash:c.tokenHash,type:e,issuer:t,obligor:r,issuedAt:c.issuanceDate,dueDate:a.credentialSubject.dueDate,priority:a.credentialSubject.priority}},notifyObligor:{endpoint:"POST /notifications/obligation-issued",data:{tokenId:c.id,issuer:t,obligor:r,obligationType:e,dueDate:a.credentialSubject.dueDate,priority:a.credentialSubject.priority}},scheduleReminders:a.credentialSubject.dueDate?{endpoint:"POST /obligations/schedule-reminders",data:{tokenId:c.id,obligor:r,dueDate:a.credentialSubject.dueDate,reminderSchedule:o.reminderSchedule||["7d","3d","1d"]}}:null}}}catch(l){return{success:!1,error:l.message}}},prepareObligationVerification:function(e,t){t=t||{};try{var r=[],n=[];this._validateTokenStructure(e,r),this._verifyTokenSignature(e,r,t),this._validateTokenTemporal(e,r,n),this._validateObligationType(e,r),this._validateObligationStatus(e,r,n),this._validateObligationPriority(e,n);var i={valid:r.length===0,errors:r,warnings:n,issuerDID:e.issuer,obligorDID:e.credentialSubject?e.credentialSubject.id:null,obligationType:e.credentialSubject?e.credentialSubject.obligationType:null,status:e.credentialSubject?e.credentialSubject.status:null,priority:e.credentialSubject?e.credentialSubject.priority:null,isOverdue:this._checkIfOverdue(e),verifiedAt:new Date().toISOString()};return{success:!0,verification:i,externalOperations:{recordVerification:{endpoint:"POST /obligations/verification-record",data:{tokenId:e.id,result:i.valid,errors:r,warnings:n,verifiedAt:i.verifiedAt,isOverdue:i.isOverdue}},auditVerification:{endpoint:"POST /audit/obligation-verification",data:{tokenId:e.id,obligationType:i.obligationType,issuer:i.issuerDID,obligor:i.obligorDID,result:i.valid,verifiedAt:i.verifiedAt}},updateStatus:i.isOverdue&&e.credentialSubject.status===ur.ACTIVE?{endpoint:"PUT /obligations/tokens/"+e.id+"/status",data:{status:ur.OVERDUE,updatedAt:i.verifiedAt,reason:"Due date passed"}}:null}}}catch(o){return{success:!1,error:"Verification preparation failed: "+o.message}}},prepareObligationFulfillment:function(e,t,r,n){n=n||{},gr.checkArgument(e&&typeof e=="object","Invalid token"),gr.checkArgument(t&&typeof t=="object","Invalid fulfillment"),gr.checkArgument(r instanceof hI,"Invalid obligor key");try{var i=this.prepareObligationVerification(e,{});if(!i.success||!i.verification.valid)return{success:!1,error:"Cannot fulfill invalid obligation: "+i.verification.errors.join(", ")};if(e.credentialSubject.status===ur.COMPLETED)return{success:!1,error:"Obligation already fulfilled"};if(e.credentialSubject.status===ur.TERMINATED)return{success:!1,error:"Obligation has been terminated"};var o={"@context":["https://www.w3.org/2018/credentials/v1","https://smartledger.technology/contexts/ltp/v1"],id:"urn:uuid:"+this._generateUUID(),type:["VerifiableCredential","ObligationFulfillment"],issuer:e.credentialSubject.id,issuanceDate:new Date().toISOString(),credentialSubject:{id:e.id,fulfillmentType:t.type||"FULL_FULFILLMENT",fulfillmentDate:new Date().toISOString(),evidence:t.evidence||null,description:t.description||"",completionPercentage:t.completionPercentage||100,attestations:t.attestations||[],notes:t.notes||null}},s=this._signToken(o,r),a=o.credentialSubject.completionPercentage>=100?ur.COMPLETED:ur.IN_PROGRESS;return{success:!0,fulfillmentRecord:s,newStatus:a,fulfillmentId:s.id,externalOperations:{recordFulfillment:{endpoint:"POST /obligations/fulfillments",data:{obligationId:e.id,fulfillmentRecord:s,obligor:e.credentialSubject.id,fulfillmentDate:o.credentialSubject.fulfillmentDate,completionPercentage:o.credentialSubject.completionPercentage}},updateStatus:{endpoint:"PUT /obligations/tokens/"+e.id+"/status",data:{status:a,fulfillmentId:s.id,updatedAt:o.credentialSubject.fulfillmentDate,completionPercentage:o.credentialSubject.completionPercentage}},notifyRightHolder:e.credentialSubject.rightHolder?{endpoint:"POST /notifications/obligation-fulfilled",data:{obligationId:e.id,fulfillmentId:s.id,obligor:e.credentialSubject.id,rightHolder:e.credentialSubject.rightHolder,completionPercentage:o.credentialSubject.completionPercentage,newStatus:a}}:null,auditFulfillment:{endpoint:"POST /audit/obligation-fulfillment",data:{obligationId:e.id,fulfillmentId:s.id,obligor:e.credentialSubject.id,fulfilledAt:o.credentialSubject.fulfillmentDate,completionPercentage:o.credentialSubject.completionPercentage}}}}}catch(c){return{success:!1,error:c.message}}},prepareObligationBreachAssessment:function(e,t,r){gr.checkArgument(e&&typeof e=="object","Invalid token"),gr.checkArgument(t&&typeof t=="object","Invalid breach details"),gr.checkArgument(r&&typeof r=="object","Invalid assessor");try{var n={"@context":["https://www.w3.org/2018/credentials/v1","https://smartledger.technology/contexts/ltp/v1"],id:"urn:uuid:"+this._generateUUID(),type:["VerifiableCredential","ObligationBreachAssessment"],issuer:r.did||r.id,issuanceDate:new Date().toISOString(),credentialSubject:{id:e.id,breachType:t.type||"MATERIAL_BREACH",breachDate:t.date||new Date().toISOString(),description:t.description||"",severity:t.severity||"MODERATE",evidence:t.evidence||[],assessor:{did:r.did||r.id,name:r.name||"Unknown",authority:r.authority||null,jurisdiction:r.jurisdiction||null},damages:t.damages||null,recommendedRemedies:t.recommendedRemedies||[],assessmentDate:new Date().toISOString()}},i=Fp.sha256(d.Buffer.from(JSON.stringify(n))).toString("hex");return n.credentialSubject.assessmentHash=i,{success:!0,breachAssessment:n,breachId:n.id,severity:t.severity||"MODERATE",externalOperations:{recordBreach:{endpoint:"POST /obligations/breaches",data:{obligationId:e.id,breachAssessment:n,obligor:e.credentialSubject.id,rightHolder:e.credentialSubject.rightHolder,breachDate:t.date||new Date().toISOString(),severity:t.severity||"MODERATE"}},updateStatus:{endpoint:"PUT /obligations/tokens/"+e.id+"/status",data:{status:ur.BREACHED,breachId:n.id,breachDate:t.date||new Date().toISOString(),updatedAt:new Date().toISOString()}},notifyParties:{endpoint:"POST /notifications/obligation-breached",data:{obligationId:e.id,breachId:n.id,obligor:e.credentialSubject.id,rightHolder:e.credentialSubject.rightHolder,breachType:t.type||"MATERIAL_BREACH",severity:t.severity||"MODERATE"}},escalateBreach:t.severity==="CRITICAL"?{endpoint:"POST /legal/escalate-breach",data:{obligationId:e.id,breachId:n.id,severity:t.severity,jurisdiction:e.credentialSubject.jurisdiction}}:null,auditBreach:{endpoint:"POST /audit/obligation-breach",data:{obligationId:e.id,breachId:n.id,obligor:e.credentialSubject.id,assessedAt:n.credentialSubject.assessmentDate,severity:t.severity||"MODERATE"}}}}}catch(o){return{success:!1,error:o.message}}},prepareObligationMonitoringReport:function(e,t){t=t||{},gr.checkArgument(Array.isArray(e),"Obligations must be array");try{var r={reportId:"rpt_"+this._generateUUID(),generatedAt:new Date().toISOString(),criteria:t,summary:{totalObligations:e.length,byStatus:{},byPriority:{},byType:{},overdue:0,dueSoon:0,completed:0},obligations:[],alerts:[],recommendations:[]},n=new Date,i=new Date(n.getTime()+10080*60*1e3);return e.forEach(function(o){var s={id:o.id,type:o.credentialSubject.obligationType,status:o.credentialSubject.status,priority:o.credentialSubject.priority,obligor:o.credentialSubject.id,dueDate:o.credentialSubject.dueDate,isOverdue:this._checkIfOverdue(o),isDueSoon:!1};if(o.credentialSubject.dueDate){var a=new Date(o.credentialSubject.dueDate);s.isDueSoon=a<=i&&a>n}r.summary.byStatus[s.status]=(r.summary.byStatus[s.status]||0)+1,r.summary.byPriority[s.priority]=(r.summary.byPriority[s.priority]||0)+1,r.summary.byType[s.type]=(r.summary.byType[s.type]||0)+1,s.isOverdue&&r.summary.overdue++,s.isDueSoon&&r.summary.dueSoon++,s.status===ur.COMPLETED&&r.summary.completed++,s.isOverdue&&s.priority===vs.CRITICAL&&r.alerts.push({type:"CRITICAL_OVERDUE",obligationId:o.id,message:"Critical obligation is overdue",priority:"HIGH"}),s.isDueSoon&&s.priority===vs.HIGH&&r.alerts.push({type:"HIGH_PRIORITY_DUE_SOON",obligationId:o.id,message:"High priority obligation due soon",priority:"MEDIUM"}),r.obligations.push(s)}.bind(this)),r.summary.overdue>0&&r.recommendations.push({type:"OVERDUE_MANAGEMENT",message:"Consider prioritizing overdue obligations",count:r.summary.overdue}),r.summary.dueSoon>5&&r.recommendations.push({type:"WORKLOAD_MANAGEMENT",message:"High number of obligations due soon - consider workload distribution",count:r.summary.dueSoon}),{success:!0,report:r,externalOperations:{storeReport:{endpoint:"POST /obligations/monitoring-reports",data:{report:r,generatedAt:r.generatedAt}},sendAlerts:r.alerts.length>0?{endpoint:"POST /notifications/obligation-alerts",data:{reportId:r.reportId,alerts:r.alerts,summary:r.summary}}:null,updateDashboard:{endpoint:"PUT /dashboard/obligation-metrics",data:{summary:r.summary,lastUpdated:r.generatedAt}}}}}catch(o){return{success:!1,error:o.message}}},getObligationTypes:function(){return Nc},getObligationPriority:function(){return vs},getObligationStatus:function(){return ur},_signToken:function(e,t){var r=this._canonicalizeToken(e),n=Fp.sha256(d.Buffer.from(r)),i=new cI;i.hashbuf=n,i.privkey=t,i.pubkey=t.toPublicKey(),i.sign();var o=i.sig,s={type:"EcdsaSecp256k1Signature2019",created:new Date().toISOString(),verificationMethod:"did:smartledger:"+t.toPublicKey().toString()+"#keys-1",proofPurpose:"assertionMethod",jws:this._createJWS(n,o)},a=JSON.parse(JSON.stringify(e));return a.proof=s,a.tokenHash=n.toString("hex"),a},_createJWS:function(e,t){var r={alg:"ES256K",typ:"JWT"},n=d.Buffer.from(JSON.stringify(r)).toString("base64url"),i=e.toString("base64url"),o=t.toDER().toString("base64url");return n+".."+o},_canonicalizeToken:function(e){var t=JSON.parse(JSON.stringify(e));return delete t.proof,delete t.tokenHash,JSON.stringify(this._sortObjectKeys(t))},_sortObjectKeys:function(e){if(Array.isArray(e))return e.map(this._sortObjectKeys.bind(this));if(e!==null&&typeof e=="object"){var t={};return Object.keys(e).sort().forEach(function(r){t[r]=this._sortObjectKeys(e[r])}.bind(this)),t}return e},_validateTokenStructure:function(e,t){e["@context"]||t.push("Missing @context"),e.id||t.push("Missing id"),(!e.type||!Array.isArray(e.type))&&t.push("Missing or invalid type"),e.issuer||t.push("Missing issuer"),e.issuanceDate||t.push("Missing issuanceDate"),e.credentialSubject||t.push("Missing credentialSubject"),e.proof||t.push("Missing proof")},_verifyTokenSignature:function(e,t,r){try{if(!e.proof||!e.proof.jws){t.push("Missing signature proof");return}var n=this._canonicalizeToken(e),i=Fp.sha256(d.Buffer.from(n));if(e.tokenHash&&e.tokenHash!==i.toString("hex")){t.push("Token hash mismatch");return}var o=j4(e,r);if(!o){t.push("Signature not verified: issuer public key could not be resolved from token.issuer; pass options.issuerPublicKey");return}var s=e.proof.jws.split(".");if(s.length!==3||!s[2]){t.push("Malformed JWS");return}var a=F4.fromDER(d.Buffer.from(s[2],"base64url")),c=new cI;c.hashbuf=i,c.sig=a,c.pubkey=o,c.verify()!==!0&&t.push("Signature verification failed")}catch(l){t.push("Signature verification failed: "+l.message)}},_validateTokenTemporal:function(e,t,r){var n=new Date,i=new Date(e.issuanceDate);if(i>n&&t.push("Token issued in the future"),e.credentialSubject.effectiveDate){var o=new Date(e.credentialSubject.effectiveDate);n<o&&r.push("Obligation not yet effective")}if(e.credentialSubject.expirationDate){var s=new Date(e.credentialSubject.expirationDate);n>s&&t.push("Obligation expired")}},_validateObligationType:function(e,t){if(!e.credentialSubject.obligationType){t.push("Missing obligationType");return}var r=Object.values(Nc);r.includes(e.credentialSubject.obligationType)||t.push("Invalid obligation type: "+e.credentialSubject.obligationType)},_validateObligationStatus:function(e,t,r){if(!e.credentialSubject.status){t.push("Missing status");return}var n=Object.values(ur);n.includes(e.credentialSubject.status)||t.push("Invalid obligation status: "+e.credentialSubject.status),this._checkIfOverdue(e)&&e.credentialSubject.status===ur.ACTIVE&&r.push("Obligation is overdue but status is still ACTIVE")},_validateObligationPriority:function(e,t){if(e.credentialSubject.priority){var r=Object.values(vs);r.includes(e.credentialSubject.priority)||t.push("Invalid obligation priority: "+e.credentialSubject.priority)}},_checkIfOverdue:function(e){if(!e.credentialSubject.dueDate)return!1;var t=new Date,r=new Date(e.credentialSubject.dueDate);return t>r&&e.credentialSubject.status!==ur.COMPLETED},_generateUUID:function(){return H4.uuid4()}};Mc.ObligationTypes=Nc;Mc.ObligationPriority=vs;Mc.ObligationStatus=ur;lI.exports=Mc});var gI=P((I7,pI)=>{"use strict";p();var fo=Qx(),kc=tI(),Za=nI(),Hp=sI(),vn=fI(),K4=dI(),jp=io(),yr=Ce(),Re=function(e){return this instanceof Re?(this.config=e||{},this.registry=null,this.config.registry&&(this.registry=vn.createRegistry(this.config.registry)),this):new Re(e)};Re.prototype.createRightToken=function(e,t,r){yr.checkArgument(e&&typeof e=="object","Invalid right data"),yr.checkArgument(t instanceof jp,"Invalid private key"),r=r||{};try{var n=fo.create(e.type,e.owner,e.owner,e,t,r);if(!n)return{success:!1,error:"Failed to create token"};if(r.addProof!==!1&&(n=fo._signToken(n,t)),r.anchor){var i=Za.anchorToken(n,r.anchor);i.success&&(n.anchorTx=i.txid,n.anchorBlock=i.blockHeight)}if(this.registry&&r.register!==!1){var o=vn.registerToken(this.registry,n,{registeredBy:r.registeredBy||"SYSTEM"});o.success&&(n.registrationId=o.registrationId,n.registrationStatus=o.status)}return{success:!0,token:n,type:"LegalRightToken"}}catch(s){return{success:!1,error:s.message}}};Re.prototype.validateClaim=function(e,t){return kc.validate(e,t)};Re.prototype.createSelectiveDisclosure=function(e,t,r){return Hp.prepareSelectiveDisclosure(e,t,r)};Re.prototype.verifyToken=function(e,t){return!e||!e.proof?{valid:!1,error:"No proof found in token"}:fo.verifyToken(e,t)};Re.prototype.transferRight=function(e,t,r,n){yr.checkArgument(e&&typeof e=="object","Invalid token"),yr.checkArgument(typeof t=="string","New owner must be string"),yr.checkArgument(r instanceof jp,"Invalid owner key"),n=n||{};try{var i=this.verifyToken(e,r.toPublicKey().toString());if(!i.valid)return{success:!1,error:"Invalid token or ownership proof"};var o=fo.prepareRightTokenTransfer(e,t,r,n);if(!o.success)return{success:!1,error:o.error};var s=o.newToken,a=o.transferProof;if(n.anchor){var c=Za.anchorToken(s,n.anchor);c.success&&(s.transferAnchorTx=c.txid)}if(this.registry){var l=vn.registerToken(this.registry,s,{registeredBy:n.registeredBy||t,metadata:{transferFrom:e.owner,transferTo:t,originalTokenId:e.id}});l.success&&(s.registrationId=l.registrationId)}return{success:!0,token:s,transferId:a.id,transferredAt:a.issuanceDate,transferProof:a}}catch(g){return{success:!1,error:g.message}}};Re.prototype.createObligation=function(e,t,r){yr.checkArgument(e&&typeof e=="object","Invalid right token"),yr.checkArgument(t&&typeof t=="object","Invalid obligation data"),yr.checkArgument(r instanceof jp,"Invalid private key");try{var n=fo.prepareObligationToken(e,t.obligor,t,r);return n.success?{success:!0,obligation:n.obligationToken,rightTokenId:e.id}:{success:!1,error:n.error}}catch(i){return{success:!1,error:i.message}}};Re.prototype.revokeToken=function(e,t,r){return yr.checkArgument(typeof e=="string","Token ID must be string"),yr.checkArgument(t&&typeof t=="object","Invalid revocation data"),yr.checkArgument(typeof r=="string","Authority must be string"),this.registry?vn.revokeToken(this.registry,e,{reason:t.reason,revokedBy:r,legalBasis:t.legalBasis,evidence:t.evidence}):{success:!1,error:"No registry available for revocation"}};Re.prototype.checkTokenStatus=function(e){return yr.checkArgument(typeof e=="string","Token ID must be string"),this.registry?vn.checkTokenStatus(this.registry,e):{found:!1,error:"No registry available"}};Re.prototype.searchTokens=function(e){return this.registry?vn.searchTokens(this.registry,e):{success:!1,error:"No registry available"}};Re.prototype.getRegistryStats=function(){return this.registry?vn.getStatistics(this.registry):{error:"No registry available"}};Re.prototype.createLegalValidityProof=function(e,t,r){return Hp.prepareLegalValidityProof(e,t,r)};Re.prototype.anchorTokenBatch=function(e,t){return Za.anchorBatch(e,t)};Re.prototype.verifyAnchor=function(e,t){return Za.verifyAnchor(e,t)};Re.prototype.getRightTypes=function(){return fo.getRightTypes()};Re.prototype.getClaimSchemas=function(){return kc.getSchemas()};Re.prototype.createRegistry=function(e){return this.registry=vn.createRegistry(e),this.registry};Re.prototype.setRegistry=function(e){yr.checkArgument(e&&typeof e=="object","Invalid registry"),this.registry=e};Re.create=function(e){return new Re(e)};Re.createRightToken=function(e,t,r){var n=new Re;return n.createRightToken(e,t,r)};Re.validateClaim=function(e,t){return kc.validate(e,t)};Re.verifyToken=function(e,t){var r=new Re;return r.verifyToken(e,t)};Re.createRegistry=function(e){return vn.createRegistry(e)};Re.Right=fo;Re.Claim=kc;Re.Anchor=Za;Re.Proof=Hp;Re.Registry=vn;Re.Obligation=K4;pI.exports=Re});var V4=P((O7,yI)=>{p();yI.exports=gI()});return V4();})();
|
|
68
|
+
`).concat(vc(e),`
|
|
69
|
+
`));var a=new li({actual:e,expected:t,message:r,operator:i,stackStartFn:n});throw a.generatedMessage=s,a}}Ge.match=function e(t,r,n){$E(t,r,n,e,"match")};Ge.doesNotMatch=function e(t,r,n){$E(t,r,n,e,"doesNotMatch")};function ZE(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];jE.apply(void 0,[ZE,t.length].concat(t))}Ge.strict=u6(ZE,Ge,{equal:Ge.strictEqual,deepEqual:Ge.deepStrictEqual,notEqual:Ge.notStrictEqual,notDeepEqual:Ge.notDeepStrictEqual});Ge.strict.strict=Ge.strict});var Ji=P((OF,QE)=>{"use strict";y();var JE=oc(),tt=function e(t){if(!(this instanceof e))return new e(t);this.bufLen=0,t?this.set(t):this.bufs=[]};tt.prototype.set=function(e){return this.bufs=e.bufs||this.bufs||[],this.bufLen=this.bufs.reduce(function(t,r){return t+r.length},0),this};tt.prototype.toBuffer=function(){return this.concat()};tt.prototype.concat=function(){return d.Buffer.concat(this.bufs,this.bufLen)};tt.prototype.write=function(e){return JE(d.Buffer.isBuffer(e)),this.bufs.push(e),this.bufLen+=e.length,this};tt.prototype.writeReverse=function(e){return JE(d.Buffer.isBuffer(e)),this.bufs.push(d.Buffer.from(e).reverse()),this.bufLen+=e.length,this};tt.prototype.writeUInt8=function(e){var t=d.Buffer.alloc(1);return t.writeUInt8(e,0),this.write(t),this};tt.prototype.writeUInt16BE=function(e){var t=d.Buffer.alloc(2);return t.writeUInt16BE(e,0),this.write(t),this};tt.prototype.writeUInt16LE=function(e){var t=d.Buffer.alloc(2);return t.writeUInt16LE(e,0),this.write(t),this};tt.prototype.writeUInt32BE=function(e){var t=d.Buffer.alloc(4);return t.writeUInt32BE(e,0),this.write(t),this};tt.prototype.writeInt32LE=function(e){var t=d.Buffer.alloc(4);return t.writeInt32LE(e,0),this.write(t),this};tt.prototype.writeUInt32LE=function(e){var t=d.Buffer.alloc(4);return t.writeUInt32LE(e,0),this.write(t),this};tt.prototype.writeUInt64BEBN=function(e){var t=e.toBuffer({size:8});return this.write(t),this};tt.prototype.writeUInt64LEBN=function(e){var t=e.toBuffer({size:8});return this.writeReverse(t),this};tt.prototype.writeVarintNum=function(e){var t=tt.varintBufNum(e);return this.write(t),this};tt.prototype.writeVarintBN=function(e){var t=tt.varintBufBN(e);return this.write(t),this};tt.varintBufNum=function(e){var t;return e<253?(t=d.Buffer.alloc(1),t.writeUInt8(e,0)):e<65536?(t=d.Buffer.alloc(3),t.writeUInt8(253,0),t.writeUInt16LE(e,1)):e<4294967296?(t=d.Buffer.alloc(5),t.writeUInt8(254,0),t.writeUInt32LE(e,1)):(t=d.Buffer.alloc(9),t.writeUInt8(255,0),t.writeInt32LE(e&-1,1),t.writeUInt32LE(Math.floor(e/4294967296),5)),t};tt.varintBufBN=function(e){var t,r=e.toNumber();if(r<253)t=d.Buffer.alloc(1),t.writeUInt8(r,0);else if(r<65536)t=d.Buffer.alloc(3),t.writeUInt8(253,0),t.writeUInt16LE(r,1);else if(r<4294967296)t=d.Buffer.alloc(5),t.writeUInt8(254,0),t.writeUInt32LE(r,1);else{var n=new tt;n.writeUInt8(255),n.writeUInt64LEBN(e),t=n.concat()}return t};QE.exports=tt});var up=P((TF,e1)=>{"use strict";y();var is=Ve(),Na=ke(),c6=pr();function Pe(e){if(!(this instanceof Pe))return new Pe(e);var t;if(is.isNumber(e))t=e;else if(is.isString(e))t=Pe.map[e];else throw new TypeError('Unrecognized num type: "'+typeof e+'" for Opcode');return c6.defineImmutable(this,{num:t}),this}Pe.fromBuffer=function(e){return Na.checkArgument(d.Buffer.isBuffer(e)),new Pe(+("0x"+e.toString("hex")))};Pe.fromNumber=function(e){return Na.checkArgument(is.isNumber(e)),new Pe(e)};Pe.fromString=function(e){Na.checkArgument(is.isString(e));var t=Pe.map[e];if(typeof t>"u")throw new TypeError("Invalid opcodestr");return new Pe(t)};Pe.prototype.toHex=function(){return this.num.toString(16)};Pe.prototype.toBuffer=function(){return d.Buffer.from(this.toHex(),"hex")};Pe.prototype.toNumber=function(){return this.num};Pe.prototype.toString=function(){var e=Pe.reverseMap[this.num];if(typeof e>"u")throw new Error("Opcode does not have a string representation");return e};Pe.smallInt=function(e){return Na.checkArgument(is.isNumber(e),"Invalid Argument: n should be number"),Na.checkArgument(e>=0&&e<=16,"Invalid Argument: n must be between 0 and 16"),e===0?Pe("OP_0"):new Pe(Pe.map.OP_1+e-1)};Pe.map={OP_FALSE:0,OP_0:0,OP_PUSHDATA1:76,OP_PUSHDATA2:77,OP_PUSHDATA4:78,OP_1NEGATE:79,OP_RESERVED:80,OP_TRUE:81,OP_1:81,OP_2:82,OP_3:83,OP_4:84,OP_5:85,OP_6:86,OP_7:87,OP_8:88,OP_9:89,OP_10:90,OP_11:91,OP_12:92,OP_13:93,OP_14:94,OP_15:95,OP_16:96,OP_NOP:97,OP_VER:98,OP_IF:99,OP_NOTIF:100,OP_VERIF:101,OP_VERNOTIF:102,OP_ELSE:103,OP_ENDIF:104,OP_VERIFY:105,OP_RETURN:106,OP_TOALTSTACK:107,OP_FROMALTSTACK:108,OP_2DROP:109,OP_2DUP:110,OP_3DUP:111,OP_2OVER:112,OP_2ROT:113,OP_2SWAP:114,OP_IFDUP:115,OP_DEPTH:116,OP_DROP:117,OP_DUP:118,OP_NIP:119,OP_OVER:120,OP_PICK:121,OP_ROLL:122,OP_ROT:123,OP_SWAP:124,OP_TUCK:125,OP_CAT:126,OP_SPLIT:127,OP_NUM2BIN:128,OP_BIN2NUM:129,OP_SIZE:130,OP_INVERT:131,OP_AND:132,OP_OR:133,OP_XOR:134,OP_EQUAL:135,OP_EQUALVERIFY:136,OP_RESERVED1:137,OP_RESERVED2:138,OP_1ADD:139,OP_1SUB:140,OP_2MUL:141,OP_2DIV:142,OP_NEGATE:143,OP_ABS:144,OP_NOT:145,OP_0NOTEQUAL:146,OP_ADD:147,OP_SUB:148,OP_MUL:149,OP_DIV:150,OP_MOD:151,OP_LSHIFT:152,OP_RSHIFT:153,OP_BOOLAND:154,OP_BOOLOR:155,OP_NUMEQUAL:156,OP_NUMEQUALVERIFY:157,OP_NUMNOTEQUAL:158,OP_LESSTHAN:159,OP_GREATERTHAN:160,OP_LESSTHANOREQUAL:161,OP_GREATERTHANOREQUAL:162,OP_MIN:163,OP_MAX:164,OP_WITHIN:165,OP_RIPEMD160:166,OP_SHA1:167,OP_SHA256:168,OP_HASH160:169,OP_HASH256:170,OP_CODESEPARATOR:171,OP_CHECKSIG:172,OP_CHECKSIGVERIFY:173,OP_CHECKMULTISIG:174,OP_CHECKMULTISIGVERIFY:175,OP_CHECKLOCKTIMEVERIFY:177,OP_CHECKSEQUENCEVERIFY:178,OP_NOP1:176,OP_NOP2:177,OP_NOP3:178,OP_SUBSTR:179,OP_LEFT:180,OP_RIGHT:181,OP_LSHIFTNUM:182,OP_RSHIFTNUM:183,OP_NOP9:184,OP_NOP10:185,OP_PUBKEYHASH:253,OP_PUBKEY:254,OP_INVALIDOPCODE:255};Pe.reverseMap=[];for(ap in Pe.map)Pe.reverseMap[Pe.map[ap]]=ap;var ap;is.extend(Pe,Pe.map);Pe.isSmallIntOp=function(e){return e instanceof Pe&&(e=e.toNumber()),e===Pe.map.OP_0||e>=Pe.map.OP_1&&e<=Pe.map.OP_16};Pe.prototype.inspect=function(){return"<Opcode: "+this.toString()+", hex: "+this.toHex()+", decimal: "+this.num+">"};e1.exports=Pe});var ir=P((BF,r1)=>{"use strict";y();var Qi=Er(),l6=Ve(),nr=ke(),h6=pr(),Ie=function e(t,r){if(!(this instanceof e))return new e(t,r);if(t instanceof Qi)this.set({r:t,s:r});else if(t){var n=t;this.set(n)}};Ie.prototype.set=function(e){return this.r=e.r||this.r||void 0,this.s=e.s||this.s||void 0,this.i=typeof e.i<"u"?e.i:this.i,this.compressed=typeof e.compressed<"u"?e.compressed:this.compressed,this.nhashtype=e.nhashtype||this.nhashtype||void 0,this};Ie.fromCompact=function(e){nr.checkArgument(d.Buffer.isBuffer(e),"Argument is expected to be a Buffer");var t=new Ie,r=!0,n=e.slice(0,1)[0]-27-4;n<0&&(r=!1,n=n+4);var i=e.slice(1,33),o=e.slice(33,65);return nr.checkArgument(n===0||n===1||n===2||n===3,new Error("i must be 0, 1, 2, or 3")),nr.checkArgument(i.length===32,new Error("r must be 32 bytes")),nr.checkArgument(o.length===32,new Error("s must be 32 bytes")),t.compressed=r,t.i=n,t.r=Qi.fromBuffer(i),t.s=Qi.fromBuffer(o),t};Ie.fromDER=Ie.fromBuffer=function(e,t){var r=Ie.parseDER(e,t),n=new Ie;return n.r=r.r,n.s=r.s,n};Ie.fromTxFormat=function(e){var t=e.readUInt8(e.length-1),r=e.slice(0,e.length-1),n=Ie.fromDER(r,!1);return n.nhashtype=t,n};Ie.fromString=function(e){var t=d.Buffer.from(e,"hex");return Ie.fromDER(t)};function t1(e,t){nr.checkArgument(t.length>0,new Error("Length of "+e+" is zero")),nr.checkArgument(!(t[0]&128),new Error("Value of "+e+" is negative")),nr.checkArgument(!(t.length>1&&t[0]===0&&!(t[1]&128)),new Error("Value of "+e+" is excessively padded"))}Ie.parseDER=function(e,t){nr.checkArgument(d.Buffer.isBuffer(e),new Error("DER formatted signature should be a buffer")),l6.isUndefined(t)&&(t=!0);var r=e[0];nr.checkArgument(r===48,new Error("Header byte should be 0x30"));var n=e[1],i=e.slice(2).length;nr.checkArgument(!t||n===i,new Error("Length byte should length of what follows")),n=n<i?n:i;var o=e[2];nr.checkArgument(o===2,new Error("Integer byte for r should be 0x02"));var s=e[3],a=e.slice(4,4+s),c=Qi.fromBuffer(a),h=e[4]===0;nr.checkArgument(s===a.length,new Error("Length of r incorrect"));var g=e[4+s+0];nr.checkArgument(g===2,new Error("Integer byte for s should be 0x02"));var m=e[4+s+1],_=e.slice(4+s+2,4+s+2+m),I=Qi.fromBuffer(_),R=e[4+s+2]===0;nr.checkArgument(m===_.length,new Error("Length of s incorrect"));var N=4+s+2+m;nr.checkArgument(n===N-2,new Error("Length of signature incorrect")),t&&(t1("r",a),t1("s",_));var L={header:r,length:n,rheader:o,rlength:s,rneg:h,rbuf:a,r:c,sheader:g,slength:m,sneg:R,sbuf:_,s:I};return L};Ie.prototype.toCompact=function(e,t){if(e=typeof e=="number"?e:this.i,t=typeof t=="boolean"?t:this.compressed,!(e===0||e===1||e===2||e===3))throw new Error("i must be equal to 0, 1, 2, or 3");var r=e+27+4;t===!1&&(r=r-4);var n=d.Buffer.from([r]),i=this.r.toBuffer({size:32}),o=this.s.toBuffer({size:32});return d.Buffer.concat([n,i,o])};Ie.prototype.toBuffer=Ie.prototype.toDER=function(){var e=this.r.toBuffer(),t=this.s.toBuffer(),r=!!(e[0]&128),n=!!(t[0]&128),i=r?d.Buffer.concat([d.Buffer.from([0]),e]):e,o=n?d.Buffer.concat([d.Buffer.from([0]),t]):t,s=i.length,a=o.length,c=2+s+2+a,h=2,g=2,m=48,_=d.Buffer.concat([d.Buffer.from([m,c,h,s]),i,d.Buffer.from([g,a]),o]);return _};Ie.prototype.toString=function(){var e=this.toDER();return e.toString("hex")};Ie.isTxDER=function(e){if(e.length<9||e.length>73||e[0]!==48||e[1]!==e.length-3)return!1;var t=e[3];if(5+t>=e.length)return!1;var r=e[5+t];if(t+r+7!==e.length)return!1;var n=e.slice(4);if(e[2]!==2||t===0||n[0]&128||t>1&&n[0]===0&&!(n[1]&128))return!1;var i=e.slice(6+t);return!(e[6+t-2]!==2||r===0||i[0]&128||r>1&&i[0]===0&&!(i[1]&128))};Ie.prototype.hasLowS=function(){return!(this.s.lt(new Qi(1))||this.s.gt(new Qi("7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0","hex")))};Ie.prototype.hasDefinedHashtype=function(){if(!h6.isNaturalNumber(this.nhashtype))return!1;var e=this.nhashtype&31;return!(e<Ie.SIGHASH_ALL||e>Ie.SIGHASH_SINGLE)};Ie.prototype.toTxFormat=function(){var e=this.toDER(),t=d.Buffer.alloc(1);return t.writeUInt8(this.nhashtype,0),d.Buffer.concat([e,t])};Ie.SIGHASH_ALL=1;Ie.SIGHASH_NONE=2;Ie.SIGHASH_SINGLE=3;Ie.SIGHASH_CHRONICLE=32;Ie.SIGHASH_FORKID=64;Ie.SIGHASH_ANYONECANPAY=128;Ie.prototype.isCanonical=function(){var e=ii(),t=e.getN().shrn(1);return this.s.lte(t)};Ie.prototype.toCanonical=function(){if(this.isCanonical())return new Ie({r:this.r,s:this.s,i:this.i,compressed:this.compressed,nhashtype:this.nhashtype});var e=ii(),t=e.getN(),r=t.sub(this.s);return new Ie({r:this.r,s:r,i:this.i,compressed:this.compressed,nhashtype:this.nhashtype})};Ie.prototype.validate=function(){if(!this.r||!this.s)throw new Error("Signature missing r or s component");if(this.r.isZero())throw new Error("Signature r component is zero");if(this.s.isZero())throw new Error("Signature s component is zero");var e=ii(),t=e.getN();if(this.r.gte(t))throw new Error("Signature r component >= curve order");if(this.s.gte(t))throw new Error("Signature s component >= curve order");if(this.r.isNeg())throw new Error("Signature r component is negative");if(this.s.isNeg())throw new Error("Signature s component is negative");return!0};Ie.prototype.isValid=function(){try{return this.validate(),!0}catch{return!1}};Ie.prototype.applySecurityPatches=function(){var e=ii(),t=e.getN(),r=t.shrn(1);if(this.r.isZero()||this.s.isZero())throw new Error("Invalid signature: zero r or s");if(this.r.gte(t)||this.s.gte(t))throw new Error("Invalid signature: out of range");if(this.s.gt(r))throw new Error("Invalid signature: non-canonical (high) s");return this};r1.exports=Ie});var lp=P((MF,o1)=>{"use strict";y();var Hr=ro(),d6=va(),p6=Ji(),fp=Qt(),Z=up(),to=Tr(),eo=ir(),n1=ga(),$e=ke(),Ae=Ve(),cp=Jn(),i1=Tt(),g6=pr(),D=function e(t){if(!(this instanceof e))return new e(t);if(this.chunks=[],d.Buffer.isBuffer(t))return e.fromBuffer(t);if(t instanceof Hr)return e.fromAddress(t);if(t instanceof e)return e.fromBuffer(t.toBuffer());if(Ae.isString(t))return e.fromString(t);Ae.isObject(t)&&Ae.isArray(t.chunks)&&this.set(t)};D.prototype.set=function(e){return $e.checkArgument(Ae.isObject(e)),$e.checkArgument(Ae.isArray(e.chunks)),this.chunks=e.chunks,this};D.fromBuffer=function(e){var t=new D;t.chunks=[];for(var r=new d6(e);!r.finished();)try{var n=r.readUInt8(),i,o;n>0&&n<Z.OP_PUSHDATA1?(i=n,t.chunks.push({buf:r.read(i),len:i,opcodenum:n})):n===Z.OP_PUSHDATA1?(i=r.readUInt8(),o=r.read(i),t.chunks.push({buf:o,len:i,opcodenum:n})):n===Z.OP_PUSHDATA2?(i=r.readUInt16LE(),o=r.read(i),t.chunks.push({buf:o,len:i,opcodenum:n})):n===Z.OP_PUSHDATA4?(i=r.readUInt32LE(),o=r.read(i),t.chunks.push({buf:o,len:i,opcodenum:n})):t.chunks.push({opcodenum:n})}catch(s){throw s instanceof RangeError?new cp.Script.InvalidBuffer(e.toString("hex")):s}return t};D.prototype.toBuffer=function(){for(var e=new p6,t=0;t<this.chunks.length;t++){var r=this.chunks[t],n=r.opcodenum;e.writeUInt8(r.opcodenum),r.buf&&(n<Z.OP_PUSHDATA1?e.write(r.buf):n===Z.OP_PUSHDATA1?(e.writeUInt8(r.len),e.write(r.buf)):n===Z.OP_PUSHDATA2?(e.writeUInt16LE(r.len),e.write(r.buf)):n===Z.OP_PUSHDATA4&&(e.writeUInt32LE(r.len),e.write(r.buf)))}return e.concat()};D.fromASM=function(e){var t=new D;t.chunks=[];for(var r=e.split(" "),n=0;n<r.length;){var i=r[n],o=Z(i),s=o.toNumber();if(i==="0")s=0,t.chunks.push({opcodenum:s}),n=n+1;else if(i==="-1")s=Z.OP_1NEGATE,t.chunks.push({opcodenum:s}),n=n+1;else if(Ae.isUndefined(s)){var a=d.Buffer.from(r[n],"hex");if(a.toString("hex")!==r[n])throw new Error("invalid hex string in script");var c=a.length;c>=0&&c<Z.OP_PUSHDATA1?s=c:c<Math.pow(2,8)?s=Z.OP_PUSHDATA1:c<Math.pow(2,16)?s=Z.OP_PUSHDATA2:c<Math.pow(2,32)&&(s=Z.OP_PUSHDATA4),t.chunks.push({buf:a,len:a.length,opcodenum:s}),n=n+1}else t.chunks.push({opcodenum:s}),n=n+1}return t};D.fromHex=function(e){return new D(i1.Buffer.from(e,"hex"))};D.fromString=function(e){if(g6.isHexa(e)||e.length===0)return new D(i1.Buffer.from(e,"hex"));var t=new D;t.chunks=[];for(var r=e.split(" "),n=0;n<r.length;){var i=r[n],o=Z(i),s=o.toNumber();if(Ae.isUndefined(s))if(s=parseInt(i),s>0&&s<Z.OP_PUSHDATA1)t.chunks.push({buf:d.Buffer.from(r[n+1].slice(2),"hex"),len:s,opcodenum:s}),n=n+2;else throw new Error("Invalid script: "+JSON.stringify(e));else if(s===Z.OP_PUSHDATA1||s===Z.OP_PUSHDATA2||s===Z.OP_PUSHDATA4){if(r[n+2].slice(0,2)!=="0x")throw new Error("Pushdata data must start with 0x");t.chunks.push({buf:d.Buffer.from(r[n+2].slice(2),"hex"),len:parseInt(r[n+1]),opcodenum:s}),n=n+3}else t.chunks.push({opcodenum:s}),n=n+1}return t};D.prototype._chunkToString=function(e,t){var r=e.opcodenum,n=t==="asm",i="";if(e.buf)!n&&(r===Z.OP_PUSHDATA1||r===Z.OP_PUSHDATA2||r===Z.OP_PUSHDATA4)&&(i=i+" "+Z(r).toString()),e.len>0&&(n?i=i+" "+e.buf.toString("hex"):i=i+" "+e.len+" 0x"+e.buf.toString("hex"));else if(typeof Z.reverseMap[r]<"u")n?r===0?i=i+" 0":r===79?i=i+" -1":i=i+" "+Z(r).toString():i=i+" "+Z(r).toString();else{var o=r.toString(16);o.length%2!==0&&(o="0"+o),n?i=i+" "+o:i=i+" 0x"+o}return i};D.prototype.toASM=function(){for(var e="",t=0;t<this.chunks.length;t++){var r=this.chunks[t];e+=this._chunkToString(r,"asm")}return e.substr(1)};D.prototype.toString=function(){for(var e="",t=0;t<this.chunks.length;t++){var r=this.chunks[t];e+=this._chunkToString(r)}return e.substr(1)};D.prototype.toHex=function(){return this.toBuffer().toString("hex")};D.prototype.inspect=function(){return"<Script: "+this.toString()+">"};D.prototype.isPublicKeyHashOut=function(){return!!(this.chunks.length===5&&this.chunks[0].opcodenum===Z.OP_DUP&&this.chunks[1].opcodenum===Z.OP_HASH160&&this.chunks[2].buf&&this.chunks[2].buf.length===20&&this.chunks[3].opcodenum===Z.OP_EQUALVERIFY&&this.chunks[4].opcodenum===Z.OP_CHECKSIG)};D.prototype.isPublicKeyHashOutPrefix=function(){return!!(this.chunks.length>=5&&this.chunks[0].opcodenum===Z.OP_DUP&&this.chunks[1].opcodenum===Z.OP_HASH160&&this.chunks[2].buf&&this.chunks[2].buf.length===20&&this.chunks[3].opcodenum===Z.OP_EQUALVERIFY&&this.chunks[4].opcodenum===Z.OP_CHECKSIG)};D.prototype.isPublicKeyHashIn=function(){if(this.chunks.length===2){var e=this.chunks[0].buf,t=this.chunks[1].buf;if(e&&e.length&&e[0]===48&&t&&t.length){var r=t[0];if((r===4||r===6||r===7)&&t.length===65)return!0;if((r===3||r===2)&&t.length===33)return!0}}return!1};D.prototype.getPublicKey=function(){return $e.checkState(this.isPublicKeyOut(),"Can't retrieve PublicKey from a non-PK output"),this.chunks[0].buf};D.prototype.getPublicKeyHash=function(){return $e.checkState(this.isPublicKeyHashOut(),"Can't retrieve PublicKeyHash from a non-PKH output"),this.chunks[2].buf};D.prototype.isPublicKeyOut=function(){if(this.chunks.length===2&&this.chunks[0].buf&&this.chunks[0].buf.length&&this.chunks[1].opcodenum===Z.OP_CHECKSIG){var e=this.chunks[0].buf,t=e[0],r=!1;if(((t===4||t===6||t===7)&&e.length===65||(t===3||t===2)&&e.length===33)&&(r=!0),r)return to.isValid(e)}return!1};D.prototype.isPublicKeyIn=function(){if(this.chunks.length===1){var e=this.chunks[0].buf;if(e&&e.length&&e[0]===48)return!0}return!1};D.prototype.isScriptHashOut=function(){var e=this.toBuffer();return e.length===23&&e[0]===Z.OP_HASH160&&e[1]===20&&e[e.length-1]===Z.OP_EQUAL};D.prototype.isScriptHashIn=function(){if(this.chunks.length<=1)return!1;var e=this.chunks[this.chunks.length-1],t=e.buf;if(!t)return!1;var r;try{r=D.fromBuffer(t)}catch(i){if(i instanceof cp.Script.InvalidBuffer)return!1;throw i}var n=r.classify();return n!==D.types.UNKNOWN};D.prototype.isMultisigOut=function(){return this.chunks.length>3&&Z.isSmallIntOp(this.chunks[0].opcodenum)&&this.chunks.slice(1,this.chunks.length-2).every(function(e){return e.buf&&d.Buffer.isBuffer(e.buf)})&&Z.isSmallIntOp(this.chunks[this.chunks.length-2].opcodenum)&&this.chunks[this.chunks.length-1].opcodenum===Z.OP_CHECKMULTISIG};D.prototype.isMultisigIn=function(){return this.chunks.length>=2&&this.chunks[0].opcodenum===0&&this.chunks.slice(1,this.chunks.length).every(function(e){return e.buf&&d.Buffer.isBuffer(e.buf)&&eo.isTxDER(e.buf)})};D.prototype.isDataOut=function(){var e=this.chunks.length>=1&&this.chunks[0].opcodenum===Z.OP_RETURN;if(!e)return!1;var t=this.chunks.slice(1),r=new D({chunks:t});return r.isPushOnly()};D.prototype.isSafeDataOut=function(){if(this.chunks.length<2||this.chunks[0].opcodenum!==Z.OP_FALSE)return!1;var e=this.chunks.slice(1),t=new D({chunks:e});return t.isDataOut()};D.prototype.getData=function(){if(this.isSafeDataOut()){var e=this.chunks.slice(2),t=e.map(r=>r.buf);return t}if(this.isDataOut()||this.isScriptHashOut())return Ae.isUndefined(this.chunks[1])?d.Buffer.alloc(0):d.Buffer.from(this.chunks[1].buf);if(this.isPublicKeyHashOut())return d.Buffer.from(this.chunks[2].buf);throw new Error("Unrecognized script type to get data from")};D.prototype.isPushOnly=function(){return Ae.every(this.chunks,function(e){return e.opcodenum<=Z.OP_16||e.opcodenum===Z.OP_PUSHDATA1||e.opcodenum===Z.OP_PUSHDATA2||e.opcodenum===Z.OP_PUSHDATA4})};D.types={};D.types.UNKNOWN="Unknown";D.types.PUBKEY_OUT="Pay to public key";D.types.PUBKEY_IN="Spend from public key";D.types.PUBKEYHASH_OUT="Pay to public key hash";D.types.PUBKEYHASH_IN="Spend from public key hash";D.types.SCRIPTHASH_OUT="Pay to script hash";D.types.SCRIPTHASH_IN="Spend from script hash";D.types.MULTISIG_OUT="Pay to multisig";D.types.MULTISIG_IN="Spend from multisig";D.types.DATA_OUT="Data push";D.types.SAFE_DATA_OUT="Safe data push";D.OP_RETURN_STANDARD_SIZE=220;D.prototype.classify=function(){if(this._isInput)return this.classifyInput();if(this._isOutput)return this.classifyOutput();var e=this.classifyOutput();return e!==D.types.UNKNOWN?e:this.classifyInput()};D.outputIdentifiers={};D.outputIdentifiers.PUBKEY_OUT=D.prototype.isPublicKeyOut;D.outputIdentifiers.PUBKEYHASH_OUT=D.prototype.isPublicKeyHashOut;D.outputIdentifiers.MULTISIG_OUT=D.prototype.isMultisigOut;D.outputIdentifiers.SCRIPTHASH_OUT=D.prototype.isScriptHashOut;D.outputIdentifiers.DATA_OUT=D.prototype.isDataOut;D.outputIdentifiers.SAFE_DATA_OUT=D.prototype.isSafeDataOut;D.prototype.classifyOutput=function(){for(var e in D.outputIdentifiers)if(D.outputIdentifiers[e].bind(this)())return D.types[e];return D.types.UNKNOWN};D.inputIdentifiers={};D.inputIdentifiers.PUBKEY_IN=D.prototype.isPublicKeyIn;D.inputIdentifiers.PUBKEYHASH_IN=D.prototype.isPublicKeyHashIn;D.inputIdentifiers.MULTISIG_IN=D.prototype.isMultisigIn;D.inputIdentifiers.SCRIPTHASH_IN=D.prototype.isScriptHashIn;D.prototype.classifyInput=function(){for(var e in D.inputIdentifiers)if(D.inputIdentifiers[e].bind(this)())return D.types[e];return D.types.UNKNOWN};D.prototype.isStandard=function(){return this.classify()!==D.types.UNKNOWN};D.prototype.prepend=function(e){return this._addByType(e,!0),this};D.prototype.equals=function(e){if($e.checkState(e instanceof D,"Must provide another script"),this.chunks.length!==e.chunks.length)return!1;var t;for(t=0;t<this.chunks.length;t++){if(d.Buffer.isBuffer(this.chunks[t].buf)&&!d.Buffer.isBuffer(e.chunks[t].buf)||d.Buffer.isBuffer(this.chunks[t].buf)&&!this.chunks[t].buf.equals(e.chunks[t].buf))return!1;if(this.chunks[t].opcodenum!==e.chunks[t].opcodenum)return!1}return!0};D.prototype.add=function(e){return this._addByType(e,!1),this};D.prototype._addByType=function(e,t){if(typeof e=="string")this._addOpcode(e,t);else if(typeof e=="number")this._addOpcode(e,t);else if(e instanceof Z)this._addOpcode(e,t);else if(d.Buffer.isBuffer(e))this._addBuffer(e,t);else if(e instanceof D)this.chunks=this.chunks.concat(e.chunks);else if(typeof e=="object")this._insertAtPosition(e,t);else throw new Error("Invalid script chunk")};D.prototype._insertAtPosition=function(e,t){t?this.chunks.unshift(e):this.chunks.push(e)};D.prototype._addOpcode=function(e,t){var r;return typeof e=="number"?r=e:e instanceof Z?r=e.toNumber():r=Z(e).toNumber(),this._insertAtPosition({opcodenum:r},t),this};D.prototype._addBuffer=function(e,t){var r,n=e.length;if(n>=0&&n<Z.OP_PUSHDATA1)r=n;else if(n<Math.pow(2,8))r=Z.OP_PUSHDATA1;else if(n<Math.pow(2,16))r=Z.OP_PUSHDATA2;else if(n<Math.pow(2,32))r=Z.OP_PUSHDATA4;else throw new Error("You can't push that much data");return this._insertAtPosition({buf:e,len:n,opcodenum:r},t),this};D.prototype.removeCodeseparators=function(){for(var e=[],t=0;t<this.chunks.length;t++)this.chunks[t].opcodenum!==Z.OP_CODESEPARATOR&&e.push(this.chunks[t]);return this.chunks=e,this};D.buildMultisigOut=function(e,t,r){$e.checkArgument(t<=e.length,"Number of required signatures must be less than or equal to the number of public keys"),r=r||{};var n=new D;n.add(Z.smallInt(t)),e=Ae.map(e,to);var i=e;r.noSorting||(i=e.map(a=>a.toString("hex")).sort().map(a=>new to(a)));for(var o=0;o<i.length;o++){var s=i[o];n.add(s.toBuffer())}return n.add(Z.smallInt(e.length)),n.add(Z.OP_CHECKMULTISIG),n};D.buildMultisigIn=function(e,t,r,n){$e.checkArgument(Ae.isArray(e)),$e.checkArgument(Ae.isNumber(t)),$e.checkArgument(Ae.isArray(r)),n=n||{};var i=new D;return i.add(Z.OP_0),Ae.each(r,function(o){$e.checkArgument(d.Buffer.isBuffer(o),"Signatures must be an array of Buffers"),i.add(o)}),i};D.buildP2SHMultisigIn=function(e,t,r,n){$e.checkArgument(Ae.isArray(e)),$e.checkArgument(Ae.isNumber(t)),$e.checkArgument(Ae.isArray(r)),n=n||{};var i=new D;return i.add(Z.OP_0),Ae.each(r,function(o){$e.checkArgument(d.Buffer.isBuffer(o),"Signatures must be an array of Buffers"),i.add(o)}),i.add((n.cachedMultisig||D.buildMultisigOut(e,t,n)).toBuffer()),i};D.buildPublicKeyHashOut=function(e){$e.checkArgument(!Ae.isUndefined(e)),$e.checkArgument(e instanceof to||e instanceof Hr||Ae.isString(e)),e instanceof to?e=e.toAddress():Ae.isString(e)&&(e=new Hr(e));var t=new D;return t.add(Z.OP_DUP).add(Z.OP_HASH160).add(e.hashBuffer).add(Z.OP_EQUALVERIFY).add(Z.OP_CHECKSIG),t._network=e.network,t};D.buildPublicKeyOut=function(e){$e.checkArgument(e instanceof to);var t=new D;return t.add(e.toBuffer()).add(Z.OP_CHECKSIG),t};D.buildDataOut=function(e,t){$e.checkArgument(Ae.isUndefined(e)||Ae.isString(e)||Ae.isArray(e)||d.Buffer.isBuffer(e));var r=e;Ae.isArray(r)||(r=[e]);var n=new D;n.add(Z.OP_RETURN);for(let i of r)$e.checkArgument(Ae.isUndefined(i)||Ae.isString(i)||d.Buffer.isBuffer(i)),Ae.isString(i)&&(i=d.Buffer.from(i,t)),Ae.isUndefined(i)||n.add(i);return n};D.buildSafeDataOut=function(e,t){var r=D.buildDataOut(e,t),n=new D;return n.add(Z.OP_FALSE),n.add(r),n};D.buildScriptHashOut=function(e){$e.checkArgument(e instanceof D||e instanceof Hr&&e.isPayToScriptHash());var t=new D;return t.add(Z.OP_HASH160).add(e instanceof Hr?e.hashBuffer:fp.sha256ripemd160(e.toBuffer())).add(Z.OP_EQUAL),t._network=e._network||e.network,t};D.buildPublicKeyIn=function(e,t){$e.checkArgument(e instanceof eo||d.Buffer.isBuffer(e)),$e.checkArgument(Ae.isUndefined(t)||Ae.isNumber(t)),e instanceof eo&&(e=e.toBuffer());var r=new D;return r.add(d.Buffer.concat([e,d.Buffer.from([(t||eo.SIGHASH_ALL)&255])])),r};D.buildPublicKeyHashIn=function(e,t,r){$e.checkArgument(t instanceof eo||d.Buffer.isBuffer(t)),$e.checkArgument(Ae.isUndefined(r)||Ae.isNumber(r)),t instanceof eo&&(t=t.toBuffer());var n=new D().add(d.Buffer.concat([t,d.Buffer.from([(r||eo.SIGHASH_ALL)&255])])).add(new to(e).toBuffer());return n};D.empty=function(){return new D};D.prototype.toScriptHashOut=function(){return D.buildScriptHashOut(this)};D.fromAddress=function(e){if(e=Hr(e),e.isPayToScriptHash())return D.buildScriptHashOut(e);if(e.isPayToPublicKeyHash())return D.buildPublicKeyHashOut(e);throw new cp.Script.UnrecognizedAddress(e)};D.prototype.getAddressInfo=function(e){if(this._isInput)return this._getInputAddressInfo();if(this._isOutput)return this._getOutputAddressInfo();var t=this._getOutputAddressInfo();return t||this._getInputAddressInfo()};D.prototype._getOutputAddressInfo=function(){var e={};if(this.isScriptHashOut())e.hashBuffer=this.getData(),e.type=Hr.PayToScriptHash;else if(this.isPublicKeyHashOut())e.hashBuffer=this.getData(),e.type=Hr.PayToPublicKeyHash;else return!1;return e};D.prototype._getInputAddressInfo=function(){var e={};if(this.isPublicKeyHashIn())e.hashBuffer=fp.sha256ripemd160(this.chunks[1].buf),e.type=Hr.PayToPublicKeyHash;else if(this.isScriptHashIn())e.hashBuffer=fp.sha256ripemd160(this.chunks[this.chunks.length-1].buf),e.type=Hr.PayToScriptHash;else return!1;return e};D.prototype.toAddress=function(e){var t=this.getAddressInfo();return t?(t.network=n1.get(e)||this._network||n1.defaultNetwork,new Hr(t)):!1};D.prototype.findAndDelete=function(e){for(var t=e.toBuffer(),r=t.toString("hex"),n=0;n<this.chunks.length;n++){var i=D({chunks:[this.chunks[n]]}),o=i.toBuffer(),s=o.toString("hex");r===s&&this.chunks.splice(n,1)}return this};D.prototype.checkMinimalPush=function(e){var t=this.chunks[e],r=t.buf,n=t.opcodenum;return r?r.length===0?n===Z.OP_0:r.length===1&&r[0]>=1&&r[0]<=16?n===Z.OP_1+(r[0]-1):r.length===1&&r[0]===129?n===Z.OP_1NEGATE:r.length<=75?n===r.length:r.length<=255?n===Z.OP_PUSHDATA1:r.length<=65535?n===Z.OP_PUSHDATA2:!0:!0};D.prototype._decodeOP_N=function(e){if(e===Z.OP_0)return 0;if(e>=Z.OP_1&&e<=Z.OP_16)return e-(Z.OP_1-1);throw new Error("Invalid opcode: "+JSON.stringify(e))};D.prototype.getSignatureOperationsCount=function(e){e=Ae.isUndefined(e)?!0:e;var t=this,r=0,n=Z.OP_INVALIDOPCODE;return Ae.each(t.chunks,function(o){var s=o.opcodenum;s===Z.OP_CHECKSIG||s===Z.OP_CHECKSIGVERIFY?r++:(s===Z.OP_CHECKMULTISIG||s===Z.OP_CHECKMULTISIGVERIFY)&&(e&&n>=Z.OP_1&&n<=Z.OP_16?r+=t._decodeOP_N(n):r+=20),n=s}),r};o1.exports=D});var Ma=P((CF,u1)=>{"use strict";y();var s1=Ji(),a1=va(),y6=Er(),jr=function e(t){if(!(this instanceof e))return new e(t);if(d.Buffer.isBuffer(t))this.buf=t;else if(typeof t=="number"){var r=t;this.fromNumber(r)}else if(t instanceof y6){var n=t;this.fromBN(n)}else if(t){var i=t;this.set(i)}};jr.prototype.set=function(e){return this.buf=e.buf||this.buf,this};jr.prototype.fromString=function(e){return this.set({buf:d.Buffer.from(e,"hex")}),this};jr.prototype.toString=function(){return this.buf.toString("hex")};jr.prototype.fromBuffer=function(e){return this.buf=e,this};jr.prototype.fromBufferReader=function(e){return this.buf=e.readVarintBuf(),this};jr.prototype.fromBN=function(e){return this.buf=s1().writeVarintBN(e).concat(),this};jr.prototype.fromNumber=function(e){return this.buf=s1().writeVarintNum(e).concat(),this};jr.prototype.toBuffer=function(){return this.buf};jr.prototype.toBN=function(){return a1(this.buf).readVarintBN()};jr.prototype.toNumber=function(){return a1(this.buf).readVarintNum()};u1.exports=jr});var Dn=P((DF,c1)=>{"use strict";y();var Ec=Ve(),hp=Er(),f1=Tt(),xc=pr(),m6=Ji(),v6=Ma(),dp=Kr(),pp=ke(),b6=Jn(),_6=9007199254740991;function Ut(e){if(!(this instanceof Ut))return new Ut(e);if(Ec.isObject(e))if(this.satoshis=e.satoshis,d.Buffer.isBuffer(e.script))this._scriptBuffer=e.script;else{var t;Ec.isString(e.script)&&xc.isHexa(e.script)?t=f1.Buffer.from(e.script,"hex"):t=e.script,this.setScript(t)}else throw new TypeError("Unrecognized argument for Output")}Object.defineProperty(Ut.prototype,"script",{configurable:!1,enumerable:!0,get:function(){return this._script?this._script:(this.setScriptFromBuffer(this._scriptBuffer),this._script)}});Object.defineProperty(Ut.prototype,"satoshis",{configurable:!1,enumerable:!0,get:function(){return this._satoshis},set:function(e){e instanceof hp?(this._satoshisBN=e,this._satoshis=e.toNumber()):Ec.isString(e)?(this._satoshis=parseInt(e),this._satoshisBN=hp.fromNumber(this._satoshis)):(pp.checkArgument(xc.isNaturalNumber(e),"Output satoshis is not a natural number"),this._satoshisBN=hp.fromNumber(e),this._satoshis=e),pp.checkState(xc.isNaturalNumber(this._satoshis),"Output satoshis is not a natural number")}});Ut.prototype.invalidSatoshis=function(){return this._satoshis>_6?"transaction txout satoshis greater than max safe integer":this._satoshis!==this._satoshisBN.toNumber()?"transaction txout satoshis has corrupted value":this._satoshis<0?"transaction txout negative":!1};Object.defineProperty(Ut.prototype,"satoshisBN",{configurable:!1,enumerable:!0,get:function(){return this._satoshisBN},set:function(e){this._satoshisBN=e,this._satoshis=e.toNumber(),pp.checkState(xc.isNaturalNumber(this._satoshis),"Output satoshis is not a natural number")}});Ut.prototype.toObject=Ut.prototype.toJSON=function(){var t={satoshis:this.satoshis};return t.script=this._scriptBuffer.toString("hex"),t};Ut.fromObject=function(e){return new Ut(e)};Ut.prototype.setScriptFromBuffer=function(e){this._scriptBuffer=e;try{this._script=dp.fromBuffer(this._scriptBuffer),this._script._isOutput=!0}catch(t){if(t instanceof b6.Script.InvalidBuffer)this._script=null;else throw t}};Ut.prototype.setScript=function(e){if(e instanceof dp)this._scriptBuffer=e.toBuffer(),this._script=e,this._script._isOutput=!0;else if(Ec.isString(e))this._script=dp.fromString(e),this._scriptBuffer=this._script.toBuffer(),this._script._isOutput=!0;else if(d.Buffer.isBuffer(e))this.setScriptFromBuffer(e);else throw new TypeError("Invalid argument type: script");return this};Ut.prototype.inspect=function(){var e;return this.script?e=this.script.inspect():e=this._scriptBuffer.toString("hex"),"<Output ("+this.satoshis+" sats) "+e+">"};Ut.fromBufferReader=function(e){var t={};t.satoshis=e.readUInt64LEBN();var r=e.readVarintNum();return r!==0?t.script=e.read(r):t.script=f1.Buffer.from([]),new Ut(t)};Ut.prototype.toBufferWriter=function(e){e||(e=new m6),e.writeUInt64LEBN(this._satoshisBN);var t=this._scriptBuffer;return e.writeVarintNum(t.length),e.write(t),e};Ut.prototype.getSize=function(){var e=this.script.toBuffer().length,t=v6(e).toBuffer().length;return 8+t+e};c1.exports=Ut});var ka=P((FF,l1)=>{"use strict";y();var gr=Er(),cn=ii(),w6=ir(),S6=Tr(),E6=ea(),hi=Qt(),x6=Ve(),gp=ke(),qe=function e(t){if(!(this instanceof e))return new e(t);t&&this.set(t)};Object.defineProperty(qe.prototype,"k",{get:function(){return this._k},set:function(e){this._k=e,this._kFresh=!0},enumerable:!0,configurable:!0});qe.prototype.set=function(e){if(this.hashbuf=e.hashbuf||this.hashbuf,this.endian=e.endian||this.endian,this.privkey=e.privkey||this.privkey,this.pubkey=e.pubkey||(this.privkey?this.privkey.publicKey:this.pubkey),e.sig)if(d.Buffer.isBuffer(e.sig)){var t=ir();this.sig=t.fromDER(e.sig)}else this.sig=e.sig;else this.sig=this.sig;return e.k&&(this.k=e.k),this.verified=e.verified||this.verified,this};qe.prototype.privkey2pubkey=function(){this.pubkey=this.privkey.toPublicKey()};qe.prototype.calci=function(){for(var e=0;e<4;e++){this.sig.i=e;var t;try{t=this.toPublicKey()}catch(r){console.error(r);continue}if(t.point.eq(this.pubkey.point))return this.sig.compressed=this.pubkey.compressed,this}throw this.sig.i=void 0,new Error("Unable to find valid recovery factor")};qe.fromString=function(e){var t=JSON.parse(e);return new qe(t)};qe.prototype.randomK=function(){var e=cn.getN(),t;do t=gr.fromBuffer(E6.getRandomBuffer(32));while(!(t.lt(e)&&t.gt(gr.Zero)));return this.k=t,this};qe.prototype.deterministicK=function(e){x6.isUndefined(e)&&(e=0);var t=d.Buffer.alloc(32);t.fill(1);var r=d.Buffer.alloc(32);r.fill(0);var n=this.privkey.bn.toBuffer({size:32}),i=this.endian==="little"?d.Buffer.from(this.hashbuf).reverse():this.hashbuf;r=hi.sha256hmac(d.Buffer.concat([t,d.Buffer.from([0]),n,i]),r),t=hi.sha256hmac(t,r),r=hi.sha256hmac(d.Buffer.concat([t,d.Buffer.from([1]),n,i]),r),t=hi.sha256hmac(t,r),t=hi.sha256hmac(t,r);for(var o=gr.fromBuffer(t),s=cn.getN(),a=0;a<e||!(o.lt(s)&&o.gt(gr.Zero));a++)r=hi.sha256hmac(d.Buffer.concat([t,d.Buffer.from([0])]),r),t=hi.sha256hmac(t,r),t=hi.sha256hmac(t,r),o=gr.fromBuffer(t);return this.k=o,this};qe.prototype.toPublicKey=function(){var e=this.sig.i;gp.checkArgument(e===0||e===1||e===2||e===3,new Error("i must be equal to 0, 1, 2, or 3"));var t=gr.fromBuffer(this.hashbuf),r=this.sig.r,n=this.sig.s,i=e&1,o=e>>1,s=cn.getN(),a=cn.getG(),c=o?r.add(s):r,h=cn.fromX(i,c),g=h.mul(s);if(!g.isInfinity())throw new Error("nR is not a valid curve point");var m=t.neg().umod(s),_=r.invm(s),I=h.mul(n).add(a.mul(m)).mul(_),R=S6.fromPoint(I,this.sig.compressed);return R};qe.prototype.sigError=function(){if(!d.Buffer.isBuffer(this.hashbuf)||this.hashbuf.length!==32)return"hashbuf must be a 32 byte buffer";var e=this.sig.r,t=this.sig.s,r=cn.getN();try{if(e.lte(gr.Zero)||t.lte(gr.Zero)||e.gte(r)||t.gte(r))return"r and s not in range";var n=gr.fromBuffer(this.hashbuf,this.endian?{endian:this.endian}:void 0),i=t.invm(r),o=i.mul(n).umod(r),s=i.mul(e).umod(r),a=cn.getG().mulAdd(o,this.pubkey.point,s);return a.isInfinity()?"p is infinity":a.getX().umod(r).cmp(e)!==0?"Invalid signature":!1}catch(c){return"Signature security validation failed: "+c.message}};qe.toLowS=function(e){return e.gt(gr.fromBuffer(d.Buffer.from("7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0","hex")))&&(e=cn.getN().sub(e)),e};qe.prototype._findSignature=function(e,t){var r=cn.getN(),n=cn.getG(),i=0,o,s,a,c;do(!this.k||!this._kFresh||i>0)&&this.deterministicK(i),i++,o=this.k,s=n.mul(o),a=s.x.umod(r),c=o.invm(r).mul(t.add(e.mul(a))).umod(r);while(a.cmp(gr.Zero)<=0||c.cmp(gr.Zero)<=0);return this._kFresh=!1,c=qe.toLowS(c),{s:c,r:a}};qe.prototype.sign=function(){var e=this.hashbuf,t=this.privkey,r=t.bn;gp.checkState(e&&t&&r,new Error("invalid parameters")),gp.checkState(d.Buffer.isBuffer(e)&&e.length===32,new Error("hashbuf must be a 32 byte buffer"));var n=gr.fromBuffer(e,this.endian?{endian:this.endian}:void 0),i=this._findSignature(r,n);return i.compressed=this.pubkey.compressed,this.sig=new w6(i),this};qe.prototype.signRandomK=function(){return this.randomK(),this.sign()};qe.prototype.toString=function(){var e={};return this.hashbuf&&(e.hashbuf=this.hashbuf.toString("hex")),this.privkey&&(e.privkey=this.privkey.toString()),this.pubkey&&(e.pubkey=this.pubkey.toString()),this.sig&&(e.sig=this.sig.toString()),this.k&&(e.k=this.k.toString()),JSON.stringify(e)};qe.prototype.verify=function(){return this.verified=!this.sigError(),this.verified};qe.prototype.verifyBool=function(){return this.verify()===!0};qe.sign=function(e,t,r){return qe().set({hashbuf:e,endian:r,privkey:t}).sign().sig};qe.signWithCalcI=function(e,t,r){return qe().set({hashbuf:e,endian:r,privkey:t}).sign().calci().sig};qe.signRandomK=function(e,t,r){return qe().set({hashbuf:e,endian:r,privkey:t}).signRandomK().sig};qe.verify=function(e,t,r,n){return qe().set({hashbuf:e,endian:n,sig:t,pubkey:r}).verify()};l1.exports=qe});var os=P((HF,g1)=>{"use strict";y();var di=Ve(),I6=ke(),Ca=Jn(),A6=Ji(),yp=Tt(),d1=pr(),Ic=Kr(),O6=pi(),h1=Dn(),Ac=4294967295,R6=Ac-2,p1=Ac,T6=Ac-1;function He(e){if(!(this instanceof He))return new He(e);if(e)return this._fromObject(e)}He.MAXINT=Ac;He.DEFAULT_SEQNUMBER=p1;He.DEFAULT_LOCKTIME_SEQNUMBER=T6;He.DEFAULT_RBF_SEQNUMBER=R6;He.BASE_SIZE=40;Object.defineProperty(He.prototype,"script",{configurable:!1,enumerable:!0,get:function(){return this.isNull()?null:(this._script||(this._script=new Ic(this._scriptBuffer),this._script._isInput=!0),this._script)}});He.fromObject=function(e){I6.checkArgument(di.isObject(e));var t=new He;return t._fromObject(e)};He.prototype._fromObject=function(e){var t;if(di.isString(e.prevTxId)&&d1.isHexa(e.prevTxId)?t=yp.Buffer.from(e.prevTxId,"hex"):t=e.prevTxId,this.output=e.output?e.output instanceof h1?e.output:new h1(e.output):void 0,this.prevTxId=t||e.txidbuf,this.outputIndex=di.isUndefined(e.outputIndex)?e.txoutnum:e.outputIndex,this.sequenceNumber=di.isUndefined(e.sequenceNumber)?di.isUndefined(e.seqnum)?p1:e.seqnum:e.sequenceNumber,di.isUndefined(e.script)&&di.isUndefined(e.scriptBuffer))throw new Ca.Transaction.Input.MissingScript;return this.setScript(e.scriptBuffer||e.script),this};He.prototype.toObject=He.prototype.toJSON=function(){var t={prevTxId:this.prevTxId.toString("hex"),outputIndex:this.outputIndex,sequenceNumber:this.sequenceNumber,script:this._scriptBuffer.toString("hex")};return this.script&&(t.scriptString=this.script.toString()),this.output&&(t.output=this.output.toObject()),t};He.fromBufferReader=function(e){var t=new He;return t.prevTxId=e.readReverse(32),t.outputIndex=e.readUInt32LE(),t._scriptBuffer=e.readVarLengthBuffer(),t.sequenceNumber=e.readUInt32LE(),t};He.prototype.toBufferWriter=function(e){e||(e=new A6),e.writeReverse(this.prevTxId),e.writeUInt32LE(this.outputIndex);var t=this._scriptBuffer;return e.writeVarintNum(t.length),e.write(t),e.writeUInt32LE(this.sequenceNumber),e};He.prototype.setScript=function(e){if(this._script=null,e instanceof Ic)this._script=e,this._script._isInput=!0,this._scriptBuffer=e.toBuffer();else if(e===null)this._script=Ic.empty(),this._script._isInput=!0,this._scriptBuffer=this._script.toBuffer();else if(d1.isHexa(e))this._scriptBuffer=yp.Buffer.from(e,"hex");else if(di.isString(e))this._script=new Ic(e),this._script._isInput=!0,this._scriptBuffer=this._script.toBuffer();else if(d.Buffer.isBuffer(e))this._scriptBuffer=yp.Buffer.from(e);else throw new TypeError("Invalid argument type: script");return this};He.prototype.getSignatures=function(){throw new Ca.AbstractMethodInvoked("Trying to sign unsupported output type (only P2PKH and P2SH multisig inputs are supported) for input: "+JSON.stringify(this))};He.prototype.isFullySigned=function(){throw new Ca.AbstractMethodInvoked("Input#isFullySigned")};He.prototype.isFinal=function(){return this.sequenceNumber===He.MAXINT};He.prototype.addSignature=function(){throw new Ca.AbstractMethodInvoked("Input#addSignature")};He.prototype.clearSignatures=function(){throw new Ca.AbstractMethodInvoked("Input#clearSignatures")};He.prototype.isValidSignature=function(e,t){return t.signature.nhashtype=t.sigtype,O6.verify(e,t.signature,t.publicKey,t.inputIndex,this.output.script,this.output.satoshisBN)};He.prototype.isNull=function(){return this.prevTxId.toString("hex")==="0000000000000000000000000000000000000000000000000000000000000000"&&this.outputIndex===4294967295};He.prototype._estimateSize=function(){return this.toBufferWriter().toBuffer().length};g1.exports=He});var ss=P((KF,y1)=>{"use strict";y();y1.exports=function(t,r){r&&(t.super_=r,t.prototype=Object.create(r.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}))}});var us=P((GF,b1)=>{"use strict";y();var as=Ve(),Pr=ke(),P6=ss(),m1=pr(),v1=Tr(),B6=Jn(),La=ir();function Vr(e){if(!(this instanceof Vr))return new Vr(e);if(e instanceof Vr)return e;if(as.isObject(e))return this._fromObject(e);throw new B6.InvalidArgument("TransactionSignatures must be instantiated from an object")}P6(Vr,La);Vr.prototype._fromObject=function(e){return this._checkObjectArgs(e),this.publicKey=new v1(e.publicKey),this.prevTxId=d.Buffer.isBuffer(e.prevTxId)?e.prevTxId:d.Buffer.from(e.prevTxId,"hex"),this.outputIndex=e.outputIndex,this.inputIndex=e.inputIndex,this.signature=e.signature instanceof La?e.signature:d.Buffer.isBuffer(e.signature)?La.fromBuffer(e.signature):La.fromString(e.signature),this.sigtype=e.sigtype,this};Vr.prototype._checkObjectArgs=function(e){Pr.checkArgument(v1(e.publicKey),"publicKey"),Pr.checkArgument(!as.isUndefined(e.inputIndex),"inputIndex"),Pr.checkArgument(!as.isUndefined(e.outputIndex),"outputIndex"),Pr.checkState(as.isNumber(e.inputIndex),"inputIndex must be a number"),Pr.checkState(as.isNumber(e.outputIndex),"outputIndex must be a number"),Pr.checkArgument(e.signature,"signature"),Pr.checkArgument(e.prevTxId,"prevTxId"),Pr.checkState(e.signature instanceof La||d.Buffer.isBuffer(e.signature)||m1.isHexa(e.signature),"signature must be a buffer or hexa value"),Pr.checkState(d.Buffer.isBuffer(e.prevTxId)||m1.isHexa(e.prevTxId),"prevTxId must be a buffer or hexa value"),Pr.checkArgument(e.sigtype,"sigtype"),Pr.checkState(as.isNumber(e.sigtype),"sigtype must be a number")};Vr.prototype.toObject=Vr.prototype.toJSON=function(){return{publicKey:this.publicKey.toString(),prevTxId:this.prevTxId.toString("hex"),outputIndex:this.outputIndex,inputIndex:this.inputIndex,signature:this.signature.toString(),sigtype:this.sigtype}};Vr.fromObject=function(e){return Pr.checkArgument(e),new Vr(e)};b1.exports=Vr});var x1=P((zF,E1)=>{"use strict";y();var N6=ss(),w1=ke(),mp=os(),M6=Dn(),k6=pi(),S1=Kr(),_1=ir(),C6=us();function Un(){mp.apply(this,arguments)}N6(Un,mp);Un.prototype.getSignatures=function(e,t,r,n){w1.checkState(this.output instanceof M6),n=n||_1.SIGHASH_ALL|_1.SIGHASH_FORKID;var i=t.toPublicKey();return i.toString()===this.output.script.getPublicKey().toString("hex")?[new C6({publicKey:i,prevTxId:this.prevTxId,outputIndex:this.outputIndex,inputIndex:r,signature:k6.sign(e,t,n,r,this.output.script,this.output.satoshisBN),sigtype:n})]:[]};Un.prototype.addSignature=function(e,t){return w1.checkState(this.isValidSignature(e,t),"Signature is invalid"),this.setScript(S1.buildPublicKeyIn(t.signature.toDER(),t.sigtype)),this};Un.prototype.clearSignatures=function(){return this.setScript(S1.empty()),this};Un.prototype.isFullySigned=function(){return this.script.isPublicKeyIn()};Un.SCRIPT_MAX_SIZE=74;Un.prototype._estimateSize=function(){return mp.BASE_SIZE+Un.SCRIPT_MAX_SIZE};E1.exports=Un});var T1=P(($F,R1)=>{"use strict";y();var L6=ss(),A1=ke(),D6=Qt(),vp=os(),U6=Dn(),F6=pi(),O1=Kr(),I1=ir(),q6=us();function Fn(){vp.apply(this,arguments)}L6(Fn,vp);Fn.prototype.getSignatures=function(e,t,r,n,i){A1.checkState(this.output instanceof U6),i=i||D6.sha256ripemd160(t.publicKey.toBuffer()),n=n||I1.SIGHASH_ALL|I1.SIGHASH_FORKID;var o=this.output.script.chunks[2]&&this.output.script.chunks[2].buf;return o&&i.equals(o)?[new q6({publicKey:t.publicKey,prevTxId:this.prevTxId,outputIndex:this.outputIndex,inputIndex:r,signature:F6.sign(e,t,n,r,this.output.script,this.output.satoshisBN),sigtype:n})]:[]};Fn.prototype.addSignature=function(e,t){return A1.checkState(this.isValidSignature(e,t),"Signature is invalid"),this.setScript(O1.buildPublicKeyHashIn(t.publicKey,t.signature.toDER(),t.sigtype)),this};Fn.prototype.clearSignatures=function(){return this.setScript(O1.empty()),this};Fn.prototype.isFullySigned=function(){return this.script.isPublicKeyHashIn()};Fn.SCRIPT_MAX_SIZE=108;Fn.prototype._estimateSize=function(){return vp.BASE_SIZE+Fn.SCRIPT_MAX_SIZE};R1.exports=Fn});var N1=P((XF,B1)=>{"use strict";y();var Gr=Ve(),H6=ss(),Rc=os(),j6=Dn(),Da=ke(),P1=Kr(),Oc=ir(),bp=pi(),_p=us(),K6=Tr(),V6=Ma();function Pt(e,t,r,n){Rc.apply(this,arguments);var i=this;t=t||e.publicKeys,r=r||e.threshold,n=n||e.signatures,this.publicKeys=t.map(o=>o.toString("hex")).sort().map(o=>new K6(o)),Da.checkState(P1.buildMultisigOut(this.publicKeys,r).equals(this.output.script),"Provided public keys don't match to the provided output script"),this.publicKeyIndex={},Gr.each(this.publicKeys,function(o,s){i.publicKeyIndex[o.toString()]=s}),this.threshold=r,this.signatures=n?this._deserializeSignatures(n):new Array(this.publicKeys.length)}H6(Pt,Rc);Pt.prototype.toObject=function(){var e=Rc.prototype.toObject.apply(this,arguments);return e.threshold=this.threshold,e.publicKeys=Gr.map(this.publicKeys,function(t){return t.toString()}),e.signatures=this._serializeSignatures(),e};Pt.prototype._deserializeSignatures=function(e){return Gr.map(e,function(t){if(t)return new _p(t)})};Pt.prototype._serializeSignatures=function(){return Gr.map(this.signatures,function(e){if(e)return e.toObject()})};Pt.prototype.getSignatures=function(e,t,r,n){Da.checkState(this.output instanceof j6),n=n||Oc.SIGHASH_ALL|Oc.SIGHASH_FORKID;var i=this,o=[];return Gr.each(this.publicKeys,function(s){s.toString()===t.publicKey.toString()&&o.push(new _p({publicKey:t.publicKey,prevTxId:i.prevTxId,outputIndex:i.outputIndex,inputIndex:r,signature:bp.sign(e,t,n,r,i.output.script,i.output.satoshisBN),sigtype:n}))}),o};Pt.prototype.addSignature=function(e,t){return Da.checkState(!this.isFullySigned(),"All needed signatures have already been added"),Da.checkArgument(!Gr.isUndefined(this.publicKeyIndex[t.publicKey.toString()]),"Signature has no matching public key"),Da.checkState(this.isValidSignature(e,t)),this.signatures[this.publicKeyIndex[t.publicKey.toString()]]=t,this._updateScript(),this};Pt.prototype._updateScript=function(){return this.setScript(P1.buildMultisigIn(this.publicKeys,this.threshold,this._createSignatures())),this};Pt.prototype._createSignatures=function(){return Gr.map(Gr.filter(this.signatures,function(e){return!Gr.isUndefined(e)}),function(e){return d.Buffer.concat([e.signature.toDER(),d.Buffer.from([e.sigtype&255])])})};Pt.prototype.clearSignatures=function(){this.signatures=new Array(this.publicKeys.length),this._updateScript()};Pt.prototype.isFullySigned=function(){return this.countSignatures()===this.threshold};Pt.prototype.countMissingSignatures=function(){return this.threshold-this.countSignatures()};Pt.prototype.countSignatures=function(){return Gr.reduce(this.signatures,function(e,t){return e+!!t},0)};Pt.prototype.publicKeysWithoutSignature=function(){var e=this;return Gr.filter(this.publicKeys,function(t){return!e.signatures[e.publicKeyIndex[t.toString()]]})};Pt.prototype.isValidSignature=function(e,t){return t.signature.nhashtype=t.sigtype,bp.verify(e,t.signature,t.publicKey,t.inputIndex,this.output.script,this.output.satoshisBN)};Pt.normalizeSignatures=function(e,t,r,n,i){return i.map(function(o){var s=null;return n=n.filter(function(a){if(s)return!0;var c=new _p({signature:Oc.fromTxFormat(a),publicKey:o,prevTxId:t.prevTxId,outputIndex:t.outputIndex,inputIndex:r,sigtype:Oc.SIGHASH_ALL});c.signature.nhashtype=c.sigtype;var h=bp.verify(e,c.signature,c.publicKey,c.inputIndex,t.output.script);return h?(s=c,!1):!0}),s||null})};Pt.SIGNATURE_SIZE=73;Pt.prototype._estimateSize=function(){var e=1+this.threshold*Pt.SIGNATURE_SIZE;return Rc.BASE_SIZE+V6(e).toBuffer().length+e};B1.exports=Pt});var D1=P((QF,L1)=>{"use strict";y();var Wr=Ve(),G6=ss(),Tc=os(),W6=Dn(),Ua=ke(),wp=Kr(),M1=ir(),k1=pi(),C1=us(),z6=Tr(),Y6=Ma();function Ot(e,t,r,n){Tc.apply(this,arguments);var i=this;t=t||e.publicKeys,r=r||e.threshold,n=n||e.signatures,this.publicKeys=t.map(o=>o.toString("hex")).sort().map(o=>new z6(o)),this.redeemScript=wp.buildMultisigOut(this.publicKeys,r),Ua.checkState(wp.buildScriptHashOut(this.redeemScript).equals(this.output.script),"Provided public keys don't hash to the provided output"),this.publicKeyIndex={},Wr.each(this.publicKeys,function(o,s){i.publicKeyIndex[o.toString()]=s}),this.threshold=r,this.signatures=n?this._deserializeSignatures(n):new Array(this.publicKeys.length)}G6(Ot,Tc);Ot.prototype.toObject=function(){var e=Tc.prototype.toObject.apply(this,arguments);return e.threshold=this.threshold,e.publicKeys=Wr.map(this.publicKeys,function(t){return t.toString()}),e.signatures=this._serializeSignatures(),e};Ot.prototype._deserializeSignatures=function(e){return Wr.map(e,function(t){if(t)return new C1(t)})};Ot.prototype._serializeSignatures=function(){return Wr.map(this.signatures,function(e){if(e)return e.toObject()})};Ot.prototype.getSignatures=function(e,t,r,n){Ua.checkState(this.output instanceof W6),n=n||M1.SIGHASH_ALL|M1.SIGHASH_FORKID;var i=this,o=[];return Wr.each(this.publicKeys,function(s){s.toString()===t.publicKey.toString()&&o.push(new C1({publicKey:t.publicKey,prevTxId:i.prevTxId,outputIndex:i.outputIndex,inputIndex:r,signature:k1.sign(e,t,n,r,i.redeemScript,i.output.satoshisBN),sigtype:n}))}),o};Ot.prototype.addSignature=function(e,t){return Ua.checkState(!this.isFullySigned(),"All needed signatures have already been added"),Ua.checkArgument(!Wr.isUndefined(this.publicKeyIndex[t.publicKey.toString()]),"Signature has no matching public key"),Ua.checkState(this.isValidSignature(e,t)),this.signatures[this.publicKeyIndex[t.publicKey.toString()]]=t,this._updateScript(),this};Ot.prototype._updateScript=function(){return this.setScript(wp.buildP2SHMultisigIn(this.publicKeys,this.threshold,this._createSignatures(),{cachedMultisig:this.redeemScript})),this};Ot.prototype._createSignatures=function(){return Wr.map(Wr.filter(this.signatures,function(e){return!Wr.isUndefined(e)}),function(e){return d.Buffer.concat([e.signature.toDER(),d.Buffer.from([e.sigtype&255])])})};Ot.prototype.clearSignatures=function(){this.signatures=new Array(this.publicKeys.length),this._updateScript()};Ot.prototype.isFullySigned=function(){return this.countSignatures()===this.threshold};Ot.prototype.countMissingSignatures=function(){return this.threshold-this.countSignatures()};Ot.prototype.countSignatures=function(){return Wr.reduce(this.signatures,function(e,t){return e+!!t},0)};Ot.prototype.publicKeysWithoutSignature=function(){var e=this;return Wr.filter(this.publicKeys,function(t){return!e.signatures[e.publicKeyIndex[t.toString()]]})};Ot.prototype.isValidSignature=function(e,t){return t.signature.nhashtype=t.sigtype,k1.verify(e,t.signature,t.publicKey,t.inputIndex,this.redeemScript,this.output.satoshisBN)};Ot.SIGNATURE_SIZE=73;Ot.PUBKEY_SIZE=34;Ot.prototype._estimateSize=function(){var e=this.publicKeys.length*Ot.PUBKEY_SIZE,t=this.threshold*Ot.SIGNATURE_SIZE,r=3+e,n=r<=75?1:r<=255?2:3,i=t+1+n+r;return Tc.BASE_SIZE+Y6(i).toBuffer().length+i};L1.exports=Ot});var Pc=P((t5,fs)=>{y();fs.exports=os();fs.exports.PublicKey=x1();fs.exports.PublicKeyHash=T1();fs.exports.MultiSig=N1();fs.exports.MultiSigScriptHash=D1()});var pi=P((n5,j1)=>{"use strict";y();var $6=Tt(),fr=ir(),Sp=Kr(),Z6=Dn(),X6=va(),Fa=Ji(),U1=Er(),Bc=Qt(),F1=ka(),Ep=ke(),Nc=Mc(),gi=Ve(),q1=d.Buffer.from("0000000000000000000000000000000000000000000000000000000000000001","hex"),J6="ffffffffffffffff",Q6=Nc.SCRIPT_ENABLE_SIGHASH_FORKID,ek=function(e,t,r,n,i){var o=e.inputs[r];Ep.checkArgument(i instanceof U1,"For ForkId=0 signatures, satoshis or complete input must be provided");function s(N){var L=new Fa;gi.each(N.inputs,function(K){L.writeReverse(K.prevTxId),L.writeUInt32LE(K.outputIndex)});var q=L.toBuffer(),G=Bc.sha256sha256(q);return G}function a(N){var L=new Fa;gi.each(N.inputs,function(K){L.writeUInt32LE(K.sequenceNumber)});var q=L.toBuffer(),G=Bc.sha256sha256(q);return G}function c(N,L){var q=new Fa;gi.isUndefined(L)?gi.each(N.outputs,function(z){z.toBufferWriter(q)}):N.outputs[L].toBufferWriter(q);var G=q.toBuffer(),K=Bc.sha256sha256(G);return K}var h=d.Buffer.alloc(32),g=d.Buffer.alloc(32),m=d.Buffer.alloc(32);t&fr.SIGHASH_ANYONECANPAY||(h=s(e)),!(t&fr.SIGHASH_ANYONECANPAY)&&(t&31)!==fr.SIGHASH_SINGLE&&(t&31)!==fr.SIGHASH_NONE&&(g=a(e)),(t&31)!==fr.SIGHASH_SINGLE&&(t&31)!==fr.SIGHASH_NONE?m=c(e):(t&31)===fr.SIGHASH_SINGLE&&r<e.outputs.length&&(m=c(e,r));var _=new Fa;_.writeInt32LE(e.version),_.write(h),_.write(g),_.writeReverse(o.prevTxId),_.writeUInt32LE(o.outputIndex),_.writeVarintNum(n.toBuffer().length),_.write(n.toBuffer()),_.writeUInt64LEBN(i);var I=o.sequenceNumber;_.writeUInt32LE(I),_.write(m),_.writeUInt32LE(e.nLockTime),_.writeUInt32LE(t>>>0);var R=_.toBuffer();return R},H1=function(t,r,n,i,o,s){var a=Ip(),c=Pc();gi.isUndefined(s)&&(s=Q6);var h=a.shallowCopy(t);if(i=new Sp(i),s&Nc.SCRIPT_ENABLE_REPLAY_PROTECTION){var g=r>>8,m=16711680|g^57005;r=m<<8|r&255}if(!(r&fr.SIGHASH_CHRONICLE&&s&Nc.SCRIPT_ENABLE_CHRONICLE)){if(r&fr.SIGHASH_FORKID&&s&Nc.SCRIPT_ENABLE_SIGHASH_FORKID)return ek(h,r,n,i,o)}i.removeCodeseparators();var _;for(_=0;_<h.inputs.length;_++)h.inputs[_]=new c(h.inputs[_]).setScript(Sp.empty());if(h.inputs[n]=new c(h.inputs[n]).setScript(i),(r&31)===fr.SIGHASH_NONE||(r&31)===fr.SIGHASH_SINGLE)for(_=0;_<h.inputs.length;_++)_!==n&&(h.inputs[_].sequenceNumber=0);if((r&31)===fr.SIGHASH_NONE)h.outputs=[];else if((r&31)===fr.SIGHASH_SINGLE){if(n>=h.outputs.length)return q1;for(h.outputs.length=n+1,_=0;_<n;_++)h.outputs[_]=new Z6({satoshis:U1.fromBuffer($6.Buffer.from(J6,"hex")),script:Sp.empty()})}r&fr.SIGHASH_ANYONECANPAY&&(h.inputs=[h.inputs[n]]);var I=new Fa().write(h.toBuffer()).writeInt32LE(r).toBuffer();return I},xp=function(t,r,n,i,o,s){var a=H1(t,r,n,i,o,s);if(a.compare(q1)===0)return a;var c=Bc.sha256sha256(a);return c=new X6(c).readReverse(),c};function tk(e,t,r,n,i,o,s){var a=xp(e,r,n,i,o,s),c=F1.sign(a,t,"little").set({nhashtype:r});return c}function rk(e,t,r,n,i,o,s){Ep.checkArgument(!gi.isUndefined(e)),Ep.checkArgument(!gi.isUndefined(t)&&!gi.isUndefined(t.nhashtype));var a=xp(e,t.nhashtype,n,i,o,s);return F1.verify(a,t,r,"little")}j1.exports={sighashPreimage:H1,sighash:xp,sign:tk,verify:rk}});var Ap=P((o5,V1)=>{"use strict";y();var qn=Ve(),kc=ke(),K1=pr(),nk=Kr(),ik=ro();function Hn(e){if(!(this instanceof Hn))return new Hn(e);kc.checkArgument(qn.isObject(e),"Must provide an object from where to extract data");var t=e.address?new ik(e.address):void 0,r=e.txid?e.txid:e.txId;if(!r||!K1.isHexaString(r)||r.length>64)throw new Error("Invalid TXID in object",e);var n=qn.isUndefined(e.vout)?e.outputIndex:e.vout;if(!qn.isNumber(n))throw new Error("Invalid outputIndex, received "+n);kc.checkArgument(!qn.isUndefined(e.scriptPubKey)||!qn.isUndefined(e.script),"Must provide the scriptPubKey for that output!");var i=new nk(e.scriptPubKey||e.script);kc.checkArgument(!qn.isUndefined(e.amount)||!qn.isUndefined(e.satoshis),"Must provide an amount for the output");var o=qn.isUndefined(e.amount)?e.satoshis:Math.round(e.amount*1e8);kc.checkArgument(qn.isNumber(o),"Amount must be a number"),K1.defineImmutable(this,{address:t,txId:r,outputIndex:n,script:i,satoshis:o})}Hn.prototype.inspect=function(){return"<UnspentOutput: "+this.txId+":"+this.outputIndex+", satoshis: "+this.satoshis+", address: "+this.address+">"};Hn.prototype.toString=function(){return this.txId+":"+this.outputIndex};Hn.fromObject=function(e){return new Hn(e)};Hn.prototype.toObject=Hn.prototype.toJSON=function(){return{address:this.address?this.address.toString():void 0,txid:this.txId,vout:this.outputIndex,scriptPubKey:this.script.toBuffer().toString("hex"),amount:Number.parseFloat((this.satoshis/1e8).toFixed(8))}};V1.exports=Hn});var Ip=P((a5,J1)=>{"use strict";y();var ge=Ve(),Ft=ke(),ok=Tt(),Nt=Jn(),W1=pr(),z1=va(),sk=Ji(),G1=Ma(),Y1=Qt(),Lc=ir(),$1=pi(),ak=ro(),Z1=Ap(),Bt=Pc(),uk=Bt.PublicKeyHash,fk=Bt.PublicKey,ck=Bt.MultiSigScriptHash,lk=Bt.MultiSig,zr=Dn(),ln=Kr(),hk=no(),Cc=Er(),dk=Mc(),pk=dk.SCRIPT_ENABLE_SIGHASH_FORKID;function W(e){if(!(this instanceof W))return new W(e);if(this.inputs=[],this.outputs=[],this._inputAmount=void 0,this._outputAmount=void 0,e){if(e instanceof W)return W.shallowCopy(e);if(W1.isHexa(e))this.fromString(e);else if(d.Buffer.isBuffer(e))this.fromBuffer(e);else if(ge.isObject(e))this.fromObject(e);else throw new Nt.InvalidArgument("Must provide an object or string to deserialize a transaction")}else this._newTransaction()}var gk=1,yk=0,mk=1e6;W.DUST_AMOUNT=546;W.FEE_SECURITY_MARGIN=150;W.MAX_MONEY=21e6*1e8;W.NLOCKTIME_BLOCKHEIGHT_LIMIT=5e8;W.NLOCKTIME_MAX_VALUE=4294967295;W.FEE_PER_KB=500;W.CHANGE_OUTPUT_MAX_SIZE=62;W.shallowCopy=function(e){var t=new W(e.toBuffer());return t};var X1={configurable:!1,enumerable:!0,get:function(){return this._hash=new z1(this._getHash()).readReverse().toString("hex"),this._hash}};Object.defineProperty(W.prototype,"hash",X1);Object.defineProperty(W.prototype,"id",X1);var Op={configurable:!1,enumerable:!0,get:function(){return this._getInputAmount()}};Object.defineProperty(W.prototype,"inputAmount",Op);Op.get=function(){return this._getOutputAmount()};Object.defineProperty(W.prototype,"outputAmount",Op);W.prototype._getHash=function(){return Y1.sha256sha256(this.toBuffer())};W.prototype.serialize=function(e){return e===!0||e&&e.disableAll?this.uncheckedSerialize():this.checkedSerialize(e)};W.prototype.uncheckedSerialize=W.prototype.toString=function(){return this.toBuffer().toString("hex")};W.prototype.checkedSerialize=function(e){var t=this.getSerializationError(e);if(t)throw t.message+=" - For more information please see: https://bsv.io/api/lib/transaction#serialization-checks",t;return this.uncheckedSerialize()};W.prototype.invalidSatoshis=function(){for(var e=!1,t=0;t<this.outputs.length;t++)this.outputs[t].invalidSatoshis()&&(e=!0);return e};W.prototype.getSerializationError=function(e){if(e=e||{},this.invalidSatoshis())return new Nt.Transaction.InvalidSatoshis;var t=this._getUnspentValue(),r;return t<0?e.disableMoreOutputThanInput||(r=new Nt.Transaction.InvalidOutputAmountSum):r=this._hasFeeError(e,t),r||this._hasDustOutputs(e)||this._isMissingSignatures(e)};W.prototype._hasFeeError=function(e,t){if(!ge.isUndefined(this._fee)&&this._fee!==t)return new Nt.Transaction.FeeError.Different("Unspent value is "+t+" but specified fee is "+this._fee);if(!e.disableLargeFees){var r=Math.floor(W.FEE_SECURITY_MARGIN*this._estimateFee());if(t>r)return this._missingChange()?new Nt.Transaction.ChangeAddressMissing("Fee is too large and no change address was provided"):new Nt.Transaction.FeeError.TooLarge("expected less than "+r+" but got "+t)}};W.prototype._missingChange=function(){return!this._changeScript};W.prototype._hasDustOutputs=function(e){if(!e.disableDustOutputs){var t,r;for(t in this.outputs)if(r=this.outputs[t],r.satoshis<W.DUST_AMOUNT&&!r.script.isDataOut()&&!r.script.isSafeDataOut())return new Nt.Transaction.DustOutputs}};W.prototype._isMissingSignatures=function(e){if(!e.disableIsFullySigned&&!this.isFullySigned())return new Nt.Transaction.MissingSignatures};W.prototype.inspect=function(){return"<Transaction: "+this.uncheckedSerialize()+">"};W.prototype.toBuffer=function(){var e=new sk;return this.toBufferWriter(e).toBuffer()};W.prototype.toBufferWriter=function(e){return e.writeInt32LE(this.version),e.writeVarintNum(this.inputs.length),ge.each(this.inputs,function(t){t.toBufferWriter(e)}),e.writeVarintNum(this.outputs.length),ge.each(this.outputs,function(t){t.toBufferWriter(e)}),e.writeUInt32LE(this.nLockTime),e};W.prototype.fromBuffer=function(e){var t=new z1(e);return this.fromBufferReader(t)};W.prototype.fromBufferReader=function(e){Ft.checkArgument(!e.finished(),"No transaction data received");var t,r,n;for(this.version=e.readInt32LE(),r=e.readVarintNum(),t=0;t<r;t++){var i=Bt.fromBufferReader(e);this.inputs.push(i)}for(n=e.readVarintNum(),t=0;t<n;t++)this.outputs.push(zr.fromBufferReader(e));return this.nLockTime=e.readUInt32LE(),this};W.prototype.toObject=W.prototype.toJSON=function(){var t=[];this.inputs.forEach(function(i){t.push(i.toObject())});var r=[];this.outputs.forEach(function(i){r.push(i.toObject())});var n={hash:this.hash,version:this.version,inputs:t,outputs:r,nLockTime:this.nLockTime};return this._changeScript&&(n.changeScript=this._changeScript.toString()),ge.isUndefined(this._changeIndex)||(n.changeIndex=this._changeIndex),ge.isUndefined(this._fee)||(n.fee=this._fee),n};W.prototype.fromObject=function(t){Ft.checkArgument(ge.isObject(t)||t instanceof W);var r=this,n;return t instanceof W?n=t.toObject():n=t,ge.each(n.inputs,function(i){if(!i.output||!i.output.script){r.uncheckedAddInput(new Bt(i));return}var o=new ln(i.output.script),s;if(o.isPublicKeyHashOut())s=new Bt.PublicKeyHash(i);else if(o.isScriptHashOut()&&i.publicKeys&&i.threshold)s=new Bt.MultiSigScriptHash(i,i.publicKeys,i.threshold,i.signatures);else if(o.isPublicKeyOut())s=new Bt.PublicKey(i);else throw new Nt.Transaction.Input.UnsupportedScript(i.output.script);r.addInput(s)}),ge.each(n.outputs,function(i){r.addOutput(new zr(i))}),n.changeIndex&&(this._changeIndex=n.changeIndex),n.changeScript&&(this._changeScript=new ln(n.changeScript)),n.fee&&(this._fee=n.fee),this.nLockTime=n.nLockTime,this.version=n.version,this._checkConsistency(t),this};W.prototype._checkConsistency=function(e){ge.isUndefined(this._changeIndex)||(Ft.checkState(this._changeScript,"Change script is expected."),Ft.checkState(this.outputs[this._changeIndex],"Change index points to undefined output."),Ft.checkState(this.outputs[this._changeIndex].script.toString()===this._changeScript.toString(),"Change output has an unexpected script.")),e&&e.hash&&Ft.checkState(e.hash===this.hash,"Hash in object does not match transaction hash.")};W.prototype.lockUntilDate=function(e){if(Ft.checkArgument(e),ge.isNumber(e)&&e<W.NLOCKTIME_BLOCKHEIGHT_LIMIT)throw new Nt.Transaction.LockTimeTooEarly;ge.isDate(e)&&(e=e.getTime()/1e3);for(var t=0;t<this.inputs.length;t++)this.inputs[t].sequenceNumber===Bt.DEFAULT_SEQNUMBER&&(this.inputs[t].sequenceNumber=Bt.DEFAULT_LOCKTIME_SEQNUMBER);return this.nLockTime=e,this};W.prototype.lockUntilBlockHeight=function(e){if(Ft.checkArgument(ge.isNumber(e)),e>=W.NLOCKTIME_BLOCKHEIGHT_LIMIT)throw new Nt.Transaction.BlockHeightTooHigh;if(e<0)throw new Nt.Transaction.NLockTimeOutOfRange;for(var t=0;t<this.inputs.length;t++)this.inputs[t].sequenceNumber===Bt.DEFAULT_SEQNUMBER&&(this.inputs[t].sequenceNumber=Bt.DEFAULT_LOCKTIME_SEQNUMBER);return this.nLockTime=e,this};W.prototype.getLockTime=function(){return this.nLockTime?this.nLockTime<W.NLOCKTIME_BLOCKHEIGHT_LIMIT?this.nLockTime:new Date(1e3*this.nLockTime):null};W.prototype.fromString=function(e){this.fromBuffer(ok.Buffer.from(e,"hex"))};W.prototype._newTransaction=function(){this.version=gk,this.nLockTime=yk};W.prototype.from=function(e,t,r){if(ge.isArray(e)){var n=this;return ge.each(e,function(o){n.from(o,t,r)}),this}var i=ge.some(this.inputs,function(o){return o.prevTxId.toString("hex")===e.txId&&o.outputIndex===e.outputIndex});return i?this:(t&&r?this._fromMultisigUtxo(e,t,r):this._fromNonP2SH(e),this)};W.prototype._fromNonP2SH=function(e){var t;e=new Z1(e),e.script.isPublicKeyHashOutPrefix()?t=uk:e.script.isPublicKeyOut()?t=fk:t=Bt,this.addInput(new t({output:new zr({script:e.script,satoshis:e.satoshis}),prevTxId:e.txId,outputIndex:e.outputIndex,script:ln.empty()}))};W.prototype._fromMultisigUtxo=function(e,t,r){Ft.checkArgument(r<=t.length,"Number of required signatures must be greater than the number of public keys");var n;if(e=new Z1(e),e.script.isMultisigOut())n=lk;else if(e.script.isScriptHashOut())n=ck;else throw new Nt.Transaction.Input.UnsupportedScript(e.script.toString());this.addInput(new n({output:new zr({script:e.script,satoshis:e.satoshis}),prevTxId:e.txId,outputIndex:e.outputIndex,script:ln.empty()},t,r))};W.prototype.addInput=function(e,t,r){if(Ft.checkArgumentType(e,Bt,"input"),!e.output&&(ge.isUndefined(t)||ge.isUndefined(r)))throw new Nt.Transaction.NeedMoreInfo("Need information about the UTXO script and satoshis");return!e.output&&t&&!ge.isUndefined(r)&&(t=t instanceof ln?t:new ln(t),Ft.checkArgumentType(r,"number","satoshis"),e.output=new zr({script:t,satoshis:r})),this.uncheckedAddInput(e)};W.prototype.uncheckedAddInput=function(e){return Ft.checkArgumentType(e,Bt,"input"),this.inputs.push(e),this._inputAmount=void 0,this._updateChangeOutput(),this};W.prototype.hasAllUtxoInfo=function(){return ge.every(this.inputs.map(function(e){return!!e.output}))};W.prototype.fee=function(e){return Ft.checkArgument(ge.isNumber(e),"amount must be a number"),this._fee=e,this._updateChangeOutput(),this};W.prototype.feePerKb=function(e){return Ft.checkArgument(ge.isNumber(e),"amount must be a number"),this._feePerKb=e,this._updateChangeOutput(),this};W.prototype.change=function(e){return Ft.checkArgument(e,"address is required"),this._changeScript=ln.fromAddress(e),this._updateChangeOutput(),this};W.prototype.getChangeOutput=function(){return ge.isUndefined(this._changeIndex)?null:this.outputs[this._changeIndex]};W.prototype.to=function(e,t){if(ge.isArray(e)){var r=this;return ge.each(e,function(n){r.to(n.address,n.satoshis)}),this}return Ft.checkArgument(W1.isNaturalNumber(t),"Amount is expected to be a positive integer"),this.addOutput(new zr({script:ln(new ak(e)),satoshis:t})),this};W.prototype.addData=function(e){return this.addOutput(new zr({script:ln.buildDataOut(e),satoshis:0})),this};W.prototype.addSafeData=function(e){return this.addOutput(new zr({script:ln.buildSafeDataOut(e),satoshis:0})),this};W.prototype.addOutput=function(e){return Ft.checkArgumentType(e,zr,"output"),this._addOutput(e),this._updateChangeOutput(),this};W.prototype.clearOutputs=function(){return this.outputs=[],this._clearSignatures(),this._outputAmount=void 0,this._changeIndex=void 0,this._updateChangeOutput(),this};W.prototype._addOutput=function(e){this.outputs.push(e),this._outputAmount=void 0};W.prototype._getOutputAmount=function(){if(ge.isUndefined(this._outputAmount)){var e=this;this._outputAmount=0,ge.each(this.outputs,function(t){e._outputAmount+=t.satoshis})}return this._outputAmount};W.prototype._getInputAmount=function(){if(ge.isUndefined(this._inputAmount)){var e=this;this._inputAmount=0,ge.each(this.inputs,function(t){if(ge.isUndefined(t.output))throw new Nt.Transaction.Input.MissingPreviousOutput;e._inputAmount+=t.output.satoshis})}return this._inputAmount};W.prototype._updateChangeOutput=function(){if(this._changeScript){this._clearSignatures(),ge.isUndefined(this._changeIndex)||this._removeOutput(this._changeIndex),this._changeIndex=this.outputs.length,this._addOutput(new zr({script:this._changeScript,satoshis:0}));var e=this._getUnspentValue(),t=this.getFee(),r=e-t;this._removeOutput(this._changeIndex),this._changeIndex=void 0,r>=W.DUST_AMOUNT&&(this._changeIndex=this.outputs.length,this._addOutput(new zr({script:this._changeScript,satoshis:r})))}};W.prototype.getFee=function(){return this.isCoinbase()?0:ge.isUndefined(this._fee)?this._changeScript?this._estimateFee():this._getUnspentValue():this._fee};W.prototype._estimateFee=function(){var e=this._estimateSize();return Math.ceil(e/1e3*(this._feePerKb||W.FEE_PER_KB))};W.prototype._getUnspentValue=function(){return this._getInputAmount()-this._getOutputAmount()};W.prototype._clearSignatures=function(){ge.each(this.inputs,function(e){e.clearSignatures!==Bt.prototype.clearSignatures&&e.clearSignatures()})};W.prototype._estimateSize=function(){var e=8;return e+=G1(this.inputs.length).toBuffer().length,e+=G1(this.outputs.length).toBuffer().length,ge.each(this.inputs,function(t){e+=t._estimateSize()}),ge.each(this.outputs,function(t){e+=t.getSize()}),e};W.prototype._removeOutput=function(e){var t=this.outputs[e];this.outputs=ge.without(this.outputs,t),this._outputAmount=void 0};W.prototype.removeOutput=function(e){this._removeOutput(e),this._updateChangeOutput()};W.prototype.sort=function(){return this.sortInputs(function(e){var t=Array.prototype.concat.apply([],e);return t.sort(function(r,n){return r.prevTxId.compare(n.prevTxId)||r.outputIndex-n.outputIndex}),t}),this.sortOutputs(function(e){var t=Array.prototype.concat.apply([],e);return t.sort(function(r,n){return r.satoshis-n.satoshis||r.script.toBuffer().compare(n.script.toBuffer())}),t}),this};W.prototype.shuffleOutputs=function(){return this.sortOutputs(ge.shuffle)};W.prototype.sortOutputs=function(e){var t=e(this.outputs);return this._newOutputOrder(t)};W.prototype.sortInputs=function(e){return this.inputs=e(this.inputs),this._clearSignatures(),this};W.prototype._newOutputOrder=function(e){var t=this.outputs.length!==e.length||ge.difference(this.outputs,e).length!==0;if(t)throw new Nt.Transaction.InvalidSorting;if(!ge.isUndefined(this._changeIndex)){var r=this.outputs[this._changeIndex];this._changeIndex=e.indexOf(r)}return this.outputs=e,this};W.prototype.removeInput=function(e,t){var r;if(!t&&ge.isNumber(e)?r=e:r=ge.findIndex(this.inputs,function(i){return i.prevTxId.toString("hex")===e&&i.outputIndex===t}),r<0||r>=this.inputs.length)throw new Nt.Transaction.InvalidIndex(r,this.inputs.length);var n=this.inputs[r];this.inputs=ge.without(this.inputs,n),this._inputAmount=void 0,this._updateChangeOutput()};W.prototype.sign=function(e,t){Ft.checkState(this.hasAllUtxoInfo(),"Not all utxo information is available to sign the transaction.");var r=this;return ge.isArray(e)?(ge.each(e,function(n){r.sign(n,t)}),this):(ge.each(this.getSignatures(e,t),function(n){r.applySignature(n)}),this)};W.prototype.getSignatures=function(e,t){e=new hk(e),t=t||Lc.SIGHASH_ALL|Lc.SIGHASH_FORKID;var r=this,n=[],i=Y1.sha256ripemd160(e.publicKey.toBuffer());return ge.each(this.inputs,function(s,a){ge.each(s.getSignatures(r,e,a,t,i),function(c){n.push(c)})}),n};W.prototype.applySignature=function(e){return this.inputs[e.inputIndex].addSignature(this,e),this};W.prototype.isFullySigned=function(){return ge.each(this.inputs,function(e){if(e.isFullySigned===Bt.prototype.isFullySigned)throw new Nt.Transaction.UnableToVerifySignature("Unrecognized script kind, or not enough information to execute script.This usually happens when creating a transaction from a serialized transaction")}),ge.every(ge.map(this.inputs,function(e){return e.isFullySigned()}))};W.prototype.isValidSignature=function(e){var t=this;if(this.inputs[e.inputIndex].isValidSignature===Bt.prototype.isValidSignature)throw new Nt.Transaction.UnableToVerifySignature("Unrecognized script kind, or not enough information to execute script.This usually happens when creating a transaction from a serialized transaction");return this.inputs[e.inputIndex].isValidSignature(t,e)};W.prototype.verifySignature=function(e,t,r,n,i,o){return $1.verify(this,e,t,r,n,i,o)};W.prototype.verify=function(){if(this.inputs.length===0)return"transaction txins empty";if(this.outputs.length===0)return"transaction txouts empty";for(var e=new Cc(0),t=0;t<this.outputs.length;t++){var r=this.outputs[t];if(r.invalidSatoshis())return"transaction txout "+t+" satoshis is invalid";if(r._satoshisBN.gt(new Cc(W.MAX_MONEY,10)))return"transaction txout "+t+" greater than MAX_MONEY";if(e=e.add(r._satoshisBN),e.gt(new Cc(W.MAX_MONEY)))return"transaction txout "+t+" total output greater than MAX_MONEY"}if(this.toBuffer().length>mk)return"transaction over the maximum block size";var n={};for(t=0;t<this.inputs.length;t++){var i=this.inputs[t],o=i.prevTxId+":"+i.outputIndex;if(!ge.isUndefined(n[o]))return"transaction input "+t+" duplicate input";n[o]=!0}var s=this.isCoinbase();if(s){var a=this.inputs[0]._scriptBuffer;if(a.length<2||a.length>100)return"coinbase transaction script size invalid"}else for(t=0;t<this.inputs.length;t++)if(this.inputs[t].isNull())return"transaction input "+t+" has null input";return!0};W.prototype.isCoinbase=function(){return this.inputs.length===1&&this.inputs[0].isNull()};W.prototype.sighash=function(e,t,r,n,i){t=t||Lc.SIGHASH_ALL|Lc.SIGHASH_FORKID;var o=this.inputs[e];if(!o)throw new Error("Input index "+e+" does not exist");return!r&&o.output&&(r=o.output.script),!n&&o.output&&(n=new Cc(o.output.satoshis)),i=i||pk,$1.sighash(this,t,e,r,n,i)};J1.exports=W});var Rp=P((f5,io)=>{y();io.exports=Ip();io.exports.Input=Pc();io.exports.Output=Dn();io.exports.UnspentOutput=Ap();io.exports.Signature=us();io.exports.Sighash=pi()});var Mc=P((l5,tx)=>{"use strict";y();var Dc=Ve(),Ha=lp(),B=up(),ce=Er(),qa=Qt(),oo=ir(),Tp=Tr();function Q1(e){return e.map(function(t){return d.Buffer.isBuffer(t)?d.Buffer.from(t):t})}var M=function e(t){if(!(this instanceof e))return new e(t);t?(this.initialize(),this.set(t)):this.initialize()};M.prototype.verify=function(e,t,r,n,i,o){var s=Rp();if(Dc.isUndefined(r)&&(r=new s),Dc.isUndefined(n)&&(n=0),Dc.isUndefined(i)&&(i=0),i&M.SCRIPT_ENABLE_SIGHASH_FORKID&&(i|=M.SCRIPT_VERIFY_STRICTENC,!o))throw new Error("internal error - need satoshisBN to verify FORKID transactions");this.set({script:e,tx:r,nin:n,flags:i,satoshisBN:o});var a;if((i&M.SCRIPT_VERIFY_SIGPUSHONLY)!==0&&!e.isPushOnly())return this.errstr="SCRIPT_ERR_SIG_PUSHONLY",!1;if(!this.evaluate())return!1;i&M.SCRIPT_VERIFY_P2SH&&(a=this.stack.slice());var c=this.stack;if(this.initialize(),this.set({script:t,stack:c,tx:r,nin:n,flags:i,satoshisBN:o}),!this.evaluate())return!1;if(this.stack.length===0)return this.errstr="SCRIPT_ERR_EVAL_FALSE_NO_RESULT",!1;var h=this.stack[this.stack.length-1];if(!M.castToBool(h))return this.errstr="SCRIPT_ERR_EVAL_FALSE_IN_STACK",!1;if(i&M.SCRIPT_VERIFY_P2SH&&t.isScriptHashOut()){if(!e.isPushOnly())return this.errstr="SCRIPT_ERR_SIG_PUSHONLY",!1;if(a.length===0)throw new Error("internal error - stack copy empty");var g=a[a.length-1],m=Ha.fromBuffer(g);if(a.pop(),this.initialize(),this.set({script:m,stack:a,tx:r,nin:n,flags:i,satoshisBN:o}),!this.evaluate())return!1;if(a.length===0)return this.errstr="SCRIPT_ERR_EVAL_FALSE_NO_P2SH_STACK",!1;if(!M.castToBool(a[a.length-1]))return this.errstr="SCRIPT_ERR_EVAL_FALSE_IN_P2SH_STACK",!1}if((i&M.SCRIPT_VERIFY_CLEANSTACK)!==0){if((i&M.SCRIPT_VERIFY_P2SH)===0)throw new Error("internal error - CLEANSTACK without P2SH");if(a.length!==1)return this.errstr="SCRIPT_ERR_CLEANSTACK",!1}return!0};tx.exports=M;M.prototype.initialize=function(e){this.stack=[],this.altstack=[],this.pc=0,this.pbegincodehash=0,this.nOpCount=0,this.vfExec=[],this.errstr="",this.flags=0};M.prototype.set=function(e){this.script=e.script||this.script,this.tx=e.tx||this.tx,this.nin=typeof e.nin<"u"?e.nin:this.nin,this.satoshisBN=e.satoshisBN||this.satoshisBN,this.stack=e.stack||this.stack,this.altstack=e.altstack||this.altstack,this.pc=typeof e.pc<"u"?e.pc:this.pc,this.pbegincodehash=typeof e.pbegincodehash<"u"?e.pbegincodehash:this.pbegincodehash,this.nOpCount=typeof e.nOpCount<"u"?e.nOpCount:this.nOpCount,this.vfExec=e.vfExec||this.vfExec,this.errstr=e.errstr||this.errstr,this.flags=typeof e.flags<"u"?e.flags:this.flags};M.true=d.Buffer.from([1]);M.false=d.Buffer.from([]);M.MAX_SCRIPT_ELEMENT_SIZE=520;M.MAXIMUM_ELEMENT_SIZE=4;M.MAX_OPS_PER_SCRIPT=201;M.MAX_SCRIPT_SIZE=1e4;M.LOCKTIME_THRESHOLD=5e8;M.LOCKTIME_THRESHOLD_BN=new ce(M.LOCKTIME_THRESHOLD);M.useGenesisLimits=function(e){return e=e||2147483647,M.MAX_SCRIPT_ELEMENT_SIZE=e,M.MAXIMUM_ELEMENT_SIZE=e,M.MAX_OPS_PER_SCRIPT=e,M.MAX_SCRIPT_SIZE=e,M};M.getLimits=function(){return{maxScriptElementSize:M.MAX_SCRIPT_ELEMENT_SIZE,maximumElementSize:M.MAXIMUM_ELEMENT_SIZE,maxOpsPerScript:M.MAX_OPS_PER_SCRIPT,maxScriptSize:M.MAX_SCRIPT_SIZE}};M.setLimits=function(e){return e=e||{},e.maxScriptElementSize!=null&&(M.MAX_SCRIPT_ELEMENT_SIZE=e.maxScriptElementSize),e.maximumElementSize!=null&&(M.MAXIMUM_ELEMENT_SIZE=e.maximumElementSize),e.maxOpsPerScript!=null&&(M.MAX_OPS_PER_SCRIPT=e.maxOpsPerScript),e.maxScriptSize!=null&&(M.MAX_SCRIPT_SIZE=e.maxScriptSize),M};M.SCRIPT_VERIFY_NONE=0;M.SCRIPT_VERIFY_P2SH=1;M.SCRIPT_VERIFY_STRICTENC=2;M.SCRIPT_VERIFY_DERSIG=4;M.SCRIPT_VERIFY_LOW_S=8;M.SCRIPT_VERIFY_NULLDUMMY=16;M.SCRIPT_VERIFY_SIGPUSHONLY=32;M.SCRIPT_VERIFY_MINIMALDATA=64;M.SCRIPT_VERIFY_DISCOURAGE_UPGRADABLE_NOPS=128;M.SCRIPT_VERIFY_CLEANSTACK=256;M.SCRIPT_VERIFY_CHECKLOCKTIMEVERIFY=512;M.SCRIPT_VERIFY_CHECKSEQUENCEVERIFY=1024;M.SCRIPT_VERIFY_MINIMALIF=8192;M.SCRIPT_VERIFY_NULLFAIL=16384;M.SCRIPT_VERIFY_COMPRESSED_PUBKEYTYPE=32768;M.SCRIPT_ENABLE_SIGHASH_FORKID=65536;M.SCRIPT_ENABLE_REPLAY_PROTECTION=1<<17;M.SCRIPT_ENABLE_MONOLITH_OPCODES=1<<18;M.SCRIPT_ENABLE_MAGNETIC_OPCODES=1<<19;M.SCRIPT_ENABLE_CHRONICLE=1<<20;M.CHRONICLE_ACTIVATION_HEIGHT=943816;M.mainnetFlags=function(e){e=e||{};var t=M.SCRIPT_VERIFY_P2SH|M.SCRIPT_VERIFY_STRICTENC|M.SCRIPT_VERIFY_DERSIG|M.SCRIPT_VERIFY_LOW_S|M.SCRIPT_VERIFY_NULLFAIL|M.SCRIPT_VERIFY_MINIMALDATA|M.SCRIPT_VERIFY_CHECKLOCKTIMEVERIFY|M.SCRIPT_VERIFY_CHECKSEQUENCEVERIFY|M.SCRIPT_ENABLE_SIGHASH_FORKID|M.SCRIPT_ENABLE_MAGNETIC_OPCODES|M.SCRIPT_ENABLE_MONOLITH_OPCODES;return e.afterChronicle!==!1&&(t|=M.SCRIPT_ENABLE_CHRONICLE),t};M.SEQUENCE_LOCKTIME_DISABLE_FLAG=1<<31;M.SEQUENCE_LOCKTIME_TYPE_FLAG=1<<22;M.SEQUENCE_LOCKTIME_MASK=65535;M.castToBool=function(e){for(var t=0;t<e.length;t++)if(e[t]!==0)return!(t===e.length-1&&e[t]===128);return!1};M.prototype.checkSignatureEncoding=function(e){var t;if(e.length===0)return!0;if((this.flags&(M.SCRIPT_VERIFY_DERSIG|M.SCRIPT_VERIFY_LOW_S|M.SCRIPT_VERIFY_STRICTENC))!==0&&!oo.isTxDER(e))return this.errstr="SCRIPT_ERR_SIG_DER_INVALID_FORMAT",!1;if((this.flags&M.SCRIPT_VERIFY_LOW_S)!==0){if(t=oo.fromTxFormat(e),!t.hasLowS())return this.errstr="SCRIPT_ERR_SIG_DER_HIGH_S",!1}else if((this.flags&M.SCRIPT_VERIFY_STRICTENC)!==0){if(t=oo.fromTxFormat(e),!t.hasDefinedHashtype())return this.errstr="SCRIPT_ERR_SIG_HASHTYPE",!1;if(!(this.flags&M.SCRIPT_ENABLE_SIGHASH_FORKID)&&t.nhashtype&oo.SIGHASH_FORKID)return this.errstr="SCRIPT_ERR_ILLEGAL_FORKID",!1;if(this.flags&M.SCRIPT_ENABLE_SIGHASH_FORKID&&!(t.nhashtype&oo.SIGHASH_FORKID))return this.errstr="SCRIPT_ERR_MUST_USE_FORKID",!1}return!0};M.prototype.checkPubkeyEncoding=function(e){return(this.flags&M.SCRIPT_VERIFY_STRICTENC)!==0&&!Tp.isValid(e)?(this.errstr="SCRIPT_ERR_PUBKEYTYPE",!1):!0};M._isMinimallyEncoded=function(e,t){return t=t||M.MAXIMUM_ELEMENT_SIZE,!(e.length>t||e.length>0&&(e[e.length-1]&127)===0&&(e.length<=1||(e[e.length-2]&128)===0))};M._minimallyEncode=function(e){if(e.length===0)return e;var t=e[e.length-1];if(t&127)return e;if(e.length===1)return d.Buffer.from("");if(e[e.length-2]&128)return e;for(var r=e.length-1;r>0;r--)if(e[r-1]!==0)return e[r-1]&128?e[r++]=t:e[r-1]|=t,e.slice(0,r);return d.Buffer.from("")};M.prototype.evaluate=function(){if(this.script.toBuffer().length>M.MAX_SCRIPT_SIZE)return this.errstr="SCRIPT_ERR_SCRIPT_SIZE",!1;try{for(;this.pc<this.script.chunks.length;){let t={pc:this.pc,opcode:B.fromNumber(this.script.chunks[this.pc].opcodenum)};var e=this.step();if(!e)return!1;this._callbackStep(t)}if(this.stack.length+this.altstack.length>1e3)return this.errstr="SCRIPT_ERR_STACK_SIZE",!1}catch(t){return this.errstr="SCRIPT_ERR_UNKNOWN_ERROR: "+t,!1}return this.vfExec.length>0?(this.errstr="SCRIPT_ERR_UNBALANCED_CONDITIONAL",!1):!0};M.prototype._callbackStep=function(e){if(typeof this.stepListener=="function")try{this.stepListener(e,Q1(this.stack),Q1(this.altstack))}catch(t){console.log(`Error in Step callback:${t}`)}};M.prototype.checkLockTime=function(e){return!(!(this.tx.nLockTime<M.LOCKTIME_THRESHOLD&&e.lt(M.LOCKTIME_THRESHOLD_BN)||this.tx.nLockTime>=M.LOCKTIME_THRESHOLD&&e.gte(M.LOCKTIME_THRESHOLD_BN))||e.gt(new ce(this.tx.nLockTime))||this.tx.inputs[this.nin].isFinal())};M.prototype.checkSequence=function(e){var t=this.tx.inputs[this.nin].sequenceNumber;if(this.tx.version<2||t&M.SEQUENCE_LOCKTIME_DISABLE_FLAG)return!1;var r=M.SEQUENCE_LOCKTIME_TYPE_FLAG|M.SEQUENCE_LOCKTIME_MASK,n=new ce(t&r),i=e.and(new ce(r)),o=new ce(M.SEQUENCE_LOCKTIME_TYPE_FLAG);return!(!(n.lt(o)&&i.lt(o)||n.gte(o)&&i.gte(o))||i.gt(n))};function vk(e,t){let r=e;for(;r.length<t;)r=d.Buffer.concat([d.Buffer.from([0]),r]);return r}function ex(e){var t=d.Buffer.alloc(4);return t.writeInt32LE(e|0,0),t}M.prototype.step=function(){var e=this;function t(te){return e.stack[e.stack.length+te]}function r(te){switch(te){case B.OP_2MUL:case B.OP_2DIV:if((e.flags&M.SCRIPT_ENABLE_CHRONICLE)===0)return!0;break;case B.OP_INVERT:case B.OP_MUL:case B.OP_LSHIFT:case B.OP_RSHIFT:if((e.flags&M.SCRIPT_ENABLE_MAGNETIC_OPCODES)===0)return!0;break;case B.OP_DIV:case B.OP_MOD:case B.OP_SPLIT:case B.OP_CAT:case B.OP_AND:case B.OP_OR:case B.OP_XOR:case B.OP_BIN2NUM:case B.OP_NUM2BIN:return!1;default:break}return!1}var n=(this.flags&M.SCRIPT_VERIFY_MINIMALDATA)!==0,i=this.vfExec.indexOf(!1)===-1,o,s,a,c,h,g,m,_,I,R,N,L,q,G,K,z,X,oe=this.script.chunks[this.pc];this.pc++;var ue=oe.opcodenum;if(Dc.isUndefined(ue))return this.errstr="SCRIPT_ERR_UNDEFINED_OPCODE",!1;if(oe.buf&&oe.buf.length>M.MAX_SCRIPT_ELEMENT_SIZE)return this.errstr="SCRIPT_ERR_PUSH_SIZE",!1;if(ue>B.OP_16&&++this.nOpCount>M.MAX_OPS_PER_SCRIPT)return this.errstr="SCRIPT_ERR_OP_COUNT",!1;if(r(ue))return this.errstr="SCRIPT_ERR_DISABLED_OPCODE",!1;if(i&&ue>=0&&ue<=B.OP_PUSHDATA4){if(n&&!this.script.checkMinimalPush(this.pc-1))return this.errstr="SCRIPT_ERR_MINIMALDATA",!1;if(!oe.buf)this.stack.push(M.false);else{if(oe.len!==oe.buf.length)throw new Error(`Length of push value not equal to length of data (${oe.len},${oe.buf.length})`);this.stack.push(oe.buf)}}else if(i||B.OP_IF<=ue&&ue<=B.OP_ENDIF)switch(ue){case B.OP_1NEGATE:case B.OP_1:case B.OP_2:case B.OP_3:case B.OP_4:case B.OP_5:case B.OP_6:case B.OP_7:case B.OP_8:case B.OP_9:case B.OP_10:case B.OP_11:case B.OP_12:case B.OP_13:case B.OP_14:case B.OP_15:case B.OP_16:h=ue-(B.OP_1-1),o=new ce(h).toScriptNumBuffer(),this.stack.push(o);break;case B.OP_NOP:break;case B.OP_NOP2:case B.OP_CHECKLOCKTIMEVERIFY:if(!(this.flags&M.SCRIPT_VERIFY_CHECKLOCKTIMEVERIFY)){if(this.flags&M.SCRIPT_VERIFY_DISCOURAGE_UPGRADABLE_NOPS)return this.errstr="SCRIPT_ERR_DISCOURAGE_UPGRADABLE_NOPS",!1;break}if(this.stack.length<1)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;var se=ce.fromScriptNumBuffer(this.stack[this.stack.length-1],n,5);if(se.lt(new ce(0)))return this.errstr="SCRIPT_ERR_NEGATIVE_LOCKTIME",!1;if(!this.checkLockTime(se))return this.errstr="SCRIPT_ERR_UNSATISFIED_LOCKTIME",!1;break;case B.OP_NOP3:case B.OP_CHECKSEQUENCEVERIFY:if(!(this.flags&M.SCRIPT_VERIFY_CHECKSEQUENCEVERIFY)){if(this.flags&M.SCRIPT_VERIFY_DISCOURAGE_UPGRADABLE_NOPS)return this.errstr="SCRIPT_ERR_DISCOURAGE_UPGRADABLE_NOPS",!1;break}if(this.stack.length<1)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;var de=ce.fromScriptNumBuffer(t(-1),n,5);if(de.lt(new ce(0)))return this.errstr="SCRIPT_ERR_NEGATIVE_LOCKTIME",!1;if((de&M.SEQUENCE_LOCKTIME_DISABLE_FLAG)!==0)break;if(!this.checkSequence(de))return this.errstr="SCRIPT_ERR_UNSATISFIED_LOCKTIME",!1;break;case B.OP_NOP1:case B.OP_NOP9:case B.OP_NOP10:if(this.flags&M.SCRIPT_VERIFY_DISCOURAGE_UPGRADABLE_NOPS)return this.errstr="SCRIPT_ERR_DISCOURAGE_UPGRADABLE_NOPS",!1;break;case B.OP_LSHIFTNUM:case B.OP_RSHIFTNUM:if((this.flags&M.SCRIPT_ENABLE_CHRONICLE)===0){if(this.flags&M.SCRIPT_VERIFY_DISCOURAGE_UPGRADABLE_NOPS)return this.errstr="SCRIPT_ERR_DISCOURAGE_UPGRADABLE_NOPS",!1;break}if(this.stack.length<2)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;var A=M.MAXIMUM_ELEMENT_SIZE,u=ce.fromScriptNumBuffer(t(-1),n,A);if(u.isNeg())return this.errstr="SCRIPT_ERR_INVALID_NUMBER_RANGE",!1;this.stack.pop();var l=ce.fromScriptNumBuffer(t(-1),n,A);this.stack.pop();var p=u.toNumber(),v=l.isNeg(),b=l.abs(),E;if(ue===B.OP_LSHIFTNUM){var O=l.toScriptNumBuffer().length;if(O+Math.floor(p/8)>A)return this.errstr="SCRIPT_ERR_SCRIPTNUM_OVERFLOW",!1;E=b.shln(p)}else E=p>=b.bitLength()?new ce(0):b.shrn(p);if(v&&!E.isZero()&&(E=E.neg()),E.toScriptNumBuffer().length>A)return this.errstr="SCRIPT_ERR_SCRIPTNUM_OVERFLOW",!1;this.stack.push(E.toScriptNumBuffer());break;case B.OP_VER:if((this.flags&M.SCRIPT_ENABLE_CHRONICLE)===0)return this.errstr="SCRIPT_ERR_BAD_OPCODE",!1;if(this.tx==null)return this.errstr="SCRIPT_ERR_UNKNOWN_ERROR",!1;this.stack.push(ex(this.tx.version));break;case B.OP_VERIF:case B.OP_VERNOTIF:if((this.flags&M.SCRIPT_ENABLE_CHRONICLE)===0){if(!i)break;return this.errstr="SCRIPT_ERR_BAD_OPCODE",!1}if(z=!1,i){if(this.stack.length<1)return this.errstr="SCRIPT_ERR_UNBALANCED_CONDITIONAL",!1;if(this.tx==null)return this.errstr="SCRIPT_ERR_UNKNOWN_ERROR",!1;o=t(-1),z=o.length===4&&o.equals(ex(this.tx.version)),ue===B.OP_VERNOTIF&&(z=!z),this.stack.pop()}this.vfExec.push(z);break;case B.OP_IF:case B.OP_NOTIF:if(z=!1,i){if(this.stack.length<1)return this.errstr="SCRIPT_ERR_UNBALANCED_CONDITIONAL",!1;if(o=t(-1),this.flags&M.SCRIPT_VERIFY_MINIMALIF){if(o.length>1)return this.errstr="SCRIPT_ERR_MINIMALIF",!1;if(o.length===1&&o[0]!==1)return this.errstr="SCRIPT_ERR_MINIMALIF",!1}z=M.castToBool(o),ue===B.OP_NOTIF&&(z=!z),this.stack.pop()}this.vfExec.push(z);break;case B.OP_ELSE:if(this.vfExec.length===0)return this.errstr="SCRIPT_ERR_UNBALANCED_CONDITIONAL",!1;this.vfExec[this.vfExec.length-1]=!this.vfExec[this.vfExec.length-1];break;case B.OP_ENDIF:if(this.vfExec.length===0)return this.errstr="SCRIPT_ERR_UNBALANCED_CONDITIONAL",!1;this.vfExec.pop();break;case B.OP_VERIFY:if(this.stack.length<1)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;if(o=t(-1),z=M.castToBool(o),z)this.stack.pop();else return this.errstr="SCRIPT_ERR_VERIFY",!1;break;case B.OP_RETURN:return this.errstr="SCRIPT_ERR_OP_RETURN",!1;case B.OP_TOALTSTACK:if(this.stack.length<1)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;this.altstack.push(this.stack.pop());break;case B.OP_FROMALTSTACK:if(this.altstack.length<1)return this.errstr="SCRIPT_ERR_INVALID_ALTSTACK_OPERATION",!1;this.stack.push(this.altstack.pop());break;case B.OP_2DROP:if(this.stack.length<2)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;this.stack.pop(),this.stack.pop();break;case B.OP_2DUP:if(this.stack.length<2)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;s=t(-2),a=t(-1),this.stack.push(d.Buffer.from(s)),this.stack.push(d.Buffer.from(a));break;case B.OP_3DUP:if(this.stack.length<3)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;s=t(-3),a=t(-2);var w=t(-1);this.stack.push(d.Buffer.from(s)),this.stack.push(d.Buffer.from(a)),this.stack.push(d.Buffer.from(w));break;case B.OP_2OVER:if(this.stack.length<4)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;s=t(-4),a=t(-3),this.stack.push(d.Buffer.from(s)),this.stack.push(d.Buffer.from(a));break;case B.OP_2ROT:if(this.stack.length<6)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;c=this.stack.splice(this.stack.length-6,2),this.stack.push(c[0]),this.stack.push(c[1]);break;case B.OP_2SWAP:if(this.stack.length<4)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;c=this.stack.splice(this.stack.length-4,2),this.stack.push(c[0]),this.stack.push(c[1]);break;case B.OP_IFDUP:if(this.stack.length<1)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;o=t(-1),z=M.castToBool(o),z&&this.stack.push(d.Buffer.from(o));break;case B.OP_DEPTH:o=new ce(this.stack.length).toScriptNumBuffer(),this.stack.push(o);break;case B.OP_DROP:if(this.stack.length<1)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;this.stack.pop();break;case B.OP_DUP:if(this.stack.length<1)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;this.stack.push(d.Buffer.from(t(-1)));break;case B.OP_NIP:if(this.stack.length<2)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;this.stack.splice(this.stack.length-2,1);break;case B.OP_OVER:if(this.stack.length<2)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;this.stack.push(d.Buffer.from(t(-2)));break;case B.OP_PICK:case B.OP_ROLL:if(this.stack.length<2)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;if(o=t(-1),_=ce.fromScriptNumBuffer(o,n),h=_.toNumber(),this.stack.pop(),h<0||h>=this.stack.length)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;o=t(-h-1),ue===B.OP_ROLL&&this.stack.splice(this.stack.length-h-1,1),this.stack.push(d.Buffer.from(o));break;case B.OP_ROT:if(this.stack.length<3)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;g=t(-3),m=t(-2);var f=t(-1);this.stack[this.stack.length-3]=m,this.stack[this.stack.length-2]=f,this.stack[this.stack.length-1]=g;break;case B.OP_SWAP:if(this.stack.length<2)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;g=t(-2),m=t(-1),this.stack[this.stack.length-2]=m,this.stack[this.stack.length-1]=g;break;case B.OP_TUCK:if(this.stack.length<2)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;this.stack.splice(this.stack.length-2,0,d.Buffer.from(t(-1)));break;case B.OP_SIZE:if(this.stack.length<1)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;_=new ce(t(-1).length),this.stack.push(_.toScriptNumBuffer());break;case B.OP_AND:case B.OP_OR:case B.OP_XOR:if(this.stack.length<2)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;if(s=t(-2),a=t(-1),s.length!==a.length)return this.errstr="SCRIPT_ERR_INVALID_OPERAND_SIZE",!1;switch(ue){case B.OP_AND:for(let te=0;te<s.length;te++)s[te]&=a[te];break;case B.OP_OR:for(let te=0;te<s.length;te++)s[te]|=a[te];break;case B.OP_XOR:for(let te=0;te<s.length;te++)s[te]^=a[te];break;default:break}this.stack.pop();break;case B.OP_INVERT:this.stack.length<1&&(this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION"),o=t(-1);for(let te=0;te<o.length;te++)o[te]=~o[te];break;case B.OP_LSHIFT:case B.OP_RSHIFT:if(this.stack.length<2)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;if(s=t(-2),s.length===0)this.stack.pop();else{if(I=new ce(s),R=ce.fromScriptNumBuffer(t(-1),n),h=R.toNumber(),h<0)return this.errstr="SCRIPT_ERR_INVALID_NUMBER_RANGE",!1;this.stack.pop(),this.stack.pop();let te;ue===B.OP_LSHIFT&&(te=I.ushln(h)),ue===B.OP_RSHIFT&&(te=I.ushrn(h));let ve=vk(d.Buffer.from(te.toArray().slice(s.length*-1)),s.length);this.stack.push(ve)}break;case B.OP_EQUAL:case B.OP_EQUALVERIFY:if(this.stack.length<2)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;s=t(-2),a=t(-1);var S=s.toString("hex")===a.toString("hex");if(this.stack.pop(),this.stack.pop(),this.stack.push(S?M.true:M.false),ue===B.OP_EQUALVERIFY)if(S)this.stack.pop();else return this.errstr="SCRIPT_ERR_EQUALVERIFY",!1;break;case B.OP_2MUL:case B.OP_2DIV:case B.OP_1ADD:case B.OP_1SUB:case B.OP_NEGATE:case B.OP_ABS:case B.OP_NOT:case B.OP_0NOTEQUAL:if(this.stack.length<1)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;switch(o=t(-1),_=ce.fromScriptNumBuffer(o,n),ue){case B.OP_2MUL:_=_.mul(new ce(2));break;case B.OP_2DIV:_=_.div(new ce(2));break;case B.OP_1ADD:_=_.add(ce.One);break;case B.OP_1SUB:_=_.sub(ce.One);break;case B.OP_NEGATE:_=_.neg();break;case B.OP_ABS:_.cmp(ce.Zero)<0&&(_=_.neg());break;case B.OP_NOT:_=new ce((_.cmp(ce.Zero)===0)+0);break;case B.OP_0NOTEQUAL:_=new ce((_.cmp(ce.Zero)!==0)+0);break}this.stack.pop(),this.stack.push(_.toScriptNumBuffer());break;case B.OP_ADD:case B.OP_SUB:case B.OP_MUL:case B.OP_MOD:case B.OP_DIV:case B.OP_BOOLAND:case B.OP_BOOLOR:case B.OP_NUMEQUAL:case B.OP_NUMEQUALVERIFY:case B.OP_NUMNOTEQUAL:case B.OP_LESSTHAN:case B.OP_GREATERTHAN:case B.OP_LESSTHANOREQUAL:case B.OP_GREATERTHANOREQUAL:case B.OP_MIN:case B.OP_MAX:if(this.stack.length<2)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;switch(I=ce.fromScriptNumBuffer(t(-2),n,M.MAXIMUM_ELEMENT_SIZE),R=ce.fromScriptNumBuffer(t(-1),n,M.MAXIMUM_ELEMENT_SIZE),_=new ce(0),ue){case B.OP_ADD:_=I.add(R);break;case B.OP_SUB:_=I.sub(R);break;case B.OP_MUL:_=I.mul(R);break;case B.OP_DIV:if(R===0)return this.errstr="SCRIPT_ERR_DIV_BY_ZERO",!1;_=I.div(R);break;case B.OP_MOD:if(R===0)return this.errstr="SCRIPT_ERR_DIV_BY_ZERO",!1;_=I.mod(R);break;case B.OP_BOOLAND:_=new ce((I.cmp(ce.Zero)!==0&&R.cmp(ce.Zero)!==0)+0);break;case B.OP_BOOLOR:_=new ce((I.cmp(ce.Zero)!==0||R.cmp(ce.Zero)!==0)+0);break;case B.OP_NUMEQUAL:_=new ce((I.cmp(R)===0)+0);break;case B.OP_NUMEQUALVERIFY:_=new ce((I.cmp(R)===0)+0);break;case B.OP_NUMNOTEQUAL:_=new ce((I.cmp(R)!==0)+0);break;case B.OP_LESSTHAN:_=new ce((I.cmp(R)<0)+0);break;case B.OP_GREATERTHAN:_=new ce((I.cmp(R)>0)+0);break;case B.OP_LESSTHANOREQUAL:_=new ce((I.cmp(R)<=0)+0);break;case B.OP_GREATERTHANOREQUAL:_=new ce((I.cmp(R)>=0)+0);break;case B.OP_MIN:_=I.cmp(R)<0?I:R;break;case B.OP_MAX:_=I.cmp(R)>0?I:R;break}if(this.stack.pop(),this.stack.pop(),this.stack.push(_.toScriptNumBuffer()),ue===B.OP_NUMEQUALVERIFY)if(M.castToBool(t(-1)))this.stack.pop();else return this.errstr="SCRIPT_ERR_NUMEQUALVERIFY",!1;break;case B.OP_WITHIN:if(this.stack.length<3)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;I=ce.fromScriptNumBuffer(t(-3),n,M.MAXIMUM_ELEMENT_SIZE),R=ce.fromScriptNumBuffer(t(-2),n,M.MAXIMUM_ELEMENT_SIZE);var j=ce.fromScriptNumBuffer(t(-1),n,M.MAXIMUM_ELEMENT_SIZE);z=R.cmp(I)<=0&&I.cmp(j)<0,this.stack.pop(),this.stack.pop(),this.stack.pop(),this.stack.push(z?M.true:M.false);break;case B.OP_RIPEMD160:case B.OP_SHA1:case B.OP_SHA256:case B.OP_HASH160:case B.OP_HASH256:if(this.stack.length<1)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;o=t(-1);var F;ue===B.OP_RIPEMD160?F=qa.ripemd160(o):ue===B.OP_SHA1?F=qa.sha1(o):ue===B.OP_SHA256?F=qa.sha256(o):ue===B.OP_HASH160?F=qa.sha256ripemd160(o):ue===B.OP_HASH256&&(F=qa.sha256sha256(o)),this.stack.pop(),this.stack.push(F);break;case B.OP_CODESEPARATOR:this.pbegincodehash=this.pc;break;case B.OP_CHECKSIG:case B.OP_CHECKSIGVERIFY:if(this.stack.length<2)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;if(N=t(-2),L=t(-1),!this.checkSignatureEncoding(N)||!this.checkPubkeyEncoding(L))return!1;q=new Ha().set({chunks:this.script.chunks.slice(this.pbegincodehash)});var Y=new Ha().add(N);q.findAndDelete(Y);try{G=oo.fromTxFormat(N),K=Tp.fromBuffer(L,!1),X=this.tx.verifySignature(G,K,this.nin,q,this.satoshisBN,this.flags)}catch{X=!1}if(!X&&this.flags&M.SCRIPT_VERIFY_NULLFAIL&&N.length)return this.errstr="SCRIPT_ERR_NULLFAIL",!1;if(this.stack.pop(),this.stack.pop(),this.stack.push(X?M.true:M.false),ue===B.OP_CHECKSIGVERIFY)if(X)this.stack.pop();else return this.errstr="SCRIPT_ERR_CHECKSIGVERIFY",!1;break;case B.OP_CHECKMULTISIG:case B.OP_CHECKMULTISIGVERIFY:var $=1;if(this.stack.length<$)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;var J=ce.fromScriptNumBuffer(t(-$),n).toNumber();if(J<0||J>20)return this.errstr="SCRIPT_ERR_PUBKEY_COUNT",!1;if(this.nOpCount+=J,this.nOpCount>M.MAX_OPS_PER_SCRIPT)return this.errstr="SCRIPT_ERR_OP_COUNT",!1;var ae=++$;$+=J;var ye=J+2;if(this.stack.length<$)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;var he=ce.fromScriptNumBuffer(t(-$),n).toNumber();if(he<0||he>J)return this.errstr="SCRIPT_ERR_SIG_COUNT",!1;var T=++$;if($+=he,this.stack.length<$)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;q=new Ha().set({chunks:this.script.chunks.slice(this.pbegincodehash)});for(var k=0;k<he;k++)N=t(-T-k),q.findAndDelete(new Ha().add(N));for(X=!0;X&&he>0;){if(N=t(-T),L=t(-ae),!this.checkSignatureEncoding(N)||!this.checkPubkeyEncoding(L))return!1;var H;try{G=oo.fromTxFormat(N),K=Tp.fromBuffer(L,!1),H=this.tx.verifySignature(G,K,this.nin,q,this.satoshisBN,this.flags)}catch{H=!1}H&&(T++,he--),ae++,J--,he>J&&(X=!1)}for(;$-- >1;){if(!X&&this.flags&M.SCRIPT_VERIFY_NULLFAIL&&!ye&&t(-1).length)return this.errstr="SCRIPT_ERR_NULLFAIL",!1;ye>0&&ye--,this.stack.pop()}if(this.stack.length<1)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;if(this.flags&M.SCRIPT_VERIFY_NULLDUMMY&&t(-1).length)return this.errstr="SCRIPT_ERR_SIG_NULLDUMMY",!1;if(this.stack.pop(),this.stack.push(X?M.true:M.false),ue===B.OP_CHECKMULTISIGVERIFY)if(X)this.stack.pop();else return this.errstr="SCRIPT_ERR_CHECKMULTISIGVERIFY",!1;break;case B.OP_CAT:if(this.stack.length<2)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;if(s=t(-2),a=t(-1),s.length+a.length>M.MAX_SCRIPT_ELEMENT_SIZE)return this.errstr="SCRIPT_ERR_PUSH_SIZE",!1;this.stack[this.stack.length-2]=d.Buffer.concat([s,a]),this.stack.pop();break;case B.OP_SPLIT:if(this.stack.length<2)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;s=t(-2);var V=ce.fromScriptNumBuffer(t(-1),n).toNumber();if(V<0||V>s.length)return this.errstr="SCRIPT_ERR_INVALID_SPLIT_RANGE",!1;var ne=d.Buffer.from(s);this.stack[this.stack.length-2]=ne.slice(0,V),this.stack[this.stack.length-1]=ne.slice(V);break;case B.OP_LEFT:case B.OP_RIGHT:if((this.flags&M.SCRIPT_ENABLE_CHRONICLE)===0){if(this.flags&M.SCRIPT_VERIFY_DISCOURAGE_UPGRADABLE_NOPS)return this.errstr="SCRIPT_ERR_DISCOURAGE_UPGRADABLE_NOPS",!1;break}if(this.stack.length<2)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;if(s=t(-2),h=ce.fromScriptNumBuffer(t(-1),n,M.MAXIMUM_ELEMENT_SIZE).toNumber(),h<0||h>s.length)return this.errstr="SCRIPT_ERR_INVALID_NUMBER_RANGE",!1;this.stack.pop(),ue===B.OP_LEFT?this.stack[this.stack.length-1]=d.Buffer.from(s).slice(0,h):this.stack[this.stack.length-1]=d.Buffer.from(s).slice(s.length-h);break;case B.OP_SUBSTR:if((this.flags&M.SCRIPT_ENABLE_CHRONICLE)===0){if(this.flags&M.SCRIPT_VERIFY_DISCOURAGE_UPGRADABLE_NOPS)return this.errstr="SCRIPT_ERR_DISCOURAGE_UPGRADABLE_NOPS",!1;break}if(this.stack.length<3)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;s=t(-3);var Q=ce.fromScriptNumBuffer(t(-1),n,M.MAXIMUM_ELEMENT_SIZE).toNumber(),ee=ce.fromScriptNumBuffer(t(-2),n,M.MAXIMUM_ELEMENT_SIZE).toNumber();if(ee<0||ee>=s.length||Q<0||Q>s.length-ee)return this.errstr="SCRIPT_ERR_INVALID_NUMBER_RANGE",!1;this.stack.pop(),this.stack.pop(),this.stack[this.stack.length-1]=d.Buffer.from(s).slice(ee,ee+Q);break;case B.OP_NUM2BIN:if(this.stack.length<2)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;var pe=ce.fromScriptNumBuffer(t(-1),n).toNumber();if(pe>M.MAX_SCRIPT_ELEMENT_SIZE)return this.errstr="SCRIPT_ERR_PUSH_SIZE",!1;this.stack.pop();var ie=t(-1);if(ie=M._minimallyEncode(ie),ie.length>pe)return this.errstr="SCRIPT_ERR_IMPOSSIBLE_ENCODING",!1;if(ie.length===pe){this.stack[this.stack.length-1]=ie;break}var fe=0;ie.length>0&&(fe=ie[ie.length-1]&128,ie[ie.length-1]&=127);var ze=d.Buffer.alloc(pe);ie.copy(ze,0);for(var Oe=ie.length-1;Oe++<pe-2;)ze[Oe]=0;ze[Oe]=fe,this.stack[this.stack.length-1]=ze;break;case B.OP_BIN2NUM:if(this.stack.length<1)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;if(s=t(-1),a=M._minimallyEncode(s),this.stack[this.stack.length-1]=a,!M._isMinimallyEncoded(a))return this.errstr="SCRIPT_ERR_INVALID_NUMBER_RANGE",!1;break;default:return this.errstr="SCRIPT_ERR_BAD_OPCODE",!1}return!0}});var Kr=P((d5,Pp)=>{y();Pp.exports=lp();Pp.exports.Interpreter=Mc()});var ro=P((g5,ox)=>{"use strict";y();var Bp=Ve(),jn=ke(),bk=Jn(),rx=Hd(),Br=ga(),nx=Qt(),ix=pr(),Np=Tr();function re(e,t,r){if(!(this instanceof re))return new re(e,t,r);if(Bp.isArray(e)&&Bp.isNumber(t))return re.createMultisig(e,t,r);if(e instanceof re)return e;if(jn.checkArgument(e,"First argument is required, please include address data.","guide/address.html"),t&&!Br.get(t))throw new TypeError('Second argument must be "livenet", "testnet", or "regtest".');if(r&&r!==re.PayToPublicKeyHash&&r!==re.PayToScriptHash)throw new TypeError('Third argument must be "pubkeyhash" or "scripthash".');var n=this._classifyArguments(e,t,r);return n.network=n.network||Br.get(t)||Br.defaultNetwork,n.type=n.type||r||re.PayToPublicKeyHash,ix.defineImmutable(this,{hashBuffer:n.hashBuffer,network:n.network,type:n.type}),this}re.prototype._classifyArguments=function(e,t,r){if((e instanceof d.Buffer||e instanceof Uint8Array)&&e.length===20)return re._transformHash(e);if((e instanceof d.Buffer||e instanceof Uint8Array)&&e.length===21)return re._transformBuffer(e,t,r);if(e instanceof Np)return re._transformPublicKey(e);if(e instanceof ja())return re._transformScript(e,t);if(typeof e=="string")return re._transformString(e,t,r);if(Bp.isObject(e))return re._transformObject(e);throw new TypeError("First argument is an unrecognized data format.")};re.PayToPublicKeyHash="pubkeyhash";re.PayToScriptHash="scripthash";re._transformHash=function(e){var t={};if(!(e instanceof d.Buffer)&&!(e instanceof Uint8Array))throw new TypeError("Address supplied is not a buffer.");if(e.length!==20)throw new TypeError("Address hashbuffers must be exactly 20 bytes.");return t.hashBuffer=e,t};re._transformObject=function(e){return jn.checkArgument(e.hash||e.hashBuffer,"Must provide a `hash` or `hashBuffer` property"),jn.checkArgument(e.type,"Must provide a `type` property"),{hashBuffer:e.hash?d.Buffer.from(e.hash,"hex"):e.hashBuffer,network:Br.get(e.network)||Br.defaultNetwork,type:e.type}};re._classifyFromVersion=function(e){var t={},r=Br.get(e[0],"pubkeyhash"),n=Br.get(e[0],"scripthash");return r?(t.network=r,t.type=re.PayToPublicKeyHash):n&&(t.network=n,t.type=re.PayToScriptHash),t};re._transformBuffer=function(e,t,r){var n={};if(!(e instanceof d.Buffer)&&!(e instanceof Uint8Array))throw new TypeError("Address supplied is not a buffer.");if(e.length!==21)throw new TypeError("Address buffers must be exactly 21 bytes.");var i=Br.get(t),o=re._classifyFromVersion(e);if(t&&!i)throw new TypeError("Unknown network");if(!o.network||i&&i!==o.network)throw new TypeError("Address has mismatched network type.");if(!o.type||r&&r!==o.type)throw new TypeError("Address has mismatched type.");return n.hashBuffer=e.slice(1),n.network=o.network,n.type=o.type,n};re._transformPublicKey=function(e){var t={};if(!(e instanceof Np))throw new TypeError("Address must be an instance of PublicKey.");return t.hashBuffer=nx.sha256ripemd160(e.toBuffer()),t.type=re.PayToPublicKeyHash,t};re._transformScript=function(e,t){jn.checkArgument(e instanceof ja(),"script must be a Script instance");var r=e.getAddressInfo(t);if(!r)throw new bk.Script.CantDeriveAddress(e);return r};re.createMultisig=function(e,t,r){return r=r||e[0].network||Br.defaultNetwork,re.payingTo(ja().buildMultisigOut(e,t),r)};re._transformString=function(e,t,r){if(typeof e!="string")throw new TypeError("data parameter supplied is not a string.");if(e.length<27)throw new Error("Invalid Address string provided");e=e.trim();var n=Br.get(t);if(t&&!n)throw new TypeError("Unknown network");var i=rx.decode(e);return re._transformBuffer(i,t,r)};re.fromPublicKey=function(e,t){var r=re._transformPublicKey(e);return t=t||Br.defaultNetwork,new re(r.hashBuffer,t,r.type)};re.fromPrivateKey=function(e,t){let r=Np.fromPrivateKey(e);return t=t||e.network||Br.defaultNetwork,re.fromPublicKey(r,t)};re.fromPublicKeyHash=function(e,t){var r=re._transformHash(e);return new re(r.hashBuffer,t,re.PayToPublicKeyHash)};re.fromScriptHash=function(e,t){jn.checkArgument(e,"hash parameter is required");var r=re._transformHash(e);return new re(r.hashBuffer,t,re.PayToScriptHash)};re.payingTo=function(e,t){return jn.checkArgument(e,"script is required"),jn.checkArgument(e instanceof ja(),"script must be instance of Script"),re.fromScriptHash(nx.sha256ripemd160(e.toBuffer()),t)};re.fromScript=function(e,t){jn.checkArgument(e instanceof ja(),"script must be a Script instance");var r=re._transformScript(e,t);return new re(r.hashBuffer,t,r.type)};re.fromBuffer=function(e,t,r){var n=re._transformBuffer(e,t,r);return new re(n.hashBuffer,n.network,n.type)};re.fromHex=function(e,t,r){return re.fromBuffer(d.Buffer.from(e,"hex"),t,r)};re.fromString=function(e,t,r){var n=re._transformString(e,t,r);return new re(n.hashBuffer,n.network,n.type)};re.fromObject=function(t){jn.checkState(ix.isHexa(t.hash),'Unexpected hash property, "'+t.hash+'", expected to be hex.');var r=d.Buffer.from(t.hash,"hex");return new re(r,t.network,t.type)};re.getValidationError=function(e,t,r){var n;try{new re(e,t,r)}catch(i){n=i}return n};re.isValid=function(e,t,r){return!re.getValidationError(e,t,r)};re.prototype.isPayToPublicKeyHash=function(){return this.type===re.PayToPublicKeyHash};re.prototype.isPayToScriptHash=function(){return this.type===re.PayToScriptHash};re.prototype.toBuffer=function(){var e=d.Buffer.from([this.network[this.type]]),t=d.Buffer.concat([e,this.hashBuffer]);return t};re.prototype.toHex=function(){return this.toBuffer().toString("hex")};re.prototype.toObject=re.prototype.toJSON=function(){return{hash:this.hashBuffer.toString("hex"),type:this.type,network:this.network.toString()}};re.prototype.inspect=function(){return"<Address: "+this.toString()+", type: "+this.type+", network: "+this.network+">"};re.prototype.toString=function(){return rx.encode(this.toBuffer())};ox.exports=re;function ja(){return Kr()}});var no=P((m5,fx)=>{"use strict";y();var Uc=Ve(),_k=ro(),sx=Hd(),yi=Er(),ax=pr(),hn=ga(),kp=ii(),wk=Tr(),Sk=ea(),ux=ke(),Mp="[REDACTED]";function me(e,t){if(!(this instanceof me))return new me(e,t);if(e instanceof me)return e;var r=this._classifyArguments(e,t);if(!r.bn||r.bn.cmp(new yi(0))===0)throw new TypeError("Number can not be equal to zero, undefined, null or false");if(!r.bn.lt(kp.getN()))throw new TypeError("Number must be less than N");if(typeof r.network>"u")throw new TypeError('Must specify the network ("livenet" or "testnet")');return ax.defineImmutable(this,{bn:r.bn,compressed:r.compressed,network:r.network}),Object.defineProperty(this,"publicKey",{configurable:!1,enumerable:!0,get:this.toPublicKey.bind(this)}),this}me.prototype._classifyArguments=function(e,t){var r={compressed:!0,network:t?hn.get(t):hn.defaultNetwork};if(Uc.isUndefined(e)||Uc.isNull(e))r.bn=me._getRandomBN();else if(e instanceof yi)r.bn=e;else if(e instanceof d.Buffer||e instanceof Uint8Array)r=me._transformBuffer(e,t);else if(e.bn&&e.network)r=me._transformObject(e);else if(!t&&hn.get(e))r.bn=me._getRandomBN(),r.network=hn.get(e);else if(typeof e=="string")ax.isHexa(e)?r.bn=new yi(d.Buffer.from(e,"hex")):r=me._transformWIF(e,t);else throw new TypeError("First argument is an unrecognized data type.");return r};me._getRandomBN=function(){var e,t;do{var r=Sk.getRandomBuffer(32);t=yi.fromBuffer(r),e=t.lt(kp.getN())}while(!e);return t};me._transformBuffer=function(e,t){var r={};if(e.length===32)return me._transformBNBuffer(e,t);if(r.network=hn.get(e[0],"privatekey"),!r.network)throw new Error("Invalid network");if(t&&r.network!==hn.get(t))throw new TypeError("Private key network mismatch");if(e.length===34&&e[33]===1)r.compressed=!0;else if(e.length===33)r.compressed=!1;else throw new Error("Length of buffer must be 33 (uncompressed) or 34 (compressed)");return r.bn=yi.fromBuffer(e.slice(1,33)),r};me._transformBNBuffer=function(e,t,r){var n={};return n.network=hn.get(t)||hn.defaultNetwork,n.bn=yi.fromBuffer(e),n.compressed=r===void 0?!0:!!r,n};me._transformWIF=function(e,t){return me._transformBuffer(sx.decode(e),t)};me.fromBuffer=function(e,t,r){return r!==void 0&&e&&e.length===32?new me(me._transformBNBuffer(e,t,r)):new me(e,t)};me.fromHex=function(e,t,r){return me.fromBuffer(d.Buffer.from(e,"hex"),t,r)};me._transformObject=function(e){if(e.bn instanceof yi)return{bn:e.bn,network:hn.get(e.network),compressed:e.compressed};if(typeof e.bn!="string"||!e.bn.length)throw new TypeError("Invalid private key: `bn` must be a hex string");if(e.bn===Mp)throw new TypeError('Invalid private key: `bn` is "'+Mp+'". JSON.stringify() redacts the secret on purpose \u2014 use toObject() for a round-trippable export, or toWIF().');if(!/^[0-9a-fA-F]+$/.test(e.bn))throw new TypeError("Invalid private key: `bn` is not hexadecimal");var t=new yi(e.bn,"hex");if(t.isZero()||t.gte(kp.getN()))throw new TypeError("Invalid private key: outside the range of valid keys");var r=hn.get(e.network);return{bn:t,network:r,compressed:e.compressed}};me.fromString=me.fromWIF=function(e,t){return ux.checkArgument(Uc.isString(e),"First argument is expected to be a string."),new me(e,t)};me.fromObject=me.fromJSON=function(e){return ux.checkArgument(Uc.isObject(e),"First argument is expected to be an object."),new me(e)};me.fromRandom=function(e){var t=me._getRandomBN();return new me(t,e)};me.getValidationError=function(e,t){var r;try{new me(e,t)}catch(n){r=n}return r};me.isValid=function(e,t){return e?!me.getValidationError(e,t):!1};me.prototype.toString=function(){return this.toWIF()};me.prototype.toWIF=function(){var e=this.network,t=this.compressed,r;return t?r=d.Buffer.concat([d.Buffer.from([e.privatekey]),this.bn.toBuffer({size:32}),d.Buffer.from([1])]):r=d.Buffer.concat([d.Buffer.from([e.privatekey]),this.bn.toBuffer({size:32})]),sx.encode(r)};me.prototype.toBigNumber=function(){return this.bn};me.prototype.toBuffer=function(){return this.bn.toBuffer({size:32})};me.prototype.toHex=function(){return this.toBuffer().toString("hex")};me.prototype.toPublicKey=function(){return this._pubkey||(this._pubkey=wk.fromPrivateKey(this)),this._pubkey};me.prototype.toAddress=function(e){var t=this.toPublicKey();return _k.fromPublicKey(t,e||this.network)};me.prototype.toObject=function(){return{bn:this.bn.toString("hex"),compressed:this.compressed,network:this.network.toString()}};me.prototype.toJSON=function(){return{bn:Mp,compressed:this.compressed,network:this.network.toString()}};me.prototype.inspect=function(){var e=this.compressed?"":", uncompressed";return"<PrivateKey: "+this.toHex()+", network: "+this.network+e+">"};fx.exports=me});var Tr=P((b5,lx)=>{"use strict";y();var cs=Er(),ls=ii(),Ek=Qt(),xk=pr(),cx=ga(),Cp=Ve(),so=ke();function le(e,t){if(!(this instanceof le))return new le(e,t);if(so.checkArgument(e,"First argument is required, please include public key data."),e instanceof le)return e;t=t||{};var r=this._classifyArgs(e,t);return r.point.validate(),xk.defineImmutable(this,{point:r.point,compressed:r.compressed,network:r.network||cx.defaultNetwork}),this}le.prototype._classifyArgs=function(e,t){var r={compressed:Cp.isUndefined(t.compressed)||t.compressed};if(e instanceof ls)r.point=e;else if(e.x&&e.y)r=le._transformObject(e);else if(typeof e=="string")r=le._transformDER(d.Buffer.from(e,"hex"));else if(le._isBuffer(e))r=le._transformDER(e);else if(le._isPrivateKey(e))r=le._transformPrivateKey(e);else throw new TypeError("First argument is an unrecognized data format.");return r.network||(r.network=Cp.isUndefined(t.network)?void 0:cx.get(t.network)),r};le._isPrivateKey=function(e){var t=no();return e instanceof t};le._isBuffer=function(e){return e instanceof d.Buffer||e instanceof Uint8Array};le._transformPrivateKey=function(e){so.checkArgument(le._isPrivateKey(e),"Must be an instance of PrivateKey");var t={};return t.point=ls.getG().mul(e.bn),t.compressed=e.compressed,t.network=e.network,t};le._transformDER=function(e,t){so.checkArgument(le._isBuffer(e),"Must be a buffer of DER encoded public key");var r={};t=Cp.isUndefined(t)?!0:t;var n,i,o,s;if(e[0]===4||!t&&(e[0]===6||e[0]===7)){if(o=e.slice(1,33),s=e.slice(33,65),o.length!==32||s.length!==32||e.length!==65)throw new TypeError("Length of x and y must be 32 bytes");n=new cs(o),i=new cs(s),r.point=new ls(n,i),r.compressed=!1}else if(e[0]===3)o=e.slice(1),n=new cs(o),r=le._transformX(!0,n),r.compressed=!0;else if(e[0]===2)o=e.slice(1),n=new cs(o),r=le._transformX(!1,n),r.compressed=!0;else throw new TypeError("Invalid DER format public key");return r};le._transformX=function(e,t){so.checkArgument(typeof e=="boolean","Must specify whether y is odd or not (true or false)");var r={};return r.point=ls.fromX(e,t),r};le._transformObject=function(e){var t=new cs(e.x,"hex"),r=new cs(e.y,"hex"),n=new ls(t,r);return new le(n,{compressed:e.compressed})};le.fromPrivateKey=function(e){so.checkArgument(le._isPrivateKey(e),"Must be an instance of PrivateKey");var t=le._transformPrivateKey(e);return new le(t.point,{compressed:t.compressed,network:t.network})};le.fromDER=le.fromBuffer=function(e,t){so.checkArgument(le._isBuffer(e),"Must be a buffer of DER encoded public key");var r=le._transformDER(e,t);return new le(r.point,{compressed:r.compressed})};le.fromPoint=function(e,t){return so.checkArgument(e instanceof ls,"First argument must be an instance of Point."),new le(e,{compressed:t})};le.fromHex=le.fromString=function(e,t){var r=d.Buffer.from(e,t||"hex"),n=le._transformDER(r);return new le(n.point,{compressed:n.compressed})};le.fromX=function(e,t){var r=le._transformX(e,t);return new le(r.point,{compressed:r.compressed})};le.getValidationError=function(e){var t;try{new le(e)}catch(r){t=r}return t};le.isValid=function(e){return!le.getValidationError(e)};le.prototype.toObject=le.prototype.toJSON=function(){return{x:this.point.getX().toString("hex",2),y:this.point.getY().toString("hex",2),compressed:this.compressed}};le.prototype.toBuffer=le.prototype.toDER=function(){var e=this.point.getX(),t=this.point.getY(),r=e.toBuffer({size:32}),n=t.toBuffer({size:32}),i;if(this.compressed){var o=n[n.length-1]%2;return o?i=d.Buffer.from([3]):i=d.Buffer.from([2]),d.Buffer.concat([i,r])}else return i=d.Buffer.from([4]),d.Buffer.concat([i,r,n])};le.prototype._getID=function(){return Ek.sha256ripemd160(this.toBuffer())};le.prototype.toAddress=function(e){var t=ro();return t.fromPublicKey(this,e||this.network)};le.prototype.toString=le.prototype.toHex=function(){return this.toDER().toString("hex")};le.prototype.inspect=function(){return"<PublicKey: "+this.toHex()+(this.compressed?"":", uncompressed")+">"};lx.exports=le});var Ka=P((w5,dx)=>{"use strict";y();var hx=ea();function Ik(){var e=hx.getRandomBuffer(16);e[6]=e[6]&15|64,e[8]=e[8]&63|128;var t=e.toString("hex");return[t.substring(0,8),t.substring(8,12),t.substring(12,16),t.substring(16,20),t.substring(20,32)].join("-")}function Ak(e){return hx.getRandomBuffer(Math.ceil(e/2)).toString("hex").substring(0,e)}dx.exports={uuid4:Ik,randomHex:Ak}});var vx=P((x5,mx)=>{"use strict";y();var Va=Tr(),Lp=Qt(),Dp=ka(),px=ir(),Up=no(),Rt=ke(),E5=Ve(),Ok=Ka();function gx(e,t){if(t=t||{},t.issuerPublicKey)return t.issuerPublicKey instanceof Va?t.issuerPublicKey:Va.fromString(t.issuerPublicKey);var r=e&&e.issuer;if(typeof r!="string")return null;try{var n=r.split("#")[0].split(":")[2];return n?Va.fromString(n):null}catch{return null}}var hs={PROPERTY_TITLE:"PropertyTitle",VEHICLE_TITLE:"VehicleTitle",INTELLECTUAL_PROPERTY:"IntellectualProperty",MUSIC_LICENSE:"MusicLicense",SOFTWARE_LICENSE:"SoftwareLicense",FINANCIAL_INSTRUMENT:"FinancialInstrument",PROMISSORY_NOTE:"PromissoryNote",BOND:"Bond",EQUITY_SHARE:"EquityShare",PROFESSIONAL_LICENSE:"ProfessionalLicense",REGULATORY_PERMIT:"RegulatoryPermit",ACCESS_RIGHT:"AccessRight",VOTING_RIGHT:"VotingRight",ROYALTY_RIGHT:"RoyaltyRight",USAGE_RIGHT:"UsageRight"},yx={create:function(e,t,r,n,i,o){o=o||{},Rt.checkArgument(typeof e=="string","Right type must be string"),Rt.checkArgument(typeof t=="string","Issuer DID must be string"),Rt.checkArgument(typeof r=="string","Subject DID must be string"),Rt.checkArgument(n&&typeof n=="object","Claim must be object");var s=Object.values(hs);Rt.checkArgument(s.includes(e),"Invalid right type: "+e);var a={"@context":["https://www.w3.org/2018/credentials/v1","https://smartledger.technology/contexts/ltp/v1"],id:"urn:uuid:"+this._generateUUID(),type:["VerifiableCredential","LegalRightToken",e],issuer:t,issuanceDate:new Date().toISOString(),credentialSubject:{id:r,rightType:e,claim:n,jurisdiction:o.jurisdiction||"US",purpose:o.purpose||"legal_right",validFrom:o.validFrom||new Date().toISOString(),validUntil:o.validUntil||null,transferable:o.transferable!==!1,revocable:o.revocable!==!1}};return o.metadata&&(a.credentialSubject.metadata=o.metadata),a},prepareRightToken:function(e,t,r,n,i,o){o=o||{},Rt.checkArgument(typeof e=="string","Right type must be string"),Rt.checkArgument(typeof t=="string","Issuer DID must be string"),Rt.checkArgument(typeof r=="string","Subject DID must be string"),Rt.checkArgument(n&&typeof n=="object","Claim must be object"),Rt.checkArgument(i instanceof Up,"Invalid issuer private key");var s=Object.values(hs);Rt.checkArgument(s.includes(e),"Invalid right type: "+e);try{var a=this.create(e,t,r,n,i,o),c=this._signToken(a,i);return{success:!0,rightToken:c,tokenHash:c.tokenHash,metadata:{type:e,issuer:t,subject:r,transferable:a.credentialSubject.transferable,revocable:a.credentialSubject.revocable,jurisdiction:a.credentialSubject.jurisdiction},externalOperations:{storeToken:{endpoint:"POST /rights/tokens",data:{token:c,metadata:{type:e,issuer:t,subject:r,transferable:a.credentialSubject.transferable,revocable:a.credentialSubject.revocable,jurisdiction:a.credentialSubject.jurisdiction}}},indexToken:{endpoint:"POST /rights/index",data:{tokenId:c.id,tokenHash:c.tokenHash,type:e,issuer:t,subject:r,issuedAt:c.issuanceDate}},notifyParties:{endpoint:"POST /notifications/right-issued",data:{tokenId:c.id,issuer:t,subject:r,rightType:e}}}}}catch(h){return{success:!1,error:h.message}}},prepareRightTokenVerification:function(e,t){t=t||{};try{var r=[],n=[];this._validateTokenStructure(e,r),this._verifyTokenSignature(e,r,t),this._validateTokenTemporal(e,r,n),this._validateRightType(e,r),t.requireJurisdiction&&this._validateJurisdiction(e,t.allowedJurisdictions,r);var i={valid:r.length===0,errors:r,warnings:n,issuerDID:e.issuer,subjectDID:e.credentialSubject?e.credentialSubject.id:null,rightType:e.credentialSubject?e.credentialSubject.rightType:null,transferable:e.credentialSubject?e.credentialSubject.transferable:null,revocable:e.credentialSubject?e.credentialSubject.revocable:null,verifiedAt:new Date().toISOString()};return{success:!0,verification:i,externalOperations:{recordVerification:{endpoint:"POST /rights/verification-record",data:{tokenId:e.id,result:i.valid,errors:r,warnings:n,verifiedAt:i.verifiedAt}},auditVerification:{endpoint:"POST /audit/right-verification",data:{tokenId:e.id,rightType:i.rightType,issuer:i.issuerDID,subject:i.subjectDID,result:i.valid,verifiedAt:i.verifiedAt}},updateTokenStatus:i.valid?{endpoint:"PUT /rights/tokens/"+e.id+"/status",data:{status:"VERIFIED",verifiedAt:i.verifiedAt}}:null}}}catch(o){return{success:!1,error:"Verification preparation failed: "+o.message}}},prepareRightTokenTransfer:function(e,t,r,n){n=n||{},Rt.checkArgument(e&&typeof e=="object","Invalid token"),Rt.checkArgument(typeof t=="string","New owner DID must be string"),Rt.checkArgument(r instanceof Up,"Invalid current owner key");try{var i=this.prepareRightTokenVerification(e,{});if(!i.success||!i.verification.valid)return{success:!1,error:"Cannot transfer invalid token: "+i.verification.errors.join(", ")};if(!e.credentialSubject.transferable)return{success:!1,error:"Token is not transferable"};var o=e.credentialSubject&&e.credentialSubject.id,s=gx({issuer:o},{issuerPublicKey:n.currentOwnerPublicKey});if(!s)return{success:!1,error:"Cannot resolve current owner public key from token.credentialSubject.id; pass options.currentOwnerPublicKey"};if(r.toPublicKey().toString()!==s.toString())return{success:!1,error:"Unauthorized transfer: signing key does not match the current owner"};var a={"@context":["https://www.w3.org/2018/credentials/v1","https://smartledger.technology/contexts/ltp/v1"],id:"urn:uuid:"+this._generateUUID(),type:["VerifiableCredential","LegalRightTransfer"],issuer:e.credentialSubject.id,issuanceDate:new Date().toISOString(),credentialSubject:{id:t,originalToken:e.id,transferFrom:e.credentialSubject.id,transferTo:t,transferDate:new Date().toISOString(),transferReason:n.reason||"ownership_transfer",consideration:n.consideration||null}},c=this._signToken(a,r),h=JSON.parse(JSON.stringify(e));h.id="urn:uuid:"+this._generateUUID(),h.issuanceDate=new Date().toISOString(),h.credentialSubject.id=t,h.credentialSubject.transferHistory=h.credentialSubject.transferHistory||[],h.credentialSubject.transferHistory.push({transferId:c.id,transferDate:c.issuanceDate,from:e.credentialSubject.id,to:t}),delete h.proof;var g=this._signToken(h,r);return{success:!0,newToken:g,transferProof:c,transferId:c.id,externalOperations:{recordTransfer:{endpoint:"POST /rights/transfers",data:{originalTokenId:e.id,newTokenId:g.id,transferProof:c,fromOwner:e.credentialSubject.id,toOwner:t,transferDate:c.issuanceDate}},updateOwnership:{endpoint:"PUT /rights/tokens/"+e.id+"/ownership",data:{newOwner:t,transferId:c.id,transferDate:c.issuanceDate,previousOwner:e.credentialSubject.id}},notifyParties:{endpoint:"POST /notifications/right-transferred",data:{originalTokenId:e.id,newTokenId:g.id,fromOwner:e.credentialSubject.id,toOwner:t,rightType:e.credentialSubject.rightType}},auditTransfer:{endpoint:"POST /audit/right-transfer",data:{originalTokenId:e.id,newTokenId:g.id,transferId:c.id,fromOwner:e.credentialSubject.id,toOwner:t,transferredAt:c.issuanceDate}}}}}catch(m){return{success:!1,error:m.message}}},prepareObligationToken:function(e,t,r,n){Rt.checkArgument(e&&typeof e=="object","Invalid right token"),Rt.checkArgument(typeof t=="string","Obligor DID must be string"),Rt.checkArgument(r&&typeof r=="object","Obligation must be object"),Rt.checkArgument(n instanceof Up,"Invalid issuer key");try{var i={"@context":["https://www.w3.org/2018/credentials/v1","https://smartledger.technology/contexts/ltp/v1"],id:"urn:uuid:"+this._generateUUID(),type:["VerifiableCredential","LegalObligationToken"],issuer:e.issuer,issuanceDate:new Date().toISOString(),credentialSubject:{id:t,obligationType:"correlative_obligation",correlativeRight:e.id,rightHolder:e.credentialSubject.id,obligation:r,jurisdiction:e.credentialSubject.jurisdiction,purpose:e.credentialSubject.purpose}},o=this._signToken(i,n);return{success:!0,obligationToken:o,correlativeRight:e.id,externalOperations:{storeObligation:{endpoint:"POST /obligations/tokens",data:{obligationToken:o,correlativeRightId:e.id,obligor:t,rightHolder:e.credentialSubject.id}},linkToRight:{endpoint:"POST /rights/tokens/"+e.id+"/obligations",data:{obligationId:o.id,obligor:t,obligationType:"correlative_obligation"}},notifyObligor:{endpoint:"POST /notifications/obligation-created",data:{obligationId:o.id,obligor:t,rightHolder:e.credentialSubject.id,correlativeRight:e.id}}}}}catch(s){return{success:!1,error:s.message}}},prepareRightTypeValidation:function(e){Rt.checkArgument(typeof e=="string","Right type must be string");var t=Object.values(hs),r=t.includes(e);return{success:!0,validation:{type:e,valid:r,availableTypes:t,category:this._categorizeRightType(e),description:this._getRightTypeDescription(e)},externalOperations:{validateType:{endpoint:"POST /rights/validate-type",data:{type:e,valid:r}}}}},_categorizeRightType:function(e){var t={PropertyTitle:"PROPERTY_RIGHT",VehicleTitle:"PROPERTY_RIGHT",IntellectualProperty:"IP_RIGHT",MusicLicense:"IP_RIGHT",SoftwareLicense:"IP_RIGHT",FinancialInstrument:"FINANCIAL_RIGHT",PromissoryNote:"FINANCIAL_RIGHT",Bond:"FINANCIAL_RIGHT",EquityShare:"FINANCIAL_RIGHT",ProfessionalLicense:"LICENSE_RIGHT",RegulatoryPermit:"LICENSE_RIGHT",AccessRight:"ACCESS_RIGHT",VotingRight:"GOVERNANCE_RIGHT",RoyaltyRight:"IP_RIGHT",UsageRight:"ACCESS_RIGHT"};return t[e]||"UNKNOWN"},_getRightTypeDescription:function(e){var t={PropertyTitle:"Legal ownership of real estate property",VehicleTitle:"Legal ownership of motor vehicle",IntellectualProperty:"Rights to intellectual property assets",MusicLicense:"License for music performance and usage",SoftwareLicense:"License for software usage and distribution",FinancialInstrument:"Rights related to financial instruments",PromissoryNote:"Promise to pay a specified amount",Bond:"Debt security representing loan",EquityShare:"Ownership stake in company",ProfessionalLicense:"License for professional practice",RegulatoryPermit:"Permit for regulated activities",AccessRight:"Right to access resources or locations",VotingRight:"Right to participate in governance",RoyaltyRight:"Right to receive royalty payments",UsageRight:"Right to use specific assets or services"};return t[e]||"Unknown right type"},getRightTypes:function(){return hs},verifyToken:function(e,t){var r=[];try{if(Rt.checkArgument(e&&typeof e=="object","Invalid token"),!e.proof||!e.proof.jws)return r.push("Missing signature proof"),{valid:!1,errors:r};var n=t instanceof Va?t:Va.fromString(t),i=this._canonicalizeToken(e),o=Lp.sha256(d.Buffer.from(i));if(e.tokenHash&&e.tokenHash!==o.toString("hex"))return r.push("Token hash mismatch"),{valid:!1,errors:r};var s=e.proof.jws.split(".");if(s.length!==3||!s[2])return r.push("Malformed JWS"),{valid:!1,errors:r};var a=px.fromDER(d.Buffer.from(s[2],"base64url")),c=new Dp;return c.hashbuf=o,c.sig=a,c.pubkey=n,c.verify()||r.push("Signature verification failed"),{valid:r.length===0,errors:r,tokenHash:o.toString("hex"),verifiedAt:new Date().toISOString()}}catch(h){return r.push(h.message),{valid:!1,errors:r}}},_signToken:function(e,t){var r=this._canonicalizeToken(e),n=Lp.sha256(d.Buffer.from(r)),i=new Dp;i.hashbuf=n,i.privkey=t,i.pubkey=t.toPublicKey(),i.sign();var o=i.sig,s={type:"EcdsaSecp256k1Signature2019",created:new Date().toISOString(),verificationMethod:"did:smartledger:"+t.toPublicKey().toString()+"#keys-1",proofPurpose:"assertionMethod",jws:this._createJWS(n,o)},a=JSON.parse(JSON.stringify(e));return a.proof=s,a.tokenHash=n.toString("hex"),a},_createJWS:function(e,t){var r={alg:"ES256K",typ:"JWT"},n=d.Buffer.from(JSON.stringify(r)).toString("base64url"),i=t.toDER().toString("base64url");return n+".."+i},_canonicalizeToken:function(e){var t=JSON.parse(JSON.stringify(e));return delete t.proof,delete t.tokenHash,JSON.stringify(this._sortObjectKeys(t))},_sortObjectKeys:function(e){if(Array.isArray(e))return e.map(this._sortObjectKeys.bind(this));if(e!==null&&typeof e=="object"){var t={};return Object.keys(e).sort().forEach(function(r){t[r]=this._sortObjectKeys(e[r])}.bind(this)),t}return e},_validateTokenStructure:function(e,t){e["@context"]||t.push("Missing @context"),e.id||t.push("Missing id"),(!e.type||!Array.isArray(e.type))&&t.push("Missing or invalid type"),e.issuer||t.push("Missing issuer"),e.issuanceDate||t.push("Missing issuanceDate"),e.credentialSubject||t.push("Missing credentialSubject"),e.proof||t.push("Missing proof")},_verifyTokenSignature:function(e,t,r){try{if(!e.proof||!e.proof.jws){t.push("Missing signature proof");return}var n=this._canonicalizeToken(e),i=Lp.sha256(d.Buffer.from(n));if(e.tokenHash&&e.tokenHash!==i.toString("hex")){t.push("Token hash mismatch");return}var o=gx(e,r);if(!o){t.push("Signature not verified: issuer public key could not be resolved from token.issuer; pass options.issuerPublicKey");return}var s=e.proof.jws.split(".");if(s.length!==3||!s[2]){t.push("Malformed JWS");return}var a=px.fromDER(d.Buffer.from(s[2],"base64url")),c=new Dp;c.hashbuf=i,c.sig=a,c.pubkey=o,c.verify()!==!0&&t.push("Signature verification failed")}catch(h){t.push("Signature verification failed: "+h.message)}},_validateTokenTemporal:function(e,t,r){var n=new Date,i=new Date(e.issuanceDate);if(i>n&&t.push("Token issued in the future"),e.credentialSubject.validFrom){var o=new Date(e.credentialSubject.validFrom);n<o&&r.push("Token not yet valid")}if(e.credentialSubject.validUntil){var s=new Date(e.credentialSubject.validUntil);n>s&&t.push("Token expired")}},_validateRightType:function(e,t){if(!e.credentialSubject.rightType){t.push("Missing rightType");return}var r=Object.values(hs);r.includes(e.credentialSubject.rightType)||t.push("Invalid right type: "+e.credentialSubject.rightType)},_validateJurisdiction:function(e,t,r){if(!e.credentialSubject.jurisdiction){r.push("Missing jurisdiction");return}t&&Array.isArray(t)&&(t.includes(e.credentialSubject.jurisdiction)||r.push("Jurisdiction not allowed: "+e.credentialSubject.jurisdiction))},_generateUUID:function(){return Ok.uuid4()}};yx.RightTypes=hs;mx.exports=yx});var _x=P((A5,bx)=>{"use strict";y();var Ga=Qt(),yr=ke(),Rk=Ka(),ao={PropertyTitle:{title:"Property Title",description:"Real estate property ownership title",type:"object",required:["propertyId","address","ownershipType"],properties:{propertyId:{type:"string",description:"Unique property identifier"},address:{type:"object",required:["street","city","state","country"],properties:{street:{type:"string"},city:{type:"string"},state:{type:"string"},country:{type:"string"},postalCode:{type:"string"}}},ownershipType:{type:"string",enum:["fee_simple","leasehold","joint_tenancy","tenancy_in_common"]},titleNumber:{type:"string"},registeredDate:{type:"string",format:"date-time"},legalDescription:{type:"string"},encumbrances:{type:"array",items:{type:"object",properties:{type:{type:"string"},amount:{type:"number"},description:{type:"string"}}}}}},VehicleTitle:{title:"Vehicle Title",description:"Motor vehicle ownership title",type:"object",required:["vin","make","model","year"],properties:{vin:{type:"string",pattern:"^[A-HJ-NPR-Z0-9]{17}$",description:"Vehicle Identification Number"},make:{type:"string"},model:{type:"string"},year:{type:"integer",minimum:1900,maximum:2030},titleNumber:{type:"string"},registeredState:{type:"string"},mileage:{type:"integer",minimum:0},color:{type:"string"},fuelType:{type:"string",enum:["gasoline","diesel","electric","hybrid","other"]},liens:{type:"array",items:{type:"object",properties:{lienholderName:{type:"string"},lienAmount:{type:"number"},lienDate:{type:"string",format:"date"}}}}}},PromissoryNote:{title:"Promissory Note",description:"Legal promise to pay a specified amount",type:"object",required:["principal","interestRate","maturityDate","borrower","lender"],properties:{principalAmount:{type:"number",minimum:0,description:"Principal amount in base currency units"},currency:{type:"string",default:"USD"},interestRate:{type:"number",minimum:0,maximum:100,description:"Annual interest rate percentage"},maturityDate:{type:"string",format:"date",description:"Date when principal and interest are due"},payee:{type:"string",description:"DID of the payee (creditor)"},payor:{type:"string",description:"DID of the payor (debtor)"},paymentSchedule:{type:"string",enum:["lump_sum","monthly","quarterly","annually"]},collateral:{type:"array",items:{type:"object",properties:{description:{type:"string"},value:{type:"number"},type:{type:"string"}}}},defaultProvisions:{type:"string"},governingLaw:{type:"string"}}},IntellectualProperty:{title:"Intellectual Property",description:"Intellectual property rights and licensing",type:"object",required:["ipType","title","registrationNumber"],properties:{ipType:{type:"string",enum:["patent","trademark","copyright","trade_secret"]},title:{type:"string"},creator:{type:"string",description:"Creator DID"},registrationNumber:{type:"string"},registrationDate:{type:"string",format:"date"},expirationDate:{type:"string",format:"date"},jurisdiction:{type:"string"},description:{type:"string"},claims:{type:"array",items:{type:"string"}},priorArt:{type:"array",items:{type:"object",properties:{reference:{type:"string"},date:{type:"string",format:"date"},relevance:{type:"string"}}}}}},ProfessionalLicense:{title:"Professional License",description:"Professional practice license or certification",type:"object",required:["licenseType","licenseNumber","issuingAuthority","expirationDate"],properties:{licenseType:{type:"string"},licenseNumber:{type:"string"},issuingAuthority:{type:"string"},licensee:{type:"string",description:"Licensee DID"},issueDate:{type:"string",format:"date"},expirationDate:{type:"string",format:"date"},renewalDate:{type:"string",format:"date"},jurisdiction:{type:"string"},scope:{type:"string"},restrictions:{type:"array",items:{type:"string"}},continuing_education:{type:"object",properties:{hours_required:{type:"integer"},deadline:{type:"string",format:"date"},completed_hours:{type:"integer"}}}}},MusicLicense:{title:"Music License",description:"Music performance and usage licensing",type:"object",required:["songTitle","artist","licenseType","royaltyRate"],properties:{workTitle:{type:"string"},composer:{type:"string",description:"Composer DID"},performer:{type:"string",description:"Performer DID"},licenseType:{type:"string",enum:["mechanical","performance","synchronization","master_use"]},territory:{type:"string"},duration:{type:"string"},royaltyRate:{type:"number",minimum:0,maximum:100},advancePayment:{type:"number",minimum:0},exclusivity:{type:"boolean"},mediaTypes:{type:"array",items:{type:"string",enum:["cd","vinyl","digital","streaming","broadcast","film","tv"]}},usage_restrictions:{type:"string"},copyrightNotice:{type:"string"}}}},Tk={prepareClaimValidation:function(e,t){try{yr.checkArgument(e&&typeof e=="object","Invalid claim"),yr.checkArgument(typeof t=="string","Schema name must be string");var r=ao[t];if(!r)return{success:!1,error:"Unknown schema: "+t};var n=[],i=[];this._validateObject(e,r,"",n,i);var o={valid:n.length===0,errors:n,warnings:i,schema:t,claimHash:this.hash(e),canonical:this.canonicalize(e)};return{success:!0,validation:o,claim:e,schema:r,externalOperations:{store:{endpoint:"POST /claims/validate",data:{claim:e,validation:o,schema:t}},index:{endpoint:"POST /claims/index",data:{claimHash:o.claimHash,schemaName:t,valid:o.valid}}}}}catch(s){return{success:!1,error:"Validation preparation failed: "+s.message}}},prepareClaimAttestation:function(e,t,r){try{yr.checkArgument(e&&typeof e=="object","Invalid claim"),yr.checkArgument(typeof t=="string","Schema name must be string"),yr.checkArgument(r&&typeof r=="object","Invalid attestor");var n=this.prepareClaimValidation(e,t);if(!n.success||!n.validation.valid)return{success:!1,error:"Cannot attest invalid claim",validation:n};var i={type:"LTP_CLAIM_ATTESTATION",claimHash:n.validation.claimHash,schemaName:t,attestor:{did:r.did||r.id,name:r.name||"Unknown",authority:r.authority||null,jurisdiction:r.jurisdiction||null},attestedAt:new Date().toISOString(),confidence:r.confidence||100,evidence:r.evidence||null,notes:r.notes||null},o=Ga.sha256(d.Buffer.from(this.canonicalize(i))).toString("hex");return i.attestationHash=o,{success:!0,attestation:i,claim:e,validation:n.validation,externalOperations:{storeAttestation:{endpoint:"POST /claims/"+n.validation.claimHash+"/attestations",data:i},notifyStakeholders:{endpoint:"POST /notifications/claim-attested",data:{claimHash:n.validation.claimHash,attestorDid:i.attestor.did,attestationHash:o}}}}}catch(s){return{success:!1,error:"Attestation preparation failed: "+s.message}}},prepareClaimDispute:function(e,t,r){try{yr.checkArgument(typeof e=="string","Claim hash must be string"),yr.checkArgument(t&&typeof t=="object","Invalid disputant"),yr.checkArgument(r&&typeof r=="object","Invalid dispute");var n={type:"LTP_CLAIM_DISPUTE",claimHash:e,disputant:{did:t.did||t.id,name:t.name||"Unknown",jurisdiction:t.jurisdiction||null},dispute:{reason:r.reason||"UNSPECIFIED",category:r.category||"ACCURACY",description:r.description||"",evidence:r.evidence||null,requestedAction:r.requestedAction||"REVIEW"},disputedAt:new Date().toISOString(),status:"FILED",priority:r.priority||"NORMAL"},i=Ga.sha256(d.Buffer.from(this.canonicalize(n))).toString("hex");return n.disputeHash=i,{success:!0,dispute:n,disputeId:this._generateDisputeId(e),externalOperations:{fileDispute:{endpoint:"POST /claims/"+e+"/disputes",data:n},notifyStakeholders:{endpoint:"POST /notifications/claim-disputed",data:{claimHash:e,disputantDid:n.disputant.did,disputeHash:i}},escalate:{endpoint:"POST /disputes/escalate",data:{disputeHash:i,priority:n.priority}}}}}catch(o){return{success:!1,error:"Dispute preparation failed: "+o.message}}},prepareBulkClaimValidation:function(e,t){try{yr.checkArgument(Array.isArray(e),"Claims must be array"),yr.checkArgument(typeof t=="string","Schema name must be string");var r=[],n=[],i=0;e.forEach(function(a,c){try{var h=this.prepareClaimValidation(a,t);h.success&&h.validation.valid&&i++,r.push({index:c,result:h})}catch(g){n.push({index:c,error:g.message})}}.bind(this));var o=this._generateBatchId(),s=Ga.sha256(d.Buffer.from(JSON.stringify(r.map(a=>a.result.validation.claimHash)))).toString("hex");return{success:!0,batchId:o,batchHash:s,totalClaims:e.length,validClaims:i,invalidClaims:e.length-i,validations:r,errors:n,externalOperations:{storeBatch:{endpoint:"POST /claims/batch-validate",data:{batchId:o,batchHash:s,schemaName:t,validations:r}},generateReport:{endpoint:"POST /reports/bulk-validation",data:{batchId:o,summary:{total:e.length,valid:i,invalid:e.length-i}}}}}}catch(a){return{success:!1,error:"Bulk validation preparation failed: "+a.message}}},canonicalize:function(e){yr.checkArgument(e&&typeof e=="object","Invalid claim");var t=this._sortObjectKeys(e);return JSON.stringify(t)},hash:function(e){var t=this.canonicalize(e);return Ga.sha256(d.Buffer.from(t)).toString("hex")},prepareClaimTemplate:function(e,t){t=t||{};try{var r=ao[e];if(!r)return{success:!1,error:"Unknown schema: "+e};var n=this._createTemplateFromSchema(r),i=this._generateFormStructure(r);return{success:!0,schemaName:e,template:n,schema:r,formStructure:i,validation:{required:r.required||[],patterns:this._extractPatterns(r),enums:this._extractEnums(r)},externalOperations:{generateForm:{endpoint:"POST /forms/generate",data:{schemaName:e,formStructure:i,template:n}},saveTemplate:{endpoint:"POST /templates/claim",data:{schemaName:e,template:n,customizations:t.customizations||{}}}}}}catch(o){return{success:!1,error:"Template preparation failed: "+o.message}}},getSchemas:function(){return ao},getSchemaNames:function(){return Object.keys(ao)},getSchema:function(e){return ao[e]||null},addSchema:function(e,t){yr.checkArgument(typeof e=="string","Schema name must be string"),yr.checkArgument(t&&typeof t=="object","Invalid schema"),ao[e]=t},createTemplate:function(e){var t=ao[e];if(!t)throw new Error("Unknown schema: "+e);return this._createTemplateFromSchema(t)},_generateDisputeId:function(e){var t="dispute_"+e+"_"+Date.now();return Ga.sha256(d.Buffer.from(t)).toString("hex").substring(0,16)},_generateBatchId:function(){return Rk.randomHex(16)},_generateFormStructure:function(e){var t={type:"form",title:e.title||"Legal Claim Form",description:e.description||"",fields:[]};return e.properties&&Object.keys(e.properties).forEach(function(r){var n=e.properties[r],i={name:r,label:this._humanizeFieldName(r),type:this._mapSchemaTypeToFormType(n),required:e.required&&e.required.includes(r),validation:this._extractFieldValidation(n)};n.enum&&(i.options=n.enum.map(function(o){return{value:o,label:this._humanizeValue(o)}}.bind(this))),t.fields.push(i)}.bind(this)),t},_extractPatterns:function(e){var t={};return e.properties&&Object.keys(e.properties).forEach(function(r){var n=e.properties[r];n.pattern&&(t[r]=n.pattern)}),t},_extractEnums:function(e){var t={};return e.properties&&Object.keys(e.properties).forEach(function(r){var n=e.properties[r];n.enum&&(t[r]=n.enum)}),t},_mapSchemaTypeToFormType:function(e){switch(e.type){case"string":return e.enum?"select":e.format==="date"?"date":e.format==="date-time"?"datetime":"text";case"number":case"integer":return"number";case"boolean":return"checkbox";case"array":return"list";case"object":return"fieldset";default:return"text"}},_extractFieldValidation:function(e){var t={};return e.pattern&&(t.pattern=e.pattern),e.minimum!==void 0&&(t.min=e.minimum),e.maximum!==void 0&&(t.max=e.maximum),e.format&&(t.format=e.format),t},_humanizeFieldName:function(e){return e.replace(/([A-Z])/g," $1").replace(/^./,function(t){return t.toUpperCase()}).replace(/_/g," ")},_humanizeValue:function(e){return e.replace(/_/g," ").replace(/\b\w/g,function(t){return t.toUpperCase()})},_validateObject:function(e,t,r,n,i){t.type==="object"?(t.required&&Array.isArray(t.required)&&t.required.forEach(function(o){e.hasOwnProperty(o)||n.push("Missing required field: "+this._getFieldPath(r,o))}.bind(this)),t.properties&&Object.keys(e).forEach(function(o){var s=this._getFieldPath(r,o),a=t.properties[o];a?this._validateValue(e[o],a,s,n,i):i.push("Unknown field: "+s)}.bind(this))):this._validateValue(e,t,r,n,i)},_validateValue:function(e,t,r,n,i){if(t.type){var o=Array.isArray(e)?"array":typeof e;if(o!==t.type){n.push("Invalid type for "+r+": expected "+t.type+", got "+o);return}}if(t.type==="string"&&(t.pattern&&!new RegExp(t.pattern).test(e)&&n.push("Value does not match pattern for "+r),t.enum&&!t.enum.includes(e)&&n.push("Invalid enum value for "+r+": "+e),t.format==="date"&&!this._isValidDate(e)&&n.push("Invalid date format for "+r),t.format==="date-time"&&!this._isValidDateTime(e)&&n.push("Invalid date-time format for "+r)),(t.type==="number"||t.type==="integer")&&(t.minimum!==void 0&&e<t.minimum&&n.push("Value below minimum for "+r+": "+e+" < "+t.minimum),t.maximum!==void 0&&e>t.maximum&&n.push("Value above maximum for "+r+": "+e+" > "+t.maximum),t.type==="integer"&&!Number.isInteger(e)&&n.push("Value must be integer for "+r)),t.type==="array"&&t.items)for(var s=0;s<e.length;s++)this._validateValue(e[s],t.items,r+"["+s+"]",n,i);t.type==="object"&&this._validateObject(e,t,r,n,i)},_sortObjectKeys:function(e){if(Array.isArray(e))return e.map(this._sortObjectKeys.bind(this));if(e!==null&&typeof e=="object"){var t={};return Object.keys(e).sort().forEach(function(r){t[r]=this._sortObjectKeys(e[r])}.bind(this)),t}return e},_createTemplateFromSchema:function(e){if(e.type==="object"){var t={};return e.properties&&Object.keys(e.properties).forEach(function(r){var n=e.properties[r];t[r]=this._getDefaultValue(n)}.bind(this)),t}return this._getDefaultValue(e)},_getDefaultValue:function(e){if(e.default!==void 0)return e.default;switch(e.type){case"string":return e.enum?e.enum[0]:e.format==="date"?"2023-01-01":e.format==="date-time"?new Date().toISOString():"PLACEHOLDER_STRING";case"number":case"integer":return e.minimum||0;case"boolean":return!1;case"array":return[];case"object":return this._createTemplateFromSchema(e);default:return null}},_getFieldPath:function(e,t){return e?e+"."+t:t},_isValidDate:function(e){var t=new Date(e);return!isNaN(t.getTime())&&e.match(/^\d{4}-\d{2}-\d{2}$/)},_isValidDateTime:function(e){var t=new Date(e);return!isNaN(t.getTime())}};bx.exports=Tk});var Sx=P((R5,wx)=>{"use strict";y();var Wa=Qt(),ds=ke(),Pk={prepareTokenCommitment:function(e,t){t=t||{},ds.checkArgument(e&&typeof e=="object","Invalid token");try{var r=this._createCommitment(e,t),n=this._formatOpReturn(r,t),i=this._createTxTemplate(n,t);return{success:!0,commitment:r,opReturnData:n,txTemplate:i,preparedAt:new Date().toISOString(),metadata:{tokenId:e.id,purpose:t.purpose||"legal_token_anchor",version:"LTP.v1"}}}catch(o){return{success:!1,error:o.message}}},prepareBatchCommitment:function(e,t){t=t||{},ds.checkArgument(Array.isArray(e),"Tokens must be array");try{var r=this._createBatchCommitment(e,t),n=this._formatOpReturn(r,t),i=this._createTxTemplate(n,t);return{success:!0,batchCommitment:r,opReturnData:n,txTemplate:i,tokenCount:e.length,preparedAt:new Date().toISOString(),metadata:{purpose:t.purpose||"legal_token_batch_anchor",version:"LTP.v1"}}}catch(o){return{success:!1,error:o.message}}},verifyTokenAnchor:function(e,t,r){ds.checkArgument(e&&typeof e=="object","Invalid token"),ds.checkArgument(typeof t=="string","Transaction ID must be string");try{var n=this._createCommitment(e,{}),i=this._extractOpReturn(r);if(!i)return{valid:!1,error:"No OP_RETURN data found in transaction"};var o=this._verifyCommitment(n,i);return{valid:o,chainVerified:!1,txid:t,commitment:n,anchorData:i,verifiedAt:new Date().toISOString()}}catch(s){return{valid:!1,error:s.message}}},formatRevocation:function(e,t){ds.checkArgument(typeof e=="string","Token ID must be string"),ds.checkArgument(t&&typeof t=="object","Invalid revocation data");try{var r={type:"LTP_REVOCATION",tokenId:e,reason:t.reason||"UNSPECIFIED",revokedBy:t.revokedBy||"UNKNOWN",revokedAt:new Date().toISOString(),effectiveDate:t.effectiveDate||new Date().toISOString(),legalBasis:t.legalBasis||null,evidence:t.evidence||null},n=Wa.sha256(d.Buffer.from(JSON.stringify(r))).toString("hex");return{success:!0,revocation:r,revocationHash:n,opReturnData:this._formatOpReturn({hash:n,type:"REVOCATION"},{})}}catch(i){return{success:!1,error:i.message}}},_createCommitment:function(e,t){var r=this._canonicalizeToken(e),n={type:"LTP_TOKEN",tokenHash:Wa.sha256(d.Buffer.from(r)).toString("hex"),tokenId:e.id,timestamp:new Date().toISOString(),purpose:t.purpose||"legal_token"},i=Wa.sha256(d.Buffer.from(JSON.stringify(n))).toString("hex");return{hash:i,data:n,canonical:r}},_createBatchCommitment:function(e,t){var r=[],n=[];e.forEach(function(a){var c=this._createCommitment(a,t);r.push(c.hash),n.push(a.id)}.bind(this));var i=this._createMerkleRoot(r),o={type:"LTP_BATCH",merkleRoot:i,tokenCount:e.length,tokenIds:n,timestamp:new Date().toISOString(),purpose:t.purpose||"batch_anchor"},s=Wa.sha256(d.Buffer.from(JSON.stringify(o))).toString("hex");return{hash:s,data:o,merkleRoot:i,tokenHashes:r}},_formatOpReturn:function(e,t){var r=t.prefix||"LTP.v1",n=e.hash;return{prefix:r,data:n,full:r+"."+n,bytes:d.Buffer.from(r+"."+n,"utf8"),size:d.Buffer.from(r+"."+n,"utf8").length}},_createTxTemplate:function(e,t){try{var r={version:1,inputs:[],outputs:[{satoshis:0,script:"OP_RETURN "+e.data}],locktime:0};return t.feeOutput&&r.outputs.push(t.feeOutput),{template:r,opReturn:e,estimatedSize:this._estimateSize(r),instructions:{step1:"Add input UTXOs to cover fees",step2:"Add change output if needed",step3:"Sign transaction with appropriate keys",step4:"Broadcast to BSV network"}}}catch(n){throw new Error("Failed to create transaction template: "+n.message)}},_extractOpReturn:function(e){try{if(!e||!e.outputs)return null;for(var t=0;t<e.outputs.length;t++){var r=e.outputs[t];if(r.script&&r.script.startsWith("OP_RETURN")){var n=r.script.replace("OP_RETURN ","");return{raw:n,decoded:d.Buffer.from(n,"hex").toString("utf8")}}}return null}catch{return null}},_verifyCommitment:function(e,t){try{return!t||!t.decoded?!1:t.decoded.includes(e.hash)}catch{return!1}},_canonicalizeToken:function(e){var t=JSON.parse(JSON.stringify(e));return delete t.proof,delete t.tokenHash,delete t.anchorTx,delete t.anchorBlock,JSON.stringify(this._sortObjectKeys(t))},_createMerkleRoot:function(e){if(e.length===0)return null;if(e.length===1)return e[0];for(var t=e.slice();t.length>1;){for(var r=[],n=0;n<t.length;n+=2){var i=t[n],o=t[n+1]||i,s=d.Buffer.concat([d.Buffer.from(i,"hex"),d.Buffer.from(o,"hex")]),a=Wa.sha256(s).toString("hex");r.push(a)}t=r}return t[0]},_estimateSize:function(e){var t=10,r=e.outputs.length*34,n=148;return{base:t+r,withOneInput:t+r+n,bytesPerInput:n}},_sortObjectKeys:function(e){if(Array.isArray(e))return e.map(this._sortObjectKeys.bind(this));if(e!==null&&typeof e=="object"){var t={};return Object.keys(e).sort().forEach(function(r){t[r]=this._sortObjectKeys(e[r])}.bind(this)),t}return e}};wx.exports=Pk});var Ix=P((P5,xx)=>{"use strict";y();var Bk=Tr(),Yr=Qt(),Ex=ka(),Nk=ir(),Mk=no(),or=ke(),kk={prepareSignatureProof:function(e,t,r){r=r||{},or.checkArgument(e&&typeof e=="object","Invalid token"),or.checkArgument(t instanceof Mk,"Invalid private key");try{var n=this._canonicalizeForSigning(e),i=Yr.sha256(d.Buffer.from(n)),o=new Ex;o.hashbuf=i,o.privkey=t,o.pubkey=t.toPublicKey(),o.sign();var s=o.sig,a={type:"EcdsaSecp256k1Signature2019",created:new Date().toISOString(),verificationMethod:"did:smartledger:"+t.toPublicKey().toString()+"#keys-1",proofPurpose:r.purpose||"assertionMethod",jws:this._createJWS(i,s),proofValue:s.toDER().toString("hex")};return{success:!0,proof:a,tokenHash:i.toString("hex"),canonical:n,signingKey:{publicKey:t.toPublicKey().toString(),keyId:"did:smartledger:"+t.toPublicKey().toString()+"#keys-1"},externalOperations:{storeProof:{endpoint:"POST /proofs/signature",data:{tokenHash:i.toString("hex"),proof:a,signingKey:t.toPublicKey().toString()}},verifyProof:{endpoint:"POST /proofs/verify-signature",data:{tokenHash:i.toString("hex"),signature:s.toDER().toString("hex"),publicKey:t.toPublicKey().toString()}}}}}catch(c){return{success:!1,error:c.message}}},prepareSignatureVerification:function(e,t){try{if(or.checkArgument(e&&typeof e=="object","Invalid token"),or.checkArgument(typeof t=="string","Public key must be string"),!e.proof)return{success:!1,error:"No proof found in token"};var r=this._canonicalizeForSigning(e),n=Yr.sha256(d.Buffer.from(r)),i=Nk.fromDER(d.Buffer.from(e.proof.proofValue,"hex")),o={tokenHash:n.toString("hex"),signature:i.toDER().toString("hex"),publicKey:t,proof:e.proof,canonical:r},s=new Ex;s.hashbuf=n,s.sig=i,s.pubkey=Bk.fromString(t);var a=s.verify()===!0;return{success:!0,verification:{valid:a,tokenHash:n.toString("hex"),signatureValid:a,publicKey:t,verifiedAt:new Date().toISOString()},verificationData:o,externalOperations:{recordVerification:{endpoint:"POST /proofs/verification-record",data:{tokenHash:n.toString("hex"),result:a,publicKey:t,verifiedAt:new Date().toISOString()}},auditVerification:{endpoint:"POST /audit/proof-verification",data:{tokenId:e.id,proofType:e.proof.type,result:a,verifier:t}}}}}catch(c){return{success:!1,error:c.message}}},prepareSelectiveDisclosure:function(e,t,r){or.checkArgument(e&&typeof e=="object","Invalid token"),or.checkArgument(Array.isArray(t),"Revealed fields must be array"),or.checkArgument(typeof r=="string","Nonce must be string");try{var n=this._createFieldCommitments(e,r),i=this._createMerkleTree(n),o=[],s=[];t.forEach(function(c){var h=this._getNestedValue(e,c),g=this._findFieldCommitment(n,c);if(g){o.push({path:c,value:h,commitment:g.hash,salt:g.salt});var m=this._generateMerkleProof(i,g.index);s.push({path:c,leafIndex:g.index,proof:m})}}.bind(this));var a={type:"LegalTokenSelectiveDisclosure",created:new Date().toISOString(),proofPurpose:"selectiveDisclosure",verificationMethod:e.proof?e.proof.verificationMethod:null,nonce:r,merkleRoot:i.root,disclosures:o,merkleProofs:s,totalFields:n.length};return{success:!0,proof:a,hiddenFieldCount:n.length-o.length,revealedFieldCount:o.length,externalOperations:{storeDisclosure:{endpoint:"POST /proofs/selective-disclosure",data:{tokenId:e.id,proof:a,merkleRoot:i.root}},verifyDisclosure:{endpoint:"POST /proofs/verify-disclosure",data:{proof:a,expectedNonce:r}},auditDisclosure:{endpoint:"POST /audit/selective-disclosure",data:{tokenId:e.id,revealedFields:t,totalFields:n.length,disclosedAt:new Date().toISOString()}}}}}catch(c){return{success:!1,error:c.message}}},prepareSelectiveDisclosureVerification:function(e,t){try{if(or.checkArgument(e&&typeof e=="object","Invalid proof"),or.checkArgument(typeof t=="string","Expected nonce must be string"),e.nonce!==t)return{success:!1,error:"Nonce mismatch"};var r=[],n=[];e.disclosures.forEach(function(o,s){var a=e.merkleProofs[s],c=this._hashField(o.path,o.value,o.salt);if(c!==o.commitment){n.push("Invalid commitment for field: "+o.path);return}var h=this._verifyMerkleProof(o.commitment,a.leafIndex,a.proof,e.merkleRoot);h?r.push({path:o.path,value:o.value,verified:!0}):n.push("Invalid Merkle proof for field: "+o.path)}.bind(this));var i={valid:n.length===0,errors:n,disclosures:r,merkleRoot:e.merkleRoot,totalFields:e.totalFields,verifiedAt:new Date().toISOString()};return{success:!0,verification:i,externalOperations:{recordVerification:{endpoint:"POST /proofs/disclosure-verification",data:{proofId:e.id||"unknown",result:i.valid,verifiedFields:r.length,totalFields:e.totalFields,verifiedAt:i.verifiedAt}},auditVerification:{endpoint:"POST /audit/disclosure-verification",data:{merkleRoot:e.merkleRoot,disclosuresVerified:r.length,errors:n.length,result:i.valid}}}}}catch(o){return{success:!1,error:o.message}}},prepareLegalValidityProof:function(e,t,r){or.checkArgument(e&&typeof e=="object","Invalid token"),or.checkArgument(t&&typeof t=="object","Invalid jurisdiction"),or.checkArgument(typeof r=="string","Nonce must be string");try{var n=t.requirements||[],i=[],o=!0;n.forEach(function(a){var c=this._checkLegalRequirement(e,a);i.push(c),c.satisfied||(o=!1)}.bind(this));var s={type:"LegalValidityProof",created:new Date().toISOString(),proofPurpose:"legalValidity",jurisdiction:t.code,nonce:r,valid:o,checks:i,complianceHash:this._hashCompliance(e,t,r)};return{success:!0,proof:s,valid:o,complianceReport:{jurisdiction:t.code,totalRequirements:n.length,satisfiedRequirements:i.filter(a=>a.satisfied).length,failedRequirements:i.filter(a=>!a.satisfied).length,overallCompliance:o},externalOperations:{submitCompliance:{endpoint:"POST /compliance/legal-validity",data:{tokenId:e.id,jurisdiction:t.code,proof:s,complianceReport:{jurisdiction:t.code,totalRequirements:n.length,satisfiedRequirements:i.filter(a=>a.satisfied).length,failedRequirements:i.filter(a=>!a.satisfied).length,overallCompliance:o}}},auditCompliance:{endpoint:"POST /audit/compliance-check",data:{tokenId:e.id,jurisdiction:t.code,result:o,checkedAt:new Date().toISOString(),requirements:i}},notifyRegulator:o?null:{endpoint:"POST /notifications/compliance-failure",data:{tokenId:e.id,jurisdiction:t.code,failedRequirements:i.filter(a=>!a.satisfied)}}}}}catch(a){return{success:!1,error:a.message}}},prepareZeroKnowledgeProof:function(e,t,r){or.checkArgument(e&&typeof e=="object","Invalid token"),or.checkArgument(t&&typeof t=="object","Invalid statement"),or.checkArgument(typeof r=="string","Nonce must be string");try{var n=Yr.sha256(d.Buffer.from(this._canonicalizeForSigning(e)+r)).toString("hex"),i={type:"LegalTokenZKProof",created:new Date().toISOString(),proofPurpose:"zeroKnowledge",statement:{claim:t.claim||"UNSPECIFIED",predicate:t.predicate||"SATISFIES",threshold:t.threshold||null},commitment:n,nonce:r,proofData:this._generateZKProofData(e,t,r)};return{success:!0,proof:i,commitment:n,externalOperations:{storeZKProof:{endpoint:"POST /proofs/zero-knowledge",data:{tokenId:e.id,proof:i,statement:t}},verifyZKProof:{endpoint:"POST /proofs/verify-zk",data:{proof:i,expectedNonce:r}},auditZKProof:{endpoint:"POST /audit/zk-proof",data:{tokenId:e.id,statement:t.claim,proofGenerated:new Date().toISOString()}}}}}catch(o){return{success:!1,error:o.message}}},_generateZKProofData:function(e,t,r){var n={challenge:Yr.sha256(d.Buffer.from(t.claim+r)).toString("hex"),response:Yr.sha256(d.Buffer.from(this._canonicalizeForSigning(e)+t.claim)).toString("hex"),witness:Yr.sha256(d.Buffer.from(r+e.id+t.predicate)).toString("hex")};return n},_createJWS:function(e,t){var r={alg:"ES256K",typ:"JWT"},n=d.Buffer.from(JSON.stringify(r)).toString("base64url"),i=e.toString("base64url"),o=t.toDER().toString("base64url");return n+".."+o},_canonicalizeForSigning:function(e){var t=JSON.parse(JSON.stringify(e));delete t.proof,delete t.tokenHash;var r=this._sortObjectKeys(t);return JSON.stringify(r)},_createFieldCommitments:function(e,t){var r=[],n=0;return this._traverseObject(e,"",function(i,o){if(i!=="proof"&&i!=="tokenHash"){var s=Yr.sha256(d.Buffer.from(t+i+n)).toString("hex"),a=this._hashField(i,o,s);r.push({path:i,value:o,salt:s,hash:a,index:n}),n++}}.bind(this)),r},_hashField:function(e,t,r){var n=e+":"+JSON.stringify(t)+":"+r;return Yr.sha256(d.Buffer.from(n)).toString("hex")},_createMerkleTree:function(e){var t=e.map(function(g){return g.hash});if(t.length===0)return{root:null,levels:[]};for(var r=[t],n=t;n.length>1;){for(var i=[],o=0;o<n.length;o+=2){var s=n[o],a=n[o+1]||s,c=d.Buffer.concat([d.Buffer.from(s,"hex"),d.Buffer.from(a,"hex")]),h=Yr.sha256(c).toString("hex");i.push(h)}r.push(i),n=i}return{root:n[0],levels:r}},_generateMerkleProof:function(e,t){for(var r=[],n=t,i=0;i<e.levels.length-1;i++){var o=e.levels[i],s=n%2===0,a=s?n+1:n-1;a<o.length&&r.push({hash:o[a],isLeft:!s}),n=Math.floor(n/2)}return r},_verifyMerkleProof:function(e,t,r,n){for(var i=e,o=t,s=0;s<r.length;s++){var a=r[s],c=o%2===0,h;a.isLeft?h=d.Buffer.concat([d.Buffer.from(a.hash,"hex"),d.Buffer.from(i,"hex")]):h=d.Buffer.concat([d.Buffer.from(i,"hex"),d.Buffer.from(a.hash,"hex")]),i=Yr.sha256(h).toString("hex"),o=Math.floor(o/2)}return i===n},_traverseObject:function(e,t,r){Array.isArray(e)?e.forEach(function(n,i){var o=t+"["+i+"]";this._traverseObject(n,o,r)}.bind(this)):e!==null&&typeof e=="object"?Object.keys(e).forEach(function(n){var i=t?t+"."+n:n;this._traverseObject(e[n],i,r)}.bind(this)):r(t,e)},_getNestedValue:function(e,t){return t.split(".").reduce(function(r,n){return r&&r[n]},e)},_findFieldCommitment:function(e,t){return e.find(function(r){return r.path===t})},_checkLegalRequirement:function(e,t){switch(t.type){case"field_present":var r=this._getNestedValue(e,t.field);return{requirement:t.type,field:t.field,satisfied:r!=null};case"field_value":var r=this._getNestedValue(e,t.field);return{requirement:t.type,field:t.field,satisfied:r===t.expectedValue};case"temporal_validity":var n=new Date,i=new Date(e.issuanceDate);return{requirement:t.type,satisfied:i<=n};default:return{requirement:t.type,satisfied:!1,error:"Unknown requirement type"}}},_hashCompliance:function(e,t,r){var n={tokenId:e.id,jurisdiction:t.code,nonce:r,timestamp:new Date().toISOString()};return Yr.sha256(d.Buffer.from(JSON.stringify(n))).toString("hex")},_sortObjectKeys:function(e){if(Array.isArray(e))return e.map(this._sortObjectKeys.bind(this));if(e!==null&&typeof e=="object"){var t={};return Object.keys(e).sort().forEach(function(r){t[r]=this._sortObjectKeys(e[r])}.bind(this)),t}return e}};xx.exports=kk});var Rx=P((k5,Ox)=>{"use strict";y();var za=Qt(),N5=ro(),M5=Rp(),cr=ke(),Ax=Ka(),Ck={prepareRegistry:function(e){e=e||{},cr.checkArgument(typeof e=="object","Config must be object");var t={id:e.id||this._generateRegistryId(),name:e.name||"Legal Token Registry",jurisdiction:e.jurisdiction||"GLOBAL",authority:e.authority||null,created:new Date().toISOString(),version:"1.0.0",config:{allowPublicRegistration:e.allowPublicRegistration||!1,requireApproval:e.requireApproval||!0,enableRevocation:e.enableRevocation!==!1,enableAuditTrail:e.enableAuditTrail!==!1,retentionPeriod:e.retentionPeriod||"7Y",complianceLevel:e.complianceLevel||"STANDARD"},dataStructure:{tokens:"Map<tokenId, registrationRecord>",revocations:"Map<tokenId, revocationRecord>",auditLog:"Array<auditEntry>",statistics:{totalTokens:0,activeTokens:0,revokedTokens:0,registrations:0}},externalStorage:{required:!0,type:"database_or_blockchain",endpoints:{store:"POST /registry/{id}/tokens",retrieve:"GET /registry/{id}/tokens/{tokenId}",search:"GET /registry/{id}/search",revoke:"POST /registry/{id}/revocations"}}},r=this._prepareAuditEntry({action:"REGISTRY_CREATED",actor:e.authority,timestamp:t.created,metadata:{jurisdiction:t.jurisdiction,config:t.config}});return{success:!0,registry:t,initialAudit:r,instructions:{step1:"Store registry configuration in external system",step2:"Initialize token storage with provided data structure",step3:"Set up audit logging with provided templates",step4:"Configure external endpoints for registry operations"}}},prepareTokenRegistration:function(e,t,r){r=r||{},cr.checkArgument(e&&typeof e=="object","Invalid token"),cr.checkArgument(t&&typeof t=="object","Invalid registry config");try{var n=this._validateTokenForRegistration(e,t);if(!n.valid)return{success:!1,error:"Token validation failed: "+n.error};var i={tokenId:e.id,tokenHash:this._hashToken(e),token:e,status:t.requireApproval?"PENDING":"ACTIVE",registeredBy:r.registeredBy||"UNKNOWN",registeredAt:new Date().toISOString(),approvedBy:null,approvedAt:null,metadata:r.metadata||{},compliance:{jurisdiction:e.jurisdiction||t.jurisdiction,level:this._calculateComplianceLevel(e),checks:n.checks||[]}},o=this._prepareAuditEntry({action:"TOKEN_REGISTERED",actor:r.registeredBy,tokenId:e.id,timestamp:i.registeredAt,metadata:{status:i.status,tokenType:e.type,compliance:i.compliance}});return{success:!0,registrationRecord:i,auditEntry:o,registrationId:this._generateRegistrationId(e.id),validation:n,externalOperations:{store:{endpoint:"POST /registry/"+t.id+"/tokens",data:i},audit:{endpoint:"POST /registry/"+t.id+"/audit",data:o}}}}catch(s){return{success:!1,error:s.message}}},prepareTokenApproval:function(e,t,r){try{cr.checkArgument(typeof e=="string","Token ID must be string"),cr.checkArgument(typeof t=="string","Approver must be string"),cr.checkArgument(r&&typeof r=="object","Invalid registry config");var n={tokenId:e,status:"ACTIVE",approvedBy:t,approvedAt:new Date().toISOString()},i=this._prepareAuditEntry({action:"TOKEN_APPROVED",actor:t,tokenId:e,timestamp:n.approvedAt});return{success:!0,approvalData:n,auditEntry:i,externalOperations:{update:{endpoint:"PUT /registry/"+r.id+"/tokens/"+e+"/status",data:n},audit:{endpoint:"POST /registry/"+r.id+"/audit",data:i}}}}catch(o){return{success:!1,error:o.message}}},prepareTokenRevocation:function(e,t,r){try{if(cr.checkArgument(typeof e=="string","Token ID must be string"),cr.checkArgument(t&&typeof t=="object","Invalid revocation"),cr.checkArgument(r&&typeof r=="object","Invalid registry config"),!r.enableRevocation)return{success:!1,error:"Revocation is disabled for this registry"};var n={tokenId:e,reason:t.reason||"UNSPECIFIED",revokedBy:t.revokedBy||"UNKNOWN",revokedAt:new Date().toISOString(),effectiveDate:t.effectiveDate||new Date().toISOString(),legalBasis:t.legalBasis||null,evidence:t.evidence||null,revocationHash:this._generateRevocationHash(e,t)},i={tokenId:e,status:"REVOKED",revokedAt:n.revokedAt,revocationReason:n.reason},o=this._prepareAuditEntry({action:"TOKEN_REVOKED",actor:t.revokedBy,tokenId:e,timestamp:n.revokedAt,metadata:{reason:n.reason,legalBasis:n.legalBasis}});return{success:!0,revocationRecord:n,statusUpdate:i,auditEntry:o,revocationId:this._generateRevocationId(e),externalOperations:{storeRevocation:{endpoint:"POST /registry/"+r.id+"/revocations",data:n},updateStatus:{endpoint:"PUT /registry/"+r.id+"/tokens/"+e+"/status",data:i},audit:{endpoint:"POST /registry/"+r.id+"/audit",data:o}}}}catch(s){return{success:!1,error:s.message}}},prepareTokenStatusQuery:function(e,t){try{return cr.checkArgument(typeof e=="string","Token ID must be string"),cr.checkArgument(t&&typeof t=="object","Invalid registry config"),{success:!0,query:{tokenId:e,registryId:t.id},externalOperations:{retrieve:{endpoint:"GET /registry/"+t.id+"/tokens/"+e,method:"GET"},checkRevocation:{endpoint:"GET /registry/"+t.id+"/revocations/"+e,method:"GET"}},expectedResponse:{found:"boolean",status:"string (PENDING|ACTIVE|REVOKED)",registeredAt:"ISO datetime",registeredBy:"string",approvedAt:"ISO datetime or null",approvedBy:"string or null",revokedAt:"ISO datetime or null",revocationReason:"string or null",compliance:"object",revocation:"object or null"}}}catch(r){return{success:!1,error:r.message}}},prepareTokenSearch:function(e,t){e=e||{};try{cr.checkArgument(t&&typeof t=="object","Invalid registry config");var r=[];e.status&&r.push("status="+encodeURIComponent(e.status)),e.type&&r.push("type="+encodeURIComponent(e.type)),e.registeredBy&&r.push("registeredBy="+encodeURIComponent(e.registeredBy)),e.jurisdiction&&r.push("jurisdiction="+encodeURIComponent(e.jurisdiction)),e.dateFrom&&r.push("dateFrom="+encodeURIComponent(e.dateFrom)),e.dateTo&&r.push("dateTo="+encodeURIComponent(e.dateTo)),e.includeTokens&&r.push("includeTokens=true"),e.sortBy&&r.push("sortBy="+encodeURIComponent(e.sortBy)),e.sortOrder&&r.push("sortOrder="+encodeURIComponent(e.sortOrder));var n=e.offset||0,i=e.limit||100;r.push("offset="+n),r.push("limit="+i);var o=r.length>0?"?"+r.join("&"):"";return{success:!0,searchCriteria:e,externalOperations:{search:{endpoint:"GET /registry/"+t.id+"/search"+o,method:"GET"}},expectedResponse:{success:"boolean",results:"Array<tokenRecord>",totalCount:"number",totalRegistrations:"number",offset:"number",limit:"number",hasMore:"boolean"}}}catch(s){return{success:!1,error:s.message}}},prepareStatisticsQuery:function(e){return cr.checkArgument(e&&typeof e=="object","Invalid registry config"),{success:!0,query:{registryId:e.id},externalOperations:{getStatistics:{endpoint:"GET /registry/"+e.id+"/statistics",method:"GET"}},expectedResponse:{id:"string",name:"string",jurisdiction:"string",created:"ISO datetime",statistics:{totalTokens:"number",activeTokens:"number",revokedTokens:"number",registrations:"number"},auditEntries:"number",lastActivity:"ISO datetime"}}},prepareAuditLogQuery:function(e,t){if(t=t||{},cr.checkArgument(e&&typeof e=="object","Invalid registry config"),!e.enableAuditTrail)return{success:!1,error:"Audit trail is disabled"};var r=[];t.action&&r.push("action="+encodeURIComponent(t.action)),t.actor&&r.push("actor="+encodeURIComponent(t.actor)),t.tokenId&&r.push("tokenId="+encodeURIComponent(t.tokenId)),t.dateFrom&&r.push("dateFrom="+encodeURIComponent(t.dateFrom)),t.dateTo&&r.push("dateTo="+encodeURIComponent(t.dateTo));var n=t.offset||0,i=t.limit||100;r.push("offset="+n),r.push("limit="+i);var o=r.length>0?"?"+r.join("&"):"";return{success:!0,auditOptions:t,externalOperations:{getAuditLog:{endpoint:"GET /registry/"+e.id+"/audit"+o,method:"GET"}},expectedResponse:{success:"boolean",entries:"Array<auditEntry>",totalEntries:"number",offset:"number",limit:"number",hasMore:"boolean"}}},_generateRegistryId:function(){return"reg_"+Ax.randomHex(16)},_generateRegistrationId:function(e){var t="reg_"+e+"_"+Date.now();return za.sha256(d.Buffer.from(t)).toString("hex").substring(0,16)},_generateRevocationId:function(e){var t="rev_"+e+"_"+Date.now();return za.sha256(d.Buffer.from(t)).toString("hex").substring(0,16)},_hashToken:function(e){var t=JSON.parse(JSON.stringify(e));return delete t.proof,delete t.tokenHash,za.sha256(d.Buffer.from(JSON.stringify(t))).toString("hex")},_generateRevocationHash:function(e,t){var r=e+(t.reason||"")+(t.revokedBy||"")+Date.now();return za.sha256(d.Buffer.from(r)).toString("hex")},_validateTokenForRegistration:function(e,t){var r=[],n=!0;return e.id?r.push({field:"id",valid:!0}):(r.push({field:"id",valid:!1,error:"Missing token ID"}),n=!1),e.type?r.push({field:"type",valid:!0}):(r.push({field:"type",valid:!1,error:"Missing token type"}),n=!1),e.issuanceDate?r.push({field:"issuanceDate",valid:!0}):(r.push({field:"issuanceDate",valid:!1,error:"Missing issuance date"}),n=!1),e.proof?r.push({field:"proof",valid:!0}):(r.push({field:"proof",valid:!1,error:"Missing cryptographic proof"}),n=!1),{valid:n,checks:r}},_calculateComplianceLevel:function(e){var t="BASIC";return e.proof&&e.proof.type&&(t="STANDARD"),e.jurisdiction&&e.legalBasis&&(t="ENHANCED"),e.attestations&&e.attestations.length>0&&(t="PREMIUM"),t},_prepareAuditEntry:function(e){var t={id:this._generateAuditId(),action:e.action,actor:e.actor||"SYSTEM",tokenId:e.tokenId||null,timestamp:e.timestamp||new Date().toISOString(),metadata:e.metadata||{},hash:this._generateAuditHash(e)};return t},_generateAuditId:function(){return"audit_"+Ax.randomHex(32)},_generateAuditHash:function(e){var t=(e.action||"")+(e.actor||"")+(e.tokenId||"")+(e.timestamp||"");return za.sha256(d.Buffer.from(t)).toString("hex").substring(0,16)}};Ox.exports=Ck});var Nx=P((L5,Bx)=>{"use strict";y();var Fp=Tr(),qp=Qt(),Tx=ka(),Lk=ir(),Px=no(),mr=ke(),Dk=Ka();function Uk(e,t){if(t=t||{},t.issuerPublicKey)return t.issuerPublicKey instanceof Fp?t.issuerPublicKey:Fp.fromString(t.issuerPublicKey);var r=e&&e.issuer;if(typeof r!="string")return null;try{var n=r.split("#")[0].split(":")[2];return n?Fp.fromString(n):null}catch{return null}}var Fc={CORRELATIVE_OBLIGATION:"CorrelativeObligation",CONTRACTUAL_OBLIGATION:"ContractualObligation",PAYMENT_OBLIGATION:"PaymentObligation",DELIVERY_OBLIGATION:"DeliveryObligation",PERFORMANCE_OBLIGATION:"PerformanceObligation",MAINTENANCE_OBLIGATION:"MaintenanceObligation",COMPLIANCE_OBLIGATION:"ComplianceObligation",REPORTING_OBLIGATION:"ReportingObligation",CONFIDENTIALITY_OBLIGATION:"ConfidentialityObligation",NON_COMPETE_OBLIGATION:"NonCompeteObligation",INDEMNIFICATION_OBLIGATION:"IndemnificationObligation",WARRANTY_OBLIGATION:"WarrantyObligation",SUPPORT_OBLIGATION:"SupportObligation",REGULATORY_OBLIGATION:"RegulatoryObligation",FIDUCIARY_OBLIGATION:"FiduciaryObligation"},ps={CRITICAL:"CRITICAL",HIGH:"HIGH",MEDIUM:"MEDIUM",LOW:"LOW",DEFERRED:"DEFERRED"},lr={PENDING:"PENDING",ACTIVE:"ACTIVE",IN_PROGRESS:"IN_PROGRESS",COMPLETED:"COMPLETED",OVERDUE:"OVERDUE",BREACHED:"BREACHED",WAIVED:"WAIVED",TERMINATED:"TERMINATED"},qc={prepareObligationToken:function(e,t,r,n,i,o){o=o||{},mr.checkArgument(typeof e=="string","Obligation type must be string"),mr.checkArgument(typeof t=="string","Issuer DID must be string"),mr.checkArgument(typeof r=="string","Obligor DID must be string"),mr.checkArgument(n&&typeof n=="object","Obligation must be object"),mr.checkArgument(i instanceof Px,"Invalid issuer private key");var s=Object.values(Fc);mr.checkArgument(s.includes(e),"Invalid obligation type: "+e);try{var a={"@context":["https://www.w3.org/2018/credentials/v1","https://smartledger.technology/contexts/ltp/v1"],id:"urn:uuid:"+this._generateUUID(),type:["VerifiableCredential","LegalObligationToken",e],issuer:t,issuanceDate:new Date().toISOString(),credentialSubject:{id:r,obligationType:e,obligation:n,jurisdiction:o.jurisdiction||"US",priority:o.priority||ps.MEDIUM,status:lr.PENDING,dueDate:o.dueDate||null,effectiveDate:o.effectiveDate||new Date().toISOString(),expirationDate:o.expirationDate||null,correlativeRight:o.correlativeRight||null,rightHolder:o.rightHolder||null,enforceable:o.enforceable!==!1,penalties:o.penalties||null,remedies:o.remedies||null}};o.metadata&&(a.credentialSubject.metadata=o.metadata);var c=this._signToken(a,i);return{success:!0,obligationToken:c,tokenHash:c.tokenHash,metadata:{type:e,issuer:t,obligor:r,priority:a.credentialSubject.priority,status:a.credentialSubject.status,jurisdiction:a.credentialSubject.jurisdiction,dueDate:a.credentialSubject.dueDate,correlativeRight:a.credentialSubject.correlativeRight},externalOperations:{storeToken:{endpoint:"POST /obligations/tokens",data:{token:c,metadata:{type:e,issuer:t,obligor:r,priority:a.credentialSubject.priority,status:a.credentialSubject.status,jurisdiction:a.credentialSubject.jurisdiction,dueDate:a.credentialSubject.dueDate,correlativeRight:a.credentialSubject.correlativeRight}}},indexToken:{endpoint:"POST /obligations/index",data:{tokenId:c.id,tokenHash:c.tokenHash,type:e,issuer:t,obligor:r,issuedAt:c.issuanceDate,dueDate:a.credentialSubject.dueDate,priority:a.credentialSubject.priority}},notifyObligor:{endpoint:"POST /notifications/obligation-issued",data:{tokenId:c.id,issuer:t,obligor:r,obligationType:e,dueDate:a.credentialSubject.dueDate,priority:a.credentialSubject.priority}},scheduleReminders:a.credentialSubject.dueDate?{endpoint:"POST /obligations/schedule-reminders",data:{tokenId:c.id,obligor:r,dueDate:a.credentialSubject.dueDate,reminderSchedule:o.reminderSchedule||["7d","3d","1d"]}}:null}}}catch(h){return{success:!1,error:h.message}}},prepareObligationVerification:function(e,t){t=t||{};try{var r=[],n=[];this._validateTokenStructure(e,r),this._verifyTokenSignature(e,r,t),this._validateTokenTemporal(e,r,n),this._validateObligationType(e,r),this._validateObligationStatus(e,r,n),this._validateObligationPriority(e,n);var i={valid:r.length===0,errors:r,warnings:n,issuerDID:e.issuer,obligorDID:e.credentialSubject?e.credentialSubject.id:null,obligationType:e.credentialSubject?e.credentialSubject.obligationType:null,status:e.credentialSubject?e.credentialSubject.status:null,priority:e.credentialSubject?e.credentialSubject.priority:null,isOverdue:this._checkIfOverdue(e),verifiedAt:new Date().toISOString()};return{success:!0,verification:i,externalOperations:{recordVerification:{endpoint:"POST /obligations/verification-record",data:{tokenId:e.id,result:i.valid,errors:r,warnings:n,verifiedAt:i.verifiedAt,isOverdue:i.isOverdue}},auditVerification:{endpoint:"POST /audit/obligation-verification",data:{tokenId:e.id,obligationType:i.obligationType,issuer:i.issuerDID,obligor:i.obligorDID,result:i.valid,verifiedAt:i.verifiedAt}},updateStatus:i.isOverdue&&e.credentialSubject.status===lr.ACTIVE?{endpoint:"PUT /obligations/tokens/"+e.id+"/status",data:{status:lr.OVERDUE,updatedAt:i.verifiedAt,reason:"Due date passed"}}:null}}}catch(o){return{success:!1,error:"Verification preparation failed: "+o.message}}},prepareObligationFulfillment:function(e,t,r,n){n=n||{},mr.checkArgument(e&&typeof e=="object","Invalid token"),mr.checkArgument(t&&typeof t=="object","Invalid fulfillment"),mr.checkArgument(r instanceof Px,"Invalid obligor key");try{var i=this.prepareObligationVerification(e,{});if(!i.success||!i.verification.valid)return{success:!1,error:"Cannot fulfill invalid obligation: "+i.verification.errors.join(", ")};if(e.credentialSubject.status===lr.COMPLETED)return{success:!1,error:"Obligation already fulfilled"};if(e.credentialSubject.status===lr.TERMINATED)return{success:!1,error:"Obligation has been terminated"};var o={"@context":["https://www.w3.org/2018/credentials/v1","https://smartledger.technology/contexts/ltp/v1"],id:"urn:uuid:"+this._generateUUID(),type:["VerifiableCredential","ObligationFulfillment"],issuer:e.credentialSubject.id,issuanceDate:new Date().toISOString(),credentialSubject:{id:e.id,fulfillmentType:t.type||"FULL_FULFILLMENT",fulfillmentDate:new Date().toISOString(),evidence:t.evidence||null,description:t.description||"",completionPercentage:t.completionPercentage||100,attestations:t.attestations||[],notes:t.notes||null}},s=this._signToken(o,r),a=o.credentialSubject.completionPercentage>=100?lr.COMPLETED:lr.IN_PROGRESS;return{success:!0,fulfillmentRecord:s,newStatus:a,fulfillmentId:s.id,externalOperations:{recordFulfillment:{endpoint:"POST /obligations/fulfillments",data:{obligationId:e.id,fulfillmentRecord:s,obligor:e.credentialSubject.id,fulfillmentDate:o.credentialSubject.fulfillmentDate,completionPercentage:o.credentialSubject.completionPercentage}},updateStatus:{endpoint:"PUT /obligations/tokens/"+e.id+"/status",data:{status:a,fulfillmentId:s.id,updatedAt:o.credentialSubject.fulfillmentDate,completionPercentage:o.credentialSubject.completionPercentage}},notifyRightHolder:e.credentialSubject.rightHolder?{endpoint:"POST /notifications/obligation-fulfilled",data:{obligationId:e.id,fulfillmentId:s.id,obligor:e.credentialSubject.id,rightHolder:e.credentialSubject.rightHolder,completionPercentage:o.credentialSubject.completionPercentage,newStatus:a}}:null,auditFulfillment:{endpoint:"POST /audit/obligation-fulfillment",data:{obligationId:e.id,fulfillmentId:s.id,obligor:e.credentialSubject.id,fulfilledAt:o.credentialSubject.fulfillmentDate,completionPercentage:o.credentialSubject.completionPercentage}}}}}catch(c){return{success:!1,error:c.message}}},prepareObligationBreachAssessment:function(e,t,r){mr.checkArgument(e&&typeof e=="object","Invalid token"),mr.checkArgument(t&&typeof t=="object","Invalid breach details"),mr.checkArgument(r&&typeof r=="object","Invalid assessor");try{var n={"@context":["https://www.w3.org/2018/credentials/v1","https://smartledger.technology/contexts/ltp/v1"],id:"urn:uuid:"+this._generateUUID(),type:["VerifiableCredential","ObligationBreachAssessment"],issuer:r.did||r.id,issuanceDate:new Date().toISOString(),credentialSubject:{id:e.id,breachType:t.type||"MATERIAL_BREACH",breachDate:t.date||new Date().toISOString(),description:t.description||"",severity:t.severity||"MODERATE",evidence:t.evidence||[],assessor:{did:r.did||r.id,name:r.name||"Unknown",authority:r.authority||null,jurisdiction:r.jurisdiction||null},damages:t.damages||null,recommendedRemedies:t.recommendedRemedies||[],assessmentDate:new Date().toISOString()}},i=qp.sha256(d.Buffer.from(JSON.stringify(n))).toString("hex");return n.credentialSubject.assessmentHash=i,{success:!0,breachAssessment:n,breachId:n.id,severity:t.severity||"MODERATE",externalOperations:{recordBreach:{endpoint:"POST /obligations/breaches",data:{obligationId:e.id,breachAssessment:n,obligor:e.credentialSubject.id,rightHolder:e.credentialSubject.rightHolder,breachDate:t.date||new Date().toISOString(),severity:t.severity||"MODERATE"}},updateStatus:{endpoint:"PUT /obligations/tokens/"+e.id+"/status",data:{status:lr.BREACHED,breachId:n.id,breachDate:t.date||new Date().toISOString(),updatedAt:new Date().toISOString()}},notifyParties:{endpoint:"POST /notifications/obligation-breached",data:{obligationId:e.id,breachId:n.id,obligor:e.credentialSubject.id,rightHolder:e.credentialSubject.rightHolder,breachType:t.type||"MATERIAL_BREACH",severity:t.severity||"MODERATE"}},escalateBreach:t.severity==="CRITICAL"?{endpoint:"POST /legal/escalate-breach",data:{obligationId:e.id,breachId:n.id,severity:t.severity,jurisdiction:e.credentialSubject.jurisdiction}}:null,auditBreach:{endpoint:"POST /audit/obligation-breach",data:{obligationId:e.id,breachId:n.id,obligor:e.credentialSubject.id,assessedAt:n.credentialSubject.assessmentDate,severity:t.severity||"MODERATE"}}}}}catch(o){return{success:!1,error:o.message}}},prepareObligationMonitoringReport:function(e,t){t=t||{},mr.checkArgument(Array.isArray(e),"Obligations must be array");try{var r={reportId:"rpt_"+this._generateUUID(),generatedAt:new Date().toISOString(),criteria:t,summary:{totalObligations:e.length,byStatus:{},byPriority:{},byType:{},overdue:0,dueSoon:0,completed:0},obligations:[],alerts:[],recommendations:[]},n=new Date,i=new Date(n.getTime()+10080*60*1e3);return e.forEach(function(o){var s={id:o.id,type:o.credentialSubject.obligationType,status:o.credentialSubject.status,priority:o.credentialSubject.priority,obligor:o.credentialSubject.id,dueDate:o.credentialSubject.dueDate,isOverdue:this._checkIfOverdue(o),isDueSoon:!1};if(o.credentialSubject.dueDate){var a=new Date(o.credentialSubject.dueDate);s.isDueSoon=a<=i&&a>n}r.summary.byStatus[s.status]=(r.summary.byStatus[s.status]||0)+1,r.summary.byPriority[s.priority]=(r.summary.byPriority[s.priority]||0)+1,r.summary.byType[s.type]=(r.summary.byType[s.type]||0)+1,s.isOverdue&&r.summary.overdue++,s.isDueSoon&&r.summary.dueSoon++,s.status===lr.COMPLETED&&r.summary.completed++,s.isOverdue&&s.priority===ps.CRITICAL&&r.alerts.push({type:"CRITICAL_OVERDUE",obligationId:o.id,message:"Critical obligation is overdue",priority:"HIGH"}),s.isDueSoon&&s.priority===ps.HIGH&&r.alerts.push({type:"HIGH_PRIORITY_DUE_SOON",obligationId:o.id,message:"High priority obligation due soon",priority:"MEDIUM"}),r.obligations.push(s)}.bind(this)),r.summary.overdue>0&&r.recommendations.push({type:"OVERDUE_MANAGEMENT",message:"Consider prioritizing overdue obligations",count:r.summary.overdue}),r.summary.dueSoon>5&&r.recommendations.push({type:"WORKLOAD_MANAGEMENT",message:"High number of obligations due soon - consider workload distribution",count:r.summary.dueSoon}),{success:!0,report:r,externalOperations:{storeReport:{endpoint:"POST /obligations/monitoring-reports",data:{report:r,generatedAt:r.generatedAt}},sendAlerts:r.alerts.length>0?{endpoint:"POST /notifications/obligation-alerts",data:{reportId:r.reportId,alerts:r.alerts,summary:r.summary}}:null,updateDashboard:{endpoint:"PUT /dashboard/obligation-metrics",data:{summary:r.summary,lastUpdated:r.generatedAt}}}}}catch(o){return{success:!1,error:o.message}}},getObligationTypes:function(){return Fc},getObligationPriority:function(){return ps},getObligationStatus:function(){return lr},_signToken:function(e,t){var r=this._canonicalizeToken(e),n=qp.sha256(d.Buffer.from(r)),i=new Tx;i.hashbuf=n,i.privkey=t,i.pubkey=t.toPublicKey(),i.sign();var o=i.sig,s={type:"EcdsaSecp256k1Signature2019",created:new Date().toISOString(),verificationMethod:"did:smartledger:"+t.toPublicKey().toString()+"#keys-1",proofPurpose:"assertionMethod",jws:this._createJWS(n,o)},a=JSON.parse(JSON.stringify(e));return a.proof=s,a.tokenHash=n.toString("hex"),a},_createJWS:function(e,t){var r={alg:"ES256K",typ:"JWT"},n=d.Buffer.from(JSON.stringify(r)).toString("base64url"),i=e.toString("base64url"),o=t.toDER().toString("base64url");return n+".."+o},_canonicalizeToken:function(e){var t=JSON.parse(JSON.stringify(e));return delete t.proof,delete t.tokenHash,JSON.stringify(this._sortObjectKeys(t))},_sortObjectKeys:function(e){if(Array.isArray(e))return e.map(this._sortObjectKeys.bind(this));if(e!==null&&typeof e=="object"){var t={};return Object.keys(e).sort().forEach(function(r){t[r]=this._sortObjectKeys(e[r])}.bind(this)),t}return e},_validateTokenStructure:function(e,t){e["@context"]||t.push("Missing @context"),e.id||t.push("Missing id"),(!e.type||!Array.isArray(e.type))&&t.push("Missing or invalid type"),e.issuer||t.push("Missing issuer"),e.issuanceDate||t.push("Missing issuanceDate"),e.credentialSubject||t.push("Missing credentialSubject"),e.proof||t.push("Missing proof")},_verifyTokenSignature:function(e,t,r){try{if(!e.proof||!e.proof.jws){t.push("Missing signature proof");return}var n=this._canonicalizeToken(e),i=qp.sha256(d.Buffer.from(n));if(e.tokenHash&&e.tokenHash!==i.toString("hex")){t.push("Token hash mismatch");return}var o=Uk(e,r);if(!o){t.push("Signature not verified: issuer public key could not be resolved from token.issuer; pass options.issuerPublicKey");return}var s=e.proof.jws.split(".");if(s.length!==3||!s[2]){t.push("Malformed JWS");return}var a=Lk.fromDER(d.Buffer.from(s[2],"base64url")),c=new Tx;c.hashbuf=i,c.sig=a,c.pubkey=o,c.verify()!==!0&&t.push("Signature verification failed")}catch(h){t.push("Signature verification failed: "+h.message)}},_validateTokenTemporal:function(e,t,r){var n=new Date,i=new Date(e.issuanceDate);if(i>n&&t.push("Token issued in the future"),e.credentialSubject.effectiveDate){var o=new Date(e.credentialSubject.effectiveDate);n<o&&r.push("Obligation not yet effective")}if(e.credentialSubject.expirationDate){var s=new Date(e.credentialSubject.expirationDate);n>s&&t.push("Obligation expired")}},_validateObligationType:function(e,t){if(!e.credentialSubject.obligationType){t.push("Missing obligationType");return}var r=Object.values(Fc);r.includes(e.credentialSubject.obligationType)||t.push("Invalid obligation type: "+e.credentialSubject.obligationType)},_validateObligationStatus:function(e,t,r){if(!e.credentialSubject.status){t.push("Missing status");return}var n=Object.values(lr);n.includes(e.credentialSubject.status)||t.push("Invalid obligation status: "+e.credentialSubject.status),this._checkIfOverdue(e)&&e.credentialSubject.status===lr.ACTIVE&&r.push("Obligation is overdue but status is still ACTIVE")},_validateObligationPriority:function(e,t){if(e.credentialSubject.priority){var r=Object.values(ps);r.includes(e.credentialSubject.priority)||t.push("Invalid obligation priority: "+e.credentialSubject.priority)}},_checkIfOverdue:function(e){if(!e.credentialSubject.dueDate)return!1;var t=new Date,r=new Date(e.credentialSubject.dueDate);return t>r&&e.credentialSubject.status!==lr.COMPLETED},_generateUUID:function(){return Dk.uuid4()}};qc.ObligationTypes=Fc;qc.ObligationPriority=ps;qc.ObligationStatus=lr;Bx.exports=qc});var kx=P((U5,Mx)=>{"use strict";y();var uo=vx(),Hc=_x(),Ya=Sx(),Hp=Ix(),dn=Rx(),Fk=Nx(),jp=no(),vr=ke(),Re=function(e){return this instanceof Re?(this.config=e||{},this.registry=null,this.config.registry&&(this.registry=dn.createRegistry(this.config.registry)),this):new Re(e)};Re.prototype.createRightToken=function(e,t,r){vr.checkArgument(e&&typeof e=="object","Invalid right data"),vr.checkArgument(t instanceof jp,"Invalid private key"),r=r||{};try{var n=uo.create(e.type,e.owner,e.owner,e,t,r);if(!n)return{success:!1,error:"Failed to create token"};if(r.addProof!==!1&&(n=uo._signToken(n,t)),r.anchor){var i=Ya.anchorToken(n,r.anchor);i.success&&(n.anchorTx=i.txid,n.anchorBlock=i.blockHeight)}if(this.registry&&r.register!==!1){var o=dn.registerToken(this.registry,n,{registeredBy:r.registeredBy||"SYSTEM"});o.success&&(n.registrationId=o.registrationId,n.registrationStatus=o.status)}return{success:!0,token:n,type:"LegalRightToken"}}catch(s){return{success:!1,error:s.message}}};Re.prototype.validateClaim=function(e,t){return Hc.validate(e,t)};Re.prototype.createSelectiveDisclosure=function(e,t,r){return Hp.prepareSelectiveDisclosure(e,t,r)};Re.prototype.verifyToken=function(e,t){return!e||!e.proof?{valid:!1,error:"No proof found in token"}:uo.verifyToken(e,t)};Re.prototype.transferRight=function(e,t,r,n){vr.checkArgument(e&&typeof e=="object","Invalid token"),vr.checkArgument(typeof t=="string","New owner must be string"),vr.checkArgument(r instanceof jp,"Invalid owner key"),n=n||{};try{var i=this.verifyToken(e,r.toPublicKey().toString());if(!i.valid)return{success:!1,error:"Invalid token or ownership proof"};var o=uo.prepareRightTokenTransfer(e,t,r,n);if(!o.success)return{success:!1,error:o.error};var s=o.newToken,a=o.transferProof;if(n.anchor){var c=Ya.anchorToken(s,n.anchor);c.success&&(s.transferAnchorTx=c.txid)}if(this.registry){var h=dn.registerToken(this.registry,s,{registeredBy:n.registeredBy||t,metadata:{transferFrom:e.owner,transferTo:t,originalTokenId:e.id}});h.success&&(s.registrationId=h.registrationId)}return{success:!0,token:s,transferId:a.id,transferredAt:a.issuanceDate,transferProof:a}}catch(g){return{success:!1,error:g.message}}};Re.prototype.createObligation=function(e,t,r){vr.checkArgument(e&&typeof e=="object","Invalid right token"),vr.checkArgument(t&&typeof t=="object","Invalid obligation data"),vr.checkArgument(r instanceof jp,"Invalid private key");try{var n=uo.prepareObligationToken(e,t.obligor,t,r);return n.success?{success:!0,obligation:n.obligationToken,rightTokenId:e.id}:{success:!1,error:n.error}}catch(i){return{success:!1,error:i.message}}};Re.prototype.revokeToken=function(e,t,r){return vr.checkArgument(typeof e=="string","Token ID must be string"),vr.checkArgument(t&&typeof t=="object","Invalid revocation data"),vr.checkArgument(typeof r=="string","Authority must be string"),this.registry?dn.revokeToken(this.registry,e,{reason:t.reason,revokedBy:r,legalBasis:t.legalBasis,evidence:t.evidence}):{success:!1,error:"No registry available for revocation"}};Re.prototype.checkTokenStatus=function(e){return vr.checkArgument(typeof e=="string","Token ID must be string"),this.registry?dn.checkTokenStatus(this.registry,e):{found:!1,error:"No registry available"}};Re.prototype.searchTokens=function(e){return this.registry?dn.searchTokens(this.registry,e):{success:!1,error:"No registry available"}};Re.prototype.getRegistryStats=function(){return this.registry?dn.getStatistics(this.registry):{error:"No registry available"}};Re.prototype.createLegalValidityProof=function(e,t,r){return Hp.prepareLegalValidityProof(e,t,r)};Re.prototype.anchorTokenBatch=function(e,t){return Ya.anchorBatch(e,t)};Re.prototype.verifyAnchor=function(e,t){return Ya.verifyAnchor(e,t)};Re.prototype.getRightTypes=function(){return uo.getRightTypes()};Re.prototype.getClaimSchemas=function(){return Hc.getSchemas()};Re.prototype.createRegistry=function(e){return this.registry=dn.createRegistry(e),this.registry};Re.prototype.setRegistry=function(e){vr.checkArgument(e&&typeof e=="object","Invalid registry"),this.registry=e};Re.create=function(e){return new Re(e)};Re.createRightToken=function(e,t,r){var n=new Re;return n.createRightToken(e,t,r)};Re.validateClaim=function(e,t){return Hc.validate(e,t)};Re.verifyToken=function(e,t){var r=new Re;return r.verifyToken(e,t)};Re.createRegistry=function(e){return dn.createRegistry(e)};Re.Right=uo;Re.Claim=Hc;Re.Anchor=Ya;Re.Proof=Hp;Re.Registry=dn;Re.Obligation=Fk;Mx.exports=Re});var qk=P((q5,Cx)=>{y();Cx.exports=kx()});return qk();})();
|
|
70
70
|
if(typeof module!=="undefined"&&module.exports){module.exports=bsvLTP}else if(typeof define==="function"&&define.amd){define([],function(){return bsvLTP})}
|