@smartledger/bsv 9.15.0 → 9.16.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 +63 -0
- package/README.md +19 -19
- package/bsv-gdaf.min.js +2 -2
- package/bsv-ltp.min.js +3 -3
- package/bsv-smartcontract.min.js +1 -1
- package/bsv.bundle.js +2 -2
- package/bsv.min.js +2 -2
- package/docs/AUDIT_SCOPE.md +6 -6
- package/docs/BRC220_BATCH_LEAF_AMENDMENT.md +16 -4
- package/docs/BRC220_CERTIFICATE_FIELDS_AMENDMENT.md +11 -4
- package/docs/BRC220_PLAN.md +5 -2
- package/docs/MODULE_REFERENCE_COMPLETE.md +27 -27
- package/docs/advanced/UTXO_MANAGER_GUIDE.md +1 -1
- package/docs/audit-rfq/cure53.txt +1 -1
- package/docs/audit-rfq/ncc-group.txt +1 -1
- package/docs/audit-rfq/trail-of-bits.txt +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/lib/script/interpreter.js +38 -15
- package/package.json +9 -5
- package/tools/gen-blind-spot-vectors.js +422 -0
- package/tools/minimal_reproduction.js +1 -1
- package/tools/opcode_map.js +11 -4
- package/tools/simple_real_tx.js +1 -1
- package/tools/sv-vector-coverage.js +174 -0
- package/tools/sv-vector-harness.js +8 -4
- package/version.js +1 -1
package/bsv-ltp.min.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var bsvLTP=(()=>{var gI=Object.create;var ps=Object.defineProperty;var yI=Object.getOwnPropertyDescriptor;var mI=Object.getOwnPropertyNames;var vI=Object.getPrototypeOf,bI=Object.prototype.hasOwnProperty;var _I=(e,t,r)=>t in e?ps(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r;var Wt=(e,t,r)=>()=>{if(r)throw r[0];try{return e&&(t=e(e=0)),t}catch(n){throw r=[n],n}};var B=(e,t)=>()=>{try{return t||e((t={exports:{}}).exports,t),t.exports}catch(r){throw t=0,r}},ul=(e,t)=>{for(var r in t)ps(e,r,{get:t[r],enumerable:!0})},u0=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of mI(t))!bI.call(e,i)&&i!==r&&ps(e,i,{get:()=>t[i],enumerable:!(n=yI(t,i))||n.enumerable});return e};var f0=(e,t,r)=>(r=e!=null?gI(vI(e)):{},u0(t||!e||!e.__esModule?ps(r,"default",{value:e,enumerable:!0}):r,e)),fl=e=>u0(ps({},"__esModule",{value:!0}),e);var Z=(e,t,r)=>_I(e,typeof t!="symbol"?t+"":t,r);var p0=B((FC,d0)=>{p();var tt=d0.exports={},Wr,zr;function cl(){throw new Error("setTimeout has not been defined")}function ll(){throw new Error("clearTimeout has not been defined")}(function(){try{typeof setTimeout=="function"?Wr=setTimeout:Wr=cl}catch{Wr=cl}try{typeof clearTimeout=="function"?zr=clearTimeout:zr=ll}catch{zr=ll}})();function c0(e){if(Wr===setTimeout)return setTimeout(e,0);if((Wr===cl||!Wr)&&setTimeout)return Wr=setTimeout,setTimeout(e,0);try{return Wr(e,0)}catch{try{return Wr.call(null,e,0)}catch{return Wr.call(this,e,0)}}}function SI(e){if(zr===clearTimeout)return clearTimeout(e);if((zr===ll||!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 pn=[],uo=!1,wi,Xa=-1;function wI(){!uo||!wi||(uo=!1,wi.length?pn=wi.concat(pn):Xa=-1,pn.length&&l0())}function l0(){if(!uo){var e=c0(wI);uo=!0;for(var t=pn.length;t;){for(wi=pn,pn=[];++Xa<t;)wi&&wi[Xa].run();Xa=-1,t=pn.length}wi=null,uo=!1,SI(e)}}tt.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];pn.push(new h0(e,t)),pn.length===1&&!uo&&c0(l0)};function h0(e,t){this.fun=e,this.array=t}h0.prototype.run=function(){this.fun.apply(null,this.array)};tt.title="browser";tt.browser=!0;tt.env={};tt.argv=[];tt.version="";tt.versions={};function gn(){}tt.on=gn;tt.addListener=gn;tt.once=gn;tt.off=gn;tt.removeListener=gn;tt.removeAllListeners=gn;tt.emit=gn;tt.prependListener=gn;tt.prependOnceListener=gn;tt.listeners=function(e){return[]};tt.binding=function(e){throw new Error("process.binding is not supported")};tt.cwd=function(){return"/"};tt.chdir=function(e){throw new Error("process.chdir is not supported")};tt.umask=function(){return 0}});var m0=B(Ja=>{"use strict";p();Ja.byteLength=xI;Ja.toByteArray=AI;Ja.fromByteArray=TI;var Yr=[],vr=[],EI=typeof Uint8Array<"u"?Uint8Array:Array,hl="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";for(Ei=0,g0=hl.length;Ei<g0;++Ei)Yr[Ei]=hl[Ei],vr[hl.charCodeAt(Ei)]=Ei;var Ei,g0;vr[45]=62;vr[95]=63;function y0(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 xI(e){var t=y0(e),r=t[0],n=t[1];return(r+n)*3/4-n}function II(e,t,r){return(t+r)*3/4-r}function AI(e){var t,r=y0(e),n=r[0],i=r[1],o=new EI(II(e,n,i)),s=0,a=i>0?n-4:n,f;for(f=0;f<a;f+=4)t=vr[e.charCodeAt(f)]<<18|vr[e.charCodeAt(f+1)]<<12|vr[e.charCodeAt(f+2)]<<6|vr[e.charCodeAt(f+3)],o[s++]=t>>16&255,o[s++]=t>>8&255,o[s++]=t&255;return i===2&&(t=vr[e.charCodeAt(f)]<<2|vr[e.charCodeAt(f+1)]>>4,o[s++]=t&255),i===1&&(t=vr[e.charCodeAt(f)]<<10|vr[e.charCodeAt(f+1)]<<4|vr[e.charCodeAt(f+2)]>>2,o[s++]=t>>8&255,o[s++]=t&255),o}function OI(e){return Yr[e>>18&63]+Yr[e>>12&63]+Yr[e>>6&63]+Yr[e&63]}function RI(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(OI(n));return i.join("")}function TI(e){for(var t,r=e.length,n=r%3,i=[],o=16383,s=0,a=r-n;s<a;s+=o)i.push(RI(e,s,s+o>a?a:s+o));return n===1?(t=e[r-1],i.push(Yr[t>>2]+Yr[t<<4&63]+"==")):n===2&&(t=(e[r-2]<<8)+e[r-1],i.push(Yr[t>>10]+Yr[t>>4&63]+Yr[t<<2&63]+"=")),i.join("")}});var v0=B(dl=>{p();dl.read=function(e,t,r,n,i){var o,s,a=i*8-n-1,f=(1<<a)-1,l=f>>1,y=-7,g=r?i-1:0,v=r?-1:1,E=e[t+g];for(g+=v,o=E&(1<<-y)-1,E>>=-y,y+=a;y>0;o=o*256+e[t+g],g+=v,y-=8);for(s=o&(1<<-y)-1,o>>=-y,y+=n;y>0;s=s*256+e[t+g],g+=v,y-=8);if(o===0)o=1-l;else{if(o===f)return s?NaN:(E?-1:1)*(1/0);s=s+Math.pow(2,n),o=o-l}return(E?-1:1)*s*Math.pow(2,o-n)};dl.write=function(e,t,r,n,i,o){var s,a,f,l=o*8-i-1,y=(1<<l)-1,g=y>>1,v=i===23?Math.pow(2,-24)-Math.pow(2,-77):0,E=n?0:o-1,T=n?1:-1,M=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=y):(s=Math.floor(Math.log(t)/Math.LN2),t*(f=Math.pow(2,-s))<1&&(s--,f*=2),s+g>=1?t+=v/f:t+=v*Math.pow(2,1-g),t*f>=2&&(s++,f/=2),s+g>=y?(a=0,s=y):s+g>=1?(a=(t*f-1)*Math.pow(2,i),s=s+g):(a=t*Math.pow(2,g-1)*Math.pow(2,i),s=0));i>=8;e[r+E]=a&255,E+=T,a/=256,i-=8);for(s=s<<i|a,l+=i;l>0;e[r+E]=s&255,E+=T,s/=256,l-=8);e[r+E-T]|=M*128}});var Nt=B(ho=>{"use strict";p();var pl=m0(),co=v0(),b0=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):null;ho.Buffer=j;ho.SlowBuffer=CI;ho.INSPECT_MAX_BYTES=50;var Qa=2147483647;ho.kMaxLength=Qa;j.TYPED_ARRAY_SUPPORT=PI();!j.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 PI(){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(j.prototype,"parent",{enumerable:!0,get:function(){if(j.isBuffer(this))return this.buffer}});Object.defineProperty(j.prototype,"offset",{enumerable:!0,get:function(){if(j.isBuffer(this))return this.byteOffset}});function yn(e){if(e>Qa)throw new RangeError('The value "'+e+'" is invalid for option "size"');let t=new Uint8Array(e);return Object.setPrototypeOf(t,j.prototype),t}function j(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 vl(e)}return E0(e,t,r)}j.poolSize=8192;function E0(e,t,r){if(typeof e=="string")return NI(e,t);if(ArrayBuffer.isView(e))return MI(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($r(e,ArrayBuffer)||e&&$r(e.buffer,ArrayBuffer)||typeof SharedArrayBuffer<"u"&&($r(e,SharedArrayBuffer)||e&&$r(e.buffer,SharedArrayBuffer)))return yl(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 j.from(n,t,r);let i=kI(e);if(i)return i;if(typeof Symbol<"u"&&Symbol.toPrimitive!=null&&typeof e[Symbol.toPrimitive]=="function")return j.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)}j.from=function(e,t,r){return E0(e,t,r)};Object.setPrototypeOf(j.prototype,Uint8Array.prototype);Object.setPrototypeOf(j,Uint8Array);function x0(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 BI(e,t,r){return x0(e),e<=0?yn(e):t!==void 0?typeof r=="string"?yn(e).fill(t,r):yn(e).fill(t):yn(e)}j.alloc=function(e,t,r){return BI(e,t,r)};function vl(e){return x0(e),yn(e<0?0:bl(e)|0)}j.allocUnsafe=function(e){return vl(e)};j.allocUnsafeSlow=function(e){return vl(e)};function NI(e,t){if((typeof t!="string"||t==="")&&(t="utf8"),!j.isEncoding(t))throw new TypeError("Unknown encoding: "+t);let r=I0(e,t)|0,n=yn(r),i=n.write(e,t);return i!==r&&(n=n.slice(0,i)),n}function gl(e){let t=e.length<0?0:bl(e.length)|0,r=yn(t);for(let n=0;n<t;n+=1)r[n]=e[n]&255;return r}function MI(e){if($r(e,Uint8Array)){let t=new Uint8Array(e);return yl(t.buffer,t.byteOffset,t.byteLength)}return gl(e)}function yl(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,j.prototype),n}function kI(e){if(j.isBuffer(e)){let t=bl(e.length)|0,r=yn(t);return r.length===0||e.copy(r,0,0,t),r}if(e.length!==void 0)return typeof e.length!="number"||Sl(e.length)?yn(0):gl(e);if(e.type==="Buffer"&&Array.isArray(e.data))return gl(e.data)}function bl(e){if(e>=Qa)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+Qa.toString(16)+" bytes");return e|0}function CI(e){return+e!=e&&(e=0),j.alloc(+e)}j.isBuffer=function(t){return t!=null&&t._isBuffer===!0&&t!==j.prototype};j.compare=function(t,r){if($r(t,Uint8Array)&&(t=j.from(t,t.offset,t.byteLength)),$r(r,Uint8Array)&&(r=j.from(r,r.offset,r.byteLength)),!j.isBuffer(t)||!j.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};j.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}};j.concat=function(t,r){if(!Array.isArray(t))throw new TypeError('"list" argument must be an Array of Buffers');if(t.length===0)return j.alloc(0);let n;if(r===void 0)for(r=0,n=0;n<t.length;++n)r+=t[n].length;let i=j.allocUnsafe(r),o=0;for(n=0;n<t.length;++n){let s=t[n];if($r(s,Uint8Array))o+s.length>i.length?(j.isBuffer(s)||(s=j.from(s)),s.copy(i,o)):Uint8Array.prototype.set.call(i,s,o);else if(j.isBuffer(s))s.copy(i,o);else throw new TypeError('"list" argument must be an Array of Buffers');o+=s.length}return i};function I0(e,t){if(j.isBuffer(e))return e.length;if(ArrayBuffer.isView(e)||$r(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 ml(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return r*2;case"hex":return r>>>1;case"base64":return k0(e).length;default:if(i)return n?-1:ml(e).length;t=(""+t).toLowerCase(),i=!0}}j.byteLength=I0;function LI(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 WI(this,t,r);case"utf8":case"utf-8":return O0(this,t,r);case"ascii":return GI(this,t,r);case"latin1":case"binary":return VI(this,t,r);case"base64":return jI(this,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return zI(this,t,r);default:if(n)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),n=!0}}j.prototype._isBuffer=!0;function xi(e,t,r){let n=e[t];e[t]=e[r],e[r]=n}j.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)xi(this,r,r+1);return this};j.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)xi(this,r,r+3),xi(this,r+1,r+2);return this};j.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)xi(this,r,r+7),xi(this,r+1,r+6),xi(this,r+2,r+5),xi(this,r+3,r+4);return this};j.prototype.toString=function(){let t=this.length;return t===0?"":arguments.length===0?O0(this,0,t):LI.apply(this,arguments)};j.prototype.toLocaleString=j.prototype.toString;j.prototype.equals=function(t){if(!j.isBuffer(t))throw new TypeError("Argument must be a Buffer");return this===t?!0:j.compare(this,t)===0};j.prototype.inspect=function(){let t="",r=ho.INSPECT_MAX_BYTES;return t=this.toString("hex",0,r).replace(/(.{2})/g,"$1 ").trim(),this.length>r&&(t+=" ... "),"<Buffer "+t+">"};b0&&(j.prototype[b0]=j.prototype.inspect);j.prototype.compare=function(t,r,n,i,o){if($r(t,Uint8Array)&&(t=j.from(t,t.offset,t.byteLength)),!j.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,f=Math.min(s,a),l=this.slice(i,o),y=t.slice(r,n);for(let g=0;g<f;++g)if(l[g]!==y[g]){s=l[g],a=y[g];break}return s<a?-1:a<s?1:0};function A0(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,Sl(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=j.from(t,n)),j.isBuffer(t))return t.length===0?-1:_0(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):_0(e,[t],r,n,i);throw new TypeError("val must be string, number or Buffer")}function _0(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 f(y,g){return o===1?y[g]:y.readUInt16BE(g*o)}let l;if(i){let y=-1;for(l=r;l<s;l++)if(f(e,l)===f(t,y===-1?0:l-y)){if(y===-1&&(y=l),l-y+1===a)return y*o}else y!==-1&&(l-=l-y),y=-1}else for(r+a>s&&(r=s-a),l=r;l>=0;l--){let y=!0;for(let g=0;g<a;g++)if(f(e,l+g)!==f(t,g)){y=!1;break}if(y)return l}return-1}j.prototype.includes=function(t,r,n){return this.indexOf(t,r,n)!==-1};j.prototype.indexOf=function(t,r,n){return A0(this,t,r,n,!0)};j.prototype.lastIndexOf=function(t,r,n){return A0(this,t,r,n,!1)};function DI(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(Sl(a))return s;e[r+s]=a}return s}function UI(e,t,r,n){return eu(ml(t,e.length-r),e,r,n)}function FI(e,t,r,n){return eu(XI(t),e,r,n)}function qI(e,t,r,n){return eu(k0(t),e,r,n)}function HI(e,t,r,n){return eu(JI(t,e.length-r),e,r,n)}j.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 DI(this,t,r,n);case"utf8":case"utf-8":return UI(this,t,r,n);case"ascii":case"latin1":case"binary":return FI(this,t,r,n);case"base64":return qI(this,t,r,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return HI(this,t,r,n);default:if(s)throw new TypeError("Unknown encoding: "+i);i=(""+i).toLowerCase(),s=!0}};j.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function jI(e,t,r){return t===0&&r===e.length?pl.fromByteArray(e):pl.fromByteArray(e.slice(t,r))}function O0(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 f,l,y,g;switch(a){case 1:o<128&&(s=o);break;case 2:f=e[i+1],(f&192)===128&&(g=(o&31)<<6|f&63,g>127&&(s=g));break;case 3:f=e[i+1],l=e[i+2],(f&192)===128&&(l&192)===128&&(g=(o&15)<<12|(f&63)<<6|l&63,g>2047&&(g<55296||g>57343)&&(s=g));break;case 4:f=e[i+1],l=e[i+2],y=e[i+3],(f&192)===128&&(l&192)===128&&(y&192)===128&&(g=(o&15)<<18|(f&63)<<12|(l&63)<<6|y&63,g>65535&&g<1114112&&(s=g))}}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 KI(n)}var S0=4096;function KI(e){let t=e.length;if(t<=S0)return String.fromCharCode.apply(String,e);let r="",n=0;for(;n<t;)r+=String.fromCharCode.apply(String,e.slice(n,n+=S0));return r}function GI(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 VI(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 WI(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+=QI[e[o]];return i}function zI(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}j.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,j.prototype),i};function Ut(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")}j.prototype.readUintLE=j.prototype.readUIntLE=function(t,r,n){t=t>>>0,r=r>>>0,n||Ut(t,r,this.length);let i=this[t],o=1,s=0;for(;++s<r&&(o*=256);)i+=this[t+s]*o;return i};j.prototype.readUintBE=j.prototype.readUIntBE=function(t,r,n){t=t>>>0,r=r>>>0,n||Ut(t,r,this.length);let i=this[t+--r],o=1;for(;r>0&&(o*=256);)i+=this[t+--r]*o;return i};j.prototype.readUint8=j.prototype.readUInt8=function(t,r){return t=t>>>0,r||Ut(t,1,this.length),this[t]};j.prototype.readUint16LE=j.prototype.readUInt16LE=function(t,r){return t=t>>>0,r||Ut(t,2,this.length),this[t]|this[t+1]<<8};j.prototype.readUint16BE=j.prototype.readUInt16BE=function(t,r){return t=t>>>0,r||Ut(t,2,this.length),this[t]<<8|this[t+1]};j.prototype.readUint32LE=j.prototype.readUInt32LE=function(t,r){return t=t>>>0,r||Ut(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+this[t+3]*16777216};j.prototype.readUint32BE=j.prototype.readUInt32BE=function(t,r){return t=t>>>0,r||Ut(t,4,this.length),this[t]*16777216+(this[t+1]<<16|this[t+2]<<8|this[t+3])};j.prototype.readBigUInt64LE=Kn(function(t){t=t>>>0,lo(t,"offset");let r=this[t],n=this[t+7];(r===void 0||n===void 0)&&gs(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))});j.prototype.readBigUInt64BE=Kn(function(t){t=t>>>0,lo(t,"offset");let r=this[t],n=this[t+7];(r===void 0||n===void 0)&&gs(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)});j.prototype.readIntLE=function(t,r,n){t=t>>>0,r=r>>>0,n||Ut(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};j.prototype.readIntBE=function(t,r,n){t=t>>>0,r=r>>>0,n||Ut(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};j.prototype.readInt8=function(t,r){return t=t>>>0,r||Ut(t,1,this.length),this[t]&128?(255-this[t]+1)*-1:this[t]};j.prototype.readInt16LE=function(t,r){t=t>>>0,r||Ut(t,2,this.length);let n=this[t]|this[t+1]<<8;return n&32768?n|4294901760:n};j.prototype.readInt16BE=function(t,r){t=t>>>0,r||Ut(t,2,this.length);let n=this[t+1]|this[t]<<8;return n&32768?n|4294901760:n};j.prototype.readInt32LE=function(t,r){return t=t>>>0,r||Ut(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24};j.prototype.readInt32BE=function(t,r){return t=t>>>0,r||Ut(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]};j.prototype.readBigInt64LE=Kn(function(t){t=t>>>0,lo(t,"offset");let r=this[t],n=this[t+7];(r===void 0||n===void 0)&&gs(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)});j.prototype.readBigInt64BE=Kn(function(t){t=t>>>0,lo(t,"offset");let r=this[t],n=this[t+7];(r===void 0||n===void 0)&&gs(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)});j.prototype.readFloatLE=function(t,r){return t=t>>>0,r||Ut(t,4,this.length),co.read(this,t,!0,23,4)};j.prototype.readFloatBE=function(t,r){return t=t>>>0,r||Ut(t,4,this.length),co.read(this,t,!1,23,4)};j.prototype.readDoubleLE=function(t,r){return t=t>>>0,r||Ut(t,8,this.length),co.read(this,t,!0,52,8)};j.prototype.readDoubleBE=function(t,r){return t=t>>>0,r||Ut(t,8,this.length),co.read(this,t,!1,52,8)};function sr(e,t,r,n,i,o){if(!j.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")}j.prototype.writeUintLE=j.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};j.prototype.writeUintBE=j.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};j.prototype.writeUint8=j.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};j.prototype.writeUint16LE=j.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};j.prototype.writeUint16BE=j.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};j.prototype.writeUint32LE=j.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};j.prototype.writeUint32BE=j.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 R0(e,t,r,n,i){M0(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 T0(e,t,r,n,i){M0(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}j.prototype.writeBigUInt64LE=Kn(function(t,r=0){return R0(this,t,r,BigInt(0),BigInt("0xffffffffffffffff"))});j.prototype.writeBigUInt64BE=Kn(function(t,r=0){return T0(this,t,r,BigInt(0),BigInt("0xffffffffffffffff"))});j.prototype.writeIntLE=function(t,r,n,i){if(t=+t,r=r>>>0,!i){let f=Math.pow(2,8*n-1);sr(this,t,r,n,f-1,-f)}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};j.prototype.writeIntBE=function(t,r,n,i){if(t=+t,r=r>>>0,!i){let f=Math.pow(2,8*n-1);sr(this,t,r,n,f-1,-f)}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};j.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};j.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};j.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};j.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};j.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};j.prototype.writeBigInt64LE=Kn(function(t,r=0){return R0(this,t,r,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});j.prototype.writeBigInt64BE=Kn(function(t,r=0){return T0(this,t,r,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});function P0(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 B0(e,t,r,n,i){return t=+t,r=r>>>0,i||P0(e,t,r,4,34028234663852886e22,-34028234663852886e22),co.write(e,t,r,n,23,4),r+4}j.prototype.writeFloatLE=function(t,r,n){return B0(this,t,r,!0,n)};j.prototype.writeFloatBE=function(t,r,n){return B0(this,t,r,!1,n)};function N0(e,t,r,n,i){return t=+t,r=r>>>0,i||P0(e,t,r,8,17976931348623157e292,-17976931348623157e292),co.write(e,t,r,n,52,8),r+8}j.prototype.writeDoubleLE=function(t,r,n){return N0(this,t,r,!0,n)};j.prototype.writeDoubleBE=function(t,r,n){return N0(this,t,r,!1,n)};j.prototype.copy=function(t,r,n,i){if(!j.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};j.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"&&!j.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=j.isBuffer(t)?t:j.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 fo={};function _l(e,t,r){fo[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}`}}}_l("ERR_BUFFER_OUT_OF_BOUNDS",function(e){return e?`${e} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"},RangeError);_l("ERR_INVALID_ARG_TYPE",function(e,t){return`The "${e}" argument must be of type number. Received type ${typeof t}`},TypeError);_l("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=w0(String(r)):typeof r=="bigint"&&(i=String(r),(r>BigInt(2)**BigInt(32)||r<-(BigInt(2)**BigInt(32)))&&(i=w0(i)),i+="n"),n+=` It must be ${t}. Received ${i}`,n},RangeError);function w0(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 YI(e,t,r){lo(t,"offset"),(e[t]===void 0||e[t+r]===void 0)&&gs(t,e.length-(r+1))}function M0(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 fo.ERR_OUT_OF_RANGE("value",a,e)}YI(n,i,o)}function lo(e,t){if(typeof e!="number")throw new fo.ERR_INVALID_ARG_TYPE(t,"number",e)}function gs(e,t,r){throw Math.floor(e)!==e?(lo(e,r),new fo.ERR_OUT_OF_RANGE(r||"offset","an integer",e)):t<0?new fo.ERR_BUFFER_OUT_OF_BOUNDS:new fo.ERR_OUT_OF_RANGE(r||"offset",`>= ${r?1:0} and <= ${t}`,e)}var $I=/[^+/0-9A-Za-z-_]/g;function ZI(e){if(e=e.split("=")[0],e=e.trim().replace($I,""),e.length<2)return"";for(;e.length%4!==0;)e=e+"=";return e}function ml(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 XI(e){let t=[];for(let r=0;r<e.length;++r)t.push(e.charCodeAt(r)&255);return t}function JI(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 k0(e){return pl.toByteArray(ZI(e))}function eu(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 $r(e,t){return e instanceof t||e!=null&&e.constructor!=null&&e.constructor.name!=null&&e.constructor.name===t.name}function Sl(e){return e!==e}var QI=(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"?eA:e}function eA(){throw new Error("BigInt not supported")}});var x,d,p=Wt(()=>{x=f0(p0()),d=f0(Nt())});var L0=B((C0,wl)=>{p();(function(e,t){"use strict";function r(I,u){if(!I)throw new Error(u||"Assertion failed")}function n(I,u){I.super_=u;var h=function(){};h.prototype=u.prototype,I.prototype=new h,I.prototype.constructor=I}function i(I,u,h){if(i.isBN(I))return I;this.negative=0,this.words=null,this.length=0,this.red=null,I!==null&&((u==="le"||u==="be")&&(h=u,u=10),this._init(I||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=Nt().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,m){if(typeof u=="number")return this._initNumber(u,h,m);if(typeof u=="object")return this._initArray(u,h,m);h==="hex"&&(h=16),r(h===(h|0)&&h>=2&&h<=36),u=u.toString().replace(/\s+/g,"");var S=0;u[0]==="-"&&(S++,this.negative=1),S<u.length&&(h===16?this._parseHex(u,S,m):(this._parseBase(u,h,S),m==="le"&&this._initArray(this.toArray(),h,m)))},i.prototype._initNumber=function(u,h,m){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),m==="le"&&this._initArray(this.toArray(),h,m)},i.prototype._initArray=function(u,h,m){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 S=0;S<this.length;S++)this.words[S]=0;var w,R,A=0;if(m==="be")for(S=u.length-1,w=0;S>=0;S-=3)R=u[S]|u[S-1]<<8|u[S-2]<<16,this.words[w]|=R<<A&67108863,this.words[w+1]=R>>>26-A&67108863,A+=24,A>=26&&(A-=26,w++);else if(m==="le")for(S=0,w=0;S<u.length;S+=3)R=u[S]|u[S+1]<<8|u[S+2]<<16,this.words[w]|=R<<A&67108863,this.words[w+1]=R>>>26-A&67108863,A+=24,A>=26&&(A-=26,w++);return this.strip()};function s(I,u){var h=I.charCodeAt(u);return h>=65&&h<=70?h-55:h>=97&&h<=102?h-87:h-48&15}function a(I,u,h){var m=s(I,h);return h-1>=u&&(m|=s(I,h-1)<<4),m}i.prototype._parseHex=function(u,h,m){this.length=Math.ceil((u.length-h)/6),this.words=new Array(this.length);for(var S=0;S<this.length;S++)this.words[S]=0;var w=0,R=0,A;if(m==="be")for(S=u.length-1;S>=h;S-=2)A=a(u,h,S)<<w,this.words[R]|=A&67108863,w>=18?(w-=18,R+=1,this.words[R]|=A>>>26):w+=8;else{var _=u.length-h;for(S=_%2===0?h+1:h;S<u.length;S+=2)A=a(u,h,S)<<w,this.words[R]|=A&67108863,w>=18?(w-=18,R+=1,this.words[R]|=A>>>26):w+=8}this.strip()};function f(I,u,h,m){for(var S=0,w=Math.min(I.length,h),R=u;R<w;R++){var A=I.charCodeAt(R)-48;S*=m,A>=49?S+=A-49+10:A>=17?S+=A-17+10:S+=A}return S}i.prototype._parseBase=function(u,h,m){this.words=[0],this.length=1;for(var S=0,w=1;w<=67108863;w*=h)S++;S--,w=w/h|0;for(var R=u.length-m,A=R%S,_=Math.min(R,R-A)+m,c=0,b=m;b<_;b+=S)c=f(u,b,b+S,h),this.imuln(w),this.words[0]+c<67108864?this.words[0]+=c:this._iaddn(c);if(A!==0){var k=1;for(c=f(u,b,u.length,h),b=0;b<A;b++)k*=h;this.imuln(k),this.words[0]+c<67108864?this.words[0]+=c:this._iaddn(c)}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"],y=[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],g=[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 m;if(u===16||u==="hex"){m="";for(var S=0,w=0,R=0;R<this.length;R++){var A=this.words[R],_=((A<<S|w)&16777215).toString(16);w=A>>>24-S&16777215,S+=2,S>=26&&(S-=26,R--),w!==0||R!==this.length-1?m=l[6-_.length]+_+m:m=_+m}for(w!==0&&(m=w.toString(16)+m);m.length%h!==0;)m="0"+m;return this.negative!==0&&(m="-"+m),m}if(u===(u|0)&&u>=2&&u<=36){var c=y[u],b=g[u];m="";var k=this.clone();for(k.negative=0;!k.isZero();){var L=k.modn(b).toString(u);k=k.idivn(b),k.isZero()?m=L+m:m=l[c-L.length]+L+m}for(this.isZero()&&(m="0"+m);m.length%h!==0;)m="0"+m;return this.negative!==0&&(m="-"+m),m}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,m){var S=this.byteLength(),w=m||Math.max(1,S);r(S<=w,"byte array longer than desired length"),r(w>0,"Requested array length <= 0"),this.strip();var R=h==="le",A=new u(w),_,c,b=this.clone();if(R){for(c=0;!b.isZero();c++)_=b.andln(255),b.iushrn(8),A[c]=_;for(;c<w;c++)A[c]=0}else{for(c=0;c<w-S;c++)A[c]=0;for(c=0;!b.isZero();c++)_=b.andln(255),b.iushrn(8),A[w-c-1]=_}return A},Math.clz32?i.prototype._countBits=function(u){return 32-Math.clz32(u)}:i.prototype._countBits=function(u){var h=u,m=0;return h>=4096&&(m+=13,h>>>=13),h>=64&&(m+=7,h>>>=7),h>=8&&(m+=4,h>>>=4),h>=2&&(m+=2,h>>>=2),m+h},i.prototype._zeroBits=function(u){if(u===0)return 26;var h=u,m=0;return(h&8191)===0&&(m+=13,h>>>=13),(h&127)===0&&(m+=7,h>>>=7),(h&15)===0&&(m+=4,h>>>=4),(h&3)===0&&(m+=2,h>>>=2),(h&1)===0&&m++,m},i.prototype.bitLength=function(){var u=this.words[this.length-1],h=this._countBits(u);return(this.length-1)*26+h};function v(I){for(var u=new Array(I.bitLength()),h=0;h<u.length;h++){var m=h/26|0,S=h%26;u[h]=(I.words[m]&1<<S)>>>S}return u}i.prototype.zeroBits=function(){if(this.isZero())return 0;for(var u=0,h=0;h<this.length;h++){var m=this._zeroBits(this.words[h]);if(u+=m,m!==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 m=0;m<h.length;m++)this.words[m]=this.words[m]&u.words[m];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,m;this.length>u.length?(h=this,m=u):(h=u,m=this);for(var S=0;S<m.length;S++)this.words[S]=h.words[S]^m.words[S];if(this!==h)for(;S<h.length;S++)this.words[S]=h.words[S];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,m=u%26;this._expand(h),m>0&&h--;for(var S=0;S<h;S++)this.words[S]=~this.words[S]&67108863;for(m>0&&(this.words[S]=~this.words[S]&67108863>>26-m,S++);S<this.length;S++)this.words[S]=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 m=u/26|0,S=u%26;return this._expand(m+1),h?this.words[m]=this.words[m]|1<<S:this.words[m]=this.words[m]&~(1<<S),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 m,S;this.length>u.length?(m=this,S=u):(m=u,S=this);for(var w=0,R=0;R<S.length;R++)h=(m.words[R]|0)+(S.words[R]|0)+w,this.words[R]=h&67108863,w=h>>>26;for(;w!==0&&R<m.length;R++)h=(m.words[R]|0)+w,this.words[R]=h&67108863,w=h>>>26;if(this.length=m.length,w!==0)this.words[this.length]=w,this.length++;else if(m!==this)for(;R<m.length;R++)this.words[R]=m.words[R];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 m=this.cmp(u);if(m===0)return this.negative=0,this.length=1,this.words[0]=0,this;var S,w;m>0?(S=this,w=u):(S=u,w=this);for(var R=0,A=0;A<w.length;A++)h=(S.words[A]|0)-(w.words[A]|0)+R,R=h>>26,this.words[A]=h&67108863;for(;R!==0&&A<S.length;A++)h=(S.words[A]|0)+R,R=h>>26,this.words[A]=h&67108863;if(R===0&&A<S.length&&S!==this)for(;A<S.length;A++)this.words[A]=S.words[A];return this.length=Math.max(this.length,A),S!==this&&(this.negative=1),this.strip()},i.prototype.sub=function(u){return this.clone().isub(u)};function E(I,u,h){h.negative=u.negative^I.negative;var m=I.length+u.length|0;h.length=m,m=m-1|0;var S=I.words[0]|0,w=u.words[0]|0,R=S*w,A=R&67108863,_=R/67108864|0;h.words[0]=A;for(var c=1;c<m;c++){for(var b=_>>>26,k=_&67108863,L=Math.min(c,u.length-1),H=Math.max(0,c-I.length+1);H<=L;H++){var W=c-H|0;S=I.words[W]|0,w=u.words[H]|0,R=S*w+k,b+=R/67108864|0,k=R&67108863}h.words[c]=k|0,_=b|0}return _!==0?h.words[c]=_|0:h.length--,h.strip()}var T=function(u,h,m){var S=u.words,w=h.words,R=m.words,A=0,_,c,b,k=S[0]|0,L=k&8191,H=k>>>13,W=S[1]|0,te=W&8191,X=W>>>13,ue=S[2]|0,fe=ue&8191,O=ue>>>13,C=S[3]|0,D=C&8191,K=C>>>13,re=S[4]|0,J=re&8191,Q=re>>>13,se=S[5]|0,ce=se&8191,ae=se>>>13,_e=S[6]|0,oe=_e&8191,Pe=_e>>>13,ge=S[7]|0,be=ge&8191,Ee=ge>>>13,or=S[8]|0,Ze=or&8191,Ve=or>>>13,Za=S[9]|0,Je=Za&8191,st=Za>>>13,Jp=w[0]|0,at=Jp&8191,ut=Jp>>>13,Qp=w[1]|0,ft=Qp&8191,ct=Qp>>>13,e0=w[2]|0,lt=e0&8191,ht=e0>>>13,t0=w[3]|0,dt=t0&8191,pt=t0>>>13,r0=w[4]|0,gt=r0&8191,yt=r0>>>13,n0=w[5]|0,mt=n0&8191,vt=n0>>>13,i0=w[6]|0,bt=i0&8191,_t=i0>>>13,o0=w[7]|0,St=o0&8191,wt=o0>>>13,s0=w[8]|0,Et=s0&8191,xt=s0>>>13,a0=w[9]|0,It=a0&8191,At=a0>>>13;m.negative=u.negative^h.negative,m.length=19,_=Math.imul(L,at),c=Math.imul(L,ut),c=c+Math.imul(H,at)|0,b=Math.imul(H,ut);var Kc=(A+_|0)+((c&8191)<<13)|0;A=(b+(c>>>13)|0)+(Kc>>>26)|0,Kc&=67108863,_=Math.imul(te,at),c=Math.imul(te,ut),c=c+Math.imul(X,at)|0,b=Math.imul(X,ut),_=_+Math.imul(L,ft)|0,c=c+Math.imul(L,ct)|0,c=c+Math.imul(H,ft)|0,b=b+Math.imul(H,ct)|0;var Gc=(A+_|0)+((c&8191)<<13)|0;A=(b+(c>>>13)|0)+(Gc>>>26)|0,Gc&=67108863,_=Math.imul(fe,at),c=Math.imul(fe,ut),c=c+Math.imul(O,at)|0,b=Math.imul(O,ut),_=_+Math.imul(te,ft)|0,c=c+Math.imul(te,ct)|0,c=c+Math.imul(X,ft)|0,b=b+Math.imul(X,ct)|0,_=_+Math.imul(L,lt)|0,c=c+Math.imul(L,ht)|0,c=c+Math.imul(H,lt)|0,b=b+Math.imul(H,ht)|0;var Vc=(A+_|0)+((c&8191)<<13)|0;A=(b+(c>>>13)|0)+(Vc>>>26)|0,Vc&=67108863,_=Math.imul(D,at),c=Math.imul(D,ut),c=c+Math.imul(K,at)|0,b=Math.imul(K,ut),_=_+Math.imul(fe,ft)|0,c=c+Math.imul(fe,ct)|0,c=c+Math.imul(O,ft)|0,b=b+Math.imul(O,ct)|0,_=_+Math.imul(te,lt)|0,c=c+Math.imul(te,ht)|0,c=c+Math.imul(X,lt)|0,b=b+Math.imul(X,ht)|0,_=_+Math.imul(L,dt)|0,c=c+Math.imul(L,pt)|0,c=c+Math.imul(H,dt)|0,b=b+Math.imul(H,pt)|0;var Wc=(A+_|0)+((c&8191)<<13)|0;A=(b+(c>>>13)|0)+(Wc>>>26)|0,Wc&=67108863,_=Math.imul(J,at),c=Math.imul(J,ut),c=c+Math.imul(Q,at)|0,b=Math.imul(Q,ut),_=_+Math.imul(D,ft)|0,c=c+Math.imul(D,ct)|0,c=c+Math.imul(K,ft)|0,b=b+Math.imul(K,ct)|0,_=_+Math.imul(fe,lt)|0,c=c+Math.imul(fe,ht)|0,c=c+Math.imul(O,lt)|0,b=b+Math.imul(O,ht)|0,_=_+Math.imul(te,dt)|0,c=c+Math.imul(te,pt)|0,c=c+Math.imul(X,dt)|0,b=b+Math.imul(X,pt)|0,_=_+Math.imul(L,gt)|0,c=c+Math.imul(L,yt)|0,c=c+Math.imul(H,gt)|0,b=b+Math.imul(H,yt)|0;var zc=(A+_|0)+((c&8191)<<13)|0;A=(b+(c>>>13)|0)+(zc>>>26)|0,zc&=67108863,_=Math.imul(ce,at),c=Math.imul(ce,ut),c=c+Math.imul(ae,at)|0,b=Math.imul(ae,ut),_=_+Math.imul(J,ft)|0,c=c+Math.imul(J,ct)|0,c=c+Math.imul(Q,ft)|0,b=b+Math.imul(Q,ct)|0,_=_+Math.imul(D,lt)|0,c=c+Math.imul(D,ht)|0,c=c+Math.imul(K,lt)|0,b=b+Math.imul(K,ht)|0,_=_+Math.imul(fe,dt)|0,c=c+Math.imul(fe,pt)|0,c=c+Math.imul(O,dt)|0,b=b+Math.imul(O,pt)|0,_=_+Math.imul(te,gt)|0,c=c+Math.imul(te,yt)|0,c=c+Math.imul(X,gt)|0,b=b+Math.imul(X,yt)|0,_=_+Math.imul(L,mt)|0,c=c+Math.imul(L,vt)|0,c=c+Math.imul(H,mt)|0,b=b+Math.imul(H,vt)|0;var Yc=(A+_|0)+((c&8191)<<13)|0;A=(b+(c>>>13)|0)+(Yc>>>26)|0,Yc&=67108863,_=Math.imul(oe,at),c=Math.imul(oe,ut),c=c+Math.imul(Pe,at)|0,b=Math.imul(Pe,ut),_=_+Math.imul(ce,ft)|0,c=c+Math.imul(ce,ct)|0,c=c+Math.imul(ae,ft)|0,b=b+Math.imul(ae,ct)|0,_=_+Math.imul(J,lt)|0,c=c+Math.imul(J,ht)|0,c=c+Math.imul(Q,lt)|0,b=b+Math.imul(Q,ht)|0,_=_+Math.imul(D,dt)|0,c=c+Math.imul(D,pt)|0,c=c+Math.imul(K,dt)|0,b=b+Math.imul(K,pt)|0,_=_+Math.imul(fe,gt)|0,c=c+Math.imul(fe,yt)|0,c=c+Math.imul(O,gt)|0,b=b+Math.imul(O,yt)|0,_=_+Math.imul(te,mt)|0,c=c+Math.imul(te,vt)|0,c=c+Math.imul(X,mt)|0,b=b+Math.imul(X,vt)|0,_=_+Math.imul(L,bt)|0,c=c+Math.imul(L,_t)|0,c=c+Math.imul(H,bt)|0,b=b+Math.imul(H,_t)|0;var $c=(A+_|0)+((c&8191)<<13)|0;A=(b+(c>>>13)|0)+($c>>>26)|0,$c&=67108863,_=Math.imul(be,at),c=Math.imul(be,ut),c=c+Math.imul(Ee,at)|0,b=Math.imul(Ee,ut),_=_+Math.imul(oe,ft)|0,c=c+Math.imul(oe,ct)|0,c=c+Math.imul(Pe,ft)|0,b=b+Math.imul(Pe,ct)|0,_=_+Math.imul(ce,lt)|0,c=c+Math.imul(ce,ht)|0,c=c+Math.imul(ae,lt)|0,b=b+Math.imul(ae,ht)|0,_=_+Math.imul(J,dt)|0,c=c+Math.imul(J,pt)|0,c=c+Math.imul(Q,dt)|0,b=b+Math.imul(Q,pt)|0,_=_+Math.imul(D,gt)|0,c=c+Math.imul(D,yt)|0,c=c+Math.imul(K,gt)|0,b=b+Math.imul(K,yt)|0,_=_+Math.imul(fe,mt)|0,c=c+Math.imul(fe,vt)|0,c=c+Math.imul(O,mt)|0,b=b+Math.imul(O,vt)|0,_=_+Math.imul(te,bt)|0,c=c+Math.imul(te,_t)|0,c=c+Math.imul(X,bt)|0,b=b+Math.imul(X,_t)|0,_=_+Math.imul(L,St)|0,c=c+Math.imul(L,wt)|0,c=c+Math.imul(H,St)|0,b=b+Math.imul(H,wt)|0;var Zc=(A+_|0)+((c&8191)<<13)|0;A=(b+(c>>>13)|0)+(Zc>>>26)|0,Zc&=67108863,_=Math.imul(Ze,at),c=Math.imul(Ze,ut),c=c+Math.imul(Ve,at)|0,b=Math.imul(Ve,ut),_=_+Math.imul(be,ft)|0,c=c+Math.imul(be,ct)|0,c=c+Math.imul(Ee,ft)|0,b=b+Math.imul(Ee,ct)|0,_=_+Math.imul(oe,lt)|0,c=c+Math.imul(oe,ht)|0,c=c+Math.imul(Pe,lt)|0,b=b+Math.imul(Pe,ht)|0,_=_+Math.imul(ce,dt)|0,c=c+Math.imul(ce,pt)|0,c=c+Math.imul(ae,dt)|0,b=b+Math.imul(ae,pt)|0,_=_+Math.imul(J,gt)|0,c=c+Math.imul(J,yt)|0,c=c+Math.imul(Q,gt)|0,b=b+Math.imul(Q,yt)|0,_=_+Math.imul(D,mt)|0,c=c+Math.imul(D,vt)|0,c=c+Math.imul(K,mt)|0,b=b+Math.imul(K,vt)|0,_=_+Math.imul(fe,bt)|0,c=c+Math.imul(fe,_t)|0,c=c+Math.imul(O,bt)|0,b=b+Math.imul(O,_t)|0,_=_+Math.imul(te,St)|0,c=c+Math.imul(te,wt)|0,c=c+Math.imul(X,St)|0,b=b+Math.imul(X,wt)|0,_=_+Math.imul(L,Et)|0,c=c+Math.imul(L,xt)|0,c=c+Math.imul(H,Et)|0,b=b+Math.imul(H,xt)|0;var Xc=(A+_|0)+((c&8191)<<13)|0;A=(b+(c>>>13)|0)+(Xc>>>26)|0,Xc&=67108863,_=Math.imul(Je,at),c=Math.imul(Je,ut),c=c+Math.imul(st,at)|0,b=Math.imul(st,ut),_=_+Math.imul(Ze,ft)|0,c=c+Math.imul(Ze,ct)|0,c=c+Math.imul(Ve,ft)|0,b=b+Math.imul(Ve,ct)|0,_=_+Math.imul(be,lt)|0,c=c+Math.imul(be,ht)|0,c=c+Math.imul(Ee,lt)|0,b=b+Math.imul(Ee,ht)|0,_=_+Math.imul(oe,dt)|0,c=c+Math.imul(oe,pt)|0,c=c+Math.imul(Pe,dt)|0,b=b+Math.imul(Pe,pt)|0,_=_+Math.imul(ce,gt)|0,c=c+Math.imul(ce,yt)|0,c=c+Math.imul(ae,gt)|0,b=b+Math.imul(ae,yt)|0,_=_+Math.imul(J,mt)|0,c=c+Math.imul(J,vt)|0,c=c+Math.imul(Q,mt)|0,b=b+Math.imul(Q,vt)|0,_=_+Math.imul(D,bt)|0,c=c+Math.imul(D,_t)|0,c=c+Math.imul(K,bt)|0,b=b+Math.imul(K,_t)|0,_=_+Math.imul(fe,St)|0,c=c+Math.imul(fe,wt)|0,c=c+Math.imul(O,St)|0,b=b+Math.imul(O,wt)|0,_=_+Math.imul(te,Et)|0,c=c+Math.imul(te,xt)|0,c=c+Math.imul(X,Et)|0,b=b+Math.imul(X,xt)|0,_=_+Math.imul(L,It)|0,c=c+Math.imul(L,At)|0,c=c+Math.imul(H,It)|0,b=b+Math.imul(H,At)|0;var Jc=(A+_|0)+((c&8191)<<13)|0;A=(b+(c>>>13)|0)+(Jc>>>26)|0,Jc&=67108863,_=Math.imul(Je,ft),c=Math.imul(Je,ct),c=c+Math.imul(st,ft)|0,b=Math.imul(st,ct),_=_+Math.imul(Ze,lt)|0,c=c+Math.imul(Ze,ht)|0,c=c+Math.imul(Ve,lt)|0,b=b+Math.imul(Ve,ht)|0,_=_+Math.imul(be,dt)|0,c=c+Math.imul(be,pt)|0,c=c+Math.imul(Ee,dt)|0,b=b+Math.imul(Ee,pt)|0,_=_+Math.imul(oe,gt)|0,c=c+Math.imul(oe,yt)|0,c=c+Math.imul(Pe,gt)|0,b=b+Math.imul(Pe,yt)|0,_=_+Math.imul(ce,mt)|0,c=c+Math.imul(ce,vt)|0,c=c+Math.imul(ae,mt)|0,b=b+Math.imul(ae,vt)|0,_=_+Math.imul(J,bt)|0,c=c+Math.imul(J,_t)|0,c=c+Math.imul(Q,bt)|0,b=b+Math.imul(Q,_t)|0,_=_+Math.imul(D,St)|0,c=c+Math.imul(D,wt)|0,c=c+Math.imul(K,St)|0,b=b+Math.imul(K,wt)|0,_=_+Math.imul(fe,Et)|0,c=c+Math.imul(fe,xt)|0,c=c+Math.imul(O,Et)|0,b=b+Math.imul(O,xt)|0,_=_+Math.imul(te,It)|0,c=c+Math.imul(te,At)|0,c=c+Math.imul(X,It)|0,b=b+Math.imul(X,At)|0;var Qc=(A+_|0)+((c&8191)<<13)|0;A=(b+(c>>>13)|0)+(Qc>>>26)|0,Qc&=67108863,_=Math.imul(Je,lt),c=Math.imul(Je,ht),c=c+Math.imul(st,lt)|0,b=Math.imul(st,ht),_=_+Math.imul(Ze,dt)|0,c=c+Math.imul(Ze,pt)|0,c=c+Math.imul(Ve,dt)|0,b=b+Math.imul(Ve,pt)|0,_=_+Math.imul(be,gt)|0,c=c+Math.imul(be,yt)|0,c=c+Math.imul(Ee,gt)|0,b=b+Math.imul(Ee,yt)|0,_=_+Math.imul(oe,mt)|0,c=c+Math.imul(oe,vt)|0,c=c+Math.imul(Pe,mt)|0,b=b+Math.imul(Pe,vt)|0,_=_+Math.imul(ce,bt)|0,c=c+Math.imul(ce,_t)|0,c=c+Math.imul(ae,bt)|0,b=b+Math.imul(ae,_t)|0,_=_+Math.imul(J,St)|0,c=c+Math.imul(J,wt)|0,c=c+Math.imul(Q,St)|0,b=b+Math.imul(Q,wt)|0,_=_+Math.imul(D,Et)|0,c=c+Math.imul(D,xt)|0,c=c+Math.imul(K,Et)|0,b=b+Math.imul(K,xt)|0,_=_+Math.imul(fe,It)|0,c=c+Math.imul(fe,At)|0,c=c+Math.imul(O,It)|0,b=b+Math.imul(O,At)|0;var el=(A+_|0)+((c&8191)<<13)|0;A=(b+(c>>>13)|0)+(el>>>26)|0,el&=67108863,_=Math.imul(Je,dt),c=Math.imul(Je,pt),c=c+Math.imul(st,dt)|0,b=Math.imul(st,pt),_=_+Math.imul(Ze,gt)|0,c=c+Math.imul(Ze,yt)|0,c=c+Math.imul(Ve,gt)|0,b=b+Math.imul(Ve,yt)|0,_=_+Math.imul(be,mt)|0,c=c+Math.imul(be,vt)|0,c=c+Math.imul(Ee,mt)|0,b=b+Math.imul(Ee,vt)|0,_=_+Math.imul(oe,bt)|0,c=c+Math.imul(oe,_t)|0,c=c+Math.imul(Pe,bt)|0,b=b+Math.imul(Pe,_t)|0,_=_+Math.imul(ce,St)|0,c=c+Math.imul(ce,wt)|0,c=c+Math.imul(ae,St)|0,b=b+Math.imul(ae,wt)|0,_=_+Math.imul(J,Et)|0,c=c+Math.imul(J,xt)|0,c=c+Math.imul(Q,Et)|0,b=b+Math.imul(Q,xt)|0,_=_+Math.imul(D,It)|0,c=c+Math.imul(D,At)|0,c=c+Math.imul(K,It)|0,b=b+Math.imul(K,At)|0;var tl=(A+_|0)+((c&8191)<<13)|0;A=(b+(c>>>13)|0)+(tl>>>26)|0,tl&=67108863,_=Math.imul(Je,gt),c=Math.imul(Je,yt),c=c+Math.imul(st,gt)|0,b=Math.imul(st,yt),_=_+Math.imul(Ze,mt)|0,c=c+Math.imul(Ze,vt)|0,c=c+Math.imul(Ve,mt)|0,b=b+Math.imul(Ve,vt)|0,_=_+Math.imul(be,bt)|0,c=c+Math.imul(be,_t)|0,c=c+Math.imul(Ee,bt)|0,b=b+Math.imul(Ee,_t)|0,_=_+Math.imul(oe,St)|0,c=c+Math.imul(oe,wt)|0,c=c+Math.imul(Pe,St)|0,b=b+Math.imul(Pe,wt)|0,_=_+Math.imul(ce,Et)|0,c=c+Math.imul(ce,xt)|0,c=c+Math.imul(ae,Et)|0,b=b+Math.imul(ae,xt)|0,_=_+Math.imul(J,It)|0,c=c+Math.imul(J,At)|0,c=c+Math.imul(Q,It)|0,b=b+Math.imul(Q,At)|0;var rl=(A+_|0)+((c&8191)<<13)|0;A=(b+(c>>>13)|0)+(rl>>>26)|0,rl&=67108863,_=Math.imul(Je,mt),c=Math.imul(Je,vt),c=c+Math.imul(st,mt)|0,b=Math.imul(st,vt),_=_+Math.imul(Ze,bt)|0,c=c+Math.imul(Ze,_t)|0,c=c+Math.imul(Ve,bt)|0,b=b+Math.imul(Ve,_t)|0,_=_+Math.imul(be,St)|0,c=c+Math.imul(be,wt)|0,c=c+Math.imul(Ee,St)|0,b=b+Math.imul(Ee,wt)|0,_=_+Math.imul(oe,Et)|0,c=c+Math.imul(oe,xt)|0,c=c+Math.imul(Pe,Et)|0,b=b+Math.imul(Pe,xt)|0,_=_+Math.imul(ce,It)|0,c=c+Math.imul(ce,At)|0,c=c+Math.imul(ae,It)|0,b=b+Math.imul(ae,At)|0;var nl=(A+_|0)+((c&8191)<<13)|0;A=(b+(c>>>13)|0)+(nl>>>26)|0,nl&=67108863,_=Math.imul(Je,bt),c=Math.imul(Je,_t),c=c+Math.imul(st,bt)|0,b=Math.imul(st,_t),_=_+Math.imul(Ze,St)|0,c=c+Math.imul(Ze,wt)|0,c=c+Math.imul(Ve,St)|0,b=b+Math.imul(Ve,wt)|0,_=_+Math.imul(be,Et)|0,c=c+Math.imul(be,xt)|0,c=c+Math.imul(Ee,Et)|0,b=b+Math.imul(Ee,xt)|0,_=_+Math.imul(oe,It)|0,c=c+Math.imul(oe,At)|0,c=c+Math.imul(Pe,It)|0,b=b+Math.imul(Pe,At)|0;var il=(A+_|0)+((c&8191)<<13)|0;A=(b+(c>>>13)|0)+(il>>>26)|0,il&=67108863,_=Math.imul(Je,St),c=Math.imul(Je,wt),c=c+Math.imul(st,St)|0,b=Math.imul(st,wt),_=_+Math.imul(Ze,Et)|0,c=c+Math.imul(Ze,xt)|0,c=c+Math.imul(Ve,Et)|0,b=b+Math.imul(Ve,xt)|0,_=_+Math.imul(be,It)|0,c=c+Math.imul(be,At)|0,c=c+Math.imul(Ee,It)|0,b=b+Math.imul(Ee,At)|0;var ol=(A+_|0)+((c&8191)<<13)|0;A=(b+(c>>>13)|0)+(ol>>>26)|0,ol&=67108863,_=Math.imul(Je,Et),c=Math.imul(Je,xt),c=c+Math.imul(st,Et)|0,b=Math.imul(st,xt),_=_+Math.imul(Ze,It)|0,c=c+Math.imul(Ze,At)|0,c=c+Math.imul(Ve,It)|0,b=b+Math.imul(Ve,At)|0;var sl=(A+_|0)+((c&8191)<<13)|0;A=(b+(c>>>13)|0)+(sl>>>26)|0,sl&=67108863,_=Math.imul(Je,It),c=Math.imul(Je,At),c=c+Math.imul(st,It)|0,b=Math.imul(st,At);var al=(A+_|0)+((c&8191)<<13)|0;return A=(b+(c>>>13)|0)+(al>>>26)|0,al&=67108863,R[0]=Kc,R[1]=Gc,R[2]=Vc,R[3]=Wc,R[4]=zc,R[5]=Yc,R[6]=$c,R[7]=Zc,R[8]=Xc,R[9]=Jc,R[10]=Qc,R[11]=el,R[12]=tl,R[13]=rl,R[14]=nl,R[15]=il,R[16]=ol,R[17]=sl,R[18]=al,A!==0&&(R[19]=A,m.length++),m};Math.imul||(T=E);function M(I,u,h){h.negative=u.negative^I.negative,h.length=I.length+u.length;for(var m=0,S=0,w=0;w<h.length-1;w++){var R=S;S=0;for(var A=m&67108863,_=Math.min(w,u.length-1),c=Math.max(0,w-I.length+1);c<=_;c++){var b=w-c,k=I.words[b]|0,L=u.words[c]|0,H=k*L,W=H&67108863;R=R+(H/67108864|0)|0,W=W+A|0,A=W&67108863,R=R+(W>>>26)|0,S+=R>>>26,R&=67108863}h.words[w]=A,m=R,R=S}return m!==0?h.words[w]=m:h.length--,h.strip()}function U(I,u,h){var m=new F;return m.mulp(I,u,h)}i.prototype.mulTo=function(u,h){var m,S=this.length+u.length;return this.length===10&&u.length===10?m=T(this,u,h):S<63?m=E(this,u,h):S<1024?m=M(this,u,h):m=U(this,u,h),m};function F(I,u){this.x=I,this.y=u}F.prototype.makeRBT=function(u){for(var h=new Array(u),m=i.prototype._countBits(u)-1,S=0;S<u;S++)h[S]=this.revBin(S,m,u);return h},F.prototype.revBin=function(u,h,m){if(u===0||u===m-1)return u;for(var S=0,w=0;w<h;w++)S|=(u&1)<<h-w-1,u>>=1;return S},F.prototype.permute=function(u,h,m,S,w,R){for(var A=0;A<R;A++)S[A]=h[u[A]],w[A]=m[u[A]]},F.prototype.transform=function(u,h,m,S,w,R){this.permute(R,u,h,m,S,w);for(var A=1;A<w;A<<=1)for(var _=A<<1,c=Math.cos(2*Math.PI/_),b=Math.sin(2*Math.PI/_),k=0;k<w;k+=_)for(var L=c,H=b,W=0;W<A;W++){var te=m[k+W],X=S[k+W],ue=m[k+W+A],fe=S[k+W+A],O=L*ue-H*fe;fe=L*fe+H*ue,ue=O,m[k+W]=te+ue,S[k+W]=X+fe,m[k+W+A]=te-ue,S[k+W+A]=X-fe,W!==_&&(O=c*L-b*H,H=c*H+b*L,L=O)}},F.prototype.guessLen13b=function(u,h){var m=Math.max(h,u)|1,S=m&1,w=0;for(m=m/2|0;m;m=m>>>1)w++;return 1<<w+1+S},F.prototype.conjugate=function(u,h,m){if(!(m<=1))for(var S=0;S<m/2;S++){var w=u[S];u[S]=u[m-S-1],u[m-S-1]=w,w=h[S],h[S]=-h[m-S-1],h[m-S-1]=-w}},F.prototype.normalize13b=function(u,h){for(var m=0,S=0;S<h/2;S++){var w=Math.round(u[2*S+1]/h)*8192+Math.round(u[2*S]/h)+m;u[S]=w&67108863,w<67108864?m=0:m=w/67108864|0}return u},F.prototype.convert13b=function(u,h,m,S){for(var w=0,R=0;R<h;R++)w=w+(u[R]|0),m[2*R]=w&8191,w=w>>>13,m[2*R+1]=w&8191,w=w>>>13;for(R=2*h;R<S;++R)m[R]=0;r(w===0),r((w&-8192)===0)},F.prototype.stub=function(u){for(var h=new Array(u),m=0;m<u;m++)h[m]=0;return h},F.prototype.mulp=function(u,h,m){var S=2*this.guessLen13b(u.length,h.length),w=this.makeRBT(S),R=this.stub(S),A=new Array(S),_=new Array(S),c=new Array(S),b=new Array(S),k=new Array(S),L=new Array(S),H=m.words;H.length=S,this.convert13b(u.words,u.length,A,S),this.convert13b(h.words,h.length,b,S),this.transform(A,R,_,c,S,w),this.transform(b,R,k,L,S,w);for(var W=0;W<S;W++){var te=_[W]*k[W]-c[W]*L[W];c[W]=_[W]*L[W]+c[W]*k[W],_[W]=te}return this.conjugate(_,c,S),this.transform(_,c,H,R,S,w),this.conjugate(H,R,S),this.normalize13b(H,S),m.negative=u.negative^h.negative,m.length=u.length+h.length,m.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),U(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,m=0;m<this.length;m++){var S=(this.words[m]|0)*u,w=(S&67108863)+(h&67108863);h>>=26,h+=S/67108864|0,h+=w>>>26,this.words[m]=w&67108863}return h!==0&&(this.words[m]=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=v(u);if(h.length===0)return new i(1);for(var m=this,S=0;S<h.length&&h[S]===0;S++,m=m.sqr());if(++S<h.length)for(var w=m.sqr();S<h.length;S++,w=w.sqr())h[S]!==0&&(m=m.mul(w));return m},i.prototype.iushln=function(u){r(typeof u=="number"&&u>=0);var h=u%26,m=(u-h)/26,S=67108863>>>26-h<<26-h,w;if(h!==0){var R=0;for(w=0;w<this.length;w++){var A=this.words[w]&S,_=(this.words[w]|0)-A<<h;this.words[w]=_|R,R=A>>>26-h}R&&(this.words[w]=R,this.length++)}if(m!==0){for(w=this.length-1;w>=0;w--)this.words[w+m]=this.words[w];for(w=0;w<m;w++)this.words[w]=0;this.length+=m}return this.strip()},i.prototype.ishln=function(u){return r(this.negative===0),this.iushln(u)},i.prototype.iushrn=function(u,h,m){r(typeof u=="number"&&u>=0);var S;h?S=(h-h%26)/26:S=0;var w=u%26,R=Math.min((u-w)/26,this.length),A=67108863^67108863>>>w<<w,_=m;if(S-=R,S=Math.max(0,S),_){for(var c=0;c<R;c++)_.words[c]=this.words[c];_.length=R}if(R!==0)if(this.length>R)for(this.length-=R,c=0;c<this.length;c++)this.words[c]=this.words[c+R];else this.words[0]=0,this.length=1;var b=0;for(c=this.length-1;c>=0&&(b!==0||c>=S);c--){var k=this.words[c]|0;this.words[c]=b<<26-w|k>>>w,b=k&A}return _&&b!==0&&(_.words[_.length++]=b),this.length===0&&(this.words[0]=0,this.length=1),this.strip()},i.prototype.ishrn=function(u,h,m){return r(this.negative===0),this.iushrn(u,h,m)},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,m=(u-h)/26,S=1<<h;if(this.length<=m)return!1;var w=this.words[m];return!!(w&S)},i.prototype.imaskn=function(u){r(typeof u=="number"&&u>=0);var h=u%26,m=(u-h)/26;if(r(this.negative===0,"imaskn works only with positive numbers"),this.length<=m)return this;if(h!==0&&m++,this.length=Math.min(m,this.length),h!==0){var S=67108863^67108863>>>h<<h;this.words[this.length-1]&=S}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,m){var S=u.length+m,w;this._expand(S);var R,A=0;for(w=0;w<u.length;w++){R=(this.words[w+m]|0)+A;var _=(u.words[w]|0)*h;R-=_&67108863,A=(R>>26)-(_/67108864|0),this.words[w+m]=R&67108863}for(;w<this.length-m;w++)R=(this.words[w+m]|0)+A,A=R>>26,this.words[w+m]=R&67108863;if(A===0)return this.strip();for(r(A===-1),A=0,w=0;w<this.length;w++)R=-(this.words[w]|0)+A,A=R>>26,this.words[w]=R&67108863;return this.negative=1,this.strip()},i.prototype._wordDiv=function(u,h){var m=this.length-u.length,S=this.clone(),w=u,R=w.words[w.length-1]|0,A=this._countBits(R);m=26-A,m!==0&&(w=w.ushln(m),S.iushln(m),R=w.words[w.length-1]|0);var _=S.length-w.length,c;if(h!=="mod"){c=new i(null),c.length=_+1,c.words=new Array(c.length);for(var b=0;b<c.length;b++)c.words[b]=0}var k=S.clone()._ishlnsubmul(w,1,_);k.negative===0&&(S=k,c&&(c.words[_]=1));for(var L=_-1;L>=0;L--){var H=(S.words[w.length+L]|0)*67108864+(S.words[w.length+L-1]|0);for(H=Math.min(H/R|0,67108863),S._ishlnsubmul(w,H,L);S.negative!==0;)H--,S.negative=0,S._ishlnsubmul(w,1,L),S.isZero()||(S.negative^=1);c&&(c.words[L]=H)}return c&&c.strip(),S.strip(),h!=="div"&&m!==0&&S.iushrn(m),{div:c||null,mod:S}},i.prototype.divmod=function(u,h,m){if(r(!u.isZero()),this.isZero())return{div:new i(0),mod:new i(0)};var S,w,R;return this.negative!==0&&u.negative===0?(R=this.neg().divmod(u,h),h!=="mod"&&(S=R.div.neg()),h!=="div"&&(w=R.mod.neg(),m&&w.negative!==0&&w.iadd(u)),{div:S,mod:w}):this.negative===0&&u.negative!==0?(R=this.divmod(u.neg(),h),h!=="mod"&&(S=R.div.neg()),{div:S,mod:R.mod}):(this.negative&u.negative)!==0?(R=this.neg().divmod(u.neg(),h),h!=="div"&&(w=R.mod.neg(),m&&w.negative!==0&&w.isub(u)),{div:R.div,mod:w}):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 m=h.mod.abs(),S=u.abs().iushrn(1),w=u.words[0]&1,R=m.cmp(S);if(R<0||w===1&&R===0)return h.div;var A=new i(1);return A.negative=this.negative^u.negative,h.div.iadd(A)},i.prototype.modn=function(u){r(u<=67108863);for(var h=(1<<26)%u,m=0,S=this.length-1;S>=0;S--)m=(h*m+(this.words[S]|0))%u;return m},i.prototype.idivn=function(u){r(u<=67108863);for(var h=0,m=this.length-1;m>=0;m--){var S=(this.words[m]|0)+h*67108864;this.words[m]=S/u|0,h=S%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,m=u.clone();h.negative!==0?h=h.umod(u):h=h.clone();for(var S=new i(1),w=new i(0),R=new i(0),A=new i(1),_=0;h.isEven()&&m.isEven();)h.iushrn(1),m.iushrn(1),++_;for(var c=m.clone(),b=h.clone();!h.isZero();){for(var k=0,L=1;(h.words[0]&L)===0&&k<26;++k,L<<=1);if(k>0)for(h.iushrn(k);k-- >0;)(S.isOdd()||w.isOdd())&&(S.iadd(c),w.isub(b)),S.iushrn(1),w.iushrn(1);for(var H=0,W=1;(m.words[0]&W)===0&&H<26;++H,W<<=1);if(H>0)for(m.iushrn(H);H-- >0;)(R.isOdd()||A.isOdd())&&(R.iadd(c),A.isub(b)),R.iushrn(1),A.iushrn(1);h.cmp(m)>=0?(h.isub(m),S.isub(R),w.isub(A)):(m.isub(h),R.isub(S),A.isub(w))}return{a:R,b:A,gcd:m.iushln(_)}},i.prototype._invmp=function(u){r(u.negative===0),r(!u.isZero());var h=this,m=u.clone();h.negative!==0?h=h.umod(u):h=h.clone();for(var S=new i(1),w=new i(0),R=m.clone();h.cmpn(1)>0&&m.cmpn(1)>0;){for(var A=0,_=1;(h.words[0]&_)===0&&A<26;++A,_<<=1);if(A>0)for(h.iushrn(A);A-- >0;)S.isOdd()&&S.iadd(R),S.iushrn(1);for(var c=0,b=1;(m.words[0]&b)===0&&c<26;++c,b<<=1);if(c>0)for(m.iushrn(c);c-- >0;)w.isOdd()&&w.iadd(R),w.iushrn(1);h.cmp(m)>=0?(h.isub(m),S.isub(w)):(m.isub(h),w.isub(S))}var k;return h.cmpn(1)===0?k=S:k=w,k.cmpn(0)<0&&k.iadd(u),k},i.prototype.gcd=function(u){if(this.isZero())return u.abs();if(u.isZero())return this.abs();var h=this.clone(),m=u.clone();h.negative=0,m.negative=0;for(var S=0;h.isEven()&&m.isEven();S++)h.iushrn(1),m.iushrn(1);do{for(;h.isEven();)h.iushrn(1);for(;m.isEven();)m.iushrn(1);var w=h.cmp(m);if(w<0){var R=h;h=m,m=R}else if(w===0||m.cmpn(1)===0)break;h.isub(m)}while(!0);return m.iushln(S)},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,m=(u-h)/26,S=1<<h;if(this.length<=m)return this._expand(m+1),this.words[m]|=S,this;for(var w=S,R=m;w!==0&&R<this.length;R++){var A=this.words[R]|0;A+=w,w=A>>>26,A&=67108863,this.words[R]=A}return w!==0&&(this.words[R]=w,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 m;if(this.length>1)m=1;else{h&&(u=-u),r(u<=67108863,"Number is too big");var S=this.words[0]|0;m=S===u?0:S<u?-1:1}return this.negative!==0?-m|0:m},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,m=this.length-1;m>=0;m--){var S=this.words[m]|0,w=u.words[m]|0;if(S!==w){S<w?h=-1:S>w&&(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 le(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(I,u){this.name=I,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,m;do this.split(h,this.tmp),h=this.imulK(h),h=h.iadd(this.tmp),m=h.bitLength();while(m>this.n);var S=m<this.n?-1:h.ucmp(this.p);return S===0?(h.words[0]=0,h.length=1):S>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 G(){z.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}n(G,z),G.prototype.split=function(u,h){for(var m=4194303,S=Math.min(u.length,9),w=0;w<S;w++)h.words[w]=u.words[w];if(h.length=S,u.length<=9){u.words[0]=0,u.length=1;return}var R=u.words[9];for(h.words[h.length++]=R&m,w=10;w<u.length;w++){var A=u.words[w]|0;u.words[w-10]=(A&m)<<4|R>>>22,R=A}R>>>=22,u.words[w-10]=R,R===0&&u.length>10?u.length-=10:u.length-=9},G.prototype.imulK=function(u){u.words[u.length]=0,u.words[u.length+1]=0,u.length+=2;for(var h=0,m=0;m<u.length;m++){var S=u.words[m]|0;h+=S*977,u.words[m]=h&67108863,h=S*64+(h/67108864|0)}return u.words[u.length-1]===0&&(u.length--,u.words[u.length-1]===0&&u.length--),u};function ie(){z.call(this,"p224","ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001")}n(ie,z);function ee(){z.call(this,"p192","ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff")}n(ee,z);function pe(){z.call(this,"25519","7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed")}n(pe,z),pe.prototype.imulK=function(u){for(var h=0,m=0;m<u.length;m++){var S=(u.words[m]|0)*19+h,w=S&67108863;S>>>=26,u.words[m]=w,h=S}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 G;else if(u==="p224")h=new ie;else if(u==="p192")h=new ee;else if(u==="p25519")h=new pe;else throw new Error("Unknown prime "+u);return V[u]=h,h};function le(I){if(typeof I=="string"){var u=i._prime(I);this.m=u.p,this.prime=u}else r(I.gtn(1),"modulus must be greater than 1"),this.m=I,this.prime=null}le.prototype._verify1=function(u){r(u.negative===0,"red works only with positives"),r(u.red,"red works only with red numbers")},le.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")},le.prototype.imod=function(u){return this.prime?this.prime.ireduce(u)._forceRed(this):u.umod(this.m)._forceRed(this)},le.prototype.neg=function(u){return u.isZero()?u.clone():this.m.sub(u)._forceRed(this)},le.prototype.add=function(u,h){this._verify2(u,h);var m=u.add(h);return m.cmp(this.m)>=0&&m.isub(this.m),m._forceRed(this)},le.prototype.iadd=function(u,h){this._verify2(u,h);var m=u.iadd(h);return m.cmp(this.m)>=0&&m.isub(this.m),m},le.prototype.sub=function(u,h){this._verify2(u,h);var m=u.sub(h);return m.cmpn(0)<0&&m.iadd(this.m),m._forceRed(this)},le.prototype.isub=function(u,h){this._verify2(u,h);var m=u.isub(h);return m.cmpn(0)<0&&m.iadd(this.m),m},le.prototype.shl=function(u,h){return this._verify1(u),this.imod(u.ushln(h))},le.prototype.imul=function(u,h){return this._verify2(u,h),this.imod(u.imul(h))},le.prototype.mul=function(u,h){return this._verify2(u,h),this.imod(u.mul(h))},le.prototype.isqr=function(u){return this.imul(u,u.clone())},le.prototype.sqr=function(u){return this.mul(u,u)},le.prototype.sqrt=function(u){if(u.isZero())return u.clone();var h=this.m.andln(3);if(r(h%2===1),h===3){var m=this.m.add(new i(1)).iushrn(2);return this.pow(u,m)}for(var S=this.m.subn(1),w=0;!S.isZero()&&S.andln(1)===0;)w++,S.iushrn(1);r(!S.isZero());var R=new i(1).toRed(this),A=R.redNeg(),_=this.m.subn(1).iushrn(1),c=this.m.bitLength();for(c=new i(2*c*c).toRed(this);this.pow(c,_).cmp(A)!==0;)c.redIAdd(A);for(var b=this.pow(c,S),k=this.pow(u,S.addn(1).iushrn(1)),L=this.pow(u,S),H=w;L.cmp(R)!==0;){for(var W=L,te=0;W.cmp(R)!==0;te++)W=W.redSqr();r(te<H);var X=this.pow(b,new i(1).iushln(H-te-1));k=k.redMul(X),b=X.redSqr(),L=L.redMul(b),H=te}return k},le.prototype.invm=function(u){var h=u._invmp(this.m);return h.negative!==0?(h.negative=0,this.imod(h).redNeg()):this.imod(h)},le.prototype.pow=function(u,h){if(h.isZero())return new i(1).toRed(this);if(h.cmpn(1)===0)return u.clone();var m=4,S=new Array(1<<m);S[0]=new i(1).toRed(this),S[1]=u;for(var w=2;w<S.length;w++)S[w]=this.mul(S[w-1],u);var R=S[0],A=0,_=0,c=h.bitLength()%26;for(c===0&&(c=26),w=h.length-1;w>=0;w--){for(var b=h.words[w],k=c-1;k>=0;k--){var L=b>>k&1;if(R!==S[0]&&(R=this.sqr(R)),L===0&&A===0){_=0;continue}A<<=1,A|=L,_++,!(_!==m&&(w!==0||k!==0))&&(R=this.mul(R,S[A]),_=0,A=0)}c=26}return R},le.prototype.convertTo=function(u){var h=u.umod(this.m);return h===u?h.clone():h},le.prototype.convertFrom=function(u){var h=u.clone();return h.red=null,h},i.mont=function(u){return new me(u)};function me(I){le.call(this,I),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(me,le),me.prototype.convertTo=function(u){return this.imod(u.ushln(this.shift))},me.prototype.convertFrom=function(u){var h=this.imod(u.mul(this.rinv));return h.red=null,h},me.prototype.imul=function(u,h){if(u.isZero()||h.isZero())return u.words[0]=0,u.length=1,u;var m=u.imul(h),S=m.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),w=m.isub(S).iushrn(this.shift),R=w;return w.cmp(this.m)>=0?R=w.isub(this.m):w.cmpn(0)<0&&(R=w.iadd(this.m)),R._forceRed(this)},me.prototype.mul=function(u,h){if(u.isZero()||h.isZero())return new i(0)._forceRed(this);var m=u.mul(h),S=m.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),w=m.isub(S).iushrn(this.shift),R=w;return w.cmp(this.m)>=0?R=w.isub(this.m):w.cmpn(0)<0&&(R=w.iadd(this.m)),R._forceRed(this)},me.prototype.invm=function(u){var h=this.imod(u._invmp(this.m).mul(this.r2));return h._forceRed(this)}})(typeof wl>"u"||wl,C0)});var Fe=B((ZC,El)=>{p();typeof Object.create=="function"?El.exports=function(t,r){r&&(t.super_=r,t.prototype=Object.create(r.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}))}:El.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 Gt=B((xl,U0)=>{p();var tu=Nt(),Zr=tu.Buffer;function D0(e,t){for(var r in e)t[r]=e[r]}Zr.from&&Zr.alloc&&Zr.allocUnsafe&&Zr.allocUnsafeSlow?U0.exports=tu:(D0(tu,xl),xl.Buffer=Ii);function Ii(e,t,r){return Zr(e,t,r)}Ii.prototype=Object.create(Zr.prototype);D0(Zr,Ii);Ii.from=function(e,t,r){if(typeof e=="number")throw new TypeError("Argument must not be a number");return Zr(e,t,r)};Ii.alloc=function(e,t,r){if(typeof e!="number")throw new TypeError("Argument must be a number");var n=Zr(e);return t!==void 0?typeof r=="string"?n.fill(t,r):n.fill(t):n.fill(0),n};Ii.allocUnsafe=function(e){if(typeof e!="number")throw new TypeError("Argument must be a number");return Zr(e)};Ii.allocUnsafeSlow=function(e){if(typeof e!="number")throw new TypeError("Argument must be a number");return tu.SlowBuffer(e)}});var go=B((QC,Il)=>{"use strict";p();var po=typeof Reflect=="object"?Reflect:null,F0=po&&typeof po.apply=="function"?po.apply:function(t,r,n){return Function.prototype.apply.call(t,r,n)},ru;po&&typeof po.ownKeys=="function"?ru=po.ownKeys:Object.getOwnPropertySymbols?ru=function(t){return Object.getOwnPropertyNames(t).concat(Object.getOwnPropertySymbols(t))}:ru=function(t){return Object.getOwnPropertyNames(t)};function tA(e){console&&console.warn&&console.warn(e)}var H0=Number.isNaN||function(t){return t!==t};function De(){De.init.call(this)}Il.exports=De;Il.exports.once=oA;De.EventEmitter=De;De.prototype._events=void 0;De.prototype._eventsCount=0;De.prototype._maxListeners=void 0;var q0=10;function nu(e){if(typeof e!="function")throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof e)}Object.defineProperty(De,"defaultMaxListeners",{enumerable:!0,get:function(){return q0},set:function(e){if(typeof e!="number"||e<0||H0(e))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+e+".");q0=e}});De.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};De.prototype.setMaxListeners=function(t){if(typeof t!="number"||t<0||H0(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 j0(e){return e._maxListeners===void 0?De.defaultMaxListeners:e._maxListeners}De.prototype.getMaxListeners=function(){return j0(this)};De.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 f=o[t];if(f===void 0)return!1;if(typeof f=="function")F0(f,this,r);else for(var l=f.length,y=z0(f,l),n=0;n<l;++n)F0(y[n],this,r);return!0};function K0(e,t,r,n){var i,o,s;if(nu(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=j0(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,tA(a)}return e}De.prototype.addListener=function(t,r){return K0(this,t,r,!1)};De.prototype.on=De.prototype.addListener;De.prototype.prependListener=function(t,r){return K0(this,t,r,!0)};function rA(){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 G0(e,t,r){var n={fired:!1,wrapFn:void 0,target:e,type:t,listener:r},i=rA.bind(n);return i.listener=r,n.wrapFn=i,i}De.prototype.once=function(t,r){return nu(r),this.on(t,G0(this,t,r)),this};De.prototype.prependOnceListener=function(t,r){return nu(r),this.prependListener(t,G0(this,t,r)),this};De.prototype.removeListener=function(t,r){var n,i,o,s,a;if(nu(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():nA(n,o),n.length===1&&(i[t]=n[0]),i.removeListener!==void 0&&this.emit("removeListener",t,a||r)}return this};De.prototype.off=De.prototype.removeListener;De.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 V0(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?iA(i):z0(i,i.length)}De.prototype.listeners=function(t){return V0(this,t,!0)};De.prototype.rawListeners=function(t){return V0(this,t,!1)};De.listenerCount=function(e,t){return typeof e.listenerCount=="function"?e.listenerCount(t):W0.call(e,t)};De.prototype.listenerCount=W0;function W0(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}De.prototype.eventNames=function(){return this._eventsCount>0?ru(this._events):[]};function z0(e,t){for(var r=new Array(t),n=0;n<t;++n)r[n]=e[n];return r}function nA(e,t){for(;t+1<e.length;t++)e[t]=e[t+1];e.pop()}function iA(e){for(var t=new Array(e.length),r=0;r<t.length;++r)t[r]=e[r].listener||e[r];return t}function oA(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))}Y0(e,t,o,{once:!0}),t!=="error"&&sA(e,i,{once:!0})})}function sA(e,t,r){typeof e.on=="function"&&Y0(e,"error",t,r)}function Y0(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 Al=B((tL,$0)=>{p();$0.exports=go().EventEmitter});var iu=B((nL,Z0)=>{"use strict";p();Z0.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 ys=B((oL,X0)=>{"use strict";p();var aA=iu();X0.exports=function(){return aA()&&!!Symbol.toStringTag}});var ou=B((aL,J0)=>{"use strict";p();J0.exports=Object});var eg=B((fL,Q0)=>{"use strict";p();Q0.exports=Error});var rg=B((lL,tg)=>{"use strict";p();tg.exports=EvalError});var ig=B((dL,ng)=>{"use strict";p();ng.exports=RangeError});var sg=B((gL,og)=>{"use strict";p();og.exports=ReferenceError});var Ol=B((mL,ag)=>{"use strict";p();ag.exports=SyntaxError});var Ai=B((bL,ug)=>{"use strict";p();ug.exports=TypeError});var cg=B((SL,fg)=>{"use strict";p();fg.exports=URIError});var hg=B((EL,lg)=>{"use strict";p();lg.exports=Math.abs});var pg=B((IL,dg)=>{"use strict";p();dg.exports=Math.floor});var yg=B((OL,gg)=>{"use strict";p();gg.exports=Math.max});var vg=B((TL,mg)=>{"use strict";p();mg.exports=Math.min});var _g=B((BL,bg)=>{"use strict";p();bg.exports=Math.pow});var wg=B((ML,Sg)=>{"use strict";p();Sg.exports=Math.round});var xg=B((CL,Eg)=>{"use strict";p();Eg.exports=Number.isNaN||function(t){return t!==t}});var Ag=B((DL,Ig)=>{"use strict";p();var uA=xg();Ig.exports=function(t){return uA(t)||t===0?t:t<0?-1:1}});var Rg=B((FL,Og)=>{"use strict";p();Og.exports=Object.getOwnPropertyDescriptor});var Oi=B((HL,Tg)=>{"use strict";p();var su=Rg();if(su)try{su([],"length")}catch{su=null}Tg.exports=su});var ms=B((KL,Pg)=>{"use strict";p();var au=Object.defineProperty||!1;if(au)try{au({},"a",{value:1})}catch{au=!1}Pg.exports=au});var Mg=B((VL,Ng)=>{"use strict";p();var Bg=typeof Symbol<"u"&&Symbol,fA=iu();Ng.exports=function(){return typeof Bg!="function"||typeof Symbol!="function"||typeof Bg("foo")!="symbol"||typeof Symbol("bar")!="symbol"?!1:fA()}});var Rl=B((zL,kg)=>{"use strict";p();kg.exports=typeof Reflect<"u"&&Reflect.getPrototypeOf||null});var Tl=B(($L,Cg)=>{"use strict";p();var cA=ou();Cg.exports=cA.getPrototypeOf||null});var Ug=B((XL,Dg)=>{"use strict";p();var lA="Function.prototype.bind called on incompatible ",hA=Object.prototype.toString,dA=Math.max,pA="[object Function]",Lg=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},gA=function(t,r){for(var n=[],i=r||0,o=0;i<t.length;i+=1,o+=1)n[o]=t[i];return n},yA=function(e,t){for(var r="",n=0;n<e.length;n+=1)r+=e[n],n+1<e.length&&(r+=t);return r};Dg.exports=function(t){var r=this;if(typeof r!="function"||hA.apply(r)!==pA)throw new TypeError(lA+r);for(var n=gA(arguments,1),i,o=function(){if(this instanceof i){var y=r.apply(this,Lg(n,arguments));return Object(y)===y?y:this}return r.apply(t,Lg(n,arguments))},s=dA(0,r.length-n.length),a=[],f=0;f<s;f++)a[f]="$"+f;if(i=Function("binder","return function ("+yA(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 yo=B((QL,Fg)=>{"use strict";p();var mA=Ug();Fg.exports=Function.prototype.bind||mA});var uu=B((t8,qg)=>{"use strict";p();qg.exports=Function.prototype.call});var fu=B((n8,Hg)=>{"use strict";p();Hg.exports=Function.prototype.apply});var Kg=B((o8,jg)=>{"use strict";p();jg.exports=typeof Reflect<"u"&&Reflect&&Reflect.apply});var Pl=B((a8,Gg)=>{"use strict";p();var vA=yo(),bA=fu(),_A=uu(),SA=Kg();Gg.exports=SA||vA.call(_A,bA)});var cu=B((f8,Vg)=>{"use strict";p();var wA=yo(),EA=Ai(),xA=uu(),IA=Pl();Vg.exports=function(t){if(t.length<1||typeof t[0]!="function")throw new EA("a function is required");return IA(wA,xA,t)}});var Xg=B((l8,Zg)=>{"use strict";p();var AA=cu(),Wg=Oi(),Yg;try{Yg=[].__proto__===Array.prototype}catch(e){if(!e||typeof e!="object"||!("code"in e)||e.code!=="ERR_PROTO_ACCESS")throw e}var Bl=!!Yg&&Wg&&Wg(Object.prototype,"__proto__"),$g=Object,zg=$g.getPrototypeOf;Zg.exports=Bl&&typeof Bl.get=="function"?AA([Bl.get]):typeof zg=="function"?function(t){return zg(t==null?t:$g(t))}:!1});var lu=B((d8,ty)=>{"use strict";p();var Jg=Rl(),Qg=Tl(),ey=Xg();ty.exports=Jg?function(t){return Jg(t)}:Qg?function(t){if(!t||typeof t!="object"&&typeof t!="function")throw new TypeError("getProto: not an object");return Qg(t)}:ey?function(t){return ey(t)}:null});var Nl=B((g8,ry)=>{"use strict";p();var OA=Function.prototype.call,RA=Object.prototype.hasOwnProperty,TA=yo();ry.exports=TA.call(OA,RA)});var pu=B((m8,uy)=>{"use strict";p();var xe,PA=ou(),BA=eg(),NA=rg(),MA=ig(),kA=sg(),_o=Ol(),bo=Ai(),CA=cg(),LA=hg(),DA=pg(),UA=yg(),FA=vg(),qA=_g(),HA=wg(),jA=Ag(),sy=Function,Ml=function(e){try{return sy('"use strict"; return ('+e+").constructor;")()}catch{}},vs=Oi(),KA=ms(),kl=function(){throw new bo},GA=vs?(function(){try{return arguments.callee,kl}catch{try{return vs(arguments,"callee").get}catch{return kl}}})():kl,mo=Mg()(),Ft=lu(),VA=Tl(),WA=Rl(),ay=fu(),bs=uu(),vo={},zA=typeof Uint8Array>"u"||!Ft?xe:Ft(Uint8Array),Ri={__proto__:null,"%AggregateError%":typeof AggregateError>"u"?xe:AggregateError,"%Array%":Array,"%ArrayBuffer%":typeof ArrayBuffer>"u"?xe:ArrayBuffer,"%ArrayIteratorPrototype%":mo&&Ft?Ft([][Symbol.iterator]()):xe,"%AsyncFromSyncIteratorPrototype%":xe,"%AsyncFunction%":vo,"%AsyncGenerator%":vo,"%AsyncGeneratorFunction%":vo,"%AsyncIteratorPrototype%":vo,"%Atomics%":typeof Atomics>"u"?xe:Atomics,"%BigInt%":typeof BigInt>"u"?xe:BigInt,"%BigInt64Array%":typeof BigInt64Array>"u"?xe:BigInt64Array,"%BigUint64Array%":typeof BigUint64Array>"u"?xe:BigUint64Array,"%Boolean%":Boolean,"%DataView%":typeof DataView>"u"?xe:DataView,"%Date%":Date,"%decodeURI%":decodeURI,"%decodeURIComponent%":decodeURIComponent,"%encodeURI%":encodeURI,"%encodeURIComponent%":encodeURIComponent,"%Error%":BA,"%eval%":eval,"%EvalError%":NA,"%Float16Array%":typeof Float16Array>"u"?xe:Float16Array,"%Float32Array%":typeof Float32Array>"u"?xe:Float32Array,"%Float64Array%":typeof Float64Array>"u"?xe:Float64Array,"%FinalizationRegistry%":typeof FinalizationRegistry>"u"?xe:FinalizationRegistry,"%Function%":sy,"%GeneratorFunction%":vo,"%Int8Array%":typeof Int8Array>"u"?xe:Int8Array,"%Int16Array%":typeof Int16Array>"u"?xe:Int16Array,"%Int32Array%":typeof Int32Array>"u"?xe:Int32Array,"%isFinite%":isFinite,"%isNaN%":isNaN,"%IteratorPrototype%":mo&&Ft?Ft(Ft([][Symbol.iterator]())):xe,"%JSON%":typeof JSON=="object"?JSON:xe,"%Map%":typeof Map>"u"?xe:Map,"%MapIteratorPrototype%":typeof Map>"u"||!mo||!Ft?xe:Ft(new Map()[Symbol.iterator]()),"%Math%":Math,"%Number%":Number,"%Object%":PA,"%Object.getOwnPropertyDescriptor%":vs,"%parseFloat%":parseFloat,"%parseInt%":parseInt,"%Promise%":typeof Promise>"u"?xe:Promise,"%Proxy%":typeof Proxy>"u"?xe:Proxy,"%RangeError%":MA,"%ReferenceError%":kA,"%Reflect%":typeof Reflect>"u"?xe:Reflect,"%RegExp%":RegExp,"%Set%":typeof Set>"u"?xe:Set,"%SetIteratorPrototype%":typeof Set>"u"||!mo||!Ft?xe:Ft(new Set()[Symbol.iterator]()),"%SharedArrayBuffer%":typeof SharedArrayBuffer>"u"?xe:SharedArrayBuffer,"%String%":String,"%StringIteratorPrototype%":mo&&Ft?Ft(""[Symbol.iterator]()):xe,"%Symbol%":mo?Symbol:xe,"%SyntaxError%":_o,"%ThrowTypeError%":GA,"%TypedArray%":zA,"%TypeError%":bo,"%Uint8Array%":typeof Uint8Array>"u"?xe:Uint8Array,"%Uint8ClampedArray%":typeof Uint8ClampedArray>"u"?xe:Uint8ClampedArray,"%Uint16Array%":typeof Uint16Array>"u"?xe:Uint16Array,"%Uint32Array%":typeof Uint32Array>"u"?xe:Uint32Array,"%URIError%":CA,"%WeakMap%":typeof WeakMap>"u"?xe:WeakMap,"%WeakRef%":typeof WeakRef>"u"?xe:WeakRef,"%WeakSet%":typeof WeakSet>"u"?xe:WeakSet,"%Function.prototype.call%":bs,"%Function.prototype.apply%":ay,"%Object.defineProperty%":KA,"%Object.getPrototypeOf%":VA,"%Math.abs%":LA,"%Math.floor%":DA,"%Math.max%":UA,"%Math.min%":FA,"%Math.pow%":qA,"%Math.round%":HA,"%Math.sign%":jA,"%Reflect.getPrototypeOf%":WA};if(Ft)try{null.error}catch(e){ny=Ft(Ft(e)),Ri["%Error.prototype%"]=ny}var ny,YA=function e(t){var r;if(t==="%AsyncFunction%")r=Ml("async function () {}");else if(t==="%GeneratorFunction%")r=Ml("function* () {}");else if(t==="%AsyncGeneratorFunction%")r=Ml("async function* () {}");else if(t==="%AsyncGenerator%"){var n=e("%AsyncGeneratorFunction%");n&&(r=n.prototype)}else if(t==="%AsyncIteratorPrototype%"){var i=e("%AsyncGenerator%");i&&Ft&&(r=Ft(i.prototype))}return Ri[t]=r,r},iy={__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"]},_s=yo(),hu=Nl(),$A=_s.call(bs,Array.prototype.concat),ZA=_s.call(ay,Array.prototype.splice),oy=_s.call(bs,String.prototype.replace),du=_s.call(bs,String.prototype.slice),XA=_s.call(bs,RegExp.prototype.exec),JA=/[^%.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|%$))/g,QA=/\\(\\)?/g,eO=function(t){var r=du(t,0,1),n=du(t,-1);if(r==="%"&&n!=="%")throw new _o("invalid intrinsic syntax, expected closing `%`");if(n==="%"&&r!=="%")throw new _o("invalid intrinsic syntax, expected opening `%`");var i=[];return oy(t,JA,function(o,s,a,f){i[i.length]=a?oy(f,QA,"$1"):s||o}),i},tO=function(t,r){var n=t,i;if(hu(iy,n)&&(i=iy[n],n="%"+i[0]+"%"),hu(Ri,n)){var o=Ri[n];if(o===vo&&(o=YA(n)),typeof o>"u"&&!r)throw new bo("intrinsic "+t+" exists, but is not available. Please file an issue!");return{alias:i,name:n,value:o}}throw new _o("intrinsic "+t+" does not exist!")};uy.exports=function(t,r){if(typeof t!="string"||t.length===0)throw new bo("intrinsic name must be a non-empty string");if(arguments.length>1&&typeof r!="boolean")throw new bo('"allowMissing" argument must be a boolean');if(XA(/^%?[^%]*%?$/,t)===null)throw new _o("`%` may not be present anywhere but at the beginning and end of the intrinsic name");var n=eO(t),i=n.length>0?n[0]:"",o=tO("%"+i+"%",r),s=o.name,a=o.value,f=!1,l=o.alias;l&&(i=l[0],ZA(n,$A([0,1],l)));for(var y=1,g=!0;y<n.length;y+=1){var v=n[y],E=du(v,0,1),T=du(v,-1);if((E==='"'||E==="'"||E==="`"||T==='"'||T==="'"||T==="`")&&E!==T)throw new _o("property names with quotes must have matching quotes");if((v==="constructor"||!g)&&(f=!0),i+="."+v,s="%"+i+"%",hu(Ri,s))a=Ri[s];else if(a!=null){if(!(v in a)){if(!r)throw new bo("base intrinsic for "+t+" exists, but the property is not available.");return}if(vs&&y+1>=n.length){var M=vs(a,v);g=!!M,g&&"get"in M&&!("originalValue"in M.get)?a=M.get:a=a[v]}else g=hu(a,v),a=a[v];g&&!f&&(Ri[s]=a)}}return a}});var Gn=B((b8,ly)=>{"use strict";p();var fy=pu(),cy=cu(),rO=cy([fy("%String.prototype.indexOf%")]);ly.exports=function(t,r){var n=fy(t,!!r);return typeof n=="function"&&rO(t,".prototype.")>-1?cy([n]):n}});var py=B((S8,dy)=>{"use strict";p();var nO=ys()(),iO=Gn(),Cl=iO("Object.prototype.toString"),gu=function(t){return nO&&t&&typeof t=="object"&&Symbol.toStringTag in t?!1:Cl(t)==="[object Arguments]"},hy=function(t){return gu(t)?!0:t!==null&&typeof t=="object"&&"length"in t&&typeof t.length=="number"&&t.length>=0&&Cl(t)!=="[object Array]"&&"callee"in t&&Cl(t.callee)==="[object Function]"},oO=(function(){return gu(arguments)})();gu.isLegacyArguments=hy;dy.exports=oO?gu:hy});var _y=B((E8,by)=>{"use strict";p();var gy=Gn(),sO=ys()(),aO=Nl(),uO=Oi(),Ul;sO?(yy=gy("RegExp.prototype.exec"),Ll={},yu=function(){throw Ll},Dl={toString:yu,valueOf:yu},typeof Symbol.toPrimitive=="symbol"&&(Dl[Symbol.toPrimitive]=yu),Ul=function(t){if(!t||typeof t!="object")return!1;var r=uO(t,"lastIndex"),n=r&&aO(r,"value");if(!n)return!1;try{yy(t,Dl)}catch(i){return i===Ll}}):(my=gy("Object.prototype.toString"),vy="[object RegExp]",Ul=function(t){return!t||typeof t!="object"&&typeof t!="function"?!1:my(t)===vy});var yy,Ll,yu,Dl,my,vy;by.exports=Ul});var wy=B((I8,Sy)=>{"use strict";p();var fO=Gn(),cO=_y(),lO=fO("RegExp.prototype.exec"),hO=Ai();Sy.exports=function(t){if(!cO(t))throw new hO("`regex` must be a RegExp");return function(n){return lO(t,n)!==null}}});var xy=B((O8,Ey)=>{"use strict";p();var dO=function*(){}.constructor;Ey.exports=()=>dO});var Ry=B((T8,Oy)=>{"use strict";p();var Ay=Gn(),pO=wy(),gO=pO(/^\s*(?:function)?\*/),yO=ys()(),Iy=lu(),mO=Ay("Object.prototype.toString"),vO=Ay("Function.prototype.toString"),bO=xy();Oy.exports=function(t){if(typeof t!="function")return!1;if(gO(vO(t)))return!0;if(!yO){var r=mO(t);return r==="[object GeneratorFunction]"}if(!Iy)return!1;var n=bO();return n&&Iy(t)===n.prototype}});var Ny=B((B8,By)=>{"use strict";p();var Py=Function.prototype.toString,So=typeof Reflect=="object"&&Reflect!==null&&Reflect.apply,ql,mu;if(typeof So=="function"&&typeof Object.defineProperty=="function")try{ql=Object.defineProperty({},"length",{get:function(){throw mu}}),mu={},So(function(){throw 42},null,ql)}catch(e){e!==mu&&(So=null)}else So=null;var _O=/^\s*class\b/,Hl=function(t){try{var r=Py.call(t);return _O.test(r)}catch{return!1}},Fl=function(t){try{return Hl(t)?!1:(Py.call(t),!0)}catch{return!1}},vu=Object.prototype.toString,SO="[object Object]",wO="[object Function]",EO="[object GeneratorFunction]",xO="[object HTMLAllCollection]",IO="[object HTML document.all class]",AO="[object HTMLCollection]",OO=typeof Symbol=="function"&&!!Symbol.toStringTag,RO=!(0 in[,]),jl=function(){return!1};typeof document=="object"&&(Ty=document.all,vu.call(Ty)===vu.call(document.all)&&(jl=function(t){if((RO||!t)&&(typeof t>"u"||typeof t=="object"))try{var r=vu.call(t);return(r===xO||r===IO||r===AO||r===SO)&&t("")==null}catch{}return!1}));var Ty;By.exports=So?function(t){if(jl(t))return!0;if(!t||typeof t!="function"&&typeof t!="object")return!1;try{So(t,null,ql)}catch(r){if(r!==mu)return!1}return!Hl(t)&&Fl(t)}:function(t){if(jl(t))return!0;if(!t||typeof t!="function"&&typeof t!="object")return!1;if(OO)return Fl(t);if(Hl(t))return!1;var r=vu.call(t);return r!==wO&&r!==EO&&!/^\[object HTML/.test(r)?!1:Fl(t)}});var Cy=B((M8,ky)=>{"use strict";p();var TO=Ny(),PO=Object.prototype.toString,My=Object.prototype.hasOwnProperty,BO=function(t,r,n){for(var i=0,o=t.length;i<o;i++)My.call(t,i)&&(n==null?r(t[i],i,t):r.call(n,t[i],i,t))},NO=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)},MO=function(t,r,n){for(var i in t)My.call(t,i)&&(n==null?r(t[i],i,t):r.call(n,t[i],i,t))};function kO(e){return PO.call(e)==="[object Array]"}ky.exports=function(t,r,n){if(!TO(r))throw new TypeError("iterator must be a function");var i;arguments.length>=3&&(i=n),kO(t)?BO(t,r,i):typeof t=="string"?NO(t,r,i):MO(t,r,i)}});var Dy=B((C8,Ly)=>{"use strict";p();Ly.exports=["Float16Array","Float32Array","Float64Array","Int8Array","Int16Array","Int32Array","Uint8Array","Uint8ClampedArray","Uint16Array","Uint32Array","BigInt64Array","BigUint64Array"]});var Fy=B((D8,Uy)=>{"use strict";p();var Kl=Dy(),CO=globalThis;Uy.exports=function(){for(var t=[],r=0;r<Kl.length;r++)typeof CO[Kl[r]]=="function"&&(t[t.length]=Kl[r]);return t}});var Gl=B((F8,jy)=>{"use strict";p();var qy=ms(),LO=Ol(),wo=Ai(),Hy=Oi();jy.exports=function(t,r,n){if(!t||typeof t!="object"&&typeof t!="function")throw new wo("`obj` must be an object or a function`");if(typeof r!="string"&&typeof r!="symbol")throw new wo("`property` must be a string or a symbol`");if(arguments.length>3&&typeof arguments[3]!="boolean"&&arguments[3]!==null)throw new wo("`nonEnumerable`, if provided, must be a boolean or null");if(arguments.length>4&&typeof arguments[4]!="boolean"&&arguments[4]!==null)throw new wo("`nonWritable`, if provided, must be a boolean or null");if(arguments.length>5&&typeof arguments[5]!="boolean"&&arguments[5]!==null)throw new wo("`nonConfigurable`, if provided, must be a boolean or null");if(arguments.length>6&&typeof arguments[6]!="boolean")throw new wo("`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,f=!!Hy&&Hy(t,r);if(qy)qy(t,r,{configurable:s===null&&f?f.configurable:!s,enumerable:i===null&&f?f.enumerable:!i,value:n,writable:o===null&&f?f.writable:!o});else if(a||!i&&!o&&!s)t[r]=n;else throw new LO("This environment does not support defining a property as non-configurable, non-writable, or non-enumerable.")}});var Wl=B((H8,Gy)=>{"use strict";p();var Vl=ms(),Ky=function(){return!!Vl};Ky.hasArrayLengthDefineBug=function(){if(!Vl)return null;try{return Vl([],"length",{value:1}).length!==1}catch{return!0}};Gy.exports=Ky});var $y=B((K8,Yy)=>{"use strict";p();var DO=pu(),Vy=Gl(),UO=Wl()(),Wy=Oi(),zy=Ai(),FO=DO("%Math.floor%");Yy.exports=function(t,r){if(typeof t!="function")throw new zy("`fn` is not a function");if(typeof r!="number"||r<0||r>4294967295||FO(r)!==r)throw new zy("`length` must be a positive 32-bit integer");var n=arguments.length>2&&!!arguments[2],i=!0,o=!0;if("length"in t&&Wy){var s=Wy(t,"length");s&&!s.configurable&&(i=!1),s&&!s.writable&&(o=!1)}return(i||o||!n)&&(UO?Vy(t,"length",r,!0,!0):Vy(t,"length",r)),t}});var Xy=B((V8,Zy)=>{"use strict";p();var qO=yo(),HO=fu(),jO=Pl();Zy.exports=function(){return jO(qO,HO,arguments)}});var Ss=B((z8,bu)=>{"use strict";p();var KO=$y(),Jy=ms(),GO=cu(),Qy=Xy();bu.exports=function(t){var r=GO(arguments),n=1+t.length-(arguments.length-1);return KO(r,n>0?n:0,!0)};Jy?Jy(bu.exports,"apply",{value:Qy}):bu.exports.apply=Qy});var Zl=B(($8,nm)=>{"use strict";p();var wu=Cy(),VO=Fy(),em=Ss(),Yl=Gn(),Su=Oi(),_u=lu(),WO=Yl("Object.prototype.toString"),rm=ys()(),tm=globalThis,zl=VO(),$l=Yl("String.prototype.slice"),zO=Yl("Array.prototype.indexOf",!0)||function(t,r){for(var n=0;n<t.length;n+=1)if(t[n]===r)return n;return-1},Eu={__proto__:null};rm&&Su&&_u?wu(zl,function(e){var t=new tm[e];if(Symbol.toStringTag in t&&_u){var r=_u(t),n=Su(r,Symbol.toStringTag);if(!n&&r){var i=_u(r);n=Su(i,Symbol.toStringTag)}if(n&&n.get){var o=em(n.get);Eu["$"+e]=o}}}):wu(zl,function(e){var t=new tm[e],r=t.slice||t.set;if(r){var n=em(r);Eu["$"+e]=n}});var YO=function(t){var r=!1;return wu(Eu,function(n,i){if(!r)try{"$"+n(t)===i&&(r=$l(i,1))}catch{}}),r},$O=function(t){var r=!1;return wu(Eu,function(n,i){if(!r)try{n(t),r=$l(i,1)}catch{}}),r};nm.exports=function(t){if(!t||typeof t!="object")return!1;if(!rm){var r=$l(WO(t),8,-1);return zO(zl,r)>-1?r:r!=="Object"?!1:$O(t)}return Su?YO(t):null}});var Xl=B((X8,im)=>{"use strict";p();var ZO=Zl();im.exports=function(t){return!!ZO(t)}});var vm=B(Ie=>{"use strict";p();var XO=py(),JO=Ry(),Tr=Zl(),om=Xl();function Eo(e){return e.call.bind(e)}var sm=typeof BigInt<"u",am=typeof Symbol<"u",br=Eo(Object.prototype.toString),QO=Eo(Number.prototype.valueOf),eR=Eo(String.prototype.valueOf),tR=Eo(Boolean.prototype.valueOf);sm&&(um=Eo(BigInt.prototype.valueOf));var um;am&&(fm=Eo(Symbol.prototype.valueOf));var fm;function Es(e,t){if(typeof e!="object")return!1;try{return t(e),!0}catch{return!1}}Ie.isArgumentsObject=XO;Ie.isGeneratorFunction=JO;Ie.isTypedArray=om;function rR(e){return typeof Promise<"u"&&e instanceof Promise||e!==null&&typeof e=="object"&&typeof e.then=="function"&&typeof e.catch=="function"}Ie.isPromise=rR;function nR(e){return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?ArrayBuffer.isView(e):om(e)||lm(e)}Ie.isArrayBufferView=nR;function iR(e){return Tr(e)==="Uint8Array"}Ie.isUint8Array=iR;function oR(e){return Tr(e)==="Uint8ClampedArray"}Ie.isUint8ClampedArray=oR;function sR(e){return Tr(e)==="Uint16Array"}Ie.isUint16Array=sR;function aR(e){return Tr(e)==="Uint32Array"}Ie.isUint32Array=aR;function uR(e){return Tr(e)==="Int8Array"}Ie.isInt8Array=uR;function fR(e){return Tr(e)==="Int16Array"}Ie.isInt16Array=fR;function cR(e){return Tr(e)==="Int32Array"}Ie.isInt32Array=cR;function lR(e){return Tr(e)==="Float32Array"}Ie.isFloat32Array=lR;function hR(e){return Tr(e)==="Float64Array"}Ie.isFloat64Array=hR;function dR(e){return Tr(e)==="BigInt64Array"}Ie.isBigInt64Array=dR;function pR(e){return Tr(e)==="BigUint64Array"}Ie.isBigUint64Array=pR;function xu(e){return br(e)==="[object Map]"}xu.working=typeof Map<"u"&&xu(new Map);function gR(e){return typeof Map>"u"?!1:xu.working?xu(e):e instanceof Map}Ie.isMap=gR;function Iu(e){return br(e)==="[object Set]"}Iu.working=typeof Set<"u"&&Iu(new Set);function yR(e){return typeof Set>"u"?!1:Iu.working?Iu(e):e instanceof Set}Ie.isSet=yR;function Au(e){return br(e)==="[object WeakMap]"}Au.working=typeof WeakMap<"u"&&Au(new WeakMap);function mR(e){return typeof WeakMap>"u"?!1:Au.working?Au(e):e instanceof WeakMap}Ie.isWeakMap=mR;function Ql(e){return br(e)==="[object WeakSet]"}Ql.working=typeof WeakSet<"u"&&Ql(new WeakSet);function vR(e){return Ql(e)}Ie.isWeakSet=vR;function Ou(e){return br(e)==="[object ArrayBuffer]"}Ou.working=typeof ArrayBuffer<"u"&&Ou(new ArrayBuffer);function cm(e){return typeof ArrayBuffer>"u"?!1:Ou.working?Ou(e):e instanceof ArrayBuffer}Ie.isArrayBuffer=cm;function Ru(e){return br(e)==="[object DataView]"}Ru.working=typeof ArrayBuffer<"u"&&typeof DataView<"u"&&Ru(new DataView(new ArrayBuffer(1),0,1));function lm(e){return typeof DataView>"u"?!1:Ru.working?Ru(e):e instanceof DataView}Ie.isDataView=lm;var Jl=typeof SharedArrayBuffer<"u"?SharedArrayBuffer:void 0;function ws(e){return br(e)==="[object SharedArrayBuffer]"}function hm(e){return typeof Jl>"u"?!1:(typeof ws.working>"u"&&(ws.working=ws(new Jl)),ws.working?ws(e):e instanceof Jl)}Ie.isSharedArrayBuffer=hm;function bR(e){return br(e)==="[object AsyncFunction]"}Ie.isAsyncFunction=bR;function _R(e){return br(e)==="[object Map Iterator]"}Ie.isMapIterator=_R;function SR(e){return br(e)==="[object Set Iterator]"}Ie.isSetIterator=SR;function wR(e){return br(e)==="[object Generator]"}Ie.isGeneratorObject=wR;function ER(e){return br(e)==="[object WebAssembly.Module]"}Ie.isWebAssemblyCompiledModule=ER;function dm(e){return Es(e,QO)}Ie.isNumberObject=dm;function pm(e){return Es(e,eR)}Ie.isStringObject=pm;function gm(e){return Es(e,tR)}Ie.isBooleanObject=gm;function ym(e){return sm&&Es(e,um)}Ie.isBigIntObject=ym;function mm(e){return am&&Es(e,fm)}Ie.isSymbolObject=mm;function xR(e){return dm(e)||pm(e)||gm(e)||ym(e)||mm(e)}Ie.isBoxedPrimitive=xR;function IR(e){return typeof Uint8Array<"u"&&(cm(e)||hm(e))}Ie.isAnyArrayBuffer=IR;["isProxy","isExternal","isModuleNamespaceObject"].forEach(function(e){Object.defineProperty(Ie,e,{enumerable:!1,value:function(){throw new Error(e+" is not supported in userland")}})})});var _m=B((tD,bm)=>{p();bm.exports=function(t){return t&&typeof t=="object"&&typeof t.copy=="function"&&typeof t.fill=="function"&&typeof t.readUInt8=="function"}});var Xr=B(Ae=>{p();var Sm=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},AR=/%[sdj%]/g;Ae.format=function(e){if(!Cu(e)){for(var t=[],r=0;r<arguments.length;r++)t.push(Vn(arguments[r]));return t.join(" ")}for(var r=1,n=arguments,i=n.length,o=String(e).replace(AR,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])ku(s)||!xo(s)?o+=" "+s:o+=" "+Vn(s);return o};Ae.deprecate=function(e,t){if(typeof x.default<"u"&&x.default.noDeprecation===!0)return e;if(typeof x.default>"u")return function(){return Ae.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 Tu={},wm=/^$/;x.default.env.NODE_DEBUG&&(Pu=x.default.env.NODE_DEBUG,Pu=Pu.replace(/[|\\{}()[\]^$+?.]/g,"\\$&").replace(/\*/g,".*").replace(/,/g,"$|^").toUpperCase(),wm=new RegExp("^"+Pu+"$","i"));var Pu;Ae.debuglog=function(e){if(e=e.toUpperCase(),!Tu[e])if(wm.test(e)){var t=x.default.pid;Tu[e]=function(){var r=Ae.format.apply(Ae,arguments);console.error("%s %d: %s",e,t,r)}}else Tu[e]=function(){};return Tu[e]};function Vn(e,t){var r={seen:[],stylize:RR};return arguments.length>=3&&(r.depth=arguments[2]),arguments.length>=4&&(r.colors=arguments[3]),nh(t)?r.showHidden=t:t&&Ae._extend(r,t),Pi(r.showHidden)&&(r.showHidden=!1),Pi(r.depth)&&(r.depth=2),Pi(r.colors)&&(r.colors=!1),Pi(r.customInspect)&&(r.customInspect=!0),r.colors&&(r.stylize=OR),Nu(r,e,r.depth)}Ae.inspect=Vn;Vn.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]};Vn.styles={special:"cyan",number:"yellow",boolean:"yellow",undefined:"grey",null:"bold",string:"green",date:"magenta",regexp:"red"};function OR(e,t){var r=Vn.styles[t];return r?"\x1B["+Vn.colors[r][0]+"m"+e+"\x1B["+Vn.colors[r][1]+"m":e}function RR(e,t){return e}function TR(e){var t={};return e.forEach(function(r,n){t[r]=!0}),t}function Nu(e,t,r){if(e.customInspect&&t&&Bu(t.inspect)&&t.inspect!==Ae.inspect&&!(t.constructor&&t.constructor.prototype===t)){var n=t.inspect(r,e);return Cu(n)||(n=Nu(e,n,r)),n}var i=PR(e,t);if(i)return i;var o=Object.keys(t),s=TR(o);if(e.showHidden&&(o=Object.getOwnPropertyNames(t)),Is(t)&&(o.indexOf("message")>=0||o.indexOf("description")>=0))return eh(t);if(o.length===0){if(Bu(t)){var a=t.name?": "+t.name:"";return e.stylize("[Function"+a+"]","special")}if(xs(t))return e.stylize(RegExp.prototype.toString.call(t),"regexp");if(Mu(t))return e.stylize(Date.prototype.toString.call(t),"date");if(Is(t))return eh(t)}var f="",l=!1,y=["{","}"];if(Em(t)&&(l=!0,y=["[","]"]),Bu(t)){var g=t.name?": "+t.name:"";f=" [Function"+g+"]"}if(xs(t)&&(f=" "+RegExp.prototype.toString.call(t)),Mu(t)&&(f=" "+Date.prototype.toUTCString.call(t)),Is(t)&&(f=" "+eh(t)),o.length===0&&(!l||t.length==0))return y[0]+f+y[1];if(r<0)return xs(t)?e.stylize(RegExp.prototype.toString.call(t),"regexp"):e.stylize("[Object]","special");e.seen.push(t);var v;return l?v=BR(e,t,r,s,o):v=o.map(function(E){return rh(e,t,r,s,E,l)}),e.seen.pop(),NR(v,f,y)}function PR(e,t){if(Pi(t))return e.stylize("undefined","undefined");if(Cu(t)){var r="'"+JSON.stringify(t).replace(/^"|"$/g,"").replace(/'/g,"\\'").replace(/\\"/g,'"')+"'";return e.stylize(r,"string")}if(xm(t))return e.stylize(""+t,"number");if(nh(t))return e.stylize(""+t,"boolean");if(ku(t))return e.stylize("null","null")}function eh(e){return"["+Error.prototype.toString.call(e)+"]"}function BR(e,t,r,n,i){for(var o=[],s=0,a=t.length;s<a;++s)Im(t,String(s))?o.push(rh(e,t,r,n,String(s),!0)):o.push("");return i.forEach(function(f){f.match(/^\d+$/)||o.push(rh(e,t,r,n,f,!0))}),o}function rh(e,t,r,n,i,o){var s,a,f;if(f=Object.getOwnPropertyDescriptor(t,i)||{value:t[i]},f.get?f.set?a=e.stylize("[Getter/Setter]","special"):a=e.stylize("[Getter]","special"):f.set&&(a=e.stylize("[Setter]","special")),Im(n,i)||(s="["+i+"]"),a||(e.seen.indexOf(f.value)<0?(ku(r)?a=Nu(e,f.value,null):a=Nu(e,f.value,r-1),a.indexOf(`
|
|
1
|
+
var bsvLTP=(()=>{var gI=Object.create;var ps=Object.defineProperty;var yI=Object.getOwnPropertyDescriptor;var mI=Object.getOwnPropertyNames;var vI=Object.getPrototypeOf,bI=Object.prototype.hasOwnProperty;var _I=(e,t,r)=>t in e?ps(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r;var Wt=(e,t,r)=>()=>{if(r)throw r[0];try{return e&&(t=e(e=0)),t}catch(n){throw r=[n],n}};var B=(e,t)=>()=>{try{return t||e((t={exports:{}}).exports,t),t.exports}catch(r){throw t=0,r}},ul=(e,t)=>{for(var r in t)ps(e,r,{get:t[r],enumerable:!0})},u0=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of mI(t))!bI.call(e,i)&&i!==r&&ps(e,i,{get:()=>t[i],enumerable:!(n=yI(t,i))||n.enumerable});return e};var f0=(e,t,r)=>(r=e!=null?gI(vI(e)):{},u0(t||!e||!e.__esModule?ps(r,"default",{value:e,enumerable:!0}):r,e)),fl=e=>u0(ps({},"__esModule",{value:!0}),e);var Z=(e,t,r)=>_I(e,typeof t!="symbol"?t+"":t,r);var p0=B((FC,d0)=>{p();var tt=d0.exports={},Wr,zr;function cl(){throw new Error("setTimeout has not been defined")}function ll(){throw new Error("clearTimeout has not been defined")}(function(){try{typeof setTimeout=="function"?Wr=setTimeout:Wr=cl}catch{Wr=cl}try{typeof clearTimeout=="function"?zr=clearTimeout:zr=ll}catch{zr=ll}})();function c0(e){if(Wr===setTimeout)return setTimeout(e,0);if((Wr===cl||!Wr)&&setTimeout)return Wr=setTimeout,setTimeout(e,0);try{return Wr(e,0)}catch{try{return Wr.call(null,e,0)}catch{return Wr.call(this,e,0)}}}function SI(e){if(zr===clearTimeout)return clearTimeout(e);if((zr===ll||!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 pn=[],uo=!1,wi,Xa=-1;function wI(){!uo||!wi||(uo=!1,wi.length?pn=wi.concat(pn):Xa=-1,pn.length&&l0())}function l0(){if(!uo){var e=c0(wI);uo=!0;for(var t=pn.length;t;){for(wi=pn,pn=[];++Xa<t;)wi&&wi[Xa].run();Xa=-1,t=pn.length}wi=null,uo=!1,SI(e)}}tt.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];pn.push(new h0(e,t)),pn.length===1&&!uo&&c0(l0)};function h0(e,t){this.fun=e,this.array=t}h0.prototype.run=function(){this.fun.apply(null,this.array)};tt.title="browser";tt.browser=!0;tt.env={};tt.argv=[];tt.version="";tt.versions={};function gn(){}tt.on=gn;tt.addListener=gn;tt.once=gn;tt.off=gn;tt.removeListener=gn;tt.removeAllListeners=gn;tt.emit=gn;tt.prependListener=gn;tt.prependOnceListener=gn;tt.listeners=function(e){return[]};tt.binding=function(e){throw new Error("process.binding is not supported")};tt.cwd=function(){return"/"};tt.chdir=function(e){throw new Error("process.chdir is not supported")};tt.umask=function(){return 0}});var m0=B(Ja=>{"use strict";p();Ja.byteLength=xI;Ja.toByteArray=AI;Ja.fromByteArray=TI;var Yr=[],vr=[],EI=typeof Uint8Array<"u"?Uint8Array:Array,hl="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";for(Ei=0,g0=hl.length;Ei<g0;++Ei)Yr[Ei]=hl[Ei],vr[hl.charCodeAt(Ei)]=Ei;var Ei,g0;vr[45]=62;vr[95]=63;function y0(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 xI(e){var t=y0(e),r=t[0],n=t[1];return(r+n)*3/4-n}function II(e,t,r){return(t+r)*3/4-r}function AI(e){var t,r=y0(e),n=r[0],i=r[1],o=new EI(II(e,n,i)),s=0,a=i>0?n-4:n,f;for(f=0;f<a;f+=4)t=vr[e.charCodeAt(f)]<<18|vr[e.charCodeAt(f+1)]<<12|vr[e.charCodeAt(f+2)]<<6|vr[e.charCodeAt(f+3)],o[s++]=t>>16&255,o[s++]=t>>8&255,o[s++]=t&255;return i===2&&(t=vr[e.charCodeAt(f)]<<2|vr[e.charCodeAt(f+1)]>>4,o[s++]=t&255),i===1&&(t=vr[e.charCodeAt(f)]<<10|vr[e.charCodeAt(f+1)]<<4|vr[e.charCodeAt(f+2)]>>2,o[s++]=t>>8&255,o[s++]=t&255),o}function OI(e){return Yr[e>>18&63]+Yr[e>>12&63]+Yr[e>>6&63]+Yr[e&63]}function RI(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(OI(n));return i.join("")}function TI(e){for(var t,r=e.length,n=r%3,i=[],o=16383,s=0,a=r-n;s<a;s+=o)i.push(RI(e,s,s+o>a?a:s+o));return n===1?(t=e[r-1],i.push(Yr[t>>2]+Yr[t<<4&63]+"==")):n===2&&(t=(e[r-2]<<8)+e[r-1],i.push(Yr[t>>10]+Yr[t>>4&63]+Yr[t<<2&63]+"=")),i.join("")}});var v0=B(dl=>{p();dl.read=function(e,t,r,n,i){var o,s,a=i*8-n-1,f=(1<<a)-1,l=f>>1,y=-7,g=r?i-1:0,v=r?-1:1,E=e[t+g];for(g+=v,o=E&(1<<-y)-1,E>>=-y,y+=a;y>0;o=o*256+e[t+g],g+=v,y-=8);for(s=o&(1<<-y)-1,o>>=-y,y+=n;y>0;s=s*256+e[t+g],g+=v,y-=8);if(o===0)o=1-l;else{if(o===f)return s?NaN:(E?-1:1)*(1/0);s=s+Math.pow(2,n),o=o-l}return(E?-1:1)*s*Math.pow(2,o-n)};dl.write=function(e,t,r,n,i,o){var s,a,f,l=o*8-i-1,y=(1<<l)-1,g=y>>1,v=i===23?Math.pow(2,-24)-Math.pow(2,-77):0,E=n?0:o-1,T=n?1:-1,M=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=y):(s=Math.floor(Math.log(t)/Math.LN2),t*(f=Math.pow(2,-s))<1&&(s--,f*=2),s+g>=1?t+=v/f:t+=v*Math.pow(2,1-g),t*f>=2&&(s++,f/=2),s+g>=y?(a=0,s=y):s+g>=1?(a=(t*f-1)*Math.pow(2,i),s=s+g):(a=t*Math.pow(2,g-1)*Math.pow(2,i),s=0));i>=8;e[r+E]=a&255,E+=T,a/=256,i-=8);for(s=s<<i|a,l+=i;l>0;e[r+E]=s&255,E+=T,s/=256,l-=8);e[r+E-T]|=M*128}});var Nt=B(ho=>{"use strict";p();var pl=m0(),co=v0(),b0=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):null;ho.Buffer=j;ho.SlowBuffer=CI;ho.INSPECT_MAX_BYTES=50;var Qa=2147483647;ho.kMaxLength=Qa;j.TYPED_ARRAY_SUPPORT=PI();!j.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 PI(){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(j.prototype,"parent",{enumerable:!0,get:function(){if(j.isBuffer(this))return this.buffer}});Object.defineProperty(j.prototype,"offset",{enumerable:!0,get:function(){if(j.isBuffer(this))return this.byteOffset}});function yn(e){if(e>Qa)throw new RangeError('The value "'+e+'" is invalid for option "size"');let t=new Uint8Array(e);return Object.setPrototypeOf(t,j.prototype),t}function j(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 vl(e)}return E0(e,t,r)}j.poolSize=8192;function E0(e,t,r){if(typeof e=="string")return NI(e,t);if(ArrayBuffer.isView(e))return MI(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($r(e,ArrayBuffer)||e&&$r(e.buffer,ArrayBuffer)||typeof SharedArrayBuffer<"u"&&($r(e,SharedArrayBuffer)||e&&$r(e.buffer,SharedArrayBuffer)))return yl(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 j.from(n,t,r);let i=kI(e);if(i)return i;if(typeof Symbol<"u"&&Symbol.toPrimitive!=null&&typeof e[Symbol.toPrimitive]=="function")return j.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)}j.from=function(e,t,r){return E0(e,t,r)};Object.setPrototypeOf(j.prototype,Uint8Array.prototype);Object.setPrototypeOf(j,Uint8Array);function x0(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 BI(e,t,r){return x0(e),e<=0?yn(e):t!==void 0?typeof r=="string"?yn(e).fill(t,r):yn(e).fill(t):yn(e)}j.alloc=function(e,t,r){return BI(e,t,r)};function vl(e){return x0(e),yn(e<0?0:bl(e)|0)}j.allocUnsafe=function(e){return vl(e)};j.allocUnsafeSlow=function(e){return vl(e)};function NI(e,t){if((typeof t!="string"||t==="")&&(t="utf8"),!j.isEncoding(t))throw new TypeError("Unknown encoding: "+t);let r=I0(e,t)|0,n=yn(r),i=n.write(e,t);return i!==r&&(n=n.slice(0,i)),n}function gl(e){let t=e.length<0?0:bl(e.length)|0,r=yn(t);for(let n=0;n<t;n+=1)r[n]=e[n]&255;return r}function MI(e){if($r(e,Uint8Array)){let t=new Uint8Array(e);return yl(t.buffer,t.byteOffset,t.byteLength)}return gl(e)}function yl(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,j.prototype),n}function kI(e){if(j.isBuffer(e)){let t=bl(e.length)|0,r=yn(t);return r.length===0||e.copy(r,0,0,t),r}if(e.length!==void 0)return typeof e.length!="number"||Sl(e.length)?yn(0):gl(e);if(e.type==="Buffer"&&Array.isArray(e.data))return gl(e.data)}function bl(e){if(e>=Qa)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+Qa.toString(16)+" bytes");return e|0}function CI(e){return+e!=e&&(e=0),j.alloc(+e)}j.isBuffer=function(t){return t!=null&&t._isBuffer===!0&&t!==j.prototype};j.compare=function(t,r){if($r(t,Uint8Array)&&(t=j.from(t,t.offset,t.byteLength)),$r(r,Uint8Array)&&(r=j.from(r,r.offset,r.byteLength)),!j.isBuffer(t)||!j.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};j.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}};j.concat=function(t,r){if(!Array.isArray(t))throw new TypeError('"list" argument must be an Array of Buffers');if(t.length===0)return j.alloc(0);let n;if(r===void 0)for(r=0,n=0;n<t.length;++n)r+=t[n].length;let i=j.allocUnsafe(r),o=0;for(n=0;n<t.length;++n){let s=t[n];if($r(s,Uint8Array))o+s.length>i.length?(j.isBuffer(s)||(s=j.from(s)),s.copy(i,o)):Uint8Array.prototype.set.call(i,s,o);else if(j.isBuffer(s))s.copy(i,o);else throw new TypeError('"list" argument must be an Array of Buffers');o+=s.length}return i};function I0(e,t){if(j.isBuffer(e))return e.length;if(ArrayBuffer.isView(e)||$r(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 ml(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return r*2;case"hex":return r>>>1;case"base64":return k0(e).length;default:if(i)return n?-1:ml(e).length;t=(""+t).toLowerCase(),i=!0}}j.byteLength=I0;function LI(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 WI(this,t,r);case"utf8":case"utf-8":return O0(this,t,r);case"ascii":return GI(this,t,r);case"latin1":case"binary":return VI(this,t,r);case"base64":return jI(this,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return zI(this,t,r);default:if(n)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),n=!0}}j.prototype._isBuffer=!0;function xi(e,t,r){let n=e[t];e[t]=e[r],e[r]=n}j.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)xi(this,r,r+1);return this};j.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)xi(this,r,r+3),xi(this,r+1,r+2);return this};j.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)xi(this,r,r+7),xi(this,r+1,r+6),xi(this,r+2,r+5),xi(this,r+3,r+4);return this};j.prototype.toString=function(){let t=this.length;return t===0?"":arguments.length===0?O0(this,0,t):LI.apply(this,arguments)};j.prototype.toLocaleString=j.prototype.toString;j.prototype.equals=function(t){if(!j.isBuffer(t))throw new TypeError("Argument must be a Buffer");return this===t?!0:j.compare(this,t)===0};j.prototype.inspect=function(){let t="",r=ho.INSPECT_MAX_BYTES;return t=this.toString("hex",0,r).replace(/(.{2})/g,"$1 ").trim(),this.length>r&&(t+=" ... "),"<Buffer "+t+">"};b0&&(j.prototype[b0]=j.prototype.inspect);j.prototype.compare=function(t,r,n,i,o){if($r(t,Uint8Array)&&(t=j.from(t,t.offset,t.byteLength)),!j.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,f=Math.min(s,a),l=this.slice(i,o),y=t.slice(r,n);for(let g=0;g<f;++g)if(l[g]!==y[g]){s=l[g],a=y[g];break}return s<a?-1:a<s?1:0};function A0(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,Sl(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=j.from(t,n)),j.isBuffer(t))return t.length===0?-1:_0(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):_0(e,[t],r,n,i);throw new TypeError("val must be string, number or Buffer")}function _0(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 f(y,g){return o===1?y[g]:y.readUInt16BE(g*o)}let l;if(i){let y=-1;for(l=r;l<s;l++)if(f(e,l)===f(t,y===-1?0:l-y)){if(y===-1&&(y=l),l-y+1===a)return y*o}else y!==-1&&(l-=l-y),y=-1}else for(r+a>s&&(r=s-a),l=r;l>=0;l--){let y=!0;for(let g=0;g<a;g++)if(f(e,l+g)!==f(t,g)){y=!1;break}if(y)return l}return-1}j.prototype.includes=function(t,r,n){return this.indexOf(t,r,n)!==-1};j.prototype.indexOf=function(t,r,n){return A0(this,t,r,n,!0)};j.prototype.lastIndexOf=function(t,r,n){return A0(this,t,r,n,!1)};function DI(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(Sl(a))return s;e[r+s]=a}return s}function UI(e,t,r,n){return eu(ml(t,e.length-r),e,r,n)}function FI(e,t,r,n){return eu(XI(t),e,r,n)}function qI(e,t,r,n){return eu(k0(t),e,r,n)}function HI(e,t,r,n){return eu(JI(t,e.length-r),e,r,n)}j.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 DI(this,t,r,n);case"utf8":case"utf-8":return UI(this,t,r,n);case"ascii":case"latin1":case"binary":return FI(this,t,r,n);case"base64":return qI(this,t,r,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return HI(this,t,r,n);default:if(s)throw new TypeError("Unknown encoding: "+i);i=(""+i).toLowerCase(),s=!0}};j.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function jI(e,t,r){return t===0&&r===e.length?pl.fromByteArray(e):pl.fromByteArray(e.slice(t,r))}function O0(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 f,l,y,g;switch(a){case 1:o<128&&(s=o);break;case 2:f=e[i+1],(f&192)===128&&(g=(o&31)<<6|f&63,g>127&&(s=g));break;case 3:f=e[i+1],l=e[i+2],(f&192)===128&&(l&192)===128&&(g=(o&15)<<12|(f&63)<<6|l&63,g>2047&&(g<55296||g>57343)&&(s=g));break;case 4:f=e[i+1],l=e[i+2],y=e[i+3],(f&192)===128&&(l&192)===128&&(y&192)===128&&(g=(o&15)<<18|(f&63)<<12|(l&63)<<6|y&63,g>65535&&g<1114112&&(s=g))}}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 KI(n)}var S0=4096;function KI(e){let t=e.length;if(t<=S0)return String.fromCharCode.apply(String,e);let r="",n=0;for(;n<t;)r+=String.fromCharCode.apply(String,e.slice(n,n+=S0));return r}function GI(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 VI(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 WI(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+=QI[e[o]];return i}function zI(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}j.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,j.prototype),i};function Ut(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")}j.prototype.readUintLE=j.prototype.readUIntLE=function(t,r,n){t=t>>>0,r=r>>>0,n||Ut(t,r,this.length);let i=this[t],o=1,s=0;for(;++s<r&&(o*=256);)i+=this[t+s]*o;return i};j.prototype.readUintBE=j.prototype.readUIntBE=function(t,r,n){t=t>>>0,r=r>>>0,n||Ut(t,r,this.length);let i=this[t+--r],o=1;for(;r>0&&(o*=256);)i+=this[t+--r]*o;return i};j.prototype.readUint8=j.prototype.readUInt8=function(t,r){return t=t>>>0,r||Ut(t,1,this.length),this[t]};j.prototype.readUint16LE=j.prototype.readUInt16LE=function(t,r){return t=t>>>0,r||Ut(t,2,this.length),this[t]|this[t+1]<<8};j.prototype.readUint16BE=j.prototype.readUInt16BE=function(t,r){return t=t>>>0,r||Ut(t,2,this.length),this[t]<<8|this[t+1]};j.prototype.readUint32LE=j.prototype.readUInt32LE=function(t,r){return t=t>>>0,r||Ut(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+this[t+3]*16777216};j.prototype.readUint32BE=j.prototype.readUInt32BE=function(t,r){return t=t>>>0,r||Ut(t,4,this.length),this[t]*16777216+(this[t+1]<<16|this[t+2]<<8|this[t+3])};j.prototype.readBigUInt64LE=Kn(function(t){t=t>>>0,lo(t,"offset");let r=this[t],n=this[t+7];(r===void 0||n===void 0)&&gs(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))});j.prototype.readBigUInt64BE=Kn(function(t){t=t>>>0,lo(t,"offset");let r=this[t],n=this[t+7];(r===void 0||n===void 0)&&gs(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)});j.prototype.readIntLE=function(t,r,n){t=t>>>0,r=r>>>0,n||Ut(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};j.prototype.readIntBE=function(t,r,n){t=t>>>0,r=r>>>0,n||Ut(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};j.prototype.readInt8=function(t,r){return t=t>>>0,r||Ut(t,1,this.length),this[t]&128?(255-this[t]+1)*-1:this[t]};j.prototype.readInt16LE=function(t,r){t=t>>>0,r||Ut(t,2,this.length);let n=this[t]|this[t+1]<<8;return n&32768?n|4294901760:n};j.prototype.readInt16BE=function(t,r){t=t>>>0,r||Ut(t,2,this.length);let n=this[t+1]|this[t]<<8;return n&32768?n|4294901760:n};j.prototype.readInt32LE=function(t,r){return t=t>>>0,r||Ut(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24};j.prototype.readInt32BE=function(t,r){return t=t>>>0,r||Ut(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]};j.prototype.readBigInt64LE=Kn(function(t){t=t>>>0,lo(t,"offset");let r=this[t],n=this[t+7];(r===void 0||n===void 0)&&gs(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)});j.prototype.readBigInt64BE=Kn(function(t){t=t>>>0,lo(t,"offset");let r=this[t],n=this[t+7];(r===void 0||n===void 0)&&gs(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)});j.prototype.readFloatLE=function(t,r){return t=t>>>0,r||Ut(t,4,this.length),co.read(this,t,!0,23,4)};j.prototype.readFloatBE=function(t,r){return t=t>>>0,r||Ut(t,4,this.length),co.read(this,t,!1,23,4)};j.prototype.readDoubleLE=function(t,r){return t=t>>>0,r||Ut(t,8,this.length),co.read(this,t,!0,52,8)};j.prototype.readDoubleBE=function(t,r){return t=t>>>0,r||Ut(t,8,this.length),co.read(this,t,!1,52,8)};function sr(e,t,r,n,i,o){if(!j.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")}j.prototype.writeUintLE=j.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};j.prototype.writeUintBE=j.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};j.prototype.writeUint8=j.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};j.prototype.writeUint16LE=j.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};j.prototype.writeUint16BE=j.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};j.prototype.writeUint32LE=j.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};j.prototype.writeUint32BE=j.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 R0(e,t,r,n,i){M0(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 T0(e,t,r,n,i){M0(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}j.prototype.writeBigUInt64LE=Kn(function(t,r=0){return R0(this,t,r,BigInt(0),BigInt("0xffffffffffffffff"))});j.prototype.writeBigUInt64BE=Kn(function(t,r=0){return T0(this,t,r,BigInt(0),BigInt("0xffffffffffffffff"))});j.prototype.writeIntLE=function(t,r,n,i){if(t=+t,r=r>>>0,!i){let f=Math.pow(2,8*n-1);sr(this,t,r,n,f-1,-f)}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};j.prototype.writeIntBE=function(t,r,n,i){if(t=+t,r=r>>>0,!i){let f=Math.pow(2,8*n-1);sr(this,t,r,n,f-1,-f)}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};j.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};j.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};j.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};j.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};j.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};j.prototype.writeBigInt64LE=Kn(function(t,r=0){return R0(this,t,r,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});j.prototype.writeBigInt64BE=Kn(function(t,r=0){return T0(this,t,r,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});function P0(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 B0(e,t,r,n,i){return t=+t,r=r>>>0,i||P0(e,t,r,4,34028234663852886e22,-34028234663852886e22),co.write(e,t,r,n,23,4),r+4}j.prototype.writeFloatLE=function(t,r,n){return B0(this,t,r,!0,n)};j.prototype.writeFloatBE=function(t,r,n){return B0(this,t,r,!1,n)};function N0(e,t,r,n,i){return t=+t,r=r>>>0,i||P0(e,t,r,8,17976931348623157e292,-17976931348623157e292),co.write(e,t,r,n,52,8),r+8}j.prototype.writeDoubleLE=function(t,r,n){return N0(this,t,r,!0,n)};j.prototype.writeDoubleBE=function(t,r,n){return N0(this,t,r,!1,n)};j.prototype.copy=function(t,r,n,i){if(!j.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};j.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"&&!j.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=j.isBuffer(t)?t:j.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 fo={};function _l(e,t,r){fo[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}`}}}_l("ERR_BUFFER_OUT_OF_BOUNDS",function(e){return e?`${e} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"},RangeError);_l("ERR_INVALID_ARG_TYPE",function(e,t){return`The "${e}" argument must be of type number. Received type ${typeof t}`},TypeError);_l("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=w0(String(r)):typeof r=="bigint"&&(i=String(r),(r>BigInt(2)**BigInt(32)||r<-(BigInt(2)**BigInt(32)))&&(i=w0(i)),i+="n"),n+=` It must be ${t}. Received ${i}`,n},RangeError);function w0(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 YI(e,t,r){lo(t,"offset"),(e[t]===void 0||e[t+r]===void 0)&&gs(t,e.length-(r+1))}function M0(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 fo.ERR_OUT_OF_RANGE("value",a,e)}YI(n,i,o)}function lo(e,t){if(typeof e!="number")throw new fo.ERR_INVALID_ARG_TYPE(t,"number",e)}function gs(e,t,r){throw Math.floor(e)!==e?(lo(e,r),new fo.ERR_OUT_OF_RANGE(r||"offset","an integer",e)):t<0?new fo.ERR_BUFFER_OUT_OF_BOUNDS:new fo.ERR_OUT_OF_RANGE(r||"offset",`>= ${r?1:0} and <= ${t}`,e)}var $I=/[^+/0-9A-Za-z-_]/g;function ZI(e){if(e=e.split("=")[0],e=e.trim().replace($I,""),e.length<2)return"";for(;e.length%4!==0;)e=e+"=";return e}function ml(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 XI(e){let t=[];for(let r=0;r<e.length;++r)t.push(e.charCodeAt(r)&255);return t}function JI(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 k0(e){return pl.toByteArray(ZI(e))}function eu(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 $r(e,t){return e instanceof t||e!=null&&e.constructor!=null&&e.constructor.name!=null&&e.constructor.name===t.name}function Sl(e){return e!==e}var QI=(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"?eA:e}function eA(){throw new Error("BigInt not supported")}});var x,d,p=Wt(()=>{x=f0(p0()),d=f0(Nt())});var L0=B((C0,wl)=>{p();(function(e,t){"use strict";function r(I,u){if(!I)throw new Error(u||"Assertion failed")}function n(I,u){I.super_=u;var h=function(){};h.prototype=u.prototype,I.prototype=new h,I.prototype.constructor=I}function i(I,u,h){if(i.isBN(I))return I;this.negative=0,this.words=null,this.length=0,this.red=null,I!==null&&((u==="le"||u==="be")&&(h=u,u=10),this._init(I||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=Nt().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,m){if(typeof u=="number")return this._initNumber(u,h,m);if(typeof u=="object")return this._initArray(u,h,m);h==="hex"&&(h=16),r(h===(h|0)&&h>=2&&h<=36),u=u.toString().replace(/\s+/g,"");var S=0;u[0]==="-"&&(S++,this.negative=1),S<u.length&&(h===16?this._parseHex(u,S,m):(this._parseBase(u,h,S),m==="le"&&this._initArray(this.toArray(),h,m)))},i.prototype._initNumber=function(u,h,m){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),m==="le"&&this._initArray(this.toArray(),h,m)},i.prototype._initArray=function(u,h,m){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 S=0;S<this.length;S++)this.words[S]=0;var w,R,A=0;if(m==="be")for(S=u.length-1,w=0;S>=0;S-=3)R=u[S]|u[S-1]<<8|u[S-2]<<16,this.words[w]|=R<<A&67108863,this.words[w+1]=R>>>26-A&67108863,A+=24,A>=26&&(A-=26,w++);else if(m==="le")for(S=0,w=0;S<u.length;S+=3)R=u[S]|u[S+1]<<8|u[S+2]<<16,this.words[w]|=R<<A&67108863,this.words[w+1]=R>>>26-A&67108863,A+=24,A>=26&&(A-=26,w++);return this.strip()};function s(I,u){var h=I.charCodeAt(u);return h>=65&&h<=70?h-55:h>=97&&h<=102?h-87:h-48&15}function a(I,u,h){var m=s(I,h);return h-1>=u&&(m|=s(I,h-1)<<4),m}i.prototype._parseHex=function(u,h,m){this.length=Math.ceil((u.length-h)/6),this.words=new Array(this.length);for(var S=0;S<this.length;S++)this.words[S]=0;var w=0,R=0,A;if(m==="be")for(S=u.length-1;S>=h;S-=2)A=a(u,h,S)<<w,this.words[R]|=A&67108863,w>=18?(w-=18,R+=1,this.words[R]|=A>>>26):w+=8;else{var _=u.length-h;for(S=_%2===0?h+1:h;S<u.length;S+=2)A=a(u,h,S)<<w,this.words[R]|=A&67108863,w>=18?(w-=18,R+=1,this.words[R]|=A>>>26):w+=8}this.strip()};function f(I,u,h,m){for(var S=0,w=Math.min(I.length,h),R=u;R<w;R++){var A=I.charCodeAt(R)-48;S*=m,A>=49?S+=A-49+10:A>=17?S+=A-17+10:S+=A}return S}i.prototype._parseBase=function(u,h,m){this.words=[0],this.length=1;for(var S=0,w=1;w<=67108863;w*=h)S++;S--,w=w/h|0;for(var R=u.length-m,A=R%S,_=Math.min(R,R-A)+m,c=0,b=m;b<_;b+=S)c=f(u,b,b+S,h),this.imuln(w),this.words[0]+c<67108864?this.words[0]+=c:this._iaddn(c);if(A!==0){var k=1;for(c=f(u,b,u.length,h),b=0;b<A;b++)k*=h;this.imuln(k),this.words[0]+c<67108864?this.words[0]+=c:this._iaddn(c)}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"],y=[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],g=[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 m;if(u===16||u==="hex"){m="";for(var S=0,w=0,R=0;R<this.length;R++){var A=this.words[R],_=((A<<S|w)&16777215).toString(16);w=A>>>24-S&16777215,S+=2,S>=26&&(S-=26,R--),w!==0||R!==this.length-1?m=l[6-_.length]+_+m:m=_+m}for(w!==0&&(m=w.toString(16)+m);m.length%h!==0;)m="0"+m;return this.negative!==0&&(m="-"+m),m}if(u===(u|0)&&u>=2&&u<=36){var c=y[u],b=g[u];m="";var k=this.clone();for(k.negative=0;!k.isZero();){var L=k.modn(b).toString(u);k=k.idivn(b),k.isZero()?m=L+m:m=l[c-L.length]+L+m}for(this.isZero()&&(m="0"+m);m.length%h!==0;)m="0"+m;return this.negative!==0&&(m="-"+m),m}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,m){var S=this.byteLength(),w=m||Math.max(1,S);r(S<=w,"byte array longer than desired length"),r(w>0,"Requested array length <= 0"),this.strip();var R=h==="le",A=new u(w),_,c,b=this.clone();if(R){for(c=0;!b.isZero();c++)_=b.andln(255),b.iushrn(8),A[c]=_;for(;c<w;c++)A[c]=0}else{for(c=0;c<w-S;c++)A[c]=0;for(c=0;!b.isZero();c++)_=b.andln(255),b.iushrn(8),A[w-c-1]=_}return A},Math.clz32?i.prototype._countBits=function(u){return 32-Math.clz32(u)}:i.prototype._countBits=function(u){var h=u,m=0;return h>=4096&&(m+=13,h>>>=13),h>=64&&(m+=7,h>>>=7),h>=8&&(m+=4,h>>>=4),h>=2&&(m+=2,h>>>=2),m+h},i.prototype._zeroBits=function(u){if(u===0)return 26;var h=u,m=0;return(h&8191)===0&&(m+=13,h>>>=13),(h&127)===0&&(m+=7,h>>>=7),(h&15)===0&&(m+=4,h>>>=4),(h&3)===0&&(m+=2,h>>>=2),(h&1)===0&&m++,m},i.prototype.bitLength=function(){var u=this.words[this.length-1],h=this._countBits(u);return(this.length-1)*26+h};function v(I){for(var u=new Array(I.bitLength()),h=0;h<u.length;h++){var m=h/26|0,S=h%26;u[h]=(I.words[m]&1<<S)>>>S}return u}i.prototype.zeroBits=function(){if(this.isZero())return 0;for(var u=0,h=0;h<this.length;h++){var m=this._zeroBits(this.words[h]);if(u+=m,m!==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 m=0;m<h.length;m++)this.words[m]=this.words[m]&u.words[m];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,m;this.length>u.length?(h=this,m=u):(h=u,m=this);for(var S=0;S<m.length;S++)this.words[S]=h.words[S]^m.words[S];if(this!==h)for(;S<h.length;S++)this.words[S]=h.words[S];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,m=u%26;this._expand(h),m>0&&h--;for(var S=0;S<h;S++)this.words[S]=~this.words[S]&67108863;for(m>0&&(this.words[S]=~this.words[S]&67108863>>26-m,S++);S<this.length;S++)this.words[S]=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 m=u/26|0,S=u%26;return this._expand(m+1),h?this.words[m]=this.words[m]|1<<S:this.words[m]=this.words[m]&~(1<<S),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 m,S;this.length>u.length?(m=this,S=u):(m=u,S=this);for(var w=0,R=0;R<S.length;R++)h=(m.words[R]|0)+(S.words[R]|0)+w,this.words[R]=h&67108863,w=h>>>26;for(;w!==0&&R<m.length;R++)h=(m.words[R]|0)+w,this.words[R]=h&67108863,w=h>>>26;if(this.length=m.length,w!==0)this.words[this.length]=w,this.length++;else if(m!==this)for(;R<m.length;R++)this.words[R]=m.words[R];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 m=this.cmp(u);if(m===0)return this.negative=0,this.length=1,this.words[0]=0,this;var S,w;m>0?(S=this,w=u):(S=u,w=this);for(var R=0,A=0;A<w.length;A++)h=(S.words[A]|0)-(w.words[A]|0)+R,R=h>>26,this.words[A]=h&67108863;for(;R!==0&&A<S.length;A++)h=(S.words[A]|0)+R,R=h>>26,this.words[A]=h&67108863;if(R===0&&A<S.length&&S!==this)for(;A<S.length;A++)this.words[A]=S.words[A];return this.length=Math.max(this.length,A),S!==this&&(this.negative=1),this.strip()},i.prototype.sub=function(u){return this.clone().isub(u)};function E(I,u,h){h.negative=u.negative^I.negative;var m=I.length+u.length|0;h.length=m,m=m-1|0;var S=I.words[0]|0,w=u.words[0]|0,R=S*w,A=R&67108863,_=R/67108864|0;h.words[0]=A;for(var c=1;c<m;c++){for(var b=_>>>26,k=_&67108863,L=Math.min(c,u.length-1),H=Math.max(0,c-I.length+1);H<=L;H++){var W=c-H|0;S=I.words[W]|0,w=u.words[H]|0,R=S*w+k,b+=R/67108864|0,k=R&67108863}h.words[c]=k|0,_=b|0}return _!==0?h.words[c]=_|0:h.length--,h.strip()}var T=function(u,h,m){var S=u.words,w=h.words,R=m.words,A=0,_,c,b,k=S[0]|0,L=k&8191,H=k>>>13,W=S[1]|0,te=W&8191,X=W>>>13,ue=S[2]|0,fe=ue&8191,O=ue>>>13,C=S[3]|0,D=C&8191,K=C>>>13,re=S[4]|0,J=re&8191,Q=re>>>13,se=S[5]|0,ce=se&8191,ae=se>>>13,_e=S[6]|0,oe=_e&8191,Pe=_e>>>13,ge=S[7]|0,be=ge&8191,Ee=ge>>>13,or=S[8]|0,Ze=or&8191,Ve=or>>>13,Za=S[9]|0,Je=Za&8191,st=Za>>>13,Jp=w[0]|0,at=Jp&8191,ut=Jp>>>13,Qp=w[1]|0,ft=Qp&8191,ct=Qp>>>13,e0=w[2]|0,lt=e0&8191,ht=e0>>>13,t0=w[3]|0,dt=t0&8191,pt=t0>>>13,r0=w[4]|0,gt=r0&8191,yt=r0>>>13,n0=w[5]|0,mt=n0&8191,vt=n0>>>13,i0=w[6]|0,bt=i0&8191,_t=i0>>>13,o0=w[7]|0,St=o0&8191,wt=o0>>>13,s0=w[8]|0,Et=s0&8191,xt=s0>>>13,a0=w[9]|0,It=a0&8191,At=a0>>>13;m.negative=u.negative^h.negative,m.length=19,_=Math.imul(L,at),c=Math.imul(L,ut),c=c+Math.imul(H,at)|0,b=Math.imul(H,ut);var Kc=(A+_|0)+((c&8191)<<13)|0;A=(b+(c>>>13)|0)+(Kc>>>26)|0,Kc&=67108863,_=Math.imul(te,at),c=Math.imul(te,ut),c=c+Math.imul(X,at)|0,b=Math.imul(X,ut),_=_+Math.imul(L,ft)|0,c=c+Math.imul(L,ct)|0,c=c+Math.imul(H,ft)|0,b=b+Math.imul(H,ct)|0;var Gc=(A+_|0)+((c&8191)<<13)|0;A=(b+(c>>>13)|0)+(Gc>>>26)|0,Gc&=67108863,_=Math.imul(fe,at),c=Math.imul(fe,ut),c=c+Math.imul(O,at)|0,b=Math.imul(O,ut),_=_+Math.imul(te,ft)|0,c=c+Math.imul(te,ct)|0,c=c+Math.imul(X,ft)|0,b=b+Math.imul(X,ct)|0,_=_+Math.imul(L,lt)|0,c=c+Math.imul(L,ht)|0,c=c+Math.imul(H,lt)|0,b=b+Math.imul(H,ht)|0;var Vc=(A+_|0)+((c&8191)<<13)|0;A=(b+(c>>>13)|0)+(Vc>>>26)|0,Vc&=67108863,_=Math.imul(D,at),c=Math.imul(D,ut),c=c+Math.imul(K,at)|0,b=Math.imul(K,ut),_=_+Math.imul(fe,ft)|0,c=c+Math.imul(fe,ct)|0,c=c+Math.imul(O,ft)|0,b=b+Math.imul(O,ct)|0,_=_+Math.imul(te,lt)|0,c=c+Math.imul(te,ht)|0,c=c+Math.imul(X,lt)|0,b=b+Math.imul(X,ht)|0,_=_+Math.imul(L,dt)|0,c=c+Math.imul(L,pt)|0,c=c+Math.imul(H,dt)|0,b=b+Math.imul(H,pt)|0;var Wc=(A+_|0)+((c&8191)<<13)|0;A=(b+(c>>>13)|0)+(Wc>>>26)|0,Wc&=67108863,_=Math.imul(J,at),c=Math.imul(J,ut),c=c+Math.imul(Q,at)|0,b=Math.imul(Q,ut),_=_+Math.imul(D,ft)|0,c=c+Math.imul(D,ct)|0,c=c+Math.imul(K,ft)|0,b=b+Math.imul(K,ct)|0,_=_+Math.imul(fe,lt)|0,c=c+Math.imul(fe,ht)|0,c=c+Math.imul(O,lt)|0,b=b+Math.imul(O,ht)|0,_=_+Math.imul(te,dt)|0,c=c+Math.imul(te,pt)|0,c=c+Math.imul(X,dt)|0,b=b+Math.imul(X,pt)|0,_=_+Math.imul(L,gt)|0,c=c+Math.imul(L,yt)|0,c=c+Math.imul(H,gt)|0,b=b+Math.imul(H,yt)|0;var zc=(A+_|0)+((c&8191)<<13)|0;A=(b+(c>>>13)|0)+(zc>>>26)|0,zc&=67108863,_=Math.imul(ce,at),c=Math.imul(ce,ut),c=c+Math.imul(ae,at)|0,b=Math.imul(ae,ut),_=_+Math.imul(J,ft)|0,c=c+Math.imul(J,ct)|0,c=c+Math.imul(Q,ft)|0,b=b+Math.imul(Q,ct)|0,_=_+Math.imul(D,lt)|0,c=c+Math.imul(D,ht)|0,c=c+Math.imul(K,lt)|0,b=b+Math.imul(K,ht)|0,_=_+Math.imul(fe,dt)|0,c=c+Math.imul(fe,pt)|0,c=c+Math.imul(O,dt)|0,b=b+Math.imul(O,pt)|0,_=_+Math.imul(te,gt)|0,c=c+Math.imul(te,yt)|0,c=c+Math.imul(X,gt)|0,b=b+Math.imul(X,yt)|0,_=_+Math.imul(L,mt)|0,c=c+Math.imul(L,vt)|0,c=c+Math.imul(H,mt)|0,b=b+Math.imul(H,vt)|0;var Yc=(A+_|0)+((c&8191)<<13)|0;A=(b+(c>>>13)|0)+(Yc>>>26)|0,Yc&=67108863,_=Math.imul(oe,at),c=Math.imul(oe,ut),c=c+Math.imul(Pe,at)|0,b=Math.imul(Pe,ut),_=_+Math.imul(ce,ft)|0,c=c+Math.imul(ce,ct)|0,c=c+Math.imul(ae,ft)|0,b=b+Math.imul(ae,ct)|0,_=_+Math.imul(J,lt)|0,c=c+Math.imul(J,ht)|0,c=c+Math.imul(Q,lt)|0,b=b+Math.imul(Q,ht)|0,_=_+Math.imul(D,dt)|0,c=c+Math.imul(D,pt)|0,c=c+Math.imul(K,dt)|0,b=b+Math.imul(K,pt)|0,_=_+Math.imul(fe,gt)|0,c=c+Math.imul(fe,yt)|0,c=c+Math.imul(O,gt)|0,b=b+Math.imul(O,yt)|0,_=_+Math.imul(te,mt)|0,c=c+Math.imul(te,vt)|0,c=c+Math.imul(X,mt)|0,b=b+Math.imul(X,vt)|0,_=_+Math.imul(L,bt)|0,c=c+Math.imul(L,_t)|0,c=c+Math.imul(H,bt)|0,b=b+Math.imul(H,_t)|0;var $c=(A+_|0)+((c&8191)<<13)|0;A=(b+(c>>>13)|0)+($c>>>26)|0,$c&=67108863,_=Math.imul(be,at),c=Math.imul(be,ut),c=c+Math.imul(Ee,at)|0,b=Math.imul(Ee,ut),_=_+Math.imul(oe,ft)|0,c=c+Math.imul(oe,ct)|0,c=c+Math.imul(Pe,ft)|0,b=b+Math.imul(Pe,ct)|0,_=_+Math.imul(ce,lt)|0,c=c+Math.imul(ce,ht)|0,c=c+Math.imul(ae,lt)|0,b=b+Math.imul(ae,ht)|0,_=_+Math.imul(J,dt)|0,c=c+Math.imul(J,pt)|0,c=c+Math.imul(Q,dt)|0,b=b+Math.imul(Q,pt)|0,_=_+Math.imul(D,gt)|0,c=c+Math.imul(D,yt)|0,c=c+Math.imul(K,gt)|0,b=b+Math.imul(K,yt)|0,_=_+Math.imul(fe,mt)|0,c=c+Math.imul(fe,vt)|0,c=c+Math.imul(O,mt)|0,b=b+Math.imul(O,vt)|0,_=_+Math.imul(te,bt)|0,c=c+Math.imul(te,_t)|0,c=c+Math.imul(X,bt)|0,b=b+Math.imul(X,_t)|0,_=_+Math.imul(L,St)|0,c=c+Math.imul(L,wt)|0,c=c+Math.imul(H,St)|0,b=b+Math.imul(H,wt)|0;var Zc=(A+_|0)+((c&8191)<<13)|0;A=(b+(c>>>13)|0)+(Zc>>>26)|0,Zc&=67108863,_=Math.imul(Ze,at),c=Math.imul(Ze,ut),c=c+Math.imul(Ve,at)|0,b=Math.imul(Ve,ut),_=_+Math.imul(be,ft)|0,c=c+Math.imul(be,ct)|0,c=c+Math.imul(Ee,ft)|0,b=b+Math.imul(Ee,ct)|0,_=_+Math.imul(oe,lt)|0,c=c+Math.imul(oe,ht)|0,c=c+Math.imul(Pe,lt)|0,b=b+Math.imul(Pe,ht)|0,_=_+Math.imul(ce,dt)|0,c=c+Math.imul(ce,pt)|0,c=c+Math.imul(ae,dt)|0,b=b+Math.imul(ae,pt)|0,_=_+Math.imul(J,gt)|0,c=c+Math.imul(J,yt)|0,c=c+Math.imul(Q,gt)|0,b=b+Math.imul(Q,yt)|0,_=_+Math.imul(D,mt)|0,c=c+Math.imul(D,vt)|0,c=c+Math.imul(K,mt)|0,b=b+Math.imul(K,vt)|0,_=_+Math.imul(fe,bt)|0,c=c+Math.imul(fe,_t)|0,c=c+Math.imul(O,bt)|0,b=b+Math.imul(O,_t)|0,_=_+Math.imul(te,St)|0,c=c+Math.imul(te,wt)|0,c=c+Math.imul(X,St)|0,b=b+Math.imul(X,wt)|0,_=_+Math.imul(L,Et)|0,c=c+Math.imul(L,xt)|0,c=c+Math.imul(H,Et)|0,b=b+Math.imul(H,xt)|0;var Xc=(A+_|0)+((c&8191)<<13)|0;A=(b+(c>>>13)|0)+(Xc>>>26)|0,Xc&=67108863,_=Math.imul(Je,at),c=Math.imul(Je,ut),c=c+Math.imul(st,at)|0,b=Math.imul(st,ut),_=_+Math.imul(Ze,ft)|0,c=c+Math.imul(Ze,ct)|0,c=c+Math.imul(Ve,ft)|0,b=b+Math.imul(Ve,ct)|0,_=_+Math.imul(be,lt)|0,c=c+Math.imul(be,ht)|0,c=c+Math.imul(Ee,lt)|0,b=b+Math.imul(Ee,ht)|0,_=_+Math.imul(oe,dt)|0,c=c+Math.imul(oe,pt)|0,c=c+Math.imul(Pe,dt)|0,b=b+Math.imul(Pe,pt)|0,_=_+Math.imul(ce,gt)|0,c=c+Math.imul(ce,yt)|0,c=c+Math.imul(ae,gt)|0,b=b+Math.imul(ae,yt)|0,_=_+Math.imul(J,mt)|0,c=c+Math.imul(J,vt)|0,c=c+Math.imul(Q,mt)|0,b=b+Math.imul(Q,vt)|0,_=_+Math.imul(D,bt)|0,c=c+Math.imul(D,_t)|0,c=c+Math.imul(K,bt)|0,b=b+Math.imul(K,_t)|0,_=_+Math.imul(fe,St)|0,c=c+Math.imul(fe,wt)|0,c=c+Math.imul(O,St)|0,b=b+Math.imul(O,wt)|0,_=_+Math.imul(te,Et)|0,c=c+Math.imul(te,xt)|0,c=c+Math.imul(X,Et)|0,b=b+Math.imul(X,xt)|0,_=_+Math.imul(L,It)|0,c=c+Math.imul(L,At)|0,c=c+Math.imul(H,It)|0,b=b+Math.imul(H,At)|0;var Jc=(A+_|0)+((c&8191)<<13)|0;A=(b+(c>>>13)|0)+(Jc>>>26)|0,Jc&=67108863,_=Math.imul(Je,ft),c=Math.imul(Je,ct),c=c+Math.imul(st,ft)|0,b=Math.imul(st,ct),_=_+Math.imul(Ze,lt)|0,c=c+Math.imul(Ze,ht)|0,c=c+Math.imul(Ve,lt)|0,b=b+Math.imul(Ve,ht)|0,_=_+Math.imul(be,dt)|0,c=c+Math.imul(be,pt)|0,c=c+Math.imul(Ee,dt)|0,b=b+Math.imul(Ee,pt)|0,_=_+Math.imul(oe,gt)|0,c=c+Math.imul(oe,yt)|0,c=c+Math.imul(Pe,gt)|0,b=b+Math.imul(Pe,yt)|0,_=_+Math.imul(ce,mt)|0,c=c+Math.imul(ce,vt)|0,c=c+Math.imul(ae,mt)|0,b=b+Math.imul(ae,vt)|0,_=_+Math.imul(J,bt)|0,c=c+Math.imul(J,_t)|0,c=c+Math.imul(Q,bt)|0,b=b+Math.imul(Q,_t)|0,_=_+Math.imul(D,St)|0,c=c+Math.imul(D,wt)|0,c=c+Math.imul(K,St)|0,b=b+Math.imul(K,wt)|0,_=_+Math.imul(fe,Et)|0,c=c+Math.imul(fe,xt)|0,c=c+Math.imul(O,Et)|0,b=b+Math.imul(O,xt)|0,_=_+Math.imul(te,It)|0,c=c+Math.imul(te,At)|0,c=c+Math.imul(X,It)|0,b=b+Math.imul(X,At)|0;var Qc=(A+_|0)+((c&8191)<<13)|0;A=(b+(c>>>13)|0)+(Qc>>>26)|0,Qc&=67108863,_=Math.imul(Je,lt),c=Math.imul(Je,ht),c=c+Math.imul(st,lt)|0,b=Math.imul(st,ht),_=_+Math.imul(Ze,dt)|0,c=c+Math.imul(Ze,pt)|0,c=c+Math.imul(Ve,dt)|0,b=b+Math.imul(Ve,pt)|0,_=_+Math.imul(be,gt)|0,c=c+Math.imul(be,yt)|0,c=c+Math.imul(Ee,gt)|0,b=b+Math.imul(Ee,yt)|0,_=_+Math.imul(oe,mt)|0,c=c+Math.imul(oe,vt)|0,c=c+Math.imul(Pe,mt)|0,b=b+Math.imul(Pe,vt)|0,_=_+Math.imul(ce,bt)|0,c=c+Math.imul(ce,_t)|0,c=c+Math.imul(ae,bt)|0,b=b+Math.imul(ae,_t)|0,_=_+Math.imul(J,St)|0,c=c+Math.imul(J,wt)|0,c=c+Math.imul(Q,St)|0,b=b+Math.imul(Q,wt)|0,_=_+Math.imul(D,Et)|0,c=c+Math.imul(D,xt)|0,c=c+Math.imul(K,Et)|0,b=b+Math.imul(K,xt)|0,_=_+Math.imul(fe,It)|0,c=c+Math.imul(fe,At)|0,c=c+Math.imul(O,It)|0,b=b+Math.imul(O,At)|0;var el=(A+_|0)+((c&8191)<<13)|0;A=(b+(c>>>13)|0)+(el>>>26)|0,el&=67108863,_=Math.imul(Je,dt),c=Math.imul(Je,pt),c=c+Math.imul(st,dt)|0,b=Math.imul(st,pt),_=_+Math.imul(Ze,gt)|0,c=c+Math.imul(Ze,yt)|0,c=c+Math.imul(Ve,gt)|0,b=b+Math.imul(Ve,yt)|0,_=_+Math.imul(be,mt)|0,c=c+Math.imul(be,vt)|0,c=c+Math.imul(Ee,mt)|0,b=b+Math.imul(Ee,vt)|0,_=_+Math.imul(oe,bt)|0,c=c+Math.imul(oe,_t)|0,c=c+Math.imul(Pe,bt)|0,b=b+Math.imul(Pe,_t)|0,_=_+Math.imul(ce,St)|0,c=c+Math.imul(ce,wt)|0,c=c+Math.imul(ae,St)|0,b=b+Math.imul(ae,wt)|0,_=_+Math.imul(J,Et)|0,c=c+Math.imul(J,xt)|0,c=c+Math.imul(Q,Et)|0,b=b+Math.imul(Q,xt)|0,_=_+Math.imul(D,It)|0,c=c+Math.imul(D,At)|0,c=c+Math.imul(K,It)|0,b=b+Math.imul(K,At)|0;var tl=(A+_|0)+((c&8191)<<13)|0;A=(b+(c>>>13)|0)+(tl>>>26)|0,tl&=67108863,_=Math.imul(Je,gt),c=Math.imul(Je,yt),c=c+Math.imul(st,gt)|0,b=Math.imul(st,yt),_=_+Math.imul(Ze,mt)|0,c=c+Math.imul(Ze,vt)|0,c=c+Math.imul(Ve,mt)|0,b=b+Math.imul(Ve,vt)|0,_=_+Math.imul(be,bt)|0,c=c+Math.imul(be,_t)|0,c=c+Math.imul(Ee,bt)|0,b=b+Math.imul(Ee,_t)|0,_=_+Math.imul(oe,St)|0,c=c+Math.imul(oe,wt)|0,c=c+Math.imul(Pe,St)|0,b=b+Math.imul(Pe,wt)|0,_=_+Math.imul(ce,Et)|0,c=c+Math.imul(ce,xt)|0,c=c+Math.imul(ae,Et)|0,b=b+Math.imul(ae,xt)|0,_=_+Math.imul(J,It)|0,c=c+Math.imul(J,At)|0,c=c+Math.imul(Q,It)|0,b=b+Math.imul(Q,At)|0;var rl=(A+_|0)+((c&8191)<<13)|0;A=(b+(c>>>13)|0)+(rl>>>26)|0,rl&=67108863,_=Math.imul(Je,mt),c=Math.imul(Je,vt),c=c+Math.imul(st,mt)|0,b=Math.imul(st,vt),_=_+Math.imul(Ze,bt)|0,c=c+Math.imul(Ze,_t)|0,c=c+Math.imul(Ve,bt)|0,b=b+Math.imul(Ve,_t)|0,_=_+Math.imul(be,St)|0,c=c+Math.imul(be,wt)|0,c=c+Math.imul(Ee,St)|0,b=b+Math.imul(Ee,wt)|0,_=_+Math.imul(oe,Et)|0,c=c+Math.imul(oe,xt)|0,c=c+Math.imul(Pe,Et)|0,b=b+Math.imul(Pe,xt)|0,_=_+Math.imul(ce,It)|0,c=c+Math.imul(ce,At)|0,c=c+Math.imul(ae,It)|0,b=b+Math.imul(ae,At)|0;var nl=(A+_|0)+((c&8191)<<13)|0;A=(b+(c>>>13)|0)+(nl>>>26)|0,nl&=67108863,_=Math.imul(Je,bt),c=Math.imul(Je,_t),c=c+Math.imul(st,bt)|0,b=Math.imul(st,_t),_=_+Math.imul(Ze,St)|0,c=c+Math.imul(Ze,wt)|0,c=c+Math.imul(Ve,St)|0,b=b+Math.imul(Ve,wt)|0,_=_+Math.imul(be,Et)|0,c=c+Math.imul(be,xt)|0,c=c+Math.imul(Ee,Et)|0,b=b+Math.imul(Ee,xt)|0,_=_+Math.imul(oe,It)|0,c=c+Math.imul(oe,At)|0,c=c+Math.imul(Pe,It)|0,b=b+Math.imul(Pe,At)|0;var il=(A+_|0)+((c&8191)<<13)|0;A=(b+(c>>>13)|0)+(il>>>26)|0,il&=67108863,_=Math.imul(Je,St),c=Math.imul(Je,wt),c=c+Math.imul(st,St)|0,b=Math.imul(st,wt),_=_+Math.imul(Ze,Et)|0,c=c+Math.imul(Ze,xt)|0,c=c+Math.imul(Ve,Et)|0,b=b+Math.imul(Ve,xt)|0,_=_+Math.imul(be,It)|0,c=c+Math.imul(be,At)|0,c=c+Math.imul(Ee,It)|0,b=b+Math.imul(Ee,At)|0;var ol=(A+_|0)+((c&8191)<<13)|0;A=(b+(c>>>13)|0)+(ol>>>26)|0,ol&=67108863,_=Math.imul(Je,Et),c=Math.imul(Je,xt),c=c+Math.imul(st,Et)|0,b=Math.imul(st,xt),_=_+Math.imul(Ze,It)|0,c=c+Math.imul(Ze,At)|0,c=c+Math.imul(Ve,It)|0,b=b+Math.imul(Ve,At)|0;var sl=(A+_|0)+((c&8191)<<13)|0;A=(b+(c>>>13)|0)+(sl>>>26)|0,sl&=67108863,_=Math.imul(Je,It),c=Math.imul(Je,At),c=c+Math.imul(st,It)|0,b=Math.imul(st,At);var al=(A+_|0)+((c&8191)<<13)|0;return A=(b+(c>>>13)|0)+(al>>>26)|0,al&=67108863,R[0]=Kc,R[1]=Gc,R[2]=Vc,R[3]=Wc,R[4]=zc,R[5]=Yc,R[6]=$c,R[7]=Zc,R[8]=Xc,R[9]=Jc,R[10]=Qc,R[11]=el,R[12]=tl,R[13]=rl,R[14]=nl,R[15]=il,R[16]=ol,R[17]=sl,R[18]=al,A!==0&&(R[19]=A,m.length++),m};Math.imul||(T=E);function M(I,u,h){h.negative=u.negative^I.negative,h.length=I.length+u.length;for(var m=0,S=0,w=0;w<h.length-1;w++){var R=S;S=0;for(var A=m&67108863,_=Math.min(w,u.length-1),c=Math.max(0,w-I.length+1);c<=_;c++){var b=w-c,k=I.words[b]|0,L=u.words[c]|0,H=k*L,W=H&67108863;R=R+(H/67108864|0)|0,W=W+A|0,A=W&67108863,R=R+(W>>>26)|0,S+=R>>>26,R&=67108863}h.words[w]=A,m=R,R=S}return m!==0?h.words[w]=m:h.length--,h.strip()}function U(I,u,h){var m=new F;return m.mulp(I,u,h)}i.prototype.mulTo=function(u,h){var m,S=this.length+u.length;return this.length===10&&u.length===10?m=T(this,u,h):S<63?m=E(this,u,h):S<1024?m=M(this,u,h):m=U(this,u,h),m};function F(I,u){this.x=I,this.y=u}F.prototype.makeRBT=function(u){for(var h=new Array(u),m=i.prototype._countBits(u)-1,S=0;S<u;S++)h[S]=this.revBin(S,m,u);return h},F.prototype.revBin=function(u,h,m){if(u===0||u===m-1)return u;for(var S=0,w=0;w<h;w++)S|=(u&1)<<h-w-1,u>>=1;return S},F.prototype.permute=function(u,h,m,S,w,R){for(var A=0;A<R;A++)S[A]=h[u[A]],w[A]=m[u[A]]},F.prototype.transform=function(u,h,m,S,w,R){this.permute(R,u,h,m,S,w);for(var A=1;A<w;A<<=1)for(var _=A<<1,c=Math.cos(2*Math.PI/_),b=Math.sin(2*Math.PI/_),k=0;k<w;k+=_)for(var L=c,H=b,W=0;W<A;W++){var te=m[k+W],X=S[k+W],ue=m[k+W+A],fe=S[k+W+A],O=L*ue-H*fe;fe=L*fe+H*ue,ue=O,m[k+W]=te+ue,S[k+W]=X+fe,m[k+W+A]=te-ue,S[k+W+A]=X-fe,W!==_&&(O=c*L-b*H,H=c*H+b*L,L=O)}},F.prototype.guessLen13b=function(u,h){var m=Math.max(h,u)|1,S=m&1,w=0;for(m=m/2|0;m;m=m>>>1)w++;return 1<<w+1+S},F.prototype.conjugate=function(u,h,m){if(!(m<=1))for(var S=0;S<m/2;S++){var w=u[S];u[S]=u[m-S-1],u[m-S-1]=w,w=h[S],h[S]=-h[m-S-1],h[m-S-1]=-w}},F.prototype.normalize13b=function(u,h){for(var m=0,S=0;S<h/2;S++){var w=Math.round(u[2*S+1]/h)*8192+Math.round(u[2*S]/h)+m;u[S]=w&67108863,w<67108864?m=0:m=w/67108864|0}return u},F.prototype.convert13b=function(u,h,m,S){for(var w=0,R=0;R<h;R++)w=w+(u[R]|0),m[2*R]=w&8191,w=w>>>13,m[2*R+1]=w&8191,w=w>>>13;for(R=2*h;R<S;++R)m[R]=0;r(w===0),r((w&-8192)===0)},F.prototype.stub=function(u){for(var h=new Array(u),m=0;m<u;m++)h[m]=0;return h},F.prototype.mulp=function(u,h,m){var S=2*this.guessLen13b(u.length,h.length),w=this.makeRBT(S),R=this.stub(S),A=new Array(S),_=new Array(S),c=new Array(S),b=new Array(S),k=new Array(S),L=new Array(S),H=m.words;H.length=S,this.convert13b(u.words,u.length,A,S),this.convert13b(h.words,h.length,b,S),this.transform(A,R,_,c,S,w),this.transform(b,R,k,L,S,w);for(var W=0;W<S;W++){var te=_[W]*k[W]-c[W]*L[W];c[W]=_[W]*L[W]+c[W]*k[W],_[W]=te}return this.conjugate(_,c,S),this.transform(_,c,H,R,S,w),this.conjugate(H,R,S),this.normalize13b(H,S),m.negative=u.negative^h.negative,m.length=u.length+h.length,m.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),U(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,m=0;m<this.length;m++){var S=(this.words[m]|0)*u,w=(S&67108863)+(h&67108863);h>>=26,h+=S/67108864|0,h+=w>>>26,this.words[m]=w&67108863}return h!==0&&(this.words[m]=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=v(u);if(h.length===0)return new i(1);for(var m=this,S=0;S<h.length&&h[S]===0;S++,m=m.sqr());if(++S<h.length)for(var w=m.sqr();S<h.length;S++,w=w.sqr())h[S]!==0&&(m=m.mul(w));return m},i.prototype.iushln=function(u){r(typeof u=="number"&&u>=0);var h=u%26,m=(u-h)/26,S=67108863>>>26-h<<26-h,w;if(h!==0){var R=0;for(w=0;w<this.length;w++){var A=this.words[w]&S,_=(this.words[w]|0)-A<<h;this.words[w]=_|R,R=A>>>26-h}R&&(this.words[w]=R,this.length++)}if(m!==0){for(w=this.length-1;w>=0;w--)this.words[w+m]=this.words[w];for(w=0;w<m;w++)this.words[w]=0;this.length+=m}return this.strip()},i.prototype.ishln=function(u){return r(this.negative===0),this.iushln(u)},i.prototype.iushrn=function(u,h,m){r(typeof u=="number"&&u>=0);var S;h?S=(h-h%26)/26:S=0;var w=u%26,R=Math.min((u-w)/26,this.length),A=67108863^67108863>>>w<<w,_=m;if(S-=R,S=Math.max(0,S),_){for(var c=0;c<R;c++)_.words[c]=this.words[c];_.length=R}if(R!==0)if(this.length>R)for(this.length-=R,c=0;c<this.length;c++)this.words[c]=this.words[c+R];else this.words[0]=0,this.length=1;var b=0;for(c=this.length-1;c>=0&&(b!==0||c>=S);c--){var k=this.words[c]|0;this.words[c]=b<<26-w|k>>>w,b=k&A}return _&&b!==0&&(_.words[_.length++]=b),this.length===0&&(this.words[0]=0,this.length=1),this.strip()},i.prototype.ishrn=function(u,h,m){return r(this.negative===0),this.iushrn(u,h,m)},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,m=(u-h)/26,S=1<<h;if(this.length<=m)return!1;var w=this.words[m];return!!(w&S)},i.prototype.imaskn=function(u){r(typeof u=="number"&&u>=0);var h=u%26,m=(u-h)/26;if(r(this.negative===0,"imaskn works only with positive numbers"),this.length<=m)return this;if(h!==0&&m++,this.length=Math.min(m,this.length),h!==0){var S=67108863^67108863>>>h<<h;this.words[this.length-1]&=S}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,m){var S=u.length+m,w;this._expand(S);var R,A=0;for(w=0;w<u.length;w++){R=(this.words[w+m]|0)+A;var _=(u.words[w]|0)*h;R-=_&67108863,A=(R>>26)-(_/67108864|0),this.words[w+m]=R&67108863}for(;w<this.length-m;w++)R=(this.words[w+m]|0)+A,A=R>>26,this.words[w+m]=R&67108863;if(A===0)return this.strip();for(r(A===-1),A=0,w=0;w<this.length;w++)R=-(this.words[w]|0)+A,A=R>>26,this.words[w]=R&67108863;return this.negative=1,this.strip()},i.prototype._wordDiv=function(u,h){var m=this.length-u.length,S=this.clone(),w=u,R=w.words[w.length-1]|0,A=this._countBits(R);m=26-A,m!==0&&(w=w.ushln(m),S.iushln(m),R=w.words[w.length-1]|0);var _=S.length-w.length,c;if(h!=="mod"){c=new i(null),c.length=_+1,c.words=new Array(c.length);for(var b=0;b<c.length;b++)c.words[b]=0}var k=S.clone()._ishlnsubmul(w,1,_);k.negative===0&&(S=k,c&&(c.words[_]=1));for(var L=_-1;L>=0;L--){var H=(S.words[w.length+L]|0)*67108864+(S.words[w.length+L-1]|0);for(H=Math.min(H/R|0,67108863),S._ishlnsubmul(w,H,L);S.negative!==0;)H--,S.negative=0,S._ishlnsubmul(w,1,L),S.isZero()||(S.negative^=1);c&&(c.words[L]=H)}return c&&c.strip(),S.strip(),h!=="div"&&m!==0&&S.iushrn(m),{div:c||null,mod:S}},i.prototype.divmod=function(u,h,m){if(r(!u.isZero()),this.isZero())return{div:new i(0),mod:new i(0)};var S,w,R;return this.negative!==0&&u.negative===0?(R=this.neg().divmod(u,h),h!=="mod"&&(S=R.div.neg()),h!=="div"&&(w=R.mod.neg(),m&&w.negative!==0&&w.iadd(u)),{div:S,mod:w}):this.negative===0&&u.negative!==0?(R=this.divmod(u.neg(),h),h!=="mod"&&(S=R.div.neg()),{div:S,mod:R.mod}):(this.negative&u.negative)!==0?(R=this.neg().divmod(u.neg(),h),h!=="div"&&(w=R.mod.neg(),m&&w.negative!==0&&w.isub(u)),{div:R.div,mod:w}):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 m=h.mod.abs(),S=u.abs().iushrn(1),w=u.words[0]&1,R=m.cmp(S);if(R<0||w===1&&R===0)return h.div;var A=new i(1);return A.negative=this.negative^u.negative,h.div.iadd(A)},i.prototype.modn=function(u){r(u<=67108863);for(var h=(1<<26)%u,m=0,S=this.length-1;S>=0;S--)m=(h*m+(this.words[S]|0))%u;return m},i.prototype.idivn=function(u){r(u<=67108863);for(var h=0,m=this.length-1;m>=0;m--){var S=(this.words[m]|0)+h*67108864;this.words[m]=S/u|0,h=S%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,m=u.clone();h.negative!==0?h=h.umod(u):h=h.clone();for(var S=new i(1),w=new i(0),R=new i(0),A=new i(1),_=0;h.isEven()&&m.isEven();)h.iushrn(1),m.iushrn(1),++_;for(var c=m.clone(),b=h.clone();!h.isZero();){for(var k=0,L=1;(h.words[0]&L)===0&&k<26;++k,L<<=1);if(k>0)for(h.iushrn(k);k-- >0;)(S.isOdd()||w.isOdd())&&(S.iadd(c),w.isub(b)),S.iushrn(1),w.iushrn(1);for(var H=0,W=1;(m.words[0]&W)===0&&H<26;++H,W<<=1);if(H>0)for(m.iushrn(H);H-- >0;)(R.isOdd()||A.isOdd())&&(R.iadd(c),A.isub(b)),R.iushrn(1),A.iushrn(1);h.cmp(m)>=0?(h.isub(m),S.isub(R),w.isub(A)):(m.isub(h),R.isub(S),A.isub(w))}return{a:R,b:A,gcd:m.iushln(_)}},i.prototype._invmp=function(u){r(u.negative===0),r(!u.isZero());var h=this,m=u.clone();h.negative!==0?h=h.umod(u):h=h.clone();for(var S=new i(1),w=new i(0),R=m.clone();h.cmpn(1)>0&&m.cmpn(1)>0;){for(var A=0,_=1;(h.words[0]&_)===0&&A<26;++A,_<<=1);if(A>0)for(h.iushrn(A);A-- >0;)S.isOdd()&&S.iadd(R),S.iushrn(1);for(var c=0,b=1;(m.words[0]&b)===0&&c<26;++c,b<<=1);if(c>0)for(m.iushrn(c);c-- >0;)w.isOdd()&&w.iadd(R),w.iushrn(1);h.cmp(m)>=0?(h.isub(m),S.isub(w)):(m.isub(h),w.isub(S))}var k;return h.cmpn(1)===0?k=S:k=w,k.cmpn(0)<0&&k.iadd(u),k},i.prototype.gcd=function(u){if(this.isZero())return u.abs();if(u.isZero())return this.abs();var h=this.clone(),m=u.clone();h.negative=0,m.negative=0;for(var S=0;h.isEven()&&m.isEven();S++)h.iushrn(1),m.iushrn(1);do{for(;h.isEven();)h.iushrn(1);for(;m.isEven();)m.iushrn(1);var w=h.cmp(m);if(w<0){var R=h;h=m,m=R}else if(w===0||m.cmpn(1)===0)break;h.isub(m)}while(!0);return m.iushln(S)},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,m=(u-h)/26,S=1<<h;if(this.length<=m)return this._expand(m+1),this.words[m]|=S,this;for(var w=S,R=m;w!==0&&R<this.length;R++){var A=this.words[R]|0;A+=w,w=A>>>26,A&=67108863,this.words[R]=A}return w!==0&&(this.words[R]=w,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 m;if(this.length>1)m=1;else{h&&(u=-u),r(u<=67108863,"Number is too big");var S=this.words[0]|0;m=S===u?0:S<u?-1:1}return this.negative!==0?-m|0:m},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,m=this.length-1;m>=0;m--){var S=this.words[m]|0,w=u.words[m]|0;if(S!==w){S<w?h=-1:S>w&&(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 le(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(I,u){this.name=I,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,m;do this.split(h,this.tmp),h=this.imulK(h),h=h.iadd(this.tmp),m=h.bitLength();while(m>this.n);var S=m<this.n?-1:h.ucmp(this.p);return S===0?(h.words[0]=0,h.length=1):S>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 G(){z.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}n(G,z),G.prototype.split=function(u,h){for(var m=4194303,S=Math.min(u.length,9),w=0;w<S;w++)h.words[w]=u.words[w];if(h.length=S,u.length<=9){u.words[0]=0,u.length=1;return}var R=u.words[9];for(h.words[h.length++]=R&m,w=10;w<u.length;w++){var A=u.words[w]|0;u.words[w-10]=(A&m)<<4|R>>>22,R=A}R>>>=22,u.words[w-10]=R,R===0&&u.length>10?u.length-=10:u.length-=9},G.prototype.imulK=function(u){u.words[u.length]=0,u.words[u.length+1]=0,u.length+=2;for(var h=0,m=0;m<u.length;m++){var S=u.words[m]|0;h+=S*977,u.words[m]=h&67108863,h=S*64+(h/67108864|0)}return u.words[u.length-1]===0&&(u.length--,u.words[u.length-1]===0&&u.length--),u};function ie(){z.call(this,"p224","ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001")}n(ie,z);function ee(){z.call(this,"p192","ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff")}n(ee,z);function pe(){z.call(this,"25519","7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed")}n(pe,z),pe.prototype.imulK=function(u){for(var h=0,m=0;m<u.length;m++){var S=(u.words[m]|0)*19+h,w=S&67108863;S>>>=26,u.words[m]=w,h=S}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 G;else if(u==="p224")h=new ie;else if(u==="p192")h=new ee;else if(u==="p25519")h=new pe;else throw new Error("Unknown prime "+u);return V[u]=h,h};function le(I){if(typeof I=="string"){var u=i._prime(I);this.m=u.p,this.prime=u}else r(I.gtn(1),"modulus must be greater than 1"),this.m=I,this.prime=null}le.prototype._verify1=function(u){r(u.negative===0,"red works only with positives"),r(u.red,"red works only with red numbers")},le.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")},le.prototype.imod=function(u){return this.prime?this.prime.ireduce(u)._forceRed(this):u.umod(this.m)._forceRed(this)},le.prototype.neg=function(u){return u.isZero()?u.clone():this.m.sub(u)._forceRed(this)},le.prototype.add=function(u,h){this._verify2(u,h);var m=u.add(h);return m.cmp(this.m)>=0&&m.isub(this.m),m._forceRed(this)},le.prototype.iadd=function(u,h){this._verify2(u,h);var m=u.iadd(h);return m.cmp(this.m)>=0&&m.isub(this.m),m},le.prototype.sub=function(u,h){this._verify2(u,h);var m=u.sub(h);return m.cmpn(0)<0&&m.iadd(this.m),m._forceRed(this)},le.prototype.isub=function(u,h){this._verify2(u,h);var m=u.isub(h);return m.cmpn(0)<0&&m.iadd(this.m),m},le.prototype.shl=function(u,h){return this._verify1(u),this.imod(u.ushln(h))},le.prototype.imul=function(u,h){return this._verify2(u,h),this.imod(u.imul(h))},le.prototype.mul=function(u,h){return this._verify2(u,h),this.imod(u.mul(h))},le.prototype.isqr=function(u){return this.imul(u,u.clone())},le.prototype.sqr=function(u){return this.mul(u,u)},le.prototype.sqrt=function(u){if(u.isZero())return u.clone();var h=this.m.andln(3);if(r(h%2===1),h===3){var m=this.m.add(new i(1)).iushrn(2);return this.pow(u,m)}for(var S=this.m.subn(1),w=0;!S.isZero()&&S.andln(1)===0;)w++,S.iushrn(1);r(!S.isZero());var R=new i(1).toRed(this),A=R.redNeg(),_=this.m.subn(1).iushrn(1),c=this.m.bitLength();for(c=new i(2*c*c).toRed(this);this.pow(c,_).cmp(A)!==0;)c.redIAdd(A);for(var b=this.pow(c,S),k=this.pow(u,S.addn(1).iushrn(1)),L=this.pow(u,S),H=w;L.cmp(R)!==0;){for(var W=L,te=0;W.cmp(R)!==0;te++)W=W.redSqr();r(te<H);var X=this.pow(b,new i(1).iushln(H-te-1));k=k.redMul(X),b=X.redSqr(),L=L.redMul(b),H=te}return k},le.prototype.invm=function(u){var h=u._invmp(this.m);return h.negative!==0?(h.negative=0,this.imod(h).redNeg()):this.imod(h)},le.prototype.pow=function(u,h){if(h.isZero())return new i(1).toRed(this);if(h.cmpn(1)===0)return u.clone();var m=4,S=new Array(1<<m);S[0]=new i(1).toRed(this),S[1]=u;for(var w=2;w<S.length;w++)S[w]=this.mul(S[w-1],u);var R=S[0],A=0,_=0,c=h.bitLength()%26;for(c===0&&(c=26),w=h.length-1;w>=0;w--){for(var b=h.words[w],k=c-1;k>=0;k--){var L=b>>k&1;if(R!==S[0]&&(R=this.sqr(R)),L===0&&A===0){_=0;continue}A<<=1,A|=L,_++,!(_!==m&&(w!==0||k!==0))&&(R=this.mul(R,S[A]),_=0,A=0)}c=26}return R},le.prototype.convertTo=function(u){var h=u.umod(this.m);return h===u?h.clone():h},le.prototype.convertFrom=function(u){var h=u.clone();return h.red=null,h},i.mont=function(u){return new me(u)};function me(I){le.call(this,I),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(me,le),me.prototype.convertTo=function(u){return this.imod(u.ushln(this.shift))},me.prototype.convertFrom=function(u){var h=this.imod(u.mul(this.rinv));return h.red=null,h},me.prototype.imul=function(u,h){if(u.isZero()||h.isZero())return u.words[0]=0,u.length=1,u;var m=u.imul(h),S=m.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),w=m.isub(S).iushrn(this.shift),R=w;return w.cmp(this.m)>=0?R=w.isub(this.m):w.cmpn(0)<0&&(R=w.iadd(this.m)),R._forceRed(this)},me.prototype.mul=function(u,h){if(u.isZero()||h.isZero())return new i(0)._forceRed(this);var m=u.mul(h),S=m.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),w=m.isub(S).iushrn(this.shift),R=w;return w.cmp(this.m)>=0?R=w.isub(this.m):w.cmpn(0)<0&&(R=w.iadd(this.m)),R._forceRed(this)},me.prototype.invm=function(u){var h=this.imod(u._invmp(this.m).mul(this.r2));return h._forceRed(this)}})(typeof wl>"u"||wl,C0)});var Fe=B((ZC,El)=>{p();typeof Object.create=="function"?El.exports=function(t,r){r&&(t.super_=r,t.prototype=Object.create(r.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}))}:El.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 Gt=B((xl,U0)=>{p();var tu=Nt(),Zr=tu.Buffer;function D0(e,t){for(var r in e)t[r]=e[r]}Zr.from&&Zr.alloc&&Zr.allocUnsafe&&Zr.allocUnsafeSlow?U0.exports=tu:(D0(tu,xl),xl.Buffer=Ii);function Ii(e,t,r){return Zr(e,t,r)}Ii.prototype=Object.create(Zr.prototype);D0(Zr,Ii);Ii.from=function(e,t,r){if(typeof e=="number")throw new TypeError("Argument must not be a number");return Zr(e,t,r)};Ii.alloc=function(e,t,r){if(typeof e!="number")throw new TypeError("Argument must be a number");var n=Zr(e);return t!==void 0?typeof r=="string"?n.fill(t,r):n.fill(t):n.fill(0),n};Ii.allocUnsafe=function(e){if(typeof e!="number")throw new TypeError("Argument must be a number");return Zr(e)};Ii.allocUnsafeSlow=function(e){if(typeof e!="number")throw new TypeError("Argument must be a number");return tu.SlowBuffer(e)}});var go=B((QC,Il)=>{"use strict";p();var po=typeof Reflect=="object"?Reflect:null,F0=po&&typeof po.apply=="function"?po.apply:function(t,r,n){return Function.prototype.apply.call(t,r,n)},ru;po&&typeof po.ownKeys=="function"?ru=po.ownKeys:Object.getOwnPropertySymbols?ru=function(t){return Object.getOwnPropertyNames(t).concat(Object.getOwnPropertySymbols(t))}:ru=function(t){return Object.getOwnPropertyNames(t)};function tA(e){console&&console.warn&&console.warn(e)}var H0=Number.isNaN||function(t){return t!==t};function De(){De.init.call(this)}Il.exports=De;Il.exports.once=oA;De.EventEmitter=De;De.prototype._events=void 0;De.prototype._eventsCount=0;De.prototype._maxListeners=void 0;var q0=10;function nu(e){if(typeof e!="function")throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof e)}Object.defineProperty(De,"defaultMaxListeners",{enumerable:!0,get:function(){return q0},set:function(e){if(typeof e!="number"||e<0||H0(e))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+e+".");q0=e}});De.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};De.prototype.setMaxListeners=function(t){if(typeof t!="number"||t<0||H0(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 j0(e){return e._maxListeners===void 0?De.defaultMaxListeners:e._maxListeners}De.prototype.getMaxListeners=function(){return j0(this)};De.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 f=o[t];if(f===void 0)return!1;if(typeof f=="function")F0(f,this,r);else for(var l=f.length,y=z0(f,l),n=0;n<l;++n)F0(y[n],this,r);return!0};function K0(e,t,r,n){var i,o,s;if(nu(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=j0(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,tA(a)}return e}De.prototype.addListener=function(t,r){return K0(this,t,r,!1)};De.prototype.on=De.prototype.addListener;De.prototype.prependListener=function(t,r){return K0(this,t,r,!0)};function rA(){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 G0(e,t,r){var n={fired:!1,wrapFn:void 0,target:e,type:t,listener:r},i=rA.bind(n);return i.listener=r,n.wrapFn=i,i}De.prototype.once=function(t,r){return nu(r),this.on(t,G0(this,t,r)),this};De.prototype.prependOnceListener=function(t,r){return nu(r),this.prependListener(t,G0(this,t,r)),this};De.prototype.removeListener=function(t,r){var n,i,o,s,a;if(nu(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():nA(n,o),n.length===1&&(i[t]=n[0]),i.removeListener!==void 0&&this.emit("removeListener",t,a||r)}return this};De.prototype.off=De.prototype.removeListener;De.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 V0(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?iA(i):z0(i,i.length)}De.prototype.listeners=function(t){return V0(this,t,!0)};De.prototype.rawListeners=function(t){return V0(this,t,!1)};De.listenerCount=function(e,t){return typeof e.listenerCount=="function"?e.listenerCount(t):W0.call(e,t)};De.prototype.listenerCount=W0;function W0(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}De.prototype.eventNames=function(){return this._eventsCount>0?ru(this._events):[]};function z0(e,t){for(var r=new Array(t),n=0;n<t;++n)r[n]=e[n];return r}function nA(e,t){for(;t+1<e.length;t++)e[t]=e[t+1];e.pop()}function iA(e){for(var t=new Array(e.length),r=0;r<t.length;++r)t[r]=e[r].listener||e[r];return t}function oA(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))}Y0(e,t,o,{once:!0}),t!=="error"&&sA(e,i,{once:!0})})}function sA(e,t,r){typeof e.on=="function"&&Y0(e,"error",t,r)}function Y0(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 Al=B((tL,$0)=>{p();$0.exports=go().EventEmitter});var iu=B((nL,Z0)=>{"use strict";p();Z0.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 ys=B((oL,X0)=>{"use strict";p();var aA=iu();X0.exports=function(){return aA()&&!!Symbol.toStringTag}});var ou=B((aL,J0)=>{"use strict";p();J0.exports=Object});var eg=B((fL,Q0)=>{"use strict";p();Q0.exports=Error});var rg=B((lL,tg)=>{"use strict";p();tg.exports=EvalError});var ig=B((dL,ng)=>{"use strict";p();ng.exports=RangeError});var sg=B((gL,og)=>{"use strict";p();og.exports=ReferenceError});var Ol=B((mL,ag)=>{"use strict";p();ag.exports=SyntaxError});var Ai=B((bL,ug)=>{"use strict";p();ug.exports=TypeError});var cg=B((SL,fg)=>{"use strict";p();fg.exports=URIError});var hg=B((EL,lg)=>{"use strict";p();lg.exports=Math.abs});var pg=B((IL,dg)=>{"use strict";p();dg.exports=Math.floor});var yg=B((OL,gg)=>{"use strict";p();gg.exports=Math.max});var vg=B((TL,mg)=>{"use strict";p();mg.exports=Math.min});var _g=B((BL,bg)=>{"use strict";p();bg.exports=Math.pow});var wg=B((ML,Sg)=>{"use strict";p();Sg.exports=Math.round});var xg=B((CL,Eg)=>{"use strict";p();Eg.exports=Number.isNaN||function(t){return t!==t}});var Ag=B((DL,Ig)=>{"use strict";p();var uA=xg();Ig.exports=function(t){return uA(t)||t===0?t:t<0?-1:1}});var Rg=B((FL,Og)=>{"use strict";p();Og.exports=Object.getOwnPropertyDescriptor});var Oi=B((HL,Tg)=>{"use strict";p();var su=Rg();if(su)try{su([],"length")}catch{su=null}Tg.exports=su});var ms=B((KL,Pg)=>{"use strict";p();var au=Object.defineProperty||!1;if(au)try{au({},"a",{value:1})}catch{au=!1}Pg.exports=au});var Mg=B((VL,Ng)=>{"use strict";p();var Bg=typeof Symbol<"u"&&Symbol,fA=iu();Ng.exports=function(){return typeof Bg!="function"||typeof Symbol!="function"||typeof Bg("foo")!="symbol"||typeof Symbol("bar")!="symbol"?!1:fA()}});var Rl=B((zL,kg)=>{"use strict";p();kg.exports=typeof Reflect<"u"&&Reflect.getPrototypeOf||null});var Tl=B(($L,Cg)=>{"use strict";p();var cA=ou();Cg.exports=cA.getPrototypeOf||null});var Ug=B((XL,Dg)=>{"use strict";p();var lA="Function.prototype.bind called on incompatible ",hA=Object.prototype.toString,dA=Math.max,pA="[object Function]",Lg=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},gA=function(t,r){for(var n=[],i=r||0,o=0;i<t.length;i+=1,o+=1)n[o]=t[i];return n},yA=function(e,t){for(var r="",n=0;n<e.length;n+=1)r+=e[n],n+1<e.length&&(r+=t);return r};Dg.exports=function(t){var r=this;if(typeof r!="function"||hA.apply(r)!==pA)throw new TypeError(lA+r);for(var n=gA(arguments,1),i,o=function(){if(this instanceof i){var y=r.apply(this,Lg(n,arguments));return Object(y)===y?y:this}return r.apply(t,Lg(n,arguments))},s=dA(0,r.length-n.length),a=[],f=0;f<s;f++)a[f]="$"+f;if(i=Function("binder","return function ("+yA(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 yo=B((QL,Fg)=>{"use strict";p();var mA=Ug();Fg.exports=Function.prototype.bind||mA});var uu=B((t8,qg)=>{"use strict";p();qg.exports=Function.prototype.call});var fu=B((n8,Hg)=>{"use strict";p();Hg.exports=Function.prototype.apply});var Kg=B((o8,jg)=>{"use strict";p();jg.exports=typeof Reflect<"u"&&Reflect&&Reflect.apply});var Pl=B((a8,Gg)=>{"use strict";p();var vA=yo(),bA=fu(),_A=uu(),SA=Kg();Gg.exports=SA||vA.call(_A,bA)});var cu=B((f8,Vg)=>{"use strict";p();var wA=yo(),EA=Ai(),xA=uu(),IA=Pl();Vg.exports=function(t){if(t.length<1||typeof t[0]!="function")throw new EA("a function is required");return IA(wA,xA,t)}});var Xg=B((l8,Zg)=>{"use strict";p();var AA=cu(),Wg=Oi(),Yg;try{Yg=[].__proto__===Array.prototype}catch(e){if(!e||typeof e!="object"||!("code"in e)||e.code!=="ERR_PROTO_ACCESS")throw e}var Bl=!!Yg&&Wg&&Wg(Object.prototype,"__proto__"),$g=Object,zg=$g.getPrototypeOf;Zg.exports=Bl&&typeof Bl.get=="function"?AA([Bl.get]):typeof zg=="function"?function(t){return zg(t==null?t:$g(t))}:!1});var lu=B((d8,ty)=>{"use strict";p();var Jg=Rl(),Qg=Tl(),ey=Xg();ty.exports=Jg?function(t){return Jg(t)}:Qg?function(t){if(!t||typeof t!="object"&&typeof t!="function")throw new TypeError("getProto: not an object");return Qg(t)}:ey?function(t){return ey(t)}:null});var Nl=B((g8,ry)=>{"use strict";p();var OA=Function.prototype.call,RA=Object.prototype.hasOwnProperty,TA=yo();ry.exports=TA.call(OA,RA)});var pu=B((m8,uy)=>{"use strict";p();var xe,PA=ou(),BA=eg(),NA=rg(),MA=ig(),kA=sg(),_o=Ol(),bo=Ai(),CA=cg(),LA=hg(),DA=pg(),UA=yg(),FA=vg(),qA=_g(),HA=wg(),jA=Ag(),sy=Function,Ml=function(e){try{return sy('"use strict"; return ('+e+").constructor;")()}catch{}},vs=Oi(),KA=ms(),kl=function(){throw new bo},GA=vs?(function(){try{return arguments.callee,kl}catch{try{return vs(arguments,"callee").get}catch{return kl}}})():kl,mo=Mg()(),Ft=lu(),VA=Tl(),WA=Rl(),ay=fu(),bs=uu(),vo={},zA=typeof Uint8Array>"u"||!Ft?xe:Ft(Uint8Array),Ri={__proto__:null,"%AggregateError%":typeof AggregateError>"u"?xe:AggregateError,"%Array%":Array,"%ArrayBuffer%":typeof ArrayBuffer>"u"?xe:ArrayBuffer,"%ArrayIteratorPrototype%":mo&&Ft?Ft([][Symbol.iterator]()):xe,"%AsyncFromSyncIteratorPrototype%":xe,"%AsyncFunction%":vo,"%AsyncGenerator%":vo,"%AsyncGeneratorFunction%":vo,"%AsyncIteratorPrototype%":vo,"%Atomics%":typeof Atomics>"u"?xe:Atomics,"%BigInt%":typeof BigInt>"u"?xe:BigInt,"%BigInt64Array%":typeof BigInt64Array>"u"?xe:BigInt64Array,"%BigUint64Array%":typeof BigUint64Array>"u"?xe:BigUint64Array,"%Boolean%":Boolean,"%DataView%":typeof DataView>"u"?xe:DataView,"%Date%":Date,"%decodeURI%":decodeURI,"%decodeURIComponent%":decodeURIComponent,"%encodeURI%":encodeURI,"%encodeURIComponent%":encodeURIComponent,"%Error%":BA,"%eval%":eval,"%EvalError%":NA,"%Float16Array%":typeof Float16Array>"u"?xe:Float16Array,"%Float32Array%":typeof Float32Array>"u"?xe:Float32Array,"%Float64Array%":typeof Float64Array>"u"?xe:Float64Array,"%FinalizationRegistry%":typeof FinalizationRegistry>"u"?xe:FinalizationRegistry,"%Function%":sy,"%GeneratorFunction%":vo,"%Int8Array%":typeof Int8Array>"u"?xe:Int8Array,"%Int16Array%":typeof Int16Array>"u"?xe:Int16Array,"%Int32Array%":typeof Int32Array>"u"?xe:Int32Array,"%isFinite%":isFinite,"%isNaN%":isNaN,"%IteratorPrototype%":mo&&Ft?Ft(Ft([][Symbol.iterator]())):xe,"%JSON%":typeof JSON=="object"?JSON:xe,"%Map%":typeof Map>"u"?xe:Map,"%MapIteratorPrototype%":typeof Map>"u"||!mo||!Ft?xe:Ft(new Map()[Symbol.iterator]()),"%Math%":Math,"%Number%":Number,"%Object%":PA,"%Object.getOwnPropertyDescriptor%":vs,"%parseFloat%":parseFloat,"%parseInt%":parseInt,"%Promise%":typeof Promise>"u"?xe:Promise,"%Proxy%":typeof Proxy>"u"?xe:Proxy,"%RangeError%":MA,"%ReferenceError%":kA,"%Reflect%":typeof Reflect>"u"?xe:Reflect,"%RegExp%":RegExp,"%Set%":typeof Set>"u"?xe:Set,"%SetIteratorPrototype%":typeof Set>"u"||!mo||!Ft?xe:Ft(new Set()[Symbol.iterator]()),"%SharedArrayBuffer%":typeof SharedArrayBuffer>"u"?xe:SharedArrayBuffer,"%String%":String,"%StringIteratorPrototype%":mo&&Ft?Ft(""[Symbol.iterator]()):xe,"%Symbol%":mo?Symbol:xe,"%SyntaxError%":_o,"%ThrowTypeError%":GA,"%TypedArray%":zA,"%TypeError%":bo,"%Uint8Array%":typeof Uint8Array>"u"?xe:Uint8Array,"%Uint8ClampedArray%":typeof Uint8ClampedArray>"u"?xe:Uint8ClampedArray,"%Uint16Array%":typeof Uint16Array>"u"?xe:Uint16Array,"%Uint32Array%":typeof Uint32Array>"u"?xe:Uint32Array,"%URIError%":CA,"%WeakMap%":typeof WeakMap>"u"?xe:WeakMap,"%WeakRef%":typeof WeakRef>"u"?xe:WeakRef,"%WeakSet%":typeof WeakSet>"u"?xe:WeakSet,"%Function.prototype.call%":bs,"%Function.prototype.apply%":ay,"%Object.defineProperty%":KA,"%Object.getPrototypeOf%":VA,"%Math.abs%":LA,"%Math.floor%":DA,"%Math.max%":UA,"%Math.min%":FA,"%Math.pow%":qA,"%Math.round%":HA,"%Math.sign%":jA,"%Reflect.getPrototypeOf%":WA};if(Ft)try{null.error}catch(e){ny=Ft(Ft(e)),Ri["%Error.prototype%"]=ny}var ny,YA=function e(t){var r;if(t==="%AsyncFunction%")r=Ml("async function () {}");else if(t==="%GeneratorFunction%")r=Ml("function* () {}");else if(t==="%AsyncGeneratorFunction%")r=Ml("async function* () {}");else if(t==="%AsyncGenerator%"){var n=e("%AsyncGeneratorFunction%");n&&(r=n.prototype)}else if(t==="%AsyncIteratorPrototype%"){var i=e("%AsyncGenerator%");i&&Ft&&(r=Ft(i.prototype))}return Ri[t]=r,r},iy={__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"]},_s=yo(),hu=Nl(),$A=_s.call(bs,Array.prototype.concat),ZA=_s.call(ay,Array.prototype.splice),oy=_s.call(bs,String.prototype.replace),du=_s.call(bs,String.prototype.slice),XA=_s.call(bs,RegExp.prototype.exec),JA=/[^%.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|%$))/g,QA=/\\(\\)?/g,eO=function(t){var r=du(t,0,1),n=du(t,-1);if(r==="%"&&n!=="%")throw new _o("invalid intrinsic syntax, expected closing `%`");if(n==="%"&&r!=="%")throw new _o("invalid intrinsic syntax, expected opening `%`");var i=[];return oy(t,JA,function(o,s,a,f){i[i.length]=a?oy(f,QA,"$1"):s||o}),i},tO=function(t,r){var n=t,i;if(hu(iy,n)&&(i=iy[n],n="%"+i[0]+"%"),hu(Ri,n)){var o=Ri[n];if(o===vo&&(o=YA(n)),typeof o>"u"&&!r)throw new bo("intrinsic "+t+" exists, but is not available. Please file an issue!");return{alias:i,name:n,value:o}}throw new _o("intrinsic "+t+" does not exist!")};uy.exports=function(t,r){if(typeof t!="string"||t.length===0)throw new bo("intrinsic name must be a non-empty string");if(arguments.length>1&&typeof r!="boolean")throw new bo('"allowMissing" argument must be a boolean');if(XA(/^%?[^%]*%?$/,t)===null)throw new _o("`%` may not be present anywhere but at the beginning and end of the intrinsic name");var n=eO(t),i=n.length>0?n[0]:"",o=tO("%"+i+"%",r),s=o.name,a=o.value,f=!1,l=o.alias;l&&(i=l[0],ZA(n,$A([0,1],l)));for(var y=1,g=!0;y<n.length;y+=1){var v=n[y],E=du(v,0,1),T=du(v,-1);if((E==='"'||E==="'"||E==="`"||T==='"'||T==="'"||T==="`")&&E!==T)throw new _o("property names with quotes must have matching quotes");if((v==="constructor"||!g)&&(f=!0),i+="."+v,s="%"+i+"%",hu(Ri,s))a=Ri[s];else if(a!=null){if(!(v in a)){if(!r)throw new bo("base intrinsic for "+t+" exists, but the property is not available.");return}if(vs&&y+1>=n.length){var M=vs(a,v);g=!!M,g&&"get"in M&&!("originalValue"in M.get)?a=M.get:a=a[v]}else g=hu(a,v),a=a[v];g&&!f&&(Ri[s]=a)}}return a}});var Gn=B((b8,ly)=>{"use strict";p();var fy=pu(),cy=cu(),rO=cy([fy("%String.prototype.indexOf%")]);ly.exports=function(t,r){var n=fy(t,!!r);return typeof n=="function"&&rO(t,".prototype.")>-1?cy([n]):n}});var py=B((S8,dy)=>{"use strict";p();var nO=ys()(),iO=Gn(),Cl=iO("Object.prototype.toString"),gu=function(t){return nO&&t&&typeof t=="object"&&Symbol.toStringTag in t?!1:Cl(t)==="[object Arguments]"},hy=function(t){return gu(t)?!0:t!==null&&typeof t=="object"&&"length"in t&&typeof t.length=="number"&&t.length>=0&&Cl(t)!=="[object Array]"&&"callee"in t&&Cl(t.callee)==="[object Function]"},oO=(function(){return gu(arguments)})();gu.isLegacyArguments=hy;dy.exports=oO?gu:hy});var _y=B((E8,by)=>{"use strict";p();var gy=Gn(),sO=ys()(),aO=Nl(),uO=Oi(),Ul;sO?(yy=gy("RegExp.prototype.exec"),Ll={},yu=function(){throw Ll},Dl={toString:yu,valueOf:yu},typeof Symbol.toPrimitive=="symbol"&&(Dl[Symbol.toPrimitive]=yu),Ul=function(t){if(!t||typeof t!="object")return!1;var r=uO(t,"lastIndex"),n=r&&aO(r,"value");if(!n)return!1;try{yy(t,Dl)}catch(i){return i===Ll}}):(my=gy("Object.prototype.toString"),vy="[object RegExp]",Ul=function(t){return!t||typeof t!="object"&&typeof t!="function"?!1:my(t)===vy});var yy,Ll,yu,Dl,my,vy;by.exports=Ul});var wy=B((I8,Sy)=>{"use strict";p();var fO=Gn(),cO=_y(),lO=fO("RegExp.prototype.exec"),hO=Ai();Sy.exports=function(t){if(!cO(t))throw new hO("`regex` must be a RegExp");return function(n){return lO(t,n)!==null}}});var xy=B((O8,Ey)=>{"use strict";p();var dO=function*(){}.constructor;Ey.exports=()=>dO});var Ry=B((T8,Oy)=>{"use strict";p();var Ay=Gn(),pO=wy(),gO=pO(/^\s*(?:function)?\*/),yO=ys()(),Iy=lu(),mO=Ay("Object.prototype.toString"),vO=Ay("Function.prototype.toString"),bO=xy();Oy.exports=function(t){if(typeof t!="function")return!1;if(gO(vO(t)))return!0;if(!yO){var r=mO(t);return r==="[object GeneratorFunction]"}if(!Iy)return!1;var n=bO();return n&&Iy(t)===n.prototype}});var Ny=B((B8,By)=>{"use strict";p();var Py=Function.prototype.toString,So=typeof Reflect=="object"&&Reflect!==null&&Reflect.apply,ql,mu;if(typeof So=="function"&&typeof Object.defineProperty=="function")try{ql=Object.defineProperty({},"length",{get:function(){throw mu}}),mu={},So(function(){throw 42},null,ql)}catch(e){e!==mu&&(So=null)}else So=null;var _O=/^\s*class\b/,Hl=function(t){try{var r=Py.call(t);return _O.test(r)}catch{return!1}},Fl=function(t){try{return Hl(t)?!1:(Py.call(t),!0)}catch{return!1}},vu=Object.prototype.toString,SO="[object Object]",wO="[object Function]",EO="[object GeneratorFunction]",xO="[object HTMLAllCollection]",IO="[object HTML document.all class]",AO="[object HTMLCollection]",OO=typeof Symbol=="function"&&!!Symbol.toStringTag,RO=!(0 in[,]),jl=function(){return!1};typeof document=="object"&&(Ty=document.all,vu.call(Ty)===vu.call(document.all)&&(jl=function(t){if((RO||!t)&&(typeof t>"u"||typeof t=="object"))try{var r=vu.call(t);return(r===xO||r===IO||r===AO||r===SO)&&t("")==null}catch{}return!1}));var Ty;By.exports=So?function(t){if(jl(t))return!0;if(!t||typeof t!="function"&&typeof t!="object")return!1;try{So(t,null,ql)}catch(r){if(r!==mu)return!1}return!Hl(t)&&Fl(t)}:function(t){if(jl(t))return!0;if(!t||typeof t!="function"&&typeof t!="object")return!1;if(OO)return Fl(t);if(Hl(t))return!1;var r=vu.call(t);return r!==wO&&r!==EO&&!/^\[object HTML/.test(r)?!1:Fl(t)}});var Cy=B((M8,ky)=>{"use strict";p();var TO=Ny(),PO=Object.prototype.toString,My=Object.prototype.hasOwnProperty,BO=function(t,r,n){for(var i=0,o=t.length;i<o;i++)My.call(t,i)&&(n==null?r(t[i],i,t):r.call(n,t[i],i,t))},NO=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)},MO=function(t,r,n){for(var i in t)My.call(t,i)&&(n==null?r(t[i],i,t):r.call(n,t[i],i,t))};function kO(e){return PO.call(e)==="[object Array]"}ky.exports=function(t,r,n){if(!TO(r))throw new TypeError("iterator must be a function");var i;arguments.length>=3&&(i=n),kO(t)?BO(t,r,i):typeof t=="string"?NO(t,r,i):MO(t,r,i)}});var Dy=B((C8,Ly)=>{"use strict";p();Ly.exports=["Float16Array","Float32Array","Float64Array","Int8Array","Int16Array","Int32Array","Uint8Array","Uint8ClampedArray","Uint16Array","Uint32Array","BigInt64Array","BigUint64Array"]});var Fy=B((D8,Uy)=>{"use strict";p();var Kl=Dy(),CO=globalThis;Uy.exports=function(){for(var t=[],r=0;r<Kl.length;r++)typeof CO[Kl[r]]=="function"&&(t[t.length]=Kl[r]);return t}});var Gl=B((F8,jy)=>{"use strict";p();var qy=ms(),LO=Ol(),wo=Ai(),Hy=Oi();jy.exports=function(t,r,n){if(!t||typeof t!="object"&&typeof t!="function")throw new wo("`obj` must be an object or a function`");if(typeof r!="string"&&typeof r!="symbol")throw new wo("`property` must be a string or a symbol`");if(arguments.length>3&&typeof arguments[3]!="boolean"&&arguments[3]!==null)throw new wo("`nonEnumerable`, if provided, must be a boolean or null");if(arguments.length>4&&typeof arguments[4]!="boolean"&&arguments[4]!==null)throw new wo("`nonWritable`, if provided, must be a boolean or null");if(arguments.length>5&&typeof arguments[5]!="boolean"&&arguments[5]!==null)throw new wo("`nonConfigurable`, if provided, must be a boolean or null");if(arguments.length>6&&typeof arguments[6]!="boolean")throw new wo("`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,f=!!Hy&&Hy(t,r);if(qy)qy(t,r,{configurable:s===null&&f?f.configurable:!s,enumerable:i===null&&f?f.enumerable:!i,value:n,writable:o===null&&f?f.writable:!o});else if(a||!i&&!o&&!s)t[r]=n;else throw new LO("This environment does not support defining a property as non-configurable, non-writable, or non-enumerable.")}});var Wl=B((H8,Gy)=>{"use strict";p();var Vl=ms(),Ky=function(){return!!Vl};Ky.hasArrayLengthDefineBug=function(){if(!Vl)return null;try{return Vl([],"length",{value:1}).length!==1}catch{return!0}};Gy.exports=Ky});var $y=B((K8,Yy)=>{"use strict";p();var DO=pu(),Vy=Gl(),UO=Wl()(),Wy=Oi(),zy=Ai(),FO=DO("%Math.floor%");Yy.exports=function(t,r){if(typeof t!="function")throw new zy("`fn` is not a function");if(typeof r!="number"||r<0||r>4294967295||FO(r)!==r)throw new zy("`length` must be a positive 32-bit integer");var n=arguments.length>2&&!!arguments[2],i=!0,o=!0;if("length"in t&&Wy){var s=Wy(t,"length");s&&!s.configurable&&(i=!1),s&&!s.writable&&(o=!1)}return(i||o||!n)&&(UO?Vy(t,"length",r,!0,!0):Vy(t,"length",r)),t}});var Xy=B((V8,Zy)=>{"use strict";p();var qO=yo(),HO=fu(),jO=Pl();Zy.exports=function(){return jO(qO,HO,arguments)}});var Ss=B((z8,bu)=>{"use strict";p();var KO=$y(),Jy=ms(),GO=cu(),Qy=Xy();bu.exports=function(t){var r=GO(arguments),n=1+t.length-(arguments.length-1);return KO(r,n>0?n:0,!0)};Jy?Jy(bu.exports,"apply",{value:Qy}):bu.exports.apply=Qy});var Zl=B(($8,nm)=>{"use strict";p();var wu=Cy(),VO=Fy(),em=Ss(),Yl=Gn(),Su=Oi(),_u=lu(),WO=Yl("Object.prototype.toString"),rm=ys()(),tm=globalThis,zl=VO(),$l=Yl("String.prototype.slice"),zO=Yl("Array.prototype.indexOf",!0)||function(t,r){for(var n=0;n<t.length;n+=1)if(t[n]===r)return n;return-1},Eu={__proto__:null};rm&&Su&&_u?wu(zl,function(e){var t=new tm[e];if(Symbol.toStringTag in t&&_u){var r=_u(t),n=Su(r,Symbol.toStringTag);if(!n&&r){var i=_u(r);n=Su(i,Symbol.toStringTag)}if(n&&n.get){var o=em(n.get);Eu["$"+e]=o}}}):wu(zl,function(e){var t=new tm[e],r=t.slice||t.set;if(r){var n=em(r);Eu["$"+e]=n}});var YO=function(t){var r=!1;return wu(Eu,function(n,i){if(!r)try{"$"+n(t)===i&&(r=$l(i,1))}catch{}}),r},$O=function(t){var r=!1;return wu(Eu,function(n,i){if(!r)try{n(t),r=$l(i,1)}catch{}}),r};nm.exports=function(t){if(!t||typeof t!="object")return!1;if(!rm){var r=$l(WO(t),8,-1);return zO(zl,r)>-1?r:r!=="Object"?!1:$O(t)}return Su?YO(t):null}});var Xl=B((X8,im)=>{"use strict";p();var ZO=Zl();im.exports=function(t){return!!ZO(t)}});var vm=B(Ie=>{"use strict";p();var XO=py(),JO=Ry(),Tr=Zl(),om=Xl();function Eo(e){return e.call.bind(e)}var sm=typeof BigInt<"u",am=typeof Symbol<"u",br=Eo(Object.prototype.toString),QO=Eo(Number.prototype.valueOf),eR=Eo(String.prototype.valueOf),tR=Eo(Boolean.prototype.valueOf);sm&&(um=Eo(BigInt.prototype.valueOf));var um;am&&(fm=Eo(Symbol.prototype.valueOf));var fm;function Es(e,t){if(typeof e!="object")return!1;try{return t(e),!0}catch{return!1}}Ie.isArgumentsObject=XO;Ie.isGeneratorFunction=JO;Ie.isTypedArray=om;function rR(e){return typeof Promise<"u"&&e instanceof Promise||e!==null&&typeof e=="object"&&typeof e.then=="function"&&typeof e.catch=="function"}Ie.isPromise=rR;function nR(e){return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?ArrayBuffer.isView(e):om(e)||lm(e)}Ie.isArrayBufferView=nR;function iR(e){return Tr(e)==="Uint8Array"}Ie.isUint8Array=iR;function oR(e){return Tr(e)==="Uint8ClampedArray"}Ie.isUint8ClampedArray=oR;function sR(e){return Tr(e)==="Uint16Array"}Ie.isUint16Array=sR;function aR(e){return Tr(e)==="Uint32Array"}Ie.isUint32Array=aR;function uR(e){return Tr(e)==="Int8Array"}Ie.isInt8Array=uR;function fR(e){return Tr(e)==="Int16Array"}Ie.isInt16Array=fR;function cR(e){return Tr(e)==="Int32Array"}Ie.isInt32Array=cR;function lR(e){return Tr(e)==="Float32Array"}Ie.isFloat32Array=lR;function hR(e){return Tr(e)==="Float64Array"}Ie.isFloat64Array=hR;function dR(e){return Tr(e)==="BigInt64Array"}Ie.isBigInt64Array=dR;function pR(e){return Tr(e)==="BigUint64Array"}Ie.isBigUint64Array=pR;function xu(e){return br(e)==="[object Map]"}xu.working=typeof Map<"u"&&xu(new Map);function gR(e){return typeof Map>"u"?!1:xu.working?xu(e):e instanceof Map}Ie.isMap=gR;function Iu(e){return br(e)==="[object Set]"}Iu.working=typeof Set<"u"&&Iu(new Set);function yR(e){return typeof Set>"u"?!1:Iu.working?Iu(e):e instanceof Set}Ie.isSet=yR;function Au(e){return br(e)==="[object WeakMap]"}Au.working=typeof WeakMap<"u"&&Au(new WeakMap);function mR(e){return typeof WeakMap>"u"?!1:Au.working?Au(e):e instanceof WeakMap}Ie.isWeakMap=mR;function Ql(e){return br(e)==="[object WeakSet]"}Ql.working=typeof WeakSet<"u"&&Ql(new WeakSet);function vR(e){return Ql(e)}Ie.isWeakSet=vR;function Ou(e){return br(e)==="[object ArrayBuffer]"}Ou.working=typeof ArrayBuffer<"u"&&Ou(new ArrayBuffer);function cm(e){return typeof ArrayBuffer>"u"?!1:Ou.working?Ou(e):e instanceof ArrayBuffer}Ie.isArrayBuffer=cm;function Ru(e){return br(e)==="[object DataView]"}Ru.working=typeof ArrayBuffer<"u"&&typeof DataView<"u"&&Ru(new DataView(new ArrayBuffer(1),0,1));function lm(e){return typeof DataView>"u"?!1:Ru.working?Ru(e):e instanceof DataView}Ie.isDataView=lm;var Jl=typeof SharedArrayBuffer<"u"?SharedArrayBuffer:void 0;function ws(e){return br(e)==="[object SharedArrayBuffer]"}function hm(e){return typeof Jl>"u"?!1:(typeof ws.working>"u"&&(ws.working=ws(new Jl)),ws.working?ws(e):e instanceof Jl)}Ie.isSharedArrayBuffer=hm;function bR(e){return br(e)==="[object AsyncFunction]"}Ie.isAsyncFunction=bR;function _R(e){return br(e)==="[object Map Iterator]"}Ie.isMapIterator=_R;function SR(e){return br(e)==="[object Set Iterator]"}Ie.isSetIterator=SR;function wR(e){return br(e)==="[object Generator]"}Ie.isGeneratorObject=wR;function ER(e){return br(e)==="[object WebAssembly.Module]"}Ie.isWebAssemblyCompiledModule=ER;function dm(e){return Es(e,QO)}Ie.isNumberObject=dm;function pm(e){return Es(e,eR)}Ie.isStringObject=pm;function gm(e){return Es(e,tR)}Ie.isBooleanObject=gm;function ym(e){return sm&&Es(e,um)}Ie.isBigIntObject=ym;function mm(e){return am&&Es(e,fm)}Ie.isSymbolObject=mm;function xR(e){return dm(e)||pm(e)||gm(e)||ym(e)||mm(e)}Ie.isBoxedPrimitive=xR;function IR(e){return typeof Uint8Array<"u"&&(cm(e)||hm(e))}Ie.isAnyArrayBuffer=IR;["isProxy","isExternal","isModuleNamespaceObject"].forEach(function(e){Object.defineProperty(Ie,e,{enumerable:!1,value:function(){throw new Error(e+" is not supported in userland")}})})});var _m=B((t4,bm)=>{p();bm.exports=function(t){return t&&typeof t=="object"&&typeof t.copy=="function"&&typeof t.fill=="function"&&typeof t.readUInt8=="function"}});var Xr=B(Ae=>{p();var Sm=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},AR=/%[sdj%]/g;Ae.format=function(e){if(!Cu(e)){for(var t=[],r=0;r<arguments.length;r++)t.push(Vn(arguments[r]));return t.join(" ")}for(var r=1,n=arguments,i=n.length,o=String(e).replace(AR,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])ku(s)||!xo(s)?o+=" "+s:o+=" "+Vn(s);return o};Ae.deprecate=function(e,t){if(typeof x.default<"u"&&x.default.noDeprecation===!0)return e;if(typeof x.default>"u")return function(){return Ae.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 Tu={},wm=/^$/;x.default.env.NODE_DEBUG&&(Pu=x.default.env.NODE_DEBUG,Pu=Pu.replace(/[|\\{}()[\]^$+?.]/g,"\\$&").replace(/\*/g,".*").replace(/,/g,"$|^").toUpperCase(),wm=new RegExp("^"+Pu+"$","i"));var Pu;Ae.debuglog=function(e){if(e=e.toUpperCase(),!Tu[e])if(wm.test(e)){var t=x.default.pid;Tu[e]=function(){var r=Ae.format.apply(Ae,arguments);console.error("%s %d: %s",e,t,r)}}else Tu[e]=function(){};return Tu[e]};function Vn(e,t){var r={seen:[],stylize:RR};return arguments.length>=3&&(r.depth=arguments[2]),arguments.length>=4&&(r.colors=arguments[3]),nh(t)?r.showHidden=t:t&&Ae._extend(r,t),Pi(r.showHidden)&&(r.showHidden=!1),Pi(r.depth)&&(r.depth=2),Pi(r.colors)&&(r.colors=!1),Pi(r.customInspect)&&(r.customInspect=!0),r.colors&&(r.stylize=OR),Nu(r,e,r.depth)}Ae.inspect=Vn;Vn.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]};Vn.styles={special:"cyan",number:"yellow",boolean:"yellow",undefined:"grey",null:"bold",string:"green",date:"magenta",regexp:"red"};function OR(e,t){var r=Vn.styles[t];return r?"\x1B["+Vn.colors[r][0]+"m"+e+"\x1B["+Vn.colors[r][1]+"m":e}function RR(e,t){return e}function TR(e){var t={};return e.forEach(function(r,n){t[r]=!0}),t}function Nu(e,t,r){if(e.customInspect&&t&&Bu(t.inspect)&&t.inspect!==Ae.inspect&&!(t.constructor&&t.constructor.prototype===t)){var n=t.inspect(r,e);return Cu(n)||(n=Nu(e,n,r)),n}var i=PR(e,t);if(i)return i;var o=Object.keys(t),s=TR(o);if(e.showHidden&&(o=Object.getOwnPropertyNames(t)),Is(t)&&(o.indexOf("message")>=0||o.indexOf("description")>=0))return eh(t);if(o.length===0){if(Bu(t)){var a=t.name?": "+t.name:"";return e.stylize("[Function"+a+"]","special")}if(xs(t))return e.stylize(RegExp.prototype.toString.call(t),"regexp");if(Mu(t))return e.stylize(Date.prototype.toString.call(t),"date");if(Is(t))return eh(t)}var f="",l=!1,y=["{","}"];if(Em(t)&&(l=!0,y=["[","]"]),Bu(t)){var g=t.name?": "+t.name:"";f=" [Function"+g+"]"}if(xs(t)&&(f=" "+RegExp.prototype.toString.call(t)),Mu(t)&&(f=" "+Date.prototype.toUTCString.call(t)),Is(t)&&(f=" "+eh(t)),o.length===0&&(!l||t.length==0))return y[0]+f+y[1];if(r<0)return xs(t)?e.stylize(RegExp.prototype.toString.call(t),"regexp"):e.stylize("[Object]","special");e.seen.push(t);var v;return l?v=BR(e,t,r,s,o):v=o.map(function(E){return rh(e,t,r,s,E,l)}),e.seen.pop(),NR(v,f,y)}function PR(e,t){if(Pi(t))return e.stylize("undefined","undefined");if(Cu(t)){var r="'"+JSON.stringify(t).replace(/^"|"$/g,"").replace(/'/g,"\\'").replace(/\\"/g,'"')+"'";return e.stylize(r,"string")}if(xm(t))return e.stylize(""+t,"number");if(nh(t))return e.stylize(""+t,"boolean");if(ku(t))return e.stylize("null","null")}function eh(e){return"["+Error.prototype.toString.call(e)+"]"}function BR(e,t,r,n,i){for(var o=[],s=0,a=t.length;s<a;++s)Im(t,String(s))?o.push(rh(e,t,r,n,String(s),!0)):o.push("");return i.forEach(function(f){f.match(/^\d+$/)||o.push(rh(e,t,r,n,f,!0))}),o}function rh(e,t,r,n,i,o){var s,a,f;if(f=Object.getOwnPropertyDescriptor(t,i)||{value:t[i]},f.get?f.set?a=e.stylize("[Getter/Setter]","special"):a=e.stylize("[Getter]","special"):f.set&&(a=e.stylize("[Setter]","special")),Im(n,i)||(s="["+i+"]"),a||(e.seen.indexOf(f.value)<0?(ku(r)?a=Nu(e,f.value,null):a=Nu(e,f.value,r-1),a.indexOf(`
|
|
2
2
|
`)>-1&&(o?a=a.split(`
|
|
3
3
|
`).map(function(l){return" "+l}).join(`
|
|
4
4
|
`).slice(2):a=`
|
|
@@ -7,7 +7,7 @@ var bsvLTP=(()=>{var gI=Object.create;var ps=Object.defineProperty;var yI=Object
|
|
|
7
7
|
`))):a=e.stylize("[Circular]","special")),Pi(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 NR(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]}Ae.types=vm();function Em(e){return Array.isArray(e)}Ae.isArray=Em;function nh(e){return typeof e=="boolean"}Ae.isBoolean=nh;function ku(e){return e===null}Ae.isNull=ku;function MR(e){return e==null}Ae.isNullOrUndefined=MR;function xm(e){return typeof e=="number"}Ae.isNumber=xm;function Cu(e){return typeof e=="string"}Ae.isString=Cu;function kR(e){return typeof e=="symbol"}Ae.isSymbol=kR;function Pi(e){return e===void 0}Ae.isUndefined=Pi;function xs(e){return xo(e)&&ih(e)==="[object RegExp]"}Ae.isRegExp=xs;Ae.types.isRegExp=xs;function xo(e){return typeof e=="object"&&e!==null}Ae.isObject=xo;function Mu(e){return xo(e)&&ih(e)==="[object Date]"}Ae.isDate=Mu;Ae.types.isDate=Mu;function Is(e){return xo(e)&&(ih(e)==="[object Error]"||e instanceof Error)}Ae.isError=Is;Ae.types.isNativeError=Is;function Bu(e){return typeof e=="function"}Ae.isFunction=Bu;function CR(e){return e===null||typeof e=="boolean"||typeof e=="number"||typeof e=="string"||typeof e=="symbol"||typeof e>"u"}Ae.isPrimitive=CR;Ae.isBuffer=_m();function ih(e){return Object.prototype.toString.call(e)}function th(e){return e<10?"0"+e.toString(10):e.toString(10)}var LR=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function DR(){var e=new Date,t=[th(e.getHours()),th(e.getMinutes()),th(e.getSeconds())].join(":");return[e.getDate(),LR[e.getMonth()],t].join(" ")}Ae.log=function(){console.log("%s - %s",DR(),Ae.format.apply(Ae,arguments))};Ae.inherits=Fe();Ae._extend=function(e,t){if(!t||!xo(t))return e;for(var r=Object.keys(t),n=r.length;n--;)e[r[n]]=t[r[n]];return e};function Im(e,t){return Object.prototype.hasOwnProperty.call(e,t)}var Ti=typeof Symbol<"u"?Symbol("util.promisify.custom"):void 0;Ae.promisify=function(t){if(typeof t!="function")throw new TypeError('The "original" argument must be of type Function');if(Ti&&t[Ti]){var r=t[Ti];if(typeof r!="function")throw new TypeError('The "util.promisify.custom" argument must be of type Function');return Object.defineProperty(r,Ti,{value:r,enumerable:!1,writable:!1,configurable:!0}),r}function r(){for(var n,i,o=new Promise(function(f,l){n=f,i=l}),s=[],a=0;a<arguments.length;a++)s.push(arguments[a]);s.push(function(f,l){f?i(f):n(l)});try{t.apply(this,s)}catch(f){i(f)}return o}return Object.setPrototypeOf(r,Object.getPrototypeOf(t)),Ti&&Object.defineProperty(r,Ti,{value:r,enumerable:!1,writable:!1,configurable:!0}),Object.defineProperties(r,Sm(t))};Ae.promisify.custom=Ti;function UR(e,t){if(!e){var r=new Error("Promise was rejected with a falsy value");r.reason=e,e=r}return t(e)}function FR(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(UR.bind(null,a,s))})}return Object.setPrototypeOf(t,Object.getPrototypeOf(e)),Object.defineProperties(t,Sm(e)),t}Ae.callbackify=FR});var Bm=B((oD,Pm)=>{"use strict";p();function Am(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 Om(e){for(var t=1;t<arguments.length;t++){var r=arguments[t]!=null?arguments[t]:{};t%2?Am(Object(r),!0).forEach(function(n){qR(e,n,r[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):Am(Object(r)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(r,n))})}return e}function qR(e,t,r){return t=Tm(t),t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function HR(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function Rm(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,Tm(n.key),n)}}function jR(e,t,r){return t&&Rm(e.prototype,t),r&&Rm(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e}function Tm(e){var t=KR(e,"string");return typeof t=="symbol"?t:String(t)}function KR(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 GR=Nt(),Lu=GR.Buffer,VR=Xr(),oh=VR.inspect,WR=oh&&oh.custom||"inspect";function zR(e,t,r){Lu.prototype.copy.call(e,t,r)}Pm.exports=(function(){function e(){HR(this,e),this.head=null,this.tail=null,this.length=0}return jR(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 Lu.alloc(0);for(var n=Lu.allocUnsafe(r>>>0),i=this.head,o=0;i;)zR(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=Lu.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:WR,value:function(r,n){return oh(this,Om(Om({},n),{},{depth:0,customInspect:!1}))}}]),e})()});var ah=B((aD,Mm)=>{"use strict";p();function YR(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(sh,this,e)):x.default.nextTick(sh,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(Du,r):(r._writableState.errorEmitted=!0,x.default.nextTick(Nm,r,o)):x.default.nextTick(Nm,r,o):t?(x.default.nextTick(Du,r),t(o)):x.default.nextTick(Du,r)}),this)}function Nm(e,t){sh(e,t),Du(e)}function Du(e){e._writableState&&!e._writableState.emitClose||e._readableState&&!e._readableState.emitClose||e.emit("close")}function $R(){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 sh(e,t){e.emit("error",t)}function ZR(e,t){var r=e._readableState,n=e._writableState;r&&r.autoDestroy||n&&n.autoDestroy?e.destroy(t):e.emit("error",t)}Mm.exports={destroy:YR,undestroy:$R,errorOrDestroy:ZR}});var Bi=B((fD,Lm)=>{"use strict";p();function XR(e,t){e.prototype=Object.create(t.prototype),e.prototype.constructor=e,e.__proto__=t}var Cm={};function _r(e,t,r){r||(r=Error);function n(o,s,a){return typeof t=="string"?t:t(o,s,a)}var i=(function(o){XR(s,o);function s(a,f,l){return o.call(this,n(a,f,l))||this}return s})(r);i.prototype.name=r.name,i.prototype.code=e,Cm[e]=i}function km(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 JR(e,t,r){return e.substr(!r||r<0?0:+r,t.length)===t}function QR(e,t,r){return(r===void 0||r>e.length)&&(r=e.length),e.substring(r-t.length,r)===t}function eT(e,t,r){return typeof r!="number"&&(r=0),r+t.length>e.length?!1:e.indexOf(t,r)!==-1}_r("ERR_INVALID_OPT_VALUE",function(e,t){return'The value "'+t+'" is invalid for option "'+e+'"'},TypeError);_r("ERR_INVALID_ARG_TYPE",function(e,t,r){var n;typeof t=="string"&&JR(t,"not ")?(n="must not be",t=t.replace(/^not /,"")):n="must be";var i;if(QR(e," argument"))i="The ".concat(e," ").concat(n," ").concat(km(t,"type"));else{var o=eT(e,".")?"property":"argument";i='The "'.concat(e,'" ').concat(o," ").concat(n," ").concat(km(t,"type"))}return i+=". Received type ".concat(typeof r),i},TypeError);_r("ERR_STREAM_PUSH_AFTER_EOF","stream.push() after EOF");_r("ERR_METHOD_NOT_IMPLEMENTED",function(e){return"The "+e+" method is not implemented"});_r("ERR_STREAM_PREMATURE_CLOSE","Premature close");_r("ERR_STREAM_DESTROYED",function(e){return"Cannot call "+e+" after a stream was destroyed"});_r("ERR_MULTIPLE_CALLBACK","Callback called multiple times");_r("ERR_STREAM_CANNOT_PIPE","Cannot pipe, not readable");_r("ERR_STREAM_WRITE_AFTER_END","write after end");_r("ERR_STREAM_NULL_VALUES","May not write null values to stream",TypeError);_r("ERR_UNKNOWN_ENCODING",function(e){return"Unknown encoding: "+e},TypeError);_r("ERR_STREAM_UNSHIFT_AFTER_END_EVENT","stream.unshift() after end event");Lm.exports.codes=Cm});var uh=B((lD,Dm)=>{"use strict";p();var tT=Bi().codes.ERR_INVALID_OPT_VALUE;function rT(e,t,r){return e.highWaterMark!=null?e.highWaterMark:t?e[r]:null}function nT(e,t,r,n){var i=rT(t,n,r);if(i!=null){if(!(isFinite(i)&&Math.floor(i)===i)||i<0){var o=n?r:"highWaterMark";throw new tT(o,i)}return Math.floor(i)}return e.objectMode?16:16*1024}Dm.exports={getHighWaterMark:nT}});var ch=B((dD,Um)=>{p();Um.exports=iT;function iT(e,t){if(fh("noDeprecation"))return e;var r=!1;function n(){if(!r){if(fh("throwDeprecation"))throw new Error(t);fh("traceDeprecation")?console.trace(t):console.warn(t),r=!0}return e.apply(this,arguments)}return n}function fh(e){try{if(!globalThis.localStorage)return!1}catch{return!1}var t=globalThis.localStorage[e];return t==null?!1:String(t).toLowerCase()==="true"}});var dh=B((gD,Gm)=>{"use strict";p();Gm.exports=Qe;function qm(e){var t=this;this.next=null,this.entry=null,this.finish=function(){BT(t,e)}}var Io;Qe.WritableState=Os;var oT={deprecate:ch()},Hm=Al(),Fu=Nt().Buffer,sT=(typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof self<"u"?self:{}).Uint8Array||function(){};function aT(e){return Fu.from(e)}function uT(e){return Fu.isBuffer(e)||e instanceof sT}var hh=ah(),fT=uh(),cT=fT.getHighWaterMark,Wn=Bi().codes,lT=Wn.ERR_INVALID_ARG_TYPE,hT=Wn.ERR_METHOD_NOT_IMPLEMENTED,dT=Wn.ERR_MULTIPLE_CALLBACK,pT=Wn.ERR_STREAM_CANNOT_PIPE,gT=Wn.ERR_STREAM_DESTROYED,yT=Wn.ERR_STREAM_NULL_VALUES,mT=Wn.ERR_STREAM_WRITE_AFTER_END,vT=Wn.ERR_UNKNOWN_ENCODING,Ao=hh.errorOrDestroy;Fe()(Qe,Hm);function bT(){}function Os(e,t,r){Io=Io||Ni(),e=e||{},typeof r!="boolean"&&(r=t instanceof Io),this.objectMode=!!e.objectMode,r&&(this.objectMode=this.objectMode||!!e.writableObjectMode),this.highWaterMark=cT(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){AT(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 qm(this)}Os.prototype.getBuffer=function(){for(var t=this.bufferedRequest,r=[];t;)r.push(t),t=t.next;return r};(function(){try{Object.defineProperty(Os.prototype,"buffer",{get:oT.deprecate(function(){return this.getBuffer()},"_writableState.buffer is deprecated. Use _writableState.getBuffer instead.","DEP0003")})}catch{}})();var Uu;typeof Symbol=="function"&&Symbol.hasInstance&&typeof Function.prototype[Symbol.hasInstance]=="function"?(Uu=Function.prototype[Symbol.hasInstance],Object.defineProperty(Qe,Symbol.hasInstance,{value:function(t){return Uu.call(this,t)?!0:this!==Qe?!1:t&&t._writableState instanceof Os}})):Uu=function(t){return t instanceof this};function Qe(e){Io=Io||Ni();var t=this instanceof Io;if(!t&&!Uu.call(Qe,this))return new Qe(e);this._writableState=new Os(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)),Hm.call(this)}Qe.prototype.pipe=function(){Ao(this,new pT)};function _T(e,t){var r=new mT;Ao(e,r),x.default.nextTick(t,r)}function ST(e,t,r,n){var i;return r===null?i=new yT:typeof r!="string"&&!t.objectMode&&(i=new lT("chunk",["string","Buffer"],r)),i?(Ao(e,i),x.default.nextTick(n,i),!1):!0}Qe.prototype.write=function(e,t,r){var n=this._writableState,i=!1,o=!n.objectMode&&uT(e);return o&&!Fu.isBuffer(e)&&(e=aT(e)),typeof t=="function"&&(r=t,t=null),o?t="buffer":t||(t=n.defaultEncoding),typeof r!="function"&&(r=bT),n.ending?_T(this,r):(o||ST(this,n,e,r))&&(n.pendingcb++,i=ET(this,n,o,e,t,r)),i};Qe.prototype.cork=function(){this._writableState.corked++};Qe.prototype.uncork=function(){var e=this._writableState;e.corked&&(e.corked--,!e.writing&&!e.corked&&!e.bufferProcessing&&e.bufferedRequest&&jm(this,e))};Qe.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 vT(t);return this._writableState.defaultEncoding=t,this};Object.defineProperty(Qe.prototype,"writableBuffer",{enumerable:!1,get:function(){return this._writableState&&this._writableState.getBuffer()}});function wT(e,t,r){return!e.objectMode&&e.decodeStrings!==!1&&typeof t=="string"&&(t=Fu.from(t,r)),t}Object.defineProperty(Qe.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}});function ET(e,t,r,n,i,o){if(!r){var s=wT(t,n,i);n!==s&&(r=!0,i="buffer",n=s)}var a=t.objectMode?1:n.length;t.length+=a;var f=t.length<t.highWaterMark;if(f||(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 lh(e,t,!1,a,n,i,o);return f}function lh(e,t,r,n,i,o,s){t.writelen=n,t.writecb=s,t.writing=!0,t.sync=!0,t.destroyed?t.onwrite(new gT("write")):r?e._writev(i,t.onwrite):e._write(i,o,t.onwrite),t.sync=!1}function xT(e,t,r,n,i){--t.pendingcb,r?(x.default.nextTick(i,n),x.default.nextTick(As,e,t),e._writableState.errorEmitted=!0,Ao(e,n)):(i(n),e._writableState.errorEmitted=!0,Ao(e,n),As(e,t))}function IT(e){e.writing=!1,e.writecb=null,e.length-=e.writelen,e.writelen=0}function AT(e,t){var r=e._writableState,n=r.sync,i=r.writecb;if(typeof i!="function")throw new dT;if(IT(r),t)xT(e,r,n,t,i);else{var o=Km(r)||e.destroyed;!o&&!r.corked&&!r.bufferProcessing&&r.bufferedRequest&&jm(e,r),n?x.default.nextTick(Fm,e,r,o,i):Fm(e,r,o,i)}}function Fm(e,t,r,n){r||OT(e,t),t.pendingcb--,n(),As(e,t)}function OT(e,t){t.length===0&&t.needDrain&&(t.needDrain=!1,e.emit("drain"))}function jm(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,lh(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 qm(t),t.bufferedRequestCount=0}else{for(;r;){var f=r.chunk,l=r.encoding,y=r.callback,g=t.objectMode?1:f.length;if(lh(e,t,!1,g,f,l,y),r=r.next,t.bufferedRequestCount--,t.writing)break}r===null&&(t.lastBufferedRequest=null)}t.bufferedRequest=r,t.bufferProcessing=!1}Qe.prototype._write=function(e,t,r){r(new hT("_write()"))};Qe.prototype._writev=null;Qe.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||PT(this,n,r),this};Object.defineProperty(Qe.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 RT(e,t){e._final(function(r){t.pendingcb--,r&&Ao(e,r),t.prefinished=!0,e.emit("prefinish"),As(e,t)})}function TT(e,t){!t.prefinished&&!t.finalCalled&&(typeof e._final=="function"&&!t.destroyed?(t.pendingcb++,t.finalCalled=!0,x.default.nextTick(RT,e,t)):(t.prefinished=!0,e.emit("prefinish")))}function As(e,t){var r=Km(t);if(r&&(TT(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 PT(e,t,r){t.ending=!0,As(e,t),r&&(t.finished?x.default.nextTick(r):e.once("finish",r)),t.ended=!0,e.writable=!1}function BT(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(Qe.prototype,"destroyed",{enumerable:!1,get:function(){return this._writableState===void 0?!1:this._writableState.destroyed},set:function(t){this._writableState&&(this._writableState.destroyed=t)}});Qe.prototype.destroy=hh.destroy;Qe.prototype._undestroy=hh.undestroy;Qe.prototype._destroy=function(e,t){t(e)}});var Ni=B((mD,Wm)=>{"use strict";p();var NT=Object.keys||function(e){var t=[];for(var r in e)t.push(r);return t};Wm.exports=Jr;var Vm=yh(),gh=dh();Fe()(Jr,Vm);for(ph=NT(gh.prototype),qu=0;qu<ph.length;qu++)Hu=ph[qu],Jr.prototype[Hu]||(Jr.prototype[Hu]=gh.prototype[Hu]);var ph,Hu,qu;function Jr(e){if(!(this instanceof Jr))return new Jr(e);Vm.call(this,e),gh.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",MT)))}Object.defineProperty(Jr.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}});Object.defineProperty(Jr.prototype,"writableBuffer",{enumerable:!1,get:function(){return this._writableState&&this._writableState.getBuffer()}});Object.defineProperty(Jr.prototype,"writableLength",{enumerable:!1,get:function(){return this._writableState.length}});function MT(){this._writableState.ended||x.default.nextTick(kT,this)}function kT(e){e.end()}Object.defineProperty(Jr.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 $m=B((mh,Ym)=>{p();var ju=Nt(),mn=ju.Buffer;function zm(e,t){for(var r in e)t[r]=e[r]}mn.from&&mn.alloc&&mn.allocUnsafe&&mn.allocUnsafeSlow?Ym.exports=ju:(zm(ju,mh),mh.Buffer=Oo);function Oo(e,t,r){return mn(e,t,r)}zm(mn,Oo);Oo.from=function(e,t,r){if(typeof e=="number")throw new TypeError("Argument must not be a number");return mn(e,t,r)};Oo.alloc=function(e,t,r){if(typeof e!="number")throw new TypeError("Argument must be a number");var n=mn(e);return t!==void 0?typeof r=="string"?n.fill(t,r):n.fill(t):n.fill(0),n};Oo.allocUnsafe=function(e){if(typeof e!="number")throw new TypeError("Argument must be a number");return mn(e)};Oo.allocUnsafeSlow=function(e){if(typeof e!="number")throw new TypeError("Argument must be a number");return ju.SlowBuffer(e)}});var Ro=B(Xm=>{"use strict";p();var bh=$m().Buffer,Zm=bh.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 CT(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 LT(e){var t=CT(e);if(typeof t!="string"&&(bh.isEncoding===Zm||!Zm(e)))throw new Error("Unknown encoding: "+e);return t||e}Xm.StringDecoder=Rs;function Rs(e){this.encoding=LT(e);var t;switch(this.encoding){case"utf16le":this.text=jT,this.end=KT,t=4;break;case"utf8":this.fillLast=FT,t=4;break;case"base64":this.text=GT,this.end=VT,t=3;break;default:this.write=WT,this.end=zT;return}this.lastNeed=0,this.lastTotal=0,this.lastChar=bh.allocUnsafe(t)}Rs.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||""};Rs.prototype.end=HT;Rs.prototype.text=qT;Rs.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 vh(e){return e<=127?0:e>>5===6?2:e>>4===14?3:e>>3===30?4:e>>6===2?-1:-2}function DT(e,t,r){var n=t.length-1;if(n<r)return 0;var i=vh(t[n]);return i>=0?(i>0&&(e.lastNeed=i-1),i):--n<r||i===-2?0:(i=vh(t[n]),i>=0?(i>0&&(e.lastNeed=i-2),i):--n<r||i===-2?0:(i=vh(t[n]),i>=0?(i>0&&(i===2?i=0:e.lastNeed=i-3),i):0))}function UT(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 FT(e){var t=this.lastTotal-this.lastNeed,r=UT(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 qT(e,t){var r=DT(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 HT(e){var t=e&&e.length?this.write(e):"";return this.lastNeed?t+"\uFFFD":t}function jT(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 KT(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 GT(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 VT(e){var t=e&&e.length?this.write(e):"";return this.lastNeed?t+this.lastChar.toString("base64",0,3-this.lastNeed):t}function WT(e){return e.toString(this.encoding)}function zT(e){return e&&e.length?this.write(e):""}});var Ku=B((wD,ev)=>{"use strict";p();var Jm=Bi().codes.ERR_STREAM_PREMATURE_CLOSE;function YT(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 $T(){}function ZT(e){return e.setHeader&&typeof e.abort=="function"}function Qm(e,t,r){if(typeof t=="function")return Qm(e,null,t);t||(t={}),r=YT(r||$T);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)},f=e._readableState&&e._readableState.endEmitted,l=function(){n=!1,f=!0,i||r.call(e)},y=function(T){r.call(e,T)},g=function(){var T;if(n&&!f)return(!e._readableState||!e._readableState.ended)&&(T=new Jm),r.call(e,T);if(i&&!s)return(!e._writableState||!e._writableState.ended)&&(T=new Jm),r.call(e,T)},v=function(){e.req.on("finish",a)};return ZT(e)?(e.on("complete",a),e.on("abort",g),e.req?v():e.on("request",v)):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",y),e.on("close",g),function(){e.removeListener("complete",a),e.removeListener("abort",g),e.removeListener("request",v),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",y),e.removeListener("close",g)}}ev.exports=Qm});var rv=B((xD,tv)=>{"use strict";p();var Gu;function zn(e,t,r){return t=XT(t),t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function XT(e){var t=JT(e,"string");return typeof t=="symbol"?t:String(t)}function JT(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 QT=Ku(),Yn=Symbol("lastResolve"),Mi=Symbol("lastReject"),Ts=Symbol("error"),Vu=Symbol("ended"),ki=Symbol("lastPromise"),_h=Symbol("handlePromise"),Ci=Symbol("stream");function $n(e,t){return{value:e,done:t}}function e2(e){var t=e[Yn];if(t!==null){var r=e[Ci].read();r!==null&&(e[ki]=null,e[Yn]=null,e[Mi]=null,t($n(r,!1)))}}function t2(e){x.default.nextTick(e2,e)}function r2(e,t){return function(r,n){e.then(function(){if(t[Vu]){r($n(void 0,!0));return}t[_h](r,n)},n)}}var n2=Object.getPrototypeOf(function(){}),i2=Object.setPrototypeOf((Gu={get stream(){return this[Ci]},next:function(){var t=this,r=this[Ts];if(r!==null)return Promise.reject(r);if(this[Vu])return Promise.resolve($n(void 0,!0));if(this[Ci].destroyed)return new Promise(function(s,a){x.default.nextTick(function(){t[Ts]?a(t[Ts]):s($n(void 0,!0))})});var n=this[ki],i;if(n)i=new Promise(r2(n,this));else{var o=this[Ci].read();if(o!==null)return Promise.resolve($n(o,!1));i=new Promise(this[_h])}return this[ki]=i,i}},zn(Gu,Symbol.asyncIterator,function(){return this}),zn(Gu,"return",function(){var t=this;return new Promise(function(r,n){t[Ci].destroy(null,function(i){if(i){n(i);return}r($n(void 0,!0))})})}),Gu),n2),o2=function(t){var r,n=Object.create(i2,(r={},zn(r,Ci,{value:t,writable:!0}),zn(r,Yn,{value:null,writable:!0}),zn(r,Mi,{value:null,writable:!0}),zn(r,Ts,{value:null,writable:!0}),zn(r,Vu,{value:t._readableState.endEmitted,writable:!0}),zn(r,_h,{value:function(o,s){var a=n[Ci].read();a?(n[ki]=null,n[Yn]=null,n[Mi]=null,o($n(a,!1))):(n[Yn]=o,n[Mi]=s)},writable:!0}),r));return n[ki]=null,QT(t,function(i){if(i&&i.code!=="ERR_STREAM_PREMATURE_CLOSE"){var o=n[Mi];o!==null&&(n[ki]=null,n[Yn]=null,n[Mi]=null,o(i)),n[Ts]=i;return}var s=n[Yn];s!==null&&(n[ki]=null,n[Yn]=null,n[Mi]=null,s($n(void 0,!0))),n[Vu]=!0}),t.on("readable",t2.bind(null,n)),n};tv.exports=o2});var iv=B((AD,nv)=>{p();nv.exports=function(){throw new Error("Readable.from is not available in the browser")}});var yh=B((TD,pv)=>{"use strict";p();pv.exports=Be;var To;Be.ReadableState=uv;var RD=go().EventEmitter,av=function(t,r){return t.listeners(r).length},Bs=Al(),Wu=Nt().Buffer,s2=(typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof self<"u"?self:{}).Uint8Array||function(){};function a2(e){return Wu.from(e)}function u2(e){return Wu.isBuffer(e)||e instanceof s2}var Sh=Xr(),we;Sh&&Sh.debuglog?we=Sh.debuglog("stream"):we=function(){};var f2=Bm(),Rh=ah(),c2=uh(),l2=c2.getHighWaterMark,zu=Bi().codes,h2=zu.ERR_INVALID_ARG_TYPE,d2=zu.ERR_STREAM_PUSH_AFTER_EOF,p2=zu.ERR_METHOD_NOT_IMPLEMENTED,g2=zu.ERR_STREAM_UNSHIFT_AFTER_END_EVENT,Po,wh,Eh;Fe()(Be,Bs);var Ps=Rh.errorOrDestroy,xh=["error","close","destroy","pause","resume"];function y2(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 uv(e,t,r){To=To||Ni(),e=e||{},typeof r!="boolean"&&(r=t instanceof To),this.objectMode=!!e.objectMode,r&&(this.objectMode=this.objectMode||!!e.readableObjectMode),this.highWaterMark=l2(this,e,"readableHighWaterMark",r),this.buffer=new f2,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&&(Po||(Po=Ro().StringDecoder),this.decoder=new Po(e.encoding),this.encoding=e.encoding)}function Be(e){if(To=To||Ni(),!(this instanceof Be))return new Be(e);var t=this instanceof To;this._readableState=new uv(e,this,t),this.readable=!0,e&&(typeof e.read=="function"&&(this._read=e.read),typeof e.destroy=="function"&&(this._destroy=e.destroy)),Bs.call(this)}Object.defineProperty(Be.prototype,"destroyed",{enumerable:!1,get:function(){return this._readableState===void 0?!1:this._readableState.destroyed},set:function(t){this._readableState&&(this._readableState.destroyed=t)}});Be.prototype.destroy=Rh.destroy;Be.prototype._undestroy=Rh.undestroy;Be.prototype._destroy=function(e,t){t(e)};Be.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),fv(this,e,t,!1,n)};Be.prototype.unshift=function(e){return fv(this,e,null,!0,!1)};function fv(e,t,r,n,i){we("readableAddChunk",t);var o=e._readableState;if(t===null)o.reading=!1,b2(e,o);else{var s;if(i||(s=m2(o,t)),s)Ps(e,s);else if(o.objectMode||t&&t.length>0)if(typeof t!="string"&&!o.objectMode&&Object.getPrototypeOf(t)!==Wu.prototype&&(t=a2(t)),n)o.endEmitted?Ps(e,new g2):Ih(e,o,t,!0);else if(o.ended)Ps(e,new d2);else{if(o.destroyed)return!1;o.reading=!1,o.decoder&&!r?(t=o.decoder.write(t),o.objectMode||t.length!==0?Ih(e,o,t,!1):Oh(e,o)):Ih(e,o,t,!1)}else n||(o.reading=!1,Oh(e,o))}return!o.ended&&(o.length<o.highWaterMark||o.length===0)}function Ih(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&&Yu(e)),Oh(e,t)}function m2(e,t){var r;return!u2(t)&&typeof t!="string"&&t!==void 0&&!e.objectMode&&(r=new h2("chunk",["string","Buffer","Uint8Array"],t)),r}Be.prototype.isPaused=function(){return this._readableState.flowing===!1};Be.prototype.setEncoding=function(e){Po||(Po=Ro().StringDecoder);var t=new Po(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 ov=1073741824;function v2(e){return e>=ov?e=ov:(e--,e|=e>>>1,e|=e>>>2,e|=e>>>4,e|=e>>>8,e|=e>>>16,e++),e}function sv(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=v2(e)),e<=t.length?e:t.ended?t.length:(t.needReadable=!0,0))}Be.prototype.read=function(e){we("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 we("read: emitReadable",t.length,t.ended),t.length===0&&t.ended?Ah(this):Yu(this),null;if(e=sv(e,t),e===0&&t.ended)return t.length===0&&Ah(this),null;var n=t.needReadable;we("need readable",n),(t.length===0||t.length-e<t.highWaterMark)&&(n=!0,we("length less than watermark",n)),t.ended||t.reading?(n=!1,we("reading or ended",n)):n&&(we("do read"),t.reading=!0,t.sync=!0,t.length===0&&(t.needReadable=!0),this._read(t.highWaterMark),t.sync=!1,t.reading||(e=sv(r,t)));var i;return e>0?i=hv(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&&Ah(this)),i!==null&&this.emit("data",i),i};function b2(e,t){if(we("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?Yu(e):(t.needReadable=!1,t.emittedReadable||(t.emittedReadable=!0,cv(e)))}}function Yu(e){var t=e._readableState;we("emitReadable",t.needReadable,t.emittedReadable),t.needReadable=!1,t.emittedReadable||(we("emitReadable",t.flowing),t.emittedReadable=!0,x.default.nextTick(cv,e))}function cv(e){var t=e._readableState;we("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,Th(e)}function Oh(e,t){t.readingMore||(t.readingMore=!0,x.default.nextTick(_2,e,t))}function _2(e,t){for(;!t.reading&&!t.ended&&(t.length<t.highWaterMark||t.flowing&&t.length===0);){var r=t.length;if(we("maybeReadMore read 0"),e.read(0),r===t.length)break}t.readingMore=!1}Be.prototype._read=function(e){Ps(this,new p2("_read()"))};Be.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,we("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:M;n.endEmitted?x.default.nextTick(o):r.once("end",o),e.on("unpipe",s);function s(U,F){we("onunpipe"),U===r&&F&&F.hasUnpiped===!1&&(F.hasUnpiped=!0,y())}function a(){we("onend"),e.end()}var f=S2(r);e.on("drain",f);var l=!1;function y(){we("cleanup"),e.removeListener("close",E),e.removeListener("finish",T),e.removeListener("drain",f),e.removeListener("error",v),e.removeListener("unpipe",s),r.removeListener("end",a),r.removeListener("end",M),r.removeListener("data",g),l=!0,n.awaitDrain&&(!e._writableState||e._writableState.needDrain)&&f()}r.on("data",g);function g(U){we("ondata");var F=e.write(U);we("dest.write",F),F===!1&&((n.pipesCount===1&&n.pipes===e||n.pipesCount>1&&dv(n.pipes,e)!==-1)&&!l&&(we("false write response, pause",n.awaitDrain),n.awaitDrain++),r.pause())}function v(U){we("onerror",U),M(),e.removeListener("error",v),av(e,"error")===0&&Ps(e,U)}y2(e,"error",v);function E(){e.removeListener("finish",T),M()}e.once("close",E);function T(){we("onfinish"),e.removeListener("close",E),M()}e.once("finish",T);function M(){we("unpipe"),r.unpipe(e)}return e.emit("pipe",r),n.flowing||(we("pipe resume"),r.resume()),e};function S2(e){return function(){var r=e._readableState;we("pipeOnDrain",r.awaitDrain),r.awaitDrain&&r.awaitDrain--,r.awaitDrain===0&&av(e,"data")&&(r.flowing=!0,Th(e))}}Be.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=dv(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)};Be.prototype.on=function(e,t){var r=Bs.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,we("on readable",n.length,n.reading),n.length?Yu(this):n.reading||x.default.nextTick(w2,this)),r};Be.prototype.addListener=Be.prototype.on;Be.prototype.removeListener=function(e,t){var r=Bs.prototype.removeListener.call(this,e,t);return e==="readable"&&x.default.nextTick(lv,this),r};Be.prototype.removeAllListeners=function(e){var t=Bs.prototype.removeAllListeners.apply(this,arguments);return(e==="readable"||e===void 0)&&x.default.nextTick(lv,this),t};function lv(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 w2(e){we("readable nexttick read 0"),e.read(0)}Be.prototype.resume=function(){var e=this._readableState;return e.flowing||(we("resume"),e.flowing=!e.readableListening,E2(this,e)),e.paused=!1,this};function E2(e,t){t.resumeScheduled||(t.resumeScheduled=!0,x.default.nextTick(x2,e,t))}function x2(e,t){we("resume",t.reading),t.reading||e.read(0),t.resumeScheduled=!1,e.emit("resume"),Th(e),t.flowing&&!t.reading&&e.read(0)}Be.prototype.pause=function(){return we("call pause flowing=%j",this._readableState.flowing),this._readableState.flowing!==!1&&(we("pause"),this._readableState.flowing=!1,this.emit("pause")),this._readableState.paused=!0,this};function Th(e){var t=e._readableState;for(we("flow",t.flowing);t.flowing&&e.read()!==null;);}Be.prototype.wrap=function(e){var t=this,r=this._readableState,n=!1;e.on("end",function(){if(we("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(we("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<xh.length;o++)e.on(xh[o],this.emit.bind(this,xh[o]));return this._read=function(s){we("wrapped _read",s),n&&(n=!1,e.resume())},this};typeof Symbol=="function"&&(Be.prototype[Symbol.asyncIterator]=function(){return wh===void 0&&(wh=rv()),wh(this)});Object.defineProperty(Be.prototype,"readableHighWaterMark",{enumerable:!1,get:function(){return this._readableState.highWaterMark}});Object.defineProperty(Be.prototype,"readableBuffer",{enumerable:!1,get:function(){return this._readableState&&this._readableState.buffer}});Object.defineProperty(Be.prototype,"readableFlowing",{enumerable:!1,get:function(){return this._readableState.flowing},set:function(t){this._readableState&&(this._readableState.flowing=t)}});Be._fromList=hv;Object.defineProperty(Be.prototype,"readableLength",{enumerable:!1,get:function(){return this._readableState.length}});function hv(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 Ah(e){var t=e._readableState;we("endReadable",t.endEmitted),t.endEmitted||(t.ended=!0,x.default.nextTick(I2,t,e))}function I2(e,t){if(we("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"&&(Be.from=function(e,t){return Eh===void 0&&(Eh=iv()),Eh(Be,e,t)});function dv(e,t){for(var r=0,n=e.length;r<n;r++)if(e[r]===t)return r;return-1}});var Ph=B((BD,yv)=>{"use strict";p();yv.exports=vn;var $u=Bi().codes,A2=$u.ERR_METHOD_NOT_IMPLEMENTED,O2=$u.ERR_MULTIPLE_CALLBACK,R2=$u.ERR_TRANSFORM_ALREADY_TRANSFORMING,T2=$u.ERR_TRANSFORM_WITH_LENGTH_0,Zu=Ni();Fe()(vn,Zu);function P2(e,t){var r=this._transformState;r.transforming=!1;var n=r.writecb;if(n===null)return this.emit("error",new O2);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 vn(e){if(!(this instanceof vn))return new vn(e);Zu.call(this,e),this._transformState={afterTransform:P2.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",B2)}function B2(){var e=this;typeof this._flush=="function"&&!this._readableState.destroyed?this._flush(function(t,r){gv(e,t,r)}):gv(this,null,null)}vn.prototype.push=function(e,t){return this._transformState.needTransform=!1,Zu.prototype.push.call(this,e,t)};vn.prototype._transform=function(e,t,r){r(new A2("_transform()"))};vn.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)}};vn.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};vn.prototype._destroy=function(e,t){Zu.prototype._destroy.call(this,e,function(r){t(r)})};function gv(e,t,r){if(t)return e.emit("error",t);if(r!=null&&e.push(r),e._writableState.length)throw new T2;if(e._transformState.transforming)throw new R2;return e.push(null)}});var bv=B((MD,vv)=>{"use strict";p();vv.exports=Ns;var mv=Ph();Fe()(Ns,mv);function Ns(e){if(!(this instanceof Ns))return new Ns(e);mv.call(this,e)}Ns.prototype._transform=function(e,t,r){r(null,e)}});var xv=B((CD,Ev)=>{"use strict";p();var Bh;function N2(e){var t=!1;return function(){t||(t=!0,e.apply(void 0,arguments))}}var wv=Bi().codes,M2=wv.ERR_MISSING_ARGS,k2=wv.ERR_STREAM_DESTROYED;function _v(e){if(e)throw e}function C2(e){return e.setHeader&&typeof e.abort=="function"}function L2(e,t,r,n){n=N2(n);var i=!1;e.on("close",function(){i=!0}),Bh===void 0&&(Bh=Ku()),Bh(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,C2(e))return e.abort();if(typeof e.destroy=="function")return e.destroy();n(s||new k2("pipe"))}}}function Sv(e){e()}function D2(e,t){return e.pipe(t)}function U2(e){return!e.length||typeof e[e.length-1]!="function"?_v:e.pop()}function F2(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];var n=U2(t);if(Array.isArray(t[0])&&(t=t[0]),t.length<2)throw new M2("streams");var i,o=t.map(function(s,a){var f=a<t.length-1,l=a>0;return L2(s,f,l,function(y){i||(i=y),y&&o.forEach(Sv),!f&&(o.forEach(Sv),n(i))})});return t.reduce(D2)}Ev.exports=F2});var Mh=B((DD,Iv)=>{p();Iv.exports=Sr;var Nh=go().EventEmitter,q2=Fe();q2(Sr,Nh);Sr.Readable=yh();Sr.Writable=dh();Sr.Duplex=Ni();Sr.Transform=Ph();Sr.PassThrough=bv();Sr.finished=Ku();Sr.pipeline=xv();Sr.Stream=Sr;function Sr(){Nh.call(this)}Sr.prototype.pipe=function(e,t){var r=this;function n(y){e.writable&&e.write(y)===!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 f(y){if(l(),Nh.listenerCount(this,"error")===0)throw y}r.on("error",f),e.on("error",f);function l(){r.removeListener("data",n),e.removeListener("drain",i),r.removeListener("end",s),r.removeListener("close",a),r.removeListener("error",f),e.removeListener("error",f),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 Rv=B((FD,Ov)=>{"use strict";p();var Qr=Gt().Buffer,Av=Mh().Transform,H2=Fe();function Zn(e){Av.call(this),this._block=Qr.allocUnsafe(e),this._blockSize=e,this._blockOffset=0,this._length=[0,0,0,0],this._finalized=!1}H2(Zn,Av);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 j2=typeof Uint8Array<"u",K2=typeof ArrayBuffer<"u"&&typeof Uint8Array<"u"&&ArrayBuffer.isView&&(Qr.prototype instanceof Uint8Array||Qr.TYPED_ARRAY_SUPPORT);function G2(e,t){if(e instanceof Qr)return e;if(typeof e=="string")return Qr.from(e,t);if(K2&&ArrayBuffer.isView(e)){if(e.byteLength===0)return Qr.alloc(0);var r=Qr.from(e.buffer,e.byteOffset,e.byteLength);if(r.byteLength===e.byteLength)return r}if(j2&&e instanceof Uint8Array||Qr.isBuffer(e)&&e.constructor&&typeof e.constructor.isBuffer=="function"&&e.constructor.isBuffer(e))return Qr.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=G2(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")};Ov.exports=Zn});var kh=B((HD,Pv)=>{"use strict";p();var V2=Fe(),Tv=Rv(),W2=Gt().Buffer,z2=new Array(16);function Xu(){Tv.call(this,64),this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878}V2(Xu,Tv);Xu.prototype._update=function(){for(var e=z2,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=zt(r,n,i,o,e[0],3614090360,7),o=zt(o,r,n,i,e[1],3905402710,12),i=zt(i,o,r,n,e[2],606105819,17),n=zt(n,i,o,r,e[3],3250441966,22),r=zt(r,n,i,o,e[4],4118548399,7),o=zt(o,r,n,i,e[5],1200080426,12),i=zt(i,o,r,n,e[6],2821735955,17),n=zt(n,i,o,r,e[7],4249261313,22),r=zt(r,n,i,o,e[8],1770035416,7),o=zt(o,r,n,i,e[9],2336552879,12),i=zt(i,o,r,n,e[10],4294925233,17),n=zt(n,i,o,r,e[11],2304563134,22),r=zt(r,n,i,o,e[12],1804603682,7),o=zt(o,r,n,i,e[13],4254626195,12),i=zt(i,o,r,n,e[14],2792965006,17),n=zt(n,i,o,r,e[15],1236535329,22),r=Yt(r,n,i,o,e[1],4129170786,5),o=Yt(o,r,n,i,e[6],3225465664,9),i=Yt(i,o,r,n,e[11],643717713,14),n=Yt(n,i,o,r,e[0],3921069994,20),r=Yt(r,n,i,o,e[5],3593408605,5),o=Yt(o,r,n,i,e[10],38016083,9),i=Yt(i,o,r,n,e[15],3634488961,14),n=Yt(n,i,o,r,e[4],3889429448,20),r=Yt(r,n,i,o,e[9],568446438,5),o=Yt(o,r,n,i,e[14],3275163606,9),i=Yt(i,o,r,n,e[3],4107603335,14),n=Yt(n,i,o,r,e[8],1163531501,20),r=Yt(r,n,i,o,e[13],2850285829,5),o=Yt(o,r,n,i,e[2],4243563512,9),i=Yt(i,o,r,n,e[7],1735328473,14),n=Yt(n,i,o,r,e[12],2368359562,20),r=$t(r,n,i,o,e[5],4294588738,4),o=$t(o,r,n,i,e[8],2272392833,11),i=$t(i,o,r,n,e[11],1839030562,16),n=$t(n,i,o,r,e[14],4259657740,23),r=$t(r,n,i,o,e[1],2763975236,4),o=$t(o,r,n,i,e[4],1272893353,11),i=$t(i,o,r,n,e[7],4139469664,16),n=$t(n,i,o,r,e[10],3200236656,23),r=$t(r,n,i,o,e[13],681279174,4),o=$t(o,r,n,i,e[0],3936430074,11),i=$t(i,o,r,n,e[3],3572445317,16),n=$t(n,i,o,r,e[6],76029189,23),r=$t(r,n,i,o,e[9],3654602809,4),o=$t(o,r,n,i,e[12],3873151461,11),i=$t(i,o,r,n,e[15],530742520,16),n=$t(n,i,o,r,e[2],3299628645,23),r=Zt(r,n,i,o,e[0],4096336452,6),o=Zt(o,r,n,i,e[7],1126891415,10),i=Zt(i,o,r,n,e[14],2878612391,15),n=Zt(n,i,o,r,e[5],4237533241,21),r=Zt(r,n,i,o,e[12],1700485571,6),o=Zt(o,r,n,i,e[3],2399980690,10),i=Zt(i,o,r,n,e[10],4293915773,15),n=Zt(n,i,o,r,e[1],2240044497,21),r=Zt(r,n,i,o,e[8],1873313359,6),o=Zt(o,r,n,i,e[15],4264355552,10),i=Zt(i,o,r,n,e[6],2734768916,15),n=Zt(n,i,o,r,e[13],1309151649,21),r=Zt(r,n,i,o,e[4],4149444226,6),o=Zt(o,r,n,i,e[11],3174756917,10),i=Zt(i,o,r,n,e[2],718787259,15),n=Zt(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};Xu.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=W2.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 Ju(e,t){return e<<t|e>>>32-t}function zt(e,t,r,n,i,o,s){return Ju(e+(t&r|~t&n)+i+o|0,s)+t|0}function Yt(e,t,r,n,i,o,s){return Ju(e+(t&n|r&~n)+i+o|0,s)+t|0}function $t(e,t,r,n,i,o,s){return Ju(e+(t^r^n)+i+o|0,s)+t|0}function Zt(e,t,r,n,i,o,s){return Ju(e+(r^(t|~n))+i+o|0,s)+t|0}Pv.exports=Xu});var Nv=B((KD,Bv)=>{p();var Y2={}.toString;Bv.exports=Array.isArray||function(e){return Y2.call(e)=="[object Array]"}});var kv=B((VD,Mv)=>{"use strict";p();var $2=Ai(),Z2=Gn(),X2=Z2("TypedArray.prototype.buffer",!0),J2=Xl();Mv.exports=X2||function(t){if(!J2(t))throw new $2("Not a Typed Array");return t.buffer}});var Qu=B((zD,Lv)=>{"use strict";p();var Pr=Gt().Buffer,Q2=Nv(),eP=kv(),tP=ArrayBuffer.isView||function(t){try{return eP(t),!0}catch{return!1}},rP=typeof Uint8Array<"u",Cv=typeof ArrayBuffer<"u"&&typeof Uint8Array<"u",nP=Cv&&(Pr.prototype instanceof Uint8Array||Pr.TYPED_ARRAY_SUPPORT);Lv.exports=function(t,r){if(Pr.isBuffer(t))return t.constructor&&!("isBuffer"in t)?Pr.from(t):t;if(typeof t=="string")return Pr.from(t,r);if(Cv&&tP(t)){if(t.byteLength===0)return Pr.alloc(0);if(nP){var n=Pr.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=Pr.from(i);if(o.length===t.byteLength)return o}if(rP&&t instanceof Uint8Array)return Pr.from(t);var s=Q2(t);if(s)for(var a=0;a<t.length;a+=1){var f=t[a];if(typeof f!="number"||f<0||f>255||~~f!==f)throw new RangeError("Array items must be numbers in the range 0-255.")}if(s||Pr.isBuffer(t)&&t.constructor&&typeof t.constructor.isBuffer=="function"&&t.constructor.isBuffer(t))return Pr.from(t);throw new TypeError('The "data" argument must be a string, an Array, a Buffer, a Uint8Array, or a DataView.')}});var qv=B(($D,Fv)=>{"use strict";p();var iP=Gt().Buffer,oP=Qu(),Uv=typeof Uint8Array<"u",sP=Uv&&typeof ArrayBuffer<"u",Dv=sP&&ArrayBuffer.isView;Fv.exports=function(e,t){if(typeof e=="string"||iP.isBuffer(e)||Uv&&e instanceof Uint8Array||Dv&&Dv(e))return oP(e,t);throw new TypeError('The "data" argument must be a string, a Buffer, a Uint8Array, or a DataView')}});var Ms=B((XD,Ch)=>{"use strict";p();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?Ch.exports={nextTick:aP}:Ch.exports=x.default;function aP(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 jv=B((QD,Hv)=>{p();var uP={}.toString;Hv.exports=Array.isArray||function(e){return uP.call(e)=="[object Array]"}});var Lh=B((t4,Kv)=>{p();Kv.exports=go().EventEmitter});var tf=B((Dh,Vv)=>{p();var ef=Nt(),bn=ef.Buffer;function Gv(e,t){for(var r in e)t[r]=e[r]}bn.from&&bn.alloc&&bn.allocUnsafe&&bn.allocUnsafeSlow?Vv.exports=ef:(Gv(ef,Dh),Dh.Buffer=Bo);function Bo(e,t,r){return bn(e,t,r)}Gv(bn,Bo);Bo.from=function(e,t,r){if(typeof e=="number")throw new TypeError("Argument must not be a number");return bn(e,t,r)};Bo.alloc=function(e,t,r){if(typeof e!="number")throw new TypeError("Argument must be a number");var n=bn(e);return t!==void 0?typeof r=="string"?n.fill(t,r):n.fill(t):n.fill(0),n};Bo.allocUnsafe=function(e){if(typeof e!="number")throw new TypeError("Argument must be a number");return bn(e)};Bo.allocUnsafeSlow=function(e){if(typeof e!="number")throw new TypeError("Argument must be a number");return ef.SlowBuffer(e)}});var No=B(Xt=>{p();function fP(e){return Array.isArray?Array.isArray(e):rf(e)==="[object Array]"}Xt.isArray=fP;function cP(e){return typeof e=="boolean"}Xt.isBoolean=cP;function lP(e){return e===null}Xt.isNull=lP;function hP(e){return e==null}Xt.isNullOrUndefined=hP;function dP(e){return typeof e=="number"}Xt.isNumber=dP;function pP(e){return typeof e=="string"}Xt.isString=pP;function gP(e){return typeof e=="symbol"}Xt.isSymbol=gP;function yP(e){return e===void 0}Xt.isUndefined=yP;function mP(e){return rf(e)==="[object RegExp]"}Xt.isRegExp=mP;function vP(e){return typeof e=="object"&&e!==null}Xt.isObject=vP;function bP(e){return rf(e)==="[object Date]"}Xt.isDate=bP;function _P(e){return rf(e)==="[object Error]"||e instanceof Error}Xt.isError=_P;function SP(e){return typeof e=="function"}Xt.isFunction=SP;function wP(e){return e===null||typeof e=="boolean"||typeof e=="number"||typeof e=="string"||typeof e=="symbol"||typeof e>"u"}Xt.isPrimitive=wP;Xt.isBuffer=Nt().Buffer.isBuffer;function rf(e){return Object.prototype.toString.call(e)}});var zv=B((s4,Uh)=>{"use strict";p();function EP(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}var Wv=tf().Buffer,ks=Xr();function xP(e,t,r){e.copy(t,r)}Uh.exports=(function(){function e(){EP(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 Wv.alloc(0);for(var n=Wv.allocUnsafe(r>>>0),i=this.head,o=0;i;)xP(i.data,n,o),o+=i.data.length,i=i.next;return n},e})();ks&&ks.inspect&&ks.inspect.custom&&(Uh.exports.prototype[ks.inspect.custom]=function(){var e=ks.inspect({length:this.length});return this.constructor.name+" "+e})});var Fh=B((u4,Yv)=>{"use strict";p();var nf=Ms();function IP(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,nf.nextTick(of,this,e)):nf.nextTick(of,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,nf.nextTick(of,r,o)):nf.nextTick(of,r,o):t&&t(o)}),this)}function AP(){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 of(e,t){e.emit("error",t)}Yv.exports={destroy:IP,undestroy:AP}});var Hh=B((c4,rb)=>{"use strict";p();var Li=Ms();rb.exports=Ot;function Zv(e){var t=this;this.next=null,this.entry=null,this.finish=function(){GP(t,e)}}var OP=!x.default.browser&&["v0.10","v0.9."].indexOf(x.default.version.slice(0,5))>-1?setImmediate:Li.nextTick,Mo;Ot.WritableState=Ls;var Xv=Object.create(No());Xv.inherits=Fe();var RP={deprecate:ch()},Jv=Lh(),af=tf().Buffer,TP=(typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof self<"u"?self:{}).Uint8Array||function(){};function PP(e){return af.from(e)}function BP(e){return af.isBuffer(e)||e instanceof TP}var Qv=Fh();Xv.inherits(Ot,Jv);function NP(){}function Ls(e,t){Mo=Mo||Di(),e=e||{};var r=t instanceof Mo;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){FP(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 Zv(this)}Ls.prototype.getBuffer=function(){for(var t=this.bufferedRequest,r=[];t;)r.push(t),t=t.next;return r};(function(){try{Object.defineProperty(Ls.prototype,"buffer",{get:RP.deprecate(function(){return this.getBuffer()},"_writableState.buffer is deprecated. Use _writableState.getBuffer instead.","DEP0003")})}catch{}})();var sf;typeof Symbol=="function"&&Symbol.hasInstance&&typeof Function.prototype[Symbol.hasInstance]=="function"?(sf=Function.prototype[Symbol.hasInstance],Object.defineProperty(Ot,Symbol.hasInstance,{value:function(e){return sf.call(this,e)?!0:this!==Ot?!1:e&&e._writableState instanceof Ls}})):sf=function(e){return e instanceof this};function Ot(e){if(Mo=Mo||Di(),!sf.call(Ot,this)&&!(this instanceof Mo))return new Ot(e);this._writableState=new Ls(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)),Jv.call(this)}Ot.prototype.pipe=function(){this.emit("error",new Error("Cannot pipe, not readable"))};function MP(e,t){var r=new Error("write after end");e.emit("error",r),Li.nextTick(t,r)}function kP(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),Li.nextTick(n,o),i=!1),i}Ot.prototype.write=function(e,t,r){var n=this._writableState,i=!1,o=!n.objectMode&&BP(e);return o&&!af.isBuffer(e)&&(e=PP(e)),typeof t=="function"&&(r=t,t=null),o?t="buffer":t||(t=n.defaultEncoding),typeof r!="function"&&(r=NP),n.ended?MP(this,r):(o||kP(this,n,e,r))&&(n.pendingcb++,i=LP(this,n,o,e,t,r)),i};Ot.prototype.cork=function(){var e=this._writableState;e.corked++};Ot.prototype.uncork=function(){var e=this._writableState;e.corked&&(e.corked--,!e.writing&&!e.corked&&!e.bufferProcessing&&e.bufferedRequest&&eb(this,e))};Ot.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 CP(e,t,r){return!e.objectMode&&e.decodeStrings!==!1&&typeof t=="string"&&(t=af.from(t,r)),t}Object.defineProperty(Ot.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}});function LP(e,t,r,n,i,o){if(!r){var s=CP(t,n,i);n!==s&&(r=!0,i="buffer",n=s)}var a=t.objectMode?1:n.length;t.length+=a;var f=t.length<t.highWaterMark;if(f||(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 qh(e,t,!1,a,n,i,o);return f}function qh(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 DP(e,t,r,n,i){--t.pendingcb,r?(Li.nextTick(i,n),Li.nextTick(Cs,e,t),e._writableState.errorEmitted=!0,e.emit("error",n)):(i(n),e._writableState.errorEmitted=!0,e.emit("error",n),Cs(e,t))}function UP(e){e.writing=!1,e.writecb=null,e.length-=e.writelen,e.writelen=0}function FP(e,t){var r=e._writableState,n=r.sync,i=r.writecb;if(UP(r),t)DP(e,r,n,t,i);else{var o=tb(r);!o&&!r.corked&&!r.bufferProcessing&&r.bufferedRequest&&eb(e,r),n?OP($v,e,r,o,i):$v(e,r,o,i)}}function $v(e,t,r,n){r||qP(e,t),t.pendingcb--,n(),Cs(e,t)}function qP(e,t){t.length===0&&t.needDrain&&(t.needDrain=!1,e.emit("drain"))}function eb(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,qh(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 Zv(t),t.bufferedRequestCount=0}else{for(;r;){var f=r.chunk,l=r.encoding,y=r.callback,g=t.objectMode?1:f.length;if(qh(e,t,!1,g,f,l,y),r=r.next,t.bufferedRequestCount--,t.writing)break}r===null&&(t.lastBufferedRequest=null)}t.bufferedRequest=r,t.bufferProcessing=!1}Ot.prototype._write=function(e,t,r){r(new Error("_write() is not implemented"))};Ot.prototype._writev=null;Ot.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||KP(this,n,r)};function tb(e){return e.ending&&e.length===0&&e.bufferedRequest===null&&!e.finished&&!e.writing}function HP(e,t){e._final(function(r){t.pendingcb--,r&&e.emit("error",r),t.prefinished=!0,e.emit("prefinish"),Cs(e,t)})}function jP(e,t){!t.prefinished&&!t.finalCalled&&(typeof e._final=="function"?(t.pendingcb++,t.finalCalled=!0,Li.nextTick(HP,e,t)):(t.prefinished=!0,e.emit("prefinish")))}function Cs(e,t){var r=tb(t);return r&&(jP(e,t),t.pendingcb===0&&(t.finished=!0,e.emit("finish"))),r}function KP(e,t,r){t.ending=!0,Cs(e,t),r&&(t.finished?Li.nextTick(r):e.once("finish",r)),t.ended=!0,e.writable=!1}function GP(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(Ot.prototype,"destroyed",{get:function(){return this._writableState===void 0?!1:this._writableState.destroyed},set:function(e){this._writableState&&(this._writableState.destroyed=e)}});Ot.prototype.destroy=Qv.destroy;Ot.prototype._undestroy=Qv.undestroy;Ot.prototype._destroy=function(e,t){this.end(),t(e)}});var Di=B((h4,sb)=>{"use strict";p();var nb=Ms(),VP=Object.keys||function(e){var t=[];for(var r in e)t.push(r);return t};sb.exports=_n;var ib=Object.create(No());ib.inherits=Fe();var ob=Gh(),Kh=Hh();ib.inherits(_n,ob);for(jh=VP(Kh.prototype),uf=0;uf<jh.length;uf++)ff=jh[uf],_n.prototype[ff]||(_n.prototype[ff]=Kh.prototype[ff]);var jh,ff,uf;function _n(e){if(!(this instanceof _n))return new _n(e);ob.call(this,e),Kh.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",WP)}Object.defineProperty(_n.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}});function WP(){this.allowHalfOpen||this._writableState.ended||nb.nextTick(zP,this)}function zP(e){e.end()}Object.defineProperty(_n.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)}});_n.prototype._destroy=function(e,t){this.push(null),this.end(),nb.nextTick(t,e)}});var Gh=B((g4,vb)=>{"use strict";p();var Co=Ms();vb.exports=$e;var YP=jv(),Ds;$e.ReadableState=db;var p4=go().EventEmitter,cb=function(e,t){return e.listeners(t).length},$h=Lh(),Us=tf().Buffer,$P=(typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof self<"u"?self:{}).Uint8Array||function(){};function ZP(e){return Us.from(e)}function XP(e){return Us.isBuffer(e)||e instanceof $P}var lb=Object.create(No());lb.inherits=Fe();var Vh=Xr(),ke=void 0;Vh&&Vh.debuglog?ke=Vh.debuglog("stream"):ke=function(){};var JP=zv(),hb=Fh(),ko;lb.inherits($e,$h);var Wh=["error","close","destroy","pause","resume"];function QP(e,t,r){if(typeof e.prependListener=="function")return e.prependListener(t,r);!e._events||!e._events[t]?e.on(t,r):YP(e._events[t])?e._events[t].unshift(r):e._events[t]=[r,e._events[t]]}function db(e,t){Ds=Ds||Di(),e=e||{};var r=t instanceof Ds;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 JP,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&&(ko||(ko=Ro().StringDecoder),this.decoder=new ko(e.encoding),this.encoding=e.encoding)}function $e(e){if(Ds=Ds||Di(),!(this instanceof $e))return new $e(e);this._readableState=new db(e,this),this.readable=!0,e&&(typeof e.read=="function"&&(this._read=e.read),typeof e.destroy=="function"&&(this._destroy=e.destroy)),$h.call(this)}Object.defineProperty($e.prototype,"destroyed",{get:function(){return this._readableState===void 0?!1:this._readableState.destroyed},set:function(e){this._readableState&&(this._readableState.destroyed=e)}});$e.prototype.destroy=hb.destroy;$e.prototype._undestroy=hb.undestroy;$e.prototype._destroy=function(e,t){this.push(null),t(e)};$e.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=Us.from(e,t),t=""),n=!0),pb(this,e,t,!1,n)};$e.prototype.unshift=function(e){return pb(this,e,null,!0,!1)};function pb(e,t,r,n,i){var o=e._readableState;if(t===null)o.reading=!1,nB(e,o);else{var s;i||(s=eB(o,t)),s?e.emit("error",s):o.objectMode||t&&t.length>0?(typeof t!="string"&&!o.objectMode&&Object.getPrototypeOf(t)!==Us.prototype&&(t=ZP(t)),n?o.endEmitted?e.emit("error",new Error("stream.unshift() after end event")):zh(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?zh(e,o,t,!1):gb(e,o)):zh(e,o,t,!1))):n||(o.reading=!1)}return tB(o)}function zh(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&&cf(e)),gb(e,t)}function eB(e,t){var r;return!XP(t)&&typeof t!="string"&&t!==void 0&&!e.objectMode&&(r=new TypeError("Invalid non-string/buffer chunk")),r}function tB(e){return!e.ended&&(e.needReadable||e.length<e.highWaterMark||e.length===0)}$e.prototype.isPaused=function(){return this._readableState.flowing===!1};$e.prototype.setEncoding=function(e){return ko||(ko=Ro().StringDecoder),this._readableState.decoder=new ko(e),this._readableState.encoding=e,this};var ab=8388608;function rB(e){return e>=ab?e=ab:(e--,e|=e>>>1,e|=e>>>2,e|=e>>>4,e|=e>>>8,e|=e>>>16,e++),e}function ub(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=rB(e)),e<=t.length?e:t.ended?t.length:(t.needReadable=!0,0))}$e.prototype.read=function(e){ke("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 ke("read: emitReadable",t.length,t.ended),t.length===0&&t.ended?Yh(this):cf(this),null;if(e=ub(e,t),e===0&&t.ended)return t.length===0&&Yh(this),null;var n=t.needReadable;ke("need readable",n),(t.length===0||t.length-e<t.highWaterMark)&&(n=!0,ke("length less than watermark",n)),t.ended||t.reading?(n=!1,ke("reading or ended",n)):n&&(ke("do read"),t.reading=!0,t.sync=!0,t.length===0&&(t.needReadable=!0),this._read(t.highWaterMark),t.sync=!1,t.reading||(e=ub(r,t)));var i;return e>0?i=yb(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&&Yh(this)),i!==null&&this.emit("data",i),i};function nB(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,cf(e)}}function cf(e){var t=e._readableState;t.needReadable=!1,t.emittedReadable||(ke("emitReadable",t.flowing),t.emittedReadable=!0,t.sync?Co.nextTick(fb,e):fb(e))}function fb(e){ke("emit readable"),e.emit("readable"),Zh(e)}function gb(e,t){t.readingMore||(t.readingMore=!0,Co.nextTick(iB,e,t))}function iB(e,t){for(var r=t.length;!t.reading&&!t.flowing&&!t.ended&&t.length<t.highWaterMark&&(ke("maybeReadMore read 0"),e.read(0),r!==t.length);)r=t.length;t.readingMore=!1}$e.prototype._read=function(e){this.emit("error",new Error("_read() is not implemented"))};$e.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,ke("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:U;n.endEmitted?Co.nextTick(o):r.once("end",o),e.on("unpipe",s);function s(F,V){ke("onunpipe"),F===r&&V&&V.hasUnpiped===!1&&(V.hasUnpiped=!0,y())}function a(){ke("onend"),e.end()}var f=oB(r);e.on("drain",f);var l=!1;function y(){ke("cleanup"),e.removeListener("close",T),e.removeListener("finish",M),e.removeListener("drain",f),e.removeListener("error",E),e.removeListener("unpipe",s),r.removeListener("end",a),r.removeListener("end",U),r.removeListener("data",v),l=!0,n.awaitDrain&&(!e._writableState||e._writableState.needDrain)&&f()}var g=!1;r.on("data",v);function v(F){ke("ondata"),g=!1;var V=e.write(F);V===!1&&!g&&((n.pipesCount===1&&n.pipes===e||n.pipesCount>1&&mb(n.pipes,e)!==-1)&&!l&&(ke("false write response, pause",n.awaitDrain),n.awaitDrain++,g=!0),r.pause())}function E(F){ke("onerror",F),U(),e.removeListener("error",E),cb(e,"error")===0&&e.emit("error",F)}QP(e,"error",E);function T(){e.removeListener("finish",M),U()}e.once("close",T);function M(){ke("onfinish"),e.removeListener("close",T),U()}e.once("finish",M);function U(){ke("unpipe"),r.unpipe(e)}return e.emit("pipe",r),n.flowing||(ke("pipe resume"),r.resume()),e};function oB(e){return function(){var t=e._readableState;ke("pipeOnDrain",t.awaitDrain),t.awaitDrain&&t.awaitDrain--,t.awaitDrain===0&&cb(e,"data")&&(t.flowing=!0,Zh(e))}}$e.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=mb(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)};$e.prototype.on=function(e,t){var r=$h.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&&cf(this):Co.nextTick(sB,this))}return r};$e.prototype.addListener=$e.prototype.on;function sB(e){ke("readable nexttick read 0"),e.read(0)}$e.prototype.resume=function(){var e=this._readableState;return e.flowing||(ke("resume"),e.flowing=!0,aB(this,e)),this};function aB(e,t){t.resumeScheduled||(t.resumeScheduled=!0,Co.nextTick(uB,e,t))}function uB(e,t){t.reading||(ke("resume read 0"),e.read(0)),t.resumeScheduled=!1,t.awaitDrain=0,e.emit("resume"),Zh(e),t.flowing&&!t.reading&&e.read(0)}$e.prototype.pause=function(){return ke("call pause flowing=%j",this._readableState.flowing),this._readableState.flowing!==!1&&(ke("pause"),this._readableState.flowing=!1,this.emit("pause")),this};function Zh(e){var t=e._readableState;for(ke("flow",t.flowing);t.flowing&&e.read()!==null;);}$e.prototype.wrap=function(e){var t=this,r=this._readableState,n=!1;e.on("end",function(){if(ke("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(ke("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<Wh.length;o++)e.on(Wh[o],this.emit.bind(this,Wh[o]));return this._read=function(s){ke("wrapped _read",s),n&&(n=!1,e.resume())},this};Object.defineProperty($e.prototype,"readableHighWaterMark",{enumerable:!1,get:function(){return this._readableState.highWaterMark}});$e._fromList=yb;function yb(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=fB(e,t.buffer,t.decoder),r}function fB(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?cB(e,t):lB(e,t),n}function cB(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 lB(e,t){var r=Us.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 Yh(e){var t=e._readableState;if(t.length>0)throw new Error('"endReadable()" called on non-empty stream');t.endEmitted||(t.ended=!0,Co.nextTick(hB,t,e))}function hB(e,t){!e.endEmitted&&e.length===0&&(e.endEmitted=!0,t.readable=!1,t.emit("end"))}function mb(e,t){for(var r=0,n=e.length;r<n;r++)if(e[r]===t)return r;return-1}});var Xh=B((m4,Sb)=>{"use strict";p();Sb.exports=Sn;var lf=Di(),_b=Object.create(No());_b.inherits=Fe();_b.inherits(Sn,lf);function dB(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);lf.call(this,e),this._transformState={afterTransform:dB.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",pB)}function pB(){var e=this;typeof this._flush=="function"?this._flush(function(t,r){bb(e,t,r)}):bb(this,null,null)}Sn.prototype.push=function(e,t){return this._transformState.needTransform=!1,lf.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;lf.prototype._destroy.call(this,e,function(n){t(n),r.emit("close")})};function bb(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 Ib=B((b4,xb)=>{"use strict";p();xb.exports=Fs;var wb=Xh(),Eb=Object.create(No());Eb.inherits=Fe();Eb.inherits(Fs,wb);function Fs(e){if(!(this instanceof Fs))return new Fs(e);wb.call(this,e)}Fs.prototype._transform=function(e,t,r){r(null,e)}});var Ob=B((en,Ab)=>{p();en=Ab.exports=Gh();en.Stream=en;en.Readable=en;en.Writable=Hh();en.Duplex=Di();en.Transform=Xh();en.PassThrough=Ib()});var Pb=B((w4,Tb)=>{"use strict";p();var gB=Gt().Buffer,yB=qv(),Rb=Ob().Transform,mB=Fe();function Xn(e){Rb.call(this),this._block=gB.allocUnsafe(e),this._blockSize=e,this._blockOffset=0,this._length=[0,0,0,0],this._finalized=!1}mB(Xn,Rb);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=yB(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")};Tb.exports=Xn});var Qh=B((x4,Db)=>{"use strict";p();var Jh=Nt().Buffer,vB=Fe(),Lb=Pb(),bB=new Array(16),qs=[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],Hs=[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],js=[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],Ks=[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],Vs=[1352829926,1548603684,1836072691,2053994217,0];function Ui(e,t){return e<<t|e>>>32-t}function Bb(e,t,r,n,i,o,s,a){return Ui(e+(t^r^n)+o+s|0,a)+i|0}function Nb(e,t,r,n,i,o,s,a){return Ui(e+(t&r|~t&n)+o+s|0,a)+i|0}function Mb(e,t,r,n,i,o,s,a){return Ui(e+((t|~r)^n)+o+s|0,a)+i|0}function kb(e,t,r,n,i,o,s,a){return Ui(e+(t&n|r&~n)+o+s|0,a)+i|0}function Cb(e,t,r,n,i,o,s,a){return Ui(e+(t^(r|~n))+o+s|0,a)+i|0}function hf(){Lb.call(this,64),this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878,this._e=3285377520}vB(hf,Lb);hf.prototype._update=function(){for(var e=bB,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,f=this._b|0,l=this._c|0,y=this._d|0,g=this._e|0,v=0;v<80;v+=1){var E,T;v<16?(E=Bb(r,n,i,o,s,e[qs[v]],Gs[0],js[v]),T=Cb(a,f,l,y,g,e[Hs[v]],Vs[0],Ks[v])):v<32?(E=Nb(r,n,i,o,s,e[qs[v]],Gs[1],js[v]),T=kb(a,f,l,y,g,e[Hs[v]],Vs[1],Ks[v])):v<48?(E=Mb(r,n,i,o,s,e[qs[v]],Gs[2],js[v]),T=Mb(a,f,l,y,g,e[Hs[v]],Vs[2],Ks[v])):v<64?(E=kb(r,n,i,o,s,e[qs[v]],Gs[3],js[v]),T=Nb(a,f,l,y,g,e[Hs[v]],Vs[3],Ks[v])):(E=Cb(r,n,i,o,s,e[qs[v]],Gs[4],js[v]),T=Bb(a,f,l,y,g,e[Hs[v]],Vs[4],Ks[v])),r=s,s=o,o=Ui(i,10),i=n,n=E,a=g,g=y,y=Ui(l,10),l=f,f=T}var M=this._b+i+y|0;this._b=this._c+o+g|0,this._c=this._d+s+a|0,this._d=this._e+r+f|0,this._e=this._a+n+l|0,this._a=M};hf.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=Jh.alloc?Jh.alloc(20):new Jh(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};Db.exports=hf});var Fi=B((A4,Ub)=>{"use strict";p();var _B=Gt().Buffer,SB=Qu();function df(e,t){this._block=_B.alloc(e),this._finalSize=t,this._blockSize=e,this._len=0}df.prototype.update=function(e,t){e=SB(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,f=Math.min(i-s,n-a),l=0;l<f;l++)r[a+l]=e[s+l];o+=f,s+=f,o%n===0&&this._update(r)}return this._len+=i,this};df.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};df.prototype._update=function(){throw new Error("_update must be implemented by subclass")};Ub.exports=df});var Hb=B((R4,qb)=>{"use strict";p();var wB=Fe(),Fb=Fi(),EB=Gt().Buffer,xB=[1518500249,1859775393,-1894007588,-899497514],IB=new Array(80);function Ws(){this.init(),this._w=IB,Fb.call(this,64,56)}wB(Ws,Fb);Ws.prototype.init=function(){return this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878,this._e=3285377520,this};function AB(e){return e<<5|e>>>27}function OB(e){return e<<30|e>>>2}function RB(e,t,r,n){return e===0?t&r|~t&n:e===2?t&r|t&n|r&n:t^r^n}Ws.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 f=0;f<80;++f){var l=~~(f/20),y=AB(r)+RB(l,n,i,o)+s+t[f]+xB[l]|0;s=o,o=i,i=OB(n),n=r,r=y}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};Ws.prototype._hash=function(){var e=EB.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};qb.exports=Ws});var Gb=B((P4,Kb)=>{"use strict";p();var TB=Fe(),jb=Fi(),PB=Gt().Buffer,BB=[1518500249,1859775393,-1894007588,-899497514],NB=new Array(80);function zs(){this.init(),this._w=NB,jb.call(this,64,56)}TB(zs,jb);zs.prototype.init=function(){return this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878,this._e=3285377520,this};function MB(e){return e<<1|e>>>31}function kB(e){return e<<5|e>>>27}function CB(e){return e<<30|e>>>2}function LB(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]=MB(t[a-3]^t[a-8]^t[a-14]^t[a-16]);for(var f=0;f<80;++f){var l=~~(f/20),y=kB(r)+LB(l,n,i,o)+s+t[f]+BB[l]|0;s=o,o=i,i=CB(n),n=r,r=y}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=PB.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=zs});var ed=B((N4,Wb)=>{"use strict";p();var DB=Fe(),Vb=Fi(),UB=Gt().Buffer,FB=[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],qB=new Array(64);function Ys(){this.init(),this._w=qB,Vb.call(this,64,56)}DB(Ys,Vb);Ys.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 HB(e,t,r){return r^e&(t^r)}function jB(e,t,r){return e&t|r&(e|t)}function KB(e){return(e>>>2|e<<30)^(e>>>13|e<<19)^(e>>>22|e<<10)}function GB(e){return(e>>>6|e<<26)^(e>>>11|e<<21)^(e>>>25|e<<7)}function VB(e){return(e>>>7|e<<25)^(e>>>18|e<<14)^e>>>3}function WB(e){return(e>>>17|e<<15)^(e>>>19|e<<13)^e>>>10}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=this._f|0,f=this._g|0,l=this._h|0,y=0;y<16;++y)t[y]=e.readInt32BE(y*4);for(;y<64;++y)t[y]=WB(t[y-2])+t[y-7]+VB(t[y-15])+t[y-16]|0;for(var g=0;g<64;++g){var v=l+GB(s)+HB(s,a,f)+FB[g]+t[g]|0,E=KB(r)+jB(r,n,i)|0;l=f,f=a,a=s,s=o+v|0,o=i,i=n,n=r,r=v+E|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=f+this._g|0,this._h=l+this._h|0};Ys.prototype._hash=function(){var e=UB.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};Wb.exports=Ys});var Yb=B((k4,zb)=>{"use strict";p();var zB=Fe(),YB=ed(),$B=Fi(),ZB=Gt().Buffer,XB=new Array(64);function pf(){this.init(),this._w=XB,$B.call(this,64,56)}zB(pf,YB);pf.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};pf.prototype._hash=function(){var e=ZB.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};zb.exports=pf});var td=B((L4,t_)=>{"use strict";p();var JB=Fe(),e_=Fi(),QB=Gt().Buffer,$b=[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],eN=new Array(160);function $s(){this.init(),this._w=eN,e_.call(this,128,112)}JB($s,e_);$s.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 Zb(e,t,r){return r^e&(t^r)}function Xb(e,t,r){return e&t|r&(e|t)}function Jb(e,t){return(e>>>28|t<<4)^(t>>>2|e<<30)^(t>>>7|e<<25)}function Qb(e,t){return(e>>>14|t<<18)^(e>>>18|t<<14)^(t>>>9|e<<23)}function tN(e,t){return(e>>>1|t<<31)^(e>>>8|t<<24)^e>>>7}function rN(e,t){return(e>>>1|t<<31)^(e>>>8|t<<24)^(e>>>7|t<<25)}function nN(e,t){return(e>>>19|t<<13)^(t>>>29|e<<3)^e>>>6}function iN(e,t){return(e>>>19|t<<13)^(t>>>29|e<<3)^(e>>>6|t<<26)}function qt(e,t){return e>>>0<t>>>0?1:0}$s.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,f=this._gh|0,l=this._hh|0,y=this._al|0,g=this._bl|0,v=this._cl|0,E=this._dl|0,T=this._el|0,M=this._fl|0,U=this._gl|0,F=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],G=t[V-30+1],ie=tN(z,G),ee=rN(G,z);z=t[V-4],G=t[V-4+1];var pe=nN(z,G),le=iN(G,z),me=t[V-14],I=t[V-14+1],u=t[V-32],h=t[V-32+1],m=ee+I|0,S=ie+me+qt(m,ee)|0;m=m+le|0,S=S+pe+qt(m,le)|0,m=m+h|0,S=S+u+qt(m,h)|0,t[V]=S,t[V+1]=m}for(var w=0;w<160;w+=2){S=t[w],m=t[w+1];var R=Xb(r,n,i),A=Xb(y,g,v),_=Jb(r,y),c=Jb(y,r),b=Qb(s,T),k=Qb(T,s),L=$b[w],H=$b[w+1],W=Zb(s,a,f),te=Zb(T,M,U),X=F+k|0,ue=l+b+qt(X,F)|0;X=X+te|0,ue=ue+W+qt(X,te)|0,X=X+H|0,ue=ue+L+qt(X,H)|0,X=X+m|0,ue=ue+S+qt(X,m)|0;var fe=c+A|0,O=_+R+qt(fe,c)|0;l=f,F=U,f=a,U=M,a=s,M=T,T=E+X|0,s=o+ue+qt(T,E)|0,o=i,E=v,i=n,v=g,n=r,g=y,y=X+fe|0,r=ue+O+qt(y,X)|0}this._al=this._al+y|0,this._bl=this._bl+g|0,this._cl=this._cl+v|0,this._dl=this._dl+E|0,this._el=this._el+T|0,this._fl=this._fl+M|0,this._gl=this._gl+U|0,this._hl=this._hl+F|0,this._ah=this._ah+r+qt(this._al,y)|0,this._bh=this._bh+n+qt(this._bl,g)|0,this._ch=this._ch+i+qt(this._cl,v)|0,this._dh=this._dh+o+qt(this._dl,E)|0,this._eh=this._eh+s+qt(this._el,T)|0,this._fh=this._fh+a+qt(this._fl,M)|0,this._gh=this._gh+f+qt(this._gl,U)|0,this._hh=this._hh+l+qt(this._hl,F)|0};$s.prototype._hash=function(){var e=QB.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};t_.exports=$s});var n_=B((U4,r_)=>{"use strict";p();var oN=Fe(),sN=td(),aN=Fi(),uN=Gt().Buffer,fN=new Array(160);function gf(){this.init(),this._w=fN,aN.call(this,128,112)}oN(gf,sN);gf.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};gf.prototype._hash=function(){var e=uN.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};r_.exports=gf});var rd=B((q4,wn)=>{"use strict";p();wn.exports=function(t){var r=t.toLowerCase(),n=wn.exports[r];if(!n)throw new Error(r+" is not supported (we accept pull requests)");return new n};wn.exports.sha=Hb();wn.exports.sha1=Gb();wn.exports.sha224=Yb();wn.exports.sha256=ed();wn.exports.sha384=n_();wn.exports.sha512=td()});var yf=B((j4,o_)=>{"use strict";p();var cN=Gt().Buffer,i_=Mh().Transform,lN=Ro().StringDecoder,hN=Fe(),dN=Qu();function Br(e){i_.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}hN(Br,i_);Br.prototype.update=function(e,t,r){var n=dN(e,t),i=this._update(n);return this.hashMode?this:(r&&(i=this._toString(i,r)),i)};Br.prototype.setAutoPadding=function(){};Br.prototype.getAuthTag=function(){throw new Error("trying to get auth tag in unsupported state")};Br.prototype.setAuthTag=function(){throw new Error("trying to set auth tag in unsupported state")};Br.prototype.setAAD=function(){throw new Error("trying to set aad in unsupported state")};Br.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)}};Br.prototype._flush=function(e){var t;try{this.push(this.__final())}catch(r){t=r}e(t)};Br.prototype._finalOrDigest=function(e){var t=this.__final()||cN.alloc(0);return e&&(t=this._toString(t,e,!0)),t};Br.prototype._toString=function(e,t,r){if(this._decoder||(this._decoder=new lN(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};o_.exports=Br});var u_=B((G4,a_)=>{"use strict";p();var pN=Fe(),gN=kh(),yN=Qh(),mN=rd(),s_=yf();function mf(e){s_.call(this,"digest"),this._hash=e}pN(mf,s_);mf.prototype._update=function(e){this._hash.update(e)};mf.prototype._final=function(){return this._hash.digest()};a_.exports=function(t){return t=t.toLowerCase(),t==="md5"?new gN:t==="rmd160"||t==="ripemd160"?new yN:new mf(mN(t))}});var l_=B((W4,c_)=>{"use strict";p();var vN=Fe(),qi=Gt().Buffer,f_=yf(),bN=qi.alloc(128),Lo=64;function vf(e,t){f_.call(this,"digest"),typeof t=="string"&&(t=qi.from(t)),this._alg=e,this._key=t,t.length>Lo?t=e(t):t.length<Lo&&(t=qi.concat([t,bN],Lo));for(var r=this._ipad=qi.allocUnsafe(Lo),n=this._opad=qi.allocUnsafe(Lo),i=0;i<Lo;i++)r[i]=t[i]^54,n[i]=t[i]^92;this._hash=[r]}vN(vf,f_);vf.prototype._update=function(e){this._hash.push(e)};vf.prototype._final=function(){var e=this._alg(qi.concat(this._hash));return this._alg(qi.concat([this._opad,e]))};c_.exports=vf});var d_=B((Y4,h_)=>{p();var _N=kh();h_.exports=function(e){return new _N().update(e).digest()}});var y_=B((Z4,g_)=>{"use strict";p();var SN=Fe(),wN=l_(),p_=yf(),Zs=Gt().Buffer,EN=d_(),nd=Qh(),id=rd(),xN=Zs.alloc(128);function Xs(e,t){p_.call(this,"digest"),typeof t=="string"&&(t=Zs.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 nd:id(e);t=n.update(t).digest()}else t.length<r&&(t=Zs.concat([t,xN],r));for(var i=this._ipad=Zs.allocUnsafe(r),o=this._opad=Zs.allocUnsafe(r),s=0;s<r;s++)i[s]=t[s]^54,o[s]=t[s]^92;this._hash=e==="rmd160"?new nd:id(e),this._hash.update(i)}SN(Xs,p_);Xs.prototype._update=function(e){this._hash.update(e)};Xs.prototype._final=function(){var e=this._hash.digest(),t=this._alg==="rmd160"?new nd:id(this._alg);return t.update(this._opad).update(e).digest()};g_.exports=function(t,r){return t=t.toLowerCase(),t==="rmd160"||t==="ripemd160"?new Xs("rmd160",r):t==="md5"?new wN(EN,r):new Xs(t,r)}});var m_=B((J4,sd)=>{"use strict";p();var od=65536,IN=4294967295;function AN(){throw new Error(`Secure random number generation is not supported by this browser.
|
|
10
|
+
`)+" "+r[1]:r[0]+t+" "+e.join(", ")+" "+r[1]}Ae.types=vm();function Em(e){return Array.isArray(e)}Ae.isArray=Em;function nh(e){return typeof e=="boolean"}Ae.isBoolean=nh;function ku(e){return e===null}Ae.isNull=ku;function MR(e){return e==null}Ae.isNullOrUndefined=MR;function xm(e){return typeof e=="number"}Ae.isNumber=xm;function Cu(e){return typeof e=="string"}Ae.isString=Cu;function kR(e){return typeof e=="symbol"}Ae.isSymbol=kR;function Pi(e){return e===void 0}Ae.isUndefined=Pi;function xs(e){return xo(e)&&ih(e)==="[object RegExp]"}Ae.isRegExp=xs;Ae.types.isRegExp=xs;function xo(e){return typeof e=="object"&&e!==null}Ae.isObject=xo;function Mu(e){return xo(e)&&ih(e)==="[object Date]"}Ae.isDate=Mu;Ae.types.isDate=Mu;function Is(e){return xo(e)&&(ih(e)==="[object Error]"||e instanceof Error)}Ae.isError=Is;Ae.types.isNativeError=Is;function Bu(e){return typeof e=="function"}Ae.isFunction=Bu;function CR(e){return e===null||typeof e=="boolean"||typeof e=="number"||typeof e=="string"||typeof e=="symbol"||typeof e>"u"}Ae.isPrimitive=CR;Ae.isBuffer=_m();function ih(e){return Object.prototype.toString.call(e)}function th(e){return e<10?"0"+e.toString(10):e.toString(10)}var LR=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function DR(){var e=new Date,t=[th(e.getHours()),th(e.getMinutes()),th(e.getSeconds())].join(":");return[e.getDate(),LR[e.getMonth()],t].join(" ")}Ae.log=function(){console.log("%s - %s",DR(),Ae.format.apply(Ae,arguments))};Ae.inherits=Fe();Ae._extend=function(e,t){if(!t||!xo(t))return e;for(var r=Object.keys(t),n=r.length;n--;)e[r[n]]=t[r[n]];return e};function Im(e,t){return Object.prototype.hasOwnProperty.call(e,t)}var Ti=typeof Symbol<"u"?Symbol("util.promisify.custom"):void 0;Ae.promisify=function(t){if(typeof t!="function")throw new TypeError('The "original" argument must be of type Function');if(Ti&&t[Ti]){var r=t[Ti];if(typeof r!="function")throw new TypeError('The "util.promisify.custom" argument must be of type Function');return Object.defineProperty(r,Ti,{value:r,enumerable:!1,writable:!1,configurable:!0}),r}function r(){for(var n,i,o=new Promise(function(f,l){n=f,i=l}),s=[],a=0;a<arguments.length;a++)s.push(arguments[a]);s.push(function(f,l){f?i(f):n(l)});try{t.apply(this,s)}catch(f){i(f)}return o}return Object.setPrototypeOf(r,Object.getPrototypeOf(t)),Ti&&Object.defineProperty(r,Ti,{value:r,enumerable:!1,writable:!1,configurable:!0}),Object.defineProperties(r,Sm(t))};Ae.promisify.custom=Ti;function UR(e,t){if(!e){var r=new Error("Promise was rejected with a falsy value");r.reason=e,e=r}return t(e)}function FR(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(UR.bind(null,a,s))})}return Object.setPrototypeOf(t,Object.getPrototypeOf(e)),Object.defineProperties(t,Sm(e)),t}Ae.callbackify=FR});var Bm=B((o4,Pm)=>{"use strict";p();function Am(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 Om(e){for(var t=1;t<arguments.length;t++){var r=arguments[t]!=null?arguments[t]:{};t%2?Am(Object(r),!0).forEach(function(n){qR(e,n,r[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):Am(Object(r)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(r,n))})}return e}function qR(e,t,r){return t=Tm(t),t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function HR(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function Rm(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,Tm(n.key),n)}}function jR(e,t,r){return t&&Rm(e.prototype,t),r&&Rm(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e}function Tm(e){var t=KR(e,"string");return typeof t=="symbol"?t:String(t)}function KR(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 GR=Nt(),Lu=GR.Buffer,VR=Xr(),oh=VR.inspect,WR=oh&&oh.custom||"inspect";function zR(e,t,r){Lu.prototype.copy.call(e,t,r)}Pm.exports=(function(){function e(){HR(this,e),this.head=null,this.tail=null,this.length=0}return jR(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 Lu.alloc(0);for(var n=Lu.allocUnsafe(r>>>0),i=this.head,o=0;i;)zR(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=Lu.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:WR,value:function(r,n){return oh(this,Om(Om({},n),{},{depth:0,customInspect:!1}))}}]),e})()});var ah=B((a4,Mm)=>{"use strict";p();function YR(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(sh,this,e)):x.default.nextTick(sh,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(Du,r):(r._writableState.errorEmitted=!0,x.default.nextTick(Nm,r,o)):x.default.nextTick(Nm,r,o):t?(x.default.nextTick(Du,r),t(o)):x.default.nextTick(Du,r)}),this)}function Nm(e,t){sh(e,t),Du(e)}function Du(e){e._writableState&&!e._writableState.emitClose||e._readableState&&!e._readableState.emitClose||e.emit("close")}function $R(){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 sh(e,t){e.emit("error",t)}function ZR(e,t){var r=e._readableState,n=e._writableState;r&&r.autoDestroy||n&&n.autoDestroy?e.destroy(t):e.emit("error",t)}Mm.exports={destroy:YR,undestroy:$R,errorOrDestroy:ZR}});var Bi=B((f4,Lm)=>{"use strict";p();function XR(e,t){e.prototype=Object.create(t.prototype),e.prototype.constructor=e,e.__proto__=t}var Cm={};function _r(e,t,r){r||(r=Error);function n(o,s,a){return typeof t=="string"?t:t(o,s,a)}var i=(function(o){XR(s,o);function s(a,f,l){return o.call(this,n(a,f,l))||this}return s})(r);i.prototype.name=r.name,i.prototype.code=e,Cm[e]=i}function km(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 JR(e,t,r){return e.substr(!r||r<0?0:+r,t.length)===t}function QR(e,t,r){return(r===void 0||r>e.length)&&(r=e.length),e.substring(r-t.length,r)===t}function eT(e,t,r){return typeof r!="number"&&(r=0),r+t.length>e.length?!1:e.indexOf(t,r)!==-1}_r("ERR_INVALID_OPT_VALUE",function(e,t){return'The value "'+t+'" is invalid for option "'+e+'"'},TypeError);_r("ERR_INVALID_ARG_TYPE",function(e,t,r){var n;typeof t=="string"&&JR(t,"not ")?(n="must not be",t=t.replace(/^not /,"")):n="must be";var i;if(QR(e," argument"))i="The ".concat(e," ").concat(n," ").concat(km(t,"type"));else{var o=eT(e,".")?"property":"argument";i='The "'.concat(e,'" ').concat(o," ").concat(n," ").concat(km(t,"type"))}return i+=". Received type ".concat(typeof r),i},TypeError);_r("ERR_STREAM_PUSH_AFTER_EOF","stream.push() after EOF");_r("ERR_METHOD_NOT_IMPLEMENTED",function(e){return"The "+e+" method is not implemented"});_r("ERR_STREAM_PREMATURE_CLOSE","Premature close");_r("ERR_STREAM_DESTROYED",function(e){return"Cannot call "+e+" after a stream was destroyed"});_r("ERR_MULTIPLE_CALLBACK","Callback called multiple times");_r("ERR_STREAM_CANNOT_PIPE","Cannot pipe, not readable");_r("ERR_STREAM_WRITE_AFTER_END","write after end");_r("ERR_STREAM_NULL_VALUES","May not write null values to stream",TypeError);_r("ERR_UNKNOWN_ENCODING",function(e){return"Unknown encoding: "+e},TypeError);_r("ERR_STREAM_UNSHIFT_AFTER_END_EVENT","stream.unshift() after end event");Lm.exports.codes=Cm});var uh=B((l4,Dm)=>{"use strict";p();var tT=Bi().codes.ERR_INVALID_OPT_VALUE;function rT(e,t,r){return e.highWaterMark!=null?e.highWaterMark:t?e[r]:null}function nT(e,t,r,n){var i=rT(t,n,r);if(i!=null){if(!(isFinite(i)&&Math.floor(i)===i)||i<0){var o=n?r:"highWaterMark";throw new tT(o,i)}return Math.floor(i)}return e.objectMode?16:16*1024}Dm.exports={getHighWaterMark:nT}});var ch=B((d4,Um)=>{p();Um.exports=iT;function iT(e,t){if(fh("noDeprecation"))return e;var r=!1;function n(){if(!r){if(fh("throwDeprecation"))throw new Error(t);fh("traceDeprecation")?console.trace(t):console.warn(t),r=!0}return e.apply(this,arguments)}return n}function fh(e){try{if(!globalThis.localStorage)return!1}catch{return!1}var t=globalThis.localStorage[e];return t==null?!1:String(t).toLowerCase()==="true"}});var dh=B((g4,Gm)=>{"use strict";p();Gm.exports=Qe;function qm(e){var t=this;this.next=null,this.entry=null,this.finish=function(){BT(t,e)}}var Io;Qe.WritableState=Os;var oT={deprecate:ch()},Hm=Al(),Fu=Nt().Buffer,sT=(typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof self<"u"?self:{}).Uint8Array||function(){};function aT(e){return Fu.from(e)}function uT(e){return Fu.isBuffer(e)||e instanceof sT}var hh=ah(),fT=uh(),cT=fT.getHighWaterMark,Wn=Bi().codes,lT=Wn.ERR_INVALID_ARG_TYPE,hT=Wn.ERR_METHOD_NOT_IMPLEMENTED,dT=Wn.ERR_MULTIPLE_CALLBACK,pT=Wn.ERR_STREAM_CANNOT_PIPE,gT=Wn.ERR_STREAM_DESTROYED,yT=Wn.ERR_STREAM_NULL_VALUES,mT=Wn.ERR_STREAM_WRITE_AFTER_END,vT=Wn.ERR_UNKNOWN_ENCODING,Ao=hh.errorOrDestroy;Fe()(Qe,Hm);function bT(){}function Os(e,t,r){Io=Io||Ni(),e=e||{},typeof r!="boolean"&&(r=t instanceof Io),this.objectMode=!!e.objectMode,r&&(this.objectMode=this.objectMode||!!e.writableObjectMode),this.highWaterMark=cT(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){AT(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 qm(this)}Os.prototype.getBuffer=function(){for(var t=this.bufferedRequest,r=[];t;)r.push(t),t=t.next;return r};(function(){try{Object.defineProperty(Os.prototype,"buffer",{get:oT.deprecate(function(){return this.getBuffer()},"_writableState.buffer is deprecated. Use _writableState.getBuffer instead.","DEP0003")})}catch{}})();var Uu;typeof Symbol=="function"&&Symbol.hasInstance&&typeof Function.prototype[Symbol.hasInstance]=="function"?(Uu=Function.prototype[Symbol.hasInstance],Object.defineProperty(Qe,Symbol.hasInstance,{value:function(t){return Uu.call(this,t)?!0:this!==Qe?!1:t&&t._writableState instanceof Os}})):Uu=function(t){return t instanceof this};function Qe(e){Io=Io||Ni();var t=this instanceof Io;if(!t&&!Uu.call(Qe,this))return new Qe(e);this._writableState=new Os(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)),Hm.call(this)}Qe.prototype.pipe=function(){Ao(this,new pT)};function _T(e,t){var r=new mT;Ao(e,r),x.default.nextTick(t,r)}function ST(e,t,r,n){var i;return r===null?i=new yT:typeof r!="string"&&!t.objectMode&&(i=new lT("chunk",["string","Buffer"],r)),i?(Ao(e,i),x.default.nextTick(n,i),!1):!0}Qe.prototype.write=function(e,t,r){var n=this._writableState,i=!1,o=!n.objectMode&&uT(e);return o&&!Fu.isBuffer(e)&&(e=aT(e)),typeof t=="function"&&(r=t,t=null),o?t="buffer":t||(t=n.defaultEncoding),typeof r!="function"&&(r=bT),n.ending?_T(this,r):(o||ST(this,n,e,r))&&(n.pendingcb++,i=ET(this,n,o,e,t,r)),i};Qe.prototype.cork=function(){this._writableState.corked++};Qe.prototype.uncork=function(){var e=this._writableState;e.corked&&(e.corked--,!e.writing&&!e.corked&&!e.bufferProcessing&&e.bufferedRequest&&jm(this,e))};Qe.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 vT(t);return this._writableState.defaultEncoding=t,this};Object.defineProperty(Qe.prototype,"writableBuffer",{enumerable:!1,get:function(){return this._writableState&&this._writableState.getBuffer()}});function wT(e,t,r){return!e.objectMode&&e.decodeStrings!==!1&&typeof t=="string"&&(t=Fu.from(t,r)),t}Object.defineProperty(Qe.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}});function ET(e,t,r,n,i,o){if(!r){var s=wT(t,n,i);n!==s&&(r=!0,i="buffer",n=s)}var a=t.objectMode?1:n.length;t.length+=a;var f=t.length<t.highWaterMark;if(f||(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 lh(e,t,!1,a,n,i,o);return f}function lh(e,t,r,n,i,o,s){t.writelen=n,t.writecb=s,t.writing=!0,t.sync=!0,t.destroyed?t.onwrite(new gT("write")):r?e._writev(i,t.onwrite):e._write(i,o,t.onwrite),t.sync=!1}function xT(e,t,r,n,i){--t.pendingcb,r?(x.default.nextTick(i,n),x.default.nextTick(As,e,t),e._writableState.errorEmitted=!0,Ao(e,n)):(i(n),e._writableState.errorEmitted=!0,Ao(e,n),As(e,t))}function IT(e){e.writing=!1,e.writecb=null,e.length-=e.writelen,e.writelen=0}function AT(e,t){var r=e._writableState,n=r.sync,i=r.writecb;if(typeof i!="function")throw new dT;if(IT(r),t)xT(e,r,n,t,i);else{var o=Km(r)||e.destroyed;!o&&!r.corked&&!r.bufferProcessing&&r.bufferedRequest&&jm(e,r),n?x.default.nextTick(Fm,e,r,o,i):Fm(e,r,o,i)}}function Fm(e,t,r,n){r||OT(e,t),t.pendingcb--,n(),As(e,t)}function OT(e,t){t.length===0&&t.needDrain&&(t.needDrain=!1,e.emit("drain"))}function jm(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,lh(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 qm(t),t.bufferedRequestCount=0}else{for(;r;){var f=r.chunk,l=r.encoding,y=r.callback,g=t.objectMode?1:f.length;if(lh(e,t,!1,g,f,l,y),r=r.next,t.bufferedRequestCount--,t.writing)break}r===null&&(t.lastBufferedRequest=null)}t.bufferedRequest=r,t.bufferProcessing=!1}Qe.prototype._write=function(e,t,r){r(new hT("_write()"))};Qe.prototype._writev=null;Qe.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||PT(this,n,r),this};Object.defineProperty(Qe.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 RT(e,t){e._final(function(r){t.pendingcb--,r&&Ao(e,r),t.prefinished=!0,e.emit("prefinish"),As(e,t)})}function TT(e,t){!t.prefinished&&!t.finalCalled&&(typeof e._final=="function"&&!t.destroyed?(t.pendingcb++,t.finalCalled=!0,x.default.nextTick(RT,e,t)):(t.prefinished=!0,e.emit("prefinish")))}function As(e,t){var r=Km(t);if(r&&(TT(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 PT(e,t,r){t.ending=!0,As(e,t),r&&(t.finished?x.default.nextTick(r):e.once("finish",r)),t.ended=!0,e.writable=!1}function BT(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(Qe.prototype,"destroyed",{enumerable:!1,get:function(){return this._writableState===void 0?!1:this._writableState.destroyed},set:function(t){this._writableState&&(this._writableState.destroyed=t)}});Qe.prototype.destroy=hh.destroy;Qe.prototype._undestroy=hh.undestroy;Qe.prototype._destroy=function(e,t){t(e)}});var Ni=B((m4,Wm)=>{"use strict";p();var NT=Object.keys||function(e){var t=[];for(var r in e)t.push(r);return t};Wm.exports=Jr;var Vm=yh(),gh=dh();Fe()(Jr,Vm);for(ph=NT(gh.prototype),qu=0;qu<ph.length;qu++)Hu=ph[qu],Jr.prototype[Hu]||(Jr.prototype[Hu]=gh.prototype[Hu]);var ph,Hu,qu;function Jr(e){if(!(this instanceof Jr))return new Jr(e);Vm.call(this,e),gh.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",MT)))}Object.defineProperty(Jr.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}});Object.defineProperty(Jr.prototype,"writableBuffer",{enumerable:!1,get:function(){return this._writableState&&this._writableState.getBuffer()}});Object.defineProperty(Jr.prototype,"writableLength",{enumerable:!1,get:function(){return this._writableState.length}});function MT(){this._writableState.ended||x.default.nextTick(kT,this)}function kT(e){e.end()}Object.defineProperty(Jr.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 $m=B((mh,Ym)=>{p();var ju=Nt(),mn=ju.Buffer;function zm(e,t){for(var r in e)t[r]=e[r]}mn.from&&mn.alloc&&mn.allocUnsafe&&mn.allocUnsafeSlow?Ym.exports=ju:(zm(ju,mh),mh.Buffer=Oo);function Oo(e,t,r){return mn(e,t,r)}zm(mn,Oo);Oo.from=function(e,t,r){if(typeof e=="number")throw new TypeError("Argument must not be a number");return mn(e,t,r)};Oo.alloc=function(e,t,r){if(typeof e!="number")throw new TypeError("Argument must be a number");var n=mn(e);return t!==void 0?typeof r=="string"?n.fill(t,r):n.fill(t):n.fill(0),n};Oo.allocUnsafe=function(e){if(typeof e!="number")throw new TypeError("Argument must be a number");return mn(e)};Oo.allocUnsafeSlow=function(e){if(typeof e!="number")throw new TypeError("Argument must be a number");return ju.SlowBuffer(e)}});var Ro=B(Xm=>{"use strict";p();var bh=$m().Buffer,Zm=bh.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 CT(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 LT(e){var t=CT(e);if(typeof t!="string"&&(bh.isEncoding===Zm||!Zm(e)))throw new Error("Unknown encoding: "+e);return t||e}Xm.StringDecoder=Rs;function Rs(e){this.encoding=LT(e);var t;switch(this.encoding){case"utf16le":this.text=jT,this.end=KT,t=4;break;case"utf8":this.fillLast=FT,t=4;break;case"base64":this.text=GT,this.end=VT,t=3;break;default:this.write=WT,this.end=zT;return}this.lastNeed=0,this.lastTotal=0,this.lastChar=bh.allocUnsafe(t)}Rs.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||""};Rs.prototype.end=HT;Rs.prototype.text=qT;Rs.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 vh(e){return e<=127?0:e>>5===6?2:e>>4===14?3:e>>3===30?4:e>>6===2?-1:-2}function DT(e,t,r){var n=t.length-1;if(n<r)return 0;var i=vh(t[n]);return i>=0?(i>0&&(e.lastNeed=i-1),i):--n<r||i===-2?0:(i=vh(t[n]),i>=0?(i>0&&(e.lastNeed=i-2),i):--n<r||i===-2?0:(i=vh(t[n]),i>=0?(i>0&&(i===2?i=0:e.lastNeed=i-3),i):0))}function UT(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 FT(e){var t=this.lastTotal-this.lastNeed,r=UT(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 qT(e,t){var r=DT(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 HT(e){var t=e&&e.length?this.write(e):"";return this.lastNeed?t+"\uFFFD":t}function jT(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 KT(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 GT(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 VT(e){var t=e&&e.length?this.write(e):"";return this.lastNeed?t+this.lastChar.toString("base64",0,3-this.lastNeed):t}function WT(e){return e.toString(this.encoding)}function zT(e){return e&&e.length?this.write(e):""}});var Ku=B((w4,ev)=>{"use strict";p();var Jm=Bi().codes.ERR_STREAM_PREMATURE_CLOSE;function YT(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 $T(){}function ZT(e){return e.setHeader&&typeof e.abort=="function"}function Qm(e,t,r){if(typeof t=="function")return Qm(e,null,t);t||(t={}),r=YT(r||$T);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)},f=e._readableState&&e._readableState.endEmitted,l=function(){n=!1,f=!0,i||r.call(e)},y=function(T){r.call(e,T)},g=function(){var T;if(n&&!f)return(!e._readableState||!e._readableState.ended)&&(T=new Jm),r.call(e,T);if(i&&!s)return(!e._writableState||!e._writableState.ended)&&(T=new Jm),r.call(e,T)},v=function(){e.req.on("finish",a)};return ZT(e)?(e.on("complete",a),e.on("abort",g),e.req?v():e.on("request",v)):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",y),e.on("close",g),function(){e.removeListener("complete",a),e.removeListener("abort",g),e.removeListener("request",v),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",y),e.removeListener("close",g)}}ev.exports=Qm});var rv=B((x4,tv)=>{"use strict";p();var Gu;function zn(e,t,r){return t=XT(t),t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function XT(e){var t=JT(e,"string");return typeof t=="symbol"?t:String(t)}function JT(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 QT=Ku(),Yn=Symbol("lastResolve"),Mi=Symbol("lastReject"),Ts=Symbol("error"),Vu=Symbol("ended"),ki=Symbol("lastPromise"),_h=Symbol("handlePromise"),Ci=Symbol("stream");function $n(e,t){return{value:e,done:t}}function e2(e){var t=e[Yn];if(t!==null){var r=e[Ci].read();r!==null&&(e[ki]=null,e[Yn]=null,e[Mi]=null,t($n(r,!1)))}}function t2(e){x.default.nextTick(e2,e)}function r2(e,t){return function(r,n){e.then(function(){if(t[Vu]){r($n(void 0,!0));return}t[_h](r,n)},n)}}var n2=Object.getPrototypeOf(function(){}),i2=Object.setPrototypeOf((Gu={get stream(){return this[Ci]},next:function(){var t=this,r=this[Ts];if(r!==null)return Promise.reject(r);if(this[Vu])return Promise.resolve($n(void 0,!0));if(this[Ci].destroyed)return new Promise(function(s,a){x.default.nextTick(function(){t[Ts]?a(t[Ts]):s($n(void 0,!0))})});var n=this[ki],i;if(n)i=new Promise(r2(n,this));else{var o=this[Ci].read();if(o!==null)return Promise.resolve($n(o,!1));i=new Promise(this[_h])}return this[ki]=i,i}},zn(Gu,Symbol.asyncIterator,function(){return this}),zn(Gu,"return",function(){var t=this;return new Promise(function(r,n){t[Ci].destroy(null,function(i){if(i){n(i);return}r($n(void 0,!0))})})}),Gu),n2),o2=function(t){var r,n=Object.create(i2,(r={},zn(r,Ci,{value:t,writable:!0}),zn(r,Yn,{value:null,writable:!0}),zn(r,Mi,{value:null,writable:!0}),zn(r,Ts,{value:null,writable:!0}),zn(r,Vu,{value:t._readableState.endEmitted,writable:!0}),zn(r,_h,{value:function(o,s){var a=n[Ci].read();a?(n[ki]=null,n[Yn]=null,n[Mi]=null,o($n(a,!1))):(n[Yn]=o,n[Mi]=s)},writable:!0}),r));return n[ki]=null,QT(t,function(i){if(i&&i.code!=="ERR_STREAM_PREMATURE_CLOSE"){var o=n[Mi];o!==null&&(n[ki]=null,n[Yn]=null,n[Mi]=null,o(i)),n[Ts]=i;return}var s=n[Yn];s!==null&&(n[ki]=null,n[Yn]=null,n[Mi]=null,s($n(void 0,!0))),n[Vu]=!0}),t.on("readable",t2.bind(null,n)),n};tv.exports=o2});var iv=B((A4,nv)=>{p();nv.exports=function(){throw new Error("Readable.from is not available in the browser")}});var yh=B((T4,pv)=>{"use strict";p();pv.exports=Be;var To;Be.ReadableState=uv;var R4=go().EventEmitter,av=function(t,r){return t.listeners(r).length},Bs=Al(),Wu=Nt().Buffer,s2=(typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof self<"u"?self:{}).Uint8Array||function(){};function a2(e){return Wu.from(e)}function u2(e){return Wu.isBuffer(e)||e instanceof s2}var Sh=Xr(),we;Sh&&Sh.debuglog?we=Sh.debuglog("stream"):we=function(){};var f2=Bm(),Rh=ah(),c2=uh(),l2=c2.getHighWaterMark,zu=Bi().codes,h2=zu.ERR_INVALID_ARG_TYPE,d2=zu.ERR_STREAM_PUSH_AFTER_EOF,p2=zu.ERR_METHOD_NOT_IMPLEMENTED,g2=zu.ERR_STREAM_UNSHIFT_AFTER_END_EVENT,Po,wh,Eh;Fe()(Be,Bs);var Ps=Rh.errorOrDestroy,xh=["error","close","destroy","pause","resume"];function y2(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 uv(e,t,r){To=To||Ni(),e=e||{},typeof r!="boolean"&&(r=t instanceof To),this.objectMode=!!e.objectMode,r&&(this.objectMode=this.objectMode||!!e.readableObjectMode),this.highWaterMark=l2(this,e,"readableHighWaterMark",r),this.buffer=new f2,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&&(Po||(Po=Ro().StringDecoder),this.decoder=new Po(e.encoding),this.encoding=e.encoding)}function Be(e){if(To=To||Ni(),!(this instanceof Be))return new Be(e);var t=this instanceof To;this._readableState=new uv(e,this,t),this.readable=!0,e&&(typeof e.read=="function"&&(this._read=e.read),typeof e.destroy=="function"&&(this._destroy=e.destroy)),Bs.call(this)}Object.defineProperty(Be.prototype,"destroyed",{enumerable:!1,get:function(){return this._readableState===void 0?!1:this._readableState.destroyed},set:function(t){this._readableState&&(this._readableState.destroyed=t)}});Be.prototype.destroy=Rh.destroy;Be.prototype._undestroy=Rh.undestroy;Be.prototype._destroy=function(e,t){t(e)};Be.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),fv(this,e,t,!1,n)};Be.prototype.unshift=function(e){return fv(this,e,null,!0,!1)};function fv(e,t,r,n,i){we("readableAddChunk",t);var o=e._readableState;if(t===null)o.reading=!1,b2(e,o);else{var s;if(i||(s=m2(o,t)),s)Ps(e,s);else if(o.objectMode||t&&t.length>0)if(typeof t!="string"&&!o.objectMode&&Object.getPrototypeOf(t)!==Wu.prototype&&(t=a2(t)),n)o.endEmitted?Ps(e,new g2):Ih(e,o,t,!0);else if(o.ended)Ps(e,new d2);else{if(o.destroyed)return!1;o.reading=!1,o.decoder&&!r?(t=o.decoder.write(t),o.objectMode||t.length!==0?Ih(e,o,t,!1):Oh(e,o)):Ih(e,o,t,!1)}else n||(o.reading=!1,Oh(e,o))}return!o.ended&&(o.length<o.highWaterMark||o.length===0)}function Ih(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&&Yu(e)),Oh(e,t)}function m2(e,t){var r;return!u2(t)&&typeof t!="string"&&t!==void 0&&!e.objectMode&&(r=new h2("chunk",["string","Buffer","Uint8Array"],t)),r}Be.prototype.isPaused=function(){return this._readableState.flowing===!1};Be.prototype.setEncoding=function(e){Po||(Po=Ro().StringDecoder);var t=new Po(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 ov=1073741824;function v2(e){return e>=ov?e=ov:(e--,e|=e>>>1,e|=e>>>2,e|=e>>>4,e|=e>>>8,e|=e>>>16,e++),e}function sv(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=v2(e)),e<=t.length?e:t.ended?t.length:(t.needReadable=!0,0))}Be.prototype.read=function(e){we("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 we("read: emitReadable",t.length,t.ended),t.length===0&&t.ended?Ah(this):Yu(this),null;if(e=sv(e,t),e===0&&t.ended)return t.length===0&&Ah(this),null;var n=t.needReadable;we("need readable",n),(t.length===0||t.length-e<t.highWaterMark)&&(n=!0,we("length less than watermark",n)),t.ended||t.reading?(n=!1,we("reading or ended",n)):n&&(we("do read"),t.reading=!0,t.sync=!0,t.length===0&&(t.needReadable=!0),this._read(t.highWaterMark),t.sync=!1,t.reading||(e=sv(r,t)));var i;return e>0?i=hv(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&&Ah(this)),i!==null&&this.emit("data",i),i};function b2(e,t){if(we("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?Yu(e):(t.needReadable=!1,t.emittedReadable||(t.emittedReadable=!0,cv(e)))}}function Yu(e){var t=e._readableState;we("emitReadable",t.needReadable,t.emittedReadable),t.needReadable=!1,t.emittedReadable||(we("emitReadable",t.flowing),t.emittedReadable=!0,x.default.nextTick(cv,e))}function cv(e){var t=e._readableState;we("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,Th(e)}function Oh(e,t){t.readingMore||(t.readingMore=!0,x.default.nextTick(_2,e,t))}function _2(e,t){for(;!t.reading&&!t.ended&&(t.length<t.highWaterMark||t.flowing&&t.length===0);){var r=t.length;if(we("maybeReadMore read 0"),e.read(0),r===t.length)break}t.readingMore=!1}Be.prototype._read=function(e){Ps(this,new p2("_read()"))};Be.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,we("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:M;n.endEmitted?x.default.nextTick(o):r.once("end",o),e.on("unpipe",s);function s(U,F){we("onunpipe"),U===r&&F&&F.hasUnpiped===!1&&(F.hasUnpiped=!0,y())}function a(){we("onend"),e.end()}var f=S2(r);e.on("drain",f);var l=!1;function y(){we("cleanup"),e.removeListener("close",E),e.removeListener("finish",T),e.removeListener("drain",f),e.removeListener("error",v),e.removeListener("unpipe",s),r.removeListener("end",a),r.removeListener("end",M),r.removeListener("data",g),l=!0,n.awaitDrain&&(!e._writableState||e._writableState.needDrain)&&f()}r.on("data",g);function g(U){we("ondata");var F=e.write(U);we("dest.write",F),F===!1&&((n.pipesCount===1&&n.pipes===e||n.pipesCount>1&&dv(n.pipes,e)!==-1)&&!l&&(we("false write response, pause",n.awaitDrain),n.awaitDrain++),r.pause())}function v(U){we("onerror",U),M(),e.removeListener("error",v),av(e,"error")===0&&Ps(e,U)}y2(e,"error",v);function E(){e.removeListener("finish",T),M()}e.once("close",E);function T(){we("onfinish"),e.removeListener("close",E),M()}e.once("finish",T);function M(){we("unpipe"),r.unpipe(e)}return e.emit("pipe",r),n.flowing||(we("pipe resume"),r.resume()),e};function S2(e){return function(){var r=e._readableState;we("pipeOnDrain",r.awaitDrain),r.awaitDrain&&r.awaitDrain--,r.awaitDrain===0&&av(e,"data")&&(r.flowing=!0,Th(e))}}Be.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=dv(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)};Be.prototype.on=function(e,t){var r=Bs.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,we("on readable",n.length,n.reading),n.length?Yu(this):n.reading||x.default.nextTick(w2,this)),r};Be.prototype.addListener=Be.prototype.on;Be.prototype.removeListener=function(e,t){var r=Bs.prototype.removeListener.call(this,e,t);return e==="readable"&&x.default.nextTick(lv,this),r};Be.prototype.removeAllListeners=function(e){var t=Bs.prototype.removeAllListeners.apply(this,arguments);return(e==="readable"||e===void 0)&&x.default.nextTick(lv,this),t};function lv(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 w2(e){we("readable nexttick read 0"),e.read(0)}Be.prototype.resume=function(){var e=this._readableState;return e.flowing||(we("resume"),e.flowing=!e.readableListening,E2(this,e)),e.paused=!1,this};function E2(e,t){t.resumeScheduled||(t.resumeScheduled=!0,x.default.nextTick(x2,e,t))}function x2(e,t){we("resume",t.reading),t.reading||e.read(0),t.resumeScheduled=!1,e.emit("resume"),Th(e),t.flowing&&!t.reading&&e.read(0)}Be.prototype.pause=function(){return we("call pause flowing=%j",this._readableState.flowing),this._readableState.flowing!==!1&&(we("pause"),this._readableState.flowing=!1,this.emit("pause")),this._readableState.paused=!0,this};function Th(e){var t=e._readableState;for(we("flow",t.flowing);t.flowing&&e.read()!==null;);}Be.prototype.wrap=function(e){var t=this,r=this._readableState,n=!1;e.on("end",function(){if(we("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(we("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<xh.length;o++)e.on(xh[o],this.emit.bind(this,xh[o]));return this._read=function(s){we("wrapped _read",s),n&&(n=!1,e.resume())},this};typeof Symbol=="function"&&(Be.prototype[Symbol.asyncIterator]=function(){return wh===void 0&&(wh=rv()),wh(this)});Object.defineProperty(Be.prototype,"readableHighWaterMark",{enumerable:!1,get:function(){return this._readableState.highWaterMark}});Object.defineProperty(Be.prototype,"readableBuffer",{enumerable:!1,get:function(){return this._readableState&&this._readableState.buffer}});Object.defineProperty(Be.prototype,"readableFlowing",{enumerable:!1,get:function(){return this._readableState.flowing},set:function(t){this._readableState&&(this._readableState.flowing=t)}});Be._fromList=hv;Object.defineProperty(Be.prototype,"readableLength",{enumerable:!1,get:function(){return this._readableState.length}});function hv(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 Ah(e){var t=e._readableState;we("endReadable",t.endEmitted),t.endEmitted||(t.ended=!0,x.default.nextTick(I2,t,e))}function I2(e,t){if(we("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"&&(Be.from=function(e,t){return Eh===void 0&&(Eh=iv()),Eh(Be,e,t)});function dv(e,t){for(var r=0,n=e.length;r<n;r++)if(e[r]===t)return r;return-1}});var Ph=B((B4,yv)=>{"use strict";p();yv.exports=vn;var $u=Bi().codes,A2=$u.ERR_METHOD_NOT_IMPLEMENTED,O2=$u.ERR_MULTIPLE_CALLBACK,R2=$u.ERR_TRANSFORM_ALREADY_TRANSFORMING,T2=$u.ERR_TRANSFORM_WITH_LENGTH_0,Zu=Ni();Fe()(vn,Zu);function P2(e,t){var r=this._transformState;r.transforming=!1;var n=r.writecb;if(n===null)return this.emit("error",new O2);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 vn(e){if(!(this instanceof vn))return new vn(e);Zu.call(this,e),this._transformState={afterTransform:P2.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",B2)}function B2(){var e=this;typeof this._flush=="function"&&!this._readableState.destroyed?this._flush(function(t,r){gv(e,t,r)}):gv(this,null,null)}vn.prototype.push=function(e,t){return this._transformState.needTransform=!1,Zu.prototype.push.call(this,e,t)};vn.prototype._transform=function(e,t,r){r(new A2("_transform()"))};vn.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)}};vn.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};vn.prototype._destroy=function(e,t){Zu.prototype._destroy.call(this,e,function(r){t(r)})};function gv(e,t,r){if(t)return e.emit("error",t);if(r!=null&&e.push(r),e._writableState.length)throw new T2;if(e._transformState.transforming)throw new R2;return e.push(null)}});var bv=B((M4,vv)=>{"use strict";p();vv.exports=Ns;var mv=Ph();Fe()(Ns,mv);function Ns(e){if(!(this instanceof Ns))return new Ns(e);mv.call(this,e)}Ns.prototype._transform=function(e,t,r){r(null,e)}});var xv=B((C4,Ev)=>{"use strict";p();var Bh;function N2(e){var t=!1;return function(){t||(t=!0,e.apply(void 0,arguments))}}var wv=Bi().codes,M2=wv.ERR_MISSING_ARGS,k2=wv.ERR_STREAM_DESTROYED;function _v(e){if(e)throw e}function C2(e){return e.setHeader&&typeof e.abort=="function"}function L2(e,t,r,n){n=N2(n);var i=!1;e.on("close",function(){i=!0}),Bh===void 0&&(Bh=Ku()),Bh(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,C2(e))return e.abort();if(typeof e.destroy=="function")return e.destroy();n(s||new k2("pipe"))}}}function Sv(e){e()}function D2(e,t){return e.pipe(t)}function U2(e){return!e.length||typeof e[e.length-1]!="function"?_v:e.pop()}function F2(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];var n=U2(t);if(Array.isArray(t[0])&&(t=t[0]),t.length<2)throw new M2("streams");var i,o=t.map(function(s,a){var f=a<t.length-1,l=a>0;return L2(s,f,l,function(y){i||(i=y),y&&o.forEach(Sv),!f&&(o.forEach(Sv),n(i))})});return t.reduce(D2)}Ev.exports=F2});var Mh=B((D4,Iv)=>{p();Iv.exports=Sr;var Nh=go().EventEmitter,q2=Fe();q2(Sr,Nh);Sr.Readable=yh();Sr.Writable=dh();Sr.Duplex=Ni();Sr.Transform=Ph();Sr.PassThrough=bv();Sr.finished=Ku();Sr.pipeline=xv();Sr.Stream=Sr;function Sr(){Nh.call(this)}Sr.prototype.pipe=function(e,t){var r=this;function n(y){e.writable&&e.write(y)===!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 f(y){if(l(),Nh.listenerCount(this,"error")===0)throw y}r.on("error",f),e.on("error",f);function l(){r.removeListener("data",n),e.removeListener("drain",i),r.removeListener("end",s),r.removeListener("close",a),r.removeListener("error",f),e.removeListener("error",f),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 Rv=B((F4,Ov)=>{"use strict";p();var Qr=Gt().Buffer,Av=Mh().Transform,H2=Fe();function Zn(e){Av.call(this),this._block=Qr.allocUnsafe(e),this._blockSize=e,this._blockOffset=0,this._length=[0,0,0,0],this._finalized=!1}H2(Zn,Av);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 j2=typeof Uint8Array<"u",K2=typeof ArrayBuffer<"u"&&typeof Uint8Array<"u"&&ArrayBuffer.isView&&(Qr.prototype instanceof Uint8Array||Qr.TYPED_ARRAY_SUPPORT);function G2(e,t){if(e instanceof Qr)return e;if(typeof e=="string")return Qr.from(e,t);if(K2&&ArrayBuffer.isView(e)){if(e.byteLength===0)return Qr.alloc(0);var r=Qr.from(e.buffer,e.byteOffset,e.byteLength);if(r.byteLength===e.byteLength)return r}if(j2&&e instanceof Uint8Array||Qr.isBuffer(e)&&e.constructor&&typeof e.constructor.isBuffer=="function"&&e.constructor.isBuffer(e))return Qr.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=G2(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")};Ov.exports=Zn});var kh=B((H4,Pv)=>{"use strict";p();var V2=Fe(),Tv=Rv(),W2=Gt().Buffer,z2=new Array(16);function Xu(){Tv.call(this,64),this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878}V2(Xu,Tv);Xu.prototype._update=function(){for(var e=z2,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=zt(r,n,i,o,e[0],3614090360,7),o=zt(o,r,n,i,e[1],3905402710,12),i=zt(i,o,r,n,e[2],606105819,17),n=zt(n,i,o,r,e[3],3250441966,22),r=zt(r,n,i,o,e[4],4118548399,7),o=zt(o,r,n,i,e[5],1200080426,12),i=zt(i,o,r,n,e[6],2821735955,17),n=zt(n,i,o,r,e[7],4249261313,22),r=zt(r,n,i,o,e[8],1770035416,7),o=zt(o,r,n,i,e[9],2336552879,12),i=zt(i,o,r,n,e[10],4294925233,17),n=zt(n,i,o,r,e[11],2304563134,22),r=zt(r,n,i,o,e[12],1804603682,7),o=zt(o,r,n,i,e[13],4254626195,12),i=zt(i,o,r,n,e[14],2792965006,17),n=zt(n,i,o,r,e[15],1236535329,22),r=Yt(r,n,i,o,e[1],4129170786,5),o=Yt(o,r,n,i,e[6],3225465664,9),i=Yt(i,o,r,n,e[11],643717713,14),n=Yt(n,i,o,r,e[0],3921069994,20),r=Yt(r,n,i,o,e[5],3593408605,5),o=Yt(o,r,n,i,e[10],38016083,9),i=Yt(i,o,r,n,e[15],3634488961,14),n=Yt(n,i,o,r,e[4],3889429448,20),r=Yt(r,n,i,o,e[9],568446438,5),o=Yt(o,r,n,i,e[14],3275163606,9),i=Yt(i,o,r,n,e[3],4107603335,14),n=Yt(n,i,o,r,e[8],1163531501,20),r=Yt(r,n,i,o,e[13],2850285829,5),o=Yt(o,r,n,i,e[2],4243563512,9),i=Yt(i,o,r,n,e[7],1735328473,14),n=Yt(n,i,o,r,e[12],2368359562,20),r=$t(r,n,i,o,e[5],4294588738,4),o=$t(o,r,n,i,e[8],2272392833,11),i=$t(i,o,r,n,e[11],1839030562,16),n=$t(n,i,o,r,e[14],4259657740,23),r=$t(r,n,i,o,e[1],2763975236,4),o=$t(o,r,n,i,e[4],1272893353,11),i=$t(i,o,r,n,e[7],4139469664,16),n=$t(n,i,o,r,e[10],3200236656,23),r=$t(r,n,i,o,e[13],681279174,4),o=$t(o,r,n,i,e[0],3936430074,11),i=$t(i,o,r,n,e[3],3572445317,16),n=$t(n,i,o,r,e[6],76029189,23),r=$t(r,n,i,o,e[9],3654602809,4),o=$t(o,r,n,i,e[12],3873151461,11),i=$t(i,o,r,n,e[15],530742520,16),n=$t(n,i,o,r,e[2],3299628645,23),r=Zt(r,n,i,o,e[0],4096336452,6),o=Zt(o,r,n,i,e[7],1126891415,10),i=Zt(i,o,r,n,e[14],2878612391,15),n=Zt(n,i,o,r,e[5],4237533241,21),r=Zt(r,n,i,o,e[12],1700485571,6),o=Zt(o,r,n,i,e[3],2399980690,10),i=Zt(i,o,r,n,e[10],4293915773,15),n=Zt(n,i,o,r,e[1],2240044497,21),r=Zt(r,n,i,o,e[8],1873313359,6),o=Zt(o,r,n,i,e[15],4264355552,10),i=Zt(i,o,r,n,e[6],2734768916,15),n=Zt(n,i,o,r,e[13],1309151649,21),r=Zt(r,n,i,o,e[4],4149444226,6),o=Zt(o,r,n,i,e[11],3174756917,10),i=Zt(i,o,r,n,e[2],718787259,15),n=Zt(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};Xu.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=W2.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 Ju(e,t){return e<<t|e>>>32-t}function zt(e,t,r,n,i,o,s){return Ju(e+(t&r|~t&n)+i+o|0,s)+t|0}function Yt(e,t,r,n,i,o,s){return Ju(e+(t&n|r&~n)+i+o|0,s)+t|0}function $t(e,t,r,n,i,o,s){return Ju(e+(t^r^n)+i+o|0,s)+t|0}function Zt(e,t,r,n,i,o,s){return Ju(e+(r^(t|~n))+i+o|0,s)+t|0}Pv.exports=Xu});var Nv=B((K4,Bv)=>{p();var Y2={}.toString;Bv.exports=Array.isArray||function(e){return Y2.call(e)=="[object Array]"}});var kv=B((V4,Mv)=>{"use strict";p();var $2=Ai(),Z2=Gn(),X2=Z2("TypedArray.prototype.buffer",!0),J2=Xl();Mv.exports=X2||function(t){if(!J2(t))throw new $2("Not a Typed Array");return t.buffer}});var Qu=B((z4,Lv)=>{"use strict";p();var Pr=Gt().Buffer,Q2=Nv(),eP=kv(),tP=ArrayBuffer.isView||function(t){try{return eP(t),!0}catch{return!1}},rP=typeof Uint8Array<"u",Cv=typeof ArrayBuffer<"u"&&typeof Uint8Array<"u",nP=Cv&&(Pr.prototype instanceof Uint8Array||Pr.TYPED_ARRAY_SUPPORT);Lv.exports=function(t,r){if(Pr.isBuffer(t))return t.constructor&&!("isBuffer"in t)?Pr.from(t):t;if(typeof t=="string")return Pr.from(t,r);if(Cv&&tP(t)){if(t.byteLength===0)return Pr.alloc(0);if(nP){var n=Pr.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=Pr.from(i);if(o.length===t.byteLength)return o}if(rP&&t instanceof Uint8Array)return Pr.from(t);var s=Q2(t);if(s)for(var a=0;a<t.length;a+=1){var f=t[a];if(typeof f!="number"||f<0||f>255||~~f!==f)throw new RangeError("Array items must be numbers in the range 0-255.")}if(s||Pr.isBuffer(t)&&t.constructor&&typeof t.constructor.isBuffer=="function"&&t.constructor.isBuffer(t))return Pr.from(t);throw new TypeError('The "data" argument must be a string, an Array, a Buffer, a Uint8Array, or a DataView.')}});var qv=B(($4,Fv)=>{"use strict";p();var iP=Gt().Buffer,oP=Qu(),Uv=typeof Uint8Array<"u",sP=Uv&&typeof ArrayBuffer<"u",Dv=sP&&ArrayBuffer.isView;Fv.exports=function(e,t){if(typeof e=="string"||iP.isBuffer(e)||Uv&&e instanceof Uint8Array||Dv&&Dv(e))return oP(e,t);throw new TypeError('The "data" argument must be a string, a Buffer, a Uint8Array, or a DataView')}});var Ms=B((X4,Ch)=>{"use strict";p();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?Ch.exports={nextTick:aP}:Ch.exports=x.default;function aP(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 jv=B((Q4,Hv)=>{p();var uP={}.toString;Hv.exports=Array.isArray||function(e){return uP.call(e)=="[object Array]"}});var Lh=B((tD,Kv)=>{p();Kv.exports=go().EventEmitter});var tf=B((Dh,Vv)=>{p();var ef=Nt(),bn=ef.Buffer;function Gv(e,t){for(var r in e)t[r]=e[r]}bn.from&&bn.alloc&&bn.allocUnsafe&&bn.allocUnsafeSlow?Vv.exports=ef:(Gv(ef,Dh),Dh.Buffer=Bo);function Bo(e,t,r){return bn(e,t,r)}Gv(bn,Bo);Bo.from=function(e,t,r){if(typeof e=="number")throw new TypeError("Argument must not be a number");return bn(e,t,r)};Bo.alloc=function(e,t,r){if(typeof e!="number")throw new TypeError("Argument must be a number");var n=bn(e);return t!==void 0?typeof r=="string"?n.fill(t,r):n.fill(t):n.fill(0),n};Bo.allocUnsafe=function(e){if(typeof e!="number")throw new TypeError("Argument must be a number");return bn(e)};Bo.allocUnsafeSlow=function(e){if(typeof e!="number")throw new TypeError("Argument must be a number");return ef.SlowBuffer(e)}});var No=B(Xt=>{p();function fP(e){return Array.isArray?Array.isArray(e):rf(e)==="[object Array]"}Xt.isArray=fP;function cP(e){return typeof e=="boolean"}Xt.isBoolean=cP;function lP(e){return e===null}Xt.isNull=lP;function hP(e){return e==null}Xt.isNullOrUndefined=hP;function dP(e){return typeof e=="number"}Xt.isNumber=dP;function pP(e){return typeof e=="string"}Xt.isString=pP;function gP(e){return typeof e=="symbol"}Xt.isSymbol=gP;function yP(e){return e===void 0}Xt.isUndefined=yP;function mP(e){return rf(e)==="[object RegExp]"}Xt.isRegExp=mP;function vP(e){return typeof e=="object"&&e!==null}Xt.isObject=vP;function bP(e){return rf(e)==="[object Date]"}Xt.isDate=bP;function _P(e){return rf(e)==="[object Error]"||e instanceof Error}Xt.isError=_P;function SP(e){return typeof e=="function"}Xt.isFunction=SP;function wP(e){return e===null||typeof e=="boolean"||typeof e=="number"||typeof e=="string"||typeof e=="symbol"||typeof e>"u"}Xt.isPrimitive=wP;Xt.isBuffer=Nt().Buffer.isBuffer;function rf(e){return Object.prototype.toString.call(e)}});var zv=B((sD,Uh)=>{"use strict";p();function EP(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}var Wv=tf().Buffer,ks=Xr();function xP(e,t,r){e.copy(t,r)}Uh.exports=(function(){function e(){EP(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 Wv.alloc(0);for(var n=Wv.allocUnsafe(r>>>0),i=this.head,o=0;i;)xP(i.data,n,o),o+=i.data.length,i=i.next;return n},e})();ks&&ks.inspect&&ks.inspect.custom&&(Uh.exports.prototype[ks.inspect.custom]=function(){var e=ks.inspect({length:this.length});return this.constructor.name+" "+e})});var Fh=B((uD,Yv)=>{"use strict";p();var nf=Ms();function IP(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,nf.nextTick(of,this,e)):nf.nextTick(of,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,nf.nextTick(of,r,o)):nf.nextTick(of,r,o):t&&t(o)}),this)}function AP(){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 of(e,t){e.emit("error",t)}Yv.exports={destroy:IP,undestroy:AP}});var Hh=B((cD,rb)=>{"use strict";p();var Li=Ms();rb.exports=Ot;function Zv(e){var t=this;this.next=null,this.entry=null,this.finish=function(){GP(t,e)}}var OP=!x.default.browser&&["v0.10","v0.9."].indexOf(x.default.version.slice(0,5))>-1?setImmediate:Li.nextTick,Mo;Ot.WritableState=Ls;var Xv=Object.create(No());Xv.inherits=Fe();var RP={deprecate:ch()},Jv=Lh(),af=tf().Buffer,TP=(typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof self<"u"?self:{}).Uint8Array||function(){};function PP(e){return af.from(e)}function BP(e){return af.isBuffer(e)||e instanceof TP}var Qv=Fh();Xv.inherits(Ot,Jv);function NP(){}function Ls(e,t){Mo=Mo||Di(),e=e||{};var r=t instanceof Mo;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){FP(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 Zv(this)}Ls.prototype.getBuffer=function(){for(var t=this.bufferedRequest,r=[];t;)r.push(t),t=t.next;return r};(function(){try{Object.defineProperty(Ls.prototype,"buffer",{get:RP.deprecate(function(){return this.getBuffer()},"_writableState.buffer is deprecated. Use _writableState.getBuffer instead.","DEP0003")})}catch{}})();var sf;typeof Symbol=="function"&&Symbol.hasInstance&&typeof Function.prototype[Symbol.hasInstance]=="function"?(sf=Function.prototype[Symbol.hasInstance],Object.defineProperty(Ot,Symbol.hasInstance,{value:function(e){return sf.call(this,e)?!0:this!==Ot?!1:e&&e._writableState instanceof Ls}})):sf=function(e){return e instanceof this};function Ot(e){if(Mo=Mo||Di(),!sf.call(Ot,this)&&!(this instanceof Mo))return new Ot(e);this._writableState=new Ls(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)),Jv.call(this)}Ot.prototype.pipe=function(){this.emit("error",new Error("Cannot pipe, not readable"))};function MP(e,t){var r=new Error("write after end");e.emit("error",r),Li.nextTick(t,r)}function kP(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),Li.nextTick(n,o),i=!1),i}Ot.prototype.write=function(e,t,r){var n=this._writableState,i=!1,o=!n.objectMode&&BP(e);return o&&!af.isBuffer(e)&&(e=PP(e)),typeof t=="function"&&(r=t,t=null),o?t="buffer":t||(t=n.defaultEncoding),typeof r!="function"&&(r=NP),n.ended?MP(this,r):(o||kP(this,n,e,r))&&(n.pendingcb++,i=LP(this,n,o,e,t,r)),i};Ot.prototype.cork=function(){var e=this._writableState;e.corked++};Ot.prototype.uncork=function(){var e=this._writableState;e.corked&&(e.corked--,!e.writing&&!e.corked&&!e.bufferProcessing&&e.bufferedRequest&&eb(this,e))};Ot.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 CP(e,t,r){return!e.objectMode&&e.decodeStrings!==!1&&typeof t=="string"&&(t=af.from(t,r)),t}Object.defineProperty(Ot.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}});function LP(e,t,r,n,i,o){if(!r){var s=CP(t,n,i);n!==s&&(r=!0,i="buffer",n=s)}var a=t.objectMode?1:n.length;t.length+=a;var f=t.length<t.highWaterMark;if(f||(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 qh(e,t,!1,a,n,i,o);return f}function qh(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 DP(e,t,r,n,i){--t.pendingcb,r?(Li.nextTick(i,n),Li.nextTick(Cs,e,t),e._writableState.errorEmitted=!0,e.emit("error",n)):(i(n),e._writableState.errorEmitted=!0,e.emit("error",n),Cs(e,t))}function UP(e){e.writing=!1,e.writecb=null,e.length-=e.writelen,e.writelen=0}function FP(e,t){var r=e._writableState,n=r.sync,i=r.writecb;if(UP(r),t)DP(e,r,n,t,i);else{var o=tb(r);!o&&!r.corked&&!r.bufferProcessing&&r.bufferedRequest&&eb(e,r),n?OP($v,e,r,o,i):$v(e,r,o,i)}}function $v(e,t,r,n){r||qP(e,t),t.pendingcb--,n(),Cs(e,t)}function qP(e,t){t.length===0&&t.needDrain&&(t.needDrain=!1,e.emit("drain"))}function eb(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,qh(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 Zv(t),t.bufferedRequestCount=0}else{for(;r;){var f=r.chunk,l=r.encoding,y=r.callback,g=t.objectMode?1:f.length;if(qh(e,t,!1,g,f,l,y),r=r.next,t.bufferedRequestCount--,t.writing)break}r===null&&(t.lastBufferedRequest=null)}t.bufferedRequest=r,t.bufferProcessing=!1}Ot.prototype._write=function(e,t,r){r(new Error("_write() is not implemented"))};Ot.prototype._writev=null;Ot.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||KP(this,n,r)};function tb(e){return e.ending&&e.length===0&&e.bufferedRequest===null&&!e.finished&&!e.writing}function HP(e,t){e._final(function(r){t.pendingcb--,r&&e.emit("error",r),t.prefinished=!0,e.emit("prefinish"),Cs(e,t)})}function jP(e,t){!t.prefinished&&!t.finalCalled&&(typeof e._final=="function"?(t.pendingcb++,t.finalCalled=!0,Li.nextTick(HP,e,t)):(t.prefinished=!0,e.emit("prefinish")))}function Cs(e,t){var r=tb(t);return r&&(jP(e,t),t.pendingcb===0&&(t.finished=!0,e.emit("finish"))),r}function KP(e,t,r){t.ending=!0,Cs(e,t),r&&(t.finished?Li.nextTick(r):e.once("finish",r)),t.ended=!0,e.writable=!1}function GP(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(Ot.prototype,"destroyed",{get:function(){return this._writableState===void 0?!1:this._writableState.destroyed},set:function(e){this._writableState&&(this._writableState.destroyed=e)}});Ot.prototype.destroy=Qv.destroy;Ot.prototype._undestroy=Qv.undestroy;Ot.prototype._destroy=function(e,t){this.end(),t(e)}});var Di=B((hD,sb)=>{"use strict";p();var nb=Ms(),VP=Object.keys||function(e){var t=[];for(var r in e)t.push(r);return t};sb.exports=_n;var ib=Object.create(No());ib.inherits=Fe();var ob=Gh(),Kh=Hh();ib.inherits(_n,ob);for(jh=VP(Kh.prototype),uf=0;uf<jh.length;uf++)ff=jh[uf],_n.prototype[ff]||(_n.prototype[ff]=Kh.prototype[ff]);var jh,ff,uf;function _n(e){if(!(this instanceof _n))return new _n(e);ob.call(this,e),Kh.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",WP)}Object.defineProperty(_n.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}});function WP(){this.allowHalfOpen||this._writableState.ended||nb.nextTick(zP,this)}function zP(e){e.end()}Object.defineProperty(_n.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)}});_n.prototype._destroy=function(e,t){this.push(null),this.end(),nb.nextTick(t,e)}});var Gh=B((gD,vb)=>{"use strict";p();var Co=Ms();vb.exports=$e;var YP=jv(),Ds;$e.ReadableState=db;var pD=go().EventEmitter,cb=function(e,t){return e.listeners(t).length},$h=Lh(),Us=tf().Buffer,$P=(typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof self<"u"?self:{}).Uint8Array||function(){};function ZP(e){return Us.from(e)}function XP(e){return Us.isBuffer(e)||e instanceof $P}var lb=Object.create(No());lb.inherits=Fe();var Vh=Xr(),ke=void 0;Vh&&Vh.debuglog?ke=Vh.debuglog("stream"):ke=function(){};var JP=zv(),hb=Fh(),ko;lb.inherits($e,$h);var Wh=["error","close","destroy","pause","resume"];function QP(e,t,r){if(typeof e.prependListener=="function")return e.prependListener(t,r);!e._events||!e._events[t]?e.on(t,r):YP(e._events[t])?e._events[t].unshift(r):e._events[t]=[r,e._events[t]]}function db(e,t){Ds=Ds||Di(),e=e||{};var r=t instanceof Ds;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 JP,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&&(ko||(ko=Ro().StringDecoder),this.decoder=new ko(e.encoding),this.encoding=e.encoding)}function $e(e){if(Ds=Ds||Di(),!(this instanceof $e))return new $e(e);this._readableState=new db(e,this),this.readable=!0,e&&(typeof e.read=="function"&&(this._read=e.read),typeof e.destroy=="function"&&(this._destroy=e.destroy)),$h.call(this)}Object.defineProperty($e.prototype,"destroyed",{get:function(){return this._readableState===void 0?!1:this._readableState.destroyed},set:function(e){this._readableState&&(this._readableState.destroyed=e)}});$e.prototype.destroy=hb.destroy;$e.prototype._undestroy=hb.undestroy;$e.prototype._destroy=function(e,t){this.push(null),t(e)};$e.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=Us.from(e,t),t=""),n=!0),pb(this,e,t,!1,n)};$e.prototype.unshift=function(e){return pb(this,e,null,!0,!1)};function pb(e,t,r,n,i){var o=e._readableState;if(t===null)o.reading=!1,nB(e,o);else{var s;i||(s=eB(o,t)),s?e.emit("error",s):o.objectMode||t&&t.length>0?(typeof t!="string"&&!o.objectMode&&Object.getPrototypeOf(t)!==Us.prototype&&(t=ZP(t)),n?o.endEmitted?e.emit("error",new Error("stream.unshift() after end event")):zh(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?zh(e,o,t,!1):gb(e,o)):zh(e,o,t,!1))):n||(o.reading=!1)}return tB(o)}function zh(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&&cf(e)),gb(e,t)}function eB(e,t){var r;return!XP(t)&&typeof t!="string"&&t!==void 0&&!e.objectMode&&(r=new TypeError("Invalid non-string/buffer chunk")),r}function tB(e){return!e.ended&&(e.needReadable||e.length<e.highWaterMark||e.length===0)}$e.prototype.isPaused=function(){return this._readableState.flowing===!1};$e.prototype.setEncoding=function(e){return ko||(ko=Ro().StringDecoder),this._readableState.decoder=new ko(e),this._readableState.encoding=e,this};var ab=8388608;function rB(e){return e>=ab?e=ab:(e--,e|=e>>>1,e|=e>>>2,e|=e>>>4,e|=e>>>8,e|=e>>>16,e++),e}function ub(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=rB(e)),e<=t.length?e:t.ended?t.length:(t.needReadable=!0,0))}$e.prototype.read=function(e){ke("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 ke("read: emitReadable",t.length,t.ended),t.length===0&&t.ended?Yh(this):cf(this),null;if(e=ub(e,t),e===0&&t.ended)return t.length===0&&Yh(this),null;var n=t.needReadable;ke("need readable",n),(t.length===0||t.length-e<t.highWaterMark)&&(n=!0,ke("length less than watermark",n)),t.ended||t.reading?(n=!1,ke("reading or ended",n)):n&&(ke("do read"),t.reading=!0,t.sync=!0,t.length===0&&(t.needReadable=!0),this._read(t.highWaterMark),t.sync=!1,t.reading||(e=ub(r,t)));var i;return e>0?i=yb(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&&Yh(this)),i!==null&&this.emit("data",i),i};function nB(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,cf(e)}}function cf(e){var t=e._readableState;t.needReadable=!1,t.emittedReadable||(ke("emitReadable",t.flowing),t.emittedReadable=!0,t.sync?Co.nextTick(fb,e):fb(e))}function fb(e){ke("emit readable"),e.emit("readable"),Zh(e)}function gb(e,t){t.readingMore||(t.readingMore=!0,Co.nextTick(iB,e,t))}function iB(e,t){for(var r=t.length;!t.reading&&!t.flowing&&!t.ended&&t.length<t.highWaterMark&&(ke("maybeReadMore read 0"),e.read(0),r!==t.length);)r=t.length;t.readingMore=!1}$e.prototype._read=function(e){this.emit("error",new Error("_read() is not implemented"))};$e.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,ke("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:U;n.endEmitted?Co.nextTick(o):r.once("end",o),e.on("unpipe",s);function s(F,V){ke("onunpipe"),F===r&&V&&V.hasUnpiped===!1&&(V.hasUnpiped=!0,y())}function a(){ke("onend"),e.end()}var f=oB(r);e.on("drain",f);var l=!1;function y(){ke("cleanup"),e.removeListener("close",T),e.removeListener("finish",M),e.removeListener("drain",f),e.removeListener("error",E),e.removeListener("unpipe",s),r.removeListener("end",a),r.removeListener("end",U),r.removeListener("data",v),l=!0,n.awaitDrain&&(!e._writableState||e._writableState.needDrain)&&f()}var g=!1;r.on("data",v);function v(F){ke("ondata"),g=!1;var V=e.write(F);V===!1&&!g&&((n.pipesCount===1&&n.pipes===e||n.pipesCount>1&&mb(n.pipes,e)!==-1)&&!l&&(ke("false write response, pause",n.awaitDrain),n.awaitDrain++,g=!0),r.pause())}function E(F){ke("onerror",F),U(),e.removeListener("error",E),cb(e,"error")===0&&e.emit("error",F)}QP(e,"error",E);function T(){e.removeListener("finish",M),U()}e.once("close",T);function M(){ke("onfinish"),e.removeListener("close",T),U()}e.once("finish",M);function U(){ke("unpipe"),r.unpipe(e)}return e.emit("pipe",r),n.flowing||(ke("pipe resume"),r.resume()),e};function oB(e){return function(){var t=e._readableState;ke("pipeOnDrain",t.awaitDrain),t.awaitDrain&&t.awaitDrain--,t.awaitDrain===0&&cb(e,"data")&&(t.flowing=!0,Zh(e))}}$e.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=mb(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)};$e.prototype.on=function(e,t){var r=$h.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&&cf(this):Co.nextTick(sB,this))}return r};$e.prototype.addListener=$e.prototype.on;function sB(e){ke("readable nexttick read 0"),e.read(0)}$e.prototype.resume=function(){var e=this._readableState;return e.flowing||(ke("resume"),e.flowing=!0,aB(this,e)),this};function aB(e,t){t.resumeScheduled||(t.resumeScheduled=!0,Co.nextTick(uB,e,t))}function uB(e,t){t.reading||(ke("resume read 0"),e.read(0)),t.resumeScheduled=!1,t.awaitDrain=0,e.emit("resume"),Zh(e),t.flowing&&!t.reading&&e.read(0)}$e.prototype.pause=function(){return ke("call pause flowing=%j",this._readableState.flowing),this._readableState.flowing!==!1&&(ke("pause"),this._readableState.flowing=!1,this.emit("pause")),this};function Zh(e){var t=e._readableState;for(ke("flow",t.flowing);t.flowing&&e.read()!==null;);}$e.prototype.wrap=function(e){var t=this,r=this._readableState,n=!1;e.on("end",function(){if(ke("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(ke("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<Wh.length;o++)e.on(Wh[o],this.emit.bind(this,Wh[o]));return this._read=function(s){ke("wrapped _read",s),n&&(n=!1,e.resume())},this};Object.defineProperty($e.prototype,"readableHighWaterMark",{enumerable:!1,get:function(){return this._readableState.highWaterMark}});$e._fromList=yb;function yb(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=fB(e,t.buffer,t.decoder),r}function fB(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?cB(e,t):lB(e,t),n}function cB(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 lB(e,t){var r=Us.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 Yh(e){var t=e._readableState;if(t.length>0)throw new Error('"endReadable()" called on non-empty stream');t.endEmitted||(t.ended=!0,Co.nextTick(hB,t,e))}function hB(e,t){!e.endEmitted&&e.length===0&&(e.endEmitted=!0,t.readable=!1,t.emit("end"))}function mb(e,t){for(var r=0,n=e.length;r<n;r++)if(e[r]===t)return r;return-1}});var Xh=B((mD,Sb)=>{"use strict";p();Sb.exports=Sn;var lf=Di(),_b=Object.create(No());_b.inherits=Fe();_b.inherits(Sn,lf);function dB(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);lf.call(this,e),this._transformState={afterTransform:dB.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",pB)}function pB(){var e=this;typeof this._flush=="function"?this._flush(function(t,r){bb(e,t,r)}):bb(this,null,null)}Sn.prototype.push=function(e,t){return this._transformState.needTransform=!1,lf.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;lf.prototype._destroy.call(this,e,function(n){t(n),r.emit("close")})};function bb(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 Ib=B((bD,xb)=>{"use strict";p();xb.exports=Fs;var wb=Xh(),Eb=Object.create(No());Eb.inherits=Fe();Eb.inherits(Fs,wb);function Fs(e){if(!(this instanceof Fs))return new Fs(e);wb.call(this,e)}Fs.prototype._transform=function(e,t,r){r(null,e)}});var Ob=B((en,Ab)=>{p();en=Ab.exports=Gh();en.Stream=en;en.Readable=en;en.Writable=Hh();en.Duplex=Di();en.Transform=Xh();en.PassThrough=Ib()});var Pb=B((wD,Tb)=>{"use strict";p();var gB=Gt().Buffer,yB=qv(),Rb=Ob().Transform,mB=Fe();function Xn(e){Rb.call(this),this._block=gB.allocUnsafe(e),this._blockSize=e,this._blockOffset=0,this._length=[0,0,0,0],this._finalized=!1}mB(Xn,Rb);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=yB(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")};Tb.exports=Xn});var Qh=B((xD,Db)=>{"use strict";p();var Jh=Nt().Buffer,vB=Fe(),Lb=Pb(),bB=new Array(16),qs=[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],Hs=[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],js=[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],Ks=[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],Vs=[1352829926,1548603684,1836072691,2053994217,0];function Ui(e,t){return e<<t|e>>>32-t}function Bb(e,t,r,n,i,o,s,a){return Ui(e+(t^r^n)+o+s|0,a)+i|0}function Nb(e,t,r,n,i,o,s,a){return Ui(e+(t&r|~t&n)+o+s|0,a)+i|0}function Mb(e,t,r,n,i,o,s,a){return Ui(e+((t|~r)^n)+o+s|0,a)+i|0}function kb(e,t,r,n,i,o,s,a){return Ui(e+(t&n|r&~n)+o+s|0,a)+i|0}function Cb(e,t,r,n,i,o,s,a){return Ui(e+(t^(r|~n))+o+s|0,a)+i|0}function hf(){Lb.call(this,64),this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878,this._e=3285377520}vB(hf,Lb);hf.prototype._update=function(){for(var e=bB,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,f=this._b|0,l=this._c|0,y=this._d|0,g=this._e|0,v=0;v<80;v+=1){var E,T;v<16?(E=Bb(r,n,i,o,s,e[qs[v]],Gs[0],js[v]),T=Cb(a,f,l,y,g,e[Hs[v]],Vs[0],Ks[v])):v<32?(E=Nb(r,n,i,o,s,e[qs[v]],Gs[1],js[v]),T=kb(a,f,l,y,g,e[Hs[v]],Vs[1],Ks[v])):v<48?(E=Mb(r,n,i,o,s,e[qs[v]],Gs[2],js[v]),T=Mb(a,f,l,y,g,e[Hs[v]],Vs[2],Ks[v])):v<64?(E=kb(r,n,i,o,s,e[qs[v]],Gs[3],js[v]),T=Nb(a,f,l,y,g,e[Hs[v]],Vs[3],Ks[v])):(E=Cb(r,n,i,o,s,e[qs[v]],Gs[4],js[v]),T=Bb(a,f,l,y,g,e[Hs[v]],Vs[4],Ks[v])),r=s,s=o,o=Ui(i,10),i=n,n=E,a=g,g=y,y=Ui(l,10),l=f,f=T}var M=this._b+i+y|0;this._b=this._c+o+g|0,this._c=this._d+s+a|0,this._d=this._e+r+f|0,this._e=this._a+n+l|0,this._a=M};hf.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=Jh.alloc?Jh.alloc(20):new Jh(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};Db.exports=hf});var Fi=B((AD,Ub)=>{"use strict";p();var _B=Gt().Buffer,SB=Qu();function df(e,t){this._block=_B.alloc(e),this._finalSize=t,this._blockSize=e,this._len=0}df.prototype.update=function(e,t){e=SB(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,f=Math.min(i-s,n-a),l=0;l<f;l++)r[a+l]=e[s+l];o+=f,s+=f,o%n===0&&this._update(r)}return this._len+=i,this};df.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};df.prototype._update=function(){throw new Error("_update must be implemented by subclass")};Ub.exports=df});var Hb=B((RD,qb)=>{"use strict";p();var wB=Fe(),Fb=Fi(),EB=Gt().Buffer,xB=[1518500249,1859775393,-1894007588,-899497514],IB=new Array(80);function Ws(){this.init(),this._w=IB,Fb.call(this,64,56)}wB(Ws,Fb);Ws.prototype.init=function(){return this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878,this._e=3285377520,this};function AB(e){return e<<5|e>>>27}function OB(e){return e<<30|e>>>2}function RB(e,t,r,n){return e===0?t&r|~t&n:e===2?t&r|t&n|r&n:t^r^n}Ws.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 f=0;f<80;++f){var l=~~(f/20),y=AB(r)+RB(l,n,i,o)+s+t[f]+xB[l]|0;s=o,o=i,i=OB(n),n=r,r=y}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};Ws.prototype._hash=function(){var e=EB.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};qb.exports=Ws});var Gb=B((PD,Kb)=>{"use strict";p();var TB=Fe(),jb=Fi(),PB=Gt().Buffer,BB=[1518500249,1859775393,-1894007588,-899497514],NB=new Array(80);function zs(){this.init(),this._w=NB,jb.call(this,64,56)}TB(zs,jb);zs.prototype.init=function(){return this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878,this._e=3285377520,this};function MB(e){return e<<1|e>>>31}function kB(e){return e<<5|e>>>27}function CB(e){return e<<30|e>>>2}function LB(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]=MB(t[a-3]^t[a-8]^t[a-14]^t[a-16]);for(var f=0;f<80;++f){var l=~~(f/20),y=kB(r)+LB(l,n,i,o)+s+t[f]+BB[l]|0;s=o,o=i,i=CB(n),n=r,r=y}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=PB.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=zs});var ed=B((ND,Wb)=>{"use strict";p();var DB=Fe(),Vb=Fi(),UB=Gt().Buffer,FB=[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],qB=new Array(64);function Ys(){this.init(),this._w=qB,Vb.call(this,64,56)}DB(Ys,Vb);Ys.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 HB(e,t,r){return r^e&(t^r)}function jB(e,t,r){return e&t|r&(e|t)}function KB(e){return(e>>>2|e<<30)^(e>>>13|e<<19)^(e>>>22|e<<10)}function GB(e){return(e>>>6|e<<26)^(e>>>11|e<<21)^(e>>>25|e<<7)}function VB(e){return(e>>>7|e<<25)^(e>>>18|e<<14)^e>>>3}function WB(e){return(e>>>17|e<<15)^(e>>>19|e<<13)^e>>>10}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=this._f|0,f=this._g|0,l=this._h|0,y=0;y<16;++y)t[y]=e.readInt32BE(y*4);for(;y<64;++y)t[y]=WB(t[y-2])+t[y-7]+VB(t[y-15])+t[y-16]|0;for(var g=0;g<64;++g){var v=l+GB(s)+HB(s,a,f)+FB[g]+t[g]|0,E=KB(r)+jB(r,n,i)|0;l=f,f=a,a=s,s=o+v|0,o=i,i=n,n=r,r=v+E|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=f+this._g|0,this._h=l+this._h|0};Ys.prototype._hash=function(){var e=UB.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};Wb.exports=Ys});var Yb=B((kD,zb)=>{"use strict";p();var zB=Fe(),YB=ed(),$B=Fi(),ZB=Gt().Buffer,XB=new Array(64);function pf(){this.init(),this._w=XB,$B.call(this,64,56)}zB(pf,YB);pf.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};pf.prototype._hash=function(){var e=ZB.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};zb.exports=pf});var td=B((LD,t_)=>{"use strict";p();var JB=Fe(),e_=Fi(),QB=Gt().Buffer,$b=[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],eN=new Array(160);function $s(){this.init(),this._w=eN,e_.call(this,128,112)}JB($s,e_);$s.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 Zb(e,t,r){return r^e&(t^r)}function Xb(e,t,r){return e&t|r&(e|t)}function Jb(e,t){return(e>>>28|t<<4)^(t>>>2|e<<30)^(t>>>7|e<<25)}function Qb(e,t){return(e>>>14|t<<18)^(e>>>18|t<<14)^(t>>>9|e<<23)}function tN(e,t){return(e>>>1|t<<31)^(e>>>8|t<<24)^e>>>7}function rN(e,t){return(e>>>1|t<<31)^(e>>>8|t<<24)^(e>>>7|t<<25)}function nN(e,t){return(e>>>19|t<<13)^(t>>>29|e<<3)^e>>>6}function iN(e,t){return(e>>>19|t<<13)^(t>>>29|e<<3)^(e>>>6|t<<26)}function qt(e,t){return e>>>0<t>>>0?1:0}$s.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,f=this._gh|0,l=this._hh|0,y=this._al|0,g=this._bl|0,v=this._cl|0,E=this._dl|0,T=this._el|0,M=this._fl|0,U=this._gl|0,F=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],G=t[V-30+1],ie=tN(z,G),ee=rN(G,z);z=t[V-4],G=t[V-4+1];var pe=nN(z,G),le=iN(G,z),me=t[V-14],I=t[V-14+1],u=t[V-32],h=t[V-32+1],m=ee+I|0,S=ie+me+qt(m,ee)|0;m=m+le|0,S=S+pe+qt(m,le)|0,m=m+h|0,S=S+u+qt(m,h)|0,t[V]=S,t[V+1]=m}for(var w=0;w<160;w+=2){S=t[w],m=t[w+1];var R=Xb(r,n,i),A=Xb(y,g,v),_=Jb(r,y),c=Jb(y,r),b=Qb(s,T),k=Qb(T,s),L=$b[w],H=$b[w+1],W=Zb(s,a,f),te=Zb(T,M,U),X=F+k|0,ue=l+b+qt(X,F)|0;X=X+te|0,ue=ue+W+qt(X,te)|0,X=X+H|0,ue=ue+L+qt(X,H)|0,X=X+m|0,ue=ue+S+qt(X,m)|0;var fe=c+A|0,O=_+R+qt(fe,c)|0;l=f,F=U,f=a,U=M,a=s,M=T,T=E+X|0,s=o+ue+qt(T,E)|0,o=i,E=v,i=n,v=g,n=r,g=y,y=X+fe|0,r=ue+O+qt(y,X)|0}this._al=this._al+y|0,this._bl=this._bl+g|0,this._cl=this._cl+v|0,this._dl=this._dl+E|0,this._el=this._el+T|0,this._fl=this._fl+M|0,this._gl=this._gl+U|0,this._hl=this._hl+F|0,this._ah=this._ah+r+qt(this._al,y)|0,this._bh=this._bh+n+qt(this._bl,g)|0,this._ch=this._ch+i+qt(this._cl,v)|0,this._dh=this._dh+o+qt(this._dl,E)|0,this._eh=this._eh+s+qt(this._el,T)|0,this._fh=this._fh+a+qt(this._fl,M)|0,this._gh=this._gh+f+qt(this._gl,U)|0,this._hh=this._hh+l+qt(this._hl,F)|0};$s.prototype._hash=function(){var e=QB.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};t_.exports=$s});var n_=B((UD,r_)=>{"use strict";p();var oN=Fe(),sN=td(),aN=Fi(),uN=Gt().Buffer,fN=new Array(160);function gf(){this.init(),this._w=fN,aN.call(this,128,112)}oN(gf,sN);gf.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};gf.prototype._hash=function(){var e=uN.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};r_.exports=gf});var rd=B((qD,wn)=>{"use strict";p();wn.exports=function(t){var r=t.toLowerCase(),n=wn.exports[r];if(!n)throw new Error(r+" is not supported (we accept pull requests)");return new n};wn.exports.sha=Hb();wn.exports.sha1=Gb();wn.exports.sha224=Yb();wn.exports.sha256=ed();wn.exports.sha384=n_();wn.exports.sha512=td()});var yf=B((jD,o_)=>{"use strict";p();var cN=Gt().Buffer,i_=Mh().Transform,lN=Ro().StringDecoder,hN=Fe(),dN=Qu();function Br(e){i_.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}hN(Br,i_);Br.prototype.update=function(e,t,r){var n=dN(e,t),i=this._update(n);return this.hashMode?this:(r&&(i=this._toString(i,r)),i)};Br.prototype.setAutoPadding=function(){};Br.prototype.getAuthTag=function(){throw new Error("trying to get auth tag in unsupported state")};Br.prototype.setAuthTag=function(){throw new Error("trying to set auth tag in unsupported state")};Br.prototype.setAAD=function(){throw new Error("trying to set aad in unsupported state")};Br.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)}};Br.prototype._flush=function(e){var t;try{this.push(this.__final())}catch(r){t=r}e(t)};Br.prototype._finalOrDigest=function(e){var t=this.__final()||cN.alloc(0);return e&&(t=this._toString(t,e,!0)),t};Br.prototype._toString=function(e,t,r){if(this._decoder||(this._decoder=new lN(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};o_.exports=Br});var u_=B((GD,a_)=>{"use strict";p();var pN=Fe(),gN=kh(),yN=Qh(),mN=rd(),s_=yf();function mf(e){s_.call(this,"digest"),this._hash=e}pN(mf,s_);mf.prototype._update=function(e){this._hash.update(e)};mf.prototype._final=function(){return this._hash.digest()};a_.exports=function(t){return t=t.toLowerCase(),t==="md5"?new gN:t==="rmd160"||t==="ripemd160"?new yN:new mf(mN(t))}});var l_=B((WD,c_)=>{"use strict";p();var vN=Fe(),qi=Gt().Buffer,f_=yf(),bN=qi.alloc(128),Lo=64;function vf(e,t){f_.call(this,"digest"),typeof t=="string"&&(t=qi.from(t)),this._alg=e,this._key=t,t.length>Lo?t=e(t):t.length<Lo&&(t=qi.concat([t,bN],Lo));for(var r=this._ipad=qi.allocUnsafe(Lo),n=this._opad=qi.allocUnsafe(Lo),i=0;i<Lo;i++)r[i]=t[i]^54,n[i]=t[i]^92;this._hash=[r]}vN(vf,f_);vf.prototype._update=function(e){this._hash.push(e)};vf.prototype._final=function(){var e=this._alg(qi.concat(this._hash));return this._alg(qi.concat([this._opad,e]))};c_.exports=vf});var d_=B((YD,h_)=>{p();var _N=kh();h_.exports=function(e){return new _N().update(e).digest()}});var y_=B((ZD,g_)=>{"use strict";p();var SN=Fe(),wN=l_(),p_=yf(),Zs=Gt().Buffer,EN=d_(),nd=Qh(),id=rd(),xN=Zs.alloc(128);function Xs(e,t){p_.call(this,"digest"),typeof t=="string"&&(t=Zs.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 nd:id(e);t=n.update(t).digest()}else t.length<r&&(t=Zs.concat([t,xN],r));for(var i=this._ipad=Zs.allocUnsafe(r),o=this._opad=Zs.allocUnsafe(r),s=0;s<r;s++)i[s]=t[s]^54,o[s]=t[s]^92;this._hash=e==="rmd160"?new nd:id(e),this._hash.update(i)}SN(Xs,p_);Xs.prototype._update=function(e){this._hash.update(e)};Xs.prototype._final=function(){var e=this._hash.digest(),t=this._alg==="rmd160"?new nd:id(this._alg);return t.update(this._opad).update(e).digest()};g_.exports=function(t,r){return t=t.toLowerCase(),t==="rmd160"||t==="ripemd160"?new Xs("rmd160",r):t==="md5"?new wN(EN,r):new Xs(t,r)}});var m_=B((JD,sd)=>{"use strict";p();var od=65536,IN=4294967295;function AN(){throw new Error(`Secure random number generation is not supported by this browser.
|
|
11
11
|
Use Chrome, Firefox or Internet Explorer 11`)}var ON=Gt().Buffer,bf=globalThis.crypto||globalThis.msCrypto;bf&&bf.getRandomValues?sd.exports=RN:sd.exports=AN;function RN(e,t){if(e>IN)throw new RangeError("requested too many random bytes");var r=ON.allocUnsafe(e);if(e>0)if(e>od)for(var n=0;n<e;n+=od)bf.getRandomValues(r.slice(n,n+od));else bf.getRandomValues(r);return typeof t=="function"?x.default.nextTick(function(){t(null,r)}):r}});var Js=B(_f=>{"use strict";p();_f.createHash=u_();_f.createHmac=y_();_f.randomBytes=m_()});var Qs=B((rU,b_)=>{"use strict";p();var v_=65536;function Hi(){}Hi.getRandomBuffer=function(e){var t=typeof globalThis<"u"?globalThis.crypto:void 0;if(t&&typeof t.getRandomValues=="function")return Hi._fromGetRandomValues(t,e);try{var r=Js();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)")};Hi._fromGetRandomValues=function(e,t){for(var r=d.Buffer.alloc(t),n=0;n<t;n+=v_){var i=new Uint8Array(Math.min(v_,t-n));e.getRandomValues(i),d.Buffer.from(i).copy(r,n)}return r};Hi.getRandomBufferNode=function(e){var t=Js();return t.randomBytes(e)};Hi.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 Hi._fromGetRandomValues(r,e)};b_.exports=Hi});var ze=B((iU,__)=>{"use strict";p();var TN=Qs(),We={};We.isArray=e=>Array.isArray(e);We.isNumber=e=>typeof e=="number";We.isObject=e=>e&&typeof e=="object";We.isString=e=>typeof e=="string";We.isUndefined=e=>typeof e>"u";We.isFunction=e=>typeof e=="function";We.isNull=e=>e===null;We.isDate=e=>e instanceof Date;We.extend=(e,t)=>Object.assign(e,t);We.noop=()=>{};We.every=(e,t)=>e.every(t||(r=>r));We.map=(e,t)=>Array.from(e).map(t||(r=>r));We.includes=(e,t)=>e.includes(t);We.each=(e,t)=>e.forEach(t);We.clone=e=>Object.assign({},e);We.pick=(e,t)=>{let r={};return t.forEach(n=>{typeof e[n]<"u"&&(r[n]=e[n])}),r};We.values=e=>Object.values(e);We.filter=(e,t)=>e.filter(t);We.reduce=(e,t,r)=>e.reduce(t,r);We.without=(e,t)=>e.filter(r=>r!==t);We.shuffle=e=>{let t=e.slice(0);for(let r=t.length-1;r>0;r--){let i=TN.getRandomBuffer(4).readUInt32BE(0)/4294967296,o=Math.floor(i*(r+1));[t[r],t[o]]=[t[o],t[r]]}return t};We.difference=(e,t)=>e.filter(r=>!t.includes(r));We.findIndex=(e,t)=>e.findIndex(t);We.some=(e,t)=>e.some(t);We.range=e=>[...Array(e).keys()];__.exports=We});var w_=B((sU,S_)=>{"use strict";p();var PN="https://docs.moneybutton.com/";S_.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: "+PN+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=B((uU,ud)=>{"use strict";p();var ad=ze();function BN(e,t){return e.replace("{0}",t[0]).replace("{1}",t[1]).replace("{2}",t[2])}var E_=function(e,t){var r=function(){if(ad.isString(t.message))this.message=BN(t.message,arguments);else if(ad.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
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&&x_(r,t.errors),r},x_=function(e,t){ad.each(t,function(r){E_(e,r)})},NN=function(e,t){return x_(e,t),e},Do={};Do.Error=function(){this.message="Internal error",this.stack=this.message+`
|
|
13
13
|
`+new Error().stack};Do.Error.prototype=Object.create(Error.prototype);Do.Error.prototype.name="bsv.Error";var MN=w_();NN(Do.Error,MN);ud.exports=Do.Error;ud.exports.extend=function(e){return E_(Do.Error,e)}});var Le=B((cU,I_)=>{"use strict";p();var ea=Jn(),kN=ze();I_.exports={checkState:function(e,t){if(!e)throw new ea.InvalidState(t)},checkArgument:function(e,t,r,n){if(!e)throw new ea.InvalidArgument(t,r,n)},checkArgumentType:function(e,t,r){if(r=r||"(unknown name)",kN.isString(t)){if(t==="Buffer"){var n=Nt();if(!n.Buffer.isBuffer(e))throw new ea.InvalidArgumentType(e,t,r)}else if(typeof e!==t)throw new ea.InvalidArgumentType(e,t,r)}else if(!(e instanceof t))throw new ea.InvalidArgumentType(e,t.name,r)}}});var wr=B((hU,T_)=>{"use strict";p();var Me=L0(),O_=Le(),R_=ze(),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};Me.Zero=new Me(0);Me.One=new Me(1);Me.Minus1=new Me(-1);Me.fromNumber=function(e){return O_.checkArgument(R_.isNumber(e)),new Me(e)};Me.fromString=function(e,t){return O_.checkArgument(R_.isString(e)),new Me(e,t)};Me.fromBuffer=function(e,t){typeof t<"u"&&t.endian==="little"&&(e=Sf(e));var r=e.toString("hex"),n=new Me(r,16);return n};Me.fromSM=function(e,t){var r;if(e.length===0)return Me.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=Me.fromBuffer(e),r.neg().copy(r)):r=Me.fromBuffer(e),r};Me.prototype.toNumber=function(){return parseInt(this.toString(10),10)};Me.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=Me.trim(t,n):n<e.size&&(t=Me.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};Me.prototype.toSMBigEndian=function(){var e;return this.cmp(Me.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};Me.prototype.toSM=function(e){var t=e?e.endian:"big",r=this.toSMBigEndian();return t==="little"&&(r=Sf(r)),r};function A_(e,t){var r=new Error(e);return r.scriptErr=t,r}Me.fromScriptNumBuffer=function(e,t,r){var n=r||4;if(e.length>n)throw A_("script number overflow","SCRIPT_ERR_SCRIPTNUM_OVERFLOW");if(t&&e.length>0&&(e[e.length-1]&127)===0&&(e.length<=1||(e[e.length-2]&128)===0))throw A_("non-minimally encoded script number","SCRIPT_ERR_SCRIPTNUM_MINENCODE");return Me.fromSM(e,{endian:"little"})};Me.prototype.toScriptNumBuffer=function(){return this.toSM({endian:"little"})};Me.trim=function(e,t){return e.slice(t-e.length,e.length)};Me.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};Me.prototype.toHex=function(...e){return this.toBuffer(...e).toString("hex")};Me.fromHex=function(e,...t){return Me.fromBuffer(d.Buffer.from(e,"hex"),...t)};T_.exports=Me});function CN(e,t=!1){return t?{h:Number(e&wf),l:Number(e>>P_&wf)}:{h:Number(e>>P_&wf)|0,l:Number(e&wf)|0}}function B_(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}=CN(e[o],t);[n[o],i[o]]=[s,a]}return[n,i]}function N_(e,t,r,n){let i=LN(r),o=DN(r);e.setUint32(t,n?o:i,n),e.setUint32(t+4,n?i:o,n)}function tn(e,t,r,n){let i=(t>>>0)+(n>>>0);return{h:e+r+(i/2**32|0)|0,l:i|0}}var wf,P_,LN,DN,fd,cd,ji,Ki,ta,ra,M_,k_,C_,L_,D_,U_,ld=Wt(()=>{p();wf=BigInt(4294967295),P_=BigInt(32);LN=e=>e/2**32|0,DN=e=>e>>>0;fd=(e,t,r)=>e>>>r,cd=(e,t,r)=>e<<32-r|t>>>r,ji=(e,t,r)=>e>>>r|t<<32-r,Ki=(e,t,r)=>e<<32-r|t>>>r,ta=(e,t,r)=>e<<64-r|t>>>r-32,ra=(e,t,r)=>e>>>r-32|t<<64-r;M_=(e,t,r)=>(e>>>0)+(t>>>0)+(r>>>0),k_=(e,t,r,n)=>t+r+n+(e/2**32|0)|0,C_=(e,t,r,n)=>(e>>>0)+(t>>>0)+(r>>>0)+(n>>>0),L_=(e,t,r,n,i)=>t+r+n+i+(e/2**32|0)|0,D_=(e,t,r,n,i)=>(e>>>0)+(t>>>0)+(r>>>0)+(n>>>0)+(i>>>0),U_=(e,t,r,n,i,o)=>t+r+n+i+o+(e/2**32|0)|0});function Ef(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name==="Uint8Array"&&"BYTES_PER_ELEMENT"in e&&e.BYTES_PER_ELEMENT===1}function En(e,t=""){if(typeof e!="number")throw new TypeError(hd(t)+"expected number, got "+typeof e);if(!Number.isSafeInteger(e)||e<0)throw new RangeError(hd(t)+"expected integer >= 0, got "+e);return e}function rn(e,t,r=""){if(Ef(e)&&(t===void 0||e.length===t))return e;t!==void 0&&En(t,"length");let n=Ef(e),i=t!==void 0?` of length ${t}`:"",o=n?`length=${e.length}`:`type=${typeof e}`,s=hd(r)+"expected Uint8Array"+i+", got "+o;throw n?new RangeError(s):new TypeError(s)}function xf(e){if(typeof e!="function"||typeof e.create!="function")throw new TypeError("expected hash wrapped by utils.createHasher");if(En(e.outputLen),En(e.blockLen),e.outputLen<1||e.blockLen<1)throw new Error("hash blockLen / outputLen must be >= 1")}function Uo(e,t=!0){if(e.destroyed)throw new Error("hash was destroyed");if(t&&e.finished)throw new Error("digest() was already called")}function If(e,t){rn(e,void 0,"output");let r=t.outputLen;if(!(e.length>=r))throw new RangeError('"output" expected length >= '+r)}function ar(...e){for(let t=0;t<e.length;t++)e[t].fill(0)}function Af(e){return new DataView(e.buffer,e.byteOffset,e.byteLength)}function Nr(e,t){return e<<32-t|e>>>t}function xn(e,t){return e<<t|e>>>32-t>>>0}function Of(e){if(rn(e),H_)return e.toHex();let t="";for(let r=0;r<e.length;r++)t+=FN[e[r]];return t}function q_(e){return e>=48&&e<=57?e-48:e>=65&&e<=70?e-55:e>=97&&e<=102?e-87:void 0}function dd(e){if(typeof e!="string")throw new TypeError("hex string expected, got "+typeof e);if(H_)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=q_(e.charCodeAt(o)),a=q_(e.charCodeAt(o+1));if(s===void 0||a===void 0){let f=e[o]+e[o+1];throw new RangeError('hex string expected, got non-hex character "'+f+'" at index '+o)}n[i]=s*16+a}return n}function In(e){if(typeof e!="string")throw new TypeError("string expected");return new Uint8Array(new TextEncoder().encode(e))}function j_(...e){let t=0;for(let n=0;n<e.length;n++){let i=e[n];rn(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 qN(e,t,r="opts"){return F_(e,"defaults"),t!==void 0&&F_(t,r),Object.assign(e,t)}function Mr(e,t={}){if(typeof e!="function")throw new TypeError('"hashCons" expected function, got type='+typeof e);t=qN({},t,"info");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 na(e=32){En(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 hd,F_,H_,FN,Gi,An=Wt(()=>{p();hd=e=>e?`"${e}" `:"";F_=(e,t)=>{if(e===null||typeof e!="object"||Array.isArray(e))throw new TypeError((t==="object"?"":`"${t}" `)+"expected object, got type="+typeof e)};H_=typeof Uint8Array.from([]).toHex=="function"&&typeof Uint8Array.fromHex=="function",FN=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,"0"));Gi=e=>({oid:Uint8Array.from([6,9,96,134,72,1,101,3,4,2,e])})});function Fo(e,t,r){return e&t^~e&r}function Rf(e,t,r){return e&t^e&r^t&r}var On,K_,G_,V_,W_,pd=Wt(()=>{p();ld();An();On=class{constructor(t,r,n,i){Z(this,"blockLen");Z(this,"outputLen");Z(this,"canXOF",!1);Z(this,"padOffset");Z(this,"isLE");Z(this,"buffer");Z(this,"view");Z(this,"finished",!1);Z(this,"length",0);Z(this,"pos",0);Z(this,"destroyed",!1);this.blockLen=t,this.outputLen=r,this.padOffset=n,this.isLE=i,this.buffer=new Uint8Array(t),this.view=Af(this.buffer)}update(t){Uo(this),rn(t);let{view:r,buffer:n,blockLen:i}=this,o=t.length,s=!1;for(let a=0;a<o;){let f=Math.min(i-this.pos,o-a);if(f===i){let l=Af(t);for(;i<=o-a;a+=i)this.process(l,a);s=!0;continue}n.set(a===0&&f===o?t:t.subarray(a,a+f),this.pos),this.pos+=f,a+=f,this.pos===i&&(this.process(r,0),this.pos=0,s=!0)}return this.length+=t.length,s&&this.roundClean(),this}digestInto(t){Uo(this),If(t,this),this.finished=!0;let{buffer:r,view:n,blockLen:i,isLE:o}=this,{pos:s}=this;r[s++]=128,r.fill(0,s),this.padOffset>i-s&&(this.process(n,0),r.fill(0)),N_(n,i-8,this.length*8,o),this.process(n,0),this.roundClean();let a=t===r?n:Af(t),f=this.outputLen,l=f/4,y=this.get();if(f%4||l>y.length)throw new Error("invalid outputLen");for(let g=0;g<l;g++)a.setUint32(4*g,y[g],o)}digest(){let{buffer:t,outputLen:r}=this;this.digestInto(t);let n=t.slice(0,r);return this.destroy(),n}_cloneIntoMeta(t){let{buffer:r,length:n,finished:i,destroyed:o,pos:s}=this;return t.destroyed=o,t.finished=i,t.length=n,t.pos=s,s&&t.buffer.set(r),t}clone(){return this._cloneInto()}},K_=Uint32Array.from([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),G_=Uint32Array.from([3238371032,914150663,812702999,4144912697,4290775857,1750603025,1694076839,3204075428]),V_=Uint32Array.from([3418070365,3238371032,1654270250,914150663,2438529370,812702999,355462360,4144912697,1731405415,4290775857,2394180231,1750603025,3675008525,1694076839,1203062813,3204075428]),W_=Uint32Array.from([1779033703,4089235720,3144134277,2227873595,1013904242,4271175723,2773480762,1595750129,1359893119,2917565137,2600822924,725511199,528734635,4215389547,1541459225,327033209])});var Y_={};ul(Y_,{_SHA224:()=>Bf,_SHA256:()=>Pf,_SHA384:()=>Mf,_SHA512:()=>Nf,_SHA512_224:()=>kf,_SHA512_256:()=>Cf,sha224:()=>WN,sha256:()=>ri,sha384:()=>YN,sha512:()=>zN,sha512_224:()=>ZN,sha512_256:()=>$N});var HN,Qn,Tf,Pf,Bf,z_,jN,KN,ei,ti,qo,Nf,Mf,GN,VN,kf,Cf,ri,WN,zN,YN,$N,ZN,gd=Wt(()=>{p();pd();ld();An();HN=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]),Qn=new Uint32Array(64),Tf=class extends On{constructor(r,n){super(64,r,8,!1);Z(this,"A",0);Z(this,"B",0);Z(this,"C",0);Z(this,"D",0);Z(this,"E",0);Z(this,"F",0);Z(this,"G",0);Z(this,"H",0);this.A=n[0]|0,this.B=n[1]|0,this.C=n[2]|0,this.D=n[3]|0,this.E=n[4]|0,this.F=n[5]|0,this.G=n[6]|0,this.H=n[7]|0}get(){let{A:r,B:n,C:i,D:o,E:s,F:a,G:f,H:l}=this;return[r,n,i,o,s,a,f,l]}set(r,n,i,o,s,a,f,l){this.A=r|0,this.B=n|0,this.C=i|0,this.D=o|0,this.E=s|0,this.F=a|0,this.G=f|0,this.H=l|0}_cloneInto(r){return(r||(r=new this.constructor)).set(...this.get()),this._cloneIntoMeta(r)}process(r,n){for(let v=0;v<16;v++,n+=4)Qn[v]=r.getUint32(n,!1);for(let v=16;v<64;v++){let E=Qn[v-15],T=Qn[v-2],M=Nr(E,7)^Nr(E,18)^E>>>3,U=Nr(T,17)^Nr(T,19)^T>>>10;Qn[v]=U+Qn[v-7]+M+Qn[v-16]|0}let{A:i,B:o,C:s,D:a,E:f,F:l,G:y,H:g}=this;for(let v=0;v<64;v++){let E=Nr(f,6)^Nr(f,11)^Nr(f,25),T=g+E+Fo(f,l,y)+HN[v]+Qn[v]|0,U=(Nr(i,2)^Nr(i,13)^Nr(i,22))+Rf(i,o,s)|0;g=y,y=l,l=f,f=a+T|0,a=s,s=o,o=i,i=T+U|0}i=i+this.A|0,o=o+this.B|0,s=s+this.C|0,a=a+this.D|0,f=f+this.E|0,l=l+this.F|0,y=y+this.G|0,g=g+this.H|0,this.set(i,o,s,a,f,l,y,g)}roundClean(){ar(Qn)}destroy(){this.destroyed=!0,this.set(0,0,0,0,0,0,0,0),ar(this.buffer)}},Pf=class extends Tf{constructor(){super(32,K_)}},Bf=class extends Tf{constructor(){super(28,G_)}},z_=B_(["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))),jN=z_[0],KN=z_[1],ei=new Uint32Array(80),ti=new Uint32Array(80),qo=class extends On{constructor(r,n){super(128,r,16,!1);Z(this,"Ah",0);Z(this,"Al",0);Z(this,"Bh",0);Z(this,"Bl",0);Z(this,"Ch",0);Z(this,"Cl",0);Z(this,"Dh",0);Z(this,"Dl",0);Z(this,"Eh",0);Z(this,"El",0);Z(this,"Fh",0);Z(this,"Fl",0);Z(this,"Gh",0);Z(this,"Gl",0);Z(this,"Hh",0);Z(this,"Hl",0);this.Ah=n[0]|0,this.Al=n[1]|0,this.Bh=n[2]|0,this.Bl=n[3]|0,this.Ch=n[4]|0,this.Cl=n[5]|0,this.Dh=n[6]|0,this.Dl=n[7]|0,this.Eh=n[8]|0,this.El=n[9]|0,this.Fh=n[10]|0,this.Fl=n[11]|0,this.Gh=n[12]|0,this.Gl=n[13]|0,this.Hh=n[14]|0,this.Hl=n[15]|0}get(){let{Ah:r,Al:n,Bh:i,Bl:o,Ch:s,Cl:a,Dh:f,Dl:l,Eh:y,El:g,Fh:v,Fl:E,Gh:T,Gl:M,Hh:U,Hl:F}=this;return[r,n,i,o,s,a,f,l,y,g,v,E,T,M,U,F]}set(r,n,i,o,s,a,f,l,y,g,v,E,T,M,U,F){this.Ah=r|0,this.Al=n|0,this.Bh=i|0,this.Bl=o|0,this.Ch=s|0,this.Cl=a|0,this.Dh=f|0,this.Dl=l|0,this.Eh=y|0,this.El=g|0,this.Fh=v|0,this.Fl=E|0,this.Gh=T|0,this.Gl=M|0,this.Hh=U|0,this.Hl=F|0}_cloneInto(r){return(r||(r=new this.constructor)).set(...this.get()),this._cloneIntoMeta(r)}process(r,n){for(let G=0;G<16;G++,n+=4)ei[G]=r.getUint32(n),ti[G]=r.getUint32(n+=4);for(let G=16;G<80;G++){let ie=ei[G-15]|0,ee=ti[G-15]|0,pe=ji(ie,ee,1)^ji(ie,ee,8)^fd(ie,ee,7),le=Ki(ie,ee,1)^Ki(ie,ee,8)^cd(ie,ee,7),me=ei[G-2]|0,I=ti[G-2]|0,u=ji(me,I,19)^ta(me,I,61)^fd(me,I,6),h=Ki(me,I,19)^ra(me,I,61)^cd(me,I,6),m=C_(le,h,ti[G-7],ti[G-16]),S=L_(m,pe,u,ei[G-7],ei[G-16]);ei[G]=S|0,ti[G]=m|0}let{Ah:i,Al:o,Bh:s,Bl:a,Ch:f,Cl:l,Dh:y,Dl:g,Eh:v,El:E,Fh:T,Fl:M,Gh:U,Gl:F,Hh:V,Hl:z}=this;for(let G=0;G<80;G++){let ie=ji(v,E,14)^ji(v,E,18)^ta(v,E,41),ee=Ki(v,E,14)^Ki(v,E,18)^ra(v,E,41),pe=v&T^~v&U,le=E&M^~E&F,me=D_(z,ee,le,KN[G],ti[G]),I=U_(me,V,ie,pe,jN[G],ei[G]),u=me|0,h=ji(i,o,28)^ta(i,o,34)^ta(i,o,39),m=Ki(i,o,28)^ra(i,o,34)^ra(i,o,39),S=i&s^i&f^s&f,w=o&a^o&l^a&l;V=U|0,z=F|0,U=T|0,F=M|0,T=v|0,M=E|0,{h:v,l:E}=tn(y|0,g|0,I|0,u|0),y=f|0,g=l|0,f=s|0,l=a|0,s=i|0,a=o|0;let R=M_(u,m,w);i=k_(R,I,h,S),o=R|0}({h:i,l:o}=tn(this.Ah|0,this.Al|0,i|0,o|0)),{h:s,l:a}=tn(this.Bh|0,this.Bl|0,s|0,a|0),{h:f,l}=tn(this.Ch|0,this.Cl|0,f|0,l|0),{h:y,l:g}=tn(this.Dh|0,this.Dl|0,y|0,g|0),{h:v,l:E}=tn(this.Eh|0,this.El|0,v|0,E|0),{h:T,l:M}=tn(this.Fh|0,this.Fl|0,T|0,M|0),{h:U,l:F}=tn(this.Gh|0,this.Gl|0,U|0,F|0),{h:V,l:z}=tn(this.Hh|0,this.Hl|0,V|0,z|0),this.set(i,o,s,a,f,l,y,g,v,E,T,M,U,F,V,z)}roundClean(){ar(ei,ti)}destroy(){this.destroyed=!0,ar(this.buffer),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}},Nf=class extends qo{constructor(){super(64,W_)}},Mf=class extends qo{constructor(){super(48,V_)}},GN=Uint32Array.from([2352822216,424955298,1944164710,2312950998,502970286,855612546,1738396948,1479516111,258812777,2077511080,2011393907,79989058,1067287976,1780299464,286451373,2446758561]),VN=Uint32Array.from([573645204,4230739756,2673172387,3360449730,596883563,1867755857,2520282905,1497426621,2519219938,2827943907,3193839141,1401305490,721525244,746961066,246885852,2177182882]),kf=class extends qo{constructor(){super(28,GN)}},Cf=class extends qo{constructor(){super(32,VN)}},ri=Mr(()=>new Pf,Gi(1)),WN=Mr(()=>new Bf,Gi(4)),zN=Mr(()=>new Nf,Gi(3)),YN=Mr(()=>new Mf,Gi(2)),$N=Mr(()=>new Cf,Gi(6)),ZN=Mr(()=>new kf,Gi(5))});function rt(e,t,r=()=>{}){if(!Array.isArray(e))throw new TypeError(`"${t}" expected array, got type=${typeof e}`);for(let n=0;n<e.length;n++)r(e[n],`${t}[${n}]`);return e}function ia(e,t=""){if(typeof e!="string"){let r=t&&`"${t}" `;throw new TypeError(r+"expected string, got type="+typeof e)}return e}function ni(e,t="object"){if(e===null||typeof e!="object"||Array.isArray(e))throw new TypeError(t==="object"?"expected valid options object":`"${t}" expected object, got type=${typeof e}`);return e}function Vi(e,t){if(typeof e!="function")throw new TypeError(`"${t}" is invalid: expected function, got ${typeof e}`);return e}function on(e,t=""){if(typeof e!="boolean")throw new TypeError(XN(t)+"expected boolean, got type="+typeof e);return e}function Df(e){if(typeof e=="bigint"){if(!ii(e))throw new RangeError("positive bigint expected, got "+e)}else yd(e);return e}function nt(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=Df(e).toString(16);return t.length&1?"0"+t:t}function Z_(e){if(typeof e!="string")throw new TypeError("hex string expected, got "+typeof e);return e===""?Lf:BigInt("0x"+e)}function Mt(e){return Z_(Of(e))}function jo(e){return Z_(Of(Ff(rn(e)).reverse()))}function Uf(e,t){if(En(t),t===0)throw new Error("zero output length is invalid");e=Df(e);let r=t*2,n=e.toString(16);if(n.length>r)throw new RangeError("number is too large");return dd(n.padStart(r,"0"))}function md(e,t){return Uf(e,t).reverse()}function Ff(e){return Uint8Array.from(Se(e))}function Ko(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 ii(e){return typeof e=="bigint"&&Lf<=e}function vd(e,t,r){return ii(e)&&ii(t)&&ii(r)&&t<=e&&e<r}function bd(e,t,r,n){if(!vd(t,r,n))throw new RangeError("expected valid "+e+": "+r+" <= n < "+n+", got "+t)}function Go(e){if(e<Lf)throw new Error("expected non-negative bigint, got "+e);return e===Lf?0:e.toString(2).length}function X_(e,t,r){if(En(e,"hashLen"),En(t,"qByteLen"),typeof r!="function")throw new TypeError("hmacFn must be a function");let n=U=>new Uint8Array(U),i=Uint8Array.of(),o=Uint8Array.of(0),s=Uint8Array.of(1),a=1e3,f=n(e),l=n(e),y=0,g=()=>{f.fill(1),l.fill(0),y=0},v=(...U)=>r(l,Ce(f,...U)),E=(U=i)=>{l=v(o,U),f=v(),U.length!==0&&(l=v(s,U),f=v())},T=()=>{if(y++>=a)throw new Error("drbg: tried max amount of iterations");let U=0,F=[];for(;U<t;){f=v();let V=f.slice();F.push(V),U+=f.length}return Ce(...F)};return(U,F)=>{g(),E(U);let V;for(;(V=F(T()))===void 0;)E();return g(),V}}function qe(e,t={},r={},n="object"){ni(e,n),ni(t,"fields"),ni(r,"optFields");function i(s,a,f){let l=n==="object"?`param "${String(s)}"`:`"${n}.${String(s)}"`,y=e[s];if(!Object.hasOwn(e,s)&&(f?y!==void 0:a!=="function"))throw new TypeError(`${l} is invalid: expected own property`);if(f&&y===void 0)return;let g=typeof y;if(g!==a||y===null)throw new TypeError(`${l} is invalid: expected ${a}, got ${g}`)}let o=(s,a)=>Object.entries(s).forEach(([f,l])=>i(f,l,a));o(t,!1),o(r,!0)}var Se,yd,Rn,Ce,Ho,nn,Qt,Lf,$_,XN,sa,oi=Wt(()=>{p();An();Se=(e,t,r)=>rn(e,t,r),yd=En;Rn=Of,Ce=(...e)=>j_(...e),Ho=e=>dd(e),nn=Ef,Qt=e=>na(e),Lf=BigInt(0),$_=BigInt(1),XN=e=>e?`"${e}" `:"";sa=e=>(nt(e,"n"),($_<<BigInt(e))-$_)});function er(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 iS(e,t,r){if(r<=Ue)throw new Error("pow: expected modulus > 1, got "+r);if(typeof t!="bigint")throw new TypeError("invalid exponent: expected bigint, got "+typeof t);if(t<kt)throw new Error("invalid exponent, negatives unsupported");if(t===kt)return Ue;if(t===Ue)return e;let n=e%r;if(n<kt&&(n+=r),t<tM){let a=Ue;for(;t>kt;)t&Ue&&(a=a*n%r),n=n*n%r,t>>=Ue;return a}let i=[];for(;t>kt;)i.push(Number(t&eM)),t>>=Sd;let o=new Array(16);o[0]=Ue,o[1]=n;for(let a=2;a<16;a++)o[a]=o[a-1]*n%r;let s=o[i[i.length-1]];for(let a=i.length-2;a>=0;a--){s=s*s%r,s=s*s%r,s=s*s%r,s=s*s%r;let f=i[a];f!==0&&(s=s*o[f]%r)}return s}function dr(e,t,r){if(r<=Ue)throw new Error("pow2: expected modulus > 1, got "+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 J_(e,t){if(e===kt)throw new Error("invert: expected non-zero number");if(t<=Ue)throw new Error("invert: expected modulus > 1, got "+t);let r=er(e,t),n=t,i=kt,o=Ue;for(;r!==kt;){let a=n/r,f=n-r*a,l=i-o*a;n=r,r=f,i=o,o=l}if(n!==Ue)throw new Error("invert: does not exist");return er(i,t)}function oS(e,t){if(t<=Ue)throw new Error("invertCt: expected prime modulus > 1, got "+t);let r=er(e,t);if(r===kt)throw new Error("invertCt: expected non-zero number");let n=iS(r,t-si,t);if(er(r*n,t)!==Ue)throw new Error("invertCt: does not exist");return n}function wd(e,t,r){let n=e;if(!n.eql(n.sqr(t),r))throw new Error("Cannot find square root")}function Ed(e,t){if((e&Ue)===kt)throw new Error(t+": expected odd modulus, got "+e)}function sS(e,t){let r=e,n=(r.ORDER+Ue)/Sd,i=r.pow(t,n);return wd(r,i,t),i}function rM(e,t){let r=e,n=(r.ORDER-tS)/rS,i=r.mul(t,si),o=r.pow(i,n),s=r.mul(t,o),a=r.mul(r.mul(s,si),o),f=r.mul(s,r.sub(a,r.ONE));return wd(r,f,t),f}function nM(e){let t=Wo(e),r=aS(e),n=r(t,t.neg(t.ONE)),i=r(t,n),o=r(t,t.neg(n)),s=(e+JN)/nS;return((a,f)=>{let l=a,y=l.pow(f,s),g=l.mul(y,n),v=l.mul(y,i),E=l.mul(y,o),T=l.eql(l.sqr(g),f),M=l.eql(l.sqr(v),f);y=l.cmov(y,g,T),g=l.cmov(E,v,M);let U=l.eql(l.sqr(g),f),F=l.cmov(y,g,U);return wd(l,F,f),F})}function aS(e){if(e<eS)throw new Error("sqrt is not defined for small field");Ed(e,"tonelliShanks");let t=e-Ue,r=0;for(;t%si===kt;)t/=si,r++;let n=si,i=Wo(e);for(;_d(i,n)===1;)if(n++>1e3)throw new Error("Cannot find square root: probably non-prime P");if(r===1)return sS;let o=i.pow(n,t),s=(t+Ue)/si;return function(f,l){let y=f;if(y.is0(l))return l;if(_d(y,l)!==1)throw new Error("Cannot find square root");let g=r,v=y.mul(y.ONE,o),E=y.pow(l,t),T=y.pow(l,s);for(;!y.eql(E,y.ONE);){if(y.is0(E))throw new Error("Cannot find square root: probably non-prime P");let M=1,U=y.sqr(E);for(;!y.eql(U,y.ONE);)if(M++,U=y.sqr(U),M===g)throw new Error("Cannot find square root");let F=Ue<<BigInt(g-M-1),V=y.pow(v,F);g=M,v=y.sqr(V),E=y.mul(E,v),T=y.mul(T,V)}return T}}function iM(e){return Ed(e,"Fp.sqrt"),e%Sd===eS?sS:e%rS===tS?rM:e%nS===QN?nM(e):aS(e)}function Er(e){if(ni(e,"field"),typeof e.ORDER!="bigint")throw new TypeError('param "ORDER" is invalid: expected bigint, got '+typeof e.ORDER);nt(e.BYTES,"BYTES"),nt(e.BITS,"BITS");for(let t of oM)Vi(e[t],"field."+t);if(e.BYTES<1||e.BITS<1)throw new Error("invalid field: expected BYTES/BITS > 0");if(e.ORDER<=Ue)throw new Error("invalid field: expected ORDER > 1, got "+e.ORDER);return e}function Vo(e,t,r=!1){Er(e),rt(t,"nums"),on(r,"passZero");let n=e,i=new Array(t.length).fill(r?n.ZERO:void 0),o=t.reduce((a,f,l)=>n.is0(f)?a:(i[l]=a,n.mul(a,f)),n.ONE),s=n.inv(o);return t.reduceRight((a,f,l)=>n.is0(f)?a:(i[l]=n.mul(a,i[l]),n.mul(a,f)),s),i}function _d(e,t){Er(e);let r=e;Ed(r.ORDER,"FpLegendre");let n=(r.ORDER-Ue)/si,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 xd(e,t){return _d(e,t)!==-1}function sM(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=Go(e);if(t!==void 0&&t<r)throw new Error(`invalid n length: expected nBitLength (${t}) >= bitLen(n) (${r})`);let n=t!==void 0?t:r,i=Math.ceil(n/8);return{nBitLength:n,nByteLength:i}}function Wo(e,t={}){return Object.freeze(qf.prototype),new qf(e,t)}function uS(e){if(typeof e!="bigint")throw new Error("field order must be bigint");if(e<=Ue)throw new Error("field order must be greater than 1");let t=Go(e-Ue);return Math.ceil(t/8)}function zo(e){let t=uS(e);return t+Math.ceil(t/2)}function Wi(e,t,r=!1){Se(e);let n=e.length,i=uS(t),o=Math.max(zo(t),16);if(n<o||n>1024)throw new Error("expected "+o+"-1024 bytes of input, got "+n);let s=r?jo(e):Mt(e),a=er(s,t-Ue)+Ue;return r?md(a,i):Uf(a,i)}var kt,Ue,si,eS,Sd,tS,JN,rS,QN,eM,nS,tM,oM,Q_,qf,zi=Wt(()=>{p();oi();kt=BigInt(0),Ue=BigInt(1),si=BigInt(2),eS=BigInt(3),Sd=BigInt(4),tS=BigInt(5),JN=BigInt(7),rS=BigInt(8),QN=BigInt(9),eM=BigInt(15),nS=BigInt(16),tM=BigInt("0x10000000000000000");oM=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];Q_=new WeakMap,qf=class{constructor(t,r={}){Z(this,"ORDER");Z(this,"BITS");Z(this,"BYTES");Z(this,"isLE");Z(this,"ZERO",kt);Z(this,"ONE",Ue);Z(this,"_lengths");Z(this,"_mod");if(t<=Ue)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}=sM(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 er(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&Ue)===Ue}neg(t){return er(-t,this.ORDER)}eql(t,r){return t===r}sqr(t){return er(t*t,this.ORDER)}add(t,r){return er(t+r,this.ORDER)}sub(t,r){return er(t-r,this.ORDER)}mul(t,r){return er(t*r,this.ORDER)}pow(t,r){return iS(t,r,this.ORDER)}div(t,r){return er(t*J_(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 J_(t,this.ORDER)}sqrt(t){let r=Q_.get(this);return r||Q_.set(this,r=iM(this.ORDER)),r(this,t)}toBytes(t){return this.isLE?md(t,this.BYTES):Uf(t,this.BYTES)}fromBytes(t,r=!1){Se(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 f=o?jo(t):Mt(t);if(a&&(f=er(f,s)),!r&&!this.isValid(f))throw new Error("invalid field element: outside of range 0..ORDER");return f}invertBatch(t){return Vo(this,t,!0)}cmov(t,r,n){return on(n,"condition"),n?r:t}}});function ai(e){let t=e;if(typeof t!="function")throw new TypeError('"Point" expected constructor, got type='+typeof e);Vi(t.fromAffine,"Point.fromAffine"),Vi(t.fromBytes,"Point.fromBytes"),Vi(t.fromHex,"Point.fromHex"),ni(t.BASE,"Point.BASE"),ni(t.ZERO,"Point.ZERO"),Er(t.Fp),Er(t.Fn)}function hS(e,t){ai(e),dS(t,e);let r=Vo(e.Fp,t.map(n=>n.Z));return t.map((n,i)=>e.fromAffine(n.toAffine(r[i])))}function fM(e,t,r=1){if(!Number.isSafeInteger(e)||e<r||e>t)throw new Error("invalid window size, expected ["+r+".."+t+"], got W="+e)}function cM(e,t){let r=e*(4*t+128);if(r>cS)throw new Error("invalid window size: table would need ~"+Math.ceil(r/2**20)+" MiB, max "+cS/2**20+" MiB")}function Rd(e,t){if(e!==void 0){Vi(e,"randomBytes");try{let r=e(t);if(!nn(r)||r.length!==t)return}catch{return}return e}}function dS(e,t){rt(e,"points"),e.forEach((r,n)=>{if(!(r instanceof t))throw new Error("invalid point at index "+n)})}function lM(e,t,r){if(!Array.isArray(e))throw new Error("array of scalars expected");e.forEach((n,i)=>{if(!(r===void 0?t.isValid(n):ii(n)&&n<r))throw new Error("invalid scalar at index "+i)})}function Ad(e){return pS.get(e)||1}function hM(e,t){let r=e.double(),n=[e];for(let i=1;i<t;i++)n.push(n[i-1].add(r));return n}function dM(e,t){let r=2**t,n=r/2,i=BigInt(r-1),o=[];for(;e>Od;){let s=0;e&aa&&(s=Number(e&i),s>=n&&(s-=r),e-=BigInt(s)),o.push(s),e>>=aa}return o}function pM(e,t,r){let n=2**t,i=n/2,o=BigInt(n-1),s=BigInt(t),a=[];for(let f=0;f<r;f++){let l=Number(e&o);e>>=s,l>i&&(l-=n,e+=aa),a.push(l)}if(e!==Od)throw new Error("invalid wnaf");return a}function gM(e,t,r){let n=0;for(let o of r)n=Math.max(n,o.length);let i=e;for(let o=n-1;o>=0;o--){o!==n-1&&(i=i.double());for(let s=0;s<r.length;s++){let a=r[s][o];if(a){let f=t[s][Math.abs(a)-1>>1];i=i.add(a<0?f.negate():f)}}}return i}function Yo(e,t,r,n=!1){if(ai(e),dS(t,e),on(n,"allowOversized"),lM(r,e.Fn,n?e.Fn.ORDER**aM:void 0),t.length!==r.length)throw new Error("arrays of points and scalars must have equal length");let i=t.map(s=>hM(s,4)),o=r.map(s=>dM(s,4));return gM(e.ZERO,i,o)}function lS(e,t,r){if(t){if(t.ORDER!==e)throw new Error("Field.ORDER must match order: Fp == p, Fn == n");return Er(t),t}else return Wo(e,{isLE:r})}function gS(e,t,r={},n){if(e!=="weierstrass"&&e!=="edwards")throw new Error('expected curve type "weierstrass" or "edwards"');if(n===void 0&&(n=e==="edwards"),!t||typeof t!="object")throw new Error(`expected valid ${e} CURVE object`);qe(r);for(let f of["p","n","h"]){let l=t[f];if(!(ii(l)&&l!==Od))throw new Error(`CURVE.${f} must be positive bigint`)}let i=lS(t.p,r.Fp,n),o=lS(t.n,r.Fn,n),a=["Gx","Gy","a",e==="weierstrass"?"b":"d"];for(let f of a)if(!i.isValid(t[f]))throw new Error(`CURVE.${f} must be valid field element of CURVE.Fp`);return t=Object.freeze(Object.assign({},t)),{CURVE:t,Fp:i,Fn:o}}function jf(e,t){return function(n){let i=e(n);return{secretKey:i,publicKey:t(i)}}}var Od,aa,aM,Id,fS,uM,cS,pS,Hf,Kf=Wt(()=>{p();oi();zi();Od=BigInt(0),aa=BigInt(1),aM=BigInt(4),Id=16,fS=128,uM=5,cS=2**31;pS=new WeakMap;Hf=class{constructor(t,r){Z(this,"Point");Z(this,"BASE");Z(this,"ZERO");Z(this,"randomBytes");Z(this,"wnafPrecomputes",new WeakMap);Z(this,"baseCanBeBlinded");Z(this,"bits");ai(t),this.randomBytes=Rd(r,Id),this.Point=t,this.BASE=t.BASE,this.ZERO=t.ZERO,this.bits=t.Fn.BITS}buildWnafTable(t,r,n){let i=Math.ceil(n/r)+1,o=2**(r-1),s=[],a=t;for(let f=0;f<i;f++){let l=a;for(let y=0;y<o;y++)s.push(l),l=l.add(a);a=s[s.length-1].double()}return{W:r,bits:n,windows:i,comp:s}}wnafCachedCT(t,r){let{W:n,windows:i,comp:o}=t,s=2**(n-1),a=pM(r,n,i),f=this.ZERO,l=this.BASE;for(let y=0;y<i;y++){let g=a[y],v=y*s,E=Math.abs(g)-1,T=o[v];for(let U=1;U<s;U++)T=U===E?o[v+U]:T;let M=T.negate();g===0?l=l.add(o[v]):f=f.add(g<0?M:T)}return{p:f,f:l}}getWnafPrecomputes(t,r,n,i){let o=this.wnafPrecomputes.get(r),s=o?.find(a=>a.W===t&&a.bits===n);return s||(s=this.buildWnafTable(r,t,n),typeof i=="function"&&(s={...s,comp:i(s.comp)}),o||(o=[],this.wnafPrecomputes.set(r,o)),o.push(s)),s}assertPoint(t){if(!(t instanceof this.Point))throw new TypeError('"point" expected Point instance, got type='+typeof t)}validateMulInput(t,r){if(this.assertPoint(t),!vd(r,aa,this.Point.Fn.ORDER))throw new Error("invalid scalar")}runCT(t,r,n,i){let o=Ad(t);return o===1?this.fixedWindowCT(t,r,n):this.wnafCachedCT(this.getWnafPrecomputes(o,t,n,i),r)}mulCT(t,r,n){return this.validateMulInput(t,r),this.runCT(t,r,this.bits,n)}mulCTBlinded(t,r,n){if(this.validateMulInput(t,r),this.randomBytes===void 0)throw new Error("randomBytes is required for scalar blinding");let i=this.Point.Fn.BITS+fS,o=this.randomBytes(Id);if(!nn(o)||o.length!==Id)throw new Error("randomBytes returned invalid byte array");o[0]=o[0]&63|128;let s=r+Mt(o)*this.Point.Fn.ORDER;return this.runCT(t,s,i,n)}fixedWindowCT(t,r,n){let i=uM,o=1<<i,s=sa(i),a=new Array(o);a[0]=this.ZERO;for(let y=1;y<o;y++)a[y]=a[y-1].add(t);let f=Math.ceil(n/i),l=this.ZERO;for(let y=f-1;y>=0;y--){if(y!==f-1)for(let E=0;E<i;E++)l=l.double();let g=Number(r>>BigInt(y*i)&s),v=a[0];for(let E=1;E<o;E++)v=E===g?a[E]:v;l=l.add(v)}return{p:l,f:l}}shouldBlind(t,r){return this.randomBytes===void 0?!1:r===aa?!0:t!==this.BASE?!1:(this.baseCanBeBlinded===void 0&&(this.baseCanBeBlinded=this.mulUnsafe(this.BASE,this.Point.Fn.ORDER).is0()),this.baseCanBeBlinded)}mulSecret(t,r,n,i){return this.shouldBlind(t,n)?this.mulCTBlinded(t,r,i):this.mulCT(t,r,i)}mulUnsafe(t,r,n){if(this.assertPoint(t),!ii(r))throw new Error("invalid scalar");let i=Ad(t);if(i===1||r>=this.Point.Fn.ORDER)return Yo(this.Point,[t],[r],!0);let o=this.getWnafPrecomputes(i,t,this.bits,n);return this.wnafCachedCT(o,r).p}setWindowSize(t,r){this.assertPoint(t),fM(r,this.bits);let n=Math.ceil((this.bits+fS)/r)+1;cM(n*2**(r-1),this.Point.Fp.BYTES),pS.set(t,r),this.wnafPrecomputes.delete(t)}hasWindowSize(t){return Ad(t)!==1}}});function Td(e,t="n"){if(typeof e!="number")throw new TypeError(`wrong u32 integer "${t}": expected number, got type=${typeof e}`);if(!Number.isSafeInteger(e)||e<0||e>4294967295)throw new RangeError(`wrong u32 integer "${t}": expected 0..4294967295, got ${e}`);return e}function yS(e){return Td(e,"x"),(e&e-1)===0&&e!==0}function yM(e){if(Td(e),e<=1)return 1;if(e>2147483648)throw new Error("nextPowerOfTwo overflow: result does not fit u32");return 1<<Gf(e-1)+1>>>0}function Gf(e){return Td(e),31-Math.clz32(e)}function mS(e,t,r,n,i){Er(e);let o=e,s=r||((g,v)=>new Array(g).fill(v??o.ZERO)),a=g=>{if(Array.isArray(g))return!0;if(!ArrayBuffer.isView(g))return!1;let v=g;return typeof v.length=="number"&&typeof v.slice=="function"&&typeof v[Symbol.iterator]=="function"},f=(g,v)=>{if(!a(v))throw new TypeError(`"${g}" expected polynomial, got type=${typeof v}`)},l=(g,v)=>{f("a",g);let E=g.length;if(v!==void 0&&(f("b",v),v.length!==E))throw new Error(`poly: mismatched lengths ${E} vs ${v.length}`);if(i!==void 0&&E!==i)throw new Error(`poly: expected fixed length ${i}, got ${E}`);return E};function y(g,v,E=!1,T){if(!yS(v))throw new Error("poly.lagrange: expected power of two length, got "+v);let M=T||(E?t.brp(Gf(v)):t.roots(Gf(v)));for(let U=0;U<v;U++)if(o.eql(g,M[U]))return U;return-1}return{roots:t,create:s,length:i,extend:(g,v)=>{l(g);let E=s(v,o.ZERO);for(let T=0;T<Math.min(g.length,v);T++)E[T]=g[T];return E},degree:g=>{l(g);for(let v=g.length-1;v>=0;v--)if(!o.is0(g[v]))return v;return-1},add:(g,v)=>{let E=l(g,v),T=s(E);for(let M=0;M<E;M++)T[M]=o.add(g[M],v[M]);return T},sub:(g,v)=>{let E=l(g,v),T=s(E);for(let M=0;M<E;M++)T[M]=o.sub(g[M],v[M]);return T},dot:(g,v)=>{let E=l(g,v),T=s(E);for(let M=0;M<E;M++)T[M]=o.mul(g[M],v[M]);return T},mul:(g,v)=>{if(a(v)){let E=l(g,v);if(n){let T=n.direct(g,!1,!0),M=n.direct(v,!1,!0);for(let U=0;U<T.length;U++)T[U]=o.mul(T[U],M[U]);return n.inverse(T,!0,!1)}else{let T=s(E);for(let M=0;M<E;M++)for(let U=0;U<E;U++){let F=(M+U)%E;T[F]=o.add(T[F],o.mul(g[M],v[U]))}return T}}else{let E=s(l(g));for(let T=0;T<E.length;T++)E[T]=o.mul(g[T],v);return E}},convolve(g,v){f("a",g),f("b",v);let E=yM(g.length+v.length-1);return this.mul(this.extend(g,E),this.extend(v,E))},shift(g,v){f("p",g);let E=s(g.length);if(i!==void 0&&g.length!==i)throw new Error(`poly: expected fixed length ${i}, got ${g.length}`);if(!g.length)return E;E[0]=g[0];for(let T=1,M=o.ONE;T<g.length;T++)M=o.mul(M,v),E[T]=o.mul(g[T],M);return E},clone:g=>{l(g);let v=s(g.length);for(let E=0;E<g.length;E++)v[E]=g[E];return v},eval:(g,v)=>{l(g,v);let E=o.ZERO;for(let T=0;T<g.length;T++)E=o.add(E,o.mul(g[T],v[T]));return E},monomial:{basis:(g,v)=>{let E=s(v),T=o.ONE;for(let M=0;M<v;M++)E[M]=T,T=o.mul(T,g);return E},eval:(g,v)=>{l(g);let E=o.ZERO;for(let T=g.length-1;T>=0;T--)E=o.add(o.mul(E,v),g[T]);return E}},lagrange:{basis:(g,v,E=!1,T)=>{if(!yS(v))throw new Error("poly.lagrange: expected power of two length, got "+v);let M=Gf(v),U=T||(E?t.brp(M):t.roots(M)),F=s(v),V=y(g,v,E,T);if(V!==-1)return F[V]=o.ONE,F;let z=o.pow(g,BigInt(v)),G=o.mul(o.sub(z,o.ONE),o.inv(BigInt(v))),ie=s(v);for(let pe=0;pe<v;pe++)ie[pe]=o.sub(g,U[pe]);let ee=o.invertBatch(ie);for(let pe=0;pe<v;pe++)F[pe]=o.mul(G,o.mul(U[pe],ee[pe]));return F},eval(g,v,E=!1){l(g);let T=y(v,g.length,E);if(T!==-1)return g[T];let M=this.basis(v,g.length,E),U=o.ZERO;for(let F=0;F<g.length;F++)o.is0(g[F])||(U=o.add(U,o.mul(g[F],M[F])));return U}},vanishing(g){if(f("roots",g),i!==void 0&&g.length!==i)throw new Error(`poly: expected fixed length ${i}, got ${g.length}`);let v=s(g.length+1,o.ZERO);v[0]=o.ONE;for(let E of g){let T=o.neg(E);for(let M=v.length-1;M>0;M--)v[M]=o.add(o.mul(v[M],T),v[M-1]);v[0]=o.mul(v[0],T)}return v}}}var vS=Wt(()=>{p();zi()});function Yi(e,t){if(nt(e),nt(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 vM(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 wS(e){if(!nn(e)&&typeof e!="string")throw new Error("DST must be Uint8Array or ascii string");let t=typeof e=="string"?Ko(e):e;if(t.length===0)throw new Error("DST must be non-empty");return t}function bM(e,t,r,n){if(Se(e),nt(r),typeof n!="function")throw new Error("expand_message_xmd: expected hash function");nt(n.outputLen,"hash.outputLen"),nt(n.blockLen,"hash.blockLen"),t=wS(t),t.length>255&&(t=n(Ce(Ko("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=Ce(t,Yi(t.length,1)),f=new Uint8Array(o),l=Yi(r,2),y=new Array(s),g=n(Ce(f,e,l,Yi(0,1),a));y[0]=n(Ce(g,Yi(1,1),a));for(let E=1;E<s;E++){let T=[vM(g,y[E-1]),Yi(E+1,1),a];y[E]=n(Ce(...T))}return Ce(...y).slice(0,r)}function _M(e,t,r,n,i){if(Se(e),nt(r),nt(n,"k"),n<0)throw new Error("expand_message_xof: invalid k");if(typeof i!="function")throw new Error("expand_message_xof: expected XOF function");if(typeof i.create!="function")throw new Error("expand_message_xof: expected XOF create");if(t=wS(t),r<0||r>65535)throw new Error("expand_message_xof: invalid lenInBytes");if(t.length>255){let o=Math.ceil(2*n/8);t=i.create({dkLen:o}).update(Ko("H2C-OVERSIZE-DST-")).update(t).digest()}if(t.length>255)throw new Error("expand_message_xof: invalid DST");return i.create({dkLen:r}).update(e).update(Yi(r,2)).update(t).update(Yi(t.length,1)).digest()}function Pd(e,t,r){qe(r,{p:"bigint",m:"number",k:"number",hash:"function"});let{p:n,k:i,m:o,hash:s,expand:a,DST:f}=r;if(nt(s.outputLen,"valid hash"),Se(e),nt(t),nt(o,"m"),nt(i,"k"),n<=BigInt(1))throw new Error("hash_to_field: expected valid field characteristic");if(t<1)throw new Error("hash_to_field: expected count >= 1");if(o<1)throw new Error("hash_to_field: expected m >= 1");if(i<0)throw new Error("hash_to_field: invalid k");let l=n.toString(2).length,y=Math.ceil((l+i)/8),g=t*o*y,v;if(a==="xmd")v=bM(e,f,g,s);else if(a==="xof")v=_M(e,f,g,i,s);else if(a==="_internal_pass")v=e;else throw new Error('expand must be "xmd" or "xof"');let E=new Array(t);for(let T=0;T<t;T++){let M=new Array(o);for(let U=0;U<o;U++){let F=y*(U+T*o),V=v.subarray(F,F+y);M[U]=er(mM(V),n)}E[T]=M}return E}function ES(e,t){Er(e),rt(t,"map");let r=t.map((n,i)=>{if(rt(n,"map["+i+"]"),n.length<1)throw new Error("isogenyMap: expected non-empty coefficients");return Array.from(n).reverse()});return(n,i)=>{let[o,s,a,f]=r.map(v=>v.reduce((E,T)=>e.add(e.mul(E,n),T))),l=e.is0(s)||e.is0(f),[y,g]=Vo(e,[s,f],!0);return n=e.mul(o,y),i=e.mul(i,e.mul(a,g)),l?{x:e.ZERO,y:e.ZERO}:{x:n,y:i}}}function xS(e,t,r){if(typeof t!="function")throw new Error("mapToCurve() must be defined");qe(r);let n=f=>Object.freeze({...f,DST:nn(f.DST)?Ff(f.DST):f.DST,...f.encodeDST===void 0?{}:{encodeDST:nn(f.encodeDST)?Ff(f.encodeDST):f.encodeDST}}),i=n(r),o=f=>f&&f.DST!==void 0?{DST:f.DST}:void 0;function s(f){return e.fromAffine(t(f))}function a(f){let l=f.clearCofactor();return l.equals(e.ZERO)?e.ZERO:(l.assertValidity(),l)}return Object.freeze({get defaults(){return n(i)},Point:e,hashToCurve(f,l){let y=Object.assign({},i,o(l)),g=Pd(f,2,y),v=s(g[0]),E=s(g[1]);return a(v.add(E))},encodeToCurve(f,l){let y=i.encodeDST===void 0?{}:{DST:i.encodeDST},g=Object.assign({},i,y,o(l)),v=Pd(f,1,g),E=s(v[0]);return a(E)},mapToCurve(f){if(i.m===1){if(typeof f!="bigint")throw new Error("expected bigint (m=1)");return a(s([f]))}if(!Array.isArray(f))throw new Error("expected array of bigints");if(f.length!==i.m)throw new Error(`expected array of ${i.m} bigints`);for(let l of f)if(typeof l!="bigint")throw new Error("expected array of bigints");return a(s(f))},hashToScalar(f,l){let y=e.Fn.ORDER,g=Object.assign({},i,{DST:SM},o(l),{p:y,m:1});return Pd(f,1,g)[0][0]}})}function wM(e,t){let r=Er(e),n=r.ORDER,i=bS;for(let M=n-sn;M%ui===bS;M/=ui)i+=sn;let o=i,s=ui<<o-sn-sn,a=s*ui,f=(n-sn)/a,l=(f-sn)/ui,y=a-sn,g=s,v=r.pow(t,f),E=r.pow(t,(f+sn)/ui),T=(M,U)=>{let F=v,V=r.pow(U,y),z=r.sqr(V);z=r.mul(z,U);let G=r.mul(M,z);G=r.pow(G,l),G=r.mul(G,V),V=r.mul(G,U),z=r.mul(G,M);let ie=r.mul(z,V);G=r.pow(ie,g);let ee=r.eql(G,r.ONE);V=r.mul(z,E),G=r.mul(ie,F),z=r.cmov(V,z,ee),ie=r.cmov(G,ie,ee);for(let pe=o;pe>sn;pe--){let le=pe-ui;le=ui<<le-sn;let me=r.pow(ie,le),I=r.eql(me,r.ONE);V=r.mul(z,F),F=r.mul(F,F),me=r.mul(ie,F),z=r.cmov(V,z,I),ie=r.cmov(me,ie,I)}return{isValid:!r.is0(U)&&(ee||r.is0(M)),value:z}};if(r.ORDER%SS===_S){let M=(r.ORDER-_S)/SS,U=r.sqrt(r.neg(t));T=(F,V)=>{let z=r.sqr(V),G=r.mul(F,V);z=r.mul(z,G);let ie=r.pow(z,M);ie=r.mul(ie,G);let ee=r.mul(ie,U),pe=r.mul(r.sqr(ie),V),le=r.eql(pe,F),me=r.cmov(ee,ie,le);return{isValid:!r.is0(V)&&le,value:me}}}return T}function IS(e,t){let r=Er(e);qe(t,{},{},"opts");let{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))||xd(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(!xd(r,a))throw new Error("mapToCurveSimpleSWU: invalid opts");let f=wM(r,o);if(!r.isOdd)throw new Error("Field does not have .isOdd()");return l=>{let y,g,v,E,T,M,U,F;y=r.sqr(l),y=r.mul(y,o),g=r.sqr(y),g=r.add(g,y),v=r.add(g,r.ONE),v=r.mul(v,i),E=r.cmov(o,r.neg(g),!r.eql(g,r.ZERO)),E=r.mul(E,n),g=r.sqr(v),M=r.sqr(E),T=r.mul(M,n),g=r.add(g,T),g=r.mul(g,v),M=r.mul(M,E),T=r.mul(M,i),g=r.add(g,T),U=r.mul(y,v);let{isValid:V,value:z}=f(g,M);F=r.mul(y,l),F=r.mul(F,z),U=r.cmov(U,v,V),F=r.cmov(F,z,V);let G=r.isOdd(l)===r.isOdd(F);F=r.cmov(r.neg(F),F,G);let ie=Vo(r,[E],!0)[0];return U=r.mul(U,ie),{x:U,y:F}}}var bS,sn,ui,_S,SS,mM,SM,AS=Wt(()=>{p();oi();zi();bS=BigInt(0),sn=BigInt(1),ui=BigInt(2),_S=BigInt(3),SS=BigInt(4),mM=Mt;SM="HashToScalar-"});function Bd(e){qe(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"}),ai(e.Point);let{Point:t}=e,r=e.Fn===void 0?t.Fn:e.Fn,n=e.hash,i=e.hashToScalar===void 0?(O,C={DST:new Uint8Array})=>{let D=n(Ce(C.DST,O));return r.create(r.isLE?jo(D):Mt(D))}:e.hashToScalar,o=In(e.H1!==void 0?e.H1:e.name+"rho"),s=In(e.H2!==void 0?e.H2:e.name+"chal"),a=In(e.H3!==void 0?e.H3:e.name+"nonce"),f=In(e.H4!==void 0?e.H4:e.name+"msg"),l=In(e.H5!==void 0?e.H5:e.name+"com"),y=In(e.HDKG!==void 0?e.HDKG:e.name+"dkg"),g=In(e.HID!==void 0?e.HID:e.name+"id"),v=O=>i(O,{DST:o}),E=O=>i(O,{DST:s}),T=O=>i(O,{DST:a}),M=O=>n(Ce(f,O)),U=O=>n(Ce(l,O)),F=O=>i(O,{DST:y}),V=O=>i(O,{DST:g}),z=(O=Qt)=>{if(typeof O!="function")throw new TypeError('"rng" expected function, got type='+typeof O);let C=Wi(O(zo(r.ORDER)),r.ORDER,r.isLE);return r.isLE?jo(C):Mt(C)},G=O=>O.toBytes(),ie=O=>{let C=t.fromBytes(O);return e.validatePoint&&e.validatePoint(C),C},ee=(O,C)=>({identifier:O,hiding:G(t.BASE.multiply(r.fromBytes(C.hiding))),binding:G(t.BASE.multiply(r.fromBytes(C.binding)))}),pe=e.adjustPoint===void 0?O=>O:e.adjustPoint,le=O=>{if(!r.isValid(O)||r.is0(O))throw new Error("Invalid identifier "+O);return O},me=O=>Rn(r.toBytes(le(O))),I=(O,C="identifier")=>{ia(O,C);let D=le(r.fromBytes(Ho(O)));if(me(D)!==O)throw new Error("expected canonical identifier hex");return D},u={encode:(O,C)=>{let D=Ce(G(O),r.toBytes(C));return e.adjustTx&&(D=e.adjustTx.encode(D)),D},decode:O=>{e.adjustTx&&(O=e.adjustTx.decode(O));let C=O.subarray(0,-r.BYTES),D=ie(C);if(G(D).length!==C.length)throw new Error("invalid signature encoding");let K=r.fromBytes(O.subarray(-r.BYTES));return{R:D,z:K}}},h=(O=Qt)=>{let C=z(O);e.adjustScalar&&(C=e.adjustScalar(C));let D=t.BASE.multiply(C);return{scalar:C,point:D}},m="roots are unavailable in FROST polynomial mode",S={info:{G:r.ZERO,oddFactor:r.ZERO,powerOfTwo:0},roots(){throw new Error(m)},brp(){throw new Error(m)},inverse(){throw new Error(m)},omega(){throw new Error(m)},clear(){}},w=mS(r,S),R=(O,C)=>Yo(t,O,C),A=(O,C)=>{if(!C.length)throw new Error("empty coefficients");return w.monomial.eval(C,O)},_=(O,C)=>{let D="invalid parameters";if(!O.some(Q=>r.eql(Q,C)))throw new Error(D);let K=new Set(O);if(K.size!==O.length)throw new Error(D);if(!K.has(C))throw new Error(D);let re=r.ONE,J=r.ONE;for(let Q of O)r.eql(Q,C)||(re=r.mul(re,Q),J=r.mul(J,r.sub(Q,C)));return r.div(re,J)},c=(O,C)=>{let D=w.monomial.basis(O,C.length);return R(C,D)},b=(O,C,D,K=Qt)=>{if(an(O),C!==void 0&&Se(C,r.BYTES,"secret"),D!==void 0&&rt(D,"coeffs"),typeof K!="function")throw new TypeError('"rng" expected function, got type='+typeof K);let re=C===void 0?z(K):r.fromBytes(C);if(!D){D=[];for(let se=0;se<O.min-1;se++)D.push(z(K))}if(D.length!==O.min-1)throw new Error("wrong coefficients length");let J=[re,...D],Q=J.map(se=>t.BASE.multiply(se));return{coefficients:J,commitment:Q,secret:re}},k={challenge:(O,C,D)=>F(Ce(r.toBytes(O),G(C),G(D))),compute(O,C,D,K=Qt){if(C.length<1)throw new Error("coefficients should have at least one element");let{point:re,scalar:J}=h(K),Q=D[0],se=this.challenge(O,Q,re),ce=r.add(J,r.mul(C[0],se));return u.encode(re,ce)},validate(O,C,D){if(C.length<1)throw new Error("commitment should have at least one element");let{R:K,z:re}=u.decode(D),J=ie(C[0]),Q=this.challenge(O,J,K);if(!K.equals(t.BASE.multiplyUnsafe(re).subtract(J.multiplyUnsafe(Q))))throw new Error("invalid proof of knowledge")}},L={challenge:(O,C,D)=>e.challenge?e.challenge(O,C,D):E(Ce(G(O),G(C),D)),sign(O,C,D=Qt){let{point:K,scalar:re}=h(D),J=t.BASE.multiply(C),Q=this.challenge(K,J,O),se=r.add(re,r.mul(Q,C));return[K,se]},verify(O,C,D,K){e.adjustPoint&&(K=e.adjustPoint(K)),e.adjustPoint&&(C=e.adjustPoint(C));let re=this.challenge(C,K,O),J=t.BASE.multiplyUnsafe(D),Q=K.multiplyUnsafe(re),se=J.subtract(Q).subtract(C);return se.clearCofactor&&(se=se.clearCofactor()),t.ZERO.equals(se)}},H=(O,C,D)=>{if(!t.BASE.multiply(D).equals(c(O,C)))throw new Error("invalid secret share")},W={fromNumber(O){if(!Number.isSafeInteger(O))throw new Error("expected safe interger");return me(BigInt(O))},derive(O){return ia(O,"s"),me(V(In(O)))}},te=(O,C=Qt)=>T(Ce(C(32),r.toBytes(O))),X=(O,C,D)=>{let K=C.map(ge=>[ge.identifier,I(ge.identifier),ie(ge.hiding),ie(ge.binding)]);K.sort((ge,be)=>ge[1]<be[1]?-1:ge[1]>be[1]?1:0);let re=[];for(let[ge,be,Ee,or]of K)re.push(r.toBytes(be),G(Ee),G(or));let J=U(Ce(...re)),Q=Ce(G(O),M(D),J),se={};for(let[ge,be]of K)se[ge]=v(Ce(Q,r.toBytes(be)));let ce=t.ZERO,ae=[],_e=[];for(let[ge,be,Ee,or]of K){if(t.ZERO.equals(Ee)||t.ZERO.equals(or))throw new Error("infinity commitment");ce=ce.add(Ee),ae.push(or),_e.push(se[ge])}let oe=ce.add(R(ae,_e));return{identifiers:K.map(ge=>ge[1]),groupCommitment:oe,bindingFactors:se}},ue=(O,C,D,K)=>{let re=pe(ie(O)),J=I(K),{identifiers:Q,groupCommitment:se,bindingFactors:ce}=X(re,C,D),ae=ce[K],_e=_(Q,J),oe=L.challenge(se,re,D);return{lambda:_e,challenge:oe,bindingFactor:ae,groupCommitment:se}};Object.freeze(W);let fe={Identifier:W,DKG:Object.freeze({round1:(O,C,D,K=Qt)=>{let re=I(O,"id");an(C);let{coefficients:J,commitment:Q}=b(C,D,void 0,K),se=k.compute(re,J,Q,K),ce=Q.map(G),ae={identifier:me(re),commitment:ce,proofOfKnowledge:se},_e={identifier:re,coefficients:J,commitment:Q.map(G),signers:{min:C.min,max:C.max},step:1};return{public:ae,secret:_e}},round2:(O,C)=>{if(qe(O,{identifier:"bigint",commitment:"object",signers:"object"},{coefficients:"object",round2Cache:"object",step:"number"},"secret"),an(O.signers,"secret.signers"),rt(C,"others"),C.length!==O.signers.max-1)throw new Error("wrong number of round1 packages");if(!O.coefficients||O.step===3)throw new Error("round3 package used in round2");if(O.round2Cache!==void 0)return O.round2Cache;let D={};for(let K of C){if(K.commitment.length!==O.signers.min)throw new Error("wrong number of commitments");let re=I(K.identifier);if(re===O.identifier)throw new Error("duplicate id="+me(re));k.validate(re,K.commitment,K.proofOfKnowledge);for(let Q of K.commitment)ie(Q);if(D[K.identifier])throw new Error("Duplicate id="+re);let J=r.toBytes(A(re,O.coefficients));D[K.identifier]={identifier:me(O.identifier),signingShare:J}}return O.round2Cache=D,O.step=2,D},round3:(O,C,D)=>{if(qe(O,{identifier:"bigint",commitment:"object",signers:"object"},{coefficients:"object",round2Cache:"object",step:"number"},"secret"),an(O.signers,"secret.signers"),rt(C,"round1"),rt(D,"round2"),C.length!==O.signers.max-1)throw new Error("wrong length of round1 packages");if(!O.coefficients||O.step!==2)throw new Error("round2 package used in round3");if(D.length!==C.length)throw new Error("wrong length of round2 packages");let K={};for(let ge of C){if(!ge.identifier||!ge.commitment)throw new Error("wrong round1 share");K[ge.identifier]={...ge}}for(let ge of D){if(!ge.identifier||!ge.signingShare)throw new Error("wrong round2 share");if(!K[ge.identifier])throw new Error("round1 share for "+ge.identifier+" is missing");K[ge.identifier].signingShare=ge.signingShare}if(Object.keys(K).length!==C.length)throw new Error("mismatch identifiers between rounds");let re=r.ZERO;if(O.commitment.length!==O.signers.min)throw new Error("wrong commitments length");let J=O.commitment.map(ie),Q=A(O.identifier,O.coefficients);H(O.identifier,J,Q);let se=J.map(G),ce={[me(O.identifier)]:se};for(let ge in K){let be=K[ge];if(!be.signingShare||!be.commitment)throw new Error("mismatch identifiers");let Ee=I(ge),or=r.fromBytes(be.signingShare),Ze=be.commitment.map(ie);H(O.identifier,Ze,or),re=r.add(re,or);let Ve=me(Ee);if(ce[Ve])throw new Error("duplicated id="+Ve);ce[Ve]=be.commitment}re=r.add(re,Q);let ae=new Array(O.signers.min).fill(t.ZERO);for(let ge in ce){let be=ce[ge];if(be.length!==O.signers.min)throw new Error("wrong commitments length");for(let Ee=0;Ee<be.length;Ee++)ae[Ee]=ae[Ee].add(ie(be[Ee]))}let _e=ae.map(G),oe={};for(let ge in ce)oe[ge]=G(c(I(ge),ae));let Pe={public:{signers:{min:O.signers.min,max:O.signers.max},commitments:_e,verifyingShares:Object.fromEntries(Object.entries(oe).map(([ge,be])=>[ge,be.slice()]))},secret:{identifier:me(O.identifier),signingShare:r.toBytes(re)}};e.adjustDKG&&(Pe=e.adjustDKG(Pe));for(let ge=0;ge<O.coefficients.length;ge++)O.coefficients[ge]-=O.coefficients[ge];return delete O.coefficients,delete O.round2Cache,O.step=3,Pe},clean(O){if(qe(O,{identifier:"bigint",commitment:"object",signers:"object"},{coefficients:"object",round2Cache:"object",step:"number"},"secret"),O.identifier-=O.identifier,O.coefficients)for(let C=0;C<O.coefficients.length;C++)O.coefficients[C]-=O.coefficients[C];delete O.round2Cache,O.step=3}}),trustedDealer(O,C,D,K=Qt){if(an(O),C===void 0){C=[];for(let ae=1;ae<=O.max;ae++)C.push(W.fromNumber(ae))}else if(rt(C,"identifiers"),C.length!==O.max)throw new Error("identifiers should be array of "+O.max);let re={};for(let ae of C){let _e=I(ae);if(ae in re)throw new Error("duplicated id="+ae);re[ae]=_e}let J=b(O,D,void 0,K),Q=J.commitment.map(G),se={},ce={};for(let ae of C){let _e=A(re[ae],J.coefficients);ce[ae]=G(t.BASE.multiply(_e)),se[ae]={identifier:ae,signingShare:r.toBytes(_e)}}return{public:{signers:{min:O.min,max:O.max},commitments:Q,verifyingShares:ce},secretShares:se}},validateSecret(O,C){qe(O,{identifier:"string",signingShare:"object"},{},"secret"),Se(O.signingShare,r.BYTES,"secret.signingShare"),qe(C,{signers:"object",commitments:"object",verifyingShares:"object"},{},"pub"),an(C.signers,"pub.signers"),rt(C.commitments,"pub.commitments");let D=I(O.identifier),K=C.commitments.map(ie),re=r.fromBytes(O.signingShare);H(D,K,re)},commit(O,C=Qt){if(qe(O,{identifier:"string",signingShare:"object"},{},"secret"),Se(O.signingShare,r.BYTES,"secret.signingShare"),typeof C!="function")throw new TypeError('"rng" expected function, got type='+typeof C);let D=r.fromBytes(O.signingShare),K=te(D,C),re=te(D,C),J={hiding:r.toBytes(K),binding:r.toBytes(re)};return{nonces:J,commitments:ee(O.identifier,J)}},signShare(O,C,D,K,re){qe(O,{identifier:"string",signingShare:"object"},{},"secret"),Se(O.signingShare,r.BYTES,"secret.signingShare"),qe(C,{signers:"object",commitments:"object",verifyingShares:"object"},{},"pub"),an(C.signers,"pub.signers"),rt(C.commitments,"pub.commitments"),qe(D,{hiding:"object",binding:"object"},{},"nonces"),Se(D.hiding,r.BYTES,"nonces.hiding"),Se(D.binding,r.BYTES,"nonces.binding"),rt(K,"commitmentList"),Se(re,void 0,"msg"),OS(C.signers,K.length);let J=r.fromBytes(D.hiding),Q=r.fromBytes(D.binding);if(r.is0(J)||r.is0(Q))throw new Error("signing nonces already used");let se={identifier:O.identifier,hiding:G(t.BASE.multiply(J)),binding:G(t.BASE.multiply(Q))},ce=K.find(Je=>Je.identifier===O.identifier);if(!ce)throw new Error("missing signer commitment");if(Rn(ce.hiding)!==Rn(se.hiding)||Rn(ce.binding)!==Rn(se.binding))throw new Error("incorrect signer commitment");e.adjustSecret&&(O=e.adjustSecret(O,C)),e.adjustPublic&&(C=e.adjustPublic(C));let ae=r.fromBytes(O.signingShare),{lambda:_e,challenge:oe,bindingFactor:Pe,groupCommitment:ge}=ue(C.commitments[0],K,re,O.identifier),be=e.adjustNonces?e.adjustNonces(ge,D):D,Ee=e.adjustNonces?r.fromBytes(be.hiding):J,or=e.adjustNonces?r.fromBytes(be.binding):Q,Ze=r.mul(r.mul(_e,ae),oe),Ve=r.mul(or,Pe),Za=r.toBytes(r.add(r.add(Ee,Ve),Ze));return D.hiding.fill(0),D.binding.fill(0),Za},verifyShare(O,C,D,K,re){qe(O,{signers:"object",commitments:"object",verifyingShares:"object"},{},"pub"),an(O.signers,"pub.signers"),rt(O.commitments,"pub.commitments"),rt(C,"commitmentList"),Se(D,void 0,"msg"),I(K),Se(re,r.BYTES,"sigShare"),e.adjustPublic&&(O=e.adjustPublic(O));let J=C.find(or=>or.identifier===K);if(!J)throw new Error("cannot find identifier commitment");let Q=ie(O.verifyingShares[K]),se=ie(J.hiding),ce=ie(J.binding),{lambda:ae,challenge:_e,bindingFactor:oe,groupCommitment:Pe}=ue(O.commitments[0],C,D,K),ge=se.add(ce.multiplyUnsafe(oe));e.adjustGroupCommitmentShare&&(ge=e.adjustGroupCommitmentShare(Pe,ge));let be=t.BASE.multiplyUnsafe(r.fromBytes(re)),Ee=ge.add(Q.multiplyUnsafe(r.mul(_e,ae)));return be.equals(Ee)},aggregate(O,C,D,K){qe(O,{signers:"object",commitments:"object",verifyingShares:"object"},{},"pub"),an(O.signers,"pub.signers"),rt(O.commitments,"pub.commitments"),rt(C,"commitmentList"),Se(D,void 0,"msg"),qe(K,{},{},"sigShares");let re=O;e.adjustPublic&&(O=e.adjustPublic(O));try{OS(O.signers,C.length)}catch{throw new $i("aggregation failed",[])}let J=C.map(_e=>_e.identifier),Q=new Set;for(let _e of J){if(Q.has(_e))throw new $i("aggregation failed",[]);Q.add(_e)}if(J.length!==Object.keys(K).length)throw new $i("aggregation failed",[]);for(let _e of J)if(!(_e in K)||!(_e in O.verifyingShares))throw new $i("aggregation failed",[]);let se=ie(O.commitments[0]),{groupCommitment:ce}=X(se,C,D),ae=r.ZERO;for(let _e of J)ae=r.add(ae,r.fromBytes(K[_e]));if(!L.verify(D,ce,ae,se)){let _e=[];for(let oe of J)this.verifyShare(re,C,D,oe,K[oe])||_e.push(oe);throw new $i("aggregation failed",_e)}return u.encode(ce,ae)},sign(O,C){let D=r.fromBytes(C);e.adjustScalar&&(D=e.adjustScalar(D));let[K,re]=L.sign(O,D);return u.encode(K,re)},verify(O,C,D){let K=e.parsePublicKey?e.parsePublicKey(D):ie(D),{R:re,z:J}=u.decode(O);return L.verify(C,re,J,K)},combineSecret(O,C){if(rt(O,"shares"),an(C),O.length<C.min||O.length>C.max)throw new Error("wrong secret shares array");let D=[],K={};for(let Q of O){let se=I(Q.identifier),ce=me(se);if(K[ce])throw new Error("duplicated id="+ce);K[ce]=!0,D.push([se,r.fromBytes(Q.signingShare)])}let re=D.map(([Q])=>Q),J=r.ZERO;for(let[Q,se]of D)J=r.add(J,r.mul(se,_(re,Q)));return r.toBytes(J)},utils:Object.freeze({Fn:r,randomScalar:(O=Qt)=>r.toBytes(h(O).scalar),generateSecretPolynomial:(O,C,D,K)=>{let re=b(O,C,D,K);return{...re,commitment:re.commitment.map(G)}}})};return Object.freeze(fe)}var an,OS,$i,RS=Wt(()=>{p();An();oi();Kf();vS();zi();an=(e,t="signers")=>{if(qe(e,{min:"number",max:"number"},{},t),nt(e.min,t+".min"),nt(e.max,t+".max"),e.min<2||e.max<2||e.min>e.max)throw new Error("Wrong signers info: min="+e.min+" max="+e.max)},OS=(e,t)=>{if(t<e.min||t>e.max)throw new Error("Wrong number of commitments="+t)},$i=class extends Error{constructor(r,n){super(r);Z(this,"cheaters");this.cheaters=n}}});var Vf,TS,PS=Wt(()=>{p();An();Vf=class{constructor(t,r){Z(this,"oHash");Z(this,"iHash");Z(this,"blockLen");Z(this,"outputLen");Z(this,"canXOF",!1);Z(this,"finished",!1);Z(this,"destroyed",!1);if(xf(t),rn(r,void 0,"key"),this.iHash=t.create(),typeof this.iHash.update!="function")throw new Error("expected Hash instance");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),ar(i)}update(t){return Uo(this),this.iHash.update(t),this}digestInto(t){Uo(this),If(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,canXOF:f}=this;return t=t,t.finished=i,t.destroyed=o,t.blockLen=s,t.outputLen=a,t.canXOF=f,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()}},TS=(()=>{let e=((t,r,n)=>new Vf(t,r).update(n).digest());return e.create=(t,r)=>new Vf(t,r),e})()});var EM,Nd,Tn,Md,BS=Wt(()=>{p();oi();EM=BigInt(0),Nd=class extends Error{constructor(t=""){super(t)}},Tn={Err:Nd,_tlv:{encode:(e,t)=>{let{Err:r}=Tn;if(nt(e,"tag"),e<0||e>255)throw new r("tlv.encode: wrong tag");if(ia(t,"data"),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}=Tn;t=Se(t,void 0,"DER data");let n=0;if(e<0||e>255)throw new r("tlv.decode: 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 f=i&127;if(!f)throw new r("tlv.decode(long): indefinite length not supported");if(f>4)throw new r("tlv.decode(long): byte length is too big");let l=t.subarray(n,n+f);if(l.length!==f)throw new r("tlv.decode: length bytes not complete");if(l[0]===0)throw new r("tlv.decode(long): zero leftmost byte");for(let y of l)s=s<<8|y;if(n+=f,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}=Tn;if(Df(e),e<EM)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}=Tn;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 Mt(e)}},toSig(e){let{Err:t,_int:r,_tlv:n}=Tn,i=Se(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:f}=n.decode(2,o),{v:l,l:y}=n.decode(2,f);if(y.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}=Tn;qe(e,{r:"bigint",s:"bigint"},{},"sig");let n=t.encode(2,r.encode(e.r)),i=t.encode(2,r.encode(e.s)),o=n+i;return t.encode(48,o)}},Md=(Object.freeze(Tn._tlv),Object.freeze(Tn._int),Object.freeze(Tn))});function xM(e,t,r){bd("scalar",e,Pn,r);let[[n,i],[o,s]]=t,a=NS(s*e,r),f=NS(-i*e,r),l=e-a*n-f*o,y=-a*i-f*s,g=l<Pn,v=y<Pn;g&&(l=-l),v&&(y=-y);let E=sa(Math.ceil(Go(r)/2))+Zi;if(l<Pn||l>=E||y<Pn||y>=E)throw new Error("splitScalar (endomorphism): failed for k");return{k1neg:g,k1:l,k2neg:v,k2:y}}function Ld(e){if(!["compact","recovered","der"].includes(e))throw new Error('Signature format must be "compact", "recovered", or "der"');return e}function kd(e,t){qe(e);let r={};for(let n of Object.keys(t))r[n]=e[n]===void 0?t[n]:e[n];return on(r.lowS,"lowS"),on(r.prehash,"prehash"),r.format!==void 0&&Ld(r.format),r}function kS(e,t={}){let r=gS("weierstrass",e,t),n=r.Fp,i=r.Fn,o=r.CURVE,{h:s,n:a}=o;qe(t,{},{allowInfinityPoint:"boolean",clearCofactor:"function",isTorsionFree:"function",fromBytes:"function",toBytes:"function",endo:"object",randomBytes:"function"});let{endo:f,allowInfinityPoint:l}=t,y=t.randomBytes===void 0?Qt:t.randomBytes;if(f&&(!n.is0(o.a)||typeof f.beta!="bigint"||!Array.isArray(f.basises)))throw new Error('invalid endo: expected "beta": bigint and "basises": array');let g=LS(n,i);function v(){if(!n.isOdd)throw new Error("compression is not supported: Field does not have .isOdd()")}function E(R,A,_){if(l&&A.is0())return Uint8Array.of(0);let{x:c,y:b}=A.toAffine(),k=n.toBytes(c);if(on(_,"isCompressed"),_){v();let L=!n.isOdd(b);return Ce(CS(L),k)}else return Ce(Uint8Array.of(4),k,n.toBytes(b))}function T(R){Se(R,void 0,"Point");let{publicKey:A,publicKeyUncompressed:_}=g,c=R.length,b=R[0],k=R.subarray(1);if(l&&c===1&&b===0)return{x:n.ZERO,y:n.ZERO};if(c===A&&(b===2||b===3)){let L=n.fromBytes(k);if(!n.isValid(L))throw new Error("bad point: is not on curve, wrong x");let H=z(L),W;try{W=n.sqrt(H)}catch(ue){let fe=ue instanceof Error?": "+ue.message:"";throw new Error("bad point: is not on curve, sqrt error"+fe)}v();let te=n.isOdd(W);return(b&1)===1!==te&&(W=n.neg(W)),{x:L,y:W}}else if(c===_&&b===4){let L=n.BYTES,H=n.fromBytes(k.subarray(0,L)),W=n.fromBytes(k.subarray(L,L*2));if(!G(H,W))throw new Error("bad point: is not on curve");return{x:H,y:W}}else throw new Error(`bad point: got length ${c}, expected compressed=${A} or uncompressed=${_}`)}let M=t.toBytes===void 0?E:t.toBytes,U=t.fromBytes===void 0?T:t.fromBytes,F=n.mul(o.b,Cd),V=n.is0(o.a)?R=>n.ZERO:R=>n.mul(o.a,R);function z(R){let A=n.sqr(R),_=n.mul(A,R);return n.add(n.add(_,n.mul(R,o.a)),o.b)}function G(R,A){let _=n.sqr(A),c=z(R);return n.eql(_,c)}if(!G(o.Gx,o.Gy))throw new Error("bad curve params: generator point");let ie=n.mul(n.pow(o.a,Cd),IM),ee=n.mul(n.sqr(o.b),BigInt(27));if(n.is0(n.add(ie,ee)))throw new Error("bad curve params: a or b");function pe(R,A,_=!1){if(!n.isValid(A)||_&&n.is0(A))throw new Error(`bad point coordinate ${R}`);return A}function le(R){if(!(R instanceof h))throw new Error("Weierstrass Point expected")}function me(R){if(!f||!f.basises)throw new Error("no endo");return xM(R,f.basises,i.ORDER)}function I(R,A,_,c){if(!i.isValid(c))throw new RangeError("invalid scalar: out of range");if(f){let{k1neg:b,k1:k,k2neg:L,k2:H}=me(c),W=new h(n.mul(_.X,f.beta),_.Y,_.Z);R.push(b?_.negate():_,L?W.negate():W),A.push(k,H)}else R.push(_),A.push(c)}let u=new WeakSet,w=class w{constructor(A,_,c){Z(this,"X");Z(this,"Y");Z(this,"Z");this.X=pe("x",A),this.Y=pe("y",_,!0),this.Z=pe("z",c),Object.freeze(this)}static CURVE(){return o}static fromAffine(A){let{x:_,y:c}=A||{};if(!A||!n.isValid(_)||!n.isValid(c))throw new Error("invalid affine point");if(A instanceof w)throw new Error("projective point not allowed");return n.is0(_)&&n.is0(c)?w.ZERO:new w(_,c,n.ONE)}static fromBytes(A){let _=w.fromAffine(U(Se(A,void 0,"point")));return _.assertValidity(),_}static fromHex(A){return w.fromBytes(Ho(A))}get x(){return this.toAffine().x}get y(){return this.toAffine().y}precompute(A=6,_=!0){return S.setWindowSize(this,A),_||this.multiply(Cd),this}assertValidity(){let A=this;if(A.is0()){if(t.allowInfinityPoint&&n.is0(A.X)&&n.eql(A.Y,n.ONE)&&n.is0(A.Z))return;throw new Error("bad point: ZERO")}if(u.has(A))return;let{x:_,y:c}=A.toAffine();if(!n.isValid(_)||!n.isValid(c))throw new Error("bad point: x or y not field elements");if(!G(_,c))throw new Error("bad point: equation left != right");if(!A.isTorsionFree())throw new Error("bad point: not in prime-order subgroup");u.add(A)}hasEvenY(){let{y:A}=this.toAffine();if(!n.isOdd)throw new Error("Field doesn't support isOdd");return!n.isOdd(A)}equals(A){le(A);let{X:_,Y:c,Z:b}=this,{X:k,Y:L,Z:H}=A,W=n.eql(n.mul(_,H),n.mul(k,b)),te=n.eql(n.mul(c,H),n.mul(L,b));return W&&te}negate(){return new w(this.X,n.neg(this.Y),this.Z)}double(){let{X:A,Y:_,Z:c}=this,b=n.ZERO,k=n.ZERO,L=n.ZERO,H=n.mul(A,A),W=n.mul(_,_),te=n.mul(c,c),X=n.mul(A,_);return X=n.add(X,X),L=n.mul(A,c),L=n.add(L,L),b=V(L),k=n.mul(F,te),k=n.add(b,k),b=n.sub(W,k),k=n.add(W,k),k=n.mul(b,k),b=n.mul(X,b),L=n.mul(F,L),te=V(te),X=n.sub(H,te),X=V(X),X=n.add(X,L),L=n.add(H,H),H=n.add(L,H),H=n.add(H,te),H=n.mul(H,X),k=n.add(k,H),te=n.mul(_,c),te=n.add(te,te),H=n.mul(te,X),b=n.sub(b,H),L=n.mul(te,W),L=n.add(L,L),L=n.add(L,L),new w(b,k,L)}add(A){le(A);let{X:_,Y:c,Z:b}=this,{X:k,Y:L,Z:H}=A,W=n.ZERO,te=n.ZERO,X=n.ZERO,ue=n.mul(_,k),fe=n.mul(c,L),O=n.mul(b,H),C=n.add(_,c),D=n.add(k,L);C=n.mul(C,D),D=n.add(ue,fe),C=n.sub(C,D),D=n.add(_,b);let K=n.add(k,H);return D=n.mul(D,K),K=n.add(ue,O),D=n.sub(D,K),K=n.add(c,b),W=n.add(L,H),K=n.mul(K,W),W=n.add(fe,O),K=n.sub(K,W),X=V(D),W=n.mul(F,O),X=n.add(W,X),W=n.sub(fe,X),X=n.add(fe,X),te=n.mul(W,X),fe=n.add(ue,ue),fe=n.add(fe,ue),O=V(O),D=n.mul(F,D),fe=n.add(fe,O),O=n.sub(ue,O),O=V(O),D=n.add(D,O),ue=n.mul(fe,D),te=n.add(te,ue),ue=n.mul(K,D),W=n.mul(C,W),W=n.sub(W,ue),ue=n.mul(C,fe),X=n.mul(K,X),X=n.add(X,ue),new w(W,te,X)}subtract(A){return le(A),this.add(A.negate())}is0(){return this.equals(w.ZERO)}multiply(A){if(!i.isValidNot0(A))throw new RangeError("invalid scalar: out of range");let{p:_,f:c}=S.mulSecret(this,A,s,m);return m([_,c])[0]}multiplyUnsafe(A){let _=this,c=A;if(!i.isValid(c))throw new RangeError("invalid scalar: out of range");if(c===Pn||_.is0())return w.ZERO;if(c===Zi)return _;if(S.hasWindowSize(this))return S.mulUnsafe(_,c,m);let b=[],k=[];return I(b,k,_,c),Yo(w,b,k)}mulAddUnsafe(A,_,c){le(_);let b=[],k=[];return I(b,k,this,A),I(b,k,_,c),Yo(w,b,k)}toAffine(A){let _=this,c=A;if(c!=null&&!n.isValid(c))throw new RangeError('"invertedZ" expected valid field element');let{X:b,Y:k,Z:L}=_;if(n.eql(L,n.ONE))return{x:b,y:k};let H=_.is0();c==null&&(c=H?n.ONE:n.inv(L));let W=n.mul(b,c),te=n.mul(k,c),X=n.mul(L,c);if(H)return{x:n.ZERO,y:n.ZERO};if(!n.eql(X,n.ONE))throw new Error("invZ was invalid");return{x:W,y:te}}isTorsionFree(){let{isTorsionFree:A}=t;return s===Zi?!0:A?A(w,this):S.mulUnsafe(this,a).is0()}clearCofactor(){let{clearCofactor:A}=t;return s===Zi?this:A?A(w,this):this.multiplyUnsafe(s)}isSmallOrder(){return s===Zi?this.is0():this.clearCofactor().is0()}toBytes(A=!0){return on(A,"isCompressed"),this.assertValidity(),M(w,this,A)}toHex(A=!0){return Rn(this.toBytes(A))}toString(){return`<Point ${this.is0()?"ZERO":this.toHex()}>`}};Z(w,"BASE",new w(o.Gx,o.Gy,n.ONE)),Z(w,"ZERO",new w(n.ZERO,n.ONE,n.ZERO)),Z(w,"Fp",n),Z(w,"Fn",i);let h=w,m=R=>hS(h,R),S=new Hf(h,y);return S.bits>=6&&h.BASE.precompute(6),Object.freeze(h.prototype),Object.freeze(h),h}function CS(e){return Uint8Array.of(e?2:3)}function LS(e,t){return{secretKey:t.BYTES,publicKey:1+e.BYTES,publicKeyUncompressed:1+2*e.BYTES,publicKeyHasPrefix:!0,signature:2*t.BYTES}}function AM(e,t={}){ai(e);let{Fn:r}=e,n=t.randomBytes===void 0?Qt:t.randomBytes,i=Object.assign(LS(e.Fp,r),{seed:Math.max(zo(r.ORDER),16)});function o(E){try{let T=r.fromBytes(E);return r.isValidNot0(T)}catch{return!1}}function s(E,T){let{publicKey:M,publicKeyUncompressed:U}=i;try{let F=E.length;return T===!0&&F!==M||T===!1&&F!==U?!1:!!e.fromBytes(E)}catch{return!1}}function a(E){return E=E===void 0?n(i.seed):E,Wi(Se(E,i.seed,"seed"),r.ORDER)}function f(E,T=!0){return e.BASE.multiply(r.fromBytes(E)).toBytes(T)}function l(E){let{secretKey:T,publicKey:M,publicKeyUncompressed:U}=i,F=r._lengths;if(!nn(E))return;let V=Se(E,void 0,"key").length,z=V===M||V===U,G=V===T||!!F?.includes(V);if(!(z&&G))return z}function y(E,T,M=!0){if(l(E)===!0)throw new Error("first arg must be private key");if(l(T)===!1)throw new Error("second arg must be public key");let U=r.fromBytes(E);return e.fromBytes(T).multiply(U).toBytes(M)}let g={isValidSecretKey:o,isValidPublicKey:s,randomSecretKey:a},v=jf(a,f);return Object.freeze(g),Object.freeze(i),Object.freeze({getPublicKey:f,getSharedSecret:y,keygen:v,Point:e,utils:g,lengths:i})}function DS(e,t,r={}){ai(e);let n=t;xf(n),qe(r,{},{hmac:"function",lowS:"boolean",randomBytes:"function",bits2int:"function",bits2int_modN:"function"});let i=Object.assign({},r),o=i.randomBytes===void 0?Qt:i.randomBytes,s=i.hmac===void 0?(b,k)=>TS(n,b,k):i.hmac,{Fp:a,Fn:f}=e,{ORDER:l,BITS:y}=f,g=zo(l),v=Rd(o,g),{keygen:E,getPublicKey:T,getSharedSecret:M,utils:U,lengths:F}=AM(e,i),V={prehash:!0,lowS:typeof i.lowS=="boolean"?i.lowS:!0,format:"compact",extraEntropy:!1},z=l*MS+Zi<a.ORDER;function G(b){let k=l>>Zi;return b>k}function ie(b,k){if(!f.isValidNot0(k))throw new Error(`invalid signature ${b}: out of range 1..Point.Fn.ORDER`);return k}function ee(){if(!a.isOdd)throw new Error("Field doesn't support isOdd")}function pe(b,k,L){return ee(),(b===L?0:2)|Number(a.isOdd(k))}function le(){if(z)throw new Error('"recovered" sig type is not supported for cofactor >2 curves')}function me(b,k){Ld(k);let L=F.signature,H=k==="compact"?L:k==="recovered"?L+1:void 0;return Se(b,H)}class I{constructor(k,L,H){Z(this,"r");Z(this,"s");Z(this,"recovery");if(this.r=ie("r",k),this.s=ie("s",L),H!=null){if(le(),![0,1,2,3].includes(H))throw new Error("invalid recovery id");this.recovery=H}Object.freeze(this)}static fromBytes(k,L=V.format){me(k,L);let H;if(L==="der"){let{r:ue,s:fe}=Md.toSig(Se(k));return new I(ue,fe)}L==="recovered"&&(H=k[0],L="compact",k=k.subarray(1));let W=F.signature/2,te=k.subarray(0,W),X=k.subarray(W,W*2);return new I(f.fromBytes(te),f.fromBytes(X),H)}static fromHex(k,L){return this.fromBytes(Ho(k),L)}assertRecovery(){let{recovery:k}=this;if(k==null)throw new Error("invalid recovery id: must be present");return k}addRecoveryBit(k){return new I(this.r,this.s,k)}recoverPublicKey(k){let{r:L,s:H}=this,W=this.assertRecovery(),te=W===2||W===3?L+l:L;if(!a.isValid(te))throw new Error("invalid recovery id: sig.r+curve.n != R.x");let X=a.toBytes(te),ue=e.fromBytes(Ce(CS((W&1)===0),X)),fe=f.inv(te),O=h(Se(k,void 0,"msgHash")),C=f.create(-O*fe),D=f.create(H*fe),K=e.BASE.mulAddUnsafe(C,ue,D);if(K.is0())throw new Error("invalid recovery: point at infinify");return K.assertValidity(),K}hasHighS(){return G(this.s)}toBytes(k=V.format){if(Ld(k),k==="der")return Ho(Md.hexFromSig(this));let{r:L,s:H}=this,W=f.toBytes(L),te=f.toBytes(H);return k==="recovered"?(le(),Ce(Uint8Array.of(this.assertRecovery()),W,te)):Ce(W,te)}toHex(k){return Rn(this.toBytes(k))}}Object.freeze(I.prototype),Object.freeze(I);let u=i.bits2int===void 0?function(k){if(k.length>8192)throw new Error("input is too large");let L=Mt(k),H=k.length*8-y;return H>0?L>>BigInt(H):L}:i.bits2int,h=i.bits2int_modN===void 0?function(k){return f.create(u(k))}:i.bits2int_modN,m=sa(y);function S(b){return bd("num < 2^"+y,b,Pn,m),f.toBytes(b)}function w(b,k){return Se(b,void 0,"message"),k?Se(n(b),void 0,"prehashed message"):b}function R(b,k,L){let{lowS:H,prehash:W,extraEntropy:te}=kd(L,V);b=w(b,W);let X=h(b),ue=f.fromBytes(k);if(!f.isValidNot0(ue))throw new Error("invalid private key");let fe=[S(ue),S(X)];if(te!=null&&te!==!1){let K=te===!0?o(F.secretKey):te;fe.push(Se(K,void 0,"extraEntropy"))}let O=Ce(...fe),C=X;function D(K){let re=u(K);if(!f.isValidNot0(re))return;let J=e.BASE.multiply(re).toAffine(),Q=f.create(J.x);if(Q===Pn)return;let se;if(v!==void 0){let _e=Mt(Wi(v(g),l)),oe=f.inv(f.mul(_e,re)),Pe=f.mul(_e,C),ge=f.mul(_e,ue);se=f.create(oe*f.create(Pe+ge*Q))}else{let _e=oS(re,l);se=f.create(_e*f.create(C+Q*ue))}if(se===Pn)return;let ce=pe(J.x,J.y,Q),ae=se;return H&&G(se)&&(ae=f.neg(se),ce^=1),new I(Q,ae,z?void 0:ce)}return{seed:O,k2sig:D}}function A(b,k,L={}){let{seed:H,k2sig:W}=R(b,k,L);return X_(n.outputLen,f.BYTES,s)(H,W).toBytes(L.format)}function _(b,k,L,H={}){let{lowS:W,prehash:te,format:X}=kd(H,V);if(L=Se(L,void 0,"publicKey"),k=w(k,te),!nn(b)){let ue=b instanceof I?", use sig.toBytes()":"";throw new Error("verify expects Uint8Array signature"+ue)}me(b,X);try{let ue=I.fromBytes(b,X),fe=e.fromBytes(L);if(W&&ue.hasHighS())return!1;let{r:O,s:C}=ue,D=h(k),K=f.inv(C),re=f.create(D*K),J=f.create(O*K),Q=e.BASE.mulAddUnsafe(re,fe,J);if(Q.is0())return!1;let se=Q.toAffine();return!(f.create(se.x)!==O||X==="recovered"&&ue.recovery!==pe(se.x,se.y,O))}catch{return!1}}function c(b,k,L={}){let{prehash:H}=kd(L,V);return k=w(k,H),I.fromBytes(b,"recovered").recoverPublicKey(k).toBytes()}return Object.freeze({keygen:E,getPublicKey:T,getSharedSecret:M,utils:U,lengths:F,Point:e,sign:A,verify:_,recoverPublicKey:c,Signature:I,hash:n})}var NS,Pn,Zi,MS,Cd,IM,US=Wt(()=>{p();PS();An();oi();Kf();BS();zi();NS=(e,t)=>(e+(e>=0?t:-t)/MS)/t;Pn=BigInt(0),Zi=BigInt(1),MS=BigInt(2),Cd=BigInt(3),IM=BigInt(4)});var ZS={};ul(ZS,{__TEST:()=>BM,schnorr:()=>NM,schnorr_FROST:()=>DM,secp256k1:()=>TM,secp256k1_FROST:()=>CM,secp256k1_hasher:()=>Fd});function RM(e){let t=Wf.p,r=BigInt(3),n=BigInt(6),i=BigInt(11),o=BigInt(22),s=BigInt(23),a=BigInt(44),f=BigInt(88),l=e*e*e%t,y=l*l*e%t,g=dr(y,r,t)*y%t,v=dr(g,r,t)*y%t,E=dr(v,FS,t)*l%t,T=dr(E,i,t)*E%t,M=dr(T,o,t)*T%t,U=dr(M,a,t)*M%t,F=dr(U,f,t)*U%t,V=dr(F,a,t)*M%t,z=dr(V,r,t)*y%t,G=dr(z,s,t)*T%t,ie=dr(G,n,t)*l%t,ee=dr(ie,FS,t);if(!kr.eql(kr.sqr(ee),e))throw new Error("Cannot find square root");return ee}function ua(e,...t){let r=qS[e];if(r===void 0){let n=ri(Ko(e));r=Ce(n,n),qS[e]=r}return ri(Ce(r,...t))}function GS(e){let{Fn:t,BASE:r}=He,n=t.fromBytes(Se(e,32,"secretKey")),o=r.multiply(n).toAffine();return{scalar:un(o.y)?n:t.neg(n),bytes:KS(o)}}function zf(e){let t=kr;if(!t.isValidNot0(e))throw new Error("invalid x: Fail if x \u2265 p");let r=t.sqr(e),n=t.add(t.mulN(r,e),BigInt(7)),i=t.sqrt(n);un(i)||(i=t.neg(i));let o=He.fromAffine({x:e,y:i});return o.assertValidity(),o}function Ud(...e){return He.Fn.create($o(ua("BIP0340/challenge",...e)))}function HS(e){return GS(e).bytes}function PM(e,t,r=na(32)){let{Fn:n,BASE:i}=He,o=Se(e,void 0,"message"),{bytes:s,scalar:a}=GS(t),f=Se(r,32,"auxRand"),l=n.toBytes(a^$o(ua("BIP0340/aux",f))),y=ua("BIP0340/nonce",l,s,o),g=n.create($o(y));if(g===Dd)throw new Error("sign failed: k is zero");let E=i.multiply(g).toAffine(),T=un(E.y)?g:n.neg(g),M=KS(E),U=Ud(M,s,o),F=new Uint8Array(64);if(F.set(M,0),F.set(n.toBytes(n.create(T+U*a)),32),!VS(F,o,s))throw new Error("sign: Invalid signature produced");return F}function VS(e,t,r){let{Fp:n,Fn:i,BASE:o}=He,s=Se(e,64,"signature"),a=Se(t,void 0,"message"),f=Se(r,32,"publicKey");try{let l=zf($o(f)),y=s.subarray(0,32),g=$o(y);if(!n.isValidNot0(g))return!1;let v=$o(s.subarray(32,64));if(!i.isValidNot0(v))return!1;let E=Ud(y,fa(l),a),T=o.mulAddUnsafe(v,l,i.neg(E)),{x:M,y:U}=T.toAffine();return!(T.is0()||!un(U)||!n.eql(M,g))}catch{return!1}}function WS(e,t){if(t===void 0)return Dd;let r=fa(e),n=Mt(ua("TapTweak",r,t));if(!He.Fn.isValid(n))throw new Error("invalid TapTweak hash");return n}function qd(e){let t=He.fromBytes(e.commitments[0]);return un(t.y)?e:{signers:{min:e.signers.min,max:e.signers.max},commitments:e.commitments.map(r=>He.fromBytes(r).negate().toBytes()),verifyingShares:Object.fromEntries(Object.entries(e.verifyingShares).map(([r,n])=>[r,He.fromBytes(n).negate().toBytes()]))}}function zS(e,t){let r=He.fromBytes(t.commitments[0]);if(un(r.y))return e;let n=He.Fn;return{...e,signingShare:n.toBytes(n.neg(n.fromBytes(e.signingShare)))}}function LM(e,t){if(un(e.y))return t;let r=He.Fn;return{binding:r.toBytes(r.neg(r.fromBytes(t.binding))),hiding:r.toBytes(r.neg(r.fromBytes(t.hiding)))}}function YS(e,t,r){let n=He.Fn,i=zS(e,t),o=qd(t),s=WS(He.fromBytes(o.commitments[0]),r),a=n.toBytes(n.add(n.fromBytes(i.signingShare),s));return{identifier:i.identifier,signingShare:a}}function $S(e,t){let r=qd(e),n=WS(He.fromBytes(r.commitments[0]),t);if(n===Dd)return r;let i=He.BASE.multiply(n),o=r.commitments.map((a,f)=>(f===0?He.fromBytes(a).add(i):He.fromBytes(a)).toBytes()),s={};for(let a in r.verifyingShares)s[a]=He.fromBytes(r.verifyingShares[a]).add(i).toBytes();return{signers:{min:r.signers.min,max:r.signers.max},commitments:o,verifyingShares:s}}var Wf,OM,Dd,FS,kr,He,TM,qS,fa,KS,un,$o,BM,NM,MM,jS,kM,Fd,CM,DM,XS=Wt(()=>{p();gd();An();Kf();RS();AS();zi();US();oi();Wf={p:BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),n:BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),h:BigInt(1),a:BigInt(0),b:BigInt(7),Gx:BigInt("0x79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"),Gy:BigInt("0x483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8")},OM={beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),basises:[[BigInt("0x3086d221a7d46bcde86c90e49284eb15"),-BigInt("0xe4437ed6010e88286f547fa90abfe4c3")],[BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),BigInt("0x3086d221a7d46bcde86c90e49284eb15")]]},Dd=BigInt(0),FS=BigInt(2);kr=Wo(Wf.p,{sqrt:RM}),He=kS(Wf,{Fp:kr,endo:OM}),TM=DS(He,ri),qS=Object.create(null);fa=e=>e.toBytes(!0).slice(1),KS=({x:e})=>kr.toBytes(e),un=e=>!kr.isOdd(e);$o=Mt;BM=Object.freeze({lift_x:zf,frostTweakPublic:$S,frostTweakSecret:YS}),NM=(()=>{let r=n=>(n=n===void 0?na(48):n,Wi(Se(n,48,"seed"),Wf.n));return Object.freeze({keygen:jf(r,HS),getPublicKey:HS,sign:PM,verify:VS,Point:He,utils:Object.freeze({randomSecretKey:r,taggedHash:ua,lift_x:zf,pointToBytes:fa}),lengths:Object.freeze({secretKey:32,publicKey:32,publicKeyHasPrefix:!1,signature:64,seed:48})})})(),MM=ES(kr,[["0x8e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38daaaaa8c7","0x7d3d4c80bc321d5b9f315cea7fd44c5d595d2fc0bf63b92dfff1044f17c6581","0x534c328d23f234e6e2a413deca25caece4506144037c40314ecbd0b53d9dd262","0x8e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38daaaaa88c"],["0xd35771193d94918a9ca34ccbb7b640dd86cd409542f8487d9fe6b745781eb49b","0xedadc6f64383dc1df7c4b2d51b54225406d36b641f5e41bbc52a56612a8c6d14","0x0000000000000000000000000000000000000000000000000000000000000001"],["0x4bda12f684bda12f684bda12f684bda12f684bda12f684bda12f684b8e38e23c","0xc75e0c32d5cb7c0fa9d0a54b12a0a6d5647ab046d686da6fdffc90fc201d71a3","0x29a6194691f91a73715209ef6512e576722830a201be2018a765e85a9ecee931","0x2f684bda12f684bda12f684bda12f684bda12f684bda12f684bda12f38e38d84"],["0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffff93b","0x7a06534bb8bdb49fd5e9e6632722c2989467c1bfc8e8d978dfb425d2685c2573","0x6484aa716545ca2cf3a70c3fa8fe337e0a3d21162f0d6299a7bf8192bfd2a76f","0x0000000000000000000000000000000000000000000000000000000000000001"]].map(e=>e.map(t=>BigInt(t)))),kM=()=>jS||(jS=IS(kr,{A:BigInt("0x3f8731abdd661adca08a5558f0f5d272e953d363cb6f0e5d405447c01a444533"),B:BigInt("1771"),Z:kr.create(BigInt("-11"))})),Fd=xS(He,e=>{let{x:t,y:r}=kM()(kr.create(e[0]));return MM(t,r)},{DST:"secp256k1_XMD:SHA-256_SSWU_RO_",encodeDST:"secp256k1_XMD:SHA-256_SSWU_NU_",p:kr.ORDER,m:1,k:128,expand:"xmd",hash:ri}),CM=Bd({name:"FROST-secp256k1-SHA256-v1",Point:He,hashToScalar:Fd.hashToScalar,hash:ri});DM=Bd({name:"FROST-secp256k1-SHA256-TR-v1",Point:He,hashToScalar:Fd.hashToScalar,hash:ri,parsePublicKey(e){if(e.length===32)return zf(Mt(e));if(e.length===33)return He.fromBytes(e);throw new Error(`expected x-only or compressed public key, got length=${e.length}`)},adjustScalar(e){let t=He.BASE.multiply(e);return un(t.y)?e:He.Fn.neg(e)},adjustPoint:e=>un(e.y)?e:e.negate(),challenge(e,t,r){return Ud(fa(e),fa(t),r)},adjustNonces:LM,adjustGroupCommitmentShare:(e,t)=>un(e.y)?t:t.negate(),adjustPublic:qd,adjustSecret:zS,adjustTx:{encode:e=>e.subarray(1),decode:e=>Ce(Uint8Array.of(2),e)},adjustDKG:e=>{let t=new Uint8Array(0);return{public:$S(e.public,t),secret:YS(e.secret,e.public,t)}}})});var fi=B((xF,tw)=>{"use strict";p();var JS=wr(),{secp256k1:UM}=(XS(),fl(ZS)),la=UM.Point,Yf=la.Fn.ORDER;function FM(e){return BigInt("0x"+(e.toString(16)||"0"))}function Hd(e){var t=e.toString(16);return t.length%2&&(t="0"+t),new JS(t,16)}function $f(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 FM(e);throw new Error("Invalid Point")}function ca(e){var t=Object.create(je.prototype);return t._p=e,t}function QS(e,t){var r=$f(t).toString(16).padStart(64,"0");return la.fromHex((e?"03":"02")+r)}function ew(e,t){var r;try{r=QS((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 je(e,t,r){if(!(this instanceof je))return new je(e,t,r);var n,i;try{n=$f(e),i=$f(t)}catch{throw new Error("Invalid Point")}ew(n,i);try{this._p=la.fromAffine({x:n,y:i})}catch{throw new Error("Invalid Point")}return this}je.fromX=function(t,r){try{var n=ca(QS(t,r))}catch{throw new Error("Invalid X")}return n.validate(),n};je.getG=function(){return ca(la.BASE)};je.getN=function(){return Hd(Yf)};je.prototype.getX=function(){return Hd(this._p.toAffine().x)};je.prototype.getY=function(){return Hd(this._p.toAffine().y)};Object.defineProperty(je.prototype,"x",{configurable:!0,enumerable:!0,get:function(){return this.getX()}});Object.defineProperty(je.prototype,"y",{configurable:!0,enumerable:!0,get:function(){return this.getY()}});je.prototype.mul=function(t){var r=($f(t)%Yf+Yf)%Yf;return r===0n||this._p.is0()?ca(la.ZERO):ca(this._p.multiply(r))};je.prototype.add=function(t){return ca(this._p.add(t._p))};je.prototype.mulAdd=function(t,r,n){return this.mul(t).add(r.mul(n))};je.prototype.eq=function(t){return this._p.equals(t._p)};je.prototype.isInfinity=function(){return this._p.is0()};je.prototype.validate=function(){if(this.isInfinity())throw new Error("Point cannot be equal to Infinity");var t=this._p.toAffine();return ew(t.x,t.y),this};je.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])};je.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=JS.fromBuffer(e.slice(1,33));return je.fromX(r,n)};je.prototype.toBuffer=function(){return je.pointToCompressed(this)};je.prototype.toHex=function(){return this.toBuffer().toString("hex")};je.fromBuffer=function(e){return je.pointFromCompressed(e)};je.fromHex=function(e){return je.fromBuffer(d.Buffer.from(e,"hex"))};tw.exports=je});var nw=B((AF,rw)=>{"use strict";p();var Zf=Js(),Bn=Le(),Rt=rw.exports;Rt.sha1=function(e){return Bn.checkArgument(d.Buffer.isBuffer(e)),Zf.createHash("sha1").update(e).digest()};Rt.sha1.blocksize=512;Rt.sha256=function(e){return Bn.checkArgument(d.Buffer.isBuffer(e)),Zf.createHash("sha256").update(e).digest()};Rt.sha256.blocksize=512;Rt.sha256sha256=function(e){return Bn.checkArgument(d.Buffer.isBuffer(e)),Rt.sha256(Rt.sha256(e))};Rt.ripemd160=function(e){return Bn.checkArgument(d.Buffer.isBuffer(e)),Zf.createHash("ripemd160").update(e).digest()};Rt.sha256ripemd160=function(e){return Bn.checkArgument(d.Buffer.isBuffer(e)),Rt.ripemd160(Rt.sha256(e))};Rt.sha512=function(e){return Bn.checkArgument(d.Buffer.isBuffer(e)),Zf.createHash("sha512").update(e).digest()};Rt.sha512.blocksize=1024;Rt.hmac=function(e,t,r){Bn.checkArgument(d.Buffer.isBuffer(t)),Bn.checkArgument(d.Buffer.isBuffer(r)),Bn.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),f=d.Buffer.alloc(n),l=0;l<n;l++)a[l]=o[l]^r[l],f[l]=s[l]^r[l];return e(d.Buffer.concat([a,e(d.Buffer.concat([f,t]))]))};Rt.sha256hmac=function(e,t){return Rt.hmac(Rt.sha256,e,t)};Rt.sha512hmac=function(e,t){return Rt.hmac(Rt.sha512,e,t)}});var cw={};ul(cw,{_MD5:()=>ec,_RIPEMD160:()=>tc,_SHA1:()=>Qf,md5:()=>GM,ripemd160:()=>XM,sha1:()=>qM});function iw(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 Zo,ci,Qf,qM,HM,jM,Xf,jd,KM,ec,GM,VM,ow,WM,sw,aw,uw,fw,zM,YM,$M,ZM,Jf,tc,XM,lw=Wt(()=>{p();pd();An();Zo=Uint32Array.from([1732584193,4023233417,2562383102,271733878,3285377520]),ci=new Uint32Array(80),Qf=class extends On{constructor(){super(64,20,8,!1);Z(this,"A",Zo[0]|0);Z(this,"B",Zo[1]|0);Z(this,"C",Zo[2]|0);Z(this,"D",Zo[3]|0);Z(this,"E",Zo[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}_cloneInto(r){return(r||(r=new this.constructor)).set(...this.get()),this._cloneIntoMeta(r)}process(r,n){for(let l=0;l<16;l++,n+=4)ci[l]=r.getUint32(n,!1);for(let l=16;l<80;l++)ci[l]=xn(ci[l-3]^ci[l-8]^ci[l-14]^ci[l-16],1);let{A:i,B:o,C:s,D:a,E:f}=this;for(let l=0;l<80;l++){let y,g;l<20?(y=Fo(o,s,a),g=1518500249):l<40?(y=o^s^a,g=1859775393):l<60?(y=Rf(o,s,a),g=2400959708):(y=o^s^a,g=3395469782);let v=xn(i,5)+y+f+g+ci[l]|0;f=a,a=s,s=xn(o,30),o=i,i=v}i=i+this.A|0,o=o+this.B|0,s=s+this.C|0,a=a+this.D|0,f=f+this.E|0,this.set(i,o,s,a,f)}roundClean(){ar(ci)}destroy(){this.destroyed=!0,this.set(0,0,0,0,0),ar(this.buffer)}},qM=Mr(()=>new Qf),HM=Math.pow(2,32),jM=Array.from({length:64},(e,t)=>Math.floor(HM*Math.abs(Math.sin(t+1)))),Xf=Zo.slice(0,4),jd=new Uint32Array(16),KM=(()=>{let e=[[7,12,17,22],[5,9,14,20],[4,11,16,23],[6,10,15,21]];return Uint8Array.from({length:64},(t,r)=>e[Math.floor(r/16)][r%4])})(),ec=class extends On{constructor(){super(64,16,8,!0);Z(this,"A",Xf[0]|0);Z(this,"B",Xf[1]|0);Z(this,"C",Xf[2]|0);Z(this,"D",Xf[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}_cloneInto(r){return(r||(r=new this.constructor)).set(...this.get()),this._cloneIntoMeta(r)}process(r,n){for(let f=0;f<16;f++,n+=4)jd[f]=r.getUint32(n,!0);let{A:i,B:o,C:s,D:a}=this;for(let f=0;f<64;f++){let l,y;f<16?(l=Fo(o,s,a),y=f):f<32?(l=Fo(a,o,s),y=(5*f+1)%16):f<48?(l=o^s^a,y=(3*f+5)%16):(l=s^(o|~a),y=7*f%16),l=l+i+jM[f]+jd[y],i=a,a=s,s=o,o=o+xn(l,KM[f])}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(){ar(jd)}destroy(){this.destroyed=!0,this.set(0,0,0,0),ar(this.buffer)}},GM=Mr(()=>new ec),VM=Uint8Array.from([7,4,13,1,10,6,15,3,12,0,9,5,2,14,11,8]),ow=Uint8Array.from(new Array(16).fill(0).map((e,t)=>t)),WM=ow.map(e=>(9*e+5)%16),sw=(()=>{let r=[[ow],[WM]];for(let n=0;n<4;n++)for(let i of r)i.push(i[n].map(o=>VM[o]));return r})(),aw=sw[0],uw=sw[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)),zM=aw.map((e,t)=>e.map(r=>fw[t][r])),YM=uw.map((e,t)=>e.map(r=>fw[t][r])),$M=Uint32Array.from([0,1518500249,1859775393,2400959708,2840853838]),ZM=Uint32Array.from([1352829926,1548603684,1836072691,2053994217,0]);Jf=new Uint32Array(16),tc=class extends On{constructor(){super(64,20,8,!0);Z(this,"h0",1732584193);Z(this,"h1",-271733879);Z(this,"h2",-1732584194);Z(this,"h3",271733878);Z(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}_cloneInto(r){return(r||(r=new this.constructor)).set(...this.get()),this._cloneIntoMeta(r)}process(r,n){for(let T=0;T<16;T++,n+=4)Jf[T]=r.getUint32(n,!0);let i=this.h0|0,o=i,s=this.h1|0,a=s,f=this.h2|0,l=f,y=this.h3|0,g=y,v=this.h4|0,E=v;for(let T=0;T<5;T++){let M=4-T,U=$M[T],F=ZM[T],V=aw[T],z=uw[T],G=zM[T],ie=YM[T];for(let ee=0;ee<16;ee++){let pe=xn(i+iw(T,s,f,y)+Jf[V[ee]]+U,G[ee])+v|0;i=v,v=y,y=xn(f,10)|0,f=s,s=pe}for(let ee=0;ee<16;ee++){let pe=xn(o+iw(M,a,l,g)+Jf[z[ee]]+F,ie[ee])+E|0;o=E,E=g,g=xn(l,10)|0,l=a,a=pe}}this.set(this.h1+f+g|0,this.h2+y+E|0,this.h3+v+o|0,this.h4+i+a|0,this.h0+s+l|0)}roundClean(){ar(Jf)}destroy(){this.destroyed=!0,ar(this.buffer),this.set(0,0,0,0,0)}},XM=Mr(()=>new tc)});var dw=B((NF,hw)=>{"use strict";p();var{sha256:JM,sha512:QM}=(gd(),fl(Y_)),{sha1:ek,ripemd160:tk}=(lw(),fl(cw)),Nn=Le(),Tt=hw.exports;Tt.sha1=function(e){return Nn.checkArgument(d.Buffer.isBuffer(e)),d.Buffer.from(ek(e))};Tt.sha1.blocksize=512;Tt.sha256=function(e){return Nn.checkArgument(d.Buffer.isBuffer(e)),d.Buffer.from(JM(e))};Tt.sha256.blocksize=512;Tt.sha256sha256=function(e){return Nn.checkArgument(d.Buffer.isBuffer(e)),Tt.sha256(Tt.sha256(e))};Tt.ripemd160=function(e){return Nn.checkArgument(d.Buffer.isBuffer(e)),d.Buffer.from(tk(e))};Tt.sha256ripemd160=function(e){return Nn.checkArgument(d.Buffer.isBuffer(e)),Tt.ripemd160(Tt.sha256(e))};Tt.sha512=function(e){return Nn.checkArgument(d.Buffer.isBuffer(e)),d.Buffer.from(QM(e))};Tt.sha512.blocksize=1024;Tt.hmac=function(e,t,r){Nn.checkArgument(d.Buffer.isBuffer(t)),Nn.checkArgument(d.Buffer.isBuffer(r)),Nn.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),f=d.Buffer.alloc(n),l=0;l<n;l++)a[l]=o[l]^r[l],f[l]=s[l]^r[l];return e(d.Buffer.concat([a,e(d.Buffer.concat([f,t]))]))};Tt.sha256hmac=function(e,t){return Tt.hmac(Tt.sha256,e,t)};Tt.sha512hmac=function(e,t){return Tt.hmac(Tt.sha512,e,t)}});var Jt=B((kF,gw)=>{"use strict";p();var pw={sha1:"a9993e364706816aba3e25717850c26c9cd0d89d",sha256:"ba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad",sha512:"ddaf35a193617abacc417349ae20413112e6fa4e89a97ea20a9eeee64b55d39a2192992a274fc1a836ba3c23a3feebbd454d4423643ce80e2a9ac94fa54ca49f",ripemd160:"8eb208f7e05d987a9b044a8e98c6b087f15a0bfc"};function rk(){var e;try{e=Js()}catch{return!1}if(!e||typeof e.createHash!="function")return!1;for(var t=Object.keys(pw),r=0;r<t.length;r++){var n=t[r];try{if(e.createHash(n).update("abc").digest("hex")!==pw[n])return!1}catch{return!1}}return!0}gw.exports=rk()?nw():dw()});var pr=B((LF,vw)=>{"use strict";p();var mw=ze(),nk=Le(),yw=function(t){return mw.isString(t)?/^[0-9a-fA-F]+$/.test(t):!1};vw.exports={isValidJSON:function(t){var r;if(!mw.isString(t))return!1;try{r=JSON.parse(t)}catch{return!1}return typeof r=="object"},isHexa:yw,isHexaString:yw,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){nk.checkArgumentType(t,"number","integer");let r=d.Buffer.allocUnsafe(4);return r.writeUInt32BE(t,0),r}}});var ya=B((UF,Sw)=>{"use strict";p();var Mn=ze(),ha=pr(),Xi=[],da={};function bw(){}bw.prototype.toString=function(){return this.name};function pa(e,t){if(~Xi.indexOf(e))return e;if(t){Mn.isArray(t)||(t=[t]);for(var r=0;r<Xi.length;r++){var n=Xi[r],i=Mn.pick(n,t),o=Mn.values(i);if(~o.indexOf(e))return n}return}return da[e]}function rc(e){for(var t=[],r=0;r<e.length;r++)t.push(e.charCodeAt(r)&31);return t}function ga(e){var t=new bw;ha.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&&Mn.extend(t,{cashAddrPrefix:e.cashAddrPrefix,cashAddrPrefixArray:rc(e.cashAddrPrefix)}),e.networkMagic&&Mn.extend(t,{networkMagic:ha.integerAsBuffer(e.networkMagic)}),e.port&&Mn.extend(t,{port:e.port}),e.dnsSeeds&&Mn.extend(t,{dnsSeeds:e.dnsSeeds}),Xi.push(t),ik(t,r),t}function ik(e,t){for(var r=0;r<t.length;r++){var n=t[r],i=e[n];!Mn.isUndefined(i)&&!Mn.isObject(i)&&(da[i]=e)}}function ok(e,t){for(var r=0;r<t.length;r++){var n=t[r];da[n]===e&&delete da[n]}}function sk(e){for(var t=0;t<Xi.length;t++)Xi[t]===e&&Xi.splice(t,1);ok(e,Object.keys(da))}var nc={livenet:3823236072,testnet:4108710900,regtest:3669344250,stn:4224632057},_w=["seed.bitcoinsv.org","seed.bitcoinunlimited.info"],li={PORT:18333,NETWORK_MAGIC:nc.testnet,DNS_SEEDS:_w,PREFIX:"testnet",CASHADDRPREFIX:"bchtest"},kn={PORT:18444,NETWORK_MAGIC:nc.regtest,DNS_SEEDS:[],PREFIX:"regtest",CASHADDRPREFIX:"bchreg"},hi={PORT:9333,NETWORK_MAGIC:nc.stn,DNS_SEEDS:["stn-seed.bitcoinsv.io"],PREFIX:"stn",CASHADDRPREFIX:"bsvstn"},ak={name:"livenet",alias:"mainnet",prefix:"bitcoin",cashAddrPrefix:"bitcoincash",pubkeyhash:0,privatekey:128,scripthash:5,xpubkey:76067358,xprivkey:76066276,networkMagic:nc.livenet,port:8333,dnsSeeds:_w},uk={name:"testnet",prefix:li.PREFIX,cashAddrPrefix:li.CASHADDRPREFIX,pubkeyhash:111,privatekey:239,scripthash:196,xpubkey:70617039,xprivkey:70615956,networkMagic:li.NETWORK_MAGIC},fk={name:"regtest",prefix:kn.PREFIX,cashAddrPrefix:kn.CASHADDRPREFIX,pubkeyhash:111,privatekey:239,scripthash:196,xpubkey:70617039,xprivkey:70615956,networkMagic:kn.NETWORK_MAGIC,port:kn.PORT,dnsSeeds:[],indexBy:["port","name","cashAddrPrefix","networkMagic"]},ck={name:"stn",prefix:hi.PREFIX,cashAddrPrefix:hi.CASHADDRPREFIX,pubkeyhash:111,privatekey:239,scripthash:196,xpubkey:70617039,xprivkey:70615956,networkMagic:hi.NETWORK_MAGIC,indexBy:["port","name","cashAddrPrefix","networkMagic"]};ga(uk);ga(ck);ga(fk);ga(ak);var Kd=pa("livenet"),lk=pa("regtest"),fn=pa("testnet"),hk=pa("stn");Object.defineProperty(fn,"port",{enumerable:!0,configurable:!1,get:function(){return this.regtestEnabled?kn.PORT:this.stnEnabled?hi.PORT:li.PORT}});Object.defineProperty(fn,"networkMagic",{enumerable:!0,configurable:!1,get:function(){return this.regtestEnabled?ha.integerAsBuffer(kn.NETWORK_MAGIC):this.stnEnabled?ha.integerAsBuffer(hi.NETWORK_MAGIC):ha.integerAsBuffer(li.NETWORK_MAGIC)}});Object.defineProperty(fn,"dnsSeeds",{enumerable:!0,configurable:!1,get:function(){return this.regtestEnabled?kn.DNS_SEEDS:this.stnEnabled?hi.DNS_SEEDS:li.DNS_SEEDS}});Object.defineProperty(fn,"cashAddrPrefix",{enumerable:!0,configurable:!1,get:function(){return this.regtestEnabled?kn.CASHADDRPREFIX:this.stnEnabled?hi.CASHADDRPREFIX:li.CASHADDRPREFIX}});Object.defineProperty(fn,"cashAddrPrefixArray",{enumerable:!0,configurable:!1,get:function(){return this.regtestEnabled?rc(kn.CASHADDRPREFIX):this.stnEnabled?rc(hi.CASHADDRPREFIX):rc(li.CASHADDRPREFIX)}});function dk(){fn.regtestEnabled=!0}function pk(){fn.regtestEnabled=!1}function gk(){fn.stnEnabled=!0}function yk(){fn.stnEnabled=!1}Sw.exports={add:ga,remove:sk,defaultNetwork:Kd,livenet:Kd,mainnet:Kd,testnet:fn,regtest:lk,stn:hk,get:pa,enableRegtest:dk,disableRegtest:pk,enableStn:gk,disableStn:yk}});var Iw=B((qF,xw)=>{"use strict";p();var Gd=ze(),ww=Nt(),Xo="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz".split(""),Ew={};for(ma=0;ma<Xo.length;ma++)Ew[Xo[ma]]=ma;var ma;function mk(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+=Xo[0];for(r=t.length-1;r>=0;r--)o+=Xo[t[r]];return o}function vk(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=Ew[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]===Xo[0]&&r<e.length-1;r++)t.push(0);return d.Buffer.from(t.reverse())}var Ht=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)}};Ht.validCharacters=function(t){return ww.Buffer.isBuffer(t)&&(t=t.toString()),Gd.every(Gd.map(t,function(r){return Gd.includes(Xo,r)}))};Ht.prototype.set=function(e){return this.buf=e.buf||this.buf||void 0,this};Ht.encode=function(e){if(!ww.Buffer.isBuffer(e))throw new Error("Input should be a buffer");return mk(e)};Ht.decode=function(e){if(typeof e!="string")throw new Error("Input should be a string");return vk(e)};Ht.prototype.fromBuffer=function(e){return this.buf=e,this};Ht.fromBuffer=function(e){return new Ht().fromBuffer(e)};Ht.fromHex=function(e){return Ht.fromBuffer(d.Buffer.from(e,"hex"))};Ht.prototype.fromString=function(e){var t=Ht.decode(e);return this.buf=t,this};Ht.fromString=function(e){return new Ht().fromString(e)};Ht.prototype.toBuffer=function(){return this.buf};Ht.prototype.toHex=function(){return this.toBuffer().toString("hex")};Ht.prototype.toString=function(){return Ht.encode(this.buf)};xw.exports=Ht});var Vd=B((jF,Tw)=>{"use strict";p();var Aw=ze(),ic=Iw(),Ow=Nt(),Rw=Jt().sha256sha256,et=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)}};et.prototype.set=function(e){return this.buf=e.buf||this.buf||void 0,this};et.validChecksum=function(t,r){return Aw.isString(t)&&(t=Ow.Buffer.from(ic.decode(t))),Aw.isString(r)&&(r=Ow.Buffer.from(ic.decode(r))),r||(r=t.slice(-4),t=t.slice(0,-4)),et.checksum(t).toString("hex")===r.toString("hex")};et.decode=function(e){if(typeof e!="string")throw new Error("Input must be a string");var t=d.Buffer.from(ic.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};et.checksum=function(e){return Rw(e).slice(0,4)};et.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=et.checksum(e);return e.copy(t),r.copy(t,e.length),ic.encode(t)};et.prototype.fromBuffer=function(e){return this.buf=e,this};et.fromBuffer=function(e){return new et().fromBuffer(e)};et.fromHex=function(e){return et.fromBuffer(d.Buffer.from(e,"hex"))};et.prototype.fromString=function(e){var t=et.decode(e);return this.buf=t,this};et.fromString=function(e){var t=et.decode(e);return new et(t)};et.prototype.toBuffer=function(){return this.buf};et.prototype.toHex=function(){return this.toBuffer().toString("hex")};et.prototype.toString=function(){return et.encode(this.buf)};Tw.exports=et});var Yd=B((GF,Mw)=>{"use strict";p();function di(e){"@babel/helpers - typeof";return di=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},di(e)}function Pw(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,_k(n.key),n)}}function bk(e,t,r){return t&&Pw(e.prototype,t),r&&Pw(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e}function _k(e){var t=Sk(e,"string");return di(t)==="symbol"?t:String(t)}function Sk(e,t){if(di(e)!=="object"||e===null)return e;var r=e[Symbol.toPrimitive];if(r!==void 0){var n=r.call(e,t||"default");if(di(n)!=="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}function wk(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function Ek(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&&zd(e,t)}function zd(e,t){return zd=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(n,i){return n.__proto__=i,n},zd(e,t)}function xk(e){var t=Ok();return function(){var n=oc(e),i;if(t){var o=oc(this).constructor;i=Reflect.construct(n,arguments,o)}else i=n.apply(this,arguments);return Ik(this,i)}}function Ik(e,t){if(t&&(di(t)==="object"||typeof t=="function"))return t;if(t!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return Ak(e)}function Ak(e){if(e===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function Ok(){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 oc(e){return oc=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(r){return r.__proto__||Object.getPrototypeOf(r)},oc(e)}var Nw={},Jo,Wd;function va(e,t,r){r||(r=Error);function n(o,s,a){return typeof t=="string"?t:t(o,s,a)}var i=(function(o){Ek(a,o);var s=xk(a);function a(f,l,y){var g;return wk(this,a),g=s.call(this,n(f,l,y)),g.code=e,g}return bk(a)})(r);Nw[e]=i}function Bw(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 Rk(e,t,r){return e.substr(!r||r<0?0:+r,t.length)===t}function Tk(e,t,r){return(r===void 0||r>e.length)&&(r=e.length),e.substring(r-t.length,r)===t}function Pk(e,t,r){return typeof r!="number"&&(r=0),r+t.length>e.length?!1:e.indexOf(t,r)!==-1}va("ERR_AMBIGUOUS_ARGUMENT",'The "%s" argument is ambiguous. %s',TypeError);va("ERR_INVALID_ARG_TYPE",function(e,t,r){Jo===void 0&&(Jo=ba()),Jo(typeof e=="string","'name' must be a string");var n;typeof t=="string"&&Rk(t,"not ")?(n="must not be",t=t.replace(/^not /,"")):n="must be";var i;if(Tk(e," argument"))i="The ".concat(e," ").concat(n," ").concat(Bw(t,"type"));else{var o=Pk(e,".")?"property":"argument";i='The "'.concat(e,'" ').concat(o," ").concat(n," ").concat(Bw(t,"type"))}return i+=". Received type ".concat(di(r)),i},TypeError);va("ERR_INVALID_ARG_VALUE",function(e,t){var r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:"is invalid";Wd===void 0&&(Wd=Xr());var n=Wd.inspect(t);return n.length>128&&(n="".concat(n.slice(0,128),"...")),"The argument '".concat(e,"' ").concat(r,". Received ").concat(n)},TypeError,RangeError);va("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(di(r)),"Expected ".concat(e,' to be returned from the "').concat(t,'"')+" function but got ".concat(n,".")},TypeError);va("ERR_MISSING_ARGS",function(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];Jo===void 0&&(Jo=ba()),Jo(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);Mw.exports.codes=Nw});var Kw=B((WF,jw)=>{"use strict";p();function kw(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 Cw(e){for(var t=1;t<arguments.length;t++){var r=arguments[t]!=null?arguments[t]:{};t%2?kw(Object(r),!0).forEach(function(n){Bk(e,n,r[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):kw(Object(r)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(r,n))})}return e}function Bk(e,t,r){return t=Fw(t),t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function Nk(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function Lw(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,Fw(n.key),n)}}function Mk(e,t,r){return t&&Lw(e.prototype,t),r&&Lw(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e}function Fw(e){var t=kk(e,"string");return ur(t)==="symbol"?t:String(t)}function kk(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 Ck(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 Lk(e){var t=Hw();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 qw(this,i)}}function qw(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 $d(e)}function $d(e){if(e===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function Zd(e){var t=typeof Map=="function"?new Map:void 0;return Zd=function(n){if(n===null||!Dk(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)},Zd(e)}function sc(e,t,r){return Hw()?sc=Reflect.construct.bind():sc=function(i,o,s){var a=[null];a.push.apply(a,o);var f=Function.bind.apply(i,a),l=new f;return s&&Ea(l,s.prototype),l},sc.apply(null,arguments)}function Hw(){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 Dk(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 Uk=Xr(),Xd=Uk.inspect,Fk=Yd(),qk=Fk.codes.ERR_INVALID_ARG_TYPE;function Dw(e,t,r){return(r===void 0||r>e.length)&&(r=e.length),e.substring(r-t.length,r)===t}function Hk(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 Cr="",_a="",Sa="",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:"},jk=10;function Uw(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 wa(e){return Xd(e,{compact:!1,customInspect:!1,depth:1e3,maxArrayLength:1/0,showHidden:!1,breakLength:1/0,showProxy:!1,sorted:!0,getters:!0})}function Kk(e,t,r){var n="",i="",o=0,s="",a=!1,f=wa(e),l=f.split(`
|
|
@@ -71,5 +71,5 @@ The flags passed to verify() (0x`+(e>>>0).toString(16)+`) carry no era bit, so t
|
|
|
71
71
|
To validate against BSV as it is today, omit the flags argument or pass Interpreter.mainnetFlags(). If you are deliberately testing pre-Genesis consensus this failure is correct \u2014 set Interpreter.eraDiagnostics = false (or BSV_NO_ERA_HINT=1) to silence this.`,P.eraDiagnostics&&!kp&&(kp=!0,console.warn(`
|
|
72
72
|
[@smartledger/bsv] `+this.eraHint+`
|
|
73
73
|
(shown once per process)
|
|
74
|
-
`))}}};P.prototype.verify=function(e,t,r,n,i,o){this.eraHint=null;var s=this._verifyCore(e,t,r,n,i,o);return s||this._eraDiagnose(i),s};P._resetEraWarning=function(){kp=!1};P.mainnetFlags=function(e){e=e||{};var t=P.SCRIPT_VERIFY_P2SH|P.SCRIPT_VERIFY_STRICTENC|P.SCRIPT_VERIFY_DERSIG|P.SCRIPT_VERIFY_SIGPUSHONLY|P.SCRIPT_VERIFY_LOW_S|P.SCRIPT_VERIFY_NULLFAIL|P.SCRIPT_VERIFY_MINIMALDATA|P.SCRIPT_ENABLE_SIGHASH_FORKID|P.SCRIPT_ENABLE_MAGNETIC_OPCODES|P.SCRIPT_ENABLE_MONOLITH_OPCODES|P.SCRIPT_GENESIS|P.SCRIPT_UTXO_AFTER_GENESIS;return e.afterChronicle!==!1&&(t|=P.SCRIPT_ENABLE_CHRONICLE|P.SCRIPT_UTXO_AFTER_CHRONICLE),t};P.currentConsensusFlags=function(){return P.SCRIPT_ENABLE_MONOLITH_OPCODES|P.SCRIPT_ENABLE_MAGNETIC_OPCODES|P.SCRIPT_GENESIS|P.SCRIPT_UTXO_AFTER_GENESIS|P.SCRIPT_ENABLE_CHRONICLE|P.SCRIPT_UTXO_AFTER_CHRONICLE|P.SCRIPT_ENABLE_SIGHASH_FORKID|P.SCRIPT_VERIFY_SIGPUSHONLY|P.SCRIPT_VERIFY_LOW_S|P.SCRIPT_VERIFY_NULLFAIL};P.useMainnetConsensus=function(e){return e=e||{},P.useGenesisLimits(e.max),P.mainnetFlags(e)};P.SEQUENCE_LOCKTIME_DISABLE_FLAG=1<<31;P.SEQUENCE_LOCKTIME_TYPE_FLAG=1<<22;P.SEQUENCE_LOCKTIME_MASK=65535;P.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};function Ox(e,t){return(e&P.SCRIPT_CHRONICLE)===0?!0:!(t&&(t.version|0)>1)}P.prototype.enforceNonMalleability=function(){return Ox(this.flags,this.tx)};P.prototype.checkSignatureEncoding=function(e){var t;if(e.length===0)return!0;if((this.flags&(P.SCRIPT_VERIFY_DERSIG|P.SCRIPT_VERIFY_LOW_S|P.SCRIPT_VERIFY_STRICTENC))!==0&&!qn.isTxDER(e))return this.errstr="SCRIPT_ERR_SIG_DER_INVALID_FORMAT",!1;if((this.flags&P.SCRIPT_VERIFY_LOW_S)!==0&&(t=qn.fromTxFormat(e),!t.hasLowS()&&this.enforceNonMalleability()))return this.errstr="SCRIPT_ERR_SIG_DER_HIGH_S",!1;if((this.flags&P.SCRIPT_VERIFY_STRICTENC)!==0){if(t=qn.fromTxFormat(e),!t.hasDefinedHashtype())return this.errstr="SCRIPT_ERR_SIG_HASHTYPE",!1;if(!(this.flags&P.SCRIPT_ENABLE_SIGHASH_FORKID)&&t.nhashtype&qn.SIGHASH_FORKID)return this.errstr="SCRIPT_ERR_ILLEGAL_FORKID",!1;if(!(this.flags&P.SCRIPT_CHRONICLE)&&t.nhashtype&qn.SIGHASH_CHRONICLE)return this.errstr="SCRIPT_ERR_ILLEGAL_CHRONICLE",!1;if(this.flags&P.SCRIPT_ENABLE_SIGHASH_FORKID&&!(t.nhashtype&qn.SIGHASH_FORKID))return this.errstr="SCRIPT_ERR_MUST_USE_FORKID",!1}return!0};function Ix(e,t,r){var n=t.length?t[t.length-1]:0;return(!(r&P.SCRIPT_ENABLE_SIGHASH_FORKID)||!(n&qn.SIGHASH_FORKID))&&e.findAndDelete(new Uc().add(t)),e}P.prototype.checkPubkeyEncoding=function(e){return(this.flags&P.SCRIPT_VERIFY_STRICTENC)!==0&&!Mp.isValid(e)?(this.errstr="SCRIPT_ERR_PUBKEYTYPE",!1):!0};P.prototype.isAfterGenesis=function(){return(this.flags&P.SCRIPT_UTXO_AFTER_GENESIS)!==0};P.prototype.isAfterChronicle=function(){return(this.flags&(P.SCRIPT_UTXO_AFTER_CHRONICLE|P.SCRIPT_ENABLE_CHRONICLE))!==0};P.prototype.maxScriptElementSize=function(){return this.isAfterGenesis()?P.UNLIMITED:P.MAX_SCRIPT_ELEMENT_SIZE};P.prototype.maxScriptSize=function(){return this.isAfterGenesis()?P.UNLIMITED:P.MAX_SCRIPT_SIZE};P.prototype.maxOpsPerScript=function(){return this.isAfterGenesis()?P.UNLIMITED:P.MAX_OPS_PER_SCRIPT};P.prototype.maxScriptNumLength=function(){return this.isAfterChronicle()?P.MAX_SCRIPT_NUM_LENGTH_AFTER_CHRONICLE:this.isAfterGenesis()?P.MAX_SCRIPT_NUM_LENGTH_AFTER_GENESIS:P.MAXIMUM_ELEMENT_SIZE};P.prototype.maxStackSize=function(){return this.isAfterGenesis()?P.UNLIMITED:P.MAX_STACK_SIZE};P.prototype.maxStackMemoryUsage=function(){return this.isAfterGenesis()?P.MAX_STACK_MEMORY_USAGE_AFTER_GENESIS:P.UNLIMITED};P.prototype.stackMemoryUsage=function(){let e=P.STACK_ELEMENT_OVERHEAD,t=(this.stack.length+this.altstack.length)*e;for(let r=0;r<this.stack.length;r++)t+=this.stack[r].length;for(let r=0;r<this.altstack.length;r++)t+=this.altstack[r].length;return t};P.prototype.checkStackLimits=function(){if(this.stack.length+this.altstack.length>this.maxStackSize())return"SCRIPT_ERR_STACK_SIZE";let e=this.maxStackMemoryUsage();return e!==P.UNLIMITED&&this.stackMemoryUsage()>e?"SCRIPT_ERR_STACK_SIZE":null};P.prototype.maxPubKeysPerMultisig=function(){return this.isAfterGenesis()?P.MAX_PUBKEYS_PER_MULTISIG_AFTER_GENESIS:20};P._isMinimallyEncoded=function(e,t){return t=t||P.MAXIMUM_ELEMENT_SIZE,!(e.length>t||e.length>0&&(e[e.length-1]&127)===0&&(e.length<=1||(e[e.length-2]&128)===0))};P._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;e=d.Buffer.from(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("")};P.prototype.evaluate=function(){if(this.script.toBuffer().length>this.maxScriptSize())return this.errstr="SCRIPT_ERR_SCRIPT_SIZE",!1;try{for(;this.pc<this.script.chunks.length;){let r={pc:this.pc,opcode:N.fromNumber(this.script.chunks[this.pc].opcodenum)};var e=this.step();if(!e)return!1;if(this._callbackStep(r),this.returned)return!0;let n=this.checkStackLimits();if(n)return this.errstr=n,!1}let t=this.checkStackLimits();if(t)return this.errstr=t,!1}catch(t){return this.errstr=t.scriptErr||"SCRIPT_ERR_UNKNOWN_ERROR: "+t,!1}return this.vfExec.length>0?(this.errstr="SCRIPT_ERR_UNBALANCED_CONDITIONAL",!1):!0};P.prototype._callbackStep=function(e){if(typeof this.stepListener=="function")try{this.stepListener(e,xx(this.stack),xx(this.altstack))}catch(t){console.log(`Error in Step callback:${t}`)}};P.prototype.checkLockTime=function(e){if(!(this.tx.nLockTime<P.LOCKTIME_THRESHOLD&&e.lt(P.LOCKTIME_THRESHOLD_BN)||this.tx.nLockTime>=P.LOCKTIME_THRESHOLD&&e.gte(P.LOCKTIME_THRESHOLD_BN))||e.gt(new he(this.tx.nLockTime)))return!1;var t=this.tx.inputs[this.nin];return!(!t||t.isFinal())};P.prototype.checkSequence=function(e){var t=this.tx.inputs[this.nin];if(!t)return!1;var r=t.sequenceNumber;if(this.tx.version<2||r&P.SEQUENCE_LOCKTIME_DISABLE_FLAG)return!1;var n=P.SEQUENCE_LOCKTIME_TYPE_FLAG|P.SEQUENCE_LOCKTIME_MASK,i=new he(r&n),o=e.and(new he(n)),s=new he(P.SEQUENCE_LOCKTIME_TYPE_FLAG);return!(!(i.lt(s)&&o.lt(s)||i.gte(s)&&o.gte(s))||o.gt(i))};function hC(e,t){let r=e;for(;r.length<t;)r=d.Buffer.concat([d.Buffer.from([0]),r]);return r}function Ax(e){var t=d.Buffer.alloc(4);return t.writeInt32LE(e|0,0),t}P.prototype.step=function(){var e=this;function t(oe){return e.stack[e.stack.length+oe]}function r(oe){switch(oe){case N.OP_2MUL:case N.OP_2DIV:if(!e.isAfterChronicle())return!0;break;case N.OP_INVERT:case N.OP_MUL:case N.OP_LSHIFT:case N.OP_RSHIFT:if((e.flags&P.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&P.SCRIPT_VERIFY_MINIMALDATA)!==0&&this.enforceNonMalleability(),i,o,s,a,f,l,y,g,v,E,T,M,U,F,V,z,G,ie=this.script.chunks[this.pc];this.pc++;var ee=ie.opcodenum,pe=this.vfExec.indexOf(!1)===-1&&(!this.nonTopLevelReturnAfterGenesis||ee===N.OP_RETURN);if(Dc.isUndefined(ee))return this.errstr="SCRIPT_ERR_UNDEFINED_OPCODE",!1;if(ie.buf&&ie.buf.length>this.maxScriptElementSize())return this.errstr="SCRIPT_ERR_PUSH_SIZE",!1;if(ee>N.OP_16&&++this.nOpCount>this.maxOpsPerScript())return this.errstr="SCRIPT_ERR_OP_COUNT",!1;if(r(ee)&&(!this.isAfterGenesis()||pe))return this.errstr="SCRIPT_ERR_DISABLED_OPCODE",!1;if(pe&&ee>=0&&ee<=N.OP_PUSHDATA4){if(n&&!this.script.checkMinimalPush(this.pc-1))return this.errstr="SCRIPT_ERR_MINIMALDATA",!1;if(!ie.buf)this.stack.push(P.false);else{if(ie.len!==ie.buf.length)return this.errstr="SCRIPT_ERR_BAD_OPCODE",!1;this.stack.push(ie.buf)}}else if(pe||N.OP_IF<=ee&&ee<=N.OP_ENDIF)switch(ee){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:f=ee-(N.OP_1-1),i=new he(f).toScriptNumBuffer(),this.stack.push(i);break;case N.OP_NOP:break;case N.OP_NOP2:case N.OP_CHECKLOCKTIMEVERIFY:if(!(this.flags&P.SCRIPT_VERIFY_CHECKLOCKTIMEVERIFY)||this.isAfterGenesis()){if(this.flags&P.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 le=he.fromScriptNumBuffer(this.stack[this.stack.length-1],n,5);if(le.lt(new he(0)))return this.errstr="SCRIPT_ERR_NEGATIVE_LOCKTIME",!1;if(!this.checkLockTime(le))return this.errstr="SCRIPT_ERR_UNSATISFIED_LOCKTIME",!1;break;case N.OP_NOP3:case N.OP_CHECKSEQUENCEVERIFY:if(!(this.flags&P.SCRIPT_VERIFY_CHECKSEQUENCEVERIFY)||this.isAfterGenesis()){if(this.flags&P.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 me=he.fromScriptNumBuffer(t(-1),n,5);if(me.lt(new he(0)))return this.errstr="SCRIPT_ERR_NEGATIVE_LOCKTIME",!1;if((me&P.SEQUENCE_LOCKTIME_DISABLE_FLAG)!==0)break;if(!this.checkSequence(me))return this.errstr="SCRIPT_ERR_UNSATISFIED_LOCKTIME",!1;break;case N.OP_NOP1:case N.OP_NOP9:case N.OP_NOP10:if(this.flags&P.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.isAfterChronicle()){if(this.flags&P.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 I=this.maxScriptNumLength(),u=he.fromScriptNumBuffer(t(-1),n,I);if(u.isNeg())return this.errstr="SCRIPT_ERR_INVALID_NUMBER_RANGE",!1;this.stack.pop();var h=he.fromScriptNumBuffer(t(-1),n,I);this.stack.pop();var m=u.toNumber(),S=h.isNeg(),w=h.abs(),R;if(ee===N.OP_LSHIFTNUM){var A=h.toScriptNumBuffer().length;if(A+Math.floor(m/8)>I)return this.errstr="SCRIPT_ERR_SCRIPTNUM_OVERFLOW",!1;R=w.shln(m)}else R=m>=w.bitLength()?new he(0):w.shrn(m);if(S&&!R.isZero()&&(R=R.neg()),R.toScriptNumBuffer().length>I)return this.errstr="SCRIPT_ERR_SCRIPTNUM_OVERFLOW",!1;this.stack.push(R.toScriptNumBuffer());break;case N.OP_VER:if(!this.isAfterChronicle())return this.errstr="SCRIPT_ERR_BAD_OPCODE",!1;if(this.tx==null)return this.errstr="SCRIPT_ERR_UNKNOWN_ERROR",!1;this.stack.push(Ax(this.tx.version));break;case N.OP_VERIF:case N.OP_VERNOTIF:if(!this.isAfterChronicle()){if(this.isAfterGenesis()&&!pe)break;return this.errstr="SCRIPT_ERR_BAD_OPCODE",!1}if(z=!1,pe){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;i=t(-1),z=i.length===4&&i.equals(Ax(this.tx.version)),ee===N.OP_VERNOTIF&&(z=!z),this.stack.pop()}this.vfExec.push(z),this.vfElse.push(!1);break;case N.OP_IF:case N.OP_NOTIF:if(z=!1,pe){if(this.stack.length<1)return this.errstr="SCRIPT_ERR_UNBALANCED_CONDITIONAL",!1;if(i=t(-1),this.flags&P.SCRIPT_VERIFY_MINIMALIF&&(i.length>1||i.length===1&&i[0]!==1)&&this.enforceNonMalleability())return this.errstr="SCRIPT_ERR_MINIMALIF",!1;z=P.castToBool(i),ee===N.OP_NOTIF&&(z=!z),this.stack.pop()}this.vfExec.push(z),this.vfElse.push(!1);break;case N.OP_ELSE:if(this.vfExec.length===0||this.vfElse[this.vfElse.length-1]&&this.isAfterGenesis())return this.errstr="SCRIPT_ERR_UNBALANCED_CONDITIONAL",!1;this.vfExec[this.vfExec.length-1]=!this.vfExec[this.vfExec.length-1],this.vfElse[this.vfElse.length-1]=!0;break;case N.OP_ENDIF:if(this.vfExec.length===0)return this.errstr="SCRIPT_ERR_UNBALANCED_CONDITIONAL",!1;this.vfExec.pop(),this.vfElse.pop();break;case N.OP_VERIFY:if(this.stack.length<1)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;if(i=t(-1),z=P.castToBool(i),z)this.stack.pop();else return this.errstr="SCRIPT_ERR_VERIFY",!1;break;case N.OP_RETURN:if(this.isAfterGenesis()){if(this.vfExec.length===0){this.returned=!0;break}this.nonTopLevelReturnAfterGenesis=!0;break}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;o=t(-2),s=t(-1),this.stack.push(d.Buffer.from(o)),this.stack.push(d.Buffer.from(s));break;case N.OP_3DUP:if(this.stack.length<3)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;o=t(-3),s=t(-2);var _=t(-1);this.stack.push(d.Buffer.from(o)),this.stack.push(d.Buffer.from(s)),this.stack.push(d.Buffer.from(_));break;case N.OP_2OVER:if(this.stack.length<4)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;o=t(-4),s=t(-3),this.stack.push(d.Buffer.from(o)),this.stack.push(d.Buffer.from(s));break;case N.OP_2ROT:if(this.stack.length<6)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;a=this.stack.splice(this.stack.length-6,2),this.stack.push(a[0]),this.stack.push(a[1]);break;case N.OP_2SWAP:if(this.stack.length<4)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;a=this.stack.splice(this.stack.length-4,2),this.stack.push(a[0]),this.stack.push(a[1]);break;case N.OP_IFDUP:if(this.stack.length<1)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;i=t(-1),z=P.castToBool(i),z&&this.stack.push(d.Buffer.from(i));break;case N.OP_DEPTH:i=new he(this.stack.length).toScriptNumBuffer(),this.stack.push(i);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(i=t(-1),g=he.fromScriptNumBuffer(i,n,this.maxScriptNumLength()),f=g.toNumber(),this.stack.pop(),f<0||f>=this.stack.length)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;i=t(-f-1),ee===N.OP_ROLL&&this.stack.splice(this.stack.length-f-1,1),this.stack.push(d.Buffer.from(i));break;case N.OP_ROT:if(this.stack.length<3)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;l=t(-3),y=t(-2);var c=t(-1);this.stack[this.stack.length-3]=y,this.stack[this.stack.length-2]=c,this.stack[this.stack.length-1]=l;break;case N.OP_SWAP:if(this.stack.length<2)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;l=t(-2),y=t(-1),this.stack[this.stack.length-2]=y,this.stack[this.stack.length-1]=l;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;g=new he(t(-1).length),this.stack.push(g.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(o=t(-2),s=t(-1),o.length!==s.length)return this.errstr="SCRIPT_ERR_INVALID_OPERAND_SIZE",!1;switch(a=d.Buffer.alloc(o.length),ee){case N.OP_AND:for(let oe=0;oe<o.length;oe++)a[oe]=o[oe]&s[oe];break;case N.OP_OR:for(let oe=0;oe<o.length;oe++)a[oe]=o[oe]|s[oe];break;case N.OP_XOR:for(let oe=0;oe<o.length;oe++)a[oe]=o[oe]^s[oe];break;default:break}this.stack.pop(),this.stack[this.stack.length-1]=a;break;case N.OP_INVERT:if(this.stack.length<1)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;i=t(-1),o=d.Buffer.alloc(i.length);for(let oe=0;oe<i.length;oe++)o[oe]=~i[oe]&255;this.stack[this.stack.length-1]=o;break;case N.OP_LSHIFT:case N.OP_RSHIFT:if(this.stack.length<2)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;if(o=t(-2),o.length===0)this.stack.pop();else{if(v=new he(o),E=he.fromScriptNumBuffer(t(-1),n,this.maxScriptNumLength()),f=E.toNumber(),f<0)return this.errstr="SCRIPT_ERR_INVALID_NUMBER_RANGE",!1;this.stack.pop(),this.stack.pop();let oe;ee===N.OP_LSHIFT&&(oe=v.ushln(f)),ee===N.OP_RSHIFT&&(oe=v.ushrn(f));let Pe=hC(d.Buffer.from(oe.toArray().slice(o.length*-1)),o.length);this.stack.push(Pe)}break;case N.OP_EQUAL:case N.OP_EQUALVERIFY:if(this.stack.length<2)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;o=t(-2),s=t(-1);var b=o.toString("hex")===s.toString("hex");if(this.stack.pop(),this.stack.pop(),this.stack.push(b?P.true:P.false),ee===N.OP_EQUALVERIFY)if(b)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(i=t(-1),g=he.fromScriptNumBuffer(i,n,this.maxScriptNumLength()),ee){case N.OP_2MUL:g=g.mul(new he(2));break;case N.OP_2DIV:g=g.div(new he(2));break;case N.OP_1ADD:g=g.add(he.One);break;case N.OP_1SUB:g=g.sub(he.One);break;case N.OP_NEGATE:g=g.neg();break;case N.OP_ABS:g.cmp(he.Zero)<0&&(g=g.neg());break;case N.OP_NOT:g=new he((g.cmp(he.Zero)===0)+0);break;case N.OP_0NOTEQUAL:g=new he((g.cmp(he.Zero)!==0)+0);break}this.stack.pop(),this.stack.push(g.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(v=he.fromScriptNumBuffer(t(-2),n,this.maxScriptNumLength()),E=he.fromScriptNumBuffer(t(-1),n,this.maxScriptNumLength()),g=new he(0),ee){case N.OP_ADD:g=v.add(E);break;case N.OP_SUB:g=v.sub(E);break;case N.OP_MUL:g=v.mul(E);break;case N.OP_DIV:if(E.cmp(he.Zero)===0)return this.errstr="SCRIPT_ERR_DIV_BY_ZERO",!1;g=v.div(E);break;case N.OP_MOD:if(E.cmp(he.Zero)===0)return this.errstr="SCRIPT_ERR_MOD_BY_ZERO",!1;g=v.mod(E);break;case N.OP_BOOLAND:g=new he((v.cmp(he.Zero)!==0&&E.cmp(he.Zero)!==0)+0);break;case N.OP_BOOLOR:g=new he((v.cmp(he.Zero)!==0||E.cmp(he.Zero)!==0)+0);break;case N.OP_NUMEQUAL:g=new he((v.cmp(E)===0)+0);break;case N.OP_NUMEQUALVERIFY:g=new he((v.cmp(E)===0)+0);break;case N.OP_NUMNOTEQUAL:g=new he((v.cmp(E)!==0)+0);break;case N.OP_LESSTHAN:g=new he((v.cmp(E)<0)+0);break;case N.OP_GREATERTHAN:g=new he((v.cmp(E)>0)+0);break;case N.OP_LESSTHANOREQUAL:g=new he((v.cmp(E)<=0)+0);break;case N.OP_GREATERTHANOREQUAL:g=new he((v.cmp(E)>=0)+0);break;case N.OP_MIN:g=v.cmp(E)<0?v:E;break;case N.OP_MAX:g=v.cmp(E)>0?v:E;break}if(this.stack.pop(),this.stack.pop(),this.stack.push(g.toScriptNumBuffer()),ee===N.OP_NUMEQUALVERIFY)if(P.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;v=he.fromScriptNumBuffer(t(-3),n,this.maxScriptNumLength()),E=he.fromScriptNumBuffer(t(-2),n,this.maxScriptNumLength());var k=he.fromScriptNumBuffer(t(-1),n,this.maxScriptNumLength());z=E.cmp(v)<=0&&v.cmp(k)<0,this.stack.pop(),this.stack.pop(),this.stack.pop(),this.stack.push(z?P.true:P.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;i=t(-1);var L;ee===N.OP_RIPEMD160?L=Ka.ripemd160(i):ee===N.OP_SHA1?L=Ka.sha1(i):ee===N.OP_SHA256?L=Ka.sha256(i):ee===N.OP_HASH160?L=Ka.sha256ripemd160(i):ee===N.OP_HASH256&&(L=Ka.sha256sha256(i)),this.stack.pop(),this.stack.push(L);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(T=t(-2),M=t(-1),!this.checkSignatureEncoding(T)||!this.checkPubkeyEncoding(M))return!1;U=new Uc().set({chunks:this.script.chunks.slice(this.pbegincodehash)}),Ix(U,T,this.flags);try{F=qn.fromTxFormat(T),V=Mp.fromBuffer(M,!1),G=this.tx.verifySignature(F,V,this.nin,U,this.satoshisBN,this.flags)}catch{G=!1}if(!G&&this.flags&P.SCRIPT_VERIFY_NULLFAIL&&T.length&&this.enforceNonMalleability())return this.errstr="SCRIPT_ERR_NULLFAIL",!1;if(this.stack.pop(),this.stack.pop(),this.stack.push(G?P.true:P.false),ee===N.OP_CHECKSIGVERIFY)if(G)this.stack.pop();else return this.errstr="SCRIPT_ERR_CHECKSIGVERIFY",!1;break;case N.OP_CHECKMULTISIG:case N.OP_CHECKMULTISIGVERIFY:var H=1;if(this.stack.length<H)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;var W=he.fromScriptNumBuffer(t(-H),n,this.maxScriptNumLength()).toNumber();if(W<0||W>this.maxPubKeysPerMultisig())return this.errstr="SCRIPT_ERR_PUBKEY_COUNT",!1;if(this.nOpCount+=W,this.nOpCount>this.maxOpsPerScript())return this.errstr="SCRIPT_ERR_OP_COUNT",!1;var te=++H;H+=W;var X=W+2;if(this.stack.length<H)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;var ue=he.fromScriptNumBuffer(t(-H),n,this.maxScriptNumLength()).toNumber();if(ue<0||ue>W)return this.errstr="SCRIPT_ERR_SIG_COUNT",!1;var fe=++H;if(H+=ue,this.stack.length<H)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;U=new Uc().set({chunks:this.script.chunks.slice(this.pbegincodehash)});for(var O=0;O<ue;O++)T=t(-fe-O),Ix(U,T,this.flags);for(G=!0;G&&ue>0;){if(T=t(-fe),M=t(-te),!this.checkSignatureEncoding(T)||!this.checkPubkeyEncoding(M))return!1;var C;try{F=qn.fromTxFormat(T),V=Mp.fromBuffer(M,!1),C=this.tx.verifySignature(F,V,this.nin,U,this.satoshisBN,this.flags)}catch{C=!1}C&&(fe++,ue--),te++,W--,ue>W&&(G=!1)}for(;H-- >1;){if(!G&&this.flags&P.SCRIPT_VERIFY_NULLFAIL&&!X&&t(-1).length&&this.enforceNonMalleability())return this.errstr="SCRIPT_ERR_NULLFAIL",!1;X>0&&X--,this.stack.pop()}if(this.stack.length<1)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;if(this.flags&P.SCRIPT_VERIFY_NULLDUMMY&&t(-1).length&&this.enforceNonMalleability())return this.errstr="SCRIPT_ERR_SIG_NULLDUMMY",!1;if(this.stack.pop(),this.stack.push(G?P.true:P.false),ee===N.OP_CHECKMULTISIGVERIFY)if(G)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(o=t(-2),s=t(-1),o.length+s.length>this.maxScriptElementSize())return this.errstr="SCRIPT_ERR_PUSH_SIZE",!1;this.stack[this.stack.length-2]=d.Buffer.concat([o,s]),this.stack.pop();break;case N.OP_SPLIT:if(this.stack.length<2)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;o=t(-2);var D=he.fromScriptNumBuffer(t(-1),n,this.maxScriptNumLength()).toNumber();if(D<0||D>o.length)return this.errstr="SCRIPT_ERR_INVALID_SPLIT_RANGE",!1;var K=d.Buffer.from(o);this.stack[this.stack.length-2]=K.slice(0,D),this.stack[this.stack.length-1]=K.slice(D);break;case N.OP_LEFT:case N.OP_RIGHT:if(!this.isAfterChronicle()){if(this.flags&P.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(o=t(-2),f=he.fromScriptNumBuffer(t(-1),n,this.maxScriptNumLength()).toNumber(),f<0||f>o.length)return this.errstr="SCRIPT_ERR_INVALID_NUMBER_RANGE",!1;this.stack.pop(),ee===N.OP_LEFT?this.stack[this.stack.length-1]=d.Buffer.from(o).slice(0,f):this.stack[this.stack.length-1]=d.Buffer.from(o).slice(o.length-f);break;case N.OP_SUBSTR:if(!this.isAfterChronicle()){if(this.flags&P.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;o=t(-3);var re=he.fromScriptNumBuffer(t(-1),n,this.maxScriptNumLength()).toNumber(),J=he.fromScriptNumBuffer(t(-2),n,this.maxScriptNumLength()).toNumber();if(J<0||J>=o.length||re<0||re>o.length-J)return this.errstr="SCRIPT_ERR_INVALID_NUMBER_RANGE",!1;this.stack.pop(),this.stack.pop(),this.stack[this.stack.length-1]=d.Buffer.from(o).slice(J,J+re);break;case N.OP_NUM2BIN:if(this.stack.length<2)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;var Q=he.fromScriptNumBuffer(t(-1),n,this.maxScriptNumLength()).toNumber();if(Q<0||Q>this.maxScriptElementSize())return this.errstr="SCRIPT_ERR_PUSH_SIZE",!1;this.stack.pop();var se=t(-1);if(se=P._minimallyEncode(se),se.length>Q)return this.errstr="SCRIPT_ERR_IMPOSSIBLE_ENCODING",!1;if(se.length===Q){this.stack[this.stack.length-1]=se;break}var ce=0;se.length>0&&(se=d.Buffer.from(se),ce=se[se.length-1]&128,se[se.length-1]&=127);var ae=d.Buffer.alloc(Q);se.copy(ae,0);for(var _e=se.length-1;_e++<Q-2;)ae[_e]=0;ae[_e]=ce,this.stack[this.stack.length-1]=ae;break;case N.OP_BIN2NUM:if(this.stack.length<1)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;if(o=t(-1),s=P._minimallyEncode(o),this.stack[this.stack.length-1]=s,!P._isMinimallyEncoded(s,this.maxScriptNumLength()))return this.errstr="SCRIPT_ERR_INVALID_NUMBER_RANGE",!1;break;default:return this.errstr="SCRIPT_ERR_BAD_OPCODE",!1}return!0}});var qr=B((yq,Cp)=>{p();Cp.exports=gp();Cp.exports.Interpreter=Mc()});var ro=B((vq,Nx)=>{"use strict";p();var Lp=ze(),Hn=Le(),dC=Jn(),Tx=Vd(),Rr=ya(),Px=Jt(),Bx=pr(),Dp=Ar();function ne(e,t,r){if(!(this instanceof ne))return new ne(e,t,r);if(Lp.isArray(e)&&Lp.isNumber(t))return ne.createMultisig(e,t,r);if(e instanceof ne)return e;if(Hn.checkArgument(e,"First argument is required, please include address data.","guide/address.html"),t&&!Rr.get(t))throw new TypeError('Second argument must be "livenet", "testnet", or "regtest".');if(r&&r!==ne.PayToPublicKeyHash&&r!==ne.PayToScriptHash)throw new TypeError('Third argument must be "pubkeyhash" or "scripthash".');var n=this._classifyArguments(e,t,r);return n.network=n.network||Rr.get(t)||Rr.defaultNetwork,n.type=n.type||r||ne.PayToPublicKeyHash,Bx.defineImmutable(this,{hashBuffer:n.hashBuffer,network:n.network,type:n.type}),this}ne.prototype._classifyArguments=function(e,t,r){if((e instanceof d.Buffer||e instanceof Uint8Array)&&e.length===20)return ne._transformHash(e);if((e instanceof d.Buffer||e instanceof Uint8Array)&&e.length===21)return ne._transformBuffer(e,t,r);if(e instanceof Dp)return ne._transformPublicKey(e);if(e instanceof Ga())return ne._transformScript(e,t);if(typeof e=="string")return ne._transformString(e,t,r);if(Lp.isObject(e))return ne._transformObject(e);throw new TypeError("First argument is an unrecognized data format.")};ne.PayToPublicKeyHash="pubkeyhash";ne.PayToScriptHash="scripthash";ne._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};ne._transformObject=function(e){return Hn.checkArgument(e.hash||e.hashBuffer,"Must provide a `hash` or `hashBuffer` property"),Hn.checkArgument(e.type,"Must provide a `type` property"),{hashBuffer:e.hash?d.Buffer.from(e.hash,"hex"):e.hashBuffer,network:Rr.get(e.network)||Rr.defaultNetwork,type:e.type}};ne._classifyFromVersion=function(e){var t={},r=Rr.get(e[0],"pubkeyhash"),n=Rr.get(e[0],"scripthash");return r?(t.network=r,t.type=ne.PayToPublicKeyHash):n&&(t.network=n,t.type=ne.PayToScriptHash),t};ne._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=Rr.get(t),o=ne._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};ne._transformPublicKey=function(e){var t={};if(!(e instanceof Dp))throw new TypeError("Address must be an instance of PublicKey.");return t.hashBuffer=Px.sha256ripemd160(e.toBuffer()),t.type=ne.PayToPublicKeyHash,t};ne._transformScript=function(e,t){Hn.checkArgument(e instanceof Ga(),"script must be a Script instance");var r=e.getAddressInfo(t);if(!r)throw new dC.Script.CantDeriveAddress(e);return r};ne.createMultisig=function(e,t,r){return r=r||e[0].network||Rr.defaultNetwork,ne.payingTo(Ga().buildMultisigOut(e,t),r)};ne._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=Rr.get(t);if(t&&!n)throw new TypeError("Unknown network");var i=Tx.decode(e);return ne._transformBuffer(i,t,r)};ne.fromPublicKey=function(e,t){var r=ne._transformPublicKey(e);return t=t||Rr.defaultNetwork,new ne(r.hashBuffer,t,r.type)};ne.fromPrivateKey=function(e,t){let r=Dp.fromPrivateKey(e);return t=t||e.network||Rr.defaultNetwork,ne.fromPublicKey(r,t)};ne.fromPublicKeyHash=function(e,t){var r=ne._transformHash(e);return new ne(r.hashBuffer,t,ne.PayToPublicKeyHash)};ne.fromScriptHash=function(e,t){Hn.checkArgument(e,"hash parameter is required");var r=ne._transformHash(e);return new ne(r.hashBuffer,t,ne.PayToScriptHash)};ne.payingTo=function(e,t){return Hn.checkArgument(e,"script is required"),Hn.checkArgument(e instanceof Ga(),"script must be instance of Script"),ne.fromScriptHash(Px.sha256ripemd160(e.toBuffer()),t)};ne.fromScript=function(e,t){Hn.checkArgument(e instanceof Ga(),"script must be a Script instance");var r=ne._transformScript(e,t);return new ne(r.hashBuffer,t,r.type)};ne.fromBuffer=function(e,t,r){var n=ne._transformBuffer(e,t,r);return new ne(n.hashBuffer,n.network,n.type)};ne.fromHex=function(e,t,r){return ne.fromBuffer(d.Buffer.from(e,"hex"),t,r)};ne.fromString=function(e,t,r){var n=ne._transformString(e,t,r);return new ne(n.hashBuffer,n.network,n.type)};ne.fromObject=function(t){Hn.checkState(Bx.isHexa(t.hash),'Unexpected hash property, "'+t.hash+'", expected to be hex.');var r=d.Buffer.from(t.hash,"hex");return new ne(r,t.network,t.type)};ne.getValidationError=function(e,t,r){var n;try{new ne(e,t,r)}catch(i){n=i}return n};ne.isValid=function(e,t,r){return!ne.getValidationError(e,t,r)};ne.prototype.isPayToPublicKeyHash=function(){return this.type===ne.PayToPublicKeyHash};ne.prototype.isPayToScriptHash=function(){return this.type===ne.PayToScriptHash};ne.prototype.toBuffer=function(){var e=d.Buffer.from([this.network[this.type]]),t=d.Buffer.concat([e,this.hashBuffer]);return t};ne.prototype.toHex=function(){return this.toBuffer().toString("hex")};ne.prototype.toObject=ne.prototype.toJSON=function(){return{hash:this.hashBuffer.toString("hex"),type:this.type,network:this.network.toString()}};ne.prototype.inspect=function(){return"<Address: "+this.toString()+", type: "+this.type+", network: "+this.network+">"};ne.prototype.toString=function(){return Tx.encode(this.toBuffer())};Nx.exports=ne;function Ga(){return qr()}});var no=B((_q,Lx)=>{"use strict";p();var Fc=ze(),pC=ro(),Mx=Vd(),Si=wr(),kx=pr(),hn=ya(),Fp=fi(),gC=Ar(),yC=Qs(),Cx=Le(),Up="[REDACTED]";function ve(e,t){if(!(this instanceof ve))return new ve(e,t);if(e instanceof ve)return e;var r=this._classifyArguments(e,t);if(!r.bn||r.bn.cmp(new Si(0))===0)throw new TypeError("Number can not be equal to zero, undefined, null or false");if(!r.bn.lt(Fp.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 kx.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}ve.prototype._classifyArguments=function(e,t){var r={compressed:!0,network:t?hn.get(t):hn.defaultNetwork};if(Fc.isUndefined(e)||Fc.isNull(e))r.bn=ve._getRandomBN();else if(e instanceof Si)r.bn=e;else if(e instanceof d.Buffer||e instanceof Uint8Array)r=ve._transformBuffer(e,t);else if(e.bn&&e.network)r=ve._transformObject(e);else if(!t&&hn.get(e))r.bn=ve._getRandomBN(),r.network=hn.get(e);else if(typeof e=="string")kx.isHexa(e)?r.bn=new Si(d.Buffer.from(e,"hex")):r=ve._transformWIF(e,t);else throw new TypeError("First argument is an unrecognized data type.");return r};ve._getRandomBN=function(){var e,t;do{var r=yC.getRandomBuffer(32);t=Si.fromBuffer(r),e=t.lt(Fp.getN())}while(!e);return t};ve._transformBuffer=function(e,t){var r={};if(e.length===32)return ve._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=Si.fromBuffer(e.slice(1,33)),r};ve._transformBNBuffer=function(e,t,r){var n={};return n.network=hn.get(t)||hn.defaultNetwork,n.bn=Si.fromBuffer(e),n.compressed=r===void 0?!0:!!r,n};ve._transformWIF=function(e,t){return ve._transformBuffer(Mx.decode(e),t)};ve.fromBuffer=function(e,t,r){return r!==void 0&&e&&e.length===32?new ve(ve._transformBNBuffer(e,t,r)):new ve(e,t)};ve.fromHex=function(e,t,r){return ve.fromBuffer(d.Buffer.from(e,"hex"),t,r)};ve._transformObject=function(e){if(e.bn instanceof Si)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===Up)throw new TypeError('Invalid private key: `bn` is "'+Up+'". 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 Si(e.bn,"hex");if(t.isZero()||t.gte(Fp.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}};ve.fromString=ve.fromWIF=function(e,t){return Cx.checkArgument(Fc.isString(e),"First argument is expected to be a string."),new ve(e,t)};ve.fromObject=ve.fromJSON=function(e){return Cx.checkArgument(Fc.isObject(e),"First argument is expected to be an object."),new ve(e)};ve.fromRandom=function(e){var t=ve._getRandomBN();return new ve(t,e)};ve.getValidationError=function(e,t){var r;try{new ve(e,t)}catch(n){r=n}return r};ve.isValid=function(e,t){return e?!ve.getValidationError(e,t):!1};ve.prototype.toString=function(){return this.toWIF()};ve.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})]),Mx.encode(r)};ve.prototype.toBigNumber=function(){return this.bn};ve.prototype.toBuffer=function(){return this.bn.toBuffer({size:32})};ve.prototype.toHex=function(){return this.toBuffer().toString("hex")};ve.prototype.toPublicKey=function(){return this._pubkey||(this._pubkey=gC.fromPrivateKey(this)),this._pubkey};ve.prototype.toAddress=function(e){var t=this.toPublicKey();return pC.fromPublicKey(t,e||this.network)};ve.prototype.toObject=function(){return{bn:this.bn.toString("hex"),compressed:this.compressed,network:this.network.toString()}};ve.prototype.toJSON=function(){return{bn:Up,compressed:this.compressed,network:this.network.toString()}};ve.prototype.inspect=function(){var e=this.compressed?"":", uncompressed";return"<PrivateKey: "+this.toHex()+", network: "+this.network+e+">"};Lx.exports=ve});var Ar=B((wq,Ux)=>{"use strict";p();var us=wr(),fs=fi(),mC=Jt(),vC=pr(),Dx=ya(),qp=ze(),oo=Le();function de(e,t){if(!(this instanceof de))return new de(e,t);if(oo.checkArgument(e,"First argument is required, please include public key data."),e instanceof de)return e;t=t||{};var r=this._classifyArgs(e,t);return r.point.validate(),vC.defineImmutable(this,{point:r.point,compressed:r.compressed,network:r.network||Dx.defaultNetwork}),this}de.prototype._classifyArgs=function(e,t){var r={compressed:qp.isUndefined(t.compressed)||t.compressed};if(e instanceof fs)r.point=e;else if(e.x&&e.y)r=de._transformObject(e);else if(typeof e=="string")r=de._transformDER(d.Buffer.from(e,"hex"));else if(de._isBuffer(e))r=de._transformDER(e);else if(de._isPrivateKey(e))r=de._transformPrivateKey(e);else throw new TypeError("First argument is an unrecognized data format.");return r.network||(r.network=qp.isUndefined(t.network)?void 0:Dx.get(t.network)),r};de._isPrivateKey=function(e){var t=no();return e instanceof t};de._isBuffer=function(e){return e instanceof d.Buffer||e instanceof Uint8Array};de._transformPrivateKey=function(e){oo.checkArgument(de._isPrivateKey(e),"Must be an instance of PrivateKey");var t={};return t.point=fs.getG().mul(e.bn),t.compressed=e.compressed,t.network=e.network,t};de._transformDER=function(e,t){oo.checkArgument(de._isBuffer(e),"Must be a buffer of DER encoded public key");var r={};t=qp.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 us(o),i=new us(s),r.point=new fs(n,i),r.compressed=!1}else if(e[0]===3)o=e.slice(1),n=new us(o),r=de._transformX(!0,n),r.compressed=!0;else if(e[0]===2)o=e.slice(1),n=new us(o),r=de._transformX(!1,n),r.compressed=!0;else throw new TypeError("Invalid DER format public key");return r};de._transformX=function(e,t){oo.checkArgument(typeof e=="boolean","Must specify whether y is odd or not (true or false)");var r={};return r.point=fs.fromX(e,t),r};de._transformObject=function(e){var t=new us(e.x,"hex"),r=new us(e.y,"hex"),n=new fs(t,r);return new de(n,{compressed:e.compressed})};de.fromPrivateKey=function(e){oo.checkArgument(de._isPrivateKey(e),"Must be an instance of PrivateKey");var t=de._transformPrivateKey(e);return new de(t.point,{compressed:t.compressed,network:t.network})};de.fromDER=de.fromBuffer=function(e,t){oo.checkArgument(de._isBuffer(e),"Must be a buffer of DER encoded public key");var r=de._transformDER(e,t);return new de(r.point,{compressed:r.compressed})};de.fromPoint=function(e,t){return oo.checkArgument(e instanceof fs,"First argument must be an instance of Point."),new de(e,{compressed:t})};de.fromHex=de.fromString=function(e,t){var r=d.Buffer.from(e,t||"hex"),n=de._transformDER(r);return new de(n.point,{compressed:n.compressed})};de.fromX=function(e,t){var r=de._transformX(e,t);return new de(r.point,{compressed:r.compressed})};de.getValidationError=function(e){var t;try{new de(e)}catch(r){t=r}return t};de.isValid=function(e){return!de.getValidationError(e)};de.prototype.toObject=de.prototype.toJSON=function(){return{x:this.point.getX().toString("hex",2),y:this.point.getY().toString("hex",2),compressed:this.compressed}};de.prototype.toBuffer=de.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])};de.prototype._getID=function(){return mC.sha256ripemd160(this.toBuffer())};de.prototype.toAddress=function(e){var t=ro();return t.fromPublicKey(this,e||this.network)};de.prototype.toString=de.prototype.toHex=function(){return this.toDER().toString("hex")};de.prototype.inspect=function(){return"<PublicKey: "+this.toHex()+(this.compressed?"":", uncompressed")+">"};Ux.exports=de});var Va=B((xq,qx)=>{"use strict";p();var Fx=Qs();function bC(){var e=Fx.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 _C(e){return Fx.getRandomBuffer(Math.ceil(e/2)).toString("hex").substring(0,e)}qx.exports={uuid4:bC,randomHex:_C}});var Vx=B((Oq,Gx)=>{"use strict";p();var Wa=Ar(),Hp=Jt(),jp=La(),Hx=nr(),Kp=no(),Bt=Le(),Aq=ze(),SC=Va();function jx(e,t){if(t=t||{},t.issuerPublicKey)return t.issuerPublicKey instanceof Wa?t.issuerPublicKey:Wa.fromString(t.issuerPublicKey);var r=e&&e.issuer;if(typeof r!="string")return null;try{var n=r.split("#")[0].split(":")[2];return n?Wa.fromString(n):null}catch{return null}}var cs={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"},Kx={create:function(e,t,r,n,i,o){o=o||{},Bt.checkArgument(typeof e=="string","Right type must be string"),Bt.checkArgument(typeof t=="string","Issuer DID must be string"),Bt.checkArgument(typeof r=="string","Subject DID must be string"),Bt.checkArgument(n&&typeof n=="object","Claim must be object");var s=Object.values(cs);Bt.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||{},Bt.checkArgument(typeof e=="string","Right type must be string"),Bt.checkArgument(typeof t=="string","Issuer DID must be string"),Bt.checkArgument(typeof r=="string","Subject DID must be string"),Bt.checkArgument(n&&typeof n=="object","Claim must be object"),Bt.checkArgument(i instanceof Kp,"Invalid issuer private key");var s=Object.values(cs);Bt.checkArgument(s.includes(e),"Invalid right type: "+e);try{var a=this.create(e,t,r,n,i,o),f=this._signToken(a,i);return{success:!0,rightToken:f,tokenHash:f.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:f,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:f.id,tokenHash:f.tokenHash,type:e,issuer:t,subject:r,issuedAt:f.issuanceDate}},notifyParties:{endpoint:"POST /notifications/right-issued",data:{tokenId:f.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||{},Bt.checkArgument(e&&typeof e=="object","Invalid token"),Bt.checkArgument(typeof t=="string","New owner DID must be string"),Bt.checkArgument(r instanceof Kp,"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=jx({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}},f=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:f.id,transferDate:f.issuanceDate,from:e.credentialSubject.id,to:t}),delete l.proof;var y=this._signToken(l,r);return{success:!0,newToken:y,transferProof:f,transferId:f.id,externalOperations:{recordTransfer:{endpoint:"POST /rights/transfers",data:{originalTokenId:e.id,newTokenId:y.id,transferProof:f,fromOwner:e.credentialSubject.id,toOwner:t,transferDate:f.issuanceDate}},updateOwnership:{endpoint:"PUT /rights/tokens/"+e.id+"/ownership",data:{newOwner:t,transferId:f.id,transferDate:f.issuanceDate,previousOwner:e.credentialSubject.id}},notifyParties:{endpoint:"POST /notifications/right-transferred",data:{originalTokenId:e.id,newTokenId:y.id,fromOwner:e.credentialSubject.id,toOwner:t,rightType:e.credentialSubject.rightType}},auditTransfer:{endpoint:"POST /audit/right-transfer",data:{originalTokenId:e.id,newTokenId:y.id,transferId:f.id,fromOwner:e.credentialSubject.id,toOwner:t,transferredAt:f.issuanceDate}}}}}catch(g){return{success:!1,error:g.message}}},prepareObligationToken:function(e,t,r,n){Bt.checkArgument(e&&typeof e=="object","Invalid right token"),Bt.checkArgument(typeof t=="string","Obligor DID must be string"),Bt.checkArgument(r&&typeof r=="object","Obligation must be object"),Bt.checkArgument(n instanceof Kp,"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){Bt.checkArgument(typeof e=="string","Right type must be string");var t=Object.values(cs),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 cs},verifyToken:function(e,t){var r=[];try{if(Bt.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 Wa?t:Wa.fromString(t),i=this._canonicalizeToken(e),o=Hp.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=Hx.fromDER(d.Buffer.from(s[2],"base64url")),f=new jp;return f.hashbuf=o,f.sig=a,f.pubkey=n,f.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=Hp.sha256(d.Buffer.from(r)),i=new jp;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=Hp.sha256(d.Buffer.from(n));if(e.tokenHash&&e.tokenHash!==i.toString("hex")){t.push("Token hash mismatch");return}var o=jx(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=Hx.fromDER(d.Buffer.from(s[2],"base64url")),f=new jp;f.hashbuf=i,f.sig=a,f.pubkey=o,f.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(cs);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 SC.uuid4()}};Kx.RightTypes=cs;Gx.exports=Kx});var Yx=B((Tq,zx)=>{"use strict";p();var Wx={};Wx.stringify=function(e){return Gp(e,[])};function Gp(e,t){if(e===null)return"null";var r=typeof e;if(r==="boolean")return e?"true":"false";if(r==="number"){if(!isFinite(e))throw new Error("Cannot canonicalize non-finite number: "+e);return JSON.stringify(e)}if(r==="string")return JSON.stringify(e);if(r==="bigint")throw new Error("Cannot canonicalize bigint; represent it as a string");if(Array.isArray(e)||r==="object"){if(t.indexOf(e)!==-1)throw new Error("Cannot canonicalize a circular structure");t.push(e);var n;if(Array.isArray(e))n="["+e.map(function(o){return o===void 0?"null":Gp(o,t)}).join(",")+"]";else{var i=Object.keys(e).filter(function(o){return e[o]!==void 0&&typeof e[o]!="function"}).sort();n="{"+i.map(function(o){return JSON.stringify(o)+":"+Gp(e[o],t)}).join(",")+"}"}return t.pop(),n}throw new Error("Cannot canonicalize value of type: "+r)}zx.exports=Wx});var Xx=B((Bq,Zx)=>{"use strict";p();var Vp=Object.create(null),Wp=[],zp=!(typeof x.default<"u"&&x.default.env&&x.default.env.BSV_NO_DEPRECATION_WARNINGS==="1");function $x(e,t){if(!e||typeof e.what!="string"||e.what==="")throw new TypeError(t+"() requires { what: string }")}function wC(e){var t="[@smartledger/bsv] "+e.what+" is deprecated";return e.since&&(t+=" since "+e.since),t+=".",e.why&&(t+=" "+e.why.charAt(0).toUpperCase()+e.why.slice(1)+"."),e.use&&(t+=" Use "+e.use+" instead."),t+=e.removeIn?" It will be removed in "+e.removeIn+".":" A removal version has not been set; it will not be removed in a 9.x release.",t}function jn(e){if(!e||!e.what)throw new TypeError("deprecate() requires { what }");if(Vp[e.what])return!1;Vp[e.what]=!0;var t=wC(e);return Wp.push({what:e.what,since:e.since||null,removeIn:e.removeIn||null,use:e.use||null,message:t}),zp&&console.warn(t),!0}jn.fn=function(e,t){if(typeof e!="function")throw new TypeError("deprecate.fn() requires a function");$x(t,"deprecate.fn");var r=function(){return jn(t),e.apply(this,arguments)};return Object.defineProperty(r,"name",{value:e.name,configurable:!0}),Object.defineProperty(r,"length",{value:e.length,configurable:!0}),r.__wrapped=e,r.__deprecation=t,r};jn.property=function(e,t,r,n){$x(n,"deprecate.property");var i,o=!1;return Object.defineProperty(e,t,{configurable:!0,enumerable:!0,get:function(){return jn(n),o||(i=r(),o=!0),i}}),e};jn.fired=function(){return Wp.slice()};jn.setEnabled=function(e){zp=!!e};jn.isEnabled=function(){return zp};jn.reset=function(){Vp=Object.create(null),Wp.length=0};Zx.exports=jn});var Qx=B((Mq,Jx)=>{"use strict";p();var ls=Jt(),cr=Le(),EC=Va(),xC=Yx(),IC=Xx(),so={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"}}}},AC={prepareClaimValidation:function(e,t){try{cr.checkArgument(e&&typeof e=="object","Invalid claim"),cr.checkArgument(typeof t=="string","Schema name must be string");var r=so[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:ls.sha256(d.Buffer.from(this._canonicalizeWith(e,this.CANONICALIZATION.LEGACY))).toString("hex"),canonical:this._canonicalizeWith(e,this.CANONICALIZATION.LEGACY)};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{cr.checkArgument(e&&typeof e=="object","Invalid claim"),cr.checkArgument(typeof t=="string","Schema name must be string"),cr.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=ls.sha256(d.Buffer.from(this._canonicalizeWith(i,this.CANONICALIZATION.LEGACY))).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{cr.checkArgument(typeof e=="string","Claim hash must be string"),cr.checkArgument(t&&typeof t=="object","Invalid disputant"),cr.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=ls.sha256(d.Buffer.from(this._canonicalizeWith(n,this.CANONICALIZATION.LEGACY))).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{cr.checkArgument(Array.isArray(e),"Claims must be array"),cr.checkArgument(typeof t=="string","Schema name must be string");var r=[],n=[],i=0;e.forEach(function(a,f){try{var l=this.prepareClaimValidation(a,t);l.success&&l.validation.valid&&i++,r.push({index:f,result:l})}catch(y){n.push({index:f,error:y.message})}}.bind(this));var o=this._generateBatchId(),s=ls.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}}},CANONICALIZATION:{JCS:"jcs",LEGACY:"legacy"},canonicalize:function(e,t){return this._canonicalizeWith(e,this._resolveCanonicalization(t,"LTP.Claim.canonicalize"))},hash:function(e,t){var r=this._canonicalizeWith(e,this._resolveCanonicalization(t,"LTP.Claim.hash"));return ls.sha256(d.Buffer.from(r)).toString("hex")},_canonicalizeWith:function(e,t){if(cr.checkArgument(e&&typeof e=="object","Invalid claim"),t===this.CANONICALIZATION.JCS)return xC.stringify(e);var r=this._sortObjectKeys(e);return JSON.stringify(r)},_resolveCanonicalization:function(e,t){return e===void 0?(IC({what:t+"() without a canonicalization argument",since:"9.2.0",removeIn:"10.0.0",use:t+"(claim, bsv.LTP.Claim.CANONICALIZATION.JCS)",why:"the default sorted-key form is not RFC 8785, so other implementations compute a different claim hash"}),this.CANONICALIZATION.LEGACY):(cr.checkArgument(e===this.CANONICALIZATION.JCS||e===this.CANONICALIZATION.LEGACY,"Unknown canonicalization: "+e+". Expected 'jcs' or 'legacy' (bsv.LTP.Claim.CANONICALIZATION)"),e)},prepareClaimTemplate:function(e,t){t=t||{};try{var r=so[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 so},getSchemaNames:function(){return Object.keys(so)},getSchema:function(e){return so[e]||null},addSchema:function(e,t){cr.checkArgument(typeof e=="string","Schema name must be string"),cr.checkArgument(t&&typeof t=="object","Invalid schema"),so[e]=t},createTemplate:function(e){var t=so[e];if(!t)throw new Error("Unknown schema: "+e);return this._createTemplateFromSchema(t)},_generateDisputeId:function(e){var t="dispute_"+e+"_"+Date.now();return ls.sha256(d.Buffer.from(t)).toString("hex").substring(0,16)},_generateBatchId:function(){return EC.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())}};Jx.exports=AC});var tI=B((Cq,eI)=>{"use strict";p();var za=Jt(),hs=Le(),OC={prepareTokenCommitment:function(e,t){t=t||{},hs.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||{},hs.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){hs.checkArgument(e&&typeof e=="object","Invalid token"),hs.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){hs.checkArgument(typeof e=="string","Token ID must be string"),hs.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=za.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:za.sha256(d.Buffer.from(r)).toString("hex"),tokenId:e.id,timestamp:new Date().toISOString(),purpose:t.purpose||"legal_token"},i=za.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 f=this._createCommitment(a,t);r.push(f.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=za.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=za.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}};eI.exports=OC});var iI=B((Dq,nI)=>{"use strict";p();var RC=Ar(),Vr=Jt(),rI=La(),TC=nr(),PC=no(),ir=Le(),BC={prepareSignatureProof:function(e,t,r){r=r||{},ir.checkArgument(e&&typeof e=="object","Invalid token"),ir.checkArgument(t instanceof PC,"Invalid private key");try{var n=this._canonicalizeForSigning(e),i=Vr.sha256(d.Buffer.from(n)),o=new rI;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(f){return{success:!1,error:f.message}}},prepareSignatureVerification:function(e,t){try{if(ir.checkArgument(e&&typeof e=="object","Invalid token"),ir.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=Vr.sha256(d.Buffer.from(r)),i=TC.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 rI;s.hashbuf=n,s.sig=i,s.pubkey=RC.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(f){return{success:!1,error:f.message}}},prepareSelectiveDisclosure:function(e,t,r){ir.checkArgument(e&&typeof e=="object","Invalid token"),ir.checkArgument(Array.isArray(t),"Revealed fields must be array"),ir.checkArgument(typeof r=="string","Nonce must be string");try{var n=this._createFieldCommitments(e,r),i=this._createMerkleTree(n),o=[],s=[];t.forEach(function(f){var l=this._getNestedValue(e,f),y=this._findFieldCommitment(n,f);if(y){o.push({path:f,value:l,commitment:y.hash,salt:y.salt});var g=this._generateMerkleProof(i,y.index);s.push({path:f,leafIndex:y.index,proof:g})}}.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(f){return{success:!1,error:f.message}}},prepareSelectiveDisclosureVerification:function(e,t){try{if(ir.checkArgument(e&&typeof e=="object","Invalid proof"),ir.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],f=this._hashField(o.path,o.value,o.salt);if(f!==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){ir.checkArgument(e&&typeof e=="object","Invalid token"),ir.checkArgument(t&&typeof t=="object","Invalid jurisdiction"),ir.checkArgument(typeof r=="string","Nonce must be string");try{var n=t.requirements||[],i=[],o=!0;n.forEach(function(a){var f=this._checkLegalRequirement(e,a);i.push(f),f.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){ir.checkArgument(e&&typeof e=="object","Invalid token"),ir.checkArgument(t&&typeof t=="object","Invalid statement"),ir.checkArgument(typeof r=="string","Nonce must be string");try{var n=Vr.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:Vr.sha256(d.Buffer.from(t.claim+r)).toString("hex"),response:Vr.sha256(d.Buffer.from(this._canonicalizeForSigning(e)+t.claim)).toString("hex"),witness:Vr.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=Vr.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 Vr.sha256(d.Buffer.from(n)).toString("hex")},_createMerkleTree:function(e){var t=e.map(function(y){return y.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,f=d.Buffer.concat([d.Buffer.from(s,"hex"),d.Buffer.from(a,"hex")]),l=Vr.sha256(f).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],f=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=Vr.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 Vr.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}};nI.exports=BC});var aI=B((Hq,sI)=>{"use strict";p();var Ya=Jt(),Fq=ro(),qq=Np(),lr=Le(),oI=Va(),NC={prepareRegistry:function(e){e=e||{},lr.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||{},lr.checkArgument(e&&typeof e=="object","Invalid token"),lr.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{lr.checkArgument(typeof e=="string","Token ID must be string"),lr.checkArgument(typeof t=="string","Approver must be string"),lr.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(lr.checkArgument(typeof e=="string","Token ID must be string"),lr.checkArgument(t&&typeof t=="object","Invalid revocation"),lr.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 lr.checkArgument(typeof e=="string","Token ID must be string"),lr.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{lr.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 lr.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||{},lr.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_"+oI.randomHex(16)},_generateRegistrationId:function(e){var t="reg_"+e+"_"+Date.now();return Ya.sha256(d.Buffer.from(t)).toString("hex").substring(0,16)},_generateRevocationId:function(e){var t="rev_"+e+"_"+Date.now();return Ya.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,Ya.sha256(d.Buffer.from(JSON.stringify(t))).toString("hex")},_generateRevocationHash:function(e,t){var r=e+(t.reason||"")+(t.revokedBy||"")+Date.now();return Ya.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_"+oI.randomHex(32)},_generateAuditHash:function(e){var t=(e.action||"")+(e.actor||"")+(e.tokenId||"")+(e.timestamp||"");return Ya.sha256(d.Buffer.from(t)).toString("hex").substring(0,16)}};sI.exports=NC});var lI=B((Kq,cI)=>{"use strict";p();var Yp=Ar(),$p=Jt(),uI=La(),MC=nr(),fI=no(),yr=Le(),kC=Va();function CC(e,t){if(t=t||{},t.issuerPublicKey)return t.issuerPublicKey instanceof Yp?t.issuerPublicKey:Yp.fromString(t.issuerPublicKey);var r=e&&e.issuer;if(typeof r!="string")return null;try{var n=r.split("#")[0].split(":")[2];return n?Yp.fromString(n):null}catch{return null}}var qc={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"},ds={CRITICAL:"CRITICAL",HIGH:"HIGH",MEDIUM:"MEDIUM",LOW:"LOW",DEFERRED:"DEFERRED"},hr={PENDING:"PENDING",ACTIVE:"ACTIVE",IN_PROGRESS:"IN_PROGRESS",COMPLETED:"COMPLETED",OVERDUE:"OVERDUE",BREACHED:"BREACHED",WAIVED:"WAIVED",TERMINATED:"TERMINATED"},Hc={prepareObligationToken:function(e,t,r,n,i,o){o=o||{},yr.checkArgument(typeof e=="string","Obligation type must be string"),yr.checkArgument(typeof t=="string","Issuer DID must be string"),yr.checkArgument(typeof r=="string","Obligor DID must be string"),yr.checkArgument(n&&typeof n=="object","Obligation must be object"),yr.checkArgument(i instanceof fI,"Invalid issuer private key");var s=Object.values(qc);yr.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||ds.MEDIUM,status:hr.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 f=this._signToken(a,i);return{success:!0,obligationToken:f,tokenHash:f.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:f,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:f.id,tokenHash:f.tokenHash,type:e,issuer:t,obligor:r,issuedAt:f.issuanceDate,dueDate:a.credentialSubject.dueDate,priority:a.credentialSubject.priority}},notifyObligor:{endpoint:"POST /notifications/obligation-issued",data:{tokenId:f.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:f.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===hr.ACTIVE?{endpoint:"PUT /obligations/tokens/"+e.id+"/status",data:{status:hr.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||{},yr.checkArgument(e&&typeof e=="object","Invalid token"),yr.checkArgument(t&&typeof t=="object","Invalid fulfillment"),yr.checkArgument(r instanceof fI,"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===hr.COMPLETED)return{success:!1,error:"Obligation already fulfilled"};if(e.credentialSubject.status===hr.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?hr.COMPLETED:hr.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(f){return{success:!1,error:f.message}}},prepareObligationBreachAssessment:function(e,t,r){yr.checkArgument(e&&typeof e=="object","Invalid token"),yr.checkArgument(t&&typeof t=="object","Invalid breach details"),yr.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=$p.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:hr.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||{},yr.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===hr.COMPLETED&&r.summary.completed++,s.isOverdue&&s.priority===ds.CRITICAL&&r.alerts.push({type:"CRITICAL_OVERDUE",obligationId:o.id,message:"Critical obligation is overdue",priority:"HIGH"}),s.isDueSoon&&s.priority===ds.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 qc},getObligationPriority:function(){return ds},getObligationStatus:function(){return hr},_signToken:function(e,t){var r=this._canonicalizeToken(e),n=$p.sha256(d.Buffer.from(r)),i=new uI;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=$p.sha256(d.Buffer.from(n));if(e.tokenHash&&e.tokenHash!==i.toString("hex")){t.push("Token hash mismatch");return}var o=CC(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=MC.fromDER(d.Buffer.from(s[2],"base64url")),f=new uI;f.hashbuf=i,f.sig=a,f.pubkey=o,f.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(qc);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(hr);n.includes(e.credentialSubject.status)||t.push("Invalid obligation status: "+e.credentialSubject.status),this._checkIfOverdue(e)&&e.credentialSubject.status===hr.ACTIVE&&r.push("Obligation is overdue but status is still ACTIVE")},_validateObligationPriority:function(e,t){if(e.credentialSubject.priority){var r=Object.values(ds);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!==hr.COMPLETED},_generateUUID:function(){return kC.uuid4()}};Hc.ObligationTypes=qc;Hc.ObligationPriority=ds;Hc.ObligationStatus=hr;cI.exports=Hc});var dI=B((Vq,hI)=>{"use strict";p();var ao=Vx(),jc=Qx(),$a=tI(),Zp=iI(),dn=aI(),LC=lI(),Xp=no(),mr=Le(),Te=function(e){return this instanceof Te?(this.config=e||{},this.registry=null,this.config.registry&&(this.registry=dn.createRegistry(this.config.registry)),this):new Te(e)};Te.prototype.createRightToken=function(e,t,r){mr.checkArgument(e&&typeof e=="object","Invalid right data"),mr.checkArgument(t instanceof Xp,"Invalid private key"),r=r||{};try{var n=ao.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=ao._signToken(n,t)),r.anchor){var i=$a.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}}};Te.prototype.validateClaim=function(e,t){return jc.validate(e,t)};Te.prototype.createSelectiveDisclosure=function(e,t,r){return Zp.prepareSelectiveDisclosure(e,t,r)};Te.prototype.verifyToken=function(e,t){return!e||!e.proof?{valid:!1,error:"No proof found in token"}:ao.verifyToken(e,t)};Te.prototype.transferRight=function(e,t,r,n){mr.checkArgument(e&&typeof e=="object","Invalid token"),mr.checkArgument(typeof t=="string","New owner must be string"),mr.checkArgument(r instanceof Xp,"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=ao.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 f=$a.anchorToken(s,n.anchor);f.success&&(s.transferAnchorTx=f.txid)}if(this.registry){var l=dn.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(y){return{success:!1,error:y.message}}};Te.prototype.createObligation=function(e,t,r){mr.checkArgument(e&&typeof e=="object","Invalid right token"),mr.checkArgument(t&&typeof t=="object","Invalid obligation data"),mr.checkArgument(r instanceof Xp,"Invalid private key");try{var n=ao.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}}};Te.prototype.revokeToken=function(e,t,r){return mr.checkArgument(typeof e=="string","Token ID must be string"),mr.checkArgument(t&&typeof t=="object","Invalid revocation data"),mr.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"}};Te.prototype.checkTokenStatus=function(e){return mr.checkArgument(typeof e=="string","Token ID must be string"),this.registry?dn.checkTokenStatus(this.registry,e):{found:!1,error:"No registry available"}};Te.prototype.searchTokens=function(e){return this.registry?dn.searchTokens(this.registry,e):{success:!1,error:"No registry available"}};Te.prototype.getRegistryStats=function(){return this.registry?dn.getStatistics(this.registry):{error:"No registry available"}};Te.prototype.createLegalValidityProof=function(e,t,r){return Zp.prepareLegalValidityProof(e,t,r)};Te.prototype.anchorTokenBatch=function(e,t){return $a.anchorBatch(e,t)};Te.prototype.verifyAnchor=function(e,t){return $a.verifyAnchor(e,t)};Te.prototype.getRightTypes=function(){return ao.getRightTypes()};Te.prototype.getClaimSchemas=function(){return jc.getSchemas()};Te.prototype.createRegistry=function(e){return this.registry=dn.createRegistry(e),this.registry};Te.prototype.setRegistry=function(e){mr.checkArgument(e&&typeof e=="object","Invalid registry"),this.registry=e};Te.create=function(e){return new Te(e)};Te.createRightToken=function(e,t,r){var n=new Te;return n.createRightToken(e,t,r)};Te.validateClaim=function(e,t){return jc.validate(e,t)};Te.verifyToken=function(e,t){var r=new Te;return r.verifyToken(e,t)};Te.createRegistry=function(e){return dn.createRegistry(e)};Te.Right=ao;Te.Claim=jc;Te.Anchor=$a;Te.Proof=Zp;Te.Registry=dn;Te.Obligation=LC;hI.exports=Te});var DC=B((zq,pI)=>{p();pI.exports=dI()});return DC();})();
|
|
74
|
+
`))}}};P.prototype.verify=function(e,t,r,n,i,o){this.eraHint=null;var s=this._verifyCore(e,t,r,n,i,o);return s||this._eraDiagnose(i),s};P._resetEraWarning=function(){kp=!1};P.mainnetFlags=function(e){e=e||{};var t=P.SCRIPT_VERIFY_P2SH|P.SCRIPT_VERIFY_STRICTENC|P.SCRIPT_VERIFY_DERSIG|P.SCRIPT_VERIFY_SIGPUSHONLY|P.SCRIPT_VERIFY_LOW_S|P.SCRIPT_VERIFY_NULLFAIL|P.SCRIPT_VERIFY_MINIMALDATA|P.SCRIPT_ENABLE_SIGHASH_FORKID|P.SCRIPT_ENABLE_MAGNETIC_OPCODES|P.SCRIPT_ENABLE_MONOLITH_OPCODES|P.SCRIPT_GENESIS|P.SCRIPT_UTXO_AFTER_GENESIS;return e.afterChronicle!==!1&&(t|=P.SCRIPT_ENABLE_CHRONICLE|P.SCRIPT_UTXO_AFTER_CHRONICLE),t};P.currentConsensusFlags=function(){return P.SCRIPT_ENABLE_MONOLITH_OPCODES|P.SCRIPT_ENABLE_MAGNETIC_OPCODES|P.SCRIPT_GENESIS|P.SCRIPT_UTXO_AFTER_GENESIS|P.SCRIPT_ENABLE_CHRONICLE|P.SCRIPT_UTXO_AFTER_CHRONICLE|P.SCRIPT_ENABLE_SIGHASH_FORKID|P.SCRIPT_VERIFY_SIGPUSHONLY|P.SCRIPT_VERIFY_LOW_S|P.SCRIPT_VERIFY_NULLFAIL};P.useMainnetConsensus=function(e){return e=e||{},P.useGenesisLimits(e.max),P.mainnetFlags(e)};P.SEQUENCE_LOCKTIME_DISABLE_FLAG=1<<31;P.SEQUENCE_LOCKTIME_TYPE_FLAG=1<<22;P.SEQUENCE_LOCKTIME_MASK=65535;P.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};function Ox(e,t){return(e&P.SCRIPT_CHRONICLE)===0?!0:!(t&&(t.version|0)>1)}P.prototype.enforceNonMalleability=function(){return Ox(this.flags,this.tx)};P.prototype.checkSignatureEncoding=function(e){var t;if(e.length===0)return!0;if((this.flags&(P.SCRIPT_VERIFY_DERSIG|P.SCRIPT_VERIFY_LOW_S|P.SCRIPT_VERIFY_STRICTENC))!==0&&!qn.isTxDER(e))return this.errstr="SCRIPT_ERR_SIG_DER_INVALID_FORMAT",!1;if((this.flags&P.SCRIPT_VERIFY_LOW_S)!==0&&(t=qn.fromTxFormat(e),!t.hasLowS()&&this.enforceNonMalleability()))return this.errstr="SCRIPT_ERR_SIG_DER_HIGH_S",!1;if((this.flags&P.SCRIPT_VERIFY_STRICTENC)!==0){if(t=qn.fromTxFormat(e),!t.hasDefinedHashtype())return this.errstr="SCRIPT_ERR_SIG_HASHTYPE",!1;if(!(this.flags&P.SCRIPT_ENABLE_SIGHASH_FORKID)&&t.nhashtype&qn.SIGHASH_FORKID)return this.errstr="SCRIPT_ERR_ILLEGAL_FORKID",!1;if(!(this.flags&P.SCRIPT_CHRONICLE)&&t.nhashtype&qn.SIGHASH_CHRONICLE)return this.errstr="SCRIPT_ERR_ILLEGAL_CHRONICLE",!1;if(this.flags&P.SCRIPT_ENABLE_SIGHASH_FORKID&&!(t.nhashtype&qn.SIGHASH_FORKID))return this.errstr="SCRIPT_ERR_MUST_USE_FORKID",!1}return!0};function Ix(e,t,r){var n=t.length?t[t.length-1]:0;return(!(r&P.SCRIPT_ENABLE_SIGHASH_FORKID)||!(n&qn.SIGHASH_FORKID))&&e.findAndDelete(new Uc().add(t)),e}P.prototype.checkPubkeyEncoding=function(e){return(this.flags&P.SCRIPT_VERIFY_STRICTENC)!==0&&!Mp.isValid(e)?(this.errstr="SCRIPT_ERR_PUBKEYTYPE",!1):!0};P.prototype.isAfterGenesis=function(){return(this.flags&P.SCRIPT_UTXO_AFTER_GENESIS)!==0};P.prototype.isAfterChronicle=function(){return(this.flags&(P.SCRIPT_UTXO_AFTER_CHRONICLE|P.SCRIPT_ENABLE_CHRONICLE))!==0};P.prototype.maxScriptElementSize=function(){return this.isAfterGenesis()?P.UNLIMITED:P.MAX_SCRIPT_ELEMENT_SIZE};P.prototype.maxScriptSize=function(){return this.isAfterGenesis()?P.UNLIMITED:P.MAX_SCRIPT_SIZE};P.prototype.maxOpsPerScript=function(){return this.isAfterGenesis()?P.UNLIMITED:P.MAX_OPS_PER_SCRIPT};P.prototype.maxScriptNumLength=function(){return this.isAfterChronicle()?P.MAX_SCRIPT_NUM_LENGTH_AFTER_CHRONICLE:this.isAfterGenesis()?P.MAX_SCRIPT_NUM_LENGTH_AFTER_GENESIS:P.MAXIMUM_ELEMENT_SIZE};P.prototype.maxStackSize=function(){return this.isAfterGenesis()?P.UNLIMITED:P.MAX_STACK_SIZE};P.prototype.maxStackMemoryUsage=function(){return this.isAfterGenesis()?P.MAX_STACK_MEMORY_USAGE_AFTER_GENESIS:P.UNLIMITED};P.prototype.stackMemoryUsage=function(){let e=P.STACK_ELEMENT_OVERHEAD,t=(this.stack.length+this.altstack.length)*e;for(let r=0;r<this.stack.length;r++)t+=this.stack[r].length;for(let r=0;r<this.altstack.length;r++)t+=this.altstack[r].length;return t};P.prototype.checkStackLimits=function(){if(this.stack.length+this.altstack.length>this.maxStackSize())return"SCRIPT_ERR_STACK_SIZE";let e=this.maxStackMemoryUsage();return e!==P.UNLIMITED&&this.stackMemoryUsage()>e?"SCRIPT_ERR_STACK_SIZE":null};P.prototype.maxPubKeysPerMultisig=function(){return this.isAfterGenesis()?P.MAX_PUBKEYS_PER_MULTISIG_AFTER_GENESIS:20};P._isMinimallyEncoded=function(e,t){return t=t||P.MAXIMUM_ELEMENT_SIZE,!(e.length>t||e.length>0&&(e[e.length-1]&127)===0&&(e.length<=1||(e[e.length-2]&128)===0))};P._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;e=d.Buffer.from(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("")};P.prototype.evaluate=function(){if(this.script.toBuffer().length>this.maxScriptSize())return this.errstr="SCRIPT_ERR_SCRIPT_SIZE",!1;try{for(;this.pc<this.script.chunks.length;){let r={pc:this.pc,opcode:N.fromNumber(this.script.chunks[this.pc].opcodenum)};var e=this.step();if(!e)return!1;if(this._callbackStep(r),this.returned)return!0;let n=this.checkStackLimits();if(n)return this.errstr=n,!1}let t=this.checkStackLimits();if(t)return this.errstr=t,!1}catch(t){return this.errstr=t.scriptErr||"SCRIPT_ERR_UNKNOWN_ERROR: "+t,!1}return this.vfExec.length>0?(this.errstr="SCRIPT_ERR_UNBALANCED_CONDITIONAL",!1):!0};P.prototype._callbackStep=function(e){if(typeof this.stepListener=="function")try{this.stepListener(e,xx(this.stack),xx(this.altstack))}catch(t){console.log(`Error in Step callback:${t}`)}};P.prototype.checkLockTime=function(e){if(!(this.tx.nLockTime<P.LOCKTIME_THRESHOLD&&e.lt(P.LOCKTIME_THRESHOLD_BN)||this.tx.nLockTime>=P.LOCKTIME_THRESHOLD&&e.gte(P.LOCKTIME_THRESHOLD_BN))||e.gt(new he(this.tx.nLockTime)))return!1;var t=this.tx.inputs[this.nin];return!(!t||t.isFinal())};P.prototype.checkSequence=function(e){var t=this.tx.inputs[this.nin];if(!t)return!1;var r=t.sequenceNumber;if(this.tx.version<2||r&P.SEQUENCE_LOCKTIME_DISABLE_FLAG)return!1;var n=P.SEQUENCE_LOCKTIME_TYPE_FLAG|P.SEQUENCE_LOCKTIME_MASK,i=new he(r&n),o=e.and(new he(n)),s=new he(P.SEQUENCE_LOCKTIME_TYPE_FLAG);return!(!(i.lt(s)&&o.lt(s)||i.gte(s)&&o.gte(s))||o.gt(i))};function hC(e,t){let r=e;for(;r.length<t;)r=d.Buffer.concat([d.Buffer.from([0]),r]);return r}function Ax(e){var t=d.Buffer.alloc(4);return t.writeInt32LE(e|0,0),t}P.prototype.step=function(){var e=this;function t(oe){return e.stack[e.stack.length+oe]}function r(oe){switch(oe){case N.OP_2MUL:case N.OP_2DIV:if(!e.isAfterChronicle())return!0;break;case N.OP_INVERT:case N.OP_MUL:case N.OP_LSHIFT:case N.OP_RSHIFT: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&P.SCRIPT_VERIFY_MINIMALDATA)!==0&&this.enforceNonMalleability(),i,o,s,a,f,l,y,g,v,E,T,M,U,F,V,z,G,ie=this.script.chunks[this.pc];this.pc++;var ee=ie.opcodenum,pe=this.vfExec.indexOf(!1)===-1&&(!this.nonTopLevelReturnAfterGenesis||ee===N.OP_RETURN);if(Dc.isUndefined(ee))return this.errstr="SCRIPT_ERR_UNDEFINED_OPCODE",!1;if(ie.buf&&ie.buf.length>this.maxScriptElementSize())return this.errstr="SCRIPT_ERR_PUSH_SIZE",!1;if(ee>N.OP_16&&++this.nOpCount>this.maxOpsPerScript())return this.errstr="SCRIPT_ERR_OP_COUNT",!1;if(r(ee)&&(!this.isAfterGenesis()||pe))return this.errstr="SCRIPT_ERR_DISABLED_OPCODE",!1;if(pe&&ee>=0&&ee<=N.OP_PUSHDATA4){if(n&&!this.script.checkMinimalPush(this.pc-1))return this.errstr="SCRIPT_ERR_MINIMALDATA",!1;if(!ie.buf)this.stack.push(P.false);else{if(ie.len!==ie.buf.length)return this.errstr="SCRIPT_ERR_BAD_OPCODE",!1;this.stack.push(ie.buf)}}else if(pe||N.OP_IF<=ee&&ee<=N.OP_ENDIF)switch(ee){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:f=ee-(N.OP_1-1),i=new he(f).toScriptNumBuffer(),this.stack.push(i);break;case N.OP_NOP:break;case N.OP_NOP2:case N.OP_CHECKLOCKTIMEVERIFY:if(!(this.flags&P.SCRIPT_VERIFY_CHECKLOCKTIMEVERIFY)||this.isAfterGenesis()){if(this.flags&P.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 le=he.fromScriptNumBuffer(this.stack[this.stack.length-1],n,5);if(le.lt(new he(0)))return this.errstr="SCRIPT_ERR_NEGATIVE_LOCKTIME",!1;if(!this.checkLockTime(le))return this.errstr="SCRIPT_ERR_UNSATISFIED_LOCKTIME",!1;break;case N.OP_NOP3:case N.OP_CHECKSEQUENCEVERIFY:if(!(this.flags&P.SCRIPT_VERIFY_CHECKSEQUENCEVERIFY)||this.isAfterGenesis()){if(this.flags&P.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 me=he.fromScriptNumBuffer(t(-1),n,5);if(me.lt(new he(0)))return this.errstr="SCRIPT_ERR_NEGATIVE_LOCKTIME",!1;if((me&P.SEQUENCE_LOCKTIME_DISABLE_FLAG)!==0)break;if(!this.checkSequence(me))return this.errstr="SCRIPT_ERR_UNSATISFIED_LOCKTIME",!1;break;case N.OP_NOP1:case N.OP_NOP9:case N.OP_NOP10:if(this.flags&P.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.isAfterChronicle()){if(this.flags&P.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 I=this.maxScriptNumLength(),u=he.fromScriptNumBuffer(t(-1),n,I);if(u.isNeg())return this.errstr="SCRIPT_ERR_INVALID_NUMBER_RANGE",!1;this.stack.pop();var h=he.fromScriptNumBuffer(t(-1),n,I);this.stack.pop();var m=u.toNumber(),S=h.isNeg(),w=h.abs(),R;if(ee===N.OP_LSHIFTNUM){var A=h.toScriptNumBuffer().length;if(A+Math.floor(m/8)>I)return this.errstr="SCRIPT_ERR_SCRIPTNUM_OVERFLOW",!1;R=w.shln(m)}else R=m>=w.bitLength()?new he(0):w.shrn(m);if(S&&!R.isZero()&&(R=R.neg()),R.toScriptNumBuffer().length>I)return this.errstr="SCRIPT_ERR_SCRIPTNUM_OVERFLOW",!1;this.stack.push(R.toScriptNumBuffer());break;case N.OP_VER:if(!this.isAfterChronicle())return this.errstr="SCRIPT_ERR_BAD_OPCODE",!1;if(this.tx==null)return this.errstr="SCRIPT_ERR_UNKNOWN_ERROR",!1;this.stack.push(Ax(this.tx.version));break;case N.OP_VERIF:case N.OP_VERNOTIF:if(!this.isAfterChronicle()){if(this.isAfterGenesis()&&!pe)break;return this.errstr="SCRIPT_ERR_BAD_OPCODE",!1}if(z=!1,pe){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;i=t(-1),z=i.length===4&&i.equals(Ax(this.tx.version)),ee===N.OP_VERNOTIF&&(z=!z),this.stack.pop()}this.vfExec.push(z),this.vfElse.push(!1);break;case N.OP_IF:case N.OP_NOTIF:if(z=!1,pe){if(this.stack.length<1)return this.errstr="SCRIPT_ERR_UNBALANCED_CONDITIONAL",!1;if(i=t(-1),this.flags&P.SCRIPT_VERIFY_MINIMALIF&&(i.length>1||i.length===1&&i[0]!==1)&&this.enforceNonMalleability())return this.errstr="SCRIPT_ERR_MINIMALIF",!1;z=P.castToBool(i),ee===N.OP_NOTIF&&(z=!z),this.stack.pop()}this.vfExec.push(z),this.vfElse.push(!1);break;case N.OP_ELSE:if(this.vfExec.length===0||this.vfElse[this.vfElse.length-1]&&this.isAfterGenesis())return this.errstr="SCRIPT_ERR_UNBALANCED_CONDITIONAL",!1;this.vfExec[this.vfExec.length-1]=!this.vfExec[this.vfExec.length-1],this.vfElse[this.vfElse.length-1]=!0;break;case N.OP_ENDIF:if(this.vfExec.length===0)return this.errstr="SCRIPT_ERR_UNBALANCED_CONDITIONAL",!1;this.vfExec.pop(),this.vfElse.pop();break;case N.OP_VERIFY:if(this.stack.length<1)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;if(i=t(-1),z=P.castToBool(i),z)this.stack.pop();else return this.errstr="SCRIPT_ERR_VERIFY",!1;break;case N.OP_RETURN:if(this.isAfterGenesis()){if(this.vfExec.length===0){this.returned=!0;break}this.nonTopLevelReturnAfterGenesis=!0;break}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;o=t(-2),s=t(-1),this.stack.push(d.Buffer.from(o)),this.stack.push(d.Buffer.from(s));break;case N.OP_3DUP:if(this.stack.length<3)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;o=t(-3),s=t(-2);var _=t(-1);this.stack.push(d.Buffer.from(o)),this.stack.push(d.Buffer.from(s)),this.stack.push(d.Buffer.from(_));break;case N.OP_2OVER:if(this.stack.length<4)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;o=t(-4),s=t(-3),this.stack.push(d.Buffer.from(o)),this.stack.push(d.Buffer.from(s));break;case N.OP_2ROT:if(this.stack.length<6)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;a=this.stack.splice(this.stack.length-6,2),this.stack.push(a[0]),this.stack.push(a[1]);break;case N.OP_2SWAP:if(this.stack.length<4)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;a=this.stack.splice(this.stack.length-4,2),this.stack.push(a[0]),this.stack.push(a[1]);break;case N.OP_IFDUP:if(this.stack.length<1)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;i=t(-1),z=P.castToBool(i),z&&this.stack.push(d.Buffer.from(i));break;case N.OP_DEPTH:i=new he(this.stack.length).toScriptNumBuffer(),this.stack.push(i);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(i=t(-1),g=he.fromScriptNumBuffer(i,n,this.maxScriptNumLength()),f=g.toNumber(),this.stack.pop(),f<0||f>=this.stack.length)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;i=t(-f-1),ee===N.OP_ROLL&&this.stack.splice(this.stack.length-f-1,1),this.stack.push(d.Buffer.from(i));break;case N.OP_ROT:if(this.stack.length<3)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;l=t(-3),y=t(-2);var c=t(-1);this.stack[this.stack.length-3]=y,this.stack[this.stack.length-2]=c,this.stack[this.stack.length-1]=l;break;case N.OP_SWAP:if(this.stack.length<2)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;l=t(-2),y=t(-1),this.stack[this.stack.length-2]=y,this.stack[this.stack.length-1]=l;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;g=new he(t(-1).length),this.stack.push(g.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(o=t(-2),s=t(-1),o.length!==s.length)return this.errstr="SCRIPT_ERR_INVALID_OPERAND_SIZE",!1;switch(a=d.Buffer.alloc(o.length),ee){case N.OP_AND:for(let oe=0;oe<o.length;oe++)a[oe]=o[oe]&s[oe];break;case N.OP_OR:for(let oe=0;oe<o.length;oe++)a[oe]=o[oe]|s[oe];break;case N.OP_XOR:for(let oe=0;oe<o.length;oe++)a[oe]=o[oe]^s[oe];break;default:break}this.stack.pop(),this.stack[this.stack.length-1]=a;break;case N.OP_INVERT:if(this.stack.length<1)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;i=t(-1),o=d.Buffer.alloc(i.length);for(let oe=0;oe<i.length;oe++)o[oe]=~i[oe]&255;this.stack[this.stack.length-1]=o;break;case N.OP_LSHIFT:case N.OP_RSHIFT:if(this.stack.length<2)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;if(o=t(-2),o.length===0)this.stack.pop();else{if(v=new he(o),E=he.fromScriptNumBuffer(t(-1),n,this.maxScriptNumLength()),f=E.toNumber(),f<0)return this.errstr="SCRIPT_ERR_INVALID_NUMBER_RANGE",!1;this.stack.pop(),this.stack.pop();let oe;ee===N.OP_LSHIFT&&(oe=v.ushln(f)),ee===N.OP_RSHIFT&&(oe=v.ushrn(f));let Pe=hC(d.Buffer.from(oe.toArray().slice(o.length*-1)),o.length);this.stack.push(Pe)}break;case N.OP_EQUAL:case N.OP_EQUALVERIFY:if(this.stack.length<2)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;o=t(-2),s=t(-1);var b=o.toString("hex")===s.toString("hex");if(this.stack.pop(),this.stack.pop(),this.stack.push(b?P.true:P.false),ee===N.OP_EQUALVERIFY)if(b)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(i=t(-1),g=he.fromScriptNumBuffer(i,n,this.maxScriptNumLength()),ee){case N.OP_2MUL:g=g.mul(new he(2));break;case N.OP_2DIV:g=g.div(new he(2));break;case N.OP_1ADD:g=g.add(he.One);break;case N.OP_1SUB:g=g.sub(he.One);break;case N.OP_NEGATE:g=g.neg();break;case N.OP_ABS:g.cmp(he.Zero)<0&&(g=g.neg());break;case N.OP_NOT:g=new he((g.cmp(he.Zero)===0)+0);break;case N.OP_0NOTEQUAL:g=new he((g.cmp(he.Zero)!==0)+0);break}this.stack.pop(),this.stack.push(g.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(v=he.fromScriptNumBuffer(t(-2),n,this.maxScriptNumLength()),E=he.fromScriptNumBuffer(t(-1),n,this.maxScriptNumLength()),g=new he(0),ee){case N.OP_ADD:g=v.add(E);break;case N.OP_SUB:g=v.sub(E);break;case N.OP_MUL:g=v.mul(E);break;case N.OP_DIV:if(E.cmp(he.Zero)===0)return this.errstr="SCRIPT_ERR_DIV_BY_ZERO",!1;g=v.div(E);break;case N.OP_MOD:if(E.cmp(he.Zero)===0)return this.errstr="SCRIPT_ERR_MOD_BY_ZERO",!1;g=v.mod(E);break;case N.OP_BOOLAND:g=new he((v.cmp(he.Zero)!==0&&E.cmp(he.Zero)!==0)+0);break;case N.OP_BOOLOR:g=new he((v.cmp(he.Zero)!==0||E.cmp(he.Zero)!==0)+0);break;case N.OP_NUMEQUAL:g=new he((v.cmp(E)===0)+0);break;case N.OP_NUMEQUALVERIFY:g=new he((v.cmp(E)===0)+0);break;case N.OP_NUMNOTEQUAL:g=new he((v.cmp(E)!==0)+0);break;case N.OP_LESSTHAN:g=new he((v.cmp(E)<0)+0);break;case N.OP_GREATERTHAN:g=new he((v.cmp(E)>0)+0);break;case N.OP_LESSTHANOREQUAL:g=new he((v.cmp(E)<=0)+0);break;case N.OP_GREATERTHANOREQUAL:g=new he((v.cmp(E)>=0)+0);break;case N.OP_MIN:g=v.cmp(E)<0?v:E;break;case N.OP_MAX:g=v.cmp(E)>0?v:E;break}if(this.stack.pop(),this.stack.pop(),this.stack.push(g.toScriptNumBuffer()),ee===N.OP_NUMEQUALVERIFY)if(P.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;v=he.fromScriptNumBuffer(t(-3),n,this.maxScriptNumLength()),E=he.fromScriptNumBuffer(t(-2),n,this.maxScriptNumLength());var k=he.fromScriptNumBuffer(t(-1),n,this.maxScriptNumLength());z=E.cmp(v)<=0&&v.cmp(k)<0,this.stack.pop(),this.stack.pop(),this.stack.pop(),this.stack.push(z?P.true:P.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;i=t(-1);var L;ee===N.OP_RIPEMD160?L=Ka.ripemd160(i):ee===N.OP_SHA1?L=Ka.sha1(i):ee===N.OP_SHA256?L=Ka.sha256(i):ee===N.OP_HASH160?L=Ka.sha256ripemd160(i):ee===N.OP_HASH256&&(L=Ka.sha256sha256(i)),this.stack.pop(),this.stack.push(L);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(T=t(-2),M=t(-1),!this.checkSignatureEncoding(T)||!this.checkPubkeyEncoding(M))return!1;U=new Uc().set({chunks:this.script.chunks.slice(this.pbegincodehash)}),Ix(U,T,this.flags);try{F=qn.fromTxFormat(T),V=Mp.fromBuffer(M,!1),G=this.tx.verifySignature(F,V,this.nin,U,this.satoshisBN,this.flags)}catch{G=!1}if(!G&&this.flags&P.SCRIPT_VERIFY_NULLFAIL&&T.length&&this.enforceNonMalleability())return this.errstr="SCRIPT_ERR_NULLFAIL",!1;if(this.stack.pop(),this.stack.pop(),this.stack.push(G?P.true:P.false),ee===N.OP_CHECKSIGVERIFY)if(G)this.stack.pop();else return this.errstr="SCRIPT_ERR_CHECKSIGVERIFY",!1;break;case N.OP_CHECKMULTISIG:case N.OP_CHECKMULTISIGVERIFY:var H=1;if(this.stack.length<H)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;var W=he.fromScriptNumBuffer(t(-H),n,4).toNumber();if(W<0||W>this.maxPubKeysPerMultisig())return this.errstr="SCRIPT_ERR_PUBKEY_COUNT",!1;if(this.nOpCount+=W,this.nOpCount>this.maxOpsPerScript())return this.errstr="SCRIPT_ERR_OP_COUNT",!1;var te=++H;H+=W;var X=W+2;if(this.stack.length<H)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;var ue=he.fromScriptNumBuffer(t(-H),n,4).toNumber();if(ue<0||ue>W)return this.errstr="SCRIPT_ERR_SIG_COUNT",!1;var fe=++H;if(H+=ue,this.stack.length<H)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;U=new Uc().set({chunks:this.script.chunks.slice(this.pbegincodehash)});for(var O=0;O<ue;O++)T=t(-fe-O),Ix(U,T,this.flags);for(G=!0;G&&ue>0;){if(T=t(-fe),M=t(-te),!this.checkSignatureEncoding(T)||!this.checkPubkeyEncoding(M))return!1;var C;try{F=qn.fromTxFormat(T),V=Mp.fromBuffer(M,!1),C=this.tx.verifySignature(F,V,this.nin,U,this.satoshisBN,this.flags)}catch{C=!1}C&&(fe++,ue--),te++,W--,ue>W&&(G=!1)}for(;H-- >1;){if(!G&&this.flags&P.SCRIPT_VERIFY_NULLFAIL&&!X&&t(-1).length&&this.enforceNonMalleability())return this.errstr="SCRIPT_ERR_NULLFAIL",!1;X>0&&X--,this.stack.pop()}if(this.stack.length<1)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;if(this.flags&P.SCRIPT_VERIFY_NULLDUMMY&&t(-1).length&&this.enforceNonMalleability())return this.errstr="SCRIPT_ERR_SIG_NULLDUMMY",!1;if(this.stack.pop(),this.stack.push(G?P.true:P.false),ee===N.OP_CHECKMULTISIGVERIFY)if(G)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(o=t(-2),s=t(-1),o.length+s.length>this.maxScriptElementSize())return this.errstr="SCRIPT_ERR_PUSH_SIZE",!1;this.stack[this.stack.length-2]=d.Buffer.concat([o,s]),this.stack.pop();break;case N.OP_SPLIT:if(this.stack.length<2)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;o=t(-2);var D=he.fromScriptNumBuffer(t(-1),n,this.maxScriptNumLength()).toNumber();if(D<0||D>o.length)return this.errstr="SCRIPT_ERR_INVALID_SPLIT_RANGE",!1;var K=d.Buffer.from(o);this.stack[this.stack.length-2]=K.slice(0,D),this.stack[this.stack.length-1]=K.slice(D);break;case N.OP_LEFT:case N.OP_RIGHT:if(!this.isAfterChronicle()){if(this.flags&P.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(o=t(-2),f=he.fromScriptNumBuffer(t(-1),n,this.maxScriptNumLength()).toNumber(),f<0||f>o.length)return this.errstr="SCRIPT_ERR_INVALID_NUMBER_RANGE",!1;this.stack.pop(),ee===N.OP_LEFT?this.stack[this.stack.length-1]=d.Buffer.from(o).slice(0,f):this.stack[this.stack.length-1]=d.Buffer.from(o).slice(o.length-f);break;case N.OP_SUBSTR:if(!this.isAfterChronicle()){if(this.flags&P.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;o=t(-3);var re=he.fromScriptNumBuffer(t(-1),n,this.maxScriptNumLength()).toNumber(),J=he.fromScriptNumBuffer(t(-2),n,this.maxScriptNumLength()).toNumber();if(J<0||J>=o.length||re<0||re>o.length-J)return this.errstr="SCRIPT_ERR_INVALID_NUMBER_RANGE",!1;this.stack.pop(),this.stack.pop(),this.stack[this.stack.length-1]=d.Buffer.from(o).slice(J,J+re);break;case N.OP_NUM2BIN:if(this.stack.length<2)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;var Q=he.fromScriptNumBuffer(t(-1),n,this.maxScriptNumLength()).toNumber();if(Q<0||Q>this.maxScriptElementSize())return this.errstr="SCRIPT_ERR_PUSH_SIZE",!1;this.stack.pop();var se=t(-1);if(se=P._minimallyEncode(se),se.length>Q)return this.errstr="SCRIPT_ERR_IMPOSSIBLE_ENCODING",!1;if(se.length===Q){this.stack[this.stack.length-1]=se;break}var ce=0;se.length>0&&(se=d.Buffer.from(se),ce=se[se.length-1]&128,se[se.length-1]&=127);var ae=d.Buffer.alloc(Q);se.copy(ae,0);for(var _e=se.length-1;_e++<Q-2;)ae[_e]=0;ae[_e]=ce,this.stack[this.stack.length-1]=ae;break;case N.OP_BIN2NUM:if(this.stack.length<1)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;if(o=t(-1),s=P._minimallyEncode(o),this.stack[this.stack.length-1]=s,!P._isMinimallyEncoded(s,this.maxScriptNumLength()))return this.errstr="SCRIPT_ERR_INVALID_NUMBER_RANGE",!1;break;default:return this.errstr="SCRIPT_ERR_BAD_OPCODE",!1}return!0}});var qr=B((yq,Cp)=>{p();Cp.exports=gp();Cp.exports.Interpreter=Mc()});var ro=B((vq,Nx)=>{"use strict";p();var Lp=ze(),Hn=Le(),dC=Jn(),Tx=Vd(),Rr=ya(),Px=Jt(),Bx=pr(),Dp=Ar();function ne(e,t,r){if(!(this instanceof ne))return new ne(e,t,r);if(Lp.isArray(e)&&Lp.isNumber(t))return ne.createMultisig(e,t,r);if(e instanceof ne)return e;if(Hn.checkArgument(e,"First argument is required, please include address data.","guide/address.html"),t&&!Rr.get(t))throw new TypeError('Second argument must be "livenet", "testnet", or "regtest".');if(r&&r!==ne.PayToPublicKeyHash&&r!==ne.PayToScriptHash)throw new TypeError('Third argument must be "pubkeyhash" or "scripthash".');var n=this._classifyArguments(e,t,r);return n.network=n.network||Rr.get(t)||Rr.defaultNetwork,n.type=n.type||r||ne.PayToPublicKeyHash,Bx.defineImmutable(this,{hashBuffer:n.hashBuffer,network:n.network,type:n.type}),this}ne.prototype._classifyArguments=function(e,t,r){if((e instanceof d.Buffer||e instanceof Uint8Array)&&e.length===20)return ne._transformHash(e);if((e instanceof d.Buffer||e instanceof Uint8Array)&&e.length===21)return ne._transformBuffer(e,t,r);if(e instanceof Dp)return ne._transformPublicKey(e);if(e instanceof Ga())return ne._transformScript(e,t);if(typeof e=="string")return ne._transformString(e,t,r);if(Lp.isObject(e))return ne._transformObject(e);throw new TypeError("First argument is an unrecognized data format.")};ne.PayToPublicKeyHash="pubkeyhash";ne.PayToScriptHash="scripthash";ne._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};ne._transformObject=function(e){return Hn.checkArgument(e.hash||e.hashBuffer,"Must provide a `hash` or `hashBuffer` property"),Hn.checkArgument(e.type,"Must provide a `type` property"),{hashBuffer:e.hash?d.Buffer.from(e.hash,"hex"):e.hashBuffer,network:Rr.get(e.network)||Rr.defaultNetwork,type:e.type}};ne._classifyFromVersion=function(e){var t={},r=Rr.get(e[0],"pubkeyhash"),n=Rr.get(e[0],"scripthash");return r?(t.network=r,t.type=ne.PayToPublicKeyHash):n&&(t.network=n,t.type=ne.PayToScriptHash),t};ne._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=Rr.get(t),o=ne._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};ne._transformPublicKey=function(e){var t={};if(!(e instanceof Dp))throw new TypeError("Address must be an instance of PublicKey.");return t.hashBuffer=Px.sha256ripemd160(e.toBuffer()),t.type=ne.PayToPublicKeyHash,t};ne._transformScript=function(e,t){Hn.checkArgument(e instanceof Ga(),"script must be a Script instance");var r=e.getAddressInfo(t);if(!r)throw new dC.Script.CantDeriveAddress(e);return r};ne.createMultisig=function(e,t,r){return r=r||e[0].network||Rr.defaultNetwork,ne.payingTo(Ga().buildMultisigOut(e,t),r)};ne._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=Rr.get(t);if(t&&!n)throw new TypeError("Unknown network");var i=Tx.decode(e);return ne._transformBuffer(i,t,r)};ne.fromPublicKey=function(e,t){var r=ne._transformPublicKey(e);return t=t||Rr.defaultNetwork,new ne(r.hashBuffer,t,r.type)};ne.fromPrivateKey=function(e,t){let r=Dp.fromPrivateKey(e);return t=t||e.network||Rr.defaultNetwork,ne.fromPublicKey(r,t)};ne.fromPublicKeyHash=function(e,t){var r=ne._transformHash(e);return new ne(r.hashBuffer,t,ne.PayToPublicKeyHash)};ne.fromScriptHash=function(e,t){Hn.checkArgument(e,"hash parameter is required");var r=ne._transformHash(e);return new ne(r.hashBuffer,t,ne.PayToScriptHash)};ne.payingTo=function(e,t){return Hn.checkArgument(e,"script is required"),Hn.checkArgument(e instanceof Ga(),"script must be instance of Script"),ne.fromScriptHash(Px.sha256ripemd160(e.toBuffer()),t)};ne.fromScript=function(e,t){Hn.checkArgument(e instanceof Ga(),"script must be a Script instance");var r=ne._transformScript(e,t);return new ne(r.hashBuffer,t,r.type)};ne.fromBuffer=function(e,t,r){var n=ne._transformBuffer(e,t,r);return new ne(n.hashBuffer,n.network,n.type)};ne.fromHex=function(e,t,r){return ne.fromBuffer(d.Buffer.from(e,"hex"),t,r)};ne.fromString=function(e,t,r){var n=ne._transformString(e,t,r);return new ne(n.hashBuffer,n.network,n.type)};ne.fromObject=function(t){Hn.checkState(Bx.isHexa(t.hash),'Unexpected hash property, "'+t.hash+'", expected to be hex.');var r=d.Buffer.from(t.hash,"hex");return new ne(r,t.network,t.type)};ne.getValidationError=function(e,t,r){var n;try{new ne(e,t,r)}catch(i){n=i}return n};ne.isValid=function(e,t,r){return!ne.getValidationError(e,t,r)};ne.prototype.isPayToPublicKeyHash=function(){return this.type===ne.PayToPublicKeyHash};ne.prototype.isPayToScriptHash=function(){return this.type===ne.PayToScriptHash};ne.prototype.toBuffer=function(){var e=d.Buffer.from([this.network[this.type]]),t=d.Buffer.concat([e,this.hashBuffer]);return t};ne.prototype.toHex=function(){return this.toBuffer().toString("hex")};ne.prototype.toObject=ne.prototype.toJSON=function(){return{hash:this.hashBuffer.toString("hex"),type:this.type,network:this.network.toString()}};ne.prototype.inspect=function(){return"<Address: "+this.toString()+", type: "+this.type+", network: "+this.network+">"};ne.prototype.toString=function(){return Tx.encode(this.toBuffer())};Nx.exports=ne;function Ga(){return qr()}});var no=B((_q,Lx)=>{"use strict";p();var Fc=ze(),pC=ro(),Mx=Vd(),Si=wr(),kx=pr(),hn=ya(),Fp=fi(),gC=Ar(),yC=Qs(),Cx=Le(),Up="[REDACTED]";function ve(e,t){if(!(this instanceof ve))return new ve(e,t);if(e instanceof ve)return e;var r=this._classifyArguments(e,t);if(!r.bn||r.bn.cmp(new Si(0))===0)throw new TypeError("Number can not be equal to zero, undefined, null or false");if(!r.bn.lt(Fp.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 kx.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}ve.prototype._classifyArguments=function(e,t){var r={compressed:!0,network:t?hn.get(t):hn.defaultNetwork};if(Fc.isUndefined(e)||Fc.isNull(e))r.bn=ve._getRandomBN();else if(e instanceof Si)r.bn=e;else if(e instanceof d.Buffer||e instanceof Uint8Array)r=ve._transformBuffer(e,t);else if(e.bn&&e.network)r=ve._transformObject(e);else if(!t&&hn.get(e))r.bn=ve._getRandomBN(),r.network=hn.get(e);else if(typeof e=="string")kx.isHexa(e)?r.bn=new Si(d.Buffer.from(e,"hex")):r=ve._transformWIF(e,t);else throw new TypeError("First argument is an unrecognized data type.");return r};ve._getRandomBN=function(){var e,t;do{var r=yC.getRandomBuffer(32);t=Si.fromBuffer(r),e=t.lt(Fp.getN())}while(!e);return t};ve._transformBuffer=function(e,t){var r={};if(e.length===32)return ve._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=Si.fromBuffer(e.slice(1,33)),r};ve._transformBNBuffer=function(e,t,r){var n={};return n.network=hn.get(t)||hn.defaultNetwork,n.bn=Si.fromBuffer(e),n.compressed=r===void 0?!0:!!r,n};ve._transformWIF=function(e,t){return ve._transformBuffer(Mx.decode(e),t)};ve.fromBuffer=function(e,t,r){return r!==void 0&&e&&e.length===32?new ve(ve._transformBNBuffer(e,t,r)):new ve(e,t)};ve.fromHex=function(e,t,r){return ve.fromBuffer(d.Buffer.from(e,"hex"),t,r)};ve._transformObject=function(e){if(e.bn instanceof Si)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===Up)throw new TypeError('Invalid private key: `bn` is "'+Up+'". 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 Si(e.bn,"hex");if(t.isZero()||t.gte(Fp.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}};ve.fromString=ve.fromWIF=function(e,t){return Cx.checkArgument(Fc.isString(e),"First argument is expected to be a string."),new ve(e,t)};ve.fromObject=ve.fromJSON=function(e){return Cx.checkArgument(Fc.isObject(e),"First argument is expected to be an object."),new ve(e)};ve.fromRandom=function(e){var t=ve._getRandomBN();return new ve(t,e)};ve.getValidationError=function(e,t){var r;try{new ve(e,t)}catch(n){r=n}return r};ve.isValid=function(e,t){return e?!ve.getValidationError(e,t):!1};ve.prototype.toString=function(){return this.toWIF()};ve.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})]),Mx.encode(r)};ve.prototype.toBigNumber=function(){return this.bn};ve.prototype.toBuffer=function(){return this.bn.toBuffer({size:32})};ve.prototype.toHex=function(){return this.toBuffer().toString("hex")};ve.prototype.toPublicKey=function(){return this._pubkey||(this._pubkey=gC.fromPrivateKey(this)),this._pubkey};ve.prototype.toAddress=function(e){var t=this.toPublicKey();return pC.fromPublicKey(t,e||this.network)};ve.prototype.toObject=function(){return{bn:this.bn.toString("hex"),compressed:this.compressed,network:this.network.toString()}};ve.prototype.toJSON=function(){return{bn:Up,compressed:this.compressed,network:this.network.toString()}};ve.prototype.inspect=function(){var e=this.compressed?"":", uncompressed";return"<PrivateKey: "+this.toHex()+", network: "+this.network+e+">"};Lx.exports=ve});var Ar=B((wq,Ux)=>{"use strict";p();var us=wr(),fs=fi(),mC=Jt(),vC=pr(),Dx=ya(),qp=ze(),oo=Le();function de(e,t){if(!(this instanceof de))return new de(e,t);if(oo.checkArgument(e,"First argument is required, please include public key data."),e instanceof de)return e;t=t||{};var r=this._classifyArgs(e,t);return r.point.validate(),vC.defineImmutable(this,{point:r.point,compressed:r.compressed,network:r.network||Dx.defaultNetwork}),this}de.prototype._classifyArgs=function(e,t){var r={compressed:qp.isUndefined(t.compressed)||t.compressed};if(e instanceof fs)r.point=e;else if(e.x&&e.y)r=de._transformObject(e);else if(typeof e=="string")r=de._transformDER(d.Buffer.from(e,"hex"));else if(de._isBuffer(e))r=de._transformDER(e);else if(de._isPrivateKey(e))r=de._transformPrivateKey(e);else throw new TypeError("First argument is an unrecognized data format.");return r.network||(r.network=qp.isUndefined(t.network)?void 0:Dx.get(t.network)),r};de._isPrivateKey=function(e){var t=no();return e instanceof t};de._isBuffer=function(e){return e instanceof d.Buffer||e instanceof Uint8Array};de._transformPrivateKey=function(e){oo.checkArgument(de._isPrivateKey(e),"Must be an instance of PrivateKey");var t={};return t.point=fs.getG().mul(e.bn),t.compressed=e.compressed,t.network=e.network,t};de._transformDER=function(e,t){oo.checkArgument(de._isBuffer(e),"Must be a buffer of DER encoded public key");var r={};t=qp.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 us(o),i=new us(s),r.point=new fs(n,i),r.compressed=!1}else if(e[0]===3)o=e.slice(1),n=new us(o),r=de._transformX(!0,n),r.compressed=!0;else if(e[0]===2)o=e.slice(1),n=new us(o),r=de._transformX(!1,n),r.compressed=!0;else throw new TypeError("Invalid DER format public key");return r};de._transformX=function(e,t){oo.checkArgument(typeof e=="boolean","Must specify whether y is odd or not (true or false)");var r={};return r.point=fs.fromX(e,t),r};de._transformObject=function(e){var t=new us(e.x,"hex"),r=new us(e.y,"hex"),n=new fs(t,r);return new de(n,{compressed:e.compressed})};de.fromPrivateKey=function(e){oo.checkArgument(de._isPrivateKey(e),"Must be an instance of PrivateKey");var t=de._transformPrivateKey(e);return new de(t.point,{compressed:t.compressed,network:t.network})};de.fromDER=de.fromBuffer=function(e,t){oo.checkArgument(de._isBuffer(e),"Must be a buffer of DER encoded public key");var r=de._transformDER(e,t);return new de(r.point,{compressed:r.compressed})};de.fromPoint=function(e,t){return oo.checkArgument(e instanceof fs,"First argument must be an instance of Point."),new de(e,{compressed:t})};de.fromHex=de.fromString=function(e,t){var r=d.Buffer.from(e,t||"hex"),n=de._transformDER(r);return new de(n.point,{compressed:n.compressed})};de.fromX=function(e,t){var r=de._transformX(e,t);return new de(r.point,{compressed:r.compressed})};de.getValidationError=function(e){var t;try{new de(e)}catch(r){t=r}return t};de.isValid=function(e){return!de.getValidationError(e)};de.prototype.toObject=de.prototype.toJSON=function(){return{x:this.point.getX().toString("hex",2),y:this.point.getY().toString("hex",2),compressed:this.compressed}};de.prototype.toBuffer=de.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])};de.prototype._getID=function(){return mC.sha256ripemd160(this.toBuffer())};de.prototype.toAddress=function(e){var t=ro();return t.fromPublicKey(this,e||this.network)};de.prototype.toString=de.prototype.toHex=function(){return this.toDER().toString("hex")};de.prototype.inspect=function(){return"<PublicKey: "+this.toHex()+(this.compressed?"":", uncompressed")+">"};Ux.exports=de});var Va=B((xq,qx)=>{"use strict";p();var Fx=Qs();function bC(){var e=Fx.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 _C(e){return Fx.getRandomBuffer(Math.ceil(e/2)).toString("hex").substring(0,e)}qx.exports={uuid4:bC,randomHex:_C}});var Vx=B((Oq,Gx)=>{"use strict";p();var Wa=Ar(),Hp=Jt(),jp=La(),Hx=nr(),Kp=no(),Bt=Le(),Aq=ze(),SC=Va();function jx(e,t){if(t=t||{},t.issuerPublicKey)return t.issuerPublicKey instanceof Wa?t.issuerPublicKey:Wa.fromString(t.issuerPublicKey);var r=e&&e.issuer;if(typeof r!="string")return null;try{var n=r.split("#")[0].split(":")[2];return n?Wa.fromString(n):null}catch{return null}}var cs={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"},Kx={create:function(e,t,r,n,i,o){o=o||{},Bt.checkArgument(typeof e=="string","Right type must be string"),Bt.checkArgument(typeof t=="string","Issuer DID must be string"),Bt.checkArgument(typeof r=="string","Subject DID must be string"),Bt.checkArgument(n&&typeof n=="object","Claim must be object");var s=Object.values(cs);Bt.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||{},Bt.checkArgument(typeof e=="string","Right type must be string"),Bt.checkArgument(typeof t=="string","Issuer DID must be string"),Bt.checkArgument(typeof r=="string","Subject DID must be string"),Bt.checkArgument(n&&typeof n=="object","Claim must be object"),Bt.checkArgument(i instanceof Kp,"Invalid issuer private key");var s=Object.values(cs);Bt.checkArgument(s.includes(e),"Invalid right type: "+e);try{var a=this.create(e,t,r,n,i,o),f=this._signToken(a,i);return{success:!0,rightToken:f,tokenHash:f.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:f,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:f.id,tokenHash:f.tokenHash,type:e,issuer:t,subject:r,issuedAt:f.issuanceDate}},notifyParties:{endpoint:"POST /notifications/right-issued",data:{tokenId:f.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||{},Bt.checkArgument(e&&typeof e=="object","Invalid token"),Bt.checkArgument(typeof t=="string","New owner DID must be string"),Bt.checkArgument(r instanceof Kp,"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=jx({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}},f=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:f.id,transferDate:f.issuanceDate,from:e.credentialSubject.id,to:t}),delete l.proof;var y=this._signToken(l,r);return{success:!0,newToken:y,transferProof:f,transferId:f.id,externalOperations:{recordTransfer:{endpoint:"POST /rights/transfers",data:{originalTokenId:e.id,newTokenId:y.id,transferProof:f,fromOwner:e.credentialSubject.id,toOwner:t,transferDate:f.issuanceDate}},updateOwnership:{endpoint:"PUT /rights/tokens/"+e.id+"/ownership",data:{newOwner:t,transferId:f.id,transferDate:f.issuanceDate,previousOwner:e.credentialSubject.id}},notifyParties:{endpoint:"POST /notifications/right-transferred",data:{originalTokenId:e.id,newTokenId:y.id,fromOwner:e.credentialSubject.id,toOwner:t,rightType:e.credentialSubject.rightType}},auditTransfer:{endpoint:"POST /audit/right-transfer",data:{originalTokenId:e.id,newTokenId:y.id,transferId:f.id,fromOwner:e.credentialSubject.id,toOwner:t,transferredAt:f.issuanceDate}}}}}catch(g){return{success:!1,error:g.message}}},prepareObligationToken:function(e,t,r,n){Bt.checkArgument(e&&typeof e=="object","Invalid right token"),Bt.checkArgument(typeof t=="string","Obligor DID must be string"),Bt.checkArgument(r&&typeof r=="object","Obligation must be object"),Bt.checkArgument(n instanceof Kp,"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){Bt.checkArgument(typeof e=="string","Right type must be string");var t=Object.values(cs),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 cs},verifyToken:function(e,t){var r=[];try{if(Bt.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 Wa?t:Wa.fromString(t),i=this._canonicalizeToken(e),o=Hp.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=Hx.fromDER(d.Buffer.from(s[2],"base64url")),f=new jp;return f.hashbuf=o,f.sig=a,f.pubkey=n,f.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=Hp.sha256(d.Buffer.from(r)),i=new jp;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=Hp.sha256(d.Buffer.from(n));if(e.tokenHash&&e.tokenHash!==i.toString("hex")){t.push("Token hash mismatch");return}var o=jx(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=Hx.fromDER(d.Buffer.from(s[2],"base64url")),f=new jp;f.hashbuf=i,f.sig=a,f.pubkey=o,f.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(cs);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 SC.uuid4()}};Kx.RightTypes=cs;Gx.exports=Kx});var Yx=B((Tq,zx)=>{"use strict";p();var Wx={};Wx.stringify=function(e){return Gp(e,[])};function Gp(e,t){if(e===null)return"null";var r=typeof e;if(r==="boolean")return e?"true":"false";if(r==="number"){if(!isFinite(e))throw new Error("Cannot canonicalize non-finite number: "+e);return JSON.stringify(e)}if(r==="string")return JSON.stringify(e);if(r==="bigint")throw new Error("Cannot canonicalize bigint; represent it as a string");if(Array.isArray(e)||r==="object"){if(t.indexOf(e)!==-1)throw new Error("Cannot canonicalize a circular structure");t.push(e);var n;if(Array.isArray(e))n="["+e.map(function(o){return o===void 0?"null":Gp(o,t)}).join(",")+"]";else{var i=Object.keys(e).filter(function(o){return e[o]!==void 0&&typeof e[o]!="function"}).sort();n="{"+i.map(function(o){return JSON.stringify(o)+":"+Gp(e[o],t)}).join(",")+"}"}return t.pop(),n}throw new Error("Cannot canonicalize value of type: "+r)}zx.exports=Wx});var Xx=B((Bq,Zx)=>{"use strict";p();var Vp=Object.create(null),Wp=[],zp=!(typeof x.default<"u"&&x.default.env&&x.default.env.BSV_NO_DEPRECATION_WARNINGS==="1");function $x(e,t){if(!e||typeof e.what!="string"||e.what==="")throw new TypeError(t+"() requires { what: string }")}function wC(e){var t="[@smartledger/bsv] "+e.what+" is deprecated";return e.since&&(t+=" since "+e.since),t+=".",e.why&&(t+=" "+e.why.charAt(0).toUpperCase()+e.why.slice(1)+"."),e.use&&(t+=" Use "+e.use+" instead."),t+=e.removeIn?" It will be removed in "+e.removeIn+".":" A removal version has not been set; it will not be removed in a 9.x release.",t}function jn(e){if(!e||!e.what)throw new TypeError("deprecate() requires { what }");if(Vp[e.what])return!1;Vp[e.what]=!0;var t=wC(e);return Wp.push({what:e.what,since:e.since||null,removeIn:e.removeIn||null,use:e.use||null,message:t}),zp&&console.warn(t),!0}jn.fn=function(e,t){if(typeof e!="function")throw new TypeError("deprecate.fn() requires a function");$x(t,"deprecate.fn");var r=function(){return jn(t),e.apply(this,arguments)};return Object.defineProperty(r,"name",{value:e.name,configurable:!0}),Object.defineProperty(r,"length",{value:e.length,configurable:!0}),r.__wrapped=e,r.__deprecation=t,r};jn.property=function(e,t,r,n){$x(n,"deprecate.property");var i,o=!1;return Object.defineProperty(e,t,{configurable:!0,enumerable:!0,get:function(){return jn(n),o||(i=r(),o=!0),i}}),e};jn.fired=function(){return Wp.slice()};jn.setEnabled=function(e){zp=!!e};jn.isEnabled=function(){return zp};jn.reset=function(){Vp=Object.create(null),Wp.length=0};Zx.exports=jn});var Qx=B((Mq,Jx)=>{"use strict";p();var ls=Jt(),cr=Le(),EC=Va(),xC=Yx(),IC=Xx(),so={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"}}}},AC={prepareClaimValidation:function(e,t){try{cr.checkArgument(e&&typeof e=="object","Invalid claim"),cr.checkArgument(typeof t=="string","Schema name must be string");var r=so[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:ls.sha256(d.Buffer.from(this._canonicalizeWith(e,this.CANONICALIZATION.LEGACY))).toString("hex"),canonical:this._canonicalizeWith(e,this.CANONICALIZATION.LEGACY)};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{cr.checkArgument(e&&typeof e=="object","Invalid claim"),cr.checkArgument(typeof t=="string","Schema name must be string"),cr.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=ls.sha256(d.Buffer.from(this._canonicalizeWith(i,this.CANONICALIZATION.LEGACY))).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{cr.checkArgument(typeof e=="string","Claim hash must be string"),cr.checkArgument(t&&typeof t=="object","Invalid disputant"),cr.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=ls.sha256(d.Buffer.from(this._canonicalizeWith(n,this.CANONICALIZATION.LEGACY))).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{cr.checkArgument(Array.isArray(e),"Claims must be array"),cr.checkArgument(typeof t=="string","Schema name must be string");var r=[],n=[],i=0;e.forEach(function(a,f){try{var l=this.prepareClaimValidation(a,t);l.success&&l.validation.valid&&i++,r.push({index:f,result:l})}catch(y){n.push({index:f,error:y.message})}}.bind(this));var o=this._generateBatchId(),s=ls.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}}},CANONICALIZATION:{JCS:"jcs",LEGACY:"legacy"},canonicalize:function(e,t){return this._canonicalizeWith(e,this._resolveCanonicalization(t,"LTP.Claim.canonicalize"))},hash:function(e,t){var r=this._canonicalizeWith(e,this._resolveCanonicalization(t,"LTP.Claim.hash"));return ls.sha256(d.Buffer.from(r)).toString("hex")},_canonicalizeWith:function(e,t){if(cr.checkArgument(e&&typeof e=="object","Invalid claim"),t===this.CANONICALIZATION.JCS)return xC.stringify(e);var r=this._sortObjectKeys(e);return JSON.stringify(r)},_resolveCanonicalization:function(e,t){return e===void 0?(IC({what:t+"() without a canonicalization argument",since:"9.2.0",removeIn:"10.0.0",use:t+"(claim, bsv.LTP.Claim.CANONICALIZATION.JCS)",why:"the default sorted-key form is not RFC 8785, so other implementations compute a different claim hash"}),this.CANONICALIZATION.LEGACY):(cr.checkArgument(e===this.CANONICALIZATION.JCS||e===this.CANONICALIZATION.LEGACY,"Unknown canonicalization: "+e+". Expected 'jcs' or 'legacy' (bsv.LTP.Claim.CANONICALIZATION)"),e)},prepareClaimTemplate:function(e,t){t=t||{};try{var r=so[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 so},getSchemaNames:function(){return Object.keys(so)},getSchema:function(e){return so[e]||null},addSchema:function(e,t){cr.checkArgument(typeof e=="string","Schema name must be string"),cr.checkArgument(t&&typeof t=="object","Invalid schema"),so[e]=t},createTemplate:function(e){var t=so[e];if(!t)throw new Error("Unknown schema: "+e);return this._createTemplateFromSchema(t)},_generateDisputeId:function(e){var t="dispute_"+e+"_"+Date.now();return ls.sha256(d.Buffer.from(t)).toString("hex").substring(0,16)},_generateBatchId:function(){return EC.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())}};Jx.exports=AC});var tI=B((Cq,eI)=>{"use strict";p();var za=Jt(),hs=Le(),OC={prepareTokenCommitment:function(e,t){t=t||{},hs.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||{},hs.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){hs.checkArgument(e&&typeof e=="object","Invalid token"),hs.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){hs.checkArgument(typeof e=="string","Token ID must be string"),hs.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=za.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:za.sha256(d.Buffer.from(r)).toString("hex"),tokenId:e.id,timestamp:new Date().toISOString(),purpose:t.purpose||"legal_token"},i=za.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 f=this._createCommitment(a,t);r.push(f.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=za.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=za.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}};eI.exports=OC});var iI=B((Dq,nI)=>{"use strict";p();var RC=Ar(),Vr=Jt(),rI=La(),TC=nr(),PC=no(),ir=Le(),BC={prepareSignatureProof:function(e,t,r){r=r||{},ir.checkArgument(e&&typeof e=="object","Invalid token"),ir.checkArgument(t instanceof PC,"Invalid private key");try{var n=this._canonicalizeForSigning(e),i=Vr.sha256(d.Buffer.from(n)),o=new rI;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(f){return{success:!1,error:f.message}}},prepareSignatureVerification:function(e,t){try{if(ir.checkArgument(e&&typeof e=="object","Invalid token"),ir.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=Vr.sha256(d.Buffer.from(r)),i=TC.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 rI;s.hashbuf=n,s.sig=i,s.pubkey=RC.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(f){return{success:!1,error:f.message}}},prepareSelectiveDisclosure:function(e,t,r){ir.checkArgument(e&&typeof e=="object","Invalid token"),ir.checkArgument(Array.isArray(t),"Revealed fields must be array"),ir.checkArgument(typeof r=="string","Nonce must be string");try{var n=this._createFieldCommitments(e,r),i=this._createMerkleTree(n),o=[],s=[];t.forEach(function(f){var l=this._getNestedValue(e,f),y=this._findFieldCommitment(n,f);if(y){o.push({path:f,value:l,commitment:y.hash,salt:y.salt});var g=this._generateMerkleProof(i,y.index);s.push({path:f,leafIndex:y.index,proof:g})}}.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(f){return{success:!1,error:f.message}}},prepareSelectiveDisclosureVerification:function(e,t){try{if(ir.checkArgument(e&&typeof e=="object","Invalid proof"),ir.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],f=this._hashField(o.path,o.value,o.salt);if(f!==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){ir.checkArgument(e&&typeof e=="object","Invalid token"),ir.checkArgument(t&&typeof t=="object","Invalid jurisdiction"),ir.checkArgument(typeof r=="string","Nonce must be string");try{var n=t.requirements||[],i=[],o=!0;n.forEach(function(a){var f=this._checkLegalRequirement(e,a);i.push(f),f.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){ir.checkArgument(e&&typeof e=="object","Invalid token"),ir.checkArgument(t&&typeof t=="object","Invalid statement"),ir.checkArgument(typeof r=="string","Nonce must be string");try{var n=Vr.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:Vr.sha256(d.Buffer.from(t.claim+r)).toString("hex"),response:Vr.sha256(d.Buffer.from(this._canonicalizeForSigning(e)+t.claim)).toString("hex"),witness:Vr.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=Vr.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 Vr.sha256(d.Buffer.from(n)).toString("hex")},_createMerkleTree:function(e){var t=e.map(function(y){return y.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,f=d.Buffer.concat([d.Buffer.from(s,"hex"),d.Buffer.from(a,"hex")]),l=Vr.sha256(f).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],f=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=Vr.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 Vr.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}};nI.exports=BC});var aI=B((Hq,sI)=>{"use strict";p();var Ya=Jt(),Fq=ro(),qq=Np(),lr=Le(),oI=Va(),NC={prepareRegistry:function(e){e=e||{},lr.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||{},lr.checkArgument(e&&typeof e=="object","Invalid token"),lr.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{lr.checkArgument(typeof e=="string","Token ID must be string"),lr.checkArgument(typeof t=="string","Approver must be string"),lr.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(lr.checkArgument(typeof e=="string","Token ID must be string"),lr.checkArgument(t&&typeof t=="object","Invalid revocation"),lr.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 lr.checkArgument(typeof e=="string","Token ID must be string"),lr.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{lr.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 lr.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||{},lr.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_"+oI.randomHex(16)},_generateRegistrationId:function(e){var t="reg_"+e+"_"+Date.now();return Ya.sha256(d.Buffer.from(t)).toString("hex").substring(0,16)},_generateRevocationId:function(e){var t="rev_"+e+"_"+Date.now();return Ya.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,Ya.sha256(d.Buffer.from(JSON.stringify(t))).toString("hex")},_generateRevocationHash:function(e,t){var r=e+(t.reason||"")+(t.revokedBy||"")+Date.now();return Ya.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_"+oI.randomHex(32)},_generateAuditHash:function(e){var t=(e.action||"")+(e.actor||"")+(e.tokenId||"")+(e.timestamp||"");return Ya.sha256(d.Buffer.from(t)).toString("hex").substring(0,16)}};sI.exports=NC});var lI=B((Kq,cI)=>{"use strict";p();var Yp=Ar(),$p=Jt(),uI=La(),MC=nr(),fI=no(),yr=Le(),kC=Va();function CC(e,t){if(t=t||{},t.issuerPublicKey)return t.issuerPublicKey instanceof Yp?t.issuerPublicKey:Yp.fromString(t.issuerPublicKey);var r=e&&e.issuer;if(typeof r!="string")return null;try{var n=r.split("#")[0].split(":")[2];return n?Yp.fromString(n):null}catch{return null}}var qc={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"},ds={CRITICAL:"CRITICAL",HIGH:"HIGH",MEDIUM:"MEDIUM",LOW:"LOW",DEFERRED:"DEFERRED"},hr={PENDING:"PENDING",ACTIVE:"ACTIVE",IN_PROGRESS:"IN_PROGRESS",COMPLETED:"COMPLETED",OVERDUE:"OVERDUE",BREACHED:"BREACHED",WAIVED:"WAIVED",TERMINATED:"TERMINATED"},Hc={prepareObligationToken:function(e,t,r,n,i,o){o=o||{},yr.checkArgument(typeof e=="string","Obligation type must be string"),yr.checkArgument(typeof t=="string","Issuer DID must be string"),yr.checkArgument(typeof r=="string","Obligor DID must be string"),yr.checkArgument(n&&typeof n=="object","Obligation must be object"),yr.checkArgument(i instanceof fI,"Invalid issuer private key");var s=Object.values(qc);yr.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||ds.MEDIUM,status:hr.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 f=this._signToken(a,i);return{success:!0,obligationToken:f,tokenHash:f.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:f,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:f.id,tokenHash:f.tokenHash,type:e,issuer:t,obligor:r,issuedAt:f.issuanceDate,dueDate:a.credentialSubject.dueDate,priority:a.credentialSubject.priority}},notifyObligor:{endpoint:"POST /notifications/obligation-issued",data:{tokenId:f.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:f.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===hr.ACTIVE?{endpoint:"PUT /obligations/tokens/"+e.id+"/status",data:{status:hr.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||{},yr.checkArgument(e&&typeof e=="object","Invalid token"),yr.checkArgument(t&&typeof t=="object","Invalid fulfillment"),yr.checkArgument(r instanceof fI,"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===hr.COMPLETED)return{success:!1,error:"Obligation already fulfilled"};if(e.credentialSubject.status===hr.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?hr.COMPLETED:hr.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(f){return{success:!1,error:f.message}}},prepareObligationBreachAssessment:function(e,t,r){yr.checkArgument(e&&typeof e=="object","Invalid token"),yr.checkArgument(t&&typeof t=="object","Invalid breach details"),yr.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=$p.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:hr.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||{},yr.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===hr.COMPLETED&&r.summary.completed++,s.isOverdue&&s.priority===ds.CRITICAL&&r.alerts.push({type:"CRITICAL_OVERDUE",obligationId:o.id,message:"Critical obligation is overdue",priority:"HIGH"}),s.isDueSoon&&s.priority===ds.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 qc},getObligationPriority:function(){return ds},getObligationStatus:function(){return hr},_signToken:function(e,t){var r=this._canonicalizeToken(e),n=$p.sha256(d.Buffer.from(r)),i=new uI;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=$p.sha256(d.Buffer.from(n));if(e.tokenHash&&e.tokenHash!==i.toString("hex")){t.push("Token hash mismatch");return}var o=CC(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=MC.fromDER(d.Buffer.from(s[2],"base64url")),f=new uI;f.hashbuf=i,f.sig=a,f.pubkey=o,f.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(qc);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(hr);n.includes(e.credentialSubject.status)||t.push("Invalid obligation status: "+e.credentialSubject.status),this._checkIfOverdue(e)&&e.credentialSubject.status===hr.ACTIVE&&r.push("Obligation is overdue but status is still ACTIVE")},_validateObligationPriority:function(e,t){if(e.credentialSubject.priority){var r=Object.values(ds);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!==hr.COMPLETED},_generateUUID:function(){return kC.uuid4()}};Hc.ObligationTypes=qc;Hc.ObligationPriority=ds;Hc.ObligationStatus=hr;cI.exports=Hc});var dI=B((Vq,hI)=>{"use strict";p();var ao=Vx(),jc=Qx(),$a=tI(),Zp=iI(),dn=aI(),LC=lI(),Xp=no(),mr=Le(),Te=function(e){return this instanceof Te?(this.config=e||{},this.registry=null,this.config.registry&&(this.registry=dn.createRegistry(this.config.registry)),this):new Te(e)};Te.prototype.createRightToken=function(e,t,r){mr.checkArgument(e&&typeof e=="object","Invalid right data"),mr.checkArgument(t instanceof Xp,"Invalid private key"),r=r||{};try{var n=ao.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=ao._signToken(n,t)),r.anchor){var i=$a.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}}};Te.prototype.validateClaim=function(e,t){return jc.validate(e,t)};Te.prototype.createSelectiveDisclosure=function(e,t,r){return Zp.prepareSelectiveDisclosure(e,t,r)};Te.prototype.verifyToken=function(e,t){return!e||!e.proof?{valid:!1,error:"No proof found in token"}:ao.verifyToken(e,t)};Te.prototype.transferRight=function(e,t,r,n){mr.checkArgument(e&&typeof e=="object","Invalid token"),mr.checkArgument(typeof t=="string","New owner must be string"),mr.checkArgument(r instanceof Xp,"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=ao.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 f=$a.anchorToken(s,n.anchor);f.success&&(s.transferAnchorTx=f.txid)}if(this.registry){var l=dn.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(y){return{success:!1,error:y.message}}};Te.prototype.createObligation=function(e,t,r){mr.checkArgument(e&&typeof e=="object","Invalid right token"),mr.checkArgument(t&&typeof t=="object","Invalid obligation data"),mr.checkArgument(r instanceof Xp,"Invalid private key");try{var n=ao.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}}};Te.prototype.revokeToken=function(e,t,r){return mr.checkArgument(typeof e=="string","Token ID must be string"),mr.checkArgument(t&&typeof t=="object","Invalid revocation data"),mr.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"}};Te.prototype.checkTokenStatus=function(e){return mr.checkArgument(typeof e=="string","Token ID must be string"),this.registry?dn.checkTokenStatus(this.registry,e):{found:!1,error:"No registry available"}};Te.prototype.searchTokens=function(e){return this.registry?dn.searchTokens(this.registry,e):{success:!1,error:"No registry available"}};Te.prototype.getRegistryStats=function(){return this.registry?dn.getStatistics(this.registry):{error:"No registry available"}};Te.prototype.createLegalValidityProof=function(e,t,r){return Zp.prepareLegalValidityProof(e,t,r)};Te.prototype.anchorTokenBatch=function(e,t){return $a.anchorBatch(e,t)};Te.prototype.verifyAnchor=function(e,t){return $a.verifyAnchor(e,t)};Te.prototype.getRightTypes=function(){return ao.getRightTypes()};Te.prototype.getClaimSchemas=function(){return jc.getSchemas()};Te.prototype.createRegistry=function(e){return this.registry=dn.createRegistry(e),this.registry};Te.prototype.setRegistry=function(e){mr.checkArgument(e&&typeof e=="object","Invalid registry"),this.registry=e};Te.create=function(e){return new Te(e)};Te.createRightToken=function(e,t,r){var n=new Te;return n.createRightToken(e,t,r)};Te.validateClaim=function(e,t){return jc.validate(e,t)};Te.verifyToken=function(e,t){var r=new Te;return r.verifyToken(e,t)};Te.createRegistry=function(e){return dn.createRegistry(e)};Te.Right=ao;Te.Claim=jc;Te.Anchor=$a;Te.Proof=Zp;Te.Registry=dn;Te.Obligation=LC;hI.exports=Te});var DC=B((zq,pI)=>{p();pI.exports=dI()});return DC();})();
|
|
75
75
|
if(typeof module!=="undefined"&&module.exports){module.exports=bsvLTP}else if(typeof define==="function"&&define.amd){define([],function(){return bsvLTP})}
|