@smartledger/bsv 9.11.1 → 9.11.2

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/bsv.min.js CHANGED
@@ -8,7 +8,7 @@
8
8
  `)>=0&&i++,o+a.replace(/\u001b\[\d\d?m/g,"").length+1},0);return n>60?r[0]+(t===""?"":t+`
9
9
  `)+" "+e.join(`,
10
10
  `)+" "+r[1]:r[0]+t+" "+e.join(", ")+" "+r[1]}Ve.types=EO();function TO(e){return Array.isArray(e)}Ve.isArray=TO;function D0(e){return typeof e=="boolean"}Ve.isBoolean=D0;function Kd(e){return e===null}Ve.isNull=Kd;function FF(e){return e==null}Ve.isNullOrUndefined=FF;function PO(e){return typeof e=="number"}Ve.isNumber=PO;function Vd(e){return typeof e=="string"}Ve.isString=Vd;function jF(e){return typeof e=="symbol"}Ve.isSymbol=jF;function As(e){return e===void 0}Ve.isUndefined=As;function Hf(e){return Gu(e)&&q0(e)==="[object RegExp]"}Ve.isRegExp=Hf;Ve.types.isRegExp=Hf;function Gu(e){return typeof e=="object"&&e!==null}Ve.isObject=Gu;function zd(e){return Gu(e)&&q0(e)==="[object Date]"}Ve.isDate=zd;Ve.types.isDate=zd;function Uf(e){return Gu(e)&&(q0(e)==="[object Error]"||e instanceof Error)}Ve.isError=Uf;Ve.types.isNativeError=Uf;function Fd(e){return typeof e=="function"}Ve.isFunction=Fd;function zF(e){return e===null||typeof e=="boolean"||typeof e=="number"||typeof e=="string"||typeof e=="symbol"||typeof e>"u"}Ve.isPrimitive=zF;Ve.isBuffer=OO();function q0(e){return Object.prototype.toString.call(e)}function L0(e){return e<10?"0"+e.toString(10):e.toString(10)}var KF=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function VF(){var e=new Date,t=[L0(e.getHours()),L0(e.getMinutes()),L0(e.getSeconds())].join(":");return[e.getDate(),KF[e.getMonth()],t].join(" ")}Ve.log=function(){console.log("%s - %s",VF(),Ve.format.apply(Ve,arguments))};Ve.inherits=vt();Ve._extend=function(e,t){if(!t||!Gu(t))return e;for(var r=Object.keys(t),i=r.length;i--;)e[r[i]]=t[r[i]];return e};function RO(e,t){return Object.prototype.hasOwnProperty.call(e,t)}var Is=typeof Symbol<"u"?Symbol("util.promisify.custom"):void 0;Ve.promisify=function(t){if(typeof t!="function")throw new TypeError('The "original" argument must be of type Function');if(Is&&t[Is]){var r=t[Is];if(typeof r!="function")throw new TypeError('The "util.promisify.custom" argument must be of type Function');return Object.defineProperty(r,Is,{value:r,enumerable:!1,writable:!1,configurable:!0}),r}function r(){for(var i,n,o=new Promise(function(u,c){i=u,n=c}),a=[],s=0;s<arguments.length;s++)a.push(arguments[s]);a.push(function(u,c){u?n(u):i(c)});try{t.apply(this,a)}catch(u){n(u)}return o}return Object.setPrototypeOf(r,Object.getPrototypeOf(t)),Is&&Object.defineProperty(r,Is,{value:r,enumerable:!1,writable:!1,configurable:!0}),Object.defineProperties(r,IO(t))};Ve.promisify.custom=Is;function GF(e,t){if(!e){var r=new Error("Promise was rejected with a falsy value");r.reason=e,e=r}return t(e)}function WF(e){if(typeof e!="function")throw new TypeError('The "original" argument must be of type Function');function t(){for(var r=[],i=0;i<arguments.length;i++)r.push(arguments[i]);var n=r.pop();if(typeof n!="function")throw new TypeError("The last argument must be of type Function");var o=this,a=function(){return n.apply(o,arguments)};e.apply(this,r).then(function(s){b.default.nextTick(a.bind(null,null,s))},function(s){b.default.nextTick(GF.bind(null,s,a))})}return Object.setPrototypeOf(t,Object.getPrototypeOf(e)),Object.defineProperties(t,IO(e)),t}Ve.callbackify=WF});var MO=P((are,LO)=>{"use strict";g();function kO(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);t&&(i=i.filter(function(n){return Object.getOwnPropertyDescriptor(e,n).enumerable})),r.push.apply(r,i)}return r}function BO(e){for(var t=1;t<arguments.length;t++){var r=arguments[t]!=null?arguments[t]:{};t%2?kO(Object(r),!0).forEach(function(i){YF(e,i,r[i])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):kO(Object(r)).forEach(function(i){Object.defineProperty(e,i,Object.getOwnPropertyDescriptor(r,i))})}return e}function YF(e,t,r){return t=CO(t),t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function ZF(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function NO(e,t){for(var r=0;r<t.length;r++){var i=t[r];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,CO(i.key),i)}}function $F(e,t,r){return t&&NO(e.prototype,t),r&&NO(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e}function CO(e){var t=XF(e,"string");return typeof t=="symbol"?t:String(t)}function XF(e,t){if(typeof e!="object"||e===null)return e;var r=e[Symbol.toPrimitive];if(r!==void 0){var i=r.call(e,t||"default");if(typeof i!="object")return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}var JF=jt(),Gd=JF.Buffer,QF=Qi(),H0=QF.inspect,e8=H0&&H0.custom||"inspect";function t8(e,t,r){Gd.prototype.copy.call(e,t,r)}LO.exports=(function(){function e(){ZF(this,e),this.head=null,this.tail=null,this.length=0}return $F(e,[{key:"push",value:function(r){var i={data:r,next:null};this.length>0?this.tail.next=i:this.head=i,this.tail=i,++this.length}},{key:"unshift",value:function(r){var i={data:r,next:this.head};this.length===0&&(this.tail=i),this.head=i,++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 i=this.head,n=""+i.data;i=i.next;)n+=r+i.data;return n}},{key:"concat",value:function(r){if(this.length===0)return Gd.alloc(0);for(var i=Gd.allocUnsafe(r>>>0),n=this.head,o=0;n;)t8(n.data,i,o),o+=n.data.length,n=n.next;return i}},{key:"consume",value:function(r,i){var n;return r<this.head.data.length?(n=this.head.data.slice(0,r),this.head.data=this.head.data.slice(r)):r===this.head.data.length?n=this.shift():n=i?this._getString(r):this._getBuffer(r),n}},{key:"first",value:function(){return this.head.data}},{key:"_getString",value:function(r){var i=this.head,n=1,o=i.data;for(r-=o.length;i=i.next;){var a=i.data,s=r>a.length?a.length:r;if(s===a.length?o+=a:o+=a.slice(0,r),r-=s,r===0){s===a.length?(++n,i.next?this.head=i.next:this.head=this.tail=null):(this.head=i,i.data=a.slice(s));break}++n}return this.length-=n,o}},{key:"_getBuffer",value:function(r){var i=Gd.allocUnsafe(r),n=this.head,o=1;for(n.data.copy(i),r-=n.data.length;n=n.next;){var a=n.data,s=r>a.length?a.length:r;if(a.copy(i,i.length-r,0,s),r-=s,r===0){s===a.length?(++o,n.next?this.head=n.next:this.head=this.tail=null):(this.head=n,n.data=a.slice(s));break}++o}return this.length-=o,i}},{key:e8,value:function(r,i){return H0(this,BO(BO({},i),{},{depth:0,customInspect:!1}))}}]),e})()});var F0=P((ure,qO)=>{"use strict";g();function r8(e,t){var r=this,i=this._readableState&&this._readableState.destroyed,n=this._writableState&&this._writableState.destroyed;return i||n?(t?t(e):e&&(this._writableState?this._writableState.errorEmitted||(this._writableState.errorEmitted=!0,b.default.nextTick(U0,this,e)):b.default.nextTick(U0,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?b.default.nextTick(Wd,r):(r._writableState.errorEmitted=!0,b.default.nextTick(DO,r,o)):b.default.nextTick(DO,r,o):t?(b.default.nextTick(Wd,r),t(o)):b.default.nextTick(Wd,r)}),this)}function DO(e,t){U0(e,t),Wd(e)}function Wd(e){e._writableState&&!e._writableState.emitClose||e._readableState&&!e._readableState.emitClose||e.emit("close")}function i8(){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 U0(e,t){e.emit("error",t)}function n8(e,t){var r=e._readableState,i=e._writableState;r&&r.autoDestroy||i&&i.autoDestroy?e.destroy(t):e.emit("error",t)}qO.exports={destroy:r8,undestroy:i8,errorOrDestroy:n8}});var Ts=P((fre,FO)=>{"use strict";g();function o8(e,t){e.prototype=Object.create(t.prototype),e.prototype.constructor=e,e.__proto__=t}var UO={};function en(e,t,r){r||(r=Error);function i(o,a,s){return typeof t=="string"?t:t(o,a,s)}var n=(function(o){o8(a,o);function a(s,u,c){return o.call(this,i(s,u,c))||this}return a})(r);n.prototype.name=r.name,n.prototype.code=e,UO[e]=n}function HO(e,t){if(Array.isArray(e)){var r=e.length;return e=e.map(function(i){return String(i)}),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 a8(e,t,r){return e.substr(!r||r<0?0:+r,t.length)===t}function s8(e,t,r){return(r===void 0||r>e.length)&&(r=e.length),e.substring(r-t.length,r)===t}function u8(e,t,r){return typeof r!="number"&&(r=0),r+t.length>e.length?!1:e.indexOf(t,r)!==-1}en("ERR_INVALID_OPT_VALUE",function(e,t){return'The value "'+t+'" is invalid for option "'+e+'"'},TypeError);en("ERR_INVALID_ARG_TYPE",function(e,t,r){var i;typeof t=="string"&&a8(t,"not ")?(i="must not be",t=t.replace(/^not /,"")):i="must be";var n;if(s8(e," argument"))n="The ".concat(e," ").concat(i," ").concat(HO(t,"type"));else{var o=u8(e,".")?"property":"argument";n='The "'.concat(e,'" ').concat(o," ").concat(i," ").concat(HO(t,"type"))}return n+=". Received type ".concat(typeof r),n},TypeError);en("ERR_STREAM_PUSH_AFTER_EOF","stream.push() after EOF");en("ERR_METHOD_NOT_IMPLEMENTED",function(e){return"The "+e+" method is not implemented"});en("ERR_STREAM_PREMATURE_CLOSE","Premature close");en("ERR_STREAM_DESTROYED",function(e){return"Cannot call "+e+" after a stream was destroyed"});en("ERR_MULTIPLE_CALLBACK","Callback called multiple times");en("ERR_STREAM_CANNOT_PIPE","Cannot pipe, not readable");en("ERR_STREAM_WRITE_AFTER_END","write after end");en("ERR_STREAM_NULL_VALUES","May not write null values to stream",TypeError);en("ERR_UNKNOWN_ENCODING",function(e){return"Unknown encoding: "+e},TypeError);en("ERR_STREAM_UNSHIFT_AFTER_END_EVENT","stream.unshift() after end event");FO.exports.codes=UO});var j0=P((hre,jO)=>{"use strict";g();var c8=Ts().codes.ERR_INVALID_OPT_VALUE;function f8(e,t,r){return e.highWaterMark!=null?e.highWaterMark:t?e[r]:null}function l8(e,t,r,i){var n=f8(t,i,r);if(n!=null){if(!(isFinite(n)&&Math.floor(n)===n)||n<0){var o=i?r:"highWaterMark";throw new c8(o,n)}return Math.floor(n)}return e.objectMode?16:16*1024}jO.exports={getHighWaterMark:l8}});var K0=P((pre,zO)=>{g();zO.exports=h8;function h8(e,t){if(z0("noDeprecation"))return e;var r=!1;function i(){if(!r){if(z0("throwDeprecation"))throw new Error(t);z0("traceDeprecation")?console.trace(t):console.warn(t),r=!0}return e.apply(this,arguments)}return i}function z0(e){try{if(!globalThis.localStorage)return!1}catch{return!1}var t=globalThis.localStorage[e];return t==null?!1:String(t).toLowerCase()==="true"}});var W0=P((mre,ZO)=>{"use strict";g();ZO.exports=zt;function VO(e){var t=this;this.next=null,this.entry=null,this.finish=function(){H8(t,e)}}var Wu;zt.WritableState=jf;var d8={deprecate:K0()},GO=a0(),Zd=jt().Buffer,p8=(typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof self<"u"?self:{}).Uint8Array||function(){};function g8(e){return Zd.from(e)}function m8(e){return Zd.isBuffer(e)||e instanceof p8}var G0=F0(),v8=j0(),y8=v8.getHighWaterMark,xa=Ts().codes,b8=xa.ERR_INVALID_ARG_TYPE,_8=xa.ERR_METHOD_NOT_IMPLEMENTED,w8=xa.ERR_MULTIPLE_CALLBACK,S8=xa.ERR_STREAM_CANNOT_PIPE,E8=xa.ERR_STREAM_DESTROYED,x8=xa.ERR_STREAM_NULL_VALUES,O8=xa.ERR_STREAM_WRITE_AFTER_END,I8=xa.ERR_UNKNOWN_ENCODING,Yu=G0.errorOrDestroy;vt()(zt,GO);function A8(){}function jf(e,t,r){Wu=Wu||Ps(),e=e||{},typeof r!="boolean"&&(r=t instanceof Wu),this.objectMode=!!e.objectMode,r&&(this.objectMode=this.objectMode||!!e.writableObjectMode),this.highWaterMark=y8(this,e,"writableHighWaterMark",r),this.finalCalled=!1,this.needDrain=!1,this.ending=!1,this.ended=!1,this.finished=!1,this.destroyed=!1;var i=e.decodeStrings===!1;this.decodeStrings=!i,this.defaultEncoding=e.defaultEncoding||"utf8",this.length=0,this.writing=!1,this.corked=0,this.sync=!0,this.bufferProcessing=!1,this.onwrite=function(n){C8(t,n)},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 VO(this)}jf.prototype.getBuffer=function(){for(var t=this.bufferedRequest,r=[];t;)r.push(t),t=t.next;return r};(function(){try{Object.defineProperty(jf.prototype,"buffer",{get:d8.deprecate(function(){return this.getBuffer()},"_writableState.buffer is deprecated. Use _writableState.getBuffer instead.","DEP0003")})}catch{}})();var Yd;typeof Symbol=="function"&&Symbol.hasInstance&&typeof Function.prototype[Symbol.hasInstance]=="function"?(Yd=Function.prototype[Symbol.hasInstance],Object.defineProperty(zt,Symbol.hasInstance,{value:function(t){return Yd.call(this,t)?!0:this!==zt?!1:t&&t._writableState instanceof jf}})):Yd=function(t){return t instanceof this};function zt(e){Wu=Wu||Ps();var t=this instanceof Wu;if(!t&&!Yd.call(zt,this))return new zt(e);this._writableState=new jf(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)),GO.call(this)}zt.prototype.pipe=function(){Yu(this,new S8)};function T8(e,t){var r=new O8;Yu(e,r),b.default.nextTick(t,r)}function P8(e,t,r,i){var n;return r===null?n=new x8:typeof r!="string"&&!t.objectMode&&(n=new b8("chunk",["string","Buffer"],r)),n?(Yu(e,n),b.default.nextTick(i,n),!1):!0}zt.prototype.write=function(e,t,r){var i=this._writableState,n=!1,o=!i.objectMode&&m8(e);return o&&!Zd.isBuffer(e)&&(e=g8(e)),typeof t=="function"&&(r=t,t=null),o?t="buffer":t||(t=i.defaultEncoding),typeof r!="function"&&(r=A8),i.ending?T8(this,r):(o||P8(this,i,e,r))&&(i.pendingcb++,n=k8(this,i,o,e,t,r)),n};zt.prototype.cork=function(){this._writableState.corked++};zt.prototype.uncork=function(){var e=this._writableState;e.corked&&(e.corked--,!e.writing&&!e.corked&&!e.bufferProcessing&&e.bufferedRequest&&WO(this,e))};zt.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 I8(t);return this._writableState.defaultEncoding=t,this};Object.defineProperty(zt.prototype,"writableBuffer",{enumerable:!1,get:function(){return this._writableState&&this._writableState.getBuffer()}});function R8(e,t,r){return!e.objectMode&&e.decodeStrings!==!1&&typeof t=="string"&&(t=Zd.from(t,r)),t}Object.defineProperty(zt.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}});function k8(e,t,r,i,n,o){if(!r){var a=R8(t,i,n);i!==a&&(r=!0,n="buffer",i=a)}var s=t.objectMode?1:i.length;t.length+=s;var u=t.length<t.highWaterMark;if(u||(t.needDrain=!0),t.writing||t.corked){var c=t.lastBufferedRequest;t.lastBufferedRequest={chunk:i,encoding:n,isBuf:r,callback:o,next:null},c?c.next=t.lastBufferedRequest:t.bufferedRequest=t.lastBufferedRequest,t.bufferedRequestCount+=1}else V0(e,t,!1,s,i,n,o);return u}function V0(e,t,r,i,n,o,a){t.writelen=i,t.writecb=a,t.writing=!0,t.sync=!0,t.destroyed?t.onwrite(new E8("write")):r?e._writev(n,t.onwrite):e._write(n,o,t.onwrite),t.sync=!1}function B8(e,t,r,i,n){--t.pendingcb,r?(b.default.nextTick(n,i),b.default.nextTick(Ff,e,t),e._writableState.errorEmitted=!0,Yu(e,i)):(n(i),e._writableState.errorEmitted=!0,Yu(e,i),Ff(e,t))}function N8(e){e.writing=!1,e.writecb=null,e.length-=e.writelen,e.writelen=0}function C8(e,t){var r=e._writableState,i=r.sync,n=r.writecb;if(typeof n!="function")throw new w8;if(N8(r),t)B8(e,r,i,t,n);else{var o=YO(r)||e.destroyed;!o&&!r.corked&&!r.bufferProcessing&&r.bufferedRequest&&WO(e,r),i?b.default.nextTick(KO,e,r,o,n):KO(e,r,o,n)}}function KO(e,t,r,i){r||L8(e,t),t.pendingcb--,i(),Ff(e,t)}function L8(e,t){t.length===0&&t.needDrain&&(t.needDrain=!1,e.emit("drain"))}function WO(e,t){t.bufferProcessing=!0;var r=t.bufferedRequest;if(e._writev&&r&&r.next){var i=t.bufferedRequestCount,n=new Array(i),o=t.corkedRequestsFree;o.entry=r;for(var a=0,s=!0;r;)n[a]=r,r.isBuf||(s=!1),r=r.next,a+=1;n.allBuffers=s,V0(e,t,!0,t.length,n,"",o.finish),t.pendingcb++,t.lastBufferedRequest=null,o.next?(t.corkedRequestsFree=o.next,o.next=null):t.corkedRequestsFree=new VO(t),t.bufferedRequestCount=0}else{for(;r;){var u=r.chunk,c=r.encoding,l=r.callback,d=t.objectMode?1:u.length;if(V0(e,t,!1,d,u,c,l),r=r.next,t.bufferedRequestCount--,t.writing)break}r===null&&(t.lastBufferedRequest=null)}t.bufferedRequest=r,t.bufferProcessing=!1}zt.prototype._write=function(e,t,r){r(new _8("_write()"))};zt.prototype._writev=null;zt.prototype.end=function(e,t,r){var i=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),i.corked&&(i.corked=1,this.uncork()),i.ending||q8(this,i,r),this};Object.defineProperty(zt.prototype,"writableLength",{enumerable:!1,get:function(){return this._writableState.length}});function YO(e){return e.ending&&e.length===0&&e.bufferedRequest===null&&!e.finished&&!e.writing}function M8(e,t){e._final(function(r){t.pendingcb--,r&&Yu(e,r),t.prefinished=!0,e.emit("prefinish"),Ff(e,t)})}function D8(e,t){!t.prefinished&&!t.finalCalled&&(typeof e._final=="function"&&!t.destroyed?(t.pendingcb++,t.finalCalled=!0,b.default.nextTick(M8,e,t)):(t.prefinished=!0,e.emit("prefinish")))}function Ff(e,t){var r=YO(t);if(r&&(D8(e,t),t.pendingcb===0&&(t.finished=!0,e.emit("finish"),t.autoDestroy))){var i=e._readableState;(!i||i.autoDestroy&&i.endEmitted)&&e.destroy()}return r}function q8(e,t,r){t.ending=!0,Ff(e,t),r&&(t.finished?b.default.nextTick(r):e.once("finish",r)),t.ended=!0,e.writable=!1}function H8(e,t,r){var i=e.entry;for(e.entry=null;i;){var n=i.callback;t.pendingcb--,n(r),i=i.next}t.corkedRequestsFree.next=e}Object.defineProperty(zt.prototype,"destroyed",{enumerable:!1,get:function(){return this._writableState===void 0?!1:this._writableState.destroyed},set:function(t){this._writableState&&(this._writableState.destroyed=t)}});zt.prototype.destroy=G0.destroy;zt.prototype._undestroy=G0.undestroy;zt.prototype._destroy=function(e,t){t(e)}});var Ps=P((yre,XO)=>{"use strict";g();var U8=Object.keys||function(e){var t=[];for(var r in e)t.push(r);return t};XO.exports=Yn;var $O=$0(),Z0=W0();vt()(Yn,$O);for(Y0=U8(Z0.prototype),$d=0;$d<Y0.length;$d++)Xd=Y0[$d],Yn.prototype[Xd]||(Yn.prototype[Xd]=Z0.prototype[Xd]);var Y0,Xd,$d;function Yn(e){if(!(this instanceof Yn))return new Yn(e);$O.call(this,e),Z0.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",F8)))}Object.defineProperty(Yn.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}});Object.defineProperty(Yn.prototype,"writableBuffer",{enumerable:!1,get:function(){return this._writableState&&this._writableState.getBuffer()}});Object.defineProperty(Yn.prototype,"writableLength",{enumerable:!1,get:function(){return this._writableState.length}});function F8(){this._writableState.ended||b.default.nextTick(j8,this)}function j8(e){e.end()}Object.defineProperty(Yn.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 eI=P((X0,QO)=>{g();var Jd=jt(),Do=Jd.Buffer;function JO(e,t){for(var r in e)t[r]=e[r]}Do.from&&Do.alloc&&Do.allocUnsafe&&Do.allocUnsafeSlow?QO.exports=Jd:(JO(Jd,X0),X0.Buffer=Zu);function Zu(e,t,r){return Do(e,t,r)}JO(Do,Zu);Zu.from=function(e,t,r){if(typeof e=="number")throw new TypeError("Argument must not be a number");return Do(e,t,r)};Zu.alloc=function(e,t,r){if(typeof e!="number")throw new TypeError("Argument must be a number");var i=Do(e);return t!==void 0?typeof r=="string"?i.fill(t,r):i.fill(t):i.fill(0),i};Zu.allocUnsafe=function(e){if(typeof e!="number")throw new TypeError("Argument must be a number");return Do(e)};Zu.allocUnsafeSlow=function(e){if(typeof e!="number")throw new TypeError("Argument must be a number");return Jd.SlowBuffer(e)}});var $u=P(rI=>{"use strict";g();var Q0=eI().Buffer,tI=Q0.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 z8(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 K8(e){var t=z8(e);if(typeof t!="string"&&(Q0.isEncoding===tI||!tI(e)))throw new Error("Unknown encoding: "+e);return t||e}rI.StringDecoder=zf;function zf(e){this.encoding=K8(e);var t;switch(this.encoding){case"utf16le":this.text=$8,this.end=X8,t=4;break;case"utf8":this.fillLast=W8,t=4;break;case"base64":this.text=J8,this.end=Q8,t=3;break;default:this.write=e4,this.end=t4;return}this.lastNeed=0,this.lastTotal=0,this.lastChar=Q0.allocUnsafe(t)}zf.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||""};zf.prototype.end=Z8;zf.prototype.text=Y8;zf.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 J0(e){return e<=127?0:e>>5===6?2:e>>4===14?3:e>>3===30?4:e>>6===2?-1:-2}function V8(e,t,r){var i=t.length-1;if(i<r)return 0;var n=J0(t[i]);return n>=0?(n>0&&(e.lastNeed=n-1),n):--i<r||n===-2?0:(n=J0(t[i]),n>=0?(n>0&&(e.lastNeed=n-2),n):--i<r||n===-2?0:(n=J0(t[i]),n>=0?(n>0&&(n===2?n=0:e.lastNeed=n-3),n):0))}function G8(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 W8(e){var t=this.lastTotal-this.lastNeed,r=G8(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 Y8(e,t){var r=V8(this,e,t);if(!this.lastNeed)return e.toString("utf8",t);this.lastTotal=r;var i=e.length-(r-this.lastNeed);return e.copy(this.lastChar,0,i),e.toString("utf8",t,i)}function Z8(e){var t=e&&e.length?this.write(e):"";return this.lastNeed?t+"\uFFFD":t}function $8(e,t){if((e.length-t)%2===0){var r=e.toString("utf16le",t);if(r){var i=r.charCodeAt(r.length-1);if(i>=55296&&i<=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 X8(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 J8(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 Q8(e){var t=e&&e.length?this.write(e):"";return this.lastNeed?t+this.lastChar.toString("base64",0,3-this.lastNeed):t}function e4(e){return e.toString(this.encoding)}function t4(e){return e&&e.length?this.write(e):""}});var Qd=P((Ere,oI)=>{"use strict";g();var iI=Ts().codes.ERR_STREAM_PREMATURE_CLOSE;function r4(e){var t=!1;return function(){if(!t){t=!0;for(var r=arguments.length,i=new Array(r),n=0;n<r;n++)i[n]=arguments[n];e.apply(this,i)}}}function i4(){}function n4(e){return e.setHeader&&typeof e.abort=="function"}function nI(e,t,r){if(typeof t=="function")return nI(e,null,t);t||(t={}),r=r4(r||i4);var i=t.readable||t.readable!==!1&&e.readable,n=t.writable||t.writable!==!1&&e.writable,o=function(){e.writable||s()},a=e._writableState&&e._writableState.finished,s=function(){n=!1,a=!0,i||r.call(e)},u=e._readableState&&e._readableState.endEmitted,c=function(){i=!1,u=!0,n||r.call(e)},l=function(_){r.call(e,_)},d=function(){var _;if(i&&!u)return(!e._readableState||!e._readableState.ended)&&(_=new iI),r.call(e,_);if(n&&!a)return(!e._writableState||!e._writableState.ended)&&(_=new iI),r.call(e,_)},p=function(){e.req.on("finish",s)};return n4(e)?(e.on("complete",s),e.on("abort",d),e.req?p():e.on("request",p)):n&&!e._writableState&&(e.on("end",o),e.on("close",o)),e.on("end",c),e.on("finish",s),t.error!==!1&&e.on("error",l),e.on("close",d),function(){e.removeListener("complete",s),e.removeListener("abort",d),e.removeListener("request",p),e.req&&e.req.removeListener("finish",s),e.removeListener("end",o),e.removeListener("close",o),e.removeListener("finish",s),e.removeListener("end",c),e.removeListener("error",l),e.removeListener("close",d)}}oI.exports=nI});var sI=P((Ore,aI)=>{"use strict";g();var ep;function Oa(e,t,r){return t=o4(t),t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function o4(e){var t=a4(e,"string");return typeof t=="symbol"?t:String(t)}function a4(e,t){if(typeof e!="object"||e===null)return e;var r=e[Symbol.toPrimitive];if(r!==void 0){var i=r.call(e,t||"default");if(typeof i!="object")return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}var s4=Qd(),Ia=Symbol("lastResolve"),Rs=Symbol("lastReject"),Kf=Symbol("error"),tp=Symbol("ended"),ks=Symbol("lastPromise"),ey=Symbol("handlePromise"),Bs=Symbol("stream");function Aa(e,t){return{value:e,done:t}}function u4(e){var t=e[Ia];if(t!==null){var r=e[Bs].read();r!==null&&(e[ks]=null,e[Ia]=null,e[Rs]=null,t(Aa(r,!1)))}}function c4(e){b.default.nextTick(u4,e)}function f4(e,t){return function(r,i){e.then(function(){if(t[tp]){r(Aa(void 0,!0));return}t[ey](r,i)},i)}}var l4=Object.getPrototypeOf(function(){}),h4=Object.setPrototypeOf((ep={get stream(){return this[Bs]},next:function(){var t=this,r=this[Kf];if(r!==null)return Promise.reject(r);if(this[tp])return Promise.resolve(Aa(void 0,!0));if(this[Bs].destroyed)return new Promise(function(a,s){b.default.nextTick(function(){t[Kf]?s(t[Kf]):a(Aa(void 0,!0))})});var i=this[ks],n;if(i)n=new Promise(f4(i,this));else{var o=this[Bs].read();if(o!==null)return Promise.resolve(Aa(o,!1));n=new Promise(this[ey])}return this[ks]=n,n}},Oa(ep,Symbol.asyncIterator,function(){return this}),Oa(ep,"return",function(){var t=this;return new Promise(function(r,i){t[Bs].destroy(null,function(n){if(n){i(n);return}r(Aa(void 0,!0))})})}),ep),l4),d4=function(t){var r,i=Object.create(h4,(r={},Oa(r,Bs,{value:t,writable:!0}),Oa(r,Ia,{value:null,writable:!0}),Oa(r,Rs,{value:null,writable:!0}),Oa(r,Kf,{value:null,writable:!0}),Oa(r,tp,{value:t._readableState.endEmitted,writable:!0}),Oa(r,ey,{value:function(o,a){var s=i[Bs].read();s?(i[ks]=null,i[Ia]=null,i[Rs]=null,o(Aa(s,!1))):(i[Ia]=o,i[Rs]=a)},writable:!0}),r));return i[ks]=null,s4(t,function(n){if(n&&n.code!=="ERR_STREAM_PREMATURE_CLOSE"){var o=i[Rs];o!==null&&(i[ks]=null,i[Ia]=null,i[Rs]=null,o(n)),i[Kf]=n;return}var a=i[Ia];a!==null&&(i[ks]=null,i[Ia]=null,i[Rs]=null,a(Aa(void 0,!0))),i[tp]=!0}),t.on("readable",c4.bind(null,i)),i};aI.exports=d4});var cI=P((Are,uI)=>{g();uI.exports=function(){throw new Error("Readable.from is not available in the browser")}});var $0=P((Rre,bI)=>{"use strict";g();bI.exports=ot;var Xu;ot.ReadableState=dI;var Pre=Du().EventEmitter,hI=function(t,r){return t.listeners(r).length},Gf=a0(),rp=jt().Buffer,p4=(typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof self<"u"?self:{}).Uint8Array||function(){};function g4(e){return rp.from(e)}function m4(e){return rp.isBuffer(e)||e instanceof p4}var ty=Qi(),He;ty&&ty.debuglog?He=ty.debuglog("stream"):He=function(){};var v4=MO(),uy=F0(),y4=j0(),b4=y4.getHighWaterMark,ip=Ts().codes,_4=ip.ERR_INVALID_ARG_TYPE,w4=ip.ERR_STREAM_PUSH_AFTER_EOF,S4=ip.ERR_METHOD_NOT_IMPLEMENTED,E4=ip.ERR_STREAM_UNSHIFT_AFTER_END_EVENT,Ju,ry,iy;vt()(ot,Gf);var Vf=uy.errorOrDestroy,ny=["error","close","destroy","pause","resume"];function x4(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 dI(e,t,r){Xu=Xu||Ps(),e=e||{},typeof r!="boolean"&&(r=t instanceof Xu),this.objectMode=!!e.objectMode,r&&(this.objectMode=this.objectMode||!!e.readableObjectMode),this.highWaterMark=b4(this,e,"readableHighWaterMark",r),this.buffer=new v4,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&&(Ju||(Ju=$u().StringDecoder),this.decoder=new Ju(e.encoding),this.encoding=e.encoding)}function ot(e){if(Xu=Xu||Ps(),!(this instanceof ot))return new ot(e);var t=this instanceof Xu;this._readableState=new dI(e,this,t),this.readable=!0,e&&(typeof e.read=="function"&&(this._read=e.read),typeof e.destroy=="function"&&(this._destroy=e.destroy)),Gf.call(this)}Object.defineProperty(ot.prototype,"destroyed",{enumerable:!1,get:function(){return this._readableState===void 0?!1:this._readableState.destroyed},set:function(t){this._readableState&&(this._readableState.destroyed=t)}});ot.prototype.destroy=uy.destroy;ot.prototype._undestroy=uy.undestroy;ot.prototype._destroy=function(e,t){t(e)};ot.prototype.push=function(e,t){var r=this._readableState,i;return r.objectMode?i=!0:typeof e=="string"&&(t=t||r.defaultEncoding,t!==r.encoding&&(e=rp.from(e,t),t=""),i=!0),pI(this,e,t,!1,i)};ot.prototype.unshift=function(e){return pI(this,e,null,!0,!1)};function pI(e,t,r,i,n){He("readableAddChunk",t);var o=e._readableState;if(t===null)o.reading=!1,A4(e,o);else{var a;if(n||(a=O4(o,t)),a)Vf(e,a);else if(o.objectMode||t&&t.length>0)if(typeof t!="string"&&!o.objectMode&&Object.getPrototypeOf(t)!==rp.prototype&&(t=g4(t)),i)o.endEmitted?Vf(e,new E4):oy(e,o,t,!0);else if(o.ended)Vf(e,new w4);else{if(o.destroyed)return!1;o.reading=!1,o.decoder&&!r?(t=o.decoder.write(t),o.objectMode||t.length!==0?oy(e,o,t,!1):sy(e,o)):oy(e,o,t,!1)}else i||(o.reading=!1,sy(e,o))}return!o.ended&&(o.length<o.highWaterMark||o.length===0)}function oy(e,t,r,i){t.flowing&&t.length===0&&!t.sync?(t.awaitDrain=0,e.emit("data",r)):(t.length+=t.objectMode?1:r.length,i?t.buffer.unshift(r):t.buffer.push(r),t.needReadable&&np(e)),sy(e,t)}function O4(e,t){var r;return!m4(t)&&typeof t!="string"&&t!==void 0&&!e.objectMode&&(r=new _4("chunk",["string","Buffer","Uint8Array"],t)),r}ot.prototype.isPaused=function(){return this._readableState.flowing===!1};ot.prototype.setEncoding=function(e){Ju||(Ju=$u().StringDecoder);var t=new Ju(e);this._readableState.decoder=t,this._readableState.encoding=this._readableState.decoder.encoding;for(var r=this._readableState.buffer.head,i="";r!==null;)i+=t.write(r.data),r=r.next;return this._readableState.buffer.clear(),i!==""&&this._readableState.buffer.push(i),this._readableState.length=i.length,this};var fI=1073741824;function I4(e){return e>=fI?e=fI:(e--,e|=e>>>1,e|=e>>>2,e|=e>>>4,e|=e>>>8,e|=e>>>16,e++),e}function lI(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=I4(e)),e<=t.length?e:t.ended?t.length:(t.needReadable=!0,0))}ot.prototype.read=function(e){He("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 He("read: emitReadable",t.length,t.ended),t.length===0&&t.ended?ay(this):np(this),null;if(e=lI(e,t),e===0&&t.ended)return t.length===0&&ay(this),null;var i=t.needReadable;He("need readable",i),(t.length===0||t.length-e<t.highWaterMark)&&(i=!0,He("length less than watermark",i)),t.ended||t.reading?(i=!1,He("reading or ended",i)):i&&(He("do read"),t.reading=!0,t.sync=!0,t.length===0&&(t.needReadable=!0),this._read(t.highWaterMark),t.sync=!1,t.reading||(e=lI(r,t)));var n;return e>0?n=vI(e,t):n=null,n===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&&ay(this)),n!==null&&this.emit("data",n),n};function A4(e,t){if(He("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?np(e):(t.needReadable=!1,t.emittedReadable||(t.emittedReadable=!0,gI(e)))}}function np(e){var t=e._readableState;He("emitReadable",t.needReadable,t.emittedReadable),t.needReadable=!1,t.emittedReadable||(He("emitReadable",t.flowing),t.emittedReadable=!0,b.default.nextTick(gI,e))}function gI(e){var t=e._readableState;He("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,cy(e)}function sy(e,t){t.readingMore||(t.readingMore=!0,b.default.nextTick(T4,e,t))}function T4(e,t){for(;!t.reading&&!t.ended&&(t.length<t.highWaterMark||t.flowing&&t.length===0);){var r=t.length;if(He("maybeReadMore read 0"),e.read(0),r===t.length)break}t.readingMore=!1}ot.prototype._read=function(e){Vf(this,new S4("_read()"))};ot.prototype.pipe=function(e,t){var r=this,i=this._readableState;switch(i.pipesCount){case 0:i.pipes=e;break;case 1:i.pipes=[i.pipes,e];break;default:i.pipes.push(e);break}i.pipesCount+=1,He("pipe count=%d opts=%j",i.pipesCount,t);var n=(!t||t.end!==!1)&&e!==b.default.stdout&&e!==b.default.stderr,o=n?s:T;i.endEmitted?b.default.nextTick(o):r.once("end",o),e.on("unpipe",a);function a(R,B){He("onunpipe"),R===r&&B&&B.hasUnpiped===!1&&(B.hasUnpiped=!0,l())}function s(){He("onend"),e.end()}var u=P4(r);e.on("drain",u);var c=!1;function l(){He("cleanup"),e.removeListener("close",y),e.removeListener("finish",_),e.removeListener("drain",u),e.removeListener("error",p),e.removeListener("unpipe",a),r.removeListener("end",s),r.removeListener("end",T),r.removeListener("data",d),c=!0,i.awaitDrain&&(!e._writableState||e._writableState.needDrain)&&u()}r.on("data",d);function d(R){He("ondata");var B=e.write(R);He("dest.write",B),B===!1&&((i.pipesCount===1&&i.pipes===e||i.pipesCount>1&&yI(i.pipes,e)!==-1)&&!c&&(He("false write response, pause",i.awaitDrain),i.awaitDrain++),r.pause())}function p(R){He("onerror",R),T(),e.removeListener("error",p),hI(e,"error")===0&&Vf(e,R)}x4(e,"error",p);function y(){e.removeListener("finish",_),T()}e.once("close",y);function _(){He("onfinish"),e.removeListener("close",y),T()}e.once("finish",_);function T(){He("unpipe"),r.unpipe(e)}return e.emit("pipe",r),i.flowing||(He("pipe resume"),r.resume()),e};function P4(e){return function(){var r=e._readableState;He("pipeOnDrain",r.awaitDrain),r.awaitDrain&&r.awaitDrain--,r.awaitDrain===0&&hI(e,"data")&&(r.flowing=!0,cy(e))}}ot.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 i=t.pipes,n=t.pipesCount;t.pipes=null,t.pipesCount=0,t.flowing=!1;for(var o=0;o<n;o++)i[o].emit("unpipe",this,{hasUnpiped:!1});return this}var a=yI(t.pipes,e);return a===-1?this:(t.pipes.splice(a,1),t.pipesCount-=1,t.pipesCount===1&&(t.pipes=t.pipes[0]),e.emit("unpipe",this,r),this)};ot.prototype.on=function(e,t){var r=Gf.prototype.on.call(this,e,t),i=this._readableState;return e==="data"?(i.readableListening=this.listenerCount("readable")>0,i.flowing!==!1&&this.resume()):e==="readable"&&!i.endEmitted&&!i.readableListening&&(i.readableListening=i.needReadable=!0,i.flowing=!1,i.emittedReadable=!1,He("on readable",i.length,i.reading),i.length?np(this):i.reading||b.default.nextTick(R4,this)),r};ot.prototype.addListener=ot.prototype.on;ot.prototype.removeListener=function(e,t){var r=Gf.prototype.removeListener.call(this,e,t);return e==="readable"&&b.default.nextTick(mI,this),r};ot.prototype.removeAllListeners=function(e){var t=Gf.prototype.removeAllListeners.apply(this,arguments);return(e==="readable"||e===void 0)&&b.default.nextTick(mI,this),t};function mI(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 R4(e){He("readable nexttick read 0"),e.read(0)}ot.prototype.resume=function(){var e=this._readableState;return e.flowing||(He("resume"),e.flowing=!e.readableListening,k4(this,e)),e.paused=!1,this};function k4(e,t){t.resumeScheduled||(t.resumeScheduled=!0,b.default.nextTick(B4,e,t))}function B4(e,t){He("resume",t.reading),t.reading||e.read(0),t.resumeScheduled=!1,e.emit("resume"),cy(e),t.flowing&&!t.reading&&e.read(0)}ot.prototype.pause=function(){return He("call pause flowing=%j",this._readableState.flowing),this._readableState.flowing!==!1&&(He("pause"),this._readableState.flowing=!1,this.emit("pause")),this._readableState.paused=!0,this};function cy(e){var t=e._readableState;for(He("flow",t.flowing);t.flowing&&e.read()!==null;);}ot.prototype.wrap=function(e){var t=this,r=this._readableState,i=!1;e.on("end",function(){if(He("wrapped end"),r.decoder&&!r.ended){var a=r.decoder.end();a&&a.length&&t.push(a)}t.push(null)}),e.on("data",function(a){if(He("wrapped data"),r.decoder&&(a=r.decoder.write(a)),!(r.objectMode&&a==null)&&!(!r.objectMode&&(!a||!a.length))){var s=t.push(a);s||(i=!0,e.pause())}});for(var n in e)this[n]===void 0&&typeof e[n]=="function"&&(this[n]=(function(s){return function(){return e[s].apply(e,arguments)}})(n));for(var o=0;o<ny.length;o++)e.on(ny[o],this.emit.bind(this,ny[o]));return this._read=function(a){He("wrapped _read",a),i&&(i=!1,e.resume())},this};typeof Symbol=="function"&&(ot.prototype[Symbol.asyncIterator]=function(){return ry===void 0&&(ry=sI()),ry(this)});Object.defineProperty(ot.prototype,"readableHighWaterMark",{enumerable:!1,get:function(){return this._readableState.highWaterMark}});Object.defineProperty(ot.prototype,"readableBuffer",{enumerable:!1,get:function(){return this._readableState&&this._readableState.buffer}});Object.defineProperty(ot.prototype,"readableFlowing",{enumerable:!1,get:function(){return this._readableState.flowing},set:function(t){this._readableState&&(this._readableState.flowing=t)}});ot._fromList=vI;Object.defineProperty(ot.prototype,"readableLength",{enumerable:!1,get:function(){return this._readableState.length}});function vI(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 ay(e){var t=e._readableState;He("endReadable",t.endEmitted),t.endEmitted||(t.ended=!0,b.default.nextTick(N4,t,e))}function N4(e,t){if(He("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"&&(ot.from=function(e,t){return iy===void 0&&(iy=cI()),iy(ot,e,t)});function yI(e,t){for(var r=0,i=e.length;r<i;r++)if(e[r]===t)return r;return-1}});var fy=P((Bre,wI)=>{"use strict";g();wI.exports=qo;var op=Ts().codes,C4=op.ERR_METHOD_NOT_IMPLEMENTED,L4=op.ERR_MULTIPLE_CALLBACK,M4=op.ERR_TRANSFORM_ALREADY_TRANSFORMING,D4=op.ERR_TRANSFORM_WITH_LENGTH_0,ap=Ps();vt()(qo,ap);function q4(e,t){var r=this._transformState;r.transforming=!1;var i=r.writecb;if(i===null)return this.emit("error",new L4);r.writechunk=null,r.writecb=null,t!=null&&this.push(t),i(e);var n=this._readableState;n.reading=!1,(n.needReadable||n.length<n.highWaterMark)&&this._read(n.highWaterMark)}function qo(e){if(!(this instanceof qo))return new qo(e);ap.call(this,e),this._transformState={afterTransform:q4.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",H4)}function H4(){var e=this;typeof this._flush=="function"&&!this._readableState.destroyed?this._flush(function(t,r){_I(e,t,r)}):_I(this,null,null)}qo.prototype.push=function(e,t){return this._transformState.needTransform=!1,ap.prototype.push.call(this,e,t)};qo.prototype._transform=function(e,t,r){r(new C4("_transform()"))};qo.prototype._write=function(e,t,r){var i=this._transformState;if(i.writecb=r,i.writechunk=e,i.writeencoding=t,!i.transforming){var n=this._readableState;(i.needTransform||n.needReadable||n.length<n.highWaterMark)&&this._read(n.highWaterMark)}};qo.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};qo.prototype._destroy=function(e,t){ap.prototype._destroy.call(this,e,function(r){t(r)})};function _I(e,t,r){if(t)return e.emit("error",t);if(r!=null&&e.push(r),e._writableState.length)throw new D4;if(e._transformState.transforming)throw new M4;return e.push(null)}});var xI=P((Cre,EI)=>{"use strict";g();EI.exports=Wf;var SI=fy();vt()(Wf,SI);function Wf(e){if(!(this instanceof Wf))return new Wf(e);SI.call(this,e)}Wf.prototype._transform=function(e,t,r){r(null,e)}});var PI=P((Mre,TI)=>{"use strict";g();var ly;function U4(e){var t=!1;return function(){t||(t=!0,e.apply(void 0,arguments))}}var AI=Ts().codes,F4=AI.ERR_MISSING_ARGS,j4=AI.ERR_STREAM_DESTROYED;function OI(e){if(e)throw e}function z4(e){return e.setHeader&&typeof e.abort=="function"}function K4(e,t,r,i){i=U4(i);var n=!1;e.on("close",function(){n=!0}),ly===void 0&&(ly=Qd()),ly(e,{readable:t,writable:r},function(a){if(a)return i(a);n=!0,i()});var o=!1;return function(a){if(!n&&!o){if(o=!0,z4(e))return e.abort();if(typeof e.destroy=="function")return e.destroy();i(a||new j4("pipe"))}}}function II(e){e()}function V4(e,t){return e.pipe(t)}function G4(e){return!e.length||typeof e[e.length-1]!="function"?OI:e.pop()}function W4(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];var i=G4(t);if(Array.isArray(t[0])&&(t=t[0]),t.length<2)throw new F4("streams");var n,o=t.map(function(a,s){var u=s<t.length-1,c=s>0;return K4(a,u,c,function(l){n||(n=l),l&&o.forEach(II),!u&&(o.forEach(II),i(n))})});return t.reduce(V4)}TI.exports=W4});var sp=P((qre,RI)=>{g();RI.exports=tn;var hy=Du().EventEmitter,Y4=vt();Y4(tn,hy);tn.Readable=$0();tn.Writable=W0();tn.Duplex=Ps();tn.Transform=fy();tn.PassThrough=xI();tn.finished=Qd();tn.pipeline=PI();tn.Stream=tn;function tn(){hy.call(this)}tn.prototype.pipe=function(e,t){var r=this;function i(l){e.writable&&e.write(l)===!1&&r.pause&&r.pause()}r.on("data",i);function n(){r.readable&&r.resume&&r.resume()}e.on("drain",n),!e._isStdio&&(!t||t.end!==!1)&&(r.on("end",a),r.on("close",s));var o=!1;function a(){o||(o=!0,e.end())}function s(){o||(o=!0,typeof e.destroy=="function"&&e.destroy())}function u(l){if(c(),hy.listenerCount(this,"error")===0)throw l}r.on("error",u),e.on("error",u);function c(){r.removeListener("data",i),e.removeListener("drain",n),r.removeListener("end",a),r.removeListener("close",s),r.removeListener("error",u),e.removeListener("error",u),r.removeListener("end",c),r.removeListener("close",c),e.removeListener("close",c)}return r.on("end",c),r.on("close",c),e.on("close",c),e.emit("pipe",r),e}});var NI=P((Ure,BI)=>{"use strict";g();var Zn=Qr().Buffer,kI=sp().Transform,Z4=vt();function Ta(e){kI.call(this),this._block=Zn.allocUnsafe(e),this._blockSize=e,this._blockOffset=0,this._length=[0,0,0,0],this._finalized=!1}Z4(Ta,kI);Ta.prototype._transform=function(e,t,r){var i=null;try{this.update(e,t)}catch(n){i=n}r(i)};Ta.prototype._flush=function(e){var t=null;try{this.push(this.digest())}catch(r){t=r}e(t)};var $4=typeof Uint8Array<"u",X4=typeof ArrayBuffer<"u"&&typeof Uint8Array<"u"&&ArrayBuffer.isView&&(Zn.prototype instanceof Uint8Array||Zn.TYPED_ARRAY_SUPPORT);function J4(e,t){if(e instanceof Zn)return e;if(typeof e=="string")return Zn.from(e,t);if(X4&&ArrayBuffer.isView(e)){if(e.byteLength===0)return Zn.alloc(0);var r=Zn.from(e.buffer,e.byteOffset,e.byteLength);if(r.byteLength===e.byteLength)return r}if($4&&e instanceof Uint8Array||Zn.isBuffer(e)&&e.constructor&&typeof e.constructor.isBuffer=="function"&&e.constructor.isBuffer(e))return Zn.from(e);throw new TypeError('The "data" argument must be of type string or an instance of Buffer, TypedArray, or DataView.')}Ta.prototype.update=function(e,t){if(this._finalized)throw new Error("Digest already called");e=J4(e,t);for(var r=this._block,i=0;this._blockOffset+e.length-i>=this._blockSize;){for(var n=this._blockOffset;n<this._blockSize;)r[n++]=e[i++];this._update(),this._blockOffset=0}for(;i<e.length;)r[this._blockOffset++]=e[i++];for(var o=0,a=e.length*8;a>0;++o)this._length[o]+=a,a=this._length[o]/4294967296|0,a>0&&(this._length[o]-=4294967296*a);return this};Ta.prototype._update=function(){throw new Error("_update is not implemented")};Ta.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};Ta.prototype._digest=function(){throw new Error("_digest is not implemented")};BI.exports=Ta});var dy=P((jre,LI)=>{"use strict";g();var Q4=vt(),CI=NI(),e5=Qr().Buffer,t5=new Array(16);function up(){CI.call(this,64),this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878}Q4(up,CI);up.prototype._update=function(){for(var e=t5,t=0;t<16;++t)e[t]=this._block.readInt32LE(t*4);var r=this._a,i=this._b,n=this._c,o=this._d;r=ni(r,i,n,o,e[0],3614090360,7),o=ni(o,r,i,n,e[1],3905402710,12),n=ni(n,o,r,i,e[2],606105819,17),i=ni(i,n,o,r,e[3],3250441966,22),r=ni(r,i,n,o,e[4],4118548399,7),o=ni(o,r,i,n,e[5],1200080426,12),n=ni(n,o,r,i,e[6],2821735955,17),i=ni(i,n,o,r,e[7],4249261313,22),r=ni(r,i,n,o,e[8],1770035416,7),o=ni(o,r,i,n,e[9],2336552879,12),n=ni(n,o,r,i,e[10],4294925233,17),i=ni(i,n,o,r,e[11],2304563134,22),r=ni(r,i,n,o,e[12],1804603682,7),o=ni(o,r,i,n,e[13],4254626195,12),n=ni(n,o,r,i,e[14],2792965006,17),i=ni(i,n,o,r,e[15],1236535329,22),r=oi(r,i,n,o,e[1],4129170786,5),o=oi(o,r,i,n,e[6],3225465664,9),n=oi(n,o,r,i,e[11],643717713,14),i=oi(i,n,o,r,e[0],3921069994,20),r=oi(r,i,n,o,e[5],3593408605,5),o=oi(o,r,i,n,e[10],38016083,9),n=oi(n,o,r,i,e[15],3634488961,14),i=oi(i,n,o,r,e[4],3889429448,20),r=oi(r,i,n,o,e[9],568446438,5),o=oi(o,r,i,n,e[14],3275163606,9),n=oi(n,o,r,i,e[3],4107603335,14),i=oi(i,n,o,r,e[8],1163531501,20),r=oi(r,i,n,o,e[13],2850285829,5),o=oi(o,r,i,n,e[2],4243563512,9),n=oi(n,o,r,i,e[7],1735328473,14),i=oi(i,n,o,r,e[12],2368359562,20),r=ai(r,i,n,o,e[5],4294588738,4),o=ai(o,r,i,n,e[8],2272392833,11),n=ai(n,o,r,i,e[11],1839030562,16),i=ai(i,n,o,r,e[14],4259657740,23),r=ai(r,i,n,o,e[1],2763975236,4),o=ai(o,r,i,n,e[4],1272893353,11),n=ai(n,o,r,i,e[7],4139469664,16),i=ai(i,n,o,r,e[10],3200236656,23),r=ai(r,i,n,o,e[13],681279174,4),o=ai(o,r,i,n,e[0],3936430074,11),n=ai(n,o,r,i,e[3],3572445317,16),i=ai(i,n,o,r,e[6],76029189,23),r=ai(r,i,n,o,e[9],3654602809,4),o=ai(o,r,i,n,e[12],3873151461,11),n=ai(n,o,r,i,e[15],530742520,16),i=ai(i,n,o,r,e[2],3299628645,23),r=si(r,i,n,o,e[0],4096336452,6),o=si(o,r,i,n,e[7],1126891415,10),n=si(n,o,r,i,e[14],2878612391,15),i=si(i,n,o,r,e[5],4237533241,21),r=si(r,i,n,o,e[12],1700485571,6),o=si(o,r,i,n,e[3],2399980690,10),n=si(n,o,r,i,e[10],4293915773,15),i=si(i,n,o,r,e[1],2240044497,21),r=si(r,i,n,o,e[8],1873313359,6),o=si(o,r,i,n,e[15],4264355552,10),n=si(n,o,r,i,e[6],2734768916,15),i=si(i,n,o,r,e[13],1309151649,21),r=si(r,i,n,o,e[4],4149444226,6),o=si(o,r,i,n,e[11],3174756917,10),n=si(n,o,r,i,e[2],718787259,15),i=si(i,n,o,r,e[9],3951481745,21),this._a=this._a+r|0,this._b=this._b+i|0,this._c=this._c+n|0,this._d=this._d+o|0};up.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=e5.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 cp(e,t){return e<<t|e>>>32-t}function ni(e,t,r,i,n,o,a){return cp(e+(t&r|~t&i)+n+o|0,a)+t|0}function oi(e,t,r,i,n,o,a){return cp(e+(t&i|r&~i)+n+o|0,a)+t|0}function ai(e,t,r,i,n,o,a){return cp(e+(t^r^i)+n+o|0,a)+t|0}function si(e,t,r,i,n,o,a){return cp(e+(r^(t|~i))+n+o|0,a)+t|0}LI.exports=up});var DI=P((Kre,MI)=>{g();var r5={}.toString;MI.exports=Array.isArray||function(e){return r5.call(e)=="[object Array]"}});var HI=P((Gre,qI)=>{"use strict";g();var i5=Es(),n5=Sa(),o5=n5("TypedArray.prototype.buffer",!0),a5=k0();qI.exports=o5||function(t){if(!a5(t))throw new i5("Not a Typed Array");return t.buffer}});var fp=P((Yre,FI)=>{"use strict";g();var bn=Qr().Buffer,s5=DI(),u5=HI(),c5=ArrayBuffer.isView||function(t){try{return u5(t),!0}catch{return!1}},f5=typeof Uint8Array<"u",UI=typeof ArrayBuffer<"u"&&typeof Uint8Array<"u",l5=UI&&(bn.prototype instanceof Uint8Array||bn.TYPED_ARRAY_SUPPORT);FI.exports=function(t,r){if(bn.isBuffer(t))return t.constructor&&!("isBuffer"in t)?bn.from(t):t;if(typeof t=="string")return bn.from(t,r);if(UI&&c5(t)){if(t.byteLength===0)return bn.alloc(0);if(l5){var i=bn.from(t.buffer,t.byteOffset,t.byteLength);if(i.byteLength===t.byteLength)return i}var n=t instanceof Uint8Array?t:new Uint8Array(t.buffer,t.byteOffset,t.byteLength),o=bn.from(n);if(o.length===t.byteLength)return o}if(f5&&t instanceof Uint8Array)return bn.from(t);var a=s5(t);if(a)for(var s=0;s<t.length;s+=1){var u=t[s];if(typeof u!="number"||u<0||u>255||~~u!==u)throw new RangeError("Array items must be numbers in the range 0-255.")}if(a||bn.isBuffer(t)&&t.constructor&&typeof t.constructor.isBuffer=="function"&&t.constructor.isBuffer(t))return bn.from(t);throw new TypeError('The "data" argument must be a string, an Array, a Buffer, a Uint8Array, or a DataView.')}});var VI=P(($re,KI)=>{"use strict";g();var h5=Qr().Buffer,d5=fp(),zI=typeof Uint8Array<"u",p5=zI&&typeof ArrayBuffer<"u",jI=p5&&ArrayBuffer.isView;KI.exports=function(e,t){if(typeof e=="string"||h5.isBuffer(e)||zI&&e instanceof Uint8Array||jI&&jI(e))return d5(e,t);throw new TypeError('The "data" argument must be a string, a Buffer, a Uint8Array, or a DataView')}});var Yf=P((Jre,py)=>{"use strict";g();typeof b.default>"u"||!b.default.version||b.default.version.indexOf("v0.")===0||b.default.version.indexOf("v1.")===0&&b.default.version.indexOf("v1.8.")!==0?py.exports={nextTick:g5}:py.exports=b.default;function g5(e,t,r,i){if(typeof e!="function")throw new TypeError('"callback" argument must be a function');var n=arguments.length,o,a;switch(n){case 0:case 1:return b.default.nextTick(e);case 2:return b.default.nextTick(function(){e.call(null,t)});case 3:return b.default.nextTick(function(){e.call(null,t,r)});case 4:return b.default.nextTick(function(){e.call(null,t,r,i)});default:for(o=new Array(n-1),a=0;a<o.length;)o[a++]=arguments[a];return b.default.nextTick(function(){e.apply(null,o)})}}});var WI=P((eie,GI)=>{g();var m5={}.toString;GI.exports=Array.isArray||function(e){return m5.call(e)=="[object Array]"}});var gy=P((rie,YI)=>{g();YI.exports=Du().EventEmitter});var hp=P((my,$I)=>{g();var lp=jt(),Ho=lp.Buffer;function ZI(e,t){for(var r in e)t[r]=e[r]}Ho.from&&Ho.alloc&&Ho.allocUnsafe&&Ho.allocUnsafeSlow?$I.exports=lp:(ZI(lp,my),my.Buffer=Qu);function Qu(e,t,r){return Ho(e,t,r)}ZI(Ho,Qu);Qu.from=function(e,t,r){if(typeof e=="number")throw new TypeError("Argument must not be a number");return Ho(e,t,r)};Qu.alloc=function(e,t,r){if(typeof e!="number")throw new TypeError("Argument must be a number");var i=Ho(e);return t!==void 0?typeof r=="string"?i.fill(t,r):i.fill(t):i.fill(0),i};Qu.allocUnsafe=function(e){if(typeof e!="number")throw new TypeError("Argument must be a number");return Ho(e)};Qu.allocUnsafeSlow=function(e){if(typeof e!="number")throw new TypeError("Argument must be a number");return lp.SlowBuffer(e)}});var ec=P(ui=>{g();function v5(e){return Array.isArray?Array.isArray(e):dp(e)==="[object Array]"}ui.isArray=v5;function y5(e){return typeof e=="boolean"}ui.isBoolean=y5;function b5(e){return e===null}ui.isNull=b5;function _5(e){return e==null}ui.isNullOrUndefined=_5;function w5(e){return typeof e=="number"}ui.isNumber=w5;function S5(e){return typeof e=="string"}ui.isString=S5;function E5(e){return typeof e=="symbol"}ui.isSymbol=E5;function x5(e){return e===void 0}ui.isUndefined=x5;function O5(e){return dp(e)==="[object RegExp]"}ui.isRegExp=O5;function I5(e){return typeof e=="object"&&e!==null}ui.isObject=I5;function A5(e){return dp(e)==="[object Date]"}ui.isDate=A5;function T5(e){return dp(e)==="[object Error]"||e instanceof Error}ui.isError=T5;function P5(e){return typeof e=="function"}ui.isFunction=P5;function R5(e){return e===null||typeof e=="boolean"||typeof e=="number"||typeof e=="string"||typeof e=="symbol"||typeof e>"u"}ui.isPrimitive=R5;ui.isBuffer=jt().Buffer.isBuffer;function dp(e){return Object.prototype.toString.call(e)}});var JI=P((sie,vy)=>{"use strict";g();function k5(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}var XI=hp().Buffer,Zf=Qi();function B5(e,t,r){e.copy(t,r)}vy.exports=(function(){function e(){k5(this,e),this.head=null,this.tail=null,this.length=0}return e.prototype.push=function(r){var i={data:r,next:null};this.length>0?this.tail.next=i:this.head=i,this.tail=i,++this.length},e.prototype.unshift=function(r){var i={data:r,next:this.head};this.length===0&&(this.tail=i),this.head=i,++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 i=this.head,n=""+i.data;i=i.next;)n+=r+i.data;return n},e.prototype.concat=function(r){if(this.length===0)return XI.alloc(0);for(var i=XI.allocUnsafe(r>>>0),n=this.head,o=0;n;)B5(n.data,i,o),o+=n.data.length,n=n.next;return i},e})();Zf&&Zf.inspect&&Zf.inspect.custom&&(vy.exports.prototype[Zf.inspect.custom]=function(){var e=Zf.inspect({length:this.length});return this.constructor.name+" "+e})});var yy=P((cie,QI)=>{"use strict";g();var pp=Yf();function N5(e,t){var r=this,i=this._readableState&&this._readableState.destroyed,n=this._writableState&&this._writableState.destroyed;return i||n?(t?t(e):e&&(this._writableState?this._writableState.errorEmitted||(this._writableState.errorEmitted=!0,pp.nextTick(gp,this,e)):pp.nextTick(gp,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,pp.nextTick(gp,r,o)):pp.nextTick(gp,r,o):t&&t(o)}),this)}function C5(){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 gp(e,t){e.emit("error",t)}QI.exports={destroy:N5,undestroy:C5}});var _y=P((lie,sA)=>{"use strict";g();var Ns=Yf();sA.exports=Sr;function tA(e){var t=this;this.next=null,this.entry=null,this.finish=function(){J5(t,e)}}var L5=!b.default.browser&&["v0.10","v0.9."].indexOf(b.default.version.slice(0,5))>-1?setImmediate:Ns.nextTick,tc;Sr.WritableState=Xf;var rA=Object.create(ec());rA.inherits=vt();var M5={deprecate:K0()},iA=gy(),vp=hp().Buffer,D5=(typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof self<"u"?self:{}).Uint8Array||function(){};function q5(e){return vp.from(e)}function H5(e){return vp.isBuffer(e)||e instanceof D5}var nA=yy();rA.inherits(Sr,iA);function U5(){}function Xf(e,t){tc=tc||Cs(),e=e||{};var r=t instanceof tc;this.objectMode=!!e.objectMode,r&&(this.objectMode=this.objectMode||!!e.writableObjectMode);var i=e.highWaterMark,n=e.writableHighWaterMark,o=this.objectMode?16:16*1024;i||i===0?this.highWaterMark=i:r&&(n||n===0)?this.highWaterMark=n: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 a=e.decodeStrings===!1;this.decodeStrings=!a,this.defaultEncoding=e.defaultEncoding||"utf8",this.length=0,this.writing=!1,this.corked=0,this.sync=!0,this.bufferProcessing=!1,this.onwrite=function(s){W5(t,s)},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 tA(this)}Xf.prototype.getBuffer=function(){for(var t=this.bufferedRequest,r=[];t;)r.push(t),t=t.next;return r};(function(){try{Object.defineProperty(Xf.prototype,"buffer",{get:M5.deprecate(function(){return this.getBuffer()},"_writableState.buffer is deprecated. Use _writableState.getBuffer instead.","DEP0003")})}catch{}})();var mp;typeof Symbol=="function"&&Symbol.hasInstance&&typeof Function.prototype[Symbol.hasInstance]=="function"?(mp=Function.prototype[Symbol.hasInstance],Object.defineProperty(Sr,Symbol.hasInstance,{value:function(e){return mp.call(this,e)?!0:this!==Sr?!1:e&&e._writableState instanceof Xf}})):mp=function(e){return e instanceof this};function Sr(e){if(tc=tc||Cs(),!mp.call(Sr,this)&&!(this instanceof tc))return new Sr(e);this._writableState=new Xf(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)),iA.call(this)}Sr.prototype.pipe=function(){this.emit("error",new Error("Cannot pipe, not readable"))};function F5(e,t){var r=new Error("write after end");e.emit("error",r),Ns.nextTick(t,r)}function j5(e,t,r,i){var n=!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),Ns.nextTick(i,o),n=!1),n}Sr.prototype.write=function(e,t,r){var i=this._writableState,n=!1,o=!i.objectMode&&H5(e);return o&&!vp.isBuffer(e)&&(e=q5(e)),typeof t=="function"&&(r=t,t=null),o?t="buffer":t||(t=i.defaultEncoding),typeof r!="function"&&(r=U5),i.ended?F5(this,r):(o||j5(this,i,e,r))&&(i.pendingcb++,n=K5(this,i,o,e,t,r)),n};Sr.prototype.cork=function(){var e=this._writableState;e.corked++};Sr.prototype.uncork=function(){var e=this._writableState;e.corked&&(e.corked--,!e.writing&&!e.corked&&!e.bufferProcessing&&e.bufferedRequest&&oA(this,e))};Sr.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 z5(e,t,r){return!e.objectMode&&e.decodeStrings!==!1&&typeof t=="string"&&(t=vp.from(t,r)),t}Object.defineProperty(Sr.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}});function K5(e,t,r,i,n,o){if(!r){var a=z5(t,i,n);i!==a&&(r=!0,n="buffer",i=a)}var s=t.objectMode?1:i.length;t.length+=s;var u=t.length<t.highWaterMark;if(u||(t.needDrain=!0),t.writing||t.corked){var c=t.lastBufferedRequest;t.lastBufferedRequest={chunk:i,encoding:n,isBuf:r,callback:o,next:null},c?c.next=t.lastBufferedRequest:t.bufferedRequest=t.lastBufferedRequest,t.bufferedRequestCount+=1}else by(e,t,!1,s,i,n,o);return u}function by(e,t,r,i,n,o,a){t.writelen=i,t.writecb=a,t.writing=!0,t.sync=!0,r?e._writev(n,t.onwrite):e._write(n,o,t.onwrite),t.sync=!1}function V5(e,t,r,i,n){--t.pendingcb,r?(Ns.nextTick(n,i),Ns.nextTick($f,e,t),e._writableState.errorEmitted=!0,e.emit("error",i)):(n(i),e._writableState.errorEmitted=!0,e.emit("error",i),$f(e,t))}function G5(e){e.writing=!1,e.writecb=null,e.length-=e.writelen,e.writelen=0}function W5(e,t){var r=e._writableState,i=r.sync,n=r.writecb;if(G5(r),t)V5(e,r,i,t,n);else{var o=aA(r);!o&&!r.corked&&!r.bufferProcessing&&r.bufferedRequest&&oA(e,r),i?L5(eA,e,r,o,n):eA(e,r,o,n)}}function eA(e,t,r,i){r||Y5(e,t),t.pendingcb--,i(),$f(e,t)}function Y5(e,t){t.length===0&&t.needDrain&&(t.needDrain=!1,e.emit("drain"))}function oA(e,t){t.bufferProcessing=!0;var r=t.bufferedRequest;if(e._writev&&r&&r.next){var i=t.bufferedRequestCount,n=new Array(i),o=t.corkedRequestsFree;o.entry=r;for(var a=0,s=!0;r;)n[a]=r,r.isBuf||(s=!1),r=r.next,a+=1;n.allBuffers=s,by(e,t,!0,t.length,n,"",o.finish),t.pendingcb++,t.lastBufferedRequest=null,o.next?(t.corkedRequestsFree=o.next,o.next=null):t.corkedRequestsFree=new tA(t),t.bufferedRequestCount=0}else{for(;r;){var u=r.chunk,c=r.encoding,l=r.callback,d=t.objectMode?1:u.length;if(by(e,t,!1,d,u,c,l),r=r.next,t.bufferedRequestCount--,t.writing)break}r===null&&(t.lastBufferedRequest=null)}t.bufferedRequest=r,t.bufferProcessing=!1}Sr.prototype._write=function(e,t,r){r(new Error("_write() is not implemented"))};Sr.prototype._writev=null;Sr.prototype.end=function(e,t,r){var i=this._writableState;typeof e=="function"?(r=e,e=null,t=null):typeof t=="function"&&(r=t,t=null),e!=null&&this.write(e,t),i.corked&&(i.corked=1,this.uncork()),i.ending||X5(this,i,r)};function aA(e){return e.ending&&e.length===0&&e.bufferedRequest===null&&!e.finished&&!e.writing}function Z5(e,t){e._final(function(r){t.pendingcb--,r&&e.emit("error",r),t.prefinished=!0,e.emit("prefinish"),$f(e,t)})}function $5(e,t){!t.prefinished&&!t.finalCalled&&(typeof e._final=="function"?(t.pendingcb++,t.finalCalled=!0,Ns.nextTick(Z5,e,t)):(t.prefinished=!0,e.emit("prefinish")))}function $f(e,t){var r=aA(t);return r&&($5(e,t),t.pendingcb===0&&(t.finished=!0,e.emit("finish"))),r}function X5(e,t,r){t.ending=!0,$f(e,t),r&&(t.finished?Ns.nextTick(r):e.once("finish",r)),t.ended=!0,e.writable=!1}function J5(e,t,r){var i=e.entry;for(e.entry=null;i;){var n=i.callback;t.pendingcb--,n(r),i=i.next}t.corkedRequestsFree.next=e}Object.defineProperty(Sr.prototype,"destroyed",{get:function(){return this._writableState===void 0?!1:this._writableState.destroyed},set:function(e){this._writableState&&(this._writableState.destroyed=e)}});Sr.prototype.destroy=nA.destroy;Sr.prototype._undestroy=nA.undestroy;Sr.prototype._destroy=function(e,t){this.end(),t(e)}});var Cs=P((die,lA)=>{"use strict";g();var uA=Yf(),Q5=Object.keys||function(e){var t=[];for(var r in e)t.push(r);return t};lA.exports=Uo;var cA=Object.create(ec());cA.inherits=vt();var fA=Ey(),Sy=_y();cA.inherits(Uo,fA);for(wy=Q5(Sy.prototype),yp=0;yp<wy.length;yp++)bp=wy[yp],Uo.prototype[bp]||(Uo.prototype[bp]=Sy.prototype[bp]);var wy,bp,yp;function Uo(e){if(!(this instanceof Uo))return new Uo(e);fA.call(this,e),Sy.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",ej)}Object.defineProperty(Uo.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}});function ej(){this.allowHalfOpen||this._writableState.ended||uA.nextTick(tj,this)}function tj(e){e.end()}Object.defineProperty(Uo.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)}});Uo.prototype._destroy=function(e,t){this.push(null),this.end(),uA.nextTick(t,e)}});var Ey=P((mie,EA)=>{"use strict";g();var ic=Yf();EA.exports=At;var rj=WI(),Jf;At.ReadableState=yA;var gie=Du().EventEmitter,gA=function(e,t){return e.listeners(t).length},Ty=gy(),Qf=hp().Buffer,ij=(typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof self<"u"?self:{}).Uint8Array||function(){};function nj(e){return Qf.from(e)}function oj(e){return Qf.isBuffer(e)||e instanceof ij}var mA=Object.create(ec());mA.inherits=vt();var xy=Qi(),ft=void 0;xy&&xy.debuglog?ft=xy.debuglog("stream"):ft=function(){};var aj=JI(),vA=yy(),rc;mA.inherits(At,Ty);var Oy=["error","close","destroy","pause","resume"];function sj(e,t,r){if(typeof e.prependListener=="function")return e.prependListener(t,r);!e._events||!e._events[t]?e.on(t,r):rj(e._events[t])?e._events[t].unshift(r):e._events[t]=[r,e._events[t]]}function yA(e,t){Jf=Jf||Cs(),e=e||{};var r=t instanceof Jf;this.objectMode=!!e.objectMode,r&&(this.objectMode=this.objectMode||!!e.readableObjectMode);var i=e.highWaterMark,n=e.readableHighWaterMark,o=this.objectMode?16:16*1024;i||i===0?this.highWaterMark=i:r&&(n||n===0)?this.highWaterMark=n:this.highWaterMark=o,this.highWaterMark=Math.floor(this.highWaterMark),this.buffer=new aj,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&&(rc||(rc=$u().StringDecoder),this.decoder=new rc(e.encoding),this.encoding=e.encoding)}function At(e){if(Jf=Jf||Cs(),!(this instanceof At))return new At(e);this._readableState=new yA(e,this),this.readable=!0,e&&(typeof e.read=="function"&&(this._read=e.read),typeof e.destroy=="function"&&(this._destroy=e.destroy)),Ty.call(this)}Object.defineProperty(At.prototype,"destroyed",{get:function(){return this._readableState===void 0?!1:this._readableState.destroyed},set:function(e){this._readableState&&(this._readableState.destroyed=e)}});At.prototype.destroy=vA.destroy;At.prototype._undestroy=vA.undestroy;At.prototype._destroy=function(e,t){this.push(null),t(e)};At.prototype.push=function(e,t){var r=this._readableState,i;return r.objectMode?i=!0:typeof e=="string"&&(t=t||r.defaultEncoding,t!==r.encoding&&(e=Qf.from(e,t),t=""),i=!0),bA(this,e,t,!1,i)};At.prototype.unshift=function(e){return bA(this,e,null,!0,!1)};function bA(e,t,r,i,n){var o=e._readableState;if(t===null)o.reading=!1,lj(e,o);else{var a;n||(a=uj(o,t)),a?e.emit("error",a):o.objectMode||t&&t.length>0?(typeof t!="string"&&!o.objectMode&&Object.getPrototypeOf(t)!==Qf.prototype&&(t=nj(t)),i?o.endEmitted?e.emit("error",new Error("stream.unshift() after end event")):Iy(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?Iy(e,o,t,!1):_A(e,o)):Iy(e,o,t,!1))):i||(o.reading=!1)}return cj(o)}function Iy(e,t,r,i){t.flowing&&t.length===0&&!t.sync?(e.emit("data",r),e.read(0)):(t.length+=t.objectMode?1:r.length,i?t.buffer.unshift(r):t.buffer.push(r),t.needReadable&&_p(e)),_A(e,t)}function uj(e,t){var r;return!oj(t)&&typeof t!="string"&&t!==void 0&&!e.objectMode&&(r=new TypeError("Invalid non-string/buffer chunk")),r}function cj(e){return!e.ended&&(e.needReadable||e.length<e.highWaterMark||e.length===0)}At.prototype.isPaused=function(){return this._readableState.flowing===!1};At.prototype.setEncoding=function(e){return rc||(rc=$u().StringDecoder),this._readableState.decoder=new rc(e),this._readableState.encoding=e,this};var hA=8388608;function fj(e){return e>=hA?e=hA:(e--,e|=e>>>1,e|=e>>>2,e|=e>>>4,e|=e>>>8,e|=e>>>16,e++),e}function dA(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=fj(e)),e<=t.length?e:t.ended?t.length:(t.needReadable=!0,0))}At.prototype.read=function(e){ft("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 ft("read: emitReadable",t.length,t.ended),t.length===0&&t.ended?Ay(this):_p(this),null;if(e=dA(e,t),e===0&&t.ended)return t.length===0&&Ay(this),null;var i=t.needReadable;ft("need readable",i),(t.length===0||t.length-e<t.highWaterMark)&&(i=!0,ft("length less than watermark",i)),t.ended||t.reading?(i=!1,ft("reading or ended",i)):i&&(ft("do read"),t.reading=!0,t.sync=!0,t.length===0&&(t.needReadable=!0),this._read(t.highWaterMark),t.sync=!1,t.reading||(e=dA(r,t)));var n;return e>0?n=wA(e,t):n=null,n===null?(t.needReadable=!0,e=0):t.length-=e,t.length===0&&(t.ended||(t.needReadable=!0),r!==e&&t.ended&&Ay(this)),n!==null&&this.emit("data",n),n};function lj(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,_p(e)}}function _p(e){var t=e._readableState;t.needReadable=!1,t.emittedReadable||(ft("emitReadable",t.flowing),t.emittedReadable=!0,t.sync?ic.nextTick(pA,e):pA(e))}function pA(e){ft("emit readable"),e.emit("readable"),Py(e)}function _A(e,t){t.readingMore||(t.readingMore=!0,ic.nextTick(hj,e,t))}function hj(e,t){for(var r=t.length;!t.reading&&!t.flowing&&!t.ended&&t.length<t.highWaterMark&&(ft("maybeReadMore read 0"),e.read(0),r!==t.length);)r=t.length;t.readingMore=!1}At.prototype._read=function(e){this.emit("error",new Error("_read() is not implemented"))};At.prototype.pipe=function(e,t){var r=this,i=this._readableState;switch(i.pipesCount){case 0:i.pipes=e;break;case 1:i.pipes=[i.pipes,e];break;default:i.pipes.push(e);break}i.pipesCount+=1,ft("pipe count=%d opts=%j",i.pipesCount,t);var n=(!t||t.end!==!1)&&e!==b.default.stdout&&e!==b.default.stderr,o=n?s:R;i.endEmitted?ic.nextTick(o):r.once("end",o),e.on("unpipe",a);function a(B,H){ft("onunpipe"),B===r&&H&&H.hasUnpiped===!1&&(H.hasUnpiped=!0,l())}function s(){ft("onend"),e.end()}var u=dj(r);e.on("drain",u);var c=!1;function l(){ft("cleanup"),e.removeListener("close",_),e.removeListener("finish",T),e.removeListener("drain",u),e.removeListener("error",y),e.removeListener("unpipe",a),r.removeListener("end",s),r.removeListener("end",R),r.removeListener("data",p),c=!0,i.awaitDrain&&(!e._writableState||e._writableState.needDrain)&&u()}var d=!1;r.on("data",p);function p(B){ft("ondata"),d=!1;var H=e.write(B);H===!1&&!d&&((i.pipesCount===1&&i.pipes===e||i.pipesCount>1&&SA(i.pipes,e)!==-1)&&!c&&(ft("false write response, pause",i.awaitDrain),i.awaitDrain++,d=!0),r.pause())}function y(B){ft("onerror",B),R(),e.removeListener("error",y),gA(e,"error")===0&&e.emit("error",B)}sj(e,"error",y);function _(){e.removeListener("finish",T),R()}e.once("close",_);function T(){ft("onfinish"),e.removeListener("close",_),R()}e.once("finish",T);function R(){ft("unpipe"),r.unpipe(e)}return e.emit("pipe",r),i.flowing||(ft("pipe resume"),r.resume()),e};function dj(e){return function(){var t=e._readableState;ft("pipeOnDrain",t.awaitDrain),t.awaitDrain&&t.awaitDrain--,t.awaitDrain===0&&gA(e,"data")&&(t.flowing=!0,Py(e))}}At.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 i=t.pipes,n=t.pipesCount;t.pipes=null,t.pipesCount=0,t.flowing=!1;for(var o=0;o<n;o++)i[o].emit("unpipe",this,{hasUnpiped:!1});return this}var a=SA(t.pipes,e);return a===-1?this:(t.pipes.splice(a,1),t.pipesCount-=1,t.pipesCount===1&&(t.pipes=t.pipes[0]),e.emit("unpipe",this,r),this)};At.prototype.on=function(e,t){var r=Ty.prototype.on.call(this,e,t);if(e==="data")this._readableState.flowing!==!1&&this.resume();else if(e==="readable"){var i=this._readableState;!i.endEmitted&&!i.readableListening&&(i.readableListening=i.needReadable=!0,i.emittedReadable=!1,i.reading?i.length&&_p(this):ic.nextTick(pj,this))}return r};At.prototype.addListener=At.prototype.on;function pj(e){ft("readable nexttick read 0"),e.read(0)}At.prototype.resume=function(){var e=this._readableState;return e.flowing||(ft("resume"),e.flowing=!0,gj(this,e)),this};function gj(e,t){t.resumeScheduled||(t.resumeScheduled=!0,ic.nextTick(mj,e,t))}function mj(e,t){t.reading||(ft("resume read 0"),e.read(0)),t.resumeScheduled=!1,t.awaitDrain=0,e.emit("resume"),Py(e),t.flowing&&!t.reading&&e.read(0)}At.prototype.pause=function(){return ft("call pause flowing=%j",this._readableState.flowing),this._readableState.flowing!==!1&&(ft("pause"),this._readableState.flowing=!1,this.emit("pause")),this};function Py(e){var t=e._readableState;for(ft("flow",t.flowing);t.flowing&&e.read()!==null;);}At.prototype.wrap=function(e){var t=this,r=this._readableState,i=!1;e.on("end",function(){if(ft("wrapped end"),r.decoder&&!r.ended){var a=r.decoder.end();a&&a.length&&t.push(a)}t.push(null)}),e.on("data",function(a){if(ft("wrapped data"),r.decoder&&(a=r.decoder.write(a)),!(r.objectMode&&a==null)&&!(!r.objectMode&&(!a||!a.length))){var s=t.push(a);s||(i=!0,e.pause())}});for(var n in e)this[n]===void 0&&typeof e[n]=="function"&&(this[n]=(function(a){return function(){return e[a].apply(e,arguments)}})(n));for(var o=0;o<Oy.length;o++)e.on(Oy[o],this.emit.bind(this,Oy[o]));return this._read=function(a){ft("wrapped _read",a),i&&(i=!1,e.resume())},this};Object.defineProperty(At.prototype,"readableHighWaterMark",{enumerable:!1,get:function(){return this._readableState.highWaterMark}});At._fromList=wA;function wA(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=vj(e,t.buffer,t.decoder),r}function vj(e,t,r){var i;return e<t.head.data.length?(i=t.head.data.slice(0,e),t.head.data=t.head.data.slice(e)):e===t.head.data.length?i=t.shift():i=r?yj(e,t):bj(e,t),i}function yj(e,t){var r=t.head,i=1,n=r.data;for(e-=n.length;r=r.next;){var o=r.data,a=e>o.length?o.length:e;if(a===o.length?n+=o:n+=o.slice(0,e),e-=a,e===0){a===o.length?(++i,r.next?t.head=r.next:t.head=t.tail=null):(t.head=r,r.data=o.slice(a));break}++i}return t.length-=i,n}function bj(e,t){var r=Qf.allocUnsafe(e),i=t.head,n=1;for(i.data.copy(r),e-=i.data.length;i=i.next;){var o=i.data,a=e>o.length?o.length:e;if(o.copy(r,r.length-e,0,a),e-=a,e===0){a===o.length?(++n,i.next?t.head=i.next:t.head=t.tail=null):(t.head=i,i.data=o.slice(a));break}++n}return t.length-=n,r}function Ay(e){var t=e._readableState;if(t.length>0)throw new Error('"endReadable()" called on non-empty stream');t.endEmitted||(t.ended=!0,ic.nextTick(_j,t,e))}function _j(e,t){!e.endEmitted&&e.length===0&&(e.endEmitted=!0,t.readable=!1,t.emit("end"))}function SA(e,t){for(var r=0,i=e.length;r<i;r++)if(e[r]===t)return r;return-1}});var Ry=P((yie,IA)=>{"use strict";g();IA.exports=Fo;var wp=Cs(),OA=Object.create(ec());OA.inherits=vt();OA.inherits(Fo,wp);function wj(e,t){var r=this._transformState;r.transforming=!1;var i=r.writecb;if(!i)return this.emit("error",new Error("write callback called multiple times"));r.writechunk=null,r.writecb=null,t!=null&&this.push(t),i(e);var n=this._readableState;n.reading=!1,(n.needReadable||n.length<n.highWaterMark)&&this._read(n.highWaterMark)}function Fo(e){if(!(this instanceof Fo))return new Fo(e);wp.call(this,e),this._transformState={afterTransform:wj.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",Sj)}function Sj(){var e=this;typeof this._flush=="function"?this._flush(function(t,r){xA(e,t,r)}):xA(this,null,null)}Fo.prototype.push=function(e,t){return this._transformState.needTransform=!1,wp.prototype.push.call(this,e,t)};Fo.prototype._transform=function(e,t,r){throw new Error("_transform() is not implemented")};Fo.prototype._write=function(e,t,r){var i=this._transformState;if(i.writecb=r,i.writechunk=e,i.writeencoding=t,!i.transforming){var n=this._readableState;(i.needTransform||n.needReadable||n.length<n.highWaterMark)&&this._read(n.highWaterMark)}};Fo.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};Fo.prototype._destroy=function(e,t){var r=this;wp.prototype._destroy.call(this,e,function(i){t(i),r.emit("close")})};function xA(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 RA=P((_ie,PA)=>{"use strict";g();PA.exports=el;var AA=Ry(),TA=Object.create(ec());TA.inherits=vt();TA.inherits(el,AA);function el(e){if(!(this instanceof el))return new el(e);AA.call(this,e)}el.prototype._transform=function(e,t,r){r(null,e)}});var BA=P(($n,kA)=>{g();$n=kA.exports=Ey();$n.Stream=$n;$n.Readable=$n;$n.Writable=_y();$n.Duplex=Cs();$n.Transform=Ry();$n.PassThrough=RA()});var LA=P((Eie,CA)=>{"use strict";g();var Ej=Qr().Buffer,xj=VI(),NA=BA().Transform,Oj=vt();function Pa(e){NA.call(this),this._block=Ej.allocUnsafe(e),this._blockSize=e,this._blockOffset=0,this._length=[0,0,0,0],this._finalized=!1}Oj(Pa,NA);Pa.prototype._transform=function(e,t,r){var i=null;try{this.update(e,t)}catch(n){i=n}r(i)};Pa.prototype._flush=function(e){var t=null;try{this.push(this.digest())}catch(r){t=r}e(t)};Pa.prototype.update=function(e,t){if(this._finalized)throw new Error("Digest already called");for(var r=xj(e,t),i=this._block,n=0;this._blockOffset+r.length-n>=this._blockSize;){for(var o=this._blockOffset;o<this._blockSize;)i[o]=r[n],o+=1,n+=1;this._update(),this._blockOffset=0}for(;n<r.length;)i[this._blockOffset]=r[n],this._blockOffset+=1,n+=1;for(var a=0,s=r.length*8;s>0;++a)this._length[a]+=s,s=this._length[a]/4294967296|0,s>0&&(this._length[a]-=4294967296*s);return this};Pa.prototype._update=function(){throw new Error("_update is not implemented")};Pa.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};Pa.prototype._digest=function(){throw new Error("_digest is not implemented")};CA.exports=Pa});var By=P((Oie,jA)=>{"use strict";g();var ky=jt().Buffer,Ij=vt(),FA=LA(),Aj=new Array(16),tl=[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],rl=[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],il=[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],nl=[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],ol=[0,1518500249,1859775393,2400959708,2840853838],al=[1352829926,1548603684,1836072691,2053994217,0];function Ls(e,t){return e<<t|e>>>32-t}function MA(e,t,r,i,n,o,a,s){return Ls(e+(t^r^i)+o+a|0,s)+n|0}function DA(e,t,r,i,n,o,a,s){return Ls(e+(t&r|~t&i)+o+a|0,s)+n|0}function qA(e,t,r,i,n,o,a,s){return Ls(e+((t|~r)^i)+o+a|0,s)+n|0}function HA(e,t,r,i,n,o,a,s){return Ls(e+(t&i|r&~i)+o+a|0,s)+n|0}function UA(e,t,r,i,n,o,a,s){return Ls(e+(t^(r|~i))+o+a|0,s)+n|0}function Sp(){FA.call(this,64),this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878,this._e=3285377520}Ij(Sp,FA);Sp.prototype._update=function(){for(var e=Aj,t=0;t<16;++t)e[t]=this._block.readInt32LE(t*4);for(var r=this._a|0,i=this._b|0,n=this._c|0,o=this._d|0,a=this._e|0,s=this._a|0,u=this._b|0,c=this._c|0,l=this._d|0,d=this._e|0,p=0;p<80;p+=1){var y,_;p<16?(y=MA(r,i,n,o,a,e[tl[p]],ol[0],il[p]),_=UA(s,u,c,l,d,e[rl[p]],al[0],nl[p])):p<32?(y=DA(r,i,n,o,a,e[tl[p]],ol[1],il[p]),_=HA(s,u,c,l,d,e[rl[p]],al[1],nl[p])):p<48?(y=qA(r,i,n,o,a,e[tl[p]],ol[2],il[p]),_=qA(s,u,c,l,d,e[rl[p]],al[2],nl[p])):p<64?(y=HA(r,i,n,o,a,e[tl[p]],ol[3],il[p]),_=DA(s,u,c,l,d,e[rl[p]],al[3],nl[p])):(y=UA(r,i,n,o,a,e[tl[p]],ol[4],il[p]),_=MA(s,u,c,l,d,e[rl[p]],al[4],nl[p])),r=a,a=o,o=Ls(n,10),n=i,i=y,s=d,d=l,l=Ls(c,10),c=u,u=_}var T=this._b+n+l|0;this._b=this._c+o+d|0,this._c=this._d+a+s|0,this._d=this._e+r+u|0,this._e=this._a+i+c|0,this._a=T};Sp.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=ky.alloc?ky.alloc(20):new ky(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};jA.exports=Sp});var Ms=P((Aie,zA)=>{"use strict";g();var Tj=Qr().Buffer,Pj=fp();function Ep(e,t){this._block=Tj.alloc(e),this._finalSize=t,this._blockSize=e,this._len=0}Ep.prototype.update=function(e,t){e=Pj(e,t||"utf8");for(var r=this._block,i=this._blockSize,n=e.length,o=this._len,a=0;a<n;){for(var s=o%i,u=Math.min(n-a,i-s),c=0;c<u;c++)r[s+c]=e[a+c];o+=u,a+=u,o%i===0&&this._update(r)}return this._len+=n,this};Ep.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 i=(r&4294967295)>>>0,n=(r-i)/4294967296;this._block.writeUInt32BE(n,this._blockSize-8),this._block.writeUInt32BE(i,this._blockSize-4)}this._update(this._block);var o=this._hash();return e?o.toString(e):o};Ep.prototype._update=function(){throw new Error("_update must be implemented by subclass")};zA.exports=Ep});var GA=P((Pie,VA)=>{"use strict";g();var Rj=vt(),KA=Ms(),kj=Qr().Buffer,Bj=[1518500249,1859775393,-1894007588,-899497514],Nj=new Array(80);function sl(){this.init(),this._w=Nj,KA.call(this,64,56)}Rj(sl,KA);sl.prototype.init=function(){return this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878,this._e=3285377520,this};function Cj(e){return e<<5|e>>>27}function Lj(e){return e<<30|e>>>2}function Mj(e,t,r,i){return e===0?t&r|~t&i:e===2?t&r|t&i|r&i:t^r^i}sl.prototype._update=function(e){for(var t=this._w,r=this._a|0,i=this._b|0,n=this._c|0,o=this._d|0,a=this._e|0,s=0;s<16;++s)t[s]=e.readInt32BE(s*4);for(;s<80;++s)t[s]=t[s-3]^t[s-8]^t[s-14]^t[s-16];for(var u=0;u<80;++u){var c=~~(u/20),l=Cj(r)+Mj(c,i,n,o)+a+t[u]+Bj[c]|0;a=o,o=n,n=Lj(i),i=r,r=l}this._a=r+this._a|0,this._b=i+this._b|0,this._c=n+this._c|0,this._d=o+this._d|0,this._e=a+this._e|0};sl.prototype._hash=function(){var e=kj.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};VA.exports=sl});var ZA=P((kie,YA)=>{"use strict";g();var Dj=vt(),WA=Ms(),qj=Qr().Buffer,Hj=[1518500249,1859775393,-1894007588,-899497514],Uj=new Array(80);function ul(){this.init(),this._w=Uj,WA.call(this,64,56)}Dj(ul,WA);ul.prototype.init=function(){return this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878,this._e=3285377520,this};function Fj(e){return e<<1|e>>>31}function jj(e){return e<<5|e>>>27}function zj(e){return e<<30|e>>>2}function Kj(e,t,r,i){return e===0?t&r|~t&i:e===2?t&r|t&i|r&i:t^r^i}ul.prototype._update=function(e){for(var t=this._w,r=this._a|0,i=this._b|0,n=this._c|0,o=this._d|0,a=this._e|0,s=0;s<16;++s)t[s]=e.readInt32BE(s*4);for(;s<80;++s)t[s]=Fj(t[s-3]^t[s-8]^t[s-14]^t[s-16]);for(var u=0;u<80;++u){var c=~~(u/20),l=jj(r)+Kj(c,i,n,o)+a+t[u]+Hj[c]|0;a=o,o=n,n=zj(i),i=r,r=l}this._a=r+this._a|0,this._b=i+this._b|0,this._c=n+this._c|0,this._d=o+this._d|0,this._e=a+this._e|0};ul.prototype._hash=function(){var e=qj.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};YA.exports=ul});var Ny=P((Nie,XA)=>{"use strict";g();var Vj=vt(),$A=Ms(),Gj=Qr().Buffer,Wj=[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],Yj=new Array(64);function cl(){this.init(),this._w=Yj,$A.call(this,64,56)}Vj(cl,$A);cl.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 Zj(e,t,r){return r^e&(t^r)}function $j(e,t,r){return e&t|r&(e|t)}function Xj(e){return(e>>>2|e<<30)^(e>>>13|e<<19)^(e>>>22|e<<10)}function Jj(e){return(e>>>6|e<<26)^(e>>>11|e<<21)^(e>>>25|e<<7)}function Qj(e){return(e>>>7|e<<25)^(e>>>18|e<<14)^e>>>3}function ez(e){return(e>>>17|e<<15)^(e>>>19|e<<13)^e>>>10}cl.prototype._update=function(e){for(var t=this._w,r=this._a|0,i=this._b|0,n=this._c|0,o=this._d|0,a=this._e|0,s=this._f|0,u=this._g|0,c=this._h|0,l=0;l<16;++l)t[l]=e.readInt32BE(l*4);for(;l<64;++l)t[l]=ez(t[l-2])+t[l-7]+Qj(t[l-15])+t[l-16]|0;for(var d=0;d<64;++d){var p=c+Jj(a)+Zj(a,s,u)+Wj[d]+t[d]|0,y=Xj(r)+$j(r,i,n)|0;c=u,u=s,s=a,a=o+p|0,o=n,n=i,i=r,r=p+y|0}this._a=r+this._a|0,this._b=i+this._b|0,this._c=n+this._c|0,this._d=o+this._d|0,this._e=a+this._e|0,this._f=s+this._f|0,this._g=u+this._g|0,this._h=c+this._h|0};cl.prototype._hash=function(){var e=Gj.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};XA.exports=cl});var QA=P((Lie,JA)=>{"use strict";g();var tz=vt(),rz=Ny(),iz=Ms(),nz=Qr().Buffer,oz=new Array(64);function xp(){this.init(),this._w=oz,iz.call(this,64,56)}tz(xp,rz);xp.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};xp.prototype._hash=function(){var e=nz.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};JA.exports=xp});var Cy=P((Die,aT)=>{"use strict";g();var az=vt(),oT=Ms(),sz=Qr().Buffer,eT=[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],uz=new Array(160);function fl(){this.init(),this._w=uz,oT.call(this,128,112)}az(fl,oT);fl.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 tT(e,t,r){return r^e&(t^r)}function rT(e,t,r){return e&t|r&(e|t)}function iT(e,t){return(e>>>28|t<<4)^(t>>>2|e<<30)^(t>>>7|e<<25)}function nT(e,t){return(e>>>14|t<<18)^(e>>>18|t<<14)^(t>>>9|e<<23)}function cz(e,t){return(e>>>1|t<<31)^(e>>>8|t<<24)^e>>>7}function fz(e,t){return(e>>>1|t<<31)^(e>>>8|t<<24)^(e>>>7|t<<25)}function lz(e,t){return(e>>>19|t<<13)^(t>>>29|e<<3)^e>>>6}function hz(e,t){return(e>>>19|t<<13)^(t>>>29|e<<3)^(e>>>6|t<<26)}function Vr(e,t){return e>>>0<t>>>0?1:0}fl.prototype._update=function(e){for(var t=this._w,r=this._ah|0,i=this._bh|0,n=this._ch|0,o=this._dh|0,a=this._eh|0,s=this._fh|0,u=this._gh|0,c=this._hh|0,l=this._al|0,d=this._bl|0,p=this._cl|0,y=this._dl|0,_=this._el|0,T=this._fl|0,R=this._gl|0,B=this._hl|0,H=0;H<32;H+=2)t[H]=e.readInt32BE(H*4),t[H+1]=e.readInt32BE(H*4+4);for(;H<160;H+=2){var j=t[H-30],I=t[H-30+1],k=cz(j,I),D=fz(I,j);j=t[H-4],I=t[H-4+1];var F=lz(j,I),K=hz(I,j),G=t[H-14],S=t[H-14+1],h=t[H-32],v=t[H-32+1],w=D+S|0,E=k+G+Vr(w,D)|0;w=w+K|0,E=E+F+Vr(w,K)|0,w=w+v|0,E=E+h+Vr(w,v)|0,t[H]=E,t[H+1]=w}for(var A=0;A<160;A+=2){E=t[A],w=t[A+1];var L=rT(r,i,n),N=rT(l,d,p),x=iT(r,l),m=iT(l,r),O=nT(a,_),z=nT(_,a),W=eT[A],X=eT[A+1],ie=tT(a,s,u),le=tT(_,T,R),se=B+z|0,ye=c+O+Vr(se,B)|0;se=se+le|0,ye=ye+ie+Vr(se,le)|0,se=se+X|0,ye=ye+W+Vr(se,X)|0,se=se+w|0,ye=ye+E+Vr(se,w)|0;var be=m+N|0,C=x+L+Vr(be,m)|0;c=u,B=R,u=s,R=T,s=a,T=_,_=y+se|0,a=o+ye+Vr(_,y)|0,o=n,y=p,n=i,p=d,i=r,d=l,l=se+be|0,r=ye+C+Vr(l,se)|0}this._al=this._al+l|0,this._bl=this._bl+d|0,this._cl=this._cl+p|0,this._dl=this._dl+y|0,this._el=this._el+_|0,this._fl=this._fl+T|0,this._gl=this._gl+R|0,this._hl=this._hl+B|0,this._ah=this._ah+r+Vr(this._al,l)|0,this._bh=this._bh+i+Vr(this._bl,d)|0,this._ch=this._ch+n+Vr(this._cl,p)|0,this._dh=this._dh+o+Vr(this._dl,y)|0,this._eh=this._eh+a+Vr(this._el,_)|0,this._fh=this._fh+s+Vr(this._fl,T)|0,this._gh=this._gh+u+Vr(this._gl,R)|0,this._hh=this._hh+c+Vr(this._hl,B)|0};fl.prototype._hash=function(){var e=sz.allocUnsafe(64);function t(r,i,n){e.writeInt32BE(r,n),e.writeInt32BE(i,n+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};aT.exports=fl});var uT=P((Hie,sT)=>{"use strict";g();var dz=vt(),pz=Cy(),gz=Ms(),mz=Qr().Buffer,vz=new Array(160);function Op(){this.init(),this._w=vz,gz.call(this,128,112)}dz(Op,pz);Op.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};Op.prototype._hash=function(){var e=mz.allocUnsafe(48);function t(r,i,n){e.writeInt32BE(r,n),e.writeInt32BE(i,n+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};sT.exports=Op});var Ly=P((Fie,jo)=>{"use strict";g();jo.exports=function(t){var r=t.toLowerCase(),i=jo.exports[r];if(!i)throw new Error(r+" is not supported (we accept pull requests)");return new i};jo.exports.sha=GA();jo.exports.sha1=ZA();jo.exports.sha224=QA();jo.exports.sha256=Ny();jo.exports.sha384=uT();jo.exports.sha512=Cy()});var Ip=P((zie,fT)=>{"use strict";g();var yz=Qr().Buffer,cT=sp().Transform,bz=$u().StringDecoder,_z=vt(),wz=fp();function _n(e){cT.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}_z(_n,cT);_n.prototype.update=function(e,t,r){var i=wz(e,t),n=this._update(i);return this.hashMode?this:(r&&(n=this._toString(n,r)),n)};_n.prototype.setAutoPadding=function(){};_n.prototype.getAuthTag=function(){throw new Error("trying to get auth tag in unsupported state")};_n.prototype.setAuthTag=function(){throw new Error("trying to set auth tag in unsupported state")};_n.prototype.setAAD=function(){throw new Error("trying to set aad in unsupported state")};_n.prototype._transform=function(e,t,r){var i;try{this.hashMode?this._update(e):this.push(this._update(e))}catch(n){i=n}finally{r(i)}};_n.prototype._flush=function(e){var t;try{this.push(this.__final())}catch(r){t=r}e(t)};_n.prototype._finalOrDigest=function(e){var t=this.__final()||yz.alloc(0);return e&&(t=this._toString(t,e,!0)),t};_n.prototype._toString=function(e,t,r){if(this._decoder||(this._decoder=new bz(t),this._encoding=t),this._encoding!==t)throw new Error("can\u2019t switch encodings");var i=this._decoder.write(e);return r&&(i+=this._decoder.end()),i};fT.exports=_n});var dT=P((Vie,hT)=>{"use strict";g();var Sz=vt(),Ez=dy(),xz=By(),Oz=Ly(),lT=Ip();function Ap(e){lT.call(this,"digest"),this._hash=e}Sz(Ap,lT);Ap.prototype._update=function(e){this._hash.update(e)};Ap.prototype._final=function(){return this._hash.digest()};hT.exports=function(t){return t=t.toLowerCase(),t==="md5"?new Ez:t==="rmd160"||t==="ripemd160"?new xz:new Ap(Oz(t))}});var mT=P((Wie,gT)=>{"use strict";g();var Iz=vt(),Ds=Qr().Buffer,pT=Ip(),Az=Ds.alloc(128),nc=64;function Tp(e,t){pT.call(this,"digest"),typeof t=="string"&&(t=Ds.from(t)),this._alg=e,this._key=t,t.length>nc?t=e(t):t.length<nc&&(t=Ds.concat([t,Az],nc));for(var r=this._ipad=Ds.allocUnsafe(nc),i=this._opad=Ds.allocUnsafe(nc),n=0;n<nc;n++)r[n]=t[n]^54,i[n]=t[n]^92;this._hash=[r]}Iz(Tp,pT);Tp.prototype._update=function(e){this._hash.push(e)};Tp.prototype._final=function(){var e=this._alg(Ds.concat(this._hash));return this._alg(Ds.concat([this._opad,e]))};gT.exports=Tp});var yT=P((Zie,vT)=>{g();var Tz=dy();vT.exports=function(e){return new Tz().update(e).digest()}});var wT=P((Xie,_T)=>{"use strict";g();var Pz=vt(),Rz=mT(),bT=Ip(),ll=Qr().Buffer,kz=yT(),My=By(),Dy=Ly(),Bz=ll.alloc(128);function hl(e,t){bT.call(this,"digest"),typeof t=="string"&&(t=ll.from(t));var r=e==="sha512"||e==="sha384"?128:64;if(this._alg=e,this._key=t,t.length>r){var i=e==="rmd160"?new My:Dy(e);t=i.update(t).digest()}else t.length<r&&(t=ll.concat([t,Bz],r));for(var n=this._ipad=ll.allocUnsafe(r),o=this._opad=ll.allocUnsafe(r),a=0;a<r;a++)n[a]=t[a]^54,o[a]=t[a]^92;this._hash=e==="rmd160"?new My:Dy(e),this._hash.update(n)}Pz(hl,bT);hl.prototype._update=function(e){this._hash.update(e)};hl.prototype._final=function(){var e=this._hash.digest(),t=this._alg==="rmd160"?new My:Dy(this._alg);return t.update(this._opad).update(e).digest()};_T.exports=function(t,r){return t=t.toLowerCase(),t==="rmd160"||t==="ripemd160"?new hl("rmd160",r):t==="md5"?new Rz(kz,r):new hl(t,r)}});var ST=P((Qie,Hy)=>{"use strict";g();var qy=65536,Nz=4294967295;function Cz(){throw new Error(`Secure random number generation is not supported by this browser.
11
- Use Chrome, Firefox or Internet Explorer 11`)}var Lz=Qr().Buffer,Pp=globalThis.crypto||globalThis.msCrypto;Pp&&Pp.getRandomValues?Hy.exports=Mz:Hy.exports=Cz;function Mz(e,t){if(e>Nz)throw new RangeError("requested too many random bytes");var r=Lz.allocUnsafe(e);if(e>0)if(e>qy)for(var i=0;i<e;i+=qy)Pp.getRandomValues(r.slice(i,i+qy));else Pp.getRandomValues(r);return typeof t=="function"?b.default.nextTick(function(){t(null,r)}):r}});var Kt=P(Rp=>{"use strict";g();Rp.createHash=dT();Rp.createHmac=wT();Rp.randomBytes=ST()});var Ui=P((ine,xT)=>{"use strict";g();var ET=65536;function qs(){}qs.getRandomBuffer=function(e){var t=typeof globalThis<"u"?globalThis.crypto:void 0;if(t&&typeof t.getRandomValues=="function")return qs._fromGetRandomValues(t,e);try{var r=Kt();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)")};qs._fromGetRandomValues=function(e,t){for(var r=f.Buffer.alloc(t),i=0;i<t;i+=ET){var n=new Uint8Array(Math.min(ET,t-i));e.getRandomValues(n),f.Buffer.from(n).copy(r,i)}return r};qs.getRandomBufferNode=function(e){var t=Kt();return t.randomBytes(e)};qs.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 qs._fromGetRandomValues(r,e)};xT.exports=qs});var Je=P((one,OT)=>{"use strict";g();var Dz=Ui(),xt={};xt.isArray=e=>Array.isArray(e);xt.isNumber=e=>typeof e=="number";xt.isObject=e=>e&&typeof e=="object";xt.isString=e=>typeof e=="string";xt.isUndefined=e=>typeof e>"u";xt.isFunction=e=>typeof e=="function";xt.isNull=e=>e===null;xt.isDate=e=>e instanceof Date;xt.extend=(e,t)=>Object.assign(e,t);xt.noop=()=>{};xt.every=(e,t)=>e.every(t||(r=>r));xt.map=(e,t)=>Array.from(e).map(t||(r=>r));xt.includes=(e,t)=>e.includes(t);xt.each=(e,t)=>e.forEach(t);xt.clone=e=>Object.assign({},e);xt.pick=(e,t)=>{let r={};return t.forEach(i=>{typeof e[i]<"u"&&(r[i]=e[i])}),r};xt.values=e=>Object.values(e);xt.filter=(e,t)=>e.filter(t);xt.reduce=(e,t,r)=>e.reduce(t,r);xt.without=(e,t)=>e.filter(r=>r!==t);xt.shuffle=e=>{let t=e.slice(0);for(let r=t.length-1;r>0;r--){let n=Dz.getRandomBuffer(4).readUInt32BE(0)/4294967296,o=Math.floor(n*(r+1));[t[r],t[o]]=[t[o],t[r]]}return t};xt.difference=(e,t)=>e.filter(r=>!t.includes(r));xt.findIndex=(e,t)=>e.findIndex(t);xt.some=(e,t)=>e.some(t);xt.range=e=>[...Array(e).keys()];OT.exports=xt});var ac=P((sne,TT)=>{"use strict";g();var Uy=Je(),IT=jt(),oc="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz".split(""),AT={};for(dl=0;dl<oc.length;dl++)AT[oc[dl]]=dl;var dl;function qz(e){if(e.length===0)return"";var t=[0],r,i,n;for(r=0;r<e.length;r++){for(i=0,n=e[r];i<t.length;i++)n+=t[i]<<8,t[i]=n%58,n=n/58|0;for(;n>0;)t.push(n%58),n=n/58|0}var o="";for(r=0;e[r]===0&&r<e.length-1;r++)o+=oc[0];for(r=t.length-1;r>=0;r--)o+=oc[t[r]];return o}function Hz(e){if(e.length===0)return f.Buffer.alloc(0);var t=[0],r,i,n;for(r=0;r<e.length;r++){var o=AT[e[r]];if(o===void 0)throw new Error("Non-base58 character");for(i=0,n=o;i<t.length;i++)n+=t[i]*58,t[i]=n&255,n>>=8;for(;n>0;)t.push(n&255),n>>=8}for(r=0;e[r]===oc[0]&&r<e.length-1;r++)t.push(0);return f.Buffer.from(t.reverse())}var Gr=function e(t){if(!(this instanceof e))return new e(t);if(f.Buffer.isBuffer(t)){var r=t;this.fromBuffer(r)}else if(typeof t=="string"){var i=t;this.fromString(i)}};Gr.validCharacters=function(t){return IT.Buffer.isBuffer(t)&&(t=t.toString()),Uy.every(Uy.map(t,function(r){return Uy.includes(oc,r)}))};Gr.prototype.set=function(e){return this.buf=e.buf||this.buf||void 0,this};Gr.encode=function(e){if(!IT.Buffer.isBuffer(e))throw new Error("Input should be a buffer");return qz(e)};Gr.decode=function(e){if(typeof e!="string")throw new Error("Input should be a string");return Hz(e)};Gr.prototype.fromBuffer=function(e){return this.buf=e,this};Gr.fromBuffer=function(e){return new Gr().fromBuffer(e)};Gr.fromHex=function(e){return Gr.fromBuffer(f.Buffer.from(e,"hex"))};Gr.prototype.fromString=function(e){var t=Gr.decode(e);return this.buf=t,this};Gr.fromString=function(e){return new Gr().fromString(e)};Gr.prototype.toBuffer=function(){return this.buf};Gr.prototype.toHex=function(){return this.toBuffer().toString("hex")};Gr.prototype.toString=function(){return Gr.encode(this.buf)};TT.exports=Gr});var kp=P((PT,Fy)=>{g();(function(e,t){"use strict";function r(S,h){if(!S)throw new Error(h||"Assertion failed")}function i(S,h){S.super_=h;var v=function(){};v.prototype=h.prototype,S.prototype=new v,S.prototype.constructor=S}function n(S,h,v){if(n.isBN(S))return S;this.negative=0,this.words=null,this.length=0,this.red=null,S!==null&&((h==="le"||h==="be")&&(v=h,h=10),this._init(S||0,h||10,v||"be"))}typeof e=="object"?e.exports=n:t.BN=n,n.BN=n,n.wordSize=26;var o;try{typeof window<"u"&&typeof window.Buffer<"u"?o=window.Buffer:o=jt().Buffer}catch{}n.isBN=function(h){return h instanceof n?!0:h!==null&&typeof h=="object"&&h.constructor.wordSize===n.wordSize&&Array.isArray(h.words)},n.max=function(h,v){return h.cmp(v)>0?h:v},n.min=function(h,v){return h.cmp(v)<0?h:v},n.prototype._init=function(h,v,w){if(typeof h=="number")return this._initNumber(h,v,w);if(typeof h=="object")return this._initArray(h,v,w);v==="hex"&&(v=16),r(v===(v|0)&&v>=2&&v<=36),h=h.toString().replace(/\s+/g,"");var E=0;h[0]==="-"&&(E++,this.negative=1),E<h.length&&(v===16?this._parseHex(h,E,w):(this._parseBase(h,v,E),w==="le"&&this._initArray(this.toArray(),v,w)))},n.prototype._initNumber=function(h,v,w){h<0&&(this.negative=1,h=-h),h<67108864?(this.words=[h&67108863],this.length=1):h<4503599627370496?(this.words=[h&67108863,h/67108864&67108863],this.length=2):(r(h<9007199254740992),this.words=[h&67108863,h/67108864&67108863,1],this.length=3),w==="le"&&this._initArray(this.toArray(),v,w)},n.prototype._initArray=function(h,v,w){if(r(typeof h.length=="number"),h.length<=0)return this.words=[0],this.length=1,this;this.length=Math.ceil(h.length/3),this.words=new Array(this.length);for(var E=0;E<this.length;E++)this.words[E]=0;var A,L,N=0;if(w==="be")for(E=h.length-1,A=0;E>=0;E-=3)L=h[E]|h[E-1]<<8|h[E-2]<<16,this.words[A]|=L<<N&67108863,this.words[A+1]=L>>>26-N&67108863,N+=24,N>=26&&(N-=26,A++);else if(w==="le")for(E=0,A=0;E<h.length;E+=3)L=h[E]|h[E+1]<<8|h[E+2]<<16,this.words[A]|=L<<N&67108863,this.words[A+1]=L>>>26-N&67108863,N+=24,N>=26&&(N-=26,A++);return this.strip()};function a(S,h){var v=S.charCodeAt(h);return v>=65&&v<=70?v-55:v>=97&&v<=102?v-87:v-48&15}function s(S,h,v){var w=a(S,v);return v-1>=h&&(w|=a(S,v-1)<<4),w}n.prototype._parseHex=function(h,v,w){this.length=Math.ceil((h.length-v)/6),this.words=new Array(this.length);for(var E=0;E<this.length;E++)this.words[E]=0;var A=0,L=0,N;if(w==="be")for(E=h.length-1;E>=v;E-=2)N=s(h,v,E)<<A,this.words[L]|=N&67108863,A>=18?(A-=18,L+=1,this.words[L]|=N>>>26):A+=8;else{var x=h.length-v;for(E=x%2===0?v+1:v;E<h.length;E+=2)N=s(h,v,E)<<A,this.words[L]|=N&67108863,A>=18?(A-=18,L+=1,this.words[L]|=N>>>26):A+=8}this.strip()};function u(S,h,v,w){for(var E=0,A=Math.min(S.length,v),L=h;L<A;L++){var N=S.charCodeAt(L)-48;E*=w,N>=49?E+=N-49+10:N>=17?E+=N-17+10:E+=N}return E}n.prototype._parseBase=function(h,v,w){this.words=[0],this.length=1;for(var E=0,A=1;A<=67108863;A*=v)E++;E--,A=A/v|0;for(var L=h.length-w,N=L%E,x=Math.min(L,L-N)+w,m=0,O=w;O<x;O+=E)m=u(h,O,O+E,v),this.imuln(A),this.words[0]+m<67108864?this.words[0]+=m:this._iaddn(m);if(N!==0){var z=1;for(m=u(h,O,h.length,v),O=0;O<N;O++)z*=v;this.imuln(z),this.words[0]+m<67108864?this.words[0]+=m:this._iaddn(m)}this.strip()},n.prototype.copy=function(h){h.words=new Array(this.length);for(var v=0;v<this.length;v++)h.words[v]=this.words[v];h.length=this.length,h.negative=this.negative,h.red=this.red},n.prototype.clone=function(){var h=new n(null);return this.copy(h),h},n.prototype._expand=function(h){for(;this.length<h;)this.words[this.length++]=0;return this},n.prototype.strip=function(){for(;this.length>1&&this.words[this.length-1]===0;)this.length--;return this._normSign()},n.prototype._normSign=function(){return this.length===1&&this.words[0]===0&&(this.negative=0),this},n.prototype.inspect=function(){return(this.red?"<BN-R: ":"<BN: ")+this.toString(16)+">"};var c=["","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"],l=[0,0,25,16,12,11,10,9,8,8,7,7,7,7,6,6,6,6,6,6,6,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5],d=[0,0,33554432,43046721,16777216,48828125,60466176,40353607,16777216,43046721,1e7,19487171,35831808,62748517,7529536,11390625,16777216,24137569,34012224,47045881,64e6,4084101,5153632,6436343,7962624,9765625,11881376,14348907,17210368,20511149,243e5,28629151,33554432,39135393,45435424,52521875,60466176];n.prototype.toString=function(h,v){h=h||10,v=v|0||1;var w;if(h===16||h==="hex"){w="";for(var E=0,A=0,L=0;L<this.length;L++){var N=this.words[L],x=((N<<E|A)&16777215).toString(16);A=N>>>24-E&16777215,E+=2,E>=26&&(E-=26,L--),A!==0||L!==this.length-1?w=c[6-x.length]+x+w:w=x+w}for(A!==0&&(w=A.toString(16)+w);w.length%v!==0;)w="0"+w;return this.negative!==0&&(w="-"+w),w}if(h===(h|0)&&h>=2&&h<=36){var m=l[h],O=d[h];w="";var z=this.clone();for(z.negative=0;!z.isZero();){var W=z.modn(O).toString(h);z=z.idivn(O),z.isZero()?w=W+w:w=c[m-W.length]+W+w}for(this.isZero()&&(w="0"+w);w.length%v!==0;)w="0"+w;return this.negative!==0&&(w="-"+w),w}r(!1,"Base should be between 2 and 36")},n.prototype.toNumber=function(){var h=this.words[0];return this.length===2?h+=this.words[1]*67108864:this.length===3&&this.words[2]===1?h+=4503599627370496+this.words[1]*67108864:this.length>2&&r(!1,"Number can only safely store up to 53 bits"),this.negative!==0?-h:h},n.prototype.toJSON=function(){return this.toString(16)},n.prototype.toBuffer=function(h,v){return r(typeof o<"u"),this.toArrayLike(o,h,v)},n.prototype.toArray=function(h,v){return this.toArrayLike(Array,h,v)},n.prototype.toArrayLike=function(h,v,w){var E=this.byteLength(),A=w||Math.max(1,E);r(E<=A,"byte array longer than desired length"),r(A>0,"Requested array length <= 0"),this.strip();var L=v==="le",N=new h(A),x,m,O=this.clone();if(L){for(m=0;!O.isZero();m++)x=O.andln(255),O.iushrn(8),N[m]=x;for(;m<A;m++)N[m]=0}else{for(m=0;m<A-E;m++)N[m]=0;for(m=0;!O.isZero();m++)x=O.andln(255),O.iushrn(8),N[A-m-1]=x}return N},Math.clz32?n.prototype._countBits=function(h){return 32-Math.clz32(h)}:n.prototype._countBits=function(h){var v=h,w=0;return v>=4096&&(w+=13,v>>>=13),v>=64&&(w+=7,v>>>=7),v>=8&&(w+=4,v>>>=4),v>=2&&(w+=2,v>>>=2),w+v},n.prototype._zeroBits=function(h){if(h===0)return 26;var v=h,w=0;return(v&8191)===0&&(w+=13,v>>>=13),(v&127)===0&&(w+=7,v>>>=7),(v&15)===0&&(w+=4,v>>>=4),(v&3)===0&&(w+=2,v>>>=2),(v&1)===0&&w++,w},n.prototype.bitLength=function(){var h=this.words[this.length-1],v=this._countBits(h);return(this.length-1)*26+v};function p(S){for(var h=new Array(S.bitLength()),v=0;v<h.length;v++){var w=v/26|0,E=v%26;h[v]=(S.words[w]&1<<E)>>>E}return h}n.prototype.zeroBits=function(){if(this.isZero())return 0;for(var h=0,v=0;v<this.length;v++){var w=this._zeroBits(this.words[v]);if(h+=w,w!==26)break}return h},n.prototype.byteLength=function(){return Math.ceil(this.bitLength()/8)},n.prototype.toTwos=function(h){return this.negative!==0?this.abs().inotn(h).iaddn(1):this.clone()},n.prototype.fromTwos=function(h){return this.testn(h-1)?this.notn(h).iaddn(1).ineg():this.clone()},n.prototype.isNeg=function(){return this.negative!==0},n.prototype.neg=function(){return this.clone().ineg()},n.prototype.ineg=function(){return this.isZero()||(this.negative^=1),this},n.prototype.iuor=function(h){for(;this.length<h.length;)this.words[this.length++]=0;for(var v=0;v<h.length;v++)this.words[v]=this.words[v]|h.words[v];return this.strip()},n.prototype.ior=function(h){return r((this.negative|h.negative)===0),this.iuor(h)},n.prototype.or=function(h){return this.length>h.length?this.clone().ior(h):h.clone().ior(this)},n.prototype.uor=function(h){return this.length>h.length?this.clone().iuor(h):h.clone().iuor(this)},n.prototype.iuand=function(h){var v;this.length>h.length?v=h:v=this;for(var w=0;w<v.length;w++)this.words[w]=this.words[w]&h.words[w];return this.length=v.length,this.strip()},n.prototype.iand=function(h){return r((this.negative|h.negative)===0),this.iuand(h)},n.prototype.and=function(h){return this.length>h.length?this.clone().iand(h):h.clone().iand(this)},n.prototype.uand=function(h){return this.length>h.length?this.clone().iuand(h):h.clone().iuand(this)},n.prototype.iuxor=function(h){var v,w;this.length>h.length?(v=this,w=h):(v=h,w=this);for(var E=0;E<w.length;E++)this.words[E]=v.words[E]^w.words[E];if(this!==v)for(;E<v.length;E++)this.words[E]=v.words[E];return this.length=v.length,this.strip()},n.prototype.ixor=function(h){return r((this.negative|h.negative)===0),this.iuxor(h)},n.prototype.xor=function(h){return this.length>h.length?this.clone().ixor(h):h.clone().ixor(this)},n.prototype.uxor=function(h){return this.length>h.length?this.clone().iuxor(h):h.clone().iuxor(this)},n.prototype.inotn=function(h){r(typeof h=="number"&&h>=0);var v=Math.ceil(h/26)|0,w=h%26;this._expand(v),w>0&&v--;for(var E=0;E<v;E++)this.words[E]=~this.words[E]&67108863;for(w>0&&(this.words[E]=~this.words[E]&67108863>>26-w,E++);E<this.length;E++)this.words[E]=0;return this.strip()},n.prototype.notn=function(h){return this.clone().inotn(h)},n.prototype.setn=function(h,v){r(typeof h=="number"&&h>=0);var w=h/26|0,E=h%26;return this._expand(w+1),v?this.words[w]=this.words[w]|1<<E:this.words[w]=this.words[w]&~(1<<E),this.strip()},n.prototype.iadd=function(h){var v;if(this.negative!==0&&h.negative===0)return this.negative=0,v=this.isub(h),this.negative^=1,this._normSign();if(this.negative===0&&h.negative!==0)return h.negative=0,v=this.isub(h),h.negative=1,v._normSign();var w,E;this.length>h.length?(w=this,E=h):(w=h,E=this);for(var A=0,L=0;L<E.length;L++)v=(w.words[L]|0)+(E.words[L]|0)+A,this.words[L]=v&67108863,A=v>>>26;for(;A!==0&&L<w.length;L++)v=(w.words[L]|0)+A,this.words[L]=v&67108863,A=v>>>26;if(this.length=w.length,A!==0)this.words[this.length]=A,this.length++;else if(w!==this)for(;L<w.length;L++)this.words[L]=w.words[L];return this},n.prototype.add=function(h){var v;return h.negative!==0&&this.negative===0?(h.negative=0,v=this.sub(h),h.negative^=1,v):h.negative===0&&this.negative!==0?(this.negative=0,v=h.sub(this),this.negative=1,v):this.length>h.length?this.clone().iadd(h):h.clone().iadd(this)},n.prototype.isub=function(h){if(h.negative!==0){h.negative=0;var v=this.iadd(h);return h.negative=1,v._normSign()}else if(this.negative!==0)return this.negative=0,this.iadd(h),this.negative=1,this._normSign();var w=this.cmp(h);if(w===0)return this.negative=0,this.length=1,this.words[0]=0,this;var E,A;w>0?(E=this,A=h):(E=h,A=this);for(var L=0,N=0;N<A.length;N++)v=(E.words[N]|0)-(A.words[N]|0)+L,L=v>>26,this.words[N]=v&67108863;for(;L!==0&&N<E.length;N++)v=(E.words[N]|0)+L,L=v>>26,this.words[N]=v&67108863;if(L===0&&N<E.length&&E!==this)for(;N<E.length;N++)this.words[N]=E.words[N];return this.length=Math.max(this.length,N),E!==this&&(this.negative=1),this.strip()},n.prototype.sub=function(h){return this.clone().isub(h)};function y(S,h,v){v.negative=h.negative^S.negative;var w=S.length+h.length|0;v.length=w,w=w-1|0;var E=S.words[0]|0,A=h.words[0]|0,L=E*A,N=L&67108863,x=L/67108864|0;v.words[0]=N;for(var m=1;m<w;m++){for(var O=x>>>26,z=x&67108863,W=Math.min(m,h.length-1),X=Math.max(0,m-S.length+1);X<=W;X++){var ie=m-X|0;E=S.words[ie]|0,A=h.words[X]|0,L=E*A+z,O+=L/67108864|0,z=L&67108863}v.words[m]=z|0,x=O|0}return x!==0?v.words[m]=x|0:v.length--,v.strip()}var _=function(h,v,w){var E=h.words,A=v.words,L=w.words,N=0,x,m,O,z=E[0]|0,W=z&8191,X=z>>>13,ie=E[1]|0,le=ie&8191,se=ie>>>13,ye=E[2]|0,be=ye&8191,C=ye>>>13,V=E[3]|0,Y=V&8191,Q=V>>>13,he=E[4]|0,ue=he&8191,ce=he>>>13,me=E[5]|0,_e=me&8191,ve=me>>>13,Be=E[6]|0,ge=Be&8191,nt=Be>>>13,xe=E[7]|0,Re=xe&8191,je=xe>>>13,xi=E[8]|0,kt=xi&8191,Et=xi>>>13,ad=E[9]|0,Ft=ad&8191,tr=ad>>>13,oE=A[0]|0,rr=oE&8191,ir=oE>>>13,aE=A[1]|0,nr=aE&8191,or=aE>>>13,sE=A[2]|0,ar=sE&8191,sr=sE>>>13,uE=A[3]|0,ur=uE&8191,cr=uE>>>13,cE=A[4]|0,fr=cE&8191,lr=cE>>>13,fE=A[5]|0,hr=fE&8191,dr=fE>>>13,lE=A[6]|0,pr=lE&8191,gr=lE>>>13,hE=A[7]|0,mr=hE&8191,vr=hE>>>13,dE=A[8]|0,yr=dE&8191,br=dE>>>13,pE=A[9]|0,_r=pE&8191,wr=pE>>>13;w.negative=h.negative^v.negative,w.length=19,x=Math.imul(W,rr),m=Math.imul(W,ir),m=m+Math.imul(X,rr)|0,O=Math.imul(X,ir);var Iv=(N+x|0)+((m&8191)<<13)|0;N=(O+(m>>>13)|0)+(Iv>>>26)|0,Iv&=67108863,x=Math.imul(le,rr),m=Math.imul(le,ir),m=m+Math.imul(se,rr)|0,O=Math.imul(se,ir),x=x+Math.imul(W,nr)|0,m=m+Math.imul(W,or)|0,m=m+Math.imul(X,nr)|0,O=O+Math.imul(X,or)|0;var Av=(N+x|0)+((m&8191)<<13)|0;N=(O+(m>>>13)|0)+(Av>>>26)|0,Av&=67108863,x=Math.imul(be,rr),m=Math.imul(be,ir),m=m+Math.imul(C,rr)|0,O=Math.imul(C,ir),x=x+Math.imul(le,nr)|0,m=m+Math.imul(le,or)|0,m=m+Math.imul(se,nr)|0,O=O+Math.imul(se,or)|0,x=x+Math.imul(W,ar)|0,m=m+Math.imul(W,sr)|0,m=m+Math.imul(X,ar)|0,O=O+Math.imul(X,sr)|0;var Tv=(N+x|0)+((m&8191)<<13)|0;N=(O+(m>>>13)|0)+(Tv>>>26)|0,Tv&=67108863,x=Math.imul(Y,rr),m=Math.imul(Y,ir),m=m+Math.imul(Q,rr)|0,O=Math.imul(Q,ir),x=x+Math.imul(be,nr)|0,m=m+Math.imul(be,or)|0,m=m+Math.imul(C,nr)|0,O=O+Math.imul(C,or)|0,x=x+Math.imul(le,ar)|0,m=m+Math.imul(le,sr)|0,m=m+Math.imul(se,ar)|0,O=O+Math.imul(se,sr)|0,x=x+Math.imul(W,ur)|0,m=m+Math.imul(W,cr)|0,m=m+Math.imul(X,ur)|0,O=O+Math.imul(X,cr)|0;var Pv=(N+x|0)+((m&8191)<<13)|0;N=(O+(m>>>13)|0)+(Pv>>>26)|0,Pv&=67108863,x=Math.imul(ue,rr),m=Math.imul(ue,ir),m=m+Math.imul(ce,rr)|0,O=Math.imul(ce,ir),x=x+Math.imul(Y,nr)|0,m=m+Math.imul(Y,or)|0,m=m+Math.imul(Q,nr)|0,O=O+Math.imul(Q,or)|0,x=x+Math.imul(be,ar)|0,m=m+Math.imul(be,sr)|0,m=m+Math.imul(C,ar)|0,O=O+Math.imul(C,sr)|0,x=x+Math.imul(le,ur)|0,m=m+Math.imul(le,cr)|0,m=m+Math.imul(se,ur)|0,O=O+Math.imul(se,cr)|0,x=x+Math.imul(W,fr)|0,m=m+Math.imul(W,lr)|0,m=m+Math.imul(X,fr)|0,O=O+Math.imul(X,lr)|0;var Rv=(N+x|0)+((m&8191)<<13)|0;N=(O+(m>>>13)|0)+(Rv>>>26)|0,Rv&=67108863,x=Math.imul(_e,rr),m=Math.imul(_e,ir),m=m+Math.imul(ve,rr)|0,O=Math.imul(ve,ir),x=x+Math.imul(ue,nr)|0,m=m+Math.imul(ue,or)|0,m=m+Math.imul(ce,nr)|0,O=O+Math.imul(ce,or)|0,x=x+Math.imul(Y,ar)|0,m=m+Math.imul(Y,sr)|0,m=m+Math.imul(Q,ar)|0,O=O+Math.imul(Q,sr)|0,x=x+Math.imul(be,ur)|0,m=m+Math.imul(be,cr)|0,m=m+Math.imul(C,ur)|0,O=O+Math.imul(C,cr)|0,x=x+Math.imul(le,fr)|0,m=m+Math.imul(le,lr)|0,m=m+Math.imul(se,fr)|0,O=O+Math.imul(se,lr)|0,x=x+Math.imul(W,hr)|0,m=m+Math.imul(W,dr)|0,m=m+Math.imul(X,hr)|0,O=O+Math.imul(X,dr)|0;var kv=(N+x|0)+((m&8191)<<13)|0;N=(O+(m>>>13)|0)+(kv>>>26)|0,kv&=67108863,x=Math.imul(ge,rr),m=Math.imul(ge,ir),m=m+Math.imul(nt,rr)|0,O=Math.imul(nt,ir),x=x+Math.imul(_e,nr)|0,m=m+Math.imul(_e,or)|0,m=m+Math.imul(ve,nr)|0,O=O+Math.imul(ve,or)|0,x=x+Math.imul(ue,ar)|0,m=m+Math.imul(ue,sr)|0,m=m+Math.imul(ce,ar)|0,O=O+Math.imul(ce,sr)|0,x=x+Math.imul(Y,ur)|0,m=m+Math.imul(Y,cr)|0,m=m+Math.imul(Q,ur)|0,O=O+Math.imul(Q,cr)|0,x=x+Math.imul(be,fr)|0,m=m+Math.imul(be,lr)|0,m=m+Math.imul(C,fr)|0,O=O+Math.imul(C,lr)|0,x=x+Math.imul(le,hr)|0,m=m+Math.imul(le,dr)|0,m=m+Math.imul(se,hr)|0,O=O+Math.imul(se,dr)|0,x=x+Math.imul(W,pr)|0,m=m+Math.imul(W,gr)|0,m=m+Math.imul(X,pr)|0,O=O+Math.imul(X,gr)|0;var Bv=(N+x|0)+((m&8191)<<13)|0;N=(O+(m>>>13)|0)+(Bv>>>26)|0,Bv&=67108863,x=Math.imul(Re,rr),m=Math.imul(Re,ir),m=m+Math.imul(je,rr)|0,O=Math.imul(je,ir),x=x+Math.imul(ge,nr)|0,m=m+Math.imul(ge,or)|0,m=m+Math.imul(nt,nr)|0,O=O+Math.imul(nt,or)|0,x=x+Math.imul(_e,ar)|0,m=m+Math.imul(_e,sr)|0,m=m+Math.imul(ve,ar)|0,O=O+Math.imul(ve,sr)|0,x=x+Math.imul(ue,ur)|0,m=m+Math.imul(ue,cr)|0,m=m+Math.imul(ce,ur)|0,O=O+Math.imul(ce,cr)|0,x=x+Math.imul(Y,fr)|0,m=m+Math.imul(Y,lr)|0,m=m+Math.imul(Q,fr)|0,O=O+Math.imul(Q,lr)|0,x=x+Math.imul(be,hr)|0,m=m+Math.imul(be,dr)|0,m=m+Math.imul(C,hr)|0,O=O+Math.imul(C,dr)|0,x=x+Math.imul(le,pr)|0,m=m+Math.imul(le,gr)|0,m=m+Math.imul(se,pr)|0,O=O+Math.imul(se,gr)|0,x=x+Math.imul(W,mr)|0,m=m+Math.imul(W,vr)|0,m=m+Math.imul(X,mr)|0,O=O+Math.imul(X,vr)|0;var Nv=(N+x|0)+((m&8191)<<13)|0;N=(O+(m>>>13)|0)+(Nv>>>26)|0,Nv&=67108863,x=Math.imul(kt,rr),m=Math.imul(kt,ir),m=m+Math.imul(Et,rr)|0,O=Math.imul(Et,ir),x=x+Math.imul(Re,nr)|0,m=m+Math.imul(Re,or)|0,m=m+Math.imul(je,nr)|0,O=O+Math.imul(je,or)|0,x=x+Math.imul(ge,ar)|0,m=m+Math.imul(ge,sr)|0,m=m+Math.imul(nt,ar)|0,O=O+Math.imul(nt,sr)|0,x=x+Math.imul(_e,ur)|0,m=m+Math.imul(_e,cr)|0,m=m+Math.imul(ve,ur)|0,O=O+Math.imul(ve,cr)|0,x=x+Math.imul(ue,fr)|0,m=m+Math.imul(ue,lr)|0,m=m+Math.imul(ce,fr)|0,O=O+Math.imul(ce,lr)|0,x=x+Math.imul(Y,hr)|0,m=m+Math.imul(Y,dr)|0,m=m+Math.imul(Q,hr)|0,O=O+Math.imul(Q,dr)|0,x=x+Math.imul(be,pr)|0,m=m+Math.imul(be,gr)|0,m=m+Math.imul(C,pr)|0,O=O+Math.imul(C,gr)|0,x=x+Math.imul(le,mr)|0,m=m+Math.imul(le,vr)|0,m=m+Math.imul(se,mr)|0,O=O+Math.imul(se,vr)|0,x=x+Math.imul(W,yr)|0,m=m+Math.imul(W,br)|0,m=m+Math.imul(X,yr)|0,O=O+Math.imul(X,br)|0;var Cv=(N+x|0)+((m&8191)<<13)|0;N=(O+(m>>>13)|0)+(Cv>>>26)|0,Cv&=67108863,x=Math.imul(Ft,rr),m=Math.imul(Ft,ir),m=m+Math.imul(tr,rr)|0,O=Math.imul(tr,ir),x=x+Math.imul(kt,nr)|0,m=m+Math.imul(kt,or)|0,m=m+Math.imul(Et,nr)|0,O=O+Math.imul(Et,or)|0,x=x+Math.imul(Re,ar)|0,m=m+Math.imul(Re,sr)|0,m=m+Math.imul(je,ar)|0,O=O+Math.imul(je,sr)|0,x=x+Math.imul(ge,ur)|0,m=m+Math.imul(ge,cr)|0,m=m+Math.imul(nt,ur)|0,O=O+Math.imul(nt,cr)|0,x=x+Math.imul(_e,fr)|0,m=m+Math.imul(_e,lr)|0,m=m+Math.imul(ve,fr)|0,O=O+Math.imul(ve,lr)|0,x=x+Math.imul(ue,hr)|0,m=m+Math.imul(ue,dr)|0,m=m+Math.imul(ce,hr)|0,O=O+Math.imul(ce,dr)|0,x=x+Math.imul(Y,pr)|0,m=m+Math.imul(Y,gr)|0,m=m+Math.imul(Q,pr)|0,O=O+Math.imul(Q,gr)|0,x=x+Math.imul(be,mr)|0,m=m+Math.imul(be,vr)|0,m=m+Math.imul(C,mr)|0,O=O+Math.imul(C,vr)|0,x=x+Math.imul(le,yr)|0,m=m+Math.imul(le,br)|0,m=m+Math.imul(se,yr)|0,O=O+Math.imul(se,br)|0,x=x+Math.imul(W,_r)|0,m=m+Math.imul(W,wr)|0,m=m+Math.imul(X,_r)|0,O=O+Math.imul(X,wr)|0;var Lv=(N+x|0)+((m&8191)<<13)|0;N=(O+(m>>>13)|0)+(Lv>>>26)|0,Lv&=67108863,x=Math.imul(Ft,nr),m=Math.imul(Ft,or),m=m+Math.imul(tr,nr)|0,O=Math.imul(tr,or),x=x+Math.imul(kt,ar)|0,m=m+Math.imul(kt,sr)|0,m=m+Math.imul(Et,ar)|0,O=O+Math.imul(Et,sr)|0,x=x+Math.imul(Re,ur)|0,m=m+Math.imul(Re,cr)|0,m=m+Math.imul(je,ur)|0,O=O+Math.imul(je,cr)|0,x=x+Math.imul(ge,fr)|0,m=m+Math.imul(ge,lr)|0,m=m+Math.imul(nt,fr)|0,O=O+Math.imul(nt,lr)|0,x=x+Math.imul(_e,hr)|0,m=m+Math.imul(_e,dr)|0,m=m+Math.imul(ve,hr)|0,O=O+Math.imul(ve,dr)|0,x=x+Math.imul(ue,pr)|0,m=m+Math.imul(ue,gr)|0,m=m+Math.imul(ce,pr)|0,O=O+Math.imul(ce,gr)|0,x=x+Math.imul(Y,mr)|0,m=m+Math.imul(Y,vr)|0,m=m+Math.imul(Q,mr)|0,O=O+Math.imul(Q,vr)|0,x=x+Math.imul(be,yr)|0,m=m+Math.imul(be,br)|0,m=m+Math.imul(C,yr)|0,O=O+Math.imul(C,br)|0,x=x+Math.imul(le,_r)|0,m=m+Math.imul(le,wr)|0,m=m+Math.imul(se,_r)|0,O=O+Math.imul(se,wr)|0;var Mv=(N+x|0)+((m&8191)<<13)|0;N=(O+(m>>>13)|0)+(Mv>>>26)|0,Mv&=67108863,x=Math.imul(Ft,ar),m=Math.imul(Ft,sr),m=m+Math.imul(tr,ar)|0,O=Math.imul(tr,sr),x=x+Math.imul(kt,ur)|0,m=m+Math.imul(kt,cr)|0,m=m+Math.imul(Et,ur)|0,O=O+Math.imul(Et,cr)|0,x=x+Math.imul(Re,fr)|0,m=m+Math.imul(Re,lr)|0,m=m+Math.imul(je,fr)|0,O=O+Math.imul(je,lr)|0,x=x+Math.imul(ge,hr)|0,m=m+Math.imul(ge,dr)|0,m=m+Math.imul(nt,hr)|0,O=O+Math.imul(nt,dr)|0,x=x+Math.imul(_e,pr)|0,m=m+Math.imul(_e,gr)|0,m=m+Math.imul(ve,pr)|0,O=O+Math.imul(ve,gr)|0,x=x+Math.imul(ue,mr)|0,m=m+Math.imul(ue,vr)|0,m=m+Math.imul(ce,mr)|0,O=O+Math.imul(ce,vr)|0,x=x+Math.imul(Y,yr)|0,m=m+Math.imul(Y,br)|0,m=m+Math.imul(Q,yr)|0,O=O+Math.imul(Q,br)|0,x=x+Math.imul(be,_r)|0,m=m+Math.imul(be,wr)|0,m=m+Math.imul(C,_r)|0,O=O+Math.imul(C,wr)|0;var Dv=(N+x|0)+((m&8191)<<13)|0;N=(O+(m>>>13)|0)+(Dv>>>26)|0,Dv&=67108863,x=Math.imul(Ft,ur),m=Math.imul(Ft,cr),m=m+Math.imul(tr,ur)|0,O=Math.imul(tr,cr),x=x+Math.imul(kt,fr)|0,m=m+Math.imul(kt,lr)|0,m=m+Math.imul(Et,fr)|0,O=O+Math.imul(Et,lr)|0,x=x+Math.imul(Re,hr)|0,m=m+Math.imul(Re,dr)|0,m=m+Math.imul(je,hr)|0,O=O+Math.imul(je,dr)|0,x=x+Math.imul(ge,pr)|0,m=m+Math.imul(ge,gr)|0,m=m+Math.imul(nt,pr)|0,O=O+Math.imul(nt,gr)|0,x=x+Math.imul(_e,mr)|0,m=m+Math.imul(_e,vr)|0,m=m+Math.imul(ve,mr)|0,O=O+Math.imul(ve,vr)|0,x=x+Math.imul(ue,yr)|0,m=m+Math.imul(ue,br)|0,m=m+Math.imul(ce,yr)|0,O=O+Math.imul(ce,br)|0,x=x+Math.imul(Y,_r)|0,m=m+Math.imul(Y,wr)|0,m=m+Math.imul(Q,_r)|0,O=O+Math.imul(Q,wr)|0;var qv=(N+x|0)+((m&8191)<<13)|0;N=(O+(m>>>13)|0)+(qv>>>26)|0,qv&=67108863,x=Math.imul(Ft,fr),m=Math.imul(Ft,lr),m=m+Math.imul(tr,fr)|0,O=Math.imul(tr,lr),x=x+Math.imul(kt,hr)|0,m=m+Math.imul(kt,dr)|0,m=m+Math.imul(Et,hr)|0,O=O+Math.imul(Et,dr)|0,x=x+Math.imul(Re,pr)|0,m=m+Math.imul(Re,gr)|0,m=m+Math.imul(je,pr)|0,O=O+Math.imul(je,gr)|0,x=x+Math.imul(ge,mr)|0,m=m+Math.imul(ge,vr)|0,m=m+Math.imul(nt,mr)|0,O=O+Math.imul(nt,vr)|0,x=x+Math.imul(_e,yr)|0,m=m+Math.imul(_e,br)|0,m=m+Math.imul(ve,yr)|0,O=O+Math.imul(ve,br)|0,x=x+Math.imul(ue,_r)|0,m=m+Math.imul(ue,wr)|0,m=m+Math.imul(ce,_r)|0,O=O+Math.imul(ce,wr)|0;var Hv=(N+x|0)+((m&8191)<<13)|0;N=(O+(m>>>13)|0)+(Hv>>>26)|0,Hv&=67108863,x=Math.imul(Ft,hr),m=Math.imul(Ft,dr),m=m+Math.imul(tr,hr)|0,O=Math.imul(tr,dr),x=x+Math.imul(kt,pr)|0,m=m+Math.imul(kt,gr)|0,m=m+Math.imul(Et,pr)|0,O=O+Math.imul(Et,gr)|0,x=x+Math.imul(Re,mr)|0,m=m+Math.imul(Re,vr)|0,m=m+Math.imul(je,mr)|0,O=O+Math.imul(je,vr)|0,x=x+Math.imul(ge,yr)|0,m=m+Math.imul(ge,br)|0,m=m+Math.imul(nt,yr)|0,O=O+Math.imul(nt,br)|0,x=x+Math.imul(_e,_r)|0,m=m+Math.imul(_e,wr)|0,m=m+Math.imul(ve,_r)|0,O=O+Math.imul(ve,wr)|0;var Uv=(N+x|0)+((m&8191)<<13)|0;N=(O+(m>>>13)|0)+(Uv>>>26)|0,Uv&=67108863,x=Math.imul(Ft,pr),m=Math.imul(Ft,gr),m=m+Math.imul(tr,pr)|0,O=Math.imul(tr,gr),x=x+Math.imul(kt,mr)|0,m=m+Math.imul(kt,vr)|0,m=m+Math.imul(Et,mr)|0,O=O+Math.imul(Et,vr)|0,x=x+Math.imul(Re,yr)|0,m=m+Math.imul(Re,br)|0,m=m+Math.imul(je,yr)|0,O=O+Math.imul(je,br)|0,x=x+Math.imul(ge,_r)|0,m=m+Math.imul(ge,wr)|0,m=m+Math.imul(nt,_r)|0,O=O+Math.imul(nt,wr)|0;var Fv=(N+x|0)+((m&8191)<<13)|0;N=(O+(m>>>13)|0)+(Fv>>>26)|0,Fv&=67108863,x=Math.imul(Ft,mr),m=Math.imul(Ft,vr),m=m+Math.imul(tr,mr)|0,O=Math.imul(tr,vr),x=x+Math.imul(kt,yr)|0,m=m+Math.imul(kt,br)|0,m=m+Math.imul(Et,yr)|0,O=O+Math.imul(Et,br)|0,x=x+Math.imul(Re,_r)|0,m=m+Math.imul(Re,wr)|0,m=m+Math.imul(je,_r)|0,O=O+Math.imul(je,wr)|0;var jv=(N+x|0)+((m&8191)<<13)|0;N=(O+(m>>>13)|0)+(jv>>>26)|0,jv&=67108863,x=Math.imul(Ft,yr),m=Math.imul(Ft,br),m=m+Math.imul(tr,yr)|0,O=Math.imul(tr,br),x=x+Math.imul(kt,_r)|0,m=m+Math.imul(kt,wr)|0,m=m+Math.imul(Et,_r)|0,O=O+Math.imul(Et,wr)|0;var zv=(N+x|0)+((m&8191)<<13)|0;N=(O+(m>>>13)|0)+(zv>>>26)|0,zv&=67108863,x=Math.imul(Ft,_r),m=Math.imul(Ft,wr),m=m+Math.imul(tr,_r)|0,O=Math.imul(tr,wr);var Kv=(N+x|0)+((m&8191)<<13)|0;return N=(O+(m>>>13)|0)+(Kv>>>26)|0,Kv&=67108863,L[0]=Iv,L[1]=Av,L[2]=Tv,L[3]=Pv,L[4]=Rv,L[5]=kv,L[6]=Bv,L[7]=Nv,L[8]=Cv,L[9]=Lv,L[10]=Mv,L[11]=Dv,L[12]=qv,L[13]=Hv,L[14]=Uv,L[15]=Fv,L[16]=jv,L[17]=zv,L[18]=Kv,N!==0&&(L[19]=N,w.length++),w};Math.imul||(_=y);function T(S,h,v){v.negative=h.negative^S.negative,v.length=S.length+h.length;for(var w=0,E=0,A=0;A<v.length-1;A++){var L=E;E=0;for(var N=w&67108863,x=Math.min(A,h.length-1),m=Math.max(0,A-S.length+1);m<=x;m++){var O=A-m,z=S.words[O]|0,W=h.words[m]|0,X=z*W,ie=X&67108863;L=L+(X/67108864|0)|0,ie=ie+N|0,N=ie&67108863,L=L+(ie>>>26)|0,E+=L>>>26,L&=67108863}v.words[A]=N,w=L,L=E}return w!==0?v.words[A]=w:v.length--,v.strip()}function R(S,h,v){var w=new B;return w.mulp(S,h,v)}n.prototype.mulTo=function(h,v){var w,E=this.length+h.length;return this.length===10&&h.length===10?w=_(this,h,v):E<63?w=y(this,h,v):E<1024?w=T(this,h,v):w=R(this,h,v),w};function B(S,h){this.x=S,this.y=h}B.prototype.makeRBT=function(h){for(var v=new Array(h),w=n.prototype._countBits(h)-1,E=0;E<h;E++)v[E]=this.revBin(E,w,h);return v},B.prototype.revBin=function(h,v,w){if(h===0||h===w-1)return h;for(var E=0,A=0;A<v;A++)E|=(h&1)<<v-A-1,h>>=1;return E},B.prototype.permute=function(h,v,w,E,A,L){for(var N=0;N<L;N++)E[N]=v[h[N]],A[N]=w[h[N]]},B.prototype.transform=function(h,v,w,E,A,L){this.permute(L,h,v,w,E,A);for(var N=1;N<A;N<<=1)for(var x=N<<1,m=Math.cos(2*Math.PI/x),O=Math.sin(2*Math.PI/x),z=0;z<A;z+=x)for(var W=m,X=O,ie=0;ie<N;ie++){var le=w[z+ie],se=E[z+ie],ye=w[z+ie+N],be=E[z+ie+N],C=W*ye-X*be;be=W*be+X*ye,ye=C,w[z+ie]=le+ye,E[z+ie]=se+be,w[z+ie+N]=le-ye,E[z+ie+N]=se-be,ie!==x&&(C=m*W-O*X,X=m*X+O*W,W=C)}},B.prototype.guessLen13b=function(h,v){var w=Math.max(v,h)|1,E=w&1,A=0;for(w=w/2|0;w;w=w>>>1)A++;return 1<<A+1+E},B.prototype.conjugate=function(h,v,w){if(!(w<=1))for(var E=0;E<w/2;E++){var A=h[E];h[E]=h[w-E-1],h[w-E-1]=A,A=v[E],v[E]=-v[w-E-1],v[w-E-1]=-A}},B.prototype.normalize13b=function(h,v){for(var w=0,E=0;E<v/2;E++){var A=Math.round(h[2*E+1]/v)*8192+Math.round(h[2*E]/v)+w;h[E]=A&67108863,A<67108864?w=0:w=A/67108864|0}return h},B.prototype.convert13b=function(h,v,w,E){for(var A=0,L=0;L<v;L++)A=A+(h[L]|0),w[2*L]=A&8191,A=A>>>13,w[2*L+1]=A&8191,A=A>>>13;for(L=2*v;L<E;++L)w[L]=0;r(A===0),r((A&-8192)===0)},B.prototype.stub=function(h){for(var v=new Array(h),w=0;w<h;w++)v[w]=0;return v},B.prototype.mulp=function(h,v,w){var E=2*this.guessLen13b(h.length,v.length),A=this.makeRBT(E),L=this.stub(E),N=new Array(E),x=new Array(E),m=new Array(E),O=new Array(E),z=new Array(E),W=new Array(E),X=w.words;X.length=E,this.convert13b(h.words,h.length,N,E),this.convert13b(v.words,v.length,O,E),this.transform(N,L,x,m,E,A),this.transform(O,L,z,W,E,A);for(var ie=0;ie<E;ie++){var le=x[ie]*z[ie]-m[ie]*W[ie];m[ie]=x[ie]*W[ie]+m[ie]*z[ie],x[ie]=le}return this.conjugate(x,m,E),this.transform(x,m,X,L,E,A),this.conjugate(X,L,E),this.normalize13b(X,E),w.negative=h.negative^v.negative,w.length=h.length+v.length,w.strip()},n.prototype.mul=function(h){var v=new n(null);return v.words=new Array(this.length+h.length),this.mulTo(h,v)},n.prototype.mulf=function(h){var v=new n(null);return v.words=new Array(this.length+h.length),R(this,h,v)},n.prototype.imul=function(h){return this.clone().mulTo(h,this)},n.prototype.imuln=function(h){r(typeof h=="number"),r(h<67108864);for(var v=0,w=0;w<this.length;w++){var E=(this.words[w]|0)*h,A=(E&67108863)+(v&67108863);v>>=26,v+=E/67108864|0,v+=A>>>26,this.words[w]=A&67108863}return v!==0&&(this.words[w]=v,this.length++),h===0&&(this.length=1,this._normSign()),this},n.prototype.muln=function(h){return this.clone().imuln(h)},n.prototype.sqr=function(){return this.mul(this)},n.prototype.isqr=function(){return this.imul(this.clone())},n.prototype.pow=function(h){var v=p(h);if(v.length===0)return new n(1);for(var w=this,E=0;E<v.length&&v[E]===0;E++,w=w.sqr());if(++E<v.length)for(var A=w.sqr();E<v.length;E++,A=A.sqr())v[E]!==0&&(w=w.mul(A));return w},n.prototype.iushln=function(h){r(typeof h=="number"&&h>=0);var v=h%26,w=(h-v)/26,E=67108863>>>26-v<<26-v,A;if(v!==0){var L=0;for(A=0;A<this.length;A++){var N=this.words[A]&E,x=(this.words[A]|0)-N<<v;this.words[A]=x|L,L=N>>>26-v}L&&(this.words[A]=L,this.length++)}if(w!==0){for(A=this.length-1;A>=0;A--)this.words[A+w]=this.words[A];for(A=0;A<w;A++)this.words[A]=0;this.length+=w}return this.strip()},n.prototype.ishln=function(h){return r(this.negative===0),this.iushln(h)},n.prototype.iushrn=function(h,v,w){r(typeof h=="number"&&h>=0);var E;v?E=(v-v%26)/26:E=0;var A=h%26,L=Math.min((h-A)/26,this.length),N=67108863^67108863>>>A<<A,x=w;if(E-=L,E=Math.max(0,E),x){for(var m=0;m<L;m++)x.words[m]=this.words[m];x.length=L}if(L!==0)if(this.length>L)for(this.length-=L,m=0;m<this.length;m++)this.words[m]=this.words[m+L];else this.words[0]=0,this.length=1;var O=0;for(m=this.length-1;m>=0&&(O!==0||m>=E);m--){var z=this.words[m]|0;this.words[m]=O<<26-A|z>>>A,O=z&N}return x&&O!==0&&(x.words[x.length++]=O),this.length===0&&(this.words[0]=0,this.length=1),this.strip()},n.prototype.ishrn=function(h,v,w){return r(this.negative===0),this.iushrn(h,v,w)},n.prototype.shln=function(h){return this.clone().ishln(h)},n.prototype.ushln=function(h){return this.clone().iushln(h)},n.prototype.shrn=function(h){return this.clone().ishrn(h)},n.prototype.ushrn=function(h){return this.clone().iushrn(h)},n.prototype.testn=function(h){r(typeof h=="number"&&h>=0);var v=h%26,w=(h-v)/26,E=1<<v;if(this.length<=w)return!1;var A=this.words[w];return!!(A&E)},n.prototype.imaskn=function(h){r(typeof h=="number"&&h>=0);var v=h%26,w=(h-v)/26;if(r(this.negative===0,"imaskn works only with positive numbers"),this.length<=w)return this;if(v!==0&&w++,this.length=Math.min(w,this.length),v!==0){var E=67108863^67108863>>>v<<v;this.words[this.length-1]&=E}return this.length===0&&(this.words[0]=0,this.length=1),this.strip()},n.prototype.maskn=function(h){return this.clone().imaskn(h)},n.prototype.iaddn=function(h){return r(typeof h=="number"),r(h<67108864),h<0?this.isubn(-h):this.negative!==0?this.length===1&&(this.words[0]|0)<h?(this.words[0]=h-(this.words[0]|0),this.negative=0,this):(this.negative=0,this.isubn(h),this.negative=1,this):this._iaddn(h)},n.prototype._iaddn=function(h){this.words[0]+=h;for(var v=0;v<this.length&&this.words[v]>=67108864;v++)this.words[v]-=67108864,v===this.length-1?this.words[v+1]=1:this.words[v+1]++;return this.length=Math.max(this.length,v+1),this},n.prototype.isubn=function(h){if(r(typeof h=="number"),r(h<67108864),h<0)return this.iaddn(-h);if(this.negative!==0)return this.negative=0,this.iaddn(h),this.negative=1,this;if(this.words[0]-=h,this.length===1&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var v=0;v<this.length&&this.words[v]<0;v++)this.words[v]+=67108864,this.words[v+1]-=1;return this.strip()},n.prototype.addn=function(h){return this.clone().iaddn(h)},n.prototype.subn=function(h){return this.clone().isubn(h)},n.prototype.iabs=function(){return this.negative=0,this},n.prototype.abs=function(){return this.clone().iabs()},n.prototype._ishlnsubmul=function(h,v,w){var E=h.length+w,A;this._expand(E);var L,N=0;for(A=0;A<h.length;A++){L=(this.words[A+w]|0)+N;var x=(h.words[A]|0)*v;L-=x&67108863,N=(L>>26)-(x/67108864|0),this.words[A+w]=L&67108863}for(;A<this.length-w;A++)L=(this.words[A+w]|0)+N,N=L>>26,this.words[A+w]=L&67108863;if(N===0)return this.strip();for(r(N===-1),N=0,A=0;A<this.length;A++)L=-(this.words[A]|0)+N,N=L>>26,this.words[A]=L&67108863;return this.negative=1,this.strip()},n.prototype._wordDiv=function(h,v){var w=this.length-h.length,E=this.clone(),A=h,L=A.words[A.length-1]|0,N=this._countBits(L);w=26-N,w!==0&&(A=A.ushln(w),E.iushln(w),L=A.words[A.length-1]|0);var x=E.length-A.length,m;if(v!=="mod"){m=new n(null),m.length=x+1,m.words=new Array(m.length);for(var O=0;O<m.length;O++)m.words[O]=0}var z=E.clone()._ishlnsubmul(A,1,x);z.negative===0&&(E=z,m&&(m.words[x]=1));for(var W=x-1;W>=0;W--){var X=(E.words[A.length+W]|0)*67108864+(E.words[A.length+W-1]|0);for(X=Math.min(X/L|0,67108863),E._ishlnsubmul(A,X,W);E.negative!==0;)X--,E.negative=0,E._ishlnsubmul(A,1,W),E.isZero()||(E.negative^=1);m&&(m.words[W]=X)}return m&&m.strip(),E.strip(),v!=="div"&&w!==0&&E.iushrn(w),{div:m||null,mod:E}},n.prototype.divmod=function(h,v,w){if(r(!h.isZero()),this.isZero())return{div:new n(0),mod:new n(0)};var E,A,L;return this.negative!==0&&h.negative===0?(L=this.neg().divmod(h,v),v!=="mod"&&(E=L.div.neg()),v!=="div"&&(A=L.mod.neg(),w&&A.negative!==0&&A.iadd(h)),{div:E,mod:A}):this.negative===0&&h.negative!==0?(L=this.divmod(h.neg(),v),v!=="mod"&&(E=L.div.neg()),{div:E,mod:L.mod}):(this.negative&h.negative)!==0?(L=this.neg().divmod(h.neg(),v),v!=="div"&&(A=L.mod.neg(),w&&A.negative!==0&&A.isub(h)),{div:L.div,mod:A}):h.length>this.length||this.cmp(h)<0?{div:new n(0),mod:this}:h.length===1?v==="div"?{div:this.divn(h.words[0]),mod:null}:v==="mod"?{div:null,mod:new n(this.modn(h.words[0]))}:{div:this.divn(h.words[0]),mod:new n(this.modn(h.words[0]))}:this._wordDiv(h,v)},n.prototype.div=function(h){return this.divmod(h,"div",!1).div},n.prototype.mod=function(h){return this.divmod(h,"mod",!1).mod},n.prototype.umod=function(h){return this.divmod(h,"mod",!0).mod},n.prototype.divRound=function(h){var v=this.divmod(h);if(v.mod.isZero())return v.div;var w=v.mod.abs(),E=h.abs().iushrn(1),A=h.words[0]&1,L=w.cmp(E);if(L<0||A===1&&L===0)return v.div;var N=new n(1);return N.negative=this.negative^h.negative,v.div.iadd(N)},n.prototype.modn=function(h){r(h<=67108863);for(var v=(1<<26)%h,w=0,E=this.length-1;E>=0;E--)w=(v*w+(this.words[E]|0))%h;return w},n.prototype.idivn=function(h){r(h<=67108863);for(var v=0,w=this.length-1;w>=0;w--){var E=(this.words[w]|0)+v*67108864;this.words[w]=E/h|0,v=E%h}return this.strip()},n.prototype.divn=function(h){return this.clone().idivn(h)},n.prototype.egcd=function(h){r(h.negative===0),r(!h.isZero());var v=this,w=h.clone();v.negative!==0?v=v.umod(h):v=v.clone();for(var E=new n(1),A=new n(0),L=new n(0),N=new n(1),x=0;v.isEven()&&w.isEven();)v.iushrn(1),w.iushrn(1),++x;for(var m=w.clone(),O=v.clone();!v.isZero();){for(var z=0,W=1;(v.words[0]&W)===0&&z<26;++z,W<<=1);if(z>0)for(v.iushrn(z);z-- >0;)(E.isOdd()||A.isOdd())&&(E.iadd(m),A.isub(O)),E.iushrn(1),A.iushrn(1);for(var X=0,ie=1;(w.words[0]&ie)===0&&X<26;++X,ie<<=1);if(X>0)for(w.iushrn(X);X-- >0;)(L.isOdd()||N.isOdd())&&(L.iadd(m),N.isub(O)),L.iushrn(1),N.iushrn(1);v.cmp(w)>=0?(v.isub(w),E.isub(L),A.isub(N)):(w.isub(v),L.isub(E),N.isub(A))}return{a:L,b:N,gcd:w.iushln(x)}},n.prototype._invmp=function(h){r(h.negative===0),r(!h.isZero());var v=this,w=h.clone();v.negative!==0?v=v.umod(h):v=v.clone();for(var E=new n(1),A=new n(0),L=w.clone();v.cmpn(1)>0&&w.cmpn(1)>0;){for(var N=0,x=1;(v.words[0]&x)===0&&N<26;++N,x<<=1);if(N>0)for(v.iushrn(N);N-- >0;)E.isOdd()&&E.iadd(L),E.iushrn(1);for(var m=0,O=1;(w.words[0]&O)===0&&m<26;++m,O<<=1);if(m>0)for(w.iushrn(m);m-- >0;)A.isOdd()&&A.iadd(L),A.iushrn(1);v.cmp(w)>=0?(v.isub(w),E.isub(A)):(w.isub(v),A.isub(E))}var z;return v.cmpn(1)===0?z=E:z=A,z.cmpn(0)<0&&z.iadd(h),z},n.prototype.gcd=function(h){if(this.isZero())return h.abs();if(h.isZero())return this.abs();var v=this.clone(),w=h.clone();v.negative=0,w.negative=0;for(var E=0;v.isEven()&&w.isEven();E++)v.iushrn(1),w.iushrn(1);do{for(;v.isEven();)v.iushrn(1);for(;w.isEven();)w.iushrn(1);var A=v.cmp(w);if(A<0){var L=v;v=w,w=L}else if(A===0||w.cmpn(1)===0)break;v.isub(w)}while(!0);return w.iushln(E)},n.prototype.invm=function(h){return this.egcd(h).a.umod(h)},n.prototype.isEven=function(){return(this.words[0]&1)===0},n.prototype.isOdd=function(){return(this.words[0]&1)===1},n.prototype.andln=function(h){return this.words[0]&h},n.prototype.bincn=function(h){r(typeof h=="number");var v=h%26,w=(h-v)/26,E=1<<v;if(this.length<=w)return this._expand(w+1),this.words[w]|=E,this;for(var A=E,L=w;A!==0&&L<this.length;L++){var N=this.words[L]|0;N+=A,A=N>>>26,N&=67108863,this.words[L]=N}return A!==0&&(this.words[L]=A,this.length++),this},n.prototype.isZero=function(){return this.length===1&&this.words[0]===0},n.prototype.cmpn=function(h){var v=h<0;if(this.negative!==0&&!v)return-1;if(this.negative===0&&v)return 1;this.strip();var w;if(this.length>1)w=1;else{v&&(h=-h),r(h<=67108863,"Number is too big");var E=this.words[0]|0;w=E===h?0:E<h?-1:1}return this.negative!==0?-w|0:w},n.prototype.cmp=function(h){if(this.negative!==0&&h.negative===0)return-1;if(this.negative===0&&h.negative!==0)return 1;var v=this.ucmp(h);return this.negative!==0?-v|0:v},n.prototype.ucmp=function(h){if(this.length>h.length)return 1;if(this.length<h.length)return-1;for(var v=0,w=this.length-1;w>=0;w--){var E=this.words[w]|0,A=h.words[w]|0;if(E!==A){E<A?v=-1:E>A&&(v=1);break}}return v},n.prototype.gtn=function(h){return this.cmpn(h)===1},n.prototype.gt=function(h){return this.cmp(h)===1},n.prototype.gten=function(h){return this.cmpn(h)>=0},n.prototype.gte=function(h){return this.cmp(h)>=0},n.prototype.ltn=function(h){return this.cmpn(h)===-1},n.prototype.lt=function(h){return this.cmp(h)===-1},n.prototype.lten=function(h){return this.cmpn(h)<=0},n.prototype.lte=function(h){return this.cmp(h)<=0},n.prototype.eqn=function(h){return this.cmpn(h)===0},n.prototype.eq=function(h){return this.cmp(h)===0},n.red=function(h){return new K(h)},n.prototype.toRed=function(h){return r(!this.red,"Already a number in reduction context"),r(this.negative===0,"red works only with positives"),h.convertTo(this)._forceRed(h)},n.prototype.fromRed=function(){return r(this.red,"fromRed works only with numbers in reduction context"),this.red.convertFrom(this)},n.prototype._forceRed=function(h){return this.red=h,this},n.prototype.forceRed=function(h){return r(!this.red,"Already a number in reduction context"),this._forceRed(h)},n.prototype.redAdd=function(h){return r(this.red,"redAdd works only with red numbers"),this.red.add(this,h)},n.prototype.redIAdd=function(h){return r(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,h)},n.prototype.redSub=function(h){return r(this.red,"redSub works only with red numbers"),this.red.sub(this,h)},n.prototype.redISub=function(h){return r(this.red,"redISub works only with red numbers"),this.red.isub(this,h)},n.prototype.redShl=function(h){return r(this.red,"redShl works only with red numbers"),this.red.shl(this,h)},n.prototype.redMul=function(h){return r(this.red,"redMul works only with red numbers"),this.red._verify2(this,h),this.red.mul(this,h)},n.prototype.redIMul=function(h){return r(this.red,"redMul works only with red numbers"),this.red._verify2(this,h),this.red.imul(this,h)},n.prototype.redSqr=function(){return r(this.red,"redSqr works only with red numbers"),this.red._verify1(this),this.red.sqr(this)},n.prototype.redISqr=function(){return r(this.red,"redISqr works only with red numbers"),this.red._verify1(this),this.red.isqr(this)},n.prototype.redSqrt=function(){return r(this.red,"redSqrt works only with red numbers"),this.red._verify1(this),this.red.sqrt(this)},n.prototype.redInvm=function(){return r(this.red,"redInvm works only with red numbers"),this.red._verify1(this),this.red.invm(this)},n.prototype.redNeg=function(){return r(this.red,"redNeg works only with red numbers"),this.red._verify1(this),this.red.neg(this)},n.prototype.redPow=function(h){return r(this.red&&!h.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,h)};var H={k256:null,p224:null,p192:null,p25519:null};function j(S,h){this.name=S,this.p=new n(h,16),this.n=this.p.bitLength(),this.k=new n(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}j.prototype._tmp=function(){var h=new n(null);return h.words=new Array(Math.ceil(this.n/13)),h},j.prototype.ireduce=function(h){var v=h,w;do this.split(v,this.tmp),v=this.imulK(v),v=v.iadd(this.tmp),w=v.bitLength();while(w>this.n);var E=w<this.n?-1:v.ucmp(this.p);return E===0?(v.words[0]=0,v.length=1):E>0?v.isub(this.p):v.strip!==void 0?v.strip():v._strip(),v},j.prototype.split=function(h,v){h.iushrn(this.n,0,v)},j.prototype.imulK=function(h){return h.imul(this.k)};function I(){j.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}i(I,j),I.prototype.split=function(h,v){for(var w=4194303,E=Math.min(h.length,9),A=0;A<E;A++)v.words[A]=h.words[A];if(v.length=E,h.length<=9){h.words[0]=0,h.length=1;return}var L=h.words[9];for(v.words[v.length++]=L&w,A=10;A<h.length;A++){var N=h.words[A]|0;h.words[A-10]=(N&w)<<4|L>>>22,L=N}L>>>=22,h.words[A-10]=L,L===0&&h.length>10?h.length-=10:h.length-=9},I.prototype.imulK=function(h){h.words[h.length]=0,h.words[h.length+1]=0,h.length+=2;for(var v=0,w=0;w<h.length;w++){var E=h.words[w]|0;v+=E*977,h.words[w]=v&67108863,v=E*64+(v/67108864|0)}return h.words[h.length-1]===0&&(h.length--,h.words[h.length-1]===0&&h.length--),h};function k(){j.call(this,"p224","ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001")}i(k,j);function D(){j.call(this,"p192","ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff")}i(D,j);function F(){j.call(this,"25519","7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed")}i(F,j),F.prototype.imulK=function(h){for(var v=0,w=0;w<h.length;w++){var E=(h.words[w]|0)*19+v,A=E&67108863;E>>>=26,h.words[w]=A,v=E}return v!==0&&(h.words[h.length++]=v),h},n._prime=function(h){if(H[h])return H[h];var v;if(h==="k256")v=new I;else if(h==="p224")v=new k;else if(h==="p192")v=new D;else if(h==="p25519")v=new F;else throw new Error("Unknown prime "+h);return H[h]=v,v};function K(S){if(typeof S=="string"){var h=n._prime(S);this.m=h.p,this.prime=h}else r(S.gtn(1),"modulus must be greater than 1"),this.m=S,this.prime=null}K.prototype._verify1=function(h){r(h.negative===0,"red works only with positives"),r(h.red,"red works only with red numbers")},K.prototype._verify2=function(h,v){r((h.negative|v.negative)===0,"red works only with positives"),r(h.red&&h.red===v.red,"red works only with red numbers")},K.prototype.imod=function(h){return this.prime?this.prime.ireduce(h)._forceRed(this):h.umod(this.m)._forceRed(this)},K.prototype.neg=function(h){return h.isZero()?h.clone():this.m.sub(h)._forceRed(this)},K.prototype.add=function(h,v){this._verify2(h,v);var w=h.add(v);return w.cmp(this.m)>=0&&w.isub(this.m),w._forceRed(this)},K.prototype.iadd=function(h,v){this._verify2(h,v);var w=h.iadd(v);return w.cmp(this.m)>=0&&w.isub(this.m),w},K.prototype.sub=function(h,v){this._verify2(h,v);var w=h.sub(v);return w.cmpn(0)<0&&w.iadd(this.m),w._forceRed(this)},K.prototype.isub=function(h,v){this._verify2(h,v);var w=h.isub(v);return w.cmpn(0)<0&&w.iadd(this.m),w},K.prototype.shl=function(h,v){return this._verify1(h),this.imod(h.ushln(v))},K.prototype.imul=function(h,v){return this._verify2(h,v),this.imod(h.imul(v))},K.prototype.mul=function(h,v){return this._verify2(h,v),this.imod(h.mul(v))},K.prototype.isqr=function(h){return this.imul(h,h.clone())},K.prototype.sqr=function(h){return this.mul(h,h)},K.prototype.sqrt=function(h){if(h.isZero())return h.clone();var v=this.m.andln(3);if(r(v%2===1),v===3){var w=this.m.add(new n(1)).iushrn(2);return this.pow(h,w)}for(var E=this.m.subn(1),A=0;!E.isZero()&&E.andln(1)===0;)A++,E.iushrn(1);r(!E.isZero());var L=new n(1).toRed(this),N=L.redNeg(),x=this.m.subn(1).iushrn(1),m=this.m.bitLength();for(m=new n(2*m*m).toRed(this);this.pow(m,x).cmp(N)!==0;)m.redIAdd(N);for(var O=this.pow(m,E),z=this.pow(h,E.addn(1).iushrn(1)),W=this.pow(h,E),X=A;W.cmp(L)!==0;){for(var ie=W,le=0;ie.cmp(L)!==0;le++)ie=ie.redSqr();r(le<X);var se=this.pow(O,new n(1).iushln(X-le-1));z=z.redMul(se),O=se.redSqr(),W=W.redMul(O),X=le}return z},K.prototype.invm=function(h){var v=h._invmp(this.m);return v.negative!==0?(v.negative=0,this.imod(v).redNeg()):this.imod(v)},K.prototype.pow=function(h,v){if(v.isZero())return new n(1).toRed(this);if(v.cmpn(1)===0)return h.clone();var w=4,E=new Array(1<<w);E[0]=new n(1).toRed(this),E[1]=h;for(var A=2;A<E.length;A++)E[A]=this.mul(E[A-1],h);var L=E[0],N=0,x=0,m=v.bitLength()%26;for(m===0&&(m=26),A=v.length-1;A>=0;A--){for(var O=v.words[A],z=m-1;z>=0;z--){var W=O>>z&1;if(L!==E[0]&&(L=this.sqr(L)),W===0&&N===0){x=0;continue}N<<=1,N|=W,x++,!(x!==w&&(A!==0||z!==0))&&(L=this.mul(L,E[N]),x=0,N=0)}m=26}return L},K.prototype.convertTo=function(h){var v=h.umod(this.m);return v===h?v.clone():v},K.prototype.convertFrom=function(h){var v=h.clone();return v.red=null,v},n.mont=function(h){return new G(h)};function G(S){K.call(this,S),this.shift=this.m.bitLength(),this.shift%26!==0&&(this.shift+=26-this.shift%26),this.r=new n(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)}i(G,K),G.prototype.convertTo=function(h){return this.imod(h.ushln(this.shift))},G.prototype.convertFrom=function(h){var v=this.imod(h.mul(this.rinv));return v.red=null,v},G.prototype.imul=function(h,v){if(h.isZero()||v.isZero())return h.words[0]=0,h.length=1,h;var w=h.imul(v),E=w.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),A=w.isub(E).iushrn(this.shift),L=A;return A.cmp(this.m)>=0?L=A.isub(this.m):A.cmpn(0)<0&&(L=A.iadd(this.m)),L._forceRed(this)},G.prototype.mul=function(h,v){if(h.isZero()||v.isZero())return new n(0)._forceRed(this);var w=h.mul(v),E=w.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),A=w.isub(E).iushrn(this.shift),L=A;return A.cmp(this.m)>=0?L=A.isub(this.m):A.cmpn(0)<0&&(L=A.iadd(this.m)),L._forceRed(this)},G.prototype.invm=function(h){var v=this.imod(h._invmp(this.m).mul(this.r2));return v._forceRed(this)}})(typeof Fy>"u"||Fy,PT)});var jy=P((fne,RT)=>{"use strict";g();RT.exports="9.11.1"});var BT=P((hne,kT)=>{"use strict";g();var Uz="https://docs.moneybutton.com/";kT.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: "+Uz+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 ci=P((pne,Ky)=>{"use strict";g();var zy=Je();function Fz(e,t){return e.replace("{0}",t[0]).replace("{1}",t[1]).replace("{2}",t[2])}var NT=function(e,t){var r=function(){if(zy.isString(t.message))this.message=Fz(t.message,arguments);else if(zy.isFunction(t.message))this.message=t.message.apply(null,arguments);else throw new Error("Invalid error definition for "+t.name);this.stack=this.message+`
11
+ Use Chrome, Firefox or Internet Explorer 11`)}var Lz=Qr().Buffer,Pp=globalThis.crypto||globalThis.msCrypto;Pp&&Pp.getRandomValues?Hy.exports=Mz:Hy.exports=Cz;function Mz(e,t){if(e>Nz)throw new RangeError("requested too many random bytes");var r=Lz.allocUnsafe(e);if(e>0)if(e>qy)for(var i=0;i<e;i+=qy)Pp.getRandomValues(r.slice(i,i+qy));else Pp.getRandomValues(r);return typeof t=="function"?b.default.nextTick(function(){t(null,r)}):r}});var Kt=P(Rp=>{"use strict";g();Rp.createHash=dT();Rp.createHmac=wT();Rp.randomBytes=ST()});var Ui=P((ine,xT)=>{"use strict";g();var ET=65536;function qs(){}qs.getRandomBuffer=function(e){var t=typeof globalThis<"u"?globalThis.crypto:void 0;if(t&&typeof t.getRandomValues=="function")return qs._fromGetRandomValues(t,e);try{var r=Kt();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)")};qs._fromGetRandomValues=function(e,t){for(var r=f.Buffer.alloc(t),i=0;i<t;i+=ET){var n=new Uint8Array(Math.min(ET,t-i));e.getRandomValues(n),f.Buffer.from(n).copy(r,i)}return r};qs.getRandomBufferNode=function(e){var t=Kt();return t.randomBytes(e)};qs.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 qs._fromGetRandomValues(r,e)};xT.exports=qs});var Je=P((one,OT)=>{"use strict";g();var Dz=Ui(),xt={};xt.isArray=e=>Array.isArray(e);xt.isNumber=e=>typeof e=="number";xt.isObject=e=>e&&typeof e=="object";xt.isString=e=>typeof e=="string";xt.isUndefined=e=>typeof e>"u";xt.isFunction=e=>typeof e=="function";xt.isNull=e=>e===null;xt.isDate=e=>e instanceof Date;xt.extend=(e,t)=>Object.assign(e,t);xt.noop=()=>{};xt.every=(e,t)=>e.every(t||(r=>r));xt.map=(e,t)=>Array.from(e).map(t||(r=>r));xt.includes=(e,t)=>e.includes(t);xt.each=(e,t)=>e.forEach(t);xt.clone=e=>Object.assign({},e);xt.pick=(e,t)=>{let r={};return t.forEach(i=>{typeof e[i]<"u"&&(r[i]=e[i])}),r};xt.values=e=>Object.values(e);xt.filter=(e,t)=>e.filter(t);xt.reduce=(e,t,r)=>e.reduce(t,r);xt.without=(e,t)=>e.filter(r=>r!==t);xt.shuffle=e=>{let t=e.slice(0);for(let r=t.length-1;r>0;r--){let n=Dz.getRandomBuffer(4).readUInt32BE(0)/4294967296,o=Math.floor(n*(r+1));[t[r],t[o]]=[t[o],t[r]]}return t};xt.difference=(e,t)=>e.filter(r=>!t.includes(r));xt.findIndex=(e,t)=>e.findIndex(t);xt.some=(e,t)=>e.some(t);xt.range=e=>[...Array(e).keys()];OT.exports=xt});var ac=P((sne,TT)=>{"use strict";g();var Uy=Je(),IT=jt(),oc="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz".split(""),AT={};for(dl=0;dl<oc.length;dl++)AT[oc[dl]]=dl;var dl;function qz(e){if(e.length===0)return"";var t=[0],r,i,n;for(r=0;r<e.length;r++){for(i=0,n=e[r];i<t.length;i++)n+=t[i]<<8,t[i]=n%58,n=n/58|0;for(;n>0;)t.push(n%58),n=n/58|0}var o="";for(r=0;e[r]===0&&r<e.length-1;r++)o+=oc[0];for(r=t.length-1;r>=0;r--)o+=oc[t[r]];return o}function Hz(e){if(e.length===0)return f.Buffer.alloc(0);var t=[0],r,i,n;for(r=0;r<e.length;r++){var o=AT[e[r]];if(o===void 0)throw new Error("Non-base58 character");for(i=0,n=o;i<t.length;i++)n+=t[i]*58,t[i]=n&255,n>>=8;for(;n>0;)t.push(n&255),n>>=8}for(r=0;e[r]===oc[0]&&r<e.length-1;r++)t.push(0);return f.Buffer.from(t.reverse())}var Gr=function e(t){if(!(this instanceof e))return new e(t);if(f.Buffer.isBuffer(t)){var r=t;this.fromBuffer(r)}else if(typeof t=="string"){var i=t;this.fromString(i)}};Gr.validCharacters=function(t){return IT.Buffer.isBuffer(t)&&(t=t.toString()),Uy.every(Uy.map(t,function(r){return Uy.includes(oc,r)}))};Gr.prototype.set=function(e){return this.buf=e.buf||this.buf||void 0,this};Gr.encode=function(e){if(!IT.Buffer.isBuffer(e))throw new Error("Input should be a buffer");return qz(e)};Gr.decode=function(e){if(typeof e!="string")throw new Error("Input should be a string");return Hz(e)};Gr.prototype.fromBuffer=function(e){return this.buf=e,this};Gr.fromBuffer=function(e){return new Gr().fromBuffer(e)};Gr.fromHex=function(e){return Gr.fromBuffer(f.Buffer.from(e,"hex"))};Gr.prototype.fromString=function(e){var t=Gr.decode(e);return this.buf=t,this};Gr.fromString=function(e){return new Gr().fromString(e)};Gr.prototype.toBuffer=function(){return this.buf};Gr.prototype.toHex=function(){return this.toBuffer().toString("hex")};Gr.prototype.toString=function(){return Gr.encode(this.buf)};TT.exports=Gr});var kp=P((PT,Fy)=>{g();(function(e,t){"use strict";function r(S,h){if(!S)throw new Error(h||"Assertion failed")}function i(S,h){S.super_=h;var v=function(){};v.prototype=h.prototype,S.prototype=new v,S.prototype.constructor=S}function n(S,h,v){if(n.isBN(S))return S;this.negative=0,this.words=null,this.length=0,this.red=null,S!==null&&((h==="le"||h==="be")&&(v=h,h=10),this._init(S||0,h||10,v||"be"))}typeof e=="object"?e.exports=n:t.BN=n,n.BN=n,n.wordSize=26;var o;try{typeof window<"u"&&typeof window.Buffer<"u"?o=window.Buffer:o=jt().Buffer}catch{}n.isBN=function(h){return h instanceof n?!0:h!==null&&typeof h=="object"&&h.constructor.wordSize===n.wordSize&&Array.isArray(h.words)},n.max=function(h,v){return h.cmp(v)>0?h:v},n.min=function(h,v){return h.cmp(v)<0?h:v},n.prototype._init=function(h,v,w){if(typeof h=="number")return this._initNumber(h,v,w);if(typeof h=="object")return this._initArray(h,v,w);v==="hex"&&(v=16),r(v===(v|0)&&v>=2&&v<=36),h=h.toString().replace(/\s+/g,"");var E=0;h[0]==="-"&&(E++,this.negative=1),E<h.length&&(v===16?this._parseHex(h,E,w):(this._parseBase(h,v,E),w==="le"&&this._initArray(this.toArray(),v,w)))},n.prototype._initNumber=function(h,v,w){h<0&&(this.negative=1,h=-h),h<67108864?(this.words=[h&67108863],this.length=1):h<4503599627370496?(this.words=[h&67108863,h/67108864&67108863],this.length=2):(r(h<9007199254740992),this.words=[h&67108863,h/67108864&67108863,1],this.length=3),w==="le"&&this._initArray(this.toArray(),v,w)},n.prototype._initArray=function(h,v,w){if(r(typeof h.length=="number"),h.length<=0)return this.words=[0],this.length=1,this;this.length=Math.ceil(h.length/3),this.words=new Array(this.length);for(var E=0;E<this.length;E++)this.words[E]=0;var A,L,N=0;if(w==="be")for(E=h.length-1,A=0;E>=0;E-=3)L=h[E]|h[E-1]<<8|h[E-2]<<16,this.words[A]|=L<<N&67108863,this.words[A+1]=L>>>26-N&67108863,N+=24,N>=26&&(N-=26,A++);else if(w==="le")for(E=0,A=0;E<h.length;E+=3)L=h[E]|h[E+1]<<8|h[E+2]<<16,this.words[A]|=L<<N&67108863,this.words[A+1]=L>>>26-N&67108863,N+=24,N>=26&&(N-=26,A++);return this.strip()};function a(S,h){var v=S.charCodeAt(h);return v>=65&&v<=70?v-55:v>=97&&v<=102?v-87:v-48&15}function s(S,h,v){var w=a(S,v);return v-1>=h&&(w|=a(S,v-1)<<4),w}n.prototype._parseHex=function(h,v,w){this.length=Math.ceil((h.length-v)/6),this.words=new Array(this.length);for(var E=0;E<this.length;E++)this.words[E]=0;var A=0,L=0,N;if(w==="be")for(E=h.length-1;E>=v;E-=2)N=s(h,v,E)<<A,this.words[L]|=N&67108863,A>=18?(A-=18,L+=1,this.words[L]|=N>>>26):A+=8;else{var x=h.length-v;for(E=x%2===0?v+1:v;E<h.length;E+=2)N=s(h,v,E)<<A,this.words[L]|=N&67108863,A>=18?(A-=18,L+=1,this.words[L]|=N>>>26):A+=8}this.strip()};function u(S,h,v,w){for(var E=0,A=Math.min(S.length,v),L=h;L<A;L++){var N=S.charCodeAt(L)-48;E*=w,N>=49?E+=N-49+10:N>=17?E+=N-17+10:E+=N}return E}n.prototype._parseBase=function(h,v,w){this.words=[0],this.length=1;for(var E=0,A=1;A<=67108863;A*=v)E++;E--,A=A/v|0;for(var L=h.length-w,N=L%E,x=Math.min(L,L-N)+w,m=0,O=w;O<x;O+=E)m=u(h,O,O+E,v),this.imuln(A),this.words[0]+m<67108864?this.words[0]+=m:this._iaddn(m);if(N!==0){var z=1;for(m=u(h,O,h.length,v),O=0;O<N;O++)z*=v;this.imuln(z),this.words[0]+m<67108864?this.words[0]+=m:this._iaddn(m)}this.strip()},n.prototype.copy=function(h){h.words=new Array(this.length);for(var v=0;v<this.length;v++)h.words[v]=this.words[v];h.length=this.length,h.negative=this.negative,h.red=this.red},n.prototype.clone=function(){var h=new n(null);return this.copy(h),h},n.prototype._expand=function(h){for(;this.length<h;)this.words[this.length++]=0;return this},n.prototype.strip=function(){for(;this.length>1&&this.words[this.length-1]===0;)this.length--;return this._normSign()},n.prototype._normSign=function(){return this.length===1&&this.words[0]===0&&(this.negative=0),this},n.prototype.inspect=function(){return(this.red?"<BN-R: ":"<BN: ")+this.toString(16)+">"};var c=["","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"],l=[0,0,25,16,12,11,10,9,8,8,7,7,7,7,6,6,6,6,6,6,6,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5],d=[0,0,33554432,43046721,16777216,48828125,60466176,40353607,16777216,43046721,1e7,19487171,35831808,62748517,7529536,11390625,16777216,24137569,34012224,47045881,64e6,4084101,5153632,6436343,7962624,9765625,11881376,14348907,17210368,20511149,243e5,28629151,33554432,39135393,45435424,52521875,60466176];n.prototype.toString=function(h,v){h=h||10,v=v|0||1;var w;if(h===16||h==="hex"){w="";for(var E=0,A=0,L=0;L<this.length;L++){var N=this.words[L],x=((N<<E|A)&16777215).toString(16);A=N>>>24-E&16777215,E+=2,E>=26&&(E-=26,L--),A!==0||L!==this.length-1?w=c[6-x.length]+x+w:w=x+w}for(A!==0&&(w=A.toString(16)+w);w.length%v!==0;)w="0"+w;return this.negative!==0&&(w="-"+w),w}if(h===(h|0)&&h>=2&&h<=36){var m=l[h],O=d[h];w="";var z=this.clone();for(z.negative=0;!z.isZero();){var W=z.modn(O).toString(h);z=z.idivn(O),z.isZero()?w=W+w:w=c[m-W.length]+W+w}for(this.isZero()&&(w="0"+w);w.length%v!==0;)w="0"+w;return this.negative!==0&&(w="-"+w),w}r(!1,"Base should be between 2 and 36")},n.prototype.toNumber=function(){var h=this.words[0];return this.length===2?h+=this.words[1]*67108864:this.length===3&&this.words[2]===1?h+=4503599627370496+this.words[1]*67108864:this.length>2&&r(!1,"Number can only safely store up to 53 bits"),this.negative!==0?-h:h},n.prototype.toJSON=function(){return this.toString(16)},n.prototype.toBuffer=function(h,v){return r(typeof o<"u"),this.toArrayLike(o,h,v)},n.prototype.toArray=function(h,v){return this.toArrayLike(Array,h,v)},n.prototype.toArrayLike=function(h,v,w){var E=this.byteLength(),A=w||Math.max(1,E);r(E<=A,"byte array longer than desired length"),r(A>0,"Requested array length <= 0"),this.strip();var L=v==="le",N=new h(A),x,m,O=this.clone();if(L){for(m=0;!O.isZero();m++)x=O.andln(255),O.iushrn(8),N[m]=x;for(;m<A;m++)N[m]=0}else{for(m=0;m<A-E;m++)N[m]=0;for(m=0;!O.isZero();m++)x=O.andln(255),O.iushrn(8),N[A-m-1]=x}return N},Math.clz32?n.prototype._countBits=function(h){return 32-Math.clz32(h)}:n.prototype._countBits=function(h){var v=h,w=0;return v>=4096&&(w+=13,v>>>=13),v>=64&&(w+=7,v>>>=7),v>=8&&(w+=4,v>>>=4),v>=2&&(w+=2,v>>>=2),w+v},n.prototype._zeroBits=function(h){if(h===0)return 26;var v=h,w=0;return(v&8191)===0&&(w+=13,v>>>=13),(v&127)===0&&(w+=7,v>>>=7),(v&15)===0&&(w+=4,v>>>=4),(v&3)===0&&(w+=2,v>>>=2),(v&1)===0&&w++,w},n.prototype.bitLength=function(){var h=this.words[this.length-1],v=this._countBits(h);return(this.length-1)*26+v};function p(S){for(var h=new Array(S.bitLength()),v=0;v<h.length;v++){var w=v/26|0,E=v%26;h[v]=(S.words[w]&1<<E)>>>E}return h}n.prototype.zeroBits=function(){if(this.isZero())return 0;for(var h=0,v=0;v<this.length;v++){var w=this._zeroBits(this.words[v]);if(h+=w,w!==26)break}return h},n.prototype.byteLength=function(){return Math.ceil(this.bitLength()/8)},n.prototype.toTwos=function(h){return this.negative!==0?this.abs().inotn(h).iaddn(1):this.clone()},n.prototype.fromTwos=function(h){return this.testn(h-1)?this.notn(h).iaddn(1).ineg():this.clone()},n.prototype.isNeg=function(){return this.negative!==0},n.prototype.neg=function(){return this.clone().ineg()},n.prototype.ineg=function(){return this.isZero()||(this.negative^=1),this},n.prototype.iuor=function(h){for(;this.length<h.length;)this.words[this.length++]=0;for(var v=0;v<h.length;v++)this.words[v]=this.words[v]|h.words[v];return this.strip()},n.prototype.ior=function(h){return r((this.negative|h.negative)===0),this.iuor(h)},n.prototype.or=function(h){return this.length>h.length?this.clone().ior(h):h.clone().ior(this)},n.prototype.uor=function(h){return this.length>h.length?this.clone().iuor(h):h.clone().iuor(this)},n.prototype.iuand=function(h){var v;this.length>h.length?v=h:v=this;for(var w=0;w<v.length;w++)this.words[w]=this.words[w]&h.words[w];return this.length=v.length,this.strip()},n.prototype.iand=function(h){return r((this.negative|h.negative)===0),this.iuand(h)},n.prototype.and=function(h){return this.length>h.length?this.clone().iand(h):h.clone().iand(this)},n.prototype.uand=function(h){return this.length>h.length?this.clone().iuand(h):h.clone().iuand(this)},n.prototype.iuxor=function(h){var v,w;this.length>h.length?(v=this,w=h):(v=h,w=this);for(var E=0;E<w.length;E++)this.words[E]=v.words[E]^w.words[E];if(this!==v)for(;E<v.length;E++)this.words[E]=v.words[E];return this.length=v.length,this.strip()},n.prototype.ixor=function(h){return r((this.negative|h.negative)===0),this.iuxor(h)},n.prototype.xor=function(h){return this.length>h.length?this.clone().ixor(h):h.clone().ixor(this)},n.prototype.uxor=function(h){return this.length>h.length?this.clone().iuxor(h):h.clone().iuxor(this)},n.prototype.inotn=function(h){r(typeof h=="number"&&h>=0);var v=Math.ceil(h/26)|0,w=h%26;this._expand(v),w>0&&v--;for(var E=0;E<v;E++)this.words[E]=~this.words[E]&67108863;for(w>0&&(this.words[E]=~this.words[E]&67108863>>26-w,E++);E<this.length;E++)this.words[E]=0;return this.strip()},n.prototype.notn=function(h){return this.clone().inotn(h)},n.prototype.setn=function(h,v){r(typeof h=="number"&&h>=0);var w=h/26|0,E=h%26;return this._expand(w+1),v?this.words[w]=this.words[w]|1<<E:this.words[w]=this.words[w]&~(1<<E),this.strip()},n.prototype.iadd=function(h){var v;if(this.negative!==0&&h.negative===0)return this.negative=0,v=this.isub(h),this.negative^=1,this._normSign();if(this.negative===0&&h.negative!==0)return h.negative=0,v=this.isub(h),h.negative=1,v._normSign();var w,E;this.length>h.length?(w=this,E=h):(w=h,E=this);for(var A=0,L=0;L<E.length;L++)v=(w.words[L]|0)+(E.words[L]|0)+A,this.words[L]=v&67108863,A=v>>>26;for(;A!==0&&L<w.length;L++)v=(w.words[L]|0)+A,this.words[L]=v&67108863,A=v>>>26;if(this.length=w.length,A!==0)this.words[this.length]=A,this.length++;else if(w!==this)for(;L<w.length;L++)this.words[L]=w.words[L];return this},n.prototype.add=function(h){var v;return h.negative!==0&&this.negative===0?(h.negative=0,v=this.sub(h),h.negative^=1,v):h.negative===0&&this.negative!==0?(this.negative=0,v=h.sub(this),this.negative=1,v):this.length>h.length?this.clone().iadd(h):h.clone().iadd(this)},n.prototype.isub=function(h){if(h.negative!==0){h.negative=0;var v=this.iadd(h);return h.negative=1,v._normSign()}else if(this.negative!==0)return this.negative=0,this.iadd(h),this.negative=1,this._normSign();var w=this.cmp(h);if(w===0)return this.negative=0,this.length=1,this.words[0]=0,this;var E,A;w>0?(E=this,A=h):(E=h,A=this);for(var L=0,N=0;N<A.length;N++)v=(E.words[N]|0)-(A.words[N]|0)+L,L=v>>26,this.words[N]=v&67108863;for(;L!==0&&N<E.length;N++)v=(E.words[N]|0)+L,L=v>>26,this.words[N]=v&67108863;if(L===0&&N<E.length&&E!==this)for(;N<E.length;N++)this.words[N]=E.words[N];return this.length=Math.max(this.length,N),E!==this&&(this.negative=1),this.strip()},n.prototype.sub=function(h){return this.clone().isub(h)};function y(S,h,v){v.negative=h.negative^S.negative;var w=S.length+h.length|0;v.length=w,w=w-1|0;var E=S.words[0]|0,A=h.words[0]|0,L=E*A,N=L&67108863,x=L/67108864|0;v.words[0]=N;for(var m=1;m<w;m++){for(var O=x>>>26,z=x&67108863,W=Math.min(m,h.length-1),X=Math.max(0,m-S.length+1);X<=W;X++){var ie=m-X|0;E=S.words[ie]|0,A=h.words[X]|0,L=E*A+z,O+=L/67108864|0,z=L&67108863}v.words[m]=z|0,x=O|0}return x!==0?v.words[m]=x|0:v.length--,v.strip()}var _=function(h,v,w){var E=h.words,A=v.words,L=w.words,N=0,x,m,O,z=E[0]|0,W=z&8191,X=z>>>13,ie=E[1]|0,le=ie&8191,se=ie>>>13,ye=E[2]|0,be=ye&8191,C=ye>>>13,V=E[3]|0,Y=V&8191,Q=V>>>13,he=E[4]|0,ue=he&8191,ce=he>>>13,me=E[5]|0,_e=me&8191,ve=me>>>13,Be=E[6]|0,ge=Be&8191,nt=Be>>>13,xe=E[7]|0,Re=xe&8191,je=xe>>>13,xi=E[8]|0,kt=xi&8191,Et=xi>>>13,ad=E[9]|0,Ft=ad&8191,tr=ad>>>13,oE=A[0]|0,rr=oE&8191,ir=oE>>>13,aE=A[1]|0,nr=aE&8191,or=aE>>>13,sE=A[2]|0,ar=sE&8191,sr=sE>>>13,uE=A[3]|0,ur=uE&8191,cr=uE>>>13,cE=A[4]|0,fr=cE&8191,lr=cE>>>13,fE=A[5]|0,hr=fE&8191,dr=fE>>>13,lE=A[6]|0,pr=lE&8191,gr=lE>>>13,hE=A[7]|0,mr=hE&8191,vr=hE>>>13,dE=A[8]|0,yr=dE&8191,br=dE>>>13,pE=A[9]|0,_r=pE&8191,wr=pE>>>13;w.negative=h.negative^v.negative,w.length=19,x=Math.imul(W,rr),m=Math.imul(W,ir),m=m+Math.imul(X,rr)|0,O=Math.imul(X,ir);var Iv=(N+x|0)+((m&8191)<<13)|0;N=(O+(m>>>13)|0)+(Iv>>>26)|0,Iv&=67108863,x=Math.imul(le,rr),m=Math.imul(le,ir),m=m+Math.imul(se,rr)|0,O=Math.imul(se,ir),x=x+Math.imul(W,nr)|0,m=m+Math.imul(W,or)|0,m=m+Math.imul(X,nr)|0,O=O+Math.imul(X,or)|0;var Av=(N+x|0)+((m&8191)<<13)|0;N=(O+(m>>>13)|0)+(Av>>>26)|0,Av&=67108863,x=Math.imul(be,rr),m=Math.imul(be,ir),m=m+Math.imul(C,rr)|0,O=Math.imul(C,ir),x=x+Math.imul(le,nr)|0,m=m+Math.imul(le,or)|0,m=m+Math.imul(se,nr)|0,O=O+Math.imul(se,or)|0,x=x+Math.imul(W,ar)|0,m=m+Math.imul(W,sr)|0,m=m+Math.imul(X,ar)|0,O=O+Math.imul(X,sr)|0;var Tv=(N+x|0)+((m&8191)<<13)|0;N=(O+(m>>>13)|0)+(Tv>>>26)|0,Tv&=67108863,x=Math.imul(Y,rr),m=Math.imul(Y,ir),m=m+Math.imul(Q,rr)|0,O=Math.imul(Q,ir),x=x+Math.imul(be,nr)|0,m=m+Math.imul(be,or)|0,m=m+Math.imul(C,nr)|0,O=O+Math.imul(C,or)|0,x=x+Math.imul(le,ar)|0,m=m+Math.imul(le,sr)|0,m=m+Math.imul(se,ar)|0,O=O+Math.imul(se,sr)|0,x=x+Math.imul(W,ur)|0,m=m+Math.imul(W,cr)|0,m=m+Math.imul(X,ur)|0,O=O+Math.imul(X,cr)|0;var Pv=(N+x|0)+((m&8191)<<13)|0;N=(O+(m>>>13)|0)+(Pv>>>26)|0,Pv&=67108863,x=Math.imul(ue,rr),m=Math.imul(ue,ir),m=m+Math.imul(ce,rr)|0,O=Math.imul(ce,ir),x=x+Math.imul(Y,nr)|0,m=m+Math.imul(Y,or)|0,m=m+Math.imul(Q,nr)|0,O=O+Math.imul(Q,or)|0,x=x+Math.imul(be,ar)|0,m=m+Math.imul(be,sr)|0,m=m+Math.imul(C,ar)|0,O=O+Math.imul(C,sr)|0,x=x+Math.imul(le,ur)|0,m=m+Math.imul(le,cr)|0,m=m+Math.imul(se,ur)|0,O=O+Math.imul(se,cr)|0,x=x+Math.imul(W,fr)|0,m=m+Math.imul(W,lr)|0,m=m+Math.imul(X,fr)|0,O=O+Math.imul(X,lr)|0;var Rv=(N+x|0)+((m&8191)<<13)|0;N=(O+(m>>>13)|0)+(Rv>>>26)|0,Rv&=67108863,x=Math.imul(_e,rr),m=Math.imul(_e,ir),m=m+Math.imul(ve,rr)|0,O=Math.imul(ve,ir),x=x+Math.imul(ue,nr)|0,m=m+Math.imul(ue,or)|0,m=m+Math.imul(ce,nr)|0,O=O+Math.imul(ce,or)|0,x=x+Math.imul(Y,ar)|0,m=m+Math.imul(Y,sr)|0,m=m+Math.imul(Q,ar)|0,O=O+Math.imul(Q,sr)|0,x=x+Math.imul(be,ur)|0,m=m+Math.imul(be,cr)|0,m=m+Math.imul(C,ur)|0,O=O+Math.imul(C,cr)|0,x=x+Math.imul(le,fr)|0,m=m+Math.imul(le,lr)|0,m=m+Math.imul(se,fr)|0,O=O+Math.imul(se,lr)|0,x=x+Math.imul(W,hr)|0,m=m+Math.imul(W,dr)|0,m=m+Math.imul(X,hr)|0,O=O+Math.imul(X,dr)|0;var kv=(N+x|0)+((m&8191)<<13)|0;N=(O+(m>>>13)|0)+(kv>>>26)|0,kv&=67108863,x=Math.imul(ge,rr),m=Math.imul(ge,ir),m=m+Math.imul(nt,rr)|0,O=Math.imul(nt,ir),x=x+Math.imul(_e,nr)|0,m=m+Math.imul(_e,or)|0,m=m+Math.imul(ve,nr)|0,O=O+Math.imul(ve,or)|0,x=x+Math.imul(ue,ar)|0,m=m+Math.imul(ue,sr)|0,m=m+Math.imul(ce,ar)|0,O=O+Math.imul(ce,sr)|0,x=x+Math.imul(Y,ur)|0,m=m+Math.imul(Y,cr)|0,m=m+Math.imul(Q,ur)|0,O=O+Math.imul(Q,cr)|0,x=x+Math.imul(be,fr)|0,m=m+Math.imul(be,lr)|0,m=m+Math.imul(C,fr)|0,O=O+Math.imul(C,lr)|0,x=x+Math.imul(le,hr)|0,m=m+Math.imul(le,dr)|0,m=m+Math.imul(se,hr)|0,O=O+Math.imul(se,dr)|0,x=x+Math.imul(W,pr)|0,m=m+Math.imul(W,gr)|0,m=m+Math.imul(X,pr)|0,O=O+Math.imul(X,gr)|0;var Bv=(N+x|0)+((m&8191)<<13)|0;N=(O+(m>>>13)|0)+(Bv>>>26)|0,Bv&=67108863,x=Math.imul(Re,rr),m=Math.imul(Re,ir),m=m+Math.imul(je,rr)|0,O=Math.imul(je,ir),x=x+Math.imul(ge,nr)|0,m=m+Math.imul(ge,or)|0,m=m+Math.imul(nt,nr)|0,O=O+Math.imul(nt,or)|0,x=x+Math.imul(_e,ar)|0,m=m+Math.imul(_e,sr)|0,m=m+Math.imul(ve,ar)|0,O=O+Math.imul(ve,sr)|0,x=x+Math.imul(ue,ur)|0,m=m+Math.imul(ue,cr)|0,m=m+Math.imul(ce,ur)|0,O=O+Math.imul(ce,cr)|0,x=x+Math.imul(Y,fr)|0,m=m+Math.imul(Y,lr)|0,m=m+Math.imul(Q,fr)|0,O=O+Math.imul(Q,lr)|0,x=x+Math.imul(be,hr)|0,m=m+Math.imul(be,dr)|0,m=m+Math.imul(C,hr)|0,O=O+Math.imul(C,dr)|0,x=x+Math.imul(le,pr)|0,m=m+Math.imul(le,gr)|0,m=m+Math.imul(se,pr)|0,O=O+Math.imul(se,gr)|0,x=x+Math.imul(W,mr)|0,m=m+Math.imul(W,vr)|0,m=m+Math.imul(X,mr)|0,O=O+Math.imul(X,vr)|0;var Nv=(N+x|0)+((m&8191)<<13)|0;N=(O+(m>>>13)|0)+(Nv>>>26)|0,Nv&=67108863,x=Math.imul(kt,rr),m=Math.imul(kt,ir),m=m+Math.imul(Et,rr)|0,O=Math.imul(Et,ir),x=x+Math.imul(Re,nr)|0,m=m+Math.imul(Re,or)|0,m=m+Math.imul(je,nr)|0,O=O+Math.imul(je,or)|0,x=x+Math.imul(ge,ar)|0,m=m+Math.imul(ge,sr)|0,m=m+Math.imul(nt,ar)|0,O=O+Math.imul(nt,sr)|0,x=x+Math.imul(_e,ur)|0,m=m+Math.imul(_e,cr)|0,m=m+Math.imul(ve,ur)|0,O=O+Math.imul(ve,cr)|0,x=x+Math.imul(ue,fr)|0,m=m+Math.imul(ue,lr)|0,m=m+Math.imul(ce,fr)|0,O=O+Math.imul(ce,lr)|0,x=x+Math.imul(Y,hr)|0,m=m+Math.imul(Y,dr)|0,m=m+Math.imul(Q,hr)|0,O=O+Math.imul(Q,dr)|0,x=x+Math.imul(be,pr)|0,m=m+Math.imul(be,gr)|0,m=m+Math.imul(C,pr)|0,O=O+Math.imul(C,gr)|0,x=x+Math.imul(le,mr)|0,m=m+Math.imul(le,vr)|0,m=m+Math.imul(se,mr)|0,O=O+Math.imul(se,vr)|0,x=x+Math.imul(W,yr)|0,m=m+Math.imul(W,br)|0,m=m+Math.imul(X,yr)|0,O=O+Math.imul(X,br)|0;var Cv=(N+x|0)+((m&8191)<<13)|0;N=(O+(m>>>13)|0)+(Cv>>>26)|0,Cv&=67108863,x=Math.imul(Ft,rr),m=Math.imul(Ft,ir),m=m+Math.imul(tr,rr)|0,O=Math.imul(tr,ir),x=x+Math.imul(kt,nr)|0,m=m+Math.imul(kt,or)|0,m=m+Math.imul(Et,nr)|0,O=O+Math.imul(Et,or)|0,x=x+Math.imul(Re,ar)|0,m=m+Math.imul(Re,sr)|0,m=m+Math.imul(je,ar)|0,O=O+Math.imul(je,sr)|0,x=x+Math.imul(ge,ur)|0,m=m+Math.imul(ge,cr)|0,m=m+Math.imul(nt,ur)|0,O=O+Math.imul(nt,cr)|0,x=x+Math.imul(_e,fr)|0,m=m+Math.imul(_e,lr)|0,m=m+Math.imul(ve,fr)|0,O=O+Math.imul(ve,lr)|0,x=x+Math.imul(ue,hr)|0,m=m+Math.imul(ue,dr)|0,m=m+Math.imul(ce,hr)|0,O=O+Math.imul(ce,dr)|0,x=x+Math.imul(Y,pr)|0,m=m+Math.imul(Y,gr)|0,m=m+Math.imul(Q,pr)|0,O=O+Math.imul(Q,gr)|0,x=x+Math.imul(be,mr)|0,m=m+Math.imul(be,vr)|0,m=m+Math.imul(C,mr)|0,O=O+Math.imul(C,vr)|0,x=x+Math.imul(le,yr)|0,m=m+Math.imul(le,br)|0,m=m+Math.imul(se,yr)|0,O=O+Math.imul(se,br)|0,x=x+Math.imul(W,_r)|0,m=m+Math.imul(W,wr)|0,m=m+Math.imul(X,_r)|0,O=O+Math.imul(X,wr)|0;var Lv=(N+x|0)+((m&8191)<<13)|0;N=(O+(m>>>13)|0)+(Lv>>>26)|0,Lv&=67108863,x=Math.imul(Ft,nr),m=Math.imul(Ft,or),m=m+Math.imul(tr,nr)|0,O=Math.imul(tr,or),x=x+Math.imul(kt,ar)|0,m=m+Math.imul(kt,sr)|0,m=m+Math.imul(Et,ar)|0,O=O+Math.imul(Et,sr)|0,x=x+Math.imul(Re,ur)|0,m=m+Math.imul(Re,cr)|0,m=m+Math.imul(je,ur)|0,O=O+Math.imul(je,cr)|0,x=x+Math.imul(ge,fr)|0,m=m+Math.imul(ge,lr)|0,m=m+Math.imul(nt,fr)|0,O=O+Math.imul(nt,lr)|0,x=x+Math.imul(_e,hr)|0,m=m+Math.imul(_e,dr)|0,m=m+Math.imul(ve,hr)|0,O=O+Math.imul(ve,dr)|0,x=x+Math.imul(ue,pr)|0,m=m+Math.imul(ue,gr)|0,m=m+Math.imul(ce,pr)|0,O=O+Math.imul(ce,gr)|0,x=x+Math.imul(Y,mr)|0,m=m+Math.imul(Y,vr)|0,m=m+Math.imul(Q,mr)|0,O=O+Math.imul(Q,vr)|0,x=x+Math.imul(be,yr)|0,m=m+Math.imul(be,br)|0,m=m+Math.imul(C,yr)|0,O=O+Math.imul(C,br)|0,x=x+Math.imul(le,_r)|0,m=m+Math.imul(le,wr)|0,m=m+Math.imul(se,_r)|0,O=O+Math.imul(se,wr)|0;var Mv=(N+x|0)+((m&8191)<<13)|0;N=(O+(m>>>13)|0)+(Mv>>>26)|0,Mv&=67108863,x=Math.imul(Ft,ar),m=Math.imul(Ft,sr),m=m+Math.imul(tr,ar)|0,O=Math.imul(tr,sr),x=x+Math.imul(kt,ur)|0,m=m+Math.imul(kt,cr)|0,m=m+Math.imul(Et,ur)|0,O=O+Math.imul(Et,cr)|0,x=x+Math.imul(Re,fr)|0,m=m+Math.imul(Re,lr)|0,m=m+Math.imul(je,fr)|0,O=O+Math.imul(je,lr)|0,x=x+Math.imul(ge,hr)|0,m=m+Math.imul(ge,dr)|0,m=m+Math.imul(nt,hr)|0,O=O+Math.imul(nt,dr)|0,x=x+Math.imul(_e,pr)|0,m=m+Math.imul(_e,gr)|0,m=m+Math.imul(ve,pr)|0,O=O+Math.imul(ve,gr)|0,x=x+Math.imul(ue,mr)|0,m=m+Math.imul(ue,vr)|0,m=m+Math.imul(ce,mr)|0,O=O+Math.imul(ce,vr)|0,x=x+Math.imul(Y,yr)|0,m=m+Math.imul(Y,br)|0,m=m+Math.imul(Q,yr)|0,O=O+Math.imul(Q,br)|0,x=x+Math.imul(be,_r)|0,m=m+Math.imul(be,wr)|0,m=m+Math.imul(C,_r)|0,O=O+Math.imul(C,wr)|0;var Dv=(N+x|0)+((m&8191)<<13)|0;N=(O+(m>>>13)|0)+(Dv>>>26)|0,Dv&=67108863,x=Math.imul(Ft,ur),m=Math.imul(Ft,cr),m=m+Math.imul(tr,ur)|0,O=Math.imul(tr,cr),x=x+Math.imul(kt,fr)|0,m=m+Math.imul(kt,lr)|0,m=m+Math.imul(Et,fr)|0,O=O+Math.imul(Et,lr)|0,x=x+Math.imul(Re,hr)|0,m=m+Math.imul(Re,dr)|0,m=m+Math.imul(je,hr)|0,O=O+Math.imul(je,dr)|0,x=x+Math.imul(ge,pr)|0,m=m+Math.imul(ge,gr)|0,m=m+Math.imul(nt,pr)|0,O=O+Math.imul(nt,gr)|0,x=x+Math.imul(_e,mr)|0,m=m+Math.imul(_e,vr)|0,m=m+Math.imul(ve,mr)|0,O=O+Math.imul(ve,vr)|0,x=x+Math.imul(ue,yr)|0,m=m+Math.imul(ue,br)|0,m=m+Math.imul(ce,yr)|0,O=O+Math.imul(ce,br)|0,x=x+Math.imul(Y,_r)|0,m=m+Math.imul(Y,wr)|0,m=m+Math.imul(Q,_r)|0,O=O+Math.imul(Q,wr)|0;var qv=(N+x|0)+((m&8191)<<13)|0;N=(O+(m>>>13)|0)+(qv>>>26)|0,qv&=67108863,x=Math.imul(Ft,fr),m=Math.imul(Ft,lr),m=m+Math.imul(tr,fr)|0,O=Math.imul(tr,lr),x=x+Math.imul(kt,hr)|0,m=m+Math.imul(kt,dr)|0,m=m+Math.imul(Et,hr)|0,O=O+Math.imul(Et,dr)|0,x=x+Math.imul(Re,pr)|0,m=m+Math.imul(Re,gr)|0,m=m+Math.imul(je,pr)|0,O=O+Math.imul(je,gr)|0,x=x+Math.imul(ge,mr)|0,m=m+Math.imul(ge,vr)|0,m=m+Math.imul(nt,mr)|0,O=O+Math.imul(nt,vr)|0,x=x+Math.imul(_e,yr)|0,m=m+Math.imul(_e,br)|0,m=m+Math.imul(ve,yr)|0,O=O+Math.imul(ve,br)|0,x=x+Math.imul(ue,_r)|0,m=m+Math.imul(ue,wr)|0,m=m+Math.imul(ce,_r)|0,O=O+Math.imul(ce,wr)|0;var Hv=(N+x|0)+((m&8191)<<13)|0;N=(O+(m>>>13)|0)+(Hv>>>26)|0,Hv&=67108863,x=Math.imul(Ft,hr),m=Math.imul(Ft,dr),m=m+Math.imul(tr,hr)|0,O=Math.imul(tr,dr),x=x+Math.imul(kt,pr)|0,m=m+Math.imul(kt,gr)|0,m=m+Math.imul(Et,pr)|0,O=O+Math.imul(Et,gr)|0,x=x+Math.imul(Re,mr)|0,m=m+Math.imul(Re,vr)|0,m=m+Math.imul(je,mr)|0,O=O+Math.imul(je,vr)|0,x=x+Math.imul(ge,yr)|0,m=m+Math.imul(ge,br)|0,m=m+Math.imul(nt,yr)|0,O=O+Math.imul(nt,br)|0,x=x+Math.imul(_e,_r)|0,m=m+Math.imul(_e,wr)|0,m=m+Math.imul(ve,_r)|0,O=O+Math.imul(ve,wr)|0;var Uv=(N+x|0)+((m&8191)<<13)|0;N=(O+(m>>>13)|0)+(Uv>>>26)|0,Uv&=67108863,x=Math.imul(Ft,pr),m=Math.imul(Ft,gr),m=m+Math.imul(tr,pr)|0,O=Math.imul(tr,gr),x=x+Math.imul(kt,mr)|0,m=m+Math.imul(kt,vr)|0,m=m+Math.imul(Et,mr)|0,O=O+Math.imul(Et,vr)|0,x=x+Math.imul(Re,yr)|0,m=m+Math.imul(Re,br)|0,m=m+Math.imul(je,yr)|0,O=O+Math.imul(je,br)|0,x=x+Math.imul(ge,_r)|0,m=m+Math.imul(ge,wr)|0,m=m+Math.imul(nt,_r)|0,O=O+Math.imul(nt,wr)|0;var Fv=(N+x|0)+((m&8191)<<13)|0;N=(O+(m>>>13)|0)+(Fv>>>26)|0,Fv&=67108863,x=Math.imul(Ft,mr),m=Math.imul(Ft,vr),m=m+Math.imul(tr,mr)|0,O=Math.imul(tr,vr),x=x+Math.imul(kt,yr)|0,m=m+Math.imul(kt,br)|0,m=m+Math.imul(Et,yr)|0,O=O+Math.imul(Et,br)|0,x=x+Math.imul(Re,_r)|0,m=m+Math.imul(Re,wr)|0,m=m+Math.imul(je,_r)|0,O=O+Math.imul(je,wr)|0;var jv=(N+x|0)+((m&8191)<<13)|0;N=(O+(m>>>13)|0)+(jv>>>26)|0,jv&=67108863,x=Math.imul(Ft,yr),m=Math.imul(Ft,br),m=m+Math.imul(tr,yr)|0,O=Math.imul(tr,br),x=x+Math.imul(kt,_r)|0,m=m+Math.imul(kt,wr)|0,m=m+Math.imul(Et,_r)|0,O=O+Math.imul(Et,wr)|0;var zv=(N+x|0)+((m&8191)<<13)|0;N=(O+(m>>>13)|0)+(zv>>>26)|0,zv&=67108863,x=Math.imul(Ft,_r),m=Math.imul(Ft,wr),m=m+Math.imul(tr,_r)|0,O=Math.imul(tr,wr);var Kv=(N+x|0)+((m&8191)<<13)|0;return N=(O+(m>>>13)|0)+(Kv>>>26)|0,Kv&=67108863,L[0]=Iv,L[1]=Av,L[2]=Tv,L[3]=Pv,L[4]=Rv,L[5]=kv,L[6]=Bv,L[7]=Nv,L[8]=Cv,L[9]=Lv,L[10]=Mv,L[11]=Dv,L[12]=qv,L[13]=Hv,L[14]=Uv,L[15]=Fv,L[16]=jv,L[17]=zv,L[18]=Kv,N!==0&&(L[19]=N,w.length++),w};Math.imul||(_=y);function T(S,h,v){v.negative=h.negative^S.negative,v.length=S.length+h.length;for(var w=0,E=0,A=0;A<v.length-1;A++){var L=E;E=0;for(var N=w&67108863,x=Math.min(A,h.length-1),m=Math.max(0,A-S.length+1);m<=x;m++){var O=A-m,z=S.words[O]|0,W=h.words[m]|0,X=z*W,ie=X&67108863;L=L+(X/67108864|0)|0,ie=ie+N|0,N=ie&67108863,L=L+(ie>>>26)|0,E+=L>>>26,L&=67108863}v.words[A]=N,w=L,L=E}return w!==0?v.words[A]=w:v.length--,v.strip()}function R(S,h,v){var w=new B;return w.mulp(S,h,v)}n.prototype.mulTo=function(h,v){var w,E=this.length+h.length;return this.length===10&&h.length===10?w=_(this,h,v):E<63?w=y(this,h,v):E<1024?w=T(this,h,v):w=R(this,h,v),w};function B(S,h){this.x=S,this.y=h}B.prototype.makeRBT=function(h){for(var v=new Array(h),w=n.prototype._countBits(h)-1,E=0;E<h;E++)v[E]=this.revBin(E,w,h);return v},B.prototype.revBin=function(h,v,w){if(h===0||h===w-1)return h;for(var E=0,A=0;A<v;A++)E|=(h&1)<<v-A-1,h>>=1;return E},B.prototype.permute=function(h,v,w,E,A,L){for(var N=0;N<L;N++)E[N]=v[h[N]],A[N]=w[h[N]]},B.prototype.transform=function(h,v,w,E,A,L){this.permute(L,h,v,w,E,A);for(var N=1;N<A;N<<=1)for(var x=N<<1,m=Math.cos(2*Math.PI/x),O=Math.sin(2*Math.PI/x),z=0;z<A;z+=x)for(var W=m,X=O,ie=0;ie<N;ie++){var le=w[z+ie],se=E[z+ie],ye=w[z+ie+N],be=E[z+ie+N],C=W*ye-X*be;be=W*be+X*ye,ye=C,w[z+ie]=le+ye,E[z+ie]=se+be,w[z+ie+N]=le-ye,E[z+ie+N]=se-be,ie!==x&&(C=m*W-O*X,X=m*X+O*W,W=C)}},B.prototype.guessLen13b=function(h,v){var w=Math.max(v,h)|1,E=w&1,A=0;for(w=w/2|0;w;w=w>>>1)A++;return 1<<A+1+E},B.prototype.conjugate=function(h,v,w){if(!(w<=1))for(var E=0;E<w/2;E++){var A=h[E];h[E]=h[w-E-1],h[w-E-1]=A,A=v[E],v[E]=-v[w-E-1],v[w-E-1]=-A}},B.prototype.normalize13b=function(h,v){for(var w=0,E=0;E<v/2;E++){var A=Math.round(h[2*E+1]/v)*8192+Math.round(h[2*E]/v)+w;h[E]=A&67108863,A<67108864?w=0:w=A/67108864|0}return h},B.prototype.convert13b=function(h,v,w,E){for(var A=0,L=0;L<v;L++)A=A+(h[L]|0),w[2*L]=A&8191,A=A>>>13,w[2*L+1]=A&8191,A=A>>>13;for(L=2*v;L<E;++L)w[L]=0;r(A===0),r((A&-8192)===0)},B.prototype.stub=function(h){for(var v=new Array(h),w=0;w<h;w++)v[w]=0;return v},B.prototype.mulp=function(h,v,w){var E=2*this.guessLen13b(h.length,v.length),A=this.makeRBT(E),L=this.stub(E),N=new Array(E),x=new Array(E),m=new Array(E),O=new Array(E),z=new Array(E),W=new Array(E),X=w.words;X.length=E,this.convert13b(h.words,h.length,N,E),this.convert13b(v.words,v.length,O,E),this.transform(N,L,x,m,E,A),this.transform(O,L,z,W,E,A);for(var ie=0;ie<E;ie++){var le=x[ie]*z[ie]-m[ie]*W[ie];m[ie]=x[ie]*W[ie]+m[ie]*z[ie],x[ie]=le}return this.conjugate(x,m,E),this.transform(x,m,X,L,E,A),this.conjugate(X,L,E),this.normalize13b(X,E),w.negative=h.negative^v.negative,w.length=h.length+v.length,w.strip()},n.prototype.mul=function(h){var v=new n(null);return v.words=new Array(this.length+h.length),this.mulTo(h,v)},n.prototype.mulf=function(h){var v=new n(null);return v.words=new Array(this.length+h.length),R(this,h,v)},n.prototype.imul=function(h){return this.clone().mulTo(h,this)},n.prototype.imuln=function(h){r(typeof h=="number"),r(h<67108864);for(var v=0,w=0;w<this.length;w++){var E=(this.words[w]|0)*h,A=(E&67108863)+(v&67108863);v>>=26,v+=E/67108864|0,v+=A>>>26,this.words[w]=A&67108863}return v!==0&&(this.words[w]=v,this.length++),h===0&&(this.length=1,this._normSign()),this},n.prototype.muln=function(h){return this.clone().imuln(h)},n.prototype.sqr=function(){return this.mul(this)},n.prototype.isqr=function(){return this.imul(this.clone())},n.prototype.pow=function(h){var v=p(h);if(v.length===0)return new n(1);for(var w=this,E=0;E<v.length&&v[E]===0;E++,w=w.sqr());if(++E<v.length)for(var A=w.sqr();E<v.length;E++,A=A.sqr())v[E]!==0&&(w=w.mul(A));return w},n.prototype.iushln=function(h){r(typeof h=="number"&&h>=0);var v=h%26,w=(h-v)/26,E=67108863>>>26-v<<26-v,A;if(v!==0){var L=0;for(A=0;A<this.length;A++){var N=this.words[A]&E,x=(this.words[A]|0)-N<<v;this.words[A]=x|L,L=N>>>26-v}L&&(this.words[A]=L,this.length++)}if(w!==0){for(A=this.length-1;A>=0;A--)this.words[A+w]=this.words[A];for(A=0;A<w;A++)this.words[A]=0;this.length+=w}return this.strip()},n.prototype.ishln=function(h){return r(this.negative===0),this.iushln(h)},n.prototype.iushrn=function(h,v,w){r(typeof h=="number"&&h>=0);var E;v?E=(v-v%26)/26:E=0;var A=h%26,L=Math.min((h-A)/26,this.length),N=67108863^67108863>>>A<<A,x=w;if(E-=L,E=Math.max(0,E),x){for(var m=0;m<L;m++)x.words[m]=this.words[m];x.length=L}if(L!==0)if(this.length>L)for(this.length-=L,m=0;m<this.length;m++)this.words[m]=this.words[m+L];else this.words[0]=0,this.length=1;var O=0;for(m=this.length-1;m>=0&&(O!==0||m>=E);m--){var z=this.words[m]|0;this.words[m]=O<<26-A|z>>>A,O=z&N}return x&&O!==0&&(x.words[x.length++]=O),this.length===0&&(this.words[0]=0,this.length=1),this.strip()},n.prototype.ishrn=function(h,v,w){return r(this.negative===0),this.iushrn(h,v,w)},n.prototype.shln=function(h){return this.clone().ishln(h)},n.prototype.ushln=function(h){return this.clone().iushln(h)},n.prototype.shrn=function(h){return this.clone().ishrn(h)},n.prototype.ushrn=function(h){return this.clone().iushrn(h)},n.prototype.testn=function(h){r(typeof h=="number"&&h>=0);var v=h%26,w=(h-v)/26,E=1<<v;if(this.length<=w)return!1;var A=this.words[w];return!!(A&E)},n.prototype.imaskn=function(h){r(typeof h=="number"&&h>=0);var v=h%26,w=(h-v)/26;if(r(this.negative===0,"imaskn works only with positive numbers"),this.length<=w)return this;if(v!==0&&w++,this.length=Math.min(w,this.length),v!==0){var E=67108863^67108863>>>v<<v;this.words[this.length-1]&=E}return this.length===0&&(this.words[0]=0,this.length=1),this.strip()},n.prototype.maskn=function(h){return this.clone().imaskn(h)},n.prototype.iaddn=function(h){return r(typeof h=="number"),r(h<67108864),h<0?this.isubn(-h):this.negative!==0?this.length===1&&(this.words[0]|0)<h?(this.words[0]=h-(this.words[0]|0),this.negative=0,this):(this.negative=0,this.isubn(h),this.negative=1,this):this._iaddn(h)},n.prototype._iaddn=function(h){this.words[0]+=h;for(var v=0;v<this.length&&this.words[v]>=67108864;v++)this.words[v]-=67108864,v===this.length-1?this.words[v+1]=1:this.words[v+1]++;return this.length=Math.max(this.length,v+1),this},n.prototype.isubn=function(h){if(r(typeof h=="number"),r(h<67108864),h<0)return this.iaddn(-h);if(this.negative!==0)return this.negative=0,this.iaddn(h),this.negative=1,this;if(this.words[0]-=h,this.length===1&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var v=0;v<this.length&&this.words[v]<0;v++)this.words[v]+=67108864,this.words[v+1]-=1;return this.strip()},n.prototype.addn=function(h){return this.clone().iaddn(h)},n.prototype.subn=function(h){return this.clone().isubn(h)},n.prototype.iabs=function(){return this.negative=0,this},n.prototype.abs=function(){return this.clone().iabs()},n.prototype._ishlnsubmul=function(h,v,w){var E=h.length+w,A;this._expand(E);var L,N=0;for(A=0;A<h.length;A++){L=(this.words[A+w]|0)+N;var x=(h.words[A]|0)*v;L-=x&67108863,N=(L>>26)-(x/67108864|0),this.words[A+w]=L&67108863}for(;A<this.length-w;A++)L=(this.words[A+w]|0)+N,N=L>>26,this.words[A+w]=L&67108863;if(N===0)return this.strip();for(r(N===-1),N=0,A=0;A<this.length;A++)L=-(this.words[A]|0)+N,N=L>>26,this.words[A]=L&67108863;return this.negative=1,this.strip()},n.prototype._wordDiv=function(h,v){var w=this.length-h.length,E=this.clone(),A=h,L=A.words[A.length-1]|0,N=this._countBits(L);w=26-N,w!==0&&(A=A.ushln(w),E.iushln(w),L=A.words[A.length-1]|0);var x=E.length-A.length,m;if(v!=="mod"){m=new n(null),m.length=x+1,m.words=new Array(m.length);for(var O=0;O<m.length;O++)m.words[O]=0}var z=E.clone()._ishlnsubmul(A,1,x);z.negative===0&&(E=z,m&&(m.words[x]=1));for(var W=x-1;W>=0;W--){var X=(E.words[A.length+W]|0)*67108864+(E.words[A.length+W-1]|0);for(X=Math.min(X/L|0,67108863),E._ishlnsubmul(A,X,W);E.negative!==0;)X--,E.negative=0,E._ishlnsubmul(A,1,W),E.isZero()||(E.negative^=1);m&&(m.words[W]=X)}return m&&m.strip(),E.strip(),v!=="div"&&w!==0&&E.iushrn(w),{div:m||null,mod:E}},n.prototype.divmod=function(h,v,w){if(r(!h.isZero()),this.isZero())return{div:new n(0),mod:new n(0)};var E,A,L;return this.negative!==0&&h.negative===0?(L=this.neg().divmod(h,v),v!=="mod"&&(E=L.div.neg()),v!=="div"&&(A=L.mod.neg(),w&&A.negative!==0&&A.iadd(h)),{div:E,mod:A}):this.negative===0&&h.negative!==0?(L=this.divmod(h.neg(),v),v!=="mod"&&(E=L.div.neg()),{div:E,mod:L.mod}):(this.negative&h.negative)!==0?(L=this.neg().divmod(h.neg(),v),v!=="div"&&(A=L.mod.neg(),w&&A.negative!==0&&A.isub(h)),{div:L.div,mod:A}):h.length>this.length||this.cmp(h)<0?{div:new n(0),mod:this}:h.length===1?v==="div"?{div:this.divn(h.words[0]),mod:null}:v==="mod"?{div:null,mod:new n(this.modn(h.words[0]))}:{div:this.divn(h.words[0]),mod:new n(this.modn(h.words[0]))}:this._wordDiv(h,v)},n.prototype.div=function(h){return this.divmod(h,"div",!1).div},n.prototype.mod=function(h){return this.divmod(h,"mod",!1).mod},n.prototype.umod=function(h){return this.divmod(h,"mod",!0).mod},n.prototype.divRound=function(h){var v=this.divmod(h);if(v.mod.isZero())return v.div;var w=v.mod.abs(),E=h.abs().iushrn(1),A=h.words[0]&1,L=w.cmp(E);if(L<0||A===1&&L===0)return v.div;var N=new n(1);return N.negative=this.negative^h.negative,v.div.iadd(N)},n.prototype.modn=function(h){r(h<=67108863);for(var v=(1<<26)%h,w=0,E=this.length-1;E>=0;E--)w=(v*w+(this.words[E]|0))%h;return w},n.prototype.idivn=function(h){r(h<=67108863);for(var v=0,w=this.length-1;w>=0;w--){var E=(this.words[w]|0)+v*67108864;this.words[w]=E/h|0,v=E%h}return this.strip()},n.prototype.divn=function(h){return this.clone().idivn(h)},n.prototype.egcd=function(h){r(h.negative===0),r(!h.isZero());var v=this,w=h.clone();v.negative!==0?v=v.umod(h):v=v.clone();for(var E=new n(1),A=new n(0),L=new n(0),N=new n(1),x=0;v.isEven()&&w.isEven();)v.iushrn(1),w.iushrn(1),++x;for(var m=w.clone(),O=v.clone();!v.isZero();){for(var z=0,W=1;(v.words[0]&W)===0&&z<26;++z,W<<=1);if(z>0)for(v.iushrn(z);z-- >0;)(E.isOdd()||A.isOdd())&&(E.iadd(m),A.isub(O)),E.iushrn(1),A.iushrn(1);for(var X=0,ie=1;(w.words[0]&ie)===0&&X<26;++X,ie<<=1);if(X>0)for(w.iushrn(X);X-- >0;)(L.isOdd()||N.isOdd())&&(L.iadd(m),N.isub(O)),L.iushrn(1),N.iushrn(1);v.cmp(w)>=0?(v.isub(w),E.isub(L),A.isub(N)):(w.isub(v),L.isub(E),N.isub(A))}return{a:L,b:N,gcd:w.iushln(x)}},n.prototype._invmp=function(h){r(h.negative===0),r(!h.isZero());var v=this,w=h.clone();v.negative!==0?v=v.umod(h):v=v.clone();for(var E=new n(1),A=new n(0),L=w.clone();v.cmpn(1)>0&&w.cmpn(1)>0;){for(var N=0,x=1;(v.words[0]&x)===0&&N<26;++N,x<<=1);if(N>0)for(v.iushrn(N);N-- >0;)E.isOdd()&&E.iadd(L),E.iushrn(1);for(var m=0,O=1;(w.words[0]&O)===0&&m<26;++m,O<<=1);if(m>0)for(w.iushrn(m);m-- >0;)A.isOdd()&&A.iadd(L),A.iushrn(1);v.cmp(w)>=0?(v.isub(w),E.isub(A)):(w.isub(v),A.isub(E))}var z;return v.cmpn(1)===0?z=E:z=A,z.cmpn(0)<0&&z.iadd(h),z},n.prototype.gcd=function(h){if(this.isZero())return h.abs();if(h.isZero())return this.abs();var v=this.clone(),w=h.clone();v.negative=0,w.negative=0;for(var E=0;v.isEven()&&w.isEven();E++)v.iushrn(1),w.iushrn(1);do{for(;v.isEven();)v.iushrn(1);for(;w.isEven();)w.iushrn(1);var A=v.cmp(w);if(A<0){var L=v;v=w,w=L}else if(A===0||w.cmpn(1)===0)break;v.isub(w)}while(!0);return w.iushln(E)},n.prototype.invm=function(h){return this.egcd(h).a.umod(h)},n.prototype.isEven=function(){return(this.words[0]&1)===0},n.prototype.isOdd=function(){return(this.words[0]&1)===1},n.prototype.andln=function(h){return this.words[0]&h},n.prototype.bincn=function(h){r(typeof h=="number");var v=h%26,w=(h-v)/26,E=1<<v;if(this.length<=w)return this._expand(w+1),this.words[w]|=E,this;for(var A=E,L=w;A!==0&&L<this.length;L++){var N=this.words[L]|0;N+=A,A=N>>>26,N&=67108863,this.words[L]=N}return A!==0&&(this.words[L]=A,this.length++),this},n.prototype.isZero=function(){return this.length===1&&this.words[0]===0},n.prototype.cmpn=function(h){var v=h<0;if(this.negative!==0&&!v)return-1;if(this.negative===0&&v)return 1;this.strip();var w;if(this.length>1)w=1;else{v&&(h=-h),r(h<=67108863,"Number is too big");var E=this.words[0]|0;w=E===h?0:E<h?-1:1}return this.negative!==0?-w|0:w},n.prototype.cmp=function(h){if(this.negative!==0&&h.negative===0)return-1;if(this.negative===0&&h.negative!==0)return 1;var v=this.ucmp(h);return this.negative!==0?-v|0:v},n.prototype.ucmp=function(h){if(this.length>h.length)return 1;if(this.length<h.length)return-1;for(var v=0,w=this.length-1;w>=0;w--){var E=this.words[w]|0,A=h.words[w]|0;if(E!==A){E<A?v=-1:E>A&&(v=1);break}}return v},n.prototype.gtn=function(h){return this.cmpn(h)===1},n.prototype.gt=function(h){return this.cmp(h)===1},n.prototype.gten=function(h){return this.cmpn(h)>=0},n.prototype.gte=function(h){return this.cmp(h)>=0},n.prototype.ltn=function(h){return this.cmpn(h)===-1},n.prototype.lt=function(h){return this.cmp(h)===-1},n.prototype.lten=function(h){return this.cmpn(h)<=0},n.prototype.lte=function(h){return this.cmp(h)<=0},n.prototype.eqn=function(h){return this.cmpn(h)===0},n.prototype.eq=function(h){return this.cmp(h)===0},n.red=function(h){return new K(h)},n.prototype.toRed=function(h){return r(!this.red,"Already a number in reduction context"),r(this.negative===0,"red works only with positives"),h.convertTo(this)._forceRed(h)},n.prototype.fromRed=function(){return r(this.red,"fromRed works only with numbers in reduction context"),this.red.convertFrom(this)},n.prototype._forceRed=function(h){return this.red=h,this},n.prototype.forceRed=function(h){return r(!this.red,"Already a number in reduction context"),this._forceRed(h)},n.prototype.redAdd=function(h){return r(this.red,"redAdd works only with red numbers"),this.red.add(this,h)},n.prototype.redIAdd=function(h){return r(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,h)},n.prototype.redSub=function(h){return r(this.red,"redSub works only with red numbers"),this.red.sub(this,h)},n.prototype.redISub=function(h){return r(this.red,"redISub works only with red numbers"),this.red.isub(this,h)},n.prototype.redShl=function(h){return r(this.red,"redShl works only with red numbers"),this.red.shl(this,h)},n.prototype.redMul=function(h){return r(this.red,"redMul works only with red numbers"),this.red._verify2(this,h),this.red.mul(this,h)},n.prototype.redIMul=function(h){return r(this.red,"redMul works only with red numbers"),this.red._verify2(this,h),this.red.imul(this,h)},n.prototype.redSqr=function(){return r(this.red,"redSqr works only with red numbers"),this.red._verify1(this),this.red.sqr(this)},n.prototype.redISqr=function(){return r(this.red,"redISqr works only with red numbers"),this.red._verify1(this),this.red.isqr(this)},n.prototype.redSqrt=function(){return r(this.red,"redSqrt works only with red numbers"),this.red._verify1(this),this.red.sqrt(this)},n.prototype.redInvm=function(){return r(this.red,"redInvm works only with red numbers"),this.red._verify1(this),this.red.invm(this)},n.prototype.redNeg=function(){return r(this.red,"redNeg works only with red numbers"),this.red._verify1(this),this.red.neg(this)},n.prototype.redPow=function(h){return r(this.red&&!h.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,h)};var H={k256:null,p224:null,p192:null,p25519:null};function j(S,h){this.name=S,this.p=new n(h,16),this.n=this.p.bitLength(),this.k=new n(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}j.prototype._tmp=function(){var h=new n(null);return h.words=new Array(Math.ceil(this.n/13)),h},j.prototype.ireduce=function(h){var v=h,w;do this.split(v,this.tmp),v=this.imulK(v),v=v.iadd(this.tmp),w=v.bitLength();while(w>this.n);var E=w<this.n?-1:v.ucmp(this.p);return E===0?(v.words[0]=0,v.length=1):E>0?v.isub(this.p):v.strip!==void 0?v.strip():v._strip(),v},j.prototype.split=function(h,v){h.iushrn(this.n,0,v)},j.prototype.imulK=function(h){return h.imul(this.k)};function I(){j.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}i(I,j),I.prototype.split=function(h,v){for(var w=4194303,E=Math.min(h.length,9),A=0;A<E;A++)v.words[A]=h.words[A];if(v.length=E,h.length<=9){h.words[0]=0,h.length=1;return}var L=h.words[9];for(v.words[v.length++]=L&w,A=10;A<h.length;A++){var N=h.words[A]|0;h.words[A-10]=(N&w)<<4|L>>>22,L=N}L>>>=22,h.words[A-10]=L,L===0&&h.length>10?h.length-=10:h.length-=9},I.prototype.imulK=function(h){h.words[h.length]=0,h.words[h.length+1]=0,h.length+=2;for(var v=0,w=0;w<h.length;w++){var E=h.words[w]|0;v+=E*977,h.words[w]=v&67108863,v=E*64+(v/67108864|0)}return h.words[h.length-1]===0&&(h.length--,h.words[h.length-1]===0&&h.length--),h};function k(){j.call(this,"p224","ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001")}i(k,j);function D(){j.call(this,"p192","ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff")}i(D,j);function F(){j.call(this,"25519","7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed")}i(F,j),F.prototype.imulK=function(h){for(var v=0,w=0;w<h.length;w++){var E=(h.words[w]|0)*19+v,A=E&67108863;E>>>=26,h.words[w]=A,v=E}return v!==0&&(h.words[h.length++]=v),h},n._prime=function(h){if(H[h])return H[h];var v;if(h==="k256")v=new I;else if(h==="p224")v=new k;else if(h==="p192")v=new D;else if(h==="p25519")v=new F;else throw new Error("Unknown prime "+h);return H[h]=v,v};function K(S){if(typeof S=="string"){var h=n._prime(S);this.m=h.p,this.prime=h}else r(S.gtn(1),"modulus must be greater than 1"),this.m=S,this.prime=null}K.prototype._verify1=function(h){r(h.negative===0,"red works only with positives"),r(h.red,"red works only with red numbers")},K.prototype._verify2=function(h,v){r((h.negative|v.negative)===0,"red works only with positives"),r(h.red&&h.red===v.red,"red works only with red numbers")},K.prototype.imod=function(h){return this.prime?this.prime.ireduce(h)._forceRed(this):h.umod(this.m)._forceRed(this)},K.prototype.neg=function(h){return h.isZero()?h.clone():this.m.sub(h)._forceRed(this)},K.prototype.add=function(h,v){this._verify2(h,v);var w=h.add(v);return w.cmp(this.m)>=0&&w.isub(this.m),w._forceRed(this)},K.prototype.iadd=function(h,v){this._verify2(h,v);var w=h.iadd(v);return w.cmp(this.m)>=0&&w.isub(this.m),w},K.prototype.sub=function(h,v){this._verify2(h,v);var w=h.sub(v);return w.cmpn(0)<0&&w.iadd(this.m),w._forceRed(this)},K.prototype.isub=function(h,v){this._verify2(h,v);var w=h.isub(v);return w.cmpn(0)<0&&w.iadd(this.m),w},K.prototype.shl=function(h,v){return this._verify1(h),this.imod(h.ushln(v))},K.prototype.imul=function(h,v){return this._verify2(h,v),this.imod(h.imul(v))},K.prototype.mul=function(h,v){return this._verify2(h,v),this.imod(h.mul(v))},K.prototype.isqr=function(h){return this.imul(h,h.clone())},K.prototype.sqr=function(h){return this.mul(h,h)},K.prototype.sqrt=function(h){if(h.isZero())return h.clone();var v=this.m.andln(3);if(r(v%2===1),v===3){var w=this.m.add(new n(1)).iushrn(2);return this.pow(h,w)}for(var E=this.m.subn(1),A=0;!E.isZero()&&E.andln(1)===0;)A++,E.iushrn(1);r(!E.isZero());var L=new n(1).toRed(this),N=L.redNeg(),x=this.m.subn(1).iushrn(1),m=this.m.bitLength();for(m=new n(2*m*m).toRed(this);this.pow(m,x).cmp(N)!==0;)m.redIAdd(N);for(var O=this.pow(m,E),z=this.pow(h,E.addn(1).iushrn(1)),W=this.pow(h,E),X=A;W.cmp(L)!==0;){for(var ie=W,le=0;ie.cmp(L)!==0;le++)ie=ie.redSqr();r(le<X);var se=this.pow(O,new n(1).iushln(X-le-1));z=z.redMul(se),O=se.redSqr(),W=W.redMul(O),X=le}return z},K.prototype.invm=function(h){var v=h._invmp(this.m);return v.negative!==0?(v.negative=0,this.imod(v).redNeg()):this.imod(v)},K.prototype.pow=function(h,v){if(v.isZero())return new n(1).toRed(this);if(v.cmpn(1)===0)return h.clone();var w=4,E=new Array(1<<w);E[0]=new n(1).toRed(this),E[1]=h;for(var A=2;A<E.length;A++)E[A]=this.mul(E[A-1],h);var L=E[0],N=0,x=0,m=v.bitLength()%26;for(m===0&&(m=26),A=v.length-1;A>=0;A--){for(var O=v.words[A],z=m-1;z>=0;z--){var W=O>>z&1;if(L!==E[0]&&(L=this.sqr(L)),W===0&&N===0){x=0;continue}N<<=1,N|=W,x++,!(x!==w&&(A!==0||z!==0))&&(L=this.mul(L,E[N]),x=0,N=0)}m=26}return L},K.prototype.convertTo=function(h){var v=h.umod(this.m);return v===h?v.clone():v},K.prototype.convertFrom=function(h){var v=h.clone();return v.red=null,v},n.mont=function(h){return new G(h)};function G(S){K.call(this,S),this.shift=this.m.bitLength(),this.shift%26!==0&&(this.shift+=26-this.shift%26),this.r=new n(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)}i(G,K),G.prototype.convertTo=function(h){return this.imod(h.ushln(this.shift))},G.prototype.convertFrom=function(h){var v=this.imod(h.mul(this.rinv));return v.red=null,v},G.prototype.imul=function(h,v){if(h.isZero()||v.isZero())return h.words[0]=0,h.length=1,h;var w=h.imul(v),E=w.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),A=w.isub(E).iushrn(this.shift),L=A;return A.cmp(this.m)>=0?L=A.isub(this.m):A.cmpn(0)<0&&(L=A.iadd(this.m)),L._forceRed(this)},G.prototype.mul=function(h,v){if(h.isZero()||v.isZero())return new n(0)._forceRed(this);var w=h.mul(v),E=w.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),A=w.isub(E).iushrn(this.shift),L=A;return A.cmp(this.m)>=0?L=A.isub(this.m):A.cmpn(0)<0&&(L=A.iadd(this.m)),L._forceRed(this)},G.prototype.invm=function(h){var v=this.imod(h._invmp(this.m).mul(this.r2));return v._forceRed(this)}})(typeof Fy>"u"||Fy,PT)});var jy=P((fne,RT)=>{"use strict";g();RT.exports="9.11.2"});var BT=P((hne,kT)=>{"use strict";g();var Uz="https://docs.moneybutton.com/";kT.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: "+Uz+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 ci=P((pne,Ky)=>{"use strict";g();var zy=Je();function Fz(e,t){return e.replace("{0}",t[0]).replace("{1}",t[1]).replace("{2}",t[2])}var NT=function(e,t){var r=function(){if(zy.isString(t.message))this.message=Fz(t.message,arguments);else if(zy.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&&CT(r,t.errors),r},CT=function(e,t){zy.each(t,function(r){NT(e,r)})},jz=function(e,t){return CT(e,t),e},sc={};sc.Error=function(){this.message="Internal error",this.stack=this.message+`
13
13
  `+new Error().stack};sc.Error.prototype=Object.create(Error.prototype);sc.Error.prototype.name="bsv.Error";var zz=BT();jz(sc.Error,zz);Ky.exports=sc.Error;Ky.exports.extend=function(e){return NT(sc.Error,e)}});var Oe=P((mne,LT)=>{"use strict";g();var pl=ci(),Kz=Je();LT.exports={checkState:function(e,t){if(!e)throw new pl.InvalidState(t)},checkArgument:function(e,t,r,i){if(!e)throw new pl.InvalidArgument(t,r,i)},checkArgumentType:function(e,t,r){if(r=r||"(unknown name)",Kz.isString(t)){if(t==="Buffer"){var i=jt();if(!i.Buffer.isBuffer(e))throw new pl.InvalidArgumentType(e,t,r)}else if(typeof e!==t)throw new pl.InvalidArgumentType(e,t,r)}else if(!(e instanceof t))throw new pl.InvalidArgumentType(e,t.name,r)}}});var Ye=P((yne,HT)=>{"use strict";g();var st=kp(),DT=Oe(),qT=Je(),Bp=function(e){for(var t=f.Buffer.alloc(e.length),r=0;r<e.length;r++)t[r]=e[e.length-1-r];return t};st.Zero=new st(0);st.One=new st(1);st.Minus1=new st(-1);st.fromNumber=function(e){return DT.checkArgument(qT.isNumber(e)),new st(e)};st.fromString=function(e,t){return DT.checkArgument(qT.isString(e)),new st(e,t)};st.fromBuffer=function(e,t){typeof t<"u"&&t.endian==="little"&&(e=Bp(e));var r=e.toString("hex"),i=new st(r,16);return i};st.fromSM=function(e,t){var r;if(e.length===0)return st.fromBuffer(f.Buffer.from([0]));var i="big";return t&&(i=t.endian),i==="little"&&(e=Bp(e)),e[0]&128?(e[0]=e[0]&127,r=st.fromBuffer(e),r.neg().copy(r)):r=st.fromBuffer(e),r};st.prototype.toNumber=function(){return parseInt(this.toString(10),10)};st.prototype.toBuffer=function(e){var t,r;if(e&&e.size){r=this.toString(16,2);var i=r.length/2;t=f.Buffer.from(r,"hex"),i===e.size||(i>e.size?t=st.trim(t,i):i<e.size&&(t=st.pad(t,i,e.size)))}else r=this.toString(16,2),t=f.Buffer.from(r,"hex");return typeof e<"u"&&e.endian==="little"&&(t=Bp(t)),t};st.prototype.toSMBigEndian=function(){var e;return this.cmp(st.Zero)===-1?(e=this.neg().toBuffer(),e[0]&128?e=f.Buffer.concat([f.Buffer.from([128]),e]):e[0]=e[0]|128):(e=this.toBuffer(),e[0]&128&&(e=f.Buffer.concat([f.Buffer.from([0]),e]))),e.length===1&&e[0]===0&&(e=f.Buffer.from([])),e};st.prototype.toSM=function(e){var t=e?e.endian:"big",r=this.toSMBigEndian();return t==="little"&&(r=Bp(r)),r};function MT(e,t){var r=new Error(e);return r.scriptErr=t,r}st.fromScriptNumBuffer=function(e,t,r){var i=r||4;if(e.length>i)throw MT("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 MT("non-minimally encoded script number","SCRIPT_ERR_SCRIPTNUM_MINENCODE");return st.fromSM(e,{endian:"little"})};st.prototype.toScriptNumBuffer=function(){return this.toSM({endian:"little"})};st.trim=function(e,t){return e.slice(t-e.length,e.length)};st.pad=function(e,t,r){for(var i=f.Buffer.alloc(r),n=0;n<e.length;n++)i[i.length-1-n]=e[e.length-1-n];for(n=0;n<r-t;n++)i[n]=0;return i};st.prototype.toHex=function(...e){return this.toBuffer(...e).toString("hex")};st.fromHex=function(e,...t){return st.fromBuffer(f.Buffer.from(e,"hex"),...t)};HT.exports=st});function Vz(e,t=!1){return t?{h:Number(e&Np),l:Number(e>>UT&Np)}:{h:Number(e>>UT&Np)|0,l:Number(e&Np)|0}}function FT(e,t=!1){let r=e.length,i=new Uint32Array(r),n=new Uint32Array(r);for(let o=0;o<r;o++){let{h:a,l:s}=Vz(e[o],t);[i[o],n[o]]=[a,s]}return[i,n]}function jT(e,t,r,i){let n=Gz(r),o=Wz(r);e.setUint32(t,i?o:n,i),e.setUint32(t+4,i?n:o,i)}function Xn(e,t,r,i){let n=(t>>>0)+(i>>>0);return{h:e+r+(n/2**32|0)|0,l:n|0}}var Np,UT,Gz,Wz,Vy,Gy,Hs,Us,gl,ml,zT,KT,VT,GT,WT,YT,Wy=Br(()=>{g();Np=BigInt(4294967295),UT=BigInt(32);Gz=e=>e/2**32|0,Wz=e=>e>>>0;Vy=(e,t,r)=>e>>>r,Gy=(e,t,r)=>e<<32-r|t>>>r,Hs=(e,t,r)=>e>>>r|t<<32-r,Us=(e,t,r)=>e<<32-r|t>>>r,gl=(e,t,r)=>e<<64-r|t>>>r-32,ml=(e,t,r)=>e>>>r-32|t<<64-r;zT=(e,t,r)=>(e>>>0)+(t>>>0)+(r>>>0),KT=(e,t,r,i)=>t+r+i+(e/2**32|0)|0,VT=(e,t,r,i)=>(e>>>0)+(t>>>0)+(r>>>0)+(i>>>0),GT=(e,t,r,i,n)=>t+r+i+n+(e/2**32|0)|0,WT=(e,t,r,i,n)=>(e>>>0)+(t>>>0)+(r>>>0)+(i>>>0)+(n>>>0),YT=(e,t,r,i,n,o)=>t+r+i+n+o+(e/2**32|0)|0});function Cp(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name==="Uint8Array"&&"BYTES_PER_ELEMENT"in e&&e.BYTES_PER_ELEMENT===1}function zo(e,t=""){if(typeof e!="number")throw new TypeError(Yy(t)+"expected number, got "+typeof e);if(!Number.isSafeInteger(e)||e<0)throw new RangeError(Yy(t)+"expected integer >= 0, got "+e);return e}function Jn(e,t,r=""){if(Cp(e)&&(t===void 0||e.length===t))return e;t!==void 0&&zo(t,"length");let i=Cp(e),n=t!==void 0?` of length ${t}`:"",o=i?`length=${e.length}`:`type=${typeof e}`,a=Yy(r)+"expected Uint8Array"+n+", got "+o;throw i?new RangeError(a):new TypeError(a)}function Lp(e){if(typeof e!="function"||typeof e.create!="function")throw new TypeError("expected hash wrapped by utils.createHasher");if(zo(e.outputLen),zo(e.blockLen),e.outputLen<1||e.blockLen<1)throw new Error("hash blockLen / outputLen must be >= 1")}function uc(e,t=!0){if(e.destroyed)throw new Error("hash was destroyed");if(t&&e.finished)throw new Error("digest() was already called")}function Mp(e,t){Jn(e,void 0,"output");let r=t.outputLen;if(!(e.length>=r))throw new RangeError('"output" expected length >= '+r)}function Ii(...e){for(let t=0;t<e.length;t++)e[t].fill(0)}function Dp(e){return new DataView(e.buffer,e.byteOffset,e.byteLength)}function wn(e,t){return e<<32-t|e>>>t}function Ko(e,t){return e<<t|e>>>32-t>>>0}function qp(e){if(Jn(e),XT)return e.toHex();let t="";for(let r=0;r<e.length;r++)t+=Zz[e[r]];return t}function $T(e){return e>=48&&e<=57?e-48:e>=65&&e<=70?e-55:e>=97&&e<=102?e-87:void 0}function Zy(e){if(typeof e!="string")throw new TypeError("hex string expected, got "+typeof e);if(XT)try{return Uint8Array.fromHex(e)}catch(n){throw n instanceof SyntaxError?new RangeError(n.message):n}let t=e.length,r=t/2;if(t%2)throw new RangeError("hex string expected, got unpadded hex of length "+t);let i=new Uint8Array(r);for(let n=0,o=0;n<r;n++,o+=2){let a=$T(e.charCodeAt(o)),s=$T(e.charCodeAt(o+1));if(a===void 0||s===void 0){let u=e[o]+e[o+1];throw new RangeError('hex string expected, got non-hex character "'+u+'" at index '+o)}i[n]=a*16+s}return i}function Vo(e){if(typeof e!="string")throw new TypeError("string expected");return new Uint8Array(new TextEncoder().encode(e))}function JT(...e){let t=0;for(let i=0;i<e.length;i++){let n=e[i];Jn(n),t+=n.length}let r=new Uint8Array(t);for(let i=0,n=0;i<e.length;i++){let o=e[i];r.set(o,n),n+=o.length}return r}function $z(e,t,r="opts"){return ZT(e,"defaults"),t!==void 0&&ZT(t,r),Object.assign(e,t)}function Sn(e,t={}){if(typeof e!="function")throw new TypeError('"hashCons" expected function, got type='+typeof e);t=$z({},t,"info");let r=(n,o)=>e(o).update(n).digest(),i=e(void 0);return r.outputLen=i.outputLen,r.blockLen=i.blockLen,r.canXOF=i.canXOF,r.create=n=>e(n),Object.assign(r,t),Object.freeze(r)}function vl(e=32){zo(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 Yy,ZT,XT,Zz,Fs,Go=Br(()=>{g();Yy=e=>e?`"${e}" `:"";ZT=(e,t)=>{if(e===null||typeof e!="object"||Array.isArray(e))throw new TypeError((t==="object"?"":`"${t}" `)+"expected object, got type="+typeof e)};XT=typeof Uint8Array.from([]).toHex=="function"&&typeof Uint8Array.fromHex=="function",Zz=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,"0"));Fs=e=>({oid:Uint8Array.from([6,9,96,134,72,1,101,3,4,2,e])})});function cc(e,t,r){return e&t^~e&r}function Hp(e,t,r){return e&t^e&r^t&r}var Wo,QT,eP,tP,rP,$y=Br(()=>{g();Wy();Go();Wo=class{constructor(t,r,i,n){te(this,"blockLen");te(this,"outputLen");te(this,"canXOF",!1);te(this,"padOffset");te(this,"isLE");te(this,"buffer");te(this,"view");te(this,"finished",!1);te(this,"length",0);te(this,"pos",0);te(this,"destroyed",!1);this.blockLen=t,this.outputLen=r,this.padOffset=i,this.isLE=n,this.buffer=new Uint8Array(t),this.view=Dp(this.buffer)}update(t){uc(this),Jn(t);let{view:r,buffer:i,blockLen:n}=this,o=t.length,a=!1;for(let s=0;s<o;){let u=Math.min(n-this.pos,o-s);if(u===n){let c=Dp(t);for(;n<=o-s;s+=n)this.process(c,s);a=!0;continue}i.set(s===0&&u===o?t:t.subarray(s,s+u),this.pos),this.pos+=u,s+=u,this.pos===n&&(this.process(r,0),this.pos=0,a=!0)}return this.length+=t.length,a&&this.roundClean(),this}digestInto(t){uc(this),Mp(t,this),this.finished=!0;let{buffer:r,view:i,blockLen:n,isLE:o}=this,{pos:a}=this;r[a++]=128,r.fill(0,a),this.padOffset>n-a&&(this.process(i,0),r.fill(0)),jT(i,n-8,this.length*8,o),this.process(i,0),this.roundClean();let s=t===r?i:Dp(t),u=this.outputLen,c=u/4,l=this.get();if(u%4||c>l.length)throw new Error("invalid outputLen");for(let d=0;d<c;d++)s.setUint32(4*d,l[d],o)}digest(){let{buffer:t,outputLen:r}=this;this.digestInto(t);let i=t.slice(0,r);return this.destroy(),i}_cloneIntoMeta(t){let{buffer:r,length:i,finished:n,destroyed:o,pos:a}=this;return t.destroyed=o,t.finished=n,t.length=i,t.pos=a,a&&t.buffer.set(r),t}clone(){return this._cloneInto()}},QT=Uint32Array.from([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),eP=Uint32Array.from([3238371032,914150663,812702999,4144912697,4290775857,1750603025,1694076839,3204075428]),tP=Uint32Array.from([3418070365,3238371032,1654270250,914150663,2438529370,812702999,355462360,4144912697,1731405415,4290775857,2394180231,1750603025,3675008525,1694076839,1203062813,3204075428]),rP=Uint32Array.from([1779033703,4089235720,3144134277,2227873595,1013904242,4271175723,2773480762,1595750129,1359893119,2917565137,2600822924,725511199,528734635,4215389547,1541459225,327033209])});var Wp={};Pf(Wp,{_SHA224:()=>jp,_SHA256:()=>Fp,_SHA384:()=>Kp,_SHA512:()=>zp,_SHA512_224:()=>Vp,_SHA512_256:()=>Gp,sha224:()=>rK,sha256:()=>Na,sha384:()=>nK,sha512:()=>iK,sha512_224:()=>aK,sha512_256:()=>oK});var Xz,Ra,Up,Fp,jp,iP,Jz,Qz,ka,Ba,fc,zp,Kp,eK,tK,Vp,Gp,Na,rK,iK,nK,oK,aK,yl=Br(()=>{g();$y();Wy();Go();Xz=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]),Ra=new Uint32Array(64),Up=class extends Wo{constructor(r,i){super(64,r,8,!1);te(this,"A",0);te(this,"B",0);te(this,"C",0);te(this,"D",0);te(this,"E",0);te(this,"F",0);te(this,"G",0);te(this,"H",0);this.A=i[0]|0,this.B=i[1]|0,this.C=i[2]|0,this.D=i[3]|0,this.E=i[4]|0,this.F=i[5]|0,this.G=i[6]|0,this.H=i[7]|0}get(){let{A:r,B:i,C:n,D:o,E:a,F:s,G:u,H:c}=this;return[r,i,n,o,a,s,u,c]}set(r,i,n,o,a,s,u,c){this.A=r|0,this.B=i|0,this.C=n|0,this.D=o|0,this.E=a|0,this.F=s|0,this.G=u|0,this.H=c|0}_cloneInto(r){return(r||(r=new this.constructor)).set(...this.get()),this._cloneIntoMeta(r)}process(r,i){for(let p=0;p<16;p++,i+=4)Ra[p]=r.getUint32(i,!1);for(let p=16;p<64;p++){let y=Ra[p-15],_=Ra[p-2],T=wn(y,7)^wn(y,18)^y>>>3,R=wn(_,17)^wn(_,19)^_>>>10;Ra[p]=R+Ra[p-7]+T+Ra[p-16]|0}let{A:n,B:o,C:a,D:s,E:u,F:c,G:l,H:d}=this;for(let p=0;p<64;p++){let y=wn(u,6)^wn(u,11)^wn(u,25),_=d+y+cc(u,c,l)+Xz[p]+Ra[p]|0,R=(wn(n,2)^wn(n,13)^wn(n,22))+Hp(n,o,a)|0;d=l,l=c,c=u,u=s+_|0,s=a,a=o,o=n,n=_+R|0}n=n+this.A|0,o=o+this.B|0,a=a+this.C|0,s=s+this.D|0,u=u+this.E|0,c=c+this.F|0,l=l+this.G|0,d=d+this.H|0,this.set(n,o,a,s,u,c,l,d)}roundClean(){Ii(Ra)}destroy(){this.destroyed=!0,this.set(0,0,0,0,0,0,0,0),Ii(this.buffer)}},Fp=class extends Up{constructor(){super(32,QT)}},jp=class extends Up{constructor(){super(28,eP)}},iP=FT(["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))),Jz=iP[0],Qz=iP[1],ka=new Uint32Array(80),Ba=new Uint32Array(80),fc=class extends Wo{constructor(r,i){super(128,r,16,!1);te(this,"Ah",0);te(this,"Al",0);te(this,"Bh",0);te(this,"Bl",0);te(this,"Ch",0);te(this,"Cl",0);te(this,"Dh",0);te(this,"Dl",0);te(this,"Eh",0);te(this,"El",0);te(this,"Fh",0);te(this,"Fl",0);te(this,"Gh",0);te(this,"Gl",0);te(this,"Hh",0);te(this,"Hl",0);this.Ah=i[0]|0,this.Al=i[1]|0,this.Bh=i[2]|0,this.Bl=i[3]|0,this.Ch=i[4]|0,this.Cl=i[5]|0,this.Dh=i[6]|0,this.Dl=i[7]|0,this.Eh=i[8]|0,this.El=i[9]|0,this.Fh=i[10]|0,this.Fl=i[11]|0,this.Gh=i[12]|0,this.Gl=i[13]|0,this.Hh=i[14]|0,this.Hl=i[15]|0}get(){let{Ah:r,Al:i,Bh:n,Bl:o,Ch:a,Cl:s,Dh:u,Dl:c,Eh:l,El:d,Fh:p,Fl:y,Gh:_,Gl:T,Hh:R,Hl:B}=this;return[r,i,n,o,a,s,u,c,l,d,p,y,_,T,R,B]}set(r,i,n,o,a,s,u,c,l,d,p,y,_,T,R,B){this.Ah=r|0,this.Al=i|0,this.Bh=n|0,this.Bl=o|0,this.Ch=a|0,this.Cl=s|0,this.Dh=u|0,this.Dl=c|0,this.Eh=l|0,this.El=d|0,this.Fh=p|0,this.Fl=y|0,this.Gh=_|0,this.Gl=T|0,this.Hh=R|0,this.Hl=B|0}_cloneInto(r){return(r||(r=new this.constructor)).set(...this.get()),this._cloneIntoMeta(r)}process(r,i){for(let I=0;I<16;I++,i+=4)ka[I]=r.getUint32(i),Ba[I]=r.getUint32(i+=4);for(let I=16;I<80;I++){let k=ka[I-15]|0,D=Ba[I-15]|0,F=Hs(k,D,1)^Hs(k,D,8)^Vy(k,D,7),K=Us(k,D,1)^Us(k,D,8)^Gy(k,D,7),G=ka[I-2]|0,S=Ba[I-2]|0,h=Hs(G,S,19)^gl(G,S,61)^Vy(G,S,6),v=Us(G,S,19)^ml(G,S,61)^Gy(G,S,6),w=VT(K,v,Ba[I-7],Ba[I-16]),E=GT(w,F,h,ka[I-7],ka[I-16]);ka[I]=E|0,Ba[I]=w|0}let{Ah:n,Al:o,Bh:a,Bl:s,Ch:u,Cl:c,Dh:l,Dl:d,Eh:p,El:y,Fh:_,Fl:T,Gh:R,Gl:B,Hh:H,Hl:j}=this;for(let I=0;I<80;I++){let k=Hs(p,y,14)^Hs(p,y,18)^gl(p,y,41),D=Us(p,y,14)^Us(p,y,18)^ml(p,y,41),F=p&_^~p&R,K=y&T^~y&B,G=WT(j,D,K,Qz[I],Ba[I]),S=YT(G,H,k,F,Jz[I],ka[I]),h=G|0,v=Hs(n,o,28)^gl(n,o,34)^gl(n,o,39),w=Us(n,o,28)^ml(n,o,34)^ml(n,o,39),E=n&a^n&u^a&u,A=o&s^o&c^s&c;H=R|0,j=B|0,R=_|0,B=T|0,_=p|0,T=y|0,{h:p,l:y}=Xn(l|0,d|0,S|0,h|0),l=u|0,d=c|0,u=a|0,c=s|0,a=n|0,s=o|0;let L=zT(h,w,A);n=KT(L,S,v,E),o=L|0}({h:n,l:o}=Xn(this.Ah|0,this.Al|0,n|0,o|0)),{h:a,l:s}=Xn(this.Bh|0,this.Bl|0,a|0,s|0),{h:u,l:c}=Xn(this.Ch|0,this.Cl|0,u|0,c|0),{h:l,l:d}=Xn(this.Dh|0,this.Dl|0,l|0,d|0),{h:p,l:y}=Xn(this.Eh|0,this.El|0,p|0,y|0),{h:_,l:T}=Xn(this.Fh|0,this.Fl|0,_|0,T|0),{h:R,l:B}=Xn(this.Gh|0,this.Gl|0,R|0,B|0),{h:H,l:j}=Xn(this.Hh|0,this.Hl|0,H|0,j|0),this.set(n,o,a,s,u,c,l,d,p,y,_,T,R,B,H,j)}roundClean(){Ii(ka,Ba)}destroy(){this.destroyed=!0,Ii(this.buffer),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}},zp=class extends fc{constructor(){super(64,rP)}},Kp=class extends fc{constructor(){super(48,tP)}},eK=Uint32Array.from([2352822216,424955298,1944164710,2312950998,502970286,855612546,1738396948,1479516111,258812777,2077511080,2011393907,79989058,1067287976,1780299464,286451373,2446758561]),tK=Uint32Array.from([573645204,4230739756,2673172387,3360449730,596883563,1867755857,2520282905,1497426621,2519219938,2827943907,3193839141,1401305490,721525244,746961066,246885852,2177182882]),Vp=class extends fc{constructor(){super(28,eK)}},Gp=class extends fc{constructor(){super(32,tK)}},Na=Sn(()=>new Fp,Fs(1)),rK=Sn(()=>new jp,Fs(4)),iK=Sn(()=>new zp,Fs(3)),nK=Sn(()=>new Kp,Fs(2)),oK=Sn(()=>new Gp,Fs(6)),aK=Sn(()=>new Vp,Fs(5))});function $t(e,t,r=()=>{}){if(!Array.isArray(e))throw new TypeError(`"${t}" expected array, got type=${typeof e}`);for(let i=0;i<e.length;i++)r(e[i],`${t}[${i}]`);return e}function bl(e,t=""){if(typeof e!="string"){let r=t&&`"${t}" `;throw new TypeError(r+"expected string, got type="+typeof e)}return e}function Ca(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 js(e,t){if(typeof e!="function")throw new TypeError(`"${t}" is invalid: expected function, got ${typeof e}`);return e}function eo(e,t=""){if(typeof e!="boolean")throw new TypeError(sK(t)+"expected boolean, got type="+typeof e);return e}function Zp(e){if(typeof e=="bigint"){if(!La(e))throw new RangeError("positive bigint expected, got "+e)}else Xy(e);return e}function Xt(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 _l(e){let t=Zp(e).toString(16);return t.length&1?"0"+t:t}function oP(e){if(typeof e!="string")throw new TypeError("hex string expected, got "+typeof e);return e===""?Yp:BigInt("0x"+e)}function Nr(e){return oP(qp(e))}function hc(e){return oP(qp(Xp(Jn(e)).reverse()))}function $p(e,t){if(zo(t),t===0)throw new Error("zero output length is invalid");e=Zp(e);let r=t*2,i=e.toString(16);if(i.length>r)throw new RangeError("number is too large");return Zy(i.padStart(r,"0"))}function Jy(e,t){return $p(e,t).reverse()}function Xp(e){return Uint8Array.from(Ce(e))}function dc(e){if(typeof e!="string")throw new TypeError("ascii string expected, got "+typeof e);return Uint8Array.from(e,(t,r)=>{let i=t.charCodeAt(0);if(t.length!==1||i>127)throw new RangeError(`string contains non-ASCII character "${e[r]}" with code ${i} at position ${r}`);return i})}function La(e){return typeof e=="bigint"&&Yp<=e}function Qy(e,t,r){return La(e)&&La(t)&&La(r)&&t<=e&&e<r}function eb(e,t,r,i){if(!Qy(t,r,i))throw new RangeError("expected valid "+e+": "+r+" <= n < "+i+", got "+t)}function pc(e){if(e<Yp)throw new Error("expected non-negative bigint, got "+e);return e===Yp?0:e.toString(2).length}function aP(e,t,r){if(zo(e,"hashLen"),zo(t,"qByteLen"),typeof r!="function")throw new TypeError("hmacFn must be a function");let i=R=>new Uint8Array(R),n=Uint8Array.of(),o=Uint8Array.of(0),a=Uint8Array.of(1),s=1e3,u=i(e),c=i(e),l=0,d=()=>{u.fill(1),c.fill(0),l=0},p=(...R)=>r(c,lt(u,...R)),y=(R=n)=>{c=p(o,R),u=p(),R.length!==0&&(c=p(a,R),u=p())},_=()=>{if(l++>=s)throw new Error("drbg: tried max amount of iterations");let R=0,B=[];for(;R<t;){u=p();let H=u.slice();B.push(H),R+=u.length}return lt(...B)};return(R,B)=>{d(),y(R);let H;for(;(H=B(_()))===void 0;)y();return d(),H}}function yt(e,t={},r={},i="object"){Ca(e,i),Ca(t,"fields"),Ca(r,"optFields");function n(a,s,u){let c=i==="object"?`param "${String(a)}"`:`"${i}.${String(a)}"`,l=e[a];if(!Object.hasOwn(e,a)&&(u?l!==void 0:s!=="function"))throw new TypeError(`${c} is invalid: expected own property`);if(u&&l===void 0)return;let d=typeof l;if(d!==s||l===null)throw new TypeError(`${c} is invalid: expected ${s}, got ${d}`)}let o=(a,s)=>Object.entries(a).forEach(([u,c])=>n(u,c,s));o(t,!1),o(r,!0)}var Ce,Xy,Yo,lt,lc,Qn,mi,Yp,nP,sK,wl,Ma=Br(()=>{g();Go();Ce=(e,t,r)=>Jn(e,t,r),Xy=zo;Yo=qp,lt=(...e)=>JT(...e),lc=e=>Zy(e),Qn=Cp,mi=e=>vl(e),Yp=BigInt(0),nP=BigInt(1),sK=e=>e?`"${e}" `:"";wl=e=>(Xt(e,"n"),(nP<<BigInt(e))-nP)});function vi(e,t){if(t<=Cr)throw new Error("mod: expected positive modulus, got "+t);let r=e%t;return r>=Cr?r:t+r}function dP(e,t,r){if(r<=mt)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<Cr)throw new Error("invalid exponent, negatives unsupported");if(t===Cr)return mt;if(t===mt)return e;let i=e%r;if(i<Cr&&(i+=r),t<lK){let s=mt;for(;t>Cr;)t&mt&&(s=s*i%r),i=i*i%r,t>>=mt;return s}let n=[];for(;t>Cr;)n.push(Number(t&fK)),t>>=rb;let o=new Array(16);o[0]=mt,o[1]=i;for(let s=2;s<16;s++)o[s]=o[s-1]*i%r;let a=o[n[n.length-1]];for(let s=n.length-2;s>=0;s--){a=a*a%r,a=a*a%r,a=a*a%r,a=a*a%r;let u=n[s];u!==0&&(a=a*o[u]%r)}return a}function Fi(e,t,r){if(r<=mt)throw new Error("pow2: expected modulus > 1, got "+r);if(t<Cr)throw new Error("pow2: expected non-negative exponent, got "+t);let i=e;for(;t-- >Cr;)i*=i,i%=r;return i}function sP(e,t){if(e===Cr)throw new Error("invert: expected non-zero number");if(t<=mt)throw new Error("invert: expected modulus > 1, got "+t);let r=vi(e,t),i=t,n=Cr,o=mt;for(;r!==Cr;){let s=i/r,u=i-r*s,c=n-o*s;i=r,r=u,n=o,o=c}if(i!==mt)throw new Error("invert: does not exist");return vi(n,t)}function pP(e,t){if(t<=mt)throw new Error("invertCt: expected prime modulus > 1, got "+t);let r=vi(e,t);if(r===Cr)throw new Error("invertCt: expected non-zero number");let i=dP(r,t-Da,t);if(vi(r*i,t)!==mt)throw new Error("invertCt: does not exist");return i}function ib(e,t,r){let i=e;if(!i.eql(i.sqr(t),r))throw new Error("Cannot find square root")}function nb(e,t){if((e&mt)===Cr)throw new Error(t+": expected odd modulus, got "+e)}function gP(e,t){let r=e,i=(r.ORDER+mt)/rb,n=r.pow(t,i);return ib(r,n,t),n}function hK(e,t){let r=e,i=(r.ORDER-fP)/lP,n=r.mul(t,Da),o=r.pow(n,i),a=r.mul(t,o),s=r.mul(r.mul(a,Da),o),u=r.mul(a,r.sub(s,r.ONE));return ib(r,u,t),u}function dK(e){let t=mc(e),r=mP(e),i=r(t,t.neg(t.ONE)),n=r(t,i),o=r(t,t.neg(i)),a=(e+uK)/hP;return((s,u)=>{let c=s,l=c.pow(u,a),d=c.mul(l,i),p=c.mul(l,n),y=c.mul(l,o),_=c.eql(c.sqr(d),u),T=c.eql(c.sqr(p),u);l=c.cmov(l,d,_),d=c.cmov(y,p,T);let R=c.eql(c.sqr(d),u),B=c.cmov(l,d,R);return ib(c,B,u),B})}function mP(e){if(e<cP)throw new Error("sqrt is not defined for small field");nb(e,"tonelliShanks");let t=e-mt,r=0;for(;t%Da===Cr;)t/=Da,r++;let i=Da,n=mc(e);for(;tb(n,i)===1;)if(i++>1e3)throw new Error("Cannot find square root: probably non-prime P");if(r===1)return gP;let o=n.pow(i,t),a=(t+mt)/Da;return function(u,c){let l=u;if(l.is0(c))return c;if(tb(l,c)!==1)throw new Error("Cannot find square root");let d=r,p=l.mul(l.ONE,o),y=l.pow(c,t),_=l.pow(c,a);for(;!l.eql(y,l.ONE);){if(l.is0(y))throw new Error("Cannot find square root: probably non-prime P");let T=1,R=l.sqr(y);for(;!l.eql(R,l.ONE);)if(T++,R=l.sqr(R),T===d)throw new Error("Cannot find square root");let B=mt<<BigInt(d-T-1),H=l.pow(p,B);d=T,p=l.sqr(H),y=l.mul(y,p),_=l.mul(_,H)}return _}}function pK(e){return nb(e,"Fp.sqrt"),e%rb===cP?gP:e%lP===fP?hK:e%hP===cK?dK(e):mP(e)}function rn(e){if(Ca(e,"field"),typeof e.ORDER!="bigint")throw new TypeError('param "ORDER" is invalid: expected bigint, got '+typeof e.ORDER);Xt(e.BYTES,"BYTES"),Xt(e.BITS,"BITS");for(let t of gK)js(e[t],"field."+t);if(e.BYTES<1||e.BITS<1)throw new Error("invalid field: expected BYTES/BITS > 0");if(e.ORDER<=mt)throw new Error("invalid field: expected ORDER > 1, got "+e.ORDER);return e}function gc(e,t,r=!1){rn(e),$t(t,"nums"),eo(r,"passZero");let i=e,n=new Array(t.length).fill(r?i.ZERO:void 0),o=t.reduce((s,u,c)=>i.is0(u)?s:(n[c]=s,i.mul(s,u)),i.ONE),a=i.inv(o);return t.reduceRight((s,u,c)=>i.is0(u)?s:(n[c]=i.mul(s,n[c]),i.mul(s,u)),a),n}function tb(e,t){rn(e);let r=e;nb(r.ORDER,"FpLegendre");let i=(r.ORDER-mt)/Da,n=r.pow(t,i),o=r.eql(n,r.ONE),a=r.eql(n,r.ZERO),s=r.eql(n,r.neg(r.ONE));if(!o&&!a&&!s)throw new Error("invalid Legendre symbol result");return o?1:a?0:-1}function ob(e,t){return tb(e,t)!==-1}function mK(e,t){if(t!==void 0&&Xy(t),e<=Cr)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=pc(e);if(t!==void 0&&t<r)throw new Error(`invalid n length: expected nBitLength (${t}) >= bitLen(n) (${r})`);let i=t!==void 0?t:r,n=Math.ceil(i/8);return{nBitLength:i,nByteLength:n}}function mc(e,t={}){return Object.freeze(Jp.prototype),new Jp(e,t)}function vP(e){if(typeof e!="bigint")throw new Error("field order must be bigint");if(e<=mt)throw new Error("field order must be greater than 1");let t=pc(e-mt);return Math.ceil(t/8)}function vc(e){let t=vP(e);return t+Math.ceil(t/2)}function zs(e,t,r=!1){Ce(e);let i=e.length,n=vP(t),o=Math.max(vc(t),16);if(i<o||i>1024)throw new Error("expected "+o+"-1024 bytes of input, got "+i);let a=r?hc(e):Nr(e),s=vi(a,t-mt)+mt;return r?Jy(s,n):$p(s,n)}var Cr,mt,Da,cP,rb,fP,uK,lP,cK,fK,hP,lK,gK,uP,Jp,Ks=Br(()=>{g();Ma();Cr=BigInt(0),mt=BigInt(1),Da=BigInt(2),cP=BigInt(3),rb=BigInt(4),fP=BigInt(5),uK=BigInt(7),lP=BigInt(8),cK=BigInt(9),fK=BigInt(15),hP=BigInt(16),lK=BigInt("0x10000000000000000");gK=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];uP=new WeakMap,Jp=class{constructor(t,r={}){te(this,"ORDER");te(this,"BITS");te(this,"BYTES");te(this,"isLE");te(this,"ZERO",Cr);te(this,"ONE",mt);te(this,"_lengths");te(this,"_mod");if(t<=mt)throw new Error("invalid field: expected ORDER > 1, got "+t);let i;this.isLE=!1,r!=null&&typeof r=="object"&&(typeof r.BITS=="number"&&(i=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:n,nByteLength:o}=mK(t,i);if(o>2048)throw new Error("invalid field: expected ORDER of <= 2048 bytes");this.ORDER=t,this.BITS=n,this.BYTES=o,Object.freeze(this)}create(t){return vi(t,this.ORDER)}isValid(t){if(typeof t!="bigint")throw new TypeError("invalid field element: expected bigint, got "+typeof t);return Cr<=t&&t<this.ORDER}is0(t){return t===Cr}isValidNot0(t){return!this.is0(t)&&this.isValid(t)}isOdd(t){return(t&mt)===mt}neg(t){return vi(-t,this.ORDER)}eql(t,r){return t===r}sqr(t){return vi(t*t,this.ORDER)}add(t,r){return vi(t+r,this.ORDER)}sub(t,r){return vi(t-r,this.ORDER)}mul(t,r){return vi(t*r,this.ORDER)}pow(t,r){return dP(t,r,this.ORDER)}div(t,r){return vi(t*sP(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 sP(t,this.ORDER)}sqrt(t){let r=uP.get(this);return r||uP.set(this,r=pK(this.ORDER)),r(this,t)}toBytes(t){return this.isLE?Jy(t,this.BYTES):$p(t,this.BYTES)}fromBytes(t,r=!1){Ce(t);let{_lengths:i,BYTES:n,isLE:o,ORDER:a,_mod:s}=this;if(i){if(t.length<1||!i.includes(t.length)||t.length>n)throw new Error("Field.fromBytes: expected "+i+" bytes, got "+t.length);let c=new Uint8Array(n);c.set(t,o?0:c.length-t.length),t=c}if(t.length!==n)throw new Error("Field.fromBytes: expected "+n+" bytes, got "+t.length);let u=o?hc(t):Nr(t);if(s&&(u=vi(u,a)),!r&&!this.isValid(u))throw new Error("invalid field element: outside of range 0..ORDER");return u}invertBatch(t){return gc(this,t,!0)}cmov(t,r,i){return eo(i,"condition"),i?r:t}}});function qa(e){let t=e;if(typeof t!="function")throw new TypeError('"Point" expected constructor, got type='+typeof e);js(t.fromAffine,"Point.fromAffine"),js(t.fromBytes,"Point.fromBytes"),js(t.fromHex,"Point.fromHex"),Ca(t.BASE,"Point.BASE"),Ca(t.ZERO,"Point.ZERO"),rn(t.Fp),rn(t.Fn)}function wP(e,t){qa(e),SP(t,e);let r=gc(e.Fp,t.map(i=>i.Z));return t.map((i,n)=>e.fromAffine(i.toAffine(r[n])))}function bK(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 _K(e,t){let r=e*(4*t+128);if(r>bP)throw new Error("invalid window size: table would need ~"+Math.ceil(r/2**20)+" MiB, max "+bP/2**20+" MiB")}function cb(e,t){if(e!==void 0){js(e,"randomBytes");try{let r=e(t);if(!Qn(r)||r.length!==t)return}catch{return}return e}}function SP(e,t){$t(e,"points"),e.forEach((r,i)=>{if(!(r instanceof t))throw new Error("invalid point at index "+i)})}function wK(e,t,r){if(!Array.isArray(e))throw new Error("array of scalars expected");e.forEach((i,n)=>{if(!(r===void 0?t.isValid(i):La(i)&&i<r))throw new Error("invalid scalar at index "+n)})}function sb(e){return EP.get(e)||1}function SK(e,t){let r=e.double(),i=[e];for(let n=1;n<t;n++)i.push(i[n-1].add(r));return i}function EK(e,t){let r=2**t,i=r/2,n=BigInt(r-1),o=[];for(;e>ub;){let a=0;e&Sl&&(a=Number(e&n),a>=i&&(a-=r),e-=BigInt(a)),o.push(a),e>>=Sl}return o}function xK(e,t,r){let i=2**t,n=i/2,o=BigInt(i-1),a=BigInt(t),s=[];for(let u=0;u<r;u++){let c=Number(e&o);e>>=a,c>n&&(c-=i,e+=Sl),s.push(c)}if(e!==ub)throw new Error("invalid wnaf");return s}function OK(e,t,r){let i=0;for(let o of r)i=Math.max(i,o.length);let n=e;for(let o=i-1;o>=0;o--){o!==i-1&&(n=n.double());for(let a=0;a<r.length;a++){let s=r[a][o];if(s){let u=t[a][Math.abs(s)-1>>1];n=n.add(s<0?u.negate():u)}}}return n}function yc(e,t,r,i=!1){if(qa(e),SP(t,e),eo(i,"allowOversized"),wK(r,e.Fn,i?e.Fn.ORDER**vK:void 0),t.length!==r.length)throw new Error("arrays of points and scalars must have equal length");let n=t.map(a=>SK(a,4)),o=r.map(a=>EK(a,4));return OK(e.ZERO,n,o)}function _P(e,t,r){if(t){if(t.ORDER!==e)throw new Error("Field.ORDER must match order: Fp == p, Fn == n");return rn(t),t}else return mc(e,{isLE:r})}function xP(e,t,r={},i){if(e!=="weierstrass"&&e!=="edwards")throw new Error('expected curve type "weierstrass" or "edwards"');if(i===void 0&&(i=e==="edwards"),!t||typeof t!="object")throw new Error(`expected valid ${e} CURVE object`);yt(r);for(let u of["p","n","h"]){let c=t[u];if(!(La(c)&&c!==ub))throw new Error(`CURVE.${u} must be positive bigint`)}let n=_P(t.p,r.Fp,i),o=_P(t.n,r.Fn,i),s=["Gx","Gy","a",e==="weierstrass"?"b":"d"];for(let u of s)if(!n.isValid(t[u]))throw new Error(`CURVE.${u} must be valid field element of CURVE.Fp`);return t=Object.freeze(Object.assign({},t)),{CURVE:t,Fp:n,Fn:o}}function eg(e,t){return function(i){let n=e(i);return{secretKey:n,publicKey:t(n)}}}var ub,Sl,vK,ab,yP,yK,bP,EP,Qp,tg=Br(()=>{g();Ma();Ks();ub=BigInt(0),Sl=BigInt(1),vK=BigInt(4),ab=16,yP=128,yK=5,bP=2**31;EP=new WeakMap;Qp=class{constructor(t,r){te(this,"Point");te(this,"BASE");te(this,"ZERO");te(this,"randomBytes");te(this,"wnafPrecomputes",new WeakMap);te(this,"baseCanBeBlinded");te(this,"bits");qa(t),this.randomBytes=cb(r,ab),this.Point=t,this.BASE=t.BASE,this.ZERO=t.ZERO,this.bits=t.Fn.BITS}buildWnafTable(t,r,i){let n=Math.ceil(i/r)+1,o=2**(r-1),a=[],s=t;for(let u=0;u<n;u++){let c=s;for(let l=0;l<o;l++)a.push(c),c=c.add(s);s=a[a.length-1].double()}return{W:r,bits:i,windows:n,comp:a}}wnafCachedCT(t,r){let{W:i,windows:n,comp:o}=t,a=2**(i-1),s=xK(r,i,n),u=this.ZERO,c=this.BASE;for(let l=0;l<n;l++){let d=s[l],p=l*a,y=Math.abs(d)-1,_=o[p];for(let R=1;R<a;R++)_=R===y?o[p+R]:_;let T=_.negate();d===0?c=c.add(o[p]):u=u.add(d<0?T:_)}return{p:u,f:c}}getWnafPrecomputes(t,r,i,n){let o=this.wnafPrecomputes.get(r),a=o?.find(s=>s.W===t&&s.bits===i);return a||(a=this.buildWnafTable(r,t,i),typeof n=="function"&&(a={...a,comp:n(a.comp)}),o||(o=[],this.wnafPrecomputes.set(r,o)),o.push(a)),a}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),!Qy(r,Sl,this.Point.Fn.ORDER))throw new Error("invalid scalar")}runCT(t,r,i,n){let o=sb(t);return o===1?this.fixedWindowCT(t,r,i):this.wnafCachedCT(this.getWnafPrecomputes(o,t,i,n),r)}mulCT(t,r,i){return this.validateMulInput(t,r),this.runCT(t,r,this.bits,i)}mulCTBlinded(t,r,i){if(this.validateMulInput(t,r),this.randomBytes===void 0)throw new Error("randomBytes is required for scalar blinding");let n=this.Point.Fn.BITS+yP,o=this.randomBytes(ab);if(!Qn(o)||o.length!==ab)throw new Error("randomBytes returned invalid byte array");o[0]=o[0]&63|128;let a=r+Nr(o)*this.Point.Fn.ORDER;return this.runCT(t,a,n,i)}fixedWindowCT(t,r,i){let n=yK,o=1<<n,a=wl(n),s=new Array(o);s[0]=this.ZERO;for(let l=1;l<o;l++)s[l]=s[l-1].add(t);let u=Math.ceil(i/n),c=this.ZERO;for(let l=u-1;l>=0;l--){if(l!==u-1)for(let y=0;y<n;y++)c=c.double();let d=Number(r>>BigInt(l*n)&a),p=s[0];for(let y=1;y<o;y++)p=y===d?s[y]:p;c=c.add(p)}return{p:c,f:c}}shouldBlind(t,r){return this.randomBytes===void 0?!1:r===Sl?!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,i,n){return this.shouldBlind(t,i)?this.mulCTBlinded(t,r,n):this.mulCT(t,r,n)}mulUnsafe(t,r,i){if(this.assertPoint(t),!La(r))throw new Error("invalid scalar");let n=sb(t);if(n===1||r>=this.Point.Fn.ORDER)return yc(this.Point,[t],[r],!0);let o=this.getWnafPrecomputes(n,t,this.bits,i);return this.wnafCachedCT(o,r).p}setWindowSize(t,r){this.assertPoint(t),bK(r,this.bits);let i=Math.ceil((this.bits+yP)/r)+1;_K(i*2**(r-1),this.Point.Fp.BYTES),EP.set(t,r),this.wnafPrecomputes.delete(t)}hasWindowSize(t){return sb(t)!==1}}});function fb(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 OP(e){return fb(e,"x"),(e&e-1)===0&&e!==0}function IK(e){if(fb(e),e<=1)return 1;if(e>2147483648)throw new Error("nextPowerOfTwo overflow: result does not fit u32");return 1<<rg(e-1)+1>>>0}function rg(e){return fb(e),31-Math.clz32(e)}function IP(e,t,r,i,n){rn(e);let o=e,a=r||((d,p)=>new Array(d).fill(p??o.ZERO)),s=d=>{if(Array.isArray(d))return!0;if(!ArrayBuffer.isView(d))return!1;let p=d;return typeof p.length=="number"&&typeof p.slice=="function"&&typeof p[Symbol.iterator]=="function"},u=(d,p)=>{if(!s(p))throw new TypeError(`"${d}" expected polynomial, got type=${typeof p}`)},c=(d,p)=>{u("a",d);let y=d.length;if(p!==void 0&&(u("b",p),p.length!==y))throw new Error(`poly: mismatched lengths ${y} vs ${p.length}`);if(n!==void 0&&y!==n)throw new Error(`poly: expected fixed length ${n}, got ${y}`);return y};function l(d,p,y=!1,_){if(!OP(p))throw new Error("poly.lagrange: expected power of two length, got "+p);let T=_||(y?t.brp(rg(p)):t.roots(rg(p)));for(let R=0;R<p;R++)if(o.eql(d,T[R]))return R;return-1}return{roots:t,create:a,length:n,extend:(d,p)=>{c(d);let y=a(p,o.ZERO);for(let _=0;_<Math.min(d.length,p);_++)y[_]=d[_];return y},degree:d=>{c(d);for(let p=d.length-1;p>=0;p--)if(!o.is0(d[p]))return p;return-1},add:(d,p)=>{let y=c(d,p),_=a(y);for(let T=0;T<y;T++)_[T]=o.add(d[T],p[T]);return _},sub:(d,p)=>{let y=c(d,p),_=a(y);for(let T=0;T<y;T++)_[T]=o.sub(d[T],p[T]);return _},dot:(d,p)=>{let y=c(d,p),_=a(y);for(let T=0;T<y;T++)_[T]=o.mul(d[T],p[T]);return _},mul:(d,p)=>{if(s(p)){let y=c(d,p);if(i){let _=i.direct(d,!1,!0),T=i.direct(p,!1,!0);for(let R=0;R<_.length;R++)_[R]=o.mul(_[R],T[R]);return i.inverse(_,!0,!1)}else{let _=a(y);for(let T=0;T<y;T++)for(let R=0;R<y;R++){let B=(T+R)%y;_[B]=o.add(_[B],o.mul(d[T],p[R]))}return _}}else{let y=a(c(d));for(let _=0;_<y.length;_++)y[_]=o.mul(d[_],p);return y}},convolve(d,p){u("a",d),u("b",p);let y=IK(d.length+p.length-1);return this.mul(this.extend(d,y),this.extend(p,y))},shift(d,p){u("p",d);let y=a(d.length);if(n!==void 0&&d.length!==n)throw new Error(`poly: expected fixed length ${n}, got ${d.length}`);if(!d.length)return y;y[0]=d[0];for(let _=1,T=o.ONE;_<d.length;_++)T=o.mul(T,p),y[_]=o.mul(d[_],T);return y},clone:d=>{c(d);let p=a(d.length);for(let y=0;y<d.length;y++)p[y]=d[y];return p},eval:(d,p)=>{c(d,p);let y=o.ZERO;for(let _=0;_<d.length;_++)y=o.add(y,o.mul(d[_],p[_]));return y},monomial:{basis:(d,p)=>{let y=a(p),_=o.ONE;for(let T=0;T<p;T++)y[T]=_,_=o.mul(_,d);return y},eval:(d,p)=>{c(d);let y=o.ZERO;for(let _=d.length-1;_>=0;_--)y=o.add(o.mul(y,p),d[_]);return y}},lagrange:{basis:(d,p,y=!1,_)=>{if(!OP(p))throw new Error("poly.lagrange: expected power of two length, got "+p);let T=rg(p),R=_||(y?t.brp(T):t.roots(T)),B=a(p),H=l(d,p,y,_);if(H!==-1)return B[H]=o.ONE,B;let j=o.pow(d,BigInt(p)),I=o.mul(o.sub(j,o.ONE),o.inv(BigInt(p))),k=a(p);for(let F=0;F<p;F++)k[F]=o.sub(d,R[F]);let D=o.invertBatch(k);for(let F=0;F<p;F++)B[F]=o.mul(I,o.mul(R[F],D[F]));return B},eval(d,p,y=!1){c(d);let _=l(p,d.length,y);if(_!==-1)return d[_];let T=this.basis(p,d.length,y),R=o.ZERO;for(let B=0;B<d.length;B++)o.is0(d[B])||(R=o.add(R,o.mul(d[B],T[B])));return R}},vanishing(d){if(u("roots",d),n!==void 0&&d.length!==n)throw new Error(`poly: expected fixed length ${n}, got ${d.length}`);let p=a(d.length+1,o.ZERO);p[0]=o.ONE;for(let y of d){let _=o.neg(y);for(let T=p.length-1;T>0;T--)p[T]=o.add(o.mul(p[T],_),p[T-1]);p[0]=o.mul(p[0],_)}return p}}}var AP=Br(()=>{g();Ks()});function Vs(e,t){if(Xt(e),Xt(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 i=t-1;i>=0;i--)r[i]=e&255,e>>>=8;return new Uint8Array(r)}function TK(e,t){let r=new Uint8Array(e.length);for(let i=0;i<e.length;i++)r[i]=e[i]^t[i];return r}function kP(e){if(!Qn(e)&&typeof e!="string")throw new Error("DST must be Uint8Array or ascii string");let t=typeof e=="string"?dc(e):e;if(t.length===0)throw new Error("DST must be non-empty");return t}function PK(e,t,r,i){if(Ce(e),Xt(r),typeof i!="function")throw new Error("expand_message_xmd: expected hash function");Xt(i.outputLen,"hash.outputLen"),Xt(i.blockLen,"hash.blockLen"),t=kP(t),t.length>255&&(t=i(lt(dc("H2C-OVERSIZE-DST-"),t)));let{outputLen:n,blockLen:o}=i,a=Math.ceil(r/n);if(r>65535||a>255)throw new Error("expand_message_xmd: invalid lenInBytes");let s=lt(t,Vs(t.length,1)),u=new Uint8Array(o),c=Vs(r,2),l=new Array(a),d=i(lt(u,e,c,Vs(0,1),s));l[0]=i(lt(d,Vs(1,1),s));for(let y=1;y<a;y++){let _=[TK(d,l[y-1]),Vs(y+1,1),s];l[y]=i(lt(..._))}return lt(...l).slice(0,r)}function RK(e,t,r,i,n){if(Ce(e),Xt(r),Xt(i,"k"),i<0)throw new Error("expand_message_xof: invalid k");if(typeof n!="function")throw new Error("expand_message_xof: expected XOF function");if(typeof n.create!="function")throw new Error("expand_message_xof: expected XOF create");if(t=kP(t),r<0||r>65535)throw new Error("expand_message_xof: invalid lenInBytes");if(t.length>255){let o=Math.ceil(2*i/8);t=n.create({dkLen:o}).update(dc("H2C-OVERSIZE-DST-")).update(t).digest()}if(t.length>255)throw new Error("expand_message_xof: invalid DST");return n.create({dkLen:r}).update(e).update(Vs(r,2)).update(t).update(Vs(t.length,1)).digest()}function lb(e,t,r){yt(r,{p:"bigint",m:"number",k:"number",hash:"function"});let{p:i,k:n,m:o,hash:a,expand:s,DST:u}=r;if(Xt(a.outputLen,"valid hash"),Ce(e),Xt(t),Xt(o,"m"),Xt(n,"k"),i<=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(n<0)throw new Error("hash_to_field: invalid k");let c=i.toString(2).length,l=Math.ceil((c+n)/8),d=t*o*l,p;if(s==="xmd")p=PK(e,u,d,a);else if(s==="xof")p=RK(e,u,d,n,a);else if(s==="_internal_pass")p=e;else throw new Error('expand must be "xmd" or "xof"');let y=new Array(t);for(let _=0;_<t;_++){let T=new Array(o);for(let R=0;R<o;R++){let B=l*(R+_*o),H=p.subarray(B,B+l);T[R]=vi(AK(H),i)}y[_]=T}return y}function BP(e,t){rn(e),$t(t,"map");let r=t.map((i,n)=>{if($t(i,"map["+n+"]"),i.length<1)throw new Error("isogenyMap: expected non-empty coefficients");return Array.from(i).reverse()});return(i,n)=>{let[o,a,s,u]=r.map(p=>p.reduce((y,_)=>e.add(e.mul(y,i),_))),c=e.is0(a)||e.is0(u),[l,d]=gc(e,[a,u],!0);return i=e.mul(o,l),n=e.mul(n,e.mul(s,d)),c?{x:e.ZERO,y:e.ZERO}:{x:i,y:n}}}function NP(e,t,r){if(typeof t!="function")throw new Error("mapToCurve() must be defined");yt(r);let i=u=>Object.freeze({...u,DST:Qn(u.DST)?Xp(u.DST):u.DST,...u.encodeDST===void 0?{}:{encodeDST:Qn(u.encodeDST)?Xp(u.encodeDST):u.encodeDST}}),n=i(r),o=u=>u&&u.DST!==void 0?{DST:u.DST}:void 0;function a(u){return e.fromAffine(t(u))}function s(u){let c=u.clearCofactor();return c.equals(e.ZERO)?e.ZERO:(c.assertValidity(),c)}return Object.freeze({get defaults(){return i(n)},Point:e,hashToCurve(u,c){let l=Object.assign({},n,o(c)),d=lb(u,2,l),p=a(d[0]),y=a(d[1]);return s(p.add(y))},encodeToCurve(u,c){let l=n.encodeDST===void 0?{}:{DST:n.encodeDST},d=Object.assign({},n,l,o(c)),p=lb(u,1,d),y=a(p[0]);return s(y)},mapToCurve(u){if(n.m===1){if(typeof u!="bigint")throw new Error("expected bigint (m=1)");return s(a([u]))}if(!Array.isArray(u))throw new Error("expected array of bigints");if(u.length!==n.m)throw new Error(`expected array of ${n.m} bigints`);for(let c of u)if(typeof c!="bigint")throw new Error("expected array of bigints");return s(a(u))},hashToScalar(u,c){let l=e.Fn.ORDER,d=Object.assign({},n,{DST:kK},o(c),{p:l,m:1});return lb(u,1,d)[0][0]}})}function BK(e,t){let r=rn(e),i=r.ORDER,n=TP;for(let T=i-to;T%Ha===TP;T/=Ha)n+=to;let o=n,a=Ha<<o-to-to,s=a*Ha,u=(i-to)/s,c=(u-to)/Ha,l=s-to,d=a,p=r.pow(t,u),y=r.pow(t,(u+to)/Ha),_=(T,R)=>{let B=p,H=r.pow(R,l),j=r.sqr(H);j=r.mul(j,R);let I=r.mul(T,j);I=r.pow(I,c),I=r.mul(I,H),H=r.mul(I,R),j=r.mul(I,T);let k=r.mul(j,H);I=r.pow(k,d);let D=r.eql(I,r.ONE);H=r.mul(j,y),I=r.mul(k,B),j=r.cmov(H,j,D),k=r.cmov(I,k,D);for(let F=o;F>to;F--){let K=F-Ha;K=Ha<<K-to;let G=r.pow(k,K),S=r.eql(G,r.ONE);H=r.mul(j,B),B=r.mul(B,B),G=r.mul(k,B),j=r.cmov(H,j,S),k=r.cmov(G,k,S)}return{isValid:!r.is0(R)&&(D||r.is0(T)),value:j}};if(r.ORDER%RP===PP){let T=(r.ORDER-PP)/RP,R=r.sqrt(r.neg(t));_=(B,H)=>{let j=r.sqr(H),I=r.mul(B,H);j=r.mul(j,I);let k=r.pow(j,T);k=r.mul(k,I);let D=r.mul(k,R),F=r.mul(r.sqr(k),H),K=r.eql(F,B),G=r.cmov(D,k,K);return{isValid:!r.is0(H)&&K,value:G}}}return _}function CP(e,t){let r=rn(e);yt(t,{},{},"opts");let{A:i,B:n,Z:o}=t;if(!r.isValidNot0(i)||!r.isValidNot0(n)||!r.isValid(o))throw new Error("mapToCurveSimpleSWU: invalid opts");if(r.eql(o,r.neg(r.ONE))||ob(r,o))throw new Error("mapToCurveSimpleSWU: invalid opts");let a=r.mul(n,r.inv(r.mul(o,i))),s=r.add(r.add(r.mul(r.sqr(a),a),r.mul(i,a)),n);if(!ob(r,s))throw new Error("mapToCurveSimpleSWU: invalid opts");let u=BK(r,o);if(!r.isOdd)throw new Error("Field does not have .isOdd()");return c=>{let l,d,p,y,_,T,R,B;l=r.sqr(c),l=r.mul(l,o),d=r.sqr(l),d=r.add(d,l),p=r.add(d,r.ONE),p=r.mul(p,n),y=r.cmov(o,r.neg(d),!r.eql(d,r.ZERO)),y=r.mul(y,i),d=r.sqr(p),T=r.sqr(y),_=r.mul(T,i),d=r.add(d,_),d=r.mul(d,p),T=r.mul(T,y),_=r.mul(T,n),d=r.add(d,_),R=r.mul(l,p);let{isValid:H,value:j}=u(d,T);B=r.mul(l,c),B=r.mul(B,j),R=r.cmov(R,p,H),B=r.cmov(B,j,H);let I=r.isOdd(c)===r.isOdd(B);B=r.cmov(r.neg(B),B,I);let k=gc(r,[y],!0)[0];return R=r.mul(R,k),{x:R,y:B}}}var TP,to,Ha,PP,RP,AK,kK,LP=Br(()=>{g();Ma();Ks();TP=BigInt(0),to=BigInt(1),Ha=BigInt(2),PP=BigInt(3),RP=BigInt(4),AK=Nr;kK="HashToScalar-"});function hb(e){yt(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"}),qa(e.Point);let{Point:t}=e,r=e.Fn===void 0?t.Fn:e.Fn,i=e.hash,n=e.hashToScalar===void 0?(C,V={DST:new Uint8Array})=>{let Y=i(lt(V.DST,C));return r.create(r.isLE?hc(Y):Nr(Y))}:e.hashToScalar,o=Vo(e.H1!==void 0?e.H1:e.name+"rho"),a=Vo(e.H2!==void 0?e.H2:e.name+"chal"),s=Vo(e.H3!==void 0?e.H3:e.name+"nonce"),u=Vo(e.H4!==void 0?e.H4:e.name+"msg"),c=Vo(e.H5!==void 0?e.H5:e.name+"com"),l=Vo(e.HDKG!==void 0?e.HDKG:e.name+"dkg"),d=Vo(e.HID!==void 0?e.HID:e.name+"id"),p=C=>n(C,{DST:o}),y=C=>n(C,{DST:a}),_=C=>n(C,{DST:s}),T=C=>i(lt(u,C)),R=C=>i(lt(c,C)),B=C=>n(C,{DST:l}),H=C=>n(C,{DST:d}),j=(C=mi)=>{if(typeof C!="function")throw new TypeError('"rng" expected function, got type='+typeof C);let V=zs(C(vc(r.ORDER)),r.ORDER,r.isLE);return r.isLE?hc(V):Nr(V)},I=C=>C.toBytes(),k=C=>{let V=t.fromBytes(C);return e.validatePoint&&e.validatePoint(V),V},D=(C,V)=>({identifier:C,hiding:I(t.BASE.multiply(r.fromBytes(V.hiding))),binding:I(t.BASE.multiply(r.fromBytes(V.binding)))}),F=e.adjustPoint===void 0?C=>C:e.adjustPoint,K=C=>{if(!r.isValid(C)||r.is0(C))throw new Error("Invalid identifier "+C);return C},G=C=>Yo(r.toBytes(K(C))),S=(C,V="identifier")=>{bl(C,V);let Y=K(r.fromBytes(lc(C)));if(G(Y)!==C)throw new Error("expected canonical identifier hex");return Y},h={encode:(C,V)=>{let Y=lt(I(C),r.toBytes(V));return e.adjustTx&&(Y=e.adjustTx.encode(Y)),Y},decode:C=>{e.adjustTx&&(C=e.adjustTx.decode(C));let V=C.subarray(0,-r.BYTES),Y=k(V);if(I(Y).length!==V.length)throw new Error("invalid signature encoding");let Q=r.fromBytes(C.subarray(-r.BYTES));return{R:Y,z:Q}}},v=(C=mi)=>{let V=j(C);e.adjustScalar&&(V=e.adjustScalar(V));let Y=t.BASE.multiply(V);return{scalar:V,point:Y}},w="roots are unavailable in FROST polynomial mode",E={info:{G:r.ZERO,oddFactor:r.ZERO,powerOfTwo:0},roots(){throw new Error(w)},brp(){throw new Error(w)},inverse(){throw new Error(w)},omega(){throw new Error(w)},clear(){}},A=IP(r,E),L=(C,V)=>yc(t,C,V),N=(C,V)=>{if(!V.length)throw new Error("empty coefficients");return A.monomial.eval(V,C)},x=(C,V)=>{let Y="invalid parameters";if(!C.some(ce=>r.eql(ce,V)))throw new Error(Y);let Q=new Set(C);if(Q.size!==C.length)throw new Error(Y);if(!Q.has(V))throw new Error(Y);let he=r.ONE,ue=r.ONE;for(let ce of C)r.eql(ce,V)||(he=r.mul(he,ce),ue=r.mul(ue,r.sub(ce,V)));return r.div(he,ue)},m=(C,V)=>{let Y=A.monomial.basis(C,V.length);return L(V,Y)},O=(C,V,Y,Q=mi)=>{if(ro(C),V!==void 0&&Ce(V,r.BYTES,"secret"),Y!==void 0&&$t(Y,"coeffs"),typeof Q!="function")throw new TypeError('"rng" expected function, got type='+typeof Q);let he=V===void 0?j(Q):r.fromBytes(V);if(!Y){Y=[];for(let me=0;me<C.min-1;me++)Y.push(j(Q))}if(Y.length!==C.min-1)throw new Error("wrong coefficients length");let ue=[he,...Y],ce=ue.map(me=>t.BASE.multiply(me));return{coefficients:ue,commitment:ce,secret:he}},z={challenge:(C,V,Y)=>B(lt(r.toBytes(C),I(V),I(Y))),compute(C,V,Y,Q=mi){if(V.length<1)throw new Error("coefficients should have at least one element");let{point:he,scalar:ue}=v(Q),ce=Y[0],me=this.challenge(C,ce,he),_e=r.add(ue,r.mul(V[0],me));return h.encode(he,_e)},validate(C,V,Y){if(V.length<1)throw new Error("commitment should have at least one element");let{R:Q,z:he}=h.decode(Y),ue=k(V[0]),ce=this.challenge(C,ue,Q);if(!Q.equals(t.BASE.multiplyUnsafe(he).subtract(ue.multiplyUnsafe(ce))))throw new Error("invalid proof of knowledge")}},W={challenge:(C,V,Y)=>e.challenge?e.challenge(C,V,Y):y(lt(I(C),I(V),Y)),sign(C,V,Y=mi){let{point:Q,scalar:he}=v(Y),ue=t.BASE.multiply(V),ce=this.challenge(Q,ue,C),me=r.add(he,r.mul(ce,V));return[Q,me]},verify(C,V,Y,Q){e.adjustPoint&&(Q=e.adjustPoint(Q)),e.adjustPoint&&(V=e.adjustPoint(V));let he=this.challenge(V,Q,C),ue=t.BASE.multiplyUnsafe(Y),ce=Q.multiplyUnsafe(he),me=ue.subtract(ce).subtract(V);return me.clearCofactor&&(me=me.clearCofactor()),t.ZERO.equals(me)}},X=(C,V,Y)=>{if(!t.BASE.multiply(Y).equals(m(C,V)))throw new Error("invalid secret share")},ie={fromNumber(C){if(!Number.isSafeInteger(C))throw new Error("expected safe interger");return G(BigInt(C))},derive(C){return bl(C,"s"),G(H(Vo(C)))}},le=(C,V=mi)=>_(lt(V(32),r.toBytes(C))),se=(C,V,Y)=>{let Q=V.map(xe=>[xe.identifier,S(xe.identifier),k(xe.hiding),k(xe.binding)]);Q.sort((xe,Re)=>xe[1]<Re[1]?-1:xe[1]>Re[1]?1:0);let he=[];for(let[xe,Re,je,xi]of Q)he.push(r.toBytes(Re),I(je),I(xi));let ue=R(lt(...he)),ce=lt(I(C),T(Y),ue),me={};for(let[xe,Re]of Q)me[xe]=p(lt(ce,r.toBytes(Re)));let _e=t.ZERO,ve=[],Be=[];for(let[xe,Re,je,xi]of Q){if(t.ZERO.equals(je)||t.ZERO.equals(xi))throw new Error("infinity commitment");_e=_e.add(je),ve.push(xi),Be.push(me[xe])}let ge=_e.add(L(ve,Be));return{identifiers:Q.map(xe=>xe[1]),groupCommitment:ge,bindingFactors:me}},ye=(C,V,Y,Q)=>{let he=F(k(C)),ue=S(Q),{identifiers:ce,groupCommitment:me,bindingFactors:_e}=se(he,V,Y),ve=_e[Q],Be=x(ce,ue),ge=W.challenge(me,he,Y);return{lambda:Be,challenge:ge,bindingFactor:ve,groupCommitment:me}};Object.freeze(ie);let be={Identifier:ie,DKG:Object.freeze({round1:(C,V,Y,Q=mi)=>{let he=S(C,"id");ro(V);let{coefficients:ue,commitment:ce}=O(V,Y,void 0,Q),me=z.compute(he,ue,ce,Q),_e=ce.map(I),ve={identifier:G(he),commitment:_e,proofOfKnowledge:me},Be={identifier:he,coefficients:ue,commitment:ce.map(I),signers:{min:V.min,max:V.max},step:1};return{public:ve,secret:Be}},round2:(C,V)=>{if(yt(C,{identifier:"bigint",commitment:"object",signers:"object"},{coefficients:"object",round2Cache:"object",step:"number"},"secret"),ro(C.signers,"secret.signers"),$t(V,"others"),V.length!==C.signers.max-1)throw new Error("wrong number of round1 packages");if(!C.coefficients||C.step===3)throw new Error("round3 package used in round2");if(C.round2Cache!==void 0)return C.round2Cache;let Y={};for(let Q of V){if(Q.commitment.length!==C.signers.min)throw new Error("wrong number of commitments");let he=S(Q.identifier);if(he===C.identifier)throw new Error("duplicate id="+G(he));z.validate(he,Q.commitment,Q.proofOfKnowledge);for(let ce of Q.commitment)k(ce);if(Y[Q.identifier])throw new Error("Duplicate id="+he);let ue=r.toBytes(N(he,C.coefficients));Y[Q.identifier]={identifier:G(C.identifier),signingShare:ue}}return C.round2Cache=Y,C.step=2,Y},round3:(C,V,Y)=>{if(yt(C,{identifier:"bigint",commitment:"object",signers:"object"},{coefficients:"object",round2Cache:"object",step:"number"},"secret"),ro(C.signers,"secret.signers"),$t(V,"round1"),$t(Y,"round2"),V.length!==C.signers.max-1)throw new Error("wrong length of round1 packages");if(!C.coefficients||C.step!==2)throw new Error("round2 package used in round3");if(Y.length!==V.length)throw new Error("wrong length of round2 packages");let Q={};for(let xe of V){if(!xe.identifier||!xe.commitment)throw new Error("wrong round1 share");Q[xe.identifier]={...xe}}for(let xe of Y){if(!xe.identifier||!xe.signingShare)throw new Error("wrong round2 share");if(!Q[xe.identifier])throw new Error("round1 share for "+xe.identifier+" is missing");Q[xe.identifier].signingShare=xe.signingShare}if(Object.keys(Q).length!==V.length)throw new Error("mismatch identifiers between rounds");let he=r.ZERO;if(C.commitment.length!==C.signers.min)throw new Error("wrong commitments length");let ue=C.commitment.map(k),ce=N(C.identifier,C.coefficients);X(C.identifier,ue,ce);let me=ue.map(I),_e={[G(C.identifier)]:me};for(let xe in Q){let Re=Q[xe];if(!Re.signingShare||!Re.commitment)throw new Error("mismatch identifiers");let je=S(xe),xi=r.fromBytes(Re.signingShare),kt=Re.commitment.map(k);X(C.identifier,kt,xi),he=r.add(he,xi);let Et=G(je);if(_e[Et])throw new Error("duplicated id="+Et);_e[Et]=Re.commitment}he=r.add(he,ce);let ve=new Array(C.signers.min).fill(t.ZERO);for(let xe in _e){let Re=_e[xe];if(Re.length!==C.signers.min)throw new Error("wrong commitments length");for(let je=0;je<Re.length;je++)ve[je]=ve[je].add(k(Re[je]))}let Be=ve.map(I),ge={};for(let xe in _e)ge[xe]=I(m(S(xe),ve));let nt={public:{signers:{min:C.signers.min,max:C.signers.max},commitments:Be,verifyingShares:Object.fromEntries(Object.entries(ge).map(([xe,Re])=>[xe,Re.slice()]))},secret:{identifier:G(C.identifier),signingShare:r.toBytes(he)}};e.adjustDKG&&(nt=e.adjustDKG(nt));for(let xe=0;xe<C.coefficients.length;xe++)C.coefficients[xe]-=C.coefficients[xe];return delete C.coefficients,delete C.round2Cache,C.step=3,nt},clean(C){if(yt(C,{identifier:"bigint",commitment:"object",signers:"object"},{coefficients:"object",round2Cache:"object",step:"number"},"secret"),C.identifier-=C.identifier,C.coefficients)for(let V=0;V<C.coefficients.length;V++)C.coefficients[V]-=C.coefficients[V];delete C.round2Cache,C.step=3}}),trustedDealer(C,V,Y,Q=mi){if(ro(C),V===void 0){V=[];for(let ve=1;ve<=C.max;ve++)V.push(ie.fromNumber(ve))}else if($t(V,"identifiers"),V.length!==C.max)throw new Error("identifiers should be array of "+C.max);let he={};for(let ve of V){let Be=S(ve);if(ve in he)throw new Error("duplicated id="+ve);he[ve]=Be}let ue=O(C,Y,void 0,Q),ce=ue.commitment.map(I),me={},_e={};for(let ve of V){let Be=N(he[ve],ue.coefficients);_e[ve]=I(t.BASE.multiply(Be)),me[ve]={identifier:ve,signingShare:r.toBytes(Be)}}return{public:{signers:{min:C.min,max:C.max},commitments:ce,verifyingShares:_e},secretShares:me}},validateSecret(C,V){yt(C,{identifier:"string",signingShare:"object"},{},"secret"),Ce(C.signingShare,r.BYTES,"secret.signingShare"),yt(V,{signers:"object",commitments:"object",verifyingShares:"object"},{},"pub"),ro(V.signers,"pub.signers"),$t(V.commitments,"pub.commitments");let Y=S(C.identifier),Q=V.commitments.map(k),he=r.fromBytes(C.signingShare);X(Y,Q,he)},commit(C,V=mi){if(yt(C,{identifier:"string",signingShare:"object"},{},"secret"),Ce(C.signingShare,r.BYTES,"secret.signingShare"),typeof V!="function")throw new TypeError('"rng" expected function, got type='+typeof V);let Y=r.fromBytes(C.signingShare),Q=le(Y,V),he=le(Y,V),ue={hiding:r.toBytes(Q),binding:r.toBytes(he)};return{nonces:ue,commitments:D(C.identifier,ue)}},signShare(C,V,Y,Q,he){yt(C,{identifier:"string",signingShare:"object"},{},"secret"),Ce(C.signingShare,r.BYTES,"secret.signingShare"),yt(V,{signers:"object",commitments:"object",verifyingShares:"object"},{},"pub"),ro(V.signers,"pub.signers"),$t(V.commitments,"pub.commitments"),yt(Y,{hiding:"object",binding:"object"},{},"nonces"),Ce(Y.hiding,r.BYTES,"nonces.hiding"),Ce(Y.binding,r.BYTES,"nonces.binding"),$t(Q,"commitmentList"),Ce(he,void 0,"msg"),MP(V.signers,Q.length);let ue=r.fromBytes(Y.hiding),ce=r.fromBytes(Y.binding);if(r.is0(ue)||r.is0(ce))throw new Error("signing nonces already used");let me={identifier:C.identifier,hiding:I(t.BASE.multiply(ue)),binding:I(t.BASE.multiply(ce))},_e=Q.find(Ft=>Ft.identifier===C.identifier);if(!_e)throw new Error("missing signer commitment");if(Yo(_e.hiding)!==Yo(me.hiding)||Yo(_e.binding)!==Yo(me.binding))throw new Error("incorrect signer commitment");e.adjustSecret&&(C=e.adjustSecret(C,V)),e.adjustPublic&&(V=e.adjustPublic(V));let ve=r.fromBytes(C.signingShare),{lambda:Be,challenge:ge,bindingFactor:nt,groupCommitment:xe}=ye(V.commitments[0],Q,he,C.identifier),Re=e.adjustNonces?e.adjustNonces(xe,Y):Y,je=e.adjustNonces?r.fromBytes(Re.hiding):ue,xi=e.adjustNonces?r.fromBytes(Re.binding):ce,kt=r.mul(r.mul(Be,ve),ge),Et=r.mul(xi,nt),ad=r.toBytes(r.add(r.add(je,Et),kt));return Y.hiding.fill(0),Y.binding.fill(0),ad},verifyShare(C,V,Y,Q,he){yt(C,{signers:"object",commitments:"object",verifyingShares:"object"},{},"pub"),ro(C.signers,"pub.signers"),$t(C.commitments,"pub.commitments"),$t(V,"commitmentList"),Ce(Y,void 0,"msg"),S(Q),Ce(he,r.BYTES,"sigShare"),e.adjustPublic&&(C=e.adjustPublic(C));let ue=V.find(xi=>xi.identifier===Q);if(!ue)throw new Error("cannot find identifier commitment");let ce=k(C.verifyingShares[Q]),me=k(ue.hiding),_e=k(ue.binding),{lambda:ve,challenge:Be,bindingFactor:ge,groupCommitment:nt}=ye(C.commitments[0],V,Y,Q),xe=me.add(_e.multiplyUnsafe(ge));e.adjustGroupCommitmentShare&&(xe=e.adjustGroupCommitmentShare(nt,xe));let Re=t.BASE.multiplyUnsafe(r.fromBytes(he)),je=xe.add(ce.multiplyUnsafe(r.mul(Be,ve)));return Re.equals(je)},aggregate(C,V,Y,Q){yt(C,{signers:"object",commitments:"object",verifyingShares:"object"},{},"pub"),ro(C.signers,"pub.signers"),$t(C.commitments,"pub.commitments"),$t(V,"commitmentList"),Ce(Y,void 0,"msg"),yt(Q,{},{},"sigShares");let he=C;e.adjustPublic&&(C=e.adjustPublic(C));try{MP(C.signers,V.length)}catch{throw new Gs("aggregation failed",[])}let ue=V.map(Be=>Be.identifier),ce=new Set;for(let Be of ue){if(ce.has(Be))throw new Gs("aggregation failed",[]);ce.add(Be)}if(ue.length!==Object.keys(Q).length)throw new Gs("aggregation failed",[]);for(let Be of ue)if(!(Be in Q)||!(Be in C.verifyingShares))throw new Gs("aggregation failed",[]);let me=k(C.commitments[0]),{groupCommitment:_e}=se(me,V,Y),ve=r.ZERO;for(let Be of ue)ve=r.add(ve,r.fromBytes(Q[Be]));if(!W.verify(Y,_e,ve,me)){let Be=[];for(let ge of ue)this.verifyShare(he,V,Y,ge,Q[ge])||Be.push(ge);throw new Gs("aggregation failed",Be)}return h.encode(_e,ve)},sign(C,V){let Y=r.fromBytes(V);e.adjustScalar&&(Y=e.adjustScalar(Y));let[Q,he]=W.sign(C,Y);return h.encode(Q,he)},verify(C,V,Y){let Q=e.parsePublicKey?e.parsePublicKey(Y):k(Y),{R:he,z:ue}=h.decode(C);return W.verify(V,he,ue,Q)},combineSecret(C,V){if($t(C,"shares"),ro(V),C.length<V.min||C.length>V.max)throw new Error("wrong secret shares array");let Y=[],Q={};for(let ce of C){let me=S(ce.identifier),_e=G(me);if(Q[_e])throw new Error("duplicated id="+_e);Q[_e]=!0,Y.push([me,r.fromBytes(ce.signingShare)])}let he=Y.map(([ce])=>ce),ue=r.ZERO;for(let[ce,me]of Y)ue=r.add(ue,r.mul(me,x(he,ce)));return r.toBytes(ue)},utils:Object.freeze({Fn:r,randomScalar:(C=mi)=>r.toBytes(v(C).scalar),generateSecretPolynomial:(C,V,Y,Q)=>{let he=O(C,V,Y,Q);return{...he,commitment:he.commitment.map(I)}}})};return Object.freeze(be)}var ro,MP,Gs,DP=Br(()=>{g();Go();Ma();tg();AP();Ks();ro=(e,t="signers")=>{if(yt(e,{min:"number",max:"number"},{},t),Xt(e.min,t+".min"),Xt(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)},MP=(e,t)=>{if(t<e.min||t>e.max)throw new Error("Wrong number of commitments="+t)},Gs=class extends Error{constructor(r,i){super(r);te(this,"cheaters");this.cheaters=i}}});var pb={};Pf(pb,{_HMAC:()=>El,hmac:()=>db});var El,db,ig=Br(()=>{g();Go();El=class{constructor(t,r){te(this,"oHash");te(this,"iHash");te(this,"blockLen");te(this,"outputLen");te(this,"canXOF",!1);te(this,"finished",!1);te(this,"destroyed",!1);if(Lp(t),Jn(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 i=this.blockLen,n=new Uint8Array(i);n.set(r.length>i?t.create().update(r).digest():r);for(let o=0;o<n.length;o++)n[o]^=54;this.iHash.update(n),this.oHash=t.create();for(let o=0;o<n.length;o++)n[o]^=106;this.oHash.update(n),Ii(n)}update(t){return uc(this),this.iHash.update(t),this}digestInto(t){uc(this),Mp(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:i,finished:n,destroyed:o,blockLen:a,outputLen:s,canXOF:u}=this;return t=t,t.finished=n,t.destroyed=o,t.blockLen=a,t.outputLen=s,t.canXOF=u,t.oHash=r._cloneInto(t.oHash),t.iHash=i._cloneInto(t.iHash),t}clone(){return this._cloneInto()}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}},db=(()=>{let e=((t,r,i)=>new El(t,r).update(i).digest());return e.create=(t,r)=>new El(t,r),e})()});var NK,gb,Zo,mb,qP=Br(()=>{g();Ma();NK=BigInt(0),gb=class extends Error{constructor(t=""){super(t)}},Zo={Err:gb,_tlv:{encode:(e,t)=>{let{Err:r}=Zo;if(Xt(e,"tag"),e<0||e>255)throw new r("tlv.encode: wrong tag");if(bl(t,"data"),t.length&1)throw new r("tlv.encode: unpadded data");let i=t.length/2,n=_l(i);if(n.length/2&128)throw new r("tlv.encode: long form length too big");let o=i>127?_l(n.length/2|128):"";return _l(e)+o+n+t},decode(e,t){let{Err:r}=Zo;t=Ce(t,void 0,"DER data");let i=0;if(e<0||e>255)throw new r("tlv.decode: wrong tag");if(t.length<2||t[i++]!==e)throw new r("tlv.decode: wrong tlv");let n=t[i++],o=!!(n&128),a=0;if(!o)a=n;else{let u=n&127;if(!u)throw new r("tlv.decode(long): indefinite length not supported");if(u>4)throw new r("tlv.decode(long): byte length is too big");let c=t.subarray(i,i+u);if(c.length!==u)throw new r("tlv.decode: length bytes not complete");if(c[0]===0)throw new r("tlv.decode(long): zero leftmost byte");for(let l of c)a=a<<8|l;if(i+=u,a<128)throw new r("tlv.decode(long): not minimal encoding")}let s=t.subarray(i,i+a);if(s.length!==a)throw new r("tlv.decode: wrong value length");return{v:s,l:t.subarray(i+a)}}},_int:{encode(e){let{Err:t}=Zo;if(Zp(e),e<NK)throw new t("integer: negative integers are not allowed");let r=_l(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}=Zo;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 Nr(e)}},toSig(e){let{Err:t,_int:r,_tlv:i}=Zo,n=Ce(e,void 0,"signature"),{v:o,l:a}=i.decode(48,n);if(a.length)throw new t("invalid signature: left bytes after parsing");let{v:s,l:u}=i.decode(2,o),{v:c,l}=i.decode(2,u);if(l.length)throw new t("invalid signature: left bytes after parsing");return{r:r.decode(s),s:r.decode(c)}},hexFromSig(e){let{_tlv:t,_int:r}=Zo;yt(e,{r:"bigint",s:"bigint"},{},"sig");let i=t.encode(2,r.encode(e.r)),n=t.encode(2,r.encode(e.s)),o=i+n;return t.encode(48,o)}},mb=(Object.freeze(Zo._tlv),Object.freeze(Zo._int),Object.freeze(Zo))});function CK(e,t,r){eb("scalar",e,$o,r);let[[i,n],[o,a]]=t,s=HP(a*e,r),u=HP(-n*e,r),c=e-s*i-u*o,l=-s*n-u*a,d=c<$o,p=l<$o;d&&(c=-c),p&&(l=-l);let y=wl(Math.ceil(pc(r)/2))+Ws;if(c<$o||c>=y||l<$o||l>=y)throw new Error("splitScalar (endomorphism): failed for k");return{k1neg:d,k1:c,k2neg:p,k2:l}}function bb(e){if(!["compact","recovered","der"].includes(e))throw new Error('Signature format must be "compact", "recovered", or "der"');return e}function vb(e,t){yt(e);let r={};for(let i of Object.keys(t))r[i]=e[i]===void 0?t[i]:e[i];return eo(r.lowS,"lowS"),eo(r.prehash,"prehash"),r.format!==void 0&&bb(r.format),r}function FP(e,t={}){let r=xP("weierstrass",e,t),i=r.Fp,n=r.Fn,o=r.CURVE,{h:a,n:s}=o;yt(t,{},{allowInfinityPoint:"boolean",clearCofactor:"function",isTorsionFree:"function",fromBytes:"function",toBytes:"function",endo:"object",randomBytes:"function"});let{endo:u,allowInfinityPoint:c}=t,l=t.randomBytes===void 0?mi:t.randomBytes;if(u&&(!i.is0(o.a)||typeof u.beta!="bigint"||!Array.isArray(u.basises)))throw new Error('invalid endo: expected "beta": bigint and "basises": array');let d=zP(i,n);function p(){if(!i.isOdd)throw new Error("compression is not supported: Field does not have .isOdd()")}function y(L,N,x){if(c&&N.is0())return Uint8Array.of(0);let{x:m,y:O}=N.toAffine(),z=i.toBytes(m);if(eo(x,"isCompressed"),x){p();let W=!i.isOdd(O);return lt(jP(W),z)}else return lt(Uint8Array.of(4),z,i.toBytes(O))}function _(L){Ce(L,void 0,"Point");let{publicKey:N,publicKeyUncompressed:x}=d,m=L.length,O=L[0],z=L.subarray(1);if(c&&m===1&&O===0)return{x:i.ZERO,y:i.ZERO};if(m===N&&(O===2||O===3)){let W=i.fromBytes(z);if(!i.isValid(W))throw new Error("bad point: is not on curve, wrong x");let X=j(W),ie;try{ie=i.sqrt(X)}catch(ye){let be=ye instanceof Error?": "+ye.message:"";throw new Error("bad point: is not on curve, sqrt error"+be)}p();let le=i.isOdd(ie);return(O&1)===1!==le&&(ie=i.neg(ie)),{x:W,y:ie}}else if(m===x&&O===4){let W=i.BYTES,X=i.fromBytes(z.subarray(0,W)),ie=i.fromBytes(z.subarray(W,W*2));if(!I(X,ie))throw new Error("bad point: is not on curve");return{x:X,y:ie}}else throw new Error(`bad point: got length ${m}, expected compressed=${N} or uncompressed=${x}`)}let T=t.toBytes===void 0?y:t.toBytes,R=t.fromBytes===void 0?_:t.fromBytes,B=i.mul(o.b,yb),H=i.is0(o.a)?L=>i.ZERO:L=>i.mul(o.a,L);function j(L){let N=i.sqr(L),x=i.mul(N,L);return i.add(i.add(x,i.mul(L,o.a)),o.b)}function I(L,N){let x=i.sqr(N),m=j(L);return i.eql(x,m)}if(!I(o.Gx,o.Gy))throw new Error("bad curve params: generator point");let k=i.mul(i.pow(o.a,yb),LK),D=i.mul(i.sqr(o.b),BigInt(27));if(i.is0(i.add(k,D)))throw new Error("bad curve params: a or b");function F(L,N,x=!1){if(!i.isValid(N)||x&&i.is0(N))throw new Error(`bad point coordinate ${L}`);return N}function K(L){if(!(L instanceof v))throw new Error("Weierstrass Point expected")}function G(L){if(!u||!u.basises)throw new Error("no endo");return CK(L,u.basises,n.ORDER)}function S(L,N,x,m){if(!n.isValid(m))throw new RangeError("invalid scalar: out of range");if(u){let{k1neg:O,k1:z,k2neg:W,k2:X}=G(m),ie=new v(i.mul(x.X,u.beta),x.Y,x.Z);L.push(O?x.negate():x,W?ie.negate():ie),N.push(z,X)}else L.push(x),N.push(m)}let h=new WeakSet,A=class A{constructor(N,x,m){te(this,"X");te(this,"Y");te(this,"Z");this.X=F("x",N),this.Y=F("y",x,!0),this.Z=F("z",m),Object.freeze(this)}static CURVE(){return o}static fromAffine(N){let{x,y:m}=N||{};if(!N||!i.isValid(x)||!i.isValid(m))throw new Error("invalid affine point");if(N instanceof A)throw new Error("projective point not allowed");return i.is0(x)&&i.is0(m)?A.ZERO:new A(x,m,i.ONE)}static fromBytes(N){let x=A.fromAffine(R(Ce(N,void 0,"point")));return x.assertValidity(),x}static fromHex(N){return A.fromBytes(lc(N))}get x(){return this.toAffine().x}get y(){return this.toAffine().y}precompute(N=6,x=!0){return E.setWindowSize(this,N),x||this.multiply(yb),this}assertValidity(){let N=this;if(N.is0()){if(t.allowInfinityPoint&&i.is0(N.X)&&i.eql(N.Y,i.ONE)&&i.is0(N.Z))return;throw new Error("bad point: ZERO")}if(h.has(N))return;let{x,y:m}=N.toAffine();if(!i.isValid(x)||!i.isValid(m))throw new Error("bad point: x or y not field elements");if(!I(x,m))throw new Error("bad point: equation left != right");if(!N.isTorsionFree())throw new Error("bad point: not in prime-order subgroup");h.add(N)}hasEvenY(){let{y:N}=this.toAffine();if(!i.isOdd)throw new Error("Field doesn't support isOdd");return!i.isOdd(N)}equals(N){K(N);let{X:x,Y:m,Z:O}=this,{X:z,Y:W,Z:X}=N,ie=i.eql(i.mul(x,X),i.mul(z,O)),le=i.eql(i.mul(m,X),i.mul(W,O));return ie&&le}negate(){return new A(this.X,i.neg(this.Y),this.Z)}double(){let{X:N,Y:x,Z:m}=this,O=i.ZERO,z=i.ZERO,W=i.ZERO,X=i.mul(N,N),ie=i.mul(x,x),le=i.mul(m,m),se=i.mul(N,x);return se=i.add(se,se),W=i.mul(N,m),W=i.add(W,W),O=H(W),z=i.mul(B,le),z=i.add(O,z),O=i.sub(ie,z),z=i.add(ie,z),z=i.mul(O,z),O=i.mul(se,O),W=i.mul(B,W),le=H(le),se=i.sub(X,le),se=H(se),se=i.add(se,W),W=i.add(X,X),X=i.add(W,X),X=i.add(X,le),X=i.mul(X,se),z=i.add(z,X),le=i.mul(x,m),le=i.add(le,le),X=i.mul(le,se),O=i.sub(O,X),W=i.mul(le,ie),W=i.add(W,W),W=i.add(W,W),new A(O,z,W)}add(N){K(N);let{X:x,Y:m,Z:O}=this,{X:z,Y:W,Z:X}=N,ie=i.ZERO,le=i.ZERO,se=i.ZERO,ye=i.mul(x,z),be=i.mul(m,W),C=i.mul(O,X),V=i.add(x,m),Y=i.add(z,W);V=i.mul(V,Y),Y=i.add(ye,be),V=i.sub(V,Y),Y=i.add(x,O);let Q=i.add(z,X);return Y=i.mul(Y,Q),Q=i.add(ye,C),Y=i.sub(Y,Q),Q=i.add(m,O),ie=i.add(W,X),Q=i.mul(Q,ie),ie=i.add(be,C),Q=i.sub(Q,ie),se=H(Y),ie=i.mul(B,C),se=i.add(ie,se),ie=i.sub(be,se),se=i.add(be,se),le=i.mul(ie,se),be=i.add(ye,ye),be=i.add(be,ye),C=H(C),Y=i.mul(B,Y),be=i.add(be,C),C=i.sub(ye,C),C=H(C),Y=i.add(Y,C),ye=i.mul(be,Y),le=i.add(le,ye),ye=i.mul(Q,Y),ie=i.mul(V,ie),ie=i.sub(ie,ye),ye=i.mul(V,be),se=i.mul(Q,se),se=i.add(se,ye),new A(ie,le,se)}subtract(N){return K(N),this.add(N.negate())}is0(){return this.equals(A.ZERO)}multiply(N){if(!n.isValidNot0(N))throw new RangeError("invalid scalar: out of range");let{p:x,f:m}=E.mulSecret(this,N,a,w);return w([x,m])[0]}multiplyUnsafe(N){let x=this,m=N;if(!n.isValid(m))throw new RangeError("invalid scalar: out of range");if(m===$o||x.is0())return A.ZERO;if(m===Ws)return x;if(E.hasWindowSize(this))return E.mulUnsafe(x,m,w);let O=[],z=[];return S(O,z,x,m),yc(A,O,z)}mulAddUnsafe(N,x,m){K(x);let O=[],z=[];return S(O,z,this,N),S(O,z,x,m),yc(A,O,z)}toAffine(N){let x=this,m=N;if(m!=null&&!i.isValid(m))throw new RangeError('"invertedZ" expected valid field element');let{X:O,Y:z,Z:W}=x;if(i.eql(W,i.ONE))return{x:O,y:z};let X=x.is0();m==null&&(m=X?i.ONE:i.inv(W));let ie=i.mul(O,m),le=i.mul(z,m),se=i.mul(W,m);if(X)return{x:i.ZERO,y:i.ZERO};if(!i.eql(se,i.ONE))throw new Error("invZ was invalid");return{x:ie,y:le}}isTorsionFree(){let{isTorsionFree:N}=t;return a===Ws?!0:N?N(A,this):E.mulUnsafe(this,s).is0()}clearCofactor(){let{clearCofactor:N}=t;return a===Ws?this:N?N(A,this):this.multiplyUnsafe(a)}isSmallOrder(){return a===Ws?this.is0():this.clearCofactor().is0()}toBytes(N=!0){return eo(N,"isCompressed"),this.assertValidity(),T(A,this,N)}toHex(N=!0){return Yo(this.toBytes(N))}toString(){return`<Point ${this.is0()?"ZERO":this.toHex()}>`}};te(A,"BASE",new A(o.Gx,o.Gy,i.ONE)),te(A,"ZERO",new A(i.ZERO,i.ONE,i.ZERO)),te(A,"Fp",i),te(A,"Fn",n);let v=A,w=L=>wP(v,L),E=new Qp(v,l);return E.bits>=6&&v.BASE.precompute(6),Object.freeze(v.prototype),Object.freeze(v),v}function jP(e){return Uint8Array.of(e?2:3)}function zP(e,t){return{secretKey:t.BYTES,publicKey:1+e.BYTES,publicKeyUncompressed:1+2*e.BYTES,publicKeyHasPrefix:!0,signature:2*t.BYTES}}function MK(e,t={}){qa(e);let{Fn:r}=e,i=t.randomBytes===void 0?mi:t.randomBytes,n=Object.assign(zP(e.Fp,r),{seed:Math.max(vc(r.ORDER),16)});function o(y){try{let _=r.fromBytes(y);return r.isValidNot0(_)}catch{return!1}}function a(y,_){let{publicKey:T,publicKeyUncompressed:R}=n;try{let B=y.length;return _===!0&&B!==T||_===!1&&B!==R?!1:!!e.fromBytes(y)}catch{return!1}}function s(y){return y=y===void 0?i(n.seed):y,zs(Ce(y,n.seed,"seed"),r.ORDER)}function u(y,_=!0){return e.BASE.multiply(r.fromBytes(y)).toBytes(_)}function c(y){let{secretKey:_,publicKey:T,publicKeyUncompressed:R}=n,B=r._lengths;if(!Qn(y))return;let H=Ce(y,void 0,"key").length,j=H===T||H===R,I=H===_||!!B?.includes(H);if(!(j&&I))return j}function l(y,_,T=!0){if(c(y)===!0)throw new Error("first arg must be private key");if(c(_)===!1)throw new Error("second arg must be public key");let R=r.fromBytes(y);return e.fromBytes(_).multiply(R).toBytes(T)}let d={isValidSecretKey:o,isValidPublicKey:a,randomSecretKey:s},p=eg(s,u);return Object.freeze(d),Object.freeze(n),Object.freeze({getPublicKey:u,getSharedSecret:l,keygen:p,Point:e,utils:d,lengths:n})}function KP(e,t,r={}){qa(e);let i=t;Lp(i),yt(r,{},{hmac:"function",lowS:"boolean",randomBytes:"function",bits2int:"function",bits2int_modN:"function"});let n=Object.assign({},r),o=n.randomBytes===void 0?mi:n.randomBytes,a=n.hmac===void 0?(O,z)=>db(i,O,z):n.hmac,{Fp:s,Fn:u}=e,{ORDER:c,BITS:l}=u,d=vc(c),p=cb(o,d),{keygen:y,getPublicKey:_,getSharedSecret:T,utils:R,lengths:B}=MK(e,n),H={prehash:!0,lowS:typeof n.lowS=="boolean"?n.lowS:!0,format:"compact",extraEntropy:!1},j=c*UP+Ws<s.ORDER;function I(O){let z=c>>Ws;return O>z}function k(O,z){if(!u.isValidNot0(z))throw new Error(`invalid signature ${O}: out of range 1..Point.Fn.ORDER`);return z}function D(){if(!s.isOdd)throw new Error("Field doesn't support isOdd")}function F(O,z,W){return D(),(O===W?0:2)|Number(s.isOdd(z))}function K(){if(j)throw new Error('"recovered" sig type is not supported for cofactor >2 curves')}function G(O,z){bb(z);let W=B.signature,X=z==="compact"?W:z==="recovered"?W+1:void 0;return Ce(O,X)}class S{constructor(z,W,X){te(this,"r");te(this,"s");te(this,"recovery");if(this.r=k("r",z),this.s=k("s",W),X!=null){if(K(),![0,1,2,3].includes(X))throw new Error("invalid recovery id");this.recovery=X}Object.freeze(this)}static fromBytes(z,W=H.format){G(z,W);let X;if(W==="der"){let{r:ye,s:be}=mb.toSig(Ce(z));return new S(ye,be)}W==="recovered"&&(X=z[0],W="compact",z=z.subarray(1));let ie=B.signature/2,le=z.subarray(0,ie),se=z.subarray(ie,ie*2);return new S(u.fromBytes(le),u.fromBytes(se),X)}static fromHex(z,W){return this.fromBytes(lc(z),W)}assertRecovery(){let{recovery:z}=this;if(z==null)throw new Error("invalid recovery id: must be present");return z}addRecoveryBit(z){return new S(this.r,this.s,z)}recoverPublicKey(z){let{r:W,s:X}=this,ie=this.assertRecovery(),le=ie===2||ie===3?W+c:W;if(!s.isValid(le))throw new Error("invalid recovery id: sig.r+curve.n != R.x");let se=s.toBytes(le),ye=e.fromBytes(lt(jP((ie&1)===0),se)),be=u.inv(le),C=v(Ce(z,void 0,"msgHash")),V=u.create(-C*be),Y=u.create(X*be),Q=e.BASE.mulAddUnsafe(V,ye,Y);if(Q.is0())throw new Error("invalid recovery: point at infinify");return Q.assertValidity(),Q}hasHighS(){return I(this.s)}toBytes(z=H.format){if(bb(z),z==="der")return lc(mb.hexFromSig(this));let{r:W,s:X}=this,ie=u.toBytes(W),le=u.toBytes(X);return z==="recovered"?(K(),lt(Uint8Array.of(this.assertRecovery()),ie,le)):lt(ie,le)}toHex(z){return Yo(this.toBytes(z))}}Object.freeze(S.prototype),Object.freeze(S);let h=n.bits2int===void 0?function(z){if(z.length>8192)throw new Error("input is too large");let W=Nr(z),X=z.length*8-l;return X>0?W>>BigInt(X):W}:n.bits2int,v=n.bits2int_modN===void 0?function(z){return u.create(h(z))}:n.bits2int_modN,w=wl(l);function E(O){return eb("num < 2^"+l,O,$o,w),u.toBytes(O)}function A(O,z){return Ce(O,void 0,"message"),z?Ce(i(O),void 0,"prehashed message"):O}function L(O,z,W){let{lowS:X,prehash:ie,extraEntropy:le}=vb(W,H);O=A(O,ie);let se=v(O),ye=u.fromBytes(z);if(!u.isValidNot0(ye))throw new Error("invalid private key");let be=[E(ye),E(se)];if(le!=null&&le!==!1){let Q=le===!0?o(B.secretKey):le;be.push(Ce(Q,void 0,"extraEntropy"))}let C=lt(...be),V=se;function Y(Q){let he=h(Q);if(!u.isValidNot0(he))return;let ue=e.BASE.multiply(he).toAffine(),ce=u.create(ue.x);if(ce===$o)return;let me;if(p!==void 0){let Be=Nr(zs(p(d),c)),ge=u.inv(u.mul(Be,he)),nt=u.mul(Be,V),xe=u.mul(Be,ye);me=u.create(ge*u.create(nt+xe*ce))}else{let Be=pP(he,c);me=u.create(Be*u.create(V+ce*ye))}if(me===$o)return;let _e=F(ue.x,ue.y,ce),ve=me;return X&&I(me)&&(ve=u.neg(me),_e^=1),new S(ce,ve,j?void 0:_e)}return{seed:C,k2sig:Y}}function N(O,z,W={}){let{seed:X,k2sig:ie}=L(O,z,W);return aP(i.outputLen,u.BYTES,a)(X,ie).toBytes(W.format)}function x(O,z,W,X={}){let{lowS:ie,prehash:le,format:se}=vb(X,H);if(W=Ce(W,void 0,"publicKey"),z=A(z,le),!Qn(O)){let ye=O instanceof S?", use sig.toBytes()":"";throw new Error("verify expects Uint8Array signature"+ye)}G(O,se);try{let ye=S.fromBytes(O,se),be=e.fromBytes(W);if(ie&&ye.hasHighS())return!1;let{r:C,s:V}=ye,Y=v(z),Q=u.inv(V),he=u.create(Y*Q),ue=u.create(C*Q),ce=e.BASE.mulAddUnsafe(he,be,ue);if(ce.is0())return!1;let me=ce.toAffine();return!(u.create(me.x)!==C||se==="recovered"&&ye.recovery!==F(me.x,me.y,C))}catch{return!1}}function m(O,z,W={}){let{prehash:X}=vb(W,H);return z=A(z,X),S.fromBytes(O,"recovered").recoverPublicKey(z).toBytes()}return Object.freeze({keygen:y,getPublicKey:_,getSharedSecret:T,utils:R,lengths:B,Point:e,sign:N,verify:x,recoverPublicKey:m,Signature:S,hash:i})}var HP,$o,Ws,UP,yb,LK,VP=Br(()=>{g();ig();Go();Ma();tg();qP();Ks();HP=(e,t)=>(e+(e>=0?t:-t)/UP)/t;$o=BigInt(0),Ws=BigInt(1),UP=BigInt(2),yb=BigInt(3),LK=BigInt(4)});var Il={};Pf(Il,{__TEST:()=>FK,schnorr:()=>jK,schnorr_FROST:()=>WK,secp256k1:()=>HK,secp256k1_FROST:()=>VK,secp256k1_hasher:()=>Sb});function qK(e){let t=ng.p,r=BigInt(3),i=BigInt(6),n=BigInt(11),o=BigInt(22),a=BigInt(23),s=BigInt(44),u=BigInt(88),c=e*e*e%t,l=c*c*e%t,d=Fi(l,r,t)*l%t,p=Fi(d,r,t)*l%t,y=Fi(p,GP,t)*c%t,_=Fi(y,n,t)*y%t,T=Fi(_,o,t)*_%t,R=Fi(T,s,t)*T%t,B=Fi(R,u,t)*R%t,H=Fi(B,s,t)*T%t,j=Fi(H,r,t)*l%t,I=Fi(j,a,t)*_%t,k=Fi(I,i,t)*c%t,D=Fi(k,GP,t);if(!En.eql(En.sqr(D),e))throw new Error("Cannot find square root");return D}function xl(e,...t){let r=WP[e];if(r===void 0){let i=Na(dc(e));r=lt(i,i),WP[e]=r}return Na(lt(r,...t))}function XP(e){let{Fn:t,BASE:r}=bt,i=t.fromBytes(Ce(e,32,"secretKey")),o=r.multiply(i).toAffine();return{scalar:io(o.y)?i:t.neg(i),bytes:$P(o)}}function og(e){let t=En;if(!t.isValidNot0(e))throw new Error("invalid x: Fail if x \u2265 p");let r=t.sqr(e),i=t.add(t.mulN(r,e),BigInt(7)),n=t.sqrt(i);io(n)||(n=t.neg(n));let o=bt.fromAffine({x:e,y:n});return o.assertValidity(),o}function wb(...e){return bt.Fn.create(bc(xl("BIP0340/challenge",...e)))}function YP(e){return XP(e).bytes}function UK(e,t,r=vl(32)){let{Fn:i,BASE:n}=bt,o=Ce(e,void 0,"message"),{bytes:a,scalar:s}=XP(t),u=Ce(r,32,"auxRand"),c=i.toBytes(s^bc(xl("BIP0340/aux",u))),l=xl("BIP0340/nonce",c,a,o),d=i.create(bc(l));if(d===_b)throw new Error("sign failed: k is zero");let y=n.multiply(d).toAffine(),_=io(y.y)?d:i.neg(d),T=$P(y),R=wb(T,a,o),B=new Uint8Array(64);if(B.set(T,0),B.set(i.toBytes(i.create(_+R*s)),32),!JP(B,o,a))throw new Error("sign: Invalid signature produced");return B}function JP(e,t,r){let{Fp:i,Fn:n,BASE:o}=bt,a=Ce(e,64,"signature"),s=Ce(t,void 0,"message"),u=Ce(r,32,"publicKey");try{let c=og(bc(u)),l=a.subarray(0,32),d=bc(l);if(!i.isValidNot0(d))return!1;let p=bc(a.subarray(32,64));if(!n.isValidNot0(p))return!1;let y=wb(l,Ol(c),s),_=o.mulAddUnsafe(p,c,n.neg(y)),{x:T,y:R}=_.toAffine();return!(_.is0()||!io(R)||!i.eql(T,d))}catch{return!1}}function QP(e,t){if(t===void 0)return _b;let r=Ol(e),i=Nr(xl("TapTweak",r,t));if(!bt.Fn.isValid(i))throw new Error("invalid TapTweak hash");return i}function Eb(e){let t=bt.fromBytes(e.commitments[0]);return io(t.y)?e:{signers:{min:e.signers.min,max:e.signers.max},commitments:e.commitments.map(r=>bt.fromBytes(r).negate().toBytes()),verifyingShares:Object.fromEntries(Object.entries(e.verifyingShares).map(([r,i])=>[r,bt.fromBytes(i).negate().toBytes()]))}}function e2(e,t){let r=bt.fromBytes(t.commitments[0]);if(io(r.y))return e;let i=bt.Fn;return{...e,signingShare:i.toBytes(i.neg(i.fromBytes(e.signingShare)))}}function GK(e,t){if(io(e.y))return t;let r=bt.Fn;return{binding:r.toBytes(r.neg(r.fromBytes(t.binding))),hiding:r.toBytes(r.neg(r.fromBytes(t.hiding)))}}function t2(e,t,r){let i=bt.Fn,n=e2(e,t),o=Eb(t),a=QP(bt.fromBytes(o.commitments[0]),r),s=i.toBytes(i.add(i.fromBytes(n.signingShare),a));return{identifier:n.identifier,signingShare:s}}function r2(e,t){let r=Eb(e),i=QP(bt.fromBytes(r.commitments[0]),t);if(i===_b)return r;let n=bt.BASE.multiply(i),o=r.commitments.map((s,u)=>(u===0?bt.fromBytes(s).add(n):bt.fromBytes(s)).toBytes()),a={};for(let s in r.verifyingShares)a[s]=bt.fromBytes(r.verifyingShares[s]).add(n).toBytes();return{signers:{min:r.signers.min,max:r.signers.max},commitments:o,verifyingShares:a}}var ng,DK,_b,GP,En,bt,HK,WP,Ol,$P,io,bc,FK,jK,zK,ZP,KK,Sb,VK,WK,Al=Br(()=>{g();yl();Go();tg();DP();LP();Ks();VP();Ma();ng={p:BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),n:BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),h:BigInt(1),a:BigInt(0),b:BigInt(7),Gx:BigInt("0x79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"),Gy:BigInt("0x483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8")},DK={beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),basises:[[BigInt("0x3086d221a7d46bcde86c90e49284eb15"),-BigInt("0xe4437ed6010e88286f547fa90abfe4c3")],[BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),BigInt("0x3086d221a7d46bcde86c90e49284eb15")]]},_b=BigInt(0),GP=BigInt(2);En=mc(ng.p,{sqrt:qK}),bt=FP(ng,{Fp:En,endo:DK}),HK=KP(bt,Na),WP=Object.create(null);Ol=e=>e.toBytes(!0).slice(1),$P=({x:e})=>En.toBytes(e),io=e=>!En.isOdd(e);bc=Nr;FK=Object.freeze({lift_x:og,frostTweakPublic:r2,frostTweakSecret:t2}),jK=(()=>{let r=i=>(i=i===void 0?vl(48):i,zs(Ce(i,48,"seed"),ng.n));return Object.freeze({keygen:eg(r,YP),getPublicKey:YP,sign:UK,verify:JP,Point:bt,utils:Object.freeze({randomSecretKey:r,taggedHash:xl,lift_x:og,pointToBytes:Ol}),lengths:Object.freeze({secretKey:32,publicKey:32,publicKeyHasPrefix:!1,signature:64,seed:48})})})(),zK=BP(En,[["0x8e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38daaaaa8c7","0x7d3d4c80bc321d5b9f315cea7fd44c5d595d2fc0bf63b92dfff1044f17c6581","0x534c328d23f234e6e2a413deca25caece4506144037c40314ecbd0b53d9dd262","0x8e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38daaaaa88c"],["0xd35771193d94918a9ca34ccbb7b640dd86cd409542f8487d9fe6b745781eb49b","0xedadc6f64383dc1df7c4b2d51b54225406d36b641f5e41bbc52a56612a8c6d14","0x0000000000000000000000000000000000000000000000000000000000000001"],["0x4bda12f684bda12f684bda12f684bda12f684bda12f684bda12f684b8e38e23c","0xc75e0c32d5cb7c0fa9d0a54b12a0a6d5647ab046d686da6fdffc90fc201d71a3","0x29a6194691f91a73715209ef6512e576722830a201be2018a765e85a9ecee931","0x2f684bda12f684bda12f684bda12f684bda12f684bda12f684bda12f38e38d84"],["0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffff93b","0x7a06534bb8bdb49fd5e9e6632722c2989467c1bfc8e8d978dfb425d2685c2573","0x6484aa716545ca2cf3a70c3fa8fe337e0a3d21162f0d6299a7bf8192bfd2a76f","0x0000000000000000000000000000000000000000000000000000000000000001"]].map(e=>e.map(t=>BigInt(t)))),KK=()=>ZP||(ZP=CP(En,{A:BigInt("0x3f8731abdd661adca08a5558f0f5d272e953d363cb6f0e5d405447c01a444533"),B:BigInt("1771"),Z:En.create(BigInt("-11"))})),Sb=NP(bt,e=>{let{x:t,y:r}=KK()(En.create(e[0]));return zK(t,r)},{DST:"secp256k1_XMD:SHA-256_SSWU_RO_",encodeDST:"secp256k1_XMD:SHA-256_SSWU_NU_",p:En.ORDER,m:1,k:128,expand:"xmd",hash:Na}),VK=hb({name:"FROST-secp256k1-SHA256-v1",Point:bt,hashToScalar:Sb.hashToScalar,hash:Na});WK=hb({name:"FROST-secp256k1-SHA256-TR-v1",Point:bt,hashToScalar:Sb.hashToScalar,hash:Na,parsePublicKey(e){if(e.length===32)return og(Nr(e));if(e.length===33)return bt.fromBytes(e);throw new Error(`expected x-only or compressed public key, got length=${e.length}`)},adjustScalar(e){let t=bt.BASE.multiply(e);return io(t.y)?e:bt.Fn.neg(e)},adjustPoint:e=>io(e.y)?e:e.negate(),challenge(e,t,r){return wb(Ol(e),Ol(t),r)},adjustNonces:GK,adjustGroupCommitmentShare:(e,t)=>io(e.y)?t:t.negate(),adjustPublic:Eb,adjustSecret:e2,adjustTx:{encode:e=>e.subarray(1),decode:e=>lt(Uint8Array.of(2),e)},adjustDKG:e=>{let t=new Uint8Array(0);return{public:r2(e.public,t),secret:t2(e.secret,e.public,t)}}})});var nn=P((Poe,a2)=>{"use strict";g();var i2=Ye(),{secp256k1:YK}=(Al(),$i(Il)),Pl=YK.Point,ag=Pl.Fn.ORDER;function ZK(e){return BigInt("0x"+(e.toString(16)||"0"))}function xb(e){var t=e.toString(16);return t.length%2&&(t="0"+t),new i2(t,16)}function sg(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 ZK(e);throw new Error("Invalid Point")}function Tl(e){var t=Object.create(_t.prototype);return t._p=e,t}function n2(e,t){var r=sg(t).toString(16).padStart(64,"0");return Pl.fromHex((e?"03":"02")+r)}function o2(e,t){var r;try{r=n2((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 _t(e,t,r){if(!(this instanceof _t))return new _t(e,t,r);var i,n;try{i=sg(e),n=sg(t)}catch{throw new Error("Invalid Point")}o2(i,n);try{this._p=Pl.fromAffine({x:i,y:n})}catch{throw new Error("Invalid Point")}return this}_t.fromX=function(t,r){try{var i=Tl(n2(t,r))}catch{throw new Error("Invalid X")}return i.validate(),i};_t.getG=function(){return Tl(Pl.BASE)};_t.getN=function(){return xb(ag)};_t.prototype.getX=function(){return xb(this._p.toAffine().x)};_t.prototype.getY=function(){return xb(this._p.toAffine().y)};Object.defineProperty(_t.prototype,"x",{configurable:!0,enumerable:!0,get:function(){return this.getX()}});Object.defineProperty(_t.prototype,"y",{configurable:!0,enumerable:!0,get:function(){return this.getY()}});_t.prototype.mul=function(t){var r=(sg(t)%ag+ag)%ag;return r===0n||this._p.is0()?Tl(Pl.ZERO):Tl(this._p.multiply(r))};_t.prototype.add=function(t){return Tl(this._p.add(t._p))};_t.prototype.mulAdd=function(t,r,i){return this.mul(t).add(r.mul(i))};_t.prototype.eq=function(t){return this._p.equals(t._p)};_t.prototype.isInfinity=function(){return this._p.is0()};_t.prototype.validate=function(){if(this.isInfinity())throw new Error("Point cannot be equal to Infinity");var t=this._p.toAffine();return o2(t.x,t.y),this};_t.pointToCompressed=function(t){var r=t.getX().toBuffer({size:32}),i=t.getY().toBuffer({size:32}),n,o=i[i.length-1]%2;return o?n=f.Buffer.from([3]):n=f.Buffer.from([2]),f.Buffer.concat([n,r])};_t.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 i=i2.fromBuffer(e.slice(1,33));return _t.fromX(r,i)};_t.prototype.toBuffer=function(){return _t.pointToCompressed(this)};_t.prototype.toHex=function(){return this.toBuffer().toString("hex")};_t.fromBuffer=function(e){return _t.pointFromCompressed(e)};_t.fromHex=function(e){return _t.fromBuffer(f.Buffer.from(e,"hex"))};a2.exports=_t});var ei=P((koe,c2)=>{"use strict";g();var u2=Je(),$K=Oe(),s2=function(t){return u2.isString(t)?/^[0-9a-fA-F]+$/.test(t):!1};c2.exports={isValidJSON:function(t){var r;if(!u2.isString(t))return!1;try{r=JSON.parse(t)}catch{return!1}return typeof r=="object"},isHexa:s2,isHexaString:s2,defineImmutable:function(t,r){return Object.keys(r).forEach(function(i){Object.defineProperty(t,i,{configurable:!1,enumerable:!0,value:r[i]})}),t},isNaturalNumber:function(t){return typeof t=="number"&&isFinite(t)&&Math.floor(t)===t&&t>=0},integerAsBuffer:function(t){$K.checkArgumentType(t,"number","integer");let r=f.Buffer.allocUnsafe(4);return r.writeUInt32BE(t,0),r}}});var ut=P((Noe,l2)=>{"use strict";g();var Ys=Ye(),XK=Je(),yi=Oe(),JK=ei(),Ze=function e(t,r){if(!(this instanceof e))return new e(t,r);if(t instanceof Ys)this.set({r:t,s:r});else if(t){var i=t;this.set(i)}};Ze.prototype.set=function(e){return this.r=e.r||this.r||void 0,this.s=e.s||this.s||void 0,this.i=typeof e.i<"u"?e.i:this.i,this.compressed=typeof e.compressed<"u"?e.compressed:this.compressed,this.nhashtype=e.nhashtype||this.nhashtype||void 0,this};Ze.fromCompact=function(e){yi.checkArgument(f.Buffer.isBuffer(e),"Argument is expected to be a Buffer");var t=new Ze,r=!0,i=e.slice(0,1)[0]-27-4;i<0&&(r=!1,i=i+4);var n=e.slice(1,33),o=e.slice(33,65);return yi.checkArgument(i===0||i===1||i===2||i===3,new Error("i must be 0, 1, 2, or 3")),yi.checkArgument(n.length===32,new Error("r must be 32 bytes")),yi.checkArgument(o.length===32,new Error("s must be 32 bytes")),t.compressed=r,t.i=i,t.r=Ys.fromBuffer(n),t.s=Ys.fromBuffer(o),t};Ze.fromDER=Ze.fromBuffer=function(e,t){var r=Ze.parseDER(e,t),i=new Ze;return i.r=r.r,i.s=r.s,i};Ze.fromTxFormat=function(e){var t=e.readUInt8(e.length-1),r=e.slice(0,e.length-1),i=Ze.fromDER(r,!1);return i.nhashtype=t,i};Ze.fromString=function(e){var t=f.Buffer.from(e,"hex");return Ze.fromDER(t)};function f2(e,t){yi.checkArgument(t.length>0,new Error("Length of "+e+" is zero")),yi.checkArgument(!(t[0]&128),new Error("Value of "+e+" is negative")),yi.checkArgument(!(t.length>1&&t[0]===0&&!(t[1]&128)),new Error("Value of "+e+" is excessively padded"))}Ze.parseDER=function(e,t){yi.checkArgument(f.Buffer.isBuffer(e),new Error("DER formatted signature should be a buffer")),XK.isUndefined(t)&&(t=!0);var r=e[0];yi.checkArgument(r===48,new Error("Header byte should be 0x30"));var i=e[1],n=e.slice(2).length;yi.checkArgument(!t||i===n,new Error("Length byte should length of what follows")),i=i<n?i:n;var o=e[2];yi.checkArgument(o===2,new Error("Integer byte for r should be 0x02"));var a=e[3],s=e.slice(4,4+a),u=Ys.fromBuffer(s),c=e[4]===0;yi.checkArgument(a===s.length,new Error("Length of r incorrect"));var l=e[4+a+0];yi.checkArgument(l===2,new Error("Integer byte for s should be 0x02"));var d=e[4+a+1],p=e.slice(4+a+2,4+a+2+d),y=Ys.fromBuffer(p),_=e[4+a+2]===0;yi.checkArgument(d===p.length,new Error("Length of s incorrect"));var T=4+a+2+d;yi.checkArgument(i===T-2,new Error("Length of signature incorrect")),t&&(f2("r",s),f2("s",p));var R={header:r,length:i,rheader:o,rlength:a,rneg:c,rbuf:s,r:u,sheader:l,slength:d,sneg:_,sbuf:p,s:y};return R};Ze.prototype.toCompact=function(e,t){if(e=typeof e=="number"?e:this.i,t=typeof t=="boolean"?t:this.compressed,!(e===0||e===1||e===2||e===3))throw new Error("i must be equal to 0, 1, 2, or 3");var r=e+27+4;t===!1&&(r=r-4);var i=f.Buffer.from([r]),n=this.r.toBuffer({size:32}),o=this.s.toBuffer({size:32});return f.Buffer.concat([i,n,o])};Ze.prototype.toBuffer=Ze.prototype.toDER=function(){var e=this.r.toBuffer(),t=this.s.toBuffer(),r=!!(e[0]&128),i=!!(t[0]&128),n=r?f.Buffer.concat([f.Buffer.from([0]),e]):e,o=i?f.Buffer.concat([f.Buffer.from([0]),t]):t,a=n.length,s=o.length,u=2+a+2+s,c=2,l=2,d=48,p=f.Buffer.concat([f.Buffer.from([d,u,c,a]),n,f.Buffer.from([l,s]),o]);return p};Ze.prototype.toString=function(){var e=this.toDER();return e.toString("hex")};Ze.isTxDER=function(e){if(e.length<9||e.length>73||e[0]!==48||e[1]!==e.length-3)return!1;var t=e[3];if(5+t>=e.length)return!1;var r=e[5+t];if(t+r+7!==e.length)return!1;var i=e.slice(4);if(e[2]!==2||t===0||i[0]&128||t>1&&i[0]===0&&!(i[1]&128))return!1;var n=e.slice(6+t);return!(e[6+t-2]!==2||r===0||n[0]&128||r>1&&n[0]===0&&!(n[1]&128))};Ze.prototype.hasLowS=function(){return!(this.s.lt(new Ys(1))||this.s.gt(new Ys("7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0","hex")))};Ze.prototype.hasDefinedHashtype=function(){if(!JK.isNaturalNumber(this.nhashtype))return!1;var e=this.nhashtype&31;return!(e<Ze.SIGHASH_ALL||e>Ze.SIGHASH_SINGLE)};Ze.prototype.toTxFormat=function(){var e=this.toDER(),t=f.Buffer.alloc(1);return t.writeUInt8(this.nhashtype,0),f.Buffer.concat([e,t])};Ze.SIGHASH_ALL=1;Ze.SIGHASH_NONE=2;Ze.SIGHASH_SINGLE=3;Ze.SIGHASH_CHRONICLE=32;Ze.SIGHASH_FORKID=64;Ze.SIGHASH_ANYONECANPAY=128;Ze.prototype.isCanonical=function(){var e=nn(),t=e.getN().shrn(1);return this.s.lte(t)};Ze.prototype.toCanonical=function(){if(this.isCanonical())return new Ze({r:this.r,s:this.s,i:this.i,compressed:this.compressed,nhashtype:this.nhashtype});var e=nn(),t=e.getN(),r=t.sub(this.s);return new Ze({r:this.r,s:r,i:this.i,compressed:this.compressed,nhashtype:this.nhashtype})};Ze.prototype.validate=function(){if(!this.r||!this.s)throw new Error("Signature missing r or s component");if(this.r.isZero())throw new Error("Signature r component is zero");if(this.s.isZero())throw new Error("Signature s component is zero");var e=nn(),t=e.getN();if(this.r.gte(t))throw new Error("Signature r component >= curve order");if(this.s.gte(t))throw new Error("Signature s component >= curve order");if(this.r.isNeg())throw new Error("Signature r component is negative");if(this.s.isNeg())throw new Error("Signature s component is negative");return!0};Ze.prototype.isValid=function(){try{return this.validate(),!0}catch{return!1}};Ze.prototype.applySecurityPatches=function(){var e=nn(),t=e.getN(),r=t.shrn(1);if(this.r.isZero()||this.s.isZero())throw new Error("Invalid signature: zero r or s");if(this.r.gte(t)||this.s.gte(t))throw new Error("Invalid signature: out of range");if(this.s.gt(r))throw new Error("Invalid signature: non-canonical (high) s");return this};l2.exports=Ze});var d2=P((Loe,h2)=>{"use strict";g();var ug=Kt(),Xo=Oe(),Er=h2.exports;Er.sha1=function(e){return Xo.checkArgument(f.Buffer.isBuffer(e)),ug.createHash("sha1").update(e).digest()};Er.sha1.blocksize=512;Er.sha256=function(e){return Xo.checkArgument(f.Buffer.isBuffer(e)),ug.createHash("sha256").update(e).digest()};Er.sha256.blocksize=512;Er.sha256sha256=function(e){return Xo.checkArgument(f.Buffer.isBuffer(e)),Er.sha256(Er.sha256(e))};Er.ripemd160=function(e){return Xo.checkArgument(f.Buffer.isBuffer(e)),ug.createHash("ripemd160").update(e).digest()};Er.sha256ripemd160=function(e){return Xo.checkArgument(f.Buffer.isBuffer(e)),Er.ripemd160(Er.sha256(e))};Er.sha512=function(e){return Xo.checkArgument(f.Buffer.isBuffer(e)),ug.createHash("sha512").update(e).digest()};Er.sha512.blocksize=1024;Er.hmac=function(e,t,r){Xo.checkArgument(f.Buffer.isBuffer(t)),Xo.checkArgument(f.Buffer.isBuffer(r)),Xo.checkArgument(e.blocksize);var i=e.blocksize/8;if(r.length>i)r=e(r);else if(r.length<i){var n=f.Buffer.alloc(i);n.fill(0),r.copy(n),r=n}var o=f.Buffer.alloc(i);o.fill(92);var a=f.Buffer.alloc(i);a.fill(54);for(var s=f.Buffer.alloc(i),u=f.Buffer.alloc(i),c=0;c<i;c++)s[c]=o[c]^r[c],u[c]=a[c]^r[c];return e(f.Buffer.concat([s,e(f.Buffer.concat([u,t]))]))};Er.sha256hmac=function(e,t){return Er.hmac(Er.sha256,e,t)};Er.sha512hmac=function(e,t){return Er.hmac(Er.sha512,e,t)}});var _2={};Pf(_2,{_MD5:()=>hg,_RIPEMD160:()=>dg,_SHA1:()=>lg,md5:()=>iV,ripemd160:()=>fV,sha1:()=>QK});function p2(e,t,r,i){return e===0?t^r^i:e===1?t&r|~t&i:e===2?(t|~r)^i:e===3?t&i|r&~i:t^(r|~i)}var _c,Ua,lg,QK,eV,tV,cg,Ob,rV,hg,iV,nV,g2,oV,m2,v2,y2,b2,aV,sV,uV,cV,fg,dg,fV,w2=Br(()=>{g();$y();Go();_c=Uint32Array.from([1732584193,4023233417,2562383102,271733878,3285377520]),Ua=new Uint32Array(80),lg=class extends Wo{constructor(){super(64,20,8,!1);te(this,"A",_c[0]|0);te(this,"B",_c[1]|0);te(this,"C",_c[2]|0);te(this,"D",_c[3]|0);te(this,"E",_c[4]|0)}get(){let{A:r,B:i,C:n,D:o,E:a}=this;return[r,i,n,o,a]}set(r,i,n,o,a){this.A=r|0,this.B=i|0,this.C=n|0,this.D=o|0,this.E=a|0}_cloneInto(r){return(r||(r=new this.constructor)).set(...this.get()),this._cloneIntoMeta(r)}process(r,i){for(let c=0;c<16;c++,i+=4)Ua[c]=r.getUint32(i,!1);for(let c=16;c<80;c++)Ua[c]=Ko(Ua[c-3]^Ua[c-8]^Ua[c-14]^Ua[c-16],1);let{A:n,B:o,C:a,D:s,E:u}=this;for(let c=0;c<80;c++){let l,d;c<20?(l=cc(o,a,s),d=1518500249):c<40?(l=o^a^s,d=1859775393):c<60?(l=Hp(o,a,s),d=2400959708):(l=o^a^s,d=3395469782);let p=Ko(n,5)+l+u+d+Ua[c]|0;u=s,s=a,a=Ko(o,30),o=n,n=p}n=n+this.A|0,o=o+this.B|0,a=a+this.C|0,s=s+this.D|0,u=u+this.E|0,this.set(n,o,a,s,u)}roundClean(){Ii(Ua)}destroy(){this.destroyed=!0,this.set(0,0,0,0,0),Ii(this.buffer)}},QK=Sn(()=>new lg),eV=Math.pow(2,32),tV=Array.from({length:64},(e,t)=>Math.floor(eV*Math.abs(Math.sin(t+1)))),cg=_c.slice(0,4),Ob=new Uint32Array(16),rV=(()=>{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])})(),hg=class extends Wo{constructor(){super(64,16,8,!0);te(this,"A",cg[0]|0);te(this,"B",cg[1]|0);te(this,"C",cg[2]|0);te(this,"D",cg[3]|0)}get(){let{A:r,B:i,C:n,D:o}=this;return[r,i,n,o]}set(r,i,n,o){this.A=r|0,this.B=i|0,this.C=n|0,this.D=o|0}_cloneInto(r){return(r||(r=new this.constructor)).set(...this.get()),this._cloneIntoMeta(r)}process(r,i){for(let u=0;u<16;u++,i+=4)Ob[u]=r.getUint32(i,!0);let{A:n,B:o,C:a,D:s}=this;for(let u=0;u<64;u++){let c,l;u<16?(c=cc(o,a,s),l=u):u<32?(c=cc(s,o,a),l=(5*u+1)%16):u<48?(c=o^a^s,l=(3*u+5)%16):(c=a^(o|~s),l=7*u%16),c=c+n+tV[u]+Ob[l],n=s,s=a,a=o,o=o+Ko(c,rV[u])}n=n+this.A|0,o=o+this.B|0,a=a+this.C|0,s=s+this.D|0,this.set(n,o,a,s)}roundClean(){Ii(Ob)}destroy(){this.destroyed=!0,this.set(0,0,0,0),Ii(this.buffer)}},iV=Sn(()=>new hg),nV=Uint8Array.from([7,4,13,1,10,6,15,3,12,0,9,5,2,14,11,8]),g2=Uint8Array.from(new Array(16).fill(0).map((e,t)=>t)),oV=g2.map(e=>(9*e+5)%16),m2=(()=>{let r=[[g2],[oV]];for(let i=0;i<4;i++)for(let n of r)n.push(n[i].map(o=>nV[o]));return r})(),v2=m2[0],y2=m2[1],b2=[[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)),aV=v2.map((e,t)=>e.map(r=>b2[t][r])),sV=y2.map((e,t)=>e.map(r=>b2[t][r])),uV=Uint32Array.from([0,1518500249,1859775393,2400959708,2840853838]),cV=Uint32Array.from([1352829926,1548603684,1836072691,2053994217,0]);fg=new Uint32Array(16),dg=class extends Wo{constructor(){super(64,20,8,!0);te(this,"h0",1732584193);te(this,"h1",-271733879);te(this,"h2",-1732584194);te(this,"h3",271733878);te(this,"h4",-1009589776)}get(){let{h0:r,h1:i,h2:n,h3:o,h4:a}=this;return[r,i,n,o,a]}set(r,i,n,o,a){this.h0=r|0,this.h1=i|0,this.h2=n|0,this.h3=o|0,this.h4=a|0}_cloneInto(r){return(r||(r=new this.constructor)).set(...this.get()),this._cloneIntoMeta(r)}process(r,i){for(let _=0;_<16;_++,i+=4)fg[_]=r.getUint32(i,!0);let n=this.h0|0,o=n,a=this.h1|0,s=a,u=this.h2|0,c=u,l=this.h3|0,d=l,p=this.h4|0,y=p;for(let _=0;_<5;_++){let T=4-_,R=uV[_],B=cV[_],H=v2[_],j=y2[_],I=aV[_],k=sV[_];for(let D=0;D<16;D++){let F=Ko(n+p2(_,a,u,l)+fg[H[D]]+R,I[D])+p|0;n=p,p=l,l=Ko(u,10)|0,u=a,a=F}for(let D=0;D<16;D++){let F=Ko(o+p2(T,s,c,d)+fg[j[D]]+B,k[D])+y|0;o=y,y=d,d=Ko(c,10)|0,c=s,s=F}}this.set(this.h1+u+d|0,this.h2+l+y|0,this.h3+p+o|0,this.h4+n+s|0,this.h0+a+c|0)}roundClean(){Ii(fg)}destroy(){this.destroyed=!0,Ii(this.buffer),this.set(0,0,0,0,0)}},fV=Sn(()=>new dg)});var E2=P((Foe,S2)=>{"use strict";g();var{sha256:lV,sha512:hV}=(yl(),$i(Wp)),{sha1:dV,ripemd160:pV}=(w2(),$i(_2)),Jo=Oe(),xr=S2.exports;xr.sha1=function(e){return Jo.checkArgument(f.Buffer.isBuffer(e)),f.Buffer.from(dV(e))};xr.sha1.blocksize=512;xr.sha256=function(e){return Jo.checkArgument(f.Buffer.isBuffer(e)),f.Buffer.from(lV(e))};xr.sha256.blocksize=512;xr.sha256sha256=function(e){return Jo.checkArgument(f.Buffer.isBuffer(e)),xr.sha256(xr.sha256(e))};xr.ripemd160=function(e){return Jo.checkArgument(f.Buffer.isBuffer(e)),f.Buffer.from(pV(e))};xr.sha256ripemd160=function(e){return Jo.checkArgument(f.Buffer.isBuffer(e)),xr.ripemd160(xr.sha256(e))};xr.sha512=function(e){return Jo.checkArgument(f.Buffer.isBuffer(e)),f.Buffer.from(hV(e))};xr.sha512.blocksize=1024;xr.hmac=function(e,t,r){Jo.checkArgument(f.Buffer.isBuffer(t)),Jo.checkArgument(f.Buffer.isBuffer(r)),Jo.checkArgument(e.blocksize);var i=e.blocksize/8;if(r.length>i)r=e(r);else if(r.length<i){var n=f.Buffer.alloc(i);n.fill(0),r.copy(n),r=n}var o=f.Buffer.alloc(i);o.fill(92);var a=f.Buffer.alloc(i);a.fill(54);for(var s=f.Buffer.alloc(i),u=f.Buffer.alloc(i),c=0;c<i;c++)s[c]=o[c]^r[c],u[c]=a[c]^r[c];return e(f.Buffer.concat([s,e(f.Buffer.concat([u,t]))]))};xr.sha256hmac=function(e,t){return xr.hmac(xr.sha256,e,t)};xr.sha512hmac=function(e,t){return xr.hmac(xr.sha512,e,t)}});var ke=P((zoe,O2)=>{"use strict";g();var x2={sha1:"a9993e364706816aba3e25717850c26c9cd0d89d",sha256:"ba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad",sha512:"ddaf35a193617abacc417349ae20413112e6fa4e89a97ea20a9eeee64b55d39a2192992a274fc1a836ba3c23a3feebbd454d4423643ce80e2a9ac94fa54ca49f",ripemd160:"8eb208f7e05d987a9b044a8e98c6b087f15a0bfc"};function gV(){var e;try{e=Kt()}catch{return!1}if(!e||typeof e.createHash!="function")return!1;for(var t=Object.keys(x2),r=0;r<t.length;r++){var i=t[r];try{if(e.createHash(i).update("abc").digest("hex")!==x2[i])return!1}catch{return!1}}return!0}O2.exports=gV()?d2():E2()});var ta=P((Voe,T2)=>{"use strict";g();var Qo=Je(),Rl=ei(),Zs=[],kl={};function I2(){}I2.prototype.toString=function(){return this.name};function Bl(e,t){if(~Zs.indexOf(e))return e;if(t){Qo.isArray(t)||(t=[t]);for(var r=0;r<Zs.length;r++){var i=Zs[r],n=Qo.pick(i,t),o=Qo.values(n);if(~o.indexOf(e))return i}return}return kl[e]}function pg(e){for(var t=[],r=0;r<e.length;r++)t.push(e.charCodeAt(r)&31);return t}function Nl(e){var t=new I2;Rl.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&&Qo.extend(t,{cashAddrPrefix:e.cashAddrPrefix,cashAddrPrefixArray:pg(e.cashAddrPrefix)}),e.networkMagic&&Qo.extend(t,{networkMagic:Rl.integerAsBuffer(e.networkMagic)}),e.port&&Qo.extend(t,{port:e.port}),e.dnsSeeds&&Qo.extend(t,{dnsSeeds:e.dnsSeeds}),Zs.push(t),mV(t,r),t}function mV(e,t){for(var r=0;r<t.length;r++){var i=t[r],n=e[i];!Qo.isUndefined(n)&&!Qo.isObject(n)&&(kl[n]=e)}}function vV(e,t){for(var r=0;r<t.length;r++){var i=t[r];kl[i]===e&&delete kl[i]}}function yV(e){for(var t=0;t<Zs.length;t++)Zs[t]===e&&Zs.splice(t,1);vV(e,Object.keys(kl))}var gg={livenet:3823236072,testnet:4108710900,regtest:3669344250,stn:4224632057},A2=["seed.bitcoinsv.org","seed.bitcoinunlimited.info"],Fa={PORT:18333,NETWORK_MAGIC:gg.testnet,DNS_SEEDS:A2,PREFIX:"testnet",CASHADDRPREFIX:"bchtest"},ea={PORT:18444,NETWORK_MAGIC:gg.regtest,DNS_SEEDS:[],PREFIX:"regtest",CASHADDRPREFIX:"bchreg"},ja={PORT:9333,NETWORK_MAGIC:gg.stn,DNS_SEEDS:["stn-seed.bitcoinsv.io"],PREFIX:"stn",CASHADDRPREFIX:"bsvstn"},bV={name:"livenet",alias:"mainnet",prefix:"bitcoin",cashAddrPrefix:"bitcoincash",pubkeyhash:0,privatekey:128,scripthash:5,xpubkey:76067358,xprivkey:76066276,networkMagic:gg.livenet,port:8333,dnsSeeds:A2},_V={name:"testnet",prefix:Fa.PREFIX,cashAddrPrefix:Fa.CASHADDRPREFIX,pubkeyhash:111,privatekey:239,scripthash:196,xpubkey:70617039,xprivkey:70615956,networkMagic:Fa.NETWORK_MAGIC},wV={name:"regtest",prefix:ea.PREFIX,cashAddrPrefix:ea.CASHADDRPREFIX,pubkeyhash:111,privatekey:239,scripthash:196,xpubkey:70617039,xprivkey:70615956,networkMagic:ea.NETWORK_MAGIC,port:ea.PORT,dnsSeeds:[],indexBy:["port","name","cashAddrPrefix","networkMagic"]},SV={name:"stn",prefix:ja.PREFIX,cashAddrPrefix:ja.CASHADDRPREFIX,pubkeyhash:111,privatekey:239,scripthash:196,xpubkey:70617039,xprivkey:70615956,networkMagic:ja.NETWORK_MAGIC,indexBy:["port","name","cashAddrPrefix","networkMagic"]};Nl(_V);Nl(SV);Nl(wV);Nl(bV);var Ib=Bl("livenet"),EV=Bl("regtest"),no=Bl("testnet"),xV=Bl("stn");Object.defineProperty(no,"port",{enumerable:!0,configurable:!1,get:function(){return this.regtestEnabled?ea.PORT:this.stnEnabled?ja.PORT:Fa.PORT}});Object.defineProperty(no,"networkMagic",{enumerable:!0,configurable:!1,get:function(){return this.regtestEnabled?Rl.integerAsBuffer(ea.NETWORK_MAGIC):this.stnEnabled?Rl.integerAsBuffer(ja.NETWORK_MAGIC):Rl.integerAsBuffer(Fa.NETWORK_MAGIC)}});Object.defineProperty(no,"dnsSeeds",{enumerable:!0,configurable:!1,get:function(){return this.regtestEnabled?ea.DNS_SEEDS:this.stnEnabled?ja.DNS_SEEDS:Fa.DNS_SEEDS}});Object.defineProperty(no,"cashAddrPrefix",{enumerable:!0,configurable:!1,get:function(){return this.regtestEnabled?ea.CASHADDRPREFIX:this.stnEnabled?ja.CASHADDRPREFIX:Fa.CASHADDRPREFIX}});Object.defineProperty(no,"cashAddrPrefixArray",{enumerable:!0,configurable:!1,get:function(){return this.regtestEnabled?pg(ea.CASHADDRPREFIX):this.stnEnabled?pg(ja.CASHADDRPREFIX):pg(Fa.CASHADDRPREFIX)}});function OV(){no.regtestEnabled=!0}function IV(){no.regtestEnabled=!1}function AV(){no.stnEnabled=!0}function TV(){no.stnEnabled=!1}T2.exports={add:Nl,remove:yV,defaultNetwork:Ib,livenet:Ib,mainnet:Ib,testnet:no,regtest:EV,stn:xV,get:Bl,enableRegtest:OV,disableRegtest:IV,enableStn:AV,disableStn:TV}});var wc=P((Woe,B2)=>{"use strict";g();var P2=Je(),mg=ac(),R2=jt(),k2=ke().sha256sha256,Vt=function e(t){if(!(this instanceof e))return new e(t);if(f.Buffer.isBuffer(t)){var r=t;this.fromBuffer(r)}else if(typeof t=="string"){var i=t;this.fromString(i)}};Vt.prototype.set=function(e){return this.buf=e.buf||this.buf||void 0,this};Vt.validChecksum=function(t,r){return P2.isString(t)&&(t=R2.Buffer.from(mg.decode(t))),P2.isString(r)&&(r=R2.Buffer.from(mg.decode(r))),r||(r=t.slice(-4),t=t.slice(0,-4)),Vt.checksum(t).toString("hex")===r.toString("hex")};Vt.decode=function(e){if(typeof e!="string")throw new Error("Input must be a string");var t=f.Buffer.from(mg.decode(e));if(t.length<4)throw new Error("Input string too short");var r=t.slice(0,-4),i=t.slice(-4),n=k2(r),o=n.slice(0,4);if(i.toString("hex")!==o.toString("hex"))throw new Error("Checksum mismatch");return r};Vt.checksum=function(e){return k2(e).slice(0,4)};Vt.encode=function(e){if(!f.Buffer.isBuffer(e))throw new Error("Input must be a buffer");var t=f.Buffer.alloc(e.length+4),r=Vt.checksum(e);return e.copy(t),r.copy(t,e.length),mg.encode(t)};Vt.prototype.fromBuffer=function(e){return this.buf=e,this};Vt.fromBuffer=function(e){return new Vt().fromBuffer(e)};Vt.fromHex=function(e){return Vt.fromBuffer(f.Buffer.from(e,"hex"))};Vt.prototype.fromString=function(e){var t=Vt.decode(e);return this.buf=t,this};Vt.fromString=function(e){var t=Vt.decode(e);return new Vt(t)};Vt.prototype.toBuffer=function(){return this.buf};Vt.prototype.toHex=function(){return this.toBuffer().toString("hex")};Vt.prototype.toString=function(){return Vt.encode(this.buf)};B2.exports=Vt});var Pb=P((Zoe,M2)=>{"use strict";g();function za(e){"@babel/helpers - typeof";return za=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},za(e)}function N2(e,t){for(var r=0;r<t.length;r++){var i=t[r];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,RV(i.key),i)}}function PV(e,t,r){return t&&N2(e.prototype,t),r&&N2(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e}function RV(e){var t=kV(e,"string");return za(t)==="symbol"?t:String(t)}function kV(e,t){if(za(e)!=="object"||e===null)return e;var r=e[Symbol.toPrimitive];if(r!==void 0){var i=r.call(e,t||"default");if(za(i)!=="object")return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}function BV(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function NV(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&&Tb(e,t)}function Tb(e,t){return Tb=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(i,n){return i.__proto__=n,i},Tb(e,t)}function CV(e){var t=DV();return function(){var i=vg(e),n;if(t){var o=vg(this).constructor;n=Reflect.construct(i,arguments,o)}else n=i.apply(this,arguments);return LV(this,n)}}function LV(e,t){if(t&&(za(t)==="object"||typeof t=="function"))return t;if(t!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return MV(e)}function MV(e){if(e===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function DV(){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 vg(e){return vg=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(r){return r.__proto__||Object.getPrototypeOf(r)},vg(e)}var L2={},Sc,Ab;function Cl(e,t,r){r||(r=Error);function i(o,a,s){return typeof t=="string"?t:t(o,a,s)}var n=(function(o){NV(s,o);var a=CV(s);function s(u,c,l){var d;return BV(this,s),d=a.call(this,i(u,c,l)),d.code=e,d}return PV(s)})(r);L2[e]=n}function C2(e,t){if(Array.isArray(e)){var r=e.length;return e=e.map(function(i){return String(i)}),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 qV(e,t,r){return e.substr(!r||r<0?0:+r,t.length)===t}function HV(e,t,r){return(r===void 0||r>e.length)&&(r=e.length),e.substring(r-t.length,r)===t}function UV(e,t,r){return typeof r!="number"&&(r=0),r+t.length>e.length?!1:e.indexOf(t,r)!==-1}Cl("ERR_AMBIGUOUS_ARGUMENT",'The "%s" argument is ambiguous. %s',TypeError);Cl("ERR_INVALID_ARG_TYPE",function(e,t,r){Sc===void 0&&(Sc=ra()),Sc(typeof e=="string","'name' must be a string");var i;typeof t=="string"&&qV(t,"not ")?(i="must not be",t=t.replace(/^not /,"")):i="must be";var n;if(HV(e," argument"))n="The ".concat(e," ").concat(i," ").concat(C2(t,"type"));else{var o=UV(e,".")?"property":"argument";n='The "'.concat(e,'" ').concat(o," ").concat(i," ").concat(C2(t,"type"))}return n+=". Received type ".concat(za(r)),n},TypeError);Cl("ERR_INVALID_ARG_VALUE",function(e,t){var r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:"is invalid";Ab===void 0&&(Ab=Qi());var i=Ab.inspect(t);return i.length>128&&(i="".concat(i.slice(0,128),"...")),"The argument '".concat(e,"' ").concat(r,". Received ").concat(i)},TypeError,RangeError);Cl("ERR_INVALID_RETURN_VALUE",function(e,t,r){var i;return r&&r.constructor&&r.constructor.name?i="instance of ".concat(r.constructor.name):i="type ".concat(za(r)),"Expected ".concat(e,' to be returned from the "').concat(t,'"')+" function but got ".concat(i,".")},TypeError);Cl("ERR_MISSING_ARGS",function(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];Sc===void 0&&(Sc=ra()),Sc(t.length>0,"At least one arg needs to be specified");var i="The ",n=t.length;switch(t=t.map(function(o){return'"'.concat(o,'"')}),n){case 1:i+="".concat(t[0]," argument");break;case 2:i+="".concat(t[0]," and ").concat(t[1]," arguments");break;default:i+=t.slice(0,n-1).join(", "),i+=", and ".concat(t[n-1]," arguments");break}return"".concat(i," must be specified")},TypeError);M2.exports.codes=L2});var G2=P((Xoe,V2)=>{"use strict";g();function D2(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);t&&(i=i.filter(function(n){return Object.getOwnPropertyDescriptor(e,n).enumerable})),r.push.apply(r,i)}return r}function q2(e){for(var t=1;t<arguments.length;t++){var r=arguments[t]!=null?arguments[t]:{};t%2?D2(Object(r),!0).forEach(function(i){FV(e,i,r[i])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):D2(Object(r)).forEach(function(i){Object.defineProperty(e,i,Object.getOwnPropertyDescriptor(r,i))})}return e}function FV(e,t,r){return t=j2(t),t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function jV(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function H2(e,t){for(var r=0;r<t.length;r++){var i=t[r];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,j2(i.key),i)}}function zV(e,t,r){return t&&H2(e.prototype,t),r&&H2(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e}function j2(e){var t=KV(e,"string");return Ai(t)==="symbol"?t:String(t)}function KV(e,t){if(Ai(e)!=="object"||e===null)return e;var r=e[Symbol.toPrimitive];if(r!==void 0){var i=r.call(e,t||"default");if(Ai(i)!=="object")return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}function VV(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&&ql(e,t)}function GV(e){var t=K2();return function(){var i=Hl(e),n;if(t){var o=Hl(this).constructor;n=Reflect.construct(i,arguments,o)}else n=i.apply(this,arguments);return z2(this,n)}}function z2(e,t){if(t&&(Ai(t)==="object"||typeof t=="function"))return t;if(t!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return Rb(e)}function Rb(e){if(e===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function kb(e){var t=typeof Map=="function"?new Map:void 0;return kb=function(i){if(i===null||!WV(i))return i;if(typeof i!="function")throw new TypeError("Super expression must either be null or a function");if(typeof t<"u"){if(t.has(i))return t.get(i);t.set(i,n)}function n(){return yg(i,arguments,Hl(this).constructor)}return n.prototype=Object.create(i.prototype,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}}),ql(n,i)},kb(e)}function yg(e,t,r){return K2()?yg=Reflect.construct.bind():yg=function(n,o,a){var s=[null];s.push.apply(s,o);var u=Function.bind.apply(n,s),c=new u;return a&&ql(c,a.prototype),c},yg.apply(null,arguments)}function K2(){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 WV(e){return Function.toString.call(e).indexOf("[native code]")!==-1}function ql(e,t){return ql=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(i,n){return i.__proto__=n,i},ql(e,t)}function Hl(e){return Hl=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(r){return r.__proto__||Object.getPrototypeOf(r)},Hl(e)}function Ai(e){"@babel/helpers - typeof";return Ai=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},Ai(e)}var YV=Qi(),Bb=YV.inspect,ZV=Pb(),$V=ZV.codes.ERR_INVALID_ARG_TYPE;function U2(e,t,r){return(r===void 0||r>e.length)&&(r=e.length),e.substring(r-t.length,r)===t}function XV(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 xn="",Ll="",Ml="",ti="",$s={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:"},JV=10;function F2(e){var t=Object.keys(e),r=Object.create(Object.getPrototypeOf(e));return t.forEach(function(i){r[i]=e[i]}),Object.defineProperty(r,"message",{value:e.message}),r}function Dl(e){return Bb(e,{compact:!1,customInspect:!1,depth:1e3,maxArrayLength:1/0,showHidden:!1,breakLength:1/0,showProxy:!1,sorted:!0,getters:!0})}function QV(e,t,r){var i="",n="",o=0,a="",s=!1,u=Dl(e),c=u.split(`
14
14
  `),l=Dl(t).split(`
@@ -66,7 +66,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
66
66
  `))}throw i}};function _k(e,t,r,i,n){if(!kg(t))throw new Ec("regexp","RegExp",t);var o=n==="match";if(typeof e!="string"||Bg(t,e)!==o){if(r instanceof Error)throw r;var a=!r;r=r||(typeof e!="string"?'The "string" argument must be of type string. Received type '+"".concat(On(e)," (").concat(Rg(e),")"):(o?"The input did not match the regular expression ":"The input was expected to not match the regular expression ")+"".concat(Rg(t),`. Input:
67
67
 
68
68
  `).concat(Rg(e),`
69
- `));var s=new Ga({actual:e,expected:t,message:r,operator:n,stackStartFn:i});throw s.generatedMessage=a,s}}Ot.match=function e(t,r,i){_k(t,r,i,e,"match")};Ot.doesNotMatch=function e(t,r,i){_k(t,r,i,e,"doesNotMatch")};function wk(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];dk.apply(void 0,[wk,t.length].concat(t))}Ot.strict=l7(wk,Ot,{equal:Ot.strictEqual,deepEqual:Ot.deepStrictEqual,notEqual:Ot.notStrictEqual,notDeepEqual:Ot.notDeepStrictEqual});Ot.strict.strict=Ot.strict});var oo=P((Nae,xk)=>{"use strict";g();var Wl=Je(),Ek=Oe(),xc=Ye(),Jt=function e(t){if(!(this instanceof e))return new e(t);if(!Wl.isUndefined(t))if(f.Buffer.isBuffer(t))this.set({buf:t});else if(Wl.isString(t)){var r=f.Buffer.from(t,"hex");if(r.length*2!==t.length)throw new TypeError("Invalid hex string");this.set({buf:r})}else if(Wl.isObject(t)){var i=t;this.set(i)}else throw new TypeError("Unrecognized argument for BufferReader")};Jt.prototype.set=function(e){return this.buf=e.buf||this.buf||void 0,this.pos=e.pos||this.pos||0,this};Jt.prototype.eof=function(){return this.pos>=this.buf.length};Jt.prototype.finished=Jt.prototype.eof;Jt.prototype.read=function(e){Ek.checkArgument(!Wl.isUndefined(e),"Must specify a length");var t=this.buf.slice(this.pos,this.pos+e);return this.pos=this.pos+e,t};Jt.prototype.readAll=function(){var e=this.buf.slice(this.pos,this.buf.length);return this.pos=this.buf.length,e};Jt.prototype.readUInt8=function(){var e=this.buf.readUInt8(this.pos);return this.pos=this.pos+1,e};Jt.prototype.readUInt16BE=function(){var e=this.buf.readUInt16BE(this.pos);return this.pos=this.pos+2,e};Jt.prototype.readUInt16LE=function(){var e=this.buf.readUInt16LE(this.pos);return this.pos=this.pos+2,e};Jt.prototype.readUInt32BE=function(){var e=this.buf.readUInt32BE(this.pos);return this.pos=this.pos+4,e};Jt.prototype.readUInt32LE=function(){var e=this.buf.readUInt32LE(this.pos);return this.pos=this.pos+4,e};Jt.prototype.readInt32LE=function(){var e=this.buf.readInt32LE(this.pos);return this.pos=this.pos+4,e};Jt.prototype.readUInt64BEBN=function(){var e=this.buf.slice(this.pos,this.pos+8),t=xc.fromBuffer(e);return this.pos=this.pos+8,t};Jt.prototype.readUInt64LEBN=function(){var e=this.buf.readUInt32LE(this.pos),t=this.buf.readUInt32LE(this.pos+4),r=t*4294967296+e,i;if(r<=9007199254740991)i=new xc(r);else{var n=Array.prototype.slice.call(this.buf,this.pos,this.pos+8);i=new xc(n,10,"le")}return this.pos=this.pos+8,i};Jt.prototype.readVarintNum=function(){var e=this.readUInt8();switch(e){case 253:return this.readUInt16LE();case 254:return this.readUInt32LE();case 255:var t=this.readUInt64LEBN(),r=t.toNumber();if(r<=Math.pow(2,53))return r;throw new Error("number too large to retain precision - use readVarintBN");default:return e}};Jt.prototype.readVarLengthBuffer=function(){var e=this.readVarintNum(),t=this.read(e);return Ek.checkState(t.length===e,"Invalid length while reading varlength buffer. Expected to read: "+e+" and read "+t.length),t};Jt.prototype.readVarintBuf=function(){var e=this.buf.readUInt8(this.pos);switch(e){case 253:return this.read(3);case 254:return this.read(5);case 255:return this.read(9);default:return this.read(1)}};Jt.prototype.readVarintBN=function(){var e=this.readUInt8();switch(e){case 253:return new xc(this.readUInt16LE());case 254:return new xc(this.readUInt32LE());case 255:return this.readUInt64LEBN();default:return new xc(e)}};Jt.prototype.reverse=function(){for(var e=f.Buffer.alloc(this.buf.length),t=0;t<e.length;t++)e[t]=this.buf[this.buf.length-1-t];return this.buf=e,this};Jt.prototype.readReverse=function(e){Wl.isUndefined(e)&&(e=this.buf.length);var t=this.buf.slice(this.pos,this.pos+e);return this.pos=this.pos+e,f.Buffer.from(t).reverse()};xk.exports=Jt});var Or=P((Lae,Ok)=>{"use strict";g();var Oc=Je(),Yl=Oe(),d7=ei();function at(e){if(!(this instanceof at))return new at(e);var t;if(Oc.isNumber(e))t=e;else if(Oc.isString(e))t=at.map[e];else throw new TypeError('Unrecognized num type: "'+typeof e+'" for Opcode');return d7.defineImmutable(this,{num:t}),this}at.fromBuffer=function(e){return Yl.checkArgument(f.Buffer.isBuffer(e)),new at(+("0x"+e.toString("hex")))};at.fromNumber=function(e){return Yl.checkArgument(Oc.isNumber(e)),new at(e)};at.fromString=function(e){Yl.checkArgument(Oc.isString(e));var t=at.map[e];if(typeof t>"u")throw new TypeError("Invalid opcodestr");return new at(t)};at.prototype.toHex=function(){return this.num.toString(16)};at.prototype.toBuffer=function(){return f.Buffer.from(this.toHex(),"hex")};at.prototype.toNumber=function(){return this.num};at.prototype.toString=function(){var e=at.reverseMap[this.num];if(typeof e>"u")throw new Error("Opcode does not have a string representation");return e};at.smallInt=function(e){return Yl.checkArgument(Oc.isNumber(e),"Invalid Argument: n should be number"),Yl.checkArgument(e>=0&&e<=16,"Invalid Argument: n must be between 0 and 16"),e===0?at("OP_0"):new at(at.map.OP_1+e-1)};at.map={OP_FALSE:0,OP_0:0,OP_PUSHDATA1:76,OP_PUSHDATA2:77,OP_PUSHDATA4:78,OP_1NEGATE:79,OP_RESERVED:80,OP_TRUE:81,OP_1:81,OP_2:82,OP_3:83,OP_4:84,OP_5:85,OP_6:86,OP_7:87,OP_8:88,OP_9:89,OP_10:90,OP_11:91,OP_12:92,OP_13:93,OP_14:94,OP_15:95,OP_16:96,OP_NOP:97,OP_VER:98,OP_IF:99,OP_NOTIF:100,OP_VERIF:101,OP_VERNOTIF:102,OP_ELSE:103,OP_ENDIF:104,OP_VERIFY:105,OP_RETURN:106,OP_TOALTSTACK:107,OP_FROMALTSTACK:108,OP_2DROP:109,OP_2DUP:110,OP_3DUP:111,OP_2OVER:112,OP_2ROT:113,OP_2SWAP:114,OP_IFDUP:115,OP_DEPTH:116,OP_DROP:117,OP_DUP:118,OP_NIP:119,OP_OVER:120,OP_PICK:121,OP_ROLL:122,OP_ROT:123,OP_SWAP:124,OP_TUCK:125,OP_CAT:126,OP_SPLIT:127,OP_NUM2BIN:128,OP_BIN2NUM:129,OP_SIZE:130,OP_INVERT:131,OP_AND:132,OP_OR:133,OP_XOR:134,OP_EQUAL:135,OP_EQUALVERIFY:136,OP_RESERVED1:137,OP_RESERVED2:138,OP_1ADD:139,OP_1SUB:140,OP_2MUL:141,OP_2DIV:142,OP_NEGATE:143,OP_ABS:144,OP_NOT:145,OP_0NOTEQUAL:146,OP_ADD:147,OP_SUB:148,OP_MUL:149,OP_DIV:150,OP_MOD:151,OP_LSHIFT:152,OP_RSHIFT:153,OP_BOOLAND:154,OP_BOOLOR:155,OP_NUMEQUAL:156,OP_NUMEQUALVERIFY:157,OP_NUMNOTEQUAL:158,OP_LESSTHAN:159,OP_GREATERTHAN:160,OP_LESSTHANOREQUAL:161,OP_GREATERTHANOREQUAL:162,OP_MIN:163,OP_MAX:164,OP_WITHIN:165,OP_RIPEMD160:166,OP_SHA1:167,OP_SHA256:168,OP_HASH160:169,OP_HASH256:170,OP_CODESEPARATOR:171,OP_CHECKSIG:172,OP_CHECKSIGVERIFY:173,OP_CHECKMULTISIG:174,OP_CHECKMULTISIGVERIFY:175,OP_CHECKLOCKTIMEVERIFY:177,OP_CHECKSEQUENCEVERIFY:178,OP_NOP1:176,OP_NOP2:177,OP_NOP3:178,OP_SUBSTR:179,OP_LEFT:180,OP_RIGHT:181,OP_LSHIFTNUM:182,OP_RSHIFTNUM:183,OP_NOP9:184,OP_NOP10:185,OP_PUBKEYHASH:253,OP_PUBKEY:254,OP_INVALIDOPCODE:255};at.reverseMap=[];for(Gb in at.map)at.reverseMap[at.map[Gb]]=Gb;var Gb;Oc.extend(at,at.map);at.isSmallIntOp=function(e){return e instanceof at&&(e=e.toNumber()),e===at.map.OP_0||e>=at.map.OP_1&&e<=at.map.OP_16};at.prototype.inspect=function(){return"<Opcode: "+this.toString()+", hex: "+this.toHex()+", decimal: "+this.num+">"};Ok.exports=at});var Mg=P((Dae,Pk)=>{"use strict";g();var p7=ra(),An=Ti(),g7=oo(),Wb=ke(),ae=Or(),Js=Gt(),Xs=ut(),Ik=ta(),Bt=Oe(),Qe=Je(),Yb=ci(),Ak=jt(),m7=ei(),$=function e(t){if(!(this instanceof e))return new e(t);if(this.chunks=[],f.Buffer.isBuffer(t))return e.fromBuffer(t);if(t instanceof An)return e.fromAddress(t);if(t instanceof e)return e.fromBuffer(t.toBuffer());if(Qe.isString(t))return e.fromString(t);Qe.isObject(t)&&Qe.isArray(t.chunks)&&this.set(t)};$.prototype.set=function(e){return Bt.checkArgument(Qe.isObject(e)),Bt.checkArgument(Qe.isArray(e.chunks)),this.chunks=e.chunks,this};$.fromBuffer=function(e){var t=new $;t.chunks=[];for(var r=new g7(e);!r.finished();)try{var i=r.readUInt8(),n,o;i>0&&i<ae.OP_PUSHDATA1?(n=i,t.chunks.push({buf:r.read(n),len:n,opcodenum:i})):i===ae.OP_PUSHDATA1?(n=r.readUInt8(),o=r.read(n),t.chunks.push({buf:o,len:n,opcodenum:i})):i===ae.OP_PUSHDATA2?(n=r.readUInt16LE(),o=r.read(n),t.chunks.push({buf:o,len:n,opcodenum:i})):i===ae.OP_PUSHDATA4?(n=r.readUInt32LE(),o=r.read(n),t.chunks.push({buf:o,len:n,opcodenum:i})):t.chunks.push({opcodenum:i})}catch(a){throw a instanceof RangeError?new Yb.Script.InvalidBuffer(e.toString("hex")):a}return t};$.prototype.toBuffer=function(){var e=this.chunks,t=0,r,i,n;for(r=0;r<e.length;r++)i=e[r],n=i.opcodenum,t+=1,i.buf&&(n<ae.OP_PUSHDATA1?t+=Lg(i.buf):n===ae.OP_PUSHDATA1?t+=1+Lg(i.buf):n===ae.OP_PUSHDATA2?t+=2+Lg(i.buf):n===ae.OP_PUSHDATA4&&(t+=4+Lg(i.buf)));var o=f.Buffer.alloc(t),a=0;for(r=0;r<e.length;r++)i=e[r],n=i.opcodenum,a=o.writeUInt8(i.opcodenum,a),i.buf&&(n<ae.OP_PUSHDATA1?a+=i.buf.copy(o,a):n===ae.OP_PUSHDATA1?(a=o.writeUInt8(i.len,a),a+=i.buf.copy(o,a)):n===ae.OP_PUSHDATA2?(a=o.writeUInt16LE(i.len,a),a+=i.buf.copy(o,a)):n===ae.OP_PUSHDATA4&&(a=o.writeUInt32LE(i.len,a),a+=i.buf.copy(o,a)));return o};function Lg(e){if(!f.Buffer.isBuffer(e))throw new p7.AssertionError({message:"chunk data must be a Buffer",actual:e,expected:"Buffer",operator:"isBuffer"});return e.length}function Tk(e){if(/^0x[0-9a-fA-F]{2}$/.test(e)){var t=parseInt(e.slice(2),16);return t>ae.OP_PUSHDATA4?t:void 0}}$.fromASM=function(e){var t=new $;if(t.chunks=[],e==="")return t;for(var r=e.split(" "),i=0;i<r.length;){var n=r[i],o=ae(n),a=o.toNumber(),s=Tk(n);if(s!==void 0)t.chunks.push({opcodenum:s}),i=i+1;else if(n==="0")a=0,t.chunks.push({opcodenum:a}),i=i+1;else if(n==="-1")a=ae.OP_1NEGATE,t.chunks.push({opcodenum:a}),i=i+1;else if(Qe.isUndefined(a)){var u=f.Buffer.from(r[i],"hex");if(u.toString("hex")!==r[i])throw new Error("invalid hex string in script");var c=u.length;c>=0&&c<ae.OP_PUSHDATA1?a=c:c<Math.pow(2,8)?a=ae.OP_PUSHDATA1:c<Math.pow(2,16)?a=ae.OP_PUSHDATA2:c<Math.pow(2,32)&&(a=ae.OP_PUSHDATA4),t.chunks.push({buf:u,len:u.length,opcodenum:a}),i=i+1}else t.chunks.push({opcodenum:a}),i=i+1}return t};$.fromHex=function(e){return new $(Ak.Buffer.from(e,"hex"))};$.fromString=function(e){if(m7.isHexa(e)||e.length===0)return new $(Ak.Buffer.from(e,"hex"));var t=new $;t.chunks=[];for(var r=e.split(" "),i=0;i<r.length;){var n=r[i],o=ae(n),a=o.toNumber(),s=Tk(n);if(s!==void 0)t.chunks.push({opcodenum:s}),i=i+1;else if(Qe.isUndefined(a))if(a=parseInt(n),a>0&&a<ae.OP_PUSHDATA1)t.chunks.push({buf:f.Buffer.from(r[i+1].slice(2),"hex"),len:a,opcodenum:a}),i=i+2;else throw new Error("Invalid script: "+JSON.stringify(e));else if(a===ae.OP_PUSHDATA1||a===ae.OP_PUSHDATA2||a===ae.OP_PUSHDATA4){if(r[i+2].slice(0,2)!=="0x")throw new Error("Pushdata data must start with 0x");t.chunks.push({buf:f.Buffer.from(r[i+2].slice(2),"hex"),len:parseInt(r[i+1]),opcodenum:a}),i=i+3}else t.chunks.push({opcodenum:a}),i=i+1}return t};$.prototype._chunkToString=function(e,t){var r=e.opcodenum,i=t==="asm",n="";if(e.buf)!i&&(r===ae.OP_PUSHDATA1||r===ae.OP_PUSHDATA2||r===ae.OP_PUSHDATA4)&&(n=n+" "+ae(r).toString()),e.len>0&&(i?n=n+" "+e.buf.toString("hex"):n=n+" "+e.len+" 0x"+e.buf.toString("hex"));else if(typeof ae.reverseMap[r]<"u")i?r===0?n=n+" 0":r===79?n=n+" -1":n=n+" "+ae(r).toString():n=n+" "+ae(r).toString();else{var o=r.toString(16);o.length%2!==0&&(o="0"+o),n=n+" 0x"+o}return n};$.prototype.toASM=function(){for(var e="",t=0;t<this.chunks.length;t++){var r=this.chunks[t];e+=this._chunkToString(r,"asm")}return e.substr(1)};$.prototype.toString=function(){for(var e="",t=0;t<this.chunks.length;t++){var r=this.chunks[t];e+=this._chunkToString(r)}return e.substr(1)};$.prototype.toHex=function(){return this.toBuffer().toString("hex")};$.prototype.inspect=function(){return"<Script: "+this.toString()+">"};$.prototype.isPublicKeyHashOut=function(){return!!(this.chunks.length===5&&this.chunks[0].opcodenum===ae.OP_DUP&&this.chunks[1].opcodenum===ae.OP_HASH160&&this.chunks[2].buf&&this.chunks[2].buf.length===20&&this.chunks[3].opcodenum===ae.OP_EQUALVERIFY&&this.chunks[4].opcodenum===ae.OP_CHECKSIG)};$.prototype.isPublicKeyHashOutPrefix=function(){return!!(this.chunks.length>=5&&this.chunks[0].opcodenum===ae.OP_DUP&&this.chunks[1].opcodenum===ae.OP_HASH160&&this.chunks[2].buf&&this.chunks[2].buf.length===20&&this.chunks[3].opcodenum===ae.OP_EQUALVERIFY&&this.chunks[4].opcodenum===ae.OP_CHECKSIG)};$.prototype.isPublicKeyHashIn=function(){if(this.chunks.length===2){var e=this.chunks[0].buf,t=this.chunks[1].buf;if(e&&e.length&&e[0]===48&&t&&t.length){var r=t[0];if((r===4||r===6||r===7)&&t.length===65)return!0;if((r===3||r===2)&&t.length===33)return!0}}return!1};$.prototype.getPublicKey=function(){return Bt.checkState(this.isPublicKeyOut(),"Can't retrieve PublicKey from a non-PK output"),this.chunks[0].buf};$.prototype.getPublicKeyHash=function(){return Bt.checkState(this.isPublicKeyHashOut(),"Can't retrieve PublicKeyHash from a non-PKH output"),this.chunks[2].buf};$.prototype.isPublicKeyOut=function(){if(this.chunks.length===2&&this.chunks[0].buf&&this.chunks[0].buf.length&&this.chunks[1].opcodenum===ae.OP_CHECKSIG){var e=this.chunks[0].buf,t=e[0],r=!1;if(((t===4||t===6||t===7)&&e.length===65||(t===3||t===2)&&e.length===33)&&(r=!0),r)return Js.isValid(e)}return!1};$.prototype.isPublicKeyIn=function(){if(this.chunks.length===1){var e=this.chunks[0].buf;if(e&&e.length&&e[0]===48)return!0}return!1};$.prototype.isScriptHashOut=function(){var e=this.toBuffer();return e.length===23&&e[0]===ae.OP_HASH160&&e[1]===20&&e[e.length-1]===ae.OP_EQUAL};$.prototype.isScriptHashIn=function(){if(this.chunks.length<=1)return!1;var e=this.chunks[this.chunks.length-1],t=e.buf;if(!t)return!1;var r;try{r=$.fromBuffer(t)}catch(n){if(n instanceof Yb.Script.InvalidBuffer)return!1;throw n}var i=r.classify();return i!==$.types.UNKNOWN};$.prototype.isMultisigOut=function(){return this.chunks.length>3&&ae.isSmallIntOp(this.chunks[0].opcodenum)&&this.chunks.slice(1,this.chunks.length-2).every(function(e){return e.buf&&f.Buffer.isBuffer(e.buf)})&&ae.isSmallIntOp(this.chunks[this.chunks.length-2].opcodenum)&&this.chunks[this.chunks.length-1].opcodenum===ae.OP_CHECKMULTISIG};$.prototype.isMultisigIn=function(){return this.chunks.length>=2&&this.chunks[0].opcodenum===0&&this.chunks.slice(1,this.chunks.length).every(function(e){return e.buf&&f.Buffer.isBuffer(e.buf)&&Xs.isTxDER(e.buf)})};$.prototype.isDataOut=function(){var e=this.chunks.length>=1&&this.chunks[0].opcodenum===ae.OP_RETURN;if(!e)return!1;var t=this.chunks.slice(1),r=new $({chunks:t});return r.isPushOnly()};$.prototype.isSafeDataOut=function(){if(this.chunks.length<2||this.chunks[0].opcodenum!==ae.OP_FALSE)return!1;var e=this.chunks.slice(1),t=new $({chunks:e});return t.isDataOut()};$.prototype.getData=function(){if(this.isSafeDataOut()){var e=this.chunks.slice(2),t=e.map(r=>r.buf);return t}if(this.isDataOut()||this.isScriptHashOut())return Qe.isUndefined(this.chunks[1])?f.Buffer.alloc(0):f.Buffer.from(this.chunks[1].buf);if(this.isPublicKeyHashOut())return f.Buffer.from(this.chunks[2].buf);throw new Error("Unrecognized script type to get data from")};$.prototype.isPushOnly=function(){return Qe.every(this.chunks,function(e){return e.opcodenum<=ae.OP_16||e.opcodenum===ae.OP_PUSHDATA1||e.opcodenum===ae.OP_PUSHDATA2||e.opcodenum===ae.OP_PUSHDATA4})};$.types={};$.types.UNKNOWN="Unknown";$.types.PUBKEY_OUT="Pay to public key";$.types.PUBKEY_IN="Spend from public key";$.types.PUBKEYHASH_OUT="Pay to public key hash";$.types.PUBKEYHASH_IN="Spend from public key hash";$.types.SCRIPTHASH_OUT="Pay to script hash";$.types.SCRIPTHASH_IN="Spend from script hash";$.types.MULTISIG_OUT="Pay to multisig";$.types.MULTISIG_IN="Spend from multisig";$.types.DATA_OUT="Data push";$.types.SAFE_DATA_OUT="Safe data push";$.OP_RETURN_STANDARD_SIZE=220;$.prototype.classify=function(){if(this._isInput)return this.classifyInput();if(this._isOutput)return this.classifyOutput();var e=this.classifyOutput();return e!==$.types.UNKNOWN?e:this.classifyInput()};$.outputIdentifiers={};$.outputIdentifiers.PUBKEY_OUT=$.prototype.isPublicKeyOut;$.outputIdentifiers.PUBKEYHASH_OUT=$.prototype.isPublicKeyHashOut;$.outputIdentifiers.MULTISIG_OUT=$.prototype.isMultisigOut;$.outputIdentifiers.SCRIPTHASH_OUT=$.prototype.isScriptHashOut;$.outputIdentifiers.DATA_OUT=$.prototype.isDataOut;$.outputIdentifiers.SAFE_DATA_OUT=$.prototype.isSafeDataOut;$.prototype.classifyOutput=function(){for(var e in $.outputIdentifiers)if($.outputIdentifiers[e].bind(this)())return $.types[e];return $.types.UNKNOWN};$.inputIdentifiers={};$.inputIdentifiers.PUBKEY_IN=$.prototype.isPublicKeyIn;$.inputIdentifiers.PUBKEYHASH_IN=$.prototype.isPublicKeyHashIn;$.inputIdentifiers.MULTISIG_IN=$.prototype.isMultisigIn;$.inputIdentifiers.SCRIPTHASH_IN=$.prototype.isScriptHashIn;$.prototype.classifyInput=function(){for(var e in $.inputIdentifiers)if($.inputIdentifiers[e].bind(this)())return $.types[e];return $.types.UNKNOWN};$.prototype.isStandard=function(){return this.classify()!==$.types.UNKNOWN};$.prototype.prepend=function(e){return this._addByType(e,!0),this};$.prototype.equals=function(e){if(Bt.checkState(e instanceof $,"Must provide another script"),this.chunks.length!==e.chunks.length)return!1;var t;for(t=0;t<this.chunks.length;t++){if(f.Buffer.isBuffer(this.chunks[t].buf)&&!f.Buffer.isBuffer(e.chunks[t].buf)||f.Buffer.isBuffer(this.chunks[t].buf)&&!this.chunks[t].buf.equals(e.chunks[t].buf))return!1;if(this.chunks[t].opcodenum!==e.chunks[t].opcodenum)return!1}return!0};$.prototype.add=function(e){return this._addByType(e,!1),this};$.prototype._addByType=function(e,t){if(typeof e=="string")this._addOpcode(e,t);else if(typeof e=="number")this._addOpcode(e,t);else if(e instanceof ae)this._addOpcode(e,t);else if(f.Buffer.isBuffer(e))this._addBuffer(e,t);else if(e instanceof $)this.chunks=this.chunks.concat(e.chunks);else if(typeof e=="object")this._insertAtPosition(e,t);else throw new Error("Invalid script chunk")};$.prototype._insertAtPosition=function(e,t){t?this.chunks.unshift(e):this.chunks.push(e)};$.prototype._addOpcode=function(e,t){var r;return typeof e=="number"?r=e:e instanceof ae?r=e.toNumber():r=ae(e).toNumber(),this._insertAtPosition({opcodenum:r},t),this};$.prototype._addBuffer=function(e,t){var r,i=e.length;if(i>=0&&i<ae.OP_PUSHDATA1)r=i;else if(i<Math.pow(2,8))r=ae.OP_PUSHDATA1;else if(i<Math.pow(2,16))r=ae.OP_PUSHDATA2;else if(i<Math.pow(2,32))r=ae.OP_PUSHDATA4;else throw new Error("You can't push that much data");return this._insertAtPosition({buf:e,len:i,opcodenum:r},t),this};$.prototype.removeCodeseparators=function(){for(var e=[],t=0;t<this.chunks.length;t++)this.chunks[t].opcodenum!==ae.OP_CODESEPARATOR&&e.push(this.chunks[t]);return this.chunks=e,this};$.buildMultisigOut=function(e,t,r){Bt.checkArgument(t<=e.length,"Number of required signatures must be less than or equal to the number of public keys"),r=r||{};var i=new $;i.add(ae.smallInt(t)),e=Qe.map(e,Js);var n=e;r.noSorting||(n=e.map(s=>s.toString("hex")).sort().map(s=>new Js(s)));for(var o=0;o<n.length;o++){var a=n[o];i.add(a.toBuffer())}return i.add(ae.smallInt(e.length)),i.add(ae.OP_CHECKMULTISIG),i};$.buildMultisigIn=function(e,t,r,i){Bt.checkArgument(Qe.isArray(e)),Bt.checkArgument(Qe.isNumber(t)),Bt.checkArgument(Qe.isArray(r)),i=i||{};var n=new $;return n.add(ae.OP_0),Qe.each(r,function(o){Bt.checkArgument(f.Buffer.isBuffer(o),"Signatures must be an array of Buffers"),n.add(o)}),n};$.buildP2SHMultisigIn=function(e,t,r,i){Bt.checkArgument(Qe.isArray(e)),Bt.checkArgument(Qe.isNumber(t)),Bt.checkArgument(Qe.isArray(r)),i=i||{};var n=new $;return n.add(ae.OP_0),Qe.each(r,function(o){Bt.checkArgument(f.Buffer.isBuffer(o),"Signatures must be an array of Buffers"),n.add(o)}),n.add((i.cachedMultisig||$.buildMultisigOut(e,t,i)).toBuffer()),n};$.buildPublicKeyHashOut=function(e){Bt.checkArgument(!Qe.isUndefined(e)),Bt.checkArgument(e instanceof Js||e instanceof An||Qe.isString(e)),e instanceof Js?e=e.toAddress():Qe.isString(e)&&(e=new An(e));var t=new $;return t.add(ae.OP_DUP).add(ae.OP_HASH160).add(e.hashBuffer).add(ae.OP_EQUALVERIFY).add(ae.OP_CHECKSIG),t._network=e.network,t};$.buildPublicKeyOut=function(e){Bt.checkArgument(e instanceof Js);var t=new $;return t.add(e.toBuffer()).add(ae.OP_CHECKSIG),t};$.buildDataOut=function(e,t){Bt.checkArgument(Qe.isUndefined(e)||Qe.isString(e)||Qe.isArray(e)||f.Buffer.isBuffer(e));var r=e;Qe.isArray(r)||(r=[e]);var i=new $;i.add(ae.OP_RETURN);for(let n of r)Bt.checkArgument(Qe.isUndefined(n)||Qe.isString(n)||f.Buffer.isBuffer(n)),Qe.isString(n)&&(n=f.Buffer.from(n,t)),Qe.isUndefined(n)||i.add(n);return i};$.buildSafeDataOut=function(e,t){var r=$.buildDataOut(e,t),i=new $;return i.add(ae.OP_FALSE),i.add(r),i};$.buildScriptHashOut=function(e){Bt.checkArgument(e instanceof $||e instanceof An&&e.isPayToScriptHash());var t=new $;return t.add(ae.OP_HASH160).add(e instanceof An?e.hashBuffer:Wb.sha256ripemd160(e.toBuffer())).add(ae.OP_EQUAL),t._network=e._network||e.network,t};$.buildPublicKeyIn=function(e,t){Bt.checkArgument(e instanceof Xs||f.Buffer.isBuffer(e)),Bt.checkArgument(Qe.isUndefined(t)||Qe.isNumber(t)),e instanceof Xs&&(e=e.toBuffer());var r=new $;return r.add(f.Buffer.concat([e,f.Buffer.from([(t||Xs.SIGHASH_ALL)&255])])),r};$.buildPublicKeyHashIn=function(e,t,r){Bt.checkArgument(t instanceof Xs||f.Buffer.isBuffer(t)),Bt.checkArgument(Qe.isUndefined(r)||Qe.isNumber(r)),t instanceof Xs&&(t=t.toBuffer());var i=new $().add(f.Buffer.concat([t,f.Buffer.from([(r||Xs.SIGHASH_ALL)&255])])).add(new Js(e).toBuffer());return i};$.empty=function(){return new $};$.prototype.toScriptHashOut=function(){return $.buildScriptHashOut(this)};$.fromAddress=function(e){if(e=An(e),e.isPayToScriptHash())return $.buildScriptHashOut(e);if(e.isPayToPublicKeyHash())return $.buildPublicKeyHashOut(e);throw new Yb.Script.UnrecognizedAddress(e)};$.prototype.getAddressInfo=function(e){if(this._isInput)return this._getInputAddressInfo();if(this._isOutput)return this._getOutputAddressInfo();var t=this._getOutputAddressInfo();return t||this._getInputAddressInfo()};$.prototype._getOutputAddressInfo=function(){var e={};if(this.isScriptHashOut())e.hashBuffer=this.getData(),e.type=An.PayToScriptHash;else if(this.isPublicKeyHashOut())e.hashBuffer=this.getData(),e.type=An.PayToPublicKeyHash;else return!1;return e};$.prototype._getInputAddressInfo=function(){var e={};if(this.isPublicKeyHashIn())e.hashBuffer=Wb.sha256ripemd160(this.chunks[1].buf),e.type=An.PayToPublicKeyHash;else if(this.isScriptHashIn())e.hashBuffer=Wb.sha256ripemd160(this.chunks[this.chunks.length-1].buf),e.type=An.PayToScriptHash;else return!1;return e};$.prototype.toAddress=function(e){var t=this.getAddressInfo();return t?(t.network=Ik.get(e)||this._network||Ik.defaultNetwork,new An(t)):!1};$.prototype.findAndDelete=function(e){for(var t=e.toBuffer(),r=t.length?t[0]:-1,i=0;i<this.chunks.length;i++){var n=this.chunks[i];if(!(n.opcodenum!==r&&v7(n))){var o=$({chunks:[n]}).toBuffer();t.equals(o)&&(this.chunks.splice(i,1),i--)}}return this};function v7(e){var t=e.opcodenum;if(typeof t!="number"||!Number.isInteger(t)||t<0||t>255)return!1;if(!e.buf||t>ae.OP_PUSHDATA4)return!0;if(!f.Buffer.isBuffer(e.buf))return!1;var r=e.len;return t===ae.OP_PUSHDATA1?Number.isInteger(r)&&r>=0&&r<=255:t===ae.OP_PUSHDATA2?Number.isInteger(r)&&r>=0&&r<=65535:t===ae.OP_PUSHDATA4?Number.isInteger(r)&&r>=0&&r<=4294967295:!0}$.prototype.checkMinimalPush=function(e){var t=this.chunks[e],r=t.buf,i=t.opcodenum;return r?r.length===0?i===ae.OP_0:r.length===1&&r[0]>=1&&r[0]<=16?i===ae.OP_1+(r[0]-1):r.length===1&&r[0]===129?i===ae.OP_1NEGATE:r.length<=75?i===r.length:r.length<=255?i===ae.OP_PUSHDATA1:r.length<=65535?i===ae.OP_PUSHDATA2:!0:!0};$.prototype._decodeOP_N=function(e){if(e===ae.OP_0)return 0;if(e>=ae.OP_1&&e<=ae.OP_16)return e-(ae.OP_1-1);throw new Error("Invalid opcode: "+JSON.stringify(e))};$.prototype.getSignatureOperationsCount=function(e){e=Qe.isUndefined(e)?!0:e;var t=this,r=0,i=ae.OP_INVALIDOPCODE;return Qe.each(t.chunks,function(o){var a=o.opcodenum;a===ae.OP_CHECKSIG||a===ae.OP_CHECKSIGVERIFY?r++:(a===ae.OP_CHECKMULTISIG||a===ae.OP_CHECKMULTISIGVERIFY)&&(e&&i>=ae.OP_1&&i<=ae.OP_16?r+=t._decodeOP_N(i):r+=20),i=a}),r};Pk.exports=$});var Tn=P((Hae,kk)=>{"use strict";g();var Rk=ra(),Qt=function e(t){if(!(this instanceof e))return new e(t);this.bufLen=0,t?this.set(t):this.bufs=[]};Qt.prototype.set=function(e){return this.bufs=e.bufs||this.bufs||[],this.bufLen=this.bufs.reduce(function(t,r){return t+r.length},0),this};Qt.prototype.toBuffer=function(){return this.concat()};Qt.prototype.concat=function(){return f.Buffer.concat(this.bufs,this.bufLen)};Qt.prototype.write=function(e){return Rk(f.Buffer.isBuffer(e)),this.bufs.push(e),this.bufLen+=e.length,this};Qt.prototype.writeReverse=function(e){return Rk(f.Buffer.isBuffer(e)),this.bufs.push(f.Buffer.from(e).reverse()),this.bufLen+=e.length,this};Qt.prototype.writeUInt8=function(e){var t=f.Buffer.alloc(1);return t.writeUInt8(e,0),this.write(t),this};Qt.prototype.writeUInt16BE=function(e){var t=f.Buffer.alloc(2);return t.writeUInt16BE(e,0),this.write(t),this};Qt.prototype.writeUInt16LE=function(e){var t=f.Buffer.alloc(2);return t.writeUInt16LE(e,0),this.write(t),this};Qt.prototype.writeUInt32BE=function(e){var t=f.Buffer.alloc(4);return t.writeUInt32BE(e,0),this.write(t),this};Qt.prototype.writeInt32LE=function(e){var t=f.Buffer.alloc(4);return t.writeInt32LE(e,0),this.write(t),this};Qt.prototype.writeUInt32LE=function(e){var t=f.Buffer.alloc(4);return t.writeUInt32LE(e,0),this.write(t),this};Qt.prototype.writeUInt64BEBN=function(e){var t=e.toBuffer({size:8});return this.write(t),this};Qt.prototype.writeUInt64LEBN=function(e){var t=e.toBuffer({size:8});return this.writeReverse(t),this};Qt.prototype.writeVarintNum=function(e){var t=Qt.varintBufNum(e);return this.write(t),this};Qt.prototype.writeVarintBN=function(e){var t=Qt.varintBufBN(e);return this.write(t),this};Qt.varintBufNum=function(e){var t;return e<253?(t=f.Buffer.alloc(1),t.writeUInt8(e,0)):e<65536?(t=f.Buffer.alloc(3),t.writeUInt8(253,0),t.writeUInt16LE(e,1)):e<4294967296?(t=f.Buffer.alloc(5),t.writeUInt8(254,0),t.writeUInt32LE(e,1)):(t=f.Buffer.alloc(9),t.writeUInt8(255,0),t.writeInt32LE(e&-1,1),t.writeUInt32LE(Math.floor(e/4294967296),5)),t};Qt.varintBufBN=function(e){var t,r=e.toNumber();if(r<253)t=f.Buffer.alloc(1),t.writeUInt8(r,0);else if(r<65536)t=f.Buffer.alloc(3),t.writeUInt8(253,0),t.writeUInt16LE(r,1);else if(r<4294967296)t=f.Buffer.alloc(5),t.writeUInt8(254,0),t.writeUInt32LE(r,1);else{var i=new Qt;i.writeUInt8(255),i.writeUInt64LEBN(e),t=i.concat()}return t};kk.exports=Qt});var Ic=P((Fae,Ck)=>{"use strict";g();var Bk=Tn(),Nk=oo(),y7=Ye(),Pn=function e(t){if(!(this instanceof e))return new e(t);if(f.Buffer.isBuffer(t))this.buf=t;else if(typeof t=="number"){var r=t;this.fromNumber(r)}else if(t instanceof y7){var i=t;this.fromBN(i)}else if(t){var n=t;this.set(n)}};Pn.prototype.set=function(e){return this.buf=e.buf||this.buf,this};Pn.prototype.fromString=function(e){return this.set({buf:f.Buffer.from(e,"hex")}),this};Pn.prototype.toString=function(){return this.buf.toString("hex")};Pn.prototype.fromBuffer=function(e){return this.buf=e,this};Pn.prototype.fromBufferReader=function(e){return this.buf=e.readVarintBuf(),this};Pn.prototype.fromBN=function(e){return this.buf=Bk().writeVarintBN(e).concat(),this};Pn.prototype.fromNumber=function(e){return this.buf=Bk().writeVarintNum(e).concat(),this};Pn.prototype.toBuffer=function(){return this.buf};Pn.prototype.toBN=function(){return Nk(this.buf).readVarintBN()};Pn.prototype.toNumber=function(){return Nk(this.buf).readVarintNum()};Ck.exports=Pn});var fi=P((zae,Mk)=>{"use strict";g();var Dg=Je(),Zb=Ye(),Lk=jt(),qg=ei(),b7=Tn(),_7=Ic(),$b=et(),Xb=Oe(),w7=ci(),S7=9007199254740991;function Wr(e){if(!(this instanceof Wr))return new Wr(e);if(Dg.isObject(e))if(this.satoshis=e.satoshis,f.Buffer.isBuffer(e.script))this._scriptBuffer=e.script;else{var t;Dg.isString(e.script)&&qg.isHexa(e.script)?t=Lk.Buffer.from(e.script,"hex"):t=e.script,this.setScript(t)}else throw new TypeError("Unrecognized argument for Output")}Object.defineProperty(Wr.prototype,"script",{configurable:!1,enumerable:!0,get:function(){return this._script?this._script:(this.setScriptFromBuffer(this._scriptBuffer),this._script)}});Object.defineProperty(Wr.prototype,"satoshis",{configurable:!1,enumerable:!0,get:function(){return this._satoshis},set:function(e){e instanceof Zb?(this._satoshisBN=e,this._satoshis=e.toNumber()):Dg.isString(e)?(this._satoshis=parseInt(e),this._satoshisBN=Zb.fromNumber(this._satoshis)):(Xb.checkArgument(qg.isNaturalNumber(e),"Output satoshis is not a natural number"),this._satoshisBN=Zb.fromNumber(e),this._satoshis=e),Xb.checkState(qg.isNaturalNumber(this._satoshis),"Output satoshis is not a natural number")}});Wr.prototype.invalidSatoshis=function(){return this._satoshis>S7?"transaction txout satoshis greater than max safe integer":this._satoshis!==this._satoshisBN.toNumber()?"transaction txout satoshis has corrupted value":this._satoshis<0?"transaction txout negative":!1};Object.defineProperty(Wr.prototype,"satoshisBN",{configurable:!1,enumerable:!0,get:function(){return this._satoshisBN},set:function(e){this._satoshisBN=e,this._satoshis=e.toNumber(),Xb.checkState(qg.isNaturalNumber(this._satoshis),"Output satoshis is not a natural number")}});Wr.prototype.toObject=Wr.prototype.toJSON=function(){var t={satoshis:this.satoshis};return t.script=this._scriptBuffer.toString("hex"),t};Wr.fromObject=function(e){return new Wr(e)};Wr.prototype.setScriptFromBuffer=function(e){this._scriptBuffer=e;try{this._script=$b.fromBuffer(this._scriptBuffer),this._script._isOutput=!0}catch(t){if(t instanceof w7.Script.InvalidBuffer)this._script=null;else throw t}};Wr.prototype.setScript=function(e){if(e instanceof $b)this._scriptBuffer=e.toBuffer(),this._script=e,this._script._isOutput=!0;else if(Dg.isString(e))this._script=$b.fromString(e),this._scriptBuffer=this._script.toBuffer(),this._script._isOutput=!0;else if(f.Buffer.isBuffer(e))this.setScriptFromBuffer(e);else throw new TypeError("Invalid argument type: script");return this};Wr.prototype.inspect=function(){var e;return this.script?e=this.script.inspect():e=this._scriptBuffer.toString("hex"),"<Output ("+this.satoshis+" sats) "+e+">"};Wr.fromBufferReader=function(e){var t={};t.satoshis=e.readUInt64LEBN();var r=e.readVarintNum();return r!==0?t.script=e.read(r):t.script=Lk.Buffer.from([]),new Wr(t)};Wr.prototype.toBufferWriter=function(e){e||(e=new b7),e.writeUInt64LEBN(this._satoshisBN);var t=this._scriptBuffer;return e.writeVarintNum(t.length),e.write(t),e};Wr.prototype.getSize=function(){var e=this.script.toBuffer().length,t=_7(e).toBuffer().length;return 8+t+e};Mk.exports=Wr});var Ac=P((Vae,Uk)=>{"use strict";g();var Wa=Je(),E7=Oe(),Zl=ci(),x7=Tn(),Jb=jt(),qk=ei(),Hg=et(),O7=li(),Dk=fi(),Ug=4294967295,I7=Ug-2,Hk=Ug,A7=Ug-1;function wt(e){if(!(this instanceof wt))return new wt(e);if(e)return this._fromObject(e)}wt.MAXINT=Ug;wt.DEFAULT_SEQNUMBER=Hk;wt.DEFAULT_LOCKTIME_SEQNUMBER=A7;wt.DEFAULT_RBF_SEQNUMBER=I7;wt.BASE_SIZE=40;Object.defineProperty(wt.prototype,"script",{configurable:!1,enumerable:!0,get:function(){return this.isNull()?null:(this._script||(this._script=new Hg(this._scriptBuffer),this._script._isInput=!0),this._script)}});wt.fromObject=function(e){E7.checkArgument(Wa.isObject(e));var t=new wt;return t._fromObject(e)};wt.prototype._fromObject=function(e){var t;if(Wa.isString(e.prevTxId)&&qk.isHexa(e.prevTxId)?t=Jb.Buffer.from(e.prevTxId,"hex"):t=e.prevTxId,this.output=e.output?e.output instanceof Dk?e.output:new Dk(e.output):void 0,this.prevTxId=t||e.txidbuf,this.outputIndex=Wa.isUndefined(e.outputIndex)?e.txoutnum:e.outputIndex,this.sequenceNumber=Wa.isUndefined(e.sequenceNumber)?Wa.isUndefined(e.seqnum)?Hk:e.seqnum:e.sequenceNumber,Wa.isUndefined(e.script)&&Wa.isUndefined(e.scriptBuffer))throw new Zl.Transaction.Input.MissingScript;return this.setScript(e.scriptBuffer||e.script),this};wt.prototype.toObject=wt.prototype.toJSON=function(){var t={prevTxId:this.prevTxId.toString("hex"),outputIndex:this.outputIndex,sequenceNumber:this.sequenceNumber,script:this._scriptBuffer.toString("hex")};return this.script&&(t.scriptString=this.script.toString()),this.output&&(t.output=this.output.toObject()),t};wt.fromBufferReader=function(e){var t=new wt;return t.prevTxId=e.readReverse(32),t.outputIndex=e.readUInt32LE(),t._scriptBuffer=e.readVarLengthBuffer(),t.sequenceNumber=e.readUInt32LE(),t};wt.prototype.toBufferWriter=function(e){e||(e=new x7),e.writeReverse(this.prevTxId),e.writeUInt32LE(this.outputIndex);var t=this._scriptBuffer;return e.writeVarintNum(t.length),e.write(t),e.writeUInt32LE(this.sequenceNumber),e};wt.prototype.setScript=function(e){if(this._script=null,e instanceof Hg)this._script=e,this._script._isInput=!0,this._scriptBuffer=e.toBuffer();else if(e===null)this._script=Hg.empty(),this._script._isInput=!0,this._scriptBuffer=this._script.toBuffer();else if(qk.isHexa(e))this._scriptBuffer=Jb.Buffer.from(e,"hex");else if(Wa.isString(e))this._script=new Hg(e),this._script._isInput=!0,this._scriptBuffer=this._script.toBuffer();else if(f.Buffer.isBuffer(e))this._scriptBuffer=Jb.Buffer.from(e);else throw new TypeError("Invalid argument type: script");return this};wt.prototype.getSignatures=function(){throw new Zl.AbstractMethodInvoked("Trying to sign unsupported output type (only P2PKH and P2SH multisig inputs are supported) for input: "+JSON.stringify(this))};wt.prototype.isFullySigned=function(){throw new Zl.AbstractMethodInvoked("Input#isFullySigned")};wt.prototype.isFinal=function(){return this.sequenceNumber===wt.MAXINT};wt.prototype.addSignature=function(){throw new Zl.AbstractMethodInvoked("Input#addSignature")};wt.prototype.clearSignatures=function(){throw new Zl.AbstractMethodInvoked("Input#clearSignatures")};wt.prototype.isValidSignature=function(e,t){return t.signature.nhashtype=t.sigtype,O7.verify(e,t.signature,t.publicKey,t.inputIndex,this.output.script,this.output.satoshisBN)};wt.prototype.isNull=function(){return this.prevTxId.toString("hex")==="0000000000000000000000000000000000000000000000000000000000000000"&&this.outputIndex===4294967295};wt.prototype._estimateSize=function(){return this.toBufferWriter().toBuffer().length};Uk.exports=wt});var Tc=P((Wae,Fk)=>{"use strict";g();Fk.exports=function(t,r){r&&(t.super_=r,t.prototype=Object.create(r.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}))}});var Rc=P((Zae,Kk)=>{"use strict";g();var Pc=Je(),sn=Oe(),T7=Tc(),jk=ei(),zk=Gt(),P7=ci(),$l=ut();function Rn(e){if(!(this instanceof Rn))return new Rn(e);if(e instanceof Rn)return e;if(Pc.isObject(e))return this._fromObject(e);throw new P7.InvalidArgument("TransactionSignatures must be instantiated from an object")}T7(Rn,$l);Rn.prototype._fromObject=function(e){return this._checkObjectArgs(e),this.publicKey=new zk(e.publicKey),this.prevTxId=f.Buffer.isBuffer(e.prevTxId)?e.prevTxId:f.Buffer.from(e.prevTxId,"hex"),this.outputIndex=e.outputIndex,this.inputIndex=e.inputIndex,this.signature=e.signature instanceof $l?e.signature:f.Buffer.isBuffer(e.signature)?$l.fromBuffer(e.signature):$l.fromString(e.signature),this.sigtype=e.sigtype,this};Rn.prototype._checkObjectArgs=function(e){sn.checkArgument(zk(e.publicKey),"publicKey"),sn.checkArgument(!Pc.isUndefined(e.inputIndex),"inputIndex"),sn.checkArgument(!Pc.isUndefined(e.outputIndex),"outputIndex"),sn.checkState(Pc.isNumber(e.inputIndex),"inputIndex must be a number"),sn.checkState(Pc.isNumber(e.outputIndex),"outputIndex must be a number"),sn.checkArgument(e.signature,"signature"),sn.checkArgument(e.prevTxId,"prevTxId"),sn.checkState(e.signature instanceof $l||f.Buffer.isBuffer(e.signature)||jk.isHexa(e.signature),"signature must be a buffer or hexa value"),sn.checkState(f.Buffer.isBuffer(e.prevTxId)||jk.isHexa(e.prevTxId),"prevTxId must be a buffer or hexa value"),sn.checkArgument(e.sigtype,"sigtype"),sn.checkState(Pc.isNumber(e.sigtype),"sigtype must be a number")};Rn.prototype.toObject=Rn.prototype.toJSON=function(){return{publicKey:this.publicKey.toString(),prevTxId:this.prevTxId.toString("hex"),outputIndex:this.outputIndex,inputIndex:this.inputIndex,signature:this.signature.toString(),sigtype:this.sigtype}};Rn.fromObject=function(e){return sn.checkArgument(e),new Rn(e)};Kk.exports=Rn});var Zk=P((Xae,Yk)=>{"use strict";g();var R7=Tc(),Gk=Oe(),Qb=Ac(),k7=fi(),B7=li(),Wk=et(),Vk=ut(),N7=Rc();function ia(){Qb.apply(this,arguments)}R7(ia,Qb);ia.prototype.getSignatures=function(e,t,r,i){Gk.checkState(this.output instanceof k7),i=i||Vk.SIGHASH_ALL|Vk.SIGHASH_FORKID;var n=t.toPublicKey();return n.toString()===this.output.script.getPublicKey().toString("hex")?[new N7({publicKey:n,prevTxId:this.prevTxId,outputIndex:this.outputIndex,inputIndex:r,signature:B7.sign(e,t,i,r,this.output.script,this.output.satoshisBN),sigtype:i})]:[]};ia.prototype.addSignature=function(e,t){return Gk.checkState(this.isValidSignature(e,t),"Signature is invalid"),this.setScript(Wk.buildPublicKeyIn(t.signature.toDER(),t.sigtype)),this};ia.prototype.clearSignatures=function(){return this.setScript(Wk.empty()),this};ia.prototype.isFullySigned=function(){return this.script.isPublicKeyIn()};ia.SCRIPT_MAX_SIZE=74;ia.prototype._estimateSize=function(){return Qb.BASE_SIZE+ia.SCRIPT_MAX_SIZE};Yk.exports=ia});var eB=P((Qae,Qk)=>{"use strict";g();var C7=Tc(),Xk=Oe(),L7=ke(),e_=Ac(),M7=fi(),D7=li(),Jk=et(),$k=ut(),q7=Rc();function na(){e_.apply(this,arguments)}C7(na,e_);na.prototype.getSignatures=function(e,t,r,i,n){Xk.checkState(this.output instanceof M7),n=n||L7.sha256ripemd160(t.publicKey.toBuffer()),i=i||$k.SIGHASH_ALL|$k.SIGHASH_FORKID;var o=this.output.script.chunks[2]&&this.output.script.chunks[2].buf;return o&&n.equals(o)?[new q7({publicKey:t.publicKey,prevTxId:this.prevTxId,outputIndex:this.outputIndex,inputIndex:r,signature:D7.sign(e,t,i,r,this.output.script,this.output.satoshisBN),sigtype:i})]:[]};na.prototype.addSignature=function(e,t){return Xk.checkState(this.isValidSignature(e,t),"Signature is invalid"),this.setScript(Jk.buildPublicKeyHashIn(t.publicKey,t.signature.toDER(),t.sigtype)),this};na.prototype.clearSignatures=function(){return this.setScript(Jk.empty()),this};na.prototype.isFullySigned=function(){return this.script.isPublicKeyHashIn()};na.SCRIPT_MAX_SIZE=108;na.prototype._estimateSize=function(){return e_.BASE_SIZE+na.SCRIPT_MAX_SIZE};Qk.exports=na});var iB=P((tse,rB)=>{"use strict";g();var kn=Je(),H7=Tc(),jg=Ac(),U7=fi(),Xl=Oe(),tB=et(),Fg=ut(),t_=li(),r_=Rc(),F7=Gt(),j7=Ic();function Lr(e,t,r,i){jg.apply(this,arguments);var n=this;t=t||e.publicKeys,r=r||e.threshold,i=i||e.signatures,this.publicKeys=t.map(o=>o.toString("hex")).sort().map(o=>new F7(o)),Xl.checkState(tB.buildMultisigOut(this.publicKeys,r).equals(this.output.script),"Provided public keys don't match to the provided output script"),this.publicKeyIndex={},kn.each(this.publicKeys,function(o,a){n.publicKeyIndex[o.toString()]=a}),this.threshold=r,this.signatures=i?this._deserializeSignatures(i):new Array(this.publicKeys.length)}H7(Lr,jg);Lr.prototype.toObject=function(){var e=jg.prototype.toObject.apply(this,arguments);return e.threshold=this.threshold,e.publicKeys=kn.map(this.publicKeys,function(t){return t.toString()}),e.signatures=this._serializeSignatures(),e};Lr.prototype._deserializeSignatures=function(e){return kn.map(e,function(t){if(t)return new r_(t)})};Lr.prototype._serializeSignatures=function(){return kn.map(this.signatures,function(e){if(e)return e.toObject()})};Lr.prototype.getSignatures=function(e,t,r,i){Xl.checkState(this.output instanceof U7),i=i||Fg.SIGHASH_ALL|Fg.SIGHASH_FORKID;var n=this,o=[];return kn.each(this.publicKeys,function(a){a.toString()===t.publicKey.toString()&&o.push(new r_({publicKey:t.publicKey,prevTxId:n.prevTxId,outputIndex:n.outputIndex,inputIndex:r,signature:t_.sign(e,t,i,r,n.output.script,n.output.satoshisBN),sigtype:i}))}),o};Lr.prototype.addSignature=function(e,t){return Xl.checkState(!this.isFullySigned(),"All needed signatures have already been added"),Xl.checkArgument(!kn.isUndefined(this.publicKeyIndex[t.publicKey.toString()]),"Signature has no matching public key"),Xl.checkState(this.isValidSignature(e,t)),this.signatures[this.publicKeyIndex[t.publicKey.toString()]]=t,this._updateScript(),this};Lr.prototype._updateScript=function(){return this.setScript(tB.buildMultisigIn(this.publicKeys,this.threshold,this._createSignatures())),this};Lr.prototype._createSignatures=function(){return kn.map(kn.filter(this.signatures,function(e){return!kn.isUndefined(e)}),function(e){return f.Buffer.concat([e.signature.toDER(),f.Buffer.from([e.sigtype&255])])})};Lr.prototype.clearSignatures=function(){this.signatures=new Array(this.publicKeys.length),this._updateScript()};Lr.prototype.isFullySigned=function(){return this.countSignatures()===this.threshold};Lr.prototype.countMissingSignatures=function(){return this.threshold-this.countSignatures()};Lr.prototype.countSignatures=function(){return kn.reduce(this.signatures,function(e,t){return e+!!t},0)};Lr.prototype.publicKeysWithoutSignature=function(){var e=this;return kn.filter(this.publicKeys,function(t){return!e.signatures[e.publicKeyIndex[t.toString()]]})};Lr.prototype.isValidSignature=function(e,t){return t.signature.nhashtype=t.sigtype,t_.verify(e,t.signature,t.publicKey,t.inputIndex,this.output.script,this.output.satoshisBN)};Lr.normalizeSignatures=function(e,t,r,i,n){return n.map(function(o){var a=null;return i=i.filter(function(s){if(a)return!0;var u=new r_({signature:Fg.fromTxFormat(s),publicKey:o,prevTxId:t.prevTxId,outputIndex:t.outputIndex,inputIndex:r,sigtype:Fg.SIGHASH_ALL});u.signature.nhashtype=u.sigtype;var c=t_.verify(e,u.signature,u.publicKey,u.inputIndex,t.output.script);return c?(a=u,!1):!0}),a||null})};Lr.SIGNATURE_SIZE=73;Lr.prototype._estimateSize=function(){var e=1+this.threshold*Lr.SIGNATURE_SIZE;return jg.BASE_SIZE+j7(e).toBuffer().length+e};rB.exports=Lr});var uB=P((ise,sB)=>{"use strict";g();var Bn=Je(),z7=Tc(),zg=Ac(),K7=fi(),Jl=Oe(),i_=et(),nB=ut(),oB=li(),aB=Rc(),V7=Gt(),G7=Ic();function Ir(e,t,r,i){zg.apply(this,arguments);var n=this;t=t||e.publicKeys,r=r||e.threshold,i=i||e.signatures,this.publicKeys=t.map(o=>o.toString("hex")).sort().map(o=>new V7(o)),this.redeemScript=i_.buildMultisigOut(this.publicKeys,r),Jl.checkState(i_.buildScriptHashOut(this.redeemScript).equals(this.output.script),"Provided public keys don't hash to the provided output"),this.publicKeyIndex={},Bn.each(this.publicKeys,function(o,a){n.publicKeyIndex[o.toString()]=a}),this.threshold=r,this.signatures=i?this._deserializeSignatures(i):new Array(this.publicKeys.length)}z7(Ir,zg);Ir.prototype.toObject=function(){var e=zg.prototype.toObject.apply(this,arguments);return e.threshold=this.threshold,e.publicKeys=Bn.map(this.publicKeys,function(t){return t.toString()}),e.signatures=this._serializeSignatures(),e};Ir.prototype._deserializeSignatures=function(e){return Bn.map(e,function(t){if(t)return new aB(t)})};Ir.prototype._serializeSignatures=function(){return Bn.map(this.signatures,function(e){if(e)return e.toObject()})};Ir.prototype.getSignatures=function(e,t,r,i){Jl.checkState(this.output instanceof K7),i=i||nB.SIGHASH_ALL|nB.SIGHASH_FORKID;var n=this,o=[];return Bn.each(this.publicKeys,function(a){a.toString()===t.publicKey.toString()&&o.push(new aB({publicKey:t.publicKey,prevTxId:n.prevTxId,outputIndex:n.outputIndex,inputIndex:r,signature:oB.sign(e,t,i,r,n.redeemScript,n.output.satoshisBN),sigtype:i}))}),o};Ir.prototype.addSignature=function(e,t){return Jl.checkState(!this.isFullySigned(),"All needed signatures have already been added"),Jl.checkArgument(!Bn.isUndefined(this.publicKeyIndex[t.publicKey.toString()]),"Signature has no matching public key"),Jl.checkState(this.isValidSignature(e,t)),this.signatures[this.publicKeyIndex[t.publicKey.toString()]]=t,this._updateScript(),this};Ir.prototype._updateScript=function(){return this.setScript(i_.buildP2SHMultisigIn(this.publicKeys,this.threshold,this._createSignatures(),{cachedMultisig:this.redeemScript})),this};Ir.prototype._createSignatures=function(){return Bn.map(Bn.filter(this.signatures,function(e){return!Bn.isUndefined(e)}),function(e){return f.Buffer.concat([e.signature.toDER(),f.Buffer.from([e.sigtype&255])])})};Ir.prototype.clearSignatures=function(){this.signatures=new Array(this.publicKeys.length),this._updateScript()};Ir.prototype.isFullySigned=function(){return this.countSignatures()===this.threshold};Ir.prototype.countMissingSignatures=function(){return this.threshold-this.countSignatures()};Ir.prototype.countSignatures=function(){return Bn.reduce(this.signatures,function(e,t){return e+!!t},0)};Ir.prototype.publicKeysWithoutSignature=function(){var e=this;return Bn.filter(this.publicKeys,function(t){return!e.signatures[e.publicKeyIndex[t.toString()]]})};Ir.prototype.isValidSignature=function(e,t){return t.signature.nhashtype=t.sigtype,oB.verify(e,t.signature,t.publicKey,t.inputIndex,this.redeemScript,this.output.satoshisBN)};Ir.SIGNATURE_SIZE=73;Ir.PUBKEY_SIZE=34;Ir.prototype._estimateSize=function(){var e=this.publicKeys.length*Ir.PUBKEY_SIZE,t=this.threshold*Ir.SIGNATURE_SIZE,r=3+e,i=r<=75?1:r<=255?2:3,n=t+1+i+r;return zg.BASE_SIZE+G7(n).toBuffer().length+n};sB.exports=Ir});var ao=P((ose,kc)=>{g();kc.exports=Ac();kc.exports.PublicKey=Zk();kc.exports.PublicKeyHash=eB();kc.exports.MultiSig=iB();kc.exports.MultiSigScriptHash=uB()});var li=P((sse,dB)=>{"use strict";g();var W7=jt(),Pi=ut(),Ql=et(),Y7=fi(),Z7=oo(),eh=Tn(),cB=Ye(),Kg=ke(),fB=cn(),n_=Oe(),o_=un(),Ya=Je(),lB=f.Buffer.from("0000000000000000000000000000000000000000000000000000000000000001","hex"),$7="ffffffffffffffff",X7=o_.SCRIPT_ENABLE_SIGHASH_FORKID,J7=function(e,t,r,i,n){var o=e.inputs[r];n_.checkArgument(n instanceof cB,"For ForkId=0 signatures, satoshis or complete input must be provided");function a(R){var B=new eh;Ya.each(R.inputs,function(I){B.writeReverse(I.prevTxId),B.writeUInt32LE(I.outputIndex)});var H=B.toBuffer(),j=Kg.sha256sha256(H);return j}function s(R){var B=new eh;Ya.each(R.inputs,function(I){B.writeUInt32LE(I.sequenceNumber)});var H=B.toBuffer(),j=Kg.sha256sha256(H);return j}function u(R,B){var H=new eh;Ya.isUndefined(B)?Ya.each(R.outputs,function(k){k.toBufferWriter(H)}):R.outputs[B].toBufferWriter(H);var j=H.toBuffer(),I=Kg.sha256sha256(j);return I}var c=f.Buffer.alloc(32),l=f.Buffer.alloc(32),d=f.Buffer.alloc(32);t&Pi.SIGHASH_ANYONECANPAY||(c=a(e)),!(t&Pi.SIGHASH_ANYONECANPAY)&&(t&31)!==Pi.SIGHASH_SINGLE&&(t&31)!==Pi.SIGHASH_NONE&&(l=s(e)),(t&31)!==Pi.SIGHASH_SINGLE&&(t&31)!==Pi.SIGHASH_NONE?d=u(e):(t&31)===Pi.SIGHASH_SINGLE&&r<e.outputs.length&&(d=u(e,r));var p=new eh;p.writeInt32LE(e.version),p.write(c),p.write(l),p.writeReverse(o.prevTxId),p.writeUInt32LE(o.outputIndex);var y=i.toBuffer();p.writeVarintNum(y.length),p.write(y),p.writeUInt64LEBN(n);var _=o.sequenceNumber;p.writeUInt32LE(_),p.write(d),p.writeUInt32LE(e.nLockTime),p.writeUInt32LE(t>>>0);var T=p.toBuffer();return T},hB=function(t,r,i,n,o,a){var s=s_(),u=ao();Ya.isUndefined(a)&&(a=X7);var c=s.shallowCopy(t);if(n instanceof Ql||(n=new Ql(n)),a&o_.SCRIPT_ENABLE_REPLAY_PROTECTION){var l=r>>8,d=16711680|l^57005;r=d<<8|r&255}if(r&Pi.SIGHASH_FORKID&&!(r&Pi.SIGHASH_CHRONICLE)&&a&o_.SCRIPT_ENABLE_SIGHASH_FORKID)return J7(c,r,i,n,o);n=new Ql(n),n.removeCodeseparators();var p;for(p=0;p<c.inputs.length;p++)c.inputs[p]=new u(c.inputs[p]).setScript(Ql.empty());if(c.inputs[i]=new u(c.inputs[i]).setScript(n),(r&31)===Pi.SIGHASH_NONE||(r&31)===Pi.SIGHASH_SINGLE)for(p=0;p<c.inputs.length;p++)p!==i&&(c.inputs[p].sequenceNumber=0);if((r&31)===Pi.SIGHASH_NONE)c.outputs=[];else if((r&31)===Pi.SIGHASH_SINGLE){if(i>=c.outputs.length)return lB;for(c.outputs.length=i+1,p=0;p<i;p++)c.outputs[p]=new Y7({satoshis:cB.fromBuffer(W7.Buffer.from($7,"hex")),script:Ql.empty()})}r&Pi.SIGHASH_ANYONECANPAY&&(c.inputs=[c.inputs[i]]);var y=new eh().write(c.toBuffer()).writeInt32LE(r).toBuffer();return y},a_=function(t,r,i,n,o,a){var s=hB(t,r,i,n,o,a);if(s.compare(lB)===0)return s;var u=Kg.sha256sha256(s);return u=new Z7(u).readReverse(),u};function Q7(e,t,r,i,n,o,a){var s=a_(e,r,i,n,o,a),u=fB.sign(s,t,"little").set({nhashtype:r});return u}function e9(e,t,r,i,n,o,a){n_.checkArgument(!Ya.isUndefined(e)),n_.checkArgument(!Ya.isUndefined(t)&&!Ya.isUndefined(t.nhashtype));var s=a_(e,t.nhashtype,i,n,o,a);return fB.verify(s,t,r,"little")}dB.exports={sighashPreimage:hB,sighash:a_,sign:Q7,verify:e9}});var u_=P((cse,gB)=>{"use strict";g();var oa=Je(),Vg=Oe(),pB=ei(),t9=et(),r9=Ti();function aa(e){if(!(this instanceof aa))return new aa(e);Vg.checkArgument(oa.isObject(e),"Must provide an object from where to extract data");var t=e.address?new r9(e.address):void 0,r=e.txid?e.txid:e.txId;if(!r||!pB.isHexaString(r)||r.length>64)throw new Error("Invalid TXID in object",e);var i=oa.isUndefined(e.vout)?e.outputIndex:e.vout;if(!oa.isNumber(i))throw new Error("Invalid outputIndex, received "+i);Vg.checkArgument(!oa.isUndefined(e.scriptPubKey)||!oa.isUndefined(e.script),"Must provide the scriptPubKey for that output!");var n=new t9(e.scriptPubKey||e.script);Vg.checkArgument(!oa.isUndefined(e.amount)||!oa.isUndefined(e.satoshis),"Must provide an amount for the output");var o=oa.isUndefined(e.amount)?e.satoshis:Math.round(e.amount*1e8);Vg.checkArgument(oa.isNumber(o),"Amount must be a number"),pB.defineImmutable(this,{address:t,txId:r,outputIndex:i,script:n,satoshis:o})}aa.prototype.inspect=function(){return"<UnspentOutput: "+this.txId+":"+this.outputIndex+", satoshis: "+this.satoshis+", address: "+this.address+">"};aa.prototype.toString=function(){return this.txId+":"+this.outputIndex};aa.fromObject=function(e){return new aa(e)};aa.prototype.toObject=aa.prototype.toJSON=function(){return{address:this.address?this.address.toString():void 0,txid:this.txId,vout:this.outputIndex,scriptPubKey:this.script.toBuffer().toString("hex"),amount:Number.parseFloat((this.satoshis/1e8).toFixed(8))}};gB.exports=aa});var s_=P((lse,EB)=>{"use strict";g();var Ie=Je(),Yr=Oe(),i9=jt(),Dr=ci(),vB=ei(),yB=oo(),n9=Tn(),mB=Ic(),bB=ke(),Wg=ut(),_B=li(),o9=Ti(),wB=u_(),Mr=ao(),a9=Mr.PublicKeyHash,s9=Mr.PublicKey,u9=Mr.MultiSigScriptHash,c9=Mr.MultiSig,Nn=fi(),so=et(),f9=Zr(),Gg=Ye(),l9=un(),h9=l9.SCRIPT_ENABLE_SIGHASH_FORKID;function oe(e){if(!(this instanceof oe))return new oe(e);if(this.inputs=[],this.outputs=[],this._inputAmount=void 0,this._outputAmount=void 0,e){if(e instanceof oe)return oe.shallowCopy(e);if(vB.isHexa(e))this.fromString(e);else if(f.Buffer.isBuffer(e))this.fromBuffer(e);else if(Ie.isObject(e))this.fromObject(e);else throw new Dr.InvalidArgument("Must provide an object or string to deserialize a transaction")}else this._newTransaction()}var d9=1,p9=0,g9=1e6;oe.DUST_AMOUNT=546;oe.FEE_SECURITY_MARGIN=150;oe.MAX_MONEY=21e6*1e8;oe.NLOCKTIME_BLOCKHEIGHT_LIMIT=5e8;oe.NLOCKTIME_MAX_VALUE=4294967295;oe.FEE_PER_KB=500;oe.CHANGE_OUTPUT_MAX_SIZE=62;oe.shallowCopy=function(e){var t=new oe(e.toBuffer());return t};var SB={configurable:!1,enumerable:!0,get:function(){return this._hash=new yB(this._getHash()).readReverse().toString("hex"),this._hash}};Object.defineProperty(oe.prototype,"hash",SB);Object.defineProperty(oe.prototype,"id",SB);var c_={configurable:!1,enumerable:!0,get:function(){return this._getInputAmount()}};Object.defineProperty(oe.prototype,"inputAmount",c_);c_.get=function(){return this._getOutputAmount()};Object.defineProperty(oe.prototype,"outputAmount",c_);oe.prototype._getHash=function(){return bB.sha256sha256(this.toBuffer())};oe.prototype.serialize=function(e){return e===!0||e&&e.disableAll?this.uncheckedSerialize():this.checkedSerialize(e)};oe.prototype.uncheckedSerialize=oe.prototype.toString=function(){return this.toBuffer().toString("hex")};oe.prototype.checkedSerialize=function(e){var t=this.getSerializationError(e);if(t)throw t.message+=" - For more information please see: https://bsv.io/api/lib/transaction#serialization-checks",t;return this.uncheckedSerialize()};oe.prototype.invalidSatoshis=function(){for(var e=!1,t=0;t<this.outputs.length;t++)this.outputs[t].invalidSatoshis()&&(e=!0);return e};oe.prototype.getSerializationError=function(e){if(e=e||{},this.invalidSatoshis())return new Dr.Transaction.InvalidSatoshis;var t=this._getUnspentValue(),r;return t<0?e.disableMoreOutputThanInput||(r=new Dr.Transaction.InvalidOutputAmountSum):r=this._hasFeeError(e,t),r||this._hasDustOutputs(e)||this._isMissingSignatures(e)};oe.prototype._hasFeeError=function(e,t){if(!Ie.isUndefined(this._fee)&&this._fee!==t)return new Dr.Transaction.FeeError.Different("Unspent value is "+t+" but specified fee is "+this._fee);if(!e.disableLargeFees){var r=Math.floor(oe.FEE_SECURITY_MARGIN*this._estimateFee());if(t>r)return this._missingChange()?new Dr.Transaction.ChangeAddressMissing("Fee is too large and no change address was provided"):new Dr.Transaction.FeeError.TooLarge("expected less than "+r+" but got "+t)}};oe.prototype._missingChange=function(){return!this._changeScript};oe.prototype._hasDustOutputs=function(e){if(!e.disableDustOutputs){var t,r;for(t in this.outputs)if(r=this.outputs[t],r.satoshis<oe.DUST_AMOUNT&&!r.script.isDataOut()&&!r.script.isSafeDataOut())return new Dr.Transaction.DustOutputs}};oe.prototype._isMissingSignatures=function(e){if(!e.disableIsFullySigned&&!this.isFullySigned())return new Dr.Transaction.MissingSignatures};oe.prototype.inspect=function(){return"<Transaction: "+this.uncheckedSerialize()+">"};oe.prototype.toBuffer=function(){var e=new n9;return this.toBufferWriter(e).toBuffer()};oe.prototype.toBufferWriter=function(e){return e.writeInt32LE(this.version),e.writeVarintNum(this.inputs.length),Ie.each(this.inputs,function(t){t.toBufferWriter(e)}),e.writeVarintNum(this.outputs.length),Ie.each(this.outputs,function(t){t.toBufferWriter(e)}),e.writeUInt32LE(this.nLockTime),e};oe.prototype.fromBuffer=function(e){var t=new yB(e);return this.fromBufferReader(t)};oe.prototype.fromBufferReader=function(e){Yr.checkArgument(!e.finished(),"No transaction data received");var t,r,i;for(this.version=e.readInt32LE(),r=e.readVarintNum(),t=0;t<r;t++){var n=Mr.fromBufferReader(e);this.inputs.push(n)}for(i=e.readVarintNum(),t=0;t<i;t++)this.outputs.push(Nn.fromBufferReader(e));return this.nLockTime=e.readUInt32LE(),this};oe.prototype.toObject=oe.prototype.toJSON=function(){var t=[];this.inputs.forEach(function(n){t.push(n.toObject())});var r=[];this.outputs.forEach(function(n){r.push(n.toObject())});var i={hash:this.hash,version:this.version,inputs:t,outputs:r,nLockTime:this.nLockTime};return this._changeScript&&(i.changeScript=this._changeScript.toString()),Ie.isUndefined(this._changeIndex)||(i.changeIndex=this._changeIndex),Ie.isUndefined(this._fee)||(i.fee=this._fee),i};oe.prototype.fromObject=function(t){Yr.checkArgument(Ie.isObject(t)||t instanceof oe);var r=this,i;return t instanceof oe?i=t.toObject():i=t,Ie.each(i.inputs,function(n){if(!n.output||!n.output.script){r.uncheckedAddInput(new Mr(n));return}var o=new so(n.output.script),a;if(o.isPublicKeyHashOut())a=new Mr.PublicKeyHash(n);else if(o.isScriptHashOut()&&n.publicKeys&&n.threshold)a=new Mr.MultiSigScriptHash(n,n.publicKeys,n.threshold,n.signatures);else if(o.isPublicKeyOut())a=new Mr.PublicKey(n);else throw new Dr.Transaction.Input.UnsupportedScript(n.output.script);r.addInput(a)}),Ie.each(i.outputs,function(n){r.addOutput(new Nn(n))}),i.changeIndex&&(this._changeIndex=i.changeIndex),i.changeScript&&(this._changeScript=new so(i.changeScript)),i.fee&&(this._fee=i.fee),this.nLockTime=i.nLockTime,this.version=i.version,this._checkConsistency(t),this};oe.prototype._checkConsistency=function(e){Ie.isUndefined(this._changeIndex)||(Yr.checkState(this._changeScript,"Change script is expected."),Yr.checkState(this.outputs[this._changeIndex],"Change index points to undefined output."),Yr.checkState(this.outputs[this._changeIndex].script.toString()===this._changeScript.toString(),"Change output has an unexpected script.")),e&&e.hash&&Yr.checkState(e.hash===this.hash,"Hash in object does not match transaction hash.")};oe.prototype.lockUntilDate=function(e){if(Yr.checkArgument(e),Ie.isNumber(e)&&e<oe.NLOCKTIME_BLOCKHEIGHT_LIMIT)throw new Dr.Transaction.LockTimeTooEarly;Ie.isDate(e)&&(e=e.getTime()/1e3);for(var t=0;t<this.inputs.length;t++)this.inputs[t].sequenceNumber===Mr.DEFAULT_SEQNUMBER&&(this.inputs[t].sequenceNumber=Mr.DEFAULT_LOCKTIME_SEQNUMBER);return this.nLockTime=e,this};oe.prototype.lockUntilBlockHeight=function(e){if(Yr.checkArgument(Ie.isNumber(e)),e>=oe.NLOCKTIME_BLOCKHEIGHT_LIMIT)throw new Dr.Transaction.BlockHeightTooHigh;if(e<0)throw new Dr.Transaction.NLockTimeOutOfRange;for(var t=0;t<this.inputs.length;t++)this.inputs[t].sequenceNumber===Mr.DEFAULT_SEQNUMBER&&(this.inputs[t].sequenceNumber=Mr.DEFAULT_LOCKTIME_SEQNUMBER);return this.nLockTime=e,this};oe.prototype.getLockTime=function(){return this.nLockTime?this.nLockTime<oe.NLOCKTIME_BLOCKHEIGHT_LIMIT?this.nLockTime:new Date(1e3*this.nLockTime):null};oe.prototype.fromString=function(e){this.fromBuffer(i9.Buffer.from(e,"hex"))};oe.prototype._newTransaction=function(){this.version=d9,this.nLockTime=p9};oe.prototype.from=function(e,t,r){if(Ie.isArray(e)){var i=this;return Ie.each(e,function(o){i.from(o,t,r)}),this}var n=Ie.some(this.inputs,function(o){return o.prevTxId.toString("hex")===e.txId&&o.outputIndex===e.outputIndex});return n?this:(t&&r?this._fromMultisigUtxo(e,t,r):this._fromNonP2SH(e),this)};oe.prototype._fromNonP2SH=function(e){var t;e=new wB(e),e.script.isPublicKeyHashOutPrefix()?t=a9:e.script.isPublicKeyOut()?t=s9:t=Mr,this.addInput(new t({output:new Nn({script:e.script,satoshis:e.satoshis}),prevTxId:e.txId,outputIndex:e.outputIndex,script:so.empty()}))};oe.prototype._fromMultisigUtxo=function(e,t,r){Yr.checkArgument(r<=t.length,"Number of required signatures must be greater than the number of public keys");var i;if(e=new wB(e),e.script.isMultisigOut())i=c9;else if(e.script.isScriptHashOut())i=u9;else throw new Dr.Transaction.Input.UnsupportedScript(e.script.toString());this.addInput(new i({output:new Nn({script:e.script,satoshis:e.satoshis}),prevTxId:e.txId,outputIndex:e.outputIndex,script:so.empty()},t,r))};oe.prototype.addInput=function(e,t,r){if(Yr.checkArgumentType(e,Mr,"input"),!e.output&&(Ie.isUndefined(t)||Ie.isUndefined(r)))throw new Dr.Transaction.NeedMoreInfo("Need information about the UTXO script and satoshis");return!e.output&&t&&!Ie.isUndefined(r)&&(t=t instanceof so?t:new so(t),Yr.checkArgumentType(r,"number","satoshis"),e.output=new Nn({script:t,satoshis:r})),this.uncheckedAddInput(e)};oe.prototype.uncheckedAddInput=function(e){return Yr.checkArgumentType(e,Mr,"input"),this.inputs.push(e),this._inputAmount=void 0,this._updateChangeOutput(),this};oe.prototype.hasAllUtxoInfo=function(){return Ie.every(this.inputs.map(function(e){return!!e.output}))};oe.prototype.fee=function(e){return Yr.checkArgument(Ie.isNumber(e),"amount must be a number"),this._fee=e,this._updateChangeOutput(),this};oe.prototype.feePerKb=function(e){return Yr.checkArgument(Ie.isNumber(e),"amount must be a number"),this._feePerKb=e,this._updateChangeOutput(),this};oe.prototype.change=function(e){return Yr.checkArgument(e,"address is required"),this._changeScript=so.fromAddress(e),this._updateChangeOutput(),this};oe.prototype.getChangeOutput=function(){return Ie.isUndefined(this._changeIndex)?null:this.outputs[this._changeIndex]};oe.prototype.to=function(e,t){if(Ie.isArray(e)){var r=this;return Ie.each(e,function(i){r.to(i.address,i.satoshis)}),this}return Yr.checkArgument(vB.isNaturalNumber(t),"Amount is expected to be a positive integer"),this.addOutput(new Nn({script:so(new o9(e)),satoshis:t})),this};oe.prototype.addData=function(e){return this.addOutput(new Nn({script:so.buildDataOut(e),satoshis:0})),this};oe.prototype.addSafeData=function(e){return this.addOutput(new Nn({script:so.buildSafeDataOut(e),satoshis:0})),this};oe.prototype.addOutput=function(e){return Yr.checkArgumentType(e,Nn,"output"),this._addOutput(e),this._updateChangeOutput(),this};oe.prototype.clearOutputs=function(){return this.outputs=[],this._clearSignatures(),this._outputAmount=void 0,this._changeIndex=void 0,this._updateChangeOutput(),this};oe.prototype._addOutput=function(e){this.outputs.push(e),this._outputAmount=void 0};oe.prototype._getOutputAmount=function(){if(Ie.isUndefined(this._outputAmount)){var e=this;this._outputAmount=0,Ie.each(this.outputs,function(t){e._outputAmount+=t.satoshis})}return this._outputAmount};oe.prototype._getInputAmount=function(){if(Ie.isUndefined(this._inputAmount)){var e=this;this._inputAmount=0,Ie.each(this.inputs,function(t){if(Ie.isUndefined(t.output))throw new Dr.Transaction.Input.MissingPreviousOutput;e._inputAmount+=t.output.satoshis})}return this._inputAmount};oe.prototype._updateChangeOutput=function(){if(this._changeScript){this._clearSignatures(),Ie.isUndefined(this._changeIndex)||this._removeOutput(this._changeIndex),this._changeIndex=this.outputs.length,this._addOutput(new Nn({script:this._changeScript,satoshis:0}));var e=this._getUnspentValue(),t=this.getFee(),r=e-t;this._removeOutput(this._changeIndex),this._changeIndex=void 0,r>=oe.DUST_AMOUNT&&(this._changeIndex=this.outputs.length,this._addOutput(new Nn({script:this._changeScript,satoshis:r})))}};oe.prototype.getFee=function(){return this.isCoinbase()?0:Ie.isUndefined(this._fee)?this._changeScript?this._estimateFee():this._getUnspentValue():this._fee};oe.prototype._estimateFee=function(){var e=this._estimateSize();return Math.ceil(e/1e3*(this._feePerKb||oe.FEE_PER_KB))};oe.prototype._getUnspentValue=function(){return this._getInputAmount()-this._getOutputAmount()};oe.prototype._clearSignatures=function(){Ie.each(this.inputs,function(e){e.clearSignatures!==Mr.prototype.clearSignatures&&e.clearSignatures()})};oe.prototype._estimateSize=function(){var e=8;return e+=mB(this.inputs.length).toBuffer().length,e+=mB(this.outputs.length).toBuffer().length,Ie.each(this.inputs,function(t){e+=t._estimateSize()}),Ie.each(this.outputs,function(t){e+=t.getSize()}),e};oe.prototype._removeOutput=function(e){var t=this.outputs[e];this.outputs=Ie.without(this.outputs,t),this._outputAmount=void 0};oe.prototype.removeOutput=function(e){this._removeOutput(e),this._updateChangeOutput()};oe.prototype.sort=function(){return this.sortInputs(function(e){var t=Array.prototype.concat.apply([],e);return t.sort(function(r,i){return r.prevTxId.compare(i.prevTxId)||r.outputIndex-i.outputIndex}),t}),this.sortOutputs(function(e){var t=Array.prototype.concat.apply([],e);return t.sort(function(r,i){return r.satoshis-i.satoshis||r.script.toBuffer().compare(i.script.toBuffer())}),t}),this};oe.prototype.shuffleOutputs=function(){return this.sortOutputs(Ie.shuffle)};oe.prototype.sortOutputs=function(e){var t=e(this.outputs);return this._newOutputOrder(t)};oe.prototype.sortInputs=function(e){return this.inputs=e(this.inputs),this._clearSignatures(),this};oe.prototype._newOutputOrder=function(e){var t=this.outputs.length!==e.length||Ie.difference(this.outputs,e).length!==0;if(t)throw new Dr.Transaction.InvalidSorting;if(!Ie.isUndefined(this._changeIndex)){var r=this.outputs[this._changeIndex];this._changeIndex=e.indexOf(r)}return this.outputs=e,this};oe.prototype.removeInput=function(e,t){var r;if(!t&&Ie.isNumber(e)?r=e:r=Ie.findIndex(this.inputs,function(n){return n.prevTxId.toString("hex")===e&&n.outputIndex===t}),r<0||r>=this.inputs.length)throw new Dr.Transaction.InvalidIndex(r,this.inputs.length);var i=this.inputs[r];this.inputs=Ie.without(this.inputs,i),this._inputAmount=void 0,this._updateChangeOutput()};oe.prototype.sign=function(e,t){Yr.checkState(this.hasAllUtxoInfo(),"Not all utxo information is available to sign the transaction.");var r=this;return Ie.isArray(e)?(Ie.each(e,function(i){r.sign(i,t)}),this):(Ie.each(this.getSignatures(e,t),function(i){r.applySignature(i)}),this)};oe.prototype.getSignatures=function(e,t){e=new f9(e),t=t||Wg.SIGHASH_ALL|Wg.SIGHASH_FORKID;var r=this,i=[],n=bB.sha256ripemd160(e.publicKey.toBuffer());return Ie.each(this.inputs,function(a,s){Ie.each(a.getSignatures(r,e,s,t,n),function(u){i.push(u)})}),i};oe.prototype.applySignature=function(e){return this.inputs[e.inputIndex].addSignature(this,e),this};oe.prototype.isFullySigned=function(){return Ie.each(this.inputs,function(e){if(e.isFullySigned===Mr.prototype.isFullySigned)throw new Dr.Transaction.UnableToVerifySignature("Unrecognized script kind, or not enough information to execute script.This usually happens when creating a transaction from a serialized transaction")}),Ie.every(Ie.map(this.inputs,function(e){return e.isFullySigned()}))};oe.prototype.isValidSignature=function(e){var t=this;if(this.inputs[e.inputIndex].isValidSignature===Mr.prototype.isValidSignature)throw new Dr.Transaction.UnableToVerifySignature("Unrecognized script kind, or not enough information to execute script.This usually happens when creating a transaction from a serialized transaction");return this.inputs[e.inputIndex].isValidSignature(t,e)};oe.prototype.verifySignature=function(e,t,r,i,n,o){return _B.verify(this,e,t,r,i,n,o)};oe.prototype.verify=function(){if(this.inputs.length===0)return"transaction txins empty";if(this.outputs.length===0)return"transaction txouts empty";for(var e=new Gg(0),t=0;t<this.outputs.length;t++){var r=this.outputs[t];if(r.invalidSatoshis())return"transaction txout "+t+" satoshis is invalid";if(r._satoshisBN.gt(new Gg(oe.MAX_MONEY,10)))return"transaction txout "+t+" greater than MAX_MONEY";if(e=e.add(r._satoshisBN),e.gt(new Gg(oe.MAX_MONEY)))return"transaction txout "+t+" total output greater than MAX_MONEY"}if(this.toBuffer().length>g9)return"transaction over the maximum block size";var i={};for(t=0;t<this.inputs.length;t++){var n=this.inputs[t],o=n.prevTxId+":"+n.outputIndex;if(!Ie.isUndefined(i[o]))return"transaction input "+t+" duplicate input";i[o]=!0}var a=this.isCoinbase();if(a){var s=this.inputs[0]._scriptBuffer;if(s.length<2||s.length>100)return"coinbase transaction script size invalid"}else for(t=0;t<this.inputs.length;t++)if(this.inputs[t].isNull())return"transaction input "+t+" has null input";return!0};oe.prototype.isCoinbase=function(){return this.inputs.length===1&&this.inputs[0].isNull()};oe.prototype.sighash=function(e,t,r,i,n){t=t||Wg.SIGHASH_ALL|Wg.SIGHASH_FORKID;var o=this.inputs[e];if(!o)throw new Error("Input index "+e+" does not exist");return!r&&o.output&&(r=o.output.script),!i&&o.output&&(i=new Gg(o.output.satoshis)),n=n||h9,_B.sighash(this,t,e,r,i,n)};EB.exports=oe});var Tt=P((dse,Qs)=>{g();Qs.exports=s_();Qs.exports.Input=ao();Qs.exports.Output=fi();Qs.exports.UnspentOutput=u_();Qs.exports.Signature=Rc();Qs.exports.Sighash=li()});var un=P((gse,AB)=>{"use strict";g();var Yg=Je(),Zg=Mg(),U=Or(),Se=Ye(),th=ke(),sa=ut(),f_=Gt();function xB(e){return e.map(function(t){return f.Buffer.isBuffer(t)?f.Buffer.from(t):t})}var M=function e(t){if(!(this instanceof e))return new e(t);t?(this.initialize(),this.set(t)):this.initialize()};M.prototype._verifyCore=function(e,t,r,i,n,o){var a=Tt();if(Yg.isUndefined(r)&&(r=new a),Yg.isUndefined(i)&&(i=0),Yg.isUndefined(n)&&(n=M.currentConsensusFlags(),o||(n&=~M.SCRIPT_ENABLE_SIGHASH_FORKID)),n&M.SCRIPT_ENABLE_SIGHASH_FORKID&&(n|=M.SCRIPT_VERIFY_STRICTENC,!o))throw new Error("internal error - need satoshisBN to verify FORKID transactions");this.set({script:e,tx:r,nin:i,flags:n,satoshisBN:o});var s;if((n&M.SCRIPT_VERIFY_SIGPUSHONLY)!==0&&!e.isPushOnly())return this.errstr="SCRIPT_ERR_SIG_PUSHONLY",!1;if(!this.evaluate())return!1;var u=(n&M.SCRIPT_VERIFY_P2SH)!==0&&(n&M.SCRIPT_UTXO_AFTER_GENESIS)===0;u&&(s=this.stack.slice());var c=this.stack;if(this.initialize(),this.set({script:t,stack:c,tx:r,nin:i,flags:n,satoshisBN:o}),!this.evaluate())return!1;if(this.stack.length===0)return this.errstr="SCRIPT_ERR_EVAL_FALSE_NO_RESULT",!1;var l=this.stack[this.stack.length-1];if(!M.castToBool(l))return this.errstr="SCRIPT_ERR_EVAL_FALSE_IN_STACK",!1;if(u&&t.isScriptHashOut()){if(!e.isPushOnly())return this.errstr="SCRIPT_ERR_SIG_PUSHONLY",!1;if(s.length===0)throw new Error("internal error - stack copy empty");var d=s[s.length-1],p=Zg.fromBuffer(d);if(s.pop(),this.initialize(),this.set({script:p,stack:s,tx:r,nin:i,flags:n,satoshisBN:o}),!this.evaluate())return!1;if(s.length===0)return this.errstr="SCRIPT_ERR_EVAL_FALSE_NO_P2SH_STACK",!1;if(!M.castToBool(s[s.length-1]))return this.errstr="SCRIPT_ERR_EVAL_FALSE_IN_P2SH_STACK",!1}if((n&M.SCRIPT_VERIFY_CLEANSTACK)!==0){if((n&M.SCRIPT_VERIFY_P2SH)===0&&(n&M.SCRIPT_UTXO_AFTER_GENESIS)===0)throw new Error("internal error - CLEANSTACK without P2SH");if(this.stack.length!==1)return this.errstr="SCRIPT_ERR_CLEANSTACK",!1}return!0};AB.exports=M;M.prototype.initialize=function(e){this.stack=[],this.altstack=[],this.pc=0,this.pbegincodehash=0,this.nOpCount=0,this.returned=!1,this.nonTopLevelReturnAfterGenesis=!1,this.vfExec=[],this.vfElse=[],this.errstr="",this.flags=0};M.prototype.set=function(e){this.script=e.script||this.script,this.tx=e.tx||this.tx,this.nin=typeof e.nin<"u"?e.nin:this.nin,this.satoshisBN=e.satoshisBN||this.satoshisBN,this.stack=e.stack||this.stack,this.altstack=e.altstack||this.altstack,this.pc=typeof e.pc<"u"?e.pc:this.pc,this.pbegincodehash=typeof e.pbegincodehash<"u"?e.pbegincodehash:this.pbegincodehash,this.nOpCount=typeof e.nOpCount<"u"?e.nOpCount:this.nOpCount,this.returned=typeof e.returned<"u"?e.returned:this.returned,this.nonTopLevelReturnAfterGenesis=typeof e.nonTopLevelReturnAfterGenesis<"u"?e.nonTopLevelReturnAfterGenesis:this.nonTopLevelReturnAfterGenesis,this.vfExec=e.vfExec||this.vfExec,this.vfElse=e.vfElse||this.vfElse,this.errstr=e.errstr||this.errstr,this.flags=typeof e.flags<"u"?e.flags:this.flags};M.true=f.Buffer.from([1]);M.false=f.Buffer.from([]);M.MAX_SCRIPT_ELEMENT_SIZE=520;M.MAXIMUM_ELEMENT_SIZE=4;M.MAX_OPS_PER_SCRIPT=500;M.MAX_SCRIPT_SIZE=1e4;M.UNLIMITED=Number.MAX_SAFE_INTEGER;M.MAX_SCRIPT_NUM_LENGTH_AFTER_GENESIS=75e4;M.MAX_SCRIPT_NUM_LENGTH_AFTER_CHRONICLE=32e6;M.MAX_PUBKEYS_PER_MULTISIG_AFTER_GENESIS=4294967295;M.MAX_STACK_SIZE=1e3;M.MAX_STACK_MEMORY_USAGE_AFTER_GENESIS=M.UNLIMITED;M.STACK_MEMORY_USAGE_POLICY=100*1024*1024;M.STACK_ELEMENT_OVERHEAD=32;M.LOCKTIME_THRESHOLD=5e8;M.LOCKTIME_THRESHOLD_BN=new Se(M.LOCKTIME_THRESHOLD);M.useGenesisLimits=function(e){return e=e||2147483647,M.MAX_SCRIPT_ELEMENT_SIZE=e,M.MAX_OPS_PER_SCRIPT=e,M.MAX_SCRIPT_SIZE=e,M};M.getLimits=function(){return{maxScriptElementSize:M.MAX_SCRIPT_ELEMENT_SIZE,maximumElementSize:M.MAXIMUM_ELEMENT_SIZE,maxOpsPerScript:M.MAX_OPS_PER_SCRIPT,maxScriptSize:M.MAX_SCRIPT_SIZE}};M.setLimits=function(e){return e=e||{},e.maxScriptElementSize!=null&&(M.MAX_SCRIPT_ELEMENT_SIZE=e.maxScriptElementSize),e.maximumElementSize!=null&&(M.MAXIMUM_ELEMENT_SIZE=e.maximumElementSize),e.maxOpsPerScript!=null&&(M.MAX_OPS_PER_SCRIPT=e.maxOpsPerScript),e.maxScriptSize!=null&&(M.MAX_SCRIPT_SIZE=e.maxScriptSize),M};M.SCRIPT_VERIFY_NONE=0;M.SCRIPT_VERIFY_P2SH=1;M.SCRIPT_VERIFY_STRICTENC=2;M.SCRIPT_VERIFY_DERSIG=4;M.SCRIPT_VERIFY_LOW_S=8;M.SCRIPT_VERIFY_NULLDUMMY=16;M.SCRIPT_VERIFY_SIGPUSHONLY=32;M.SCRIPT_VERIFY_MINIMALDATA=64;M.SCRIPT_VERIFY_DISCOURAGE_UPGRADABLE_NOPS=128;M.SCRIPT_VERIFY_CLEANSTACK=256;M.SCRIPT_VERIFY_CHECKLOCKTIMEVERIFY=512;M.SCRIPT_VERIFY_CHECKSEQUENCEVERIFY=1024;M.SCRIPT_VERIFY_MINIMALIF=8192;M.SCRIPT_VERIFY_NULLFAIL=16384;M.SCRIPT_VERIFY_COMPRESSED_PUBKEYTYPE=32768;M.SCRIPT_ENABLE_SIGHASH_FORKID=65536;M.SCRIPT_ENABLE_REPLAY_PROTECTION=1<<17;M.SCRIPT_ENABLE_MONOLITH_OPCODES=2048;M.SCRIPT_ENABLE_MAGNETIC_OPCODES=4096;M.SCRIPT_GENESIS=1<<18;M.SCRIPT_UTXO_AFTER_GENESIS=1<<19;M.SCRIPT_ENABLE_CHRONICLE=1<<20;M.SCRIPT_CHRONICLE=M.SCRIPT_ENABLE_CHRONICLE;M.SCRIPT_UTXO_AFTER_CHRONICLE=1<<21;M.CHRONICLE_ACTIVATION_HEIGHT=943816;M.ERA_SENSITIVE_ERRORS={SCRIPT_ERR_PUSH_SIZE:{cap:"stack element size (capped at 520 bytes pre-Genesis, unbounded after)",lifts:M.SCRIPT_UTXO_AFTER_GENESIS},SCRIPT_ERR_SCRIPT_SIZE:{cap:"total script size (capped at 10,000 bytes pre-Genesis, unbounded after)",lifts:M.SCRIPT_UTXO_AFTER_GENESIS},SCRIPT_ERR_OP_COUNT:{cap:"opcode count (capped at 201 pre-Genesis, unbounded after)",lifts:M.SCRIPT_UTXO_AFTER_GENESIS},SCRIPT_ERR_SCRIPTNUM_OVERFLOW:{cap:"script number width (4 bytes pre-Genesis, 750,000 after Genesis, 32,000,000 after Chronicle)",lifts:M.SCRIPT_UTXO_AFTER_GENESIS|M.SCRIPT_UTXO_AFTER_CHRONICLE}};M.ERA_FLAGS=M.SCRIPT_GENESIS|M.SCRIPT_UTXO_AFTER_GENESIS|M.SCRIPT_ENABLE_CHRONICLE|M.SCRIPT_UTXO_AFTER_CHRONICLE;M.eraDiagnostics=!(typeof b.default<"u"&&b.default.env&&b.default.env.BSV_NO_ERA_HINT==="1");var l_=!1;M.prototype._eraDiagnose=function(e){if(e!==void 0){var t=M.ERA_SENSITIVE_ERRORS[this.errstr];if(t&&(e&t.lifts)===0){var r=t.cap;this.eraHint=this.errstr+" was produced under PRE-GENESIS limits: "+r+`.
69
+ `));var s=new Ga({actual:e,expected:t,message:r,operator:n,stackStartFn:i});throw s.generatedMessage=a,s}}Ot.match=function e(t,r,i){_k(t,r,i,e,"match")};Ot.doesNotMatch=function e(t,r,i){_k(t,r,i,e,"doesNotMatch")};function wk(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];dk.apply(void 0,[wk,t.length].concat(t))}Ot.strict=l7(wk,Ot,{equal:Ot.strictEqual,deepEqual:Ot.deepStrictEqual,notEqual:Ot.notStrictEqual,notDeepEqual:Ot.notDeepStrictEqual});Ot.strict.strict=Ot.strict});var oo=P((Nae,xk)=>{"use strict";g();var Wl=Je(),Ek=Oe(),xc=Ye(),Jt=function e(t){if(!(this instanceof e))return new e(t);if(!Wl.isUndefined(t))if(f.Buffer.isBuffer(t))this.set({buf:t});else if(Wl.isString(t)){var r=f.Buffer.from(t,"hex");if(r.length*2!==t.length)throw new TypeError("Invalid hex string");this.set({buf:r})}else if(Wl.isObject(t)){var i=t;this.set(i)}else throw new TypeError("Unrecognized argument for BufferReader")};Jt.prototype.set=function(e){return this.buf=e.buf||this.buf||void 0,this.pos=e.pos||this.pos||0,this};Jt.prototype.eof=function(){return this.pos>=this.buf.length};Jt.prototype.finished=Jt.prototype.eof;Jt.prototype.read=function(e){Ek.checkArgument(!Wl.isUndefined(e),"Must specify a length");var t=this.buf.slice(this.pos,this.pos+e);return this.pos=this.pos+e,t};Jt.prototype.readAll=function(){var e=this.buf.slice(this.pos,this.buf.length);return this.pos=this.buf.length,e};Jt.prototype.readUInt8=function(){var e=this.buf.readUInt8(this.pos);return this.pos=this.pos+1,e};Jt.prototype.readUInt16BE=function(){var e=this.buf.readUInt16BE(this.pos);return this.pos=this.pos+2,e};Jt.prototype.readUInt16LE=function(){var e=this.buf.readUInt16LE(this.pos);return this.pos=this.pos+2,e};Jt.prototype.readUInt32BE=function(){var e=this.buf.readUInt32BE(this.pos);return this.pos=this.pos+4,e};Jt.prototype.readUInt32LE=function(){var e=this.buf.readUInt32LE(this.pos);return this.pos=this.pos+4,e};Jt.prototype.readInt32LE=function(){var e=this.buf.readInt32LE(this.pos);return this.pos=this.pos+4,e};Jt.prototype.readUInt64BEBN=function(){var e=this.buf.slice(this.pos,this.pos+8),t=xc.fromBuffer(e);return this.pos=this.pos+8,t};Jt.prototype.readUInt64LEBN=function(){var e=this.buf.readUInt32LE(this.pos),t=this.buf.readUInt32LE(this.pos+4),r=t*4294967296+e,i;if(r<=9007199254740991)i=new xc(r);else{var n=Array.prototype.slice.call(this.buf,this.pos,this.pos+8);i=new xc(n,10,"le")}return this.pos=this.pos+8,i};Jt.prototype.readVarintNum=function(){var e=this.readUInt8();switch(e){case 253:return this.readUInt16LE();case 254:return this.readUInt32LE();case 255:var t=this.readUInt64LEBN(),r=t.toNumber();if(r<=Math.pow(2,53))return r;throw new Error("number too large to retain precision - use readVarintBN");default:return e}};Jt.prototype.readVarLengthBuffer=function(){var e=this.readVarintNum(),t=this.read(e);return Ek.checkState(t.length===e,"Invalid length while reading varlength buffer. Expected to read: "+e+" and read "+t.length),t};Jt.prototype.readVarintBuf=function(){var e=this.buf.readUInt8(this.pos);switch(e){case 253:return this.read(3);case 254:return this.read(5);case 255:return this.read(9);default:return this.read(1)}};Jt.prototype.readVarintBN=function(){var e=this.readUInt8();switch(e){case 253:return new xc(this.readUInt16LE());case 254:return new xc(this.readUInt32LE());case 255:return this.readUInt64LEBN();default:return new xc(e)}};Jt.prototype.reverse=function(){for(var e=f.Buffer.alloc(this.buf.length),t=0;t<e.length;t++)e[t]=this.buf[this.buf.length-1-t];return this.buf=e,this};Jt.prototype.readReverse=function(e){Wl.isUndefined(e)&&(e=this.buf.length);var t=this.buf.slice(this.pos,this.pos+e);return this.pos=this.pos+e,f.Buffer.from(t).reverse()};xk.exports=Jt});var Or=P((Lae,Ok)=>{"use strict";g();var Oc=Je(),Yl=Oe(),d7=ei();function at(e){if(!(this instanceof at))return new at(e);var t;if(Oc.isNumber(e))t=e;else if(Oc.isString(e))t=at.map[e];else throw new TypeError('Unrecognized num type: "'+typeof e+'" for Opcode');return d7.defineImmutable(this,{num:t}),this}at.fromBuffer=function(e){return Yl.checkArgument(f.Buffer.isBuffer(e)),new at(+("0x"+e.toString("hex")))};at.fromNumber=function(e){return Yl.checkArgument(Oc.isNumber(e)),new at(e)};at.fromString=function(e){Yl.checkArgument(Oc.isString(e));var t=at.map[e];if(typeof t>"u")throw new TypeError("Invalid opcodestr");return new at(t)};at.prototype.toHex=function(){return this.num.toString(16)};at.prototype.toBuffer=function(){return f.Buffer.from(this.toHex(),"hex")};at.prototype.toNumber=function(){return this.num};at.prototype.toString=function(){var e=at.reverseMap[this.num];if(typeof e>"u")throw new Error("Opcode does not have a string representation");return e};at.smallInt=function(e){return Yl.checkArgument(Oc.isNumber(e),"Invalid Argument: n should be number"),Yl.checkArgument(e>=0&&e<=16,"Invalid Argument: n must be between 0 and 16"),e===0?at("OP_0"):new at(at.map.OP_1+e-1)};at.map={OP_FALSE:0,OP_0:0,OP_PUSHDATA1:76,OP_PUSHDATA2:77,OP_PUSHDATA4:78,OP_1NEGATE:79,OP_RESERVED:80,OP_TRUE:81,OP_1:81,OP_2:82,OP_3:83,OP_4:84,OP_5:85,OP_6:86,OP_7:87,OP_8:88,OP_9:89,OP_10:90,OP_11:91,OP_12:92,OP_13:93,OP_14:94,OP_15:95,OP_16:96,OP_NOP:97,OP_VER:98,OP_IF:99,OP_NOTIF:100,OP_VERIF:101,OP_VERNOTIF:102,OP_ELSE:103,OP_ENDIF:104,OP_VERIFY:105,OP_RETURN:106,OP_TOALTSTACK:107,OP_FROMALTSTACK:108,OP_2DROP:109,OP_2DUP:110,OP_3DUP:111,OP_2OVER:112,OP_2ROT:113,OP_2SWAP:114,OP_IFDUP:115,OP_DEPTH:116,OP_DROP:117,OP_DUP:118,OP_NIP:119,OP_OVER:120,OP_PICK:121,OP_ROLL:122,OP_ROT:123,OP_SWAP:124,OP_TUCK:125,OP_CAT:126,OP_SPLIT:127,OP_NUM2BIN:128,OP_BIN2NUM:129,OP_SIZE:130,OP_INVERT:131,OP_AND:132,OP_OR:133,OP_XOR:134,OP_EQUAL:135,OP_EQUALVERIFY:136,OP_RESERVED1:137,OP_RESERVED2:138,OP_1ADD:139,OP_1SUB:140,OP_2MUL:141,OP_2DIV:142,OP_NEGATE:143,OP_ABS:144,OP_NOT:145,OP_0NOTEQUAL:146,OP_ADD:147,OP_SUB:148,OP_MUL:149,OP_DIV:150,OP_MOD:151,OP_LSHIFT:152,OP_RSHIFT:153,OP_BOOLAND:154,OP_BOOLOR:155,OP_NUMEQUAL:156,OP_NUMEQUALVERIFY:157,OP_NUMNOTEQUAL:158,OP_LESSTHAN:159,OP_GREATERTHAN:160,OP_LESSTHANOREQUAL:161,OP_GREATERTHANOREQUAL:162,OP_MIN:163,OP_MAX:164,OP_WITHIN:165,OP_RIPEMD160:166,OP_SHA1:167,OP_SHA256:168,OP_HASH160:169,OP_HASH256:170,OP_CODESEPARATOR:171,OP_CHECKSIG:172,OP_CHECKSIGVERIFY:173,OP_CHECKMULTISIG:174,OP_CHECKMULTISIGVERIFY:175,OP_CHECKLOCKTIMEVERIFY:177,OP_CHECKSEQUENCEVERIFY:178,OP_NOP1:176,OP_NOP2:177,OP_NOP3:178,OP_SUBSTR:179,OP_LEFT:180,OP_RIGHT:181,OP_LSHIFTNUM:182,OP_RSHIFTNUM:183,OP_NOP9:184,OP_NOP10:185,OP_PUBKEYHASH:253,OP_PUBKEY:254,OP_INVALIDOPCODE:255};at.reverseMap=[];for(Gb in at.map)at.reverseMap[at.map[Gb]]=Gb;var Gb;Oc.extend(at,at.map);at.isSmallIntOp=function(e){return e instanceof at&&(e=e.toNumber()),e===at.map.OP_0||e>=at.map.OP_1&&e<=at.map.OP_16};at.prototype.inspect=function(){return"<Opcode: "+this.toString()+", hex: "+this.toHex()+", decimal: "+this.num+">"};Ok.exports=at});var Mg=P((Dae,Pk)=>{"use strict";g();var p7=ra(),An=Ti(),g7=oo(),Wb=ke(),ae=Or(),Js=Gt(),Xs=ut(),Ik=ta(),Bt=Oe(),Qe=Je(),Yb=ci(),Ak=jt(),m7=ei(),$=function e(t){if(!(this instanceof e))return new e(t);if(this.chunks=[],f.Buffer.isBuffer(t))return e.fromBuffer(t);if(t instanceof An)return e.fromAddress(t);if(t instanceof e)return e.fromBuffer(t.toBuffer());if(Qe.isString(t))return e.fromString(t);Qe.isObject(t)&&Qe.isArray(t.chunks)&&this.set(t)};$.prototype.set=function(e){return Bt.checkArgument(Qe.isObject(e)),Bt.checkArgument(Qe.isArray(e.chunks)),this.chunks=e.chunks,this};$.fromBuffer=function(e){var t=new $;t.chunks=[];for(var r=new g7(e);!r.finished();)try{var i=r.readUInt8(),n,o;i>0&&i<ae.OP_PUSHDATA1?(n=i,t.chunks.push({buf:r.read(n),len:n,opcodenum:i})):i===ae.OP_PUSHDATA1?(n=r.readUInt8(),o=r.read(n),t.chunks.push({buf:o,len:n,opcodenum:i})):i===ae.OP_PUSHDATA2?(n=r.readUInt16LE(),o=r.read(n),t.chunks.push({buf:o,len:n,opcodenum:i})):i===ae.OP_PUSHDATA4?(n=r.readUInt32LE(),o=r.read(n),t.chunks.push({buf:o,len:n,opcodenum:i})):t.chunks.push({opcodenum:i})}catch(a){throw a instanceof RangeError?new Yb.Script.InvalidBuffer(e.toString("hex")):a}return t};$.prototype.toBuffer=function(){var e=this.chunks,t=0,r,i,n;for(r=0;r<e.length;r++)i=e[r],n=i.opcodenum,t+=1,i.buf&&(n<ae.OP_PUSHDATA1?t+=Lg(i.buf):n===ae.OP_PUSHDATA1?t+=1+Lg(i.buf):n===ae.OP_PUSHDATA2?t+=2+Lg(i.buf):n===ae.OP_PUSHDATA4&&(t+=4+Lg(i.buf)));var o=f.Buffer.alloc(t),a=0;for(r=0;r<e.length;r++)i=e[r],n=i.opcodenum,a=o.writeUInt8(i.opcodenum,a),i.buf&&(n<ae.OP_PUSHDATA1?a+=i.buf.copy(o,a):n===ae.OP_PUSHDATA1?(a=o.writeUInt8(i.len,a),a+=i.buf.copy(o,a)):n===ae.OP_PUSHDATA2?(a=o.writeUInt16LE(i.len,a),a+=i.buf.copy(o,a)):n===ae.OP_PUSHDATA4&&(a=o.writeUInt32LE(i.len,a),a+=i.buf.copy(o,a)));return o};function Lg(e){if(!f.Buffer.isBuffer(e))throw new p7.AssertionError({message:"chunk data must be a Buffer",actual:e,expected:"Buffer",operator:"isBuffer"});return e.length}function Tk(e){if(/^0x[0-9a-fA-F]{2}$/.test(e)){var t=parseInt(e.slice(2),16);return t>ae.OP_PUSHDATA4?t:void 0}}$.fromASM=function(e){var t=new $;if(t.chunks=[],e==="")return t;for(var r=e.split(" "),i=0;i<r.length;){var n=r[i],o=ae(n),a=o.toNumber(),s=Tk(n);if(s!==void 0)t.chunks.push({opcodenum:s}),i=i+1;else if(n==="0")a=0,t.chunks.push({opcodenum:a}),i=i+1;else if(n==="-1")a=ae.OP_1NEGATE,t.chunks.push({opcodenum:a}),i=i+1;else if(Qe.isUndefined(a)){var u=f.Buffer.from(r[i],"hex");if(u.toString("hex")!==r[i])throw new Error("invalid hex string in script");var c=u.length;c>=0&&c<ae.OP_PUSHDATA1?a=c:c<Math.pow(2,8)?a=ae.OP_PUSHDATA1:c<Math.pow(2,16)?a=ae.OP_PUSHDATA2:c<Math.pow(2,32)&&(a=ae.OP_PUSHDATA4),t.chunks.push({buf:u,len:u.length,opcodenum:a}),i=i+1}else t.chunks.push({opcodenum:a}),i=i+1}return t};$.fromHex=function(e){return new $(Ak.Buffer.from(e,"hex"))};$.fromString=function(e){if(m7.isHexa(e)||e.length===0)return new $(Ak.Buffer.from(e,"hex"));var t=new $;t.chunks=[];for(var r=e.split(" "),i=0;i<r.length;){var n=r[i],o=ae(n),a=o.toNumber(),s=Tk(n);if(s!==void 0)t.chunks.push({opcodenum:s}),i=i+1;else if(Qe.isUndefined(a))if(a=parseInt(n),a>0&&a<ae.OP_PUSHDATA1)t.chunks.push({buf:f.Buffer.from(r[i+1].slice(2),"hex"),len:a,opcodenum:a}),i=i+2;else throw new Error("Invalid script: "+JSON.stringify(e));else if(a===ae.OP_PUSHDATA1||a===ae.OP_PUSHDATA2||a===ae.OP_PUSHDATA4){if(r[i+2].slice(0,2)!=="0x")throw new Error("Pushdata data must start with 0x");t.chunks.push({buf:f.Buffer.from(r[i+2].slice(2),"hex"),len:parseInt(r[i+1]),opcodenum:a}),i=i+3}else t.chunks.push({opcodenum:a}),i=i+1}return t};$.prototype._chunkToString=function(e,t){var r=e.opcodenum,i=t==="asm",n="";if(e.buf){var a=r===ae.OP_PUSHDATA1||r===ae.OP_PUSHDATA2||r===ae.OP_PUSHDATA4;!i&&a&&(n=n+" "+ae(r).toString()),e.len>0?i?n=n+" "+e.buf.toString("hex"):n=n+" "+e.len+" 0x"+e.buf.toString("hex"):i?n=n+" 0":a?n=n+" 0 0x":n=n+" OP_0"}else if(typeof ae.reverseMap[r]<"u")i?r===0?n=n+" 0":r===79?n=n+" -1":n=n+" "+ae(r).toString():n=n+" "+ae(r).toString();else{var o=r.toString(16);o.length%2!==0&&(o="0"+o),n=n+" 0x"+o}return n};$.prototype.toASM=function(){for(var e="",t=0;t<this.chunks.length;t++){var r=this.chunks[t];e+=this._chunkToString(r,"asm")}return e.substr(1)};$.prototype.toString=function(){for(var e="",t=0;t<this.chunks.length;t++){var r=this.chunks[t];e+=this._chunkToString(r)}return e.substr(1)};$.prototype.toHex=function(){return this.toBuffer().toString("hex")};$.prototype.inspect=function(){return"<Script: "+this.toString()+">"};$.prototype.isPublicKeyHashOut=function(){return!!(this.chunks.length===5&&this.chunks[0].opcodenum===ae.OP_DUP&&this.chunks[1].opcodenum===ae.OP_HASH160&&this.chunks[2].buf&&this.chunks[2].buf.length===20&&this.chunks[3].opcodenum===ae.OP_EQUALVERIFY&&this.chunks[4].opcodenum===ae.OP_CHECKSIG)};$.prototype.isPublicKeyHashOutPrefix=function(){return!!(this.chunks.length>=5&&this.chunks[0].opcodenum===ae.OP_DUP&&this.chunks[1].opcodenum===ae.OP_HASH160&&this.chunks[2].buf&&this.chunks[2].buf.length===20&&this.chunks[3].opcodenum===ae.OP_EQUALVERIFY&&this.chunks[4].opcodenum===ae.OP_CHECKSIG)};$.prototype.isPublicKeyHashIn=function(){if(this.chunks.length===2){var e=this.chunks[0].buf,t=this.chunks[1].buf;if(e&&e.length&&e[0]===48&&t&&t.length){var r=t[0];if((r===4||r===6||r===7)&&t.length===65)return!0;if((r===3||r===2)&&t.length===33)return!0}}return!1};$.prototype.getPublicKey=function(){return Bt.checkState(this.isPublicKeyOut(),"Can't retrieve PublicKey from a non-PK output"),this.chunks[0].buf};$.prototype.getPublicKeyHash=function(){return Bt.checkState(this.isPublicKeyHashOut(),"Can't retrieve PublicKeyHash from a non-PKH output"),this.chunks[2].buf};$.prototype.isPublicKeyOut=function(){if(this.chunks.length===2&&this.chunks[0].buf&&this.chunks[0].buf.length&&this.chunks[1].opcodenum===ae.OP_CHECKSIG){var e=this.chunks[0].buf,t=e[0],r=!1;if(((t===4||t===6||t===7)&&e.length===65||(t===3||t===2)&&e.length===33)&&(r=!0),r)return Js.isValid(e)}return!1};$.prototype.isPublicKeyIn=function(){if(this.chunks.length===1){var e=this.chunks[0].buf;if(e&&e.length&&e[0]===48)return!0}return!1};$.prototype.isScriptHashOut=function(){var e=this.toBuffer();return e.length===23&&e[0]===ae.OP_HASH160&&e[1]===20&&e[e.length-1]===ae.OP_EQUAL};$.prototype.isScriptHashIn=function(){if(this.chunks.length<=1)return!1;var e=this.chunks[this.chunks.length-1],t=e.buf;if(!t)return!1;var r;try{r=$.fromBuffer(t)}catch(n){if(n instanceof Yb.Script.InvalidBuffer)return!1;throw n}var i=r.classify();return i!==$.types.UNKNOWN};$.prototype.isMultisigOut=function(){return this.chunks.length>3&&ae.isSmallIntOp(this.chunks[0].opcodenum)&&this.chunks.slice(1,this.chunks.length-2).every(function(e){return e.buf&&f.Buffer.isBuffer(e.buf)})&&ae.isSmallIntOp(this.chunks[this.chunks.length-2].opcodenum)&&this.chunks[this.chunks.length-1].opcodenum===ae.OP_CHECKMULTISIG};$.prototype.isMultisigIn=function(){return this.chunks.length>=2&&this.chunks[0].opcodenum===0&&this.chunks.slice(1,this.chunks.length).every(function(e){return e.buf&&f.Buffer.isBuffer(e.buf)&&Xs.isTxDER(e.buf)})};$.prototype.isDataOut=function(){var e=this.chunks.length>=1&&this.chunks[0].opcodenum===ae.OP_RETURN;if(!e)return!1;var t=this.chunks.slice(1),r=new $({chunks:t});return r.isPushOnly()};$.prototype.isSafeDataOut=function(){if(this.chunks.length<2||this.chunks[0].opcodenum!==ae.OP_FALSE)return!1;var e=this.chunks.slice(1),t=new $({chunks:e});return t.isDataOut()};$.prototype.getData=function(){if(this.isSafeDataOut()){var e=this.chunks.slice(2),t=e.map(r=>r.buf);return t}if(this.isDataOut()||this.isScriptHashOut())return Qe.isUndefined(this.chunks[1])?f.Buffer.alloc(0):f.Buffer.from(this.chunks[1].buf);if(this.isPublicKeyHashOut())return f.Buffer.from(this.chunks[2].buf);throw new Error("Unrecognized script type to get data from")};$.prototype.isPushOnly=function(){return Qe.every(this.chunks,function(e){return e.opcodenum<=ae.OP_16||e.opcodenum===ae.OP_PUSHDATA1||e.opcodenum===ae.OP_PUSHDATA2||e.opcodenum===ae.OP_PUSHDATA4})};$.types={};$.types.UNKNOWN="Unknown";$.types.PUBKEY_OUT="Pay to public key";$.types.PUBKEY_IN="Spend from public key";$.types.PUBKEYHASH_OUT="Pay to public key hash";$.types.PUBKEYHASH_IN="Spend from public key hash";$.types.SCRIPTHASH_OUT="Pay to script hash";$.types.SCRIPTHASH_IN="Spend from script hash";$.types.MULTISIG_OUT="Pay to multisig";$.types.MULTISIG_IN="Spend from multisig";$.types.DATA_OUT="Data push";$.types.SAFE_DATA_OUT="Safe data push";$.OP_RETURN_STANDARD_SIZE=220;$.prototype.classify=function(){if(this._isInput)return this.classifyInput();if(this._isOutput)return this.classifyOutput();var e=this.classifyOutput();return e!==$.types.UNKNOWN?e:this.classifyInput()};$.outputIdentifiers={};$.outputIdentifiers.PUBKEY_OUT=$.prototype.isPublicKeyOut;$.outputIdentifiers.PUBKEYHASH_OUT=$.prototype.isPublicKeyHashOut;$.outputIdentifiers.MULTISIG_OUT=$.prototype.isMultisigOut;$.outputIdentifiers.SCRIPTHASH_OUT=$.prototype.isScriptHashOut;$.outputIdentifiers.DATA_OUT=$.prototype.isDataOut;$.outputIdentifiers.SAFE_DATA_OUT=$.prototype.isSafeDataOut;$.prototype.classifyOutput=function(){for(var e in $.outputIdentifiers)if($.outputIdentifiers[e].bind(this)())return $.types[e];return $.types.UNKNOWN};$.inputIdentifiers={};$.inputIdentifiers.PUBKEY_IN=$.prototype.isPublicKeyIn;$.inputIdentifiers.PUBKEYHASH_IN=$.prototype.isPublicKeyHashIn;$.inputIdentifiers.MULTISIG_IN=$.prototype.isMultisigIn;$.inputIdentifiers.SCRIPTHASH_IN=$.prototype.isScriptHashIn;$.prototype.classifyInput=function(){for(var e in $.inputIdentifiers)if($.inputIdentifiers[e].bind(this)())return $.types[e];return $.types.UNKNOWN};$.prototype.isStandard=function(){return this.classify()!==$.types.UNKNOWN};$.prototype.prepend=function(e){return this._addByType(e,!0),this};$.prototype.equals=function(e){if(Bt.checkState(e instanceof $,"Must provide another script"),this.chunks.length!==e.chunks.length)return!1;var t;for(t=0;t<this.chunks.length;t++){if(f.Buffer.isBuffer(this.chunks[t].buf)&&!f.Buffer.isBuffer(e.chunks[t].buf)||f.Buffer.isBuffer(this.chunks[t].buf)&&!this.chunks[t].buf.equals(e.chunks[t].buf))return!1;if(this.chunks[t].opcodenum!==e.chunks[t].opcodenum)return!1}return!0};$.prototype.add=function(e){return this._addByType(e,!1),this};$.prototype._addByType=function(e,t){if(typeof e=="string")this._addOpcode(e,t);else if(typeof e=="number")this._addOpcode(e,t);else if(e instanceof ae)this._addOpcode(e,t);else if(f.Buffer.isBuffer(e))this._addBuffer(e,t);else if(e instanceof $)this.chunks=this.chunks.concat(e.chunks);else if(typeof e=="object")this._insertAtPosition(e,t);else throw new Error("Invalid script chunk")};$.prototype._insertAtPosition=function(e,t){t?this.chunks.unshift(e):this.chunks.push(e)};$.prototype._addOpcode=function(e,t){var r;return typeof e=="number"?r=e:e instanceof ae?r=e.toNumber():r=ae(e).toNumber(),this._insertAtPosition({opcodenum:r},t),this};$.prototype._addBuffer=function(e,t){var r,i=e.length;if(i>=0&&i<ae.OP_PUSHDATA1)r=i;else if(i<Math.pow(2,8))r=ae.OP_PUSHDATA1;else if(i<Math.pow(2,16))r=ae.OP_PUSHDATA2;else if(i<Math.pow(2,32))r=ae.OP_PUSHDATA4;else throw new Error("You can't push that much data");return this._insertAtPosition({buf:e,len:i,opcodenum:r},t),this};$.prototype.removeCodeseparators=function(){for(var e=[],t=0;t<this.chunks.length;t++)this.chunks[t].opcodenum!==ae.OP_CODESEPARATOR&&e.push(this.chunks[t]);return this.chunks=e,this};$.buildMultisigOut=function(e,t,r){Bt.checkArgument(t<=e.length,"Number of required signatures must be less than or equal to the number of public keys"),r=r||{};var i=new $;i.add(ae.smallInt(t)),e=Qe.map(e,Js);var n=e;r.noSorting||(n=e.map(s=>s.toString("hex")).sort().map(s=>new Js(s)));for(var o=0;o<n.length;o++){var a=n[o];i.add(a.toBuffer())}return i.add(ae.smallInt(e.length)),i.add(ae.OP_CHECKMULTISIG),i};$.buildMultisigIn=function(e,t,r,i){Bt.checkArgument(Qe.isArray(e)),Bt.checkArgument(Qe.isNumber(t)),Bt.checkArgument(Qe.isArray(r)),i=i||{};var n=new $;return n.add(ae.OP_0),Qe.each(r,function(o){Bt.checkArgument(f.Buffer.isBuffer(o),"Signatures must be an array of Buffers"),n.add(o)}),n};$.buildP2SHMultisigIn=function(e,t,r,i){Bt.checkArgument(Qe.isArray(e)),Bt.checkArgument(Qe.isNumber(t)),Bt.checkArgument(Qe.isArray(r)),i=i||{};var n=new $;return n.add(ae.OP_0),Qe.each(r,function(o){Bt.checkArgument(f.Buffer.isBuffer(o),"Signatures must be an array of Buffers"),n.add(o)}),n.add((i.cachedMultisig||$.buildMultisigOut(e,t,i)).toBuffer()),n};$.buildPublicKeyHashOut=function(e){Bt.checkArgument(!Qe.isUndefined(e)),Bt.checkArgument(e instanceof Js||e instanceof An||Qe.isString(e)),e instanceof Js?e=e.toAddress():Qe.isString(e)&&(e=new An(e));var t=new $;return t.add(ae.OP_DUP).add(ae.OP_HASH160).add(e.hashBuffer).add(ae.OP_EQUALVERIFY).add(ae.OP_CHECKSIG),t._network=e.network,t};$.buildPublicKeyOut=function(e){Bt.checkArgument(e instanceof Js);var t=new $;return t.add(e.toBuffer()).add(ae.OP_CHECKSIG),t};$.buildDataOut=function(e,t){Bt.checkArgument(Qe.isUndefined(e)||Qe.isString(e)||Qe.isArray(e)||f.Buffer.isBuffer(e));var r=e;Qe.isArray(r)||(r=[e]);var i=new $;i.add(ae.OP_RETURN);for(let n of r)Bt.checkArgument(Qe.isUndefined(n)||Qe.isString(n)||f.Buffer.isBuffer(n)),Qe.isString(n)&&(n=f.Buffer.from(n,t)),Qe.isUndefined(n)||i.add(n);return i};$.buildSafeDataOut=function(e,t){var r=$.buildDataOut(e,t),i=new $;return i.add(ae.OP_FALSE),i.add(r),i};$.buildScriptHashOut=function(e){Bt.checkArgument(e instanceof $||e instanceof An&&e.isPayToScriptHash());var t=new $;return t.add(ae.OP_HASH160).add(e instanceof An?e.hashBuffer:Wb.sha256ripemd160(e.toBuffer())).add(ae.OP_EQUAL),t._network=e._network||e.network,t};$.buildPublicKeyIn=function(e,t){Bt.checkArgument(e instanceof Xs||f.Buffer.isBuffer(e)),Bt.checkArgument(Qe.isUndefined(t)||Qe.isNumber(t)),e instanceof Xs&&(e=e.toBuffer());var r=new $;return r.add(f.Buffer.concat([e,f.Buffer.from([(t||Xs.SIGHASH_ALL)&255])])),r};$.buildPublicKeyHashIn=function(e,t,r){Bt.checkArgument(t instanceof Xs||f.Buffer.isBuffer(t)),Bt.checkArgument(Qe.isUndefined(r)||Qe.isNumber(r)),t instanceof Xs&&(t=t.toBuffer());var i=new $().add(f.Buffer.concat([t,f.Buffer.from([(r||Xs.SIGHASH_ALL)&255])])).add(new Js(e).toBuffer());return i};$.empty=function(){return new $};$.prototype.toScriptHashOut=function(){return $.buildScriptHashOut(this)};$.fromAddress=function(e){if(e=An(e),e.isPayToScriptHash())return $.buildScriptHashOut(e);if(e.isPayToPublicKeyHash())return $.buildPublicKeyHashOut(e);throw new Yb.Script.UnrecognizedAddress(e)};$.prototype.getAddressInfo=function(e){if(this._isInput)return this._getInputAddressInfo();if(this._isOutput)return this._getOutputAddressInfo();var t=this._getOutputAddressInfo();return t||this._getInputAddressInfo()};$.prototype._getOutputAddressInfo=function(){var e={};if(this.isScriptHashOut())e.hashBuffer=this.getData(),e.type=An.PayToScriptHash;else if(this.isPublicKeyHashOut())e.hashBuffer=this.getData(),e.type=An.PayToPublicKeyHash;else return!1;return e};$.prototype._getInputAddressInfo=function(){var e={};if(this.isPublicKeyHashIn())e.hashBuffer=Wb.sha256ripemd160(this.chunks[1].buf),e.type=An.PayToPublicKeyHash;else if(this.isScriptHashIn())e.hashBuffer=Wb.sha256ripemd160(this.chunks[this.chunks.length-1].buf),e.type=An.PayToScriptHash;else return!1;return e};$.prototype.toAddress=function(e){var t=this.getAddressInfo();return t?(t.network=Ik.get(e)||this._network||Ik.defaultNetwork,new An(t)):!1};$.prototype.findAndDelete=function(e){for(var t=e.toBuffer(),r=t.length?t[0]:-1,i=0;i<this.chunks.length;i++){var n=this.chunks[i];if(!(n.opcodenum!==r&&v7(n))){var o=$({chunks:[n]}).toBuffer();t.equals(o)&&(this.chunks.splice(i,1),i--)}}return this};function v7(e){var t=e.opcodenum;if(typeof t!="number"||!Number.isInteger(t)||t<0||t>255)return!1;if(!e.buf||t>ae.OP_PUSHDATA4)return!0;if(!f.Buffer.isBuffer(e.buf))return!1;var r=e.len;return t===ae.OP_PUSHDATA1?Number.isInteger(r)&&r>=0&&r<=255:t===ae.OP_PUSHDATA2?Number.isInteger(r)&&r>=0&&r<=65535:t===ae.OP_PUSHDATA4?Number.isInteger(r)&&r>=0&&r<=4294967295:!0}$.prototype.checkMinimalPush=function(e){var t=this.chunks[e],r=t.buf,i=t.opcodenum;return r?r.length===0?i===ae.OP_0:r.length===1&&r[0]>=1&&r[0]<=16?i===ae.OP_1+(r[0]-1):r.length===1&&r[0]===129?i===ae.OP_1NEGATE:r.length<=75?i===r.length:r.length<=255?i===ae.OP_PUSHDATA1:r.length<=65535?i===ae.OP_PUSHDATA2:!0:!0};$.prototype._decodeOP_N=function(e){if(e===ae.OP_0)return 0;if(e>=ae.OP_1&&e<=ae.OP_16)return e-(ae.OP_1-1);throw new Error("Invalid opcode: "+JSON.stringify(e))};$.prototype.getSignatureOperationsCount=function(e){e=Qe.isUndefined(e)?!0:e;var t=this,r=0,i=ae.OP_INVALIDOPCODE;return Qe.each(t.chunks,function(o){var a=o.opcodenum;a===ae.OP_CHECKSIG||a===ae.OP_CHECKSIGVERIFY?r++:(a===ae.OP_CHECKMULTISIG||a===ae.OP_CHECKMULTISIGVERIFY)&&(e&&i>=ae.OP_1&&i<=ae.OP_16?r+=t._decodeOP_N(i):r+=20),i=a}),r};Pk.exports=$});var Tn=P((Hae,kk)=>{"use strict";g();var Rk=ra(),Qt=function e(t){if(!(this instanceof e))return new e(t);this.bufLen=0,t?this.set(t):this.bufs=[]};Qt.prototype.set=function(e){return this.bufs=e.bufs||this.bufs||[],this.bufLen=this.bufs.reduce(function(t,r){return t+r.length},0),this};Qt.prototype.toBuffer=function(){return this.concat()};Qt.prototype.concat=function(){return f.Buffer.concat(this.bufs,this.bufLen)};Qt.prototype.write=function(e){return Rk(f.Buffer.isBuffer(e)),this.bufs.push(e),this.bufLen+=e.length,this};Qt.prototype.writeReverse=function(e){return Rk(f.Buffer.isBuffer(e)),this.bufs.push(f.Buffer.from(e).reverse()),this.bufLen+=e.length,this};Qt.prototype.writeUInt8=function(e){var t=f.Buffer.alloc(1);return t.writeUInt8(e,0),this.write(t),this};Qt.prototype.writeUInt16BE=function(e){var t=f.Buffer.alloc(2);return t.writeUInt16BE(e,0),this.write(t),this};Qt.prototype.writeUInt16LE=function(e){var t=f.Buffer.alloc(2);return t.writeUInt16LE(e,0),this.write(t),this};Qt.prototype.writeUInt32BE=function(e){var t=f.Buffer.alloc(4);return t.writeUInt32BE(e,0),this.write(t),this};Qt.prototype.writeInt32LE=function(e){var t=f.Buffer.alloc(4);return t.writeInt32LE(e,0),this.write(t),this};Qt.prototype.writeUInt32LE=function(e){var t=f.Buffer.alloc(4);return t.writeUInt32LE(e,0),this.write(t),this};Qt.prototype.writeUInt64BEBN=function(e){var t=e.toBuffer({size:8});return this.write(t),this};Qt.prototype.writeUInt64LEBN=function(e){var t=e.toBuffer({size:8});return this.writeReverse(t),this};Qt.prototype.writeVarintNum=function(e){var t=Qt.varintBufNum(e);return this.write(t),this};Qt.prototype.writeVarintBN=function(e){var t=Qt.varintBufBN(e);return this.write(t),this};Qt.varintBufNum=function(e){var t;return e<253?(t=f.Buffer.alloc(1),t.writeUInt8(e,0)):e<65536?(t=f.Buffer.alloc(3),t.writeUInt8(253,0),t.writeUInt16LE(e,1)):e<4294967296?(t=f.Buffer.alloc(5),t.writeUInt8(254,0),t.writeUInt32LE(e,1)):(t=f.Buffer.alloc(9),t.writeUInt8(255,0),t.writeInt32LE(e&-1,1),t.writeUInt32LE(Math.floor(e/4294967296),5)),t};Qt.varintBufBN=function(e){var t,r=e.toNumber();if(r<253)t=f.Buffer.alloc(1),t.writeUInt8(r,0);else if(r<65536)t=f.Buffer.alloc(3),t.writeUInt8(253,0),t.writeUInt16LE(r,1);else if(r<4294967296)t=f.Buffer.alloc(5),t.writeUInt8(254,0),t.writeUInt32LE(r,1);else{var i=new Qt;i.writeUInt8(255),i.writeUInt64LEBN(e),t=i.concat()}return t};kk.exports=Qt});var Ic=P((Fae,Ck)=>{"use strict";g();var Bk=Tn(),Nk=oo(),y7=Ye(),Pn=function e(t){if(!(this instanceof e))return new e(t);if(f.Buffer.isBuffer(t))this.buf=t;else if(typeof t=="number"){var r=t;this.fromNumber(r)}else if(t instanceof y7){var i=t;this.fromBN(i)}else if(t){var n=t;this.set(n)}};Pn.prototype.set=function(e){return this.buf=e.buf||this.buf,this};Pn.prototype.fromString=function(e){return this.set({buf:f.Buffer.from(e,"hex")}),this};Pn.prototype.toString=function(){return this.buf.toString("hex")};Pn.prototype.fromBuffer=function(e){return this.buf=e,this};Pn.prototype.fromBufferReader=function(e){return this.buf=e.readVarintBuf(),this};Pn.prototype.fromBN=function(e){return this.buf=Bk().writeVarintBN(e).concat(),this};Pn.prototype.fromNumber=function(e){return this.buf=Bk().writeVarintNum(e).concat(),this};Pn.prototype.toBuffer=function(){return this.buf};Pn.prototype.toBN=function(){return Nk(this.buf).readVarintBN()};Pn.prototype.toNumber=function(){return Nk(this.buf).readVarintNum()};Ck.exports=Pn});var fi=P((zae,Mk)=>{"use strict";g();var Dg=Je(),Zb=Ye(),Lk=jt(),qg=ei(),b7=Tn(),_7=Ic(),$b=et(),Xb=Oe(),w7=ci(),S7=9007199254740991;function Wr(e){if(!(this instanceof Wr))return new Wr(e);if(Dg.isObject(e))if(this.satoshis=e.satoshis,f.Buffer.isBuffer(e.script))this._scriptBuffer=e.script;else{var t;Dg.isString(e.script)&&qg.isHexa(e.script)?t=Lk.Buffer.from(e.script,"hex"):t=e.script,this.setScript(t)}else throw new TypeError("Unrecognized argument for Output")}Object.defineProperty(Wr.prototype,"script",{configurable:!1,enumerable:!0,get:function(){return this._script?this._script:(this.setScriptFromBuffer(this._scriptBuffer),this._script)}});Object.defineProperty(Wr.prototype,"satoshis",{configurable:!1,enumerable:!0,get:function(){return this._satoshis},set:function(e){e instanceof Zb?(this._satoshisBN=e,this._satoshis=e.toNumber()):Dg.isString(e)?(this._satoshis=parseInt(e),this._satoshisBN=Zb.fromNumber(this._satoshis)):(Xb.checkArgument(qg.isNaturalNumber(e),"Output satoshis is not a natural number"),this._satoshisBN=Zb.fromNumber(e),this._satoshis=e),Xb.checkState(qg.isNaturalNumber(this._satoshis),"Output satoshis is not a natural number")}});Wr.prototype.invalidSatoshis=function(){return this._satoshis>S7?"transaction txout satoshis greater than max safe integer":this._satoshis!==this._satoshisBN.toNumber()?"transaction txout satoshis has corrupted value":this._satoshis<0?"transaction txout negative":!1};Object.defineProperty(Wr.prototype,"satoshisBN",{configurable:!1,enumerable:!0,get:function(){return this._satoshisBN},set:function(e){this._satoshisBN=e,this._satoshis=e.toNumber(),Xb.checkState(qg.isNaturalNumber(this._satoshis),"Output satoshis is not a natural number")}});Wr.prototype.toObject=Wr.prototype.toJSON=function(){var t={satoshis:this.satoshis};return t.script=this._scriptBuffer.toString("hex"),t};Wr.fromObject=function(e){return new Wr(e)};Wr.prototype.setScriptFromBuffer=function(e){this._scriptBuffer=e;try{this._script=$b.fromBuffer(this._scriptBuffer),this._script._isOutput=!0}catch(t){if(t instanceof w7.Script.InvalidBuffer)this._script=null;else throw t}};Wr.prototype.setScript=function(e){if(e instanceof $b)this._scriptBuffer=e.toBuffer(),this._script=e,this._script._isOutput=!0;else if(Dg.isString(e))this._script=$b.fromString(e),this._scriptBuffer=this._script.toBuffer(),this._script._isOutput=!0;else if(f.Buffer.isBuffer(e))this.setScriptFromBuffer(e);else throw new TypeError("Invalid argument type: script");return this};Wr.prototype.inspect=function(){var e;return this.script?e=this.script.inspect():e=this._scriptBuffer.toString("hex"),"<Output ("+this.satoshis+" sats) "+e+">"};Wr.fromBufferReader=function(e){var t={};t.satoshis=e.readUInt64LEBN();var r=e.readVarintNum();return r!==0?t.script=e.read(r):t.script=Lk.Buffer.from([]),new Wr(t)};Wr.prototype.toBufferWriter=function(e){e||(e=new b7),e.writeUInt64LEBN(this._satoshisBN);var t=this._scriptBuffer;return e.writeVarintNum(t.length),e.write(t),e};Wr.prototype.getSize=function(){var e=this.script.toBuffer().length,t=_7(e).toBuffer().length;return 8+t+e};Mk.exports=Wr});var Ac=P((Vae,Uk)=>{"use strict";g();var Wa=Je(),E7=Oe(),Zl=ci(),x7=Tn(),Jb=jt(),qk=ei(),Hg=et(),O7=li(),Dk=fi(),Ug=4294967295,I7=Ug-2,Hk=Ug,A7=Ug-1;function wt(e){if(!(this instanceof wt))return new wt(e);if(e)return this._fromObject(e)}wt.MAXINT=Ug;wt.DEFAULT_SEQNUMBER=Hk;wt.DEFAULT_LOCKTIME_SEQNUMBER=A7;wt.DEFAULT_RBF_SEQNUMBER=I7;wt.BASE_SIZE=40;Object.defineProperty(wt.prototype,"script",{configurable:!1,enumerable:!0,get:function(){return this.isNull()?null:(this._script||(this._script=new Hg(this._scriptBuffer),this._script._isInput=!0),this._script)}});wt.fromObject=function(e){E7.checkArgument(Wa.isObject(e));var t=new wt;return t._fromObject(e)};wt.prototype._fromObject=function(e){var t;if(Wa.isString(e.prevTxId)&&qk.isHexa(e.prevTxId)?t=Jb.Buffer.from(e.prevTxId,"hex"):t=e.prevTxId,this.output=e.output?e.output instanceof Dk?e.output:new Dk(e.output):void 0,this.prevTxId=t||e.txidbuf,this.outputIndex=Wa.isUndefined(e.outputIndex)?e.txoutnum:e.outputIndex,this.sequenceNumber=Wa.isUndefined(e.sequenceNumber)?Wa.isUndefined(e.seqnum)?Hk:e.seqnum:e.sequenceNumber,Wa.isUndefined(e.script)&&Wa.isUndefined(e.scriptBuffer))throw new Zl.Transaction.Input.MissingScript;return this.setScript(e.scriptBuffer||e.script),this};wt.prototype.toObject=wt.prototype.toJSON=function(){var t={prevTxId:this.prevTxId.toString("hex"),outputIndex:this.outputIndex,sequenceNumber:this.sequenceNumber,script:this._scriptBuffer.toString("hex")};return this.script&&(t.scriptString=this.script.toString()),this.output&&(t.output=this.output.toObject()),t};wt.fromBufferReader=function(e){var t=new wt;return t.prevTxId=e.readReverse(32),t.outputIndex=e.readUInt32LE(),t._scriptBuffer=e.readVarLengthBuffer(),t.sequenceNumber=e.readUInt32LE(),t};wt.prototype.toBufferWriter=function(e){e||(e=new x7),e.writeReverse(this.prevTxId),e.writeUInt32LE(this.outputIndex);var t=this._scriptBuffer;return e.writeVarintNum(t.length),e.write(t),e.writeUInt32LE(this.sequenceNumber),e};wt.prototype.setScript=function(e){if(this._script=null,e instanceof Hg)this._script=e,this._script._isInput=!0,this._scriptBuffer=e.toBuffer();else if(e===null)this._script=Hg.empty(),this._script._isInput=!0,this._scriptBuffer=this._script.toBuffer();else if(qk.isHexa(e))this._scriptBuffer=Jb.Buffer.from(e,"hex");else if(Wa.isString(e))this._script=new Hg(e),this._script._isInput=!0,this._scriptBuffer=this._script.toBuffer();else if(f.Buffer.isBuffer(e))this._scriptBuffer=Jb.Buffer.from(e);else throw new TypeError("Invalid argument type: script");return this};wt.prototype.getSignatures=function(){throw new Zl.AbstractMethodInvoked("Trying to sign unsupported output type (only P2PKH and P2SH multisig inputs are supported) for input: "+JSON.stringify(this))};wt.prototype.isFullySigned=function(){throw new Zl.AbstractMethodInvoked("Input#isFullySigned")};wt.prototype.isFinal=function(){return this.sequenceNumber===wt.MAXINT};wt.prototype.addSignature=function(){throw new Zl.AbstractMethodInvoked("Input#addSignature")};wt.prototype.clearSignatures=function(){throw new Zl.AbstractMethodInvoked("Input#clearSignatures")};wt.prototype.isValidSignature=function(e,t){return t.signature.nhashtype=t.sigtype,O7.verify(e,t.signature,t.publicKey,t.inputIndex,this.output.script,this.output.satoshisBN)};wt.prototype.isNull=function(){return this.prevTxId.toString("hex")==="0000000000000000000000000000000000000000000000000000000000000000"&&this.outputIndex===4294967295};wt.prototype._estimateSize=function(){return this.toBufferWriter().toBuffer().length};Uk.exports=wt});var Tc=P((Wae,Fk)=>{"use strict";g();Fk.exports=function(t,r){r&&(t.super_=r,t.prototype=Object.create(r.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}))}});var Rc=P((Zae,Kk)=>{"use strict";g();var Pc=Je(),sn=Oe(),T7=Tc(),jk=ei(),zk=Gt(),P7=ci(),$l=ut();function Rn(e){if(!(this instanceof Rn))return new Rn(e);if(e instanceof Rn)return e;if(Pc.isObject(e))return this._fromObject(e);throw new P7.InvalidArgument("TransactionSignatures must be instantiated from an object")}T7(Rn,$l);Rn.prototype._fromObject=function(e){return this._checkObjectArgs(e),this.publicKey=new zk(e.publicKey),this.prevTxId=f.Buffer.isBuffer(e.prevTxId)?e.prevTxId:f.Buffer.from(e.prevTxId,"hex"),this.outputIndex=e.outputIndex,this.inputIndex=e.inputIndex,this.signature=e.signature instanceof $l?e.signature:f.Buffer.isBuffer(e.signature)?$l.fromBuffer(e.signature):$l.fromString(e.signature),this.sigtype=e.sigtype,this};Rn.prototype._checkObjectArgs=function(e){sn.checkArgument(zk(e.publicKey),"publicKey"),sn.checkArgument(!Pc.isUndefined(e.inputIndex),"inputIndex"),sn.checkArgument(!Pc.isUndefined(e.outputIndex),"outputIndex"),sn.checkState(Pc.isNumber(e.inputIndex),"inputIndex must be a number"),sn.checkState(Pc.isNumber(e.outputIndex),"outputIndex must be a number"),sn.checkArgument(e.signature,"signature"),sn.checkArgument(e.prevTxId,"prevTxId"),sn.checkState(e.signature instanceof $l||f.Buffer.isBuffer(e.signature)||jk.isHexa(e.signature),"signature must be a buffer or hexa value"),sn.checkState(f.Buffer.isBuffer(e.prevTxId)||jk.isHexa(e.prevTxId),"prevTxId must be a buffer or hexa value"),sn.checkArgument(e.sigtype,"sigtype"),sn.checkState(Pc.isNumber(e.sigtype),"sigtype must be a number")};Rn.prototype.toObject=Rn.prototype.toJSON=function(){return{publicKey:this.publicKey.toString(),prevTxId:this.prevTxId.toString("hex"),outputIndex:this.outputIndex,inputIndex:this.inputIndex,signature:this.signature.toString(),sigtype:this.sigtype}};Rn.fromObject=function(e){return sn.checkArgument(e),new Rn(e)};Kk.exports=Rn});var Zk=P((Xae,Yk)=>{"use strict";g();var R7=Tc(),Gk=Oe(),Qb=Ac(),k7=fi(),B7=li(),Wk=et(),Vk=ut(),N7=Rc();function ia(){Qb.apply(this,arguments)}R7(ia,Qb);ia.prototype.getSignatures=function(e,t,r,i){Gk.checkState(this.output instanceof k7),i=i||Vk.SIGHASH_ALL|Vk.SIGHASH_FORKID;var n=t.toPublicKey();return n.toString()===this.output.script.getPublicKey().toString("hex")?[new N7({publicKey:n,prevTxId:this.prevTxId,outputIndex:this.outputIndex,inputIndex:r,signature:B7.sign(e,t,i,r,this.output.script,this.output.satoshisBN),sigtype:i})]:[]};ia.prototype.addSignature=function(e,t){return Gk.checkState(this.isValidSignature(e,t),"Signature is invalid"),this.setScript(Wk.buildPublicKeyIn(t.signature.toDER(),t.sigtype)),this};ia.prototype.clearSignatures=function(){return this.setScript(Wk.empty()),this};ia.prototype.isFullySigned=function(){return this.script.isPublicKeyIn()};ia.SCRIPT_MAX_SIZE=74;ia.prototype._estimateSize=function(){return Qb.BASE_SIZE+ia.SCRIPT_MAX_SIZE};Yk.exports=ia});var eB=P((Qae,Qk)=>{"use strict";g();var C7=Tc(),Xk=Oe(),L7=ke(),e_=Ac(),M7=fi(),D7=li(),Jk=et(),$k=ut(),q7=Rc();function na(){e_.apply(this,arguments)}C7(na,e_);na.prototype.getSignatures=function(e,t,r,i,n){Xk.checkState(this.output instanceof M7),n=n||L7.sha256ripemd160(t.publicKey.toBuffer()),i=i||$k.SIGHASH_ALL|$k.SIGHASH_FORKID;var o=this.output.script.chunks[2]&&this.output.script.chunks[2].buf;return o&&n.equals(o)?[new q7({publicKey:t.publicKey,prevTxId:this.prevTxId,outputIndex:this.outputIndex,inputIndex:r,signature:D7.sign(e,t,i,r,this.output.script,this.output.satoshisBN),sigtype:i})]:[]};na.prototype.addSignature=function(e,t){return Xk.checkState(this.isValidSignature(e,t),"Signature is invalid"),this.setScript(Jk.buildPublicKeyHashIn(t.publicKey,t.signature.toDER(),t.sigtype)),this};na.prototype.clearSignatures=function(){return this.setScript(Jk.empty()),this};na.prototype.isFullySigned=function(){return this.script.isPublicKeyHashIn()};na.SCRIPT_MAX_SIZE=108;na.prototype._estimateSize=function(){return e_.BASE_SIZE+na.SCRIPT_MAX_SIZE};Qk.exports=na});var iB=P((tse,rB)=>{"use strict";g();var kn=Je(),H7=Tc(),jg=Ac(),U7=fi(),Xl=Oe(),tB=et(),Fg=ut(),t_=li(),r_=Rc(),F7=Gt(),j7=Ic();function Lr(e,t,r,i){jg.apply(this,arguments);var n=this;t=t||e.publicKeys,r=r||e.threshold,i=i||e.signatures,this.publicKeys=t.map(o=>o.toString("hex")).sort().map(o=>new F7(o)),Xl.checkState(tB.buildMultisigOut(this.publicKeys,r).equals(this.output.script),"Provided public keys don't match to the provided output script"),this.publicKeyIndex={},kn.each(this.publicKeys,function(o,a){n.publicKeyIndex[o.toString()]=a}),this.threshold=r,this.signatures=i?this._deserializeSignatures(i):new Array(this.publicKeys.length)}H7(Lr,jg);Lr.prototype.toObject=function(){var e=jg.prototype.toObject.apply(this,arguments);return e.threshold=this.threshold,e.publicKeys=kn.map(this.publicKeys,function(t){return t.toString()}),e.signatures=this._serializeSignatures(),e};Lr.prototype._deserializeSignatures=function(e){return kn.map(e,function(t){if(t)return new r_(t)})};Lr.prototype._serializeSignatures=function(){return kn.map(this.signatures,function(e){if(e)return e.toObject()})};Lr.prototype.getSignatures=function(e,t,r,i){Xl.checkState(this.output instanceof U7),i=i||Fg.SIGHASH_ALL|Fg.SIGHASH_FORKID;var n=this,o=[];return kn.each(this.publicKeys,function(a){a.toString()===t.publicKey.toString()&&o.push(new r_({publicKey:t.publicKey,prevTxId:n.prevTxId,outputIndex:n.outputIndex,inputIndex:r,signature:t_.sign(e,t,i,r,n.output.script,n.output.satoshisBN),sigtype:i}))}),o};Lr.prototype.addSignature=function(e,t){return Xl.checkState(!this.isFullySigned(),"All needed signatures have already been added"),Xl.checkArgument(!kn.isUndefined(this.publicKeyIndex[t.publicKey.toString()]),"Signature has no matching public key"),Xl.checkState(this.isValidSignature(e,t)),this.signatures[this.publicKeyIndex[t.publicKey.toString()]]=t,this._updateScript(),this};Lr.prototype._updateScript=function(){return this.setScript(tB.buildMultisigIn(this.publicKeys,this.threshold,this._createSignatures())),this};Lr.prototype._createSignatures=function(){return kn.map(kn.filter(this.signatures,function(e){return!kn.isUndefined(e)}),function(e){return f.Buffer.concat([e.signature.toDER(),f.Buffer.from([e.sigtype&255])])})};Lr.prototype.clearSignatures=function(){this.signatures=new Array(this.publicKeys.length),this._updateScript()};Lr.prototype.isFullySigned=function(){return this.countSignatures()===this.threshold};Lr.prototype.countMissingSignatures=function(){return this.threshold-this.countSignatures()};Lr.prototype.countSignatures=function(){return kn.reduce(this.signatures,function(e,t){return e+!!t},0)};Lr.prototype.publicKeysWithoutSignature=function(){var e=this;return kn.filter(this.publicKeys,function(t){return!e.signatures[e.publicKeyIndex[t.toString()]]})};Lr.prototype.isValidSignature=function(e,t){return t.signature.nhashtype=t.sigtype,t_.verify(e,t.signature,t.publicKey,t.inputIndex,this.output.script,this.output.satoshisBN)};Lr.normalizeSignatures=function(e,t,r,i,n){return n.map(function(o){var a=null;return i=i.filter(function(s){if(a)return!0;var u=new r_({signature:Fg.fromTxFormat(s),publicKey:o,prevTxId:t.prevTxId,outputIndex:t.outputIndex,inputIndex:r,sigtype:Fg.SIGHASH_ALL});u.signature.nhashtype=u.sigtype;var c=t_.verify(e,u.signature,u.publicKey,u.inputIndex,t.output.script);return c?(a=u,!1):!0}),a||null})};Lr.SIGNATURE_SIZE=73;Lr.prototype._estimateSize=function(){var e=1+this.threshold*Lr.SIGNATURE_SIZE;return jg.BASE_SIZE+j7(e).toBuffer().length+e};rB.exports=Lr});var uB=P((ise,sB)=>{"use strict";g();var Bn=Je(),z7=Tc(),zg=Ac(),K7=fi(),Jl=Oe(),i_=et(),nB=ut(),oB=li(),aB=Rc(),V7=Gt(),G7=Ic();function Ir(e,t,r,i){zg.apply(this,arguments);var n=this;t=t||e.publicKeys,r=r||e.threshold,i=i||e.signatures,this.publicKeys=t.map(o=>o.toString("hex")).sort().map(o=>new V7(o)),this.redeemScript=i_.buildMultisigOut(this.publicKeys,r),Jl.checkState(i_.buildScriptHashOut(this.redeemScript).equals(this.output.script),"Provided public keys don't hash to the provided output"),this.publicKeyIndex={},Bn.each(this.publicKeys,function(o,a){n.publicKeyIndex[o.toString()]=a}),this.threshold=r,this.signatures=i?this._deserializeSignatures(i):new Array(this.publicKeys.length)}z7(Ir,zg);Ir.prototype.toObject=function(){var e=zg.prototype.toObject.apply(this,arguments);return e.threshold=this.threshold,e.publicKeys=Bn.map(this.publicKeys,function(t){return t.toString()}),e.signatures=this._serializeSignatures(),e};Ir.prototype._deserializeSignatures=function(e){return Bn.map(e,function(t){if(t)return new aB(t)})};Ir.prototype._serializeSignatures=function(){return Bn.map(this.signatures,function(e){if(e)return e.toObject()})};Ir.prototype.getSignatures=function(e,t,r,i){Jl.checkState(this.output instanceof K7),i=i||nB.SIGHASH_ALL|nB.SIGHASH_FORKID;var n=this,o=[];return Bn.each(this.publicKeys,function(a){a.toString()===t.publicKey.toString()&&o.push(new aB({publicKey:t.publicKey,prevTxId:n.prevTxId,outputIndex:n.outputIndex,inputIndex:r,signature:oB.sign(e,t,i,r,n.redeemScript,n.output.satoshisBN),sigtype:i}))}),o};Ir.prototype.addSignature=function(e,t){return Jl.checkState(!this.isFullySigned(),"All needed signatures have already been added"),Jl.checkArgument(!Bn.isUndefined(this.publicKeyIndex[t.publicKey.toString()]),"Signature has no matching public key"),Jl.checkState(this.isValidSignature(e,t)),this.signatures[this.publicKeyIndex[t.publicKey.toString()]]=t,this._updateScript(),this};Ir.prototype._updateScript=function(){return this.setScript(i_.buildP2SHMultisigIn(this.publicKeys,this.threshold,this._createSignatures(),{cachedMultisig:this.redeemScript})),this};Ir.prototype._createSignatures=function(){return Bn.map(Bn.filter(this.signatures,function(e){return!Bn.isUndefined(e)}),function(e){return f.Buffer.concat([e.signature.toDER(),f.Buffer.from([e.sigtype&255])])})};Ir.prototype.clearSignatures=function(){this.signatures=new Array(this.publicKeys.length),this._updateScript()};Ir.prototype.isFullySigned=function(){return this.countSignatures()===this.threshold};Ir.prototype.countMissingSignatures=function(){return this.threshold-this.countSignatures()};Ir.prototype.countSignatures=function(){return Bn.reduce(this.signatures,function(e,t){return e+!!t},0)};Ir.prototype.publicKeysWithoutSignature=function(){var e=this;return Bn.filter(this.publicKeys,function(t){return!e.signatures[e.publicKeyIndex[t.toString()]]})};Ir.prototype.isValidSignature=function(e,t){return t.signature.nhashtype=t.sigtype,oB.verify(e,t.signature,t.publicKey,t.inputIndex,this.redeemScript,this.output.satoshisBN)};Ir.SIGNATURE_SIZE=73;Ir.PUBKEY_SIZE=34;Ir.prototype._estimateSize=function(){var e=this.publicKeys.length*Ir.PUBKEY_SIZE,t=this.threshold*Ir.SIGNATURE_SIZE,r=3+e,i=r<=75?1:r<=255?2:3,n=t+1+i+r;return zg.BASE_SIZE+G7(n).toBuffer().length+n};sB.exports=Ir});var ao=P((ose,kc)=>{g();kc.exports=Ac();kc.exports.PublicKey=Zk();kc.exports.PublicKeyHash=eB();kc.exports.MultiSig=iB();kc.exports.MultiSigScriptHash=uB()});var li=P((sse,dB)=>{"use strict";g();var W7=jt(),Pi=ut(),Ql=et(),Y7=fi(),Z7=oo(),eh=Tn(),cB=Ye(),Kg=ke(),fB=cn(),n_=Oe(),o_=un(),Ya=Je(),lB=f.Buffer.from("0000000000000000000000000000000000000000000000000000000000000001","hex"),$7="ffffffffffffffff",X7=o_.SCRIPT_ENABLE_SIGHASH_FORKID,J7=function(e,t,r,i,n){var o=e.inputs[r];n_.checkArgument(n instanceof cB,"For ForkId=0 signatures, satoshis or complete input must be provided");function a(R){var B=new eh;Ya.each(R.inputs,function(I){B.writeReverse(I.prevTxId),B.writeUInt32LE(I.outputIndex)});var H=B.toBuffer(),j=Kg.sha256sha256(H);return j}function s(R){var B=new eh;Ya.each(R.inputs,function(I){B.writeUInt32LE(I.sequenceNumber)});var H=B.toBuffer(),j=Kg.sha256sha256(H);return j}function u(R,B){var H=new eh;Ya.isUndefined(B)?Ya.each(R.outputs,function(k){k.toBufferWriter(H)}):R.outputs[B].toBufferWriter(H);var j=H.toBuffer(),I=Kg.sha256sha256(j);return I}var c=f.Buffer.alloc(32),l=f.Buffer.alloc(32),d=f.Buffer.alloc(32);t&Pi.SIGHASH_ANYONECANPAY||(c=a(e)),!(t&Pi.SIGHASH_ANYONECANPAY)&&(t&31)!==Pi.SIGHASH_SINGLE&&(t&31)!==Pi.SIGHASH_NONE&&(l=s(e)),(t&31)!==Pi.SIGHASH_SINGLE&&(t&31)!==Pi.SIGHASH_NONE?d=u(e):(t&31)===Pi.SIGHASH_SINGLE&&r<e.outputs.length&&(d=u(e,r));var p=new eh;p.writeInt32LE(e.version),p.write(c),p.write(l),p.writeReverse(o.prevTxId),p.writeUInt32LE(o.outputIndex);var y=i.toBuffer();p.writeVarintNum(y.length),p.write(y),p.writeUInt64LEBN(n);var _=o.sequenceNumber;p.writeUInt32LE(_),p.write(d),p.writeUInt32LE(e.nLockTime),p.writeUInt32LE(t>>>0);var T=p.toBuffer();return T},hB=function(t,r,i,n,o,a){var s=s_(),u=ao();Ya.isUndefined(a)&&(a=X7);var c=s.shallowCopy(t);if(n instanceof Ql||(n=new Ql(n)),a&o_.SCRIPT_ENABLE_REPLAY_PROTECTION){var l=r>>8,d=16711680|l^57005;r=d<<8|r&255}if(r&Pi.SIGHASH_FORKID&&!(r&Pi.SIGHASH_CHRONICLE)&&a&o_.SCRIPT_ENABLE_SIGHASH_FORKID)return J7(c,r,i,n,o);n=new Ql(n),n.removeCodeseparators();var p;for(p=0;p<c.inputs.length;p++)c.inputs[p]=new u(c.inputs[p]).setScript(Ql.empty());if(c.inputs[i]=new u(c.inputs[i]).setScript(n),(r&31)===Pi.SIGHASH_NONE||(r&31)===Pi.SIGHASH_SINGLE)for(p=0;p<c.inputs.length;p++)p!==i&&(c.inputs[p].sequenceNumber=0);if((r&31)===Pi.SIGHASH_NONE)c.outputs=[];else if((r&31)===Pi.SIGHASH_SINGLE){if(i>=c.outputs.length)return lB;for(c.outputs.length=i+1,p=0;p<i;p++)c.outputs[p]=new Y7({satoshis:cB.fromBuffer(W7.Buffer.from($7,"hex")),script:Ql.empty()})}r&Pi.SIGHASH_ANYONECANPAY&&(c.inputs=[c.inputs[i]]);var y=new eh().write(c.toBuffer()).writeInt32LE(r).toBuffer();return y},a_=function(t,r,i,n,o,a){var s=hB(t,r,i,n,o,a);if(s.compare(lB)===0)return s;var u=Kg.sha256sha256(s);return u=new Z7(u).readReverse(),u};function Q7(e,t,r,i,n,o,a){var s=a_(e,r,i,n,o,a),u=fB.sign(s,t,"little").set({nhashtype:r});return u}function e9(e,t,r,i,n,o,a){n_.checkArgument(!Ya.isUndefined(e)),n_.checkArgument(!Ya.isUndefined(t)&&!Ya.isUndefined(t.nhashtype));var s=a_(e,t.nhashtype,i,n,o,a);return fB.verify(s,t,r,"little")}dB.exports={sighashPreimage:hB,sighash:a_,sign:Q7,verify:e9}});var u_=P((cse,gB)=>{"use strict";g();var oa=Je(),Vg=Oe(),pB=ei(),t9=et(),r9=Ti();function aa(e){if(!(this instanceof aa))return new aa(e);Vg.checkArgument(oa.isObject(e),"Must provide an object from where to extract data");var t=e.address?new r9(e.address):void 0,r=e.txid?e.txid:e.txId;if(!r||!pB.isHexaString(r)||r.length>64)throw new Error("Invalid TXID in object",e);var i=oa.isUndefined(e.vout)?e.outputIndex:e.vout;if(!oa.isNumber(i))throw new Error("Invalid outputIndex, received "+i);Vg.checkArgument(!oa.isUndefined(e.scriptPubKey)||!oa.isUndefined(e.script),"Must provide the scriptPubKey for that output!");var n=new t9(e.scriptPubKey||e.script);Vg.checkArgument(!oa.isUndefined(e.amount)||!oa.isUndefined(e.satoshis),"Must provide an amount for the output");var o=oa.isUndefined(e.amount)?e.satoshis:Math.round(e.amount*1e8);Vg.checkArgument(oa.isNumber(o),"Amount must be a number"),pB.defineImmutable(this,{address:t,txId:r,outputIndex:i,script:n,satoshis:o})}aa.prototype.inspect=function(){return"<UnspentOutput: "+this.txId+":"+this.outputIndex+", satoshis: "+this.satoshis+", address: "+this.address+">"};aa.prototype.toString=function(){return this.txId+":"+this.outputIndex};aa.fromObject=function(e){return new aa(e)};aa.prototype.toObject=aa.prototype.toJSON=function(){return{address:this.address?this.address.toString():void 0,txid:this.txId,vout:this.outputIndex,scriptPubKey:this.script.toBuffer().toString("hex"),amount:Number.parseFloat((this.satoshis/1e8).toFixed(8))}};gB.exports=aa});var s_=P((lse,EB)=>{"use strict";g();var Ie=Je(),Yr=Oe(),i9=jt(),Dr=ci(),vB=ei(),yB=oo(),n9=Tn(),mB=Ic(),bB=ke(),Wg=ut(),_B=li(),o9=Ti(),wB=u_(),Mr=ao(),a9=Mr.PublicKeyHash,s9=Mr.PublicKey,u9=Mr.MultiSigScriptHash,c9=Mr.MultiSig,Nn=fi(),so=et(),f9=Zr(),Gg=Ye(),l9=un(),h9=l9.SCRIPT_ENABLE_SIGHASH_FORKID;function oe(e){if(!(this instanceof oe))return new oe(e);if(this.inputs=[],this.outputs=[],this._inputAmount=void 0,this._outputAmount=void 0,e){if(e instanceof oe)return oe.shallowCopy(e);if(vB.isHexa(e))this.fromString(e);else if(f.Buffer.isBuffer(e))this.fromBuffer(e);else if(Ie.isObject(e))this.fromObject(e);else throw new Dr.InvalidArgument("Must provide an object or string to deserialize a transaction")}else this._newTransaction()}var d9=1,p9=0,g9=1e6;oe.DUST_AMOUNT=546;oe.FEE_SECURITY_MARGIN=150;oe.MAX_MONEY=21e6*1e8;oe.NLOCKTIME_BLOCKHEIGHT_LIMIT=5e8;oe.NLOCKTIME_MAX_VALUE=4294967295;oe.FEE_PER_KB=500;oe.CHANGE_OUTPUT_MAX_SIZE=62;oe.shallowCopy=function(e){var t=new oe(e.toBuffer());return t};var SB={configurable:!1,enumerable:!0,get:function(){return this._hash=new yB(this._getHash()).readReverse().toString("hex"),this._hash}};Object.defineProperty(oe.prototype,"hash",SB);Object.defineProperty(oe.prototype,"id",SB);var c_={configurable:!1,enumerable:!0,get:function(){return this._getInputAmount()}};Object.defineProperty(oe.prototype,"inputAmount",c_);c_.get=function(){return this._getOutputAmount()};Object.defineProperty(oe.prototype,"outputAmount",c_);oe.prototype._getHash=function(){return bB.sha256sha256(this.toBuffer())};oe.prototype.serialize=function(e){return e===!0||e&&e.disableAll?this.uncheckedSerialize():this.checkedSerialize(e)};oe.prototype.uncheckedSerialize=oe.prototype.toString=function(){return this.toBuffer().toString("hex")};oe.prototype.checkedSerialize=function(e){var t=this.getSerializationError(e);if(t)throw t.message+=" - For more information please see: https://bsv.io/api/lib/transaction#serialization-checks",t;return this.uncheckedSerialize()};oe.prototype.invalidSatoshis=function(){for(var e=!1,t=0;t<this.outputs.length;t++)this.outputs[t].invalidSatoshis()&&(e=!0);return e};oe.prototype.getSerializationError=function(e){if(e=e||{},this.invalidSatoshis())return new Dr.Transaction.InvalidSatoshis;var t=this._getUnspentValue(),r;return t<0?e.disableMoreOutputThanInput||(r=new Dr.Transaction.InvalidOutputAmountSum):r=this._hasFeeError(e,t),r||this._hasDustOutputs(e)||this._isMissingSignatures(e)};oe.prototype._hasFeeError=function(e,t){if(!Ie.isUndefined(this._fee)&&this._fee!==t)return new Dr.Transaction.FeeError.Different("Unspent value is "+t+" but specified fee is "+this._fee);if(!e.disableLargeFees){var r=Math.floor(oe.FEE_SECURITY_MARGIN*this._estimateFee());if(t>r)return this._missingChange()?new Dr.Transaction.ChangeAddressMissing("Fee is too large and no change address was provided"):new Dr.Transaction.FeeError.TooLarge("expected less than "+r+" but got "+t)}};oe.prototype._missingChange=function(){return!this._changeScript};oe.prototype._hasDustOutputs=function(e){if(!e.disableDustOutputs){var t,r;for(t in this.outputs)if(r=this.outputs[t],r.satoshis<oe.DUST_AMOUNT&&!r.script.isDataOut()&&!r.script.isSafeDataOut())return new Dr.Transaction.DustOutputs}};oe.prototype._isMissingSignatures=function(e){if(!e.disableIsFullySigned&&!this.isFullySigned())return new Dr.Transaction.MissingSignatures};oe.prototype.inspect=function(){return"<Transaction: "+this.uncheckedSerialize()+">"};oe.prototype.toBuffer=function(){var e=new n9;return this.toBufferWriter(e).toBuffer()};oe.prototype.toBufferWriter=function(e){return e.writeInt32LE(this.version),e.writeVarintNum(this.inputs.length),Ie.each(this.inputs,function(t){t.toBufferWriter(e)}),e.writeVarintNum(this.outputs.length),Ie.each(this.outputs,function(t){t.toBufferWriter(e)}),e.writeUInt32LE(this.nLockTime),e};oe.prototype.fromBuffer=function(e){var t=new yB(e);return this.fromBufferReader(t)};oe.prototype.fromBufferReader=function(e){Yr.checkArgument(!e.finished(),"No transaction data received");var t,r,i;for(this.version=e.readInt32LE(),r=e.readVarintNum(),t=0;t<r;t++){var n=Mr.fromBufferReader(e);this.inputs.push(n)}for(i=e.readVarintNum(),t=0;t<i;t++)this.outputs.push(Nn.fromBufferReader(e));return this.nLockTime=e.readUInt32LE(),this};oe.prototype.toObject=oe.prototype.toJSON=function(){var t=[];this.inputs.forEach(function(n){t.push(n.toObject())});var r=[];this.outputs.forEach(function(n){r.push(n.toObject())});var i={hash:this.hash,version:this.version,inputs:t,outputs:r,nLockTime:this.nLockTime};return this._changeScript&&(i.changeScript=this._changeScript.toString()),Ie.isUndefined(this._changeIndex)||(i.changeIndex=this._changeIndex),Ie.isUndefined(this._fee)||(i.fee=this._fee),i};oe.prototype.fromObject=function(t){Yr.checkArgument(Ie.isObject(t)||t instanceof oe);var r=this,i;return t instanceof oe?i=t.toObject():i=t,Ie.each(i.inputs,function(n){if(!n.output||!n.output.script){r.uncheckedAddInput(new Mr(n));return}var o=new so(n.output.script),a;if(o.isPublicKeyHashOut())a=new Mr.PublicKeyHash(n);else if(o.isScriptHashOut()&&n.publicKeys&&n.threshold)a=new Mr.MultiSigScriptHash(n,n.publicKeys,n.threshold,n.signatures);else if(o.isPublicKeyOut())a=new Mr.PublicKey(n);else throw new Dr.Transaction.Input.UnsupportedScript(n.output.script);r.addInput(a)}),Ie.each(i.outputs,function(n){r.addOutput(new Nn(n))}),i.changeIndex&&(this._changeIndex=i.changeIndex),i.changeScript&&(this._changeScript=new so(i.changeScript)),i.fee&&(this._fee=i.fee),this.nLockTime=i.nLockTime,this.version=i.version,this._checkConsistency(t),this};oe.prototype._checkConsistency=function(e){Ie.isUndefined(this._changeIndex)||(Yr.checkState(this._changeScript,"Change script is expected."),Yr.checkState(this.outputs[this._changeIndex],"Change index points to undefined output."),Yr.checkState(this.outputs[this._changeIndex].script.toString()===this._changeScript.toString(),"Change output has an unexpected script.")),e&&e.hash&&Yr.checkState(e.hash===this.hash,"Hash in object does not match transaction hash.")};oe.prototype.lockUntilDate=function(e){if(Yr.checkArgument(e),Ie.isNumber(e)&&e<oe.NLOCKTIME_BLOCKHEIGHT_LIMIT)throw new Dr.Transaction.LockTimeTooEarly;Ie.isDate(e)&&(e=e.getTime()/1e3);for(var t=0;t<this.inputs.length;t++)this.inputs[t].sequenceNumber===Mr.DEFAULT_SEQNUMBER&&(this.inputs[t].sequenceNumber=Mr.DEFAULT_LOCKTIME_SEQNUMBER);return this.nLockTime=e,this};oe.prototype.lockUntilBlockHeight=function(e){if(Yr.checkArgument(Ie.isNumber(e)),e>=oe.NLOCKTIME_BLOCKHEIGHT_LIMIT)throw new Dr.Transaction.BlockHeightTooHigh;if(e<0)throw new Dr.Transaction.NLockTimeOutOfRange;for(var t=0;t<this.inputs.length;t++)this.inputs[t].sequenceNumber===Mr.DEFAULT_SEQNUMBER&&(this.inputs[t].sequenceNumber=Mr.DEFAULT_LOCKTIME_SEQNUMBER);return this.nLockTime=e,this};oe.prototype.getLockTime=function(){return this.nLockTime?this.nLockTime<oe.NLOCKTIME_BLOCKHEIGHT_LIMIT?this.nLockTime:new Date(1e3*this.nLockTime):null};oe.prototype.fromString=function(e){this.fromBuffer(i9.Buffer.from(e,"hex"))};oe.prototype._newTransaction=function(){this.version=d9,this.nLockTime=p9};oe.prototype.from=function(e,t,r){if(Ie.isArray(e)){var i=this;return Ie.each(e,function(o){i.from(o,t,r)}),this}var n=Ie.some(this.inputs,function(o){return o.prevTxId.toString("hex")===e.txId&&o.outputIndex===e.outputIndex});return n?this:(t&&r?this._fromMultisigUtxo(e,t,r):this._fromNonP2SH(e),this)};oe.prototype._fromNonP2SH=function(e){var t;e=new wB(e),e.script.isPublicKeyHashOutPrefix()?t=a9:e.script.isPublicKeyOut()?t=s9:t=Mr,this.addInput(new t({output:new Nn({script:e.script,satoshis:e.satoshis}),prevTxId:e.txId,outputIndex:e.outputIndex,script:so.empty()}))};oe.prototype._fromMultisigUtxo=function(e,t,r){Yr.checkArgument(r<=t.length,"Number of required signatures must be greater than the number of public keys");var i;if(e=new wB(e),e.script.isMultisigOut())i=c9;else if(e.script.isScriptHashOut())i=u9;else throw new Dr.Transaction.Input.UnsupportedScript(e.script.toString());this.addInput(new i({output:new Nn({script:e.script,satoshis:e.satoshis}),prevTxId:e.txId,outputIndex:e.outputIndex,script:so.empty()},t,r))};oe.prototype.addInput=function(e,t,r){if(Yr.checkArgumentType(e,Mr,"input"),!e.output&&(Ie.isUndefined(t)||Ie.isUndefined(r)))throw new Dr.Transaction.NeedMoreInfo("Need information about the UTXO script and satoshis");return!e.output&&t&&!Ie.isUndefined(r)&&(t=t instanceof so?t:new so(t),Yr.checkArgumentType(r,"number","satoshis"),e.output=new Nn({script:t,satoshis:r})),this.uncheckedAddInput(e)};oe.prototype.uncheckedAddInput=function(e){return Yr.checkArgumentType(e,Mr,"input"),this.inputs.push(e),this._inputAmount=void 0,this._updateChangeOutput(),this};oe.prototype.hasAllUtxoInfo=function(){return Ie.every(this.inputs.map(function(e){return!!e.output}))};oe.prototype.fee=function(e){return Yr.checkArgument(Ie.isNumber(e),"amount must be a number"),this._fee=e,this._updateChangeOutput(),this};oe.prototype.feePerKb=function(e){return Yr.checkArgument(Ie.isNumber(e),"amount must be a number"),this._feePerKb=e,this._updateChangeOutput(),this};oe.prototype.change=function(e){return Yr.checkArgument(e,"address is required"),this._changeScript=so.fromAddress(e),this._updateChangeOutput(),this};oe.prototype.getChangeOutput=function(){return Ie.isUndefined(this._changeIndex)?null:this.outputs[this._changeIndex]};oe.prototype.to=function(e,t){if(Ie.isArray(e)){var r=this;return Ie.each(e,function(i){r.to(i.address,i.satoshis)}),this}return Yr.checkArgument(vB.isNaturalNumber(t),"Amount is expected to be a positive integer"),this.addOutput(new Nn({script:so(new o9(e)),satoshis:t})),this};oe.prototype.addData=function(e){return this.addOutput(new Nn({script:so.buildDataOut(e),satoshis:0})),this};oe.prototype.addSafeData=function(e){return this.addOutput(new Nn({script:so.buildSafeDataOut(e),satoshis:0})),this};oe.prototype.addOutput=function(e){return Yr.checkArgumentType(e,Nn,"output"),this._addOutput(e),this._updateChangeOutput(),this};oe.prototype.clearOutputs=function(){return this.outputs=[],this._clearSignatures(),this._outputAmount=void 0,this._changeIndex=void 0,this._updateChangeOutput(),this};oe.prototype._addOutput=function(e){this.outputs.push(e),this._outputAmount=void 0};oe.prototype._getOutputAmount=function(){if(Ie.isUndefined(this._outputAmount)){var e=this;this._outputAmount=0,Ie.each(this.outputs,function(t){e._outputAmount+=t.satoshis})}return this._outputAmount};oe.prototype._getInputAmount=function(){if(Ie.isUndefined(this._inputAmount)){var e=this;this._inputAmount=0,Ie.each(this.inputs,function(t){if(Ie.isUndefined(t.output))throw new Dr.Transaction.Input.MissingPreviousOutput;e._inputAmount+=t.output.satoshis})}return this._inputAmount};oe.prototype._updateChangeOutput=function(){if(this._changeScript){this._clearSignatures(),Ie.isUndefined(this._changeIndex)||this._removeOutput(this._changeIndex),this._changeIndex=this.outputs.length,this._addOutput(new Nn({script:this._changeScript,satoshis:0}));var e=this._getUnspentValue(),t=this.getFee(),r=e-t;this._removeOutput(this._changeIndex),this._changeIndex=void 0,r>=oe.DUST_AMOUNT&&(this._changeIndex=this.outputs.length,this._addOutput(new Nn({script:this._changeScript,satoshis:r})))}};oe.prototype.getFee=function(){return this.isCoinbase()?0:Ie.isUndefined(this._fee)?this._changeScript?this._estimateFee():this._getUnspentValue():this._fee};oe.prototype._estimateFee=function(){var e=this._estimateSize();return Math.ceil(e/1e3*(this._feePerKb||oe.FEE_PER_KB))};oe.prototype._getUnspentValue=function(){return this._getInputAmount()-this._getOutputAmount()};oe.prototype._clearSignatures=function(){Ie.each(this.inputs,function(e){e.clearSignatures!==Mr.prototype.clearSignatures&&e.clearSignatures()})};oe.prototype._estimateSize=function(){var e=8;return e+=mB(this.inputs.length).toBuffer().length,e+=mB(this.outputs.length).toBuffer().length,Ie.each(this.inputs,function(t){e+=t._estimateSize()}),Ie.each(this.outputs,function(t){e+=t.getSize()}),e};oe.prototype._removeOutput=function(e){var t=this.outputs[e];this.outputs=Ie.without(this.outputs,t),this._outputAmount=void 0};oe.prototype.removeOutput=function(e){this._removeOutput(e),this._updateChangeOutput()};oe.prototype.sort=function(){return this.sortInputs(function(e){var t=Array.prototype.concat.apply([],e);return t.sort(function(r,i){return r.prevTxId.compare(i.prevTxId)||r.outputIndex-i.outputIndex}),t}),this.sortOutputs(function(e){var t=Array.prototype.concat.apply([],e);return t.sort(function(r,i){return r.satoshis-i.satoshis||r.script.toBuffer().compare(i.script.toBuffer())}),t}),this};oe.prototype.shuffleOutputs=function(){return this.sortOutputs(Ie.shuffle)};oe.prototype.sortOutputs=function(e){var t=e(this.outputs);return this._newOutputOrder(t)};oe.prototype.sortInputs=function(e){return this.inputs=e(this.inputs),this._clearSignatures(),this};oe.prototype._newOutputOrder=function(e){var t=this.outputs.length!==e.length||Ie.difference(this.outputs,e).length!==0;if(t)throw new Dr.Transaction.InvalidSorting;if(!Ie.isUndefined(this._changeIndex)){var r=this.outputs[this._changeIndex];this._changeIndex=e.indexOf(r)}return this.outputs=e,this};oe.prototype.removeInput=function(e,t){var r;if(!t&&Ie.isNumber(e)?r=e:r=Ie.findIndex(this.inputs,function(n){return n.prevTxId.toString("hex")===e&&n.outputIndex===t}),r<0||r>=this.inputs.length)throw new Dr.Transaction.InvalidIndex(r,this.inputs.length);var i=this.inputs[r];this.inputs=Ie.without(this.inputs,i),this._inputAmount=void 0,this._updateChangeOutput()};oe.prototype.sign=function(e,t){Yr.checkState(this.hasAllUtxoInfo(),"Not all utxo information is available to sign the transaction.");var r=this;return Ie.isArray(e)?(Ie.each(e,function(i){r.sign(i,t)}),this):(Ie.each(this.getSignatures(e,t),function(i){r.applySignature(i)}),this)};oe.prototype.getSignatures=function(e,t){e=new f9(e),t=t||Wg.SIGHASH_ALL|Wg.SIGHASH_FORKID;var r=this,i=[],n=bB.sha256ripemd160(e.publicKey.toBuffer());return Ie.each(this.inputs,function(a,s){Ie.each(a.getSignatures(r,e,s,t,n),function(u){i.push(u)})}),i};oe.prototype.applySignature=function(e){return this.inputs[e.inputIndex].addSignature(this,e),this};oe.prototype.isFullySigned=function(){return Ie.each(this.inputs,function(e){if(e.isFullySigned===Mr.prototype.isFullySigned)throw new Dr.Transaction.UnableToVerifySignature("Unrecognized script kind, or not enough information to execute script.This usually happens when creating a transaction from a serialized transaction")}),Ie.every(Ie.map(this.inputs,function(e){return e.isFullySigned()}))};oe.prototype.isValidSignature=function(e){var t=this;if(this.inputs[e.inputIndex].isValidSignature===Mr.prototype.isValidSignature)throw new Dr.Transaction.UnableToVerifySignature("Unrecognized script kind, or not enough information to execute script.This usually happens when creating a transaction from a serialized transaction");return this.inputs[e.inputIndex].isValidSignature(t,e)};oe.prototype.verifySignature=function(e,t,r,i,n,o){return _B.verify(this,e,t,r,i,n,o)};oe.prototype.verify=function(){if(this.inputs.length===0)return"transaction txins empty";if(this.outputs.length===0)return"transaction txouts empty";for(var e=new Gg(0),t=0;t<this.outputs.length;t++){var r=this.outputs[t];if(r.invalidSatoshis())return"transaction txout "+t+" satoshis is invalid";if(r._satoshisBN.gt(new Gg(oe.MAX_MONEY,10)))return"transaction txout "+t+" greater than MAX_MONEY";if(e=e.add(r._satoshisBN),e.gt(new Gg(oe.MAX_MONEY)))return"transaction txout "+t+" total output greater than MAX_MONEY"}if(this.toBuffer().length>g9)return"transaction over the maximum block size";var i={};for(t=0;t<this.inputs.length;t++){var n=this.inputs[t],o=n.prevTxId+":"+n.outputIndex;if(!Ie.isUndefined(i[o]))return"transaction input "+t+" duplicate input";i[o]=!0}var a=this.isCoinbase();if(a){var s=this.inputs[0]._scriptBuffer;if(s.length<2||s.length>100)return"coinbase transaction script size invalid"}else for(t=0;t<this.inputs.length;t++)if(this.inputs[t].isNull())return"transaction input "+t+" has null input";return!0};oe.prototype.isCoinbase=function(){return this.inputs.length===1&&this.inputs[0].isNull()};oe.prototype.sighash=function(e,t,r,i,n){t=t||Wg.SIGHASH_ALL|Wg.SIGHASH_FORKID;var o=this.inputs[e];if(!o)throw new Error("Input index "+e+" does not exist");return!r&&o.output&&(r=o.output.script),!i&&o.output&&(i=new Gg(o.output.satoshis)),n=n||h9,_B.sighash(this,t,e,r,i,n)};EB.exports=oe});var Tt=P((dse,Qs)=>{g();Qs.exports=s_();Qs.exports.Input=ao();Qs.exports.Output=fi();Qs.exports.UnspentOutput=u_();Qs.exports.Signature=Rc();Qs.exports.Sighash=li()});var un=P((gse,AB)=>{"use strict";g();var Yg=Je(),Zg=Mg(),U=Or(),Se=Ye(),th=ke(),sa=ut(),f_=Gt();function xB(e){return e.map(function(t){return f.Buffer.isBuffer(t)?f.Buffer.from(t):t})}var M=function e(t){if(!(this instanceof e))return new e(t);t?(this.initialize(),this.set(t)):this.initialize()};M.prototype._verifyCore=function(e,t,r,i,n,o){var a=Tt();if(Yg.isUndefined(r)&&(r=new a),Yg.isUndefined(i)&&(i=0),Yg.isUndefined(n)&&(n=M.currentConsensusFlags(),o||(n&=~M.SCRIPT_ENABLE_SIGHASH_FORKID)),n&M.SCRIPT_ENABLE_SIGHASH_FORKID&&(n|=M.SCRIPT_VERIFY_STRICTENC,!o))throw new Error("internal error - need satoshisBN to verify FORKID transactions");this.set({script:e,tx:r,nin:i,flags:n,satoshisBN:o});var s;if((n&M.SCRIPT_VERIFY_SIGPUSHONLY)!==0&&!e.isPushOnly())return this.errstr="SCRIPT_ERR_SIG_PUSHONLY",!1;if(!this.evaluate())return!1;var u=(n&M.SCRIPT_VERIFY_P2SH)!==0&&(n&M.SCRIPT_UTXO_AFTER_GENESIS)===0;u&&(s=this.stack.slice());var c=this.stack;if(this.initialize(),this.set({script:t,stack:c,tx:r,nin:i,flags:n,satoshisBN:o}),!this.evaluate())return!1;if(this.stack.length===0)return this.errstr="SCRIPT_ERR_EVAL_FALSE_NO_RESULT",!1;var l=this.stack[this.stack.length-1];if(!M.castToBool(l))return this.errstr="SCRIPT_ERR_EVAL_FALSE_IN_STACK",!1;if(u&&t.isScriptHashOut()){if(!e.isPushOnly())return this.errstr="SCRIPT_ERR_SIG_PUSHONLY",!1;if(s.length===0)throw new Error("internal error - stack copy empty");var d=s[s.length-1],p=Zg.fromBuffer(d);if(s.pop(),this.initialize(),this.set({script:p,stack:s,tx:r,nin:i,flags:n,satoshisBN:o}),!this.evaluate())return!1;if(s.length===0)return this.errstr="SCRIPT_ERR_EVAL_FALSE_NO_P2SH_STACK",!1;if(!M.castToBool(s[s.length-1]))return this.errstr="SCRIPT_ERR_EVAL_FALSE_IN_P2SH_STACK",!1}if((n&M.SCRIPT_VERIFY_CLEANSTACK)!==0){if((n&M.SCRIPT_VERIFY_P2SH)===0&&(n&M.SCRIPT_UTXO_AFTER_GENESIS)===0)throw new Error("internal error - CLEANSTACK without P2SH");if(this.stack.length!==1)return this.errstr="SCRIPT_ERR_CLEANSTACK",!1}return!0};AB.exports=M;M.prototype.initialize=function(e){this.stack=[],this.altstack=[],this.pc=0,this.pbegincodehash=0,this.nOpCount=0,this.returned=!1,this.nonTopLevelReturnAfterGenesis=!1,this.vfExec=[],this.vfElse=[],this.errstr="",this.flags=0};M.prototype.set=function(e){this.script=e.script||this.script,this.tx=e.tx||this.tx,this.nin=typeof e.nin<"u"?e.nin:this.nin,this.satoshisBN=e.satoshisBN||this.satoshisBN,this.stack=e.stack||this.stack,this.altstack=e.altstack||this.altstack,this.pc=typeof e.pc<"u"?e.pc:this.pc,this.pbegincodehash=typeof e.pbegincodehash<"u"?e.pbegincodehash:this.pbegincodehash,this.nOpCount=typeof e.nOpCount<"u"?e.nOpCount:this.nOpCount,this.returned=typeof e.returned<"u"?e.returned:this.returned,this.nonTopLevelReturnAfterGenesis=typeof e.nonTopLevelReturnAfterGenesis<"u"?e.nonTopLevelReturnAfterGenesis:this.nonTopLevelReturnAfterGenesis,this.vfExec=e.vfExec||this.vfExec,this.vfElse=e.vfElse||this.vfElse,this.errstr=e.errstr||this.errstr,this.flags=typeof e.flags<"u"?e.flags:this.flags};M.true=f.Buffer.from([1]);M.false=f.Buffer.from([]);M.MAX_SCRIPT_ELEMENT_SIZE=520;M.MAXIMUM_ELEMENT_SIZE=4;M.MAX_OPS_PER_SCRIPT=500;M.MAX_SCRIPT_SIZE=1e4;M.UNLIMITED=Number.MAX_SAFE_INTEGER;M.MAX_SCRIPT_NUM_LENGTH_AFTER_GENESIS=75e4;M.MAX_SCRIPT_NUM_LENGTH_AFTER_CHRONICLE=32e6;M.MAX_PUBKEYS_PER_MULTISIG_AFTER_GENESIS=4294967295;M.MAX_STACK_SIZE=1e3;M.MAX_STACK_MEMORY_USAGE_AFTER_GENESIS=M.UNLIMITED;M.STACK_MEMORY_USAGE_POLICY=100*1024*1024;M.STACK_ELEMENT_OVERHEAD=32;M.LOCKTIME_THRESHOLD=5e8;M.LOCKTIME_THRESHOLD_BN=new Se(M.LOCKTIME_THRESHOLD);M.useGenesisLimits=function(e){return e=e||2147483647,M.MAX_SCRIPT_ELEMENT_SIZE=e,M.MAX_OPS_PER_SCRIPT=e,M.MAX_SCRIPT_SIZE=e,M};M.getLimits=function(){return{maxScriptElementSize:M.MAX_SCRIPT_ELEMENT_SIZE,maximumElementSize:M.MAXIMUM_ELEMENT_SIZE,maxOpsPerScript:M.MAX_OPS_PER_SCRIPT,maxScriptSize:M.MAX_SCRIPT_SIZE}};M.setLimits=function(e){return e=e||{},e.maxScriptElementSize!=null&&(M.MAX_SCRIPT_ELEMENT_SIZE=e.maxScriptElementSize),e.maximumElementSize!=null&&(M.MAXIMUM_ELEMENT_SIZE=e.maximumElementSize),e.maxOpsPerScript!=null&&(M.MAX_OPS_PER_SCRIPT=e.maxOpsPerScript),e.maxScriptSize!=null&&(M.MAX_SCRIPT_SIZE=e.maxScriptSize),M};M.SCRIPT_VERIFY_NONE=0;M.SCRIPT_VERIFY_P2SH=1;M.SCRIPT_VERIFY_STRICTENC=2;M.SCRIPT_VERIFY_DERSIG=4;M.SCRIPT_VERIFY_LOW_S=8;M.SCRIPT_VERIFY_NULLDUMMY=16;M.SCRIPT_VERIFY_SIGPUSHONLY=32;M.SCRIPT_VERIFY_MINIMALDATA=64;M.SCRIPT_VERIFY_DISCOURAGE_UPGRADABLE_NOPS=128;M.SCRIPT_VERIFY_CLEANSTACK=256;M.SCRIPT_VERIFY_CHECKLOCKTIMEVERIFY=512;M.SCRIPT_VERIFY_CHECKSEQUENCEVERIFY=1024;M.SCRIPT_VERIFY_MINIMALIF=8192;M.SCRIPT_VERIFY_NULLFAIL=16384;M.SCRIPT_VERIFY_COMPRESSED_PUBKEYTYPE=32768;M.SCRIPT_ENABLE_SIGHASH_FORKID=65536;M.SCRIPT_ENABLE_REPLAY_PROTECTION=1<<17;M.SCRIPT_ENABLE_MONOLITH_OPCODES=2048;M.SCRIPT_ENABLE_MAGNETIC_OPCODES=4096;M.SCRIPT_GENESIS=1<<18;M.SCRIPT_UTXO_AFTER_GENESIS=1<<19;M.SCRIPT_ENABLE_CHRONICLE=1<<20;M.SCRIPT_CHRONICLE=M.SCRIPT_ENABLE_CHRONICLE;M.SCRIPT_UTXO_AFTER_CHRONICLE=1<<21;M.CHRONICLE_ACTIVATION_HEIGHT=943816;M.ERA_SENSITIVE_ERRORS={SCRIPT_ERR_PUSH_SIZE:{cap:"stack element size (capped at 520 bytes pre-Genesis, unbounded after)",lifts:M.SCRIPT_UTXO_AFTER_GENESIS},SCRIPT_ERR_SCRIPT_SIZE:{cap:"total script size (capped at 10,000 bytes pre-Genesis, unbounded after)",lifts:M.SCRIPT_UTXO_AFTER_GENESIS},SCRIPT_ERR_OP_COUNT:{cap:"opcode count (capped at 201 pre-Genesis, unbounded after)",lifts:M.SCRIPT_UTXO_AFTER_GENESIS},SCRIPT_ERR_SCRIPTNUM_OVERFLOW:{cap:"script number width (4 bytes pre-Genesis, 750,000 after Genesis, 32,000,000 after Chronicle)",lifts:M.SCRIPT_UTXO_AFTER_GENESIS|M.SCRIPT_UTXO_AFTER_CHRONICLE}};M.ERA_FLAGS=M.SCRIPT_GENESIS|M.SCRIPT_UTXO_AFTER_GENESIS|M.SCRIPT_ENABLE_CHRONICLE|M.SCRIPT_UTXO_AFTER_CHRONICLE;M.eraDiagnostics=!(typeof b.default<"u"&&b.default.env&&b.default.env.BSV_NO_ERA_HINT==="1");var l_=!1;M.prototype._eraDiagnose=function(e){if(e!==void 0){var t=M.ERA_SENSITIVE_ERRORS[this.errstr];if(t&&(e&t.lifts)===0){var r=t.cap;this.eraHint=this.errstr+" was produced under PRE-GENESIS limits: "+r+`.
70
70
  The flags passed to verify() (0x`+(e>>>0).toString(16)+`) carry no era bit, so those caps applied regardless of which feature opcodes were enabled.
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.`,M.eraDiagnostics&&!l_&&(l_=!0,console.warn(`
72
72
  [@smartledger/bsv] `+this.eraHint+`